@yamada-ui/autocomplete 1.5.4-next-20241005220055 → 1.6.0-dev-20241011151311

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/dist/autocomplete-context.d.mts +115 -115
  2. package/dist/autocomplete-context.d.ts +115 -115
  3. package/dist/autocomplete-context.js +2 -2
  4. package/dist/autocomplete-context.js.map +1 -1
  5. package/dist/autocomplete-context.mjs +1 -1
  6. package/dist/autocomplete-create.d.mts +4 -4
  7. package/dist/autocomplete-create.d.ts +4 -4
  8. package/dist/autocomplete-create.js +32 -32
  9. package/dist/autocomplete-create.js.map +1 -1
  10. package/dist/autocomplete-create.mjs +4 -4
  11. package/dist/autocomplete-empty.d.mts +4 -4
  12. package/dist/autocomplete-empty.d.ts +4 -4
  13. package/dist/autocomplete-empty.js +34 -34
  14. package/dist/autocomplete-empty.js.map +1 -1
  15. package/dist/autocomplete-empty.mjs +4 -4
  16. package/dist/autocomplete-icon.js +17 -17
  17. package/dist/autocomplete-icon.js.map +1 -1
  18. package/dist/autocomplete-icon.mjs +2 -2
  19. package/dist/autocomplete-list.d.mts +2 -2
  20. package/dist/autocomplete-list.d.ts +2 -2
  21. package/dist/autocomplete-list.js +18 -18
  22. package/dist/autocomplete-list.js.map +1 -1
  23. package/dist/autocomplete-list.mjs +3 -3
  24. package/dist/autocomplete-option-group.js +10 -10
  25. package/dist/autocomplete-option-group.js.map +1 -1
  26. package/dist/autocomplete-option-group.mjs +3 -3
  27. package/dist/autocomplete-option.d.mts +1 -1
  28. package/dist/autocomplete-option.d.ts +1 -1
  29. package/dist/autocomplete-option.js +56 -47
  30. package/dist/autocomplete-option.js.map +1 -1
  31. package/dist/autocomplete-option.mjs +4 -4
  32. package/dist/autocomplete.d.mts +31 -31
  33. package/dist/autocomplete.d.ts +31 -31
  34. package/dist/autocomplete.js +303 -292
  35. package/dist/autocomplete.js.map +1 -1
  36. package/dist/autocomplete.mjs +12 -12
  37. package/dist/{chunk-5GKGL6BL.mjs → chunk-2HJUFFCU.mjs} +16 -16
  38. package/dist/chunk-2HJUFFCU.mjs.map +1 -0
  39. package/dist/{chunk-6F3LT7J6.mjs → chunk-4SBNPEK7.mjs} +7 -7
  40. package/dist/{chunk-6F3LT7J6.mjs.map → chunk-4SBNPEK7.mjs.map} +1 -1
  41. package/dist/{chunk-JMX72TSD.mjs → chunk-67X7JKWL.mjs} +7 -7
  42. package/dist/{chunk-JMX72TSD.mjs.map → chunk-67X7JKWL.mjs.map} +1 -1
  43. package/dist/{chunk-5LPWFWE6.mjs → chunk-6OLHNK7O.mjs} +46 -34
  44. package/dist/chunk-6OLHNK7O.mjs.map +1 -0
  45. package/dist/{chunk-QPIWG4ZF.mjs → chunk-7LZUXESV.mjs} +63 -61
  46. package/dist/chunk-7LZUXESV.mjs.map +1 -0
  47. package/dist/{chunk-S2HFYJVI.mjs → chunk-AIBJWPRA.mjs} +13 -13
  48. package/dist/chunk-AIBJWPRA.mjs.map +1 -0
  49. package/dist/{chunk-Q2HZVVOI.mjs → chunk-K5HCHHCJ.mjs} +16 -16
  50. package/dist/chunk-K5HCHHCJ.mjs.map +1 -0
  51. package/dist/{chunk-HZECQUHV.mjs → chunk-Q33EMTO2.mjs} +40 -40
  52. package/dist/{chunk-HZECQUHV.mjs.map → chunk-Q33EMTO2.mjs.map} +1 -1
  53. package/dist/{chunk-R76HPAN4.mjs → chunk-TR4X4EEG.mjs} +7 -7
  54. package/dist/{chunk-R76HPAN4.mjs.map → chunk-TR4X4EEG.mjs.map} +1 -1
  55. package/dist/{chunk-7SWSKLSA.mjs → chunk-V6YCG642.mjs} +18 -18
  56. package/dist/chunk-V6YCG642.mjs.map +1 -0
  57. package/dist/{chunk-S53LMDD7.mjs → chunk-VTBUO5SK.mjs} +15 -15
  58. package/dist/chunk-VTBUO5SK.mjs.map +1 -0
  59. package/dist/{chunk-JPUKYLBW.mjs → chunk-WDQYM4FP.mjs} +5 -5
  60. package/dist/chunk-WDQYM4FP.mjs.map +1 -0
  61. package/dist/{chunk-OLOU5HFC.mjs → chunk-WERCEZNJ.mjs} +168 -166
  62. package/dist/chunk-WERCEZNJ.mjs.map +1 -0
  63. package/dist/index.d.mts +4 -4
  64. package/dist/index.d.ts +4 -4
  65. package/dist/index.js +356 -343
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +13 -13
  68. package/dist/multi-autocomplete.d.mts +51 -51
  69. package/dist/multi-autocomplete.d.ts +51 -51
  70. package/dist/multi-autocomplete.js +326 -313
  71. package/dist/multi-autocomplete.js.map +1 -1
  72. package/dist/multi-autocomplete.mjs +12 -12
  73. package/dist/use-autocomplete-list.d.mts +1 -1
  74. package/dist/use-autocomplete-list.d.ts +1 -1
  75. package/dist/use-autocomplete-list.js +7 -7
  76. package/dist/use-autocomplete-list.js.map +1 -1
  77. package/dist/use-autocomplete-list.mjs +2 -2
  78. package/dist/use-autocomplete-option-group.js +7 -7
  79. package/dist/use-autocomplete-option-group.js.map +1 -1
  80. package/dist/use-autocomplete-option-group.mjs +2 -2
  81. package/dist/use-autocomplete-option.d.mts +12 -12
  82. package/dist/use-autocomplete-option.d.ts +12 -12
  83. package/dist/use-autocomplete-option.js +43 -34
  84. package/dist/use-autocomplete-option.js.map +1 -1
  85. package/dist/use-autocomplete-option.mjs +2 -2
  86. package/dist/use-autocomplete.d.mts +86 -86
  87. package/dist/use-autocomplete.d.ts +86 -86
  88. package/dist/use-autocomplete.js +225 -214
  89. package/dist/use-autocomplete.js.map +1 -1
  90. package/dist/use-autocomplete.mjs +7 -7
  91. package/package.json +13 -13
  92. package/dist/chunk-5GKGL6BL.mjs.map +0 -1
  93. package/dist/chunk-5LPWFWE6.mjs.map +0 -1
  94. package/dist/chunk-7SWSKLSA.mjs.map +0 -1
  95. package/dist/chunk-JPUKYLBW.mjs.map +0 -1
  96. package/dist/chunk-OLOU5HFC.mjs.map +0 -1
  97. package/dist/chunk-Q2HZVVOI.mjs.map +0 -1
  98. package/dist/chunk-QPIWG4ZF.mjs.map +0 -1
  99. package/dist/chunk-S2HFYJVI.mjs.map +0 -1
  100. package/dist/chunk-S53LMDD7.mjs.map +0 -1
@@ -34,9 +34,9 @@ var import_use_descendant = require("@yamada-ui/use-descendant");
34
34
  var import_utils = require("@yamada-ui/utils");
