@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.
package/dist/index.js ADDED
@@ -0,0 +1,1661 @@
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/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Autocomplete: () => Autocomplete,
24
+ AutocompleteCreate: () => AutocompleteCreate,
25
+ AutocompleteEmpty: () => AutocompleteEmpty,
26
+ AutocompleteOption: () => AutocompleteOption,
27
+ AutocompleteOptionGroup: () => AutocompleteOptionGroup,
28
+ MultiAutocomplete: () => MultiAutocomplete
29
+ });
30
+ module.exports = __toCommonJS(src_exports);
31
+
32
+ // src/autocomplete.tsx
33
+ var import_core4 = require("@yamada-ui/core");
34
+ var import_popover2 = require("@yamada-ui/popover");
35
+ var import_utils4 = require("@yamada-ui/utils");
36
+
37
+ // src/autocomplete-icon.tsx
38
+ var import_core2 = require("@yamada-ui/core");
39
+ var import_icon = require("@yamada-ui/icon");
40
+ var import_use_clickable = require("@yamada-ui/use-clickable");
41
+ var import_utils2 = require("@yamada-ui/utils");
42
+ var import_react2 = require("react");
43
+
44
+ // src/use-autocomplete.tsx
45
+ var import_core = require("@yamada-ui/core");
46
+ var import_form_control = require("@yamada-ui/form-control");
47
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
48
+ var import_use_descendant = require("@yamada-ui/use-descendant");
49
+ var import_use_outside_click = require("@yamada-ui/use-outside-click");
50
+ var import_utils = require("@yamada-ui/utils");
51
+ var import_react = require("react");
52
+ var import_jsx_runtime = require("react/jsx-runtime");
53
+ var kanaMap = {
54
+ \uFF76\uFF9E: "\u30AC",
55
+ \uFF77\uFF9E: "\u30AE",
56
+ \uFF78\uFF9E: "\u30B0",
57
+ \uFF79\uFF9E: "\u30B2",
58
+ \uFF7A\uFF9E: "\u30B4",
59
+ \uFF7B\uFF9E: "\u30B6",
60
+ \uFF7C\uFF9E: "\u30B8",
61
+ \uFF7D\uFF9E: "\u30BA",
62
+ \uFF7E\uFF9E: "\u30BC",
63
+ \uFF7F\uFF9E: "\u30BE",
64
+ \uFF80\uFF9E: "\u30C0",
65
+ \uFF81\uFF9E: "\u30C2",
66
+ \uFF82\uFF9E: "\u30C5",
67
+ \uFF83\uFF9E: "\u30C7",
68
+ \uFF84\uFF9E: "\u30C9",
69
+ \uFF8A\uFF9E: "\u30D0",
70
+ \uFF8B\uFF9E: "\u30D3",
71
+ \uFF8C\uFF9E: "\u30D6",
72
+ \uFF8D\uFF9E: "\u30D9",
73
+ \uFF8E\uFF9E: "\u30DC",
74
+ \uFF8A\uFF9F: "\u30D1",
75
+ \uFF8B\uFF9F: "\u30D4",
76
+ \uFF8C\uFF9F: "\u30D7",
77
+ \uFF8D\uFF9F: "\u30DA",
78
+ \uFF8E\uFF9F: "\u30DD",
79
+ \uFF73\uFF9E: "\u30F4",
80
+ \uFF9C\uFF9E: "\u30F7",
81
+ \uFF66\uFF9E: "\u30FA",
82
+ \uFF71: "\u30A2",
83
+ \uFF72: "\u30A4",
84
+ \uFF73: "\u30A6",
85
+ \uFF74: "\u30A8",
86
+ \uFF75: "\u30AA",
87
+ \uFF76: "\u30AB",
88
+ \uFF77: "\u30AD",
89
+ \uFF78: "\u30AF",
90
+ \uFF79: "\u30B1",
91
+ \uFF7A: "\u30B3",
92
+ \uFF7B: "\u30B5",
93
+ \uFF7C: "\u30B7",
94
+ \uFF7D: "\u30B9",
95
+ \uFF7E: "\u30BB",
96
+ \uFF7F: "\u30BD",
97
+ \uFF80: "\u30BF",
98
+ \uFF81: "\u30C1",
99
+ \uFF82: "\u30C4",
100
+ \uFF83: "\u30C6",
101
+ \uFF84: "\u30C8",
102
+ \uFF85: "\u30CA",
103
+ \uFF86: "\u30CB",
104
+ \uFF87: "\u30CC",
105
+ \uFF88: "\u30CD",
106
+ \uFF89: "\u30CE",
107
+ \uFF8A: "\u30CF",
108
+ \uFF8B: "\u30D2",
109
+ \uFF8C: "\u30D5",
110
+ \uFF8D: "\u30D8",
111
+ \uFF8E: "\u30DB",
112
+ \uFF8F: "\u30DE",
113
+ \uFF90: "\u30DF",
114
+ \uFF91: "\u30E0",
115
+ \uFF92: "\u30E1",
116
+ \uFF93: "\u30E2",
117
+ \uFF94: "\u30E4",
118
+ \uFF95: "\u30E6",
119
+ \uFF96: "\u30E8",
120
+ \uFF97: "\u30E9",
121
+ \uFF98: "\u30EA",
122
+ \uFF99: "\u30EB",
123
+ \uFF9A: "\u30EC",
124
+ \uFF9B: "\u30ED",
125
+ \uFF9C: "\u30EF",
126
+ \uFF66: "\u30F2",
127
+ \uFF9D: "\u30F3",
128
+ \uFF67: "\u30A1",
129
+ \uFF68: "\u30A3",
130
+ \uFF69: "\u30A5",
131
+ \uFF6A: "\u30A7",
132
+ \uFF6B: "\u30A9",
133
+ \uFF6F: "\u30C3",
134
+ \uFF6C: "\u30E3",
135
+ \uFF6D: "\u30E5",
136
+ \uFF6E: "\u30E7",
137
+ "\uFF61": "\u3002",
138
+ "\uFF64": "\u3001",
139
+ \uFF70: "\u30FC",
140
+ "\uFF62": "\u300C",
141
+ "\uFF63": "\u300D",
142
+ "\uFF65": "\u30FB"
143
+ };
144
+ var defaultFormat = (value) => {
145
+ value = value.replace(/[!-~]/g, (v) => String.fromCharCode(v.charCodeAt(0) - 65248));
146
+ const reg = new RegExp("(" + Object.keys(kanaMap).join("|") + ")", "g");
147
+ value = value.replace(reg, (v) => kanaMap[v]).replace(/゙/g, "\u309B").replace(/゚/g, "\u309C");
148
+ value = value.toUpperCase();
149
+ return value;
150
+ };
151
+ var flattenData = (data) => {
152
+ const filterData = (data2) => data2.map((data3) => {
153
+ const { value, isDisabled, isFocusable } = data3;
154
+ const trulyDisabled = !!isDisabled && !isFocusable;
155
+ const isMulti = (0, import_utils.isArray)(value);
156
+ if (trulyDisabled)
157
+ return;
158
+ if (!isMulti) {
159
+ return data3;
160
+ } else {
161
+ return filterData(value);
162
+ }
163
+ }).filter(Boolean);
164
+ return filterData(data).flat(Infinity);
165
+ };
166
+ var isTargetOption = (target) => {
167
+ var _a;
168
+ return (0, import_utils.isHTMLElement)(target) && !!((_a = target == null ? void 0 : target.getAttribute("role")) == null ? void 0 : _a.startsWith("autocomplete-item"));
169
+ };
170
+ var {
171
+ DescendantsContextProvider: AutocompleteDescendantsContextProvider,
172
+ useDescendantsContext: useAutocompleteDescendantsContext,
173
+ useDescendants: useAutocompleteDescendants,
174
+ useDescendant: useAutocompleteDescendant
175
+ } = (0, import_use_descendant.createDescendant)();
176
+ var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
177
+ name: "AutocompleteContext",
178
+ errorMessage: `useAutocompleteContext returned is 'undefined'. Seems you forgot to wrap the components in "<Autocomplete />" or "<MultiAutocomplete />"`
179
+ });
180
+ var useAutocomplete = ({
181
+ defaultIsOpen,
182
+ closeOnSelect = true,
183
+ omitSelectedValues = false,
184
+ maxSelectedValues,
185
+ closeOnBlur = true,
186
+ closeOnEsc = true,
187
+ createOption = false,
188
+ createOrder = "first",
189
+ createSecondOrder = "first",
190
+ emptyMessage = "No results found",
191
+ format = defaultFormat,
192
+ placement = "bottom-start",
193
+ duration = 0.2,
194
+ optionProps,
195
+ placeholder,
196
+ children,
197
+ ...rest
198
+ }) => {
199
+ rest = (0, import_form_control.useFormControlProps)(rest);
200
+ const { id } = rest;
201
+ const formControlProps = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
202
+ const [containerProps, inputProps] = (0, import_utils.splitObject)(
203
+ (0, import_utils.omitObject)(rest, ["id", "value", "onChange", "month", "onChangeMonth"]),
204
+ import_core.layoutStylesProperties
205
+ );
206
+ const descendants = useAutocompleteDescendants();
207
+ const containerRef = (0, import_react.useRef)(null);
208
+ const listRef = (0, import_react.useRef)(null);
209
+ const inputRef = (0, import_react.useRef)(null);
210
+ const timeoutIds = (0, import_react.useRef)(/* @__PURE__ */ new Set([]));
211
+ const isComposition = (0, import_react.useRef)(false);
212
+ const [data, setData] = (0, import_react.useState)(rest.data);
213
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
214
+ value: rest.value,
215
+ defaultValue: rest.defaultValue,
216
+ onChange: rest.onChange
217
+ });
218
+ const [displayValue, setDisplayValue] = (0, import_react.useState)(void 0);
219
+ const [inputValue, setInputValue] = (0, import_react.useState)("");
220
+ const [focusedIndex, setFocusedIndex] = (0, import_react.useState)(-1);
221
+ const [isAllSelected, setIsAllSelected] = (0, import_react.useState)(false);
222
+ const [isHit, setIsHit] = (0, import_react.useState)(true);
223
+ const [isOpen, setIsOpen] = (0, import_react.useState)(defaultIsOpen != null ? defaultIsOpen : false);
224
+ const isFocused = focusedIndex > -1;
225
+ const isCreate = focusedIndex === -2 && createOption;
226
+ const isMulti = (0, import_utils.isArray)(value);
227
+ const isEmptyValue = !isMulti ? !value : !value.length;
228
+ if (createOption && !(0, import_utils.isUndefined)(children)) {
229
+ console.warn(
230
+ `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: ${!isMulti ? "Autocomplete" : "MultiAutocomplete"} internally prefers 'children'. If 'createOption' is true, it will not be reflected correctly. If want to reflect, please set 'data' in props.`
231
+ );
232
+ }
233
+ const selectedValues = descendants.enabledValues(
234
+ ({ node }) => {
235
+ var _a;
236
+ return isMulti && value.includes((_a = node.dataset.value) != null ? _a : "");
237
+ }
238
+ );
239
+ const selectedIndexes = selectedValues.map(({ index }) => index);
240
+ const enabledValues = descendants.enabledValues(
241
+ ({ node, index }) => "target" in node.dataset && !selectedIndexes.includes(index)
242
+ );
243
+ const validChildren = (0, import_utils.getValidChildren)(children);
244
+ const computedChildren = data == null ? void 0 : data.map(({ label, value: value2, ...props }, i) => {
245
+ if (!(0, import_utils.isArray)(value2)) {
246
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AutocompleteOption, { value: value2, ...props, children: label }, i);
247
+ } else {
248
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AutocompleteOptionGroup, { label, ...props, children: value2.map(
249
+ ({ label: label2, value: value3, ...props2 }, i2) => !(0, import_utils.isArray)(value3) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AutocompleteOption, { value: value3, ...props2, children: label2 }, i2) : null
250
+ ) }, i);
251
+ }
252
+ });
253
+ const isEmpty = !validChildren.length && !(computedChildren == null ? void 0 : computedChildren.length);
254
+ const onOpen = (0, import_react.useCallback)(() => {
255
+ var _a;
256
+ if (formControlProps.disabled || formControlProps.readOnly)
257
+ return;
258
+ if (!createOption && (isEmpty || isAllSelected))
259
+ return;
260
+ setIsOpen(true);
261
+ if (inputRef.current)
262
+ inputRef.current.focus();
263
+ (_a = rest.onOpen) == null ? void 0 : _a.call(rest);
264
+ }, [createOption, formControlProps, isAllSelected, isEmpty, rest]);
265
+ const onClose = (0, import_react.useCallback)(() => {
266
+ var _a;
267
+ setIsOpen(false);
268
+ (_a = rest.onClose) == null ? void 0 : _a.call(rest);
269
+ }, [rest]);
270
+ const onFocusFirst = (0, import_react.useCallback)(() => {
271
+ const id2 = setTimeout(() => {
272
+ if (isEmpty || isAllSelected)
273
+ return;
274
+ const first = descendants.enabledfirstValue(({ node }) => "target" in node.dataset);
275
+ if (!first)
276
+ return;
277
+ if (!isMulti || !omitSelectedValues) {
278
+ setFocusedIndex(first.index);
279
+ } else {
280
+ if (selectedIndexes.includes(first.index)) {
281
+ const enabledFirst = enabledValues[0];
282
+ setFocusedIndex(enabledFirst.index);
283
+ } else {
284
+ setFocusedIndex(first.index);
285
+ }
286
+ }
287
+ });
288
+ timeoutIds.current.add(id2);
289
+ }, [
290
+ descendants,
291
+ enabledValues,
292
+ isAllSelected,
293
+ isEmpty,
294
+ isMulti,
295
+ omitSelectedValues,
296
+ selectedIndexes
297
+ ]);
298
+ const onFocusLast = (0, import_react.useCallback)(() => {
299
+ const id2 = setTimeout(() => {
300
+ if (isEmpty || isAllSelected)
301
+ return;
302
+ const last = descendants.enabledlastValue(({ node }) => "target" in node.dataset);
303
+ if (!last)
304
+ return;
305
+ if (!isMulti || !omitSelectedValues) {
306
+ setFocusedIndex(last.index);
307
+ } else {
308
+ if (selectedIndexes.includes(last.index)) {
309
+ const enabledlast = enabledValues.reverse()[0];
310
+ setFocusedIndex(enabledlast.index);
311
+ } else {
312
+ setFocusedIndex(last.index);
313
+ }
314
+ }
315
+ });
316
+ timeoutIds.current.add(id2);
317
+ }, [
318
+ descendants,
319
+ enabledValues,
320
+ isAllSelected,
321
+ isEmpty,
322
+ isMulti,
323
+ omitSelectedValues,
324
+ selectedIndexes
325
+ ]);
326
+ const onFocusSelected = (0, import_react.useCallback)(() => {
327
+ const id2 = setTimeout(() => {
328
+ const values = descendants.enabledValues();
329
+ const selected = values.find(
330
+ ({ node }) => {
331
+ var _a;
332
+ return !isMulti ? node.dataset.value === value : value.includes((_a = node.dataset.value) != null ? _a : "");
333
+ }
334
+ );
335
+ if (selected)
336
+ setFocusedIndex(selected.index);
337
+ });
338
+ timeoutIds.current.add(id2);
339
+ }, [descendants, isMulti, value]);
340
+ const onFocusNext = (0, import_react.useCallback)(
341
+ (index = focusedIndex) => {
342
+ const id2 = setTimeout(() => {
343
+ var _a;
344
+ const next = descendants.enabledNextValue(index, ({ node }) => "target" in node.dataset);
345
+ if (!next)
346
+ return;
347
+ if (!isMulti || !omitSelectedValues) {
348
+ setFocusedIndex(next.index);
349
+ } else {
350
+ if (selectedIndexes.includes(next.index)) {
351
+ const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
352
+ setFocusedIndex(enabledNext.index);
353
+ } else {
354
+ setFocusedIndex(next.index);
355
+ }
356
+ }
357
+ });
358
+ timeoutIds.current.add(id2);
359
+ },
360
+ [descendants, enabledValues, focusedIndex, isMulti, omitSelectedValues, selectedIndexes]
361
+ );
362
+ const onFocusPrev = (0, import_react.useCallback)(
363
+ (index = focusedIndex) => {
364
+ const id2 = setTimeout(() => {
365
+ var _a;
366
+ const prev = descendants.enabledPrevValue(index, ({ node }) => "target" in node.dataset);
367
+ if (!prev)
368
+ return;
369
+ if (!isMulti || !omitSelectedValues) {
370
+ setFocusedIndex(prev.index);
371
+ } else {
372
+ if (selectedIndexes.includes(prev.index)) {
373
+ const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
374
+ setFocusedIndex(enabledPrev.index);
375
+ } else {
376
+ setFocusedIndex(prev.index);
377
+ }
378
+ }
379
+ });
380
+ timeoutIds.current.add(id2);
381
+ },
382
+ [descendants, enabledValues, focusedIndex, isMulti, omitSelectedValues, selectedIndexes]
383
+ );
384
+ const onFocusFirstOrSelected = isEmptyValue || omitSelectedValues ? onFocusFirst : onFocusSelected;
385
+ const onFocusLastOrSelected = isEmptyValue || omitSelectedValues ? onFocusLast : onFocusSelected;
386
+ const pickOptions = (0, import_react.useCallback)(
387
+ (value2) => {
388
+ const values = descendants.values();
389
+ let isHit2 = false;
390
+ let isFocused2 = false;
391
+ values.forEach(({ node, index }) => {
392
+ var _a;
393
+ if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
394
+ isHit2 = true;
395
+ const isDisabled = "disabled" in node.dataset;
396
+ node.dataset.target = "";
397
+ if (!isFocused2 && !isDisabled) {
398
+ isFocused2 = true;
399
+ setFocusedIndex(index);
400
+ }
401
+ } else {
402
+ delete node.dataset.target;
403
+ }
404
+ });
405
+ setIsHit(isHit2);
406
+ },
407
+ [descendants, format]
408
+ );
409
+ const rebirthOptions = (0, import_react.useCallback)(
410
+ (runFocus = true) => {
411
+ const values = descendants.values();
412
+ values.forEach(({ node }) => {
413
+ node.dataset.target = "";
414
+ });
415
+ if (runFocus)
416
+ onFocusFirst();
417
+ setIsHit(true);
418
+ },
419
+ [descendants, onFocusFirst]
420
+ );
421
+ const onChangeDisplayValue = (0, import_react.useCallback)(
422
+ (newValue, runOmit = true) => {
423
+ const enabledValues2 = descendants.enabledValues();
424
+ const selectedValues2 = enabledValues2.filter(({ node }) => node.dataset.value === newValue).map(({ node }) => {
425
+ var _a;
426
+ return (_a = node.textContent) != null ? _a : "";
427
+ });
428
+ setDisplayValue((prev) => {
429
+ if (!isMulti) {
430
+ return selectedValues2[0];
431
+ } else {
432
+ selectedValues2.forEach((selectedValue) => {
433
+ const isSelected = (0, import_utils.isArray)(prev) && prev.includes(selectedValue != null ? selectedValue : "");
434
+ if (!isSelected) {
435
+ prev = [...(0, import_utils.isArray)(prev) ? prev : [], selectedValue];
436
+ } else if (runOmit) {
437
+ prev = (0, import_utils.isArray)(prev) ? prev.filter((value2) => value2 !== selectedValue) : void 0;
438
+ }
439
+ });
440
+ return prev;
441
+ }
442
+ });
443
+ },
444
+ [descendants, isMulti]
445
+ );
446
+ const onChange = (0, import_react.useCallback)(
447
+ (newValue) => {
448
+ setValue((prev) => {
449
+ if (!(0, import_utils.isArray)(prev)) {
450
+ return newValue;
451
+ } else {
452
+ const isSelected = prev.includes(newValue);
453
+ if (!isSelected) {
454
+ return [...prev, newValue];
455
+ } else {
456
+ return prev.filter((value2) => value2 !== newValue);
457
+ }
458
+ }
459
+ });
460
+ onChangeDisplayValue(newValue);
461
+ setInputValue("");
462
+ rebirthOptions(false);
463
+ },
464
+ [onChangeDisplayValue, rebirthOptions, setValue]
465
+ );
466
+ const onSelect = (0, import_react.useCallback)(() => {
467
+ var _a, _b;
468
+ let enabledValue = descendants.value(focusedIndex);
469
+ if ("disabled" in ((_a = enabledValue == null ? void 0 : enabledValue.node.dataset) != null ? _a : {}))
470
+ enabledValue = void 0;
471
+ if (!enabledValue)
472
+ return;
473
+ const value2 = (_b = enabledValue.node.dataset.value) != null ? _b : "";
474
+ onChange(value2);
475
+ if (closeOnSelect)
476
+ onClose();
477
+ if (omitSelectedValues)
478
+ onFocusNext();
479
+ }, [closeOnSelect, descendants, focusedIndex, omitSelectedValues, onChange, onClose, onFocusNext]);
480
+ const onSearch = (0, import_react.useCallback)(
481
+ (ev) => {
482
+ var _a;
483
+ if (!isOpen)
484
+ onOpen();
485
+ (_a = rest.onSearch) == null ? void 0 : _a.call(rest, ev);
486
+ const value2 = ev.target.value;
487
+ const computedValue = format(value2);
488
+ if (computedValue) {
489
+ pickOptions(computedValue);
490
+ } else {
491
+ rebirthOptions();
492
+ }
493
+ setInputValue(value2);
494
+ },
495
+ [isOpen, onOpen, format, rest, pickOptions, rebirthOptions]
496
+ );
497
+ const onCompositionStart = (0, import_react.useCallback)(() => {
498
+ isComposition.current = true;
499
+ }, []);
500
+ const onCompositionEnd = (0, import_react.useCallback)(() => {
501
+ isComposition.current = false;
502
+ }, []);
503
+ const onCreate = (0, import_react.useCallback)(() => {
504
+ var _a;
505
+ if (!listRef.current)
506
+ return;
507
+ const newOption = { label: inputValue, value: inputValue };
508
+ let newData = [];
509
+ if (data)
510
+ newData = data;
511
+ if (createOrder === "first") {
512
+ newData = [newOption, ...newData];
513
+ } else if (createOrder === "last") {
514
+ newData = [...newData, newOption];
515
+ } else {
516
+ const i = newData.findIndex(({ label }) => label === createOrder);
517
+ if (i !== -1 && (0, import_utils.isArray)(newData[i].value)) {
518
+ if (createSecondOrder === "first") {
519
+ newData[i].value = [newOption, ...newData[i].value];
520
+ } else {
521
+ newData[i].value = [...newData[i].value, newOption];
522
+ }
523
+ } else {
524
+ console.warn(
525
+ `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: '${createOrder}' specified in createOrder does not exist in the option group.`
526
+ );
527
+ }
528
+ }
529
+ setData(newData);
530
+ onChange(inputValue);
531
+ rebirthOptions(false);
532
+ const index = flattenData(newData).findIndex(({ value: value2 }) => value2 === inputValue);
533
+ setFocusedIndex(index);
534
+ (_a = rest.onCreate) == null ? void 0 : _a.call(rest, newOption, newData);
535
+ }, [inputValue, data, createOrder, onChange, rebirthOptions, rest, createSecondOrder, isMulti]);
536
+ const onDelete = (0, import_react.useCallback)(() => {
537
+ if (!isMulti) {
538
+ onChange("");
539
+ } else {
540
+ onChange(value[value.length - 1]);
541
+ }
542
+ }, [isMulti, onChange, value]);
543
+ const onClear = (0, import_react.useCallback)(
544
+ (ev) => {
545
+ ev.stopPropagation();
546
+ setValue([]);
547
+ setDisplayValue(void 0);
548
+ setInputValue("");
549
+ rebirthOptions();
550
+ if (inputRef.current)
551
+ inputRef.current.focus();
552
+ },
553
+ [setDisplayValue, setInputValue, setValue, rebirthOptions, inputRef]
554
+ );
555
+ const onClick = (0, import_react.useCallback)(() => {
556
+ if (isOpen) {
557
+ if (inputRef.current)
558
+ inputRef.current.focus();
559
+ } else {
560
+ onOpen();
561
+ onFocusFirstOrSelected();
562
+ }
563
+ }, [isOpen, onFocusFirstOrSelected, onOpen]);
564
+ const onFocus = (0, import_react.useCallback)(() => {
565
+ if (isOpen)
566
+ return;
567
+ onOpen();
568
+ onFocusFirstOrSelected();
569
+ }, [isOpen, onFocusFirstOrSelected, onOpen]);
570
+ const onBlur = (0, import_react.useCallback)(
571
+ (ev) => {
572
+ const relatedTarget = (0, import_utils.getEventRelatedTarget)(ev);
573
+ if ((0, import_utils.isContains)(containerRef.current, relatedTarget))
574
+ return;
575
+ if (!closeOnBlur && isHit)
576
+ return;
577
+ setInputValue("");
578
+ if (isOpen)
579
+ onClose();
580
+ },
581
+ [closeOnBlur, isHit, isOpen, onClose]
582
+ );
583
+ const onKeyDown = (0, import_react.useCallback)(
584
+ (ev) => {
585
+ if (ev.key === " ")
586
+ ev.key = ev.code;
587
+ if (formControlProps.disabled || formControlProps.readOnly)
588
+ return;
589
+ if (isComposition.current)
590
+ return;
591
+ const enabledDelete = displayValue === inputValue || !inputValue.length;
592
+ const actions = {
593
+ ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
594
+ ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusLastOrSelected) : void 0,
595
+ Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
596
+ Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
597
+ Home: isOpen ? onFocusFirst : void 0,
598
+ End: isOpen ? onFocusLast : void 0,
599
+ Escape: closeOnEsc ? onClose : void 0,
600
+ Backspace: !isEmptyValue && enabledDelete ? onDelete : void 0
601
+ };
602
+ const action = actions[ev.key];
603
+ if (!action)
604
+ return;
605
+ ev.preventDefault();
606
+ ev.stopPropagation();
607
+ action(ev);
608
+ },
609
+ [
610
+ formControlProps,
611
+ displayValue,
612
+ inputValue,
613
+ onOpen,
614
+ isFocused,
615
+ onFocusFirstOrSelected,
616
+ onFocusNext,
617
+ onFocusLastOrSelected,
618
+ onFocusPrev,
619
+ isCreate,
620
+ onCreate,
621
+ onSelect,
622
+ isOpen,
623
+ onFocusFirst,
624
+ onFocusLast,
625
+ closeOnEsc,
626
+ onClose,
627
+ isEmptyValue,
628
+ onDelete
629
+ ]
630
+ );
631
+ (0, import_react.useEffect)(() => {
632
+ if (!isMulti)
633
+ return;
634
+ if (!omitSelectedValues && (0, import_utils.isUndefined)(maxSelectedValues))
635
+ return;
636
+ const isAll = value.length > 0 && value.length === descendants.count();
637
+ const isMax = value.length === maxSelectedValues;
638
+ if (isAll || isMax) {
639
+ onClose();
640
+ setIsAllSelected(true);
641
+ } else {
642
+ setIsAllSelected(false);
643
+ }
644
+ }, [omitSelectedValues, value, descendants, isMulti, onClose, maxSelectedValues]);
645
+ (0, import_utils.useUpdateEffect)(() => {
646
+ if (isOpen)
647
+ return;
648
+ setFocusedIndex(-1);
649
+ setInputValue("");
650
+ }, [isOpen]);
651
+ (0, import_utils.useUpdateEffect)(() => {
652
+ if (!isHit)
653
+ setFocusedIndex(-2);
654
+ }, [isHit]);
655
+ (0, import_utils.useUnmountEffect)(() => {
656
+ timeoutIds.current.forEach((id2) => clearTimeout(id2));
657
+ timeoutIds.current.clear();
658
+ });
659
+ (0, import_use_outside_click.useOutsideClick)({
660
+ ref: containerRef,
661
+ handler: onClose,
662
+ enabled: closeOnBlur || !isHit
663
+ });
664
+ const getPopoverProps = (0, import_react.useCallback)(
665
+ (props) => ({
666
+ ...rest,
667
+ ...props,
668
+ isOpen,
669
+ onOpen,
670
+ onClose,
671
+ placement,
672
+ duration,
673
+ trigger: "never",
674
+ closeOnButton: false
675
+ }),
676
+ [duration, isOpen, onClose, onOpen, placement, rest]
677
+ );
678
+ const getContainerProps = (0, import_react.useCallback)(
679
+ (props = {}, ref = null) => ({
680
+ ref: (0, import_utils.mergeRefs)(containerRef, ref),
681
+ ...containerProps,
682
+ ...props,
683
+ ...formControlProps,
684
+ onClick: (0, import_utils.handlerAll)(props.onClick, rest.onClick, onClick),
685
+ onFocus: (0, import_utils.handlerAll)(props.onFocus, rest.onFocus, onFocus),
686
+ onBlur: (0, import_utils.handlerAll)(props.onBlur, rest.onBlur, onBlur)
687
+ }),
688
+ [containerProps, formControlProps, onBlur, onClick, onFocus, rest]
689
+ );
690
+ const getFieldProps = (0, import_react.useCallback)(
691
+ (props = {}, ref = null) => ({
692
+ ref,
693
+ tabIndex: -1,
694
+ ...props,
695
+ ...formControlProps,
696
+ placeholder,
697
+ "data-active": (0, import_utils.dataAttr)(isOpen),
698
+ "aria-expanded": (0, import_utils.dataAttr)(isOpen),
699
+ onKeyDown: (0, import_utils.handlerAll)(props.onKeyDown, rest.onKeyDown, onKeyDown)
700
+ }),
701
+ [formControlProps, placeholder, isOpen, rest, onKeyDown]
702
+ );
703
+ return {
704
+ id,
705
+ descendants,
706
+ value,
707
+ displayValue,
708
+ inputValue,
709
+ isHit,
710
+ isEmpty,
711
+ computedChildren,
712
+ focusedIndex,
713
+ omitSelectedValues,
714
+ closeOnSelect,
715
+ createOption,
716
+ emptyMessage,
717
+ isOpen,
718
+ isAllSelected,
719
+ listRef,
720
+ inputRef,
721
+ optionProps,
722
+ formControlProps,
723
+ setFocusedIndex,
724
+ onChangeDisplayValue,
725
+ onChange,
726
+ onSearch,
727
+ onCreate,
728
+ onClear,
729
+ onCompositionStart,
730
+ onCompositionEnd,
731
+ pickOptions,
732
+ rebirthOptions,
733
+ onOpen,
734
+ onClose,
735
+ onFocusFirst,
736
+ onFocusLast,
737
+ onFocusSelected,
738
+ onFocusNext,
739
+ onFocusPrev,
740
+ getPopoverProps,
741
+ getContainerProps,
742
+ getFieldProps,
743
+ inputProps
744
+ };
745
+ };
746
+ var useAutocompleteInput = () => {
747
+ const {
748
+ id,
749
+ inputRef,
750
+ onSearch,
751
+ onCompositionStart,
752
+ onCompositionEnd,
753
+ isAllSelected,
754
+ formControlProps,
755
+ inputProps
756
+ } = useAutocompleteContext();
757
+ (0, import_utils.useUpdateEffect)(() => {
758
+ if (isAllSelected && inputRef.current)
759
+ inputRef.current.blur();
760
+ }, [isAllSelected]);
761
+ const getInputProps = (0, import_react.useCallback)(
762
+ (props = {}, ref = null) => ({
763
+ ref: (0, import_utils.mergeRefs)(inputRef, ref),
764
+ ...formControlProps,
765
+ ...inputProps,
766
+ ...props,
767
+ id,
768
+ cursor: formControlProps.readOnly ? "default" : "text",
769
+ pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
770
+ tabIndex: isAllSelected ? -1 : 0,
771
+ onChange: (0, import_utils.handlerAll)(props.onChange, onSearch),
772
+ onCompositionStart: (0, import_utils.handlerAll)(
773
+ props.onCompositionStart,
774
+ inputProps.onCompositionStart,
775
+ onCompositionStart
776
+ ),
777
+ onCompositionEnd: (0, import_utils.handlerAll)(
778
+ props.onCompositionEnd,
779
+ inputProps.onCompositionEnd,
780
+ onCompositionEnd
781
+ )
782
+ }),
783
+ [
784
+ inputProps,
785
+ inputRef,
786
+ formControlProps,
787
+ id,
788
+ isAllSelected,
789
+ onSearch,
790
+ onCompositionStart,
791
+ onCompositionEnd
792
+ ]
793
+ );
794
+ return {
795
+ getInputProps
796
+ };
797
+ };
798
+ var useAutocompleteList = () => {
799
+ const { focusedIndex, isOpen, listRef, rebirthOptions } = useAutocompleteContext();
800
+ const descendants = useAutocompleteDescendantsContext();
801
+ const beforeFocusedIndex = (0, import_react.useRef)(-1);
802
+ const selectedValue = descendants.value(focusedIndex);
803
+ const onAnimationComplete = (0, import_react.useCallback)(() => {
804
+ if (!isOpen)
805
+ rebirthOptions(false);
806
+ }, [isOpen, rebirthOptions]);
807
+ (0, import_react.useEffect)(() => {
808
+ if (!listRef.current || !selectedValue)
809
+ return;
810
+ const parent = listRef.current;
811
+ const child = selectedValue.node;
812
+ const parentHeight = parent.clientHeight;
813
+ const viewTop = parent.scrollTop;
814
+ const viewBottom = viewTop + parentHeight;
815
+ const childHeight = child.clientHeight;
816
+ const childTop = child.offsetTop;
817
+ const childBottom = childTop + childHeight;
818
+ const isInView = viewTop <= childTop && childBottom <= viewBottom;
819
+ const isScrollBottom = beforeFocusedIndex.current < selectedValue.index;
820
+ if (!isInView) {
821
+ if (childBottom <= parentHeight) {
822
+ listRef.current.scrollTo({ top: 0 });
823
+ } else {
824
+ if (!isScrollBottom) {
825
+ listRef.current.scrollTo({ top: childTop + 1 });
826
+ } else {
827
+ listRef.current.scrollTo({ top: childBottom - parentHeight });
828
+ }
829
+ }
830
+ }
831
+ beforeFocusedIndex.current = selectedValue.index;
832
+ }, [listRef, selectedValue]);
833
+ (0, import_utils.useUpdateEffect)(() => {
834
+ if (!isOpen)
835
+ beforeFocusedIndex.current = -1;
836
+ }, [isOpen]);
837
+ const getListProps = (0, import_react.useCallback)(
838
+ (props = {}, ref = null) => ({
839
+ as: "ul",
840
+ ref: (0, import_utils.mergeRefs)(listRef, ref),
841
+ role: "select",
842
+ tabIndex: -1,
843
+ ...props,
844
+ onAnimationComplete: (0, import_utils.handlerAll)(props.onAnimationComplete, onAnimationComplete)
845
+ }),
846
+ [listRef, onAnimationComplete]
847
+ );
848
+ return {
849
+ getListProps
850
+ };
851
+ };
852
+ var useAutocompleteOptionGroup = ({ label, ...rest }) => {
853
+ const { value, omitSelectedValues } = useAutocompleteContext();
854
+ const isMulti = (0, import_utils.isArray)(value);
855
+ const descendants = useAutocompleteDescendantsContext();
856
+ const values = descendants.values();
857
+ const selectedValues = isMulti && omitSelectedValues ? descendants.values(({ node }) => {
858
+ var _a;
859
+ return value.includes((_a = node.dataset.value) != null ? _a : "");
860
+ }) : [];
861
+ const selectedIndexes = selectedValues.map(({ index }) => index);
862
+ const childValues = values.filter(
863
+ ({ node, index }) => {
864
+ var _a;
865
+ return ((_a = node.parentElement) == null ? void 0 : _a.dataset.label) === label && !selectedIndexes.includes(index) && "target" in node.dataset;
866
+ }
867
+ );
868
+ const isEmpty = !childValues.length;
869
+ const computedRest = (0, import_utils.splitObject)(rest, import_core.layoutStylesProperties);
870
+ const getContainerProps = (0, import_react.useCallback)(
871
+ (props = {}, ref = null) => {
872
+ const style = {
873
+ border: "0px",
874
+ clip: "rect(0px, 0px, 0px, 0px)",
875
+ height: "1px",
876
+ width: "1px",
877
+ margin: "-1px",
878
+ padding: "0px",
879
+ overflow: "hidden",
880
+ whiteSpace: "nowrap",
881
+ position: "absolute"
882
+ };
883
+ return {
884
+ ref,
885
+ ...props,
886
+ ...computedRest[0],
887
+ style: isEmpty ? style : void 0,
888
+ "data-label": label,
889
+ role: "autocomplete-group-container"
890
+ };
891
+ },
892
+ [computedRest, isEmpty, label]
893
+ );
894
+ const getGroupProps = (0, import_react.useCallback)(
895
+ (props = {}, ref = null) => ({
896
+ ref,
897
+ ...props,
898
+ ...computedRest[1],
899
+ "data-label": label,
900
+ role: "autocomplete-group"
901
+ }),
902
+ [computedRest, label]
903
+ );
904
+ return {
905
+ label,
906
+ getContainerProps,
907
+ getGroupProps
908
+ };
909
+ };
910
+ var useAutocompleteOption = (props) => {
911
+ var _a, _b, _c, _d;
912
+ const {
913
+ value,
914
+ omitSelectedValues,
915
+ onChange,
916
+ onChangeDisplayValue,
917
+ focusedIndex,
918
+ setFocusedIndex,
919
+ onClose,
920
+ closeOnSelect: generalCloseOnSelect,
921
+ optionProps,
922
+ inputRef,
923
+ onFocusNext
924
+ } = useAutocompleteContext();
925
+ let {
926
+ icon: customIcon,
927
+ isDisabled,
928
+ isFocusable,
929
+ closeOnSelect: customCloseOnSelect,
930
+ children,
931
+ ...computedProps
932
+ } = { ...optionProps, ...props };
933
+ const trulyDisabled = !!isDisabled && !isFocusable;
934
+ const itemRef = (0, import_react.useRef)(null);
935
+ const { index, register, descendants } = useAutocompleteDescendant({ disabled: trulyDisabled });
936
+ const values = descendants.values();
937
+ const frontValues = values.slice(0, index);
938
+ const isMulti = (0, import_utils.isArray)(value);
939
+ const isDuplicated = !isMulti ? frontValues.some(({ node }) => {
940
+ var _a2;
941
+ return node.dataset.value === ((_a2 = computedProps.value) != null ? _a2 : "");
942
+ }) : false;
943
+ const isSelected = !isDuplicated && (!isMulti ? ((_a = computedProps.value) != null ? _a : "") === value : value.includes((_b = computedProps.value) != null ? _b : ""));
944
+ const isTarget = "target" in ((_d = (_c = itemRef.current) == null ? void 0 : _c.dataset) != null ? _d : {});
945
+ const isFocused = index === focusedIndex;
946
+ const onClick = (0, import_react.useCallback)(
947
+ (ev) => {
948
+ var _a2;
949
+ ev.stopPropagation();
950
+ if (isDisabled) {
951
+ if (inputRef.current)
952
+ inputRef.current.focus();
953
+ return;
954
+ }
955
+ if (!isTargetOption(ev.currentTarget)) {
956
+ if (inputRef.current)
957
+ inputRef.current.focus();
958
+ return;
959
+ }
960
+ setFocusedIndex(index);
961
+ onChange((_a2 = computedProps.value) != null ? _a2 : "");
962
+ if (inputRef.current)
963
+ inputRef.current.focus();
964
+ if (customCloseOnSelect != null ? customCloseOnSelect : generalCloseOnSelect)
965
+ onClose();
966
+ if (omitSelectedValues)
967
+ onFocusNext(index);
968
+ },
969
+ [
970
+ onFocusNext,
971
+ omitSelectedValues,
972
+ isDisabled,
973
+ computedProps,
974
+ setFocusedIndex,
975
+ index,
976
+ onChange,
977
+ customCloseOnSelect,
978
+ generalCloseOnSelect,
979
+ onClose,
980
+ inputRef
981
+ ]
982
+ );
983
+ (0, import_react.useEffect)(() => {
984
+ var _a2;
985
+ if (isSelected)
986
+ onChangeDisplayValue((_a2 = computedProps.value) != null ? _a2 : "", false);
987
+ }, [computedProps, isSelected, onChangeDisplayValue]);
988
+ const getOptionProps = (0, import_react.useCallback)(
989
+ (props2 = {}, ref = null) => {
990
+ var _a2;
991
+ const style = {
992
+ border: "0px",
993
+ clip: "rect(0px, 0px, 0px, 0px)",
994
+ height: "1px",
995
+ width: "1px",
996
+ margin: "-1px",
997
+ padding: "0px",
998
+ overflow: "hidden",
999
+ whiteSpace: "nowrap",
1000
+ position: "absolute"
1001
+ };
1002
+ return {
1003
+ ref: (0, import_utils.mergeRefs)(itemRef, ref, register),
1004
+ ...(0, import_utils.omitObject)(computedProps, ["value"]),
1005
+ ...props2,
1006
+ role: "autocomplete-item",
1007
+ tabIndex: -1,
1008
+ style: !isTarget || omitSelectedValues && isSelected ? style : void 0,
1009
+ "data-target": (0, import_utils.dataAttr)(true),
1010
+ "data-value": (_a2 = computedProps.value) != null ? _a2 : "",
1011
+ "data-focus": (0, import_utils.dataAttr)(isFocused),
1012
+ "data-disabled": (0, import_utils.dataAttr)(isDisabled),
1013
+ "aria-checked": (0, import_utils.ariaAttr)(isSelected),
1014
+ "aria-disabled": (0, import_utils.ariaAttr)(isDisabled),
1015
+ onClick: (0, import_utils.handlerAll)(computedProps.onClick, props2.onClick, onClick)
1016
+ };
1017
+ },
1018
+ [
1019
+ computedProps,
1020
+ isDisabled,
1021
+ isFocused,
1022
+ isSelected,
1023
+ isTarget,
1024
+ omitSelectedValues,
1025
+ onClick,
1026
+ register
1027
+ ]
1028
+ );
1029
+ return {
1030
+ isSelected,
1031
+ isFocused,
1032
+ customIcon,
1033
+ children,
1034
+ getOptionProps
1035
+ };
1036
+ };
1037
+ var useAutocompleteCreate = () => {
1038
+ const { isHit, onCreate } = useAutocompleteContext();
1039
+ const getCreateProps = (0, import_react.useCallback)(
1040
+ (props = {}, ref = null) => {
1041
+ const style = {
1042
+ border: "0px",
1043
+ clip: "rect(0px, 0px, 0px, 0px)",
1044
+ height: "1px",
1045
+ width: "1px",
1046
+ margin: "-1px",
1047
+ padding: "0px",
1048
+ overflow: "hidden",
1049
+ whiteSpace: "nowrap",
1050
+ position: "absolute"
1051
+ };
1052
+ return {
1053
+ ref,
1054
+ ...props,
1055
+ tabIndex: -1,
1056
+ style: isHit ? style : void 0,
1057
+ "data-focus": (0, import_utils.dataAttr)(!isHit),
1058
+ onClick: (0, import_utils.handlerAll)(props.onClick, onCreate)
1059
+ };
1060
+ },
1061
+ [isHit, onCreate]
1062
+ );
1063
+ return { getCreateProps };
1064
+ };
1065
+ var useAutocompleteEmpty = () => {
1066
+ const { isHit, isEmpty } = useAutocompleteContext();
1067
+ const getEmptyProps = (0, import_react.useCallback)(
1068
+ (props = {}, ref = null) => {
1069
+ const style = {
1070
+ border: "0px",
1071
+ clip: "rect(0px, 0px, 0px, 0px)",
1072
+ height: "1px",
1073
+ width: "1px",
1074
+ margin: "-1px",
1075
+ padding: "0px",
1076
+ overflow: "hidden",
1077
+ whiteSpace: "nowrap",
1078
+ position: "absolute"
1079
+ };
1080
+ return {
1081
+ ref,
1082
+ ...props,
1083
+ tabIndex: -1,
1084
+ style: isHit && !isEmpty ? style : void 0
1085
+ };
1086
+ },
1087
+ [isHit, isEmpty]
1088
+ );
1089
+ return { getEmptyProps };
1090
+ };
1091
+
1092
+ // src/autocomplete-icon.tsx
1093
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1094
+ var AutocompleteIcon = (0, import_core2.forwardRef)(
1095
+ ({ className, children, __css, ...rest }, ref) => {
1096
+ const { styles } = useAutocompleteContext();
1097
+ const css = {
1098
+ position: "absolute",
1099
+ top: "50%",
1100
+ transform: "translateY(-50%)",
1101
+ display: "inline-flex",
1102
+ alignItems: "center",
1103
+ justifyContent: "center",
1104
+ pointerEvents: "none",
1105
+ cursor: "pointer",
1106
+ ...styles.icon,
1107
+ ...__css
1108
+ };
1109
+ const validChildren = (0, import_utils2.getValidChildren)(children);
1110
+ const cloneChildren = validChildren.map(
1111
+ (child) => (0, import_react2.cloneElement)(child, {
1112
+ focusable: false,
1113
+ "aria-hidden": true,
1114
+ style: {
1115
+ maxWidth: "1em",
1116
+ maxHeight: "1em",
1117
+ color: "currentColor"
1118
+ }
1119
+ })
1120
+ );
1121
+ 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, {}) });
1122
+ }
1123
+ );
1124
+ var AutocompleteClearIcon = ({
1125
+ className,
1126
+ children,
1127
+ ...props
1128
+ }) => {
1129
+ const ref = (0, import_react2.useRef)(null);
1130
+ const { styles } = useAutocompleteContext();
1131
+ const isDisabled = props.disabled;
1132
+ const rest = (0, import_use_clickable.useClickable)({
1133
+ ref,
1134
+ isDisabled,
1135
+ ...props
1136
+ });
1137
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1138
+ AutocompleteIcon,
1139
+ {
1140
+ className: (0, import_utils2.cx)("ui-autocomplete-clear-icon", className),
1141
+ __css: styles.clearIcon,
1142
+ ...rest,
1143
+ children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icon.CloseIcon, { w: "0.5em", h: "0.5em" })
1144
+ }
1145
+ );
1146
+ };
1147
+ var AutocompleteItemIcon = (0, import_core2.forwardRef)(
1148
+ ({ className, ...rest }, ref) => {
1149
+ const { styles } = useAutocompleteContext();
1150
+ const css = {
1151
+ flexShrink: 0,
1152
+ display: "inline-flex",
1153
+ justifyContent: "center",
1154
+ alignItems: "center",
1155
+ fontSize: "0.85em",
1156
+ ...styles.itemIcon
1157
+ };
1158
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1159
+ import_core2.ui.span,
1160
+ {
1161
+ ref,
1162
+ className: (0, import_utils2.cx)("ui-autocomplete-item-icon", className),
1163
+ __css: css,
1164
+ ...rest
1165
+ }
1166
+ );
1167
+ }
1168
+ );
1169
+
1170
+ // src/autocomplete-list.tsx
1171
+ var import_core3 = require("@yamada-ui/core");
1172
+ var import_popover = require("@yamada-ui/popover");
1173
+ var import_utils3 = require("@yamada-ui/utils");
1174
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1175
+ var AutocompleteList = (0, import_core3.forwardRef)(
1176
+ ({ className, w, width, minW, minWidth, ...rest }, ref) => {
1177
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1178
+ const { styles } = useAutocompleteContext();
1179
+ const { getListProps } = useAutocompleteList();
1180
+ 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;
1181
+ 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;
1182
+ const css = { ...styles.list };
1183
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1184
+ import_popover.PopoverContent,
1185
+ {
1186
+ className: (0, import_utils3.cx)("ui-autocomplete-list", className),
1187
+ w,
1188
+ minW,
1189
+ __css: css,
1190
+ ...getListProps(rest, ref)
1191
+ }
1192
+ );
1193
+ }
1194
+ );
1195
+
1196
+ // src/autocomplete.tsx
1197
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1198
+ var Autocomplete = (0, import_core4.forwardRef)((props, ref) => {
1199
+ const [styles, mergedProps] = (0, import_core4.useMultiComponentStyle)("Select", props);
1200
+ let {
1201
+ className,
1202
+ defaultValue = "",
1203
+ color,
1204
+ h,
1205
+ height,
1206
+ minH,
1207
+ minHeight,
1208
+ containerProps,
1209
+ listProps,
1210
+ inputProps,
1211
+ iconProps,
1212
+ children,
1213
+ ...computedProps
1214
+ } = (0, import_core4.omitThemeProps)(mergedProps);
1215
+ const {
1216
+ descendants,
1217
+ formControlProps,
1218
+ getPopoverProps,
1219
+ getContainerProps,
1220
+ getFieldProps,
1221
+ createOption,
1222
+ isEmpty,
1223
+ inputValue,
1224
+ computedChildren,
1225
+ ...rest
1226
+ } = useAutocomplete({ ...computedProps, defaultValue, children });
1227
+ h = h != null ? h : height;
1228
+ minH = minH != null ? minH : minHeight;
1229
+ const css = {
1230
+ position: "relative",
1231
+ w: "100%",
1232
+ h: "fit-content",
1233
+ color,
1234
+ ...styles.container
1235
+ };
1236
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1237
+ AutocompleteProvider,
1238
+ {
1239
+ value: { ...rest, formControlProps, inputValue, createOption, isEmpty, styles },
1240
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover2.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1241
+ import_core4.ui.div,
1242
+ {
1243
+ className: (0, import_utils4.cx)("ui-autocomplete", className),
1244
+ __css: css,
1245
+ ...getContainerProps(containerProps),
1246
+ children: [
1247
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1248
+ AutocompleteField,
1249
+ {
1250
+ h,
1251
+ minH,
1252
+ inputProps,
1253
+ ...getFieldProps({}, ref)
1254
+ }
1255
+ ),
1256
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
1257
+ !isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(AutocompleteList, { ...listProps, children: [
1258
+ createOption ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteEmpty, {}),
1259
+ children != null ? children : computedChildren
1260
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteEmpty, {}) })
1261
+ ]
1262
+ }
1263
+ ) })
1264
+ }
1265
+ ) });
1266
+ });
1267
+ var AutocompleteField = (0, import_core4.forwardRef)(
1268
+ ({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {
1269
+ const { displayValue, inputValue, styles } = useAutocompleteContext();
1270
+ const { getInputProps } = useAutocompleteInput();
1271
+ const css = {
1272
+ paddingEnd: "2rem",
1273
+ h,
1274
+ minH,
1275
+ display: "flex",
1276
+ alignItems: "center",
1277
+ ...styles.field,
1278
+ cursor: "text"
1279
+ };
1280
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover2.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.div, { className: (0, import_utils4.cx)("ui-autocomplete-field", className), __css: css, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1281
+ import_core4.ui.input,
1282
+ {
1283
+ className: "ui-autocomplete-input",
1284
+ display: "inline-block",
1285
+ w: "full",
1286
+ placeholder,
1287
+ ...getInputProps(inputProps, ref),
1288
+ value: inputValue || displayValue || ""
1289
+ }
1290
+ ) }) });
1291
+ }
1292
+ );
1293
+
1294
+ // src/autocomplete-option-group.tsx
1295
+ var import_core5 = require("@yamada-ui/core");
1296
+ var import_utils5 = require("@yamada-ui/utils");
1297
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1298
+ var AutocompleteOptionGroup = (0, import_core5.forwardRef)(
1299
+ ({ className, color, h, height, minH, minHeight, children, ...rest }, ref) => {
1300
+ const { styles } = useAutocompleteContext();
1301
+ const { label, getContainerProps, getGroupProps } = useAutocompleteOptionGroup(rest);
1302
+ h = h != null ? h : height;
1303
+ minH = minH != null ? minH : minHeight;
1304
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1305
+ import_core5.ui.li,
1306
+ {
1307
+ className: "ui-autocomplete-group-container",
1308
+ __css: { w: "100%", h: "fit-content", color },
1309
+ ...getContainerProps(),
1310
+ children: [
1311
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1312
+ import_core5.ui.span,
1313
+ {
1314
+ className: (0, import_utils5.cx)("ui-autocomplete-group-label"),
1315
+ __css: styles.groupLabel,
1316
+ noOfLines: 1,
1317
+ children: label
1318
+ }
1319
+ ),
1320
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1321
+ import_core5.ui.ul,
1322
+ {
1323
+ ...getGroupProps({}, ref),
1324
+ className: (0, import_utils5.cx)("ui-autocomplete-group", className),
1325
+ __css: { h, minH, ...styles.group },
1326
+ children
1327
+ }
1328
+ )
1329
+ ]
1330
+ }
1331
+ );
1332
+ }
1333
+ );
1334
+
1335
+ // src/autocomplete-option.tsx
1336
+ var import_core6 = require("@yamada-ui/core");
1337
+ var import_utils6 = require("@yamada-ui/utils");
1338
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1339
+ var AutocompleteOption = (0, import_core6.forwardRef)(
1340
+ ({ className, icon, ...rest }, ref) => {
1341
+ const { styles } = useAutocompleteContext();
1342
+ const { isSelected, customIcon, children, getOptionProps } = useAutocompleteOption(rest);
1343
+ icon = icon != null ? icon : customIcon;
1344
+ const css = {
1345
+ textDecoration: "none",
1346
+ color: "inherit",
1347
+ userSelect: "none",
1348
+ display: "flex",
1349
+ width: "100%",
1350
+ alignItems: "center",
1351
+ textAlign: "start",
1352
+ flex: "0 0 auto",
1353
+ outline: 0,
1354
+ gap: "0.75rem",
1355
+ ...styles.item
1356
+ };
1357
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1358
+ import_core6.ui.li,
1359
+ {
1360
+ className: (0, import_utils6.cx)("ui-autocomplete-item", className),
1361
+ __css: css,
1362
+ ...getOptionProps({}, ref),
1363
+ children: [
1364
+ icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutocompleteItemIcon, { opacity: isSelected ? 1 : 0, children: icon || /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, {}) }) : null,
1365
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.ui.span, { style: { pointerEvents: "none", flex: 1 }, noOfLines: 1, children }) : children
1366
+ ]
1367
+ }
1368
+ );
1369
+ }
1370
+ );
1371
+ var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1372
+ "polygon",
1373
+ {
1374
+ fill: "currentColor",
1375
+ points: "5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"
1376
+ }
1377
+ ) });
1378
+
1379
+ // src/autocomplete-create.tsx
1380
+ var import_core7 = require("@yamada-ui/core");
1381
+ var import_utils7 = require("@yamada-ui/utils");
1382
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1383
+ var AutocompleteCreate = (0, import_core7.forwardRef)(
1384
+ ({ className, icon, children, ...rest }, ref) => {
1385
+ const { inputValue, styles } = useAutocompleteContext();
1386
+ const { getCreateProps } = useAutocompleteCreate();
1387
+ children != null ? children : children = inputValue;
1388
+ const css = {
1389
+ textDecoration: "none",
1390
+ color: "inherit",
1391
+ userSelect: "none",
1392
+ display: "flex",
1393
+ width: "100%",
1394
+ alignItems: "center",
1395
+ textAlign: "start",
1396
+ flex: "0 0 auto",
1397
+ outline: 0,
1398
+ gap: "0.75rem",
1399
+ ...styles.item
1400
+ };
1401
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1402
+ import_core7.ui.li,
1403
+ {
1404
+ className: (0, import_utils7.cx)("ui-autocomplete-create", className),
1405
+ __css: css,
1406
+ ...getCreateProps(rest, ref),
1407
+ children: [
1408
+ icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PlusIcon, {}) }) : null,
1409
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.ui.span, { style: { pointerEvents: "none", flex: 1 }, noOfLines: 1, children: (0, import_utils7.runIfFunc)(children, inputValue) }) : (0, import_utils7.runIfFunc)(children, inputValue)
1410
+ ]
1411
+ }
1412
+ );
1413
+ }
1414
+ );
1415
+ var PlusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { viewBox: "0 0 45.402 45.402", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1416
+ "path",
1417
+ {
1418
+ fill: "currentColor",
1419
+ d: "M41.267,18.557H26.832V4.134C26.832,1.851,24.99,0,22.707,0c-2.283,0-4.124,1.851-4.124,4.135v14.432H4.141 c-2.283,0-4.139,1.851-4.138,4.135c-0.001,1.141,0.46,2.187,1.207,2.934c0.748,0.749,1.78,1.222,2.92,1.222h14.453V41.27 c0,1.142,0.453,2.176,1.201,2.922c0.748,0.748,1.777,1.211,2.919,1.211c2.282,0,4.129-1.851,4.129-4.133V26.857h14.435 c2.283,0,4.134-1.867,4.133-4.15C45.399,20.425,43.548,18.557,41.267,18.557z"
1420
+ }
1421
+ ) });
1422
+
1423
+ // src/autocomplete-empty.tsx
1424
+ var import_core8 = require("@yamada-ui/core");
1425
+ var import_utils8 = require("@yamada-ui/utils");
1426
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1427
+ var AutocompleteEmpty = (0, import_core8.forwardRef)(
1428
+ ({ className, icon, children, ...rest }, ref) => {
1429
+ const { emptyMessage, styles } = useAutocompleteContext();
1430
+ const { getEmptyProps } = useAutocompleteEmpty();
1431
+ children != null ? children : children = emptyMessage;
1432
+ const css = {
1433
+ textDecoration: "none",
1434
+ color: "inherit",
1435
+ userSelect: "none",
1436
+ display: "flex",
1437
+ width: "100%",
1438
+ alignItems: "center",
1439
+ textAlign: "start",
1440
+ flex: "0 0 auto",
1441
+ outline: 0,
1442
+ gap: "0.75rem",
1443
+ pointerEvents: "none",
1444
+ ...styles.item
1445
+ };
1446
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1447
+ import_core8.ui.li,
1448
+ {
1449
+ className: (0, import_utils8.cx)("ui-autocomplete-empty", className),
1450
+ __css: css,
1451
+ ...getEmptyProps(rest, ref),
1452
+ children: [
1453
+ icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MinusIcon, {}) }) : null,
1454
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.ui.span, { style: { pointerEvents: "none", flex: 1 }, noOfLines: 1, children }) : children
1455
+ ]
1456
+ }
1457
+ );
1458
+ }
1459
+ );
1460
+ var MinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 448 512", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1461
+ "path",
1462
+ {
1463
+ fill: "currentColor",
1464
+ d: "M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z"
1465
+ }
1466
+ ) });
1467
+
1468
+ // src/multi-autocomplete.tsx
1469
+ var import_core9 = require("@yamada-ui/core");
1470
+ var import_popover3 = require("@yamada-ui/popover");
1471
+ var import_utils9 = require("@yamada-ui/utils");
1472
+ var import_react3 = require("react");
1473
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1474
+ var MultiAutocomplete = (0, import_core9.forwardRef)((props, ref) => {
1475
+ const [styles, mergedProps] = (0, import_core9.useMultiComponentStyle)("Select", props);
1476
+ let {
1477
+ className,
1478
+ defaultValue = [],
1479
+ component,
1480
+ separator,
1481
+ isClearable = true,
1482
+ color,
1483
+ h,
1484
+ height,
1485
+ minH,
1486
+ minHeight,
1487
+ closeOnSelect = false,
1488
+ keepPlaceholder = false,
1489
+ containerProps,
1490
+ listProps,
1491
+ inputProps,
1492
+ iconProps,
1493
+ clearIconProps,
1494
+ children,
1495
+ ...computedProps
1496
+ } = (0, import_core9.omitThemeProps)(mergedProps);
1497
+ const {
1498
+ value,
1499
+ descendants,
1500
+ formControlProps,
1501
+ getPopoverProps,
1502
+ getContainerProps,
1503
+ getFieldProps,
1504
+ createOption,
1505
+ isEmpty,
1506
+ inputValue,
1507
+ computedChildren,
1508
+ onClear,
1509
+ ...rest
1510
+ } = useAutocomplete({
1511
+ ...computedProps,
1512
+ defaultValue,
1513
+ closeOnSelect,
1514
+ children
1515
+ });
1516
+ h = h != null ? h : height;
1517
+ minH = minH != null ? minH : minHeight;
1518
+ const css = {
1519
+ position: "relative",
1520
+ w: "100%",
1521
+ h: "fit-content",
1522
+ color,
1523
+ ...styles.container
1524
+ };
1525
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1526
+ AutocompleteProvider,
1527
+ {
1528
+ value: {
1529
+ ...rest,
1530
+ value,
1531
+ formControlProps,
1532
+ inputValue,
1533
+ createOption,
1534
+ isEmpty,
1535
+ styles
1536
+ },
1537
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover3.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core9.ui.div, { className: "ui-autocomplete", __css: css, ...getContainerProps(containerProps), children: [
1538
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1539
+ MultiAutocompleteField,
1540
+ {
1541
+ component,
1542
+ separator,
1543
+ keepPlaceholder,
1544
+ h,
1545
+ minH,
1546
+ inputProps,
1547
+ ...getFieldProps({}, ref)
1548
+ }
1549
+ ),
1550
+ isClearable && value.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1551
+ AutocompleteClearIcon,
1552
+ {
1553
+ ...clearIconProps,
1554
+ onClick: (0, import_utils9.handlerAll)(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
1555
+ ...formControlProps
1556
+ }
1557
+ ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
1558
+ !isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(AutocompleteList, { ...listProps, children: [
1559
+ createOption ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, {}),
1560
+ children != null ? children : computedChildren
1561
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, {}) })
1562
+ ] }) })
1563
+ }
1564
+ ) });
1565
+ });
1566
+ var MultiAutocompleteField = (0, import_core9.forwardRef)(
1567
+ ({
1568
+ className,
1569
+ component,
1570
+ separator = ",",
1571
+ keepPlaceholder,
1572
+ h,
1573
+ minH,
1574
+ placeholder,
1575
+ inputProps,
1576
+ ...rest
1577
+ }, ref) => {
1578
+ const { value, displayValue, inputValue, onChange, isOpen, inputRef, styles } = useAutocompleteContext();
1579
+ const { getInputProps } = useAutocompleteInput();
1580
+ const cloneChildren = (0, import_react3.useMemo)(() => {
1581
+ if (!(displayValue == null ? void 0 : displayValue.length))
1582
+ return null;
1583
+ if (component) {
1584
+ return displayValue.map((displayValue2, index) => {
1585
+ const onRemove = (e) => {
1586
+ e.stopPropagation();
1587
+ onChange(value[index]);
1588
+ if (inputRef.current)
1589
+ inputRef.current.focus();
1590
+ };
1591
+ const el = component({
1592
+ value: value[index],
1593
+ displayValue: displayValue2,
1594
+ index,
1595
+ onRemove
1596
+ });
1597
+ const style = {
1598
+ cursor: "default",
1599
+ marginBlockStart: "0.125rem",
1600
+ marginBlockEnd: "0.125rem",
1601
+ marginInlineEnd: "0.25rem"
1602
+ };
1603
+ return el ? (0, import_react3.cloneElement)(el, { style }) : null;
1604
+ });
1605
+ } else {
1606
+ return displayValue.map((value2, index) => {
1607
+ const isLast = displayValue.length === index + 1;
1608
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core9.ui.span, { display: "inline-block", me: "0.25rem", children: [
1609
+ value2,
1610
+ !isLast || isOpen ? separator : null
1611
+ ] }, index);
1612
+ });
1613
+ }
1614
+ }, [displayValue, component, value, onChange, isOpen, inputRef, separator]);
1615
+ const css = {
1616
+ paddingEnd: "2rem",
1617
+ h,
1618
+ minH,
1619
+ display: "flex",
1620
+ flexWrap: "wrap",
1621
+ alignItems: "center",
1622
+ ...styles.field,
1623
+ cursor: "text"
1624
+ };
1625
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover3.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1626
+ import_core9.ui.div,
1627
+ {
1628
+ className: (0, import_utils9.cx)("ui-autocomplete-field", className),
1629
+ __css: css,
1630
+ py: (displayValue == null ? void 0 : displayValue.length) && component ? "0.125rem" : void 0,
1631
+ ...rest,
1632
+ children: [
1633
+ cloneChildren,
1634
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1635
+ import_core9.ui.input,
1636
+ {
1637
+ className: "ui-autocomplete-input",
1638
+ display: "inline-block",
1639
+ flex: "1",
1640
+ overflow: "hidden",
1641
+ marginBlockStart: "0.125rem",
1642
+ marginBlockEnd: "0.125rem",
1643
+ placeholder: !displayValue || keepPlaceholder && isOpen ? placeholder : void 0,
1644
+ ...getInputProps(inputProps, ref),
1645
+ value: inputValue
1646
+ }
1647
+ )
1648
+ ]
1649
+ }
1650
+ ) });
1651
+ }
1652
+ );
1653
+ // Annotate the CommonJS export names for ESM import in node:
1654
+ 0 && (module.exports = {
1655
+ Autocomplete,
1656
+ AutocompleteCreate,
1657
+ AutocompleteEmpty,
1658
+ AutocompleteOption,
1659
+ AutocompleteOptionGroup,
1660
+ MultiAutocomplete
1661
+ });