@fileverse-dev/dsheet 1.2.97-data-validation-fix-1 → 1.2.97-ydoc

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.
@@ -0,0 +1,20 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ type SyncContext = {
5
+ sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
6
+ ydocRef: React.MutableRefObject<Y.Doc | null>;
7
+ dsheetId: string;
8
+ handleOnChangePortalUpdate: () => void;
9
+ };
10
+ export declare const syncCurrentSheetField: (context: SyncContext, field: "images" | "iframes" | "frozen" | "name" | "config" | "showGridLines") => void;
11
+ export declare const createSheetLengthChangeHandler: ({ sheetEditorRef, ydocRef, dsheetId, currentDataRef, handleOnChangePortalUpdate, }: {
12
+ sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
13
+ ydocRef: React.MutableRefObject<Y.Doc | null>;
14
+ dsheetId: string;
15
+ currentDataRef: React.MutableRefObject<any>;
16
+ handleOnChangePortalUpdate: () => void;
17
+ }) => () => void;
18
+ export declare const createAfterOrderChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
19
+ export declare const createAfterColRowChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
20
+ export {};
@@ -3,6 +3,7 @@ import { ERROR_MESSAGES_FLAG as ErrorMessagesFlagType, SERVICES_API_KEY as Servi
3
3
  export declare const ERROR_MESSAGES_FLAG: ErrorMessagesFlagType;
4
4
  export declare const SERVICES_API_KEY: ServicesApiKeyType;
5
5
  export declare const DEFAULT_SHEET_DATA: {
6
+ id: string;
6
7
  name: string;
7
8
  celldata: never[];
8
9
  config: {};
@@ -5,6 +5,7 @@ import { DataBlockApiKeyHandlerType, SheetUpdateData } from '../types';
5
5
 
6
6
  import * as Y from 'yjs';
7
7
  export interface EditorContextType {
8
+ handleOnChangePortalUpdate: () => void;
8
9
  setSelectedTemplate?: React.Dispatch<React.SetStateAction<string>>;
9
10
  setShowSmartContractModal?: React.Dispatch<React.SetStateAction<boolean>>;
10
11
  getDocumentTitle?: () => string;
@@ -20,7 +20,7 @@ export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | nul
20
20
  currentDataRef: import('react').MutableRefObject<Sheet[]>;
21
21
  remoteUpdateRef: import('react').MutableRefObject<boolean>;
22
22
  isDataLoaded: boolean;
23
- handleChange: (data: Sheet[]) => void;
23
+ handleChange: (_data: Sheet[]) => void;
24
24
  handleLiveQuery: (subsheetIndex: number, queryData: import('@fileverse-dev/fortune-core').LiveQueryData) => void;
25
25
  initialiseLiveQueryData: (sheets: Sheet[]) => void;
26
26
  };
@@ -0,0 +1,13 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync calcChain array for active sheet.
6
+ * calcChain is keyed by `r_c` while stored in Yjs.
7
+ */
8
+ export declare const calcChainYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
9
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
10
+ ydocRef: React.RefObject<Y.Doc | null>;
11
+ dsheetId: string;
12
+ handleContentPortal?: any;
13
+ }) => void;
@@ -0,0 +1,13 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync condition format rules for active sheet.
6
+ * This field is stored as one array payload in Yjs.
7
+ */
8
+ export declare const conditionFormatYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
9
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
10
+ ydocRef: React.RefObject<Y.Doc | null>;
11
+ dsheetId: string;
12
+ handleContentPortal?: any;
13
+ }) => void;
@@ -2,4 +2,4 @@ import { default as React } from 'react';
2
2
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
3
3
 
4
4
  import * as Y from 'yjs';
