@yamada-ui/autocomplete 1.5.4-dev-20241005224505 → 1.5.4-dev-20241006032009
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/autocomplete-context.d.mts +115 -115
- package/dist/autocomplete-context.d.ts +115 -115
- package/dist/autocomplete-context.js +2 -2
- package/dist/autocomplete-context.js.map +1 -1
- package/dist/autocomplete-context.mjs +1 -1
- package/dist/autocomplete-create.d.mts +4 -4
- package/dist/autocomplete-create.d.ts +4 -4
- package/dist/autocomplete-create.js +32 -32
- package/dist/autocomplete-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +4 -4
- package/dist/autocomplete-empty.d.mts +4 -4
- package/dist/autocomplete-empty.d.ts +4 -4
- package/dist/autocomplete-empty.js +34 -34
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +4 -4
- package/dist/autocomplete-icon.js +17 -17
- package/dist/autocomplete-icon.js.map +1 -1
- package/dist/autocomplete-icon.mjs +2 -2
- package/dist/autocomplete-list.d.mts +2 -2
- package/dist/autocomplete-list.d.ts +2 -2
- package/dist/autocomplete-list.js +18 -18
- package/dist/autocomplete-list.js.map +1 -1
- package/dist/autocomplete-list.mjs +3 -3
- package/dist/autocomplete-option-group.js +14 -14
- package/dist/autocomplete-option-group.js.map +1 -1
- package/dist/autocomplete-option-group.mjs +3 -3
- package/dist/autocomplete-option.d.mts +1 -1
- package/dist/autocomplete-option.d.ts +1 -1
- package/dist/autocomplete-option.js +47 -47
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +4 -4
- package/dist/autocomplete.d.mts +31 -31
- package/dist/autocomplete.d.ts +31 -31
- package/dist/autocomplete.js +299 -297
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +12 -12
- package/dist/{chunk-5GKGL6BL.mjs → chunk-2MVSDK7L.mjs} +16 -16
- package/dist/chunk-2MVSDK7L.mjs.map +1 -0
- package/dist/{chunk-JMX72TSD.mjs → chunk-2SISETLV.mjs} +11 -11
- package/dist/{chunk-JMX72TSD.mjs.map → chunk-2SISETLV.mjs.map} +1 -1
- package/dist/{chunk-OLOU5HFC.mjs → chunk-4APEPTYJ.mjs} +169 -167
- package/dist/chunk-4APEPTYJ.mjs.map +1 -0
- package/dist/{chunk-6F3LT7J6.mjs → chunk-EWV3Q3S4.mjs} +7 -7
- package/dist/{chunk-6F3LT7J6.mjs.map → chunk-EWV3Q3S4.mjs.map} +1 -1
- package/dist/{chunk-Q2HZVVOI.mjs → chunk-I4IW2CW7.mjs} +16 -16
- package/dist/chunk-I4IW2CW7.mjs.map +1 -0
- package/dist/{chunk-7SWSKLSA.mjs → chunk-I5X4WSCX.mjs} +18 -18
- package/dist/chunk-I5X4WSCX.mjs.map +1 -0
- package/dist/{chunk-HZECQUHV.mjs → chunk-PXQD7AV2.mjs} +40 -40
- package/dist/{chunk-HZECQUHV.mjs.map → chunk-PXQD7AV2.mjs.map} +1 -1
- package/dist/{chunk-QPIWG4ZF.mjs → chunk-TJGVRIGK.mjs} +62 -60
- package/dist/chunk-TJGVRIGK.mjs.map +1 -0
- package/dist/{chunk-R76HPAN4.mjs → chunk-TR4X4EEG.mjs} +7 -7
- package/dist/{chunk-R76HPAN4.mjs.map → chunk-TR4X4EEG.mjs.map} +1 -1
- package/dist/{chunk-S53LMDD7.mjs → chunk-VTBUO5SK.mjs} +15 -15
- package/dist/chunk-VTBUO5SK.mjs.map +1 -0
- package/dist/{chunk-JPUKYLBW.mjs → chunk-WDQYM4FP.mjs} +5 -5
- package/dist/chunk-WDQYM4FP.mjs.map +1 -0
- package/dist/{chunk-S2HFYJVI.mjs → chunk-ZEGANG5C.mjs} +13 -13
- package/dist/chunk-ZEGANG5C.mjs.map +1 -0
- package/dist/{chunk-5LPWFWE6.mjs → chunk-ZJFWWXQM.mjs} +34 -34
- package/dist/chunk-ZJFWWXQM.mjs.map +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +351 -347
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/multi-autocomplete.d.mts +51 -51
- package/dist/multi-autocomplete.d.ts +51 -51
- package/dist/multi-autocomplete.js +321 -317
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +12 -12
- package/dist/use-autocomplete-list.d.mts +1 -1
- package/dist/use-autocomplete-list.d.ts +1 -1
- package/dist/use-autocomplete-list.js +7 -7
- package/dist/use-autocomplete-list.js.map +1 -1
- package/dist/use-autocomplete-list.mjs +2 -2
- package/dist/use-autocomplete-option-group.js +11 -11
- package/dist/use-autocomplete-option-group.js.map +1 -1
- package/dist/use-autocomplete-option-group.mjs +2 -2
- package/dist/use-autocomplete-option.d.mts +12 -12
- package/dist/use-autocomplete-option.d.ts +12 -12
- package/dist/use-autocomplete-option.js +34 -34
- package/dist/use-autocomplete-option.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +2 -2
- package/dist/use-autocomplete.d.mts +86 -86
- package/dist/use-autocomplete.d.ts +86 -86
- package/dist/use-autocomplete.js +221 -219
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +7 -7
- package/package.json +13 -13
- package/dist/chunk-5GKGL6BL.mjs.map +0 -1
- package/dist/chunk-5LPWFWE6.mjs.map +0 -1
- package/dist/chunk-7SWSKLSA.mjs.map +0 -1
- package/dist/chunk-JPUKYLBW.mjs.map +0 -1
- package/dist/chunk-OLOU5HFC.mjs.map +0 -1
- package/dist/chunk-Q2HZVVOI.mjs.map +0 -1
- package/dist/chunk-QPIWG4ZF.mjs.map +0 -1
- package/dist/chunk-S2HFYJVI.mjs.map +0 -1
- 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,
|
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 =
|
28
|
-
type UseAutocompleteBaseProps<T extends string | string[] = string> =
|
27
|
+
type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue;
|
28
|
+
type UseAutocompleteBaseProps<T extends string | string[] = string> = {
|
29
29
|
/**
|
30
|
-
*
|
30
|
+
* If `true`, enables the creation of autocomplete option.
|
31
|
+
*
|
32
|
+
* @default false
|
31
33
|
*/
|
32
|
-
|
34
|
+
allowCreate?: boolean;
|
33
35
|
/**
|
34
|
-
*
|
36
|
+
* If `true`, enables the free input.
|
35
37
|
*/
|
36
|
-
|
38
|
+
allowFree?: boolean;
|
37
39
|
/**
|
38
|
-
*
|
40
|
+
* If `true`, the list element will be closed when value is selected.
|
41
|
+
*
|
42
|
+
* @default true
|
39
43
|
*/
|
40
|
-
|
44
|
+
closeOnSelect?: boolean;
|
41
45
|
/**
|
42
|
-
* The
|
46
|
+
* The initial value of the autocomplete.
|
43
47
|
*/
|
44
|
-
|
48
|
+
defaultValue?: T;
|
45
49
|
/**
|
46
|
-
* The
|
50
|
+
* The message displayed when the search yields no hits.
|
51
|
+
*
|
52
|
+
* @default 'No results found'
|
47
53
|
*/
|
48
|
-
|
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?:
|
64
|
+
insertPositionItem?: [string, "first" | "last"] | Union<"first" | "last">;
|
59
65
|
/**
|
60
|
-
* If
|
61
|
-
*
|
62
|
-
* @default true
|
66
|
+
* If provided, generate options based on items.
|
63
67
|
*/
|
64
|
-
|
68
|
+
items?: AutocompleteItem[];
|
65
69
|
/**
|
66
|
-
* The
|
67
|
-
*
|
68
|
-
* @default 'No results found'
|
70
|
+
* The maximum selectable value.
|
69
71
|
*/
|
70
|
-
|
72
|
+
maxSelectValues?: number;
|
71
73
|
/**
|
72
|
-
* If `true`,
|
74
|
+
* If `true`, the selected item(s) will be excluded from the list.
|
73
75
|
*
|
74
76
|
* @default false
|
75
77
|
*/
|
76
|
-
|
78
|
+
omitSelectedValues?: boolean;
|
77
79
|
/**
|
78
|
-
*
|
80
|
+
* The value of the autocomplete.
|
79
81
|
*/
|
80
|
-
|
82
|
+
value?: T;
|
81
83
|
/**
|
82
|
-
*
|
83
|
-
*
|
84
|
-
* @default false
|
84
|
+
* Props for select option element.
|
85
85
|
*/
|
86
|
-
|
86
|
+
optionProps?: Omit<AutocompleteOptionProps, "children" | "value">;
|
87
87
|
/**
|
88
|
-
* The
|
88
|
+
* The callback invoked when value state changes.
|
89
89
|
*/
|
90
|
-
|
90
|
+
onChange?: (value: T) => void;
|
91
91
|
/**
|
92
|
-
*
|
92
|
+
* The callback invoked when autocomplete option created.
|
93
93
|
*/
|
94
|
-
|
94
|
+
onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
|
95
95
|
/**
|
96
|
-
*
|
96
|
+
* The callback invoked when search input.
|
97
97
|
*/
|
98
|
-
|
99
|
-
};
|
100
|
-
type UseAutocompleteProps<T extends string | string[] = string> = Omit<HTMLUIProps<"input">,
|
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
|
-
|
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
|
-
|
129
|
-
|
132
|
+
emptyMessage: string;
|
133
|
+
focusedIndex: number;
|
134
|
+
inputRef: react.RefObject<HTMLInputElement>;
|
130
135
|
inputValue: string;
|
131
|
-
|
136
|
+
isAllSelected: boolean;
|
132
137
|
isEmpty: boolean;
|
133
|
-
|
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
|
-
|
140
|
+
label: T | undefined;
|
142
141
|
listRef: react.RefObject<HTMLUListElement>;
|
143
|
-
|
144
|
-
|
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
|
-
|
161
|
-
|
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
|
-
|
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
|
-
|
178
|
-
|
179
|
-
|
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,
|
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 =
|
28
|
-
type UseAutocompleteBaseProps<T extends string | string[] = string> =
|
27
|
+
type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue;
|
28
|
+
type UseAutocompleteBaseProps<T extends string | string[] = string> = {
|
29
29
|
/**
|
30
|
-
*
|
30
|
+
* If `true`, enables the creation of autocomplete option.
|
31
|
+
*
|
32
|
+
* @default false
|
31
33
|
*/
|
32
|
-
|
34
|
+
allowCreate?: boolean;
|
33
35
|
/**
|
34
|
-
*
|
36
|
+
* If `true`, enables the free input.
|
35
37
|
*/
|
36
|
-
|
38
|
+
allowFree?: boolean;
|
37
39
|
/**
|
38
|
-
*
|
40
|
+
* If `true`, the list element will be closed when value is selected.
|
41
|
+
*
|
42
|
+
* @default true
|
39
43
|
*/
|
40
|
-
|
44
|
+
closeOnSelect?: boolean;
|
41
45
|
/**
|
42
|
-
* The
|
46
|
+
* The initial value of the autocomplete.
|
43
47
|
*/
|
44
|
-
|
48
|
+
defaultValue?: T;
|
45
49
|
/**
|
46
|
-
* The
|
50
|
+
* The message displayed when the search yields no hits.
|
51
|
+
*
|
52
|
+
* @default 'No results found'
|
47
53
|
*/
|
48
|
-
|
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?:
|
64
|
+
insertPositionItem?: [string, "first" | "last"] | Union<"first" | "last">;
|
59
65
|
/**
|
60
|
-
* If
|
61
|
-
*
|
62
|
-
* @default true
|
66
|
+
* If provided, generate options based on items.
|
63
67
|
*/
|
64
|
-
|
68
|
+
items?: AutocompleteItem[];
|
65
69
|
/**
|
66
|
-
* The
|
67
|
-
*
|
68
|
-
* @default 'No results found'
|
70
|
+
* The maximum selectable value.
|
69
71
|
*/
|
70
|
-
|
72
|
+
maxSelectValues?: number;
|
71
73
|
/**
|
72
|
-
* If `true`,
|
74
|
+
* If `true`, the selected item(s) will be excluded from the list.
|
73
75
|
*
|
74
76
|
* @default false
|
75
77
|
*/
|
76
|
-
|
78
|
+
omitSelectedValues?: boolean;
|
77
79
|
/**
|
78
|
-
*
|
80
|
+
* The value of the autocomplete.
|
79
81
|
*/
|
80
|
-
|
82
|
+
value?: T;
|
81
83
|
/**
|
82
|
-
*
|
83
|
-
*
|
84
|
-
* @default false
|
84
|
+
* Props for select option element.
|
85
85
|
*/
|
86
|
-
|
86
|
+
optionProps?: Omit<AutocompleteOptionProps, "children" | "value">;
|
87
87
|
/**
|
88
|
-
* The
|
88
|
+
* The callback invoked when value state changes.
|
89
89
|
*/
|
90
|
-
|
90
|
+
onChange?: (value: T) => void;
|
91
91
|
/**
|
92
|
-
*
|
92
|
+
* The callback invoked when autocomplete option created.
|
93
93
|
*/
|
94
|
-
|
94
|
+
onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
|
95
95
|
/**
|
96
|
-
*
|
96
|
+
* The callback invoked when search input.
|
97
97
|
*/
|
98
|
-
|
99
|
-
};
|
100
|
-
type UseAutocompleteProps<T extends string | string[] = string> = Omit<HTMLUIProps<"input">,
|
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
|
-
|
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
|
-
|
129
|
-
|
132
|
+
emptyMessage: string;
|
133
|
+
focusedIndex: number;
|
134
|
+
inputRef: react.RefObject<HTMLInputElement>;
|
130
135
|
inputValue: string;
|
131
|
-
|
136
|
+
isAllSelected: boolean;
|
132
137
|
isEmpty: boolean;
|
133
|
-
|
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
|
-
|
140
|
+
label: T | undefined;
|
142
141
|
listRef: react.RefObject<HTMLUListElement>;
|
143
|
-
|
144
|
-
|
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
|
-
|
161
|
-
|
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
|
-
|
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
|
-
|
178
|
-
|
179
|
-
|
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: () => {
|