@yamada-ui/autocomplete 0.0.0-dev-20231208053121 → 0.0.0-dev-20231210171713

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.
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteCreate
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  AutocompleteCreate
7
7
  };
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteEmpty
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  AutocompleteEmpty
7
7
  };
@@ -3,7 +3,7 @@ import {
3
3
  AutocompleteClearIcon,
4
4
  AutocompleteIcon,
5
5
  AutocompleteItemIcon
6
- } from "./chunk-CIFWQ6SD.mjs";
6
+ } from "./chunk-EL55QO7P.mjs";
7
7
  export {
8
8
  AutocompleteClearIcon,
9
9
  AutocompleteIcon,
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteList
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  AutocompleteList
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
- import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-292DXnK-.mjs';
3
+ import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-PdT_PKFf.mjs';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
6
  import '@yamada-ui/form-control';
@@ -1,6 +1,6 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
- import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-292DXnK-.js';
3
+ import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-PdT_PKFf.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
6
  import '@yamada-ui/form-control';
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteOptionGroup
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  AutocompleteOptionGroup
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import '@yamada-ui/core';
2
2
  import 'react';
3
- export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-292DXnK-.mjs';
3
+ export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-PdT_PKFf.mjs';
4
4
  import 'react/jsx-runtime';
5
5
  import '@yamada-ui/form-control';
6
6
  import '@yamada-ui/popover';
@@ -1,6 +1,6 @@
1
1
  import '@yamada-ui/core';
2
2
  import 'react';
3
- export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-292DXnK-.js';
3
+ export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-PdT_PKFf.js';
4
4
  import 'react/jsx-runtime';
5
5
  import '@yamada-ui/form-control';
6
6
  import '@yamada-ui/popover';
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteOption
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  AutocompleteOption
7
7
  };
@@ -2,7 +2,7 @@ import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
3
  import { AutocompleteIconProps } from './autocomplete-icon.mjs';
4
4
  import { AutocompleteListProps } from './autocomplete-list.mjs';
5
- import { c as UseAutocompleteProps } from './use-autocomplete-292DXnK-.mjs';
5
+ import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.mjs';
6
6
  import 'react';
7
7
  import 'react/jsx-runtime';
8
8
  import '@yamada-ui/form-control';
@@ -2,7 +2,7 @@ import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
3
  import { AutocompleteIconProps } from './autocomplete-icon.js';
4
4
  import { AutocompleteListProps } from './autocomplete-list.js';
5
- import { c as UseAutocompleteProps } from './use-autocomplete-292DXnK-.js';
5
+ import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.js';
6
6
  import 'react';
7
7
  import 'react/jsx-runtime';
8
8
  import '@yamada-ui/form-control';