5
- export declare const handleCSVUpload: (event: React.ChangeEventHandler<HTMLInputElement> | undefined, ydoc: Y.Doc | null, setForceSheetRender: React.Dispatch<React.SetStateAction<number>>, dsheetId: string, currentDataRef: React.MutableRefObject<object | null>, sheetEditorRef: React.RefObject<WorkbookInstance | null>, updateDocumentTitle?: (title: string) => void, fileArg?: File, importType?: string) => void;
5
+ export declare const handleCSVUpload: (event: React.ChangeEventHandler<HTMLInputElement> | undefined, ydoc: Y.Doc | null, setForceSheetRender: React.Dispatch<React.SetStateAction<number>>, dsheetId: string, currentDataRef: React.MutableRefObject<object | null>, sheetEditorRef: React.RefObject<WorkbookInstance | null>, updateDocumentTitle?: (title: string) => void, fileArg?: File, importType?: string, handleContentPortal?: any) => void;
@@ -2,12 +2,13 @@ import { default as React, ChangeEventHandler } from 'react';
2
2
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
3
3
 
4
4
  import * as Y from 'yjs';
5
- export declare const getCustomToolbarItems: ({ setShowSmartContractModal, setExportDropdownOpen, handleCSVUpload, handleXLSXUpload, handleExportToXLSX, handleExportToCSV, handleExportToJSON, sheetEditorRef, ydocRef, dsheetId, currentDataRef, setForceSheetRender, toggleTemplateSidebar, getDocumentTitle, updateDocumentTitle, }: {
5
+ export declare const getCustomToolbarItems: ({ handleContentPortal, setShowSmartContractModal, setExportDropdownOpen, handleCSVUpload, handleXLSXUpload, handleExportToXLSX, handleExportToCSV, handleExportToJSON, sheetEditorRef, ydocRef, dsheetId, currentDataRef, setForceSheetRender, toggleTemplateSidebar, getDocumentTitle, updateDocumentTitle, }: {
6
+ handleContentPortal?: any;
6
7
  setShowSmartContractModal?: React.Dispatch<React.SetStateAction<boolean>>;
7
8
  getDocumentTitle?: () => string;
8
9
  updateDocumentTitle?: (title: string) => void;
9
10
  setExportDropdownOpen: React.Dispatch<React.SetStateAction<boolean>>;
10
- handleCSVUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, ydocRef: Y.Doc | null, setForceSheetRender: React.Dispatch<React.SetStateAction<number>>, dsheetId: string, currentDataRef: React.MutableRefObject<object | null>, sheetEditorRef: React.RefObject<WorkbookInstance | null>, updateDocumentTitle?: (title: string) => void, file?: File, importType?: string) => void;
11
+ handleCSVUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, ydocRef: Y.Doc | null, setForceSheetRender: React.Dispatch<React.SetStateAction<number>>, dsheetId: string, currentDataRef: React.MutableRefObject<object | null>, sheetEditorRef: React.RefObject<WorkbookInstance | null>, updateDocumentTitle?: (title: string) => void, file?: File, importType?: string, handleContentPortal?: any) => void;
11
12
  handleXLSXUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, file?: File, importType?: string) => void;
12
13
  handleExportToXLSX: (sheetEditorRef: React.RefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string, getDocumentTitle?: () => string) => void;
13
14
  handleExportToCSV: (sheetEditorRef: React.RefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string) => void;
@@ -0,0 +1,13 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync dataBlockCalcFunction map for the active sheet to Yjs.
6
+ */
7
+ export declare const dataBlockListYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, dataBlockCalcFunction }: {
8
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
9
+ ydocRef: React.RefObject<Y.Doc | null>;
10
+ dsheetId: string;
11
+ handleContentPortal?: any;
12
+ dataBlockCalcFunction?: any;
13
+ }) => void;
@@ -0,0 +1,12 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync current sheet dataVerification object to Yjs.
6
+ */
7
+ export declare const dataVerificationYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
8
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
9
+ ydocRef: React.RefObject<Y.Doc | null>;
10
+ dsheetId: string;
11
+ handleContentPortal?: any;
12
+ }) => void;
@@ -1,9 +1,35 @@
1
- import { Sheet } from '@fileverse-dev/fortune-react';
2
-
3
1
  /**
4
2
  * Compare two spreadsheets' cell data and images, checking if anything changed
5
3
  * @param {Array} oldSheets - Original sheets data
6
4
  * @param {Array} newSheets - New sheets data
7
5
  * @returns {boolean} - true if any cell data or images changed, false if identical
8
6
  */
