schummar-table 0.5.2 → 0.5.5
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/cjs/index.js +20 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +17 -15
- package/dist/es/index.js.map +1 -1
- package/dist/types/components/dateFilter.d.ts +3 -0
- package/dist/types/components/datePicker.d.ts +8 -0
- package/dist/types/components/selectFilter.d.ts +4 -0
- package/dist/types/components/textFilter.d.ts +4 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/internalState/syncSelections.d.ts +1 -1
- package/dist/types/types.d.ts +26 -11
- package/package.json +1 -5
package/dist/cjs/index.js
CHANGED
|
@@ -621,6 +621,7 @@ class Queue {
|
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
const KEYS = ["sort", "selection", "expanded", "hiddenColumns", "filterValues", "columnWidths", "columnOrder"];
|
|
624
|
+
const storageName = (id) => `schummar-table_state-v1_${id}`;
|
|
624
625
|
function stringify(value) {
|
|
625
626
|
function prepare(value2) {
|
|
626
627
|
if (value2 instanceof Date) {
|
|
@@ -669,8 +670,8 @@ function useTableStateStorage() {
|
|
|
669
670
|
(async () => {
|
|
670
671
|
var _a, _b;
|
|
671
672
|
try {
|
|
672
|
-
const { storage, id
|
|
673
|
-
const json = await storage.getItem(
|
|
673
|
+
const { storage, id, include, exclude } = persist;
|
|
674
|
+
const json = await storage.getItem(storageName(id));
|
|
674
675
|
if (isCanceled || !json)
|
|
675
676
|
return;
|
|
676
677
|
const data = parse(json);
|
|
@@ -712,7 +713,7 @@ function useTableStateStorage() {
|
|
|
712
713
|
var _a, _b;
|
|
713
714
|
if (!state.props.persist)
|
|
714
715
|
return;
|
|
715
|
-
const { storage, id
|
|
716
|
+
const { storage, id, include, exclude } = state.props.persist;
|
|
716
717
|
const data = {};
|
|
717
718
|
for (const key of KEYS) {
|
|
718
719
|
if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key))) {
|
|
@@ -736,7 +737,7 @@ function useTableStateStorage() {
|
|
|
736
737
|
const { storage, id, data } = props;
|
|
737
738
|
(_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "save", data, stringify(data));
|
|
738
739
|
q.run(async () => {
|
|
739
|
-
await storage.setItem(
|
|
740
|
+
await storage.setItem(storageName(id), stringify(data));
|
|
740
741
|
}, true);
|
|
741
742
|
}, { throttle: 1e3 });
|
|
742
743
|
}, [isHydrated]);
|
|
@@ -935,7 +936,7 @@ function cleanupState(state) {
|
|
|
935
936
|
draft.sort = newSort;
|
|
936
937
|
setTimeout(() => {
|
|
937
938
|
var _a, _b;
|
|
938
|
-
(_b = (_a =
|
|
939
|
+
(_b = (_a = state.getState().props).onSortChange) == null ? void 0 : _b.call(_a, newSort);
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
942
|
for (const id of draft.filters.keys()) {
|
|
@@ -964,7 +965,7 @@ function cleanupState(state) {
|
|
|
964
965
|
draft.selection = newSelection;
|
|
965
966
|
setTimeout(() => {
|
|
966
967
|
var _a, _b;
|
|
967
|
-
(_b = (_a =
|
|
968
|
+
(_b = (_a = state.getState().props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
|
|
968
969
|
});
|
|
969
970
|
}
|
|
970
971
|
const newExpanded = intersect(draft.expanded, itemsById);
|
|
@@ -972,7 +973,7 @@ function cleanupState(state) {
|
|
|
972
973
|
draft.expanded = newExpanded;
|
|
973
974
|
setTimeout(() => {
|
|
974
975
|
var _a, _b;
|
|
975
|
-
(_b = (_a =
|
|
976
|
+
(_b = (_a = state.getState().props).onExpandedChange) == null ? void 0 : _b.call(_a, newExpanded);
|
|
976
977
|
});
|
|
977
978
|
}
|
|
978
979
|
}
|
|
@@ -983,8 +984,8 @@ function filterColumns(state) {
|
|
|
983
984
|
draft.activeColumns = orderBy(columns.filter((column) => !hiddenColumns.has(column.id)), [(column) => columnOrder.indexOf(column.id)]);
|
|
984
985
|
}, { runNow: true }), [state]);
|
|
985
986
|
}
|
|
986
|
-
function syncSelections(
|
|
987
|
-
react.useEffect(() =>
|
|
987
|
+
function syncSelections(table) {
|
|
988
|
+
react.useEffect(() => table.addReaction((state) => [state.props.selectSyncChildren, state.selection, state.activeItems], ([selectSyncChildren, selection, activeItems], state) => {
|
|
988
989
|
if (!selectSyncChildren)
|
|
989
990
|
return;
|
|
990
991
|
const newSelection = new Set(selection);
|
|
@@ -994,13 +995,13 @@ function syncSelections(state) {
|
|
|
994
995
|
}
|
|
995
996
|
}
|
|
996
997
|
if (newSelection.size !== selection.size) {
|
|
997
|
-
|
|
998
|
+
state.selection = newSelection;
|
|
998
999
|
setTimeout(() => {
|
|
999
1000
|
var _a, _b;
|
|
1000
|
-
(_b = (_a =
|
|
1001
|
+
(_b = (_a = table.getState().props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
|
|
1001
1002
|
});
|
|
1002
1003
|
}
|
|
1003
|
-
}, { runNow: true }), [
|
|
1004
|
+
}, { runNow: true }), [table]);
|
|
1004
1005
|
}
|
|
1005
1006
|
function useTableState(_props) {
|
|
1006
1007
|
const props = calcProps(_props);
|
|
@@ -1925,8 +1926,10 @@ function Virtualized(_e) {
|
|
|
1925
1926
|
if (!virtual || !probeRef.current)
|
|
1926
1927
|
return;
|
|
1927
1928
|
window.addEventListener("scroll", incCounter, true);
|
|
1929
|
+
window.addEventListener("resize", incCounter, true);
|
|
1928
1930
|
return () => {
|
|
1929
1931
|
window.removeEventListener("scroll", incCounter, true);
|
|
1932
|
+
window.removeEventListener("resize", incCounter, true);
|
|
1930
1933
|
};
|
|
1931
1934
|
}, [probeRef.current, incCounter]);
|
|
1932
1935
|
(_d = (_c = table.getState().props).debugRender) == null ? void 0 : _d.call(_c, `Virtualalized render ${from} to ${to}`);
|
|
@@ -2193,7 +2196,6 @@ function debounce(fn, ms) {
|
|
|
2193
2196
|
});
|
|
2194
2197
|
}
|
|
2195
2198
|
function useFilter(impl) {
|
|
2196
|
-
var _a;
|
|
2197
2199
|
const table = useTableContext();
|
|
2198
2200
|
const columnId = useColumnContext();
|
|
2199
2201
|
react.useEffect(() => {
|
|
@@ -2215,7 +2217,7 @@ function useFilter(impl) {
|
|
|
2215
2217
|
state.filters.delete(columnId);
|
|
2216
2218
|
});
|
|
2217
2219
|
};
|
|
2218
|
-
}, [table, columnId,
|
|
2220
|
+
}, [table, columnId, impl]);
|
|
2219
2221
|
const value = table.useState((state) => state.filterValues.get(columnId));
|
|
2220
2222
|
const [dirtyValue, setDirtyValue] = react.useState();
|
|
2221
2223
|
const implRef = react.useRef(impl);
|
|
@@ -2314,10 +2316,14 @@ exports.mergeThemes = tableTheme.mergeThemes;
|
|
|
2314
2316
|
exports.AutoFocusTextField = AutoFocusTextField;
|
|
2315
2317
|
exports.ColumnContext = ColumnContext;
|
|
2316
2318
|
exports.DateFilter = DateFilter;
|
|
2319
|
+
exports.DatePicker = DatePicker;
|
|
2317
2320
|
exports.SelectFilter = SelectFilter;
|
|
2318
2321
|
exports.Table = Table;
|
|
2319
2322
|
exports.TableContext = TableContext;
|
|
2320
2323
|
exports.TextFilter = TextFilter;
|
|
2324
|
+
exports.dateIntersect = dateIntersect;
|
|
2325
|
+
exports.endOfDay = endOfDay;
|
|
2326
|
+
exports.startOfDay = startOfDay;
|
|
2321
2327
|
exports.termMatch = termMatch;
|
|
2322
2328
|
exports.textMatch = textMatch;
|
|
2323
2329
|
exports.useColumnContext = useColumnContext;
|