@canvas-components/react-xlsx-table 0.0.0-stage → 0.1.3

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,305 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties, ForwardedRef } from 'react';
3
+ import { XlsxCellStyle, XlsxCellType, XlsxTableExportFormat, XlsxCellBorderPreset, XlsxCellBorderLine, XlsxTableOptions, XlsxSelectionState, XlsxWorkbook, XlsxTableExportOptions, XlsxFormulaDependencyDebugSnapshot, XlsxNamedRange, XlsxFormulaBarState, CreateSheetOptions, DuplicateSheetOptions, XlsxRemoteSelection, XlsxFrozenPane, XlsxSortDirection, XlsxHeaderActionType, XlsxFilterOptionItem, XlsxFilterValue, XlsxFilterOptionValue, XlsxFilterCondition, XlsxFilterConditionRelation, XlsxEditorRequest, XlsxContextMenuRequest, XlsxSheet } from '@canvas-components/xlsx-table';
4
+ export { CreateSheetOptions, XlsxCell, XlsxCellAddress, XlsxCellRange, XlsxEditorRequest, XlsxFormulaBarState, XlsxFormulaDependencyDebugSnapshot, XlsxNamedRange, XlsxRemoteSelection, XlsxSelectionState, XlsxSheet, XlsxTableExportFormat, XlsxTableExportOptions, XlsxTableOptions, XlsxTableTheme, XlsxWorkbook } from '@canvas-components/xlsx-table';
5
+
6
+ type XlsxToolbarIconName = "menu" | "undo" | "redo" | "paint-format" | "clear-format" | "insert" | "font-family" | "font-size" | "bold" | "italic" | "underline" | "strikethrough" | "text-color" | "fill-color" | "border" | "vertical-align" | "vertical-align-top" | "vertical-align-bottom" | "align-left" | "align-center" | "align-right" | "merge-cells" | "number-format" | "currency" | "percent" | "decrease-decimal" | "increase-decimal" | "freeze" | "filter" | "sort" | "conditional-format" | "data-validation" | "formula" | "multidimensional-table" | "find-replace" | "comment" | "ai-formula" | "chevron-down" | "more";
7
+ declare function XlsxToolbarIcon(props: {
8
+ name: XlsxToolbarIconName;
9
+ size?: number;
10
+ }): react.JSX.Element | null;
11
+
12
+ type XlsxToolbarCommand = "menu" | "undo" | "redo" | "paint-format" | "clear-format" | "insert" | "font-family" | "font-size" | "bold" | "italic" | "underline" | "strikethrough" | "text-color" | "fill-color" | "border" | "vertical-align" | "align-left" | "align-center" | "align-right" | "merge-cells" | "number-format" | "currency" | "percent" | "decrease-decimal" | "increase-decimal" | "freeze" | "filter" | "sort" | "conditional-format" | "data-validation" | "formula" | "multidimensional-table" | "find-replace" | "comment" | "ai-formula";
13
+ type XlsxToolbarDensity = "compact" | "comfortable";
14
+ interface XlsxToolbarOptions {
15
+ /** 工具栏密度。@default "comfortable" */
16
+ density?: XlsxToolbarDensity;
17
+ /** 隐藏指定命令。 */
18
+ hiddenCommands?: XlsxToolbarCommand[];
19
+ /** 强制禁用指定命令。 */
20
+ disabledCommands?: XlsxToolbarCommand[];
21
+ /** 启用由 `onToolbarCommand` 承接的扩展命令。 */
22
+ enabledCommands?: XlsxToolbarCommand[];
23
+ }
24
+
25
+ interface XlsxToolbarHistoryState {
26
+ canUndo: boolean;
27
+ canRedo: boolean;
28
+ }
29
+ type XlsxToolbarNumberFormat = "normal" | "number" | "money" | "percent";
30
+ interface XlsxToolbarState {
31
+ style?: Partial<XlsxCellStyle>;
32
+ cellType?: XlsxCellType;
33
+ canPaintFormat?: boolean;
34
+ paintFormatActive?: boolean;
35
+ frozen?: boolean;
36
+ freezeTarget?: "row" | "column";
37
+ filtered?: boolean;
38
+ sorted?: boolean;
39
+ merged?: boolean;
40
+ canMerge?: boolean;
41
+ }
42
+ interface XlsxToolbarProps {
43
+ historyState: XlsxToolbarHistoryState;
44
+ state?: XlsxToolbarState;
45
+ readonly?: boolean;
46
+ options?: XlsxToolbarOptions;
47
+ onUndo: () => void;
48
+ onRedo: () => void;
49
+ onCreateSheet?: () => void;
50
+ onDuplicateSheet?: () => void;
51
+ onExport?: (format: XlsxTableExportFormat) => void;
52
+ onApplyStyle?: (style: Partial<XlsxCellStyle>) => void;
53
+ onApplyBorder?: (preset: XlsxCellBorderPreset, line: XlsxCellBorderLine) => void;
54
+ onMergeCells?: () => void;
55
+ onUnmergeCells?: () => void;
56
+ onPaintFormat?: () => void;
57
+ onToggleStyle?: (activeStyle: Partial<XlsxCellStyle>, inactiveStyle: Partial<XlsxCellStyle>) => void;
58
+ onClearStyle?: () => void;
59
+ onClearStyleKeys?: (keys: Array<keyof XlsxCellStyle>) => void;
60
+ onClearValues?: () => void;
61
+ onSetCellType?: (type: XlsxCellType | undefined) => void;
62
+ onInsertFormula?: (template: string) => void;
63
+ onFreeze?: (target: "row" | "column") => void;
64
+ onClearFreeze?: () => void;
65
+ onInsertRows?: (placement: "above" | "below") => void;
66
+ onInsertColumns?: (placement: "left" | "right") => void;
67
+ onDeleteRows?: () => void;
68
+ onDeleteColumns?: () => void;
69
+ onFilter?: () => void;
70
+ onSort?: () => void;
71
+ onCommand?: (command: XlsxToolbarCommand) => void;
72
+ style?: CSSProperties;
73
+ }
74
+ /**
75
+ * 在线表格顶部命令工具栏。
76
+ */
77
+ declare function XlsxToolbar(props: XlsxToolbarProps): react.JSX.Element;
78
+
79
+ interface ReactXlsxTableProps extends XlsxTableOptions {
80
+ className?: string;
81
+ style?: CSSProperties;
82
+ /** 是否显示公式栏。@default true */
83
+ showFormulaBar?: boolean;
84
+ /** 是否显示顶部工具栏。@default true */
85
+ showToolbar?: boolean;
86
+ /** 顶部工具栏配置。传 false 时隐藏工具栏。 */
87
+ toolbar?: false | XlsxToolbarOptions;
88
+ /** 是否启用公式栏自动补全。@default true */
89
+ showFormulaAutocomplete?: boolean;
90
+ /** 是否显示 sheet 标签栏。@default true */
91
+ showSheetTabs?: boolean;
92
+ /** sheet 标签栏位置。@default "top" */
93
+ sheetTabsPlacement?: "top" | "bottom" | "hidden";
94
+ /** 是否显示命名区域管理器。@default false */
95
+ showNamedRangeManager?: boolean;
96
+ /** 是否显示公式依赖图调试面板。仅建议开发环境开启。@default false */
97
+ showFormulaDependencyDebugger?: boolean;
98
+ /** 顶部工具栏未内置命令的旁路回调。 */
99
+ onToolbarCommand?: (command: XlsxToolbarCommand) => void;
100
+ }
101
+ interface ReactXlsxTableRef {
102
+ getSelection: () => XlsxSelectionState;
103
+ getWorkbook: () => XlsxWorkbook;
104
+ exportActiveSheet: (format: XlsxTableExportFormat, options?: XlsxTableExportOptions) => Promise<boolean>;
105
+ getFormulaDependencyDebugSnapshot: () => XlsxFormulaDependencyDebugSnapshot;
106
+ getNamedRanges: () => XlsxNamedRange[];
107
+ upsertNamedRange: (named: XlsxNamedRange) => boolean;
108
+ removeNamedRange: (name: string) => boolean;
109
+ getFormulaBarState: () => XlsxFormulaBarState;
110
+ getActiveSheetId: () => string | null;
111
+ setActiveSheet: (sheetId: string) => boolean;
112
+ addSheet: (options?: CreateSheetOptions & {
113
+ activate?: boolean;
114
+ }) => string | null;
115
+ duplicateSheet: (sheetId: string, options?: DuplicateSheetOptions) => string | null;
116
+ moveSheet: (sheetId: string, targetIndex: number) => boolean;
117
+ renameSheet: (sheetId: string, name: string) => boolean;
118
+ removeSheet: (sheetId: string) => boolean;
119
+ startEditing: (mode?: "edit" | "replace", initialText?: string) => boolean;
120
+ commitFormulaBarText: (text: string) => boolean;
121
+ undo: () => boolean;
122
+ redo: () => boolean;
123
+ getHistoryState: () => {
124
+ canUndo: boolean;
125
+ canRedo: boolean;
126
+ undoCount: number;
127
+ redoCount: number;
128
+ };
129
+ getRemoteSelections: () => XlsxRemoteSelection[];
130
+ getPresenceRecord: () => Record<string, XlsxRemoteSelection>;
131
+ acknowledgePatches: (patchIds: string[]) => void;
132
+ hideRows: (rowIndexes: number[]) => boolean;
133
+ showRows: (rowIndexes: number[]) => boolean;
134
+ hideColumns: (columnIndexes: number[]) => boolean;
135
+ showColumns: (columnIndexes: number[]) => boolean;
136
+ clearSelectionValues: () => boolean;
137
+ mergeSelectionCells: () => boolean;
138
+ unmergeSelectionCells: () => boolean;
139
+ setSelectionCellStyle: (stylePatch: Partial<XlsxCellStyle>) => boolean;
140
+ setSelectionCellBorder: (preset: XlsxCellBorderPreset, line: XlsxCellBorderLine) => boolean;
141
+ toggleSelectionCellStyle: (activeStyle: Partial<XlsxCellStyle>, inactiveStyle: Partial<XlsxCellStyle>) => boolean;
142
+ clearSelectionCellStyle: () => boolean;
143
+ clearSelectionCellStyleKeys: (keys: Array<keyof XlsxCellStyle>) => boolean;
144
+ setSelectionCellType: (type: XlsxCellType | undefined) => boolean;
145
+ setFrozenPane: (frozen: XlsxFrozenPane | null) => boolean;
146
+ freezeToSelection: () => boolean;
147
+ clearFreeze: () => boolean;
148
+ insertFormulaTemplate: (template: string) => boolean;
149
+ insertRows: (rowIndex: number, count?: number) => boolean;
150
+ insertColumns: (columnIndex: number, count?: number) => boolean;
151
+ deleteRows: (rowIndex: number, count?: number) => boolean;
152
+ deleteColumns: (columnIndex: number, count?: number) => boolean;
153
+ sortByColumn: (columnIndex: number, direction: XlsxSortDirection) => boolean;
154
+ clearSort: () => boolean;
155
+ setHeaderActionHint: (columnIndex: number, actionType: XlsxHeaderActionType) => boolean;
156
+ getColumnFilterOptions: (columnIndex: number) => XlsxFilterOptionItem[];
157
+ setColumnFilterValues: (columnIndex: number, values: XlsxFilterValue[]) => boolean;
158
+ setColumnFilterOptionValues: (columnIndex: number, values: XlsxFilterOptionValue[]) => boolean;
159
+ setColumnFilterCondition: (params: {
160
+ columnIndex: number;
161
+ condition: XlsxFilterCondition;
162
+ secondCondition?: XlsxFilterCondition;
163
+ relation?: XlsxFilterConditionRelation;
164
+ }) => boolean;
165
+ clearColumnFilter: (columnIndex: number) => boolean;
166
+ clearFilters: () => boolean;
167
+ }
168
+ declare function ReactXlsxTableInner(props: ReactXlsxTableProps, ref: ForwardedRef<ReactXlsxTableRef>): react.JSX.Element;
169
+ /**
170
+ * XlsxTable 的 React 宿主组件。
171
+ */
172
+ declare const ReactXlsxTable: <T = unknown>(props: ReactXlsxTableProps & {
173
+ ref?: ForwardedRef<ReactXlsxTableRef>;
174
+ }) => ReturnType<typeof ReactXlsxTableInner>;
175
+
176
+ /**
177
+ * xlsx-table 单元格编辑浮层。
178
+ */
179
+ declare function XlsxEditorOverlay(props: {
180
+ request: XlsxEditorRequest;
181
+ }): react.JSX.Element;
182
+
183
+ interface XlsxFormulaDependencyDebugPanelProps {
184
+ snapshot: XlsxFormulaDependencyDebugSnapshot;
185
+ }
186
+ /**
187
+ * 公式依赖图 dev-only 调试面板。
188
+ */
189
+ declare function XlsxFormulaDependencyDebugPanel({ snapshot, }: XlsxFormulaDependencyDebugPanelProps): react.JSX.Element;
190
+
191
+ /**
192
+ * 公式栏。
193
+ */
194
+ declare function XlsxFormulaBar(props: {
195
+ state: XlsxFormulaBarState;
196
+ onCommit: (text: string) => void;
197
+ workbook?: XlsxWorkbook;
198
+ autocomplete?: boolean;
199
+ rowHeaderWidth?: number;
200
+ style?: CSSProperties;
201
+ }): react.JSX.Element;
202
+
203
+ type XlsxContextMenuItemKind = "item" | "separator" | "label";
204
+ interface XlsxContextMenuItem {
205
+ key: string;
206
+ kind: XlsxContextMenuItemKind;
207
+ label?: string;
208
+ disabled?: boolean;
209
+ danger?: boolean;
210
+ onSelect?: () => void;
211
+ }
212
+ interface XlsxContextMenuActions {
213
+ openFilterPanel: (columnIndex: number, anchorRect: XlsxContextMenuAnchorRect) => void;
214
+ hideRows: (rowIndexes: number[]) => void;
215
+ showRows: (rowIndexes: number[]) => void;
216
+ hideColumns: (columnIndexes: number[]) => void;
217
+ showColumns: (columnIndexes: number[]) => void;
218
+ insertRows: (rowIndex: number, count?: number) => void;
219
+ insertColumns: (columnIndex: number, count?: number) => void;
220
+ deleteRows: (rowIndex: number, count?: number) => void;
221
+ deleteColumns: (columnIndex: number, count?: number) => void;
222
+ sortByColumn: (columnIndex: number, direction: "asc" | "desc") => void;
223
+ clearSort: () => void;
224
+ setColumnFilterValues: (columnIndex: number, values: XlsxFilterValue[]) => void;
225
+ setColumnFilterOptionValues: (columnIndex: number, values: XlsxFilterOptionValue[]) => void;
226
+ setColumnFilterCondition: (params: {
227
+ columnIndex: number;
228
+ condition: XlsxFilterCondition;
229
+ secondCondition?: XlsxFilterCondition;
230
+ relation?: XlsxFilterConditionRelation;
231
+ }) => void;
232
+ clearColumnFilter: (columnIndex: number) => void;
233
+ clearFilters: () => void;
234
+ clearSelectionValues: () => void;
235
+ mergeCells: () => void;
236
+ unmergeCells: () => void;
237
+ freezeToSelection: () => void;
238
+ freezeRowsTo: (rowCount: number) => void;
239
+ freezeColumnsTo: (columnCount: number) => void;
240
+ clearFreeze: () => void;
241
+ }
242
+ interface XlsxContextMenuAnchorRect {
243
+ x: number;
244
+ y: number;
245
+ width: number;
246
+ height: number;
247
+ }
248
+ /**
249
+ * 构建 xlsx-table 右键菜单项。
250
+ */
251
+ declare function buildXlsxContextMenuItems(params: {
252
+ request: XlsxContextMenuRequest;
253
+ readonly?: boolean;
254
+ mergeState?: {
255
+ canMerge?: boolean;
256
+ merged?: boolean;
257
+ };
258
+ actions: XlsxContextMenuActions;
259
+ }): XlsxContextMenuItem[];
260
+
261
+ interface XlsxContextMenuProps {
262
+ request: XlsxContextMenuRequest | null;
263
+ workbook: XlsxWorkbook;
264
+ readonly?: boolean;
265
+ mergeState?: {
266
+ canMerge?: boolean;
267
+ merged?: boolean;
268
+ };
269
+ onClose: () => void;
270
+ actions: XlsxContextMenuActions;
271
+ }
272
+ /**
273
+ * xlsx-table 右键菜单。
274
+ */
275
+ declare function XlsxContextMenu({ request, workbook, readonly, mergeState, onClose, actions, }: XlsxContextMenuProps): react.JSX.Element | null;
276
+
277
+ interface XlsxNamedRangeManagerProps {
278
+ workbook: XlsxWorkbook;
279
+ readonly?: boolean;
280
+ onUpsert: (named: XlsxNamedRange) => boolean;
281
+ onRemove: (name: string) => boolean;
282
+ }
283
+ /**
284
+ * 轻量命名区域管理器。
285
+ */
286
+ declare function XlsxNamedRangeManager(props: XlsxNamedRangeManagerProps): react.JSX.Element;
287
+
288
+ /**
289
+ * Sheet 标签栏。
290
+ */
291
+ declare function XlsxSheetTabs(props: {
292
+ sheets: XlsxSheet[];
293
+ activeSheetId: string | null;
294
+ readonly?: boolean;
295
+ onActivate: (sheetId: string) => void;
296
+ onAdd?: () => void;
297
+ onDuplicate?: (sheetId: string) => void;
298
+ onMove?: (sheetId: string, targetIndex: number) => void;
299
+ onRename?: (sheetId: string, name: string) => void;
300
+ onRemove?: (sheetId: string) => void;
301
+ placement?: "top" | "bottom";
302
+ style?: CSSProperties;
303
+ }): react.JSX.Element;
304
+
305
+ export { ReactXlsxTable, type ReactXlsxTableProps, type ReactXlsxTableRef, XlsxContextMenu, type XlsxContextMenuActions, type XlsxContextMenuItem, type XlsxContextMenuItemKind, type XlsxContextMenuProps, XlsxEditorOverlay, XlsxFormulaBar, XlsxFormulaDependencyDebugPanel, type XlsxFormulaDependencyDebugPanelProps, XlsxNamedRangeManager, type XlsxNamedRangeManagerProps, XlsxSheetTabs, XlsxToolbar, type XlsxToolbarCommand, type XlsxToolbarHistoryState, XlsxToolbarIcon, type XlsxToolbarIconName, type XlsxToolbarNumberFormat, type XlsxToolbarOptions, type XlsxToolbarProps, type XlsxToolbarState, buildXlsxContextMenuItems };
@@ -0,0 +1,305 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties, ForwardedRef } from 'react';
3
+ import { XlsxCellStyle, XlsxCellType, XlsxTableExportFormat, XlsxCellBorderPreset, XlsxCellBorderLine, XlsxTableOptions, XlsxSelectionState, XlsxWorkbook, XlsxTableExportOptions, XlsxFormulaDependencyDebugSnapshot, XlsxNamedRange, XlsxFormulaBarState, CreateSheetOptions, DuplicateSheetOptions, XlsxRemoteSelection, XlsxFrozenPane, XlsxSortDirection, XlsxHeaderActionType, XlsxFilterOptionItem, XlsxFilterValue, XlsxFilterOptionValue, XlsxFilterCondition, XlsxFilterConditionRelation, XlsxEditorRequest, XlsxContextMenuRequest, XlsxSheet } from '@canvas-components/xlsx-table';
4
+ export { CreateSheetOptions, XlsxCell, XlsxCellAddress, XlsxCellRange, XlsxEditorRequest, XlsxFormulaBarState, XlsxFormulaDependencyDebugSnapshot, XlsxNamedRange, XlsxRemoteSelection, XlsxSelectionState, XlsxSheet, XlsxTableExportFormat, XlsxTableExportOptions, XlsxTableOptions, XlsxTableTheme, XlsxWorkbook } from '@canvas-components/xlsx-table';
5
+
6
+ type XlsxToolbarIconName = "menu" | "undo" | "redo" | "paint-format" | "clear-format" | "insert" | "font-family" | "font-size" | "bold" | "italic" | "underline" | "strikethrough" | "text-color" | "fill-color" | "border" | "vertical-align" | "vertical-align-top" | "vertical-align-bottom" | "align-left" | "align-center" | "align-right" | "merge-cells" | "number-format" | "currency" | "percent" | "decrease-decimal" | "increase-decimal" | "freeze" | "filter" | "sort" | "conditional-format" | "data-validation" | "formula" | "multidimensional-table" | "find-replace" | "comment" | "ai-formula" | "chevron-down" | "more";
7
+ declare function XlsxToolbarIcon(props: {
8
+ name: XlsxToolbarIconName;
9
+ size?: number;
10
+ }): react.JSX.Element | null;
11
+
12
+ type XlsxToolbarCommand = "menu" | "undo" | "redo" | "paint-format" | "clear-format" | "insert" | "font-family" | "font-size" | "bold" | "italic" | "underline" | "strikethrough" | "text-color" | "fill-color" | "border" | "vertical-align" | "align-left" | "align-center" | "align-right" | "merge-cells" | "number-format" | "currency" | "percent" | "decrease-decimal" | "increase-decimal" | "freeze" | "filter" | "sort" | "conditional-format" | "data-validation" | "formula" | "multidimensional-table" | "find-replace" | "comment" | "ai-formula";
13
+ type XlsxToolbarDensity = "compact" | "comfortable";
14
+ interface XlsxToolbarOptions {
15
+ /** 工具栏密度。@default "comfortable" */
16
+ density?: XlsxToolbarDensity;
17
+ /** 隐藏指定命令。 */
18
+ hiddenCommands?: XlsxToolbarCommand[];
19
+ /** 强制禁用指定命令。 */
20
+ disabledCommands?: XlsxToolbarCommand[];
21
+ /** 启用由 `onToolbarCommand` 承接的扩展命令。 */
22
+ enabledCommands?: XlsxToolbarCommand[];
23
+ }
24
+
25
+ interface XlsxToolbarHistoryState {
26
+ canUndo: boolean;
27
+ canRedo: boolean;
28
+ }
29
+ type XlsxToolbarNumberFormat = "normal" | "number" | "money" | "percent";
30
+ interface XlsxToolbarState {
31
+ style?: Partial<XlsxCellStyle>;
32
+ cellType?: XlsxCellType;
33
+ canPaintFormat?: boolean;
34
+ paintFormatActive?: boolean;
35
+ frozen?: boolean;
36
+ freezeTarget?: "row" | "column";
37
+ filtered?: boolean;
38
+ sorted?: boolean;
39
+ merged?: boolean;
40
+ canMerge?: boolean;
41
+ }
42
+ interface XlsxToolbarProps {
43
+ historyState: XlsxToolbarHistoryState;
44
+ state?: XlsxToolbarState;
45
+ readonly?: boolean;
46
+ options?: XlsxToolbarOptions;
47
+ onUndo: () => void;
48
+ onRedo: () => void;
49
+ onCreateSheet?: () => void;
50
+ onDuplicateSheet?: () => void;
51
+ onExport?: (format: XlsxTableExportFormat) => void;
52
+ onApplyStyle?: (style: Partial<XlsxCellStyle>) => void;
53
+ onApplyBorder?: (preset: XlsxCellBorderPreset, line: XlsxCellBorderLine) => void;
54
+ onMergeCells?: () => void;
55
+ onUnmergeCells?: () => void;
56
+ onPaintFormat?: () => void;
57
+ onToggleStyle?: (activeStyle: Partial<XlsxCellStyle>, inactiveStyle: Partial<XlsxCellStyle>) => void;
58
+ onClearStyle?: () => void;
59
+ onClearStyleKeys?: (keys: Array<keyof XlsxCellStyle>) => void;
60
+ onClearValues?: () => void;
61
+ onSetCellType?: (type: XlsxCellType | undefined) => void;
62
+ onInsertFormula?: (template: string) => void;
63
+ onFreeze?: (target: "row" | "column") => void;
64
+ onClearFreeze?: () => void;
65
+ onInsertRows?: (placement: "above" | "below") => void;
66
+ onInsertColumns?: (placement: "left" | "right") => void;
67
+ onDeleteRows?: () => void;
68
+ onDeleteColumns?: () => void;
69
+ onFilter?: () => void;
70
+ onSort?: () => void;
71
+ onCommand?: (command: XlsxToolbarCommand) => void;
72
+ style?: CSSProperties;
73
+ }
74
+ /**
75
+ * 在线表格顶部命令工具栏。
76
+ */
77
+ declare function XlsxToolbar(props: XlsxToolbarProps): react.JSX.Element;
78
+
79
+ interface ReactXlsxTableProps extends XlsxTableOptions {
80
+ className?: string;
81
+ style?: CSSProperties;
82
+ /** 是否显示公式栏。@default true */
83
+ showFormulaBar?: boolean;
84
+ /** 是否显示顶部工具栏。@default true */
85
+ showToolbar?: boolean;
86
+ /** 顶部工具栏配置。传 false 时隐藏工具栏。 */
87
+ toolbar?: false | XlsxToolbarOptions;
88
+ /** 是否启用公式栏自动补全。@default true */
89
+ showFormulaAutocomplete?: boolean;
90
+ /** 是否显示 sheet 标签栏。@default true */
91
+ showSheetTabs?: boolean;
92
+ /** sheet 标签栏位置。@default "top" */
93
+ sheetTabsPlacement?: "top" | "bottom" | "hidden";
94
+ /** 是否显示命名区域管理器。@default false */
95
+ showNamedRangeManager?: boolean;
96
+ /** 是否显示公式依赖图调试面板。仅建议开发环境开启。@default false */
97
+ showFormulaDependencyDebugger?: boolean;
98
+ /** 顶部工具栏未内置命令的旁路回调。 */
99
+ onToolbarCommand?: (command: XlsxToolbarCommand) => void;
100
+ }
101
+ interface ReactXlsxTableRef {
102
+ getSelection: () => XlsxSelectionState;
103
+ getWorkbook: () => XlsxWorkbook;
104
+ exportActiveSheet: (format: XlsxTableExportFormat, options?: XlsxTableExportOptions) => Promise<boolean>;
105
+ getFormulaDependencyDebugSnapshot: () => XlsxFormulaDependencyDebugSnapshot;
106
+ getNamedRanges: () => XlsxNamedRange[];
107
+ upsertNamedRange: (named: XlsxNamedRange) => boolean;
108
+ removeNamedRange: (name: string) => boolean;
109
+ getFormulaBarState: () => XlsxFormulaBarState;
110
+ getActiveSheetId: () => string | null;
111
+ setActiveSheet: (sheetId: string) => boolean;
112
+ addSheet: (options?: CreateSheetOptions & {
113
+ activate?: boolean;
114
+ }) => string | null;
115
+ duplicateSheet: (sheetId: string, options?: DuplicateSheetOptions) => string | null;
116
+ moveSheet: (sheetId: string, targetIndex: number) => boolean;
117
+ renameSheet: (sheetId: string, name: string) => boolean;
118
+ removeSheet: (sheetId: string) => boolean;
119
+ startEditing: (mode?: "edit" | "replace", initialText?: string) => boolean;
120
+ commitFormulaBarText: (text: string) => boolean;
121
+ undo: () => boolean;
122
+ redo: () => boolean;
123
+ getHistoryState: () => {
124
+ canUndo: boolean;
125
+ canRedo: boolean;
126
+ undoCount: number;
127
+ redoCount: number;
128
+ };
129
+ getRemoteSelections: () => XlsxRemoteSelection[];
130
+ getPresenceRecord: () => Record<string, XlsxRemoteSelection>;
131
+ acknowledgePatches: (patchIds: string[]) => void;
132
+ hideRows: (rowIndexes: number[]) => boolean;
133
+ showRows: (rowIndexes: number[]) => boolean;
134
+ hideColumns: (columnIndexes: number[]) => boolean;
135
+ showColumns: (columnIndexes: number[]) => boolean;
136
+ clearSelectionValues: () => boolean;
137
+ mergeSelectionCells: () => boolean;
138
+ unmergeSelectionCells: () => boolean;
139
+ setSelectionCellStyle: (stylePatch: Partial<XlsxCellStyle>) => boolean;
140
+ setSelectionCellBorder: (preset: XlsxCellBorderPreset, line: XlsxCellBorderLine) => boolean;
141
+ toggleSelectionCellStyle: (activeStyle: Partial<XlsxCellStyle>, inactiveStyle: Partial<XlsxCellStyle>) => boolean;
142
+ clearSelectionCellStyle: () => boolean;
143
+ clearSelectionCellStyleKeys: (keys: Array<keyof XlsxCellStyle>) => boolean;
144
+ setSelectionCellType: (type: XlsxCellType | undefined) => boolean;
145
+ setFrozenPane: (frozen: XlsxFrozenPane | null) => boolean;
146
+ freezeToSelection: () => boolean;
147
+ clearFreeze: () => boolean;
148
+ insertFormulaTemplate: (template: string) => boolean;
149
+ insertRows: (rowIndex: number, count?: number) => boolean;
150
+ insertColumns: (columnIndex: number, count?: number) => boolean;
151
+ deleteRows: (rowIndex: number, count?: number) => boolean;
152
+ deleteColumns: (columnIndex: number, count?: number) => boolean;
153
+ sortByColumn: (columnIndex: number, direction: XlsxSortDirection) => boolean;
154
+ clearSort: () => boolean;
155
+ setHeaderActionHint: (columnIndex: number, actionType: XlsxHeaderActionType) => boolean;
156
+ getColumnFilterOptions: (columnIndex: number) => XlsxFilterOptionItem[];
157
+ setColumnFilterValues: (columnIndex: number, values: XlsxFilterValue[]) => boolean;
158
+ setColumnFilterOptionValues: (columnIndex: number, values: XlsxFilterOptionValue[]) => boolean;
159
+ setColumnFilterCondition: (params: {
160
+ columnIndex: number;
161
+ condition: XlsxFilterCondition;
162
+ secondCondition?: XlsxFilterCondition;
163
+ relation?: XlsxFilterConditionRelation;
164
+ }) => boolean;
165
+ clearColumnFilter: (columnIndex: number) => boolean;
166
+ clearFilters: () => boolean;
167
+ }
168
+ declare function ReactXlsxTableInner(props: ReactXlsxTableProps, ref: ForwardedRef<ReactXlsxTableRef>): react.JSX.Element;
169
+ /**
170
+ * XlsxTable 的 React 宿主组件。
171
+ */
172
+ declare const ReactXlsxTable: <T = unknown>(props: ReactXlsxTableProps & {
173
+ ref?: ForwardedRef<ReactXlsxTableRef>;
174
+ }) => ReturnType<typeof ReactXlsxTableInner>;
175
+
176
+ /**
177
+ * xlsx-table 单元格编辑浮层。
178
+ */
179
+ declare function XlsxEditorOverlay(props: {
180
+ request: XlsxEditorRequest;
181
+ }): react.JSX.Element;
182
+
183
+ interface XlsxFormulaDependencyDebugPanelProps {
184
+ snapshot: XlsxFormulaDependencyDebugSnapshot;
185
+ }
186
+ /**
187
+ * 公式依赖图 dev-only 调试面板。
188
+ */
189
+ declare function XlsxFormulaDependencyDebugPanel({ snapshot, }: XlsxFormulaDependencyDebugPanelProps): react.JSX.Element;
190
+
191
+ /**
192
+ * 公式栏。
193
+ */
194
+ declare function XlsxFormulaBar(props: {
195
+ state: XlsxFormulaBarState;
196
+ onCommit: (text: string) => void;
197
+ workbook?: XlsxWorkbook;
198
+ autocomplete?: boolean;
199
+ rowHeaderWidth?: number;
200
+ style?: CSSProperties;
201
+ }): react.JSX.Element;
202
+
203
+ type XlsxContextMenuItemKind = "item" | "separator" | "label";
204
+ interface XlsxContextMenuItem {
205
+ key: string;
206
+ kind: XlsxContextMenuItemKind;
207
+ label?: string;
208
+ disabled?: boolean;
209
+ danger?: boolean;
210
+ onSelect?: () => void;
211
+ }
212
+ interface XlsxContextMenuActions {
213
+ openFilterPanel: (columnIndex: number, anchorRect: XlsxContextMenuAnchorRect) => void;
214
+ hideRows: (rowIndexes: number[]) => void;
215
+ showRows: (rowIndexes: number[]) => void;
216
+ hideColumns: (columnIndexes: number[]) => void;
217
+ showColumns: (columnIndexes: number[]) => void;
218
+ insertRows: (rowIndex: number, count?: number) => void;
219
+ insertColumns: (columnIndex: number, count?: number) => void;
220
+ deleteRows: (rowIndex: number, count?: number) => void;
221
+ deleteColumns: (columnIndex: number, count?: number) => void;
222
+ sortByColumn: (columnIndex: number, direction: "asc" | "desc") => void;
223
+ clearSort: () => void;
224
+ setColumnFilterValues: (columnIndex: number, values: XlsxFilterValue[]) => void;
225
+ setColumnFilterOptionValues: (columnIndex: number, values: XlsxFilterOptionValue[]) => void;
226
+ setColumnFilterCondition: (params: {
227
+ columnIndex: number;
228
+ condition: XlsxFilterCondition;
229
+ secondCondition?: XlsxFilterCondition;
230
+ relation?: XlsxFilterConditionRelation;
231
+ }) => void;
232
+ clearColumnFilter: (columnIndex: number) => void;
233
+ clearFilters: () => void;
234
+ clearSelectionValues: () => void;
235
+ mergeCells: () => void;
236
+ unmergeCells: () => void;
237
+ freezeToSelection: () => void;
238
+ freezeRowsTo: (rowCount: number) => void;
239
+ freezeColumnsTo: (columnCount: number) => void;
240
+ clearFreeze: () => void;
241
+ }
242
+ interface XlsxContextMenuAnchorRect {
243
+ x: number;
244
+ y: number;
245
+ width: number;
246
+ height: number;
247
+ }
248
+ /**
249
+ * 构建 xlsx-table 右键菜单项。
250
+ */
251
+ declare function buildXlsxContextMenuItems(params: {
252
+ request: XlsxContextMenuRequest;
253
+ readonly?: boolean;
254
+ mergeState?: {
255
+ canMerge?: boolean;
256
+ merged?: boolean;
257
+ };
258
+ actions: XlsxContextMenuActions;
259
+ }): XlsxContextMenuItem[];
260
+
261
+ interface XlsxContextMenuProps {
262
+ request: XlsxContextMenuRequest | null;
263
+ workbook: XlsxWorkbook;
264
+ readonly?: boolean;
265
+ mergeState?: {
266
+ canMerge?: boolean;
267
+ merged?: boolean;
268
+ };
269
+ onClose: () => void;
270
+ actions: XlsxContextMenuActions;
271
+ }
272
+ /**
273
+ * xlsx-table 右键菜单。
274
+ */
275
+ declare function XlsxContextMenu({ request, workbook, readonly, mergeState, onClose, actions, }: XlsxContextMenuProps): react.JSX.Element | null;
276
+
277
+ interface XlsxNamedRangeManagerProps {
278
+ workbook: XlsxWorkbook;
279
+ readonly?: boolean;
280
+ onUpsert: (named: XlsxNamedRange) => boolean;
281
+ onRemove: (name: string) => boolean;
282
+ }
283
+ /**
284
+ * 轻量命名区域管理器。
285
+ */
286
+ declare function XlsxNamedRangeManager(props: XlsxNamedRangeManagerProps): react.JSX.Element;
287
+
288
+ /**
289
+ * Sheet 标签栏。
290
+ */
291
+ declare function XlsxSheetTabs(props: {
292
+ sheets: XlsxSheet[];
293
+ activeSheetId: string | null;
294
+ readonly?: boolean;
295
+ onActivate: (sheetId: string) => void;
296
+ onAdd?: () => void;
297
+ onDuplicate?: (sheetId: string) => void;
298
+ onMove?: (sheetId: string, targetIndex: number) => void;
299
+ onRename?: (sheetId: string, name: string) => void;
300
+ onRemove?: (sheetId: string) => void;
301
+ placement?: "top" | "bottom";
302
+ style?: CSSProperties;
303
+ }): react.JSX.Element;
304
+
305
+ export { ReactXlsxTable, type ReactXlsxTableProps, type ReactXlsxTableRef, XlsxContextMenu, type XlsxContextMenuActions, type XlsxContextMenuItem, type XlsxContextMenuItemKind, type XlsxContextMenuProps, XlsxEditorOverlay, XlsxFormulaBar, XlsxFormulaDependencyDebugPanel, type XlsxFormulaDependencyDebugPanelProps, XlsxNamedRangeManager, type XlsxNamedRangeManagerProps, XlsxSheetTabs, XlsxToolbar, type XlsxToolbarCommand, type XlsxToolbarHistoryState, XlsxToolbarIcon, type XlsxToolbarIconName, type XlsxToolbarNumberFormat, type XlsxToolbarOptions, type XlsxToolbarProps, type XlsxToolbarState, buildXlsxContextMenuItems };