@yamada-ui/autocomplete 0.4.13 → 0.5.2

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 (37) hide show
  1. package/dist/autocomplete-create.d.mts +1 -1
  2. package/dist/autocomplete-create.d.ts +1 -1
  3. package/dist/autocomplete-create.mjs +1 -1
  4. package/dist/autocomplete-empty.d.mts +1 -1
  5. package/dist/autocomplete-empty.d.ts +1 -1
  6. package/dist/autocomplete-empty.mjs +1 -1
  7. package/dist/autocomplete-icon.d.mts +2 -2
  8. package/dist/autocomplete-icon.d.ts +2 -2
  9. package/dist/autocomplete-icon.mjs +1 -1
  10. package/dist/autocomplete-list.d.mts +1 -1
  11. package/dist/autocomplete-list.d.ts +1 -1
  12. package/dist/autocomplete-list.mjs +1 -1
  13. package/dist/autocomplete-option-group.d.mts +2 -3
  14. package/dist/autocomplete-option-group.d.ts +2 -3
  15. package/dist/autocomplete-option-group.mjs +1 -1
  16. package/dist/autocomplete-option.d.mts +1 -2
  17. package/dist/autocomplete-option.d.ts +1 -2
  18. package/dist/autocomplete-option.mjs +1 -1
  19. package/dist/autocomplete.d.mts +5 -6
  20. package/dist/autocomplete.d.ts +5 -6
  21. package/dist/autocomplete.js +57 -60
  22. package/dist/autocomplete.mjs +1 -1
  23. package/dist/{chunk-EFOFI4S7.mjs → chunk-JKY5MMNC.mjs} +61 -64
  24. package/dist/index.d.mts +1 -2
  25. package/dist/index.d.ts +1 -2
  26. package/dist/index.js +61 -64
  27. package/dist/index.mjs +1 -1
  28. package/dist/multi-autocomplete.d.mts +5 -6
  29. package/dist/multi-autocomplete.d.ts +5 -6
  30. package/dist/multi-autocomplete.js +57 -60
  31. package/dist/multi-autocomplete.mjs +1 -1
  32. package/dist/{use-autocomplete-2422c1c8.d.ts → use-autocomplete-3e77a4da.d.ts} +31 -42
  33. package/dist/use-autocomplete.d.mts +1 -2
  34. package/dist/use-autocomplete.d.ts +1 -2
  35. package/dist/use-autocomplete.js +53 -56
  36. package/dist/use-autocomplete.mjs +1 -1
  37. package/package.json +6 -6
@@ -12,7 +12,7 @@ type AutocompleteCreateOptions = {
12
12
  */
13
13
  children?: string | ((inputValue: string) => string);
14
14
  };
15
- type AutocompleteCreateProps = Omit<HTMLUIProps<'li'>, 'children'> & AutocompleteCreateOptions;
15
+ type AutocompleteCreateProps = Omit<HTMLUIProps<"li">, "children"> & AutocompleteCreateOptions;
16
16
  declare const AutocompleteCreate: _yamada_ui_core.Component<"li", AutocompleteCreateProps>;
17
17
 
18
18
  export { AutocompleteCreate, AutocompleteCreateProps };
@@ -12,7 +12,7 @@ type AutocompleteCreateOptions = {
12
12
  */
13
13
  children?: string | ((inputValue: string) => string);
14
14
  };
15
- type AutocompleteCreateProps = Omit<HTMLUIProps<'li'>, 'children'> & AutocompleteCreateOptions;
15
+ type AutocompleteCreateProps = Omit<HTMLUIProps<"li">, "children"> & AutocompleteCreateOptions;
16
16
  declare const AutocompleteCreate: _yamada_ui_core.Component<"li", AutocompleteCreateProps>;
17
17
 
18
18
  export { AutocompleteCreate, AutocompleteCreateProps };
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteCreate
4
- } from "./chunk-EFOFI4S7.mjs";
4
+ } from "./chunk-JKY5MMNC.mjs";
5
5
  export {
6
6
  AutocompleteCreate
7
7
  };
