vft 0.0.493 → 0.0.495

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 (69) 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/config-provider/hooks/use-global-config.js +3 -3
  7. package/es/components/popconfirm/index.d.ts +15 -15
  8. package/es/components/popconfirm/popconfirm.vue.d.ts +1 -1
  9. package/es/components/select/index.d.ts +4 -4
  10. package/es/components/select/select.vue.d.ts +4 -4
  11. package/es/components/select/useSelect.d.ts +4 -4
  12. package/es/components/super-form/index.d.ts +9 -0
  13. package/es/components/super-form/super-form-item.vue2.js +219 -219
  14. package/es/components/super-form/super-form.vue2.js +97 -95
  15. package/es/components/super-form/types.d.ts +20 -1
  16. package/es/components/super-form/use/use-form-events.d.ts +1 -0
  17. package/es/components/super-form/use/use-form-events.js +205 -171
  18. package/es/components/switch/index.d.ts +2 -2
  19. package/es/components/switch/types.d.ts +22 -1
  20. package/es/components/table/field.js +60 -55
  21. package/es/components/table/index.d.ts +3 -3
  22. package/es/components/table/table.vue.d.ts +1 -1
  23. package/es/components/table/types.d.ts +2 -2
  24. package/es/components/table/use/use-data-source.d.ts +1 -1
  25. package/es/components/table/use/use-data-source.js +136 -119
  26. package/es/components/table/use/use-loading.js +15 -13
  27. package/es/components/tree/index.d.ts +5 -5
  28. package/es/components/tree/tree.vue.d.ts +2 -2
  29. package/es/components/upload/index.d.ts +15 -15
  30. package/es/components/upload/upload-content.vue.d.ts +1 -1
  31. package/es/components/upload/upload.vue.d.ts +1 -1
  32. package/es/package.json.d.ts +1 -1
  33. package/es/package.json.js +1 -1
  34. package/lib/components/autocomplete/autocomplete.vue.d.ts +2 -2
  35. package/lib/components/autocomplete/index.d.ts +6 -6
  36. package/lib/components/button/index.d.ts +9 -9
  37. package/lib/components/popconfirm/index.d.ts +15 -15
  38. package/lib/components/popconfirm/popconfirm.vue.d.ts +1 -1
  39. package/lib/components/select/index.d.ts +4 -4
  40. package/lib/components/select/select.vue.d.ts +4 -4
  41. package/lib/components/select/useSelect.d.ts +4 -4
  42. package/lib/components/super-form/index.d.ts +9 -0
  43. package/lib/components/super-form/super-form-item.vue2.cjs +1 -1
  44. package/lib/components/super-form/super-form.vue2.cjs +1 -1
  45. package/lib/components/super-form/types.d.ts +20 -1
  46. package/lib/components/super-form/use/use-form-events.cjs +1 -1
  47. package/lib/components/super-form/use/use-form-events.d.ts +1 -0
  48. package/lib/components/switch/index.d.ts +2 -2
  49. package/lib/components/switch/types.d.ts +22 -1
  50. package/lib/components/table/field.cjs +1 -1
  51. package/lib/components/table/index.d.ts +3 -3
  52. package/lib/components/table/table.vue.d.ts +1 -1
  53. package/lib/components/table/types.d.ts +2 -2
  54. package/lib/components/table/use/use-data-source.cjs +1 -1
  55. package/lib/components/table/use/use-data-source.d.ts +1 -1
  56. package/lib/components/table/use/use-loading.cjs +1 -1
  57. package/lib/components/tree/index.d.ts +5 -5
  58. package/lib/components/tree/tree.vue.d.ts +2 -2
  59. package/lib/components/upload/index.d.ts +15 -15
  60. package/lib/components/upload/upload-content.vue.d.ts +1 -1
  61. package/lib/components/upload/upload.vue.d.ts +1 -1
  62. package/lib/package.json.cjs +1 -1
  63. package/lib/package.json.d.ts +1 -1
  64. package/package.json +5 -5
  65. package/tags.json +1 -1
  66. package/theme-style/index.css +1 -1
  67. package/theme-style/src/table.scss +2 -4
  68. package/theme-style/vft-table.css +1 -1
  69. package/web-types.json +1 -1
