@aspire-ui/element-component-pro 1.0.25 → 1.0.27

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.
Files changed (37) hide show
  1. package/dist/ProTableForm/CellEditor.vue.d.ts +33 -0
  2. package/dist/ProTableForm/ProTableForm.vue.d.ts +122 -102
  3. package/dist/ProTableForm/index.d.ts +4 -2
  4. package/dist/ProTableForm/types.d.ts +1 -69
  5. package/dist/ProTableForm/useProTableForm.d.ts +55 -0
  6. package/dist/element-component-pro.es.js +1433 -1255
  7. package/dist/element-component-pro.es.js.map +1 -1
  8. package/dist/element-component-pro.umd.js +2 -2
  9. package/dist/element-component-pro.umd.js.map +1 -1
  10. package/dist/index.d.ts +445 -282
  11. package/dist/style.css +1 -1
  12. package/dist/types/index.d.ts +227 -0
  13. package/docs/CollapseContainer.md +100 -0
  14. package/docs/ComponentSetting.md +113 -0
  15. package/docs/ProDescriptions.md +215 -0
  16. package/docs/ProForm.md +879 -0
  17. package/docs/ProTable-Redesign.md +214 -0
  18. package/docs/ProTable.md +556 -0
  19. package/docs/ProTableForm.md +207 -0
  20. package/docs/image.png +0 -0
  21. package/package.json +3 -2
  22. package/src/CollapseContainer/CollapseContainer.vue +1 -1
  23. package/src/ProDescriptions/ProDescriptions.vue +1 -1
  24. package/src/ProForm/FormActions.vue +1 -1
  25. package/src/ProForm/ProForm.vue +1 -1
  26. package/src/ProForm/ProFormItem.vue +1 -1
  27. package/src/ProForm/TreeSelect.vue +1 -1
  28. package/src/ProTable/ProTable.vue +1 -2
  29. package/src/ProTable/TableAction.vue +1 -1
  30. package/src/ProTableForm/CellEditor.vue +192 -0
  31. package/src/ProTableForm/ProTableForm.vue +350 -453
  32. package/src/ProTableForm/TableFormCell.vue +46 -0
  33. package/src/ProTableForm/index.ts +6 -7
  34. package/src/ProTableForm/types.ts +12 -72
  35. package/src/ProTableForm/useProTableForm.ts +442 -0
  36. package/src/index.ts +6 -4
  37. package/src/types/index.ts +241 -0
@@ -0,0 +1,33 @@
1
+ import { ProTableFormColumn, ProTableFormColumnChild, ProTableFormActionType } from '../types';
2
+
3
+ declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
4
+ col: ProTableFormColumn | ProTableFormColumnChild;
5
+ value: unknown;
6
+ /** 当前行数据,用于 dynamicComponentProps 动态求值 */
7
+ row?: Record<string, unknown>;
8
+ size?: "medium" | "small" | "large";
9
+ placeholder?: string;
10
+ /** ProTableForm 操作实例 */
11
+ action?: ProTableFormActionType;
12
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
13
+ update: (v: unknown) => void;
14
+ }, string, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
15
+ col: ProTableFormColumn | ProTableFormColumnChild;
16
+ value: unknown;
17
+ /** 当前行数据,用于 dynamicComponentProps 动态求值 */
18
+ row?: Record<string, unknown>;
19
+ size?: "medium" | "small" | "large";
20
+ placeholder?: string;
21
+ /** ProTableForm 操作实例 */
22
+ action?: ProTableFormActionType;
23
+ }>>>, {}>;
24
+ export default _default;
25
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
26
+ type __VLS_TypePropsToRuntimeProps<T> = {
27
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
28
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
29
+ } : {
30
+ type: import('vue').PropType<T[K]>;
31
+ required: true;
32
+ };
33
+ };
@@ -1,142 +1,162 @@
1
- import { ProTableFormActionColumn, ProTableFormColumn, ProTableFormFixedRow } from './types';
1
+ import { ProTableFormColumn, ProTableFormColumnChild } from '../types';
2
2
 
3
- /**
4
- * Vue 2 默认 v-model 绑定 value + input;本组件使用 modelValue(与 Vue 3 一致),需显式声明 model。
5
- */
6
3
  declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
