@aplus-frontend/ui 7.19.0-beta.2 → 7.19.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.
@@ -1,21 +1,21 @@
1
- import { defineComponent as L, useSlots as P, ref as y, onMounted as G, watch as W, createElementBlock as U, openBlock as $, Fragment as q, createVNode as p, unref as l, mergeProps as g, withCtx as h, createSlots as J, renderList as Q, renderSlot as X, normalizeProps as Y, guardReactiveProps as Z } from "vue";
2
- import { cloneDeep as u, isEqual as ee, omit as oe } from "lodash-unified";
3
- import { ApForm as C } from "../../ap-form/index.mjs";
4
- import { useInjectForm as te } from "../../ap-form/context.mjs";
5
- import { useWatch as ae } from "../../ap-form/hooks/use-watch.mjs";
6
- import { getModelValue as ne } from "../../ap-form/utils/get.mjs";
7
- import { transformValues as le } from "../../ap-form/utils/transform.mjs";
1
+ import { defineComponent as G, useSlots as W, ref as y, onMounted as U, watch as $, unref as r, createElementBlock as q, openBlock as J, Fragment as Q, createVNode as f, mergeProps as h, withCtx as C, createSlots as X, renderList as Y, renderSlot as Z, normalizeProps as ee, guardReactiveProps as oe } from "vue";
2
+ import { cloneDeep as u, isEqual as te, omit as ae } from "lodash-unified";
3
+ import { ApForm as b } from "../../ap-form/index.mjs";
4
+ import { useInjectForm as ne } from "../../ap-form/context.mjs";
5
+ import { useWatch as le } from "../../ap-form/hooks/use-watch.mjs";
6
+ import { getModelValue as re } from "../../ap-form/utils/get.mjs";
7
+ import { transformValues as ie } from "../../ap-form/utils/transform.mjs";
8
8
  import "../../config-provider/index.mjs";
9
- import { useGetEditableColumns as re } from "../hooks/use-editable-columns.mjs";
10
- import { useEditableFormItemApi as se } from "../hooks/use-editable-form-item-api.mjs";
9
+ import { useGetEditableColumns as se } from "../hooks/use-editable-columns.mjs";
10
+ import { useEditableFormItemApi as me } from "../hooks/use-editable-form-item-api.mjs";
11
11
  import "../index.vue2.mjs";
