@dxos/react-ui-searchlist 0.8.4-main.b97322e → 0.8.4-main.bc674ce

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 (78) hide show
  1. package/dist/lib/browser/index.mjs +743 -292
  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 +743 -292
  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 +84 -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/SearchList.d.ts +87 -0
  20. package/dist/types/src/components/SearchList/SearchList.d.ts.map +1 -0
  21. package/dist/types/src/components/SearchList/SearchList.stories.d.ts +28 -0
  22. package/dist/types/src/components/SearchList/SearchList.stories.d.ts.map +1 -0
  23. package/dist/types/src/components/SearchList/context.d.ts +33 -0
  24. package/dist/types/src/components/SearchList/context.d.ts.map +1 -0
  25. package/dist/types/src/components/SearchList/hooks/index.d.ts +5 -0
  26. package/dist/types/src/components/SearchList/hooks/index.d.ts.map +1 -0
  27. package/dist/types/src/components/SearchList/hooks/useGlobalFilter.d.ts +34 -0
  28. package/dist/types/src/components/SearchList/hooks/useGlobalFilter.d.ts.map +1 -0
  29. package/dist/types/src/components/SearchList/hooks/useSearchListInput.d.ts +12 -0
  30. package/dist/types/src/components/SearchList/hooks/useSearchListInput.d.ts.map +1 -0
  31. package/dist/types/src/components/SearchList/hooks/useSearchListItem.d.ts +10 -0
  32. package/dist/types/src/components/SearchList/hooks/useSearchListItem.d.ts.map +1 -0
  33. package/dist/types/src/components/SearchList/hooks/useSearchListResults.d.ts +36 -0
  34. package/dist/types/src/components/SearchList/hooks/useSearchListResults.d.ts.map +1 -0
  35. package/dist/types/src/components/SearchList/index.d.ts +3 -0
  36. package/dist/types/src/components/SearchList/index.d.ts.map +1 -0
  37. package/dist/types/src/components/index.d.ts +2 -0
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/index.d.ts +0 -1
  40. package/dist/types/src/index.d.ts.map +1 -1
  41. package/dist/types/src/translations.d.ts +4 -2
  42. package/dist/types/src/translations.d.ts.map +1 -1
  43. package/dist/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +23 -17
  45. package/src/components/Combobox/Combobox.stories.tsx +62 -0
  46. package/src/components/Combobox/Combobox.tsx +356 -0
  47. package/src/components/Combobox/index.ts +5 -0
  48. package/src/components/Listbox/Listbox.stories.tsx +53 -0
  49. package/src/components/Listbox/Listbox.tsx +214 -0
  50. package/src/components/Listbox/index.ts +5 -0
  51. package/src/components/SearchList/SearchList.stories.tsx +534 -0
  52. package/src/components/SearchList/SearchList.tsx +559 -0
  53. package/src/components/SearchList/context.ts +43 -0
  54. package/src/components/SearchList/hooks/index.ts +8 -0
  55. package/src/components/SearchList/hooks/useGlobalFilter.tsx +61 -0
  56. package/src/components/SearchList/hooks/useSearchListInput.ts +14 -0
  57. package/src/components/SearchList/hooks/useSearchListItem.ts +14 -0
  58. package/src/components/SearchList/hooks/useSearchListResults.ts +104 -0
  59. package/src/components/SearchList/index.ts +6 -0
  60. package/src/components/index.ts +2 -0
  61. package/src/index.ts +0 -1
  62. package/src/translations.ts +4 -2
  63. package/src/types/command-score.d.ts +16 -0
  64. package/dist/types/src/components/SearchList.d.ts +0 -44
  65. package/dist/types/src/components/SearchList.d.ts.map +0 -1
  66. package/dist/types/src/components/SearchList.stories.d.ts +0 -15
  67. package/dist/types/src/components/SearchList.stories.d.ts.map +0 -1
  68. package/dist/types/src/composites/PopoverCombobox.d.ts +0 -32
  69. package/dist/types/src/composites/PopoverCombobox.d.ts.map +0 -1
  70. package/dist/types/src/composites/PopoverCombobox.stories.d.ts +0 -28
  71. package/dist/types/src/composites/PopoverCombobox.stories.d.ts.map +0 -1
  72. package/dist/types/src/composites/index.d.ts +0 -2
  73. package/dist/types/src/composites/index.d.ts.map +0 -1
  74. package/src/components/SearchList.stories.tsx +0 -47
  75. package/src/components/SearchList.tsx +0 -250
  76. package/src/composites/PopoverCombobox.stories.tsx +0 -44
  77. package/src/composites/PopoverCombobox.tsx +0 -208
  78. package/src/composites/index.ts +0 -5
@@ -1,322 +1,773 @@
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 { createContext } from "@radix-ui/react-context";
3
+ // src/components/Combobox/Combobox.tsx
4
+ import { createContext as createContext3 } from "@radix-ui/react-context";
5
+ import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
6
+ import React3, { forwardRef as forwardRef2, useCallback as useCallback3 } from "react";
7
+ import { Button, Icon as Icon2, Popover } from "@dxos/react-ui";
8
+ import { useId } from "@dxos/react-ui";
9
+ import { mx as mx2, staticPlaceholderText } from "@dxos/ui-theme";
10
+
11
+ // src/components/SearchList/SearchList.tsx
6
12
  import { useControllableState } from "@radix-ui/react-use-controllable-state";
