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

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 +744 -266
  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 +744 -266
  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 -19
  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 -186
  78. package/src/composites/index.ts +0 -5
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-searchlist",
3
- "version": "0.8.4-main.84f28bd",
3
+ "version": "0.8.4-main.9735255",
4
4
  "description": "A themed ⌘K-style combobox component, triggered by a button (or keyboard shortcut), where values are queried only within the invoked modal.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
17
+ "source": "./src/index.ts",
13
18
  "types": "./dist/types/src/index.d.ts",
14
19
  "browser": "./dist/lib/browser/index.mjs",
15
20
  "node": "./dist/lib/node-esm/index.mjs"
@@ -24,29 +29,28 @@
24
29
  "src"
25
30
  ],
26
31
  "dependencies": {
27
- "@preact-signals/safe-react": "^0.9.0",
32
+ "@fluentui/react-tabster": "9.26.11",
33
+ "@radix-ui/react-compose-refs": "1.1.1",
28
34
  "@radix-ui/react-context": "1.1.1",
29
35
  "@radix-ui/react-use-controllable-state": "1.1.0",
30
- "cmdk": "^0.2.0"
36
+ "command-score": "0.1.2"
31
37
  },
32
38
  "devDependencies": {
33
- "@phosphor-icons/react": "^2.1.5",
34
- "@types/react": "~18.2.0",
35
- "@types/react-dom": "~18.2.0",
36
- "react": "~18.2.0",
37
- "react-dom": "~18.2.0",
38
- "vite": "5.4.7",
39
- "@dxos/random": "0.8.4-main.84f28bd",
40
- "@dxos/react-ui": "0.8.4-main.84f28bd",
41
- "@dxos/react-ui-theme": "0.8.4-main.84f28bd",
42
- "@dxos/storybook-utils": "0.8.4-main.84f28bd"
39
+ "@types/react": "~19.2.7",
40
+ "@types/react-dom": "~19.2.3",
41
+ "react": "~19.2.3",
42
+ "react-dom": "~19.2.3",
43
+ "vite": "7.1.9",
44
+ "@dxos/random": "0.8.4-main.9735255",
45
+ "@dxos/react-ui": "0.8.4-main.9735255",
46
+ "@dxos/storybook-utils": "0.8.4-main.9735255",
47
+ "@dxos/ui-theme": "0.8.4-main.9735255"
43
48
  },
44
49
  "peerDependencies": {
45
- "@phosphor-icons/react": "^2.1.5",
46
- "react": "~18.2.0",
47
- "react-dom": "~18.2.0",
48
- "@dxos/react-ui": "0.8.4-main.84f28bd",
49
- "@dxos/react-ui-theme": "0.8.4-main.84f28bd"
50
+ "react": "~19.2.3",
51
+ "react-dom": "~19.2.3",
52
+ "@dxos/react-ui": "0.8.4-main.9735255",
53
+ "@dxos/ui-theme": "0.8.4-main.9735255"
50
54
  },
