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.
Files changed (119) hide show
  1. package/libs/button/index.css +579 -1
  2. package/libs/button/index.mjs +111 -66
  3. package/libs/button/index.umd.js +203 -2
  4. package/libs/cell/index.css +1077 -1
  5. package/libs/cell/index.mjs +167 -104
  6. package/libs/cell/index.umd.js +300 -2
  7. package/libs/checkbox/index.css +1053 -1
  8. package/libs/checkbox/index.mjs +242 -127
  9. package/libs/checkbox/index.umd.js +369 -2
  10. package/libs/checkboxGroup/index.css +422 -1
  11. package/libs/checkboxGroup/index.mjs +173 -87
  12. package/libs/checkboxGroup/index.umd.js +265 -2
  13. package/libs/col/index.css +615 -1
  14. package/libs/col/index.mjs +246 -81
  15. package/libs/col/index.umd.js +305 -2
  16. package/libs/countdown/index.css +417 -1
  17. package/libs/countdown/index.mjs +179 -71
  18. package/libs/countdown/index.umd.js +231 -2
  19. package/libs/dialog/index.css +1405 -1
  20. package/libs/dialog/index.mjs +646 -476
  21. package/libs/dialog/index.umd.js +1128 -2
  22. package/libs/empty/index.css +457 -1
  23. package/libs/empty/index.mjs +91 -44
  24. package/libs/empty/index.umd.js +139 -2
  25. package/libs/form/index.css +477 -1
  26. package/libs/form/index.mjs +226 -126
  27. package/libs/form/index.umd.js +319 -2
  28. package/libs/formItem/index.css +477 -1
  29. package/libs/formItem/index.mjs +276 -126
  30. package/libs/formItem/index.umd.js +372 -2
  31. package/libs/icon/index.css +982 -1
  32. package/libs/icon/index.mjs +107 -58
  33. package/libs/icon/index.umd.js +186 -2
  34. package/libs/index.css +2902 -1
  35. package/libs/index.mjs +3785 -2344
  36. package/libs/index.umd.js +5509 -2
  37. package/libs/input/index.css +483 -1
  38. package/libs/input/index.mjs +183 -92
  39. package/libs/input/index.umd.js +274 -2
  40. package/libs/layout/index.css +684 -1
  41. package/libs/layout/index.mjs +230 -130
  42. package/libs/layout/index.umd.js +318 -2
  43. package/libs/list/index.css +440 -1
  44. package/libs/list/index.mjs +388 -207
  45. package/libs/list/index.umd.js +571 -2
  46. package/libs/loading/index.css +548 -1
  47. package/libs/loading/index.mjs +196 -118
  48. package/libs/loading/index.umd.js +321 -2
  49. package/libs/mask/index.css +426 -1
  50. package/libs/mask/index.mjs +131 -70
  51. package/libs/mask/index.umd.js +201 -2
  52. package/libs/popup/index.css +465 -1
  53. package/libs/popup/index.mjs +210 -134
  54. package/libs/popup/index.umd.js +358 -2
  55. package/libs/progress/index.css +488 -1
  56. package/libs/progress/index.mjs +200 -128
  57. package/libs/progress/index.umd.js +322 -2
  58. package/libs/pullrefresh/index.css +441 -1
  59. package/libs/pullrefresh/index.mjs +241 -111
  60. package/libs/pullrefresh/index.umd.js +302 -2
  61. package/libs/row/index.css +485 -1
  62. package/libs/row/index.mjs +181 -89
  63. package/libs/row/index.umd.js +237 -2
  64. package/libs/slider/index.css +558 -1
  65. package/libs/slider/index.mjs +356 -160
  66. package/libs/slider/index.umd.js +453 -2
  67. package/libs/stepper/index.css +489 -1
  68. package/libs/stepper/index.mjs +181 -101
  69. package/libs/stepper/index.umd.js +269 -2
  70. package/libs/swipe/index.css +506 -1
  71. package/libs/swipe/index.mjs +542 -259
  72. package/libs/swipe/index.umd.js +703 -2
  73. package/libs/swipeItem/index.css +424 -1
  74. package/libs/swipeItem/index.mjs +111 -52
  75. package/libs/swipeItem/index.umd.js +154 -2
  76. package/libs/switch/index.css +472 -1
  77. package/libs/switch/index.mjs +121 -62
  78. package/libs/switch/index.umd.js +200 -2
  79. package/libs/tab/index.mjs +131 -68
  80. package/libs/tab/index.umd.js +190 -1
  81. package/libs/tabs/index.css +514 -1
  82. package/libs/tabs/index.mjs +751 -410
  83. package/libs/tabs/index.umd.js +1020 -2
  84. package/libs/toast/index.css +1050 -1
  85. package/libs/toast/index.mjs +183 -114
  86. package/libs/toast/index.umd.js +306 -2
  87. package/libs/tooltip/index.css +514 -1
  88. package/libs/tooltip/index.mjs +293 -155
  89. package/libs/tooltip/index.umd.js +416 -2
  90. package/package.json +5 -4
  91. package/libs/button/package.json +0 -5
  92. package/libs/cell/package.json +0 -5
  93. package/libs/checkbox/package.json +0 -5
  94. package/libs/checkboxGroup/package.json +0 -5
  95. package/libs/col/package.json +0 -5
  96. package/libs/countdown/package.json +0 -5
  97. package/libs/dialog/package.json +0 -5
  98. package/libs/empty/package.json +0 -5
  99. package/libs/form/package.json +0 -5
  100. package/libs/formItem/package.json +0 -5
  101. package/libs/icon/package.json +0 -5
  102. package/libs/input/package.json +0 -5
  103. package/libs/layout/package.json +0 -5
  104. package/libs/list/package.json +0 -5
  105. package/libs/loading/package.json +0 -5
  106. package/libs/mask/package.json +0 -5
  107. package/libs/popup/package.json +0 -5
  108. package/libs/progress/package.json +0 -5
  109. package/libs/pullrefresh/package.json +0 -5
  110. package/libs/row/package.json +0 -5
  111. package/libs/slider/package.json +0 -5
  112. package/libs/stepper/package.json +0 -5
  113. package/libs/swipe/package.json +0 -5
  114. package/libs/swipeItem/package.json +0 -5
  115. package/libs/switch/package.json +0 -5
  116. package/libs/tab/package.json +0 -5
  117. package/libs/tabs/package.json +0 -5
  118. package/libs/toast/package.json +0 -5
  119. package/libs/tooltip/package.json +0 -5
