@yamada-ui/react 2.1.4-dev-20260323012739 → 2.1.4-dev-20260323160112

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 (196) hide show
  1. package/dist/cjs/components/autocomplete/use-autocomplete.cjs +6 -7
  2. package/dist/cjs/components/autocomplete/use-autocomplete.cjs.map +1 -1
  3. package/dist/esm/components/autocomplete/use-autocomplete.js +6 -7
  4. package/dist/esm/components/autocomplete/use-autocomplete.js.map +1 -1
  5. package/dist/types/components/accordion/accordion.d.ts +2 -2
  6. package/dist/types/components/accordion/use-accordion.d.ts +11 -11
  7. package/dist/types/components/airy/airy.d.ts +2 -2
  8. package/dist/types/components/alert/alert.d.ts +2 -2
  9. package/dist/types/components/alpha-slider/alpha-slider.d.ts +2 -2
  10. package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +2 -2
  11. package/dist/types/components/autocomplete/autocomplete.d.ts +2 -2
  12. package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
  13. package/dist/types/components/autocomplete/use-autocomplete.d.ts +7 -8
  14. package/dist/types/components/avatar/avatar.d.ts +5 -5
  15. package/dist/types/components/avatar/use-avatar-group.d.ts +2 -2
  16. package/dist/types/components/badge/badge.d.ts +2 -2
  17. package/dist/types/components/bleed/bleed.d.ts +2 -2
  18. package/dist/types/components/blockquote/blockquote.d.ts +2 -2
  19. package/dist/types/components/breadcrumb/breadcrumb.d.ts +2 -2
  20. package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +2 -2
  21. package/dist/types/components/button/button.d.ts +2 -2
  22. package/dist/types/components/button/icon-button.d.ts +2 -2
  23. package/dist/types/components/calendar/calendar.d.ts +2 -2
  24. package/dist/types/components/calendar/calendar.style.d.ts +2 -2
  25. package/dist/types/components/calendar/use-calendar.d.ts +8 -8
  26. package/dist/types/components/card/card.d.ts +2 -2
  27. package/dist/types/components/carousel/carousel.d.ts +2 -2
  28. package/dist/types/components/carousel/carousel.style.d.ts +2 -2
  29. package/dist/types/components/carousel/use-carousel.d.ts +3 -3
  30. package/dist/types/components/center/center.d.ts +2 -2
  31. package/dist/types/components/chart/area-chart.d.ts +2 -2
  32. package/dist/types/components/chart/bar-chart.d.ts +2 -2
  33. package/dist/types/components/chart/chart.d.ts +2 -2
  34. package/dist/types/components/chart/line-chart.d.ts +2 -2
  35. package/dist/types/components/chart/pie-chart.d.ts +2 -2
  36. package/dist/types/components/chart/radial-chart.d.ts +2 -2
  37. package/dist/types/components/chart/use-chart.d.ts +2 -2
  38. package/dist/types/components/checkbox/checkbox.d.ts +4 -4
  39. package/dist/types/components/checkbox/use-checkbox-group.d.ts +2 -2
  40. package/dist/types/components/checkbox-card/checkbox-card.d.ts +5 -5
  41. package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
  42. package/dist/types/components/circle-progress/circle-progress.d.ts +2 -2
  43. package/dist/types/components/close-button/close-button.d.ts +2 -2
  44. package/dist/types/components/code/code.d.ts +2 -2
  45. package/dist/types/components/collapse/collapse.d.ts +2 -2
  46. package/dist/types/components/color-picker/color-picker.d.ts +2 -2
  47. package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
  48. package/dist/types/components/color-picker/use-color-picker.d.ts +2 -2
  49. package/dist/types/components/color-selector/color-selector.d.ts +2 -2
  50. package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
  51. package/dist/types/components/color-selector/use-color-selector.d.ts +3 -3
  52. package/dist/types/components/color-swatch/color-swatch.d.ts +2 -2
  53. package/dist/types/components/container/container.d.ts +2 -2
  54. package/dist/types/components/data-list/data-list.d.ts +2 -2
  55. package/dist/types/components/date-picker/date-picker.d.ts +2 -2
  56. package/dist/types/components/date-picker/use-date-picker.d.ts +4 -4
  57. package/dist/types/components/drawer/drawer.d.ts +2 -2
  58. package/dist/types/components/dropzone/dropzone.d.ts +4 -4
  59. package/dist/types/components/editable/editable.d.ts +4 -4
  60. package/dist/types/components/editable/use-editable.d.ts +2 -2
  61. package/dist/types/components/em/em.d.ts +2 -2
  62. package/dist/types/components/empty-state/empty-state.d.ts +2 -2
  63. package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
  64. package/dist/types/components/fade/fade.d.ts +2 -2
  65. package/dist/types/components/field/field.d.ts +3 -3
  66. package/dist/types/components/field/field.style.d.ts +2 -2
  67. package/dist/types/components/field/use-field-props.d.ts +4 -4
  68. package/dist/types/components/fieldset/fieldset.d.ts +3 -3
  69. package/dist/types/components/fieldset/fieldset.style.d.ts +1 -1
  70. package/dist/types/components/file-button/file-button.d.ts +2 -2
  71. package/dist/types/components/file-button/use-file-button.d.ts +18 -18
  72. package/dist/types/components/file-input/file-input.d.ts +2 -2
  73. package/dist/types/components/file-input/file-input.style.d.ts +1 -1
  74. package/dist/types/components/file-input/use-file-input.d.ts +15 -15
  75. package/dist/types/components/flex/flex.d.ts +2 -2
  76. package/dist/types/components/flip/flip.d.ts +4 -4
  77. package/dist/types/components/float/float.d.ts +2 -2
  78. package/dist/types/components/form/form.d.ts +3 -3
  79. package/dist/types/components/format/format-byte.d.ts +4 -4
  80. package/dist/types/components/format/format-date-time.d.ts +4 -4
  81. package/dist/types/components/format/format-number.d.ts +2 -2
  82. package/dist/types/components/grid/grid-item.d.ts +2 -2
  83. package/dist/types/components/grid/grid.d.ts +2 -2
  84. package/dist/types/components/group/group.d.ts +2 -2
  85. package/dist/types/components/group/use-group.d.ts +2 -2
  86. package/dist/types/components/heading/heading.d.ts +2 -2
  87. package/dist/types/components/hue-slider/hue-slider.d.ts +3 -3
  88. package/dist/types/components/icon/icon.d.ts +5 -5
  89. package/dist/types/components/image/image.d.ts +2 -2
  90. package/dist/types/components/indicator/indicator.d.ts +4 -4
  91. package/dist/types/components/infinite-scroll-area/infinite-scroll-area.d.ts +2 -2
  92. package/dist/types/components/infinite-scroll-area/infinite-scroll-area.style.d.ts +2 -2
  93. package/dist/types/components/input/input-addon.d.ts +2 -2
  94. package/dist/types/components/input/input-element.d.ts +2 -2
  95. package/dist/types/components/input/input.d.ts +2 -2
  96. package/dist/types/components/kbd/kbd.d.ts +2 -2
  97. package/dist/types/components/link/link.d.ts +2 -2
  98. package/dist/types/components/link-box/link-box.d.ts +2 -2
  99. package/dist/types/components/list/list.d.ts +2 -2
  100. package/dist/types/components/loading/loading-provider.d.ts +2 -2
  101. package/dist/types/components/loading/loading.d.ts +3 -3
  102. package/dist/types/components/mark/mark.d.ts +2 -2
  103. package/dist/types/components/menu/menu.d.ts +2 -2
  104. package/dist/types/components/menu/use-menu.d.ts +11 -11
  105. package/dist/types/components/modal/modal.d.ts +2 -2
  106. package/dist/types/components/native-accordion/native-accordion.d.ts +2 -2
  107. package/dist/types/components/native-accordion/use-native-accordion.d.ts +2 -2
  108. package/dist/types/components/native-popover/native-popover.d.ts +2 -2
  109. package/dist/types/components/native-select/native-select.d.ts +2 -2
  110. package/dist/types/components/native-table/native-table.d.ts +4 -4
  111. package/dist/types/components/number-input/number-input.d.ts +2 -2
  112. package/dist/types/components/number-input/number-input.style.d.ts +1 -1
  113. package/dist/types/components/pagination/pagination.d.ts +2 -2
  114. package/dist/types/components/pagination/use-pagination.d.ts +2 -2
  115. package/dist/types/components/password-input/password-input.d.ts +2 -2
  116. package/dist/types/components/password-input/strength-meter.d.ts +2 -2
  117. package/dist/types/components/password-input/use-password-input.d.ts +2 -2
  118. package/dist/types/components/pin-input/pin-input.d.ts +2 -2
  119. package/dist/types/components/pin-input/use-pin-input.d.ts +7 -7
  120. package/dist/types/components/popover/popover.d.ts +2 -2
  121. package/dist/types/components/progress/progress.d.ts +4 -4
  122. package/dist/types/components/progress/use-progress.d.ts +706 -706
  123. package/dist/types/components/qr-code/qr-code.d.ts +2 -2
  124. package/dist/types/components/radio/radio.d.ts +4 -4
  125. package/dist/types/components/radio/use-radio-group.d.ts +2 -2
  126. package/dist/types/components/radio-card/radio-card.d.ts +5 -5
  127. package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
  128. package/dist/types/components/rating/use-rating.d.ts +7 -7
  129. package/dist/types/components/reorder/reorder.d.ts +2 -2
  130. package/dist/types/components/reorder/reorder.style.d.ts +1 -1
  131. package/dist/types/components/reorder/use-reorder.d.ts +3 -3
  132. package/dist/types/components/resizable/resizable.d.ts +2 -2
  133. package/dist/types/components/resizable/resizable.style.d.ts +2 -2
  134. package/dist/types/components/resizable/use-resizable.d.ts +2 -2
  135. package/dist/types/components/ripple/ripple.d.ts +2 -2
  136. package/dist/types/components/ripple/use-ripple.d.ts +2 -2
  137. package/dist/types/components/rotate/rotate.d.ts +2 -2
  138. package/dist/types/components/saturation-slider/saturation-slider.d.ts +2 -2
  139. package/dist/types/components/saturation-slider/use-saturation-slider.d.ts +2 -2
  140. package/dist/types/components/scroll-area/scroll-area.d.ts +2 -2
  141. package/dist/types/components/segmented-control/segmented-control.d.ts +2 -2
  142. package/dist/types/components/segmented-control/use-segmented-control.d.ts +9 -9
  143. package/dist/types/components/select/select.d.ts +2 -2
  144. package/dist/types/components/select/select.style.d.ts +1 -1
  145. package/dist/types/components/select/use-select.d.ts +4 -4
  146. package/dist/types/components/separator/separator.d.ts +2 -2
  147. package/dist/types/components/simple-grid/simple-grid.d.ts +2 -2
  148. package/dist/types/components/skeleton/skeleton.d.ts +2 -2
  149. package/dist/types/components/slide/slide.d.ts +2 -2
  150. package/dist/types/components/slide-fade/slide-fade.d.ts +2 -2
  151. package/dist/types/components/slider/slider.d.ts +2 -2
  152. package/dist/types/components/slider/use-slider.d.ts +2 -2
  153. package/dist/types/components/stack/h-stack.d.ts +2 -2
  154. package/dist/types/components/stack/stack.d.ts +2 -2
  155. package/dist/types/components/stack/v-stack.d.ts +2 -2
  156. package/dist/types/components/stack/z-stack.d.ts +2 -2
  157. package/dist/types/components/stat/stat.d.ts +2 -2
  158. package/dist/types/components/stat/stat.style.d.ts +2 -2
  159. package/dist/types/components/status/status.d.ts +2 -2
  160. package/dist/types/components/steps/steps.d.ts +2 -2
  161. package/dist/types/components/steps/steps.style.d.ts +1 -1
  162. package/dist/types/components/steps/use-steps.d.ts +10 -10
  163. package/dist/types/components/switch/switch.d.ts +2 -2
  164. package/dist/types/components/table/table.d.ts +2 -2
  165. package/dist/types/components/tabs/tabs.d.ts +2 -2
  166. package/dist/types/components/tabs/use-tabs.d.ts +16 -16
  167. package/dist/types/components/tag/tag.d.ts +2 -2
  168. package/dist/types/components/tag/tag.style.d.ts +1 -1
  169. package/dist/types/components/text/text.d.ts +2 -2
  170. package/dist/types/components/textarea/textarea.d.ts +2 -2
  171. package/dist/types/components/textarea/use-autosize.d.ts +2 -2
  172. package/dist/types/components/timeline/timeline.d.ts +5 -5
  173. package/dist/types/components/timeline/timeline.style.d.ts +2 -2
  174. package/dist/types/components/toggle/toggle.d.ts +5 -5
  175. package/dist/types/components/toggle/use-toggle-group.d.ts +2 -2
  176. package/dist/types/components/toggle/use-toggle.d.ts +2 -2
  177. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  178. package/dist/types/components/visually-hidden/visually-hidden.d.ts +2 -2
  179. package/dist/types/components/wrap/wrap.d.ts +2 -2
  180. package/dist/types/core/components/create-component.d.ts +7 -7
  181. package/dist/types/core/system/color-mode-provider.d.ts +2 -2
  182. package/dist/types/core/system/storage-script.d.ts +3 -3
  183. package/dist/types/core/system/styled.d.ts +2 -2
  184. package/dist/types/core/system/system-provider.d.ts +2 -2
  185. package/dist/types/hooks/use-breakpoint/use-breakpoint-state.d.ts +2 -2
  186. package/dist/types/hooks/use-clickable/index.d.ts +7 -7
  187. package/dist/types/hooks/use-clipboard/index.d.ts +2 -2
  188. package/dist/types/hooks/use-combobox/index.d.ts +12 -12
  189. package/dist/types/hooks/use-counter/index.d.ts +2 -2
  190. package/dist/types/hooks/use-field-sizing/index.d.ts +2 -2
  191. package/dist/types/hooks/use-hover/index.d.ts +2 -2
  192. package/dist/types/hooks/use-popper/index.d.ts +2 -2
  193. package/dist/types/providers/i18n-provider/i18n-provider.d.ts +3 -3
  194. package/dist/types/providers/ui-provider/ui-provider.d.ts +2 -2
  195. package/dist/types/utils/children.d.ts +2 -2
  196. package/package.json +2 -2
