@addsign/moje-agenda-shared-lib 2.0.60 → 2.0.62
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/components/datatable/DataTableServer.js +93 -54
- package/dist/components/datatable/DataTableServer.js.map +1 -1
- package/dist/components/form/FileInput.d.ts +1 -0
- package/dist/components/form/FileInput.js +13 -4
- package/dist/components/form/FileInput.js.map +1 -1
- package/dist/components/form/FileInputMultiple.d.ts +1 -0
- package/dist/components/form/FileInputMultiple.js +11 -3
- package/dist/components/form/FileInputMultiple.js.map +1 -1
- package/lib/components/datatable/DataTableServer.tsx +124 -66
- package/lib/components/form/FileInput.tsx +15 -2
- package/lib/components/form/FileInputMultiple.tsx +13 -1
- package/package.json +1 -1
|
@@ -21733,22 +21733,24 @@ function DataTableServer({
|
|
|
21733
21733
|
const bottomScrollbarRef = useRef(null);
|
|
21734
21734
|
const tableRef = useRef(null);
|
|
21735
21735
|
const syncWidthRef = useRef(null);
|
|
21736
|
-
const [itemsPerPageLocal, setItemsPerPageLocal] = useState();
|
|
21736
|
+
const [itemsPerPageLocal, setItemsPerPageLocal] = useState(10);
|
|
21737
21737
|
const federationContext = useFederationContext();
|
|
21738
21738
|
const [data, setData] = useState();
|
|
21739
21739
|
const [isLoading, setIsLoading] = useState(false);
|
|
21740
21740
|
const [isLocalStorageLoaded, setIsLocalStorageLoaded] = useState(false);
|
|
21741
21741
|
const [tableKey, setTableKey] = useState(0);
|
|
21742
21742
|
const [hasMounted, setHasMounted] = useState(false);
|
|
21743
|
-
const [currentPage, setCurrentPage] = useState();
|
|
21743
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
21744
21744
|
const [selectedItems, setSelectedItems] = useState([]);
|
|
21745
21745
|
const [fulltextSearch, setFulltextSearch] = useState("");
|
|
21746
21746
|
const [filterOptions, setFilterOptions] = useState({});
|
|
21747
21747
|
const [columnFilters, setColumnFilters] = useState(
|
|
21748
21748
|
{}
|
|
21749
21749
|
);
|
|
21750
|
-
const [showColFilters, setShowColFilters] = useState();
|
|
21750
|
+
const [showColFilters, setShowColFilters] = useState(false);
|
|
21751
21751
|
const [sortConfig, setSortConfig] = useState(null);
|
|
21752
|
+
const prevDepsRef = useRef([]);
|
|
21753
|
+
const prevFilterDepsRef = useRef([]);
|
|
21752
21754
|
const createDataPageable = (response, itemsPerPage) => {
|
|
21753
21755
|
var _a2, _b2, _c, _d;
|
|
21754
21756
|
const isPageable = !!((_a2 = response.data) == null ? void 0 : _a2.content);
|
|
@@ -21770,21 +21772,47 @@ function DataTableServer({
|
|
|
21770
21772
|
return showColFilters ? { ...columnFilters, ...filters } : filters || {};
|
|
21771
21773
|
}, [columnFilters, filters, showColFilters]);
|
|
21772
21774
|
useEffect(() => {
|
|
21773
|
-
|
|
21775
|
+
const currentDeps = [
|
|
21776
|
+
url,
|
|
21777
|
+
showColFilters,
|
|
21778
|
+
columnFilters,
|
|
21779
|
+
itemsPerPageLocal,
|
|
21780
|
+
currentPage,
|
|
21781
|
+
sortConfig,
|
|
21782
|
+
filters,
|
|
21783
|
+
tableKey
|
|
21784
|
+
];
|
|
21785
|
+
const hasChanged = currentDeps.some((dep, index) => {
|
|
21786
|
+
return JSON.stringify(dep) !== JSON.stringify(prevDepsRef.current[index]);
|
|
21787
|
+
});
|
|
21788
|
+
if (hasChanged) {
|
|
21789
|
+
console.log(
|
|
21790
|
+
"setting reloadData - actual change detected",
|
|
21791
|
+
url,
|
|
21792
|
+
showColFilters,
|
|
21793
|
+
columnFilters,
|
|
21794
|
+
itemsPerPageLocal,
|
|
21795
|
+
currentPage,
|
|
21796
|
+
sortConfig,
|
|
21797
|
+
filters,
|
|
21798
|
+
tableKey,
|
|
21799
|
+
reloadData
|
|
21800
|
+
);
|
|
21801
|
+
setReloadData(true);
|
|
21802
|
+
}
|
|
21803
|
+
prevDepsRef.current = currentDeps;
|
|
21774
21804
|
}, [
|
|
21775
21805
|
url,
|
|
21776
21806
|
showColFilters,
|
|
21777
|
-
// id,
|
|
21778
21807
|
columnFilters,
|
|
21779
21808
|
itemsPerPageLocal,
|
|
21780
21809
|
currentPage,
|
|
21781
21810
|
sortConfig,
|
|
21782
|
-
federationContext.apiClient,
|
|
21783
|
-
federationContext.emitter,
|
|
21784
21811
|
filters,
|
|
21785
21812
|
tableKey
|
|
21786
21813
|
]);
|
|
21787
21814
|
useEffect(() => {
|
|
21815
|
+
console.log("reloadData", reloadData);
|
|
21788
21816
|
if (reloadData) {
|
|
21789
21817
|
if (abortControllerRef.current) {
|
|
21790
21818
|
abortControllerRef.current.abort();
|
|
@@ -21877,51 +21905,68 @@ function DataTableServer({
|
|
|
21877
21905
|
}
|
|
21878
21906
|
}, [id]);
|
|
21879
21907
|
useEffect(() => {
|
|
21880
|
-
const
|
|
21881
|
-
|
|
21882
|
-
|
|
21883
|
-
|
|
21884
|
-
|
|
21885
|
-
const response = await federationContext.apiClient.get(
|
|
21886
|
-
column.filterSource
|
|
21887
|
-
);
|
|
21888
|
-
const options = response.data.map((item) => {
|
|
21889
|
-
var _a2, _b2;
|
|
21890
|
-
return {
|
|
21891
|
-
value: (_a2 = item[column.filterValueKey]) == null ? void 0 : _a2.toString(),
|
|
21892
|
-
label: (_b2 = item[column.filterLabelKey]) == null ? void 0 : _b2.toString()
|
|
21893
|
-
};
|
|
21894
|
-
});
|
|
21895
|
-
return options;
|
|
21896
|
-
} catch (error) {
|
|
21897
|
-
console.error("Error fetching filter options:", error);
|
|
21898
|
-
return [];
|
|
21899
|
-
}
|
|
21908
|
+
const currentFilterDeps = [columns, federationContext.apiClient];
|
|
21909
|
+
const hasFilterChanged = currentFilterDeps.some((dep, index) => {
|
|
21910
|
+
const prev = prevFilterDepsRef.current[index];
|
|
21911
|
+
if (index === 1) {
|
|
21912
|
+
return dep !== prev;
|
|
21900
21913
|
} else {
|
|
21901
|
-
return
|
|
21914
|
+
return JSON.stringify(dep) !== JSON.stringify(prev);
|
|
21902
21915
|
}
|
|
21903
|
-
};
|
|
21904
|
-
|
|
21905
|
-
const
|
|
21906
|
-
|
|
21907
|
-
|
|
21908
|
-
|
|
21909
|
-
|
|
21910
|
-
const
|
|
21911
|
-
|
|
21916
|
+
});
|
|
21917
|
+
if (hasFilterChanged) {
|
|
21918
|
+
const fetchFilterOptions = async (column) => {
|
|
21919
|
+
if (column.filterOptions) {
|
|
21920
|
+
return column.filterOptions;
|
|
21921
|
+
} else if (column.filterSource) {
|
|
21922
|
+
try {
|
|
21923
|
+
const response = await federationContext.apiClient.get(
|
|
21924
|
+
column.filterSource
|
|
21912
21925
|
);
|
|
21913
|
-
|
|
21914
|
-
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
|
|
21918
|
-
|
|
21926
|
+
const options = response.data.map((item) => {
|
|
21927
|
+
var _a2, _b2;
|
|
21928
|
+
return {
|
|
21929
|
+
value: (_a2 = item[column.filterValueKey]) == null ? void 0 : _a2.toString(),
|
|
21930
|
+
label: (_b2 = item[column.filterLabelKey]) == null ? void 0 : _b2.toString()
|
|
21931
|
+
};
|
|
21932
|
+
});
|
|
21933
|
+
return options;
|
|
21934
|
+
} catch (error) {
|
|
21935
|
+
console.error("Error fetching filter options:", error);
|
|
21936
|
+
return [];
|
|
21919
21937
|
}
|
|
21938
|
+
} else {
|
|
21939
|
+
return [];
|
|
21920
21940
|
}
|
|
21921
|
-
}
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
|
|
21941
|
+
};
|
|
21942
|
+
const updateFilterOptions = async () => {
|
|
21943
|
+
const newFilterOptions = {};
|
|
21944
|
+
for (const column of columns) {
|
|
21945
|
+
if ((column.filterType === "select" || column.filterType === "multi-select") && (column.filterSource || column.filterOptions) && column.filterValueKey && column.filterLabelKey && column.filterParam) {
|
|
21946
|
+
const options = await fetchFilterOptions(column);
|
|
21947
|
+
if (options && column.filterType === "select") {
|
|
21948
|
+
const filteredOptions = options.filter(
|
|
21949
|
+
(option) => option.value !== null && option.value !== void 0 && option.value !== ""
|
|
21950
|
+
);
|
|
21951
|
+
newFilterOptions[column.filterParam] = [
|
|
21952
|
+
{ value: "__clear__", label: "Všechny" },
|
|
21953
|
+
...filteredOptions
|
|
21954
|
+
];
|
|
21955
|
+
} else if (options && column.filterType === "multi-select") {
|
|
21956
|
+
newFilterOptions[column.filterParam] = options;
|
|
21957
|
+
}
|
|
21958
|
+
}
|
|
21959
|
+
}
|
|
21960
|
+
setFilterOptions(newFilterOptions);
|
|
21961
|
+
};
|
|
21962
|
+
console.log(
|
|
21963
|
+
"updateFilterOptions - actual change detected",
|
|
21964
|
+
columns,
|
|
21965
|
+
federationContext.apiClient
|
|
21966
|
+
);
|
|
21967
|
+
updateFilterOptions();
|
|
21968
|
+
}
|
|
21969
|
+
prevFilterDepsRef.current = currentFilterDeps;
|
|
21925
21970
|
}, [columns, federationContext.apiClient]);
|
|
21926
21971
|
const hasSomeColFilters = useMemo(() => {
|
|
21927
21972
|
return columns.some((column) => !!column.filterParam);
|
|
@@ -22297,13 +22342,7 @@ function DataTableServer({
|
|
|
22297
22342
|
filters || {}
|
|
22298
22343
|
).includes(String(filterParam)),
|
|
22299
22344
|
children: [
|
|
22300
|
-
/* @__PURE__ */ jsx(
|
|
22301
|
-
SelectTrigger,
|
|
22302
|
-
{
|
|
22303
|
-
className: "flex-1 w-full px-2 font-normal placeholder-muted-foreground",
|
|
22304
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Zadejte filtr" })
|
|
22305
|
-
}
|
|
22306
|
-
),
|
|
22345
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "flex-1 w-full px-2 font-normal placeholder-muted-foreground", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Zadejte filtr" }) }),
|
|
22307
22346
|
/* @__PURE__ */ jsx(SelectContent, { children: (_c = (_b2 = filterOptions[String(filterParam)]) == null ? void 0 : _b2.filter(
|
|
22308
22347
|
(option) => option.value !== null && option.value !== void 0 && option.value !== ""
|
|
22309
22348
|
)) == null ? void 0 : _c.map((option) => {
|