vft 0.0.485 → 0.0.493

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/attributes.json +1 -1
  2. package/dist/index.css +1 -1
  3. package/es/components/autocomplete/autocomplete.vue.d.ts +2 -2
  4. package/es/components/autocomplete/index.d.ts +6 -6
  5. package/es/components/button/index.d.ts +9 -9
  6. package/es/components/carousel/use-carousel.js +1 -1
  7. package/es/components/config-provider/hooks/use-global-config.js +3 -3
  8. package/es/components/dialog/use-dialog.js +11 -11
  9. package/es/components/input/input.vue2.js +4 -4
  10. package/es/components/input-tag/composables/use-input-tag.js +1 -1
  11. package/es/components/message/message.vue2.js +45 -42
  12. package/es/components/message/types.d.ts +8 -2
  13. package/es/components/message/types.js +2 -1
  14. package/es/components/modal/index.d.ts +72 -3
  15. package/es/components/modal/modal-footer-action.vue.d.ts +1 -1
  16. package/es/components/modal/modal-footer-action.vue2.js +13 -15
  17. package/es/components/modal/modal.vue.d.ts +27 -3
  18. package/es/components/modal/modal.vue2.js +59 -59
  19. package/es/components/modal/types.d.ts +2 -0
  20. package/es/components/popconfirm/index.d.ts +15 -15
  21. package/es/components/popconfirm/popconfirm.vue.d.ts +1 -1
  22. package/es/components/router-view-content/index.d.ts +6 -0
  23. package/es/components/router-view-content/router-view-content.vue.d.ts +1 -0
  24. package/es/components/router-view-content/router-view-content.vue2.js +19 -18
  25. package/es/components/select/index.d.ts +4 -4
  26. package/es/components/select/select.vue.d.ts +4 -4
  27. package/es/components/select/useSelect.d.ts +4 -4
  28. package/es/components/super-form/index.d.ts +30 -24
  29. package/es/components/super-form/super-form-item.vue2.js +263 -231
  30. package/es/components/super-form/super-form.vue.d.ts +3 -1
  31. package/es/components/super-form/super-form.vue2.js +153 -132
  32. package/es/components/super-form/types.d.ts +4 -2
  33. package/es/components/super-form/use/helper.d.ts +34 -0
  34. package/es/components/super-form/use/helper.js +81 -34
  35. package/es/components/switch/index.d.ts +1 -0
  36. package/es/components/switch/switch.vue.d.ts +1 -25
  37. package/es/components/switch/types.d.ts +25 -0
  38. package/es/components/switch/types.js +1 -0
  39. package/es/components/table/index.d.ts +6 -0
  40. package/es/components/table/table.vue.d.ts +4 -0
  41. package/es/components/table/table.vue2.js +164 -149
  42. package/es/package.json.d.ts +1 -1
  43. package/es/package.json.js +1 -1
  44. package/es/utils/form-register.d.ts +1 -1
  45. package/es/utils/form-register.js +1 -1
  46. package/es/utils/vue/vnode.js +1 -1
  47. package/lib/components/autocomplete/autocomplete.vue.d.ts +2 -2
  48. package/lib/components/autocomplete/index.d.ts +6 -6
  49. package/lib/components/button/index.d.ts +9 -9
  50. package/lib/components/dialog/use-dialog.cjs +1 -1
  51. package/lib/components/input/input.vue2.cjs +1 -1
  52. package/lib/components/message/message.vue2.cjs +1 -1
  53. package/lib/components/message/types.cjs +1 -1
  54. package/lib/components/message/types.d.ts +8 -2
  55. package/lib/components/modal/index.d.ts +72 -3
  56. package/lib/components/modal/modal-footer-action.vue.d.ts +1 -1
  57. package/lib/components/modal/modal-footer-action.vue2.cjs +1 -1
  58. package/lib/components/modal/modal.vue.d.ts +27 -3
  59. package/lib/components/modal/modal.vue2.cjs +1 -1
  60. package/lib/components/modal/types.d.ts +2 -0
  61. package/lib/components/popconfirm/index.d.ts +15 -15
  62. package/lib/components/popconfirm/popconfirm.vue.d.ts +1 -1
  63. package/lib/components/router-view-content/index.d.ts +6 -0
  64. package/lib/components/router-view-content/router-view-content.vue.d.ts +1 -0
  65. package/lib/components/router-view-content/router-view-content.vue2.cjs +1 -1
  66. package/lib/components/select/index.d.ts +4 -4
  67. package/lib/components/select/select.vue.d.ts +4 -4
  68. package/lib/components/select/useSelect.d.ts +4 -4
  69. package/lib/components/super-form/index.d.ts +30 -24
  70. package/lib/components/super-form/super-form-item.vue2.cjs +1 -1
  71. package/lib/components/super-form/super-form.vue.d.ts +3 -1
  72. package/lib/components/super-form/super-form.vue2.cjs +1 -1
  73. package/lib/components/super-form/types.d.ts +4 -2
  74. package/lib/components/super-form/use/helper.cjs +1 -1
  75. package/lib/components/super-form/use/helper.d.ts +34 -0
  76. package/lib/components/switch/index.d.ts +1 -0
  77. package/lib/components/switch/switch.vue.d.ts +1 -25
  78. package/lib/components/switch/types.cjs +1 -0
  79. package/lib/components/switch/types.d.ts +25 -0
  80. package/lib/components/table/index.d.ts +6 -0
  81. package/lib/components/table/table.vue.d.ts +4 -0
  82. package/lib/components/table/table.vue2.cjs +1 -1
  83. package/lib/package.json.cjs +1 -1
  84. package/lib/package.json.d.ts +1 -1
  85. package/lib/utils/form-register.cjs +1 -1
  86. package/lib/utils/form-register.d.ts +1 -1
  87. package/package.json +5 -5
  88. package/tags.json +1 -1
  89. package/theme-style/index.css +1 -1
  90. package/theme-style/src/dialog.scss +1 -1
  91. package/theme-style/src/message.scss +8 -4
  92. package/theme-style/src/super-form.scss +6 -0
  93. package/theme-style/src/table.scss +25 -6
  94. package/theme-style/vft-dialog.css +1 -1
  95. package/theme-style/vft-message.css +1 -1
  96. package/theme-style/vft-super-form.css +1 -1
  97. package/theme-style/vft-table.css +1 -1
  98. package/web-types.json +1 -1
