@dxos/react-ui-searchlist 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe

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 (55) hide show
  1. package/dist/lib/browser/index.mjs +246 -131
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +246 -131
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/Combobox/Combobox.d.ts +44 -0
  8. package/dist/types/src/components/Combobox/Combobox.d.ts.map +1 -0
  9. package/dist/types/src/{composites/PopoverCombobox.stories.d.ts → components/Combobox/Combobox.stories.d.ts} +10 -2
  10. package/dist/types/src/components/Combobox/Combobox.stories.d.ts.map +1 -0
  11. package/dist/types/src/components/Combobox/index.d.ts +2 -0
  12. package/dist/types/src/components/Combobox/index.d.ts.map +1 -0
  13. package/dist/types/src/components/Listbox/Listbox.d.ts +31 -0
  14. package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -0
  15. package/dist/types/src/components/Listbox/Listbox.stories.d.ts +21 -0
  16. package/dist/types/src/components/Listbox/Listbox.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/Listbox/index.d.ts +2 -0
  18. package/dist/types/src/components/Listbox/index.d.ts.map +1 -0
  19. package/dist/types/src/components/{SearchList.d.ts → SearchList/SearchList.d.ts} +7 -27
  20. package/dist/types/src/components/SearchList/SearchList.d.ts.map +1 -0
  21. package/dist/types/src/components/{SearchList.stories.d.ts → SearchList/SearchList.stories.d.ts} +9 -1
  22. package/dist/types/src/components/SearchList/SearchList.stories.d.ts.map +1 -0
  23. package/dist/types/src/components/SearchList/index.d.ts +2 -0
  24. package/dist/types/src/components/SearchList/index.d.ts.map +1 -0
  25. package/dist/types/src/components/index.d.ts +2 -0
  26. package/dist/types/src/components/index.d.ts.map +1 -1
  27. package/dist/types/src/index.d.ts +0 -1
  28. package/dist/types/src/index.d.ts.map +1 -1
  29. package/dist/types/src/translations.d.ts +3 -1
  30. package/dist/types/src/translations.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +16 -14
  33. package/src/components/Combobox/Combobox.stories.tsx +57 -0
  34. package/src/components/Combobox/Combobox.tsx +335 -0
  35. package/src/components/Combobox/index.ts +5 -0
  36. package/src/components/Listbox/Listbox.stories.tsx +53 -0
  37. package/src/components/Listbox/Listbox.tsx +209 -0
  38. package/src/components/Listbox/index.ts +5 -0
  39. package/src/components/{SearchList.stories.tsx → SearchList/SearchList.stories.tsx} +17 -10
  40. package/src/components/SearchList/SearchList.tsx +163 -0
  41. package/src/components/SearchList/index.ts +5 -0
  42. package/src/components/index.ts +2 -0
  43. package/src/index.ts +0 -1
  44. package/src/translations.ts +3 -1
  45. package/dist/types/src/components/SearchList.d.ts.map +0 -1
  46. package/dist/types/src/components/SearchList.stories.d.ts.map +0 -1
  47. package/dist/types/src/composites/PopoverCombobox.d.ts +0 -32
  48. package/dist/types/src/composites/PopoverCombobox.d.ts.map +0 -1
  49. package/dist/types/src/composites/PopoverCombobox.stories.d.ts.map +0 -1
  50. package/dist/types/src/composites/index.d.ts +0 -2
  51. package/dist/types/src/composites/index.d.ts.map +0 -1
  52. package/src/components/SearchList.tsx +0 -253
  53. package/src/composites/PopoverCombobox.stories.tsx +0 -49
  54. package/src/composites/PopoverCombobox.tsx +0 -209
  55. package/src/composites/index.ts +0 -5
@@ -1,24 +1,44 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // src/components/SearchList.tsx
4
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
3
+ // src/components/Combobox/Combobox.tsx
4
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
5
5
  import { createContext } from "@radix-ui/react-context";
6
6
  import { useControllableState } from "@radix-ui/react-use-controllable-state";
7
+ import React2, { forwardRef as forwardRef2, useCallback } from "react";
8
+ import { Button, Icon, Popover } from "@dxos/react-ui";
9
+ import { useId } from "@dxos/react-ui";
10
+ import { mx as mx2, staticPlaceholderText } from "@dxos/react-ui-theme";
11
+
12
+ // src/components/SearchList/SearchList.tsx
13
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
7
14
  import { CommandEmpty, CommandInput, CommandItem, CommandList, CommandRoot } from "cmdk";
