@fileverse-dev/dsheet 3.0.2 → 3.0.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.
Files changed (49) hide show
  1. package/README.md +1 -0
  2. package/dist/{constants-Q8nzbvQO.js → constants-Cdz6oSCq.js} +3 -5
  3. package/dist/constants.js +1 -1
  4. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  5. package/dist/editor/constants/shared-constants.d.ts +0 -2
  6. package/dist/editor/contexts/editor-context.d.ts +4 -0
  7. package/dist/editor/dsheet-editor.d.ts +1 -1
  8. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  9. package/dist/editor/hooks/use-editor-sync.d.ts +2 -0
  10. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +2 -1
  11. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  12. package/dist/editor/types.d.ts +8 -0
  13. package/dist/editor/utils/apply-comment-markers.d.ts +22 -0
  14. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  15. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  16. package/dist/editor/utils/update-ydoc.d.ts +13 -3
  17. package/dist/executeStringFunction-DVN2p-9G.js +32625 -0
  18. package/dist/formula.js +1 -1
  19. package/dist/{index-Dql-IRPC.js → index-T7U1EYEU.js} +21792 -24680
  20. package/dist/index.es.js +39 -39
  21. package/dist/persistence-utils-DsM_MOB1.js +89 -0
  22. package/dist/persistence-utils.d.ts +17 -0
  23. package/dist/persistence.d.ts +12 -0
  24. package/dist/persistence.js +118 -0
  25. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  26. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  27. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  28. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  29. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  30. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +1 -0
  31. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  32. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  33. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  34. package/dist/sheet-engine/core/settings.d.ts +1 -1
  35. package/dist/sheet-engine/core/types.d.ts +3 -0
  36. package/dist/sheet-engine/core/utils/active-draft-context.d.ts +4 -0
  37. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  38. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  39. package/dist/sheet-engine/core/utils/merge-hydrate.d.ts +15 -0
  40. package/dist/sheet-engine/core/utils/mirror-cell-format-ranges.d.ts +17 -0
  41. package/dist/sheet-engine/core/utils/range-format.d.ts +76 -0
  42. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +46 -0
  43. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  44. package/dist/sheet-engine/react/components/Workbook/index.d.ts +5 -1
  45. package/dist/use-xlsx-import-impl-B9Uq_cFK.js +1572 -0
  46. package/dist/{xlsx-export-impl-DfQuhamE.js → xlsx-export-impl-0bnKq9JC.js} +1210 -1198
  47. package/package.json +16 -6
  48. package/dist/executeStringFunction-C5hEkx9z.js +0 -27694
  49. package/dist/use-xlsx-import-impl-BsL90Hs0.js +0 -1537