7
- 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";
13
- var SEARCHLIST_NAME = "SearchList";
14
- var SEARCHLIST_ITEM_NAME = "SearchListItem";
15
- var [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME, {});
16
- var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
17
- var _effect = _useSignals();
18
- try {
19
- return /* @__PURE__ */ React.createElement(CommandRoot, {
20
- ...props,
21
- className: mx("", classNames),
22
- ref: forwardedRef
23
- }, children);
24
- } finally {
25
- _effect.f();
26
- }
27
- });
28
- SearchListRoot.displayName = SEARCHLIST_NAME;
29
- var SearchListInput = /* @__PURE__ */ forwardRef(({ children, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
30
- var _effect = _useSignals();
31
- try {
32
- const { hasIosKeyboard } = useThemeContext();
33
- const { tx } = useThemeContext();
34
- const density = useDensityContext(propsDensity);
35
- const elevation = useElevationContext(propsElevation);
36
- return /* @__PURE__ */ React.createElement(CommandInput, {
37
- ...props,
38
- className: tx("input.input", "input", {
39
- variant,
40
- disabled: props.disabled,
41
- density,
42
- elevation
43
- }, "mbe-cardSpacingBlock", classNames),
44
- ...props.autoFocus && !hasIosKeyboard && {
45
- autoFocus: true
46
- },
47
- ref: forwardedRef
48
- });
49
- } finally {
50
- _effect.f();
51
- }
52
- });
53
- var SearchListContent = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
54
- var _effect = _useSignals();
55
- try {
56
- return /* @__PURE__ */ React.createElement(CommandList, {
57
- ...props,
58
- className: mx(classNames),
59
- ref: forwardedRef
60
- }, children);
61
- } finally {
62
- _effect.f();
13
+ import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
14
+ import { Icon, useDensityContext, useElevationContext, useThemeContext, useTranslation } from "@dxos/react-ui";
15
+ import { descriptionText, mx } from "@dxos/ui-theme";
16
+
17
+ // src/translations.ts
18
+ var translationKey = "@dxos/react-ui-searchlist";
19
+ var translations = [
20
+ {
21
+ "en-US": {
22
+ [translationKey]: {
23
+ "search.placeholder": "Search..."
24
+ }
25
+ }
63
26
  }
27
+ ];
28
+
29
+ // src/components/SearchList/context.ts
30
+ import { createContext } from "@radix-ui/react-context";
31
+ var [SearchListItemContextProvider, useSearchListItemContext] = createContext("SearchListItem");
32
+ var [SearchListInputContextProvider, useSearchListInputContext] = createContext("SearchListInput");
33
+
34
+ // src/components/SearchList/SearchList.tsx
35
+ var SearchListRoot = ({ children, value: valueProp, defaultValue = "", debounceMs = 200, onSearch }) => {
36
+ const [query = "", setQuery] = useControllableState({
37
+ prop: valueProp,
38
+ defaultProp: defaultValue,
39
+ onChange: void 0
40
+ });
41
+ const [selectedValue, setSelectedValue] = useState(void 0);
42
+ const itemsRef = useRef(/* @__PURE__ */ new Map());
43
+ const debounceRef = useRef(null);
44
+ const handleQueryChange = useCallback((newQuery) => {
45
+ setQuery(newQuery);
46
+ if (debounceRef.current) {
47
+ clearTimeout(debounceRef.current);
48
+ }
49
+ debounceRef.current = setTimeout(() => {
50
+ onSearch?.(newQuery);
51
+ }, debounceMs);
52
+ }, [
53
+ setQuery,
54
+ onSearch,
55
+ debounceMs
56
+ ]);
57
+ const [itemVersion, setItemVersion] = useState(0);
58
+ useEffect(() => {
59
+ return () => {
60
+ if (debounceRef.current) {
61
+ clearTimeout(debounceRef.current);
62
+ }
63
+ };
64
+ }, []);
65
+ useEffect(() => {
66
+ const currentItem = selectedValue !== void 0 ? itemsRef.current.get(selectedValue) : void 0;
67
+ const isSelectionValid = currentItem !== void 0 && !currentItem.disabled;
68
+ if (!isSelectionValid && itemsRef.current.size > 0) {
69
+ const entries = Array.from(itemsRef.current.entries()).filter(([, data]) => !data.disabled);
70
+ if (entries.length > 0) {
71
+ entries.sort(([, a], [, b]) => {
72
+ const position = a.element.compareDocumentPosition(b.element);
73
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
74
+ return -1;
75
+ }
76
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
77
+ return 1;
78
+ }
79
+ return 0;
80
+ });
81
+ const firstValue = entries[0]?.[0];
82
+ if (firstValue !== void 0 && firstValue !== selectedValue) {
83
+ setSelectedValue(firstValue);
84
+ }
85
+ } else if (selectedValue !== void 0) {
86
+ setSelectedValue(void 0);
87
+ }
88
+ }
89
+ }, [
90
+ itemVersion,
91
+ selectedValue
92
+ ]);
93
+ const registerItem = useCallback((value, element, onSelect, disabled) => {
94
+ if (element) {
95
+ itemsRef.current.set(value, {
96
+ element,
97
+ onSelect,
98
+ disabled
99
+ });
100
+ setItemVersion((v) => v + 1);
101
+ }
102
+ }, []);
103
+ const unregisterItem = useCallback((value) => {
104
+ itemsRef.current.delete(value);
105
+ setItemVersion((v) => v + 1);
106
+ }, []);
107
+ const getItemValues = useCallback(() => {
108
+ return Array.from(itemsRef.current.entries()).filter(([, data]) => !data.disabled).sort(([, a], [, b]) => {
109
+ const position = a.element.compareDocumentPosition(b.element);
110
+ return position & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : position & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
111
+ }).map(([value]) => value);
112
+ }, []);
113
+ const triggerSelect = useCallback(() => {
114
+ if (selectedValue !== void 0) {
115
+ const item = itemsRef.current.get(selectedValue);
116
+ item?.onSelect?.();
117
+ }
118
+ }, [
119
+ selectedValue
120
+ ]);
121
+ const itemContextValue = useMemo(() => ({
122
+ selectedValue,
123
+ onSelectedValueChange: setSelectedValue,
124
+ registerItem,
125
+ unregisterItem
126
+ }), [
127
+ selectedValue,
128
+ registerItem,
129
+ unregisterItem
130
+ ]);
131
+ const inputContextValue = useMemo(() => ({
132
+ query,
133
+ onQueryChange: handleQueryChange,
134
+ selectedValue,
135
+ onSelectedValueChange: setSelectedValue,
136
+ getItemValues,
137
+ triggerSelect
138
+ }), [
139
+ query,
140
+ handleQueryChange,
141
+ selectedValue,
142
+ getItemValues,
143
+ triggerSelect
144
+ ]);
145
+ return /* @__PURE__ */ React.createElement(SearchListInputContextProvider, {
146
+ query: inputContextValue.query,
147
+ onQueryChange: inputContextValue.onQueryChange,
148
+ selectedValue: inputContextValue.selectedValue,
149
+ onSelectedValueChange: inputContextValue.onSelectedValueChange,
150
+ getItemValues: inputContextValue.getItemValues,
151
+ triggerSelect: inputContextValue.triggerSelect
152
+ }, /* @__PURE__ */ React.createElement(SearchListItemContextProvider, {
153
+ selectedValue: itemContextValue.selectedValue,
154
+ onSelectedValueChange: itemContextValue.onSelectedValueChange,
155
+ registerItem: itemContextValue.registerItem,
156
+ unregisterItem: itemContextValue.unregisterItem
157
+ }, children));
158
+ };
159
+ SearchListRoot.displayName = "SearchList.Root";
160
+ var SearchListViewport = ({ classNames, children }) => {
161
+ return /* @__PURE__ */ React.createElement("div", {
162
+ role: "none",
163
+ className: mx("is-full min-bs-0 grow overflow-y-auto", classNames)
164
+ }, children);
165
+ };
166
+ SearchListViewport.displayName = "SearchList.Viewport";
167
+ var SearchListContent = /* @__PURE__ */ forwardRef(({ classNames, children }, forwardedRef) => {
168
+ return /* @__PURE__ */ React.createElement("div", {
169
+ ref: forwardedRef,
170
+ role: "listbox",
171
+ className: mx("flex flex-col is-full min-bs-0 grow overflow-hidden", classNames)
172
+ }, children);
64
173
  });
