@aplus-frontend/ui 7.20.2 → 7.20.4

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 (64) hide show
  1. package/es/index.mjs +73 -71
  2. package/es/src/ag-grid/editable/form-item.vue.mjs +72 -70
  3. package/es/src/ag-grid/editable/index.vue.mjs +59 -57
  4. package/es/src/ag-grid/editable/interface.d.ts +7 -0
  5. package/es/src/ag-grid/hooks/use-columns.mjs +18 -18
  6. package/es/src/ag-grid/hooks/use-editable-api.d.ts +1 -0
  7. package/es/src/ag-grid/hooks/use-editable-api.mjs +107 -88
  8. package/es/src/ag-grid/hooks/use-editable-form-item-api.d.ts +1 -0
  9. package/es/src/ag-grid/hooks/use-editable-form-item-api.mjs +105 -86
  10. package/es/src/ag-grid/index.vue.mjs +230 -227
  11. package/es/src/ap-action/item-popconfirm/index.vue.mjs +14 -14
  12. package/es/src/ap-list/hooks/use-offline-list.mjs +31 -18
  13. package/es/src/business/ag-grid-container/index.d.ts +3 -0
  14. package/es/src/business/ag-grid-container/index.mjs +2 -0
  15. package/es/src/business/ag-grid-container/index.vue.d.ts +33 -0
  16. package/es/src/business/ag-grid-container/index.vue.mjs +64 -0
  17. package/es/src/business/ag-grid-container/index.vue2.mjs +4 -0
  18. package/es/src/business/ag-grid-container/interface.d.ts +4 -0
  19. package/es/src/business/ag-grid-container/interface.mjs +1 -0
  20. package/es/src/business/index.d.ts +1 -0
  21. package/es/src/business/index.mjs +55 -54
  22. package/es/src/check-card/index.vue.d.ts +0 -1
  23. package/es/src/check-card/index.vue2.mjs +3 -5
  24. package/es/src/config-provider/config-provider-props.d.ts +1 -1
  25. package/es/src/config-provider/config-provider.d.ts +3 -0
  26. package/es/src/config-provider/config-provider.mjs +1 -1
  27. package/es/src/config-provider/hooks/use-global-config.d.ts +2 -0
  28. package/es/src/config-provider/index.d.ts +4 -0
  29. package/es/src/highlight/index.vue.mjs +9 -9
  30. package/es/src/index.mjs +82 -80
  31. package/es/src/version.d.ts +1 -1
  32. package/es/src/version.mjs +1 -1
  33. package/lib/index.js +1 -1
  34. package/lib/src/ag-grid/editable/form-item.vue.js +1 -1
  35. package/lib/src/ag-grid/editable/index.vue.js +1 -1
  36. package/lib/src/ag-grid/editable/interface.d.ts +7 -0
  37. package/lib/src/ag-grid/hooks/use-columns.js +1 -1
  38. package/lib/src/ag-grid/hooks/use-editable-api.d.ts +1 -0
  39. package/lib/src/ag-grid/hooks/use-editable-api.js +1 -1
  40. package/lib/src/ag-grid/hooks/use-editable-form-item-api.d.ts +1 -0
  41. package/lib/src/ag-grid/hooks/use-editable-form-item-api.js +1 -1
  42. package/lib/src/ag-grid/index.vue.js +1 -1
  43. package/lib/src/ap-action/item-popconfirm/index.vue.js +1 -1
  44. package/lib/src/ap-list/hooks/use-offline-list.js +1 -1
  45. package/lib/src/business/ag-grid-container/index.d.ts +3 -0
  46. package/lib/src/business/ag-grid-container/index.js +1 -0
  47. package/lib/src/business/ag-grid-container/index.vue.d.ts +33 -0
  48. package/lib/src/business/ag-grid-container/index.vue.js +1 -0
  49. package/lib/src/business/ag-grid-container/index.vue2.js +1 -0
  50. package/lib/src/business/ag-grid-container/interface.d.ts +4 -0
  51. package/lib/src/business/ag-grid-container/interface.js +1 -0
  52. package/lib/src/business/index.d.ts +1 -0
  53. package/lib/src/business/index.js +1 -1
  54. package/lib/src/check-card/index.vue.d.ts +0 -1
  55. package/lib/src/check-card/index.vue2.js +1 -1
  56. package/lib/src/config-provider/config-provider-props.d.ts +1 -1
  57. package/lib/src/config-provider/config-provider.d.ts +3 -0
  58. package/lib/src/config-provider/config-provider.js +1 -1
  59. package/lib/src/config-provider/hooks/use-global-config.d.ts +2 -0
  60. package/lib/src/config-provider/index.d.ts +4 -0
  61. package/lib/src/index.js +1 -1
  62. package/lib/src/version.d.ts +1 -1
  63. package/lib/src/version.js +1 -1
  64. package/package.json +4 -4
