@fileverse-dev/dsheet 2.1.5 → 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 (132) 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/api-key-modal/api-key-input.d.ts +5 -0
  4. package/dist/editor/components/api-key-modal/api-key-modal.d.ts +7 -0
  5. package/dist/editor/components/api-key-modal/rate-limit-info.d.ts +4 -0
  6. package/dist/editor/components/comments/comment-actions-dropdown.d.ts +19 -0
  7. package/dist/editor/components/comments/comment-cell-popup.d.ts +4 -0
  8. package/dist/editor/components/comments/comment-input.d.ts +4 -0
  9. package/dist/editor/components/comments/comment-item.d.ts +4 -0
  10. package/dist/editor/components/comments/comment-sidebar-empty.d.ts +4 -0
  11. package/dist/editor/components/comments/comment-sidebar.d.ts +4 -0
  12. package/dist/editor/components/comments/ens/ens-cache.d.ts +10 -0
  13. package/dist/editor/components/comments/ens/use-ens-status.d.ts +10 -0
  14. package/dist/editor/components/comments/use-comment-cell-popup.d.ts +12 -0
  15. package/dist/editor/components/comments/use-comment-permissions.d.ts +15 -0
  16. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  17. package/dist/editor/components/editor-workbook.d.ts +11 -17
  18. package/dist/editor/components/sidebar/editor-right-sidebar.d.ts +20 -0
  19. package/dist/editor/components/sidebar/right-sidebar.d.ts +14 -0
  20. package/dist/editor/components/sidebar/sidebar-context.d.ts +17 -0
  21. package/dist/editor/components/sidebar/sidebar-portal-registry.d.ts +20 -0
  22. package/dist/editor/components/sidebar/use-right-panels.d.ts +12 -0
  23. package/dist/editor/components/sidebars/conditional-format.d.ts +2 -0
  24. package/dist/editor/components/sidebars/data-verification.d.ts +2 -0
  25. package/dist/editor/components/sidebars/function/function-categories-logic.d.ts +11 -0
  26. package/dist/editor/components/sidebars/function/function-categories.d.ts +6 -0
  27. package/dist/editor/components/sidebars/function/function-metadata.d.ts +7 -0
  28. package/dist/editor/components/sidebars/function/functionList.d.ts +8 -0
  29. package/dist/editor/components/sidebars/function/types.d.ts +24 -0
  30. package/dist/editor/components/sidebars/function/use-functions.d.ts +20 -0
  31. package/dist/editor/components/sidebars/function-content.d.ts +8 -0
  32. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  33. package/dist/editor/components/sidebars/template-ui.d.ts +22 -0
  34. package/dist/editor/components/sidebars/templates.d.ts +9 -0
  35. package/dist/editor/components/smart-contract/error-toast.d.ts +11 -0
  36. package/dist/editor/components/smart-contract/modal/abi-input-section.d.ts +11 -0
  37. package/dist/editor/components/smart-contract/modal/contract-name-section.d.ts +13 -0
  38. package/dist/editor/components/smart-contract/modal/file-upload-section.d.ts +12 -0
  39. package/dist/editor/components/smart-contract/modal/import-section.d.ts +8 -0
  40. package/dist/editor/components/smart-contract/modal/modal-header.d.ts +17 -0
  41. package/dist/editor/components/smart-contract/smart-contract-list-item.d.ts +8 -0
  42. package/dist/editor/components/smart-contract/smart-contract-modal-ui.d.ts +33 -0
  43. package/dist/editor/components/smart-contract/smart-contract-modal.d.ts +12 -0
  44. package/dist/editor/components/smart-contract/smart-contract-reading-intro.d.ts +4 -0
  45. package/dist/editor/components/smart-contract/smart-contract-view-list.d.ts +6 -0
  46. package/dist/editor/components/smart-contract/use-address-validation.d.ts +5 -0
  47. package/dist/editor/components/smart-contract/use-modal-outside-click.d.ts +18 -0
  48. package/dist/editor/components/smart-contract/use-smart-contract-modal.d.ts +38 -0
  49. package/dist/editor/constants/shared-constants.d.ts +0 -2
  50. package/dist/editor/contexts/editor-context.d.ts +20 -5
  51. package/dist/editor/dsheet-editor.d.ts +1 -1
  52. package/dist/editor/hooks/live-query/use-live-query.d.ts +4 -2
  53. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  54. package/dist/editor/hooks/use-editor-data.d.ts +4 -2
  55. package/dist/editor/hooks/use-smart-contract.d.ts +26 -0
  56. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +8 -1
  57. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  58. package/dist/editor/types/comments.d.ts +134 -0
  59. package/dist/editor/types/smart-contract.d.ts +88 -0
  60. package/dist/editor/types.d.ts +39 -32
  61. package/dist/editor/utils/after-update-cell.d.ts +13 -8
  62. package/dist/editor/utils/api-key-storage.d.ts +6 -0
  63. package/dist/editor/utils/api-keys-local-storage.d.ts +19 -0
  64. package/dist/editor/utils/cell-comment-marker.d.ts +30 -0
  65. package/dist/editor/utils/comment-key-utils.d.ts +7 -0
  66. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  67. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  68. package/dist/editor/utils/csv-import.d.ts +3 -1
  69. package/dist/editor/utils/data-block-error-handler.d.ts +21 -0
  70. package/dist/editor/utils/datablock-error-utils.d.ts +1 -0
  71. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  72. package/dist/editor/utils/sheet-editor-safe.d.ts +26 -0
  73. package/dist/editor/utils/smart-contract/constants.d.ts +488 -0
  74. package/dist/editor/utils/smart-contract/error-helper.d.ts +20 -0
  75. package/dist/editor/utils/smart-contract/helpers.d.ts +4 -0
  76. package/dist/editor/utils/smart-contract/reading-utils.d.ts +34 -0
  77. package/dist/editor/utils/smart-contract/signature-utils.d.ts +9 -0
  78. package/dist/editor/utils/spreadsheet-import.d.ts +12 -0
  79. package/dist/editor/utils/update-ydoc.d.ts +2 -2
  80. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  81. package/dist/executeStringFunction-DMPoSj5F.js +32826 -0
  82. package/dist/formula.js +1 -1
  83. package/dist/index-DAVuAF9T.js +55303 -0
  84. package/dist/index.d.ts +11 -1
  85. package/dist/index.es.js +55 -49
  86. package/dist/jszip.min-CEyB-71x.js +2319 -0
  87. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  88. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  89. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  90. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  91. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  92. package/dist/sheet-engine/core/context.d.ts +8 -1
  93. package/dist/sheet-engine/core/index.d.ts +2 -2
  94. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +53 -0
  95. package/dist/sheet-engine/core/modules/formula-eval.worker.d.ts +1 -0
  96. package/dist/sheet-engine/core/modules/formula-range-cache.d.ts +20 -0
  97. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +51 -0
  98. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +7 -0
  99. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +17 -0
  100. package/dist/sheet-engine/core/modules/formula-worker-types.d.ts +24 -0
  101. package/dist/sheet-engine/core/modules/formula.d.ts +53 -1
  102. package/dist/sheet-engine/core/modules/index.d.ts +5 -2
  103. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  104. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  105. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  106. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  107. package/dist/sheet-engine/core/settings.d.ts +3 -1
  108. package/dist/sheet-engine/core/theme.d.ts +67 -0
  109. package/dist/sheet-engine/core/types.d.ts +20 -0
  110. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  111. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  112. package/dist/sheet-engine/core/utils/range-format.d.ts +71 -0
  113. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +40 -0
  114. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  115. package/dist/sheet-engine/react/components/SheetOverlay/Icon.d.ts +5 -4
  116. package/dist/sheet-engine/react/components/SheetOverlay/LucideIcon.d.ts +4 -4
  117. package/dist/sheet-engine/react/components/SidebarPanelPortals/index.d.ts +17 -0
  118. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  119. package/dist/sheet-engine/react/components/Workbook/index.d.ts +11 -1
  120. package/dist/sheet-engine/react/components/index.d.ts +1 -0
  121. package/dist/sheet-engine/react/utils/datepickerStyles.d.ts +1 -1
  122. package/dist/style.css +1 -1
  123. package/dist/use-xlsx-import-impl-DzthrhwA.js +1595 -0
  124. package/dist/xlsx-defined-names-D2KoICbm.js +117 -0
  125. package/dist/xlsx-export-impl-b2z4De4f.js +818 -0
  126. package/package.json +6 -4
  127. package/dist/executeStringFunction-BkmJj04p.js +0 -27295
  128. package/dist/index-Drl8OuI3.js +0 -52659
  129. package/dist/sheet-engine/react/components/Toolbar/conditionalFormatPortal.d.ts +0 -7
  130. package/dist/sheet-engine/react/components/Toolbar/dataVerificationPortal.d.ts +0 -6
  131. package/dist/use-xlsx-import-impl-DC_BfAcT.js +0 -1527
  132. package/dist/xlsx-export-impl-DP_eK3zS.js +0 -3126
