Skip to content

Commit 142d32c

Browse files
committed
Update all dependencies
1 parent 04737e0 commit 142d32c

File tree

7 files changed

+882
-1175
lines changed

7 files changed

+882
-1175
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
/node_modules/
3+
/node_modules
34
.rpt2_cache/
45
/dist/**

package.json

+22-23
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,38 @@
2828
},
2929
"homepage": "https://github.com/custom-cards/button-card#readme",
3030
"devDependencies": {
31-
"@babel/core": "^7.8.7",
32-
"@babel/plugin-proposal-class-properties": "^7.8.3",
33-
"@babel/plugin-proposal-decorators": "^7.8.3",
34-
"@rollup/plugin-commonjs": "^11.0.2",
31+
"@babel/cli": "^7.12.1",
32+
"@babel/core": "^7.12.3",
33+
"@babel/plugin-proposal-class-properties": "^7.12.1",
34+
"@babel/plugin-proposal-decorators": "^7.12.1",
35+
"@rollup/plugin-babel": "^5.2.1",
36+
"@rollup/plugin-commonjs": "^16.0.0",
3537
"@rollup/plugin-json": "^4.0.2",
36-
"@rollup/plugin-node-resolve": "^7.1.1",
37-
"@typescript-eslint/eslint-plugin": "^2.24.0",
38-
"@typescript-eslint/parser": "^2.24.0",
39-
"babel-cli": "^6.26.0",
40-
"eslint": "^6.8.0",
38+
"@rollup/plugin-node-resolve": "^10.0.0",
39+
"@typescript-eslint/eslint-plugin": "^4.6.1",
40+
"@typescript-eslint/parser": "^4.6.1",
41+
"eslint": "7.12.1",
4142
"eslint-config-airbnb-base": "^14.1.0",
42-
"eslint-config-prettier": "^6.10.0",
43-
"eslint-plugin-import": "^2.20.1",
43+
"eslint-config-prettier": "^6.15.0",
44+
"eslint-plugin-import": "^2.22.1",
4445
"eslint-plugin-prettier": "^3.1.2",
4546
"npm": "^6.14.3",
46-
"prettier": "^1.19.0",
47-
"prettier-eslint": "^9.0.1",
48-
"rollup": "^2.1.0",
49-
"rollup-plugin-babel": "^4.4.0",
50-
"rollup-plugin-commonjs": "^10.1.0",
51-
"rollup-plugin-serve": "^1.0.1",
52-
"rollup-plugin-terser": "^5.3.0",
53-
"rollup-plugin-typescript2": "^0.26.0",
47+
"prettier": "^2.1.2",
48+
"prettier-eslint": "^11.0.0",
49+
"rollup": "^2.33.1",
50+
"rollup-plugin-serve": "^1.1.0",
51+
"rollup-plugin-terser": "^7.0.2",
52+
"rollup-plugin-typescript2": "^0.29.0",
5453
"ts-lit-plugin": "^1.1.10",
55-
"typescript": "^3.8.3",
54+
"typescript": "^4.0.5",
5655
"typescript-styled-plugin": "^0.15.0"
5756
},
5857
"dependencies": {
59-
"@ctrl/tinycolor": "^2.6.1",
60-
"@material/mwc-ripple": "^0.15.0",
58+
"@ctrl/tinycolor": "^3.1.6",
59+
"@material/mwc-ripple": "^0.19.1",
6160
"custom-card-helpers": "^1.6.5",
6261
"fast-copy": "^2.1.0",
63-
"home-assistant-js-websocket": "^5.1.0",
62+
"home-assistant-js-websocket": "^5.7.0",
6463
"lit-element": "^2.3.0",
6564
"lit-html": "^1.2.0"
6665
}

rollup.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typescript from 'rollup-plugin-typescript2';
22
import commonjs from '@rollup/plugin-commonjs';
33
import nodeResolve from '@rollup/plugin-node-resolve';
4-
import babel from 'rollup-plugin-babel';
4+
import babel from '@rollup/plugin-babel';
55
import { terser } from 'rollup-plugin-terser';
66
import serve from 'rollup-plugin-serve';
77
import json from '@rollup/plugin-json';
@@ -25,6 +25,7 @@ const plugins = [
2525
json(),
2626
babel({
2727
exclude: 'node_modules/**',
28+
babelHelpers: 'bundled',
2829
}),
2930
dev && serve(serveopts),
3031
!dev &&

src/action-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ActionHandler extends HTMLElement implements ActionHandler {
7676
this.appendChild(this.ripple);
7777
this.ripple.primary = true;
7878

79-
['touchcancel', 'mouseout', 'mouseup', 'touchmove', 'mousewheel', 'wheel', 'scroll'].forEach(ev => {
79+
['touchcancel', 'mouseout', 'mouseup', 'touchmove', 'mousewheel', 'wheel', 'scroll'].forEach((ev) => {
8080
document.addEventListener(
8181
ev,
8282
() => {

src/button-card.ts

+22-24
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import * as pjson from '../package.json';
6060
import { deepEqual } from './deep-equal';
6161

6262
let helpers = (window as any).cardHelpers;
63-
const helperPromise = new Promise(async resolve => {
63+
const helperPromise = new Promise(async (resolve) => {
6464
if (helpers) resolve();
6565
if ((window as any).loadCardHelpers) {
6666
helpers = await (window as any).loadCardHelpers();
@@ -104,7 +104,7 @@ class ButtonCard extends LitElement {
104104

105105
public set hass(hass: HomeAssistant) {
106106
this._hass = hass;
107-
Object.keys(this._cards).forEach(element => {
107+
Object.keys(this._cards).forEach((element) => {
108108
const el = this._cards[element];
109109
el.hass = this._hass;
110110
});
@@ -174,9 +174,7 @@ class ButtonCard extends LitElement {
174174
error: e.toString(),
175175
origConfig: this._config,
176176
});
177-
return html`
178-
${errorCard}
179-
`;
177+
return html` ${errorCard} `;
180178
}
181179
}
182180

@@ -244,12 +242,12 @@ class ButtonCard extends LitElement {
244242
if (!this._config!.state) {
245243
return undefined;
246244
}
247-
const hasTemplate = this._config!.state.find(elt => elt.operator === 'template');
245+
const hasTemplate = this._config!.state.find((elt) => elt.operator === 'template');
248246
if (!state && !hasTemplate) {
249247
return undefined;
250248
}
251249
let def: StateConfig | undefined;
252-
const retval = this._config!.state.find(elt => {
250+
const retval = this._config!.state.find((elt) => {
253251
if (elt.operator) {
254252
switch (elt.operator) {
255253
case '==':
@@ -318,7 +316,7 @@ class ButtonCard extends LitElement {
318316
if (['number', 'boolean'].includes(typeof value)) return value;
319317
if (!value) return value;
320318
if (['object'].includes(typeof value)) {
321-
Object.keys(value).forEach(key => {
319+
Object.keys(value).forEach((key) => {
322320
value[key] = this._getTemplateOrValue(state, value[key]);
323321
});
324322
return value;
@@ -448,7 +446,7 @@ class ButtonCard extends LitElement {
448446
...configStateStyle,
449447
};
450448
}
451-
Object.keys(style).forEach(key => {
449+
Object.keys(style).forEach((key) => {
452450
style[key] = this._getTemplateOrValue(state, style[key]);
453451
});
454452
return style;
@@ -476,7 +474,7 @@ class ButtonCard extends LitElement {
476474
...configStateStyle,
477475
};
478476
}
479-
Object.keys(style).forEach(key => {
477+
Object.keys(style).forEach((key) => {
480478
style[key] = this._getTemplateOrValue(state, style[key]);
481479
});
482480
return style;
@@ -578,7 +576,7 @@ class ButtonCard extends LitElement {
578576
const fields: any = {};
579577
const cards: any = {};
580578
if (this._config!.custom_fields) {
581-
Object.keys(this._config!.custom_fields).forEach(key => {
579+
Object.keys(this._config!.custom_fields).forEach((key) => {
582580
const value = this._config!.custom_fields![key];
583581
if (!(value as CustomFieldCard).card) {
584582
fields[key] = this._getTemplateOrValue(state, value);
@@ -588,7 +586,7 @@ class ButtonCard extends LitElement {
588586
});
589587
}
590588
if (configState && configState.custom_fields) {
591-
Object.keys(configState.custom_fields).forEach(key => {
589+
Object.keys(configState.custom_fields).forEach((key) => {
592590
const value = configState!.custom_fields![key];
593591
if (!(value as CustomFieldCard)!.card) {
594592
fields[key] = this._getTemplateOrValue(state, value);
@@ -597,7 +595,7 @@ class ButtonCard extends LitElement {
597595
}
598596
});
599597
}
600-
Object.keys(fields).forEach(key => {
598+
Object.keys(fields).forEach((key) => {
601599
if (fields[key] != undefined) {
602600
const customStyle: StyleInfo = {
603601
...this._buildCustomStyleGeneric(state, configState, key),
@@ -611,7 +609,7 @@ class ButtonCard extends LitElement {
611609
`;
612610
}
613611
});
614-
Object.keys(cards).forEach(key => {
612+
Object.keys(cards).forEach((key) => {
615613
if (cards[key] != undefined) {
616614
const customStyle: StyleInfo = {
617615
...this._buildCustomStyleGeneric(state, configState, key),
@@ -935,7 +933,7 @@ class ButtonCard extends LitElement {
935933
let result: any = {};
936934
let mergedStateConfig: StateConfig[] | undefined;
937935
const tpls = tpl && Array.isArray(tpl) ? tpl : [tpl];
938-
tpls?.forEach(template => {
936+
tpls?.forEach((template) => {
939937
if (!(ll.config.button_card_templates && ll.config.button_card_templates[template]))
940938
throw new Error(`Button-card template '${template}' is missing!`);
941939
const res = this._configFromLLTemplates(ll, ll.config.button_card_templates[template]);
@@ -1014,7 +1012,7 @@ class ButtonCard extends LitElement {
10141012
const entitiesRxp = new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/, 'gm');
10151013
const entitiesRxp2 = new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/, 'm');
10161014
const matched = jsonConfig.match(entitiesRxp);
1017-
matched?.forEach(match => {
1015+
matched?.forEach((match) => {
10181016
const res = match.match(entitiesRxp2);
10191017
if (res && !this._entities.includes(res[2])) this._entities.push(res[2]);
10201018
});
@@ -1031,7 +1029,7 @@ class ButtonCard extends LitElement {
10311029

10321030
private _loopGroup(entityList: string[] | undefined): void {
10331031
if (entityList) {
1034-
entityList.forEach(childEntity => {
1032+
entityList.forEach((childEntity) => {
10351033
if (this._hass?.states[childEntity]) {
10361034
if (computeDomain(childEntity) === 'group' && this._hass.states[childEntity].attributes?.entity_id) {
10371035
this._loopGroup(this._hass.states[childEntity].attributes.entity_id);
@@ -1047,7 +1045,7 @@ class ButtonCard extends LitElement {
10471045

10481046
private _expandTriggerGroups(): void {
10491047
if (this._hass && this._config?.group_expand && this._entities) {
1050-
this._entities.forEach(entity => {
1048+
this._entities.forEach((entity) => {
10511049
if (computeDomain(entity) === 'group') {
10521050
this._loopGroup(this._hass?.states[entity].attributes?.entity_id);
10531051
}
@@ -1068,7 +1066,7 @@ class ButtonCard extends LitElement {
10681066
if (!configEval) {
10691067
return configEval;
10701068
}
1071-
Object.keys(configEval).forEach(key => {
1069+
Object.keys(configEval).forEach((key) => {
10721070
if (typeof configEval[key] === 'object') {
10731071
configEval[key] = __evalObject(configEval[key]);
10741072
} else {
@@ -1092,19 +1090,19 @@ class ButtonCard extends LitElement {
10921090
// backward compatibility
10931091
@eventOptions({ passive: true })
10941092
private handleRippleActivate(evt?: Event): void {
1095-
this._ripple.then(r => r && r.startPress && this._rippleHandlers.startPress(evt));
1093+
this._ripple.then((r) => r && r.startPress && this._rippleHandlers.startPress(evt));
10961094
}
10971095

10981096
private handleRippleDeactivate(): void {
1099-
this._ripple.then(r => r && r.endPress && this._rippleHandlers.endPress());
1097+
this._ripple.then((r) => r && r.endPress && this._rippleHandlers.endPress());
11001098
}
11011099

11021100
private handleRippleFocus(): void {
1103-
this._ripple.then(r => r && r.startFocus && this._rippleHandlers.startFocus());
1101+
this._ripple.then((r) => r && r.startFocus && this._rippleHandlers.startFocus());
11041102
}
11051103

11061104
private handleRippleBlur(): void {
1107-
this._ripple.then(r => r && r.endFocus && this._rippleHandlers.endFocus());
1105+
this._ripple.then((r) => r && r.endFocus && this._rippleHandlers.endFocus());
11081106
}
11091107

11101108
private _handleAction(ev: any): void {
@@ -1157,7 +1155,7 @@ class ButtonCard extends LitElement {
11571155
if (this._config!.lock!.exemptions) {
11581156
if (!this._hass!.user.name || !this._hass!.user.id) return;
11591157
let matched = false;
1160-
this._config!.lock!.exemptions.forEach(e => {
1158+
this._config!.lock!.exemptions.forEach((e) => {
11611159
if (
11621160
(!matched && (e as ExemptionUserConfig).user === this._hass!.user.id) ||
11631161
(e as ExemptionUsernameConfig).username === this._hass!.user.name

src/helpers.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ export function computeEntity(entityId: string): string {
1313

1414
export function getColorFromVariable(color: string): string {
1515
if (color.substring(0, 3) === 'var') {
16-
return window
17-
.getComputedStyle(document.documentElement)
18-
.getPropertyValue(color.substring(4).slice(0, -1))
19-
.trim();
16+
return window.getComputedStyle(document.documentElement).getPropertyValue(color.substring(4).slice(0, -1)).trim();
2017
}
2118
return color;
2219
}
@@ -99,7 +96,7 @@ export function mergeDeep(...objects: any): any {
9996
const isObject = (obj: any) => obj && typeof obj === 'object';
10097

10198
return objects.reduce((prev: any, obj: any) => {
102-
Object.keys(obj).forEach(key => {
99+
Object.keys(obj).forEach((key) => {
103100
const pVal = prev[key];
104101
const oVal = obj[key];
105102

@@ -123,10 +120,10 @@ export function mergeStatesById(
123120
): StateConfig[] {
124121
let resultStateConfigs: StateConfig[] = [];
125122
if (intoStates) {
126-
intoStates.forEach(intoState => {
123+
intoStates.forEach((intoState) => {
127124
let localState = intoState;
128125
if (fromStates) {
129-
fromStates.forEach(fromState => {
126+
fromStates.forEach((fromState) => {
130127
if (fromState.id && intoState.id && fromState.id == intoState.id)
131128
localState = mergeDeep(localState, fromState);
132129
});
@@ -137,7 +134,7 @@ export function mergeStatesById(
137134
if (fromStates) {
138135
/* eslint eqeqeq: 0 no-confusing-arrow: 0 */
139136
resultStateConfigs = resultStateConfigs.concat(
140-
fromStates.filter(x => (!intoStates ? true : !intoStates.find(y => (y.id && x.id ? y.id == x.id : false)))),
137+
fromStates.filter((x) => (!intoStates ? true : !intoStates.find((y) => (y.id && x.id ? y.id == x.id : false)))),
141138
);
142139
}
143140
return resultStateConfigs;

0 commit comments

Comments
 (0)