@@ -1,18 +1,18 @@
1
- import { defineComponent as Q, useSlots as X, ref as h, watch as Y, unref as r, createBlock as Z, openBlock as ee, withCtx as c, createVNode as C, mergeProps as oe, createSlots as ae, renderList as te, renderSlot as ne, normalizeProps as re, guardReactiveProps as le } from "vue";
2
- import { isEqual as se, isArray as b, omit as ie } from "lodash-unified";
1
+ import { defineComponent as X, useSlots as Y, ref as h, watch as Z, unref as r, createBlock as ee, openBlock as oe, withCtx as c, createVNode as C, mergeProps as ae, createSlots as te, renderList as ne, renderSlot as re, normalizeProps as le, guardReactiveProps as se } from "vue";
2
+ import { isEqual as ie, isArray as b, omit as de } from "lodash-unified";
3
3
  import { ApForm as f } from "../../ap-form/index.mjs";
4
4
  import "../../config-provider/index.mjs";
5
5
  import "../../hooks/index.mjs";
6
- import { useEditableApi as de } from "../hooks/use-editable-api.mjs";
7
- import { useGetEditableColumns as ue } from "../hooks/use-editable-columns.mjs";
6
+ import { useEditableApi as ue } from "../hooks/use-editable-api.mjs";
7
+ import { useGetEditableColumns as pe } from "../hooks/use-editable-columns.mjs";
8
8
  import "../index.vue2.mjs";
