@dxos/react-ui-searchlist 0.8.4-main.ae835ea → 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 (49) hide show
  1. package/dist/lib/browser/index.mjs +669 -337
  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 +669 -337
  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 +48 -8
  8. package/dist/types/src/components/Combobox/Combobox.d.ts.map +1 -1
  9. package/dist/types/src/components/Combobox/Combobox.stories.d.ts +1 -1
  10. package/dist/types/src/components/Combobox/Combobox.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -1
  12. package/dist/types/src/components/Listbox/Listbox.stories.d.ts +1 -1
  13. package/dist/types/src/components/SearchList/SearchList.d.ts +83 -20
  14. package/dist/types/src/components/SearchList/SearchList.d.ts.map +1 -1
  15. package/dist/types/src/components/SearchList/SearchList.stories.d.ts +10 -7
  16. package/dist/types/src/components/SearchList/SearchList.stories.d.ts.map +1 -1
  17. package/dist/types/src/components/SearchList/context.d.ts +33 -0
  18. package/dist/types/src/components/SearchList/context.d.ts.map +1 -0
  19. package/dist/types/src/components/SearchList/hooks/index.d.ts +5 -0
  20. package/dist/types/src/components/SearchList/hooks/index.d.ts.map +1 -0
  21. package/dist/types/src/components/SearchList/hooks/useGlobalFilter.d.ts +34 -0
  22. package/dist/types/src/components/SearchList/hooks/useGlobalFilter.d.ts.map +1 -0
  23. package/dist/types/src/components/SearchList/hooks/useSearchListInput.d.ts +12 -0
  24. package/dist/types/src/components/SearchList/hooks/useSearchListInput.d.ts.map +1 -0
  25. package/dist/types/src/components/SearchList/hooks/useSearchListItem.d.ts +10 -0
  26. package/dist/types/src/components/SearchList/hooks/useSearchListItem.d.ts.map +1 -0
  27. package/dist/types/src/components/SearchList/hooks/useSearchListResults.d.ts +36 -0
  28. package/dist/types/src/components/SearchList/hooks/useSearchListResults.d.ts.map +1 -0
  29. package/dist/types/src/components/SearchList/index.d.ts +1 -0
  30. package/dist/types/src/components/SearchList/index.d.ts.map +1 -1
  31. package/dist/types/src/translations.d.ts +2 -2
  32. package/dist/types/src/translations.d.ts.map +1 -1
  33. package/dist/types/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +20 -17
  35. package/src/components/Combobox/Combobox.stories.tsx +9 -4
  36. package/src/components/Combobox/Combobox.tsx +35 -14
  37. package/src/components/Listbox/Listbox.stories.tsx +1 -1
  38. package/src/components/Listbox/Listbox.tsx +8 -3
  39. package/src/components/SearchList/SearchList.stories.tsx +500 -30
  40. package/src/components/SearchList/SearchList.tsx +458 -62
  41. package/src/components/SearchList/context.ts +43 -0
  42. package/src/components/SearchList/hooks/index.ts +8 -0
  43. package/src/components/SearchList/hooks/useGlobalFilter.tsx +61 -0
  44. package/src/components/SearchList/hooks/useSearchListInput.ts +14 -0
  45. package/src/components/SearchList/hooks/useSearchListItem.ts +14 -0
  46. package/src/components/SearchList/hooks/useSearchListResults.ts +104 -0
  47. package/src/components/SearchList/index.ts +1 -0
  48. package/src/translations.ts +1 -1
  49. package/src/types/command-score.d.ts +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"SearchList.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchList/SearchList.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAUzC,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAqBF,QAAA,MAAM,IAAI;;eAEsB,GAAG;wBArBa,UAAU;;;;;;;;;;;CA2BrB,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