@@ -0,0 +1,76 @@
1
+ import { Cell, CellMatrix, CellWithRowAndCol, Sheet } from '../types';
2
+
3
+ export type CellFormatRange = {
4
+ row: [number, number];
5
+ column: [number, number];
6
+ tb?: string;
7
+ ht?: number | string;
8
+ vt?: number | string;
9
+ tr?: string;
10
+ fs?: number;
11
+ ff?: number | string;
12
+ fc?: string;
13
+ bl?: number;
14
+ it?: number;
15
+ un?: number;
16
+ cl?: number;
17
+ bg?: string;
18
+ ct?: Cell["ct"];
19
+ };
20
+ declare function rangesEqual(a: CellFormatRange[] | undefined, b: CellFormatRange[] | undefined): boolean;
21
+ /** Merge overlapping/adjacent ranges that carry identical format attrs. */
22
+ export declare function normalizeCellFormatRanges(ranges: CellFormatRange[] | undefined): CellFormatRange[];
23
+ /**
24
+ * Remap format ranges after a row or column permutation, such as header
25
+ * drag-and-drop. A contiguous source range can become multiple rectangles
26
+ * when the moved indices are no longer contiguous.
27
+ */
28
+ export declare function remapCellFormatRanges(ranges: CellFormatRange[] | undefined, axis: "row" | "column", indexMap: Record<number, number>): CellFormatRange[];
29
+ /**
30
+ * Move format ranges with a cut-and-paste cell block move. Formatting in both
31
+ * the old source and the overwritten destination is cleared; only the source
32
+ * intersection is translated to the target rectangle.
33
+ */
34
+ export declare function moveCellFormatRanges(ranges: CellFormatRange[] | undefined, source: Pick<CellFormatRange, "row" | "column">, target: Pick<CellFormatRange, "row" | "column">): CellFormatRange[];
35
+ export declare function getCellFormatRangeGridBounds(ranges: CellFormatRange[] | undefined): {
36
+ maxRow: number;
37
+ maxCol: number;
38
+ } | null;
39
+ export declare function upsertCellFormatRange(ranges: CellFormatRange[] | undefined, rowSt: number, rowEd: number, colSt: number, colEd: number, attrs: Partial<CellFormatRange>): {
40
+ ranges: CellFormatRange[];
41
+ changed: boolean;
42
+ };
43
+ /**
44
+ * When a cell loses meaningful content but keeps style, put that style back
45
+ * into cellFormatRanges as a 1x1 (normalize merges with neighbours).
46
+ */
47
+ export declare function migrateFormatOnlyCellIntoRanges(ranges: CellFormatRange[] | undefined, r: number, c: number, cell: Cell | string | number | boolean | null | undefined): {
48
+ ranges: CellFormatRange[];
49
+ changed: boolean;
50
+ };
51
+ /**
52
+ * Scan a dense-data rectangle and move any format-only cells into
53
+ * cellFormatRanges. Adjacent identical styles merge via normalize.
54
+ */
55
+ export declare function migrateFormatOnlyCellsFromData(ranges: CellFormatRange[] | undefined, data: CellMatrix | null | undefined, r1: number, r2: number, c1: number, c2: number): {
56
+ ranges: CellFormatRange[];
57
+ changed: boolean;
58
+ };
59
+ export declare function punchHoleInCellFormatRanges(ranges: CellFormatRange[] | undefined, r: number, c: number): CellFormatRange[];
60
+ /**
61
+ * Remove format coverage for a whole rectangle in O(ranges), not O(area × ranges).
62
+ * Prefer this over punching cell-by-cell (select-all clear must stay cheap).
63
+ */
64
+ export declare function removeCellFormatRangesInRect(ranges: CellFormatRange[] | undefined, row: [number, number], column: [number, number]): CellFormatRange[];
65
+ export declare function punchRectHoleInCellFormatRanges(ranges: CellFormatRange[] | undefined, rowSt: number, rowEd: number, colSt: number, colEd: number): CellFormatRange[];
66
+ export declare function shiftCellFormatRangesOnInsert(ranges: CellFormatRange[] | undefined, type: "row" | "column", index: number, count: number, direction: "lefttop" | "rightbottom"): CellFormatRange[];
67
+ export declare function shiftCellFormatRangesOnDelete(ranges: CellFormatRange[] | undefined, type: "row" | "column", start: number, end: number): CellFormatRange[];
68
+ export declare function applyCellFormatRangesToData(data: CellMatrix | null | undefined, ranges: CellFormatRange[] | undefined): void;
69
+ export declare function buildSheetDataMatrixForExport(sheet: {
70
+ data?: CellMatrix | null;
71
+ celldata?: CellWithRowAndCol[];
72
+ row?: number;
73
+ column?: number;
74
+ config?: Sheet["config"];
75
+ }): CellMatrix;
76
+ export { rangesEqual };
@@ -0,0 +1,46 @@
1
+ import { Context } from '../context';
2
+ import { Cell, CellWithRowAndCol } from '../types';
3
+
4
+ export type CelldataYdocChange = {
5
+ sheetId: string;
6
+ path: string[];
7
+ key?: string;
8
+ value: any;
9
+ type?: 'update' | 'delete';
10
+ };
11
+ /** Cheap equality before deep compare — hot path for structural diffs. */
12
+ export declare function cellsEqualForYdocPersist(before: unknown, after: unknown): boolean;
13
+ /**
14
+ * Snapshot persisted cells in a range.
15
+ * Prefer sparse `celldata` when provided — O(populated cells), not O(range area).
16
+ */
17
+ export declare function snapshotPersistedCelldataInRange(data: unknown[][] | null | undefined, r1: number, r2: number, c1: number, c2: number, celldata?: CellWithRowAndCol[] | null): Map<string, Cell | string | number | boolean>;
18
+ export declare function appendCelldataDiffChange(changes: CelldataYdocChange[], sheetId: string, r: number, c: number, cell: unknown, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
19
+ export declare function buildCelldataChangesForRange(sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): CelldataYdocChange[];
20
+ export declare function emitCelldataRangeDiffToYdoc(ctx: Context, sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
21
+ /**
22
+ * After delete row/col, emit deletes for persisted keys that now sit past the
23
+ * shrunken grid. Range diffs only visit coordinates still inside `data`, so
24
+ * tail keys would otherwise resurrect on peers/reload.
25
+ */
26
+ export declare function emitCelldataDeletesBeyondGrid(ctx: Context, sheetId: string, beforePersisted: Map<string, Cell | string | number | boolean> | undefined, rowCount: number, colCount: number): void;
27
+ export type MergeBounds = {
28
+ minR: number;
29
+ minC: number;
30
+ maxR: number;
31
+ maxC: number;
32
+ };
33
+ /** Disturbed range for insert row/col — snapshot only rows/cols that may shift. */
34
+ export declare function getInsertRowColSnapshotBounds(type: 'row' | 'column', index: number, direction: 'lefttop' | 'rightbottom', rowCount: number, colCount: number, mergeBounds: MergeBounds | null): {
35
+ r1: number;
36
+ r2: number;
37
+ c1: number;
38
+ c2: number;
39
+ };
40
+ /** Disturbed range for delete row/col — from deletion point to sheet edge. */
41
+ export declare function getDeleteRowColSnapshotBounds(type: 'row' | 'column', start: number, rowCount: number, colCount: number, mergeBounds: MergeBounds | null): {
42
+ r1: number;
43
+ r2: number;
44
+ c1: number;
45
+ c2: number;
46
+ };
@@ -1,3 +1,4 @@
1
+ import { CellFormatRange } from '../../../core/utils/range-format';
1
2
  import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from '../../../core';
2
3
  import { getCryptoPrice } from '../../utils/cryptoApi';
3
4
  import { SetContextOptions } from '../../context';
@@ -148,6 +149,12 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
148
149
  } | null;
149
150
  }, options?: api.CommonOptions) => void;
