@monolith-forensics/monolith-ui 1.2.45 → 1.2.47
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.
|
@@ -168,20 +168,26 @@ const StyledItem = styled.div `
|
|
|
168
168
|
* if the value is not found, it will return the value as is so that custom values can be displayed without a lookup
|
|
169
169
|
*/
|
|
170
170
|
const resolveValue = (value, data) => {
|
|
171
|
+
let foundOption;
|
|
171
172
|
if (value === undefined)
|
|
172
173
|
return undefined;
|
|
173
|
-
let foundOption = null;
|
|
174
174
|
if (typeof value === "string") {
|
|
175
175
|
foundOption = data.find((item) => item.value === value);
|
|
176
176
|
}
|
|
177
|
-
else {
|
|
178
|
-
foundOption = data.find((item) => item.value === value
|
|
177
|
+
else if (typeof value === "number") {
|
|
178
|
+
foundOption = data.find((item) => item.value === value);
|
|
179
|
+
}
|
|
180
|
+
else if (typeof value === "object") {
|
|
181
|
+
foundOption = data.find((item) => item.value == value.value);
|
|
179
182
|
}
|
|
180
183
|
if (foundOption)
|
|
181
184
|
return foundOption;
|
|
182
185
|
if (typeof value === "string") {
|
|
183
186
|
return { value, label: value };
|
|
184
187
|
}
|
|
188
|
+
if (typeof value === "number") {
|
|
189
|
+
return { value, label: value.toString() };
|
|
190
|
+
}
|
|
185
191
|
return value;
|
|
186
192
|
};
|
|
187
193
|
const SelectBox = styled(({ className, data = [], placeholder = "Select...", arrow = true, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, label, description, required = false, error, openOnFocus = true, renderOption, actionComponent, focused, grouped, OptionTooltip, // Custom tooltip component for search menu items
|
|
@@ -214,7 +220,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, }) => {
|
|
|
214
220
|
* if controlled, use the controlled value, otherwise use the resolved value
|
|
215
221
|
*/
|
|
216
222
|
const _value = isControlled ? resolvedValue : valueState;
|
|
217
|
-
const [inputValue, setInputValue] = useState((_value === null || _value === void 0 ? void 0 : _value.label) || "");
|
|
223
|
+
const [inputValue, setInputValue] = useState(typeof _value === "object" ? (_value === null || _value === void 0 ? void 0 : _value.label) || "" : _value || "");
|
|
218
224
|
const [isOpen, setIsOpen] = useState(false);
|
|
219
225
|
const [searchValue, setSearchValue] = useState("");
|
|
220
226
|
const [customItems, setCustomItems] = useState([]);
|
|
@@ -5,6 +5,7 @@ export type Option = {
|
|
|
5
5
|
group?: string;
|
|
6
6
|
data?: any;
|
|
7
7
|
};
|
|
8
|
+
export type Value = number | boolean | string | Option;
|
|
8
9
|
export interface SelectBoxProps {
|
|
9
10
|
className?: string;
|
|
10
11
|
defaultValue?: Option | string;
|
|
@@ -34,7 +35,7 @@ export interface SelectBoxProps {
|
|
|
34
35
|
OptionTooltip?: (props: {
|
|
35
36
|
data: any;
|
|
36
37
|
}) => JSX.Element | React.ReactNode;
|
|
37
|
-
onChange?: (value:
|
|
38
|
+
onChange?: (value: any, item: any) => void;
|
|
38
39
|
onScroll?: (e: any) => void;
|
|
39
40
|
onSearch?: (value: string) => void;
|
|
40
41
|
searchFn?: (value: string) => void;
|
package/dist/TagBox/TagBox.js
CHANGED
|
@@ -312,6 +312,10 @@ const resolveValues = (value, data) => {
|
|
|
312
312
|
const found = data.find((option) => option.value === item);
|
|
313
313
|
resolvedValues.push(found || { value: item, label: item });
|
|
314
314
|
}
|
|
315
|
+
else if (typeof item === "number") {
|
|
316
|
+
const found = data.find((option) => option.value === item);
|
|
317
|
+
resolvedValues.push(found || { value: item, label: item.toString() });
|
|
318
|
+
}
|
|
315
319
|
else if (typeof item === "object") {
|
|
316
320
|
const found = data.find((option) => option.value === item.value);
|
|
317
321
|
resolvedValues.push(found || item);
|
|
@@ -369,7 +373,7 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
369
373
|
return !isSelected;
|
|
370
374
|
})
|
|
371
375
|
.filter((item) => {
|
|
372
|
-
return item.
|
|
376
|
+
return item.label.toLowerCase().includes(searchValue.toLowerCase());
|
|
373
377
|
})
|
|
374
378
|
.sort((a, b) => {
|
|
375
379
|
if (grouped) {
|