@canvas-components/react-list-table 0.3.82 → 1.0.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/README.md +198 -15
- package/dist/index.cjs +365 -60
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +366 -62
- package/package.json +10 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import { ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableDensity, ListTable, ListTableExternalValidationError, ListTableValidationErrorTarget, ListTableScrollToOptions, ListTableFreezeRowTarget, ListTableFrozenRow,
|
|
1
|
+
import { ListTableColumn, CellClickEvent, ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableDensity, ListTable, ListTableExternalValidationError, ListTableValidationErrorTarget, ListTableScrollToOptions, ListTableFreezeRowTarget, ListTableFrozenRow, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions, EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, ListTableExportNameRequest, ListTableExportSummarySettings } from '@canvas-components/list-table';
|
|
2
2
|
export { EXPAND_COLUMN, FormulaAlignedOptions, FormulaBracket, FormulaMatrixOptions, FormulaNodeStyle, FormulaOperatorName, FormulaOperatorOptions, ListTableCSSProperties, ListTableCacheCategory, ListTableCachePreferences, ListTableConditionalFormatCondition, ListTableConditionalFormatRule, ListTableConditionalOperator, ListTableExternalValidationError, ListTableFormulaCellContent, ListTableFormulaInput, ListTableFormulaNode, ListTableHighlightApplyResult, ListTableHighlightOptions, ListTablePaginationCSSProperties, ListTablePaginationStyleSlot, ListTablePaginationStyles, ListTableScrollbarCSSProperties, ListTableSorter, ListTableStyles, ListTableValidationErrorTarget, ROW_SELECTION_COLUMN, SELECTION_COLUMN, getListTableStoredPageSize } from '@canvas-components/list-table';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { CSSProperties, ReactNode, ForwardedRef, PropsWithChildren } from 'react';
|
|
5
|
+
import { UIJSXNode } from '@canvas-components/react-canvas-ui';
|
|
6
|
+
import { UILayoutDocument, UIRuntimeBinding } from '@canvas-components/canvas-ui/host';
|
|
5
7
|
import { ReactListTablePrintPreset } from '@canvas-components/print-design-plugin/list-table-print';
|
|
6
8
|
export { ReactListTableHostMenu, ReactListTablePrintColumnConfig, ReactListTablePrintConfig, ReactListTablePrintHostProps, ReactListTablePrintIntegration, ReactListTablePrintMenuContext, ReactListTablePrintPreset } from '@canvas-components/print-design-plugin/list-table-print';
|
|
7
9
|
import { PrintDesignDocument } from '@canvas-components/print-design';
|
|
8
10
|
export { ReactListTablePrintProvider, defineReactListTablePrintIntegration } from './print-integration.cjs';
|
|
9
11
|
|
|
12
|
+
type CellClickHandler<Row = unknown> = (event: CellClickEvent, record: Row) => void;
|
|
13
|
+
interface CellCompileContext<Row> {
|
|
14
|
+
record: Row;
|
|
15
|
+
rowIndex: number;
|
|
16
|
+
rowKey?: string | number;
|
|
17
|
+
columnKey?: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
onDiagnostic?: (message: string, path: string) => void;
|
|
20
|
+
}
|
|
21
|
+
interface CompiledCellLayout<Row> {
|
|
22
|
+
document: UILayoutDocument;
|
|
23
|
+
handlers: Map<string, CellClickHandler<Row>>;
|
|
24
|
+
runtimeBindings?: Map<string, UIRuntimeBinding>;
|
|
25
|
+
releaseRuntimeBindings?: () => void;
|
|
26
|
+
}
|
|
27
|
+
interface CellCompileRuntime<Row> {
|
|
28
|
+
/** 声明静态表头布局,事件在实际绘制帧中发布。 */
|
|
29
|
+
registerHeader?: (result: CompiledCellLayout<Row>) => void;
|
|
30
|
+
context?: (record: Row, rowIndex: number, columnKey?: string) => CellCompileContext<Row>;
|
|
31
|
+
register?: (result: CompiledCellLayout<Row>, context: CellCompileContext<Row>) => void;
|
|
32
|
+
}
|
|
33
|
+
type NativeCellRenderResult<Row> = ReturnType<NonNullable<ListTableColumn<Row>["render"]>>;
|
|
34
|
+
type ReactCellRenderResult<Row> = NativeCellRenderResult<Row> | UIJSXNode;
|
|
35
|
+
|
|
10
36
|
interface ReactListTableScrollConfig {
|
|
11
37
|
x?: number | string | true;
|
|
12
38
|
y?: number | string;
|
|
@@ -14,7 +40,8 @@ interface ReactListTableScrollConfig {
|
|
|
14
40
|
interface ReactListTableLocale {
|
|
15
41
|
emptyText?: string;
|
|
16
42
|
}
|
|
17
|
-
interface ReactListTableProps<RecordType = Record<string, unknown>> extends Omit<ListTableOptions<RecordType>, "type" | "ui" | "width" | "height" | "emptyText"> {
|
|
43
|
+
interface ReactListTableProps<RecordType = Record<string, unknown>> extends Omit<ListTableOptions<RecordType>, "type" | "ui" | "width" | "height" | "emptyText" | "columns"> {
|
|
44
|
+
columns: ReactListTableColumnsType<RecordType>;
|
|
18
45
|
width?: number | string;
|
|
19
46
|
height?: number | string;
|
|
20
47
|
emptyText?: string;
|
|
@@ -106,7 +133,15 @@ type ReactListTableTableProps<RecordType = Record<string, unknown>> = ReactListT
|
|
|
106
133
|
/**
|
|
107
134
|
* 单列类型。
|
|
108
135
|
*/
|
|
109
|
-
type ReactListTableColumnType<RecordType = Record<string, unknown>> = ListTableColumn<RecordType
|
|
136
|
+
type ReactListTableColumnType<RecordType = Record<string, unknown>> = Omit<ListTableColumn<RecordType>, "render" | "children" | "title"> & {
|
|
137
|
+
/** 表头支持原生标题和 Canvas UI JSX;不接受原生或第三方 JSX 标签。 */
|
|
138
|
+
title?: ListTableColumn<RecordType>["title"] | UIJSXNode;
|
|
139
|
+
children?: ReactListTableColumnsType<RecordType>;
|
|
140
|
+
/** 保持旧原生列回调的赋值兼容,同时允许 JSX 返回值。 */
|
|
141
|
+
render?: {
|
|
142
|
+
bivarianceHack(value: unknown, record: RecordType, rowIndex: number, column: ReactListTableColumnType<RecordType>): ReactCellRenderResult<RecordType>;
|
|
143
|
+
}["bivarianceHack"];
|
|
144
|
+
};
|
|
110
145
|
/**
|
|
111
146
|
* 列数组类型。
|
|
112
147
|
*/
|
|
@@ -171,4 +206,7 @@ interface ReactListTableDebugProviderProps extends PropsWithChildren {
|
|
|
171
206
|
*/
|
|
172
207
|
declare function ReactListTableDebugProvider(props: ReactListTableDebugProviderProps): react.JSX.Element;
|
|
173
208
|
|
|
174
|
-
|
|
209
|
+
/** 递归适配列,包装函数在运行时与源列/render 引用不变时保持稳定。 */
|
|
210
|
+
declare function adaptCellColumns<Row>(columns: ReactListTableColumnsType<Row>, runtime: CellCompileRuntime<Row>): ListTableColumn<Row>[];
|
|
211
|
+
|
|
212
|
+
export { type ReactCellRenderResult, ReactListTable, type ReactListTableColumnType, type ReactListTableColumnsType, ReactListTableDebugProvider, type ReactListTableDebugProviderProps, ReactListTableExportNameDialog, type ReactListTableLocale, type ReactListTablePagination, type ReactListTableProps, type ReactListTableQuery, type ReactListTableRef, type ReactListTableRowSelection, type ReactListTableScrollConfig, type ReactListTableTableProps, type ReactListTableToolbarOptions, adaptCellColumns };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import { ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableDensity, ListTable, ListTableExternalValidationError, ListTableValidationErrorTarget, ListTableScrollToOptions, ListTableFreezeRowTarget, ListTableFrozenRow,
|
|
1
|
+
import { ListTableColumn, CellClickEvent, ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableDensity, ListTable, ListTableExternalValidationError, ListTableValidationErrorTarget, ListTableScrollToOptions, ListTableFreezeRowTarget, ListTableFrozenRow, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions, EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, ListTableExportNameRequest, ListTableExportSummarySettings } from '@canvas-components/list-table';
|
|
2
2
|
export { EXPAND_COLUMN, FormulaAlignedOptions, FormulaBracket, FormulaMatrixOptions, FormulaNodeStyle, FormulaOperatorName, FormulaOperatorOptions, ListTableCSSProperties, ListTableCacheCategory, ListTableCachePreferences, ListTableConditionalFormatCondition, ListTableConditionalFormatRule, ListTableConditionalOperator, ListTableExternalValidationError, ListTableFormulaCellContent, ListTableFormulaInput, ListTableFormulaNode, ListTableHighlightApplyResult, ListTableHighlightOptions, ListTablePaginationCSSProperties, ListTablePaginationStyleSlot, ListTablePaginationStyles, ListTableScrollbarCSSProperties, ListTableSorter, ListTableStyles, ListTableValidationErrorTarget, ROW_SELECTION_COLUMN, SELECTION_COLUMN, getListTableStoredPageSize } from '@canvas-components/list-table';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { CSSProperties, ReactNode, ForwardedRef, PropsWithChildren } from 'react';
|
|
5
|
+
import { UIJSXNode } from '@canvas-components/react-canvas-ui';
|
|
6
|
+
import { UILayoutDocument, UIRuntimeBinding } from '@canvas-components/canvas-ui/host';
|
|
5
7
|
import { ReactListTablePrintPreset } from '@canvas-components/print-design-plugin/list-table-print';
|
|
6
8
|
export { ReactListTableHostMenu, ReactListTablePrintColumnConfig, ReactListTablePrintConfig, ReactListTablePrintHostProps, ReactListTablePrintIntegration, ReactListTablePrintMenuContext, ReactListTablePrintPreset } from '@canvas-components/print-design-plugin/list-table-print';
|
|
7
9
|
import { PrintDesignDocument } from '@canvas-components/print-design';
|
|
8
10
|
export { ReactListTablePrintProvider, defineReactListTablePrintIntegration } from './print-integration.js';
|
|
9
11
|
|
|
12
|
+
type CellClickHandler<Row = unknown> = (event: CellClickEvent, record: Row) => void;
|
|
13
|
+
interface CellCompileContext<Row> {
|
|
14
|
+
record: Row;
|
|
15
|
+
rowIndex: number;
|
|
16
|
+
rowKey?: string | number;
|
|
17
|
+
columnKey?: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
onDiagnostic?: (message: string, path: string) => void;
|
|
20
|
+
}
|
|
21
|
+
interface CompiledCellLayout<Row> {
|
|
22
|
+
document: UILayoutDocument;
|
|
23
|
+
handlers: Map<string, CellClickHandler<Row>>;
|
|
24
|
+
runtimeBindings?: Map<string, UIRuntimeBinding>;
|
|
25
|
+
releaseRuntimeBindings?: () => void;
|
|
26
|
+
}
|
|
27
|
+
interface CellCompileRuntime<Row> {
|
|
28
|
+
/** 声明静态表头布局,事件在实际绘制帧中发布。 */
|
|
29
|
+
registerHeader?: (result: CompiledCellLayout<Row>) => void;
|
|
30
|
+
context?: (record: Row, rowIndex: number, columnKey?: string) => CellCompileContext<Row>;
|
|
31
|
+
register?: (result: CompiledCellLayout<Row>, context: CellCompileContext<Row>) => void;
|
|
32
|
+
}
|
|
33
|
+
type NativeCellRenderResult<Row> = ReturnType<NonNullable<ListTableColumn<Row>["render"]>>;
|
|
34
|
+
type ReactCellRenderResult<Row> = NativeCellRenderResult<Row> | UIJSXNode;
|
|
35
|
+
|
|
10
36
|
interface ReactListTableScrollConfig {
|
|
11
37
|
x?: number | string | true;
|
|
12
38
|
y?: number | string;
|
|
@@ -14,7 +40,8 @@ interface ReactListTableScrollConfig {
|
|
|
14
40
|
interface ReactListTableLocale {
|
|
15
41
|
emptyText?: string;
|
|
16
42
|
}
|
|
17
|
-
interface ReactListTableProps<RecordType = Record<string, unknown>> extends Omit<ListTableOptions<RecordType>, "type" | "ui" | "width" | "height" | "emptyText"> {
|
|
43
|
+
interface ReactListTableProps<RecordType = Record<string, unknown>> extends Omit<ListTableOptions<RecordType>, "type" | "ui" | "width" | "height" | "emptyText" | "columns"> {
|
|
44
|
+
columns: ReactListTableColumnsType<RecordType>;
|
|
18
45
|
width?: number | string;
|
|
19
46
|
height?: number | string;
|
|
20
47
|
emptyText?: string;
|
|
@@ -106,7 +133,15 @@ type ReactListTableTableProps<RecordType = Record<string, unknown>> = ReactListT
|
|
|
106
133
|
/**
|
|
107
134
|
* 单列类型。
|
|
108
135
|
*/
|
|
109
|
-
type ReactListTableColumnType<RecordType = Record<string, unknown>> = ListTableColumn<RecordType
|
|
136
|
+
type ReactListTableColumnType<RecordType = Record<string, unknown>> = Omit<ListTableColumn<RecordType>, "render" | "children" | "title"> & {
|
|
137
|
+
/** 表头支持原生标题和 Canvas UI JSX;不接受原生或第三方 JSX 标签。 */
|
|
138
|
+
title?: ListTableColumn<RecordType>["title"] | UIJSXNode;
|
|
139
|
+
children?: ReactListTableColumnsType<RecordType>;
|
|
140
|
+
/** 保持旧原生列回调的赋值兼容,同时允许 JSX 返回值。 */
|
|
141
|
+
render?: {
|
|
142
|
+
bivarianceHack(value: unknown, record: RecordType, rowIndex: number, column: ReactListTableColumnType<RecordType>): ReactCellRenderResult<RecordType>;
|
|
143
|
+
}["bivarianceHack"];
|
|
144
|
+
};
|
|
110
145
|
/**
|
|
111
146
|
* 列数组类型。
|
|
112
147
|
*/
|
|
@@ -171,4 +206,7 @@ interface ReactListTableDebugProviderProps extends PropsWithChildren {
|
|
|
171
206
|
*/
|
|
172
207
|
declare function ReactListTableDebugProvider(props: ReactListTableDebugProviderProps): react.JSX.Element;
|
|
173
208
|
|
|
174
|
-
|
|
209
|
+
/** 递归适配列,包装函数在运行时与源列/render 引用不变时保持稳定。 */
|
|
210
|
+
declare function adaptCellColumns<Row>(columns: ReactListTableColumnsType<Row>, runtime: CellCompileRuntime<Row>): ListTableColumn<Row>[];
|
|
211
|
+
|
|
212
|
+
export { type ReactCellRenderResult, ReactListTable, type ReactListTableColumnType, type ReactListTableColumnsType, ReactListTableDebugProvider, type ReactListTableDebugProviderProps, ReactListTableExportNameDialog, type ReactListTableLocale, type ReactListTablePagination, type ReactListTableProps, type ReactListTableQuery, type ReactListTableRef, type ReactListTableRowSelection, type ReactListTableScrollConfig, type ReactListTableTableProps, type ReactListTableToolbarOptions, adaptCellColumns };
|