7
- modelValue?: Record<string, unknown>;
4
+ modelValue?: Record<string, unknown>[];
8
5
  columns: ProTableFormColumn[];
9
- fixedRows: ProTableFormFixedRow[];
10
- competitorsKey?: string;
11
- competitorNameKey?: string;
12
- firstColumnTitle?: string;
13
- competitorNamePlaceholder?: string;
14
6
  metricPlaceholder?: string;
15
- addCompetitorText?: string;
16
- minCompetitors?: number;
7
+ minRows?: number;
17
8
  rules?: Record<string, unknown>;
18
9
  labelWidth?: string;
19
10
  bordered?: boolean;
20
- firstColMinWidth?: number;
21
- actionWidth?: number;
22
- showFirstColumn?: boolean;
23
- showActionColumn?: boolean;
24
- actionColumn?: ProTableFormActionColumn;
11
+ spanMethod?: (params: {
12
+ row: Record<string, unknown>;
13
+ column: {
14
+ property: string;
15
+ label: string;
16
+ };
17
+ rowIndex: number;
18
+ columnIndex: number;
19
+ }) => [number, number] | {
20
+ rowspan: number;
21
+ colspan: number;
22
+ } | void;
23
+ formSize?: "medium" | "small" | "large";
24
+ labelPosition?: "left" | "right" | "top";
25
+ disabled?: boolean;
26
+ stripe?: boolean;
27
+ size?: "medium" | "small" | "large";
28
+ maxHeight?: number | string;
29
+ height?: number | string;
30
+ rowClassName?: string | ((params: {
31
+ row: Record<string, unknown>;
32
+ rowIndex: number;
33
+ }) => string);
34
+ expandRowKeys?: (string | number)[];
35
+ defaultExpandAll?: boolean;
36
+ onRowClick?: (row: Record<string, unknown>, event: Event) => void;
37
+ onRowDblclick?: (row: Record<string, unknown>, event: Event) => void;
38
+ onSortChange?: (sortInfo: {
39
+ prop: string;
40
+ order: string;
41
+ }) => void;
42
+ onExpandChange?: (row: Record<string, unknown>, expanded: boolean) => void;
43
+ tableProps?: Record<string, unknown>;
44
+ formProps?: Record<string, unknown>;
25
45
  }>, {
26
- modelValue: () => {};
27
- competitorsKey: string;
28
- competitorNameKey: string;
29
- firstColumnTitle: string;
30
- competitorNamePlaceholder: string;
46
+ modelValue: () => never[];
31
47
  metricPlaceholder: string;
32
- addCompetitorText: string;
33
- minCompetitors: number;
48
+ minRows: number;
34
49
  labelWidth: string;
35
50
  bordered: boolean;
36
- firstColMinWidth: number;
37
- actionWidth: number;
38
- showFirstColumn: boolean;
39
- showActionColumn: boolean;
51
+ stripe: boolean;
52
+ size: string;
53
+ defaultExpandAll: boolean;
40
54
  }>, {
41
55
  validate: () => Promise<boolean>;
42
56
  clearValidate: (propsArg?: string | string[]) => void;
43
- addCompetitor: () => void;
44
- removeCompetitor: (index: number) => void;
57
+ addRow: () => void;
58
+ removeRow: (index: number) => void;
59
+ getRows: () => Record<string, unknown>[];
60
+ getRowCount: () => number;
61
+ getTable: () => {
62
+ clearSelection: () => void;
63
+ } | null;
64
+ getModelValue: () => Record<string, unknown>[];
65
+ setModelValue: (val: Record<string, unknown>[]) => void;
66
+ getFormRef: () => import('..').FormInstance | null;
45
67
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
46
- "update:modelValue": (v: Record<string, unknown>) => void;
68
+ "update:modelValue": (v: Record<string, unknown>[]) => void;
69
+ "add-row": () => void;
70
+ "remove-row": (index: number) => void;
71
+ register: (action: Record<string, unknown>) => void;
47
72
  }, string, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
48
- modelValue?: Record<string, unknown>;
73
+ modelValue?: Record<string, unknown>[];
49
74
  columns: ProTableFormColumn[];
