@yamada-ui/autocomplete 0.5.5 → 0.6.0

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.
Files changed (35) hide show
  1. package/dist/autocomplete-create.js +1 -0
  2. package/dist/autocomplete-create.mjs +1 -1
  3. package/dist/autocomplete-empty.js +1 -0
  4. package/dist/autocomplete-empty.mjs +1 -1
  5. package/dist/autocomplete-icon.js +1 -0
  6. package/dist/autocomplete-icon.mjs +1 -1
  7. package/dist/autocomplete-list.js +3 -2
  8. package/dist/autocomplete-list.mjs +1 -1
  9. package/dist/autocomplete-option-group.d.mts +1 -1
  10. package/dist/autocomplete-option-group.d.ts +1 -1
  11. package/dist/autocomplete-option-group.js +1 -0
  12. package/dist/autocomplete-option-group.mjs +1 -1
  13. package/dist/autocomplete-option.d.mts +1 -1
  14. package/dist/autocomplete-option.d.ts +1 -1
  15. package/dist/autocomplete-option.js +1 -0
  16. package/dist/autocomplete-option.mjs +1 -1
  17. package/dist/autocomplete.d.mts +1 -1
  18. package/dist/autocomplete.d.ts +1 -1
  19. package/dist/autocomplete.js +64 -21
  20. package/dist/autocomplete.mjs +1 -1
  21. package/dist/{chunk-GQ4NNX5K.mjs → chunk-TZHEVPHW.mjs} +94 -56
  22. package/dist/index.d.mts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +98 -47
  25. package/dist/index.mjs +1 -1
  26. package/dist/multi-autocomplete.d.mts +1 -1
  27. package/dist/multi-autocomplete.d.ts +1 -1
  28. package/dist/multi-autocomplete.js +77 -34
  29. package/dist/multi-autocomplete.mjs +1 -1
  30. package/dist/{use-autocomplete-3e77a4da.d.ts → use-autocomplete-72ef1a50.d.ts} +7 -2
  31. package/dist/use-autocomplete.d.mts +1 -1
  32. package/dist/use-autocomplete.d.ts +1 -1
  33. package/dist/use-autocomplete.js +45 -10
  34. package/dist/use-autocomplete.mjs +1 -1
  35. package/package.json +10 -10
@@ -1,20 +1,17 @@
1
1
  "use client"
2
2
 
3
3
  // src/autocomplete-list.tsx
4
- import {
5
- forwardRef as forwardRef8
6
- } from "@yamada-ui/core";
4
+ import { forwardRef as forwardRef8 } from "@yamada-ui/core";
7
5
  import { PopoverContent } from "@yamada-ui/popover";
8
6
  import { cx as cx8 } from "@yamada-ui/utils";
9
7
 
10
8
  // src/use-autocomplete.tsx
11
- import {
12
- layoutStylesProperties
13
- } from "@yamada-ui/core";
9
+ import { layoutStylesProperties } from "@yamada-ui/core";
14
10
  import {
15
11
  formControlProperties,
16
12
  useFormControlProps
17
13
  } from "@yamada-ui/form-control";
14
+ import { popoverProperties } from "@yamada-ui/popover";
18
15
  import { useControllableState } from "@yamada-ui/use-controllable-state";
19
16
  import { createDescendant } from "@yamada-ui/use-descendant";
20
17
  import { useOutsideClick } from "@yamada-ui/use-outside-click";
@@ -37,13 +34,7 @@ import {
37
34
  getValidChildren as getValidChildren2,
38
35
  isUndefined
39
36
  } from "@yamada-ui/utils";
40
- import {
41
- useCallback,
42
- useEffect,
43
- useMemo as useMemo2,
44
- useRef as useRef2,
45
- useState
46
- } from "react";
37
+ import { useCallback, useEffect, useMemo as useMemo2, useRef as useRef2, useState } from "react";
47
38
 
48
39
  // src/autocomplete.tsx
