@heroui/autocomplete 2.3.11 → 2.3.14

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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Next UI
3
+ Copyright (c) 2020 Next UI Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -15,10 +15,10 @@ npm i @heroui/autocomplete
15
15
  ## Contribution
16
16
 
17
17
  Yes please! See the
18
- [contributing guidelines](https://github.com/frontio-ai/heroui/blob/master/CONTRIBUTING.md)
18
+ [contributing guidelines](https://github.com/heroui-inc/heroui/blob/master/CONTRIBUTING.md)
19
19
  for details.
20
20
 
21
21
  ## License
22
22
 
23
23
  This project is licensed under the terms of the
24
- [MIT license](https://github.com/frontio-ai/heroui/blob/master/LICENSE).
24
+ [MIT license](https://github.com/heroui-inc/heroui/blob/master/LICENSE).
@@ -0,0 +1,21 @@
1
+ import { ReactElement } from 'react';
2
+ import { UseAutocompleteProps } from './use-autocomplete.mjs';
3
+ import 'tailwind-variants';
4
+ import '@react-stately/combobox';
5
+ import '@heroui/system';
6
+ import '@heroui/theme';
7
+ import '@heroui/react-utils';
8
+ import '@react-types/combobox';
9
+ import '@heroui/popover';
10
+ import '@heroui/listbox';
11
+ import '@heroui/input';
12
+ import '@heroui/scroll-shadow';
13
+ import '@heroui/button';
14
+ import '@react-types/shared';
15
+
16
+ interface Props<T> extends UseAutocompleteProps<T> {
17
+ }
18
+ type AutocompleteProps<T extends object = object> = Props<T>;
19
+ declare const Autocomplete: <T extends object>(props: AutocompleteProps<T>) => ReactElement;
20
+
21
+ export { type AutocompleteProps, Autocomplete as default };
@@ -18,4 +18,4 @@ interface Props<T> extends UseAutocompleteProps<T> {
18
18
  type AutocompleteProps<T extends object = object> = Props<T>;
19
19
  declare const Autocomplete: <T extends object>(props: AutocompleteProps<T>) => ReactElement;
20
20
 
21
- export { AutocompleteProps, Autocomplete as default };
21
+ export { type AutocompleteProps, Autocomplete as default };
@@ -206,8 +206,7 @@ function useAutocomplete(originalProps) {
206
206
  const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
207
207
  const isOpen = ((_e = slotsProps.listboxProps) == null ? void 0 : _e.hideEmptyContent) ? state.isOpen && !!state.collection.size : state.isOpen;
208
208
  (0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
209
- if (!inputRef.current)
210
- return;
209
+ if (!inputRef.current) return;
211
210
  const key = inputRef.current.value;
212
211
  const item = state.collection.getItem(key);
213
212
  if (item && state.inputValue !== item.textValue) {
@@ -246,10 +245,9 @@ function useAutocomplete(originalProps) {
246
245
  () => (0, import_theme.autocomplete)({
247
246
  ...variantProps,
248
247
  isClearable,
249
- disableAnimation,
250
- className
248
+ disableAnimation
251
249
  }),
252
- [(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation, className]
250
+ [(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation]
253
251
  );
254
252
  const getBaseProps = () => ({
255
253
  "data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
@@ -271,6 +269,7 @@ function useAutocomplete(originalProps) {
271
269
  var _a2, _b2;
272
270
  return {
273
271
  ...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
272
+ // disable original focus and state toggle from react aria
274
273
  onPressStart: () => {
275
274
  var _a3;
276
275
  (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
@@ -337,6 +336,8 @@ function useAutocomplete(originalProps) {
337
336
  })
338
337
  },
339
338
  shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
339
+ // when the popover is open, the focus should be on input instead of dialog
340
+ // therefore, we skip dialog focus here
340
341
  disableDialogFocus: true
341
342
  };
342
343
  };
@@ -443,5 +444,3 @@ var Autocomplete = (0, import_system2.forwardRef)(function Autocomplete2(props,
443
444
  ] });
444
445
  });
445
446
  var autocomplete_default = Autocomplete;
446
- // Annotate the CommonJS export names for ESM import in node:
447
- 0 && (module.exports = {});
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  autocomplete_default
4
- } from "./chunk-SV7R5B4H.mjs";
5
- import "./chunk-QZCVHGAT.mjs";
4
+ } from "./chunk-DNIGSRME.mjs";
5
+ import "./chunk-OHYOYGT2.mjs";
6
6
  export {
7
7
  autocomplete_default as default
8
8
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useAutocomplete
4
- } from "./chunk-QZCVHGAT.mjs";
4
+ } from "./chunk-OHYOYGT2.mjs";
5
5
 
6
6
  // src/autocomplete.tsx
7
7
  import { forwardRef } from "@heroui/system";
@@ -173,8 +173,7 @@ function useAutocomplete(originalProps) {
173
173
  const baseStyles = clsx(classNames == null ? void 0 : classNames.base, className);
174
174
  const isOpen = ((_e = slotsProps.listboxProps) == null ? void 0 : _e.hideEmptyContent) ? state.isOpen && !!state.collection.size : state.isOpen;
175
175
  useSafeLayoutEffect(() => {
176
- if (!inputRef.current)
177
- return;
176
+ if (!inputRef.current) return;
178
177
  const key = inputRef.current.value;
179
178
  const item = state.collection.getItem(key);
180
179
  if (item && state.inputValue !== item.textValue) {
@@ -213,10 +212,9 @@ function useAutocomplete(originalProps) {
213
212
  () => autocomplete({
214
213
  ...variantProps,
215
214
  isClearable,
216
- disableAnimation,
217
- className
215
+ disableAnimation
218
216
  }),
219
- [objectToDeps(variantProps), isClearable, disableAnimation, className]
217
+ [objectToDeps(variantProps), isClearable, disableAnimation]
220
218
  );
221
219
  const getBaseProps = () => ({
222
220
  "data-invalid": dataAttr(isInvalid),
@@ -238,6 +236,7 @@ function useAutocomplete(originalProps) {
238
236
  var _a2, _b2;
239
237
  return {
240
238
  ...mergeProps(buttonProps, slotsProps.clearButtonProps),
239
+ // disable original focus and state toggle from react aria
241
240
  onPressStart: () => {
242
241
  var _a3;
243
242
  (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
@@ -304,6 +303,8 @@ function useAutocomplete(originalProps) {
304
303
  })
305
304
  },
306
305
  shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => ariaShouldCloseOnInteractOutside(element, inputWrapperRef, state),
306
+ // when the popover is open, the focus should be on input instead of dialog
307
+ // therefore, we skip dialog focus here
307
308
  disableDialogFocus: true
308
309
  };
309
310
  };
@@ -0,0 +1,19 @@
1
+ export { ListboxItem as AutocompleteItem, ListboxItemProps as AutocompleteItemProps, ListboxSection as AutocompleteSection, ListboxSectionProps as AutocompleteSectionProps } from '@heroui/listbox';
2
+ import { MenuTriggerAction as MenuTriggerAction$1 } from '@react-types/combobox';
3
+ export { default as Autocomplete, AutocompleteProps } from './autocomplete.mjs';
4
+ export { useAutocomplete } from './use-autocomplete.mjs';
5
+ import 'react';
6
+ import 'tailwind-variants';
7
+ import '@react-stately/combobox';
8
+ import '@heroui/system';
9
+ import '@heroui/theme';
10
+ import '@heroui/react-utils';
11
+ import '@heroui/popover';
12
+ import '@heroui/input';
13
+ import '@heroui/scroll-shadow';
14
+ import '@heroui/button';
15
+ import '@react-types/shared';
16
+
17
+ type MenuTriggerAction = MenuTriggerAction$1 | undefined;
18
+
19
+ export type { MenuTriggerAction };
package/dist/index.d.ts CHANGED
@@ -16,4 +16,4 @@ import '@react-types/shared';
16
16
 
17
17
  type MenuTriggerAction = MenuTriggerAction$1 | undefined;
18
18
 
19
- export { MenuTriggerAction };
19
+ export type { MenuTriggerAction };
package/dist/index.js CHANGED
@@ -19,14 +19,14 @@ var __copyProps = (to, from, except, desc) => {
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
 
21
21
  // src/index.ts
22
- var src_exports = {};
23
- __export(src_exports, {
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
24
  Autocomplete: () => autocomplete_default,
25
25
  AutocompleteItem: () => import_listbox2.ListboxItem,
26
26
  AutocompleteSection: () => import_listbox2.ListboxSection,
27
27
  useAutocomplete: () => useAutocomplete
28
28
  });
29
- module.exports = __toCommonJS(src_exports);
29
+ module.exports = __toCommonJS(index_exports);
30
30
  var import_listbox2 = require("@heroui/listbox");
31
31
 
32
32
  // src/autocomplete.tsx
@@ -212,8 +212,7 @@ function useAutocomplete(originalProps) {
212
212
  const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
213
213
  const isOpen = ((_e = slotsProps.listboxProps) == null ? void 0 : _e.hideEmptyContent) ? state.isOpen && !!state.collection.size : state.isOpen;
214
214
  (0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
215
- if (!inputRef.current)
216
- return;
215
+ if (!inputRef.current) return;
217
216
  const key = inputRef.current.value;
218
217
  const item = state.collection.getItem(key);
219
218
  if (item && state.inputValue !== item.textValue) {
@@ -252,10 +251,9 @@ function useAutocomplete(originalProps) {
252
251
  () => (0, import_theme.autocomplete)({
253
252
  ...variantProps,
254
253
  isClearable,
255
- disableAnimation,
256
- className
254
+ disableAnimation
257
255
  }),
258
- [(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation, className]
256
+ [(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation]
259
257
  );
260
258
  const getBaseProps = () => ({
261
259
  "data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
@@ -277,6 +275,7 @@ function useAutocomplete(originalProps) {
277
275
  var _a2, _b2;
278
276
  return {
279
277
  ...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
278
+ // disable original focus and state toggle from react aria
280
279
  onPressStart: () => {
281
280
  var _a3;
282
281
  (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
@@ -343,6 +342,8 @@ function useAutocomplete(originalProps) {
343
342
  })
344
343
  },
345
344
  shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
345
+ // when the popover is open, the focus should be on input instead of dialog
346
+ // therefore, we skip dialog focus here
346
347
  disableDialogFocus: true
347
348
  };
348
349
  };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  autocomplete_default
4
- } from "./chunk-SV7R5B4H.mjs";
4
+ } from "./chunk-DNIGSRME.mjs";
5
5
  import {
6
6
  useAutocomplete
7
- } from "./chunk-QZCVHGAT.mjs";
7
+ } from "./chunk-OHYOYGT2.mjs";
8
8
 
9
9
  // src/index.ts
10
10
  import { ListboxItem, ListboxSection } from "@heroui/listbox";
@@ -0,0 +1,229 @@
1
+ import * as tailwind_variants from 'tailwind-variants';
2
+ import * as _react_stately_combobox from '@react-stately/combobox';
3
+ import { FilterFn } from '@react-stately/combobox';
4
+ import * as react from 'react';
5
+ import { ReactNode } from 'react';
6
+ import * as _heroui_system from '@heroui/system';
7
+ import { PropGetter, DOMAttributes, HTMLHeroUIProps } from '@heroui/system';
8
+ import { AutocompleteVariantProps, SlotsToClasses, AutocompleteSlots } from '@heroui/theme';
9
+ import { ReactRef } from '@heroui/react-utils';
10
+ import { ComboBoxProps } from '@react-types/combobox';
11
+ import { PopoverProps } from '@heroui/popover';
12
+ import { ListboxProps } from '@heroui/listbox';
13
+ import { InputProps } from '@heroui/input';
14
+ import { ScrollShadowProps } from '@heroui/scroll-shadow';
15
+ import { ButtonProps } from '@heroui/button';
16
+ import { AsyncLoadable } from '@react-types/shared';
17
+
18
+ interface Props<T> extends Omit<HTMLHeroUIProps<"input">, keyof ComboBoxProps<T>> {
19
+ /**
20
+ * Ref to the DOM node.
21
+ */
22
+ ref?: ReactRef<HTMLElement | null>;
23
+ /**
24
+ * The ref to the scroll element. Useful when having async loading of items.
25
+ */
26
+ scrollRef?: ReactRef<HTMLElement | null>;
27
+ /**
28
+ * The icon that represents the autocomplete open state. Usually a chevron icon.
29
+ */
30
+ selectorIcon?: ReactNode;
31
+ /**
32
+ * The icon that represents the clear button. Usually a cross icon.
33
+ */
34
+ clearIcon?: ReactNode;
35
+ /**
36
+ * Whether to display a top and bottom arrow indicators when the listbox is scrollable.
37
+ * @default true
38
+ */
39
+ showScrollIndicators?: boolean;
40
+ /**
41
+ * Props to be passed to the scroll shadow component. This component
42
+ * adds a shadow to the top and bottom of the listbox when it is scrollable.
43
+ *
44
+ * @default { hideScrollBar: true, offset: 15 }
45
+ */
46
+ scrollShadowProps?: Partial<ScrollShadowProps>;
47
+ /**
48
+ * Props to be passed to the popover component.
49
+ *
50
+ * @default { placement: "bottom", triggerScaleOnOpen: false, offset: 5 }
51
+ */
52
+ popoverProps?: Partial<PopoverProps>;
53
+ /**
54
+ * Props to be passed to the listbox component.
55
+ *
56
+ * @default { disableAnimation: false }
57
+ */
58
+ listboxProps?: Partial<ListboxProps>;
59
+ /**
60
+ * Props to be passed to the input component.
61
+ *
62
+ * @default { disableAnimation: false }
63
+ */
64
+ inputProps?: Partial<InputProps>;
65
+ /**
66
+ * Whether the clear button should be hidden.
67
+ * @default false
68
+ * @deprecated Use `isClearable` instead.
69
+ */
70
+ disableClearable?: boolean;
71
+ /**
72
+ * Props to be passed to the selector button component.
73
+ * @default { size: "sm", variant: "light", radius: "full", isIconOnly: true }
74
+ */
75
+ selectorButtonProps?: Partial<ButtonProps>;
76
+ /**
77
+ * Props to be passed to the clear button component.
78
+ * @default { size: "sm", variant: "light", radius: "full", isIconOnly: true }
79
+ */
80
+ clearButtonProps?: Partial<ButtonProps>;
81
+ /**
82
+ * The filter options to use when filtering items based on user input.
83
+ * @default {sensitivity: 'base'}
84
+ */
85
+ filterOptions?: Intl.CollatorOptions;
86
+ /**
87
+ * Whether the autocomplete allows the menu to be open when the collection is empty.
88
+ * @default true
89
+ */
90
+ allowsEmptyCollection?: boolean;
91
+ /**
92
+ * Whether the autocomplete menu should close on blur.
93
+ * @default true
94
+ * */
95
+ shouldCloseOnBlur?: boolean;
96
+ /**
97
+ * Classes object to style the autocomplete and its children.
98
+ */
99
+ classNames?: SlotsToClasses<AutocompleteSlots>;
100
+ /**
101
+ * The filter function used to determine if a option should be included in the autocomplete list.
102
+ * */
103
+ defaultFilter?: FilterFn;
104
+ /**
105
+ * Callback fired when the select menu is closed.
106
+ */
107
+ onClose?: () => void;
108
+ /**
109
+ * Whether to enable virtualization of the listbox items.
110
+ * By default, virtualization is automatically enabled when the number of items is greater than 50.
111
+ * @default undefined
112
+ */
113
+ isVirtualized?: boolean;
114
+ }
115
+ type UseAutocompleteProps<T> = Props<T> & Omit<InputProps, "children" | "value" | "isClearable" | "defaultValue" | "classNames"> & ComboBoxProps<T> & AsyncLoadable & AutocompleteVariantProps & {
116
+ /**
117
+ * The height of each item in the listbox.
118
+ * This is required for virtualized listboxes to calculate the height of each item.
119
+ */
120
+ itemHeight?: number;
121
+ /**
122
+ * The max height of the listbox (which will be rendered in a popover).
123
+ * This is required for virtualized listboxes to set the maximum height of the listbox.
124
+ */
125
+ maxListboxHeight?: number;
126
+ };
127
+ declare function useAutocomplete<T extends object>(originalProps: UseAutocompleteProps<T>): {
128
+ Component: _heroui_system.As<any>;
129
+ inputRef: react.RefObject<HTMLInputElement>;
130
+ label: ReactNode;
131
+ state: _react_stately_combobox.ComboBoxState<T>;
132
+ slots: {
133
+ base: (slotProps?: ({
134
+ isClearable?: boolean | undefined;
135
+ disableAnimation?: boolean | undefined;
136
+ disableSelectorIconRotation?: boolean | undefined;
137
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
138
+ listboxWrapper: (slotProps?: ({
139
+ isClearable?: boolean | undefined;
140
+ disableAnimation?: boolean | undefined;
141
+ disableSelectorIconRotation?: boolean | undefined;
142
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
143
+ listbox: (slotProps?: ({
144
+ isClearable?: boolean | undefined;
145
+ disableAnimation?: boolean | undefined;
146
+ disableSelectorIconRotation?: boolean | undefined;
147
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
148
+ popoverContent: (slotProps?: ({
149
+ isClearable?: boolean | undefined;
150
+ disableAnimation?: boolean | undefined;
151
+ disableSelectorIconRotation?: boolean | undefined;
152
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
153
+ endContentWrapper: (slotProps?: ({
154
+ isClearable?: boolean | undefined;
155
+ disableAnimation?: boolean | undefined;
156
+ disableSelectorIconRotation?: boolean | undefined;
157
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
158
+ clearButton: (slotProps?: ({
159
+ isClearable?: boolean | undefined;
160
+ disableAnimation?: boolean | undefined;
161
+ disableSelectorIconRotation?: boolean | undefined;
162
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
163
+ selectorButton: (slotProps?: ({
164
+ isClearable?: boolean | undefined;
165
+ disableAnimation?: boolean | undefined;
166
+ disableSelectorIconRotation?: boolean | undefined;
167
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
168
+ } & {
169
+ base: (slotProps?: ({
170
+ isClearable?: boolean | undefined;
171
+ disableAnimation?: boolean | undefined;
172
+ disableSelectorIconRotation?: boolean | undefined;
173
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
174
+ listboxWrapper: (slotProps?: ({
175
+ isClearable?: boolean | undefined;
176
+ disableAnimation?: boolean | undefined;
177
+ disableSelectorIconRotation?: boolean | undefined;
178
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
179
+ listbox: (slotProps?: ({
180
+ isClearable?: boolean | undefined;
181
+ disableAnimation?: boolean | undefined;
182
+ disableSelectorIconRotation?: boolean | undefined;
183
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
184
+ popoverContent: (slotProps?: ({
185
+ isClearable?: boolean | undefined;
186
+ disableAnimation?: boolean | undefined;
187
+ disableSelectorIconRotation?: boolean | undefined;
188
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
189
+ endContentWrapper: (slotProps?: ({
190
+ isClearable?: boolean | undefined;
191
+ disableAnimation?: boolean | undefined;
192
+ disableSelectorIconRotation?: boolean | undefined;
193
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
194
+ clearButton: (slotProps?: ({
195
+ isClearable?: boolean | undefined;
196
+ disableAnimation?: boolean | undefined;
197
+ disableSelectorIconRotation?: boolean | undefined;
198
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
199
+ selectorButton: (slotProps?: ({
200
+ isClearable?: boolean | undefined;
201
+ disableAnimation?: boolean | undefined;
202
+ disableSelectorIconRotation?: boolean | undefined;
203
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
204
+ } & {};
205
+ classNames: SlotsToClasses<"base" | "clearButton" | "listbox" | "listboxWrapper" | "popoverContent" | "endContentWrapper" | "selectorButton"> | undefined;
206
+ isLoading: boolean | undefined;
207
+ clearIcon: ReactNode;
208
+ isOpen: boolean;
209
+ endContent: ReactNode;
210
+ isClearable: boolean | undefined;
211
+ disableAnimation: boolean;
212
+ allowsCustomValue: boolean;
213
+ selectorIcon: ReactNode;
214
+ getBaseProps: PropGetter;
215
+ getInputProps: () => InputProps;
216
+ getListBoxProps: () => ListboxProps;
217
+ getPopoverProps: (props?: DOMAttributes) => PopoverProps;
218
+ getEmptyPopoverProps: () => {
219
+ ref: react.RefObject<HTMLDivElement>;
220
+ className: string;
221
+ };
222
+ getClearButtonProps: () => ButtonProps;
223
+ getSelectorButtonProps: () => ButtonProps;
224
+ getListBoxWrapperProps: PropGetter;
225
+ getEndContentWrapperProps: PropGetter;
226
+ };
227
+ type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>;
228
+
229
+ export { type UseAutocompleteProps, type UseAutocompleteReturn, useAutocomplete };
@@ -134,73 +134,73 @@ declare function useAutocomplete<T extends object>(originalProps: UseAutocomplet
134
134
  isClearable?: boolean | undefined;
135
135
  disableAnimation?: boolean | undefined;
136
136
  disableSelectorIconRotation?: boolean | undefined;
137
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
137
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
138
138
  listboxWrapper: (slotProps?: ({
139
139
  isClearable?: boolean | undefined;
140
140
  disableAnimation?: boolean | undefined;
141
141
  disableSelectorIconRotation?: boolean | undefined;
142
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
142
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
143
143
  listbox: (slotProps?: ({
144
144
  isClearable?: boolean | undefined;
145
145
  disableAnimation?: boolean | undefined;
146
146
  disableSelectorIconRotation?: boolean | undefined;
147
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
147
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
148
148
  popoverContent: (slotProps?: ({
149
149
  isClearable?: boolean | undefined;
150
150
  disableAnimation?: boolean | undefined;
151
151
  disableSelectorIconRotation?: boolean | undefined;
152
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
152
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
153
153
  endContentWrapper: (slotProps?: ({
154
154
  isClearable?: boolean | undefined;
155
155
  disableAnimation?: boolean | undefined;
156
156
  disableSelectorIconRotation?: boolean | undefined;
157
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
157
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
158
158
  clearButton: (slotProps?: ({
159
159
  isClearable?: boolean | undefined;
160
160
  disableAnimation?: boolean | undefined;
161
161
  disableSelectorIconRotation?: boolean | undefined;
162
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
162
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
163
163
  selectorButton: (slotProps?: ({
164
164
  isClearable?: boolean | undefined;
165
165
  disableAnimation?: boolean | undefined;
166
166
  disableSelectorIconRotation?: boolean | undefined;
167
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
167
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
168
168
  } & {
169
169
  base: (slotProps?: ({
170
170
  isClearable?: boolean | undefined;
171
171
  disableAnimation?: boolean | undefined;
172
172
  disableSelectorIconRotation?: boolean | undefined;
173
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
173
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
174
174
  listboxWrapper: (slotProps?: ({
175
175
  isClearable?: boolean | undefined;
176
176
  disableAnimation?: boolean | undefined;
177
177
  disableSelectorIconRotation?: boolean | undefined;
178
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
178
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
179
179
  listbox: (slotProps?: ({
180
180
  isClearable?: boolean | undefined;
181
181
  disableAnimation?: boolean | undefined;
182
182
  disableSelectorIconRotation?: boolean | undefined;
183
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
183
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
184
184
  popoverContent: (slotProps?: ({
185
185
  isClearable?: boolean | undefined;
186
186
  disableAnimation?: boolean | undefined;
187
187
  disableSelectorIconRotation?: boolean | undefined;
188
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
188
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
189
189
  endContentWrapper: (slotProps?: ({
190
190
  isClearable?: boolean | undefined;
191
191
  disableAnimation?: boolean | undefined;
192
192
  disableSelectorIconRotation?: boolean | undefined;
193
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
193
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
194
194
  clearButton: (slotProps?: ({
195
195
  isClearable?: boolean | undefined;
196
196
  disableAnimation?: boolean | undefined;
197
197
  disableSelectorIconRotation?: boolean | undefined;
198
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
198
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
199
199
  selectorButton: (slotProps?: ({
200
200
  isClearable?: boolean | undefined;
201
201
  disableAnimation?: boolean | undefined;
202
202
  disableSelectorIconRotation?: boolean | undefined;
203
- } & tailwind_variants.ClassProp<ClassValue>) | undefined) => string;
203
+ } & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
204
204
  } & {};
205
205
  classNames: SlotsToClasses<"base" | "clearButton" | "listbox" | "listboxWrapper" | "popoverContent" | "endContentWrapper" | "selectorButton"> | undefined;
206
206
  isLoading: boolean | undefined;
@@ -211,9 +211,9 @@ declare function useAutocomplete<T extends object>(originalProps: UseAutocomplet
211
211
  disableAnimation: boolean;
212
212
  allowsCustomValue: boolean;
213
213
  selectorIcon: ReactNode;
214
- getBaseProps: PropGetter<Record<string, unknown>, DOMAttributes<_heroui_system.DOMElement>>;
214
+ getBaseProps: PropGetter;
215
215
  getInputProps: () => InputProps;
216
- getListBoxProps: () => ListboxProps<object>;
216
+ getListBoxProps: () => ListboxProps;
217
217
  getPopoverProps: (props?: DOMAttributes) => PopoverProps;
218
218
  getEmptyPopoverProps: () => {
219
219
  ref: react.RefObject<HTMLDivElement>;
@@ -221,9 +221,9 @@ declare function useAutocomplete<T extends object>(originalProps: UseAutocomplet
221
221
  };
222
222
  getClearButtonProps: () => ButtonProps;
223
223
  getSelectorButtonProps: () => ButtonProps;
224
- getListBoxWrapperProps: PropGetter<Record<string, unknown>, DOMAttributes<_heroui_system.DOMElement>>;
225
- getEndContentWrapperProps: PropGetter<Record<string, unknown>, DOMAttributes<_heroui_system.DOMElement>>;
224
+ getListBoxWrapperProps: PropGetter;
225
+ getEndContentWrapperProps: PropGetter;
226
226
  };
227
227
  type UseAutocompleteReturn = ReturnType<typeof useAutocomplete>;
228
228
 
229
- export { UseAutocompleteProps, UseAutocompleteReturn, useAutocomplete };
229
+ export { type UseAutocompleteProps, type UseAutocompleteReturn, useAutocomplete };
@@ -196,8 +196,7 @@ function useAutocomplete(originalProps) {
196
196
  const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
197
197
  const isOpen = ((_e = slotsProps.listboxProps) == null ? void 0 : _e.hideEmptyContent) ? state.isOpen && !!state.collection.size : state.isOpen;
198
198
  (0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
199
- if (!inputRef.current)
200
- return;
199
+ if (!inputRef.current) return;
201
200
  const key = inputRef.current.value;
202
201
  const item = state.collection.getItem(key);
203
202
  if (item && state.inputValue !== item.textValue) {
@@ -236,10 +235,9 @@ function useAutocomplete(originalProps) {
236
235
  () => (0, import_theme.autocomplete)({
237
236
  ...variantProps,
238
237
  isClearable,
239
- disableAnimation,
240
- className
238
+ disableAnimation
241
239
  }),
242
- [(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation, className]
240
+ [(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation]
243
241
  );
244
242
  const getBaseProps = () => ({
245
243
  "data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
@@ -261,6 +259,7 @@ function useAutocomplete(originalProps) {
261
259
  var _a2, _b2;
262
260
  return {
263
261
  ...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
262
+ // disable original focus and state toggle from react aria
264
263
  onPressStart: () => {
265
264
  var _a3;
266
265
  (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
@@ -327,6 +326,8 @@ function useAutocomplete(originalProps) {
327
326
  })
328
327
  },
329
328
  shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
329
+ // when the popover is open, the focus should be on input instead of dialog
330
+ // therefore, we skip dialog focus here
330
331
  disableDialogFocus: true
331
332
  };
332
333
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useAutocomplete
4
- } from "./chunk-QZCVHGAT.mjs";
4
+ } from "./chunk-OHYOYGT2.mjs";
5
5
  export {
6
6
  useAutocomplete
7
7
  };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@heroui/autocomplete",
3
- "version": "2.3.11",
3
+ "version": "2.3.14",
4
4
  "description": "An autocomplete combines a text input with a listbox, allowing users to filter a list of options to items matching a query.",
5
5
  "keywords": [
6
6
  "autocomplete"
7
7
  ],
8
- "author": "Junior Garcia <jrgarciadev@gmail.com>",
8
+ "author": "HeroUI <support@heroui.com>",
9
9
  "homepage": "https://heroui.com",
10
10
  "license": "MIT",
11
11
  "main": "dist/index.js",
@@ -25,35 +25,35 @@
25
25
  "url": "https://github.com/heroui-inc/heroui/issues"
26
26
  },
27
27
  "peerDependencies": {
28
- "@heroui/system": ">=2.4.0",
29
- "@heroui/theme": ">=2.4.0",
28
+ "@heroui/system": ">=2.4.7",
29
+ "@heroui/theme": ">=2.4.6",
30
30
  "framer-motion": ">=11.5.6 || >=12.0.0-alpha.1",
31
31
  "react": ">=18 || >=19.0.0-rc.0",
32
32
  "react-dom": ">=18 || >=19.0.0-rc.0"
33
33
  },
34
34
  "dependencies": {
35
- "@react-aria/combobox": "3.11.0",
36
- "@react-aria/focus": "3.19.0",
37
- "@react-aria/i18n": "3.12.4",
38
- "@react-aria/interactions": "3.22.5",
39
- "@react-aria/utils": "3.26.0",
40
- "@react-aria/visually-hidden": "3.8.18",
41
- "@react-stately/combobox": "3.10.1",
42
- "@react-types/combobox": "3.13.1",
43
- "@react-types/shared": "3.26.0",
44
- "@heroui/form": "2.1.9",
45
- "@heroui/aria-utils": "2.2.8",
46
- "@heroui/button": "2.2.10",
47
- "@heroui/input": "2.4.10",
48
- "@heroui/listbox": "2.3.10",
49
- "@heroui/popover": "2.3.10",
50
- "@heroui/react-utils": "2.1.4",
51
- "@heroui/scroll-shadow": "2.3.6",
52
- "@heroui/shared-icons": "2.1.2",
53
- "@heroui/shared-utils": "2.1.3",
54
- "@heroui/spinner": "2.2.7",
55
- "@heroui/use-aria-button": "2.2.5",
56
- "@heroui/use-safe-layout-effect": "2.1.2"
35
+ "@react-aria/combobox": "3.11.1",
36
+ "@react-aria/focus": "3.19.1",
37
+ "@react-aria/i18n": "3.12.5",
38
+ "@react-aria/interactions": "3.23.0",
39
+ "@react-aria/utils": "3.27.0",
40
+ "@react-aria/visually-hidden": "3.8.19",
41
+ "@react-stately/combobox": "3.10.2",
42
+ "@react-types/combobox": "3.13.2",
43
+ "@react-types/shared": "3.27.0",
44
+ "@heroui/form": "2.1.12",
45
+ "@heroui/aria-utils": "2.2.11",
46
+ "@heroui/button": "2.2.13",
47
+ "@heroui/input": "2.4.13",
48
+ "@heroui/listbox": "2.3.13",
49
+ "@heroui/popover": "2.3.13",
50
+ "@heroui/react-utils": "2.1.7",
51
+ "@heroui/scroll-shadow": "2.3.9",
52
+ "@heroui/shared-icons": "2.1.5",
53
+ "@heroui/shared-utils": "2.1.6",
54
+ "@heroui/spinner": "2.2.10",
55
+ "@heroui/use-aria-button": "2.2.8",
56
+ "@heroui/use-safe-layout-effect": "2.1.5"
57
57
  },
58
58
  "clean-package": "../../../clean-package.config.json",
59
59
  "module": "dist/index.mjs",