@aplus-frontend/ui 0.6.0-beta.3 → 0.6.0-beta.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.
@@ -1,15 +1,15 @@
1
- import { defineComponent as O, ref as c, unref as s, useSlots as K, toRef as G, watch as H, nextTick as U, createBlock as W, openBlock as $, mergeProps as h, withCtx as x, createVNode as q, createSlots as J, renderList as Q, renderSlot as X, normalizeProps as Y, guardReactiveProps as Z } from "vue";
2
- import { Table as I } from "@aplus-frontend/antdv";
3
- import { ApForm as g } from "../ap-form/index.mjs";
4
- import { isArray as M, isUndefined as ee, isNumber as m, cloneDeep as oe, omit as w } from "lodash-unified";
1
+ import { defineComponent as G, ref as c, unref as s, useSlots as H, toRef as U, watch as W, nextTick as $, createBlock as q, openBlock as J, mergeProps as h, withCtx as w, createVNode as Q, createSlots as X, renderList as Y, renderSlot as Z, normalizeProps as I, guardReactiveProps as M } from "vue";
2
+ import { Table as ee } from "@aplus-frontend/antdv";
3
+ import { ApForm as x } from "../ap-form/index.mjs";
4
+ import { isArray as g, isUndefined as oe, isNumber as m, cloneDeep as te, omit as y } from "lodash-unified";
5
5
  import "../config-provider/index.mjs";
6
- import { useInjectForm as te } from "../ap-form/context.mjs";
6
+ import { useInjectForm as ae } from "../ap-form/context.mjs";
7
7
  import { isDef as b } from "../utils/index.mjs";
8
- import ae from "./hooks/use-get-columns.mjs";
9
- import { scrollToRowIndex as le } from "./utils.mjs";
8
+ import le from "./hooks/use-get-columns.mjs";
9
+ import { scrollToRowIndex as ue } from "./utils.mjs";
10
10
  import { useNamespace as ne } from "../config-provider/hooks/use-namespace.mjs";
