fui-material 2.8.19 → 2.8.20
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/f-ui-kit.es.js +315 -3
- package/dist/f-ui-kit.es.js.map +1 -1
- package/dist/f-ui-kit.umd.js +2 -2
- package/dist/f-ui-kit.umd.js.map +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useFManualApiQuery/index.d.ts +1 -0
- package/dist/types/hooks/useFManualApiQuery/useFManualApiQuery.d.ts +6 -1
- package/dist/types/hooks/useFManualPagination/index.d.ts +2 -0
- package/dist/types/hooks/useFManualPagination/types.d.ts +105 -0
- package/dist/types/hooks/useFManualPagination/useFManualPagination.d.ts +3 -0
- package/dist/types/material/FProgressiveList/FProgressiveList.d.ts +4 -0
- package/dist/types/material/FProgressiveList/index.d.ts +2 -0
- package/dist/types/material/FProgressiveList/types.d.ts +34 -0
- package/dist/types/material/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/f-ui-kit.es.js
CHANGED
|
@@ -4925,6 +4925,92 @@ const FStatusBadge = ({
|
|
|
4925
4925
|
/* @__PURE__ */ jsx("span", { children })
|
|
4926
4926
|
] });
|
|
4927
4927
|
};
|
|
4928
|
+
function FProgressiveList({
|
|
4929
|
+
items,
|
|
4930
|
+
chunkSize = 6,
|
|
4931
|
+
estimatedItemHeight = 280,
|
|
4932
|
+
keyExtractor,
|
|
4933
|
+
className,
|
|
4934
|
+
st,
|
|
4935
|
+
showProgress = true,
|
|
4936
|
+
renderProgress,
|
|
4937
|
+
children,
|
|
4938
|
+
onLoadMore,
|
|
4939
|
+
hasMore = false,
|
|
4940
|
+
isLoadingMore = false,
|
|
4941
|
+
loader: loader2,
|
|
4942
|
+
threshold = 250
|
|
4943
|
+
}) {
|
|
4944
|
+
const totalCount = items.length;
|
|
4945
|
+
const [renderedCount, setRenderedCount] = useState(() => Math.min(chunkSize, totalCount));
|
|
4946
|
+
const sentinelRef = useRef(null);
|
|
4947
|
+
const prevFirstKeyRef = useRef(void 0);
|
|
4948
|
+
const prevTotalCountRef = useRef(totalCount);
|
|
4949
|
+
useEffect(() => {
|
|
4950
|
+
const currentFirstKey = items.length > 0 ? keyExtractor(items[0], 0) : void 0;
|
|
4951
|
+
const isReset = currentFirstKey !== prevFirstKeyRef.current || totalCount < prevTotalCountRef.current;
|
|
4952
|
+
if (isReset) {
|
|
4953
|
+
setRenderedCount(Math.min(chunkSize, totalCount));
|
|
4954
|
+
}
|
|
4955
|
+
prevFirstKeyRef.current = currentFirstKey;
|
|
4956
|
+
prevTotalCountRef.current = totalCount;
|
|
4957
|
+
}, [items, keyExtractor, chunkSize, totalCount]);
|
|
4958
|
+
useEffect(() => {
|
|
4959
|
+
if (renderedCount >= totalCount) return;
|
|
4960
|
+
const frameId = requestAnimationFrame(() => {
|
|
4961
|
+
setRenderedCount((prev) => Math.min(prev + chunkSize, totalCount));
|
|
4962
|
+
});
|
|
4963
|
+
return () => cancelAnimationFrame(frameId);
|
|
4964
|
+
}, [renderedCount, totalCount, chunkSize]);
|
|
4965
|
+
useEffect(() => {
|
|
4966
|
+
if (!onLoadMore || !hasMore || isLoadingMore) return;
|
|
4967
|
+
if (renderedCount < totalCount) return;
|
|
4968
|
+
const sentinelEl = sentinelRef.current;
|
|
4969
|
+
if (!sentinelEl) return;
|
|
4970
|
+
const observer = new IntersectionObserver(
|
|
4971
|
+
(entries) => {
|
|
4972
|
+
const [entry] = entries;
|
|
4973
|
+
if (entry && entry.isIntersecting) {
|
|
4974
|
+
onLoadMore();
|
|
4975
|
+
}
|
|
4976
|
+
},
|
|
4977
|
+
{
|
|
4978
|
+
rootMargin: `0px 0px ${threshold}px 0px`,
|
|
4979
|
+
threshold: 0
|
|
4980
|
+
}
|
|
4981
|
+
);
|
|
4982
|
+
observer.observe(sentinelEl);
|
|
4983
|
+
return () => {
|
|
4984
|
+
observer.disconnect();
|
|
4985
|
+
};
|
|
4986
|
+
}, [onLoadMore, hasMore, isLoadingMore, renderedCount, totalCount, threshold]);
|
|
4987
|
+
const visibleItems = items.slice(0, renderedCount);
|
|
4988
|
+
const itemWrapperStyle = {
|
|
4989
|
+
contentVisibility: "auto",
|
|
4990
|
+
containIntrinsicSize: `0 ${estimatedItemHeight}px`,
|
|
4991
|
+
marginBottom: 16
|
|
4992
|
+
};
|
|
4993
|
+
return /* @__PURE__ */ jsxs("div", { className, style: st, children: [
|
|
4994
|
+
visibleItems.map((item, index) => /* @__PURE__ */ jsx(
|
|
4995
|
+
"div",
|
|
4996
|
+
{
|
|
4997
|
+
style: itemWrapperStyle,
|
|
4998
|
+
children: children(item, index)
|
|
4999
|
+
},
|
|
5000
|
+
keyExtractor(item, index)
|
|
5001
|
+
)),
|
|
5002
|
+
showProgress && renderProgress && renderedCount < totalCount && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "8px 0" }, children: renderProgress(renderedCount, totalCount) }),
|
|
5003
|
+
onLoadMore && hasMore && /* @__PURE__ */ jsx(
|
|
5004
|
+
"div",
|
|
5005
|
+
{
|
|
5006
|
+
ref: sentinelRef,
|
|
5007
|
+
style: { height: 1, width: "100%", pointerEvents: "none", visibility: "hidden" },
|
|
5008
|
+
"aria-hidden": "true"
|
|
5009
|
+
}
|
|
5010
|
+
),
|
|
5011
|
+
isLoadingMore && /* @__PURE__ */ jsx("div", { style: { padding: "16px 0", textAlign: "center" }, children: loader2 ?? /* @__PURE__ */ jsx(FProgress, {}) })
|
|
5012
|
+
] });
|
|
5013
|
+
}
|
|
4928
5014
|
const FPlusIcon = React.forwardRef(({
|
|
4929
5015
|
color = "primary",
|
|
4930
5016
|
size = 30,
|
|
@@ -9750,9 +9836,16 @@ const useFApiQuery = (queryKey, url, config, options) => {
|
|
|
9750
9836
|
function useFManualApiQuery(queryKey, url, initialParams, config, options) {
|
|
9751
9837
|
const { apiService } = useFLibraryContext();
|
|
9752
9838
|
const queryClient = useQueryClient();
|
|
9839
|
+
const abortControllerRef = useRef(null);
|
|
9753
9840
|
const [params, setParams] = useState(initialParams);
|
|
9754
9841
|
const [urlParams, setUrlParams] = useState(options == null ? void 0 : options.urlParams);
|
|
9755
9842
|
const [dopUrl, setDopUrl] = useState(void 0);
|
|
9843
|
+
useEffect(() => {
|
|
9844
|
+
return () => {
|
|
9845
|
+
var _a;
|
|
9846
|
+
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
9847
|
+
};
|
|
9848
|
+
}, []);
|
|
9756
9849
|
const {
|
|
9757
9850
|
onErrorNotification = false,
|
|
9758
9851
|
onErrorLog = false,
|
|
@@ -9789,6 +9882,9 @@ function useFManualApiQuery(queryKey, url, initialParams, config, options) {
|
|
|
9789
9882
|
...restOptions
|
|
9790
9883
|
});
|
|
9791
9884
|
const handleSideErrors = useCallback((error2) => {
|
|
9885
|
+
if (axios.isCancel(error2)) {
|
|
9886
|
+
return;
|
|
9887
|
+
}
|
|
9792
9888
|
if (onErrorNotification) {
|
|
9793
9889
|
fNotification({
|
|
9794
9890
|
variant: "error",
|
|
@@ -9810,10 +9906,21 @@ function useFManualApiQuery(queryKey, url, initialParams, config, options) {
|
|
|
9810
9906
|
newParams,
|
|
9811
9907
|
newUrlParams,
|
|
9812
9908
|
preserveParams = false,
|
|
9909
|
+
mergeParams = false,
|
|
9813
9910
|
dopUrl: newDopUrl,
|
|
9814
9911
|
preserveUrlParams = false
|
|
9815
9912
|
} = {}) => {
|
|
9816
|
-
|
|
9913
|
+
if (abortControllerRef.current) {
|
|
9914
|
+
abortControllerRef.current.abort();
|
|
9915
|
+
}
|
|
9916
|
+
abortControllerRef.current = new AbortController();
|
|
9917
|
+
const activeSignal = abortControllerRef.current.signal;
|
|
9918
|
+
let updatedParams;
|
|
9919
|
+
if (mergeParams && params && typeof params === "object" && newParams && typeof newParams === "object") {
|
|
9920
|
+
updatedParams = { ...params, ...newParams };
|
|
9921
|
+
} else {
|
|
9922
|
+
updatedParams = preserveParams && newParams === void 0 ? params : newParams;
|
|
9923
|
+
}
|
|
9817
9924
|
const updatedUrlParams = newUrlParams === void 0 ? urlParams : preserveUrlParams ? { ...urlParams, ...newUrlParams } : newUrlParams;
|
|
9818
9925
|
const updatedDopUrl = newDopUrl !== void 0 ? newDopUrl : dopUrl;
|
|
9819
9926
|
setParams(updatedParams);
|
|
@@ -9825,7 +9932,20 @@ function useFManualApiQuery(queryKey, url, initialParams, config, options) {
|
|
|
9825
9932
|
try {
|
|
9826
9933
|
const rawResult = await queryClient.fetchQuery({
|
|
9827
9934
|
queryKey: nextQueryKey,
|
|
9828
|
-
queryFn: ({ signal }) =>
|
|
9935
|
+
queryFn: ({ signal }) => {
|
|
9936
|
+
var _a;
|
|
9937
|
+
if (signal) {
|
|
9938
|
+
if (signal.aborted) {
|
|
9939
|
+
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
9940
|
+
} else {
|
|
9941
|
+
signal.addEventListener("abort", () => {
|
|
9942
|
+
var _a2;
|
|
9943
|
+
(_a2 = abortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
9944
|
+
}, { once: true });
|
|
9945
|
+
}
|
|
9946
|
+
}
|
|
9947
|
+
return fetcher(updatedParams, updatedUrlParams, updatedDopUrl, activeSignal);
|
|
9948
|
+
},
|
|
9829
9949
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9830
9950
|
staleTime: restOptions.staleTime
|
|
9831
9951
|
});
|
|
@@ -9840,6 +9960,196 @@ function useFManualApiQuery(queryKey, url, initialParams, config, options) {
|
|
|
9840
9960
|
}, [params, urlParams, dopUrl, queryKey, fetcher, queryClient, restOptions, handleSideErrors]);
|
|
9841
9961
|
return { ...query, run, params, urlParams };
|
|
9842
9962
|
}
|
|
9963
|
+
function extractDefaultData(raw) {
|
|
9964
|
+
if (!raw || typeof raw !== "object") {
|
|
9965
|
+
return raw;
|
|
9966
|
+
}
|
|
9967
|
+
const record = raw;
|
|
9968
|
+
const candidate = record.result ?? record.items ?? record.content ?? record.data;
|
|
9969
|
+
return candidate !== void 0 ? candidate : raw;
|
|
9970
|
+
}
|
|
9971
|
+
function extractDefaultPageMeta(raw, defaultSize, currentPage) {
|
|
9972
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
9973
|
+
const record = raw;
|
|
9974
|
+
const p = record.page ?? record.pagination;
|
|
9975
|
+
if (!p || typeof p !== "object") return void 0;
|
|
9976
|
+
const totalItems = Number(p.totalItems ?? p.totalElements ?? p.totalCount ?? p.total ?? 0);
|
|
9977
|
+
const size = Number(p.size ?? p.pageSize ?? p.limit ?? defaultSize);
|
|
9978
|
+
const totalPages = Number(p.totalPages ?? p.pageCount ?? (size > 0 ? Math.ceil(totalItems / size) : 1));
|
|
9979
|
+
const number = Number(p.number ?? p.currentPage ?? p.page ?? currentPage);
|
|
9980
|
+
return { totalItems, size, totalPages, number };
|
|
9981
|
+
}
|
|
9982
|
+
function useFManualPagination(options) {
|
|
9983
|
+
const {
|
|
9984
|
+
queryKey,
|
|
9985
|
+
url,
|
|
9986
|
+
defaultPageSize = 20,
|
|
9987
|
+
initialFilters,
|
|
9988
|
+
method = "POST",
|
|
9989
|
+
config,
|
|
9990
|
+
mode = "pagination",
|
|
9991
|
+
select,
|
|
9992
|
+
selectPage,
|
|
9993
|
+
appendData,
|
|
9994
|
+
onErrorNotification = true,
|
|
9995
|
+
onErrorLog = false,
|
|
9996
|
+
onLoadingLog = false,
|
|
9997
|
+
onSuccessNotification = false,
|
|
9998
|
+
notificationTitle,
|
|
9999
|
+
notificationBody,
|
|
10000
|
+
loadingNotificationTitle,
|
|
10001
|
+
loadingNotificationBody,
|
|
10002
|
+
successNotificationTitle,
|
|
10003
|
+
successNotificationBody
|
|
10004
|
+
} = options;
|
|
10005
|
+
const [page, setPage] = useState(1);
|
|
10006
|
+
const [pageSize, setPageSize] = useState(defaultPageSize);
|
|
10007
|
+
const [accumulatedData, setAccumulatedData] = useState(void 0);
|
|
10008
|
+
const [isFetchingMore, setIsFetchingMore] = useState(false);
|
|
10009
|
+
const isInfinite = mode === "infinite";
|
|
10010
|
+
useEffect(() => {
|
|
10011
|
+
setPageSize(defaultPageSize);
|
|
10012
|
+
}, [defaultPageSize]);
|
|
10013
|
+
const query = useFManualApiQuery(
|
|
10014
|
+
queryKey,
|
|
10015
|
+
url,
|
|
10016
|
+
initialFilters ? { ...initialFilters, page: 1, size: defaultPageSize } : void 0,
|
|
10017
|
+
config,
|
|
10018
|
+
{
|
|
10019
|
+
method,
|
|
10020
|
+
onErrorNotification,
|
|
10021
|
+
onErrorLog,
|
|
10022
|
+
onLoadingLog,
|
|
10023
|
+
onSuccessNotification,
|
|
10024
|
+
notificationTitle,
|
|
10025
|
+
notificationBody,
|
|
10026
|
+
loadingNotificationTitle,
|
|
10027
|
+
loadingNotificationBody,
|
|
10028
|
+
successNotificationTitle,
|
|
10029
|
+
successNotificationBody
|
|
10030
|
+
}
|
|
10031
|
+
);
|
|
10032
|
+
const rawData = query.data;
|
|
10033
|
+
const pageMeta = useMemo(() => {
|
|
10034
|
+
if (!rawData) return void 0;
|
|
10035
|
+
if (selectPage) return selectPage(rawData);
|
|
10036
|
+
return extractDefaultPageMeta(rawData, pageSize, page);
|
|
10037
|
+
}, [rawData, selectPage, pageSize, page]);
|
|
10038
|
+
const currentExtractedData = useMemo(() => {
|
|
10039
|
+
if (!rawData) return void 0;
|
|
10040
|
+
if (select) return select(rawData);
|
|
10041
|
+
return extractDefaultData(rawData);
|
|
10042
|
+
}, [rawData, select]);
|
|
10043
|
+
const meta = useMemo(() => {
|
|
10044
|
+
if (!rawData || typeof rawData !== "object") return void 0;
|
|
10045
|
+
return rawData.meta;
|
|
10046
|
+
}, [rawData]);
|
|
10047
|
+
const data = isInfinite ? accumulatedData : currentExtractedData;
|
|
10048
|
+
const extractResult = useCallback((rawResult) => {
|
|
10049
|
+
if (select) return select(rawResult);
|
|
10050
|
+
return extractDefaultData(rawResult);
|
|
10051
|
+
}, [select]);
|
|
10052
|
+
const defaultAppend = useCallback((prev, next) => {
|
|
10053
|
+
if (appendData) return appendData(prev, next);
|
|
10054
|
+
if (Array.isArray(next)) {
|
|
10055
|
+
const prevArray = Array.isArray(prev) ? prev : [];
|
|
10056
|
+
return [...prevArray, ...next];
|
|
10057
|
+
}
|
|
10058
|
+
return next;
|
|
10059
|
+
}, [appendData]);
|
|
10060
|
+
const submitFilters = useCallback(async ({
|
|
10061
|
+
payload,
|
|
10062
|
+
resetPage = true,
|
|
10063
|
+
dopUrl
|
|
10064
|
+
}) => {
|
|
10065
|
+
const targetPage = resetPage ? 1 : page;
|
|
10066
|
+
if (resetPage) {
|
|
10067
|
+
setPage(1);
|
|
10068
|
+
if (isInfinite) {
|
|
10069
|
+
setAccumulatedData(void 0);
|
|
10070
|
+
}
|
|
10071
|
+
}
|
|
10072
|
+
const rawResponse = await query.run({
|
|
10073
|
+
newParams: { ...payload, page: targetPage, size: pageSize },
|
|
10074
|
+
dopUrl
|
|
10075
|
+
});
|
|
10076
|
+
const extracted = extractResult(rawResponse);
|
|
10077
|
+
if (isInfinite) {
|
|
10078
|
+
setAccumulatedData(extracted);
|
|
10079
|
+
}
|
|
10080
|
+
return extracted;
|
|
10081
|
+
}, [query, page, pageSize, isInfinite, extractResult]);
|
|
10082
|
+
const changePage = useCallback(async (newPage) => {
|
|
10083
|
+
if (isInfinite) {
|
|
10084
|
+
setIsFetchingMore(true);
|
|
10085
|
+
try {
|
|
10086
|
+
const rawResponse = await query.run({
|
|
10087
|
+
newParams: { page: newPage, size: pageSize },
|
|
10088
|
+
mergeParams: true
|
|
10089
|
+
});
|
|
10090
|
+
const extracted = extractResult(rawResponse);
|
|
10091
|
+
setAccumulatedData((prev) => defaultAppend(prev, extracted));
|
|
10092
|
+
setPage(newPage);
|
|
10093
|
+
return extracted;
|
|
10094
|
+
} finally {
|
|
10095
|
+
setIsFetchingMore(false);
|
|
10096
|
+
}
|
|
10097
|
+
} else {
|
|
10098
|
+
setPage(newPage);
|
|
10099
|
+
const rawResponse = await query.run({
|
|
10100
|
+
newParams: { page: newPage, size: pageSize },
|
|
10101
|
+
mergeParams: true
|
|
10102
|
+
});
|
|
10103
|
+
return extractResult(rawResponse);
|
|
10104
|
+
}
|
|
10105
|
+
}, [query, pageSize, isInfinite, extractResult, defaultAppend]);
|
|
10106
|
+
const hasMore = useMemo(() => {
|
|
10107
|
+
if (!pageMeta) return false;
|
|
10108
|
+
return pageMeta.number < pageMeta.totalPages;
|
|
10109
|
+
}, [pageMeta]);
|
|
10110
|
+
const loadMore = useCallback(async () => {
|
|
10111
|
+
if (query.isFetching || isFetchingMore || !hasMore) {
|
|
10112
|
+
return void 0;
|
|
10113
|
+
}
|
|
10114
|
+
const nextPage = ((pageMeta == null ? void 0 : pageMeta.number) ?? page) + 1;
|
|
10115
|
+
return changePage(nextPage);
|
|
10116
|
+
}, [query.isFetching, isFetchingMore, hasMore, pageMeta, page, changePage]);
|
|
10117
|
+
const paginationProps = useMemo(() => ({
|
|
10118
|
+
currentPage: (pageMeta == null ? void 0 : pageMeta.number) ?? page,
|
|
10119
|
+
totalCount: (pageMeta == null ? void 0 : pageMeta.totalItems) ?? 0,
|
|
10120
|
+
pageSize: (pageMeta == null ? void 0 : pageMeta.size) ?? pageSize,
|
|
10121
|
+
siblingCount: 1,
|
|
10122
|
+
onPageChange: (newPage) => {
|
|
10123
|
+
if (typeof newPage === "number") {
|
|
10124
|
+
changePage(newPage).catch(() => {
|
|
10125
|
+
});
|
|
10126
|
+
} else if (newPage === "prev") {
|
|
10127
|
+
changePage(Math.max(1, ((pageMeta == null ? void 0 : pageMeta.number) ?? page) - 1)).catch(() => {
|
|
10128
|
+
});
|
|
10129
|
+
} else if (newPage === "next") {
|
|
10130
|
+
const max = (pageMeta == null ? void 0 : pageMeta.totalPages) ?? page;
|
|
10131
|
+
changePage(Math.min(max, ((pageMeta == null ? void 0 : pageMeta.number) ?? page) + 1)).catch(() => {
|
|
10132
|
+
});
|
|
10133
|
+
}
|
|
10134
|
+
}
|
|
10135
|
+
}), [pageMeta, page, pageSize, changePage]);
|
|
10136
|
+
return {
|
|
10137
|
+
data,
|
|
10138
|
+
result: data,
|
|
10139
|
+
rawResponse: rawData,
|
|
10140
|
+
meta,
|
|
10141
|
+
pageMeta,
|
|
10142
|
+
isLoading: query.isLoading,
|
|
10143
|
+
isFetching: query.isFetching,
|
|
10144
|
+
isFetchingMore,
|
|
10145
|
+
hasMore,
|
|
10146
|
+
error: query.error,
|
|
10147
|
+
submitFilters,
|
|
10148
|
+
changePage,
|
|
10149
|
+
loadMore,
|
|
10150
|
+
paginationProps
|
|
10151
|
+
};
|
|
10152
|
+
}
|
|
9843
10153
|
const waterError = "_waterError_10t7p_1";
|
|
9844
10154
|
const scene = "_scene_10t7p_12";
|
|
9845
10155
|
const waves = "_waves_10t7p_18";
|
|
@@ -9985,6 +10295,7 @@ export {
|
|
|
9985
10295
|
FPlusIcon,
|
|
9986
10296
|
FPreloader,
|
|
9987
10297
|
FProgress,
|
|
10298
|
+
FProgressiveList,
|
|
9988
10299
|
FRadioButton,
|
|
9989
10300
|
FReloadIcon,
|
|
9990
10301
|
FSafeIcon,
|
|
@@ -10045,6 +10356,7 @@ export {
|
|
|
10045
10356
|
useFApiQuery,
|
|
10046
10357
|
useFLibraryContext,
|
|
10047
10358
|
useFLibraryContextOptional,
|
|
10048
|
-
useFManualApiQuery
|
|
10359
|
+
useFManualApiQuery,
|
|
10360
|
+
useFManualPagination
|
|
10049
10361
|
};
|
|
10050
10362
|
//# sourceMappingURL=f-ui-kit.es.js.map
|