@esri/calcite-components 5.1.0-next.13 → 5.1.0-next.14

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.
Files changed (153) hide show
  1. package/dist/cdn/{LDTOD4DT.js → 22RWV6QP.js} +1 -1
  2. package/dist/cdn/{ACON6LGO.js → 25JDEBUF.js} +1 -1
  3. package/dist/cdn/{G362YMP6.js → 27FCDARI.js} +1 -1
  4. package/dist/cdn/{JX3BHPF2.js → 32VYHGDH.js} +1 -1
  5. package/dist/cdn/{TH3QUGNP.js → 3AZEW3HC.js} +1 -1
  6. package/dist/cdn/{NTGSDL2N.js → 3MKLAJGJ.js} +1 -1
  7. package/dist/cdn/{PIN2J3IM.js → 3YDAMC5I.js} +1 -1
  8. package/dist/cdn/{YMYA43OX.js → 3ZGQTXQO.js} +1 -1
  9. package/dist/cdn/{YTXB5BKT.js → 4C3MB2GK.js} +1 -1
  10. package/dist/cdn/{RRNENB44.js → 4E5CZZ5M.js} +1 -1
  11. package/dist/cdn/{JW5AXWSR.js → 4GI75SEX.js} +1 -1
  12. package/dist/cdn/{7YACGPDW.js → 4ULBFBUZ.js} +1 -1
  13. package/dist/cdn/{IT6E2HBW.js → 5EA66567.js} +1 -1
  14. package/dist/cdn/{5SIZALLU.js → 6SSIJAD6.js} +1 -1
  15. package/dist/cdn/{WSYLURBF.js → 6UG4Z3XT.js} +1 -1
  16. package/dist/cdn/{3LVAGPAN.js → 6WPJ34FX.js} +1 -1
  17. package/dist/cdn/{X6QKKRKG.js → 6XD6O5OE.js} +1 -1
  18. package/dist/cdn/{VSPXRUNP.js → 6ZN7JLSW.js} +1 -1
  19. package/dist/cdn/{4SEMQUI5.js → 7CYEXMUQ.js} +1 -1
  20. package/dist/cdn/{CLWPGJZ5.js → 7Z5KFNBW.js} +1 -1
  21. package/dist/cdn/{LXYWLOXP.js → A2OVD4TR.js} +1 -1
  22. package/dist/cdn/{LPZOPIC7.js → A452W5YE.js} +1 -1
  23. package/dist/cdn/{4OAYJZ53.js → AMVVUZIN.js} +1 -1
  24. package/dist/cdn/{J3SNZZCJ.js → AVIW6C7H.js} +1 -1
  25. package/dist/cdn/{CU2Q4KA5.js → BCRGWY4W.js} +1 -1
  26. package/dist/cdn/{NF5UERIW.js → BKQ2SGST.js} +1 -1
  27. package/dist/cdn/{5V4DQQ57.js → BTF2THZC.js} +1 -1
  28. package/dist/cdn/{UPJOLADB.js → C2OQ5TA5.js} +1 -1
  29. package/dist/cdn/{LA2L7YVD.js → CBN33A2K.js} +1 -1
  30. package/dist/cdn/{Y53Q6FTX.js → CHAGVNPE.js} +1 -1
  31. package/dist/cdn/{JHFKJ4Q3.js → CMPURUJI.js} +1 -1
  32. package/dist/cdn/{G3JTRJUS.js → D6W2LBV4.js} +1 -1
  33. package/dist/cdn/{DGUJEZZ6.js → DG4NTQKW.js} +1 -1
  34. package/dist/cdn/{5U6XUVG5.js → DGNMDMZ5.js} +1 -1
  35. package/dist/cdn/{T74NIOKP.js → DLAJOPMU.js} +1 -1
  36. package/dist/cdn/{LMG7CPBB.js → DOEZG2JP.js} +1 -1
  37. package/dist/cdn/{BKRP34YH.js → DVKWL263.js} +1 -1
  38. package/dist/cdn/{VQUDSLKM.js → E23HZTZO.js} +1 -1
  39. package/dist/cdn/E7ASSWHL.js +2 -0
  40. package/dist/cdn/{YUCOJPIY.js → EBZ5VIDW.js} +1 -1
  41. package/dist/cdn/{MOEDIY3E.js → EFSQT5D5.js} +1 -1
  42. package/dist/cdn/{OK7CYG2Q.js → EMCCIIUM.js} +1 -1
  43. package/dist/cdn/{PMFWKUV5.js → EZWLF442.js} +1 -1
  44. package/dist/cdn/{H6VM2JWW.js → F7456TVN.js} +1 -1
  45. package/dist/cdn/{YB5ZE5ZG.js → FHGDXLR5.js} +1 -1
  46. package/dist/cdn/{VGQRSLHP.js → FOQ4BS75.js} +1 -1
  47. package/dist/cdn/{77PEJR7C.js → FS66OD2Z.js} +1 -1
  48. package/dist/cdn/{7PDJEKY7.js → FXKZVMPD.js} +1 -1
  49. package/dist/cdn/{C37LO3WG.js → G77XULTS.js} +1 -1
  50. package/dist/cdn/{TG26BQOY.js → GAOGACGP.js} +1 -1
  51. package/dist/cdn/{HFEHUBJG.js → GHPM5W3Y.js} +1 -1
  52. package/dist/cdn/{PVZ3EPI5.js → GQRHU2NJ.js} +1 -1
  53. package/dist/cdn/{4TGPM7I5.js → GSMXAQ2L.js} +1 -1
  54. package/dist/cdn/{FTYQVE6T.js → GYBFABJD.js} +1 -1
  55. package/dist/cdn/{P3YCPKWZ.js → HCO675FC.js} +1 -1
  56. package/dist/cdn/{CFLYSS5A.js → HG2A7DG2.js} +1 -1
  57. package/dist/cdn/{SZG4V4PR.js → HRTXIDXP.js} +1 -1
  58. package/dist/cdn/{K4WKHSIF.js → HTKWLUFB.js} +1 -1
  59. package/dist/cdn/{UZ35OYI7.js → I2BYQLHV.js} +1 -1
  60. package/dist/cdn/{FLAY44HL.js → IG7C5G37.js} +1 -1
  61. package/dist/cdn/{FJRW4YMN.js → IHEV3WNI.js} +1 -1
  62. package/dist/cdn/{7UHIUVY4.js → IUZ6SBWD.js} +1 -1
  63. package/dist/cdn/{77NFNDVJ.js → JK7JIIX3.js} +1 -1
  64. package/dist/cdn/{MHQCKR37.js → JKJONT3F.js} +1 -1
  65. package/dist/cdn/{VYW3GC6J.js → JLEHCUKU.js} +1 -1
  66. package/dist/cdn/{2AOTS7JD.js → JQU644YO.js} +1 -1
  67. package/dist/cdn/{OYHIOHY2.js → JTGHI5IX.js} +1 -1
  68. package/dist/cdn/{JQERGOAL.js → JUAFJEHB.js} +1 -1
  69. package/dist/cdn/{32MLXVEN.js → JWSUZYJK.js} +1 -1
  70. package/dist/cdn/{RHWJ6NSV.js → K23AEOT6.js} +1 -1
  71. package/dist/cdn/{LPBE76CV.js → KM36CA3Y.js} +1 -1
  72. package/dist/cdn/{XQHQLW6O.js → KV72IXEW.js} +1 -1
  73. package/dist/cdn/{POS6BZNF.js → L4EFYP66.js} +1 -1
  74. package/dist/cdn/{DVXV5ZRZ.js → L4GJSURJ.js} +1 -1
  75. package/dist/cdn/{65AMWD6E.js → L4XDRMVG.js} +1 -1
  76. package/dist/cdn/{YS5CQELP.js → LBK77YUK.js} +1 -1
  77. package/dist/cdn/{NI5ZZ5GK.js → LW5BTPW7.js} +1 -1
  78. package/dist/cdn/{K5YWIYA5.js → M5QSGSMQ.js} +1 -1
  79. package/dist/cdn/{GTDMVZXX.js → MJFI5UTM.js} +1 -1
  80. package/dist/cdn/{RAEAOYKN.js → MOU4OKPJ.js} +1 -1
  81. package/dist/cdn/{OGRWDESZ.js → MTENHIJR.js} +1 -1
  82. package/dist/cdn/{5DE4KVRT.js → NDTFBLEM.js} +1 -1
  83. package/dist/cdn/{CBMJ652S.js → NQIHWLUV.js} +1 -1
  84. package/dist/cdn/{I6C4ASCI.js → NR5UESWA.js} +1 -1
  85. package/dist/cdn/{FDJ63ORN.js → NX3LVHRX.js} +1 -1
  86. package/dist/cdn/{JMLADU7B.js → NXNIQW2R.js} +1 -1
  87. package/dist/cdn/{R76W6LVB.js → O4ALBCML.js} +1 -1
  88. package/dist/cdn/{FPG2HELI.js → OO7NQTVD.js} +1 -1
  89. package/dist/cdn/{C6TU2KHO.js → OSCSUL3G.js} +1 -1
  90. package/dist/cdn/{M5JMQS42.js → OU6PFEBR.js} +1 -1
  91. package/dist/cdn/{65UMC6GN.js → OYA2L4Z5.js} +1 -1
  92. package/dist/cdn/{4MJZVDBE.js → P4FRA4PT.js} +1 -1
  93. package/dist/cdn/{PDQH2ROR.js → P5NKCJW4.js} +1 -1
  94. package/dist/cdn/{BIWKEWAN.js → PFM4JGSK.js} +1 -1
  95. package/dist/cdn/{OL3TMXKW.js → PRWO3UOA.js} +1 -1
  96. package/dist/cdn/{MEZL5G6M.js → QCMQXPY4.js} +1 -1
  97. package/dist/cdn/{KOFCDN3E.js → QW6VLW2I.js} +1 -1
  98. package/dist/cdn/{DMSJWJ6R.js → REGR4UG2.js} +1 -1
  99. package/dist/cdn/{MNR4OSPQ.js → RHZGKGJY.js} +1 -1
  100. package/dist/cdn/{CZI7XFN5.js → RKE3HSUQ.js} +1 -1
  101. package/dist/cdn/{7NUEP656.js → RNEN4PMT.js} +1 -1
  102. package/dist/cdn/{LYHUQBAV.js → RS3WIOJ2.js} +1 -1
  103. package/dist/cdn/{GREPCYAX.js → SVNK2VIG.js} +1 -1
  104. package/dist/cdn/T4QG2LRI.js +2 -0
  105. package/dist/cdn/{CTDFMC2L.js → T7P6UWNT.js} +1 -1
  106. package/dist/cdn/{N6I5ZZ32.js → TFEZNLRU.js} +1 -1
  107. package/dist/cdn/{3CTEG5OC.js → TK2PCE7H.js} +1 -1
  108. package/dist/cdn/{VXVQYSN5.js → TKFN5WLL.js} +1 -1
  109. package/dist/cdn/{MVEASF4W.js → TMZHZVQB.js} +1 -1
  110. package/dist/cdn/{DKZ6MWAZ.js → TP3V6AFY.js} +1 -1
  111. package/dist/cdn/{UBRCSTEG.js → TR5JX34U.js} +1 -1
  112. package/dist/cdn/{CRYMTY2R.js → TWAD3RLQ.js} +1 -1
  113. package/dist/cdn/{HAP5KF3X.js → TXVPN2YR.js} +1 -1
  114. package/dist/cdn/{M5HZRKR3.js → UEHXHACM.js} +1 -1
  115. package/dist/cdn/{GHT4TFQ6.js → UFUSWPYC.js} +1 -1
  116. package/dist/cdn/{44T7OREC.js → UN37VT7C.js} +1 -1
  117. package/dist/cdn/UOLL7GD7.js +2 -0
  118. package/dist/cdn/{RIVYDVF4.js → UQBI3W5X.js} +1 -1
  119. package/dist/cdn/{N5PSKGBC.js → UXUJGWYY.js} +1 -1
  120. package/dist/cdn/{R3L4IZ2G.js → VDJIQ76C.js} +1 -1
  121. package/dist/cdn/{34SFIDVL.js → VKEE4CSH.js} +1 -1
  122. package/dist/cdn/{JZFKU2ZM.js → VKRTT773.js} +1 -1
  123. package/dist/cdn/{EWU5JVMQ.js → VVQ7JG2U.js} +1 -1
  124. package/dist/cdn/{56HEEILX.js → WJLL6PRQ.js} +1 -1
  125. package/dist/cdn/{6YQDVKXT.js → WJYECE3U.js} +1 -1
  126. package/dist/cdn/{26AV55CR.js → WLLPEABX.js} +1 -1
  127. package/dist/cdn/{CDQOPSGR.js → WPHFOGQQ.js} +1 -1
  128. package/dist/cdn/{HBYLZDXS.js → WUF6X5G3.js} +1 -1
  129. package/dist/cdn/{XEWTMJGZ.js → WXB7MBSF.js} +1 -1
  130. package/dist/cdn/{4VET23BY.js → XCSGFRTN.js} +1 -1
  131. package/dist/cdn/{C3XJZW6F.js → XILRRKB5.js} +1 -1
  132. package/dist/cdn/{CSXQ5Z4G.js → XYJ4V2D4.js} +1 -1
  133. package/dist/cdn/{57MEVGHV.js → Y2WJN2N7.js} +1 -1
  134. package/dist/cdn/{DIO5CFXN.js → Y6Q3SH2K.js} +1 -1
  135. package/dist/cdn/{C2E2OXI7.js → YCXK2C5S.js} +1 -1
  136. package/dist/cdn/{XOV2BVZT.js → YE5WMYH2.js} +1 -1
  137. package/dist/cdn/{IWHXGNSP.js → YFXV6TWV.js} +1 -1
  138. package/dist/cdn/{I5BK6WOV.js → YYE3YS37.js} +1 -1
  139. package/dist/cdn/{TRAYPJCJ.js → ZNB2D2LW.js} +1 -1
  140. package/dist/cdn/{WLX2F73G.js → ZY2R26XI.js} +1 -1
  141. package/dist/cdn/index.js +1 -1
  142. package/dist/chunks/runtime.js +4 -4
  143. package/dist/components/calcite-dropdown/customElement.js +140 -81
  144. package/dist/components/calcite-dropdown-item/customElement.js +14 -32
  145. package/dist/docs/api.json +1 -1
  146. package/dist/docs/docs.json +1 -1
  147. package/dist/docs/web-types.json +1 -1
  148. package/dist/loader.js +1 -1
  149. package/package.json +2 -2
  150. package/dist/cdn/3G4DHLX3.js +0 -2
  151. package/dist/cdn/GUF7ZXRS.js +0 -2
  152. package/dist/cdn/KKPPI422.js +0 -2
  153. package/dist/cdn/ZQLGBHLZ.js +0 -2
