@ark-ui/solid 5.15.0 → 5.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +1 -0
  2. package/dist/chunk/{QTPO6CAG.jsx → 4L4266PL.jsx} +10 -10
  3. package/dist/chunk/{LHJM3X56.jsx → 4T2T3PMU.jsx} +7 -7
  4. package/dist/chunk/6ATAHZBX.js +193 -0
  5. package/dist/chunk/{QZL7A4I6.jsx → 6XAZQVOY.jsx} +10 -10
  6. package/dist/chunk/{WYNHVCCC.jsx → 7FASJWDK.jsx} +6 -6
  7. package/dist/chunk/{4JKVIHU2.jsx → 7OXBQSIZ.jsx} +10 -10
  8. package/dist/chunk/{UBCF5HI7.jsx → 7RYPC5LL.jsx} +6 -6
  9. package/dist/chunk/{NUPYPPGN.jsx → 7UNWOGPT.jsx} +7 -7
  10. package/dist/chunk/{5UVX33V2.jsx → CINP4S7J.jsx} +6 -6
  11. package/dist/chunk/{IFVMP7PM.jsx → DLZTFD37.jsx} +10 -10
  12. package/dist/chunk/{PNYN26W7.jsx → FG427CLW.jsx} +6 -6
  13. package/dist/chunk/{P5ZRUIVB.jsx → FOIEK72O.jsx} +6 -6
  14. package/dist/chunk/{6Q4ZZUWZ.jsx → GKS4JQZJ.jsx} +4 -4
  15. package/dist/chunk/{OIG52XTL.jsx → GLN6WFQR.jsx} +3 -3
  16. package/dist/chunk/{7JA2F6LW.jsx → H4MJ4254.jsx} +7 -7
  17. package/dist/chunk/{O2Q7MOG6.jsx → HQOIDGRU.jsx} +2 -2
  18. package/dist/chunk/I7VQFKYT.jsx +172 -0
  19. package/dist/chunk/{2Z37DOO5.jsx → IDNDLSEV.jsx} +7 -7
  20. package/dist/chunk/{5FW3VV3B.jsx → JK6QXH6B.jsx} +6 -6
  21. package/dist/chunk/{5OA4XEHW.jsx → JKM73NGJ.jsx} +6 -6
  22. package/dist/chunk/{FS6GEMRM.jsx → JY6PMVAK.jsx} +4 -4
  23. package/dist/chunk/{7AMCFBJH.jsx → KJ353BY6.jsx} +7 -7
  24. package/dist/chunk/{SXZY4NGI.jsx → KNVMVQG6.jsx} +7 -7
  25. package/dist/chunk/L5XYJCAK.jsx +264 -0
  26. package/dist/chunk/{A6XGGK7D.jsx → MJTOTU2A.jsx} +6 -6
  27. package/dist/chunk/{FKI6A35L.jsx → N3W3K2ZD.jsx} +7 -7
  28. package/dist/chunk/{VSLHNUS2.jsx → OM7DNJ6L.jsx} +7 -7
  29. package/dist/chunk/{TTZNIVIU.jsx → OM7V7VVC.jsx} +7 -7
  30. package/dist/chunk/P5BHXVYK.js +126 -0
  31. package/dist/chunk/{B4ZXV6YG.jsx → PRA2XFQE.jsx} +6 -6
  32. package/dist/chunk/{J4VOAZA3.jsx → QXYWHKF7.jsx} +6 -6
  33. package/dist/chunk/{ZF7UP5R3.jsx → RULCXX3A.jsx} +4 -4
  34. package/dist/chunk/TBR4XVH2.js +172 -0
  35. package/dist/chunk/{ZMXVBUJS.jsx → TTIVTOWQ.jsx} +1 -1
  36. package/dist/chunk/{N4LRXFJX.jsx → U7QDCJXT.jsx} +10 -10
  37. package/dist/chunk/{3HYU2MCP.jsx → V2GDFVDR.jsx} +1 -1
  38. package/dist/chunk/{7BS7ZITV.jsx → V6S3C3U7.jsx} +7 -7
  39. package/dist/chunk/{TILCNQZF.jsx → V75EMOIC.jsx} +7 -7
  40. package/dist/chunk/{Q3QMDHRY.jsx → VR5BNKL7.jsx} +7 -7
  41. package/dist/chunk/{WKKFHYOJ.jsx → VXQNQSLM.jsx} +10 -10
  42. package/dist/chunk/{YIQG5BP3.jsx → WBLWV2L4.jsx} +7 -7
  43. package/dist/chunk/{LY6KT2RR.jsx → X5GWQYGE.jsx} +6 -6
  44. package/dist/chunk/{44EPTWQE.jsx → XENPQFEN.jsx} +7 -7
  45. package/dist/chunk/{JWPRFVT7.jsx → XSGHIZ6Q.jsx} +6 -6
  46. package/dist/chunk/{7EHWC54T.jsx → Y2LC36B4.jsx} +7 -7
  47. package/dist/chunk/{2JINNNT3.jsx → YJX4W6VT.jsx} +7 -7
  48. package/dist/chunk/{CFW2CEDK.jsx → YM35RFYG.jsx} +7 -7
  49. package/dist/chunk/{XOVDOF3R.jsx → Z2BXVXSV.jsx} +6 -6
  50. package/dist/chunk/ZHLQWQXX.jsx +253 -0
  51. package/dist/components/accordion/index.jsx +5 -5
  52. package/dist/components/angle-slider/index.jsx +4 -4
  53. package/dist/components/avatar/index.jsx +4 -4
  54. package/dist/components/carousel/index.jsx +4 -4
  55. package/dist/components/checkbox/index.jsx +6 -6
  56. package/dist/components/clipboard/index.jsx +4 -4
  57. package/dist/components/collapsible/index.jsx +4 -4
  58. package/dist/components/color-picker/index.jsx +8 -8
  59. package/dist/components/combobox/index.jsx +9 -9
  60. package/dist/components/date-picker/index.jsx +6 -6
  61. package/dist/components/dialog/index.jsx +6 -6
  62. package/dist/components/download-trigger/index.jsx +4 -4
  63. package/dist/components/editable/index.jsx +6 -6
  64. package/dist/components/field/index.jsx +5 -5
  65. package/dist/components/fieldset/index.jsx +4 -4
  66. package/dist/components/file-upload/index.jsx +6 -6
  67. package/dist/components/floating-panel/index.js +1 -1
  68. package/dist/components/floating-panel/index.jsx +6 -7
  69. package/dist/components/format/index.jsx +2 -2
  70. package/dist/components/frame/index.jsx +3 -3
  71. package/dist/components/hover-card/index.jsx +6 -6
  72. package/dist/components/index.d.ts +1 -1
  73. package/dist/components/index.js +25 -25
  74. package/dist/components/index.jsx +465 -464
  75. package/dist/components/listbox/index.d.ts +11 -6
  76. package/dist/components/listbox/index.js +1 -1
  77. package/dist/components/listbox/index.jsx +6 -5
  78. package/dist/components/menu/index.jsx +6 -6
  79. package/dist/components/number-input/index.jsx +6 -6
  80. package/dist/components/pagination/index.jsx +4 -4
  81. package/dist/components/password-input/index.js +1 -1
  82. package/dist/components/password-input/index.jsx +6 -7
  83. package/dist/components/pin-input/index.jsx +6 -6
  84. package/dist/components/popover/index.jsx +6 -6
  85. package/dist/components/presence/index.jsx +3 -3
  86. package/dist/components/progress/index.jsx +4 -4
  87. package/dist/components/qr-code/index.jsx +4 -4
  88. package/dist/components/radio-group/index.jsx +4 -4
  89. package/dist/components/rating-group/index.jsx +6 -6
  90. package/dist/components/segment-group/index.jsx +4 -4
  91. package/dist/components/select/index.jsx +9 -9
  92. package/dist/components/signature-pad/index.jsx +6 -6
  93. package/dist/components/slider/index.jsx +4 -4
  94. package/dist/components/splitter/index.jsx +4 -4
  95. package/dist/components/steps/index.jsx +4 -4
  96. package/dist/components/switch/index.jsx +6 -6
  97. package/dist/components/tabs/index.jsx +6 -6
  98. package/dist/components/tags-input/index.jsx +6 -6
  99. package/dist/components/time-picker/index.jsx +6 -6
  100. package/dist/components/timer/index.jsx +4 -4
  101. package/dist/components/toast/index.jsx +4 -4
  102. package/dist/components/toggle-group/index.jsx +4 -4
  103. package/dist/components/tooltip/index.jsx +6 -6
  104. package/dist/components/tour/index.jsx +6 -6
  105. package/dist/components/tree-view/index.jsx +6 -6
  106. package/dist/index.d.ts +1 -1
  107. package/dist/index.js +25 -25
  108. package/dist/index.jsx +443 -442
  109. package/dist/providers/environment/index.jsx +2 -2
  110. package/dist/providers/index.jsx +5 -5
  111. package/package.json +58 -53
  112. package/dist/chunk/6IL4FKPO.jsx +0 -1818
  113. package/dist/chunk/ETB2BIQZ.jsx +0 -30
  114. package/dist/chunk/I3E4ZWU3.js +0 -1065
  115. package/dist/chunk/OO4YLIXE.js +0 -352
  116. package/dist/chunk/PKUUD527.js +0 -25
  117. package/dist/chunk/VWQOTIDH.jsx +0 -1137
  118. package/dist/chunk/XWFAYRYW.jsx +0 -400
  119. package/dist/chunk/YGAFIEFX.js +0 -1706
  120. package/dist/chunk/{6J5H27AQ.jsx → E2L62MKC.jsx} +3 -3
  121. package/dist/chunk/{T67EMHNB.jsx → WC2HBDLJ.jsx} +6 -6