65
- var SearchListEmpty = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
66
- var _effect = _useSignals();
67
- try {
68
- return /* @__PURE__ */ React.createElement(CommandEmpty, {
69
- ...props,
70
- className: mx(classNames),
71
- ref: forwardedRef
72
- }, children);
73
- } finally {
74
- _effect.f();
75
- }
174
+ SearchListContent.displayName = "SearchList.Content";
175
+ var SearchListInput = /* @__PURE__ */ forwardRef(({ classNames, density: propsDensity, elevation: propsElevation, variant, placeholder, onChange, ...props }, forwardedRef) => {
176
+ const { query, onQueryChange, selectedValue, onSelectedValueChange, getItemValues, triggerSelect } = useSearchListInputContext("SearchList.Input");
177
+ const { t } = useTranslation(translationKey);
178
+ const { hasIosKeyboard, tx } = useThemeContext();
179
+ const density = useDensityContext(propsDensity);
180
+ const elevation = useElevationContext(propsElevation);
181
+ const defaultPlaceholder = t("search.placeholder");
182
+ const handleChange = useCallback((event) => {
183
+ onQueryChange(event.target.value);
184
+ onChange?.(event);
185
+ }, [
186
+ onQueryChange,
187
+ onChange
188
+ ]);
189
+ const handleKeyDown = useCallback((event) => {
190
+ const values = getItemValues();
191
+ if (values.length === 0) {
192
+ if (event.key === "Escape") {
193
+ onQueryChange("");
194
+ }
195
+ return;
196
+ }
197
+ const currentIndex = selectedValue !== void 0 ? values.indexOf(selectedValue) : -1;
198
+ switch (event.key) {
199
+ case "ArrowDown": {
200
+ event.preventDefault();
201
+ const nextIndex = currentIndex === -1 ? 0 : Math.min(currentIndex + 1, values.length - 1);
202
+ const nextValue = values[nextIndex];
203
+ if (nextValue !== void 0) {
204
+ onSelectedValueChange(nextValue);
205
+ }
206
+ break;
207
+ }
208
+ case "ArrowUp": {
209
+ event.preventDefault();
210
+ const prevIndex = currentIndex === -1 ? values.length - 1 : Math.max(currentIndex - 1, 0);
211
+ const prevValue = values[prevIndex];
212
+ if (prevValue !== void 0) {
213
+ onSelectedValueChange(prevValue);
214
+ }
215
+ break;
216
+ }
217
+ case "Enter": {
218
+ if (selectedValue !== void 0) {
219
+ event.preventDefault();
220
+ triggerSelect();
221
+ }
222
+ break;
223
+ }
224
+ case "Home": {
225
+ event.preventDefault();
226
+ const firstValue = values[0];
227
+ if (firstValue !== void 0) {
228
+ onSelectedValueChange(firstValue);
229
+ }
230
+ break;
231
+ }
232
+ case "End": {
233
+ event.preventDefault();
234
+ const lastValue = values[values.length - 1];
235
+ if (lastValue !== void 0) {
236
+ onSelectedValueChange(lastValue);
237
+ }
238
+ break;
239
+ }
240
+ case "Escape": {
241
+ event.preventDefault();
242
+ if (selectedValue !== void 0) {
243
+ onSelectedValueChange(void 0);
244
+ } else {
245
+ onQueryChange("");
246
+ }
247
+ break;
248
+ }
249
+ }
250
+ }, [
251
+ selectedValue,
252
+ onSelectedValueChange,
253
+ getItemValues,
254
+ triggerSelect,
255
+ onQueryChange
256
+ ]);
257
+ return /* @__PURE__ */ React.createElement("input", {
258
+ ...props,
259
+ ...props.autoFocus && !hasIosKeyboard && {
260
+ autoFocus: true
261
+ },
262
+ type: "text",
263
+ value: query,
264
+ placeholder: placeholder ?? defaultPlaceholder,
265
+ className: tx("input.input", "input", {
266
+ variant,
267
+ disabled: props.disabled,
268
+ density,
269
+ elevation
270
+ }, classNames),
271
+ onChange: handleChange,
272
+ onKeyDown: handleKeyDown,
273
+ ref: forwardedRef
274
+ });
76
275
  });