35
35
  var {
36
36
  DescendantsContextProvider: AutocompleteDescendantsContextProvider,
37
- useDescendantsContext: useAutocompleteDescendantsContext,
37
+ useDescendant: useAutocompleteDescendant,
38
38
  useDescendants: useAutocompleteDescendants,
39
- useDescendant: useAutocompleteDescendant
39
+ useDescendantsContext: useAutocompleteDescendantsContext
40
40
  } = (0, import_use_descendant.createDescendant)();
41
41
  var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
42
42
  name: "AutocompleteContext",
@@ -58,27 +58,27 @@ var AutocompleteIcon = (0, import_core.forwardRef)(
58
58
  ({ className, children, __css, ...rest }, ref) => {
59
59
  const { styles } = useAutocompleteContext();
60
60
  const css = {
61
- position: "absolute",
62
- top: "50%",
63
- transform: "translateY(-50%)",
64
- display: "inline-flex",
65
61
  alignItems: "center",
62
+ cursor: "pointer",
63
+ display: "inline-flex",
66
64
  justifyContent: "center",
67
65
  pointerEvents: "none",
68
- cursor: "pointer",
66
+ position: "absolute",
67
+ top: "50%",
68
+ transform: "translateY(-50%)",
69
69
  ...styles.icon,
70
70
  ...__css
71
71
  };
72
72
  const validChildren = (0, import_utils2.getValidChildren)(children);
73
73
  const cloneChildren = validChildren.map(
74
74
  (child) => (0, import_react.cloneElement)(child, {
75
- focusable: false,
76
- "aria-hidden": true,
77
75
  style: {
78
- maxWidth: "1em",
76
+ color: "currentColor",
79
77
  maxHeight: "1em",
80
- color: "currentColor"
81
- }
78
+ maxWidth: "1em"
79
+ },
80
+ "aria-hidden": true,
81
+ focusable: false
82
82
  })
83
83
  );
84
84
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -111,11 +111,11 @@ var AutocompleteClearIcon = ({
111
111
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
112
  AutocompleteIcon,
113
113
  {
114
- "aria-label": "Clear value",
115
114
  className: (0, import_utils2.cx)("ui-autocomplete__icon--clear", className),
115
+ "aria-label": "Clear value",
116
116
  __css: styles.clearIcon,
117
117
  ...rest,
118
- children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.CloseIcon, { w: "0.5em", h: "0.5em" })
118
+ children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.CloseIcon, { h: "0.5em", w: "0.5em" })
119
119
  }
120
120
  );
121
121
  };
