y-design-ssr 0.2.3 → 0.2.5

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 (120) hide show
  1. package/README.md +21 -16
  2. package/libs/button/index.css +1 -579
  3. package/libs/button/index.mjs +66 -111
  4. package/libs/button/index.umd.js +2 -203
  5. package/libs/button/package.json +1 -7
  6. package/libs/cell/index.css +1 -1077
  7. package/libs/cell/index.mjs +104 -167
  8. package/libs/cell/index.umd.js +2 -300
  9. package/libs/cell/package.json +1 -7
  10. package/libs/checkbox/index.css +1 -1053
  11. package/libs/checkbox/index.mjs +127 -242
  12. package/libs/checkbox/index.umd.js +2 -369
  13. package/libs/checkbox/package.json +1 -7
  14. package/libs/checkboxGroup/index.css +1 -422
  15. package/libs/checkboxGroup/index.mjs +87 -173
  16. package/libs/checkboxGroup/index.umd.js +2 -265
  17. package/libs/checkboxGroup/package.json +1 -7
  18. package/libs/col/index.css +1 -615
  19. package/libs/col/index.mjs +81 -246
  20. package/libs/col/index.umd.js +2 -305
  21. package/libs/col/package.json +1 -7
  22. package/libs/countdown/index.css +1 -417
  23. package/libs/countdown/index.mjs +71 -179
  24. package/libs/countdown/index.umd.js +2 -231
  25. package/libs/countdown/package.json +1 -7
  26. package/libs/dialog/index.css +1 -1405
  27. package/libs/dialog/index.mjs +476 -646
  28. package/libs/dialog/index.umd.js +2 -1128
  29. package/libs/dialog/package.json +1 -7
  30. package/libs/empty/index.css +1 -457
  31. package/libs/empty/index.mjs +44 -91
  32. package/libs/empty/index.umd.js +2 -139
  33. package/libs/empty/package.json +1 -7
  34. package/libs/form/index.css +1 -477
  35. package/libs/form/index.mjs +126 -226
  36. package/libs/form/index.umd.js +2 -319
  37. package/libs/form/package.json +1 -7
  38. package/libs/formItem/index.css +1 -477
  39. package/libs/formItem/index.mjs +126 -276
  40. package/libs/formItem/index.umd.js +2 -372
  41. package/libs/formItem/package.json +1 -7
  42. package/libs/icon/index.css +1 -982
  43. package/libs/icon/index.mjs +58 -107
  44. package/libs/icon/index.umd.js +2 -186
  45. package/libs/icon/package.json +1 -7
  46. package/libs/index.css +1 -2902
  47. package/libs/index.mjs +2348 -3789
  48. package/libs/index.umd.js +2 -5509
  49. package/libs/input/index.css +1 -483
  50. package/libs/input/index.mjs +92 -183
  51. package/libs/input/index.umd.js +2 -274
  52. package/libs/input/package.json +1 -7
  53. package/libs/layout/index.css +1 -684
  54. package/libs/layout/index.mjs +130 -230
  55. package/libs/layout/index.umd.js +2 -318
  56. package/libs/layout/package.json +1 -7
  57. package/libs/list/index.css +1 -440
  58. package/libs/list/index.mjs +207 -388
  59. package/libs/list/index.umd.js +2 -571
  60. package/libs/list/package.json +1 -7
  61. package/libs/loading/index.css +1 -548
  62. package/libs/loading/index.mjs +118 -196
  63. package/libs/loading/index.umd.js +2 -321
  64. package/libs/loading/package.json +1 -7
  65. package/libs/mask/index.css +1 -426
  66. package/libs/mask/index.mjs +70 -131
  67. package/libs/mask/index.umd.js +2 -201
  68. package/libs/mask/package.json +1 -7
  69. package/libs/popup/index.css +1 -465
  70. package/libs/popup/index.mjs +134 -210
  71. package/libs/popup/index.umd.js +2 -358
  72. package/libs/popup/package.json +1 -7
  73. package/libs/progress/index.css +1 -488
  74. package/libs/progress/index.mjs +128 -200
  75. package/libs/progress/index.umd.js +2 -322
  76. package/libs/progress/package.json +1 -7
  77. package/libs/pullrefresh/index.css +1 -441
  78. package/libs/pullrefresh/index.mjs +111 -241
  79. package/libs/pullrefresh/index.umd.js +2 -302
  80. package/libs/pullrefresh/package.json +1 -7
  81. package/libs/row/index.css +1 -485
  82. package/libs/row/index.mjs +89 -181
  83. package/libs/row/index.umd.js +2 -237
  84. package/libs/row/package.json +1 -7
  85. package/libs/slider/index.css +1 -558
  86. package/libs/slider/index.mjs +160 -356
  87. package/libs/slider/index.umd.js +2 -453
  88. package/libs/slider/package.json +1 -7
  89. package/libs/stepper/index.css +1 -489
  90. package/libs/stepper/index.mjs +101 -181
  91. package/libs/stepper/index.umd.js +2 -269
  92. package/libs/stepper/package.json +1 -7
  93. package/libs/swipe/index.css +1 -506
  94. package/libs/swipe/index.mjs +259 -542
  95. package/libs/swipe/index.umd.js +2 -703
  96. package/libs/swipe/package.json +1 -7
  97. package/libs/swipeItem/index.css +1 -424
  98. package/libs/swipeItem/index.mjs +52 -111
  99. package/libs/swipeItem/index.umd.js +2 -154
  100. package/libs/swipeItem/package.json +1 -7
  101. package/libs/switch/index.css +1 -472
  102. package/libs/switch/index.mjs +62 -121
  103. package/libs/switch/index.umd.js +2 -200
  104. package/libs/switch/package.json +1 -7
  105. package/libs/tab/index.mjs +68 -131
  106. package/libs/tab/index.umd.js +1 -190
  107. package/libs/tab/package.json +1 -7
  108. package/libs/tabs/index.css +1 -514
  109. package/libs/tabs/index.mjs +410 -751
  110. package/libs/tabs/index.umd.js +2 -1020
  111. package/libs/tabs/package.json +1 -7
  112. package/libs/toast/index.css +1 -1050
  113. package/libs/toast/index.mjs +114 -183
  114. package/libs/toast/index.umd.js +2 -306
  115. package/libs/toast/package.json +1 -7
  116. package/libs/tooltip/index.css +1 -514
  117. package/libs/tooltip/index.mjs +155 -293
  118. package/libs/tooltip/index.umd.js +2 -416
  119. package/libs/tooltip/package.json +1 -7
  120. package/package.json +7 -11
