@kp-ui/lowcode 2.16.2 → 2.16.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,30 +1,30 @@
1
- import { inject as m, ref as u, getCurrentInstance as He, computed as s, toRaw as P, onMounted as ze, onBeforeUnmount as Ue } from "vue";
1
+ import { inject as m, ref as f, getCurrentInstance as Se, computed as s, toRaw as P, onMounted as He, onBeforeUnmount as ze } from "vue";
2
2
  import { deepClone as $ } from "../../../../utils/util.js";
3
- import I from "../../../../utils/validators.js";
4
- import { get as j, eq as Le, isArray as Te } from "lodash-es";
3
+ import x from "../../../../utils/validators.js";
4
+ import { get as Ue, eq as Le, isArray as Te } from "lodash-es";
5
5
  import { useI18n as We } from "../../../../utils/i18n.js";
6
6
  import { useEmitter as Je } from "../../../../utils/useEmitter.js";
7
7
  import { useAppRef as Pe } from "../../useAppRef.js";
8
8
  import { useExecFunction as $e } from "tmgc2-share";
9
- function _e(t, w = !0) {
10
- const D = m("formConfig", u({})), h = m("formData", u({})), G = m("getReadMode", () => !1), M = m("isSubFormField", !1), V = m("getSubFormName", () => ""), o = m("designState", !1), { registerToRefList: K, getWidgetRef: Q, getFormRef: B, unregisterFromRefList: X } = Pe(), { executeFunction: r, asyncExecuteFunction: g } = $e(), { i18nt: E, i18n2t: Y } = We(), { field: l } = t, C = u(null), k = u(null), x = u(!1), Z = u(!1), a = u([]), A = u({}), _ = u(null), b = He(), { dispatch: v } = Je(), p = s(() => {
9
+ function _e(t, j = !0) {
10
+ const I = m("formConfig", f({})), R = m("formData", f({})), w = m("getReadMode", () => !1), D = m("isSubFormField", !1), M = m("getSubFormName", () => ""), o = m("designState", !1), { registerToRefList: G, getWidgetRef: K, getFormRef: B, unregisterFromRefList: Q } = Pe(), { executeFunction: u, asyncExecuteFunction: g } = $e(), { i18nt: E, i18n2t: X } = We(), { field: a } = t, h = f(null), k = f(null), V = f(!1), Y = f(!1), l = f([]), A = f({}), Z = f(null), C = Se(), { dispatch: v } = Je(), _ = s(() => {
11
11
  var e;
12
- return (e = l == null ? void 0 : l.options) != null && e.size ? l.options.size : D.value.size || "middle";
13
- }), F = s(() => V ? V() : ""), d = s({
12
+ return (e = a == null ? void 0 : a.options) != null && e.size ? a.options.size : I.value.size || "middle";
13
+ }), b = s(() => M ? M() : ""), d = s({
14
14
  get() {
15
- return console.log(j(h.value, f.value), f.value), j(h.value, f.value);
15
+ return Ue(R.value, c.value);
16
16
  },
17
17
  set(e) {
18
- console.log(e), H(e);
18
+ H(e);
19
19
  }
20
- }), ee = s(() => h.value[F.value]), N = s(() => G() ? !0 : x.value), te = s(() => {
20
+ }), p = s(() => R.value[b.value]), N = s(() => w() ? !0 : V.value), ee = s(() => {
21
21
  if (o)
22
22
  return !1;
23
23
  const { onHidden: e, hidden: n } = t.field.options;
24
24
  if (n) return !0;
25
25
  if (e)
26
26
  try {
27
- const i = r({
27
+ const i = u({
28
28
  functionBody: e
29
29
  });
30
30
  return typeof i == "boolean" ? i : !1;
@@ -39,7 +39,7 @@ function _e(t, w = !0) {
39
39
  if (n) return !0;
40
40
  if (e)
41
41
  try {
42
- const i = r({
42
+ const i = u({
43
43
  functionBody: e
44
44
  });
45
45
  return typeof i == "boolean" ? i : !1;
@@ -47,31 +47,31 @@ function _e(t, w = !0) {
47
47
  return console.log({ error: i }), !1;
48
48
  }
49
49
  return !1;
50
- }), ne = (e, n) => {
50
+ }), te = (e, n) => {
51
51
  if (!Array.isArray(e))
52
52
  return -1;
53
53
  let i = -1;
54
- return e.forEach((c, Se) => {
55
- c === n && (i = Se);
54
+ return e.forEach((r, qe) => {
55
+ r === n && (i = qe);
56
56
  }), i;
57
- }, f = s(() => M && !o ? F.value + "." + t.subFormRowIndex + "." + t.field.options.name : t.field.options.name);
58
- async function ie() {
57
+ }, c = s(() => D && !o ? b.value + "." + t.subFormRowIndex + "." + t.field.options.name : t.field.options.name);
58
+ async function ne() {
59
59
  o || t.field.options.onCreated && await g({
60
60
  functionBody: t.field.options.onCreated
61
61
  });
62
62
  }
63
- async function oe() {
63
+ async function ie() {
64
64
  o || t.field.options.onMounted && await g({
65
65
  functionBody: t.field.options.onMounted
66
66
  });
67
67
  }
68
- const le = () => {
68
+ const oe = () => {
69
69
  d.value = t.field.options.defaultValue;
70
70
  }, q = () => {
71
- t.field.formItemFlag && a.value.splice(0, a.value.length);
72
- }, y = () => {
71
+ t.field.formItemFlag && l.value.splice(0, l.value.length);
72
+ }, F = () => {
73
73
  if (!(!(t != null && t.field.formItemFlag) || t != null && t.field.options.hidden)) {
74
- if (a.value.splice(0, a.value.length), t.field.options.required && a.value.push({
74
+ if (l.value.splice(0, l.value.length), t.field.options.required && l.value.push({
75
75
  required: !0,
76
76
  // trigger: ['blur', 'change'],
77
77
  trigger: [
@@ -80,13 +80,13 @@ function _e(t, w = !0) {
80
80
  message: t.field.options.requiredHint || E("render.hint.fieldRequired")
81
81
  }), t.field.options.validation) {
82
82
  const e = t.field.options.validation;
83
- I[e] ? a.value.push({
84
- validator: I[e],
83
+ x[e] ? l.value.push({
84
+ validator: x[e],
85
85
  trigger: ["blur", "change"],
86
86
  label: t.field.options.label,
87
87
  errorMsg: t.field.options.validationHint
88
- }) : a.value.push({
89
- validator: I.regExp,
88
+ }) : l.value.push({
89
+ validator: x.regExp,
90
90
  trigger: ["blur", "change"],
91
91
  regExp: e,
92
92
  label: t.field.options.label,
@@ -94,148 +94,148 @@ function _e(t, w = !0) {
94
94
  });
95
95
  }
96
96
  if (t.field.options.onValidate) {
97
- const e = (n, i) => r({
97
+ const e = (n, i) => u({
98
98
  functionBody: t.field.options.onValidate,
99
99
  params: { rule: n, value: i },
100
100
  keys: ["rule", "value"]
101
101
  });
102
- a.value.push({
102
+ l.value.push({
103
103
  validator: e,
104
104
  trigger: ["blur"],
105
105
  label: t.field.options.label
106
106
  });
107
107
  }
108
108
  }
109
- }, ae = () => {
110
- a.value && a.value.forEach((e) => {
109
+ }, le = () => {
110
+ l.value && l.value.forEach((e) => {
111
111
  e.trigger && e.trigger.splice(0, e.trigger.length);
112
112
  });
113
- }, de = () => {
114
- a.value && a.value.forEach((e) => {
113
+ }, ae = () => {
114
+ l.value && l.value.forEach((e) => {
115
115
  e.trigger && (e.trigger.push("blur"), e.trigger.push("change"));
116
116
  });
117
- }, se = (e, n) => {
117
+ }, de = (e, n) => {
118
118
  e && e.length > 0 && e.forEach((i) => {
119
119
  i.value === n && (i.disabled = !0);
120
120
  });
121
- }, fe = (e, n) => {
121
+ }, se = (e, n) => {
122
122
  e && e.length > 0 && e.forEach((i) => {
123
123
  i.value === n && (i.disabled = !1);
124
124
  });
125
125
  }, S = (e, n) => {
126
- e && (e = e.target ? e.target.value : e), b && v("VFormRender", "fieldChange", [
126
+ e && (e = e.target ? e.target.value : e), C && v("VFormRender", "fieldChange", [
127
127
  t.field.options.name,
128
128
  e,
129
129
  n,
130
- F.value,
130
+ b.value,
131
131
  t.subFormRowIndex
132
132
  ]);
133
133
  }, H = (e) => {
134
134
  if (o) {
135
135
  v("VFormDesigner", "fieldChange", {
136
- fieldName: f.value,
136
+ fieldName: c.value,
137
137
  value: e,
138
- field: l
138
+ field: a
139
139
  });
140
140
  return;
141
141
  }
142
- v("VFormRender", "fieldValidation", [f.value]);
142
+ v("VFormRender", "fieldValidation", [c.value]);
143
143
  const n = P(d.value);
144
144
  v("VFormRender", "fieldChange", {
145
- fieldName: f.value,
145
+ fieldName: c.value,
146
146
  value: e,
147
147
  oldValue: n,
148
- field: l
148
+ field: a
149
149
  }), z(e, n);
150
- }, ue = (e) => {
151
- o || (k.value = $(d.value), t.field.options.onFocus && r({
150
+ }, fe = (e) => {
151
+ o || (k.value = $(d.value), t.field.options.onFocus && u({
152
152
  functionBody: t.field.options.onFocus,
153
153
  params: { event: e },
154
154
  keys: ["event"]
155
155
  }));
156
- }, re = (e) => {
157
- o || t.field.options.onBlur && r({
156
+ }, ue = (e) => {
157
+ o || t.field.options.onBlur && u({
158
158
  functionBody: t.field.options.onBlur,
159
159
  params: { event: e },
160
160
  keys: ["event"]
161
161
  });
162
- }, ce = () => {
163
- o || t.field.options.onAppendButtonClick && r({
162
+ }, re = () => {
163
+ o || t.field.options.onAppendButtonClick && u({
164
164
  functionBody: t.field.options.onAppendButtonClick
165
165
  });
166
166
  }, z = (e, n) => {
167
- o || t.field.options.onChange && r({
167
+ o || t.field.options.onChange && u({
168
168
  functionBody: t.field.options.onChange,
169
169
  params: {
170
170
  value: e,
171
171
  oldValue: n,
172
- subFormData: ee.value,
172
+ subFormData: p.value,
173
173
  rowId: t.subFormRowId
174
174
  },
175
175
  keys: ["value", "oldValue", "subFormData", "rowId"]
176
176
  });
177
- }, me = async () => {
177
+ }, ce = async () => {
178
178
  if (!o && t.field.options.onClick)
179
179
  return await g({
180
180
  functionBody: t.field.options.onClick
181
181
  });
182
- }, ge = async () => {
183
- o || O.value || l.options.onClickIcon && await g({
184
- functionBody: l.options.onClickIcon
182
+ }, me = async () => {
183
+ o || O.value || a.options.onClickIcon && await g({
184
+ functionBody: a.options.onClickIcon
185
185
  });
186
- }, R = () => C.value, U = (e) => (typeof e == "string" && (e = JSON.parse(e)), Te(e) ? e.map((i, c) => ({
186
+ }, y = () => h.value, U = (e) => (typeof e == "string" && (e = JSON.parse(e)), Te(e) ? e.map((i, r) => ({
187
187
  ...i,
188
188
  name: i.fileName,
189
- uid: c
189
+ uid: r
190
190
  })) : []), L = (e, n = !1) => {
191
- if (console.log(l.options.name), e && (e = e.target ? e.target.value : e), Le(d.value, e)) return;
191
+ if (e && (e = e.target ? e.target.value : e), Le(d.value, e)) return;
192
192
  const i = $(d.value);
193
193
  if (t.field.type === "file-upload")
194
194
  e = U(e || []);
195
195
  else if (t.field.type === "code-editor") {
196
- const c = R();
197
- c && c.setValue(e);
196
+ const r = y();
197
+ r && r.setValue(e);
198
198
  }
199
199
  d.value = e, n || S(e, i);
200
- }, ve = () => d.value, he = () => {
200
+ }, ge = () => d.value, ve = () => {
201
201
  const e = t.field.options.defaultValue;
202
202
  L(e), (t.field.type === "picture-upload" || t.field.type === "file-upload") && d.value.splice(0, d.value.length);
203
- }, Ce = (e) => {
203
+ }, he = (e) => {
204
204
  t.field.options.readonly = e;
205
- }, be = (e) => {
205
+ }, Ce = (e) => {
206
206
  t.field.options.disabled = e;
207
- }, Fe = (e) => {
207
+ }, be = (e) => {
208
208
  t.field.options.appendButton = e;
209
- }, ye = (e) => {
209
+ }, Fe = (e) => {
210
210
  t.field.options.appendButtonDisabled = e;
211
+ }, ye = (e) => {
212
+ t.field.options.hidden = e, e ? q() : F();
211
213
  }, Re = (e) => {
212
- t.field.options.hidden = e, e ? q() : y();
213
- }, Be = (e) => {
214
- t.field.options.required = e, y(), !o && !e && T();
214
+ t.field.options.required = e, F(), !o && !e && T();
215
215
  }, T = () => {
216
- o || B().clearValidate(f.value);
217
- }, Ee = () => B().vfCtx, xe = (e) => {
216
+ o || B().clearValidate(c.value);
217
+ }, Be = () => B().vfCtx, Ee = (e) => {
218
218
  t.field.options.label = e;
219
219
  }, W = () => {
220
- const e = R();
220
+ const e = y();
221
221
  e && e.focus && e.focus();
222
- }, Ie = (e, n) => {
222
+ }, Ve = (e, n) => {
223
223
  A.value[e] = n;
224
- }, De = (e = !0) => {
225
- x.value = e;
226
- }, Me = (e) => {
224
+ }, xe = (e = !0) => {
225
+ V.value = e;
226
+ }, Ie = (e) => {
227
227
  t.field.options.customClass ? t.field.options.customClass.push(e) : t.field.options.customClass = [e];
228
- }, Ve = s(() => t.field.options.customClass), ke = (e) => {
228
+ }, De = s(() => t.field.options.customClass), Me = (e) => {
229
229
  if (!t.field.options.customClass)
230
230
  return;
231
231
  let n = -1;
232
- t.field.options.customClass.map((i, c) => {
233
- i === e && (n = c);
232
+ t.field.options.customClass.map((i, r) => {
233
+ i === e && (n = r);
234
234
  }), n > -1 && t.field.options.customClass.splice(n, 1);
235
- }, Ae = () => {
235
+ }, ke = () => {
236
236
  var e;
237
- return (e = C.value) == null ? void 0 : e.$el;
238
- }, Ne = (e, n) => {
237
+ return (e = h.value) == null ? void 0 : e.$el;
238
+ }, Ae = (e, n) => {
239
239
  t.field.options[e] = n;
240
240
  }, J = s({
241
241
  get() {
@@ -244,100 +244,101 @@ function _e(t, w = !0) {
244
244
  set(e) {
245
245
  t.field.options = e;
246
246
  }
247
- }), Oe = () => {
247
+ }), Ne = () => {
248
+ const e = typeof t.field.options.defaultValue > "u" ? "" : t.field.options.defaultValue;
248
249
  v("VFormRender", "fieldChange", {
249
- fieldName: f.value,
250
- value: t.field.options.defaultValue ?? "",
250
+ fieldName: c.value,
251
+ value: e,
251
252
  oldValue: P(d.value),
252
- field: l
253
+ field: a
253
254
  });
254
255
  };
255
- ze(async () => {
256
- w && Oe(), await K(), await ie(), await oe(), y();
257
- }), Ue(() => {
258
- X();
256
+ He(async () => {
257
+ j && Ne(), await G(), await ne(), await ie(), F();
258
+ }), ze(() => {
259
+ Q();
259
260
  });
260
- const qe = {
261
+ const Oe = {
261
262
  i18nt: E,
262
263
  options: J,
263
- proxy: b == null ? void 0 : b.proxy,
264
- field: l,
265
- widget: l,
264
+ proxy: C == null ? void 0 : C.proxy,
265
+ field: a,
266
+ widget: a,
266
267
  fieldModel: d,
267
- fieldEditor: C,
268
+ fieldEditor: h,
268
269
  isReadMode: N,
269
- setWidgetOption: Ne,
270
- setReadonly: Ce,
271
- setDisabled: be,
272
- getVfCtx: Ee,
273
- setLabel: xe,
274
- getEl: Ae,
275
- setReadMode: De,
276
- resetField: he,
270
+ setWidgetOption: Ae,
271
+ setReadonly: he,
272
+ setDisabled: Ce,
273
+ getVfCtx: Be,
274
+ setLabel: Ee,
275
+ getEl: ke,
276
+ setReadMode: xe,
277
+ resetField: ve,
277
278
  setValue: L,
278
- getValue: ve,
279
- getFieldEditor: R,
279
+ getValue: ge,
280
+ getFieldEditor: y,
280
281
  getFormRef: B,
281
- getWidgetRef: Q,
282
- setHidden: Re,
283
- addCssClass: Me,
284
- removeCssClass: ke,
285
- setRequired: Be,
282
+ getWidgetRef: K,
283
+ setHidden: ye,
284
+ addCssClass: Ie,
285
+ removeCssClass: Me,
286
+ setRequired: Re,
286
287
  clearValidate: T,
287
288
  focus: W
288
289
  };
289
290
  return {
290
291
  asyncExecuteFunction: g,
291
- executeFunction: r,
292
+ executeFunction: u,
292
293
  options: J,
293
- customClass: Ve,
294
- fieldEditor: C,
294
+ customClass: De,
295
+ fieldEditor: h,
295
296
  // 状态
296
297
  fieldModel: d,
297
298
  oldFieldValue: k,
298
- fieldReadonlyFlag: x,
299
- loading: Z,
300
- rules: a,
299
+ fieldReadonlyFlag: V,
300
+ loading: Y,
301
+ rules: l,
301
302
  uploadData: A,
302
303
  designState: o,
303
- customToolbar: _,
304
+ customToolbar: Z,
304
305
  i18nt: E,
305
- i18n2t: Y,
306
- size: p,
307
- field: l,
306
+ i18n2t: X,
307
+ size: _,
308
+ field: a,
308
309
  // 计算属性
309
- formConfig: D,
310
- subFormName: F,
311
- formModel: h,
310
+ formConfig: I,
311
+ subFormName: b,
312
+ formModel: R,
312
313
  isReadMode: N,
313
314
  // 方法
314
- handleHidden: te,
315
+ handleHidden: ee,
315
316
  handleDisabled: O,
316
- findInArray: ne,
317
- getPropName: f,
318
- refreshDefaultValue: le,
317
+ findInArray: te,
318
+ getPropName: c,
319
+ refreshDefaultValue: oe,
319
320
  clearFieldRules: q,
320
- buildFieldRules: y,
321
- disableChangeValidate: ae,
322
- enableChangeValidate: de,
323
- disableOptionOfList: se,
324
- enableOptionOfList: fe,
321
+ buildFieldRules: F,
322
+ disableChangeValidate: le,
323
+ enableChangeValidate: ae,
324
+ disableOptionOfList: de,
325
+ enableOptionOfList: se,
325
326
  emitFieldDataChange: S,
326
327
  syncUpdateFormModel: H,
327
- handleFocusCustomEvent: ue,
328
- handleBlurCustomEvent: re,
329
- emitAppendButtonClick: ce,
328
+ handleFocusCustomEvent: fe,
329
+ handleBlurCustomEvent: ue,
330
+ emitAppendButtonClick: re,
330
331
  handleOnChange: z,
331
- onClick: me,
332
- handleClickIcon: ge,
333
- getFieldEditor: R,
332
+ onClick: ce,
333
+ handleClickIcon: me,
334
+ getFieldEditor: y,
334
335
  showFileList: U,
335
- setAppendButtonVisible: Fe,
336
- setAppendButtonDisabled: ye,
336
+ setAppendButtonVisible: be,
337
+ setAppendButtonDisabled: Fe,
337
338
  focus: W,
338
- setUploadData: Ie,
339
- isSubFormField: M,
340
- defineExposed: qe
339
+ setUploadData: Ve,
340
+ isSubFormField: D,
341
+ defineExposed: Oe
341
342
  };
342
343
  }
343
344
  export {