@vrojs/element-plus 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,119 +1,121 @@
|
|
|
1
|
-
import { defineComponent as z, computed as
|
|
1
|
+
import { defineComponent as z, computed as I, ref as F, watchEffect as A, useTemplateRef as O, createBlock as P, openBlock as g, unref as u, mergeProps as c, withCtx as i, createVNode as j, createElementBlock as G, renderSlot as E, Fragment as H, renderList as _, createSlots as B, resolveDynamicComponent as J } from "vue";
|
|
2
2
|
import Q from "@daysnap/banana";
|
|
3
|
-
import { isFunction as
|
|
4
|
-
import { getSlotEntries as
|
|
3
|
+
import { isFunction as d, isString as R, filterEmptyValue as W } from "@daysnap/utils";
|
|
4
|
+
import { getSlotEntries as D } from "@vrojs/base";
|
|
5
5
|
import { ElForm as X, ElRow as Y, ElCol as Z, ElFormItem as k } from "element-plus";
|
|
6
6
|
import { useLocale as ee } from "../locale/useLocale.js";
|
|
7
7
|
import { datePickerValueFormat as re } from "../utils/datePickerValueFormat.js";
|
|
8
8
|
import { defineVroElSchemaFormFieldTrigger as ae } from "./defineVroElSchemaFormFieldTrigger.js";
|
|
9
9
|
import { vroElSchemaFormProps as oe } from "./types.js";
|
|
10
10
|
import { vroElSchemaFormFieldManager as te } from "./vroElSchemaFormFieldManager.js";
|
|
11
|
-
const
|
|
11
|
+
const he = /* @__PURE__ */ z({
|
|
12
12
|
name: "VroElSchemaForm",
|
|
13
13
|
__name: "vro-el-schema-form",
|
|
14
14
|
props: oe,
|
|
15
15
|
emits: ["change-field", "input-field"],
|
|
16
|
-
setup(
|
|
17
|
-
const
|
|
16
|
+
setup($, { expose: x, emit: y }) {
|
|
17
|
+
const C = y, s = $, K = I(() => ({
|
|
18
18
|
validateOnRuleChange: !1,
|
|
19
|
-
...
|
|
20
|
-
})), { locale:
|
|
19
|
+
...s.formProps
|
|
20
|
+
})), { locale: L } = ee(), V = F({}), b = F({}), h = F({});
|
|
21
21
|
A(() => {
|
|
22
|
-
const { schema: e } =
|
|
23
|
-
h.value = {}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const { schema: e } = s;
|
|
23
|
+
h.value = {};
|
|
24
|
+
const t = {}, r = {};
|
|
25
|
+
Object.entries(e).forEach(([o, a]) => {
|
|
26
|
+
let { hidden: l, value: n, rules: m, is: p } = a;
|
|
27
|
+
d(l) && (l = l(n, a, e)), p || (l = !0), l || (r[o] = n, h.value[o] = a), d(m) && (m = m(n, a, e)), t[o] = m;
|
|
28
|
+
}), Object.assign(b.value, r), Object.assign(V.value, t);
|
|
27
29
|
});
|
|
28
|
-
const
|
|
29
|
-
let { props:
|
|
30
|
-
if (R(
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
let
|
|
34
|
-
R(
|
|
30
|
+
const w = I(() => Object.entries(h.value).reduce((e, [t, r]) => {
|
|
31
|
+
let { props: o = {}, is: a, options: l, labelKey: n, valueKey: m } = r;
|
|
32
|
+
if (R(a)) {
|
|
33
|
+
const p = te.get(a);
|
|
34
|
+
if (p) {
|
|
35
|
+
let S = {};
|
|
36
|
+
R(a) && (S = L.value.el.schemaForm[a]), a === "ElDatePicker" && (o.valueFormat = re[o?.type ?? "date"]), a = p.is, o = Object.assign(
|
|
35
37
|
{},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
W({ options:
|
|
39
|
-
|
|
40
|
-
),
|
|
38
|
+
p.props,
|
|
39
|
+
S,
|
|
40
|
+
W({ options: l, labelKey: n, valueKey: m }),
|
|
41
|
+
o
|
|
42
|
+
), o.disabled && (o.placeholder = "-", a === "ElDatePicker" && (o.startPlaceholder = "-", o.endPlaceholder = "-"));
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
|
-
return e[t] = { is:
|
|
44
|
-
}, {})),
|
|
45
|
-
|
|
45
|
+
return e[t] = { is: a, props: o }, e;
|
|
46
|
+
}, {})), M = async (e, t) => {
|
|
47
|
+
C("change-field", { key: e, value: t }), await s.schema[e]?.onChange?.(t, s.schema[e], s.schema);
|
|
46
48
|
}, T = async (e, t) => {
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
const e =
|
|
50
|
-
await Promise.all([
|
|
51
|
-
},
|
|
52
|
-
const e =
|
|
49
|
+
C("input-field", { key: e, value: t }), await s.schema[e]?.onInput?.(t, s.schema[e], s.schema);
|
|
50
|
+
}, v = O("refComponents"), f = O("refForm"), U = async () => {
|
|
51
|
+
const e = v.value?.filter((t) => d(t.validate)) ?? [];
|
|
52
|
+
await Promise.all([f.value, ...e].map((t) => t?.validate()));
|
|
53
|
+
}, N = async () => {
|
|
54
|
+
const e = v.value?.filter((r) => d(r.extractValues)) ?? [], t = await Promise.all(
|
|
53
55
|
e.map((r) => r.extractValues())
|
|
54
56
|
);
|
|
55
|
-
return t.push(Q.extract(
|
|
56
|
-
},
|
|
57
|
-
const t =
|
|
57
|
+
return t.push(Q.extract(s.schema)), t.filter(Boolean).reduce((r, o) => ({ ...r, ...o }), {});
|
|
58
|
+
}, q = ae(async (e) => {
|
|
59
|
+
const t = v.value?.filter((r) => d(r.trigger)) ?? [];
|
|
58
60
|
await Promise.all(t.map((r) => r.trigger(e)));
|
|
59
61
|
});
|
|
60
|
-
return
|
|
62
|
+
return x({
|
|
61
63
|
get form() {
|
|
62
|
-
return
|
|
64
|
+
return f.value;
|
|
63
65
|
},
|
|
64
66
|
validate: U,
|
|
65
|
-
resetFields: () =>
|
|
66
|
-
trigger:
|
|
67
|
-
extractValues:
|
|
68
|
-
validateField: async (e) =>
|
|
69
|
-
}), (e, t) => (
|
|
67
|
+
resetFields: () => f.value?.resetFields(),
|
|
68
|
+
trigger: q,
|
|
69
|
+
extractValues: N,
|
|
70
|
+
validateField: async (e) => f.value?.validateField(e)
|
|
71
|
+
}), (e, t) => (g(), P(u(X), c(K.value, {
|
|
70
72
|
ref_key: "refForm",
|
|
71
|
-
ref:
|
|
73
|
+
ref: f,
|
|
72
74
|
class: "vro-el-schema-form",
|
|
73
|
-
model:
|
|
74
|
-
rules:
|
|
75
|
+
model: b.value,
|
|
76
|
+
rules: V.value
|
|
75
77
|
}), {
|
|
76
|
-
default:
|
|
77
|
-
|
|
78
|
-
default:
|
|
79
|
-
(
|
|
80
|
-
default:
|
|
81
|
-
|
|
78
|
+
default: i(() => [
|
|
79
|
+
j(u(Y), c({ gutter: 16 }, e.rowProps), {
|
|
80
|
+
default: i(() => [
|
|
81
|
+
(g(!0), G(H, null, _(h.value, (r, o) => (g(), P(u(Z), c({ key: o }, { ref_for: !0 }, { ...e.colProps, ...r.colProps }), {
|
|
82
|
+
default: i(() => [
|
|
83
|
+
j(u(k), c({
|
|
82
84
|
label: r.label,
|
|
83
|
-
prop:
|
|
84
|
-
}, { ref_for: !0 }, { ...e.formItemProps, ...r.formItemProps }),
|
|
85
|
-
default:
|
|
86
|
-
(
|
|
85
|
+
prop: o
|
|
86
|
+
}, { ref_for: !0 }, { ...e.formItemProps, ...r.formItemProps }), B({
|
|
87
|
+
default: i(() => [
|
|
88
|
+
(g(), P(J(w.value?.[o]?.is), c({
|
|
87
89
|
modelValue: r.value,
|
|
88
|
-
"onUpdate:modelValue": (
|
|
89
|
-
}, { ref_for: !0 },
|
|
90
|
+
"onUpdate:modelValue": (a) => r.value = a
|
|
91
|
+
}, { ref_for: !0 }, w.value?.[o]?.props, {
|
|
90
92
|
ref_for: !0,
|
|
91
93
|
ref_key: "refComponents",
|
|
92
|
-
ref:
|
|
93
|
-
onChange: (
|
|
94
|
-
onInput: (
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
name:
|
|
98
|
-
fn:
|
|
99
|
-
|
|
94
|
+
ref: v,
|
|
95
|
+
onChange: (a) => M(o, a),
|
|
96
|
+
onInput: (a) => T(o, a)
|
|
97
|
+
}), B({ _: 2 }, [
|
|
98
|
+
_(u(D)(r.slots), ({ source: a, target: l }) => ({
|
|
99
|
+
name: l,
|
|
100
|
+
fn: i((n) => [
|
|
101
|
+
E(e.$slots, a, c({ ref_for: !0 }, n ?? {}, { item: r }))
|
|
100
102
|
])
|
|
101
103
|
}))
|
|
102
104
|
]), 1040, ["modelValue", "onUpdate:modelValue", "onChange", "onInput"]))
|
|
103
105
|
]),
|
|
104
106
|
_: 2
|
|
105
107
|
}, [
|
|
106
|
-
|
|
107
|
-
name:
|
|
108
|
-
fn:
|
|
109
|
-
|
|
108
|
+
_(u(D)(r.itemSlots), ({ source: a, target: l }) => ({
|
|
109
|
+
name: l,
|
|
110
|
+
fn: i((n) => [
|
|
111
|
+
E(e.$slots, a, c({ ref_for: !0 }, n ?? {}, { item: r }))
|
|
110
112
|
])
|
|
111
113
|
}))
|
|
112
114
|
]), 1040, ["label", "prop"])
|
|
113
115
|
]),
|
|
114
116
|
_: 2
|
|
115
117
|
}, 1040))), 128)),
|
|
116
|
-
|
|
118
|
+
E(e.$slots, "default")
|
|
117
119
|
]),
|
|
118
120
|
_: 3
|
|
119
121
|
}, 16)
|
|
@@ -123,5 +125,5 @@ const ve = /* @__PURE__ */ z({
|
|
|
123
125
|
}
|
|
124
126
|
});
|
|
125
127
|
export {
|
|
126
|
-
|
|
128
|
+
he as default
|
|
127
129
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vrojs/element-plus",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "vrojs ui",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": [
|
|
13
|
+
"src/**/style/*",
|
|
14
|
+
"src/**/*.css",
|
|
15
|
+
"src/**/*.scss",
|
|
13
16
|
"dist/**/style/*",
|
|
14
17
|
"dist/**/*.css"
|
|
15
18
|
],
|
|
@@ -50,8 +53,8 @@
|
|
|
50
53
|
"vite": "^7.1.12",
|
|
51
54
|
"vite-plugin-dts": "^4.5.4",
|
|
52
55
|
"vue": "^3.5.22",
|
|
53
|
-
"@vrojs/
|
|
54
|
-
"@vrojs/
|
|
56
|
+
"@vrojs/base": "0.0.3",
|
|
57
|
+
"@vrojs/use": "0.0.2"
|
|
55
58
|
},
|
|
56
59
|
"scripts": {
|
|
57
60
|
"build": "npm run clean && vite build",
|