@bsg-export/react 1.0.6

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,44 @@
1
+ /**
2
+ * ExportButton - 开箱即用的导出按钮组件
3
+ *
4
+ * 自动管理 WASM 初始化、导出状态和进度显示。
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * <ExportButton tableId="my-table" filename="报表.xlsx" format={ExportFormat.Xlsx}>
9
+ * 导出 Excel
10
+ * </ExportButton>
11
+ * ```
12
+ */
13
+ import React from 'react';
14
+ import type { ExportFormat } from '@bsg-export/types';
15
+ /** ExportButton 组件的 Props */
16
+ export interface ExportButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onError'> {
17
+ /** 要导出的 HTML 表格元素的 ID */
18
+ tableId: string;
19
+ /** 导出文件名 */
20
+ filename?: string;
21
+ /** 导出格式 */
22
+ format?: ExportFormat;
23
+ /** 是否排除隐藏行/列 */
24
+ excludeHidden?: boolean;
25
+ /** 是否添加 UTF-8 BOM(仅 CSV 有效) */
26
+ withBom?: boolean;
27
+ /** 导出成功回调 */
28
+ onExportSuccess?: () => void;
29
+ /** 导出失败回调 */
30
+ onExportError?: (error: Error) => void;
31
+ /** 进度变化回调 */
32
+ onExportProgress?: (progress: number) => void;
33
+ /** 初始化中的提示文本 */
34
+ initializingText?: string;
35
+ /** 导出中的提示文本(支持 {progress} 占位符) */
36
+ loadingText?: string;
37
+ }
38
+ /**
39
+ * 导出按钮组件
40
+ *
41
+ * 封装了 WASM 初始化和导出逻辑,通过 props 配置导出参数。
42
+ */
43
+ export declare function ExportButton({ tableId, filename, format, excludeHidden, withBom, onExportSuccess, onExportError, onExportProgress, initializingText, loadingText, children, disabled, ...buttonProps }: ExportButtonProps): import("react/jsx-runtime").JSX.Element;
44
+ //# sourceMappingURL=ExportButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportButton.d.ts","sourceRoot":"","sources":["../src/ExportButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,6BAA6B;AAC7B,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IACtE,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW;IACX,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,gBAAgB;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa;IACb,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,aAAa;IACb,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,aAAa;IACb,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,gBAAgB;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,MAAM,EACN,aAAa,EACb,OAAO,EACP,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAA4B,EAC5B,WAA+B,EAC/B,QAAe,EACf,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,iBAAiB,2CAoDnB"}
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * ExportButton - 开箱即用的导出按钮组件
4
+ *
5
+ * 自动管理 WASM 初始化、导出状态和进度显示。
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * <ExportButton tableId="my-table" filename="报表.xlsx" format={ExportFormat.Xlsx}>
10
+ * 导出 Excel
11
+ * </ExportButton>
12
+ * ```
13
+ */
14
+ import React from 'react';
15
+ import { useExporter } from './use-exporter';
16
+ /**
17
+ * 导出按钮组件
18
+ *
19
+ * 封装了 WASM 初始化和导出逻辑,通过 props 配置导出参数。
20
+ */
21
+ export function ExportButton({ tableId, filename, format, excludeHidden, withBom, onExportSuccess, onExportError, onExportProgress, initializingText = '初始化中...', loadingText = '导出中 {progress}%', children = '导出', disabled, ...buttonProps }) {
22
+ const { initialized, loading, progress, error, exportTable } = useExporter();
23
+ React.useEffect(() => {
24
+ if (error && onExportError) {
25
+ onExportError(error);
26
+ }
27
+ }, [error, onExportError]);
28
+ React.useEffect(() => {
29
+ if (onExportProgress) {
30
+ onExportProgress(progress);
31
+ }
32
+ }, [progress, onExportProgress]);
33
+ const handleClick = React.useCallback((e) => {
34
+ buttonProps.onClick?.(e);
35
+ if (e.defaultPrevented)
36
+ return;
37
+ exportTable({
38
+ tableId,
39
+ filename,
40
+ format,
41
+ excludeHidden,
42
+ withBom,
43
+ });
44
+ // 导出成功回调(同步导出完成后立即触发)
45
+ if (onExportSuccess && !error) {
46
+ onExportSuccess();
47
+ }
48
+ }, [tableId, filename, format, excludeHidden, withBom, exportTable, onExportSuccess, error, buttonProps]);
49
+ /** 渲染按钮文本 */
50
+ const renderText = () => {
51
+ if (!initialized)
52
+ return initializingText;
53
+ if (loading)
54
+ return loadingText.replace('{progress}', Math.round(progress).toString());
55
+ return children;
56
+ };
57
+ return (_jsx("button", { ...buttonProps, disabled: disabled || !initialized || loading, onClick: handleClick, children: renderText() }));
58
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @bsg-export/react - belobog-stellar-grid 的 React 官方封装
3
+ *
4
+ * 提供 Hook 和组件,简化在 React 项目中使用表格导出功能。
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { useExporter } from './use-exporter';
9
+ export type { UseExporterReturn, ExportTableOptions, ExportTablesXlsxOptions, ExportCsvBatchOptions, ExportXlsxBatchOptions, ExportTablesBatchOptions, } from './use-exporter';
10
+ export { ExportButton } from './ExportButton';
11
+ export type { ExportButtonProps } from './ExportButton';
12
+ export type { Column, MergeCellValue, CellValue, MergeableCellValue, DataRow, ExportDataOptions, SheetConfig, BatchSheetConfig, ProgressCallback, } from '@bsg-export/types';
13
+ export { ExportFormat } from '@bsg-export/types';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,YAAY,EACV,MAAM,EACN,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @bsg-export/react - belobog-stellar-grid 的 React 官方封装
3
+ *
4
+ * 提供 Hook 和组件,简化在 React 项目中使用表格导出功能。
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ // Hook
9
+ export { useExporter } from './use-exporter';
10
+ // 组件
11
+ export { ExportButton } from './ExportButton';
12
+ export { ExportFormat } from '@bsg-export/types';
@@ -0,0 +1,108 @@
1
+ /**
2
+ * useExporter - WASM 导出管理 Hook
3
+ *
4
+ * 自动管理 WASM 初始化生命周期,提供类型安全的导出方法和状态追踪。
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * const { initialized, loading, progress, exportTable } = useExporter();
9
+ *
10
+ * return (
11
+ * <button onClick={() => exportTable({ tableId: 'my-table', filename: '报表.xlsx' })}
12
+ * disabled={!initialized || loading}>
13
+ * {loading ? `导出中 ${progress}%` : '导出 Excel'}
14
+ * </button>
15
+ * );
16
+ * ```
17
+ */
18
+ import type { ExportFormat, ExportDataOptions, SheetConfig, BatchSheetConfig, DataRow } from '@bsg-export/types';
19
+ /** export_table 的参数配置 */
20
+ export interface ExportTableOptions {
21
+ /** 要导出的 HTML 表格元素的 ID */
22
+ tableId: string;
23
+ /** 导出文件名 */
24
+ filename?: string;
25
+ /** 导出格式 */
26
+ format?: ExportFormat;
27
+ /** 是否排除隐藏行/列 */
28
+ excludeHidden?: boolean;
29
+ /** 是否添加 UTF-8 BOM(仅 CSV 有效) */
30
+ withBom?: boolean;
31
+ /** 回调失败是否中断导出 */
32
+ strictProgressCallback?: boolean;
33
+ }
34
+ /** 多工作表导出的参数配置 */
35
+ export interface ExportTablesXlsxOptions {
36
+ /** Sheet 配置数组 */
37
+ sheets: SheetConfig[];
38
+ /** 导出文件名 */
39
+ filename?: string;
40
+ }
41
+ /** 分批导出 CSV 的参数配置 */
42
+ export interface ExportCsvBatchOptions {
43
+ /** 要导出的 HTML 表格元素的 ID */
44
+ tableId: string;
45
+ /** 可选的独立 tbody ID */
46
+ tbodyId?: string;
47
+ /** 导出文件名 */
48
+ filename?: string;
49
+ /** 每批处理行数 */
50
+ batchSize?: number;
51
+ /** 是否排除隐藏行/列 */
52
+ excludeHidden?: boolean;
53
+ /** 是否添加 UTF-8 BOM */
54
+ withBom?: boolean;
55
+ }
56
+ /** 分批导出 XLSX 的参数配置 */
57
+ export interface ExportXlsxBatchOptions {
58
+ /** 要导出的 HTML 表格元素的 ID */
59
+ tableId: string;
60
+ /** 可选的独立 tbody ID */
61
+ tbodyId?: string;
62
+ /** 导出文件名 */
63
+ filename?: string;
64
+ /** 每批处理行数 */
65
+ batchSize?: number;
66
+ /** 是否排除隐藏行/列 */
67
+ excludeHidden?: boolean;
68
+ }
69
+ /** 多工作表分批导出的参数配置 */
70
+ export interface ExportTablesBatchOptions {
71
+ /** Sheet 配置数组 */
72
+ sheets: BatchSheetConfig[];
73
+ /** 导出文件名 */
74
+ filename?: string;
75
+ /** 每批处理行数 */
76
+ batchSize?: number;
77
+ }
78
+ /** useExporter Hook 的返回值 */
79
+ export interface UseExporterReturn {
80
+ /** WASM 是否已初始化完成 */
81
+ initialized: boolean;
82
+ /** 是否正在导出 */
83
+ loading: boolean;
84
+ /** 导出进度 (0-100) */
85
+ progress: number;
86
+ /** 错误信息 */
87
+ error: Error | null;
88
+ /** 导出 HTML 表格 */
89
+ exportTable: (options: ExportTableOptions) => void;
90
+ /** 从 JS 数组直接导出 */
91
+ exportData: (data: DataRow[], options?: ExportDataOptions) => void;
92
+ /** 多工作表同步导出 */
93
+ exportTablesXlsx: (options: ExportTablesXlsxOptions) => void;
94
+ /** 分批异步导出 CSV */
95
+ exportCsvBatch: (options: ExportCsvBatchOptions) => Promise<void>;
96
+ /** 分批异步导出 XLSX */
97
+ exportXlsxBatch: (options: ExportXlsxBatchOptions) => Promise<void>;
98
+ /** 多工作表分批异步导出 */
99
+ exportTablesBatch: (options: ExportTablesBatchOptions) => Promise<void>;
100
+ }
101
+ /**
102
+ * WASM 导出管理 Hook
103
+ *
104
+ * 自动初始化 WASM 模块,提供类型安全的导出方法,
105
+ * 管理 loading / progress / error 状态。
106
+ */
107
+ export declare function useExporter(): UseExporterReturn;
108
+ //# sourceMappingURL=use-exporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-exporter.d.ts","sourceRoot":"","sources":["../src/use-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAEhB,OAAO,EACR,MAAM,mBAAmB,CAAC;AAE3B,yBAAyB;AACzB,MAAM,WAAW,kBAAkB;IACjC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW;IACX,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,gBAAgB;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,kBAAkB;AAClB,MAAM,WAAW,uBAAuB;IACtC,iBAAiB;IACjB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,YAAY;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAqB;AACrB,MAAM,WAAW,qBAAqB;IACpC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,sBAAsB;AACtB,MAAM,WAAW,sBAAsB;IACrC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,oBAAoB;AACpB,MAAM,WAAW,wBAAwB;IACvC,iBAAiB;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,YAAY;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4BAA4B;AAC5B,MAAM,WAAW,iBAAiB;IAChC,oBAAoB;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,iBAAiB;IACjB,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,kBAAkB;IAClB,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnE,eAAe;IACf,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,iBAAiB;IACjB,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,kBAAkB;IAClB,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,iBAAiB;IACjB,iBAAiB,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE;AAuBD;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAwK/C"}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * useExporter - WASM 导出管理 Hook
3
+ *
4
+ * 自动管理 WASM 初始化生命周期,提供类型安全的导出方法和状态追踪。
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * const { initialized, loading, progress, exportTable } = useExporter();
9
+ *
10
+ * return (
11
+ * <button onClick={() => exportTable({ tableId: 'my-table', filename: '报表.xlsx' })}
12
+ * disabled={!initialized || loading}>
13
+ * {loading ? `导出中 ${progress}%` : '导出 Excel'}
14
+ * </button>
15
+ * );
16
+ * ```
17
+ */
18
+ import { useState, useEffect, useCallback, useRef } from 'react';
19
+ /** WASM 模块缓存 */
20
+ let wasmModule = null;
21
+ let wasmInitPromise = null;
22
+ /**
23
+ * 初始化 WASM 模块(单例模式)
24
+ */
25
+ async function initWasm() {
26
+ if (wasmModule)
27
+ return wasmModule;
28
+ if (!wasmInitPromise) {
29
+ wasmInitPromise = import('belobog-stellar-grid').then(async (mod) => {
30
+ await mod.default();
31
+ wasmModule = mod;
32
+ return mod;
33
+ });
34
+ }
35
+ return wasmInitPromise;
36
+ }
37
+ /**
38
+ * WASM 导出管理 Hook
39
+ *
40
+ * 自动初始化 WASM 模块,提供类型安全的导出方法,
41
+ * 管理 loading / progress / error 状态。
42
+ */
43
+ export function useExporter() {
44
+ const [initialized, setInitialized] = useState(false);
45
+ const [loading, setLoading] = useState(false);
46
+ const [progress, setProgress] = useState(0);
47
+ const [error, setError] = useState(null);
48
+ const mountedRef = useRef(true);
49
+ useEffect(() => {
50
+ mountedRef.current = true;
51
+ initWasm()
52
+ .then(() => {
53
+ if (mountedRef.current)
54
+ setInitialized(true);
55
+ })
56
+ .catch((err) => {
57
+ if (mountedRef.current)
58
+ setError(err instanceof Error ? err : new Error(String(err)));
59
+ });
60
+ return () => {
61
+ mountedRef.current = false;
62
+ };
63
+ }, []);
64
+ /** 创建进度回调(自动更新 progress 状态) */
65
+ const createProgressCallback = useCallback(() => {
66
+ return (p) => {
67
+ if (mountedRef.current)
68
+ setProgress(p);
69
+ };
70
+ }, []);
71
+ /** 包装同步导出操作 */
72
+ const wrapSync = useCallback((fn) => {
73
+ if (!initialized || !wasmModule)
74
+ return;
75
+ setLoading(true);
76
+ setProgress(0);
77
+ setError(null);
78
+ try {
79
+ fn();
80
+ if (mountedRef.current)
81
+ setProgress(100);
82
+ }
83
+ catch (err) {
84
+ if (mountedRef.current)
85
+ setError(err instanceof Error ? err : new Error(String(err)));
86
+ }
87
+ finally {
88
+ if (mountedRef.current)
89
+ setLoading(false);
90
+ }
91
+ }, [initialized]);
92
+ /** 包装异步导出操作 */
93
+ const wrapAsync = useCallback(async (fn) => {
94
+ if (!initialized || !wasmModule)
95
+ return;
96
+ setLoading(true);
97
+ setProgress(0);
98
+ setError(null);
99
+ try {
100
+ await fn();
101
+ if (mountedRef.current)
102
+ setProgress(100);
103
+ }
104
+ catch (err) {
105
+ if (mountedRef.current)
106
+ setError(err instanceof Error ? err : new Error(String(err)));
107
+ }
108
+ finally {
109
+ if (mountedRef.current)
110
+ setLoading(false);
111
+ }
112
+ }, [initialized]);
113
+ const exportTable = useCallback((options) => {
114
+ wrapSync(() => {
115
+ wasmModule.export_table(options.tableId, options.filename, options.format, options.excludeHidden, createProgressCallback(), options.withBom, options.strictProgressCallback);
116
+ });
117
+ }, [wrapSync, createProgressCallback]);
118
+ const exportData = useCallback((data, options) => {
119
+ wrapSync(() => {
120
+ const opts = options
121
+ ? { ...options, progressCallback: options.progressCallback ?? createProgressCallback() }
122
+ : { progressCallback: createProgressCallback() };
123
+ wasmModule.export_data(data, opts);
124
+ });
125
+ }, [wrapSync, createProgressCallback]);
126
+ const exportTablesXlsx = useCallback((options) => {
127
+ wrapSync(() => {
128
+ wasmModule.export_tables_xlsx(options.sheets, options.filename, createProgressCallback());
129
+ });
130
+ }, [wrapSync, createProgressCallback]);
131
+ const exportCsvBatch = useCallback(async (options) => {
132
+ await wrapAsync(async () => {
133
+ await wasmModule.export_table_to_csv_batch(options.tableId, options.tbodyId, options.filename, options.batchSize, options.excludeHidden, createProgressCallback(), options.withBom);
134
+ });
135
+ }, [wrapAsync, createProgressCallback]);
136
+ const exportXlsxBatch = useCallback(async (options) => {
137
+ await wrapAsync(async () => {
138
+ await wasmModule.export_table_to_xlsx_batch(options.tableId, options.tbodyId, options.filename, options.batchSize, options.excludeHidden, createProgressCallback());
139
+ });
140
+ }, [wrapAsync, createProgressCallback]);
141
+ const exportTablesBatch = useCallback(async (options) => {
142
+ await wrapAsync(async () => {
143
+ await wasmModule.export_tables_to_xlsx_batch(options.sheets, options.filename, options.batchSize, createProgressCallback());
144
+ });
145
+ }, [wrapAsync, createProgressCallback]);
146
+ return {
147
+ initialized,
148
+ loading,
149
+ progress,
150
+ error,
151
+ exportTable,
152
+ exportData,
153
+ exportTablesXlsx,
154
+ exportCsvBatch,
155
+ exportXlsxBatch,
156
+ exportTablesBatch,
157
+ };
158
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@bsg-export/react",
3
+ "version": "1.0.6",
4
+ "description": "belobog-stellar-grid 的 React 官方封装组件",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "typecheck": "tsc --noEmit"
20
+ },
21
+ "keywords": [
22
+ "belobog",
23
+ "stellar-grid",
24
+ "react",
25
+ "export",
26
+ "table"
27
+ ],
28
+ "author": "Kurisu <makise_kurisuu@outlook.jp>",
29
+ "license": "MIT OR Apache-2.0",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/kurisu994/belobog-stellar-grid",
33
+ "directory": "packages/react"
34
+ },
35
+ "peerDependencies": {
36
+ "belobog-stellar-grid": ">=1.0.0",
37
+ "react": ">=17.0.0"
38
+ },
39
+ "dependencies": {
40
+ "@bsg-export/types": "file:../types"
41
+ },
42
+ "devDependencies": {
43
+ "@types/react": "^19.0.0",
44
+ "react": "^19.0.0",
45
+ "typescript": "^5.7.0"
46
+ }
47
+ }