@@ -1,269 +1,303 @@
1
- import { FormCompEnum as j } from "../../../utils/form-register.js";
1
+ import { FormCompEnum as T } from "../../../utils/form-register.js";
2
2
  import "@vueuse/core";
3
- import { isDef as H, isFunction as A, isString as x, isObject as m, isArray as V, deepMerge as nt, findDifferentValuesForObj as rt, isNullOrUndefined as J, isEmpty as st, isEmptyObject as lt } from "@vft/utils";
3
+ import { isFunction as b, isDef as H, isString as g, isObject as j, isArray as C, deepMerge as ot, findDifferentValuesForObj as st, isNullOrUndefined as J, isEmpty as at, isEmptyObject as ct } from "@vft/utils";
4
4
  import "../../config-provider/hooks/use-global-config.js";
5
- import { unref as n, toRaw as S, nextTick as Q } from "vue";
6
- import { get as ot, cloneDeep as B, uniqBy as at, isEqual as ft, set as X } from "lodash-es";
5
+ import { toRaw as I, unref as n, nextTick as Q } from "vue";
6
+ import { get as lt, cloneDeep as A, uniqBy as ft, isEqual as ut, set as X } from "lodash-es";
7
7
  import "../../form/index.js";
8
8
  import { formatToDate as W } from "@vft/utils/date";