@@ -124,11 +124,11 @@ AutocompleteClearIcon.__ui__ = "AutocompleteClearIcon";
124
124
  var AutocompleteItemIcon = (0, import_core.forwardRef)(({ className, ...rest }, ref) => {
125
125
  const { styles } = useAutocompleteContext();
126
126
  const css = {
127
- flexShrink: 0,
128
- display: "inline-flex",
129
- justifyContent: "center",
130
127
  alignItems: "center",
128
+ display: "inline-flex",
129
+ flexShrink: 0,
131
130
  fontSize: "0.85em",
131
+ justifyContent: "center",
132
132
  ...styles.itemIcon
133
133
  };
134
134
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -149,41 +149,50 @@ var import_utils3 = require("@yamada-ui/utils");
149
149
  var import_react2 = require("react");
150
150
  var isTargetOption = (target) => {
151
151
  var _a;
152
- return (0, import_utils3.isHTMLElement)(target) && !!((_a = target == null ? void 0 : target.getAttribute("role")) == null ? void 0 : _a.startsWith("option"));
152
+ return (0, import_utils3.isHTMLElement)(target) && !!((_a = target.getAttribute("role")) == null ? void 0 : _a.startsWith("option"));
153
153
  };
154
154
  var useAutocompleteOption = (props) => {
155
155
  var _a, _b;
156
156
  const {
157
- value,
157
+ closeOnSelect: generalCloseOnSelect,
158
+ focusedIndex,
159
+ inputRef,
158
160
  omitSelectedValues,
161
+ setFocusedIndex,
162
+ value,
163
+ optionProps,
159
164
  onChange,
160
165
  onChangeLabel,
161
- focusedIndex,
162
- setFocusedIndex,
163
166
  onClose,
164
- closeOnSelect: generalCloseOnSelect,
165
- optionProps,
166
- inputRef,
167
167
  onFocusNext
168
168
  } = useAutocompleteContext();
169
169
  const id = (0, import_react2.useId)();
170
170
  let {
171
+ children,
172
+ closeOnSelect: customCloseOnSelect,
171
173
  icon: customIcon,
172
174
  isDisabled,
173
175
  isFocusable,
174
- closeOnSelect: customCloseOnSelect,
175
- children,
176
176
  value: optionValue,
177
177
  ...computedProps
178
178
  } = { ...optionProps, ...props };
179
179
  const trulyDisabled = !!isDisabled && !isFocusable;
180
180
  const itemRef = (0, import_react2.useRef)(null);
181
- const { index, register, descendants } = useAutocompleteDescendant({
181
+ const { descendants, index, register } = useAutocompleteDescendant({
182
182
  disabled: trulyDisabled
183
183
  });
184
184
  const values = descendants.values();
185
185
  const frontValues = values.slice(0, index);
186
186
  const isMulti = (0, import_utils3.isArray)(value);
187
+ if ((0, import_utils3.isUndefined)(optionValue)) {
188
+ if ((0, import_utils3.isString)(children) || (0, import_utils3.isNumber)(children)) {
189
+ optionValue = children.toString();
190
+ } else {
191
+ console.warn(
192
+ `${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: Cannot infer the option value of complex children. Pass a \`value\` prop or use a plain string as children to <Option>.`
193
+ );
194
+ }
195
+ }
187
196
  const isDuplicated = !isMulti ? frontValues.some(({ node }) => node.dataset.value === (optionValue != null ? optionValue : "")) : false;
188
197
  const isSelected = !isDuplicated && (!isMulti ? (optionValue != null ? optionValue : "") === value : value.includes(optionValue != null ? optionValue : ""));
189
198
  const isTarget = "target" in ((_b = (_a = itemRef.current) == null ? void 0 : _a.dataset) != null ? _b : {});
@@ -228,27 +237,27 @@ var useAutocompleteOption = (props) => {
228
237
  border: "0px",
229
238
  clip: "rect(0px, 0px, 0px, 0px)",
230
239
  height: "1px",
231
- width: "1px",
232
240
  margin: "-1px",
233
- padding: "0px",
234
241
  overflow: "hidden",
242
+ padding: "0px",
243
+ position: "absolute",
235
244
  whiteSpace: "nowrap",
236
- position: "absolute"
245
+ width: "1px"
237
246
  };
238
247
  return {
239
- ref: (0, import_utils3.mergeRefs)(itemRef, ref, register),
240
248
  id,
249
+ ref: (0, import_utils3.mergeRefs)(itemRef, ref, register),
241
250
  role: "option",
242
251
  ...computedProps,
243
252
  ...props2,
244
- tabIndex: -1,
245
253
  style: !isTarget || omitSelectedValues && isSelected ? style : void 0,
246
- "data-target": (0, import_utils3.dataAttr)(true),
247
- "data-value": optionValue != null ? optionValue : "",
248
- "data-focus": (0, import_utils3.dataAttr)(isFocused),
249
- "data-disabled": (0, import_utils3.dataAttr)(isDisabled),
250
254
  "aria-checked": isSelected,
251
255
  "aria-disabled": (0, import_utils3.ariaAttr)(isDisabled),
256
+ "data-disabled": (0, import_utils3.dataAttr)(isDisabled),
257
+ "data-focus": (0, import_utils3.dataAttr)(isFocused),
258
+ "data-target": (0, import_utils3.dataAttr)(true),
259
+ "data-value": optionValue != null ? optionValue : "",
260
+ tabIndex: -1,
252
261
  onClick: (0, import_utils3.handlerAll)(computedProps.onClick, props2.onClick, onClick)
253
262
  };
254
263
  },
@@ -266,10 +275,10 @@ var useAutocompleteOption = (props) => {
266
275
  ]
267
276
  );
268
277
  return {
269
- isSelected,
270
- isFocused,
271
- customIcon,
272
278
  children,
279
+ customIcon,
280
+ isFocused,
281
+ isSelected,
273
282
  getOptionProps
274
283
  };
275
284
  };
@@ -281,19 +290,19 @@ var useAutocompleteCreate = () => {
281
290
  border: "0px",
282
291
  clip: "rect(0px, 0px, 0px, 0px)",
283
292
  height: "1px",
284
- width: "1px",
285
293
  margin: "-1px",
286
- padding: "0px",
287
294
  overflow: "hidden",
295
+ padding: "0px",
296
+ position: "absolute",
288
297
  whiteSpace: "nowrap",
289
- position: "absolute"
298
+ width: "1px"
290
299
  };
291
300
  return {
292
301
  ref,
293
302
  ...props,
294
- tabIndex: -1,
295
303
  style: isHit ? style : void 0,
296
304
  "data-focus": (0, import_utils3.dataAttr)(!isHit),
305
+ tabIndex: -1,
297
306
  onClick: (0, import_utils3.handlerAll)(props.onClick, onCreate)
298
307
  };
299
308
  },
@@ -302,25 +311,25 @@ var useAutocompleteCreate = () => {
302
311
  return { getCreateProps };
303
312
  };
304
313
  var useAutocompleteEmpty = () => {
305
- const { isHit, isEmpty } = useAutocompleteContext();
314
+ const { isEmpty, isHit } = useAutocompleteContext();
306
315
  const getEmptyProps = (0, import_react2.useCallback)(
307
316
  (props = {}, ref = null) => {
308
317
  const style = {
309
318
  border: "0px",
310
319
  clip: "rect(0px, 0px, 0px, 0px)",
311
320
  height: "1px",
312
- width: "1px",
313
321
  margin: "-1px",
314
- padding: "0px",
315
322
  overflow: "hidden",
323
+ padding: "0px",
324
+ position: "absolute",
316
325
  whiteSpace: "nowrap",
317
- position: "absolute"
326
+ width: "1px"
318
327
  };
319
328
  return {
320
329
  ref,
321
330
  ...props,
322
- tabIndex: -1,
323
- style: isHit && !isEmpty ? style : void 0
331
+ style: isHit && !isEmpty ? style : void 0,
332
+ tabIndex: -1
324
333
  };
325
334
  },
326
335
  [isHit, isEmpty]
@@ -331,21 +340,21 @@ var useAutocompleteEmpty = () => {
331
340
  // src/autocomplete-create.tsx
332
341
  var import_jsx_runtime2 = require("react/jsx-runtime");
333
342
  var AutocompleteCreate = (0, import_core2.forwardRef)(
334
- ({ className, icon, children, ...rest }, ref) => {
343
+ ({ className, children, icon, ...rest }, ref) => {
335
344
  const { inputValue, styles } = useAutocompleteContext();
336
345
  const { getCreateProps } = useAutocompleteCreate();
337
346
  children != null ? children : children = inputValue;
338
347
  const css = {
339
- textDecoration: "none",
348
+ alignItems: "center",
340
349
  color: "inherit",
341
- userSelect: "none",
342
350
  display: "flex",
343
- width: "100%",
344
- alignItems: "center",
345
- textAlign: "start",
346
351
  flex: "0 0 auto",
347
- outline: 0,
348
352
  gap: "0.75rem",
353
+ outline: 0,
354
+ textAlign: "start",
355
+ textDecoration: "none",
356
+ userSelect: "none",
357
+ width: "100%",
349
358
  ...styles.item
350
359
  };
351
360
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -356,7 +365,7 @@ var AutocompleteCreate = (0, import_core2.forwardRef)(
356
365
  ...getCreateProps(rest, ref),
357
366
  children: [
358
367
  icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AutocompletePlusIcon, {}) }) : null,
359
- icon ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { style: { pointerEvents: "none", flex: 1 }, lineClamp: 1, children: (0, import_utils4.runIfFunc)(children, inputValue) }) : (0, import_utils4.runIfFunc)(children, inputValue)
368
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { style: { flex: 1, pointerEvents: "none" }, lineClamp: 1, children: (0, import_utils4.runIfFunc)(children, inputValue) }) : (0, import_utils4.runIfFunc)(children, inputValue)
360
369
  ]
361
370
  }
362
371
  );
@@ -364,11 +373,11 @@ var AutocompleteCreate = (0, import_core2.forwardRef)(
364
373
  );
365
374
  AutocompleteCreate.displayName = "AutocompleteCreate";
366
375
  AutocompleteCreate.__ui__ = "AutocompleteCreate";
367
- var AutocompletePlusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 45.402 45.402", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
376
+ var AutocompletePlusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { height: "1em", viewBox: "0 0 45.402 45.402", width: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
368
377
  "path",
369
378
  {
370
- fill: "currentColor",
371
- 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"
379
+ 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",
380
+ fill: "currentColor"
372
381
  }
373
382
  ) });
374
383
  AutocompletePlusIcon.displayName = "AutocompletePlusIcon";
@@ -379,22 +388,22 @@ var import_core3 = require("@yamada-ui/core");
379
388
  var import_utils5 = require("@yamada-ui/utils");
380
389
  var import_jsx_runtime3 = require("react/jsx-runtime");
381
390
  var AutocompleteEmpty = (0, import_core3.forwardRef)(
382
- ({ className, icon, children, ...rest }, ref) => {
391
+ ({ className, children, icon, ...rest }, ref) => {
383
392
  const { emptyMessage, styles } = useAutocompleteContext();
384
393
  const { getEmptyProps } = useAutocompleteEmpty();
385
394
  children != null ? children : children = emptyMessage;
386
395
  const css = {
387
- textDecoration: "none",
396
+ alignItems: "center",
388
397
  color: "inherit",
389
- userSelect: "none",
390
398
  display: "flex",
391
- width: "100%",
392
- alignItems: "center",
393
- textAlign: "start",
394
399
  flex: "0 0 auto",
395
- outline: 0,
396
400
  gap: "0.75rem",
401
+ outline: 0,
397
402
  pointerEvents: "none",
403
+ textAlign: "start",
404
+ textDecoration: "none",
405
+ userSelect: "none",
406
+ width: "100%",
398
407
  ...styles.item
399
408
  };
400
409
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
@@ -405,7 +414,7 @@ var AutocompleteEmpty = (0, import_core3.forwardRef)(
405
414
  ...getEmptyProps(rest, ref),
406
415
  children: [
407
416
  icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteMinusIcon, {}) }) : null,
408
- icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { pointerEvents: "none", flex: 1 }, lineClamp: 1, children }) : children
417
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { flex: 1, pointerEvents: "none" }, lineClamp: 1, children }) : children
409
418
  ]
410
419
  }
411
420
  );
@@ -413,11 +422,11 @@ var AutocompleteEmpty = (0, import_core3.forwardRef)(
413
422
  );
414
423
  AutocompleteEmpty.displayName = "AutocompleteEmpty";
415
424
  AutocompleteEmpty.__ui__ = "AutocompleteEmpty";