49
40
  import {
@@ -180,7 +171,6 @@ var Autocomplete = forwardRef2(
180
171
  h != null ? h : h = height;
181
172
  minH != null ? minH : minH = minHeight;
182
173
  const css = {
183
- position: "relative",
184
174
  w: "100%",
185
175
  h: "fit-content",
186
176
  color,
@@ -204,16 +194,25 @@ var Autocomplete = forwardRef2(
204
194
  __css: css,
205
195
  ...getContainerProps(containerProps),
206
196
  children: [
207
- /* @__PURE__ */ jsx2(
208
- AutocompleteField,
197
+ /* @__PURE__ */ jsxs(
198
+ ui2.div,
209
199
  {
210
- h,
211
- minH,
212
- inputProps,
213
- ...getFieldProps({}, ref)
200
+ className: "ui-autocomplete__inner",
201
+ __css: { position: "relative", ...styles.inner },
202
+ children: [
203
+ /* @__PURE__ */ jsx2(
204
+ AutocompleteField,
205
+ {
206
+ h,
207
+ minH,
208
+ inputProps,
209
+ ...getFieldProps({}, ref)
210
+ }
211
+ ),
212
+ /* @__PURE__ */ jsx2(AutocompleteIcon, { ...iconProps, ...formControlProps })
213
+ ]
214
214
  }
215
215
  ),
216
- /* @__PURE__ */ jsx2(AutocompleteIcon, { ...iconProps, ...formControlProps }),
217
216
  !isEmpty ? /* @__PURE__ */ jsxs(AutocompleteList, { ...listProps, children: [
218
217
  allowCreate ? /* @__PURE__ */ jsx2(AutocompleteCreate, {}) : /* @__PURE__ */ jsx2(AutocompleteEmpty, {}),
219
218
  children != null ? children : computedChildren
@@ -449,10 +448,7 @@ import {
449
448
  } from "@yamada-ui/core";
450
449
  import { Popover as Popover2, PopoverTrigger as PopoverTrigger2 } from "@yamada-ui/popover";
451
450
  import { cx as cx7, handlerAll } from "@yamada-ui/utils";
452
- import {
453
- cloneElement as cloneElement2,
454
- useMemo
455
- } from "react";
451
+ import { cloneElement as cloneElement2, useMemo } from "react";
456
452
  import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
457
453
  var MultiAutocomplete = forwardRef7(
458
454
  (props, ref) => {
@@ -503,7 +499,6 @@ var MultiAutocomplete = forwardRef7(
503
499
  h != null ? h : h = height;
504
500
  minH != null ? minH : minH = minHeight;
505
501
  const css = {
506
- position: "relative",
507
502
  w: "100%",
508
503
  h: "fit-content",
509
504
  color,
@@ -524,30 +519,39 @@ var MultiAutocomplete = forwardRef7(
524
519
  children: /* @__PURE__ */ jsx7(Popover2, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs6(
525
520
  ui7.div,
526
521
  {
527
- className: cx7("ui-autocomplete", className),
522
+ className: cx7("ui-multi-autocomplete", className),
528
523
  __css: css,
529
524
  ...getContainerProps(containerProps),
530
525
  children: [
531
- /* @__PURE__ */ jsx7(
532
- MultiAutocompleteField,
526
+ /* @__PURE__ */ jsxs6(
527
+ ui7.div,
533
528
  {
534
- component,
535
- separator,
536
- keepPlaceholder,
537
- h,
538
- minH,
539
- inputProps,
540
- ...getFieldProps({}, ref)
529
+ className: "ui-multi-autocomplete__inner",
530
+ __css: { position: "relative", ...styles.inner },
531
+ children: [
532
+ /* @__PURE__ */ jsx7(
533
+ MultiAutocompleteField,
534
+ {
535
+ component,
536
+ separator,
537
+ keepPlaceholder,
538
+ h,
539
+ minH,
540
+ inputProps,
541
+ ...getFieldProps({}, ref)
542
+ }
543
+ ),
544
+ isClearable && value.length ? /* @__PURE__ */ jsx7(
545
+ AutocompleteClearIcon,
546
+ {
547
+ ...clearIconProps,
548
+ onClick: handlerAll(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
549
+ ...formControlProps
550
+ }
551
+ ) : /* @__PURE__ */ jsx7(AutocompleteIcon, { ...iconProps, ...formControlProps })
552
+ ]
541
553
  }
542
554
  ),
543
- isClearable && value.length ? /* @__PURE__ */ jsx7(
544
- AutocompleteClearIcon,
545
- {
546
- ...clearIconProps,
547
- onClick: handlerAll(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
548
- ...formControlProps
549
- }
550
- ) : /* @__PURE__ */ jsx7(AutocompleteIcon, { ...iconProps, ...formControlProps }),
551
555
  !isEmpty ? /* @__PURE__ */ jsxs6(AutocompleteList, { ...listProps, children: [
552
556
  allowCreate ? /* @__PURE__ */ jsx7(AutocompleteCreate, {}) : /* @__PURE__ */ jsx7(AutocompleteEmpty, {}),
553
557
  children != null ? children : computedChildren
@@ -629,7 +633,7 @@ var MultiAutocompleteField = forwardRef7(
629
633
  return /* @__PURE__ */ jsx7(PopoverTrigger2, { children: /* @__PURE__ */ jsxs6(
630
634
  ui7.div,
631
635
  {
632
- className: cx7("ui-autocomplete__field", className),
636
+ className: cx7("ui-multi-autocomplete__field", className),
633
637
  __css: css,
634
638
  py: (displayValue == null ? void 0 : displayValue.length) && component ? "0.125rem" : void 0,
635
639
  ...rest,
@@ -638,7 +642,7 @@ var MultiAutocompleteField = forwardRef7(
638
642
  /* @__PURE__ */ jsx7(
639
643
  ui7.input,
640
644
  {
641
- className: cx7("ui-autocomplete__field__input", className),
645
+ className: "ui-multi-autocomplete__field__input",
642
646
  display: "inline-block",
643
647
  flex: "1",
644
648
  overflow: "hidden",
@@ -794,6 +798,7 @@ var useAutocomplete = ({
794
798
  closeOnBlur = true,
795
799
  closeOnEsc = true,
796
800
  allowCreate = false,
801
+ allowFree = false,
797
802
  insertPositionItem = "first",
798
803
  emptyMessage = "No results found",
799
804
  format = defaultFormat,
@@ -810,12 +815,13 @@ var useAutocomplete = ({
810
815
  const formControlProps = pickObject(rest, formControlProperties);
811
816
  const [containerProps, inputProps] = splitObject(
812
817
  omitObject(rest, [
818
+ ...popoverProperties,
813
819
  "id",
814
820
  "value",
815
821
  "defaultValue",
816
822
  "onChange",
817
- "month",
818
- "onChangeMonth"
823
+ "onCreate",
824
+ "onSearch"
819
825
  ]),
820
826
  layoutStylesProperties
821
827
  );
@@ -1080,6 +1086,10 @@ var useAutocomplete = ({
1080
1086
  var _a;
1081
1087
  return (_a = node.textContent) != null ? _a : "";
1082
1088
  });
1089
+ if (allowFree && selectedValues2.length === 0) {
1090
+ selectedValues2.push(newValue);
1091
+ setInputValue("");
1092
+ }
1083
1093
  setDisplayValue((prev) => {
1084
1094
  if (!isMulti) {
1085
1095
  return selectedValues2[0];
@@ -1096,7 +1106,7 @@ var useAutocomplete = ({
1096
1106
  }
1097
1107
  });
1098
1108
  },
1099
- [descendants, isMulti]
1109
+ [descendants, isMulti, allowFree]
1100
1110
  );
1101
1111
  const onChange = useCallback(
1102
1112
  (newValue) => {
@@ -1112,11 +1122,26 @@ var useAutocomplete = ({
1112
1122
  }
1113
1123
  }
1114
1124
  });
1125
+ const isHit2 = descendants.values().filter(
1126
+ ({ node }) => {
1127
+ var _a;
1128
+ return format((_a = node.textContent) != null ? _a : "").includes(newValue);
1129
+ }
1130
+ ).length > 0;
1115
1131
  onChangeDisplayValue(newValue);
1116
- setInputValue("");
1132
+ if (!allowFree || isHit2) {
1133
+ setInputValue("");
1134
+ }
1117
1135
  rebirthOptions(false);
1118
1136
  },
1119
- [onChangeDisplayValue, rebirthOptions, setValue]
1137
+ [
1138
+ allowFree,
1139
+ onChangeDisplayValue,
1140
+ rebirthOptions,
1141
+ setValue,
1142
+ descendants,
1143
+ format
1144
+ ]
1120
1145
  );
1121
1146
  const onSelect = useCallback(() => {
1122
1147
  var _a, _b;
@@ -1250,11 +1275,15 @@ var useAutocomplete = ({
1250
1275
  return;
1251
1276
  if (!closeOnBlur && isHit)
1252
1277
  return;
1253
- setInputValue("");
1278
+ if (allowFree && !!inputValue) {
1279
+ onChange(inputValue);
1280
+ } else {
1281
+ setInputValue("");
1282
+ }
1254
1283
  if (isOpen)
1255
1284
  onClose();
1256
1285
  },
1257
- [closeOnBlur, isHit, isOpen, onClose]
1286
+ [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
1258
1287
  );
1259
1288
  const onKeyDown = useCallback(
1260
1289
  (ev) => {
@@ -1269,7 +1298,11 @@ var useAutocomplete = ({
1269
1298
  ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0,
1270
1299
  ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? funcAll(onOpen, onFocusLastOrSelected) : void 0,
1271
1300
  Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0,
1272
- Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : void 0,
1301
+ Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? funcAll(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
1302
+ if (inputValue)
1303
+ onChange(inputValue);
1304
+ setFocusedIndex(0);
1305
+ } : void 0,
1273
1306
  Home: isOpen ? onFocusFirst : void 0,
1274
1307
  End: isOpen ? onFocusLast : void 0,
1275
1308
  Escape: closeOnEsc ? onClose : void 0,
@@ -1283,11 +1316,13 @@ var useAutocomplete = ({
1283
1316
  action(ev);
1284
1317
  },
1285
1318
  [
1319
+ allowFree,
1286
1320
  formControlProps,
1287
1321
  displayValue,
1288
1322
  inputValue,
1289
1323
  onOpen,
1290
1324
  isFocused,
1325
+ isMulti,
1291
1326
  onFocusFirstOrSelected,
1292
1327
  onFocusNext,
1293
1328
  onFocusLastOrSelected,
@@ -1301,7 +1336,8 @@ var useAutocomplete = ({
1301
1336
  closeOnEsc,
1302
1337
  onClose,
1303
1338
  isEmptyValue,
1304
- onDelete
1339
+ onDelete,
1340
+ onChange
1305
1341
  ]
1306
1342
  );
1307
1343
  useEffect(() => {
@@ -1326,7 +1362,7 @@ var useAutocomplete = ({
1326
1362
  maxSelectedValues
1327
1363
  ]);
1328
1364
  useUpdateEffect(() => {
1329
- if (isOpen)
1365
+ if (isOpen || allowFree)
1330
1366
  return;
1331
1367
  setFocusedIndex(-1);
1332
1368
  setInputValue("");
@@ -1346,6 +1382,7 @@ var useAutocomplete = ({
1346
1382
  });
1347
1383
  const getPopoverProps = useCallback(
1348
1384
  (props) => ({
1385
+ matchWidth: true,
1349
1386
  ...rest,
1350
1387
  ...props,
1351
1388
  isOpen,
@@ -1396,6 +1433,7 @@ var useAutocomplete = ({
1396
1433
  omitSelectedValues,
1397
1434
  closeOnSelect,
1398
1435
  allowCreate,
1436
+ allowFree,
1399
1437
  emptyMessage,
1400
1438
  isOpen,
1401
1439
  isAllSelected,
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Autocomplete, AutocompleteProps } from './autocomplete.mjs';
2
2
  export { AutocompleteOptionGroup, AutocompleteOptionGroupProps } from './autocomplete-option-group.mjs';
3
- export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-3e77a4da.js';
3
+ export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-72ef1a50.js';
4
4
  export { AutocompleteCreate, AutocompleteCreateProps } from './autocomplete-create.mjs';
5
5
  export { AutocompleteEmpty, AutocompleteEmptyProps } from './autocomplete-empty.mjs';
6
6
  export { MultiAutocomplete, MultiAutocompleteProps } from './multi-autocomplete.mjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Autocomplete, AutocompleteProps } from './autocomplete.js';
2
2
  export { AutocompleteOptionGroup, AutocompleteOptionGroupProps } from './autocomplete-option-group.js';
3
- export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-3e77a4da.js';
3
+ export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-72ef1a50.js';
4
4
  export { AutocompleteCreate, AutocompleteCreateProps } from './autocomplete-create.js';
5
5
  export { AutocompleteEmpty, AutocompleteEmptyProps } from './autocomplete-empty.js';
6
6
  export { MultiAutocomplete, MultiAutocompleteProps } from './multi-autocomplete.js';
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(src_exports);
32
32
 
33
33
  // src/autocomplete.tsx
34
34
  var import_core4 = require("@yamada-ui/core");
35
- var import_popover2 = require("@yamada-ui/popover");
35
+ var import_popover3 = require("@yamada-ui/popover");
36
36
  var import_utils4 = require("@yamada-ui/utils");
37
37
 
38
38
  // src/autocomplete-icon.tsx
@@ -45,6 +45,7 @@ var import_react2 = require("react");
45
45
  // src/use-autocomplete.tsx
46
46
  var import_core = require("@yamada-ui/core");
47
47
  var import_form_control = require("@yamada-ui/form-control");
48
+ var import_popover = require("@yamada-ui/popover");
48
49
  var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
49
50
  var import_use_descendant = require("@yamada-ui/use-descendant");
50
51
  var import_use_outside_click = require("@yamada-ui/use-outside-click");
@@ -189,6 +190,7 @@ var useAutocomplete = ({
189
190
  closeOnBlur = true,
190
191
  closeOnEsc = true,
191
192
  allowCreate = false,
193
+ allowFree = false,
192
194
  insertPositionItem = "first",
193
195
  emptyMessage = "No results found",
194
196
  format = defaultFormat,
@@ -205,12 +207,13 @@ var useAutocomplete = ({
205
207
  const formControlProps = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
206
208
  const [containerProps, inputProps] = (0, import_utils.splitObject)(
207
209
  (0, import_utils.omitObject)(rest, [
210
+ ...import_popover.popoverProperties,
208
211
  "id",
209
212
  "value",
210
213
  "defaultValue",
211
214
  "onChange",
212
- "month",
213
- "onChangeMonth"
215
+ "onCreate",
216
+ "onSearch"
214
217
  ]),
215
218
  import_core.layoutStylesProperties
216
219
  );
@@ -475,6 +478,10 @@ var useAutocomplete = ({
475
478
  var _a;
476
479
  return (_a = node.textContent) != null ? _a : "";
477
480
  });
481
+ if (allowFree && selectedValues2.length === 0) {
482
+ selectedValues2.push(newValue);
483
+ setInputValue("");
484
+ }
478
485
  setDisplayValue((prev) => {
479
486
  if (!isMulti) {
480
487
  return selectedValues2[0];
@@ -491,7 +498,7 @@ var useAutocomplete = ({
491
498
  }
492
499
  });
493
500
  },
494
- [descendants, isMulti]
501
+ [descendants, isMulti, allowFree]
495
502
  );
496
503
  const onChange = (0, import_react.useCallback)(
497
504
  (newValue) => {
@@ -507,11 +514,26 @@ var useAutocomplete = ({
507
514
  }
508
515
  }
509
516
  });
517
+ const isHit2 = descendants.values().filter(
518
+ ({ node }) => {
519
+ var _a;
520
+ return format((_a = node.textContent) != null ? _a : "").includes(newValue);
521
+ }
522
+ ).length > 0;
510
523
  onChangeDisplayValue(newValue);
511
- setInputValue("");
524
+ if (!allowFree || isHit2) {
525
+ setInputValue("");
526
+ }
512
527
  rebirthOptions(false);
513
528
  },
514
- [onChangeDisplayValue, rebirthOptions, setValue]
529
+ [
530
+ allowFree,
531
+ onChangeDisplayValue,
532
+ rebirthOptions,
533
+ setValue,
534
+ descendants,
535
+ format
536
+ ]
515
537
  );
516
538
  const onSelect = (0, import_react.useCallback)(() => {
517
539
  var _a, _b;
@@ -645,11 +667,15 @@ var useAutocomplete = ({
645
667
  return;
646
668
  if (!closeOnBlur && isHit)
647
669
  return;
648
- setInputValue("");
670
+ if (allowFree && !!inputValue) {
671
+ onChange(inputValue);
672
+ } else {
673
+ setInputValue("");
674
+ }
649
675
  if (isOpen)
650
676
  onClose();
651
677
  },
652
- [closeOnBlur, isHit, isOpen, onClose]
678
+ [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
653
679
  );
654
680
  const onKeyDown = (0, import_react.useCallback)(
655
681
  (ev) => {
@@ -664,7 +690,11 @@ var useAutocomplete = ({
664
690
  ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
665
691
  ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusLastOrSelected) : void 0,
666
692
  Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
667
- Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
693
+ Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
694
+ if (inputValue)
695
+ onChange(inputValue);
696
+ setFocusedIndex(0);
697
+ } : void 0,
668
698
  Home: isOpen ? onFocusFirst : void 0,
669
699
  End: isOpen ? onFocusLast : void 0,
670
700
  Escape: closeOnEsc ? onClose : void 0,
@@ -678,11 +708,13 @@ var useAutocomplete = ({
678
708
  action(ev);
679
709
  },
680
710
  [
711
+ allowFree,
681
712
  formControlProps,
682
713
  displayValue,
683
714
  inputValue,
684
715
  onOpen,
685
716
  isFocused,
717
+ isMulti,
686
718
  onFocusFirstOrSelected,
687
719
  onFocusNext,
688
720
  onFocusLastOrSelected,
@@ -696,7 +728,8 @@ var useAutocomplete = ({
696
728
  closeOnEsc,
697
729
  onClose,
698
730
  isEmptyValue,
699
- onDelete
731
+ onDelete,
732
+ onChange
700
733
  ]
701
734
  );
702
735
  (0, import_react.useEffect)(() => {
@@ -721,7 +754,7 @@ var useAutocomplete = ({
721
754
  maxSelectedValues
722
755
  ]);
723
756
  (0, import_utils.useUpdateEffect)(() => {
724
- if (isOpen)
757
+ if (isOpen || allowFree)
725
758
  return;
726
759
  setFocusedIndex(-1);
727
760
  setInputValue("");
@@ -741,6 +774,7 @@ var useAutocomplete = ({
741
774
  });
742
775
  const getPopoverProps = (0, import_react.useCallback)(
743
776
  (props) => ({
777
+ matchWidth: true,
744
778
  ...rest,
745
779
  ...props,
746
780
  isOpen,
@@ -791,6 +825,7 @@ var useAutocomplete = ({
791
825
  omitSelectedValues,
792
826
  closeOnSelect,
793
827
  allowCreate,
828
+ allowFree,
794
829
  emptyMessage,
795
830
  isOpen,
796
831
  isAllSelected,
@@ -1268,7 +1303,7 @@ var AutocompleteItemIcon = (0, import_core2.forwardRef)(({ className, ...rest },
1268
1303
 
1269
1304
  // src/autocomplete-list.tsx
1270
1305
  var import_core3 = require("@yamada-ui/core");
1271
- var import_popover = require("@yamada-ui/popover");
1306
+ var import_popover2 = require("@yamada-ui/popover");
1272
1307
  var import_utils3 = require("@yamada-ui/utils");
1273
1308
  var import_jsx_runtime3 = require("react/jsx-runtime");
1274
1309
  var AutocompleteList = (0, import_core3.forwardRef)(
@@ -1280,7 +1315,7 @@ var AutocompleteList = (0, import_core3.forwardRef)(
1280
1315
  minW = (_h = minW != null ? minW : minWidth) != null ? _h : (_g = (_e = styles.list) == null ? void 0 : _e.minW) != null ? _g : (_f = styles.list) == null ? void 0 : _f.minWidth;
1281
1316
  const css = { ...styles.list };
1282
1317
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1283
- import_popover.PopoverContent,
1318
+ import_popover2.PopoverContent,
1284
1319
  {
1285
1320
  className: (0, import_utils3.cx)("ui-autocomplete__list", className),
1286
1321
  w,
@@ -1327,7 +1362,6 @@ var Autocomplete = (0, import_core4.forwardRef)(
1327
1362
  h != null ? h : h = height;
1328
1363
  minH != null ? minH : minH = minHeight;
1329
1364
  const css = {
1330
- position: "relative",
1331
1365
  w: "100%",
1332
1366
  h: "fit-content",
1333
1367
  color,
@@ -1344,23 +1378,32 @@ var Autocomplete = (0, import_core4.forwardRef)(
1344
1378
  isEmpty,
1345
1379
  styles
1346
1380
  },
1347
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover2.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1381
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover3.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1348
1382
  import_core4.ui.div,
1349
1383
  {
1350
1384
  className: (0, import_utils4.cx)("ui-autocomplete", className),
1351
1385
  __css: css,
1352
1386
  ...getContainerProps(containerProps),
1353
1387
  children: [
1354
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1355
- AutocompleteField,
1388
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1389
+ import_core4.ui.div,
1356
1390
  {
1357
- h,
1358
- minH,
1359
- inputProps,
1360
- ...getFieldProps({}, ref)
1391
+ className: "ui-autocomplete__inner",
1392
+ __css: { position: "relative", ...styles.inner },
1393
+ children: [
1394
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1395
+ AutocompleteField,
1396
+ {
1397
+ h,
1398
+ minH,
1399
+ inputProps,
1400
+ ...getFieldProps({}, ref)
1401
+ }
1402
+ ),
1403
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps })
1404
+ ]
1361
1405
  }
1362
1406
  ),
1363
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
1364
1407
  !isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(AutocompleteList, { ...listProps, children: [
1365
1408
  allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteEmpty, {}),
1366
1409
  children != null ? children : computedChildren
@@ -1385,7 +1428,7 @@ var AutocompleteField = (0, import_core4.forwardRef)(
1385
1428
  ...styles.field,
1386
1429
  cursor: "text"
1387
1430
  };
1388
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover2.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1431
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover3.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1389
1432
  import_core4.ui.div,
1390
1433
  {
1391
1434
  className: (0, import_utils4.cx)("ui-autocomplete__field", className),
@@ -1589,7 +1632,7 @@ var MinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { view
1589
1632
 
1590
1633
  // src/multi-autocomplete.tsx
1591
1634
  var import_core9 = require("@yamada-ui/core");
1592
- var import_popover3 = require("@yamada-ui/popover");
1635
+ var import_popover4 = require("@yamada-ui/popover");
1593
1636
  var import_utils9 = require("@yamada-ui/utils");
1594
1637
  var import_react3 = require("react");
1595
1638
  var import_jsx_runtime9 = require("react/jsx-runtime");
@@ -1642,7 +1685,6 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
1642
1685
  h != null ? h : h = height;
1643
1686
  minH != null ? minH : minH = minHeight;
1644
1687
  const css = {
1645
- position: "relative",
1646
1688
  w: "100%",
1647
1689
  h: "fit-content",
1648
1690
  color,
@@ -1660,33 +1702,42 @@ var MultiAutocomplete = (0, import_core9.forwardRef)(
1660
1702
  isEmpty,
1661
1703
  styles
1662
1704
  },
1663
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover3.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1705
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover4.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1664
1706
  import_core9.ui.div,
1665
1707
  {
1666
- className: (0, import_utils9.cx)("ui-autocomplete", className),
1708
+ className: (0, import_utils9.cx)("ui-multi-autocomplete", className),
1667
1709
  __css: css,
1668
1710
  ...getContainerProps(containerProps),
1669
1711
  children: [
1670
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1671
- MultiAutocompleteField,
1712
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1713
+ import_core9.ui.div,
1672
1714
  {
1673
- component,
1674
- separator,
1675
- keepPlaceholder,
1676
- h,
1677
- minH,
1678
- inputProps,
1679
- ...getFieldProps({}, ref)
1715
+ className: "ui-multi-autocomplete__inner",
1716
+ __css: { position: "relative", ...styles.inner },
1717
+ children: [
1718
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1719
+ MultiAutocompleteField,
1720
+ {
1721
+ component,
1722
+ separator,
1723
+ keepPlaceholder,
1724
+ h,
1725
+ minH,
1726
+ inputProps,
1727
+ ...getFieldProps({}, ref)
1728
+ }
1729
+ ),
1730
+ isClearable && value.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1731
+ AutocompleteClearIcon,
1732
+ {
1733
+ ...clearIconProps,
1734
+ onClick: (0, import_utils9.handlerAll)(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
1735
+ ...formControlProps
1736
+ }
1737
+ ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps })
1738
+ ]
1680
1739
  }
1681
1740
  ),
1682
- isClearable && value.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1683
- AutocompleteClearIcon,
1684
- {
1685
- ...clearIconProps,
1686
- onClick: (0, import_utils9.handlerAll)(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
1687
- ...formControlProps
1688
- }
1689
- ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
1690
1741
  !isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(AutocompleteList, { ...listProps, children: [
1691
1742
  allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, {}),
1692
1743
  children != null ? children : computedChildren
@@ -1765,10 +1816,10 @@ var MultiAutocompleteField = (0, import_core9.forwardRef)(
1765
1816
  ...styles.field,
1766
1817
  cursor: "text"
1767
1818
  };
1768
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover3.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1819
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover4.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1769
1820
  import_core9.ui.div,
1770
1821
  {
1771
- className: (0, import_utils9.cx)("ui-autocomplete__field", className),
1822
+ className: (0, import_utils9.cx)("ui-multi-autocomplete__field", className),
1772
1823
  __css: css,
1773
1824
  py: (displayValue == null ? void 0 : displayValue.length) && component ? "0.125rem" : void 0,
1774
1825
  ...rest,
@@ -1777,7 +1828,7 @@ var MultiAutocompleteField = (0, import_core9.forwardRef)(
1777
1828
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1778
1829
  import_core9.ui.input,
1779
1830
  {
1780
- className: (0, import_utils9.cx)("ui-autocomplete__field__input", className),
1831
+ className: "ui-multi-autocomplete__field__input",
1781
1832
  display: "inline-block",
1782
1833
  flex: "1",
1783
1834
  overflow: "hidden",