@aplus-frontend/ui 0.0.12 → 0.0.13

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 (65) hide show
  1. package/es/index.mjs +166 -158
  2. package/es/src/ap-action/item/index.vue2.mjs +5 -5
  3. package/es/src/ap-form/ap-form.vue2.mjs +22 -22
  4. package/es/src/ap-table/ap-table.vue.d.ts +5 -1
  5. package/es/src/business/index.d.ts +126 -0
  6. package/es/src/business/index.mjs +8 -0
  7. package/es/src/business/title/ApTitle.vue.d.ts +45 -0
  8. package/es/src/business/title/ApTitle.vue.mjs +50 -0
  9. package/es/src/business/title/ApTitle.vue2.mjs +4 -0
  10. package/es/src/business/title/interface.d.ts +21 -0
  11. package/es/src/business/title/style.css +39 -0
  12. package/es/src/components.d.ts +1 -0
  13. package/es/src/editable-table/form-item.vue.d.ts +304 -0
  14. package/es/src/editable-table/form-item.vue.mjs +189 -0
  15. package/es/src/editable-table/form-item.vue2.mjs +4 -0
  16. package/es/src/editable-table/hooks/use-get-columns.d.ts +5 -0
  17. package/es/src/editable-table/hooks/use-get-columns.mjs +76 -0
  18. package/es/src/editable-table/index.d.ts +5 -0
  19. package/es/src/editable-table/index.mjs +3 -0
  20. package/es/src/editable-table/index.vue.d.ts +196 -0
  21. package/es/src/editable-table/index.vue.mjs +209 -0
  22. package/es/src/editable-table/index.vue2.mjs +4 -0
  23. package/es/src/editable-table/interface.d.ts +71 -6
  24. package/es/src/editable-table/interface.mjs +1 -0
  25. package/es/src/editable-table/style/index.css +35 -0
  26. package/es/src/editable-table/utils.mjs +10 -0
  27. package/es/src/index.d.ts +2 -0
  28. package/es/src/index.mjs +229 -220
  29. package/es/src/theme/antd-global-overwrite/admin/index.css +8 -0
  30. package/es/src/theme/antd-global-overwrite/admin/table.css +8 -0
  31. package/es/src/theme/ap-title/ap-title.css +39 -0
  32. package/es/src/theme/editable-table/index.css +35 -0
  33. package/lib/index.js +1 -1
  34. package/lib/src/ap-action/item/index.vue2.js +1 -1
  35. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  36. package/lib/src/ap-table/ap-table.vue.d.ts +5 -1
  37. package/lib/src/business/index.d.ts +126 -0
  38. package/lib/src/business/index.js +1 -0
  39. package/lib/src/business/title/ApTitle.vue.d.ts +45 -0
  40. package/lib/src/business/title/ApTitle.vue.js +1 -0
  41. package/lib/src/business/title/ApTitle.vue2.js +1 -0
  42. package/lib/src/business/title/interface.d.ts +21 -0
  43. package/lib/src/business/title/style.css +39 -0
  44. package/lib/src/components.d.ts +1 -0
  45. package/lib/src/editable-table/form-item.vue.d.ts +304 -0
  46. package/lib/src/editable-table/form-item.vue.js +1 -0
  47. package/lib/src/editable-table/form-item.vue2.js +1 -0
  48. package/lib/src/editable-table/hooks/use-get-columns.d.ts +5 -0
  49. package/lib/src/editable-table/hooks/use-get-columns.js +1 -0
  50. package/lib/src/editable-table/index.d.ts +5 -0
  51. package/lib/src/editable-table/index.js +1 -0
  52. package/lib/src/editable-table/index.vue.d.ts +196 -0
  53. package/lib/src/editable-table/index.vue.js +1 -0
  54. package/lib/src/editable-table/index.vue2.js +1 -0
  55. package/lib/src/editable-table/interface.d.ts +71 -6
  56. package/lib/src/editable-table/interface.js +1 -0
  57. package/lib/src/editable-table/style/index.css +35 -0
  58. package/lib/src/editable-table/utils.js +1 -0
  59. package/lib/src/index.d.ts +2 -0
  60. package/lib/src/index.js +1 -1
  61. package/lib/src/theme/antd-global-overwrite/admin/index.css +8 -0
  62. package/lib/src/theme/antd-global-overwrite/admin/table.css +8 -0
  63. package/lib/src/theme/ap-title/ap-title.css +39 -0
  64. package/lib/src/theme/editable-table/index.css +35 -0
  65. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  import { ColumnType, TableProps } from 'ant-design-vue/es/table';
