frontile 0.18.6 → 0.18.8

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 (204) hide show
  1. package/declarations/-private/icons.d.ts +4 -0
  2. package/declarations/-private/icons.d.ts.map +1 -1
  3. package/declarations/components/buttons/chip.d.ts +2 -3
  4. package/declarations/components/buttons/chip.d.ts.map +1 -1
  5. package/declarations/components/collections/dropdown/dropdown.d.ts +50 -53
  6. package/declarations/components/collections/dropdown/dropdown.d.ts.map +1 -1
  7. package/declarations/components/collections/listbox/item.d.ts +52 -1
  8. package/declarations/components/collections/listbox/item.d.ts.map +1 -1
  9. package/declarations/components/forms/form.d.ts +3 -2
  10. package/declarations/components/forms/form.d.ts.map +1 -1
  11. package/declarations/components/forms/native-select.d.ts.map +1 -1
  12. package/declarations/components/forms/select/select.d.ts +17 -0
  13. package/declarations/components/forms/select/select.d.ts.map +1 -1
  14. package/declarations/components/forms/select/trigger.d.ts +8 -0
  15. package/declarations/components/forms/select/trigger.d.ts.map +1 -1
  16. package/declarations/components/forms/select/types.d.ts +8 -4
  17. package/declarations/components/forms/select/types.d.ts.map +1 -1
  18. package/declarations/components/layout/app-layout-state.d.ts +32 -0
  19. package/declarations/components/layout/app-layout-state.d.ts.map +1 -0
  20. package/declarations/components/layout/app-layout.d.ts +1298 -0
  21. package/declarations/components/layout/app-layout.d.ts.map +1 -0
  22. package/declarations/components/layout/aside-toggle.d.ts +55 -0
  23. package/declarations/components/layout/aside-toggle.d.ts.map +1 -0
  24. package/declarations/components/layout/aside.d.ts +1055 -0
  25. package/declarations/components/layout/aside.d.ts.map +1 -0
  26. package/declarations/components/layout/bottom-nav-more.d.ts +123 -0
  27. package/declarations/components/layout/bottom-nav-more.d.ts.map +1 -0
  28. package/declarations/components/layout/bottom-nav.d.ts +60 -0
  29. package/declarations/components/layout/bottom-nav.d.ts.map +1 -0
  30. package/declarations/components/layout/context.d.ts +143 -0
  31. package/declarations/components/layout/context.d.ts.map +1 -0
  32. package/declarations/components/layout/index.d.ts +14 -0
  33. package/declarations/components/layout/index.d.ts.map +1 -0
  34. package/declarations/components/layout/main.d.ts +28 -0
  35. package/declarations/components/layout/main.d.ts.map +1 -0
  36. package/declarations/components/layout/menu-toggle.d.ts +58 -0
  37. package/declarations/components/layout/menu-toggle.d.ts.map +1 -0
  38. package/declarations/components/layout/nav-context.d.ts +45 -0
  39. package/declarations/components/layout/nav-context.d.ts.map +1 -0
  40. package/declarations/components/layout/nav-folder.d.ts +216 -0
  41. package/declarations/components/layout/nav-folder.d.ts.map +1 -0
  42. package/declarations/components/layout/nav-item.d.ts +220 -0
  43. package/declarations/components/layout/nav-item.d.ts.map +1 -0
  44. package/declarations/components/layout/nav-link.d.ts +67 -0
  45. package/declarations/components/layout/nav-link.d.ts.map +1 -0
  46. package/declarations/components/layout/navbar.d.ts +1028 -0
  47. package/declarations/components/layout/navbar.d.ts.map +1 -0
  48. package/declarations/components/layout/page-header.d.ts +40 -0
  49. package/declarations/components/layout/page-header.d.ts.map +1 -0
  50. package/declarations/components/layout/sidebar-group.d.ts +41 -0
  51. package/declarations/components/layout/sidebar-group.d.ts.map +1 -0
  52. package/declarations/components/layout/sidebar-toggle.d.ts +71 -0
  53. package/declarations/components/layout/sidebar-toggle.d.ts.map +1 -0
  54. package/declarations/components/layout/sidebar.d.ts +1215 -0
  55. package/declarations/components/layout/sidebar.d.ts.map +1 -0
  56. package/declarations/components/navigation/index.d.ts +1 -0
  57. package/declarations/components/navigation/index.d.ts.map +1 -1
  58. package/declarations/components/navigation/stepper/collapse-menu.d.ts +42 -0
  59. package/declarations/components/navigation/stepper/collapse-menu.d.ts.map +1 -0
  60. package/declarations/components/navigation/stepper/list.d.ts +24 -0
  61. package/declarations/components/navigation/stepper/list.d.ts.map +1 -0
  62. package/declarations/components/navigation/stepper/panel.d.ts +42 -0
  63. package/declarations/components/navigation/stepper/panel.d.ts.map +1 -0
  64. package/declarations/components/navigation/stepper/step.d.ts +123 -0
  65. package/declarations/components/navigation/stepper/step.d.ts.map +1 -0
  66. package/declarations/components/navigation/stepper/stepper.d.ts +947 -0
  67. package/declarations/components/navigation/stepper/stepper.d.ts.map +1 -0
  68. package/declarations/components/navigation/stepper.d.ts +6 -0
  69. package/declarations/components/navigation/stepper.d.ts.map +1 -0
  70. package/declarations/components/navigation/tab-nav/item.d.ts +2 -2
  71. package/declarations/components/navigation/tab-nav/item.d.ts.map +1 -1
  72. package/declarations/components/overlays/portal.d.ts.map +1 -1
  73. package/declarations/components/status/badge.d.ts +83 -0
  74. package/declarations/components/status/badge.d.ts.map +1 -0
  75. package/declarations/components/status/index.d.ts +1 -0
  76. package/declarations/components/status/index.d.ts.map +1 -1
  77. package/declarations/components/utilities/collapsible.d.ts +19 -2
  78. package/declarations/components/utilities/collapsible.d.ts.map +1 -1
  79. package/declarations/index.d.ts +1 -0
  80. package/declarations/index.d.ts.map +1 -1
  81. package/declarations/layout.d.ts +2 -0
  82. package/declarations/layout.d.ts.map +1 -0
  83. package/declarations/utils/breakpoint.d.ts +16 -0
  84. package/declarations/utils/breakpoint.d.ts.map +1 -0
  85. package/declarations/utils/document-listener.d.ts +6 -0
  86. package/declarations/utils/document-listener.d.ts.map +1 -0
  87. package/declarations/utils/listManager.d.ts +7 -1
  88. package/declarations/utils/listManager.d.ts.map +1 -1
  89. package/declarations/utils/route-active.d.ts +34 -0
  90. package/declarations/utils/route-active.d.ts.map +1 -0
  91. package/declarations/utils/selection-indicator.d.ts +7 -4
  92. package/declarations/utils/selection-indicator.d.ts.map +1 -1
  93. package/dist/components/buttons/chip.js +12 -1
  94. package/dist/components/buttons/chip.js.map +1 -1
  95. package/dist/components/collections/calendar/header.js +1 -1
  96. package/dist/components/collections/dropdown/dropdown.js +172 -48
  97. package/dist/components/collections/dropdown/dropdown.js.map +1 -1
  98. package/dist/components/collections/listbox/item.js +36 -2
  99. package/dist/components/collections/listbox/item.js.map +1 -1
  100. package/dist/components/collections/table/column-visibility.js +1 -1
  101. package/dist/components/collections/table/sort-button.js +1 -1
  102. package/dist/components/disclosure/accordion/item.js +1 -1
  103. package/dist/components/forms/autocomplete.js +1 -1
  104. package/dist/components/forms/date-picker/end-content.js +1 -1
  105. package/dist/components/forms/form.js.map +1 -1
  106. package/dist/components/forms/native-select.js +2 -2
  107. package/dist/components/forms/native-select.js.map +1 -1
  108. package/dist/components/forms/select/end-content.js +1 -1
  109. package/dist/components/forms/select/select.js +3 -2
  110. package/dist/components/forms/select/select.js.map +1 -1
  111. package/dist/components/forms/select/trigger.js +1 -1
  112. package/dist/components/forms/select/trigger.js.map +1 -1
  113. package/dist/components/layout/app-layout-state.js +64 -0
  114. package/dist/components/layout/app-layout-state.js.map +1 -0
  115. package/dist/components/layout/app-layout.js +441 -0
  116. package/dist/components/layout/app-layout.js.map +1 -0
  117. package/dist/components/layout/aside-toggle.js +55 -0
  118. package/dist/components/layout/aside-toggle.js.map +1 -0
  119. package/dist/components/layout/aside.js +98 -0
  120. package/dist/components/layout/aside.js.map +1 -0
  121. package/dist/components/layout/bottom-nav-more.js +150 -0
  122. package/dist/components/layout/bottom-nav-more.js.map +1 -0
  123. package/dist/components/layout/bottom-nav.js +65 -0
  124. package/dist/components/layout/bottom-nav.js.map +1 -0
  125. package/dist/components/layout/context.js +103 -0
  126. package/dist/components/layout/context.js.map +1 -0
  127. package/dist/components/layout/index.js +14 -0
  128. package/dist/components/layout/index.js.map +1 -0
  129. package/dist/components/layout/main.js +34 -0
  130. package/dist/components/layout/main.js.map +1 -0
  131. package/dist/components/layout/menu-toggle.js +61 -0
  132. package/dist/components/layout/menu-toggle.js.map +1 -0
  133. package/dist/components/layout/nav-context.js +85 -0
  134. package/dist/components/layout/nav-context.js.map +1 -0
  135. package/dist/components/layout/nav-folder.js +271 -0
  136. package/dist/components/layout/nav-folder.js.map +1 -0
  137. package/dist/components/layout/nav-item.js +192 -0
  138. package/dist/components/layout/nav-item.js.map +1 -0
  139. package/dist/components/layout/nav-link.js +58 -0
  140. package/dist/components/layout/nav-link.js.map +1 -0
  141. package/dist/components/layout/navbar.js +51 -0
  142. package/dist/components/layout/navbar.js.map +1 -0
  143. package/dist/components/layout/page-header.js +45 -0
  144. package/dist/components/layout/page-header.js.map +1 -0
  145. package/dist/components/layout/sidebar-group.js +41 -0
  146. package/dist/components/layout/sidebar-group.js.map +1 -0
  147. package/dist/components/layout/sidebar-toggle.js +82 -0
  148. package/dist/components/layout/sidebar-toggle.js.map +1 -0
  149. package/dist/components/layout/sidebar.js +252 -0
  150. package/dist/components/layout/sidebar.js.map +1 -0
  151. package/dist/components/navigation/breadcrumbs/separator.js +1 -1
  152. package/dist/components/navigation/index.js +4 -0
  153. package/dist/components/navigation/index.js.map +1 -1
  154. package/dist/components/navigation/pagination/pagination.js +1 -1
  155. package/dist/components/navigation/stepper/collapse-menu.js +128 -0
  156. package/dist/components/navigation/stepper/collapse-menu.js.map +1 -0
  157. package/dist/components/navigation/stepper/list.js +17 -0
  158. package/dist/components/navigation/stepper/list.js.map +1 -0
  159. package/dist/components/navigation/stepper/panel.js +26 -0
  160. package/dist/components/navigation/stepper/panel.js.map +1 -0
  161. package/dist/components/navigation/stepper/step.js +130 -0
  162. package/dist/components/navigation/stepper/step.js.map +1 -0
  163. package/dist/components/navigation/stepper/stepper.js +475 -0
  164. package/dist/components/navigation/stepper/stepper.js.map +1 -0
  165. package/dist/components/navigation/stepper.js +5 -0
  166. package/dist/components/navigation/stepper.js.map +1 -0
  167. package/dist/components/navigation/tab-nav/item.js +6 -40
  168. package/dist/components/navigation/tab-nav/item.js.map +1 -1
  169. package/dist/components/notifications/index.js +1 -1
  170. package/dist/components/notifications/notification-card.js +2 -2
  171. package/dist/components/notifications/notifications-container.js +1 -1
  172. package/dist/components/overlays/portal.js +11 -2
  173. package/dist/components/overlays/portal.js.map +1 -1
  174. package/dist/components/status/alert.js +1 -1
  175. package/dist/components/status/badge.js +52 -0
  176. package/dist/components/status/badge.js.map +1 -0
  177. package/dist/components/status/index.js +1 -0
  178. package/dist/components/status/index.js.map +1 -1
  179. package/dist/components/utilities/collapsible.js +33 -5
  180. package/dist/components/utilities/collapsible.js.map +1 -1
  181. package/dist/{icons-DZ61nCzv.js → icons-55dthVFk.js} +14 -2
  182. package/dist/{icons-DZ61nCzv.js.map → icons-55dthVFk.js.map} +1 -1
  183. package/dist/index.js +19 -1
  184. package/dist/index.js.map +1 -1
  185. package/dist/layout.js +14 -0
  186. package/dist/layout.js.map +1 -0
  187. package/dist/navigation.js +4 -0
  188. package/dist/navigation.js.map +1 -1
  189. package/dist/{notification-card-dz-eE6z9.js → notification-card-BPfDo-Gf.js} +2 -2
  190. package/dist/{notification-card-dz-eE6z9.js.map → notification-card-BPfDo-Gf.js.map} +1 -1
  191. package/dist/notifications.js +1 -1
  192. package/dist/status.js +1 -0
  193. package/dist/status.js.map +1 -1
  194. package/dist/utils/breakpoint.js +56 -0
  195. package/dist/utils/breakpoint.js.map +1 -0
  196. package/dist/utils/document-listener.js +10 -0
  197. package/dist/utils/document-listener.js.map +1 -0
  198. package/dist/utils/listManager.js +12 -2
  199. package/dist/utils/listManager.js.map +1 -1
  200. package/dist/utils/route-active.js +70 -0
  201. package/dist/utils/route-active.js.map +1 -0
  202. package/dist/utils/selection-indicator.js +25 -5
  203. package/dist/utils/selection-indicator.js.map +1 -1
  204. package/package.json +7 -3
