@dxos/react-ui-searchlist 0.8.4-main.84f28bd → 0.8.4-main.ae835ea

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 (58) hide show
  1. package/dist/lib/browser/index.mjs +285 -139
  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 +285 -139
  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/components/Combobox/Combobox.stories.d.ts +21 -0
  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/SearchList.stories.d.ts +25 -0
  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 +17 -16
  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/SearchList.stories.tsx +64 -0
  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 +0 -15
  47. package/dist/types/src/components/SearchList.stories.d.ts.map +0 -1
  48. package/dist/types/src/composites/PopoverCombobox.d.ts +0 -32
  49. package/dist/types/src/composites/PopoverCombobox.d.ts.map +0 -1
  50. package/dist/types/src/composites/PopoverCombobox.stories.d.ts +0 -28
  51. package/dist/types/src/composites/PopoverCombobox.stories.d.ts.map +0 -1
  52. package/dist/types/src/composites/index.d.ts +0 -2
  53. package/dist/types/src/composites/index.d.ts.map +0 -1
  54. package/src/components/SearchList.stories.tsx +0 -47
  55. package/src/components/SearchList.tsx +0 -250
  56. package/src/composites/PopoverCombobox.stories.tsx +0 -44
  57. package/src/composites/PopoverCombobox.tsx +0 -186
  58. package/src/composites/index.ts +0 -5
@@ -1,25 +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";
5
- import { CaretDown } from "@phosphor-icons/react";
3
+ // src/components/Combobox/Combobox.tsx
4
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
6
5
  import { createContext } from "@radix-ui/react-context";
7
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";
8
14
  import { CommandEmpty, CommandInput, CommandItem, CommandList, CommandRoot } from "cmdk";
9
- import React, { forwardRef, useCallback } from "react";
10
- import { Button, useDensityContext, useElevationContext, useId, useThemeContext } from "@dxos/react-ui";
11
- import { getSize, mx, staticPlaceholderText } from "@dxos/react-ui-theme";
12
- var COMBOBOX_NAME = "Combobox";
13
- 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";
14
34
  var SEARCHLIST_NAME = "SearchList";
15
35
  var SEARCHLIST_ITEM_NAME = "SearchListItem";
16
- var [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME, {});
17
36
  var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
18
37
  var _effect = _useSignals();
19
38
  try {
20
39
  return /* @__PURE__ */ React.createElement(CommandRoot, {
21
40
  ...props,
22
- className: mx("", classNames),
41
+ className: mx(classNames),
23
42
  ref: forwardedRef
24
43
  }, children);
25
44
  } finally {
@@ -27,15 +46,18 @@ var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...prop
27
46
  }
28
47
  });
29
48
  SearchListRoot.displayName = SEARCHLIST_NAME;
