@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
|
@@ -907,37 +907,41 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
907
907
|
var scrollRef = React.useRef(null);
|
|
908
908
|
var inputRef = React.useRef(null);
|
|
909
909
|
|
|
910
|
-
var _useState = React.useState(
|
|
911
|
-
|
|
912
|
-
|
|
910
|
+
var _useState = React.useState(false),
|
|
911
|
+
isInit = _useState[0],
|
|
912
|
+
setIsInit = _useState[1];
|
|
913
913
|
|
|
914
|
-
var _useState2 = React.useState(
|
|
915
|
-
|
|
916
|
-
|
|
914
|
+
var _useState2 = React.useState([]),
|
|
915
|
+
localValues = _useState2[0],
|
|
916
|
+
setLocalValues = _useState2[1];
|
|
917
917
|
|
|
918
|
-
var _useState3 = React.useState(
|
|
919
|
-
|
|
920
|
-
|
|
918
|
+
var _useState3 = React.useState(options),
|
|
919
|
+
localOptions = _useState3[0],
|
|
920
|
+
setLocalOptions = _useState3[1];
|
|
921
921
|
|
|
922
922
|
var _useState4 = React.useState(false),
|
|
923
|
-
|
|
924
|
-
|
|
923
|
+
isFocussed = _useState4[0],
|
|
924
|
+
setIsFocussed = _useState4[1];
|
|
925
925
|
|
|
926
|
-
var _useState5 = React.useState(
|
|
927
|
-
|
|
928
|
-
|
|
926
|
+
var _useState5 = React.useState(false),
|
|
927
|
+
shouldSideScroll = _useState5[0],
|
|
928
|
+
setShouldSideScroll = _useState5[1];
|
|
929
929
|
|
|
930
|
-
var _useState6 = React.useState(
|
|
931
|
-
|
|
932
|
-
|
|
930
|
+
var _useState6 = React.useState(null),
|
|
931
|
+
optionIndex = _useState6[0],
|
|
932
|
+
setOptionIndex = _useState6[1];
|
|
933
933
|
|
|
934
|
-
var _useState7 = React.useState(''),
|
|
935
|
-
|
|
936
|
-
|
|
934
|
+
var _useState7 = React.useState('top'),
|
|
935
|
+
position = _useState7[0],
|
|
936
|
+
setPosition = _useState7[1];
|
|
937
937
|
|
|
938
938
|
var _useState8 = React.useState(''),
|
|
939
|
-
|
|
940
|
-
|
|
939
|
+
searchValue = _useState8[0],
|
|
940
|
+
setSearchValue = _useState8[1];
|
|
941
|
+
|
|
942
|
+
var _useState9 = React.useState(''),
|
|
943
|
+
debouncedSearchValue = _useState9[0],
|
|
944
|
+
setDebouncedSearchValue = _useState9[1];
|
|
941
945
|
|
|
942
946
|
console.log({
|
|
943
947
|
searchValue: searchValue,
|
|
@@ -958,6 +962,7 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
958
962
|
React.useEffect(function () {
|
|
959
963
|
if (watchedValue !== undefined && !watchedValue.length) {
|
|
960
964
|
setLocalValues([]);
|
|
965
|
+
setIsInit(true);
|
|
961
966
|
}
|
|
962
967
|
|
|
963
968
|
if (watchedValue !== undefined && watchedValue != null && watchedValue.length) {
|
|
@@ -971,13 +976,25 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
971
976
|
setShouldSideScroll(false);
|
|
972
977
|
}
|
|
973
978
|
|
|
979
|
+
if (isInit) return;
|
|
974
980
|
setLocalValues(watchedValue.split(',').filter(Boolean).map(function (value) {
|
|
975
981
|
return options.find(function (option) {
|
|
976
982
|
return option.value === value;
|
|
977
983
|
});
|
|
978
|
-
}));
|
|
984
|
+
})); // Filter out options that are already selected
|
|
985
|
+
|
|
986
|
+
setLocalOptions(function (prevLocalOptions) {
|
|
987
|
+
return prevLocalOptions.filter(function (localOption) {
|
|
988
|
+
return !watchedValue.split(',').filter(Boolean).map(function (value) {
|
|
989
|
+
return options.find(function (option) {
|
|
990
|
+
return option.value === value;
|
|
991
|
+
});
|
|
992
|
+
}).includes(localOption);
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
setIsInit(true);
|
|
979
996
|
}
|
|
980
|
-
}, [options, shouldSideScroll, watchedValue]);
|
|
997
|
+
}, [isInit, localOptions, localValues, options, shouldSideScroll, watchedValue]);
|
|
981
998
|
|
|
982
999
|
var handleChange = function handleChange(option) {
|
|
983
1000
|
setShouldSideScroll(true);
|