77
- var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, onSelect, ...props }, forwardedRef) => {
78
- var _effect = _useSignals();
79
- 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
- return /* @__PURE__ */ React.createElement(CommandItem, {
91
- ...props,
92
- onSelect: handleSelect,
93
- className: mx("p-1 rounded select-none cursor-pointer data-[selected]:bg-hoverOverlay", classNames),
94
- ref: forwardedRef
95
- }, children);
96
- } finally {
97
- _effect.f();
98
- }
276
+ SearchListInput.displayName = "SearchList.Input";
277
+ var SearchListItem = /* @__PURE__ */ forwardRef(({ classNames, value, label, icon, checked, suffix, onSelect, disabled }, forwardedRef) => {
278
+ const { selectedValue, registerItem, unregisterItem } = useSearchListItemContext("SearchList.Item");
279
+ const internalRef = useRef(null);
280
+ const isSelected = selectedValue === value && !disabled;
281
+ useEffect(() => {
282
+ const element = internalRef.current;
283
+ if (element) {
284
+ registerItem(value, element, onSelect, disabled);
285
+ }
286
+ return () => unregisterItem(value);
287
+ }, [
288
+ value,
289
+ onSelect,
290
+ disabled,
291
+ registerItem,
292
+ unregisterItem
293
+ ]);
294
+ useEffect(() => {
295
+ if (isSelected && internalRef.current) {
296
+ internalRef.current.scrollIntoView({
297
+ block: "nearest",
298
+ behavior: "smooth"
299
+ });
300
+ }
301
+ }, [
302
+ isSelected
303
+ ]);
304
+ const handleClick = useCallback(() => {
305
+ if (!disabled) {
306
+ onSelect?.();
307
+ }
308
+ }, [
309
+ onSelect,
310
+ disabled
311
+ ]);
312
+ return /* @__PURE__ */ React.createElement("div", {
313
+ ref: (node) => {
314
+ internalRef.current = node;
315
+ if (typeof forwardedRef === "function") {
316
+ forwardedRef(node);
317
+ } else if (forwardedRef) {
318
+ forwardedRef.current = node;
319
+ }
320
+ },
321
+ role: "option",
322
+ "aria-selected": isSelected,
323
+ "aria-disabled": disabled,
324
+ "data-selected": isSelected,
325
+ "data-disabled": disabled,
326
+ "data-value": value,
327
+ tabIndex: -1,
328
+ className: mx("flex gap-2 items-center", "plb-1 pli-2 rounded-sm select-none cursor-pointer data-[selected=true]:bg-hoverOverlay hover:bg-hoverOverlay", disabled && "opacity-50 cursor-not-allowed hover:bg-transparent data-[selected=true]:bg-transparent", classNames),
329
+ onClick: handleClick
330
+ }, icon && /* @__PURE__ */ React.createElement(Icon, {
331
+ icon,
332
+ size: 5
333
+ }), /* @__PURE__ */ React.createElement("span", {
334
+ className: "is-0 grow truncate"
335
+ }, label), suffix && /* @__PURE__ */ React.createElement("span", {
336
+ className: mx("shrink-0", descriptionText)
337
+ }, suffix), checked && /* @__PURE__ */ React.createElement(Icon, {
338
+ icon: "ph--check--regular",
339
+ size: 5
340
+ }));
99
341
  });
100
- 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
- }
342
+ SearchListItem.displayName = "SearchList.Item";
343
+ var SearchListEmpty = ({ classNames, children }) => {
344
+ return /* @__PURE__ */ React.createElement("div", {
345
+ role: "status",
346
+ className: mx("flex flex-col is-full pli-2 plb-1", classNames)
347
+ }, children);
127
348
  };
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
- }
349
+ SearchListEmpty.displayName = "SearchList.Empty";
350
+ var SearchListGroup = /* @__PURE__ */ forwardRef(({ classNames, heading, children }, forwardedRef) => {
351
+ return /* @__PURE__ */ React.createElement("div", {
352
+ ref: forwardedRef,
353
+ role: "group",
354
+ className: mx("flex flex-col", classNames)
355
+ }, heading && /* @__PURE__ */ React.createElement("div", {
356
+ role: "presentation",
357
+ className: "pli-2 plb-1 text-xs font-medium text-description"
358
+ }, heading), children);
157
359
  });