150
151
  setSheetMapField: (field: string, value: Record<string, any> | null | undefined, options?: api.CommonOptions) => void;
152
+ /** Merge keys into a map-backed sheet field without replacing the whole map. */
153
+ patchSheetMapField: (field: string, updates: Record<string, any>, deleteKeys?: string[], options?: api.CommonOptions) => void;
154
+ /** Merge sub-keys into sheet.config without replacing the whole config object. */
155
+ setSheetConfigFields: (partial: Record<string, any>, options?: api.CommonOptions & {
156
+ deleteKeys?: string[];
157
+ }) => void;
151
158
  setSheetConditionFormatRules: (rules: any[], options?: api.CommonOptions) => void;
152
159
  scroll: (options: {
153
160
  scrollLeft?: number;
@@ -166,7 +173,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
166
173
  calculateSubSheetFormula: (id: string) => void;
167
174
  calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
168
175
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
169
- celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
176
+ celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: CellFormatRange[], merge?: Record<string, any> | null) => CellMatrix | null;
170
177
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
171
178
  getLocaleContext: () => any;
172
179
  getWorkbookContext: () => Context;
@@ -150,6 +150,10 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
150
150
  } | null;
151
151
  }, options?: api.CommonOptions) => void;
152
152
  setSheetMapField: (field: string, value: Record<string, any> | null | undefined, options?: api.CommonOptions) => void;
153
+ patchSheetMapField: (field: string, updates: Record<string, any>, deleteKeys?: string[], options?: api.CommonOptions) => void;
154
+ setSheetConfigFields: (partial: Record<string, any>, options?: api.CommonOptions & {
155
+ deleteKeys?: string[];
156
+ }) => void;
153
157
  setSheetConditionFormatRules: (rules: any[], options?: api.CommonOptions) => void;
154
158
  scroll: (options: {
155
159
  scrollLeft?: number;
@@ -168,7 +172,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
168
172
  calculateSubSheetFormula: (id: string) => void;
169
173
  calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
170
174
  dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
171
- celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
175
+ celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: import('../../../core/utils/range-format').CellFormatRange[], merge?: Record<string, any> | null) => CellMatrix | null;
172
176
  insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
173
177
  getLocaleContext: () => any;
174
178
  getWorkbookContext: () => Context;