@@ -1,13 +1,11 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
2
  import { c as customElement } from "../../chunks/runtime.js";
3
3
  import { ref } from "lit/directives/ref.js";
4
- import { css, nothing, html } from "lit";
4
+ import { css, html } from "lit";
5
5
  import { LitElement, createEvent, safeClassMap } from "@arcgis/lumina";
6
- import { queryAssignedElements } from "lit/decorators.js";
7
6
  import { useDirection } from "@arcgis/lumina/controllers";
8
- import { f as focusElementInGroup, i as focusElement, u as nextFrame } from "../../chunks/dom.js";
7
+ import { u as nextFrame } from "../../chunks/dom.js";
9
8
  import { d as defaultMenuPlacement, r as reposition, c as connectFloatingUI, a as disconnectFloatingUI, f as filterValidFlipPlacements, h as hideFloatingUI, F as FloatingCSS } from "../../chunks/floating-ui.js";
10
- import { g as guid } from "../../chunks/guid.js";
11
9
  import { i as isActivationKey } from "../../chunks/key.js";
12
10
  import { c as createObserver, u as updateRefObserver } from "../../chunks/observers.js";
13
11
  import { t as toggleOpenClose } from "../../chunks/openCloseComponent.js";
@@ -23,28 +21,14 @@ const CSS = {
23
21
  wrapper: "wrapper",
24
22
  triggerContainer: "trigger-container"
25
23
  };
