Compare commits

..
Author SHA1 Message Date
renovate[bot] d5c9dc89df Update pnpm to v12.25.1 (#56387)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-02 23:52:13 +00:00
renovate[bot] a7d9a8721e Update dependency glob to v14.0.7 (#56386)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-02 23:51:41 +00:00
Paul Bottein 30cf5240a1 Pass the form context to nested forms (#56373) 2026-12-02 23:43:21 +00:00
renovate[bot] 81e088885d Update dependency temporal-polyfill to v1.0.9 (#56379)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-02 20:08:09 +01:00
9 changed files with 195 additions and 313 deletions

No files matched your search

+3 -3
View File
@@ -124,7 +124,7 @@
"sortablejs": "1.15.7",
"stacktrace-js": "2.0.2",
"superstruct": "2.0.2",
"temporal-polyfill": "1.0.8",
"temporal-polyfill": "1.0.9",
"tinykeys": "4.0.1",
"weekstart": "2.0.0",
"workbox-cacheable-response": "7.4.1",
@@ -189,7 +189,7 @@
"fancy-log": "2.0.0",
"fs-extra": "11.4.1",
"generate-license-file": "4.2.5",
"glob": "14.0.6",
"glob": "14.0.7",
"globals": "17.14.0",
"gulp": "5.0.1",
"gulp-json-transform": "0.5.0",
@@ -223,7 +223,7 @@
"webpackbar": "7.0.0",
"workbox-build": "7.4.1"
},
"packageManager": "[email protected]4.0",
"packageManager": "[email protected]5.1",
"volta": {
"node": "24.22.3"
}
+93 -93
View File
@@ -7,172 +7,172 @@ importers:
configDependencies: {}
packageManagerDependencies:
pnpm:
specifier: 12.24.0
version: 12.24.0
specifier: 12.25.1
version: 12.25.1
packages:
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-X22iCSEW/KDoYthnl5DXWv/ikFBuXHx91Gl6sjCcSVVIN3emVFQYkezWzaYYyG/I82e3jXEpZei4ItBGMtxxCA==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-QHXIyWMsuntq05xq9twYS6upQZS2TYeJIfmBWDFw1Xyi8XQxiaD06DSTWwZYjR38GwOP/dveeMC2jk2Y68IAAg==}
cpu: [arm64]
os: [android]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-gRJtKBWbmztU5GEpUIPNR2oHDKljHsyKyUrJK9JBDnwVDdnabVUHCNYeO+wukkiYSvWt7zkRBtOP3IXMDDiNLQ==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-bOJZTzi5c0MrI8xn6qU+0QzYu3gHMUtwLxb8ZRzuk/by7u6XhGXpn+gfppw7BF3te+rxpqK/mSR2PXb40d/7kg==}
cpu: [x64]
os: [android]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-0BT++Bo1b5cHULSRiKAiNwwh5KNFlVvA+qupw+MjhkOfKdVY7iSztUeHqQT3pwkE/Ls3Sv7PhszBdaB7j6T20g==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-NXG2kaXA7ui3T7aznhAmG8AwWZ/BmKkxqT9DIIQJ0jU1jLKkRhGce1gbyJ+RAeGKx0HcRHAJbRi38lcHgpCteA==}
cpu: [arm64]
os: [darwin]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-zRT0h/538rJgoxSaYRccWPVlEh/v/vsE0VhfiOuNCxTnX9GCi//ttM7F+gkb5uD5Anspj52SR1iUU8C3oqmpbw==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-cDnnUeocsg6ESvgjxTs9az5SUt9MEaINaMKGzAEqrfFMCRvaYgkC+0Ct7eYb/41i9WYPvd9DFv8H29LHECwcVA==}
cpu: [x64]
os: [darwin]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-irpbUEPP8LCGlX7SElqZrzcTIZ/B1pgwO0uYlf1DiedVBnsYM9COoWuoXnbudtFpuwCtWGSOOhsMNGGOsiAonA==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-LEDM+BE5BdYEetfEHKSD9f5IhOWmMAHix9bMqhds6dn3cMICNQeJZQaoimwUDeVVAR8yMtvaDwRZGuWXOq5gJw==}
cpu: [x64]
os: [freebsd]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-LCvWPUR1+/EQ/AVp9U1zLKMOo2i0G9+6jSSw1xaL59VR13KEPbTFsKFDO8fmn2o1BAQG5rh9lx+KHVinTSDWpQ==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-LtURUp1sJoS0ENQtKLk+oTI7oSlcEDHl3SOxxS8AUD/FTmP1AM1htwYwxi+91J+MTinOYqcUFrgb1f87Zn1Vfw==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-xSu3krlF1mW+v20odelPYs56om88VGZp6pE0vJKmUtPJ+8EUB6OA4WbVyyxEuqtubhkvFxyZiWDN/cvDKF2OWw==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-55Ni6+zebnL2zdvKq23tZCEWbtPSMKeQ1MwJAwqDqS/VjD/Z6hT0BlJSTFvHKUgrWOBxnH501iTIyQgLVD+Cfw==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-xuIEolHGrT9LbKhLeSrjCT3xlC62kNrEHGjkuUJIHCdgWCRSVoH4Xh0jvVn29/ArKN7aFurqnl8EQoQ7leVJuw==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-52Fzal3IdcqsJ1kChNZC00JoFcwA9tDem/qTuZxpeJcc0KTALXTI5U/LbVF1+OXBfn72ADjS0Hxewkng7Q1iBA==}
cpu: [loong64]
os: [linux]
libc: [glibc]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-OQxi46cY9uc91A6yv7qz6l1NlyVCTsWxbbgk0oKzhMIQuCt+U7OCHcwbfly5Y9FJSsERJVz2MYwVGvy4sgRtPw==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-x3b9VQyrmHi1IIejDGqZWrdmgbtTV/qgE3Sca0NVYmY6gT1cAvkKFq6tQvHJEgeEdny7hGKl+1sk6YkKRs1Sfg==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-uIFs1byuK2ZRcqmb6+9/KddZdHE+JUYM3yjxnN7H+x9A237EoGRnw8UeruWFW9OYMMfFTGRAxuq2b0DiYx4gHQ==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-lPQ5PjYog/N07VsOBEZr661GgZ7y39wQLRCviHcL4RfpMBpe4XeJKK3W7YKl9NJz6+5/nzMYYfTcvZPFLWuMvA==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-Ct1ggli4DyL/LnasrhqgEc8PDlzmhKx0DculRiWygyN+STzQWA/qwHtuMzgbLQd84CNUJGZfTrUkBYaXmLifKw==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-5kdJeOXns1O/PYqdR2Zk/0ci/0mCz1LhaJDIA6NiqNdgFxwCC6ufRTBiu9u4FB/F2MWBLPDtyHxwzpcbBFCP9Q==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-NeIW64Azg/b+QFj6Z14BYb84pUKVIrvf15JhhuV7YmouaZbiMRG/8nDwIvEIRvwLqXacd4gVdcsGqUcO7oIYhQ==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-GRsFj54bSmdhceZwrA+zReMfGJw6X6qpC4pJh6iLaUcy3p0fG7A7Zqr70AKmtzvW1Zm2VGkeeIzja6QSkN09Vw==}
cpu: [x64]
os: [linux]
libc: [musl]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-5As5an12DTY8MlssTLCaMtRDYpn9C3hxcasEDCJQC0VqS6ZnRmlLWsL8dI0ocqdh3ejW6o6F0esucP5MECo1nA==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-Db2T6CtSNO8hjG6FISkOaZ2PW/OpynoXcT+jWEh44xDgSBt68rgbjGIbzjXSKJ+vH2mkoUxaUZCcLLusBVqelw==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-bZxzTQU8hqBoLzjb6VELvxJNDnWUrNf3/xSbl7ewIPfVgvs8+R77Rc+30ynxWndr3tD6zJB/iEYIdxuGZB/bnQ==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-2hU5yNM/C8FT5eqbrNzB+0yGw/SS3oMJ1afk8pXEDsGU4vWdiiWxSqQ0kM8GHIvCDa/qRyw9ns98XWu5KZxxiA==}
cpu: [x64]
os: [netbsd]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-TzhbjiypYbZ7HejRPjxzJreWVymMFtxcm9pvxOY7DUCmYxEcOqR0iJruzLXJL7STJ6O+KrpwpcybmiKPrhOZyg==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-v7YduE+TgEid1AiIThVBmYBnF0dj6vtk3ymcCkcM5FvanAM8MXoZhSiQYayQruh8xDwTXf5n8Zgn1OOi8WtqDg==}
cpu: [arm64]
os: [win32]
'@pnpm/[email protected]4.0':
resolution: {integrity: sha512-h0s1cTRBVxKLv7uDQaN0YIXRc6itKv3mbuw5m093HL9bqy7Ys+FPZ8gvR/+cABheg64ke1xwmqO4QbuBI+qbhQ==}
'@pnpm/[email protected]5.1':
resolution: {integrity: sha512-cMfLsOE4zxSYBZYWyK1tr6BvCKVDyC81CnZg953t/6MEL592D8gk0eGdHQilEcd+yO+o6Ey1W9LLQdjl7pglsQ==}
cpu: [x64]
os: [win32]
[email protected]4.0:
resolution: {integrity: sha512-X5D1CkiqQPAdxDvTrLUoki/YmdO5CQFf2yOvc7sxxXjynOspvppNbwFGrbNCBqrDMnlgQ8xQJLgV73YojLrHZw==}
[email protected]5.1:
resolution: {integrity: sha512-psZ31wNNPXmvE28z2zPNbUEz1z+lZaBr1kqPCW0lN92HoI1o4Y/zd3cf9RwY4uwxvgO0RnDrGeJBiQ6uOu0Bag==}
engines: {node: '>=18'}
hasBin: true
snapshots:
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
'@pnpm/[email protected]4.0':
'@pnpm/[email protected]5.1':
optional: true
[email protected]4.0:
[email protected]5.1:
optionalDependencies:
'@pnpm/exe.android-arm64': 12.24.0
'@pnpm/exe.android-x64': 12.24.0
'@pnpm/exe.darwin-arm64': 12.24.0
'@pnpm/exe.darwin-x64': 12.24.0
'@pnpm/exe.freebsd-x64': 12.24.0
'@pnpm/exe.linux-arm64': 12.24.0
'@pnpm/exe.linux-arm64-musl': 12.24.0
'@pnpm/exe.linux-loong64': 12.24.0
'@pnpm/exe.linux-ppc64': 12.24.0
'@pnpm/exe.linux-riscv64': 12.24.0
'@pnpm/exe.linux-s390x': 12.24.0
'@pnpm/exe.linux-x64': 12.24.0
'@pnpm/exe.linux-x64-musl': 12.24.0
'@pnpm/exe.netbsd-x64': 12.24.0
'@pnpm/exe.win32-arm64': 12.24.0
'@pnpm/exe.win32-x64': 12.24.0
'@pnpm/exe.android-arm64': 12.25.1
'@pnpm/exe.android-x64': 12.25.1
'@pnpm/exe.darwin-arm64': 12.25.1
'@pnpm/exe.darwin-x64': 12.25.1
'@pnpm/exe.freebsd-x64': 12.25.1
'@pnpm/exe.linux-arm64': 12.25.1
'@pnpm/exe.linux-arm64-musl': 12.25.1
'@pnpm/exe.linux-loong64': 12.25.1
'@pnpm/exe.linux-ppc64': 12.25.1
'@pnpm/exe.linux-riscv64': 12.25.1
'@pnpm/exe.linux-s390x': 12.25.1
'@pnpm/exe.linux-x64': 12.25.1
'@pnpm/exe.linux-x64-musl': 12.25.1
'@pnpm/exe.netbsd-x64': 12.25.1
'@pnpm/exe.win32-arm64': 12.25.1
'@pnpm/exe.win32-x64': 12.25.1
---
lockfileVersion: '9.0'
@@ -371,7 +371,7 @@ importers:
version: 3.0.2
fullcalendar:
specifier: 7.1.5
version: 7.1.5([email protected].8)
version: 7.1.5([email protected].9)
fuse.js:
specifier: 7.5.0
version: 7.5.0
@@ -451,8 +451,8 @@ importers:
specifier: 2.0.2
version: 2.0.2
temporal-polyfill:
specifier: 1.0.8
version: 1.0.8
specifier: 1.0.9
version: 1.0.9
tinykeys:
specifier: 4.0.1
version: 4.0.1(patch_hash=cdc7ece96d53357d38ff3c124a2553f86e3a5dc333d641d223eb6f07e28275f0)
@@ -641,8 +641,8 @@ importers:
specifier: 4.2.5
version: 4.2.5([email protected])
glob:
specifier: 14.0.6
version: 14.0.6
specifier: 14.0.7
version: 14.0.7
globals:
specifier: 17.14.0
version: 17.14.0
@@ -5424,8 +5424,8 @@ packages:
resolution: {integrity: sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==}
engines: {node: 18 || 20 || >=22}
[email protected].6:
resolution: {integrity: sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==}
[email protected].7:
resolution: {integrity: sha512-ob8P0VbyEjcLG2ycNYmzYhZj65kkcN5b7tt5moGhTq3rkXtuU8MB+i0GIzPtLnSHVF2DkK4M+nQRojDvsOGVJw==}
engines: {node: 18 || 20 || >=22}
[email protected]:
@@ -7446,14 +7446,14 @@ packages:
resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==}
engines: {node: '>=8'}
[email protected].8:
resolution: {integrity: sha512-RCCGa0GddT099XG49ijdD0tDf86L8vfuZun1+JyJiO4Y2NP9PACQsG0OnvNPXwVLisdvhr/zqL2nhKQmXXx08A==}
[email protected].9:
resolution: {integrity: sha512-DPZZyb4Q8fwVUtWCN0Ugj4ZEHC0BfNHJxqRkNKpCSC9A0m7KowVRBz6mq8SjVvafMG+f7y8uioOICCNmj+j84Q==}
[email protected]:
resolution: {integrity: sha512-wxVoanmDeavXie1vu2JaQ3WIc3JZnWAOYFBsJyATaVsXsycKYUflGsyBmrRSnoCpZJpwPyr38VpgSUlQ8CbFxg==}
[email protected].4:
resolution: {integrity: sha512-4mAcgbWlaxe+gn23gk8g0iHxCVGVOhKzSCfF5HM3lfvH8BdT+/pBmH/R/E4CrIse+koUgs8ThkPzCLnui6Fi8w==}
[email protected].5:
resolution: {integrity: sha512-8gRTzLbYDO3e4riWZ+wbKQ70Q8A5j8EI7fpSPgni151f/dDg26mPwfin1d/xk0TssDGuPE3hNfUwWsZf9DZi3A==}
[email protected]:
resolution: {integrity: sha512-G13vtMYPT/J8A4X2SjdtBTphZlrp1gKv6hZiOjw14RCWg6GbHuQBGtjlx75xLbYV/wEc0D7G5K4rxKP/cXk8Bw==}
@@ -9918,14 +9918,14 @@ snapshots:
optionalDependencies:
typescript: 6.0.3
'@full-ui/[email protected]([email protected].8)':
'@full-ui/[email protected]([email protected].9)':
dependencies:
temporal-polyfill: 1.0.8
temporal-polyfill: 1.0.9
'@fullcalendar/[email protected](@full-ui/[email protected]([email protected].8))([email protected].8)':
'@fullcalendar/[email protected](@full-ui/[email protected]([email protected].9))([email protected].9)':
dependencies:
'@full-ui/headless-calendar': 7.1.5([email protected].8)
temporal-polyfill: 1.0.8
'@full-ui/headless-calendar': 7.1.5([email protected].9)
temporal-polyfill: 1.0.9
'@gar/[email protected]': {}
@@ -13274,12 +13274,12 @@ snapshots:
[email protected]:
optional: true
[email protected]([email protected].8):
[email protected]([email protected].9):
dependencies:
'@full-ui/headless-calendar': 7.1.5([email protected].8)
'@fullcalendar/core': 7.1.5(@full-ui/[email protected]([email protected].8))([email protected].8)
'@full-ui/headless-calendar': 7.1.5([email protected].9)
'@fullcalendar/core': 7.1.5(@full-ui/[email protected]([email protected].9))([email protected].9)
preact: 10.29.8
temporal-polyfill: 1.0.8
temporal-polyfill: 1.0.9
transitivePeerDependencies:
- preact-render-to-string
@@ -13409,7 +13409,7 @@ snapshots:
minipass: 7.1.3
path-scurry: 2.0.2
[email protected].6:
[email protected].7:
dependencies:
minimatch: 11.0.5
minipass: 7.1.3
@@ -15668,14 +15668,14 @@ snapshots:
[email protected]: {}
[email protected].8:
[email protected].9:
dependencies:
temporal-spec: 1.0.1
temporal-utils: 1.0.4
temporal-utils: 1.0.5
[email protected]: {}
[email protected].4: {}
[email protected].5: {}
[email protected]:
dependencies:
+82 -92
View File
@@ -18,87 +18,6 @@ import "../ha-generic-picker";
import type { PickerComboBoxItem } from "../ha-picker-combo-box";
import type { PickerValueRenderer } from "../ha-picker-field";
export const computeEntityStateItems = (
states: HassEntities | null | undefined,
formatters: HomeAssistantFormatters,
language: string,
entityId: string | string[] | undefined,
attribute: string | undefined,
hideStates: string[] | undefined,
extraOptions: PickerComboBoxItem[] | undefined
): PickerComboBoxItem[] => {
const entityIds = entityId ? ensureArray(entityId) : [];
const entitiesOptions = entityIds.map<PickerComboBoxItem[]>(
(entityIdItem) => {
const stateObj =
states?.[entityIdItem] ||
({ entity_id: entityIdItem, attributes: {} } as HassEntity);
const options = getStates(
states ?? {},
language,
stateObj,
attribute
).filter((s) => !hideStates?.includes(s));
return options
.map((s) => {
const primary = attribute
? formatters.formatEntityAttributeValue(stateObj, attribute, s)
: formatters.formatEntityState(stateObj, s);
return {
id: s,
primary,
sorting_label: primary,
};
})
.filter((option) => option.id && option.primary);
}
);
const options: PickerComboBoxItem[] = [];
const optionsSet = new Set<string>();
for (const entityOptions of entitiesOptions) {
for (const option of entityOptions) {
if (!optionsSet.has(option.id)) {
optionsSet.add(option.id);
options.push(option);
}
}
}
if (extraOptions) {
// Filter out any extraOptions with empty primary or id fields
const validExtraOptions = extraOptions.filter(
(option) => option.id && option.primary
);
options.unshift(...validExtraOptions);
}
return options;
};
// When an attribute is configured, default to the attribute's friendly
// name (e.g. "Source") instead of the generic "State". Requires a concrete
// entity to resolve the translated name; otherwise fall back to "State".
export const computeDefaultStateLabel = (
i18n: ContextType<typeof internationalizationContext>,
formatters: HomeAssistantFormatters,
stateObjs: Record<string, HassEntity> | undefined,
entityId: string | string[] | undefined,
attribute: string | undefined
): string => {
if (attribute && entityId) {
const firstEntityId = ensureArray(entityId)[0];
const stateObj = firstEntityId ? stateObjs?.[firstEntityId] : undefined;
if (stateObj) {
return formatters.formatEntityAttributeName(stateObj, attribute);
}
}
return i18n.localize("ui.components.entity.entity-state-picker.state");
};
@customElement("ha-entity-state-picker")
export class HaEntityStatePicker extends LitElement {
@property({ attribute: false }) public entityId?: string | string[];
@@ -141,7 +60,68 @@ export class HaEntityStatePicker extends LitElement {
@consume({ context: internationalizationContext, subscribe: true })
private _i18n!: ContextType<typeof internationalizationContext>;
private _getItems = memoizeOne(computeEntityStateItems);
private _getItems = memoizeOne(
(
states: HassEntities | null | undefined,
formatters: HomeAssistantFormatters,
language: string,
entityId: string | string[] | undefined,
attribute: string | undefined,
hideStates: string[] | undefined,
extraOptions: PickerComboBoxItem[] | undefined
): PickerComboBoxItem[] => {
const entityIds = entityId ? ensureArray(entityId) : [];
const entitiesOptions = entityIds.map<PickerComboBoxItem[]>(
(entityIdItem) => {
const stateObj =
states?.[entityIdItem] ||
({ entity_id: entityIdItem, attributes: {} } as HassEntity);
const options = getStates(
states ?? {},
language,
stateObj,
attribute
).filter((s) => !hideStates?.includes(s));
return options
.map((s) => {
const primary = attribute
? formatters.formatEntityAttributeValue(stateObj, attribute, s)
: formatters.formatEntityState(stateObj, s);
return {
id: s,
primary,
sorting_label: primary,
};
})
.filter((option) => option.id && option.primary);
}
);
const options: PickerComboBoxItem[] = [];
const optionsSet = new Set<string>();
for (const entityOptions of entitiesOptions) {
for (const option of entityOptions) {
if (!optionsSet.has(option.id)) {
optionsSet.add(option.id);
options.push(option);
}
}
}
if (extraOptions) {
// Filter out any extraOptions with empty primary or id fields
const validExtraOptions = extraOptions.filter(
(option) => option.id && option.primary
);
options.unshift(...validExtraOptions);
}
return options;
}
);
private _getFilteredItems = (
_searchString?: string,
@@ -163,6 +143,25 @@ export class HaEntityStatePicker extends LitElement {
return html`<span slot="headline">${item?.primary ?? value}</span>`;
};
private _computeDefaultLabel(): string {
// When an attribute is configured, default to the attribute's friendly
// name (e.g. "Source") instead of the generic "State". Requires a concrete
// entity to resolve the translated name; otherwise fall back to "State".
if (this.attribute && this.entityId) {
const entityId = ensureArray(this.entityId)[0];
const stateObj = entityId ? this._stateObjs?.[entityId] : undefined;
if (stateObj) {
return this._formatters.formatEntityAttributeName(
stateObj,
this.attribute
);
}
}
return this._i18n.localize(
"ui.components.entity.entity-state-picker.state"
);
}
protected render() {
const noEntity = !ensureArray(this.entityId)?.length;
@@ -172,16 +171,7 @@ export class HaEntityStatePicker extends LitElement {
.disabled=${this.disabled || noEntity}
.autofocus=${this.autofocus}
.required=${this.required}
.label=${
this.label ??
computeDefaultStateLabel(
this._i18n,
this._formatters,
this._stateObjs,
this.entityId,
this.attribute
)
}
.label=${this.label ?? this._computeDefaultLabel()}
.helper=${this.helper}
.value=${this.value}
.getItems=${this._getFilteredItems}
@@ -1,33 +1,16 @@
import type { ContextType } from "@lit/context";
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
import type { PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { customElement, property } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { repeat } from "lit/directives/repeat";
import memoizeOne from "memoize-one";
import { ensureArray } from "../../common/array/ensure-array";
import { consume } from "../../common/decorators/consume";
import { consumeEntityStates } from "../../common/decorators/consume-context-entry";
import { fireEvent } from "../../common/dom/fire_event";
import {
formattersContext,
internationalizationContext,
statesContext,
} from "../../data/context";
import type { SelectSelector } from "../../data/selector";
import type { HomeAssistantFormatters } from "../../types";
import type { PickerComboBoxItem } from "../ha-picker-combo-box";
import "../ha-selector/ha-selector-select";
import { ANY_STATE_VALUE } from "./const";
import {
computeDefaultStateLabel,
computeEntityStateItems,
} from "./ha-entity-state-picker";
import { ensureArray } from "../../common/array/ensure-array";
import "./ha-entity-state-picker";
@customElement("ha-entity-states-picker")
export class HaEntityStatesPicker extends LitElement {
@property({ attribute: false }) public entityId?: string | string[];
@property({ attribute: false }) public entityId?: string;
@property() public attribute?: string;
@@ -49,61 +32,6 @@ export class HaEntityStatesPicker extends LitElement {
@property({ attribute: false })
public hideStates?: string[];
@property({ type: Boolean }) public reorder = false;
@state()
@consumeEntityStates({ entityIdPath: ["entityId"] })
private _stateObjs?: Record<string, HassEntity>;
@consume({ context: statesContext, subscribe: true })
private _states?: ContextType<typeof statesContext>;
@state()
@consume({ context: formattersContext, subscribe: true })
private _formatters!: ContextType<typeof formattersContext>;
@state()
@consume({ context: internationalizationContext, subscribe: true })
private _i18n!: ContextType<typeof internationalizationContext>;
private _chipsSelector = memoizeOne(
(
states: HassEntities | null | undefined,
formatters: HomeAssistantFormatters,
language: string,
entityId: string | string[] | undefined,
attribute: string | undefined,
hideStates: string[] | undefined,
extraOptions: PickerComboBoxItem[] | undefined,
customValue: boolean,
lockedValue: string[] | undefined
): SelectSelector => {
const items = computeEntityStateItems(
states,
formatters,
language,
entityId,
attribute,
hideStates,
extraOptions
);
const options = items
.filter((item) => !lockedValue || lockedValue.includes(item.id))
.map((item) => ({
value: item.id,
label: item.primary,
}));
return {
select: {
multiple: true,
reorder: true,
custom_value: customValue && !lockedValue,
options,
},
};
}
);
private _keys: string[] = [];
private _getKey(index: number) {
@@ -120,50 +48,7 @@ export class HaEntityStatesPicker extends LitElement {
}
}
private _renderChips() {
const value = this.value ?? [];
const anyStateSelected = value.includes(ANY_STATE_VALUE);
const noEntity = !ensureArray(this.entityId)?.length;
const selector = this._chipsSelector(
this._states,
this._formatters,
this._i18n.locale.language,
this.entityId,
this.attribute,
this.hideStates,
this.extraOptions,
Boolean(this.allowCustomValue),
anyStateSelected ? value : undefined
);
const label =
this.label ??
computeDefaultStateLabel(
this._i18n,
this._formatters,
this._stateObjs,
this.entityId,
this.attribute
);
return html`
<ha-selector-select
.selector=${selector}
.value=${this.value}
.label=${label}
.helper=${this.helper}
.disabled=${this.disabled || noEntity}
.required=${this.required}
></ha-selector-select>
`;
}
protected render() {
if (this.reorder) {
return this._renderChips();
}
const value = this.value || [];
const hide = [...(this.hideStates || []), ...value];
const hideValue = value.includes(ANY_STATE_VALUE);
@@ -171,18 +56,18 @@ export class HaEntityStatesPicker extends LitElement {
return html`
${repeat(
value,
(_item, index) => this._getKey(index),
(item, index) => html`
(_state, index) => this._getKey(index),
(state, index) => html`
<div>
<ha-entity-state-picker
.index=${index}
.entityId=${this.entityId}
.attribute=${this.attribute}
.extraOptions=${this.extraOptions}
.hideStates=${hide.filter((v) => v !== item)}
.hideStates=${hide.filter((v) => v !== state)}
.allowCustomValue=${this.allowCustomValue}
.label=${this.label}
.value=${item}
.value=${state}
.disabled=${this.disabled}
.helper=${
this.disabled && index === value.length - 1
@@ -36,6 +36,8 @@ export class HaFormExpandable extends LitElement implements HaFormElement {
key: string
) => string;
@property({ attribute: false }) public context?: Record<string, any>;
@query("ha-form", true) private _form?: HaForm;
public reportValidity(): boolean {
@@ -109,6 +111,7 @@ export class HaFormExpandable extends LitElement implements HaFormElement {
.computeLabel=${this._computeLabel}
.computeHelper=${this._computeHelper}
.localizeValue=${this.localizeValue}
.context=${this.context}
></ha-form>
</div>
</ha-expansion-panel>
+3
View File
@@ -35,6 +35,8 @@ export class HaFormGrid extends LitElement implements HaFormElement {
key: string
) => string;
@property({ attribute: false }) public context?: Record<string, any>;
@queryAll("ha-form", true) private _forms?: HaForm[];
static shadowRootOptions = {
@@ -83,6 +85,7 @@ export class HaFormGrid extends LitElement implements HaFormElement {
.computeLabel=${this.computeLabel}
.computeHelper=${this.computeHelper}
.localizeValue=${this.localizeValue}
.context=${this.context}
></ha-form>
`
)}
@@ -54,6 +54,8 @@ export class HaFormOptionalActions extends LitElement implements HaFormElement {
key: string
) => string;
@property({ attribute: false }) public context?: Record<string, any>;
@state() private _displayActions?: string[];
@query("ha-form") private _form?: HaForm;
@@ -130,6 +132,7 @@ export class HaFormOptionalActions extends LitElement implements HaFormElement {
.computeLabel=${this.computeLabel}
.computeHelper=${this.computeHelper}
.localizeValue=${this.localizeValue}
.context=${this.context}
></ha-form>
`
: nothing
@@ -86,7 +86,6 @@ export class HaSelectorState extends SubscribeMixin(LitElement) {
.required=${this.required}
allow-custom-value
.hideStates=${this.selector.state?.hide_states}
.reorder=${this.selector.state?.reorder ?? false}
></ha-entity-states-picker>
`;
}
-1
View File
@@ -576,7 +576,6 @@ export interface StateSelector {
attribute?: string;
hide_states?: string[];
multiple?: boolean;
reorder?: boolean;
} | null;
}