@aplus-frontend/ui 0.1.32 → 0.1.34
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.
- package/es/src/ap-form/ap-form-item.vue.d.ts +1 -1
- package/es/src/ap-form/ap-form-item.vue.mjs +68 -62
- package/es/src/ap-form/ap-form-list.vue.mjs +23 -21
- package/es/src/ap-form/ap-form.vue.d.ts +3 -1
- package/es/src/ap-form/ap-form.vue2.mjs +130 -80
- package/es/src/ap-form/interface.d.ts +51 -1
- package/es/src/ap-form/items/checkbox/index.vue.mjs +6 -5
- package/es/src/ap-form/items/date/index.vue.mjs +10 -9
- package/es/src/ap-form/items/date-range/index.vue.mjs +8 -7
- package/es/src/ap-form/items/number/index.vue.mjs +12 -11
- package/es/src/ap-form/items/radio/index.vue.mjs +5 -4
- package/es/src/ap-form/items/select/index.vue.mjs +1 -0
- package/es/src/ap-form/items/switch/index.vue.mjs +10 -9
- package/es/src/ap-form/items/text/index.vue2.mjs +1 -0
- package/es/src/ap-form/items/text/password.vue.mjs +1 -0
- package/es/src/ap-form/items/text-area/index.vue.mjs +7 -6
- package/es/src/ap-form/modal-form/index.vue.d.ts +7 -3
- package/es/src/ap-form/search-form/index.vue.d.ts +7 -3
- package/es/src/ap-form/utils/get.d.ts +1 -0
- package/es/src/ap-form/utils/get.mjs +12 -0
- package/es/src/ap-form/utils/set.d.ts +6 -0
- package/es/src/ap-form/utils/set.mjs +41 -0
- package/es/src/ap-list/index.vue.d.ts +3 -0
- package/es/src/ap-list/index.vue.mjs +51 -49
- package/es/src/ap-table/ap-table.vue.d.ts +4 -1
- package/es/src/ap-table/ap-table.vue.mjs +65 -59
- package/es/src/ap-table/components/setting/select-group/index.vue2.mjs +8 -8
- package/es/src/ap-table/components/setting/tree-select/index.vue2.mjs +14 -11
- package/es/src/ap-table/components/setting/utils.mjs +29 -29
- package/es/src/ap-table/constants.d.ts +121 -1
- package/es/src/ap-table/interface.d.ts +6 -1
- package/es/src/ap-table/utils.d.ts +121 -1
- package/es/src/business/ap-card/ApCard.vue2.mjs +31 -26
- package/es/src/business/ap-expand-alert/ApExpandAlert.vue.d.ts +30 -100
- package/es/src/business/ap-expand-alert/ApExpandAlert.vue2.mjs +104 -64
- package/es/src/business/ap-expand-alert/interface.d.ts +24 -6
- package/es/src/business/ap-expand-alert/style.css +9 -0
- package/es/src/business/ap-title/style.css +4 -4
- package/es/src/business/hooks/usePageListApTable.d.ts +2 -0
- package/es/src/business/index.d.ts +53 -187
- package/es/src/check-card/group.vue.d.ts +7 -1
- package/es/src/check-card/group.vue.mjs +26 -22
- package/es/src/check-card/index.vue.d.ts +5 -2
- package/es/src/check-card/index.vue2.mjs +69 -60
- package/es/src/check-card/interface.d.ts +12 -0
- package/es/src/check-card/style/index.css +9 -5
- package/es/src/locale/lang/en.mjs +4 -0
- package/es/src/locale/lang/zh-cn.mjs +4 -0
- package/es/src/theme/ap-expand-alert/ap-expand-alert.css +9 -0
- package/es/src/theme/ap-title/ap-title.css +4 -4
- package/es/src/theme/check-card/index.css +9 -5
- package/lib/src/ap-form/ap-form-item.vue.d.ts +1 -1
- package/lib/src/ap-form/ap-form-item.vue.js +1 -1
- package/lib/src/ap-form/ap-form-list.vue.js +1 -1
- package/lib/src/ap-form/ap-form.vue.d.ts +3 -1
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-form/interface.d.ts +51 -1
- package/lib/src/ap-form/items/checkbox/index.vue.js +1 -1
- package/lib/src/ap-form/items/date/index.vue.js +1 -1
- package/lib/src/ap-form/items/date-range/index.vue.js +1 -1
- package/lib/src/ap-form/items/number/index.vue.js +1 -1
- package/lib/src/ap-form/items/radio/index.vue.js +1 -1
- package/lib/src/ap-form/items/select/index.vue.js +1 -1
- package/lib/src/ap-form/items/switch/index.vue.js +1 -1
- package/lib/src/ap-form/items/text/index.vue2.js +1 -1
- package/lib/src/ap-form/items/text/password.vue.js +1 -1
- package/lib/src/ap-form/items/text-area/index.vue.js +1 -1
- package/lib/src/ap-form/modal-form/index.vue.d.ts +7 -3
- package/lib/src/ap-form/search-form/index.vue.d.ts +7 -3
- package/lib/src/ap-form/utils/get.d.ts +1 -0
- package/lib/src/ap-form/utils/get.js +1 -0
- package/lib/src/ap-form/utils/set.d.ts +6 -0
- package/lib/src/ap-form/utils/set.js +1 -0
- package/lib/src/ap-list/index.vue.d.ts +3 -0
- package/lib/src/ap-list/index.vue.js +1 -1
- package/lib/src/ap-table/ap-table.vue.d.ts +4 -1
- package/lib/src/ap-table/ap-table.vue.js +1 -1
- package/lib/src/ap-table/components/setting/select-group/index.vue2.js +1 -1
- package/lib/src/ap-table/components/setting/tree-select/index.vue2.js +1 -1
- package/lib/src/ap-table/components/setting/utils.js +1 -1
- package/lib/src/ap-table/constants.d.ts +121 -1
- package/lib/src/ap-table/interface.d.ts +6 -1
- package/lib/src/ap-table/utils.d.ts +121 -1
- package/lib/src/business/ap-card/ApCard.vue2.js +1 -1
- package/lib/src/business/ap-expand-alert/ApExpandAlert.vue.d.ts +30 -100
- package/lib/src/business/ap-expand-alert/ApExpandAlert.vue2.js +1 -1
- package/lib/src/business/ap-expand-alert/interface.d.ts +24 -6
- package/lib/src/business/ap-expand-alert/style.css +9 -0
- package/lib/src/business/ap-title/style.css +4 -4
- package/lib/src/business/hooks/usePageListApTable.d.ts +2 -0
- package/lib/src/business/index.d.ts +53 -187
- package/lib/src/check-card/group.vue.d.ts +7 -1
- package/lib/src/check-card/group.vue.js +1 -1
- package/lib/src/check-card/index.vue.d.ts +5 -2
- package/lib/src/check-card/index.vue2.js +1 -1
- package/lib/src/check-card/interface.d.ts +12 -0
- package/lib/src/check-card/style/index.css +9 -5
- package/lib/src/locale/lang/en.js +1 -1
- package/lib/src/locale/lang/zh-cn.js +1 -1
- package/lib/src/theme/ap-expand-alert/ap-expand-alert.css +9 -0
- package/lib/src/theme/ap-title/ap-title.css +4 -4
- package/lib/src/theme/check-card/index.css +9 -5
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ declare function onFieldBlur(): void;
|
|
|
9
9
|
declare function onFieldChange(): void;
|
|
10
10
|
declare function clearValidate(): void;
|
|
11
11
|
declare function resetField(): void;
|
|
12
|
-
declare function getFieldValue(): any;
|
|
12
|
+
declare function getFieldValue(shouldFormat?: boolean): any;
|
|
13
13
|
declare function __VLS_template(): {
|
|
14
14
|
slots: Readonly<ApFormItemSlots> & ApFormItemSlots;
|
|
15
15
|
refs: {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { useToken as
|
|
4
|
-
import { isFunction as
|
|
1
|
+
import { defineComponent as j, useSlots as q, ref as d, onMounted as E, computed as B, unref as t, watch as K, cloneVNode as Q, openBlock as V, createBlock as g, mergeProps as U, createSlots as G, withCtx as i, resolveDynamicComponent as H, createCommentVNode as J, createElementVNode as C, normalizeClass as M, createVNode as k, normalizeStyle as W, toDisplayString as X, renderList as Y, renderSlot as Z, normalizeProps as ee, guardReactiveProps as oe } from "vue";
|
|
2
|
+
import { Form as te, Tooltip as le } from "ant-design-vue";
|
|
3
|
+
import { useToken as re } from "ant-design-vue/es/theme/internal";
|
|
4
|
+
import { isFunction as N, cloneDeep as ae, isArray as ne, omit as P } from "lodash-unified";
|
|
5
5
|
import { apFormItemColPropKeys as ie } from "./constant.mjs";
|
|
6
6
|
import { QuestionCircleOutlined as ue } from "@ant-design/icons-vue";
|
|
7
7
|
import "../config-provider/index.mjs";
|
|
8
8
|
import { useInjectForm as se } from "./context.mjs";
|
|
9
9
|
import "./style/ap-form-item.css";
|
|
10
|
-
import { isPromise as
|
|
11
|
-
import { useNamespace as
|
|
12
|
-
const
|
|
10
|
+
import { isPromise as me } from "@fruits-chain/utils";
|
|
11
|
+
import { useNamespace as fe } from "../config-provider/hooks/use-namespace.mjs";
|
|
12
|
+
const de = ["title"], ke = /* @__PURE__ */ j({
|
|
13
13
|
name: "ApFormItem",
|
|
14
14
|
__name: "ap-form-item",
|
|
15
15
|
props: {
|
|
@@ -50,103 +50,109 @@ const fe = ["title"], ke = /* @__PURE__ */ $({
|
|
|
50
50
|
bordered: { type: Boolean, default: !1 },
|
|
51
51
|
valuePropName: { default: "value" },
|
|
52
52
|
initialValue: {},
|
|
53
|
-
_signal: {}
|
|
53
|
+
_signal: {},
|
|
54
|
+
transform: {}
|
|
54
55
|
},
|
|
55
|
-
setup(
|
|
56
|
+
setup(S, { expose: w }) {
|
|
56
57
|
var b, F;
|
|
57
|
-
const o =
|
|
58
|
-
|
|
59
|
-
let e =
|
|
60
|
-
|
|
58
|
+
const o = S, r = q(), { model: u, updateModel: s, internalInstance: m } = se(), { m: p, b: x } = fe("ap-form-item"), f = d(!1), n = d(), [, I] = re();
|
|
59
|
+
E(async () => {
|
|
60
|
+
let e = N(o.initialValue) ? o.initialValue() : o.initialValue;
|
|
61
|
+
me(e) && (e = await e), m == null || m.registerField({
|
|
61
62
|
name: o.name,
|
|
62
|
-
initialValue:
|
|
63
|
+
initialValue: ae(e),
|
|
64
|
+
transform: o.transform
|
|
63
65
|
});
|
|
64
66
|
});
|
|
65
|
-
const c = B(() => o.name ? ne(o.name) ? o.name.reduce((e,
|
|
66
|
-
|
|
67
|
+
const c = B(() => o.name ? ne(o.name) ? o.name.reduce((e, l) => e == null ? void 0 : e[l], t(u)) : u == null ? void 0 : u.value[o.name] : null), v = d((F = (b = r.default) == null ? void 0 : b.call(r)) == null ? void 0 : F[0]);
|
|
68
|
+
K(
|
|
67
69
|
() => {
|
|
68
70
|
var e;
|
|
69
|
-
return (e =
|
|
71
|
+
return (e = r.default) == null ? void 0 : e.call(r);
|
|
70
72
|
},
|
|
71
73
|
(e) => {
|
|
72
74
|
v.value = e == null ? void 0 : e[0];
|
|
73
75
|
}
|
|
74
76
|
);
|
|
75
|
-
function
|
|
77
|
+
function _(e) {
|
|
76
78
|
s == null || s(o.name, e);
|
|
77
79
|
}
|
|
78
|
-
function _() {
|
|
79
|
-
m.value = !0;
|
|
80
|
-
}
|
|
81
80
|
function z() {
|
|
82
|
-
|
|
81
|
+
f.value = !0;
|
|
82
|
+
}
|
|
83
|
+
function A() {
|
|
84
|
+
f.value = !1;
|
|
83
85
|
}
|
|
84
86
|
const y = B(() => {
|
|
85
|
-
var
|
|
87
|
+
var l, a;
|
|
86
88
|
if (!o.name)
|
|
87
|
-
return (
|
|
88
|
-
const e =
|
|
89
|
-
return e ?
|
|
90
|
-
[o.valuePropName]:
|
|
91
|
-
[`onUpdate:${o.valuePropName}`]:
|
|
92
|
-
bordered: o.bordered ? !1 : (
|
|
93
|
-
onFocus:
|
|
94
|
-
onBlur:
|
|
89
|
+
return (l = r.default()) == null ? void 0 : l[0];
|
|
90
|
+
const e = t(v);
|
|
91
|
+
return e ? Q(e, {
|
|
92
|
+
[o.valuePropName]: t(c),
|
|
93
|
+
[`onUpdate:${o.valuePropName}`]: _,
|
|
94
|
+
bordered: o.bordered ? !1 : (a = e == null ? void 0 : e.props) == null ? void 0 : a.bordered,
|
|
95
|
+
onFocus: z,
|
|
96
|
+
onBlur: A
|
|
95
97
|
}) : null;
|
|
96
98
|
});
|
|
97
|
-
function A() {
|
|
98
|
-
var e;
|
|
99
|
-
(e = a.value) == null || e.onFieldBlur();
|
|
100
|
-
}
|
|
101
99
|
function D() {
|
|
102
100
|
var e;
|
|
103
|
-
(e =
|
|
101
|
+
(e = n.value) == null || e.onFieldBlur();
|
|
104
102
|
}
|
|
105
103
|
function R() {
|
|
106
104
|
var e;
|
|
107
|
-
(e =
|
|
105
|
+
(e = n.value) == null || e.onFieldChange();
|
|
108
106
|
}
|
|
109
107
|
function T() {
|
|
110
108
|
var e;
|
|
111
|
-
(e =
|
|
109
|
+
(e = n.value) == null || e.clearValidate();
|
|
112
110
|
}
|
|
113
111
|
function L() {
|
|
114
|
-
|
|
112
|
+
var e;
|
|
113
|
+
(e = n.value) == null || e.resetField();
|
|
114
|
+
}
|
|
115
|
+
function O(e = !1) {
|
|
116
|
+
const l = t(c);
|
|
117
|
+
if (!e || !o.transform)
|
|
118
|
+
return l;
|
|
119
|
+
const a = N(o.transform) ? o.transform : o.transform.transformer;
|
|
120
|
+
return o.transform ? a(l) : l;
|
|
115
121
|
}
|
|
116
|
-
return
|
|
117
|
-
onFieldBlur:
|
|
118
|
-
onFieldChange:
|
|
119
|
-
clearValidate:
|
|
120
|
-
resetField:
|
|
121
|
-
getFieldValue:
|
|
122
|
-
}), (e,
|
|
122
|
+
return w({
|
|
123
|
+
onFieldBlur: D,
|
|
124
|
+
onFieldChange: R,
|
|
125
|
+
clearValidate: T,
|
|
126
|
+
resetField: L,
|
|
127
|
+
getFieldValue: O
|
|
128
|
+
}), (e, l) => (V(), g(t(te).Item, U({
|
|
123
129
|
ref_key: "formItemRef",
|
|
124
|
-
ref:
|
|
125
|
-
},
|
|
130
|
+
ref: n
|
|
131
|
+
}, t(P)(o, [...t(ie), "tooltip", "label"]), {
|
|
126
132
|
class: {
|
|
127
|
-
[
|
|
128
|
-
[
|
|
129
|
-
[
|
|
133
|
+
[t(p)("bordered")]: e.bordered,
|
|
134
|
+
[t(p)("focused")]: e.bordered && f.value,
|
|
135
|
+
[t(x)()]: !0
|
|
130
136
|
},
|
|
131
137
|
colon: e.bordered ? !1 : o.colon
|
|
132
|
-
}),
|
|
138
|
+
}), G({
|
|
133
139
|
default: i(() => [
|
|
134
|
-
y.value ? (
|
|
140
|
+
y.value ? (V(), g(H(y.value), { key: 0 })) : J("", !0)
|
|
135
141
|
]),
|
|
136
142
|
_: 2
|
|
137
143
|
}, [
|
|
138
144
|
o.tooltip ? {
|
|
139
145
|
name: "tooltip",
|
|
140
|
-
fn: i(({ class:
|
|
146
|
+
fn: i(({ class: a }) => [
|
|
141
147
|
C("span", {
|
|
142
|
-
class:
|
|
148
|
+
class: M(a)
|
|
143
149
|
}, [
|
|
144
|
-
k(
|
|
150
|
+
k(t(le), {
|
|
145
151
|
title: o.tooltip
|
|
146
152
|
}, {
|
|
147
153
|
default: i(() => [
|
|
148
|
-
k(
|
|
149
|
-
style:
|
|
154
|
+
k(t(ue), {
|
|
155
|
+
style: W({ color: t(I).colorPrimary })
|
|
150
156
|
}, null, 8, ["style"])
|
|
151
157
|
]),
|
|
152
158
|
_: 1
|
|
@@ -165,14 +171,14 @@ const fe = ["title"], ke = /* @__PURE__ */ $({
|
|
|
165
171
|
overflow: "hidden",
|
|
166
172
|
textOverflow: "ellipsis"
|
|
167
173
|
}
|
|
168
|
-
},
|
|
174
|
+
}, X(e.label), 9, de)
|
|
169
175
|
]),
|
|
170
176
|
key: "1"
|
|
171
177
|
} : void 0,
|
|
172
|
-
|
|
178
|
+
Y(t(P)(r, "default"), (a, h) => ({
|
|
173
179
|
name: h,
|
|
174
|
-
fn: i((
|
|
175
|
-
|
|
180
|
+
fn: i(($) => [
|
|
181
|
+
Z(e.$slots, h, ee(oe($ || {})))
|
|
176
182
|
])
|
|
177
183
|
}))
|
|
178
184
|
]), 1040, ["class", "colon"]));
|
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as v, onMounted as V, computed as f, unref as u, renderSlot as k } from "vue";
|
|
2
2
|
import { useInjectForm as h } from "./context.mjs";
|
|
3
|
-
import { isArray as
|
|
4
|
-
const
|
|
3
|
+
import { isArray as j } from "lodash-unified";
|
|
4
|
+
const g = /* @__PURE__ */ v({
|
|
5
5
|
name: "ApFormList",
|
|
6
6
|
__name: "ap-form-list",
|
|
7
7
|
props: {
|
|
8
8
|
name: {},
|
|
9
|
-
initialValue: {}
|
|
9
|
+
initialValue: {},
|
|
10
|
+
transform: { type: [Function, Object] }
|
|
10
11
|
},
|
|
11
12
|
setup(p) {
|
|
12
|
-
let
|
|
13
|
-
const
|
|
13
|
+
let o = 1;
|
|
14
|
+
const s = [], t = p, { model: a, updateModel: r, internalInstance: c } = h();
|
|
14
15
|
V(() => {
|
|
15
|
-
|
|
16
|
+
c == null || c.registerField({
|
|
16
17
|
name: t.name,
|
|
17
|
-
initialValue: t.initialValue
|
|
18
|
+
initialValue: t.initialValue,
|
|
19
|
+
transform: t.transform
|
|
18
20
|
});
|
|
19
21
|
});
|
|
20
|
-
const
|
|
22
|
+
const i = f(() => j(t.name) ? t.name.reduce((e, n) => e == null ? void 0 : e.value[n], a) : a == null ? void 0 : a.value[t.name]);
|
|
21
23
|
function y(e = void 0) {
|
|
22
|
-
const n =
|
|
23
|
-
|
|
24
|
+
const n = u(i) ? [...u(i), e] : [e];
|
|
25
|
+
s.push(o), o += 1, r == null || r(t.name, n);
|
|
24
26
|
}
|
|
25
27
|
function _(e) {
|
|
26
|
-
let n =
|
|
27
|
-
n = [...n.slice(0, e), ...n.slice(e + 1)],
|
|
28
|
+
let n = u(i) || [];
|
|
29
|
+
n = [...n.slice(0, e), ...n.slice(e + 1)], s.splice(e, 1), r == null || r(t.name, n);
|
|
28
30
|
}
|
|
29
31
|
const d = {
|
|
30
32
|
add: y,
|
|
31
33
|
remove: _
|
|
32
|
-
},
|
|
33
|
-
let
|
|
34
|
-
return typeof
|
|
35
|
-
key:
|
|
36
|
-
fieldName:
|
|
37
|
-
name: [t.name,
|
|
34
|
+
}, F = f(() => (u(i) || []).map((n, m) => {
|
|
35
|
+
let l = s[m];
|
|
36
|
+
return typeof l > "u" && (s[m] = o, l = o, o += 1), {
|
|
37
|
+
key: l,
|
|
38
|
+
fieldName: m,
|
|
39
|
+
name: [t.name, m],
|
|
38
40
|
value: n
|
|
39
41
|
};
|
|
40
42
|
}));
|
|
41
43
|
return (e, n) => k(e.$slots, "default", {
|
|
42
|
-
fields:
|
|
44
|
+
fields: F.value,
|
|
43
45
|
actions: d
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
49
|
export {
|
|
48
|
-
|
|
50
|
+
g as default
|
|
49
51
|
};
|
|
@@ -17,7 +17,7 @@ declare function registerWatch(callback: WatchFunc, inner: boolean): () => void;
|
|
|
17
17
|
* 注册表单项
|
|
18
18
|
* @param field
|
|
19
19
|
*/
|
|
20
|
-
declare function registerField({ initialValue, name }: RegistedFieldType): void;
|
|
20
|
+
declare function registerField({ initialValue, name, transform }: RegistedFieldType): void;
|
|
21
21
|
declare function getInternalInstance(mark: string): {
|
|
22
22
|
registerField: typeof registerField;
|
|
23
23
|
registerWatch: typeof registerWatch;
|
|
@@ -911,6 +911,8 @@ declare const __VLS_component: DefineComponent<__VLS_WithDefaults<__VLS_TypeProp
|
|
|
911
911
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
912
912
|
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
913
913
|
registerWatch: typeof registerWatch;
|
|
914
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
915
|
+
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
914
916
|
getInternalInstance: typeof getInternalInstance;
|
|
915
917
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ApFormProps>, {
|
|
916
918
|
layout: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { useProvideForm as
|
|
4
|
-
import { isArray as
|
|
5
|
-
import { INTERNAL_FORM_INSTANCE_MARK as
|
|
6
|
-
import { isDef as
|
|
7
|
-
|
|
1
|
+
import { defineComponent as D, ref as L, reactive as k, nextTick as K, toRaw as T, computed as $, openBlock as G, createBlock as H, unref as b, mergeProps as J, withCtx as Q, renderSlot as U } from "vue";
|
|
2
|
+
import { Form as X } from "ant-design-vue";
|
|
3
|
+
import { useProvideForm as Y } from "./context.mjs";
|
|
4
|
+
import { isArray as d, cloneDeep as B, isFunction as V, isPlainObject as C, omit as Z } from "lodash-unified";
|
|
5
|
+
import { INTERNAL_FORM_INSTANCE_MARK as ee } from "./constant.mjs";
|
|
6
|
+
import { isDef as _ } from "../utils/index.mjs";
|
|
7
|
+
import te from "./utils/set.mjs";
|
|
8
|
+
const ue = /* @__PURE__ */ D({
|
|
8
9
|
__name: "ap-form",
|
|
9
10
|
props: {
|
|
10
11
|
layout: { default: "horizontal" },
|
|
@@ -32,112 +33,161 @@ const Y = /* @__PURE__ */ A({
|
|
|
32
33
|
onValidate: {},
|
|
33
34
|
initialValues: {}
|
|
34
35
|
},
|
|
35
|
-
setup(
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
var
|
|
39
|
-
if (
|
|
40
|
-
let
|
|
36
|
+
setup(I, { expose: M }) {
|
|
37
|
+
const a = I;
|
|
38
|
+
function p(e, t, l = !0) {
|
|
39
|
+
var r;
|
|
40
|
+
if (d(e)) {
|
|
41
|
+
let i = s;
|
|
41
42
|
for (let u = 0; u < e.length - 1; u++)
|
|
42
|
-
e[u] in
|
|
43
|
-
|
|
43
|
+
e[u] in i || (i[e[u]] = {}), i = i[e[u]];
|
|
44
|
+
i[e[e.length - 1]] = t;
|
|
44
45
|
} else
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
l && ((
|
|
46
|
+
s[e] = t;
|
|
47
|
+
let o = d(e) ? e[0] : e;
|
|
48
|
+
l && ((r = a.onValuesChange) == null || r.call(a, { [o]: s[o] }, s)), F();
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
function O(e) {
|
|
51
|
+
var l;
|
|
52
|
+
const t = g(e, c);
|
|
53
|
+
(l = a.onFinish) == null || l.call(a, t);
|
|
54
|
+
}
|
|
55
|
+
const n = L();
|
|
56
|
+
let m = a.initialValues ? B(a.initialValues) : {}, c = {};
|
|
57
|
+
const s = k(a.initialValues || {});
|
|
58
|
+
let h = [];
|
|
59
|
+
const w = async () => {
|
|
54
60
|
var e;
|
|
55
|
-
(e =
|
|
56
|
-
Object.keys(
|
|
61
|
+
(e = n.value) == null || e.resetFields(), await K(() => {
|
|
62
|
+
Object.keys(s).forEach((t) => delete s[t]), Object.assign(s, B(m)), F();
|
|
57
63
|
});
|
|
58
|
-
},
|
|
64
|
+
}, E = (e) => {
|
|
59
65
|
var t;
|
|
60
|
-
(t =
|
|
61
|
-
},
|
|
66
|
+
(t = n.value) == null || t.clearValidate(e);
|
|
67
|
+
}, j = (e, t) => {
|
|
62
68
|
var l;
|
|
63
|
-
return (l =
|
|
64
|
-
},
|
|
69
|
+
return (l = n.value) == null ? void 0 : l.validateFields(e, t);
|
|
70
|
+
}, x = async (e, t) => {
|
|
71
|
+
var o;
|
|
72
|
+
const l = await ((o = n.value) == null ? void 0 : o.validateFields(
|
|
73
|
+
e,
|
|
74
|
+
t
|
|
75
|
+
));
|
|
76
|
+
return g(l, c);
|
|
77
|
+
}, A = (e) => {
|
|
65
78
|
var t;
|
|
66
|
-
return (t =
|
|
67
|
-
},
|
|
79
|
+
return (t = n.value) == null ? void 0 : t.getFieldsValue(e);
|
|
80
|
+
}, N = (e) => {
|
|
68
81
|
var l;
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
const t = (l = n.value) == null ? void 0 : l.getFieldsValue(e);
|
|
83
|
+
return g(t, c);
|
|
84
|
+
}, P = (e, t) => {
|
|
71
85
|
var l;
|
|
72
|
-
(l =
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
return (l = n.value) == null ? void 0 : l.validate(e, t);
|
|
87
|
+
}, S = (e, t = {}) => {
|
|
88
|
+
var l;
|
|
89
|
+
(l = n.value) == null || l.scrollToField(e, t);
|
|
90
|
+
}, W = (e) => {
|
|
91
|
+
Object.assign(s, e), F();
|
|
92
|
+
}, y = (e, t) => {
|
|
93
|
+
p(e, t), F();
|
|
77
94
|
};
|
|
78
|
-
function
|
|
79
|
-
return t || e(
|
|
80
|
-
|
|
95
|
+
function v(e, t) {
|
|
96
|
+
return t || e(T(s)), h.push(e), () => {
|
|
97
|
+
h = h.filter((l) => l !== e);
|
|
81
98
|
};
|
|
82
99
|
}
|
|
83
|
-
function
|
|
84
|
-
if (
|
|
85
|
-
if (
|
|
86
|
-
let
|
|
100
|
+
function R({ initialValue: e, name: t, transform: l }) {
|
|
101
|
+
if (_(e) && _(t))
|
|
102
|
+
if (p(t, e, !1), d(t)) {
|
|
103
|
+
let o = m;
|
|
87
104
|
for (let r = 0; r < t.length - 1; r++)
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
_(o[t[r]]) || (o[t[r]] = {}), o = o[t[r]];
|
|
106
|
+
o[t[t.length - 1]] = e;
|
|
90
107
|
} else
|
|
91
|
-
|
|
108
|
+
m[t] = e;
|
|
109
|
+
c = te(
|
|
110
|
+
c,
|
|
111
|
+
[t].flat(1),
|
|
112
|
+
l,
|
|
113
|
+
!0
|
|
114
|
+
);
|
|
92
115
|
}
|
|
93
|
-
function
|
|
94
|
-
if (e !==
|
|
116
|
+
function q(e) {
|
|
117
|
+
if (e !== ee) {
|
|
95
118
|
console.warn("getInternalInstance should only used at internal");
|
|
96
119
|
return;
|
|
97
120
|
}
|
|
98
121
|
return {
|
|
99
|
-
registerField:
|
|
100
|
-
registerWatch:
|
|
122
|
+
registerField: R,
|
|
123
|
+
registerWatch: v
|
|
101
124
|
};
|
|
102
125
|
}
|
|
103
|
-
function
|
|
104
|
-
if (
|
|
105
|
-
const e =
|
|
106
|
-
|
|
126
|
+
function F() {
|
|
127
|
+
if (h.length) {
|
|
128
|
+
const e = T(s);
|
|
129
|
+
h.forEach((t) => {
|
|
107
130
|
t(e);
|
|
108
131
|
});
|
|
109
132
|
}
|
|
110
133
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
134
|
+
function g(e, t) {
|
|
135
|
+
if (e == null)
|
|
136
|
+
return;
|
|
137
|
+
let l = d(e) ? [] : {};
|
|
138
|
+
return Object.keys(e).forEach((o) => {
|
|
139
|
+
const r = e[o], i = t[o], u = V(i) ? i : i == null ? void 0 : i.transformer, z = V(i) ? !0 : i == null ? void 0 : i.flat;
|
|
140
|
+
if (V(u)) {
|
|
141
|
+
const f = u(r);
|
|
142
|
+
z ? d(f) && d(l) ? l = [...l, ...f] : C(f) && C(l) ? l = {
|
|
143
|
+
...l,
|
|
144
|
+
...f
|
|
145
|
+
} : l[o] = f : l[o] = f;
|
|
146
|
+
} else if (C(r) || d(r)) {
|
|
147
|
+
const f = g(
|
|
148
|
+
r,
|
|
149
|
+
i
|
|
150
|
+
);
|
|
151
|
+
l[o] = f;
|
|
152
|
+
} else
|
|
153
|
+
l[o] = r;
|
|
154
|
+
}), l;
|
|
155
|
+
}
|
|
156
|
+
return Y({
|
|
157
|
+
model: $(() => s),
|
|
158
|
+
updateModel: p,
|
|
114
159
|
internalInstance: {
|
|
115
|
-
registerWatch:
|
|
116
|
-
registerField:
|
|
117
|
-
setFieldValue:
|
|
160
|
+
registerWatch: v,
|
|
161
|
+
registerField: R,
|
|
162
|
+
setFieldValue: y
|
|
118
163
|
}
|
|
119
|
-
}),
|
|
120
|
-
resetFields:
|
|
121
|
-
clearValidate:
|
|
122
|
-
validateFields:
|
|
123
|
-
getFieldsValue:
|
|
124
|
-
validate:
|
|
125
|
-
scrollToField:
|
|
126
|
-
setFieldsValue:
|
|
127
|
-
setFieldValue:
|
|
128
|
-
registerWatch:
|
|
129
|
-
|
|
130
|
-
|
|
164
|
+
}), M({
|
|
165
|
+
resetFields: w,
|
|
166
|
+
clearValidate: E,
|
|
167
|
+
validateFields: j,
|
|
168
|
+
getFieldsValue: A,
|
|
169
|
+
validate: P,
|
|
170
|
+
scrollToField: S,
|
|
171
|
+
setFieldsValue: W,
|
|
172
|
+
setFieldValue: y,
|
|
173
|
+
registerWatch: v,
|
|
174
|
+
validateFieldsReturnTransformed: x,
|
|
175
|
+
getFieldsValueTransformed: N,
|
|
176
|
+
getInternalInstance: q
|
|
177
|
+
}), (e, t) => (G(), H(b(X), J({
|
|
131
178
|
ref_key: "formRef",
|
|
132
|
-
ref:
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
|
|
179
|
+
ref: n
|
|
180
|
+
}, b(Z)(a, ["initialValues", "onValuesChange", "onFinish"]), {
|
|
181
|
+
onFinish: O,
|
|
182
|
+
model: s
|
|
183
|
+
}), {
|
|
184
|
+
default: Q(() => [
|
|
185
|
+
U(e.$slots, "default")
|
|
136
186
|
]),
|
|
137
187
|
_: 3
|
|
138
188
|
}, 16, ["model"]));
|
|
139
189
|
}
|
|
140
190
|
});
|
|
141
191
|
export {
|
|
142
|
-
|
|
192
|
+
ue as default
|
|
143
193
|
};
|
|
@@ -4,6 +4,14 @@ import { InternalNamePath, NamePath, ValidateOptions } from 'ant-design-vue/es/f
|
|
|
4
4
|
import { Recordable } from '../type';
|
|
5
5
|
import { VNode } from 'vue';
|
|
6
6
|
export type ApFormColProps = Omit<ColProps, 'prefixCls'>;
|
|
7
|
+
export type ApFormItemTransformFn = (value: any) => any;
|
|
8
|
+
export type ApFormItemTransformType = ApFormItemTransformFn | {
|
|
9
|
+
transformer: ApFormItemTransformFn;
|
|
10
|
+
/**
|
|
11
|
+
* 是否进行扁平化处理(只向上扁平化一层)
|
|
12
|
+
*/
|
|
13
|
+
flat?: boolean;
|
|
14
|
+
};
|
|
7
15
|
export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
|
|
8
16
|
/**
|
|
9
17
|
* 是否展示包含了输入框&label的border
|
|
@@ -18,6 +26,12 @@ export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
|
|
|
18
26
|
* 内部使用,请勿传入
|
|
19
27
|
*/
|
|
20
28
|
_signal?: number;
|
|
29
|
+
/**
|
|
30
|
+
* 数据转换(提交/或者手动调用时才会)
|
|
31
|
+
* @param value
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
transform?: ApFormItemTransformType;
|
|
21
35
|
};
|
|
22
36
|
export type ApFormItemGroupProps = RowProps & {
|
|
23
37
|
countPerRow?: number;
|
|
@@ -48,6 +62,19 @@ export type ApFormExpose<ModelType = any> = {
|
|
|
48
62
|
* @returns
|
|
49
63
|
*/
|
|
50
64
|
getInternalInstance: (mark: string) => ApFormInternalInstance;
|
|
65
|
+
/**
|
|
66
|
+
* 校验表单并返回转换后的数据
|
|
67
|
+
* @param nameList
|
|
68
|
+
* @param options
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* 获取表单数据并转换
|
|
74
|
+
* @param nameList
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
|
|
51
78
|
};
|
|
52
79
|
/**
|
|
53
80
|
* 被注册的表单项
|
|
@@ -55,6 +82,7 @@ export type ApFormExpose<ModelType = any> = {
|
|
|
55
82
|
export type RegistedFieldType = {
|
|
56
83
|
name: FormItemProps['name'];
|
|
57
84
|
initialValue?: any;
|
|
85
|
+
transform?: ApFormItemTransformType;
|
|
58
86
|
};
|
|
59
87
|
export type ApFormInternalInstance = {
|
|
60
88
|
/**
|
|
@@ -72,7 +100,12 @@ export type ApFormInternalInstance = {
|
|
|
72
100
|
registerField: (field: RegistedFieldType) => void;
|
|
73
101
|
} & Pick<ApFormExpose, 'setFieldValue'>;
|
|
74
102
|
export type ApFormItemExpose = FormItemExpose & {
|
|
75
|
-
|
|
103
|
+
/**
|
|
104
|
+
* 是否需要格式化(默认为false)
|
|
105
|
+
* @param shouldFormat
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
getFieldValue: (shouldFormat?: boolean) => any;
|
|
76
109
|
};
|
|
77
110
|
export type ApFormListProps = {
|
|
78
111
|
name: FormItemProps['name'];
|
|
@@ -80,6 +113,7 @@ export type ApFormListProps = {
|
|
|
80
113
|
* 设置FormList的默认值
|
|
81
114
|
*/
|
|
82
115
|
initialValue?: any[];
|
|
116
|
+
transform?: ApFormItemTransformType;
|
|
83
117
|
};
|
|
84
118
|
export type ApFormSearchFormProps = ApFormProps & {
|
|
85
119
|
collapse?: boolean;
|
|
@@ -129,3 +163,19 @@ export type ApFormItemSlots = {
|
|
|
129
163
|
export type ApFormDependencyProps = {
|
|
130
164
|
nameList: NamePath[];
|
|
131
165
|
};
|
|
166
|
+
export type ApFormSetProps = {
|
|
167
|
+
/**
|
|
168
|
+
* 需要聚合成的字段名
|
|
169
|
+
*/
|
|
170
|
+
name: NamePath;
|
|
171
|
+
/**
|
|
172
|
+
* 聚合成(数组/对象)
|
|
173
|
+
*/
|
|
174
|
+
as?: 'array' | 'object';
|
|
175
|
+
/**
|
|
176
|
+
* 转换函数(表单提交时触发)
|
|
177
|
+
* @param value
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
transform?: ApFormItemTransformType;
|
|
181
|
+
};
|