@hexclave/dashboard-ui-components 1.0.49 → 1.0.52
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/data-grid/data-grid.js +7 -5
- package/dist/components/data-grid/data-grid.js.map +1 -1
- package/dist/components/data-grid/data-grid.test.js +36 -3
- package/dist/components/data-grid/data-grid.test.js.map +1 -1
- package/dist/components/data-grid/use-data-source.js +56 -22
- package/dist/components/data-grid/use-data-source.js.map +1 -1
- package/dist/components/data-grid/use-data-source.test.d.ts +1 -0
- package/dist/components/data-grid/use-data-source.test.js +276 -0
- package/dist/components/data-grid/use-data-source.test.js.map +1 -0
- package/dist/dashboard-ui-components.global.js +74 -28
- package/dist/dashboard-ui-components.global.js.map +2 -2
- package/dist/data-grid-AJi1TNDa.d.ts.map +1 -1
- package/dist/esm/components/data-grid/data-grid.d.ts.map +1 -1
- package/dist/esm/components/data-grid/data-grid.js +7 -5
- package/dist/esm/components/data-grid/data-grid.js.map +1 -1
- package/dist/esm/components/data-grid/data-grid.test.js +36 -3
- package/dist/esm/components/data-grid/data-grid.test.js.map +1 -1
- package/dist/esm/components/data-grid/use-data-source.d.ts.map +1 -1
- package/dist/esm/components/data-grid/use-data-source.js +56 -22
- package/dist/esm/components/data-grid/use-data-source.js.map +1 -1
- package/dist/esm/components/data-grid/use-data-source.test.d.ts +1 -0
- package/dist/esm/components/data-grid/use-data-source.test.js +277 -0
- package/dist/esm/components/data-grid/use-data-source.test.js.map +1 -0
- package/dist/use-data-source-BVFynerX.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/data-grid/data-grid.test.tsx +46 -3
- package/src/components/data-grid/data-grid.tsx +22 -5
- package/src/components/data-grid/use-data-source.test.tsx +289 -0
- package/src/components/data-grid/use-data-source.ts +120 -18
|
@@ -9780,14 +9780,17 @@ attempted value: ${formattedValue}
|
|
|
9780
9780
|
if (error instanceof Error) concatStacktraces(error, currentError);
|
|
9781
9781
|
});
|
|
9782
9782
|
}
|
|
9783
|
-
async function wait(ms) {
|
|
9783
|
+
async function wait(ms, options) {
|
|
9784
9784
|
if (!Number.isFinite(ms) || ms < 0) throw new HexclaveAssertionError(`wait() requires a non-negative integer number of milliseconds to wait. (found: ${ms}ms)`);
|
|
9785
9785
|
if (ms >= 2 ** 31) throw new HexclaveAssertionError("The maximum timeout for wait() is 2147483647ms (2**31 - 1). (found: ${ms}ms)");
|
|
9786
9786
|
return await traceSpan({
|
|
9787
9787
|
description: "wait(...)",
|
|
9788
9788
|
attributes: { "stack.wait.ms": ms }
|
|
9789
9789
|
}, async (span) => {
|
|
9790
|
-
return await new Promise((resolve) =>
|
|
9790
|
+
return await new Promise((resolve) => {
|
|
9791
|
+
const timeout = setTimeout(resolve, ms);
|
|
9792
|
+
if (options?.unref === true && typeof timeout === "object") timeout.unref();
|
|
9793
|
+
});
|
|
9791
9794
|
});
|
|
9792
9795
|
}
|
|
9793
9796
|
function runAsynchronouslyWithAlert(...args) {
|
|
@@ -23005,6 +23008,7 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
23005
23008
|
}
|
|
23006
23009
|
|
|
23007
23010
|
// src/components/data-grid/data-grid.tsx
|
|
23011
|
+
var DEFAULT_INFINITE_MAX_HEIGHT = "calc(100dvh - 16rem)";
|
|
23008
23012
|
function getEventTargetElement(target) {
|
|
23009
23013
|
if (target instanceof Element) return target;
|
|
23010
23014
|
if (target instanceof Node) return target.parentElement;
|
|
@@ -23705,7 +23709,8 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
23705
23709
|
);
|
|
23706
23710
|
const allSelected = rowIds.length > 0 && rowIds.every((id) => state.selection.selectedIds.has(id));
|
|
23707
23711
|
const someSelected = !allSelected && rowIds.some((id) => state.selection.selectedIds.has(id));
|
|
23708
|
-
const
|
|
23712
|
+
const effectiveMaxHeight = maxHeight ?? (paginationMode === "infinite" && !fillHeight ? DEFAULT_INFINITE_MAX_HEIGHT : void 0);
|
|
23713
|
+
const infiniteScrollRootRef = paginationMode === "infinite" && (fillHeight || effectiveMaxHeight != null) ? scrollContainerRef : void 0;
|
|
23709
23714
|
const headers = (0, import_react35.useMemo)(
|
|
23710
23715
|
() => table.getHeaderGroups()[0]?.headers.filter((h) => visibleColumns.some((c4) => c4.id === h.column.id)) ?? [],
|
|
23711
23716
|
[table, visibleColumns]
|
|
@@ -23715,7 +23720,7 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
23715
23720
|
for (const h of headers) m5.set(h.column.id, h);
|
|
23716
23721
|
return m5;
|
|
23717
23722
|
}, [headers]);
|
|
23718
|
-
const isBounded = fillHeight ||
|
|
23723
|
+
const isBounded = fillHeight || effectiveMaxHeight != null;
|
|
23719
23724
|
return /* @__PURE__ */ jsxs(Fragment24, { children: [
|
|
23720
23725
|
/* @__PURE__ */ jsx(
|
|
23721
23726
|
DataGridExportDialog,
|
|
@@ -23738,7 +23743,7 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
23738
23743
|
isBounded && "overflow-hidden",
|
|
23739
23744
|
className
|
|
23740
23745
|
),
|
|
23741
|
-
style:
|
|
23746
|
+
style: effectiveMaxHeight != null ? { ...cssVars, maxHeight: effectiveMaxHeight } : cssVars,
|
|
23742
23747
|
role: "grid",
|
|
23743
23748
|
"aria-rowcount": totalRowCount ?? rows.length,
|
|
23744
23749
|
"aria-colcount": visibleColumns.length,
|
|
@@ -23748,7 +23753,7 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
23748
23753
|
{
|
|
23749
23754
|
ref: stickyChromeRef,
|
|
23750
23755
|
className: "sticky z-30 w-full min-w-0 shrink-0 overflow-visible rounded-t-[calc(var(--radius)*2)] bg-white/90 dark:bg-background backdrop-blur-xl",
|
|
23751
|
-
style: { top: stickyTop ?? (
|
|
23756
|
+
style: { top: stickyTop ?? (effectiveMaxHeight != null ? 0 : "var(--data-grid-sticky-top, 0px)") },
|
|
23752
23757
|
children: [
|
|
23753
23758
|
toolbar !== false && /* @__PURE__ */ jsx("div", { className: "relative bg-transparent", children: toolbar ? toolbar(toolbarCtx) : /* @__PURE__ */ jsx(
|
|
23754
23759
|
DataGridToolbar,
|
|
@@ -23989,10 +23994,15 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
23989
23994
|
const [hasMore, setHasMore] = (0, import_react36.useState)(true);
|
|
23990
23995
|
const [error, setError] = (0, import_react36.useState)(null);
|
|
23991
23996
|
const cursorRef = (0, import_react36.useRef)(void 0);
|
|
23992
|
-
const
|
|
23997
|
+
const inFlightFetchRef = (0, import_react36.useRef)(null);
|
|
23998
|
+
const pendingLoadMoreRef = (0, import_react36.useRef)(false);
|
|
23999
|
+
const hasMoreRef = (0, import_react36.useRef)(true);
|
|
24000
|
+
const paginationModeRef = (0, import_react36.useRef)(paginationMode);
|
|
24001
|
+
paginationModeRef.current = paginationMode;
|
|
23993
24002
|
const pageIndexRef = (0, import_react36.useRef)(0);
|
|
23994
24003
|
const hasDataRef = (0, import_react36.useRef)(false);
|
|
23995
24004
|
const hasMountedServerPaginationRef = (0, import_react36.useRef)(false);
|
|
24005
|
+
const lastCompletedNonAppendFetchKeyRef = (0, import_react36.useRef)(null);
|
|
23996
24006
|
const latestArgsRef = (0, import_react36.useRef)({
|
|
23997
24007
|
dataSource,
|
|
23998
24008
|
getRowId,
|
|
@@ -24005,6 +24015,9 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
24005
24015
|
const quickSearchKey = quickSearch;
|
|
24006
24016
|
const fetchPage = (0, import_react36.useCallback)(
|
|
24007
24017
|
async (append) => {
|
|
24018
|
+
if (append && inFlightFetchRef.current != null) {
|
|
24019
|
+
return;
|
|
24020
|
+
}
|
|
24008
24021
|
const {
|
|
24009
24022
|
dataSource: currentDataSource,
|
|
24010
24023
|
getRowId: currentGetRowId,
|
|
@@ -24012,9 +24025,15 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
24012
24025
|
quickSearch: currentQuickSearch,
|
|
24013
24026
|
pagination: currentPagination
|
|
24014
24027
|
} = latestArgsRef.current;
|
|
24015
|
-
|
|
24028
|
+
inFlightFetchRef.current?.abort();
|
|
24016
24029
|
const controller = new AbortController();
|
|
24017
|
-
|
|
24030
|
+
inFlightFetchRef.current = controller;
|
|
24031
|
+
const fetchKey = {
|
|
24032
|
+
dataSource: currentDataSource,
|
|
24033
|
+
sortingKey: JSON.stringify(currentSorting),
|
|
24034
|
+
quickSearchKey: currentQuickSearch,
|
|
24035
|
+
pageSize: currentPagination.pageSize
|
|
24036
|
+
};
|
|
24018
24037
|
if (append) {
|
|
24019
24038
|
setIsLoadingMore(true);
|
|
24020
24039
|
} else {
|
|
@@ -24023,16 +24042,18 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
24023
24042
|
} else {
|
|
24024
24043
|
setIsLoading(true);
|
|
24025
24044
|
}
|
|
24026
|
-
cursorRef.current = void 0;
|
|
24027
|
-
pageIndexRef.current = 0;
|
|
24028
24045
|
}
|
|
24029
24046
|
setError(null);
|
|
24047
|
+
let cursor = append ? cursorRef.current : void 0;
|
|
24048
|
+
let pageIndex = append ? pageIndexRef.current : 0;
|
|
24049
|
+
let failed = false;
|
|
24050
|
+
let committedResult = false;
|
|
24030
24051
|
try {
|
|
24031
24052
|
const params = {
|
|
24032
24053
|
sorting: currentSorting,
|
|
24033
24054
|
quickSearch: currentQuickSearch,
|
|
24034
|
-
pagination: append ? { pageIndex
|
|
24035
|
-
cursor
|
|
24055
|
+
pagination: append ? { pageIndex, pageSize: currentPagination.pageSize } : currentPagination,
|
|
24056
|
+
cursor
|
|
24036
24057
|
};
|
|
24037
24058
|
const gen = currentDataSource(params);
|
|
24038
24059
|
for await (const result of gen) {
|
|
@@ -24041,9 +24062,11 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
24041
24062
|
setTotalRowCount(result.totalRowCount);
|
|
24042
24063
|
}
|
|
24043
24064
|
if (result.nextCursor !== void 0) {
|
|
24044
|
-
|
|
24065
|
+
cursor = result.nextCursor;
|
|
24045
24066
|
}
|
|
24046
|
-
|
|
24067
|
+
cursorRef.current = cursor;
|
|
24068
|
+
hasMoreRef.current = result.hasMore !== false;
|
|
24069
|
+
setHasMore(hasMoreRef.current);
|
|
24047
24070
|
if (append) {
|
|
24048
24071
|
setRows((prev) => {
|
|
24049
24072
|
const existingIds = new Set(prev.map(currentGetRowId));
|
|
@@ -24053,29 +24076,50 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
24053
24076
|
return [...prev, ...newRows];
|
|
24054
24077
|
});
|
|
24055
24078
|
} else {
|
|
24079
|
+
lastCompletedNonAppendFetchKeyRef.current = null;
|
|
24056
24080
|
setRows(result.rows);
|
|
24057
24081
|
}
|
|
24058
24082
|
hasDataRef.current = true;
|
|
24059
|
-
|
|
24083
|
+
committedResult = true;
|
|
24084
|
+
pageIndex++;
|
|
24085
|
+
pageIndexRef.current = pageIndex;
|
|
24086
|
+
}
|
|
24087
|
+
if (!append && committedResult && !controller.signal.aborted) {
|
|
24088
|
+
lastCompletedNonAppendFetchKeyRef.current = fetchKey;
|
|
24060
24089
|
}
|
|
24061
24090
|
} catch (err) {
|
|
24062
24091
|
if (controller.signal.aborted) return;
|
|
24063
24092
|
console.error("[DataGrid] Data source error:", err);
|
|
24093
|
+
failed = true;
|
|
24064
24094
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
24065
24095
|
} finally {
|
|
24066
|
-
if (
|
|
24096
|
+
if (inFlightFetchRef.current === controller) {
|
|
24097
|
+
inFlightFetchRef.current = null;
|
|
24067
24098
|
setIsLoading(false);
|
|
24068
24099
|
setIsRefetching(false);
|
|
24069
24100
|
setIsLoadingMore(false);
|
|
24101
|
+
const shouldChainLoadMore = pendingLoadMoreRef.current && !failed && !controller.signal.aborted && hasMoreRef.current && paginationModeRef.current === "infinite";
|
|
24102
|
+
pendingLoadMoreRef.current = false;
|
|
24103
|
+
if (shouldChainLoadMore) {
|
|
24104
|
+
runAsynchronously(fetchPage(true));
|
|
24105
|
+
}
|
|
24070
24106
|
}
|
|
24071
24107
|
}
|
|
24072
24108
|
},
|
|
24073
24109
|
[]
|
|
24074
24110
|
);
|
|
24075
24111
|
(0, import_react36.useEffect)(() => {
|
|
24076
|
-
|
|
24077
|
-
|
|
24078
|
-
|
|
24112
|
+
if (paginationMode !== "infinite") {
|
|
24113
|
+
pendingLoadMoreRef.current = false;
|
|
24114
|
+
}
|
|
24115
|
+
}, [paginationMode]);
|
|
24116
|
+
(0, import_react36.useEffect)(() => {
|
|
24117
|
+
const lastCompletedKey = lastCompletedNonAppendFetchKeyRef.current;
|
|
24118
|
+
const isSameCompletedFetch = hasDataRef.current && lastCompletedKey?.dataSource === dataSource && lastCompletedKey.sortingKey === sortingKey && lastCompletedKey.quickSearchKey === quickSearchKey && lastCompletedKey.pageSize === pagination.pageSize;
|
|
24119
|
+
if (!isSameCompletedFetch) {
|
|
24120
|
+
runAsynchronously(fetchPage(false));
|
|
24121
|
+
}
|
|
24122
|
+
return () => inFlightFetchRef.current?.abort();
|
|
24079
24123
|
}, [fetchPage, dataSource, sortingKey, quickSearchKey, pagination.pageSize]);
|
|
24080
24124
|
(0, import_react36.useEffect)(() => {
|
|
24081
24125
|
if (paginationMode !== "server") {
|
|
@@ -24086,18 +24130,20 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
24086
24130
|
hasMountedServerPaginationRef.current = true;
|
|
24087
24131
|
return;
|
|
24088
24132
|
}
|
|
24089
|
-
fetchPage(false)
|
|
24090
|
-
});
|
|
24133
|
+
runAsynchronously(fetchPage(false));
|
|
24091
24134
|
}, [fetchPage, paginationMode, pagination.pageIndex]);
|
|
24092
24135
|
const loadMore = (0, import_react36.useCallback)(() => {
|
|
24093
|
-
if (
|
|
24094
|
-
|
|
24095
|
-
|
|
24136
|
+
if (paginationMode !== "infinite" || !hasMore) {
|
|
24137
|
+
return;
|
|
24138
|
+
}
|
|
24139
|
+
if (inFlightFetchRef.current != null) {
|
|
24140
|
+
pendingLoadMoreRef.current = true;
|
|
24141
|
+
return;
|
|
24096
24142
|
}
|
|
24097
|
-
|
|
24143
|
+
runAsynchronously(fetchPage(true));
|
|
24144
|
+
}, [hasMore, paginationMode, fetchPage]);
|
|
24098
24145
|
const reload = (0, import_react36.useCallback)(() => {
|
|
24099
|
-
fetchPage(false)
|
|
24100
|
-
});
|
|
24146
|
+
runAsynchronously(fetchPage(false));
|
|
24101
24147
|
}, [fetchPage]);
|
|
24102
24148
|
return {
|
|
24103
24149
|
rows,
|