9
- export declare function isSpreadsheetChanged(oldSheets: Sheet[], newSheets: Sheet[]): boolean;
7
+ type DiffChange<T> = {
8
+ from: T;
9
+ to: T;
10
+ };
11
+ type UpdatedItem<T> = {
12
+ key: string;
13
+ before: T;
14
+ after: T;
15
+ changes: Partial<Record<keyof T, DiffChange<any>>>;
16
+ };
17
+ type DiffResult<T> = {
18
+ added: T[];
19
+ removed: T[];
20
+ updated: UpdatedItem<T>[];
21
+ };
22
+ export declare function diffObjectArrays<T extends Record<string, any>>(oldArr: readonly T[], newArr: readonly T[], getKey?: (item: T) => string): DiffResult<T>;
23
+ type UpdatedEntry<T> = {
24
+ key: string;
25
+ before: T;
26
+ after: T;
27
+ changes: Partial<Record<keyof T, DiffChange<any>>>;
28
+ };
29
+ type ObjectDiffResult<T> = {
30
+ added: Record<string, T>;
31
+ removed: Record<string, T>;
32
+ updated: UpdatedEntry<T>[];
33
+ };
34
+ export declare function diffObjectMap<T extends Record<string, any>>(oldObj: Record<string, T>, newObj: Record<string, T>): ObjectDiffResult<T>;
35
+ export {};
@@ -0,0 +1,12 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync hyperlink map for the active sheet to Yjs.
6
+ */
7
+ export declare const hyperlinkYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
8
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
9
+ ydocRef: React.RefObject<Y.Doc | null>;
10
+ dsheetId: string;
11
+ handleContentPortal?: any;
12
+ }) => void;
@@ -1,4 +1,4 @@
1
1
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
- export declare const handleExportToJSON: (sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string) => void;
4
+ export declare const handleExportToJSON: (sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, _dsheetId: string) => void;
@@ -0,0 +1,12 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync liveQueryList map for the active sheet to Yjs.
6
+ */
7
+ export declare const liveQueryListYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
8
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
9
+ ydocRef: React.RefObject<Y.Doc | null>;
10
+ dsheetId: string;
11
+ handleContentPortal?: any;
12
+ }) => void;
@@ -0,0 +1,6 @@
1
+ import { Sheet } from '@fileverse-dev/fortune-react';
2
+ import * as Y from 'yjs';
3
+ export declare function migrateSheetArrayIfNeeded(ydoc: Y.Doc, sheetArray: Y.Array<any>): void;
4
+ type SheetFactory = () => Y.Map<any>;
5
+ export declare function migrateSheetFactoryForImport(sheet: Sheet | Y.Map<any>): SheetFactory;
6
+ export {};
@@ -0,0 +1,31 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+ import { SheetChangePath } from './update-ydoc';
3
+
4
+ import * as Y from 'yjs';
5
+ type SyncContext = {
6
+ currentSheetId: string;
7
+ oldSheet: Record<string, any>;
8
+ ydoc: Y.Doc;
9
+ };
10
+ /**
11
+ * Build a stable sync context from current editor sheet and Yjs snapshot.
12
+ * This keeps all field-level sync handlers aligned on the same baseline.
13
+ */
14
+ export declare const getSheetYdocSyncContext: ({ sheetEditorRef, ydocRef, dsheetId, }: {
15
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
16
+ ydocRef: React.RefObject<Y.Doc | null>;
17
+ dsheetId: string;
18
+ }) => SyncContext | null;
19
+ export declare const buildMapFieldChanges: ({ sheetId, fieldPath, oldData, newData, }: {
20
+ sheetId: string;
21
+ fieldPath: string;
22
+ oldData: Record<string, any>;
23
+ newData: Record<string, any>;
24
+ }) => SheetChangePath[];
25
+ export declare const applyYdocSheetChanges: ({ ydoc, dsheetId, changes, handleContentPortal, }: {
26
+ ydoc: Y.Doc;
27
+ dsheetId: string;
28
+ changes: SheetChangePath[];
29
+ handleContentPortal?: any;
30
+ }) => void;
31
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Sheet } from '@fileverse-dev/fortune-react';
2
+ import * as Y from 'yjs';
3
+ export type SheetChangePath = {
4
+ sheetId: string;
5
+ path: string[];
6
+ key?: string;
7
+ value: any;
8
+ type?: 'update' | 'delete';
9
+ };
10
+ export declare const updateYdocSheetData: (ydoc: Y.Doc | null, dsheetId: string, changes: SheetChangePath[], handleContentPortal: any) => void;
11
+ export declare function ySheetArrayToPlain(sheetArray: Y.Array<Y.Map>): Sheet[];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/dsheet",
3
3
  "private": false,