8
- import React, { forwardRef, useCallback } from "react";
9
- import { Button, Icon, useDensityContext, useElevationContext, useId, useThemeContext } from "@dxos/react-ui";
10
- import { mx, staticPlaceholderText } from "@dxos/react-ui-theme";
11
- var COMBOBOX_NAME = "Combobox";
12
- var COMBOBOX_TRIGGER_NAME = "ComboboxTrigger";
15
+ import React, { forwardRef } from "react";
16
+ import { useDensityContext, useElevationContext, useThemeContext, useTranslation } from "@dxos/react-ui";
17
+ import { mx } from "@dxos/react-ui-theme";
18
+
19
+ // src/translations.ts
20
+ var translationKey = "react-ui-searchlist";
21
+ var translations = [
22
+ {
23
+ "en-US": {
24
+ [translationKey]: {
25
+ "search.placeholder": "Search..."
26
+ }
27
+ }
28
+ }
29
+ ];
30
+
31
+ // src/components/SearchList/SearchList.tsx
32
+ var commandItem = "flex items-center overflow-hidden";
33
+ var searchListItem = "plb-1 pli-2 rounded-sm select-none cursor-pointer data-[selected]:bg-hoverOverlay hover:bg-hoverOverlay";
13
34
  var SEARCHLIST_NAME = "SearchList";
14
35
  var SEARCHLIST_ITEM_NAME = "SearchListItem";
15
- var [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME, {});
16
36
  var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
17
37
  var _effect = _useSignals();
18
38
  try {
19
39
  return /* @__PURE__ */ React.createElement(CommandRoot, {
20
40
  ...props,
21
- className: mx("", classNames),
41
+ className: mx(classNames),
22
42
  ref: forwardedRef
23
43
  }, children);
24
44
  } finally {
@@ -26,15 +46,18 @@ var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...prop
26
46
  }
27
47
  });
28
48
  SearchListRoot.displayName = SEARCHLIST_NAME;