@@ -24,30 +24,29 @@ const defaultRender = ({ count, focused, index, label, max, separator }) => {
24
24
  });
25
25
  };
26
26
  const getInputValue = (item) => (0, require_utils_index.utils_exports.isString)(item?.label) ? item.label : item?.query ?? "";
27
- const defaultFilter = (inputValue, items, matcher) => {
27
+ const defaultFilter = (inputValue, items, match$1) => {
28
28
  if (!inputValue.length) return items;
29
29
  return items.map((item) => {
30
30
  if ("items" in item) {
31
31
  const items$1 = item.items.filter((item$1) => {
32
- if ("query" in item$1) return matcher(inputValue, item$1.query);
33
- else if ((0, require_utils_index.utils_exports.isString)(item$1.label)) return matcher(inputValue, item$1.label);
32
+ if ("query" in item$1) return (0, require_utils_index.utils_exports.isString)(item$1.query) && match$1(item$1.query, inputValue);
33
+ else if ((0, require_utils_index.utils_exports.isString)(item$1.label)) return (0, require_utils_index.utils_exports.isString)(item$1.label) && match$1(item$1.label, inputValue);
34
34
  });
35
35
  if (items$1.length) return {
36
36
  ...item,
37
37
  items: items$1
38
38
  };
39
39
  } else if ("query" in item) {
40
- if (matcher(inputValue, item.query)) return item;
40
+ if ((0, require_utils_index.utils_exports.isString)(item.query) && match$1(item.query, inputValue)) return item;
41
41
  } else if ((0, require_utils_index.utils_exports.isString)(item.label)) {
42
- if (matcher(inputValue, item.label)) return item;
42
+ if ((0, require_utils_index.utils_exports.isString)(item.label) && match$1(item.label, inputValue)) return item;
43
43
  }
44
44
  }).filter(Boolean);
45
45
  };
46
- const defaultMatcher = (input, target) => target?.toLowerCase().includes(input.toLowerCase()) ?? false;
47
46
  const [AutocompleteContext, useAutocompleteContext] = require_context.createContext({ name: "AutocompleteContext" });
48
47
  const useAutocomplete = (props = {}) => {
49
48
  const { t } = require_i18n_provider.useI18n("autocomplete");
50
- const { props: { id, ref, name, allowCustomValue = false, closeOnChange = false, multiple = false, closeOnSelect = !multiple, defaultInputValue, defaultValue = multiple ? [] : "", disabled, emptyMessage = t("No results found"), filter = defaultFilter, focusOnClear = true, inputValue: inputValueProp, items = [], matcher = defaultMatcher, max, openOnChange = true, openOnClick = true, openOnFocus = true, placeholder, readOnly, render = defaultRender, required, separator = ",", value: valueProp, onChange: onChangeProp, onInputChange: onInputChangeProp, ...rest }, ariaProps, dataProps, eventProps } = require_use_field_props.useFieldProps(props);
49
+ const { props: { id, ref, name, allowCustomValue = false, closeOnChange = false, multiple = false, closeOnSelect = !multiple, defaultInputValue, defaultValue = multiple ? [] : "", disabled, emptyMessage = t("No results found"), filter = defaultFilter, focusOnClear = true, inputValue: inputValueProp, items = [], matcher = require_utils_index.utils_exports.match, max, openOnChange = true, openOnClick = true, openOnFocus = true, placeholder, readOnly, render = defaultRender, required, separator = ",", value: valueProp, onChange: onChangeProp, onInputChange: onInputChangeProp, ...rest }, ariaProps, dataProps, eventProps } = require_use_field_props.useFieldProps(props);
51
50
  const fieldRef = (0, react.useRef)(null);
52
51
  const contentRef = (0, react.useRef)(null);
53
52
  const inputRef = (0, react.useRef)(null);
@@ -1 +1 @@
1
- {"version":3,"file":"use-autocomplete.cjs","names":["defaultRender: AutocompleteItemRender","defaultFilter: AutocompleteFilter","items","item","defaultMatcher: AutocompleteMatcher","createContext","useI18n","useFieldProps","valueMap: { [key: string]: ComboboxItemWithValue }","valueMap","useControllableState","useCombobox","value","onClear","inputValue","isComposing","getRootProps: PropGetter","props","getFieldProps: PropGetter","mergeRefs","ref","getInputProps: PropGetter<\"input\">","visuallyHiddenAttributes","getContentProps: PropGetter","getIconProps: PropGetter","runKeyAction","useComboboxItem"],"sources":["../../../../src/components/autocomplete/use-autocomplete.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type {\n ComboboxItem,\n ComboboxItemWithValue,\n UseComboboxItemProps,\n UseComboboxProps,\n} from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox, useComboboxItem } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isComposing,\n isNumber,\n isString,\n isUndefined,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface AutocompleteRenderProps extends ComboboxItemWithValue {\n count: number\n focused: boolean\n index: number\n separator: string\n onClear: () => void\n max?: number\n}\n\nexport interface AutocompleteItemRender {\n (props: AutocompleteRenderProps): ReactNode\n}\n\nconst defaultRender: AutocompleteItemRender = ({\n count,\n focused,\n index,\n label,\n max,\n separator,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {label}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nconst getInputValue = (item?: ComboboxItemWithValue) =>\n isString(item?.label) ? item.label : (item?.query ?? \"\")\n\nexport interface AutocompleteFilter {\n (\n inputValue: string,\n items: ComboboxItem[],\n matcher: AutocompleteMatcher,\n ): ComboboxItem[]\n}\n\nconst defaultFilter: AutocompleteFilter = (inputValue, items, matcher) => {\n if (!inputValue.length) return items\n\n return items\n .map((item) => {\n if (\"items\" in item) {\n const items = item.items.filter((item) => {\n if (\"query\" in item) {\n return matcher(inputValue, item.query)\n } else if (isString(item.label)) {\n return matcher(inputValue, item.label)\n }\n })\n\n if (items.length) return { ...item, items }\n } else if (\"query\" in item) {\n if (matcher(inputValue, item.query)) return item\n } else if (isString(item.label)) {\n if (matcher(inputValue, item.label)) return item\n }\n })\n .filter(Boolean) as ComboboxItem[]\n}\n\nexport interface AutocompleteMatcher {\n (input: string, target?: string): boolean\n}\n\nconst defaultMatcher: AutocompleteMatcher = (input, target) =>\n target?.toLowerCase().includes(input.toLowerCase()) ?? false\n\ninterface AutocompleteContext extends Pick<\n UseAutocompleteReturn,\n \"max\" | \"value\"\n> {}\n\nconst [AutocompleteContext, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n })\n\nexport { AutocompleteContext, useAutocompleteContext }\n\nexport interface UseAutocompleteProps<Multiple extends boolean = false>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\" | \"value\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the autocomplete will allow custom value.\n *\n * @default false\n */\n allowCustomValue?: boolean\n /**\n * If `true`, the autocomplete will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: string\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: Multiple extends true ? string[] : string\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: ReactNode\n /**\n * The function to filter the items.\n */\n filter?: AutocompleteFilter\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: string\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: ComboboxItem[]\n /**\n * The function to match the items.\n */\n matcher?: AutocompleteMatcher\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * If `true`, the autocomplete will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the autocomplete will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the autocomplete will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The placeholder for autocomplete.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The value of the autocomplete.\n */\n value?: Multiple extends true ? string[] : string\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: Multiple extends true ? string[] : string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: string) => void\n /**\n * The function to render the selected items.\n */\n render?: (props: AutocompleteRenderProps) => ReactNode\n}\n\nexport const useAutocomplete = <Multiple extends boolean = false>(\n props: UseAutocompleteProps<Multiple> = {},\n) => {\n type MaybeValue = Multiple extends true ? string[] : string\n\n const { t } = useI18n(\"autocomplete\")\n const {\n props: {\n id,\n ref,\n name,\n allowCustomValue = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultValue = (multiple ? [] : \"\") as MaybeValue,\n disabled,\n emptyMessage = t(\"No results found\"),\n filter = defaultFilter,\n focusOnClear = true,\n inputValue: inputValueProp,\n items = [],\n matcher = defaultMatcher,\n max,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n placeholder,\n readOnly,\n render = defaultRender,\n required,\n separator = \",\",\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const valueMap = useMemo<{ [key: string]: ComboboxItemWithValue }>(() => {\n const valueMap: { [key: string]: ComboboxItemWithValue } = {}\n\n items.forEach((item) => {\n if (\"items\" in item) {\n item.items.forEach((item) => {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n })\n } else {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n }\n })\n\n return valueMap\n }, [items])\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [inputValue, setInputValue] = useControllableState({\n defaultValue:\n defaultInputValue ??\n getInputValue(isArray(value) ? undefined : valueMap[value as string]),\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (isArray(prev)) {\n if (prev.includes(selectedValue)) {\n return prev.filter(\n (prevValue) => prevValue !== selectedValue,\n ) as MaybeValue\n } else if (!isNumber(max) || prev.length < max) {\n return [...prev, selectedValue] as MaybeValue\n } else {\n return prev\n }\n } else {\n return selectedValue as MaybeValue\n }\n })\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n const item = valueMap[selectedValue]\n\n setInputValue(getInputValue(item))\n }\n },\n [max, setInputValue, setValue, value, valueMap],\n )\n const {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onSelect,\n } = useCombobox({\n closeOnSelect,\n disabled,\n initialFocusValue: isArray(value) ? value[0] : value,\n openOnClick: false,\n openOnEnter: false,\n openOnSpace: false,\n readOnly,\n selectFocusRef: inputRef,\n selectOnSpace: false,\n onChange,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const filteredItems = useMemo<ComboboxItem[]>(() => {\n if (!items.length) return []\n\n return filter(inputValue, items, matcher)\n }, [filter, inputValue, items, matcher])\n const resolvedItems = useMemo<ComboboxItem[]>(() => {\n return filteredItems.length\n ? filteredItems\n : [{ \"data-empty\": \"\", label: emptyMessage }]\n }, [filteredItems, emptyMessage])\n const empty = useMemo(\n () => !resolvedItems.filter(({ hidden }) => !hidden).length,\n [resolvedItems],\n )\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((value, index) => {\n const item = valueMap[value] ?? { label: value, value }\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n if (item.value) onChange(item.value)\n }\n\n const component = render({\n count,\n focused,\n index,\n max,\n separator,\n onClear,\n ...item,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [focused, max, onChange, render, separator, value, valueMap])\n const hasValues = isArray(value) && !!value.length\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n activeDescendant.current = null\n\n const inputValue = ev.target.value\n\n setInputValue(inputValue)\n\n if (inputValue.length || isArray(value)) return\n\n setValue(\"\" as MaybeValue)\n },\n [\n activeDescendant,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n setInputValue,\n setValue,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!isArray(value)) return\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) => prev.slice(0, -1) as MaybeValue)\n },\n Enter: (ev) => {\n if (!open || !inputValue.length || activeDescendant.current) return\n\n const item = filteredItems[0]\n\n if (!item) {\n if (!allowCustomValue || !isArray(value)) return\n\n ev.preventDefault()\n\n onSelect(inputValue)\n } else {\n ev.preventDefault()\n\n if (\"items\" in item) {\n onSelect(item.items[0]?.value)\n } else {\n onSelect(item.value)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n activeDescendant,\n allowCustomValue,\n disabled,\n filteredItems,\n onSelect,\n open,\n setValue,\n value,\n ],\n )\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n inputRef.current?.focus()\n\n if (openOnClick) onOpenWithActiveDescendant(descendants.enabledFirstValue)\n }, [descendants, interactive, onOpenWithActiveDescendant, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n\n focusByClickRef.current = false\n },\n [openOnFocus, onOpenWithActiveDescendant, descendants.enabledFirstValue],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setFocused(false)\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n if (allowCustomValue) {\n if (inputValue) setValue(inputValue as MaybeValue)\n } else {\n const item = valueMap[value as string]\n\n setInputValue(getInputValue(item))\n }\n }\n }\n },\n [allowCustomValue, inputValue, setInputValue, setValue, value, valueMap],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => (isArray(prev) ? [] : \"\") as MaybeValue)\n setInputValue(\"\")\n\n if (focusOnClear) inputRef.current?.focus()\n }, [focusOnClear, interactive, setInputValue, setValue])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n setInputValue(\n getInputValue(valueProp ? valueMap[valueProp as string] : undefined),\n )\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n tabIndex: -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n }),\n\n [getTriggerProps, onClick],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!focused && isArray(value) && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...props.style,\n },\n \"data-max\": dataAttr(\n isArray(value) && isNumber(max) && value.length >= max,\n ),\n autoCapitalize: \"off\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n disabled,\n placeholder: hasValues ? undefined : placeholder,\n readOnly,\n required,\n spellCheck: false,\n value: inputValue,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n dataProps,\n disabled,\n focused,\n hasValues,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n hidden: empty,\n ...props,\n }),\n [empty, getComboboxContentProps],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n descendants,\n inputValue,\n interactive,\n items: resolvedItems,\n max,\n open,\n setInputValue,\n setValue,\n value,\n valueMap,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n getSeparatorProps,\n popoverProps,\n onActiveDescendant,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport interface UseAutocompleteOptionProps extends UseComboboxItemProps {}\n\nexport const useAutocompleteOption = ({\n children,\n closeOnSelect,\n disabled,\n hidden,\n value,\n ...rest\n}: UseAutocompleteOptionProps = {}) => {\n const { max, value: selectedValue } = useAutocompleteContext()\n\n value ??= isString(children) ? children : undefined\n\n const selected = isArray(selectedValue)\n ? !isUndefined(value) && selectedValue.includes(value)\n : selectedValue === value\n const completed =\n isNumber(max) && isArray(selectedValue) && selectedValue.length >= max\n const { getIndicatorProps, getItemProps } = useComboboxItem({\n children,\n closeOnSelect,\n disabled: disabled || hidden || (completed && !selected),\n hidden,\n selected,\n value,\n ...rest,\n })\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}) => getItemProps(props),\n [getItemProps],\n )\n\n return { getIndicatorProps, getOptionProps }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8DA,MAAMA,iBAAyC,EAC7C,OACA,SACA,OACA,OACA,KACA,gBACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,4CAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,iDAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAIX,MAAM,iBAAiB,yDACZ,MAAM,MAAM,GAAG,KAAK,QAAS,MAAM,SAAS;AA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AAK,OAAO,kBAAkB,wBAAwB;AAE9D,2DAAmB,SAAS,GAAG,WAAW;CAE1C,MAAM,0DAAmB,cAAc,GACnC,oDAAa,MAAM,IAAI,cAAc,SAAS,MAAM,GACpD,kBAAkB;CACtB,MAAM,4DACK,IAAI,mDAAY,cAAc,IAAI,cAAc,UAAU;CACrE,MAAM,EAAE,mBAAmB,iBAAiBC,iDAAgB;EAC1D;EACA;EACA,UAAU,YAAY,UAAW,aAAa,CAAC;EAC/C;EACA;EACA;EACA,GAAG;EACJ,CAAC;AAOF,QAAO;EAAE;EAAmB,wCAJzB,QAAQ,EAAE,KAAK,aAAa,MAAM,EACnC,CAAC,aAAa,CACf;EAE2C"}
1
+ {"version":3,"file":"use-autocomplete.cjs","names":["defaultRender: AutocompleteItemRender","defaultFilter: AutocompleteFilter","items","item","match","createContext","useI18n","useFieldProps","valueMap: { [key: string]: ComboboxItemWithValue }","valueMap","useControllableState","useCombobox","value","onClear","inputValue","isComposing","getRootProps: PropGetter","props","getFieldProps: PropGetter","mergeRefs","ref","getInputProps: PropGetter<\"input\">","visuallyHiddenAttributes","getContentProps: PropGetter","getIconProps: PropGetter","runKeyAction","useComboboxItem"],"sources":["../../../../src/components/autocomplete/use-autocomplete.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type {\n ComboboxItem,\n ComboboxItemWithValue,\n UseComboboxItemProps,\n UseComboboxProps,\n} from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox, useComboboxItem } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isComposing,\n isNumber,\n isString,\n isUndefined,\n match,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface AutocompleteRenderProps extends ComboboxItemWithValue {\n count: number\n focused: boolean\n index: number\n separator: string\n onClear: () => void\n max?: number\n}\n\nexport interface AutocompleteItemRender {\n (props: AutocompleteRenderProps): ReactNode\n}\n\nconst defaultRender: AutocompleteItemRender = ({\n count,\n focused,\n index,\n label,\n max,\n separator,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {label}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nconst getInputValue = (item?: ComboboxItemWithValue) =>\n isString(item?.label) ? item.label : (item?.query ?? \"\")\n\nexport interface AutocompleteFilter {\n (\n inputValue: string,\n items: ComboboxItem[],\n matcher: AutocompleteMatcher,\n ): ComboboxItem[]\n}\n\nconst defaultFilter: AutocompleteFilter = (inputValue, items, match) => {\n if (!inputValue.length) return items\n\n return items\n .map((item) => {\n if (\"items\" in item) {\n const items = item.items.filter((item) => {\n if (\"query\" in item) {\n return isString(item.query) && match(item.query, inputValue)\n } else if (isString(item.label)) {\n return isString(item.label) && match(item.label, inputValue)\n }\n })\n\n if (items.length) return { ...item, items }\n } else if (\"query\" in item) {\n if (isString(item.query) && match(item.query, inputValue)) return item\n } else if (isString(item.label)) {\n if (isString(item.label) && match(item.label, inputValue)) return item\n }\n })\n .filter(Boolean) as ComboboxItem[]\n}\n\nexport type AutocompleteMatcher = typeof match\n\ninterface AutocompleteContext extends Pick<\n UseAutocompleteReturn,\n \"max\" | \"value\"\n> {}\n\nconst [AutocompleteContext, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n })\n\nexport { AutocompleteContext, useAutocompleteContext }\n\nexport interface UseAutocompleteProps<Multiple extends boolean = false>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\" | \"value\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the autocomplete will allow custom value.\n *\n * @default false\n */\n allowCustomValue?: boolean\n /**\n * If `true`, the autocomplete will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: string\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: Multiple extends true ? string[] : string\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: ReactNode\n /**\n * The function to filter the items.\n */\n filter?: AutocompleteFilter\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: string\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: ComboboxItem[]\n /**\n * The function to match the items.\n */\n matcher?: AutocompleteMatcher\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * If `true`, the autocomplete will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the autocomplete will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the autocomplete will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The placeholder for autocomplete.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The value of the autocomplete.\n */\n value?: Multiple extends true ? string[] : string\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: Multiple extends true ? string[] : string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: string) => void\n /**\n * The function to render the selected items.\n */\n render?: (props: AutocompleteRenderProps) => ReactNode\n}\n\nexport const useAutocomplete = <Multiple extends boolean = false>(\n props: UseAutocompleteProps<Multiple> = {},\n) => {\n type MaybeValue = Multiple extends true ? string[] : string\n\n const { t } = useI18n(\"autocomplete\")\n const {\n props: {\n id,\n ref,\n name,\n allowCustomValue = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultValue = (multiple ? [] : \"\") as MaybeValue,\n disabled,\n emptyMessage = t(\"No results found\"),\n filter = defaultFilter,\n focusOnClear = true,\n inputValue: inputValueProp,\n items = [],\n matcher = match,\n max,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n placeholder,\n readOnly,\n render = defaultRender,\n required,\n separator = \",\",\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const valueMap = useMemo<{ [key: string]: ComboboxItemWithValue }>(() => {\n const valueMap: { [key: string]: ComboboxItemWithValue } = {}\n\n items.forEach((item) => {\n if (\"items\" in item) {\n item.items.forEach((item) => {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n })\n } else {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n }\n })\n\n return valueMap\n }, [items])\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [inputValue, setInputValue] = useControllableState({\n defaultValue:\n defaultInputValue ??\n getInputValue(isArray(value) ? undefined : valueMap[value as string]),\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (isArray(prev)) {\n if (prev.includes(selectedValue)) {\n return prev.filter(\n (prevValue) => prevValue !== selectedValue,\n ) as MaybeValue\n } else if (!isNumber(max) || prev.length < max) {\n return [...prev, selectedValue] as MaybeValue\n } else {\n return prev\n }\n } else {\n return selectedValue as MaybeValue\n }\n })\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n const item = valueMap[selectedValue]\n\n setInputValue(getInputValue(item))\n }\n },\n [max, setInputValue, setValue, value, valueMap],\n )\n const {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onSelect,\n } = useCombobox({\n closeOnSelect,\n disabled,\n initialFocusValue: isArray(value) ? value[0] : value,\n openOnClick: false,\n openOnEnter: false,\n openOnSpace: false,\n readOnly,\n selectFocusRef: inputRef,\n selectOnSpace: false,\n onChange,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const filteredItems = useMemo<ComboboxItem[]>(() => {\n if (!items.length) return []\n\n return filter(inputValue, items, matcher)\n }, [filter, inputValue, items, matcher])\n const resolvedItems = useMemo<ComboboxItem[]>(() => {\n return filteredItems.length\n ? filteredItems\n : [{ \"data-empty\": \"\", label: emptyMessage }]\n }, [filteredItems, emptyMessage])\n const empty = useMemo(\n () => !resolvedItems.filter(({ hidden }) => !hidden).length,\n [resolvedItems],\n )\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((value, index) => {\n const item = valueMap[value] ?? { label: value, value }\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n if (item.value) onChange(item.value)\n }\n\n const component = render({\n count,\n focused,\n index,\n max,\n separator,\n onClear,\n ...item,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [focused, max, onChange, render, separator, value, valueMap])\n const hasValues = isArray(value) && !!value.length\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n activeDescendant.current = null\n\n const inputValue = ev.target.value\n\n setInputValue(inputValue)\n\n if (inputValue.length || isArray(value)) return\n\n setValue(\"\" as MaybeValue)\n },\n [\n activeDescendant,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n setInputValue,\n setValue,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!isArray(value)) return\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) => prev.slice(0, -1) as MaybeValue)\n },\n Enter: (ev) => {\n if (!open || !inputValue.length || activeDescendant.current) return\n\n const item = filteredItems[0]\n\n if (!item) {\n if (!allowCustomValue || !isArray(value)) return\n\n ev.preventDefault()\n\n onSelect(inputValue)\n } else {\n ev.preventDefault()\n\n if (\"items\" in item) {\n onSelect(item.items[0]?.value)\n } else {\n onSelect(item.value)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n activeDescendant,\n allowCustomValue,\n disabled,\n filteredItems,\n onSelect,\n open,\n setValue,\n value,\n ],\n )\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n inputRef.current?.focus()\n\n if (openOnClick) onOpenWithActiveDescendant(descendants.enabledFirstValue)\n }, [descendants, interactive, onOpenWithActiveDescendant, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n\n focusByClickRef.current = false\n },\n [openOnFocus, onOpenWithActiveDescendant, descendants.enabledFirstValue],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setFocused(false)\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n if (allowCustomValue) {\n if (inputValue) setValue(inputValue as MaybeValue)\n } else {\n const item = valueMap[value as string]\n\n setInputValue(getInputValue(item))\n }\n }\n }\n },\n [allowCustomValue, inputValue, setInputValue, setValue, value, valueMap],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => (isArray(prev) ? [] : \"\") as MaybeValue)\n setInputValue(\"\")\n\n if (focusOnClear) inputRef.current?.focus()\n }, [focusOnClear, interactive, setInputValue, setValue])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n setInputValue(\n getInputValue(valueProp ? valueMap[valueProp as string] : undefined),\n )\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n tabIndex: -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n }),\n\n [getTriggerProps, onClick],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!focused && isArray(value) && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...props.style,\n },\n \"data-max\": dataAttr(\n isArray(value) && isNumber(max) && value.length >= max,\n ),\n autoCapitalize: \"off\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n disabled,\n placeholder: hasValues ? undefined : placeholder,\n readOnly,\n required,\n spellCheck: false,\n value: inputValue,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n dataProps,\n disabled,\n focused,\n hasValues,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n hidden: empty,\n ...props,\n }),\n [empty, getComboboxContentProps],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n descendants,\n inputValue,\n interactive,\n items: resolvedItems,\n max,\n open,\n setInputValue,\n setValue,\n value,\n valueMap,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n getSeparatorProps,\n popoverProps,\n onActiveDescendant,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport interface UseAutocompleteOptionProps extends UseComboboxItemProps {}\n\nexport const useAutocompleteOption = ({\n children,\n closeOnSelect,\n disabled,\n hidden,\n value,\n ...rest\n}: UseAutocompleteOptionProps = {}) => {\n const { max, value: selectedValue } = useAutocompleteContext()\n\n value ??= isString(children) ? children : undefined\n\n const selected = isArray(selectedValue)\n ? !isUndefined(value) && selectedValue.includes(value)\n : selectedValue === value\n const completed =\n isNumber(max) && isArray(selectedValue) && selectedValue.length >= max\n const { getIndicatorProps, getItemProps } = useComboboxItem({\n children,\n closeOnSelect,\n disabled: disabled || hidden || (completed && !selected),\n hidden,\n selected,\n value,\n ...rest,\n })\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}) => getItemProps(props),\n [getItemProps],\n )\n\n return { getIndicatorProps, getOptionProps }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+DA,MAAMA,iBAAyC,EAC7C,OACA,SACA,OACA,OACA,KACA,gBACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,4CAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,iDAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAIX,MAAM,iBAAiB,yDACZ,MAAM,MAAM,GAAG,KAAK,QAAS,MAAM,SAAS;AAUvD,MAAMC,iBAAqC,YAAY,OAAO,YAAU;AACtE,KAAI,CAAC,WAAW,OAAQ,QAAO;AAE/B,QAAO,MACJ,KAAK,SAAS;AACb,MAAI,WAAW,MAAM;GACnB,MAAMC,UAAQ,KAAK,MAAM,QAAQ,WAAS;AACxC,QAAI,WAAWC,OACb,wDAAgBA,OAAK,MAAM,IAAIC,QAAMD,OAAK,OAAO,WAAW;6DAC1CA,OAAK,MAAM,CAC7B,wDAA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CAAC;EAC/C;EACA;EACA;EACA,GAAG;EACJ,CAAC;AAOF,QAAO;EAAE;EAAmB,wCAJzB,QAAQ,EAAE,KAAK,aAAa,MAAM,EACnC,CAAC,aAAa,CACf;EAE2C"}
@@ -23,30 +23,29 @@ const defaultRender = ({ count, focused, index, label, max, separator }) => {
23
23
  });
24
24
  };
25
25
  const getInputValue = (item) => (0, utils_exports.isString)(item?.label) ? item.label : item?.query ?? "";
26
- const defaultFilter = (inputValue, items, matcher) => {
26
+ const defaultFilter = (inputValue, items, match$1) => {
27
27
  if (!inputValue.length) return items;
28
28
  return items.map((item) => {
29
29
  if ("items" in item) {
30
30
  const items$1 = item.items.filter((item$1) => {
31
- if ("query" in item$1) return matcher(inputValue, item$1.query);
32
- else if ((0, utils_exports.isString)(item$1.label)) return matcher(inputValue, item$1.label);
31
+ if ("query" in item$1) return (0, utils_exports.isString)(item$1.query) && match$1(item$1.query, inputValue);
32
+ else if ((0, utils_exports.isString)(item$1.label)) return (0, utils_exports.isString)(item$1.label) && match$1(item$1.label, inputValue);
33
33
  });
34
34
  if (items$1.length) return {
35
35
  ...item,
36
36
  items: items$1
37
37
  };
38
38
  } else if ("query" in item) {
39
- if (matcher(inputValue, item.query)) return item;
39
+ if ((0, utils_exports.isString)(item.query) && match$1(item.query, inputValue)) return item;
40
40
  } else if ((0, utils_exports.isString)(item.label)) {
41
- if (matcher(inputValue, item.label)) return item;
41
+ if ((0, utils_exports.isString)(item.label) && match$1(item.label, inputValue)) return item;
42
42
  }
43
43
  }).filter(Boolean);
44
44
  };
45
- const defaultMatcher = (input, target) => target?.toLowerCase().includes(input.toLowerCase()) ?? false;
46
45
  const [AutocompleteContext, useAutocompleteContext] = createContext$1({ name: "AutocompleteContext" });
47
46
  const useAutocomplete = (props = {}) => {
48
47
  const { t } = useI18n("autocomplete");
49
- const { props: { id, ref, name, allowCustomValue = false, closeOnChange = false, multiple = false, closeOnSelect = !multiple, defaultInputValue, defaultValue = multiple ? [] : "", disabled, emptyMessage = t("No results found"), filter = defaultFilter, focusOnClear = true, inputValue: inputValueProp, items = [], matcher = defaultMatcher, max, openOnChange = true, openOnClick = true, openOnFocus = true, placeholder, readOnly, render = defaultRender, required, separator = ",", value: valueProp, onChange: onChangeProp, onInputChange: onInputChangeProp, ...rest }, ariaProps, dataProps, eventProps } = useFieldProps(props);
48
+ const { props: { id, ref, name, allowCustomValue = false, closeOnChange = false, multiple = false, closeOnSelect = !multiple, defaultInputValue, defaultValue = multiple ? [] : "", disabled, emptyMessage = t("No results found"), filter = defaultFilter, focusOnClear = true, inputValue: inputValueProp, items = [], matcher = utils_exports.match, max, openOnChange = true, openOnClick = true, openOnFocus = true, placeholder, readOnly, render = defaultRender, required, separator = ",", value: valueProp, onChange: onChangeProp, onInputChange: onInputChangeProp, ...rest }, ariaProps, dataProps, eventProps } = useFieldProps(props);
50
49
  const fieldRef = useRef(null);
51
50
  const contentRef = useRef(null);
52
51
  const inputRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"use-autocomplete.js","names":["defaultRender: AutocompleteItemRender","defaultFilter: AutocompleteFilter","items","item","defaultMatcher: AutocompleteMatcher","createContext","valueMap: { [key: string]: ComboboxItemWithValue }","valueMap","value","onClear","inputValue","getRootProps: PropGetter","props","getFieldProps: PropGetter","ref","getInputProps: PropGetter<\"input\">","getContentProps: PropGetter","getIconProps: PropGetter"],"sources":["../../../../src/components/autocomplete/use-autocomplete.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type {\n ComboboxItem,\n ComboboxItemWithValue,\n UseComboboxItemProps,\n UseComboboxProps,\n} from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox, useComboboxItem } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isComposing,\n isNumber,\n isString,\n isUndefined,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface AutocompleteRenderProps extends ComboboxItemWithValue {\n count: number\n focused: boolean\n index: number\n separator: string\n onClear: () => void\n max?: number\n}\n\nexport interface AutocompleteItemRender {\n (props: AutocompleteRenderProps): ReactNode\n}\n\nconst defaultRender: AutocompleteItemRender = ({\n count,\n focused,\n index,\n label,\n max,\n separator,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {label}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nconst getInputValue = (item?: ComboboxItemWithValue) =>\n isString(item?.label) ? item.label : (item?.query ?? \"\")\n\nexport interface AutocompleteFilter {\n (\n inputValue: string,\n items: ComboboxItem[],\n matcher: AutocompleteMatcher,\n ): ComboboxItem[]\n}\n\nconst defaultFilter: AutocompleteFilter = (inputValue, items, matcher) => {\n if (!inputValue.length) return items\n\n return items\n .map((item) => {\n if (\"items\" in item) {\n const items = item.items.filter((item) => {\n if (\"query\" in item) {\n return matcher(inputValue, item.query)\n } else if (isString(item.label)) {\n return matcher(inputValue, item.label)\n }\n })\n\n if (items.length) return { ...item, items }\n } else if (\"query\" in item) {\n if (matcher(inputValue, item.query)) return item\n } else if (isString(item.label)) {\n if (matcher(inputValue, item.label)) return item\n }\n })\n .filter(Boolean) as ComboboxItem[]\n}\n\nexport interface AutocompleteMatcher {\n (input: string, target?: string): boolean\n}\n\nconst defaultMatcher: AutocompleteMatcher = (input, target) =>\n target?.toLowerCase().includes(input.toLowerCase()) ?? false\n\ninterface AutocompleteContext extends Pick<\n UseAutocompleteReturn,\n \"max\" | \"value\"\n> {}\n\nconst [AutocompleteContext, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n })\n\nexport { AutocompleteContext, useAutocompleteContext }\n\nexport interface UseAutocompleteProps<Multiple extends boolean = false>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\" | \"value\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the autocomplete will allow custom value.\n *\n * @default false\n */\n allowCustomValue?: boolean\n /**\n * If `true`, the autocomplete will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: string\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: Multiple extends true ? string[] : string\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: ReactNode\n /**\n * The function to filter the items.\n */\n filter?: AutocompleteFilter\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: string\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: ComboboxItem[]\n /**\n * The function to match the items.\n */\n matcher?: AutocompleteMatcher\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * If `true`, the autocomplete will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the autocomplete will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the autocomplete will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The placeholder for autocomplete.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The value of the autocomplete.\n */\n value?: Multiple extends true ? string[] : string\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: Multiple extends true ? string[] : string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: string) => void\n /**\n * The function to render the selected items.\n */\n render?: (props: AutocompleteRenderProps) => ReactNode\n}\n\nexport const useAutocomplete = <Multiple extends boolean = false>(\n props: UseAutocompleteProps<Multiple> = {},\n) => {\n type MaybeValue = Multiple extends true ? string[] : string\n\n const { t } = useI18n(\"autocomplete\")\n const {\n props: {\n id,\n ref,\n name,\n allowCustomValue = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultValue = (multiple ? [] : \"\") as MaybeValue,\n disabled,\n emptyMessage = t(\"No results found\"),\n filter = defaultFilter,\n focusOnClear = true,\n inputValue: inputValueProp,\n items = [],\n matcher = defaultMatcher,\n max,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n placeholder,\n readOnly,\n render = defaultRender,\n required,\n separator = \",\",\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const valueMap = useMemo<{ [key: string]: ComboboxItemWithValue }>(() => {\n const valueMap: { [key: string]: ComboboxItemWithValue } = {}\n\n items.forEach((item) => {\n if (\"items\" in item) {\n item.items.forEach((item) => {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n })\n } else {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n }\n })\n\n return valueMap\n }, [items])\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [inputValue, setInputValue] = useControllableState({\n defaultValue:\n defaultInputValue ??\n getInputValue(isArray(value) ? undefined : valueMap[value as string]),\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (isArray(prev)) {\n if (prev.includes(selectedValue)) {\n return prev.filter(\n (prevValue) => prevValue !== selectedValue,\n ) as MaybeValue\n } else if (!isNumber(max) || prev.length < max) {\n return [...prev, selectedValue] as MaybeValue\n } else {\n return prev\n }\n } else {\n return selectedValue as MaybeValue\n }\n })\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n const item = valueMap[selectedValue]\n\n setInputValue(getInputValue(item))\n }\n },\n [max, setInputValue, setValue, value, valueMap],\n )\n const {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onSelect,\n } = useCombobox({\n closeOnSelect,\n disabled,\n initialFocusValue: isArray(value) ? value[0] : value,\n openOnClick: false,\n openOnEnter: false,\n openOnSpace: false,\n readOnly,\n selectFocusRef: inputRef,\n selectOnSpace: false,\n onChange,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const filteredItems = useMemo<ComboboxItem[]>(() => {\n if (!items.length) return []\n\n return filter(inputValue, items, matcher)\n }, [filter, inputValue, items, matcher])\n const resolvedItems = useMemo<ComboboxItem[]>(() => {\n return filteredItems.length\n ? filteredItems\n : [{ \"data-empty\": \"\", label: emptyMessage }]\n }, [filteredItems, emptyMessage])\n const empty = useMemo(\n () => !resolvedItems.filter(({ hidden }) => !hidden).length,\n [resolvedItems],\n )\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((value, index) => {\n const item = valueMap[value] ?? { label: value, value }\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n if (item.value) onChange(item.value)\n }\n\n const component = render({\n count,\n focused,\n index,\n max,\n separator,\n onClear,\n ...item,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [focused, max, onChange, render, separator, value, valueMap])\n const hasValues = isArray(value) && !!value.length\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n activeDescendant.current = null\n\n const inputValue = ev.target.value\n\n setInputValue(inputValue)\n\n if (inputValue.length || isArray(value)) return\n\n setValue(\"\" as MaybeValue)\n },\n [\n activeDescendant,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n setInputValue,\n setValue,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!isArray(value)) return\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) => prev.slice(0, -1) as MaybeValue)\n },\n Enter: (ev) => {\n if (!open || !inputValue.length || activeDescendant.current) return\n\n const item = filteredItems[0]\n\n if (!item) {\n if (!allowCustomValue || !isArray(value)) return\n\n ev.preventDefault()\n\n onSelect(inputValue)\n } else {\n ev.preventDefault()\n\n if (\"items\" in item) {\n onSelect(item.items[0]?.value)\n } else {\n onSelect(item.value)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n activeDescendant,\n allowCustomValue,\n disabled,\n filteredItems,\n onSelect,\n open,\n setValue,\n value,\n ],\n )\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n inputRef.current?.focus()\n\n if (openOnClick) onOpenWithActiveDescendant(descendants.enabledFirstValue)\n }, [descendants, interactive, onOpenWithActiveDescendant, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n\n focusByClickRef.current = false\n },\n [openOnFocus, onOpenWithActiveDescendant, descendants.enabledFirstValue],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setFocused(false)\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n if (allowCustomValue) {\n if (inputValue) setValue(inputValue as MaybeValue)\n } else {\n const item = valueMap[value as string]\n\n setInputValue(getInputValue(item))\n }\n }\n }\n },\n [allowCustomValue, inputValue, setInputValue, setValue, value, valueMap],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => (isArray(prev) ? [] : \"\") as MaybeValue)\n setInputValue(\"\")\n\n if (focusOnClear) inputRef.current?.focus()\n }, [focusOnClear, interactive, setInputValue, setValue])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n setInputValue(\n getInputValue(valueProp ? valueMap[valueProp as string] : undefined),\n )\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n tabIndex: -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n }),\n\n [getTriggerProps, onClick],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!focused && isArray(value) && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...props.style,\n },\n \"data-max\": dataAttr(\n isArray(value) && isNumber(max) && value.length >= max,\n ),\n autoCapitalize: \"off\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n disabled,\n placeholder: hasValues ? undefined : placeholder,\n readOnly,\n required,\n spellCheck: false,\n value: inputValue,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n dataProps,\n disabled,\n focused,\n hasValues,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n hidden: empty,\n ...props,\n }),\n [empty, getComboboxContentProps],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n descendants,\n inputValue,\n interactive,\n items: resolvedItems,\n max,\n open,\n setInputValue,\n setValue,\n value,\n valueMap,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n getSeparatorProps,\n popoverProps,\n onActiveDescendant,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport interface UseAutocompleteOptionProps extends UseComboboxItemProps {}\n\nexport const useAutocompleteOption = ({\n children,\n closeOnSelect,\n disabled,\n hidden,\n value,\n ...rest\n}: UseAutocompleteOptionProps = {}) => {\n const { max, value: selectedValue } = useAutocompleteContext()\n\n value ??= isString(children) ? children : undefined\n\n const selected = isArray(selectedValue)\n ? !isUndefined(value) && selectedValue.includes(value)\n : selectedValue === value\n const completed =\n isNumber(max) && isArray(selectedValue) && selectedValue.length >= max\n const { getIndicatorProps, getItemProps } = useComboboxItem({\n children,\n closeOnSelect,\n disabled: disabled || hidden || (completed && !selected),\n hidden,\n selected,\n value,\n ...rest,\n })\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}) => getItemProps(props),\n [getItemProps],\n )\n\n return { getIndicatorProps, getOptionProps }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n"],"mappings":";;;;;;;;;;;;;;;;;AA8DA,MAAMA,iBAAyC,EAC7C,OACA,SACA,OACA,OACA,KACA,gBACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,qBAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,6BAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAIX,MAAM,iBAAiB,qCACZ,MAAM,MAAM,GAAG,KAAK,QAAS,MAAM,SAAS;AAUvD,MAAMC,iBAAqC,YAAY,OAAO,YAAY;AACxE,KAAI,CAAC,WAAW,OAAQ,QAAO;AAE/B,QAAO,MACJ,KAAK,SAA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B,EAAE,KAAK;CACrC,MAAM,EAAE,KAAK,OAAO,kBAAkB,wBAAwB;AAE9D,uCAAmB,SAAS,GAAG,WAAW;CAE1C,MAAM,sCAAmB,cAAc,GACnC,gCAAa,MAAM,IAAI,cAAc,SAAS,MAAM,GACpD,kBAAkB;CACtB,MAAM,wCACK,IAAI,+BAAY,cAAc,IAAI,cAAc,UAAU;CACrE,MAAM,EAAE,mBAAmB,iBAAiB,gBAAgB;EAC1D;EACA;EACA,UAAU,YAAY,UAAW,aAAa,CAAC;EAC/C;EACA;EACA;EACA,GAAG;EACJ,CAAC;AAOF,QAAO;EAAE;EAAmB,gBALO,aAChC,QAAQ,EAAE,KAAK,aAAa,MAAM,EACnC,CAAC,aAAa,CACf;EAE2C"}
1
+ {"version":3,"file":"use-autocomplete.js","names":["defaultRender: AutocompleteItemRender","defaultFilter: AutocompleteFilter","items","item","match","createContext","valueMap: { [key: string]: ComboboxItemWithValue }","valueMap","value","onClear","inputValue","getRootProps: PropGetter","props","getFieldProps: PropGetter","ref","getInputProps: PropGetter<\"input\">","getContentProps: PropGetter","getIconProps: PropGetter"],"sources":["../../../../src/components/autocomplete/use-autocomplete.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type {\n ComboboxItem,\n ComboboxItemWithValue,\n UseComboboxItemProps,\n UseComboboxProps,\n} from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox, useComboboxItem } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n isComposing,\n isNumber,\n isString,\n isUndefined,\n match,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface AutocompleteRenderProps extends ComboboxItemWithValue {\n count: number\n focused: boolean\n index: number\n separator: string\n onClear: () => void\n max?: number\n}\n\nexport interface AutocompleteItemRender {\n (props: AutocompleteRenderProps): ReactNode\n}\n\nconst defaultRender: AutocompleteItemRender = ({\n count,\n focused,\n index,\n label,\n max,\n separator,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {label}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nconst getInputValue = (item?: ComboboxItemWithValue) =>\n isString(item?.label) ? item.label : (item?.query ?? \"\")\n\nexport interface AutocompleteFilter {\n (\n inputValue: string,\n items: ComboboxItem[],\n matcher: AutocompleteMatcher,\n ): ComboboxItem[]\n}\n\nconst defaultFilter: AutocompleteFilter = (inputValue, items, match) => {\n if (!inputValue.length) return items\n\n return items\n .map((item) => {\n if (\"items\" in item) {\n const items = item.items.filter((item) => {\n if (\"query\" in item) {\n return isString(item.query) && match(item.query, inputValue)\n } else if (isString(item.label)) {\n return isString(item.label) && match(item.label, inputValue)\n }\n })\n\n if (items.length) return { ...item, items }\n } else if (\"query\" in item) {\n if (isString(item.query) && match(item.query, inputValue)) return item\n } else if (isString(item.label)) {\n if (isString(item.label) && match(item.label, inputValue)) return item\n }\n })\n .filter(Boolean) as ComboboxItem[]\n}\n\nexport type AutocompleteMatcher = typeof match\n\ninterface AutocompleteContext extends Pick<\n UseAutocompleteReturn,\n \"max\" | \"value\"\n> {}\n\nconst [AutocompleteContext, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n })\n\nexport { AutocompleteContext, useAutocompleteContext }\n\nexport interface UseAutocompleteProps<Multiple extends boolean = false>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\" | \"value\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the autocomplete will allow custom value.\n *\n * @default false\n */\n allowCustomValue?: boolean\n /**\n * If `true`, the autocomplete will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: string\n /**\n * The initial value of the autocomplete.\n */\n defaultValue?: Multiple extends true ? string[] : string\n /**\n * The message displayed when the search yields no hits.\n *\n * @default 'No results found'\n */\n emptyMessage?: ReactNode\n /**\n * The function to filter the items.\n */\n filter?: AutocompleteFilter\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: string\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: ComboboxItem[]\n /**\n * The function to match the items.\n */\n matcher?: AutocompleteMatcher\n /**\n * The maximum selectable value.\n */\n max?: number\n /**\n * If `true`, the autocomplete will be multiple.\n *\n * @default false\n */\n multiple?: Multiple\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the autocomplete will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the autocomplete will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The placeholder for autocomplete.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The value of the autocomplete.\n */\n value?: Multiple extends true ? string[] : string\n /**\n * The callback invoked when value state changes.\n */\n onChange?: (value: Multiple extends true ? string[] : string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: string) => void\n /**\n * The function to render the selected items.\n */\n render?: (props: AutocompleteRenderProps) => ReactNode\n}\n\nexport const useAutocomplete = <Multiple extends boolean = false>(\n props: UseAutocompleteProps<Multiple> = {},\n) => {\n type MaybeValue = Multiple extends true ? string[] : string\n\n const { t } = useI18n(\"autocomplete\")\n const {\n props: {\n id,\n ref,\n name,\n allowCustomValue = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultValue = (multiple ? [] : \"\") as MaybeValue,\n disabled,\n emptyMessage = t(\"No results found\"),\n filter = defaultFilter,\n focusOnClear = true,\n inputValue: inputValueProp,\n items = [],\n matcher = match,\n max,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n placeholder,\n readOnly,\n render = defaultRender,\n required,\n separator = \",\",\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const valueMap = useMemo<{ [key: string]: ComboboxItemWithValue }>(() => {\n const valueMap: { [key: string]: ComboboxItemWithValue } = {}\n\n items.forEach((item) => {\n if (\"items\" in item) {\n item.items.forEach((item) => {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n })\n } else {\n item.value ??= isString(item.label) ? item.label : undefined\n\n if (!isUndefined(item.value)) valueMap[item.value] = item\n }\n })\n\n return valueMap\n }, [items])\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [inputValue, setInputValue] = useControllableState({\n defaultValue:\n defaultInputValue ??\n getInputValue(isArray(value) ? undefined : valueMap[value as string]),\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (isArray(prev)) {\n if (prev.includes(selectedValue)) {\n return prev.filter(\n (prevValue) => prevValue !== selectedValue,\n ) as MaybeValue\n } else if (!isNumber(max) || prev.length < max) {\n return [...prev, selectedValue] as MaybeValue\n } else {\n return prev\n }\n } else {\n return selectedValue as MaybeValue\n }\n })\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n const item = valueMap[selectedValue]\n\n setInputValue(getInputValue(item))\n }\n },\n [max, setInputValue, setValue, value, valueMap],\n )\n const {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onSelect,\n } = useCombobox({\n closeOnSelect,\n disabled,\n initialFocusValue: isArray(value) ? value[0] : value,\n openOnClick: false,\n openOnEnter: false,\n openOnSpace: false,\n readOnly,\n selectFocusRef: inputRef,\n selectOnSpace: false,\n onChange,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const filteredItems = useMemo<ComboboxItem[]>(() => {\n if (!items.length) return []\n\n return filter(inputValue, items, matcher)\n }, [filter, inputValue, items, matcher])\n const resolvedItems = useMemo<ComboboxItem[]>(() => {\n return filteredItems.length\n ? filteredItems\n : [{ \"data-empty\": \"\", label: emptyMessage }]\n }, [filteredItems, emptyMessage])\n const empty = useMemo(\n () => !resolvedItems.filter(({ hidden }) => !hidden).length,\n [resolvedItems],\n )\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((value, index) => {\n const item = valueMap[value] ?? { label: value, value }\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n if (item.value) onChange(item.value)\n }\n\n const component = render({\n count,\n focused,\n index,\n max,\n separator,\n onClear,\n ...item,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [focused, max, onChange, render, separator, value, valueMap])\n const hasValues = isArray(value) && !!value.length\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n activeDescendant.current = null\n\n const inputValue = ev.target.value\n\n setInputValue(inputValue)\n\n if (inputValue.length || isArray(value)) return\n\n setValue(\"\" as MaybeValue)\n },\n [\n activeDescendant,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n setInputValue,\n setValue,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!isArray(value)) return\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) => prev.slice(0, -1) as MaybeValue)\n },\n Enter: (ev) => {\n if (!open || !inputValue.length || activeDescendant.current) return\n\n const item = filteredItems[0]\n\n if (!item) {\n if (!allowCustomValue || !isArray(value)) return\n\n ev.preventDefault()\n\n onSelect(inputValue)\n } else {\n ev.preventDefault()\n\n if (\"items\" in item) {\n onSelect(item.items[0]?.value)\n } else {\n onSelect(item.value)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n activeDescendant,\n allowCustomValue,\n disabled,\n filteredItems,\n onSelect,\n open,\n setValue,\n value,\n ],\n )\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n inputRef.current?.focus()\n\n if (openOnClick) onOpenWithActiveDescendant(descendants.enabledFirstValue)\n }, [descendants, interactive, onOpenWithActiveDescendant, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n\n focusByClickRef.current = false\n },\n [openOnFocus, onOpenWithActiveDescendant, descendants.enabledFirstValue],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setFocused(false)\n\n if (isArray(value)) {\n setInputValue(\"\")\n } else {\n if (allowCustomValue) {\n if (inputValue) setValue(inputValue as MaybeValue)\n } else {\n const item = valueMap[value as string]\n\n setInputValue(getInputValue(item))\n }\n }\n }\n },\n [allowCustomValue, inputValue, setInputValue, setValue, value, valueMap],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => (isArray(prev) ? [] : \"\") as MaybeValue)\n setInputValue(\"\")\n\n if (focusOnClear) inputRef.current?.focus()\n }, [focusOnClear, interactive, setInputValue, setValue])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n setInputValue(\n getInputValue(valueProp ? valueMap[valueProp as string] : undefined),\n )\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n tabIndex: -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n }),\n\n [getTriggerProps, onClick],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!focused && isArray(value) && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...props.style,\n },\n \"data-max\": dataAttr(\n isArray(value) && isNumber(max) && value.length >= max,\n ),\n autoCapitalize: \"off\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n disabled,\n placeholder: hasValues ? undefined : placeholder,\n readOnly,\n required,\n spellCheck: false,\n value: inputValue,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n dataProps,\n disabled,\n focused,\n hasValues,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n hidden: empty,\n ...props,\n }),\n [empty, getComboboxContentProps],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n descendants,\n inputValue,\n interactive,\n items: resolvedItems,\n max,\n open,\n setInputValue,\n setValue,\n value,\n valueMap,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n getSeparatorProps,\n popoverProps,\n onActiveDescendant,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>\n\nexport interface UseAutocompleteOptionProps extends UseComboboxItemProps {}\n\nexport const useAutocompleteOption = ({\n children,\n closeOnSelect,\n disabled,\n hidden,\n value,\n ...rest\n}: UseAutocompleteOptionProps = {}) => {\n const { max, value: selectedValue } = useAutocompleteContext()\n\n value ??= isString(children) ? children : undefined\n\n const selected = isArray(selectedValue)\n ? !isUndefined(value) && selectedValue.includes(value)\n : selectedValue === value\n const completed =\n isNumber(max) && isArray(selectedValue) && selectedValue.length >= max\n const { getIndicatorProps, getItemProps } = useComboboxItem({\n children,\n closeOnSelect,\n disabled: disabled || hidden || (completed && !selected),\n hidden,\n selected,\n value,\n ...rest,\n })\n\n const getOptionProps: PropGetter = useCallback(\n (props = {}) => getItemProps(props),\n [getItemProps],\n )\n\n return { getIndicatorProps, getOptionProps }\n}\n\nexport type UseAutocompleteOptionReturn = ReturnType<\n typeof useAutocompleteOption\n>\n"],"mappings":";;;;;;;;;;;;;;;;;AA+DA,MAAMA,iBAAyC,EAC7C,OACA,SACA,OACA,OACA,KACA,gBACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,qBAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,6BAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAIX,MAAM,iBAAiB,qCACZ,MAAM,MAAM,GAAG,KAAK,QAAS,MAAM,SAAS;AAUvD,MAAMC,iBAAqC,YAAY,OAAO,YAAU;AACtE,KAAI,CAAC,WAAW,OAAQ,QAAO;AAE/B,QAAO,MACJ,KAAK,SAAS;AACb,MAAI,WAAW,MAAM;GACnB,MAAMC,UAAQ,KAAK,MAAM,QAAQ,WAAS;AACxC,QAAI,WAAWC,OACb,oCAAgBA,OAAK,MAAM,IAAIC,QAAMD,OAAK,OAAO,WAAW;yCAC1CA,OAAK,MAAM,CAC7B,oCAAgBA,OAAK,MAAM,IAAIC,QAAMD,OAAK,OAAO,W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c,UAAU;CACrE,MAAM,EAAE,mBAAmB,iBAAiB,gBAAgB;EAC1D;EACA;EACA,UAAU,YAAY,UAAW,aAAa,CAAC;EAC/C;EACA;EACA;EACA,GAAG;EACJ,CAAC;AAOF,QAAO;EAAE;EAAmB,gBALO,aAChC,QAAQ,EAAE,KAAK,aAAa,MAAM,EACnC,CAAC,aAAa,CACf;EAE2C"}
@@ -7,7 +7,7 @@ import { CollapseProps } from "../collapse/collapse.js";
7
7
  import "../../index.js";
8
8
  import { AccordionStyle } from "./accordion.style.js";
9
9
  import { UseAccordionItemProps, UseAccordionProps } from "./use-accordion.js";
10
- import * as react248 from "react";
10
+ import * as react177 from "react";
11
11
 
12
12
  //#region src/components/accordion/accordion.d.ts
13
13
  interface AccordionCallBackProps {
@@ -31,7 +31,7 @@ interface AccordionRootProps extends Omit<HTMLStyledProps, "onChange">, ThemePro
31
31
  */
32
32
  items?: AccordionItem[];
33
33
  }
34
- declare const AccordionPropsContext: react248.Context<Partial<AccordionRootProps> | undefined>, useAccordionPropsContext: () => Partial<AccordionRootProps> | undefined;
34
+ declare const AccordionPropsContext: react177.Context<Partial<AccordionRootProps> | undefined>, useAccordionPropsContext: () => Partial<AccordionRootProps> | undefined;
35
35
  /**
36
36
  * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.
37
37
  *
@@ -2,10 +2,10 @@ import { HTMLProps, PropGetter } from "../../core/components/index.types.js";
2
2
  import "../../core/index.js";
3
3
  import { Descendant } from "../../hooks/use-descendants/index.js";
4
4
  import "../../index.js";
5
- import * as react236 from "react";
5
+ import * as react165 from "react";
6
6
 
7
7
  //#region src/components/accordion/use-accordion.d.ts
8
- declare const AccordionDescendantsContext: react236.Context<{
8
+ declare const AccordionDescendantsContext: react165.Context<{
9
9
  active: (target?: HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null | undefined, options?: FocusOptions) => void;
10
10
  count: () => number;
11
11
  destroy: () => void;
@@ -24,7 +24,7 @@ declare const AccordionDescendantsContext: react236.Context<{
24
24
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
25
25
  register: (props?: {
26
26
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
27
- } | undefined) => react236.RefCallback<HTMLButtonElement>;
27
+ } | undefined) => react165.RefCallback<HTMLButtonElement>;
28
28
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
29
29
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
30
30
  values: () => Descendant<HTMLButtonElement, {}>[];
@@ -50,12 +50,12 @@ declare const AccordionDescendantsContext: react236.Context<{
50
50
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
51
51
  register: (props?: {
52
52
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
53
- } | undefined) => react236.RefCallback<HTMLButtonElement>;
53
+ } | undefined) => react165.RefCallback<HTMLButtonElement>;
54
54
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
55
55
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
56
56
  values: () => Descendant<HTMLButtonElement, {}>[];
57
57
  };
58
- register: react236.RefCallback<HTMLButtonElement>;
58
+ register: react165.RefCallback<HTMLButtonElement>;
59
59
  }, useAccordionDescendants: () => {
60
60
  active: (target?: HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null | undefined, options?: FocusOptions) => void;
61
61
  count: () => number;
@@ -75,15 +75,15 @@ declare const AccordionDescendantsContext: react236.Context<{
75
75
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
76
76
  register: (props?: {
77
77
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
78
- } | undefined) => react236.RefCallback<HTMLButtonElement>;
78
+ } | undefined) => react165.RefCallback<HTMLButtonElement>;
79
79
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
80
80
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
81
81
  values: () => Descendant<HTMLButtonElement, {}>[];
82
82
  };
83
83
  interface AccordionContext extends Omit<UseAccordionReturn, "descendants" | "getRootProps"> {}
84
- declare const AccordionContext: react236.Context<AccordionContext>, useAccordionContext: () => AccordionContext;
84
+ declare const AccordionContext: react165.Context<AccordionContext>, useAccordionContext: () => AccordionContext;
85
85
  interface AccordionItemContext extends Omit<UseAccordionItemReturn, "getItemProps"> {}
86
- declare const AccordionItemContext: react236.Context<AccordionItemContext>, useAccordionItemContext: () => AccordionItemContext;
86
+ declare const AccordionItemContext: react165.Context<AccordionItemContext>, useAccordionItemContext: () => AccordionItemContext;
87
87
  interface UseAccordionProps extends Omit<HTMLProps, "onChange"> {
88
88
  /**
89
89
  * The initial index(es) of the accordion item to expand.
@@ -137,7 +137,7 @@ declare const useAccordion: ({
137
137
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean) => Descendant<HTMLButtonElement, {}> | undefined;
138
138
  register: (props?: {
139
139
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
140
- } | undefined) => react236.RefCallback<HTMLButtonElement>;
140
+ } | undefined) => react165.RefCallback<HTMLButtonElement>;
141
141
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
142
142
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
143
143
  values: () => Descendant<HTMLButtonElement, {}>[];
@@ -145,8 +145,8 @@ declare const useAccordion: ({
145
145
  focusedIndex: number;
146
146
  index: number | number[];
147
147
  multiple: boolean | undefined;
148
- setFocusedIndex: react236.Dispatch<react236.SetStateAction<number>>;
149
- setIndex: react236.Dispatch<react236.SetStateAction<number | number[]>>;
148
+ setFocusedIndex: react165.Dispatch<react165.SetStateAction<number>>;
149
+ setIndex: react165.Dispatch<react165.SetStateAction<number | number[]>>;
150
150
  toggle: boolean | undefined;
151
151
  getRootProps: PropGetter<"div", undefined, undefined>;
152
152
  };
@@ -4,7 +4,7 @@ import "../../core/index.js";
4
4
  import { AiryStyle } from "./airy.style.js";
5
5
  import { HTMLMotionProps } from "../motion/index.types.js";
6
6
  import "../../index.js";
7
- import * as react232 from "react";
7
+ import * as react179 from "react";
8
8
  import { ReactNode } from "react";
9
9
 
10
10
  //#region src/components/airy/airy.d.ts
@@ -56,7 +56,7 @@ interface AiryProps extends Omit<HTMLMotionProps<"button">, "onChange">, ThemePr
56
56
  */
57
57
  onChange?: (value: KeyframeIdent) => void;
58
58
  }
59
- declare const AiryPropsContext: react232.Context<Partial<AiryProps> | undefined>, useAiryPropsContext: () => Partial<AiryProps> | undefined;
59
+ declare const AiryPropsContext: react179.Context<Partial<AiryProps> | undefined>, useAiryPropsContext: () => Partial<AiryProps> | undefined;
60
60
  /**
61
61
  * `Airy` is a component that creates an airy animation, switching between two elements when one is clicked.
62
62
  *
@@ -6,7 +6,7 @@ import { IconProps } from "../icon/icon.js";
6
6
  import { LoadingProps } from "../loading/loading.js";
7
7
  import { StatusScheme } from "../status/status.js";
8
8
  import "../../index.js";
9
- import * as react233 from "react";
9
+ import * as react164 from "react";
10
10
 
11
11
  //#region src/components/alert/alert.d.ts
12
12
  interface AlertRootProps extends HTMLStyledProps, ThemeProps<AlertStyle> {
@@ -17,7 +17,7 @@ interface AlertRootProps extends HTMLStyledProps, ThemeProps<AlertStyle> {
17
17
  */
18
18
  status?: StatusScheme;
19
19
  }
20
- declare const AlertPropsContext: react233.Context<Partial<AlertRootProps> | undefined>, useAlertPropsContext: () => Partial<AlertRootProps> | undefined;
20
+ declare const AlertPropsContext: react164.Context<Partial<AlertRootProps> | undefined>, useAlertPropsContext: () => Partial<AlertRootProps> | undefined;
21
21
  /**
22
22
  * `Alert` is a component that conveys information to the user.
23
23
  *
@@ -4,7 +4,7 @@ import "../../core/index.js";
4
4
  import { AlphaSliderStyle } from "./alpha-slider.style.js";
5
5
  import { HueSliderOverlayProps, HueSliderRootProps, HueSliderThumbProps, HueSliderTrackProps } from "../hue-slider/hue-slider.js";
6
6
  import "../../index.js";
7
- import * as react231 from "react";
7
+ import * as react163 from "react";
8
8
 
9
9
  //#region src/components/alpha-slider/alpha-slider.d.ts
10
10
  interface AlphaSliderRootProps extends WithoutThemeProps<Omit<HueSliderRootProps, "color" | "max" | "step" | "thumbProps" | "trackProps">, AlphaSliderStyle> {
@@ -37,7 +37,7 @@ interface AlphaSliderRootProps extends WithoutThemeProps<Omit<HueSliderRootProps
37
37
  */
38
38
  trackProps?: AlphaSliderTrackProps;
39
39
  }
