@yamada-ui/autocomplete 1.5.1 → 1.5.2-dev-20240917033401
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.
- package/dist/autocomplete-context.d.mts +210 -0
- package/dist/autocomplete-context.d.ts +210 -0
- package/dist/autocomplete-context.js +53 -0
- package/dist/autocomplete-context.js.map +1 -0
- package/dist/autocomplete-context.mjs +18 -0
- package/dist/autocomplete-context.mjs.map +1 -0
- package/dist/autocomplete-create.d.mts +4 -3
- package/dist/autocomplete-create.d.ts +4 -3
- package/dist/autocomplete-create.js +56 -61
- package/dist/autocomplete-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +4 -1
- package/dist/autocomplete-empty.d.mts +4 -3
- package/dist/autocomplete-empty.d.ts +4 -3
- package/dist/autocomplete-empty.js +54 -59
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +4 -1
- package/dist/autocomplete-icon.d.mts +6 -4
- package/dist/autocomplete-icon.d.ts +6 -4
- package/dist/autocomplete-icon.js +15 -22
- package/dist/autocomplete-icon.js.map +1 -1
- package/dist/autocomplete-icon.mjs +2 -1
- package/dist/autocomplete-list.d.mts +2 -2
- package/dist/autocomplete-list.d.ts +2 -2
- package/dist/autocomplete-list.js +20 -23
- package/dist/autocomplete-list.js.map +1 -1
- package/dist/autocomplete-list.mjs +3 -1
- package/dist/autocomplete-option-group.d.mts +5 -9
- package/dist/autocomplete-option-group.d.ts +5 -9
- package/dist/autocomplete-option-group.js +14 -16
- package/dist/autocomplete-option-group.js.map +1 -1
- package/dist/autocomplete-option-group.mjs +3 -1
- package/dist/autocomplete-option.d.mts +15 -8
- package/dist/autocomplete-option.d.ts +15 -8
- package/dist/autocomplete-option.js +97 -102
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +4 -1
- package/dist/autocomplete.d.mts +13 -7
- package/dist/autocomplete.d.ts +13 -7
- package/dist/autocomplete.js +673 -661
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +12 -1
- package/dist/chunk-7GCVSXCV.mjs +190 -0
- package/dist/chunk-7GCVSXCV.mjs.map +1 -0
- package/dist/chunk-BD7VZQOL.mjs +267 -0
- package/dist/chunk-BD7VZQOL.mjs.map +1 -0
- package/dist/chunk-FZM3BH3D.mjs +57 -0
- package/dist/chunk-FZM3BH3D.mjs.map +1 -0
- package/dist/chunk-GM7RV2YY.mjs +959 -0
- package/dist/chunk-GM7RV2YY.mjs.map +1 -0
- package/dist/chunk-GOMUH7TZ.mjs +60 -0
- package/dist/chunk-GOMUH7TZ.mjs.map +1 -0
- package/dist/chunk-HL2KEBRX.mjs +87 -0
- package/dist/chunk-HL2KEBRX.mjs.map +1 -0
- package/dist/chunk-JMX72TSD.mjs +78 -0
- package/dist/chunk-JMX72TSD.mjs.map +1 -0
- package/dist/chunk-JPUKYLBW.mjs +25 -0
- package/dist/chunk-JPUKYLBW.mjs.map +1 -0
- package/dist/chunk-JXFXCGZK.mjs +102 -0
- package/dist/chunk-JXFXCGZK.mjs.map +1 -0
- package/dist/chunk-KCALQJLK.mjs +59 -0
- package/dist/chunk-KCALQJLK.mjs.map +1 -0
- package/dist/chunk-PRDD3JJO.mjs +202 -0
- package/dist/chunk-PRDD3JJO.mjs.map +1 -0
- package/dist/chunk-QGOCVO2C.mjs +68 -0
- package/dist/chunk-QGOCVO2C.mjs.map +1 -0
- package/dist/chunk-QQFSHTTC.mjs +59 -0
- package/dist/chunk-QQFSHTTC.mjs.map +1 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1550 -1536
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/multi-autocomplete.d.mts +13 -7
- package/dist/multi-autocomplete.d.ts +13 -7
- package/dist/multi-autocomplete.js +1516 -1504
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +12 -1
- package/dist/use-autocomplete-list.d.mts +8 -0
- package/dist/use-autocomplete-list.d.ts +8 -0
- package/dist/use-autocomplete-list.js +103 -0
- package/dist/use-autocomplete-list.js.map +1 -0
- package/dist/use-autocomplete-list.mjs +9 -0
- package/dist/use-autocomplete-list.mjs.map +1 -0
- package/dist/use-autocomplete-option-group.d.mts +16 -0
- package/dist/use-autocomplete-option-group.d.ts +16 -0
- package/dist/use-autocomplete-option-group.js +113 -0
- package/dist/use-autocomplete-option-group.js.map +1 -0
- package/dist/use-autocomplete-option-group.mjs +9 -0
- package/dist/use-autocomplete-option-group.mjs.map +1 -0
- package/dist/use-autocomplete-option.d.mts +49 -0
- package/dist/use-autocomplete-option.d.ts +49 -0
- package/dist/use-autocomplete-option.js +231 -0
- package/dist/use-autocomplete-option.js.map +1 -0
- package/dist/use-autocomplete-option.mjs +13 -0
- package/dist/use-autocomplete-option.mjs.map +1 -0
- package/dist/use-autocomplete.d.mts +188 -8
- package/dist/use-autocomplete.d.ts +188 -8
- package/dist/use-autocomplete.js +359 -481
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +9 -25
- package/package.json +13 -13
- package/dist/chunk-ZD25NCFE.mjs +0 -2038
- package/dist/chunk-ZD25NCFE.mjs.map +0 -1
- package/dist/use-autocomplete-BJNWa6hL.d.mts +0 -389
- package/dist/use-autocomplete-BJNWa6hL.d.ts +0 -389
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import {
|
|
3
|
+
useAutocompleteCreate,
|
|
4
|
+
useAutocompleteEmpty,
|
|
5
|
+
useAutocompleteOption
|
|
6
|
+
} from "./chunk-PRDD3JJO.mjs";
|
|
7
|
+
import "./chunk-JPUKYLBW.mjs";
|
|
8
|
+
export {
|
|
9
|
+
useAutocompleteCreate,
|
|
10
|
+
useAutocompleteEmpty,
|
|
11
|
+
useAutocompleteOption
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=use-autocomplete-option.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,8 +1,188 @@
|
|
|
1
|
-
import '@yamada-ui/core';
|
|
2
|
-
import '
|
|
3
|
-
import 'react';
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import '@yamada-ui/
|
|
7
|
-
import '@yamada-ui/
|
|
8
|
-
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps, PropGetter } from '@yamada-ui/core';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { FocusEvent, ChangeEvent, MouseEvent, DOMAttributes } from 'react';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant';
|
|
7
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
8
|
+
import { PopoverProps, ComboBoxProps } from '@yamada-ui/popover';
|
|
9
|
+
import { Union } from '@yamada-ui/utils';
|
|
10
|
+
import { AutocompleteOptionProps } from './autocomplete-option.mjs';
|
|
11
|
+
import { AutocompleteOptionGroupProps } from './autocomplete-option-group.mjs';
|
|
12
|
+
import './use-autocomplete-option.mjs';
|
|
13
|
+
import './use-autocomplete-option-group.mjs';
|
|
14
|
+
|
|
15
|
+
interface ChangeOptions {
|
|
16
|
+
forceUpdate?: boolean;
|
|
17
|
+
runOmit?: boolean;
|
|
18
|
+
runRebirth?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface AutocompleteItemWithValue extends AutocompleteOptionProps {
|
|
21
|
+
label?: string;
|
|
22
|
+
value?: string;
|
|
23
|
+
}
|
|
24
|
+
interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "isDisabled" | "isFocusable"> {
|
|
25
|
+
items?: AutocompleteItemWithValue[];
|
|
26
|
+
}
|
|
27
|
+
type AutocompleteItem = AutocompleteItemWithValue | AutocompleteItemWithItems;
|
|
28
|
+
type UseAutocompleteBaseProps<T extends string | string[] = string> = ComboBoxProps & FormControlOptions & {
|
|
29
|
+
/**
|
|
30
|
+
* The value of the autocomplete.
|
|
31
|
+
*/
|
|
32
|
+
value?: T;
|
|
33
|
+
/**
|
|
34
|
+
* The initial value of the autocomplete.
|
|
35
|
+
*/
|
|
36
|
+
defaultValue?: T;
|
|
37
|
+
/**
|
|
38
|
+
* The callback invoked when value state changes.
|
|
39
|
+
*/
|
|
40
|
+
onChange?: (value: T) => void;
|
|
41
|
+
/**
|
|
42
|
+
* The callback invoked when search input.
|
|
43
|
+
*/
|
|
44
|
+
onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* The callback invoked when autocomplete option created.
|
|
47
|
+
*/
|
|
48
|
+
onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Function to format text when search input.
|
|
51
|
+
*/
|
|
52
|
+
format?: (value: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* The position to be inserted when the autocomplete option is created.
|
|
55
|
+
*
|
|
56
|
+
* @default 'first'
|
|
57
|
+
*/
|
|
58
|
+
insertPositionItem?: Union<"first" | "last"> | [string, "first" | "last"];
|
|
59
|
+
/**
|
|
60
|
+
* If `true`, the list element will be closed when value is selected.
|
|
61
|
+
*
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
closeOnSelect?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The message displayed when the search yields no hits.
|
|
67
|
+
*
|
|
68
|
+
* @default 'No results found'
|
|
69
|
+
*/
|
|
70
|
+
emptyMessage?: string;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, enables the creation of autocomplete option.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
allowCreate?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* If `true`, enables the free input.
|
|
79
|
+
*/
|
|
80
|
+
allowFree?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* If `true`, the selected item(s) will be excluded from the list.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
omitSelectedValues?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The maximum selectable value.
|
|
89
|
+
*/
|
|
90
|
+
maxSelectValues?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Props for select option element.
|
|
93
|
+
*/
|
|
94
|
+
optionProps?: Omit<AutocompleteOptionProps, "value" | "children">;
|
|
95
|
+
/**
|
|
96
|
+
* If provided, generate options based on items.
|
|
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>;
|
|
101
|
+
declare const useAutocomplete: <T extends string | string[] = string>(props: UseAutocompleteProps<T>) => {
|
|
102
|
+
id: string | undefined;
|
|
103
|
+
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
|
+
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;
|
|
119
|
+
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
|
+
enabledFirstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
|
|
124
|
+
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
|
+
enabledNextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
|
|
127
|
+
};
|
|
128
|
+
value: T;
|
|
129
|
+
label: T | undefined;
|
|
130
|
+
inputValue: string;
|
|
131
|
+
isHit: boolean;
|
|
132
|
+
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;
|
|
140
|
+
isOpen: boolean;
|
|
141
|
+
isAllSelected: boolean;
|
|
142
|
+
listRef: react.RefObject<HTMLUListElement>;
|
|
143
|
+
inputRef: react.RefObject<HTMLInputElement>;
|
|
144
|
+
optionProps: Omit<AutocompleteOptionProps, "value" | "children"> | undefined;
|
|
145
|
+
formControlProps: {
|
|
146
|
+
disabled: boolean | undefined;
|
|
147
|
+
_invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
148
|
+
_hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
149
|
+
_active?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
150
|
+
_focus?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
151
|
+
_focusVisible?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
152
|
+
readOnly: boolean | undefined;
|
|
153
|
+
required: boolean | undefined;
|
|
154
|
+
"aria-disabled": boolean | undefined;
|
|
155
|
+
"aria-invalid": boolean | undefined;
|
|
156
|
+
"aria-required": boolean | undefined;
|
|
157
|
+
onBlur: (event: FocusEvent<HTMLInputElement, Element>) => void;
|
|
158
|
+
"data-readonly": boolean | "false" | "true";
|
|
159
|
+
};
|
|
160
|
+
setFocusedIndex: react.Dispatch<react.SetStateAction<number>>;
|
|
161
|
+
onChangeLabel: (newValue: string, { forceUpdate, runOmit }?: ChangeOptions) => void;
|
|
162
|
+
onChange: (newValue: string, { forceUpdate, runRebirth }?: ChangeOptions) => void;
|
|
163
|
+
onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
164
|
+
onCreate: () => void;
|
|
165
|
+
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
|
+
onClose: () => void;
|
|
172
|
+
onFocusFirst: () => void;
|
|
173
|
+
onFocusLast: () => void;
|
|
174
|
+
onFocusSelected: () => void;
|
|
175
|
+
onFocusNext: (index?: number) => void;
|
|
176
|
+
onFocusPrev: (index?: number) => void;
|
|
177
|
+
getPopoverProps: (props?: PopoverProps) => PopoverProps;
|
|
178
|
+
getContainerProps: PropGetter<"div", undefined>;
|
|
179
|
+
getFieldProps: PropGetter<"div", undefined>;
|
|
180
|
+
inputProps: DOMAttributes<HTMLInputElement>;
|
|
181
|
+
};
|
|
182
|
+
type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>;
|
|
183
|
+
declare const useAutocompleteInput: () => {
|
|
184
|
+
getInputProps: PropGetter<"input", undefined>;
|
|
185
|
+
};
|
|
186
|
+
type UseAutocompleteInputReturn = ReturnType<typeof useAutocompleteInput>;
|
|
187
|
+
|
|
188
|
+
export { type AutocompleteItem, type ChangeOptions, type UseAutocompleteInputReturn, type UseAutocompleteProps, type UseAutocompleteReturn, useAutocomplete, useAutocompleteInput };
|
|
@@ -1,8 +1,188 @@
|
|
|
1
|
-
import '@yamada-ui/core';
|
|
2
|
-
import '
|
|
3
|
-
import 'react';
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import '@yamada-ui/
|
|
7
|
-
import '@yamada-ui/
|
|
8
|
-
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps, PropGetter } from '@yamada-ui/core';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { FocusEvent, ChangeEvent, MouseEvent, DOMAttributes } from 'react';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant';
|
|
7
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
8
|
+
import { PopoverProps, ComboBoxProps } from '@yamada-ui/popover';
|
|
9
|
+
import { Union } from '@yamada-ui/utils';
|
|
10
|
+
import { AutocompleteOptionProps } from './autocomplete-option.js';
|
|
11
|
+
import { AutocompleteOptionGroupProps } from './autocomplete-option-group.js';
|
|
12
|
+
import './use-autocomplete-option.js';
|
|
13
|
+
import './use-autocomplete-option-group.js';
|
|
14
|
+
|
|
15
|
+
interface ChangeOptions {
|
|
16
|
+
forceUpdate?: boolean;
|
|
17
|
+
runOmit?: boolean;
|
|
18
|
+
runRebirth?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface AutocompleteItemWithValue extends AutocompleteOptionProps {
|
|
21
|
+
label?: string;
|
|
22
|
+
value?: string;
|
|
23
|
+
}
|
|
24
|
+
interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick<AutocompleteOptionProps, "isDisabled" | "isFocusable"> {
|
|
25
|
+
items?: AutocompleteItemWithValue[];
|
|
26
|
+
}
|
|
27
|
+
type AutocompleteItem = AutocompleteItemWithValue | AutocompleteItemWithItems;
|
|
28
|
+
type UseAutocompleteBaseProps<T extends string | string[] = string> = ComboBoxProps & FormControlOptions & {
|
|
29
|
+
/**
|
|
30
|
+
* The value of the autocomplete.
|
|
31
|
+
*/
|
|
32
|
+
value?: T;
|
|
33
|
+
/**
|
|
34
|
+
* The initial value of the autocomplete.
|
|
35
|
+
*/
|
|
36
|
+
defaultValue?: T;
|
|
37
|
+
/**
|
|
38
|
+
* The callback invoked when value state changes.
|
|
39
|
+
*/
|
|
40
|
+
onChange?: (value: T) => void;
|
|
41
|
+
/**
|
|
42
|
+
* The callback invoked when search input.
|
|
43
|
+
*/
|
|
44
|
+
onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* The callback invoked when autocomplete option created.
|
|
47
|
+
*/
|
|
48
|
+
onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Function to format text when search input.
|
|
51
|
+
*/
|
|
52
|
+
format?: (value: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* The position to be inserted when the autocomplete option is created.
|
|
55
|
+
*
|
|
56
|
+
* @default 'first'
|
|
57
|
+
*/
|
|
58
|
+
insertPositionItem?: Union<"first" | "last"> | [string, "first" | "last"];
|
|
59
|
+
/**
|
|
60
|
+
* If `true`, the list element will be closed when value is selected.
|
|
61
|
+
*
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
closeOnSelect?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The message displayed when the search yields no hits.
|
|
67
|
+
*
|
|
68
|
+
* @default 'No results found'
|
|
69
|
+
*/
|
|
70
|
+
emptyMessage?: string;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, enables the creation of autocomplete option.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
allowCreate?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* If `true`, enables the free input.
|
|
79
|
+
*/
|
|
80
|
+
allowFree?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* If `true`, the selected item(s) will be excluded from the list.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
omitSelectedValues?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The maximum selectable value.
|
|
89
|
+
*/
|
|
90
|
+
maxSelectValues?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Props for select option element.
|
|
93
|
+
*/
|
|
94
|
+
optionProps?: Omit<AutocompleteOptionProps, "value" | "children">;
|
|
95
|
+
/**
|
|
96
|
+
* If provided, generate options based on items.
|
|
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>;
|
|
101
|
+
declare const useAutocomplete: <T extends string | string[] = string>(props: UseAutocompleteProps<T>) => {
|
|
102
|
+
id: string | undefined;
|
|
103
|
+
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
|
+
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;
|
|
119
|
+
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
|
+
enabledFirstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
|
|
124
|
+
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
|
+
enabledNextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant<HTMLElement, {}> | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant<HTMLElement, {}> | undefined;
|
|
127
|
+
};
|
|
128
|
+
value: T;
|
|
129
|
+
label: T | undefined;
|
|
130
|
+
inputValue: string;
|
|
131
|
+
isHit: boolean;
|
|
132
|
+
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;
|
|
140
|
+
isOpen: boolean;
|
|
141
|
+
isAllSelected: boolean;
|
|
142
|
+
listRef: react.RefObject<HTMLUListElement>;
|
|
143
|
+
inputRef: react.RefObject<HTMLInputElement>;
|
|
144
|
+
optionProps: Omit<AutocompleteOptionProps, "value" | "children"> | undefined;
|
|
145
|
+
formControlProps: {
|
|
146
|
+
disabled: boolean | undefined;
|
|
147
|
+
_invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
148
|
+
_hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
149
|
+
_active?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
150
|
+
_focus?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
151
|
+
_focusVisible?: ({} & _yamada_ui_core.CSSUIObject) | undefined;
|
|
152
|
+
readOnly: boolean | undefined;
|
|
153
|
+
required: boolean | undefined;
|
|
154
|
+
"aria-disabled": boolean | undefined;
|
|
155
|
+
"aria-invalid": boolean | undefined;
|
|
156
|
+
"aria-required": boolean | undefined;
|
|
157
|
+
onBlur: (event: FocusEvent<HTMLInputElement, Element>) => void;
|
|
158
|
+
"data-readonly": boolean | "false" | "true";
|
|
159
|
+
};
|
|
160
|
+
setFocusedIndex: react.Dispatch<react.SetStateAction<number>>;
|
|
161
|
+
onChangeLabel: (newValue: string, { forceUpdate, runOmit }?: ChangeOptions) => void;
|
|
162
|
+
onChange: (newValue: string, { forceUpdate, runRebirth }?: ChangeOptions) => void;
|
|
163
|
+
onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
|
|
164
|
+
onCreate: () => void;
|
|
165
|
+
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
|
+
onClose: () => void;
|
|
172
|
+
onFocusFirst: () => void;
|
|
173
|
+
onFocusLast: () => void;
|
|
174
|
+
onFocusSelected: () => void;
|
|
175
|
+
onFocusNext: (index?: number) => void;
|
|
176
|
+
onFocusPrev: (index?: number) => void;
|
|
177
|
+
getPopoverProps: (props?: PopoverProps) => PopoverProps;
|
|
178
|
+
getContainerProps: PropGetter<"div", undefined>;
|
|
179
|
+
getFieldProps: PropGetter<"div", undefined>;
|
|
180
|
+
inputProps: DOMAttributes<HTMLInputElement>;
|
|
181
|
+
};
|
|
182
|
+
type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>;
|
|
183
|
+
declare const useAutocompleteInput: () => {
|
|
184
|
+
getInputProps: PropGetter<"input", undefined>;
|
|
185
|
+
};
|
|
186
|
+
type UseAutocompleteInputReturn = ReturnType<typeof useAutocompleteInput>;
|
|
187
|
+
|
|
188
|
+
export { type AutocompleteItem, type ChangeOptions, type UseAutocompleteInputReturn, type UseAutocompleteProps, type UseAutocompleteReturn, useAutocomplete, useAutocompleteInput };
|