@hi-ui/schema-editable-table 4.0.0-experimental.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 +11 -0
- package/lib/cjs/body/index.js +110 -0
- package/lib/cjs/body/wrapper.js +132 -0
- package/lib/cjs/cell/aggregated.js +76 -0
- package/lib/cjs/cell/dependency.js +97 -0
- package/lib/cjs/cell/editing.js +89 -0
- package/lib/cjs/cell/footer.js +64 -0
- package/lib/cjs/cell/header.js +76 -0
- package/lib/cjs/cell/index.js +204 -0
- package/lib/cjs/const.js +35 -0
- package/lib/cjs/container/base.js +39 -0
- package/lib/cjs/container/bottom.js +86 -0
- package/lib/cjs/container/col-group.js +98 -0
- package/lib/cjs/container/column-virtual.js +53 -0
- package/lib/cjs/container/ctx.js +32 -0
- package/lib/cjs/container/full-virtual.js +61 -0
- package/lib/cjs/container/hooks.js +102 -0
- package/lib/cjs/container/index.js +69 -0
- package/lib/cjs/container/row-virtual.js +50 -0
- package/lib/cjs/container/wrapper.js +97 -0
- package/lib/cjs/ctx.js +32 -0
- package/lib/cjs/features/_overrides/aggregated.js +44 -0
- package/lib/cjs/features/_overrides/getter.js +61 -0
- package/lib/cjs/features/_overrides/grouping.js +40 -0
- package/lib/cjs/features/_overrides/overrides.js +43 -0
- package/lib/cjs/features/_overrides/row-selection.js +140 -0
- package/lib/cjs/features/async-data/getter.js +150 -0
- package/lib/cjs/features/async-data/normal.js +145 -0
- package/lib/cjs/features/async-data/use-data-fetcher.js +40 -0
- package/lib/cjs/features/async-data/use-reset-data.js +91 -0
- package/lib/cjs/features/column-grouping/get-grouping-config.js +27 -0
- package/lib/cjs/features/column-grouping/use-opts.js +42 -0
- package/lib/cjs/features/column-state.js +57 -0
- package/lib/cjs/features/filter/bridge.js +114 -0
- package/lib/cjs/features/filter/filter-fns/date.js +34 -0
- package/lib/cjs/features/filter/filter-fns/index.js +23 -0
- package/lib/cjs/features/filter/get-filter-config.js +61 -0
- package/lib/cjs/features/filter/index.js +29 -0
- package/lib/cjs/features/filter/use-opts.js +88 -0
- package/lib/cjs/features/header-actions/components/column-collapsing.js +74 -0
- package/lib/cjs/features/header-actions/get-actions.js +77 -0
- package/lib/cjs/features/pagination/component.js +89 -0
- package/lib/cjs/features/pagination/use-opts.js +98 -0
- package/lib/cjs/features/pagination/use-state.js +44 -0
- package/lib/cjs/features/row-controller.js +265 -0
- package/lib/cjs/features/row-edit/actions.js +65 -0
- package/lib/cjs/features/row-edit/hooks.js +29 -0
- package/lib/cjs/features/row-expanding/use-opts.js +39 -0
- package/lib/cjs/features/row-expanding/wrapper.js +74 -0
- package/lib/cjs/features/row-operation/buttons.js +91 -0
- package/lib/cjs/features/row-operation/cell.js +43 -0
- package/lib/cjs/features/row-operation/index.js +21 -0
- package/lib/cjs/features/row-operation/wrapper.js +114 -0
- package/lib/cjs/features/row-selection/cell.js +114 -0
- package/lib/cjs/features/row-selection/const.js +16 -0
- package/lib/cjs/features/row-selection/hooks/index.js +29 -0
- package/lib/cjs/features/row-selection/hooks/use-click-select.js +70 -0
- package/lib/cjs/features/row-selection/hooks/use-opts.js +120 -0
- package/lib/cjs/features/row-selection/hooks/use-set-selected-row-keys.js +48 -0
- package/lib/cjs/features/row-selection/hooks/use-sync-hover-style.js +86 -0
- package/lib/cjs/features/row-selection/indicator.js +173 -0
- package/lib/cjs/features/row-selection/wrapper.js +119 -0
- package/lib/cjs/features/setting-bridge.js +56 -0
- package/lib/cjs/features/sorter/bridge.js +65 -0
- package/lib/cjs/features/sorter/get-sorter-config.js +46 -0
- package/lib/cjs/features/sorter/index.js +29 -0
- package/lib/cjs/features/sorter/use-opts.js +81 -0
- package/lib/cjs/field-bridge/bridge.js +104 -0
- package/lib/cjs/field-bridge/index.js +58 -0
- package/lib/cjs/field-bridge/toolbar.js +53 -0
- package/lib/cjs/footer/index.js +99 -0
- package/lib/cjs/footer/use-first-cell-patch.js +42 -0
- package/lib/cjs/header/index.js +134 -0
- package/lib/cjs/header/validate.js +69 -0
- package/lib/cjs/hooks/use-get-fields-value.js +62 -0
- package/lib/cjs/hooks/use-global-actions.js +65 -0
- package/lib/cjs/hooks/use-global-static.js +158 -0
- package/lib/cjs/hooks/use-initial-render.js +30 -0
- package/lib/cjs/hooks/use-inner-ctx.js +105 -0
- package/lib/cjs/hooks/use-props.js +108 -0
- package/lib/cjs/hooks/use-table-columns.js +76 -0
- package/lib/cjs/hooks/use-table-meta.js +57 -0
- package/lib/cjs/hooks/use-update.js +57 -0
- package/lib/cjs/index.js +66 -0
- package/lib/cjs/index.scss.js +18 -0
- package/lib/cjs/table.js +263 -0
- package/lib/cjs/utils/cls.js +19 -0
- package/lib/cjs/utils/fixed.js +53 -0
- package/lib/cjs/utils/grouping.js +42 -0
- package/lib/cjs/utils/state-merge.js +43 -0
- package/lib/esm/body/index.js +98 -0
- package/lib/esm/body/wrapper.js +120 -0
- package/lib/esm/cell/aggregated.js +64 -0
- package/lib/esm/cell/dependency.js +90 -0
- package/lib/esm/cell/editing.js +76 -0
- package/lib/esm/cell/footer.js +52 -0
- package/lib/esm/cell/header.js +63 -0
- package/lib/esm/cell/index.js +192 -0
- package/lib/esm/const.js +24 -0
- package/lib/esm/container/base.js +27 -0
- package/lib/esm/container/bottom.js +74 -0
- package/lib/esm/container/col-group.js +85 -0
- package/lib/esm/container/column-virtual.js +41 -0
- package/lib/esm/container/ctx.js +19 -0
- package/lib/esm/container/full-virtual.js +49 -0
- package/lib/esm/container/hooks.js +95 -0
- package/lib/esm/container/index.js +57 -0
- package/lib/esm/container/row-virtual.js +38 -0
- package/lib/esm/container/wrapper.js +83 -0
- package/lib/esm/ctx.js +17 -0
- package/lib/esm/features/_overrides/aggregated.js +39 -0
- package/lib/esm/features/_overrides/getter.js +56 -0
- package/lib/esm/features/_overrides/grouping.js +35 -0
- package/lib/esm/features/_overrides/overrides.js +38 -0
- package/lib/esm/features/_overrides/row-selection.js +135 -0
- package/lib/esm/features/async-data/getter.js +143 -0
- package/lib/esm/features/async-data/normal.js +133 -0
- package/lib/esm/features/async-data/use-data-fetcher.js +34 -0
- package/lib/esm/features/async-data/use-reset-data.js +79 -0
- package/lib/esm/features/column-grouping/get-grouping-config.js +22 -0
- package/lib/esm/features/column-grouping/use-opts.js +36 -0
- package/lib/esm/features/column-state.js +51 -0
- package/lib/esm/features/filter/bridge.js +102 -0
- package/lib/esm/features/filter/filter-fns/date.js +28 -0
- package/lib/esm/features/filter/filter-fns/index.js +18 -0
- package/lib/esm/features/filter/get-filter-config.js +56 -0
- package/lib/esm/features/filter/index.js +24 -0
- package/lib/esm/features/filter/use-opts.js +82 -0
- package/lib/esm/features/header-actions/components/column-collapsing.js +62 -0
- package/lib/esm/features/header-actions/get-actions.js +65 -0
- package/lib/esm/features/pagination/component.js +77 -0
- package/lib/esm/features/pagination/use-opts.js +91 -0
- package/lib/esm/features/pagination/use-state.js +39 -0
- package/lib/esm/features/row-controller.js +253 -0
- package/lib/esm/features/row-edit/actions.js +53 -0
- package/lib/esm/features/row-edit/hooks.js +24 -0
- package/lib/esm/features/row-expanding/use-opts.js +33 -0
- package/lib/esm/features/row-expanding/wrapper.js +62 -0
- package/lib/esm/features/row-operation/buttons.js +79 -0
- package/lib/esm/features/row-operation/cell.js +31 -0
- package/lib/esm/features/row-operation/index.js +16 -0
- package/lib/esm/features/row-operation/wrapper.js +100 -0
- package/lib/esm/features/row-selection/cell.js +101 -0
- package/lib/esm/features/row-selection/const.js +11 -0
- package/lib/esm/features/row-selection/hooks/index.js +24 -0
- package/lib/esm/features/row-selection/hooks/use-click-select.js +65 -0
- package/lib/esm/features/row-selection/hooks/use-opts.js +114 -0
- package/lib/esm/features/row-selection/hooks/use-set-selected-row-keys.js +43 -0
- package/lib/esm/features/row-selection/hooks/use-sync-hover-style.js +81 -0
- package/lib/esm/features/row-selection/indicator.js +159 -0
- package/lib/esm/features/row-selection/wrapper.js +107 -0
- package/lib/esm/features/setting-bridge.js +50 -0
- package/lib/esm/features/sorter/bridge.js +53 -0
- package/lib/esm/features/sorter/get-sorter-config.js +41 -0
- package/lib/esm/features/sorter/index.js +24 -0
- package/lib/esm/features/sorter/use-opts.js +75 -0
- package/lib/esm/field-bridge/bridge.js +92 -0
- package/lib/esm/field-bridge/index.js +44 -0
- package/lib/esm/field-bridge/toolbar.js +41 -0
- package/lib/esm/footer/index.js +87 -0
- package/lib/esm/footer/use-first-cell-patch.js +37 -0
- package/lib/esm/header/index.js +121 -0
- package/lib/esm/header/validate.js +64 -0
- package/lib/esm/hooks/use-get-fields-value.js +56 -0
- package/lib/esm/hooks/use-global-actions.js +60 -0
- package/lib/esm/hooks/use-global-static.js +152 -0
- package/lib/esm/hooks/use-initial-render.js +18 -0
- package/lib/esm/hooks/use-inner-ctx.js +100 -0
- package/lib/esm/hooks/use-props.js +102 -0
- package/lib/esm/hooks/use-table-columns.js +70 -0
- package/lib/esm/hooks/use-table-meta.js +51 -0
- package/lib/esm/hooks/use-update.js +52 -0
- package/lib/esm/index.js +38 -0
- package/lib/esm/index.scss.js +13 -0
- package/lib/esm/table.js +251 -0
- package/lib/esm/utils/cls.js +13 -0
- package/lib/esm/utils/fixed.js +48 -0
- package/lib/esm/utils/grouping.js +36 -0
- package/lib/esm/utils/state-merge.js +37 -0
- package/lib/types/body/index.d.ts +14 -0
- package/lib/types/body/wrapper.d.ts +18 -0
- package/lib/types/cell/aggregated.d.ts +35 -0
- package/lib/types/cell/custom.d.ts +19 -0
- package/lib/types/cell/dependency.d.ts +47 -0
- package/lib/types/cell/editing.d.ts +8 -0
- package/lib/types/cell/footer.d.ts +5 -0
- package/lib/types/cell/header.d.ts +5 -0
- package/lib/types/cell/index.d.ts +6 -0
- package/lib/types/const.d.ts +11 -0
- package/lib/types/container/base.d.ts +2 -0
- package/lib/types/container/bottom.d.ts +20 -0
- package/lib/types/container/col-group.d.ts +11 -0
- package/lib/types/container/column-virtual.d.ts +7 -0
- package/lib/types/container/ctx.d.ts +23 -0
- package/lib/types/container/full-virtual.d.ts +8 -0
- package/lib/types/container/hooks.d.ts +13 -0
- package/lib/types/container/index.d.ts +17 -0
- package/lib/types/container/row-virtual.d.ts +7 -0
- package/lib/types/container/type.d.ts +17 -0
- package/lib/types/container/wrapper.d.ts +12 -0
- package/lib/types/ctx.d.ts +41 -0
- package/lib/types/features/_overrides/aggregated.d.ts +2 -0
- package/lib/types/features/_overrides/getter.d.ts +2 -0
- package/lib/types/features/_overrides/grouping.d.ts +7 -0
- package/lib/types/features/_overrides/index.d.ts +5 -0
- package/lib/types/features/_overrides/overrides.d.ts +2 -0
- package/lib/types/features/_overrides/row-selection.d.ts +2 -0
- package/lib/types/features/async-data/getter.d.ts +9 -0
- package/lib/types/features/async-data/group.d.ts +1 -0
- package/lib/types/features/async-data/index.d.ts +6 -0
- package/lib/types/features/async-data/normal.d.ts +48 -0
- package/lib/types/features/async-data/type.d.ts +22 -0
- package/lib/types/features/async-data/use-data-fetcher.d.ts +22 -0
- package/lib/types/features/async-data/use-reset-data.d.ts +14 -0
- package/lib/types/features/column-grouping/get-grouping-config.d.ts +2 -0
- package/lib/types/features/column-grouping/index.d.ts +3 -0
- package/lib/types/features/column-grouping/use-opts.d.ts +12 -0
- package/lib/types/features/column-state.d.ts +15 -0
- package/lib/types/features/filter/bridge.d.ts +9 -0
- package/lib/types/features/filter/filter-fns/date.d.ts +6 -0
- package/lib/types/features/filter/filter-fns/index.d.ts +6 -0
- package/lib/types/features/filter/get-filter-config.d.ts +4 -0
- package/lib/types/features/filter/index.d.ts +8 -0
- package/lib/types/features/filter/use-opts.d.ts +62 -0
- package/lib/types/features/header-actions/components/column-collapsing.d.ts +4 -0
- package/lib/types/features/header-actions/get-actions.d.ts +13 -0
- package/lib/types/features/header-actions/index.d.ts +3 -0
- package/lib/types/features/header-actions/type.d.ts +20 -0
- package/lib/types/features/pagination/component.d.ts +15 -0
- package/lib/types/features/pagination/index.d.ts +4 -0
- package/lib/types/features/pagination/use-opts.d.ts +14 -0
- package/lib/types/features/pagination/use-state.d.ts +11 -0
- package/lib/types/features/row-controller.d.ts +101 -0
- package/lib/types/features/row-edit/actions.d.ts +12 -0
- package/lib/types/features/row-edit/hooks.d.ts +1 -0
- package/lib/types/features/row-edit/index.d.ts +2 -0
- package/lib/types/features/row-expanding/index.d.ts +3 -0
- package/lib/types/features/row-expanding/use-opts.d.ts +12 -0
- package/lib/types/features/row-expanding/wrapper.d.ts +11 -0
- package/lib/types/features/row-operation/buttons.d.ts +41 -0
- package/lib/types/features/row-operation/cell.d.ts +6 -0
- package/lib/types/features/row-operation/index.d.ts +18 -0
- package/lib/types/features/row-operation/wrapper.d.ts +3 -0
- package/lib/types/features/row-selection/cell.d.ts +62 -0
- package/lib/types/features/row-selection/const.d.ts +1 -0
- package/lib/types/features/row-selection/hooks/index.d.ts +6 -0
- package/lib/types/features/row-selection/hooks/use-click-select.d.ts +1 -0
- package/lib/types/features/row-selection/hooks/use-opts.d.ts +15 -0
- package/lib/types/features/row-selection/hooks/use-set-selected-row-keys.d.ts +9 -0
- package/lib/types/features/row-selection/hooks/use-sync-hover-style.d.ts +5 -0
- package/lib/types/features/row-selection/index.d.ts +7 -0
- package/lib/types/features/row-selection/indicator.d.ts +8 -0
- package/lib/types/features/row-selection/wrapper.d.ts +9 -0
- package/lib/types/features/setting-bridge.d.ts +14 -0
- package/lib/types/features/sorter/bridge.d.ts +8 -0
- package/lib/types/features/sorter/get-sorter-config.d.ts +7 -0
- package/lib/types/features/sorter/index.d.ts +8 -0
- package/lib/types/features/sorter/use-opts.d.ts +71 -0
- package/lib/types/field-bridge/bridge.d.ts +18 -0
- package/lib/types/field-bridge/index.d.ts +11 -0
- package/lib/types/field-bridge/toolbar.d.ts +9 -0
- package/lib/types/footer/index.d.ts +6 -0
- package/lib/types/footer/use-first-cell-patch.d.ts +1 -0
- package/lib/types/header/index.d.ts +17 -0
- package/lib/types/header/validate.d.ts +10 -0
- package/lib/types/hooks/use-get-fields-value.d.ts +14 -0
- package/lib/types/hooks/use-global-actions.d.ts +24 -0
- package/lib/types/hooks/use-global-static.d.ts +83 -0
- package/lib/types/hooks/use-initial-render.d.ts +1 -0
- package/lib/types/hooks/use-inner-ctx.d.ts +12 -0
- package/lib/types/hooks/use-props.d.ts +109 -0
- package/lib/types/hooks/use-table-columns.d.ts +11 -0
- package/lib/types/hooks/use-table-meta.d.ts +15 -0
- package/lib/types/hooks/use-update.d.ts +11 -0
- package/lib/types/index.d.ts +32 -0
- package/lib/types/table.d.ts +152 -0
- package/lib/types/utils/cls.d.ts +4 -0
- package/lib/types/utils/fixed.d.ts +11 -0
- package/lib/types/utils/grouping.d.ts +6 -0
- package/lib/types/utils/index.d.ts +5 -0
- package/lib/types/utils/meta.d.ts +8 -0
- package/lib/types/utils/state-merge.d.ts +14 -0
- package/package.json +90 -0
- package/type.d.ts +143 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { ReadonlyRefObject } from '@hi-ui/schema-hooks';
|
|
2
|
+
import type { EditableSchemaTableProps } from '../table';
|
|
3
|
+
import type { PropsRefType } from '../ctx';
|
|
4
|
+
/** 标准化后的 props 类型 */
|
|
5
|
+
export type NormalizedProps<T extends AnyObject> = ReturnType<typeof getNormalizedProps<T>>;
|
|
6
|
+
export declare function getNormalizedProps<T extends AnyObject>(props: EditableSchemaTableProps<T>): {
|
|
7
|
+
subRowKey: string;
|
|
8
|
+
debug: {
|
|
9
|
+
debugAll?: boolean | undefined;
|
|
10
|
+
debugColumns?: boolean | undefined;
|
|
11
|
+
debugHeaders?: boolean | undefined;
|
|
12
|
+
debugCells?: boolean | undefined;
|
|
13
|
+
debugRows?: boolean | undefined;
|
|
14
|
+
debugTable?: boolean | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
sticky: import("..").TableStickyOpts | undefined;
|
|
17
|
+
virtualize: {
|
|
18
|
+
row: Partial<Omit<import("@tanstack/virtual-core").VirtualizerOptions<HTMLDivElement, HTMLDivElement>, "count" | "getScrollElement">> | undefined;
|
|
19
|
+
column: Partial<Omit<import("@tanstack/virtual-core").VirtualizerOptions<HTMLDivElement, HTMLDivElement>, "count" | "getScrollElement">> | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
rowSelection: {
|
|
22
|
+
enableIndicator: import("../features/row-selection/indicator").RowSelectionIndicatorOpts | undefined;
|
|
23
|
+
type?: "checkbox" | "radio";
|
|
24
|
+
onChange?: ((selected: {
|
|
25
|
+
keys: string[];
|
|
26
|
+
rows: T[];
|
|
27
|
+
}) => void) | undefined;
|
|
28
|
+
onCheckAllChange?: (ctx: {
|
|
29
|
+
checked: boolean;
|
|
30
|
+
indeterminate: boolean;
|
|
31
|
+
}) => void;
|
|
32
|
+
preserveSelectedRows?: boolean;
|
|
33
|
+
enableRowSelection?: ((rowData: T, ctx: {
|
|
34
|
+
row: import("@tanstack/table-core").Row<T>;
|
|
35
|
+
}) => boolean) | undefined;
|
|
36
|
+
enableSubRowSelection?: ((rowData: T, ctx: {
|
|
37
|
+
row: import("@tanstack/table-core").Row<T>;
|
|
38
|
+
}) => boolean) | undefined;
|
|
39
|
+
enableDynamicRowSelection?: boolean;
|
|
40
|
+
dftSelectedRowKeys?: (string | number)[];
|
|
41
|
+
enableClickSelect?: boolean;
|
|
42
|
+
} | undefined;
|
|
43
|
+
rowOperation: import("..").RowOperationOptsType<T> | undefined;
|
|
44
|
+
pagination: import("../features/pagination").PaginationProps | undefined;
|
|
45
|
+
filter: import("../features/filter").FilterOpts | undefined;
|
|
46
|
+
sorter: {
|
|
47
|
+
tooltip: {
|
|
48
|
+
text?: {
|
|
49
|
+
asc?: string;
|
|
50
|
+
desc?: string;
|
|
51
|
+
default?: string;
|
|
52
|
+
};
|
|
53
|
+
} | undefined;
|
|
54
|
+
remote?: boolean;
|
|
55
|
+
onChange?: (state: import("@tanstack/table-core").SortingState, ctx: import("../utils").OnChangeFnCtxType<import("@tanstack/table-core").SortingState>) => void;
|
|
56
|
+
enableMultiSort?: import("@tanstack/table-core").TableOptions<AnyObject>["enableMultiSort"];
|
|
57
|
+
maxMultiSortColCount?: import("@tanstack/table-core").TableOptions<AnyObject>["maxMultiSortColCount"];
|
|
58
|
+
sortUndefined?: import("@tanstack/table-core").SortingColumnDef<AnyObject>["sortUndefined"];
|
|
59
|
+
} | undefined;
|
|
60
|
+
grouping: {} | undefined;
|
|
61
|
+
expanding: {} | undefined;
|
|
62
|
+
fieldMap?: Partial<import("packages/schema/schema-fields/lib/types").ProFieldMapType>;
|
|
63
|
+
value?: T[] | undefined;
|
|
64
|
+
defaultValue?: T[] | undefined;
|
|
65
|
+
onChange?: ((val: T[]) => void) | undefined;
|
|
66
|
+
fields: import("@hi-ui/schema-core").FieldConfigType[];
|
|
67
|
+
asyncData?: import("..").AsyncDataOptsType<T> | undefined;
|
|
68
|
+
innerCtxRef?: import("react").RefObject<import("../table").TableCtxRefType<T>> | undefined;
|
|
69
|
+
onValuesChange?: ((changedValues: Record<number, Partial<T>>, allValues: T[]) => void) | undefined;
|
|
70
|
+
getRowStyle?: ((row: T, ctx: {
|
|
71
|
+
row: import("@tanstack/table-core").Row<T>;
|
|
72
|
+
}) => React.CSSProperties) | undefined;
|
|
73
|
+
defaultActive?: boolean;
|
|
74
|
+
showFooter?: boolean;
|
|
75
|
+
enableForceRerender?: boolean;
|
|
76
|
+
rowKey?: string;
|
|
77
|
+
readonly?: boolean;
|
|
78
|
+
headerAction?: import("../features/header-actions").HeaderActionOptsType;
|
|
79
|
+
bordered?: boolean;
|
|
80
|
+
bottom?: import("..").BottomRenderConfigType;
|
|
81
|
+
customCell?: import("../cell").CustomCellType<T> | undefined;
|
|
82
|
+
defaultColumn?: Partial<import("@tanstack/table-core").ColumnDef<T, unknown>> | undefined;
|
|
83
|
+
features?: import("@tanstack/table-core").TableOptions<TData>["_features"];
|
|
84
|
+
wrapperStyle?: React.CSSProperties;
|
|
85
|
+
on?: {
|
|
86
|
+
rowMounted?: import("../body").OnBodyRowMountedFn<T> | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
customEngineOpts?: Partial<import("@tanstack/table-core").TableOptions<T>> | undefined;
|
|
89
|
+
};
|
|
90
|
+
export declare function usePropsRef<T extends AnyObject>(props: EditableSchemaTableProps<T>): {
|
|
91
|
+
propsRef: PropsRefType<T>;
|
|
92
|
+
staticOptsRef: ReadonlyRefObject<{
|
|
93
|
+
enableAsyncData: boolean;
|
|
94
|
+
hasNestHeader: boolean;
|
|
95
|
+
enableRowSelection: boolean;
|
|
96
|
+
enableRowOperation: boolean;
|
|
97
|
+
enableRowEdit: boolean;
|
|
98
|
+
operationColWidth: number;
|
|
99
|
+
enablePagination: boolean;
|
|
100
|
+
enableHeaderActionHoverOnly: boolean;
|
|
101
|
+
enableFilter: boolean;
|
|
102
|
+
enableRemoteFilter: boolean;
|
|
103
|
+
enableSorter: boolean;
|
|
104
|
+
enableRemoteSorter: boolean;
|
|
105
|
+
enableRowExpanding: boolean;
|
|
106
|
+
enableRowGrouping: boolean;
|
|
107
|
+
isBottomEmpty: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
import type { PropsRefType } from '../ctx';
|
|
4
|
+
export declare function MapFieldConfigToColumnDef<TData extends AnyObject>(fields: FieldConfigType[], ctx: {
|
|
5
|
+
propsRef: PropsRefType<TData>;
|
|
6
|
+
}): ColumnDef<TData>[];
|
|
7
|
+
type UseTableColumnsCtxType<TData extends AnyObject> = {
|
|
8
|
+
propsRef: PropsRefType<TData>;
|
|
9
|
+
};
|
|
10
|
+
export declare function useTableColumns<TData extends AnyObject>(ctx: UseTableColumnsCtxType<TData>): ColumnDef<TData>[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Table, TableMeta } from '@tanstack/react-table';
|
|
2
|
+
import type { Subscription } from '@hi-ui/use-subscription';
|
|
3
|
+
import type { EditableSchemaTableProps } from '../table';
|
|
4
|
+
import type { InnerRefType } from '../ctx';
|
|
5
|
+
type UseTableMetaCtxType<TData extends AnyObject = AnyObject> = {
|
|
6
|
+
fieldMap?: EditableSchemaTableProps<TData>['fieldMap'];
|
|
7
|
+
onValuesChange?: EditableSchemaTableProps<TData>['onValuesChange'];
|
|
8
|
+
innerRef: InnerRefType<TData>;
|
|
9
|
+
};
|
|
10
|
+
export declare const useTableMeta: <TData extends AnyObject = AnyObject>(tableValue: Subscription<TData[]>, ctx: UseTableMetaCtxType<TData>) => TableMeta<TData>;
|
|
11
|
+
export declare function getCellOpFn<TData extends AnyObject = AnyObject>(table: Table<TData>): {
|
|
12
|
+
getCellValue: TableMeta<TData>["getCellValue"];
|
|
13
|
+
setCellValue: TableMeta<TData>["updateData"];
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Subscription } from '@hi-ui/use-subscription';
|
|
2
|
+
/**
|
|
3
|
+
* 监听表格数据变化,并触发重渲染
|
|
4
|
+
* @notice 仅在表格数据发生【全量变化】时触发重渲染
|
|
5
|
+
* @param tableValue 表格数据
|
|
6
|
+
* @returns 重渲染函数
|
|
7
|
+
*/
|
|
8
|
+
export declare function useTableUpdate<T>(tableValue: Subscription<T[]>): {
|
|
9
|
+
rerender: () => void;
|
|
10
|
+
forceRerenderFlag: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { default as Body, type EditTableBodyProps } from './body';
|
|
2
|
+
export { default as Header, type EditTableHeaderProps } from './header';
|
|
3
|
+
export { default as Footer, type EditTableFooterProps } from './footer';
|
|
4
|
+
export { default as Cell, FooterCell } from './cell';
|
|
5
|
+
export { EditableSchemaTable, EditableSchemaTable as EditTable } from './table';
|
|
6
|
+
export type { EditableSchemaTableProps, EditableSchemaTableProps as EditTableProps } from './table';
|
|
7
|
+
export { useEditableSchemaTableCtx, useEditTableCtx } from './ctx';
|
|
8
|
+
export type { TableCtxRefType } from './table';
|
|
9
|
+
export type { EditableSchemaTableCtxType, EditableSchemaTableCtxType as EditTableCtxType, } from './ctx';
|
|
10
|
+
export { TableContainer, useTableContainer } from './container';
|
|
11
|
+
export { useRowVirtualizer, useColumnVirtualizer } from './container/hooks';
|
|
12
|
+
export type { TableStickyOpts, VirtualizeConfig } from './container';
|
|
13
|
+
export { BottomRender } from './container/bottom';
|
|
14
|
+
export type { BottomRenderConfigType } from './container/bottom';
|
|
15
|
+
export { validateHeaderCell } from './header/validate';
|
|
16
|
+
export { useTableSetting } from './features/setting-bridge';
|
|
17
|
+
export { useDataFetcher, defineDataFetcher } from './features/async-data';
|
|
18
|
+
export { ColumnCollapsingAction } from './features/header-actions';
|
|
19
|
+
export { TableRowController } from './features/row-controller';
|
|
20
|
+
export type { GetDataSourceType, GetDataSourceBasicParamsType, GetDataSourceParamsType, GetDataSourceResType, AsyncDataOptsType, } from './features/async-data';
|
|
21
|
+
export type { OpButtonConfigType, RowOperationOptsType } from './features/row-operation';
|
|
22
|
+
export type { RowSelectionOptsType } from './features/row-selection';
|
|
23
|
+
export type { TableRowControllerType } from './features/row-controller';
|
|
24
|
+
export type { UseTableSettingProps } from './features/setting-bridge';
|
|
25
|
+
export type { GetHeaderCellWrapperDynamicAttrsFnType } from './header';
|
|
26
|
+
export type { GetBodyCellWrapperDynamicAttrsFnType } from './body/wrapper';
|
|
27
|
+
export type { FieldCustomHeaderActionsFn, FieldCustomHeaderActionComponent, } from './features/header-actions/type';
|
|
28
|
+
export type { OpButtonRenderCtx } from './features/row-operation/buttons';
|
|
29
|
+
export type { BottomRenderCtxType } from './container/bottom';
|
|
30
|
+
export { normalizeValueFromChange } from './cell/editing';
|
|
31
|
+
export { clsPrefix } from './utils/cls';
|
|
32
|
+
export { ProEditTable, type ProEditTableProps, type FormEditTableToolbarCtxType, } from './field-bridge';
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TableMeta, TableOptions } from '@tanstack/react-table';
|
|
3
|
+
import type { StandardProps } from 'ahooks/es/useControllableValue';
|
|
4
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
5
|
+
import type { UseFieldMapOpts } from '@hi-ui/schema-fields';
|
|
6
|
+
import type { BoolConfig } from '@hi-ui/schema-utils';
|
|
7
|
+
import { type EditableSchemaTableCtxType, type InnerRefType } from './ctx';
|
|
8
|
+
import { type GlobalStaticActionsType } from './hooks/use-global-actions';
|
|
9
|
+
import { useGetFieldsValue, useGetGroupedValues } from './hooks/use-get-fields-value';
|
|
10
|
+
import { type RowSelectionOptsType } from './features/row-selection';
|
|
11
|
+
import { type PaginationProps } from './features/pagination';
|
|
12
|
+
import { type FilterOpts } from './features/filter/use-opts';
|
|
13
|
+
import { type SorterOpts } from './features/sorter/use-opts';
|
|
14
|
+
import { type ExpandedOpts } from './features/row-expanding';
|
|
15
|
+
import { type GroupingOpts } from './features/column-grouping';
|
|
16
|
+
import type { CustomCellType } from './cell/index';
|
|
17
|
+
import type { AsyncDataOptsType } from './features/async-data';
|
|
18
|
+
import type { RowOperationOptsType } from './features/row-operation';
|
|
19
|
+
import type { TableStickyOpts, VirtualizeConfig } from './container/index';
|
|
20
|
+
import type { HeaderActionOptsType } from './features/header-actions';
|
|
21
|
+
import type { BottomRenderConfigType } from './container/bottom';
|
|
22
|
+
import type { EditTableBodyProps, OnBodyRowMountedFn } from './body';
|
|
23
|
+
import './index.scss';
|
|
24
|
+
/** 对外暴露的表格上下文类型 */
|
|
25
|
+
export type TableCtxRefType<TData extends AnyObject = AnyObject> = Pick<EditableSchemaTableCtxType<TData>, 'table' | 'subscription' | 'rowActions'> & {
|
|
26
|
+
/** 触发内部重渲染 */
|
|
27
|
+
rerender: () => void;
|
|
28
|
+
/** 获取所有可编辑字段的值 */
|
|
29
|
+
getFieldsValue: ReturnType<typeof useGetFieldsValue<TData>>;
|
|
30
|
+
/** 获取分组后的所有可编辑字段的值和只读字段的值 */
|
|
31
|
+
getGroupedValues: ReturnType<typeof useGetGroupedValues<TData>>;
|
|
32
|
+
/** 滚动到顶部 */
|
|
33
|
+
scrollIntoView: (behavior?: ScrollBehavior) => void;
|
|
34
|
+
/** 获取异步数据源(仅获取数据) */
|
|
35
|
+
getDataSource: GlobalStaticActionsType<TData>['getDataSource'];
|
|
36
|
+
/** 更新异步数据源(获取数据并更新表格) */
|
|
37
|
+
updateDataSource: GlobalStaticActionsType<TData>['updateDataSource'];
|
|
38
|
+
/** 重置分页、筛选状态 */
|
|
39
|
+
resetDataSource: GlobalStaticActionsType<TData>['resetDataSource'];
|
|
40
|
+
/**
|
|
41
|
+
* 设置表格数据源
|
|
42
|
+
* - 本质是调用 subscription.setValue
|
|
43
|
+
* - 支持直接传入新值或者取值函数
|
|
44
|
+
* - 调用后将直接全量更新内部数据,并触发重渲染
|
|
45
|
+
* - 若有开启 enableForceRerender 还会触发强制重渲染
|
|
46
|
+
*/
|
|
47
|
+
setDataSource: GlobalStaticActionsType<TData>['setDataSource'];
|
|
48
|
+
/**
|
|
49
|
+
* 获取单元格值
|
|
50
|
+
* - 本质是调用 table.options.meta.getCellValue
|
|
51
|
+
*/
|
|
52
|
+
getCellValue: TableMeta<TData>['getCellValue'];
|
|
53
|
+
/**
|
|
54
|
+
* 设置单元格值
|
|
55
|
+
* - 本质是调用 table.options.meta.updateData
|
|
56
|
+
*/
|
|
57
|
+
setCellValue: TableMeta<TData>['updateData'];
|
|
58
|
+
/**
|
|
59
|
+
* 设置行选择状态
|
|
60
|
+
* - 传入数组时,选中指定行
|
|
61
|
+
* - 传入 null 时,清空所有选中的行
|
|
62
|
+
* - 传入函数时,调用者可获取当前选中的rowKeys,并自行返回新的rowKeys
|
|
63
|
+
* - 传入函数时,返回 null 也可清空所有选中的行
|
|
64
|
+
*/
|
|
65
|
+
setSelectedRowKeys: GlobalStaticActionsType<TData>['setSelectedRowKeys'];
|
|
66
|
+
/**
|
|
67
|
+
* 完整的内部上下文引用
|
|
68
|
+
* @desc 一般不应被外部读取,除非明确知道用途
|
|
69
|
+
*/
|
|
70
|
+
innerRef: InnerRefType<TData>;
|
|
71
|
+
};
|
|
72
|
+
type TableDebugOpts<T extends AnyObject> = Pick<TableOptions<T>, 'debugAll' | 'debugColumns' | 'debugHeaders' | 'debugCells' | 'debugRows' | 'debugTable'>;
|
|
73
|
+
export type EditableSchemaTableProps<TData extends AnyObject = AnyObject> = UseFieldMapOpts & Partial<StandardProps<TData[]>> & {
|
|
74
|
+
fields: FieldConfigType[];
|
|
75
|
+
asyncData?: AsyncDataOptsType<TData>;
|
|
76
|
+
innerCtxRef?: React.RefObject<TableCtxRefType<TData>>;
|
|
77
|
+
onValuesChange?: (changedValues: Record<number, Partial<TData>>, allValues: TData[]) => void;
|
|
78
|
+
getRowStyle?: EditTableBodyProps<TData>['getRowStyle'];
|
|
79
|
+
/** 是否默认激活全部可编辑单元格 */
|
|
80
|
+
defaultActive?: boolean;
|
|
81
|
+
/** 是否固定表头和表尾 */
|
|
82
|
+
sticky?: BoolConfig<TableStickyOpts>;
|
|
83
|
+
/** 虚拟化配置 */
|
|
84
|
+
virtualize?: BoolConfig<VirtualizeConfig>;
|
|
85
|
+
/** 是否展示表尾 */
|
|
86
|
+
showFooter?: boolean;
|
|
87
|
+
/** 调试配置 */
|
|
88
|
+
debug?: BoolConfig<TableDebugOpts<TData>>;
|
|
89
|
+
/**
|
|
90
|
+
* 是否开启强制重渲染
|
|
91
|
+
* - 通常用在存在复杂的表格行数据操作时
|
|
92
|
+
* - 启用后会在内部触发完全更新(即subscription.setValue)时,重新渲染整个表格
|
|
93
|
+
* - 原理是给表格顶层容器增加了 key 属性,从而触发整个表格的重新渲染
|
|
94
|
+
*/
|
|
95
|
+
enableForceRerender?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* 行唯一标识
|
|
98
|
+
* @desc 会根据行数据,取出【rowKey】的值作为唯一标识
|
|
99
|
+
* @desc 用于行选择、行操作等功能,默认使用【数组索引】作为唯一标识
|
|
100
|
+
* @desc 会在行 DOM 上增加 data-id 属性
|
|
101
|
+
* @desc 仅做展示时可不传,开启【行选择】【分页】等依赖行唯一标识的功能时,则必须传入
|
|
102
|
+
*/
|
|
103
|
+
rowKey?: string;
|
|
104
|
+
/**
|
|
105
|
+
* 子行在父行中的取值字段
|
|
106
|
+
* @desc 会从指定字段中取出【子行数据】
|
|
107
|
+
* @desc 用于树形表格,默认使用【children】作为子行取值字段
|
|
108
|
+
*/
|
|
109
|
+
subRowKey?: string;
|
|
110
|
+
/** 行选择配置 */
|
|
111
|
+
rowSelection?: BoolConfig<RowSelectionOptsType<TData>>;
|
|
112
|
+
/** 行操作配置 */
|
|
113
|
+
rowOperation?: BoolConfig<RowOperationOptsType<TData>>;
|
|
114
|
+
/** 是否开启只读模式 */
|
|
115
|
+
readonly?: boolean;
|
|
116
|
+
/** 分页配置 */
|
|
117
|
+
pagination?: BoolConfig<PaginationProps>;
|
|
118
|
+
/** 表头操作配置 */
|
|
119
|
+
headerAction?: HeaderActionOptsType;
|
|
120
|
+
/** 筛选配置 */
|
|
121
|
+
filter?: BoolConfig<FilterOpts>;
|
|
122
|
+
/** 排序配置 */
|
|
123
|
+
sorter?: BoolConfig<SorterOpts>;
|
|
124
|
+
/** 行展开配置 */
|
|
125
|
+
expanding?: BoolConfig<ExpandedOpts>;
|
|
126
|
+
/** 列分组配置 */
|
|
127
|
+
grouping?: BoolConfig<GroupingOpts>;
|
|
128
|
+
/** 是否显示边框 */
|
|
129
|
+
bordered?: boolean;
|
|
130
|
+
/** 底部的渲染配置 */
|
|
131
|
+
bottom?: BottomRenderConfigType;
|
|
132
|
+
/**
|
|
133
|
+
* 自定义单元格渲染
|
|
134
|
+
* - 目前仅开放聚合单元格
|
|
135
|
+
*/
|
|
136
|
+
customCell?: CustomCellType<TData>;
|
|
137
|
+
/** 自定义默认列配置 */
|
|
138
|
+
defaultColumn?: TableOptions<TData>['defaultColumn'];
|
|
139
|
+
/** 自定义表格功能 */
|
|
140
|
+
features?: TableOptions<TData>['_features'];
|
|
141
|
+
/** 自定义表格容器样式 */
|
|
142
|
+
wrapperStyle?: React.CSSProperties;
|
|
143
|
+
/** 内部事件的集中入口 */
|
|
144
|
+
on?: {
|
|
145
|
+
/** 行挂载后触发 */
|
|
146
|
+
rowMounted?: OnBodyRowMountedFn<TData>;
|
|
147
|
+
};
|
|
148
|
+
/** 自定义 react-table 引擎选项 */
|
|
149
|
+
customEngineOpts?: Partial<TableOptions<TData>>;
|
|
150
|
+
};
|
|
151
|
+
export declare function EditableSchemaTable<TData extends AnyObject>(props: EditableSchemaTableProps<TData>): JSX.Element;
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Column } from '@tanstack/react-table';
|
|
2
|
+
import type { EditableSchemaTableCtxType } from '../ctx';
|
|
3
|
+
type FixedStyleResult = {
|
|
4
|
+
className?: string[];
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
type GetFixedStyleOptsType = {
|
|
8
|
+
globalStaticRef: EditableSchemaTableCtxType['globalStaticRef'];
|
|
9
|
+
};
|
|
10
|
+
export declare function getFixedStyles<TData>(column: Column<TData>, opts: GetFixedStyleOptsType): FixedStyleResult;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Row, RowData } from '@tanstack/table-core';
|
|
2
|
+
/**
|
|
3
|
+
* 检查值是否为空值(包括null、undefined、'null'、'undefined'和空字符串)
|
|
4
|
+
*/
|
|
5
|
+
export declare function isEmptyValue(value: unknown): boolean;
|
|
6
|
+
export declare function getGroupedLeafRows<TData extends RowData>(rows: Row<TData>[]): Row<TData>[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type OnChangeFnCtxType<TState> = {
|
|
2
|
+
rawState: TState;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* 确保状态字段完整性,为被清空的字段添加默认值
|
|
6
|
+
* @param state 变化前的状态
|
|
7
|
+
* @param newState 变化后的状态
|
|
8
|
+
* @param stateKey 要设置默认值的字段名
|
|
9
|
+
* @param defaultValue 字段被清空时的默认值
|
|
10
|
+
* @returns 处理后的状态
|
|
11
|
+
*/
|
|
12
|
+
export declare function ensureStateFields<TState extends {
|
|
13
|
+
id: string;
|
|
14
|
+
}, TKey extends keyof TState, TValue extends TState[TKey]>(state: TState[], newState: TState[], stateKey: TKey, defaultValue: TValue | undefined): TState[];
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hi-ui/schema-editable-table",
|
|
3
|
+
"version": "4.0.0-experimental.1",
|
|
4
|
+
"description": "A sub-package for @hi-ui/schema.",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
7
|
+
"homepage": "https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"directories": {
|
|
10
|
+
"lib": "lib",
|
|
11
|
+
"test": "__tests__"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"lib",
|
|
15
|
+
"type.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"main": "lib/cjs/index.js",
|
|
18
|
+
"module": "lib/esm/index.js",
|
|
19
|
+
"types": "lib/types/index.d.ts",
|
|
20
|
+
"typings": "lib/types/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"require": "./lib/cjs/index.js",
|
|
24
|
+
"default": "./lib/esm/index.js"
|
|
25
|
+
},
|
|
26
|
+
"type": {
|
|
27
|
+
"types": "./type.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/XiaoMi/hiui.git"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"clean": "rimraf lib",
|
|
40
|
+
"prebuild": "yarn clean",
|
|
41
|
+
"build:esm": "hi-build ./src/index.ts --format esm -d ./lib/esm",
|
|
42
|
+
"build:cjs": "hi-build ./src/index.ts --format cjs -d ./lib/cjs",
|
|
43
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib/types",
|
|
44
|
+
"build": "concurrently yarn:build:*"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@hi-ui/schema-action-trigger": ">=4.0.0-experimental.1",
|
|
51
|
+
"@hi-ui/schema-core": ">=4.0.0-experimental.1",
|
|
52
|
+
"@hi-ui/schema-fields": ">=4.0.0-experimental.1",
|
|
53
|
+
"@hi-ui/schema-form": ">=4.0.0-experimental.1",
|
|
54
|
+
"@hi-ui/schema-hooks": ">=4.0.0-experimental.1",
|
|
55
|
+
"@hi-ui/schema-utils": ">=4.0.0-experimental.1",
|
|
56
|
+
"@hi-ui/schema-table-extensions": ">=4.0.0-experimental.1",
|
|
57
|
+
"@hi-ui/use-subscription": ">=4.0.0-experimental.1",
|
|
58
|
+
"immer": "^11.1.3",
|
|
59
|
+
"lodash-es": "^4.17.23"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@hi-ui/button": ">=5.0.0-experimental.0",
|
|
63
|
+
"@hi-ui/checkbox": ">=5.0.0-experimental.0",
|
|
64
|
+
"@hi-ui/classname": ">=5.0.0-experimental.0",
|
|
65
|
+
"@hi-ui/ellipsis-tooltip": ">=5.0.0-experimental.0",
|
|
66
|
+
"@hi-ui/icons": ">=5.0.0-experimental.0",
|
|
67
|
+
"@hi-ui/pagination": ">=5.0.0-experimental.0",
|
|
68
|
+
"@hi-ui/radio": ">=5.0.0-experimental.0",
|
|
69
|
+
"@hi-ui/schema-types": ">=4.0.0-experimental.1",
|
|
70
|
+
"@hi-ui/space": ">=5.0.0-experimental.0",
|
|
71
|
+
"@hi-ui/switch": ">=5.0.0-experimental.0",
|
|
72
|
+
"@hi-ui/tag": ">=5.0.0-experimental.0",
|
|
73
|
+
"@hi-ui/use-id": ">=5.0.0-experimental.0",
|
|
74
|
+
"@hi-ui/utility-types": ">=4.0.0-experimental.1",
|
|
75
|
+
"@tanstack/react-table": "^8.21.3",
|
|
76
|
+
"@tanstack/react-virtual": "^3.13.18",
|
|
77
|
+
"ahooks": "^3.9.6",
|
|
78
|
+
"react": ">=16.8.6"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@hi-ui/schema-types": ">=4.0.0-experimental.1",
|
|
82
|
+
"@hi-ui/utility-types": ">=4.0.0-experimental.1",
|
|
83
|
+
"@tanstack/react-table": "^8.21.3",
|
|
84
|
+
"@tanstack/react-virtual": "^3.13.18",
|
|
85
|
+
"react": "^17.0.2"
|
|
86
|
+
},
|
|
87
|
+
"volta": {
|
|
88
|
+
"node": "14.21.3"
|
|
89
|
+
}
|
|
90
|
+
}
|
package/type.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { RowData, Cell, RowSelectionState } from '@tanstack/react-table'
|
|
2
|
+
import type { ProFieldMapType } from '@hi-ui/schema-fields'
|
|
3
|
+
import type { SubscriptionType } from '@hi-ui/use-subscription'
|
|
4
|
+
import type {
|
|
5
|
+
FieldConfigType,
|
|
6
|
+
FieldControlType,
|
|
7
|
+
FieldFilterConfigType,
|
|
8
|
+
FieldGroupingConfigType,
|
|
9
|
+
FieldPayloadType,
|
|
10
|
+
FieldSorterConfigType,
|
|
11
|
+
} from '@hi-ui/schema-core'
|
|
12
|
+
import type { InnerRefType } from './src/ctx'
|
|
13
|
+
|
|
14
|
+
declare module '@tanstack/react-table' {
|
|
15
|
+
interface CoreInstance<TData extends RowData> {
|
|
16
|
+
$getInnerRef: () => InnerRefType<TData>
|
|
17
|
+
$getCell: (cellId: string) => Cell<TData, unknown> | null
|
|
18
|
+
/**
|
|
19
|
+
* 获取指定行的实时数据
|
|
20
|
+
* @desc 与 row.original 的区别在于,会返回内部订阅中的最新数据
|
|
21
|
+
*/
|
|
22
|
+
$getRealtimeRowData: (rowId: string) => TData | undefined
|
|
23
|
+
/**
|
|
24
|
+
* 缓存选中行的原始数据
|
|
25
|
+
* - key 为行 id, value 为行数据
|
|
26
|
+
* - 仅在开启 preserveSelectedRows 时有效
|
|
27
|
+
* - 其余时间仅为一个空 Map
|
|
28
|
+
*/
|
|
29
|
+
$selectedRowsCache: Map<string, TData>
|
|
30
|
+
/**
|
|
31
|
+
* 缓存当前选中状态
|
|
32
|
+
* - rows 为选中行的原始数据
|
|
33
|
+
* - keys 为选中行的 id
|
|
34
|
+
*/
|
|
35
|
+
$rowSelectionCache: {
|
|
36
|
+
selectedRows: TData[]
|
|
37
|
+
selectedRowKeys: string[]
|
|
38
|
+
selectedRowEntries: [string, TData][]
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 更新选中行原始数据的缓存
|
|
42
|
+
*/
|
|
43
|
+
$updateSelectedRowsCache: (entries: [string, TData][]) => void
|
|
44
|
+
/**
|
|
45
|
+
* 获取选中行的原始数据
|
|
46
|
+
* - 会根据行选中状态,返回内部订阅中的最新数据
|
|
47
|
+
*/
|
|
48
|
+
$getRowSelection: (state?: RowSelectionState) => {
|
|
49
|
+
selectedRows: TData[]
|
|
50
|
+
selectedRowKeys: string[]
|
|
51
|
+
selectedRowEntries: [string, TData][]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface CoreRow<TData extends RowData> {
|
|
56
|
+
/**
|
|
57
|
+
* 获取指定列的聚合后的值
|
|
58
|
+
*/
|
|
59
|
+
// 原因是内置的 getValue 在识别到指定列是分组列后
|
|
60
|
+
// 会直接返回列本身的值,而不是返回聚合后的值
|
|
61
|
+
$getAggregatedValue: <TValue>(columnId: string) => TValue | undefined
|
|
62
|
+
/**
|
|
63
|
+
* 获取指定行的实时数据
|
|
64
|
+
* @desc 与 row.original 的区别在于,会返回内部订阅中的最新数据
|
|
65
|
+
*/
|
|
66
|
+
// 与表格实例的 getRealtimeRowData 效果一致
|
|
67
|
+
$getRealtimeRowData: () => TData
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface CoreCell {
|
|
71
|
+
/**
|
|
72
|
+
* 获取指定列的聚合后的值
|
|
73
|
+
*/
|
|
74
|
+
// 与行的 getAggregateValue 效果一致
|
|
75
|
+
$getAggregatedValue: <TValue>() => TValue | undefined
|
|
76
|
+
/**
|
|
77
|
+
* 获取指定行的实时数据
|
|
78
|
+
* @desc 与 row.original 的区别在于,会返回内部订阅中的最新数据
|
|
79
|
+
*/
|
|
80
|
+
// 与表格实例的 getRealtimeRowData 效果一致
|
|
81
|
+
$getRealtimeRowData: () => TData
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface TableMeta<TData extends RowData>
|
|
85
|
+
extends Pick<FieldControlType, 'editable' | 'readonly' | 'disabled'> {
|
|
86
|
+
/** 表格数据订阅 */
|
|
87
|
+
subscription: SubscriptionType<TData[]>
|
|
88
|
+
fieldMap?: Partial<ProFieldMapType>
|
|
89
|
+
updateData: (rowIndex: number, columnId: string, value: unknown) => void
|
|
90
|
+
getCellValue: (rowIndex: number, columnId: string) => unknown
|
|
91
|
+
innerRef: InnerRefType<TData>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface ColumnMeta<TData extends RowData, TValue>
|
|
95
|
+
extends Pick<
|
|
96
|
+
FieldControlType,
|
|
97
|
+
| 'editable'
|
|
98
|
+
| 'readonly'
|
|
99
|
+
| 'disabled'
|
|
100
|
+
| 'simple'
|
|
101
|
+
| 'fixed'
|
|
102
|
+
| 'align'
|
|
103
|
+
| 'headerCell'
|
|
104
|
+
| 'bodyCell'
|
|
105
|
+
// 下面三个会被更下面的三处定义覆盖
|
|
106
|
+
| 'filter'
|
|
107
|
+
| 'sorter'
|
|
108
|
+
| 'grouping'
|
|
109
|
+
>,
|
|
110
|
+
Pick<FieldPayloadType, 'shouldUpdate'> {
|
|
111
|
+
field: FieldConfigType // 存储原始字段配置
|
|
112
|
+
filter?: FieldFilterConfigType
|
|
113
|
+
sorter?: FieldSorterConfigType
|
|
114
|
+
grouping?: FieldGroupingConfigType
|
|
115
|
+
_IGNORE_ME_?: (data: TData) => TValue // 防止泛型参数未被使用
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface ColumnDefBase<TData extends RowData, TValue = unknown> {
|
|
119
|
+
meta: ColumnMeta<TData, TValue>
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface PaginationState {
|
|
123
|
+
rowCount: number
|
|
124
|
+
/** 标记是否内部手动设置分页状态 */
|
|
125
|
+
$fromCustom?: boolean
|
|
126
|
+
}
|
|
127
|
+
interface PaginationInstance {
|
|
128
|
+
originalResetPagination: (defaultState?: boolean) => void
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface RowSelectionRow {
|
|
132
|
+
/** 切换行选择状态后,处理父行选中状态的逻辑 */
|
|
133
|
+
$afterToggleSelected: () => void
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface TableState {
|
|
137
|
+
/**
|
|
138
|
+
* 自定义的列折叠状态
|
|
139
|
+
* @desc 仅对存在子列的父列生效
|
|
140
|
+
*/
|
|
141
|
+
customColumnCollapsing?: Record<string, boolean>
|
|
142
|
+
}
|
|
143
|
+
}
|