@aplus-frontend/ui 0.0.4 → 0.0.6
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-field/date-range/index.vue.mjs +65 -58
- package/es/src/ap-field/interface.d.ts +2 -2
- package/es/src/ap-form/ap-form-item-group/index.vue.mjs +23 -21
- package/es/src/ap-form/ap-form.vue.d.ts +7 -2
- package/es/src/ap-form/ap-form.vue2.mjs +85 -52
- package/es/src/ap-form/context.d.ts +14 -0
- package/es/src/ap-form/hooks/use-watch.d.ts +7 -0
- package/es/src/ap-form/hooks/use-watch.mjs +30 -0
- package/es/src/ap-form/index.d.ts +2 -0
- package/es/src/ap-form/index.mjs +13 -11
- package/es/src/ap-form/interface.d.ts +17 -7
- package/es/src/ap-form/modal-form/index.vue.d.ts +2 -2
- package/es/src/ap-form/modal-form/index.vue.mjs +1 -1
- package/es/src/ap-form/search-form/index.vue.mjs +27 -27
- package/es/src/ap-table/ap-table.vue.d.ts +2 -0
- package/es/src/ap-table/ap-table.vue.mjs +98 -93
- package/es/src/ap-table/interface.d.ts +18 -1
- package/es/src/pro-form/helper.mjs +7 -7
- package/es/src/theme/antd-global-overwrite/admin/alert.css +3 -0
- package/es/src/theme/antd-global-overwrite/admin/index.css +3 -0
- package/es/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
- package/es/src/theme/antd-global-overwrite/aplus/index.css +3 -0
- package/es/src/utils/index.mjs +32 -32
- package/lib/src/ap-field/date-range/index.vue.js +1 -1
- package/lib/src/ap-field/interface.d.ts +2 -2
- package/lib/src/ap-form/ap-form-item-group/index.vue.js +1 -1
- package/lib/src/ap-form/ap-form.vue.d.ts +7 -2
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-form/context.d.ts +14 -0
- package/lib/src/ap-form/hooks/use-watch.d.ts +7 -0
- package/lib/src/ap-form/hooks/use-watch.js +1 -0
- package/lib/src/ap-form/index.d.ts +2 -0
- package/lib/src/ap-form/index.js +1 -1
- package/lib/src/ap-form/interface.d.ts +17 -7
- package/lib/src/ap-form/modal-form/index.vue.d.ts +2 -2
- package/lib/src/ap-form/modal-form/index.vue.js +1 -1
- package/lib/src/ap-form/search-form/index.vue.js +1 -1
- package/lib/src/ap-table/ap-table.vue.d.ts +2 -0
- package/lib/src/ap-table/ap-table.vue.js +1 -1
- package/lib/src/ap-table/interface.d.ts +18 -1
- package/lib/src/pro-form/helper.js +1 -1
- package/lib/src/theme/antd-global-overwrite/admin/alert.css +3 -0
- package/lib/src/theme/antd-global-overwrite/admin/index.css +3 -0
- package/lib/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
- package/lib/src/theme/antd-global-overwrite/aplus/index.css +3 -0
- package/lib/src/utils/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ApFieldDatePresetFormats as
|
|
1
|
+
import { defineComponent as E, computed as p, unref as t, openBlock as y, createElementBlock as k, Fragment as B, createTextVNode as O, toDisplayString as C, createVNode as F, createBlock as N, mergeProps as V, createSlots as I, renderList as j, withCtx as U, renderSlot as H, normalizeProps as z, guardReactiveProps as K } from "vue";
|
|
2
|
+
import { ApFieldDatePresetFormats as $, PRESET_FORMAT_MAP as L, PRESET_FORMAT_PICK_MAP as Y, PRESET_FORMAT_TIME_MAP as q } from "../date/constant.mjs";
|
|
3
3
|
import "../../hooks/index.mjs";
|
|
4
|
-
import { isNil as
|
|
4
|
+
import { isNil as b, omit as G, isString as s } from "lodash-unified";
|
|
5
5
|
import u from "dayjs";
|
|
6
|
-
import { DatePicker as
|
|
7
|
-
import { formatDay as
|
|
8
|
-
import { SwapRightOutlined as
|
|
9
|
-
import { omitUndefined as
|
|
10
|
-
import { useControllableValue as
|
|
11
|
-
const
|
|
6
|
+
import { DatePicker as J } from "ant-design-vue";
|
|
7
|
+
import { formatDay as f, formatValue as S } from "../date/helper.mjs";
|
|
8
|
+
import { SwapRightOutlined as Q } from "@ant-design/icons-vue";
|
|
9
|
+
import { omitUndefined as W } from "../../utils/index.mjs";
|
|
10
|
+
import { useControllableValue as X } from "../../hooks/useControllableValue.mjs";
|
|
11
|
+
const de = /* @__PURE__ */ E({
|
|
12
12
|
__name: "index",
|
|
13
13
|
props: {
|
|
14
14
|
mode: { default: "edit" },
|
|
@@ -84,26 +84,26 @@ const ie = /* @__PURE__ */ A({
|
|
|
84
84
|
onOk: {}
|
|
85
85
|
},
|
|
86
86
|
emits: ["update:value"],
|
|
87
|
-
setup(
|
|
88
|
-
const
|
|
89
|
-
() =>
|
|
90
|
-
), l =
|
|
91
|
-
() => r.value ?
|
|
92
|
-
), { value:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
), m =
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}),
|
|
103
|
-
const e =
|
|
87
|
+
setup(T, { emit: R }) {
|
|
88
|
+
const o = T, w = R, r = p(
|
|
89
|
+
() => $.indexOf(o.format) > -1
|
|
90
|
+
), l = p(
|
|
91
|
+
() => r.value ? L[o.format] : o.format
|
|
92
|
+
), { value: g, updateValue: h } = X(
|
|
93
|
+
o,
|
|
94
|
+
w
|
|
95
|
+
), m = p(() => {
|
|
96
|
+
var a, n;
|
|
97
|
+
const e = t(g);
|
|
98
|
+
return b(e) || !(e != null && e.length) ? e : [
|
|
99
|
+
u((a = t(g)) == null ? void 0 : a[0]),
|
|
100
|
+
u((n = t(g)) == null ? void 0 : n[1])
|
|
101
|
+
];
|
|
102
|
+
}), _ = p(() => t(r) ? o.picker ?? Y[o.format] : o.picker), D = p(() => {
|
|
103
|
+
const e = t(r) ? q[o.format] : {};
|
|
104
104
|
return {
|
|
105
|
-
...
|
|
106
|
-
|
|
105
|
+
...W(
|
|
106
|
+
G(o, [
|
|
107
107
|
"value",
|
|
108
108
|
"onUpdate:value",
|
|
109
109
|
"onChange",
|
|
@@ -115,46 +115,53 @@ const ie = /* @__PURE__ */ A({
|
|
|
115
115
|
...e
|
|
116
116
|
};
|
|
117
117
|
});
|
|
118
|
-
function
|
|
119
|
-
|
|
118
|
+
function M(e) {
|
|
119
|
+
if (!e) {
|
|
120
|
+
h(e);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
120
123
|
const a = s(e[0]) ? u(e[0]) : e[0], n = s(e[1]) ? u(e[1]) : e[1];
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
]) :
|
|
124
|
+
t(r) ? h([
|
|
125
|
+
f(a, t(l)),
|
|
126
|
+
f(n, t(l), !1)
|
|
127
|
+
]) : h([S(a), S(n)]);
|
|
125
128
|
}
|
|
126
|
-
function
|
|
129
|
+
function A(e) {
|
|
127
130
|
var d;
|
|
128
|
-
const a = s(e[0]) ? u(e[0]) : e[0], n = s(e[1]) ? u(e[1]) : e[1], i = e[0] ?
|
|
129
|
-
(d =
|
|
131
|
+
const a = s(e[0]) ? u(e[0]) : e[0], n = s(e[1]) ? u(e[1]) : e[1], i = e[0] ? t(r) ? f(a, t(l)) : a.valueOf() : null, c = e[1] ? t(r) ? f(n, t(l), !1) : n.valueOf() : null;
|
|
132
|
+
(d = o.onOk) == null || d.call(o, [i, c]);
|
|
130
133
|
}
|
|
131
|
-
function
|
|
132
|
-
var v;
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
function x(e, a) {
|
|
135
|
+
var v, P;
|
|
136
|
+
if (b(e)) {
|
|
137
|
+
(v = o.onChange) == null || v.call(o, e, a);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const n = s(e[0]) ? u(e[0]) : e[0], i = s(e[1]) ? u(e[1]) : e[1], c = e[0] ? t(r) ? f(n, t(l)) : n.valueOf() : null, d = e[1] ? t(r) ? f(i, t(l), !1) : i.valueOf() : null;
|
|
141
|
+
(P = o.onChange) == null || P.call(o, [c, d], a);
|
|
135
142
|
}
|
|
136
143
|
return (e, a) => {
|
|
137
144
|
var n, i;
|
|
138
|
-
return e.mode === "read" ? (y(),
|
|
139
|
-
m.value ? (y(),
|
|
140
|
-
O(
|
|
141
|
-
|
|
142
|
-
O(" " +
|
|
143
|
-
], 64)) : (y(),
|
|
144
|
-
O(
|
|
145
|
+
return e.mode === "read" ? (y(), k(B, { key: 0 }, [
|
|
146
|
+
m.value ? (y(), k(B, { key: 0 }, [
|
|
147
|
+
O(C((n = m.value[0]) == null ? void 0 : n.format(l.value)) + " ", 1),
|
|
148
|
+
F(t(Q)),
|
|
149
|
+
O(" " + C((i = m.value[1]) == null ? void 0 : i.format(l.value)), 1)
|
|
150
|
+
], 64)) : (y(), k(B, { key: 1 }, [
|
|
151
|
+
O(C(e.emptyText), 1)
|
|
145
152
|
], 64))
|
|
146
|
-
], 64)) : (y(),
|
|
153
|
+
], 64)) : (y(), N(t(J).RangePicker, V({ key: 1 }, D.value, {
|
|
147
154
|
value: m.value,
|
|
148
|
-
"onUpdate:value":
|
|
149
|
-
onChange:
|
|
150
|
-
picker:
|
|
155
|
+
"onUpdate:value": M,
|
|
156
|
+
onChange: x,
|
|
157
|
+
picker: _.value,
|
|
151
158
|
format: l.value,
|
|
152
|
-
onOk:
|
|
153
|
-
}),
|
|
154
|
-
|
|
159
|
+
onOk: A
|
|
160
|
+
}), I({ _: 2 }, [
|
|
161
|
+
j(e.$slots, (c, d) => ({
|
|
155
162
|
name: d,
|
|
156
|
-
fn:
|
|
157
|
-
|
|
163
|
+
fn: U((v) => [
|
|
164
|
+
H(e.$slots, d, z(K(v || {})))
|
|
158
165
|
])
|
|
159
166
|
}))
|
|
160
167
|
]), 1040, ["value", "picker", "format"]));
|
|
@@ -162,5 +169,5 @@ const ie = /* @__PURE__ */ A({
|
|
|
162
169
|
}
|
|
163
170
|
});
|
|
164
171
|
export {
|
|
165
|
-
|
|
172
|
+
de as default
|
|
166
173
|
};
|
|
@@ -69,9 +69,9 @@ export type ApFieldTextAreaExpose = {
|
|
|
69
69
|
};
|
|
70
70
|
export type ApFieldDateRangeProps = BasicApFieldProps<Omit<RangePickerProps, 'value' | 'onChange' | 'onPanelChange' | 'defaultValue' | 'onOk' | 'renderExtraFooter' | 'onUpdate:value' | 'mode'>> & {
|
|
71
71
|
emptyText?: string;
|
|
72
|
-
value?: RangeValue<number
|
|
72
|
+
value?: RangeValue<number> | null;
|
|
73
73
|
defaultValue?: RangeValue<number>;
|
|
74
|
-
onChange?: (ts: RangeValue<number
|
|
74
|
+
onChange?: (ts: RangeValue<number> | null, dayStr: [string, string]) => void;
|
|
75
75
|
onOk?: (ts: RangeValue<number>) => void;
|
|
76
76
|
format?: LiteralUnion<ApFormatPresetType, string>;
|
|
77
77
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isVNode as w, defineComponent as _, useSlots as k, watch as b,
|
|
2
|
-
import { Col as
|
|
3
|
-
import { pick as
|
|
4
|
-
import { apFormItemColPropKeys as
|
|
5
|
-
import { genRealChildren as
|
|
1
|
+
import { isVNode as w, defineComponent as _, useSlots as k, watch as b, onBeforeUpdate as h, shallowRef as x, computed as B, unref as p, createVNode as R, mergeProps as m, openBlock as s, createBlock as i, withCtx as S, createElementBlock as j, Fragment as v, renderList as N, resolveDynamicComponent as P } from "vue";
|
|
2
|
+
import { Col as F, Row as I } from "ant-design-vue";
|
|
3
|
+
import { pick as O } from "lodash-unified";
|
|
4
|
+
import { apFormItemColPropKeys as V } from "../constant.mjs";
|
|
5
|
+
import { genRealChildren as l, buildColSpan as A } from "./helper.mjs";
|
|
6
6
|
import "../../config-provider/index.mjs";
|
|
7
7
|
import "../style/ap-form-item-group.css";
|
|
8
|
-
import { useNamespace as
|
|
9
|
-
function
|
|
8
|
+
import { useNamespace as D } from "../../config-provider/hooks/use-namespace.mjs";
|
|
9
|
+
function E(r) {
|
|
10
10
|
return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !w(r);
|
|
11
11
|
}
|
|
12
12
|
const M = /* @__PURE__ */ _({
|
|
@@ -29,28 +29,30 @@ const M = /* @__PURE__ */ _({
|
|
|
29
29
|
},
|
|
30
30
|
setup(r) {
|
|
31
31
|
const {
|
|
32
|
-
b:
|
|
33
|
-
} =
|
|
32
|
+
b: c
|
|
33
|
+
} = D("ap-form-item-group"), {
|
|
34
34
|
countPerRow: f,
|
|
35
35
|
...d
|
|
36
|
-
} = r,
|
|
37
|
-
b(() =>
|
|
38
|
-
|
|
36
|
+
} = r, n = k();
|
|
37
|
+
b(() => n.default(), (e) => {
|
|
38
|
+
a.value = l(e);
|
|
39
|
+
}), h(() => {
|
|
40
|
+
a.value = l(n.default());
|
|
39
41
|
});
|
|
40
|
-
const
|
|
41
|
-
const t = e.props, o =
|
|
42
|
-
return R(
|
|
43
|
-
key:
|
|
42
|
+
const a = x(l(n.default())), y = B(() => p(a).map((e, u) => {
|
|
43
|
+
const t = e.props, o = O(t, V), C = o != null && o.span ? {} : A(f), g = !!(t != null && t.hidden);
|
|
44
|
+
return R(F, m({
|
|
45
|
+
key: u
|
|
44
46
|
}, C, o, {
|
|
45
|
-
class: g ?
|
|
46
|
-
}),
|
|
47
|
+
class: g ? c("col-hidden") : ""
|
|
48
|
+
}), E(e) ? e : {
|
|
47
49
|
default: () => [e]
|
|
48
50
|
});
|
|
49
51
|
}));
|
|
50
|
-
return (e,
|
|
51
|
-
class:
|
|
52
|
+
return (e, u) => (s(), i(p(I), m({
|
|
53
|
+
class: p(c)()
|
|
52
54
|
}, d), {
|
|
53
|
-
default: S(() => [(
|
|
55
|
+
default: S(() => [(s(!0), j(v, null, N(y.value, (t, o) => (s(), i(P(t), {
|
|
54
56
|
key: o
|
|
55
57
|
}))), 128))]),
|
|
56
58
|
_: 1
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { ApFormProps } from './interface';
|
|
1
|
+
import { ApFormProps, WatchFunc } from './interface';
|
|
2
2
|
import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
|
|
3
3
|
import { DefineComponent, ComponentOptionsMixin, PublicProps, ExtractPropTypes, PropType } from 'vue';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 订阅事件
|
|
7
|
+
*/
|
|
8
|
+
declare function registerWatch(callback: WatchFunc): () => void;
|
|
5
9
|
declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ApFormProps>, {
|
|
6
10
|
layout: string;
|
|
7
11
|
hideRequiredMark: boolean;
|
|
@@ -23,7 +27,8 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
23
27
|
}> | undefined;
|
|
24
28
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
25
29
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
26
|
-
setFieldValue: (key:
|
|
30
|
+
setFieldValue: (key: any, newValue: any) => void;
|
|
31
|
+
registerWatch: typeof registerWatch;
|
|
27
32
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ApFormProps>, {
|
|
28
33
|
layout: string;
|
|
29
34
|
hideRequiredMark: boolean;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { useProvideForm as
|
|
4
|
-
import { isArray as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as b, ref as k, reactive as x, computed as M, openBlock as R, createBlock as T, unref as W, mergeProps as q, withCtx as w, renderSlot as z } from "vue";
|
|
2
|
+
import { Form as A } from "ant-design-vue";
|
|
3
|
+
import { useProvideForm as E } from "./context.mjs";
|
|
4
|
+
import { isArray as y } from "lodash-unified";
|
|
5
|
+
const I = /* @__PURE__ */ b({
|
|
6
6
|
__name: "ap-form",
|
|
7
7
|
props: {
|
|
8
|
-
initialValues: {},
|
|
9
8
|
layout: { default: "horizontal" },
|
|
10
9
|
labelCol: {},
|
|
11
10
|
wrapperCol: {},
|
|
@@ -28,62 +27,96 @@ const S = /* @__PURE__ */ u({
|
|
|
28
27
|
onFieldsChange: {},
|
|
29
28
|
onFinish: {},
|
|
30
29
|
onFinishFailed: {},
|
|
31
|
-
onValidate: {}
|
|
30
|
+
onValidate: {},
|
|
31
|
+
initialValues: {}
|
|
32
32
|
},
|
|
33
|
-
setup(
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
setup(C, { expose: B }) {
|
|
34
|
+
const r = C;
|
|
35
|
+
function _(e, t) {
|
|
36
|
+
var V;
|
|
37
|
+
if (y(e)) {
|
|
38
|
+
let u = o;
|
|
39
|
+
for (let d = 0; d < e.length - 1; d++)
|
|
40
|
+
u = u[e[d]];
|
|
41
|
+
u[e[e.length - 1]] = t;
|
|
41
42
|
} else
|
|
42
|
-
o[e] =
|
|
43
|
+
o[e] = t;
|
|
44
|
+
let l = y(e) ? e[0] : e;
|
|
45
|
+
(V = r.onValuesChange) == null || V.call(r, { [l]: o[l] }, o), s();
|
|
43
46
|
}
|
|
44
|
-
const a =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
const a = k(), o = x(r.initialValues || {});
|
|
48
|
+
let i = [];
|
|
49
|
+
const f = (e) => {
|
|
50
|
+
var t;
|
|
51
|
+
(t = a.value) == null || t.resetFields(e), s();
|
|
52
|
+
}, c = (e) => {
|
|
53
|
+
var t;
|
|
54
|
+
(t = a.value) == null || t.clearValidate(e);
|
|
55
|
+
}, p = (e, t) => {
|
|
56
|
+
var l;
|
|
57
|
+
return (l = a.value) == null ? void 0 : l.validateFields(e, t);
|
|
58
|
+
}, n = (e) => {
|
|
59
|
+
var t;
|
|
60
|
+
return (t = a.value) == null ? void 0 : t.getFieldsValue(e);
|
|
61
|
+
}, h = (e, t) => {
|
|
62
|
+
var l;
|
|
63
|
+
return (l = a.value) == null ? void 0 : l.validate(e, t);
|
|
64
|
+
}, g = (e, t = {}) => {
|
|
65
|
+
var l;
|
|
66
|
+
(l = a.value) == null || l.scrollToField(e, t);
|
|
67
|
+
}, F = (e) => {
|
|
68
|
+
Object.assign(o, e), s();
|
|
69
|
+
}, m = (e, t) => {
|
|
70
|
+
o[e] = t, s();
|
|
71
|
+
};
|
|
72
|
+
function v(e) {
|
|
73
|
+
return i.push(e), () => {
|
|
74
|
+
i = i.filter((t) => t !== e);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function s() {
|
|
78
|
+
if (i.length) {
|
|
79
|
+
const e = n(!0);
|
|
80
|
+
i.forEach((t) => {
|
|
81
|
+
t(e);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return E({
|
|
86
|
+
model: M(() => o),
|
|
87
|
+
updateModel: _,
|
|
88
|
+
formInstance: {
|
|
89
|
+
resetFields: f,
|
|
90
|
+
clearValidate: c,
|
|
91
|
+
validateFields: p,
|
|
92
|
+
getFieldsValue: n,
|
|
93
|
+
validate: h,
|
|
94
|
+
scrollToField: g,
|
|
95
|
+
setFieldsValue: F,
|
|
96
|
+
setFieldValue: m,
|
|
97
|
+
registerWatch: v
|
|
75
98
|
}
|
|
76
|
-
}), (
|
|
99
|
+
}), B({
|
|
100
|
+
resetFields: f,
|
|
101
|
+
clearValidate: c,
|
|
102
|
+
validateFields: p,
|
|
103
|
+
getFieldsValue: n,
|
|
104
|
+
validate: h,
|
|
105
|
+
scrollToField: g,
|
|
106
|
+
setFieldsValue: F,
|
|
107
|
+
setFieldValue: m,
|
|
108
|
+
registerWatch: v
|
|
109
|
+
}), (e, t) => (R(), T(W(A), q({
|
|
77
110
|
ref_key: "formRef",
|
|
78
111
|
ref: a
|
|
79
|
-
},
|
|
80
|
-
default:
|
|
81
|
-
|
|
112
|
+
}, r, { model: o }), {
|
|
113
|
+
default: w(() => [
|
|
114
|
+
z(e.$slots, "default")
|
|
82
115
|
]),
|
|
83
116
|
_: 3
|
|
84
117
|
}, 16, ["model"]));
|
|
85
118
|
}
|
|
86
119
|
});
|
|
87
120
|
export {
|
|
88
|
-
|
|
121
|
+
I as default
|
|
89
122
|
};
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { NamePath } from 'ant-design-vue/es/form/interface';
|
|
2
2
|
import { ComputedRef, InjectionKey } from 'vue';
|
|
3
|
+
import { ApFormExpose } from './interface';
|
|
3
4
|
|
|
4
5
|
type ApFormContextProps<ModelType> = {
|
|
6
|
+
/**
|
|
7
|
+
* Form数据源
|
|
8
|
+
*/
|
|
5
9
|
model?: ComputedRef<ModelType>;
|
|
10
|
+
/**
|
|
11
|
+
* 更新数据源的方法
|
|
12
|
+
* @param name
|
|
13
|
+
* @param value
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
6
16
|
updateModel?: (name: NamePath, value: any) => void;
|
|
17
|
+
/**
|
|
18
|
+
* ApForm内部实例
|
|
19
|
+
*/
|
|
20
|
+
formInstance?: ApFormExpose;
|
|
7
21
|
};
|
|
8
22
|
export declare const ApFormContextKey: InjectionKey<ApFormContextProps<any>>;
|
|
9
23
|
export declare function useProvideForm<ModelType>(state: ApFormContextProps<ModelType>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NamePath } from 'ant-design-vue/es/form/interface';
|
|
2
|
+
import { ApFormExpose } from '../interface';
|
|
3
|
+
import { Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type ApFormIns = ApFormExpose;
|
|
6
|
+
declare const useWatch: <ValueType = any>(name: NamePath, form?: Ref<ApFormIns | undefined>) => Ref<ValueType | undefined>;
|
|
7
|
+
export default useWatch;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useInjectForm as l } from "../context.mjs";
|
|
2
|
+
import { ref as g, watchEffect as h } from "vue";
|
|
3
|
+
import { isArray as S } from "lodash-unified";
|
|
4
|
+
function V(t, r) {
|
|
5
|
+
return S(r) ? r.reduce((e, n) => e == null ? void 0 : e[n], t) : t == null ? void 0 : t[r];
|
|
6
|
+
}
|
|
7
|
+
function w(t) {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.stringify(t);
|
|
10
|
+
} catch {
|
|
11
|
+
return Math.random();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const M = (t, r) => {
|
|
15
|
+
const { formInstance: e } = l(), n = g();
|
|
16
|
+
let c = "";
|
|
17
|
+
return h((s) => {
|
|
18
|
+
const u = (r == null ? void 0 : r.value) || e;
|
|
19
|
+
if (!u)
|
|
20
|
+
return;
|
|
21
|
+
const o = u.registerWatch((f) => {
|
|
22
|
+
const a = V(f, t), i = w(a);
|
|
23
|
+
i !== c && (n.value = a, c = i);
|
|
24
|
+
});
|
|
25
|
+
s(o);
|
|
26
|
+
}), n;
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
M as default
|
|
30
|
+
};
|
|
@@ -4,6 +4,7 @@ import { default as ApFormItemGroup } from './ap-form-item-group/index.vue';
|
|
|
4
4
|
import { default as ApFormList } from './ap-form-list.vue';
|
|
5
5
|
import { default as ApFormSearchForm } from './search-form/index.vue';
|
|
6
6
|
import { default as ApFormModalForm } from './modal-form/index.vue';
|
|
7
|
+
import { default as useWatch } from './hooks/use-watch';
|
|
7
8
|
|
|
8
9
|
type ApFormMixedProps = typeof _ApForm & {
|
|
9
10
|
FormItem: typeof ApFormItem;
|
|
@@ -11,6 +12,7 @@ type ApFormMixedProps = typeof _ApForm & {
|
|
|
11
12
|
FormList: typeof ApFormList;
|
|
12
13
|
SearchForm: typeof ApFormSearchForm;
|
|
13
14
|
ModalForm: typeof ApFormModalForm;
|
|
15
|
+
useWatch: typeof useWatch;
|
|
14
16
|
};
|
|
15
17
|
declare const ApForm: ApFormMixedProps;
|
|
16
18
|
export * from './items';
|
package/es/src/ap-form/index.mjs
CHANGED
|
@@ -4,25 +4,27 @@ import "./ap-form-item-group/index.vue2.mjs";
|
|
|
4
4
|
import "./ap-form-list.vue2.mjs";
|
|
5
5
|
import "./search-form/index.vue2.mjs";
|
|
6
6
|
import "./modal-form/index.vue2.mjs";
|
|
7
|
+
import o from "./hooks/use-watch.mjs";
|
|
7
8
|
import "./items/index.mjs";
|
|
8
9
|
import "./interface.mjs";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
10
|
+
import r from "./ap-form.vue2.mjs";
|
|
11
|
+
import t from "./ap-form-item.vue.mjs";
|
|
11
12
|
import p from "./ap-form-item-group/index.vue.mjs";
|
|
12
13
|
import i from "./ap-form-list.vue.mjs";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
const m =
|
|
16
|
-
m.FormItem =
|
|
14
|
+
import a from "./search-form/index.vue.mjs";
|
|
15
|
+
import s from "./modal-form/index.vue.mjs";
|
|
16
|
+
const m = r;
|
|
17
|
+
m.FormItem = t;
|
|
17
18
|
m.FormItemGroup = p;
|
|
18
19
|
m.FormList = i;
|
|
19
|
-
m.SearchForm =
|
|
20
|
-
m.ModalForm =
|
|
20
|
+
m.SearchForm = a;
|
|
21
|
+
m.ModalForm = s;
|
|
22
|
+
m.useWatch = o;
|
|
21
23
|
export {
|
|
22
24
|
m as ApForm,
|
|
23
|
-
|
|
25
|
+
t as ApFormItem,
|
|
24
26
|
p as ApFormItemGroup,
|
|
25
27
|
i as ApFormList,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
s as ApFormModalForm,
|
|
29
|
+
a as ApFormSearchForm
|
|
28
30
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonProps, ColProps, FormItemProps, FormProps, ModalProps, RowProps } from 'ant-design-vue';
|
|
2
2
|
import { FormItemExpose } from 'ant-design-vue/es/form/FormItem';
|
|
3
|
-
import { NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
|
|
3
|
+
import { InternalNamePath, NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
|
|
4
|
+
import { Recordable } from '../type';
|
|
4
5
|
|
|
5
6
|
export type ApFormColProps = Omit<ColProps, 'prefixCls'>;
|
|
6
7
|
export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
|
|
@@ -13,18 +14,27 @@ export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
|
|
|
13
14
|
export type ApFormItemGroupProps = RowProps & {
|
|
14
15
|
countPerRow?: number;
|
|
15
16
|
};
|
|
16
|
-
export type ApFormProps = {
|
|
17
|
-
initialValues?:
|
|
18
|
-
|
|
17
|
+
export type ApFormProps = Omit<FormProps, 'model'> & {
|
|
18
|
+
initialValues?: Recordable;
|
|
19
|
+
/**
|
|
20
|
+
* 字段值更新时触发
|
|
21
|
+
* @param changedValues 更改的字段值
|
|
22
|
+
* @param allValues 更改后的字段值
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
onValuesChange?: (changedValues: Recordable, allValues: Recordable) => void;
|
|
26
|
+
};
|
|
27
|
+
export type WatchFunc = (values?: Recordable) => void;
|
|
19
28
|
export type ApFormExpose<ModelType = any> = {
|
|
20
29
|
setFieldsValue?: (fields: Partial<ModelType>) => void;
|
|
21
30
|
setFieldValue?: (key: keyof ModelType, value: any) => void;
|
|
22
31
|
resetFields: (name?: NamePath) => void;
|
|
23
32
|
clearValidate: (name?: NamePath) => void;
|
|
24
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType
|
|
25
|
-
getFieldsValue: (nameList?:
|
|
26
|
-
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType
|
|
33
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
|
|
34
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
|
|
35
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
|
|
27
36
|
scrollToField: (name: NamePath, options?: any) => void;
|
|
37
|
+
registerWatch: (callback: WatchFunc) => () => void;
|
|
28
38
|
};
|
|
29
39
|
export type ApFormItemExpose = FormItemExpose & {
|
|
30
40
|
getFieldValue: () => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApFormModalFormProps, ApFormSubmitterConfig } from '../interface';
|
|
2
2
|
import { VNode, DefineComponent, ComponentOptionsMixin, PublicProps, ExtractPropTypes, PropType, CSSProperties } from 'vue';
|
|
3
|
-
import { NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
|
|
3
|
+
import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
|
|
4
4
|
import { VueTypeValidableDef } from '../../../node_modules/vue-types';
|
|
5
5
|
import { LegacyButtonType, ButtonHTMLType } from 'ant-design-vue/es/button/buttonTypes';
|
|
6
6
|
import { ButtonType, ButtonShape, ButtonSize } from 'ant-design-vue/es/button';
|
|
@@ -31,7 +31,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
31
31
|
resetFields: (name?: NamePath | undefined) => void;
|
|
32
32
|
clearValidate: (name?: NamePath | undefined) => void;
|
|
33
33
|
validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<Partial<any>> | undefined;
|
|
34
|
-
getFieldsValue: (nameList?: true |
|
|
34
|
+
getFieldsValue: (nameList?: true | InternalNamePath[] | undefined) => Partial<any> | undefined;
|
|
35
35
|
validate: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<Partial<any>> | undefined;
|
|
36
36
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
37
37
|
setFieldValue: (key: string, newValue: any) => void;
|
|
@@ -17,7 +17,6 @@ function C(d) {
|
|
|
17
17
|
const xe = /* @__PURE__ */ L({
|
|
18
18
|
__name: "index",
|
|
19
19
|
props: {
|
|
20
|
-
initialValues: {},
|
|
21
20
|
layout: {
|
|
22
21
|
default: "horizontal"
|
|
23
22
|
},
|
|
@@ -59,6 +58,7 @@ const xe = /* @__PURE__ */ L({
|
|
|
59
58
|
onFieldsChange: {},
|
|
60
59
|
onFinishFailed: {},
|
|
61
60
|
onValidate: {},
|
|
61
|
+
initialValues: {},
|
|
62
62
|
open: {
|
|
63
63
|
type: Boolean,
|
|
64
64
|
default: void 0
|