12
- import ie from "../style/editable.mjs";
13
- import { getShadowName as me } from "../utils.mjs";
14
- import { getColumnTransformOptions as ue, arrayToObject as b } from "./utils.mjs";
15
- import { useNamespace as de } from "../../config-provider/hooks/use-namespace.mjs";
16
- import { useGlobalConfig as pe } from "../../config-provider/hooks/use-global-config.mjs";
17
- import fe from "../index.vue.mjs";
18
- const Ne = /* @__PURE__ */ L({
12
+ import ue from "../style/editable.mjs";
13
+ import { getShadowName as de } from "../utils.mjs";
14
+ import { getColumnTransformOptions as pe, arrayToObject as R, getRowKey as fe } from "./utils.mjs";
15
+ import { useNamespace as ce } from "../../config-provider/hooks/use-namespace.mjs";
16
+ import { useGlobalConfig as we } from "../../config-provider/hooks/use-global-config.mjs";
17
+ import ge from "../index.vue.mjs";
18
+ const Ke = /* @__PURE__ */ G({
19
19
  name: "EditableGrid",
20
20
  __name: "form-item",
21
21
  props: {
@@ -138,112 +138,122 @@ const Ne = /* @__PURE__ */ L({
138
138
  name: {},
139
139
  formItem: {}
140
140
  },
141
- setup(R, {
141
+ setup(v, {
142
142
  expose: B
143
143
  }) {
144
- const v = P(), o = R, {
145
- b: x
146
- } = de("editable-aggrid"), I = ie("editable-aggrid"), r = y(), {
147
- internalInstance: s
148
- } = te();
149
- function S(e) {
150
- const t = ue(o.columns || []);
151
- if (!Object.keys(t).length || !e?.length)
144
+ const x = W(), a = v, {
145
+ b: S
146
+ } = ce("editable-aggrid"), I = ue("editable-aggrid"), m = y(), {
147
+ internalInstance: n
148
+ } = ne();
149
+ function F(e) {
150
+ const o = pe(a.columns || []);
151
+ if (!Object.keys(o).length || !e?.length)
152
152
  return e;
153
- let a = [];
154
- for (const m of e)
155
- a.push(le(m, t));
156
- return a;
153
+ let t = [];
154
+ for (const s of e)
155
+ t.push(ie(s, o));
156
+ return t;
157
157
  }
158
- const i = me(o.name);
159
- let f = [];
160
- G(() => {
161
- const e = o.formItem?.initialValue ?? ne(s?.getInitialValues() ?? {}, o.name);
162
- e && (s?.updateInitialModel(i, b(u(e), o.rowKey)), f = u(e), n.value || _(u(e), "suffix", !0));
158
+ const i = de(a.name);
159
+ let c = [];
160
+ U(() => {
161
+ const e = a.formItem?.initialValue ?? re(n?.getInitialValues() ?? {}, a.name);
162
+ e && (n?.updateInitialModel(i, R(u(e), a.rowKey)), c = u(e), l.value || j(u(e), "suffix", !0));
163
163
  });
164
- const n = y([]), T = ae(o.name);
165
- W(() => T.value, (e) => {
166
- ee(e, n.value) || c(e ?? u(f));
164
+ const l = y([]), T = le(a.name);
165
+ $(() => T.value, (e) => {
166
+ te(e, l.value) || w(e ?? u(c));
167
167
  }, {
168
168
  deep: !0,
169
169
  flush: "post",
170
170
  immediate: !0
171
171
  });
172
- const E = pe("valueTypeMap"), F = re(o, E, i), {
173
- add: V,
174
- addMultiple: N,
175
- __addMultiple: _,
176
- remove: j,
172
+ const E = we("valueTypeMap"), V = se(a, E, i), {
173
+ add: N,
174
+ addMultiple: _,
175
+ __addMultiple: j,
176
+ remove: K,
177
177
  removeByKey: k,
178
178
  getRowData: D,
179
179
  getRowsData: O,
180
180
  setRowData: z,
181
181
  clear: H,
182
182
  refreshRowIds: d
183
- } = se(o, s, n, i);
184
- function K() {
185
- const e = r.value?._internalGridApi;
183
+ } = me(a, n, l, i);
184
+ function L() {
185
+ const e = m.value?._internalGridApi;
186
186
  if (!d.value?.length || !e)
187
187
  return;
188
- const t = d.value.map((a) => e.getRowNode(a)).filter((a) => !!a);
188
+ const o = d.value.map((t) => e.getRowNode(t)).filter((t) => !!t);
189
189
  e.refreshCells({
190
- rowNodes: t,
190
+ rowNodes: o,
191
191
  force: !0
192
192
  }), d.value = [];
193
193
  }
194
- function c(e) {
195
- n.value = [...e];
196
- const t = b(e, o.rowKey);
197
- s?.setFieldValue(o.name, [...e]), s?.setFieldValue(i, t);
194
+ function w(e) {
195
+ l.value = [...e];
196
+ const o = R(e, a.rowKey);
197
+ n?.setFieldValue(a.name, [...e]), n?.setFieldValue(i, o);
198
198
  }
199
- function w(e, t) {
200
- const a = e === "end" ? n.value.length - 1 : e;
201
- r.value?.scrollToRow(a, t);
199
+ function g(e, o) {
200
+ const t = e === "end" ? l.value.length - 1 : e;
201
+ m.value?.scrollToRow(t, o);
202
202
  }
203
- function M(e, t) {
204
- r.value?.scrollToColumn(e, t);
203
+ function M(e, o) {
204
+ m.value?.scrollToColumn(e, o);
205
+ }
206
+ function P(e, o) {
207
+ const t = [i, String(e), o].flat();
208
+ return n?.validateFields([t]);
209
+ }
210
+ function A(e) {
211
+ const t = r(l).map((s, p) => [i, String(fe(s, p, a.rowKey)), e].flat());
212
+ return n?.validateFields(t);
205
213
  }
206
214
  return B({
207
- add: V,
208
- addMultiple: N,
209
- remove: j,
215
+ add: N,
216
+ addMultiple: _,
217
+ remove: K,
210
218
  removeByKey: k,
211
219
  getRowData: D,
212
220
  getRowsData: O,
213
221
  setRowData: z,
214
222
  clear: H,
215
- setTableData: c,
216
- scrollTo: w,
217
- scrollToRow: w,
223
+ setTableData: w,
224
+ scrollTo: g,
225
+ scrollToRow: g,
218
226
  scrollToColumn: M,
219
- table: r
220
- }), (e, t) => ($(), U(q, null, [p(l(C).FormItem, {
227
+ validateCell: P,
228
+ validateColumn: A,
229
+ table: m
230
+ }), (e, o) => (J(), q(Q, null, [f(r(b).FormItem, {
221
231
  hidden: "",
222
232
  name: e.name,
223
233
  "initial-value": e.formItem?.initialValue,
224
- transform: S
225
- }, null, 8, ["name", "initial-value"]), p(l(C).FormItem, g({
234
+ transform: F
235
+ }, null, 8, ["name", "initial-value"]), f(r(b).FormItem, h({
226
236
  label: e.label
227
237
  }, e.formItem), {
228
- default: h(() => [p(fe, g(l(oe)(o, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
238
+ default: C(() => [f(ge, h(r(ae)(a, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
229
239
  ref_key: "tableRef",
230
- ref: r,
231
- class: [l(x)(), l(I)],
240
+ ref: m,
241
+ class: [r(S)(), r(I)],
232
242
  size: "mini",
233
- columns: l(F),
234
- "data-source": n.value,
243
+ columns: r(V),
244
+ "data-source": l.value,
235
245
  "search-form": !1,
236
- onUpdate: K
237
- }), J({
246
+ onUpdate: L
247
+ }), X({
238
248
  _: 2
239
- }, [Q(v, (a, m) => ({
240
- name: m,
241
- fn: h((A) => [X(e.$slots, m, Y(Z(A || {})))])
249
+ }, [Y(x, (t, s) => ({
250
+ name: s,
251
+ fn: C((p) => [Z(e.$slots, s, ee(oe(p || {})))])
242
252
  }))]), 1040, ["class", "columns", "data-source"])]),
243
253
  _: 3
244
254
  }, 16, ["label"])], 64));
245
255
  }
246
256
  });
247
257
  export {
248
- Ne as default
258
+ Ke as default
249
259
  };
@@ -87,7 +87,21 @@ export type EditableAgGridExpose<RecordType = any, ModelType = RecordType[]> = O
87
87
  validateFieldsReturnTransformed: EditableTableExpose<ModelType, RecordType>['validateFields'];
88
88
  table: AgGridExpose;
89
89
  };
90
- export type EditableAgGridFormItemExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableAgGridExpose<RecordType, ModelType>, 'resetFields' | 'validateFields' | 'validateFieldsReturnTransformed'>;
90
+ export type EditableAgGridFormItemExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableAgGridExpose<RecordType, ModelType>, 'resetFields' | 'validateFields' | 'validateFieldsReturnTransformed'> & {
91
+ /**
92
+ * 校验单元格
93
+ * @param rowId 行唯一标识
94
+ * @param field 字段
95
+ * @returns
96
+ */
97
+ validateCell: (rowId: any, field: NamePath) => any;
98
+ /**
99
+ * 校验列
100
+ * @param colKey 列唯一标识
101
+ * @returns
102
+ */
103
+ validateColumn: (colKey: string | number) => any;
104
+ };
91
105
  export type EditableAgGridFormItemProps<RecordType = any> = Omit<EditableAgGridProps<RecordType>, 'name' | 'value' | 'onUpdate:value'> & {
92
106
  label?: string;
93
107
  /**
@@ -1,15 +1,15 @@
1
- import { defineComponent as re, reactive as oe, shallowRef as ne, ref as ie, unref as f, nextTick as le, toRaw as U, watch as ae, onWatcherCleanup as se, isVNode as ue, cloneVNode as ce, computed as fe, createBlock as b, openBlock as k, mergeProps as de, withCtx as E, renderSlot as N } from "vue";
1
+ import { defineComponent as re, reactive as oe, shallowRef as ne, ref as ie, unref as f, nextTick as le, toRaw as R, watch as ae, onWatcherCleanup as se, isVNode as ue, cloneVNode as ce, computed as fe, createBlock as k, openBlock as E, mergeProps as de, withCtx as N, renderSlot as O } from "vue";
2
2
  import { Form as pe } from "@aplus-frontend/antdv";
3
3
  import { useUrlSearchParams as ge } from "@vueuse/core";
4
- import { isArray as R, cloneDeep as O, isEqual as me, omit as Fe } from "lodash-unified";
4
+ import { isArray as P, cloneDeep as W, isEqual as me, omit as Fe } from "lodash-unified";
5
5
  import "../render/index.mjs";
6
6
  import { useDevWarning as he } from "../utils/warning.mjs";
7
7
  import { getRouteType as ye } from "../utils/index.mjs";
8
- import { INTERNAL_FORM_INSTANCE_MARK as W } from "./constant.mjs";
8
+ import { INTERNAL_FORM_INSTANCE_MARK as j } from "./constant.mjs";
9
9
  import { useProvideForm as Ve } from "./context.mjs";
10
10
  import { useInjectFormProvider as Te } from "./provider/context.mjs";
11
- import { getModelValue as j } from "./utils/get.mjs";
12
- import { genParams as P, setToParams as S } from "./utils/params.mjs";
11
+ import { getModelValue as S } from "./utils/get.mjs";
12
+ import { genParams as B, setToParams as q } from "./utils/params.mjs";
13
13
  import ve from "./utils/set.mjs";
14
14
  import { transformValues as F } from "./utils/transform.mjs";
15
15
  import { isDef as h } from "../utils/is.mjs";
@@ -47,30 +47,30 @@ const Se = /* @__PURE__ */ re({
47
47
  syncToUrlPriority: { type: Boolean },
48
48
  autoFocusFirstInput: { type: Boolean }
49
49
  },
50
- setup(q, { expose: x }) {
51
- const r = q;
50
+ setup(x, { expose: D }) {
51
+ const r = x;
52
52
  function y(e, t, o = !0, i) {
53
- if (R(e)) {
53
+ if (P(e)) {
54
54
  let l = n;
55
55
  for (let p = 0; p < e.length - 1; p++)
56
56
  e[p] in l || (l[e[p]] = {}), l = l[e[p]];
57
57
  i ? i(l, e[e.length - 1]) : l[e[e.length - 1]] = t;
58
58
  } else
59
59
  i ? i(n, e) : n[e] = t;
60
- let A = R(e) ? e[0] : e;
60
+ let b = P(e) ? e[0] : e;
61
61
  if (o) {
62
- const l = { [A]: n[A] };
62
+ const l = { [b]: n[b] };
63
63
  g.triggerFormChange(r.name, l), r.onValuesChange?.(l, n, e);
64
64
  }
65
65
  m();
66
66
  }
67
- const a = ne(), V = ge(ye()), g = Te(), D = he("ApForm"), T = ie(
68
- r.syncToUrl ? P(r.syncToUrl, V, "get") : {}
67
+ const a = ne(), V = ge(ye()), g = Te(), $ = he("ApForm"), T = ie(
68
+ r.syncToUrl ? B(r.syncToUrl, V, "get") : {}
69
69
  );
70
- let s = O(B()), u = {};
71
- const n = oe(B());
70
+ let s = W(M()), u = {};
71
+ const n = oe(M());
72
72
  let d = [];
73
- function B() {
73
+ function M() {
74
74
  const e = r.initialValues || {};
75
75
  return r.syncToUrlPriority ? {
76
76
  ...e,
@@ -80,19 +80,19 @@ const Se = /* @__PURE__ */ re({
80
80
  ...e
81
81
  };
82
82
  }
83
- function $(e) {
83
+ function K(e) {
84
84
  const t = F(
85
85
  e,
86
86
  u,
87
87
  c
88
88
  );
89
- g.triggerFormFinish(r.name, e), r.syncToUrl && S(V, P(r.syncToUrl, t, "set")), r.onFinish?.(t);
89
+ g.triggerFormFinish(r.name, e), r.syncToUrl && q(V, B(r.syncToUrl, t, "set")), r.onFinish?.(t);
90
90
  }
91
- const K = async () => {
91
+ const L = async () => {
92
92
  a.value?.resetFields(), await le(() => {
93
- Object.keys(n).forEach((e) => delete n[e]), Object.assign(n, O(s)), m(), r.syncToUrl && S(
93
+ Object.keys(n).forEach((e) => delete n[e]), Object.assign(n, W(s)), m(), r.syncToUrl && q(
94
94
  V,
95
- P(
95
+ B(
96
96
  r.syncToUrl,
97
97
  F(
98
98
  s,
@@ -103,9 +103,9 @@ const Se = /* @__PURE__ */ re({
103
103
  )
104
104
  );
105
105
  });
106
- }, L = (e) => {
106
+ }, G = (e) => {
107
107
  a.value?.clearValidate(e);
108
- }, G = (e, t) => a.value?.validateFields(e, t), H = async (e, t) => {
108
+ }, v = (e, t) => a.value?.validateFields(e, t), H = async (e, t) => {
109
109
  const o = await a.value?.validateFields(
110
110
  e,
111
111
  t
@@ -115,23 +115,23 @@ const Se = /* @__PURE__ */ re({
115
115
  u,
116
116
  c
117
117
  );
118
- }, c = (e) => e === !0 ? U(n) : a.value?.getFieldsValue(e), J = (e) => {
118
+ }, c = (e) => e === !0 ? R(n) : a.value?.getFieldsValue(e), J = (e) => {
119
119
  const t = c(e);
120
120
  return F(t, u, c);
121
121
  }, Q = (e, t) => a.value?.validate(e, t), X = (e, t = {}) => {
122
122
  a.value?.scrollToField(e, t);
123
123
  }, Y = (e) => {
124
124
  Object.assign(n, e), m();
125
- }, v = (e, t, o = !0, i) => {
125
+ }, I = (e, t, o = !0, i) => {
126
126
  y(e, t, o, i), m();
127
127
  };
128
- function I(e) {
129
- return e(U(n)), d.push(e), () => {
128
+ function C(e) {
129
+ return e(R(n)), d.push(e), () => {
130
130
  d = d.filter((t) => t !== e);
131
131
  };
132
132
  }
133
- function C(e, t) {
134
- if (R(e)) {
133
+ function U(e, t) {
134
+ if (P(e)) {
135
135
  let o = s;
136
136
  for (let i = 0; i < e.length - 1; i++)
137
137
  h(o[e[i]]) || (o[e[i]] = {}), o = o[e[i]];
@@ -142,11 +142,11 @@ const Se = /* @__PURE__ */ re({
142
142
  function Z(e, t) {
143
143
  if (!h(e) || !h(t))
144
144
  return;
145
- const o = j(s, t);
145
+ const o = S(s, t);
146
146
  if (me(o, e))
147
147
  return;
148
- const i = j(f(T), t);
149
- h(i) && r.syncToUrlPriority || (y(t, e, !1), C(t, e));
148
+ const i = S(f(T), t);
149
+ h(i) && r.syncToUrlPriority || (y(t, e, !1), U(t, e));
150
150
  }
151
151
  function z(e, t) {
152
152
  t && (u = ve(
@@ -156,44 +156,45 @@ const Se = /* @__PURE__ */ re({
156
156
  !0
157
157
  ));
158
158
  }
159
- function M({ initialValue: e, name: t, transform: o }) {
159
+ function w({ initialValue: e, name: t, transform: o }) {
160
160
  Z(e, t), z(t, o);
161
161
  }
162
- function w() {
162
+ function _() {
163
163
  return s;
164
164
  }
165
165
  function ee(e) {
166
- if (D(
167
- e === W,
166
+ if ($(
167
+ e === j,
168
168
  "usage",
169
169
  "getInternalInstance should only used at internal"
170
- ), e === W)
170
+ ), e === j)
171
171
  return {
172
- registerField: M,
173
- registerWatch: I,
174
- setFieldValue: v,
175
- getInitialValues: w,
176
- updateInitialModel: C
172
+ registerField: w,
173
+ registerWatch: C,
174
+ setFieldValue: I,
175
+ getInitialValues: _,
176
+ updateInitialModel: U,
177
+ validateFields: v
177
178
  };
178
179
  }
179
180
  function m() {
180
181
  if (d.length) {
181
- const e = U(n);
182
+ const e = R(n);
182
183
  d.forEach((t) => {
183
184
  t(e);
184
185
  });
185
186
  }
186
187
  }
187
- const _ = {
188
- resetFields: K,
189
- clearValidate: L,
190
- validateFields: G,
188
+ const A = {
189
+ resetFields: L,
190
+ clearValidate: G,
191
+ validateFields: v,
191
192
  getFieldsValue: c,
192
193
  validate: Q,
193
194
  scrollToField: X,
194
195
  setFieldsValue: Y,
195
- setFieldValue: v,
196
- registerWatch: I,
196
+ setFieldValue: I,
197
+ registerWatch: C,
197
198
  validateFieldsReturnTransformed: H,
198
199
  getFieldsValueTransformed: J,
199
200
  getInternalInstance: ee
@@ -201,7 +202,7 @@ const Se = /* @__PURE__ */ re({
201
202
  ae(
202
203
  () => r.name,
203
204
  (e) => {
204
- e && (g.registerForm(e, _), se(() => {
205
+ e && (g.registerForm(e, A), se(() => {
205
206
  g.unregisterForm(r.name);
206
207
  }));
207
208
  },
@@ -216,13 +217,14 @@ const Se = /* @__PURE__ */ re({
216
217
  model: fe(() => n),
217
218
  updateModel: y,
218
219
  internalInstance: {
219
- registerWatch: I,
220
- registerField: M,
221
- setFieldValue: v,
222
- getInitialValues: w,
223
- updateInitialModel: C
220
+ registerWatch: C,
221
+ registerField: w,
222
+ setFieldValue: I,
223
+ getInitialValues: _,
224
+ updateInitialModel: U,
225
+ validateFields: v
224
226
  }
225
- }), x(_), (e, t) => (k(), b(f(pe), de(
227
+ }), D(A), (e, t) => (E(), k(f(pe), de(
226
228
  {
227
229
  ref_key: "formRef",
228
230
  ref: a
@@ -238,19 +240,19 @@ const Se = /* @__PURE__ */ re({
238
240
  {
239
241
  model: n,
240
242
  "data-form-name": e.name,
241
- onFinish: $
243
+ onFinish: K
242
244
  }
243
245
  ), {
244
- default: E(() => [
245
- e.autoFocusFirstInput ? (k(), b(f(Ie), {
246
+ default: N(() => [
247
+ e.autoFocusFirstInput ? (E(), k(f(Ie), {
246
248
  key: 1,
247
249
  renderer: te
248
250
  }, {
249
- default: E(() => [
250
- N(e.$slots, "default")
251
+ default: N(() => [
252
+ O(e.$slots, "default")
251
253
  ]),
252
254
  _: 3
253
- })) : N(e.$slots, "default", { key: 0 })
255
+ })) : O(e.$slots, "default", { key: 0 })
254
256
  ]),
255
257
  _: 3
256
258
  }, 16, ["model", "data-form-name"]));
@@ -149,6 +149,10 @@ export type ApFormInternalInstance = {
149
149
  * 更新表单的初始值(仅用于某些组件内部调用的情况)
150
150
  */
151
151
  updateInitialModel: (name: FormItemProps['name'], val: any) => void;
152
+ /**
153
+ * 表单校验
154
+ */
155
+ validateFields: ApFormExpose['validateFields'];
152
156
  };
153
157
  export type ApFormItemExpose = FormItemExpose & {
154
158
  /**