40
- declare const AlphaSliderPropsContext: react231.Context<Partial<AlphaSliderRootProps> | undefined>, useAlphaSliderPropsContext: () => Partial<AlphaSliderRootProps> | undefined;
40
+ declare const AlphaSliderPropsContext: react163.Context<Partial<AlphaSliderRootProps> | undefined>, useAlphaSliderPropsContext: () => Partial<AlphaSliderRootProps> | undefined;
41
41
  /**
42
42
  * `AlphaSlider` is a component used to allow the user to select color transparency.
43
43
  *
@@ -2,7 +2,7 @@ import { StyleValue } from "../../core/css/index.types.js";
2
2
  import { Component, HTMLStyledProps } from "../../core/components/index.types.js";
3
3
  import "../../core/index.js";
4
4
  import "../../index.js";
5
- import * as react230 from "react";
5
+ import * as react155 from "react";
6
6
 
7
7
  //#region src/components/aspect-ratio/aspect-ratio.d.ts
8
8
  interface AspectRatioProps extends HTMLStyledProps {
@@ -13,7 +13,7 @@ interface AspectRatioProps extends HTMLStyledProps {
13
13
  */
14
14
  ratio?: StyleValue<number>;
15
15
  }
16
- declare const AspectRatioPropsContext: react230.Context<Partial<AspectRatioProps> | undefined>, useAspectRatioPropsContext: () => Partial<AspectRatioProps> | undefined;
16
+ declare const AspectRatioPropsContext: react155.Context<Partial<AspectRatioProps> | undefined>, useAspectRatioPropsContext: () => Partial<AspectRatioProps> | undefined;
17
17
  /**
18
18
  * `AspectRatio` is a component for embedding things like videos and maps while maintaining the aspect ratio.
19
19
  *
@@ -9,7 +9,7 @@ import { InputElementProps } from "../input/input-element.js";
9
9
  import { InputGroupRootProps } from "../input/input-group.js";
10
10
  import { UseAutocompleteOptionProps, UseAutocompleteProps } from "./use-autocomplete.js";
11
11
  import "../../index.js";
12
- import * as react229 from "react";
12
+ import * as react162 from "react";
13
13
  import { ReactElement, ReactNode } from "react";
14
14
 
15
15
  //#region src/components/autocomplete/autocomplete.d.ts
@@ -65,7 +65,7 @@ interface AutocompleteRootProps<Multiple extends boolean = false> extends Omit<H
65
65
  */