@@ -46,6 +46,8 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
46
46
  getSchema: import("vue").ComputedRef<FormSchema[]>;
47
47
  setFormItemError: (field: string, errMess: string) => Promise<void>;
48
48
  formModel: import("vue").ComputedRef<Recordable>;
49
+ hasActionButton: import("vue").ComputedRef<boolean>;
50
+ willExceedOneRow: import("vue").ComputedRef<boolean>;
49
51
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
50
52
  register: (instance: Partial<FormActionType>) => void;
51
53
  reset: (data: Recordable) => void;
@@ -89,11 +91,11 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
89
91
  showResetButton: boolean;
90
92
  showSubmitButton: boolean;
91
93
  showCommonButton: boolean;
94
+ quickColSpan: number;
92
95
  rulesMessageJoinLabel: boolean;
93
96
  autoCleanErrorMessage: boolean;
94
97
  compFullWidth: boolean;
95
98
  autoSetPlaceHolder: boolean;
96
- quickColSpan: number;
97
99
  rowProps: import("vft/es/components/row").RowProps;
98
100
  autoFocusFirstItem: boolean;
99
101
  autoSubmitOnEnter: boolean;
@@ -1,25 +1,26 @@
1
- import { defineComponent as j, useAttrs as se, reactive as le, ref as i, computed as c, unref as o, watch as h, nextTick as re, useSlots as ue, createBlock as u, createCommentVNode as K, openBlock as l, mergeProps as y, withKeys as ie, withModifiers as me, withCtx as v, renderSlot as O, normalizeProps as U, createElementBlock as fe, Fragment as ce, renderList as W, createSlots as pe, resolveDynamicComponent as E, h as de } from "vue";
2
- import { VftCol as Be } from "../col/index.js";
3
- import { VftForm as he } from "../form/index.js";
4
- import { VftRow as ye } from "../row/index.js";
5
- import { useTimeoutFn as ve, useDebounceFn as be } from "@vueuse/core";
6
- import { cloneDeep as ge, isEqual as Fe, pick as we, deepMerge as Re } from "@vft/utils";
1
+ import { defineComponent as J, useAttrs as le, reactive as ue, ref as m, computed as u, unref as n, watch as d, nextTick as ie, useSlots as me, createBlock as i, createCommentVNode as U, openBlock as l, mergeProps as B, withKeys as fe, withModifiers as ce, withCtx as h, renderSlot as O, normalizeProps as W, createElementBlock as pe, Fragment as de, renderList as j, createSlots as Be, resolveDynamicComponent as A, h as he } from "vue";
2
+ import { VftCol as ye } from "../col/index.js";
3
+ import { VftForm as ve } from "../form/index.js";
4
+ import { VftRow as be } from "../row/index.js";
5
+ import { useTimeoutFn as ge, useDebounceFn as we } from "@vueuse/core";
6
+ import { cloneDeep as Fe, isEqual as Re, pick as Se, deepMerge as Ce } from "@vft/utils";
7
7
  import "../config-provider/hooks/use-global-config.js";
