@erpsquad/common 1.7.0 → 1.7.1
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/CHANGELOG.md +253 -300
- package/dist/{article-cell-editor-JDI676YI-ql1HEe0N.esm.js → article-cell-editor-JDI676YI-Bgq3iI1C.esm.js} +2 -2
- package/dist/{article-cell-editor-JDI676YI-ql1HEe0N.esm.js.map → article-cell-editor-JDI676YI-Bgq3iI1C.esm.js.map} +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/icons/index.js +2 -2
- package/dist/index-Ctq0WMb1.js.map +1 -1
- package/dist/{index-Dz5Y7-tW.esm.js → index-D-LS9re6.esm.js} +530 -429
- package/dist/{index-Dz5Y7-tW.esm.js.map → index-D-LS9re6.esm.js.map} +1 -1
- package/dist/index.esm.js +31 -30
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{number-overlay-editor-FPDVTUA6-ThTLoc9Q.esm.js → number-overlay-editor-FPDVTUA6-C0znNQy0.esm.js} +2 -2
- package/dist/{number-overlay-editor-FPDVTUA6-ThTLoc9Q.esm.js.map → number-overlay-editor-FPDVTUA6-C0znNQy0.esm.js.map} +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.esm.js +4 -3
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -45615,7 +45615,7 @@ var newRowCellRenderer = {
|
|
|
45615
45615
|
onPaste: () => void 0
|
|
45616
45616
|
};
|
|
45617
45617
|
var NumberOverlayEditor = React.lazy(
|
|
45618
|
-
async () => await import("./number-overlay-editor-FPDVTUA6-
|
|
45618
|
+
async () => await import("./number-overlay-editor-FPDVTUA6-C0znNQy0.esm.js")
|
|
45619
45619
|
);
|
|
45620
45620
|
var numberCellRenderer = {
|
|
45621
45621
|
getAccessibilityString: (c2) => {
|
|
@@ -49325,7 +49325,7 @@ var renderer5 = {
|
|
|
49325
49325
|
})
|
|
49326
49326
|
};
|
|
49327
49327
|
var dropdown_cell_default = renderer5;
|
|
49328
|
-
var ArticleCellEditor = React.lazy(async () => await import("./article-cell-editor-JDI676YI-
|
|
49328
|
+
var ArticleCellEditor = React.lazy(async () => await import("./article-cell-editor-JDI676YI-Bgq3iI1C.esm.js"));
|
|
49329
49329
|
var renderer6 = {
|
|
49330
49330
|
kind: GridCellKind.Custom,
|
|
49331
49331
|
isMatch: (c2) => c2.data.kind === "article-cell",
|
|
@@ -50366,7 +50366,21 @@ const generateMenuItems$1 = ({
|
|
|
50366
50366
|
const items = [];
|
|
50367
50367
|
if (!multiple) {
|
|
50368
50368
|
items.push(
|
|
50369
|
-
/* @__PURE__ */ jsx(
|
|
50369
|
+
/* @__PURE__ */ jsx(
|
|
50370
|
+
MenuItem,
|
|
50371
|
+
{
|
|
50372
|
+
disabled: true,
|
|
50373
|
+
value: "",
|
|
50374
|
+
sx: {
|
|
50375
|
+
opacity: `0 !important`,
|
|
50376
|
+
height: `0 !important`,
|
|
50377
|
+
p: `0 !important`,
|
|
50378
|
+
m: `0 !important`
|
|
50379
|
+
},
|
|
50380
|
+
children: /* @__PURE__ */ jsx(Typography$1, { type: "s3", color: "theme.secondary.1000", children: /* @__PURE__ */ jsx("em", { children: t2(placeholder) }) })
|
|
50381
|
+
},
|
|
50382
|
+
"placeholder"
|
|
50383
|
+
)
|
|
50370
50384
|
);
|
|
50371
50385
|
}
|
|
50372
50386
|
const selectedValues = Array.isArray(values) && (values == null ? void 0 : values.length) > 0 ? values == null ? void 0 : values.filter((value) => value) : values;
|
|
@@ -50374,7 +50388,9 @@ const generateMenuItems$1 = ({
|
|
|
50374
50388
|
const childValues = childOptions.map((child) => child.value);
|
|
50375
50389
|
const valueArray = Array.isArray(selectedValues) ? selectedValues : [selectedValues];
|
|
50376
50390
|
const isParentSelected = valueArray.includes(parentValue);
|
|
50377
|
-
const updatedValues = isParentSelected ? valueArray.filter(
|
|
50391
|
+
const updatedValues = isParentSelected ? valueArray.filter(
|
|
50392
|
+
(value) => value !== parentValue && !childValues.includes(value)
|
|
50393
|
+
) : [.../* @__PURE__ */ new Set([...valueArray, parentValue, ...childValues])];
|
|
50378
50394
|
onChange(updatedValues);
|
|
50379
50395
|
handleChange == null ? void 0 : handleChange(updatedValues);
|
|
50380
50396
|
};
|
|
@@ -50401,7 +50417,9 @@ const generateMenuItems$1 = ({
|
|
|
50401
50417
|
multiple && with_checkboxes && /* @__PURE__ */ jsx(
|
|
50402
50418
|
Checkbox,
|
|
50403
50419
|
{
|
|
50404
|
-
checked: hasParent ? isAllOptionsSelected(option.value, option.options || []) : Boolean(
|
|
50420
|
+
checked: hasParent ? isAllOptionsSelected(option.value, option.options || []) : Boolean(
|
|
50421
|
+
Array.isArray(selectedValues) ? selectedValues.includes(option.value) : selectedValues == option.value
|
|
50422
|
+
),
|
|
50405
50423
|
indeterminate: hasParent && isSomeOptionsSelected(option.options || []),
|
|
50406
50424
|
onChange: () => hasParent ? handleParentChange(option.value, option.options || []) : handleChange == null ? void 0 : handleChange(option.value)
|
|
50407
50425
|
}
|
|
@@ -50433,7 +50451,9 @@ const generateMenuItems$1 = ({
|
|
|
50433
50451
|
multiple && with_checkboxes && /* @__PURE__ */ jsx(
|
|
50434
50452
|
Checkbox,
|
|
50435
50453
|
{
|
|
50436
|
-
checked: Boolean(
|
|
50454
|
+
checked: Boolean(
|
|
50455
|
+
Array.isArray(values) && values.includes(opt.value)
|
|
50456
|
+
)
|
|
50437
50457
|
}
|
|
50438
50458
|
),
|
|
50439
50459
|
/* @__PURE__ */ jsx(
|
|
@@ -50457,7 +50477,13 @@ const generateMenuItems$1 = ({
|
|
|
50457
50477
|
if (field.enable_footer) {
|
|
50458
50478
|
items.push(
|
|
50459
50479
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
50460
|
-
/* @__PURE__ */ jsx(
|
|
50480
|
+
/* @__PURE__ */ jsx(
|
|
50481
|
+
Divider,
|
|
50482
|
+
{
|
|
50483
|
+
flexItem: true,
|
|
50484
|
+
sx: { mt: "0.25rem !important", mb: "0.25rem !important" }
|
|
50485
|
+
}
|
|
50486
|
+
),
|
|
50461
50487
|
/* @__PURE__ */ jsxs(MenuItem, { sx: { gap: 1 }, onClick: onFooterClick, children: [
|
|
50462
50488
|
/* @__PURE__ */ jsx(Add, { fontSize: "small" }),
|
|
50463
50489
|
/* @__PURE__ */ jsxs(Typography$1, { type: "s4", color: "theme.secondary.1000", children: [
|
|
@@ -50497,454 +50523,529 @@ const SelectedItems$1 = ({ data, options }) => {
|
|
|
50497
50523
|
);
|
|
50498
50524
|
};
|
|
50499
50525
|
const Loading = () => /* @__PURE__ */ jsx(Typography$1, { fontStyle: "italic", color: "inherit", type: "s3", children: "Loading..." });
|
|
50500
|
-
const DynamicSearchSelect = React__default.memo(
|
|
50501
|
-
|
|
50502
|
-
|
|
50503
|
-
|
|
50504
|
-
|
|
50505
|
-
const formContext = useFormContext();
|
|
50506
|
-
const { setValue } = formContext || {};
|
|
50507
|
-
const { t: t2 } = useTranslation();
|
|
50508
|
-
const { isRtl } = useLanguage();
|
|
50509
|
-
const selectRef = useRef(null);
|
|
50510
|
-
const [options, setOptions] = useState([]);
|
|
50511
|
-
const [selectedValue, setSelectedValue] = useState(null);
|
|
50512
|
-
const [selectedOptions, setSelectedOptions] = useState([]);
|
|
50513
|
-
const [loading, setLoading] = useState(false);
|
|
50514
|
-
const [open, setOpen] = useState(false);
|
|
50515
|
-
const [isAlreadyLoaded, setIsAlreadyLoaded] = useState(false);
|
|
50516
|
-
const [prevFilter, setPrevFilter] = useState(null);
|
|
50517
|
-
const [initialLoading, setInitialLoading] = useState(false);
|
|
50518
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
50519
|
-
const [searchInitiate, setSearchInitiate] = useState(false);
|
|
50520
|
-
const [addConfig, setAddConfig] = useState(null);
|
|
50521
|
-
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
50522
|
-
const [isAddLoading, setIsAddLoading] = useState(false);
|
|
50523
|
-
const [pagination, setPagination] = useState({
|
|
50524
|
-
page: 1,
|
|
50525
|
-
hasMore: true,
|
|
50526
|
-
isLoadingMore: false,
|
|
50527
|
-
total: 0
|
|
50528
|
-
});
|
|
50529
|
-
const {
|
|
50530
|
-
handleOptions,
|
|
50531
|
-
isInternal = false,
|
|
50532
|
-
disabledIds = [],
|
|
50533
|
-
getSelectedData,
|
|
50534
|
-
attributes = [],
|
|
50535
|
-
filterKey: filterKey2 = "id",
|
|
50536
|
-
customeFilter = {},
|
|
50537
|
-
refresh,
|
|
50538
|
-
handleChange,
|
|
50539
|
-
hasParent = false,
|
|
50540
|
-
sortOrder = "id:-1",
|
|
50541
|
-
apiType,
|
|
50542
|
-
addType
|
|
50543
|
-
} = props;
|
|
50544
|
-
const limit = 25;
|
|
50545
|
-
const isInternalOptions = useMemo(() => {
|
|
50546
|
-
return isInternal || !apiType;
|
|
50547
|
-
}, [isInternal, apiType]);
|
|
50548
|
-
const cf = useMemo(() => customeFilter, [JSON.stringify(customeFilter)]);
|
|
50549
|
-
const searchOptionsLocally = useCallback((searchTerm, value) => {
|
|
50550
|
-
var _a, _b;
|
|
50551
|
-
if (!searchTerm) return props.options || [];
|
|
50552
|
-
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
50553
|
-
const filteredOptions2 = hasParent ? ((_a = props.options) == null ? void 0 : _a.reduce((acc, opt) => {
|
|
50554
|
-
var _a2;
|
|
50555
|
-
const searchedOptions = (_a2 = opt.options) == null ? void 0 : _a2.filter((item) => {
|
|
50556
|
-
const label = React__default.isValidElement(item.label) ? item.searchLabel : String(item.label);
|
|
50557
|
-
return label == null ? void 0 : label.toLowerCase().includes(lowercasedSearchTerm);
|
|
50558
|
-
});
|
|
50559
|
-
if (searchedOptions == null ? void 0 : searchedOptions.length) {
|
|
50560
|
-
acc.push({ ...opt, options: searchedOptions });
|
|
50561
|
-
}
|
|
50562
|
-
return acc;
|
|
50563
|
-
}, [])) || [] : ((_b = props.options) == null ? void 0 : _b.filter((opt) => {
|
|
50564
|
-
const label = React__default.isValidElement(opt.label) ? opt.searchLabel : String(opt.label);
|
|
50565
|
-
return label == null ? void 0 : label.toLowerCase().includes(lowercasedSearchTerm);
|
|
50566
|
-
})) || [];
|
|
50567
|
-
return sortBySelectedValues(filteredOptions2, value);
|
|
50568
|
-
}, [props.options, hasParent]);
|
|
50569
|
-
const getUniqueOptions = useCallback((data) => {
|
|
50570
|
-
const uniqueOptions = [
|
|
50571
|
-
...new Map(data == null ? void 0 : data.map((item) => [item.value, item])).values()
|
|
50572
|
-
];
|
|
50573
|
-
return uniqueOptions;
|
|
50574
|
-
}, []);
|
|
50575
|
-
const sortBySelectedValues = useCallback((arrayToSort, value) => {
|
|
50576
|
-
const selectedValues = Array.isArray(value) ? value : [value];
|
|
50577
|
-
const sortedValue = sortBy(arrayToSort, (item) => {
|
|
50578
|
-
const index2 = selectedValues.indexOf(item.id || item.value);
|
|
50579
|
-
return index2 == -1 ? Infinity : index2;
|
|
50526
|
+
const DynamicSearchSelect = React__default.memo(
|
|
50527
|
+
(props) => {
|
|
50528
|
+
const watchedValue = useWatch({
|
|
50529
|
+
control: props.formControl,
|
|
50530
|
+
name: `${props.fieldArrayName}.${props.name}`
|
|
50580
50531
|
});
|
|
50581
|
-
|
|
50582
|
-
|
|
50583
|
-
|
|
50584
|
-
|
|
50585
|
-
|
|
50586
|
-
|
|
50587
|
-
|
|
50588
|
-
|
|
50589
|
-
|
|
50590
|
-
|
|
50591
|
-
|
|
50592
|
-
|
|
50593
|
-
|
|
50594
|
-
|
|
50595
|
-
|
|
50596
|
-
|
|
50597
|
-
|
|
50598
|
-
|
|
50599
|
-
|
|
50600
|
-
|
|
50601
|
-
|
|
50602
|
-
|
|
50603
|
-
|
|
50604
|
-
|
|
50605
|
-
|
|
50606
|
-
|
|
50607
|
-
|
|
50608
|
-
|
|
50609
|
-
|
|
50610
|
-
|
|
50611
|
-
|
|
50612
|
-
|
|
50613
|
-
|
|
50614
|
-
|
|
50615
|
-
|
|
50616
|
-
|
|
50617
|
-
|
|
50618
|
-
|
|
50619
|
-
|
|
50620
|
-
|
|
50621
|
-
|
|
50622
|
-
|
|
50623
|
-
|
|
50624
|
-
|
|
50625
|
-
|
|
50626
|
-
|
|
50627
|
-
|
|
50628
|
-
|
|
50629
|
-
|
|
50630
|
-
|
|
50631
|
-
|
|
50632
|
-
|
|
50633
|
-
|
|
50634
|
-
|
|
50635
|
-
|
|
50636
|
-
|
|
50637
|
-
|
|
50638
|
-
|
|
50639
|
-
|
|
50640
|
-
|
|
50641
|
-
|
|
50642
|
-
|
|
50643
|
-
|
|
50644
|
-
|
|
50532
|
+
const formContext = useFormContext();
|
|
50533
|
+
const { setValue } = formContext || {};
|
|
50534
|
+
const { t: t2 } = useTranslation();
|
|
50535
|
+
const { isRtl } = useLanguage();
|
|
50536
|
+
const selectRef = useRef(null);
|
|
50537
|
+
const [options, setOptions] = useState([]);
|
|
50538
|
+
const [selectedValue, setSelectedValue] = useState(null);
|
|
50539
|
+
const [selectedOptions, setSelectedOptions] = useState([]);
|
|
50540
|
+
const [loading, setLoading] = useState(false);
|
|
50541
|
+
const [open, setOpen] = useState(false);
|
|
50542
|
+
const [isAlreadyLoaded, setIsAlreadyLoaded] = useState(false);
|
|
50543
|
+
const [prevFilter, setPrevFilter] = useState(null);
|
|
50544
|
+
const [initialLoading, setInitialLoading] = useState(false);
|
|
50545
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
50546
|
+
const [searchInitiate, setSearchInitiate] = useState(false);
|
|
50547
|
+
const [addConfig, setAddConfig] = useState(null);
|
|
50548
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
50549
|
+
const [isAddLoading, setIsAddLoading] = useState(false);
|
|
50550
|
+
const [pagination, setPagination] = useState({
|
|
50551
|
+
page: 1,
|
|
50552
|
+
hasMore: true,
|
|
50553
|
+
isLoadingMore: false,
|
|
50554
|
+
total: 0
|
|
50555
|
+
});
|
|
50556
|
+
const {
|
|
50557
|
+
handleOptions,
|
|
50558
|
+
isInternal = false,
|
|
50559
|
+
disabledIds = [],
|
|
50560
|
+
getSelectedData,
|
|
50561
|
+
attributes = [],
|
|
50562
|
+
filterKey: filterKey2 = "id",
|
|
50563
|
+
customeFilter = {},
|
|
50564
|
+
refresh,
|
|
50565
|
+
handleChange,
|
|
50566
|
+
hasParent = false,
|
|
50567
|
+
sortOrder = "id:-1",
|
|
50568
|
+
apiType,
|
|
50569
|
+
addType
|
|
50570
|
+
} = props;
|
|
50571
|
+
const limit = 25;
|
|
50572
|
+
const isInternalOptions = useMemo(() => {
|
|
50573
|
+
return isInternal || !apiType;
|
|
50574
|
+
}, [isInternal, apiType]);
|
|
50575
|
+
const cf = useMemo(() => customeFilter, [JSON.stringify(customeFilter)]);
|
|
50576
|
+
const searchOptionsLocally = useCallback(
|
|
50577
|
+
(searchTerm, value) => {
|
|
50578
|
+
var _a, _b;
|
|
50579
|
+
if (!searchTerm) return props.options || [];
|
|
50580
|
+
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
50581
|
+
const filteredOptions2 = hasParent ? ((_a = props.options) == null ? void 0 : _a.reduce((acc, opt) => {
|
|
50582
|
+
var _a2;
|
|
50583
|
+
const searchedOptions = (_a2 = opt.options) == null ? void 0 : _a2.filter((item) => {
|
|
50584
|
+
const label = React__default.isValidElement(item.label) ? item.searchLabel : String(item.label);
|
|
50585
|
+
return label == null ? void 0 : label.toLowerCase().includes(lowercasedSearchTerm);
|
|
50586
|
+
});
|
|
50587
|
+
if (searchedOptions == null ? void 0 : searchedOptions.length) {
|
|
50588
|
+
acc.push({ ...opt, options: searchedOptions });
|
|
50589
|
+
}
|
|
50590
|
+
return acc;
|
|
50591
|
+
}, [])) || [] : ((_b = props.options) == null ? void 0 : _b.filter((opt) => {
|
|
50592
|
+
const label = React__default.isValidElement(opt.label) ? opt.searchLabel : String(opt.label);
|
|
50593
|
+
return label == null ? void 0 : label.toLowerCase().includes(lowercasedSearchTerm);
|
|
50594
|
+
})) || [];
|
|
50595
|
+
return sortBySelectedValues(filteredOptions2, value);
|
|
50596
|
+
},
|
|
50597
|
+
[props.options, hasParent]
|
|
50645
50598
|
);
|
|
50646
|
-
|
|
50647
|
-
|
|
50648
|
-
|
|
50649
|
-
|
|
50650
|
-
|
|
50651
|
-
|
|
50652
|
-
|
|
50653
|
-
|
|
50654
|
-
|
|
50655
|
-
|
|
50656
|
-
|
|
50657
|
-
|
|
50658
|
-
await fetchOptions("", { ...cf, "&id.in": watchedValue }, 1, false);
|
|
50659
|
-
setInitialLoading(false);
|
|
50660
|
-
}
|
|
50661
|
-
}, [open, watchedValue, JSON.stringify(cf)]);
|
|
50662
|
-
const initialFetch = useCallback(async () => {
|
|
50663
|
-
const condition = JSON.stringify(cf) !== JSON.stringify(prevFilter);
|
|
50664
|
-
if (condition) {
|
|
50665
|
-
setPrevFilter(cf);
|
|
50666
|
-
setOptions([]);
|
|
50667
|
-
setIsAlreadyLoaded(false);
|
|
50668
|
-
setPagination({
|
|
50669
|
-
page: 1,
|
|
50670
|
-
hasMore: true,
|
|
50671
|
-
isLoadingMore: false,
|
|
50672
|
-
total: 0
|
|
50673
|
-
});
|
|
50674
|
-
}
|
|
50675
|
-
if (!isInternalOptions && !isAlreadyLoaded) {
|
|
50676
|
-
await fetchOptions(searchQuery, cf, 1, false);
|
|
50677
|
-
setIsAlreadyLoaded(true);
|
|
50678
|
-
}
|
|
50679
|
-
}, [cf, isInternalOptions, isAlreadyLoaded]);
|
|
50680
|
-
const debouncedSearch = useMemo(
|
|
50681
|
-
() => debounce$2(async (searchTerm) => {
|
|
50682
|
-
if (loading) return;
|
|
50683
|
-
if (!searchTerm && !isInternalOptions && searchInitiate) {
|
|
50684
|
-
setPagination({
|
|
50685
|
-
page: 1,
|
|
50686
|
-
hasMore: true,
|
|
50687
|
-
isLoadingMore: false,
|
|
50688
|
-
total: 0
|
|
50599
|
+
const getUniqueOptions = useCallback((data) => {
|
|
50600
|
+
const uniqueOptions = [
|
|
50601
|
+
...new Map(data == null ? void 0 : data.map((item) => [item.value, item])).values()
|
|
50602
|
+
];
|
|
50603
|
+
return uniqueOptions;
|
|
50604
|
+
}, []);
|
|
50605
|
+
const sortBySelectedValues = useCallback(
|
|
50606
|
+
(arrayToSort, value) => {
|
|
50607
|
+
const selectedValues = Array.isArray(value) ? value : [value];
|
|
50608
|
+
const sortedValue = sortBy(arrayToSort, (item) => {
|
|
50609
|
+
const index2 = selectedValues.indexOf(item.id || item.value);
|
|
50610
|
+
return index2 == -1 ? Infinity : index2;
|
|
50689
50611
|
});
|
|
50690
|
-
|
|
50612
|
+
return sortedValue;
|
|
50613
|
+
},
|
|
50614
|
+
[]
|
|
50615
|
+
);
|
|
50616
|
+
const filteredOptions = useMemo(() => {
|
|
50617
|
+
if (isInternalOptions) {
|
|
50618
|
+
return searchOptionsLocally(searchQuery, watchedValue);
|
|
50691
50619
|
}
|
|
50692
|
-
|
|
50620
|
+
return sortBySelectedValues(
|
|
50621
|
+
getUniqueOptions([...options, ...selectedOptions]),
|
|
50622
|
+
watchedValue
|
|
50623
|
+
);
|
|
50624
|
+
}, [
|
|
50625
|
+
options,
|
|
50626
|
+
selectedOptions,
|
|
50627
|
+
isInternalOptions,
|
|
50628
|
+
props.options,
|
|
50629
|
+
watchedValue,
|
|
50630
|
+
searchQuery,
|
|
50631
|
+
searchOptionsLocally,
|
|
50632
|
+
sortBySelectedValues,
|
|
50633
|
+
getUniqueOptions
|
|
50634
|
+
]);
|
|
50635
|
+
const fetchOptions = useCallback(
|
|
50636
|
+
async (searchTerm = "", flt = cf, page = 1, append2 = false) => {
|
|
50637
|
+
if (!apiType) return [];
|
|
50638
|
+
setLoading(true);
|
|
50639
|
+
if (page > 1) {
|
|
50640
|
+
setPagination((prev) => ({ ...prev, isLoadingMore: true }));
|
|
50641
|
+
}
|
|
50642
|
+
try {
|
|
50643
|
+
const { data = [], pagination: pagination2 = {} } = await fetchApi({
|
|
50644
|
+
apiKey: apiType,
|
|
50645
|
+
filters: {
|
|
50646
|
+
limit,
|
|
50647
|
+
skip: (page - 1) * limit,
|
|
50648
|
+
search: searchTerm,
|
|
50649
|
+
filters: flt,
|
|
50650
|
+
select: attributes,
|
|
50651
|
+
order: sortOrder
|
|
50652
|
+
}
|
|
50653
|
+
});
|
|
50654
|
+
if (data && Array.isArray(data)) {
|
|
50655
|
+
const newOptions = append2 ? [...options, ...data] : data;
|
|
50656
|
+
updateOptions(newOptions, append2);
|
|
50657
|
+
handleSelectedValue(data);
|
|
50658
|
+
setPagination((prev) => ({
|
|
50659
|
+
...prev,
|
|
50660
|
+
page,
|
|
50661
|
+
hasMore: (pagination2 == null ? void 0 : pagination2.totalCount) > page * limit,
|
|
50662
|
+
total: pagination2 == null ? void 0 : pagination2.totalCount,
|
|
50663
|
+
isLoadingMore: false
|
|
50664
|
+
}));
|
|
50665
|
+
}
|
|
50666
|
+
return data || [];
|
|
50667
|
+
} catch (error) {
|
|
50668
|
+
console.error("Error fetching options:", error);
|
|
50669
|
+
setPagination((prev) => ({ ...prev, isLoadingMore: false }));
|
|
50670
|
+
return [];
|
|
50671
|
+
} finally {
|
|
50672
|
+
setLoading(false);
|
|
50673
|
+
}
|
|
50674
|
+
},
|
|
50675
|
+
[apiType, options, attributes, sortOrder, limit, cf]
|
|
50676
|
+
);
|
|
50677
|
+
const handleScroll = useCallback(
|
|
50678
|
+
(event) => {
|
|
50679
|
+
const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;
|
|
50680
|
+
const isBottom = scrollHeight - scrollTop <= clientHeight + 10;
|
|
50681
|
+
if (isBottom && pagination.hasMore && !pagination.isLoadingMore && !isInternalOptions) {
|
|
50682
|
+
const nextPage = pagination.page + 1;
|
|
50683
|
+
fetchOptions(searchQuery, cf, nextPage, true);
|
|
50684
|
+
}
|
|
50685
|
+
},
|
|
50686
|
+
[
|
|
50687
|
+
pagination.hasMore,
|
|
50688
|
+
pagination.isLoadingMore,
|
|
50689
|
+
pagination.page,
|
|
50690
|
+
isInternalOptions,
|
|
50691
|
+
searchQuery,
|
|
50692
|
+
cf,
|
|
50693
|
+
fetchOptions
|
|
50694
|
+
]
|
|
50695
|
+
);
|
|
50696
|
+
const updateOptions = useCallback(
|
|
50697
|
+
(newOptions, append2 = false) => {
|
|
50698
|
+
const oldOptions = append2 ? options : selectedOptions;
|
|
50699
|
+
const uniqueOptions = getUniqueOptions([...oldOptions, ...newOptions]);
|
|
50700
|
+
setOptions(uniqueOptions);
|
|
50701
|
+
},
|
|
50702
|
+
[options, selectedOptions, getUniqueOptions]
|
|
50703
|
+
);
|
|
50704
|
+
const handleSelectedValue = useCallback(
|
|
50705
|
+
async (updateOptions2) => {
|
|
50706
|
+
const filterValue = props.is_multiselect ? watchedValue : [watchedValue];
|
|
50707
|
+
const isInOptions = updateOptions2 == null ? void 0 : updateOptions2.filter(
|
|
50708
|
+
(item) => Array.isArray(filterValue) ? filterValue.includes(item.id || item.value) : (item[filterKey2] || item.value || item.id) == filterValue
|
|
50709
|
+
);
|
|
50710
|
+
if (Array.isArray(isInOptions) && isInOptions.length > 0) {
|
|
50711
|
+
getSelectedData == null ? void 0 : getSelectedData(
|
|
50712
|
+
props.is_multiselect ? isInOptions : isInOptions[0],
|
|
50713
|
+
props.name
|
|
50714
|
+
);
|
|
50715
|
+
return true;
|
|
50716
|
+
}
|
|
50717
|
+
return false;
|
|
50718
|
+
},
|
|
50719
|
+
[
|
|
50720
|
+
props.is_multiselect,
|
|
50721
|
+
props.name,
|
|
50722
|
+
watchedValue,
|
|
50723
|
+
filterKey2,
|
|
50724
|
+
getSelectedData
|
|
50725
|
+
]
|
|
50726
|
+
);
|
|
50727
|
+
const fetchIdOptions = useCallback(async () => {
|
|
50728
|
+
if (open) return;
|
|
50729
|
+
if (await handleSelectedValue(filteredOptions)) return;
|
|
50730
|
+
const condition = props.is_multiselect ? Array.isArray(watchedValue) && watchedValue.length > 0 : Boolean(watchedValue);
|
|
50731
|
+
if (condition) {
|
|
50732
|
+
setInitialLoading(true);
|
|
50733
|
+
await fetchOptions(
|
|
50734
|
+
"",
|
|
50735
|
+
{ ...cf, "&id.in": watchedValue },
|
|
50736
|
+
1,
|
|
50737
|
+
false
|
|
50738
|
+
);
|
|
50739
|
+
setInitialLoading(false);
|
|
50740
|
+
}
|
|
50741
|
+
}, [open, watchedValue, JSON.stringify(cf)]);
|
|
50742
|
+
const initialFetch = useCallback(async () => {
|
|
50743
|
+
const condition = JSON.stringify(cf) !== JSON.stringify(prevFilter);
|
|
50744
|
+
if (condition) {
|
|
50745
|
+
setPrevFilter(cf);
|
|
50746
|
+
setOptions([]);
|
|
50747
|
+
setIsAlreadyLoaded(false);
|
|
50693
50748
|
setPagination({
|
|
50694
50749
|
page: 1,
|
|
50695
50750
|
hasMore: true,
|
|
50696
50751
|
isLoadingMore: false,
|
|
50697
50752
|
total: 0
|
|
50698
50753
|
});
|
|
50699
|
-
await fetchOptions(searchTerm, cf, 1, false);
|
|
50700
50754
|
}
|
|
50701
|
-
|
|
50702
|
-
|
|
50703
|
-
|
|
50704
|
-
|
|
50705
|
-
|
|
50706
|
-
|
|
50707
|
-
|
|
50708
|
-
|
|
50709
|
-
|
|
50710
|
-
|
|
50711
|
-
|
|
50712
|
-
|
|
50713
|
-
|
|
50714
|
-
|
|
50715
|
-
|
|
50716
|
-
|
|
50717
|
-
|
|
50718
|
-
|
|
50719
|
-
|
|
50720
|
-
|
|
50721
|
-
|
|
50722
|
-
|
|
50723
|
-
|
|
50724
|
-
|
|
50725
|
-
|
|
50726
|
-
|
|
50727
|
-
|
|
50728
|
-
|
|
50729
|
-
|
|
50730
|
-
|
|
50731
|
-
|
|
50732
|
-
|
|
50733
|
-
|
|
50755
|
+
if (!isInternalOptions && !isAlreadyLoaded) {
|
|
50756
|
+
await fetchOptions(searchQuery, cf, 1, false);
|
|
50757
|
+
setIsAlreadyLoaded(true);
|
|
50758
|
+
}
|
|
50759
|
+
}, [cf, isInternalOptions, isAlreadyLoaded]);
|
|
50760
|
+
const debouncedSearch = useMemo(
|
|
50761
|
+
() => debounce$2(async (searchTerm) => {
|
|
50762
|
+
if (loading) return;
|
|
50763
|
+
if (!searchTerm && !isInternalOptions && searchInitiate) {
|
|
50764
|
+
setPagination({
|
|
50765
|
+
page: 1,
|
|
50766
|
+
hasMore: true,
|
|
50767
|
+
isLoadingMore: false,
|
|
50768
|
+
total: 0
|
|
50769
|
+
});
|
|
50770
|
+
await fetchOptions("", cf, 1, false);
|
|
50771
|
+
}
|
|
50772
|
+
if (searchTerm.length > 1 && !isInternalOptions) {
|
|
50773
|
+
setPagination({
|
|
50774
|
+
page: 1,
|
|
50775
|
+
hasMore: true,
|
|
50776
|
+
isLoadingMore: false,
|
|
50777
|
+
total: 0
|
|
50778
|
+
});
|
|
50779
|
+
await fetchOptions(searchTerm, cf, 1, false);
|
|
50780
|
+
}
|
|
50781
|
+
}, 700),
|
|
50782
|
+
//eslint-disable-next-line
|
|
50783
|
+
[isInternalOptions, searchInitiate, cf]
|
|
50784
|
+
);
|
|
50785
|
+
const resetValue = useCallback(
|
|
50786
|
+
(field) => {
|
|
50787
|
+
field.onChange(props.is_multiselect ? [] : null);
|
|
50788
|
+
if (getSelectedData) {
|
|
50789
|
+
getSelectedData(null, props.name);
|
|
50790
|
+
}
|
|
50791
|
+
},
|
|
50792
|
+
[props.is_multiselect, props.name, getSelectedData]
|
|
50793
|
+
);
|
|
50794
|
+
const handleClose = useCallback(() => {
|
|
50795
|
+
setOpen(false);
|
|
50796
|
+
if (searchQuery.length > 0) {
|
|
50797
|
+
setIsAlreadyLoaded(false);
|
|
50798
|
+
}
|
|
50799
|
+
setSearchInitiate(false);
|
|
50800
|
+
setSearchQuery("");
|
|
50801
|
+
}, [searchQuery]);
|
|
50802
|
+
const handleModalOpen = useCallback(() => {
|
|
50803
|
+
setIsModalOpen(true);
|
|
50804
|
+
}, []);
|
|
50805
|
+
const handleModalSave = useCallback(
|
|
50806
|
+
async (payload) => {
|
|
50807
|
+
if (!addConfig || !addConfig.api) {
|
|
50808
|
+
console.error("Add configuration is not properly set");
|
|
50809
|
+
return;
|
|
50810
|
+
}
|
|
50811
|
+
setIsAddLoading(true);
|
|
50812
|
+
try {
|
|
50813
|
+
const result = await addConfig.api(payload);
|
|
50814
|
+
console.log("result", result);
|
|
50815
|
+
setIsAddLoading(false);
|
|
50816
|
+
setIsModalOpen(false);
|
|
50817
|
+
if (!isInternalOptions) {
|
|
50818
|
+
setPagination({
|
|
50819
|
+
page: 1,
|
|
50820
|
+
hasMore: true,
|
|
50821
|
+
isLoadingMore: false,
|
|
50822
|
+
total: 0
|
|
50823
|
+
});
|
|
50824
|
+
setIsAlreadyLoaded(false);
|
|
50825
|
+
await fetchOptions("", cf, 1, false);
|
|
50826
|
+
}
|
|
50827
|
+
if (result && result.data) {
|
|
50828
|
+
const newValue = props.is_multiselect ? [...watchedValue || [], result.data.id] : result.data.id;
|
|
50829
|
+
if (setValue) {
|
|
50830
|
+
setValue(`${props.fieldArrayName}.${props.name}`, newValue);
|
|
50831
|
+
}
|
|
50832
|
+
}
|
|
50833
|
+
} catch (error) {
|
|
50834
|
+
console.log("error", error);
|
|
50835
|
+
setIsAddLoading(false);
|
|
50836
|
+
}
|
|
50837
|
+
},
|
|
50838
|
+
[
|
|
50839
|
+
addConfig,
|
|
50840
|
+
isInternalOptions,
|
|
50841
|
+
fetchOptions,
|
|
50842
|
+
cf,
|
|
50843
|
+
props.is_multiselect,
|
|
50844
|
+
props.fieldArrayName,
|
|
50845
|
+
props.name,
|
|
50846
|
+
watchedValue,
|
|
50847
|
+
setValue
|
|
50848
|
+
]
|
|
50849
|
+
);
|
|
50850
|
+
useEffect(() => {
|
|
50851
|
+
if (handleOptions) {
|
|
50852
|
+
handleOptions(selectedValue);
|
|
50853
|
+
}
|
|
50854
|
+
}, [handleOptions, selectedValue]);
|
|
50855
|
+
useEffect(() => {
|
|
50856
|
+
if (open) {
|
|
50857
|
+
initialFetch();
|
|
50858
|
+
}
|
|
50859
|
+
}, [open, initialFetch]);
|
|
50860
|
+
useEffect(() => {
|
|
50861
|
+
fetchIdOptions();
|
|
50862
|
+
}, [fetchIdOptions]);
|
|
50863
|
+
useEffect(() => {
|
|
50864
|
+
if (refresh) {
|
|
50734
50865
|
setPagination({
|
|
50735
50866
|
page: 1,
|
|
50736
50867
|
hasMore: true,
|
|
50737
50868
|
isLoadingMore: false,
|
|
50738
50869
|
total: 0
|
|
50739
50870
|
});
|
|
50740
|
-
|
|
50741
|
-
await fetchOptions("", cf, 1, false);
|
|
50871
|
+
fetchOptions("", cf, 1, false);
|
|
50742
50872
|
}
|
|
50743
|
-
|
|
50744
|
-
|
|
50745
|
-
|
|
50746
|
-
|
|
50747
|
-
}
|
|
50873
|
+
}, [refresh, fetchOptions, cf]);
|
|
50874
|
+
useEffect(() => {
|
|
50875
|
+
if (open) {
|
|
50876
|
+
debouncedSearch(searchQuery);
|
|
50748
50877
|
}
|
|
50749
|
-
|
|
50750
|
-
|
|
50751
|
-
|
|
50752
|
-
|
|
50753
|
-
|
|
50754
|
-
|
|
50755
|
-
|
|
50756
|
-
|
|
50757
|
-
|
|
50758
|
-
|
|
50759
|
-
|
|
50760
|
-
|
|
50761
|
-
|
|
50762
|
-
|
|
50763
|
-
|
|
50764
|
-
|
|
50765
|
-
|
|
50766
|
-
|
|
50767
|
-
|
|
50768
|
-
|
|
50769
|
-
|
|
50770
|
-
|
|
50771
|
-
|
|
50772
|
-
|
|
50773
|
-
|
|
50774
|
-
|
|
50775
|
-
|
|
50776
|
-
|
|
50777
|
-
|
|
50778
|
-
|
|
50779
|
-
|
|
50780
|
-
|
|
50781
|
-
|
|
50782
|
-
|
|
50783
|
-
|
|
50784
|
-
|
|
50785
|
-
|
|
50786
|
-
|
|
50787
|
-
|
|
50788
|
-
|
|
50789
|
-
|
|
50790
|
-
|
|
50791
|
-
|
|
50792
|
-
|
|
50793
|
-
|
|
50794
|
-
|
|
50795
|
-
|
|
50796
|
-
|
|
50797
|
-
|
|
50798
|
-
|
|
50799
|
-
|
|
50800
|
-
|
|
50801
|
-
|
|
50802
|
-
|
|
50803
|
-
|
|
50804
|
-
|
|
50805
|
-
|
|
50806
|
-
|
|
50807
|
-
|
|
50808
|
-
|
|
50809
|
-
|
|
50810
|
-
|
|
50811
|
-
|
|
50812
|
-
|
|
50813
|
-
|
|
50814
|
-
|
|
50815
|
-
|
|
50816
|
-
|
|
50817
|
-
|
|
50818
|
-
|
|
50819
|
-
|
|
50820
|
-
|
|
50821
|
-
|
|
50822
|
-
|
|
50823
|
-
required: props.formType == "builder" ? false : props.required,
|
|
50824
|
-
size: props.size || "small",
|
|
50825
|
-
multiple: props.is_multiselect || false,
|
|
50826
|
-
disabled: props.disabled,
|
|
50827
|
-
sx: props.is_multiselect && ((_a = field == null ? void 0 : field.value) == null ? void 0 : _a.length) ? { "& .MuiSelect-select": { padding: "5.5px !important" } } : {},
|
|
50828
|
-
variant: "outlined",
|
|
50829
|
-
value: initialLoading ? props.is_multiselect ? [] : "" : ((_b = field.value) == null ? void 0 : _b.id) || field.value || (props.is_multiselect ? [] : ""),
|
|
50830
|
-
className: props.is_multiselect && ((_c = removeUndefined(field.value)) == null ? void 0 : _c.length) ? "MultiSelect filter-select" : "",
|
|
50831
|
-
MenuProps: {
|
|
50832
|
-
PaperProps: {
|
|
50833
|
-
onScroll: handleScroll,
|
|
50834
|
-
style: { maxHeight: 300 }
|
|
50835
|
-
}
|
|
50836
|
-
},
|
|
50837
|
-
renderValue: (selected) => {
|
|
50838
|
-
if (Array.isArray(selected)) {
|
|
50839
|
-
return /* @__PURE__ */ jsx(
|
|
50840
|
-
ChipOrPlaceholder,
|
|
50841
|
-
{
|
|
50842
|
-
selectedLabel: props.selectedLabel,
|
|
50843
|
-
data: removeUndefined(selected),
|
|
50844
|
-
placeholder: loading || props.is_loading ? /* @__PURE__ */ jsx(Loading, {}) : `${t2("common.search")} ${props.label}`,
|
|
50845
|
-
onDelete: props.onChipRemove,
|
|
50846
|
-
disabled: props.disabled,
|
|
50847
|
-
chipProps: {
|
|
50848
|
-
sx: {
|
|
50849
|
-
background: "#ebf9f2",
|
|
50850
|
-
border: 0,
|
|
50851
|
-
// borderRadius: '15px',
|
|
50852
|
-
"& .MuiTypography-body1": {
|
|
50853
|
-
color: "#289b64",
|
|
50854
|
-
fontWeight: "500"
|
|
50878
|
+
return () => debouncedSearch.cancel();
|
|
50879
|
+
}, [searchQuery, open, debouncedSearch]);
|
|
50880
|
+
useEffect(() => {
|
|
50881
|
+
if (watchedValue && !open) {
|
|
50882
|
+
const selectedData = options == null ? void 0 : options.filter(
|
|
50883
|
+
(item) => props.is_multiselect ? Array.isArray(watchedValue) && watchedValue.includes(item.id || item.value) : (item.id || item.value) == watchedValue
|
|
50884
|
+
);
|
|
50885
|
+
setSelectedOptions(selectedData || []);
|
|
50886
|
+
}
|
|
50887
|
+
}, [watchedValue, options, props.is_multiselect, open]);
|
|
50888
|
+
const removeUndefined = useCallback((selectOptions) => {
|
|
50889
|
+
return Array.isArray(selectOptions) ? selectOptions.filter(Boolean) : [];
|
|
50890
|
+
}, []);
|
|
50891
|
+
useEffect(() => {
|
|
50892
|
+
const config2 = dynamicSelectAdd(addType);
|
|
50893
|
+
setAddConfig(config2);
|
|
50894
|
+
}, [addType]);
|
|
50895
|
+
return /* @__PURE__ */ jsx(
|
|
50896
|
+
Controller,
|
|
50897
|
+
{
|
|
50898
|
+
control: props.formControl,
|
|
50899
|
+
name: `${props.fieldArrayName}.${props.name}`,
|
|
50900
|
+
render: ({ field, fieldState }) => {
|
|
50901
|
+
var _a, _b, _c, _d, _e;
|
|
50902
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50903
|
+
props.placeholder == "Select Currency" && setSelectedValue(field.value),
|
|
50904
|
+
/* @__PURE__ */ jsxs(
|
|
50905
|
+
Select$1,
|
|
50906
|
+
{
|
|
50907
|
+
...field,
|
|
50908
|
+
ref: selectRef,
|
|
50909
|
+
open,
|
|
50910
|
+
onOpen: () => setOpen(true),
|
|
50911
|
+
onClose: handleClose,
|
|
50912
|
+
fullWidth: true,
|
|
50913
|
+
dataPosition: props.position,
|
|
50914
|
+
dataName: `${props.fieldArrayName}.${props.name}`,
|
|
50915
|
+
placeholder: props.placeholder,
|
|
50916
|
+
label: props.label,
|
|
50917
|
+
defaultValue: props.defaultValue || (props.is_multiselect ? [] : ""),
|
|
50918
|
+
searchValue: searchQuery,
|
|
50919
|
+
required: props.formType == "builder" ? false : props.required,
|
|
50920
|
+
size: props.size || "small",
|
|
50921
|
+
multiple: props.is_multiselect || false,
|
|
50922
|
+
disabled: props.disabled,
|
|
50923
|
+
sx: props.is_multiselect && ((_a = field == null ? void 0 : field.value) == null ? void 0 : _a.length) ? { "& .MuiSelect-select": { padding: "5.5px !important" } } : {},
|
|
50924
|
+
variant: "outlined",
|
|
50925
|
+
value: initialLoading ? props.is_multiselect ? [] : "" : ((_b = field.value) == null ? void 0 : _b.id) || field.value || (props.is_multiselect ? [] : ""),
|
|
50926
|
+
className: props.is_multiselect && ((_c = removeUndefined(field.value)) == null ? void 0 : _c.length) ? "MultiSelect filter-select" : "",
|
|
50927
|
+
MenuProps: {
|
|
50928
|
+
PaperProps: {
|
|
50929
|
+
onScroll: handleScroll,
|
|
50930
|
+
style: { maxHeight: 300 }
|
|
50931
|
+
}
|
|
50932
|
+
},
|
|
50933
|
+
renderValue: (selected) => {
|
|
50934
|
+
if (Array.isArray(selected)) {
|
|
50935
|
+
return /* @__PURE__ */ jsx(
|
|
50936
|
+
ChipOrPlaceholder,
|
|
50937
|
+
{
|
|
50938
|
+
selectedLabel: props.selectedLabel,
|
|
50939
|
+
data: removeUndefined(selected),
|
|
50940
|
+
placeholder: loading || props.is_loading ? /* @__PURE__ */ jsx(Loading, {}) : `${t2("common.search")} ${props.label}`,
|
|
50941
|
+
onDelete: props.onChipRemove,
|
|
50942
|
+
disabled: props.disabled,
|
|
50943
|
+
chipProps: {
|
|
50944
|
+
sx: {
|
|
50945
|
+
background: "#ebf9f2",
|
|
50946
|
+
border: 0,
|
|
50947
|
+
// borderRadius: '15px',
|
|
50948
|
+
"& .MuiTypography-body1": {
|
|
50949
|
+
color: "#289b64",
|
|
50950
|
+
fontWeight: "500"
|
|
50951
|
+
}
|
|
50855
50952
|
}
|
|
50856
50953
|
}
|
|
50857
50954
|
}
|
|
50955
|
+
);
|
|
50956
|
+
} else {
|
|
50957
|
+
const selectedOption = filteredOptions.find(
|
|
50958
|
+
(option) => {
|
|
50959
|
+
var _a2;
|
|
50960
|
+
return (((_a2 = option.value) == null ? void 0 : _a2.id) || option.value) == selected;
|
|
50961
|
+
}
|
|
50962
|
+
);
|
|
50963
|
+
return loading || props.is_loading ? /* @__PURE__ */ jsx(Loading, {}) : (selectedOption == null ? void 0 : selectedOption.label) || (typeof props.label == "string" ? `${t2("common.search")} ${props.label}` : props.placeholder);
|
|
50964
|
+
}
|
|
50965
|
+
},
|
|
50966
|
+
searchPlaceholder: `${t2("common.search")} ${props.label}`,
|
|
50967
|
+
handleSearch: (text) => {
|
|
50968
|
+
setSearchQuery(text);
|
|
50969
|
+
setSearchInitiate(true);
|
|
50970
|
+
},
|
|
50971
|
+
error: Boolean((_d = fieldState.error) == null ? void 0 : _d.message),
|
|
50972
|
+
helperText: ((_e = fieldState.error) == null ? void 0 : _e.message) || "",
|
|
50973
|
+
onBlur: field.onBlur,
|
|
50974
|
+
input: /* @__PURE__ */ jsx(
|
|
50975
|
+
OutlinedInput,
|
|
50976
|
+
{
|
|
50977
|
+
label: "",
|
|
50978
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: loading || props.is_loading ? /* @__PURE__ */ jsx(
|
|
50979
|
+
CircularProgress,
|
|
50980
|
+
{
|
|
50981
|
+
size: 20,
|
|
50982
|
+
sx: { mr: 3, color: "#4AC08C" }
|
|
50983
|
+
}
|
|
50984
|
+
) : !props.disabled && (props.is_multiselect ? Array.isArray(field.value) && field.value.length > 0 : Boolean(field.value)) && /* @__PURE__ */ jsx(
|
|
50985
|
+
IconButton,
|
|
50986
|
+
{
|
|
50987
|
+
"aria-label": "clear selection",
|
|
50988
|
+
onClick: () => resetValue(field),
|
|
50989
|
+
edge: "end",
|
|
50990
|
+
sx: isRtl ? { ml: 2.5 } : { mr: 1.5 },
|
|
50991
|
+
size: "small",
|
|
50992
|
+
children: /* @__PURE__ */ jsx(Close, { sx: { fontSize: "1rem" } })
|
|
50993
|
+
}
|
|
50994
|
+
) })
|
|
50995
|
+
}
|
|
50996
|
+
),
|
|
50997
|
+
children: [
|
|
50998
|
+
generateMenuItems$1({
|
|
50999
|
+
options: filteredOptions,
|
|
51000
|
+
multiple: Boolean(props.is_multiselect),
|
|
51001
|
+
placeholder: props.placeholder,
|
|
51002
|
+
values: field.value,
|
|
51003
|
+
with_checkboxes: true,
|
|
51004
|
+
field: props,
|
|
51005
|
+
disabledIds,
|
|
51006
|
+
onChange: field.onChange,
|
|
51007
|
+
handleChange,
|
|
51008
|
+
hasParent,
|
|
51009
|
+
t: t2,
|
|
51010
|
+
onFooterClick: () => {
|
|
51011
|
+
if (props == null ? void 0 : props.onFooterClick) {
|
|
51012
|
+
props == null ? void 0 : props.onFooterClick();
|
|
51013
|
+
} else {
|
|
51014
|
+
handleModalOpen();
|
|
51015
|
+
}
|
|
50858
51016
|
}
|
|
50859
|
-
)
|
|
50860
|
-
|
|
50861
|
-
|
|
50862
|
-
(option) => {
|
|
50863
|
-
var _a2;
|
|
50864
|
-
return (((_a2 = option.value) == null ? void 0 : _a2.id) || option.value) == selected;
|
|
50865
|
-
}
|
|
50866
|
-
);
|
|
50867
|
-
return loading || props.is_loading ? /* @__PURE__ */ jsx(Loading, {}) : (selectedOption == null ? void 0 : selectedOption.label) || (typeof props.label == "string" ? `${t2("common.search")} ${props.label}` : props.placeholder);
|
|
50868
|
-
}
|
|
50869
|
-
},
|
|
50870
|
-
searchPlaceholder: `${t2("common.search")} ${props.label}`,
|
|
50871
|
-
handleSearch: (text) => {
|
|
50872
|
-
setSearchQuery(text);
|
|
50873
|
-
setSearchInitiate(true);
|
|
50874
|
-
},
|
|
50875
|
-
error: Boolean((_d = fieldState.error) == null ? void 0 : _d.message),
|
|
50876
|
-
helperText: ((_e = fieldState.error) == null ? void 0 : _e.message) || "",
|
|
50877
|
-
onBlur: field.onBlur,
|
|
50878
|
-
input: /* @__PURE__ */ jsx(
|
|
50879
|
-
OutlinedInput,
|
|
50880
|
-
{
|
|
50881
|
-
label: "",
|
|
50882
|
-
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: loading || props.is_loading ? /* @__PURE__ */ jsx(
|
|
50883
|
-
CircularProgress,
|
|
50884
|
-
{
|
|
50885
|
-
size: 20,
|
|
50886
|
-
sx: { mr: 3, color: "#4AC08C" }
|
|
50887
|
-
}
|
|
50888
|
-
) : !props.disabled && (props.is_multiselect ? Array.isArray(field.value) && field.value.length > 0 : Boolean(field.value)) && /* @__PURE__ */ jsx(
|
|
50889
|
-
IconButton,
|
|
51017
|
+
}),
|
|
51018
|
+
pagination.isLoadingMore && /* @__PURE__ */ jsx(MenuItem, { disabled: true, children: /* @__PURE__ */ jsx(
|
|
51019
|
+
Box,
|
|
50890
51020
|
{
|
|
50891
|
-
|
|
50892
|
-
|
|
50893
|
-
|
|
50894
|
-
|
|
50895
|
-
|
|
50896
|
-
children: /* @__PURE__ */ jsx(
|
|
51021
|
+
sx: {
|
|
51022
|
+
display: "flex",
|
|
51023
|
+
justifyContent: "center",
|
|
51024
|
+
width: "100%"
|
|
51025
|
+
},
|
|
51026
|
+
children: /* @__PURE__ */ jsx(CircularProgress, { size: 20 })
|
|
50897
51027
|
}
|
|
50898
51028
|
) })
|
|
50899
|
-
|
|
50900
|
-
|
|
50901
|
-
|
|
50902
|
-
|
|
50903
|
-
|
|
50904
|
-
|
|
50905
|
-
|
|
50906
|
-
|
|
50907
|
-
|
|
50908
|
-
|
|
50909
|
-
|
|
50910
|
-
|
|
50911
|
-
|
|
50912
|
-
|
|
50913
|
-
|
|
50914
|
-
|
|
50915
|
-
if (props == null ? void 0 : props.onFooterClick) {
|
|
50916
|
-
props == null ? void 0 : props.onFooterClick();
|
|
50917
|
-
} else {
|
|
50918
|
-
handleModalOpen();
|
|
50919
|
-
}
|
|
50920
|
-
}
|
|
50921
|
-
}),
|
|
50922
|
-
pagination.isLoadingMore && /* @__PURE__ */ jsx(MenuItem, { disabled: true, children: /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", width: "100%" }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 20 }) }) })
|
|
50923
|
-
]
|
|
50924
|
-
}
|
|
50925
|
-
),
|
|
50926
|
-
addConfig && addConfig.component && /* @__PURE__ */ jsx(Fragment, { children: React__default.createElement(addConfig.component, {
|
|
50927
|
-
isOpen: isModalOpen,
|
|
50928
|
-
setIsOpen: setIsModalOpen,
|
|
50929
|
-
isLoading: isAddLoading,
|
|
50930
|
-
onSave: handleModalSave,
|
|
50931
|
-
modalProps: {
|
|
50932
|
-
maxWidth: "md",
|
|
50933
|
-
fullWidth: true
|
|
50934
|
-
}
|
|
50935
|
-
}) }),
|
|
50936
|
-
props.is_multiselect && Array.isArray(field.value) && /* @__PURE__ */ jsx(
|
|
50937
|
-
SelectedItems$1,
|
|
50938
|
-
{
|
|
50939
|
-
data: field.value,
|
|
50940
|
-
options: filteredOptions
|
|
50941
|
-
}
|
|
50942
|
-
)
|
|
50943
|
-
] });
|
|
51029
|
+
]
|
|
51030
|
+
}
|
|
51031
|
+
),
|
|
51032
|
+
addConfig && addConfig.component && /* @__PURE__ */ jsx(Fragment, { children: React__default.createElement(addConfig.component, {
|
|
51033
|
+
isOpen: isModalOpen,
|
|
51034
|
+
setIsOpen: setIsModalOpen,
|
|
51035
|
+
isLoading: isAddLoading,
|
|
51036
|
+
onSave: handleModalSave,
|
|
51037
|
+
modalProps: {
|
|
51038
|
+
maxWidth: "md",
|
|
51039
|
+
fullWidth: true
|
|
51040
|
+
}
|
|
51041
|
+
}) }),
|
|
51042
|
+
props.is_multiselect && Array.isArray(field.value) && /* @__PURE__ */ jsx(SelectedItems$1, { data: field.value, options: filteredOptions })
|
|
51043
|
+
] });
|
|
51044
|
+
}
|
|
50944
51045
|
}
|
|
50945
|
-
|
|
50946
|
-
|
|
50947
|
-
|
|
51046
|
+
);
|
|
51047
|
+
}
|
|
51048
|
+
);
|
|
50948
51049
|
DynamicSearchSelect.propTypes = {
|
|
50949
51050
|
name: PropTypes.string.isRequired,
|
|
50950
51051
|
placeholder: PropTypes.string.isRequired,
|
|
@@ -60845,4 +60946,4 @@ export {
|
|
|
60845
60946
|
GeneralScheduleReport as y,
|
|
60846
60947
|
Snackbar as z
|
|
60847
60948
|
};
|
|
60848
|
-
//# sourceMappingURL=index-
|
|
60949
|
+
//# sourceMappingURL=index-D-LS9re6.esm.js.map
|