9
- import pe from "../style/editable.mjs";
10
- import { arrayToObject as v, getRowKey as me } from "./utils.mjs";
11
- import { useNamespace as ce } from "../../config-provider/hooks/use-namespace.mjs";
12
- import { useControllableValue as fe } from "../../hooks/useControllableValue.mjs";
13
- import { useGlobalConfig as ye } from "../../config-provider/hooks/use-global-config.mjs";
14
- import we from "../index.vue.mjs";
15
- const Ke = /* @__PURE__ */ Q({
9
+ import me from "../style/editable.mjs";
10
+ import { arrayToObject as v, getRowKey as ce } from "./utils.mjs";
11
+ import { useNamespace as fe } from "../../config-provider/hooks/use-namespace.mjs";
12
+ import { useControllableValue as ye } from "../../hooks/useControllableValue.mjs";
13
+ import { useGlobalConfig as we } from "../../config-provider/hooks/use-global-config.mjs";
14
+ import ge from "../index.vue.mjs";
15
+ const ke = /* @__PURE__ */ X({
16
16
  name: "EditableGrid",
17
17
  __name: "index",
18
18
  props: {
@@ -147,35 +147,36 @@ const Ke = /* @__PURE__ */ Q({
147
147
  expose: B,
148
148
  emit: S
149
149
  }) {
150
- const T = X(), t = x, {
150
+ const T = Y(), t = x, {
151
151
  b: F
152
- } = ce("editable-aggrid"), _ = pe("editable-aggrid"), A = S, s = h(), {
152
+ } = fe("editable-aggrid"), _ = me("editable-aggrid"), A = S, s = h(), {
153
153
  value: i,
154
154
  updateValue: y
155
- } = fe(t, A), l = h(), E = f.useWatch(t.name, l);
155
+ } = ye(t, A), l = h(), E = f.useWatch(t.name, l);
156
156
  let d;
157
- Y(i, (e) => {
157
+ Z(i, (e) => {
158
158
  const o = v(e, t.rowKey);
159
- se(o, r(E)) || (d = () => {
159
+ ie(o, r(E)) || (d = () => {
160
160
  l.value?.setFieldValue(t.name, o);
161
161
  });
162
162
  }, {
163
163
  deep: !0
164
164
  });
165
- const K = ye("valueTypeMap"), k = ue(t, K), {
165
+ const K = we("valueTypeMap"), k = pe(t, K), {
166
166
  add: D,
167
- addMultiple: N,
168
- remove: U,
169
- removeByKey: I,
170
- getRowData: j,
171
- getRowsData: z,
172
- getRowDataByKey: V,
173
- setRowData: H,
174
- setRowDataByKey: O,
175
- clear: G,
167
+ addByKey: N,
168
+ addMultiple: U,
169
+ remove: I,
170
+ removeByKey: j,
171
+ getRowData: z,
172
+ getRowsData: V,
173
+ getRowDataByKey: H,
174
+ setRowData: O,
175
+ setRowDataByKey: G,
176
+ clear: L,
176
177
  refreshRowIds: u
177
- } = de(t, l, i, y);
178
- function L() {
178
+ } = ue(t, l, i, y);
179
+ function P() {
179
180
  if (t.onUpdate?.(), d && (d(), d = void 0), t.supressForceRowUpdate)
180
181
  return;
181
182
  const e = s.value?._internalGridApi;
@@ -187,7 +188,7 @@ const Ke = /* @__PURE__ */ Q({
187
188
  force: !0
188
189
  }), u.value = [];
189
190
  }
190
- function P() {
191
+ function M() {
191
192
  l.value?.resetFields();
192
193
  }
193
194
  function w(e) {
@@ -195,31 +196,31 @@ const Ke = /* @__PURE__ */ Q({
195
196
  }
196
197
  function g(e) {
197
198
  try {
198
- const o = Object.keys(e), a = i.value.map((n) => me(n, void 0, t.rowKey));
199
+ const o = Object.keys(e), a = i.value.map((n) => ce(n, void 0, t.rowKey));
199
200
  return o.sort((n, p) => a.findIndex((m) => String(m) === n) - a.findIndex((m) => String(m) === p)), o.map((n) => e[n]);
200
201
  } catch {
201
202
  return e;
202
203
  }
203
204
  }
204
- async function M(e, o) {
205
+ async function W(e, o) {
205
206
  const n = (await l.value?.validateFields(w(e), o))?.[t.name];
206
207
  return g(n);
207
208
  }
208
- async function W(e, o) {
209
+ async function $(e, o) {
209
210
  const n = (await l.value?.validateFieldsReturnTransformed(w(e), o))?.[t.name];
210
211
  return g(n);
211
212
  }
212
- function $(e) {
213
+ function q(e) {
213
214
  y(e);
214
215
  }
215
216
  function R(e, o) {
216
217
  const a = e === "end" ? i.value.length - 1 : e;
217
218
  s.value?.scrollToRow(a, o);
218
219
  }
219
- function q(e, o) {
220
+ function J(e, o) {
220
221
  s.value?.scrollToColumn(e, o);
221
222
  }
222
- function J(e, o = !0) {
223
+ function Q(e, o = !0) {
223
224
  const a = Array.isArray(e) ? e : [e];
224
225
  s.value?._internalGridApi?.refreshCells({
225
226
  columns: a,
@@ -227,26 +228,27 @@ const Ke = /* @__PURE__ */ Q({
227
228
  });
228
229
  }
229
230
  return B({
230
- resetFields: P,
231
- validateFields: M,
232
- validateFieldsReturnTransformed: W,
231
+ resetFields: M,
232
+ validateFields: W,
233
+ validateFieldsReturnTransformed: $,
233
234
  add: D,
234
- addMultiple: N,
235
- remove: U,
236
- removeByKey: I,
237
- getRowData: j,
238
- getRowsData: z,
239
- setRowData: H,
240
- clear: G,
241
- setTableData: $,
235
+ addByKey: N,
236
+ addMultiple: U,
237
+ remove: I,
238
+ removeByKey: j,
239
+ getRowData: z,
240
+ getRowsData: V,
241
+ setRowData: O,
242
+ clear: L,
243
+ setTableData: q,
242
244
  scrollTo: R,
243
245
  scrollToRow: R,
244
- scrollToColumn: q,
246
+ scrollToColumn: J,
245
247
  table: s,
246
- getRowDataByKey: V,
247
- setRowDataByKey: O,
248
- refreshColumns: J
249
- }), (e, o) => (ee(), Z(r(f), {
248
+ getRowDataByKey: H,
249
+ setRowDataByKey: G,
250
+ refreshColumns: Q
251
+ }), (e, o) => (oe(), ee(r(f), {
250
252
  ref_key: "formRef",
251
253
  ref: l,
252
254
  "initial-values": {
@@ -260,7 +262,7 @@ const Ke = /* @__PURE__ */ Q({
260
262
  name: e.name,
261
263
  "no-style": ""
262
264
  }, {
263
- default: c(() => [C(we, oe(r(ie)(t, ["name", "value", "onUpdate:value", "maxLength", "onChange", "defaultValue", "onUpdate"]), {
265
+ default: c(() => [C(ge, ae(r(de)(t, ["name", "value", "onUpdate:value", "maxLength", "onChange", "defaultValue", "onUpdate"]), {
264
266
  ref_key: "tableRef",
265
267
  ref: s,
266
268
  class: [r(F)(), r(_)],
@@ -268,12 +270,12 @@ const Ke = /* @__PURE__ */ Q({
268
270
  columns: r(k),
269
271
  "data-source": r(i),
270
272
  "search-form": !1,
271
- onUpdate: L
272
- }), ae({
273
+ onUpdate: P
274
+ }), te({
273
275
  _: 2
274
- }, [te(T, (a, n) => ({
276
+ }, [ne(T, (a, n) => ({
275
277
  name: n,
276
- fn: c((p) => [ne(e.$slots, n, re(le(p || {})))])
278
+ fn: c((p) => [re(e.$slots, n, le(se(p || {})))])
277
279
  }))]), 1040, ["class", "columns", "data-source"])]),
278
280
  _: 3
279
281
  }, 8, ["name"])]),
@@ -282,5 +284,5 @@ const Ke = /* @__PURE__ */ Q({
282
284
  }
283
285
  });
284
286
  export {
285
- Ke as default
287
+ ke as default
286
288
  };
@@ -111,6 +111,13 @@ export type EditableAgGridExpose<RecordType = any, ModelType = RecordType[]> = O
111
111
  * @returns
112
112
  */
113
113
  refreshColumns: (columnKey: string | string[], force?: boolean) => void;
114
+ /**
115
+ * 添加一条数据(通过行key)
116
+ * @param defaultValue
117
+ * @param key
118
+ * @returns
119
+ */
120
+ addByKey: (defaultValue?: Partial<RecordType> | undefined, key?: number) => void;
114
121
  };
115
122
  export type EditableAgGridFormItemExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableAgGridExpose<RecordType, ModelType>, 'resetFields' | 'validateFields' | 'validateFieldsReturnTransformed'> & {
116
123
  /**
@@ -1,11 +1,11 @@
1
- import { ref as s, computed as c, watch as y } from "vue";
1
+ import { ref as c, computed as s, watch as y } from "vue";
2
2
  import { getStringKey as a, runPipelineHooks as C } from "../utils.mjs";
3
- const w = (o) => {
4
- const r = s([]), u = s([]);
5
- function l(n = []) {
3
+ const w = (r) => {
4
+ const o = c([]), l = c([]);
5
+ function u(n = []) {
6
6
  return n.filter((e) => !e.hideInTable).map((e) => {
7
7
  if (e.children?.length) {
8
- const t = l(e.children);
8
+ const t = u(e.children);
9
9
  return t?.length ? {
10
10
  ...e,
11
11
  children: t
@@ -14,25 +14,25 @@ const w = (o) => {
14
14
  return e;
15
15
  }).filter(Boolean);
16
16
  }
17
- function f(n) {
18
- return r.value.find((e) => a(e.key) === n);
17
+ function m(n) {
18
+ return o.value.find((e) => a(e.key) === n);
19
19
  }
20
- const m = c(
21
- () => r.value.map((n) => a(n.key)).filter(Boolean)
20
+ const f = s(
21
+ () => o.value.map((n) => a(n.key)).filter(Boolean)
22
22
  );
23
23
  async function d(n, e) {
24
24
  return await C(
25
- o.plugins,
25
+ r.plugins,
26
26
  n,
27
27
  (t) => t.beforeColumnsChange?.bind(t),
28
28
  e
29
29
  );
30
30
  }
31
31
  y(
32
- () => o.columns,
32
+ () => r.columns,
33
33
  async () => {
34
- const n = l(o.columns), e = await d(n, r.value);
35
- r.value = e, u.value = e, o.onShownColumnsChange?.(e);
34
+ const n = u(r.columns), e = await d(n, o.value);
35
+ o.value = e, l.value = e, r.onShownColumnsChange?.(e);
36
36
  },
37
37
  {
38
38
  deep: !0,
@@ -54,12 +54,12 @@ const w = (o) => {
54
54
  };
55
55
  }
56
56
  }
57
- const h = c(() => i(r.value));
57
+ const h = s(() => i(u(r.columns)));
58
58
  return {
59
- columns: r,
60
- shownColumns: u,
61
- columnKeys: m,
62
- getTargetColumnByKey: f,
59
+ columns: o,
60
+ shownColumns: l,
61
+ columnKeys: f,
62
+ getTargetColumnByKey: m,
63
63
  defaultSortOrder: h
64
64
  };
65
65
  };
@@ -4,6 +4,7 @@ import { ApFormInternalInstance, ApFormExpose } from '../../ap-form';
4
4
  import { EditableAgGridProps } from '../editable/interface';
5
5
  export declare const useEditableApi: <RecordType>(props: EditableAgGridProps<RecordType>, formApi: Ref<ApFormExpose | undefined> | ApFormInternalInstance | undefined, tableData: Ref<RecordType[]>, updateTableData?: (newData: RecordType[]) => void) => {
6
6
  add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
7
+ addByKey: (defaultValue?: Partial<RecordType>, key?: number) => void;
7
8
  addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
8
9
  remove: (data: RecordType | RecordType[]) => void;
9
10
  removeByKey: (key: Key | Key[]) => void;
@@ -1,149 +1,168 @@
1
- import { isFunction as K, isUndefined as S, isNumber as d, cloneDeep as T, isArray as x, isString as z } from "lodash-unified";
2
- import { shallowRef as G, computed as N, unref as w, isRef as V } from "vue";
1
+ import { isFunction as h, isUndefined as m, isNumber as K, cloneDeep as G, isArray as F, isString as N } from "lodash-unified";
2
+ import { shallowRef as W, computed as $, unref as w, isRef as q } from "vue";
3
3
  import "../../utils/index.mjs";
4
- import { useDevWarning as W } from "../../utils/warning.mjs";
5
- import { isDef as I } from "../../utils/is.mjs";
6
- let $ = 0;
7
- function F() {
8
- return `_ag_grid${$++}`;
4
+ import { useDevWarning as C } from "../../utils/warning.mjs";
5
+ import { isDef as R } from "../../utils/is.mjs";
6
+ let H = 0;
7
+ function x() {
8
+ return `_ag_grid${H++}`;
9
9
  }
10
- const Q = (u, g, i, y) => {
11
- const h = W("EditableAgGrid"), l = G([]), m = N(() => V(g) ? w(g) : g);
12
- function a(e, o) {
13
- const r = w(i)?.length || 0;
14
- if (I(u.maxLength) && r >= u.maxLength || !e && K(u.rowKey))
10
+ const Y = (u, y, i, d) => {
11
+ const I = C("EditableAgGrid"), v = W([]), B = $(() => q(y) ? w(y) : y);
12
+ function L(e, r) {
13
+ const f = w(i)?.length || 0;
14
+ if (R(u.maxLength) && f >= u.maxLength || !e && h(u.rowKey))
15
15
  return;
16
- const t = {
17
- ...e || { [u.rowKey]: F() }
16
+ const o = {
17
+ ...e || { [u.rowKey]: x() }
18
18
  };
19
19
  if (!i.value) {
20
- i.value = [t];
20
+ i.value = [o];
21
21
  return;
22
22
  }
23
- S(o) ? i.value.push(t) : (l.value = i.value.map(
24
- (n, f) => f < o ? null : c(n, f, u.rowKey)
25
- ).filter(Boolean), i.value.splice(o, 0, t));
23
+ m(r) ? i.value.push(o) : (v.value = i.value.map(
24
+ (n, t) => t < r ? null : c(n, t, u.rowKey)
25
+ ).filter(Boolean), i.value.splice(r, 0, o));
26
26
  }
27
- function B(e, o = "suffix") {
28
- const r = w(i)?.length || 0, t = d(e) ? e : e.length;
29
- if (I(u.maxLength) && r + t > u.maxLength || d(e) && K(u.rowKey))
27
+ function U(e, r) {
28
+ const f = w(i)?.length || 0;
29
+ if (R(u.maxLength) && f >= u.maxLength || !e && h(u.rowKey))
30
30
  return;
31
- const n = d(e) ? new Array(e).fill(0).map(() => ({ [u.rowKey]: F() })) : T(e);
31
+ const o = {
32
+ ...e || { [u.rowKey]: x() }
33
+ };
34
+ if (!i.value) {
35
+ i.value = [o];
36
+ return;
37
+ }
38
+ const n = i.value.findIndex(
39
+ (s, l) => c(s, l, u.rowKey) === r
40
+ ), t = m(r) || n === -1 || n === i.value?.length - 1 ? void 0 : n + 1;
41
+ m(t) ? i.value.push(o) : (v.value = i.value.map(
42
+ (s, l) => l < t ? null : c(s, l, u.rowKey)
43
+ ).filter(Boolean), i.value.splice(t, 0, o));
44
+ }
45
+ function j(e, r = "suffix") {
46
+ const f = w(i)?.length || 0, o = K(e) ? e : e.length;
47
+ if (R(u.maxLength) && f + o > u.maxLength || K(e) && h(u.rowKey))
48
+ return;
49
+ const n = K(e) ? new Array(e).fill(0).map(() => ({ [u.rowKey]: x() })) : G(e);
32
50
  if (!i.value) {
33
51
  i.value = [...n];
34
52
  return;
35
53
  }
36
- o === "suffix" ? i.value.push(...n) : (l.value = i.value.map(
37
- (f, s) => c(f, s, u.rowKey)
54
+ r === "suffix" ? i.value.push(...n) : (v.value = i.value.map(
55
+ (t, s) => c(t, s, u.rowKey)
38
56
  ), i.value.unshift(...n));
39
57
  }
40
- function L(e) {
41
- const o = x(e) ? e : [e], r = i.value.filter(
42
- (n) => !o.includes(n)
43
- ), t = i.value.findIndex(
44
- (n) => o.includes(n)
58
+ function A(e) {
59
+ const r = F(e) ? e : [e], f = i.value.filter(
60
+ (n) => !r.includes(n)
61
+ ), o = i.value.findIndex(
62
+ (n) => r.includes(n)
45
63
  );
46
- l.value = i.value.map(
47
- (n, f) => f <= t ? null : c(n, f, u.rowKey)
48
- ).filter(Boolean), y?.(r);
64
+ v.value = i.value.map(
65
+ (n, t) => t <= o ? null : c(n, t, u.rowKey)
66
+ ).filter(Boolean), d?.(f);
49
67
  }
50
- function c(e, o, r) {
51
- if (r)
52
- return z(r) ? e[r] : r(e, o);
68
+ function c(e, r, f) {
69
+ if (f)
70
+ return N(f) ? e[f] : f(e, r);
53
71
  }
54
- function U(e) {
55
- const o = new Set(x(e) ? e : [e]);
56
- if (o.size === 0)
72
+ function O(e) {
73
+ const r = new Set(F(e) ? e : [e]);
74
+ if (r.size === 0)
57
75
  return;
58
- const r = i.value.filter(
59
- (n, f) => !o.has(c(n, f, u.rowKey))
60
- ), t = i.value.findIndex(
61
- (n, f) => o.has(c(n, f, u.rowKey))
76
+ const f = i.value.filter(
77
+ (n, t) => !r.has(c(n, t, u.rowKey))
78
+ ), o = i.value.findIndex(
79
+ (n, t) => r.has(c(n, t, u.rowKey))
62
80
  );
63
- l.value = i.value.map(
64
- (n, f) => f <= t ? null : c(n, f, u.rowKey)
65
- ).filter(Boolean), y?.(r);
81
+ v.value = i.value.map(
82
+ (n, t) => t <= o ? null : c(n, t, u.rowKey)
83
+ ).filter(Boolean), d?.(f);
66
84
  }
67
- function j(e) {
68
- return h(
85
+ function k(e) {
86
+ return I(
69
87
  !u.supressForceRowUpdate,
70
88
  "usage",
71
89
  'Avoid using getRowData/setRowData methods while suppressForceRowUpdate is enabled."'
72
90
  ), w(i)?.[e];
73
91
  }
74
- function k(e) {
92
+ function _(e) {
75
93
  return i.value?.find(
76
- (o, r) => c(o, r, u.rowKey) === e
94
+ (r, f) => c(r, f, u.rowKey) === e
77
95
  );
78
96
  }
79
- function A() {
97
+ function E() {
80
98
  return w(i);
81
99
  }
82
- function O(e, o, r = !0) {
83
- h(
100
+ function S(e, r, f = !0) {
101
+ I(
84
102
  !u.supressForceRowUpdate,
85
103
  "usage",
86
104
  'Avoid using getRowData/setRowData methods while suppressForceRowUpdate is enabled."'
87
- ), m.value?.setFieldValue?.(
105
+ ), B.value?.setFieldValue?.(
88
106
  u.name,
89
107
  void 0,
90
108
  !0,
91
- (t, n) => {
92
- const f = i.value.findIndex(
93
- (R, v) => e === v
109
+ (o, n) => {
110
+ const t = i.value.findIndex(
111
+ (l, g) => e === g
94
112
  );
95
- if (!~f)
113
+ if (!~t)
96
114
  return;
97
115
  const s = c(
98
- i.value[f],
99
- f,
116
+ i.value[t],
117
+ t,
100
118
  u.rowKey
101
119
  );
102
- if (s && !(!t[n] || !t[n][s])) {
103
- if (!r) {
104
- const R = Object.keys(t[n][s]);
105
- for (const v of R)
106
- v !== u.rowKey && delete t[n][s][v];
120
+ if (s && !(!o[n] || !o[n][s])) {
121
+ if (!f) {
122
+ const l = Object.keys(o[n][s]);
123
+ for (const g of l)
124
+ g !== u.rowKey && delete o[n][s][g];
107
125
  }
108
- Object.assign(t[n][s], { ...o });
126
+ Object.assign(o[n][s], { ...r });
109
127
  }
110
128
  }
111
129
  );
112
130
  }
113
- function _(e, o, r = !0) {
114
- m.value?.setFieldValue?.(
131
+ function T(e, r, f = !0) {
132
+ B.value?.setFieldValue?.(
115
133
  u.name,
116
134
  void 0,
117
135
  !0,
118
- (t, n) => {
119
- if (!(!t[n] || !t[n][e])) {
120
- if (!r) {
121
- const f = Object.keys(t[n][e]);
122
- for (const s of f)
123
- s !== u.rowKey && delete t[n][s][s];
136
+ (o, n) => {
137
+ if (!(!o[n] || !o[n][e])) {
138
+ if (!f) {
139
+ const t = Object.keys(o[n][e]);
140
+ for (const s of t)
141
+ s !== u.rowKey && delete o[n][s][s];
124
142
  }
125
- Object.assign(t[n][e], { ...o });
143
+ Object.assign(o[n][e], { ...r });
126
144
  }
127
145
  }
128
146
  );
129
147
  }
130
- function E() {
131
- y?.([]);
148
+ function z() {
149
+ d?.([]);
132
150
  }
133
151
  return {
134
- add: a,
135
- addMultiple: B,
136
- remove: L,
137
- removeByKey: U,
138
- getRowData: j,
139
- getRowsData: A,
140
- setRowDataByKey: _,
141
- setRowData: O,
142
- clear: E,
143
- refreshRowIds: l,
144
- getRowDataByKey: k
152
+ add: L,
153
+ addByKey: U,
154
+ addMultiple: j,
155
+ remove: A,
156
+ removeByKey: O,
157
+ getRowData: k,
158
+ getRowsData: E,
159
+ setRowDataByKey: T,
160
+ setRowData: S,
161
+ clear: z,
162
+ refreshRowIds: v,
163
+ getRowDataByKey: _
145
164
  };
146
165
  };
147
166
  export {
148
- Q as useEditableApi
167
+ Y as useEditableApi
149
168
  };
@@ -4,6 +4,7 @@ import { ApFormInternalInstance } from '../../ap-form';
4
4
  import { EditableAgGridProps } from '../editable/interface';
5
5
  export declare const useEditableFormItemApi: <RecordType>(props: EditableAgGridProps<RecordType>, formApi: ApFormInternalInstance | undefined, tableData: Ref<RecordType[]>, shadowName: string) => {
6
6
  add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
7
+ addByKey: (defaultValue?: Partial<RecordType>, key?: number) => void;
7
8
  addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
8
9
  remove: (data: RecordType | RecordType[]) => void;
9
10
  removeByKey: (key: Key | Key[]) => void;