bump @lit-labs/context, fix bug in button card + optimise (#15968)
This commit is contained in:
parent
e0f7544d2f
commit
f19fdeacba
|
@ -45,7 +45,7 @@
|
|||
"@fullcalendar/list": "6.1.5",
|
||||
"@fullcalendar/timegrid": "6.1.5",
|
||||
"@lezer/highlight": "1.1.4",
|
||||
"@lit-labs/context": "0.2.0",
|
||||
"@lit-labs/context": "0.3.0",
|
||||
"@lit-labs/motion": "1.0.3",
|
||||
"@lit-labs/virtualizer": "1.0.1",
|
||||
"@lrnwebcomponents/simple-tooltip": "4.1.0",
|
||||
|
|
|
@ -93,7 +93,7 @@ export const applyThemesOnElement = (
|
|||
}
|
||||
|
||||
// Nothing was changed
|
||||
if (element._themes?.cacheKey === cacheKey) {
|
||||
if (element.__themes?.cacheKey === cacheKey) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ export const applyThemesOnElement = (
|
|||
}
|
||||
}
|
||||
|
||||
if (!element._themes?.keys && !Object.keys(themeRules).length) {
|
||||
if (!element.__themes?.keys && !Object.keys(themeRules).length) {
|
||||
// No styles to reset, and no styles to set
|
||||
return;
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ export const applyThemesOnElement = (
|
|||
: undefined;
|
||||
|
||||
// Add previous set keys to reset them, and new theme
|
||||
const styles = { ...element._themes?.keys, ...newTheme?.styles };
|
||||
element._themes = { cacheKey, keys: newTheme?.keys };
|
||||
const styles = { ...element.__themes?.keys, ...newTheme?.styles };
|
||||
element.__themes = { cacheKey, keys: newTheme?.keys };
|
||||
|
||||
// Set and/or reset styles
|
||||
if (element.updateStyles) {
|
||||
|
|
|
@ -232,7 +232,10 @@ export class HuiButtonCard extends LitElement implements LovelaceCard {
|
|||
|
||||
protected updated(changedProps: PropertyValues): void {
|
||||
super.updated(changedProps);
|
||||
if (!this._config) {
|
||||
if (!this._config || !this._themes) {
|
||||
return;
|
||||
}
|
||||
if (!changedProps.has("_themes") && !changedProps.has("_config")) {
|
||||
return;
|
||||
}
|
||||
const oldThemes = changedProps.get("_themes") as
|
||||
|
@ -243,10 +246,10 @@ export class HuiButtonCard extends LitElement implements LovelaceCard {
|
|||
| undefined;
|
||||
|
||||
if (
|
||||
!oldThemes ||
|
||||
!oldConfig ||
|
||||
oldThemes !== this._themes ||
|
||||
oldConfig.theme !== this._config.theme
|
||||
(changedProps.has("_themes") &&
|
||||
(!oldThemes || oldThemes !== this._themes)) ||
|
||||
(changedProps.has("_config") &&
|
||||
(!oldConfig || oldConfig.theme !== this._config.theme))
|
||||
) {
|
||||
applyThemesOnElement(this, this._themes, this._config.theme);
|
||||
}
|
||||
|
|
|
@ -24,66 +24,62 @@ export const contextMixin = <T extends Constructor<HassBaseEl>>(
|
|||
string,
|
||||
ContextProvider<any> | undefined
|
||||
> = {
|
||||
states: new ContextProvider(
|
||||
this,
|
||||
statesContext,
|
||||
this.hass ? this.hass.states : this._pendingHass.states
|
||||
),
|
||||
entities: new ContextProvider(
|
||||
this,
|
||||
entitiesContext,
|
||||
this.hass ? this.hass.entities : this._pendingHass.entities
|
||||
),
|
||||
devices: new ContextProvider(
|
||||
this,
|
||||
devicesContext,
|
||||
this.hass ? this.hass.devices : this._pendingHass.devices
|
||||
),
|
||||
areas: new ContextProvider(
|
||||
this,
|
||||
areasContext,
|
||||
this.hass ? this.hass.areas : this._pendingHass.areas
|
||||
),
|
||||
localize: new ContextProvider(
|
||||
this,
|
||||
localizeContext,
|
||||
this.hass ? this.hass.localize : this._pendingHass.localize
|
||||
),
|
||||
locale: new ContextProvider(
|
||||
this,
|
||||
localeContext,
|
||||
this.hass ? this.hass.locale : this._pendingHass.locale
|
||||
),
|
||||
config: new ContextProvider(
|
||||
this,
|
||||
configContext,
|
||||
this.hass ? this.hass.config : this._pendingHass.config
|
||||
),
|
||||
themes: new ContextProvider(
|
||||
this,
|
||||
themesContext,
|
||||
this.hass ? this.hass.themes : this._pendingHass.themes
|
||||
),
|
||||
selectedTheme: new ContextProvider(
|
||||
this,
|
||||
selectedThemeContext,
|
||||
this.hass ? this.hass.selectedTheme : this._pendingHass.selectedTheme
|
||||
),
|
||||
user: new ContextProvider(
|
||||
this,
|
||||
userContext,
|
||||
this.hass ? this.hass.user : this._pendingHass.user
|
||||
),
|
||||
userData: new ContextProvider(
|
||||
this,
|
||||
userDataContext,
|
||||
this.hass ? this.hass.userData : this._pendingHass.userData
|
||||
),
|
||||
panels: new ContextProvider(
|
||||
this,
|
||||
panelsContext,
|
||||
this.hass ? this.hass.panels : this._pendingHass.panels
|
||||
),
|
||||
states: new ContextProvider(this, {
|
||||
context: statesContext,
|
||||
initialValue: this.hass ? this.hass.states : this._pendingHass.states,
|
||||
}),
|
||||
entities: new ContextProvider(this, {
|
||||
context: entitiesContext,
|
||||
initialValue: this.hass
|
||||
? this.hass.entities
|
||||
: this._pendingHass.entities,
|
||||
}),
|
||||
devices: new ContextProvider(this, {
|
||||
context: devicesContext,
|
||||
initialValue: this.hass ? this.hass.devices : this._pendingHass.devices,
|
||||
}),
|
||||
areas: new ContextProvider(this, {
|
||||
context: areasContext,
|
||||
initialValue: this.hass ? this.hass.areas : this._pendingHass.areas,
|
||||
}),
|
||||
localize: new ContextProvider(this, {
|
||||
context: localizeContext,
|
||||
initialValue: this.hass
|
||||
? this.hass.localize
|
||||
: this._pendingHass.localize,
|
||||
}),
|
||||
locale: new ContextProvider(this, {
|
||||
context: localeContext,
|
||||
initialValue: this.hass ? this.hass.locale : this._pendingHass.locale,
|
||||
}),
|
||||
config: new ContextProvider(this, {
|
||||
context: configContext,
|
||||
initialValue: this.hass ? this.hass.config : this._pendingHass.config,
|
||||
}),
|
||||
themes: new ContextProvider(this, {
|
||||
context: themesContext,
|
||||
initialValue: this.hass ? this.hass.themes : this._pendingHass.themes,
|
||||
}),
|
||||
selectedTheme: new ContextProvider(this, {
|
||||
context: selectedThemeContext,
|
||||
initialValue: this.hass
|
||||
? this.hass.selectedTheme
|
||||
: this._pendingHass.selectedTheme,
|
||||
}),
|
||||
user: new ContextProvider(this, {
|
||||
context: userContext,
|
||||
initialValue: this.hass ? this.hass.user : this._pendingHass.user,
|
||||
}),
|
||||
userData: new ContextProvider(this, {
|
||||
context: userDataContext,
|
||||
initialValue: this.hass
|
||||
? this.hass.userData
|
||||
: this._pendingHass.userData,
|
||||
}),
|
||||
panels: new ContextProvider(this, {
|
||||
context: panelsContext,
|
||||
initialValue: this.hass ? this.hass.panels : this._pendingHass.panels,
|
||||
}),
|
||||
};
|
||||
|
||||
protected _updateHass(obj: Partial<HomeAssistant>) {
|
||||
|
|
14
yarn.lock
14
yarn.lock
|
@ -1955,13 +1955,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@lit-labs/context@npm:0.2.0":
|
||||
version: 0.2.0
|
||||
resolution: "@lit-labs/context@npm:0.2.0"
|
||||
"@lit-labs/context@npm:0.3.0":
|
||||
version: 0.3.0
|
||||
resolution: "@lit-labs/context@npm:0.3.0"
|
||||
dependencies:
|
||||
"@lit/reactive-element": ^1.5.0
|
||||
lit: ^2.5.0
|
||||
checksum: 0b3d803ba81683d9650ba384e5f138656ecd52d6a54448535e867e0a0ba0cb23e4526ec52e82ed657e9c3598a103c0e8b164bfe927222467e349fb070c770af3
|
||||
lit: ^2.7.0
|
||||
checksum: 85c66a67d12d3a9e3753337ef8f5566789ccacbb98b40b01c79db98ea6186c0bcdb5c16b4a27673cd5b4fb807bf3970c376b8c96797a9b20a78b0681f391efdb
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -9425,7 +9425,7 @@ __metadata:
|
|||
"@fullcalendar/timegrid": 6.1.5
|
||||
"@koa/cors": 4.0.0
|
||||
"@lezer/highlight": 1.1.4
|
||||
"@lit-labs/context": 0.2.0
|
||||
"@lit-labs/context": 0.3.0
|
||||
"@lit-labs/motion": 1.0.3
|
||||
"@lit-labs/virtualizer": 1.0.1
|
||||
"@lrnwebcomponents/simple-tooltip": 4.1.0
|
||||
|
@ -11238,7 +11238,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lit@npm:2.7.0, lit@npm:^2.0.0, lit@npm:^2.0.0-rc.2, lit@npm:^2.2.1, lit@npm:^2.2.8, lit@npm:^2.3.0, lit@npm:^2.5.0":
|
||||
"lit@npm:2.7.0, lit@npm:^2.0.0, lit@npm:^2.0.0-rc.2, lit@npm:^2.2.1, lit@npm:^2.2.8, lit@npm:^2.3.0, lit@npm:^2.5.0, lit@npm:^2.7.0":
|
||||
version: 2.7.0
|
||||
resolution: "lit@npm:2.7.0"
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in New Issue