@esri/calcite-components 5.1.1-next.6 → 5.1.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cdn/{F7RQCNJ4.js → 22ZEEBHY.js} +1 -1
- package/dist/cdn/{YI3ZMHS5.js → 2E5VWP5F.js} +1 -1
- package/dist/cdn/{KB2WIMAL.js → 2IH3A7XP.js} +1 -1
- package/dist/cdn/{MWMTHMMN.js → 35O6UEOL.js} +1 -1
- package/dist/cdn/{WVJUNLFN.js → 3DHLIYTZ.js} +1 -1
- package/dist/cdn/{TQJK5WF5.js → 3LBQM6E5.js} +1 -1
- package/dist/cdn/3OUO73FE.js +2 -0
- package/dist/cdn/3UQ52WEC.js +2 -0
- package/dist/cdn/{F5MS5PBN.js → 46QVRBZQ.js} +1 -1
- package/dist/cdn/{YFUBBPNI.js → 4DEE5DJG.js} +1 -1
- package/dist/cdn/{3BUDIEL3.js → 4ESXF6CD.js} +1 -1
- package/dist/cdn/4GINWH77.js +2 -0
- package/dist/cdn/{7M4ANW77.js → 4GLWWIFB.js} +1 -1
- package/dist/cdn/55B3DHRL.js +2 -0
- package/dist/cdn/{32QFEQZS.js → 5AIYVBUE.js} +1 -1
- package/dist/cdn/{Y44WJ7Z2.js → 5GSQDOTM.js} +1 -1
- package/dist/cdn/{3XFDQDVC.js → 5JMEGSKG.js} +1 -1
- package/dist/cdn/{NAJTDRNC.js → 5P6PZGTL.js} +1 -1
- package/dist/cdn/{3XMNPYNB.js → 5RKV22NY.js} +1 -1
- package/dist/cdn/{WYGNUS2B.js → 5XBX6MS4.js} +1 -1
- package/dist/cdn/{MRRVOAJL.js → 65AE3WDH.js} +1 -1
- package/dist/cdn/{QN4XN67Z.js → 6DMJVTU7.js} +1 -1
- package/dist/cdn/{M2TFDONT.js → 7CPR7ZY6.js} +1 -1
- package/dist/cdn/{Z2GSU7Q2.js → 7LJPLUHO.js} +1 -1
- package/dist/cdn/{VYXKMJSU.js → 7Q7ZAE37.js} +1 -1
- package/dist/cdn/{ROY5CHB3.js → 7S7I3ZX6.js} +1 -1
- package/dist/cdn/{CUSR767T.js → 7TIC7MWH.js} +1 -1
- package/dist/cdn/{ND7KY7GE.js → AE6WIDBA.js} +1 -1
- package/dist/cdn/{U6NA5WAH.js → ANR6MBC5.js} +1 -1
- package/dist/cdn/AQZ7H27V.js +2 -0
- package/dist/cdn/AUY3K2CK.js +2 -0
- package/dist/cdn/{VWQPK5JA.js → B2ZOCHY5.js} +1 -1
- package/dist/cdn/B74ZW4VM.js +2 -0
- package/dist/cdn/{74CLXGQH.js → BSFLNK3G.js} +1 -1
- package/dist/cdn/{JQIHTMWX.js → BX7JMSW4.js} +1 -1
- package/dist/cdn/{45C4ENM6.js → BXUDOEEY.js} +1 -1
- package/dist/cdn/{OXKGEAUB.js → BZW75APA.js} +1 -1
- package/dist/cdn/{QXPWDVC2.js → CCMLFJRX.js} +1 -1
- package/dist/cdn/{C4PPQBLW.js → CHVYZBJP.js} +1 -1
- package/dist/cdn/{5X2CR2NN.js → CQMH7FNX.js} +1 -1
- package/dist/cdn/{REW7C42W.js → D5RB7ITG.js} +1 -1
- package/dist/cdn/{IHGSINVA.js → D7WOEWO3.js} +1 -1
- package/dist/cdn/{ATWAUE4R.js → DAUDD3TU.js} +1 -1
- package/dist/cdn/{I2DNOFC6.js → DH7CVA3S.js} +1 -1
- package/dist/cdn/{5RJTKL4J.js → DIVK7SUE.js} +1 -1
- package/dist/cdn/{CDGEWGDD.js → DUFMSJ4N.js} +1 -1
- package/dist/cdn/{RZR44QGM.js → DVG3NA3H.js} +1 -1
- package/dist/cdn/{RIEKXKB2.js → DZ2ML6RL.js} +1 -1
- package/dist/cdn/{N3YQ6P66.js → E274U5KY.js} +1 -1
- package/dist/cdn/{5SYOHCLD.js → E5KOELX6.js} +1 -1
- package/dist/cdn/{JMKB4CRU.js → EBDWLL34.js} +1 -1
- package/dist/cdn/{YNG6JO67.js → EH5Y2TRK.js} +1 -1
- package/dist/cdn/{WAXTXFBL.js → FA5NVFJF.js} +1 -1
- package/dist/cdn/{5N32D533.js → FPSAFKXP.js} +1 -1
- package/dist/cdn/{D2HPEC7F.js → FQTCAXYA.js} +1 -1
- package/dist/cdn/{E4MGJ47Y.js → FQZZCTBU.js} +1 -1
- package/dist/cdn/{2VL3OCAZ.js → FR5GKBKS.js} +1 -1
- package/dist/cdn/{G62VTWNT.js → FTH3OHTR.js} +1 -1
- package/dist/cdn/{5L5RJCKK.js → GA2SRL7F.js} +1 -1
- package/dist/cdn/{IXQQO6HC.js → GCCKUDLZ.js} +1 -1
- package/dist/cdn/{BTSHRUHD.js → GFJSIQAL.js} +1 -1
- package/dist/cdn/{F3E7QPPC.js → GQV6EPVW.js} +1 -1
- package/dist/cdn/{CUTXFNYN.js → GUYWR6OU.js} +1 -1
- package/dist/cdn/{7YNDWV76.js → GVPG6GL6.js} +1 -1
- package/dist/cdn/{27MK2V4G.js → H5OQUUCS.js} +1 -1
- package/dist/cdn/{5QXKHC54.js → HNFN5XI4.js} +1 -1
- package/dist/cdn/{A332WZ6V.js → HOZFU3MX.js} +1 -1
- package/dist/cdn/{EJUEMY56.js → HS67EN4X.js} +1 -1
- package/dist/cdn/{TMWGSGAP.js → I5FHLUKC.js} +1 -1
- package/dist/cdn/{N6V2UT62.js → IDT2SXTU.js} +1 -1
- package/dist/cdn/{KQGUXAM6.js → IIK67UVJ.js} +1 -1
- package/dist/cdn/{W3N2DKPC.js → J4NTIVMX.js} +1 -1
- package/dist/cdn/{VVJGLEIA.js → JBJREVM7.js} +1 -1
- package/dist/cdn/{773VWCGD.js → JGIGYWX4.js} +1 -1
- package/dist/cdn/{OJO5NPP3.js → JKB2GJ3L.js} +1 -1
- package/dist/cdn/{CZPSEMDH.js → KJ3CYYKH.js} +1 -1
- package/dist/cdn/KRJOJQ44.js +2 -0
- package/dist/cdn/KZAI3CI3.js +2 -0
- package/dist/cdn/{UE4QYUAU.js → LBE47OKH.js} +1 -1
- package/dist/cdn/{SBQVCX2M.js → LELOCWEB.js} +1 -1
- package/dist/cdn/LWJGPTE6.js +2 -0
- package/dist/cdn/{5WFJNGXP.js → M3FXEHEJ.js} +1 -1
- package/dist/cdn/{2MRL4RKW.js → MOFJZGJJ.js} +1 -1
- package/dist/cdn/{Y6WCKCHJ.js → MSMAWAGB.js} +1 -1
- package/dist/cdn/{5JIKOOZ6.js → NFJSGECW.js} +1 -1
- package/dist/cdn/{JDAOWOTY.js → NFSJVK6S.js} +1 -1
- package/dist/cdn/{KJNTF66K.js → NV73Q6Y3.js} +1 -1
- package/dist/cdn/{FKX46Z6K.js → NWCJZZUP.js} +1 -1
- package/dist/cdn/{SGZ3IG5W.js → NXXNNPTZ.js} +1 -1
- package/dist/cdn/OAHYAUPC.js +2 -0
- package/dist/cdn/{RVXZUGJA.js → OJOSD3I3.js} +1 -1
- package/dist/cdn/{MD2UCHOX.js → OKEUM3YZ.js} +1 -1
- package/dist/cdn/{6W4CWLXH.js → ON5SZ43I.js} +1 -1
- package/dist/cdn/{EHS7L663.js → OO4DL46D.js} +1 -1
- package/dist/cdn/{GEKASHNF.js → OXAULX56.js} +1 -1
- package/dist/cdn/{TPML2DIA.js → OYI5HS2H.js} +1 -1
- package/dist/cdn/{3VNZC64N.js → PF2E72GP.js} +1 -1
- package/dist/cdn/{XTGDCTQE.js → PGOMURMZ.js} +1 -1
- package/dist/cdn/{WRQD4O6A.js → PTENM6H3.js} +1 -1
- package/dist/cdn/PZBMDHWQ.js +2 -0
- package/dist/cdn/{72XY7IDN.js → QEET4SDM.js} +1 -1
- package/dist/cdn/QEJPO65G.js +2 -0
- package/dist/cdn/{RDOHAXOA.js → QU4Q7ONO.js} +1 -1
- package/dist/cdn/{TRN7FUFM.js → QUBOBRBE.js} +1 -1
- package/dist/cdn/{YBFI2FQL.js → QUFMR3GW.js} +1 -1
- package/dist/cdn/{6N246L5H.js → R6QHGRLY.js} +1 -1
- package/dist/cdn/{HQHM5NWX.js → RAPPDCJC.js} +1 -1
- package/dist/cdn/{2PEF7GQE.js → RCKGNXG5.js} +1 -1
- package/dist/cdn/{O6PZKJ7R.js → ROD7LNFF.js} +1 -1
- package/dist/cdn/{IRDSJTUK.js → RRG7YZBV.js} +1 -1
- package/dist/cdn/{74UIHSVE.js → RUFVN26P.js} +1 -1
- package/dist/cdn/{BZJYGCDK.js → SNI7EAIB.js} +1 -1
- package/dist/cdn/{6MUZLYOR.js → T3FWIMHQ.js} +1 -1
- package/dist/cdn/{PJSI5N6F.js → THKF3UIU.js} +1 -1
- package/dist/cdn/{ERBKUSSX.js → TLYY3J5P.js} +1 -1
- package/dist/cdn/{CBUNIAKL.js → TMJJBLP6.js} +1 -1
- package/dist/cdn/{KCENWQ6Z.js → TNK2ZMWI.js} +1 -1
- package/dist/cdn/{TFTS26NS.js → TO7Y5WZH.js} +1 -1
- package/dist/cdn/{PW2XM5HR.js → TPA4W766.js} +1 -1
- package/dist/cdn/{NDVX6CLP.js → TPACOVOQ.js} +1 -1
- package/dist/cdn/{SH7DQCS7.js → TQ5ZBZVK.js} +1 -1
- package/dist/cdn/U5CB5AOH.js +2 -0
- package/dist/cdn/{4Q7PL2KY.js → UANLRLKZ.js} +1 -1
- package/dist/cdn/{3NNR2AZU.js → UILRTNAY.js} +1 -1
- package/dist/cdn/{DJMAPSDY.js → UJSGNQNS.js} +1 -1
- package/dist/cdn/{34WAUXUE.js → UMNCTZMZ.js} +1 -1
- package/dist/cdn/{UIFHJ5IO.js → UQADROG7.js} +1 -1
- package/dist/cdn/{ZEEFJOPQ.js → UU6TKA7Y.js} +1 -1
- package/dist/cdn/{4NYY44U4.js → V7X5QMP5.js} +1 -1
- package/dist/cdn/{FE3TGEP7.js → VKOMYCKU.js} +1 -1
- package/dist/cdn/{C4DX6ZIA.js → VL5MBQLU.js} +1 -1
- package/dist/cdn/{OB3Z74X6.js → VLTH6OI4.js} +1 -1
- package/dist/cdn/{FZTLSQJL.js → VTIIXIO2.js} +1 -1
- package/dist/cdn/{SS4J7QES.js → VVLIBG27.js} +1 -1
- package/dist/cdn/{CQYI4Z2Z.js → W776TYSB.js} +1 -1
- package/dist/cdn/{UOSSQPFY.js → WBG5KGIT.js} +1 -1
- package/dist/cdn/{DEQNFOAS.js → WE6LDLUR.js} +1 -1
- package/dist/cdn/{5CBFI2KM.js → WJLDQOSL.js} +1 -1
- package/dist/cdn/{XCNAJ4XA.js → WMAINNWS.js} +1 -1
- package/dist/cdn/{RUNWK23I.js → WMRHH4QJ.js} +1 -1
- package/dist/cdn/WYWBO53V.js +2 -0
- package/dist/cdn/XPV23QFC.js +2 -0
- package/dist/cdn/XXOHZXFG.js +2 -0
- package/dist/cdn/{R4C3WA5S.js → Y7HCDFPY.js} +1 -1
- package/dist/cdn/{ZBN5LXKS.js → YCBJZOJS.js} +1 -1
- package/dist/cdn/{3H6RVKMN.js → YETMUH7M.js} +1 -1
- package/dist/cdn/{WUBPEGFV.js → YPGTWYGF.js} +1 -1
- package/dist/cdn/{FKPCRFUW.js → YVT2GP5U.js} +1 -1
- package/dist/cdn/{6UM5PQBD.js → ZAWIMU5V.js} +1 -1
- package/dist/cdn/{72EJ64LI.js → ZU6VN5T5.js} +1 -1
- package/dist/cdn/assets/icon/buildingIndex16.json +1 -0
- package/dist/cdn/assets/icon/buildingIndex24.json +1 -0
- package/dist/cdn/assets/icon/buildingIndex32.json +1 -0
- package/dist/cdn/assets/icon/fireIndex16.json +1 -0
- package/dist/cdn/assets/icon/fireIndex24.json +1 -0
- package/dist/cdn/assets/icon/fireIndex32.json +1 -0
- package/dist/cdn/assets/icon/geologyIndex16.json +1 -0
- package/dist/cdn/assets/icon/geologyIndex24.json +1 -0
- package/dist/cdn/assets/icon/geologyIndex32.json +1 -0
- package/dist/cdn/assets/icon/snowIndex16.json +1 -0
- package/dist/cdn/assets/icon/snowIndex24.json +1 -0
- package/dist/cdn/assets/icon/snowIndex32.json +1 -0
- package/dist/cdn/assets/icon/soilAdjustedVegetationIndex16.json +1 -0
- package/dist/cdn/assets/icon/soilAdjustedVegetationIndex24.json +1 -0
- package/dist/cdn/assets/icon/soilAdjustedVegetationIndex32.json +1 -0
- package/dist/cdn/assets/icon/vegetationIndex16.json +1 -0
- package/dist/cdn/assets/icon/vegetationIndex24.json +1 -0
- package/dist/cdn/assets/icon/vegetationIndex32.json +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/openCloseComponent.js +1 -1
- package/dist/chunks/resources10.js +19 -0
- package/dist/chunks/resources11.js +63 -0
- package/dist/chunks/resources5.js +40 -51
- package/dist/chunks/resources6.js +24 -46
- package/dist/chunks/resources7.js +53 -8
- package/dist/chunks/resources8.js +50 -10
- package/dist/chunks/resources9.js +7 -53
- package/dist/chunks/runtime.js +4 -4
- package/dist/chunks/utils.js +9 -15
- package/dist/chunks/utils2.js +59 -6
- package/dist/components/calcite-block/customElement.d.ts +9 -9
- package/dist/components/calcite-block/customElement.js +8 -49
- package/dist/components/calcite-block-group/customElement.js +3 -5
- package/dist/components/calcite-block-section/customElement.d.ts +5 -5
- package/dist/components/calcite-block-section/customElement.js +1 -1
- package/dist/components/calcite-button/customElement.d.ts +8 -8
- package/dist/components/calcite-button/customElement.js +3 -3
- package/dist/components/calcite-checkbox/customElement.js +1 -1
- package/dist/components/calcite-chip/customElement.js +1 -27
- package/dist/components/calcite-color-picker/customElement.d.ts +3 -3
- package/dist/components/calcite-color-picker/customElement.js +23 -20
- package/dist/components/calcite-color-picker-hex-input/customElement.d.ts +1 -1
- package/dist/components/calcite-color-picker-hex-input/customElement.js +4 -4
- package/dist/components/calcite-color-picker-swatch/customElement.d.ts +1 -1
- package/dist/components/calcite-color-picker-swatch/customElement.js +1 -1
- package/dist/components/calcite-combobox/customElement.js +286 -132
- package/dist/components/calcite-combobox-item/customElement.js +1 -1
- package/dist/components/calcite-combobox-item-group/customElement.js +1 -1
- package/dist/components/calcite-dialog/customElement.js +1 -1
- package/dist/components/calcite-dropdown-group/customElement.js +1 -1
- package/dist/components/calcite-dropdown-item/customElement.js +1 -1
- package/dist/components/calcite-flow-item/customElement.d.ts +7 -1
- package/dist/components/calcite-flow-item/customElement.js +1 -1
- package/dist/components/calcite-input/customElement.js +1 -1
- package/dist/components/calcite-input-date-picker/customElement.js +5 -10
- package/dist/components/calcite-input-number/customElement.js +1 -1
- package/dist/components/calcite-input-text/customElement.js +1 -1
- package/dist/components/calcite-input-time-zone/customElement.js +1 -1
- package/dist/components/calcite-list/customElement.js +1 -1
- package/dist/components/calcite-list-item/customElement.js +1 -1
- package/dist/components/calcite-list-item-group/customElement.js +1 -1
- package/dist/components/calcite-panel/customElement.js +1 -1
- package/dist/components/calcite-stack/customElement.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/types/lumina.d.ts +1 -1
- package/dist/types/preact.d.ts +1 -1
- package/dist/types/react.d.ts +1 -1
- package/dist/types/stencil.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cdn/25SUELBY.js +0 -2
- package/dist/cdn/73EQ5TEB.js +0 -2
- package/dist/cdn/7AOQ4FPG.js +0 -2
- package/dist/cdn/C2BK5CUC.js +0 -2
- package/dist/cdn/DAXLXKIY.js +0 -2
- package/dist/cdn/DSQ47C3C.js +0 -2
- package/dist/cdn/DZSC3TJX.js +0 -2
- package/dist/cdn/GYYFBZS2.js +0 -2
- package/dist/cdn/I5HZNPIE.js +0 -2
- package/dist/cdn/OGNY6ZIB.js +0 -2
- package/dist/cdn/OWJYARYV.js +0 -2
- package/dist/cdn/QABVNEOF.js +0 -2
- package/dist/cdn/VCDOY22T.js +0 -2
- package/dist/cdn/VYZ6WAWT.js +0 -2
- package/dist/cdn/Z7NNDJEN.js +0 -2
- /package/dist/cdn/{IYGANVDT.js → 2G2ZTAXT.js} +0 -0
- /package/dist/cdn/{UM6KICQF.js → 5ZULUIQ5.js} +0 -0
- /package/dist/cdn/{MYDCGCGV.js → EWIZKNXQ.js} +0 -0
- /package/dist/cdn/{DCWL5FUH.js → EZQV6OUW.js} +0 -0
- /package/dist/cdn/{R6HABYRV.js → SXELOWJI.js} +0 -0
|
@@ -27,8 +27,9 @@ import { u as useCancelable } from "../../chunks/useCancelable.js";
|
|
|
27
27
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
28
28
|
import { u as useTopLayer } from "../../chunks/useTopLayer.js";
|
|
29
29
|
import { u as useForm } from "../../chunks/useForm.js";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
30
|
+
import { i as isChip } from "../../chunks/resources6.js";
|
|
31
|
+
import { I as IDS, C as CSS, a as ComboboxItemSelector, b as ComboboxItemGroupSelector, c as ICONS } from "../../chunks/resources7.js";
|
|
32
|
+
import { h as hasActiveChildren, i as isSingleLike, o as orderValuesByPrevious, a as orderByPrevious, g as getLabel, b as getItemAncestors, c as getItemChildren } from "../../chunks/utils2.js";
|
|
32
33
|
const styles = css`:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{position:relative;display:block}:host([scale=s]){font-size:var(--calcite-font-size-relative-sm);--calcite-internal-combobox-spacing-unit-l: .5rem;--calcite-internal-combobox-spacing-unit-s: .25rem;--calcite-internal-combobox-padding-inline-end: var(--calcite-space-2xs);--calcite-internal-combobox-no-matches-spacing-unit-s: .25rem;--calcite-combobox-input-height: 1rem;--calcite-internal-combobox-input-margin-block: calc(.25rem - 1px) ;--calcite-internal-close-size: 1rem}:host([scale=m]){font-size:var(--calcite-font-size-relative-base);--calcite-internal-combobox-spacing-unit-l: .75rem;--calcite-internal-combobox-spacing-unit-s: .5rem;--calcite-internal-combobox-padding-inline-end: var(--calcite-space-sm);--calcite-internal-combobox-no-matches-spacing-unit-s: .375rem;--calcite-combobox-input-height: 1rem;--calcite-internal-combobox-input-margin-block: calc(.5rem - 1px) ;--calcite-internal-close-size: 1.5rem}:host([scale=l]){font-size:var(--calcite-font-size-relative-md);--calcite-internal-combobox-spacing-unit-l: 1rem;--calcite-internal-combobox-spacing-unit-s: .75rem;--calcite-internal-combobox-padding-inline-end: var(--calcite-space-sm-plus);--calcite-internal-combobox-no-matches-spacing-unit-s: var(--calcite-space-sm-plus);--calcite-combobox-input-height: 1.5rem;--calcite-internal-combobox-input-margin-block: calc(var(--calcite-space-sm-plus) - 1px);--calcite-internal-close-size: 2rem}.wrapper{display:flex;border-width:1px;border-style:solid;outline-color:transparent;padding-block:calc(var(--calcite-internal-combobox-spacing-unit-s) / 4);padding-inline:var(--calcite-internal-combobox-spacing-unit-l) var(--calcite-internal-combobox-padding-inline-end);background-color:var(--calcite-combobox-input-background-color, var(--calcite-color-foreground-1));color:var(--calcite-combobox-input-text-color, var(--calcite-color-text-1));border-color:var(--calcite-combobox-input-border-color, var(--calcite-color-border-input))}.wrapper:hover .icon{color:var(--calcite-combobox-icon-color-hover, var(--calcite-color-text-1))}:host(:focus-within) .wrapper,.wrapper--active{outline:var(--calcite-border-width-md) solid var(--calcite-color-focus, var(--calcite-ui-focus-color, var(--calcite-color-brand)));outline-offset:calc(calc(-1 * var(--calcite-spacing-base)) * calc(1 - (2*clamp(0,var(--calcite-offset-invert-focus),1))))}:host([read-only]) .wrapper{background-color:var(--calcite-color-background)}:host([read-only]) .label{font-weight:var(--calcite-font-weight-medium)}:host([status=invalid]) .wrapper{border-color:var(--calcite-color-status-danger)}:host([status=invalid]:focus-within) .wrapper{outline:var(--calcite-border-width-md) solid var(--calcite-color-status-danger);outline-offset:calc(calc(-1 * var(--calcite-spacing-base)) * calc(1 - (2*clamp(0,var(--calcite-offset-invert-focus),1))))}.wrapper--single{padding-block:0;padding-inline:var(--calcite-internal-combobox-spacing-unit-l) var(--calcite-internal-combobox-padding-inline-end);cursor:pointer;flex-wrap:nowrap}.grid-input{position:relative;display:flex;flex-grow:1;flex-wrap:wrap;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0;gap:var(--calcite-internal-combobox-spacing-unit-s);margin-inline-end:var(--calcite-internal-combobox-spacing-unit-s)}.grid-input.selection-display--fit,.grid-input.selection-display--single{flex-wrap:nowrap;overflow:hidden}.input{flex-grow:1;appearance:none;overflow:hidden;text-overflow:ellipsis;border-style:none;background-color:transparent;padding:0;font-family:inherit;color:var(--calcite-color-text-1);font-size:inherit;block-size:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height);inline-size:100%;margin-block-end:var(--calcite-internal-combobox-spacing-unit-s);min-inline-size:4.8125rem}.input:focus{outline:2px solid transparent;outline-offset:2px}.input:placeholder-shown{text-overflow:ellipsis}.input--single{padding:0;margin-block:var(--calcite-internal-combobox-input-margin-block)}.wrapper--active .input-single{cursor:text}.input--hidden{pointer-events:none;width:0px;min-width:0px;opacity:0}.input--icon{padding-block:0;padding-inline:var(--calcite-internal-combobox-spacing-unit-l)}.placeholder-icon{color:var(--calcite-combobox-icon-color, var(--calcite-color-text-3))}.input-wrap{display:flex;flex-grow:1;align-items:center}.input-wrap--single{flex:1 1 0%;overflow:hidden}.label{pointer-events:none;max-width:100%;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0;font-weight:var(--calcite-font-weight-normal);block-size:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height)}.label--icon{padding-inline:var(--calcite-internal-combobox-spacing-unit-l)}.icon-end,.icon-start{display:flex;cursor:pointer;align-items:center}.icon-end{flex:none}.icon-end .icon{color:var(--calcite-combobox-icon-color, var(--calcite-color-text-3))}.floating-ui-container{inline-size:max-content;display:none;max-inline-size:100vw;max-block-size:100vh;inset-block-start:0;left:0;z-index:var(--calcite-floating-ui-z-index)}@starting-style{.floating-ui-container{opacity:0;inset-block-start:0;left:0}}:host([top-layer-disabled]) .floating-ui-container{--calcite-floating-ui-z-index: var(--calcite-z-index-dropdown)}.floating-ui-container[popover]{padding:0;margin:0;border:none;background-color:transparent;overflow:visible;display:none}.floating-ui-container:popover-open{display:block}.floating-ui-container .calcite-floating-ui-anim{position:relative;transition-duration:var(--calcite-floating-ui-transition);transition-property:inset-block-start,left,opacity,display;transition-behavior:allow-discrete;opacity:0;box-shadow:0 0 16px #00000029;z-index:var(--calcite-z-index);border-radius:.25rem}.floating-ui-container[data-placement^=bottom] .calcite-floating-ui-anim{inset-block-start:-5px}.floating-ui-container[data-placement^=top] .calcite-floating-ui-anim{inset-block-start:5px}.floating-ui-container[data-placement^=left] .calcite-floating-ui-anim{left:5px}.floating-ui-container[data-placement^=right] .calcite-floating-ui-anim{left:-5px}.floating-ui-container[data-placement] .calcite-floating-ui-anim--active{opacity:1;inset-block-start:0;left:0}@starting-style{.floating-ui-container[data-placement] .calcite-floating-ui-anim--active{opacity:0}}.floating-ui-container .calcite-floating-ui-anim{box-shadow:var(--calcite-shadow-md)}@media(forced-colors:active){.wrapper,.floating-ui-container{border:1px solid canvasText}}.screen-readers-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.list-container{max-height:45vh;overflow-y:auto;inline-size:var(--calcite-dropdown-width, 100%);background-color:var(--calcite-combobox-background-color, var(--calcite-color-foreground-1))}.list{margin:0;display:block;padding:0;line-height:var(--calcite-font-line-height-relative-snug)}.list--hide{height:0px;overflow:hidden}calcite-chip{--calcite-animation-timing: 0}.chip{margin-block:calc(var(--calcite-internal-combobox-spacing-unit-s) / 4);max-inline-size:100%}.chip--invisible{visibility:hidden;position:absolute}.item{display:block}.select-all{background-color:var(--calcite-combobox-item-background-color-active, var(--calcite-color-foreground-1));border-block-end-color:var(--calcite-combobox-divider-color, var(--calcite-combobox-item-border-color, var(--calcite-color-border-3)));border-block-end-style:solid;border-block-end-width:var(--calcite-border-width-sm);inset-block-start:0;position:sticky;z-index:var(--calcite-z-index-sticky)}.no-matches{padding-block:var(--calcite-internal-combobox-no-matches-spacing-unit-s);padding-inline:var(--calcite-internal-combobox-spacing-unit-l);color:var(--calcite-combobox-input-text-color, var(--calcite-color-text-1));background:var(--calcite-combobox-background-color, var(--calcite-color-foreground-1));cursor:pointer}.no-matches-placeholder{color:var(--calcite-combobox-icon-color, var(--calcite-color-text-3));cursor:default}.disabled{opacity:.5}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}.clear-button--container{display:flex;cursor:pointer;align-items:center}.clear-button--container:hover calcite-action{--calcite-action-background-color: var(--calcite-clear-button-background-color-hover, var(--calcite-color-foreground-3));--calcite-action-text-color: var(--calcite-clear-button-icon-color-hover, var(--calcite-color-text-1))}.clear-button--container:active calcite-action{--calcite-action-background-color: var(--calcite-clear-button-background-color-press, var(--calcite-color-border-2));--calcite-action-text-color: var(--calcite-clear-button-icon-color-press, var(--calcite-color-text-1))}.clear-button--container calcite-action{--calcite-internal-action-height: 100%;--calcite-internal-action-padding-inline: var(--calcite-spacing-none);--calcite-internal-action-padding-block: var(--calcite-spacing-none);--calcite-action-background-color: var(--calcite-clear-button-background-color, var(--calcite-color-foreground-2));--calcite-action-text-color: var(--calcite-clear-button-icon-color)}.clear-button--container calcite-action:hover{--calcite-action-background-color-hover: var(--calcite-clear-button-background-color-hover, var(--calcite-color-foreground-3));--calcite-action-text-color-press: var(--calcite-clear-button-icon-color-hover)}.clear-button--container calcite-action:active{--calcite-action-background-color-press: var(--calcite-clear-button-background-color-press, var(--calcite-color-border-2));--calcite-action-text-color-press: var(--calcite-clear-button-icon-color-press)}:host([scale=s]) .clear-button--container{padding:var(--calcite-spacing-xxs)}:host([scale=m]) .clear-button--container{padding:var(--calcite-spacing-xxs);padding-inline-end:var(--calcite-space-sm)}:host([scale=l]) .clear-button--container{padding-inline-end:var(--calcite-spacing-sm-plus)}.validation-container{display:flex;flex-direction:column;align-items:flex-start;align-self:stretch}:host([scale=m]) .validation-container,:host([scale=l]) .validation-container{padding-block-start:.5rem}:host([scale=s]) .validation-container{padding-block-start:.25rem}::slotted(input[slot=hidden-form-input]){margin:0!important;opacity:0!important;outline:none!important;padding:0!important;position:absolute!important;inset:0!important;transform:none!important;-webkit-appearance:none!important;z-index:-1!important}:host([hidden]){display:none}[hidden]{display:none}.text-match{background-color:transparent;color:inherit;font-weight:var(--calcite-font-weight-bold)}.internal-label-alignment--center{align-items:center}.internal-label-alignment--end{align-items:end}.internal-label--container{display:flex;justify-content:space-between;color:var(--calcite-color-text-1)}.internal-label-required--indicator{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-status-danger);padding-inline:var(--calcite-spacing-base)}.internal-label-required--indicator:hover{cursor:help}.internal-label--text{line-height:1}:host([scale=s]) .internal-label-spacing--bottom{margin-block-end:var(--calcite-spacing-xxs)}:host([scale=s]) .internal-label-spacing-inline--end{margin-inline-end:var(--calcite-spacing-sm)}:host([scale=s]) .internal-label-spacing-inline--start{margin-inline-start:var(--calcite-spacing-sm)}:host([scale=s]) .internal-label--text{font-size:var(--calcite-font-size--2)}:host([scale=m]) .internal-label-spacing--bottom{margin-block-end:var(--calcite-spacing-sm)}:host([scale=m]) .internal-label-spacing-inline--end{margin-inline-end:var(--calcite-spacing-sm)}:host([scale=m]) .internal-label-spacing-inline--start{margin-inline-start:var(--calcite-spacing-sm)}:host([scale=m]) .internal-label--text{font-size:var(--calcite-font-size--1)}:host([scale=l]) .internal-label-spacing--bottom{margin-block-end:var(--calcite-spacing-sm)}:host([scale=l]) .internal-label-spacing-inline--end{margin-inline-end:var(--calcite-spacing-md)}:host([scale=l]) .internal-label-spacing-inline--start{margin-inline-start:var(--calcite-spacing-md)}:host([scale=l]) .internal-label--text{font-size:var(--calcite-font-size-0)}::placeholder{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-input-placeholder-text-color, var(--calcite-color-text-3))}`;
|
|
33
34
|
class Combobox extends LitElement {
|
|
34
35
|
constructor() {
|
|
@@ -77,32 +78,38 @@ class Combobox extends LitElement {
|
|
|
77
78
|
this._filterText = "";
|
|
78
79
|
this.getSelectedItems = () => {
|
|
79
80
|
if (!this.isMulti()) {
|
|
80
|
-
const match = this.
|
|
81
|
+
const match = this.allItems.find(({ selected }) => selected);
|
|
81
82
|
return match ? [match] : [];
|
|
82
83
|
}
|
|
83
|
-
return this.
|
|
84
|
-
const aIdx = this.selectedItems.indexOf(a);
|
|
85
|
-
const bIdx = this.selectedItems.indexOf(b);
|
|
86
|
-
if (aIdx > -1 && bIdx > -1) {
|
|
87
|
-
return aIdx - bIdx;
|
|
88
|
-
}
|
|
89
|
-
return bIdx - aIdx;
|
|
90
|
-
});
|
|
84
|
+
return this.allItems.filter((item) => item.selected && (this.selectionMode !== "ancestors" || !hasActiveChildren(item)));
|
|
91
85
|
};
|
|
92
86
|
this.groupItems = [];
|
|
93
87
|
this.guid = guid();
|
|
94
88
|
this.ignoreSelectedEventsFlag = false;
|
|
95
89
|
this.internalValueChangeFlag = false;
|
|
90
|
+
this.previousAllSelected = false;
|
|
91
|
+
this.refreshingSelectionDisplay = false;
|
|
96
92
|
this.mutationObserver = createObserver("mutation", () => this.updateItems());
|
|
97
93
|
this.onLabelClick = () => {
|
|
98
94
|
this.setFocus();
|
|
99
95
|
};
|
|
100
96
|
this.transitionProp = "opacity";
|
|
101
|
-
this.resizeObserver =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
this.resizeObserver = (() => {
|
|
98
|
+
let resizeWorkQueued = false;
|
|
99
|
+
return createObserver("resize", () => {
|
|
100
|
+
if (resizeWorkQueued) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
resizeWorkQueued = true;
|
|
104
|
+
requestAnimationFrame(() => {
|
|
105
|
+
resizeWorkQueued = false;
|
|
106
|
+
this.setMaxScrollerHeight();
|
|
107
|
+
this.refreshSelectionDisplay();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
})();
|
|
105
111
|
this.selectedIndicatorChipRef = createRef();
|
|
112
|
+
this.selectedChipCountRef = createRef();
|
|
106
113
|
this.clearButtonRef = createRef();
|
|
107
114
|
this._selectedItems = [];
|
|
108
115
|
this.textInputRef = createRef();
|
|
@@ -120,8 +127,10 @@ class Combobox extends LitElement {
|
|
|
120
127
|
this.activeDescendant = "";
|
|
121
128
|
this.activeItemIndex = -1;
|
|
122
129
|
this.compactSelectionDisplay = false;
|
|
130
|
+
this.deferFitChipCountRender = false;
|
|
123
131
|
this.selectedHiddenChipsCount = 0;
|
|
124
132
|
this.selectedVisibleChipsCount = 0;
|
|
133
|
+
this.fitUsingCompactCountLabel = false;
|
|
125
134
|
this.allItems = [];
|
|
126
135
|
this.items = [];
|
|
127
136
|
this.clearDisabled = false;
|
|
@@ -153,7 +162,7 @@ class Combobox extends LitElement {
|
|
|
153
162
|
this.listen("click", this.comboboxFocusHandler);
|
|
154
163
|
}
|
|
155
164
|
static {
|
|
156
|
-
this.properties = { activeChipIndex: [16, {}, { state: true }], activeDescendant: [16, {}, { state: true }], activeItemIndex: [16, {}, { state: true }], compactSelectionDisplay: [16, {}, { state: true }], selectedHiddenChipsCount: [16, {}, { state: true }], selectedVisibleChipsCount: [16, {}, { state: true }], allItems: [16, {}, { state: true }], items: [16, {}, { state: true }], noMatchesFound: [16, {}, { state: true }], allowCustomValues: [7, {}, { reflect: true, type: Boolean }], clearDisabled: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], filterText: [3, {}, { reflect: true }], filterProps: [0, {}, { attribute: false }], filteredItems: [32, {}, { attribute: false, readOnly: true }], flipPlacements: [0, {}, { attribute: false }], form: [3, {}, { reflect: true }], label: 1, labelText: 1, maxItems: [11, {}, { reflect: true, type: Number }], messageOverrides: [0, {}, { attribute: false }], name: [3, {}, { reflect: true }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placeholder: 1, placeholderIcon: [3, { type: String }, { reflect: true }], placeholderIconFlipRtl: [7, {}, { reflect: true, type: Boolean }], placement: [3, {}, { reflect: true }], readOnly: [7, {}, { reflect: true, type: Boolean }], required: [7, {}, { reflect: true, type: Boolean }], scale: [3, {}, { reflect: true }], selectAllEnabled: [7, {}, { reflect: true, type: Boolean }], selectedItems: [0, {}, { attribute: false }], selectionDisplay: [3, {}, { reflect: true }], selectionAppearance: [3, {}, { reflect: true }], selectionMode: [3, {}, { reflect: true }], status: [3, {}, { reflect: true }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], validationIcon: [3, { converter: stringOrBoolean, type: String }, { reflect: true }], validationMessage: 1, validity: [32, {}, { readOnly: true, attribute: false }], value: 1 };
|
|
165
|
+
this.properties = { activeChipIndex: [16, {}, { state: true }], activeDescendant: [16, {}, { state: true }], activeItemIndex: [16, {}, { state: true }], compactSelectionDisplay: [16, {}, { state: true }], deferFitChipCountRender: [16, {}, { state: true }], selectedHiddenChipsCount: [16, {}, { state: true }], selectedVisibleChipsCount: [16, {}, { state: true }], fitUsingCompactCountLabel: [16, {}, { state: true }], allItems: [16, {}, { state: true }], items: [16, {}, { state: true }], noMatchesFound: [16, {}, { state: true }], allowCustomValues: [7, {}, { reflect: true, type: Boolean }], clearDisabled: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], filterText: [3, {}, { reflect: true }], filterProps: [0, {}, { attribute: false }], filteredItems: [32, {}, { attribute: false, readOnly: true }], flipPlacements: [0, {}, { attribute: false }], form: [3, {}, { reflect: true }], label: 1, labelText: 1, maxItems: [11, {}, { reflect: true, type: Number }], messageOverrides: [0, {}, { attribute: false }], name: [3, {}, { reflect: true }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placeholder: 1, placeholderIcon: [3, { type: String }, { reflect: true }], placeholderIconFlipRtl: [7, {}, { reflect: true, type: Boolean }], placement: [3, {}, { reflect: true }], readOnly: [7, {}, { reflect: true, type: Boolean }], required: [7, {}, { reflect: true, type: Boolean }], scale: [3, {}, { reflect: true }], selectAllEnabled: [7, {}, { reflect: true, type: Boolean }], selectedItems: [0, {}, { attribute: false }], selectionDisplay: [3, {}, { reflect: true }], selectionAppearance: [3, {}, { reflect: true }], selectionMode: [3, {}, { reflect: true }], status: [3, {}, { reflect: true }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], validationIcon: [3, { converter: stringOrBoolean, type: String }, { reflect: true }], validationMessage: 1, validity: [32, {}, { readOnly: true, attribute: false }], value: 1 };
|
|
157
166
|
}
|
|
158
167
|
static {
|
|
159
168
|
this.formAssociated = true;
|
|
@@ -178,9 +187,6 @@ class Combobox extends LitElement {
|
|
|
178
187
|
const enabledItems = this.allItems.filter((item) => !item.disabled);
|
|
179
188
|
return enabledItems.length > 0 && enabledItems.every((item) => item.selected);
|
|
180
189
|
}
|
|
181
|
-
get hasDisabledItems() {
|
|
182
|
-
return this.allItems.some((item) => item.disabled);
|
|
183
|
-
}
|
|
184
190
|
get hasDisabledSelected() {
|
|
185
191
|
return this.allItems.some((item) => item.disabled && item.selected);
|
|
186
192
|
}
|
|
@@ -325,11 +331,33 @@ class Combobox extends LitElement {
|
|
|
325
331
|
this.reposition(true);
|
|
326
332
|
}
|
|
327
333
|
selectedItemsHandler() {
|
|
334
|
+
const wasAllSelected = this.previousAllSelected;
|
|
335
|
+
const isAllSelected = this.allSelected;
|
|
336
|
+
this.previousAllSelected = isAllSelected;
|
|
328
337
|
this.internalValueChangeFlag = true;
|
|
329
338
|
this.value = this.getValue();
|
|
330
339
|
this.internalValueChangeFlag = false;
|
|
331
340
|
if (this.selectionDisplay === "fit" && this.isMulti()) {
|
|
332
|
-
|
|
341
|
+
const transitioningFromAllSelected = wasAllSelected && !isAllSelected;
|
|
342
|
+
if (wasAllSelected && !isAllSelected) {
|
|
343
|
+
this.selectedHiddenChipsCount = 0;
|
|
344
|
+
this.selectedItems.forEach((item) => {
|
|
345
|
+
const chipEl = this.referenceEl?.querySelector(`#${IDS.chip(item.guid)}`);
|
|
346
|
+
if (chipEl) {
|
|
347
|
+
this.showChip(chipEl);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
this.updateComplete.then(async () => {
|
|
352
|
+
if (transitioningFromAllSelected) {
|
|
353
|
+
await this.updateComplete;
|
|
354
|
+
}
|
|
355
|
+
await this.refreshSelectionDisplay();
|
|
356
|
+
if (this.fitFollowUpRefreshPromise) {
|
|
357
|
+
await this.fitFollowUpRefreshPromise;
|
|
358
|
+
}
|
|
359
|
+
this.deferFitChipCountRender = false;
|
|
360
|
+
});
|
|
333
361
|
}
|
|
334
362
|
}
|
|
335
363
|
async documentClickHandler(event) {
|
|
@@ -348,10 +376,11 @@ class Combobox extends LitElement {
|
|
|
348
376
|
this.open = false;
|
|
349
377
|
}
|
|
350
378
|
handleSelectAll(isSelectAllTarget) {
|
|
351
|
-
if (isSelectAllTarget) {
|
|
352
|
-
|
|
379
|
+
if (!isSelectAllTarget) {
|
|
380
|
+
return;
|
|
353
381
|
}
|
|
354
|
-
|
|
382
|
+
this.toggleSelectAll();
|
|
383
|
+
if (this.selectionDisplay !== "fit" && this.allSelected) {
|
|
355
384
|
this.selectedItems.forEach((item) => {
|
|
356
385
|
const chipEl = this.referenceEl.querySelector(`#${IDS.chip(item.guid)}`);
|
|
357
386
|
if (chipEl) {
|
|
@@ -360,6 +389,9 @@ class Combobox extends LitElement {
|
|
|
360
389
|
});
|
|
361
390
|
}
|
|
362
391
|
}
|
|
392
|
+
updateSelectedItems() {
|
|
393
|
+
this.selectedItems = this.getOrderedSelectedItems(this.getSelectedItems());
|
|
394
|
+
}
|
|
363
395
|
calciteComboboxItemChangeHandler(event) {
|
|
364
396
|
if (this.ignoreSelectedEventsFlag) {
|
|
365
397
|
return;
|
|
@@ -372,7 +404,6 @@ class Combobox extends LitElement {
|
|
|
372
404
|
const newIndex = this.keyboardNavItems.indexOf(isSelectAllTarget ? this.selectAllComboboxItemRef.value : target);
|
|
373
405
|
this.updateActiveItemIndex(newIndex);
|
|
374
406
|
this.toggleSelection(target, target.selected);
|
|
375
|
-
this.selectedItems = this.getSelectedItems();
|
|
376
407
|
}
|
|
377
408
|
calciteInternalComboboxItemChangeHandler(event) {
|
|
378
409
|
event.stopPropagation();
|
|
@@ -381,11 +412,14 @@ class Combobox extends LitElement {
|
|
|
381
412
|
}
|
|
382
413
|
}
|
|
383
414
|
clearValue() {
|
|
384
|
-
this.
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
415
|
+
const enabledSelectedItems = this.items.filter((item) => item.selected && !item.disabled);
|
|
416
|
+
if (enabledSelectedItems.length) {
|
|
417
|
+
this.ignoreSelectedEventsFlag = true;
|
|
418
|
+
enabledSelectedItems.forEach((el) => el.selected = false);
|
|
419
|
+
this.ignoreSelectedEventsFlag = false;
|
|
420
|
+
this.updateSelectedItems();
|
|
421
|
+
this.emitComboboxChange();
|
|
422
|
+
}
|
|
389
423
|
this.open = false;
|
|
390
424
|
this.updateActiveItemIndex(-1);
|
|
391
425
|
this.resetText();
|
|
@@ -403,9 +437,19 @@ class Combobox extends LitElement {
|
|
|
403
437
|
this.filteredFlipPlacements = flipPlacements ? filterValidFlipPlacements(flipPlacements, el) : null;
|
|
404
438
|
}
|
|
405
439
|
getValue() {
|
|
406
|
-
const items = this.selectedItems.map((item) => item.value?.toString());
|
|
440
|
+
const items = this.getOrderedSelectedValues(this.selectedItems.map((item) => item.value?.toString()));
|
|
407
441
|
return items.length ? items.length > 1 ? items : items[0] : "";
|
|
408
442
|
}
|
|
443
|
+
getOrderedSelectedValues(selectedValues) {
|
|
444
|
+
if (!this.isMulti()) {
|
|
445
|
+
return selectedValues;
|
|
446
|
+
}
|
|
447
|
+
const previousValues = Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
|
|
448
|
+
return orderValuesByPrevious(selectedValues, previousValues);
|
|
449
|
+
}
|
|
450
|
+
getOrderedSelectedItems(selectedItems) {
|
|
451
|
+
return this.isMulti() ? orderByPrevious(selectedItems, this.selectedItems) : selectedItems;
|
|
452
|
+
}
|
|
409
453
|
comboboxInViewport() {
|
|
410
454
|
const bounding = this.el.getBoundingClientRect();
|
|
411
455
|
return bounding.top >= 0 && bounding.left >= 0 && bounding.right <= (window.innerWidth || document.documentElement.clientWidth) && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight);
|
|
@@ -418,9 +462,16 @@ class Combobox extends LitElement {
|
|
|
418
462
|
}
|
|
419
463
|
item.selected = toggledValue;
|
|
420
464
|
});
|
|
421
|
-
this.
|
|
465
|
+
this.updateSelectedItems();
|
|
422
466
|
this.emitComboboxChange();
|
|
423
467
|
}
|
|
468
|
+
hasHiddenSelectedFitChips() {
|
|
469
|
+
if (this.selectionDisplay !== "fit" || !this.isMulti()) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
const hiddenCountChip = this.selectedChipCountRef.value;
|
|
473
|
+
return !!hiddenCountChip && !hiddenCountChip.classList.contains(CSS.chipInvisible);
|
|
474
|
+
}
|
|
424
475
|
keyDownHandler(event) {
|
|
425
476
|
if (this.readOnly) {
|
|
426
477
|
return;
|
|
@@ -547,13 +598,16 @@ class Combobox extends LitElement {
|
|
|
547
598
|
break;
|
|
548
599
|
case "Delete":
|
|
549
600
|
case "Backspace": {
|
|
550
|
-
const
|
|
601
|
+
const fitDeleteBlockedByOverflow = this.hasHiddenSelectedFitChips();
|
|
602
|
+
const overflowDeleteBlocked = fitDeleteBlockedByOverflow && this.activeChipIndex === -1;
|
|
603
|
+
const notDeletable = this.selectionDisplay === "single" || overflowDeleteBlocked;
|
|
551
604
|
if (notDeletable) {
|
|
552
605
|
return;
|
|
553
606
|
}
|
|
554
|
-
|
|
607
|
+
const deleteTargetChip = event.composedPath().find((node) => isChip(node));
|
|
608
|
+
if (this.activeChipIndex > -1 && deleteTargetChip) {
|
|
555
609
|
event.preventDefault();
|
|
556
|
-
this.removeActiveChip(
|
|
610
|
+
this.removeActiveChip(deleteTargetChip);
|
|
557
611
|
} else if (!this.filterText && this.isMulti()) {
|
|
558
612
|
event.preventDefault();
|
|
559
613
|
this.removeLastChip();
|
|
@@ -601,7 +655,7 @@ class Combobox extends LitElement {
|
|
|
601
655
|
return;
|
|
602
656
|
}
|
|
603
657
|
const composedPath = event.composedPath();
|
|
604
|
-
if (composedPath.some((node) => node
|
|
658
|
+
if (composedPath.some((node) => isChip(node))) {
|
|
605
659
|
this.open = false;
|
|
606
660
|
event.preventDefault();
|
|
607
661
|
return;
|
|
@@ -630,35 +684,63 @@ class Combobox extends LitElement {
|
|
|
630
684
|
showChip(chipEl) {
|
|
631
685
|
chipEl.classList.remove(CSS.chipInvisible);
|
|
632
686
|
}
|
|
633
|
-
refreshChipDisplay({ chipEls, availableHorizontalChipElSpace, chipContainerElGap }) {
|
|
687
|
+
refreshChipDisplay({ chipEls, availableHorizontalChipElSpace, chipContainerElGap, hideSelectedChips }) {
|
|
688
|
+
const selectedChipEls = chipEls.filter((chipEl) => chipEl.selected);
|
|
689
|
+
const enabledSelectedChipEls = selectedChipEls.filter((chipEl) => !chipEl.disabled);
|
|
690
|
+
const disabledSelectedChipEls = selectedChipEls.filter((chipEl) => chipEl.disabled);
|
|
691
|
+
const getChipWidth = (chipEl) => {
|
|
692
|
+
const computedWidth = getElementWidth(chipEl);
|
|
693
|
+
const fallbackWidth = chipEl.getBoundingClientRect().width;
|
|
694
|
+
return Number.isFinite(computedWidth) && computedWidth > 0 ? computedWidth : fallbackWidth;
|
|
695
|
+
};
|
|
696
|
+
selectedChipEls.forEach((chipEl) => getChipWidth(chipEl));
|
|
634
697
|
chipEls.forEach((chipEl) => {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
698
|
+
this.hideChip(chipEl);
|
|
699
|
+
});
|
|
700
|
+
if (hideSelectedChips) {
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
const renderFittingChips = (chips) => {
|
|
704
|
+
let visibleChipsCount = 0;
|
|
705
|
+
chips.forEach((chipEl) => {
|
|
706
|
+
const chipElWidth = getChipWidth(chipEl);
|
|
707
|
+
if (chipElWidth && chipElWidth <= availableHorizontalChipElSpace) {
|
|
640
708
|
availableHorizontalChipElSpace -= chipElWidth + chipContainerElGap;
|
|
641
709
|
this.showChip(chipEl);
|
|
642
|
-
|
|
710
|
+
visibleChipsCount++;
|
|
643
711
|
}
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
}
|
|
712
|
+
});
|
|
713
|
+
return visibleChipsCount;
|
|
714
|
+
};
|
|
715
|
+
const visibleEnabledChipsCount = renderFittingChips(enabledSelectedChipEls);
|
|
716
|
+
if (visibleEnabledChipsCount <= 1) {
|
|
717
|
+
renderFittingChips(disabledSelectedChipEls);
|
|
718
|
+
}
|
|
647
719
|
}
|
|
648
|
-
async refreshSelectionDisplay() {
|
|
649
|
-
this.
|
|
720
|
+
async refreshSelectionDisplay(followUpRefresh = true) {
|
|
721
|
+
if (this.refreshingSelectionDisplay) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
this.refreshingSelectionDisplay = true;
|
|
725
|
+
await this.componentOnReady();
|
|
650
726
|
if (isSingleLike(this.selectionMode)) {
|
|
727
|
+
this.refreshingSelectionDisplay = false;
|
|
651
728
|
return;
|
|
652
729
|
}
|
|
653
730
|
if (!this.textInputRef.value || !this.chipContainerEl) {
|
|
731
|
+
this.refreshingSelectionDisplay = false;
|
|
654
732
|
return;
|
|
655
733
|
}
|
|
656
734
|
const { allSelectedIndicatorChipRef, chipContainerEl, selectionDisplay, placeholder, selectedIndicatorChipRef, textInputRef } = this;
|
|
657
|
-
const chipContainerElGap = parseInt(getComputedStyle(chipContainerEl).gap
|
|
735
|
+
const chipContainerElGap = parseInt(getComputedStyle(chipContainerEl).gap);
|
|
658
736
|
const chipContainerElWidth = getElementWidth(chipContainerEl);
|
|
659
|
-
const { fontSize, fontFamily } = getComputedStyle(textInputRef.value);
|
|
660
|
-
const
|
|
661
|
-
const
|
|
737
|
+
const { fontSize, fontFamily, minInlineSize } = getComputedStyle(textInputRef.value);
|
|
738
|
+
const placeholderWidthMultiplier = 0.55;
|
|
739
|
+
const inputMinWidth = parseFloat(minInlineSize) || parseInt(calciteSize48);
|
|
740
|
+
const measuredPlaceholderWidth = getTextWidth(placeholder, `${fontSize} ${fontFamily}`);
|
|
741
|
+
const placeholderWidth = measuredPlaceholderWidth > 0 ? measuredPlaceholderWidth : Math.max(inputMinWidth, Math.round((placeholder?.length || 0) * (parseFloat(fontSize) || parseInt(calciteSize48)) * placeholderWidthMultiplier));
|
|
742
|
+
const fitInputWidth = Math.max(inputMinWidth, placeholderWidth);
|
|
743
|
+
const inputWidth = (selectionDisplay === "fit" ? fitInputWidth : placeholderWidth) + chipContainerElGap;
|
|
662
744
|
const allSelectedIndicatorChipElWidth = getElementWidth(allSelectedIndicatorChipRef.value);
|
|
663
745
|
const selectedIndicatorChipElWidth = getElementWidth(selectedIndicatorChipRef.value);
|
|
664
746
|
const largestSelectedIndicatorChipWidth = Math.max(allSelectedIndicatorChipElWidth, selectedIndicatorChipElWidth);
|
|
@@ -668,7 +750,7 @@ class Combobox extends LitElement {
|
|
|
668
750
|
inputWidth,
|
|
669
751
|
largestSelectedIndicatorChipWidth
|
|
670
752
|
});
|
|
671
|
-
if (
|
|
753
|
+
if (selectionDisplay !== "fit" && this.allSelected && this.selectAllEnabled) {
|
|
672
754
|
this.selectedItems.forEach((item) => {
|
|
673
755
|
const chipEl = this.referenceEl.querySelector(`#${IDS.chip(item.guid)}`);
|
|
674
756
|
if (chipEl) {
|
|
@@ -685,16 +767,64 @@ class Combobox extends LitElement {
|
|
|
685
767
|
});
|
|
686
768
|
}
|
|
687
769
|
if (selectionDisplay === "fit") {
|
|
688
|
-
const chipEls = Array.from(this.el.shadowRoot.querySelectorAll("calcite-chip")).filter((chipEl) =>
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
770
|
+
const chipEls = Array.from(this.el.shadowRoot.querySelectorAll("calcite-chip")).filter((chipEl) => {
|
|
771
|
+
const chipValue = chipEl.value;
|
|
772
|
+
const hasValue = chipValue != null && `${chipValue}` !== "";
|
|
773
|
+
return chipEl.disabled || hasValue;
|
|
774
|
+
});
|
|
775
|
+
const { hiddenChipIndicatorWidth, hideSelectedChips, reservedPlaceholderInputWidth } = this.getFitCompactDisplayState({
|
|
776
|
+
chipContainerElGap,
|
|
777
|
+
chipContainerElWidth,
|
|
778
|
+
inputMinWidth,
|
|
779
|
+
placeholderWidth,
|
|
780
|
+
selectedIndicatorChipElWidth
|
|
781
|
+
});
|
|
782
|
+
this.fitUsingCompactCountLabel = hideSelectedChips;
|
|
783
|
+
const availableHorizontalChipElSpace = Math.round(chipContainerElWidth - (hiddenChipIndicatorWidth + chipContainerElGap + reservedPlaceholderInputWidth + chipContainerElGap));
|
|
784
|
+
this.refreshChipDisplay({
|
|
785
|
+
availableHorizontalChipElSpace,
|
|
786
|
+
chipContainerElGap,
|
|
787
|
+
chipEls,
|
|
788
|
+
hideSelectedChips
|
|
789
|
+
});
|
|
790
|
+
const previousHiddenChipsCount = this.selectedHiddenChipsCount;
|
|
791
|
+
this.syncChipVisibilityCounts(chipEls);
|
|
792
|
+
const didHiddenCountChange = previousHiddenChipsCount !== this.selectedHiddenChipsCount;
|
|
793
|
+
if (didHiddenCountChange && followUpRefresh) {
|
|
794
|
+
this.fitFollowUpRefreshPromise = this.updateComplete.then(() => this.refreshSelectionDisplay(false)).then(() => {
|
|
795
|
+
this.fitFollowUpRefreshPromise = null;
|
|
796
|
+
});
|
|
797
|
+
}
|
|
692
798
|
}
|
|
799
|
+
this.refreshingSelectionDisplay = false;
|
|
693
800
|
}
|
|
694
801
|
setFloatingEl(el) {
|
|
695
802
|
this.floatingEl = el;
|
|
696
803
|
connectFloatingUI(this);
|
|
697
804
|
}
|
|
805
|
+
shouldUseFitCompactDisplay({ chipContainerElGap, chipContainerElWidth, hiddenChipIndicatorWidth, inputMinWidth, placeholderWidth, reservedPlaceholderInputWidth }) {
|
|
806
|
+
const availableHorizontalChipElSpaceWithPlaceholder = Math.round(chipContainerElWidth - (hiddenChipIndicatorWidth + chipContainerElGap + reservedPlaceholderInputWidth + chipContainerElGap));
|
|
807
|
+
const placeholderIsReallyLong = placeholderWidth > inputMinWidth * 2;
|
|
808
|
+
return placeholderIsReallyLong && availableHorizontalChipElSpaceWithPlaceholder <= 0;
|
|
809
|
+
}
|
|
810
|
+
getFitCompactDisplayState({ chipContainerElGap, chipContainerElWidth, inputMinWidth, placeholderWidth, selectedIndicatorChipElWidth }) {
|
|
811
|
+
const selectedChipCountElWidth = getElementWidth(this.selectedChipCountRef.value);
|
|
812
|
+
const hiddenChipIndicatorWidth = this.deferFitChipCountRender || this.selectedHiddenChipsCount <= 0 ? 0 : selectedChipCountElWidth || selectedIndicatorChipElWidth;
|
|
813
|
+
const reservedPlaceholderInputWidth = Math.max(inputMinWidth, placeholderWidth);
|
|
814
|
+
const hideSelectedChips = this.shouldUseFitCompactDisplay({
|
|
815
|
+
chipContainerElGap,
|
|
816
|
+
chipContainerElWidth,
|
|
817
|
+
hiddenChipIndicatorWidth,
|
|
818
|
+
inputMinWidth,
|
|
819
|
+
placeholderWidth,
|
|
820
|
+
reservedPlaceholderInputWidth
|
|
821
|
+
});
|
|
822
|
+
return {
|
|
823
|
+
hiddenChipIndicatorWidth,
|
|
824
|
+
hideSelectedChips,
|
|
825
|
+
reservedPlaceholderInputWidth
|
|
826
|
+
};
|
|
827
|
+
}
|
|
698
828
|
setCompactSelectionDisplay({ chipContainerElGap, chipContainerElWidth, inputWidth, largestSelectedIndicatorChipWidth }) {
|
|
699
829
|
const newCompactBreakpoint = Math.round(largestSelectedIndicatorChipWidth + chipContainerElGap + inputWidth);
|
|
700
830
|
if (!this.maxCompactBreakpoint || this.maxCompactBreakpoint < newCompactBreakpoint) {
|
|
@@ -715,17 +845,21 @@ class Combobox extends LitElement {
|
|
|
715
845
|
this.referenceEl = el;
|
|
716
846
|
connectFloatingUI(this);
|
|
717
847
|
}
|
|
718
|
-
|
|
848
|
+
syncChipVisibilityCounts(chipEls) {
|
|
719
849
|
let newSelectedVisibleChipsCount = 0;
|
|
850
|
+
let selectedChipCount = 0;
|
|
720
851
|
chipEls.forEach((chipEl) => {
|
|
721
|
-
if (chipEl.selected
|
|
722
|
-
|
|
852
|
+
if (chipEl.selected) {
|
|
853
|
+
selectedChipCount++;
|
|
854
|
+
if (!chipEl.classList.contains(CSS.chipInvisible)) {
|
|
855
|
+
newSelectedVisibleChipsCount++;
|
|
856
|
+
}
|
|
723
857
|
}
|
|
724
858
|
});
|
|
725
859
|
if (newSelectedVisibleChipsCount !== this.selectedVisibleChipsCount) {
|
|
726
860
|
this.selectedVisibleChipsCount = newSelectedVisibleChipsCount;
|
|
727
861
|
}
|
|
728
|
-
const newSelectedHiddenChipsCount = Math.max(0,
|
|
862
|
+
const newSelectedHiddenChipsCount = Math.max(0, selectedChipCount - newSelectedVisibleChipsCount);
|
|
729
863
|
if (newSelectedHiddenChipsCount !== this.selectedHiddenChipsCount) {
|
|
730
864
|
this.selectedHiddenChipsCount = newSelectedHiddenChipsCount;
|
|
731
865
|
}
|
|
@@ -770,6 +904,9 @@ class Combobox extends LitElement {
|
|
|
770
904
|
if (!item || this.selectionMode === "single-persist" && item.selected && item.value === this.value && !value) {
|
|
771
905
|
return;
|
|
772
906
|
}
|
|
907
|
+
if (this.selectionDisplay === "fit" && this.isMulti()) {
|
|
908
|
+
this.deferFitChipCountRender = true;
|
|
909
|
+
}
|
|
773
910
|
if (this.isMulti()) {
|
|
774
911
|
this.handleMultiSelection(item, value);
|
|
775
912
|
} else {
|
|
@@ -779,7 +916,7 @@ class Combobox extends LitElement {
|
|
|
779
916
|
handleMultiSelection(item, value) {
|
|
780
917
|
item.selected = value;
|
|
781
918
|
this.updateAncestors(item);
|
|
782
|
-
this.
|
|
919
|
+
this.updateSelectedItems();
|
|
783
920
|
this.emitComboboxChange();
|
|
784
921
|
this.resetText();
|
|
785
922
|
this.filterItems("");
|
|
@@ -788,7 +925,7 @@ class Combobox extends LitElement {
|
|
|
788
925
|
this.ignoreSelectedEventsFlag = true;
|
|
789
926
|
this.items.forEach((el) => el.selected = el === item ? value : false);
|
|
790
927
|
this.ignoreSelectedEventsFlag = false;
|
|
791
|
-
this.
|
|
928
|
+
this.updateSelectedItems();
|
|
792
929
|
this.emitComboboxChange();
|
|
793
930
|
if (this.textInputRef.value) {
|
|
794
931
|
this.textInputRef.value.value = getLabel(item);
|
|
@@ -805,11 +942,14 @@ class Combobox extends LitElement {
|
|
|
805
942
|
const ancestors = getItemAncestors(item);
|
|
806
943
|
const children = getItemChildren(item);
|
|
807
944
|
if (item.selected) {
|
|
808
|
-
ancestors.forEach((el) => {
|
|
945
|
+
[...children, ...ancestors].forEach((el) => {
|
|
946
|
+
if (el.disabled) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
809
949
|
el.selected = true;
|
|
810
950
|
});
|
|
811
951
|
} else {
|
|
812
|
-
children.forEach((el) => {
|
|
952
|
+
[...children].forEach((el) => {
|
|
813
953
|
if (el.disabled) {
|
|
814
954
|
return;
|
|
815
955
|
}
|
|
@@ -829,7 +969,8 @@ class Combobox extends LitElement {
|
|
|
829
969
|
this.data = this.getData();
|
|
830
970
|
this.groupData = this.getGroupData();
|
|
831
971
|
this.updateItemProps();
|
|
832
|
-
this.
|
|
972
|
+
this.updateSelectedItems();
|
|
973
|
+
this.previousAllSelected = this.allSelected;
|
|
833
974
|
}
|
|
834
975
|
updateItemProps() {
|
|
835
976
|
this.allItems.forEach((item) => {
|
|
@@ -903,13 +1044,17 @@ class Combobox extends LitElement {
|
|
|
903
1044
|
}
|
|
904
1045
|
removeActiveChip(chip) {
|
|
905
1046
|
const activeItem = this.selectedItems[this.activeChipIndex];
|
|
906
|
-
if (activeItem && `${IDS.chip(activeItem.guid)}` === chip.id) {
|
|
1047
|
+
if (activeItem && !activeItem.disabled && `${IDS.chip(activeItem.guid)}` === chip.id) {
|
|
907
1048
|
this.toggleSelection(activeItem, false);
|
|
908
1049
|
}
|
|
909
1050
|
this.setFocus();
|
|
910
1051
|
}
|
|
911
1052
|
removeLastChip() {
|
|
912
|
-
this.
|
|
1053
|
+
const lastEnabledSelectedItem = this.selectedItems.findLast((item) => !item.disabled);
|
|
1054
|
+
if (!lastEnabledSelectedItem) {
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
this.toggleSelection(lastEnabledSelectedItem, false);
|
|
913
1058
|
this.setFocus();
|
|
914
1059
|
}
|
|
915
1060
|
previousChip() {
|
|
@@ -980,7 +1125,11 @@ class Combobox extends LitElement {
|
|
|
980
1125
|
if (this.disabled) {
|
|
981
1126
|
return;
|
|
982
1127
|
}
|
|
1128
|
+
this.activeChipIndex = -1;
|
|
983
1129
|
this.textInputRef.value.focus();
|
|
1130
|
+
if (this.open && this.selectionDisplay === "fit" && this.isMulti()) {
|
|
1131
|
+
void this.refreshSelectionDisplay();
|
|
1132
|
+
}
|
|
984
1133
|
}
|
|
985
1134
|
createScreenReaderItem({ ariaLabel, ariaSelected, id, textContent }) {
|
|
986
1135
|
return html`<li aria-label=${ariaLabel ?? nothing} aria-selected=${ariaSelected ?? nothing} id=${id ?? nothing} role=option tabindex=-1>${textContent}</li>`;
|
|
@@ -1006,64 +1155,58 @@ class Combobox extends LitElement {
|
|
|
1006
1155
|
return keyed(item.guid || item.value || label, html`<calcite-chip .appearance=${readOnly ? "outline" : "solid"} class=${safeClassMap({
|
|
1007
1156
|
[CSS.chip]: true,
|
|
1008
1157
|
[CSS.disabled]: disabled
|
|
1009
|
-
})} .closable=${!disabled && !readOnly} .disabled=${disabled} .icon=${item.icon} .iconFlipRtl=${item.iconFlipRtl} id=${(!disabled && item.guid ? `${IDS.chip(item.guid)}` : null) ?? nothing} .label=${label} .messageOverrides=${!disabled ? { dismissLabel: messages.removeTag } : null} @calciteChipClose=${!disabled ? () => this.calciteChipCloseHandler(item) : null} @focusin=${!disabled ? () => this.activeChipIndex = index : null} .scale=${scale} .selected=${item.selected} .tabIndex=${!disabled && activeChipIndex === index ? 0 : -1} title=${label ?? nothing} .value=${item.value}>${label}</calcite-chip>`);
|
|
1158
|
+
})} .closable=${!disabled && !readOnly} data-testid=${`${disabled ? "disabled-chip" : "chip"}-${index}`} .disabled=${disabled} .icon=${item.icon} .iconFlipRtl=${item.iconFlipRtl} id=${(!disabled && item.guid ? `${IDS.chip(item.guid)}` : null) ?? nothing} .label=${label} .messageOverrides=${!disabled ? { dismissLabel: messages.removeTag } : null} @calciteChipClose=${!disabled ? () => this.calciteChipCloseHandler(item) : null} @focusin=${!disabled ? () => this.activeChipIndex = index : null} .scale=${scale} .selected=${item.selected} .tabIndex=${!disabled && activeChipIndex === index ? 0 : -1} title=${label ?? nothing} .value=${item.value}>${label}</calcite-chip>`);
|
|
1010
1159
|
}
|
|
1011
1160
|
renderChipCount(count, scale) {
|
|
1012
|
-
const label = this.messages.disabledSelectedCount?.replace("{count}", `${count}`) ?? `+${count}`;
|
|
1161
|
+
const label = this.fitUsingCompactCountLabel ? `${count}` : this.messages.disabledSelectedCount?.replace("{count}", `${count}`) ?? `+${count}`;
|
|
1013
1162
|
return html`<calcite-chip appearance=solid class=${safeClassMap({
|
|
1014
1163
|
[CSS.chip]: true
|
|
1015
|
-
})} .label=${label} .scale=${scale} tabindex=-1 title=${label ?? nothing}>${label}</calcite-chip>`;
|
|
1164
|
+
})} data-testid=selected-chip-count id=selected-chip-count .label=${label} .scale=${scale} tabindex=-1 title=${label ?? nothing} ${ref(this.selectedChipCountRef)}>${label}</calcite-chip>`;
|
|
1016
1165
|
}
|
|
1017
1166
|
renderChips() {
|
|
1018
1167
|
const { activeChipIndex, readOnly, scale, selectionDisplay, selectionMode, messages } = this;
|
|
1019
1168
|
const chips = [];
|
|
1020
1169
|
const isAncestors = selectionMode === "ancestors";
|
|
1021
|
-
const
|
|
1022
|
-
const allSelectedWithDisabledSelected = this.allSelected && this.hasDisabledSelected;
|
|
1023
|
-
const disabledItems = this.allItems.filter((item) => item.disabled && item.selected && (!isAncestors || !hasActiveChildren(item)));
|
|
1170
|
+
const hideSelectedChipsForSelectAll = this.selectAllEnabled && this.allSelected;
|
|
1024
1171
|
const preserveOrder = selectionDisplay === "all";
|
|
1025
|
-
if (
|
|
1172
|
+
if (hideSelectedChipsForSelectAll) {
|
|
1026
1173
|
return null;
|
|
1027
1174
|
}
|
|
1028
1175
|
let selectedIndex = 0;
|
|
1029
1176
|
let disabledIndex = 0;
|
|
1030
1177
|
if (preserveOrder) {
|
|
1031
|
-
this.allItems.
|
|
1178
|
+
const selectedChipItems = this.allItems.filter((item) => item.selected && (!isAncestors || !hasActiveChildren(item)));
|
|
1179
|
+
const orderedSelectedChipItems = orderByPrevious(selectedChipItems, this.selectedItems);
|
|
1180
|
+
orderedSelectedChipItems.forEach((item) => {
|
|
1032
1181
|
if (item.disabled) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}));
|
|
1044
|
-
}
|
|
1182
|
+
chips.push(this.renderChip({
|
|
1183
|
+
activeChipIndex,
|
|
1184
|
+
disabled: true,
|
|
1185
|
+
index: disabledIndex++,
|
|
1186
|
+
item,
|
|
1187
|
+
messages,
|
|
1188
|
+
readOnly,
|
|
1189
|
+
scale,
|
|
1190
|
+
isAncestors
|
|
1191
|
+
}));
|
|
1045
1192
|
return;
|
|
1046
1193
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
isAncestors
|
|
1058
|
-
}));
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1194
|
+
chips.push(this.renderChip({
|
|
1195
|
+
activeChipIndex,
|
|
1196
|
+
disabled: false,
|
|
1197
|
+
index: selectedIndex++,
|
|
1198
|
+
item,
|
|
1199
|
+
messages,
|
|
1200
|
+
readOnly,
|
|
1201
|
+
scale,
|
|
1202
|
+
isAncestors
|
|
1203
|
+
}));
|
|
1061
1204
|
});
|
|
1062
|
-
} else if (!
|
|
1205
|
+
} else if (!hideSelectedChipsForSelectAll) {
|
|
1063
1206
|
this.selectedItems.forEach((item) => {
|
|
1064
1207
|
chips.push(this.renderChip({
|
|
1065
1208
|
activeChipIndex,
|
|
1066
|
-
disabled:
|
|
1209
|
+
disabled: item.disabled,
|
|
1067
1210
|
index: selectedIndex++,
|
|
1068
1211
|
item,
|
|
1069
1212
|
messages,
|
|
@@ -1073,32 +1216,53 @@ class Combobox extends LitElement {
|
|
|
1073
1216
|
}));
|
|
1074
1217
|
});
|
|
1075
1218
|
}
|
|
1076
|
-
if (selectionDisplay === "fit"
|
|
1077
|
-
|
|
1219
|
+
if (selectionDisplay === "fit") {
|
|
1220
|
+
const hiddenSelectedCount = this.selectedHiddenChipsCount;
|
|
1221
|
+
const countChipValue = this.selectedVisibleChipsCount === 0 ? this.selectedItems.length : hiddenSelectedCount;
|
|
1222
|
+
if (hiddenSelectedCount > 0 && !this.deferFitChipCountRender) {
|
|
1223
|
+
chips.push(this.renderChipCount(countChipValue, scale));
|
|
1224
|
+
}
|
|
1078
1225
|
}
|
|
1079
1226
|
return chips.length ? chips : null;
|
|
1080
1227
|
}
|
|
1081
1228
|
renderAllSelectedIndicatorChip() {
|
|
1082
1229
|
const { allSelectedIndicatorChipRef, compactSelectionDisplay, scale, selectedVisibleChipsCount } = this;
|
|
1083
|
-
|
|
1084
|
-
|
|
1230
|
+
let useFitCompactLabel = false;
|
|
1231
|
+
if (this.selectionDisplay === "fit" && this.textInputRef.value && this.chipContainerEl) {
|
|
1232
|
+
const chipContainerElGap = parseInt(getComputedStyle(this.chipContainerEl).gap);
|
|
1233
|
+
const chipContainerElWidth = getElementWidth(this.chipContainerEl);
|
|
1234
|
+
const { fontSize, fontFamily, minInlineSize } = getComputedStyle(this.textInputRef.value);
|
|
1235
|
+
const placeholderWidthMultiplier = 0.55;
|
|
1236
|
+
const inputMinWidth = parseFloat(minInlineSize) || parseInt(calciteSize48);
|
|
1237
|
+
const measuredPlaceholderWidth = getTextWidth(this.placeholder, `${fontSize} ${fontFamily}`);
|
|
1238
|
+
const placeholderWidth = measuredPlaceholderWidth > 0 ? measuredPlaceholderWidth : Math.max(inputMinWidth, Math.round((this.placeholder?.length || 0) * (parseFloat(fontSize) || parseInt(calciteSize48)) * placeholderWidthMultiplier));
|
|
1239
|
+
const selectedIndicatorChipElWidth = getElementWidth(this.selectedIndicatorChipRef.value);
|
|
1240
|
+
useFitCompactLabel = this.getFitCompactDisplayState({
|
|
1241
|
+
chipContainerElGap,
|
|
1242
|
+
chipContainerElWidth,
|
|
1243
|
+
inputMinWidth,
|
|
1244
|
+
placeholderWidth,
|
|
1245
|
+
selectedIndicatorChipElWidth
|
|
1246
|
+
}).hideSelectedChips;
|
|
1247
|
+
}
|
|
1248
|
+
const useCompactAllLabel = compactSelectionDisplay || useFitCompactLabel;
|
|
1249
|
+
const label = useCompactAllLabel ? this.messages.all : this.messages.allSelected;
|
|
1250
|
+
const showAllSelectedChip = this.allSelected && (this.selectionDisplay === "single" || !selectedVisibleChipsCount || this.selectionDisplay === "all");
|
|
1085
1251
|
return html`<calcite-chip class=${safeClassMap({
|
|
1086
1252
|
[CSS.chip]: true,
|
|
1087
1253
|
[CSS.chipInvisible]: !showAllSelectedChip,
|
|
1088
1254
|
[CSS.allSelected]: true
|
|
1089
|
-
})} .label=${label} .scale=${scale} title=${label ?? nothing} value ${ref(allSelectedIndicatorChipRef)}>${label}</calcite-chip>`;
|
|
1255
|
+
})} data-testid=all-selected-indicator-chip .label=${label} .scale=${scale} title=${label ?? nothing} value ${ref(allSelectedIndicatorChipRef)}>${label}</calcite-chip>`;
|
|
1090
1256
|
}
|
|
1091
1257
|
renderSelectedIndicatorChip() {
|
|
1092
|
-
const { compactSelectionDisplay, selectionDisplay, scale,
|
|
1093
|
-
const allSelectedNoDisabled = this.allSelected && !this.hasDisabledItems;
|
|
1094
|
-
const allSelectedWithDisabledSelected = this.allSelected && this.hasDisabledSelected;
|
|
1258
|
+
const { compactSelectionDisplay, selectionDisplay, scale, selectedIndicatorChipRef } = this;
|
|
1095
1259
|
let chipInvisible;
|
|
1096
1260
|
let label;
|
|
1261
|
+
const selectedItemsCount = this.getSelectedItems().length;
|
|
1097
1262
|
if (compactSelectionDisplay) {
|
|
1098
1263
|
chipInvisible = true;
|
|
1099
1264
|
} else {
|
|
1100
1265
|
if (selectionDisplay === "single") {
|
|
1101
|
-
const selectedItemsCount = this.allItems.filter((item) => item.selected && (this.selectionMode !== "ancestors" || !hasActiveChildren(item))).length;
|
|
1102
1266
|
if (this.allSelected) {
|
|
1103
1267
|
chipInvisible = true;
|
|
1104
1268
|
} else if (selectedItemsCount > 0) {
|
|
@@ -1107,9 +1271,6 @@ class Combobox extends LitElement {
|
|
|
1107
1271
|
chipInvisible = true;
|
|
1108
1272
|
}
|
|
1109
1273
|
label = `${selectedItemsCount} ${this.messages.selected}`;
|
|
1110
|
-
} else if (selectionDisplay === "fit") {
|
|
1111
|
-
chipInvisible = !!((allSelectedNoDisabled || allSelectedWithDisabledSelected) && selectedVisibleChipsCount === 0 || selectedHiddenChipsCount === 0);
|
|
1112
|
-
label = selectedVisibleChipsCount > 0 ? `+${selectedHiddenChipsCount}` : `${selectedHiddenChipsCount} ${this.messages.selected}`;
|
|
1113
1274
|
}
|
|
1114
1275
|
}
|
|
1115
1276
|
return html`<calcite-chip class=${safeClassMap({
|
|
@@ -1118,18 +1279,13 @@ class Combobox extends LitElement {
|
|
|
1118
1279
|
})} .label=${label} .scale=${scale} title=${label ?? nothing} value ${ref(selectedIndicatorChipRef)}>${label}</calcite-chip>`;
|
|
1119
1280
|
}
|
|
1120
1281
|
renderSelectedIndicatorChipCompact() {
|
|
1121
|
-
const { compactSelectionDisplay, selectionDisplay, scale
|
|
1122
|
-
const allSelectedNoDisabled = this.allSelected && !this.hasDisabledItems;
|
|
1123
|
-
const allSelectedWithDisabledSelected = this.allSelected && this.hasDisabledSelected;
|
|
1282
|
+
const { compactSelectionDisplay, selectionDisplay, scale } = this;
|
|
1124
1283
|
let chipInvisible;
|
|
1125
1284
|
let label;
|
|
1285
|
+
const selectedItemsCount = this.getSelectedItems().length;
|
|
1126
1286
|
if (compactSelectionDisplay) {
|
|
1127
|
-
|
|
1128
|
-
if (allSelectedNoDisabled || allSelectedWithDisabledSelected || selectionDisplay === "single" && this.allSelected) {
|
|
1287
|
+
if (this.allSelected) {
|
|
1129
1288
|
chipInvisible = true;
|
|
1130
|
-
} else if (selectionDisplay === "fit") {
|
|
1131
|
-
chipInvisible = !(selectedHiddenChipsCount > 0);
|
|
1132
|
-
label = `${selectedHiddenChipsCount || 0}`;
|
|
1133
1289
|
} else if (selectionDisplay === "single") {
|
|
1134
1290
|
chipInvisible = !(selectedItemsCount > 0);
|
|
1135
1291
|
label = `${selectedItemsCount}`;
|
|
@@ -1158,7 +1314,7 @@ class Combobox extends LitElement {
|
|
|
1158
1314
|
[CSS.inputSingle]: true,
|
|
1159
1315
|
[CSS.inputHidden]: showLabel,
|
|
1160
1316
|
[CSS.inputIcon]: this.showingInlineIcon && !!this.placeholderIcon
|
|
1161
|
-
})} .disabled=${disabled} .id=${`${IDS.input(guid2)}`} @focus=${this.comboboxFocusHandler} @input=${this.inputHandler} placeholder=${placeholder ?? nothing} .readOnly=${this.readOnly} .required=${this.required} role=combobox .tabIndex=${this.activeChipIndex === -1 ? 0 : -1} type=text .value=${live(this.filterText ?? "")} ${ref(this.textInputRef)}>`)}</span>`;
|
|
1317
|
+
})} data-testid=input .disabled=${disabled} .id=${`${IDS.input(guid2)}`} @focus=${this.comboboxFocusHandler} @input=${this.inputHandler} placeholder=${placeholder ?? nothing} .readOnly=${this.readOnly} .required=${this.required} role=combobox .tabIndex=${this.activeChipIndex === -1 ? 0 : -1} type=text .value=${live(this.filterText ?? "")} ${ref(this.textInputRef)}>`)}</span>`;
|
|
1162
1318
|
}
|
|
1163
1319
|
renderListBoxOptions() {
|
|
1164
1320
|
const mappedListBoxOptions = this.keyboardNavItems.map((item) => this.createScreenReaderItem({
|
|
@@ -1187,7 +1343,7 @@ class Combobox extends LitElement {
|
|
|
1187
1343
|
[FloatingCSS.animationActive]: open
|
|
1188
1344
|
};
|
|
1189
1345
|
const label = (this.filterText && messages.add?.replace("{text}", `${this.filterText}`)) ?? "";
|
|
1190
|
-
return html`<div aria-hidden=true class=${safeClassMap(CSS.floatingUIContainer)} popover=manual ${ref(setFloatingEl)}><div class=${safeClassMap(classes)} ${ref(setContainerEl)}><ul class=${safeClassMap({ [CSS.list]: true, [CSS.listHide]: !open })}>${this.selectAllEnabled && this.selectionMode !== "single" && this.selectionMode !== "single-persist" && html`<calcite-combobox-item class=${safeClassMap(CSS.selectAll)} .heading=${messages.selectAll} .id=${`${this.guid}-select-all-enabled-interactive`} .indeterminate=${this.indeterminate} .label=${messages.selectAll} .scale=${scale} .selected=${this.allSelected} tabindex=-1 value=select-all ${ref(this.selectAllComboboxItemRef)}></calcite-combobox-item>` || ""}<slot></slot>${this.noMatchesFound && (this.allowCustomValues ? html`<li aria-label=${label ?? nothing} class=${safeClassMap(CSS.noMatches)} @click=${this.customChipAddHandler} role=option tabindex=0>${highlightText({
|
|
1346
|
+
return html`<div aria-hidden=true class=${safeClassMap(CSS.floatingUIContainer)} popover=manual ${ref(setFloatingEl)}><div class=${safeClassMap(classes)} ${ref(setContainerEl)}><ul class=${safeClassMap({ [CSS.list]: true, [CSS.listHide]: !open })}>${this.selectAllEnabled && this.selectionMode !== "single" && this.selectionMode !== "single-persist" && html`<calcite-combobox-item class=${safeClassMap(CSS.selectAll)} data-testid=select-all-item .heading=${messages.selectAll} .id=${`${this.guid}-select-all-enabled-interactive`} .indeterminate=${this.indeterminate} .label=${messages.selectAll} .scale=${scale} .selected=${this.allSelected} tabindex=-1 value=select-all ${ref(this.selectAllComboboxItemRef)}></calcite-combobox-item>` || ""}<slot></slot>${this.noMatchesFound && (this.allowCustomValues ? html`<li aria-label=${label ?? nothing} class=${safeClassMap(CSS.noMatches)} @click=${this.customChipAddHandler} role=option tabindex=0>${highlightText({
|
|
1191
1347
|
text: label,
|
|
1192
1348
|
pattern: new RegExp(`(${escapeRegExp(this.filterText)})`, "i")
|
|
1193
1349
|
})}</li>` : html`<li class=${safeClassMap({ [CSS.noMatchesPlaceholder]: true, [CSS.noMatches]: true })}>${messages.noMatches}</li>`) || ""}</ul></div></div>`;
|
|
@@ -1212,8 +1368,10 @@ class Combobox extends LitElement {
|
|
|
1212
1368
|
const allSelectionDisplay = selectionDisplay === "all";
|
|
1213
1369
|
const singleSelectionDisplay = selectionDisplay === "single";
|
|
1214
1370
|
const fitSelectionDisplay = !singleSelectionMode && selectionDisplay === "fit";
|
|
1215
|
-
const
|
|
1216
|
-
const
|
|
1371
|
+
const showIndicatorChips = !singleSelectionMode && !allSelectionDisplay;
|
|
1372
|
+
const showSingleIndicatorChips = showIndicatorChips && !fitSelectionDisplay;
|
|
1373
|
+
const hasClearableSelection = this.items.some((item) => item.selected && !item.disabled);
|
|
1374
|
+
const isClearable = !this.clearDisabled && this.selectionMode !== "single-persist" && !!this.value?.length && hasClearableSelection;
|
|
1217
1375
|
return this.interactiveContainer({ disabled: this.disabled, children: html`${this.labelText && InternalLabel({ labelText: this.labelText, onClick: this.onLabelClick, required: this.required, tooltipText: this.messages.required }) || ""}<div aria-live=polite class=${safeClassMap({
|
|
1218
1376
|
[CSS.wrapper]: true,
|
|
1219
1377
|
[CSS.wrapperSingle]: singleSelectionMode || !this.selectedItems.length,
|
|
@@ -1222,11 +1380,7 @@ class Combobox extends LitElement {
|
|
|
1222
1380
|
[CSS.gridInput]: true,
|
|
1223
1381
|
[CSS.selectionDisplayFit]: fitSelectionDisplay,
|
|
1224
1382
|
[CSS.selectionDisplaySingle]: singleSelectionDisplay
|
|
1225
|
-
})} ${ref(this.setChipContainerEl)}>${!singleSelectionMode && !singleSelectionDisplay && this.renderChips() || ""}${!singleSelectionMode && !singleSelectionDisplay && this.selectAllEnabled && allSelectionDisplay && (
|
|
1226
|
-
this.renderSelectedIndicatorChip(),
|
|
1227
|
-
this.renderSelectedIndicatorChipCompact(),
|
|
1228
|
-
this.renderAllSelectedIndicatorChip()
|
|
1229
|
-
] || ""}<label class=${safeClassMap(CSS.screenReadersOnly)} .htmlFor=${`${IDS.input(guid2)}`} .id=${`${IDS.label(guid2)}`}>${label}</label>${this.renderInput()}</div>`)}${!readOnly && isClearable ? ClearButton({ ariaLabel: this.messages.clear, disabled: this.disabled, ref: this.clearButtonRef, scale: this.scale, title: this.messages.clear }) : null}${!readOnly && this.renderChevronIcon() || ""}</div><ul aria-labelledby=${`${IDS.label(guid2)}`} aria-multiselectable=true class=${safeClassMap(CSS.screenReadersOnly)} .id=${`${IDS.listbox(guid2)}`} role=listbox tabindex=-1>${this.renderListBoxOptions()}</ul>${this.renderFloatingUIContainer()}${this.validationMessage && this.status === "invalid" ? Validation({ icon: this.validationIcon, id: IDS.validationMessage, message: this.validationMessage, scale: this.scale, status: this.status }) : null}` });
|
|
1383
|
+
})} ${ref(this.setChipContainerEl)}>${!singleSelectionMode && !singleSelectionDisplay && this.renderChips() || ""}${!singleSelectionMode && !singleSelectionDisplay && this.selectAllEnabled && allSelectionDisplay && this.renderAllSelectedIndicatorChip() || ""}${showSingleIndicatorChips && this.renderSelectedIndicatorChip() || ""}${showSingleIndicatorChips && this.renderSelectedIndicatorChipCompact() || ""}${showIndicatorChips && this.renderAllSelectedIndicatorChip() || ""}<label class=${safeClassMap(CSS.screenReadersOnly)} .htmlFor=${`${IDS.input(guid2)}`} .id=${`${IDS.label(guid2)}`}>${label}</label>${this.renderInput()}</div>`)}${!readOnly && isClearable ? ClearButton({ ariaLabel: this.messages.clear, disabled: this.disabled, ref: this.clearButtonRef, scale: this.scale, title: this.messages.clear }) : null}${!readOnly && this.renderChevronIcon() || ""}</div><ul aria-labelledby=${`${IDS.label(guid2)}`} aria-multiselectable=true class=${safeClassMap(CSS.screenReadersOnly)} .id=${`${IDS.listbox(guid2)}`} role=listbox tabindex=-1>${this.renderListBoxOptions()}</ul>${this.renderFloatingUIContainer()}${this.validationMessage && this.status === "invalid" ? Validation({ icon: this.validationIcon, id: IDS.validationMessage, message: this.validationMessage, scale: this.scale, status: this.status }) : null}` });
|
|
1230
1384
|
}
|
|
1231
1385
|
}
|
|
1232
1386
|
customElement("calcite-combobox", Combobox);
|