158
- ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
360
+ SearchListGroup.displayName = "SearchList.Group";
159
361
  var SearchList = {
160
362
  Root: SearchListRoot,
161
- Input: SearchListInput,
363
+ Viewport: SearchListViewport,
162
364
  Content: SearchListContent,
365
+ Input: SearchListInput,
366
+ Item: SearchListItem,
163
367
  Empty: SearchListEmpty,
164
- Item: SearchListItem
368
+ Group: SearchListGroup
165
369
  };
166
- var Combobox = {
167
- Root: ComboboxRoot,
168
- Trigger: ComboboxTrigger,
169
- useComboboxContext
370
+
371
+ // src/components/SearchList/hooks/useGlobalFilter.tsx
372
+ import React2, { createContext as createContext2, useContext, useMemo as useMemo2 } from "react";
373
+ var GlobalFilterContext = /* @__PURE__ */ createContext2({});
374
+ var GlobalFilterProvider = ({ children, filter }) => {
375
+ const value = useMemo2(() => ({
376
+ filter
377
+ }), [
378
+ filter
379
+ ]);
380
+ return /* @__PURE__ */ React2.createElement(GlobalFilterContext.Provider, {
381
+ value
382
+ }, children);
383
+ };
384
+ var useGlobalFilter = () => {
385
+ return useContext(GlobalFilterContext);
386
+ };
387
+ var useGlobalFilteredObjects = (objects) => {
388
+ const { filter } = useGlobalFilter();
389
+ return useMemo2(() => {
390
+ if (!objects) {
391
+ return [];
392
+ }
393
+ if (!filter) {
394
+ return objects;
395
+ }
396
+ return filter(objects);
397
+ }, [
398
+ objects,
399
+ filter
400
+ ]);
170
401
  };
171
402
 
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 }) => {
178
- var _effect = _useSignals2();
179
- try {
180
- const [open, onOpenChange] = useControllableState2({
181
- prop: propsOpen,
182
- onChange: propsOnOpenChange,
183
- defaultProp: defaultOpen
184
- });
185
- return /* @__PURE__ */ React2.createElement(Combobox.Root, {
186
- open,
187
- onOpenChange,
188
- ...props
189
- }, /* @__PURE__ */ React2.createElement(Popover.Root, {
190
- open,
191
- onOpenChange,
192
- modal
193
- }, children));
194
- } finally {
195
- _effect.f();
196
- }
403
+ // src/components/SearchList/hooks/useSearchListInput.ts
404
+ var useSearchListInput = () => {
405
+ const { query, onQueryChange, selectedValue, onSelectedValueChange, getItemValues, triggerSelect } = useSearchListInputContext("useSearchListInput");
406
+ return {
407
+ query,
408
+ onQueryChange,
409
+ selectedValue,
410
+ onSelectedValueChange,
411
+ getItemValues,
412
+ triggerSelect
413
+ };
197
414
  };
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) => {
200
- var _effect = _useSignals2();
201
- try {
202
- const { modalId } = Combobox.useComboboxContext(POPOVER_COMBOBOX_CONTENT_NAME);
203
- return /* @__PURE__ */ React2.createElement(Popover.Content, {
204
- side,
205
- sideOffset,
206
- align,
207
- alignOffset,
208
- avoidCollisions,
209
- collisionBoundary,
210
- collisionPadding,
211
- arrowPadding,
212
- sticky,
213
- hideWhenDetached,
214
- onOpenAutoFocus,
215
- onCloseAutoFocus,
216
- onEscapeKeyDown,
217
- onPointerDownOutside,
218
- onFocusOutside,
219
- onInteractOutside,
220
- forceMount,
221
- classNames,
222
- id: modalId,
223
- ref: forwardedRef
224
- }, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(SearchList.Root, {
225
- ...props,
226
- classNames: "contents density-fine",
227
- role: "none"
228
- }, children)));
229
- } finally {
230
- _effect.f();
231
- }
415
+
416
+ // src/components/SearchList/hooks/useSearchListItem.ts
417
+ var useSearchListItem = () => {
418
+ const { selectedValue, registerItem, unregisterItem } = useSearchListItemContext("useSearchListItem");
419
+ return {
420
+ selectedValue,
421
+ registerItem,
422
+ unregisterItem
423
+ };
424
+ };
425
+
426
+ // src/components/SearchList/hooks/useSearchListResults.ts
427
+ import commandScore from "command-score";
428
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState as useState2 } from "react";
429
+ var useSearchListResults = ({ items, filter, fuzzy = true, extract, minScore = 0 }) => {
430
+ const [query, setQuery] = useState2("");
431
+ const queryRef = useRef2("");
432
+ useEffect2(() => {
433
+ queryRef.current = "";
434
+ setQuery("");
435
+ }, [
436
+ items
437
+ ]);
438
+ const defaultExtract = useCallback2((item) => {
439
+ if (typeof item === "string") {
440
+ return item;
441
+ }
442
+ return item?.label ?? "";
443
+ }, []);
444
+ const extractFn = extract ?? defaultExtract;
445
+ const defaultFilter = useCallback2((item, query2) => {
446
+ const searchable = extractFn(item);
447
+ return searchable.toLowerCase().includes(query2.toLowerCase());
448
+ }, [
449
+ extractFn
450
+ ]);
451
+ const filterFn = filter ?? defaultFilter;
452
+ const handleSearch = useCallback2((searchQuery) => {
453
+ queryRef.current = searchQuery;
454
+ setQuery(searchQuery);
455
+ }, []);
456
+ const results = useMemo3(() => {
457
+ const currentQuery = queryRef.current;
458
+ if (!currentQuery) {
459
+ return items;
460
+ }
461
+ if (fuzzy) {
462
+ const scored = items.map((item) => ({
463
+ item,
464
+ score: commandScore(extractFn(item), currentQuery)
465
+ })).filter(({ score }) => score > minScore).sort((a, b) => b.score - a.score);
466
+ return scored.map(({ item }) => item);
467
+ } else {
468
+ return items.filter((item) => filterFn(item, currentQuery));
469
+ }
470
+ }, [
471
+ items,
472
+ query,
473
+ filterFn,
474
+ fuzzy,
475
+ extractFn,
476
+ minScore
477
+ ]);
478
+ return {
479
+ results,
480
+ handleSearch
481
+ };
482
+ };
483
+
484
+ // src/components/Combobox/Combobox.tsx
485
+ var COMBOBOX_NAME = "Combobox";
486
+ var COMBOBOX_CONTENT_NAME = "ComboboxContent";
487
+ var COMBOBOX_ITEM_NAME = "ComboboxItem";
488
+ var COMBOBOX_TRIGGER_NAME = "ComboboxTrigger";
489
+ var [ComboboxProvider, useComboboxContext] = createContext3(COMBOBOX_NAME, {});
490
+ var ComboboxRoot = ({ modal, modalId: propsModalId, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, value: propsValue, defaultValue, onValueChange: propsOnValueChange, placeholder, children }) => {
491
+ const modalId = useId(COMBOBOX_NAME, propsModalId);
492
+ const [open = false, onOpenChange] = useControllableState2({
493
+ prop: propsOpen,
494
+ onChange: propsOnOpenChange,
495
+ defaultProp: defaultOpen
496
+ });
497
+ const [value = "", onValueChange] = useControllableState2({
498
+ prop: propsValue,
499
+ onChange: propsOnValueChange,
500
+ defaultProp: defaultValue
501
+ });
502
+ return /* @__PURE__ */ React3.createElement(Popover.Root, {
503
+ open,
504
+ onOpenChange,
505
+ modal
506
+ }, /* @__PURE__ */ React3.createElement(ComboboxProvider, {
507
+ isCombobox: true,
508
+ modalId,
509
+ placeholder,
510
+ open,
511
+ onOpenChange,
512
+ value,
513
+ onValueChange
514
+ }, children));
515
+ };
516
+ 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, onSearch, value, defaultValue, debounceMs, label }, forwardedRef) => {
517
+ const { modalId } = useComboboxContext(COMBOBOX_CONTENT_NAME);
518
+ return /* @__PURE__ */ React3.createElement(Popover.Content, {
519
+ side,
520
+ sideOffset,
521
+ align,
522
+ alignOffset,
523
+ avoidCollisions,
524
+ collisionBoundary,
525
+ collisionPadding,
526
+ arrowPadding,
527
+ sticky,
528
+ hideWhenDetached,
529
+ onOpenAutoFocus,
530
+ onCloseAutoFocus,
531
+ onEscapeKeyDown,
532
+ onPointerDownOutside,
533
+ onFocusOutside,
534
+ onInteractOutside,
535
+ forceMount,
536
+ classNames: [
537
+ "is-[--radix-popover-trigger-width] max-bs-[--radix-popover-content-available-height] grid grid-rows-[min-content_1fr]",
538
+ classNames
539
+ ],
540
+ id: modalId,
541
+ ref: forwardedRef
542
+ }, /* @__PURE__ */ React3.createElement(SearchList.Root, {
543
+ onSearch,
544
+ value,
545
+ defaultValue,
546
+ debounceMs
547
+ }, /* @__PURE__ */ React3.createElement("div", {
548
+ className: "contents density-fine",
549
+ "aria-label": label,
550
+ role: "combobox",
551
+ "aria-expanded": "true"
552
+ }, children)));
232
553
  });