416
- var AutocompleteMinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 448 512", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
425
+ var AutocompleteMinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { height: "1em", viewBox: "0 0 448 512", width: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
417
426
  "path",
418
427
  {
419
- fill: "currentColor",
420
- 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"
428
+ 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",
429
+ fill: "currentColor"
421
430
  }
422
431
  ) });
423
432
  AutocompleteMinusIcon.displayName = "AutocompleteMinusIcon";
@@ -473,20 +482,20 @@ var useAutocompleteList = () => {
473
482
  (props = {}, ref = null) => {
474
483
  var _a;
475
484
  return {
476
- as: "ul",
485
+ id: (_a = props.id) != null ? _a : uuid,
477
486
  ref: (0, import_utils6.mergeRefs)(listRef, ref),
487
+ as: "ul",
488
+ position: "relative",
478
489
  role: "listbox",
479
490
  tabIndex: -1,
480
- position: "relative",
481
- id: (_a = props.id) != null ? _a : uuid,
482
491
  ...props
483
492
  };
484
493
  },
485
494
  [listRef, uuid]
486
495
  );
487
496
  return {
488
- onAnimationComplete,
489
- getListProps
497
+ getListProps,
498
+ onAnimationComplete
490
499
  };
491
500
  };
492
501
 
@@ -495,21 +504,21 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
495
504
  var AutocompleteList = (0, import_core4.forwardRef)(
496
505
  ({
497
506
  className,
498
- w,
499
- width,
500
- minW,
501
- minWidth,
507
+ children,
508
+ footer,
509
+ header,
502
510
  maxW,
503
511
  maxWidth,
512
+ minW,
513
+ minWidth,
514
+ w,
515
+ width,
504
516
  contentProps,
505
- header,
506
- footer,
507
- children,
508
517
  ...rest
509
518
  }, ref) => {
510
519
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
511
520
  const { styles } = useAutocompleteContext();
512
- const { onAnimationComplete, getListProps } = useAutocompleteList();
521
+ const { getListProps, onAnimationComplete } = useAutocompleteList();
513
522
  width != null ? width : width = w;
514
523
  width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
515
524
  minWidth != null ? minWidth : minWidth = minW;
@@ -521,10 +530,10 @@ var AutocompleteList = (0, import_core4.forwardRef)(
521
530
  {
522
531
  as: "div",
523
532
  className: "ui-autocomplete__popover",
524
- width,
525
- minWidth,
526
533
  maxWidth,
527
- __css: { ...styles.content, width, minWidth, maxWidth },
534
+ minWidth,
535
+ width,
536
+ __css: { ...styles.content, maxWidth, minWidth, width },
528
537
  ...contentProps,
529
538
  onAnimationComplete: (0, import_utils7.handlerAll)(
530
539
  contentProps == null ? void 0 : contentProps.onAnimationComplete,
@@ -580,19 +589,19 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
580
589
  var AutocompleteOption = (0, import_core5.forwardRef)(
581
590
  ({ className, icon, ...rest }, ref) => {
582
591
  const { styles } = useAutocompleteContext();
583
- const { isSelected, customIcon, children, getOptionProps } = useAutocompleteOption(rest);
592
+ const { children, customIcon, isSelected, getOptionProps } = useAutocompleteOption(rest);
584
593
  icon != null ? icon : icon = customIcon;
585
594
  const css = {
586
- textDecoration: "none",
595
+ alignItems: "center",
587
596
  color: "inherit",
588
- userSelect: "none",
589
597
  display: "flex",
590
- width: "100%",
591
- alignItems: "center",
592
- textAlign: "start",
593
598
  flex: "0 0 auto",
594
- outline: 0,
595
599
  gap: "0.75rem",
600
+ outline: 0,
601
+ textAlign: "start",
602
+ textDecoration: "none",
603
+ userSelect: "none",
604
+ width: "100%",
596
605
  ...styles.item
597
606
  };
598
607
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
@@ -611,7 +620,7 @@ var AutocompleteOption = (0, import_core5.forwardRef)(
611
620
  );
612
621
  AutocompleteOption.displayName = "AutocompleteOption";
613
622
  AutocompleteOption.__ui__ = "AutocompleteOption";
614
- var AutocompleteCheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
623
+ var AutocompleteCheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { height: "1em", viewBox: "0 0 14 14", width: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
615
624
  "polygon",
616
625
  {
617
626
  fill: "currentColor",
@@ -633,7 +642,7 @@ var useAutocompleteOptionGroup = ({
633
642
  label,
634
643
  ...rest
635
644
  }) => {
636
- const { value, omitSelectedValues } = useAutocompleteContext();
645
+ const { omitSelectedValues, value } = useAutocompleteContext();
637
646
  const isMulti = (0, import_utils9.isArray)(value);
638
647
  const descendants = useAutocompleteDescendantsContext();
639
648
  const values = descendants.values();
@@ -645,7 +654,7 @@ var useAutocompleteOptionGroup = ({
645
654
  ) : [];
646
655
  const selectedIndexes = selectedValues.map(({ index }) => index);
647
656
  const childValues = values.filter(
648
- ({ node, index }) => {
657
+ ({ index, node }) => {
649
658
  var _a;
650
659
  return ((_a = node.parentElement) == null ? void 0 : _a.dataset.label) === label && !selectedIndexes.includes(index) && "target" in node.dataset;
651
660
  }
@@ -658,12 +667,12 @@ var useAutocompleteOptionGroup = ({
658
667
  border: "0px",
659
668
  clip: "rect(0px, 0px, 0px, 0px)",
660
669
  height: "1px",
661
- width: "1px",
662
670
  margin: "-1px",
663
- padding: "0px",
664
671
  overflow: "hidden",
672
+ padding: "0px",
673
+ position: "absolute",
665
674
  whiteSpace: "nowrap",
666
- position: "absolute"
675
+ width: "1px"
667
676
  };
668
677
  return {
669
678
  ref,
@@ -698,12 +707,12 @@ var import_jsx_runtime6 = require("react/jsx-runtime");
698
707
  var AutocompleteOptionGroup = (0, import_core7.forwardRef)(
699
708
  ({
700
709
  className,
710
+ children,
701
711
  color,
702
712
  h,
703
713
  height,
704
714
  minH,
705
715
  minHeight,
706
- children,
707
716
  labelProps,
708
717
  ...rest
709
718
  }, ref) => {
@@ -719,15 +728,15 @@ var AutocompleteOptionGroup = (0, import_core7.forwardRef)(
719
728
  "ui-autocomplete__item--group",
720
729
  className
721
730
  ),
722
- __css: { w: "100%", h: "fit-content", color },
731
+ __css: { color, h: "fit-content", w: "100%" },
723
732
  ...getContainerProps(),
724
733
  children: [
725
734
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
726
735
  import_core7.ui.span,
727
736
  {
728
737
  className: "ui-autocomplete__item__group-label",
729
- __css: styles.groupLabel,
730
738
  lineClamp: 1,
739
+ __css: styles.groupLabel,
731
740
  ...labelProps,
732
741
  children: label
733
742
  }
@@ -752,64 +761,79 @@ AutocompleteOptionGroup.__ui__ = "AutocompleteOptionGroup";
752
761
  // src/use-autocomplete.tsx
753
762
  var import_jsx_runtime7 = require("react/jsx-runtime");
754
763
  var kanaMap = {
755
- \uFF76\uFF9E: "\u30AC",
756
- \uFF77\uFF9E: "\u30AE",
757
- \uFF78\uFF9E: "\u30B0",
758
- \uFF79\uFF9E: "\u30B2",
759
- \uFF7A\uFF9E: "\u30B4",
760
- \uFF7B\uFF9E: "\u30B6",
761
- \uFF7C\uFF9E: "\u30B8",
762
- \uFF7D\uFF9E: "\u30BA",
763
- \uFF7E\uFF9E: "\u30BC",
764
- \uFF7F\uFF9E: "\u30BE",
765
- \uFF80\uFF9E: "\u30C0",
766
- \uFF81\uFF9E: "\u30C2",
767
- \uFF82\uFF9E: "\u30C5",
768
- \uFF83\uFF9E: "\u30C7",
769
- \uFF84\uFF9E: "\u30C9",
770
- \uFF8A\uFF9E: "\u30D0",
771
- \uFF8B\uFF9E: "\u30D3",
772
- \uFF8C\uFF9E: "\u30D6",
773
- \uFF8D\uFF9E: "\u30D9",
774
- \uFF8E\uFF9E: "\u30DC",
775
- \uFF8A\uFF9F: "\u30D1",
776
- \uFF8B\uFF9F: "\u30D4",
777
- \uFF8C\uFF9F: "\u30D7",
778
- \uFF8D\uFF9F: "\u30DA",
779
- \uFF8E\uFF9F: "\u30DD",
780
- \uFF73\uFF9E: "\u30F4",
781
- \uFF9C\uFF9E: "\u30F7",
764
+ "\uFF61": "\u3002",
765
+ "\uFF62": "\u300C",
766
+ "\uFF63": "\u300D",
767
+ "\uFF64": "\u3001",
768
+ "\uFF65": "\u30FB",
769
+ \uFF66: "\u30F2",
782
770
  \uFF66\uFF9E: "\u30FA",
771
+ \uFF67: "\u30A1",
772
+ \uFF68: "\u30A3",
773
+ \uFF69: "\u30A5",
774
+ \uFF6A: "\u30A7",
775
+ \uFF6B: "\u30A9",
776
+ \uFF6C: "\u30E3",
777
+ \uFF6D: "\u30E5",
778
+ \uFF6E: "\u30E7",
779
+ \uFF6F: "\u30C3",
780
+ \uFF70: "\u30FC",
783
781
  \uFF71: "\u30A2",
784
782
  \uFF72: "\u30A4",
785
783
  \uFF73: "\u30A6",
784
+ \uFF73\uFF9E: "\u30F4",
786
785
  \uFF74: "\u30A8",
787
786
  \uFF75: "\u30AA",
788
787
  \uFF76: "\u30AB",
788
+ \uFF76\uFF9E: "\u30AC",
789
789
  \uFF77: "\u30AD",
790
+ \uFF77\uFF9E: "\u30AE",
790
791
  \uFF78: "\u30AF",
792
+ \uFF78\uFF9E: "\u30B0",
791
793
  \uFF79: "\u30B1",
794
+ \uFF79\uFF9E: "\u30B2",
792
795
  \uFF7A: "\u30B3",
796
+ \uFF7A\uFF9E: "\u30B4",
793
797
  \uFF7B: "\u30B5",
798
+ \uFF7B\uFF9E: "\u30B6",
794
799
  \uFF7C: "\u30B7",
800
+ \uFF7C\uFF9E: "\u30B8",
795
801
  \uFF7D: "\u30B9",
802
+ \uFF7D\uFF9E: "\u30BA",
796
803
  \uFF7E: "\u30BB",
804
+ \uFF7E\uFF9E: "\u30BC",
797
805
  \uFF7F: "\u30BD",
806
+ \uFF7F\uFF9E: "\u30BE",
798
807
  \uFF80: "\u30BF",
808
+ \uFF80\uFF9E: "\u30C0",
799
809
  \uFF81: "\u30C1",
810
+ \uFF81\uFF9E: "\u30C2",
800
811
  \uFF82: "\u30C4",
812
+ \uFF82\uFF9E: "\u30C5",
801
813
  \uFF83: "\u30C6",
814
+ \uFF83\uFF9E: "\u30C7",
802
815
  \uFF84: "\u30C8",
816
+ \uFF84\uFF9E: "\u30C9",
803
817
  \uFF85: "\u30CA",
804
818
  \uFF86: "\u30CB",
805
819
  \uFF87: "\u30CC",
806
820
  \uFF88: "\u30CD",
807
821
  \uFF89: "\u30CE",
808
822
  \uFF8A: "\u30CF",
823
+ \uFF8A\uFF9E: "\u30D0",
824
+ \uFF8A\uFF9F: "\u30D1",
809
825
  \uFF8B: "\u30D2",
826
+ \uFF8B\uFF9E: "\u30D3",
827
+ \uFF8B\uFF9F: "\u30D4",
810
828
  \uFF8C: "\u30D5",
829
+ \uFF8C\uFF9E: "\u30D6",
830
+ \uFF8C\uFF9F: "\u30D7",
811
831
  \uFF8D: "\u30D8",
832
+ \uFF8D\uFF9E: "\u30D9",
833
+ \uFF8D\uFF9F: "\u30DA",
812
834
  \uFF8E: "\u30DB",
835
+ \uFF8E\uFF9E: "\u30DC",
836
+ \uFF8E\uFF9F: "\u30DD",
813
837
  \uFF8F: "\u30DE",
814
838
  \uFF90: "\u30DF",
815
839
  \uFF91: "\u30E0",
@@ -824,23 +848,8 @@ var kanaMap = {
824
848
  \uFF9A: "\u30EC",
825
849
  \uFF9B: "\u30ED",
826
850
  \uFF9C: "\u30EF",
827
- \uFF66: "\u30F2",
828
- \uFF9D: "\u30F3",
829
- \uFF67: "\u30A1",
830
- \uFF68: "\u30A3",
831
- \uFF69: "\u30A5",
832
- \uFF6A: "\u30A7",
833
- \uFF6B: "\u30A9",
834
- \uFF6F: "\u30C3",
835
- \uFF6C: "\u30E3",
836
- \uFF6D: "\u30E5",
837
- \uFF6E: "\u30E7",
838
- "\uFF61": "\u3002",
839
- "\uFF64": "\u3001",
840
- \uFF70: "\u30FC",
841
- "\uFF62": "\u300C",
842
- "\uFF63": "\u300D",
843
- "\uFF65": "\u30FB"
851
+ \uFF9C\uFF9E: "\u30F7",
852
+ \uFF9D: "\u30F3"
844
853
  };
845
854
  var defaultFormat = (value) => {
846
855
  value = value.replace(
@@ -868,46 +877,46 @@ var flattenItems = (items) => {
868
877
  };
869
878
  var useAutocomplete = (props) => {
870
879
  const {
871
- value: valueProp,
872
- defaultValue,
873
- onChange: onChangeProp,
874
- onCreate: onCreateProp,
875
- onSearch: onSearchProp,
876
- closeOnSelect = true,
877
- omitSelectedValues = false,
878
- maxSelectValues,
879
880
  allowCreate = false,
880
881
  allowFree = false,
881
- insertPositionItem = "first",
882
- emptyMessage = "No results found",
883
- format = defaultFormat,
884
- optionProps,
885
- placeholder,
886
- onKeyDown: onKeyDownProp,
887
- isOpen: isOpenProp,
888
- defaultIsOpen,
889
- onOpen: onOpenProp,
890
- onClose: onCloseProp,
882
+ animation,
883
+ boundary,
884
+ children,
885
+ closeDelay,
891
886
  closeOnBlur = true,
892
887
  closeOnEsc = true,
893
- openDelay,
894
- closeDelay,
888
+ closeOnSelect = true,
889
+ defaultIsOpen,
890
+ defaultValue,
891
+ duration = 0.2,
892
+ emptyMessage = "No results found",
893
+ eventListeners,
894
+ flip,
895
+ format = defaultFormat,
896
+ gutter,
897
+ insertPositionItem = "first",
895
898
  isLazy,
899
+ isOpen: isOpenProp,
900
+ items,
896
901
  lazyBehavior,
897
- animation,
898
- duration = 0.2,
902
+ matchWidth = true,
903
+ maxSelectValues,
904
+ modifiers,
899
905
  offset,
900
- gutter,
906
+ omitSelectedValues = false,
907
+ openDelay,
908
+ placeholder,
909
+ placement = "bottom-start",
901
910
  preventOverflow,
902
- flip,
903
- matchWidth = true,
904
- boundary,
905
- eventListeners,
906
911
  strategy,
907
- placement = "bottom-start",
908
- modifiers,
909
- items,
910
- children,
912
+ value: valueProp,
913
+ optionProps,
914
+ onChange: onChangeProp,
915
+ onClose: onCloseProp,
916
+ onCreate: onCreateProp,
917
+ onKeyDown: onKeyDownProp,
918
+ onOpen: onOpenProp,
919
+ onSearch: onSearchProp,
911
920
  ...rest
912
921
  } = (0, import_form_control.useFormControlProps)(props);
913
922
  const {
@@ -926,8 +935,8 @@ var useAutocomplete = (props) => {
926
935
  const prevValue = (0, import_react5.useRef)(void 0);
927
936
  const [resolvedItems, setResolvedItems] = (0, import_react5.useState)(items ? JSON.parse(JSON.stringify(items)) : void 0);
928
937
  const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
929
- value: valueProp,
930
938
  defaultValue,
939
+ value: valueProp,
931
940
  onChange: onChangeProp
932
941
  });
933
942
  const [label, setLabel] = (0, import_react5.useState)(void 0);
@@ -937,13 +946,13 @@ var useAutocomplete = (props) => {
937
946
  const [isHit, setIsHit] = (0, import_react5.useState)(true);
938
947
  const {
939
948
  isOpen,
940
- onOpen: onInternalOpen,
941
- onClose
949
+ onClose,
950
+ onOpen: onInternalOpen
942
951
  } = (0, import_use_disclosure.useDisclosure)({
943
- isOpen: isOpenProp,
944
952
  defaultIsOpen,
945
- onOpen: onOpenProp,
946
- onClose: onCloseProp
953
+ isOpen: isOpenProp,
954
+ onClose: onCloseProp,
955
+ onOpen: onOpenProp
947
956
  });
948
957
  const isFocused = focusedIndex > -1;
949
958
  const isCreate = focusedIndex === -2 && allowCreate;
@@ -969,7 +978,7 @@ var useAutocomplete = (props) => {
969
978
  );
970
979
  const selectedIndexes = selectedValues.map(({ index }) => index);
971
980
  const enabledValues = descendants.enabledValues(
972
- ({ node, index }) => "target" in node.dataset && !selectedIndexes.includes(index)
981
+ ({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
973
982
  );
974
983
  const validChildren = (0, import_utils11.getValidChildren)(children);
975
984
  const computedChildren = (0, import_react5.useMemo)(
@@ -978,7 +987,7 @@ var useAutocomplete = (props) => {
978
987
  const { label: label2, value: value2, ...props2 } = item;
979
988
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AutocompleteOption, { value: value2, ...props2, children: label2 }, i);
980
989
  } else if ("items" in item) {
981
- const { label: label2, items: items2 = [], ...props2 } = item;
990
+ const { items: items2 = [], label: label2, ...props2 } = item;
982
991
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AutocompleteOptionGroup, { label: label2, ...props2, children: items2.map(({ label: label3, value: value2, ...props3 }, i2) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AutocompleteOption, { value: value2, ...props3, children: label3 }, i2)) }, i);
983
992
  }
984
993
  }),
@@ -993,6 +1002,7 @@ var useAutocomplete = (props) => {
993
1002
  }, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
994
1003
  const onFocusFirst = (0, import_react5.useCallback)(() => {
995
1004
  const id2 = setTimeout(() => {
1005
+ var _a;
996
1006
  if (isEmpty || isAllSelected) return;
997
1007
  const first = descendants.enabledFirstValue(
998
1008
  ({ node }) => "target" in node.dataset
@@ -1003,7 +1013,7 @@ var useAutocomplete = (props) => {
1003
1013
  } else {
1004
1014
  if (selectedIndexes.includes(first.index)) {
1005
1015
  const enabledFirst = enabledValues[0];
1006
- setFocusedIndex(enabledFirst.index);
1016
+ setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
1007
1017
  } else {
1008
1018
  setFocusedIndex(first.index);
1009
1019
  }
@@ -1021,6 +1031,7 @@ var useAutocomplete = (props) => {
1021
1031
  ]);
1022
1032
  const onFocusLast = (0, import_react5.useCallback)(() => {
1023
1033
  const id2 = setTimeout(() => {
1034
+ var _a;
1024
1035
  if (isEmpty || isAllSelected) return;
1025
1036
  const last = descendants.enabledLastValue(
1026
1037
  ({ node }) => "target" in node.dataset
@@ -1031,7 +1042,7 @@ var useAutocomplete = (props) => {
1031
1042
  } else {
1032
1043
  if (selectedIndexes.includes(last.index)) {
1033
1044
  const enabledLast = enabledValues.reverse()[0];
1034
- setFocusedIndex(enabledLast.index);
1045
+ setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
1035
1046
  } else {
1036
1047
  setFocusedIndex(last.index);
1037
1048
  }
@@ -1063,7 +1074,7 @@ var useAutocomplete = (props) => {
1063
1074
  const onFocusNext = (0, import_react5.useCallback)(
1064
1075
  (index = focusedIndex) => {
1065
1076
  const id2 = setTimeout(() => {
1066
- var _a;
1077
+ var _a, _b;
1067
1078
  const next = descendants.enabledNextValue(
1068
1079
  index,
1069
1080
  ({ node }) => "target" in node.dataset
@@ -1074,7 +1085,7 @@ var useAutocomplete = (props) => {
1074
1085
  } else {
1075
1086
  if (selectedIndexes.includes(next.index)) {
1076
1087
  const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
1077
- setFocusedIndex(enabledNext.index);
1088
+ setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
1078
1089
  } else {
1079
1090
  setFocusedIndex(next.index);
1080
1091
  }
@@ -1094,7 +1105,7 @@ var useAutocomplete = (props) => {
1094
1105
  const onFocusPrev = (0, import_react5.useCallback)(
1095
1106
  (index = focusedIndex) => {
1096
1107
  const id2 = setTimeout(() => {
1097
- var _a;
1108
+ var _a, _b;
1098
1109
  const prev = descendants.enabledPrevValue(
1099
1110
  index,
1100
1111
  ({ node }) => "target" in node.dataset
@@ -1105,7 +1116,7 @@ var useAutocomplete = (props) => {
1105
1116
  } else {
1106
1117
  if (selectedIndexes.includes(prev.index)) {
1107
1118
  const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
1108
- setFocusedIndex(enabledPrev.index);
1119
+ setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
1109
1120
  } else {
1110
1121
  setFocusedIndex(prev.index);
1111
1122
  }
@@ -1129,7 +1140,7 @@ var useAutocomplete = (props) => {
1129
1140
  const values = descendants.values();
1130
1141
  let isHit2 = false;
1131
1142
  let isFocused2 = false;
1132
- values.forEach(({ node, index }) => {
1143
+ values.forEach(({ index, node }) => {
1133
1144
  var _a;
1134
1145
  if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
1135
1146
  isHit2 = true;
@@ -1187,7 +1198,7 @@ var useAutocomplete = (props) => {
1187
1198
  return selectedValues2[0];
1188
1199
  } else {
1189
1200
  selectedValues2.forEach((selectedValue) => {
1190
- const isSelected = (0, import_utils11.isArray)(prev) && prev.includes(selectedValue != null ? selectedValue : "");
1201
+ const isSelected = (0, import_utils11.isArray)(prev) && prev.includes(selectedValue);
1191
1202
  if (!isSelected) {
1192
1203
  prev = [...(0, import_utils11.isArray)(prev) ? prev : [], selectedValue];
1193
1204
  } else if (runOmit) {
@@ -1292,7 +1303,7 @@ var useAutocomplete = (props) => {
1292
1303
  ({ label: label2 }) => label2 === firstInsertPositionItem
1293
1304
  );
1294
1305
  const targetItem = newItems[i];
1295
- if (i !== -1 && "items" in targetItem) {
1306
+ if (i !== -1 && targetItem && "items" in targetItem) {
1296
1307
  if (secondInsertPositionItem === "first") {
1297
1308
  targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
1298
1309
  } else {
@@ -1376,15 +1387,15 @@ var useAutocomplete = (props) => {
1376
1387
  const actions = {
1377
1388
  ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
1378
1389
  ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusLastOrSelected) : void 0,
1379
- Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
1390
+ Backspace: !isEmptyValue && enabledDelete ? onDelete : void 0,
1391
+ End: isOpen ? onFocusLast : void 0,
1380
1392
  Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
1381
1393
  if (inputValue) onChange(inputValue);
1382
1394
  setFocusedIndex(0);
1383
1395
  } : void 0,
1384
- Home: isOpen ? onFocusFirst : void 0,
1385
- End: isOpen ? onFocusLast : void 0,
1386
1396
  Escape: closeOnEsc ? onClose : void 0,
1387
- Backspace: !isEmptyValue && enabledDelete ? onDelete : void 0
1397
+ Home: isOpen ? onFocusFirst : void 0,
1398
+ Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : void 0
1388
1399
  };
1389
1400
  const action = actions[ev.key];
1390
1401
  if (!action) return;
@@ -1439,7 +1450,7 @@ var useAutocomplete = (props) => {
1439
1450
  (0, import_react5.useEffect)(() => {
1440
1451
  var _a;
1441
1452
  if (isMulti) {
1442
- if (JSON.stringify((_a = prevValue.current) != null ? _a : []) === JSON.stringify(value != null ? value : []))
1453
+ if (JSON.stringify((_a = prevValue.current) != null ? _a : []) === JSON.stringify(value))
1443
1454
  return;
1444
1455
  const label2 = getSelectedValues(value);
1445
1456
  setLabel(label2);
@@ -1465,34 +1476,34 @@ var useAutocomplete = (props) => {
1465
1476
  });
1466
1477
  (0, import_use_outside_click.useOutsideClick)({
1467
1478
  ref: containerRef,
1468
- handler: onClose,
1469
- enabled: isOpen && (closeOnBlur || !isHit)
1479
+ enabled: isOpen && (closeOnBlur || !isHit),
1480
+ handler: onClose
1470
1481
  });
1471
1482
  const getPopoverProps = (0, import_react5.useCallback)(
1472
1483
  (props2) => ({
1473
- closeOnBlur,
1474
- openDelay,
1484
+ animation,
1485
+ boundary,
1475
1486
  closeDelay,
1487
+ closeOnBlur,
1488
+ duration,
1489
+ eventListeners,
1490
+ flip,
1491
+ gutter,
1476
1492
  isLazy,
1477
1493
  lazyBehavior,
1478
- animation,
1479
- duration,
1494
+ matchWidth,
1495
+ modifiers,
1480
1496
  offset,
1481
- gutter,
1497
+ openDelay,
1498
+ placement,
1482
1499
  preventOverflow,
1483
- flip,
1484
- matchWidth,
1485
- boundary,
1486
- eventListeners,
1487
1500
  strategy,
1488
- placement,
1489
- modifiers,
1490
1501
  ...props2,
1491
- trigger: "never",
1492
1502
  closeOnButton: false,
1493
1503
  isOpen,
1494
- onOpen,
1495
- onClose
1504
+ trigger: "never",
1505
+ onClose,
1506
+ onOpen
1496
1507
  }),
1497
1508
  [
1498
1509
  closeOnBlur,
@@ -1523,8 +1534,8 @@ var useAutocomplete = (props) => {
1523
1534
  ...containerProps,
1524
1535
  ...props2,
1525
1536
  ...formControlProps,
1526
- onClick: (0, import_utils11.handlerAll)(props2.onClick, rest.onClick, onClick),
1527
- onBlur: (0, import_utils11.handlerAll)(props2.onBlur, rest.onBlur, onBlur)
1537
+ onBlur: (0, import_utils11.handlerAll)(props2.onBlur, rest.onBlur, onBlur),
1538
+ onClick: (0, import_utils11.handlerAll)(props2.onClick, rest.onClick, onClick)
1528
1539
  }),
1529
1540
  [containerProps, formControlProps, onBlur, onClick, rest]
1530
1541
  );
@@ -1534,9 +1545,9 @@ var useAutocomplete = (props) => {
1534
1545
  tabIndex: -1,
1535
1546
  ...props2,
1536
1547
  ...formControlProps,
1537
- placeholder,
1538
- "data-active": (0, import_utils11.dataAttr)(isOpen),
1539
1548
  "aria-expanded": (0, import_utils11.dataAttr)(isOpen),
1549
+ "data-active": (0, import_utils11.dataAttr)(isOpen),
1550
+ placeholder,
1540
1551
  onFocus: (0, import_utils11.handlerAll)(props2.onFocus, onFocusProp, onFocus),
1541
1552
  onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
1542
1553
  }),
@@ -1552,61 +1563,61 @@ var useAutocomplete = (props) => {
1552
1563
  );
1553
1564
  return {
1554
1565
  id,
1555
- descendants,
1556
- value,
1557
- label,
1558
- inputValue,
1559
- isHit,
1560
- isEmpty,
1561
- computedChildren,
1562
- focusedIndex,
1563
- omitSelectedValues,
1564
- closeOnSelect,
1565
1566
  allowCreate,
1566
1567
  allowFree,
1568
+ closeOnSelect,
1569
+ computedChildren,
1570
+ descendants,
1567
1571
  emptyMessage,
1568
- isOpen,
1572
+ focusedIndex,
1573
+ inputRef,
1574
+ inputValue,
1569
1575
  isAllSelected,
1576
+ isEmpty,
1577
+ isHit,
1578
+ isOpen,
1579
+ label,
1570
1580
  listRef,
1571
- inputRef,
1572
- optionProps,
1573
- formControlProps,
1581
+ omitSelectedValues,
1582
+ pickOptions,
1583
+ rebirthOptions,
1574
1584
  setFocusedIndex,
1575
- onChangeLabel,
1585
+ value,
1586
+ formControlProps,
1587
+ getContainerProps,
1588
+ getFieldProps,
1589
+ getPopoverProps,
1590
+ inputProps,
1591
+ optionProps,
1576
1592
  onChange,
1577
- onSearch,
1578
- onCreate,
1593
+ onChangeLabel,
1579
1594
  onClear,
1580
- onCompositionStart,
1581
- onCompositionEnd,
1582
- pickOptions,
1583
- rebirthOptions,
1584
- onOpen,
1585
1595
  onClose,
1596
+ onCompositionEnd,
1597
+ onCompositionStart,
1598
+ onCreate,
1586
1599
  onFocusFirst,
1587
1600
  onFocusLast,
1588
- onFocusSelected,
1589
1601
  onFocusNext,
1590
1602
  onFocusPrev,
1591
- getPopoverProps,
1592
- getContainerProps,
1593
- getFieldProps,
1594
- inputProps
1603
+ onFocusSelected,
1604
+ onOpen,
1605
+ onSearch
1595
1606
  };
1596
1607
  };
1597
1608
  var useAutocompleteInput = () => {
1598
1609
  const {
1599
1610
  id,
1611
+ focusedIndex,
1600
1612
  inputRef,
1601
- onSearch,
1602
- onCompositionStart,
1603
- onCompositionEnd,
1604
1613
  isAllSelected,
1614
+ isOpen,
1615
+ listRef,
1605
1616
  formControlProps,
1606
1617
  inputProps,
1607
- isOpen,
1608
- focusedIndex,
1609
- listRef
1618
+ onCompositionEnd,
1619
+ onCompositionStart,
1620
+ onSearch
1610
1621
  } = useAutocompleteContext();
1611
1622
  const { value } = useAutocompleteDescendantsContext();
1612
1623
  (0, import_utils11.useUpdateEffect)(() => {
@@ -1618,14 +1629,14 @@ var useAutocompleteInput = () => {
1618
1629
  return {
1619
1630
  ref: (0, import_utils11.mergeRefs)(inputRef, ref),
1620
1631
  ...formControlProps,
1621
- role: "combobox",
1622
- "aria-haspopup": "listbox",
1623
- "aria-autocomplete": "list",
1624
- "aria-expanded": isOpen,
1625
1632
  "aria-activedescendant": (_a = value(focusedIndex)) == null ? void 0 : _a.node.id,
1633
+ "aria-autocomplete": "list",
1626
1634
  "aria-controls": (_b = listRef.current) == null ? void 0 : _b.id,
1635
+ "aria-expanded": isOpen,
1636
+ "aria-haspopup": "listbox",
1627
1637
  autoCapitalize: "none",
1628
1638
  autoComplete: "off",
1639
+ role: "combobox",
1629
1640
  spellCheck: "false",
1630
1641
  ...inputProps,
1631
1642
  ...props,
@@ -1634,15 +1645,15 @@ var useAutocompleteInput = () => {
1634
1645
  pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
1635
1646
  tabIndex: isAllSelected ? -1 : 0,
1636
1647
  onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
1637
- onCompositionStart: (0, import_utils11.handlerAll)(
1638
- props.onCompositionStart,
1639
- inputProps.onCompositionStart,
1640
- onCompositionStart
1641
- ),
1642
1648
  onCompositionEnd: (0, import_utils11.handlerAll)(
1643
1649
  props.onCompositionEnd,
1644
1650
  inputProps.onCompositionEnd,
1645
1651
  onCompositionEnd
1652
+ ),
1653
+ onCompositionStart: (0, import_utils11.handlerAll)(
1654
+ props.onCompositionStart,
1655
+ inputProps.onCompositionStart,
1656
+ onCompositionStart
1646
1657
  )
1647
1658
  };
1648
1659
  },
@@ -1673,46 +1684,46 @@ var Autocomplete = (0, import_core9.forwardRef)(
1673
1684
  const [styles, mergedProps] = (0, import_core9.useComponentMultiStyle)("Autocomplete", props);
1674
1685
  let {
1675
1686
  className,
1676
- defaultValue = "",
1687
+ children,
1677
1688
  color,
1689
+ defaultValue = "",
1690
+ footer,
1678
1691
  h,
1692
+ header,
1679
1693
  height,
1680
1694
  minH,
1681
1695
  minHeight,
1682
1696
  containerProps,
1683
1697
  contentProps,
1684
- listProps,
1698
+ createProps,
1699
+ emptyProps,
1685
1700
  fieldProps,
1686
- inputProps,
1687
1701
  iconProps,
1702
+ inputProps,
1703
+ listProps,
1688
1704
  portalProps = { isDisabled: true },
1689
- createProps,
1690
- emptyProps,
1691
- header,
1692
- footer,
1693
- children,
1694
1705
  ...computedProps
1695
1706
  } = (0, import_core9.omitThemeProps)(mergedProps);
1696
1707
  const {
1697
- value,
1698
- onClose,
1708
+ allowCreate,
1709
+ computedChildren,
1699
1710
  descendants,
1711
+ inputValue,
1712
+ isEmpty,
1713
+ value,
1700
1714
  formControlProps,
1701
- getPopoverProps,
1702
1715
  getContainerProps,
1703
1716
  getFieldProps,
1704
- allowCreate,
1705
- isEmpty,
1706
- inputValue,
1707
- computedChildren,
1717
+ getPopoverProps,
1718
+ onClose,
1708
1719
  ...rest
1709
- } = useAutocomplete({ ...computedProps, defaultValue, children });
1720
+ } = useAutocomplete({ ...computedProps, children, defaultValue });
1710
1721
  h != null ? h : h = height;
1711
1722
  minH != null ? minH : minH = minHeight;
1712
1723
  const css = {
1713
- w: "100%",
1714
- h: "fit-content",
1715
1724
  color,
1725
+ h: "fit-content",
1726
+ w: "100%",
1716
1727
  ...styles.container
1717
1728
  };
1718
1729
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1720,13 +1731,13 @@ var Autocomplete = (0, import_core9.forwardRef)(
1720
1731
  {
1721
1732
  value: {
1722
1733
  ...rest,
1723
- value,
1724
- onClose,
1725
- formControlProps,
1726
- inputValue,
1727
1734
  allowCreate,
1735
+ inputValue,
1728
1736
  isEmpty,
1729
- styles
1737
+ styles,
1738
+ value,
1739
+ formControlProps,
1740
+ onClose
1730
1741
  },
1731
1742
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover2.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1732
1743
  import_core9.ui.div,
@@ -1757,8 +1768,8 @@ var Autocomplete = (0, import_core9.forwardRef)(
1757
1768
  !isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1758
1769
  AutocompleteList,
1759
1770
  {
1760
- header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
1761
1771
  footer: (0, import_utils12.runIfFunc)(footer, { value, onClose }),
1772
+ header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
1762
1773
  contentProps,
1763
1774
  ...listProps,
1764
1775
  children: [
@@ -1769,8 +1780,8 @@ var Autocomplete = (0, import_core9.forwardRef)(
1769
1780
  ) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1770
1781
  AutocompleteList,
1771
1782
  {
1772
- header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
1773
1783
  footer: (0, import_utils12.runIfFunc)(footer, { value, onClose }),
1784
+ header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
1774
1785
  contentProps,
1775
1786
  ...listProps,
1776
1787
  children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, { ...emptyProps })
@@ -1787,14 +1798,14 @@ Autocomplete.displayName = "Autocomplete";
1787
1798
  Autocomplete.__ui__ = "Autocomplete";
1788
1799
  var AutocompleteField = (0, import_core9.forwardRef)(
1789
1800
  ({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {
1790
- const { label, inputValue, styles } = useAutocompleteContext();
1801
+ const { inputValue, label, styles } = useAutocompleteContext();
1791
1802
  const { getInputProps } = useAutocompleteInput();
1792
1803
  const css = {
1793
- pe: "2rem",
1804
+ alignItems: "center",
1805
+ display: "flex",
1794
1806
  h,
1795
1807
  minH,
1796
- display: "flex",
1797
- alignItems: "center",
1808
+ pe: "2rem",
1798
1809
  ...styles.field,
1799
1810
  cursor: "text"
1800
1811
  };
@@ -1809,8 +1820,8 @@ var AutocompleteField = (0, import_core9.forwardRef)(
1809
1820
  {
1810
1821
  className: "ui-autocomplete__field__input",
1811
1822
  display: "inline-block",
1812
- w: "100%",
1813
1823
  placeholder,
1824
+ w: "100%",
1814
1825
  ...getInputProps(
1815
1826
  { ...inputProps, value: inputValue || label || "" },
1816
1827
  ref