8
8
  import "lodash-es";
9
- import { useNamespace as Se } from "../../hooks/use-namespace/index.js";
9
+ import { useNamespace as ke } from "../../hooks/use-namespace/index.js";
10
10
  import "../../hooks/use-model-toggle/index.js";
11
11
  import "@popperjs/core";
12
12
  import "../../hooks/use-z-index/index.js";
13
- import ke from "./super-form-action.vue2.js";
14
- import Ce from "./super-form-item.vue2.js";
13
+ import Ee from "./super-form-action.vue2.js";
14
+ import Oe from "./super-form-item.vue2.js";
15
15
  import { useAutoFocus as Ae } from "./use/use-auto-focus.js";
16
- import { createFormContext as Oe } from "./use/use-form-context.js";
17
- import { useFormEvents as Ee } from "./use/use-form-events.js";
18
- import { useFormValues as Pe } from "./use/use-form-values.js";
19
- const Ve = j({
16
+ import { createFormContext as Pe } from "./use/use-form-context.js";
17
+ import { useFormEvents as Ve } from "./use/use-form-events.js";
18
+ import { useFormValues as Ie } from "./use/use-form-values.js";
19
+ import { willFormExceedOneRow as Me } from "./use/helper.js";
20
+ const _e = J({
20
21
  name: "vft-super-form"
21
- }), Qe = /* @__PURE__ */ j({
22
- ...Ve,
22
+ }), et = /* @__PURE__ */ J({
23
+ ..._e,
23
24
  props: {
24
25
  size: {
25
26
  default: "default"
@@ -148,186 +149,206 @@ const Ve = j({
148
149
  }
149
150
  },
150
151
  emits: ["register", "reset", "submit", "field-value-change", "common-btn-click"],
151
- setup(J, {
152
- expose: Q,
153
- emit: X
152
+ setup(Q, {
153
+ expose: X,
154
+ emit: Y
154
155
  }) {
155
- const P = J, b = X, Y = Se("super-form"), Z = se(), r = le({}), g = i({}), p = i(!1), d = i({}), V = i(), F = i(null), I = i(), t = c(() => ({
156
+ const P = Q, y = Y, V = ke("super-form"), Z = le(), r = ue({}), p = m({}), v = m(!1), b = m({}), I = m(), g = m(null), M = m(), t = u(() => ({
156
157
  ...P,
157
- ...o(d)
158
- })), m = c(() => ({
158
+ ...n(b)
159
+ })), f = u(() => ({
159
160
  ...Z,
160
161
  ...P,
161
- ...o(t)
162
- })), s = c(() => {
163
- const e = o(V);
164
- return ge(e);
162
+ ...n(t)
163
+ })), a = u(() => {
164
+ const e = n(I);
165
+ return Fe(e);
165
166
  }), {
166
- handleFormValues: M,
167
- initDefault: _
168
- } = Pe({
167
+ handleFormValues: _,
168
+ initDefault: ee
169
+ } = Ie({
169
170
  getProps: t,
170
- defaultValueRef: g,
171
- getSchema: s,
171
+ defaultValueRef: p,
172
+ getSchema: a,
172
173
  formModel: r
173
174
  });
174
175
  Ae({
175
- getSchema: s,
176
+ getSchema: a,
176
177
  getProps: t,
177
- isInitedDefault: p,
178
- formElRef: F
178
+ isInitedDefault: v,
179
+ formElRef: g
179
180
  });
180
181
  const {
181
- handleSubmit: f,
182
+ handleSubmit: c,
182
183
  setFieldsValue: w,
183
184
  clearValidate: D,
184
185
  validate: T,
185
- validateField: q,
186
- getFieldsValue: R,
187
- updateSchema: S,
188
- resetSchema: B,
189
- appendSchemaByField: L,
190
- removeSchemaByField: $,
191
- resetFields: k,
192
- scrollToField: ee,
193
- getFieldValue: N,
194
- setFormItemError: x
195
- } = Ee({
196
- emit: b,
186
+ validateField: x,
187
+ getFieldsValue: F,
188
+ updateSchema: R,
189
+ resetSchema: S,
190
+ appendSchemaByField: q,
191
+ removeSchemaByField: L,
192
+ resetFields: C,
193
+ scrollToField: te,
194
+ getFieldValue: $,
195
+ setFormItemError: N
196
+ } = Ve({
197
+ emit: y,
197
198
  getProps: t,
198
199
  formModel: r,
199
- getSchema: s,
200
- defaultValueRef: g,
201
- formElRef: F,
202
- schemaRef: V,
203
- handleFormValues: M,
204
- initValues: I
200
+ getSchema: a,
201
+ defaultValueRef: p,
202
+ formElRef: g,
203
+ schemaRef: I,
204
+ handleFormValues: _,
205
+ initValues: M
205
206
  });
206
- Oe({
207
- resetAction: k,
208
- submitAction: f,
209
- commonAction: () => b("common-btn-click")
210
- }), h(() => o(t).model, () => {
207
+ Pe({
208
+ resetAction: C,
209
+ submitAction: c,
210
+ commonAction: () => y("common-btn-click")
211
+ }), d(() => n(t).model, () => {
211
212
  const {
212
213
  model: e
213
- } = o(t);
214
+ } = n(t);
214
215
  e && w(e);
215
216
  }, {
216
217
  immediate: !0
217
- }), h(() => o(t).schemas, (e, a) => {
218
- Fe(e, a) || B(e ?? []);
219
- }), h(() => s.value, (e) => {
220
- re(() => {
221
- }), !o(p) && e?.length && (_(), p.value = !0, t.value?.watchDataIsChange && ve(() => {
222
- I.value = R();
218
+ }), d(() => n(t).schemas, (e, o) => {
219
+ Re(e, o) || S(e ?? []);
220
+ }), d(() => a.value, (e) => {
221
+ ie(() => {
222
+ }), !n(v) && e?.length && (ee(), v.value = !0, t.value?.watchDataIsChange && ge(() => {
223
+ M.value = F();
223
224
  }, 40));
224
- }), h(() => r, be(() => {
225
- o(t).submitOnChange && f();
225
+ }), d(() => r, we(() => {
226
+ n(t).submitOnChange && c();
226
227
  }, 300), {
227
228
  deep: !0
228
229
  });
229
230
  async function G(e) {
230
- d.value = Re(o(d) || {}, e), p.value || (B(d.value?.schemas ?? []), _());
231
+ b.value = Ce(n(b) || {}, e);
231
232
  }
232
- function te(e, a, n) {
233
- r[e] = a, n && n.itemProps;
233
+ function oe(e, o, s) {
234
+ r[e] = o;
234
235
  }
235
- function oe(e) {
236
+ function ne(e) {
236
237
  const {
237
- autoSubmitOnEnter: a
238
- } = o(t);
239
- if (a && e.key === "Enter" && e.target && e.target instanceof HTMLElement) {
240
- const n = e.target;
241
- n && n.tagName && n.tagName.toUpperCase() === "INPUT" && f();
238
+ autoSubmitOnEnter: o
239
+ } = n(t);
240
+ if (o && e.key === "Enter" && e.target && e.target instanceof HTMLElement) {
241
+ const s = e.target;
242
+ s && s.tagName && s.tagName.toUpperCase() === "INPUT" && c();
242
243
  }
243
244
  }
244
245
  const H = {
245
- getFieldsValue: R,
246
- getFieldValue: N,
246
+ getFieldsValue: F,
247
+ getFieldValue: $,
247
248
  setFieldsValue: w,
248
- resetFields: k,
249
- updateSchema: S,
250
- resetSchema: B,
249
+ resetFields: C,
250
+ updateSchema: R,
251
+ resetSchema: S,
251
252
  setProps: G,
252
- removeSchemaByField: $,
253
- appendSchemaByField: L,
253
+ removeSchemaByField: L,
254
+ appendSchemaByField: q,
254
255
  clearValidate: D,
255
- validateField: q,
256
- setFormItemError: x,
256
+ validateField: x,
257
+ setFormItemError: N,
257
258
  validate: T,
258
- submit: f,
259
- scrollToField: ee
259
+ submit: c,
260
+ scrollToField: te
260
261
  };
261
- b("register", H);
262
- const ae = c(() => we(t.value, ["showResetButton", "showCommonButton", "showSubmitButton", "resetButtonOptions", "submitButtonOptions", "commonButtonOptions", "actionRowOptions", "actionSpan", "submitResetReverse"])), C = ue(), A = (e) => e ? de(ke, ae.value, {
263
- resetBefore: (a) => C.resetBefore?.(a),
264
- submitBefore: (a) => C.submitBefore?.(a),
265
- submitAfter: (a) => C.submitAfter?.(a)
262
+ y("register", H);
263
+ const ae = u(() => Se(t.value, ["showResetButton", "showCommonButton", "showSubmitButton", "resetButtonOptions", "submitButtonOptions", "commonButtonOptions", "actionRowOptions", "actionSpan", "submitResetReverse"])), se = u(() => {
264
+ const {
265
+ showCommonButton: e,
266
+ showResetButton: o,
267
+ showSubmitButton: s
268
+ } = t.value;
269
+ return !!(e || o || s);
270
+ }), z = u(() => {
271
+ const e = n(a);
272
+ if (!e || e.length === 0)
273
+ return !1;
274
+ try {
275
+ return Me(e, t.value, r, p.value).willExceed;
276
+ } catch {
277
+ return !1;
278
+ }
279
+ }), k = me(), E = (e) => e ? he(Ee, ae.value, {
280
+ resetBefore: (o) => k.resetBefore?.(o),
281
+ submitBefore: (o) => k.submitBefore?.(o),
282
+ submitAfter: (o) => k.submitAfter?.(o)
266
283
  }) : null;
267
- return Q({
268
- getFieldsValue: R,
269
- getFieldValue: N,
284
+ return X({
285
+ getFieldsValue: F,
286
+ getFieldValue: $,
270
287
  setFieldsValue: w,
271
- resetFields: k,
272
- updateSchema: S,
273
- resetSchema: B,
288
+ resetFields: C,
289
+ updateSchema: R,
290
+ resetSchema: S,
274
291
  setProps: G,
275
- removeSchemaByField: $,
276
- appendSchemaByField: L,
292
+ removeSchemaByField: L,
293
+ appendSchemaByField: q,
277
294
  clearValidate: D,
278
- validateField: q,
295
+ validateField: x,
279
296
  validate: T,
280
- submit: f,
281
- getSchema: s,
282
- setFormItemError: x,
283
- formModel: c(() => M(r))
284
- }), (e, a) => s.value?.length ? (l(), u(o(he), y({
297
+ submit: c,
298
+ getSchema: a,
299
+ setFormItemError: N,
300
+ formModel: u(() => _(r)),
301
+ hasActionButton: se,
302
+ willExceedOneRow: z
303
+ }), (e, o) => a.value?.length ? (l(), i(n(ve), B({
285
304
  key: 0
286
- }, m.value, {
305
+ }, f.value, {
287
306
  ref_key: "formElRef",
288
- ref: F,
289
- class: o(Y).b(),
307
+ ref: g,
308
+ class: [n(V).b(), {
309
+ [n(V).is("exceed-one-row")]: z.value
310
+ }],
290
311
  model: r,
291
- onSubmit: a[0] || (a[0] = me(() => {
312
+ onSubmit: o[0] || (o[0] = ce(() => {
292
313
  }, ["prevent"])),
293
- onKeypress: ie(oe, ["enter"])
314
+ onKeypress: fe(ne, ["enter"])
294
315
  }), {
295
- default: v(() => [s.value?.length ? (l(), u(o(ye), U(y({
316
+ default: h(() => [a.value?.length ? (l(), i(n(be), W(B({
296
317
  key: 0
297
- }, m.value?.rowProps)), {
298
- default: v(() => [O(e.$slots, "formHeader"), (l(!0), fe(ce, null, W(s.value, (n) => (l(), u(Ce, {
299
- key: n.field,
318
+ }, f.value?.rowProps)), {
319
+ default: h(() => [O(e.$slots, "formHeader"), (l(!0), pe(de, null, j(a.value, (s) => (l(), i(Oe, {
320
+ key: s.field,
300
321
  "form-action-type": H,
301
- schema: n,
322
+ schema: s,
302
323
  "form-props": t.value,
303
- "all-default-values": g.value,
324
+ "all-default-values": p.value,
304
325
  "form-model": r,
305
- "set-form-model": te,
306
- "update-schema": o(S)
307
- }, pe({
326
+ "set-form-model": oe,
327
+ "update-schema": n(R)
328
+ }, Be({
308
329
  _: 2
309
- }, [W(Object.keys(e.$slots), (z) => ({
310
- name: z,
311
- fn: v((ne) => [O(e.$slots, z, y({
330
+ }, [j(Object.keys(e.$slots), (K) => ({
331
+ name: K,
332
+ fn: h((re) => [O(e.$slots, K, B({
312
333
  ref_for: !0
313
- }, ne || {}))])
314
- }))]), 1032, ["schema", "form-props", "all-default-values", "form-model", "update-schema"]))), 128)), t.value?.customLayout ? (l(), u(E(A(t.value?.showActionButtonGroup && t.value?.actionInline)), {
334
+ }, re || {}))])
335
+ }))]), 1032, ["schema", "form-props", "all-default-values", "form-model", "update-schema"]))), 128)), t.value?.customLayout ? (l(), i(A(E(t.value?.showActionButtonGroup && t.value?.actionInline)), {
315
336
  key: 1
316
- })) : (l(), u(o(Be), U(y({
337
+ })) : (l(), i(n(ye), W(B({
317
338
  key: 0
318
- }, m.value?.quickColSpan ? {
319
- span: Math.ceil(24 / m.value?.quickColSpan),
320
- ...m.value?.baseColProps
339
+ }, f.value?.quickColSpan ? {
340
+ span: Math.ceil(24 / f.value?.quickColSpan),
341
+ ...f.value?.baseColProps
321
342
  } : {})), {
322
- default: v(() => [(l(), u(E(A(t.value?.showActionButtonGroup && t.value?.actionInline))))]),
343
+ default: h(() => [(l(), i(A(E(t.value?.showActionButtonGroup && t.value?.actionInline))))]),
323
344
  _: 1
324
345
  }, 16))]),
325
346
  _: 3
326
- }, 16)) : K("", !0), (l(), u(E(A(t.value?.showActionButtonGroup && !t.value?.actionInline)))), O(e.$slots, "formFooter")]),
347
+ }, 16)) : U("", !0), (l(), i(A(E(t.value?.showActionButtonGroup && !t.value?.actionInline)))), O(e.$slots, "formFooter")]),
327
348
  _: 3
328
- }, 16, ["class", "model"])) : K("", !0);
349
+ }, 16, ["class", "model"])) : U("", !0);
329
350
  }
330
351
  });
331
352
  export {
332
- Qe as default
353
+ et as default
333
354
  };
@@ -1,3 +1,4 @@
1
+ import type { SwitchProps } from 'vft/es/components';
1
2
  import type { ButtonProps } from 'vft/es/components/button';
2
3
  import type { ColProps } from 'vft/es/components/col';
3
4
  import type { FormItemProp, FormItemProps, FormProps } from 'vft/es/components/form';
@@ -39,6 +40,7 @@ type FormItemRule = Omit<RuleItem, 'validator'> & Rule & {
39
40
  } & {
40
41
  isNumber?: boolean;
41
42
  };
43
+ export type SchemaCompOptions = SwitchProps | Record<string, any>;
42
44
  /** 渲染回调参数接口 */
43
45
  export interface RenderCallbackParams {
44
46
  /** 表单配置模式 */
@@ -205,8 +207,8 @@ export interface FormSchema {
205
207
  componentProps?: ((opt: {
206
208
  schema: FormSchema;
207
209
  formActionType: FormActionType;
208
- formModel: Recordable;
209
- }) => Recordable) | object;
210
+ formModel: Record<string, any>;
211
+ }) => SchemaCompOptions | Promise<SchemaCompOptions>) | SchemaCompOptions;
210
212
  /** 是否为必填项 */
211
213
  required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
212
214
  /** 组件后自定义内容 */
@@ -1,3 +1,4 @@
1
+ import type { FormSchema, RenderCallbackParams, SuperFormProps } from '../types';
1
2
  import { type FormCompEnumType } from 'vft/es/utils';
2
3
  /**
3
4
  * @description 自动创建 placeholder
@@ -15,3 +16,36 @@ export declare function createPlaceholderMessage(type: FormCompEnumType, label?:
15
16
  * @param val
16
17
  */
17
18
  export declare function handleInputNumberValue(type?: FormCompEnumType, val?: any): any;
19
+ /**
20
+ * @description 获取表单项的显示状态
21
+ * @param schema 表单配置
22
+ * @param values 渲染回调参数(可选,用于函数类型的 show/ifShow)
23
+ * @returns { isShow: boolean, isIfShow: boolean }
24
+ */
25
+ export declare function getSchemaShowState(schema: FormSchema, values?: RenderCallbackParams): {
26
+ isShow: boolean;
27
+ isIfShow: boolean;
28
+ };
29
+ /**
30
+ * @description 计算表单项的 span 值
31
+ * @param schema 表单配置
32
+ * @param formProps 表单属性
33
+ * @returns span 值
34
+ */
35
+ export declare function calculateSchemaSpan(schema: FormSchema, formProps: SuperFormProps): number;
36
+ /**
37
+ * @description 判断表单是否会超过一行
38
+ * @param schemas 表单配置数组
39
+ * @param formProps 表单属性
40
+ * @param formModel 表单模型(可选,用于计算动态显示状态)
41
+ * @param allDefaultValues 所有默认值(可选,用于计算动态显示状态)
42
+ * @returns { willExceed: boolean, totalSpan: number, visibleItems: Array }
43
+ */
44
+ export declare function willFormExceedOneRow(schemas: FormSchema[], formProps: SuperFormProps, formModel?: Record<string, any>, allDefaultValues?: Record<string, any>): {
45
+ willExceed: boolean;
46
+ totalSpan: number;
47
+ visibleItems: Array<{
48
+ field: string;
49
+ span: number;
50
+ }>;
51
+ };
@@ -1,43 +1,90 @@
1
- import { isNumber as n } from "@vft/utils";
2
- import { isInput as u } from "../component-map.js";
3
- import { FormCompEnum as e } from "../../../utils/form-register.js";
1
+ import { isBoolean as l, isFunction as a, isNumber as h } from "@vft/utils";
2
+ import { isInput as p } from "../component-map.js";
3
+ import { FormCompEnum as i } from "../../../utils/form-register.js";
4
4
  import "@vueuse/core";
5
5
  import "../../config-provider/hooks/use-global-config.js";
6
6
  import "vue";
7
7
  import "lodash-es";
8
8
  import "../../form/index.js";
9
- function l(r, i = "") {
10
- return i = (i || "").replace(":", "") || "", [
11
- e.Input,
12
- e.InputNumber,
13
- e.Textarea,
14
- e.AutoComplete
15
- ].includes(r) ? "请输入" + i : [e.Password].includes(r) ? "请输入密码" : [
16
- e.Select,
17
- e.Radio,
18
- e.RadioSingle,
19
- e.RadioButton,
20
- e.Cascader,
21
- e.ColorPicker,
22
- e.Checkbox,
23
- e.CheckboxButton
24
- ].includes(r) ? "请选择" + i : [e.CheckboxSingle].includes(r) ? "请勾选" + i : [e.Search].includes(r) ? "请输入要搜索的内容" : [e.InputTag].includes(r) ? "请输入标签内容" : [e.Upload].includes(r) ? "请选择上传文件" : [e.Slider].includes(r) ? "请拖动滑块" : [
25
- e.TimePicker,
26
- e.YearPicker,
27
- e.MonthPicker,
28
- e.DatePicker,
29
- e.DatesPicker,
30
- e.DateTimePicker,
31
- e.WeekPicker,
32
- e.DateTimeRangePicker,
33
- e.DateRangePicker,
34
- e.MonthRangePicker
35
- ].includes(r) ? "请选择时间" : "";
9
+ function P(n, e = "") {
10
+ return e = (e || "").replace(":", "") || "", [
11
+ i.Input,
12
+ i.InputNumber,
13
+ i.Textarea,
14
+ i.AutoComplete
15
+ ].includes(n) ? "请输入" + e : [i.Password].includes(n) ? "请输入密码" : [
16
+ i.Select,
17
+ i.Radio,
18
+ i.RadioSingle,
19
+ i.RadioButton,
20
+ i.Cascader,
21
+ i.ColorPicker,
22
+ i.Checkbox,
23
+ i.CheckboxButton
24
+ ].includes(n) ? "请选择" + e : [i.CheckboxSingle].includes(n) ? "请勾选" + e : [i.Search].includes(n) ? "请输入要搜索的内容" : [i.InputTag].includes(n) ? "请输入标签内容" : [i.Upload].includes(n) ? "请选择上传文件" : [i.Slider].includes(n) ? "请拖动滑块" : [
25
+ i.TimePicker,
26
+ i.YearPicker,
27
+ i.MonthPicker,
28
+ i.DatePicker,
29
+ i.DatesPicker,
30
+ i.DateTimePicker,
31
+ i.WeekPicker,
32
+ i.DateTimeRangePicker,
33
+ i.DateRangePicker,
34
+ i.MonthRangePicker
35
+ ].includes(n) ? "请选择时间" : "";
36
36
  }
37
- function k(r, i) {
38
- return r && u(r) && i && n(i) ? `${i}` : i;
37
+ function q(n, e) {
38
+ return n && p(n) && e && h(e) ? `${e}` : e;
39
+ }
40
+ function k(n, e) {
41
+ const { show: t, ifShow: o } = n;
42
+ let c = !0, r = !0;
43
+ return l(t) ? c = t : a(t) && e && (c = t(e)), l(o) ? r = o : a(o) && e && (r = o(e)), { isShow: c, isIfShow: r };
44
+ }
45
+ function m(n, e) {
46
+ const { baseColProps: t = {}, quickColSpan: o } = e;
47
+ return n.type === i.Divider ? 24 : n.colProps?.span !== void 0 ? n.colProps.span : n.quickColSpan ? Math.ceil(24 / n.quickColSpan) : t.span !== void 0 ? t.span : o ? Math.ceil(24 / o) : 24;
48
+ }
49
+ function D(n, e, t, o) {
50
+ if (e.customLayout)
51
+ return {
52
+ willExceed: !1,
53
+ totalSpan: 0,
54
+ visibleItems: []
55
+ };
56
+ const c = [];
57
+ let r = 0;
58
+ for (const u of n) {
59
+ const f = t && o ? {
60
+ field: u.field,
61
+ model: t,
62
+ values: {
63
+ ...o,
64
+ ...t
65
+ },
66
+ schema: u
67
+ } : void 0, { isIfShow: S } = k(u, f);
68
+ if (!S)
69
+ continue;
70
+ const s = m(u, e);
71
+ c.push({ field: u.field, span: s }), r += s;
72
+ }
73
+ const d = e.showCommonButton || e.showResetButton || e.showSubmitButton;
74
+ if (e.actionInline && e.showActionButtonGroup && d && !e.customLayout) {
75
+ const u = e.quickColSpan ? Math.ceil(24 / e.quickColSpan) : e.baseColProps?.span || 24;
76
+ r += u;
77
+ }
78
+ return {
79
+ willExceed: r > 24,
80
+ totalSpan: r,
81
+ visibleItems: c
82
+ };
39
83
  }
40
84
  export {
41
- l as createPlaceholderMessage,
42
- k as handleInputNumberValue
85
+ m as calculateSchemaSpan,
86
+ P as createPlaceholderMessage,
87
+ k as getSchemaShowState,
88
+ q as handleInputNumberValue,
89
+ D as willFormExceedOneRow
43
90
  };
@@ -164,3 +164,4 @@ export declare const VftSwitch: import("vft/es/utils").SFCWithInstall<import("vu
164
164
  inactiveValue: boolean | string | number;
165
165
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>> & Record<string, any>;
166
166
  export default VftSwitch;
167
+ export * from './types';
@@ -1,28 +1,4 @@
1
- import { IconProps } from 'vft/es/components/icon';
2
- import { ComponentSize } from 'vft/es/constants';
3
- export interface SwitchProps {
4
- modelValue?: boolean | string | number;
5
- value?: boolean | string | number;
6
- disabled?: boolean;
7
- width?: string | number;
8
- inlinePrompt?: boolean;
9
- activeIcon?: IconProps | string;
10
- inactiveIcon?: IconProps | string;
11
- activeText?: string;
12
- inactiveText?: string;
13
- activeColor?: string;
14
- inactiveColor?: string;
15
- borderColor?: string;
16
- activeValue?: boolean | string | number;
17
- inactiveValue?: boolean | string | number;
18
- name?: string;
19
- validateEvent?: boolean;
20
- id?: string;
21
- loading?: boolean;
22
- beforeChange?: Function;
23
- size?: ComponentSize;
24
- tabindex?: string | number;
25
- }
1
+ import type { SwitchProps } from './types';
26
2
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<SwitchProps>, {
27
3
  modelValue: boolean;
28
4
  value: boolean;
@@ -0,0 +1,25 @@
1
+ import type { IconProps } from 'vft/es/components/icon';
2
+ import type { ComponentSize } from 'vft/es/constants';
3
+ export interface SwitchProps {
4
+ modelValue?: boolean | string | number;
5
+ value?: boolean | string | number;
6
+ disabled?: boolean;
7
+ width?: string | number;
8
+ inlinePrompt?: boolean;
9
+ activeIcon?: IconProps | string;
10
+ inactiveIcon?: IconProps | string;
11
+ activeText?: string;
12
+ inactiveText?: string;
13
+ activeColor?: string;
14
+ inactiveColor?: string;
15
+ borderColor?: string;
16
+ activeValue?: boolean | string | number;
17
+ inactiveValue?: boolean | string | number;
18
+ name?: string;
19
+ validateEvent?: boolean;
20
+ id?: string;
21
+ loading?: boolean;
22
+ beforeChange?: Function;
23
+ size?: ComponentSize;
24
+ tabindex?: string | number;
25
+ }
@@ -0,0 +1 @@
1
+