@@ -12,7 +12,7 @@ type AutocompleteEmptyOptions = {
12
12
  */
13
13
  children?: string;
14
14
  };
15
- type AutocompleteEmptyProps = Omit<HTMLUIProps<'li'>, 'children'> & AutocompleteEmptyOptions;
15
+ type AutocompleteEmptyProps = Omit<HTMLUIProps<"li">, "children"> & AutocompleteEmptyOptions;
16
16
  declare const AutocompleteEmpty: _yamada_ui_core.Component<"li", AutocompleteEmptyProps>;
17
17
 
18
18
  export { AutocompleteEmpty, AutocompleteEmptyProps };
@@ -12,7 +12,7 @@ type AutocompleteEmptyOptions = {
12
12
  */
13
13
  children?: string;
14
14
  };
15
- type AutocompleteEmptyProps = Omit<HTMLUIProps<'li'>, 'children'> & AutocompleteEmptyOptions;
15
+ type AutocompleteEmptyProps = Omit<HTMLUIProps<"li">, "children"> & AutocompleteEmptyOptions;
16
16
  declare const AutocompleteEmpty: _yamada_ui_core.Component<"li", AutocompleteEmptyProps>;
17
17
 
18
18
  export { AutocompleteEmpty, AutocompleteEmptyProps };
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteEmpty
4
- } from "./chunk-EFOFI4S7.mjs";
4
+ } from "./chunk-JKY5MMNC.mjs";
5
5
  export {
6
6
  AutocompleteEmpty
7
7
  };
@@ -2,13 +2,13 @@ import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
3
  import { FC } from 'react';
4
4
 
5
- type AutocompleteIconProps = HTMLUIProps<'div'>;
5
+ type AutocompleteIconProps = HTMLUIProps<"div">;
6
6
  declare const AutocompleteIcon: _yamada_ui_core.Component<"div", AutocompleteIconProps>;
7
7
  type AutocompleteClearIconProps = AutocompleteIconProps & {
8
8
  disabled?: boolean;
9
9
  };
10
10
  declare const AutocompleteClearIcon: FC<AutocompleteClearIconProps>;
11
- type AutocompleteItemIconProps = HTMLUIProps<'span'>;
11
+ type AutocompleteItemIconProps = HTMLUIProps<"span">;
12
12
  declare const AutocompleteItemIcon: _yamada_ui_core.Component<"span", AutocompleteItemIconProps>;
13
13
 
14
14
  export { AutocompleteClearIcon, AutocompleteClearIconProps, AutocompleteIcon, AutocompleteIconProps, AutocompleteItemIcon, AutocompleteItemIconProps };
@@ -2,13 +2,13 @@ import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
3
  import { FC } from 'react';
4
4
 
5
- type AutocompleteIconProps = HTMLUIProps<'div'>;
5
+ type AutocompleteIconProps = HTMLUIProps<"div">;
6
6
  declare const AutocompleteIcon: _yamada_ui_core.Component<"div", AutocompleteIconProps>;
7
7
  type AutocompleteClearIconProps = AutocompleteIconProps & {
8
8
  disabled?: boolean;
9
9
  };
10
10
  declare const AutocompleteClearIcon: FC<AutocompleteClearIconProps>;
11
- type AutocompleteItemIconProps = HTMLUIProps<'span'>;
11
+ type AutocompleteItemIconProps = HTMLUIProps<"span">;
12
12
  declare const AutocompleteItemIcon: _yamada_ui_core.Component<"span", AutocompleteItemIconProps>;
13
13
 
14
14
  export { AutocompleteClearIcon, AutocompleteClearIconProps, AutocompleteIcon, AutocompleteIconProps, AutocompleteItemIcon, AutocompleteItemIconProps };
