@xqmsg/ui-core 0.16.2 → 0.16.4
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/ui-core.cjs.development.js +41 -24
- package/dist/ui-core.cjs.development.js.map +1 -1
- package/dist/ui-core.cjs.production.min.js +1 -1
- package/dist/ui-core.cjs.production.min.js.map +1 -1
- package/dist/ui-core.esm.js +41 -24
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/StackedMultiSelect/index.tsx +27 -1
package/dist/ui-core.esm.js
CHANGED
|
@@ -900,37 +900,41 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
900
900
|
var scrollRef = useRef(null);
|
|
901
901
|
var inputRef = useRef(null);
|
|
902
902
|
|
|
903
|
-
var _useState = useState(
|
|
904
|
-
|
|
905
|
-
|
|
903
|
+
var _useState = useState(false),
|
|
904
|
+
isInit = _useState[0],
|
|
905
|
+
setIsInit = _useState[1];
|
|
906
906
|
|
|
907
|
-
var _useState2 = useState(
|
|
908
|
-
|
|
909
|
-
|
|
907
|
+
var _useState2 = useState([]),
|
|
908
|
+
localValues = _useState2[0],
|
|
909
|
+
setLocalValues = _useState2[1];
|
|
910
910
|
|
|
911
|
-
var _useState3 = useState(
|
|
912
|
-
|
|
913
|
-
|
|
911
|
+
var _useState3 = useState(options),
|
|
912
|
+
localOptions = _useState3[0],
|
|
913
|
+
setLocalOptions = _useState3[1];
|
|
914
914
|
|
|
915
915
|
var _useState4 = useState(false),
|
|
916
|
-
|
|
917
|
-
|
|
916
|
+
isFocussed = _useState4[0],
|
|
917
|
+
setIsFocussed = _useState4[1];
|
|
918
918
|
|
|
919
|
-
var _useState5 = useState(
|
|
920
|
-
|
|
921
|
-
|
|
919
|
+
var _useState5 = useState(false),
|
|
920
|
+
shouldSideScroll = _useState5[0],
|
|
921
|
+
setShouldSideScroll = _useState5[1];
|
|
922
922
|
|
|
923
|
-
var _useState6 = useState(
|
|
924
|
-
|
|
925
|
-
|
|
923
|
+
var _useState6 = useState(null),
|
|
924
|
+
optionIndex = _useState6[0],
|
|
925
|
+
setOptionIndex = _useState6[1];
|
|
926
926
|
|
|
927
|
-
var _useState7 = useState(''),
|
|
928
|
-
|
|
929
|
-
|
|
927
|
+
var _useState7 = useState('top'),
|
|
928
|
+
position = _useState7[0],
|
|
929
|
+
setPosition = _useState7[1];
|
|
930
930
|
|
|
931
931
|
var _useState8 = useState(''),
|
|
932
|
-
|
|
933
|
-
|
|
932
|
+
searchValue = _useState8[0],
|
|
933
|
+
setSearchValue = _useState8[1];
|
|
934
|
+
|
|
935
|
+
var _useState9 = useState(''),
|
|
936
|
+
debouncedSearchValue = _useState9[0],
|
|
937
|
+
setDebouncedSearchValue = _useState9[1];
|
|
934
938
|
|
|
935
939
|
console.log({
|
|
936
940
|
searchValue: searchValue,
|
|
@@ -951,6 +955,7 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
951
955
|
useEffect(function () {
|
|
952
956
|
if (watchedValue !== undefined && !watchedValue.length) {
|
|
953
957
|
setLocalValues([]);
|
|
958
|
+
setIsInit(true);
|
|
954
959
|
}
|
|
955
960
|
|
|
956
961
|
if (watchedValue !== undefined && watchedValue != null && watchedValue.length) {
|
|
@@ -964,13 +969,25 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
964
969
|
setShouldSideScroll(false);
|
|
965
970
|
}
|
|
966
971
|
|
|
972
|
+
if (isInit) return;
|
|
967
973
|
setLocalValues(watchedValue.split(',').filter(Boolean).map(function (value) {
|
|
968
974
|
return options.find(function (option) {
|
|
969
975
|
return option.value === value;
|
|
970
976
|
});
|
|
971
|
-
}));
|
|
977
|
+
})); // Filter out options that are already selected
|
|
978
|
+
|
|
979
|
+
setLocalOptions(function (prevLocalOptions) {
|
|
980
|
+
return prevLocalOptions.filter(function (localOption) {
|
|
981
|
+
return !watchedValue.split(',').filter(Boolean).map(function (value) {
|
|
982
|
+
return options.find(function (option) {
|
|
983
|
+
return option.value === value;
|
|
984
|
+
});
|
|
985
|
+
}).includes(localOption);
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
setIsInit(true);
|
|
972
989
|
}
|
|
973
|
-
}, [options, shouldSideScroll, watchedValue]);
|
|
990
|
+
}, [isInit, localOptions, localValues, options, shouldSideScroll, watchedValue]);
|
|
974
991
|
|
|
975
992
|
var handleChange = function handleChange(option) {
|
|
976
993
|
setShouldSideScroll(true);
|