@esri/calcite-components 5.2.0-next.1 → 5.2.0-next.2
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/dist/cdn/{AIWMELGE.js → 2AZU4JLL.js} +1 -1
- package/dist/cdn/{DE6F4LEP.js → 2C57GVL7.js} +1 -1
- package/dist/cdn/{R66RRO3R.js → 2RCOMSJ4.js} +1 -1
- package/dist/cdn/{QUKECT32.js → 2U7LTQ5E.js} +1 -1
- package/dist/cdn/{3F6G62ML.js → 3FH6QU7Y.js} +1 -1
- package/dist/cdn/{GIWBHPUL.js → 3GSXR65T.js} +1 -1
- package/dist/cdn/{Y77IPFJ6.js → 43MK3FDM.js} +1 -1
- package/dist/cdn/{XKLVTSH7.js → 45HPDOT4.js} +1 -1
- package/dist/cdn/{LLBCU6W2.js → 4AM5CFW2.js} +1 -1
- package/dist/cdn/{4DBDLDKL.js → 4C4FXK46.js} +1 -1
- package/dist/cdn/{ASL35FGE.js → 4CHUXMKI.js} +1 -1
- package/dist/cdn/{PK24O5FM.js → 4PN5ZOFS.js} +1 -1
- package/dist/cdn/{CYL77NSA.js → 4XBIPWD2.js} +1 -1
- package/dist/cdn/{OMEUUIN3.js → 57I2TDEP.js} +1 -1
- package/dist/cdn/{UYY6Z6VK.js → 5EY2EEDX.js} +1 -1
- package/dist/cdn/{V4N6LLPL.js → 5GA4KYR2.js} +1 -1
- package/dist/cdn/{25KULUYL.js → 5ISZFTOQ.js} +1 -1
- package/dist/cdn/{D2F4S4IN.js → 6A4WSEWS.js} +1 -1
- package/dist/cdn/{SVIZ25MX.js → 6WR7WF5X.js} +1 -1
- package/dist/cdn/{NSFNE7JF.js → 6ZDUL7DM.js} +1 -1
- package/dist/cdn/{VINHY2BO.js → 7IOEAAJN.js} +1 -1
- package/dist/cdn/{MZGWIJTE.js → 7JMYJBWS.js} +1 -1
- package/dist/cdn/{JSEZIWE7.js → 7Q57OJ6S.js} +1 -1
- package/dist/cdn/{2QRPMWMD.js → A2QVKNTN.js} +1 -1
- package/dist/cdn/{H6TQ2ZT5.js → AA7ZRB5K.js} +1 -1
- package/dist/cdn/{JYV5JY66.js → AFNW6NWU.js} +1 -1
- package/dist/cdn/AI4EP5I7.js +2 -0
- package/dist/cdn/{6WRZDS46.js → AO3S4HXU.js} +1 -1
- package/dist/cdn/{TKWNZUZC.js → AOWO3CEE.js} +1 -1
- package/dist/cdn/{VOYNOWTM.js → ATPHVTBE.js} +1 -1
- package/dist/cdn/{L4Z32DDI.js → AV53YUYO.js} +1 -1
- package/dist/cdn/{DXKVNK72.js → B34QFBVX.js} +1 -1
- package/dist/cdn/{YEOA76XG.js → B5M44JJO.js} +1 -1
- package/dist/cdn/{TOW6FGVT.js → BBQFFEZH.js} +1 -1
- package/dist/cdn/{54LRKMZS.js → BDJAXYZ6.js} +1 -1
- package/dist/cdn/{FGBYK22Q.js → BETERP4W.js} +1 -1
- package/dist/cdn/{VNHCZF5S.js → BUNBY5RM.js} +1 -1
- package/dist/cdn/{AYIHFCPW.js → C4VPLSW7.js} +1 -1
- package/dist/cdn/{CJ6HLMWM.js → C7C55I5S.js} +1 -1
- package/dist/cdn/{XKZW6PMR.js → CAWTUKNX.js} +1 -1
- package/dist/cdn/{JQOYQOAO.js → CC6MIBOX.js} +1 -1
- package/dist/cdn/{SYWS7CRW.js → CFFCEFZK.js} +1 -1
- package/dist/cdn/{AWONW44Y.js → CQ6NGNY6.js} +1 -1
- package/dist/cdn/{IQC2I5QX.js → CYCLHZ3A.js} +1 -1
- package/dist/cdn/D6PPMEQM.js +2 -0
- package/dist/cdn/{EAMIHL5M.js → DI3IXSN2.js} +1 -1
- package/dist/cdn/{7BAH3USN.js → DJIJFKYH.js} +1 -1
- package/dist/cdn/{MOVYXJPM.js → DJL42XA3.js} +1 -1
- package/dist/cdn/{O4JLFLGJ.js → E3RE3E2N.js} +1 -1
- package/dist/cdn/{YWSUGSZQ.js → EGQ75QVP.js} +1 -1
- package/dist/cdn/{2DTD2NAQ.js → EL7GGALP.js} +1 -1
- package/dist/cdn/{DYTBN43V.js → ENNOBBY4.js} +1 -1
- package/dist/cdn/{TX53ZOIB.js → EXXGZUR3.js} +1 -1
- package/dist/cdn/{OM2LRTKI.js → F25HCCSH.js} +1 -1
- package/dist/cdn/{N5V52FVE.js → F7AKW6A4.js} +1 -1
- package/dist/cdn/{7MVJZ7CE.js → FEMVD7MC.js} +1 -1
- package/dist/cdn/{RSDMKNTP.js → FFUBSUZQ.js} +1 -1
- package/dist/cdn/{HPG25RGF.js → FLX6RAXY.js} +1 -1
- package/dist/cdn/{ESXXYY4U.js → FPVMYG6A.js} +1 -1
- package/dist/cdn/FVB2OZEH.js +2 -0
- package/dist/cdn/{JFBAD4EH.js → G4ZSDWUZ.js} +1 -1
- package/dist/cdn/{DCQW26QE.js → GBGFI7SS.js} +1 -1
- package/dist/cdn/{RX7YQTRT.js → GBNEJ7ZF.js} +1 -1
- package/dist/cdn/{ZSURDLTS.js → GGCO6DJE.js} +1 -1
- package/dist/cdn/GLH6ZAVP.js +2 -0
- package/dist/cdn/{RDJ3NPD2.js → GMY4OPXB.js} +1 -1
- package/dist/cdn/{WBEFTFTM.js → GNF44UQG.js} +1 -1
- package/dist/cdn/{A7VRJEQ7.js → GOBJFJO6.js} +1 -1
- package/dist/cdn/{NLG3XARE.js → GUSPFAZS.js} +1 -1
- package/dist/cdn/{GEQANJCK.js → H2JTOLL2.js} +1 -1
- package/dist/cdn/{GX22FMPB.js → HBRGGPQS.js} +1 -1
- package/dist/cdn/{6P2QCONQ.js → HIXRGJPQ.js} +1 -1
- package/dist/cdn/HKIP6O5B.js +2 -0
- package/dist/cdn/{MM6ZG6HL.js → I2ZCMXRB.js} +1 -1
- package/dist/cdn/I5C2XC5I.js +2 -0
- package/dist/cdn/IJZH5BV3.js +2 -0
- package/dist/cdn/{ES72YVWM.js → IOBH7Q3C.js} +1 -1
- package/dist/cdn/{MIR7TMZV.js → IVJANKWM.js} +1 -1
- package/dist/cdn/{ACTWXLMU.js → J32XKCXC.js} +1 -1
- package/dist/cdn/{YLSRMNDL.js → JL5V6LHI.js} +1 -1
- package/dist/cdn/{EYO37APD.js → JQVKQIWK.js} +1 -1
- package/dist/cdn/{NSSVAO6G.js → JW2SKWED.js} +1 -1
- package/dist/cdn/{WMJFCYAQ.js → JZCXLE2H.js} +1 -1
- package/dist/cdn/{PV5JONG7.js → KPR7F2IQ.js} +1 -1
- package/dist/cdn/{GHBTJCIE.js → KQ322MPA.js} +1 -1
- package/dist/cdn/{IMHBTKOK.js → KQN3IXDE.js} +1 -1
- package/dist/cdn/KRZT7UVD.js +2 -0
- package/dist/cdn/{DOQVMLYE.js → KVWHPPP5.js} +1 -1
- package/dist/cdn/KZUHKTIQ.js +2 -0
- package/dist/cdn/{RJJY3IYM.js → LJJZC4QK.js} +1 -1
- package/dist/cdn/{TBBD7RAC.js → LRPJV2DQ.js} +1 -1
- package/dist/cdn/{YOMDRGFX.js → LVF7G7IY.js} +1 -1
- package/dist/cdn/{4XMK7RES.js → LZDIBXYZ.js} +1 -1
- package/dist/cdn/{ERXINDJK.js → MIE7SGGW.js} +1 -1
- package/dist/cdn/{VWJDFV4M.js → MNBJJORH.js} +1 -1
- package/dist/cdn/{ZOVBFLHG.js → MSB35HIA.js} +1 -1
- package/dist/cdn/{5B3SU7K7.js → N7DI6G6M.js} +1 -1
- package/dist/cdn/{VOLQZMH5.js → NF3TF2WJ.js} +1 -1
- package/dist/cdn/{6SJDD32D.js → NFPHYIMY.js} +1 -1
- package/dist/cdn/{7T64APC5.js → OGWGMCYY.js} +1 -1
- package/dist/cdn/{FEGURFPP.js → OLCC5YK5.js} +1 -1
- package/dist/cdn/{DXJL2WZO.js → OQY72DXY.js} +1 -1
- package/dist/cdn/{MDH6YMD3.js → OTKKHBLB.js} +1 -1
- package/dist/cdn/{XRGFDJYN.js → PKAYPMQL.js} +1 -1
- package/dist/cdn/{CWQ3PMYG.js → PO4GQAOO.js} +1 -1
- package/dist/cdn/{BXSBN734.js → PYEU7ILW.js} +1 -1
- package/dist/cdn/QIW2VXWS.js +2 -0
- package/dist/cdn/{2WQCK6Z3.js → QLMCMCFN.js} +1 -1
- package/dist/cdn/{QJVQP6SA.js → QNSEEZF5.js} +1 -1
- package/dist/cdn/{T2B7YQBZ.js → QVYX2WRU.js} +1 -1
- package/dist/cdn/{PVLYFAFT.js → QXIJOBKX.js} +1 -1
- package/dist/cdn/QXVZRQDN.js +2 -0
- package/dist/cdn/{W6FGHS7T.js → R2DOA2MN.js} +1 -1
- package/dist/cdn/{3IC622AE.js → RC3UVUK3.js} +1 -1
- package/dist/cdn/{4ETK64XH.js → RE4YAX46.js} +1 -1
- package/dist/cdn/RQVOT4ZO.js +2 -0
- package/dist/cdn/{XVA6JBXQ.js → RXXRSLAB.js} +1 -1
- package/dist/cdn/{TUOZOBAX.js → S5JJMYDX.js} +1 -1
- package/dist/cdn/{GQYGI42P.js → SU44IFYE.js} +1 -1
- package/dist/cdn/{AHIMAWOG.js → SVEPQ765.js} +1 -1
- package/dist/cdn/{T64D27BK.js → SVIANZ3V.js} +1 -1
- package/dist/cdn/{ZALKF7AK.js → T5VR3PV2.js} +1 -1
- package/dist/cdn/{JNIRX7D3.js → TD2P54UR.js} +1 -1
- package/dist/cdn/{XRQ6ALBW.js → TDOPUO3L.js} +1 -1
- package/dist/cdn/{IFGOL2KZ.js → TE3IGQZH.js} +1 -1
- package/dist/cdn/{UTYK5GN7.js → TEGKHQ5W.js} +1 -1
- package/dist/cdn/{DOTGEOAD.js → TJC3KPVJ.js} +1 -1
- package/dist/cdn/{6VJGFXTB.js → TWT5XRCW.js} +1 -1
- package/dist/cdn/{3274MQBE.js → U5IWCBXE.js} +1 -1
- package/dist/cdn/{7BPZSHP5.js → UMHABPZB.js} +1 -1
- package/dist/cdn/{UWEY77AH.js → UOQXEKIF.js} +1 -1
- package/dist/cdn/UWAER5W3.js +2 -0
- package/dist/cdn/{WJ2DBVDY.js → V3ADMKIU.js} +1 -1
- package/dist/cdn/{5BXJCRHG.js → W5TTJ4T3.js} +1 -1
- package/dist/cdn/{JAMAODSH.js → W6UFYWVG.js} +1 -1
- package/dist/cdn/{6I7CG5ZI.js → W7BKEQCB.js} +1 -1
- package/dist/cdn/{SG43VAY2.js → W7DJIM2F.js} +1 -1
- package/dist/cdn/{RL3BQHH7.js → WYJ5MJ5T.js} +1 -1
- package/dist/cdn/{GPZK2XCA.js → X33GQ3A3.js} +1 -1
- package/dist/cdn/{HI5BMWLV.js → XD2JOD4K.js} +1 -1
- package/dist/cdn/{DOEPGWZO.js → XNAMWMN5.js} +1 -1
- package/dist/cdn/{T6WFAXGK.js → XR4GGZRV.js} +1 -1
- package/dist/cdn/XZJNPGQT.js +2 -0
- package/dist/cdn/Y3U2N2BQ.js +2 -0
- package/dist/cdn/{6DUYQARM.js → YAQRXHHQ.js} +1 -1
- package/dist/cdn/{6HQ7WHUL.js → YEFCURY4.js} +1 -1
- package/dist/cdn/{4MGZ6ADZ.js → YHD7HKDX.js} +1 -1
- package/dist/cdn/{V2ZQL3ON.js → YL4XYPPL.js} +1 -1
- package/dist/cdn/{7LKWZYMO.js → YYGQFOZ7.js} +1 -1
- package/dist/cdn/{EARL5L6Z.js → ZLOMPF4H.js} +1 -1
- 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 +3 -3
- package/dist/chunks/utils.js +9 -15
- package/dist/chunks/utils2.js +1 -1
- 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-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 +245 -93
- 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.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/web-types.json +1 -1
- package/package.json +2 -2
- package/dist/cdn/6THNFXTV.js +0 -2
- package/dist/cdn/7RTTBZVL.js +0 -2
- package/dist/cdn/DHXGSMMN.js +0 -2
- package/dist/cdn/DV6Z2ZUP.js +0 -2
- package/dist/cdn/JLRS6GUS.js +0 -2
- package/dist/cdn/JWZRDSEQ.js +0 -2
- package/dist/cdn/OWVDY7XZ.js +0 -2
- package/dist/cdn/P7VFZYNM.js +0 -2
- package/dist/cdn/POCA3O3T.js +0 -2
- package/dist/cdn/S2ACIYIJ.js +0 -2
- package/dist/cdn/SKBNA7MO.js +0 -2
- package/dist/cdn/WBKHM7GQ.js +0 -2
- package/dist/cdn/WWXFCBIC.js +0 -2
- /package/dist/cdn/{XJY76HZ5.js → 2QCI6TGY.js} +0 -0
- /package/dist/cdn/{O2A6CQZA.js → BLWTCPBG.js} +0 -0
- /package/dist/cdn/{5OPFL4DZ.js → KWIC32XQ.js} +0 -0
- /package/dist/cdn/{SG5FNFQO.js → Q24FQVQ4.js} +0 -0
- /package/dist/cdn/{DE7OTXX2.js → QBJZUEM2.js} +0 -0
|
@@ -27,7 +27,8 @@ 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 {
|
|
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";
|
|
31
32
|
import { h as hasActiveChildren, i as isSingleLike, g as getLabel, a as getItemAncestors, b 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 {
|
|
@@ -77,10 +78,10 @@ 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
|
+
return this.allItems.filter((item) => item.selected && (this.selectionMode !== "ancestors" || !hasActiveChildren(item))).sort((a, b) => {
|
|
84
85
|
const aIdx = this.selectedItems.indexOf(a);
|
|
85
86
|
const bIdx = this.selectedItems.indexOf(b);
|
|
86
87
|
if (aIdx > -1 && bIdx > -1) {
|
|
@@ -93,16 +94,29 @@ class Combobox extends LitElement {
|
|
|
93
94
|
this.guid = guid();
|
|
94
95
|
this.ignoreSelectedEventsFlag = false;
|
|
95
96
|
this.internalValueChangeFlag = false;
|
|
97
|
+
this.previousAllSelected = false;
|
|
98
|
+
this.refreshingSelectionDisplay = false;
|
|
96
99
|
this.mutationObserver = createObserver("mutation", () => this.updateItems());
|
|
97
100
|
this.onLabelClick = () => {
|
|
98
101
|
this.setFocus();
|
|
99
102
|
};
|
|
100
103
|
this.transitionProp = "opacity";
|
|
101
|
-
this.resizeObserver =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
this.resizeObserver = (() => {
|
|
105
|
+
let resizeWorkQueued = false;
|
|
106
|
+
return createObserver("resize", () => {
|
|
107
|
+
if (resizeWorkQueued) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
resizeWorkQueued = true;
|
|
111
|
+
requestAnimationFrame(() => {
|
|
112
|
+
resizeWorkQueued = false;
|
|
113
|
+
this.setMaxScrollerHeight();
|
|
114
|
+
this.refreshSelectionDisplay();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
})();
|
|
105
118
|
this.selectedIndicatorChipRef = createRef();
|
|
119
|
+
this.selectedChipCountRef = createRef();
|
|
106
120
|
this.clearButtonRef = createRef();
|
|
107
121
|
this._selectedItems = [];
|
|
108
122
|
this.textInputRef = createRef();
|
|
@@ -120,8 +134,10 @@ class Combobox extends LitElement {
|
|
|
120
134
|
this.activeDescendant = "";
|
|
121
135
|
this.activeItemIndex = -1;
|
|
122
136
|
this.compactSelectionDisplay = false;
|
|
137
|
+
this.deferFitChipCountRender = false;
|
|
123
138
|
this.selectedHiddenChipsCount = 0;
|
|
124
139
|
this.selectedVisibleChipsCount = 0;
|
|
140
|
+
this.fitUsingCompactCountLabel = false;
|
|
125
141
|
this.allItems = [];
|
|
126
142
|
this.items = [];
|
|
127
143
|
this.clearDisabled = false;
|
|
@@ -153,7 +169,7 @@ class Combobox extends LitElement {
|
|
|
153
169
|
this.listen("click", this.comboboxFocusHandler);
|
|
154
170
|
}
|
|
155
171
|
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 };
|
|
172
|
+
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
173
|
}
|
|
158
174
|
static {
|
|
159
175
|
this.formAssociated = true;
|
|
@@ -178,9 +194,6 @@ class Combobox extends LitElement {
|
|
|
178
194
|
const enabledItems = this.allItems.filter((item) => !item.disabled);
|
|
179
195
|
return enabledItems.length > 0 && enabledItems.every((item) => item.selected);
|
|
180
196
|
}
|
|
181
|
-
get hasDisabledItems() {
|
|
182
|
-
return this.allItems.some((item) => item.disabled);
|
|
183
|
-
}
|
|
184
197
|
get hasDisabledSelected() {
|
|
185
198
|
return this.allItems.some((item) => item.disabled && item.selected);
|
|
186
199
|
}
|
|
@@ -325,11 +338,33 @@ class Combobox extends LitElement {
|
|
|
325
338
|
this.reposition(true);
|
|
326
339
|
}
|
|
327
340
|
selectedItemsHandler() {
|
|
341
|
+
const wasAllSelected = this.previousAllSelected;
|
|
342
|
+
const isAllSelected = this.allSelected;
|
|
343
|
+
this.previousAllSelected = isAllSelected;
|
|
328
344
|
this.internalValueChangeFlag = true;
|
|
329
345
|
this.value = this.getValue();
|
|
330
346
|
this.internalValueChangeFlag = false;
|
|
331
347
|
if (this.selectionDisplay === "fit" && this.isMulti()) {
|
|
332
|
-
|
|
348
|
+
const transitioningFromAllSelected = wasAllSelected && !isAllSelected;
|
|
349
|
+
if (wasAllSelected && !isAllSelected) {
|
|
350
|
+
this.selectedHiddenChipsCount = 0;
|
|
351
|
+
this.selectedItems.forEach((item) => {
|
|
352
|
+
const chipEl = this.referenceEl?.querySelector(`#${IDS.chip(item.guid)}`);
|
|
353
|
+
if (chipEl) {
|
|
354
|
+
this.showChip(chipEl);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
this.updateComplete.then(async () => {
|
|
359
|
+
if (transitioningFromAllSelected) {
|
|
360
|
+
await this.updateComplete;
|
|
361
|
+
}
|
|
362
|
+
await this.refreshSelectionDisplay();
|
|
363
|
+
if (this.fitFollowUpRefreshPromise) {
|
|
364
|
+
await this.fitFollowUpRefreshPromise;
|
|
365
|
+
}
|
|
366
|
+
this.deferFitChipCountRender = false;
|
|
367
|
+
});
|
|
333
368
|
}
|
|
334
369
|
}
|
|
335
370
|
async documentClickHandler(event) {
|
|
@@ -348,10 +383,11 @@ class Combobox extends LitElement {
|
|
|
348
383
|
this.open = false;
|
|
349
384
|
}
|
|
350
385
|
handleSelectAll(isSelectAllTarget) {
|
|
351
|
-
if (isSelectAllTarget) {
|
|
352
|
-
|
|
386
|
+
if (!isSelectAllTarget) {
|
|
387
|
+
return;
|
|
353
388
|
}
|
|
354
|
-
|
|
389
|
+
this.toggleSelectAll();
|
|
390
|
+
if (this.selectionDisplay !== "fit" && this.allSelected) {
|
|
355
391
|
this.selectedItems.forEach((item) => {
|
|
356
392
|
const chipEl = this.referenceEl.querySelector(`#${IDS.chip(item.guid)}`);
|
|
357
393
|
if (chipEl) {
|
|
@@ -372,7 +408,6 @@ class Combobox extends LitElement {
|
|
|
372
408
|
const newIndex = this.keyboardNavItems.indexOf(isSelectAllTarget ? this.selectAllComboboxItemRef.value : target);
|
|
373
409
|
this.updateActiveItemIndex(newIndex);
|
|
374
410
|
this.toggleSelection(target, target.selected);
|
|
375
|
-
this.selectedItems = this.getSelectedItems();
|
|
376
411
|
}
|
|
377
412
|
calciteInternalComboboxItemChangeHandler(event) {
|
|
378
413
|
event.stopPropagation();
|
|
@@ -381,11 +416,14 @@ class Combobox extends LitElement {
|
|
|
381
416
|
}
|
|
382
417
|
}
|
|
383
418
|
clearValue() {
|
|
384
|
-
this.
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
419
|
+
const enabledSelectedItems = this.items.filter((item) => item.selected && !item.disabled);
|
|
420
|
+
if (enabledSelectedItems.length) {
|
|
421
|
+
this.ignoreSelectedEventsFlag = true;
|
|
422
|
+
enabledSelectedItems.forEach((el) => el.selected = false);
|
|
423
|
+
this.ignoreSelectedEventsFlag = false;
|
|
424
|
+
this.selectedItems = this.getSelectedItems();
|
|
425
|
+
this.emitComboboxChange();
|
|
426
|
+
}
|
|
389
427
|
this.open = false;
|
|
390
428
|
this.updateActiveItemIndex(-1);
|
|
391
429
|
this.resetText();
|
|
@@ -421,6 +459,13 @@ class Combobox extends LitElement {
|
|
|
421
459
|
this.selectedItems = this.getSelectedItems();
|
|
422
460
|
this.emitComboboxChange();
|
|
423
461
|
}
|
|
462
|
+
hasHiddenSelectedFitChips() {
|
|
463
|
+
if (this.selectionDisplay !== "fit" || !this.isMulti()) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
const hiddenCountChip = this.selectedChipCountRef.value;
|
|
467
|
+
return !!hiddenCountChip && !hiddenCountChip.classList.contains(CSS.chipInvisible);
|
|
468
|
+
}
|
|
424
469
|
keyDownHandler(event) {
|
|
425
470
|
if (this.readOnly) {
|
|
426
471
|
return;
|
|
@@ -547,13 +592,16 @@ class Combobox extends LitElement {
|
|
|
547
592
|
break;
|
|
548
593
|
case "Delete":
|
|
549
594
|
case "Backspace": {
|
|
550
|
-
const
|
|
595
|
+
const fitDeleteBlockedByOverflow = this.hasHiddenSelectedFitChips();
|
|
596
|
+
const overflowDeleteBlocked = fitDeleteBlockedByOverflow && this.activeChipIndex === -1;
|
|
597
|
+
const notDeletable = this.selectionDisplay === "single" || overflowDeleteBlocked;
|
|
551
598
|
if (notDeletable) {
|
|
552
599
|
return;
|
|
553
600
|
}
|
|
554
|
-
|
|
601
|
+
const deleteTargetChip = event.composedPath().find((node) => isChip(node));
|
|
602
|
+
if (this.activeChipIndex > -1 && deleteTargetChip) {
|
|
555
603
|
event.preventDefault();
|
|
556
|
-
this.removeActiveChip(
|
|
604
|
+
this.removeActiveChip(deleteTargetChip);
|
|
557
605
|
} else if (!this.filterText && this.isMulti()) {
|
|
558
606
|
event.preventDefault();
|
|
559
607
|
this.removeLastChip();
|
|
@@ -601,7 +649,7 @@ class Combobox extends LitElement {
|
|
|
601
649
|
return;
|
|
602
650
|
}
|
|
603
651
|
const composedPath = event.composedPath();
|
|
604
|
-
if (composedPath.some((node) => node
|
|
652
|
+
if (composedPath.some((node) => isChip(node))) {
|
|
605
653
|
this.open = false;
|
|
606
654
|
event.preventDefault();
|
|
607
655
|
return;
|
|
@@ -630,35 +678,63 @@ class Combobox extends LitElement {
|
|
|
630
678
|
showChip(chipEl) {
|
|
631
679
|
chipEl.classList.remove(CSS.chipInvisible);
|
|
632
680
|
}
|
|
633
|
-
refreshChipDisplay({ chipEls, availableHorizontalChipElSpace, chipContainerElGap }) {
|
|
681
|
+
refreshChipDisplay({ chipEls, availableHorizontalChipElSpace, chipContainerElGap, hideSelectedChips }) {
|
|
682
|
+
const selectedChipEls = chipEls.filter((chipEl) => chipEl.selected);
|
|
683
|
+
const enabledSelectedChipEls = selectedChipEls.filter((chipEl) => !chipEl.disabled);
|
|
684
|
+
const disabledSelectedChipEls = selectedChipEls.filter((chipEl) => chipEl.disabled);
|
|
685
|
+
const getChipWidth = (chipEl) => {
|
|
686
|
+
const computedWidth = getElementWidth(chipEl);
|
|
687
|
+
const fallbackWidth = chipEl.getBoundingClientRect().width;
|
|
688
|
+
return Number.isFinite(computedWidth) && computedWidth > 0 ? computedWidth : fallbackWidth;
|
|
689
|
+
};
|
|
690
|
+
selectedChipEls.forEach((chipEl) => getChipWidth(chipEl));
|
|
634
691
|
chipEls.forEach((chipEl) => {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
692
|
+
this.hideChip(chipEl);
|
|
693
|
+
});
|
|
694
|
+
if (hideSelectedChips) {
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
const renderFittingChips = (chips) => {
|
|
698
|
+
let visibleChipsCount = 0;
|
|
699
|
+
chips.forEach((chipEl) => {
|
|
700
|
+
const chipElWidth = getChipWidth(chipEl);
|
|
701
|
+
if (chipElWidth && chipElWidth <= availableHorizontalChipElSpace) {
|
|
640
702
|
availableHorizontalChipElSpace -= chipElWidth + chipContainerElGap;
|
|
641
703
|
this.showChip(chipEl);
|
|
642
|
-
|
|
704
|
+
visibleChipsCount++;
|
|
643
705
|
}
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
}
|
|
706
|
+
});
|
|
707
|
+
return visibleChipsCount;
|
|
708
|
+
};
|
|
709
|
+
const visibleEnabledChipsCount = renderFittingChips(enabledSelectedChipEls);
|
|
710
|
+
if (visibleEnabledChipsCount <= 1) {
|
|
711
|
+
renderFittingChips(disabledSelectedChipEls);
|
|
712
|
+
}
|
|
647
713
|
}
|
|
648
|
-
async refreshSelectionDisplay() {
|
|
649
|
-
this.
|
|
714
|
+
async refreshSelectionDisplay(followUpRefresh = true) {
|
|
715
|
+
if (this.refreshingSelectionDisplay) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
this.refreshingSelectionDisplay = true;
|
|
719
|
+
await this.componentOnReady();
|
|
650
720
|
if (isSingleLike(this.selectionMode)) {
|
|
721
|
+
this.refreshingSelectionDisplay = false;
|
|
651
722
|
return;
|
|
652
723
|
}
|
|
653
724
|
if (!this.textInputRef.value || !this.chipContainerEl) {
|
|
725
|
+
this.refreshingSelectionDisplay = false;
|
|
654
726
|
return;
|
|
655
727
|
}
|
|
656
728
|
const { allSelectedIndicatorChipRef, chipContainerEl, selectionDisplay, placeholder, selectedIndicatorChipRef, textInputRef } = this;
|
|
657
|
-
const chipContainerElGap = parseInt(getComputedStyle(chipContainerEl).gap
|
|
729
|
+
const chipContainerElGap = parseInt(getComputedStyle(chipContainerEl).gap);
|
|
658
730
|
const chipContainerElWidth = getElementWidth(chipContainerEl);
|
|
659
|
-
const { fontSize, fontFamily } = getComputedStyle(textInputRef.value);
|
|
660
|
-
const
|
|
661
|
-
const
|
|
731
|
+
const { fontSize, fontFamily, minInlineSize } = getComputedStyle(textInputRef.value);
|
|
732
|
+
const placeholderWidthMultiplier = 0.55;
|
|
733
|
+
const inputMinWidth = parseFloat(minInlineSize) || parseInt(calciteSize48);
|
|
734
|
+
const measuredPlaceholderWidth = getTextWidth(placeholder, `${fontSize} ${fontFamily}`);
|
|
735
|
+
const placeholderWidth = measuredPlaceholderWidth > 0 ? measuredPlaceholderWidth : Math.max(inputMinWidth, Math.round((placeholder?.length || 0) * (parseFloat(fontSize) || parseInt(calciteSize48)) * placeholderWidthMultiplier));
|
|
736
|
+
const fitInputWidth = Math.max(inputMinWidth, placeholderWidth);
|
|
737
|
+
const inputWidth = (selectionDisplay === "fit" ? fitInputWidth : placeholderWidth) + chipContainerElGap;
|
|
662
738
|
const allSelectedIndicatorChipElWidth = getElementWidth(allSelectedIndicatorChipRef.value);
|
|
663
739
|
const selectedIndicatorChipElWidth = getElementWidth(selectedIndicatorChipRef.value);
|
|
664
740
|
const largestSelectedIndicatorChipWidth = Math.max(allSelectedIndicatorChipElWidth, selectedIndicatorChipElWidth);
|
|
@@ -668,7 +744,7 @@ class Combobox extends LitElement {
|
|
|
668
744
|
inputWidth,
|
|
669
745
|
largestSelectedIndicatorChipWidth
|
|
670
746
|
});
|
|
671
|
-
if (
|
|
747
|
+
if (selectionDisplay !== "fit" && this.allSelected && this.selectAllEnabled) {
|
|
672
748
|
this.selectedItems.forEach((item) => {
|
|
673
749
|
const chipEl = this.referenceEl.querySelector(`#${IDS.chip(item.guid)}`);
|
|
674
750
|
if (chipEl) {
|
|
@@ -685,16 +761,64 @@ class Combobox extends LitElement {
|
|
|
685
761
|
});
|
|
686
762
|
}
|
|
687
763
|
if (selectionDisplay === "fit") {
|
|
688
|
-
const chipEls = Array.from(this.el.shadowRoot.querySelectorAll("calcite-chip")).filter((chipEl) =>
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
764
|
+
const chipEls = Array.from(this.el.shadowRoot.querySelectorAll("calcite-chip")).filter((chipEl) => {
|
|
765
|
+
const chipValue = chipEl.value;
|
|
766
|
+
const hasValue = chipValue != null && `${chipValue}` !== "";
|
|
767
|
+
return chipEl.disabled || hasValue;
|
|
768
|
+
});
|
|
769
|
+
const { hiddenChipIndicatorWidth, hideSelectedChips, reservedPlaceholderInputWidth } = this.getFitCompactDisplayState({
|
|
770
|
+
chipContainerElGap,
|
|
771
|
+
chipContainerElWidth,
|
|
772
|
+
inputMinWidth,
|
|
773
|
+
placeholderWidth,
|
|
774
|
+
selectedIndicatorChipElWidth
|
|
775
|
+
});
|
|
776
|
+
this.fitUsingCompactCountLabel = hideSelectedChips;
|
|
777
|
+
const availableHorizontalChipElSpace = Math.round(chipContainerElWidth - (hiddenChipIndicatorWidth + chipContainerElGap + reservedPlaceholderInputWidth + chipContainerElGap));
|
|
778
|
+
this.refreshChipDisplay({
|
|
779
|
+
availableHorizontalChipElSpace,
|
|
780
|
+
chipContainerElGap,
|
|
781
|
+
chipEls,
|
|
782
|
+
hideSelectedChips
|
|
783
|
+
});
|
|
784
|
+
const previousHiddenChipsCount = this.selectedHiddenChipsCount;
|
|
785
|
+
this.syncChipVisibilityCounts(chipEls);
|
|
786
|
+
const didHiddenCountChange = previousHiddenChipsCount !== this.selectedHiddenChipsCount;
|
|
787
|
+
if (didHiddenCountChange && followUpRefresh) {
|
|
788
|
+
this.fitFollowUpRefreshPromise = this.updateComplete.then(() => this.refreshSelectionDisplay(false)).then(() => {
|
|
789
|
+
this.fitFollowUpRefreshPromise = null;
|
|
790
|
+
});
|
|
791
|
+
}
|
|
692
792
|
}
|
|
793
|
+
this.refreshingSelectionDisplay = false;
|
|
693
794
|
}
|
|
694
795
|
setFloatingEl(el) {
|
|
695
796
|
this.floatingEl = el;
|
|
696
797
|
connectFloatingUI(this);
|
|
697
798
|
}
|
|
799
|
+
shouldUseFitCompactDisplay({ chipContainerElGap, chipContainerElWidth, hiddenChipIndicatorWidth, inputMinWidth, placeholderWidth, reservedPlaceholderInputWidth }) {
|
|
800
|
+
const availableHorizontalChipElSpaceWithPlaceholder = Math.round(chipContainerElWidth - (hiddenChipIndicatorWidth + chipContainerElGap + reservedPlaceholderInputWidth + chipContainerElGap));
|
|
801
|
+
const placeholderIsReallyLong = placeholderWidth > inputMinWidth * 2;
|
|
802
|
+
return placeholderIsReallyLong && availableHorizontalChipElSpaceWithPlaceholder <= 0;
|
|
803
|
+
}
|
|
804
|
+
getFitCompactDisplayState({ chipContainerElGap, chipContainerElWidth, inputMinWidth, placeholderWidth, selectedIndicatorChipElWidth }) {
|
|
805
|
+
const selectedChipCountElWidth = getElementWidth(this.selectedChipCountRef.value);
|
|
806
|
+
const hiddenChipIndicatorWidth = this.deferFitChipCountRender || this.selectedHiddenChipsCount <= 0 ? 0 : selectedChipCountElWidth || selectedIndicatorChipElWidth;
|
|
807
|
+
const reservedPlaceholderInputWidth = Math.max(inputMinWidth, placeholderWidth);
|
|
808
|
+
const hideSelectedChips = this.shouldUseFitCompactDisplay({
|
|
809
|
+
chipContainerElGap,
|
|
810
|
+
chipContainerElWidth,
|
|
811
|
+
hiddenChipIndicatorWidth,
|
|
812
|
+
inputMinWidth,
|
|
813
|
+
placeholderWidth,
|
|
814
|
+
reservedPlaceholderInputWidth
|
|
815
|
+
});
|
|
816
|
+
return {
|
|
817
|
+
hiddenChipIndicatorWidth,
|
|
818
|
+
hideSelectedChips,
|
|
819
|
+
reservedPlaceholderInputWidth
|
|
820
|
+
};
|
|
821
|
+
}
|
|
698
822
|
setCompactSelectionDisplay({ chipContainerElGap, chipContainerElWidth, inputWidth, largestSelectedIndicatorChipWidth }) {
|
|
699
823
|
const newCompactBreakpoint = Math.round(largestSelectedIndicatorChipWidth + chipContainerElGap + inputWidth);
|
|
700
824
|
if (!this.maxCompactBreakpoint || this.maxCompactBreakpoint < newCompactBreakpoint) {
|
|
@@ -715,17 +839,21 @@ class Combobox extends LitElement {
|
|
|
715
839
|
this.referenceEl = el;
|
|
716
840
|
connectFloatingUI(this);
|
|
717
841
|
}
|
|
718
|
-
|
|
842
|
+
syncChipVisibilityCounts(chipEls) {
|
|
719
843
|
let newSelectedVisibleChipsCount = 0;
|
|
844
|
+
let selectedChipCount = 0;
|
|
720
845
|
chipEls.forEach((chipEl) => {
|
|
721
|
-
if (chipEl.selected
|
|
722
|
-
|
|
846
|
+
if (chipEl.selected) {
|
|
847
|
+
selectedChipCount++;
|
|
848
|
+
if (!chipEl.classList.contains(CSS.chipInvisible)) {
|
|
849
|
+
newSelectedVisibleChipsCount++;
|
|
850
|
+
}
|
|
723
851
|
}
|
|
724
852
|
});
|
|
725
853
|
if (newSelectedVisibleChipsCount !== this.selectedVisibleChipsCount) {
|
|
726
854
|
this.selectedVisibleChipsCount = newSelectedVisibleChipsCount;
|
|
727
855
|
}
|
|
728
|
-
const newSelectedHiddenChipsCount = Math.max(0,
|
|
856
|
+
const newSelectedHiddenChipsCount = Math.max(0, selectedChipCount - newSelectedVisibleChipsCount);
|
|
729
857
|
if (newSelectedHiddenChipsCount !== this.selectedHiddenChipsCount) {
|
|
730
858
|
this.selectedHiddenChipsCount = newSelectedHiddenChipsCount;
|
|
731
859
|
}
|
|
@@ -770,6 +898,9 @@ class Combobox extends LitElement {
|
|
|
770
898
|
if (!item || this.selectionMode === "single-persist" && item.selected && item.value === this.value && !value) {
|
|
771
899
|
return;
|
|
772
900
|
}
|
|
901
|
+
if (this.selectionDisplay === "fit" && this.isMulti()) {
|
|
902
|
+
this.deferFitChipCountRender = true;
|
|
903
|
+
}
|
|
773
904
|
if (this.isMulti()) {
|
|
774
905
|
this.handleMultiSelection(item, value);
|
|
775
906
|
} else {
|
|
@@ -805,11 +936,14 @@ class Combobox extends LitElement {
|
|
|
805
936
|
const ancestors = getItemAncestors(item);
|
|
806
937
|
const children = getItemChildren(item);
|
|
807
938
|
if (item.selected) {
|
|
808
|
-
ancestors.forEach((el) => {
|
|
939
|
+
[...children, ...ancestors].forEach((el) => {
|
|
940
|
+
if (el.disabled) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
809
943
|
el.selected = true;
|
|
810
944
|
});
|
|
811
945
|
} else {
|
|
812
|
-
children.forEach((el) => {
|
|
946
|
+
[...children].forEach((el) => {
|
|
813
947
|
if (el.disabled) {
|
|
814
948
|
return;
|
|
815
949
|
}
|
|
@@ -830,6 +964,7 @@ class Combobox extends LitElement {
|
|
|
830
964
|
this.groupData = this.getGroupData();
|
|
831
965
|
this.updateItemProps();
|
|
832
966
|
this.selectedItems = this.getSelectedItems();
|
|
967
|
+
this.previousAllSelected = this.allSelected;
|
|
833
968
|
}
|
|
834
969
|
updateItemProps() {
|
|
835
970
|
this.allItems.forEach((item) => {
|
|
@@ -903,13 +1038,17 @@ class Combobox extends LitElement {
|
|
|
903
1038
|
}
|
|
904
1039
|
removeActiveChip(chip) {
|
|
905
1040
|
const activeItem = this.selectedItems[this.activeChipIndex];
|
|
906
|
-
if (activeItem && `${IDS.chip(activeItem.guid)}` === chip.id) {
|
|
1041
|
+
if (activeItem && !activeItem.disabled && `${IDS.chip(activeItem.guid)}` === chip.id) {
|
|
907
1042
|
this.toggleSelection(activeItem, false);
|
|
908
1043
|
}
|
|
909
1044
|
this.setFocus();
|
|
910
1045
|
}
|
|
911
1046
|
removeLastChip() {
|
|
912
|
-
this.
|
|
1047
|
+
const lastEnabledSelectedItem = this.selectedItems.findLast((item) => !item.disabled);
|
|
1048
|
+
if (!lastEnabledSelectedItem) {
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
this.toggleSelection(lastEnabledSelectedItem, false);
|
|
913
1052
|
this.setFocus();
|
|
914
1053
|
}
|
|
915
1054
|
previousChip() {
|
|
@@ -980,7 +1119,11 @@ class Combobox extends LitElement {
|
|
|
980
1119
|
if (this.disabled) {
|
|
981
1120
|
return;
|
|
982
1121
|
}
|
|
1122
|
+
this.activeChipIndex = -1;
|
|
983
1123
|
this.textInputRef.value.focus();
|
|
1124
|
+
if (this.open && this.selectionDisplay === "fit" && this.isMulti()) {
|
|
1125
|
+
void this.refreshSelectionDisplay();
|
|
1126
|
+
}
|
|
984
1127
|
}
|
|
985
1128
|
createScreenReaderItem({ ariaLabel, ariaSelected, id, textContent }) {
|
|
986
1129
|
return html`<li aria-label=${ariaLabel ?? nothing} aria-selected=${ariaSelected ?? nothing} id=${id ?? nothing} role=option tabindex=-1>${textContent}</li>`;
|
|
@@ -1006,23 +1149,21 @@ class Combobox extends LitElement {
|
|
|
1006
1149
|
return keyed(item.guid || item.value || label, html`<calcite-chip .appearance=${readOnly ? "outline" : "solid"} class=${safeClassMap({
|
|
1007
1150
|
[CSS.chip]: true,
|
|
1008
1151
|
[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>`);
|
|
1152
|
+
})} .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
1153
|
}
|
|
1011
1154
|
renderChipCount(count, scale) {
|
|
1012
|
-
const label = this.messages.disabledSelectedCount?.replace("{count}", `${count}`) ?? `+${count}`;
|
|
1155
|
+
const label = this.fitUsingCompactCountLabel ? `${count}` : this.messages.disabledSelectedCount?.replace("{count}", `${count}`) ?? `+${count}`;
|
|
1013
1156
|
return html`<calcite-chip appearance=solid class=${safeClassMap({
|
|
1014
1157
|
[CSS.chip]: true
|
|
1015
|
-
})} .label=${label} .scale=${scale} tabindex=-1 title=${label ?? nothing}>${label}</calcite-chip>`;
|
|
1158
|
+
})} 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
1159
|
}
|
|
1017
1160
|
renderChips() {
|
|
1018
1161
|
const { activeChipIndex, readOnly, scale, selectionDisplay, selectionMode, messages } = this;
|
|
1019
1162
|
const chips = [];
|
|
1020
1163
|
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)));
|
|
1164
|
+
const hideSelectedChipsForSelectAll = this.selectAllEnabled && this.allSelected;
|
|
1024
1165
|
const preserveOrder = selectionDisplay === "all";
|
|
1025
|
-
if (
|
|
1166
|
+
if (hideSelectedChipsForSelectAll) {
|
|
1026
1167
|
return null;
|
|
1027
1168
|
}
|
|
1028
1169
|
let selectedIndex = 0;
|
|
@@ -1044,7 +1185,7 @@ class Combobox extends LitElement {
|
|
|
1044
1185
|
}
|
|
1045
1186
|
return;
|
|
1046
1187
|
}
|
|
1047
|
-
if (!
|
|
1188
|
+
if (!hideSelectedChipsForSelectAll) {
|
|
1048
1189
|
if (item.selected && (!isAncestors || !hasActiveChildren(item))) {
|
|
1049
1190
|
chips.push(this.renderChip({
|
|
1050
1191
|
activeChipIndex,
|
|
@@ -1059,11 +1200,11 @@ class Combobox extends LitElement {
|
|
|
1059
1200
|
}
|
|
1060
1201
|
}
|
|
1061
1202
|
});
|
|
1062
|
-
} else if (!
|
|
1203
|
+
} else if (!hideSelectedChipsForSelectAll) {
|
|
1063
1204
|
this.selectedItems.forEach((item) => {
|
|
1064
1205
|
chips.push(this.renderChip({
|
|
1065
1206
|
activeChipIndex,
|
|
1066
|
-
disabled:
|
|
1207
|
+
disabled: item.disabled,
|
|
1067
1208
|
index: selectedIndex++,
|
|
1068
1209
|
item,
|
|
1069
1210
|
messages,
|
|
@@ -1073,32 +1214,53 @@ class Combobox extends LitElement {
|
|
|
1073
1214
|
}));
|
|
1074
1215
|
});
|
|
1075
1216
|
}
|
|
1076
|
-
if (selectionDisplay === "fit"
|
|
1077
|
-
|
|
1217
|
+
if (selectionDisplay === "fit") {
|
|
1218
|
+
const hiddenSelectedCount = this.selectedHiddenChipsCount;
|
|
1219
|
+
const countChipValue = this.selectedVisibleChipsCount === 0 ? this.selectedItems.length : hiddenSelectedCount;
|
|
1220
|
+
if (hiddenSelectedCount > 0 && !this.deferFitChipCountRender) {
|
|
1221
|
+
chips.push(this.renderChipCount(countChipValue, scale));
|
|
1222
|
+
}
|
|
1078
1223
|
}
|
|
1079
1224
|
return chips.length ? chips : null;
|
|
1080
1225
|
}
|
|
1081
1226
|
renderAllSelectedIndicatorChip() {
|
|
1082
1227
|
const { allSelectedIndicatorChipRef, compactSelectionDisplay, scale, selectedVisibleChipsCount } = this;
|
|
1083
|
-
|
|
1084
|
-
|
|
1228
|
+
let useFitCompactLabel = false;
|
|
1229
|
+
if (this.selectionDisplay === "fit" && this.textInputRef.value && this.chipContainerEl) {
|
|
1230
|
+
const chipContainerElGap = parseInt(getComputedStyle(this.chipContainerEl).gap);
|
|
1231
|
+
const chipContainerElWidth = getElementWidth(this.chipContainerEl);
|
|
1232
|
+
const { fontSize, fontFamily, minInlineSize } = getComputedStyle(this.textInputRef.value);
|
|
1233
|
+
const placeholderWidthMultiplier = 0.55;
|
|
1234
|
+
const inputMinWidth = parseFloat(minInlineSize) || parseInt(calciteSize48);
|
|
1235
|
+
const measuredPlaceholderWidth = getTextWidth(this.placeholder, `${fontSize} ${fontFamily}`);
|
|
1236
|
+
const placeholderWidth = measuredPlaceholderWidth > 0 ? measuredPlaceholderWidth : Math.max(inputMinWidth, Math.round((this.placeholder?.length || 0) * (parseFloat(fontSize) || parseInt(calciteSize48)) * placeholderWidthMultiplier));
|
|
1237
|
+
const selectedIndicatorChipElWidth = getElementWidth(this.selectedIndicatorChipRef.value);
|
|
1238
|
+
useFitCompactLabel = this.getFitCompactDisplayState({
|
|
1239
|
+
chipContainerElGap,
|
|
1240
|
+
chipContainerElWidth,
|
|
1241
|
+
inputMinWidth,
|
|
1242
|
+
placeholderWidth,
|
|
1243
|
+
selectedIndicatorChipElWidth
|
|
1244
|
+
}).hideSelectedChips;
|
|
1245
|
+
}
|
|
1246
|
+
const useCompactAllLabel = compactSelectionDisplay || useFitCompactLabel;
|
|
1247
|
+
const label = useCompactAllLabel ? this.messages.all : this.messages.allSelected;
|
|
1248
|
+
const showAllSelectedChip = this.allSelected && (this.selectionDisplay === "single" || !selectedVisibleChipsCount || this.selectionDisplay === "all");
|
|
1085
1249
|
return html`<calcite-chip class=${safeClassMap({
|
|
1086
1250
|
[CSS.chip]: true,
|
|
1087
1251
|
[CSS.chipInvisible]: !showAllSelectedChip,
|
|
1088
1252
|
[CSS.allSelected]: true
|
|
1089
|
-
})} .label=${label} .scale=${scale} title=${label ?? nothing} value ${ref(allSelectedIndicatorChipRef)}>${label}</calcite-chip>`;
|
|
1253
|
+
})} data-testid=all-selected-indicator-chip .label=${label} .scale=${scale} title=${label ?? nothing} value ${ref(allSelectedIndicatorChipRef)}>${label}</calcite-chip>`;
|
|
1090
1254
|
}
|
|
1091
1255
|
renderSelectedIndicatorChip() {
|
|
1092
|
-
const { compactSelectionDisplay, selectionDisplay, scale,
|
|
1093
|
-
const allSelectedNoDisabled = this.allSelected && !this.hasDisabledItems;
|
|
1094
|
-
const allSelectedWithDisabledSelected = this.allSelected && this.hasDisabledSelected;
|
|
1256
|
+
const { compactSelectionDisplay, selectionDisplay, scale, selectedIndicatorChipRef } = this;
|
|
1095
1257
|
let chipInvisible;
|
|
1096
1258
|
let label;
|
|
1259
|
+
const selectedItemsCount = this.getSelectedItems().length;
|
|
1097
1260
|
if (compactSelectionDisplay) {
|
|
1098
1261
|
chipInvisible = true;
|
|
1099
1262
|
} else {
|
|
1100
1263
|
if (selectionDisplay === "single") {
|
|
1101
|
-
const selectedItemsCount = this.allItems.filter((item) => item.selected && (this.selectionMode !== "ancestors" || !hasActiveChildren(item))).length;
|
|
1102
1264
|
if (this.allSelected) {
|
|
1103
1265
|
chipInvisible = true;
|
|
1104
1266
|
} else if (selectedItemsCount > 0) {
|
|
@@ -1107,9 +1269,6 @@ class Combobox extends LitElement {
|
|
|
1107
1269
|
chipInvisible = true;
|
|
1108
1270
|
}
|
|
1109
1271
|
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
1272
|
}
|
|
1114
1273
|
}
|
|
1115
1274
|
return html`<calcite-chip class=${safeClassMap({
|
|
@@ -1118,18 +1277,13 @@ class Combobox extends LitElement {
|
|
|
1118
1277
|
})} .label=${label} .scale=${scale} title=${label ?? nothing} value ${ref(selectedIndicatorChipRef)}>${label}</calcite-chip>`;
|
|
1119
1278
|
}
|
|
1120
1279
|
renderSelectedIndicatorChipCompact() {
|
|
1121
|
-
const { compactSelectionDisplay, selectionDisplay, scale
|
|
1122
|
-
const allSelectedNoDisabled = this.allSelected && !this.hasDisabledItems;
|
|
1123
|
-
const allSelectedWithDisabledSelected = this.allSelected && this.hasDisabledSelected;
|
|
1280
|
+
const { compactSelectionDisplay, selectionDisplay, scale } = this;
|
|
1124
1281
|
let chipInvisible;
|
|
1125
1282
|
let label;
|
|
1283
|
+
const selectedItemsCount = this.getSelectedItems().length;
|
|
1126
1284
|
if (compactSelectionDisplay) {
|
|
1127
|
-
|
|
1128
|
-
if (allSelectedNoDisabled || allSelectedWithDisabledSelected || selectionDisplay === "single" && this.allSelected) {
|
|
1285
|
+
if (this.allSelected) {
|
|
1129
1286
|
chipInvisible = true;
|
|
1130
|
-
} else if (selectionDisplay === "fit") {
|
|
1131
|
-
chipInvisible = !(selectedHiddenChipsCount > 0);
|
|
1132
|
-
label = `${selectedHiddenChipsCount || 0}`;
|
|
1133
1287
|
} else if (selectionDisplay === "single") {
|
|
1134
1288
|
chipInvisible = !(selectedItemsCount > 0);
|
|
1135
1289
|
label = `${selectedItemsCount}`;
|
|
@@ -1158,7 +1312,7 @@ class Combobox extends LitElement {
|
|
|
1158
1312
|
[CSS.inputSingle]: true,
|
|
1159
1313
|
[CSS.inputHidden]: showLabel,
|
|
1160
1314
|
[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>`;
|
|
1315
|
+
})} 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
1316
|
}
|
|
1163
1317
|
renderListBoxOptions() {
|
|
1164
1318
|
const mappedListBoxOptions = this.keyboardNavItems.map((item) => this.createScreenReaderItem({
|
|
@@ -1187,7 +1341,7 @@ class Combobox extends LitElement {
|
|
|
1187
1341
|
[FloatingCSS.animationActive]: open
|
|
1188
1342
|
};
|
|
1189
1343
|
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({
|
|
1344
|
+
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
1345
|
text: label,
|
|
1192
1346
|
pattern: new RegExp(`(${escapeRegExp(this.filterText)})`, "i")
|
|
1193
1347
|
})}</li>` : html`<li class=${safeClassMap({ [CSS.noMatchesPlaceholder]: true, [CSS.noMatches]: true })}>${messages.noMatches}</li>`) || ""}</ul></div></div>`;
|
|
@@ -1212,8 +1366,10 @@ class Combobox extends LitElement {
|
|
|
1212
1366
|
const allSelectionDisplay = selectionDisplay === "all";
|
|
1213
1367
|
const singleSelectionDisplay = selectionDisplay === "single";
|
|
1214
1368
|
const fitSelectionDisplay = !singleSelectionMode && selectionDisplay === "fit";
|
|
1215
|
-
const
|
|
1216
|
-
const
|
|
1369
|
+
const showIndicatorChips = !singleSelectionMode && !allSelectionDisplay;
|
|
1370
|
+
const showSingleIndicatorChips = showIndicatorChips && !fitSelectionDisplay;
|
|
1371
|
+
const hasClearableSelection = this.items.some((item) => item.selected && !item.disabled);
|
|
1372
|
+
const isClearable = !this.clearDisabled && this.selectionMode !== "single-persist" && !!this.value?.length && hasClearableSelection;
|
|
1217
1373
|
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
1374
|
[CSS.wrapper]: true,
|
|
1219
1375
|
[CSS.wrapperSingle]: singleSelectionMode || !this.selectedItems.length,
|
|
@@ -1222,11 +1378,7 @@ class Combobox extends LitElement {
|
|
|
1222
1378
|
[CSS.gridInput]: true,
|
|
1223
1379
|
[CSS.selectionDisplayFit]: fitSelectionDisplay,
|
|
1224
1380
|
[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}` });
|
|
1381
|
+
})} ${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
1382
|
}
|
|
1231
1383
|
}
|
|
1232
1384
|
customElement("calcite-combobox", Combobox);
|