30
- 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) => {
31
50
  var _effect = _useSignals();
32
51
  try {
52
+ const { t } = useTranslation(translationKey);
53
+ const placeholder = props.placeholder ?? t("search.placeholder");
33
54
  const { hasIosKeyboard } = useThemeContext();
34
55
  const { tx } = useThemeContext();
35
56
  const density = useDensityContext(propsDensity);
36
57
  const elevation = useElevationContext(propsElevation);
37
58
  return /* @__PURE__ */ React.createElement(CommandInput, {
38
59
  ...props,
60
+ placeholder,
39
61
  className: tx("input.input", "input", {
40
62
  variant,
41
63
  disabled: props.disabled,
@@ -75,23 +97,12 @@ var SearchListEmpty = /* @__PURE__ */ forwardRef(({ children, classNames, ...pro
75
97
  _effect.f();
76
98
  }
77
99
  });
78
- var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, onSelect, ...props }, forwardedRef) => {
100
+ var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
79
101
  var _effect = _useSignals();
80
102
  try {
81
- const { onValueChange, onOpenChange } = useComboboxContext(SEARCHLIST_ITEM_NAME);
82
- const handleSelect = useCallback((nextValue) => {
83
- onValueChange?.(nextValue);
84
- onOpenChange?.(false);
85
- onSelect?.(nextValue);
86
- }, [
87
- onValueChange,
88
- onOpenChange,
89
- onSelect
90
- ]);
91
103
  return /* @__PURE__ */ React.createElement(CommandItem, {
92
104
  ...props,
93
- onSelect: handleSelect,
94
- className: mx("p-1 rounded select-none cursor-pointer data-[selected]:bg-hoverOverlay", classNames),
105
+ className: mx(searchListItem, classNames),
95
106
  ref: forwardedRef
96
107
  }, children);
97
108
  } finally {
@@ -99,8 +110,22 @@ var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, onSelec
99
110
  }
100
111
  });
101
112
  SearchListItem.displayName = SEARCHLIST_ITEM_NAME;
102
- var ComboboxRoot = ({ modalId: propsModalId, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, value: propsValue, defaultValue, onValueChange: propsOnValueChange, placeholder, children }) => {
103
- var _effect = _useSignals();
113
+ var SearchList = {
114
+ Root: SearchListRoot,
115
+ Input: SearchListInput,
116
+ Content: SearchListContent,
117
+ Empty: SearchListEmpty,
118
+ Item: SearchListItem
119
+ };
120
+
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 }) => {
128
+ var _effect = _useSignals2();
104
129
  try {
105
130
  const modalId = useId(COMBOBOX_NAME, propsModalId);
106
131
  const [open = false, onOpenChange] = useControllableState({
@@ -113,22 +138,63 @@ var ComboboxRoot = ({ modalId: propsModalId, open: propsOpen, defaultOpen, onOpe
113
138
  onChange: propsOnValueChange,
114
139
  defaultProp: defaultValue
115
140
  });
116
- return /* @__PURE__ */ React.createElement(ComboboxProvider, {
141
+ return /* @__PURE__ */ React2.createElement(Popover.Root, {
142
+ open,
143
+ onOpenChange,
144
+ modal
145
+ }, /* @__PURE__ */ React2.createElement(ComboboxProvider, {
117
146
  isCombobox: true,
118
147
  modalId,
148
+ placeholder,
119
149
  open,
120
150
  onOpenChange,
121
151
  value,
122
- onValueChange,
123
- placeholder
124
- }, children);
152
+ onValueChange
153
+ }, children));
125
154
  } finally {
126
155
  _effect.f();
127
156
  }
128
157
  };
129
- ComboboxRoot.displayName = COMBOBOX_NAME;
130
- var ComboboxTrigger = /* @__PURE__ */ forwardRef(({ children, onClick, ...props }, forwardedRef) => {
131
- var _effect = _useSignals();
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) => {
159
+ var _effect = _useSignals2();
160
+ try {
161
+ const { modalId } = useComboboxContext(COMBOBOX_CONTENT_NAME);
162
+ return /* @__PURE__ */ React2.createElement(Popover.Content, {
163
+ side,
164
+ sideOffset,
165
+ align,
166
+ alignOffset,
167
+ avoidCollisions,
168
+ collisionBoundary,
169
+ collisionPadding,
170
+ arrowPadding,
171
+ sticky,
172
+ hideWhenDetached,
173
+ onOpenAutoFocus,
174
+ onCloseAutoFocus,
175
+ onEscapeKeyDown,
176
+ onPointerDownOutside,
177
+ onFocusOutside,
178
+ onInteractOutside,
179
+ forceMount,
180
+ classNames: [
181
+ "is-[--radix-popover-trigger-width] max-bs-[--radix-popover-content-available-height] grid grid-rows-[min-content_1fr]",
182
+ classNames
183
+ ],
184
+ id: modalId,
185
+ ref: forwardedRef
186
+ }, /* @__PURE__ */ React2.createElement(SearchList.Root, {
187
+ ...props,
188
+ classNames: "contents density-fine",
189
+ role: "none"
190
+ }, children));
191
+ } finally {
192
+ _effect.f();
193
+ }
194
+ });
195
+ ComboboxContent.displayName = COMBOBOX_CONTENT_NAME;
196
+ var ComboboxTrigger = /* @__PURE__ */ forwardRef2(({ children, onClick, ...props }, forwardedRef) => {
197
+ var _effect = _useSignals2();
132
198
  try {
133
199
  const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
134
200
  const handleClick = useCallback((event) => {
@@ -138,7 +204,9 @@ var ComboboxTrigger = /* @__PURE__ */ forwardRef(({ children, onClick, ...props
138
204
  onClick,
139
205
  onOpenChange
140
206
  ]);
141
- return /* @__PURE__ */ React.createElement(Button, {
207
+ return /* @__PURE__ */ React2.createElement(Popover.Trigger, {
208
+ asChild: true
209
+ }, /* @__PURE__ */ React2.createElement(Button, {
142
210
  ...props,
143
211
  role: "combobox",
144
212
  "aria-expanded": open,
@@ -146,150 +214,228 @@ var ComboboxTrigger = /* @__PURE__ */ forwardRef(({ children, onClick, ...props
146
214
  "aria-haspopup": "dialog",
147
215
  onClick: handleClick,
148
216
  ref: forwardedRef
149
- }, children ?? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
150
- className: mx("font-normal text-start flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
151
- }, value || placeholder), /* @__PURE__ */ React.createElement(CaretDown, {
152
- weight: "bold",
153
- className: getSize(3)
154
- })));
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
+ }))));
155
223
  } finally {
156
224
  _effect.f();
157
225
  }
158
226
  });
159
227
  ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
160
- var SearchList = {
161
- Root: SearchListRoot,
162
- Input: SearchListInput,
163
- Content: SearchListContent,
164
- Empty: SearchListEmpty,
165
- Item: SearchListItem
166
- };
228
+ var ComboboxVirtualTrigger = Popover.VirtualTrigger;
229
+ var ComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
230
+ var _effect = _useSignals2();
231
+ try {
232
+ return /* @__PURE__ */ React2.createElement(SearchList.Input, {
233
+ ...props,
234
+ classNames: [
235
+ "mli-cardSpacingChrome mbs-cardSpacingChrome mbe-0 is-[calc(100%-2*var(--dx-cardSpacingChrome))]",
236
+ classNames
237
+ ],
238
+ ref: forwardedRef
239
+ });
240
+ } finally {
241
+ _effect.f();
242
+ }
243
+ });
244
+ var ComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
245
+ var _effect = _useSignals2();
246
+ try {
247
+ return /* @__PURE__ */ React2.createElement(SearchList.Content, {
248
+ ...props,
249
+ classNames: [
250
+ "min-bs-0 overflow-y-auto plb-cardSpacingChrome",
251
+ classNames
252
+ ],
253
+ ref: forwardedRef
254
+ });
255
+ } finally {
256
+ _effect.f();
257
+ }
258
+ });
259
+ var ComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, onSelect, ...props }, forwardedRef) => {
260
+ var _effect = _useSignals2();
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
+ ]);
272
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
273
+ ...props,
274
+ classNames: [
275
+ "mli-cardSpacingChrome pli-cardSpacingChrome",
276
+ classNames
277
+ ],
278
+ onSelect: handleSelect,
279
+ ref: forwardedRef
280
+ });
281
+ } finally {
282
+ _effect.f();
283
+ }
284
+ });
285
+ ComboboxItem.displayName = COMBOBOX_ITEM_NAME;
286
+ var ComboboxArrow = Popover.Arrow;
287
+ var ComboboxEmpty = SearchList.Empty;
167
288
  var Combobox = {
168
289
  Root: ComboboxRoot,
290
+ Content: ComboboxContent,
169
291
  Trigger: ComboboxTrigger,
170
- useComboboxContext
292
+ VirtualTrigger: ComboboxVirtualTrigger,
293
+ Input: ComboboxInput,
294
+ List: ComboboxList,
295
+ Item: ComboboxItem,
296
+ Arrow: ComboboxArrow,
297
+ Empty: ComboboxEmpty
171
298
  };