@@ -0,0 +1,18 @@
1
+ import { MutableRefObject } from 'react';
2
+
3
+ interface UseFetchUrlModalProps {
4
+ onClose?: () => void;
5
+ setInputAddress?: React.Dispatch<React.SetStateAction<string>>;
6
+ shouldPreventClose?: MutableRefObject<boolean>;
7
+ }
8
+ export declare const useModalOutsideClick: ({ onClose, setInputAddress, shouldPreventClose, }?: UseFetchUrlModalProps) => {
9
+ rowCount: number;
10
+ setRowCount: import('react').Dispatch<import('react').SetStateAction<number>>;
11
+ includeHeaders: boolean;
12
+ setIncludeHeaders: import('react').Dispatch<import('react').SetStateAction<boolean>>;
13
+ abortCall: boolean;
14
+ modalDivRef: import('react').RefObject<HTMLDivElement>;
15
+ resetModalState: () => void;
16
+ handleClose: () => void;
17
+ };
18
+ export {};
@@ -0,0 +1,38 @@
1
+ import { Hex } from 'viem';
2
+ import { ContractConfig, SupportedChain } from '../../types/smart-contract';
3
+
4
+ export declare function useSmartContractModal({ onSaveContract, setShowSmartContractModal, registryMapRef, }: {
5
+ onSaveContract: (address: Hex, chain: SupportedChain, abi: string, smartContractName: string) => Promise<void>;
6
+ setShowSmartContractModal: (show: boolean) => void;
7
+ registryMapRef: React.MutableRefObject<Record<string, ContractConfig>>;
8
+ }): {
9
+ inputAddress: string;
10
+ setInputAddress: import('react').Dispatch<import('react').SetStateAction<string>>;
11
+ selectedChain: SupportedChain;
12
+ setSelectedChain: import('react').Dispatch<import('react').SetStateAction<SupportedChain>>;
13
+ formStep: number;
14
+ setFormStep: import('react').Dispatch<import('react').SetStateAction<number>>;
15
+ abiCode: string;
16
+ setAbiCode: import('react').Dispatch<import('react').SetStateAction<string>>;
17
+ uploadedFile: any;
18
+ setUploadedFile: import('react').Dispatch<any>;
19
+ uploadProgress: number;
20
+ setUploadProgress: import('react').Dispatch<import('react').SetStateAction<number>>;
21
+ isUploading: boolean;
22
+ setIsUploading: import('react').Dispatch<import('react').SetStateAction<boolean>>;
23
+ fileInputRef: import('react').MutableRefObject<any>;
24
+ smartContractName: string;
25
+ setSmartContractName: import('react').Dispatch<import('react').SetStateAction<string>>;
26
+ isImportingRef: import('react').MutableRefObject<boolean>;
27
+ modalDivRef: import('react').RefObject<HTMLDivElement>;
28
+ handleFileInputChange: (e: any) => void;
29
+ handleUploadAreaClick: () => void;
30
+ handleRemoveFile: () => void;
31
+ handleAddressInputChange: (url: string) => void;
32
+ onClickProceed: (abi?: any) => Promise<void>;
33
+ isValidAddress: boolean;
34
+ registryMapRef: import('react').MutableRefObject<Record<string, ContractConfig>>;
35
+ errorState: {
36
+ message: string;
37
+ } | null;
38
+ };
@@ -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[];
@@ -1,7 +1,12 @@
1
1
  import { default as React } from 'react';