@@ -6,6 +6,8 @@ import { Popover } from '../../overlays/popover.js';
6
6
  import { assert } from '@ember/debug';
7
7
  import { hash } from '@ember/helper';
8
8
  import { on } from '@ember/modifier';
9
+ import { registerDestructor } from '@ember/destroyable';
10
+ import Modifier from 'ember-modifier';
9
11
  import { Sub } from './sub.js';
10
12
  import { createOverriddenMenuContext, createRootMenuContext } from './menu-context.js';
11
13
  import { r as renamedArgValue } from '../../../deprecated-args-BIUjLA8y.js';
@@ -39,10 +41,11 @@ class Dropdown extends Component {
39
41
  }
40
42
  };
41
43
  static {
42
- setComponentTemplate(precompileTemplate("<Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} as |p|>\n {{yield (hash Trigger=(component Trigger anchor=p.anchor trigger=p.trigger toggle=p.toggle setOpenSource=this.setOpenSource) Menu=(component Menu Content=p.Content toggle=p.toggle close=p.close closeOnItemSelect=@closeOnItemSelect openSource=this.openSource))}}\n</Popover>", {
44
+ setComponentTemplate(precompileTemplate("<Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} @isOpen={{@isOpen}} @onOpenChange={{@onOpenChange}} as |p|>\n {{#let (modifier TriggerBehavior anchor=p.anchor trigger=p.trigger open=p.open toggle=p.toggle setOpenSource=this.setOpenSource) as |triggerModifier|}}\n {{yield (hash Trigger=(component Trigger triggerModifier=triggerModifier) triggerModifier=triggerModifier Menu=(component Menu Content=p.Content toggle=p.toggle close=p.close closeOnItemSelect=@closeOnItemSelect openSource=this.openSource))}}\n {{/let}}\n</Popover>", {
43
45
  strictMode: true,
44
46
  scope: () => ({
45
47
  Popover,
48
+ TriggerBehavior,
46
49
  hash,
47
50
  Trigger,
48
51
  Menu
@@ -50,57 +53,142 @@ class Dropdown extends Component {
50
53
  }), this);
51
54
  }
52
55
  }
53
- class Trigger extends Component {
54
- get anchor() {
55
- assert(`Dropdown Trigger does not have anchor modifier; Missing argument @anchor`, this.args.anchor);
56
- return this.args.anchor;
57
- }
58
- get trigger() {
59
- assert(`Dropdown Trigger does not have trigger modifier; Missing argument @trigger`, this.args.trigger);
60
- return this.args.trigger;
61
- }
62
- handleKeyDown = event => {
63
- if (['ArrowUp', 'ArrowDown'].includes(event.key)) {
64
- event.preventDefault();
56
+ /**
57
+ * The public shape of the modifier `Dropdown` yields as `triggerModifier`.
58
+ */
59
+
60
+ /**
61
+ * Everything that makes an element a dropdown trigger, in one place, so a
62
+ * `Trigger` button and a consumer's own element behave identically.
63
+ *
64
+ * It installs Popover's `anchor` and `trigger` modifiers by calling them. Both
65
+ * are function-based `ember-modifier`s, and `modifier(fn)` hands back `fn`
66
+ * itself (with a manager attached), so they are callable as
67
+ * `(element, positional, named) => cleanup`. Glimmer has no way to apply two
68
+ * modifiers from one, and the alternative -- yielding both and making every
69
+ * consumer apply them together with the key handlers -- is the very thing this
70
+ * exists to avoid. If either stops being a plain function the assert below
71
+ * fails loudly instead of the trigger silently doing nothing.
72
+ *
73
+ * The class form is deliberate. Popover's `trigger` reads `isOpen`, so this
74
+ * modifier re-runs on every open and close; a class instance keeps the key and
75
+ * pointer listeners and the `anchor` call (which writes tracked state, and
76
+ * would re-position the menu if repeated) once per element, and only re-runs
77
+ * `trigger`, whose cleanup it owns.
78
+ */
79
+ class TriggerBehavior extends Modifier {
80
+ #element;
81
+ #cleanupTrigger;
82
+ #removeListeners;
83
+ #destructorRegistered = false;
84
+ modify(element, _positional, {
85
+ anchor,
86
+ trigger,
87
+ open,
88
+ toggle,
89
+ setOpenSource
90
+ }) {
91
+ if (!this.#destructorRegistered) {
92
+ this.#destructorRegistered = true;
93
+ registerDestructor(this, () => {
94
+ this.#cleanupTrigger?.();
95
+ this.#removeListeners?.();
96
+ });
65
97
  }
66
- };
67
- /**
68
- * A pointer press opens onto nothing: moving the highlight somewhere the
69
- * user never pointed is exactly what the menu button pattern avoids.
70
- *
71
- * On `pointerup` rather than `pointerdown`: the two are equivalent here
72
- * because `pointerup` still precedes the `click` that Popover's `trigger`
73
- * opens on, and binding the down event trips `no-pointer-down-event-binding`
74
- * -- a rule worth keeping, since a press the user drags away from and
75
- * cancels should leave nothing behind.
76
- */
77
- handlePointerUp = () => {
78
- this.args.setOpenSource('pointer');
79
- };
80
- /**
81
- * Enter and Space have to be handled here rather than left to the button's
82
- * native activation. The trigger renders Frontile's Button, whose `press`
83
- * modifier calls preventDefault on Enter/Space keydown — that is deliberate,
84
- * since press synthesises its own press event for `@onPress` consumers — but
85
- * it also cancels the native click, and Popover's `trigger` modifier opens on
86
- * click. Without this the menu could only be opened with the arrow keys.
87
- *
88
- * Select is unaffected because its trigger is a plain `<button>` with no press
89
- * modifier, so its native click still fires. Handling this in Popover instead
90
- * would double-toggle there.
91
- */
92
- handleKeyUp = event => {
93
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter' || event.key === ' ') {
94
- this.args.setOpenSource('keyboard');
95
- this.args.toggle();
98
+ if (this.#element !== element) {
99
+ this.#removeListeners?.();
100
+ this.#element = element;
101
+ this.#removeListeners = this.#listen(element, open, toggle, setOpenSource);
102
+ this.#call(anchor, element);
96
103
  }
97
- };
104
+ this.#cleanupTrigger?.();
105
+ const cleanup = this.#call(trigger, element);
106
+ this.#cleanupTrigger = typeof cleanup === 'function' ? cleanup : undefined;
107
+ }
108
+ #call(modifier, element) {
109
+ assert('Dropdown could not install its trigger: Popover no longer yields function-based `anchor`/`trigger` modifiers', typeof modifier === 'function');
110
+ return modifier(element, [], {});
111
+ }
112
+ #listen(element, open, toggle, setOpenSource) {
113
+ /**
114
+ * Enter and Space are cancelled here, on both key events, on top of the
115
+ * arrows. Frontile's `Button` already does it for Enter/Space (its `press`
116
+ * modifier), but any other element would not: a `<button>` fires its own
117
+ * click on Enter (keydown) and Space (keyup), which Popover's `trigger`
118
+ * toggles on -- on top of the `keyup` toggle below, so the menu would open
119
+ * and straight away close -- and an `<a href>` would navigate on Enter. The
120
+ * arrows are cancelled so they do not scroll the page.
121
+ */
122
+ const onKeyDown = event => {
123
+ if (['ArrowUp', 'ArrowDown', 'Enter', ' '].includes(event.key)) {
124
+ event.preventDefault();
125
+ }
126
+ // Popover's own keydown handler, which runs after this one, opens the
127
+ // menu on an arrow; say it was the keyboard before it renders, so it
128
+ // opens onto the first item.
129
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
130
+ setOpenSource('keyboard');
131
+ }
132
+ };
133
+ /**
134
+ * Enter and Space have to be handled here rather than left to native
135
+ * activation: `Button`'s `press` modifier cancels the native click on
136
+ * Enter/Space (deliberately -- press synthesises its own press event for
137
+ * `@onPress` consumers), and Popover's `trigger` opens on click. Without
138
+ * this the menu could only be opened with the arrow keys.
139
+ *
140
+ * Select is unaffected because its trigger is a plain `<button>` with no
141
+ * press modifier, so its native click still fires. Handling this in
142
+ * Popover instead would double-toggle there.
143
+ *
144
+ * Space is cancelled again on keyup because Firefox activates a button on
145
+ * Space keyup regardless of what keydown did.
146
+ */
147
+ const onKeyUp = event => {
148
+ if (event.key === 'Enter' || event.key === ' ') {
149
+ event.preventDefault();
150
+ setOpenSource('keyboard');
151
+ toggle();
152
+ } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
153
+ // Only ever opens. The arrow's keydown has usually opened the menu
154
+ // already, and when focus has not moved into it by the keyup (a fast
155
+ // key, a slow render), toggling here would close it again.
156
+ setOpenSource('keyboard');
157
+ open();
158
+ }
159
+ };
160
+ /**
161
+ * A pointer press opens onto nothing: moving the highlight somewhere the
162
+ * user never pointed is exactly what the menu button pattern avoids.
163
+ *
164
+ * On `pointerup` rather than `pointerdown`: the two are equivalent here
165
+ * because `pointerup` still precedes the `click` that Popover's `trigger`
166
+ * opens on, and a press the user drags away from and cancels should leave
167
+ * nothing behind.
168
+ */
169
+ const onPointerUp = () => {
170
+ setOpenSource('pointer');
171
+ };
172
+ element.addEventListener('keydown', onKeyDown);
173
+ element.addEventListener('keyup', onKeyUp);
174
+ element.addEventListener('pointerup', onPointerUp);
175
+ return () => {
176
+ element.removeEventListener('keydown', onKeyDown);
177
+ element.removeEventListener('keyup', onKeyUp);
178
+ element.removeEventListener('pointerup', onPointerUp);
179
+ };
180
+ }
181
+ }
182
+ /**
183
+ * The button form of the trigger: Frontile's `Button` with `triggerModifier`
184
+ * on it, so all of the open/close behaviour lives in one place.
185
+ */
186
+ class Trigger extends Component {
98
187
  static {
99
- setComponentTemplate(precompileTemplate("<Button {{this.trigger}} {{this.anchor}} {{on \"keydown\" this.handleKeyDown}} {{on \"keyup\" this.handleKeyUp}} {{on \"pointerup\" this.handlePointerUp}} @type=\"button\" @variant={{@variant}} @appearance={{@appearance}} @color={{@color}} @intent={{@intent}} @size={{@size}} @class={{@class}} @isInGroup={{@isInGroup}} data-test-id=\"dropdown-trigger\" ...attributes>\n {{yield}}\n</Button>", {
188
+ setComponentTemplate(precompileTemplate("<Button {{@triggerModifier}} @type=\"button\" @variant={{@variant}} @appearance={{@appearance}} @color={{@color}} @intent={{@intent}} @size={{@size}} @class={{@class}} @isInGroup={{@isInGroup}} data-test-id=\"dropdown-trigger\" ...attributes>\n {{yield}}\n</Button>", {
100
189
  strictMode: true,
101
190
  scope: () => ({
102
- Button,
103
- on
191
+ Button
104
192
  })
105
193
  }), this);
106
194
  }
@@ -216,6 +304,20 @@ class Menu extends Component {
216
304
  }
217
305
  };
218
306
  /**
307
+ * A link item is followed by the browser (or `LinkTo`), not selected, so it
308
+ * must skip `onAction` -- but it still dismisses the menu like any other
309
+ * choice, and under the same `closeOnItemSelect` rule.
310
+ */
311
+ onLinkActivate = () => {
312
+ const {
313
+ closeOnItemSelect,
314
+ closeRoot
315
+ } = this.context;
316
+ if (closeOnItemSelect !== false) {
317
+ closeRoot();
318
+ }
319
+ };
320
+ /**
219
321
  * Only the root locks the page scroll. A submenu is a second overlay over
220
322
  * the same interaction; locking again would just churn the reference count.
221
323
  */
@@ -225,6 +327,28 @@ class Menu extends Component {
225
327
  }
226
328
  return this.depth === 0;
227
329
  }
330
+ /**
331
+ * Focus goes into the menu as soon as it renders, not a timer later (focus
332
+ * trap's default `delayInitialFocus`). Until it does, keys still land on
333
+ * the trigger: a quick ArrowDown after Enter would reach the trigger
334
+ * instead of moving through the menu. Nothing needs the delay here: the
335
+ * menu opens on a click, an Enter/Space keyup, or an arrow keydown whose
336
+ * keyup the menu ignores (it acts on keydown).
337
+ *
338
+ * `preventScroll`, because at that moment the menu has not been positioned
339
+ * yet (Velcro places it a promise later): focusing it would scroll the page
340
+ * to where it sits before then, carrying the trigger out of view, which
341
+ * hides the menu (Velcro's `hide`) and drops focus to the body.
342
+ *
343
+ * A consumer's options still win.
344
+ */
345
+ get focusTrapOptions() {
346
+ return {
347
+ delayInitialFocus: false,
348
+ preventScroll: true,
349
+ ...this.args.focusTrapOptions
350
+ };
351
+ }
228
352
  get disableFocusTrap() {
229
353
  if (this.args.disableFocusTrap === true) {
230
354
  return true;
@@ -293,7 +417,7 @@ class Menu extends Component {
293
417
  }
294
418
  };
295
419
  static {
296
- setComponentTemplate(precompileTemplate("<@Content @target={{@target}} @renderInPlace={{@renderInPlace}} @disableFocusTrap={{this.disableFocusTrap}} @blockScroll={{this.blockScroll}} @transitionDuration={{this.context.transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{this.context.disableTransitions}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{@transition}}>\n <Listbox {{on \"keydown\" this.handleArrowKeys}} @allowEmpty={{this.context.allowEmpty}} @variant={{this.context.variant}} @disabledKeys={{this.context.disabledKeys}} @color={{this.context.color}} @shortcutVariant={{this.context.shortcutVariant}} @isKeyboardEventsEnabled={{true}} @onAction={{this.onAction}} @onActiveItemChange={{this.onActiveItemChange}} @onSelectionChange={{this.context.onSelectionChange}} @selectedKeys={{this.context.selectedKeys}} @selectionMode={{if this.context.selectionMode this.context.selectionMode \"none\"}} @type=\"menu\" @autoActivateMode={{this.autoActivateMode}} id={{@menuId}} ...attributes as |l|>\n {{yield (component l.Item) (component Sub item=(component l.Item) menu=Menu parentContext=this.context)}}\n </Listbox>\n</@Content>", {
420
+ setComponentTemplate(precompileTemplate("<@Content @target={{@target}} @renderInPlace={{@renderInPlace}} @disableFocusTrap={{this.disableFocusTrap}} @blockScroll={{this.blockScroll}} @transitionDuration={{this.context.transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{this.context.disableTransitions}} @focusTrapOptions={{this.focusTrapOptions}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{@transition}}>\n <Listbox {{on \"keydown\" this.handleArrowKeys}} @allowEmpty={{this.context.allowEmpty}} @variant={{this.context.variant}} @disabledKeys={{this.context.disabledKeys}} @color={{this.context.color}} @shortcutVariant={{this.context.shortcutVariant}} @isKeyboardEventsEnabled={{true}} @onAction={{this.onAction}} @onActiveItemChange={{this.onActiveItemChange}} @onSelectionChange={{this.context.onSelectionChange}} @selectedKeys={{this.context.selectedKeys}} @selectionMode={{if this.context.selectionMode this.context.selectionMode \"none\"}} @type=\"menu\" @autoActivateMode={{this.autoActivateMode}} id={{@menuId}} ...attributes as |l|>\n {{yield (component l.Item onLinkActivate=this.onLinkActivate) (component Sub item=(component l.Item) menu=Menu parentContext=this.context)}}\n </Listbox>\n</@Content>", {
297
421
  strictMode: true,
298
422
  scope: () => ({
299
423
  Listbox,
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sources":["../../../../src/components/collections/dropdown/dropdown.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { Button, type ButtonSignature } from '../../buttons/button';\nimport { Listbox, type ListboxSignature, type ListItem } from '../listbox';\nimport {\n Popover,\n type PopoverSignature,\n type ContentSignature\n} from '../../overlays/popover';\nimport { assert } from '@ember/debug';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { Sub } from './sub';\nimport {\n createOverriddenMenuContext,\n createRootMenuContext\n} from './menu-context';\nimport type { MenuContext, OpenSource, SubHandle } from './menu-context';\nimport type { ModifierLike } from '@glint/template';\nimport type { ListboxItem } from '../listbox/item';\nimport type { WithBoundArgs } from '@glint/template';\nimport { cached } from '@glimmer/tracking';\nimport { renamedArgValue } from '../../../-private/deprecated-args';\n\ninterface DropdownArgs extends Pick<\n PopoverSignature['Args'],\n | 'placement'\n | 'flipOptions'\n | 'middleware'\n | 'shiftOptions'\n | 'offsetOptions'\n | 'strategy'\n | 'didClose'\n> {\n /**\n * Whether the dropdown should close upon selecting an item.\n *\n * @defaultValue true\n */\n closeOnItemSelect?: boolean;\n}\n\ninterface DropdownSignature {\n Args: DropdownArgs;\n Element: HTMLUListElement;\n Blocks: {\n default: [\n {\n Trigger: WithBoundArgs<\n typeof Trigger,\n 'anchor' | 'toggle' | 'trigger' | 'setOpenSource'\n >;\n Menu: WithBoundArgs<\n typeof Menu,\n 'toggle' | 'close' | 'Content' | 'closeOnItemSelect'\n >;\n }\n ];\n };\n}\n\nclass Dropdown extends Component<DropdownSignature> {\n /**\n * How the menu was last asked to open.\n *\n * The WAI-ARIA menu button pattern opens onto an item when the keyboard\n * opened the menu, and onto nothing when a pointer did -- so the trigger has\n * to tell the menu how it was reached. `Sub` already says this for submenus\n * with `OpenSource`; the root says it the same way rather than inventing a\n * second spelling of the same idea.\n */\n @tracked openSource: OpenSource = 'pointer';\n\n setOpenSource = (source: OpenSource): void => {\n // Only on a real change: Ember's tracked setter dirties its tag\n // unconditionally, and the resting value is already `'pointer'`, so an\n // unguarded write would invalidate this component -- and with it the two\n // curried components it yields -- on every pointer press.\n if (this.openSource !== source) {\n this.openSource = source;\n }\n };\n\n <template>\n <Popover\n @placement={{@placement}}\n @flipOptions={{@flipOptions}}\n @middleware={{@middleware}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n @strategy={{@strategy}}\n @didClose={{@didClose}}\n as |p|\n >\n {{yield\n (hash\n Trigger=(component\n Trigger\n anchor=p.anchor\n trigger=p.trigger\n toggle=p.toggle\n setOpenSource=this.setOpenSource\n )\n Menu=(component\n Menu\n Content=p.Content\n toggle=p.toggle\n close=p.close\n closeOnItemSelect=@closeOnItemSelect\n openSource=this.openSource\n )\n )\n }}\n </Popover>\n </template>\n}\n\ninterface TriggerArgs extends Pick<\n ButtonSignature['Args'],\n 'variant' | 'appearance' | 'color' | 'intent' | 'size' | 'isInGroup' | 'class'\n> {\n /**\n * @internal\n */\n anchor: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * @internal\n */\n trigger: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * @internal\n *\n * Reports how this open was initiated, so the menu can decide whether to\n * land on an item.\n */\n setOpenSource: (source: OpenSource) => void;\n\n /**\n * @internal\n */\n toggle: () => void;\n}\n\nexport interface TriggerSignature {\n Args: TriggerArgs;\n Element: HTMLButtonElement;\n Blocks: {\n default: [];\n };\n}\n\nclass Trigger extends Component<TriggerSignature> {\n get anchor() {\n assert(\n `Dropdown Trigger does not have anchor modifier; Missing argument @anchor`,\n this.args.anchor\n );\n return this.args.anchor;\n }\n get trigger() {\n assert(\n `Dropdown Trigger does not have trigger modifier; Missing argument @trigger`,\n this.args.trigger\n );\n return this.args.trigger;\n }\n\n handleKeyDown = (event: KeyboardEvent) => {\n if (['ArrowUp', 'ArrowDown'].includes(event.key)) {\n event.preventDefault();\n }\n };\n\n /**\n * A pointer press opens onto nothing: moving the highlight somewhere the\n * user never pointed is exactly what the menu button pattern avoids.\n *\n * On `pointerup` rather than `pointerdown`: the two are equivalent here\n * because `pointerup` still precedes the `click` that Popover's `trigger`\n * opens on, and binding the down event trips `no-pointer-down-event-binding`\n * -- a rule worth keeping, since a press the user drags away from and\n * cancels should leave nothing behind.\n */\n handlePointerUp = () => {\n this.args.setOpenSource('pointer');\n };\n\n /**\n * Enter and Space have to be handled here rather than left to the button's\n * native activation. The trigger renders Frontile's Button, whose `press`\n * modifier calls preventDefault on Enter/Space keydown — that is deliberate,\n * since press synthesises its own press event for `@onPress` consumers — but\n * it also cancels the native click, and Popover's `trigger` modifier opens on\n * click. Without this the menu could only be opened with the arrow keys.\n *\n * Select is unaffected because its trigger is a plain `<button>` with no press\n * modifier, so its native click still fires. Handling this in Popover instead\n * would double-toggle there.\n */\n handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === 'ArrowDown' ||\n event.key === 'ArrowUp' ||\n event.key === 'Enter' ||\n event.key === ' '\n ) {\n this.args.setOpenSource('keyboard');\n this.args.toggle();\n }\n };\n\n <template>\n <Button\n {{this.trigger}}\n {{this.anchor}}\n {{on \"keydown\" this.handleKeyDown}}\n {{on \"keyup\" this.handleKeyUp}}\n {{on \"pointerup\" this.handlePointerUp}}\n @type=\"button\"\n @variant={{@variant}}\n @appearance={{@appearance}}\n @color={{@color}}\n @intent={{@intent}}\n @size={{@size}}\n @class={{@class}}\n @isInGroup={{@isInGroup}}\n data-test-id=\"dropdown-trigger\"\n ...attributes\n >\n {{yield}}\n </Button>\n </template>\n}\n\ninterface MenuArgs\n extends\n Pick<\n ListboxSignature<unknown>['Args'],\n | 'variant'\n | 'appearance'\n | 'color'\n | 'intent'\n | 'class'\n | 'selectionMode'\n | 'selectedKeys'\n | 'disabledKeys'\n | 'allowEmpty'\n | 'onSelectionChange'\n | 'shortcutVariant'\n >,\n Pick<\n ContentSignature['Args'],\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'transition'\n > {\n /**\n * @internal\n */\n closeOnItemSelect?: boolean;\n\n /**\n * @internal\n */\n Content: PopoverSignature['Blocks']['default'][0]['Content'];\n\n /**\n * @internal\n *\n * Optional rather than required: the root `Dropdown` binds this, but a\n * `Sub`-rendered `Menu` never does (a submenu is dismissed through `close`,\n * not `toggle` -- see `Sub`'s `Menu=(component @menu ...)` invocation, which\n * has no `toggle=` at all). `closeRoot` below already guards this with a\n * `typeof this.args.toggle === 'function'` check, so this only makes the\n * type match the runtime behavior that was already there; it does not\n * change it. Leaving this required was what made every `Sub`-bound `Menu`\n * require a fully-populated args hash at the type level, even though every\n * other remaining arg is optional.\n */\n toggle?: () => void;\n\n /**\n * Callback when a menu item is selected, receiving that item's `@key`.\n */\n onAction?: (key: string) => void;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n\n /**\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n\n /**\n * @internal\n */\n context?: MenuContext;\n\n /**\n * @internal\n */\n depth?: number;\n\n /**\n * @internal\n */\n menuId?: string;\n\n /**\n * @internal\n *\n * How this level was reached -- by the root `Trigger` for the root menu, by\n * its `Sub` for a submenu -- so a keyboard open highlights the first row per\n * the WAI-ARIA menu button pattern. Translated by `autoActivateMode` below.\n */\n openSource?: OpenSource;\n\n /**\n * @internal\n */\n autoActivateMode?: 'none' | 'first';\n\n /**\n * @internal\n */\n close?: () => void;\n\n /**\n * Callback when the active (highlighted) row changes.\n */\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n}\n\nexport interface MenuSignature {\n Args: MenuArgs;\n Element: HTMLUListElement;\n Blocks: {\n default: [\n item: WithBoundArgs<typeof ListboxItem, 'manager'>,\n sub: WithBoundArgs<typeof Sub, 'item' | 'menu' | 'parentContext'>\n ];\n };\n}\n\nclass Menu extends Component<MenuSignature> {\n /**\n * The submenus registered at this level. One map for the life of the\n * component: `context` below is a getter, rebuilt on every render, and a map\n * created there would drop every `Sub` that had already registered.\n */\n #subs = new Map<string, SubHandle>();\n\n get depth(): number {\n return this.args.depth ?? 0;\n }\n\n /**\n * Resolved once (`@cached`): `context` is read many times per render, and\n * without caching each read would re-run the deprecation.\n */\n @cached\n get variant() {\n return renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'subtle' } as const,\n {\n component: 'Dropdown',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.dropdown.appearance'\n }\n );\n }\n\n /**\n * Resolved once (`@cached`) and forwarded to the internal `Listbox` as\n * `@color` only -- never `@intent` as well, which would make the inner\n * `Listbox` raise its own deprecation for the same usage.\n */\n @cached\n get color() {\n return renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Dropdown',\n from: 'intent',\n to: 'color',\n id: 'frontile.dropdown.intent'\n }\n );\n }\n\n /**\n * A submenu is handed its level's context by the `Sub` that renders it. The\n * root builds its own, from the arguments the consumer wrote once.\n *\n * A submenu inherits that context, but may override any part of it with its\n * own arguments -- so a navigation menu can hold a multi-select submenu\n * without the root pretending to select, which is the shape every faceted\n * filter menu needs. Inheritance remains the default: a submenu that\n * declares nothing keeps using the root's settings, and is handed the\n * parent's own context object back untouched.\n *\n * Resolved once (`@cached`) for the same reason `variant` is: `context` is\n * read a dozen times per render, and the overriding branch below builds a\n * new object each time it runs. Without the cache every read produced a\n * fresh identity, which `Sub` then turned into a fresh child context for\n * the level beneath it.\n */\n @cached\n get context(): MenuContext {\n if (this.args.context) {\n return createOverriddenMenuContext(this.args.context, this.args);\n }\n\n return createRootMenuContext({\n close: this.closeRoot,\n subs: this.#subs,\n selectionMode: this.args.selectionMode,\n selectedKeys: this.args.selectedKeys,\n disabledKeys: this.args.disabledKeys,\n allowEmpty: this.args.allowEmpty,\n onAction: this.args.onAction,\n onSelectionChange: this.args.onSelectionChange,\n variant: this.variant,\n color: this.color,\n shortcutVariant: this.args.shortcutVariant,\n closeOnItemSelect: this.args.closeOnItemSelect,\n disableTransitions: this.args.disableTransitions,\n transitionDuration: this.args.transitionDuration\n });\n }\n\n closeRoot = () => {\n if (typeof this.args.close === 'function') {\n this.args.close();\n } else if (typeof this.args.toggle === 'function') {\n this.args.toggle();\n }\n };\n\n onAction = (key: string) => {\n const { onAction, closeOnItemSelect, closeRoot } = this.context;\n\n if (typeof onAction === 'function') {\n onAction(key);\n }\n\n // A leaf three levels down dismisses the whole dropdown, not just its own\n // level -- so this closes the root rather than `closeSelf`.\n if (closeOnItemSelect !== false) {\n closeRoot();\n }\n };\n\n /**\n * Only the root locks the page scroll. A submenu is a second overlay over\n * the same interaction; locking again would just churn the reference count.\n */\n get blockScroll() {\n if (this.args.blockScroll === false) {\n return false;\n }\n return this.depth === 0;\n }\n\n get disableFocusTrap() {\n if (this.args.disableFocusTrap === true) {\n return true;\n }\n return false;\n }\n\n /**\n * The one place an open source becomes an activation mode.\n *\n * Every level is told only how it was reached -- the root by its own\n * trigger, a submenu by its `Sub` -- and decides here, so the WAI-ARIA rule\n * that a keyboard open lands on an item has a single home. A consumer's\n * explicit `@autoActivateMode` outranks it.\n */\n get autoActivateMode(): 'none' | 'first' {\n if (this.args.autoActivateMode) {\n return this.args.autoActivateMode;\n }\n\n return this.args.openSource === 'keyboard' ? 'first' : 'none';\n }\n\n /**\n * The key of the row the arrow keys are currently on.\n *\n * ArrowRight has to open the submenu belonging to the *active* row, and the\n * row itself never learns about the submenu -- so the level tracks which key\n * is active and looks the submenu up in its own registry.\n */\n @tracked activeKey?: string;\n\n /**\n * Chained rather than replaced: a consumer that passed\n * `@onActiveItemChange` still hears about every move.\n */\n onActiveItemChange = (key?: string) => {\n this.activeKey = key;\n\n if (typeof this.args.onActiveItemChange === 'function') {\n this.args.onActiveItemChange(key);\n }\n };\n\n /**\n * ArrowRight and ArrowLeft, which `Listbox` does not handle.\n *\n * There is no \"which level is focused\" bookkeeping to do: every level is its\n * own portaled `Listbox` with its own `<ul tabindex=\"0\">`, and a submenu's\n * portal is a *sibling* of its parent's content element -- so a keypress\n * only ever reaches the level that holds focus.\n */\n handleArrowKeys = (event: KeyboardEvent) => {\n if (event.key === 'ArrowRight') {\n const handle = this.activeKey\n ? this.context.subs.get(this.activeKey)\n : undefined;\n\n if (handle) {\n event.preventDefault();\n event.stopPropagation();\n handle.open('keyboard');\n }\n return;\n }\n\n // The root has no parent to step back to; ArrowLeft there belongs to\n // whatever the consumer put in the row.\n if (event.key === 'ArrowLeft' && this.context.depth > 0) {\n event.preventDefault();\n event.stopPropagation();\n this.context.closeSelf();\n }\n };\n\n <template>\n <@Content\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @disableFocusTrap={{this.disableFocusTrap}}\n @blockScroll={{this.blockScroll}}\n @transitionDuration={{this.context.transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{this.context.disableTransitions}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{@transition}}\n >\n <Listbox\n {{on \"keydown\" this.handleArrowKeys}}\n @allowEmpty={{this.context.allowEmpty}}\n @variant={{this.context.variant}}\n @disabledKeys={{this.context.disabledKeys}}\n @color={{this.context.color}}\n @shortcutVariant={{this.context.shortcutVariant}}\n @isKeyboardEventsEnabled={{true}}\n @onAction={{this.onAction}}\n @onActiveItemChange={{this.onActiveItemChange}}\n @onSelectionChange={{this.context.onSelectionChange}}\n @selectedKeys={{this.context.selectedKeys}}\n @selectionMode={{if\n this.context.selectionMode\n this.context.selectionMode\n \"none\"\n }}\n @type=\"menu\"\n @autoActivateMode={{this.autoActivateMode}}\n id={{@menuId}}\n ...attributes\n as |l|\n >\n {{yield\n (component l.Item)\n (component\n Sub item=(component l.Item) menu=Menu parentContext=this.context\n )\n }}\n </Listbox>\n </@Content>\n </template>\n}\n\nexport { Dropdown, type DropdownSignature, type Menu };\nexport default Dropdown;\n"],"names":["Dropdown","Component","g","prototype","tracked","i","setOpenSource","source","openSource","setComponentTemplate","precompileTemplate","strictMode","scope","Popover","hash","Trigger","Menu","anchor","assert","args","trigger","handleKeyDown","event","includes","key","preventDefault","handlePointerUp","handleKeyUp","toggle","Button","on","Map","depth","variant","renamedArgValue","appearance","default","outlined","faded","component","from","to","id","n","cached","color","intent","context","createOverriddenMenuContext","createRootMenuContext","close","closeRoot","subs","selectionMode","selectedKeys","disabledKeys","allowEmpty","onAction","onSelectionChange","shortcutVariant","closeOnItemSelect","disableTransitions","transitionDuration","blockScroll","disableFocusTrap","autoActivateMode","onActiveItemChange","activeKey","handleArrowKeys","handle","get","undefined","stopPropagation","open","closeSelf","Listbox","Sub"],"mappings":";;;;;;;;;;;;;;;AA6DA,MAAMA,iBAAiBC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAA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AAA;AACd,MAAA;AACA,MAAA;AACF,IAAA;AAEA;AACA;AACA,IAAA,IAAInD,KAAA,CAAME,GAAG,KAAK,WAAA,IAAe,IAAI,CAACuB,OAAO,CAACf,KAAK,GAAG,CAAA,EAAG;MACvDV,KAAA,CAAMG,cAAc,EAAA;MACpBH,KAAA,CAAMkD,eAAe,EAAA;AACrB,MAAA,IAAI,CAACzB,OAAO,CAAC2B,SAAS,EAAA;AACxB,IAAA;EACF,CAAA;AAEA,EAAA;IAAAjE,oBAAA,CAAAC,kBAAA,CAAA,uuCAAA,EA8CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA+D,OAAA;QAAA7C,EAAA;QAAA8C,GAAA;AAAA5D,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"dropdown.js","sources":["../../../../src/components/collections/dropdown/dropdown.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { Button, type ButtonSignature } from '../../buttons/button';\nimport { Listbox, type ListboxSignature, type ListItem } from '../listbox';\nimport {\n Popover,\n type PopoverSignature,\n type ContentSignature\n} from '../../overlays/popover';\nimport { assert } from '@ember/debug';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { registerDestructor } from '@ember/destroyable';\nimport Modifier from 'ember-modifier';\nimport { Sub } from './sub';\nimport {\n createOverriddenMenuContext,\n createRootMenuContext\n} from './menu-context';\nimport type { MenuContext, OpenSource, SubHandle } from './menu-context';\nimport type { ModifierLike } from '@glint/template';\nimport type { ListboxItem } from '../listbox/item';\nimport type { WithBoundArgs } from '@glint/template';\nimport { cached } from '@glimmer/tracking';\nimport { renamedArgValue } from '../../../-private/deprecated-args';\n\ninterface DropdownArgs extends Pick<\n PopoverSignature['Args'],\n | 'placement'\n | 'flipOptions'\n | 'middleware'\n | 'shiftOptions'\n | 'offsetOptions'\n | 'strategy'\n | 'didClose'\n | 'isOpen'\n | 'onOpenChange'\n> {\n /**\n * Whether the dropdown should close upon selecting an item.\n *\n * @defaultValue true\n */\n closeOnItemSelect?: boolean;\n}\n\ninterface DropdownSignature {\n Args: DropdownArgs;\n Element: HTMLUListElement;\n Blocks: {\n default: [\n {\n Trigger: WithBoundArgs<typeof Trigger, 'triggerModifier'>;\n /**\n * Makes the element it is placed on the dropdown's anchor and trigger,\n * wired exactly like `Trigger`: it positions the menu, opens it on\n * click, and opens it onto the first item on ArrowDown, ArrowUp, Enter\n * or Space. Use it to make something other than a `Button` -- a link, a\n * nav item -- the trigger.\n *\n * The element should be focusable and announce itself as a button (a\n * `<button>`, or `role=\"button\"` with `tabindex=\"0\"`). Enter and Space\n * are cancelled on it, so an `<a href>` does not follow its link from\n * the keyboard; a pointer click on one still does (see the docs).\n */\n triggerModifier: TriggerModifier;\n Menu: WithBoundArgs<\n typeof Menu,\n 'toggle' | 'close' | 'Content' | 'closeOnItemSelect'\n >;\n }\n ];\n };\n}\n\nclass Dropdown extends Component<DropdownSignature> {\n /**\n * How the menu was last asked to open.\n *\n * The WAI-ARIA menu button pattern opens onto an item when the keyboard\n * opened the menu, and onto nothing when a pointer did -- so the trigger has\n * to tell the menu how it was reached. `Sub` already says this for submenus\n * with `OpenSource`; the root says it the same way rather than inventing a\n * second spelling of the same idea.\n */\n @tracked openSource: OpenSource = 'pointer';\n\n setOpenSource = (source: OpenSource): void => {\n // Only on a real change: Ember's tracked setter dirties its tag\n // unconditionally, and the resting value is already `'pointer'`, so an\n // unguarded write would invalidate this component -- and with it the two\n // curried components it yields -- on every pointer press.\n if (this.openSource !== source) {\n this.openSource = source;\n }\n };\n\n <template>\n <Popover\n @placement={{@placement}}\n @flipOptions={{@flipOptions}}\n @middleware={{@middleware}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n @strategy={{@strategy}}\n @didClose={{@didClose}}\n @isOpen={{@isOpen}}\n @onOpenChange={{@onOpenChange}}\n as |p|\n >\n {{#let\n (modifier\n TriggerBehavior\n anchor=p.anchor\n trigger=p.trigger\n open=p.open\n toggle=p.toggle\n setOpenSource=this.setOpenSource\n )\n as |triggerModifier|\n }}\n {{yield\n (hash\n Trigger=(component Trigger triggerModifier=triggerModifier)\n triggerModifier=triggerModifier\n Menu=(component\n Menu\n Content=p.Content\n toggle=p.toggle\n close=p.close\n closeOnItemSelect=@closeOnItemSelect\n openSource=this.openSource\n )\n )\n }}\n {{/let}}\n </Popover>\n </template>\n}\n\n/**\n * The public shape of the modifier `Dropdown` yields as `triggerModifier`.\n */\ntype TriggerModifier = ModifierLike<{ Element: HTMLElement }>;\n\ninterface TriggerBehaviorSignature {\n Element: HTMLElement;\n Args: {\n Named: {\n anchor: TriggerModifier;\n trigger: TriggerModifier;\n open: () => void;\n toggle: () => void;\n setOpenSource: (source: OpenSource) => void;\n };\n };\n}\n\n/**\n * Everything that makes an element a dropdown trigger, in one place, so a\n * `Trigger` button and a consumer's own element behave identically.\n *\n * It installs Popover's `anchor` and `trigger` modifiers by calling them. Both\n * are function-based `ember-modifier`s, and `modifier(fn)` hands back `fn`\n * itself (with a manager attached), so they are callable as\n * `(element, positional, named) => cleanup`. Glimmer has no way to apply two\n * modifiers from one, and the alternative -- yielding both and making every\n * consumer apply them together with the key handlers -- is the very thing this\n * exists to avoid. If either stops being a plain function the assert below\n * fails loudly instead of the trigger silently doing nothing.\n *\n * The class form is deliberate. Popover's `trigger` reads `isOpen`, so this\n * modifier re-runs on every open and close; a class instance keeps the key and\n * pointer listeners and the `anchor` call (which writes tracked state, and\n * would re-position the menu if repeated) once per element, and only re-runs\n * `trigger`, whose cleanup it owns.\n */\nclass TriggerBehavior extends Modifier<TriggerBehaviorSignature> {\n #element?: HTMLElement;\n #cleanupTrigger?: () => void;\n #removeListeners?: () => void;\n #destructorRegistered = false;\n\n modify(\n element: HTMLElement,\n _positional: [],\n {\n anchor,\n trigger,\n open,\n toggle,\n setOpenSource\n }: TriggerBehaviorSignature['Args']['Named']\n ) {\n if (!this.#destructorRegistered) {\n this.#destructorRegistered = true;\n registerDestructor(this, () => {\n this.#cleanupTrigger?.();\n this.#removeListeners?.();\n });\n }\n\n if (this.#element !== element) {\n this.#removeListeners?.();\n this.#element = element;\n this.#removeListeners = this.#listen(\n element,\n open,\n toggle,\n setOpenSource\n );\n\n this.#call(anchor, element);\n }\n\n this.#cleanupTrigger?.();\n const cleanup = this.#call(trigger, element);\n this.#cleanupTrigger =\n typeof cleanup === 'function' ? (cleanup as () => void) : undefined;\n }\n\n #call(modifier: TriggerModifier, element: HTMLElement): unknown {\n assert(\n 'Dropdown could not install its trigger: Popover no longer yields function-based `anchor`/`trigger` modifiers',\n typeof modifier === 'function'\n );\n return (\n modifier as unknown as (\n el: HTMLElement,\n positional: unknown[],\n named: Record<string, unknown>\n ) => unknown\n )(element, [], {});\n }\n\n #listen(\n element: HTMLElement,\n open: () => void,\n toggle: () => void,\n setOpenSource: (source: OpenSource) => void\n ): () => void {\n /**\n * Enter and Space are cancelled here, on both key events, on top of the\n * arrows. Frontile's `Button` already does it for Enter/Space (its `press`\n * modifier), but any other element would not: a `<button>` fires its own\n * click on Enter (keydown) and Space (keyup), which Popover's `trigger`\n * toggles on -- on top of the `keyup` toggle below, so the menu would open\n * and straight away close -- and an `<a href>` would navigate on Enter. The\n * arrows are cancelled so they do not scroll the page.\n */\n const onKeyDown = (event: KeyboardEvent) => {\n if (['ArrowUp', 'ArrowDown', 'Enter', ' '].includes(event.key)) {\n event.preventDefault();\n }\n // Popover's own keydown handler, which runs after this one, opens the\n // menu on an arrow; say it was the keyboard before it renders, so it\n // opens onto the first item.\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n setOpenSource('keyboard');\n }\n };\n\n /**\n * Enter and Space have to be handled here rather than left to native\n * activation: `Button`'s `press` modifier cancels the native click on\n * Enter/Space (deliberately -- press synthesises its own press event for\n * `@onPress` consumers), and Popover's `trigger` opens on click. Without\n * this the menu could only be opened with the arrow keys.\n *\n * Select is unaffected because its trigger is a plain `<button>` with no\n * press modifier, so its native click still fires. Handling this in\n * Popover instead would double-toggle there.\n *\n * Space is cancelled again on keyup because Firefox activates a button on\n * Space keyup regardless of what keydown did.\n */\n const onKeyUp = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n setOpenSource('keyboard');\n toggle();\n } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n // Only ever opens. The arrow's keydown has usually opened the menu\n // already, and when focus has not moved into it by the keyup (a fast\n // key, a slow render), toggling here would close it again.\n setOpenSource('keyboard');\n open();\n }\n };\n\n /**\n * A pointer press opens onto nothing: moving the highlight somewhere the\n * user never pointed is exactly what the menu button pattern avoids.\n *\n * On `pointerup` rather than `pointerdown`: the two are equivalent here\n * because `pointerup` still precedes the `click` that Popover's `trigger`\n * opens on, and a press the user drags away from and cancels should leave\n * nothing behind.\n */\n const onPointerUp = () => {\n setOpenSource('pointer');\n };\n\n element.addEventListener('keydown', onKeyDown);\n element.addEventListener('keyup', onKeyUp);\n element.addEventListener('pointerup', onPointerUp);\n\n return () => {\n element.removeEventListener('keydown', onKeyDown);\n element.removeEventListener('keyup', onKeyUp);\n element.removeEventListener('pointerup', onPointerUp);\n };\n }\n}\n\ninterface TriggerArgs extends Pick<\n ButtonSignature['Args'],\n 'variant' | 'appearance' | 'color' | 'intent' | 'size' | 'isInGroup' | 'class'\n> {\n /**\n * @internal\n *\n * The dropdown's own `triggerModifier`, bound by `Dropdown`.\n */\n triggerModifier: TriggerModifier;\n}\n\nexport interface TriggerSignature {\n Args: TriggerArgs;\n Element: HTMLButtonElement;\n Blocks: {\n default: [];\n };\n}\n\n/**\n * The button form of the trigger: Frontile's `Button` with `triggerModifier`\n * on it, so all of the open/close behaviour lives in one place.\n */\nclass Trigger extends Component<TriggerSignature> {\n <template>\n <Button\n {{@triggerModifier}}\n @type=\"button\"\n @variant={{@variant}}\n @appearance={{@appearance}}\n @color={{@color}}\n @intent={{@intent}}\n @size={{@size}}\n @class={{@class}}\n @isInGroup={{@isInGroup}}\n data-test-id=\"dropdown-trigger\"\n ...attributes\n >\n {{yield}}\n </Button>\n </template>\n}\n\ninterface MenuArgs\n extends\n Pick<\n ListboxSignature<unknown>['Args'],\n | 'variant'\n | 'appearance'\n | 'color'\n | 'intent'\n | 'class'\n | 'selectionMode'\n | 'selectedKeys'\n | 'disabledKeys'\n | 'allowEmpty'\n | 'onSelectionChange'\n | 'shortcutVariant'\n >,\n Pick<\n ContentSignature['Args'],\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'transition'\n > {\n /**\n * @internal\n */\n closeOnItemSelect?: boolean;\n\n /**\n * @internal\n */\n Content: PopoverSignature['Blocks']['default'][0]['Content'];\n\n /**\n * @internal\n *\n * Optional rather than required: the root `Dropdown` binds this, but a\n * `Sub`-rendered `Menu` never does (a submenu is dismissed through `close`,\n * not `toggle` -- see `Sub`'s `Menu=(component @menu ...)` invocation, which\n * has no `toggle=` at all). `closeRoot` below already guards this with a\n * `typeof this.args.toggle === 'function'` check, so this only makes the\n * type match the runtime behavior that was already there; it does not\n * change it. Leaving this required was what made every `Sub`-bound `Menu`\n * require a fully-populated args hash at the type level, even though every\n * other remaining arg is optional.\n */\n toggle?: () => void;\n\n /**\n * Callback when a menu item is selected, receiving that item's `@key`.\n */\n onAction?: (key: string) => void;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n\n /**\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n\n /**\n * @internal\n */\n context?: MenuContext;\n\n /**\n * @internal\n */\n depth?: number;\n\n /**\n * @internal\n */\n menuId?: string;\n\n /**\n * @internal\n *\n * How this level was reached -- by the root `Trigger` for the root menu, by\n * its `Sub` for a submenu -- so a keyboard open highlights the first row per\n * the WAI-ARIA menu button pattern. Translated by `autoActivateMode` below.\n */\n openSource?: OpenSource;\n\n /**\n * @internal\n */\n autoActivateMode?: 'none' | 'first';\n\n /**\n * @internal\n */\n close?: () => void;\n\n /**\n * Callback when the active (highlighted) row changes.\n */\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n}\n\nexport interface MenuSignature {\n Args: MenuArgs;\n Element: HTMLUListElement;\n Blocks: {\n default: [\n item: WithBoundArgs<typeof ListboxItem, 'manager' | 'onLinkActivate'>,\n sub: WithBoundArgs<typeof Sub, 'item' | 'menu' | 'parentContext'>\n ];\n };\n}\n\nclass Menu extends Component<MenuSignature> {\n /**\n * The submenus registered at this level. One map for the life of the\n * component: `context` below is a getter, rebuilt on every render, and a map\n * created there would drop every `Sub` that had already registered.\n */\n #subs = new Map<string, SubHandle>();\n\n get depth(): number {\n return this.args.depth ?? 0;\n }\n\n /**\n * Resolved once (`@cached`): `context` is read many times per render, and\n * without caching each read would re-run the deprecation.\n */\n @cached\n get variant() {\n return renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'subtle' } as const,\n {\n component: 'Dropdown',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.dropdown.appearance'\n }\n );\n }\n\n /**\n * Resolved once (`@cached`) and forwarded to the internal `Listbox` as\n * `@color` only -- never `@intent` as well, which would make the inner\n * `Listbox` raise its own deprecation for the same usage.\n */\n @cached\n get color() {\n return renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Dropdown',\n from: 'intent',\n to: 'color',\n id: 'frontile.dropdown.intent'\n }\n );\n }\n\n /**\n * A submenu is handed its level's context by the `Sub` that renders it. The\n * root builds its own, from the arguments the consumer wrote once.\n *\n * A submenu inherits that context, but may override any part of it with its\n * own arguments -- so a navigation menu can hold a multi-select submenu\n * without the root pretending to select, which is the shape every faceted\n * filter menu needs. Inheritance remains the default: a submenu that\n * declares nothing keeps using the root's settings, and is handed the\n * parent's own context object back untouched.\n *\n * Resolved once (`@cached`) for the same reason `variant` is: `context` is\n * read a dozen times per render, and the overriding branch below builds a\n * new object each time it runs. Without the cache every read produced a\n * fresh identity, which `Sub` then turned into a fresh child context for\n * the level beneath it.\n */\n @cached\n get context(): MenuContext {\n if (this.args.context) {\n return createOverriddenMenuContext(this.args.context, this.args);\n }\n\n return createRootMenuContext({\n close: this.closeRoot,\n subs: this.#subs,\n selectionMode: this.args.selectionMode,\n selectedKeys: this.args.selectedKeys,\n disabledKeys: this.args.disabledKeys,\n allowEmpty: this.args.allowEmpty,\n onAction: this.args.onAction,\n onSelectionChange: this.args.onSelectionChange,\n variant: this.variant,\n color: this.color,\n shortcutVariant: this.args.shortcutVariant,\n closeOnItemSelect: this.args.closeOnItemSelect,\n disableTransitions: this.args.disableTransitions,\n transitionDuration: this.args.transitionDuration\n });\n }\n\n closeRoot = () => {\n if (typeof this.args.close === 'function') {\n this.args.close();\n } else if (typeof this.args.toggle === 'function') {\n this.args.toggle();\n }\n };\n\n onAction = (key: string) => {\n const { onAction, closeOnItemSelect, closeRoot } = this.context;\n\n if (typeof onAction === 'function') {\n onAction(key);\n }\n\n // A leaf three levels down dismisses the whole dropdown, not just its own\n // level -- so this closes the root rather than `closeSelf`.\n if (closeOnItemSelect !== false) {\n closeRoot();\n }\n };\n\n /**\n * A link item is followed by the browser (or `LinkTo`), not selected, so it\n * must skip `onAction` -- but it still dismisses the menu like any other\n * choice, and under the same `closeOnItemSelect` rule.\n */\n onLinkActivate = () => {\n const { closeOnItemSelect, closeRoot } = this.context;\n\n if (closeOnItemSelect !== false) {\n closeRoot();\n }\n };\n\n /**\n * Only the root locks the page scroll. A submenu is a second overlay over\n * the same interaction; locking again would just churn the reference count.\n */\n get blockScroll() {\n if (this.args.blockScroll === false) {\n return false;\n }\n return this.depth === 0;\n }\n\n /**\n * Focus goes into the menu as soon as it renders, not a timer later (focus\n * trap's default `delayInitialFocus`). Until it does, keys still land on\n * the trigger: a quick ArrowDown after Enter would reach the trigger\n * instead of moving through the menu. Nothing needs the delay here: the\n * menu opens on a click, an Enter/Space keyup, or an arrow keydown whose\n * keyup the menu ignores (it acts on keydown).\n *\n * `preventScroll`, because at that moment the menu has not been positioned\n * yet (Velcro places it a promise later): focusing it would scroll the page\n * to where it sits before then, carrying the trigger out of view, which\n * hides the menu (Velcro's `hide`) and drops focus to the body.\n *\n * A consumer's options still win.\n */\n get focusTrapOptions(): MenuArgs['focusTrapOptions'] {\n return {\n delayInitialFocus: false,\n preventScroll: true,\n ...this.args.focusTrapOptions\n };\n }\n\n get disableFocusTrap() {\n if (this.args.disableFocusTrap === true) {\n return true;\n }\n return false;\n }\n\n /**\n * The one place an open source becomes an activation mode.\n *\n * Every level is told only how it was reached -- the root by its own\n * trigger, a submenu by its `Sub` -- and decides here, so the WAI-ARIA rule\n * that a keyboard open lands on an item has a single home. A consumer's\n * explicit `@autoActivateMode` outranks it.\n */\n get autoActivateMode(): 'none' | 'first' {\n if (this.args.autoActivateMode) {\n return this.args.autoActivateMode;\n }\n\n return this.args.openSource === 'keyboard' ? 'first' : 'none';\n }\n\n /**\n * The key of the row the arrow keys are currently on.\n *\n * ArrowRight has to open the submenu belonging to the *active* row, and the\n * row itself never learns about the submenu -- so the level tracks which key\n * is active and looks the submenu up in its own registry.\n */\n @tracked activeKey?: string;\n\n /**\n * Chained rather than replaced: a consumer that passed\n * `@onActiveItemChange` still hears about every move.\n */\n onActiveItemChange = (key?: string) => {\n this.activeKey = key;\n\n if (typeof this.args.onActiveItemChange === 'function') {\n this.args.onActiveItemChange(key);\n }\n };\n\n /**\n * ArrowRight and ArrowLeft, which `Listbox` does not handle.\n *\n * There is no \"which level is focused\" bookkeeping to do: every level is its\n * own portaled `Listbox` with its own `<ul tabindex=\"0\">`, and a submenu's\n * portal is a *sibling* of its parent's content element -- so a keypress\n * only ever reaches the level that holds focus.\n */\n handleArrowKeys = (event: KeyboardEvent) => {\n if (event.key === 'ArrowRight') {\n const handle = this.activeKey\n ? this.context.subs.get(this.activeKey)\n : undefined;\n\n if (handle) {\n event.preventDefault();\n event.stopPropagation();\n handle.open('keyboard');\n }\n return;\n }\n\n // The root has no parent to step back to; ArrowLeft there belongs to\n // whatever the consumer put in the row.\n if (event.key === 'ArrowLeft' && this.context.depth > 0) {\n event.preventDefault();\n event.stopPropagation();\n this.context.closeSelf();\n }\n };\n\n <template>\n <@Content\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @disableFocusTrap={{this.disableFocusTrap}}\n @blockScroll={{this.blockScroll}}\n @transitionDuration={{this.context.transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{this.context.disableTransitions}}\n @focusTrapOptions={{this.focusTrapOptions}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{@transition}}\n >\n <Listbox\n {{on \"keydown\" this.handleArrowKeys}}\n @allowEmpty={{this.context.allowEmpty}}\n @variant={{this.context.variant}}\n @disabledKeys={{this.context.disabledKeys}}\n @color={{this.context.color}}\n @shortcutVariant={{this.context.shortcutVariant}}\n @isKeyboardEventsEnabled={{true}}\n @onAction={{this.onAction}}\n @onActiveItemChange={{this.onActiveItemChange}}\n @onSelectionChange={{this.context.onSelectionChange}}\n @selectedKeys={{this.context.selectedKeys}}\n @selectionMode={{if\n this.context.selectionMode\n this.context.selectionMode\n \"none\"\n }}\n @type=\"menu\"\n @autoActivateMode={{this.autoActivateMode}}\n id={{@menuId}}\n ...attributes\n as |l|\n >\n {{yield\n (component l.Item onLinkActivate=this.onLinkActivate)\n (component\n Sub item=(component l.Item) menu=Menu parentContext=this.context\n )\n }}\n </Listbox>\n </@Content>\n </template>\n}\n\nexport { Dropdown, type DropdownSignature, type Menu };\nexport default Dropdown;\n"],"names":["Dropdown","Component","g","prototype","tracked","i","setOpenSource","source","openSource","setComponentTemplate","precompileTemplate","strictMode","scope","Popover","TriggerBehavior","hash","Trigger","Menu","Modifier","modify","element","_positional","anchor","trigger","open","toggle","registerDestructor","cleanup","undefined","#call","modifier","assert","#listen","onKeyDown","event","includes","key","preventDefault","onKeyUp","onPointerUp","addEventListener","removeEventListener","Button","Map","depth","args","variant","renamedArgValue","appearance","default","outlined","faded","component","from","to","id","n","cached","color","intent","context","createOverriddenMenuContext","createRootMenuContext","close","closeRoot","subs","selectionMode","selectedKeys","disabledKeys","allowEmpty","onAction","onSelectionChange","shortcutVariant","closeOnItemSelect","disableTransitions","transitionDuration","onLinkActivate","blockScroll","focusTrapOptions","delayInitialFocus","preventScroll","disableFocusTrap","autoActivateMode","onActiveItemChange","activeKey","handleArrowKeys","handle","get","stopPropagation","closeSelf","Listbox","on","Sub"],"mappings":";;;;;;;;;;;;;;;;;AA2EA,MAAMA,iBAAiBC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CAU9BC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiC,SAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,WAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,YAAA,CAAA,EAAA,MAAA;AATlC;;;;;;;;AAQC;EAGDC,aAAA,GAAiBC,MAAQ,IAAiB;AACxC;AACA;AACA;AACA;AACA,IAAA,IAAI,IAAI,CAACC,UAAU,KAAKD,MAAA,EAAQ;MAC9B,IAAI,CAACC,UAAU,GAAGD,MAAA;AACpB,IAAA;EACF,CAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,urBAAA,EAwCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,OAAA;QAAAC,eAAA;QAAAC,IAAA;QAAAC,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA;;AAEC;;AAgBD;;;;;;;;;;;;;;;;;;;AAmBA,MAAMH,wBAAwBI,QAAA,CAAS;AACrC,EAAA,QAA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AAA;AAEJ,MAAA,IAAI0D,MAAA,EAAQ;QACVpD,KAAA,CAAMG,cAAc,EAAA;QACpBH,KAAA,CAAMsD,eAAe,EAAA;AACrBF,QAAAA,MAAA,CAAO9D,IAAI,CAAC,UAAA,CAAA;AACd,MAAA;AACA,MAAA;AACF,IAAA;AAEA;AACA;AACA,IAAA,IAAIU,KAAA,CAAME,GAAG,KAAK,WAAA,IAAe,IAAI,CAACwB,OAAO,CAAChB,KAAK,GAAG,CAAA,EAAG;MACvDV,KAAA,CAAMG,cAAc,EAAA;MACpBH,KAAA,CAAMsD,eAAe,EAAA;AACrB,MAAA,IAAI,CAAC5B,OAAO,CAAC6B,SAAS,EAAA;AACxB,IAAA;EACF,CAAA;AAEA,EAAA;IAAAhF,oBAAA,CAAAC,kBAAA,CAAA,8wCAAA,EA8CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA8E,OAAA;QAAAC,EAAA;QAAAC,GAAA;AAAA3E,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -7,6 +7,7 @@ import { Divider } from '../../utilities/divider.js';
7
7
  import { Kbd } from '../../utilities/kbd.js';
8
8
  import { guidFor } from '@ember/object/internals';
9
9
  import { r as renamedArgValue } from '../../../deprecated-args-BIUjLA8y.js';
10
+ import { NavLink } from '../../layout/nav-link.js';
10
11
  import { precompileTemplate } from '@ember/template-compilation';
11
12
  import { setComponentTemplate } from '@ember/component';
12
13
  import templateOnly from '@ember/component/template-only';
@@ -32,10 +33,21 @@ class ListboxItem extends Component {
32
33
  onRegister = item => {
33
34
  this.listItem = item;
34
35
  };
35
- onClick = () => {
36
+ /**
37
+ * A link item exists only in a menu. `@type="listbox"` ignores the link
38
+ * args, so Listbox and Select are unchanged.
39
+ */
40
+ get isLink() {
41
+ return this.args.type === 'menu' && Boolean(this.args.href || this.args.route);
42
+ }
43
+ onClick = event => {
36
44
  if (this.listItem?.isDisabled) {
37
45
  return;
38
46
  }
47
+ if (this.isLink) {
48
+ this.activateLink(event);
49
+ return;
50
+ }
39
51
  // Opening a submenu is not choosing anything, so a sub-trigger must not
40
52
  // reach `selectItem` -- that is what fires `onAction` and
41
53
  // `onSelectionChange`. It still registers as an item, so arrow
@@ -48,6 +60,27 @@ class ListboxItem extends Component {
48
60
  }
49
61
  };
50
62
  /**
63
+ * A link item never goes through `selectItem`, which is what fires
64
+ * `onAction` and `onSelectionChange`: following a link is not choosing.
65
+ *
66
+ * A click that did not start on the anchor -- Enter and Space (the listbox
67
+ * clicks the active `li`) or a click on the row's padding -- is forwarded to
68
+ * the anchor, so the browser or `LinkTo` does the navigating. That click
69
+ * bubbles back here with the anchor as its target, and only then does the
70
+ * menu close.
71
+ */
72
+ activateLink(event) {
73
+ const anchor = event.currentTarget.querySelector('a');
74
+ if (anchor && !anchor.contains(event.target)) {
75
+ anchor.click();
76
+ return;
77
+ }
78
+ if (typeof this.args.onClick === 'function') {
79
+ this.args.onClick();
80
+ }
81
+ this.args.onLinkActivate?.();
82
+ }
83
+ /**
51
84
  * A roving tabindex: the manager nominates one option as the composite's tab
52
85
  * stop and every other option stays out of the tab order, as the ARIA
53
86
  * listbox pattern requires. Giving a `0` to each active *or selected* option
@@ -232,10 +265,11 @@ class ListboxItem extends Component {
232
265
  return this.submenuOpenState;
233
266
  }
234
267
  static {
235
- setComponentTemplate(precompileTemplate("<li {{this.manager.setupItem key=this.key textValue=@textValue item=@item onRegister=this.onRegister}} {{on \"click\" this.onClick}} id={{this.itemId}} role={{this.role}} aria-labelledby={{this.labelId}} aria-selected={{this.ariaSelected}} aria-checked={{this.ariaChecked}} aria-haspopup={{this.ariaHasPopup}} aria-expanded={{this.ariaExpanded}} aria-controls={{if @hasSubmenu @submenuId}} data-submenu-open={{this.dataSubmenuOpen}} tabindex={{this.tabindex}} data-active=\"{{this.listItem.isActive}}\" data-selected=\"{{this.listItem.isSelected}}\" data-component=\"listbox-item\" data-part=\"base\" data-key={{this.key}} aria-disabled={{if this.listItem.isDisabled \"true\"}} class={{this.classNames.base}} ...attributes>\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div data-part=\"description-wrapper\" class={{this.classNames.descriptionWrapper}}>\n <span data-part=\"label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n <span data-part=\"description\" class={{this.classNames.description}}>{{@description}}</span>\n </div>\n {{else}}\n <span data-part=\"label\" class={{this.classNames.label}} id={{this.labelId}}>{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd @keys={{@shortcut}} @size=\"sm\" @variant={{this.shortcutVariant}} data-test-id=\"listbox-item-shortcut\" />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-part=\"selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span data-part=\"submenu-indicator\" class={{this.submenuIndicatorClass}}>\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n</li>\n{{#if @withDivider}}\n <Divider @as=\"li\" />\n{{/if}}", {
268
+ setComponentTemplate(precompileTemplate("<li {{this.manager.setupItem key=this.key textValue=@textValue item=@item isDisabled=@isDisabled onRegister=this.onRegister}} {{on \"click\" this.onClick}} id={{this.itemId}} role={{this.role}} aria-labelledby={{this.labelId}} aria-selected={{this.ariaSelected}} aria-checked={{this.ariaChecked}} aria-haspopup={{this.ariaHasPopup}} aria-expanded={{this.ariaExpanded}} aria-controls={{if @hasSubmenu @submenuId}} data-submenu-open={{this.dataSubmenuOpen}} tabindex={{this.tabindex}} data-active=\"{{this.listItem.isActive}}\" data-selected=\"{{this.listItem.isSelected}}\" data-component=\"listbox-item\" data-part=\"base\" data-key={{this.key}} aria-disabled={{if this.listItem.isDisabled \"true\"}} class={{this.classNames.base}} ...attributes>\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div data-part=\"description-wrapper\" class={{this.classNames.descriptionWrapper}}>\n <span data-part=\"label\" class={{this.classNames.label}} id={{this.labelId}}>{{#if this.isLink}}<NavLink @href={{@href}} @route={{@route}} @models={{@models}} @model={{@model}} @query={{@query}} @isDisabled={{this.listItem.isDisabled}} tabindex=\"-1\" class=\"after:absolute after:inset-0 after:content-['']\">{{yield}}</NavLink>{{else}}{{yield}}{{/if}}</span>\n <span data-part=\"description\" class={{this.classNames.description}}>{{@description}}</span>\n </div>\n {{else}}\n <span data-part=\"label\" class={{this.classNames.label}} id={{this.labelId}}>{{#if this.isLink}}<NavLink @href={{@href}} @route={{@route}} @models={{@models}} @model={{@model}} @query={{@query}} @isDisabled={{this.listItem.isDisabled}} tabindex=\"-1\" class=\"after:absolute after:inset-0 after:content-['']\">{{yield}}</NavLink>{{else}}{{yield}}{{/if}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd @keys={{@shortcut}} @size=\"sm\" @variant={{this.shortcutVariant}} data-test-id=\"listbox-item-shortcut\" />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-part=\"selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span data-part=\"submenu-indicator\" class={{this.submenuIndicatorClass}}>\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n</li>\n{{#if @withDivider}}\n <Divider @as=\"li\" />\n{{/if}}", {
236
269
  strictMode: true,
237
270
  scope: () => ({
238
271
  on,
272
+ NavLink,
239
273
  Kbd,
240
274
  CheckIcon,
241
275
  ChevronRightIcon,
@@ -1 +1 @@
1
- {"version":3,"file":"item.js","sources":["../../../../src/components/collections/listbox/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked, cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { Kbd } from '../../utilities/kbd';\nimport type { KbdSignature } from '../../utilities/kbd';\nimport { guidFor } from '@ember/object/internals';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ListManager, ListItem } from '../../../utils/listManager';\nimport { renamedArgValue } from '../../../-private/deprecated-args';\n\nexport interface ListboxItemSignature {\n Args: {\n manager: ListManager;\n key: string;\n textValue?: string;\n\n /**\n * The entry of `@items` this option renders, remembered on the registered\n * list item so a selection can hand it back. Bound for you on the Item\n * yielded from the `:item` block; block-form options have no such entry.\n */\n item?: unknown;\n\n description?: string;\n\n /**\n * A keyboard shortcut shown at the end of the option, rendered by `Kbd`.\n * Accepts named keys (`\"mod+k\"`) or a literal string (`\"⌘K\"`).\n */\n shortcut?: string;\n\n /**\n * The variant of the rendered shortcut. Defaults to `inherit`, so the\n * keycap follows the option's own colour on active and filled rows.\n *\n * @defaultValue 'inherit'\n */\n shortcutVariant?: KbdSignature['Args']['variant'];\n onClick?: () => void;\n class?: string;\n withDivider?: boolean;\n\n /**\n * The variant of each item.\n *\n * @defaultValue 'solid'\n */\n variant?: 'solid' | 'outline' | 'subtle';\n\n /**\n * @deprecated Use `variant`. `default` is now `solid`, `outlined` is\n * `outline`, and `faded` is `subtle`.\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The color of each item\n */\n color?:\n | 'neutral'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * @deprecated Use `color`. `default` is now `neutral`.\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n type?: 'menu' | 'listbox';\n\n /**\n * Marks this option as the trigger for a submenu.\n *\n * It stops the option selecting: opening a submenu is not choosing\n * anything, so `onAction` and `onSelectionChange` must not fire for it.\n * The option still registers with the `ListManager` and so still takes\n * part in arrow navigation, type-ahead and the roving tab stop.\n *\n * Renders `aria-haspopup=\"menu\"` and a trailing chevron, unless an `:end`\n * block supplies its own trailing content.\n */\n hasSubmenu?: boolean;\n\n /**\n * Whether this option's submenu is currently open. Only meaningful\n * alongside `@hasSubmenu`; drives `aria-expanded` and the highlighted\n * resting state via `data-submenu-open`.\n */\n isSubmenuOpen?: boolean;\n\n /**\n * The id of the `role=\"menu\"` element this option opens, for\n * `aria-controls`. Only meaningful alongside `@hasSubmenu`.\n */\n submenuId?: string;\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [];\n selectedIcon: [];\n start: [];\n end: [];\n };\n}\n\nclass ListboxItem extends Component<ListboxItemSignature> {\n // Stable element id so consumers (e.g. Autocomplete) can reference the\n // option via aria-activedescendant.\n itemId = `${guidFor(this)}-option`;\n labelId = guidFor(this);\n @tracked listItem?: ListItem;\n\n get manager(): ListManager {\n assert(\n `ListboxItem does not have a listManager; Missing argument @manager`,\n this.args.manager\n );\n\n return this.args.manager;\n }\n\n get key(): string {\n assert(\n `Argument @key is undefined or null, @key must be provided in Listbox.Item component`,\n this.args.key\n );\n\n return this.args.key;\n }\n\n onRegister = (item: ListItem) => {\n this.listItem = item;\n };\n\n onClick = (): void => {\n if (this.listItem?.isDisabled) {\n return;\n }\n\n // Opening a submenu is not choosing anything, so a sub-trigger must not\n // reach `selectItem` -- that is what fires `onAction` and\n // `onSelectionChange`. It still registers as an item, so arrow\n // navigation, type-ahead and the roving tab stop are unaffected.\n if (!this.args.hasSubmenu) {\n this.manager.selectItem(this.listItem);\n }\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n };\n\n /**\n * A roving tabindex: the manager nominates one option as the composite's tab\n * stop and every other option stays out of the tab order, as the ARIA\n * listbox pattern requires. Giving a `0` to each active *or selected* option\n * turned a multi-select with eight selections into eight tab stops.\n */\n get tabindex() {\n return this.manager.isTabStop(this.key) ? 0 : -1;\n }\n\n /**\n * Resolved once per render (`@cached`) so referencing it from both\n * `classNames` and `submenuIndicatorClass` does not fire the deprecation\n * twice for the same item.\n */\n @cached\n get variant(): 'solid' | 'outline' | 'subtle' {\n return (\n renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'subtle' } as const,\n {\n component: 'Listbox',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.listbox.appearance'\n }\n ) || 'solid'\n );\n }\n\n /**\n * Resolved once per render (`@cached`) so referencing it from both\n * `classNames` and `submenuIndicatorClass` does not fire the deprecation\n * twice for the same item.\n */\n @cached\n get color(): NonNullable<ListboxItemSignature['Args']['color']> {\n return (\n renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Listbox',\n from: 'intent',\n to: 'color',\n id: 'frontile.listbox.intent'\n }\n ) || 'neutral'\n );\n }\n\n get classNames() {\n const { listboxItem } = useStyles();\n\n const { base, descriptionWrapper, label, description, selectedIcon } =\n listboxItem({\n variant: this.variant,\n color: this.color,\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return {\n base: base({ class: this.args.class }),\n descriptionWrapper: descriptionWrapper(),\n label: label(),\n description: description(),\n selectedIcon: selectedIcon()\n };\n }\n\n /**\n * The `submenuIndicator` slot is only ever rendered on a sub-trigger, so it\n * is looked up here rather than in `classNames`, and only when\n * `@hasSubmenu` is set — a plain item never pays for it.\n *\n * `registerCustomStyles` (`packages/theme/src/index.ts`) shallow-replaces:\n * a consumer supplying their own `listboxItem` via `tv({...})` swaps out\n * the whole config, not just the slots they mention. `tv()` in turn only\n * produces a function for a slot it was actually given. So a third-party\n * override written before this slot existed has no `submenuIndicator` key\n * at all, and calling it would throw. A published component library must\n * not crash a consumer's app over a stale override, so this stays\n * defensive — but the check now only runs for sub-triggers, not for every\n * item on every render.\n */\n get submenuIndicatorClass(): string | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n\n const { listboxItem } = useStyles();\n const { submenuIndicator } = listboxItem({\n variant: this.variant,\n color: this.color,\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return typeof submenuIndicator === 'function'\n ? submenuIndicator()\n : undefined;\n }\n\n get shortcutVariant() {\n return this.args.shortcutVariant ?? 'inherit';\n }\n\n /**\n * Whether this row carries selection state of its own.\n *\n * A row that opens a submenu never does, whatever the level selects:\n * activating it reveals another menu rather than toggling a value. Both\n * `role` and `ariaChecked` hang off this one question, so they cannot\n * disagree about it.\n */\n get isCheckableMenuRow(): boolean {\n return (\n this.args.type === 'menu' &&\n !this.args.hasSubmenu &&\n this.manager.selectionMode !== 'none'\n );\n }\n\n get role() {\n if (this.args.type !== 'menu') {\n return 'option';\n }\n\n if (!this.isCheckableMenuRow) {\n return 'menuitem';\n }\n\n return this.manager.selectionMode === 'multiple'\n ? 'menuitemcheckbox'\n : 'menuitemradio';\n }\n\n /**\n * `aria-selected` belongs on `option`, and only there — a plain `menuitem`\n * that carries it is invalid ARIA, since menu items convey state through\n * `aria-checked` and only as `menuitemcheckbox`/`menuitemradio`. Returning\n * undefined omits the attribute rather than rendering an empty one.\n */\n get ariaSelected(): 'true' | 'false' | undefined {\n return this.role === 'option' ? this.selectedState : undefined;\n }\n\n /** Selection as an ARIA attribute value, for whichever attribute carries it. */\n private get selectedState(): 'true' | 'false' {\n return this.listItem?.isSelected ? 'true' : 'false';\n }\n\n /**\n * The menu counterpart to `aria-selected`.\n *\n * Rendered only for the two checkable menu roles: `aria-checked` on a plain\n * `menuitem` is invalid ARIA, and a checkable row that omits it announces no\n * state at all, which is how a selectable menu ends up sounding identical to\n * a list of commands.\n */\n get ariaChecked(): 'true' | 'false' | undefined {\n return this.isCheckableMenuRow ? this.selectedState : undefined;\n }\n\n /**\n * `aria-haspopup=\"menu\"` rather than the bare `\"true\"`: both are valid, but\n * the explicit role tells a screen reader what is about to open.\n */\n get ariaHasPopup(): 'menu' | undefined {\n return this.args.hasSubmenu ? 'menu' : undefined;\n }\n\n /**\n * Only a row that owns a popup has an expanded state. Rendering\n * `aria-expanded` on a plain `menuitem` would be invalid ARIA, so this is\n * undefined -- and therefore omitted -- unless `@hasSubmenu` is set.\n */\n /**\n * `aria-expanded` and `data-submenu-open` share this same value — one is\n * the ARIA state for assistive tech, the other a styling hook for the\n * template's own resting/hover state — so both getters delegate here.\n */\n get submenuOpenState(): 'true' | 'false' | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n return this.args.isSubmenuOpen ? 'true' : 'false';\n }\n\n get ariaExpanded(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n get dataSubmenuOpen(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n <template>\n <li\n {{this.manager.setupItem\n key=this.key\n textValue=@textValue\n item=@item\n onRegister=this.onRegister\n }}\n {{on \"click\" this.onClick}}\n id={{this.itemId}}\n role={{this.role}}\n aria-labelledby={{this.labelId}}\n aria-selected={{this.ariaSelected}}\n aria-checked={{this.ariaChecked}}\n aria-haspopup={{this.ariaHasPopup}}\n aria-expanded={{this.ariaExpanded}}\n aria-controls={{if @hasSubmenu @submenuId}}\n data-submenu-open={{this.dataSubmenuOpen}}\n tabindex={{this.tabindex}}\n data-active=\"{{this.listItem.isActive}}\"\n data-selected=\"{{this.listItem.isSelected}}\"\n data-component=\"listbox-item\"\n data-part=\"base\"\n data-key={{this.key}}\n aria-disabled={{if this.listItem.isDisabled \"true\"}}\n class={{this.classNames.base}}\n ...attributes\n >\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div\n data-part=\"description-wrapper\"\n class={{this.classNames.descriptionWrapper}}\n >\n <span\n data-part=\"label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n <span\n data-part=\"description\"\n class={{this.classNames.description}}\n >{{@description}}</span>\n </div>\n {{else}}\n <span\n data-part=\"label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{yield}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd\n @keys={{@shortcut}}\n @size=\"sm\"\n @variant={{this.shortcutVariant}}\n data-test-id=\"listbox-item-shortcut\"\n />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-part=\"selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span\n data-part=\"submenu-indicator\"\n class={{this.submenuIndicatorClass}}\n >\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n </template>\n}\n\nconst CheckIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m4.5 12.75 6 6 9-13.5\"\n />\n </svg>\n</template>;\n\nconst ChevronRightIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m8.25 4.5 7.5 7.5-7.5 7.5\"\n />\n </svg>\n</template>;\n\nexport { ListboxItem };\n"],"names":["ListboxItem","Component","itemId","guidFor","labelId","g","prototype","tracked","i","manager","assert","args","key","onRegister","item","listItem","onClick","isDisabled","hasSubmenu","selectItem","tabindex","isTabStop","variant","renamedArgValue","appearance","default","outlined","faded","component","from","to","id","n","cached","color","intent","classNames","listboxItem","useStyles","base","descriptionWrapper","label","description","selectedIcon","isSelected","isActive","withDivider","class","submenuIndicatorClass","undefined","submenuIndicator","shortcutVariant","isCheckableMenuRow","type","selectionMode","role","ariaSelected","selectedState","ariaChecked","ariaHasPopup","submenuOpenState","isSubmenuOpen","ariaExpanded","dataSubmenuOpen","setComponentTemplate","precompileTemplate","strictMode","scope","on","Kbd","CheckIcon","ChevronRightIcon","Divider","templateOnly"],"mappings":";;;;;;;;;;;;;;AAuHA,MAAMA,oBAAoBC,SAAA,CAAU;AAClC;AACA;AACAC,EAAAA,MAAA,GAAS,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAClCC,EAAAA,OAAA,GAAUD,OAAA,CAAQ,IAAI,CAAA;AAAE,EAAA;IAAAE,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,UAAA,EAAA,CACvBC,OAAA,CAAA,CAAA;AAAA;EAAA,SAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,UAAA,CAAA,EAAA,MAAA;EAED,IAAIC,UAAuB;IACzBC,MAAA,CACE,oEAAoE,EACpE,IAAI,CAACC,IAAI,CAACF,OAAO,CAAA;AAGnB,IAAA,OAAO,IAAI,CAACE,IAAI,CAACF,OAAO;AAC1B,EAAA;EAEA,IAAIG,GAAAA,GAAc;IAChBF,MAAA,CACE,qFAAqF,EACrF,IAAI,CAACC,IAAI,CAACC,GAAG,CAAA;AAGf,IAAA,OAAO,IAAI,CAACD,IAAI,CAACC,GAAG;AACtB,EAAA;EAEAC,UAAA,GAAcC,IAAM,IAAA;IAClB,IAAI,CAACC,QAAQ,GAAGD,IAAA;EAClB,CAAA;EAEAE,OAAA,GAAUA,MAAQ;AAChB,IAAA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"version":3,"file":"item.js","sources":["../../../../src/components/collections/listbox/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked, cached } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { Divider } from '../../utilities/divider';\nimport { Kbd } from '../../utilities/kbd';\nimport type { KbdSignature } from '../../utilities/kbd';\nimport { guidFor } from '@ember/object/internals';\nimport type { TOC } from '@ember/component/template-only';\nimport type { ListManager, ListItem } from '../../../utils/listManager';\nimport { renamedArgValue } from '../../../-private/deprecated-args';\nimport { NavLink } from '../../layout/nav-link';\n\nexport interface ListboxItemSignature {\n Args: {\n manager: ListManager;\n key: string;\n textValue?: string;\n\n /**\n * The entry of `@items` this option renders, remembered on the registered\n * list item so a selection can hand it back. Bound for you on the Item\n * yielded from the `:item` block; block-form options have no such entry.\n */\n item?: unknown;\n\n description?: string;\n\n /**\n * A keyboard shortcut shown at the end of the option, rendered by `Kbd`.\n * Accepts named keys (`\"mod+k\"`) or a literal string (`\"⌘K\"`).\n */\n shortcut?: string;\n\n /**\n * The variant of the rendered shortcut. Defaults to `inherit`, so the\n * keycap follows the option's own colour on active and filled rows.\n *\n * @defaultValue 'inherit'\n */\n shortcutVariant?: KbdSignature['Args']['variant'];\n onClick?: () => void;\n class?: string;\n withDivider?: boolean;\n\n /**\n * The variant of each item.\n *\n * @defaultValue 'solid'\n */\n variant?: 'solid' | 'outline' | 'subtle';\n\n /**\n * @deprecated Use `variant`. `default` is now `solid`, `outlined` is\n * `outline`, and `faded` is `subtle`.\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The color of each item\n */\n color?:\n | 'neutral'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * @deprecated Use `color`. `default` is now `neutral`.\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n type?: 'menu' | 'listbox';\n\n /**\n * Marks this option as the trigger for a submenu.\n *\n * It stops the option selecting: opening a submenu is not choosing\n * anything, so `onAction` and `onSelectionChange` must not fire for it.\n * The option still registers with the `ListManager` and so still takes\n * part in arrow navigation, type-ahead and the roving tab stop.\n *\n * Renders `aria-haspopup=\"menu\"` and a trailing chevron, unless an `:end`\n * block supplies its own trailing content.\n */\n hasSubmenu?: boolean;\n\n /**\n * Whether this option's submenu is currently open. Only meaningful\n * alongside `@hasSubmenu`; drives `aria-expanded` and the highlighted\n * resting state via `data-submenu-open`.\n */\n isSubmenuOpen?: boolean;\n\n /**\n * The id of the `role=\"menu\"` element this option opens, for\n * `aria-controls`. Only meaningful alongside `@hasSubmenu`.\n */\n submenuId?: string;\n\n /**\n * Renders the item as a link to this URL (a plain `<a>`, no router\n * needed). Only honoured inside a `Dropdown` menu (`@type=\"menu\"`).\n *\n * A link item follows its link instead of selecting: `@onAction` and\n * `@onSelectionChange` are not called, and the menu closes.\n */\n href?: string;\n\n /**\n * Renders the item as a router link to this route. Only honoured inside\n * a `Dropdown` menu. See `@href` for what a link item does on activation.\n */\n route?: string;\n\n /** Dynamic segments for `@route`. */\n models?: unknown[];\n\n /** A single dynamic segment for `@route`. */\n model?: unknown;\n\n /** Query params for `@route`. */\n query?: Record<string, unknown>;\n\n /**\n * @internal\n *\n * Disables this one item, on top of the list's `@disabledKeys`: it is\n * skipped by the arrow keys and type-ahead, cannot be chosen, and is\n * marked `aria-disabled`. Supplied by `NavFolder` for its menu items,\n * whose disabled state is known per item rather than as a list of keys.\n */\n isDisabled?: boolean;\n\n /**\n * @internal\n *\n * Called after a link item is activated. The `Dropdown` menu binds this\n * to dismiss itself (honouring `@closeOnItemSelect`).\n */\n onLinkActivate?: () => void;\n };\n Element: HTMLLIElement;\n Blocks: {\n default: [];\n selectedIcon: [];\n start: [];\n end: [];\n };\n}\n\nclass ListboxItem extends Component<ListboxItemSignature> {\n // Stable element id so consumers (e.g. Autocomplete) can reference the\n // option via aria-activedescendant.\n itemId = `${guidFor(this)}-option`;\n labelId = guidFor(this);\n @tracked listItem?: ListItem;\n\n get manager(): ListManager {\n assert(\n `ListboxItem does not have a listManager; Missing argument @manager`,\n this.args.manager\n );\n\n return this.args.manager;\n }\n\n get key(): string {\n assert(\n `Argument @key is undefined or null, @key must be provided in Listbox.Item component`,\n this.args.key\n );\n\n return this.args.key;\n }\n\n onRegister = (item: ListItem) => {\n this.listItem = item;\n };\n\n /**\n * A link item exists only in a menu. `@type=\"listbox\"` ignores the link\n * args, so Listbox and Select are unchanged.\n */\n get isLink(): boolean {\n return (\n this.args.type === 'menu' && Boolean(this.args.href || this.args.route)\n );\n }\n\n onClick = (event: MouseEvent): void => {\n if (this.listItem?.isDisabled) {\n return;\n }\n\n if (this.isLink) {\n this.activateLink(event);\n return;\n }\n\n // Opening a submenu is not choosing anything, so a sub-trigger must not\n // reach `selectItem` -- that is what fires `onAction` and\n // `onSelectionChange`. It still registers as an item, so arrow\n // navigation, type-ahead and the roving tab stop are unaffected.\n if (!this.args.hasSubmenu) {\n this.manager.selectItem(this.listItem);\n }\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n };\n\n /**\n * A link item never goes through `selectItem`, which is what fires\n * `onAction` and `onSelectionChange`: following a link is not choosing.\n *\n * A click that did not start on the anchor -- Enter and Space (the listbox\n * clicks the active `li`) or a click on the row's padding -- is forwarded to\n * the anchor, so the browser or `LinkTo` does the navigating. That click\n * bubbles back here with the anchor as its target, and only then does the\n * menu close.\n */\n private activateLink(event: MouseEvent): void {\n const anchor = (event.currentTarget as HTMLElement).querySelector('a');\n\n if (anchor && !anchor.contains(event.target as Node)) {\n anchor.click();\n return;\n }\n\n if (typeof this.args.onClick === 'function') {\n this.args.onClick();\n }\n this.args.onLinkActivate?.();\n }\n\n /**\n * A roving tabindex: the manager nominates one option as the composite's tab\n * stop and every other option stays out of the tab order, as the ARIA\n * listbox pattern requires. Giving a `0` to each active *or selected* option\n * turned a multi-select with eight selections into eight tab stops.\n */\n get tabindex() {\n return this.manager.isTabStop(this.key) ? 0 : -1;\n }\n\n /**\n * Resolved once per render (`@cached`) so referencing it from both\n * `classNames` and `submenuIndicatorClass` does not fire the deprecation\n * twice for the same item.\n */\n @cached\n get variant(): 'solid' | 'outline' | 'subtle' {\n return (\n renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'subtle' } as const,\n {\n component: 'Listbox',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.listbox.appearance'\n }\n ) || 'solid'\n );\n }\n\n /**\n * Resolved once per render (`@cached`) so referencing it from both\n * `classNames` and `submenuIndicatorClass` does not fire the deprecation\n * twice for the same item.\n */\n @cached\n get color(): NonNullable<ListboxItemSignature['Args']['color']> {\n return (\n renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Listbox',\n from: 'intent',\n to: 'color',\n id: 'frontile.listbox.intent'\n }\n ) || 'neutral'\n );\n }\n\n get classNames() {\n const { listboxItem } = useStyles();\n\n const { base, descriptionWrapper, label, description, selectedIcon } =\n listboxItem({\n variant: this.variant,\n color: this.color,\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return {\n base: base({ class: this.args.class }),\n descriptionWrapper: descriptionWrapper(),\n label: label(),\n description: description(),\n selectedIcon: selectedIcon()\n };\n }\n\n /**\n * The `submenuIndicator` slot is only ever rendered on a sub-trigger, so it\n * is looked up here rather than in `classNames`, and only when\n * `@hasSubmenu` is set — a plain item never pays for it.\n *\n * `registerCustomStyles` (`packages/theme/src/index.ts`) shallow-replaces:\n * a consumer supplying their own `listboxItem` via `tv({...})` swaps out\n * the whole config, not just the slots they mention. `tv()` in turn only\n * produces a function for a slot it was actually given. So a third-party\n * override written before this slot existed has no `submenuIndicator` key\n * at all, and calling it would throw. A published component library must\n * not crash a consumer's app over a stale override, so this stays\n * defensive — but the check now only runs for sub-triggers, not for every\n * item on every render.\n */\n get submenuIndicatorClass(): string | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n\n const { listboxItem } = useStyles();\n const { submenuIndicator } = listboxItem({\n variant: this.variant,\n color: this.color,\n isDisabled: this.listItem?.isDisabled,\n isSelected: this.listItem?.isSelected,\n isActive: this.listItem?.isActive,\n withDivider: this.args.withDivider\n });\n\n return typeof submenuIndicator === 'function'\n ? submenuIndicator()\n : undefined;\n }\n\n get shortcutVariant() {\n return this.args.shortcutVariant ?? 'inherit';\n }\n\n /**\n * Whether this row carries selection state of its own.\n *\n * A row that opens a submenu never does, whatever the level selects:\n * activating it reveals another menu rather than toggling a value. Both\n * `role` and `ariaChecked` hang off this one question, so they cannot\n * disagree about it.\n */\n get isCheckableMenuRow(): boolean {\n return (\n this.args.type === 'menu' &&\n !this.args.hasSubmenu &&\n this.manager.selectionMode !== 'none'\n );\n }\n\n get role() {\n if (this.args.type !== 'menu') {\n return 'option';\n }\n\n if (!this.isCheckableMenuRow) {\n return 'menuitem';\n }\n\n return this.manager.selectionMode === 'multiple'\n ? 'menuitemcheckbox'\n : 'menuitemradio';\n }\n\n /**\n * `aria-selected` belongs on `option`, and only there — a plain `menuitem`\n * that carries it is invalid ARIA, since menu items convey state through\n * `aria-checked` and only as `menuitemcheckbox`/`menuitemradio`. Returning\n * undefined omits the attribute rather than rendering an empty one.\n */\n get ariaSelected(): 'true' | 'false' | undefined {\n return this.role === 'option' ? this.selectedState : undefined;\n }\n\n /** Selection as an ARIA attribute value, for whichever attribute carries it. */\n private get selectedState(): 'true' | 'false' {\n return this.listItem?.isSelected ? 'true' : 'false';\n }\n\n /**\n * The menu counterpart to `aria-selected`.\n *\n * Rendered only for the two checkable menu roles: `aria-checked` on a plain\n * `menuitem` is invalid ARIA, and a checkable row that omits it announces no\n * state at all, which is how a selectable menu ends up sounding identical to\n * a list of commands.\n */\n get ariaChecked(): 'true' | 'false' | undefined {\n return this.isCheckableMenuRow ? this.selectedState : undefined;\n }\n\n /**\n * `aria-haspopup=\"menu\"` rather than the bare `\"true\"`: both are valid, but\n * the explicit role tells a screen reader what is about to open.\n */\n get ariaHasPopup(): 'menu' | undefined {\n return this.args.hasSubmenu ? 'menu' : undefined;\n }\n\n /**\n * Only a row that owns a popup has an expanded state. Rendering\n * `aria-expanded` on a plain `menuitem` would be invalid ARIA, so this is\n * undefined -- and therefore omitted -- unless `@hasSubmenu` is set.\n */\n /**\n * `aria-expanded` and `data-submenu-open` share this same value — one is\n * the ARIA state for assistive tech, the other a styling hook for the\n * template's own resting/hover state — so both getters delegate here.\n */\n get submenuOpenState(): 'true' | 'false' | undefined {\n if (!this.args.hasSubmenu) {\n return undefined;\n }\n return this.args.isSubmenuOpen ? 'true' : 'false';\n }\n\n get ariaExpanded(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n get dataSubmenuOpen(): 'true' | 'false' | undefined {\n return this.submenuOpenState;\n }\n\n <template>\n <li\n {{this.manager.setupItem\n key=this.key\n textValue=@textValue\n item=@item\n isDisabled=@isDisabled\n onRegister=this.onRegister\n }}\n {{on \"click\" this.onClick}}\n id={{this.itemId}}\n role={{this.role}}\n aria-labelledby={{this.labelId}}\n aria-selected={{this.ariaSelected}}\n aria-checked={{this.ariaChecked}}\n aria-haspopup={{this.ariaHasPopup}}\n aria-expanded={{this.ariaExpanded}}\n aria-controls={{if @hasSubmenu @submenuId}}\n data-submenu-open={{this.dataSubmenuOpen}}\n tabindex={{this.tabindex}}\n data-active=\"{{this.listItem.isActive}}\"\n data-selected=\"{{this.listItem.isSelected}}\"\n data-component=\"listbox-item\"\n data-part=\"base\"\n data-key={{this.key}}\n aria-disabled={{if this.listItem.isDisabled \"true\"}}\n class={{this.classNames.base}}\n ...attributes\n >\n {{yield to=\"start\"}}\n\n {{#if @description}}\n <div\n data-part=\"description-wrapper\"\n class={{this.classNames.descriptionWrapper}}\n >\n <span\n data-part=\"label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{#if this.isLink}}<NavLink\n @href={{@href}}\n @route={{@route}}\n @models={{@models}}\n @model={{@model}}\n @query={{@query}}\n @isDisabled={{this.listItem.isDisabled}}\n tabindex=\"-1\"\n class=\"after:absolute after:inset-0 after:content-['']\"\n >{{yield}}</NavLink>{{else}}{{yield}}{{/if}}</span>\n <span\n data-part=\"description\"\n class={{this.classNames.description}}\n >{{@description}}</span>\n </div>\n {{else}}\n <span\n data-part=\"label\"\n class={{this.classNames.label}}\n id={{this.labelId}}\n >{{#if this.isLink}}<NavLink\n @href={{@href}}\n @route={{@route}}\n @models={{@models}}\n @model={{@model}}\n @query={{@query}}\n @isDisabled={{this.listItem.isDisabled}}\n tabindex=\"-1\"\n class=\"after:absolute after:inset-0 after:content-['']\"\n >{{yield}}</NavLink>{{else}}{{yield}}{{/if}}</span>\n {{/if}}\n\n {{#if @shortcut}}\n <Kbd\n @keys={{@shortcut}}\n @size=\"sm\"\n @variant={{this.shortcutVariant}}\n data-test-id=\"listbox-item-shortcut\"\n />\n {{/if}}\n\n {{#if this.listItem.isSelected}}\n <span data-part=\"selected-icon\" class={{this.classNames.selectedIcon}}>\n {{#if (has-block \"selectedIcon\")}}\n {{yield to=\"selectedIcon\"}}\n {{else}}\n <CheckIcon class=\"h-full w-full\" />\n {{/if}}\n </span>\n {{/if}}\n\n {{#if @hasSubmenu}}\n {{#unless (has-block \"end\")}}\n <span\n data-part=\"submenu-indicator\"\n class={{this.submenuIndicatorClass}}\n >\n <ChevronRightIcon class=\"h-full w-full\" />\n </span>\n {{/unless}}\n {{/if}}\n\n {{yield to=\"end\"}}\n </li>\n {{#if @withDivider}}\n <Divider @as=\"li\" />\n {{/if}}\n </template>\n}\n\nconst CheckIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m4.5 12.75 6 6 9-13.5\"\n />\n </svg>\n</template>;\n\nconst ChevronRightIcon: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"m8.25 4.5 7.5 7.5-7.5 7.5\"\n />\n </svg>\n</template>;\n\nexport { ListboxItem };\n"],"names":["ListboxItem","Component","itemId","guidFor","labelId","g","prototype","tracked","i","manager","assert","args","key","onRegister","item","listItem","isLink","type","Boolean","href","route","onClick","event","isDisabled","activateLink","hasSubmenu","selectItem","anchor","currentTarget","querySelector","contains","target","click","onLinkActivate","tabindex","isTabStop","variant","renamedArgValue","appearance","default","outlined","faded","component","from","to","id","n","cached","color","intent","classNames","listboxItem","useStyles","base","descriptionWrapper","label","description","selectedIcon","isSelected","isActive","withDivider","class","submenuIndicatorClass","undefined","submenuIndicator","shortcutVariant","isCheckableMenuRow","selectionMode","role","ariaSelected","selectedState","ariaChecked","ariaHasPopup","submenuOpenState","isSubmenuOpen","ariaExpanded","dataSubmenuOpen","setComponentTemplate","precompileTemplate","strictMode","scope","on","NavLink","Kbd","CheckIcon","ChevronRightIcon","Divider","templateOnly"],"mappings":";;;;;;;;;;;;;;;AAkKA,MAAMA,oBAAoBC,SAAA,CAAU;AAClC;AACA;AACAC,EAAAA,MAAA,GAAS,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAClCC,EAAAA,OAAA,GAAUD,OAAA,CAAQ,IAAI,CAAA;AAAE,EAAA;IAAAE,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,UAAA,EAAA,CACvBC,OAAA,CAAA,CAAA;AAAA;EAAA,SAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,UAAA,CAAA,EAAA,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