@monolith-forensics/monolith-ui 1.1.72 → 1.1.74
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.
|
@@ -403,14 +403,16 @@ DropDownProps = {}, debounceTime = 300, sort = false, }) => {
|
|
|
403
403
|
}, [refs.floating, refs.reference, handleBlur]);
|
|
404
404
|
// Handle default value
|
|
405
405
|
useEffect(() => {
|
|
406
|
-
if (
|
|
407
|
-
const isOption =
|
|
408
|
-
const searchPattern = isOption
|
|
406
|
+
if (defaultValue) {
|
|
407
|
+
const isOption = defaultValue.value !== undefined;
|
|
408
|
+
const searchPattern = isOption
|
|
409
|
+
? defaultValue.value
|
|
410
|
+
: defaultValue;
|
|
409
411
|
setSelected(data.find((item) => isObjectArray
|
|
410
412
|
? item.value === searchPattern
|
|
411
413
|
: item === searchPattern) || null);
|
|
412
414
|
}
|
|
413
|
-
}, [data,
|
|
415
|
+
}, [data, defaultValue, isObjectArray]);
|
|
414
416
|
// handle input value change
|
|
415
417
|
useEffect(() => {
|
|
416
418
|
if (inputRef.current) {
|
package/dist/TagBox/TagBox.js
CHANGED
|
@@ -296,7 +296,7 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
296
296
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
297
297
|
const isObjectArray = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("label");
|
|
298
298
|
const [isOpen, setIsOpen] = useState(false);
|
|
299
|
-
const [selectedItems, setSelectedItems] = useState(
|
|
299
|
+
const [selectedItems, setSelectedItems] = useState(defaultValue);
|
|
300
300
|
const [preSelected, setPreSelected] = useState(null);
|
|
301
301
|
const [customItems, setCustomItems] = useState([]);
|
|
302
302
|
const [searchValue, setSearchValue] = useState("");
|
|
@@ -543,6 +543,12 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
543
543
|
useEffect(() => {
|
|
544
544
|
update();
|
|
545
545
|
}, [selectedItems]);
|
|
546
|
+
// handle default value
|
|
547
|
+
useEffect(() => {
|
|
548
|
+
if (defaultValue) {
|
|
549
|
+
setSelectedItems(defaultValue);
|
|
550
|
+
}
|
|
551
|
+
}, [defaultValue]);
|
|
546
552
|
const referenceEl = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
|
|
547
553
|
const contentWidth = ((_e = (_d = (_c = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.getClientRects) === null || _c === void 0 ? void 0 : _c.call(referenceEl)) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.width) || "100%";
|
|
548
554
|
const scrollEl = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
|