@yamada-ui/autocomplete 1.6.9-dev-20241213204523 → 1.6.9-dev-20241213213653
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-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +2 -2
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +2 -2
- package/dist/autocomplete-option.js +44 -43
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +2 -2
- package/dist/autocomplete.js +44 -43
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +6 -6
- package/dist/{chunk-PWV7X7G6.mjs → chunk-3FXEJSLI.mjs} +4 -4
- package/dist/chunk-3FXEJSLI.mjs.map +1 -0
- package/dist/{chunk-IFH3PPSD.mjs → chunk-3KSLP2QT.mjs} +4 -4
- package/dist/{chunk-YPKDYYEV.mjs → chunk-KG6IO6XB.mjs} +2 -2
- package/dist/{chunk-RK5E5J5E.mjs → chunk-M5EWJFSX.mjs} +2 -2
- package/dist/{chunk-2LP57WVB.mjs → chunk-NPRQXPV7.mjs} +44 -43
- package/dist/chunk-NPRQXPV7.mjs.map +1 -0
- package/dist/{chunk-ZR77IT3O.mjs → chunk-Y5WDMYXH.mjs} +2 -2
- package/dist/{chunk-2CVB4NO5.mjs → chunk-Y7WZLESA.mjs} +4 -4
- package/dist/index.js +44 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/multi-autocomplete.js +44 -43
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +6 -6
- package/dist/use-autocomplete-option.d.mts +3 -3
- package/dist/use-autocomplete-option.d.ts +3 -3
- package/dist/use-autocomplete-option.js +42 -41
- package/dist/use-autocomplete-option.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +1 -1
- package/dist/use-autocomplete.js +44 -43
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +3 -3
- package/package.json +13 -13
- package/dist/chunk-2LP57WVB.mjs.map +0 -1
- package/dist/chunk-PWV7X7G6.mjs.map +0 -1
- /package/dist/{chunk-IFH3PPSD.mjs.map → chunk-3KSLP2QT.mjs.map} +0 -0
- /package/dist/{chunk-YPKDYYEV.mjs.map → chunk-KG6IO6XB.mjs.map} +0 -0
- /package/dist/{chunk-RK5E5J5E.mjs.map → chunk-M5EWJFSX.mjs.map} +0 -0
- /package/dist/{chunk-ZR77IT3O.mjs.map → chunk-Y5WDMYXH.mjs.map} +0 -0
- /package/dist/{chunk-2CVB4NO5.mjs.map → chunk-Y7WZLESA.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import {
|
|
3
3
|
MultiAutocomplete
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3KSLP2QT.mjs";
|
|
5
5
|
import {
|
|
6
6
|
Autocomplete
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-Y7WZLESA.mjs";
|
|
8
|
+
import "./chunk-Y5WDMYXH.mjs";
|
|
9
9
|
import {
|
|
10
10
|
AutocompleteCreate
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-M5EWJFSX.mjs";
|
|
12
12
|
import {
|
|
13
13
|
AutocompleteEmpty
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KG6IO6XB.mjs";
|
|
15
15
|
import "./chunk-LIBFONYN.mjs";
|
|
16
16
|
import "./chunk-4GVV3HBE.mjs";
|
|
17
17
|
import {
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
import "./chunk-UX5QECNB.mjs";
|
|
21
21
|
import {
|
|
22
22
|
AutocompleteOption
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-3FXEJSLI.mjs";
|
|
24
|
+
import "./chunk-NPRQXPV7.mjs";
|
|
25
25
|
import "./chunk-7QCZ5NGS.mjs";
|
|
26
26
|
import "./chunk-TP5VZFO3.mjs";
|
|
27
27
|
export {
|
|
@@ -160,7 +160,7 @@ var useAutocompleteOption = (props) => {
|
|
|
160
160
|
inputRef,
|
|
161
161
|
omitSelectedValues,
|
|
162
162
|
setFocusedIndex,
|
|
163
|
-
value,
|
|
163
|
+
value: selectedValue,
|
|
164
164
|
optionProps,
|
|
165
165
|
onChange,
|
|
166
166
|
onClose,
|
|
@@ -168,43 +168,44 @@ var useAutocompleteOption = (props) => {
|
|
|
168
168
|
} = useAutocompleteContext();
|
|
169
169
|
const uuid = (0, import_react2.useId)();
|
|
170
170
|
const itemRef = (0, import_react2.useRef)(null);
|
|
171
|
-
|
|
172
|
-
id,
|
|
171
|
+
const {
|
|
172
|
+
id = uuid,
|
|
173
173
|
children,
|
|
174
174
|
closeOnSelect: customCloseOnSelect,
|
|
175
|
-
disabled,
|
|
176
|
-
focusable,
|
|
177
|
-
icon: customIcon,
|
|
178
175
|
isDisabled,
|
|
176
|
+
disabled = isDisabled,
|
|
179
177
|
isFocusable,
|
|
178
|
+
focusable = isFocusable,
|
|
179
|
+
icon: customIcon,
|
|
180
180
|
value: optionValue,
|
|
181
181
|
...computedProps
|
|
182
182
|
} = { ...optionProps, ...props };
|
|
183
|
-
disabled != null ? disabled : disabled = isDisabled;
|
|
184
|
-
focusable != null ? focusable : focusable = isFocusable;
|
|
185
183
|
const trulyDisabled = !!disabled && !focusable;
|
|
186
184
|
const { descendants, index, register } = useAutocompleteDescendant({
|
|
187
185
|
disabled: trulyDisabled
|
|
188
186
|
});
|
|
189
187
|
const values = descendants.values();
|
|
190
188
|
const frontValues = values.slice(0, index);
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
`${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: Cannot infer the option value of complex children. Pass a \`value\` prop or use a plain string as children to <Option>.`
|
|
205
|
-
);
|
|
189
|
+
const multi = (0, import_utils3.isArray)(selectedValue);
|
|
190
|
+
const target = "target" in ((_b = (_a = itemRef.current) == null ? void 0 : _a.dataset) != null ? _b : {});
|
|
191
|
+
const focused = index === focusedIndex;
|
|
192
|
+
const value = (0, import_react2.useMemo)(() => {
|
|
193
|
+
let value2 = optionValue;
|
|
194
|
+
if ((0, import_utils3.isUndefined)(optionValue)) {
|
|
195
|
+
if ((0, import_utils3.isString)(children) || (0, import_utils3.isNumber)(children)) {
|
|
196
|
+
value2 = children.toString();
|
|
197
|
+
} else {
|
|
198
|
+
console.warn(
|
|
199
|
+
`${!multi ? "Autocomplete" : "MultiAutocomplete"}: Cannot infer the option value of complex children. Pass a \`value\` prop or use a plain string as children to <Option>.`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
206
202
|
}
|
|
207
|
-
|
|
203
|
+
return value2 != null ? value2 : "";
|
|
204
|
+
}, [children, multi, optionValue]);
|
|
205
|
+
const duplicated = frontValues.some(
|
|
206
|
+
({ node }) => node.dataset.value === value
|
|
207
|
+
);
|
|
208
|
+
const selected = !duplicated && (!multi ? value === selectedValue : selectedValue.includes(value));
|
|
208
209
|
const onClick = (0, import_react2.useCallback)(
|
|
209
210
|
(ev) => {
|
|
210
211
|
ev.stopPropagation();
|
|
@@ -212,18 +213,18 @@ var useAutocompleteOption = (props) => {
|
|
|
212
213
|
if (inputRef.current) inputRef.current.focus();
|
|
213
214
|
return;
|
|
214
215
|
}
|
|
215
|
-
if (!
|
|
216
|
-
onChange(
|
|
216
|
+
if (!duplicated) setFocusedIndex(index);
|
|
217
|
+
onChange(value);
|
|
217
218
|
if (inputRef.current) inputRef.current.focus();
|
|
218
219
|
if (customCloseOnSelect != null ? customCloseOnSelect : closeOnSelect) onClose();
|
|
219
220
|
if (omitSelectedValues) onFocusNext(index);
|
|
220
221
|
},
|
|
221
222
|
[
|
|
222
|
-
|
|
223
|
+
duplicated,
|
|
223
224
|
onFocusNext,
|
|
224
225
|
omitSelectedValues,
|
|
225
226
|
disabled,
|
|
226
|
-
|
|
227
|
+
value,
|
|
227
228
|
setFocusedIndex,
|
|
228
229
|
index,
|
|
229
230
|
onChange,
|
|
@@ -235,7 +236,7 @@ var useAutocompleteOption = (props) => {
|
|
|
235
236
|
);
|
|
236
237
|
const getOptionProps = (0, import_react2.useCallback)(
|
|
237
238
|
(props2 = {}, ref = null) => {
|
|
238
|
-
const isHidden = !
|
|
239
|
+
const isHidden = !target || omitSelectedValues && selected;
|
|
239
240
|
const style = {
|
|
240
241
|
border: "0px",
|
|
241
242
|
clip: "rect(0px, 0px, 0px, 0px)",
|
|
@@ -256,37 +257,37 @@ var useAutocompleteOption = (props) => {
|
|
|
256
257
|
style: isHidden ? style : void 0,
|
|
257
258
|
"aria-disabled": (0, import_utils3.ariaAttr)(disabled),
|
|
258
259
|
"aria-hidden": (0, import_utils3.ariaAttr)(isHidden),
|
|
259
|
-
"aria-selected":
|
|
260
|
+
"aria-selected": selected,
|
|
260
261
|
"data-disabled": (0, import_utils3.dataAttr)(disabled),
|
|
261
|
-
"data-duplicated": (0, import_utils3.dataAttr)(
|
|
262
|
-
"data-focus": (0, import_utils3.dataAttr)(
|
|
262
|
+
"data-duplicated": (0, import_utils3.dataAttr)(duplicated),
|
|
263
|
+
"data-focus": (0, import_utils3.dataAttr)(focused),
|
|
263
264
|
"data-target": (0, import_utils3.dataAttr)(true),
|
|
264
|
-
"data-value":
|
|
265
|
+
"data-value": value,
|
|
265
266
|
tabIndex: -1,
|
|
266
267
|
onClick: (0, import_utils3.handlerAll)(computedProps.onClick, props2.onClick, onClick)
|
|
267
268
|
};
|
|
268
269
|
},
|
|
269
270
|
[
|
|
270
271
|
id,
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
duplicated,
|
|
273
|
+
value,
|
|
273
274
|
computedProps,
|
|
274
275
|
disabled,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
focused,
|
|
277
|
+
selected,
|
|
278
|
+
target,
|
|
278
279
|
omitSelectedValues,
|
|
279
280
|
onClick,
|
|
280
281
|
register
|
|
281
282
|
]
|
|
282
283
|
);
|
|
283
284
|
return {
|
|
285
|
+
target,
|
|
284
286
|
children,
|
|
285
287
|
customIcon,
|
|
286
|
-
|
|
287
|
-
isSelected,
|
|
288
|
-
isTarget,
|
|
288
|
+
focused,
|
|
289
289
|
omitSelectedValues,
|
|
290
|
+
selected,
|
|
290
291
|
getOptionProps
|
|
291
292
|
};
|
|
292
293
|
};
|
|
@@ -606,7 +607,7 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
|
606
607
|
var AutocompleteOption = (0, import_core5.forwardRef)(
|
|
607
608
|
({ className, icon, ...rest }, ref) => {
|
|
608
609
|
const { styles } = useAutocompleteContext();
|
|
609
|
-
const { children, customIcon,
|
|
610
|
+
const { children, customIcon, selected, getOptionProps } = useAutocompleteOption(rest);
|
|
610
611
|
icon != null ? icon : icon = customIcon;
|
|
611
612
|
const css = {
|
|
612
613
|
alignItems: "center",
|
|
@@ -628,7 +629,7 @@ var AutocompleteOption = (0, import_core5.forwardRef)(
|
|
|
628
629
|
__css: css,
|
|
629
630
|
...getOptionProps({}, ref),
|
|
630
631
|
children: [
|
|
631
|
-
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AutocompleteItemIcon, { opacity:
|
|
632
|
+
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AutocompleteItemIcon, { opacity: selected ? 1 : 0, children: icon || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AutocompleteCheckIcon, {}) }) : null,
|
|
632
633
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.span, { style: { flex: 1 }, "data-label": true, children })
|
|
633
634
|
]
|
|
634
635
|
}
|