9
- import { isInput as ct, isDatePicker as ut } from "../component-map.js";
10
- import { handleInputNumberValue as dt } from "./helper.js";
11
- function _(p, v) {
12
- const { show: o, ifShow: f } = p;
13
- let h = !0, c = !0;
14
- return typeof o == "boolean" ? h = o : typeof o == "function" && (h = o({
9
+ import { isInput as dt, isDatePicker as ht } from "../component-map.js";
10
+ import { handleInputNumberValue as pt } from "./helper.js";
11
+ function L(p, F) {
12
+ const { show: c, ifShow: l } = p;
13
+ let y = !0, u = !0;
14
+ return typeof c == "boolean" ? y = c : typeof c == "function" && (y = c({
15
15
  field: p.field,
16
- model: v,
16
+ model: F,
17
17
  values: {
18
- ...v
18
+ ...F
19
19
  },
20
20
  schema: p
21
- })), typeof f == "boolean" ? c = f : typeof f == "function" && (c = f({
21
+ })), typeof l == "boolean" ? u = l : typeof l == "function" && (u = l({
22
22
  field: p.field,
23
- model: v,
23
+ model: F,
24
24
  values: {
25
- ...v
25
+ ...F
26
26
  },
27
27
  schema: p
28
- })), h && c;
28
+ })), y && u;
29
29
  }
30
- function pt(p, v = {}) {
31
- const o = /^\[(.+)\]$/;
32
- if (o.test(p)) {
33
- const f = p.match(o);
34
- if (f && f[1]) {
35
- const h = f[1].split(",");
36
- if (!h.length)
30
+ function Ft(p, F = {}) {
31
+ const c = /^\[(.+)\]$/;
32
+ if (c.test(p)) {
33
+ const l = p.match(c);
34
+ if (l && l[1]) {
35
+ const y = l[1].split(",");
36
+ if (!y.length)
37
37
  return;
38
- const c = [];
39
- return h.forEach((y, O) => {
40
- X(c, O, v[y.trim()]);
41
- }), c.filter(Boolean).length ? c : void 0;
38
+ const u = [];
39
+ return y.forEach((v, V) => {
40
+ X(u, V, F[v.trim()]);
41
+ }), u.filter(Boolean).length ? u : void 0;
42
42
  }
43
43
  }
44
44
  }
45
- function ht(p, v = {}) {
46
- const o = /^\{(.+)\}$/;
47
- if (o.test(p)) {
48
- const f = p.match(o);
49
- if (f && f[1]) {
50
- const h = f[1].split(",");
51
- if (!h.length)
45
+ function yt(p, F = {}) {
46
+ const c = /^\{(.+)\}$/;
47
+ if (c.test(p)) {
48
+ const l = p.match(c);
49
+ if (l && l[1]) {
50
+ const y = l[1].split(",");
51
+ if (!y.length)
52
52
  return;
53
- const c = {};
54
- return h.forEach((y) => {
55
- X(c, y.trim(), v[y.trim()]);
56
- }), Object.values(c).filter(Boolean).length ? c : void 0;
53
+ const u = {};
54
+ return y.forEach((v) => {
55
+ X(u, v.trim(), F[v.trim()]);
56
+ }), Object.values(u).filter(Boolean).length ? u : void 0;
57
57
  }
58
58
  }
59
59
  }
60
- function Ot({
60
+ function Ct({
61
61
  emit: p,
62
- getProps: v,
63
- formModel: o,
64
- getSchema: f,
65
- defaultValueRef: h,
66
- formElRef: c,
67
- schemaRef: y,
68
- handleFormValues: O,
69
- initValues: T
62
+ getProps: F,
63
+ formModel: c,
64
+ getSchema: l,
65
+ defaultValueRef: y,
66
+ formElRef: u,
67
+ schemaRef: v,
68
+ handleFormValues: V,
69
+ initValues: S
70
70
  }) {
71
71
  async function Y(t) {
72
- const { resetFunc: e, submitOnReset: s } = n(v);
73
- e && A(e) && await e();
74
- const r = n(c);
75
- if (r) {
72
+ const { resetFunc: i, submitOnReset: r } = n(F);
73
+ i && b(i) && await i();
74
+ const o = n(u);
75
+ if (o) {
76
76
  if (t?.length)
77
- return r.resetFields(t);
78
- Object.keys(o).forEach((a) => {
79
- const l = n(f).find((u) => u.field === a), i = B(h.value[a]);
80
- o[a] = ct(l?.type) ? i || "" : i;
81
- }), Q(() => D()), p("reset", S(o)), s && await U();
77
+ return o.resetFields(t);
78
+ Object.keys(c).forEach((s) => {
79
+ const a = n(l).find((f) => f.field === s), e = A(y.value[s]);
80
+ c[s] = dt(a?.type) ? e || "" : e;
81
+ }), Q(() => O()), p("reset", I(c)), r && await z();
82
82
  }
83
83
  }
84
- async function q(t, e = !0) {
85
- const s = n(f).map((i) => i.field).filter(Boolean), r = ".", a = s.filter(
86
- (i) => String(i).indexOf(r) >= 0
87
- ), l = [];
88
- s.forEach((i) => {
89
- const u = n(f).find((d) => d.field === i);
90
- let b = ot(t, i);
91
- const I = Reflect.has(t, i);
92
- b = dt(u?.type, b);
93
- const { componentProps: z } = u || {};
94
- let w = z;
95
- typeof z == "function" && (w = w({ formModel: n(o) }));
96
- const G = pt(i, t) || ht(i, t);
97
- if (I || G) {
98
- const d = G || b;
99
- if (M(i))
100
- if (Array.isArray(d)) {
101
- const F = [];
102
- for (const E of d)
103
- F.push(E ? W(E) : null);
104
- n(o)[i] = F;
84
+ async function q(t, i = !0) {
85
+ const r = n(l).map((e) => e.field).filter(Boolean), o = ".", s = r.filter(
86
+ (e) => String(e).indexOf(o) >= 0
87
+ ), a = [];
88
+ r.forEach((e) => {
89
+ const f = n(l).find((h) => h.field === e);
90
+ let d = lt(t, e);
91
+ const m = Reflect.has(t, e);
92
+ d = pt(f?.type, d);
93
+ const { componentProps: w } = f || {};
94
+ let D = w;
95
+ typeof w == "function" && (D = D({ formModel: n(c) }));
96
+ const G = Ft(e, t) || yt(e, t);
97
+ if (m || G) {
98
+ const h = G || d;
99
+ if (tt(e))
100
+ if (Array.isArray(h)) {
101
+ const E = [];
102
+ for (const B of h)
103
+ E.push(B ? W(B) : null);
104
+ n(c)[e] = E;
105
105
  } else
106
- n(o)[i] = d ? w?.valueFormat ? d : W(d) : null;
106
+ n(c)[e] = h ? D?.valueFormat ? h : W(h) : null;
107
107
  else
108
- n(o)[i] = d;
109
- w?.onChange && w?.onChange(d), l.push(i);
108
+ n(c)[e] = h;
109
+ D?.onChange && D?.onChange(h), a.push(e);
110
110
  } else
111
- a.forEach((d) => {
111
+ s.forEach((h) => {
112
112
  try {
113
- const F = d.split(".").reduce((E, it) => E[it], t);
114
- H(F) && (n(o)[d] = n(F), l.push(d));
113
+ const E = h.split(".").reduce((B, rt) => B[rt], t);
114
+ H(E) && (n(c)[h] = n(E), a.push(h));
115
115
  } catch {
116
- H(h.value[d]) && (n(o)[d] = B(
117
- n(h.value[d])
116
+ H(y.value[h]) && (n(c)[h] = A(
117
+ n(y.value[h])
118
118
  ));
119
119
  }
120
120
  });
121
- }), e && Q(async () => {
122
- await $(l).catch((i) => {
121
+ }), i && Q(async () => {
122
+ await $(a).catch((e) => {
123
123
  });
124
124
  });
125
125
  }
126
126
  async function Z(t) {
127
- const e = B(n(f));
127
+ const i = A(n(l));
128
128
  if (!t)
129
129
  return;
130
- let s = x(t) ? [t] : t;
131
- x(t) && (s = [t]);
132
- for (const r of s)
133
- L(r, e);
134
- y.value = e;
130
+ let r = g(t) ? [t] : t;
131
+ g(t) && (r = [t]);
132
+ for (const o of r)
133
+ P(o, i);
134
+ v.value = i;
135
135
  }
136
- function L(t, e) {
137
- if (x(t)) {
138
- const s = e.findIndex((r) => r.field === t);
139
- s !== -1 && (delete o[t], e.splice(s, 1));
136
+ function P(t, i) {
137
+ if (g(t)) {
138
+ const r = i.findIndex((o) => o.field === t);
139
+ r !== -1 && (delete c[t], i.splice(r, 1));
140
140
  }
141
141
  }
142
- async function K(t, e, s = !1) {
143
- const r = B(n(f)), a = r.findIndex((i) => i.field === e), l = m(t) ? [t] : t;
144
- if (!e || a === -1 || s) {
145
- s ? r.unshift(...l) : r.push(...l), y.value = r, g(t);
142
+ async function K(t, i, r = !1) {
143
+ const o = A(n(l)), s = o.findIndex((e) => e.field === i), a = j(t) ? [t] : t;
144
+ if (!i || s === -1 || r) {
145
+ r ? o.unshift(...a) : o.push(...a), v.value = o, x(t);
146
146
  return;
147
147
  }
148
- a !== -1 && r.splice(a + 1, 0, ...l), g(t), y.value = r;
148
+ s !== -1 && o.splice(s + 1, 0, ...a), x(t), v.value = o;
149
149
  }
150
150
  async function k(t) {
151
- let e = [];
152
- if (m(t) && e.push(t), V(t) && (e = [...t]), !e.every(
153
- (r) => r.type === j.Divider || Reflect.has(r, "field") && r.field
151
+ let i = [];
152
+ if (j(t) && i.push(t), C(t) && (i = [...t]), !i.every(
153
+ (o) => o.type === T.Divider || Reflect.has(o, "field") && o.field
154
154
  )) {
155
155
  console.error(
156
156
  "All children of the form Schema array that need to be updated must contain the `field` field"
157
157
  );
158
158
  return;
159
159
  }
160
- y.value = e;
160
+ v.value = i;
161
161
  }
162
162
  async function N(t) {
163
- let e = [];
164
- if (m(t) && e.push(t), V(t) && (e = [...t]), !e.every(
165
- (l) => l.type === j.Divider || Reflect.has(l, "field") && l.field
163
+ let i = [];
164
+ if (j(t) && i.push(t), C(t) && (i = [...t]), !i.every(
165
+ (a) => a.type === T.Divider || Reflect.has(a, "field") && a.field
166
166
  )) {
167
167
  console.error(
168
168
  "All children of the form Schema array that need to be updated must contain the `field` field"
169
169
  );
170
170
  return;
171
171
  }
172
- const r = [], a = [];
173
- n(f).forEach((l) => {
174
- let i;
175
- if (e.forEach((u) => {
176
- l.field === u.field && (i = u), u.defaultValue && u.field && r.push(u.field);
177
- }), i !== void 0 && l.field === i.field) {
178
- const u = nt(l, i);
179
- a.push(u);
172
+ const o = [], s = [];
173
+ n(l).forEach((a) => {
174
+ let e;
175
+ if (i.forEach((f) => {
176
+ a.field === f.field && (e = f), f.defaultValue && f.field && o.push(f.field);
177
+ }), e !== void 0 && a.field === e.field) {
178
+ const f = ot(a, e);
179
+ s.push(f);
180
180
  } else
181
- a.push(l);
182
- }), g(a, r), y.value = at(a, "field");
181
+ s.push(a);
182
+ }), x(s, o), v.value = ft(s, "field");
183
183
  }
184
- function g(t, e, s = !0) {
185
- if (V(e) && e?.length === 0)
184
+ function x(t, i, r = !0) {
185
+ if (C(i) && i?.length === 0)
186
186
  return;
187
- let r = [];
188
- m(t) && r.push(t), V(t) && (r = [...t]);
189
- const a = {}, l = C();
190
- r.forEach((i) => {
191
- i.type !== j.Divider && Reflect.has(i, "field") && i.field && !J(i.defaultValue) && (!(i.field in l) || J(l[i.field]) || st(l[i.field])) && (a[i.field] = i.defaultValue);
192
- }), lt(a) || q(a, s);
187
+ let o = [];
188
+ j(t) && o.push(t), C(t) && (o = [...t]);
189
+ const s = {}, a = _();
190
+ o.forEach((e) => {
191
+ e.type !== T.Divider && Reflect.has(e, "field") && e.field && !J(e.defaultValue) && (!(e.field in a) || J(a[e.field]) || at(a[e.field])) && (s[e.field] = e.defaultValue);
192
+ }), ct(s) || q(s, r);
193
193
  }
194
- function C(t = !1) {
195
- if (!n(c)) return {};
196
- const s = O(S(n(o)));
194
+ function _(t = !1) {
195
+ if (!n(u)) return {};
196
+ const r = V(I(n(c)));
197
197
  if (t)
198
- return s;
199
- const r = n(f).filter((l) => _(l, n(o))).map((l) => l.field).filter(Boolean), a = {};
200
- return r.forEach((l) => {
201
- l in s && (a[l] = s[l]);
202
- }), a;
198
+ return r;
199
+ const o = n(l).filter((d) => L(d, n(c))).map((d) => d.field).filter(Boolean), s = {};
200
+ o.forEach((d) => {
201
+ d in r && (s[d] = r[d]);
202
+ });
203
+ const a = n(l), e = {};
204
+ o.forEach((d) => {
205
+ if (d in s) {
206
+ const m = a.find((D) => D.field === d);
207
+ let w = s[d];
208
+ m?.formatter && b(m.formatter) && (w = m.formatter(
209
+ w,
210
+ d,
211
+ s,
212
+ m
213
+ )), e[d] = w;
214
+ }
215
+ });
216
+ const { formatter: f } = n(F);
217
+ return f && b(f) ? f(e) : e;
203
218
  }
204
- function R(t) {
205
- return n(c) ? S(n(o))[t] : {};
219
+ function R(t, i, r) {
220
+ const s = n(l).find((a) => a.field === t);
221
+ return s?.formatter && b(s.formatter) ? s.formatter(i, t, r, s) : i;
206
222
  }
207
223
  function M(t) {
208
- return n(f).some((e) => e.field === t ? ut(e.type) : !1);
224
+ if (!n(u)) return {};
225
+ if (!(t in n(c)))
226
+ return {};
227
+ const r = V(I(n(c))), o = r[t];
228
+ return R(t, o, r);
229
+ }
230
+ function tt(t) {
231
+ return n(l).some((i) => i.field === t ? ht(i.type) : !1);
209
232
  }
210
233
  async function $(t) {
211
- return t || (t = n(f).filter((s) => _(s, n(o))).map((s) => s.field).filter(Boolean)), n(c)?.validateField(t);
234
+ return t || (t = n(l).filter((r) => L(r, n(c))).map((r) => r.field).filter(Boolean)), n(u)?.validateField(t);
212
235
  }
213
- async function P(t) {
214
- return t || (t = n(f).filter((s) => _(s, n(o))).map((s) => s.field).filter(Boolean)), await n(c)?.validate(t, () => {
236
+ async function U(t) {
237
+ return t || (t = n(l).filter((r) => L(r, n(c))).map((r) => r.field).filter(Boolean)), await n(u)?.validate(t, () => {
215
238
  });
216
239
  }
217
- async function D(t) {
218
- await n(c)?.clearValidate(t);
240
+ async function O(t) {
241
+ await n(u)?.clearValidate(t);
219
242
  }
220
- async function tt(t, e) {
221
- await D(t), await N([{ field: t, itemProps: { error: e } }]);
243
+ async function et(t, i) {
244
+ await O(t), await N([{ field: t, itemProps: { error: i } }]);
222
245
  }
223
- async function et(t, e) {
224
- await n(c)?.scrollToField(t, e);
246
+ async function it(t, i) {
247
+ await n(u)?.scrollToField(t, i);
225
248
  }
226
- async function U(t) {
227
- const { autoCleanErrorMessage: e, watchDataIsChange: s } = n(v);
228
- t && t.preventDefault(), e && await D();
229
- const { submitFunc: r, beforeSubmitFunc: a } = n(v);
230
- if (a && A(a) && await a(), r && A(r)) {
231
- await r();
249
+ async function z(t) {
250
+ const { autoCleanErrorMessage: i, watchDataIsChange: r } = n(F);
251
+ t && t.preventDefault(), i && await O();
252
+ const { submitFunc: o, beforeSubmitFunc: s } = n(F);
253
+ if (s && b(s) && await s(), o && b(o)) {
254
+ await o();
232
255
  return;
233
256
  }
234
- if (n(c))
257
+ if (n(u))
235
258
  try {
236
- if (!await P())
259
+ if (!await U())
237
260
  return;
238
- const u = C();
239
- if (s) {
240
- const b = ft(T.value, u), I = rt(T.value, u);
241
- p("submit", u, !b, I);
261
+ const f = _();
262
+ if (r) {
263
+ const d = ut(S.value, f), m = st(S.value, f);
264
+ p("submit", f, !d, m);
242
265
  } else
243
- p("submit", u);
244
- } catch (i) {
245
- if (i?.outOfDate === !1 && i?.errorFields)
266
+ p("submit", f);
267
+ } catch (e) {
268
+ if (e?.outOfDate === !1 && e?.errorFields)
246
269
  return;
247
- throw new Error(i.message);
270
+ throw new Error(e.message);
248
271
  }
249
272
  }
273
+ function nt() {
274
+ const t = V(I(n(c))), i = n(l), r = {};
275
+ Object.keys(t).forEach((s) => {
276
+ const a = i.find((f) => f.field === s);
277
+ let e = t[s];
278
+ a?.formatter && b(a.formatter) && (e = a.formatter(e, s, t, a)), r[s] = e;
279
+ });
280
+ const { formatter: o } = n(F);
281
+ return o && b(o) ? o(r) : r;
282
+ }
250
283
  return {
251
- handleSubmit: U,
252
- clearValidate: D,
253
- validate: P,
284
+ handleSubmit: z,
285
+ clearValidate: O,
286
+ validate: U,
254
287
  validateField: $,
255
- getFieldsValue: C,
288
+ getFieldsValue: _,
256
289
  updateSchema: N,
257
290
  resetSchema: k,
258
291
  appendSchemaByField: K,
259
292
  removeSchemaByField: Z,
260
293
  resetFields: Y,
261
294
  setFieldsValue: q,
262
- scrollToField: et,
263
- getFieldValue: R,
264
- setFormItemError: tt
295
+ scrollToField: it,
296
+ getFieldValue: M,
297
+ setFormItemError: et,
298
+ getFormattedFormModel: nt
265
299
  };
266
300
  }
267
301
  export {
268
- Ot as useFormEvents
302
+ Ct as useFormEvents
269
303
  };
@@ -68,7 +68,7 @@ export declare const VftSwitch: import("vft/es/utils").SFCWithInstall<import("vu
68
68
  default: boolean;
69
69
  };
70
70
  beforeChange: {
71
- type: import("vue").PropType<Function>;
71
+ type: import("vue").PropType<() => Promise<boolean> | boolean>;
72
72
  };
73
73
  }>, {
74
74
  focus: () => void;
@@ -147,7 +147,7 @@ export declare const VftSwitch: import("vft/es/utils").SFCWithInstall<import("vu
147
147
  default: boolean;
148
148
  };
149
149
  beforeChange: {
150
- type: import("vue").PropType<Function>;
150
+ type: import("vue").PropType<() => Promise<boolean> | boolean>;
151
151
  };
152
152
  }>> & Readonly<{
153
153
  onInput?: ((...args: any[]) => any) | undefined;
@@ -1,25 +1,46 @@
1
1
  import type { IconProps } from 'vft/es/components/icon';
2
2
  import type { ComponentSize } from 'vft/es/constants';
3
3
  export interface SwitchProps {
4
+ /** 绑定值,必须等于 `active-value` 或 `inactive-value`,默认为 `boolean` 类型 */
4
5
  modelValue?: boolean | string | number;
6
+ /** 绑定值(非受控模式) */
5
7
  value?: boolean | string | number;
8
+ /** 是否禁用 */
6
9
  disabled?: boolean;
10
+ /** switch 的宽度 */
7
11
  width?: string | number;
12
+ /** 无论图标或文本是否显示在点内,只会呈现文本的第一个字符 */
8
13
  inlinePrompt?: boolean;
14
+ /** switch 状态为 `on` 时所显示图标,设置此项会忽略 `active-text` */
9
15
  activeIcon?: IconProps | string;
16
+ /** switch 状态为 `off` 时所显示图标,设置此项会忽略 `inactive-text` */
10
17
  inactiveIcon?: IconProps | string;
18
+ /** switch 打开时的文字描述 */
11
19
  activeText?: string;
20
+ /** switch 的状态为 `off` 时的文字描述 */
12
21
  inactiveText?: string;
22
+ /** 当在 `on` 状态时的背景颜色(已废弃,请使用 CSS var `--vft-switch-on-color`) */
13
23
  activeColor?: string;
24
+ /** `off` 状态时的背景颜色(已废弃,使用 CSS var `--vft-switch-off-color`) */
14
25
  inactiveColor?: string;
26
+ /** 开关的边框颜色(已废弃,使用 CSS var `--vft-switch-border-color`) */
15
27
  borderColor?: string;
28
+ /** switch 状态为 `on` 时的值 */
16
29
  activeValue?: boolean | string | number;
30
+ /** switch 的状态为 `off` 时的值 */
17
31
  inactiveValue?: boolean | string | number;
32
+ /** switch 对应的 name 属性 */
18
33
  name?: string;
34
+ /** 改变 switch 状态时是否触发表单的校验 */
19
35
  validateEvent?: boolean;
36
+ /** id for input */
20
37
  id?: string;
38
+ /** 是否显示加载中 */
21
39
  loading?: boolean;
22
- beforeChange?: Function;
40
+ /** switch 状态改变前的钩子,返回 `false` 或者返回 `Promise` 且被 reject 则停止切换 */
41
+ beforeChange?: () => Promise<boolean> | boolean;
42
+ /** switch 的大小 */
23
43
  size?: ComponentSize;
44
+ /** tabindex for input */
24
45
  tabindex?: string | number;
25
46
  }