11
- import { useGlobalConfig as ue } from "../config-provider/hooks/use-global-config.mjs";
12
- const we = /* @__PURE__ */ O({
11
+ import { useGlobalConfig as fe } from "../config-provider/hooks/use-global-config.mjs";
12
+ const ye = /* @__PURE__ */ G({
13
13
  name: "EditableTableInner",
14
14
  __name: "form-item",
15
15
  props: {
@@ -109,119 +109,127 @@ const we = /* @__PURE__ */ O({
109
109
  default: () => ({})
110
110
  }
111
111
  },
112
- setup(y, {
113
- expose: C
112
+ setup(C, {
113
+ expose: R
114
114
  }) {
115
- const l = y;
116
- function R(e, t) {
117
- return M(t) ? t.reduce((n, o) => n == null ? void 0 : n[o], e) : e == null ? void 0 : e[t];
115
+ const l = C;
116
+ function B(e, a) {
117
+ return g(a) ? a.reduce((u, t) => u == null ? void 0 : u[t], e) : e == null ? void 0 : e[a];
118
118
  }
119
119
  const {
120
- internalInstance: a,
121
- model: B
122
- } = te(), d = c(R(s(B), l.name) || []), F = K(), T = G(l, "name"), D = g.useWatch(T);
123
- H(() => D.value, async (e) => {
124
- var t;
125
- await U(), d.value = e, (t = l.onChange) == null || t.call(l, e);
120
+ internalInstance: o,
121
+ model: F
122
+ } = ae(), d = c(B(s(F), l.name) || []), T = H(), D = U(l, "name"), V = x.useWatch(D);
123
+ W(() => V.value, async (e) => {
124
+ var a;
125
+ await $(), d.value = e, (a = l.onChange) == null || a.call(l, e);
126
126
  }, {
127
127
  deep: !0
128
128
  });
129
129
  const {
130
130
  b: L
131
- } = ne("editable-table"), p = c(), V = ue("valueTypeMap"), N = ae(l, V);
132
- function S(e, t) {
133
- var u;
134
- const n = ((u = s(d)) == null ? void 0 : u.length) || 0;
135
- if (b(l.maxLength) && n >= l.maxLength)
131
+ } = ne("editable-table"), p = c(), S = fe("valueTypeMap"), v = le(l, S);
132
+ function N(e, a) {
133
+ var n;
134
+ const u = ((n = s(d)) == null ? void 0 : n.length) || 0;
135
+ if (b(l.maxLength) && u >= l.maxLength)
136
136
  return;
137
- const o = {
137
+ const t = {
138
138
  ...e || {}
139
139
  };
140
- a == null || a.setFieldValue(l.name, o, !0, (r, f) => {
141
- if (!r[f]) {
142
- r[f] = [o];
140
+ o == null || o.setFieldValue(l.name, t, !0, (f, r) => {
141
+ if (!f[r]) {
142
+ f[r] = [t];
143
143
  return;
144
144
  }
145
- ee(t) ? r[f].push(o) : r[f].splice(t, 0, o);
145
+ oe(a) ? f[r].push(t) : f[r].splice(a, 0, t);
146
146
  });
147
147
  }
148
- function k(e, t = "suffix") {
149
- var r;
150
- const n = ((r = s(d)) == null ? void 0 : r.length) || 0, o = m(e) ? e : e.length;
151
- if (b(l.maxLength) && n + o > l.maxLength)
148
+ function E(e, a = "suffix") {
149
+ var f;
150
+ const u = ((f = s(d)) == null ? void 0 : f.length) || 0, t = m(e) ? e : e.length;
151
+ if (b(l.maxLength) && u + t > l.maxLength)
152
152
  return;
153
- const u = m(e) ? new Array(e).fill(0).map(() => ({})) : oe(e);
154
- a == null || a.setFieldValue(l.name, u, !0, (f, i) => {
155
- if (!f[i]) {
156
- f[i] = [...u];
153
+ const n = m(e) ? new Array(e).fill(0).map(() => ({})) : te(e);
154
+ o == null || o.setFieldValue(l.name, n, !0, (r, i) => {
155
+ if (!r[i]) {
156
+ r[i] = [...n];
157
157
  return;
158
158
  }
159
- t === "suffix" ? f[i].push(...u) : f[i].unshift(...u);
159
+ a === "suffix" ? r[i].push(...n) : r[i].unshift(...n);
160
160
  });
161
161
  }
162
- function v(e) {
163
- const t = new Set(m(e) ? [e] : e);
164
- a == null || a.setFieldValue(l.name, void 0, !0, (n, o) => {
165
- n[o] = n[o].filter((u, r) => !t.has(r));
162
+ function _(e) {
163
+ const a = new Set(m(e) ? [e] : e);
164
+ o == null || o.setFieldValue(l.name, void 0, !0, (u, t) => {
165
+ u[t] = u[t].filter((n, f) => !a.has(f));
166
166
  });
167
167
  }
168
- function E() {
168
+ function k(e) {
169
+ var u;
170
+ const a = new Set(g(e) ? e : [e]);
171
+ a.size !== 0 && ((u = o == null ? void 0 : o.setFieldValue) == null || u.call(o, l.name, void 0, !0, (t, n) => {
172
+ t[n] = t[n].filter((f) => !a.has(f[l.rowKey]));
173
+ }));
174
+ }
175
+ function j() {
169
176
  return s(d);
170
177
  }
171
- function _(e) {
172
- var t;
173
- return (t = s(d)) == null ? void 0 : t[e];
178
+ function z(e) {
179
+ var a;
180
+ return (a = s(d)) == null ? void 0 : a[e];
174
181
  }
175
- function j(e, t, n = !0) {
176
- a == null || a.setFieldValue(l.name, void 0, !0, (o, u) => {
177
- !o[u] || !o[u][e] || (o[u][e] = {
178
- ...n ? o[u][e] : {},
179
- ...t
182
+ function K(e, a, u = !0) {
183
+ o == null || o.setFieldValue(l.name, void 0, !0, (t, n) => {
184
+ !t[n] || !t[n][e] || (t[n][e] = {
185
+ ...u ? t[n][e] : {},
186
+ ...a
180
187
  });
181
188
  });
182
189
  }
183
190
  function P(e) {
184
- a == null || a.setFieldValue(l.name, e);
191
+ o == null || o.setFieldValue(l.name, e);
185
192
  }
186
- function z(e, t) {
187
- var o;
188
- const n = e === "end" ? d.value.length - 1 : e;
189
- le(n, (o = p.value) == null ? void 0 : o.$el, t);
193
+ function A(e, a) {
194
+ var t;
195
+ const u = e === "end" ? d.value.length - 1 : e;
196
+ ue(u, (t = p.value) == null ? void 0 : t.$el, a);
190
197
  }
191
- function A() {
198
+ function O() {
192
199
  var e;
193
- (e = a == null ? void 0 : a.setFieldValue) == null || e.call(a, l.name, []);
200
+ (e = o == null ? void 0 : o.setFieldValue) == null || e.call(o, l.name, []);
194
201
  }
195
- return C({
196
- add: S,
197
- remove: v,
198
- getRowData: _,
199
- getRowsData: E,
200
- setRowData: j,
201
- addMultiple: k,
202
- scrollTo: z,
202
+ return R({
203
+ add: N,
204
+ remove: _,
205
+ getRowData: z,
206
+ getRowsData: j,
207
+ setRowData: K,
208
+ addMultiple: E,
209
+ scrollTo: A,
203
210
  setTableData: P,
204
- clear: A
205
- }), (e, t) => ($(), W(s(g).FormItem, h(e.formItem, {
211
+ clear: O,
212
+ removeByKey: k
213
+ }), (e, a) => (J(), q(s(x).FormItem, h(e.formItem, {
206
214
  name: e.name,
207
215
  label: e.label
208
216
  }), {
209
- default: x(() => [q(s(I), h(s(w)(l, ["name", "maxLength", "onChange"]), {
217
+ default: w(() => [Q(s(ee), h(s(y)(l, ["name", "maxLength", "onChange"]), {
210
218
  ref_key: "tableRef",
211
219
  ref: p,
212
220
  class: s(L)(),
213
- columns: s(N),
221
+ columns: s(v),
214
222
  "data-source": d.value
215
- }), J({
223
+ }), X({
216
224
  _: 2
217
- }, [Q(s(w)(F, ["headerCell"]), (n, o) => ({
218
- name: o,
219
- fn: x((u) => [X(e.$slots, o, Y(Z(u || {})))])
225
+ }, [Y(s(y)(T, ["headerCell"]), (u, t) => ({
226
+ name: t,
227
+ fn: w((n) => [Z(e.$slots, t, I(M(n || {})))])
220
228
  }))]), 1040, ["class", "columns", "data-source"])]),
221
229
  _: 3
222
230
  }, 16, ["name", "label"]));
223
231
  }
224
232
  });
225
233
  export {
226
- we as default
234
+ ye as default
227
235
  };
@@ -1,25 +1,11 @@
1
- import { EditableTableProps, EditableColumnType } from './interface';
2
- import { NamePath, ValidateOptions } from '@aplus-frontend/antdv/es/form/interface';
1
+ import { EditableTableProps, EditableColumnType, EditableTableExpose } from './interface';
3
2
  import { Recordable } from '../type';
4
- import { StandardBehaviorOptions } from '../../node_modules/scroll-into-view-if-needed';
5
3
  import { VNodeProps, AllowedComponentProps, ComponentCustomProps, PublicProps, ShallowUnwrapRef, VNode } from 'vue';
6
4
  declare const _default: <RecordType extends Recordable = any>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
7
5
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
8
6
  readonly "onUpdate:value"?: ((...args: any[]) => any) | undefined;
9
7
  } & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, "onUpdate:value"> & EditableTableProps<RecordType> & Partial<{}>> & PublicProps;
10
- expose(exposed: ShallowUnwrapRef<{
11
- resetFields: () => void;
12
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
13
- add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
14
- remove: (index: number | number[]) => void;
15
- getRowData: (index: number) => RecordType;
16
- getRowsData: () => RecordType[];
17
- setRowData: (index: number, payload: any, merge?: boolean) => void;
18
- addMultiple: (list: number | Partial<RecordType>[], insetIn?: "prefix" | "suffix") => void;
19
- scrollTo: (index: number | "end", options?: StandardBehaviorOptions) => void;
20
- clear: () => void;
21
- setTableData: (nextTableData: RecordType[]) => void;
22
- }>): void;
8
+ expose(exposed: ShallowUnwrapRef<EditableTableExpose>): void;
23
9
  attrs: any;
24
10
  slots: Readonly<{
25
11
  default: any;
@@ -1,16 +1,16 @@
1
- import { defineComponent as $, useSlots as q, ref as w, watch as y, unref as s, createBlock as J, openBlock as Q, withCtx as h, createVNode as C, mergeProps as X, createSlots as Y, renderList as Z, renderSlot as M, normalizeProps as ee, guardReactiveProps as te } from "vue";
2
- import { Table as ae } from "@aplus-frontend/antdv";
1
+ import { defineComponent as q, useSlots as J, ref as y, watch as C, unref as r, createBlock as Q, openBlock as X, withCtx as h, createVNode as b, mergeProps as Y, createSlots as Z, renderList as M, renderSlot as ee, normalizeProps as te, guardReactiveProps as ae } from "vue";
2
+ import { Table as ne } from "@aplus-frontend/antdv";
3
3
  import { ApForm as x } from "../ap-form/index.mjs";
4
- import { isEqual as ne, isArray as b, isUndefined as oe, isNumber as g, cloneDeep as le, omit as R } from "lodash-unified";
4
+ import { isEqual as oe, isArray as v, isUndefined as le, isNumber as g, cloneDeep as ue, omit as R } from "lodash-unified";
5
5
  import "../config-provider/index.mjs";
6
6
  import "../hooks/index.mjs";
7
7
  import { isDef as F } from "../utils/index.mjs";
8
- import { scrollToRowIndex as ue } from "./utils.mjs";
9
- import se from "./hooks/use-get-columns.mjs";
10
- import { useNamespace as re } from "../config-provider/hooks/use-namespace.mjs";
11
- import { useControllableValue as ie } from "../hooks/useControllableValue.mjs";
8
+ import { scrollToRowIndex as se } from "./utils.mjs";
9
+ import re from "./hooks/use-get-columns.mjs";
10
+ import { useNamespace as ie } from "../config-provider/hooks/use-namespace.mjs";
11
+ import { useControllableValue as fe } from "../hooks/useControllableValue.mjs";
12
12
  import { useGlobalConfig as de } from "../config-provider/hooks/use-global-config.mjs";
13
- const Re = /* @__PURE__ */ $({
13
+ const Fe = /* @__PURE__ */ q({
14
14
  name: "EditableTable",
15
15
  __name: "index",
16
16
  props: {
@@ -113,137 +113,145 @@ const Re = /* @__PURE__ */ $({
113
113
  expose: V,
114
114
  emit: T
115
115
  }) {
116
- const n = B, {
117
- b: L
118
- } = re("editable-table"), _ = q(), D = T, v = w(), {
116
+ const o = B, {
117
+ b: D
118
+ } = ie("editable-table"), L = J(), S = T, w = y(), {
119
119
  value: m,
120
- updateValue: E
121
- } = ie(n, D), i = w(), N = de("valueTypeMap"), c = x.useWatch(n.name, i);
122
- y(() => c.value, (e) => {
120
+ updateValue: _
121
+ } = fe(o, S), i = y(), E = de("valueTypeMap"), c = x.useWatch(o.name, i);
122
+ C(() => c.value, (e) => {
123
123
  var t;
124
- E(e), (t = n.onChange) == null || t.call(n, e);
124
+ _(e), (t = o.onChange) == null || t.call(o, e);
125
125
  }, {
126
126
  deep: !0,
127
127
  flush: "post"
128
- }), y(m, (e) => {
128
+ }), C(m, (e) => {
129
129
  var t;
130
- e !== s(c) && (ne(e, s(c)) || (t = i.value) == null || t.setFieldValue(n.name, e));
130
+ e !== r(c) && (oe(e, r(c)) || (t = i.value) == null || t.setFieldValue(o.name, e));
131
131
  }, {
132
132
  deep: !0
133
133
  });
134
- const S = se(n, N);
134
+ const N = re(o, E);
135
135
  function k() {
136
136
  var e;
137
137
  (e = i.value) == null || e.resetFields();
138
138
  }
139
139
  function A(e) {
140
- return e ? (b(e) ? e : [e]).map((o) => b(o) ? [n.name, ...o] : [n.name, o]) : void 0;
140
+ return e ? (v(e) ? e : [e]).map((a) => v(a) ? [o.name, ...a] : [o.name, a]) : void 0;
141
141
  }
142
- async function I(e, t) {
143
- var a;
144
- const o = await ((a = i.value) == null ? void 0 : a.validateFields(A(e), t));
145
- return o == null ? void 0 : o[n.name];
142
+ async function z(e, t) {
143
+ var n;
144
+ const a = await ((n = i.value) == null ? void 0 : n.validateFields(A(e), t));
145
+ return a == null ? void 0 : a[o.name];
146
146
  }
147
- function P(e, t) {
148
- var l, u, r;
149
- const o = ((l = s(m)) == null ? void 0 : l.length) || 0;
150
- if (F(n.maxLength) && o >= n.maxLength)
147
+ function I(e, t) {
148
+ var l, u, s;
149
+ const a = ((l = r(m)) == null ? void 0 : l.length) || 0;
150
+ if (F(o.maxLength) && a >= o.maxLength)
151
151
  return;
152
- const a = {
152
+ const n = {
153
153
  ...e || {}
154
154
  };
155
- (r = (u = i.value) == null ? void 0 : u.setFieldValue) == null || r.call(u, n.name, a, !0, (d, f) => {
156
- if (!d[f]) {
157
- d[f] = [a];
155
+ (s = (u = i.value) == null ? void 0 : u.setFieldValue) == null || s.call(u, o.name, n, !0, (f, d) => {
156
+ if (!f[d]) {
157
+ f[d] = [n];
158
158
  return;
159
159
  }
160
- oe(t) ? d[f].push(a) : d[f].splice(t, 0, a);
160
+ le(t) ? f[d].push(n) : f[d].splice(t, 0, n);
161
161
  });
162
162
  }
163
- function j(e, t = "suffix") {
164
- var u, r, d;
165
- const o = ((u = s(m)) == null ? void 0 : u.length) || 0, a = g(e) ? e : e.length;
166
- if (F(n.maxLength) && o + a > n.maxLength)
163
+ function K(e, t = "suffix") {
164
+ var u, s, f;
165
+ const a = ((u = r(m)) == null ? void 0 : u.length) || 0, n = g(e) ? e : e.length;
166
+ if (F(o.maxLength) && a + n > o.maxLength)
167
167
  return;
168
- const l = g(e) ? new Array(e).fill(0).map(() => ({})) : le(e);
169
- (d = (r = i.value) == null ? void 0 : r.setFieldValue) == null || d.call(r, n.name, l, !0, (f, p) => {
170
- if (!f[p]) {
171
- f[p] = [...l];
168
+ const l = g(e) ? new Array(e).fill(0).map(() => ({})) : ue(e);
169
+ (f = (s = i.value) == null ? void 0 : s.setFieldValue) == null || f.call(s, o.name, l, !0, (d, p) => {
170
+ if (!d[p]) {
171
+ d[p] = [...l];
172
172
  return;
173
173
  }
174
- t === "suffix" ? f[p].push(...l) : f[p].unshift(...l);
174
+ t === "suffix" ? d[p].push(...l) : d[p].unshift(...l);
175
175
  });
176
176
  }
177
- function z(e) {
178
- var o, a;
177
+ function P(e) {
178
+ var a, n;
179
179
  const t = new Set(g(e) ? [e] : e);
180
- (a = (o = i.value) == null ? void 0 : o.setFieldValue) == null || a.call(o, n.name, void 0, !0, (l, u) => {
181
- l[u] = l[u].filter((r, d) => !t.has(d));
180
+ (n = (a = i.value) == null ? void 0 : a.setFieldValue) == null || n.call(a, o.name, void 0, !0, (l, u) => {
181
+ l[u] = l[u].filter((s, f) => !t.has(f));
182
182
  });
183
183
  }
184
+ function j(e) {
185
+ var a, n;
186
+ const t = new Set(v(e) ? e : [e]);
187
+ t.size !== 0 && ((n = (a = i.value) == null ? void 0 : a.setFieldValue) == null || n.call(a, o.name, void 0, !0, (l, u) => {
188
+ l[u] = l[u].filter((s) => !t.has(s[o.rowKey]));
189
+ }));
190
+ }
184
191
  function O() {
185
- return s(m);
192
+ return r(m);
186
193
  }
187
- function K(e) {
194
+ function U(e) {
188
195
  var t;
189
- (t = i.value) == null || t.setFieldValue(n.name, e);
196
+ (t = i.value) == null || t.setFieldValue(o.name, e);
190
197
  }
191
- function U(e) {
198
+ function G(e) {
192
199
  var t;
193
- return (t = s(m)) == null ? void 0 : t[e];
200
+ return (t = r(m)) == null ? void 0 : t[e];
194
201
  }
195
- function G(e, t, o = !0) {
196
- var a, l;
197
- (l = (a = i.value) == null ? void 0 : a.setFieldValue) == null || l.call(a, n.name, void 0, !0, (u, r) => {
198
- !u[r] || !u[r][e] || (u[r][e] = {
199
- ...o ? u[r][e] : {},
202
+ function H(e, t, a = !0) {
203
+ var n, l;
204
+ (l = (n = i.value) == null ? void 0 : n.setFieldValue) == null || l.call(n, o.name, void 0, !0, (u, s) => {
205
+ !u[s] || !u[s][e] || (u[s][e] = {
206
+ ...a ? u[s][e] : {},
200
207
  ...t
201
208
  });
202
209
  });
203
210
  }
204
- function H(e, t) {
205
- var a;
206
- const o = e === "end" ? m.value.length - 1 : e;
207
- ue(o, (a = v.value) == null ? void 0 : a.$el, t);
211
+ function W(e, t) {
212
+ var n;
213
+ const a = e === "end" ? m.value.length - 1 : e;
214
+ se(a, (n = w.value) == null ? void 0 : n.$el, t);
208
215
  }
209
- function W() {
216
+ function $() {
210
217
  var e, t;
211
- (t = (e = i.value) == null ? void 0 : e.setFieldValue) == null || t.call(e, n.name, []);
218
+ (t = (e = i.value) == null ? void 0 : e.setFieldValue) == null || t.call(e, o.name, []);
212
219
  }
213
220
  return V({
214
221
  resetFields: k,
215
- validateFields: I,
216
- add: P,
217
- remove: z,
218
- getRowData: U,
222
+ validateFields: z,
223
+ add: I,
224
+ remove: P,
225
+ getRowData: G,
219
226
  getRowsData: O,
220
- setRowData: G,
221
- addMultiple: j,
222
- scrollTo: H,
223
- clear: W,
224
- setTableData: K
225
- }), (e, t) => (Q(), J(s(x), {
227
+ setRowData: H,
228
+ addMultiple: K,
229
+ scrollTo: W,
230
+ clear: $,
231
+ setTableData: U,
232
+ removeByKey: j
233
+ }), (e, t) => (X(), Q(r(x), {
226
234
  ref_key: "formRef",
227
235
  ref: i,
228
236
  "initial-values": {
229
- [n.name]: s(m)
237
+ [o.name]: r(m)
230
238
  }
231
239
  }, {
232
- default: h(() => [C(s(x).FormItem, {
240
+ default: h(() => [b(r(x).FormItem, {
233
241
  name: e.name,
234
242
  "no-style": ""
235
243
  }, {
236
- default: h(() => [C(s(ae), X(s(R)(n, ["name", "value", "onUpdate:value", "maxLength", "onChange"]), {
244
+ default: h(() => [b(r(ne), Y(r(R)(o, ["name", "value", "onUpdate:value", "maxLength", "onChange"]), {
237
245
  ref_key: "tableRef",
238
- ref: v,
239
- class: s(L)(),
240
- columns: s(S),
241
- "data-source": s(m)
242
- }), Y({
246
+ ref: w,
247
+ class: r(D)(),
248
+ columns: r(N),
249
+ "data-source": r(m)
250
+ }), Z({
243
251
  _: 2
244
- }, [Z(s(R)(_, ["headerCell"]), (o, a) => ({
245
- name: a,
246
- fn: h((l) => [M(e.$slots, a, ee(te(l || {})))])
252
+ }, [M(r(R)(L, ["headerCell"]), (a, n) => ({
253
+ name: n,
254
+ fn: h((l) => [ee(e.$slots, n, te(ae(l || {})))])
247
255
  }))]), 1040, ["class", "columns", "data-source"])]),
248
256
  _: 3
249
257
  }, 8, ["name"])]),
@@ -252,5 +260,5 @@ const Re = /* @__PURE__ */ $({
252
260
  }
253
261
  });
254
262
  export {
255
- Re as default
263
+ Fe as default
256
264
  };
@@ -7,6 +7,7 @@ import { EllipsisConfig } from '@aplus-frontend/antdv/es/typography/Base';
7
7
  import { StandardBehaviorOptions } from '../../node_modules/scroll-into-view-if-needed';
8
8
  import { Recordable } from '../type';
9
9
  import { ApFormItemProps } from '../ap-form';
10
+ import { Key } from '@aplus-frontend/antdv/es/_util/type';
10
11
  export type EditableColumnType<RecordType = any, ExtraValueType = 'text', ValueType extends ApTableValueTypes = ApTableValueTypes, MergedValueType extends ExtraValueType | ValueType = ExtraValueType | ValueType> = MergedValueType extends ExtraValueType | ValueType ? Omit<ColumnType<RecordType>, 'children' | 'customRender' | 'ellipsis'> & {
11
12
  children?: EditableColumnType<RecordType, ExtraValueType, ValueType, MergedValueType>[];
12
13
  /**
@@ -138,6 +139,12 @@ export type EditableTableExpose<ModelType = any, RecordType = any> = {
138
139
  * @returns
139
140
  */
140
141
  remove: (index: number | number[]) => void;
142
+ /**
143
+ * 通过key删除数据
144
+ * @param key
145
+ * @returns
146
+ */
147
+ removeByKey: (key: Key | Key[]) => void;
141
148
  /**
142
149
  * 清空所有数据
143
150
  * @returns
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),g=require("../../ap-form/index.js"),i=require("lodash-unified");require("../../config-provider/index.js");const h=require("../../utils/index.js"),j=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const E=require("../../ap-form/context.js"),O=require("../../config-provider/hooks/use-namespace.js"),P=require("../../config-provider/hooks/use-global-config.js"),z=require("../index.vue.js"),A=o.defineComponent({name:"EditableGrid",__name:"form-item",props:{dropdownPrefixCls:{},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},tableLayout:{default:"fixed"},title:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object],default:!1},transformCellText:{},rowClassName:{},stripe:{type:Boolean},headerRowClassName:{},footerRowClassName:{},cellClassName:{},headerCellClassName:{},footerCellClassName:{},rowStyle:{},headerRowStyle:{},footerRowStyle:{},cellStyle:{},headerCellStyle:{},footerCellStyle:{},height:{},minHeight:{},maxHeight:{},mergeCells:{},mergeFooterItems:{},cellConfig:{},loading:{type:Boolean,default:void 0},loadingConfig:{},headerCellConfig:{},footerCellConfig:{},round:{type:Boolean},rowSelection:{type:Boolean,default:void 0},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},size:{default:"mini"},adaptive:{type:Boolean,default:!1},columnResizable:{type:[Boolean,Object],default:!1},rowKey:{default:"key"},footer:{},virtual:{type:[Boolean,Object],default:void 0},expandable:{},value:{},columns:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},onFieldChange:{},label:{},name:{},formItem:{default:()=>({})}},setup(y,{expose:C}){const b=o.useSlots(),n=y,{b:w}=O.useNamespace("editable-grid");function x(e,t){return i.isArray(t)?t.reduce((u,l)=>u==null?void 0:u[l],e):e==null?void 0:e[t]}const{internalInstance:a,model:R}=E.useInjectForm(),p=o.toRef(n.name),d=o.ref(x(o.unref(R),p.value)||[]),S=g.ApForm.useWatch(p);o.watch(()=>S.value,async e=>{var t;await o.nextTick(),d.value=e,(t=n.onChange)==null||t.call(n,e)},{deep:!0});const m=o.ref(),B=P.useGlobalConfig("valueTypeMap"),v=j.useGetEditableColumns(n,B);function N(e,t){var s;const u=((s=o.unref(d))==null?void 0:s.length)||0;if(h.isDef(n.maxLength)&&u>=n.maxLength)return;const l={...e||{}};a==null||a.setFieldValue(n.name,l,!0,(f,r)=>{if(!f[r]){f[r]=[l];return}i.isUndefined(t)?f[r].push(l):f[r].splice(t,0,l)})}function _(e,t="suffix"){var f;const u=((f=o.unref(d))==null?void 0:f.length)||0,l=i.isNumber(e)?e:e.length;if(h.isDef(n.maxLength)&&u+l>n.maxLength)return;const s=i.isNumber(e)?new Array(e).fill(0).map(()=>({})):i.cloneDeep(e);a==null||a.setFieldValue(n.name,s,!0,(r,c)=>{if(!r[c]){r[c]=[...s];return}t==="suffix"?r[c].push(...s):r[c].unshift(...s)})}function F(e){const t=new Set(i.isNumber(e)?[e]:e);a==null||a.setFieldValue(n.name,void 0,!0,(u,l)=>{u[l]=u[l].filter((s,f)=>!t.has(f))})}function q(){return o.unref(d)}function D(e){var t;return(t=o.unref(d))==null?void 0:t[e]}function k(e,t,u=!0){a==null||a.setFieldValue(n.name,void 0,!0,(l,s)=>{if(!(!l[s]||!l[s][e])){if(!u){const f=Object.keys(l[s][e]);for(const r of f)r!==n.rowKey&&delete l[s][e][r]}Object.assign(l[s][e],{...t})}})}function L(e){a==null||a.setFieldValue(n.name,e)}function T(e){var u;const t=e==="end"?d.value.length-1:e;(u=m.value)==null||u.scrollToRow(t)}function V(){var e;(e=a==null?void 0:a.setFieldValue)==null||e.call(a,n.name,[])}return C({add:N,remove:F,getRowData:D,getRowsData:q,setRowData:k,addMultiple:_,scrollTo:T,setTableData:L,clear:V}),(e,t)=>(o.openBlock(),o.createBlock(o.unref(g.ApForm).FormItem,o.mergeProps(e.formItem,{name:e.name,label:e.label}),{default:o.withCtx(()=>[o.createVNode(z.default,o.mergeProps(o.unref(i.omit)(n,["name","value","onUpdate:value","maxLength","onChange","defaultValue","formItem"]),{ref_key:"tableRef",ref:m,class:o.unref(w)(),columns:o.unref(v),"data-source":d.value,"search-form":!1}),o.createSlots({_:2},[o.renderList(b,(u,l)=>({name:l,fn:o.withCtx(s=>[o.renderSlot(e.$slots,l,o.normalizeProps(o.guardReactiveProps(s||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["name","label"]))}});exports.default=A;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),y=require("../../ap-form/index.js"),i=require("lodash-unified");require("../../config-provider/index.js");const g=require("../../utils/index.js"),E=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const O=require("../../ap-form/context.js"),P=require("../../config-provider/hooks/use-namespace.js"),z=require("../../config-provider/hooks/use-global-config.js"),A=require("../index.vue.js"),K=o.defineComponent({name:"EditableGrid",__name:"form-item",props:{dropdownPrefixCls:{},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},tableLayout:{default:"fixed"},title:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object],default:!1},transformCellText:{},rowClassName:{},stripe:{type:Boolean},headerRowClassName:{},footerRowClassName:{},cellClassName:{},headerCellClassName:{},footerCellClassName:{},rowStyle:{},headerRowStyle:{},footerRowStyle:{},cellStyle:{},headerCellStyle:{},footerCellStyle:{},height:{},minHeight:{},maxHeight:{},mergeCells:{},mergeFooterItems:{},cellConfig:{},loading:{type:Boolean,default:void 0},loadingConfig:{},headerCellConfig:{},footerCellConfig:{},round:{type:Boolean},rowSelection:{type:Boolean,default:void 0},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},size:{default:"mini"},adaptive:{type:Boolean,default:!1},columnResizable:{type:[Boolean,Object],default:!1},rowKey:{default:"key"},footer:{},virtual:{type:[Boolean,Object],default:void 0},expandable:{},value:{},columns:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},onFieldChange:{},label:{},name:{},formItem:{default:()=>({})}},setup(h,{expose:C}){const w=o.useSlots(),u=h,{b}=P.useNamespace("editable-grid");function x(e,a){return i.isArray(a)?a.reduce((n,l)=>n==null?void 0:n[l],e):e==null?void 0:e[a]}const{internalInstance:t,model:R}=O.useInjectForm(),p=o.toRef(u.name),d=o.ref(x(o.unref(R),p.value)||[]),S=y.ApForm.useWatch(p);o.watch(()=>S.value,async e=>{var a;await o.nextTick(),d.value=e,(a=u.onChange)==null||a.call(u,e)},{deep:!0});const m=o.ref(),B=z.useGlobalConfig("valueTypeMap"),v=E.useGetEditableColumns(u,B);function N(e,a){var s;const n=((s=o.unref(d))==null?void 0:s.length)||0;if(g.isDef(u.maxLength)&&n>=u.maxLength)return;const l={...e||{}};t==null||t.setFieldValue(u.name,l,!0,(r,f)=>{if(!r[f]){r[f]=[l];return}i.isUndefined(a)?r[f].push(l):r[f].splice(a,0,l)})}function _(e,a="suffix"){var r;const n=((r=o.unref(d))==null?void 0:r.length)||0,l=i.isNumber(e)?e:e.length;if(g.isDef(u.maxLength)&&n+l>u.maxLength)return;const s=i.isNumber(e)?new Array(e).fill(0).map(()=>({})):i.cloneDeep(e);t==null||t.setFieldValue(u.name,s,!0,(f,c)=>{if(!f[c]){f[c]=[...s];return}a==="suffix"?f[c].push(...s):f[c].unshift(...s)})}function F(e){const a=new Set(i.isNumber(e)?[e]:e);t==null||t.setFieldValue(u.name,void 0,!0,(n,l)=>{n[l]=n[l].filter((s,r)=>!a.has(r))})}function D(e){var n;const a=new Set(i.isArray(e)?e:[e]);a.size!==0&&((n=t==null?void 0:t.setFieldValue)==null||n.call(t,u.name,void 0,!0,(l,s)=>{l[s]=l[s].filter(r=>!a.has(r[u.rowKey]))}))}function q(){return o.unref(d)}function T(e){var a;return(a=o.unref(d))==null?void 0:a[e]}function V(e,a,n=!0){t==null||t.setFieldValue(u.name,void 0,!0,(l,s)=>{if(!(!l[s]||!l[s][e])){if(!n){const r=Object.keys(l[s][e]);for(const f of r)f!==u.rowKey&&delete l[s][e][f]}Object.assign(l[s][e],{...a})}})}function L(e){t==null||t.setFieldValue(u.name,e)}function j(e){var n;const a=e==="end"?d.value.length-1:e;(n=m.value)==null||n.scrollToRow(a)}function k(){var e;(e=t==null?void 0:t.setFieldValue)==null||e.call(t,u.name,[])}return C({add:N,remove:F,getRowData:T,getRowsData:q,setRowData:V,addMultiple:_,scrollTo:j,setTableData:L,clear:k,removeByKey:D}),(e,a)=>(o.openBlock(),o.createBlock(o.unref(y.ApForm).FormItem,o.mergeProps(e.formItem,{name:e.name,label:e.label}),{default:o.withCtx(()=>[o.createVNode(A.default,o.mergeProps(o.unref(i.omit)(u,["name","value","onUpdate:value","maxLength","onChange","defaultValue","formItem"]),{ref_key:"tableRef",ref:m,class:o.unref(b)(),columns:o.unref(v),"data-source":d.value,"search-form":!1}),o.createSlots({_:2},[o.renderList(w,(n,l)=>({name:l,fn:o.withCtx(s=>[o.renderSlot(e.$slots,l,o.normalizeProps(o.guardReactiveProps(s||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["name","label"]))}});exports.default=K;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),y=require("../../ap-form/index.js"),c=require("lodash-unified");require("../../config-provider/index.js");require("../../hooks/index.js");const C=require("../../utils/index.js"),z=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const I=require("../../config-provider/hooks/use-namespace.js"),G=require("../../hooks/useControllableValue.js"),H=require("../../config-provider/hooks/use-global-config.js"),K=require("../index.vue.js"),U=t.defineComponent({name:"EditableGrid",__name:"index",props:{dropdownPrefixCls:{},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},tableLayout:{default:"fixed"},title:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object],default:!1},transformCellText:{},rowClassName:{},stripe:{type:Boolean},headerRowClassName:{},footerRowClassName:{},cellClassName:{},headerCellClassName:{},footerCellClassName:{},rowStyle:{},headerRowStyle:{},footerRowStyle:{},cellStyle:{},headerCellStyle:{},footerCellStyle:{},height:{},minHeight:{},maxHeight:{},mergeCells:{},mergeFooterItems:{},cellConfig:{},loading:{type:Boolean,default:void 0},loadingConfig:{},headerCellConfig:{},footerCellConfig:{},round:{type:Boolean},rowSelection:{type:Boolean,default:void 0},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},size:{default:"mini"},adaptive:{type:Boolean,default:!1},columnResizable:{type:[Boolean,Object],default:!1},rowKey:{default:"key"},footer:{},virtual:{type:[Boolean,Object],default:void 0},expandable:{},value:{},columns:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},name:{default:"ap-editable-table-inner-name"},onFieldChange:{}},emits:["update:value"],setup(w,{expose:v,emit:x}){const b=t.useSlots(),n=w,{b:R}=I.useNamespace("editable-grid"),S=x,g=t.ref(),{value:p,updateValue:B}=G.useControllableValue(n,S),f=t.ref(),F=H.useGlobalConfig("valueTypeMap"),h=y.ApForm.useWatch(n.name,f);t.watch(()=>h.value,e=>{var a;B(e),(a=n.onChange)==null||a.call(n,e)},{deep:!0,flush:"post"}),t.watch(p,e=>{var a;e!==t.unref(h)&&(c.isEqual(e,t.unref(h))||(a=f.value)==null||a.setFieldValue(n.name,e))},{deep:!0});const _=z.useGetEditableColumns(n,F);function N(){var e;(e=f.value)==null||e.resetFields()}function V(e){return e?(c.isArray(e)?e:[e]).map(l=>c.isArray(l)?[n.name,...l]:[n.name,l]):void 0}async function q(e,a){var o;const l=await((o=f.value)==null?void 0:o.validateFields(V(e),a));return l==null?void 0:l[n.name]}function k(e,a){var r,u,s;const l=((r=t.unref(p))==null?void 0:r.length)||0;if(C.isDef(n.maxLength)&&l>=n.maxLength)return;const o={...e||{}};(s=(u=f.value)==null?void 0:u.setFieldValue)==null||s.call(u,n.name,o,!0,(d,i)=>{if(!d[i]){d[i]=[o];return}c.isUndefined(a)?d[i].push(o):d[i].splice(a,0,o)})}function E(e,a="suffix"){var u,s,d;const l=((u=t.unref(p))==null?void 0:u.length)||0,o=c.isNumber(e)?e:e.length;if(C.isDef(n.maxLength)&&l+o>n.maxLength)return;const r=c.isNumber(e)?new Array(e).fill(0).map(()=>({})):c.cloneDeep(e);(d=(s=f.value)==null?void 0:s.setFieldValue)==null||d.call(s,n.name,r,!0,(i,m)=>{if(!i[m]){i[m]=[...r];return}a==="suffix"?i[m].push(...r):i[m].unshift(...r)})}function L(e){var l,o;const a=new Set(c.isNumber(e)?[e]:e);(o=(l=f.value)==null?void 0:l.setFieldValue)==null||o.call(l,n.name,void 0,!0,(r,u)=>{r[u]=r[u].filter((s,d)=>!a.has(d))})}function A(){return t.unref(p)}function D(e){var a;(a=f.value)==null||a.setFieldValue(n.name,e)}function T(e){var a;return(a=t.unref(p))==null?void 0:a[e]}function j(e,a,l=!0){var o,r;(r=(o=f.value)==null?void 0:o.setFieldValue)==null||r.call(o,n.name,void 0,!0,(u,s)=>{if(!(!u[s]||!u[s][e])){if(!l){const d=Object.keys(u[s][e]);for(const i of d)i!==n.rowKey&&delete u[s][e][i]}Object.assign(u[s][e],{...a})}})}function O(e){var l;const a=e==="end"?p.value.length-1:e;(l=g.value)==null||l.scrollToRow(a)}function P(){var e,a;(a=(e=f.value)==null?void 0:e.setFieldValue)==null||a.call(e,n.name,[])}return v({resetFields:N,validateFields:q,add:k,remove:L,getRowData:T,getRowsData:A,setRowData:j,addMultiple:E,scrollTo:O,clear:P,setTableData:D}),(e,a)=>(t.openBlock(),t.createBlock(t.unref(y.ApForm),{ref_key:"formRef",ref:f,"initial-values":{[n.name]:t.unref(p)},style:{height:"100%"}},{default:t.withCtx(()=>[t.createVNode(t.unref(y.ApForm).FormItem,{name:e.name,"no-style":""},{default:t.withCtx(()=>[t.createVNode(K.default,t.mergeProps(t.unref(c.omit)(n,["name","value","onUpdate:value","maxLength","onChange","defaultValue"]),{ref_key:"tableRef",ref:g,class:t.unref(R)(),columns:t.unref(_),"data-source":t.unref(p),"search-form":!1}),t.createSlots({_:2},[t.renderList(b,(l,o)=>({name:o,fn:t.withCtx(r=>[t.renderSlot(e.$slots,o,t.normalizeProps(t.guardReactiveProps(r||{})))])}))]),1040,["class","columns","data-source"])]),_:3},8,["name"])]),_:3},8,["initial-values"]))}});exports.default=U;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),y=require("../../ap-form/index.js"),c=require("lodash-unified");require("../../config-provider/index.js");require("../../hooks/index.js");const C=require("../../utils/index.js"),P=require("../hooks/use-editable-columns.js");require("../index.vue2.js");const I=require("../../config-provider/hooks/use-namespace.js"),G=require("../../hooks/useControllableValue.js"),H=require("../../config-provider/hooks/use-global-config.js"),U=require("../index.vue.js"),W=a.defineComponent({name:"EditableGrid",__name:"index",props:{dropdownPrefixCls:{},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},tableLayout:{default:"fixed"},title:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object],default:!1},transformCellText:{},rowClassName:{},stripe:{type:Boolean},headerRowClassName:{},footerRowClassName:{},cellClassName:{},headerCellClassName:{},footerCellClassName:{},rowStyle:{},headerRowStyle:{},footerRowStyle:{},cellStyle:{},headerCellStyle:{},footerCellStyle:{},height:{},minHeight:{},maxHeight:{},mergeCells:{},mergeFooterItems:{},cellConfig:{},loading:{type:Boolean,default:void 0},loadingConfig:{},headerCellConfig:{},footerCellConfig:{},round:{type:Boolean},rowSelection:{type:Boolean,default:void 0},onLoadingChange:{},onShownColumnsChange:{},pagination:{type:[Boolean,Object],default:!1},searchFormWrapperStyle:{},tableWrapperStyle:{},wrapperStyle:{},size:{default:"mini"},adaptive:{type:Boolean,default:!1},columnResizable:{type:[Boolean,Object],default:!1},rowKey:{default:"key"},footer:{},virtual:{type:[Boolean,Object],default:void 0},expandable:{},value:{},columns:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},name:{default:"ap-editable-table-inner-name"},onFieldChange:{}},emits:["update:value"],setup(w,{expose:v,emit:x}){const b=a.useSlots(),l=w,{b:R}=I.useNamespace("editable-grid"),S=x,g=a.ref(),{value:p,updateValue:B}=G.useControllableValue(l,S),i=a.ref(),F=H.useGlobalConfig("valueTypeMap"),h=y.ApForm.useWatch(l.name,i);a.watch(()=>h.value,e=>{var t;B(e),(t=l.onChange)==null||t.call(l,e)},{deep:!0,flush:"post"}),a.watch(p,e=>{var t;e!==a.unref(h)&&(c.isEqual(e,a.unref(h))||(t=i.value)==null||t.setFieldValue(l.name,e))},{deep:!0});const _=P.useGetEditableColumns(l,F);function N(){var e;(e=i.value)==null||e.resetFields()}function V(e){return e?(c.isArray(e)?e:[e]).map(n=>c.isArray(n)?[l.name,...n]:[l.name,n]):void 0}async function q(e,t){var o;const n=await((o=i.value)==null?void 0:o.validateFields(V(e),t));return n==null?void 0:n[l.name]}function A(e,t){var r,u,s;const n=((r=a.unref(p))==null?void 0:r.length)||0;if(C.isDef(l.maxLength)&&n>=l.maxLength)return;const o={...e||{}};(s=(u=i.value)==null?void 0:u.setFieldValue)==null||s.call(u,l.name,o,!0,(d,f)=>{if(!d[f]){d[f]=[o];return}c.isUndefined(t)?d[f].push(o):d[f].splice(t,0,o)})}function D(e,t="suffix"){var u,s,d;const n=((u=a.unref(p))==null?void 0:u.length)||0,o=c.isNumber(e)?e:e.length;if(C.isDef(l.maxLength)&&n+o>l.maxLength)return;const r=c.isNumber(e)?new Array(e).fill(0).map(()=>({})):c.cloneDeep(e);(d=(s=i.value)==null?void 0:s.setFieldValue)==null||d.call(s,l.name,r,!0,(f,m)=>{if(!f[m]){f[m]=[...r];return}t==="suffix"?f[m].push(...r):f[m].unshift(...r)})}function E(e){var n,o;const t=new Set(c.isNumber(e)?[e]:e);(o=(n=i.value)==null?void 0:n.setFieldValue)==null||o.call(n,l.name,void 0,!0,(r,u)=>{r[u]=r[u].filter((s,d)=>!t.has(d))})}function L(e){var n,o;const t=new Set(c.isArray(e)?e:[e]);t.size!==0&&((o=(n=i.value)==null?void 0:n.setFieldValue)==null||o.call(n,l.name,void 0,!0,(r,u)=>{r[u]=r[u].filter(s=>!t.has(s[l.rowKey]))}))}function T(){return a.unref(p)}function k(e){var t;(t=i.value)==null||t.setFieldValue(l.name,e)}function j(e){var t;return(t=a.unref(p))==null?void 0:t[e]}function O(e,t,n=!0){var o,r;(r=(o=i.value)==null?void 0:o.setFieldValue)==null||r.call(o,l.name,void 0,!0,(u,s)=>{if(!(!u[s]||!u[s][e])){if(!n){const d=Object.keys(u[s][e]);for(const f of d)f!==l.rowKey&&delete u[s][e][f]}Object.assign(u[s][e],{...t})}})}function z(e){var n;const t=e==="end"?p.value.length-1:e;(n=g.value)==null||n.scrollToRow(t)}function K(){var e,t;(t=(e=i.value)==null?void 0:e.setFieldValue)==null||t.call(e,l.name,[])}return v({resetFields:N,validateFields:q,add:A,remove:E,getRowData:j,getRowsData:T,setRowData:O,addMultiple:D,scrollTo:z,clear:K,setTableData:k,removeByKey:L}),(e,t)=>(a.openBlock(),a.createBlock(a.unref(y.ApForm),{ref_key:"formRef",ref:i,"initial-values":{[l.name]:a.unref(p)},style:{height:"100%"}},{default:a.withCtx(()=>[a.createVNode(a.unref(y.ApForm).FormItem,{name:e.name,"no-style":""},{default:a.withCtx(()=>[a.createVNode(U.default,a.mergeProps(a.unref(c.omit)(l,["name","value","onUpdate:value","maxLength","onChange","defaultValue"]),{ref_key:"tableRef",ref:g,class:a.unref(R)(),columns:a.unref(_),"data-source":a.unref(p),"search-form":!1}),a.createSlots({_:2},[a.renderList(b,(n,o)=>({name:o,fn:a.withCtx(r=>[a.renderSlot(e.$slots,o,a.normalizeProps(a.guardReactiveProps(r||{})))])}))]),1040,["class","columns","data-source"])]),_:3},8,["name"])]),_:3},8,["initial-values"]))}});exports.default=W;