@dxos/react-ui-searchlist 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 (82) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/browser/index.mjs +716 -408
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +716 -408
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/Combobox/Combobox.d.ts +85 -0
  9. package/dist/types/src/components/Combobox/Combobox.d.ts.map +1 -0
  10. package/dist/types/src/{composites/PopoverCombobox.stories.d.ts → components/Combobox/Combobox.stories.d.ts} +10 -1
  11. package/dist/types/src/components/Combobox/Combobox.stories.d.ts.map +1 -0
  12. package/dist/types/src/components/Combobox/index.d.ts +2 -0
  13. package/dist/types/src/components/Combobox/index.d.ts.map +1 -0
  14. package/dist/types/src/components/{Listbox.d.ts → Listbox/Listbox.d.ts} +6 -6
  15. package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -0
  16. package/dist/types/src/components/Listbox/Listbox.stories.d.ts +21 -0
  17. package/dist/types/src/components/Listbox/Listbox.stories.d.ts.map +1 -0
  18. package/dist/types/src/components/Listbox/index.d.ts +2 -0
  19. package/dist/types/src/components/Listbox/index.d.ts.map +1 -0
  20. package/dist/types/src/components/SearchList/SearchList.d.ts +90 -0
  21. package/dist/types/src/components/SearchList/SearchList.d.ts.map +1 -0
  22. package/dist/types/src/components/SearchList/SearchList.stories.d.ts +28 -0
  23. package/dist/types/src/components/SearchList/SearchList.stories.d.ts.map +1 -0
  24. package/dist/types/src/components/SearchList/context.d.ts +33 -0
  25. package/dist/types/src/components/SearchList/context.d.ts.map +1 -0
  26. package/dist/types/src/components/SearchList/hooks/index.d.ts +5 -0
  27. package/dist/types/src/components/SearchList/hooks/index.d.ts.map +1 -0
  28. package/dist/types/src/components/SearchList/hooks/useGlobalFilter.d.ts +34 -0
  29. package/dist/types/src/components/SearchList/hooks/useGlobalFilter.d.ts.map +1 -0
  30. package/dist/types/src/components/SearchList/hooks/useSearchListInput.d.ts +12 -0
  31. package/dist/types/src/components/SearchList/hooks/useSearchListInput.d.ts.map +1 -0
  32. package/dist/types/src/components/SearchList/hooks/useSearchListItem.d.ts +10 -0
  33. package/dist/types/src/components/SearchList/hooks/useSearchListItem.d.ts.map +1 -0
  34. package/dist/types/src/components/SearchList/hooks/useSearchListResults.d.ts +36 -0
  35. package/dist/types/src/components/SearchList/hooks/useSearchListResults.d.ts.map +1 -0
  36. package/dist/types/src/components/SearchList/index.d.ts +3 -0
  37. package/dist/types/src/components/SearchList/index.d.ts.map +1 -0
  38. package/dist/types/src/components/index.d.ts +2 -1
  39. package/dist/types/src/components/index.d.ts.map +1 -1
  40. package/dist/types/src/index.d.ts +0 -1
  41. package/dist/types/src/index.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +4 -2
  43. package/dist/types/src/translations.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +21 -18
  46. package/src/components/Combobox/Combobox.stories.tsx +62 -0
  47. package/src/components/Combobox/Combobox.tsx +343 -0
  48. package/src/components/Combobox/index.ts +5 -0
  49. package/src/components/Listbox/Listbox.stories.tsx +53 -0
  50. package/src/components/{Listbox.tsx → Listbox/Listbox.tsx} +40 -11
  51. package/src/components/Listbox/index.ts +5 -0
  52. package/src/components/SearchList/SearchList.stories.tsx +532 -0
  53. package/src/components/SearchList/SearchList.tsx +554 -0
  54. package/src/components/SearchList/context.ts +43 -0
  55. package/src/components/SearchList/hooks/index.ts +8 -0
  56. package/src/components/SearchList/hooks/useGlobalFilter.tsx +61 -0
  57. package/src/components/SearchList/hooks/useSearchListInput.ts +14 -0
  58. package/src/components/SearchList/hooks/useSearchListItem.ts +14 -0
  59. package/src/components/SearchList/hooks/useSearchListResults.ts +104 -0
  60. package/src/components/SearchList/index.ts +6 -0
  61. package/src/components/index.ts +2 -1
  62. package/src/index.ts +0 -1
  63. package/src/translations.ts +4 -2
  64. package/src/types/command-score.d.ts +16 -0
  65. package/dist/types/src/components/Listbox.d.ts.map +0 -1
  66. package/dist/types/src/components/Listbox.stories.d.ts +0 -16
  67. package/dist/types/src/components/Listbox.stories.d.ts.map +0 -1
  68. package/dist/types/src/components/SearchList.d.ts +0 -47
  69. package/dist/types/src/components/SearchList.d.ts.map +0 -1
  70. package/dist/types/src/components/SearchList.stories.d.ts +0 -16
  71. package/dist/types/src/components/SearchList.stories.d.ts.map +0 -1
  72. package/dist/types/src/composites/PopoverCombobox.d.ts +0 -32
  73. package/dist/types/src/composites/PopoverCombobox.d.ts.map +0 -1
  74. package/dist/types/src/composites/PopoverCombobox.stories.d.ts.map +0 -1
  75. package/dist/types/src/composites/index.d.ts +0 -2
  76. package/dist/types/src/composites/index.d.ts.map +0 -1
  77. package/src/components/Listbox.stories.tsx +0 -73
  78. package/src/components/SearchList.stories.tsx +0 -55
  79. package/src/components/SearchList.tsx +0 -251
  80. package/src/composites/PopoverCombobox.stories.tsx +0 -47
  81. package/src/composites/PopoverCombobox.tsx +0 -209
  82. package/src/composites/index.ts +0 -5