2
2
  import { LiveQueryData, Sheet, WorkbookInstance } from '../../sheet-engine/react';
3
3
  import { IndexeddbPersistence } from 'y-indexeddb';
4
- import { DataBlockApiKeyHandlerType, SheetUpdateData } from '../types';
4
+ import { SheetUpdateData, DataBlockEvent } from '../types';
5
+ import { CommentsConfig } from '../types/comments';
6
+ import { ApiKeyStorage } from '../utils/api-key-storage';
7
+ import { OpenApiKeyModalFn } from '../utils/data-block-error-handler';
8
+ import { SmartContractConfig } from '../types/smart-contract';
9
+ import { UseSmartContractReturn } from '../hooks/use-smart-contract';
5
10
  import { CollaborationProps, CollabState, CollabUser } from '../../sync-local/types';
6
11
  import { Awareness } from 'y-protocols/awareness';
7
12
 
@@ -48,11 +53,19 @@ export interface EditorContextType {
48
53
  terminateSession?: () => void;
49
54
  onCollaboratorsChange?: (collaborators: CollabUser[]) => void;
50
55
  handleLiveQuery: (subsheetIndex: number, data: LiveQueryData) => void;
56
+ apiKeyStorage: ApiKeyStorage;
57
+ onDataBlockEvent?: (event: DataBlockEvent) => void;
58
+ openApiKeyModal: OpenApiKeyModalFn;
59
+ apiKeyModalState: {
60
+ open: boolean;
61
+ apiKeyName: string;
62
+ onSave: (key: string) => void;
63
+ onClose: () => void;
64
+ } | null;
65
+ smartContract: UseSmartContractReturn;
51
66
  }
