@yamada-ui/autocomplete 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autocomplete-create.js +24 -17
- package/dist/autocomplete-create.mjs +1 -1
- package/dist/autocomplete-empty.js +24 -17
- package/dist/autocomplete-empty.mjs +1 -1
- package/dist/autocomplete-icon.js +30 -23
- package/dist/autocomplete-icon.mjs +1 -1
- package/dist/autocomplete-list.js +4 -1
- package/dist/autocomplete-list.mjs +1 -1
- package/dist/autocomplete-option-group.d.mts +1 -1
- package/dist/autocomplete-option-group.d.ts +1 -1
- package/dist/autocomplete-option-group.js +10 -5
- package/dist/autocomplete-option-group.mjs +1 -1
- package/dist/autocomplete-option.d.mts +1 -1
- package/dist/autocomplete-option.d.ts +1 -1
- package/dist/autocomplete-option.js +33 -22
- package/dist/autocomplete-option.mjs +1 -1
- package/dist/autocomplete.d.mts +1 -1
- package/dist/autocomplete.d.ts +1 -1
- package/dist/autocomplete.js +226 -120
- package/dist/autocomplete.mjs +1 -1
- package/dist/{chunk-5O3XEEJE.mjs → chunk-ZVZP7IWT.mjs} +352 -229
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +345 -229
- package/dist/index.mjs +1 -1
- package/dist/multi-autocomplete.d.mts +1 -1
- package/dist/multi-autocomplete.d.ts +1 -1
- package/dist/multi-autocomplete.js +245 -149
- package/dist/multi-autocomplete.mjs +1 -1
- package/dist/{use-autocomplete-cbe9b443.d.ts → use-autocomplete-2422c1c8.d.ts} +25 -5
- package/dist/use-autocomplete.d.mts +1 -1
- package/dist/use-autocomplete.d.ts +1 -1
- package/dist/use-autocomplete.js +131 -45
- package/dist/use-autocomplete.mjs +1 -1
- package/package.json +11 -11
package/dist/autocomplete.js
CHANGED
|
@@ -337,7 +337,10 @@ var kanaMap = {
|
|
|
337
337
|
"\uFF65": "\u30FB"
|
|
338
338
|
};
|
|
339
339
|
var defaultFormat = (value) => {
|
|
340
|
-
value = value.replace(
|
|
340
|
+
value = value.replace(
|
|
341
|
+
/[!-~]/g,
|
|
342
|
+
(v) => String.fromCharCode(v.charCodeAt(0) - 65248)
|
|
343
|
+
);
|
|
341
344
|
const reg = new RegExp("(" + Object.keys(kanaMap).join("|") + ")", "g");
|
|
342
345
|
value = value.replace(reg, (v) => kanaMap[v]).replace(/゙/g, "\u309B").replace(/゚/g, "\u309C");
|
|
343
346
|
value = value.toUpperCase();
|
|
@@ -394,7 +397,14 @@ var useAutocomplete = ({
|
|
|
394
397
|
const { id } = rest;
|
|
395
398
|
const formControlProps = (0, import_utils6.pickObject)(rest, import_form_control.formControlProperties);
|
|
396
399
|
const [containerProps, inputProps] = (0, import_utils6.splitObject)(
|
|
397
|
-
(0, import_utils6.omitObject)(rest, [
|
|
400
|
+
(0, import_utils6.omitObject)(rest, [
|
|
401
|
+
"id",
|
|
402
|
+
"value",
|
|
403
|
+
"defaultValue",
|
|
404
|
+
"onChange",
|
|
405
|
+
"month",
|
|
406
|
+
"onChangeMonth"
|
|
407
|
+
]),
|
|
398
408
|
import_core6.layoutStylesProperties
|
|
399
409
|
);
|
|
400
410
|
const descendants = useAutocompleteDescendants();
|
|
@@ -446,9 +456,17 @@ var useAutocomplete = ({
|
|
|
446
456
|
if (!(0, import_utils6.isArray)(value2)) {
|
|
447
457
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutocompleteOption, { value: value2, ...props, children: label }, i);
|
|
448
458
|
} else {
|
|
449
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
450
|
-
|
|
451
|
-
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
460
|
+
AutocompleteOptionGroup,
|
|
461
|
+
{
|
|
462
|
+
label,
|
|
463
|
+
...props,
|
|
464
|
+
children: value2.map(
|
|
465
|
+
({ label: label2, value: value3, ...props2 }, i2) => !(0, import_utils6.isArray)(value3) ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutocompleteOption, { value: value3, ...props2, children: label2 }, i2) : null
|
|
466
|
+
)
|
|
467
|
+
},
|
|
468
|
+
i
|
|
469
|
+
);
|
|
452
470
|
}
|
|
453
471
|
});
|
|
454
472
|
const isEmpty = !validChildren.length && !(computedChildren == null ? void 0 : computedChildren.length);
|
|
@@ -472,7 +490,9 @@ var useAutocomplete = ({
|
|
|
472
490
|
const id2 = setTimeout(() => {
|
|
473
491
|
if (isEmpty || isAllSelected)
|
|
474
492
|
return;
|
|
475
|
-
const first = descendants.enabledfirstValue(
|
|
493
|
+
const first = descendants.enabledfirstValue(
|
|
494
|
+
({ node }) => "target" in node.dataset
|
|
495
|
+
);
|
|
476
496
|
if (!first)
|
|
477
497
|
return;
|
|
478
498
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -500,7 +520,9 @@ var useAutocomplete = ({
|
|
|
500
520
|
const id2 = setTimeout(() => {
|
|
501
521
|
if (isEmpty || isAllSelected)
|
|
502
522
|
return;
|
|
503
|
-
const last = descendants.enabledlastValue(
|
|
523
|
+
const last = descendants.enabledlastValue(
|
|
524
|
+
({ node }) => "target" in node.dataset
|
|
525
|
+
);
|
|
504
526
|
if (!last)
|
|
505
527
|
return;
|
|
506
528
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -542,7 +564,10 @@ var useAutocomplete = ({
|
|
|
542
564
|
(index = focusedIndex) => {
|
|
543
565
|
const id2 = setTimeout(() => {
|
|
544
566
|
var _a;
|
|
545
|
-
const next = descendants.enabledNextValue(
|
|
567
|
+
const next = descendants.enabledNextValue(
|
|
568
|
+
index,
|
|
569
|
+
({ node }) => "target" in node.dataset
|
|
570
|
+
);
|
|
546
571
|
if (!next)
|
|
547
572
|
return;
|
|
548
573
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -558,13 +583,23 @@ var useAutocomplete = ({
|
|
|
558
583
|
});
|
|
559
584
|
timeoutIds.current.add(id2);
|
|
560
585
|
},
|
|
561
|
-
[
|
|
586
|
+
[
|
|
587
|
+
descendants,
|
|
588
|
+
enabledValues,
|
|
589
|
+
focusedIndex,
|
|
590
|
+
isMulti,
|
|
591
|
+
omitSelectedValues,
|
|
592
|
+
selectedIndexes
|
|
593
|
+
]
|
|
562
594
|
);
|
|
563
595
|
const onFocusPrev = (0, import_react.useCallback)(
|
|
564
596
|
(index = focusedIndex) => {
|
|
565
597
|
const id2 = setTimeout(() => {
|
|
566
598
|
var _a;
|
|
567
|
-
const prev = descendants.enabledPrevValue(
|
|
599
|
+
const prev = descendants.enabledPrevValue(
|
|
600
|
+
index,
|
|
601
|
+
({ node }) => "target" in node.dataset
|
|
602
|
+
);
|
|
568
603
|
if (!prev)
|
|
569
604
|
return;
|
|
570
605
|
if (!isMulti || !omitSelectedValues) {
|
|
@@ -580,7 +615,14 @@ var useAutocomplete = ({
|
|
|
580
615
|
});
|
|
581
616
|
timeoutIds.current.add(id2);
|
|
582
617
|
},
|
|
583
|
-
[
|
|
618
|
+
[
|
|
619
|
+
descendants,
|
|
620
|
+
enabledValues,
|
|
621
|
+
focusedIndex,
|
|
622
|
+
isMulti,
|
|
623
|
+
omitSelectedValues,
|
|
624
|
+
selectedIndexes
|
|
625
|
+
]
|
|
584
626
|
);
|
|
585
627
|
const onFocusFirstOrSelected = isEmptyValue || omitSelectedValues ? onFocusFirst : onFocusSelected;
|
|
586
628
|
const onFocusLastOrSelected = isEmptyValue || omitSelectedValues ? onFocusLast : onFocusSelected;
|
|
@@ -677,7 +719,15 @@ var useAutocomplete = ({
|
|
|
677
719
|
onClose();
|
|
678
720
|
if (omitSelectedValues)
|
|
679
721
|
onFocusNext();
|
|
680
|
-
}, [
|
|
722
|
+
}, [
|
|
723
|
+
closeOnSelect,
|
|
724
|
+
descendants,
|
|
725
|
+
focusedIndex,
|
|
726
|
+
omitSelectedValues,
|
|
727
|
+
onChange,
|
|
728
|
+
onClose,
|
|
729
|
+
onFocusNext
|
|
730
|
+
]);
|
|
681
731
|
const onSearch = (0, import_react.useCallback)(
|
|
682
732
|
(ev) => {
|
|
683
733
|
var _a;
|
|
@@ -714,12 +764,20 @@ var useAutocomplete = ({
|
|
|
714
764
|
} else if (firstInsertPositionOnCreate === "last") {
|
|
715
765
|
newOptions = [...newOptions, newOption];
|
|
716
766
|
} else {
|
|
717
|
-
const i = newOptions.findIndex(
|
|
767
|
+
const i = newOptions.findIndex(
|
|
768
|
+
({ label }) => label === firstInsertPositionOnCreate
|
|
769
|
+
);
|
|
718
770
|
if (i !== -1 && (0, import_utils6.isArray)(newOptions[i].value)) {
|
|
719
771
|
if (secondInsertPositionOnCreate === "first") {
|
|
720
|
-
newOptions[i].value = [
|
|
772
|
+
newOptions[i].value = [
|
|
773
|
+
newOption,
|
|
774
|
+
...newOptions[i].value
|
|
775
|
+
];
|
|
721
776
|
} else {
|
|
722
|
-
newOptions[i].value = [
|
|
777
|
+
newOptions[i].value = [
|
|
778
|
+
...newOptions[i].value,
|
|
779
|
+
newOption
|
|
780
|
+
];
|
|
723
781
|
}
|
|
724
782
|
} else {
|
|
725
783
|
console.warn(
|
|
@@ -730,7 +788,9 @@ var useAutocomplete = ({
|
|
|
730
788
|
setOptions(newOptions);
|
|
731
789
|
onChange(inputValue);
|
|
732
790
|
rebirthOptions(false);
|
|
733
|
-
const index = flattenOptions(newOptions).findIndex(
|
|
791
|
+
const index = flattenOptions(newOptions).findIndex(
|
|
792
|
+
({ value: value2 }) => value2 === inputValue
|
|
793
|
+
);
|
|
734
794
|
setFocusedIndex(index);
|
|
735
795
|
(_a = rest.onCreate) == null ? void 0 : _a.call(rest, newOption, newOptions);
|
|
736
796
|
}, [
|
|
@@ -849,7 +909,14 @@ var useAutocomplete = ({
|
|
|
849
909
|
} else {
|
|
850
910
|
setIsAllSelected(false);
|
|
851
911
|
}
|
|
852
|
-
}, [
|
|
912
|
+
}, [
|
|
913
|
+
omitSelectedValues,
|
|
914
|
+
value,
|
|
915
|
+
descendants,
|
|
916
|
+
isMulti,
|
|
917
|
+
onClose,
|
|
918
|
+
maxSelectedValues
|
|
919
|
+
]);
|
|
853
920
|
(0, import_utils6.useUpdateEffect)(() => {
|
|
854
921
|
if (isOpen)
|
|
855
922
|
return;
|
|
@@ -1051,7 +1118,10 @@ var useAutocompleteList = () => {
|
|
|
1051
1118
|
role: "select",
|
|
1052
1119
|
tabIndex: -1,
|
|
1053
1120
|
...props,
|
|
1054
|
-
onAnimationComplete: (0, import_utils6.handlerAll)(
|
|
1121
|
+
onAnimationComplete: (0, import_utils6.handlerAll)(
|
|
1122
|
+
props.onAnimationComplete,
|
|
1123
|
+
onAnimationComplete
|
|
1124
|
+
)
|
|
1055
1125
|
}),
|
|
1056
1126
|
[listRef, onAnimationComplete]
|
|
1057
1127
|
);
|
|
@@ -1059,15 +1129,20 @@ var useAutocompleteList = () => {
|
|
|
1059
1129
|
getListProps
|
|
1060
1130
|
};
|
|
1061
1131
|
};
|
|
1062
|
-
var useAutocompleteOptionGroup = ({
|
|
1132
|
+
var useAutocompleteOptionGroup = ({
|
|
1133
|
+
label,
|
|
1134
|
+
...rest
|
|
1135
|
+
}) => {
|
|
1063
1136
|
const { value, omitSelectedValues } = useAutocompleteContext();
|
|
1064
1137
|
const isMulti = (0, import_utils6.isArray)(value);
|
|
1065
1138
|
const descendants = useAutocompleteDescendantsContext();
|
|
1066
1139
|
const values = descendants.values();
|
|
1067
|
-
const selectedValues = isMulti && omitSelectedValues ? descendants.values(
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1140
|
+
const selectedValues = isMulti && omitSelectedValues ? descendants.values(
|
|
1141
|
+
({ node }) => {
|
|
1142
|
+
var _a;
|
|
1143
|
+
return value.includes((_a = node.dataset.value) != null ? _a : "");
|
|
1144
|
+
}
|
|
1145
|
+
) : [];
|
|
1071
1146
|
const selectedIndexes = selectedValues.map(({ index }) => index);
|
|
1072
1147
|
const childValues = values.filter(
|
|
1073
1148
|
({ node, index }) => {
|
|
@@ -1142,14 +1217,18 @@ var useAutocompleteOption = (props) => {
|
|
|
1142
1217
|
} = { ...optionProps, ...props };
|
|
1143
1218
|
const trulyDisabled = !!isDisabled && !isFocusable;
|
|
1144
1219
|
const itemRef = (0, import_react.useRef)(null);
|
|
1145
|
-
const { index, register, descendants } = useAutocompleteDescendant({
|
|
1220
|
+
const { index, register, descendants } = useAutocompleteDescendant({
|
|
1221
|
+
disabled: trulyDisabled
|
|
1222
|
+
});
|
|
1146
1223
|
const values = descendants.values();
|
|
1147
1224
|
const frontValues = values.slice(0, index);
|
|
1148
1225
|
const isMulti = (0, import_utils6.isArray)(value);
|
|
1149
|
-
const isDuplicated = !isMulti ? frontValues.some(
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1226
|
+
const isDuplicated = !isMulti ? frontValues.some(
|
|
1227
|
+
({ node }) => {
|
|
1228
|
+
var _a2;
|
|
1229
|
+
return node.dataset.value === ((_a2 = computedProps.value) != null ? _a2 : "");
|
|
1230
|
+
}
|
|
1231
|
+
) : false;
|
|
1153
1232
|
const isSelected = !isDuplicated && (!isMulti ? ((_a = computedProps.value) != null ? _a : "") === value : value.includes((_b = computedProps.value) != null ? _b : ""));
|
|
1154
1233
|
const isTarget = "target" in ((_d = (_c = itemRef.current) == null ? void 0 : _c.dataset) != null ? _d : {});
|
|
1155
1234
|
const isFocused = index === focusedIndex;
|
|
@@ -1328,103 +1407,119 @@ var AutocompleteIcon = (0, import_core7.forwardRef)(
|
|
|
1328
1407
|
}
|
|
1329
1408
|
})
|
|
1330
1409
|
);
|
|
1331
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.ui.div, { ref, className: (0, import_utils7.cx)("ui-autocomplete-icon", className), __css: css, ...rest, children: (0, import_utils7.isValidElement)(children) ? cloneChildren : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icon.ChevronIcon, {}) });
|
|
1332
|
-
}
|
|
1333
|
-
);
|
|
1334
|
-
var AutocompleteItemIcon = (0, import_core7.forwardRef)(
|
|
1335
|
-
({ className, ...rest }, ref) => {
|
|
1336
|
-
const { styles } = useAutocompleteContext();
|
|
1337
|
-
const css = {
|
|
1338
|
-
flexShrink: 0,
|
|
1339
|
-
display: "inline-flex",
|
|
1340
|
-
justifyContent: "center",
|
|
1341
|
-
alignItems: "center",
|
|
1342
|
-
fontSize: "0.85em",
|
|
1343
|
-
...styles.itemIcon
|
|
1344
|
-
};
|
|
1345
1410
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1346
|
-
import_core7.ui.
|
|
1411
|
+
import_core7.ui.div,
|
|
1347
1412
|
{
|
|
1348
1413
|
ref,
|
|
1349
|
-
className: (0, import_utils7.cx)("ui-autocomplete-
|
|
1414
|
+
className: (0, import_utils7.cx)("ui-autocomplete-icon", className),
|
|
1350
1415
|
__css: css,
|
|
1351
|
-
...rest
|
|
1416
|
+
...rest,
|
|
1417
|
+
children: (0, import_utils7.isValidElement)(children) ? cloneChildren : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icon.ChevronIcon, {})
|
|
1352
1418
|
}
|
|
1353
1419
|
);
|
|
1354
1420
|
}
|
|
1355
1421
|
);
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1359
|
-
var Autocomplete = (0, import_core8.forwardRef)((props, ref) => {
|
|
1360
|
-
const [styles, mergedProps] = (0, import_core8.useMultiComponentStyle)("Select", props);
|
|
1361
|
-
let {
|
|
1362
|
-
className,
|
|
1363
|
-
defaultValue = "",
|
|
1364
|
-
color,
|
|
1365
|
-
h,
|
|
1366
|
-
height,
|
|
1367
|
-
minH,
|
|
1368
|
-
minHeight,
|
|
1369
|
-
containerProps,
|
|
1370
|
-
listProps,
|
|
1371
|
-
inputProps,
|
|
1372
|
-
iconProps,
|
|
1373
|
-
children,
|
|
1374
|
-
...computedProps
|
|
1375
|
-
} = (0, import_core8.omitThemeProps)(mergedProps);
|
|
1376
|
-
const {
|
|
1377
|
-
descendants,
|
|
1378
|
-
formControlProps,
|
|
1379
|
-
getPopoverProps,
|
|
1380
|
-
getContainerProps,
|
|
1381
|
-
getFieldProps,
|
|
1382
|
-
createOption,
|
|
1383
|
-
isEmpty,
|
|
1384
|
-
inputValue,
|
|
1385
|
-
computedChildren,
|
|
1386
|
-
...rest
|
|
1387
|
-
} = useAutocomplete({ ...computedProps, defaultValue, children });
|
|
1388
|
-
h = h != null ? h : height;
|
|
1389
|
-
minH = minH != null ? minH : minHeight;
|
|
1422
|
+
var AutocompleteItemIcon = (0, import_core7.forwardRef)(({ className, ...rest }, ref) => {
|
|
1423
|
+
const { styles } = useAutocompleteContext();
|
|
1390
1424
|
const css = {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1425
|
+
flexShrink: 0,
|
|
1426
|
+
display: "inline-flex",
|
|
1427
|
+
justifyContent: "center",
|
|
1428
|
+
alignItems: "center",
|
|
1429
|
+
fontSize: "0.85em",
|
|
1430
|
+
...styles.itemIcon
|
|
1396
1431
|
};
|
|
1397
|
-
return /* @__PURE__ */ (0,
|
|
1398
|
-
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1433
|
+
import_core7.ui.span,
|
|
1399
1434
|
{
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
className: (0, import_utils8.cx)("ui-autocomplete", className),
|
|
1405
|
-
__css: css,
|
|
1406
|
-
...getContainerProps(containerProps),
|
|
1407
|
-
children: [
|
|
1408
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1409
|
-
AutocompleteField,
|
|
1410
|
-
{
|
|
1411
|
-
h,
|
|
1412
|
-
minH,
|
|
1413
|
-
inputProps,
|
|
1414
|
-
...getFieldProps({}, ref)
|
|
1415
|
-
}
|
|
1416
|
-
),
|
|
1417
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
1418
|
-
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1419
|
-
createOption ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
|
|
1420
|
-
children != null ? children : computedChildren
|
|
1421
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) })
|
|
1422
|
-
]
|
|
1423
|
-
}
|
|
1424
|
-
) })
|
|
1435
|
+
ref,
|
|
1436
|
+
className: (0, import_utils7.cx)("ui-autocomplete-item-icon", className),
|
|
1437
|
+
__css: css,
|
|
1438
|
+
...rest
|
|
1425
1439
|
}
|
|
1426
|
-
)
|
|
1440
|
+
);
|
|
1427
1441
|
});
|
|
1442
|
+
|
|
1443
|
+
// src/autocomplete.tsx
|
|
1444
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1445
|
+
var Autocomplete = (0, import_core8.forwardRef)(
|
|
1446
|
+
(props, ref) => {
|
|
1447
|
+
const [styles, mergedProps] = (0, import_core8.useMultiComponentStyle)("Select", props);
|
|
1448
|
+
let {
|
|
1449
|
+
className,
|
|
1450
|
+
defaultValue = "",
|
|
1451
|
+
color,
|
|
1452
|
+
h,
|
|
1453
|
+
height,
|
|
1454
|
+
minH,
|
|
1455
|
+
minHeight,
|
|
1456
|
+
containerProps,
|
|
1457
|
+
listProps,
|
|
1458
|
+
inputProps,
|
|
1459
|
+
iconProps,
|
|
1460
|
+
children,
|
|
1461
|
+
...computedProps
|
|
1462
|
+
} = (0, import_core8.omitThemeProps)(mergedProps);
|
|
1463
|
+
const {
|
|
1464
|
+
descendants,
|
|
1465
|
+
formControlProps,
|
|
1466
|
+
getPopoverProps,
|
|
1467
|
+
getContainerProps,
|
|
1468
|
+
getFieldProps,
|
|
1469
|
+
createOption,
|
|
1470
|
+
isEmpty,
|
|
1471
|
+
inputValue,
|
|
1472
|
+
computedChildren,
|
|
1473
|
+
...rest
|
|
1474
|
+
} = useAutocomplete({ ...computedProps, defaultValue, children });
|
|
1475
|
+
h = h != null ? h : height;
|
|
1476
|
+
minH = minH != null ? minH : minHeight;
|
|
1477
|
+
const css = {
|
|
1478
|
+
position: "relative",
|
|
1479
|
+
w: "100%",
|
|
1480
|
+
h: "fit-content",
|
|
1481
|
+
color,
|
|
1482
|
+
...styles.container
|
|
1483
|
+
};
|
|
1484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1485
|
+
AutocompleteProvider,
|
|
1486
|
+
{
|
|
1487
|
+
value: {
|
|
1488
|
+
...rest,
|
|
1489
|
+
formControlProps,
|
|
1490
|
+
inputValue,
|
|
1491
|
+
createOption,
|
|
1492
|
+
isEmpty,
|
|
1493
|
+
styles
|
|
1494
|
+
},
|
|
1495
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover2.Popover, { ...getPopoverProps(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1496
|
+
import_core8.ui.div,
|
|
1497
|
+
{
|
|
1498
|
+
className: (0, import_utils8.cx)("ui-autocomplete", className),
|
|
1499
|
+
__css: css,
|
|
1500
|
+
...getContainerProps(containerProps),
|
|
1501
|
+
children: [
|
|
1502
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1503
|
+
AutocompleteField,
|
|
1504
|
+
{
|
|
1505
|
+
h,
|
|
1506
|
+
minH,
|
|
1507
|
+
inputProps,
|
|
1508
|
+
...getFieldProps({}, ref)
|
|
1509
|
+
}
|
|
1510
|
+
),
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteIcon, { ...iconProps, ...formControlProps }),
|
|
1512
|
+
!isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(AutocompleteList, { ...listProps, children: [
|
|
1513
|
+
createOption ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}),
|
|
1514
|
+
children != null ? children : computedChildren
|
|
1515
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteList, { ...listProps, children: createOption && inputValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteCreate, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AutocompleteEmpty, {}) })
|
|
1516
|
+
]
|
|
1517
|
+
}
|
|
1518
|
+
) })
|
|
1519
|
+
}
|
|
1520
|
+
) });
|
|
1521
|
+
}
|
|
1522
|
+
);
|
|
1428
1523
|
var AutocompleteField = (0, import_core8.forwardRef)(
|
|
1429
1524
|
({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {
|
|
1430
1525
|
const { displayValue, inputValue, styles } = useAutocompleteContext();
|
|
@@ -1438,16 +1533,27 @@ var AutocompleteField = (0, import_core8.forwardRef)(
|
|
|
1438
1533
|
...styles.field,
|
|
1439
1534
|
cursor: "text"
|
|
1440
1535
|
};
|
|
1441
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover2.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1442
|
-
import_core8.ui.
|
|
1536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover2.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1537
|
+
import_core8.ui.div,
|
|
1443
1538
|
{
|
|
1444
|
-
className: "ui-autocomplete-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1539
|
+
className: (0, import_utils8.cx)("ui-autocomplete-field", className),
|
|
1540
|
+
__css: css,
|
|
1541
|
+
...rest,
|
|
1542
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1543
|
+
import_core8.ui.input,
|
|
1544
|
+
{
|
|
1545
|
+
className: "ui-autocomplete-input",
|
|
1546
|
+
display: "inline-block",
|
|
1547
|
+
w: "full",
|
|
1548
|
+
placeholder,
|
|
1549
|
+
...getInputProps(
|
|
1550
|
+
{ ...inputProps, value: inputValue || displayValue || "" },
|
|
1551
|
+
ref
|
|
1552
|
+
)
|
|
1553
|
+
}
|
|
1554
|
+
)
|
|
1449
1555
|
}
|
|
1450
|
-
) })
|
|
1556
|
+
) });
|
|
1451
1557
|
}
|
|
1452
1558
|
);
|
|
1453
1559
|
// Annotate the CommonJS export names for ESM import in node:
|