@fileverse-dev/dsheet 0.0.22 → 0.0.24
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.es.js +175471 -173505
- package/dist/package/components/editor-workbook.d.ts +20 -0
- package/dist/package/components/skeleton-loader.d.ts +6 -0
- package/dist/package/contexts/editor-context.d.ts +39 -0
- package/dist/package/dsheet-editor.d.ts +1 -1
- package/dist/package/hooks/use-editor-collaboration.d.ts +9 -0
- package/dist/package/hooks/use-editor-data.d.ts +16 -0
- package/dist/package/hooks/use-editor-sync.d.ts +12 -0
- package/dist/package/types.d.ts +26 -3
- package/dist/package/utils/after-update-cell.d.ts +13 -8
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/package/components/api-key-modal.d.ts +0 -13
- package/dist/package/hooks/use-webrtc-connection.d.ts +0 -7
- package/dist/package/hooks/use-yjs-document.d.ts +0 -6
- package/dist/package/use-dsheet-editor.d.ts +0 -128
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { OnboardingHandlerType, DataBlockApiKeyHandlerType } from '../types';
|
|
3
|
+
|
|
4
|
+
type OnboardingHandler = OnboardingHandlerType;
|
|
5
|
+
type DataBlockApiKeyHandler = DataBlockApiKeyHandlerType;
|
|
6
|
+
interface EditorWorkbookProps {
|
|
7
|
+
isReadOnly?: boolean;
|
|
8
|
+
toggleTemplateSidebar?: () => void;
|
|
9
|
+
onboardingComplete?: boolean;
|
|
10
|
+
onboardingHandler?: OnboardingHandler;
|
|
11
|
+
dataBlockApiKeyHandler?: DataBlockApiKeyHandler;
|
|
12
|
+
exportDropdownOpen?: boolean;
|
|
13
|
+
setExportDropdownOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
+
dsheetId: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* EditorWorkbook component handles rendering the Fortune Workbook with proper configuration
|
|
18
|
+
*/
|
|
19
|
+
export declare const EditorWorkbook: React.FC<EditorWorkbookProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SkeletonToolbar: () => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const SkeletonGrid: () => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const SkeletonLoader: ({ isReadOnly, }: {
|
|
4
|
+
isReadOnly: boolean | undefined;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default SkeletonLoader;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Sheet } from '@fileverse-dev/fortune-core';
|
|
3
|
+
import { WorkbookInstance } from '@fileverse-dev/fortune-react';
|
|
4
|
+
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
5
|
+
import { SheetUpdateData } from '../types';
|
|
6
|
+
|
|
7
|
+
import * as Y from 'yjs';
|
|
8
|
+
export interface EditorContextType {
|
|
9
|
+
sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
|
|
10
|
+
ydocRef: React.MutableRefObject<Y.Doc | null>;
|
|
11
|
+
persistenceRef: React.MutableRefObject<IndexeddbPersistence | null>;
|
|
12
|
+
sheetData: Sheet[];
|
|
13
|
+
setSheetData: React.Dispatch<React.SetStateAction<Sheet[]>>;
|
|
14
|
+
currentDataRef: React.MutableRefObject<Sheet[]>;
|
|
15
|
+
remoteUpdateRef: React.MutableRefObject<boolean>;
|
|
16
|
+
handleChange: (data: Sheet[]) => void;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
forceSheetRender: number;
|
|
19
|
+
setForceSheetRender: React.Dispatch<React.SetStateAction<number>>;
|
|
20
|
+
activeUsers: string[];
|
|
21
|
+
collaborationStatus: 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
22
|
+
syncStatus: 'initializing' | 'syncing' | 'synced' | 'error';
|
|
23
|
+
isCollaborative?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface EditorProviderProps {
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
dsheetId: string;
|
|
28
|
+
username?: string;
|
|
29
|
+
portalContent?: string;
|
|
30
|
+
enableIndexeddbSync?: boolean;
|
|
31
|
+
enableWebrtc?: boolean;
|
|
32
|
+
isReadOnly?: boolean;
|
|
33
|
+
onChange?: (data: SheetUpdateData, encodedUpdate?: string) => void;
|
|
34
|
+
externalEditorRef?: React.MutableRefObject<WorkbookInstance | null>;
|
|
35
|
+
isCollaborative?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const EditorProvider: React.FC<EditorProviderProps>;
|
|
38
|
+
export declare const useEditor: () => EditorContextType;
|
|
39
|
+
export {};
|
|
@@ -7,5 +7,5 @@ import { DsheetProps } from './types';
|
|
|
7
7
|
* @param props - Component properties
|
|
8
8
|
* @returns The SpreadsheetEditor component
|
|
9
9
|
*/
|
|
10
|
-
declare const SpreadsheetEditor: ({ isCollaborative, isReadOnly, renderNavbar,
|
|
10
|
+
declare const SpreadsheetEditor: ({ isCollaborative, isReadOnly, renderNavbar, enableIndexeddbSync, dsheetId, portalContent, onChange, username, selectedTemplate, toggleTemplateSidebar, isTemplateOpen, enableWebrtc, onboardingComplete, onboardingHandler, dataBlockApiKeyHandler, sheetEditorRef: externalSheetEditorRef, }: DsheetProps) => JSX.Element;
|
|
11
11
|
export default SpreadsheetEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for setting up WebRTC-based collaboration
|
|
4
|
+
* Handles real-time synchronization between peers
|
|
5
|
+
*/
|
|
6
|
+
export declare const useEditorCollaboration: (ydoc: Y.Doc | null, dsheetId: string, username?: string, enableWebrtc?: boolean, signalData?: string) => {
|
|
7
|
+
collaborationStatus: "error" | "disconnected" | "connecting" | "connected";
|
|
8
|
+
activeUsers: string[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Sheet } from '@fileverse-dev/fortune-core';
|
|
2
|
+
import { WorkbookInstance } from '@fileverse-dev/fortune-react';
|
|
3
|
+
|
|
4
|
+
import * as Y from 'yjs';
|
|
5
|
+
/**
|
|
6
|
+
* Hook for managing sheet data
|
|
7
|
+
* Handles initialization, updates, and persistence of sheet data
|
|
8
|
+
*/
|
|
9
|
+
export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | null>, dsheetId: string, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>, portalContent?: string, isReadOnly?: boolean, onChange?: (data: Sheet[]) => void, syncStatus?: "initializing" | "syncing" | "synced" | "error") => {
|
|
10
|
+
sheetData: Sheet[];
|
|
11
|
+
setSheetData: import('react').Dispatch<import('react').SetStateAction<Sheet[]>>;
|
|
12
|
+
currentDataRef: import('react').MutableRefObject<Sheet[]>;
|
|
13
|
+
remoteUpdateRef: import('react').MutableRefObject<boolean>;
|
|
14
|
+
isDataLoaded: boolean;
|
|
15
|
+
handleChange: (data: Sheet[]) => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for setting up YJS document and persistence
|
|
5
|
+
* Handles initialization of YJS document and optional IndexedDB persistence
|
|
6
|
+
*/
|
|
7
|
+
export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boolean, isReadOnly?: boolean) => {
|
|
8
|
+
ydocRef: import('react').MutableRefObject<Y.Doc | null>;
|
|
9
|
+
persistenceRef: import('react').MutableRefObject<IndexeddbPersistence | null>;
|
|
10
|
+
syncStatus: "initializing" | "syncing" | "synced" | "error";
|
|
11
|
+
isSyncedRef: import('react').MutableRefObject<boolean>;
|
|
12
|
+
};
|
package/dist/package/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sheet } from '@fileverse-dev/fortune-core';
|
|
1
|
+
import { Sheet, Cell } from '@fileverse-dev/fortune-core';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { WorkbookInstance } from '@fileverse-dev/fortune-react';
|
|
4
4
|
|
|
@@ -11,9 +11,31 @@ export interface EditorValues {
|
|
|
11
11
|
currentDataRef: React.MutableRefObject<Sheet[] | null>;
|
|
12
12
|
ydocRef: React.RefObject<Y.Doc | null>;
|
|
13
13
|
}
|
|
14
|
+
export type OnboardingHandlerType = (params: {
|
|
15
|
+
row: number;
|
|
16
|
+
column: number;
|
|
17
|
+
sheetEditorRef: React.RefObject<WorkbookInstance | null>;
|
|
18
|
+
}) => {
|
|
19
|
+
row: number;
|
|
20
|
+
column: number;
|
|
21
|
+
};
|
|
22
|
+
export type DataBlockApiKeyHandlerType = (params: {
|
|
23
|
+
data: string;
|
|
24
|
+
sheetEditorRef: React.RefObject<WorkbookInstance | null>;
|
|
25
|
+
executeStringFunction: (functionCallString: string) => Promise<unknown>;
|
|
26
|
+
row: number;
|
|
27
|
+
column: number;
|
|
28
|
+
newValue: Cell;
|
|
29
|
+
formulaResponseUiSync: (params: {
|
|
30
|
+
row: number;
|
|
31
|
+
column: number;
|
|
32
|
+
newValue: Record<string, string>;
|
|
33
|
+
apiData: Array<Record<string, object>>;
|
|
34
|
+
sheetEditorRef: React.RefObject<WorkbookInstance | null>;
|
|
35
|
+
}) => void;
|
|
36
|
+
}) => void;
|
|
14
37
|
export interface DsheetProps {
|
|
15
38
|
renderNavbar?: (editorValues?: EditorValues) => JSX.Element;
|
|
16
|
-
initialSheetData?: Sheet[];
|
|
17
39
|
enableIndexeddbSync?: boolean;
|
|
18
40
|
dsheetId: string;
|
|
19
41
|
onChange?: (updateData: SheetUpdateData, encodedUpdate?: string) => void;
|
|
@@ -25,7 +47,8 @@ export interface DsheetProps {
|
|
|
25
47
|
isCollaborative?: boolean;
|
|
26
48
|
selectedTemplate?: string;
|
|
27
49
|
onboardingComplete?: boolean;
|
|
28
|
-
onboardingHandler?:
|
|
50
|
+
onboardingHandler?: OnboardingHandlerType;
|
|
51
|
+
dataBlockApiKeyHandler?: DataBlockApiKeyHandlerType;
|
|
29
52
|
setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>;
|
|
30
53
|
toggleTemplateSidebar?: () => void;
|
|
31
54
|
sheetEditorRef?: RefObject<WorkbookInstance>;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Cell } from '@fileverse-dev/fortune-core';
|
|
2
2
|
import { WorkbookInstance } from '@fileverse-dev/fortune-react';
|
|
3
|
+
import { OnboardingHandlerType, DataBlockApiKeyHandlerType } from '../types';
|
|
3
4
|
|
|
5
|
+
export type FormulaSyncType = {
|
|
6
|
+
row: number;
|
|
7
|
+
column: number;
|
|
8
|
+
newValue: Record<string, string>;
|
|
9
|
+
apiData: Array<Record<string, object>>;
|
|
10
|
+
sheetEditorRef: React.RefObject<WorkbookInstance | null>;
|
|
11
|
+
};
|
|
12
|
+
export declare const formulaResponseUiSync: ({ row, column, newValue, apiData, sheetEditorRef, }: FormulaSyncType) => void;
|
|
4
13
|
/**
|
|
5
14
|
* Handles logic after a cell is updated, including processing formula results
|
|
6
15
|
*
|
|
@@ -9,19 +18,15 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
|
|
|
9
18
|
* @param oldValue - The previous value of the cell
|
|
10
19
|
* @param newValue - The new value of the cell
|
|
11
20
|
* @param sheetEditorRef - Reference to the workbook instance
|
|
12
|
-
* @param
|
|
13
|
-
* @param openApiKeyModalRef - Ref object tracking if the API key modal is open
|
|
14
|
-
* @param contextApiKeyName - Ref object for the current API key name context
|
|
21
|
+
* @param onboardingHandler - Function to handle onboarding from consumer side
|
|
15
22
|
* @returns {Promise<void>}
|
|
16
23
|
*/
|
|
17
|
-
export declare const afterUpdateCell: ({ row, column, newValue, sheetEditorRef,
|
|
24
|
+
export declare const afterUpdateCell: ({ row, column, newValue, sheetEditorRef, onboardingComplete, onboardingHandler, dataBlockApiKeyHandler, }: {
|
|
18
25
|
row: number;
|
|
19
26
|
column: number;
|
|
20
27
|
newValue: Cell;
|
|
21
28
|
sheetEditorRef: React.RefObject<WorkbookInstance | null>;
|
|
22
|
-
setOpenApiKeyModal: React.Dispatch<React.SetStateAction<boolean>>;
|
|
23
|
-
openApiKeyModalRef: React.MutableRefObject<boolean>;
|
|
24
|
-
contextApiKeyName: React.MutableRefObject<string | null>;
|
|
25
29
|
onboardingComplete: boolean | undefined;
|
|
26
|
-
onboardingHandler:
|
|
30
|
+
onboardingHandler: OnboardingHandlerType | undefined;
|
|
31
|
+
dataBlockApiKeyHandler: DataBlockApiKeyHandlerType | undefined;
|
|
27
32
|
}) => Promise<void>;
|