233
- PopoverComboboxContent.displayName = POPOVER_COMBOBOX_CONTENT_NAME;
234
- var PopoverComboboxTrigger = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
235
- var _effect = _useSignals2();
236
- try {
237
- return /* @__PURE__ */ React2.createElement(Popover.Trigger, {
238
- asChild: true
239
- }, /* @__PURE__ */ React2.createElement(Combobox.Trigger, {
240
- ...props,
241
- ref: forwardedRef
242
- }));
243
- } finally {
244
- _effect.f();
245
- }
554
+ ComboboxContent.displayName = COMBOBOX_CONTENT_NAME;
555
+ var ComboboxTrigger = /* @__PURE__ */ forwardRef2(({ children, onClick, ...props }, forwardedRef) => {
556
+ const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
557
+ const handleClick = useCallback3((event) => {
558
+ onClick?.(event);
559
+ onOpenChange?.(true);
560
+ }, [
561
+ onClick,
562
+ onOpenChange
563
+ ]);
564
+ return /* @__PURE__ */ React3.createElement(Popover.Trigger, {
565
+ asChild: true
566
+ }, /* @__PURE__ */ React3.createElement(Button, {
567
+ ...props,
568
+ role: "combobox",
569
+ "aria-expanded": open,
570
+ "aria-controls": modalId,
571
+ "aria-haspopup": "dialog",
572
+ onClick: handleClick,
573
+ ref: forwardedRef
574
+ }, children ?? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("span", {
575
+ className: mx2("font-normal text-start flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
576
+ }, value || placeholder), /* @__PURE__ */ React3.createElement(Icon2, {
577
+ icon: "ph--caret-down--bold",
578
+ size: 3
579
+ }))));
246
580
  });
