@canvas-components/react-list-table 0.3.53 → 0.3.55

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,30 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ // src/features/print/print-integration.tsx
7
+ function defineReactListTablePrintIntegration(integration) {
8
+ if (!integration.Host || typeof integration.createMenu !== "function" || typeof integration.readTemplates !== "function" || typeof integration.createTemplateChoices !== "function")
9
+ throw new Error("\u8868\u683C\u6253\u5370\u96C6\u6210\u7F3A\u5C11\u5BBF\u4E3B\u83DC\u5355\u3001\u6A21\u677F\u6216\u754C\u9762\u80FD\u529B\u3002");
10
+ if (!integration.componentRegistry.get("table"))
11
+ throw new Error("\u8868\u683C\u6253\u5370\u96C6\u6210\u7F3A\u5C11 table \u539F\u751F\u7EC4\u4EF6\u3002");
12
+ for (const factory of integration.editor.componentFactories.list()) {
13
+ if (!integration.componentRegistry.get(factory.type))
14
+ throw new Error(`\u6253\u5370\u8BBE\u8BA1\u7EC4\u4EF6\u7F3A\u5C11\u539F\u751F\u7ED8\u5236\u80FD\u529B\uFF1A${factory.type}`);
15
+ }
16
+ return Object.freeze(integration);
17
+ }
18
+ var PrintIntegrationContext = react.createContext(null);
19
+ function ReactListTablePrintProvider(props) {
20
+ if (props.integration)
21
+ defineReactListTablePrintIntegration(props.integration);
22
+ return /* @__PURE__ */ jsxRuntime.jsx(PrintIntegrationContext.Provider, { value: props.integration, children: props.children });
23
+ }
24
+ function useReactListTablePrintIntegration() {
25
+ return react.useContext(PrintIntegrationContext);
26
+ }
27
+
28
+ exports.ReactListTablePrintProvider = ReactListTablePrintProvider;
29
+ exports.defineReactListTablePrintIntegration = defineReactListTablePrintIntegration;
30
+ exports.useReactListTablePrintIntegration = useReactListTablePrintIntegration;
@@ -0,0 +1,76 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, ReactNode } from 'react';
3
+ import { HeaderContextMenuConfig } from '@canvas-components/list-table';
4
+ import { PrintDesignComponentRegistry, PrintDesignDocument } from '@canvas-components/print-design';
5
+ import { ReactListTablePrintPreset } from './print-settings.cjs';
6
+ import { ReactPrintDesignProps, PrintDesignTemplateVersion } from '@canvas-components/react-print-design';
7
+ import '@canvas-components/print';
8
+
9
+ /** 宿主插件贡献给表格右键菜单的子菜单项。 */
10
+ interface ReactListTableHostMenuItem {
11
+ key: string;
12
+ label: string;
13
+ disabled?: boolean;
14
+ onClick?: () => void;
15
+ }
16
+ /** 宿主插件的右键菜单描述。 */
17
+ interface ReactListTableHostMenu {
18
+ label: string;
19
+ items: readonly ReactListTableHostMenuItem[];
20
+ }
21
+ /** 当前表格实例提供的打印菜单上下文。 */
22
+ interface ReactListTablePrintMenuContext {
23
+ canPrint: boolean;
24
+ templates: readonly {
25
+ key: string;
26
+ label: string;
27
+ disabled?: boolean;
28
+ }[];
29
+ onPrintTemplate: (key: string) => void;
30
+ onDirectPrint: () => void;
31
+ onPrintDesign: () => void;
32
+ }
33
+ /** 每个表格实例传给宿主插件的请求与界面能力。 */
34
+ interface ReactListTablePrintHostProps {
35
+ integration: ReactListTablePrintIntegration;
36
+ request: HeaderContextMenuConfig | null;
37
+ portalContainer: HTMLElement;
38
+ storeKey?: string;
39
+ presets?: readonly ReactListTablePrintPreset[];
40
+ templates?: readonly PrintDesignDocument[];
41
+ pagesPerBatch?: number;
42
+ children: (menu: ReactListTableHostMenu | null) => ReactNode;
43
+ }
44
+ /** 表格右键打印设计所需的同版本原生与 React 插件能力。 */
45
+ interface ReactListTablePrintIntegration {
46
+ id: string;
47
+ version: string;
48
+ componentRegistry: PrintDesignComponentRegistry;
49
+ editor: Required<Pick<ReactPrintDesignProps, "componentFactories" | "componentMenu" | "propertySections" | "contextMenus" | "tools" | "pluginCatalog">>;
50
+ createMenu: (context: ReactListTablePrintMenuContext) => ReactListTableHostMenu;
51
+ readTemplates: (storeKey: string) => Promise<PrintDesignTemplateVersion[]>;
52
+ createTemplateChoices: (options: {
53
+ presets?: readonly {
54
+ name: string;
55
+ }[];
56
+ documents?: readonly {
57
+ name: string;
58
+ }[];
59
+ saved: readonly PrintDesignTemplateVersion[];
60
+ }) => readonly {
61
+ key: string;
62
+ label: string;
63
+ }[];
64
+ Host: ComponentType<ReactListTablePrintHostProps>;
65
+ }
66
+ /** 校验设计器创建能力与独立打印端使用同一组组件。 */
67
+ declare function defineReactListTablePrintIntegration(integration: ReactListTablePrintIntegration): Readonly<ReactListTablePrintIntegration>;
68
+ /** 在应用范围注册一次打印设计集成;传入 null 时停用该范围内的集成入口。 */
69
+ declare function ReactListTablePrintProvider(props: {
70
+ integration: ReactListTablePrintIntegration | null;
71
+ children: ReactNode;
72
+ }): react.JSX.Element;
73
+ /** 每张表读取当前应用范围的集成定义,数据仍由该表实例提供。 */
74
+ declare function useReactListTablePrintIntegration(): ReactListTablePrintIntegration | null;
75
+
76
+ export { type ReactListTableHostMenu, type ReactListTableHostMenuItem, type ReactListTablePrintHostProps, type ReactListTablePrintIntegration, type ReactListTablePrintMenuContext, ReactListTablePrintProvider, defineReactListTablePrintIntegration, useReactListTablePrintIntegration };
@@ -0,0 +1,76 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, ReactNode } from 'react';
3
+ import { HeaderContextMenuConfig } from '@canvas-components/list-table';
4
+ import { PrintDesignComponentRegistry, PrintDesignDocument } from '@canvas-components/print-design';
5
+ import { ReactListTablePrintPreset } from './print-settings.js';
6
+ import { ReactPrintDesignProps, PrintDesignTemplateVersion } from '@canvas-components/react-print-design';
7
+ import '@canvas-components/print';
8
+
9
+ /** 宿主插件贡献给表格右键菜单的子菜单项。 */
10
+ interface ReactListTableHostMenuItem {
11
+ key: string;
12
+ label: string;
13
+ disabled?: boolean;
14
+ onClick?: () => void;
15
+ }
16
+ /** 宿主插件的右键菜单描述。 */
17
+ interface ReactListTableHostMenu {
18
+ label: string;
19
+ items: readonly ReactListTableHostMenuItem[];
20
+ }
21
+ /** 当前表格实例提供的打印菜单上下文。 */
22
+ interface ReactListTablePrintMenuContext {
23
+ canPrint: boolean;
24
+ templates: readonly {
25
+ key: string;
26
+ label: string;
27
+ disabled?: boolean;
28
+ }[];
29
+ onPrintTemplate: (key: string) => void;
30
+ onDirectPrint: () => void;
31
+ onPrintDesign: () => void;
32
+ }
33
+ /** 每个表格实例传给宿主插件的请求与界面能力。 */
34
+ interface ReactListTablePrintHostProps {
35
+ integration: ReactListTablePrintIntegration;
36
+ request: HeaderContextMenuConfig | null;
37
+ portalContainer: HTMLElement;
38
+ storeKey?: string;
39
+ presets?: readonly ReactListTablePrintPreset[];
40
+ templates?: readonly PrintDesignDocument[];
41
+ pagesPerBatch?: number;
42
+ children: (menu: ReactListTableHostMenu | null) => ReactNode;
43
+ }
44
+ /** 表格右键打印设计所需的同版本原生与 React 插件能力。 */
45
+ interface ReactListTablePrintIntegration {
46
+ id: string;
47
+ version: string;
48
+ componentRegistry: PrintDesignComponentRegistry;
49
+ editor: Required<Pick<ReactPrintDesignProps, "componentFactories" | "componentMenu" | "propertySections" | "contextMenus" | "tools" | "pluginCatalog">>;
50
+ createMenu: (context: ReactListTablePrintMenuContext) => ReactListTableHostMenu;
51
+ readTemplates: (storeKey: string) => Promise<PrintDesignTemplateVersion[]>;
52
+ createTemplateChoices: (options: {
53
+ presets?: readonly {
54
+ name: string;
55
+ }[];
56
+ documents?: readonly {
57
+ name: string;
58
+ }[];
59
+ saved: readonly PrintDesignTemplateVersion[];
60
+ }) => readonly {
61
+ key: string;
62
+ label: string;
63
+ }[];
64
+ Host: ComponentType<ReactListTablePrintHostProps>;
65
+ }
66
+ /** 校验设计器创建能力与独立打印端使用同一组组件。 */
67
+ declare function defineReactListTablePrintIntegration(integration: ReactListTablePrintIntegration): Readonly<ReactListTablePrintIntegration>;
68
+ /** 在应用范围注册一次打印设计集成;传入 null 时停用该范围内的集成入口。 */
69
+ declare function ReactListTablePrintProvider(props: {
70
+ integration: ReactListTablePrintIntegration | null;
71
+ children: ReactNode;
72
+ }): react.JSX.Element;
73
+ /** 每张表读取当前应用范围的集成定义,数据仍由该表实例提供。 */
74
+ declare function useReactListTablePrintIntegration(): ReactListTablePrintIntegration | null;
75
+
76
+ export { type ReactListTableHostMenu, type ReactListTableHostMenuItem, type ReactListTablePrintHostProps, type ReactListTablePrintIntegration, type ReactListTablePrintMenuContext, ReactListTablePrintProvider, defineReactListTablePrintIntegration, useReactListTablePrintIntegration };
@@ -0,0 +1,26 @@
1
+ import { createContext, useContext } from 'react';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ // src/features/print/print-integration.tsx
5
+ function defineReactListTablePrintIntegration(integration) {
6
+ if (!integration.Host || typeof integration.createMenu !== "function" || typeof integration.readTemplates !== "function" || typeof integration.createTemplateChoices !== "function")
7
+ throw new Error("\u8868\u683C\u6253\u5370\u96C6\u6210\u7F3A\u5C11\u5BBF\u4E3B\u83DC\u5355\u3001\u6A21\u677F\u6216\u754C\u9762\u80FD\u529B\u3002");
8
+ if (!integration.componentRegistry.get("table"))
9
+ throw new Error("\u8868\u683C\u6253\u5370\u96C6\u6210\u7F3A\u5C11 table \u539F\u751F\u7EC4\u4EF6\u3002");
10
+ for (const factory of integration.editor.componentFactories.list()) {
11
+ if (!integration.componentRegistry.get(factory.type))
12
+ throw new Error(`\u6253\u5370\u8BBE\u8BA1\u7EC4\u4EF6\u7F3A\u5C11\u539F\u751F\u7ED8\u5236\u80FD\u529B\uFF1A${factory.type}`);
13
+ }
14
+ return Object.freeze(integration);
15
+ }
16
+ var PrintIntegrationContext = createContext(null);
17
+ function ReactListTablePrintProvider(props) {
18
+ if (props.integration)
19
+ defineReactListTablePrintIntegration(props.integration);
20
+ return /* @__PURE__ */ jsx(PrintIntegrationContext.Provider, { value: props.integration, children: props.children });
21
+ }
22
+ function useReactListTablePrintIntegration() {
23
+ return useContext(PrintIntegrationContext);
24
+ }
25
+
26
+ export { ReactListTablePrintProvider, defineReactListTablePrintIntegration, useReactListTablePrintIntegration };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,69 @@
1
+ import { BrowserPrintColumn, BrowserPrintPaperSize } from '@canvas-components/print';
2
+ import { ListTableExportSummarySettings, ListTableExportColumnChoice, ListTableExportSettings } from '@canvas-components/list-table';
3
+
4
+ interface PrintColumn extends BrowserPrintColumn {
5
+ summaryType?: ListTableExportSummarySettings["type"];
6
+ showTypePrefix?: "yes" | "no";
7
+ precision?: number;
8
+ roundingMode?: ListTableExportSummarySettings["roundingMode"];
9
+ preserveTrailingZeros?: "yes" | "no";
10
+ summaryTitle?: string;
11
+ }
12
+ interface PrintSettings {
13
+ version: 2;
14
+ presetName?: string;
15
+ title?: string;
16
+ subtitle?: string;
17
+ titleFontSize?: number;
18
+ subtitleFontSize?: number;
19
+ columns: PrintColumn[];
20
+ selectedKeys: string[];
21
+ rowsPerPage: number;
22
+ rowHeight?: number;
23
+ autoCalculateRowsPerPage?: boolean;
24
+ autoCalculateColumnWidths?: boolean;
25
+ includeSummary?: boolean;
26
+ summaryPosition?: "every-page" | "last-page";
27
+ showPageNumbers?: boolean;
28
+ pageNumberPosition?: "left" | "center" | "right";
29
+ showPrintTime?: boolean;
30
+ printTimePosition?: "left" | "center" | "right";
31
+ pageMargins?: {
32
+ top: number;
33
+ right: number;
34
+ bottom: number;
35
+ left: number;
36
+ };
37
+ paperSize?: BrowserPrintPaperSize;
38
+ orientation?: "portrait" | "landscape";
39
+ useCellBorders?: boolean;
40
+ borderColor?: string;
41
+ textColor?: string;
42
+ headerBackgroundColor?: string;
43
+ summaryBackgroundColor?: string;
44
+ showSectionDividers?: boolean;
45
+ sectionDividerTopSpacing?: number;
46
+ sectionDividerBottomSpacing?: number;
47
+ formItemSpacing?: number;
48
+ }
49
+ /** 打印列预设只需指定列键;宽度、对齐和超宽处理均可选。 */
50
+ type ReactListTablePrintColumnConfig = Pick<BrowserPrintColumn, "key"> & Partial<Omit<PrintColumn, "key">>;
51
+ /** 打印预设的可配置项;未提供的字段使用打印默认值。 */
52
+ type ReactListTablePrintConfig = Partial<Omit<PrintSettings, "version" | "presetName" | "columns" | "selectedKeys">> & {
53
+ columns?: readonly ReactListTablePrintColumnConfig[];
54
+ selectedKeys?: readonly string[];
55
+ };
56
+ /** 供 ReactListTable 打印弹窗选择的命名预设。名称应保持唯一。 */
57
+ interface ReactListTablePrintPreset {
58
+ name: string;
59
+ config: ReactListTablePrintConfig;
60
+ }
61
+ interface PrintSource {
62
+ columns: BrowserPrintColumn[];
63
+ rows: string[][];
64
+ summaryRow?: string[];
65
+ summaryColumns?: ListTableExportColumnChoice[];
66
+ getSummaryRow?: (settings: ListTableExportSettings) => Promise<string[]>;
67
+ }
68
+
69
+ export type { PrintColumn, PrintSettings, PrintSource, ReactListTablePrintColumnConfig, ReactListTablePrintConfig, ReactListTablePrintPreset };
@@ -0,0 +1,69 @@
1
+ import { BrowserPrintColumn, BrowserPrintPaperSize } from '@canvas-components/print';
2
+ import { ListTableExportSummarySettings, ListTableExportColumnChoice, ListTableExportSettings } from '@canvas-components/list-table';
3
+
4
+ interface PrintColumn extends BrowserPrintColumn {
5
+ summaryType?: ListTableExportSummarySettings["type"];
6
+ showTypePrefix?: "yes" | "no";
7
+ precision?: number;
8
+ roundingMode?: ListTableExportSummarySettings["roundingMode"];
9
+ preserveTrailingZeros?: "yes" | "no";
10
+ summaryTitle?: string;
11
+ }
12
+ interface PrintSettings {
13
+ version: 2;
14
+ presetName?: string;
15
+ title?: string;
16
+ subtitle?: string;
17
+ titleFontSize?: number;
18
+ subtitleFontSize?: number;
19
+ columns: PrintColumn[];
20
+ selectedKeys: string[];
21
+ rowsPerPage: number;
22
+ rowHeight?: number;
23
+ autoCalculateRowsPerPage?: boolean;
24
+ autoCalculateColumnWidths?: boolean;
25
+ includeSummary?: boolean;
26
+ summaryPosition?: "every-page" | "last-page";
27
+ showPageNumbers?: boolean;
28
+ pageNumberPosition?: "left" | "center" | "right";
29
+ showPrintTime?: boolean;
30
+ printTimePosition?: "left" | "center" | "right";
31
+ pageMargins?: {
32
+ top: number;
33
+ right: number;
34
+ bottom: number;
35
+ left: number;
36
+ };
37
+ paperSize?: BrowserPrintPaperSize;
38
+ orientation?: "portrait" | "landscape";
39
+ useCellBorders?: boolean;
40
+ borderColor?: string;
41
+ textColor?: string;
42
+ headerBackgroundColor?: string;
43
+ summaryBackgroundColor?: string;
44
+ showSectionDividers?: boolean;
45
+ sectionDividerTopSpacing?: number;
46
+ sectionDividerBottomSpacing?: number;
47
+ formItemSpacing?: number;
48
+ }
49
+ /** 打印列预设只需指定列键;宽度、对齐和超宽处理均可选。 */
50
+ type ReactListTablePrintColumnConfig = Pick<BrowserPrintColumn, "key"> & Partial<Omit<PrintColumn, "key">>;
51
+ /** 打印预设的可配置项;未提供的字段使用打印默认值。 */
52
+ type ReactListTablePrintConfig = Partial<Omit<PrintSettings, "version" | "presetName" | "columns" | "selectedKeys">> & {
53
+ columns?: readonly ReactListTablePrintColumnConfig[];
54
+ selectedKeys?: readonly string[];
55
+ };
56
+ /** 供 ReactListTable 打印弹窗选择的命名预设。名称应保持唯一。 */
57
+ interface ReactListTablePrintPreset {
58
+ name: string;
59
+ config: ReactListTablePrintConfig;
60
+ }
61
+ interface PrintSource {
62
+ columns: BrowserPrintColumn[];
63
+ rows: string[][];
64
+ summaryRow?: string[];
65
+ summaryColumns?: ListTableExportColumnChoice[];
66
+ getSummaryRow?: (settings: ListTableExportSettings) => Promise<string[]>;
67
+ }
68
+
69
+ export type { PrintColumn, PrintSettings, PrintSource, ReactListTablePrintColumnConfig, ReactListTablePrintConfig, ReactListTablePrintPreset };
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/react-list-table",
3
- "version": "0.3.53",
3
+ "version": "0.3.55",
4
4
  "description": "React adapter for the list table core engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,6 +18,16 @@
