@aplus-frontend/ui 6.31.0 → 6.32.0

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 (154) hide show
  1. package/es/index.mjs +39 -37
  2. package/es/src/ag-grid/components/body-cell/index.vue2.mjs +14 -12
  3. package/es/src/ag-grid/editable/index.vue.d.ts +18 -0
  4. package/es/src/ag-grid/editable/index.vue.mjs +233 -0
  5. package/es/src/ag-grid/editable/index.vue2.mjs +4 -0
  6. package/es/src/ag-grid/editable/interface.d.ts +96 -0
  7. package/es/src/ag-grid/editable/interface.mjs +1 -0
  8. package/es/src/ag-grid/editable/style/css.d.ts +0 -0
  9. package/es/src/ag-grid/editable/style/css.js +1 -0
  10. package/es/src/ag-grid/editable/style/index.d.ts +0 -0
  11. package/es/src/ag-grid/editable/style/index.js +1 -0
  12. package/es/src/ag-grid/editable/utils.d.ts +5 -0
  13. package/es/src/ag-grid/editable/utils.mjs +23 -0
  14. package/es/src/ag-grid/hooks/use-editable-api.d.ts +15 -0
  15. package/es/src/ag-grid/hooks/use-editable-api.mjs +150 -0
  16. package/es/src/ag-grid/hooks/use-editable-columns.d.ts +6 -0
  17. package/es/src/ag-grid/hooks/use-editable-columns.mjs +96 -0
  18. package/es/src/ag-grid/hooks/use-editable-form-item-api.d.ts +14 -0
  19. package/es/src/ag-grid/index.d.ts +3 -1
  20. package/es/src/ag-grid/index.mjs +2 -0
  21. package/es/src/ag-grid/index.vue.mjs +70 -66
  22. package/es/src/ag-grid/interface.d.ts +20 -1
  23. package/es/src/ag-grid/utils.d.ts +2 -0
  24. package/es/src/ag-grid/utils.mjs +12 -7
  25. package/es/src/ap-field/date/index.vue.mjs +29 -28
  26. package/es/src/ap-field/radio/index.vue.d.ts +4 -0
  27. package/es/src/ap-field/radio/index.vue.mjs +9 -8
  28. package/es/src/ap-field/radio/read.vue2.mjs +5 -4
  29. package/es/src/ap-field/rate/index.vue.d.ts +20 -0
  30. package/es/src/ap-field/rate/index.vue.mjs +12 -11
  31. package/es/src/ap-form/interface.d.ts +4 -0
  32. package/es/src/ap-form/item/index.vue.mjs +41 -39
  33. package/es/src/ap-form/items/checkbox/index.vue.mjs +5 -5
  34. package/es/src/ap-form/items/date/index.vue.mjs +9 -9
  35. package/es/src/ap-form/items/date-range/index.vue.mjs +8 -8
  36. package/es/src/ap-form/items/number/index.vue.mjs +11 -11
  37. package/es/src/ap-form/items/radio/index.vue.d.ts +8 -0
  38. package/es/src/ap-form/items/radio/index.vue.mjs +6 -6
  39. package/es/src/ap-form/items/select/index.vue.mjs +3 -3
  40. package/es/src/ap-form/items/switch/index.vue.mjs +2 -2
  41. package/es/src/ap-form/items/text/index.vue2.mjs +12 -12
  42. package/es/src/ap-form/items/text/password.vue.mjs +2 -2
  43. package/es/src/ap-form/items/text-area/index.vue.d.ts +4 -4
  44. package/es/src/ap-form/items/text-area/index.vue.mjs +3 -3
  45. package/es/src/ap-form/items/tree-select/index.vue.mjs +6 -6
  46. package/es/src/ap-form/render/item.vue.mjs +6 -5
  47. package/es/src/ap-grid/utils/editable.d.ts +2 -1
  48. package/es/src/ap-table/constants.d.ts +4 -0
  49. package/es/src/ap-table/interface.d.ts +5 -0
  50. package/es/src/ap-table/utils.mjs +76 -71
  51. package/es/src/ap-upload/components/MultipleFile.vue.d.ts +10 -0
  52. package/es/src/business/ap-appendix/ap-appendix.vue2.mjs +67 -68
  53. package/es/src/business/ap-copy/ApCopy.d.ts +28 -1
  54. package/es/src/business/ap-copy/ApCopy.mjs +42 -38
  55. package/es/src/business/ap-copy/constans.d.ts +12 -0
  56. package/es/src/business/ap-copy/constans.mjs +13 -0
  57. package/es/src/business/ap-copy/index.d.ts +48 -3
  58. package/es/src/business/ap-copy/interface.d.ts +4 -1
  59. package/es/src/business/batch-input-group/form-item.vue.mjs +1 -1
  60. package/es/src/editable-table/utils.d.ts +3 -2
  61. package/es/src/index.mjs +42 -40
  62. package/es/src/version.d.ts +1 -1
  63. package/es/src/version.mjs +1 -1
  64. package/lib/index.js +1 -1
  65. package/lib/src/ag-grid/components/body-cell/index.vue2.js +1 -1
  66. package/lib/src/ag-grid/editable/index.vue.d.ts +18 -0
  67. package/lib/src/ag-grid/editable/index.vue.js +1 -0
  68. package/lib/src/ag-grid/editable/index.vue2.js +1 -0
  69. package/lib/src/ag-grid/editable/interface.d.ts +96 -0
  70. package/lib/src/ag-grid/editable/interface.js +1 -0
  71. package/lib/src/ag-grid/editable/style/css.cjs +1 -0
  72. package/lib/src/ag-grid/editable/style/css.d.ts +0 -0
  73. package/lib/src/ag-grid/editable/style/index.cjs +1 -0
  74. package/lib/src/ag-grid/editable/style/index.d.ts +0 -0
  75. package/lib/src/ag-grid/editable/utils.d.ts +5 -0
  76. package/lib/src/ag-grid/editable/utils.js +1 -0
  77. package/lib/src/ag-grid/hooks/use-editable-api.d.ts +15 -0
  78. package/lib/src/ag-grid/hooks/use-editable-api.js +1 -0
  79. package/lib/src/ag-grid/hooks/use-editable-columns.d.ts +6 -0
  80. package/lib/src/ag-grid/hooks/use-editable-columns.js +1 -0
  81. package/lib/src/ag-grid/hooks/use-editable-form-item-api.d.ts +14 -0
  82. package/lib/src/ag-grid/index.d.ts +3 -1
  83. package/lib/src/ag-grid/index.js +1 -1
  84. package/lib/src/ag-grid/index.vue.js +1 -1
  85. package/lib/src/ag-grid/interface.d.ts +20 -1
  86. package/lib/src/ag-grid/utils.d.ts +2 -0
  87. package/lib/src/ag-grid/utils.js +1 -1
  88. package/lib/src/ap-field/date/index.vue.js +1 -1
  89. package/lib/src/ap-field/radio/index.vue.d.ts +4 -0
  90. package/lib/src/ap-field/radio/index.vue.js +1 -1
  91. package/lib/src/ap-field/radio/read.vue2.js +1 -1
  92. package/lib/src/ap-field/rate/index.vue.d.ts +20 -0
  93. package/lib/src/ap-field/rate/index.vue.js +1 -1
  94. package/lib/src/ap-form/interface.d.ts +4 -0
  95. package/lib/src/ap-form/item/index.vue.js +1 -1
  96. package/lib/src/ap-form/items/checkbox/index.vue.js +1 -1
  97. package/lib/src/ap-form/items/date/index.vue.js +1 -1
  98. package/lib/src/ap-form/items/date-range/index.vue.js +1 -1
  99. package/lib/src/ap-form/items/number/index.vue.js +1 -1
  100. package/lib/src/ap-form/items/radio/index.vue.d.ts +8 -0
  101. package/lib/src/ap-form/items/radio/index.vue.js +1 -1
  102. package/lib/src/ap-form/items/select/index.vue.js +1 -1
  103. package/lib/src/ap-form/items/switch/index.vue.js +1 -1
  104. package/lib/src/ap-form/items/text/index.vue2.js +1 -1
  105. package/lib/src/ap-form/items/text/password.vue.js +1 -1
  106. package/lib/src/ap-form/items/text-area/index.vue.d.ts +4 -4
  107. package/lib/src/ap-form/items/text-area/index.vue.js +1 -1
  108. package/lib/src/ap-form/items/tree-select/index.vue.js +1 -1
  109. package/lib/src/ap-form/render/item.vue.js +1 -1
  110. package/lib/src/ap-grid/utils/editable.d.ts +2 -1
  111. package/lib/src/ap-table/constants.d.ts +4 -0
  112. package/lib/src/ap-table/interface.d.ts +5 -0
  113. package/lib/src/ap-table/utils.js +1 -1
  114. package/lib/src/ap-upload/components/MultipleFile.vue.d.ts +10 -0
  115. package/lib/src/business/ap-appendix/ap-appendix.vue2.js +1 -1
  116. package/lib/src/business/ap-copy/ApCopy.d.ts +28 -1
  117. package/lib/src/business/ap-copy/ApCopy.js +1 -1
  118. package/lib/src/business/ap-copy/constans.d.ts +12 -0
  119. package/lib/src/business/ap-copy/constans.js +1 -1
  120. package/lib/src/business/ap-copy/index.d.ts +48 -3
  121. package/lib/src/business/ap-copy/interface.d.ts +4 -1
  122. package/lib/src/business/batch-input-group/form-item.vue.js +1 -1
  123. package/lib/src/editable-table/utils.d.ts +3 -2
  124. package/lib/src/index.js +1 -1
  125. package/lib/src/version.d.ts +1 -1
  126. package/lib/src/version.js +1 -1
  127. package/package.json +3 -3
  128. package/theme/ag-grid/editable.css +52 -0
  129. package/theme/ag-grid/editable.less +11 -0
  130. package/theme/ag-grid/index.css +18 -0
  131. package/theme/ag-grid/index.less +1 -0
  132. package/theme/ap-appendix/ap-appendix.css +4 -13
  133. package/theme/ap-appendix/ap-appendix.less +5 -12
  134. package/theme/ap-form/ap-form-item.css +12 -0
  135. package/theme/ap-form/ap-form-item.less +12 -0
  136. package/theme/ap-form/index.css +12 -0
  137. package/theme/ap-form/search-form.css +12 -0
  138. package/theme/ap-grid/editable.css +1 -0
  139. package/theme/ap-grid/editable.less +1 -0
  140. package/theme/ap-grid/index.css +13 -0
  141. package/theme/ap-grid/index.less +1 -0
  142. package/theme/ap-table/ap-table.css +12 -0
  143. package/theme/ap-table-modal/index.css +12 -0
  144. package/theme/editable-table/index.css +13 -0
  145. package/theme/editable-table/index.less +1 -0
  146. package/theme/index.css +25 -13
  147. package/es/src/business/ap-appendix/icons/empty-admin-icon.vue.d.ts +0 -3
  148. package/es/src/business/ap-appendix/icons/empty-admin-icon.vue.mjs +0 -20
  149. package/es/src/business/ap-appendix/icons/empty-aplus-icon.vue.d.ts +0 -3
  150. package/es/src/business/ap-appendix/icons/empty-aplus-icon.vue.mjs +0 -20
  151. package/lib/src/business/ap-appendix/icons/empty-admin-icon.vue.d.ts +0 -3
  152. package/lib/src/business/ap-appendix/icons/empty-admin-icon.vue.js +0 -1
  153. package/lib/src/business/ap-appendix/icons/empty-aplus-icon.vue.d.ts +0 -3
  154. package/lib/src/business/ap-appendix/icons/empty-aplus-icon.vue.js +0 -1
