@heroui/autocomplete 2.3.23-beta.2 → 2.3.23
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/dist/autocomplete.js +17 -14
- package/dist/autocomplete.mjs +2 -2
- package/dist/{chunk-JHANFQCV.mjs → chunk-ENG265Z6.mjs} +4 -1
- package/dist/{chunk-PRL2CTH4.mjs → chunk-FWJM6QZX.mjs} +1 -1
- package/dist/index.js +17 -14
- package/dist/index.mjs +2 -2
- package/dist/use-autocomplete.d.mts +2 -2
- package/dist/use-autocomplete.d.ts +2 -2
- package/dist/use-autocomplete.js +17 -14
- package/dist/use-autocomplete.mjs +1 -1
- package/package.json +15 -14
package/dist/autocomplete.js
CHANGED
|
@@ -34,6 +34,7 @@ var import_input = require("@heroui/input");
|
|
|
34
34
|
var import_framer_motion = require("framer-motion");
|
|
35
35
|
|
|
36
36
|
// src/use-autocomplete.ts
|
|
37
|
+
var import_utils = require("@react-aria/utils");
|
|
37
38
|
var import_shared_utils = require("@heroui/shared-utils");
|
|
38
39
|
var import_react = require("react");
|
|
39
40
|
var import_react_utils = require("@heroui/react-utils");
|
|
@@ -44,6 +45,7 @@ var import_use_safe_layout_effect = require("@heroui/use-safe-layout-effect");
|
|
|
44
45
|
var import_system = require("@heroui/system");
|
|
45
46
|
var import_combobox2 = require("@react-aria/combobox");
|
|
46
47
|
var import_form = require("@heroui/form");
|
|
48
|
+
var import_aria_utils = require("@heroui/aria-utils");
|
|
47
49
|
function useAutocomplete(originalProps) {
|
|
48
50
|
var _a, _b, _c, _d, _e;
|
|
49
51
|
const globalContext = (0, import_system.useProviderContext)();
|
|
@@ -137,7 +139,7 @@ function useAutocomplete(originalProps) {
|
|
|
137
139
|
);
|
|
138
140
|
const isInvalid = originalProps.isInvalid || isAriaInvalid;
|
|
139
141
|
const slotsProps = {
|
|
140
|
-
inputProps: (0,
|
|
142
|
+
inputProps: (0, import_utils.mergeProps)(
|
|
141
143
|
{
|
|
142
144
|
label,
|
|
143
145
|
ref: inputRef,
|
|
@@ -152,7 +154,7 @@ function useAutocomplete(originalProps) {
|
|
|
152
154
|
},
|
|
153
155
|
userInputProps
|
|
154
156
|
),
|
|
155
|
-
popoverProps: (0,
|
|
157
|
+
popoverProps: (0, import_utils.mergeProps)(
|
|
156
158
|
{
|
|
157
159
|
offset: 5,
|
|
158
160
|
placement: "bottom",
|
|
@@ -161,7 +163,7 @@ function useAutocomplete(originalProps) {
|
|
|
161
163
|
},
|
|
162
164
|
popoverProps
|
|
163
165
|
),
|
|
164
|
-
scrollShadowProps: (0,
|
|
166
|
+
scrollShadowProps: (0, import_utils.mergeProps)(
|
|
165
167
|
{
|
|
166
168
|
ref: scrollShadowRef,
|
|
167
169
|
isEnabled: (_d = showScrollIndicators && state.collection.size > 5) != null ? _d : true,
|
|
@@ -170,7 +172,7 @@ function useAutocomplete(originalProps) {
|
|
|
170
172
|
},
|
|
171
173
|
scrollShadowProps
|
|
172
174
|
),
|
|
173
|
-
listboxProps: (0,
|
|
175
|
+
listboxProps: (0, import_utils.mergeProps)(
|
|
174
176
|
{
|
|
175
177
|
hideEmptyContent: allowsCustomValue,
|
|
176
178
|
emptyContent: "No results found.",
|
|
@@ -178,7 +180,7 @@ function useAutocomplete(originalProps) {
|
|
|
178
180
|
},
|
|
179
181
|
listboxProps
|
|
180
182
|
),
|
|
181
|
-
selectorButtonProps: (0,
|
|
183
|
+
selectorButtonProps: (0, import_utils.mergeProps)(
|
|
182
184
|
{
|
|
183
185
|
isLoading,
|
|
184
186
|
size: "sm",
|
|
@@ -190,7 +192,7 @@ function useAutocomplete(originalProps) {
|
|
|
190
192
|
},
|
|
191
193
|
selectorButtonProps
|
|
192
194
|
),
|
|
193
|
-
clearButtonProps: (0,
|
|
195
|
+
clearButtonProps: (0, import_utils.mergeProps)(
|
|
194
196
|
{
|
|
195
197
|
size: "sm",
|
|
196
198
|
variant: "light",
|
|
@@ -275,7 +277,7 @@ function useAutocomplete(originalProps) {
|
|
|
275
277
|
var _a2;
|
|
276
278
|
return {
|
|
277
279
|
ref: buttonRef,
|
|
278
|
-
...(0,
|
|
280
|
+
...(0, import_utils.mergeProps)(buttonProps, slotsProps.selectorButtonProps),
|
|
279
281
|
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
280
282
|
className: slots.selectorButton({
|
|
281
283
|
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.selectorButton, (_a2 = slotsProps.selectorButtonProps) == null ? void 0 : _a2.className)
|
|
@@ -285,7 +287,7 @@ function useAutocomplete(originalProps) {
|
|
|
285
287
|
const getClearButtonProps = () => {
|
|
286
288
|
var _a2, _b2;
|
|
287
289
|
return {
|
|
288
|
-
...(0,
|
|
290
|
+
...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
|
|
289
291
|
// disable original focus and state toggle from react aria
|
|
290
292
|
onPressStart: () => {
|
|
291
293
|
var _a3;
|
|
@@ -315,7 +317,7 @@ function useAutocomplete(originalProps) {
|
|
|
315
317
|
isInvalid: hasUncommittedValidation ? void 0 : isInvalid,
|
|
316
318
|
validationBehavior,
|
|
317
319
|
errorMessage: typeof errorMessage === "function" ? errorMessage({ isInvalid, validationErrors, validationDetails }) : errorMessage || (validationErrors == null ? void 0 : validationErrors.join(" ")),
|
|
318
|
-
onClick: (0,
|
|
320
|
+
onClick: (0, import_utils.chain)(slotsProps.inputProps.onClick, otherProps.onClick)
|
|
319
321
|
});
|
|
320
322
|
const getListBoxProps = () => {
|
|
321
323
|
const shouldVirtualize = isVirtualized != null ? isVirtualized : state.collection.size > 50;
|
|
@@ -328,14 +330,14 @@ function useAutocomplete(originalProps) {
|
|
|
328
330
|
itemHeight
|
|
329
331
|
} : void 0,
|
|
330
332
|
scrollShadowProps: slotsProps.scrollShadowProps,
|
|
331
|
-
...(0,
|
|
333
|
+
...(0, import_utils.mergeProps)(slotsProps.listboxProps, listBoxProps, {
|
|
332
334
|
shouldHighlightOnFocus: true
|
|
333
335
|
})
|
|
334
336
|
};
|
|
335
337
|
};
|
|
336
338
|
const getPopoverProps = (props2 = {}) => {
|
|
337
339
|
var _a2, _b2, _c2;
|
|
338
|
-
const popoverProps2 = (0,
|
|
340
|
+
const popoverProps2 = (0, import_utils.mergeProps)(slotsProps.popoverProps, props2);
|
|
339
341
|
return {
|
|
340
342
|
state,
|
|
341
343
|
ref: popoverRef,
|
|
@@ -353,6 +355,7 @@ function useAutocomplete(originalProps) {
|
|
|
353
355
|
)
|
|
354
356
|
})
|
|
355
357
|
},
|
|
358
|
+
shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
|
|
356
359
|
// when the popover is open, the focus should be on input instead of dialog
|
|
357
360
|
// therefore, we skip dialog focus here
|
|
358
361
|
disableDialogFocus: true
|
|
@@ -367,7 +370,7 @@ function useAutocomplete(originalProps) {
|
|
|
367
370
|
const getListBoxWrapperProps = (props2 = {}) => {
|
|
368
371
|
var _a2, _b2;
|
|
369
372
|
return {
|
|
370
|
-
...(0,
|
|
373
|
+
...(0, import_utils.mergeProps)(slotsProps.scrollShadowProps, props2),
|
|
371
374
|
className: slots.listboxWrapper({
|
|
372
375
|
class: (0, import_shared_utils.clsx)(
|
|
373
376
|
classNames == null ? void 0 : classNames.listboxWrapper,
|
|
@@ -384,13 +387,13 @@ function useAutocomplete(originalProps) {
|
|
|
384
387
|
className: slots.endContentWrapper({
|
|
385
388
|
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.endContentWrapper, props2 == null ? void 0 : props2.className)
|
|
386
389
|
}),
|
|
387
|
-
onPointerDown: (0,
|
|
390
|
+
onPointerDown: (0, import_utils.chain)(props2.onPointerDown, (e) => {
|
|
388
391
|
var _a2;
|
|
389
392
|
if (e.button === 0 && e.currentTarget === e.target) {
|
|
390
393
|
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
391
394
|
}
|
|
392
395
|
}),
|
|
393
|
-
onMouseDown: (0,
|
|
396
|
+
onMouseDown: (0, import_utils.chain)(props2.onMouseDown, (e) => {
|
|
394
397
|
if (e.button === 0 && e.currentTarget === e.target) {
|
|
395
398
|
e.preventDefault();
|
|
396
399
|
}
|
package/dist/autocomplete.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/use-autocomplete.ts
|
|
4
|
-
import {
|
|
4
|
+
import { chain, mergeProps } from "@react-aria/utils";
|
|
5
|
+
import { clsx, dataAttr, objectToDeps } from "@heroui/shared-utils";
|
|
5
6
|
import { useEffect, useMemo, useRef } from "react";
|
|
6
7
|
import { useDOMRef } from "@heroui/react-utils";
|
|
7
8
|
import { useComboBoxState } from "@react-stately/combobox";
|
|
@@ -11,6 +12,7 @@ import { useSafeLayoutEffect } from "@heroui/use-safe-layout-effect";
|
|
|
11
12
|
import { mapPropsVariants, useProviderContext } from "@heroui/system";
|
|
12
13
|
import { useComboBox } from "@react-aria/combobox";
|
|
13
14
|
import { FormContext, useSlottedContext } from "@heroui/form";
|
|
15
|
+
import { ariaShouldCloseOnInteractOutside } from "@heroui/aria-utils";
|
|
14
16
|
function useAutocomplete(originalProps) {
|
|
15
17
|
var _a, _b, _c, _d, _e;
|
|
16
18
|
const globalContext = useProviderContext();
|
|
@@ -320,6 +322,7 @@ function useAutocomplete(originalProps) {
|
|
|
320
322
|
)
|
|
321
323
|
})
|
|
322
324
|
},
|
|
325
|
+
shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => ariaShouldCloseOnInteractOutside(element, inputWrapperRef, state),
|
|
323
326
|
// when the popover is open, the focus should be on input instead of dialog
|
|
324
327
|
// therefore, we skip dialog focus here
|
|
325
328
|
disableDialogFocus: true
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var import_input = require("@heroui/input");
|
|
|
40
40
|
var import_framer_motion = require("framer-motion");
|
|
41
41
|
|
|
42
42
|
// src/use-autocomplete.ts
|
|
43
|
+
var import_utils = require("@react-aria/utils");
|
|
43
44
|
var import_shared_utils = require("@heroui/shared-utils");
|
|
44
45
|
var import_react = require("react");
|
|
45
46
|
var import_react_utils = require("@heroui/react-utils");
|
|
@@ -50,6 +51,7 @@ var import_use_safe_layout_effect = require("@heroui/use-safe-layout-effect");
|
|
|
50
51
|
var import_system = require("@heroui/system");
|
|
51
52
|
var import_combobox2 = require("@react-aria/combobox");
|
|
52
53
|
var import_form = require("@heroui/form");
|
|
54
|
+
var import_aria_utils = require("@heroui/aria-utils");
|
|
53
55
|
function useAutocomplete(originalProps) {
|
|
54
56
|
var _a, _b, _c, _d, _e;
|
|
55
57
|
const globalContext = (0, import_system.useProviderContext)();
|
|
@@ -143,7 +145,7 @@ function useAutocomplete(originalProps) {
|
|
|
143
145
|
);
|
|
144
146
|
const isInvalid = originalProps.isInvalid || isAriaInvalid;
|
|
145
147
|
const slotsProps = {
|
|
146
|
-
inputProps: (0,
|
|
148
|
+
inputProps: (0, import_utils.mergeProps)(
|
|
147
149
|
{
|
|
148
150
|
label,
|
|
149
151
|
ref: inputRef,
|
|
@@ -158,7 +160,7 @@ function useAutocomplete(originalProps) {
|
|
|
158
160
|
},
|
|
159
161
|
userInputProps
|
|
160
162
|
),
|
|
161
|
-
popoverProps: (0,
|
|
163
|
+
popoverProps: (0, import_utils.mergeProps)(
|
|
162
164
|
{
|
|
163
165
|
offset: 5,
|
|
164
166
|
placement: "bottom",
|
|
@@ -167,7 +169,7 @@ function useAutocomplete(originalProps) {
|
|
|
167
169
|
},
|
|
168
170
|
popoverProps
|
|
169
171
|
),
|
|
170
|
-
scrollShadowProps: (0,
|
|
172
|
+
scrollShadowProps: (0, import_utils.mergeProps)(
|
|
171
173
|
{
|
|
172
174
|
ref: scrollShadowRef,
|
|
173
175
|
isEnabled: (_d = showScrollIndicators && state.collection.size > 5) != null ? _d : true,
|
|
@@ -176,7 +178,7 @@ function useAutocomplete(originalProps) {
|
|
|
176
178
|
},
|
|
177
179
|
scrollShadowProps
|
|
178
180
|
),
|
|
179
|
-
listboxProps: (0,
|
|
181
|
+
listboxProps: (0, import_utils.mergeProps)(
|
|
180
182
|
{
|
|
181
183
|
hideEmptyContent: allowsCustomValue,
|
|
182
184
|
emptyContent: "No results found.",
|
|
@@ -184,7 +186,7 @@ function useAutocomplete(originalProps) {
|
|
|
184
186
|
},
|
|
185
187
|
listboxProps
|
|
186
188
|
),
|
|
187
|
-
selectorButtonProps: (0,
|
|
189
|
+
selectorButtonProps: (0, import_utils.mergeProps)(
|
|
188
190
|
{
|
|
189
191
|
isLoading,
|
|
190
192
|
size: "sm",
|
|
@@ -196,7 +198,7 @@ function useAutocomplete(originalProps) {
|
|
|
196
198
|
},
|
|
197
199
|
selectorButtonProps
|
|
198
200
|
),
|
|
199
|
-
clearButtonProps: (0,
|
|
201
|
+
clearButtonProps: (0, import_utils.mergeProps)(
|
|
200
202
|
{
|
|
201
203
|
size: "sm",
|
|
202
204
|
variant: "light",
|
|
@@ -281,7 +283,7 @@ function useAutocomplete(originalProps) {
|
|
|
281
283
|
var _a2;
|
|
282
284
|
return {
|
|
283
285
|
ref: buttonRef,
|
|
284
|
-
...(0,
|
|
286
|
+
...(0, import_utils.mergeProps)(buttonProps, slotsProps.selectorButtonProps),
|
|
285
287
|
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
286
288
|
className: slots.selectorButton({
|
|
287
289
|
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.selectorButton, (_a2 = slotsProps.selectorButtonProps) == null ? void 0 : _a2.className)
|
|
@@ -291,7 +293,7 @@ function useAutocomplete(originalProps) {
|
|
|
291
293
|
const getClearButtonProps = () => {
|
|
292
294
|
var _a2, _b2;
|
|
293
295
|
return {
|
|
294
|
-
...(0,
|
|
296
|
+
...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
|
|
295
297
|
// disable original focus and state toggle from react aria
|
|
296
298
|
onPressStart: () => {
|
|
297
299
|
var _a3;
|
|
@@ -321,7 +323,7 @@ function useAutocomplete(originalProps) {
|
|
|
321
323
|
isInvalid: hasUncommittedValidation ? void 0 : isInvalid,
|
|
322
324
|
validationBehavior,
|
|
323
325
|
errorMessage: typeof errorMessage === "function" ? errorMessage({ isInvalid, validationErrors, validationDetails }) : errorMessage || (validationErrors == null ? void 0 : validationErrors.join(" ")),
|
|
324
|
-
onClick: (0,
|
|
326
|
+
onClick: (0, import_utils.chain)(slotsProps.inputProps.onClick, otherProps.onClick)
|
|
325
327
|
});
|
|
326
328
|
const getListBoxProps = () => {
|
|
327
329
|
const shouldVirtualize = isVirtualized != null ? isVirtualized : state.collection.size > 50;
|
|
@@ -334,14 +336,14 @@ function useAutocomplete(originalProps) {
|
|
|
334
336
|
itemHeight
|
|
335
337
|
} : void 0,
|
|
336
338
|
scrollShadowProps: slotsProps.scrollShadowProps,
|
|
337
|
-
...(0,
|
|
339
|
+
...(0, import_utils.mergeProps)(slotsProps.listboxProps, listBoxProps, {
|
|
338
340
|
shouldHighlightOnFocus: true
|
|
339
341
|
})
|
|
340
342
|
};
|
|
341
343
|
};
|
|
342
344
|
const getPopoverProps = (props2 = {}) => {
|
|
343
345
|
var _a2, _b2, _c2;
|
|
344
|
-
const popoverProps2 = (0,
|
|
346
|
+
const popoverProps2 = (0, import_utils.mergeProps)(slotsProps.popoverProps, props2);
|
|
345
347
|
return {
|
|
346
348
|
state,
|
|
347
349
|
ref: popoverRef,
|
|
@@ -359,6 +361,7 @@ function useAutocomplete(originalProps) {
|
|
|
359
361
|
)
|
|
360
362
|
})
|
|
361
363
|
},
|
|
364
|
+
shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
|
|
362
365
|
// when the popover is open, the focus should be on input instead of dialog
|
|
363
366
|
// therefore, we skip dialog focus here
|
|
364
367
|
disableDialogFocus: true
|
|
@@ -373,7 +376,7 @@ function useAutocomplete(originalProps) {
|
|
|
373
376
|
const getListBoxWrapperProps = (props2 = {}) => {
|
|
374
377
|
var _a2, _b2;
|
|
375
378
|
return {
|
|
376
|
-
...(0,
|
|
379
|
+
...(0, import_utils.mergeProps)(slotsProps.scrollShadowProps, props2),
|
|
377
380
|
className: slots.listboxWrapper({
|
|
378
381
|
class: (0, import_shared_utils.clsx)(
|
|
379
382
|
classNames == null ? void 0 : classNames.listboxWrapper,
|
|
@@ -390,13 +393,13 @@ function useAutocomplete(originalProps) {
|
|
|
390
393
|
className: slots.endContentWrapper({
|
|
391
394
|
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.endContentWrapper, props2 == null ? void 0 : props2.className)
|
|
392
395
|
}),
|
|
393
|
-
onPointerDown: (0,
|
|
396
|
+
onPointerDown: (0, import_utils.chain)(props2.onPointerDown, (e) => {
|
|
394
397
|
var _a2;
|
|
395
398
|
if (e.button === 0 && e.currentTarget === e.target) {
|
|
396
399
|
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
397
400
|
}
|
|
398
401
|
}),
|
|
399
|
-
onMouseDown: (0,
|
|
402
|
+
onMouseDown: (0, import_utils.chain)(props2.onMouseDown, (e) => {
|
|
400
403
|
if (e.button === 0 && e.currentTarget === e.target) {
|
|
401
404
|
e.preventDefault();
|
|
402
405
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
autocomplete_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FWJM6QZX.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useAutocomplete
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ENG265Z6.mjs";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
import { ListboxItem, ListboxSection } from "@heroui/listbox";
|
|
@@ -4,8 +4,8 @@ import { FilterFn } from '@react-stately/combobox';
|
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import * as _heroui_system from '@heroui/system';
|
|
7
|
-
import {
|
|
8
|
-
import { SlotsToClasses, AutocompleteSlots
|
|
7
|
+
import { PropGetter, DOMAttributes, HTMLHeroUIProps } from '@heroui/system';
|
|
8
|
+
import { AutocompleteVariantProps, SlotsToClasses, AutocompleteSlots } from '@heroui/theme';
|
|
9
9
|
import { ReactRef } from '@heroui/react-utils';
|
|
10
10
|
import { ComboBoxProps } from '@react-types/combobox';
|
|
11
11
|
import { PopoverProps } from '@heroui/popover';
|
|
@@ -4,8 +4,8 @@ import { FilterFn } from '@react-stately/combobox';
|
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import * as _heroui_system from '@heroui/system';
|
|
7
|
-
import {
|
|
8
|
-
import { SlotsToClasses, AutocompleteSlots
|
|
7
|
+
import { PropGetter, DOMAttributes, HTMLHeroUIProps } from '@heroui/system';
|
|
8
|
+
import { AutocompleteVariantProps, SlotsToClasses, AutocompleteSlots } from '@heroui/theme';
|
|
9
9
|
import { ReactRef } from '@heroui/react-utils';
|
|
10
10
|
import { ComboBoxProps } from '@react-types/combobox';
|
|
11
11
|
import { PopoverProps } from '@heroui/popover';
|
package/dist/use-autocomplete.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(use_autocomplete_exports, {
|
|
|
24
24
|
useAutocomplete: () => useAutocomplete
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(use_autocomplete_exports);
|
|
27
|
+
var import_utils = require("@react-aria/utils");
|
|
27
28
|
var import_shared_utils = require("@heroui/shared-utils");
|
|
28
29
|
var import_react = require("react");
|
|
29
30
|
var import_react_utils = require("@heroui/react-utils");
|
|
@@ -34,6 +35,7 @@ var import_use_safe_layout_effect = require("@heroui/use-safe-layout-effect");
|
|
|
34
35
|
var import_system = require("@heroui/system");
|
|
35
36
|
var import_combobox2 = require("@react-aria/combobox");
|
|
36
37
|
var import_form = require("@heroui/form");
|
|
38
|
+
var import_aria_utils = require("@heroui/aria-utils");
|
|
37
39
|
function useAutocomplete(originalProps) {
|
|
38
40
|
var _a, _b, _c, _d, _e;
|
|
39
41
|
const globalContext = (0, import_system.useProviderContext)();
|
|
@@ -127,7 +129,7 @@ function useAutocomplete(originalProps) {
|
|
|
127
129
|
);
|
|
128
130
|
const isInvalid = originalProps.isInvalid || isAriaInvalid;
|
|
129
131
|
const slotsProps = {
|
|
130
|
-
inputProps: (0,
|
|
132
|
+
inputProps: (0, import_utils.mergeProps)(
|
|
131
133
|
{
|
|
132
134
|
label,
|
|
133
135
|
ref: inputRef,
|
|
@@ -142,7 +144,7 @@ function useAutocomplete(originalProps) {
|
|
|
142
144
|
},
|
|
143
145
|
userInputProps
|
|
144
146
|
),
|
|
145
|
-
popoverProps: (0,
|
|
147
|
+
popoverProps: (0, import_utils.mergeProps)(
|
|
146
148
|
{
|
|
147
149
|
offset: 5,
|
|
148
150
|
placement: "bottom",
|
|
@@ -151,7 +153,7 @@ function useAutocomplete(originalProps) {
|
|
|
151
153
|
},
|
|
152
154
|
popoverProps
|
|
153
155
|
),
|
|
154
|
-
scrollShadowProps: (0,
|
|
156
|
+
scrollShadowProps: (0, import_utils.mergeProps)(
|
|
155
157
|
{
|
|
156
158
|
ref: scrollShadowRef,
|
|
157
159
|
isEnabled: (_d = showScrollIndicators && state.collection.size > 5) != null ? _d : true,
|
|
@@ -160,7 +162,7 @@ function useAutocomplete(originalProps) {
|
|
|
160
162
|
},
|
|
161
163
|
scrollShadowProps
|
|
162
164
|
),
|
|
163
|
-
listboxProps: (0,
|
|
165
|
+
listboxProps: (0, import_utils.mergeProps)(
|
|
164
166
|
{
|
|
165
167
|
hideEmptyContent: allowsCustomValue,
|
|
166
168
|
emptyContent: "No results found.",
|
|
@@ -168,7 +170,7 @@ function useAutocomplete(originalProps) {
|
|
|
168
170
|
},
|
|
169
171
|
listboxProps
|
|
170
172
|
),
|
|
171
|
-
selectorButtonProps: (0,
|
|
173
|
+
selectorButtonProps: (0, import_utils.mergeProps)(
|
|
172
174
|
{
|
|
173
175
|
isLoading,
|
|
174
176
|
size: "sm",
|
|
@@ -180,7 +182,7 @@ function useAutocomplete(originalProps) {
|
|
|
180
182
|
},
|
|
181
183
|
selectorButtonProps
|
|
182
184
|
),
|
|
183
|
-
clearButtonProps: (0,
|
|
185
|
+
clearButtonProps: (0, import_utils.mergeProps)(
|
|
184
186
|
{
|
|
185
187
|
size: "sm",
|
|
186
188
|
variant: "light",
|
|
@@ -265,7 +267,7 @@ function useAutocomplete(originalProps) {
|
|
|
265
267
|
var _a2;
|
|
266
268
|
return {
|
|
267
269
|
ref: buttonRef,
|
|
268
|
-
...(0,
|
|
270
|
+
...(0, import_utils.mergeProps)(buttonProps, slotsProps.selectorButtonProps),
|
|
269
271
|
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
270
272
|
className: slots.selectorButton({
|
|
271
273
|
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.selectorButton, (_a2 = slotsProps.selectorButtonProps) == null ? void 0 : _a2.className)
|
|
@@ -275,7 +277,7 @@ function useAutocomplete(originalProps) {
|
|
|
275
277
|
const getClearButtonProps = () => {
|
|
276
278
|
var _a2, _b2;
|
|
277
279
|
return {
|
|
278
|
-
...(0,
|
|
280
|
+
...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
|
|
279
281
|
// disable original focus and state toggle from react aria
|
|
280
282
|
onPressStart: () => {
|
|
281
283
|
var _a3;
|
|
@@ -305,7 +307,7 @@ function useAutocomplete(originalProps) {
|
|
|
305
307
|
isInvalid: hasUncommittedValidation ? void 0 : isInvalid,
|
|
306
308
|
validationBehavior,
|
|
307
309
|
errorMessage: typeof errorMessage === "function" ? errorMessage({ isInvalid, validationErrors, validationDetails }) : errorMessage || (validationErrors == null ? void 0 : validationErrors.join(" ")),
|
|
308
|
-
onClick: (0,
|
|
310
|
+
onClick: (0, import_utils.chain)(slotsProps.inputProps.onClick, otherProps.onClick)
|
|
309
311
|
});
|
|
310
312
|
const getListBoxProps = () => {
|
|
311
313
|
const shouldVirtualize = isVirtualized != null ? isVirtualized : state.collection.size > 50;
|
|
@@ -318,14 +320,14 @@ function useAutocomplete(originalProps) {
|
|
|
318
320
|
itemHeight
|
|
319
321
|
} : void 0,
|
|
320
322
|
scrollShadowProps: slotsProps.scrollShadowProps,
|
|
321
|
-
...(0,
|
|
323
|
+
...(0, import_utils.mergeProps)(slotsProps.listboxProps, listBoxProps, {
|
|
322
324
|
shouldHighlightOnFocus: true
|
|
323
325
|
})
|
|
324
326
|
};
|
|
325
327
|
};
|
|
326
328
|
const getPopoverProps = (props2 = {}) => {
|
|
327
329
|
var _a2, _b2, _c2;
|
|
328
|
-
const popoverProps2 = (0,
|
|
330
|
+
const popoverProps2 = (0, import_utils.mergeProps)(slotsProps.popoverProps, props2);
|
|
329
331
|
return {
|
|
330
332
|
state,
|
|
331
333
|
ref: popoverRef,
|
|
@@ -343,6 +345,7 @@ function useAutocomplete(originalProps) {
|
|
|
343
345
|
)
|
|
344
346
|
})
|
|
345
347
|
},
|
|
348
|
+
shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
|
|
346
349
|
// when the popover is open, the focus should be on input instead of dialog
|
|
347
350
|
// therefore, we skip dialog focus here
|
|
348
351
|
disableDialogFocus: true
|
|
@@ -357,7 +360,7 @@ function useAutocomplete(originalProps) {
|
|
|
357
360
|
const getListBoxWrapperProps = (props2 = {}) => {
|
|
358
361
|
var _a2, _b2;
|
|
359
362
|
return {
|
|
360
|
-
...(0,
|
|
363
|
+
...(0, import_utils.mergeProps)(slotsProps.scrollShadowProps, props2),
|
|
361
364
|
className: slots.listboxWrapper({
|
|
362
365
|
class: (0, import_shared_utils.clsx)(
|
|
363
366
|
classNames == null ? void 0 : classNames.listboxWrapper,
|
|
@@ -374,13 +377,13 @@ function useAutocomplete(originalProps) {
|
|
|
374
377
|
className: slots.endContentWrapper({
|
|
375
378
|
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.endContentWrapper, props2 == null ? void 0 : props2.className)
|
|
376
379
|
}),
|
|
377
|
-
onPointerDown: (0,
|
|
380
|
+
onPointerDown: (0, import_utils.chain)(props2.onPointerDown, (e) => {
|
|
378
381
|
var _a2;
|
|
379
382
|
if (e.button === 0 && e.currentTarget === e.target) {
|
|
380
383
|
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
381
384
|
}
|
|
382
385
|
}),
|
|
383
|
-
onMouseDown: (0,
|
|
386
|
+
onMouseDown: (0, import_utils.chain)(props2.onMouseDown, (e) => {
|
|
384
387
|
if (e.button === 0 && e.currentTarget === e.target) {
|
|
385
388
|
e.preventDefault();
|
|
386
389
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroui/autocomplete",
|
|
3
|
-
"version": "2.3.23
|
|
3
|
+
"version": "2.3.23",
|
|
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"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/heroui-inc/heroui/issues"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@heroui/system": ">=2.4.
|
|
29
|
-
"@heroui/theme": ">=2.4.
|
|
28
|
+
"@heroui/system": ">=2.4.17",
|
|
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"
|
|
@@ -34,20 +34,21 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@react-aria/combobox": "3.12.5",
|
|
36
36
|
"@react-aria/i18n": "3.12.10",
|
|
37
|
+
"@react-aria/utils": "3.29.1",
|
|
37
38
|
"@react-stately/combobox": "3.10.6",
|
|
38
39
|
"@react-types/combobox": "3.13.6",
|
|
39
40
|
"@react-types/shared": "3.30.0",
|
|
40
|
-
"@heroui/
|
|
41
|
-
"@heroui/
|
|
42
|
-
"@heroui/button": "2.2.22
|
|
43
|
-
"@heroui/input": "2.4.22
|
|
44
|
-
"@heroui/listbox": "2.3.21
|
|
45
|
-
"@heroui/popover": "2.3.22
|
|
46
|
-
"@heroui/react-utils": "2.1.
|
|
47
|
-
"@heroui/scroll-shadow": "2.3.15
|
|
48
|
-
"@heroui/shared-icons": "2.1.
|
|
49
|
-
"@heroui/shared-utils": "2.1.
|
|
50
|
-
"@heroui/use-safe-layout-effect": "2.1.
|
|
41
|
+
"@heroui/form": "2.1.21",
|
|
42
|
+
"@heroui/aria-utils": "2.2.19",
|
|
43
|
+
"@heroui/button": "2.2.22",
|
|
44
|
+
"@heroui/input": "2.4.22",
|
|
45
|
+
"@heroui/listbox": "2.3.21",
|
|
46
|
+
"@heroui/popover": "2.3.22",
|
|
47
|
+
"@heroui/react-utils": "2.1.11",
|
|
48
|
+
"@heroui/scroll-shadow": "2.3.15",
|
|
49
|
+
"@heroui/shared-icons": "2.1.9",
|
|
50
|
+
"@heroui/shared-utils": "2.1.9",
|
|
51
|
+
"@heroui/use-safe-layout-effect": "2.1.7"
|
|
51
52
|
},
|
|
52
53
|
"clean-package": "../../../clean-package.config.json",
|
|
53
54
|
"module": "dist/index.mjs",
|