@fileverse-dev/dsheet 1.3.7 → 1.3.8-export-fixes-2

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.
@@ -7,7 +7,7 @@ type SyncContext = {
7
7
  dsheetId: string;
8
8
  handleOnChangePortalUpdate: () => void;
9
9
  };
10
- export declare const syncCurrentSheetField: (context: SyncContext, field: "images" | "iframes" | "frozen" | "name" | "config" | "showGridLines") => void;
10
+ export declare const syncCurrentSheetField: (context: SyncContext, field: "images" | "iframes" | "frozen" | "name" | "config" | "showGridLines" | "color" | "hide") => void;
11
11
  export declare const createSheetLengthChangeHandler: ({ sheetEditorRef, ydocRef, dsheetId, currentDataRef, handleOnChangePortalUpdate, }: {
12
12
  sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
13
13
  ydocRef: React.MutableRefObject<Y.Doc | null>;
@@ -16,5 +16,8 @@ export declare const createSheetLengthChangeHandler: ({ sheetEditorRef, ydocRef,
16
16
  handleOnChangePortalUpdate: () => void;
17
17
  }) => () => void;
18
18
  export declare const createAfterOrderChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
19
+ export declare const createAfterColorChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
20
+ export declare const createAfterHideChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
19
21
  export declare const createAfterColRowChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
22
+ export declare const updateAllCell: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext, subSheetId: string) => void;
20
23
  export {};
@@ -2,8 +2,8 @@ import { ChangeEventHandler } from 'react';
2
2
 
3
3
  export declare const CustomButton: ({ setExportDropdownOpen, handleCSVUpload, handleXLSXUpload, handleExportToXLSX, handleExportToCSV, handleExportToJSON, }: {
4
4
  setExportDropdownOpen: React.Dispatch<React.SetStateAction<boolean>>;
5
- handleCSVUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, file: any, importType: string) => void;
6
- handleXLSXUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, file: any, importType: string) => void;
5
+ handleCSVUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, file: any, importType: string) => void | Promise<void>;
6
+ handleXLSXUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, file: any, importType: string) => void | Promise<void>;
7
7
  handleExportToXLSX: () => void;
8
8
  handleExportToCSV: () => void;
9
9
  handleExportToJSON: () => void;
@@ -5,6 +5,7 @@ import { DataBlockApiKeyHandlerType, SheetUpdateData } from '../types';
5
5
 
6
6
  import * as Y from 'yjs';
