@yamada-ui/autocomplete 0.1.0

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.
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/autocomplete-list.tsx
21
+ var autocomplete_list_exports = {};
22
+ __export(autocomplete_list_exports, {
23
+ AutocompleteList: () => AutocompleteList
24
+ });
25
+ module.exports = __toCommonJS(autocomplete_list_exports);
26
+ var import_core2 = require("@yamada-ui/core");
27
+ var import_popover = require("@yamada-ui/popover");
28
+ var import_utils2 = require("@yamada-ui/utils");
29
+
30
+ // src/use-autocomplete.tsx
31
+ var import_core = require("@yamada-ui/core");
32
+ var import_form_control = require("@yamada-ui/form-control");
33
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
34
+ var import_use_descendant = require("@yamada-ui/use-descendant");
35
+ var import_use_outside_click = require("@yamada-ui/use-outside-click");
36
+ var import_utils = require("@yamada-ui/utils");
37
+ var import_react = require("react");
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var {
40
+ DescendantsContextProvider: AutocompleteDescendantsContextProvider,
41
+ useDescendantsContext: useAutocompleteDescendantsContext,
42
+ useDescendants: useAutocompleteDescendants,
43
+ useDescendant: useAutocompleteDescendant
44
+ } = (0, import_use_descendant.createDescendant)();
45
+ var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
46
+ name: "AutocompleteContext",
47
+ errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
48
+ });
49
+ var useAutocompleteList = () => {
50
+ const { focusedIndex, isOpen, listRef, rebirthOptions } = useAutocompleteContext();
51
+ const descendants = useAutocompleteDescendantsContext();
52
+ const beforeFocusedIndex = (0, import_react.useRef)(-1);
53
+ const selectedValue = descendants.value(focusedIndex);
54
+ const onAnimationComplete = (0, import_react.useCallback)(() => {
55
+ if (!isOpen)
56
+ rebirthOptions(false);
57
+ }, [isOpen, rebirthOptions]);
58
+ (0, import_react.useEffect)(() => {
59
+ if (!listRef.current || !selectedValue)
60
+ return;
61
+ const parent = listRef.current;
62
+ const child = selectedValue.node;
63
+ const parentHeight = parent.clientHeight;
64
+ const viewTop = parent.scrollTop;
65
+ const viewBottom = viewTop + parentHeight;
66
+ const childHeight = child.clientHeight;
67
+ const childTop = child.offsetTop;
68
+ const childBottom = childTop + childHeight;
69
+ const isInView = viewTop <= childTop && childBottom <= viewBottom;
70
+ const isScrollBottom = beforeFocusedIndex.current < selectedValue.index;
71
+ if (!isInView) {
72
+ if (childBottom <= parentHeight) {
73
+ listRef.current.scrollTo({ top: 0 });
74
+ } else {
75
+ if (!isScrollBottom) {
76
+ listRef.current.scrollTo({ top: childTop + 1 });
77
+ } else {
78
+ listRef.current.scrollTo({ top: childBottom - parentHeight });
79
+ }
80
+ }
81
+ }
82
+ beforeFocusedIndex.current = selectedValue.index;
83
+ }, [listRef, selectedValue]);
84
+ (0, import_utils.useUpdateEffect)(() => {
85
+ if (!isOpen)
86
+ beforeFocusedIndex.current = -1;
87
+ }, [isOpen]);
88
+ const getListProps = (0, import_react.useCallback)(
89
+ (props = {}, ref = null) => ({
90
+ as: "ul",
91
+ ref: (0, import_utils.mergeRefs)(listRef, ref),
92
+ role: "select",
93
+ tabIndex: -1,
94
+ ...props,
95
+ onAnimationComplete: (0, import_utils.handlerAll)(props.onAnimationComplete, onAnimationComplete)
96
+ }),
97
+ [listRef, onAnimationComplete]
98
+ );
99
+ return {
100
+ getListProps
101
+ };
102
+ };
103
+
104
+ // src/autocomplete-list.tsx
105
+ var import_jsx_runtime2 = require("react/jsx-runtime");
106
+ var AutocompleteList = (0, import_core2.forwardRef)(
107
+ ({ className, w, width, minW, minWidth, ...rest }, ref) => {
108
+ var _a, _b, _c, _d, _e, _f, _g, _h;
109
+ const { styles } = useAutocompleteContext();
110
+ const { getListProps } = useAutocompleteList();
111
+ w = (_d = w != null ? w : width) != null ? _d : (_c = (_a = styles.list) == null ? void 0 : _a.w) != null ? _c : (_b = styles.list) == null ? void 0 : _b.width;
112
+ minW = (_h = minW != null ? minW : minWidth) != null ? _h : (_g = (_e = styles.list) == null ? void 0 : _e.minW) != null ? _g : (_f = styles.list) == null ? void 0 : _f.minWidth;
113
+ const css = { ...styles.list };
114
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
115
+ import_popover.PopoverContent,
116
+ {
117
+ className: (0, import_utils2.cx)("ui-autocomplete-list", className),
118
+ w,
119
+ minW,
120
+ __css: css,
121
+ ...getListProps(rest, ref)
122
+ }
123
+ );
124
+ }
125
+ );
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ AutocompleteList
129
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ AutocompleteList
3
+ } from "./chunk-MG2KF34Q.mjs";
4
+ export {
5
+ AutocompleteList
6
+ };
@@ -0,0 +1,15 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps } from '@yamada-ui/core';
3
+ import { U as UseAutocompleteOptionGroupProps } from './use-autocomplete-f95f21d6.js';
4
+ import 'react/jsx-runtime';
5
+ import 'react';
6
+ import '@yamada-ui/form-control';
7
+ import '@yamada-ui/popover';
8
+ import '@yamada-ui/select';
9
+ import '@yamada-ui/utils';
10
+
11
+ type AutocompleteOptionGroupOptions = UseAutocompleteOptionGroupProps;
12
+ type AutocompleteOptionGroupProps = HTMLUIProps<'ul'> & AutocompleteOptionGroupOptions;
13
+ declare const AutocompleteOptionGroup: _yamada_ui_core.Component<"ul", AutocompleteOptionGroupProps>;
14
+
15
+ export { AutocompleteOptionGroup, AutocompleteOptionGroupProps };
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/autocomplete-option-group.tsx
21
+ var autocomplete_option_group_exports = {};
22
+ __export(autocomplete_option_group_exports, {
23
+ AutocompleteOptionGroup: () => AutocompleteOptionGroup
24
+ });
25
+ module.exports = __toCommonJS(autocomplete_option_group_exports);
26
+ var import_core2 = require("@yamada-ui/core");
27
+ var import_utils2 = require("@yamada-ui/utils");
28
+
29
+ // src/use-autocomplete.tsx
30
+ var import_core = require("@yamada-ui/core");
31
+ var import_form_control = require("@yamada-ui/form-control");
32
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
33
+ var import_use_descendant = require("@yamada-ui/use-descendant");
34
+ var import_use_outside_click = require("@yamada-ui/use-outside-click");
35
+ var import_utils = require("@yamada-ui/utils");
36
+ var import_react = require("react");
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var {
39
+ DescendantsContextProvider: AutocompleteDescendantsContextProvider,
40
+ useDescendantsContext: useAutocompleteDescendantsContext,
41
+ useDescendants: useAutocompleteDescendants,
42
+ useDescendant: useAutocompleteDescendant
43
+ } = (0, import_use_descendant.createDescendant)();
44
+ var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
45
+ name: "AutocompleteContext",
46
+ errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
47
+ });
48
+ var useAutocompleteOptionGroup = ({ label, ...rest }) => {
49
+ const { value, omitSelectedValues } = useAutocompleteContext();
50
+ const isMulti = (0, import_utils.isArray)(value);
51
+ const descendants = useAutocompleteDescendantsContext();
52
+ const values = descendants.values();
53
+ const selectedValues = isMulti && omitSelectedValues ? descendants.values(({ node }) => {
54
+ var _a;
55
+ return value.includes((_a = node.dataset.value) != null ? _a : "");
56
+ }) : [];
57
+ const selectedIndexes = selectedValues.map(({ index }) => index);
58
+ const childValues = values.filter(
59
+ ({ node, index }) => {
60
+ var _a;
61
+ return ((_a = node.parentElement) == null ? void 0 : _a.dataset.label) === label && !selectedIndexes.includes(index) && "target" in node.dataset;
62
+ }
63
+ );
64
+ const isEmpty = !childValues.length;
65
+ const computedRest = (0, import_utils.splitObject)(rest, import_core.layoutStylesProperties);
66
+ const getContainerProps = (0, import_react.useCallback)(
67
+ (props = {}, ref = null) => {
68
+ const style = {
69
+ border: "0px",
70
+ clip: "rect(0px, 0px, 0px, 0px)",
71
+ height: "1px",
72
+ width: "1px",
73
+ margin: "-1px",
74
+ padding: "0px",
75
+ overflow: "hidden",
76
+ whiteSpace: "nowrap",
77
+ position: "absolute"
78
+ };
79
+ return {
80
+ ref,
81
+ ...props,
82
+ ...computedRest[0],
83
+ style: isEmpty ? style : void 0,
84
+ "data-label": label,
85
+ role: "autocomplete-group-container"
86
+ };
87
+ },
88
+ [computedRest, isEmpty, label]
89
+ );
90
+ const getGroupProps = (0, import_react.useCallback)(
91
+ (props = {}, ref = null) => ({
92
+ ref,
93
+ ...props,
94
+ ...computedRest[1],
95
+ "data-label": label,
96
+ role: "autocomplete-group"
97
+ }),
98
+ [computedRest, label]
99
+ );
100
+ return {
101
+ label,
102
+ getContainerProps,
103
+ getGroupProps
104
+ };
105
+ };
106
+
107
+ // src/autocomplete-option-group.tsx
108
+ var import_jsx_runtime2 = require("react/jsx-runtime");
109
+ var AutocompleteOptionGroup = (0, import_core2.forwardRef)(
110
+ ({ className, color, h, height, minH, minHeight, children, ...rest }, ref) => {
111
+ const { styles } = useAutocompleteContext();
112
+ const { label, getContainerProps, getGroupProps } = useAutocompleteOptionGroup(rest);
113
+ h = h != null ? h : height;
114
+ minH = minH != null ? minH : minHeight;
115
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
116
+ import_core2.ui.li,
117
+ {
118
+ className: "ui-autocomplete-group-container",
119
+ __css: { w: "100%", h: "fit-content", color },
120
+ ...getContainerProps(),
121
+ children: [
122
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
123
+ import_core2.ui.span,
124
+ {
125
+ className: (0, import_utils2.cx)("ui-autocomplete-group-label"),
126
+ __css: styles.groupLabel,
127
+ noOfLines: 1,
128
+ children: label
129
+ }
130
+ ),
131
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
132
+ import_core2.ui.ul,
133
+ {
134
+ ...getGroupProps({}, ref),
135
+ className: (0, import_utils2.cx)("ui-autocomplete-group", className),
136
+ __css: { h, minH, ...styles.group },
137
+ children
138
+ }
139
+ )
140
+ ]
141
+ }
142
+ );
143
+ }
144
+ );
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ AutocompleteOptionGroup
148
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ AutocompleteOptionGroup
3
+ } from "./chunk-MG2KF34Q.mjs";
4
+ export {
5
+ AutocompleteOptionGroup
6
+ };
@@ -0,0 +1,8 @@
1
+ import '@yamada-ui/core';
2
+ import 'react';
3
+ export { a as AutocompleteOption, A as AutocompleteOptionProps } from './use-autocomplete-f95f21d6.js';
4
+ import 'react/jsx-runtime';
5
+ import '@yamada-ui/form-control';
6
+ import '@yamada-ui/popover';
7
+ import '@yamada-ui/select';
8
+ import '@yamada-ui/utils';
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/autocomplete-option.tsx
21
+ var autocomplete_option_exports = {};
22
+ __export(autocomplete_option_exports, {
23
+ AutocompleteOption: () => AutocompleteOption
24
+ });
25
+ module.exports = __toCommonJS(autocomplete_option_exports);
26
+ var import_core3 = require("@yamada-ui/core");
27
+ var import_utils3 = require("@yamada-ui/utils");
28
+
29
+ // src/autocomplete-icon.tsx
30
+ var import_core2 = require("@yamada-ui/core");
31
+ var import_icon = require("@yamada-ui/icon");
32
+ var import_use_clickable = require("@yamada-ui/use-clickable");
33
+ var import_utils2 = require("@yamada-ui/utils");
34
+ var import_react2 = require("react");
35
+
36
+ // src/use-autocomplete.tsx
37
+ var import_core = require("@yamada-ui/core");
38
+ var import_form_control = require("@yamada-ui/form-control");
39
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
40
+ var import_use_descendant = require("@yamada-ui/use-descendant");
41
+ var import_use_outside_click = require("@yamada-ui/use-outside-click");
42
+ var import_utils = require("@yamada-ui/utils");
43
+ var import_react = require("react");
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ var isTargetOption = (target) => {
46
+ var _a;
47
+ return (0, import_utils.isHTMLElement)(target) && !!((_a = target == null ? void 0 : target.getAttribute("role")) == null ? void 0 : _a.startsWith("autocomplete-item"));
48
+ };
49
+ var {
50
+ DescendantsContextProvider: AutocompleteDescendantsContextProvider,
51
+ useDescendantsContext: useAutocompleteDescendantsContext,
52
+ useDescendants: useAutocompleteDescendants,
53
+ useDescendant: useAutocompleteDescendant
54
+ } = (0, import_use_descendant.createDescendant)();
55
+ var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
56
+ name: "AutocompleteContext",
57
+ errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
58
+ });
59
+ var useAutocompleteOption = (props) => {
60
+ var _a, _b, _c, _d;
61
+ const {
62
+ value,
63
+ omitSelectedValues,
64
+ onChange,
65
+ onChangeDisplayValue,
66
+ focusedIndex,
67
+ setFocusedIndex,
68
+ onClose,
69
+ closeOnSelect: generalCloseOnSelect,
70
+ optionProps,
71
+ inputRef,
72
+ onFocusNext
73
+ } = useAutocompleteContext();
74
+ let {
75
+ icon: customIcon,
76
+ isDisabled,
77
+ isFocusable,
78
+ closeOnSelect: customCloseOnSelect,
79
+ children,
80
+ ...computedProps
81
+ } = { ...optionProps, ...props };
82
+ const trulyDisabled = !!isDisabled && !isFocusable;
83
+ const itemRef = (0, import_react.useRef)(null);
84
+ const { index, register, descendants } = useAutocompleteDescendant({ disabled: trulyDisabled });
85
+ const values = descendants.values();
86
+ const frontValues = values.slice(0, index);
87
+ const isMulti = (0, import_utils.isArray)(value);
88
+ const isDuplicated = !isMulti ? frontValues.some(({ node }) => {
89
+ var _a2;
90
+ return node.dataset.value === ((_a2 = computedProps.value) != null ? _a2 : "");
91
+ }) : false;
92
+ const isSelected = !isDuplicated && (!isMulti ? ((_a = computedProps.value) != null ? _a : "") === value : value.includes((_b = computedProps.value) != null ? _b : ""));
93
+ const isTarget = "target" in ((_d = (_c = itemRef.current) == null ? void 0 : _c.dataset) != null ? _d : {});
94
+ const isFocused = index === focusedIndex;
95
+ const onClick = (0, import_react.useCallback)(
96
+ (ev) => {
97
+ var _a2;
98
+ ev.stopPropagation();
99
+ if (isDisabled) {
100
+ if (inputRef.current)
101
+ inputRef.current.focus();
102
+ return;
103
+ }
104
+ if (!isTargetOption(ev.currentTarget)) {
105
+ if (inputRef.current)
106
+ inputRef.current.focus();
107
+ return;
108
+ }
109
+ setFocusedIndex(index);
110
+ onChange((_a2 = computedProps.value) != null ? _a2 : "");
111
+ if (inputRef.current)
112
+ inputRef.current.focus();
113
+ if (customCloseOnSelect != null ? customCloseOnSelect : generalCloseOnSelect)
114
+ onClose();
115
+ if (omitSelectedValues)
116
+ onFocusNext(index);
117
+ },
118
+ [
119
+ onFocusNext,
120
+ omitSelectedValues,
121
+ isDisabled,
122
+ computedProps,
123
+ setFocusedIndex,
124
+ index,
125
+ onChange,
126
+ customCloseOnSelect,
127
+ generalCloseOnSelect,
128
+ onClose,
129
+ inputRef
130
+ ]
131
+ );
132
+ (0, import_react.useEffect)(() => {
133
+ var _a2;
134
+ if (isSelected)
135
+ onChangeDisplayValue((_a2 = computedProps.value) != null ? _a2 : "", false);
136
+ }, [computedProps, isSelected, onChangeDisplayValue]);
137
+ const getOptionProps = (0, import_react.useCallback)(
138
+ (props2 = {}, ref = null) => {
139
+ var _a2;
140
+ const style = {
141
+ border: "0px",
142
+ clip: "rect(0px, 0px, 0px, 0px)",
143
+ height: "1px",
144
+ width: "1px",
145
+ margin: "-1px",
146
+ padding: "0px",
147
+ overflow: "hidden",
148
+ whiteSpace: "nowrap",
149
+ position: "absolute"
150
+ };
151
+ return {
152
+ ref: (0, import_utils.mergeRefs)(itemRef, ref, register),
153
+ ...(0, import_utils.omitObject)(computedProps, ["value"]),
154
+ ...props2,
155
+ role: "autocomplete-item",
156
+ tabIndex: -1,
157
+ style: !isTarget || omitSelectedValues && isSelected ? style : void 0,
158
+ "data-target": (0, import_utils.dataAttr)(true),
159
+ "data-value": (_a2 = computedProps.value) != null ? _a2 : "",
160
+ "data-focus": (0, import_utils.dataAttr)(isFocused),
161
+ "data-disabled": (0, import_utils.dataAttr)(isDisabled),
162
+ "aria-checked": (0, import_utils.ariaAttr)(isSelected),
163
+ "aria-disabled": (0, import_utils.ariaAttr)(isDisabled),
164
+ onClick: (0, import_utils.handlerAll)(computedProps.onClick, props2.onClick, onClick)
165
+ };
166
+ },
167
+ [
168
+ computedProps,
169
+ isDisabled,
170
+ isFocused,
171
+ isSelected,
172
+ isTarget,
173
+ omitSelectedValues,
174
+ onClick,
175
+ register
176
+ ]
177
+ );
178
+ return {
179
+ isSelected,
180
+ isFocused,
181
+ customIcon,
182
+ children,
183
+ getOptionProps
184
+ };
185
+ };
186
+
187
+ // src/autocomplete-icon.tsx
188
+ var import_jsx_runtime2 = require("react/jsx-runtime");
189
+ var AutocompleteIcon = (0, import_core2.forwardRef)(
190
+ ({ className, children, __css, ...rest }, ref) => {
191
+ const { styles } = useAutocompleteContext();
192
+ const css = {
193
+ position: "absolute",
194
+ top: "50%",
195
+ transform: "translateY(-50%)",
196
+ display: "inline-flex",
197
+ alignItems: "center",
198
+ justifyContent: "center",
199
+ pointerEvents: "none",
200
+ cursor: "pointer",
201
+ ...styles.icon,
202
+ ...__css
203
+ };
204
+ const validChildren = (0, import_utils2.getValidChildren)(children);
205
+ const cloneChildren = validChildren.map(
206
+ (child) => (0, import_react2.cloneElement)(child, {
207
+ focusable: false,
208
+ "aria-hidden": true,
209
+ style: {
210
+ maxWidth: "1em",
211
+ maxHeight: "1em",
212
+ color: "currentColor"
213
+ }
214
+ })
215
+ );
216
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.div, { ref, className: (0, import_utils2.cx)("ui-autocomplete-icon", className), __css: css, ...rest, children: (0, import_utils2.isValidElement)(children) ? cloneChildren : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icon.ChevronIcon, {}) });
217
+ }
218
+ );
219
+ var AutocompleteItemIcon = (0, import_core2.forwardRef)(
220
+ ({ className, ...rest }, ref) => {
221
+ const { styles } = useAutocompleteContext();
222
+ const css = {
223
+ flexShrink: 0,
224
+ display: "inline-flex",
225
+ justifyContent: "center",
226
+ alignItems: "center",
227
+ fontSize: "0.85em",
228
+ ...styles.itemIcon
229
+ };
230
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
231
+ import_core2.ui.span,
232
+ {
233
+ ref,
234
+ className: (0, import_utils2.cx)("ui-autocomplete-item-icon", className),
235
+ __css: css,
236
+ ...rest
237
+ }
238
+ );
239
+ }
240
+ );
241
+
242
+ // src/autocomplete-option.tsx
243
+ var import_jsx_runtime3 = require("react/jsx-runtime");
244
+ var AutocompleteOption = (0, import_core3.forwardRef)(
245
+ ({ className, icon, ...rest }, ref) => {
246
+ const { styles } = useAutocompleteContext();
247
+ const { isSelected, customIcon, children, getOptionProps } = useAutocompleteOption(rest);
248
+ icon = icon != null ? icon : customIcon;
249
+ const css = {
250
+ textDecoration: "none",
251
+ color: "inherit",
252
+ userSelect: "none",
253
+ display: "flex",
254
+ width: "100%",
255
+ alignItems: "center",
256
+ textAlign: "start",
257
+ flex: "0 0 auto",
258
+ outline: 0,
259
+ gap: "0.75rem",
260
+ ...styles.item
261
+ };
262
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
263
+ import_core3.ui.li,
264
+ {
265
+ className: (0, import_utils3.cx)("ui-autocomplete-item", className),
266
+ __css: css,
267
+ ...getOptionProps({}, ref),
268
+ children: [
269
+ icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteItemIcon, { opacity: isSelected ? 1 : 0, children: icon || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, {}) }) : null,
270
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { pointerEvents: "none", flex: 1 }, noOfLines: 1, children }) : children
271
+ ]
272
+ }
273
+ );
274
+ }
275
+ );
276
+ var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
277
+ "polygon",
278
+ {
279
+ fill: "currentColor",
280
+ points: "5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"
281
+ }
282
+ ) });
283
+ // Annotate the CommonJS export names for ESM import in node:
284
+ 0 && (module.exports = {
285
+ AutocompleteOption
286
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ AutocompleteOption
3
+ } from "./chunk-MG2KF34Q.mjs";
4
+ export {
5
+ AutocompleteOption
6
+ };
@@ -0,0 +1,24 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
+ import { AutocompleteIconProps } from './autocomplete-icon.js';
4
+ import { AutocompleteListProps } from './autocomplete-list.js';
5
+ import { b as UseAutocompleteProps } from './use-autocomplete-f95f21d6.js';
6
+ import 'react';
7
+ import 'react/jsx-runtime';
8
+ import '@yamada-ui/form-control';
9
+ import '@yamada-ui/popover';
10
+ import '@yamada-ui/select';
11
+ import '@yamada-ui/utils';
12
+
13
+ type AutocompleteOptions = {
14
+ focusBorderColor?: string;
15
+ errorBorderColor?: string;
16
+ containerProps?: Omit<HTMLUIProps<'div'>, 'children'>;
17
+ listProps?: Omit<AutocompleteListProps, 'children'>;
18
+ inputProps?: HTMLUIProps<'input'>;
19
+ iconProps?: AutocompleteIconProps;
20
+ };
21
+ type AutocompleteProps = ThemeProps<'Select'> & Omit<UseAutocompleteProps<string>, 'maxSelectedValues' | 'omitSelectedValues'> & AutocompleteOptions;
22
+ declare const Autocomplete: _yamada_ui_core.Component<"input", AutocompleteProps>;
23
+
24
+ export { Autocomplete, AutocompleteProps };