@yamada-ui/autocomplete 1.2.7 → 1.3.0-dev-20240716131202

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.
@@ -371,7 +371,7 @@ var flattenItems = (items) => {
371
371
  };
372
372
  var isTargetOption = (target) => {
373
373
  var _a;
374
- return (0, import_utils6.isHTMLElement)(target) && !!((_a = target == null ? void 0 : target.getAttribute("role")) == null ? void 0 : _a.startsWith("autocomplete-item"));
374
+ return (0, import_utils6.isHTMLElement)(target) && !!((_a = target == null ? void 0 : target.getAttribute("role")) == null ? void 0 : _a.startsWith("option"));
375
375
  };
376
376
  var {
377
377
  DescendantsContextProvider: AutocompleteDescendantsContextProvider,
@@ -1075,47 +1075,58 @@ var useAutocompleteInput = () => {
1075
1075
  isAllSelected,
1076
1076
  formControlProps,
1077
1077
  inputProps,
1078
- isOpen
1078
+ isOpen,
1079
+ focusedIndex,
1080
+ listRef
1079
1081
  } = useAutocompleteContext();
1082
+ const { value } = useAutocompleteDescendantsContext();
1080
1083
  (0, import_utils6.useUpdateEffect)(() => {
1081
1084
  if (isAllSelected && inputRef.current) inputRef.current.blur();
1082
1085
  }, [isAllSelected]);
1083
1086
  const getInputProps = (0, import_react.useCallback)(
1084
- (props = {}, ref = null) => ({
1085
- ref: (0, import_utils6.mergeRefs)(inputRef, ref),
1086
- ...formControlProps,
1087
- role: "combobox",
1088
- "aria-haspopup": "listbox",
1089
- "aria-autocomplete": "list",
1090
- "aria-expanded": isOpen,
1091
- autoCapitalize: "none",
1092
- autoComplete: "off",
1093
- spellCheck: "false",
1094
- ...inputProps,
1095
- ...props,
1096
- id,
1097
- cursor: formControlProps.readOnly ? "default" : "text",
1098
- pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1099
- tabIndex: isAllSelected ? -1 : 0,
1100
- onChange: (0, import_utils6.handlerAll)(props.onChange, onSearch),
1101
- onCompositionStart: (0, import_utils6.handlerAll)(
1102
- props.onCompositionStart,
1103
- inputProps.onCompositionStart,
1104
- onCompositionStart
1105
- ),
1106
- onCompositionEnd: (0, import_utils6.handlerAll)(
1107
- props.onCompositionEnd,
1108
- inputProps.onCompositionEnd,
1109
- onCompositionEnd
1110
- )
1111
- }),
1087
+ (props = {}, ref = null) => {
1088
+ var _a, _b;
1089
+ return {
1090
+ ref: (0, import_utils6.mergeRefs)(inputRef, ref),
1091
+ ...formControlProps,
1092
+ role: "combobox",
1093
+ "aria-haspopup": "listbox",
1094
+ "aria-autocomplete": "list",
1095
+ "aria-expanded": isOpen,
1096
+ "aria-activedescendant": (_a = value(focusedIndex)) == null ? void 0 : _a.node.id,
1097
+ "aria-controls": (_b = listRef.current) == null ? void 0 : _b.id,
1098
+ autoCapitalize: "none",
1099
+ autoComplete: "off",
1100
+ spellCheck: "false",
1101
+ ...inputProps,
1102
+ ...props,
1103
+ id,
1104
+ cursor: formControlProps.readOnly ? "default" : "text",
1105
+ pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1106
+ tabIndex: isAllSelected ? -1 : 0,
1107
+ onChange: (0, import_utils6.handlerAll)(props.onChange, onSearch),
1108
+ onCompositionStart: (0, import_utils6.handlerAll)(
1109
+ props.onCompositionStart,
1110
+ inputProps.onCompositionStart,
1111
+ onCompositionStart
1112
+ ),
1113
+ onCompositionEnd: (0, import_utils6.handlerAll)(
1114
+ props.onCompositionEnd,
1115
+ inputProps.onCompositionEnd,
1116
+ onCompositionEnd
1117
+ )
1118
+ };
1119
+ },
1112
1120
  [
1121
+ listRef,
1122
+ focusedIndex,
1113
1123
  isOpen,
1114
1124
  inputProps,
1115
1125
  inputRef,
1116
1126
  formControlProps,
1117
1127
  id,
1118
1128
  isAllSelected,
1129
+ value,
1119
1130
  onSearch,
1120
1131
  onCompositionStart,
1121
1132
  onCompositionEnd
@@ -1166,8 +1177,9 @@ var useAutocompleteList = () => {
1166
1177
  (props = {}, ref = null) => ({
1167
1178
  as: "ul",
1168
1179
  ref: (0, import_utils6.mergeRefs)(listRef, ref),
1169
- role: "select",
1180
+ role: "listbox",
1170
1181
  tabIndex: -1,
1182
+ id: props.id || (0, import_react.useId)(),
1171
1183
  ...props,
1172
1184
  onAnimationComplete: (0, import_utils6.handlerAll)(
1173
1185
  props.onAnimationComplete,
@@ -1328,16 +1340,17 @@ var useAutocompleteOption = (props) => {
1328
1340
  };
1329
1341
  return {
1330
1342
  ref: (0, import_utils6.mergeRefs)(itemRef, ref, register),
1343
+ id: (0, import_react.useId)(),
1344
+ role: "option",
1331
1345
  ...computedProps,
1332
1346
  ...props2,
1333
- role: "autocomplete-item",
1334
1347
  tabIndex: -1,
1335
1348
  style: !isTarget || omitSelectedValues && isSelected ? style : void 0,
1336
1349
  "data-target": (0, import_utils6.dataAttr)(true),
1337
1350
  "data-value": optionValue != null ? optionValue : "",
1338
1351
  "data-focus": (0, import_utils6.dataAttr)(isFocused),
1339
1352
  "data-disabled": (0, import_utils6.dataAttr)(isDisabled),
1340
- "aria-checked": (0, import_utils6.ariaAttr)(isSelected),
1353
+ "aria-checked": isSelected,
1341
1354
  "aria-disabled": (0, import_utils6.ariaAttr)(isDisabled),
1342
1355
  onClick: (0, import_utils6.handlerAll)(computedProps.onClick, props2.onClick, onClick)
1343
1356
  };
@@ -1696,6 +1709,7 @@ var MultiAutocompleteField = (0, import_core8.forwardRef)(
1696
1709
  overflow: "hidden",
1697
1710
  marginBlockStart: "0.125rem",
1698
1711
  marginBlockEnd: "0.125rem",
1712
+ "aria-multiselectable": "true",
1699
1713
  placeholder: !label || !(label == null ? void 0 : label.length) || keepPlaceholder && isOpen ? placeholder : void 0,
1700
1714
  ...getInputProps({ ...inputProps, value: inputValue != null ? inputValue : "" }, ref)
1701
1715
  }