@xqmsg/ui-core 0.16.3 → 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 +35 -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 +35 -24
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/StackedMultiSelect/index.tsx +22 -3
package/package.json
CHANGED
|
@@ -47,6 +47,7 @@ const StackedMultiSelect = React.forwardRef<
|
|
|
47
47
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
48
48
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
49
49
|
|
|
50
|
+
const [isInit, setIsInit] = useState(false);
|
|
50
51
|
const [localValues, setLocalValues] = useState<FieldOptions>([]);
|
|
51
52
|
const [localOptions, setLocalOptions] = useState<FieldOptions>(options);
|
|
52
53
|
const [isFocussed, setIsFocussed] = useState(false);
|
|
@@ -75,6 +76,7 @@ const StackedMultiSelect = React.forwardRef<
|
|
|
75
76
|
useEffect(() => {
|
|
76
77
|
if (watchedValue !== undefined && !watchedValue.length) {
|
|
77
78
|
setLocalValues([]);
|
|
79
|
+
setIsInit(true);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
if (watchedValue !== undefined && watchedValue?.length) {
|
|
@@ -86,6 +88,8 @@ const StackedMultiSelect = React.forwardRef<
|
|
|
86
88
|
setShouldSideScroll(false);
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
if (isInit) return;
|
|
92
|
+
|
|
89
93
|
setLocalValues(
|
|
90
94
|
watchedValue
|
|
91
95
|
.split(',')
|
|
@@ -94,15 +98,30 @@ const StackedMultiSelect = React.forwardRef<
|
|
|
94
98
|
options.find(option => option.value === value)
|
|
95
99
|
)
|
|
96
100
|
);
|
|
97
|
-
|
|
98
101
|
// Filter out options that are already selected
|
|
99
102
|
setLocalOptions(prevLocalOptions =>
|
|
100
103
|
prevLocalOptions.filter(
|
|
101
|
-
localOption =>
|
|
104
|
+
localOption =>
|
|
105
|
+
!watchedValue
|
|
106
|
+
.split(',')
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.map((value: string) =>
|
|
109
|
+
options.find(option => option.value === value)
|
|
110
|
+
)
|
|
111
|
+
.includes(localOption)
|
|
102
112
|
)
|
|
103
113
|
);
|
|
114
|
+
|
|
115
|
+
setIsInit(true);
|
|
104
116
|
}
|
|
105
|
-
}, [
|
|
117
|
+
}, [
|
|
118
|
+
isInit,
|
|
119
|
+
localOptions,
|
|
120
|
+
localValues,
|
|
121
|
+
options,
|
|
122
|
+
shouldSideScroll,
|
|
123
|
+
watchedValue,
|
|
124
|
+
]);
|
|
106
125
|
|
|
107
126
|
const handleChange = (option: FieldOption) => {
|
|
108
127
|
setShouldSideScroll(true);
|