Update all dependencies
This commit is contained in:
parent
04737e0f46
commit
142d32cd14
|
@ -1,4 +1,5 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
/node_modules
|
||||||
.rpt2_cache/
|
.rpt2_cache/
|
||||||
/dist/**
|
/dist/**
|
||||||
|
|
45
package.json
45
package.json
|
@ -28,39 +28,38 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/custom-cards/button-card#readme",
|
"homepage": "https://github.com/custom-cards/button-card#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.8.7",
|
"@babel/cli": "^7.12.1",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
"@babel/core": "^7.12.3",
|
||||||
"@babel/plugin-proposal-decorators": "^7.8.3",
|
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||||
"@rollup/plugin-commonjs": "^11.0.2",
|
"@babel/plugin-proposal-decorators": "^7.12.1",
|
||||||
|
"@rollup/plugin-babel": "^5.2.1",
|
||||||
|
"@rollup/plugin-commonjs": "^16.0.0",
|
||||||
"@rollup/plugin-json": "^4.0.2",
|
"@rollup/plugin-json": "^4.0.2",
|
||||||
"@rollup/plugin-node-resolve": "^7.1.1",
|
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
"@typescript-eslint/eslint-plugin": "^4.6.1",
|
||||||
"@typescript-eslint/parser": "^2.24.0",
|
"@typescript-eslint/parser": "^4.6.1",
|
||||||
"babel-cli": "^6.26.0",
|
"eslint": "7.12.1",
|
||||||
"eslint": "^6.8.0",
|
|
||||||
"eslint-config-airbnb-base": "^14.1.0",
|
"eslint-config-airbnb-base": "^14.1.0",
|
||||||
"eslint-config-prettier": "^6.10.0",
|
"eslint-config-prettier": "^6.15.0",
|
||||||
"eslint-plugin-import": "^2.20.1",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"eslint-plugin-prettier": "^3.1.2",
|
"eslint-plugin-prettier": "^3.1.2",
|
||||||
"npm": "^6.14.3",
|
"npm": "^6.14.3",
|
||||||
"prettier": "^1.19.0",
|
"prettier": "^2.1.2",
|
||||||
"prettier-eslint": "^9.0.1",
|
"prettier-eslint": "^11.0.0",
|
||||||
"rollup": "^2.1.0",
|
"rollup": "^2.33.1",
|
||||||
"rollup-plugin-babel": "^4.4.0",
|
"rollup-plugin-serve": "^1.1.0",
|
||||||
"rollup-plugin-commonjs": "^10.1.0",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"rollup-plugin-serve": "^1.0.1",
|
"rollup-plugin-typescript2": "^0.29.0",
|
||||||
"rollup-plugin-terser": "^5.3.0",
|
|
||||||
"rollup-plugin-typescript2": "^0.26.0",
|
|
||||||
"ts-lit-plugin": "^1.1.10",
|
"ts-lit-plugin": "^1.1.10",
|
||||||
"typescript": "^3.8.3",
|
"typescript": "^4.0.5",
|
||||||
"typescript-styled-plugin": "^0.15.0"
|
"typescript-styled-plugin": "^0.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ctrl/tinycolor": "^2.6.1",
|
"@ctrl/tinycolor": "^3.1.6",
|
||||||
"@material/mwc-ripple": "^0.15.0",
|
"@material/mwc-ripple": "^0.19.1",
|
||||||
"custom-card-helpers": "^1.6.5",
|
"custom-card-helpers": "^1.6.5",
|
||||||
"fast-copy": "^2.1.0",
|
"fast-copy": "^2.1.0",
|
||||||
"home-assistant-js-websocket": "^5.1.0",
|
"home-assistant-js-websocket": "^5.7.0",
|
||||||
"lit-element": "^2.3.0",
|
"lit-element": "^2.3.0",
|
||||||
"lit-html": "^1.2.0"
|
"lit-html": "^1.2.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||||
import babel from 'rollup-plugin-babel';
|
import babel from '@rollup/plugin-babel';
|
||||||
import { terser } from 'rollup-plugin-terser';
|
import { terser } from 'rollup-plugin-terser';
|
||||||
import serve from 'rollup-plugin-serve';
|
import serve from 'rollup-plugin-serve';
|
||||||
import json from '@rollup/plugin-json';
|
import json from '@rollup/plugin-json';
|
||||||
|
@ -25,6 +25,7 @@ const plugins = [
|
||||||
json(),
|
json(),
|
||||||
babel({
|
babel({
|
||||||
exclude: 'node_modules/**',
|
exclude: 'node_modules/**',
|
||||||
|
babelHelpers: 'bundled',
|
||||||
}),
|
}),
|
||||||
dev && serve(serveopts),
|
dev && serve(serveopts),
|
||||||
!dev &&
|
!dev &&
|
||||||
|
|
|
@ -76,7 +76,7 @@ class ActionHandler extends HTMLElement implements ActionHandler {
|
||||||
this.appendChild(this.ripple);
|
this.appendChild(this.ripple);
|
||||||
this.ripple.primary = true;
|
this.ripple.primary = true;
|
||||||
|
|
||||||
['touchcancel', 'mouseout', 'mouseup', 'touchmove', 'mousewheel', 'wheel', 'scroll'].forEach(ev => {
|
['touchcancel', 'mouseout', 'mouseup', 'touchmove', 'mousewheel', 'wheel', 'scroll'].forEach((ev) => {
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
ev,
|
ev,
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -60,7 +60,7 @@ import * as pjson from '../package.json';
|
||||||
import { deepEqual } from './deep-equal';
|
import { deepEqual } from './deep-equal';
|
||||||
|
|
||||||
let helpers = (window as any).cardHelpers;
|
let helpers = (window as any).cardHelpers;
|
||||||
const helperPromise = new Promise(async resolve => {
|
const helperPromise = new Promise(async (resolve) => {
|
||||||
if (helpers) resolve();
|
if (helpers) resolve();
|
||||||
if ((window as any).loadCardHelpers) {
|
if ((window as any).loadCardHelpers) {
|
||||||
helpers = await (window as any).loadCardHelpers();
|
helpers = await (window as any).loadCardHelpers();
|
||||||
|
@ -104,7 +104,7 @@ class ButtonCard extends LitElement {
|
||||||
|
|
||||||
public set hass(hass: HomeAssistant) {
|
public set hass(hass: HomeAssistant) {
|
||||||
this._hass = hass;
|
this._hass = hass;
|
||||||
Object.keys(this._cards).forEach(element => {
|
Object.keys(this._cards).forEach((element) => {
|
||||||
const el = this._cards[element];
|
const el = this._cards[element];
|
||||||
el.hass = this._hass;
|
el.hass = this._hass;
|
||||||
});
|
});
|
||||||
|
@ -174,9 +174,7 @@ class ButtonCard extends LitElement {
|
||||||
error: e.toString(),
|
error: e.toString(),
|
||||||
origConfig: this._config,
|
origConfig: this._config,
|
||||||
});
|
});
|
||||||
return html`
|
return html` ${errorCard} `;
|
||||||
${errorCard}
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,12 +242,12 @@ class ButtonCard extends LitElement {
|
||||||
if (!this._config!.state) {
|
if (!this._config!.state) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const hasTemplate = this._config!.state.find(elt => elt.operator === 'template');
|
const hasTemplate = this._config!.state.find((elt) => elt.operator === 'template');
|
||||||
if (!state && !hasTemplate) {
|
if (!state && !hasTemplate) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let def: StateConfig | undefined;
|
let def: StateConfig | undefined;
|
||||||
const retval = this._config!.state.find(elt => {
|
const retval = this._config!.state.find((elt) => {
|
||||||
if (elt.operator) {
|
if (elt.operator) {
|
||||||
switch (elt.operator) {
|
switch (elt.operator) {
|
||||||
case '==':
|
case '==':
|
||||||
|
@ -318,7 +316,7 @@ class ButtonCard extends LitElement {
|
||||||
if (['number', 'boolean'].includes(typeof value)) return value;
|
if (['number', 'boolean'].includes(typeof value)) return value;
|
||||||
if (!value) return value;
|
if (!value) return value;
|
||||||
if (['object'].includes(typeof value)) {
|
if (['object'].includes(typeof value)) {
|
||||||
Object.keys(value).forEach(key => {
|
Object.keys(value).forEach((key) => {
|
||||||
value[key] = this._getTemplateOrValue(state, value[key]);
|
value[key] = this._getTemplateOrValue(state, value[key]);
|
||||||
});
|
});
|
||||||
return value;
|
return value;
|
||||||
|
@ -448,7 +446,7 @@ class ButtonCard extends LitElement {
|
||||||
...configStateStyle,
|
...configStateStyle,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Object.keys(style).forEach(key => {
|
Object.keys(style).forEach((key) => {
|
||||||
style[key] = this._getTemplateOrValue(state, style[key]);
|
style[key] = this._getTemplateOrValue(state, style[key]);
|
||||||
});
|
});
|
||||||
return style;
|
return style;
|
||||||
|
@ -476,7 +474,7 @@ class ButtonCard extends LitElement {
|
||||||
...configStateStyle,
|
...configStateStyle,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Object.keys(style).forEach(key => {
|
Object.keys(style).forEach((key) => {
|
||||||
style[key] = this._getTemplateOrValue(state, style[key]);
|
style[key] = this._getTemplateOrValue(state, style[key]);
|
||||||
});
|
});
|
||||||
return style;
|
return style;
|
||||||
|
@ -578,7 +576,7 @@ class ButtonCard extends LitElement {
|
||||||
const fields: any = {};
|
const fields: any = {};
|
||||||
const cards: any = {};
|
const cards: any = {};
|
||||||
if (this._config!.custom_fields) {
|
if (this._config!.custom_fields) {
|
||||||
Object.keys(this._config!.custom_fields).forEach(key => {
|
Object.keys(this._config!.custom_fields).forEach((key) => {
|
||||||
const value = this._config!.custom_fields![key];
|
const value = this._config!.custom_fields![key];
|
||||||
if (!(value as CustomFieldCard).card) {
|
if (!(value as CustomFieldCard).card) {
|
||||||
fields[key] = this._getTemplateOrValue(state, value);
|
fields[key] = this._getTemplateOrValue(state, value);
|
||||||
|
@ -588,7 +586,7 @@ class ButtonCard extends LitElement {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (configState && configState.custom_fields) {
|
if (configState && configState.custom_fields) {
|
||||||
Object.keys(configState.custom_fields).forEach(key => {
|
Object.keys(configState.custom_fields).forEach((key) => {
|
||||||
const value = configState!.custom_fields![key];
|
const value = configState!.custom_fields![key];
|
||||||
if (!(value as CustomFieldCard)!.card) {
|
if (!(value as CustomFieldCard)!.card) {
|
||||||
fields[key] = this._getTemplateOrValue(state, value);
|
fields[key] = this._getTemplateOrValue(state, value);
|
||||||
|
@ -597,7 +595,7 @@ class ButtonCard extends LitElement {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Object.keys(fields).forEach(key => {
|
Object.keys(fields).forEach((key) => {
|
||||||
if (fields[key] != undefined) {
|
if (fields[key] != undefined) {
|
||||||
const customStyle: StyleInfo = {
|
const customStyle: StyleInfo = {
|
||||||
...this._buildCustomStyleGeneric(state, configState, key),
|
...this._buildCustomStyleGeneric(state, configState, key),
|
||||||
|
@ -611,7 +609,7 @@ class ButtonCard extends LitElement {
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.keys(cards).forEach(key => {
|
Object.keys(cards).forEach((key) => {
|
||||||
if (cards[key] != undefined) {
|
if (cards[key] != undefined) {
|
||||||
const customStyle: StyleInfo = {
|
const customStyle: StyleInfo = {
|
||||||
...this._buildCustomStyleGeneric(state, configState, key),
|
...this._buildCustomStyleGeneric(state, configState, key),
|
||||||
|
@ -935,7 +933,7 @@ class ButtonCard extends LitElement {
|
||||||
let result: any = {};
|
let result: any = {};
|
||||||
let mergedStateConfig: StateConfig[] | undefined;
|
let mergedStateConfig: StateConfig[] | undefined;
|
||||||
const tpls = tpl && Array.isArray(tpl) ? tpl : [tpl];
|
const tpls = tpl && Array.isArray(tpl) ? tpl : [tpl];
|
||||||
tpls?.forEach(template => {
|
tpls?.forEach((template) => {
|
||||||
if (!(ll.config.button_card_templates && ll.config.button_card_templates[template]))
|
if (!(ll.config.button_card_templates && ll.config.button_card_templates[template]))
|
||||||
throw new Error(`Button-card template '${template}' is missing!`);
|
throw new Error(`Button-card template '${template}' is missing!`);
|
||||||
const res = this._configFromLLTemplates(ll, ll.config.button_card_templates[template]);
|
const res = this._configFromLLTemplates(ll, ll.config.button_card_templates[template]);
|
||||||
|
@ -1014,7 +1012,7 @@ class ButtonCard extends LitElement {
|
||||||
const entitiesRxp = new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/, 'gm');
|
const entitiesRxp = new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/, 'gm');
|
||||||
const entitiesRxp2 = new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/, 'm');
|
const entitiesRxp2 = new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/, 'm');
|
||||||
const matched = jsonConfig.match(entitiesRxp);
|
const matched = jsonConfig.match(entitiesRxp);
|
||||||
matched?.forEach(match => {
|
matched?.forEach((match) => {
|
||||||
const res = match.match(entitiesRxp2);
|
const res = match.match(entitiesRxp2);
|
||||||
if (res && !this._entities.includes(res[2])) this._entities.push(res[2]);
|
if (res && !this._entities.includes(res[2])) this._entities.push(res[2]);
|
||||||
});
|
});
|
||||||
|
@ -1031,7 +1029,7 @@ class ButtonCard extends LitElement {
|
||||||
|
|
||||||
private _loopGroup(entityList: string[] | undefined): void {
|
private _loopGroup(entityList: string[] | undefined): void {
|
||||||
if (entityList) {
|
if (entityList) {
|
||||||
entityList.forEach(childEntity => {
|
entityList.forEach((childEntity) => {
|
||||||
if (this._hass?.states[childEntity]) {
|
if (this._hass?.states[childEntity]) {
|
||||||
if (computeDomain(childEntity) === 'group' && this._hass.states[childEntity].attributes?.entity_id) {
|
if (computeDomain(childEntity) === 'group' && this._hass.states[childEntity].attributes?.entity_id) {
|
||||||
this._loopGroup(this._hass.states[childEntity].attributes.entity_id);
|
this._loopGroup(this._hass.states[childEntity].attributes.entity_id);
|
||||||
|
@ -1047,7 +1045,7 @@ class ButtonCard extends LitElement {
|
||||||
|
|
||||||
private _expandTriggerGroups(): void {
|
private _expandTriggerGroups(): void {
|
||||||
if (this._hass && this._config?.group_expand && this._entities) {
|
if (this._hass && this._config?.group_expand && this._entities) {
|
||||||
this._entities.forEach(entity => {
|
this._entities.forEach((entity) => {
|
||||||
if (computeDomain(entity) === 'group') {
|
if (computeDomain(entity) === 'group') {
|
||||||
this._loopGroup(this._hass?.states[entity].attributes?.entity_id);
|
this._loopGroup(this._hass?.states[entity].attributes?.entity_id);
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1066,7 @@ class ButtonCard extends LitElement {
|
||||||
if (!configEval) {
|
if (!configEval) {
|
||||||
return configEval;
|
return configEval;
|
||||||
}
|
}
|
||||||
Object.keys(configEval).forEach(key => {
|
Object.keys(configEval).forEach((key) => {
|
||||||
if (typeof configEval[key] === 'object') {
|
if (typeof configEval[key] === 'object') {
|
||||||
configEval[key] = __evalObject(configEval[key]);
|
configEval[key] = __evalObject(configEval[key]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1092,19 +1090,19 @@ class ButtonCard extends LitElement {
|
||||||
// backward compatibility
|
// backward compatibility
|
||||||
@eventOptions({ passive: true })
|
@eventOptions({ passive: true })
|
||||||
private handleRippleActivate(evt?: Event): void {
|
private handleRippleActivate(evt?: Event): void {
|
||||||
this._ripple.then(r => r && r.startPress && this._rippleHandlers.startPress(evt));
|
this._ripple.then((r) => r && r.startPress && this._rippleHandlers.startPress(evt));
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleRippleDeactivate(): void {
|
private handleRippleDeactivate(): void {
|
||||||
this._ripple.then(r => r && r.endPress && this._rippleHandlers.endPress());
|
this._ripple.then((r) => r && r.endPress && this._rippleHandlers.endPress());
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleRippleFocus(): void {
|
private handleRippleFocus(): void {
|
||||||
this._ripple.then(r => r && r.startFocus && this._rippleHandlers.startFocus());
|
this._ripple.then((r) => r && r.startFocus && this._rippleHandlers.startFocus());
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleRippleBlur(): void {
|
private handleRippleBlur(): void {
|
||||||
this._ripple.then(r => r && r.endFocus && this._rippleHandlers.endFocus());
|
this._ripple.then((r) => r && r.endFocus && this._rippleHandlers.endFocus());
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleAction(ev: any): void {
|
private _handleAction(ev: any): void {
|
||||||
|
@ -1157,7 +1155,7 @@ class ButtonCard extends LitElement {
|
||||||
if (this._config!.lock!.exemptions) {
|
if (this._config!.lock!.exemptions) {
|
||||||
if (!this._hass!.user.name || !this._hass!.user.id) return;
|
if (!this._hass!.user.name || !this._hass!.user.id) return;
|
||||||
let matched = false;
|
let matched = false;
|
||||||
this._config!.lock!.exemptions.forEach(e => {
|
this._config!.lock!.exemptions.forEach((e) => {
|
||||||
if (
|
if (
|
||||||
(!matched && (e as ExemptionUserConfig).user === this._hass!.user.id) ||
|
(!matched && (e as ExemptionUserConfig).user === this._hass!.user.id) ||
|
||||||
(e as ExemptionUsernameConfig).username === this._hass!.user.name
|
(e as ExemptionUsernameConfig).username === this._hass!.user.name
|
||||||
|
|
|
@ -13,10 +13,7 @@ export function computeEntity(entityId: string): string {
|
||||||
|
|
||||||
export function getColorFromVariable(color: string): string {
|
export function getColorFromVariable(color: string): string {
|
||||||
if (color.substring(0, 3) === 'var') {
|
if (color.substring(0, 3) === 'var') {
|
||||||
return window
|
return window.getComputedStyle(document.documentElement).getPropertyValue(color.substring(4).slice(0, -1)).trim();
|
||||||
.getComputedStyle(document.documentElement)
|
|
||||||
.getPropertyValue(color.substring(4).slice(0, -1))
|
|
||||||
.trim();
|
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +96,7 @@ export function mergeDeep(...objects: any): any {
|
||||||
const isObject = (obj: any) => obj && typeof obj === 'object';
|
const isObject = (obj: any) => obj && typeof obj === 'object';
|
||||||
|
|
||||||
return objects.reduce((prev: any, obj: any) => {
|
return objects.reduce((prev: any, obj: any) => {
|
||||||
Object.keys(obj).forEach(key => {
|
Object.keys(obj).forEach((key) => {
|
||||||
const pVal = prev[key];
|
const pVal = prev[key];
|
||||||
const oVal = obj[key];
|
const oVal = obj[key];
|
||||||
|
|
||||||
|
@ -123,10 +120,10 @@ export function mergeStatesById(
|
||||||
): StateConfig[] {
|
): StateConfig[] {
|
||||||
let resultStateConfigs: StateConfig[] = [];
|
let resultStateConfigs: StateConfig[] = [];
|
||||||
if (intoStates) {
|
if (intoStates) {
|
||||||
intoStates.forEach(intoState => {
|
intoStates.forEach((intoState) => {
|
||||||
let localState = intoState;
|
let localState = intoState;
|
||||||
if (fromStates) {
|
if (fromStates) {
|
||||||
fromStates.forEach(fromState => {
|
fromStates.forEach((fromState) => {
|
||||||
if (fromState.id && intoState.id && fromState.id == intoState.id)
|
if (fromState.id && intoState.id && fromState.id == intoState.id)
|
||||||
localState = mergeDeep(localState, fromState);
|
localState = mergeDeep(localState, fromState);
|
||||||
});
|
});
|
||||||
|
@ -137,7 +134,7 @@ export function mergeStatesById(
|
||||||
if (fromStates) {
|
if (fromStates) {
|
||||||
/* eslint eqeqeq: 0 no-confusing-arrow: 0 */
|
/* eslint eqeqeq: 0 no-confusing-arrow: 0 */
|
||||||
resultStateConfigs = resultStateConfigs.concat(
|
resultStateConfigs = resultStateConfigs.concat(
|
||||||
fromStates.filter(x => (!intoStates ? true : !intoStates.find(y => (y.id && x.id ? y.id == x.id : false)))),
|
fromStates.filter((x) => (!intoStates ? true : !intoStates.find((y) => (y.id && x.id ? y.id == x.id : false)))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return resultStateConfigs;
|
return resultStateConfigs;
|
||||||
|
|
Loading…
Reference in New Issue