172
299
 
173
- // src/composites/PopoverCombobox.tsx
174
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
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";
175
305
  import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
176
- import React2, { forwardRef as forwardRef2 } from "react";
177
- import { Popover } from "@dxos/react-ui";
178
- var PopoverComboboxRoot = ({ modal, children, open: propsOpen, onOpenChange: propsOnOpenChange, defaultOpen, ...props }) => {
179
- var _effect = _useSignals2();
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();
180
321
  try {
181
- const [open, onOpenChange] = useControllableState2({
182
- prop: propsOpen,
183
- onChange: propsOnOpenChange,
184
- defaultProp: defaultOpen
322
+ const { __listboxScope, children, classNames, value: propsValue, defaultValue, onValueChange, autoFocus, ...rootProps } = props;
323
+ const arrowGroup = useArrowNavigationGroup({
324
+ axis: "vertical"
185
325
  });
186
- return /* @__PURE__ */ React2.createElement(Combobox.Root, {
187
- open,
188
- onOpenChange,
189
- ...props
190
- }, /* @__PURE__ */ React2.createElement(Popover.Root, {
191
- open,
192
- onOpenChange,
193
- modal
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
194
351
  }, children));
195
352
  } finally {
196
353
  _effect.f();
197
354
  }
198
- };
199
- var POPOVER_COMBOBOX_CONTENT_NAME = "PopoverComboboxContent";
200
- 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) => {
201
- var _effect = _useSignals2();
355
+ });
356
+ ListboxRoot.displayName = LISTBOX_NAME;
357
+ var ListboxOption = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
358
+ var _effect = _useSignals3();
202
359
  try {
203
- const { modalId } = Combobox.useComboboxContext(POPOVER_COMBOBOX_CONTENT_NAME);
204
- return /* @__PURE__ */ React2.createElement(Popover.Content, {
205
- side,
206
- sideOffset,
207
- align,
208
- alignOffset,
209
- avoidCollisions,
210
- collisionBoundary,
211
- collisionPadding,
212
- arrowPadding,
213
- sticky,
214
- hideWhenDetached,
215
- onOpenAutoFocus,
216
- onCloseAutoFocus,
217
- onEscapeKeyDown,
218
- onPointerDownOutside,
219
- onFocusOutside,
220
- onInteractOutside,
221
- forceMount,
222
- classNames,
223
- id: modalId,
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
+ },
224
388
  ref: forwardedRef
225
- }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(SearchList.Root, {
226
- ...props,
227
- classNames: "contents",
228
- role: "none"
229
- }, children)));
389
+ }, children));
230
390
  } finally {
231
391
  _effect.f();
232
392
  }