1
+ {"version":3,"file":"SearchList.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchList/SearchList.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAkdjE,QAAA,MAAM,IAAI;;eAEsB,GAAG;;;;;;;;;;;;CAME,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAKxB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAK7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAK7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAKhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAExB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /** Context for items - stable, doesn't change when query changes */
2
+ export type SearchListItemContextValue = {
3
+ /** Currently selected item value for keyboard navigation. */
4
+ selectedValue: string | undefined;
5
+ /** Update the selected value. */
6
+ onSelectedValueChange: (value: string | undefined) => void;
7
+ /** Register an item for keyboard navigation. */
8
+ registerItem: (value: string, element: HTMLElement | null, onSelect: (() => void) | undefined, disabled?: boolean) => void;
9
+ /** Unregister an item. */
10
+ unregisterItem: (value: string) => void;
11
+ };
12
+ /** Context for input - can change frequently with query */
13
+ export type SearchListInputContextValue = {
14
+ /** Current search query. */
15
+ query: string;
16
+ /** Update the query value. */
17
+ onQueryChange: (query: string) => void;
18
+ /** Currently selected item value for keyboard navigation. */
19
+ selectedValue: string | undefined;
20
+ /** Update the selected value. */
21
+ onSelectedValueChange: (value: string | undefined) => void;
22
+ /** Get ordered list of registered item values (excludes disabled items). */
23
+ getItemValues: () => string[];
24
+ /** Trigger selection of the currently highlighted item. */
25
+ triggerSelect: () => void;
26
+ };
27
+ export declare const SearchListItemContextProvider: import("react").FC<SearchListItemContextValue & {
28
+ children: React.ReactNode;
29
+ }>, useSearchListItemContext: (consumerName: string) => SearchListItemContextValue;
30
+ export declare const SearchListInputContextProvider: import("react").FC<SearchListInputContextValue & {
31
+ children: React.ReactNode;
32
+ }>, useSearchListInputContext: (consumerName: string) => SearchListInputContextValue;
33
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchList/context.ts"],"names":[],"mappings":"AAMA,oEAAoE;AACpE,MAAM,MAAM,0BAA0B,GAAG;IACvC,6DAA6D;IAC7D,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iCAAiC;IACjC,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3D,gDAAgD;IAChD,YAAY,EAAE,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAClC,QAAQ,CAAC,EAAE,OAAO,KACf,IAAI,CAAC;IACV,0BAA0B;IAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,2BAA2B,GAAG;IACxC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,6DAA6D;IAC7D,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iCAAiC;IACjC,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3D,4EAA4E;IAC5E,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,2DAA2D;IAC3D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAO,6BAA6B;;IAAE,wBAAwB,sDACR,CAAC;AAC9D,eAAO,MAAO,8BAA8B;;IAAE,yBAAyB,uDACR,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './useGlobalFilter';
2
+ export * from './useSearchListInput';
3
+ export * from './useSearchListItem';
4
+ export * from './useSearchListResults';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/SearchList/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ /**
3
+ * Type for a filter function that filters an array of objects.
4
+ */
5
+ export type FilterFunction<T = any> = (objects: T[]) => T[];
6
+ type GlobalFilterContextType = {
7
+ /** The current filter function. */
8
+ filter?: FilterFunction;
9
+ };
10
+ export type GlobalFilterProviderProps = PropsWithChildren<{
11
+ /** The filter function to apply globally. */
12
+ filter?: FilterFunction;
13
+ }>;
14
+ /**
15
+ * Provider that makes a filter function available globally.
16
+ * Used by plugin-search to provide its regex-based filtering.
17
+ */
18
+ export declare const GlobalFilterProvider: ({ children, filter }: GlobalFilterProviderProps) => React.JSX.Element;
19
+ /**
20
+ * Hook to access the global filter context.
21
+ * Returns the filter function if one is provided.
22
+ */
23
+ export declare const useGlobalFilter: () => GlobalFilterContextType;
24
+ /**
25
+ * Hook that applies the global filter to an array of objects.
26
+ * If no filter is set, returns the original objects unchanged.
27
+ *
28
+ * @example
29
+ * const objects = useQuery(db, Filter.everything());
30
+ * const filteredObjects = useGlobalFilteredObjects(objects);
31
+ */
32
+ export declare const useGlobalFilteredObjects: <T extends Record<string, any>>(objects?: T[]) => T[];
33
+ export {};
34
+ //# sourceMappingURL=useGlobalFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGlobalFilter.d.ts","sourceRoot":"","sources":["../../../../../../src/components/SearchList/hooks/useGlobalFilter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAsC,MAAM,OAAO,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;AAE5D,KAAK,uBAAuB,GAAG;IAC7B,mCAAmC;IACnC,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAIF,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;IACxD,6CAA6C;IAC7C,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,sBAAsB,yBAAyB,sBAGnF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,+BAE3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,EAAE,KAAG,CAAC,EAYxF,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hook to access the search context for custom input implementations.
3
+ */
4
+ export declare const useSearchListInput: () => {
5
+ query: string;
6
+ onQueryChange: (query: string) => void;
7
+ selectedValue: string | undefined;
8
+ onSelectedValueChange: (value: string | undefined) => void;
9
+ getItemValues: () => string[];
10
+ triggerSelect: () => void;
11
+ };
12
+ //# sourceMappingURL=useSearchListInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSearchListInput.d.ts","sourceRoot":"","sources":["../../../../../../src/components/SearchList/hooks/useSearchListInput.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;CAI9B,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Hook to access selection state for custom item renderers.
3
+ * Returns the current selected value and registration functions.
4
+ */
5
+ export declare const useSearchListItem: () => {
6
+ selectedValue: string | undefined;
7
+ registerItem: (value: string, element: HTMLElement | null, onSelect: (() => void) | undefined, disabled?: boolean) => void;
8
+ unregisterItem: (value: string) => void;
9
+ };
10
+ //# sourceMappingURL=useSearchListItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSearchListItem.d.ts","sourceRoot":"","sources":["../../../../../../src/components/SearchList/hooks/useSearchListItem.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;CAG7B,CAAC"}
@@ -0,0 +1,36 @@
1
+ export type UseSearchListResultsOptions<T> = {
2
+ /** Items to filter. */
3
+ items: T[];
4
+ /** Custom filter function. Defaults to filtering by extracted string. */
5
+ filter?: (item: T, query: string) => boolean;
6
+ /** Enable fuzzy filtering using command-score algorithm. Defaults to true. */
7
+ fuzzy?: boolean;
8
+ /** Custom function to extract the searchable string from an item. Defaults to accessing 'label' property if it exists. */
9
+ extract?: (item: T) => string;
10
+ /** Minimum score threshold for fuzzy matches (0-1). Defaults to 0. */
11
+ minScore?: number;
12
+ };
13
+ /**
14
+ * Hook to manage search results with fuzzy filtering (enabled by default).
15
+ * Returns filtered results and a handleSearch function to pass to SearchList.Root.
16
+ *
17
+ * @example
18
+ * // Default fuzzy filtering using command-score (tries to extract from 'label' property)
19
+ * const { results, handleSearch } = useSearchListResults({ items });
20
+ *
21
+ * @example
22
+ * // Disable fuzzy for basic case-insensitive substring match
23
+ * const { results, handleSearch } = useSearchListResults({ items, fuzzy: false });
24
+ *
25
+ * @example
26
+ * // Custom extraction for fuzzy filtering
27
+ * const { results, handleSearch } = useSearchListResults({
28
+ * items,
29
+ * extract: (item) => `${item.name} ${item.description}`,
30
+ * });
31
+ */
32
+ export declare const useSearchListResults: <T = unknown>({ items, filter, fuzzy, extract, minScore, }: UseSearchListResultsOptions<T>) => {
33
+ results: T[];
34
+ handleSearch: (searchQuery: string) => void;
35
+ };
36
+ //# sourceMappingURL=useSearchListResults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSearchListResults.d.ts","sourceRoot":"","sources":["../../../../../../src/components/SearchList/hooks/useSearchListResults.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,2BAA2B,CAAC,CAAC,IAAI;IAC3C,uBAAuB;IACvB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,yEAAyE;IACzE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0HAA0H;IAC1H,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,GAAG,OAAO,EAAE,8CAM/C,2BAA2B,CAAC,CAAC,CAAC;;gCA8BgB,MAAM;CA4BtD,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './SearchList';
2
+ export * from './hooks';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchList/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/SearchList/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -1,7 +1,7 @@
1
- export declare const translationKey = "react-ui-searchlist";
1
+ export declare const translationKey = "@dxos/react-ui-searchlist";
2
2
  export declare const translations: [{
3
3
  readonly 'en-US': {
4
- readonly "react-ui-searchlist": {
4
+ readonly "@dxos/react-ui-searchlist": {
5
5
  readonly 'search.placeholder': "Search...";
6
6
  };
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,YAAY;;;;;;EAQM,CAAC"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,8BAA8B,CAAC;AAE1D,eAAO,MAAM,YAAY;;;;;;EAQM,CAAC"}