247
- var PopoverComboboxVirtualTrigger = Popover.VirtualTrigger;
248
- var PopoverComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
249
- var _effect = _useSignals2();
250
- try {
251
- return /* @__PURE__ */ React2.createElement(SearchList.Input, {
252
- ...props,
253
- classNames: [
254
- "mli-cardSpacingChrome mbs-cardSpacingChrome is-[calc(100%-2*var(--dx-cardSpacingChrome))]",
255
- classNames
256
- ],
257
- ref: forwardedRef
258
- });
259
- } finally {
260
- _effect.f();
261
- }
581
+ ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
582
+ var ComboboxVirtualTrigger = Popover.VirtualTrigger;
583
+ var ComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
584
+ return /* @__PURE__ */ React3.createElement(SearchList.Input, {
585
+ ...props,
586
+ classNames: [
587
+ "mli-cardSpacingChrome mbs-cardSpacingChrome mbe-0 is-[calc(100%-2*var(--dx-cardSpacingChrome))]",
588
+ classNames
589
+ ],
590
+ ref: forwardedRef
591
+ });
262
592
  });
263
- var PopoverComboboxList = /* @__PURE__ */ forwardRef2(({ constrainInline, constrainBlock, ...props }, forwardedRef) => {
264
- var _effect = _useSignals2();
265
- try {
266
- return /* @__PURE__ */ React2.createElement(Popover.Viewport, {
267
- constrainInline,
268
- constrainBlock
269
- }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
270
- ...props,
271
- ref: forwardedRef
272
- }));
273
- } finally {
274
- _effect.f();
275
- }
593
+ var ComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
594
+ return /* @__PURE__ */ React3.createElement(SearchList.Content, {
595
+ ...props,
596
+ classNames: [
597
+ "min-bs-0 overflow-y-auto plb-cardSpacingChrome",
598
+ classNames
599
+ ],
600
+ ref: forwardedRef
601
+ });
276
602
  });
277
- var PopoverComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
278
- var _effect = _useSignals2();
279
- try {
280
- return /* @__PURE__ */ React2.createElement(SearchList.Item, {
281
- ...props,
282
- classNames: [
283
- "mli-cardSpacingChrome pli-cardSpacingChrome",
284
- classNames
285
- ],
286
- ref: forwardedRef
287
- });
288
- } finally {
289
- _effect.f();
290
- }
603
+ var ComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, onSelect, value, closeOnSelect = true, ...props }, forwardedRef) => {
604
+ const { onValueChange, onOpenChange } = useComboboxContext(COMBOBOX_ITEM_NAME);
605
+ const handleSelect = useCallback3(() => {
606
+ onSelect?.();
607
+ if (value !== void 0) {
608
+ onValueChange?.(value);
609
+ }
610
+ if (closeOnSelect) {
611
+ onOpenChange?.(false);
612
+ }
613
+ }, [
614
+ onSelect,
615
+ onValueChange,
616
+ onOpenChange,
617
+ value,
618
+ closeOnSelect
619
+ ]);
620
+ return /* @__PURE__ */ React3.createElement(SearchList.Item, {
621
+ ...props,
622
+ value,
623
+ classNames: [
624
+ "mli-cardSpacingChrome pli-cardSpacingChrome",
625
+ classNames
626
+ ],
627
+ onSelect: handleSelect,
628
+ ref: forwardedRef
629
+ });
291
630
  });