@@ -700,7 +700,7 @@ var useAutocomplete = ({
700
700
  [descendants, isMulti, allowFree]
701
701
  );
702
702
  const onChange = (0, import_react.useCallback)(
703
- (newValue) => {
703
+ (newValue, runRebirth = true) => {
704
704
  setValue((prev) => {
705
705
  if (!(0, import_utils6.isArray)(prev)) {
706
706
  return newValue;
@@ -720,12 +720,20 @@ var useAutocomplete = ({
720
720
  }
721
721
  ).length > 0;
722
722
  onChangeLabel(newValue);
723
- if (!allowFree || isHit2) {
723
+ if (!allowFree || isHit2)
724
724
  setInputValue("");
725
- }
726
- rebirthOptions(false);
725
+ if (isMulti && runRebirth)
726
+ rebirthOptions(false);
727
727
  },
728
- [allowFree, onChangeLabel, rebirthOptions, setValue, descendants, format]
728
+ [
729
+ allowFree,
730
+ isMulti,
731
+ onChangeLabel,
732
+ rebirthOptions,
733
+ setValue,
734
+ descendants,
735
+ format
736
+ ]
729
737
  );
730
738
  const onSelect = (0, import_react.useCallback)(() => {
731
739
  var _a, _b;
@@ -820,23 +828,6 @@ var useAutocomplete = ({
820
828
  secondInsertPositionItem,
821
829
  isMulti
822
830
  ]);
823
- const onDelete = (0, import_react.useCallback)(() => {
824
- if (!isMulti) {
825
- onChange("");
826
- } else {
827
- onChange(value[value.length - 1]);
828
- }
829
- }, [isMulti, onChange, value]);
830
- const onClear = (0, import_react.useCallback)(
831
- (ev) => {
832
- ev.stopPropagation();
833
- setValue([]);
834
- setLabel(void 0);
835
- setInputValue("");
836
- rebirthOptions();
837
- },
838
- [setLabel, setInputValue, setValue, rebirthOptions]
839
- );
840
831
  const onClick = (0, import_react.useCallback)(() => {
841
832
  if (isOpen) {
842
833
  if (inputRef.current)
@@ -859,16 +850,35 @@ var useAutocomplete = ({
859
850
  return;
860
851
  if (!closeOnBlur && isHit)
861
852
  return;
862
- if (allowFree && !!inputValue) {
863
- onChange(inputValue);
864
- } else {
865
- setInputValue("");
866
- }
853
+ if (allowFree && !!inputValue)
854
+ onChange(inputValue, false);
855
+ setInputValue("");
867
856
  if (isOpen)
868
857
  onClose();
869
858
  },
870
859
  [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
871
860
  );
861
+ const onDelete = (0, import_react.useCallback)(() => {
862
+ if (!isMulti) {
863
+ onChange("");
864
+ } else {
865
+ onChange(value[value.length - 1]);
866
+ }
867
+ if (!isOpen)
868
+ onFocus();
869
+ }, [isMulti, isOpen, onChange, onFocus, value]);
870
+ const onClear = (0, import_react.useCallback)(
871
+ (ev) => {
872
+ ev.stopPropagation();
873
+ setValue([]);
874
+ setLabel(void 0);
875
+ setInputValue("");
876
+ rebirthOptions();
877
+ if (isOpen && inputRef.current)
878
+ inputRef.current.focus();
879
+ },
880
+ [isOpen, setLabel, setInputValue, setValue, rebirthOptions]
881
+ );
872
882
  const onKeyDown = (0, import_react.useCallback)(
873
883
  (ev) => {
874
884
  if (ev.key === " ")
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  Autocomplete
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  Autocomplete
7
7
  };
@@ -1101,7 +1101,7 @@ var useAutocomplete = ({
1101
1101
  [descendants, isMulti, allowFree]
1102
1102
  );
1103
1103
  const onChange = useCallback(
1104
- (newValue) => {
1104
+ (newValue, runRebirth = true) => {
1105
1105
  setValue((prev) => {
1106
1106
  if (!isArray(prev)) {
1107
1107
  return newValue;
@@ -1121,12 +1121,20 @@ var useAutocomplete = ({
1121
1121
  }
1122
1122
  ).length > 0;
1123
1123
  onChangeLabel(newValue);
1124
- if (!allowFree || isHit2) {
1124
+ if (!allowFree || isHit2)
1125
1125
  setInputValue("");
1126
- }
1127
- rebirthOptions(false);
1126
+ if (isMulti && runRebirth)
1127
+ rebirthOptions(false);
1128
1128
  },
1129
- [allowFree, onChangeLabel, rebirthOptions, setValue, descendants, format]
1129
+ [
1130
+ allowFree,
1131
+ isMulti,
1132
+ onChangeLabel,
1133
+ rebirthOptions,
1134
+ setValue,
1135
+ descendants,
1136
+ format
1137
+ ]
1130
1138
  );
1131
1139
  const onSelect = useCallback(() => {
1132
1140
  var _a, _b;
@@ -1221,23 +1229,6 @@ var useAutocomplete = ({
1221
1229
  secondInsertPositionItem,
1222
1230
  isMulti
1223
1231
  ]);
1224
- const onDelete = useCallback(() => {
1225
- if (!isMulti) {
1226
- onChange("");
1227
- } else {
1228
- onChange(value[value.length - 1]);
1229
- }
1230
- }, [isMulti, onChange, value]);
1231
- const onClear = useCallback(
1232
- (ev) => {
1233
- ev.stopPropagation();
1234
- setValue([]);
1235
- setLabel(void 0);
1236
- setInputValue("");
1237
- rebirthOptions();
1238
- },
1239
- [setLabel, setInputValue, setValue, rebirthOptions]
1240
- );
1241
1232
  const onClick = useCallback(() => {
1242
1233
  if (isOpen) {
1243
1234
  if (inputRef.current)
@@ -1260,16 +1251,35 @@ var useAutocomplete = ({
1260
1251
  return;
1261
1252
  if (!closeOnBlur && isHit)
1262
1253
  return;
1263
- if (allowFree && !!inputValue) {
1264
- onChange(inputValue);
1265
- } else {
1266
- setInputValue("");
1267
- }
1254
+ if (allowFree && !!inputValue)
1255
+ onChange(inputValue, false);
1256
+ setInputValue("");
1268
1257
  if (isOpen)
1269
1258
  onClose();
1270
1259
  },
1271
1260
  [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
1272
1261
  );
1262
+ const onDelete = useCallback(() => {
1263
+ if (!isMulti) {
1264
+ onChange("");
1265
+ } else {
1266
+ onChange(value[value.length - 1]);
1267
+ }
1268
+ if (!isOpen)
1269
+ onFocus();
1270
+ }, [isMulti, isOpen, onChange, onFocus, value]);
1271
+ const onClear = useCallback(
1272
+ (ev) => {
1273
+ ev.stopPropagation();
1274
+ setValue([]);
1275
+ setLabel(void 0);
1276
+ setInputValue("");
1277
+ rebirthOptions();
1278
+ if (isOpen && inputRef.current)
1279
+ inputRef.current.focus();
1280
+ },
1281
+ [isOpen, setLabel, setInputValue, setValue, rebirthOptions]
1282
+ );
1273
1283
  const onKeyDown = useCallback(
1274
1284
  (ev) => {
1275
1285
  if (ev.key === " ")
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-292DXnK-.mjs';
3
+ export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-PdT_PKFf.mjs';
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-292DXnK-.js';
3
+ export { b as AutocompleteItem, A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-PdT_PKFf.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
@@ -501,7 +501,7 @@ var useAutocomplete = ({
501
501
  [descendants, isMulti, allowFree]
502
502
  );
503
503
  const onChange = (0, import_react.useCallback)(
504
- (newValue) => {
504
+ (newValue, runRebirth = true) => {
505
505
  setValue((prev) => {
506
506
  if (!(0, import_utils.isArray)(prev)) {
507
507
  return newValue;
@@ -521,12 +521,20 @@ var useAutocomplete = ({
521
521
  }
522
522
  ).length > 0;
523
523
  onChangeLabel(newValue);
524
- if (!allowFree || isHit2) {
524
+ if (!allowFree || isHit2)
525
525
  setInputValue("");
526
- }
527
- rebirthOptions(false);
526
+ if (isMulti && runRebirth)
527
+ rebirthOptions(false);
528
528
  },
529
- [allowFree, onChangeLabel, rebirthOptions, setValue, descendants, format]
529
+ [
530
+ allowFree,
531
+ isMulti,
532
+ onChangeLabel,
533
+ rebirthOptions,
534
+ setValue,
535
+ descendants,
536
+ format
537
+ ]
530
538
  );
531
539
  const onSelect = (0, import_react.useCallback)(() => {
532
540
  var _a, _b;
@@ -621,23 +629,6 @@ var useAutocomplete = ({
621
629
  secondInsertPositionItem,
622
630
  isMulti
623
631
  ]);
624
- const onDelete = (0, import_react.useCallback)(() => {
625
- if (!isMulti) {
626
- onChange("");
627
- } else {
628
- onChange(value[value.length - 1]);
629
- }
630
- }, [isMulti, onChange, value]);
631
- const onClear = (0, import_react.useCallback)(
632
- (ev) => {
633
- ev.stopPropagation();
634
- setValue([]);
635
- setLabel(void 0);
636
- setInputValue("");
637
- rebirthOptions();
638
- },
639
- [setLabel, setInputValue, setValue, rebirthOptions]
640
- );
641
632
  const onClick = (0, import_react.useCallback)(() => {
642
633
  if (isOpen) {
643
634
  if (inputRef.current)
@@ -660,16 +651,35 @@ var useAutocomplete = ({
660
651
  return;
661
652
  if (!closeOnBlur && isHit)
662
653
  return;
663
- if (allowFree && !!inputValue) {
664
- onChange(inputValue);
665
- } else {
666
- setInputValue("");
667
- }
654
+ if (allowFree && !!inputValue)
655
+ onChange(inputValue, false);
656
+ setInputValue("");
668
657
  if (isOpen)
669
658
  onClose();
670
659
  },
671
660
  [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
672
661
  );
662
+ const onDelete = (0, import_react.useCallback)(() => {
663
+ if (!isMulti) {
664
+ onChange("");
665
+ } else {
666
+ onChange(value[value.length - 1]);
667
+ }
668
+ if (!isOpen)
669
+ onFocus();
670
+ }, [isMulti, isOpen, onChange, onFocus, value]);
671
+ const onClear = (0, import_react.useCallback)(
672
+ (ev) => {
673
+ ev.stopPropagation();
674
+ setValue([]);
675
+ setLabel(void 0);
676
+ setInputValue("");
677
+ rebirthOptions();
678
+ if (isOpen && inputRef.current)
679
+ inputRef.current.focus();
680
+ },
681
+ [isOpen, setLabel, setInputValue, setValue, rebirthOptions]
682
+ );
673
683
  const onKeyDown = (0, import_react.useCallback)(
674
684
  (ev) => {
675
685
  if (ev.key === " ")
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  AutocompleteOption,
7
7
  AutocompleteOptionGroup,
8
8
  MultiAutocomplete
9
- } from "./chunk-CIFWQ6SD.mjs";
9
+ } from "./chunk-EL55QO7P.mjs";
10
10
  export {
11
11
  Autocomplete,
12
12
  AutocompleteCreate,
@@ -3,7 +3,7 @@ import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
3
  import { FC, MouseEventHandler } from 'react';
4
4
  import { AutocompleteIconProps } from './autocomplete-icon.mjs';
5
5
  import { AutocompleteListProps } from './autocomplete-list.mjs';
6
- import { c as UseAutocompleteProps } from './use-autocomplete-292DXnK-.mjs';
6
+ import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.mjs';
7
7
  import 'react/jsx-runtime';
8
8
  import '@yamada-ui/form-control';
9
9
  import '@yamada-ui/popover';
@@ -3,7 +3,7 @@ import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
3
  import { FC, MouseEventHandler } from 'react';
4
4
  import { AutocompleteIconProps } from './autocomplete-icon.js';
5
5
  import { AutocompleteListProps } from './autocomplete-list.js';
6
- import { c as UseAutocompleteProps } from './use-autocomplete-292DXnK-.js';
6
+ import { c as UseAutocompleteProps } from './use-autocomplete-PdT_PKFf.js';
7
7
  import 'react/jsx-runtime';
8
8
  import '@yamada-ui/form-control';
9
9
  import '@yamada-ui/popover';
@@ -701,7 +701,7 @@ var useAutocomplete = ({
701
701
  [descendants, isMulti, allowFree]
702
702
  );
703
703
  const onChange = (0, import_react.useCallback)(
704
- (newValue) => {
704
+ (newValue, runRebirth = true) => {
705
705
  setValue((prev) => {
706
706
  if (!(0, import_utils6.isArray)(prev)) {
707
707
  return newValue;
@@ -721,12 +721,20 @@ var useAutocomplete = ({
721
721
  }
722
722
  ).length > 0;
723
723
  onChangeLabel(newValue);
724
- if (!allowFree || isHit2) {
724
+ if (!allowFree || isHit2)
725
725
  setInputValue("");
726
- }
727
- rebirthOptions(false);
726
+ if (isMulti && runRebirth)
727
+ rebirthOptions(false);
728
728
  },
729
- [allowFree, onChangeLabel, rebirthOptions, setValue, descendants, format]
729
+ [
730
+ allowFree,
731
+ isMulti,
732
+ onChangeLabel,
733
+ rebirthOptions,
734
+ setValue,
735
+ descendants,
736
+ format
737
+ ]
730
738
  );
731
739
  const onSelect = (0, import_react.useCallback)(() => {
732
740
  var _a, _b;
@@ -821,23 +829,6 @@ var useAutocomplete = ({
821
829
  secondInsertPositionItem,
822
830
  isMulti
823
831
  ]);
824
- const onDelete = (0, import_react.useCallback)(() => {
825
- if (!isMulti) {
826
- onChange("");
827
- } else {
828
- onChange(value[value.length - 1]);
829
- }
830
- }, [isMulti, onChange, value]);
831
- const onClear = (0, import_react.useCallback)(
832
- (ev) => {
833
- ev.stopPropagation();
834
- setValue([]);
835
- setLabel(void 0);
836
- setInputValue("");
837
- rebirthOptions();
838
- },
839
- [setLabel, setInputValue, setValue, rebirthOptions]
840
- );
841
832
  const onClick = (0, import_react.useCallback)(() => {
842
833
  if (isOpen) {
843
834
  if (inputRef.current)
@@ -860,16 +851,35 @@ var useAutocomplete = ({
860
851
  return;
861
852
  if (!closeOnBlur && isHit)
862
853
  return;
863
- if (allowFree && !!inputValue) {
864
- onChange(inputValue);
865
- } else {
866
- setInputValue("");
867
- }
854
+ if (allowFree && !!inputValue)
855
+ onChange(inputValue, false);
856
+ setInputValue("");
868
857
  if (isOpen)
869
858
  onClose();
870
859
  },
871
860
  [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
872
861
  );
862
+ const onDelete = (0, import_react.useCallback)(() => {
863
+ if (!isMulti) {
864
+ onChange("");
865
+ } else {
866
+ onChange(value[value.length - 1]);
867
+ }
868
+ if (!isOpen)
869
+ onFocus();
870
+ }, [isMulti, isOpen, onChange, onFocus, value]);
871
+ const onClear = (0, import_react.useCallback)(
872
+ (ev) => {
873
+ ev.stopPropagation();
874
+ setValue([]);
875
+ setLabel(void 0);
876
+ setInputValue("");
877
+ rebirthOptions();
878
+ if (isOpen && inputRef.current)
879
+ inputRef.current.focus();
880
+ },
881
+ [isOpen, setLabel, setInputValue, setValue, rebirthOptions]
882
+ );
873
883
  const onKeyDown = (0, import_react.useCallback)(
874
884
  (ev) => {
875
885
  if (ev.key === " ")
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  MultiAutocomplete
4
- } from "./chunk-CIFWQ6SD.mjs";
4
+ } from "./chunk-EL55QO7P.mjs";
5
5
  export {
6
6
  MultiAutocomplete
7
7
  };
@@ -3376,7 +3376,7 @@ type UseAutocompleteBaseProps<T extends string | string[] = string> = Omit<Popov
3376
3376
  */
3377
3377
  onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
3378
3378
  /**
3379
- * The callback invoked when autocomlete option created.
3379
+ * The callback invoked when autocomplete option created.
3380
3380
  */
3381
3381
  onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
3382
3382
  /**
@@ -4052,7 +4052,7 @@ declare const useAutocomplete: <T extends string | string[] = string>({ defaultI
4052
4052
  };
4053
4053
  setFocusedIndex: Dispatch<SetStateAction<number>>;
4054
4054
  onChangeLabel: (newValue: string, runOmit?: boolean) => void;
4055
- onChange: (newValue: string) => void;
4055
+ onChange: (newValue: string, runRebirth?: boolean) => void;
4056
4056
  onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
4057
4057
  onCreate: () => void;
4058
4058
  onClear: (ev: MouseEvent<HTMLDivElement>) => void;
@@ -3376,7 +3376,7 @@ type UseAutocompleteBaseProps<T extends string | string[] = string> = Omit<Popov
3376
3376
  */
3377
3377
  onSearch?: (ev: ChangeEvent<HTMLInputElement>) => void;
3378
3378
  /**
3379
- * The callback invoked when autocomlete option created.
3379
+ * The callback invoked when autocomplete option created.
3380
3380
  */
3381
3381
  onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void;
3382
3382
  /**
@@ -4052,7 +4052,7 @@ declare const useAutocomplete: <T extends string | string[] = string>({ defaultI
4052
4052
  };
4053
4053
  setFocusedIndex: Dispatch<SetStateAction<number>>;
4054
4054
  onChangeLabel: (newValue: string, runOmit?: boolean) => void;
4055
- onChange: (newValue: string) => void;
4055
+ onChange: (newValue: string, runRebirth?: boolean) => void;
4056
4056
  onSearch: (ev: ChangeEvent<HTMLInputElement>) => void;
4057
4057
  onCreate: () => void;
4058
4058
  onClear: (ev: MouseEvent<HTMLDivElement>) => void;
@@ -4,4 +4,4 @@ import '@yamada-ui/core';
4
4
  import '@yamada-ui/form-control';
5
5
  import '@yamada-ui/popover';
6
6
  import '@yamada-ui/utils';
7
- export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-292DXnK-.mjs';
7
+ export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-PdT_PKFf.mjs';
@@ -4,4 +4,4 @@ import '@yamada-ui/core';
4
4
  import '@yamada-ui/form-control';
5
5
  import '@yamada-ui/popover';
6
6
  import '@yamada-ui/utils';
7
- export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-292DXnK-.js';
7
+ export { d as AutocompleteDescendantsContextProvider, b as AutocompleteItem, g as AutocompleteProvider, t as UseAutocompleteCreateReturn, w as UseAutocompleteEmptyReturn, l as UseAutocompleteInputReturn, U as UseAutocompleteOptionGroupProps, o as UseAutocompleteOptionGroupReturn, p as UseAutocompleteOptionProps, r as UseAutocompleteOptionReturn, c as UseAutocompleteProps, j as UseAutocompleteReturn, i as useAutocomplete, h as useAutocompleteContext, s as useAutocompleteCreate, f as useAutocompleteDescendant, e as useAutocompleteDescendants, u as useAutocompleteDescendantsContext, v as useAutocompleteEmpty, k as useAutocompleteInput, m as useAutocompleteList, q as useAutocompleteOption, n as useAutocompleteOptionGroup } from './use-autocomplete-PdT_PKFf.js';
@@ -652,7 +652,7 @@ var useAutocomplete = ({
652
652
  [descendants, isMulti, allowFree]
653
653
  );
654
654
  const onChange = (0, import_react2.useCallback)(
655
- (newValue) => {
655
+ (newValue, runRebirth = true) => {
656
656
  setValue((prev) => {
657
657
  if (!(0, import_utils4.isArray)(prev)) {
658
658
  return newValue;
@@ -672,12 +672,20 @@ var useAutocomplete = ({
672
672
  }
673
673
  ).length > 0;
674
674
  onChangeLabel(newValue);
675
- if (!allowFree || isHit2) {
675
+ if (!allowFree || isHit2)
676
676
  setInputValue("");
677
- }
678
- rebirthOptions(false);
677
+ if (isMulti && runRebirth)
678
+ rebirthOptions(false);
679
679
  },
680
- [allowFree, onChangeLabel, rebirthOptions, setValue, descendants, format]
680
+ [
681
+ allowFree,
682
+ isMulti,
683
+ onChangeLabel,
684
+ rebirthOptions,
685
+ setValue,
686
+ descendants,
687
+ format
688
+ ]
681
689
  );
682
690
  const onSelect = (0, import_react2.useCallback)(() => {
683
691
  var _a, _b;
@@ -772,23 +780,6 @@ var useAutocomplete = ({
772
780
  secondInsertPositionItem,
773
781
  isMulti
774
782
  ]);
775
- const onDelete = (0, import_react2.useCallback)(() => {
776
- if (!isMulti) {
777
- onChange("");
778
- } else {
779
- onChange(value[value.length - 1]);
780
- }
781
- }, [isMulti, onChange, value]);
782
- const onClear = (0, import_react2.useCallback)(
783
- (ev) => {
784
- ev.stopPropagation();
785
- setValue([]);
786
- setLabel(void 0);
787
- setInputValue("");
788
- rebirthOptions();
789
- },
790
- [setLabel, setInputValue, setValue, rebirthOptions]
791
- );
792
783
  const onClick = (0, import_react2.useCallback)(() => {
793
784
  if (isOpen) {
794
785
  if (inputRef.current)
@@ -811,16 +802,35 @@ var useAutocomplete = ({
811
802
  return;
812
803
  if (!closeOnBlur && isHit)
813
804
  return;
814
- if (allowFree && !!inputValue) {
815
- onChange(inputValue);
816
- } else {
817
- setInputValue("");
818
- }
805
+ if (allowFree && !!inputValue)
806
+ onChange(inputValue, false);
807
+ setInputValue("");
819
808
  if (isOpen)
820
809
  onClose();
821
810
  },
822
811
  [closeOnBlur, isHit, isOpen, inputValue, allowFree, onClose, onChange]
823
812
  );
813
+ const onDelete = (0, import_react2.useCallback)(() => {
814
+ if (!isMulti) {
815
+ onChange("");
816
+ } else {
817
+ onChange(value[value.length - 1]);
818
+ }
819
+ if (!isOpen)
820
+ onFocus();
821
+ }, [isMulti, isOpen, onChange, onFocus, value]);
822
+ const onClear = (0, import_react2.useCallback)(
823
+ (ev) => {
824
+ ev.stopPropagation();
825
+ setValue([]);
826
+ setLabel(void 0);
827
+ setInputValue("");
828
+ rebirthOptions();
829
+ if (isOpen && inputRef.current)
830
+ inputRef.current.focus();
831
+ },
832
+ [isOpen, setLabel, setInputValue, setValue, rebirthOptions]
833
+ );
824
834
  const onKeyDown = (0, import_react2.useCallback)(
825
835
  (ev) => {
826
836
  if (ev.key === " ")
@@ -13,7 +13,7 @@ import {
13
13
  useAutocompleteList,
14
14
  useAutocompleteOption,
15
15
  useAutocompleteOptionGroup
16
- } from "./chunk-CIFWQ6SD.mjs";
16
+ } from "./chunk-EL55QO7P.mjs";
17
17
  export {
18
18
  AutocompleteDescendantsContextProvider,
19
19
  AutocompleteProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/autocomplete",
3
- "version": "0.0.0-dev-20231208053121",
3
+ "version": "0.0.0-dev-20231210171713",
4
4
  "description": "Yamada UI autocomplete component",
5
5
  "keywords": [
6
6
  "yamada",
@@ -36,16 +36,16 @@
36
36
  "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
37
37
  },
38
38
  "dependencies": {
39
- "@yamada-ui/core": "0.0.0-dev-20231208053121",
40
- "@yamada-ui/utils": "0.0.0-dev-20231208053121",
41
- "@yamada-ui/icon": "0.0.0-dev-20231208053121",
42
- "@yamada-ui/select": "0.0.0-dev-20231208053121",
43
- "@yamada-ui/form-control": "0.0.0-dev-20231208053121",
44
- "@yamada-ui/popover": "0.0.0-dev-20231208053121",
45
- "@yamada-ui/use-descendant": "0.0.0-dev-20231208053121",
46
- "@yamada-ui/use-clickable": "0.0.0-dev-20231208053121",
47
- "@yamada-ui/use-outside-click": "0.0.0-dev-20231208053121",
48
- "@yamada-ui/use-controllable-state": "0.0.0-dev-20231208053121"
39
+ "@yamada-ui/core": "0.13.2",
40
+ "@yamada-ui/utils": "0.4.1",
41
+ "@yamada-ui/icon": "0.3.21",
42
+ "@yamada-ui/select": "0.0.0-dev-20231210171713",
43
+ "@yamada-ui/form-control": "0.3.24",
44
+ "@yamada-ui/popover": "0.3.28",
45
+ "@yamada-ui/use-descendant": "0.2.9",
46
+ "@yamada-ui/use-clickable": "0.3.8",
47
+ "@yamada-ui/use-outside-click": "0.2.8",
48
+ "@yamada-ui/use-controllable-state": "0.4.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "react": "^18.0.0",