@gridkitjs/react 0.0.0-dev-20261108231420 → 0.0.0-dev-20261109124753
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/index.d.ts +5 -3
- package/dist/index.js +62 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -315,9 +315,11 @@ interface InfiniteScrollConfig {
|
|
|
315
315
|
/** Whether a further `onLoadMore` could still return more rows. `false` removes the sentinel entirely, so no further scrolling can trigger a load. */
|
|
316
316
|
readonly hasMore: boolean;
|
|
317
317
|
/**
|
|
318
|
-
* Called
|
|
319
|
-
*
|
|
320
|
-
*
|
|
318
|
+
* Called when the sentinel comes within `rootMargin` of the body's
|
|
319
|
+
* viewport, then not again until one of these says the request was
|
|
320
|
+
* answered: `isLoadingMore` goes back to `false`, `hasMore` changes, the
|
|
321
|
+
* sentinel leaves range and comes back, or rows appended while
|
|
322
|
+
* `isLoadingMore` never read `true` move the sentinel down.
|
|
321
323
|
*/
|
|
322
324
|
readonly onLoadMore: () => void;
|
|
323
325
|
/** Whether a load triggered by `onLoadMore` is still in flight. Suppresses further calls to it until this goes back to `false`. */
|
package/dist/index.js
CHANGED
|
@@ -1767,32 +1767,42 @@ function exportApi({
|
|
|
1767
1767
|
}
|
|
1768
1768
|
|
|
1769
1769
|
// src/DataGrid/export/useSaveFile.ts
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1770
|
+
var IDLE = { kind: "idle" };
|
|
1771
|
+
var WRITING = { kind: "writing" };
|
|
1773
1772
|
function useSaveFile({
|
|
1774
1773
|
messages,
|
|
1775
1774
|
announce
|
|
1776
1775
|
}) {
|
|
1777
|
-
const
|
|
1776
|
+
const state = useRef3(IDLE);
|
|
1777
|
+
function fail(reason, error) {
|
|
1778
|
+
console.error(`DataGrid: ${reason}`, error);
|
|
1779
|
+
announce(messages.exportFailed);
|
|
1780
|
+
}
|
|
1781
|
+
function download(file) {
|
|
1782
|
+
try {
|
|
1783
|
+
downloadBlob(exportBlob(file), file.fileName);
|
|
1784
|
+
} catch (error) {
|
|
1785
|
+
fail("the export could not be saved.", error);
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1778
1788
|
return (file) => {
|
|
1779
|
-
if (
|
|
1789
|
+
if (state.current.kind === "writing") {
|
|
1780
1790
|
console.error(
|
|
1781
1791
|
"DataGrid: an export is still being written, so this one was dropped."
|
|
1782
1792
|
);
|
|
1783
|
-
return;
|
|
1793
|
+
return false;
|
|
1784
1794
|
}
|
|
1785
1795
|
if (!(file instanceof Promise)) {
|
|
1786
1796
|
download(file);
|
|
1787
|
-
return;
|
|
1797
|
+
return true;
|
|
1788
1798
|
}
|
|
1789
|
-
|
|
1799
|
+
state.current = WRITING;
|
|
1790
1800
|
file.then(download, (error) => {
|
|
1791
|
-
|
|
1792
|
-
announce(messages.exportFailed);
|
|
1801
|
+
fail("the export's writer failed.", error);
|
|
1793
1802
|
}).finally(() => {
|
|
1794
|
-
|
|
1803
|
+
state.current = IDLE;
|
|
1795
1804
|
});
|
|
1805
|
+
return true;
|
|
1796
1806
|
};
|
|
1797
1807
|
}
|
|
1798
1808
|
|
|
@@ -1855,6 +1865,7 @@ function useGridCommands({
|
|
|
1855
1865
|
print: (document2, options) => {
|
|
1856
1866
|
printGrid(document2, options).catch((error) => {
|
|
1857
1867
|
console.error("DataGrid: the print failed.", error);
|
|
1868
|
+
announce(messages.printFailed);
|
|
1858
1869
|
});
|
|
1859
1870
|
}
|
|
1860
1871
|
};
|
|
@@ -4955,20 +4966,38 @@ import { serializeGridState } from "@gridkitjs/core";
|
|
|
4955
4966
|
import { useCallback as useCallback5 } from "react";
|
|
4956
4967
|
|
|
4957
4968
|
// src/DataGrid/hooks/useGridSnapshot.ts
|
|
4958
|
-
import {
|
|
4969
|
+
import {
|
|
4970
|
+
useCallback as useCallback4,
|
|
4971
|
+
useEffect as useEffect9,
|
|
4972
|
+
useRef as useRef22,
|
|
4973
|
+
useSyncExternalStore as useSyncExternalStore3
|
|
4974
|
+
} from "react";
|
|
4975
|
+
function subscribeTo(api, listener) {
|
|
4976
|
+
return api === null ? { kind: "waiting", listener } : {
|
|
4977
|
+
kind: "subscribed",
|
|
4978
|
+
listener,
|
|
4979
|
+
api,
|
|
4980
|
+
unsubscribe: api.subscribe(listener)
|
|
4981
|
+
};
|
|
4982
|
+
}
|
|
4983
|
+
function unsubscribe(subscription) {
|
|
4984
|
+
if (subscription?.kind === "subscribed") {
|
|
4985
|
+
subscription.unsubscribe();
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
4959
4988
|
function useGridSnapshot(gridRef, getSnapshot, fallback) {
|
|
4989
|
+
const subscription = useRef22(null);
|
|
4960
4990
|
const subscribe = useCallback4(
|
|
4961
4991
|
(listener) => {
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
}
|
|
4967
|
-
return api.subscribe(listener);
|
|
4992
|
+
subscription.current = subscribeTo(gridRef.current, listener);
|
|
4993
|
+
return () => {
|
|
4994
|
+
unsubscribe(subscription.current);
|
|
4995
|
+
subscription.current = null;
|
|
4996
|
+
};
|
|
4968
4997
|
},
|
|
4969
4998
|
[gridRef]
|
|
4970
4999
|
);
|
|
4971
|
-
|
|
5000
|
+
const snapshot = useSyncExternalStore3(
|
|
4972
5001
|
subscribe,
|
|
4973
5002
|
() => {
|
|
4974
5003
|
const api = gridRef.current;
|
|
@@ -4976,6 +5005,20 @@ function useGridSnapshot(gridRef, getSnapshot, fallback) {
|
|
|
4976
5005
|
},
|
|
4977
5006
|
() => fallback
|
|
4978
5007
|
);
|
|
5008
|
+
useEffect9(() => {
|
|
5009
|
+
const current = subscription.current;
|
|
5010
|
+
if (current === null) {
|
|
5011
|
+
return;
|
|
5012
|
+
}
|
|
5013
|
+
const api = gridRef.current;
|
|
5014
|
+
if (api === (current.kind === "subscribed" ? current.api : null)) {
|
|
5015
|
+
return;
|
|
5016
|
+
}
|
|
5017
|
+
unsubscribe(current);
|
|
5018
|
+
subscription.current = subscribeTo(api, current.listener);
|
|
5019
|
+
current.listener();
|
|
5020
|
+
});
|
|
5021
|
+
return snapshot;
|
|
4979
5022
|
}
|
|
4980
5023
|
|
|
4981
5024
|
// src/DataGrid/hooks/usePaginationState.ts
|