51
55
  "publishConfig": {
52
56
  "access": "public"
@@ -0,0 +1,62 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React from 'react';
7
+
8
+ import { faker } from '@dxos/random';
9
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
+
11
+ import { translations } from '../../translations';
12
+ import { useSearchListResults } from '../SearchList/hooks';
13
+
14
+ import { Combobox } from './Combobox';
15
+
16
+ faker.seed(1234);
17
+
18
+ const items = faker.helpers.uniqueArray(faker.commerce.productName, 16).sort();
19
+
20
+ const DefaultStory = () => {
21
+ const { results, handleSearch } = useSearchListResults({
22
+ items,
23
+ });
24
+
25
+ return (
26
+ <Combobox.Root
27
+ placeholder='Nothing selected'
28
+ onValueChange={(value) => {
29
+ console.log('[Combobox.Root.onValueChange]', value);
30
+ }}
31
+ >
32
+ <Combobox.Trigger />
33
+ <Combobox.Content onSearch={handleSearch}>
34
+ <Combobox.Input placeholder='Search...' />
35
+ <Combobox.List>
36
+ {results.map((value) => (
37
+ <Combobox.Item key={value} value={value} label={value} />
38
+ ))}
39
+ </Combobox.List>
40
+ <Combobox.Arrow />
41
+ </Combobox.Content>
42
+ </Combobox.Root>
43
+ );
44
+ };
45
+
46
+ const meta = {
47
+ title: 'ui/react-ui-searchlist/Combobox',
48
+ component: Combobox.Root as any,
49
+ render: DefaultStory,
50
+ decorators: [withTheme, withLayout({ layout: 'column', classNames: 'p-2' })],
51
+ parameters: {
52
+ translations,
53
+ },
54
+ } satisfies Meta<typeof DefaultStory>;
55
+
56
+ export default meta;
57
+
58
+ type Story = StoryObj<typeof meta>;
59
+
60
+ export const Default: Story = {
61
+ args: {},
62
+ };
@@ -0,0 +1,356 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { createContext } from '@radix-ui/react-context';
6
+ import { useControllableState } from '@radix-ui/react-use-controllable-state';
7
+ import React, { type PropsWithChildren, forwardRef, useCallback } from 'react';
8
+
9
+ import {
10
+ Button,
11
+ type ButtonProps,
12
+ Icon,
13
+ Popover,
14
+ type PopoverArrowProps,
15
+ type PopoverContentProps,
16
+ type PopoverVirtualTriggerProps,
17
+ } from '@dxos/react-ui';
18
+ import { useId } from '@dxos/react-ui';
19
+ import { mx, staticPlaceholderText } from '@dxos/ui-theme';
20
+
21
+ import {
22
+ SearchList,
23
+ type SearchListContentProps,
24
+ type SearchListEmptyProps,
25
+ type SearchListInputProps,
26
+ type SearchListItemProps,
27
+ type SearchListRootProps,
28
+ } from '../SearchList';
29
+
30
+ const COMBOBOX_NAME = 'Combobox';
31
+ const COMBOBOX_CONTENT_NAME = 'ComboboxContent';
32
+ const COMBOBOX_ITEM_NAME = 'ComboboxItem';
33
+ const COMBOBOX_TRIGGER_NAME = 'ComboboxTrigger';
34
+
35
+ //
36
+ // Context
37
+ //
38
+
39
+ type ComboboxContextValue = {
40
+ modalId: string;
41
+ isCombobox: true;
42
+ placeholder?: string;
43
+ open: boolean;
44
+ onOpenChange: (nextOpen: boolean) => void;
45
+ value: string;
46
+ onValueChange: (nextValue: string) => void;
47
+ };
48
+
49
+ const [ComboboxProvider, useComboboxContext] = createContext<Partial<ComboboxContextValue>>(COMBOBOX_NAME, {});
50
+
51
+ //
52
+ // Root
53
+ //
54
+
55
+ type ComboboxRootProps = PropsWithChildren<
56
+ Partial<ComboboxContextValue & { modal: boolean; defaultOpen: boolean; defaultValue: string; placeholder: string }>
57
+ >;
58
+
59
+ const ComboboxRoot = ({
60
+ modal,
61
+ modalId: propsModalId,
62
+ open: propsOpen,
63
+ defaultOpen,
64
+ onOpenChange: propsOnOpenChange,
65
+ value: propsValue,
66
+ defaultValue,
67
+ onValueChange: propsOnValueChange,
68
+ placeholder,
69
+ children,
70
+ }: ComboboxRootProps) => {
71
+ const modalId = useId(COMBOBOX_NAME, propsModalId);
72
+ const [open = false, onOpenChange] = useControllableState({
73
+ prop: propsOpen,
74
+ onChange: propsOnOpenChange,
75
+ defaultProp: defaultOpen,
76
+ });
77
+ const [value = '', onValueChange] = useControllableState({
78
+ prop: propsValue,
79
+ onChange: propsOnValueChange,
80
+ defaultProp: defaultValue,
81
+ });
82
+
83
+ return (
84
+ <Popover.Root open={open} onOpenChange={onOpenChange} modal={modal}>
85
+ <ComboboxProvider
86
+ isCombobox
87
+ modalId={modalId}
88
+ placeholder={placeholder}
89
+ open={open}
90
+ onOpenChange={onOpenChange}
91
+ value={value}
92
+ onValueChange={onValueChange}
93
+ >
94
+ {children}
95
+ </ComboboxProvider>
96
+ </Popover.Root>
97
+ );
98
+ };
99
+
100
+ //
101
+ // ContentProps
102
+ //
103
+
104
+ type ComboboxContentProps = SearchListRootProps & PopoverContentProps & { label?: string };
105
+
106
+ const ComboboxContent = forwardRef<HTMLDivElement, ComboboxContentProps>(
107
+ (
108
+ {
109
+ side = 'bottom',
110
+ collisionPadding = 48,
111
+ sideOffset,
112
+ align,
113
+ alignOffset,
114
+ avoidCollisions,
115
+ collisionBoundary,
116
+ arrowPadding,
117
+ sticky,
118
+ hideWhenDetached,
119
+ onOpenAutoFocus,
120
+ onCloseAutoFocus,
121
+ onEscapeKeyDown,
122
+ onPointerDownOutside,
123
+ onFocusOutside,
124
+ onInteractOutside,
125
+ forceMount,
126
+ children,
127
+ classNames,
128
+ onSearch,
129
+ value,
130
+ defaultValue,
131
+ debounceMs,
132
+ label,
133
+ },
134
+ forwardedRef,
135
+ ) => {
136
+ const { modalId } = useComboboxContext(COMBOBOX_CONTENT_NAME);
137
+
138
+ return (
139
+ <Popover.Content
140
+ {...{
141
+ side,
142
+ sideOffset,
143
+ align,
144
+ alignOffset,
145
+ avoidCollisions,
146
+ collisionBoundary,
147
+ collisionPadding,
148
+ arrowPadding,
149
+ sticky,
150
+ hideWhenDetached,
151
+ onOpenAutoFocus,
152
+ onCloseAutoFocus,
153
+ onEscapeKeyDown,
154
+ onPointerDownOutside,
155
+ onFocusOutside,
156
+ onInteractOutside,
157
+ forceMount,
158
+ }}
159
+ classNames={[
160
+ 'is-[--radix-popover-trigger-width] max-bs-[--radix-popover-content-available-height] grid grid-rows-[min-content_1fr]',
161
+ classNames,
162
+ ]}
163
+ id={modalId}
164
+ ref={forwardedRef}
165
+ >
166
+ <SearchList.Root onSearch={onSearch} value={value} defaultValue={defaultValue} debounceMs={debounceMs}>
167
+ <div className='contents density-fine' aria-label={label} role='combobox' aria-expanded='true'>
168
+ {children}
169
+ </div>
170
+ </SearchList.Root>
171
+ </Popover.Content>
172
+ );
173
+ },
174
+ );
175
+
176
+ ComboboxContent.displayName = COMBOBOX_CONTENT_NAME;
177
+
178
+ //
179
+ // Trigger
180
+ //
181
+
182
+ type ComboboxTriggerProps = ButtonProps;
183
+
184
+ const ComboboxTrigger = forwardRef<HTMLButtonElement, ComboboxTriggerProps>(
185
+ ({ children, onClick, ...props }, forwardedRef) => {
186
+ const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
187
+ const handleClick = useCallback(
188
+ (event: Parameters<Exclude<ButtonProps['onClick'], undefined>>[0]) => {
189
+ onClick?.(event);
190
+ onOpenChange?.(true);
191
+ },
192
+ [onClick, onOpenChange],
193
+ );
194
+
195
+ return (
196
+ <Popover.Trigger asChild>
197
+ <Button
198
+ {...props}
199
+ role='combobox'
200
+ aria-expanded={open}
201
+ aria-controls={modalId}
202
+ aria-haspopup='dialog'
203
+ onClick={handleClick}
204
+ ref={forwardedRef}
205
+ >
206
+ {children ?? (
207
+ <>
208
+ <span
209
+ className={mx('font-normal text-start flex-1 min-is-0 truncate mie-2', !value && staticPlaceholderText)}
210
+ >
211
+ {value || placeholder}
212
+ </span>
213
+ <Icon icon='ph--caret-down--bold' size={3} />
214
+ </>
215
+ )}
216
+ </Button>
217
+ </Popover.Trigger>
218
+ );
219
+ },
220
+ );
221
+
222
+ ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
223
+
224
+ //
225
+ // VirtualTrigger
226
+ //
227
+
228
+ type ComboboxVirtualTriggerProps = PopoverVirtualTriggerProps;
229
+
230
+ const ComboboxVirtualTrigger = Popover.VirtualTrigger;
231
+
232
+ //
233
+ // Input
234
+ //
235
+
236
+ type ComboboxInputProps = SearchListInputProps;
237
+
238
+ const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(({ classNames, ...props }, forwardedRef) => {
239
+ return (
240
+ <SearchList.Input
241
+ {...props}
242
+ classNames={[
243
+ 'mli-cardSpacingChrome mbs-cardSpacingChrome mbe-0 is-[calc(100%-2*var(--dx-cardSpacingChrome))]',
244
+ classNames,
245
+ ]}
246
+ ref={forwardedRef}
247
+ />
248
+ );
249
+ });
250
+
251
+ //
252
+ // List
253
+ //
254
+
255
+ type ComboboxListProps = SearchListContentProps;
256
+
257
+ const ComboboxList = forwardRef<HTMLDivElement, ComboboxListProps>(({ classNames, ...props }, forwardedRef) => {
258
+ return (
259
+ <SearchList.Content
260
+ {...props}
261
+ classNames={['min-bs-0 overflow-y-auto plb-cardSpacingChrome', classNames]}
262
+ ref={forwardedRef}
263
+ />
264
+ );
265
+ });
266
+
267
+ //
268
+ // Item
269
+ //
270
+
271
+ type ComboboxItemProps = SearchListItemProps & {
272
+ /** Whether to close the popover when this item is selected. Defaults to true. */
273
+ closeOnSelect?: boolean;
274
+ };
275
+
276
+ const ComboboxItem = forwardRef<HTMLDivElement, ComboboxItemProps>(
277
+ ({ classNames, onSelect, value, closeOnSelect = true, ...props }, forwardedRef) => {
278
+ const { onValueChange, onOpenChange } = useComboboxContext(COMBOBOX_ITEM_NAME);
279
+ const handleSelect = useCallback<NonNullable<SearchListItemProps['onSelect']>>(() => {
280
+ onSelect?.();
281
+ if (value !== undefined) {
282
+ onValueChange?.(value);
283
+ }
284
+ if (closeOnSelect) {
285
+ onOpenChange?.(false);
286
+ }
287
+ }, [onSelect, onValueChange, onOpenChange, value, closeOnSelect]);
288
+
289
+ return (
290
+ <SearchList.Item
291
+ {...props}
292
+ value={value}
293
+ classNames={['mli-cardSpacingChrome pli-cardSpacingChrome', classNames]}
294
+ onSelect={handleSelect}
295
+ ref={forwardedRef}
296
+ />
297
+ );
298
+ },
299
+ );
300
+
301
+ ComboboxItem.displayName = COMBOBOX_ITEM_NAME;
302
+
303
+ //
304
+ // Arrow
305
+ //
306
+
307
+ type ComboboxArrowProps = PopoverArrowProps;
308
+
309
+ const ComboboxArrow = Popover.Arrow;
310
+
311
+ //
312
+ // Empty
313
+ //
314
+
315
+ type ComboboxEmptyProps = SearchListEmptyProps;
316
+
317
+ const ComboboxEmpty = SearchList.Empty;
318
+
319
+ //
320
+ // Combobox
321
+ // https://www.w3.org/WAI/ARIA/apg/patterns/combobox
322
+ //
323
+
324
+ //
325
+ // Portal
326
+ //
327
+
328
+ type ComboboxPortalProps = React.ComponentPropsWithoutRef<typeof Popover.Portal>;
329
+
330
+ const ComboboxPortal = Popover.Portal;
331
+
332
+ export const Combobox = {
333
+ Root: ComboboxRoot,
334
+ Portal: ComboboxPortal,
335
+ Content: ComboboxContent,
336
+ Trigger: ComboboxTrigger,
337
+ VirtualTrigger: ComboboxVirtualTrigger,
338
+ Input: ComboboxInput,
339
+ List: ComboboxList,
340
+ Item: ComboboxItem,
341
+ Arrow: ComboboxArrow,
342
+ Empty: ComboboxEmpty,
343
+ };
344
+
345
+ export type {
346
+ ComboboxRootProps,
347
+ ComboboxPortalProps,
348
+ ComboboxContentProps,
349
+ ComboboxTriggerProps,
350
+ ComboboxVirtualTriggerProps,
351
+ ComboboxInputProps,
352
+ ComboboxListProps,
353
+ ComboboxItemProps,
354
+ ComboboxArrowProps,
355
+ ComboboxEmptyProps,
356
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './Combobox';
@@ -0,0 +1,53 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React, { useState } from 'react';
7
+
8
+ import { faker } from '@dxos/random';
9
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
+
11
+ import { translations } from '../../translations';
12
+
13
+ import { Listbox } from './Listbox';
14
+
15
+ faker.seed(1234);
16
+
17
+ type StoryItem = { value: string; label: string };
18
+
19
+ const options: StoryItem[] = faker.helpers.multiple(
20
+ () => ({ value: faker.string.uuid(), label: faker.commerce.productName() }) satisfies StoryItem,
21
+ { count: 16 },
22
+ );
23
+
24
+ const DefaultStory = () => {
25
+ const [selectedValue, setSelectedValue] = useState<string>();
26
+
27
+ return (
28
+ <Listbox.Root value={selectedValue} onValueChange={setSelectedValue}>
29
+ {options.map((option) => (
30
+ <Listbox.Option key={option.value} value={option.value}>
31
+ <Listbox.OptionLabel>{option.label}</Listbox.OptionLabel>
32
+ <Listbox.OptionIndicator />
33
+ </Listbox.Option>
34
+ ))}
35
+ </Listbox.Root>
36
+ );
37
+ };
38
+
39
+ const meta = {
40
+ title: 'ui/react-ui-searchlist/Listbox',
41
+ component: Listbox.Root,
42
+ render: DefaultStory,
43
+ decorators: [withTheme, withLayout({ layout: 'column', classNames: 'p-2' })],
44
+ parameters: {
45
+ translations,
46
+ },
47
+ } satisfies Meta<typeof Listbox.Root>;
48
+
49
+ export default meta;
50
+
51
+ type Story = StoryObj<typeof meta>;
52
+
53
+ export const Default: Story = {};