50
- fixedRows: ProTableFormFixedRow[];
51
- competitorsKey?: string;
52
- competitorNameKey?: string;
53
- firstColumnTitle?: string;
54
- competitorNamePlaceholder?: string;
55
75
  metricPlaceholder?: string;
56
- addCompetitorText?: string;
57
- minCompetitors?: number;
76
+ minRows?: number;
58
77
  rules?: Record<string, unknown>;
59
78
  labelWidth?: string;
60
79
  bordered?: boolean;
61
- firstColMinWidth?: number;
62
- actionWidth?: number;
63
- showFirstColumn?: boolean;
64
- showActionColumn?: boolean;
65
- actionColumn?: ProTableFormActionColumn;
80
+ spanMethod?: (params: {
81
+ row: Record<string, unknown>;
82
+ column: {
83
+ property: string;
84
+ label: string;
85
+ };
86
+ rowIndex: number;
87
+ columnIndex: number;
88
+ }) => [number, number] | {
89
+ rowspan: number;
90
+ colspan: number;
91
+ } | void;
92
+ formSize?: "medium" | "small" | "large";
93
+ labelPosition?: "left" | "right" | "top";
94
+ disabled?: boolean;
95
+ stripe?: boolean;
96
+ size?: "medium" | "small" | "large";
97
+ maxHeight?: number | string;
98
+ height?: number | string;
99
+ rowClassName?: string | ((params: {
100
+ row: Record<string, unknown>;
101
+ rowIndex: number;
102
+ }) => string);
103
+ expandRowKeys?: (string | number)[];
104
+ defaultExpandAll?: boolean;
105
+ onRowClick?: (row: Record<string, unknown>, event: Event) => void;
106
+ onRowDblclick?: (row: Record<string, unknown>, event: Event) => void;
107
+ onSortChange?: (sortInfo: {
108
+ prop: string;
109
+ order: string;
110
+ }) => void;
111
+ onExpandChange?: (row: Record<string, unknown>, expanded: boolean) => void;
112
+ tableProps?: Record<string, unknown>;
113
+ formProps?: Record<string, unknown>;
66
114
  }>, {
67
- modelValue: () => {};
68
- competitorsKey: string;
69
- competitorNameKey: string;
70
- firstColumnTitle: string;
71
- competitorNamePlaceholder: string;
115
+ modelValue: () => never[];
72
116
  metricPlaceholder: string;
73
- addCompetitorText: string;
74
- minCompetitors: number;
117
+ minRows: number;
75
118
  labelWidth: string;
76
119
  bordered: boolean;
77
- firstColMinWidth: number;
78
- actionWidth: number;
79
- showFirstColumn: boolean;
80
- showActionColumn: boolean;
120
+ stripe: boolean;
121
+ size: string;
122
+ defaultExpandAll: boolean;
81
123
  }>>>, {
124
+ size: "medium" | "small" | "large";
82
125
  bordered: boolean;
83
- modelValue: Record<string, unknown>;
126
+ modelValue: Record<string, unknown>[];
84
127
  labelWidth: string;
85
- competitorsKey: string;
86
- competitorNameKey: string;
87
- firstColumnTitle: string;
88
- competitorNamePlaceholder: string;
128
+ defaultExpandAll: boolean;
89
129
  metricPlaceholder: string;
90
- addCompetitorText: string;
91
- minCompetitors: number;
92
- firstColMinWidth: number;
93
- actionWidth: number;
94
- showFirstColumn: boolean;
95
- showActionColumn: boolean;
96
- }>, Partial<Record<string, (_: {
97
- column: ProTableFormColumn;
98
- }) => any>> & Partial<Record<string, (_: {
99
- column: ProTableFormColumn;
130
+ minRows: number;
131
+ stripe: boolean;
132
+ }>, Partial<Record<`header-${string}`, (_: {
133
+ column: ProTableFormColumn & {
134
+ _key: string;
135
+ };
136
+ }) => any>> & Partial<Record<`header-${string}`, (_: {
137
+ column: ProTableFormColumnChild;
138
+ }) => any>> & Partial<Record<`cell-${string}`, (_: {
139
+ column: ProTableFormColumnChild;
100
140
  row: any;
141
+ index: any;
101
142
  value: unknown;
102
143
  updateValue: (v: unknown) => void;
103
- }) => any>> & Partial<Record<string, (_: {
104
- column: ProTableFormColumn;
144
+ }) => any>> & Partial<Record<`header-${string}`, (_: {
145
+ column: ProTableFormColumn & {
146
+ _key: string;
147
+ };
148
+ }) => any>> & Partial<Record<`cell-${string}`, (_: {
149
+ column: ProTableFormColumn & {
150
+ _key: string;
151
+ };
105
152
  row: any;
153
+ index: any;
106
154
  value: unknown;
107
155
  updateValue: (v: unknown) => void;
108
156
  }) => any>> & {
109
- firstColumnHeader?(_: {}): any;
110
- firstColumn?(_: {
111
- row: {
112
- _type: "fixed";
113
- rowKey: string;
114
- rowLabel: string;
115
- };
116
- rowType: "fixed";
117
- rowKey: string;
118
- rowLabel: string;
119
- rowIndex?: undefined;
120
- value?: undefined;
121
- updateValue?: undefined;
122
- } | {
123
- row: {
124
- _type: "competitor";
125
- _index: number;
126
- };
127
- rowType: "competitor";
128
- rowIndex: number;
129
- value: string;
130
- updateValue: (v: string) => void;
131
- rowKey?: undefined;
132
- rowLabel?: undefined;
133
- }): any;
134
- actionHeader?(_: {}): any;
135
157
  action?(_: {
136
- row: any;
137
- canDelete: boolean;
138
- addCompetitor: () => void;
139
- removeCompetitor: (index: number) => void;
158
+ addRow: () => void;
159
+ removeRow: (index: number) => void;
140
160
  }): any;
141
161
  }>;
142
162
  export default _default;
@@ -1,5 +1,7 @@
1
1
  import { default as ProTableForm } from './ProTableForm.vue';
2
+ import { useProTableForm } from './useProTableForm';
2
3
 
3
- export { ProTableForm };
4
- export type { ProTableFormColumn, ProTableFormFixedRow, ProTableFormProps, ProTableFormActionColumn, } from './types';
4
+ export { ProTableForm, useProTableForm };
5
+ export type { ProTableFormColumn, ProTableFormColumnChild } from '../types';
6
+ export type { ProTableFormBuiltInComponent, ProTableFormProps, ProTableFormActionType } from '../types';
5
7
  export default ProTableForm;
@@ -1,69 +1 @@
1
- /** 指标列(或含友商名称等任意 key) */
2
- export interface ProTableFormColumn {
3
- /** 对应 model 中对象字段名 */
4
- key: string;
5
- title: string;
6
- required?: boolean;
7
- /**
8
- * 单元格渲染方式:
9
- * - input / formatted-number:内置
10
- * - slot:使用具名插槽 `cell-{slotName}` 完全自定义
11
- */
12
- component?: 'input' | 'formatted-number' | 'slot';
13
- /**
14
- * component 为 slot 时必填,对应插槽名为 `cell-{slotName}`(如 slotName: 'score' → #cell-score)
15
- */
16
- slotName?: string;
17
- placeholder?: string;
18
- width?: number;
19
- minWidth?: number;
20
- /**
21
- * 透传给单元格组件。`component === 'formatted-number'` 时在此传入
22
- * `integerDigits`、`decimalPlaces`、`rounding`、`inputLimit` 等(与 FormattedNumberInput / ProForm 一致)。
23
- */
24
- componentProps?: Record<string, unknown>;
25
- /** 覆盖该列默认必填规则(与 Element 表单 rules 一致) */
26
- rules?: unknown[];
27
- }
28
- /** 固定行(首列为文案,不可删) */
29
- export interface ProTableFormFixedRow {
30
- rowKey: string;
31
- label: string;
32
- }
33
- /** 操作列配置(showActionColumn 为 true 时生效) */
34
- export interface ProTableFormActionColumn {
35
- width?: number;
36
- minWidth?: number;
37
- align?: 'left' | 'center' | 'right';
38
- fixed?: boolean | 'left' | 'right';
39
- /** 表头文案,使用默认「新增」按钮时显示在按钮左侧,可留空 */
40
- title?: string;
41
- }
42
- export interface ProTableFormProps {
43
- modelValue?: Record<string, unknown>;
44
- columns: ProTableFormColumn[];
45
- fixedRows: ProTableFormFixedRow[];
46
- competitorsKey?: string;
47
- /** 友商行「名称」字段,默认 name */
48
- competitorNameKey?: string;
49
- firstColumnTitle?: string;
50
- competitorNamePlaceholder?: string;
51
- metricPlaceholder?: string;
52
- addCompetitorText?: string;
53
- minCompetitors?: number;
54
- rules?: Record<string, unknown>;
55
- labelWidth?: string;
56
- bordered?: boolean;
57
- firstColMinWidth?: number;
58
- /**
59
- * 是否展示首列(维度/友商)。存在 fixedRows 时强制为 true。
60
- * 无固定行且为 false 时隐藏首列,需在 columns 中自行配置名称等字段。
61
- */
62
- showFirstColumn?: boolean;
63
- /** 是否展示操作列,默认 true */
64
- showActionColumn?: boolean;
65
- /** 操作列宽度(showActionColumn 时) */
66
- actionWidth?: number;
67
- /** 操作列详细配置 */
68
- actionColumn?: ProTableFormActionColumn;
69
- }
1
+ export type { ProTableFormColumn, ProTableFormColumnChild, ProTableFormActionColumn, ProTableFormProps, ProTableFormBuiltInComponent, TableActionButton, TableActionRender, ProTableFormActionType, ProTableFormRowType, } from '../types';
@@ -0,0 +1,55 @@
1
+ import { Ref, ComputedRef } from 'vue';
2
+ import { ProTableFormActionType, ProTableFormColumn, ProTableFormColumnChild, ProTableFormProps, FormInstance } from '../types';
3
+
4
+ export interface ProTableFormOptions {
5
+ props: Readonly<ProTableFormProps>;
6
+ emit: (event: 'update:modelValue', value: Record<string, unknown>[]) => void;
7
+ /** 新增行事件 */
8
+ emitAddRow?: () => void;
9
+ /** 删除行事件 */
10
+ emitRemoveRow?: (index: number) => void;
11
+ }
12
+ /** useProTableForm 返回 */
13
+ export interface UseProTableFormReturn {
14
+ register: (formAction: ProTableFormActionType) => void;
15
+ currentModelValue: ComputedRef<Record<string, unknown>[]>;
16
+ formModelRef: ComputedRef<{
17
+ rows: Record<string, unknown>[];
18
+ }>;
19
+ mergedRules: ComputedRef<Record<string, unknown[]>>;
20
+ tableRows: ComputedRef<TableRow[]>;
21
+ rowKeyFn: (row: TableRow) => string;
22
+ spanMethodAdapter: (params: {
23
+ row: TableRow;
24
+ column: {
25
+ property: string;
26
+ label: string;
27
+ };
28
+ rowIndex: number;
29
+ columnIndex: number;
30
+ }) => [number, number] | {
31
+ rowspan: number;
32
+ colspan: number;
33
+ } | void;
34
+ allLeafColumnKeys: ComputedRef<string[]>;
35
+ formRef: Ref<FormInstance | null>;
36
+ /** 获取 el-form 实例 */
37
+ getFormRef: () => FormInstance | null;
38
+ cellComponent: (col: ProTableFormColumn | ProTableFormColumnChild) => unknown;
39
+ cellBind: (col: ProTableFormColumn | ProTableFormColumnChild) => Record<string, unknown>;
40
+ slotUpdateHandler: (slotProps: {
41
+ row: TableRow;
42
+ }, col: ProTableFormColumn, childKey?: string) => (v: unknown) => void;
43
+ getCellProp: (tableRow: TableRow, col: ProTableFormColumn, childKey?: string) => string;
44
+ getCellValue: (row: TableRow, col: ProTableFormColumn, childKey?: string) => unknown;
45
+ setCellValue: (tableRow: TableRow, col: ProTableFormColumn, childKey: string | undefined, val: unknown) => void;
46
+ handleAddRow: () => void;
47
+ handleRemoveRow: (index: number) => void;
48
+ validate: () => Promise<boolean>;
49
+ clearValidate: (propsArg?: string | string[]) => void;
50
+ }
51
+ type TableRow = {
52
+ _index: number;
53
+ };
54
+ export declare function useProTableForm(options: ProTableFormOptions): UseProTableFormReturn;
55
+ export {};