@heroui/autocomplete 2.3.10 → 2.3.12
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 +1 -1
- package/README.md +2 -2
- package/package.json +28 -28
- package/dist/autocomplete.d.ts +0 -21
- package/dist/autocomplete.js +0 -447
- package/dist/autocomplete.mjs +0 -8
- package/dist/chunk-QZCVHGAT.mjs +0 -377
- package/dist/chunk-SV7R5B4H.mjs +0 -55
- package/dist/index.d.ts +0 -19
- package/dist/index.js +0 -458
- package/dist/index.mjs +0 -16
- package/dist/use-autocomplete.d.ts +0 -229
- package/dist/use-autocomplete.js +0 -400
- package/dist/use-autocomplete.mjs +0 -7
package/LICENSE
CHANGED
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/
|
|
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/
|
|
24
|
+
[MIT license](https://github.com/heroui-inc/heroui/blob/master/LICENSE).
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroui/autocomplete",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.12",
|
|
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": "
|
|
8
|
+
"author": "HeroUI <support@heroui.com>",
|
|
9
9
|
"homepage": "https://heroui.com",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"main": "dist/index.js",
|
|
@@ -18,42 +18,42 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
21
|
+
"url": "git+https://github.com/heroui-inc/heroui.git",
|
|
22
22
|
"directory": "packages/components/autocomplete"
|
|
23
23
|
},
|
|
24
24
|
"bugs": {
|
|
25
|
-
"url": "https://github.com/
|
|
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.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.
|
|
36
|
-
"@react-aria/focus": "3.19.
|
|
37
|
-
"@react-aria/i18n": "3.12.
|
|
38
|
-
"@react-aria/interactions": "3.
|
|
39
|
-
"@react-aria/utils": "3.
|
|
40
|
-
"@react-aria/visually-hidden": "3.8.
|
|
41
|
-
"@react-stately/combobox": "3.10.
|
|
42
|
-
"@react-types/combobox": "3.13.
|
|
43
|
-
"@react-types/shared": "3.
|
|
44
|
-
"@heroui/form": "2.1.
|
|
45
|
-
"@heroui/aria-utils": "2.2.
|
|
46
|
-
"@heroui/button": "2.2.
|
|
47
|
-
"@heroui/input": "2.4.
|
|
48
|
-
"@heroui/listbox": "2.3.
|
|
49
|
-
"@heroui/popover": "2.3.
|
|
50
|
-
"@heroui/react-utils": "2.1.
|
|
51
|
-
"@heroui/
|
|
52
|
-
"@heroui/
|
|
53
|
-
"@heroui/
|
|
54
|
-
"@heroui/
|
|
55
|
-
"@heroui/
|
|
56
|
-
"@heroui/use-safe-layout-effect": "2.1.
|
|
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.10",
|
|
45
|
+
"@heroui/aria-utils": "2.2.9",
|
|
46
|
+
"@heroui/button": "2.2.11",
|
|
47
|
+
"@heroui/input": "2.4.11",
|
|
48
|
+
"@heroui/listbox": "2.3.11",
|
|
49
|
+
"@heroui/popover": "2.3.11",
|
|
50
|
+
"@heroui/react-utils": "2.1.5",
|
|
51
|
+
"@heroui/scroll-shadow": "2.3.7",
|
|
52
|
+
"@heroui/shared-icons": "2.1.3",
|
|
53
|
+
"@heroui/shared-utils": "2.1.4",
|
|
54
|
+
"@heroui/spinner": "2.2.8",
|
|
55
|
+
"@heroui/use-aria-button": "2.2.6",
|
|
56
|
+
"@heroui/use-safe-layout-effect": "2.1.3"
|
|
57
57
|
},
|
|
58
58
|
"clean-package": "../../../clean-package.config.json",
|
|
59
59
|
"module": "dist/index.mjs",
|
package/dist/autocomplete.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { UseAutocompleteProps } from './use-autocomplete.js';
|
|
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 { AutocompleteProps, Autocomplete as default };
|
package/dist/autocomplete.js
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/autocomplete.tsx
|
|
22
|
-
var autocomplete_exports = {};
|
|
23
|
-
__export(autocomplete_exports, {
|
|
24
|
-
default: () => autocomplete_default
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(autocomplete_exports);
|
|
27
|
-
var import_system2 = require("@heroui/system");
|
|
28
|
-
var import_popover = require("@heroui/popover");
|
|
29
|
-
var import_scroll_shadow = require("@heroui/scroll-shadow");
|
|
30
|
-
var import_shared_icons = require("@heroui/shared-icons");
|
|
31
|
-
var import_listbox = require("@heroui/listbox");
|
|
32
|
-
var import_button = require("@heroui/button");
|
|
33
|
-
var import_input = require("@heroui/input");
|
|
34
|
-
var import_framer_motion = require("framer-motion");
|
|
35
|
-
|
|
36
|
-
// src/use-autocomplete.ts
|
|
37
|
-
var import_system = require("@heroui/system");
|
|
38
|
-
var import_use_safe_layout_effect = require("@heroui/use-safe-layout-effect");
|
|
39
|
-
var import_theme = require("@heroui/theme");
|
|
40
|
-
var import_i18n = require("@react-aria/i18n");
|
|
41
|
-
var import_combobox = require("@react-stately/combobox");
|
|
42
|
-
var import_react_utils = require("@heroui/react-utils");
|
|
43
|
-
var import_react = require("react");
|
|
44
|
-
var import_shared_utils = require("@heroui/shared-utils");
|
|
45
|
-
var import_utils = require("@react-aria/utils");
|
|
46
|
-
var import_combobox2 = require("@react-aria/combobox");
|
|
47
|
-
var import_form = require("@heroui/form");
|
|
48
|
-
var import_aria_utils = require("@heroui/aria-utils");
|
|
49
|
-
function useAutocomplete(originalProps) {
|
|
50
|
-
var _a, _b, _c, _d, _e;
|
|
51
|
-
const globalContext = (0, import_system.useProviderContext)();
|
|
52
|
-
const { validationBehavior: formValidationBehavior } = (0, import_form.useSlottedContext)(import_form.FormContext) || {};
|
|
53
|
-
const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.autocomplete.variantKeys);
|
|
54
|
-
const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
55
|
-
const isClearable = originalProps.disableClearable !== void 0 ? !originalProps.disableClearable : originalProps.isReadOnly ? false : originalProps.isClearable;
|
|
56
|
-
const {
|
|
57
|
-
ref,
|
|
58
|
-
as,
|
|
59
|
-
label,
|
|
60
|
-
isLoading,
|
|
61
|
-
menuTrigger = "focus",
|
|
62
|
-
filterOptions = {
|
|
63
|
-
sensitivity: "base"
|
|
64
|
-
},
|
|
65
|
-
children,
|
|
66
|
-
selectorIcon,
|
|
67
|
-
clearIcon,
|
|
68
|
-
scrollRef: scrollRefProp,
|
|
69
|
-
defaultFilter,
|
|
70
|
-
endContent,
|
|
71
|
-
allowsEmptyCollection = true,
|
|
72
|
-
shouldCloseOnBlur = true,
|
|
73
|
-
popoverProps = {},
|
|
74
|
-
inputProps: userInputProps = {},
|
|
75
|
-
scrollShadowProps = {},
|
|
76
|
-
listboxProps = {},
|
|
77
|
-
selectorButtonProps = {},
|
|
78
|
-
clearButtonProps = {},
|
|
79
|
-
showScrollIndicators = true,
|
|
80
|
-
allowsCustomValue = false,
|
|
81
|
-
isVirtualized,
|
|
82
|
-
maxListboxHeight = 256,
|
|
83
|
-
itemHeight = 32,
|
|
84
|
-
validationBehavior = (_c = formValidationBehavior != null ? formValidationBehavior : globalContext == null ? void 0 : globalContext.validationBehavior) != null ? _c : "native",
|
|
85
|
-
className,
|
|
86
|
-
classNames,
|
|
87
|
-
errorMessage,
|
|
88
|
-
onOpenChange,
|
|
89
|
-
onClose,
|
|
90
|
-
isReadOnly = false,
|
|
91
|
-
...otherProps
|
|
92
|
-
} = props;
|
|
93
|
-
const { contains } = (0, import_i18n.useFilter)(filterOptions);
|
|
94
|
-
let state = (0, import_combobox.useComboBoxState)({
|
|
95
|
-
...originalProps,
|
|
96
|
-
children,
|
|
97
|
-
menuTrigger,
|
|
98
|
-
validationBehavior,
|
|
99
|
-
shouldCloseOnBlur,
|
|
100
|
-
allowsEmptyCollection,
|
|
101
|
-
defaultFilter: defaultFilter && typeof defaultFilter === "function" ? defaultFilter : contains,
|
|
102
|
-
onOpenChange: (open, menuTrigger2) => {
|
|
103
|
-
onOpenChange == null ? void 0 : onOpenChange(open, menuTrigger2);
|
|
104
|
-
if (!open) {
|
|
105
|
-
onClose == null ? void 0 : onClose();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
state = {
|
|
110
|
-
...state,
|
|
111
|
-
...isReadOnly && {
|
|
112
|
-
disabledKeys: /* @__PURE__ */ new Set([...state.collection.getKeys()])
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const buttonRef = (0, import_react.useRef)(null);
|
|
116
|
-
const inputWrapperRef = (0, import_react.useRef)(null);
|
|
117
|
-
const listBoxRef = (0, import_react.useRef)(null);
|
|
118
|
-
const popoverRef = (0, import_react.useRef)(null);
|
|
119
|
-
const inputRef = (0, import_react_utils.useDOMRef)(ref);
|
|
120
|
-
const scrollShadowRef = (0, import_react_utils.useDOMRef)(scrollRefProp);
|
|
121
|
-
const {
|
|
122
|
-
buttonProps,
|
|
123
|
-
inputProps,
|
|
124
|
-
listBoxProps,
|
|
125
|
-
isInvalid: isAriaInvalid,
|
|
126
|
-
validationDetails,
|
|
127
|
-
validationErrors
|
|
128
|
-
} = (0, import_combobox2.useComboBox)(
|
|
129
|
-
{
|
|
130
|
-
validationBehavior,
|
|
131
|
-
...originalProps,
|
|
132
|
-
inputRef,
|
|
133
|
-
buttonRef,
|
|
134
|
-
listBoxRef,
|
|
135
|
-
popoverRef
|
|
136
|
-
},
|
|
137
|
-
state
|
|
138
|
-
);
|
|
139
|
-
const isInvalid = originalProps.isInvalid || isAriaInvalid;
|
|
140
|
-
const slotsProps = {
|
|
141
|
-
inputProps: (0, import_utils.mergeProps)(
|
|
142
|
-
{
|
|
143
|
-
label,
|
|
144
|
-
ref: inputRef,
|
|
145
|
-
wrapperRef: inputWrapperRef,
|
|
146
|
-
onClick: () => {
|
|
147
|
-
if (!state.isOpen && !!state.selectedItem) {
|
|
148
|
-
state.open();
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
isClearable: false,
|
|
152
|
-
disableAnimation
|
|
153
|
-
},
|
|
154
|
-
userInputProps
|
|
155
|
-
),
|
|
156
|
-
popoverProps: (0, import_utils.mergeProps)(
|
|
157
|
-
{
|
|
158
|
-
offset: 5,
|
|
159
|
-
placement: "bottom",
|
|
160
|
-
triggerScaleOnOpen: false,
|
|
161
|
-
disableAnimation
|
|
162
|
-
},
|
|
163
|
-
popoverProps
|
|
164
|
-
),
|
|
165
|
-
scrollShadowProps: (0, import_utils.mergeProps)(
|
|
166
|
-
{
|
|
167
|
-
ref: scrollShadowRef,
|
|
168
|
-
isEnabled: (_d = showScrollIndicators && state.collection.size > 5) != null ? _d : true,
|
|
169
|
-
hideScrollBar: true,
|
|
170
|
-
offset: 15
|
|
171
|
-
},
|
|
172
|
-
scrollShadowProps
|
|
173
|
-
),
|
|
174
|
-
listboxProps: (0, import_utils.mergeProps)(
|
|
175
|
-
{
|
|
176
|
-
hideEmptyContent: allowsCustomValue,
|
|
177
|
-
emptyContent: "No results found.",
|
|
178
|
-
disableAnimation
|
|
179
|
-
},
|
|
180
|
-
listboxProps
|
|
181
|
-
),
|
|
182
|
-
selectorButtonProps: (0, import_utils.mergeProps)(
|
|
183
|
-
{
|
|
184
|
-
isLoading,
|
|
185
|
-
size: "sm",
|
|
186
|
-
variant: "light",
|
|
187
|
-
radius: "full",
|
|
188
|
-
color: isInvalid ? "danger" : originalProps == null ? void 0 : originalProps.color,
|
|
189
|
-
isIconOnly: true,
|
|
190
|
-
disableAnimation
|
|
191
|
-
},
|
|
192
|
-
selectorButtonProps
|
|
193
|
-
),
|
|
194
|
-
clearButtonProps: (0, import_utils.mergeProps)(
|
|
195
|
-
{
|
|
196
|
-
size: "sm",
|
|
197
|
-
variant: "light",
|
|
198
|
-
radius: "full",
|
|
199
|
-
color: isInvalid ? "danger" : originalProps == null ? void 0 : originalProps.color,
|
|
200
|
-
isIconOnly: true,
|
|
201
|
-
disableAnimation
|
|
202
|
-
},
|
|
203
|
-
clearButtonProps
|
|
204
|
-
)
|
|
205
|
-
};
|
|
206
|
-
const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
|
|
207
|
-
const isOpen = ((_e = slotsProps.listboxProps) == null ? void 0 : _e.hideEmptyContent) ? state.isOpen && !!state.collection.size : state.isOpen;
|
|
208
|
-
(0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
|
|
209
|
-
if (!inputRef.current)
|
|
210
|
-
return;
|
|
211
|
-
const key = inputRef.current.value;
|
|
212
|
-
const item = state.collection.getItem(key);
|
|
213
|
-
if (item && state.inputValue !== item.textValue) {
|
|
214
|
-
state.setSelectedKey(key);
|
|
215
|
-
state.setInputValue(item.textValue);
|
|
216
|
-
}
|
|
217
|
-
}, [inputRef.current]);
|
|
218
|
-
(0, import_react.useEffect)(() => {
|
|
219
|
-
let key = state.collection.getFirstKey();
|
|
220
|
-
while (key && state.disabledKeys.has(key)) {
|
|
221
|
-
key = state.collection.getKeyAfter(key);
|
|
222
|
-
}
|
|
223
|
-
state.selectionManager.setFocusedKey(key);
|
|
224
|
-
}, [state.collection, state.disabledKeys]);
|
|
225
|
-
(0, import_react.useEffect)(() => {
|
|
226
|
-
if (isOpen) {
|
|
227
|
-
if (popoverRef.current && inputWrapperRef.current) {
|
|
228
|
-
let rect = inputWrapperRef.current.getBoundingClientRect();
|
|
229
|
-
let popover = popoverRef.current;
|
|
230
|
-
popover.style.width = rect.width + "px";
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}, [isOpen]);
|
|
234
|
-
if (inputProps.onKeyDown) {
|
|
235
|
-
const originalOnKeyDown = inputProps.onKeyDown;
|
|
236
|
-
inputProps.onKeyDown = (e) => {
|
|
237
|
-
if ("continuePropagation" in e) {
|
|
238
|
-
e.stopPropagation = () => {
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
return originalOnKeyDown(e);
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
const Component = as || "div";
|
|
245
|
-
const slots = (0, import_react.useMemo)(
|
|
246
|
-
() => (0, import_theme.autocomplete)({
|
|
247
|
-
...variantProps,
|
|
248
|
-
isClearable,
|
|
249
|
-
disableAnimation,
|
|
250
|
-
className
|
|
251
|
-
}),
|
|
252
|
-
[(0, import_shared_utils.objectToDeps)(variantProps), isClearable, disableAnimation, className]
|
|
253
|
-
);
|
|
254
|
-
const getBaseProps = () => ({
|
|
255
|
-
"data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
|
|
256
|
-
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
257
|
-
className: slots.base({ class: baseStyles })
|
|
258
|
-
});
|
|
259
|
-
const getSelectorButtonProps = () => {
|
|
260
|
-
var _a2;
|
|
261
|
-
return {
|
|
262
|
-
ref: buttonRef,
|
|
263
|
-
...(0, import_utils.mergeProps)(buttonProps, slotsProps.selectorButtonProps),
|
|
264
|
-
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
265
|
-
className: slots.selectorButton({
|
|
266
|
-
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.selectorButton, (_a2 = slotsProps.selectorButtonProps) == null ? void 0 : _a2.className)
|
|
267
|
-
})
|
|
268
|
-
};
|
|
269
|
-
};
|
|
270
|
-
const getClearButtonProps = () => {
|
|
271
|
-
var _a2, _b2;
|
|
272
|
-
return {
|
|
273
|
-
...(0, import_utils.mergeProps)(buttonProps, slotsProps.clearButtonProps),
|
|
274
|
-
onPressStart: () => {
|
|
275
|
-
var _a3;
|
|
276
|
-
(_a3 = inputRef.current) == null ? void 0 : _a3.focus();
|
|
277
|
-
},
|
|
278
|
-
onPress: (e) => {
|
|
279
|
-
var _a3, _b3;
|
|
280
|
-
(_b3 = (_a3 = slotsProps.clearButtonProps) == null ? void 0 : _a3.onPress) == null ? void 0 : _b3.call(_a3, e);
|
|
281
|
-
if (state.selectedItem) {
|
|
282
|
-
state.setSelectedKey(null);
|
|
283
|
-
}
|
|
284
|
-
state.setInputValue("");
|
|
285
|
-
state.open();
|
|
286
|
-
},
|
|
287
|
-
"data-visible": !!state.selectedItem || ((_a2 = state.inputValue) == null ? void 0 : _a2.length) > 0,
|
|
288
|
-
className: slots.clearButton({
|
|
289
|
-
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.clearButton, (_b2 = slotsProps.clearButtonProps) == null ? void 0 : _b2.className)
|
|
290
|
-
})
|
|
291
|
-
};
|
|
292
|
-
};
|
|
293
|
-
const hasUncommittedValidation = validationBehavior === "native" && state.displayValidation.isInvalid === false && state.realtimeValidation.isInvalid === true;
|
|
294
|
-
const getInputProps = () => ({
|
|
295
|
-
...otherProps,
|
|
296
|
-
...inputProps,
|
|
297
|
-
...slotsProps.inputProps,
|
|
298
|
-
isInvalid: hasUncommittedValidation ? void 0 : isInvalid,
|
|
299
|
-
validationBehavior,
|
|
300
|
-
errorMessage: typeof errorMessage === "function" ? errorMessage({ isInvalid, validationErrors, validationDetails }) : errorMessage || (validationErrors == null ? void 0 : validationErrors.join(" ")),
|
|
301
|
-
onClick: (0, import_utils.chain)(slotsProps.inputProps.onClick, otherProps.onClick)
|
|
302
|
-
});
|
|
303
|
-
const getListBoxProps = () => {
|
|
304
|
-
const shouldVirtualize = isVirtualized != null ? isVirtualized : state.collection.size > 50;
|
|
305
|
-
return {
|
|
306
|
-
state,
|
|
307
|
-
ref: listBoxRef,
|
|
308
|
-
isVirtualized: shouldVirtualize,
|
|
309
|
-
virtualization: shouldVirtualize ? {
|
|
310
|
-
maxListboxHeight,
|
|
311
|
-
itemHeight
|
|
312
|
-
} : void 0,
|
|
313
|
-
scrollShadowProps: slotsProps.scrollShadowProps,
|
|
314
|
-
...(0, import_utils.mergeProps)(slotsProps.listboxProps, listBoxProps, {
|
|
315
|
-
shouldHighlightOnFocus: true
|
|
316
|
-
})
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
|
-
const getPopoverProps = (props2 = {}) => {
|
|
320
|
-
var _a2, _b2, _c2;
|
|
321
|
-
const popoverProps2 = (0, import_utils.mergeProps)(slotsProps.popoverProps, props2);
|
|
322
|
-
return {
|
|
323
|
-
state,
|
|
324
|
-
ref: popoverRef,
|
|
325
|
-
triggerRef: inputWrapperRef,
|
|
326
|
-
scrollRef: listBoxRef,
|
|
327
|
-
triggerType: "listbox",
|
|
328
|
-
...popoverProps2,
|
|
329
|
-
classNames: {
|
|
330
|
-
...(_a2 = slotsProps.popoverProps) == null ? void 0 : _a2.classNames,
|
|
331
|
-
content: slots.popoverContent({
|
|
332
|
-
class: (0, import_shared_utils.clsx)(
|
|
333
|
-
classNames == null ? void 0 : classNames.popoverContent,
|
|
334
|
-
(_c2 = (_b2 = slotsProps.popoverProps) == null ? void 0 : _b2.classNames) == null ? void 0 : _c2["content"],
|
|
335
|
-
props2.className
|
|
336
|
-
)
|
|
337
|
-
})
|
|
338
|
-
},
|
|
339
|
-
shouldCloseOnInteractOutside: (popoverProps2 == null ? void 0 : popoverProps2.shouldCloseOnInteractOutside) ? popoverProps2.shouldCloseOnInteractOutside : (element) => (0, import_aria_utils.ariaShouldCloseOnInteractOutside)(element, inputWrapperRef, state),
|
|
340
|
-
disableDialogFocus: true
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
const getEmptyPopoverProps = () => {
|
|
344
|
-
return {
|
|
345
|
-
ref: popoverRef,
|
|
346
|
-
className: "hidden"
|
|
347
|
-
};
|
|
348
|
-
};
|
|
349
|
-
const getListBoxWrapperProps = (props2 = {}) => {
|
|
350
|
-
var _a2, _b2;
|
|
351
|
-
return {
|
|
352
|
-
...(0, import_utils.mergeProps)(slotsProps.scrollShadowProps, props2),
|
|
353
|
-
className: slots.listboxWrapper({
|
|
354
|
-
class: (0, import_shared_utils.clsx)(
|
|
355
|
-
classNames == null ? void 0 : classNames.listboxWrapper,
|
|
356
|
-
(_a2 = slotsProps.scrollShadowProps) == null ? void 0 : _a2.className,
|
|
357
|
-
props2 == null ? void 0 : props2.className
|
|
358
|
-
)
|
|
359
|
-
}),
|
|
360
|
-
style: {
|
|
361
|
-
maxHeight: (_b2 = originalProps.maxListboxHeight) != null ? _b2 : 256
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
};
|
|
365
|
-
const getEndContentWrapperProps = (props2 = {}) => ({
|
|
366
|
-
className: slots.endContentWrapper({
|
|
367
|
-
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.endContentWrapper, props2 == null ? void 0 : props2.className)
|
|
368
|
-
}),
|
|
369
|
-
onPointerDown: (0, import_utils.chain)(props2.onPointerDown, (e) => {
|
|
370
|
-
var _a2;
|
|
371
|
-
if (e.button === 0 && e.currentTarget === e.target) {
|
|
372
|
-
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
373
|
-
}
|
|
374
|
-
}),
|
|
375
|
-
onMouseDown: (0, import_utils.chain)(props2.onMouseDown, (e) => {
|
|
376
|
-
if (e.button === 0 && e.currentTarget === e.target) {
|
|
377
|
-
e.preventDefault();
|
|
378
|
-
}
|
|
379
|
-
})
|
|
380
|
-
});
|
|
381
|
-
return {
|
|
382
|
-
Component,
|
|
383
|
-
inputRef,
|
|
384
|
-
label,
|
|
385
|
-
state,
|
|
386
|
-
slots,
|
|
387
|
-
classNames,
|
|
388
|
-
isLoading,
|
|
389
|
-
clearIcon,
|
|
390
|
-
isOpen,
|
|
391
|
-
endContent,
|
|
392
|
-
isClearable,
|
|
393
|
-
disableAnimation,
|
|
394
|
-
allowsCustomValue,
|
|
395
|
-
selectorIcon,
|
|
396
|
-
getBaseProps,
|
|
397
|
-
getInputProps,
|
|
398
|
-
getListBoxProps,
|
|
399
|
-
getPopoverProps,
|
|
400
|
-
getEmptyPopoverProps,
|
|
401
|
-
getClearButtonProps,
|
|
402
|
-
getSelectorButtonProps,
|
|
403
|
-
getListBoxWrapperProps,
|
|
404
|
-
getEndContentWrapperProps
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// src/autocomplete.tsx
|
|
409
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
410
|
-
var Autocomplete = (0, import_system2.forwardRef)(function Autocomplete2(props, ref) {
|
|
411
|
-
var _a;
|
|
412
|
-
const {
|
|
413
|
-
Component,
|
|
414
|
-
isOpen,
|
|
415
|
-
disableAnimation,
|
|
416
|
-
selectorIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_icons.ChevronDownIcon, {}),
|
|
417
|
-
clearIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_icons.CloseIcon, {}),
|
|
418
|
-
endContent,
|
|
419
|
-
getBaseProps,
|
|
420
|
-
getSelectorButtonProps,
|
|
421
|
-
getInputProps,
|
|
422
|
-
getListBoxProps,
|
|
423
|
-
getPopoverProps,
|
|
424
|
-
getEmptyPopoverProps,
|
|
425
|
-
getClearButtonProps,
|
|
426
|
-
getListBoxWrapperProps,
|
|
427
|
-
getEndContentWrapperProps
|
|
428
|
-
} = useAutocomplete({ ...props, ref });
|
|
429
|
-
const listboxProps = getListBoxProps();
|
|
430
|
-
const popoverContent = isOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.FreeSoloPopover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_scroll_shadow.ScrollShadow, { ...getListBoxWrapperProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_listbox.Listbox, { ...listboxProps }) }) }) : ((_a = listboxProps.state) == null ? void 0 : _a.collection.size) === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getEmptyPopoverProps() }) : null;
|
|
431
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Component, { ...getBaseProps(), children: [
|
|
432
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
433
|
-
import_input.Input,
|
|
434
|
-
{
|
|
435
|
-
...getInputProps(),
|
|
436
|
-
endContent: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...getEndContentWrapperProps(), children: [
|
|
437
|
-
endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { ...getClearButtonProps(), children: clearIcon }),
|
|
438
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { ...getSelectorButtonProps(), children: selectorIcon })
|
|
439
|
-
] })
|
|
440
|
-
}
|
|
441
|
-
),
|
|
442
|
-
disableAnimation ? popoverContent : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: popoverContent })
|
|
443
|
-
] });
|
|
444
|
-
});
|
|
445
|
-
var autocomplete_default = Autocomplete;
|
|
446
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
447
|
-
0 && (module.exports = {});
|