@@ -0,0 +1,104 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import commandScore from 'command-score';
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+
8
+ export type UseSearchListResultsOptions<T> = {
9
+ /** Items to filter. */
10
+ items: T[];
11
+ /** Custom filter function. Defaults to filtering by extracted string. */
12
+ filter?: (item: T, query: string) => boolean;
13
+ /** Enable fuzzy filtering using command-score algorithm. Defaults to true. */
14
+ fuzzy?: boolean;
15
+ /** Custom function to extract the searchable string from an item. Defaults to accessing 'label' property if it exists. */
16
+ extract?: (item: T) => string;
17
+ /** Minimum score threshold for fuzzy matches (0-1). Defaults to 0. */
18
+ minScore?: number;
19
+ };
20
+
21
+ /**
22
+ * Hook to manage search results with fuzzy filtering (enabled by default).
23
+ * Returns filtered results and a handleSearch function to pass to SearchList.Root.
24
+ *
25
+ * @example
26
+ * // Default fuzzy filtering using command-score (tries to extract from 'label' property)
27
+ * const { results, handleSearch } = useSearchListResults({ items });
28
+ *
29
+ * @example
30
+ * // Disable fuzzy for basic case-insensitive substring match
31
+ * const { results, handleSearch } = useSearchListResults({ items, fuzzy: false });
32
+ *
33
+ * @example
34
+ * // Custom extraction for fuzzy filtering
35
+ * const { results, handleSearch } = useSearchListResults({
36
+ * items,
37
+ * extract: (item) => `${item.name} ${item.description}`,
38
+ * });
39
+ */
40
+ export const useSearchListResults = <T = unknown>({
41
+ items,
42
+ filter,
43
+ fuzzy = true,
44
+ extract,
45
+ minScore = 0,
46
+ }: UseSearchListResultsOptions<T>) => {
47
+ const [query, setQuery] = useState<string>('');
48
+ const queryRef = useRef<string>('');
49
+
50
+ // Update results when items change.
51
+ useEffect(() => {
52
+ queryRef.current = '';
53
+ setQuery('');
54
+ }, [items]);
55
+
56
+ const defaultExtract = useCallback((item: T) => {
57
+ // If item is a string, return it directly
58
+ if (typeof item === 'string') {
59
+ return item;
60
+ }
61
+ // Otherwise, try to access 'label' property
62
+ return (item as any)?.label ?? '';
63
+ }, []);
64
+ const extractFn = extract ?? defaultExtract;
65
+
66
+ const defaultFilter = useCallback(
67
+ (item: T, query: string) => {
68
+ const searchable = extractFn(item);
69
+ return searchable.toLowerCase().includes(query.toLowerCase());
70
+ },
71
+ [extractFn],
72
+ );
73
+
74
+ const filterFn = filter ?? defaultFilter;
75
+
76
+ const handleSearch = useCallback((searchQuery: string) => {
77
+ queryRef.current = searchQuery;
78
+ setQuery(searchQuery);
79
+ }, []);
80
+
81
+ const results = useMemo(() => {
82
+ const currentQuery = queryRef.current;
83
+ if (!currentQuery) {
84
+ return items;
85
+ }
86
+
87
+ if (fuzzy) {
88
+ // Score and filter items using command-score.
89
+ const scored = items
90
+ .map((item) => ({
91
+ item,
92
+ score: commandScore(extractFn(item), currentQuery) as number,
93
+ }))
94
+ .filter(({ score }) => score > minScore)
95
+ .sort((a, b) => b.score - a.score);
96
+
97
+ return scored.map(({ item }) => item);
98
+ } else {
99
+ return items.filter((item) => filterFn(item, currentQuery));
100
+ }
101
+ }, [items, query, filterFn, fuzzy, extractFn, minScore]);
102
+
103
+ return { results, handleSearch };
104
+ };
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export * from './SearchList';
6
+ export * from './hooks';
@@ -2,5 +2,6 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- export * from './SearchList';
5
+ export * from './Combobox';
6
6
  export * from './Listbox';