@@ -0,0 +1,150 @@
1
+ import { shallowRef as _, computed as S, unref as d, isRef as z } from "vue";
2
+ import { isDef as K } from "../../utils/index.mjs";
3
+ import { isFunction as x, isUndefined as A, isNumber as h, cloneDeep as E, isArray as I, isString as N } from "lodash-unified";
4
+ import { arrayToObject as U } from "../editable/utils.mjs";
5
+ let $ = 0;
6
+ function R() {
7
+ return `_ag_grid${$++}`;
8
+ }
9
+ const J = (n, g, i, m) => {
10
+ const w = _([]), y = S(() => z(g) ? d(g) : g);
11
+ function F(u, l) {
12
+ const r = d(i)?.length || 0;
13
+ if (K(n.maxLength) && r >= n.maxLength || !u && x(n.rowKey))
14
+ return;
15
+ const f = {
16
+ ...u || { [n.rowKey]: R() }
17
+ };
18
+ y.value?.setFieldValue?.(
19
+ n.name,
20
+ f,
21
+ !0,
22
+ (o, s) => {
23
+ const e = c(f, void 0, n.rowKey);
24
+ if (o[s] ? o[s][e] = f : o[s] = { [e]: f }, !i.value?.length) {
25
+ i.value = [f];
26
+ return;
27
+ }
28
+ A(l) ? i.value.push(f) : (w.value = i.value.map(
29
+ (t, v) => v < l ? null : c(t, v, n.rowKey)
30
+ ).filter(Boolean), i.value.splice(l, 0, f));
31
+ }
32
+ );
33
+ }
34
+ function j(u, l = "suffix") {
35
+ const r = d(i)?.length || 0, f = h(u) ? u : u.length;
36
+ if (K(n.maxLength) && r + f > n.maxLength || h(u) && x(n.rowKey))
37
+ return;
38
+ const o = h(u) ? new Array(u).fill(0).map(() => ({ [n.rowKey]: R() })) : E(u), s = U(o, n.rowKey);
39
+ y.value?.setFieldValue?.(
40
+ n.name,
41
+ o,
42
+ !0,
43
+ (e, t) => {
44
+ if (e[t] ? Object.assign(e[t], s) : e[t] = s, !i.value?.length) {
45
+ i.value = [...o];
46
+ return;
47
+ }
48
+ l === "suffix" ? i.value.push(...o) : (w.value = i.value.map(
49
+ (v, T) => c(v, T, n.rowKey)
50
+ ), i.value.unshift(...o));
51
+ }
52
+ );
53
+ }
54
+ function k(u) {
55
+ const l = I(u) ? u : [u];
56
+ y.value?.setFieldValue?.(
57
+ n.name,
58
+ void 0,
59
+ !0,
60
+ (r, f) => {
61
+ for (const e of l) {
62
+ const t = c(e, void 0, n.rowKey);
63
+ delete r[f][t];
64
+ }
65
+ const o = i.value.filter(
66
+ (e) => !l.includes(e)
67
+ ), s = i.value.findIndex(
68
+ (e) => l.includes(e)
69
+ );
70
+ w.value = i.value.map(
71
+ (e, t) => t <= s ? null : c(e, t, n.rowKey)
72
+ ).filter(Boolean), m?.(o);
73
+ }
74
+ );
75
+ }
76
+ function c(u, l, r) {
77
+ if (r)
78
+ return N(r) ? u[r] : r(u, l);
79
+ }
80
+ function L(u) {
81
+ const l = new Set(I(u) ? u : [u]);
82
+ l.size !== 0 && y.value?.setFieldValue?.(
83
+ n.name,
84
+ void 0,
85
+ !0,
86
+ (r, f) => {
87
+ for (const e of l)
88
+ delete r[f][e];
89
+ const o = i.value.filter(
90
+ (e, t) => !l.has(c(e, t, n.rowKey))
91
+ ), s = i.value.findIndex(
92
+ (e, t) => l.has(c(e, t, n.rowKey))
93
+ );
94
+ w.value = i.value.map(
95
+ (e, t) => t <= s ? null : c(e, t, n.rowKey)
96
+ ).filter(Boolean), m?.(o);
97
+ }
98
+ );
99
+ }
100
+ function O(u) {
101
+ return d(i)?.[u];
102
+ }
103
+ function V() {
104
+ return d(i);
105
+ }
106
+ function B(u, l, r = !0) {
107
+ y.value?.setFieldValue?.(
108
+ n.name,
109
+ void 0,
110
+ !0,
111
+ (f, o) => {
112
+ const s = i.value.findIndex(
113
+ (t, v) => u === v
114
+ );
115
+ if (!~s)
116
+ return;
117
+ const e = c(
118
+ i.value[s],
119
+ s,
120
+ n.rowKey
121
+ );
122
+ if (e && !(!f[o] || !f[o][e])) {
123
+ if (!r) {
124
+ const t = Object.keys(f[o][e]);
125
+ for (const v of t)
126
+ v !== n.rowKey && delete f[o][e][v];
127
+ }
128
+ Object.assign(f[o][e], { ...l });
129
+ }
130
+ }
131
+ );
132
+ }
133
+ function a() {
134
+ y.value?.setFieldValue?.(n.name, {}), m?.([]);
135
+ }
136
+ return {
137
+ add: F,
138
+ addMultiple: j,
139
+ remove: k,
140
+ removeByKey: L,
141
+ getRowData: O,
142
+ getRowsData: V,
143
+ setRowData: B,
144
+ clear: a,
145
+ refreshRowIds: w
146
+ };
147
+ };
148
+ export {
149
+ J as useEditableApi
150
+ };
@@ -0,0 +1,6 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { EditableAgGridProps } from '../editable/interface';
3
+ import { ValueTypeRenderConfig } from '../../config-provider';
4
+ import { AgGridColumnType } from '../interface';
5
+ export declare const useGetEditableColumns: (props: EditableAgGridProps, extraValueTypes: Ref<Record<string, ValueTypeRenderConfig> | undefined>, shadowName?: string) => ComputedRef<AgGridColumnType[]>;
6
+ export default useGetEditableColumns;
@@ -0,0 +1,96 @@
1
+ import { unref as w, computed as E } from "vue";
2
+ import { isFunction as F, isArray as g } from "lodash-unified";
3
+ import { mergeClass as p, getColumnIsRequired as v } from "../../editable-table/utils.mjs";
4
+ import { updateFormProps as y, getFieldProps as q } from "../../ap-table/utils.mjs";
5
+ import { getFinalEditableNode as A } from "../../ap-grid/utils/editable.mjs";
6
+ import { isDef as K } from "../../utils/index.mjs";
7
+ import { getRowKey as M } from "../editable/utils.mjs";
8
+ function m(t, r, n) {
9
+ t.__skipNextRefresh ? t.__skipNextRefresh[r] = n : t.__skipNextRefresh = { [r]: n };
10
+ }
11
+ function D(t, r, n) {
12
+ t.__prevEditable ? t.__prevEditable[r] = n : t.__prevEditable = { [r]: n };
13
+ }
14
+ const J = (t, r, n) => {
15
+ function h(e) {
16
+ return !e.editable || e.children?.length ? {} : {
17
+ customRender({ value: f, originalNode: d, params: o, ...i }) {
18
+ const s = F(e.editable) ? e.editable(
19
+ i.text,
20
+ i.record,
21
+ i.rowIndex
22
+ ) : !!e.editable;
23
+ let c = d;
24
+ if (s) {
25
+ const u = y(
26
+ e,
27
+ q(e.fieldProps, {
28
+ value: f,
29
+ ...i
30
+ })
31
+ ), b = {};
32
+ t.onFieldChange && (b[`onUpdate:${u.valuePropName || "value"}`] = (k) => t.onFieldChange?.(
33
+ i.rowIndex,
34
+ e.dataIndex,
35
+ k
36
+ ));
37
+ const I = g(e.dataIndex) ? e.dataIndex : [e.dataIndex], C = n ? [n] : g(t.name) ? t.name : [t.name], R = M(
38
+ i.record,
39
+ i.rowIndex,
40
+ t.rowKey
41
+ ), N = {
42
+ name: [...C, String(R), ...I],
43
+ ...u || {},
44
+ field: {
45
+ style: "width: 100%",
46
+ ...u?.field || {},
47
+ ...b,
48
+ class: p("is-editable", u.class)
49
+ }
50
+ };
51
+ c = A(
52
+ e,
53
+ N,
54
+ i.record,
55
+ w(r)
56
+ );
57
+ }
58
+ e.customRender && (c = e.customRender({
59
+ value: f,
60
+ ...i,
61
+ editable: s,
62
+ originalNode: c,
63
+ index: i.rowIndex,
64
+ renderIndex: i.rowIndex
65
+ }));
66
+ const a = o.node, l = o.column.getColId(), _ = a.__prevEditable?.[l];
67
+ return !a.__skipNextRefresh?.[l] && K(_) && _ !== s && (m(a, l, !0), setTimeout(() => {
68
+ o?.api.refreshCells({
69
+ rowNodes: [o.node],
70
+ columns: [o.column.getColId()],
71
+ force: !0
72
+ }), m(a, l, !1);
73
+ }, 0)), D(a, l, s), c;
74
+ }
75
+ };
76
+ }
77
+ return E(() => {
78
+ const e = t.columns;
79
+ if (!e)
80
+ return [];
81
+ function x(f) {
82
+ return f.map((d) => ({
83
+ ...d,
84
+ _requireMark: v(d),
85
+ children: x(d.children || []),
86
+ // 处理可编辑/不可编辑下的单元格渲染
87
+ ...h(d)
88
+ }));
89
+ }
90
+ return x(e);
91
+ });
92
+ };
93
+ export {
94
+ J as default,
95
+ J as useGetEditableColumns
96
+ };
@@ -0,0 +1,14 @@
1
+ import { Ref } from 'vue';
2
+ import { ApFormInternalInstance } from '../../ap-form';
3
+ import { EditableAgGridProps } from '../editable/interface';
4
+ import { Key } from '@aplus-frontend/antdv/es/_util/type';
5
+ export declare const useEditableFormItemApi: <RecordType>(props: EditableAgGridProps<RecordType>, formApi: ApFormInternalInstance | undefined, tableData: Ref<RecordType[]>, shadowName: string) => {
6
+ add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
7
+ addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
8
+ remove: (data: RecordType | RecordType[]) => void;
9
+ removeByKey: (key: Key | Key[]) => void;
10
+ getRowData: (index: number) => RecordType;
11
+ getRowsData: () => RecordType[];
12
+ setRowData: (index: number, payload: any, merge?: boolean) => void;
13
+ clear: () => void;
14
+ };
@@ -1,3 +1,5 @@
1
1
  import { default as AgGrid } from './index.vue';