@@ -1,1065 +0,0 @@
1
- import { createMachine } from './PKUUD527.js';
2
- import { createSplitProps as createSplitProps$1 } from './ZMHI4GDJ.js';
3
- import { ark } from './EPLBB4QN.js';
4
- import { useLocaleContext } from './OKZ64GSY.js';
5
- import { useEnvironmentContext } from './YO2MCGXO.js';
6
- import { createContext } from './TROPIN4C.js';
7
- import { runIfFn } from './DT73WLR4.js';
8
- import { __export } from './ESLJRKWD.js';
9
- import { createComponent, mergeProps as mergeProps$1 } from 'solid-js/web';
10
- import { mergeProps, useMachine, normalizeProps } from '@zag-js/solid';
11
- import { children, createUniqueId, createMemo } from 'solid-js';
12
- import { createAnatomy } from '@zag-js/anatomy';
13
- import { Selection, ListCollection, isGridCollection } from '@zag-js/collection';
14
- import { raf, observeAttributes, getByTypeahead, getWindow, getDocument, isVirtualClick, getEventTarget, scrollIntoView, dataAttr, isSelfTarget, getEventKey, isEditableElement, ariaAttr, isCtrlOrMetaKey, isComposingEvent, getNativeEvent, isMac } from '@zag-js/dom-query';
15
- import { isEqual, createSplitProps, ensure } from '@zag-js/utils';
16
- import { createProps } from '@zag-js/types';
17
-
18
- // src/components/listbox/use-listbox-context.ts
19
- var [ListboxProvider, useListboxContext] = createContext({
20
- hookName: "useListboxContext",
21
- providerName: "<ListboxProvider />"
22
- });
23
-
24
- // src/components/listbox/listbox-context.tsx
25
- function ListboxContext(props2) {
26
- return props2.children(useListboxContext());
27
- }
28
- var ListboxContent = (props2) => {
29
- const listbox = useListboxContext();
30
- const mergedProps = mergeProps(() => listbox().getContentProps(), props2);
31
- return createComponent(ark.div, mergedProps);
32
- };
33
- var ListboxInput = (props2) => {
34
- const [inputProps, localProps] = createSplitProps$1()(props2, ["autoHighlight"]);
35
- const listbox = useListboxContext();
36
- const mergedProps = mergeProps(() => listbox().getInputProps(inputProps), localProps);
37
- return createComponent(ark.input, mergedProps);
38
- };
39
-
40
- // src/components/listbox/use-listbox-item-context.ts
41
- var [ListboxItemProvider, useListboxItemContext] = createContext({
42
- hookName: "useListboxItemContext",
43
- providerName: "<ListboxItemProvider />"
44
- });
45
-
46
- // src/components/listbox/use-listbox-item-props-context.ts
47
- var [ListboxItemPropsProvider, useListboxItemPropsContext] = createContext({
48
- hookName: "useListboxItemPropsContext",
49
- providerName: "<ListboxItemPropsProvider />"
50
- });
51
-
52
- // src/components/listbox/listbox-item.tsx
53
- var ListboxItem = (props2) => {
54
- const [itemProps2, localProps] = createSplitProps$1()(props2, ["item", "highlightOnHover"]);
55
- const listbox = useListboxContext();
56
- const mergedProps = mergeProps(() => listbox().getItemProps(itemProps2), localProps);
57
- const itemState = () => listbox().getItemState(itemProps2);
58
- return createComponent(ListboxItemPropsProvider, {
59
- value: itemProps2,
60
- get children() {
61
- return createComponent(ListboxItemProvider, {
62
- get value() {
63
- return itemState();
64
- },
65
- get children() {
66
- return createComponent(ark.div, mergedProps);
67
- }
68
- });
69
- }
70
- });
71
- };
72
-
73
- // src/components/listbox/use-listbox-item-group-props-context.ts
74
- var [ListboxItemGroupPropsProvider, useListboxItemGroupPropsContext] = createContext({
75
- hookName: "useListboxItemGroupPropsContext",
76
- providerName: "<ListboxItemGroupPropsProvider />"
77
- });
78
-
79
- // src/components/listbox/listbox-item-group.tsx
80
- var ListboxItemGroup = (props2) => {
81
- const id = createUniqueId();
82
- const [_itemGroupProps, localProps] = createSplitProps$1()(props2, ["id"]);
83
- const itemGroupProps2 = {
84
- id,
85
- ..._itemGroupProps
86
- };
87
- const listbox = useListboxContext();
88
- const mergedProps = mergeProps(() => listbox().getItemGroupProps(itemGroupProps2), localProps);
89
- return createComponent(ListboxItemGroupPropsProvider, {
90
- value: itemGroupProps2,
91
- get children() {
92
- return createComponent(ark.div, mergedProps);
93
- }
94
- });
95
- };
96
- var ListboxItemGroupLabel = (props2) => {
97
- const listbox = useListboxContext();
98
- const itemGroupProps2 = useListboxItemGroupPropsContext();
99
- const mergedProps = mergeProps(() => listbox().getItemGroupLabelProps({
100
- htmlFor: itemGroupProps2.id
101
- }), props2);
102
- return createComponent(ark.div, mergedProps);
103
- };
104
- var ListboxItemIndicator = (props2) => {
105
- const listbox = useListboxContext();
106
- const itemProps2 = useListboxItemPropsContext();
107
- const mergedProps = mergeProps(() => listbox().getItemIndicatorProps(itemProps2), props2);
108
- return createComponent(ark.div, mergedProps);
109
- };
110
- var ListboxItemText = (props2) => {
111
- const listbox = useListboxContext();
112
- const itemProps2 = useListboxItemPropsContext();
113
- const mergedProps = mergeProps(() => listbox().getItemTextProps(itemProps2), props2);
114
- return createComponent(ark.div, mergedProps);
115
- };
116
- var ListboxLabel = (props2) => {
117
- const listbox = useListboxContext();
118
- const mergedProps = mergeProps(() => listbox().getLabelProps(), props2);
119
- return createComponent(ark.label, mergedProps);
120
- };
121
- function isValidKey(e) {
122
- return !(e.metaKey || !isMac() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
123
- }
124
- var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
125
- function isKeyboardFocusEvent(isTextInput, modality, e) {
126
- const target = e ? getEventTarget(e) : null;
127
- const win = getWindow(target);
128
- isTextInput = isTextInput || target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target?.type) || target instanceof win.HTMLTextAreaElement || target instanceof win.HTMLElement && target.isContentEditable;
129
- return !(isTextInput && modality === "keyboard" && e instanceof win.KeyboardEvent && !Reflect.has(FOCUS_VISIBLE_INPUT_KEYS, e.key));
130
- }
131
- var currentModality = null;
132
- var changeHandlers = /* @__PURE__ */ new Set();
133
- var listenerMap = /* @__PURE__ */ new Map();
134
- var hasEventBeforeFocus = false;
135
- var hasBlurredWindowRecently = false;
136
- var FOCUS_VISIBLE_INPUT_KEYS = {
137
- Tab: true,
138
- Escape: true
139
- };
140
- function triggerChangeHandlers(modality, e) {
141
- for (let handler of changeHandlers) {
142
- handler(modality, e);
143
- }
144
- }
145
- function handleKeyboardEvent(e) {
146
- hasEventBeforeFocus = true;
147
- if (isValidKey(e)) {
148
- currentModality = "keyboard";
149
- triggerChangeHandlers("keyboard", e);
150
- }
151
- }
152
- function handlePointerEvent(e) {
153
- currentModality = "pointer";
154
- if (e.type === "mousedown" || e.type === "pointerdown") {
155
- hasEventBeforeFocus = true;
156
- triggerChangeHandlers("pointer", e);
157
- }
158
- }
159
- function handleClickEvent(e) {
160
- if (isVirtualClick(e)) {
161
- hasEventBeforeFocus = true;
162
- currentModality = "virtual";
163
- }
164
- }
165
- function handleFocusEvent(e) {
166
- const target = getEventTarget(e);
167
- if (target === getWindow(target) || target === getDocument(target)) {
168
- return;
169
- }
170
- if (!hasEventBeforeFocus && !hasBlurredWindowRecently) {
171
- currentModality = "virtual";
172
- triggerChangeHandlers("virtual", e);
173
- }
174
- hasEventBeforeFocus = false;
175
- hasBlurredWindowRecently = false;
176
- }
177
- function handleWindowBlur() {
178
- hasEventBeforeFocus = false;
179
- hasBlurredWindowRecently = true;
180
- }
181
- function setupGlobalFocusEvents(root) {
182
- if (typeof window === "undefined" || listenerMap.get(getWindow(root))) {
183
- return;
184
- }
185
- const win = getWindow(root);
186
- const doc = getDocument(root);
187
- let focus = win.HTMLElement.prototype.focus;
188
- function patchedFocus() {
189
- currentModality = "virtual";
190
- triggerChangeHandlers("virtual", null);
191
- hasEventBeforeFocus = true;
192
- focus.apply(this, arguments);
193
- }
194
- Object.defineProperty(win.HTMLElement.prototype, "focus", {
195
- configurable: true,
196
- value: patchedFocus
197
- });
198
- doc.addEventListener("keydown", handleKeyboardEvent, true);
199
- doc.addEventListener("keyup", handleKeyboardEvent, true);
200
- doc.addEventListener("click", handleClickEvent, true);
201
- win.addEventListener("focus", handleFocusEvent, true);
202
- win.addEventListener("blur", handleWindowBlur, false);
203
- if (typeof win.PointerEvent !== "undefined") {
204
- doc.addEventListener("pointerdown", handlePointerEvent, true);
205
- doc.addEventListener("pointermove", handlePointerEvent, true);
206
- doc.addEventListener("pointerup", handlePointerEvent, true);
207
- } else {
208
- doc.addEventListener("mousedown", handlePointerEvent, true);
209
- doc.addEventListener("mousemove", handlePointerEvent, true);
210
- doc.addEventListener("mouseup", handlePointerEvent, true);
211
- }
212
- win.addEventListener(
213
- "beforeunload",
214
- () => {
215
- tearDownWindowFocusTracking(root);
216
- },
217
- { once: true }
218
- );
219
- listenerMap.set(win, { focus });
220
- }
221
- var tearDownWindowFocusTracking = (root, loadListener) => {
222
- const win = getWindow(root);
223
- const doc = getDocument(root);
224
- if (!listenerMap.has(win)) {
225
- return;
226
- }
227
- win.HTMLElement.prototype.focus = listenerMap.get(win).focus;
228
- doc.removeEventListener("keydown", handleKeyboardEvent, true);
229
- doc.removeEventListener("keyup", handleKeyboardEvent, true);
230
- doc.removeEventListener("click", handleClickEvent, true);
231
- win.removeEventListener("focus", handleFocusEvent, true);
232
- win.removeEventListener("blur", handleWindowBlur, false);
233
- if (typeof win.PointerEvent !== "undefined") {
234
- doc.removeEventListener("pointerdown", handlePointerEvent, true);
235
- doc.removeEventListener("pointermove", handlePointerEvent, true);
236
- doc.removeEventListener("pointerup", handlePointerEvent, true);
237
- } else {
238
- doc.removeEventListener("mousedown", handlePointerEvent, true);
239
- doc.removeEventListener("mousemove", handlePointerEvent, true);
240
- doc.removeEventListener("mouseup", handlePointerEvent, true);
241
- }
242
- listenerMap.delete(win);
243
- };
244
- function getInteractionModality() {
245
- return currentModality;
246
- }
247
- function isFocusVisible() {
248
- return currentModality === "keyboard";
249
- }
250
- function trackFocusVisible(props2 = {}) {
251
- const { isTextInput, autoFocus, onChange, root } = props2;
252
- setupGlobalFocusEvents(root);
253
- onChange?.({ isFocusVisible: autoFocus || isFocusVisible(), modality: currentModality });
254
- const handler = (modality, e) => {
255
- if (!isKeyboardFocusEvent(!!isTextInput, modality, e)) return;
256
- onChange?.({ isFocusVisible: isFocusVisible(), modality });
257
- };
258
- changeHandlers.add(handler);
259
- return () => {
260
- changeHandlers.delete(handler);
261
- };
262
- }
263
- var anatomy = createAnatomy("listbox").parts(
264
- "label",
265
- "input",
266
- "item",
267
- "itemText",
268
- "itemIndicator",
269
- "itemGroup",
270
- "itemGroupLabel",
271
- "content",
272
- "root",
273
- "valueText"
274
- );
275
- var parts = anatomy.build();
276
- var collection = (options) => {
277
- return new ListCollection(options);
278
- };
279
- collection.empty = () => {
280
- return new ListCollection({ items: [] });
281
- };
282
- var getRootId = (ctx) => ctx.ids?.root ?? `select:${ctx.id}`;
283
- var getContentId = (ctx) => ctx.ids?.content ?? `select:${ctx.id}:content`;
284
- var getLabelId = (ctx) => ctx.ids?.label ?? `select:${ctx.id}:label`;
285
- var getItemId = (ctx, id) => ctx.ids?.item?.(id) ?? `select:${ctx.id}:option:${id}`;
286
- var getItemGroupId = (ctx, id) => ctx.ids?.itemGroup?.(id) ?? `select:${ctx.id}:optgroup:${id}`;
287
- var getItemGroupLabelId = (ctx, id) => ctx.ids?.itemGroupLabel?.(id) ?? `select:${ctx.id}:optgroup-label:${id}`;
288
- var getContentEl = (ctx) => ctx.getById(getContentId(ctx));
289
- var getItemEl = (ctx, id) => ctx.getById(getItemId(ctx, id));
290
- function connect(service, normalize) {
291
- const { context, prop, scope, computed, send } = service;
292
- const disabled = prop("disabled");
293
- const collection2 = prop("collection");
294
- const layout = isGridCollection(collection2) ? "grid" : "list";
295
- const value = context.get("value");
296
- const highlightedValue = context.get("highlightedValue");
297
- const highlightedItem = context.get("highlightedItem");
298
- const selectedItems = context.get("selectedItems");
299
- const isTypingAhead = computed("isTypingAhead");
300
- const interactive = computed("isInteractive");
301
- const ariaActiveDescendant = highlightedValue ? getItemId(scope, highlightedValue) : void 0;
302
- function getItemState(props2) {
303
- const itemDisabled = collection2.getItemDisabled(props2.item);
304
- const value2 = collection2.getItemValue(props2.item);
305
- ensure(value2, () => `[zag-js] No value found for item ${JSON.stringify(props2.item)}`);
306
- return {
307
- value: value2,
308
- disabled: Boolean(disabled || itemDisabled),
309
- highlighted: highlightedValue === value2 && context.get("focused"),
310
- selected: context.get("value").includes(value2)
311
- };
312
- }
313
- return {
314
- empty: value.length === 0,
315
- highlightedItem,
316
- highlightedValue,
317
- clearHighlightedValue() {
318
- send({ type: "HIGHLIGHTED_VALUE.SET", value: null });
319
- },
320
- selectedItems,
321
- hasSelectedItems: computed("hasSelectedItems"),
322
- value,
323
- valueAsString: context.get("valueAsString"),
324
- collection: collection2,
325
- disabled: !!disabled,
326
- selectValue(value2) {
327
- send({ type: "ITEM.SELECT", value: value2 });
328
- },
329
- setValue(value2) {
330
- send({ type: "VALUE.SET", value: value2 });
331
- },
332
- selectAll() {
333
- if (!computed("multiple")) {
334
- throw new Error("[zag-js] Cannot select all items in a single-select listbox");
335
- }
336
- send({ type: "VALUE.SET", value: collection2.getValues() });
337
- },
338
- highlightValue(value2) {
339
- send({ type: "HIGHLIGHTED_VALUE.SET", value: value2 });
340
- },
341
- clearValue(value2) {
342
- if (value2) {
343
- send({ type: "ITEM.CLEAR", value: value2 });
344
- } else {
345
- send({ type: "VALUE.CLEAR" });
346
- }
347
- },
348
- getItemState,
349
- getRootProps() {
350
- return normalize.element({
351
- ...parts.root.attrs,
352
- dir: prop("dir"),
353
- id: getRootId(scope),
354
- "data-orientation": prop("orientation"),
355
- "data-disabled": dataAttr(disabled)
356
- });
357
- },
358
- getInputProps(props2 = {}) {
359
- return normalize.input({
360
- ...parts.input.attrs,
361
- dir: prop("dir"),
362
- disabled,
363
- "data-disabled": dataAttr(disabled),
364
- autoComplete: "off",
365
- autoCorrect: "off",
366
- "aria-haspopup": "listbox",
367
- "aria-controls": getContentId(scope),
368
- "aria-autocomplete": "list",
369
- "aria-activedescendant": ariaActiveDescendant,
370
- spellCheck: false,
371
- enterKeyHint: "go",
372
- onFocus() {
373
- queueMicrotask(() => {
374
- const contentEl = getContentEl(scope);
375
- const win = getWindow(contentEl);
376
- const focusInEvt = new win.FocusEvent("focusin", { bubbles: true, cancelable: true });
377
- contentEl?.dispatchEvent(focusInEvt);
378
- });
379
- },
380
- onBlur(event) {
381
- if (event.defaultPrevented) return;
382
- const contentEl = getContentEl(scope);
383
- const win = getWindow(contentEl);
384
- const focusOutEvt = new win.FocusEvent("focusout", { bubbles: true, cancelable: true });
385
- contentEl?.dispatchEvent(focusOutEvt);
386
- },
387
- onInput(event) {
388
- if (!props2.autoHighlight) return;
389
- const node = event.currentTarget;
390
- queueMicrotask(() => {
391
- if (!node.isConnected) return;
392
- send({
393
- type: "HIGHLIGHTED_VALUE.SET",
394
- value: node.value ? prop("collection").firstValue : null
395
- });
396
- });
397
- },
398
- onKeyDown(event) {
399
- if (event.defaultPrevented) return;
400
- if (isComposingEvent(event)) return;
401
- const nativeEvent = getNativeEvent(event);
402
- switch (nativeEvent.key) {
403
- case "ArrowDown":
404
- case "ArrowUp":
405
- case "Home":
406
- case "End": {
407
- if ((event.key === "Home" || event.key === "End") && !highlightedValue && event.shiftKey) {
408
- return;
409
- }
410
- event.preventDefault();
411
- const win = scope.getWin();
412
- const keyboardEvent = new win.KeyboardEvent(nativeEvent.type, nativeEvent);
413
- getContentEl(scope)?.dispatchEvent(keyboardEvent);
414
- break;
415
- }
416
- case "Enter":
417
- event.preventDefault();
418
- send({ type: "ITEM.CLICK", value: highlightedValue });
419
- break;
420
- }
421
- }
422
- });
423
- },
424
- getLabelProps() {
425
- return normalize.element({
426
- dir: prop("dir"),
427
- id: getLabelId(scope),
428
- ...parts.label.attrs,
429
- "data-disabled": dataAttr(disabled)
430
- });
431
- },
432
- getValueTextProps() {
433
- return normalize.element({
434
- ...parts.valueText.attrs,
435
- dir: prop("dir"),
436
- "data-disabled": dataAttr(disabled)
437
- });
438
- },
439
- getItemProps(props2) {
440
- const itemState = getItemState(props2);
441
- return normalize.element({
442
- id: getItemId(scope, itemState.value),
443
- role: "option",
444
- ...parts.item.attrs,
445
- dir: prop("dir"),
446
- "data-value": itemState.value,
447
- "aria-selected": itemState.selected,
448
- "data-selected": dataAttr(itemState.selected),
449
- "data-layout": layout,
450
- "data-state": itemState.selected ? "checked" : "unchecked",
451
- "data-orientation": prop("orientation"),
452
- "data-highlighted": dataAttr(itemState.highlighted),
453
- "data-disabled": dataAttr(itemState.disabled),
454
- "aria-disabled": ariaAttr(itemState.disabled),
455
- onPointerMove(event) {
456
- if (!props2.highlightOnHover) return;
457
- if (itemState.disabled || event.pointerType !== "mouse") return;
458
- if (itemState.highlighted) return;
459
- send({ type: "ITEM.POINTER_MOVE", value: itemState.value });
460
- },
461
- onMouseDown(event) {
462
- event.preventDefault();
463
- getContentEl(scope)?.focus();
464
- },
465
- onClick(event) {
466
- if (event.defaultPrevented) return;
467
- if (itemState.disabled) return;
468
- send({
469
- type: "ITEM.CLICK",
470
- value: itemState.value,
471
- shiftKey: event.shiftKey,
472
- anchorValue: highlightedValue,
473
- metaKey: isCtrlOrMetaKey(event)
474
- });
475
- }
476
- });
477
- },
478
- getItemTextProps(props2) {
479
- const itemState = getItemState(props2);
480
- return normalize.element({
481
- ...parts.itemText.attrs,
482
- "data-state": itemState.selected ? "checked" : "unchecked",
483
- "data-disabled": dataAttr(itemState.disabled),
484
- "data-highlighted": dataAttr(itemState.highlighted)
485
- });
486
- },
487
- getItemIndicatorProps(props2) {
488
- const itemState = getItemState(props2);
489
- return normalize.element({
490
- ...parts.itemIndicator.attrs,
491
- "aria-hidden": true,
492
- "data-state": itemState.selected ? "checked" : "unchecked",
493
- hidden: !itemState.selected
494
- });
495
- },
496
- getItemGroupLabelProps(props2) {
497
- const { htmlFor } = props2;
498
- return normalize.element({
499
- ...parts.itemGroupLabel.attrs,
500
- id: getItemGroupLabelId(scope, htmlFor),
501
- dir: prop("dir"),
502
- role: "presentation"
503
- });
504
- },
505
- getItemGroupProps(props2) {
506
- const { id } = props2;
507
- return normalize.element({
508
- ...parts.itemGroup.attrs,
509
- "data-disabled": dataAttr(disabled),
510
- "data-orientation": prop("orientation"),
511
- "data-empty": dataAttr(collection2.size === 0),
512
- id: getItemGroupId(scope, id),
513
- "aria-labelledby": getItemGroupLabelId(scope, id),
514
- role: "group",
515
- dir: prop("dir")
516
- });
517
- },
518
- getContentProps() {
519
- return normalize.element({
520
- dir: prop("dir"),
521
- id: getContentId(scope),
522
- role: "listbox",
523
- ...parts.content.attrs,
524
- "data-activedescendant": ariaActiveDescendant,
525
- "aria-activedescendant": ariaActiveDescendant,
526
- "data-orientation": prop("orientation"),
527
- "aria-multiselectable": computed("multiple") ? true : void 0,
528
- "aria-labelledby": getLabelId(scope),
529
- tabIndex: 0,
530
- "data-layout": layout,
531
- "data-empty": dataAttr(collection2.size === 0),
532
- style: {
533
- "--column-count": isGridCollection(collection2) ? collection2.columnCount : 1
534
- },
535
- onFocus() {
536
- send({ type: "CONTENT.FOCUS" });
537
- },
538
- onBlur() {
539
- send({ type: "CONTENT.BLUR" });
540
- },
541
- onKeyDown(event) {
542
- if (!interactive) return;
543
- if (!isSelfTarget(event)) return;
544
- const shiftKey = event.shiftKey;
545
- const keyMap = {
546
- ArrowUp(event2) {
547
- let nextValue = null;
548
- if (isGridCollection(collection2) && highlightedValue) {
549
- nextValue = collection2.getPreviousRowValue(highlightedValue);
550
- } else if (highlightedValue) {
551
- nextValue = collection2.getPreviousValue(highlightedValue);
552
- }
553
- if (!nextValue && (prop("loopFocus") || !highlightedValue)) {
554
- nextValue = collection2.lastValue;
555
- }
556
- if (!nextValue) return;
557
- event2.preventDefault();
558
- send({ type: "NAVIGATE", value: nextValue, shiftKey, anchorValue: highlightedValue });
559
- },
560
- ArrowDown(event2) {
561
- let nextValue = null;
562
- if (isGridCollection(collection2) && highlightedValue) {
563
- nextValue = collection2.getNextRowValue(highlightedValue);
564
- } else if (highlightedValue) {
565
- nextValue = collection2.getNextValue(highlightedValue);
566
- }
567
- if (!nextValue && (prop("loopFocus") || !highlightedValue)) {
568
- nextValue = collection2.firstValue;
569
- }
570
- if (!nextValue) return;
571
- event2.preventDefault();
572
- send({ type: "NAVIGATE", value: nextValue, shiftKey, anchorValue: highlightedValue });
573
- },
574
- ArrowLeft() {
575
- if (!isGridCollection(collection2) && prop("orientation") === "vertical") return;
576
- let nextValue = highlightedValue ? collection2.getPreviousValue(highlightedValue) : null;
577
- if (!nextValue && prop("loopFocus")) {
578
- nextValue = collection2.lastValue;
579
- }
580
- if (!nextValue) return;
581
- event.preventDefault();
582
- send({ type: "NAVIGATE", value: nextValue, shiftKey, anchorValue: highlightedValue });
583
- },
584
- ArrowRight() {
585
- if (!isGridCollection(collection2) && prop("orientation") === "vertical") return;
586
- let nextValue = highlightedValue ? collection2.getNextValue(highlightedValue) : null;
587
- if (!nextValue && prop("loopFocus")) {
588
- nextValue = collection2.firstValue;
589
- }
590
- if (!nextValue) return;
591
- event.preventDefault();
592
- send({ type: "NAVIGATE", value: nextValue, shiftKey, anchorValue: highlightedValue });
593
- },
594
- Home(event2) {
595
- event2.preventDefault();
596
- let nextValue = collection2.firstValue;
597
- send({ type: "NAVIGATE", value: nextValue, shiftKey, anchorValue: highlightedValue });
598
- },
599
- End(event2) {
600
- event2.preventDefault();
601
- let nextValue = collection2.lastValue;
602
- send({ type: "NAVIGATE", value: nextValue, shiftKey, anchorValue: highlightedValue });
603
- },
604
- Enter() {
605
- send({ type: "ITEM.CLICK", value: highlightedValue });
606
- },
607
- a(event2) {
608
- if (isCtrlOrMetaKey(event2) && computed("multiple") && !prop("disallowSelectAll")) {
609
- event2.preventDefault();
610
- send({ type: "VALUE.SET", value: collection2.getValues() });
611
- }
612
- },
613
- Space(event2) {
614
- if (isTypingAhead && prop("typeahead")) {
615
- send({ type: "CONTENT.TYPEAHEAD", key: event2.key });
616
- } else {
617
- keyMap.Enter?.(event2);
618
- }
619
- },
620
- Escape(event2) {
621
- if (prop("deselectable") && value.length > 0) {
622
- event2.preventDefault();
623
- event2.stopPropagation();
624
- send({ type: "VALUE.CLEAR" });
625
- }
626
- }
627
- };
628
- const exec = keyMap[getEventKey(event)];
629
- if (exec) {
630
- exec(event);
631
- return;
632
- }
633
- const target = getEventTarget(event);
634
- if (isEditableElement(target)) {
635
- return;
636
- }
637
- if (getByTypeahead.isValidEvent(event) && prop("typeahead")) {
638
- send({ type: "CONTENT.TYPEAHEAD", key: event.key });
639
- event.preventDefault();
640
- }
641
- }
642
- });
643
- }
644
- };
645
- }
646
- var machine = createMachine({
647
- props({ props: props2 }) {
648
- return {
649
- loopFocus: false,
650
- composite: true,
651
- defaultValue: [],
652
- multiple: false,
653
- typeahead: true,
654
- collection: collection.empty(),
655
- orientation: "vertical",
656
- selectionMode: "single",
657
- ...props2
658
- };
659
- },
660
- context({ prop, bindable }) {
661
- return {
662
- value: bindable(() => ({
663
- defaultValue: prop("defaultValue"),
664
- value: prop("value"),
665
- isEqual,
666
- onChange(value) {
667
- const items = prop("collection").findMany(value);
668
- return prop("onValueChange")?.({ value, items });
669
- }
670
- })),
671
- highlightedValue: bindable(() => ({
672
- defaultValue: prop("defaultHighlightedValue") || null,
673
- value: prop("highlightedValue"),
674
- sync: true,
675
- onChange(value) {
676
- prop("onHighlightChange")?.({
677
- highlightedValue: value,
678
- highlightedItem: prop("collection").find(value),
679
- highlightedIndex: prop("collection").indexOf(value)
680
- });
681
- }
682
- })),
683
- highlightedItem: bindable(() => ({
684
- defaultValue: null
685
- })),
686
- selectedItems: bindable(() => {
687
- const value = prop("value") ?? prop("defaultValue") ?? [];
688
- const items = prop("collection").findMany(value);
689
- return { defaultValue: items };
690
- }),
691
- valueAsString: bindable(() => {
692
- const value = prop("value") ?? prop("defaultValue") ?? [];
693
- return { defaultValue: prop("collection").stringifyMany(value) };
694
- }),
695
- focused: bindable(() => ({
696
- defaultValue: false
697
- }))
698
- };
699
- },
700
- refs({ prop }) {
701
- return {
702
- typeahead: { ...getByTypeahead.defaultOptions },
703
- prevCollection: prop("collection")
704
- };
705
- },
706
- computed: {
707
- hasSelectedItems: ({ context }) => context.get("value").length > 0,
708
- isTypingAhead: ({ refs }) => refs.get("typeahead").keysSoFar !== "",
709
- isInteractive: ({ prop }) => !prop("disabled"),
710
- selection: ({ context, prop }) => {
711
- const selection = new Selection(context.get("value"));
712
- selection.selectionMode = prop("selectionMode");
713
- selection.deselectable = !!prop("deselectable");
714
- return selection;
715
- },
716
- multiple: ({ prop }) => prop("selectionMode") === "multiple" || prop("selectionMode") === "extended"
717
- },
718
- initialState() {
719
- return "idle";
720
- },
721
- watch({ context, prop, track, action }) {
722
- track([() => context.get("value").toString()], () => {
723
- action(["syncSelectedItems"]);
724
- });
725
- track([() => context.get("highlightedValue")], () => {
726
- action(["syncHighlightedItem"]);
727
- });
728
- track([() => prop("collection").toString()], () => {
729
- action(["syncCollection"]);
730
- });
731
- },
732
- effects: ["trackFocusVisible"],
733
- on: {
734
- "HIGHLIGHTED_VALUE.SET": {
735
- actions: ["setHighlightedItem"]
736
- },
737
- "ITEM.SELECT": {
738
- actions: ["selectItem"]
739
- },
740
- "ITEM.CLEAR": {
741
- actions: ["clearItem"]
742
- },
743
- "VALUE.SET": {
744
- actions: ["setSelectedItems"]
745
- },
746
- "VALUE.CLEAR": {
747
- actions: ["clearSelectedItems"]
748
- },
749
- "CLEAR.CLICK": {
750
- actions: ["clearSelectedItems"]
751
- }
752
- },
753
- states: {
754
- idle: {
755
- effects: ["scrollToHighlightedItem"],
756
- on: {
757
- "CONTENT.FOCUS": {
758
- actions: ["setFocused"]
759
- },
760
- "CONTENT.BLUR": {
761
- actions: ["clearFocused"]
762
- },
763
- "ITEM.CLICK": {
764
- actions: ["setHighlightedItem", "selectHighlightedItem"]
765
- },
766
- "CONTENT.TYPEAHEAD": {
767
- actions: ["highlightMatchingItem"]
768
- },
769
- "ITEM.POINTER_MOVE": {
770
- actions: ["highlightItem"]
771
- },
772
- "ITEM.POINTER_LEAVE": {
773
- actions: ["clearHighlightedItem"]
774
- },
775
- NAVIGATE: {
776
- actions: ["setHighlightedItem", "selectWithKeyboard"]
777
- }
778
- }
779
- }
780
- },
781
- implementations: {
782
- effects: {
783
- trackFocusVisible: ({ scope }) => {
784
- return trackFocusVisible({ root: scope.getRootNode?.() });
785
- },
786
- scrollToHighlightedItem({ context, prop, scope }) {
787
- const exec = (immediate) => {
788
- const highlightedValue = context.get("highlightedValue");
789
- if (highlightedValue == null) return;
790
- const modality = getInteractionModality();
791
- if (modality !== "keyboard") return;
792
- const itemEl = getItemEl(scope, highlightedValue);
793
- const contentEl2 = getContentEl(scope);
794
- const scrollToIndexFn = prop("scrollToIndexFn");
795
- if (scrollToIndexFn) {
796
- const highlightedIndex = prop("collection").indexOf(highlightedValue);
797
- scrollToIndexFn?.({ index: highlightedIndex, immediate });
798
- return;
799
- }
800
- scrollIntoView(itemEl, { rootEl: contentEl2, block: "nearest" });
801
- };
802
- raf(() => exec(true));
803
- const contentEl = () => getContentEl(scope);
804
- return observeAttributes(contentEl, {
805
- defer: true,
806
- attributes: ["data-activedescendant"],
807
- callback() {
808
- exec(false);
809
- }
810
- });
811
- }
812
- },
813
- actions: {
814
- selectHighlightedItem({ context, prop, event, computed }) {
815
- const value = event.value ?? context.get("highlightedValue");
816
- if (value == null) return;
817
- const selection = computed("selection");
818
- const collection2 = prop("collection");
819
- if (event.shiftKey && computed("multiple") && event.anchorValue) {
820
- const next = selection.extendSelection(collection2, event.anchorValue, value);
821
- invokeOnSelect(selection, next, prop("onSelect"));
822
- context.set("value", Array.from(next));
823
- } else {
824
- const next = selection.select(collection2, value, event.metaKey);
825
- invokeOnSelect(selection, next, prop("onSelect"));
826
- context.set("value", Array.from(next));
827
- }
828
- },
829
- selectWithKeyboard({ context, prop, event, computed }) {
830
- const selection = computed("selection");
831
- const collection2 = prop("collection");
832
- if (event.shiftKey && computed("multiple") && event.anchorValue) {
833
- const next = selection.extendSelection(collection2, event.anchorValue, event.value);
834
- invokeOnSelect(selection, next, prop("onSelect"));
835
- context.set("value", Array.from(next));
836
- return;
837
- }
838
- if (prop("selectOnHighlight")) {
839
- const next = selection.replaceSelection(collection2, event.value);
840
- invokeOnSelect(selection, next, prop("onSelect"));
841
- context.set("value", Array.from(next));
842
- }
843
- },
844
- highlightItem({ context, event }) {
845
- context.set("highlightedValue", event.value);
846
- },
847
- highlightMatchingItem({ context, prop, event, refs }) {
848
- const value = prop("collection").search(event.key, {
849
- state: refs.get("typeahead"),
850
- currentValue: context.get("highlightedValue")
851
- });
852
- if (value == null) return;
853
- context.set("highlightedValue", value);
854
- },
855
- setHighlightedItem({ context, event }) {
856
- context.set("highlightedValue", event.value);
857
- },
858
- clearHighlightedItem({ context }) {
859
- context.set("highlightedValue", null);
860
- },
861
- selectItem({ context, prop, event, computed }) {
862
- const collection2 = prop("collection");
863
- const selection = computed("selection");
864
- const next = selection.select(collection2, event.value);
865
- invokeOnSelect(selection, next, prop("onSelect"));
866
- context.set("value", Array.from(next));
867
- },
868
- clearItem({ context, event, computed }) {
869
- const selection = computed("selection");
870
- const value = selection.deselect(event.value);
871
- context.set("value", Array.from(value));
872
- },
873
- setSelectedItems({ context, event }) {
874
- context.set("value", event.value);
875
- },
876
- clearSelectedItems({ context }) {
877
- context.set("value", []);
878
- },
879
- syncCollection({ context, prop, refs }) {
880
- const collection2 = prop("collection");
881
- const highlightedItem = collection2.find(context.get("highlightedValue"));
882
- if (highlightedItem) context.set("highlightedItem", highlightedItem);
883
- const selectedItems = collection2.findMany(context.get("value"));
884
- context.set("selectedItems", selectedItems);
885
- const valueAsString = collection2.stringifyItems(selectedItems);
886
- context.set("valueAsString", valueAsString);
887
- const highlightedValue = syncHighlightedValue(
888
- collection2,
889
- refs.get("prevCollection"),
890
- context.get("highlightedValue")
891
- );
892
- queueMicrotask(() => {
893
- context.set("highlightedValue", highlightedValue);
894
- refs.set("prevCollection", collection2);
895
- });
896
- },
897
- syncSelectedItems({ context, prop }) {
898
- const collection2 = prop("collection");
899
- const prevSelectedItems = context.get("selectedItems");
900
- const value = context.get("value");
901
- const selectedItems = value.map((value2) => {
902
- const item = prevSelectedItems.find((item2) => collection2.getItemValue(item2) === value2);
903
- return item || collection2.find(value2);
904
- });
905
- context.set("selectedItems", selectedItems);
906
- context.set("valueAsString", collection2.stringifyItems(selectedItems));
907
- },
908
- syncHighlightedItem({ context, prop }) {
909
- const collection2 = prop("collection");
910
- const highlightedValue = context.get("highlightedValue");
911
- const highlightedItem = highlightedValue ? collection2.find(highlightedValue) : null;
912
- context.set("highlightedItem", highlightedItem);
913
- },
914
- setFocused({ context }) {
915
- context.set("focused", true);
916
- },
917
- clearFocused({ context }) {
918
- context.set("focused", false);
919
- }
920
- }
921
- }
922
- });
923
- var diff = (a, b) => {
924
- const result = new Set(a);
925
- for (const item of b) result.delete(item);
926
- return result;
927
- };
928
- function invokeOnSelect(current, next, onSelect) {
929
- const added = diff(next, current);
930
- for (const item of added) {
931
- onSelect?.({ value: item });
932
- }
933
- }
934
- function syncHighlightedValue(collection2, prevCollection, highlightedValue) {
935
- if (highlightedValue != null && !collection2.find(highlightedValue) && prevCollection) {
936
- const startIndex = prevCollection.indexOf(highlightedValue);
937
- const prevItems = [...prevCollection.items];
938
- const items = [...collection2.items];
939
- const diff2 = (prevItems?.length ?? 0) - (items?.length ?? 0);
940
- let index = Math.min(
941
- diff2 > 1 ? Math.max((startIndex ?? 0) - diff2 + 1, 0) : startIndex ?? 0,
942
- (items?.length ?? 0) - 1
943
- );
944
- let newValue = null;
945
- let isReverseSearching = false;
946
- while (index >= 0) {
947
- if (!collection2.getItemDisabled(items[index])) {
948
- newValue = collection2.getItemValue(items[index]);
949
- break;
950
- }
951
- if (index < items.length - 1 && !isReverseSearching) {
952
- index++;
953
- } else {
954
- isReverseSearching = true;
955
- if (index > (startIndex ?? 0)) {
956
- index = startIndex ?? 0;
957
- }
958
- index--;
959
- }
960
- }
961
- return newValue;
962
- }
963
- return null;
964
- }
965
- var props = createProps()([
966
- "collection",
967
- "defaultHighlightedValue",
968
- "defaultValue",
969
- "dir",
970
- "disabled",
971
- "deselectable",
972
- "disallowSelectAll",
973
- "getRootNode",
974
- "highlightedValue",
975
- "id",
976
- "ids",
977
- "loopFocus",
978
- "onHighlightChange",
979
- "onSelect",
980
- "onValueChange",
981
- "orientation",
982
- "scrollToIndexFn",
983
- "selectionMode",
984
- "selectOnHighlight",
985
- "typeahead",
986
- "value"
987
- ]);
988
- createSplitProps(props);
989
- var itemProps = createProps()(["item", "highlightOnHover"]);
990
- createSplitProps(itemProps);
991
- var itemGroupProps = createProps()(["id"]);
992
- createSplitProps(itemGroupProps);
993
- var itemGroupLabelProps = createProps()(["htmlFor"]);
994
- createSplitProps(itemGroupLabelProps);
995
- var useListbox = (props2) => {
996
- const id = createUniqueId();
997
- const locale = useLocaleContext();
998
- const environment = useEnvironmentContext();
999
- const machineProps = createMemo(() => ({
1000
- id,
1001
- dir: locale().dir,
1002
- getRootNode: environment().getRootNode,
1003
- ...runIfFn(props2)
1004
- }));
1005
- const service = useMachine(machine, machineProps);
1006
- return createMemo(() => connect(service, normalizeProps));
1007
- };
1008
-
1009
- // src/components/listbox/listbox-root.tsx
1010
- var ListboxRoot = (props2) => {
1011
- const [useListboxProps, localProps] = createSplitProps$1()(props2, ["collection", "defaultHighlightedValue", "defaultValue", "deselectable", "disabled", "disallowSelectAll", "highlightedValue", "id", "ids", "loopFocus", "onHighlightChange", "onSelect", "onValueChange", "orientation", "scrollToIndexFn", "selectionMode", "selectOnHighlight", "typeahead", "value"]);
1012
- const listbox = useListbox(useListboxProps);
1013
- const mergedProps = mergeProps(() => listbox().getRootProps(), localProps);
1014
- return createComponent(ListboxProvider, {
1015
- value: listbox,
1016
- get children() {
1017
- return createComponent(ark.div, mergedProps);
1018
- }
1019
- });
1020
- };
1021
- var ListboxRootProvider = (props2) => {
1022
- const [{
1023
- value: listbox
1024
- }, localProps] = createSplitProps$1()(props2, ["value"]);
1025
- const mergedProps = mergeProps(() => listbox().getRootProps(), localProps);
1026
- return createComponent(ListboxProvider, {
1027
- value: listbox,
1028
- get children() {
1029
- return createComponent(ark.div, mergedProps);
1030
- }
1031
- });
1032
- };
1033
- var ListboxValueText = (props2) => {
1034
- const {
1035
- placeholder,
1036
- ...localprops
1037
- } = props2;
1038
- const listbox = useListboxContext();
1039
- const mergedProps = mergeProps(() => listbox().getValueTextProps(), localprops);
1040
- const resolved = children(() => props2.children);
1041
- return createComponent(ark.span, mergeProps$1(mergedProps, {
1042
- get children() {
1043
- return resolved() || listbox().valueAsString || placeholder;
1044
- }
1045
- }));
1046
- };
1047
-
1048
- // src/components/listbox/listbox.ts
1049
- var listbox_exports = {};
1050
- __export(listbox_exports, {
1051
- Content: () => ListboxContent,
1052
- Context: () => ListboxContext,
1053
- Input: () => ListboxInput,
1054
- Item: () => ListboxItem,
1055
- ItemGroup: () => ListboxItemGroup,
1056
- ItemGroupLabel: () => ListboxItemGroupLabel,
1057
- ItemIndicator: () => ListboxItemIndicator,
1058
- ItemText: () => ListboxItemText,
1059
- Label: () => ListboxLabel,
1060
- Root: () => ListboxRoot,
1061
- RootProvider: () => ListboxRootProvider,
1062
- ValueText: () => ListboxValueText
1063
- });
1064
-
1065
- export { ListboxContent, ListboxContext, ListboxInput, ListboxItem, ListboxItemGroup, ListboxItemGroupLabel, ListboxItemIndicator, ListboxItemText, ListboxLabel, ListboxRoot, ListboxRootProvider, ListboxValueText, anatomy, listbox_exports, useListbox, useListboxContext, useListboxItemContext };