@yamada-ui/autocomplete 1.6.2-dev-20241026110242 → 1.6.2-dev-20241026111932
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/autocomplete-create.d.mts +2 -2
- package/dist/autocomplete-create.d.ts +2 -2
- package/dist/autocomplete-create.js +3 -1
- package/dist/autocomplete-create.js.map +1 -1
- package/dist/autocomplete-create.mjs +2 -2
- package/dist/autocomplete-empty.d.mts +2 -2
- package/dist/autocomplete-empty.d.ts +2 -2
- package/dist/autocomplete-empty.js +5 -2
- package/dist/autocomplete-empty.js.map +1 -1
- package/dist/autocomplete-empty.mjs +2 -2
- package/dist/autocomplete-list.d.mts +2 -2
- package/dist/autocomplete-list.d.ts +2 -2
- package/dist/autocomplete-list.js +16 -19
- package/dist/autocomplete-list.js.map +1 -1
- package/dist/autocomplete-list.mjs +2 -2
- package/dist/autocomplete-option-group.d.mts +3 -3
- package/dist/autocomplete-option-group.d.ts +3 -3
- package/dist/autocomplete-option-group.js +27 -13
- package/dist/autocomplete-option-group.js.map +1 -1
- package/dist/autocomplete-option-group.mjs +2 -2
- package/dist/autocomplete-option.d.mts +1 -1
- package/dist/autocomplete-option.d.ts +1 -1
- package/dist/autocomplete-option.js +18 -12
- package/dist/autocomplete-option.js.map +1 -1
- package/dist/autocomplete-option.mjs +2 -2
- package/dist/autocomplete.js +78 -56
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.mjs +10 -10
- package/dist/{chunk-KWIJUSLC.mjs → chunk-2UKLSSUA.mjs} +3 -3
- package/dist/chunk-2UKLSSUA.mjs.map +1 -0
- package/dist/{chunk-ZXALWDKQ.mjs → chunk-3A2HEULI.mjs} +24 -13
- package/dist/chunk-3A2HEULI.mjs.map +1 -0
- package/dist/{chunk-PKRO525W.mjs → chunk-6II6KCIJ.mjs} +3 -3
- package/dist/chunk-6II6KCIJ.mjs.map +1 -0
- package/dist/{chunk-OY5JVCQQ.mjs → chunk-6WQMVK6S.mjs} +5 -5
- package/dist/{chunk-HUY7Q3WA.mjs → chunk-6ZFQNL3O.mjs} +5 -7
- package/dist/{chunk-HUY7Q3WA.mjs.map → chunk-6ZFQNL3O.mjs.map} +1 -1
- package/dist/{chunk-7QON6ZHO.mjs → chunk-CMFJUJJW.mjs} +25 -11
- package/dist/chunk-CMFJUJJW.mjs.map +1 -0
- package/dist/{chunk-352YZTOO.mjs → chunk-EVGBK5C5.mjs} +12 -12
- package/dist/{chunk-352YZTOO.mjs.map → chunk-EVGBK5C5.mjs.map} +1 -1
- package/dist/{chunk-J6UKIKNL.mjs → chunk-G6SC44LI.mjs} +3 -3
- package/dist/chunk-G6SC44LI.mjs.map +1 -0
- package/dist/{chunk-X2PFHBZY.mjs → chunk-PTPJFYGI.mjs} +15 -17
- package/dist/chunk-PTPJFYGI.mjs.map +1 -0
- package/dist/{chunk-WNN655FX.mjs → chunk-PU6HFINM.mjs} +7 -7
- package/dist/chunk-PU6HFINM.mjs.map +1 -0
- package/dist/{chunk-WJ4P4B2E.mjs → chunk-REPBXBG3.mjs} +5 -6
- package/dist/chunk-REPBXBG3.mjs.map +1 -0
- package/dist/index.js +78 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/multi-autocomplete.js +78 -58
- package/dist/multi-autocomplete.js.map +1 -1
- package/dist/multi-autocomplete.mjs +10 -10
- package/dist/use-autocomplete-list.d.mts +1 -1
- package/dist/use-autocomplete-list.d.ts +1 -1
- package/dist/use-autocomplete-list.js +13 -15
- package/dist/use-autocomplete-list.js.map +1 -1
- package/dist/use-autocomplete-list.mjs +1 -1
- package/dist/use-autocomplete-option-group.d.mts +3 -2
- package/dist/use-autocomplete-option-group.d.ts +3 -2
- package/dist/use-autocomplete-option-group.js +22 -8
- package/dist/use-autocomplete-option-group.js.map +1 -1
- package/dist/use-autocomplete-option-group.mjs +1 -1
- package/dist/use-autocomplete-option.d.mts +6 -4
- package/dist/use-autocomplete-option.d.ts +6 -4
- package/dist/use-autocomplete-option.js +23 -12
- package/dist/use-autocomplete-option.js.map +1 -1
- package/dist/use-autocomplete-option.mjs +1 -1
- package/dist/use-autocomplete.js +54 -34
- package/dist/use-autocomplete.js.map +1 -1
- package/dist/use-autocomplete.mjs +5 -5
- package/package.json +2 -2
- package/dist/chunk-7QON6ZHO.mjs.map +0 -1
- package/dist/chunk-J6UKIKNL.mjs.map +0 -1
- package/dist/chunk-KWIJUSLC.mjs.map +0 -1
- package/dist/chunk-PKRO525W.mjs.map +0 -1
- package/dist/chunk-WJ4P4B2E.mjs.map +0 -1
- package/dist/chunk-WNN655FX.mjs.map +0 -1
- package/dist/chunk-X2PFHBZY.mjs.map +0 -1
- package/dist/chunk-ZXALWDKQ.mjs.map +0 -1
- /package/dist/{chunk-OY5JVCQQ.mjs.map → chunk-6WQMVK6S.mjs.map} +0 -0
package/dist/use-autocomplete.js
CHANGED
@@ -169,8 +169,10 @@ var useAutocompleteOption = (props) => {
|
|
169
169
|
onClose,
|
170
170
|
onFocusNext
|
171
171
|
} = useAutocompleteContext();
|
172
|
-
const
|
172
|
+
const uuid = (0, import_react2.useId)();
|
173
|
+
const itemRef = (0, import_react2.useRef)(null);
|
173
174
|
let {
|
175
|
+
id,
|
174
176
|
children,
|
175
177
|
closeOnSelect: customCloseOnSelect,
|
176
178
|
icon: customIcon,
|
@@ -180,13 +182,19 @@ var useAutocompleteOption = (props) => {
|
|
180
182
|
...computedProps
|
181
183
|
} = { ...optionProps, ...props };
|
182
184
|
const trulyDisabled = !!isDisabled && !isFocusable;
|
183
|
-
const itemRef = (0, import_react2.useRef)(null);
|
184
185
|
const { descendants, index, register } = useAutocompleteDescendant({
|
185
186
|
disabled: trulyDisabled
|
186
187
|
});
|
187
188
|
const values = descendants.values();
|
188
189
|
const frontValues = values.slice(0, index);
|
189
190
|
const isMulti = (0, import_utils3.isArray)(value);
|
191
|
+
const isDuplicated = frontValues.some(
|
192
|
+
({ node }) => node.dataset.value === (optionValue != null ? optionValue : "")
|
193
|
+
);
|
194
|
+
const isSelected = !isDuplicated && (!isMulti ? (optionValue != null ? optionValue : "") === value : value.includes(optionValue != null ? optionValue : ""));
|
195
|
+
const isTarget = "target" in ((_b = (_a = itemRef.current) == null ? void 0 : _a.dataset) != null ? _b : {});
|
196
|
+
const isFocused = index === focusedIndex;
|
197
|
+
id != null ? id : id = uuid;
|
190
198
|
if ((0, import_utils3.isUndefined)(optionValue)) {
|
191
199
|
if ((0, import_utils3.isString)(children) || (0, import_utils3.isNumber)(children)) {
|
192
200
|
optionValue = children.toString();
|
@@ -196,12 +204,6 @@ var useAutocompleteOption = (props) => {
|
|
196
204
|
);
|
197
205
|
}
|
198
206
|
}
|
199
|
-
const isDuplicated = frontValues.some(
|
200
|
-
({ node }) => node.dataset.value === (optionValue != null ? optionValue : "")
|
201
|
-
);
|
202
|
-
const isSelected = !isDuplicated && (!isMulti ? (optionValue != null ? optionValue : "") === value : value.includes(optionValue != null ? optionValue : ""));
|
203
|
-
const isTarget = "target" in ((_b = (_a = itemRef.current) == null ? void 0 : _a.dataset) != null ? _b : {});
|
204
|
-
const isFocused = index === focusedIndex;
|
205
207
|
const onClick = (0, import_react2.useCallback)(
|
206
208
|
(ev) => {
|
207
209
|
ev.stopPropagation();
|
@@ -232,6 +234,7 @@ var useAutocompleteOption = (props) => {
|
|
232
234
|
);
|
233
235
|
const getOptionProps = (0, import_react2.useCallback)(
|
234
236
|
(props2 = {}, ref = null) => {
|
237
|
+
const isHidden = !isTarget || omitSelectedValues && isSelected;
|
235
238
|
const style = {
|
236
239
|
border: "0px",
|
237
240
|
clip: "rect(0px, 0px, 0px, 0px)",
|
@@ -244,14 +247,15 @@ var useAutocompleteOption = (props) => {
|
|
244
247
|
width: "1px"
|
245
248
|
};
|
246
249
|
return {
|
247
|
-
id,
|
248
250
|
ref: (0, import_utils3.mergeRefs)(itemRef, ref, register),
|
249
251
|
role: "option",
|
250
252
|
...computedProps,
|
251
253
|
...props2,
|
252
|
-
|
253
|
-
|
254
|
+
id,
|
255
|
+
style: isHidden ? style : void 0,
|
254
256
|
"aria-disabled": (0, import_utils3.ariaAttr)(isDisabled),
|
257
|
+
"aria-hidden": (0, import_utils3.ariaAttr)(isHidden),
|
258
|
+
"aria-selected": isSelected,
|
255
259
|
"data-disabled": (0, import_utils3.dataAttr)(isDisabled),
|
256
260
|
"data-duplicated": (0, import_utils3.dataAttr)(isDuplicated),
|
257
261
|
"data-focus": (0, import_utils3.dataAttr)(isFocused),
|
@@ -280,6 +284,8 @@ var useAutocompleteOption = (props) => {
|
|
280
284
|
customIcon,
|
281
285
|
isFocused,
|
282
286
|
isSelected,
|
287
|
+
isTarget,
|
288
|
+
omitSelectedValues,
|
283
289
|
getOptionProps
|
284
290
|
};
|
285
291
|
};
|
@@ -305,7 +311,7 @@ var AutocompleteOption = (0, import_core2.forwardRef)(
|
|
305
311
|
...styles.item
|
306
312
|
};
|
307
313
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
308
|
-
import_core2.ui.
|
314
|
+
import_core2.ui.div,
|
309
315
|
{
|
310
316
|
className: (0, import_utils4.cx)("ui-autocomplete__item", className),
|
311
317
|
__css: css,
|
@@ -343,9 +349,11 @@ var useAutocompleteOptionGroup = ({
|
|
343
349
|
...rest
|
344
350
|
}) => {
|
345
351
|
const { omitSelectedValues, value } = useAutocompleteContext();
|
346
|
-
const isMulti = (0, import_utils5.isArray)(value);
|
347
352
|
const descendants = useAutocompleteDescendantsContext();
|
353
|
+
const labelRef = (0, import_react3.useRef)(null);
|
354
|
+
const labelId = (0, import_react3.useId)();
|
348
355
|
const values = descendants.values();
|
356
|
+
const isMulti = (0, import_utils5.isArray)(value);
|
349
357
|
const selectedValues = isMulti && omitSelectedValues ? descendants.values(
|
350
358
|
({ node }) => {
|
351
359
|
var _a;
|
@@ -363,6 +371,7 @@ var useAutocompleteOptionGroup = ({
|
|
363
371
|
const [containerProps, groupProps] = (0, import_utils5.splitObject)(rest, import_core3.layoutStyleProperties);
|
364
372
|
const getContainerProps = (0, import_react3.useCallback)(
|
365
373
|
(props = {}, ref = null) => {
|
374
|
+
var _a;
|
366
375
|
const style = {
|
367
376
|
border: "0px",
|
368
377
|
clip: "rect(0px, 0px, 0px, 0px)",
|
@@ -376,29 +385,40 @@ var useAutocompleteOptionGroup = ({
|
|
376
385
|
};
|
377
386
|
return {
|
378
387
|
ref,
|
388
|
+
"aria-labelledby": (_a = labelRef.current) == null ? void 0 : _a.id,
|
389
|
+
role: "group",
|
379
390
|
...props,
|
380
391
|
...containerProps,
|
381
|
-
style: isEmpty ? style : void 0
|
382
|
-
"data-label": label,
|
383
|
-
role: "autocomplete-group-container"
|
392
|
+
style: isEmpty ? style : void 0
|
384
393
|
};
|
385
394
|
},
|
386
|
-
[containerProps, isEmpty
|
395
|
+
[containerProps, isEmpty]
|
396
|
+
);
|
397
|
+
const getLabelProps = (0, import_react3.useCallback)(
|
398
|
+
({ id, ...props } = {}, ref = null) => {
|
399
|
+
return {
|
400
|
+
id: id != null ? id : labelId,
|
401
|
+
ref: (0, import_utils5.mergeRefs)(ref, labelRef),
|
402
|
+
role: "presentation",
|
403
|
+
...props
|
404
|
+
};
|
405
|
+
},
|
406
|
+
[labelId]
|
387
407
|
);
|
388
408
|
const getGroupProps = (0, import_react3.useCallback)(
|
389
409
|
(props = {}, ref = null) => ({
|
390
410
|
ref,
|
391
411
|
...props,
|
392
412
|
...groupProps,
|
393
|
-
"data-label": label
|
394
|
-
role: "autocomplete-group"
|
413
|
+
"data-label": label
|
395
414
|
}),
|
396
415
|
[groupProps, label]
|
397
416
|
);
|
398
417
|
return {
|
399
418
|
label,
|
400
419
|
getContainerProps,
|
401
|
-
getGroupProps
|
420
|
+
getGroupProps,
|
421
|
+
getLabelProps
|
402
422
|
};
|
403
423
|
};
|
404
424
|
|
@@ -417,11 +437,11 @@ var AutocompleteOptionGroup = (0, import_core4.forwardRef)(
|
|
417
437
|
...rest
|
418
438
|
}, ref) => {
|
419
439
|
const { styles } = useAutocompleteContext();
|
420
|
-
const { label, getContainerProps, getGroupProps } = useAutocompleteOptionGroup(rest);
|
440
|
+
const { label, getContainerProps, getGroupProps, getLabelProps } = useAutocompleteOptionGroup(rest);
|
421
441
|
h != null ? h : h = height;
|
422
442
|
minH != null ? minH : minH = minHeight;
|
423
443
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
424
|
-
import_core4.ui.
|
444
|
+
import_core4.ui.section,
|
425
445
|
{
|
426
446
|
className: (0, import_utils6.cx)(
|
427
447
|
"ui-autocomplete__item",
|
@@ -432,17 +452,17 @@ var AutocompleteOptionGroup = (0, import_core4.forwardRef)(
|
|
432
452
|
...getContainerProps(),
|
433
453
|
children: [
|
434
454
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
435
|
-
import_core4.ui.
|
455
|
+
import_core4.ui.header,
|
436
456
|
{
|
437
457
|
className: "ui-autocomplete__item__group-label",
|
438
458
|
lineClamp: 1,
|
439
459
|
__css: styles.groupLabel,
|
440
|
-
...labelProps,
|
460
|
+
...getLabelProps(labelProps),
|
441
461
|
children: label
|
442
462
|
}
|
443
463
|
),
|
444
464
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
445
|
-
import_core4.ui.
|
465
|
+
import_core4.ui.div,
|
446
466
|
{
|
447
467
|
...getGroupProps({}, ref),
|
448
468
|
className: "ui-autocomplete__item__group",
|
@@ -1222,7 +1242,6 @@ var useAutocomplete = (props) => {
|
|
1222
1242
|
tabIndex: -1,
|
1223
1243
|
...props2,
|
1224
1244
|
...formControlProps,
|
1225
|
-
"aria-expanded": (0, import_utils7.dataAttr)(isOpen),
|
1226
1245
|
"data-active": (0, import_utils7.dataAttr)(isOpen),
|
1227
1246
|
placeholder,
|
1228
1247
|
onFocus: (0, import_utils7.handlerAll)(props2.onFocus, onFocusProp, onFocus),
|
@@ -1282,6 +1301,7 @@ var useAutocomplete = (props) => {
|
|
1282
1301
|
};
|
1283
1302
|
};
|
1284
1303
|
var useAutocompleteInput = () => {
|
1304
|
+
var _a, _b;
|
1285
1305
|
const {
|
1286
1306
|
id,
|
1287
1307
|
focusedIndex,
|
@@ -1295,31 +1315,32 @@ var useAutocompleteInput = () => {
|
|
1295
1315
|
onCompositionStart,
|
1296
1316
|
onSearch
|
1297
1317
|
} = useAutocompleteContext();
|
1298
|
-
const
|
1318
|
+
const descendants = useAutocompleteDescendantsContext();
|
1319
|
+
const activedescendantId = (_a = descendants.value(focusedIndex)) == null ? void 0 : _a.node.id;
|
1320
|
+
const listId = (_b = listRef.current) == null ? void 0 : _b.id;
|
1299
1321
|
(0, import_utils7.useUpdateEffect)(() => {
|
1300
1322
|
if (isAllSelected && inputRef.current) inputRef.current.blur();
|
1301
1323
|
}, [isAllSelected]);
|
1302
1324
|
const getInputProps = (0, import_react4.useCallback)(
|
1303
1325
|
(props = {}, ref = null) => {
|
1304
|
-
var _a, _b;
|
1305
1326
|
return {
|
1306
1327
|
ref: (0, import_utils7.mergeRefs)(inputRef, ref),
|
1307
1328
|
...formControlProps,
|
1308
|
-
"aria-activedescendant":
|
1329
|
+
"aria-activedescendant": activedescendantId,
|
1309
1330
|
"aria-autocomplete": "list",
|
1310
|
-
"aria-controls":
|
1331
|
+
"aria-controls": listId,
|
1311
1332
|
"aria-expanded": isOpen,
|
1312
1333
|
"aria-haspopup": "listbox",
|
1313
1334
|
autoCapitalize: "none",
|
1314
1335
|
autoComplete: "off",
|
1315
1336
|
role: "combobox",
|
1316
1337
|
spellCheck: "false",
|
1338
|
+
tabIndex: isAllSelected ? -1 : 0,
|
1317
1339
|
...inputProps,
|
1318
1340
|
...props,
|
1319
1341
|
id,
|
1320
1342
|
cursor: formControlProps.readOnly ? "default" : "text",
|
1321
1343
|
pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
|
1322
|
-
tabIndex: isAllSelected ? -1 : 0,
|
1323
1344
|
onChange: (0, import_utils7.handlerAll)(props.onChange, onSearch),
|
1324
1345
|
onCompositionEnd: (0, import_utils7.handlerAll)(
|
1325
1346
|
props.onCompositionEnd,
|
@@ -1334,15 +1355,14 @@ var useAutocompleteInput = () => {
|
|
1334
1355
|
};
|
1335
1356
|
},
|
1336
1357
|
[
|
1337
|
-
|
1338
|
-
|
1358
|
+
listId,
|
1359
|
+
activedescendantId,
|
1339
1360
|
isOpen,
|
1340
1361
|
inputProps,
|
1341
1362
|
inputRef,
|
1342
1363
|
formControlProps,
|
1343
1364
|
id,
|
1344
1365
|
isAllSelected,
|
1345
|
-
value,
|
1346
1366
|
onSearch,
|
1347
1367
|
onCompositionStart,
|
1348
1368
|
onCompositionEnd
|