52
67
  interface EditorProviderProps {
53
- allowComments?: boolean;
54
68
  setSelectedTemplate?: React.Dispatch<React.SetStateAction<string>>;
55
- setShowSmartContractModal?: React.Dispatch<React.SetStateAction<boolean>>;
56
69
  getDocumentTitle?: (dsheetId: string) => Promise<string>;
57
70
  updateDocumentTitle?: (title: string) => void;
58
71
  isAuthorized: boolean;
@@ -65,7 +78,7 @@ interface EditorProviderProps {
65
78
  onChange?: (data: SheetUpdateData, encodedUpdate?: string) => void;
66
79
  collaboration?: CollaborationProps;
67
80
  externalEditorRef?: React.MutableRefObject<WorkbookInstance | null>;
68
- commentData?: object;
81
+ commentsConfig?: CommentsConfig;
69
82
  editorStateRef?: React.MutableRefObject<{
70
83
  refreshIndexedDB: () => Promise<void>;
71
84
  terminateSession?: () => void;
@@ -74,7 +87,9 @@ interface EditorProviderProps {
74
87
  } | null>;
75
88
  enableLiveQuery?: boolean;
76
89
  liveQueryRefreshRate?: number;
77
- dataBlockApiKeyHandler?: DataBlockApiKeyHandlerType;
90
+ apiKeyStorage?: ApiKeyStorage;
91
+ onDataBlockEvent?: (event: DataBlockEvent) => void;
92
+ smartContracts?: SmartContractConfig;
78
93
  onContentSyncStatusChange?: (status: 'initializing' | 'syncing' | 'synced' | 'error') => void;
79
94
  }
80
95
  export declare const EditorProvider: React.FC<EditorProviderProps>;
@@ -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: ({ isReadOnly, allowSheetDownload, allowComments, renderNavbar, enableIndexeddbSync, dsheetId, portalContent, onChange, username, selectedTemplate, toggleTemplateSidebar, isTemplateOpen, onboardingComplete, onboardingCompleteLocalStorageKey, onboardingHandler, commentData, getCommentCellUI, dataBlockApiKeyHandler, setFetchingURLData, setShowFetchURLModal, setInputFetchURLDataBlock, sheetEditorRef: externalSheetEditorRef, storeApiKey, onDuneChartEmbed, onSheetCountChange, onDataBlockApiResponse, isAuthorized, getDocumentTitle, updateDocumentTitle, setShowSmartContractModal, editorStateRef, handleSmartContractQuery, setSelectedTemplate, isNewSheet, liveQueryRefreshRate, enableLiveQuery, collaboration, onContentSyncStatusChange, }: DsheetProps) => JSX.Element;
10
+ declare const SpreadsheetEditor: ({ isReadOnly, allowSheetDownload, renderNavbar, enableIndexeddbSync, dsheetId, portalContent, onChange, username, selectedTemplate, toggleTemplateSidebar, isTemplateOpen, onboardingComplete, onboardingCompleteLocalStorageKey, onboardingHandler, commentsConfig, setFetchingURLData, setShowFetchURLModal, setInputFetchURLDataBlock, sheetEditorRef: externalSheetEditorRef, onDuneChartEmbed, onSheetCountChange, isAuthorized, getDocumentTitle, updateDocumentTitle, editorStateRef, setSelectedTemplate, isNewSheet, liveQueryRefreshRate, enableLiveQuery, collaboration, customPanels, apiKeyStorage, onDataBlockEvent, smartContracts, theme, onContentSyncStatusChange, }: DsheetProps) => JSX.Element;
11
11
  export default SpreadsheetEditor;
@@ -1,8 +1,10 @@
1
1
  import { LiveQueryData, Sheet, WorkbookInstance } from '../../../sheet-engine/react';
2
- import { DataBlockApiKeyHandlerType } from '../../types';
2
+ import { ApiKeyStorage } from '../../utils/api-key-storage';
3
+ import { OpenApiKeyModalFn } from '../../utils/data-block-error-handler';
4
+ import { DataBlockEvent } from '../../types';
3
5
 
4
6
  export declare const LIVE_QUERY_ERROR = "LIVE_QUERY_ERROR";
5
- export declare const useLiveQuery: (sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, dataBlockApiKeyHandler?: DataBlockApiKeyHandlerType, enableLiveQuery?: boolean, refreshRate?: number) => {
7
+ export declare const useLiveQuery: (sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, apiKeyStorage?: ApiKeyStorage, openApiKeyModal?: OpenApiKeyModalFn, onDataBlockEvent?: (event: DataBlockEvent) => void, enableLiveQuery?: boolean, refreshRate?: number) => {
6
8
  handleLiveQuery: (subsheetIndex: number, queryData: LiveQueryData) => void;
7
9
  initialiseLiveQueryData: (sheets: Sheet[]) => void;
8
10
  };
@@ -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 {};
@@ -1,5 +1,7 @@
1
1
  import { Sheet, WorkbookInstance } from '../../sheet-engine/react';
2
- import { DataBlockApiKeyHandlerType } from '../types';
2
+ import { ApiKeyStorage } from '../utils/api-key-storage';
3
+ import { OpenApiKeyModalFn } from '../utils/data-block-error-handler';
4
+ import { DataBlockEvent } from '../types';
3
5
 
4
6
  import * as Y from 'yjs';
5
7
  /**
@@ -14,7 +16,7 @@ export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | nul
14
16
  [key: string]: {
15
17
  [key: string]: any;
16
18
  };
17
- }>>, enableLiveQuery?: boolean, liveQueryRefreshRate?: number, dataBlockApiKeyHandler?: DataBlockApiKeyHandlerType, allowComments?: boolean, hasCollabContentInitialised?: boolean, collabEnabled?: boolean) => {
19
+ }>>, enableLiveQuery?: boolean, liveQueryRefreshRate?: number, apiKeyStorage?: ApiKeyStorage, openApiKeyModal?: OpenApiKeyModalFn, onDataBlockEvent?: (event: DataBlockEvent) => void, allowComments?: boolean, hasCollabContentInitialised?: boolean, collabEnabled?: boolean) => {
18
20
  sheetData: Sheet[];
19
21
  setSheetData: import('react').Dispatch<import('react').SetStateAction<Sheet[]>>;
20
22
  currentDataRef: import('react').MutableRefObject<Sheet[]>;
@@ -0,0 +1,26 @@
1
+ import { Abi, Hex } from 'viem';
2
+ import { ContractConfig, ContractRegistry, SmartContractConfig, SupportedChain } from '../types/smart-contract';
3
+ import { SmartContractQueryHandler } from '../utils/after-update-cell';
4
+
5
+ export declare const useSmartContract: (config?: SmartContractConfig) => {
6
+ enabled: boolean;
7
+ showSmartContractModal: boolean;
8
+ setShowSmartContractModal: import('react').Dispatch<import('react').SetStateAction<boolean>>;
9
+ userSmartContracts: ContractConfig[];
10
+ allUserContracts: ContractConfig[];
11
+ registryMapRef: import('react').MutableRefObject<ContractRegistry>;
12
+ handleSmartContractQuery: SmartContractQueryHandler | undefined;
13
+ onImportContract: (address: Hex, network: SupportedChain, abiJson: string, smartContractName: string) => Promise<void>;
14
+ onDelete: (name: string) => Promise<void>;
15
+ handleSearch: (searchText: string) => void;
16
+ smartContractReadingError: {
17
+ hasError: boolean;
18
+ errorMessage: string;
19
+ };
20
+ setSmartContractReadingError: import('react').Dispatch<import('react').SetStateAction<{
21
+ hasError: boolean;
22
+ errorMessage: string;
23
+ }>>;
24
+ fetchContractAbi: (contract: ContractConfig) => Promise<Abi>;
25
+ };
26
+ export type UseSmartContractReturn = ReturnType<typeof useSmartContract>;
@@ -11,6 +11,13 @@ export type XlsxImportRuntimeDeps = {
11
11
  updateDocumentTitle?: (title: string) => void;
12
12
  filterToastShown: boolean;
13
13
  setFilterToastShown: React.Dispatch<React.SetStateAction<boolean>>;
14
+ handleContentPortal?: () => void;
15
+ };
16
+ export type XlsxImportOptions = {
17
+ headless?: boolean;
18
+ suppressUiWarnings?: boolean;
19
+ onWarning?: (warning: string) => void;
20
+ generateSheetId?: () => string;
14
21
  };
15
22
  /** Full XLSX import pipeline; loaded only when user imports a file. */
16
- 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'): 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,134 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface CommentThread {
4
+ id: string;
5
+ key: string;
6
+ dsheetId: string;
7
+ username: string;
8
+ content: string;
9
+ createdAt: string;
10
+ commentIndex: number;
11
+ cellContent?: string;
12
+ replies: CommentReply[];
13
+ isResolved?: boolean;
14
+ isDeleted?: boolean;
15
+ }
16
+ export interface CommentReply {
17
+ id: string;
18
+ username: string;
19
+ content: string;
20
+ createdAt: string;
21
+ commentIndex: number;
22
+ isResolved?: boolean;
23
+ isDeleted?: boolean;
24
+ }
25
+ export declare enum CommentAction {
26
+ RESOLVE = "resolve",
27
+ UNRESOLVE = "unresolve",
28
+ DELETE = "delete"
29
+ }
30
+ export interface CommentActionParams {
31
+ action: CommentAction;
32
+ commentId: string;
33
+ dsheetId: string;
34
+ commentKey: string;
35
+ isReply?: boolean;
36
+ parentCommentId?: string;
37
+ row: number;
38
+ col: number;
39
+ }
40
+ export interface CommentsConfig {
41
+ commentsData: Record<string, CommentThread>;
42
+ onSendComment: (key: string, textareaId: string) => void;
43
+ onCommentAction: (action: CommentActionParams) => void;
44
+ userName?: string;
45
+ ownerAddress?: string;
46
+ currentUserAddress?: string;
47
+ isOwner?: boolean;
48
+ isAuthenticated?: boolean;
49
+ unauthenticatedFallback?: React.ReactNode;
50
+ ensResolutionUrl?: string;
51
+ disabled?: boolean;
52
+ }
53
+ export interface CellPosition {
54
+ row: number;
55
+ col: number;
56
+ sheetId?: string;
57
+ }
58
+ export interface SheetEditorRef {
59
+ scroll: (o: {
60
+ scrollLeft?: number;
61
+ scrollTop?: number;
62
+ targetRow?: number;
63
+ targetColumn?: number;
64
+ }) => void;
65
+ setSelection: (s: Array<{
66
+ row: number[];
67
+ column: number[];
68
+ }>) => void;
69
+ }
70
+ export interface CommentInputProps {
71
+ id: string;
72
+ onSend: (textareaId: string) => void;
73
+ placeholder?: string;
74
+ autoFocus?: boolean;
75
+ className?: string;
76
+ backgroundColor?: string;
77
+ inCellComment?: boolean;
78
+ cancelComment?: () => void;
79
+ onBlur?: () => void;
80
+ isStaticButton?: boolean;
81
+ removeCancelButton?: boolean;
82
+ focusTrap?: boolean;
83
+ disabled?: boolean;
84
+ }
85
+ export interface CommentItemProps {
86
+ comment: CommentThread;
87
+ showAvatar?: boolean;
88
+ avatarSize?: 'sm' | 'md' | 'lg';
89
+ className?: string;
90
+ isHovered?: boolean;
91
+ sheetName?: string;
92
+ cellReference?: string;
93
+ onAction?: (a: CommentActionParams) => void;
94
+ ownerAddress?: string;
95
+ currentUserAddress?: string;
96
+ isOwner?: boolean;
97
+ currentUserName?: string;
98
+ contentClassName?: string;
99
+ isCellPopup?: boolean;
100
+ shouldShowActions?: boolean;
101
+ row?: number;
102
+ col?: number;
103
+ }
104
+ export interface CommentCellUIProps {
105
+ row: number;
106
+ col: number;
107
+ sheetId: string;
108
+ comment?: CommentThread;
109
+ onSendComment: (commentKey: string, textareaId: string) => void;
110
+ onAction?: (a: CommentActionParams) => void;
111
+ ownerAddress?: string;
112
+ currentUserAddress?: string;
113
+ isOwner?: boolean;
114
+ sheetEditorRef?: React.RefObject<SheetEditorRef>;
115
+ currentUserName?: string;
116
+ removeCommentFromCell: (row: number, col: number) => void;
117
+ closePopup?: () => void;
118
+ dragHandler: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
119
+ isHover?: boolean;
120
+ disabled?: boolean;
121
+ }
122
+ export interface CommentsContentProps {
123
+ sheetEditorRef: React.RefObject<SheetEditorRef>;
124
+ userName: string | undefined;
125
+ commentsData: Record<string, CommentThread>;
126
+ onSendComment: (commentKey: string, textareaId: string) => void;
127
+ onCommentAction?: (a: CommentActionParams) => void;
128
+ ownerAddress?: string;
129
+ currentUserAddress?: string;
130
+ isOwner?: boolean;
131
+ disabled?: boolean;
132
+ isAuthenticated?: boolean;
133
+ unauthenticatedFallback?: React.ReactNode;
134
+ }
@@ -0,0 +1,88 @@
1
+ import { Abi, Hex } from 'viem';
2
+ import { default as React } from 'react';
3
+
4
+ export declare enum SupportedChain {
5
+ Ethereum = "Ethereum",
6
+ Sepolia = "Sepolia",
7
+ Gnosis = "Gnosis",
8
+ Base = "Base"
9
+ }
10
+ export interface ContractConfig {
11
+ address: Hex;
12
+ abiHash: string;
13
+ network: SupportedChain;
14
+ name: string;
15
+ }
16
+ export type ContractRegistry = Record<string, ContractConfig>;
17
+ export interface NewContractInput {
18
+ name: string;
19
+ address: Hex;
20
+ network: SupportedChain;
21
+ abi: Abi;
22
+ }
23
+ export type SmartContractEventType = 'query-success' | 'query-error' | 'contract-added' | 'contract-deleted';
24
+ export interface SmartContractEvent {
25
+ type: SmartContractEventType;
26
+ contractName?: string;
27
+ functionName?: string;
28
+ chainName?: string;
29
+ errorMessage?: string;
30
+ }
31
+ export interface SmartContractConfig {
32
+ /** User's persisted private contracts from consumer keystore. Defaults to []. */
33
+ contracts?: ContractConfig[];
34
+ /** RPC URL per chain. Falls back to bundled defaults when omitted. */
35
+ rpcConfig?: Partial<Record<SupportedChain, string>>;
36
+ /** Resolve ABI from stored reference (e.g. IPFS hash). Required for user-saved contracts with abiHash. */
37
+ resolveAbi?: (abiHash: string) => Promise<Abi>;
38
+ /** Persist a new contract. When omitted, package keeps it in session memory only. */
39
+ onAddContract?: (input: NewContractInput) => Promise<void>;
40
+ /** Remove a persisted contract. When omitted, package removes from session memory only. */
41
+ onDeleteContract?: (contractName: string) => Promise<void>;
42
+ validateAddress?: (address: string, chain: SupportedChain) => boolean | Promise<boolean>;
43
+ onSmartContractEvent?: (event: SmartContractEvent) => void;
44
+ }
45
+ export interface CallerParams {
46
+ abi: Abi;
47
+ contractAddress: Hex;
48
+ chain: import('viem').Chain;
49
+ functionName?: string;
50
+ args?: unknown[];
51
+ }
52
+ export interface FetchAbiParams {
53
+ contractAddress: Hex;
54
+ chain: import('viem').Chain;
55
+ ipfsHash?: string;
56
+ }
57
+ export type ParsedFunction = {
58
+ functionName: string;
59
+ output: string;
60
+ };
61
+ export interface SmartContractListViewProps {
62
+ userSmartContracts: ContractConfig[];
63
+ onDelete: (name: string) => void;
64
+ handleSearch: (searchText: string) => void;
65
+ onOpenImportModal: () => void;
66
+ fetchContractAbi: (contract: ContractConfig) => Promise<Abi>;
67
+ isAuthorized: boolean;
68
+ }
69
+ export interface MyContractsProps {
70
+ contracts: ContractConfig[];
71
+ onDelete: (name: string) => void;
72
+ fetchContractAbi: (contract: ContractConfig) => Promise<Abi>;
73
+ setActiveTab?: React.Dispatch<React.SetStateAction<string>>;
74
+ }
75
+ export interface PopularContractsProps {
76
+ contracts: ContractConfig[];
77
+ onInsert: (name: string) => void;
78
+ fetchContractAbi: (contract: ContractConfig) => Promise<Abi>;
79
+ }
80
+ export interface CodeBlockProps {
81
+ code: React.ReactNode;
82
+ copyText: string;
83
+ }
84
+ export interface ParameterDescriptionProps {
85
+ paramName: string;
86
+ description: string;
87
+ optional?: boolean;
88
+ }
@@ -1,10 +1,16 @@
1
- import { Sheet, Workbook, WorkbookInstance, Cell } from '../sheet-engine/react';
2
- import { ComponentProps, RefObject } from 'react';
1
+ import { Sheet, WorkbookInstance } from '../sheet-engine/react';
2
+ import { RefObject } from 'react';
3
3
  import { ERROR_MESSAGES_FLAG } from './constants/shared-constants';
4
- import { SmartContractQueryHandler } from './utils/after-update-cell';
5
4
  import { CollaborationProps } from '../sync-local/types';
5
+ import { CommentsConfig } from './types/comments';
6
+ import { SmartContractConfig } from './types/smart-contract';
7
+ import { ApiKeyStorage } from './utils/api-key-storage';
8
+ import { ThemeKey } from '../sheet-engine/core/theme';
6
9
 
7
10
  import * as Y from 'yjs';
11
+ export type { ThemeKey } from '../sheet-engine/core/theme';
12
+ export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, } from './types/comments';
13
+ export { CommentAction } from './types/comments';
8
14
  export interface SheetUpdateData {
9
15
  data: Sheet[];
10
16
  }
@@ -12,7 +18,19 @@ export interface EditorValues {
12
18
  sheetEditorRef: RefObject<WorkbookInstance>;
13
19
  currentDataRef: React.MutableRefObject<Sheet[] | null>;
14
20
  ydocRef: React.RefObject<Y.Doc | null>;
21
+ openPanel: (panelId: string) => void;
22
+ closePanel: () => void;
15
23
  }
24
+ export interface PanelConfig {
25
+ id: string;
26
+ header: {
27
+ title: string;
28
+ subtitle?: string;
29
+ };
30
+ width?: string;
31
+ content: React.ReactNode;
32
+ }
33
+ export type { PanelId, BuiltInPanelType, } from './components/sidebar/use-right-panels';
16
34
  export type OnboardingHandlerType = (params: {
17
35
  row: number;
18
36
  column: number;
@@ -21,31 +39,17 @@ export type OnboardingHandlerType = (params: {
21
39
  row: number;
22
40
  column: number;
23
41
  };
24
- export type DataBlockApiKeyHandlerType = (params: {
25
- data: ErrorMessageHandlerReturnType;
26
- sheetEditorRef: React.RefObject<WorkbookInstance | null>;
27
- executeStringFunction: ({ functionCallString, sheetEditorRef, dataBlockRow, dataBlockColumn, handleSmartContractQuery, }: {
28
- functionCallString: string;
29
- sheetEditorRef: React.RefObject<WorkbookInstance | null>;
30
- dataBlockRow: number;
31
- dataBlockColumn: number;
32
- handleSmartContractQuery: SmartContractQueryHandler;
33
- }) => Promise<unknown>;
34
- row: number;
35
- column: number;
36
- newValue: Cell;
37
- formulaResponseUiSync: (params: {
38
- row: number;
39
- column: number;
40
- newValue: Record<string, string>;
41
- apiData: Array<Record<string, object>>;
42
- sheetEditorRef: React.RefObject<WorkbookInstance | null>;
43
- }) => void;
44
- }) => void;
42
+ export type DataBlockEventType = 'success' | 'error' | 'api-key-required' | 'api-key-saved' | 'retry';
43
+ export interface DataBlockEvent {
44
+ type: DataBlockEventType;
45
+ functionName?: string;
46
+ errorType?: string;
47
+ apiKeyName?: string;
48
+ }
49
+ export type { ApiKeyStorage } from './utils/api-key-storage';
45
50
  export interface DsheetProps {
46
51
  isNewSheet: boolean;
47
52
  setSelectedTemplate?: React.Dispatch<React.SetStateAction<string>>;
48
- setShowSmartContractModal?: React.Dispatch<React.SetStateAction<boolean>>;
49
53
  getDocumentTitle?: (dsheetId: string) => Promise<string>;
50
54
  updateDocumentTitle?: (title: string) => void;
51
55
  isAuthorized: boolean;
@@ -67,17 +71,16 @@ export interface DsheetProps {
67
71
  /** When `onboardingComplete` is omitted, read `localStorage.getItem(key)==='true'` (default key `onboardingComplete`). */
68
72
  onboardingCompleteLocalStorageKey?: string;
69
73
  onboardingHandler?: OnboardingHandlerType;
70
- dataBlockApiKeyHandler?: DataBlockApiKeyHandlerType;
71
74
  setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>;
72
- getCommentCellUI?: ComponentProps<typeof Workbook>['getCommentCellUI'];
73
- commentData?: Object;
75
+ commentsConfig?: CommentsConfig;
74
76
  toggleTemplateSidebar?: () => void;
75
77
  sheetEditorRef?: RefObject<WorkbookInstance & {
76
78
  refreshIndexedDB: () => Promise<void>;
77
79
  }>;
78
- storeApiKey?: (apiKeyName: string) => void;
79
- allowComments?: boolean;
80
- onDataBlockApiResponse?: (dataBlockName: string) => void;
80
+ /** Override where datablock API keys are stored (default: localStorage). */
81
+ apiKeyStorage?: ApiKeyStorage;
82
+ /** Optional lifecycle events for analytics / side-effects. */
83
+ onDataBlockEvent?: (event: DataBlockEvent) => void;
81
84
  onDuneChartEmbed?: () => void;
82
85
  onSheetCountChange?: (sheetCount: number) => void;
83
86
  /** Fires whenever local content-sync status changes. Host apps should gate
@@ -87,9 +90,13 @@ export interface DsheetProps {
87
90
  editorStateRef?: React.MutableRefObject<{
88
91
  refreshIndexedDB: () => Promise<void>;
89
92
  } | null>;
90
- handleSmartContractQuery?: SmartContractQueryHandler;
93
+ /** Smart contract config: execution + UI in package; consumer owns persistence via callbacks. */
94
+ smartContracts?: SmartContractConfig;
91
95
  enableLiveQuery?: boolean;
92
96
  liveQueryRefreshRate?: number;
97
+ customPanels?: PanelConfig[];
98
+ /** Active theme; drives the canvas/grid palette (chrome themes via the <html> class). */
99
+ theme?: ThemeKey;
93
100
  }
94
101
  export type BaseError = {
95
102
  message: string;
@@ -1,7 +1,10 @@
1
1
  import { Cell, WorkbookInstance } from '../../sheet-engine/react';
2
- import { OnboardingHandlerType, DataBlockApiKeyHandlerType } from '../types';
2
+ import { OnboardingHandlerType, DataBlockEvent } from '../types';
3
3
  import { LiveQueryData } from '../../sheet-engine/core';
4
+ import { OpenApiKeyModalFn } from './data-block-error-handler';
5
+ import { ApiKeyStorage } from './api-key-storage';
4
6
 
7
+ import * as Y from 'yjs';
5
8
  export type SmartContractResponse = {
6
9
  callSignature: unknown[];
7
10
  };
@@ -22,15 +25,18 @@ interface AfterUpdateCellParams {
22
25
  oldValue?: Cell;
23
26
  newValue: Cell;
24
27
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
28
+ handleContentPortal?: () => void;
29
+ dsheetId?: string;
30
+ ydocRef?: React.MutableRefObject<Y.Doc | null>;
25
31
  onboardingComplete: boolean | undefined;
26
- setFetchingURLData: (fetching: boolean) => void;
32
+ setFetchingURLData?: (fetching: boolean) => void;
27
33
  onboardingHandler: OnboardingHandlerType | undefined;
28
- dataBlockApiKeyHandler: DataBlockApiKeyHandlerType | undefined;
34
+ apiKeyStorage: ApiKeyStorage;
35
+ openApiKeyModal: OpenApiKeyModalFn;
36
+ onDataBlockEvent?: (event: DataBlockEvent) => void;
29
37
  handleSmartContractQuery?: SmartContractQueryHandler | undefined;
30
38
  handleLiveQueryData?: (subsheetIndex: number, queryData: LiveQueryData) => void;
31
- setInputFetchURLDataBlock: React.Dispatch<React.SetStateAction<string>> | undefined;
32
- storeApiKey?: (apiKeyName: string) => void;
33
- onDataBlockApiResponse?: (dataBlockName: string) => void;
39
+ setInputFetchURLDataBlock?: React.Dispatch<React.SetStateAction<string>> | undefined;
34
40
  setDataBlockCalcFunction?: React.Dispatch<React.SetStateAction<{
35
41
  [key: string]: {
36
42
  [key: string]: any;
@@ -54,7 +60,7 @@ export declare const shouldExecuteDataBlocks: (params: {
54
60
  localUserEditRef?: React.MutableRefObject<boolean>;
55
61
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
56
62
  }) => boolean;
57
- export declare const isDatablockError: (value: any) => boolean;
63
+ export { isDatablockError } from './datablock-error-utils';
58
64
  /**
59
65
  * Handles logic after a cell is updated, including processing formula results
60
66
  *
@@ -62,4 +68,3 @@ export declare const isDatablockError: (value: any) => boolean;
62
68
  * @returns Promise that resolves when processing is complete
63
69
  */
64
70
  export declare const afterUpdateCell: (params: AfterUpdateCellParams) => Promise<void>;
65
- export {};
@@ -0,0 +1,6 @@
1
+ export interface ApiKeyStorage {
2
+ get: (name: string) => string | null;
3
+ set: (name: string, key: string) => void;
4
+ remove?: (name: string) => void;
5
+ }
6
+ export declare const defaultApiKeyStorage: ApiKeyStorage;