@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
package/dist/index.js
CHANGED
@@ -41,9 +41,9 @@ var import_use_descendant = require("@yamada-ui/use-descendant");
|
|
41
41
|
var import_utils = require("@yamada-ui/utils");
|
42
42
|
var {
|
43
43
|
DescendantsContextProvider: AutocompleteDescendantsContextProvider,
|
44
|
-
|
44
|
+
useDescendant: useAutocompleteDescendant,
|
45
45
|
useDescendants: useAutocompleteDescendants,
|
46
|
-
|
46
|
+
useDescendantsContext: useAutocompleteDescendantsContext
|
47
47
|
} = (0, import_use_descendant.createDescendant)();
|
48
48
|
var [AutocompleteProvider, useAutocompleteContext] = (0, import_utils.createContext)({
|
49
49
|
name: "AutocompleteContext",
|
@@ -65,27 +65,27 @@ var AutocompleteIcon = (0, import_core.forwardRef)(
|
|
65
65
|
({ className, children, __css, ...rest }, ref) => {
|
66
66
|
const { styles } = useAutocompleteContext();
|
67
67
|
const css = {
|
68
|
-
position: "absolute",
|
69
|
-
top: "50%",
|
70
|
-
transform: "translateY(-50%)",
|
71
|
-
display: "inline-flex",
|
72
68
|
alignItems: "center",
|
69
|
+
cursor: "pointer",
|
70
|
+
display: "inline-flex",
|
73
71
|
justifyContent: "center",
|
74
72
|
pointerEvents: "none",
|
75
|
-
|
73
|
+
position: "absolute",
|
74
|
+
top: "50%",
|
75
|
+
transform: "translateY(-50%)",
|
76
76
|
...styles.icon,
|
77
77
|
...__css
|
78
78
|
};
|
79
79
|
const validChildren = (0, import_utils2.getValidChildren)(children);
|
80
80
|
const cloneChildren = validChildren.map(
|
81
81
|
(child) => (0, import_react.cloneElement)(child, {
|
82
|
-
focusable: false,
|
83
|
-
"aria-hidden": true,
|
84
82
|
style: {
|
85
|
-
|
83
|
+
color: "currentColor",
|
86
84
|
maxHeight: "1em",
|
87
|
-
|
88
|
-
}
|
85
|
+
maxWidth: "1em"
|
86
|
+
},
|
87
|
+
"aria-hidden": true,
|
88
|
+
focusable: false
|
89
89
|
})
|
90
90
|
);
|
91
91
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
@@ -118,11 +118,11 @@ var AutocompleteClearIcon = ({
|
|
118
118
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
119
119
|
AutocompleteIcon,
|
120
120
|
{
|
121
|
-
"aria-label": "Clear value",
|
122
121
|
className: (0, import_utils2.cx)("ui-autocomplete__icon--clear", className),
|
122
|
+
"aria-label": "Clear value",
|
123
123
|
__css: styles.clearIcon,
|
124
124
|
...rest,
|
125
|
-
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.CloseIcon, {
|
125
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.CloseIcon, { h: "0.5em", w: "0.5em" })
|
126
126
|
}
|
127
127
|
);
|
128
128
|
};
|
@@ -131,11 +131,11 @@ AutocompleteClearIcon.__ui__ = "AutocompleteClearIcon";
|
|
131
131
|
var AutocompleteItemIcon = (0, import_core.forwardRef)(({ className, ...rest }, ref) => {
|
132
132
|
const { styles } = useAutocompleteContext();
|
133
133
|
const css = {
|
134
|
-
flexShrink: 0,
|
135
|
-
display: "inline-flex",
|
136
|
-
justifyContent: "center",
|
137
134
|
alignItems: "center",
|
135
|
+
display: "inline-flex",
|
136
|
+
flexShrink: 0,
|
138
137
|
fontSize: "0.85em",
|
138
|
+
justifyContent: "center",
|
139
139
|
...styles.itemIcon
|
140
140
|
};
|
141
141
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
@@ -156,41 +156,50 @@ var import_utils3 = require("@yamada-ui/utils");
|
|
156
156
|
var import_react2 = require("react");
|
157
157
|
var isTargetOption = (target) => {
|
158
158
|
var _a;
|
159
|
-
return (0, import_utils3.isHTMLElement)(target) && !!((_a = target
|
159
|
+
return (0, import_utils3.isHTMLElement)(target) && !!((_a = target.getAttribute("role")) == null ? void 0 : _a.startsWith("option"));
|
160
160
|
};
|
161
161
|
var useAutocompleteOption = (props) => {
|
162
162
|
var _a, _b;
|
163
163
|
const {
|
164
|
-
|
164
|
+
closeOnSelect: generalCloseOnSelect,
|
165
|
+
focusedIndex,
|
166
|
+
inputRef,
|
165
167
|
omitSelectedValues,
|
168
|
+
setFocusedIndex,
|
169
|
+
value,
|
170
|
+
optionProps,
|
166
171
|
onChange,
|
167
172
|
onChangeLabel,
|
168
|
-
focusedIndex,
|
169
|
-
setFocusedIndex,
|
170
173
|
onClose,
|
171
|
-
closeOnSelect: generalCloseOnSelect,
|
172
|
-
optionProps,
|
173
|
-
inputRef,
|
174
174
|
onFocusNext
|
175
175
|
} = useAutocompleteContext();
|
176
176
|
const id = (0, import_react2.useId)();
|
177
177
|
let {
|
178
|
+
children,
|
179
|
+
closeOnSelect: customCloseOnSelect,
|
178
180
|
icon: customIcon,
|
179
181
|
isDisabled,
|
180
182
|
isFocusable,
|
181
|
-
closeOnSelect: customCloseOnSelect,
|
182
|
-
children,
|
183
183
|
value: optionValue,
|
184
184
|
...computedProps
|
185
185
|
} = { ...optionProps, ...props };
|
186
186
|
const trulyDisabled = !!isDisabled && !isFocusable;
|
187
187
|
const itemRef = (0, import_react2.useRef)(null);
|
188
|
-
const { index, register
|
188
|
+
const { descendants, index, register } = useAutocompleteDescendant({
|
189
189
|
disabled: trulyDisabled
|
190
190
|
});
|
191
191
|
const values = descendants.values();
|
192
192
|
const frontValues = values.slice(0, index);
|
193
193
|
const isMulti = (0, import_utils3.isArray)(value);
|
194
|
+
if ((0, import_utils3.isUndefined)(optionValue)) {
|
195
|
+
if ((0, import_utils3.isString)(children) || (0, import_utils3.isNumber)(children)) {
|
196
|
+
optionValue = children.toString();
|
197
|
+
} else {
|
198
|
+
console.warn(
|
199
|
+
`${!isMulti ? "Autocomplete" : "MultiAutocomplete"}: Cannot infer the option value of complex children. Pass a \`value\` prop or use a plain string as children to <Option>.`
|
200
|
+
);
|
201
|
+
}
|
202
|
+
}
|
194
203
|
const isDuplicated = !isMulti ? frontValues.some(({ node }) => node.dataset.value === (optionValue != null ? optionValue : "")) : false;
|
195
204
|
const isSelected = !isDuplicated && (!isMulti ? (optionValue != null ? optionValue : "") === value : value.includes(optionValue != null ? optionValue : ""));
|
196
205
|
const isTarget = "target" in ((_b = (_a = itemRef.current) == null ? void 0 : _a.dataset) != null ? _b : {});
|
@@ -235,27 +244,27 @@ var useAutocompleteOption = (props) => {
|
|
235
244
|
border: "0px",
|
236
245
|
clip: "rect(0px, 0px, 0px, 0px)",
|
237
246
|
height: "1px",
|
238
|
-
width: "1px",
|
239
247
|
margin: "-1px",
|
240
|
-
padding: "0px",
|
241
248
|
overflow: "hidden",
|
249
|
+
padding: "0px",
|
250
|
+
position: "absolute",
|
242
251
|
whiteSpace: "nowrap",
|
243
|
-
|
252
|
+
width: "1px"
|
244
253
|
};
|
245
254
|
return {
|
246
|
-
ref: (0, import_utils3.mergeRefs)(itemRef, ref, register),
|
247
255
|
id,
|
256
|
+
ref: (0, import_utils3.mergeRefs)(itemRef, ref, register),
|
248
257
|
role: "option",
|
249
258
|
...computedProps,
|
250
259
|
...props2,
|
251
|
-
tabIndex: -1,
|
252
260
|
style: !isTarget || omitSelectedValues && isSelected ? style : void 0,
|
253
|
-
"data-target": (0, import_utils3.dataAttr)(true),
|
254
|
-
"data-value": optionValue != null ? optionValue : "",
|
255
|
-
"data-focus": (0, import_utils3.dataAttr)(isFocused),
|
256
|
-
"data-disabled": (0, import_utils3.dataAttr)(isDisabled),
|
257
261
|
"aria-checked": isSelected,
|
258
262
|
"aria-disabled": (0, import_utils3.ariaAttr)(isDisabled),
|
263
|
+
"data-disabled": (0, import_utils3.dataAttr)(isDisabled),
|
264
|
+
"data-focus": (0, import_utils3.dataAttr)(isFocused),
|
265
|
+
"data-target": (0, import_utils3.dataAttr)(true),
|
266
|
+
"data-value": optionValue != null ? optionValue : "",
|
267
|
+
tabIndex: -1,
|
259
268
|
onClick: (0, import_utils3.handlerAll)(computedProps.onClick, props2.onClick, onClick)
|
260
269
|
};
|
261
270
|
},
|
@@ -273,10 +282,10 @@ var useAutocompleteOption = (props) => {
|
|
273
282
|
]
|
274
283
|
);
|
275
284
|
return {
|
276
|
-
isSelected,
|
277
|
-
isFocused,
|
278
|
-
customIcon,
|
279
285
|
children,
|
286
|
+
customIcon,
|
287
|
+
isFocused,
|
288
|
+
isSelected,
|
280
289
|
getOptionProps
|
281
290
|
};
|
282
291
|
};
|
@@ -288,19 +297,19 @@ var useAutocompleteCreate = () => {
|
|
288
297
|
border: "0px",
|
289
298
|
clip: "rect(0px, 0px, 0px, 0px)",
|
290
299
|
height: "1px",
|
291
|
-
width: "1px",
|
292
300
|
margin: "-1px",
|
293
|
-
padding: "0px",
|
294
301
|
overflow: "hidden",
|
302
|
+
padding: "0px",
|
303
|
+
position: "absolute",
|
295
304
|
whiteSpace: "nowrap",
|
296
|
-
|
305
|
+
width: "1px"
|
297
306
|
};
|
298
307
|
return {
|
299
308
|
ref,
|
300
309
|
...props,
|
301
|
-
tabIndex: -1,
|
302
310
|
style: isHit ? style : void 0,
|
303
311
|
"data-focus": (0, import_utils3.dataAttr)(!isHit),
|
312
|
+
tabIndex: -1,
|
304
313
|
onClick: (0, import_utils3.handlerAll)(props.onClick, onCreate)
|
305
314
|
};
|
306
315
|
},
|
@@ -309,25 +318,25 @@ var useAutocompleteCreate = () => {
|
|
309
318
|
return { getCreateProps };
|
310
319
|
};
|
311
320
|
var useAutocompleteEmpty = () => {
|
312
|
-
const {
|
321
|
+
const { isEmpty, isHit } = useAutocompleteContext();
|
313
322
|
const getEmptyProps = (0, import_react2.useCallback)(
|
314
323
|
(props = {}, ref = null) => {
|
315
324
|
const style = {
|
316
325
|
border: "0px",
|
317
326
|
clip: "rect(0px, 0px, 0px, 0px)",
|
318
327
|
height: "1px",
|
319
|
-
width: "1px",
|
320
328
|
margin: "-1px",
|
321
|
-
padding: "0px",
|
322
329
|
overflow: "hidden",
|
330
|
+
padding: "0px",
|
331
|
+
position: "absolute",
|
323
332
|
whiteSpace: "nowrap",
|
324
|
-
|
333
|
+
width: "1px"
|
325
334
|
};
|
326
335
|
return {
|
327
336
|
ref,
|
328
337
|
...props,
|
329
|
-
|
330
|
-
|
338
|
+
style: isHit && !isEmpty ? style : void 0,
|
339
|
+
tabIndex: -1
|
331
340
|
};
|
332
341
|
},
|
333
342
|
[isHit, isEmpty]
|
@@ -338,21 +347,21 @@ var useAutocompleteEmpty = () => {
|
|
338
347
|
// src/autocomplete-create.tsx
|
339
348
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
340
349
|
var AutocompleteCreate = (0, import_core2.forwardRef)(
|
341
|
-
({ className,
|
350
|
+
({ className, children, icon, ...rest }, ref) => {
|
342
351
|
const { inputValue, styles } = useAutocompleteContext();
|
343
352
|
const { getCreateProps } = useAutocompleteCreate();
|
344
353
|
children != null ? children : children = inputValue;
|
345
354
|
const css = {
|
346
|
-
|
355
|
+
alignItems: "center",
|
347
356
|
color: "inherit",
|
348
|
-
userSelect: "none",
|
349
357
|
display: "flex",
|
350
|
-
width: "100%",
|
351
|
-
alignItems: "center",
|
352
|
-
textAlign: "start",
|
353
358
|
flex: "0 0 auto",
|
354
|
-
outline: 0,
|
355
359
|
gap: "0.75rem",
|
360
|
+
outline: 0,
|
361
|
+
textAlign: "start",
|
362
|
+
textDecoration: "none",
|
363
|
+
userSelect: "none",
|
364
|
+
width: "100%",
|
356
365
|
...styles.item
|
357
366
|
};
|
358
367
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
@@ -363,7 +372,7 @@ var AutocompleteCreate = (0, import_core2.forwardRef)(
|
|
363
372
|
...getCreateProps(rest, ref),
|
364
373
|
children: [
|
365
374
|
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AutocompletePlusIcon, {}) }) : null,
|
366
|
-
icon ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { style: { pointerEvents: "none"
|
375
|
+
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)
|
367
376
|
]
|
368
377
|
}
|
369
378
|
);
|
@@ -371,11 +380,11 @@ var AutocompleteCreate = (0, import_core2.forwardRef)(
|
|
371
380
|
);
|
372
381
|
AutocompleteCreate.displayName = "AutocompleteCreate";
|
373
382
|
AutocompleteCreate.__ui__ = "AutocompleteCreate";
|
374
|
-
var AutocompletePlusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 45.402 45.402", width: "1em",
|
383
|
+
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)(
|
375
384
|
"path",
|
376
385
|
{
|
377
|
-
|
378
|
-
|
386
|
+
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",
|
387
|
+
fill: "currentColor"
|
379
388
|
}
|
380
389
|
) });
|
381
390
|
AutocompletePlusIcon.displayName = "AutocompletePlusIcon";
|
@@ -386,22 +395,22 @@ var import_core3 = require("@yamada-ui/core");
|
|
386
395
|
var import_utils5 = require("@yamada-ui/utils");
|
387
396
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
388
397
|
var AutocompleteEmpty = (0, import_core3.forwardRef)(
|
389
|
-
({ className,
|
398
|
+
({ className, children, icon, ...rest }, ref) => {
|
390
399
|
const { emptyMessage, styles } = useAutocompleteContext();
|
391
400
|
const { getEmptyProps } = useAutocompleteEmpty();
|
392
401
|
children != null ? children : children = emptyMessage;
|
393
402
|
const css = {
|
394
|
-
|
403
|
+
alignItems: "center",
|
395
404
|
color: "inherit",
|
396
|
-
userSelect: "none",
|
397
405
|
display: "flex",
|
398
|
-
width: "100%",
|
399
|
-
alignItems: "center",
|
400
|
-
textAlign: "start",
|
401
406
|
flex: "0 0 auto",
|
402
|
-
outline: 0,
|
403
407
|
gap: "0.75rem",
|
408
|
+
outline: 0,
|
404
409
|
pointerEvents: "none",
|
410
|
+
textAlign: "start",
|
411
|
+
textDecoration: "none",
|
412
|
+
userSelect: "none",
|
413
|
+
width: "100%",
|
405
414
|
...styles.item
|
406
415
|
};
|
407
416
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
@@ -412,7 +421,7 @@ var AutocompleteEmpty = (0, import_core3.forwardRef)(
|
|
412
421
|
...getEmptyProps(rest, ref),
|
413
422
|
children: [
|
414
423
|
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteItemIcon, { children: icon || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AutocompleteMinusIcon, {}) }) : null,
|
415
|
-
icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { pointerEvents: "none"
|
424
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { style: { flex: 1, pointerEvents: "none" }, lineClamp: 1, children }) : children
|
416
425
|
]
|
417
426
|
}
|
418
427
|
);
|
@@ -420,11 +429,11 @@ var AutocompleteEmpty = (0, import_core3.forwardRef)(
|
|
420
429
|
);
|
421
430
|
AutocompleteEmpty.displayName = "AutocompleteEmpty";
|
422
431
|
AutocompleteEmpty.__ui__ = "AutocompleteEmpty";
|
423
|
-
var AutocompleteMinusIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 448 512", width: "1em",
|
432
|
+
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)(
|
424
433
|
"path",
|
425
434
|
{
|
426
|
-
|
427
|
-
|
435
|
+
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",
|
436
|
+
fill: "currentColor"
|
428
437
|
}
|
429
438
|
) });
|
430
439
|
AutocompleteMinusIcon.displayName = "AutocompleteMinusIcon";
|
@@ -480,20 +489,20 @@ var useAutocompleteList = () => {
|
|
480
489
|
(props = {}, ref = null) => {
|
481
490
|
var _a;
|
482
491
|
return {
|
483
|
-
|
492
|
+
id: (_a = props.id) != null ? _a : uuid,
|
484
493
|
ref: (0, import_utils6.mergeRefs)(listRef, ref),
|
494
|
+
as: "ul",
|
495
|
+
position: "relative",
|
485
496
|
role: "listbox",
|
486
497
|
tabIndex: -1,
|
487
|
-
position: "relative",
|
488
|
-
id: (_a = props.id) != null ? _a : uuid,
|
489
498
|
...props
|
490
499
|
};
|
491
500
|
},
|
492
501
|
[listRef, uuid]
|
493
502
|
);
|
494
503
|
return {
|
495
|
-
|
496
|
-
|
504
|
+
getListProps,
|
505
|
+
onAnimationComplete
|
497
506
|
};
|
498
507
|
};
|
499
508
|
|
@@ -502,21 +511,21 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
502
511
|
var AutocompleteList = (0, import_core4.forwardRef)(
|
503
512
|
({
|
504
513
|
className,
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
minWidth,
|
514
|
+
children,
|
515
|
+
footer,
|
516
|
+
header,
|
509
517
|
maxW,
|
510
518
|
maxWidth,
|
519
|
+
minW,
|
520
|
+
minWidth,
|
521
|
+
w,
|
522
|
+
width,
|
511
523
|
contentProps,
|
512
|
-
header,
|
513
|
-
footer,
|
514
|
-
children,
|
515
524
|
...rest
|
516
525
|
}, ref) => {
|
517
526
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
518
527
|
const { styles } = useAutocompleteContext();
|
519
|
-
const {
|
528
|
+
const { getListProps, onAnimationComplete } = useAutocompleteList();
|
520
529
|
width != null ? width : width = w;
|
521
530
|
width != null ? width : width = (_c = (_a = styles.list) == null ? void 0 : _a.width) != null ? _c : (_b = styles.list) == null ? void 0 : _b.w;
|
522
531
|
minWidth != null ? minWidth : minWidth = minW;
|
@@ -528,10 +537,10 @@ var AutocompleteList = (0, import_core4.forwardRef)(
|
|
528
537
|
{
|
529
538
|
as: "div",
|
530
539
|
className: "ui-autocomplete__popover",
|
531
|
-
width,
|
532
|
-
minWidth,
|
533
540
|
maxWidth,
|
534
|
-
|
541
|
+
minWidth,
|
542
|
+
width,
|
543
|
+
__css: { ...styles.content, maxWidth, minWidth, width },
|
535
544
|
...contentProps,
|
536
545
|
onAnimationComplete: (0, import_utils7.handlerAll)(
|
537
546
|
contentProps == null ? void 0 : contentProps.onAnimationComplete,
|
@@ -587,19 +596,19 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
587
596
|
var AutocompleteOption = (0, import_core5.forwardRef)(
|
588
597
|
({ className, icon, ...rest }, ref) => {
|
589
598
|
const { styles } = useAutocompleteContext();
|
590
|
-
const {
|
599
|
+
const { children, customIcon, isSelected, getOptionProps } = useAutocompleteOption(rest);
|
591
600
|
icon != null ? icon : icon = customIcon;
|
592
601
|
const css = {
|
593
|
-
|
602
|
+
alignItems: "center",
|
594
603
|
color: "inherit",
|
595
|
-
userSelect: "none",
|
596
604
|
display: "flex",
|
597
|
-
width: "100%",
|
598
|
-
alignItems: "center",
|
599
|
-
textAlign: "start",
|
600
605
|
flex: "0 0 auto",
|
601
|
-
outline: 0,
|
602
606
|
gap: "0.75rem",
|
607
|
+
outline: 0,
|
608
|
+
textAlign: "start",
|
609
|
+
textDecoration: "none",
|
610
|
+
userSelect: "none",
|
611
|
+
width: "100%",
|
603
612
|
...styles.item
|
604
613
|
};
|
605
614
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
@@ -618,7 +627,7 @@ var AutocompleteOption = (0, import_core5.forwardRef)(
|
|
618
627
|
);
|
619
628
|
AutocompleteOption.displayName = "AutocompleteOption";
|
620
629
|
AutocompleteOption.__ui__ = "AutocompleteOption";
|
621
|
-
var AutocompleteCheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 14 14", width: "1em",
|
630
|
+
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)(
|
622
631
|
"polygon",
|
623
632
|
{
|
624
633
|
fill: "currentColor",
|
@@ -640,7 +649,7 @@ var useAutocompleteOptionGroup = ({
|
|
640
649
|
label,
|
641
650
|
...rest
|
642
651
|
}) => {
|
643
|
-
const {
|
652
|
+
const { omitSelectedValues, value } = useAutocompleteContext();
|
644
653
|
const isMulti = (0, import_utils9.isArray)(value);
|
645
654
|
const descendants = useAutocompleteDescendantsContext();
|
646
655
|
const values = descendants.values();
|
@@ -652,7 +661,7 @@ var useAutocompleteOptionGroup = ({
|
|
652
661
|
) : [];
|
653
662
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
654
663
|
const childValues = values.filter(
|
655
|
-
({
|
664
|
+
({ index, node }) => {
|
656
665
|
var _a;
|
657
666
|
return ((_a = node.parentElement) == null ? void 0 : _a.dataset.label) === label && !selectedIndexes.includes(index) && "target" in node.dataset;
|
658
667
|
}
|
@@ -665,12 +674,12 @@ var useAutocompleteOptionGroup = ({
|
|
665
674
|
border: "0px",
|
666
675
|
clip: "rect(0px, 0px, 0px, 0px)",
|
667
676
|
height: "1px",
|
668
|
-
width: "1px",
|
669
677
|
margin: "-1px",
|
670
|
-
padding: "0px",
|
671
678
|
overflow: "hidden",
|
679
|
+
padding: "0px",
|
680
|
+
position: "absolute",
|
672
681
|
whiteSpace: "nowrap",
|
673
|
-
|
682
|
+
width: "1px"
|
674
683
|
};
|
675
684
|
return {
|
676
685
|
ref,
|
@@ -705,12 +714,12 @@ var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
705
714
|
var AutocompleteOptionGroup = (0, import_core7.forwardRef)(
|
706
715
|
({
|
707
716
|
className,
|
717
|
+
children,
|
708
718
|
color,
|
709
719
|
h,
|
710
720
|
height,
|
711
721
|
minH,
|
712
722
|
minHeight,
|
713
|
-
children,
|
714
723
|
labelProps,
|
715
724
|
...rest
|
716
725
|
}, ref) => {
|
@@ -726,15 +735,15 @@ var AutocompleteOptionGroup = (0, import_core7.forwardRef)(
|
|
726
735
|
"ui-autocomplete__item--group",
|
727
736
|
className
|
728
737
|
),
|
729
|
-
__css: {
|
738
|
+
__css: { color, h: "fit-content", w: "100%" },
|
730
739
|
...getContainerProps(),
|
731
740
|
children: [
|
732
741
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
733
742
|
import_core7.ui.span,
|
734
743
|
{
|
735
744
|
className: "ui-autocomplete__item__group-label",
|
736
|
-
__css: styles.groupLabel,
|
737
745
|
lineClamp: 1,
|
746
|
+
__css: styles.groupLabel,
|
738
747
|
...labelProps,
|
739
748
|
children: label
|
740
749
|
}
|
@@ -759,64 +768,79 @@ AutocompleteOptionGroup.__ui__ = "AutocompleteOptionGroup";
|
|
759
768
|
// src/use-autocomplete.tsx
|
760
769
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
761
770
|
var kanaMap = {
|
762
|
-
\
|
763
|
-
\
|
764
|
-
\
|
765
|
-
\
|
766
|
-
\
|
767
|
-
\
|
768
|
-
\uFF7C\uFF9E: "\u30B8",
|
769
|
-
\uFF7D\uFF9E: "\u30BA",
|
770
|
-
\uFF7E\uFF9E: "\u30BC",
|
771
|
-
\uFF7F\uFF9E: "\u30BE",
|
772
|
-
\uFF80\uFF9E: "\u30C0",
|
773
|
-
\uFF81\uFF9E: "\u30C2",
|
774
|
-
\uFF82\uFF9E: "\u30C5",
|
775
|
-
\uFF83\uFF9E: "\u30C7",
|
776
|
-
\uFF84\uFF9E: "\u30C9",
|
777
|
-
\uFF8A\uFF9E: "\u30D0",
|
778
|
-
\uFF8B\uFF9E: "\u30D3",
|
779
|
-
\uFF8C\uFF9E: "\u30D6",
|
780
|
-
\uFF8D\uFF9E: "\u30D9",
|
781
|
-
\uFF8E\uFF9E: "\u30DC",
|
782
|
-
\uFF8A\uFF9F: "\u30D1",
|
783
|
-
\uFF8B\uFF9F: "\u30D4",
|
784
|
-
\uFF8C\uFF9F: "\u30D7",
|
785
|
-
\uFF8D\uFF9F: "\u30DA",
|
786
|
-
\uFF8E\uFF9F: "\u30DD",
|
787
|
-
\uFF73\uFF9E: "\u30F4",
|
788
|
-
\uFF9C\uFF9E: "\u30F7",
|
771
|
+
"\uFF61": "\u3002",
|
772
|
+
"\uFF62": "\u300C",
|
773
|
+
"\uFF63": "\u300D",
|
774
|
+
"\uFF64": "\u3001",
|
775
|
+
"\uFF65": "\u30FB",
|
776
|
+
\uFF66: "\u30F2",
|
789
777
|
\uFF66\uFF9E: "\u30FA",
|
778
|
+
\uFF67: "\u30A1",
|
779
|
+
\uFF68: "\u30A3",
|
780
|
+
\uFF69: "\u30A5",
|
781
|
+
\uFF6A: "\u30A7",
|
782
|
+
\uFF6B: "\u30A9",
|
783
|
+
\uFF6C: "\u30E3",
|
784
|
+
\uFF6D: "\u30E5",
|
785
|
+
\uFF6E: "\u30E7",
|
786
|
+
\uFF6F: "\u30C3",
|
787
|
+
\uFF70: "\u30FC",
|
790
788
|
\uFF71: "\u30A2",
|
791
789
|
\uFF72: "\u30A4",
|
792
790
|
\uFF73: "\u30A6",
|
791
|
+
\uFF73\uFF9E: "\u30F4",
|
793
792
|
\uFF74: "\u30A8",
|
794
793
|
\uFF75: "\u30AA",
|
795
794
|
\uFF76: "\u30AB",
|
795
|
+
\uFF76\uFF9E: "\u30AC",
|
796
796
|
\uFF77: "\u30AD",
|
797
|
+
\uFF77\uFF9E: "\u30AE",
|
797
798
|
\uFF78: "\u30AF",
|
799
|
+
\uFF78\uFF9E: "\u30B0",
|
798
800
|
\uFF79: "\u30B1",
|
801
|
+
\uFF79\uFF9E: "\u30B2",
|
799
802
|
\uFF7A: "\u30B3",
|
803
|
+
\uFF7A\uFF9E: "\u30B4",
|
800
804
|
\uFF7B: "\u30B5",
|
805
|
+
\uFF7B\uFF9E: "\u30B6",
|
801
806
|
\uFF7C: "\u30B7",
|
807
|
+
\uFF7C\uFF9E: "\u30B8",
|
802
808
|
\uFF7D: "\u30B9",
|
809
|
+
\uFF7D\uFF9E: "\u30BA",
|
803
810
|
\uFF7E: "\u30BB",
|
811
|
+
\uFF7E\uFF9E: "\u30BC",
|
804
812
|
\uFF7F: "\u30BD",
|
813
|
+
\uFF7F\uFF9E: "\u30BE",
|
805
814
|
\uFF80: "\u30BF",
|
815
|
+
\uFF80\uFF9E: "\u30C0",
|
806
816
|
\uFF81: "\u30C1",
|
817
|
+
\uFF81\uFF9E: "\u30C2",
|
807
818
|
\uFF82: "\u30C4",
|
819
|
+
\uFF82\uFF9E: "\u30C5",
|
808
820
|
\uFF83: "\u30C6",
|
821
|
+
\uFF83\uFF9E: "\u30C7",
|
809
822
|
\uFF84: "\u30C8",
|
823
|
+
\uFF84\uFF9E: "\u30C9",
|
810
824
|
\uFF85: "\u30CA",
|
811
825
|
\uFF86: "\u30CB",
|
812
826
|
\uFF87: "\u30CC",
|
813
827
|
\uFF88: "\u30CD",
|
814
828
|
\uFF89: "\u30CE",
|
815
829
|
\uFF8A: "\u30CF",
|
830
|
+
\uFF8A\uFF9E: "\u30D0",
|
831
|
+
\uFF8A\uFF9F: "\u30D1",
|
816
832
|
\uFF8B: "\u30D2",
|
833
|
+
\uFF8B\uFF9E: "\u30D3",
|
834
|
+
\uFF8B\uFF9F: "\u30D4",
|
817
835
|
\uFF8C: "\u30D5",
|
836
|
+
\uFF8C\uFF9E: "\u30D6",
|
837
|
+
\uFF8C\uFF9F: "\u30D7",
|
818
838
|
\uFF8D: "\u30D8",
|
839
|
+
\uFF8D\uFF9E: "\u30D9",
|
840
|
+
\uFF8D\uFF9F: "\u30DA",
|
819
841
|
\uFF8E: "\u30DB",
|
842
|
+
\uFF8E\uFF9E: "\u30DC",
|
843
|
+
\uFF8E\uFF9F: "\u30DD",
|
820
844
|
\uFF8F: "\u30DE",
|
821
845
|
\uFF90: "\u30DF",
|
822
846
|
\uFF91: "\u30E0",
|
@@ -831,23 +855,8 @@ var kanaMap = {
|
|
831
855
|
\uFF9A: "\u30EC",
|
832
856
|
\uFF9B: "\u30ED",
|
833
857
|
\uFF9C: "\u30EF",
|
834
|
-
\
|
835
|
-
\uFF9D: "\u30F3"
|
836
|
-
\uFF67: "\u30A1",
|
837
|
-
\uFF68: "\u30A3",
|
838
|
-
\uFF69: "\u30A5",
|
839
|
-
\uFF6A: "\u30A7",
|
840
|
-
\uFF6B: "\u30A9",
|
841
|
-
\uFF6F: "\u30C3",
|
842
|
-
\uFF6C: "\u30E3",
|
843
|
-
\uFF6D: "\u30E5",
|
844
|
-
\uFF6E: "\u30E7",
|
845
|
-
"\uFF61": "\u3002",
|
846
|
-
"\uFF64": "\u3001",
|
847
|
-
\uFF70: "\u30FC",
|
848
|
-
"\uFF62": "\u300C",
|
849
|
-
"\uFF63": "\u300D",
|
850
|
-
"\uFF65": "\u30FB"
|
858
|
+
\uFF9C\uFF9E: "\u30F7",
|
859
|
+
\uFF9D: "\u30F3"
|
851
860
|
};
|
852
861
|
var defaultFormat = (value) => {
|
853
862
|
value = value.replace(
|
@@ -875,46 +884,46 @@ var flattenItems = (items) => {
|
|
875
884
|
};
|
876
885
|
var useAutocomplete = (props) => {
|
877
886
|
const {
|
878
|
-
value: valueProp,
|
879
|
-
defaultValue,
|
880
|
-
onChange: onChangeProp,
|
881
|
-
onCreate: onCreateProp,
|
882
|
-
onSearch: onSearchProp,
|
883
|
-
closeOnSelect = true,
|
884
|
-
omitSelectedValues = false,
|
885
|
-
maxSelectValues,
|
886
887
|
allowCreate = false,
|
887
888
|
allowFree = false,
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
placeholder,
|
893
|
-
onKeyDown: onKeyDownProp,
|
894
|
-
isOpen: isOpenProp,
|
895
|
-
defaultIsOpen,
|
896
|
-
onOpen: onOpenProp,
|
897
|
-
onClose: onCloseProp,
|
889
|
+
animation,
|
890
|
+
boundary,
|
891
|
+
children,
|
892
|
+
closeDelay,
|
898
893
|
closeOnBlur = true,
|
899
894
|
closeOnEsc = true,
|
900
|
-
|
901
|
-
|
895
|
+
closeOnSelect = true,
|
896
|
+
defaultIsOpen,
|
897
|
+
defaultValue,
|
898
|
+
duration = 0.2,
|
899
|
+
emptyMessage = "No results found",
|
900
|
+
eventListeners,
|
901
|
+
flip,
|
902
|
+
format = defaultFormat,
|
903
|
+
gutter,
|
904
|
+
insertPositionItem = "first",
|
902
905
|
isLazy,
|
906
|
+
isOpen: isOpenProp,
|
907
|
+
items,
|
903
908
|
lazyBehavior,
|
904
|
-
|
905
|
-
|
909
|
+
matchWidth = true,
|
910
|
+
maxSelectValues,
|
911
|
+
modifiers,
|
906
912
|
offset,
|
907
|
-
|
913
|
+
omitSelectedValues = false,
|
914
|
+
openDelay,
|
915
|
+
placeholder,
|
916
|
+
placement = "bottom-start",
|
908
917
|
preventOverflow,
|
909
|
-
flip,
|
910
|
-
matchWidth = true,
|
911
|
-
boundary,
|
912
|
-
eventListeners,
|
913
918
|
strategy,
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
919
|
+
value: valueProp,
|
920
|
+
optionProps,
|
921
|
+
onChange: onChangeProp,
|
922
|
+
onClose: onCloseProp,
|
923
|
+
onCreate: onCreateProp,
|
924
|
+
onKeyDown: onKeyDownProp,
|
925
|
+
onOpen: onOpenProp,
|
926
|
+
onSearch: onSearchProp,
|
918
927
|
...rest
|
919
928
|
} = (0, import_form_control.useFormControlProps)(props);
|
920
929
|
const {
|
@@ -933,8 +942,8 @@ var useAutocomplete = (props) => {
|
|
933
942
|
const prevValue = (0, import_react5.useRef)(void 0);
|
934
943
|
const [resolvedItems, setResolvedItems] = (0, import_react5.useState)(items ? JSON.parse(JSON.stringify(items)) : void 0);
|
935
944
|
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
936
|
-
value: valueProp,
|
937
945
|
defaultValue,
|
946
|
+
value: valueProp,
|
938
947
|
onChange: onChangeProp
|
939
948
|
});
|
940
949
|
const [label, setLabel] = (0, import_react5.useState)(void 0);
|
@@ -944,13 +953,13 @@ var useAutocomplete = (props) => {
|
|
944
953
|
const [isHit, setIsHit] = (0, import_react5.useState)(true);
|
945
954
|
const {
|
946
955
|
isOpen,
|
947
|
-
|
948
|
-
|
956
|
+
onClose,
|
957
|
+
onOpen: onInternalOpen
|
949
958
|
} = (0, import_use_disclosure.useDisclosure)({
|
950
|
-
isOpen: isOpenProp,
|
951
959
|
defaultIsOpen,
|
952
|
-
|
953
|
-
onClose: onCloseProp
|
960
|
+
isOpen: isOpenProp,
|
961
|
+
onClose: onCloseProp,
|
962
|
+
onOpen: onOpenProp
|
954
963
|
});
|
955
964
|
const isFocused = focusedIndex > -1;
|
956
965
|
const isCreate = focusedIndex === -2 && allowCreate;
|
@@ -976,7 +985,7 @@ var useAutocomplete = (props) => {
|
|
976
985
|
);
|
977
986
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
978
987
|
const enabledValues = descendants.enabledValues(
|
979
|
-
({
|
988
|
+
({ index, node }) => "target" in node.dataset && !selectedIndexes.includes(index)
|
980
989
|
);
|
981
990
|
const validChildren = (0, import_utils11.getValidChildren)(children);
|
982
991
|
const computedChildren = (0, import_react5.useMemo)(
|
@@ -985,7 +994,7 @@ var useAutocomplete = (props) => {
|
|
985
994
|
const { label: label2, value: value2, ...props2 } = item;
|
986
995
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AutocompleteOption, { value: value2, ...props2, children: label2 }, i);
|
987
996
|
} else if ("items" in item) {
|
988
|
-
const {
|
997
|
+
const { items: items2 = [], label: label2, ...props2 } = item;
|
989
998
|
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);
|
990
999
|
}
|
991
1000
|
}),
|
@@ -1000,6 +1009,7 @@ var useAutocomplete = (props) => {
|
|
1000
1009
|
}, [allowCreate, formControlProps, isAllSelected, isEmpty, onInternalOpen]);
|
1001
1010
|
const onFocusFirst = (0, import_react5.useCallback)(() => {
|
1002
1011
|
const id2 = setTimeout(() => {
|
1012
|
+
var _a;
|
1003
1013
|
if (isEmpty || isAllSelected) return;
|
1004
1014
|
const first = descendants.enabledFirstValue(
|
1005
1015
|
({ node }) => "target" in node.dataset
|
@@ -1010,7 +1020,7 @@ var useAutocomplete = (props) => {
|
|
1010
1020
|
} else {
|
1011
1021
|
if (selectedIndexes.includes(first.index)) {
|
1012
1022
|
const enabledFirst = enabledValues[0];
|
1013
|
-
setFocusedIndex(enabledFirst.index);
|
1023
|
+
setFocusedIndex((_a = enabledFirst == null ? void 0 : enabledFirst.index) != null ? _a : -1);
|
1014
1024
|
} else {
|
1015
1025
|
setFocusedIndex(first.index);
|
1016
1026
|
}
|
@@ -1028,6 +1038,7 @@ var useAutocomplete = (props) => {
|
|
1028
1038
|
]);
|
1029
1039
|
const onFocusLast = (0, import_react5.useCallback)(() => {
|
1030
1040
|
const id2 = setTimeout(() => {
|
1041
|
+
var _a;
|
1031
1042
|
if (isEmpty || isAllSelected) return;
|
1032
1043
|
const last = descendants.enabledLastValue(
|
1033
1044
|
({ node }) => "target" in node.dataset
|
@@ -1038,7 +1049,7 @@ var useAutocomplete = (props) => {
|
|
1038
1049
|
} else {
|
1039
1050
|
if (selectedIndexes.includes(last.index)) {
|
1040
1051
|
const enabledLast = enabledValues.reverse()[0];
|
1041
|
-
setFocusedIndex(enabledLast.index);
|
1052
|
+
setFocusedIndex((_a = enabledLast == null ? void 0 : enabledLast.index) != null ? _a : -1);
|
1042
1053
|
} else {
|
1043
1054
|
setFocusedIndex(last.index);
|
1044
1055
|
}
|
@@ -1070,7 +1081,7 @@ var useAutocomplete = (props) => {
|
|
1070
1081
|
const onFocusNext = (0, import_react5.useCallback)(
|
1071
1082
|
(index = focusedIndex) => {
|
1072
1083
|
const id2 = setTimeout(() => {
|
1073
|
-
var _a;
|
1084
|
+
var _a, _b;
|
1074
1085
|
const next = descendants.enabledNextValue(
|
1075
1086
|
index,
|
1076
1087
|
({ node }) => "target" in node.dataset
|
@@ -1081,7 +1092,7 @@ var useAutocomplete = (props) => {
|
|
1081
1092
|
} else {
|
1082
1093
|
if (selectedIndexes.includes(next.index)) {
|
1083
1094
|
const enabledNext = (_a = enabledValues.find(({ index: index2 }) => next.index < index2)) != null ? _a : enabledValues[0];
|
1084
|
-
setFocusedIndex(enabledNext.index);
|
1095
|
+
setFocusedIndex((_b = enabledNext == null ? void 0 : enabledNext.index) != null ? _b : -1);
|
1085
1096
|
} else {
|
1086
1097
|
setFocusedIndex(next.index);
|
1087
1098
|
}
|
@@ -1101,7 +1112,7 @@ var useAutocomplete = (props) => {
|
|
1101
1112
|
const onFocusPrev = (0, import_react5.useCallback)(
|
1102
1113
|
(index = focusedIndex) => {
|
1103
1114
|
const id2 = setTimeout(() => {
|
1104
|
-
var _a;
|
1115
|
+
var _a, _b;
|
1105
1116
|
const prev = descendants.enabledPrevValue(
|
1106
1117
|
index,
|
1107
1118
|
({ node }) => "target" in node.dataset
|
@@ -1112,7 +1123,7 @@ var useAutocomplete = (props) => {
|
|
1112
1123
|
} else {
|
1113
1124
|
if (selectedIndexes.includes(prev.index)) {
|
1114
1125
|
const enabledPrev = (_a = enabledValues.reverse().find(({ index: index2 }) => index2 < prev.index)) != null ? _a : enabledValues[0];
|
1115
|
-
setFocusedIndex(enabledPrev.index);
|
1126
|
+
setFocusedIndex((_b = enabledPrev == null ? void 0 : enabledPrev.index) != null ? _b : -1);
|
1116
1127
|
} else {
|
1117
1128
|
setFocusedIndex(prev.index);
|
1118
1129
|
}
|
@@ -1136,7 +1147,7 @@ var useAutocomplete = (props) => {
|
|
1136
1147
|
const values = descendants.values();
|
1137
1148
|
let isHit2 = false;
|
1138
1149
|
let isFocused2 = false;
|
1139
|
-
values.forEach(({
|
1150
|
+
values.forEach(({ index, node }) => {
|
1140
1151
|
var _a;
|
1141
1152
|
if (format((_a = node.textContent) != null ? _a : "").includes(value2)) {
|
1142
1153
|
isHit2 = true;
|
@@ -1194,7 +1205,7 @@ var useAutocomplete = (props) => {
|
|
1194
1205
|
return selectedValues2[0];
|
1195
1206
|
} else {
|
1196
1207
|
selectedValues2.forEach((selectedValue) => {
|
1197
|
-
const isSelected = (0, import_utils11.isArray)(prev) && prev.includes(selectedValue
|
1208
|
+
const isSelected = (0, import_utils11.isArray)(prev) && prev.includes(selectedValue);
|
1198
1209
|
if (!isSelected) {
|
1199
1210
|
prev = [...(0, import_utils11.isArray)(prev) ? prev : [], selectedValue];
|
1200
1211
|
} else if (runOmit) {
|
@@ -1299,7 +1310,7 @@ var useAutocomplete = (props) => {
|
|
1299
1310
|
({ label: label2 }) => label2 === firstInsertPositionItem
|
1300
1311
|
);
|
1301
1312
|
const targetItem = newItems[i];
|
1302
|
-
if (i !== -1 && "items" in targetItem) {
|
1313
|
+
if (i !== -1 && targetItem && "items" in targetItem) {
|
1303
1314
|
if (secondInsertPositionItem === "first") {
|
1304
1315
|
targetItem.items = [newItem, ...(_a = targetItem.items) != null ? _a : []];
|
1305
1316
|
} else {
|
@@ -1383,15 +1394,15 @@ var useAutocomplete = (props) => {
|
|
1383
1394
|
const actions = {
|
1384
1395
|
ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
|
1385
1396
|
ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusLastOrSelected) : void 0,
|
1386
|
-
|
1397
|
+
Backspace: !isEmptyValue && enabledDelete ? onDelete : void 0,
|
1398
|
+
End: isOpen ? onFocusLast : void 0,
|
1387
1399
|
Enter: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : allowFree && isMulti ? () => {
|
1388
1400
|
if (inputValue) onChange(inputValue);
|
1389
1401
|
setFocusedIndex(0);
|
1390
1402
|
} : void 0,
|
1391
|
-
Home: isOpen ? onFocusFirst : void 0,
|
1392
|
-
End: isOpen ? onFocusLast : void 0,
|
1393
1403
|
Escape: closeOnEsc ? onClose : void 0,
|
1394
|
-
|
1404
|
+
Home: isOpen ? onFocusFirst : void 0,
|
1405
|
+
Space: isCreate ? onCreate : isFocused ? onSelect : !isOpen ? (0, import_utils11.funcAll)(onOpen, onFocusFirstOrSelected) : void 0
|
1395
1406
|
};
|
1396
1407
|
const action = actions[ev.key];
|
1397
1408
|
if (!action) return;
|
@@ -1446,7 +1457,7 @@ var useAutocomplete = (props) => {
|
|
1446
1457
|
(0, import_react5.useEffect)(() => {
|
1447
1458
|
var _a;
|
1448
1459
|
if (isMulti) {
|
1449
|
-
if (JSON.stringify((_a = prevValue.current) != null ? _a : []) === JSON.stringify(value
|
1460
|
+
if (JSON.stringify((_a = prevValue.current) != null ? _a : []) === JSON.stringify(value))
|
1450
1461
|
return;
|
1451
1462
|
const label2 = getSelectedValues(value);
|
1452
1463
|
setLabel(label2);
|
@@ -1472,34 +1483,34 @@ var useAutocomplete = (props) => {
|
|
1472
1483
|
});
|
1473
1484
|
(0, import_use_outside_click.useOutsideClick)({
|
1474
1485
|
ref: containerRef,
|
1475
|
-
|
1476
|
-
|
1486
|
+
enabled: isOpen && (closeOnBlur || !isHit),
|
1487
|
+
handler: onClose
|
1477
1488
|
});
|
1478
1489
|
const getPopoverProps = (0, import_react5.useCallback)(
|
1479
1490
|
(props2) => ({
|
1480
|
-
|
1481
|
-
|
1491
|
+
animation,
|
1492
|
+
boundary,
|
1482
1493
|
closeDelay,
|
1494
|
+
closeOnBlur,
|
1495
|
+
duration,
|
1496
|
+
eventListeners,
|
1497
|
+
flip,
|
1498
|
+
gutter,
|
1483
1499
|
isLazy,
|
1484
1500
|
lazyBehavior,
|
1485
|
-
|
1486
|
-
|
1501
|
+
matchWidth,
|
1502
|
+
modifiers,
|
1487
1503
|
offset,
|
1488
|
-
|
1504
|
+
openDelay,
|
1505
|
+
placement,
|
1489
1506
|
preventOverflow,
|
1490
|
-
flip,
|
1491
|
-
matchWidth,
|
1492
|
-
boundary,
|
1493
|
-
eventListeners,
|
1494
1507
|
strategy,
|
1495
|
-
placement,
|
1496
|
-
modifiers,
|
1497
1508
|
...props2,
|
1498
|
-
trigger: "never",
|
1499
1509
|
closeOnButton: false,
|
1500
1510
|
isOpen,
|
1501
|
-
|
1502
|
-
onClose
|
1511
|
+
trigger: "never",
|
1512
|
+
onClose,
|
1513
|
+
onOpen
|
1503
1514
|
}),
|
1504
1515
|
[
|
1505
1516
|
closeOnBlur,
|
@@ -1530,8 +1541,8 @@ var useAutocomplete = (props) => {
|
|
1530
1541
|
...containerProps,
|
1531
1542
|
...props2,
|
1532
1543
|
...formControlProps,
|
1533
|
-
|
1534
|
-
|
1544
|
+
onBlur: (0, import_utils11.handlerAll)(props2.onBlur, rest.onBlur, onBlur),
|
1545
|
+
onClick: (0, import_utils11.handlerAll)(props2.onClick, rest.onClick, onClick)
|
1535
1546
|
}),
|
1536
1547
|
[containerProps, formControlProps, onBlur, onClick, rest]
|
1537
1548
|
);
|
@@ -1541,9 +1552,9 @@ var useAutocomplete = (props) => {
|
|
1541
1552
|
tabIndex: -1,
|
1542
1553
|
...props2,
|
1543
1554
|
...formControlProps,
|
1544
|
-
placeholder,
|
1545
|
-
"data-active": (0, import_utils11.dataAttr)(isOpen),
|
1546
1555
|
"aria-expanded": (0, import_utils11.dataAttr)(isOpen),
|
1556
|
+
"data-active": (0, import_utils11.dataAttr)(isOpen),
|
1557
|
+
placeholder,
|
1547
1558
|
onFocus: (0, import_utils11.handlerAll)(props2.onFocus, onFocusProp, onFocus),
|
1548
1559
|
onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDownProp, onKeyDown)
|
1549
1560
|
}),
|
@@ -1559,61 +1570,61 @@ var useAutocomplete = (props) => {
|
|
1559
1570
|
);
|
1560
1571
|
return {
|
1561
1572
|
id,
|
1562
|
-
descendants,
|
1563
|
-
value,
|
1564
|
-
label,
|
1565
|
-
inputValue,
|
1566
|
-
isHit,
|
1567
|
-
isEmpty,
|
1568
|
-
computedChildren,
|
1569
|
-
focusedIndex,
|
1570
|
-
omitSelectedValues,
|
1571
|
-
closeOnSelect,
|
1572
1573
|
allowCreate,
|
1573
1574
|
allowFree,
|
1575
|
+
closeOnSelect,
|
1576
|
+
computedChildren,
|
1577
|
+
descendants,
|
1574
1578
|
emptyMessage,
|
1575
|
-
|
1579
|
+
focusedIndex,
|
1580
|
+
inputRef,
|
1581
|
+
inputValue,
|
1576
1582
|
isAllSelected,
|
1583
|
+
isEmpty,
|
1584
|
+
isHit,
|
1585
|
+
isOpen,
|
1586
|
+
label,
|
1577
1587
|
listRef,
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1588
|
+
omitSelectedValues,
|
1589
|
+
pickOptions,
|
1590
|
+
rebirthOptions,
|
1581
1591
|
setFocusedIndex,
|
1582
|
-
|
1592
|
+
value,
|
1593
|
+
formControlProps,
|
1594
|
+
getContainerProps,
|
1595
|
+
getFieldProps,
|
1596
|
+
getPopoverProps,
|
1597
|
+
inputProps,
|
1598
|
+
optionProps,
|
1583
1599
|
onChange,
|
1584
|
-
|
1585
|
-
onCreate,
|
1600
|
+
onChangeLabel,
|
1586
1601
|
onClear,
|
1587
|
-
onCompositionStart,
|
1588
|
-
onCompositionEnd,
|
1589
|
-
pickOptions,
|
1590
|
-
rebirthOptions,
|
1591
|
-
onOpen,
|
1592
1602
|
onClose,
|
1603
|
+
onCompositionEnd,
|
1604
|
+
onCompositionStart,
|
1605
|
+
onCreate,
|
1593
1606
|
onFocusFirst,
|
1594
1607
|
onFocusLast,
|
1595
|
-
onFocusSelected,
|
1596
1608
|
onFocusNext,
|
1597
1609
|
onFocusPrev,
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
inputProps
|
1610
|
+
onFocusSelected,
|
1611
|
+
onOpen,
|
1612
|
+
onSearch
|
1602
1613
|
};
|
1603
1614
|
};
|
1604
1615
|
var useAutocompleteInput = () => {
|
1605
1616
|
const {
|
1606
1617
|
id,
|
1618
|
+
focusedIndex,
|
1607
1619
|
inputRef,
|
1608
|
-
onSearch,
|
1609
|
-
onCompositionStart,
|
1610
|
-
onCompositionEnd,
|
1611
1620
|
isAllSelected,
|
1621
|
+
isOpen,
|
1622
|
+
listRef,
|
1612
1623
|
formControlProps,
|
1613
1624
|
inputProps,
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1625
|
+
onCompositionEnd,
|
1626
|
+
onCompositionStart,
|
1627
|
+
onSearch
|
1617
1628
|
} = useAutocompleteContext();
|
1618
1629
|
const { value } = useAutocompleteDescendantsContext();
|
1619
1630
|
(0, import_utils11.useUpdateEffect)(() => {
|
@@ -1625,14 +1636,14 @@ var useAutocompleteInput = () => {
|
|
1625
1636
|
return {
|
1626
1637
|
ref: (0, import_utils11.mergeRefs)(inputRef, ref),
|
1627
1638
|
...formControlProps,
|
1628
|
-
role: "combobox",
|
1629
|
-
"aria-haspopup": "listbox",
|
1630
|
-
"aria-autocomplete": "list",
|
1631
|
-
"aria-expanded": isOpen,
|
1632
1639
|
"aria-activedescendant": (_a = value(focusedIndex)) == null ? void 0 : _a.node.id,
|
1640
|
+
"aria-autocomplete": "list",
|
1633
1641
|
"aria-controls": (_b = listRef.current) == null ? void 0 : _b.id,
|
1642
|
+
"aria-expanded": isOpen,
|
1643
|
+
"aria-haspopup": "listbox",
|
1634
1644
|
autoCapitalize: "none",
|
1635
1645
|
autoComplete: "off",
|
1646
|
+
role: "combobox",
|
1636
1647
|
spellCheck: "false",
|
1637
1648
|
...inputProps,
|
1638
1649
|
...props,
|
@@ -1641,15 +1652,15 @@ var useAutocompleteInput = () => {
|
|
1641
1652
|
pointerEvents: formControlProps.disabled || isAllSelected ? "none" : "auto",
|
1642
1653
|
tabIndex: isAllSelected ? -1 : 0,
|
1643
1654
|
onChange: (0, import_utils11.handlerAll)(props.onChange, onSearch),
|
1644
|
-
onCompositionStart: (0, import_utils11.handlerAll)(
|
1645
|
-
props.onCompositionStart,
|
1646
|
-
inputProps.onCompositionStart,
|
1647
|
-
onCompositionStart
|
1648
|
-
),
|
1649
1655
|
onCompositionEnd: (0, import_utils11.handlerAll)(
|
1650
1656
|
props.onCompositionEnd,
|
1651
1657
|
inputProps.onCompositionEnd,
|
1652
1658
|
onCompositionEnd
|
1659
|
+
),
|
1660
|
+
onCompositionStart: (0, import_utils11.handlerAll)(
|
1661
|
+
props.onCompositionStart,
|
1662
|
+
inputProps.onCompositionStart,
|
1663
|
+
onCompositionStart
|
1653
1664
|
)
|
1654
1665
|
};
|
1655
1666
|
},
|
@@ -1680,46 +1691,46 @@ var Autocomplete = (0, import_core9.forwardRef)(
|
|
1680
1691
|
const [styles, mergedProps] = (0, import_core9.useComponentMultiStyle)("Autocomplete", props);
|
1681
1692
|
let {
|
1682
1693
|
className,
|
1683
|
-
|
1694
|
+
children,
|
1684
1695
|
color,
|
1696
|
+
defaultValue = "",
|
1697
|
+
footer,
|
1685
1698
|
h,
|
1699
|
+
header,
|
1686
1700
|
height,
|
1687
1701
|
minH,
|
1688
1702
|
minHeight,
|
1689
1703
|
containerProps,
|
1690
1704
|
contentProps,
|
1691
|
-
|
1705
|
+
createProps,
|
1706
|
+
emptyProps,
|
1692
1707
|
fieldProps,
|
1693
|
-
inputProps,
|
1694
1708
|
iconProps,
|
1709
|
+
inputProps,
|
1710
|
+
listProps,
|
1695
1711
|
portalProps = { isDisabled: true },
|
1696
|
-
createProps,
|
1697
|
-
emptyProps,
|
1698
|
-
header,
|
1699
|
-
footer,
|
1700
|
-
children,
|
1701
1712
|
...computedProps
|
1702
1713
|
} = (0, import_core9.omitThemeProps)(mergedProps);
|
1703
1714
|
const {
|
1704
|
-
|
1705
|
-
|
1715
|
+
allowCreate,
|
1716
|
+
computedChildren,
|
1706
1717
|
descendants,
|
1718
|
+
inputValue,
|
1719
|
+
isEmpty,
|
1720
|
+
value,
|
1707
1721
|
formControlProps,
|
1708
|
-
getPopoverProps,
|
1709
1722
|
getContainerProps,
|
1710
1723
|
getFieldProps,
|
1711
|
-
|
1712
|
-
|
1713
|
-
inputValue,
|
1714
|
-
computedChildren,
|
1724
|
+
getPopoverProps,
|
1725
|
+
onClose,
|
1715
1726
|
...rest
|
1716
|
-
} = useAutocomplete({ ...computedProps,
|
1727
|
+
} = useAutocomplete({ ...computedProps, children, defaultValue });
|
1717
1728
|
h != null ? h : h = height;
|
1718
1729
|
minH != null ? minH : minH = minHeight;
|
1719
1730
|
const css = {
|
1720
|
-
w: "100%",
|
1721
|
-
h: "fit-content",
|
1722
1731
|
color,
|
1732
|
+
h: "fit-content",
|
1733
|
+
w: "100%",
|
1723
1734
|
...styles.container
|
1724
1735
|
};
|
1725
1736
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
@@ -1727,13 +1738,13 @@ var Autocomplete = (0, import_core9.forwardRef)(
|
|
1727
1738
|
{
|
1728
1739
|
value: {
|
1729
1740
|
...rest,
|
1730
|
-
value,
|
1731
|
-
onClose,
|
1732
|
-
formControlProps,
|
1733
|
-
inputValue,
|
1734
1741
|
allowCreate,
|
1742
|
+
inputValue,
|
1735
1743
|
isEmpty,
|
1736
|
-
styles
|
1744
|
+
styles,
|
1745
|
+
value,
|
1746
|
+
formControlProps,
|
1747
|
+
onClose
|
1737
1748
|
},
|
1738
1749
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover2.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1739
1750
|
import_core9.ui.div,
|
@@ -1764,8 +1775,8 @@ var Autocomplete = (0, import_core9.forwardRef)(
|
|
1764
1775
|
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
1765
1776
|
AutocompleteList,
|
1766
1777
|
{
|
1767
|
-
header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
|
1768
1778
|
footer: (0, import_utils12.runIfFunc)(footer, { value, onClose }),
|
1779
|
+
header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
|
1769
1780
|
contentProps,
|
1770
1781
|
...listProps,
|
1771
1782
|
children: [
|
@@ -1776,8 +1787,8 @@ var Autocomplete = (0, import_core9.forwardRef)(
|
|
1776
1787
|
) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
1777
1788
|
AutocompleteList,
|
1778
1789
|
{
|
1779
|
-
header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
|
1780
1790
|
footer: (0, import_utils12.runIfFunc)(footer, { value, onClose }),
|
1791
|
+
header: (0, import_utils12.runIfFunc)(header, { value, onClose }),
|
1781
1792
|
contentProps,
|
1782
1793
|
...listProps,
|
1783
1794
|
children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, { ...emptyProps })
|
@@ -1794,14 +1805,14 @@ Autocomplete.displayName = "Autocomplete";
|
|
1794
1805
|
Autocomplete.__ui__ = "Autocomplete";
|
1795
1806
|
var AutocompleteField = (0, import_core9.forwardRef)(
|
1796
1807
|
({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {
|
1797
|
-
const {
|
1808
|
+
const { inputValue, label, styles } = useAutocompleteContext();
|
1798
1809
|
const { getInputProps } = useAutocompleteInput();
|
1799
1810
|
const css = {
|
1800
|
-
|
1811
|
+
alignItems: "center",
|
1812
|
+
display: "flex",
|
1801
1813
|
h,
|
1802
1814
|
minH,
|
1803
|
-
|
1804
|
-
alignItems: "center",
|
1815
|
+
pe: "2rem",
|
1805
1816
|
...styles.field,
|
1806
1817
|
cursor: "text"
|
1807
1818
|
};
|
@@ -1816,8 +1827,8 @@ var AutocompleteField = (0, import_core9.forwardRef)(
|
|
1816
1827
|
{
|
1817
1828
|
className: "ui-autocomplete__field__input",
|
1818
1829
|
display: "inline-block",
|
1819
|
-
w: "100%",
|
1820
1830
|
placeholder,
|
1831
|
+
w: "100%",
|
1821
1832
|
...getInputProps(
|
1822
1833
|
{ ...inputProps, value: inputValue || label || "" },
|
1823
1834
|
ref
|
@@ -1846,58 +1857,58 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1846
1857
|
);
|
1847
1858
|
let {
|
1848
1859
|
className,
|
1849
|
-
|
1850
|
-
|
1851
|
-
separator,
|
1852
|
-
isClearable = true,
|
1860
|
+
children,
|
1861
|
+
closeOnSelect = false,
|
1853
1862
|
color,
|
1863
|
+
component,
|
1864
|
+
defaultValue = [],
|
1865
|
+
footer,
|
1854
1866
|
h,
|
1867
|
+
header,
|
1855
1868
|
height,
|
1869
|
+
isClearable = true,
|
1870
|
+
keepPlaceholder = false,
|
1856
1871
|
minH,
|
1857
1872
|
minHeight,
|
1858
|
-
|
1859
|
-
|
1873
|
+
separator,
|
1874
|
+
clearIconProps,
|
1860
1875
|
containerProps,
|
1861
1876
|
contentProps,
|
1862
|
-
|
1877
|
+
createProps,
|
1878
|
+
emptyProps,
|
1863
1879
|
fieldProps,
|
1864
|
-
inputProps,
|
1865
1880
|
iconProps,
|
1866
|
-
|
1881
|
+
inputProps,
|
1882
|
+
listProps,
|
1867
1883
|
portalProps = { isDisabled: true },
|
1868
|
-
createProps,
|
1869
|
-
emptyProps,
|
1870
|
-
header,
|
1871
|
-
footer,
|
1872
|
-
children,
|
1873
1884
|
...computedProps
|
1874
1885
|
} = (0, import_core10.omitThemeProps)(mergedProps);
|
1875
1886
|
const {
|
1876
|
-
|
1877
|
-
|
1887
|
+
allowCreate,
|
1888
|
+
computedChildren,
|
1878
1889
|
descendants,
|
1890
|
+
inputValue,
|
1891
|
+
isEmpty,
|
1892
|
+
value,
|
1879
1893
|
formControlProps,
|
1880
|
-
getPopoverProps,
|
1881
1894
|
getContainerProps,
|
1882
1895
|
getFieldProps,
|
1883
|
-
|
1884
|
-
isEmpty,
|
1885
|
-
inputValue,
|
1886
|
-
computedChildren,
|
1896
|
+
getPopoverProps,
|
1887
1897
|
onClear,
|
1898
|
+
onClose,
|
1888
1899
|
...rest
|
1889
1900
|
} = useAutocomplete({
|
1890
1901
|
...computedProps,
|
1891
|
-
|
1902
|
+
children,
|
1892
1903
|
closeOnSelect,
|
1893
|
-
|
1904
|
+
defaultValue
|
1894
1905
|
});
|
1895
1906
|
h != null ? h : h = height;
|
1896
1907
|
minH != null ? minH : minH = minHeight;
|
1897
1908
|
const css = {
|
1898
|
-
w: "100%",
|
1899
|
-
h: "fit-content",
|
1900
1909
|
color,
|
1910
|
+
h: "fit-content",
|
1911
|
+
w: "100%",
|
1901
1912
|
...styles.container
|
1902
1913
|
};
|
1903
1914
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
@@ -1905,13 +1916,13 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1905
1916
|
{
|
1906
1917
|
value: {
|
1907
1918
|
...rest,
|
1908
|
-
value,
|
1909
|
-
onClose,
|
1910
|
-
formControlProps,
|
1911
|
-
inputValue,
|
1912
1919
|
allowCreate,
|
1920
|
+
inputValue,
|
1913
1921
|
isEmpty,
|
1914
|
-
styles
|
1922
|
+
styles,
|
1923
|
+
value,
|
1924
|
+
formControlProps,
|
1925
|
+
onClose
|
1915
1926
|
},
|
1916
1927
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover3.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
1917
1928
|
import_core10.ui.div,
|
@@ -1930,10 +1941,10 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1930
1941
|
MultiAutocompleteField,
|
1931
1942
|
{
|
1932
1943
|
component,
|
1933
|
-
separator,
|
1934
|
-
keepPlaceholder,
|
1935
1944
|
h,
|
1945
|
+
keepPlaceholder,
|
1936
1946
|
minH,
|
1947
|
+
separator,
|
1937
1948
|
inputProps,
|
1938
1949
|
...getFieldProps(fieldProps, ref)
|
1939
1950
|
}
|
@@ -1952,8 +1963,8 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1952
1963
|
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_portal2.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
1953
1964
|
AutocompleteList,
|
1954
1965
|
{
|
1955
|
-
header: (0, import_utils13.runIfFunc)(header, { value, onClose }),
|
1956
1966
|
footer: (0, import_utils13.runIfFunc)(footer, { value, onClose }),
|
1967
|
+
header: (0, import_utils13.runIfFunc)(header, { value, onClose }),
|
1957
1968
|
contentProps,
|
1958
1969
|
...listProps,
|
1959
1970
|
children: [
|
@@ -1964,8 +1975,8 @@ var MultiAutocomplete = (0, import_core10.forwardRef)(
|
|
1964
1975
|
) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_portal2.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
1965
1976
|
AutocompleteList,
|
1966
1977
|
{
|
1967
|
-
header: (0, import_utils13.runIfFunc)(header, { value, onClose }),
|
1968
1978
|
footer: (0, import_utils13.runIfFunc)(footer, { value, onClose }),
|
1979
|
+
header: (0, import_utils13.runIfFunc)(header, { value, onClose }),
|
1969
1980
|
contentProps,
|
1970
1981
|
...listProps,
|
1971
1982
|
children: allowCreate && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AutocompleteEmpty, { ...emptyProps })
|
@@ -1984,34 +1995,36 @@ var MultiAutocompleteField = (0, import_core10.forwardRef)(
|
|
1984
1995
|
({
|
1985
1996
|
className,
|
1986
1997
|
component,
|
1987
|
-
separator = ",",
|
1988
|
-
keepPlaceholder,
|
1989
1998
|
h,
|
1999
|
+
keepPlaceholder,
|
1990
2000
|
minH,
|
1991
2001
|
placeholder,
|
2002
|
+
separator = ",",
|
1992
2003
|
inputProps,
|
1993
2004
|
...rest
|
1994
2005
|
}, ref) => {
|
1995
|
-
const {
|
2006
|
+
const { inputRef, inputValue, isOpen, label, styles, value, onChange } = useAutocompleteContext();
|
1996
2007
|
const { getInputProps } = useAutocompleteInput();
|
1997
2008
|
const cloneChildren = (0, import_react6.useMemo)(() => {
|
1998
2009
|
if (!(label == null ? void 0 : label.length)) return null;
|
1999
2010
|
if (component) {
|
2000
2011
|
return label.map((label2, index) => {
|
2012
|
+
if (!value[index]) return null;
|
2001
2013
|
const onRemove = (ev) => {
|
2014
|
+
if (!value[index]) return;
|
2002
2015
|
ev.stopPropagation();
|
2003
2016
|
onChange(value[index]);
|
2004
2017
|
if (inputRef.current) inputRef.current.focus();
|
2005
2018
|
};
|
2006
2019
|
const el = component({
|
2007
|
-
value: value[index],
|
2008
|
-
label: label2,
|
2009
2020
|
index,
|
2021
|
+
label: label2,
|
2022
|
+
value: value[index],
|
2010
2023
|
onRemove
|
2011
2024
|
});
|
2012
2025
|
const style = {
|
2013
|
-
marginBlockStart: "0.125rem",
|
2014
2026
|
marginBlockEnd: "0.125rem",
|
2027
|
+
marginBlockStart: "0.125rem",
|
2015
2028
|
marginInlineEnd: "0.25rem"
|
2016
2029
|
};
|
2017
2030
|
return el ? (0, import_react6.cloneElement)(el, { key: index, style }) : null;
|
@@ -2027,12 +2040,12 @@ var MultiAutocompleteField = (0, import_core10.forwardRef)(
|
|
2027
2040
|
}
|
2028
2041
|
}, [label, component, value, onChange, isOpen, inputRef, separator]);
|
2029
2042
|
const css = {
|
2030
|
-
|
2031
|
-
h,
|
2032
|
-
minH,
|
2043
|
+
alignItems: "center",
|
2033
2044
|
display: "flex",
|
2034
2045
|
flexWrap: "wrap",
|
2035
|
-
|
2046
|
+
h,
|
2047
|
+
minH,
|
2048
|
+
pe: "2rem",
|
2036
2049
|
...styles.field,
|
2037
2050
|
cursor: "text"
|
2038
2051
|
};
|
@@ -2040,25 +2053,25 @@ var MultiAutocompleteField = (0, import_core10.forwardRef)(
|
|
2040
2053
|
import_core10.ui.div,
|
2041
2054
|
{
|
2042
2055
|
className: (0, import_utils13.cx)("ui-multi-autocomplete__field", className),
|
2043
|
-
__css: css,
|
2044
2056
|
py: (label == null ? void 0 : label.length) && component ? "0.125rem" : void 0,
|
2057
|
+
__css: css,
|
2045
2058
|
...rest,
|
2046
2059
|
children: [
|
2047
2060
|
cloneChildren,
|
2048
2061
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
2049
2062
|
import_core10.ui.input,
|
2050
2063
|
{
|
2051
|
-
"aria-label": "Input value",
|
2052
2064
|
className: "ui-multi-autocomplete__field__input",
|
2065
|
+
"aria-label": "Input value",
|
2066
|
+
"aria-multiselectable": "true",
|
2053
2067
|
display: "inline-block",
|
2054
2068
|
flex: "1",
|
2069
|
+
marginBlockEnd: "0.125rem",
|
2070
|
+
marginBlockStart: "0.125rem",
|
2055
2071
|
minW: "0px",
|
2056
2072
|
overflow: "hidden",
|
2057
|
-
|
2058
|
-
|
2059
|
-
"aria-multiselectable": "true",
|
2060
|
-
placeholder: !label || !(label == null ? void 0 : label.length) || keepPlaceholder && isOpen ? placeholder : void 0,
|
2061
|
-
...getInputProps({ ...inputProps, value: inputValue != null ? inputValue : "" }, ref)
|
2073
|
+
placeholder: !(label == null ? void 0 : label.length) || keepPlaceholder && isOpen ? placeholder : void 0,
|
2074
|
+
...getInputProps({ ...inputProps, value: inputValue }, ref)
|
2062
2075
|
}
|
2063
2076
|
)
|
2064
2077
|
]
|