29
- var SearchListInput = /* @__PURE__ */ forwardRef(({ children, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
49
+ var SearchListInput = /* @__PURE__ */ forwardRef(({ classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
30
50
  var _effect = _useSignals();
31
51
  try {
52
+ const { t } = useTranslation(translationKey);
53
+ const placeholder = props.placeholder ?? t("search.placeholder");
32
54
  const { hasIosKeyboard } = useThemeContext();
33
55
  const { tx } = useThemeContext();
34
56
  const density = useDensityContext(propsDensity);
35
57
  const elevation = useElevationContext(propsElevation);
36
58
  return /* @__PURE__ */ React.createElement(CommandInput, {
37
59
  ...props,
60
+ placeholder,
38
61
  className: tx("input.input", "input", {
39
62
  variant,
40
63
  disabled: props.disabled,
@@ -74,23 +97,12 @@ var SearchListEmpty = /* @__PURE__ */ forwardRef(({ children, classNames, ...pro
74
97
  _effect.f();
75
98
  }
76
99
  });
77
- var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, onSelect, ...props }, forwardedRef) => {
100
+ var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
78
101
  var _effect = _useSignals();
79
102
  try {
80
- const { onValueChange, onOpenChange } = useComboboxContext(SEARCHLIST_ITEM_NAME);
81
- const handleSelect = useCallback((nextValue) => {
82
- onValueChange?.(nextValue);
83
- onOpenChange?.(false);
84
- onSelect?.(nextValue);
85
- }, [
86
- onValueChange,
87
- onOpenChange,
88
- onSelect
89
- ]);
90
103
  return /* @__PURE__ */ React.createElement(CommandItem, {
91
104
  ...props,
92
- onSelect: handleSelect,
93
- className: mx("p-1 pis-2 pie-2 rounded-sm select-none cursor-pointer data-[selected]:bg-hoverOverlay", classNames),
105
+ className: mx(searchListItem, classNames),
94
106
  ref: forwardedRef
95
107
  }, children);
96
108
  } finally {
@@ -98,64 +110,6 @@ var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, onSelec
98
110
  }
99
111
  });
100
112
  SearchListItem.displayName = SEARCHLIST_ITEM_NAME;
101
- var ComboboxRoot = ({ modalId: propsModalId, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, value: propsValue, defaultValue, onValueChange: propsOnValueChange, placeholder, children }) => {
102
- var _effect = _useSignals();
103
- try {
104
- const modalId = useId(COMBOBOX_NAME, propsModalId);
105
- const [open = false, onOpenChange] = useControllableState({
106
- prop: propsOpen,
107
- onChange: propsOnOpenChange,
108
- defaultProp: defaultOpen
109
- });
110
- const [value = "", onValueChange] = useControllableState({
111
- prop: propsValue,
112
- onChange: propsOnValueChange,
113
- defaultProp: defaultValue
114
- });
115
- return /* @__PURE__ */ React.createElement(ComboboxProvider, {
116
- isCombobox: true,
117
- modalId,
118
- open,
119
- onOpenChange,
120
- value,
121
- onValueChange,
122
- placeholder
123
- }, children);
124
- } finally {
125
- _effect.f();
126
- }
127
- };
128
- ComboboxRoot.displayName = COMBOBOX_NAME;
129
- var ComboboxTrigger = /* @__PURE__ */ forwardRef(({ children, onClick, ...props }, forwardedRef) => {
130
- var _effect = _useSignals();
131
- try {
132
- const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
133
- const handleClick = useCallback((event) => {
134
- onClick?.(event);
135
- onOpenChange?.(true);
136
- }, [
137
- onClick,
138
- onOpenChange
139
- ]);
140
- return /* @__PURE__ */ React.createElement(Button, {
141
- ...props,
142
- role: "combobox",
143
- "aria-expanded": open,
144
- "aria-controls": modalId,
145
- "aria-haspopup": "dialog",
146
- onClick: handleClick,
147
- ref: forwardedRef
148
- }, children ?? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
149
- className: mx("font-normal text-start flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
150
- }, value || placeholder), /* @__PURE__ */ React.createElement(Icon, {
151
- icon: "ph--caret-down--bold",
152
- size: 3
153
- })));
154
- } finally {
155
- _effect.f();
156
- }
157
- });
158
- ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
159
113
  var SearchList = {
160
114
  Root: SearchListRoot,
161
115
  Input: SearchListInput,
@@ -163,43 +117,48 @@ var SearchList = {
163
117
  Empty: SearchListEmpty,
164
118
  Item: SearchListItem
165
119
  };
166
- var Combobox = {
167
- Root: ComboboxRoot,
168
- Trigger: ComboboxTrigger,
169
- useComboboxContext
170
- };
171
120
 
172
- // src/composites/PopoverCombobox.tsx
173
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
174
- import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
175
- import React2, { forwardRef as forwardRef2 } from "react";
176
- import { Popover } from "@dxos/react-ui";
177
- var PopoverComboboxRoot = ({ modal, children, open: propsOpen, onOpenChange: propsOnOpenChange, defaultOpen, ...props }) => {
121
+ // src/components/Combobox/Combobox.tsx
122
+ var COMBOBOX_NAME = "Combobox";
123
+ var COMBOBOX_CONTENT_NAME = "ComboboxContent";
124
+ var COMBOBOX_ITEM_NAME = "ComboboxItem";
125
+ var COMBOBOX_TRIGGER_NAME = "ComboboxTrigger";
126
+ var [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME, {});
127
+ var ComboboxRoot = ({ modal, modalId: propsModalId, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, value: propsValue, defaultValue, onValueChange: propsOnValueChange, placeholder, children }) => {
178
128
  var _effect = _useSignals2();
179
129
  try {
180
- const [open, onOpenChange] = useControllableState2({
130
+ const modalId = useId(COMBOBOX_NAME, propsModalId);
131
+ const [open = false, onOpenChange] = useControllableState({
181
132
  prop: propsOpen,
182
133
  onChange: propsOnOpenChange,
183
134
  defaultProp: defaultOpen
184
135
  });
185
- return /* @__PURE__ */ React2.createElement(Combobox.Root, {
136
+ const [value = "", onValueChange] = useControllableState({
137
+ prop: propsValue,
138
+ onChange: propsOnValueChange,
139
+ defaultProp: defaultValue
140
+ });
141
+ return /* @__PURE__ */ React2.createElement(Popover.Root, {
186
142
  open,
187
143
  onOpenChange,
188
- ...props
189
- }, /* @__PURE__ */ React2.createElement(Popover.Root, {
144
+ modal
145
+ }, /* @__PURE__ */ React2.createElement(ComboboxProvider, {
146
+ isCombobox: true,
147
+ modalId,
148
+ placeholder,
190
149
  open,
191
150
  onOpenChange,
192
- modal
151
+ value,
152
+ onValueChange
193
153
  }, children));
194
154
  } finally {
195
155
  _effect.f();
196
156
  }
197
157
  };
198
- var POPOVER_COMBOBOX_CONTENT_NAME = "PopoverComboboxContent";
199
- var PopoverComboboxContent = /* @__PURE__ */ forwardRef2(({ side = "bottom", collisionPadding = 48, sideOffset, align, alignOffset, avoidCollisions, collisionBoundary, arrowPadding, sticky, hideWhenDetached, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, forceMount, children, classNames, ...props }, forwardedRef) => {
158
+ var ComboboxContent = /* @__PURE__ */ forwardRef2(({ side = "bottom", collisionPadding = 48, sideOffset, align, alignOffset, avoidCollisions, collisionBoundary, arrowPadding, sticky, hideWhenDetached, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, forceMount, children, classNames, ...props }, forwardedRef) => {
200
159
  var _effect = _useSignals2();
201
160
  try {
202
- const { modalId } = Combobox.useComboboxContext(POPOVER_COMBOBOX_CONTENT_NAME);
161
+ const { modalId } = useComboboxContext(COMBOBOX_CONTENT_NAME);
203
162
  return /* @__PURE__ */ React2.createElement(Popover.Content, {
204
163
  side,
205
164
  sideOffset,
@@ -219,7 +178,7 @@ var PopoverComboboxContent = /* @__PURE__ */ forwardRef2(({ side = "bottom", col
219
178
  onInteractOutside,
220
179
  forceMount,
221
180
  classNames: [
222
- "is-[--radix-popover-trigger-width] max-bs-[--radix-popover-content-available-height] grid grid-rows-[min-content_1fr] overflow-hidden",
181
+ "is-[--radix-popover-trigger-width] max-bs-[--radix-popover-content-available-height] grid grid-rows-[min-content_1fr]",
223
182
  classNames
224
183
  ],
225
184
  id: modalId,
@@ -233,22 +192,41 @@ var PopoverComboboxContent = /* @__PURE__ */ forwardRef2(({ side = "bottom", col
233
192
  _effect.f();
234
193
  }
235
194
  });
236
- PopoverComboboxContent.displayName = POPOVER_COMBOBOX_CONTENT_NAME;
237
- var PopoverComboboxTrigger = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
195
+ ComboboxContent.displayName = COMBOBOX_CONTENT_NAME;
196
+ var ComboboxTrigger = /* @__PURE__ */ forwardRef2(({ children, onClick, ...props }, forwardedRef) => {
238
197
  var _effect = _useSignals2();
239
198
  try {
199
+ const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
200
+ const handleClick = useCallback((event) => {
201
+ onClick?.(event);
202
+ onOpenChange?.(true);
203
+ }, [
204
+ onClick,
205
+ onOpenChange
206
+ ]);
240
207
  return /* @__PURE__ */ React2.createElement(Popover.Trigger, {
241
208
  asChild: true
242
- }, /* @__PURE__ */ React2.createElement(Combobox.Trigger, {
209
+ }, /* @__PURE__ */ React2.createElement(Button, {
243
210
  ...props,
211
+ role: "combobox",
212
+ "aria-expanded": open,
213
+ "aria-controls": modalId,
214
+ "aria-haspopup": "dialog",
215
+ onClick: handleClick,
244
216
  ref: forwardedRef
245
- }));
217
+ }, children ?? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("span", {
218
+ className: mx2("font-normal text-start flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
219
+ }, value || placeholder), /* @__PURE__ */ React2.createElement(Icon, {
220
+ icon: "ph--caret-down--bold",
221
+ size: 3
222
+ }))));
246
223
  } finally {
247
224
  _effect.f();
248
225
  }
249
226
  });
250
- var PopoverComboboxVirtualTrigger = Popover.VirtualTrigger;
251
- var PopoverComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
227
+ ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
228
+ var ComboboxVirtualTrigger = Popover.VirtualTrigger;
229
+ var ComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
252
230
  var _effect = _useSignals2();
253
231
  try {
254
232
  return /* @__PURE__ */ React2.createElement(SearchList.Input, {
@@ -263,7 +241,7 @@ var PopoverComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }
263
241
  _effect.f();
264
242
  }
265
243
  });
266
- var PopoverComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
244
+ var ComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
267
245
  var _effect = _useSignals2();
268
246
  try {
269
247
  return /* @__PURE__ */ React2.createElement(SearchList.Content, {
@@ -278,49 +256,186 @@ var PopoverComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, ...props },
278
256
  _effect.f();
279
257
  }
280
258
  });
281
- var PopoverComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
259
+ var ComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, onSelect, ...props }, forwardedRef) => {
282
260
  var _effect = _useSignals2();
283
261
  try {
262
+ const { onValueChange, onOpenChange } = useComboboxContext(COMBOBOX_ITEM_NAME);
263
+ const handleSelect = useCallback((nextValue) => {
264
+ onSelect?.(nextValue);
265
+ onValueChange?.(nextValue);
266
+ onOpenChange?.(false);
267
+ }, [
268
+ onSelect,
269
+ onValueChange,
270
+ onOpenChange
271
+ ]);
284
272
  return /* @__PURE__ */ React2.createElement(SearchList.Item, {
285
273
  ...props,
286
274
  classNames: [
287
275
  "mli-cardSpacingChrome pli-cardSpacingChrome",
288
276
  classNames
289
277
  ],
278
+ onSelect: handleSelect,
290
279
  ref: forwardedRef
291
280
  });
292
281
  } finally {
293
282
  _effect.f();
294
283
  }
295
284
  });
296
- var PopoverComboboxArrow = Popover.Arrow;
297
- var PopoverComboboxEmpty = SearchList.Empty;
298
- var PopoverCombobox = {
299
- Root: PopoverComboboxRoot,
300
- Content: PopoverComboboxContent,
301
- Trigger: PopoverComboboxTrigger,
302
- VirtualTrigger: PopoverComboboxVirtualTrigger,
303
- Input: PopoverComboboxInput,
304
- List: PopoverComboboxList,
305
- Item: PopoverComboboxItem,
306
- Arrow: PopoverComboboxArrow,
307
- Empty: PopoverComboboxEmpty
285
+ ComboboxItem.displayName = COMBOBOX_ITEM_NAME;
286
+ var ComboboxArrow = Popover.Arrow;
287
+ var ComboboxEmpty = SearchList.Empty;
288
+ var Combobox = {
289
+ Root: ComboboxRoot,
290
+ Content: ComboboxContent,
291
+ Trigger: ComboboxTrigger,
292
+ VirtualTrigger: ComboboxVirtualTrigger,
293
+ Input: ComboboxInput,
294
+ List: ComboboxList,
295
+ Item: ComboboxItem,
296
+ Arrow: ComboboxArrow,
297
+ Empty: ComboboxEmpty
308
298
  };
309
299
 
310
- // src/translations.ts
311
- var translationKey = "react-ui-searchlist";
312
- var translations = [
313
- {
314
- "en-US": {
315
- [translationKey]: {}
316
- }
300
+ // src/components/Listbox/Listbox.tsx
301
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
302
+ import { useArrowNavigationGroup } from "@fluentui/react-tabster";
303
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
304
+ import { createContextScope } from "@radix-ui/react-context";
305
+ import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
306
+ import React3, { forwardRef as forwardRef3, useCallback as useCallback2, useEffect, useRef } from "react";
307
+ import { Icon as Icon2 } from "@dxos/react-ui";
308
+ import { mx as mx3 } from "@dxos/react-ui-theme";
309
+ var LISTBOX_NAME = "Listbox";
310
+ var LISTBOX_OPTION_NAME = "ListboxOption";
311
+ var LISTBOX_OPTION_LABEL_NAME = "ListboxOptionLabel";
312
+ var LISTBOX_OPTION_INDICATOR_NAME = "ListboxOptionIndicator";
313
+ var [createListboxContext, createListboxScope] = createContextScope(LISTBOX_NAME, []);
314
+ var [createListboxOptionContext, createListboxOptionScope] = createContextScope(LISTBOX_OPTION_NAME, [
315
+ createListboxScope
316
+ ]);
317
+ var [ListboxProvider, useListboxContext] = createListboxContext(LISTBOX_NAME);
318
+ var [ListboxOptionProvider, useListboxOptionContext] = createListboxOptionContext(LISTBOX_OPTION_NAME);
319
+ var ListboxRoot = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
320
+ var _effect = _useSignals3();
321
+ try {
322
+ const { __listboxScope, children, classNames, value: propsValue, defaultValue, onValueChange, autoFocus, ...rootProps } = props;
323
+ const arrowGroup = useArrowNavigationGroup({
324
+ axis: "vertical"
325
+ });
326
+ const ref = useRef(null);
327
+ const rootRef = useComposedRefs(ref, forwardedRef);
328
+ const [selectedValue, setSelectedValue] = useControllableState2({
329
+ prop: propsValue,
330
+ defaultProp: defaultValue,
331
+ onChange: onValueChange
332
+ });
333
+ const handleValueChange = (value) => {
334
+ setSelectedValue(value);
335
+ };
336
+ useEffect(() => {
337
+ ref.current?.querySelector('[aria-selected="true"]')?.focus();
338
+ }, [
339
+ autoFocus
340
+ ]);
341
+ return /* @__PURE__ */ React3.createElement(ListboxProvider, {
342
+ scope: __listboxScope,
343
+ selectedValue,
344
+ onValueChange: handleValueChange
345
+ }, /* @__PURE__ */ React3.createElement("ul", {
346
+ role: "listbox",
347
+ ...rootProps,
348
+ className: mx3("is-full p-cardSpacingChrome", classNames),
349
+ ref: rootRef,
350
+ ...arrowGroup
351
+ }, children));
352
+ } finally {
353
+ _effect.f();
317
354
  }
318
- ];
355
+ });
356
+ ListboxRoot.displayName = LISTBOX_NAME;
357
+ var ListboxOption = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
358
+ var _effect = _useSignals3();
359
+ try {
360
+ const { __listboxScope, children, classNames, value, ...rootProps } = props;
361
+ const { selectedValue, onValueChange } = useListboxContext(LISTBOX_OPTION_NAME, __listboxScope);
362
+ const isSelected = selectedValue === value;
363
+ const handleSelect = useCallback2(() => {
364
+ onValueChange(value);
365
+ }, [
366
+ value,
367
+ onValueChange
368
+ ]);
369
+ return /* @__PURE__ */ React3.createElement(ListboxOptionProvider, {
370
+ scope: __listboxScope,
371
+ value,
372
+ isSelected
373
+ }, /* @__PURE__ */ React3.createElement("li", {
374
+ role: "option",
375
+ ...rootProps,
376
+ "aria-selected": isSelected,
377
+ tabIndex: 0,
378
+ className: mx3("dx-focus-ring", commandItem, searchListItem, classNames),
379
+ onClick: handleSelect,
380
+ onKeyDown: ({ key }) => {
381
+ if ([
382
+ "Enter",
383
+ " "
384
+ ].includes(key)) {
385
+ handleSelect();
386
+ }
387
+ },
388
+ ref: forwardedRef
389
+ }, children));
390
+ } finally {
391
+ _effect.f();
392
+ }
393
+ });
394
+ ListboxOption.displayName = LISTBOX_OPTION_NAME;
395
+ var ListboxOptionLabel = /* @__PURE__ */ forwardRef3(({ children, classNames, ...rootProps }, forwardedRef) => {
396
+ var _effect = _useSignals3();
397
+ try {
398
+ return /* @__PURE__ */ React3.createElement("span", {
399
+ ...rootProps,
400
+ className: mx3("grow truncate", classNames),
401
+ ref: forwardedRef
402
+ }, children);
403
+ } finally {
404
+ _effect.f();
405
+ }
406
+ });
407
+ ListboxOptionLabel.displayName = LISTBOX_OPTION_LABEL_NAME;
408
+ var ListboxOptionIndicator = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
409
+ var _effect = _useSignals3();
410
+ try {
411
+ const { __listboxOptionScope, classNames, ...rootProps } = props;
412
+ const { isSelected } = useListboxOptionContext(LISTBOX_OPTION_INDICATOR_NAME, __listboxOptionScope);
413
+ return /* @__PURE__ */ React3.createElement(Icon2, {
414
+ icon: "ph--check--regular",
415
+ ...rootProps,
416
+ classNames: mx3(!isSelected && "invisible", classNames),
417
+ ref: forwardedRef
418
+ });
419
+ } finally {
420
+ _effect.f();
421
+ }
422
+ });
423
+ ListboxOptionIndicator.displayName = LISTBOX_OPTION_INDICATOR_NAME;
424
+ var Listbox = {
425
+ Root: ListboxRoot,
426
+ Option: ListboxOption,
427
+ OptionLabel: ListboxOptionLabel,
428
+ OptionIndicator: ListboxOptionIndicator
429
+ };
319
430
  export {
320
431
  Combobox,
321
- PopoverCombobox,
432
+ Listbox,
322
433
  SearchList,
434
+ commandItem,
435
+ createListboxScope,
436
+ searchListItem,
323
437
  translationKey,
324
- translations
438
+ translations,
439
+ useListboxContext
325
440
  };
326
441
  //# sourceMappingURL=index.mjs.map