@rowsncolumns/y-spreadsheet 17.0.3 → 17.1.0
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/helpers-v5.d.ts
CHANGED
|
@@ -30,6 +30,16 @@ export declare const readStyleOverlayV5: (doc: YDoc) => StyleOverlayV5;
|
|
|
30
30
|
* A malformed block reads as the entries decoded before the damage.
|
|
31
31
|
*/
|
|
32
32
|
export declare const decodeColumnBlockV5: (buf: Uint8Array) => Map<number, CellData>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the doc's format marker says `sheet-format.cells >= 2`
|
|
35
|
+
* (`stage2_cell_format` in rnc-yrs-store-v3): on a v5 doc past it, formula text
|
|
36
|
+
* is rendered from `ft` on read and a stored `ue.fv` may be stale.
|
|
37
|
+
*/
|
|
38
|
+
export declare const v5RendersFormulaTextOnRead: (doc: YDoc) => boolean;
|
|
39
|
+
/** What every reader and writer here throws on a doc past the marker. */
|
|
40
|
+
export declare class V5FormulaTextOnReadError extends Error {
|
|
41
|
+
constructor();
|
|
42
|
+
}
|
|
33
43
|
/**
|
|
34
44
|
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
|
|
35
45
|
* `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAQnC,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,SAAS,CAA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gBzB;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,UAAU,KACd;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,IA8C3C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,IAAI,EACT,SAAS,MAAM,EACf,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,KAC/B,qBAmDF,CAAC;AA0SF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,KAAK,IAAI,EACT,SAAS,KAAK,EAAE,GAAG,SAAS,EAC5B,SAAQ,OAAc,EACtB,SAAS,cAAc,SA+CxB,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,SAAS,GACpB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,aAAa,MAAM,EACnB,OAAO,QAAQ,KACd,IAGC,CAAC;AAEL,iEAAiE;AACjE,eAAO,MAAM,YAAY,GACvB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,IAGC,CAAC;AAEL,kFAAkF;AAClF,eAAO,MAAM,aAAa,GAAI,KAAK,IAAI,EAAE,SAAS,MAAM,KAAG,IACM,CAAC"}
|
package/dist/cjs/helpers-v5.js
CHANGED
|
@@ -21,8 +21,13 @@
|
|
|
21
21
|
// positional in its write frame, `ue.fv` being the truth) and never writes a
|
|
22
22
|
// facet `anchor` (a facet written here is positional and gains one on its next
|
|
23
23
|
// engine write).
|
|
24
|
+
// Past the Stage 2 format marker (`sheet-format.cells >= 2`) a structural edit
|
|
25
|
+
// leaves `ue.fv` as written and the engine renders formula text from `ft` on
|
|
26
|
+
// read, so a stored `ue.fv` may name cells the formula no longer reads. This
|
|
27
|
+
// module reads `ue.fv` as stored: every reader and writer here refuses such a
|
|
28
|
+
// doc (`V5FormulaTextOnReadError`); read it through the engine.
|
|
24
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.deleteSheetV5 = exports.deleteCellV5 = exports.setCellV5 = exports.addSheetDataPatchesV5 = exports.resolveFacetAnchorV5 = exports.decodeFacetAnchorV5 = exports.processSheetDataChangesV5 = exports.getCellV5 = exports.createCellReaderV5 = exports.sheetDataV5ToV2 = exports.decodeColumnBlockV5 = exports.readStyleOverlayV5 = exports.parseCellKeyV5 = exports.createCellKeyV5 = exports.readLineIds = void 0;
|
|
30
|
+
exports.deleteSheetV5 = exports.deleteCellV5 = exports.setCellV5 = exports.addSheetDataPatchesV5 = exports.resolveFacetAnchorV5 = exports.decodeFacetAnchorV5 = exports.processSheetDataChangesV5 = exports.getCellV5 = exports.createCellReaderV5 = exports.sheetDataV5ToV2 = exports.V5FormulaTextOnReadError = exports.v5RendersFormulaTextOnRead = exports.decodeColumnBlockV5 = exports.readStyleOverlayV5 = exports.parseCellKeyV5 = exports.createCellKeyV5 = exports.readLineIds = void 0;
|
|
26
31
|
var tslib_1 = require("tslib");
|
|
27
32
|
var utils_1 = require("@rowsncolumns/utils");
|
|
28
33
|
var fflate_1 = require("fflate");
|
|
@@ -44,6 +49,8 @@ var BLOCK_V2_MAGIC = 0x80000000; // BLOCK_V2_MAGIC
|
|
|
44
49
|
var BLOCK_V2_DENSE = 0x40000000; // BLOCK_V2_DENSE
|
|
45
50
|
var MAX_BLOCK_RAW_BYTES = 512 * 1024 * 1024; // MAX_BLOCK_RAW_BYTES
|
|
46
51
|
var STYLE_LOG_V1 = 1; // STYLE_LOG_V1
|
|
52
|
+
var FORMAT_ROOT = "sheet-format"; // rnc-yrs-store-v3 node_cell::FORMAT_ROOT
|
|
53
|
+
var NODE_CELL_FORMAT = 2; // rnc-yrs-store-v3 node_cell::NODE_CELL_FORMAT
|
|
47
54
|
var STYLE_LOG_V2 = 2; // STYLE_LOG_V2
|
|
48
55
|
var CELL_KEY_V5 = /^(-?\d+):(-?\d+):(-?\d+)$/; // cell_key
|
|
49
56
|
var BLOCK_KEY_V5 = /^(-?\d+):(-?\d+):(\d+)$/; // block_key
|
|
@@ -442,6 +449,33 @@ var coldCellV5 = function (doc, cache, sheetId, rowId, colId) {
|
|
|
442
449
|
return (_a = cells.get((counter - 1) % BLOCK_ROWS)) !== null && _a !== void 0 ? _a : null;
|
|
443
450
|
};
|
|
444
451
|
// ── readers ─────────────────────────────────────────────────────────────────
|
|
452
|
+
/**
|
|
453
|
+
* Whether the doc's format marker says `sheet-format.cells >= 2`
|
|
454
|
+
* (`stage2_cell_format` in rnc-yrs-store-v3): on a v5 doc past it, formula text
|
|
455
|
+
* is rendered from `ft` on read and a stored `ue.fv` may be stale.
|
|
456
|
+
*/
|
|
457
|
+
var v5RendersFormulaTextOnRead = function (doc) {
|
|
458
|
+
if (!doc.share.has(FORMAT_ROOT))
|
|
459
|
+
return false;
|
|
460
|
+
var cells = doc.get(FORMAT_ROOT).getAttr("cells");
|
|
461
|
+
return typeof cells === "number" && cells >= NODE_CELL_FORMAT;
|
|
462
|
+
};
|
|
463
|
+
exports.v5RendersFormulaTextOnRead = v5RendersFormulaTextOnRead;
|
|
464
|
+
/** What every reader and writer here throws on a doc past the marker. */
|
|
465
|
+
var V5FormulaTextOnReadError = /** @class */ (function (_super) {
|
|
466
|
+
tslib_1.__extends(V5FormulaTextOnReadError, _super);
|
|
467
|
+
function V5FormulaTextOnReadError() {
|
|
468
|
+
var _this = _super.call(this, "This sheet renders formula text on read (sheet-format.cells >= 2): read and write it through the engine") || this;
|
|
469
|
+
_this.name = "V5FormulaTextOnReadError";
|
|
470
|
+
return _this;
|
|
471
|
+
}
|
|
472
|
+
return V5FormulaTextOnReadError;
|
|
473
|
+
}(Error));
|
|
474
|
+
exports.V5FormulaTextOnReadError = V5FormulaTextOnReadError;
|
|
475
|
+
var refuseRenderedText = function (doc) {
|
|
476
|
+
if ((0, exports.v5RendersFormulaTextOnRead)(doc))
|
|
477
|
+
throw new V5FormulaTextOnReadError();
|
|
478
|
+
};
|
|
445
479
|
/**
|
|
446
480
|
* The stored value of the cell under `key`: its hot entry (`ft` stripped; a
|
|
447
481
|
* `null` or any non-map is a tombstone and reads null), else its cold body.
|
|
@@ -482,6 +516,7 @@ var sheetDataV5ToV2 = function (doc, styles) {
|
|
|
482
516
|
var _d, _f;
|
|
483
517
|
var _g;
|
|
484
518
|
if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
|
|
519
|
+
refuseRenderedText(doc);
|
|
485
520
|
var sheetData = {};
|
|
486
521
|
var cache = new Map();
|
|
487
522
|
var cold = new Map();
|
|
@@ -565,10 +600,13 @@ exports.sheetDataV5ToV2 = sheetDataV5ToV2;
|
|
|
565
600
|
*/
|
|
566
601
|
var createCellReaderV5 = function (doc, styles) {
|
|
567
602
|
if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
|
|
603
|
+
refuseRenderedText(doc);
|
|
568
604
|
var lines = new Map();
|
|
569
605
|
var cold = new Map();
|
|
570
606
|
return function (sheetId, rowIndex, columnIndex) {
|
|
571
607
|
var _a;
|
|
608
|
+
// The marker can arrive with a sync after the reader was made.
|
|
609
|
+
refuseRenderedText(doc);
|
|
572
610
|
var ids = lines.get(sheetId);
|
|
573
611
|
if (!ids) {
|
|
574
612
|
ids = [(0, exports.readLineIds)(doc, sheetId, "row"), (0, exports.readLineIds)(doc, sheetId, "column")];
|
|
@@ -595,6 +633,7 @@ var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, st
|
|
|
595
633
|
var e_9, _a;
|
|
596
634
|
var _b, _c, _d;
|
|
597
635
|
if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
|
|
636
|
+
refuseRenderedText(doc);
|
|
598
637
|
var cache = new Map();
|
|
599
638
|
var cold = new Map();
|
|
600
639
|
var next = tslib_1.__assign({}, currentSheetData);
|
|
@@ -1179,6 +1218,7 @@ var addSheetDataPatchesV5 = function (doc, patches, origin, styles) {
|
|
|
1179
1218
|
if (origin === void 0) { origin = null; }
|
|
1180
1219
|
if (!(patches === null || patches === void 0 ? void 0 : patches.length))
|
|
1181
1220
|
return;
|
|
1221
|
+
refuseRenderedText(doc);
|
|
1182
1222
|
doc.transact(function () {
|
|
1183
1223
|
var e_16, _a;
|
|
1184
1224
|
var w = {
|
package/dist/esm/helpers-v5.d.ts
CHANGED
|
@@ -30,6 +30,16 @@ export declare const readStyleOverlayV5: (doc: YDoc) => StyleOverlayV5;
|
|
|
30
30
|
* A malformed block reads as the entries decoded before the damage.
|
|
31
31
|
*/
|
|
32
32
|
export declare const decodeColumnBlockV5: (buf: Uint8Array) => Map<number, CellData>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the doc's format marker says `sheet-format.cells >= 2`
|
|
35
|
+
* (`stage2_cell_format` in rnc-yrs-store-v3): on a v5 doc past it, formula text
|
|
36
|
+
* is rendered from `ft` on read and a stored `ue.fv` may be stale.
|
|
37
|
+
*/
|
|
38
|
+
export declare const v5RendersFormulaTextOnRead: (doc: YDoc) => boolean;
|
|
39
|
+
/** What every reader and writer here throws on a doc past the marker. */
|
|
40
|
+
export declare class V5FormulaTextOnReadError extends Error {
|
|
41
|
+
constructor();
|
|
42
|
+
}
|
|
33
43
|
/**
|
|
34
44
|
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
|
|
35
45
|
* `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAA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AM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACtD;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAgBzB;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,UAAU,KACd;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,IA8C3C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,IAAI,EACT,SAAS,MAAM,EACf,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,KAC/B,qBAmDF,CAAC;AA0SF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,KAAK,IAAI,EACT,SAAS,KAAK,EAAE,GAAG,SAAS,EAC5B,SAAQ,OAAc,EACtB,SAAS,cAAc,SA+CxB,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,SAAS,GACpB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,aAAa,MAAM,EACnB,OAAO,QAAQ,KACd,IAGC,CAAC;AAEL,iEAAiE;AACjE,eAAO,MAAM,YAAY,GACvB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,IAGC,CAAC;AAEL,kFAAkF;AAClF,eAAO,MAAM,aAAa,GAAI,KAAK,IAAI,EAAE,SAAS,MAAM,KAAG,IACM,CAAC"}
|
package/dist/esm/helpers-v5.js
CHANGED
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
// positional in its write frame, `ue.fv` being the truth) and never writes a
|
|
21
21
|
// facet `anchor` (a facet written here is positional and gains one on its next
|
|
22
22
|
// engine write).
|
|
23
|
+
// Past the Stage 2 format marker (`sheet-format.cells >= 2`) a structural edit
|
|
24
|
+
// leaves `ue.fv` as written and the engine renders formula text from `ft` on
|
|
25
|
+
// read, so a stored `ue.fv` may name cells the formula no longer reads. This
|
|
26
|
+
// module reads `ue.fv` as stored: every reader and writer here refuses such a
|
|
27
|
+
// doc (`V5FormulaTextOnReadError`); read it through the engine.
|
|
23
28
|
import { getCellUserEnteredFormat } from "@rowsncolumns/utils";
|
|
24
29
|
import { inflateSync } from "fflate";
|
|
25
30
|
import * as decoding from "lib0/decoding";
|
|
@@ -40,6 +45,8 @@ const BLOCK_V2_MAGIC = 0x80000000; // BLOCK_V2_MAGIC
|
|
|
40
45
|
const BLOCK_V2_DENSE = 0x40000000; // BLOCK_V2_DENSE
|
|
41
46
|
const MAX_BLOCK_RAW_BYTES = 512 * 1024 * 1024; // MAX_BLOCK_RAW_BYTES
|
|
42
47
|
const STYLE_LOG_V1 = 1; // STYLE_LOG_V1
|
|
48
|
+
const FORMAT_ROOT = "sheet-format"; // rnc-yrs-store-v3 node_cell::FORMAT_ROOT
|
|
49
|
+
const NODE_CELL_FORMAT = 2; // rnc-yrs-store-v3 node_cell::NODE_CELL_FORMAT
|
|
43
50
|
const STYLE_LOG_V2 = 2; // STYLE_LOG_V2
|
|
44
51
|
const CELL_KEY_V5 = /^(-?\d+):(-?\d+):(-?\d+)$/; // cell_key
|
|
45
52
|
const BLOCK_KEY_V5 = /^(-?\d+):(-?\d+):(\d+)$/; // block_key
|
|
@@ -363,6 +370,28 @@ const coldCellV5 = (doc, cache, sheetId, rowId, colId) => {
|
|
|
363
370
|
return cells.get((counter - 1) % BLOCK_ROWS) ?? null;
|
|
364
371
|
};
|
|
365
372
|
// ── readers ─────────────────────────────────────────────────────────────────
|
|
373
|
+
/**
|
|
374
|
+
* Whether the doc's format marker says `sheet-format.cells >= 2`
|
|
375
|
+
* (`stage2_cell_format` in rnc-yrs-store-v3): on a v5 doc past it, formula text
|
|
376
|
+
* is rendered from `ft` on read and a stored `ue.fv` may be stale.
|
|
377
|
+
*/
|
|
378
|
+
export const v5RendersFormulaTextOnRead = (doc) => {
|
|
379
|
+
if (!doc.share.has(FORMAT_ROOT))
|
|
380
|
+
return false;
|
|
381
|
+
const cells = doc.get(FORMAT_ROOT).getAttr("cells");
|
|
382
|
+
return typeof cells === "number" && cells >= NODE_CELL_FORMAT;
|
|
383
|
+
};
|
|
384
|
+
/** What every reader and writer here throws on a doc past the marker. */
|
|
385
|
+
export class V5FormulaTextOnReadError extends Error {
|
|
386
|
+
constructor() {
|
|
387
|
+
super("This sheet renders formula text on read (sheet-format.cells >= 2): read and write it through the engine");
|
|
388
|
+
this.name = "V5FormulaTextOnReadError";
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const refuseRenderedText = (doc) => {
|
|
392
|
+
if (v5RendersFormulaTextOnRead(doc))
|
|
393
|
+
throw new V5FormulaTextOnReadError();
|
|
394
|
+
};
|
|
366
395
|
/**
|
|
367
396
|
* The stored value of the cell under `key`: its hot entry (`ft` stripped; a
|
|
368
397
|
* `null` or any non-map is a tombstone and reads null), else its cold body.
|
|
@@ -399,6 +428,7 @@ const composeCell = (doc, key, styles, cold) => {
|
|
|
399
428
|
* skipped). Inflates every cold block once.
|
|
400
429
|
*/
|
|
401
430
|
export const sheetDataV5ToV2 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
431
|
+
refuseRenderedText(doc);
|
|
402
432
|
const sheetData = {};
|
|
403
433
|
const cache = new Map();
|
|
404
434
|
const cold = new Map();
|
|
@@ -449,9 +479,12 @@ export const sheetDataV5ToV2 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
|
449
479
|
* per sheet. Undefined when nothing is there or the line is unnamed.
|
|
450
480
|
*/
|
|
451
481
|
export const createCellReaderV5 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
482
|
+
refuseRenderedText(doc);
|
|
452
483
|
const lines = new Map();
|
|
453
484
|
const cold = new Map();
|
|
454
485
|
return (sheetId, rowIndex, columnIndex) => {
|
|
486
|
+
// The marker can arrive with a sync after the reader was made.
|
|
487
|
+
refuseRenderedText(doc);
|
|
455
488
|
let ids = lines.get(sheetId);
|
|
456
489
|
if (!ids) {
|
|
457
490
|
ids = [readLineIds(doc, sheetId, "row"), readLineIds(doc, sheetId, "column")];
|
|
@@ -473,6 +506,7 @@ export const getCellV5 = (doc, sheetId, rowIndex, columnIndex, styles) => create
|
|
|
473
506
|
* cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
|
|
474
507
|
*/
|
|
475
508
|
export const processSheetDataChangesV5 = (changedKeys, currentSheetData, doc, styles = readStyleOverlayV5(doc)) => {
|
|
509
|
+
refuseRenderedText(doc);
|
|
476
510
|
const cache = new Map();
|
|
477
511
|
const cold = new Map();
|
|
478
512
|
const next = { ...currentSheetData };
|
|
@@ -962,6 +996,7 @@ const applyPatchV5 = (w, { op, path, value }) => {
|
|
|
962
996
|
export const addSheetDataPatchesV5 = (doc, patches, origin = null, styles) => {
|
|
963
997
|
if (!patches?.length)
|
|
964
998
|
return;
|
|
999
|
+
refuseRenderedText(doc);
|
|
965
1000
|
doc.transact(() => {
|
|
966
1001
|
const w = {
|
|
967
1002
|
doc,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/y-spreadsheet",
|
|
3
|
-
"version": "17.0
|
|
3
|
+
"version": "17.1.0",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@rowsncolumns/common-types": ">=5.5.1",
|
|
38
38
|
"@rowsncolumns/fast-formula-parser": ">=6.2.49",
|
|
39
39
|
"@rowsncolumns/grid": ">=13.6.1",
|
|
40
|
-
"@rowsncolumns/spreadsheet": ">=10.
|
|
40
|
+
"@rowsncolumns/spreadsheet": ">=10.19.2",
|
|
41
41
|
"@rowsncolumns/spreadsheet-state": ">=29.5.6",
|
|
42
42
|
"@rowsncolumns/ui": ">=16.2.3",
|
|
43
43
|
"@rowsncolumns/utils": ">=9.8.1",
|