@fileverse-dev/dsheet 3.0.0 → 3.0.1-formula-1

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 (51) hide show
  1. package/dist/{constants-yStXQJiK.js → constants-Cdz6oSCq.js} +5 -7
  2. package/dist/constants.js +1 -1
  3. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  4. package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
  5. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  6. package/dist/editor/constants/shared-constants.d.ts +0 -2
  7. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  8. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +2 -1
  9. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  10. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  11. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  12. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  13. package/dist/editor/utils/update-ydoc.d.ts +2 -2
  14. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  15. package/dist/executeStringFunction-DMPoSj5F.js +32826 -0
  16. package/dist/formula.js +1 -1
  17. package/dist/{index-CBzFxleP.js → index-DAVuAF9T.js} +23852 -26202
  18. package/dist/index.es.js +39 -39
  19. package/dist/jszip.min-CEyB-71x.js +2319 -0
  20. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  21. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  22. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  23. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  24. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  25. package/dist/sheet-engine/core/context.d.ts +3 -1
  26. package/dist/sheet-engine/core/index.d.ts +2 -2
  27. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
  28. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +1 -0
  29. package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
  30. package/dist/sheet-engine/core/modules/index.d.ts +3 -2
  31. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  32. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  33. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  34. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  35. package/dist/sheet-engine/core/settings.d.ts +3 -1
  36. package/dist/sheet-engine/core/types.d.ts +20 -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/range-format.d.ts +71 -0
  40. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +40 -0
  41. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  42. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  43. package/dist/sheet-engine/react/components/Workbook/index.d.ts +5 -1
  44. package/dist/style.css +1 -1
  45. package/dist/use-xlsx-import-impl-DzthrhwA.js +1595 -0
  46. package/dist/xlsx-defined-names-D2KoICbm.js +117 -0
  47. package/dist/xlsx-export-impl-b2z4De4f.js +818 -0
  48. package/package.json +2 -2
  49. package/dist/executeStringFunction-C5hEkx9z.js +0 -27694
  50. package/dist/use-xlsx-import-impl-C_npga_I.js +0 -1537
  51. package/dist/xlsx-export-impl-C2cU3lhm.js +0 -3126