18
18
  "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.js",
20
20
  "require": "./dist/index.cjs"
21
+ },
22
+ "./print-settings": {
23
+ "types": "./dist/print-settings.d.ts",
24
+ "import": "./dist/print-settings.js",
25
+ "require": "./dist/print-settings.cjs"
26
+ },
27
+ "./print-integration": {
28
+ "types": "./dist/print-integration.d.ts",
29
+ "import": "./dist/print-integration.js",
30
+ "require": "./dist/print-integration.cjs"
21
31
  }
22
32
  },
23
33
  "publishConfig": {
@@ -28,17 +38,33 @@
28
38
  "pnpm": ">=9.0.0"
29
39
  },
30
40
  "dependencies": {
31
- "@canvas-components/print": "0.1.1",
32
- "@canvas-components/list-table": "0.3.43",
33
- "@canvas-components/react-components": "0.3.24",
34
41
  "@canvas-components/chart": "0.3.9",
35
- "@canvas-components/react-print-design": "0.1.7",
36
- "@canvas-components/print-design": "0.1.5"
42
+ "@canvas-components/list-table": "0.3.43",
43
+ "@canvas-components/react-components": "0.3.24"
44
+ },
45
+ "devDependencies": {
46
+ "@canvas-components/print": "0.1.1",
47
+ "@canvas-components/react-print-design": "0.1.12",
48
+ "@canvas-components/print-design": "0.1.9"
37
49
  },
38
50
  "peerDependencies": {
51
+ "@canvas-components/print": ">=0.1.0",
52
+ "@canvas-components/print-design": ">=0.1.0",
53
+ "@canvas-components/react-print-design": ">=0.1.7",
39
54
  "react": ">=16.8.0",
40
55
  "react-dom": ">=16.8.0"
41
56
  },
57
+ "peerDependenciesMeta": {
58
+ "@canvas-components/print": {
59
+ "optional": true
60
+ },
61
+ "@canvas-components/print-design": {
62
+ "optional": true
63
+ },
64
+ "@canvas-components/react-print-design": {
65
+ "optional": true
66
+ }
67
+ },
42
68
  "scripts": {
43
69
  "build": "tsup --config tsup.config.ts"
44
70
  }