66
66
  rootProps?: InputGroupRootProps;
67
67
  }
68
- declare const AutocompletePropsContext: react229.Context<Partial<AutocompleteRootProps<false>> | undefined>, useAutocompletePropsContext: () => Partial<AutocompleteRootProps<false>> | undefined;
68
+ declare const AutocompletePropsContext: react162.Context<Partial<AutocompleteRootProps<false>> | undefined>, useAutocompletePropsContext: () => Partial<AutocompleteRootProps<false>> | undefined;
69
69
  /**
70
70
  * `Autocomplete` is a component used to display suggestions in response to user text input.
71
71
  *
@@ -3,7 +3,7 @@ import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
3
3
  import "../../index.js";
4
4
 
5
5
  //#region src/components/autocomplete/autocomplete.style.d.ts
6
- declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "field" | "indicator" | "empty" | "valueText", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "field" | "indicator" | "empty" | "valueText">>, {
6
+ declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "empty" | "valueText", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "empty" | "valueText">>, {
7
7
  xs: {
8
8
  empty: {
9
9
  gap: "1.5";
@@ -1,3 +1,4 @@
1
+ import { index_d_exports } from "../../utils/index.js";
1
2
  import { HTMLProps, HTMLRefAttributes, PropGetter } from "../../core/components/index.types.js";
2
3
  import "../../core/index.js";
3
4
  import { FieldProps } from "../field/field.js";
@@ -5,7 +6,7 @@ import { Descendant, DescendantProps } from "../../hooks/use-descendants/index.j
5
6
  import { UsePopoverProps } from "../popover/use-popover.js";
6
7
  import { ComboboxDescendant, ComboboxDescendantProps, ComboboxItem, ComboboxItemWithValue, UseComboboxItemProps, UseComboboxProps } from "../../hooks/use-combobox/index.js";
7
8
  import "../../index.js";
8
- import * as react223 from "react";
9
+ import * as react156 from "react";
9
10
  import { ChangeEvent, ReactNode } from "react";
10
11
 
11
12
  //#region src/components/autocomplete/use-autocomplete.d.ts
@@ -23,11 +24,9 @@ interface AutocompleteItemRender {
23
24
  interface AutocompleteFilter {
24
25
  (inputValue: string, items: ComboboxItem[], matcher: AutocompleteMatcher): ComboboxItem[];
25
26
  }
26
- interface AutocompleteMatcher {
27
- (input: string, target?: string): boolean;
28
- }
27
+ type AutocompleteMatcher = typeof index_d_exports.match;
29
28
  interface AutocompleteContext extends Pick<UseAutocompleteReturn, "max" | "value"> {}
30
- declare const AutocompleteContext: react223.Context<AutocompleteContext>, useAutocompleteContext: () => AutocompleteContext;
29
+ declare const AutocompleteContext: react156.Context<AutocompleteContext>, useAutocompleteContext: () => AutocompleteContext;
31
30
  interface UseAutocompleteProps<Multiple extends boolean = false> extends Omit<HTMLProps, "defaultValue" | "onChange" | "ref" | "value">, Omit<UseComboboxProps, "defaultValue" | "initialFocusValue" | "onChange" | "ref" | "value">, HTMLRefAttributes<"input">, FieldProps {
32
31
  /**
33
32
  * If `true`, the autocomplete will allow custom value.
@@ -155,7 +154,7 @@ declare const useAutocomplete: <Multiple extends boolean = false>(props?: UseAut
155
154
  lastValue: () => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
156
155
  nextValue: (indexOrNode: number | HTMLDivElement | Descendant<HTMLDivElement, ComboboxDescendantProps> | null, loop?: boolean) => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
157
156
  prevValue: (indexOrNode: number | HTMLDivElement | Descendant<HTMLDivElement, ComboboxDescendantProps> | null, loop?: boolean) => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
158
- register: (props?: DescendantProps<HTMLDivElement, ComboboxDescendantProps> | undefined) => react223.RefCallback<HTMLDivElement>;
157
+ register: (props?: DescendantProps<HTMLDivElement, ComboboxDescendantProps> | undefined) => react156.RefCallback<HTMLDivElement>;
159
158
  unregister: (node?: HTMLDivElement | null | undefined) => void;
160
159
  value: (indexOrNode: number | HTMLDivElement | null) => Descendant<HTMLDivElement, ComboboxDescendantProps> | undefined;
161
160
  values: () => Descendant<HTMLDivElement, ComboboxDescendantProps>[];
@@ -165,8 +164,8 @@ declare const useAutocomplete: <Multiple extends boolean = false>(props?: UseAut
165
164
  items: ComboboxItem[];
166
165
  max: number | undefined;
167
166
  open: boolean;
168
- setInputValue: react223.Dispatch<react223.SetStateAction<string>>;
169
- setValue: react223.Dispatch<react223.SetStateAction<Multiple extends true ? string[] : string>>;
167
+ setInputValue: react156.Dispatch<react156.SetStateAction<string>>;
168
+ setValue: react156.Dispatch<react156.SetStateAction<Multiple extends true ? string[] : string>>;
170
169
  value: Multiple extends true ? string[] : string;
171
170
  valueMap: {
172
171
  [key: string]: ComboboxItemWithValue;