2
- export { AgGrid };
2
+ import { default as EditableAgGrid } from './editable/index.vue';
3
+ export { AgGrid, EditableAgGrid };
3
4
  export * from './interface';
5
+ export * from './editable/interface';
@@ -1,2 +1,4 @@
1
1
  import "./index.vue2.mjs";
2
+ import "./editable/index.vue2.mjs";
2
3
  import "./interface.mjs";
4
+ import "./editable/interface.mjs";
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as eo, useSlots as oo, ref as I, toRef as T, unref as t, computed as l, nextTick as to, watch as z, createElementBlock as A, openBlock as b, normalizeStyle as V, normalizeClass as m, createCommentVNode as re, createElementVNode as B, createVNode as M, mergeProps as O, createSlots as ro, withCtx as ae, Fragment as ao, renderList as no, createBlock as ne, resolveDynamicComponent as lo, renderSlot as le, withDirectives as so, vShow as io } from "vue";
2
- import { AgGridVue as co } from "ag-grid-vue3";
3
- import { ModuleRegistry as uo, AllCommunityModule as mo } from "ag-grid-community";
2
+ import { AgGridVue as uo } from "ag-grid-vue3";
3
+ import { ModuleRegistry as co, AllCommunityModule as mo } from "ag-grid-community";
4
4
  import { mergeProps as po } from "./utils.mjs";
