@canvas-components/react-print-design 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +88 -2
- package/dist/index.cjs +10334 -0
- package/dist/index.d.cts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +10328 -0
- package/package.json +45 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { PrintDesignOptions, PrintDesignDocument, PrintDesignSelection, PrintDesign } from '@canvas-components/print-design';
|
|
4
|
+
|
|
5
|
+
/** React 打印设计器属性。传入 document 时可使用受控文档模式。 */
|
|
6
|
+
interface ReactPrintDesignProps extends Omit<PrintDesignOptions, "onChange" | "onSelectionChange" | "onActivePageChange"> {
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
/** 模板内容变化回调。 */
|
|
10
|
+
onChange?: (document: PrintDesignDocument) => void;
|
|
11
|
+
/** 选区变化回调。 */
|
|
12
|
+
onSelectionChange?: (selection: PrintDesignSelection) => void;
|
|
13
|
+
/** 活动页面变化回调。 */
|
|
14
|
+
onActivePageChange?: (pageId: string) => void;
|
|
15
|
+
/** 是否显示内置工具栏与属性面板。@default true */
|
|
16
|
+
editor?: boolean;
|
|
17
|
+
/** 按业务键将模板版本保存到 IndexedDB。 */
|
|
18
|
+
storeKey?: string;
|
|
19
|
+
/** 传入数据的结构标识;变更后旧模板版本标记为失效。 */
|
|
20
|
+
dataFormatKey?: string;
|
|
21
|
+
/** 不可删除的内置模板;未传入时使用初始 document。 */
|
|
22
|
+
defaultTemplates?: readonly PrintDesignDocument[];
|
|
23
|
+
/** 弹窗关闭操作,传入时在工具栏右侧显示关闭按钮。 */
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
/** 外部控制的全屏状态。 */
|
|
26
|
+
fullscreen?: boolean;
|
|
27
|
+
/** 外部全屏切换回调;未传入时编辑器使用浏览器全屏。 */
|
|
28
|
+
onFullscreenChange?: (fullscreen: boolean) => void;
|
|
29
|
+
/** 是否显示右上角全屏切换按钮。@default true */
|
|
30
|
+
showFullscreenButton?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 基于 print-design 原生 Canvas 核心的 React 编辑器。
|
|
34
|
+
*/
|
|
35
|
+
declare const ReactPrintDesign: react.ForwardRefExoticComponent<ReactPrintDesignProps & react.RefAttributes<PrintDesign>>;
|
|
36
|
+
|
|
37
|
+
/** 同一 storeKey 下的一个模板历史版本。 */
|
|
38
|
+
interface PrintDesignTemplateVersion {
|
|
39
|
+
id: string;
|
|
40
|
+
templateId: string;
|
|
41
|
+
version: number;
|
|
42
|
+
savedAt: number;
|
|
43
|
+
creator?: string;
|
|
44
|
+
createdAt?: number;
|
|
45
|
+
updatedAt?: number;
|
|
46
|
+
dataFormat?: string;
|
|
47
|
+
document: PrintDesignDocument;
|
|
48
|
+
}
|
|
49
|
+
/** 读取并验证指定业务键的模板版本。 */
|
|
50
|
+
declare function readPrintDesignTemplates(storeKey: string): Promise<PrintDesignTemplateVersion[]>;
|
|
51
|
+
|
|
52
|
+
/** 仅比较字段结构与值类型,不记录实际业务数据。 */
|
|
53
|
+
declare function getPrintDesignDataFormat(data?: Record<string, unknown>): string | undefined;
|
|
54
|
+
/** 旧版本没有格式签名时,检查其表格绑定列是否仍可从传入数据读取。 */
|
|
55
|
+
declare function isPrintDesignDocumentCompatible(document: PrintDesignDocument, data?: Record<string, unknown>): boolean;
|
|
56
|
+
/** 当前输入与保存版本的数据格式不一致时判定为失效。 */
|
|
57
|
+
declare function isPrintDesignTemplateInvalid(version: PrintDesignTemplateVersion, dataFormat?: string, data?: Record<string, unknown>): boolean;
|
|
58
|
+
|
|
59
|
+
export { type PrintDesignTemplateVersion, ReactPrintDesign, type ReactPrintDesignProps, getPrintDesignDataFormat, isPrintDesignDocumentCompatible, isPrintDesignTemplateInvalid, readPrintDesignTemplates };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
import { PrintDesignOptions, PrintDesignDocument, PrintDesignSelection, PrintDesign } from '@canvas-components/print-design';
|
|
4
|
+
|
|
5
|
+
/** React 打印设计器属性。传入 document 时可使用受控文档模式。 */
|
|
6
|
+
interface ReactPrintDesignProps extends Omit<PrintDesignOptions, "onChange" | "onSelectionChange" | "onActivePageChange"> {
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
/** 模板内容变化回调。 */
|
|
10
|
+
onChange?: (document: PrintDesignDocument) => void;
|
|
11
|
+
/** 选区变化回调。 */
|
|
12
|
+
onSelectionChange?: (selection: PrintDesignSelection) => void;
|
|
13
|
+
/** 活动页面变化回调。 */
|
|
14
|
+
onActivePageChange?: (pageId: string) => void;
|
|
15
|
+
/** 是否显示内置工具栏与属性面板。@default true */
|
|
16
|
+
editor?: boolean;
|
|
17
|
+
/** 按业务键将模板版本保存到 IndexedDB。 */
|
|
18
|
+
storeKey?: string;
|
|
19
|
+
/** 传入数据的结构标识;变更后旧模板版本标记为失效。 */
|
|
20
|
+
dataFormatKey?: string;
|
|
21
|
+
/** 不可删除的内置模板;未传入时使用初始 document。 */
|
|
22
|
+
defaultTemplates?: readonly PrintDesignDocument[];
|
|
23
|
+
/** 弹窗关闭操作,传入时在工具栏右侧显示关闭按钮。 */
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
/** 外部控制的全屏状态。 */
|
|
26
|
+
fullscreen?: boolean;
|
|
27
|
+
/** 外部全屏切换回调;未传入时编辑器使用浏览器全屏。 */
|
|
28
|
+
onFullscreenChange?: (fullscreen: boolean) => void;
|
|
29
|
+
/** 是否显示右上角全屏切换按钮。@default true */
|
|
30
|
+
showFullscreenButton?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 基于 print-design 原生 Canvas 核心的 React 编辑器。
|
|
34
|
+
*/
|
|
35
|
+
declare const ReactPrintDesign: react.ForwardRefExoticComponent<ReactPrintDesignProps & react.RefAttributes<PrintDesign>>;
|
|
36
|
+
|
|
37
|
+
/** 同一 storeKey 下的一个模板历史版本。 */
|
|
38
|
+
interface PrintDesignTemplateVersion {
|
|
39
|
+
id: string;
|
|
40
|
+
templateId: string;
|
|
41
|
+
version: number;
|
|
42
|
+
savedAt: number;
|
|
43
|
+
creator?: string;
|
|
44
|
+
createdAt?: number;
|
|
45
|
+
updatedAt?: number;
|
|
46
|
+
dataFormat?: string;
|
|
47
|
+
document: PrintDesignDocument;
|
|
48
|
+
}
|
|
49
|
+
/** 读取并验证指定业务键的模板版本。 */
|
|
50
|
+
declare function readPrintDesignTemplates(storeKey: string): Promise<PrintDesignTemplateVersion[]>;
|
|
51
|
+
|
|
52
|
+
/** 仅比较字段结构与值类型,不记录实际业务数据。 */
|
|
53
|
+
declare function getPrintDesignDataFormat(data?: Record<string, unknown>): string | undefined;
|
|
54
|
+
/** 旧版本没有格式签名时,检查其表格绑定列是否仍可从传入数据读取。 */
|
|
55
|
+
declare function isPrintDesignDocumentCompatible(document: PrintDesignDocument, data?: Record<string, unknown>): boolean;
|
|
56
|
+
/** 当前输入与保存版本的数据格式不一致时判定为失效。 */
|
|
57
|
+
declare function isPrintDesignTemplateInvalid(version: PrintDesignTemplateVersion, dataFormat?: string, data?: Record<string, unknown>): boolean;
|
|
58
|
+
|
|
59
|
+
export { type PrintDesignTemplateVersion, ReactPrintDesign, type ReactPrintDesignProps, getPrintDesignDataFormat, isPrintDesignDocumentCompatible, isPrintDesignTemplateInvalid, readPrintDesignTemplates };
|