233
393
  });
234
- PopoverComboboxContent.displayName = POPOVER_COMBOBOX_CONTENT_NAME;
235
- var PopoverComboboxTrigger = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
236
- var _effect = _useSignals2();
394
+ ListboxOption.displayName = LISTBOX_OPTION_NAME;
395
+ var ListboxOptionLabel = /* @__PURE__ */ forwardRef3(({ children, classNames, ...rootProps }, forwardedRef) => {
396
+ var _effect = _useSignals3();
237
397
  try {
238
- return /* @__PURE__ */ React2.createElement(Popover.Trigger, {
239
- asChild: true
240
- }, /* @__PURE__ */ React2.createElement(Combobox.Trigger, {
241
- ...props,
398
+ return /* @__PURE__ */ React3.createElement("span", {
399
+ ...rootProps,
400
+ className: mx3("grow truncate", classNames),
242
401
  ref: forwardedRef
243
- }));
402
+ }, children);
244
403
  } finally {
245
404
  _effect.f();
246
405
  }
247
406
  });
248
- var PopoverComboboxVirtualTrigger = Popover.VirtualTrigger;
249
- var PopoverComboboxInput = SearchList.Input;
250
- var PopoverComboboxList = /* @__PURE__ */ forwardRef2(({ constrainInline, constrainBlock, ...props }, forwardedRef) => {
251
- var _effect = _useSignals2();
407
+ ListboxOptionLabel.displayName = LISTBOX_OPTION_LABEL_NAME;
408
+ var ListboxOptionIndicator = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
409
+ var _effect = _useSignals3();
252
410
  try {
253
- return /* @__PURE__ */ React2.createElement(Popover.Viewport, {
254
- constrainInline,
255
- constrainBlock
256
- }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
257
- ...props,
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),
258
417
  ref: forwardedRef
259
- }));
418
+ });
260
419
  } finally {
261
420
  _effect.f();
262
421
  }
263
422
  });
264
- var PopoverComboboxItem = SearchList.Item;
265
- var PopoverComboboxArrow = Popover.Arrow;
266
- var PopoverComboboxEmpty = SearchList.Empty;
267
- var PopoverCombobox = {
268
- Root: PopoverComboboxRoot,
269
- Content: PopoverComboboxContent,
270
- Trigger: PopoverComboboxTrigger,
271
- VirtualTrigger: PopoverComboboxVirtualTrigger,
272
- Input: PopoverComboboxInput,
273
- List: PopoverComboboxList,
274
- Item: PopoverComboboxItem,
275
- Arrow: PopoverComboboxArrow,
276
- Empty: PopoverComboboxEmpty
423
+ ListboxOptionIndicator.displayName = LISTBOX_OPTION_INDICATOR_NAME;
424
+ var Listbox = {
425
+ Root: ListboxRoot,
426
+ Option: ListboxOption,
427
+ OptionLabel: ListboxOptionLabel,
428
+ OptionIndicator: ListboxOptionIndicator
277
429
  };
278
-
279
- // src/translations.ts
280
- var translationKey = "react-ui-searchlist";
281
- var translations = [
282
- {
283
- "en-US": {
284
- [translationKey]: {}
285
- }
286
- }
287
- ];
288
430
  export {
289
431
  Combobox,
290
- PopoverCombobox,
432
+ Listbox,
291
433
  SearchList,
434
+ commandItem,
435
+ createListboxScope,
436
+ searchListItem,
292
437
  translationKey,
293
- translations
438
+ translations,
439
+ useListboxContext
294
440
  };
295
441
  //# sourceMappingURL=index.mjs.map