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