7
7
  export interface EditorContextType {
8
+ setIsDataLoaded: React.Dispatch<React.SetStateAction<boolean>>;
8
9
  handleOnChangePortalUpdate: () => void;
9
10
  setSelectedTemplate?: React.Dispatch<React.SetStateAction<string>>;
10
11
  setShowSmartContractModal?: React.Dispatch<React.SetStateAction<boolean>>;
@@ -20,6 +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
+ setIsDataLoaded: import('react').Dispatch<import('react').SetStateAction<boolean>>;
23
24
  handleChange: (_data: Sheet[]) => void;
24
25
  handleLiveQuery: (subsheetIndex: number, queryData: import('@fileverse-dev/fortune-core').LiveQueryData) => void;
25
26
  initialiseLiveQueryData: (sheets: Sheet[]) => void;
@@ -1,7 +1,8 @@
1
1
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
- export declare const usehandleHomepageRedirect: ({ setSelectedTemplate, handleXLSXUpload, handleCSVUpload, ydocRef, dsheetId, currentDataRef, setForceSheetRender, sheetEditorRef, updateDocumentTitle }: {
4
+ export declare const usehandleHomepageRedirect: ({ setIsDataLoaded, setSelectedTemplate, handleXLSXUpload, handleCSVUpload, ydocRef, dsheetId, currentDataRef, setForceSheetRender, sheetEditorRef, updateDocumentTitle, }: {
5
+ setIsDataLoaded: React.Dispatch<React.SetStateAction<boolean>>;
5
6
  setSelectedTemplate?: React.Dispatch<React.SetStateAction<string>>;
6
7
  handleXLSXUpload: any;
7
8
  handleCSVUpload: any;
@@ -1,4 +1,6 @@
1
+ import { default as React } from 'react';
1
2
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
3
+
2
4
  import * as Y from 'yjs';
3
5
  export declare const useXLSXImport: ({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, }: {
4
6
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -1,4 +1,4 @@
1
1
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
  import { MutableRefObject } from 'react';
3
3
  import * as Y from 'yjs';
4
- export declare const handleExportToCSV: (workbookRef: MutableRefObject<WorkbookInstance | null>, ydocRef: MutableRefObject<Y.Doc | null>) => void;
4
+ export declare const handleExportToCSV: (workbookRef: MutableRefObject<WorkbookInstance | null>, ydocRef: MutableRefObject<Y.Doc | null>, _dsheetId?: string, getDocumentTitle?: () => string) => 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, handleContentPortal?: any) => 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) => Promise<void>;
@@ -8,10 +8,10 @@ export declare const getCustomToolbarItems: ({ handleContentPortal, setShowSmart
8
8
  getDocumentTitle?: () => string;
9
9
  updateDocumentTitle?: (title: string) => void;
10
10
  setExportDropdownOpen: React.Dispatch<React.SetStateAction<boolean>>;
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;
12
- handleXLSXUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, 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 | Promise<void>;
12
+ handleXLSXUpload: (event: ChangeEventHandler<HTMLInputElement> | undefined, file?: File, importType?: string) => void | Promise<void>;
13
13
  handleExportToXLSX: (sheetEditorRef: React.RefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string, getDocumentTitle?: () => string) => void;
14
- handleExportToCSV: (sheetEditorRef: React.RefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string) => void;
14
+ handleExportToCSV: (sheetEditorRef: React.RefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string, getDocumentTitle?: () => string) => void;
15
15
  handleExportToJSON: (sheetEditorRef: React.RefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string) => void;
16
16
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
17
17
  ydocRef: React.RefObject<Y.Doc | null>;
@@ -0,0 +1,7 @@
1
+ export declare const sanitizeFilenameBase: (value: string) => string;
2
+ export declare const getExportFilenameBase: ({ getDocumentTitle, documentTitleFallback, sheetNameFallback, defaultBase, }: {
3
+ getDocumentTitle?: () => string;
4
+ documentTitleFallback?: string;
5
+ sheetNameFallback?: string;
6
+ defaultBase?: string;
7
+ }) => string;
@@ -0,0 +1,13 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ /**
5
+ * Sync `filter_select` for active sheet.
6
+ * Stored as a Y.Map for granular updates (keys: "row", "column").
7
+ */
8
+ export declare const filterSelectYdocUpdate: ({ 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 `filter` for active sheet.
6
+ * Stored as one object payload in Yjs (keys like "0", "1", "all" map to objects).
7
+ */
8
+ export declare const filterYdocUpdate: ({ 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,21 @@
1
+ export type BorderSide = {
2
+ style: number;
3
+ color?: string;
4
+ };
5
+ export declare const BORDER_STYLE_MAP: Record<number, string>;
6
+ /** Convert a fortune border side descriptor to an xlsx-js-style border entry. */
7
+ export declare const toBorderSide: (style: unknown, color: unknown) => {
8
+ style: string;
9
+ color: {
10
+ rgb: string;
11
+ };
12
+ } | undefined;
13
+ /**
14
+ * Reads `borderInfo` from a fortune sheet config and writes the corresponding
15
+ * border styles into the xlsx-js-style worksheet object.
16
+ *
17
+ * Handles two rangeTypes:
18
+ * - "cell" → per-cell border entries produced by luckyexcel on import
19
+ * - "range" → range border commands produced when the user draws borders in the UI
20
+ */
21
+ export declare const applyBordersToWorksheet: (worksheet: Record<string, unknown>, borderInfo: any[]) => void;
@@ -0,0 +1,47 @@
1
+ import { Worksheet } from 'exceljs';
2
+
3
+ type CellRange = {
4
+ row: [number, number];
5
+ column: [number, number];
6
+ [key: string]: unknown;
7
+ };
8
+ export type FortuneFormat = {
9
+ textColor?: string;
10
+ cellColor?: string;
11
+ bold?: boolean;
12
+ italic?: boolean;
13
+ underline?: boolean;
14
+ strikethrough?: boolean;
15
+ };
16
+ type FortuneRule = {
17
+ type: string;
18
+ cellrange: CellRange[];
19
+ format?: FortuneFormat;
20
+ conditionName: string;
21
+ conditionValue?: string[];
22
+ };
23
+ type Sheet = {
24
+ luckysheet_conditionformat_save?: FortuneRule[];
25
+ [key: string]: unknown;
26
+ };
27
+ export type PendingDuplicateRule = {
28
+ ref: string;
29
+ format: FortuneFormat;
30
+ priority: number;
31
+ };
32
+ export type CfExportResult = {
33
+ nextPriority: number;
34
+ pendingDuplicateValues: PendingDuplicateRule[];
35
+ };
36
+ /** Convert any CSS color string to an 8-char ARGB hex (e.g. "FFFF0000"). Returns null if unparseable. */
37
+ export declare function colorToArgb(color: string): string | null;
38
+ /**
39
+ * Writes all luckysheet_conditionformat_save rules from `sheet` into the
40
+ * ExcelJS worksheet.
41
+ *
42
+ * Returns the next available priority integer and any `duplicateValue` rules
43
+ * that ExcelJS cannot render — those must be injected later via
44
+ * `patchXlsxCf` in the post-processing step.
45
+ */
46
+ export declare function exportConditionalFormatting(ws: Worksheet, sheet: Sheet, startPriority: number): CfExportResult;
47
+ export {};
@@ -0,0 +1,14 @@
1
+ import { PendingDuplicateRule } from './xlsx-cf-export-utils';
2
+
3
+ export type SheetCfPatch = {
4
+ duplicateValues: PendingDuplicateRule[];
5
+ };
6
+ /**
7
+ * Post-process an XLSX buffer produced by ExcelJS to fix conditional
8
+ * formatting issues that ExcelJS cannot handle natively:
9
+ *
10
+ * 1. Adds the `text` attribute to `containsText` cfRules (ExcelJS omits it).
11
+ * 2. Injects `duplicateValues` cfRules that ExcelJS's renderer skips entirely,
12
+ * including their dxf style entries in xl/styles.xml.
13
+ */
14
+ export declare function patchXlsxCf(buffer: ArrayBuffer | Buffer, sheetPatches: SheetCfPatch[]): Promise<ArrayBuffer>;
@@ -1,4 +1,4 @@
1
1
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
  import { MutableRefObject } from 'react';
3
- import * as Y from "yjs";
3
+ import * as Y from 'yjs';
4
4
  export declare const handleExportToXLSX: (workbookRef: MutableRefObject<WorkbookInstance | null>, ydocRef: MutableRefObject<Y.Doc | null>, dsheetId: string, getDocumentTitle?: () => string) => Promise<void>;
@@ -0,0 +1,38 @@
1
+ import { Workbook, Worksheet } from 'exceljs';
2
+ import { Sheet } from '@fileverse-dev/fortune-react';
3
+
4
+ export interface RawSheetImage {
5
+ src: string;
6
+ nativeCol: number;
7
+ nativeColOff: number;
8
+ nativeRow: number;
9
+ nativeRowOff: number;
10
+ width: number;
11
+ height: number;
12
+ brNativeCol?: number;
13
+ brNativeColOff?: number;
14
+ brNativeRow?: number;
15
+ brNativeRowOff?: number;
16
+ }
17
+ export declare function extractImagesFromWorksheet(ws: Worksheet, workbook: Workbook): RawSheetImage[];
18
+ /**
19
+ * Embed Fortune sheet images into an ExcelJS worksheet.
20
+ * This is the inverse of convertRawImagesToFortuneSheet: converts pixel-based
21
+ * Image objects back to ExcelJS native cell + EMU positioning.
22
+ */
23
+ export declare function addFortuneImagesToWorksheet(ws: Worksheet, workbook: Workbook, images: {
24
+ id: string;
25
+ src: string;
26
+ left: number;
27
+ top: number;
28
+ width: number;
29
+ height: number;
30
+ }[], sheet: Sheet, defaultColPx: number, defaultRowPx: number): void;
31
+ export declare function convertRawImagesToFortuneSheet(rawImages: RawSheetImage[], sheet: Sheet, defaultColPx: number, defaultRowPx: number): {
32
+ id: string;
33
+ src: string;
34
+ left: number;
35
+ top: number;
36
+ width: number;
37
+ height: number;
38
+ }[];
@@ -0,0 +1,16 @@
1
+ import { Worksheet, RichText } from 'exceljs';
2
+
3
+ export type CellRichTextValue = {
4
+ richText: RichText[];
5
+ };
6
+ /**
7
+ * Convert a Fortune/Luckysheet `ct.s` rich text array into an ExcelJS
8
+ * CellRichTextValue. Returns null if there are no non-empty runs.
9
+ */
10
+ export declare function buildExcelJsRichText(ctS: any[]): CellRichTextValue | null;
11
+ /**
12
+ * Apply rich text values collected during Pass 1 to an ExcelJS worksheet.
13
+ * Cell-level styles (fill, borders, alignment) from xlsx-js-style are preserved
14
+ * because ExcelJS stores value and style independently.
15
+ */
16
+ export declare function applyRichTextToWorksheet(ws: Worksheet, richTextMap: Map<string, CellRichTextValue>): void;