@yamada-ui/autocomplete 0.6.0 → 0.6.2
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.mjs +1 -1
- package/dist/autocomplete-empty.mjs +1 -1
- package/dist/autocomplete-icon.mjs +1 -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.mjs +1 -1
- package/dist/autocomplete-option.d.mts +1 -1
- package/dist/autocomplete-option.d.ts +1 -1
- package/dist/autocomplete-option.js +3 -3
- 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 +22 -29
- package/dist/autocomplete.mjs +1 -1
- package/dist/{chunk-TZHEVPHW.mjs → chunk-VACNCD65.mjs} +31 -46
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -46
- package/dist/index.mjs +1 -1
- package/dist/multi-autocomplete.d.mts +2 -2
- package/dist/multi-autocomplete.d.ts +2 -2
- package/dist/multi-autocomplete.js +29 -44
- package/dist/multi-autocomplete.mjs +1 -1
- package/dist/{use-autocomplete-72ef1a50.d.ts → use-autocomplete-3c0916c6.d.ts} +4 -4
- package/dist/use-autocomplete.d.mts +1 -1
- package/dist/use-autocomplete.d.ts +1 -1
- package/dist/use-autocomplete.js +20 -27
- package/dist/use-autocomplete.mjs +1 -1
- package/package.json +2 -2
package/dist/use-autocomplete.js
CHANGED
|
@@ -380,7 +380,7 @@ var useAutocomplete = ({
|
|
|
380
380
|
defaultValue: rest.defaultValue,
|
|
381
381
|
onChange: rest.onChange
|
|
382
382
|
});
|
|
383
|
-
const [
|
|
383
|
+
const [label, setLabel] = (0, import_react2.useState)(void 0);
|
|
384
384
|
const [inputValue, setInputValue] = (0, import_react2.useState)("");
|
|
385
385
|
const [focusedIndex, setFocusedIndex] = (0, import_react2.useState)(-1);
|
|
386
386
|
const [isAllSelected, setIsAllSelected] = (0, import_react2.useState)(false);
|
|
@@ -415,16 +415,16 @@ var useAutocomplete = ({
|
|
|
415
415
|
const validChildren = (0, import_utils4.getValidChildren)(children);
|
|
416
416
|
const computedChildren = resolvedItems == null ? void 0 : resolvedItems.map((item, i) => {
|
|
417
417
|
if ("value" in item) {
|
|
418
|
-
const { label, value: value2, ...props } = item;
|
|
419
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteOption, { value: value2, ...props, children:
|
|
418
|
+
const { label: label2, value: value2, ...props } = item;
|
|
419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteOption, { value: value2, ...props, children: label2 }, i);
|
|
420
420
|
} else if ("items" in item) {
|
|
421
|
-
const { label, items: items2 = [], ...props } = item;
|
|
421
|
+
const { label: label2, items: items2 = [], ...props } = item;
|
|
422
422
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
423
423
|
AutocompleteOptionGroup,
|
|
424
424
|
{
|
|
425
|
-
label,
|
|
425
|
+
label: label2,
|
|
426
426
|
...props,
|
|
427
|
-
children: items2.map(({ label:
|
|
427
|
+
children: items2.map(({ label: label3, value: value2, ...props2 }, i2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AutocompleteOption, { value: value2, ...props2, children: label3 }, i2))
|
|
428
428
|
},
|
|
429
429
|
i
|
|
430
430
|
);
|
|
@@ -622,7 +622,7 @@ var useAutocomplete = ({
|
|
|
622
622
|
},
|
|
623
623
|
[descendants, onFocusFirst]
|
|
624
624
|
);
|
|
625
|
-
const
|
|
625
|
+
const onChangeLabel = (0, import_react2.useCallback)(
|
|
626
626
|
(newValue, runOmit = true) => {
|
|
627
627
|
const enabledValues2 = descendants.enabledValues();
|
|
628
628
|
const selectedValues2 = enabledValues2.filter(({ node }) => node.dataset.value === newValue).map(({ node }) => {
|
|
@@ -633,7 +633,7 @@ var useAutocomplete = ({
|
|
|
633
633
|
selectedValues2.push(newValue);
|
|
634
634
|
setInputValue("");
|
|
635
635
|
}
|
|
636
|
-
|
|
636
|
+
setLabel((prev) => {
|
|
637
637
|
if (!isMulti) {
|
|
638
638
|
return selectedValues2[0];
|
|
639
639
|
} else {
|
|
@@ -671,20 +671,13 @@ var useAutocomplete = ({
|
|
|
671
671
|
return format((_a = node.textContent) != null ? _a : "").includes(newValue);
|
|
672
672
|
}
|
|
673
673
|
).length > 0;
|
|
674
|
-
|
|
674
|
+
onChangeLabel(newValue);
|
|
675
675
|
if (!allowFree || isHit2) {
|
|
676
676
|
setInputValue("");
|
|
677
677
|
}
|
|
678
678
|
rebirthOptions(false);
|
|
679
679
|
},
|
|
680
|
-
[
|
|
681
|
-
allowFree,
|
|
682
|
-
onChangeDisplayValue,
|
|
683
|
-
rebirthOptions,
|
|
684
|
-
setValue,
|
|
685
|
-
descendants,
|
|
686
|
-
format
|
|
687
|
-
]
|
|
680
|
+
[allowFree, onChangeLabel, rebirthOptions, setValue, descendants, format]
|
|
688
681
|
);
|
|
689
682
|
const onSelect = (0, import_react2.useCallback)(() => {
|
|
690
683
|
var _a, _b;
|
|
@@ -745,7 +738,7 @@ var useAutocomplete = ({
|
|
|
745
738
|
newItems = [...newItems, newItem];
|
|
746
739
|
} else {
|
|
747
740
|
const i = newItems.findIndex(
|
|
748
|
-
({ label }) =>
|
|
741
|
+
({ label: label2 }) => label2 === firstInsertPositionItem
|
|
749
742
|
);
|
|
750
743
|
const targetItem = newItems[i];
|
|
751
744
|
if (i !== -1 && "items" in targetItem) {
|
|
@@ -790,11 +783,11 @@ var useAutocomplete = ({
|
|
|
790
783
|
(ev) => {
|
|
791
784
|
ev.stopPropagation();
|
|
792
785
|
setValue([]);
|
|
793
|
-
|
|
786
|
+
setLabel(void 0);
|
|
794
787
|
setInputValue("");
|
|
795
788
|
rebirthOptions();
|
|
796
789
|
},
|
|
797
|
-
[
|
|
790
|
+
[setLabel, setInputValue, setValue, rebirthOptions]
|
|
798
791
|
);
|
|
799
792
|
const onClick = (0, import_react2.useCallback)(() => {
|
|
800
793
|
if (isOpen) {
|
|
@@ -836,7 +829,7 @@ var useAutocomplete = ({
|
|
|
836
829
|
return;
|
|
837
830
|
if (isComposition.current)
|
|
838
831
|
return;
|
|
839
|
-
const enabledDelete =
|
|
832
|
+
const enabledDelete = label === inputValue || !inputValue.length;
|
|
840
833
|
const actions = {
|
|
841
834
|
ArrowDown: isFocused ? () => onFocusNext() : !isOpen ? (0, import_utils4.funcAll)(onOpen, onFocusFirstOrSelected) : void 0,
|
|
842
835
|
ArrowUp: isFocused ? () => onFocusPrev() : !isOpen ? (0, import_utils4.funcAll)(onOpen, onFocusLastOrSelected) : void 0,
|
|
@@ -861,7 +854,7 @@ var useAutocomplete = ({
|
|
|
861
854
|
[
|
|
862
855
|
allowFree,
|
|
863
856
|
formControlProps,
|
|
864
|
-
|
|
857
|
+
label,
|
|
865
858
|
inputValue,
|
|
866
859
|
onOpen,
|
|
867
860
|
isFocused,
|
|
@@ -967,7 +960,7 @@ var useAutocomplete = ({
|
|
|
967
960
|
id,
|
|
968
961
|
descendants,
|
|
969
962
|
value,
|
|
970
|
-
|
|
963
|
+
label,
|
|
971
964
|
inputValue,
|
|
972
965
|
isHit,
|
|
973
966
|
isEmpty,
|
|
@@ -985,7 +978,7 @@ var useAutocomplete = ({
|
|
|
985
978
|
optionProps,
|
|
986
979
|
formControlProps,
|
|
987
980
|
setFocusedIndex,
|
|
988
|
-
|
|
981
|
+
onChangeLabel,
|
|
989
982
|
onChange,
|
|
990
983
|
onSearch,
|
|
991
984
|
onCreate,
|
|
@@ -1187,7 +1180,7 @@ var useAutocompleteOption = (props) => {
|
|
|
1187
1180
|
value,
|
|
1188
1181
|
omitSelectedValues,
|
|
1189
1182
|
onChange,
|
|
1190
|
-
|
|
1183
|
+
onChangeLabel,
|
|
1191
1184
|
focusedIndex,
|
|
1192
1185
|
setFocusedIndex,
|
|
1193
1186
|
onClose,
|
|
@@ -1261,8 +1254,8 @@ var useAutocompleteOption = (props) => {
|
|
|
1261
1254
|
(0, import_react2.useEffect)(() => {
|
|
1262
1255
|
var _a2;
|
|
1263
1256
|
if (isSelected)
|
|
1264
|
-
|
|
1265
|
-
}, [computedProps, isSelected,
|
|
1257
|
+
onChangeLabel((_a2 = computedProps.value) != null ? _a2 : "", false);
|
|
1258
|
+
}, [computedProps, isSelected, onChangeLabel]);
|
|
1266
1259
|
const getOptionProps = (0, import_react2.useCallback)(
|
|
1267
1260
|
(props2 = {}, ref = null) => {
|
|
1268
1261
|
var _a2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/autocomplete",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Yamada UI autocomplete component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yamada",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@yamada-ui/core": "0.12.7",
|
|
40
40
|
"@yamada-ui/utils": "0.3.3",
|
|
41
41
|
"@yamada-ui/icon": "0.3.17",
|
|
42
|
-
"@yamada-ui/select": "0.5.
|
|
42
|
+
"@yamada-ui/select": "0.5.8",
|
|
43
43
|
"@yamada-ui/form-control": "0.3.20",
|
|
44
44
|
"@yamada-ui/popover": "0.3.24",
|
|
45
45
|
"@yamada-ui/use-descendant": "0.2.6",
|