7
+ export * from './SearchList';
package/src/index.ts CHANGED
@@ -3,5 +3,4 @@
3
3
  //
4
4
 
5
5
  export * from './components';
6
- export * from './composites';
7
6
  export * from './translations';
@@ -4,12 +4,14 @@
4
4
 
5
5
  import { type Resource } from '@dxos/react-ui';
6
6
 
7
- export const translationKey = 'react-ui-searchlist';
7
+ export const translationKey = '@dxos/react-ui-searchlist';
8
8
 
9
9
  export const translations = [
10
10
  {
11
11
  'en-US': {
12
- [translationKey]: {},
12
+ [translationKey]: {
13
+ 'search.placeholder': 'Search...',
14
+ },
13
15
  },
14
16
  },
15
17
  ] as const satisfies Resource[];
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ declare module 'command-score' {
6
+ /**
7
+ * Scores how well a string matches a query using a fuzzy matching algorithm.
8
+ * Used by cmdk for its built-in filtering.
9
+ *
10
+ * @param string - The string to score against.
11
+ * @param query - The search query.
12
+ * @returns A score between 0 and 1, where higher values indicate better matches.
13
+ */
14
+ function commandScore(string: string, query: string): number;
15
+ export default commandScore;
16
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Listbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Listbox.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,yBAAyB,CAAC;AAEzE,OAAO,KAAK,EAAE,EAAE,KAAK,qBAAqB,EAA8C,MAAM,OAAO,CAAC;AAEtG,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAU5E,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAG5D,KAAK,gBAAgB,GAAG,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,GAAG;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,kBAAkB,GAAG,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,GAAG;IACvE,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,QAAA,MAA6B,kBAAkB,+CAAwC,CAAC;AAKxF,KAAK,mBAAmB,GAAG;IACzB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAOF,QAAA,MAAwB,iBAAiB,8FAA2D,CAAC;AA0GrG,KAAK,2BAA2B,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAoB9F,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;AAEjD,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,16 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- declare const DefaultStory: () => React.JSX.Element;
4
- declare const DefaultValueStory: () => React.JSX.Element;
5
- declare const meta: {
6
- title: string;
7
- component: React.ForwardRefExoticComponent<Omit<import("./Listbox").ListboxRootProps, "ref"> & React.RefAttributes<HTMLUListElement>>;
8
- decorators: import("@storybook/react").Decorator[];
9
- parameters: {
10
- layout: string;
11
- };
12
- };
13
- export default meta;
14
- export declare const Default: StoryObj<typeof DefaultStory>;
15
- export declare const DefaultValue: StoryObj<typeof DefaultValueStory>;
16
- //# sourceMappingURL=Listbox.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Listbox.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Listbox.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAMxC,QAAA,MAAM,YAAY,yBAqBjB,CAAC;AAEF,QAAA,MAAM,iBAAiB,yBAmBtB,CAAC;AAEF,QAAA,MAAM,IAAI;;;;;;;CAO2B,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,OAAO,YAAY,CAEjD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,OAAO,iBAAiB,CAE3D,CAAC"}
@@ -1,47 +0,0 @@
1
- import { CommandEmpty, CommandInput, CommandItem, CommandList, CommandRoot } from 'cmdk';
2
- import React, { type ComponentPropsWithRef, type PropsWithChildren } from 'react';
3
- import { type ButtonProps, type TextInputProps, type ThemedClassName } from '@dxos/react-ui';
4
- type SearchListVariant = 'list' | 'menu' | 'listbox';
5
- type SearchListRootProps = ThemedClassName<ComponentPropsWithRef<typeof CommandRoot>> & {
6
- variant?: SearchListVariant;
7
- };
8
- type ComboboxContextValue = {
9
- isCombobox: true;
10
- modalId: string;
11
- open: boolean;
12
- onOpenChange: (nextOpen: boolean) => void;
13
- value: string;
14
- onValueChange: (nextValue: string) => void;
15
- placeholder?: string;
16
- };
17
- type ComboboxRootProps = PropsWithChildren<Partial<ComboboxContextValue & {
18
- defaultOpen: boolean;
19
- defaultValue: string;
20
- placeholder: string;
21
- }>>;
22
- type CommandInputPrimitiveProps = ComponentPropsWithRef<typeof CommandInput>;
23
- type SearchListInputProps = Omit<TextInputProps, 'value' | 'defaultValue' | 'onChange'> & Pick<CommandInputPrimitiveProps, 'value' | 'defaultValue' | 'onValueChange'>;
24
- type SearchListContentProps = ThemedClassName<ComponentPropsWithRef<typeof CommandList>>;
25
- type SearchListEmptyProps = ThemedClassName<ComponentPropsWithRef<typeof CommandEmpty>>;
26
- type SearchListItemProps = ThemedClassName<ComponentPropsWithRef<typeof CommandItem>>;
27
- declare const commandItem = "flex items-center overflow-hidden";
28
- declare const searchListItem = "plb-1 pli-2 rounded-sm select-none cursor-pointer data-[selected]:bg-hoverOverlay hover:bg-hoverOverlay";
29
- type ComboboxTriggerProps = ButtonProps;
30
- export declare const SearchList: {
31
- Root: React.ForwardRefExoticComponent<Omit<SearchListRootProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
32
- Input: React.ForwardRefExoticComponent<Omit<SearchListInputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
33
- Content: React.ForwardRefExoticComponent<Omit<SearchListContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
34
- Empty: React.ForwardRefExoticComponent<Omit<SearchListEmptyProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
35
- Item: React.ForwardRefExoticComponent<Omit<SearchListItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
36
- };
37
- export declare const Combobox: {
38
- Root: {
39
- ({ modalId: propsModalId, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, value: propsValue, defaultValue, onValueChange: propsOnValueChange, placeholder, children, }: ComboboxRootProps): React.JSX.Element;
40
- displayName: string;
41
- };
42
- Trigger: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
43
- useComboboxContext: (consumerName: string) => Partial<ComboboxContextValue>;
44
- };
45
- export type { SearchListRootProps, SearchListInputProps, SearchListContentProps, SearchListEmptyProps, SearchListItemProps, ComboboxRootProps, ComboboxTriggerProps, };
46
- export { commandItem, searchListItem };
47
- //# sourceMappingURL=SearchList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchList.d.ts","sourceRoot":"","sources":["../../../../src/components/SearchList.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACzF,OAAO,KAAK,EAAE,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAA2B,MAAM,OAAO,CAAC;AAE3G,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,eAAe,EAKrB,MAAM,gBAAgB,CAAC;AAGxB,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD,KAAK,mBAAmB,GAAG,eAAe,CAAC,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,GAAG;IACtF,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AASF,KAAK,iBAAiB,GAAG,iBAAiB,CACxC,OAAO,CAAC,oBAAoB,GAAG;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CACpG,CAAC;AAcF,KAAK,0BAA0B,GAAG,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC;AAG7E,KAAK,oBAAoB,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,CAAC,GACrF,IAAI,CAAC,0BAA0B,EAAE,OAAO,GAAG,cAAc,GAAG,eAAe,CAAC,CAAC;AAgC/E,KAAK,sBAAsB,GAAG,eAAe,CAAC,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC;AAYzF,KAAK,oBAAoB,GAAG,eAAe,CAAC,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC;AAYxF,KAAK,mBAAmB,GAAG,eAAe,CAAC,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC;AAEtF,QAAA,MAAM,WAAW,sCAAsC,CAAC;AACxD,QAAA,MAAM,cAAc,4GACuF,CAAC;AA8D5G,KAAK,oBAAoB,GAAG,WAAW,CAAC;AAuCxC,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAC;AAEF,eAAO,MAAM,QAAQ;;+LA5ElB,iBAAiB;;;;;CAgFnB,CAAC;AAEF,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC"}
@@ -1,16 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- type StoryItems = Record<string, string>;
4
- type StoryProps = {
5
- items: StoryItems;
6
- };
7
- declare const meta: {
8
- title: string;
9
- component: any;
10
- render: ({ items }: StoryProps) => React.JSX.Element;
11
- decorators: import("@storybook/react").Decorator[];
12
- };
13
- export default meta;
14
- type Story = StoryObj<typeof meta>;
15
- export declare const Default: Story;
16
- //# sourceMappingURL=SearchList.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchList.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/SearchList.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAUzC,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAiBF,QAAA,MAAM,IAAI;;eAEsB,GAAG;wBAjBa,UAAU;;CAoBrB,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC"}
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { type PopoverArrowProps, type PopoverContentProps, type PopoverVirtualTriggerProps } from '@dxos/react-ui';
3
- import { type ComboboxRootProps, type ComboboxTriggerProps, type SearchListContentProps, type SearchListEmptyProps, type SearchListInputProps, type SearchListItemProps, type SearchListRootProps } from '../components';
4
- type PopoverComboboxRootProps = ComboboxRootProps & {
5
- modal?: boolean;
6
- };
7
- type PopoverComboboxContentProps = SearchListRootProps & PopoverContentProps;
8
- type PopoverComboboxTriggerProps = ComboboxTriggerProps;
9
- type PopoverComboboxVirtualTriggerProps = PopoverVirtualTriggerProps;
10
- type PopoverComboboxInputProps = SearchListInputProps;
11
- type PopoverComboboxListProps = SearchListContentProps;
12
- type PopoverComboboxItemProps = SearchListItemProps;
13
- type PopoverComboboxArrowProps = PopoverArrowProps;
14
- type PopoverComboboxEmptyProps = SearchListEmptyProps;
15
- export declare const PopoverCombobox: {
16
- Root: ({ modal, children, open: propsOpen, onOpenChange: propsOnOpenChange, defaultOpen, ...props }: PopoverComboboxRootProps) => React.JSX.Element;
17
- Content: React.ForwardRefExoticComponent<Omit<PopoverComboboxContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
18
- Trigger: React.ForwardRefExoticComponent<Omit<import("@dxos/react-ui").ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
19
- VirtualTrigger: {
20
- (props: PopoverVirtualTriggerProps & {
21
- __scopePopover?: import("@radix-ui/react-context").Scope;
22
- }): React.JSX.Element;
23
- displayName: string;
24
- };
25
- Input: React.ForwardRefExoticComponent<Omit<SearchListInputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
26
- List: React.ForwardRefExoticComponent<Omit<SearchListContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
27
- Item: React.ForwardRefExoticComponent<Omit<SearchListItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
28
- Arrow: React.ForwardRefExoticComponent<PopoverArrowProps & React.RefAttributes<SVGSVGElement>>;
29
- Empty: React.ForwardRefExoticComponent<Omit<SearchListEmptyProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
30
- };
31
- export type { PopoverComboboxRootProps, PopoverComboboxContentProps, PopoverComboboxTriggerProps, PopoverComboboxVirtualTriggerProps, PopoverComboboxInputProps, PopoverComboboxListProps, PopoverComboboxItemProps, PopoverComboboxArrowProps, PopoverComboboxEmptyProps, };
32
- //# sourceMappingURL=PopoverCombobox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverCombobox.d.ts","sourceRoot":"","sources":["../../../../src/composites/PopoverCombobox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAChC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAEzB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,KAAK,wBAAwB,GAAG,iBAAiB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAwBxE,KAAK,2BAA2B,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAqE7E,KAAK,2BAA2B,GAAG,oBAAoB,CAAC;AAUxD,KAAK,kCAAkC,GAAG,0BAA0B,CAAC;AAIrE,KAAK,yBAAyB,GAAG,oBAAoB,CAAC;AAiBtD,KAAK,wBAAwB,GAAG,sBAAsB,CAAC;AAcvD,KAAK,wBAAwB,GAAG,mBAAmB,CAAC;AAcpD,KAAK,yBAAyB,GAAG,iBAAiB,CAAC;AAInD,KAAK,yBAAyB,GAAG,oBAAoB,CAAC;AAItD,eAAO,MAAM,eAAe;yGAvJzB,wBAAwB;;;;;;;;;;;;;;CAiK1B,CAAC;AAEF,YAAY,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,GAC1B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverCombobox.stories.d.ts","sourceRoot":"","sources":["../../../../src/composites/PopoverCombobox.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AA4B1B,QAAA,MAAM,IAAI;;eAE2B,GAAG;;;CAGH,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './PopoverCombobox';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composites/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC"}
@@ -1,73 +0,0 @@
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 { withTheme } from '@dxos/react-ui/testing';
9
-
10
- import { Listbox } from './Listbox';
11
-
12
- const DefaultStory = () => {
13
- const [selectedValue, setSelectedValue] = useState<string>('option-2');
14
-
15
- const options = [
16
- { value: 'option-1', label: 'First Option' },
17
- { value: 'option-2', label: 'Second Option' },
18
- { value: 'option-3', label: 'Third Option' },
19
- ];
20
-
21
- return (
22
- <div className='w-64'>
23
- <Listbox.Root value={selectedValue} onValueChange={setSelectedValue}>
24
- {options.map((option) => (
25
- <Listbox.Option key={option.value} value={option.value}>
26
- <Listbox.OptionLabel>{option.label}</Listbox.OptionLabel>
27
- <Listbox.OptionIndicator />
28
- </Listbox.Option>
29
- ))}
30
- </Listbox.Root>
31
- </div>
32
- );
33
- };
34
-
35
- const DefaultValueStory = () => {
36
- const options = [
37
- { value: 'apple', label: 'Apple' },
38
- { value: 'banana', label: 'Banana' },
39
- { value: 'cherry', label: 'Cherry' },
40
- ];
41
-
42
- return (
43
- <div className='w-64'>
44
- <Listbox.Root defaultValue='banana'>
45
- {options.map((option) => (
46
- <Listbox.Option key={option.value} value={option.value}>
47
- <Listbox.OptionLabel>{option.label}</Listbox.OptionLabel>
48
- <Listbox.OptionIndicator />
49
- </Listbox.Option>
50
- ))}
51
- </Listbox.Root>
52
- </div>
53
- );
54
- };
55
-
56
- const meta = {
57
- title: 'ui/react-ui-searchlist/Listbox',
58
- component: Listbox.Root,
59
- decorators: [withTheme],
60
- parameters: {
61
- layout: 'fullscreen',
62
- },
63
- } satisfies Meta<typeof Listbox.Root>;
64
-
65
- export default meta;
66
-
67
- export const Default: StoryObj<typeof DefaultStory> = {
68
- render: DefaultStory,
69
- };
70
-
71
- export const DefaultValue: StoryObj<typeof DefaultValueStory> = {
72
- render: DefaultValueStory,
73
- };
@@ -1,55 +0,0 @@
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 { withTheme } from '@dxos/react-ui/testing';
10
-
11
- import { SearchList } from './SearchList';
12
-
13
- type StoryItems = Record<string, string>;
14
-
15
- const defaultItems: StoryItems = faker.helpers
16
- .uniqueArray(faker.commerce.productName, 16)
17
- .sort()
18
- .reduce((acc: StoryItems, label) => {
19
- acc[faker.string.uuid()] = label;
20
- return acc;
21
- }, {});
22
-
23
- type StoryProps = {
24
- items: StoryItems;
25
- };
26
-
27
- const DefaultStory = ({ items = defaultItems }: StoryProps) => {
28
- return (
29
- <SearchList.Root filter={(value, search) => (items[value].includes(search) ? 1 : 0)}>
30
- <SearchList.Input placeholder='Search...' />
31
- <SearchList.Content>
32
- {Object.entries(items).map(([value, label]) => (
33
- <SearchList.Item key={value} value={value} onSelect={(value) => console.log('[item select]', value)}>
34
- {label}
35
- </SearchList.Item>
36
- ))}
37
- </SearchList.Content>
38
- </SearchList.Root>
39
- );
40
- };
41
-
42
- const meta = {
43
- title: 'ui/react-ui-searchlist/SearchList',
44
- component: SearchList.Root as any,
45
- render: DefaultStory,
46
- decorators: [withTheme],
47
- } satisfies Meta<typeof DefaultStory>;
48
-
49
- export default meta;
50
-
51
- type Story = StoryObj<typeof meta>;
52
-
53
- export const Default: Story = {
54
- args: {},
55
- };