4
4
  "description": "DSheet",
5
- "version": "1.2.97-data-validation-fix-1",
5
+ "version": "1.2.97-ydoc",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {
@@ -35,12 +35,13 @@
35
35
  "dependencies": {
36
36
  "@fileverse-dev/dsheets-templates": "^0.0.29",
37
37
  "@fileverse-dev/formulajs": "4.4.49",
38
- "@fileverse-dev/fortune-react": "^1.2.99-data-validation-fix-1",
38
+ "@fileverse-dev/fortune-react": "1.2.99-ydoc",
39
39
  "@fileverse/ui": "^5.0.0",
40
40
  "classnames": "^2.5.1",
41
41
  "exceljs": "^4.4.0",
42
42
  "js-base64": "^3.7.7",
43
43
  "katex": "^0.16.11",
44
+ "lodash": "^4.17.23",
44
45
  "luckyexcel": "^1.0.1",
45
46
  "papaparse": "^5.5.2",
46
47
  "react": "^18.2.0",
@@ -56,6 +57,7 @@
56
57
  "yjs": "^13.6.15"
57
58
  },
58
59
  "devDependencies": {
60
+ "@types/lodash": "^4.17.23",
59
61
  "@types/node": "^20.10.0",
60
62
  "@types/papaparse": "^5.3.15",
61
63
  "@types/react": "^18.2.37",
@@ -79,4 +81,4 @@
79
81
  "typescript": "^5.2.2",
80
82
  "vite": "^5.0.0"
81
83
  }
82
- }
84
+ }
@@ -1,9 +0,0 @@
1
- import { Sheet } from '@fileverse-dev/fortune-react';
2
- import { SheetUpdateData } from '../types';
3
- import * as Y from 'yjs';
4
- export declare const useSheetData: (ydoc: Y.Doc | null, dsheetId: string, onChange?: (updateData: SheetUpdateData, encodedUpdate?: string) => void) => {
5
- sheetData: Sheet[] | null;
6
- setSheetData: import('react').Dispatch<import('react').SetStateAction<Sheet[] | null>>;
7
- currentDataRef: import('react').MutableRefObject<Sheet[] | null>;
8
- remoteUpdateRef: import('react').MutableRefObject<boolean>;
9
- };
@@ -1,8 +0,0 @@
1
- import { Sheet, WorkbookInstance } from '@fileverse-dev/fortune-react';
2
- import * as Y from 'yjs';
3
- export declare const updateSheetData: (ydoc: Y.Doc | null, dsheetId: string, data: Sheet[], sheetEditor: WorkbookInstance | null, dataBlockCalcFunction?: {
4
- [key: string]: {
5
- [key: string]: any;
6
- };
7
- }, isReadOnly?: boolean) => void;
8
- export declare const formatSheetData: (data: Sheet[], preSheetArray: Sheet[], sheetEditor: WorkbookInstance) => Sheet[];