26
- const idPrefix = "calcite-dropdown";
27
- const IDS = {
28
- menuButton: (id) => `${idPrefix}-${id}-menubutton`,
29
- menu: (id) => `${idPrefix}-${id}-menu`
30
- };
31
24
  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{display:inline-block}.wrapper{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{.wrapper{opacity:0;inset-block-start:0;left:0}}:host([top-layer-disabled]) .wrapper{--calcite-floating-ui-z-index: var(--calcite-z-index-dropdown)}.wrapper[popover]{padding:0;margin:0;border:none;background-color:transparent;overflow:visible;display:none}.wrapper:popover-open{display:block}.wrapper .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}.wrapper[data-placement^=bottom] .calcite-floating-ui-anim{inset-block-start:-5px}.wrapper[data-placement^=top] .calcite-floating-ui-anim{inset-block-start:5px}.wrapper[data-placement^=left] .calcite-floating-ui-anim{left:5px}.wrapper[data-placement^=right] .calcite-floating-ui-anim{left:-5px}.wrapper[data-placement] .calcite-floating-ui-anim--active{opacity:1;inset-block-start:0;left:0}@starting-style{.wrapper[data-placement] .calcite-floating-ui-anim--active{opacity:0}}.content{max-height:45vh;width:auto;overflow-y:auto;overflow-x:hidden;inline-size:var(--calcite-dropdown-width, var(--calcite-internal-dropdown-width));background-color:var(--calcite-dropdown-background-color, var(--calcite-color-foreground-1))}.trigger-container{position:relative;display:flex;height:100%;flex:1 1 auto;word-wrap:break-word;word-break:break-word}.width-s{--calcite-internal-dropdown-width: 12rem}.width-m{--calcite-internal-dropdown-width: 14rem}.width-l{--calcite-internal-dropdown-width: 16rem}@media(forced-colors:active){:host([open]) .wrapper{border:var(--calcite-border-width-sm) solid canvasText}}:host([hidden]){display:none}[hidden]{display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}`;
32
- var __defProp = Object.defineProperty;
33
- var __decorateClass = (decorators, target, key, kind) => {
34
- var result = void 0;
35
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
36
- if (decorator = decorators[i])
37
- result = decorator(target, key, result) || result;
38
- if (result) __defProp(target, key, result);
39
- return result;
40
- };
41
25
  class Dropdown extends LitElement {
42
26
  constructor() {
43
27
  super();
44
28
  this.direction = useDirection();
45
29
  this.focusLastDropdownItem = false;
30
+ this.activeItemIndex = -1;
46
31
  this.groups = [];
47
- this.guid = guid();
48
32
  this.items = [];
49
33
  this.mutationObserver = createObserver("mutation", () => this.updateItems());
50
34
  this.transitionProp = "opacity";
@@ -72,15 +56,13 @@ class Dropdown extends LitElement {
72
56
  this.calciteDropdownOpen = createEvent({ cancelable: false });
73
57
  this.calciteDropdownSelect = createEvent({ cancelable: false });
74
58
  this.listenOn(window, "click", this.closeCalciteDropdownOnClick);
75
- this.listen("calciteInternalDropdownCloseRequest", this.closeCalciteDropdownOnEvent);
76
59
  this.listenOn(window, "calciteDropdownOpen", this.closeCalciteDropdownOnOpenEvent);
77
60
  this.listen("pointerenter", this.pointerEnterHandler);
78
61
  this.listen("pointerleave", this.pointerLeaveHandler);
79
- this.listen("calciteInternalDropdownItemKeyEvent", this.calciteInternalDropdownItemKeyEvent);
80
62
  this.listen("calciteInternalDropdownItemSelect", this.handleItemSelect);
81
63
  }
82
64
  static {
83
- this.properties = { closeOnSelectDisabled: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], flipPlacements: [0, {}, { attribute: false }], maxItems: [11, {}, { reflect: true, type: Number }], offsetDistance: [11, {}, { type: Number, reflect: true }], offsetSkidding: [11, {}, { reflect: true, type: Number }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placement: [3, {}, { reflect: true }], scale: [3, {}, { reflect: true }], selectedItems: [0, {}, { attribute: false }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], type: [3, {}, { reflect: true }], widthScale: [3, {}, { reflect: true }], width: [3, {}, { reflect: true }] };
65
+ this.properties = { activeDescendantElement: [16, {}, { state: true }], closeOnSelectDisabled: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], flipPlacements: [0, {}, { attribute: false }], maxItems: [11, {}, { reflect: true, type: Number }], offsetDistance: [11, {}, { type: Number, reflect: true }], offsetSkidding: [11, {}, { reflect: true, type: Number }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placement: [3, {}, { reflect: true }], scale: [3, {}, { reflect: true }], selectedItems: [0, {}, { attribute: false }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], type: [3, {}, { reflect: true }], widthScale: [3, {}, { reflect: true }], width: [3, {}, { reflect: true }] };
84
66
  }
85
67
  static {
86
68
  this.shadowRootOptions = { mode: "open", delegatesFocus: true };
@@ -166,23 +148,19 @@ class Dropdown extends LitElement {
166
148
  if (this.disabled || !this.open || event.composedPath().includes(this.el)) {
167
149
  return;
168
150
  }
169
- this.closeCalciteDropdown(false);
170
- }
171
- closeCalciteDropdownOnEvent(event) {
172
151
  this.closeCalciteDropdown();
173
- event.stopPropagation();
174
152
  }
175
153
  closeCalciteDropdownOnOpenEvent(event) {
176
154
  if (event.composedPath().includes(this.el)) {
177
155
  return;
178
156
  }
179
- this.open = false;
157
+ this.closeCalciteDropdown();
180
158
  }
181
159
  pointerEnterHandler() {
182
160
  if (this.disabled || this.type !== "hover") {
183
161
  return;
184
162
  }
185
- this.toggleDropdown();
163
+ this.open = true;
186
164
  }
187
165
  pointerLeaveHandler() {
188
166
  if (this.disabled || this.type !== "hover") {
@@ -193,34 +171,12 @@ class Dropdown extends LitElement {
193
171
  getTraversableItems() {
194
172
  return this.items.filter((item) => !item.disabled && !item.hidden);
195
173
  }
196
- calciteInternalDropdownItemKeyEvent(event) {
197
- const { keyboardEvent } = event.detail;
198
- const target = keyboardEvent.target;
199
- const traversableItems = this.getTraversableItems();
200
- switch (keyboardEvent.key) {
201
- case "Tab":
202
- this.open = false;
203
- this.updateTabIndexOfItems(target);
204
- break;
205
- case "ArrowDown":
206
- focusElementInGroup(traversableItems, target, "next");
207
- break;
208
- case "ArrowUp":
209
- focusElementInGroup(traversableItems, target, "previous");
210
- break;
211
- case "Home":
212
- focusElementInGroup(traversableItems, target, "first");
213
- break;
214
- case "End":
215
- focusElementInGroup(traversableItems, target, "last");
216
- break;
217
- }
218
- event.stopPropagation();
219
- }
220
- handleItemSelect(event) {
174
+ async handleItemSelect(event) {
221
175
  this.updateSelectedItems();
176
+ this.syncActiveItemFromTraversableItems();
222
177
  event.stopPropagation();
223
178
  this.calciteDropdownSelect.emit();
179
+ await this.setFocus();
224
180
  if (!this.closeOnSelectDisabled) {
225
181
  this.closeCalciteDropdown();
226
182
  }
@@ -232,6 +188,7 @@ class Dropdown extends LitElement {
232
188
  updateItems() {
233
189
  this.items = this.groups.map((group) => Array.from(group?.querySelectorAll("calcite-dropdown-item"))).reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []);
234
190
  this.updateSelectedItems();
191
+ this.syncActiveItemFromTraversableItems();
235
192
  this.reposition(true);
236
193
  this.items.forEach((item) => item.scale = this.scale);
237
194
  }
@@ -278,7 +235,7 @@ class Dropdown extends LitElement {
278
235
  this.transitionEl = el;
279
236
  }
280
237
  onBeforeOpen() {
281
- this.focusOnFirstActiveOrDefaultItem();
238
+ this.setInitialActiveItem();
282
239
  this.calciteDropdownBeforeOpen.emit();
283
240
  this.topLayer.show();
284
241
  }
@@ -310,23 +267,52 @@ class Dropdown extends LitElement {
310
267
  if (defaultPrevented) {
311
268
  return;
312
269
  }
313
- if (key === "Escape") {
270
+ if (this.open && key === "Escape") {
314
271
  this.closeCalciteDropdown();
315
272
  event.preventDefault();
316
273
  return;
317
274
  }
318
- if (this.open && event.shiftKey && key === "Tab") {
319
- this.closeCalciteDropdown();
275
+ if (!this.open && isActivationKey(key)) {
276
+ this.open = true;
320
277
  event.preventDefault();
321
278
  return;
322
279
  }
323
- if (isActivationKey(key)) {
324
- this.toggleDropdown();
325
- event.preventDefault();
326
- } else if (key === "ArrowDown" || key === "ArrowUp") {
280
+ if (!this.open && (key === "ArrowDown" || key === "ArrowUp")) {
327
281
  event.preventDefault();
328
282
  this.focusLastDropdownItem = key === "ArrowUp";
329
283
  this.open = true;
284
+ return;
285
+ }
286
+ if (!this.open) {
287
+ return;
288
+ }
289
+ if (key === "Tab") {
290
+ this.closeCalciteDropdown();
291
+ return;
292
+ }
293
+ if (key === "ArrowDown") {
294
+ event.preventDefault();
295
+ this.navigateActiveItem("next");
296
+ return;
297
+ }
298
+ if (key === "ArrowUp") {
299
+ event.preventDefault();
300
+ this.navigateActiveItem("previous");
301
+ return;
302
+ }
303
+ if (key === "Home") {
304
+ event.preventDefault();
305
+ this.navigateActiveItem("first");
306
+ return;
307
+ }
308
+ if (key === "End") {
309
+ event.preventDefault();
310
+ this.navigateActiveItem("last");
311
+ return;
312
+ }
313
+ if (isActivationKey(key)) {
314
+ event.preventDefault();
315
+ this.activateActiveItem();
330
316
  }
331
317
  }
332
318
  updateSelectedItems() {
@@ -336,48 +322,121 @@ class Dropdown extends LitElement {
336
322
  const style = last.getBoundingClientRect();
337
323
  return last.offsetTop + style.height;
338
324
  }
339
- closeCalciteDropdown(focusTrigger = true) {
325
+ closeCalciteDropdown() {
340
326
  this.open = false;
341
- if (focusTrigger) {
342
- focusElement(this.triggerEls[0]);
343
- }
327
+ this.setActiveItemByIndex(-1);
344
328
  }
345
- async focusOnFirstActiveOrDefaultItem() {
329
+ async setInitialActiveItem() {
346
330
  const selectedItem = this.getTraversableItems().find((item) => item.selected);
347
- const target = selectedItem || (this.focusLastDropdownItem ? this.items.at(-1) : this.items[0]);
331
+ const traversableItems = this.getTraversableItems();
332
+ const target = selectedItem || (this.focusLastDropdownItem ? traversableItems.at(-1) : traversableItems[0]);
348
333
  this.focusLastDropdownItem = false;
334
+ if (!target) {
335
+ this.setActiveItemByIndex(-1);
336
+ return;
337
+ }
338
+ const targetIndex = traversableItems.findIndex((item) => item === target);
339
+ this.setActiveItemByIndex(targetIndex);
340
+ await this.scrollActiveItemIntoView(target);
341
+ }
342
+ syncActiveItemFromTraversableItems() {
343
+ const traversableItems = this.getTraversableItems();
344
+ if (!traversableItems.length) {
345
+ this.setActiveItemByIndex(-1);
346
+ return;
347
+ }
348
+ if (this.activeItemIndex < 0 || this.activeItemIndex >= traversableItems.length) {
349
+ this.setActiveItemByIndex(0);
350
+ return;
351
+ }
352
+ this.updateActiveDescendantElement(traversableItems[this.activeItemIndex]);
353
+ }
354
+ setActiveItemByIndex(index) {
355
+ this.activeItemIndex = index;
356
+ const traversableItems = this.getTraversableItems();
357
+ const activeItem = index >= 0 ? traversableItems[index] : null;
358
+ this.updateActiveDescendantElement(activeItem);
359
+ }
360
+ updateActiveDescendantElement(activeItem) {
361
+ this.items.forEach((item) => {
362
+ item.activeDescendant = item === activeItem;
363
+ });
364
+ this.activeDescendantElement = activeItem ?? null;
365
+ }
366
+ navigateActiveItem(direction) {
367
+ const traversableItems = this.getTraversableItems();
368
+ if (!traversableItems.length) {
369
+ return;
370
+ }
371
+ const totalItems = traversableItems.length;
372
+ let index = this.activeItemIndex;
373
+ if (index < 0 || index >= totalItems) {
374
+ index = direction === "previous" || direction === "last" ? totalItems - 1 : 0;
375
+ } else if (direction === "next") {
376
+ index = (index + 1) % totalItems;
377
+ } else if (direction === "previous") {
378
+ index = (index - 1 + totalItems) % totalItems;
379
+ } else if (direction === "first") {
380
+ index = 0;
381
+ } else if (direction === "last") {
382
+ index = totalItems - 1;
383
+ }
384
+ const activeItem = traversableItems[index];
385
+ this.setActiveItemByIndex(index);
386
+ void this.scrollActiveItemIntoView(activeItem);
387
+ }
388
+ async scrollActiveItemIntoView(target) {
349
389
  if (!target) {
350
390
  return;
351
391
  }
352
392
  await this.updateComplete;
353
393
  await nextFrame();
354
394
  await nextFrame();
355
- await focusElement(target);
356
395
  target.scrollIntoView({ block: "nearest" });
357
396
  }
358
- toggleDropdown() {
359
- this.open = !this.open;
397
+ activateActiveItem() {
398
+ const traversableItems = this.getTraversableItems();
399
+ const activeItem = traversableItems[this.activeItemIndex] || traversableItems[0];
400
+ if (!activeItem) {
401
+ return;
402
+ }
403
+ this.setActiveItemByIndex(traversableItems.findIndex((item) => item === activeItem));
404
+ activeItem.activateItem();
360
405
  }
361
- updateTabIndexOfItems(target) {
362
- this.items.forEach((item) => {
363
- item.tabIndex = target !== item ? -1 : 0;
364
- });
406
+ openHoverDropdown() {
407
+ if (this.open || this.disabled || this.type !== "hover") {
408
+ return;
409
+ }
410
+ this.open = true;
411
+ }
412
+ closeHoverDropdown(event) {
413
+ if (!this.open || this.disabled || this.type !== "hover") {
414
+ return;
415
+ }
416
+ const relatedTarget = event.relatedTarget;
417
+ if (relatedTarget && (this.el.contains(relatedTarget) || this.referenceEl != null && this.referenceEl.contains(relatedTarget))) {
418
+ return;
419
+ }
420
+ this.closeCalciteDropdown();
421
+ }
422
+ toggleClickDropdown() {
423
+ if (this.disabled || this.type !== "click") {
424
+ return;
425
+ }
426
+ this.open = !this.open;
365
427
  }
366
428
  render() {
367
- const { open, guid: guid2 } = this;
368
- return this.interactiveContainer({ disabled: this.disabled, children: html`<div class=${safeClassMap(CSS.triggerContainer)} id=${IDS.menuButton(guid2) ?? nothing} @click=${this.toggleDropdown} @keydown=${this.keyDownHandler} ${ref(this.setReferenceEl)}><slot aria-controls=${IDS.menu(guid2) ?? nothing} .ariaExpanded=${open} aria-haspopup=menu name=${SLOTS.trigger}></slot></div><div .ariaHidden=${!open} class=${safeClassMap({
429
+ const { open } = this;
430
+ return this.interactiveContainer({ disabled: this.disabled, children: html`<div class=${safeClassMap(CSS.triggerContainer)} @click=${this.toggleClickDropdown} @focusin=${this.openHoverDropdown} @focusout=${this.closeHoverDropdown} @keydown=${this.keyDownHandler} ${ref(this.setReferenceEl)}><slot .ariaActiveDescendantElement=${this.activeDescendantElement ?? null} .ariaControlsElements=${this.scrollerEl ? [this.scrollerEl] : void 0} .ariaExpanded=${open} aria-haspopup=menu name=${SLOTS.trigger}></slot></div><div class=${safeClassMap({
369
431
  [CSS.wrapper]: true,
370
432
  [getDimensionClass("width", this.width, this.widthScale)]: !!(this.width || this.widthScale)
371
- })} popover=manual ${ref(this.setFloatingEl)}><div aria-labelledby=${IDS.menuButton(guid2) ?? nothing} class=${safeClassMap({
433
+ })} .inert=${!open} popover=manual ${ref(this.setFloatingEl)}><div .ariaLabelledByElements=${this.referenceEl ? [this.referenceEl] : void 0} class=${safeClassMap({
372
434
  [CSS.content]: true,
373
435
  [FloatingCSS.animation]: true,
374
436
  [FloatingCSS.animationActive]: open
375
- })} id=${IDS.menu(guid2) ?? nothing} role=menu ${ref(this.setScrollerAndTransitionEl)}><slot @slotchange=${this.updateGroups}></slot></div></div>` });
437
+ })} role=menu ${ref(this.setScrollerAndTransitionEl)}><slot @slotchange=${this.updateGroups}></slot></div></div>` });
376
438
  }
377
439
  }
378
- __decorateClass([
379
- queryAssignedElements({ slot: SLOTS.trigger })
380
- ], Dropdown.prototype, "triggerEls");
381
440
  customElement("calcite-dropdown", Dropdown);
382
441
  export {
383
442
  Dropdown
@@ -8,7 +8,7 @@ import { g as getIconScale } from "../../chunks/component.js";
8
8
  import { u as useSetFocus } from "../../chunks/useSetFocus.js";
9
9
  import { u as useInteractive } from "../../chunks/useInteractive.js";
10
10
  import { C as CSS, I as ICONS } from "../../chunks/resources7.js";
11
- 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:flex;flex-grow:1;align-items:center;outline:2px solid transparent;outline-offset:2px}.container{position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;text-decoration-line:none;color:var(--calcite-dropdown-item-text-color, var(--calcite-color-text-1));text-align:start}.container a{outline:none;position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;text-decoration-line:none;color:var(--calcite-dropdown-item-text-color, var(--calcite-color-text-1))}.content{flex:1 1 auto}.icon{position:relative;opacity:0;transition-timing-function:cubic-bezier(.4,0,.2,1);transform:scale(.9)}.icon--start,.icon--end{--calcite-icon-color: var(--calcite-dropdown-item-text-color, var(--calcite-color-text-3))}:host([scale=s]) .container{padding-block:.25rem;padding-inline:.5rem;font-size:var(--calcite-font-size-relative-sm);line-height:var(--calcite-font-line-height-sm)}:host([scale=s]) .icon,:host([scale=s]) .icon--start{padding-inline-end:var(--calcite-spacing-sm)}:host([scale=s]) .icon--end{padding-inline-start:var(--calcite-spacing-sm)}:host([scale=m]) .container{padding-block:.5rem;padding-inline:.75rem;font-size:var(--calcite-font-size-relative-base);line-height:var(--calcite-font-line-height-base)}:host([scale=m]) .icon,:host([scale=m]) .icon--start{padding-inline-end:var(--calcite-spacing-md)}:host([scale=m]) .icon--end{padding-inline-start:var(--calcite-spacing-md)}:host([scale=l]) .container{padding-block:.625rem;padding-inline:1rem;font-size:var(--calcite-font-size-relative-md);line-height:var(--calcite-font-line-height-md)}:host([scale=l]) .icon,:host([scale=l]) .icon--start{padding-inline-end:var(--calcite-spacing-lg)}:host([scale=l]) .icon--end{padding-inline-start:var(--calcite-spacing-lg)}:host(:focus) .container{text-decoration-line:none;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(:hover:not([disabled])) .container{background-color:var(--calcite-dropdown-item-background-color-hover, var(--calcite-color-foreground-2))}:host(:active:not([disabled])) .container{background-color:var(--calcite-dropdown-item-background-color-press, var(--calcite-color-foreground-3))}:host(:hover:not([disabled])) .container,:host(:active:not([disabled])) .container{text-decoration-line:none;color:var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1))}:host(:hover:not([disabled])) .icon--start,:host(:hover:not([disabled])) .icon--end,:host(:active:not([disabled])) .icon--start,:host(:active:not([disabled])) .icon--end{--calcite-icon-color: var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1))}:host(:hover:not([disabled])) .link,:host(:active:not([disabled])) .link{color:var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1))}:host([selected]) .container:not(.container--none-selection),:host([selected]) .link{font-weight:var(--calcite-font-weight-medium);--calcite-internal-dropdown-item-text-color: var( --calcite-dropdown-item-text-color-press, var(--calcite-color-text-1) );color:var(--calcite-internal-dropdown-item-text-color)}:host([selected]) .container:not(.container--none-selection) .icon,:host([selected]) .link .icon{--calcite-icon-color: var(--calcite-dropdown-item-icon-color-press, var(--calcite-color-brand))}:host([selected]) .container:not(.container--none-selection) .icon--start,:host([selected]) .container:not(.container--none-selection) .icon--end,:host([selected]) .link .icon--start,:host([selected]) .link .icon--end{--calcite-icon-color: var(--calcite-internal-dropdown-item-text-color)}:host(:hover:not([disabled])) .icon{--calcite-icon-color: var(--calcite-dropdown-item-icon-color-hover)}:host([selected]) .icon{opacity:1}:host([hidden]){display:none}[hidden]{display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}`;
11
+ 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:flex;flex-grow:1;align-items:center;outline:2px solid transparent;outline-offset:2px}.container{position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;text-decoration-line:none;color:var(--calcite-dropdown-item-text-color, var(--calcite-color-text-1));text-align:start}.container a{outline:none;position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;text-decoration-line:none;color:var(--calcite-dropdown-item-text-color, var(--calcite-color-text-1))}.content{flex:1 1 auto}.icon{position:relative;opacity:0;transition-timing-function:cubic-bezier(.4,0,.2,1);transform:scale(.9)}.icon--start,.icon--end{--calcite-icon-color: var(--calcite-dropdown-item-text-color, var(--calcite-color-text-3))}:host([scale=s]) .container{padding-block:.25rem;padding-inline:.5rem;font-size:var(--calcite-font-size-relative-sm);line-height:var(--calcite-font-line-height-sm)}:host([scale=s]) .icon,:host([scale=s]) .icon--start{padding-inline-end:var(--calcite-spacing-sm)}:host([scale=s]) .icon--end{padding-inline-start:var(--calcite-spacing-sm)}:host([scale=m]) .container{padding-block:.5rem;padding-inline:.75rem;font-size:var(--calcite-font-size-relative-base);line-height:var(--calcite-font-line-height-base)}:host([scale=m]) .icon,:host([scale=m]) .icon--start{padding-inline-end:var(--calcite-spacing-md)}:host([scale=m]) .icon--end{padding-inline-start:var(--calcite-spacing-md)}:host([scale=l]) .container{padding-block:.625rem;padding-inline:1rem;font-size:var(--calcite-font-size-relative-md);line-height:var(--calcite-font-line-height-md)}:host([scale=l]) .icon,:host([scale=l]) .icon--start{padding-inline-end:var(--calcite-spacing-lg)}:host([scale=l]) .icon--end{padding-inline-start:var(--calcite-spacing-lg)}:host(:focus) .container,:host([active-descendant]) .container{text-decoration-line:none;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(:hover:not([disabled])) .container{background-color:var(--calcite-dropdown-item-background-color-hover, var(--calcite-color-foreground-2))}:host(:active:not([disabled])) .container{background-color:var(--calcite-dropdown-item-background-color-press, var(--calcite-color-foreground-3))}:host(:hover:not([disabled])) .container,:host(:active:not([disabled])) .container{text-decoration-line:none;color:var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1))}:host(:hover:not([disabled])) .icon--start,:host(:hover:not([disabled])) .icon--end,:host(:active:not([disabled])) .icon--start,:host(:active:not([disabled])) .icon--end{--calcite-icon-color: var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1))}:host(:hover:not([disabled])) .link,:host(:active:not([disabled])) .link{color:var(--calcite-dropdown-item-text-color-press, var(--calcite-color-text-1))}:host([selected]) .container:not(.container--none-selection),:host([selected]) .link{font-weight:var(--calcite-font-weight-medium);--calcite-internal-dropdown-item-text-color: var( --calcite-dropdown-item-text-color-press, var(--calcite-color-text-1) );color:var(--calcite-internal-dropdown-item-text-color)}:host([selected]) .container:not(.container--none-selection) .icon,:host([selected]) .link .icon{--calcite-icon-color: var(--calcite-dropdown-item-icon-color-press, var(--calcite-color-brand))}:host([selected]) .container:not(.container--none-selection) .icon--start,:host([selected]) .container:not(.container--none-selection) .icon--end,:host([selected]) .link .icon--start,:host([selected]) .link .icon--end{--calcite-icon-color: var(--calcite-internal-dropdown-item-text-color)}:host(:hover:not([disabled])) .icon{--calcite-icon-color: var(--calcite-dropdown-item-icon-color-hover)}:host([selected]) .icon{opacity:1}:host([hidden]){display:none}[hidden]{display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}`;
12
12
  class DropdownItem extends LitElement {
13
13
  constructor() {
14
14
  super();
@@ -16,19 +16,17 @@ class DropdownItem extends LitElement {
16
16
  this.focusSetter = useSetFocus()(this);
17
17
  this.interactiveContainer = useInteractive(this);
18
18
  this.disabled = false;
19
+ this.activeDescendant = false;
19
20
  this.scale = "m";
20
21
  this.selected = false;
21
22
  this.selectionMode = "single";
22
23
  this.calciteDropdownItemSelect = createEvent({ cancelable: false });
23
- this.calciteInternalDropdownCloseRequest = createEvent({ cancelable: false });
24
- this.calciteInternalDropdownItemKeyEvent = createEvent({ cancelable: false });
25
24
  this.calciteInternalDropdownItemSelect = createEvent({ cancelable: false });
26
25
  this.listen("click", this.onClick);
27
- this.listen("keydown", this.keyDownHandler);
28
26
  this.listenOn(document.body, "calciteInternalDropdownItemChange", this.updateActiveItemOnChange);
29
27
  }
30
28
  static {
31
- this.properties = { disabled: [7, {}, { reflect: true, type: Boolean }], href: [3, {}, { reflect: true }], iconEnd: [3, { type: String }, { reflect: true }], iconFlipRtl: [3, {}, { reflect: true }], iconStart: [3, { type: String }, { reflect: true }], label: 1, rel: [3, {}, { reflect: true }], scale: [3, {}, { reflect: true }], selected: [7, {}, { reflect: true, type: Boolean }], selectionMode: 1, target: [3, {}, { reflect: true }] };
29
+ this.properties = { disabled: [7, {}, { reflect: true, type: Boolean }], activeDescendant: [7, {}, { reflect: true, type: Boolean }], href: [3, {}, { reflect: true }], iconEnd: [3, { type: String }, { reflect: true }], iconFlipRtl: [3, {}, { reflect: true }], iconStart: [3, { type: String }, { reflect: true }], label: 1, rel: [3, {}, { reflect: true }], scale: [3, {}, { reflect: true }], selected: [7, {}, { reflect: true, type: Boolean }], selectionMode: 1, target: [3, {}, { reflect: true }] };
32
30
  }
33
31
  static {
34
32
  this.styles = styles;
@@ -36,6 +34,16 @@ class DropdownItem extends LitElement {
36
34
  async setFocus(options) {
37
35
  return this.focusSetter(() => this.el, options);
38
36
  }
37
+ async activateItem() {
38
+ if (this.disabled) {
39
+ return;
40
+ }
41
+ if (this.href) {
42
+ this.childLinkRef.value?.click();
43
+ return;
44
+ }
45
+ this.emitRequestedItem();
46
+ }
39
47
  connectedCallback() {
40
48
  super.connectedCallback();
41
49
  this.initialize();
@@ -46,32 +54,6 @@ class DropdownItem extends LitElement {
46
54
  onClick() {
47
55
  this.emitRequestedItem();
48
56
  }
49
- keyDownHandler(event) {
50
- switch (event.key) {
51
- case " ":
52
- case "Enter":
53
- this.emitRequestedItem();
54
- if (this.href) {
55
- this.childLinkRef.value.click();
56
- }
57
- event.preventDefault();
58
- break;
59
- case "Escape":
60
- this.calciteInternalDropdownCloseRequest.emit();
61
- event.preventDefault();
62
- break;
63
- case "Tab":
64
- this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
65
- break;
66
- case "ArrowUp":
67
- case "ArrowDown":
68
- case "Home":
69
- case "End":
70
- event.preventDefault();
71
- this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
72
- break;
73
- }
74
- }
75
57
  updateActiveItemOnChange(event) {
76
58
  const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
77
59
  if (parentEmittedChange) {
@@ -126,7 +108,7 @@ class DropdownItem extends LitElement {
126
108
  this.el.ariaChecked = itemAria;
127
109
  this.el.ariaLabel = !href ? label : "";
128
110
  this.el.role = itemRole;
129
- setAttribute(this.el, "tabIndex", disabled ? -1 : 0);
111
+ setAttribute(this.el, "tabIndex", -1);
130
112
  return this.interactiveContainer({ disabled, children: html`<div class=${safeClassMap({
131
113
  [CSS.container]: true,
132
114
  [CSS.containerNone]: selectionMode === "none"