@yamada-ui/autocomplete 1.5.4-next-20241005220055 → 1.5.4-next-20241008193728

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/dist/autocomplete-context.d.mts +115 -115
  2. package/dist/autocomplete-context.d.ts +115 -115
  3. package/dist/autocomplete-context.js +2 -2
  4. package/dist/autocomplete-context.js.map +1 -1
  5. package/dist/autocomplete-context.mjs +1 -1
  6. package/dist/autocomplete-create.d.mts +4 -4
  7. package/dist/autocomplete-create.d.ts +4 -4
  8. package/dist/autocomplete-create.js +32 -32
  9. package/dist/autocomplete-create.js.map +1 -1
  10. package/dist/autocomplete-create.mjs +4 -4
  11. package/dist/autocomplete-empty.d.mts +4 -4
  12. package/dist/autocomplete-empty.d.ts +4 -4
  13. package/dist/autocomplete-empty.js +34 -34
  14. package/dist/autocomplete-empty.js.map +1 -1
  15. package/dist/autocomplete-empty.mjs +4 -4
  16. package/dist/autocomplete-icon.js +17 -17
  17. package/dist/autocomplete-icon.js.map +1 -1
  18. package/dist/autocomplete-icon.mjs +2 -2
  19. package/dist/autocomplete-list.d.mts +2 -2
  20. package/dist/autocomplete-list.d.ts +2 -2
  21. package/dist/autocomplete-list.js +18 -18
  22. package/dist/autocomplete-list.js.map +1 -1
  23. package/dist/autocomplete-list.mjs +3 -3
  24. package/dist/autocomplete-option-group.js +10 -10
  25. package/dist/autocomplete-option-group.js.map +1 -1
  26. package/dist/autocomplete-option-group.mjs +3 -3
  27. package/dist/autocomplete-option.d.mts +1 -1
  28. package/dist/autocomplete-option.d.ts +1 -1
  29. package/dist/autocomplete-option.js +47 -47
  30. package/dist/autocomplete-option.js.map +1 -1
  31. package/dist/autocomplete-option.mjs +4 -4
  32. package/dist/autocomplete.d.mts +31 -31
  33. package/dist/autocomplete.d.ts +31 -31
  34. package/dist/autocomplete.js +294 -292
  35. package/dist/autocomplete.js.map +1 -1
  36. package/dist/autocomplete.mjs +12 -12
  37. package/dist/{chunk-6F3LT7J6.mjs → chunk-4SBNPEK7.mjs} +7 -7
  38. package/dist/{chunk-6F3LT7J6.mjs.map → chunk-4SBNPEK7.mjs.map} +1 -1
  39. package/dist/{chunk-JMX72TSD.mjs → chunk-67X7JKWL.mjs} +7 -7
  40. package/dist/{chunk-JMX72TSD.mjs.map → chunk-67X7JKWL.mjs.map} +1 -1
  41. package/dist/{chunk-HZECQUHV.mjs → chunk-AXC7ILCH.mjs} +40 -40
  42. package/dist/{chunk-HZECQUHV.mjs.map → chunk-AXC7ILCH.mjs.map} +1 -1
  43. package/dist/{chunk-OLOU5HFC.mjs → chunk-BGZIX6SN.mjs} +168 -166
  44. package/dist/chunk-BGZIX6SN.mjs.map +1 -0
  45. package/dist/{chunk-Q2HZVVOI.mjs → chunk-BKW7XJ6R.mjs} +16 -16
  46. package/dist/chunk-BKW7XJ6R.mjs.map +1 -0
  47. package/dist/{chunk-5LPWFWE6.mjs → chunk-DDMSYTKO.mjs} +34 -34
  48. package/dist/chunk-DDMSYTKO.mjs.map +1 -0
  49. package/dist/{chunk-QPIWG4ZF.mjs → chunk-EEECVCVW.mjs} +63 -61
  50. package/dist/chunk-EEECVCVW.mjs.map +1 -0
  51. package/dist/{chunk-5GKGL6BL.mjs → chunk-KLXMUIGY.mjs} +16 -16
  52. package/dist/chunk-KLXMUIGY.mjs.map +1 -0
  53. package/dist/{chunk-R76HPAN4.mjs → chunk-TR4X4EEG.mjs} +7 -7
  54. package/dist/{chunk-R76HPAN4.mjs.map → chunk-TR4X4EEG.mjs.map} +1 -1
  55. package/dist/{chunk-7SWSKLSA.mjs → chunk-V6YCG642.mjs} +18 -18
  56. package/dist/chunk-V6YCG642.mjs.map +1 -0
  57. package/dist/{chunk-S53LMDD7.mjs → chunk-VTBUO5SK.mjs} +15 -15
  58. package/dist/chunk-VTBUO5SK.mjs.map +1 -0
  59. package/dist/{chunk-JPUKYLBW.mjs → chunk-WDQYM4FP.mjs} +5 -5
  60. package/dist/chunk-WDQYM4FP.mjs.map +1 -0
  61. package/dist/{chunk-S2HFYJVI.mjs → chunk-WFLZPB35.mjs} +13 -13
  62. package/dist/chunk-WFLZPB35.mjs.map +1 -0
  63. package/dist/index.d.mts +4 -4
  64. package/dist/index.d.ts +4 -4
  65. package/dist/index.js +347 -343
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +13 -13
  68. package/dist/multi-autocomplete.d.mts +51 -51
  69. package/dist/multi-autocomplete.d.ts +51 -51
  70. package/dist/multi-autocomplete.js +317 -313
  71. package/dist/multi-autocomplete.js.map +1 -1
  72. package/dist/multi-autocomplete.mjs +12 -12
  73. package/dist/use-autocomplete-list.d.mts +1 -1
  74. package/dist/use-autocomplete-list.d.ts +1 -1
  75. package/dist/use-autocomplete-list.js +7 -7
  76. package/dist/use-autocomplete-list.js.map +1 -1
  77. package/dist/use-autocomplete-list.mjs +2 -2
  78. package/dist/use-autocomplete-option-group.js +7 -7
  79. package/dist/use-autocomplete-option-group.js.map +1 -1
  80. package/dist/use-autocomplete-option-group.mjs +2 -2
  81. package/dist/use-autocomplete-option.d.mts +12 -12
  82. package/dist/use-autocomplete-option.d.ts +12 -12
  83. package/dist/use-autocomplete-option.js +34 -34
  84. package/dist/use-autocomplete-option.js.map +1 -1
  85. package/dist/use-autocomplete-option.mjs +2 -2
  86. package/dist/use-autocomplete.d.mts +86 -86
  87. package/dist/use-autocomplete.d.ts +86 -86
  88. package/dist/use-autocomplete.js +216 -214
  89. package/dist/use-autocomplete.js.map +1 -1
  90. package/dist/use-autocomplete.mjs +7 -7
  91. package/package.json +13 -13
  92. package/dist/chunk-5GKGL6BL.mjs.map +0 -1
  93. package/dist/chunk-5LPWFWE6.mjs.map +0 -1
  94. package/dist/chunk-7SWSKLSA.mjs.map +0 -1
  95. package/dist/chunk-JPUKYLBW.mjs.map +0 -1
  96. package/dist/chunk-OLOU5HFC.mjs.map +0 -1
  97. package/dist/chunk-Q2HZVVOI.mjs.map +0 -1
  98. package/dist/chunk-QPIWG4ZF.mjs.map +0 -1
  99. package/dist/chunk-S2HFYJVI.mjs.map +0 -1
  100. package/dist/chunk-S53LMDD7.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps, PropGetter } from '@yamada-ui/core';