292
- var PopoverComboboxArrow = Popover.Arrow;
293
- var PopoverComboboxEmpty = SearchList.Empty;
294
- var PopoverCombobox = {
295
- Root: PopoverComboboxRoot,
296
- Content: PopoverComboboxContent,
297
- Trigger: PopoverComboboxTrigger,
298
- VirtualTrigger: PopoverComboboxVirtualTrigger,
299
- Input: PopoverComboboxInput,
300
- List: PopoverComboboxList,
301
- Item: PopoverComboboxItem,
302
- Arrow: PopoverComboboxArrow,
303
- Empty: PopoverComboboxEmpty
631
+ ComboboxItem.displayName = COMBOBOX_ITEM_NAME;
632
+ var ComboboxArrow = Popover.Arrow;
633
+ var ComboboxEmpty = SearchList.Empty;
634
+ var ComboboxPortal = Popover.Portal;
635
+ var Combobox = {
636
+ Root: ComboboxRoot,
637
+ Portal: ComboboxPortal,
638
+ Content: ComboboxContent,
639
+ Trigger: ComboboxTrigger,
640
+ VirtualTrigger: ComboboxVirtualTrigger,
641
+ Input: ComboboxInput,
642
+ List: ComboboxList,
643
+ Item: ComboboxItem,
644
+ Arrow: ComboboxArrow,
645
+ Empty: ComboboxEmpty
304
646
  };
305
647
 
306
- // src/translations.ts
307
- var translationKey = "react-ui-searchlist";
308
- var translations = [
309
- {
310
- "en-US": {
311
- [translationKey]: {}
312
- }
313
- }
314
- ];
648
+ // src/components/Listbox/Listbox.tsx
649
+ import { useArrowNavigationGroup } from "@fluentui/react-tabster";
650
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
651
+ import { createContextScope } from "@radix-ui/react-context";
652
+ import { useControllableState as useControllableState3 } from "@radix-ui/react-use-controllable-state";
653
+ import React4, { forwardRef as forwardRef3, useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3 } from "react";
654
+ import { Icon as Icon3 } from "@dxos/react-ui";
655
+ import { mx as mx3 } from "@dxos/ui-theme";
656
+ var commandItem = "flex items-center overflow-hidden";
657
+ var LISTBOX_NAME = "Listbox";
658
+ var LISTBOX_OPTION_NAME = "ListboxOption";
659
+ var LISTBOX_OPTION_LABEL_NAME = "ListboxOptionLabel";
660
+ var LISTBOX_OPTION_INDICATOR_NAME = "ListboxOptionIndicator";
661
+ var [createListboxContext, createListboxScope] = createContextScope(LISTBOX_NAME, []);
662
+ var [createListboxOptionContext, createListboxOptionScope] = createContextScope(LISTBOX_OPTION_NAME, [
663
+ createListboxScope
664
+ ]);
665
+ var [ListboxProvider, useListboxContext] = createListboxContext(LISTBOX_NAME);
666
+ var [ListboxOptionProvider, useListboxOptionContext] = createListboxOptionContext(LISTBOX_OPTION_NAME);
667
+ var ListboxRoot = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
668
+ const { __listboxScope, children, classNames, value: propsValue, defaultValue, onValueChange, autoFocus, ...rootProps } = props;
669
+ const arrowGroup = useArrowNavigationGroup({
670
+ axis: "vertical"
671
+ });
672
+ const ref = useRef3(null);
673
+ const rootRef = useComposedRefs(ref, forwardedRef);
674
+ const [selectedValue, setSelectedValue] = useControllableState3({
675
+ prop: propsValue,
676
+ defaultProp: defaultValue,
677
+ onChange: onValueChange
678
+ });
679
+ const handleValueChange = (value) => {
680
+ setSelectedValue(value);
681
+ };
682
+ useEffect3(() => {
683
+ ref.current?.querySelector('[aria-selected="true"]')?.focus();
684
+ }, [
685
+ autoFocus
686
+ ]);
687
+ return /* @__PURE__ */ React4.createElement(ListboxProvider, {
688
+ scope: __listboxScope,
689
+ selectedValue,
690
+ onValueChange: handleValueChange
691
+ }, /* @__PURE__ */ React4.createElement("ul", {
692
+ role: "listbox",
693
+ ...rootProps,
694
+ className: mx3("is-full p-cardSpacingChrome", classNames),
695
+ ref: rootRef,
696
+ ...arrowGroup
697
+ }, children));
698
+ });
699
+ ListboxRoot.displayName = LISTBOX_NAME;
700
+ var ListboxOption = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
701
+ const { __listboxScope, children, classNames, value, ...rootProps } = props;
702
+ const { selectedValue, onValueChange } = useListboxContext(LISTBOX_OPTION_NAME, __listboxScope);
703
+ const isSelected = selectedValue === value;
704
+ const handleSelect = useCallback4(() => {
705
+ onValueChange(value);
706
+ }, [
707
+ value,
708
+ onValueChange
709
+ ]);
710
+ return /* @__PURE__ */ React4.createElement(ListboxOptionProvider, {
711
+ scope: __listboxScope,
712
+ value,
713
+ isSelected
714
+ }, /* @__PURE__ */ React4.createElement("li", {
715
+ role: "option",
716
+ ...rootProps,
717
+ "aria-selected": isSelected,
718
+ tabIndex: 0,
719
+ className: mx3("dx-focus-ring", "plb-1 pli-2 rounded-sm select-none cursor-pointer data-[selected=true]:bg-hoverOverlay hover:bg-hoverOverlay", commandItem, classNames),
720
+ onClick: handleSelect,
721
+ onKeyDown: ({ key }) => {
722
+ if ([
723
+ "Enter",
724
+ " "
725
+ ].includes(key)) {
726
+ handleSelect();
727
+ }
728
+ },
729
+ ref: forwardedRef
730
+ }, children));
731
+ });
732
+ ListboxOption.displayName = LISTBOX_OPTION_NAME;
733
+ var ListboxOptionLabel = /* @__PURE__ */ forwardRef3(({ children, classNames, ...rootProps }, forwardedRef) => {
734
+ return /* @__PURE__ */ React4.createElement("span", {
735
+ ...rootProps,
736
+ className: mx3("grow truncate", classNames),
737
+ ref: forwardedRef
738
+ }, children);
739
+ });
740
+ ListboxOptionLabel.displayName = LISTBOX_OPTION_LABEL_NAME;
741
+ var ListboxOptionIndicator = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
742
+ const { __listboxOptionScope, classNames, ...rootProps } = props;
743
+ const { isSelected } = useListboxOptionContext(LISTBOX_OPTION_INDICATOR_NAME, __listboxOptionScope);
744
+ return /* @__PURE__ */ React4.createElement(Icon3, {
745
+ icon: "ph--check--regular",
746
+ ...rootProps,
747
+ classNames: mx3(!isSelected && "invisible", classNames),
748
+ ref: forwardedRef
749
+ });
750
+ });
751
+ ListboxOptionIndicator.displayName = LISTBOX_OPTION_INDICATOR_NAME;
752
+ var Listbox = {
753
+ Root: ListboxRoot,
754
+ Option: ListboxOption,
755
+ OptionLabel: ListboxOptionLabel,
756
+ OptionIndicator: ListboxOptionIndicator
757
+ };
315
758
  export {
316
759
  Combobox,
317
- PopoverCombobox,
760
+ GlobalFilterProvider,
761
+ Listbox,
318
762
  SearchList,
763
+ createListboxScope,
319
764
  translationKey,
320
- translations
765
+ translations,
766
+ useGlobalFilter,
767
+ useGlobalFilteredObjects,
768
+ useListboxContext,
769
+ useSearchListInput,
770
+ useSearchListItem,
771
+ useSearchListResults
321
772
  };
322
773
  //# sourceMappingURL=index.mjs.map