@@ -3,7 +3,7 @@ import {
3
3
  AutocompleteClearIcon,
4
4
  AutocompleteIcon,
5
5
  AutocompleteItemIcon
6
- } from "./chunk-EFOFI4S7.mjs";
6
+ } from "./chunk-JKY5MMNC.mjs";
7
7
  export {
8
8
  AutocompleteClearIcon,
9
9
  AutocompleteIcon,
@@ -1,7 +1,7 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
3
 
4
- type AutocompleteListProps = HTMLUIProps<'ul'>;
4
+ type AutocompleteListProps = HTMLUIProps<"ul">;
5
5
  declare const AutocompleteList: _yamada_ui_core.Component<"ul", AutocompleteListProps>;
6
6
 
7
7
  export { AutocompleteList, AutocompleteListProps };
@@ -1,7 +1,7 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
3
 
4
- type AutocompleteListProps = HTMLUIProps<'ul'>;
4
+ type AutocompleteListProps = HTMLUIProps<"ul">;
5
5
  declare const AutocompleteList: _yamada_ui_core.Component<"ul", AutocompleteListProps>;
6
6
 
7
7
  export { AutocompleteList, AutocompleteListProps };
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteList
4
- } from "./chunk-EFOFI4S7.mjs";
4
+ } from "./chunk-JKY5MMNC.mjs";
5
5
  export {
6
6
  AutocompleteList
7
7
  };
@@ -1,15 +1,14 @@
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-2422c1c8.js';
3
+ import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-3e77a4da.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
6
  import '@yamada-ui/form-control';
7
7
  import '@yamada-ui/popover';
8
- import '@yamada-ui/select';
9
8
  import '@yamada-ui/utils';
10
9
 
11
10
  type AutocompleteOptionGroupOptions = UseAutocompleteOptionGroupProps;
12
- type AutocompleteOptionGroupProps = HTMLUIProps<'ul'> & AutocompleteOptionGroupOptions;
11
+ type AutocompleteOptionGroupProps = HTMLUIProps<"ul"> & AutocompleteOptionGroupOptions;
13
12
  declare const AutocompleteOptionGroup: _yamada_ui_core.Component<"ul", AutocompleteOptionGroupProps>;
14
13
 
15
14
  export { AutocompleteOptionGroup, AutocompleteOptionGroupProps };
@@ -1,15 +1,14 @@
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-2422c1c8.js';
3
+ import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-3e77a4da.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
6
  import '@yamada-ui/form-control';
7
7
  import '@yamada-ui/popover';
8
- import '@yamada-ui/select';
9
8
  import '@yamada-ui/utils';
10
9
 
11
10
  type AutocompleteOptionGroupOptions = UseAutocompleteOptionGroupProps;
12
- type AutocompleteOptionGroupProps = HTMLUIProps<'ul'> & AutocompleteOptionGroupOptions;
11
+ type AutocompleteOptionGroupProps = HTMLUIProps<"ul"> & AutocompleteOptionGroupOptions;
13
12
  declare const AutocompleteOptionGroup: _yamada_ui_core.Component<"ul", AutocompleteOptionGroupProps>;
14
13
 
15
14
  export { AutocompleteOptionGroup, AutocompleteOptionGroupProps };
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteOptionGroup
4
- } from "./chunk-EFOFI4S7.mjs";
4
+ } from "./chunk-JKY5MMNC.mjs";
5
5
  export {
6
6
  AutocompleteOptionGroup
7
7
  };
@@ -1,8 +1,7 @@
1
1
  import '@yamada-ui/core';
2
2
  import 'react';
3
- export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-2422c1c8.js';
3
+ export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-3e77a4da.js';
4
4
  import 'react/jsx-runtime';
5
5
  import '@yamada-ui/form-control';
6
6
  import '@yamada-ui/popover';
7
- import '@yamada-ui/select';
8
7
  import '@yamada-ui/utils';
@@ -1,8 +1,7 @@
1
1
  import '@yamada-ui/core';
2
2
  import 'react';
3
- export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-2422c1c8.js';
3
+ export { A as AutocompleteOption, a as AutocompleteOptionProps } from './use-autocomplete-3e77a4da.js';
4
4
  import 'react/jsx-runtime';
5
5
  import '@yamada-ui/form-control';
6
6
  import '@yamada-ui/popover';
