y-design-ssr 0.2.0 → 0.2.2
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/libs/button/index.css +579 -1
- package/libs/button/index.mjs +111 -66
- package/libs/button/index.umd.js +203 -2
- package/libs/cell/index.css +1077 -1
- package/libs/cell/index.mjs +167 -104
- package/libs/cell/index.umd.js +300 -2
- package/libs/checkbox/index.css +1053 -1
- package/libs/checkbox/index.mjs +242 -127
- package/libs/checkbox/index.umd.js +369 -2
- package/libs/checkboxGroup/index.css +422 -1
- package/libs/checkboxGroup/index.mjs +173 -87
- package/libs/checkboxGroup/index.umd.js +265 -2
- package/libs/col/index.css +615 -1
- package/libs/col/index.mjs +246 -81
- package/libs/col/index.umd.js +305 -2
- package/libs/countdown/index.css +417 -1
- package/libs/countdown/index.mjs +179 -71
- package/libs/countdown/index.umd.js +231 -2
- package/libs/dialog/index.css +1405 -1
- package/libs/dialog/index.mjs +646 -476
- package/libs/dialog/index.umd.js +1128 -2
- package/libs/empty/index.css +457 -1
- package/libs/empty/index.mjs +91 -44
- package/libs/empty/index.umd.js +139 -2
- package/libs/form/index.css +477 -1
- package/libs/form/index.mjs +226 -126
- package/libs/form/index.umd.js +319 -2
- package/libs/formItem/index.css +477 -1
- package/libs/formItem/index.mjs +276 -126
- package/libs/formItem/index.umd.js +372 -2
- package/libs/icon/index.css +982 -1
- package/libs/icon/index.mjs +107 -58
- package/libs/icon/index.umd.js +186 -2
- package/libs/index.css +2902 -1
- package/libs/index.mjs +3785 -2344
- package/libs/index.umd.js +5509 -2
- package/libs/input/index.css +483 -1
- package/libs/input/index.mjs +183 -92
- package/libs/input/index.umd.js +274 -2
- package/libs/layout/index.css +684 -1
- package/libs/layout/index.mjs +230 -130
- package/libs/layout/index.umd.js +318 -2
- package/libs/list/index.css +440 -1
- package/libs/list/index.mjs +388 -207
- package/libs/list/index.umd.js +571 -2
- package/libs/loading/index.css +548 -1
- package/libs/loading/index.mjs +196 -118
- package/libs/loading/index.umd.js +321 -2
- package/libs/mask/index.css +426 -1
- package/libs/mask/index.mjs +131 -70
- package/libs/mask/index.umd.js +201 -2
- package/libs/popup/index.css +465 -1
- package/libs/popup/index.mjs +210 -134
- package/libs/popup/index.umd.js +358 -2
- package/libs/progress/index.css +488 -1
- package/libs/progress/index.mjs +200 -128
- package/libs/progress/index.umd.js +322 -2
- package/libs/pullrefresh/index.css +441 -1
- package/libs/pullrefresh/index.mjs +241 -111
- package/libs/pullrefresh/index.umd.js +302 -2
- package/libs/row/index.css +485 -1
- package/libs/row/index.mjs +181 -89
- package/libs/row/index.umd.js +237 -2
- package/libs/slider/index.css +558 -1
- package/libs/slider/index.mjs +356 -160
- package/libs/slider/index.umd.js +453 -2
- package/libs/stepper/index.css +489 -1
- package/libs/stepper/index.mjs +181 -101
- package/libs/stepper/index.umd.js +269 -2
- package/libs/swipe/index.css +506 -1
- package/libs/swipe/index.mjs +542 -259
- package/libs/swipe/index.umd.js +703 -2
- package/libs/swipeItem/index.css +424 -1
- package/libs/swipeItem/index.mjs +111 -52
- package/libs/swipeItem/index.umd.js +154 -2
- package/libs/switch/index.css +472 -1
- package/libs/switch/index.mjs +121 -62
- package/libs/switch/index.umd.js +200 -2
- package/libs/tab/index.mjs +131 -68
- package/libs/tab/index.umd.js +190 -1
- package/libs/tabs/index.css +514 -1
- package/libs/tabs/index.mjs +751 -410
- package/libs/tabs/index.umd.js +1020 -2
- package/libs/toast/index.css +1050 -1
- package/libs/toast/index.mjs +183 -114
- package/libs/toast/index.umd.js +306 -2
- package/libs/tooltip/index.css +514 -1
- package/libs/tooltip/index.mjs +293 -155
- package/libs/tooltip/index.umd.js +416 -2
- package/package.json +5 -4
- package/libs/button/package.json +0 -5
- package/libs/cell/package.json +0 -5
- package/libs/checkbox/package.json +0 -5
- package/libs/checkboxGroup/package.json +0 -5
- package/libs/col/package.json +0 -5
- package/libs/countdown/package.json +0 -5
- package/libs/dialog/package.json +0 -5
- package/libs/empty/package.json +0 -5
- package/libs/form/package.json +0 -5
- package/libs/formItem/package.json +0 -5
- package/libs/icon/package.json +0 -5
- package/libs/input/package.json +0 -5
- package/libs/layout/package.json +0 -5
- package/libs/list/package.json +0 -5
- package/libs/loading/package.json +0 -5
- package/libs/mask/package.json +0 -5
- package/libs/popup/package.json +0 -5
- package/libs/progress/package.json +0 -5
- package/libs/pullrefresh/package.json +0 -5
- package/libs/row/package.json +0 -5
- package/libs/slider/package.json +0 -5
- package/libs/stepper/package.json +0 -5
- package/libs/swipe/package.json +0 -5
- package/libs/swipeItem/package.json +0 -5
- package/libs/switch/package.json +0 -5
- package/libs/tab/package.json +0 -5
- package/libs/tabs/package.json +0 -5
- package/libs/toast/package.json +0 -5
- package/libs/tooltip/package.json +0 -5
package/libs/form/index.mjs
CHANGED
|
@@ -1,40 +1,91 @@
|
|
|
1
|
-
import { getCurrentInstance
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getCurrentInstance, reactive, provide, isVNode, ref, defineComponent, createVNode } from "vue";
|
|
2
|
+
const filterChildren = (children) => {
|
|
3
|
+
const vnodes = [];
|
|
4
|
+
const _filterChildren = (childrens) => {
|
|
5
|
+
if (Array.isArray(childrens)) {
|
|
6
|
+
childrens.forEach((child) => {
|
|
7
|
+
var _a;
|
|
8
|
+
if (isVNode(child)) {
|
|
9
|
+
vnodes.push(child);
|
|
10
|
+
if ((_a = child.component) == null ? void 0 : _a.subTree) {
|
|
11
|
+
_filterChildren(child.component.subTree.children);
|
|
12
|
+
}
|
|
13
|
+
if (child.children) {
|
|
14
|
+
_filterChildren(child.children);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
_filterChildren(children);
|
|
21
|
+
return vnodes;
|
|
22
|
+
};
|
|
23
|
+
const sortChildren = (childrens, instance) => {
|
|
24
|
+
const vnodes = filterChildren(instance.subTree.children);
|
|
25
|
+
childrens.sort((a, b) => vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode));
|
|
26
|
+
};
|
|
27
|
+
const setRelation = (key) => {
|
|
28
|
+
const instance = getCurrentInstance();
|
|
29
|
+
const childrens = reactive([]);
|
|
30
|
+
const initProvide = (value) => {
|
|
31
|
+
const addChild = (child) => {
|
|
32
|
+
if (child.proxy) {
|
|
33
|
+
childrens.push(child);
|
|
34
|
+
instance && sortChildren(childrens, instance);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const removeChild = (child) => {
|
|
38
|
+
const index = childrens.indexOf(child);
|
|
39
|
+
childrens.splice(index, 1);
|
|
40
|
+
};
|
|
41
|
+
provide(key, {
|
|
42
|
+
addChild,
|
|
43
|
+
removeChild,
|
|
44
|
+
childrens,
|
|
45
|
+
...value
|
|
7
46
|
});
|
|
8
47
|
};
|
|
9
|
-
return r(e), t;
|
|
10
|
-
}, M = (e, t) => {
|
|
11
|
-
const r = F(t.subTree.children);
|
|
12
|
-
e.sort((o, l) => r.indexOf(o.vnode) - r.indexOf(l.vnode));
|
|
13
|
-
}, _ = (e) => {
|
|
14
|
-
const t = O(), r = B([]);
|
|
15
48
|
return {
|
|
16
|
-
childrens
|
|
17
|
-
initProvide
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
childrens,
|
|
50
|
+
initProvide
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const getMods = (el, mods) => {
|
|
54
|
+
if (!mods) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (typeof mods === "string") {
|
|
58
|
+
return ` ${el}--${mods}`;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(mods)) {
|
|
61
|
+
return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
|
|
62
|
+
}
|
|
63
|
+
return Object.keys(mods).reduce(
|
|
64
|
+
(acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
|
|
65
|
+
""
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
const createBEM = (block) => {
|
|
69
|
+
return (el, mods) => {
|
|
70
|
+
let _el = el;
|
|
71
|
+
let _mods = mods;
|
|
72
|
+
if (_el && typeof _el !== "string") {
|
|
73
|
+
_mods = _el;
|
|
74
|
+
_el = "";
|
|
29
75
|
}
|
|
76
|
+
_el = _el ? `${block}__${_el}` : block;
|
|
77
|
+
return `${_el}${getMods(_el, _mods)}`;
|
|
30
78
|
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
79
|
+
};
|
|
80
|
+
const createGlobalBem = () => {
|
|
81
|
+
return (el, mods) => {
|
|
82
|
+
if (!mods) {
|
|
83
|
+
return `y-${el}`;
|
|
84
|
+
}
|
|
85
|
+
return `${getMods(`y-${el}`, mods)}`;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const defaultLang = {
|
|
38
89
|
"pull-refresh": {
|
|
39
90
|
pulling: "下拉刷新...",
|
|
40
91
|
loosing: "释放刷新...",
|
|
@@ -46,23 +97,27 @@ const F = (e) => {
|
|
|
46
97
|
validateMessage: "请输入正确内容"
|
|
47
98
|
}
|
|
48
99
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"zh-CN":
|
|
100
|
+
ref("zh-CN");
|
|
101
|
+
reactive({
|
|
102
|
+
"zh-CN": defaultLang
|
|
52
103
|
});
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
return [
|
|
104
|
+
const createNamespace = (name2) => {
|
|
105
|
+
const prefixedName = `y-${name2}`;
|
|
106
|
+
return [prefixedName, createBEM(prefixedName), createGlobalBem()];
|
|
56
107
|
};
|
|
57
|
-
var
|
|
58
|
-
|
|
108
|
+
var TriggerTypes = /* @__PURE__ */ ((TriggerTypes2) => {
|
|
109
|
+
TriggerTypes2["ONCHANGE"] = "onChange";
|
|
110
|
+
TriggerTypes2["ONBLUR"] = "onBlur";
|
|
111
|
+
return TriggerTypes2;
|
|
112
|
+
})(TriggerTypes || {});
|
|
113
|
+
const commonProps = {
|
|
59
114
|
size: {
|
|
60
115
|
type: String,
|
|
61
116
|
default: null
|
|
62
117
|
},
|
|
63
118
|
border: {
|
|
64
119
|
type: Boolean,
|
|
65
|
-
default:
|
|
120
|
+
default: true
|
|
66
121
|
},
|
|
67
122
|
labelWidth: {
|
|
68
123
|
type: [Number, String],
|
|
@@ -71,7 +126,7 @@ const G = {
|
|
|
71
126
|
colon: {
|
|
72
127
|
// 是否有 ":"
|
|
73
128
|
type: Boolean,
|
|
74
|
-
default:
|
|
129
|
+
default: false
|
|
75
130
|
},
|
|
76
131
|
labelAlign: {
|
|
77
132
|
type: String,
|
|
@@ -79,11 +134,11 @@ const G = {
|
|
|
79
134
|
},
|
|
80
135
|
showError: {
|
|
81
136
|
type: Boolean,
|
|
82
|
-
default:
|
|
137
|
+
default: true
|
|
83
138
|
},
|
|
84
139
|
showErrorMessage: {
|
|
85
140
|
type: Boolean,
|
|
86
|
-
default:
|
|
141
|
+
default: true
|
|
87
142
|
},
|
|
88
143
|
errorMessageAlign: {
|
|
89
144
|
type: String,
|
|
@@ -93,18 +148,21 @@ const G = {
|
|
|
93
148
|
type: [Object, Array],
|
|
94
149
|
default: null
|
|
95
150
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
151
|
+
};
|
|
152
|
+
const [name, bem] = createNamespace("form");
|
|
153
|
+
const FORM_PROVIDE = name;
|
|
154
|
+
const Form = /* @__PURE__ */ defineComponent({
|
|
155
|
+
name,
|
|
98
156
|
props: {
|
|
99
|
-
...
|
|
157
|
+
...commonProps,
|
|
100
158
|
validateFirst: {
|
|
101
159
|
// 是否在某一项校验不通过时停止校验
|
|
102
160
|
type: Boolean,
|
|
103
|
-
default:
|
|
161
|
+
default: false
|
|
104
162
|
},
|
|
105
163
|
scrollToError: {
|
|
106
164
|
type: Boolean,
|
|
107
|
-
default:
|
|
165
|
+
default: true
|
|
108
166
|
},
|
|
109
167
|
validateTrigger: {
|
|
110
168
|
type: String,
|
|
@@ -113,101 +171,143 @@ const G = {
|
|
|
113
171
|
enterable: {
|
|
114
172
|
// 回车可以submit
|
|
115
173
|
type: Boolean,
|
|
116
|
-
default:
|
|
174
|
+
default: true
|
|
117
175
|
}
|
|
118
176
|
},
|
|
119
177
|
emits: ["change", "submit", "failed"],
|
|
120
|
-
setup(
|
|
121
|
-
slots
|
|
122
|
-
emit
|
|
123
|
-
expose
|
|
178
|
+
setup(props, {
|
|
179
|
+
slots,
|
|
180
|
+
emit,
|
|
181
|
+
expose
|
|
124
182
|
}) {
|
|
125
183
|
const {
|
|
126
|
-
initProvide
|
|
127
|
-
childrens
|
|
128
|
-
} =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
184
|
+
initProvide,
|
|
185
|
+
childrens
|
|
186
|
+
} = setRelation(FORM_PROVIDE);
|
|
187
|
+
const getValues = () => {
|
|
188
|
+
const form = {};
|
|
189
|
+
childrens.forEach((child) => {
|
|
190
|
+
const exposed = child.exposed;
|
|
191
|
+
form[child.props.prop] = exposed.formValue;
|
|
192
|
+
});
|
|
193
|
+
return form;
|
|
194
|
+
};
|
|
195
|
+
const validateField = (propName) => {
|
|
196
|
+
const fields = childrens.filter((child) => child.props.prop === propName);
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
if (fields.length === 0) {
|
|
199
|
+
reject(new Error('【YUI】form method "validateField": no field, please check your param: "propName"!'));
|
|
200
|
+
} else {
|
|
201
|
+
const exposed = fields[0].exposed;
|
|
202
|
+
exposed == null ? void 0 : exposed.validate().then((error) => {
|
|
203
|
+
if (error) {
|
|
204
|
+
reject(error);
|
|
205
|
+
} else {
|
|
206
|
+
resolve();
|
|
207
|
+
}
|
|
143
208
|
});
|
|
144
209
|
}
|
|
145
210
|
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
211
|
+
};
|
|
212
|
+
const validateOfSeq = async () => {
|
|
213
|
+
const errors = [];
|
|
214
|
+
await childrens.reduce((promise, child) => promise.then(() => {
|
|
215
|
+
if (!errors.length) {
|
|
216
|
+
const exposed = child.exposed;
|
|
217
|
+
return exposed == null ? void 0 : exposed.validate().then((error) => {
|
|
218
|
+
if (error) {
|
|
219
|
+
errors.push(error);
|
|
220
|
+
}
|
|
153
221
|
});
|
|
154
222
|
}
|
|
155
223
|
return null;
|
|
156
|
-
}), Promise.resolve())
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
224
|
+
}), Promise.resolve());
|
|
225
|
+
if (errors.length) {
|
|
226
|
+
throw errors;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
const validateOfAll = async () => {
|
|
230
|
+
const errors = await Promise.all(childrens.map((child) => {
|
|
231
|
+
const exposed = child.exposed;
|
|
232
|
+
return exposed.validate();
|
|
233
|
+
}));
|
|
234
|
+
const errs = errors.filter((error) => error);
|
|
235
|
+
if (errs.length) {
|
|
236
|
+
throw errs;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const validate = (propName) => {
|
|
240
|
+
if (propName) {
|
|
241
|
+
return validateField(propName);
|
|
242
|
+
}
|
|
243
|
+
return props.validateFirst ? validateOfSeq() : validateOfAll();
|
|
244
|
+
};
|
|
245
|
+
const scrollToField = (propName, options) => {
|
|
246
|
+
const currentChild = childrens.find((child) => child.props.prop === propName);
|
|
247
|
+
const $el = currentChild == null ? void 0 : currentChild.vnode.el;
|
|
248
|
+
$el.scrollIntoView(options);
|
|
249
|
+
};
|
|
250
|
+
const submit = () => {
|
|
251
|
+
const values = getValues();
|
|
252
|
+
validate().then(() => {
|
|
253
|
+
emit("submit", values);
|
|
254
|
+
}).catch((errors) => {
|
|
255
|
+
emit("failed", {
|
|
256
|
+
values,
|
|
257
|
+
errors
|
|
258
|
+
});
|
|
259
|
+
if (Array.isArray(errors) && props.scrollToError) {
|
|
260
|
+
scrollToField(errors == null ? void 0 : errors[0].name);
|
|
261
|
+
}
|
|
174
262
|
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
263
|
+
};
|
|
264
|
+
const onSubmit = (event) => {
|
|
265
|
+
event.preventDefault();
|
|
266
|
+
submit();
|
|
267
|
+
};
|
|
268
|
+
const change = () => {
|
|
269
|
+
emit("change", getValues());
|
|
270
|
+
};
|
|
271
|
+
const resetValidation = (propName) => {
|
|
272
|
+
childrens.forEach((children) => {
|
|
273
|
+
var _a;
|
|
274
|
+
if (!propName || children.props.prop === propName) {
|
|
275
|
+
const exposed = children.exposed;
|
|
276
|
+
(_a = exposed.resetValidation) == null ? void 0 : _a.call(exposed);
|
|
185
277
|
}
|
|
186
278
|
});
|
|
187
279
|
};
|
|
188
|
-
|
|
189
|
-
props
|
|
190
|
-
change
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
280
|
+
initProvide({
|
|
281
|
+
props,
|
|
282
|
+
change
|
|
283
|
+
});
|
|
284
|
+
expose({
|
|
285
|
+
submit,
|
|
286
|
+
scrollToField,
|
|
287
|
+
validate,
|
|
288
|
+
change,
|
|
289
|
+
resetValidation
|
|
290
|
+
});
|
|
291
|
+
return () => {
|
|
292
|
+
var _a;
|
|
293
|
+
return createVNode("form", {
|
|
294
|
+
"onSubmit": onSubmit,
|
|
295
|
+
"class": [bem()]
|
|
296
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
203
297
|
};
|
|
204
298
|
}
|
|
205
299
|
});
|
|
206
|
-
|
|
207
|
-
|
|
300
|
+
const reset = "";
|
|
301
|
+
const libs = "";
|
|
302
|
+
const font = "";
|
|
303
|
+
const animation = "";
|
|
304
|
+
const theme = "";
|
|
305
|
+
const style = "";
|
|
306
|
+
Form.install = (Vue) => {
|
|
307
|
+
Vue.component(Form.name, Form);
|
|
208
308
|
};
|
|
209
309
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
310
|
+
TriggerTypes,
|
|
311
|
+
commonProps,
|
|
312
|
+
Form as default
|
|
213
313
|
};
|