@@ -1,13 +1,11 @@
1
- import { E as n, S as a } from "./crypto-constants-CqpCRs86.js";
2
- const E = n, d = a, f = [
1
+ import { E as a, S as n } from "./crypto-constants-CqpCRs86.js";
2
+ const E = a, d = n, f = [
3
3
  {
4
4
  id: "0",
5
5
  name: "Sheet1",
6
6
  celldata: [],
7
7
  config: {},
8
- order: 0,
9
- row: 500,
10
- column: 26
8
+ order: 0
11
9
  }
12
10
  ], m = [
13
11
  "undo",
@@ -52,8 +50,8 @@ const E = n, d = a, f = [
52
50
  "copy",
53
51
  "paste",
54
52
  "|",
55
- "insert-row",
56
53
  "insert-row-above",
54
+ "insert-row",
57
55
  "insert-column",
58
56
  "insert-column-right",
59
57
  "insert-cells",
@@ -89,8 +87,8 @@ const E = n, d = a, f = [
89
87
  "copy",
90
88
  "paste",
91
89
  "|",
92
- "insert-row",
93
90
  "insert-row-above",
91
+ "insert-row",
94
92
  "insert-column",
95
93
  "insert-column-right",
96
94
  "|",
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as R, c as _, E as C, S as a, p as s } from "./constants-yStXQJiK.js";
1
+ import { a as R, c as _, E as C, S as a, p as s } from "./constants-Cdz6oSCq.js";
2
2
  export {
3
3
  R as COLLAB_PRESENCE_COLORS,
4
4
  _ as ENS_PRESENCE_COLOR,
@@ -19,5 +19,5 @@ export declare const createAfterOrderChangesHandler: ({ sheetEditorRef, ydocRef,
19
19
  export declare const createAfterColorChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
20
20
  export declare const createAfterHideChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
21
21
  export declare const createAfterColRowChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
22
- export declare const updateAllCell: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext, subSheetId: string) => void;
22
+ export declare const updateAllCell: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext, subSheetId: string, caller?: string) => void;
23
23
  export {};
@@ -1,4 +1,4 @@
1
- export type BuiltInPanelType = 'templates' | 'comments' | 'functions' | 'data-verification' | 'conditional-format';
1
+ export type BuiltInPanelType = 'templates' | 'comments' | 'functions' | 'data-verification' | 'conditional-format' | 'named-ranges';
2
2
  export type PanelId = BuiltInPanelType | string;
3
3
  interface UseRightPanelsReturn {
4
4
  activePanel: PanelId | null;
@@ -0,0 +1,2 @@
1
+ declare const NamedRanges: () => import("react/jsx-runtime").JSX.Element;
2
+ export { NamedRanges };
@@ -8,8 +8,6 @@ export declare const DEFAULT_SHEET_DATA: {
8
8
  celldata: never[];
9
9
  config: {};
10
10
  order: number;
11
- row: number;
12
- column: number;
13
11
  }[];
14
12
  export declare const TOOL_BAR_ITEMS: string[];
15
13
  export declare const CELL_CONTEXT_MENU_ITEMS: string[];
@@ -0,0 +1,23 @@
1
+ import { MutableRefObject, RefObject } from 'react';
2
+ import { WorkbookInstance, Sheet } from '../../sheet-engine/react';
3
+
4
+ import type * as Y from 'yjs';
5
+ type UseCelldataCompactionArgs = {
6
+ dsheetId: string;
7
+ ydocRef: RefObject<Y.Doc | null>;
8
+ sheetEditorRef: RefObject<WorkbookInstance | null>;
9
+ currentDataRef: MutableRefObject<Sheet[]>;
10
+ handleOnChangePortalUpdate: () => void;
11
+ syncStatus: 'initializing' | 'syncing' | 'synced' | 'error';
12
+ isDataLoaded: boolean;
13
+ isReadOnly: boolean;
14
+ remoteUpdateRef: MutableRefObject<boolean>;
15
+ collabSyncing: boolean;
16
+ };
17
+ /**
18
+ * One-shot background compaction: remove committed celldata entries that copy/paste
19
+ * would never write (`shouldPersistCelldataCell` === false). Runs once per dsheetId
20
+ * after the editor is synced and idle so it does not compete with load or edits.
21
+ */
22
+ export declare function useCelldataCompaction({ dsheetId, ydocRef, sheetEditorRef, currentDataRef, handleOnChangePortalUpdate, syncStatus, isDataLoaded, isReadOnly, remoteUpdateRef, collabSyncing, }: UseCelldataCompactionArgs): void;
23
+ export {};
@@ -11,6 +11,7 @@ export type XlsxImportRuntimeDeps = {
11
11
  updateDocumentTitle?: (title: string) => void;
12
12
  filterToastShown: boolean;
13
13
  setFilterToastShown: React.Dispatch<React.SetStateAction<boolean>>;
14
+ handleContentPortal?: () => void;
14
15
  };
15
16
  export type XlsxImportOptions = {
16
17
  headless?: boolean;
@@ -19,4 +20,4 @@ export type XlsxImportOptions = {
19
20
  generateSheetId?: () => string;
20
21
  };
21
22
  /** Full XLSX import pipeline; loaded only when user imports a file. */
22
- export declare function runXlsxFileUpload({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, filterToastShown, setFilterToastShown, }: XlsxImportRuntimeDeps, event: React.ChangeEvent<HTMLInputElement> | undefined, fileArg: File, importType?: 'new-dsheet' | 'merge-current-dsheet' | 'new-current-dsheet', options?: XlsxImportOptions): Promise<void>;
23
+ export declare function runXlsxFileUpload({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, filterToastShown, setFilterToastShown, handleContentPortal, }: XlsxImportRuntimeDeps, event: React.ChangeEvent<HTMLInputElement> | undefined, fileArg: File, importType?: 'new-dsheet' | 'merge-current-dsheet' | 'new-current-dsheet', options?: XlsxImportOptions): Promise<void>;
@@ -7,13 +7,14 @@ type ImportType = 'new-dsheet' | 'merge-current-dsheet' | 'new-current-dsheet';
7
7
  * XLSX import: keeps ~100k+ LOC (SSF, hyperlink helpers, exceljs/luckyexcel orchestration)
8
8
  * in a separate chunk until the user actually imports a file.
9
9
  */
10
- export declare const useXLSXImport: ({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, }: {
10
+ export declare const useXLSXImport: ({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, handleContentPortal, }: {
11
11
  sheetEditorRef: RefObject<WorkbookInstance | null>;
12
12
  ydocRef: RefObject<Y.Doc | null>;
13
13
  setForceSheetRender: Dispatch<SetStateAction<number>>;
14
14
  dsheetId: string;
15
15
  currentDataRef: MutableRefObject<object | null>;
16
16
  updateDocumentTitle?: (title: string) => void;
17
+ handleContentPortal?: () => void;
17
18
  }) => {
18
19
  handleXLSXUpload: (event: ChangeEvent<HTMLInputElement> | undefined, fileArg: File, importType?: ImportType) => Promise<void>;
19
20
  };
@@ -0,0 +1,28 @@
1
+ import { CellMatrix, CellWithRowAndCol, Sheet } from '../../sheet-engine/core/types';
2
+ import { SheetChangePath } from './update-ydoc';
3
+ import * as Y from 'yjs';
4
+ export declare const CELLDATA_COMPACT_STORAGE_KEY_PREFIX = "dsheet-celldata-compact-v1:";
5
+ export type CelldataCompactionResult = {
6
+ removedFromYdoc: number;
7
+ clearedInMemory: number;
8
+ changes: SheetChangePath[];
9
+ };
10
+ export declare function celldataCompactStorageKey(dsheetId: string): string;
11
+ export declare function hasCelldataCompactionCompleted(dsheetId: string): boolean;
12
+ export declare function markCelldataCompactionCompleted(dsheetId: string): void;
13
+ /** Collect Yjs celldata keys that should not be persisted (format-only / empty ghosts). */
14
+ export declare function collectStaleCelldataKeys(celldataMap: Y.Map<unknown> | Record<string, unknown> | null | undefined): string[];
15
+ export declare function buildCelldataDeleteChanges(sheetId: string, keys: string[]): SheetChangePath[];
16
+ /** Null out dense-grid cells that should not be persisted. */
17
+ export declare function compactSheetDataMatrix(data: CellMatrix | null | undefined): number;
18
+ /** Drop sparse celldata entries that should not be persisted. */
19
+ export declare function compactSheetCelldataArray(celldata: CellWithRowAndCol[] | null | undefined): {
20
+ next: CellWithRowAndCol[];
21
+ removed: number;
22
+ };
23
+ export declare function compactInMemorySheets(sheets: Sheet[] | null | undefined): number;
24
+ /**
25
+ * Scan Y.Doc for committed celldata ghosts. Does not mutate — caller applies
26
+ * `changes` via `updateYdocSheetData`.
27
+ */
28
+ export declare function planYdocCelldataCompaction(ydoc: Y.Doc, dsheetId: string): CelldataCompactionResult;
@@ -0,0 +1,20 @@
1
+ import { WorkbookInstance } from '../../sheet-engine/react';
2
+ import { SheetChangePath } from './update-ydoc';
3
+
4
+ import * as Y from 'yjs';
5
+ /** Diff top-level config sub-keys and emit granular Yjs updates. */
6
+ export declare function buildConfigSubKeyChanges({ sheetId, oldConfig, newConfig, }: {
7
+ sheetId: string;
8
+ oldConfig: Record<string, any>;
9
+ newConfig: Record<string, any>;
10
+ }): SheetChangePath[];
11
+ /**
12
+ * Sync active sheet config sub-keys to Yjs (borderInfo, merge, rowlen, …).
13
+ * Replaces whole-config writes so only changed sub-keys are broadcast.
14
+ */
15
+ export declare const configYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, }: {
16
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
17
+ ydocRef: React.RefObject<Y.Doc | null>;
18
+ dsheetId: string;
19
+ handleContentPortal?: any;
20
+ }) => void;
@@ -0,0 +1,31 @@
1
+ import { WorkbookInstance } from '../../sheet-engine/react';
2
+ import { DefinedName } from '../../sheet-engine/core/types';
3
+ import { RefObject } from 'react';
4
+
5
+ import * as Y from 'yjs';
6
+ /** Sibling share key on the same Y.Doc as the sheet array. */
7
+ export declare function getDefinedNamesMapKey(dsheetId: string): string;
8
+ export declare function getDefinedNamesYMap(ydoc: Y.Doc, dsheetId: string): Y.Map<DefinedName>;
9
+ /** Read workbook-level named ranges from Yjs (stable name order). */
10
+ export declare function readDefinedNamesFromYdoc(ydoc: Y.Doc, dsheetId: string): DefinedName[];
11
+ /**
12
+ * Prefer the sheet `Y.Array` share key when a doc has sibling maps
13
+ * (e.g. `${dsheetId}:definedNames`).
14
+ */
15
+ export declare function resolveSheetArrayShareKey(doc: Y.Doc, preferredKey?: string): string | null;
16
+ /**
17
+ * Diff Context definedNames against the Y.Map and apply set/delete by id.
18
+ */
19
+ export declare function syncDefinedNamesToYdoc({ ydoc, dsheetId, definedNames, handleContentPortal, }: {
20
+ ydoc: Y.Doc;
21
+ dsheetId: string;
22
+ definedNames: DefinedName[];
23
+ handleContentPortal?: () => void;
24
+ }): void;
25
+ /** Push current workbook definedNames into Yjs (editor hook target). */
26
+ export declare const definedNamesYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, }: {
27
+ sheetEditorRef: RefObject<WorkbookInstance | null>;
28
+ ydocRef: RefObject<Y.Doc | null>;
29
+ dsheetId: string;
30
+ handleContentPortal?: () => void;
31
+ }) => void;
@@ -1,11 +1,11 @@
1
1
  import { Sheet } from '../../sheet-engine/react';
2
- import * as Y from 'yjs';
2
+ import * as Y from "yjs";
3
3
  export type SheetChangePath = {
4
4
  sheetId: string;
5
5
  path: string[];
6
6
  key?: string;
7
7
  value: any;
8
- type?: 'update' | 'delete';
8
+ type?: "update" | "delete";
9
9
  };
10
10
  export declare const updateYdocSheetData: (ydoc: Y.Doc | null, dsheetId: string, changes: SheetChangePath[], handleContentPortal: any) => void;
11
11
  export declare function ySheetArrayToPlain(sheetArray: Y.Array<Y.Map>): Sheet[];
@@ -0,0 +1,41 @@
1
+ import { DefinedName } from '../../sheet-engine/core/types';
2
+
3
+ export type ExcelDefinedNameEntry = {
4
+ name: string;
5
+ ranges: string[];
6
+ localSheetId?: number;
7
+ };
8
+ export declare function isExcelSystemDefinedName(name: string): boolean;
9
+ /** Build Excel loc string: `Sheet1!$A$1:$C$2` (or single cell). */
10
+ export declare function encodeDefinedNameExcelRef(sheetName: string, range: DefinedName['range']): string;
11
+ /**
12
+ * Parse `Sheet1!$A$1:$B$2` / `'My Sheet'!$A$1` into sheet name + 0-based range.
13
+ */
14
+ export declare function parseExcelDefinedNameRef(ref: string): {
15
+ sheetName: string;
16
+ range: {
17
+ row: [number, number];
18
+ column: [number, number];
19
+ };
20
+ } | null;
21
+ /**
22
+ * Convert Excel defined-name entries into our DefinedName list.
23
+ * `sheets` must already have stable ids and names (Excel order).
24
+ */
25
+ export declare function excelEntriesToDefinedNames(entries: ExcelDefinedNameEntry[], sheets: Array<{
26
+ id?: string;
27
+ name?: string;
28
+ }>): DefinedName[];
29
+ /** Write defined names onto an ExcelJS workbook (Pass 2). */
30
+ export declare function applyDefinedNamesToExcelWorkbook(excelWorkbook: {
31
+ definedNames: {
32
+ add: (loc: string, name: string) => void;
33
+ };
34
+ }, definedNames: DefinedName[] | undefined, sheets: Array<{
35
+ id?: string;
36
+ name?: string;
37
+ }>): void;
38
+ /**
39
+ * Parse `<definedNames>` from xl/workbook.xml (keeps localSheetId).
40
+ */
41
+ export declare function parseDefinedNamesFromXlsxBuffer(arrayBuffer: ArrayBuffer): Promise<ExcelDefinedNameEntry[]>;