7
- import '@yamada-ui/select';
8
7
  import '@yamada-ui/utils';
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  AutocompleteOption
4
- } from "./chunk-EFOFI4S7.mjs";
4
+ } from "./chunk-JKY5MMNC.mjs";
5
5
  export {
6
6
  AutocompleteOption
7
7
  };
@@ -2,12 +2,11 @@ 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 { b as UseAutocompleteProps } from './use-autocomplete-2422c1c8.js';
5
+ import { c as UseAutocompleteProps } from './use-autocomplete-3e77a4da.js';
6
6
  import 'react';
7
7
  import 'react/jsx-runtime';
8
8
  import '@yamada-ui/form-control';
9
9
  import '@yamada-ui/popover';
10
- import '@yamada-ui/select';
11
10
  import '@yamada-ui/utils';
12
11
 
13
12
  type AutocompleteOptions = {
@@ -22,21 +21,21 @@ type AutocompleteOptions = {
22
21
  /**
23
22
  * Props for autocomplete container element.
24
23
  */
25
- containerProps?: Omit<HTMLUIProps<'div'>, 'children'>;
24
+ containerProps?: Omit<HTMLUIProps<"div">, "children">;
26
25
  /**
27
26
  * Props for autocomplete list element.
28
27
  */
29
- listProps?: Omit<AutocompleteListProps, 'children'>;
28
+ listProps?: Omit<AutocompleteListProps, "children">;
30
29
  /**
31
30
  * Props for autocomplete input element.
32
31
  */
33
- inputProps?: HTMLUIProps<'input'>;
32
+ inputProps?: HTMLUIProps<"input">;
34
33
  /**
35
34
  * Props for autocomplete icon element.
36
35
  */
37
36
  iconProps?: AutocompleteIconProps;
38
37
  };
39
- type AutocompleteProps = ThemeProps<'Select'> & Omit<UseAutocompleteProps<string>, 'maxSelectedValues' | 'omitSelectedValues'> & AutocompleteOptions;
38
+ type AutocompleteProps = ThemeProps<"Select"> & Omit<UseAutocompleteProps<string>, "maxSelectedValues" | "omitSelectedValues"> & AutocompleteOptions;
40
39
  declare const Autocomplete: _yamada_ui_core.Component<"input", AutocompleteProps>;
41
40
 
42
41
  export { Autocomplete, AutocompleteProps };
@@ -2,12 +2,11 @@ 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 { b as UseAutocompleteProps } from './use-autocomplete-2422c1c8.js';
5
+ import { c as UseAutocompleteProps } from './use-autocomplete-3e77a4da.js';
6
6
  import 'react';
7
7
  import 'react/jsx-runtime';
8
8
  import '@yamada-ui/form-control';
9
9
  import '@yamada-ui/popover';
10
- import '@yamada-ui/select';
11
10
  import '@yamada-ui/utils';
12
11
 
13
12
  type AutocompleteOptions = {
@@ -22,21 +21,21 @@ type AutocompleteOptions = {
22
21
  /**
23
22
  * Props for autocomplete container element.
24
23
  */
25
- containerProps?: Omit<HTMLUIProps<'div'>, 'children'>;
24
+ containerProps?: Omit<HTMLUIProps<"div">, "children">;
26
25
  /**
27
26
  * Props for autocomplete list element.
28
27
  */
29
- listProps?: Omit<AutocompleteListProps, 'children'>;
28
+ listProps?: Omit<AutocompleteListProps, "children">;
30
29
  /**
31
30
  * Props for autocomplete input element.
32
31
  */
33
- inputProps?: HTMLUIProps<'input'>;
32
+ inputProps?: HTMLUIProps<"input">;
34
33
  /**
35
34
  * Props for autocomplete icon element.
36
35
  */
37
36
  iconProps?: AutocompleteIconProps;
38
37
  };
39
- type AutocompleteProps = ThemeProps<'Select'> & Omit<UseAutocompleteProps<string>, 'maxSelectedValues' | 'omitSelectedValues'> & AutocompleteOptions;
38
+ type AutocompleteProps = ThemeProps<"Select"> & Omit<UseAutocompleteProps<string>, "maxSelectedValues" | "omitSelectedValues"> & AutocompleteOptions;
40
39
  declare const Autocomplete: _yamada_ui_core.Component<"input", AutocompleteProps>;
41
40
 
42
41
  export { Autocomplete, AutocompleteProps };
@@ -351,20 +351,20 @@ var defaultFormat = (value) => {
351
351
  value = value.toUpperCase();
352
352
  return value;
353
353
  };
354
- var flattenOptions = (options) => {
355
- const filterOptions = (options2) => options2.map((options3) => {
356
- const { value, isDisabled, isFocusable } = options3;
354
+ var flattenItems = (items) => {
355
+ const filterItems = (items2) => items2.map((item) => {
356
+ var _a;
357
+ const { isDisabled, isFocusable } = item;
357
358
  const trulyDisabled = !!isDisabled && !isFocusable;
358
- const isMulti = (0, import_utils6.isArray)(value);
359
359
  if (trulyDisabled)
360
360
  return;
361
- if (!isMulti) {
362
- return options3;
361
+ if ("items" in item) {
362
+ return filterItems((_a = item.items) != null ? _a : []);
363
363
  } else {
364
- return filterOptions(value);
364
+ return item;
365
365
  }
366
366
  }).filter(Boolean);
367
- return filterOptions(options).flat(Infinity);
367
+ return filterItems(items).flat(Infinity);
368
368
  };
369
369
  var isTargetOption = (target) => {
370
370
  var _a;
@@ -387,14 +387,15 @@ var useAutocomplete = ({
387
387
  maxSelectedValues,
388
388
  closeOnBlur = true,
389
389
  closeOnEsc = true,
390
- createOption = false,
391
- insertPositionOnCreate = "first",
390
+ allowCreate = false,
391
+ insertPositionItem = "first",
392
392
  emptyMessage = "No results found",
393
393
  format = defaultFormat,
394
394
  placement = "bottom-start",
395
395
  duration = 0.2,
396
396
  optionProps,
397
397
  placeholder,
398
+ items,
398
399
  children,
399
400
  ...rest
400
401
  }) => {
@@ -418,7 +419,7 @@ var useAutocomplete = ({
418
419
  const inputRef = (0, import_react.useRef)(null);
419
420
  const timeoutIds = (0, import_react.useRef)(/* @__PURE__ */ new Set([]));
420
421
  const isComposition = (0, import_react.useRef)(false);
421
- const [options, setOptions] = (0, import_react.useState)(rest.options);
422
+ const [resolvedItems, setResolvedItems] = (0, import_react.useState)(items);
422
423
  const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
423
424
  value: rest.value,
424
425
  defaultValue: rest.defaultValue,
@@ -431,19 +432,19 @@ var useAutocomplete = ({
431
432
  const [isHit, setIsHit] = (0, import_react.useState)(true);
432
433
  const [isOpen, setIsOpen] = (0, import_react.useState)(defaultIsOpen != null ? defaultIsOpen : false);
433
434
  const isFocused = focusedIndex > -1;
434
- const isCreate = focusedIndex === -2 && createOption;
435
+ const isCreate = focusedIndex === -2 && allowCreate;
435
436
  const isMulti = (0, import_utils6.isArray)(value);
436
437
  const isEmptyValue = !isMulti ? !value : !value.length;
437
- const [firstInsertPositionOnCreate, secondInsertPositionOnCreate] = (0, import_react.useMemo)(() => {
438
- if ((0, import_utils6.isArray)(insertPositionOnCreate)) {
439
- return insertPositionOnCreate;
438
+ const [firstInsertPositionItem, secondInsertPositionItem] = (0, import_react.useMemo)(() => {
439
+ if ((0, import_utils6.isArray)(insertPositionItem)) {
440
+ return insertPositionItem;
440
441
  } else {
441
- return [insertPositionOnCreate, "first"];
442
+ return [insertPositionItem, "first"];
442
443
  }
443
- }, [insertPositionOnCreate]);
444
- if (createOption && !(0, import_utils6.isUndefined)(children)) {
444
+ }, [insertPositionItem]);
445
+ if (allowCreate && !(0, import_utils6.isUndefined)(children)) {
445
446
  console.warn(
446
- `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: ${!isMulti ? "Autocomplete" : "MultiAutocomplete"} internally prefers 'children'. If 'createOption' is true, it will not be reflected correctly. If want to reflect, please set 'options' in props.`
447
+ `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: ${!isMulti ? "Autocomplete" : "MultiAutocomplete"} internally prefers 'children'. If 'allowCreate' is true, it will not be reflected correctly. If want to reflect, please set 'items' in props.`
447
448
  );
448
449
  }
449
450
  const selectedValues = descendants.enabledValues(
@@ -457,18 +458,18 @@ var useAutocomplete = ({
457
458
  ({ node, index }) => "target" in node.dataset && !selectedIndexes.includes(index)
458
459
  );
459
460
  const validChildren = (0, import_utils6.getValidChildren)(children);
460
- const computedChildren = options == null ? void 0 : options.map(({ label, value: value2, ...props }, i) => {
461
- if (!(0, import_utils6.isArray)(value2)) {
461
+ const computedChildren = resolvedItems == null ? void 0 : resolvedItems.map((item, i) => {
462
+ if ("value" in item) {
463
+ const { label, value: value2, ...props } = item;
462
464
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutocompleteOption, { value: value2, ...props, children: label }, i);
463
- } else {
465
+ } else if ("items" in item) {
466
+ const { label, items: items2 = [], ...props } = item;
464
467
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
465
468
  AutocompleteOptionGroup,
466
469
  {
467
470
  label,
468
471
  ...props,
469
- children: value2.map(
470
- ({ label: label2, value: value3, ...props2 }, i2) => !(0, import_utils6.isArray)(value3) ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutocompleteOption, { value: value3, ...props2, children: label2 }, i2) : null
471
- )
472
+ children: items2.map(({ label: label2, value: value2, ...props2 }, i2) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutocompleteOption, { value: value2, ...props2, children: label2 }, i2))
472
473
  },
473
474
  i
474
475
  );
@@ -479,13 +480,13 @@ var useAutocomplete = ({
479
480
  var _a;
480
481
  if (formControlProps.disabled || formControlProps.readOnly)
481
482
  return;
482
- if (!createOption && (isEmpty || isAllSelected))
483
+ if (!allowCreate && (isEmpty || isAllSelected))
483
484
  return;
484
485
  setIsOpen(true);
485
486
  if (inputRef.current)
486
487
  inputRef.current.focus();
487
488
  (_a = rest.onOpen) == null ? void 0 : _a.call(rest);
488
- }, [createOption, formControlProps, isAllSelected, isEmpty, rest]);
489
+ }, [allowCreate, formControlProps, isAllSelected, isEmpty, rest]);
489
490
  const onClose = (0, import_react.useCallback)(() => {
490
491
  var _a;
491
492
  setIsOpen(false);
@@ -757,55 +758,51 @@ var useAutocomplete = ({
757
758
  isComposition.current = false;
758
759
  }, []);
759
760
  const onCreate = (0, import_react.useCallback)(() => {
760
- var _a;
761
+ var _a, _b, _c;
761
762
  if (!listRef.current)
762
763
  return;
763
- const newOption = { label: inputValue, value: inputValue };
764
- let newOptions = [];
765
- if (options)
766
- newOptions = options;
767
- if (firstInsertPositionOnCreate === "first") {
768
- newOptions = [newOption, ...newOptions];
769
- } else if (firstInsertPositionOnCreate === "last") {
770
- newOptions = [...newOptions, newOption];
764
+ const newItem = { label: inputValue, value: inputValue };
765
+ let newItems = [];
766
+ if (resolvedItems)
767
+ newItems = resolvedItems;
768
+ if (firstInsertPositionItem === "first") {
769
+ newItems = [newItem, ...newItems];
770
+ } else if (firstInsertPositionItem === "last") {
771
+ newItems = [...newItems, newItem];
771
772
  } else {
772
- const i = newOptions.findIndex(
773
- ({ label }) => label === firstInsertPositionOnCreate
773
+ const i = newItems.findIndex(
774
+ ({ label }) => label === firstInsertPositionItem
774
775
  );
775
- if (i !== -1 && (0, import_utils6.isArray)(newOptions[i].value)) {
776
- if (secondInsertPositionOnCreate === "first") {
777
- newOptions[i].value = [
778
- newOption,
779
- ...newOptions[i].value
780
- ];
776
+ const targetItem = newItems[i];
777
+ if (i !== -1 && "items" in targetItem) {
778
+ if (secondInsertPositionItem === "first") {
779
+ targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
781
780
  } else {
782
- newOptions[i].value = [
783
- ...newOptions[i].value,
784
- newOption
785
- ];
781
+ targetItem.items = [...(_b = targetItem.items) != null ? _b : [], newItem];
786
782
  }
783
+ newItems[i] = targetItem;
787
784
  } else {
788
785
  console.warn(
789
- `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: '${firstInsertPositionOnCreate}' specified in insertPositionOnCreate does not exist in the option group.`
786
+ `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: '${firstInsertPositionItem}' specified in insertPositionItem does not exist in the option group.`
790
787
  );
791
788
  }
792
789
  }
793
- setOptions(newOptions);
790
+ setResolvedItems(newItems);
794
791
  onChange(inputValue);
795
792
  rebirthOptions(false);
796
- const index = flattenOptions(newOptions).findIndex(
793
+ const index = flattenItems(newItems).findIndex(
797
794
  ({ value: value2 }) => value2 === inputValue
798
795
  );
799
796
  setFocusedIndex(index);
800
- (_a = rest.onCreate) == null ? void 0 : _a.call(rest, newOption, newOptions);
797
+ (_c = rest.onCreate) == null ? void 0 : _c.call(rest, newItem, newItems);
801
798
  }, [
802
799
  inputValue,
803
- options,
804
- firstInsertPositionOnCreate,
800
+ resolvedItems,
801
+ firstInsertPositionItem,
805
802
  onChange,
806
803
  rebirthOptions,
807
804
  rest,
808
- secondInsertPositionOnCreate,
805
+ secondInsertPositionItem,
809
806
  isMulti
810
807
  ]);
811
808
  const onDelete = (0, import_react.useCallback)(() => {
@@ -992,7 +989,7 @@ var useAutocomplete = ({
992
989
  focusedIndex,
993
990
  omitSelectedValues,
994
991
  closeOnSelect,
995
- createOption,
992
+ allowCreate,
996
993
  emptyMessage,
997
994
  isOpen,
998
995
  isAllSelected,
@@ -1471,7 +1468,7 @@ var Autocomplete = (0, import_core8.forwardRef)(
1471
1468
  getPopoverProps,
1472
1469
  getContainerProps,
1473
1470
  getFieldProps,
1474
- createOption,
1471
+ allowCreate,
1475
1472
  isEmpty,
1476
1473
  inputValue,
1477
1474
  computedChildren,
@@ -1493,7 +1490,7 @@ var Autocomplete = (0, import_core8.forwardRef)(
1493
1490
  ...rest,
1494
1491
  formControlProps,
1495
1492
  inputValue,
1496
- createOption,
1493
+ allowCreate,
1497
1494
  isEmpty,
1498
1495
  styles
1499
1496
  },
@@ -1515,9 +1512,9 @@ var Autocomplete = (0, import_core8.forwardRef)(
1515
1512
  ),
1516
1513
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
1517
1514
  !isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
1518
- createOption ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
1515
+ allowCreate ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
1519
1516
  children != null ? children : computedChildren
1520
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) })
1517
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) })
1521
1518
  ]
1522
1519
  }
1523
1520
  ) })
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  Autocomplete
4
- } from "./chunk-EFOFI4S7.mjs";
4
+ } from "./chunk-JKY5MMNC.mjs";
5
5
  export {
6
6
  Autocomplete
7
7
  };