schummar-table 0.21.1 → 0.21.3

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 CHANGED
@@ -1560,6 +1560,28 @@ function useTableStateStorage(table) {
1560
1560
  (async () => {
1561
1561
  var _a, _b;
1562
1562
  try {
1563
+ let applyUpdate = function(state, key) {
1564
+ var _a2, _b2, _c, _d;
1565
+ if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key)) && key in data) {
1566
+ if (key === "filterValues") {
1567
+ for (const [id2, value] of data[key]) {
1568
+ const filter = state.filters.get(id2);
1569
+ if (filter && (filter.persist ?? filter.value === void 0)) {
1570
+ state.filterValues.set(id2, value);
1571
+ (_b2 = (_a2 = state.filters.get(id2)) == null ? void 0 : _a2.onChange) == null ? void 0 : _b2.call(_a2, value);
1572
+ }
1573
+ }
1574
+ } else {
1575
+ if (key === "expanded" || key === "hiddenColumns" || key === "selection" || key === "sort") {
1576
+ if (state.props[key] !== void 0) {
1577
+ return;
1578
+ }
1579
+ (_d = (_c = state.props)[`on${key.slice(0, 1).toUpperCase() + key.slice(1)}Change`]) == null ? void 0 : _d.call(_c, data[key]);
1580
+ }
1581
+ state[key] = data[key];
1582
+ }
1583
+ }
1584
+ };
1563
1585
  const {
1564
1586
  storage,
1565
1587
  id,
@@ -1572,27 +1594,14 @@ function useTableStateStorage(table) {
1572
1594
  const data = parse(json);
1573
1595
  (_b = (_a = table.getState().props).debug) == null ? void 0 : _b.call(_a, "load", json, data);
1574
1596
  table.update((state) => {
1575
- var _a2, _b2, _c, _d;
1576
- for (const key of KEYS) {
1577
- if ((!include || include.includes(key)) && !(exclude == null ? void 0 : exclude.includes(key)) && key in data) {
1578
- if (key === "filterValues") {
1579
- for (const [id2, value] of data[key]) {
1580
- if (((_a2 = state.filters.get(id2)) == null ? void 0 : _a2.persist) ?? ((_b2 = state.filters.get(id2)) == null ? void 0 : _b2.value) === void 0) {
1581
- state.filterValues.set(id2, value);
1582
- }
1583
- }
1584
- } else {
1585
- if (key === "expanded" || key === "hiddenColumns" || key === "selection" || key === "sort") {
1586
- if (state.props[key] !== void 0) {
1587
- continue;
1588
- }
1589
- (_d = (_c = state.props)[`on${key.slice(0, 1).toUpperCase() + key.slice(1)}Change`]) == null ? void 0 : _d.call(_c, data[key]);
1590
- }
1591
- state[key] = data[key];
1592
- }
1593
- }
1597
+ for (const key of KEYS.filter((key2) => key2 !== "filterValues")) {
1598
+ applyUpdate(state, key);
1594
1599
  }
1595
1600
  });
1601
+ await new Promise((resolve) => {
1602
+ setTimeout(resolve);
1603
+ });
1604
+ table.update((state) => applyUpdate(state, "filterValues"));
1596
1605
  } catch (error) {
1597
1606
  console.error("Failed to load table state:", error);
1598
1607
  } finally {