@@ -1,91 +1,40 @@
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
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));
46
7
  });
47
8
  };
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([]);
48
15
  return {
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 = "";
75
- }
76
- _el = _el ? `${block}__${_el}` : block;
77
- return `${_el}${getMods(_el, _mods)}`;
78
- };
79
- };
80
- const createGlobalBem = () => {
81
- return (el, mods) => {
82
- if (!mods) {
83
- return `y-${el}`;
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
+ });
84
29
  }
85
- return `${getMods(`y-${el}`, mods)}`;
86
30
  };
87
- };
88
- const defaultLang = {
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 = {
89
38
  "pull-refresh": {
90
39
  pulling: "下拉刷新...",
91
40
  loosing: "释放刷新...",
@@ -97,27 +46,23 @@ const defaultLang = {
97
46
  validateMessage: "请输入正确内容"
98
47
  }
99
48
  };
100
- ref("zh-CN");
101
- reactive({
102
- "zh-CN": defaultLang
49
+ P("zh-CN");
50
+ B({
51
+ "zh-CN": R
103
52
  });
104
- const createNamespace = (name2) => {
105
- const prefixedName = `y-${name2}`;
106
- return [prefixedName, createBEM(prefixedName), createGlobalBem()];
53
+ const z = (e) => {
54
+ const t = `y-${e}`;
55
+ return [t, T(t), I()];
107
56
  };
108
- var TriggerTypes = /* @__PURE__ */ ((TriggerTypes2) => {
109
- TriggerTypes2["ONCHANGE"] = "onChange";
110
- TriggerTypes2["ONBLUR"] = "onBlur";
111
- return TriggerTypes2;
112
- })(TriggerTypes || {});
113
- const commonProps = {
57
+ var D = /* @__PURE__ */ ((e) => (e.ONCHANGE = "onChange", e.ONBLUR = "onBlur", e))(D || {});
58
+ const G = {
114
59
  size: {
115
60
  type: String,
116
61
  default: null
117
62
  },
118
63
  border: {
119
64
  type: Boolean,
120
- default: true
65
+ default: !0
121
66
  },
122
67
  labelWidth: {
123
68
  type: [Number, String],
@@ -126,7 +71,7 @@ const commonProps = {
126
71
  colon: {
127
72
  // 是否有 ":"
128
73
  type: Boolean,
129
- default: false
74
+ default: !1
130
75
  },
131
76
  labelAlign: {
132
77
  type: String,
@@ -134,11 +79,11 @@ const commonProps = {
134
79
  },
135
80
  showError: {
136
81
  type: Boolean,
137
- default: true
82
+ default: !0
138
83
  },
139
84
  showErrorMessage: {
140
85
  type: Boolean,
141
- default: true
86
+ default: !0
142
87
  },
143
88
  errorMessageAlign: {
144
89
  type: String,
@@ -148,21 +93,18 @@ const commonProps = {
148
93
  type: [Object, Array],
149
94
  default: null
150
95
  }
151
- };
152
- const [name, bem] = createNamespace("form");
153
- const FORM_PROVIDE = name;
154
- const Form = /* @__PURE__ */ defineComponent({
155
- name,
96
+ }, [C, L] = z("form"), U = C, m = /* @__PURE__ */ S({
97
+ name: C,
156
98
  props: {
157
- ...commonProps,
99
+ ...G,
158
100
  validateFirst: {
159
101
  // 是否在某一项校验不通过时停止校验
160
102
  type: Boolean,
161
- default: false
103
+ default: !1
162
104
  },
163
105
  scrollToError: {
164
106
  type: Boolean,
165
- default: true
107
+ default: !0
166
108
  },
167
109
  validateTrigger: {
168
110
  type: String,
@@ -171,143 +113,101 @@ const Form = /* @__PURE__ */ defineComponent({
171
113
  enterable: {
172
114
  // 回车可以submit
173
115
  type: Boolean,
174
- default: true
116
+ default: !0
175
117
  }
176
118
  },
177
119
  emits: ["change", "submit", "failed"],
178
- setup(props, {
179
- slots,
180
- emit,
181
- expose
120
+ setup(e, {
121
+ slots: t,
122
+ emit: r,
123
+ expose: o
182
124
  }) {
183
125
  const {
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
- }
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();
208
143
  });
209
144
  }
210
145
  });
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
- }
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);
221
153
  });
222
154
  }
223
155
  return null;
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
- }
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);
262
174
  });
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);
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);
277
185
  }
278
186
  });
279
187
  };
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)]);
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)]);
297
203
  };
298
204
  }
299
205
  });
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);
206
+ m.install = (e) => {
207
+ e.component(m.name, m);
308
208
  };
309
209
  export {
310
- TriggerTypes,
311
- commonProps,
312
- Form as default
210
+ D as TriggerTypes,
211
+ G as commonProps,
212
+ m as default
313
213
  };