@@ -1,40 +1,91 @@
1
- import { getCurrentInstance as O, reactive as B, provide as w, isVNode as N, ref as P, defineComponent as S, createVNode as V } from "vue";
2
- const F = (e) => {
3
- const t = [], r = (o) => {
4
- Array.isArray(o) && o.forEach((l) => {
5
- var c;
6
- N(l) && (t.push(l), (c = l.component) != null && c.subTree && r(l.component.subTree.children), l.children && r(l.children));
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: r,
17
- initProvide: (l) => {
18
- w(e, {
19
- addChild: (d) => {
20
- d.proxy && (r.push(d), t && M(r, t));
21
- },
22
- removeChild: (d) => {
23
- const h = r.indexOf(d);
24
- r.splice(h, 1);
25
- },
26
- childrens: r,
27
- ...l
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
- }, f = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((r, o) => r + f(e, o), "") : Object.keys(t).reduce(
32
- (r, o) => r + (t[o] ? f(e, o) : ""),
33
- ""
34
- ) : "", T = (e) => (t, r) => {
35
- let o = t, l = r;
36
- return o && typeof o != "string" && (l = o, o = ""), o = o ? `${e}__${o}` : e, `${o}${f(o, l)}`;
37
- }, I = () => (e, t) => t ? `${f(`y-${e}`, t)}` : `y-${e}`, R = {
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
- P("zh-CN");
50
- B({
51
- "zh-CN": R
100
+ ref("zh-CN");
101
+ reactive({
102
+ "zh-CN": defaultLang
52
103
  });
53
- const z = (e) => {
54
- const t = `y-${e}`;
55
- return [t, T(t), I()];
104
+ const createNamespace = (name2) => {
105
+ const prefixedName = `y-${name2}`;
106
+ return [prefixedName, createBEM(prefixedName), createGlobalBem()];
56
107
  };
57
- var D = /* @__PURE__ */ ((e) => (e.ONCHANGE = "onChange", e.ONBLUR = "onBlur", e))(D || {});
58
- const G = {
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: !0
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: !1
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: !0
137
+ default: true
83
138
  },
84
139
  showErrorMessage: {
85
140
  type: Boolean,
86
- default: !0
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
- }, [C, L] = z("form"), U = C, m = /* @__PURE__ */ S({
97
- name: C,
151
+ };
152
+ const [name, bem] = createNamespace("form");
153
+ const FORM_PROVIDE = name;
154
+ const Form = /* @__PURE__ */ defineComponent({
155
+ name,
98
156
  props: {
99
- ...G,
157
+ ...commonProps,
100
158
  validateFirst: {
101
159
  // 是否在某一项校验不通过时停止校验
102
160
  type: Boolean,
103
- default: !1
161
+ default: false
104
162
  },
105
163
  scrollToError: {
106
164
  type: Boolean,
107
- default: !0
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: !0
174
+ default: true
117
175
  }
118
176
  },
119
177
  emits: ["change", "submit", "failed"],
120
- setup(e, {
121
- slots: t,
122
- emit: r,
123
- expose: o
178
+ setup(props, {
179
+ slots,
180
+ emit,
181
+ expose
124
182
  }) {
125
183
  const {
126
- initProvide: l,
127
- childrens: c
128
- } = _(U), p = () => {
129
- const n = {};
130
- return c.forEach((s) => {
131
- const a = s.exposed;
132
- n[s.props.prop] = a.formValue;
133
- }), n;
134
- }, d = (n) => {
135
- const s = c.filter((a) => a.props.prop === n);
136
- return new Promise((a, i) => {
137
- if (s.length === 0)
138
- i(new Error('【YUI】form method "validateField": no field, please check your param: "propName"!'));
139
- else {
140
- const u = s[0].exposed;
141
- u == null || u.validate().then((x) => {
142
- x ? i(x) : a();
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
- }, h = async () => {
147
- const n = [];
148
- if (await c.reduce((s, a) => s.then(() => {
149
- if (!n.length) {
150
- const i = a.exposed;
151
- return i == null ? void 0 : i.validate().then((u) => {
152
- u && n.push(u);
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()), n.length)
157
- throw n;
158
- }, $ = async () => {
159
- const s = (await Promise.all(c.map((a) => a.exposed.validate()))).filter((a) => a);
160
- if (s.length)
161
- throw s;
162
- }, y = (n) => n ? d(n) : e.validateFirst ? h() : $(), v = (n, s) => {
163
- const a = c.find((u) => u.props.prop === n);
164
- (a == null ? void 0 : a.vnode.el).scrollIntoView(s);
165
- }, g = () => {
166
- const n = p();
167
- y().then(() => {
168
- r("submit", n);
169
- }).catch((s) => {
170
- r("failed", {
171
- values: n,
172
- errors: s
173
- }), Array.isArray(s) && e.scrollToError && v(s == null ? void 0 : s[0].name);
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
- }, A = (n) => {
176
- n.preventDefault(), g();
177
- }, b = () => {
178
- r("change", p());
179
- }, E = (n) => {
180
- c.forEach((s) => {
181
- var a;
182
- if (!n || s.props.prop === n) {
183
- const i = s.exposed;
184
- (a = i.resetValidation) == null || a.call(i);
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
- return l({
189
- props: e,
190
- change: b
191
- }), o({
192
- submit: g,
193
- scrollToField: v,
194
- validate: y,
195
- change: b,
196
- resetValidation: E
197
- }), () => {
198
- var n;
199
- return V("form", {
200
- onSubmit: A,
201
- class: [L()]
202
- }, [(n = t.default) == null ? void 0 : n.call(t)]);
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
- m.install = (e) => {
207
- e.component(m.name, m);
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
- D as TriggerTypes,
211
- G as commonProps,
212
- m as default
310
+ TriggerTypes,
311
+ commonProps,
312
+ Form as default
213
313
  };