@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
@@ -2,32 +2,32 @@
|
|
2
2
|
import {
|
3
3
|
useAutocomplete,
|
4
4
|
useAutocompleteInput
|
5
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-4APEPTYJ.mjs";
|
6
6
|
import {
|
7
7
|
AutocompleteCreate
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-I4IW2CW7.mjs";
|
9
9
|
import {
|
10
10
|
AutocompleteEmpty
|
11
|
-
} from "./chunk-
|
11
|
+
} from "./chunk-2MVSDK7L.mjs";
|
12
12
|
import {
|
13
13
|
AutocompleteList
|
14
|
-
} from "./chunk-
|
14
|
+
} from "./chunk-VTBUO5SK.mjs";
|
15
15
|
import {
|
16
16
|
AutocompleteClearIcon,
|
17
17
|
AutocompleteIcon
|
18
|
-
} from "./chunk-
|
18
|
+
} from "./chunk-I5X4WSCX.mjs";
|
19
19
|
import {
|
20
20
|
AutocompleteDescendantsContextProvider,
|
21
21
|
AutocompleteProvider,
|
22
22
|
useAutocompleteContext
|
23
|
-
} from "./chunk-
|
23
|
+
} from "./chunk-WDQYM4FP.mjs";
|
24
24
|
|
25
25
|
// src/multi-autocomplete.tsx
|
26
26
|
import {
|
27
|
-
ui,
|
28
27
|
forwardRef,
|
29
|
-
|
30
|
-
|
28
|
+
omitThemeProps,
|
29
|
+
ui,
|
30
|
+
useComponentMultiStyle
|
31
31
|
} from "@yamada-ui/core";
|
32
32
|
import { Popover, PopoverTrigger } from "@yamada-ui/popover";
|
33
33
|
import { Portal } from "@yamada-ui/portal";
|
@@ -42,58 +42,58 @@ var MultiAutocomplete = forwardRef(
|
|
42
42
|
);
|
43
43
|
let {
|
44
44
|
className,
|
45
|
-
|
46
|
-
|
47
|
-
separator,
|
48
|
-
isClearable = true,
|
45
|
+
children,
|
46
|
+
closeOnSelect = false,
|
49
47
|
color,
|
48
|
+
component,
|
49
|
+
defaultValue = [],
|
50
|
+
footer,
|
50
51
|
h,
|
52
|
+
header,
|
51
53
|
height,
|
54
|
+
isClearable = true,
|
55
|
+
keepPlaceholder = false,
|
52
56
|
minH,
|
53
57
|
minHeight,
|
54
|
-
|
55
|
-
|
58
|
+
separator,
|
59
|
+
clearIconProps,
|
56
60
|
containerProps,
|
57
61
|
contentProps,
|
58
|
-
|
62
|
+
createProps,
|
63
|
+
emptyProps,
|
59
64
|
fieldProps,
|
60
|
-
inputProps,
|
61
65
|
iconProps,
|
62
|
-
|
66
|
+
inputProps,
|
67
|
+
listProps,
|
63
68
|
portalProps = { isDisabled: true },
|
64
|
-
createProps,
|
65
|
-
emptyProps,
|
66
|
-
header,
|
67
|
-
footer,
|
68
|
-
children,
|
69
69
|
...computedProps
|
70
70
|
} = omitThemeProps(mergedProps);
|
71
71
|
const {
|
72
|
-
|
73
|
-
|
72
|
+
allowCreate,
|
73
|
+
computedChildren,
|
74
74
|
descendants,
|
75
|
+
inputValue,
|
76
|
+
isEmpty,
|
77
|
+
value,
|
75
78
|
formControlProps,
|
76
|
-
getPopoverProps,
|
77
79
|
getContainerProps,
|
78
80
|
getFieldProps,
|
79
|
-
|
80
|
-
isEmpty,
|
81
|
-
inputValue,
|
82
|
-
computedChildren,
|
81
|
+
getPopoverProps,
|
83
82
|
onClear,
|
83
|
+
onClose,
|
84
84
|
...rest
|
85
85
|
} = useAutocomplete({
|
86
86
|
...computedProps,
|
87
|
-
|
87
|
+
children,
|
88
88
|
closeOnSelect,
|
89
|
-
|
89
|
+
defaultValue
|
90
90
|
});
|
91
91
|
h != null ? h : h = height;
|
92
92
|
minH != null ? minH : minH = minHeight;
|
93
93
|
const css = {
|
94
|
-
w: "100%",
|
95
|
-
h: "fit-content",
|
96
94
|
color,
|
95
|
+
h: "fit-content",
|
96
|
+
w: "100%",
|
97
97
|
...styles.container
|
98
98
|
};
|
99
99
|
return /* @__PURE__ */ jsx(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ jsx(
|
@@ -101,13 +101,13 @@ var MultiAutocomplete = forwardRef(
|
|
101
101
|
{
|
102
102
|
value: {
|
103
103
|
...rest,
|
104
|
-
value,
|
105
|
-
onClose,
|
106
|
-
formControlProps,
|
107
|
-
inputValue,
|
108
104
|
allowCreate,
|
105
|
+
inputValue,
|
109
106
|
isEmpty,
|
110
|
-
styles
|
107
|
+
styles,
|
108
|
+
value,
|
109
|
+
formControlProps,
|
110
|
+
onClose
|
111
111
|
},
|
112
112
|
children: /* @__PURE__ */ jsx(Popover, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs(
|
113
113
|
ui.div,
|
@@ -126,10 +126,10 @@ var MultiAutocomplete = forwardRef(
|
|
126
126
|
MultiAutocompleteField,
|
127
127
|
{
|
128
128
|
component,
|
129
|
-
separator,
|
130
|
-
keepPlaceholder,
|
131
129
|
h,
|
130
|
+
keepPlaceholder,
|
132
131
|
minH,
|
132
|
+
separator,
|
133
133
|
inputProps,
|
134
134
|
...getFieldProps(fieldProps, ref)
|
135
135
|
}
|
@@ -148,8 +148,8 @@ var MultiAutocomplete = forwardRef(
|
|
148
148
|
!isEmpty ? /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsxs(
|
149
149
|
AutocompleteList,
|
150
150
|
{
|
151
|
-
header: runIfFunc(header, { value, onClose }),
|
152
151
|
footer: runIfFunc(footer, { value, onClose }),
|
152
|
+
header: runIfFunc(header, { value, onClose }),
|
153
153
|
contentProps,
|
154
154
|
...listProps,
|
155
155
|
children: [
|
@@ -160,8 +160,8 @@ var MultiAutocomplete = forwardRef(
|
|
160
160
|
) }) : /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsx(
|
161
161
|
AutocompleteList,
|
162
162
|
{
|
163
|
-
header: runIfFunc(header, { value, onClose }),
|
164
163
|
footer: runIfFunc(footer, { value, onClose }),
|
164
|
+
header: runIfFunc(header, { value, onClose }),
|
165
165
|
contentProps,
|
166
166
|
...listProps,
|
167
167
|
children: allowCreate && inputValue ? /* @__PURE__ */ jsx(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ jsx(AutocompleteEmpty, { ...emptyProps })
|
@@ -180,34 +180,36 @@ var MultiAutocompleteField = forwardRef(
|
|
180
180
|
({
|
181
181
|
className,
|
182
182
|
component,
|
183
|
-
separator = ",",
|
184
|
-
keepPlaceholder,
|
185
183
|
h,
|
184
|
+
keepPlaceholder,
|
186
185
|
minH,
|
187
186
|
placeholder,
|
187
|
+
separator = ",",
|
188
188
|
inputProps,
|
189
189
|
...rest
|
190
190
|
}, ref) => {
|
191
|
-
const {
|
191
|
+
const { inputRef, inputValue, isOpen, label, styles, value, onChange } = useAutocompleteContext();
|
192
192
|
const { getInputProps } = useAutocompleteInput();
|
193
193
|
const cloneChildren = useMemo(() => {
|
194
194
|
if (!(label == null ? void 0 : label.length)) return null;
|
195
195
|
if (component) {
|
196
196
|
return label.map((label2, index) => {
|
197
|
+
if (!value[index]) return null;
|
197
198
|
const onRemove = (ev) => {
|
199
|
+
if (!value[index]) return;
|
198
200
|
ev.stopPropagation();
|
199
201
|
onChange(value[index]);
|
200
202
|
if (inputRef.current) inputRef.current.focus();
|
201
203
|
};
|
202
204
|
const el = component({
|
203
|
-
value: value[index],
|
204
|
-
label: label2,
|
205
205
|
index,
|
206
|
+
label: label2,
|
207
|
+
value: value[index],
|
206
208
|
onRemove
|
207
209
|
});
|
208
210
|
const style = {
|
209
|
-
marginBlockStart: "0.125rem",
|
210
211
|
marginBlockEnd: "0.125rem",
|
212
|
+
marginBlockStart: "0.125rem",
|
211
213
|
marginInlineEnd: "0.25rem"
|
212
214
|
};
|
213
215
|
return el ? cloneElement(el, { key: index, style }) : null;
|
@@ -223,12 +225,12 @@ var MultiAutocompleteField = forwardRef(
|
|
223
225
|
}
|
224
226
|
}, [label, component, value, onChange, isOpen, inputRef, separator]);
|
225
227
|
const css = {
|
226
|
-
|
227
|
-
h,
|
228
|
-
minH,
|
228
|
+
alignItems: "center",
|
229
229
|
display: "flex",
|
230
230
|
flexWrap: "wrap",
|
231
|
-
|
231
|
+
h,
|
232
|
+
minH,
|
233
|
+
pe: "2rem",
|
232
234
|
...styles.field,
|
233
235
|
cursor: "text"
|
234
236
|
};
|
@@ -236,25 +238,25 @@ var MultiAutocompleteField = forwardRef(
|
|
236
238
|
ui.div,
|
237
239
|
{
|
238
240
|
className: cx("ui-multi-autocomplete__field", className),
|
239
|
-
__css: css,
|
240
241
|
py: (label == null ? void 0 : label.length) && component ? "0.125rem" : void 0,
|
242
|
+
__css: css,
|
241
243
|
...rest,
|
242
244
|
children: [
|
243
245
|
cloneChildren,
|
244
246
|
/* @__PURE__ */ jsx(
|
245
247
|
ui.input,
|
246
248
|
{
|
247
|
-
"aria-label": "Input value",
|
248
249
|
className: "ui-multi-autocomplete__field__input",
|
249
250
|
display: "inline-block",
|
250
251
|
flex: "1",
|
252
|
+
marginBlockEnd: "0.125rem",
|
253
|
+
marginBlockStart: "0.125rem",
|
251
254
|
minW: "0px",
|
252
255
|
overflow: "hidden",
|
253
|
-
|
254
|
-
|
256
|
+
placeholder: !(label == null ? void 0 : label.length) || keepPlaceholder && isOpen ? placeholder : void 0,
|
257
|
+
"aria-label": "Input value",
|
255
258
|
"aria-multiselectable": "true",
|
256
|
-
|
257
|
-
...getInputProps({ ...inputProps, value: inputValue != null ? inputValue : "" }, ref)
|
259
|
+
...getInputProps({ ...inputProps, value: inputValue }, ref)
|
258
260
|
}
|
259
261
|
)
|
260
262
|
]
|
@@ -268,4 +270,4 @@ MultiAutocompleteField.__ui__ = "MultiAutocompleteField";
|
|
268
270
|
export {
|
269
271
|
MultiAutocomplete
|
270
272
|
};
|
271
|
-
//# sourceMappingURL=chunk-
|
273
|
+
//# sourceMappingURL=chunk-TJGVRIGK.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/multi-autocomplete.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport type { PortalProps } from \"@yamada-ui/portal\"\nimport type {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactElement,\n ReactNode,\n} from \"react\"\nimport type { AutocompleteCreateProps } from \"./autocomplete-create\"\nimport type { AutocompleteEmptyProps } from \"./autocomplete-empty\"\nimport type { AutocompleteIconProps } from \"./autocomplete-icon\"\nimport type { AutocompleteListProps } from \"./autocomplete-list\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { Popover, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { Portal } from \"@yamada-ui/portal\"\nimport { cx, handlerAll, runIfFunc } from \"@yamada-ui/utils\"\nimport { cloneElement, useMemo } from \"react\"\nimport {\n AutocompleteDescendantsContextProvider,\n AutocompleteProvider,\n useAutocompleteContext,\n} from \"./autocomplete-context\"\nimport { AutocompleteCreate } from \"./autocomplete-create\"\nimport { AutocompleteEmpty } from \"./autocomplete-empty\"\nimport { AutocompleteClearIcon, AutocompleteIcon } from \"./autocomplete-icon\"\nimport { AutocompleteList } from \"./autocomplete-list\"\nimport { useAutocomplete, useAutocompleteInput } from \"./use-autocomplete\"\n\ninterface MultiAutocompleteOptions {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default false\n */\n closeOnSelect?: boolean\n /**\n * The custom display value to use.\n */\n component?: FC<{\n index: number\n label: string\n value: number | string\n onRemove: MouseEventHandler<HTMLElement>\n }>\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: string\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: string\n /**\n * The footer of the autocomplete content element.\n */\n footer?: FC<{ value: string[] | undefined; onClose: () => void }> | ReactNode\n /**\n * The header of the autocomplete content element.\n */\n header?: FC<{ value: string[] | undefined; onClose: () => void }> | ReactNode\n /**\n * If `true`, display the select clear icon.\n *\n * @default true\n */\n isClearable?: boolean\n /**\n * If `true`, keep the placeholder.\n *\n * @default false\n */\n keepPlaceholder?: boolean\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * Props for multi autocomplete clear icon element.\n */\n clearIconProps?: AutocompleteIconProps\n /**\n * Props for multi autocomplete container element.\n */\n containerProps?: Omit<HTMLUIProps, \"children\">\n /**\n * Props for multi autocomplete content element.\n */\n contentProps?: Omit<MotionProps, \"children\">\n /**\n * Props for autocomplete create element.\n */\n createProps?: Omit<AutocompleteCreateProps, \"children\">\n /**\n * Props for autocomplete empty element.\n */\n emptyProps?: Omit<AutocompleteEmptyProps, \"children\">\n /**\n * Props for multi autocomplete field element.\n */\n fieldProps?: Omit<\n MultiAutocompleteFieldProps,\n \"children\" | \"component\" | \"inputProps\" | \"keepPlaceholder\" | \"separator\"\n >\n /**\n * Props for multi autocomplete icon element.\n */\n iconProps?: AutocompleteIconProps\n /**\n * Props for multi autocomplete input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for multi autocomplete list element.\n */\n listProps?: Omit<AutocompleteListProps, \"children\">\n /**\n * Props to be forwarded to the portal component.\n *\n * @default '{ isDisabled: true }'\n *\n */\n portalProps?: Omit<PortalProps, \"children\">\n}\n\nexport interface MultiAutocompleteProps\n extends ThemeProps<\"MultiAutocomplete\">,\n Omit<UseAutocompleteProps<string[]>, \"closeOnSelect\">,\n MultiAutocompleteOptions {}\n\n/**\n * `MultiAutocomplete` is a component used to display suggestions based on user text input and to obtain multiple values.\n *\n * @see Docs https://yamada-ui.com/components/forms/multi-autocomplete\n */\nexport const MultiAutocomplete = forwardRef<MultiAutocompleteProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\n \"MultiAutocomplete\",\n props,\n )\n let {\n className,\n children,\n closeOnSelect = false,\n color,\n component,\n defaultValue = [],\n footer,\n h,\n header,\n height,\n isClearable = true,\n keepPlaceholder = false,\n minH,\n minHeight,\n separator,\n clearIconProps,\n containerProps,\n contentProps,\n createProps,\n emptyProps,\n fieldProps,\n iconProps,\n inputProps,\n listProps,\n portalProps = { isDisabled: true },\n ...computedProps\n } = omitThemeProps(mergedProps)\n\n const {\n allowCreate,\n computedChildren,\n descendants,\n inputValue,\n isEmpty,\n value,\n formControlProps,\n getContainerProps,\n getFieldProps,\n getPopoverProps,\n onClear,\n onClose,\n ...rest\n } = useAutocomplete<string[]>({\n ...computedProps,\n children,\n closeOnSelect,\n defaultValue,\n })\n\n h ??= height\n minH ??= minHeight\n\n const css: CSSUIObject = {\n color,\n h: \"fit-content\",\n w: \"100%\",\n ...styles.container,\n }\n\n return (\n <AutocompleteDescendantsContextProvider value={descendants}>\n <AutocompleteProvider\n value={{\n ...rest,\n allowCreate,\n inputValue,\n isEmpty,\n styles,\n value,\n formControlProps,\n onClose,\n }}\n >\n <Popover {...getPopoverProps()}>\n <ui.div\n className={cx(\"ui-multi-autocomplete\", className)}\n __css={css}\n {...getContainerProps(containerProps)}\n >\n <ui.div\n className=\"ui-multi-autocomplete__inner\"\n __css={{ position: \"relative\", ...styles.inner }}\n >\n <MultiAutocompleteField\n component={component}\n h={h}\n keepPlaceholder={keepPlaceholder}\n minH={minH}\n separator={separator}\n inputProps={inputProps}\n {...getFieldProps(fieldProps, ref)}\n />\n\n {isClearable && value.length ? (\n <AutocompleteClearIcon\n {...clearIconProps}\n onClick={handlerAll(clearIconProps?.onClick, onClear)}\n {...formControlProps}\n />\n ) : (\n <AutocompleteIcon {...iconProps} {...formControlProps} />\n )}\n </ui.div>\n\n {!isEmpty ? (\n <Portal {...portalProps}>\n <AutocompleteList\n footer={runIfFunc(footer, { value, onClose })}\n header={runIfFunc(header, { value, onClose })}\n contentProps={contentProps}\n {...listProps}\n >\n {allowCreate ? (\n <AutocompleteCreate {...createProps} />\n ) : (\n <AutocompleteEmpty {...emptyProps} />\n )}\n\n {children ?? computedChildren}\n </AutocompleteList>\n </Portal>\n ) : (\n <Portal {...portalProps}>\n <AutocompleteList\n footer={runIfFunc(footer, { value, onClose })}\n header={runIfFunc(header, { value, onClose })}\n contentProps={contentProps}\n {...listProps}\n >\n {allowCreate && inputValue ? (\n <AutocompleteCreate {...createProps} />\n ) : (\n <AutocompleteEmpty {...emptyProps} />\n )}\n </AutocompleteList>\n </Portal>\n )}\n </ui.div>\n </Popover>\n </AutocompleteProvider>\n </AutocompleteDescendantsContextProvider>\n )\n },\n)\n\nMultiAutocomplete.displayName = \"MultiAutocomplete\"\nMultiAutocomplete.__ui__ = \"MultiAutocomplete\"\n\ninterface MultiAutocompleteFieldProps\n extends HTMLUIProps,\n Pick<\n MultiAutocompleteProps,\n \"component\" | \"inputProps\" | \"keepPlaceholder\" | \"separator\"\n > {}\n\nconst MultiAutocompleteField = forwardRef<MultiAutocompleteFieldProps, \"input\">(\n (\n {\n className,\n component,\n h,\n keepPlaceholder,\n minH,\n placeholder,\n separator = \",\",\n inputProps,\n ...rest\n },\n ref,\n ) => {\n const { inputRef, inputValue, isOpen, label, styles, value, onChange } =\n useAutocompleteContext()\n\n const { getInputProps } = useAutocompleteInput()\n\n const cloneChildren = useMemo(() => {\n if (!label?.length) return null\n\n if (component) {\n return (label as string[]).map((label, index) => {\n if (!value[index]) return null\n\n const onRemove: MouseEventHandler<HTMLElement> = (ev) => {\n if (!value[index]) return\n\n ev.stopPropagation()\n\n onChange(value[index])\n\n if (inputRef.current) inputRef.current.focus()\n }\n\n const el = component({\n index,\n label,\n value: value[index],\n onRemove,\n })\n\n const style: CSSProperties = {\n marginBlockEnd: \"0.125rem\",\n marginBlockStart: \"0.125rem\",\n marginInlineEnd: \"0.25rem\",\n }\n\n return el\n ? cloneElement(el as ReactElement, { key: index, style })\n : null\n })\n } else {\n return (label as string[]).map((value, index) => {\n const isLast = label.length === index + 1\n\n return (\n <ui.span key={index} display=\"inline-block\" me=\"0.25rem\">\n {value}\n {!isLast || isOpen ? separator : null}\n </ui.span>\n )\n })\n }\n }, [label, component, value, onChange, isOpen, inputRef, separator])\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n flexWrap: \"wrap\",\n h,\n minH,\n pe: \"2rem\",\n ...styles.field,\n cursor: \"text\",\n }\n\n return (\n <PopoverTrigger>\n <ui.div\n className={cx(\"ui-multi-autocomplete__field\", className)}\n py={label?.length && component ? \"0.125rem\" : undefined}\n __css={css}\n {...rest}\n >\n {cloneChildren}\n\n <ui.input\n className=\"ui-multi-autocomplete__field__input\"\n display=\"inline-block\"\n flex=\"1\"\n marginBlockEnd=\"0.125rem\"\n marginBlockStart=\"0.125rem\"\n minW=\"0px\"\n overflow=\"hidden\"\n placeholder={\n !label?.length || (keepPlaceholder && isOpen)\n ? placeholder\n : undefined\n }\n aria-label=\"Input value\"\n aria-multiselectable=\"true\"\n {...getInputProps({ ...inputProps, value: inputValue }, ref)}\n />\n </ui.div>\n </PopoverTrigger>\n )\n },\n)\n\nMultiAutocompleteField.displayName = \"MultiAutocompleteField\"\nMultiAutocompleteField.__ui__ = \"MultiAutocompleteField\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,sBAAsB;AACxC,SAAS,cAAc;AACvB,SAAS,IAAI,YAAY,iBAAiB;AAC1C,SAAS,cAAc,eAAe;AA8MxB,SAIE,KAJF;AAtFP,IAAM,oBAAoB;AAAA,EAC/B,CAAC,OAAO,QAAQ;AACd,UAAM,CAAC,QAAQ,WAAW,IAAI;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AACA,QAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA,eAAe,CAAC;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,EAAE,YAAY,KAAK;AAAA,MACjC,GAAG;AAAA,IACL,IAAI,eAAe,WAAW;AAE9B,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GA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,cACA;AAAA,cAEN,cAAW;AAAA,cACX,wBAAqB;AAAA,cACpB,GAAG,cAAc,EAAE,GAAG,YAAY,OAAO,WAAW,GAAG,GAAG;AAAA;AAAA,UAC7D;AAAA;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;AAEA,uBAAuB,cAAc;AACrC,uBAAuB,SAAS;","names":["label","value"]}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import {
|
3
3
|
useAutocompleteContext,
|
4
4
|
useAutocompleteDescendantsContext
|
5
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-WDQYM4FP.mjs";
|
6
6
|
|
7
7
|
// src/use-autocomplete-list.ts
|
8
8
|
import { mergeRefs, useUpdateEffect } from "@yamada-ui/utils";
|
@@ -49,24 +49,24 @@ var useAutocompleteList = () => {
|
|
49
49
|
(props = {}, ref = null) => {
|
50
50
|
var _a;
|
51
51
|
return {
|
52
|
-
|
52
|
+
id: (_a = props.id) != null ? _a : uuid,
|
53
53
|
ref: mergeRefs(listRef, ref),
|
54
|
+
as: "ul",
|
55
|
+
position: "relative",
|
54
56
|
role: "listbox",
|
55
57
|
tabIndex: -1,
|
56
|
-
position: "relative",
|
57
|
-
id: (_a = props.id) != null ? _a : uuid,
|
58
58
|
...props
|
59
59
|
};
|
60
60
|
},
|
61
61
|
[listRef, uuid]
|
62
62
|
);
|
63
63
|
return {
|
64
|
-
|
65
|
-
|
64
|
+
getListProps,
|
65
|
+
onAnimationComplete
|
66
66
|
};
|
67
67
|
};
|
68
68
|
|
69
69
|
export {
|
70
70
|
useAutocompleteList
|
71
71
|
};
|
72
|
-
//# sourceMappingURL=chunk-
|
72
|
+
//# sourceMappingURL=chunk-TR4X4EEG.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-autocomplete-list.ts"],"sourcesContent":["import type { PropGetter } from \"@yamada-ui/core\"\nimport { mergeRefs, useUpdateEffect } from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendantsContext,\n} from \"./autocomplete-context\"\n\nexport const useAutocompleteList = () => {\n const uuid = useId()\n const { focusedIndex, isOpen, listRef, rebirthOptions } =\n useAutocompleteContext()\n\n const descendants = useAutocompleteDescendantsContext()\n\n const beforeFocusedIndex = useRef<number>(-1)\n const selectedValue = descendants.value(focusedIndex)\n\n const onAnimationComplete = useCallback(() => {\n if (!isOpen) rebirthOptions(false)\n }, [isOpen, rebirthOptions])\n\n useEffect(() => {\n if (!listRef.current || !selectedValue) return\n\n if (beforeFocusedIndex.current === selectedValue.index) return\n\n const parent = listRef.current\n const child = selectedValue.node\n\n const parentHeight = parent.clientHeight\n const viewTop = parent.scrollTop\n const viewBottom = viewTop + parentHeight\n\n const childHeight = child.clientHeight\n const childTop = child.offsetTop\n const childBottom = childTop + childHeight\n\n const isInView = viewTop <= childTop && childBottom <= viewBottom\n\n const isScrollBottom = beforeFocusedIndex.current < selectedValue.index\n\n if (!isInView) {\n if (childBottom <= parentHeight) {\n listRef.current.scrollTo({ top: 0 })\n } else {\n if (!isScrollBottom) {\n listRef.current.scrollTo({ top: childTop + 1 })\n } else {\n listRef.current.scrollTo({ top: childBottom - parentHeight })\n }\n }\n }\n\n beforeFocusedIndex.current = selectedValue.index\n }, [listRef, selectedValue])\n\n useUpdateEffect(() => {\n if (!isOpen) beforeFocusedIndex.current = -1\n }, [isOpen])\n\n const getListProps: PropGetter<\"ul\"> = useCallback(\n (props = {}, ref = null) => ({\n
|
1
|
+
{"version":3,"sources":["../src/use-autocomplete-list.ts"],"sourcesContent":["import type { PropGetter } from \"@yamada-ui/core\"\nimport { mergeRefs, useUpdateEffect } from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport {\n useAutocompleteContext,\n useAutocompleteDescendantsContext,\n} from \"./autocomplete-context\"\n\nexport const useAutocompleteList = () => {\n const uuid = useId()\n const { focusedIndex, isOpen, listRef, rebirthOptions } =\n useAutocompleteContext()\n\n const descendants = useAutocompleteDescendantsContext()\n\n const beforeFocusedIndex = useRef<number>(-1)\n const selectedValue = descendants.value(focusedIndex)\n\n const onAnimationComplete = useCallback(() => {\n if (!isOpen) rebirthOptions(false)\n }, [isOpen, rebirthOptions])\n\n useEffect(() => {\n if (!listRef.current || !selectedValue) return\n\n if (beforeFocusedIndex.current === selectedValue.index) return\n\n const parent = listRef.current\n const child = selectedValue.node\n\n const parentHeight = parent.clientHeight\n const viewTop = parent.scrollTop\n const viewBottom = viewTop + parentHeight\n\n const childHeight = child.clientHeight\n const childTop = child.offsetTop\n const childBottom = childTop + childHeight\n\n const isInView = viewTop <= childTop && childBottom <= viewBottom\n\n const isScrollBottom = beforeFocusedIndex.current < selectedValue.index\n\n if (!isInView) {\n if (childBottom <= parentHeight) {\n listRef.current.scrollTo({ top: 0 })\n } else {\n if (!isScrollBottom) {\n listRef.current.scrollTo({ top: childTop + 1 })\n } else {\n listRef.current.scrollTo({ top: childBottom - parentHeight })\n }\n }\n }\n\n beforeFocusedIndex.current = selectedValue.index\n }, [listRef, selectedValue])\n\n useUpdateEffect(() => {\n if (!isOpen) beforeFocusedIndex.current = -1\n }, [isOpen])\n\n const getListProps: PropGetter<\"ul\"> = useCallback(\n (props = {}, ref = null) => ({\n id: props.id ?? uuid,\n ref: mergeRefs(listRef, ref),\n as: \"ul\",\n position: \"relative\",\n role: \"listbox\",\n tabIndex: -1,\n ...props,\n }),\n [listRef, uuid],\n )\n\n return {\n getListProps,\n onAnimationComplete,\n }\n}\n"],"mappings":";;;;;;;AACA,SAAS,WAAW,uBAAuB;AAC3C,SAAS,aAAa,WAAW,OAAO,cAAc;AAM/C,IAAM,sBAAsB,MAAM;AACvC,QAAM,OAAO,MAAM;AACnB,QAAM,EAAE,cAAc,QAAQ,SAAS,eAAe,IACpD,uBAAuB;AAEzB,QAAM,cAAc,kCAAkC;AAEtD,QAAM,qBAAqB,OAAe,EAAE;AAC5C,QAAM,gBAAgB,YAAY,MAAM,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,MACL;AAAA;AAAA,IACA,CAAC,SAAS,IAAI;AAAA,EAChB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
@@ -1,34 +1,34 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useAutocompleteList
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-TR4X4EEG.mjs";
|
5
5
|
import {
|
6
6
|
useAutocompleteContext
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-WDQYM4FP.mjs";
|
8
8
|
|
9
9
|
// src/autocomplete-list.tsx
|
10
|
-
import {
|
10
|
+
import { forwardRef, ui } from "@yamada-ui/core";
|
11
11
|
import { PopoverContent } from "@yamada-ui/popover";
|
12
12
|
import { cx, handlerAll } from "@yamada-ui/utils";
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
14
14
|
var AutocompleteList = forwardRef(
|
15
15
|
({
|
16
16
|
className,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
minWidth,
|
17
|
+
children,
|
18
|
+
footer,
|
19
|
+
header,
|
21
20
|
maxW,
|
22
21
|
maxWidth,
|
22
|
+
minW,
|
23
|
+
minWidth,
|
24
|
+
w,
|
25
|
+
width,
|
23
26
|
contentProps,
|
24
|
-
header,
|
25
|
-
footer,
|
26
|
-
children,
|
27
27
|
...rest
|
28
28
|
}, ref) => {
|
29
29
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
30
30
|
const { styles } = useAutocompleteContext();
|
31
|
-
const {
|
31
|
+
const { getListProps, onAnimationComplete } = useAutocompleteList();
|
32
32
|
width != null ? width : width = w;
|
33
33
|
width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
|
34
34
|
minWidth != null ? minWidth : minWidth = minW;
|
@@ -40,10 +40,10 @@ var AutocompleteList = forwardRef(
|
|
40
40
|
{
|
41
41
|
as: "div",
|
42
42
|
className: "ui-autocomplete__popover",
|
43
|
-
width,
|
44
|
-
minWidth,
|
45
43
|
maxWidth,
|
46
|
-
|
44
|
+
minWidth,
|
45
|
+
width,
|
46
|
+
__css: { ...styles.content, maxWidth, minWidth, width },
|
47
47
|
...contentProps,
|
48
48
|
onAnimationComplete: handlerAll(
|
49
49
|
contentProps == null ? void 0 : contentProps.onAnimationComplete,
|
@@ -86,4 +86,4 @@ AutocompleteList.__ui__ = "AutocompleteList";
|
|
86
86
|
export {
|
87
87
|
AutocompleteList
|
88
88
|
};
|
89
|
-
//# sourceMappingURL=chunk-
|
89
|
+
//# sourceMappingURL=chunk-VTBUO5SK.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/autocomplete-list.tsx"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { MotionPropsWithoutChildren } from \"@yamada-ui/motion\"\nimport type { ReactNode } from \"react\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { PopoverContent } from \"@yamada-ui/popover\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\nimport { useAutocompleteList } from \"./use-autocomplete-list\"\n\nexport interface AutocompleteListProps extends HTMLUIProps<\"ul\"> {\n footer?: ReactNode\n header?: ReactNode\n contentProps?: MotionPropsWithoutChildren\n}\n\nexport const AutocompleteList = forwardRef<AutocompleteListProps, \"ul\">(\n (\n {\n className,\n children,\n footer,\n header,\n maxW,\n maxWidth,\n minW,\n minWidth,\n w,\n width,\n contentProps,\n ...rest\n },\n ref,\n ) => {\n const { styles } = useAutocompleteContext()\n const { getListProps, onAnimationComplete } = useAutocompleteList()\n\n width ??= w\n width ??= (styles.list?.width ?? styles.list?.w) as CSSUIProps[\"width\"]\n minWidth ??= minW\n minWidth ??= (styles.list?.minWidth ??\n styles.list?.minW) as CSSUIProps[\"minWidth\"]\n maxWidth ??= maxW\n maxWidth ??= (styles.list?.maxWidth ??\n styles.list?.maxW) as CSSUIProps[\"maxWidth\"]\n\n return (\n <PopoverContent\n as=\"div\"\n className=\"ui-autocomplete__popover\"\n maxWidth={maxWidth}\n minWidth={minWidth}\n width={width}\n __css={{ ...styles.content, maxWidth, minWidth, width }}\n {...contentProps}\n onAnimationComplete={handlerAll(\n contentProps?.onAnimationComplete,\n onAnimationComplete,\n )}\n >\n {header ? (\n <ui.div\n className=\"ui-autocomplete__header\"\n __css={{ ...styles.header }}\n >\n {header}\n </ui.div>\n ) : null}\n\n <ui.ul\n className={cx(\"ui-autocomplete__list\", className)}\n __css={{ ...styles.list }}\n {...getListProps(rest, ref)}\n >\n {children}\n </ui.ul>\n\n {footer ? (\n <ui.div\n className=\"ui-autocomplete__footer\"\n __css={{ ...styles.footer }}\n >\n {footer}\n </ui.div>\n ) : null}\n </PopoverContent>\n )\n },\n)\n\nAutocompleteList.displayName = \"AutocompleteList\"\nAutocompleteList.__ui__ = \"AutocompleteList\"\n"],"mappings":";;;;;;;;;AAGA,SAAS,YAAY,UAAU;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,IAAI,kBAAkB;AAyCzB,SAcI,KAdJ;AA/BC,IAAM,mBAAmB;AAAA,EAC9B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AAhCP;AAiCI,UAAM,EAAE,OAAO,IAAI,uBAAuB;AAC1C,UAAM,EAAE,cAAc,oBAAoB,IAAI,oBAAoB;AAElE,oCAAU;AACV,qCAAW,kBAAO,SAAP,mBAAa,UAAb,aAAsB,YAAO,SAAP,mBAAa;AAC9C,6CAAa;AACb,8CAAc,kBAAO,SAAP,mBAAa,aAAb,aACZ,YAAO,SAAP,mBAAa;AACf,6CAAa;AACb,8CAAc,kBAAO,SAAP,mBAAa,aAAb,aACZ,YAAO,SAAP,mBAAa;AAEf,WACE;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,WAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,EAAE,GAAG,OAAO,SAAS,UAAU,UAAU,MAAM;AAAA,QACrD,GAAG;AAAA,QACJ,qBAAqB;AAAA,UACnB,6CAAc;AAAA,UACd;AAAA,QACF;AAAA,QAEC;AAAA,mBACC;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,OAAO,OAAO;AAAA,cAEzB;AAAA;AAAA,UACH,IACE;AAAA,UAEJ;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAW,GAAG,yBAAyB,SAAS;AAAA,cAChD,OAAO,EAAE,GAAG,OAAO,KAAK;AAAA,cACvB,GAAG,aAAa,MAAM,GAAG;AAAA,cAEzB;AAAA;AAAA,UACH;AAAA,UAEC,SACC;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,OAAO,OAAO;AAAA,cAEzB;AAAA;AAAA,UACH,IACE;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,iBAAiB,cAAc;AAC/B,iBAAiB,SAAS;","names":[]}
|
@@ -5,9 +5,9 @@ import { createDescendant } from "@yamada-ui/use-descendant";
|
|
5
5
|
import { createContext } from "@yamada-ui/utils";
|
6
6
|
var {
|
7
7
|
DescendantsContextProvider: AutocompleteDescendantsContextProvider,
|
8
|
-
|
8
|
+
useDescendant: useAutocompleteDescendant,
|
9
9
|
useDescendants: useAutocompleteDescendants,
|
10
|
-
|
10
|
+
useDescendantsContext: useAutocompleteDescendantsContext
|
11
11
|
} = createDescendant();
|
12
12
|
var [AutocompleteProvider, useAutocompleteContext] = createContext({
|
13
13
|
name: "AutocompleteContext",
|
@@ -16,10 +16,10 @@ var [AutocompleteProvider, useAutocompleteContext] = createContext({
|
|
16
16
|
|
17
17
|
export {
|
18
18
|
AutocompleteDescendantsContextProvider,
|
19
|
-
useAutocompleteDescendantsContext,
|
20
|
-
useAutocompleteDescendants,
|
21
19
|
useAutocompleteDescendant,
|
20
|
+
useAutocompleteDescendants,
|
21
|
+
useAutocompleteDescendantsContext,
|
22
22
|
AutocompleteProvider,
|
23
23
|
useAutocompleteContext
|
24
24
|
};
|
25
|
-
//# sourceMappingURL=chunk-
|
25
|
+
//# sourceMappingURL=chunk-WDQYM4FP.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/autocomplete-context.ts"],"sourcesContent":["import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { Dispatch, DOMAttributes, RefObject, SetStateAction } from \"react\"\nimport type { ChangeOptions, UseAutocompleteProps } from \"./use-autocomplete\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider: AutocompleteDescendantsContextProvider,\n useDescendant: useAutocompleteDescendant,\n useDescendants: useAutocompleteDescendants,\n useDescendantsContext: useAutocompleteDescendantsContext,\n} = createDescendant()\n\ninterface AutocompleteContext\n extends Omit<\n UseAutocompleteProps,\n \"defaultValue\" | \"onChange\" | \"onCreate\" | \"value\"\n > {\n focusedIndex: number\n inputRef: RefObject<HTMLInputElement>\n inputValue: string\n isAllSelected: boolean\n isEmpty: boolean\n isHit: boolean\n isOpen: boolean\n label: string | string[] | undefined\n listRef: RefObject<HTMLUListElement>\n pickOptions: (value: string) => void\n rebirthOptions: (runFocus?: boolean) => void\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n value: string | string[]\n formControlProps: { [key: string]: any }\n inputProps: DOMAttributes<HTMLInputElement>\n onChange: (newValue: string, options?: ChangeOptions) => void\n onChangeLabel: (newValue: string, options?: ChangeOptions) => void\n onClose: () => void\n onCreate: () => void\n onFocusFirst: () => void\n onFocusLast: () => void\n onFocusNext: (index?: number) => void\n onFocusPrev: (index?: number) => void\n onOpen: () => void\n}\n\nexport const [AutocompleteProvider, useAutocompleteContext] =\n createContext<AutocompleteContext>({\n name: \"AutocompleteContext\",\n errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Autocomplete />\" or \"<MultiAutocomplete />\"`,\n })\n"],"mappings":";;;AAGA,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAEvB,IAAM;AAAA,EACX,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,uBAAuB;AACzB,IAAI,iBAAiB;AAkCd,IAAM,CAAC,sBAAsB,sBAAsB,IACxD,cAAmC;AAAA,EACjC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;","names":[]}
|
@@ -1,34 +1,34 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
useAutocompleteOption
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-ZJFWWXQM.mjs";
|
5
5
|
import {
|
6
6
|
AutocompleteItemIcon
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-I5X4WSCX.mjs";
|
8
8
|
import {
|
9
9
|
useAutocompleteContext
|
10
|
-
} from "./chunk-
|
10
|
+
} from "./chunk-WDQYM4FP.mjs";
|
11
11
|
|
12
12
|
// src/autocomplete-option.tsx
|
13
|
-
import {
|
13
|
+
import { forwardRef, ui } from "@yamada-ui/core";
|
14
14
|
import { cx } from "@yamada-ui/utils";
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
16
16
|
var AutocompleteOption = forwardRef(
|
17
17
|
({ className, icon, ...rest }, ref) => {
|
18
18
|
const { styles } = useAutocompleteContext();
|
19
|
-
const {
|
19
|
+
const { children, customIcon, isSelected, getOptionProps } = useAutocompleteOption(rest);
|
20
20
|
icon != null ? icon : icon = customIcon;
|
21
21
|
const css = {
|
22
|
-
|
22
|
+
alignItems: "center",
|
23
23
|
color: "inherit",
|
24
|
-
userSelect: "none",
|
25
24
|
display: "flex",
|
26
|
-
width: "100%",
|
27
|
-
alignItems: "center",
|
28
|
-
textAlign: "start",
|
29
25
|
flex: "0 0 auto",
|
30
|
-
outline: 0,
|
31
26
|
gap: "0.75rem",
|
27
|
+
outline: 0,
|
28
|
+
textAlign: "start",
|
29
|
+
textDecoration: "none",
|
30
|
+
userSelect: "none",
|
31
|
+
width: "100%",
|
32
32
|
...styles.item
|
33
33
|
};
|
34
34
|
return /* @__PURE__ */ jsxs(
|
@@ -47,7 +47,7 @@ var AutocompleteOption = forwardRef(
|
|
47
47
|
);
|
48
48
|
AutocompleteOption.displayName = "AutocompleteOption";
|
49
49
|
AutocompleteOption.__ui__ = "AutocompleteOption";
|
50
|
-
var AutocompleteCheckIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 14 14", width: "1em",
|
50
|
+
var AutocompleteCheckIcon = () => /* @__PURE__ */ jsx("svg", { height: "1em", viewBox: "0 0 14 14", width: "1em", children: /* @__PURE__ */ jsx(
|
51
51
|
"polygon",
|
52
52
|
{
|
53
53
|
fill: "currentColor",
|
@@ -60,4 +60,4 @@ AutocompleteCheckIcon.__ui__ = "AutocompleteCheckIcon";
|
|
60
60
|
export {
|
61
61
|
AutocompleteOption
|
62
62
|
};
|
63
|
-
//# sourceMappingURL=chunk-
|
63
|
+
//# sourceMappingURL=chunk-ZEGANG5C.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/autocomplete-option.tsx"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { ReactElement } from \"react\"\nimport type { UseAutocompleteOptionProps } from \"./use-autocomplete-option\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\nimport { AutocompleteItemIcon } from \"./autocomplete-icon\"\nimport { useAutocompleteOption } from \"./use-autocomplete-option\"\n\ninterface AutocompleteOptionOptions {\n /**\n * The autocomplete option icon to use.\n */\n icon?: null | ReactElement\n}\n\nexport interface AutocompleteOptionProps\n extends UseAutocompleteOptionProps,\n AutocompleteOptionOptions {}\n\nexport const AutocompleteOption = forwardRef<AutocompleteOptionProps, \"li\">(\n ({ className, icon, ...rest }, ref) => {\n const { styles } = useAutocompleteContext()\n const { children, customIcon, isSelected, getOptionProps } =\n useAutocompleteOption(rest)\n\n icon ??= customIcon\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n color: \"inherit\",\n display: \"flex\",\n flex: \"0 0 auto\",\n gap: \"0.75rem\",\n outline: 0,\n textAlign: \"start\",\n textDecoration: \"none\",\n userSelect: \"none\",\n width: \"100%\",\n ...styles.item,\n }\n\n return (\n <ui.li\n className={cx(\"ui-autocomplete__item\", className)}\n __css={css}\n {...getOptionProps({}, ref)}\n >\n {icon !== null ? (\n <AutocompleteItemIcon opacity={isSelected ? 1 : 0}>\n {icon || <AutocompleteCheckIcon />}\n </AutocompleteItemIcon>\n ) : null}\n\n <ui.span style={{ flex: 1 }} data-label>\n {children}\n </ui.span>\n </ui.li>\n )\n },\n)\n\nAutocompleteOption.displayName = \"AutocompleteOption\"\nAutocompleteOption.__ui__ = \"AutocompleteOption\"\n\nconst AutocompleteCheckIcon: FC = () => (\n <svg height=\"1em\" viewBox=\"0 0 14 14\" width=\"1em\">\n <polygon\n fill=\"currentColor\"\n points=\"5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039\"\n />\n </svg>\n)\n\nAutocompleteCheckIcon.displayName = \"AutocompleteCheckIcon\"\nAutocompleteCheckIcon.__ui__ = \"AutocompleteCheckIcon\"\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,YAAY,UAAU;AAC/B,SAAS,UAAU;AAuCb,SAOe,KAPf;AAvBC,IAAM,qBAAqB;AAAA,EAChC,CAAC,EAAE,WAAW,MAAM,GAAG,KAAK,GAAG,QAAQ;AACrC,UAAM,EAAE,OAAO,IAAI,uBAAuB;AAC1C,UAAM,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