@aplus-frontend/ui 7.9.0 → 7.10.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,20 +1,20 @@
1
- import { defineComponent as M, useSlots as O, ref as w, onMounted as P, unref as t, watch as G, createElementBlock as W, openBlock as U, Fragment as $, createVNode as d, mergeProps as y, withCtx as g, createSlots as q, renderList as J, renderSlot as Q, normalizeProps as X, guardReactiveProps as Y } from "vue";
1
+ import { defineComponent as A, useSlots as L, ref as y, onMounted as O, watch as P, createElementBlock as G, openBlock as W, Fragment as U, createVNode as u, unref as l, withCtx as g, mergeProps as $, createSlots as q, renderList as J, renderSlot as Q, normalizeProps as X, guardReactiveProps as Y } from "vue";
2
2
  import { ApForm as h } from "../../ap-form/index.mjs";
3
- import { cloneDeep as Z, isEqual as ee, omit as b } from "lodash-unified";
3
+ import { cloneDeep as m, isEqual as Z, omit as ee } from "lodash-unified";
4
4
  import "../../config-provider/index.mjs";
5
5
  import { useGetEditableColumns as oe } from "../hooks/use-editable-columns.mjs";
6
6
  import "../index.vue2.mjs";
7
7
  import { useEditableFormItemApi as ae } from "../hooks/use-editable-form-item-api.mjs";
8
8
  import { useInjectForm as te } from "../../ap-form/context.mjs";
9
- import { getModelValue as ne } from "../../ap-form/utils/get.mjs";
10
- import { getShadowName as le } from "../utils.mjs";
9
+ import { getModelValue as le } from "../../ap-form/utils/get.mjs";
10
+ import { getShadowName as ne } from "../utils.mjs";
11
11
  import { useWatch as re } from "../../ap-form/hooks/use-watch.mjs";
12
- import { arrayToObject as se } from "./utils.mjs";
12
+ import { arrayToObject as b } from "./utils.mjs";
13
13
  import ie from "../style/editable.mjs";