2
2
  import { ApTableValueFields, ValueEnum } from '../ap-table';
3
- import { InternalNamePath, NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
3
+ import { NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
4
+ import { DataIndex } from 'ant-design-vue/es/vc-table/interface';
5
+ import { FormItemProps } from 'ant-design-vue';
4
6
 
5
7
  export type EditableColumnType<ValueType extends keyof ApTableValueFields = 'text', RecordType = any> = Omit<ColumnType<RecordType>, 'children'> & {
6
8
  /**
@@ -21,6 +23,7 @@ export type EditableColumnType<ValueType extends keyof ApTableValueFields = 'tex
21
23
  valueEnum?: ValueEnum;
22
24
  /**
23
25
  * 自定义表单
26
+ * @deprecated 未实现,请使用`customRender`
24
27
  */
25
28
  customRenderFormItem?: (config: EditableColumnType<ValueType, RecordType>) => any;
26
29
  /**
@@ -45,9 +48,13 @@ export type EditableTableProps<RecordType = any> = Omit<TableProps<RecordType>,
45
48
  */
46
49
  columns?: EditableColumnType<any, RecordType>[];
47
50
  /**
48
- * 同dataSource,传入的数组数据将作为表单的初始数据
51
+ * 表格数据v-model
49
52
  */
50
53
  value?: RecordType[];
54
+ /**
55
+ * 表格数据默认值(只生效一次,如果是异步数据,请使用`v-model`)
56
+ */
57
+ defaultValue?: RecordType[];
51
58
  'onUpdate:value'?: (value: RecordType[]) => void;
52
59
  /**
53
60
  * 数据修改时触发onChange(也包含数据的删除)
@@ -60,14 +67,72 @@ export type EditableTableProps<RecordType = any> = Omit<TableProps<RecordType>,
60
67
  */
61
68
  maxLength?: number;
62
69
  /**
63
- * 设置可编辑表格的名字,如果是作为其它表单的一部分,需要设置此字段
70
+ * 设置可编辑表格的名字,如果不传,将会使用默认值
64
71
  */
65
72
  name?: any;
73
+ /**
74
+ * 当字段值变更的时候触发(注意,向表单设置值并不会触发)
75
+ * @returns
76
+ */
77
+ onFieldChange?: (rowIndex: number, fieldName: DataIndex, newValue: any) => void;
78
+ };
79
+ export type EditableTableFormItemProps<RecordType = any> = Omit<EditableTableProps<RecordType>, 'name'> & {
80
+ label?: string;
81
+ /**
82
+ * FormItem的name 暂不支持传入数组类型
83
+ */
84
+ name: string;
85
+ /**
86
+ * 额外的表单项配置属性
87
+ */
88
+ formItem?: Partial<Omit<FormItemProps, 'name' | 'label'>>;
66
89
  };
67
- export type EditableTableExpose<ModelType = any> = {
90
+ export type EditableTableExpose<ModelType = any, RecordType = any> = {
91
+ /**
92
+ * 重设可编辑表格数据
93
+ * @param name
94
+ * @returns
95
+ */
68
96
  resetFields: (name?: NamePath) => void;
97
+ /**
98
+ * 作为单独的表单使用时,校验表格数据
99
+ * @param nameList
100
+ * @param options
101
+ * @returns
102
+ */
69
103
  validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
70
- getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
71
- add: (defaultValue?: any) => void;
104
+ /**
105
+ * 添加一行数据
106
+ * @param defaultValue
107
+ * @returns
108
+ */
109
+ add: (defaultValue?: Partial<RecordType>) => void;
110
+ /**
111
+ * 删除一行数据
112
+ * @param index
113
+ * @returns
114
+ */
72
115
  remove: (index: number) => void;
116
+ /**
117
+ * 获取所有行的数据
118
+ * @returns
119
+ */
120
+ getRowsData: () => RecordType[];
121
+ /**
122
+ * 获取指定行的数据
123
+ * @returns
124
+ */
125
+ getRowData: (index: number) => RecordType | undefined;
126
+ /**
127
+ * 设置表格行数据(数据会进行浅层合并)
128
+ * @param index
129
+ * @param data
130
+ * @returns
131
+ */
132
+ setRowData: (index: number, data: Partial<RecordType>) => void;
73
133
  };
134
+ /**
135
+ * 可编辑表格作为表单项暴露的实例
136
+ * @description 作为Form表单使用时不再暴露表单相关的API
137
+ */
138
+ export type EditableTableFormItemExpose<ModelType = any, RecordType = any> = Omit<EditableTableExpose<ModelType, RecordType>, 'resetFields' | 'validateFields'>;
@@ -5,7 +5,42 @@
5
5
  .aplus-editable-table .ant-form-item {
6
6
  margin-bottom: 20px;
7
7
  }
8
+ .aplus-editable-table .ant-form-item-explain-error {
9
+ line-height: 20px;
10
+ }
8
11
  .aplus-editable-table__header-cell--required {
9
12
  color: #FF4D4F;
10
13
  padding-right: 2px;
11
14
  }
15
+ .aplus-editable-table .ant-pagination {
16
+ margin-bottom: 0 !important;
17
+ }
18
+ .aplus-editable-table .ant-pagination .ant-pagination-total-text {
19
+ flex: 1;
20
+ }
21
+ .aplus-editable-table tr > th.ant-table-cell {
22
+ background-color: #F2F6F9;
23
+ border-bottom-color: #E9EDF3;
24
+ }
25
+ .aplus-editable-table tr > th.ant-table-cell::before {
26
+ display: none;
27
+ }
28
+ .aplus-editable-table tr > td.ant-table-cell {
29
+ border-top-color: #E9EDF3;
30
+ }
31
+ .aplus-editable-table-admin .ant-pagination {
32
+ margin-bottom: 0 !important;
33
+ }
34
+ .aplus-editable-table-admin .ant-pagination .ant-pagination-total-text {
35
+ flex: 1;
36
+ }
37
+ .aplus-editable-table-admin tr > th.ant-table-cell {
38
+ background-color: #FAFAFA;
39
+ border-bottom-color: #E9E9E9;
40
+ }
41
+ .aplus-editable-table-admin tr > th.ant-table-cell::before {
42
+ display: none;
43
+ }
44
+ .aplus-editable-table-admin tr > td.ant-table-cell {
45
+ border-top-color: #E9E9E9;
46
+ }
@@ -0,0 +1,10 @@
1
+ import { apTableFormItemMap as o } from "../ap-table/constants.mjs";
2
+ function r(e) {
3
+ const n = o[e];
4
+ return n || console.warn(
5
+ `${e} can not render because of no default renderer, use customRender instead.`
6
+ ), n;
7
+ }
8
+ export {
9
+ r as getEditableComponent
10
+ };
package/es/src/index.d.ts CHANGED
@@ -26,4 +26,6 @@ export * from './ap-tag';
26
26
  export * from './ap-layout';
27
27
  export * from './ap-upload';
28
28
  export * from './ap-download';
29
+ export * from './business';
29
30
  export * from './ap-table';
31
+ export * from './editable-table';