@gridsheet/preact-core 3.0.0-rc.6 → 3.0.0-rc.7
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.js +29 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/book.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1720,13 +1720,31 @@ function groupByType(cells) {
|
|
|
1720
1720
|
const resetZone = { startY: -1, startX: -1, endY: -1, endX: -1 };
|
|
1721
1721
|
const actions = {};
|
|
1722
1722
|
const reducer = (store, action) => {
|
|
1723
|
+
var _a, _b;
|
|
1723
1724
|
const act = actions[action.type];
|
|
1724
1725
|
if (act == null) {
|
|
1725
1726
|
return store;
|
|
1726
1727
|
}
|
|
1728
|
+
const registry = (_a = store.sheetReactive.current) == null ? void 0 : _a.registry;
|
|
1729
|
+
if ((_b = registry == null ? void 0 : registry._strictModeCache) == null ? void 0 : _b.has(action)) {
|
|
1730
|
+
const cached = registry._strictModeCache.get(action);
|
|
1731
|
+
registry._strictModeCache.delete(action);
|
|
1732
|
+
return cached;
|
|
1733
|
+
}
|
|
1727
1734
|
const { callback, ...newStore } = act.reduce(store, action.value);
|
|
1728
1735
|
callback == null ? void 0 : callback(newStore);
|
|
1729
|
-
|
|
1736
|
+
const result = { ...store, ...newStore };
|
|
1737
|
+
if (registry) {
|
|
1738
|
+
if (!registry._strictModeCache) {
|
|
1739
|
+
registry._strictModeCache = /* @__PURE__ */ new Map();
|
|
1740
|
+
}
|
|
1741
|
+
registry._strictModeCache.set(action, result);
|
|
1742
|
+
queueMicrotask(() => {
|
|
1743
|
+
var _a2;
|
|
1744
|
+
(_a2 = registry._strictModeCache) == null ? void 0 : _a2.delete(action);
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
return result;
|
|
1730
1748
|
};
|
|
1731
1749
|
const _CoreAction = class _CoreAction {
|
|
1732
1750
|
constructor() {
|
|
@@ -4510,6 +4528,7 @@ class Registry {
|
|
|
4510
4528
|
this.histories = [];
|
|
4511
4529
|
this.historyIndex = -1;
|
|
4512
4530
|
this.historyLimit = DEFAULT_HISTORY_LIMIT;
|
|
4531
|
+
this._componentSheetIds = /* @__PURE__ */ new Map();
|
|
4513
4532
|
this.ready = false;
|
|
4514
4533
|
this.functions = {};
|
|
4515
4534
|
this.policies = {};
|
|
@@ -13834,11 +13853,15 @@ function GridSheet({
|
|
|
13834
13853
|
const internalBook = useBook({});
|
|
13835
13854
|
const book = initialBook ?? internalBook;
|
|
13836
13855
|
const { registry } = book;
|
|
13837
|
-
const
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13856
|
+
const [sheetId] = useState(() => {
|
|
13857
|
+
if (sheetName) {
|
|
13858
|
+
if (!registry._componentSheetIds.has(sheetName)) {
|
|
13859
|
+
registry._componentSheetIds.set(sheetName, ++registry.sheetHead);
|
|
13860
|
+
}
|
|
13861
|
+
return registry._componentSheetIds.get(sheetName);
|
|
13862
|
+
}
|
|
13863
|
+
return ++registry.sheetHead;
|
|
13864
|
+
});
|
|
13842
13865
|
const sheetReactive = useRef(null);
|
|
13843
13866
|
const [initialState] = useState(() => {
|
|
13844
13867
|
var _a2;
|