5
5
  import { Spin as fo, Pagination as go } from "@aplus-frontend/antdv";
6
6
  import { isUndefined as F, isFunction as se } from "lodash-unified";
@@ -26,7 +26,7 @@ import Ko from "./hooks/use-selection-col-def.mjs";
26
26
  import { useNamespace as Po } from "../config-provider/hooks/use-namespace.mjs";
27
27
  import { useGlobalConfig as zo } from "../config-provider/hooks/use-global-config.mjs";
28
28
  import Ao from "./components/empty/index.vue2.mjs";
29
- const ut = /* @__PURE__ */ eo({
29
+ const ct = /* @__PURE__ */ eo({
30
30
  name: "AgGrid",
31
31
  __name: "index",
32
32
  props: {
@@ -95,16 +95,18 @@ const ut = /* @__PURE__ */ eo({
95
95
  onRowClicked: {},
96
96
  onScrollEnd: {},
97
97
  rowClassName: {},
98
- rowClassRules: {}
98
+ rowClassRules: {},
99
+ autoHeight: { type: Boolean },
100
+ onUpdate: {}
99
101
  },
100
- setup(de, { expose: ce }) {
101
- uo.registerModules([mo]);
102
- const o = de, G = oo(), { e: k, b: c, be: ue } = Po("ag-grid"), y = I(o.size), me = Fo(y, T(o, "rowHeight")), pe = Do(T(o, "virtual")), { rowPinnedGridConfig: L, getRowPinnedCellClass: fe } = Eo(
102
+ setup(de, { expose: ue }) {
103
+ co.registerModules([mo]);
104
+ const o = de, G = oo(), { e: k, b: u, be: ce } = Po("ag-grid"), y = I(o.size), me = Fo(y, T(o, "rowHeight")), pe = Do(T(o, "virtual")), { rowPinnedGridConfig: H, getRowPinnedCellClass: fe } = Eo(
103
105
  T(o, "summary")
104
- ), ge = zo("apGrid"), i = I(), [, we] = Bo();
106
+ ), ge = zo("apGrid"), s = I(), [, we] = Bo();
105
107
  let p = !!o.dataSource;
106
- const W = No(o), { shownColumns: f, columns: j, columnKeys: Se, getTargetColumnByKey: ye } = ko(o), { defaultColDef: Ce, columnDefs: he } = xo(
107
- j,
108
+ const L = No(o), { shownColumns: f, columns: U, columnKeys: Se, getTargetColumnByKey: ye } = ko(o), { defaultColDef: Ce, columnDefs: he } = xo(
109
+ U,
108
110
  o,
109
111
  fe
110
112
  ), x = I({});
@@ -119,19 +121,19 @@ const ut = /* @__PURE__ */ eo({
119
121
  desc: "descend"
120
122
  };
121
123
  function Re() {
122
- const e = i.value.getColumns()?.filter((u) => u.getSort() !== void 0), r = t(x) || {};
124
+ const e = s.value.getColumns()?.filter((c) => c.getSort() !== void 0), r = t(x) || {};
123
125
  let a = e?.[0];
124
126
  const d = Object.keys(r);
125
- if (d.length && d.every((u) => r[u] === null)) {
126
- const u = Object.keys(r)[0];
127
- u && (a = i.value?.getColumn(u));
127
+ if (d.length && d.every((c) => r[c] === null)) {
128
+ const c = Object.keys(r)[0];
129
+ c && (a = s.value?.getColumn(c));
128
130
  }
129
131
  if (!a)
130
132
  return;
131
- const s = a.getColDef(), S = a.getSort(), v = ye(s.colId);
132
- H(void 0, void 0, {
133
- column: s,
134
- field: v?.field ?? s.field ?? s.colId,
133
+ const i = a.getColDef(), S = a.getSort(), v = ye(i.colId);
134
+ j(void 0, void 0, {
135
+ column: i,
136
+ field: v?.field ?? i.field ?? i.colId,
135
137
  order: S ? ve[S] : null
136
138
  });
137
139
  }
@@ -140,7 +142,7 @@ const ut = /* @__PURE__ */ eo({
140
142
  return e.field ?? e.dataIndex ?? e.key;
141
143
  }).filter(Boolean)), Be = () => {
142
144
  x.value = {};
143
- const e = i.value;
145
+ const e = s.value;
144
146
  if (!e)
145
147
  return;
146
148
  const r = e.getColumnState()?.map((a) => ({ ...a, sort: null }));
@@ -150,8 +152,8 @@ const ut = /* @__PURE__ */ eo({
150
152
  submit: N,
151
153
  reset: D,
152
154
  data: w,
153
- tableProps: U,
154
- handleTableChangeOptional: H,
155
+ tableProps: W,
156
+ handleTableChangeOptional: j,
155
157
  submitWith: $,
156
158
  refresh: q,
157
159
  getPaging: ke,
@@ -218,9 +220,9 @@ const ut = /* @__PURE__ */ eo({
218
220
  return se(o.rowKey) ? o.rowKey(e) : e[o.rowKey];
219
221
  }
220
222
  const J = ({
221
- api: e = i.value
223
+ api: e = s.value
222
224
  }) => {
223
- if (!C.value)
225
+ if (o.onUpdate?.(), !C.value)
224
226
  return;
225
227
  const r = E.value;
226
228
  if (!r.length) {
@@ -232,8 +234,8 @@ const ut = /* @__PURE__ */ eo({
232
234
  p = !1;
233
235
  const a = [];
234
236
  e.forEachNode((d) => {
235
- const h = d.data, s = K(h);
236
- r.find((S) => K(S) === s) && a.push(d);
237
+ const h = d.data, i = K(h);
238
+ r.find((S) => K(S) === i) && a.push(d);
237
239
  }), e.setNodesSelected({ nodes: a, newValue: !0 }), setTimeout(() => {
238
240
  p = !0;
239
241
  }, 0);
@@ -242,7 +244,7 @@ const ut = /* @__PURE__ */ eo({
242
244
  }, Oe = () => {
243
245
  p = !0;
244
246
  }, P = () => {
245
- Pe(), i.value?.deselectAll();
247
+ Pe(), s.value?.deselectAll();
246
248
  };
247
249
  function Ge(e) {
248
250
  ze(e), to(() => {
@@ -268,8 +270,8 @@ const ut = /* @__PURE__ */ eo({
268
270
  function ee(e) {
269
271
  return e && String(e);
270
272
  }
271
- function Le(e) {
272
- const r = i.value;
273
+ function He(e) {
274
+ const r = s.value;
273
275
  if (!r)
274
276
  return;
275
277
  const a = r.getColumnState() || [], d = e.map((n) => n.key ? String(n.key) : n.key).filter(Boolean), h = a.map((n) => {
@@ -282,14 +284,14 @@ const ut = /* @__PURE__ */ eo({
282
284
  (_e) => ee(_e.key) === n.colId
283
285
  );
284
286
  return te && (oe.pinned = te.fixed || null), oe;
285
- }), s = new Map(
287
+ }), i = new Map(
286
288
  e.map((n, R) => [ee(n.key), R])
287
- ), S = h.filter((n) => s.has(n.colId)).sort(
288
- (n, R) => s.get(n.colId) - s.get(R.colId)
289
+ ), S = h.filter((n) => i.has(n.colId)).sort(
290
+ (n, R) => i.get(n.colId) - i.get(R.colId)
289
291
  ), v = [];
290
- let u = 0;
292
+ let c = 0;
291
293
  for (const n of h)
292
- s.has(n.colId) ? v.push(S[u++]) : v.push(n);
294
+ i.has(n.colId) ? v.push(S[c++]) : v.push(n);
293
295
  r.applyColumnState({
294
296
  state: v,
295
297
  applyOrder: !0
@@ -297,16 +299,16 @@ const ut = /* @__PURE__ */ eo({
297
299
  }
298
300
  vo({
299
301
  columns: l(() => f.value),
300
- columnsBackup: l(() => j.value),
302
+ columnsBackup: l(() => U.value),
301
303
  size: l(() => bo[y.value]),
302
304
  updateColumns(e) {
303
- f.value = e, o.onShownColumnsChange?.(e), Le(e);
305
+ f.value = e, o.onShownColumnsChange?.(e), He(e);
304
306
  },
305
307
  updateSize(e) {
306
308
  y.value = Ro[e];
307
309
  },
308
310
  renderConfig: l(() => ({
309
- className: ue("table-header", "title"),
311
+ className: ce("table-header", "title"),
310
312
  color: we.value.colorTextTertiary
311
313
  })),
312
314
  dataSource: l(() => t(w).records),
@@ -320,25 +322,25 @@ const ut = /* @__PURE__ */ eo({
320
322
  setSearchFormSorterItems: Z,
321
323
  resetSearchFormSorterItems: _
322
324
  });
323
- const We = l(
325
+ const Le = l(
324
326
  () => F(o.loading) ? w.loading : o.loading
325
- ), je = l(() => [
326
- c(),
327
- o.card ? null : c("wrapper"),
328
- c("adaptive"),
329
- c(`size-${y.value}`)
330
- ].filter(Boolean)), Ue = l(() => ({
327
+ ), Ue = l(() => [
328
+ u(),
329
+ o.card ? null : u("wrapper"),
330
+ u("adaptive"),
331
+ u(`size-${y.value}`)
332
+ ].filter(Boolean)), We = l(() => ({
331
333
  height: "100%",
332
334
  ...o.tableStyle || {}
333
- })), He = (e, r) => {
334
- H({ current: e, pageSize: r });
335
+ })), je = (e, r) => {
336
+ j({ current: e, pageSize: r });
335
337
  };
336
338
  function $e(e) {
337
339
  const r = e.data;
338
340
  return K(r);
339
341
  }
340
342
  function qe(e, r) {
341
- i.value?.ensureIndexVisible(e, r);
343
+ s.value?.ensureIndexVisible(e, r);
342
344
  }
343
345
  function Je(e) {
344
346
  o.onRowClicked?.(e.data, e.event);
@@ -347,14 +349,14 @@ const ut = /* @__PURE__ */ eo({
347
349
  o.onScrollEnd?.(e.direction);
348
350
  }
349
351
  function Xe(e) {
350
- return i.value?.refreshCells(e);
352
+ return s.value?.refreshCells(e);
351
353
  }
352
354
  function Ye(e) {
353
- return i.value?.redrawRows(e);
355
+ return s.value?.redrawRows(e);
354
356
  }
355
357
  const Ze = (e) => {
356
358
  const r = [
357
- L.value.getRowClass?.(e)
359
+ H.value.getRowClass?.(e)
358
360
  ];
359
361
  if (!e.node.rowPinned) {
360
362
  const a = se(o.rowClassName) ? o.rowClassName(e.data, e.rowIndex) : o.rowClassName;
@@ -378,7 +380,7 @@ const ut = /* @__PURE__ */ eo({
378
380
  (e) => {
379
381
  o.onLoadingChange?.(e);
380
382
  }
381
- ), ce({
383
+ ), ue({
382
384
  submit: N,
383
385
  reset: D,
384
386
  refresh: q,
@@ -399,12 +401,13 @@ const ut = /* @__PURE__ */ eo({
399
401
  setSearchFormSorterItems: Z,
400
402
  resetSearchFormSorterItems: _,
401
403
  refreshCells: Xe,
402
- redrawRows: Ye
404
+ redrawRows: Ye,
405
+ _internalGridApi: l(() => s.value)
403
406
  }), (e, r) => (b(), A("div", {
404
- class: m(je.value),
407
+ class: m(Ue.value),
405
408
  style: V(e.wrapperStyle)
406
409
  }, [
407
- t(F)(e.dataSource) && e.searchForm !== !1 && t(W).length > 0 ? (b(), A("div", {
410
+ t(F)(e.dataSource) && e.searchForm !== !1 && t(L).length > 0 ? (b(), A("div", {
408
411
  key: 0,
409
412
  class: m(e.card ? t(k)("search-wrapper") : null),
410
413
  style: V(e.searchFormWrapperStyle)
@@ -413,12 +416,12 @@ const ut = /* @__PURE__ */ eo({
413
416
  ref_key: "formRef",
414
417
  ref: g,
415
418
  "custom-reset": "",
416
- "submit-loading": t(U).loading,
419
+ "submit-loading": t(W).loading,
417
420
  onSubmit: t(N),
418
421
  onReset: t(D)
419
422
  }), ro({
420
423
  default: ae(() => [
421
- (b(!0), A(ao, null, no(t(W), (a) => (b(), ne(lo(a.renderNode), {
424
+ (b(!0), A(ao, null, no(t(L), (a) => (b(), ne(lo(a.renderNode), {
422
425
  key: a.dataIndex
423
426
  }))), 128))
424
427
  ]),
@@ -438,7 +441,7 @@ const ut = /* @__PURE__ */ eo({
438
441
  style: V(e.tableWrapperStyle)
439
442
  }, [
440
443
  B("div", {
441
- class: m(t(c)("header-wrapper"))
444
+ class: m(t(u)("header-wrapper"))
442
445
  }, [
443
446
  le(e.$slots, "title", {
444
447
  selectedRows: t(E),
@@ -448,11 +451,11 @@ const ut = /* @__PURE__ */ eo({
448
451
  })
449
452
  ], 2),
450
453
  B("div", {
451
- class: m(t(c)("grid-wrapper"))
454
+ class: m(t(u)("grid-wrapper"))
452
455
  }, [
453
- M(t(co), O(t(po)(t(pe), t(L)), {
456
+ M(t(uo), O(t(po)(t(pe), t(H)), {
454
457
  "get-row-class": Ze,
455
- style: Ue.value,
458
+ style: We.value,
456
459
  "row-data": t(w).records,
457
460
  "column-defs": t(he),
458
461
  "default-col-def": t(Ce),
@@ -467,34 +470,35 @@ const ut = /* @__PURE__ */ eo({
467
470
  "row-class-rules": e.rowClassRules,
468
471
  "no-rows-overlay-component": Ao,
469
472
  "suppress-cell-focus": "",
473
+ "dom-layout": e.autoHeight ? "autoHeight" : "normal",
470
474
  onSortChanged: Re,
471
- onGridReady: r[0] || (r[0] = (a) => i.value = a.api),
475
+ onGridReady: r[0] || (r[0] = (a) => s.value = a.api),
472
476
  onRowDataUpdated: J,
473
477
  onRowSelected: Me,
474
478
  onFirstDataRendered: Oe,
475
479
  onRowClicked: Je,
476
480
  onBodyScrollEnd: Qe
477
- }), null, 16, ["style", "row-data", "column-defs", "default-col-def", "row-selection", "selection-column-def", "theme", "enable-browser-tooltips", "row-class-rules"]),
481
+ }), null, 16, ["style", "row-data", "column-defs", "default-col-def", "row-selection", "selection-column-def", "theme", "enable-browser-tooltips", "row-class-rules", "dom-layout"]),
478
482
  so(B("div", {
479
483
  class: m(t(k)("table-loading-wrapper"))
480
484
  }, [
481
485
  M(t(fo), { delay: 300 })
482
486
  ], 2), [
483
- [io, We.value]
487
+ [io, Le.value]
484
488
  ])
485
489
  ], 2),
486
490
  B("div", {
487
- class: m(t(c)("pagination-wrapper"))
491
+ class: m(t(u)("pagination-wrapper"))
488
492
  }, [
489
493
  e.pagination !== !1 ? (b(), ne(t(go), O({
490
494
  key: 0,
491
- class: t(c)("pagination")
492
- }, t(U).pagination, { onChange: He }), null, 16, ["class"])) : re("", !0)
495
+ class: t(u)("pagination")
496
+ }, t(W).pagination, { onChange: je }), null, 16, ["class"])) : re("", !0)
493
497
  ], 2)
494
498
  ], 6)
495
499
  ], 6));
496
500
  }
497
501
  });
498
502
  export {
499
- ut as default
503
+ ct as default
500
504
  };
@@ -4,7 +4,7 @@ import { TableProps } from '@aplus-frontend/antdv';
4
4
  import { ApFormSearchFormPopoverSorterItem, ApFormSearchFormProps } from '../ap-form/interface';
5
5
  import { Recordable } from '../type';
6
6
  import { SortOrder, TableRowSelection } from '@aplus-frontend/antdv/es/table/interface';
7
- import { ColDef, IRowNode, RedrawRowsParams, RefreshCellsParams, RowClassRules, RowPinnedType, ScrollDirection } from 'ag-grid-community';
7
+ import { ColDef, GridApi, ICellRendererParams, IRowNode, RedrawRowsParams, RefreshCellsParams, RowClassRules, RowPinnedType, ScrollDirection } from 'ag-grid-community';
8
8
  import { InternalPagingType } from '../ap-table/hooks/use-table-paging-ng';
9
9
  export type AgGridColumnType<RecordType = any, ExtraValueType = 'text', ValueType extends ApTableValueTypes = ApTableValueTypes, MergedValueType extends ExtraValueType | ValueType = ExtraValueType | ValueType> = MergedValueType extends ExtraValueType | ValueType ? Omit<ExtraProColumnType<RecordType>, 'sorter' | 'rowSpan' | 'customCell' | 'customHeaderCell' | 'minWidth' | 'width' | 'maxWidth' | 'className' | 'class' | 'colSpan'> & {
10
10
  children?: AgGridColumnType<RecordType, ExtraValueType, ValueType>[];
@@ -83,6 +83,7 @@ export type AgGridColumnType<RecordType = any, ExtraValueType = 'text', ValueTyp
83
83
  originalText?: any;
84
84
  pinned?: boolean;
85
85
  rowIndex?: number;
86
+ params?: ICellRendererParams;
86
87
  }) => any;
87
88
  width?: number;
88
89
  minWidth?: number;
@@ -97,6 +98,11 @@ export type AgGridColumnType<RecordType = any, ExtraValueType = 'text', ValueTyp
97
98
  * 仅用于和接口交互的字段,如果不设置将会尝试使用`dataIndex`和`key`
98
99
  */
99
100
  field?: string;
101
+ /**
102
+ * 是否在表头渲染必填标记
103
+ * @description 仅限内部使用
104
+ */
105
+ _requireMark?: boolean;
100
106
  } : null;
101
107
  export type AgGridRowSelection<RecordType> = Pick<TableRowSelection<RecordType>, 'type' | 'fixed' | 'columnWidth' | 'defaultSelectedRowKeys'> & {
102
108
  /**
@@ -259,6 +265,15 @@ export type AgGridProps<RecordType = any, ParamsType = any> = Omit<TableProps<Re
259
265
  * 表格行自定义样式规则集
260
266
  */
261
267
  rowClassRules?: RowClassRules<RecordType>;
268
+ /**
269
+ * 使用由内容撑起的高度来布局
270
+ */
271
+ autoHeight?: boolean;
272
+ /**
273
+ * 当表格数据更新被应用后的回调
274
+ * @returns
275
+ */
276
+ onUpdate?: () => void;
262
277
  };
263
278
  export type AgGridExpose<SearchParamsType = Recordable, RecordType = any> = {
264
279
  /**
@@ -364,4 +379,8 @@ export type AgGridExpose<SearchParamsType = Recordable, RecordType = any> = {
364
379
  * @returns
365
380
  */
366
381
  redrawRows: (params?: RedrawRowsParams<RecordType>) => void;
382
+ /**
383
+ * AgGrid 暴露的Api实例(仅限内部使用)
384
+ */
385
+ _internalGridApi?: GridApi | undefined;
367
386
  };
@@ -1,4 +1,5 @@
1
1
  import { GridOptions } from 'ag-grid-community';
2
+ import { EditableAgGridFormItemProps } from './editable/interface';
2
3
  export declare function mergeProps(...options: GridOptions[]): GridOptions<any>;
3
4
  /**
4
5
  * 将尺寸单位px去掉
@@ -13,3 +14,4 @@ export declare function pxToNumber(value?: string | number, defaultValue?: numbe
13
14
  * @returns
14
15
  */
15
16
  export declare function getStringKey(key?: string | number): string | undefined;
17
+ export declare function getShadowName(name: EditableAgGridFormItemProps['name']): string;