14
- import { useNamespace as me } from "../../config-provider/hooks/use-namespace.mjs";
15
- import { useGlobalConfig as de } from "../../config-provider/hooks/use-global-config.mjs";
16
- import pe from "../index.vue.mjs";
17
- const Fe = /* @__PURE__ */ M({
14
+ import { useNamespace as se } from "../../config-provider/hooks/use-namespace.mjs";
15
+ import { useGlobalConfig as me } from "../../config-provider/hooks/use-global-config.mjs";
16
+ import de from "../index.vue.mjs";
17
+ const Ee = /* @__PURE__ */ A({
18
18
  name: "EditableGrid",
19
19
  __name: "form-item",
20
20
  props: {
@@ -133,95 +133,96 @@ const Fe = /* @__PURE__ */ M({
133
133
  setup(C, {
134
134
  expose: R
135
135
  }) {
136
- const B = O(), o = C, {
137
- b: v
138
- } = me("editable-aggrid"), x = ie("editable-aggrid"), r = w(), {
139
- internalInstance: s,
140
- model: S
141
- } = te(), i = le(o.name);
142
- let p;
143
- P(() => {
144
- const e = o.formItem?.initialValue ?? ne(t(S), o.name);
145
- p = Z(e), N(e, "suffix", !0);
136
+ const v = L(), o = C, {
137
+ b: B
138
+ } = se("editable-aggrid"), x = ie("editable-aggrid"), i = y(), {
139
+ internalInstance: n
140
+ } = te(), s = ne(o.name);
141
+ let p = [];
142
+ O(() => {
143
+ const e = o.formItem?.initialValue ?? le(n?.getInitialValues() ?? {}, o.name);
144
+ e && (n?.updateInitialModel(s, b(m(e), o.rowKey)), p = m(e), _(m(e), "suffix", !0));
146
145
  });
147
- const l = w([]), I = re(o.name);
148
- G(() => I.value, (e) => {
149
- ee(e, l.value) || u(e ?? p);
146
+ const r = y([]), I = re(o.name);
147
+ P(() => I.value, (e) => {
148
+ Z(e, r.value) || c(e ?? m(p));
150
149
  }, {
151
- deep: !0
150
+ deep: !0,
151
+ flush: "post"
152
152
  });
153
- const E = de("valueTypeMap"), F = oe(o, E, i), {
154
- add: T,
155
- addMultiple: _,
156
- __addMultiple: N,
157
- remove: V,
158
- removeByKey: j,
159
- getRowData: D,
160
- getRowsData: k,
161
- setRowData: H,
162
- clear: L,
163
- refreshRowIds: m
164
- } = ae(o, s, l, i);
165
- function z() {
166
- const e = r.value?._internalGridApi;
167
- if (!m.value?.length || !e)
153
+ const S = me("valueTypeMap"), E = oe(o, S, s), {
154
+ add: F,
155
+ addMultiple: T,
156
+ __addMultiple: _,
157
+ remove: N,
158
+ removeByKey: V,
159
+ getRowData: j,
160
+ getRowsData: D,
161
+ setRowData: k,
162
+ clear: H,
163
+ refreshRowIds: d
164
+ } = ae(o, n, r, s);
165
+ function K() {
166
+ const e = i.value?._internalGridApi;
167
+ if (!d.value?.length || !e)
168
168
  return;
169
- const a = m.value.map((n) => e.getRowNode(n)).filter((n) => !!n);
169
+ const a = d.value.map((t) => e.getRowNode(t)).filter((t) => !!t);
170
170
  e.refreshCells({
171
171
  rowNodes: a,
172
172
  force: !0
173
- }), m.value = [];
173
+ }), d.value = [];
174
174
  }
175
- function u(e) {
176
- l.value = e;
177
- const a = se(e, o.rowKey);
178
- s?.setFieldValue(o.name, e), s?.setFieldValue(i, a);
175
+ function c(e) {
176
+ r.value = [...e];
177
+ const a = b(e, o.rowKey);
178
+ n?.setFieldValue(o.name, [...e]), n?.setFieldValue(s, a);
179
179
  }
180
- function c(e, a) {
181
- const n = e === "end" ? l.value.length - 1 : e;
182
- r.value?.scrollToRow(n, a);
180
+ function f(e, a) {
181
+ const t = e === "end" ? r.value.length - 1 : e;
182
+ i.value?.scrollToRow(t, a);
183
183
  }
184
- function A(e, a) {
185
- r.value?.scrollToColumn(e, a);
184
+ function M(e, a) {
185
+ i.value?.scrollToColumn(e, a);
186
186
  }
187
187
  return R({
188
- add: T,
189
- addMultiple: _,
190
- remove: V,
191
- removeByKey: j,
192
- getRowData: D,
193
- getRowsData: k,
194
- setRowData: H,
195
- clear: L,
196
- setTableData: u,
197
- scrollTo: c,
198
- scrollToRow: c,
199
- scrollToColumn: A
200
- }), (e, a) => (U(), W($, null, [d(t(h).FormItem, {
188
+ add: F,
189
+ addMultiple: T,
190
+ remove: N,
191
+ removeByKey: V,
192
+ getRowData: j,
193
+ getRowsData: D,
194
+ setRowData: k,
195
+ clear: H,
196
+ setTableData: c,
197
+ scrollTo: f,
198
+ scrollToRow: f,
199
+ scrollToColumn: M
200
+ }), (e, a) => (W(), G(U, null, [u(l(h).FormItem, {
201
201
  hidden: "",
202
- name: e.name
203
- }, null, 8, ["name"]), d(t(h).FormItem, y(t(b)(e.formItem, "initialValue"), {
202
+ name: e.name,
203
+ "initial-value": e.formItem?.initialValue
204
+ }, null, 8, ["name", "initial-value"]), u(l(h).FormItem, {
204
205
  label: e.label
205
- }), {
206
- default: g(() => [d(pe, y(t(b)(o, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
206
+ }, {
207
+ default: g(() => [u(de, $(l(ee)(o, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
207
208
  ref_key: "tableRef",
208
- ref: r,
209
- class: [t(v)(), t(x)],
209
+ ref: i,
210
+ class: [l(B)(), l(x)],
210
211
  size: "mini",
211
- columns: t(F),
212
- "data-source": l.value,
212
+ columns: l(E),
213
+ "data-source": r.value,
213
214
  "search-form": !1,
214
- onUpdate: z
215
+ onUpdate: K
215
216
  }), q({
216
217
  _: 2
217
- }, [J(B, (n, f) => ({
218
- name: f,
219
- fn: g((K) => [Q(e.$slots, f, X(Y(K || {})))])
218
+ }, [J(v, (t, w) => ({
219
+ name: w,
220
+ fn: g((z) => [Q(e.$slots, w, X(Y(z || {})))])
220
221
  }))]), 1040, ["class", "columns", "data-source"])]),
221
222
  _: 3
222
- }, 16, ["label"])], 64));
223
+ }, 8, ["label"])], 64));
223
224
  }
224
225
  });
225
226
  export {
226
- Fe as default
227
+ Ee as default
227
228
  };
@@ -1,17 +1,17 @@
1
- import { defineComponent as ee, reactive as te, shallowRef as re, ref as oe, unref as h, nextTick as ne, toRaw as R, watch as ie, onWatcherCleanup as le, computed as se, createBlock as ae, openBlock as ue, mergeProps as ce, withCtx as fe, renderSlot as de } from "vue";
2
- import { Form as ge } from "@aplus-frontend/antdv";
3
- import { useProvideForm as me } from "./context.mjs";
4
- import { isArray as f, cloneDeep as pe, isEqual as he, isFunction as M, isPlainObject as B, omit as Fe } from "lodash-unified";
1
+ import { defineComponent as te, reactive as re, shallowRef as oe, ref as ne, unref as h, nextTick as ie, toRaw as M, watch as le, onWatcherCleanup as se, computed as ae, createBlock as ue, openBlock as ce, mergeProps as fe, withCtx as de, renderSlot as ge } from "vue";
2
+ import { Form as me } from "@aplus-frontend/antdv";
3
+ import { useProvideForm as pe } from "./context.mjs";
4
+ import { isArray as f, cloneDeep as j, isEqual as he, isFunction as B, isPlainObject as _, omit as Fe } from "lodash-unified";
5
5
  import { useUrlSearchParams as ye } from "@vueuse/core";
6
- import { INTERNAL_FORM_INSTANCE_MARK as O } from "./constant.mjs";
6
+ import { INTERNAL_FORM_INSTANCE_MARK as x } from "./constant.mjs";
7
7
  import { getRouteType as Te } from "../utils/index.mjs";
8
8
  import Ve from "./utils/set.mjs";
9
- import { genParams as _, setToParams as j } from "./utils/params.mjs";
9
+ import { genParams as b, setToParams as W } from "./utils/params.mjs";
10
10
  import { useInjectFormProvider as ve } from "./provider/context.mjs";
11
- import { getModelValue as x } from "./utils/get.mjs";
11
+ import { getModelValue as N } from "./utils/get.mjs";
12
12
  import { useDevWarning as Ce } from "../utils/warning.mjs";
13
13
  import { isDef as T } from "../utils/is.mjs";
14
- const xe = /* @__PURE__ */ ee({
14
+ const xe = /* @__PURE__ */ te({
15
15
  name: "ApForm",
16
16
  __name: "ap-form",
17
17
  props: {
@@ -43,8 +43,8 @@ const xe = /* @__PURE__ */ ee({
43
43
  syncToUrl: { type: [Boolean, Function], default: !1 },
44
44
  syncToUrlPriority: { type: Boolean }
45
45
  },
46
- setup(W, { expose: N }) {
47
- const n = W;
46
+ setup(S, { expose: q }) {
47
+ const n = S;
48
48
  function V(e, t, r = !0, o) {
49
49
  if (f(e)) {
50
50
  let i = l;
@@ -60,13 +60,13 @@ const xe = /* @__PURE__ */ ee({
60
60
  }
61
61
  y();
62
62
  }
63
- const s = re(), v = ye(Te()), F = ve(), S = Ce("ApForm"), C = oe(
64
- n.syncToUrl ? _(n.syncToUrl, v, "get") : {}
63
+ const s = oe(), v = ye(Te()), F = ve(), D = Ce("ApForm"), C = ne(
64
+ n.syncToUrl ? b(n.syncToUrl, v, "get") : {}
65
65
  );
66
- let d = pe(b()), g = {};
67
- const l = te(b());
66
+ let d = j(w()), g = {};
67
+ const l = re(w());
68
68
  let m = [];
69
- function b() {
69
+ function w() {
70
70
  const e = n.initialValues || {};
71
71
  return n.syncToUrlPriority ? {
72
72
  ...e,
@@ -76,45 +76,45 @@ const xe = /* @__PURE__ */ ee({
76
76
  ...e
77
77
  };
78
78
  }
79
- function q(e) {
79
+ function K(e) {
80
80
  const t = p(e, g);
81
- F.triggerFormFinish(n.name, e), n.syncToUrl && j(v, _(n.syncToUrl, t, "set")), n.onFinish?.(t);
81
+ F.triggerFormFinish(n.name, e), n.syncToUrl && W(v, b(n.syncToUrl, t, "set")), n.onFinish?.(t);
82
82
  }
83
- const D = async () => {
84
- s.value?.resetFields(), await ne(() => {
85
- Object.keys(l).forEach((e) => delete l[e]), Object.assign(l, d), y(), n.syncToUrl && j(
83
+ const L = async () => {
84
+ s.value?.resetFields(), await ie(() => {
85
+ Object.keys(l).forEach((e) => delete l[e]), Object.assign(l, j(d)), y(), n.syncToUrl && W(
86
86
  v,
87
- _(
87
+ b(
88
88
  n.syncToUrl,
89
89
  p(d, g),
90
90
  "set"
91
91
  )
92
92
  );
93
93
  });
94
- }, K = (e) => {
94
+ }, $ = (e) => {
95
95
  s.value?.clearValidate(e);
96
- }, L = (e, t) => s.value?.validateFields(e, t), $ = async (e, t) => {
96
+ }, k = (e, t) => s.value?.validateFields(e, t), G = async (e, t) => {
97
97
  const r = await s.value?.validateFields(
98
98
  e,
99
99
  t
100
100
  );
101
101
  return p(r, g);
102
- }, I = (e) => e === !0 ? R(l) : s.value?.getFieldsValue(e), k = (e) => {
102
+ }, I = (e) => e === !0 ? M(l) : s.value?.getFieldsValue(e), H = (e) => {
103
103
  const t = I(e);
104
104
  return p(t, g);
105
- }, G = (e, t) => s.value?.validate(e, t), H = (e, t = {}) => {
105
+ }, J = (e, t) => s.value?.validate(e, t), Q = (e, t = {}) => {
106
106
  s.value?.scrollToField(e, t);
107
- }, J = (e) => {
107
+ }, X = (e) => {
108
108
  Object.assign(l, e), y();
109
109
  }, U = (e, t, r = !0, o) => {
110
110
  V(e, t, r, o), y();
111
111
  };
112
112
  function P(e) {
113
- return e(R(l)), m.push(e), () => {
113
+ return e(M(l)), m.push(e), () => {
114
114
  m = m.filter((t) => t !== e);
115
115
  };
116
116
  }
117
- function Q(e, t) {
117
+ function R(e, t) {
118
118
  if (f(e)) {
119
119
  let r = d;
120
120
  for (let o = 0; o < e.length - 1; o++)
@@ -123,16 +123,16 @@ const xe = /* @__PURE__ */ ee({
123
123
  } else
124
124
  d[e] = t;
125
125
  }
126
- function X(e, t) {
126
+ function Y(e, t) {
127
127
  if (!T(e) || !T(t))
128
128
  return;
129
- const r = x(d, t);
129
+ const r = N(d, t);
130
130
  if (he(r, e))
131
131
  return;
132
- const o = x(h(C), t);
133
- T(o) && n.syncToUrlPriority || (V(t, e, !1), Q(t, e));
132
+ const o = N(h(C), t);
133
+ T(o) && n.syncToUrlPriority || (V(t, e, !1), R(t, e));
134
134
  }
135
- function Y(e, t) {
135
+ function Z(e, t) {
136
136
  t && (g = Ve(
137
137
  g,
138
138
  [e].flat(1),
@@ -140,28 +140,29 @@ const xe = /* @__PURE__ */ ee({
140
140
  !0
141
141
  ));
142
142
  }
143
- function w({ initialValue: e, name: t, transform: r }) {
144
- X(e, t), Y(t, r);
143
+ function A({ initialValue: e, name: t, transform: r }) {
144
+ Y(e, t), Z(t, r);
145
145
  }
146
- function A() {
146
+ function E() {
147
147
  return d;
148
148
  }
149
- function Z(e) {
150
- if (S(
151
- e === O,
149
+ function z(e) {
150
+ if (D(
151
+ e === x,
152
152
  "usage",
153
153
  "getInternalInstance should only used at internal"
154
- ), e === O)
154
+ ), e === x)
155
155
  return {
156
- registerField: w,
156
+ registerField: A,
157
157
  registerWatch: P,
158
158
  setFieldValue: U,
159
- getInitialValues: A
159
+ getInitialValues: E,
160
+ updateInitialModel: R
160
161
  };
161
162
  }
162
163
  function y() {
163
164
  if (m.length) {
164
- const e = R(l);
165
+ const e = M(l);
165
166
  m.forEach((t) => {
166
167
  t(e);
167
168
  });
@@ -172,14 +173,14 @@ const xe = /* @__PURE__ */ ee({
172
173
  return;
173
174
  let r = f(e) ? [] : {};
174
175
  return Object.keys(e).forEach((o) => {
175
- const a = e[o], i = t?.[o], u = M(i) ? i : i?.transformer, z = M(i) ? !0 : i?.flat;
176
- if (M(u)) {
176
+ const a = e[o], i = t?.[o], u = B(i) ? i : i?.transformer, ee = B(i) ? !0 : i?.flat;
177
+ if (B(u)) {
177
178
  const c = u(a, { getFieldsValue: I });
178
- z ? f(c) && f(r) ? r = [...r, ...c] : B(c) && B(r) ? r = {
179
+ ee ? f(c) && f(r) ? r = [...r, ...c] : _(c) && _(r) ? r = {
179
180
  ...r,
180
181
  ...c
181
182
  } : r[o] = c : r[o] = c;
182
- } else if (B(a) || f(a)) {
183
+ } else if (_(a) || f(a)) {
183
184
  const c = p(
184
185
  a,
185
186
  i
@@ -189,40 +190,41 @@ const xe = /* @__PURE__ */ ee({
189
190
  r[o] = a;
190
191
  }), r;
191
192
  }
192
- const E = {
193
- resetFields: D,
194
- clearValidate: K,
195
- validateFields: L,
193
+ const O = {
194
+ resetFields: L,
195
+ clearValidate: $,
196
+ validateFields: k,
196
197
  getFieldsValue: I,
197
- validate: G,
198
- scrollToField: H,
199
- setFieldsValue: J,
198
+ validate: J,
199
+ scrollToField: Q,
200
+ setFieldsValue: X,
200
201
  setFieldValue: U,
201
202
  registerWatch: P,
202
- validateFieldsReturnTransformed: $,
203
- getFieldsValueTransformed: k,
204
- getInternalInstance: Z
203
+ validateFieldsReturnTransformed: G,
204
+ getFieldsValueTransformed: H,
205
+ getInternalInstance: z
205
206
  };
206
- return ie(
207
+ return le(
207
208
  () => n.name,
208
209
  (e) => {
209
- e && (F.registerForm(e, E), le(() => {
210
+ e && (F.registerForm(e, O), se(() => {
210
211
  F.unregisterForm(n.name);
211
212
  }));
212
213
  },
213
214
  {
214
215
  immediate: !0
215
216
  }
216
- ), me({
217
- model: se(() => l),
217
+ ), pe({
218
+ model: ae(() => l),
218
219
  updateModel: V,
219
220
  internalInstance: {
220
221
  registerWatch: P,
221
- registerField: w,
222
+ registerField: A,
222
223
  setFieldValue: U,
223
- getInitialValues: A
224
+ getInitialValues: E,
225
+ updateInitialModel: R
224
226
  }
225
- }), N(E), (e, t) => (ue(), ae(h(ge), ce(
227
+ }), q(O), (e, t) => (ce(), ue(h(me), fe(
226
228
  {
227
229
  ref_key: "formRef",
228
230
  ref: s
@@ -237,11 +239,11 @@ const xe = /* @__PURE__ */ ee({
237
239
  {
238
240
  model: l,
239
241
  "data-form-name": e.name,
240
- onFinish: q
242
+ onFinish: K
241
243
  }
242
244
  ), {
243
- default: fe(() => [
244
- de(e.$slots, "default")
245
+ default: de(() => [
246
+ ge(e.$slots, "default")
245
247
  ]),
246
248
  _: 3
247
249
  }, 16, ["model", "data-form-name"]));
@@ -140,6 +140,10 @@ export type ApFormInternalInstance = {
140
140
  * @returns
141
141
  */
142
142
  getInitialValues: () => Recordable;
143
+ /**
144
+ * 更新表单的初始值(仅用于某些组件内部调用的情况)
145
+ */
146
+ updateInitialModel: (name: FormItemProps['name'], val: any) => void;
143
147
  };
144
148
  export type ApFormItemExpose = FormItemExpose & {
145
149
  /**
@@ -1,5 +1,5 @@
1
- import { genComponentStyleHook as n } from "../../utils/cssinjs/index.mjs";
2
- const e = (t) => ({
1
+ import { genComponentStyleHook as r } from "../../utils/cssinjs/index.mjs";
2
+ const n = (t) => ({
3
3
  [t.componentCls]: {
4
4
  "&-compact": {
5
5
  ".ant-select": {
@@ -44,6 +44,10 @@ const e = (t) => ({
44
44
  ".ant-form-item-control-input-content > .ant-input-group > :first-child, .ant-select-selector": {
45
45
  borderStartStartRadius: 0,
46
46
  borderEndStartRadius: 0
47
+ },
48
+ ".ant-form-item-control-input-content .ant-input-group > :first-child, .ant-select-selector": {
49
+ borderStartStartRadius: 0,
50
+ borderEndStartRadius: 0
47
51
  }
48
52
  },
49
53
  ".ant-form-item:not(:first-child):not(:last-child)": {
@@ -62,8 +66,8 @@ const e = (t) => ({
62
66
  ".ant-form-vertical .ant-input-group.ant-input-group-compact > *": {
63
67
  verticalAlign: "bottom"
64
68
  }
65
- }), o = n("ApForm.ItemTextGroup", (t) => [e(t)]);
69
+ }), o = r("ApForm.ItemTextGroup", (t) => [n(t)]);
66
70
  export {
67
71
  o as default,
68
- e as genFormItemTextGroupStyle
72
+ n as genFormItemTextGroupStyle
69
73
  };
@@ -13,6 +13,7 @@ declare const _default: <RecordType extends Recordable>(__VLS_props: NonNullable
13
13
  };
14
14
  submit: () => void;
15
15
  reset: () => void;
16
+ loading: boolean;
16
17
  }): any;
17
18
  empty?(_: {
18
19
  loading: boolean;