3
3
  import * as react from 'react';
4
- import { FocusEvent, ChangeEvent, MouseEvent, DOMAttributes } from 'react';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { FocusEvent, DOMAttributes, MouseEvent, ChangeEvent } from 'react';
6
5
  import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  import { FormControlOptions } from '@yamada-ui/form-control';
8
8
  import { PopoverProps, ComboBoxProps } from '@yamada-ui/popover';
9
9
  import { Union } from '@yamada-ui/utils';
@@ -24,28 +24,34 @@ interface AutocompleteItemWithValue extends AutocompleteOptionProps {
24
24
  interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "isDisabled" | "isFocusable"> {
25
25
  items?: AutocompleteItemWithValue[];
26
26
  }
27
- type AutocompleteItem = AutocompleteItemWithValue | AutocompleteItemWithItems;
28
- type UseAutocompleteBaseProps<T extends string | string[] = string> = ComboBoxProps & FormControlOptions & {
27
+ type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue;
28
+ type UseAutocompleteBaseProps<T extends string | string[] = string> = {
29
29
  /**
30
- * The value of the autocomplete.
30
+ * If `true`, enables the creation of autocomplete option.
31
+ *
32
+ * @default false
31
33
  */
32
- value?: T;
34
+ allowCreate?: boolean;
33
35
  /**
34
- * The initial value of the autocomplete.
36
+ * If `true`, enables the free input.
35
37
  */
36
- defaultValue?: T;
38
+ allowFree?: boolean;
37
39
  /**
38
- * The callback invoked when value state changes.
40
+ * If `true`, the list element will be closed when value is selected.
41
+ *
42
+ * @default true
39
43
  */
40
- onChange?: (value: T) => void;
44
+ closeOnSelect?: boolean;
41
45
  /**
42
- * The callback invoked when search input.
46
+ * The initial value of the autocomplete.
43
47
  */
44
- onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
48
+ defaultValue?: T;
45
49
  /**
46
- * The callback invoked when autocomplete option created.
50
+ * The message displayed when the search yields no hits.
51
+ *
52
+ * @default 'No results found'
47
53
  */
48
- onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
54
+ emptyMessage?: string;
49
55
  /**
50
56
  * Function to format text when search input.
51
57
  */
@@ -55,100 +61,96 @@ type UseAutocompleteBaseProps<T extends string | string[] = string> = ComboBoxPr
55
61
  *
56
62
  * @default 'first'
57
63
  */
58
- insertPositionItem?: Union<"first" | "last"> | [string, "first" | "last"];
64
+ insertPositionItem?: [string, "first" | "last"] | Union<"first" | "last">;
59
65
  /**
60
- * If `true`, the list element will be closed when value is selected.
61
- *
62
- * @default true
66
+ * If provided, generate options based on items.
63
67
  */
64
- closeOnSelect?: boolean;
68
+ items?: AutocompleteItem[];
65
69
  /**
66
- * The message displayed when the search yields no hits.
67
- *
68
- * @default 'No results found'
70
+ * The maximum selectable value.
69
71
  */
70
- emptyMessage?: string;
72
+ maxSelectValues?: number;
71
73
  /**
72
- * If `true`, enables the creation of autocomplete option.
74
+ * If `true`, the selected item(s) will be excluded from the list.
73
75
  *
74
76
  * @default false
75
77
  */
76
- allowCreate?: boolean;
78
+ omitSelectedValues?: boolean;
77
79
  /**
78
- * If `true`, enables the free input.
80
+ * The value of the autocomplete.
79
81
  */
80
- allowFree?: boolean;
82
+ value?: T;
81
83
  /**
82
- * If `true`, the selected item(s) will be excluded from the list.
83
- *
84
- * @default false
84
+ * Props for select option element.
85
85
  */
86
- omitSelectedValues?: boolean;
86
+ optionProps?: Omit<AutocompleteOptionProps, "children" | "value">;
87
87
  /**
88
- * The maximum selectable value.
88
+ * The callback invoked when value state changes.
89
89
  */
90
- maxSelectValues?: number;
90
+ onChange?: (value: T) => void;
91
91
  /**
92
- * Props for select option element.
92
+ * The callback invoked when autocomplete option created.
93
93
  */
94
- optionProps?: Omit<AutocompleteOptionProps, "value" | "children">;
94
+ onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
95
95
  /**
96
- * If provided, generate options based on items.
96
+ * The callback invoked when search input.
97
97
  */
98
- items?: AutocompleteItem[];
99
- };
100
- type UseAutocompleteProps<T extends string | string[] = string> = Omit<HTMLUIProps<"input">, keyof UseAutocompleteBaseProps | "list" | "disabled" | "required" | "readOnly" | "size"> & UseAutocompleteBaseProps<T>;
98
+ onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
99
+ } & ComboBoxProps & FormControlOptions;
100
+ type UseAutocompleteProps<T extends string | string[] = string> = Omit<HTMLUIProps<"input">, "disabled" | "list" | "readOnly" | "required" | "size" | keyof UseAutocompleteBaseProps> & UseAutocompleteBaseProps<T>;
101
101
  declare const useAutocomplete: <T extends string | string[] = string>(props: UseAutocompleteProps<T>) => {
102
102
  id: string | undefined;
103
+ allowCreate: boolean;
104
+ allowFree: boolean;
105
+ closeOnSelect: boolean;
106
+ computedChildren: (react_jsx_runtime.JSX.Element | undefined)[] | undefined;
103
107
  descendants: {
104
- register: (nodeOrOptions: HTMLElement | {
105
- disabled?: boolean;
106
- id?: string;
107
- filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined;
108
- } | null) => void | ((node: HTMLElement | null) => void);
109
- unregister: (node: HTMLElement) => void;
110
- destroy: () => void;
111
108
  count: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
112
- values: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
113
- value: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
114
- indexOf: (node: HTMLElement | null) => number;
115
- firstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
116
- lastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
117
- prevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
118
- nextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
109
+ destroy: () => void;
119
110
  enabledCount: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
120
- enabledValues: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
121
- enabledValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
122
- enabledIndexOf: (node: HTMLElement | null, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
123
111
  enabledFirstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
112
+ enabledIndexOf: (node?: HTMLElement | null | undefined, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
124
113
  enabledLastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
125
- enabledPrevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
126
114
  enabledNextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
115
+ enabledPrevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
116
+ enabledValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
117
+ enabledValues: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
118
+ firstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
119
+ indexOf: (node?: HTMLElement | null | undefined) => number;
120
+ lastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
121
+ nextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
122
+ prevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
123
+ register: (nodeOrOptions?: HTMLElement | {
124
+ id?: string;
125
+ disabled?: boolean;
126
+ filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined;
127
+ } | null | undefined) => void | ((node: HTMLElement | null) => void);
128
+ unregister: (node?: HTMLElement | undefined) => void;
129
+ value: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
130
+ values: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
127
131
  };
128
- value: T;
129
- label: T | undefined;
132
+ emptyMessage: string;
133
+ focusedIndex: number;
134
+ inputRef: react.RefObject<HTMLInputElement>;
130
135
  inputValue: string;
131
- isHit: boolean;
136
+ isAllSelected: boolean;
132
137
  isEmpty: boolean;
133
- computedChildren: (react_jsx_runtime.JSX.Element | undefined)[] | undefined;
134
- focusedIndex: number;
135
- omitSelectedValues: boolean;
136
- closeOnSelect: boolean;
137
- allowCreate: boolean;
138
- allowFree: boolean;
139
- emptyMessage: string;
138
+ isHit: boolean;
140
139
  isOpen: boolean;
141
- isAllSelected: boolean;
140
+ label: T | undefined;
142
141
  listRef: react.RefObject<HTMLUListElement>;
143
- inputRef: react.RefObject<HTMLInputElement>;
144
- optionProps: Omit<AutocompleteOptionProps, "value" | "children"> | undefined;
142
+ omitSelectedValues: boolean;
143
+ pickOptions: (value: string) => void;
144
+ rebirthOptions: (runFocus?: boolean) => void;
145
+ setFocusedIndex: react.Dispatch<react.SetStateAction<number>>;
146
+ value: T;
145
147
  formControlProps: {
146
148
  disabled: boolean | undefined;
147
- _invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
148
- _hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
149
149
  _active?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
150
150
  _focus?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
151
151
  _focusVisible?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
152
+ _hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
153
+ _invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
152
154
  readOnly: boolean | undefined;
153
155
  required: boolean | undefined;
154
156
  "aria-disabled": boolean | undefined;
@@ -157,27 +159,25 @@ declare const useAutocomplete: <T extends string | string[] = string>(props: Use
157
159
  onBlur: (event: FocusEvent<HTMLInputElement, Element>) => void;
158
160
  "data-readonly": boolean | "false" | "true";
159
161
  };
160
- setFocusedIndex: react.Dispatch<react.SetStateAction<number>>;
161
- onChangeLabel: (newValue: string, { forceUpdate, runOmit }?: ChangeOptions) => void;
162
+ getContainerProps: PropGetter<"div", undefined>;
163
+ getFieldProps: PropGetter<"div", undefined>;
164
+ getPopoverProps: (props?: PopoverProps) => PopoverProps;
165
+ inputProps: DOMAttributes<HTMLInputElement>;
166
+ optionProps: Omit<AutocompleteOptionProps, "value" | "children"> | undefined;
162
167
  onChange: (newValue: string, { forceUpdate, runRebirth }?: ChangeOptions) => void;
163
- onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
164
- onCreate: () => void;
168
+ onChangeLabel: (newValue: string, { forceUpdate, runOmit }?: ChangeOptions) => void;
165
169
  onClear: (ev: MouseEvent<HTMLDivElement>) => void;
166
- onCompositionStart: () => void;
167
- onCompositionEnd: () => void;
168
- pickOptions: (value: string) => void;
169
- rebirthOptions: (runFocus?: boolean) => void;
170
- onOpen: () => void;
171
170
  onClose: () => void;
171
+ onCompositionEnd: () => void;
172
+ onCompositionStart: () => void;
173
+ onCreate: () => void;
172
174
  onFocusFirst: () => void;
173
175
  onFocusLast: () => void;
174
- onFocusSelected: () => void;
175
176
  onFocusNext: (index?: number) => void;
176
177
  onFocusPrev: (index?: number) => void;
177
- getPopoverProps: (props?: PopoverProps) => PopoverProps;
178
- getContainerProps: PropGetter<"div", undefined>;
179
- getFieldProps: PropGetter<"div", undefined>;
180
- inputProps: DOMAttributes<HTMLInputElement>;
178
+ onFocusSelected: () => void;
179
+ onOpen: () => void;
180
+ onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
181
181
  };
182
182
  type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>;
183
183
  declare const useAutocompleteInput: () => {
@@ -1,9 +1,9 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps, PropGetter } from '@yamada-ui/core';
3
3
  import * as react from 'react';
4
- import { FocusEvent, ChangeEvent, MouseEvent, DOMAttributes } from 'react';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { FocusEvent, DOMAttributes, MouseEvent, ChangeEvent } from 'react';
6
5
  import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  import { FormControlOptions } from '@yamada-ui/form-control';
8
8
  import { PopoverProps, ComboBoxProps } from '@yamada-ui/popover';
9
9
  import { Union } from '@yamada-ui/utils';
@@ -24,28 +24,34 @@ interface AutocompleteItemWithValue extends AutocompleteOptionProps {
24
24
  interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "isDisabled" | "isFocusable"> {
25
25
  items?: AutocompleteItemWithValue[];
26
26
  }
27
- type AutocompleteItem = AutocompleteItemWithValue | AutocompleteItemWithItems;
28
- type UseAutocompleteBaseProps<T extends string | string[] = string> = ComboBoxProps & FormControlOptions & {
27
+ type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue;
28
+ type UseAutocompleteBaseProps<T extends string | string[] = string> = {
29
29
  /**
30
- * The value of the autocomplete.
30
+ * If `true`, enables the creation of autocomplete option.
31
+ *
32
+ * @default false
31
33
  */
32
- value?: T;
34
+ allowCreate?: boolean;
33
35
  /**
34
- * The initial value of the autocomplete.
36
+ * If `true`, enables the free input.
35
37
  */
36
- defaultValue?: T;
38
+ allowFree?: boolean;
37
39
  /**
38
- * The callback invoked when value state changes.
40
+ * If `true`, the list element will be closed when value is selected.
41
+ *
42
+ * @default true
39
43
  */
40
- onChange?: (value: T) => void;
44
+ closeOnSelect?: boolean;
41
45
  /**
42
- * The callback invoked when search input.
46
+ * The initial value of the autocomplete.
43
47
  */
44
- onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
48
+ defaultValue?: T;
45
49
  /**
46
- * The callback invoked when autocomplete option created.
50
+ * The message displayed when the search yields no hits.
51
+ *
52
+ * @default 'No results found'
47
53
  */
48
- onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
54
+ emptyMessage?: string;
49
55
  /**
50
56
  * Function to format text when search input.
51
57
  */
@@ -55,100 +61,96 @@ type UseAutocompleteBaseProps<T extends string | string[] = string> = ComboBoxPr
55
61
  *
56
62
  * @default 'first'
57
63
  */
58
- insertPositionItem?: Union<"first" | "last"> | [string, "first" | "last"];
64
+ insertPositionItem?: [string, "first" | "last"] | Union<"first" | "last">;
59
65
  /**
60
- * If `true`, the list element will be closed when value is selected.
61
- *
62
- * @default true
66
+ * If provided, generate options based on items.
63
67
  */
64
- closeOnSelect?: boolean;
68
+ items?: AutocompleteItem[];
65
69
  /**
66
- * The message displayed when the search yields no hits.
67
- *
68
- * @default 'No results found'
70
+ * The maximum selectable value.
69
71
  */
70
- emptyMessage?: string;
72
+ maxSelectValues?: number;
71
73
  /**
72
- * If `true`, enables the creation of autocomplete option.
74
+ * If `true`, the selected item(s) will be excluded from the list.
73
75
  *
74
76
  * @default false
75
77
  */
76
- allowCreate?: boolean;
78
+ omitSelectedValues?: boolean;
77
79
  /**
78
- * If `true`, enables the free input.
80
+ * The value of the autocomplete.
79
81
  */
80
- allowFree?: boolean;
82
+ value?: T;
81
83
  /**
82
- * If `true`, the selected item(s) will be excluded from the list.
83
- *
84
- * @default false
84
+ * Props for select option element.
85
85
  */
86
- omitSelectedValues?: boolean;
86
+ optionProps?: Omit<AutocompleteOptionProps, "children" | "value">;
87
87
  /**
88
- * The maximum selectable value.
88
+ * The callback invoked when value state changes.
89
89
  */
90
- maxSelectValues?: number;
90
+ onChange?: (value: T) => void;
91
91
  /**
92
- * Props for select option element.
92
+ * The callback invoked when autocomplete option created.
93
93
  */
94
- optionProps?: Omit<AutocompleteOptionProps, "value" | "children">;
94
+ onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
95
95
  /**
96
- * If provided, generate options based on items.
96
+ * The callback invoked when search input.
97
97
  */
98
- items?: AutocompleteItem[];
99
- };
100
- type UseAutocompleteProps<T extends string | string[] = string> = Omit<HTMLUIProps<"input">, keyof UseAutocompleteBaseProps | "list" | "disabled" | "required" | "readOnly" | "size"> & UseAutocompleteBaseProps<T>;
98
+ onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
99
+ } & ComboBoxProps & FormControlOptions;
100
+ type UseAutocompleteProps<T extends string | string[] = string> = Omit<HTMLUIProps<"input">, "disabled" | "list" | "readOnly" | "required" | "size" | keyof UseAutocompleteBaseProps> & UseAutocompleteBaseProps<T>;
101
101
  declare const useAutocomplete: <T extends string | string[] = string>(props: UseAutocompleteProps<T>) => {
102
102
  id: string | undefined;
103
+ allowCreate: boolean;
104
+ allowFree: boolean;
105
+ closeOnSelect: boolean;
106
+ computedChildren: (react_jsx_runtime.JSX.Element | undefined)[] | undefined;
103
107
  descendants: {
104
- register: (nodeOrOptions: HTMLElement | {
105
- disabled?: boolean;
106
- id?: string;
107
- filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined;
108
- } | null) => void | ((node: HTMLElement | null) => void);
109
- unregister: (node: HTMLElement) => void;
110
- destroy: () => void;
111
108
  count: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
112
- values: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
113
- value: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
114
- indexOf: (node: HTMLElement | null) => number;
115
- firstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
116
- lastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
117
- prevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
118
- nextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
109
+ destroy: () => void;
119
110
  enabledCount: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
120
- enabledValues: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
121
- enabledValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
122
- enabledIndexOf: (node: HTMLElement | null, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
123
111
  enabledFirstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
112
+ enabledIndexOf: (node?: HTMLElement | null | undefined, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => number;
124
113
  enabledLastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
125
- enabledPrevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
126
114
  enabledNextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
115
+ enabledPrevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
116
+ enabledValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
117
+ enabledValues: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
118
+ firstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
119
+ indexOf: (node?: HTMLElement | null | undefined) => number;
120
+ lastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
121
+ nextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
122
+ prevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
123
+ register: (nodeOrOptions?: HTMLElement | {
124
+ id?: string;
125
+ disabled?: boolean;
126
+ filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined;
127
+ } | null | undefined) => void | ((node: HTMLElement | null) => void);
128
+ unregister: (node?: HTMLElement | undefined) => void;
129
+ value: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
130
+ values: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}>[];
127
131
  };
128
- value: T;
129
- label: T | undefined;
132
+ emptyMessage: string;
133
+ focusedIndex: number;
134
+ inputRef: react.RefObject<HTMLInputElement>;
130
135
  inputValue: string;
131
- isHit: boolean;
136
+ isAllSelected: boolean;
132
137
  isEmpty: boolean;
133
- computedChildren: (react_jsx_runtime.JSX.Element | undefined)[] | undefined;
134
- focusedIndex: number;
135
- omitSelectedValues: boolean;
136
- closeOnSelect: boolean;
137
- allowCreate: boolean;
138
- allowFree: boolean;
139
- emptyMessage: string;
138
+ isHit: boolean;
140
139
  isOpen: boolean;
141
- isAllSelected: boolean;
140
+ label: T | undefined;
142
141
  listRef: react.RefObject<HTMLUListElement>;
143
- inputRef: react.RefObject<HTMLInputElement>;
144
- optionProps: Omit<AutocompleteOptionProps, "value" | "children"> | undefined;
142
+ omitSelectedValues: boolean;
143
+ pickOptions: (value: string) => void;
144
+ rebirthOptions: (runFocus?: boolean) => void;
145
+ setFocusedIndex: react.Dispatch<react.SetStateAction<number>>;
146
+ value: T;
145
147
  formControlProps: {
146
148
  disabled: boolean | undefined;
147
- _invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
148
- _hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
149
149
  _active?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
150
150
  _focus?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
151
151
  _focusVisible?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
152
+ _hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
153
+ _invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
152
154
  readOnly: boolean | undefined;
153
155
  required: boolean | undefined;
154
156
  "aria-disabled": boolean | undefined;
@@ -157,27 +159,25 @@ declare const useAutocomplete: <T extends string | string[] = string>(props: Use
157
159
  onBlur: (event: FocusEvent<HTMLInputElement, Element>) => void;
158
160
  "data-readonly": boolean | "false" | "true";
159
161
  };
160
- setFocusedIndex: react.Dispatch<react.SetStateAction<number>>;
161
- onChangeLabel: (newValue: string, { forceUpdate, runOmit }?: ChangeOptions) => void;
162
+ getContainerProps: PropGetter<"div", undefined>;
163
+ getFieldProps: PropGetter<"div", undefined>;
164
+ getPopoverProps: (props?: PopoverProps) => PopoverProps;
165
+ inputProps: DOMAttributes<HTMLInputElement>;
166
+ optionProps: Omit<AutocompleteOptionProps, "value" | "children"> | undefined;
162
167
  onChange: (newValue: string, { forceUpdate, runRebirth }?: ChangeOptions) => void;
163
- onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
164
- onCreate: () => void;
168
+ onChangeLabel: (newValue: string, { forceUpdate, runOmit }?: ChangeOptions) => void;
165
169
  onClear: (ev: MouseEvent<HTMLDivElement>) => void;
166
- onCompositionStart: () => void;
167
- onCompositionEnd: () => void;
168
- pickOptions: (value: string) => void;
169
- rebirthOptions: (runFocus?: boolean) => void;
170
- onOpen: () => void;
171
170
  onClose: () => void;
171
+ onCompositionEnd: () => void;
172
+ onCompositionStart: () => void;
173
+ onCreate: () => void;
172
174
  onFocusFirst: () => void;
173
175
  onFocusLast: () => void;
174
- onFocusSelected: () => void;
175
176
  onFocusNext: (index?: number) => void;
176
177
  onFocusPrev: (index?: number) => void;
177
- getPopoverProps: (props?: PopoverProps) => PopoverProps;
178
- getContainerProps: PropGetter<"div", undefined>;
179
- getFieldProps: PropGetter<"div", undefined>;
180
- inputProps: DOMAttributes<HTMLInputElement>;
178
+ onFocusSelected: () => void;
179
+ onOpen: () => void;
180
+ onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
181
181
  };
182
182
  type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>;
183
183
  declare const useAutocompleteInput: () => {