y-design-ssr 0.2.2 → 0.2.4

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 +1 -579
  2. package/libs/button/index.mjs +66 -111
  3. package/libs/button/index.umd.js +2 -203
  4. package/libs/button/package.json +5 -0
  5. package/libs/cell/index.css +1 -1077
  6. package/libs/cell/index.mjs +104 -167
  7. package/libs/cell/index.umd.js +2 -300
  8. package/libs/cell/package.json +5 -0
  9. package/libs/checkbox/index.css +1 -1053
  10. package/libs/checkbox/index.mjs +127 -242
  11. package/libs/checkbox/index.umd.js +2 -369
  12. package/libs/checkbox/package.json +5 -0
  13. package/libs/checkboxGroup/index.css +1 -422
  14. package/libs/checkboxGroup/index.mjs +87 -173
  15. package/libs/checkboxGroup/index.umd.js +2 -265
  16. package/libs/checkboxGroup/package.json +5 -0
  17. package/libs/col/index.css +1 -615
  18. package/libs/col/index.mjs +81 -246
  19. package/libs/col/index.umd.js +2 -305
  20. package/libs/col/package.json +5 -0
  21. package/libs/countdown/index.css +1 -417
  22. package/libs/countdown/index.mjs +71 -179
  23. package/libs/countdown/index.umd.js +2 -231
  24. package/libs/countdown/package.json +5 -0
  25. package/libs/dialog/index.css +1 -1405
  26. package/libs/dialog/index.mjs +476 -646
  27. package/libs/dialog/index.umd.js +2 -1128
  28. package/libs/dialog/package.json +5 -0
  29. package/libs/empty/index.css +1 -457
  30. package/libs/empty/index.mjs +44 -91
  31. package/libs/empty/index.umd.js +2 -139
  32. package/libs/empty/package.json +5 -0
  33. package/libs/form/index.css +1 -477
  34. package/libs/form/index.mjs +126 -226
  35. package/libs/form/index.umd.js +2 -319
  36. package/libs/form/package.json +5 -0
  37. package/libs/formItem/index.css +1 -477
  38. package/libs/formItem/index.mjs +126 -276
  39. package/libs/formItem/index.umd.js +2 -372
  40. package/libs/formItem/package.json +5 -0
  41. package/libs/icon/index.css +1 -982
  42. package/libs/icon/index.mjs +58 -107
  43. package/libs/icon/index.umd.js +2 -186
  44. package/libs/icon/package.json +5 -0
  45. package/libs/index.css +1 -2902
  46. package/libs/index.mjs +2348 -3789
  47. package/libs/index.umd.js +2 -5509
  48. package/libs/input/index.css +1 -483
  49. package/libs/input/index.mjs +92 -183
  50. package/libs/input/index.umd.js +2 -274
  51. package/libs/input/package.json +5 -0
  52. package/libs/layout/index.css +1 -684
  53. package/libs/layout/index.mjs +130 -230
  54. package/libs/layout/index.umd.js +2 -318
  55. package/libs/layout/package.json +5 -0
  56. package/libs/list/index.css +1 -440
  57. package/libs/list/index.mjs +207 -388
  58. package/libs/list/index.umd.js +2 -571
  59. package/libs/list/package.json +5 -0
  60. package/libs/loading/index.css +1 -548
  61. package/libs/loading/index.mjs +118 -196
  62. package/libs/loading/index.umd.js +2 -321
  63. package/libs/loading/package.json +5 -0
  64. package/libs/mask/index.css +1 -426
  65. package/libs/mask/index.mjs +70 -131
  66. package/libs/mask/index.umd.js +2 -201
  67. package/libs/mask/package.json +5 -0
  68. package/libs/popup/index.css +1 -465
  69. package/libs/popup/index.mjs +134 -210
  70. package/libs/popup/index.umd.js +2 -358
  71. package/libs/popup/package.json +5 -0
  72. package/libs/progress/index.css +1 -488
  73. package/libs/progress/index.mjs +128 -200
  74. package/libs/progress/index.umd.js +2 -322
  75. package/libs/progress/package.json +5 -0
  76. package/libs/pullrefresh/index.css +1 -441
  77. package/libs/pullrefresh/index.mjs +111 -241
  78. package/libs/pullrefresh/index.umd.js +2 -302
  79. package/libs/pullrefresh/package.json +5 -0
  80. package/libs/row/index.css +1 -485
  81. package/libs/row/index.mjs +89 -181
  82. package/libs/row/index.umd.js +2 -237
  83. package/libs/row/package.json +5 -0
  84. package/libs/slider/index.css +1 -558
  85. package/libs/slider/index.mjs +160 -356
  86. package/libs/slider/index.umd.js +2 -453
  87. package/libs/slider/package.json +5 -0
  88. package/libs/stepper/index.css +1 -489
  89. package/libs/stepper/index.mjs +101 -181
  90. package/libs/stepper/index.umd.js +2 -269
  91. package/libs/stepper/package.json +5 -0
  92. package/libs/swipe/index.css +1 -506
  93. package/libs/swipe/index.mjs +259 -542
  94. package/libs/swipe/index.umd.js +2 -703
  95. package/libs/swipe/package.json +5 -0
  96. package/libs/swipeItem/index.css +1 -424
  97. package/libs/swipeItem/index.mjs +52 -111
  98. package/libs/swipeItem/index.umd.js +2 -154
  99. package/libs/swipeItem/package.json +5 -0
  100. package/libs/switch/index.css +1 -472
  101. package/libs/switch/index.mjs +62 -121
  102. package/libs/switch/index.umd.js +2 -200
  103. package/libs/switch/package.json +5 -0
  104. package/libs/tab/index.mjs +68 -131
  105. package/libs/tab/index.umd.js +1 -190
  106. package/libs/tab/package.json +5 -0
  107. package/libs/tabs/index.css +1 -514
  108. package/libs/tabs/index.mjs +410 -751
  109. package/libs/tabs/index.umd.js +2 -1020
  110. package/libs/tabs/package.json +5 -0
  111. package/libs/toast/index.css +1 -1050
  112. package/libs/toast/index.mjs +114 -183
  113. package/libs/toast/index.umd.js +2 -306
  114. package/libs/toast/package.json +5 -0
  115. package/libs/tooltip/index.css +1 -514
  116. package/libs/tooltip/index.mjs +155 -293
  117. package/libs/tooltip/index.umd.js +2 -416
  118. package/libs/tooltip/package.json +5 -0
  119. package/package.json +5 -12
@@ -1,48 +1,11 @@
1
- import { ref, reactive, inject, getCurrentInstance, onUnmounted, computed, provide, defineComponent, createVNode } from "vue";
2
- const tagTester = (name2) => {
3
- return (obj) => {
4
- return Object.prototype.toString.call(obj) === `[object ${name2}]`;
5
- };
6
- };
7
- const isFunction = tagTester("Function");
8
- const isString = tagTester("String");
9
- const isObject = tagTester("Object");
10
- const getMods = (el, mods) => {
11
- if (!mods) {
12
- return "";
13
- }
14
- if (typeof mods === "string") {
15
- return ` ${el}--${mods}`;
16
- }
17
- if (Array.isArray(mods)) {
18
- return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
19
- }
20
- return Object.keys(mods).reduce(
21
- (acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
22
- ""
23
- );
24
- };
25
- const createBEM = (block) => {
26
- return (el, mods) => {
27
- let _el = el;
28
- let _mods = mods;
29
- if (_el && typeof _el !== "string") {
30
- _mods = _el;
31
- _el = "";
32
- }
33
- _el = _el ? `${block}__${_el}` : block;
34
- return `${_el}${getMods(_el, _mods)}`;
35
- };
36
- };
37
- const createGlobalBem = () => {
38
- return (el, mods) => {
39
- if (!mods) {
40
- return `y-${el}`;
41
- }
42
- return `${getMods(`y-${el}`, mods)}`;
43
- };
44
- };
45
- const defaultLang = {
1
+ import { ref as y, reactive as w, inject as z, getCurrentInstance as R, onUnmounted as j, computed as p, provide as W, defineComponent as D, createVNode as h } from "vue";
2
+ const O = (t) => (e) => Object.prototype.toString.call(e) === `[object ${t}]`, L = O("Function"), G = O("String"), U = O("Object"), x = (t, e) => e ? typeof e == "string" ? ` ${t}--${e}` : Array.isArray(e) ? e.reduce((i, r) => i + x(t, r), "") : Object.keys(e).reduce(
3
+ (i, r) => i + (e[r] ? x(t, r) : ""),
4
+ ""
5
+ ) : "", k = (t) => (e, i) => {
6
+ let r = e, d = i;
7
+ return r && typeof r != "string" && (d = r, r = ""), r = r ? `${t}__${r}` : t, `${r}${x(r, d)}`;
8
+ }, H = () => (t, e) => e ? `${x(`y-${t}`, e)}` : `y-${t}`, J = {
46
9
  "pull-refresh": {
47
10
  pulling: "下拉刷新...",
48
11
  loosing: "释放刷新...",
@@ -53,77 +16,56 @@ const defaultLang = {
53
16
  "form-item": {
54
17
  validateMessage: "请输入正确内容"
55
18
  }
56
- };
57
- const lang = ref("zh-CN");
58
- const langs = reactive({
59
- "zh-CN": defaultLang
60
- });
61
- const locale$1 = {
19
+ }, I = y("zh-CN"), F = w({
20
+ "zh-CN": J
21
+ }), K = {
62
22
  text() {
63
- return langs[lang.value];
23
+ return F[I.value];
64
24
  },
65
- use(newLang, newConfigs) {
66
- lang.value = newLang;
67
- this.add({ [newLang]: newConfigs });
25
+ use(t, e) {
26
+ I.value = t, this.add({ [t]: e });
68
27
  },
69
- add(newConfigs = {}) {
70
- Object.assign(langs, newConfigs);
28
+ add(t = {}) {
29
+ Object.assign(F, t);
71
30
  }
72
- };
73
- const createNamespace = (name2) => {
74
- const prefixedName = `y-${name2}`;
75
- return [prefixedName, createBEM(prefixedName), createGlobalBem()];
76
- };
77
- const createLocale = (name2) => {
78
- return locale$1.text()[name2];
79
- };
80
- const useRelation = (key) => {
81
- const parent = inject(key, null);
82
- const currentInstance = getCurrentInstance();
83
- if (parent && currentInstance) {
84
- const { childrens, addChild, removeChild } = parent;
85
- addChild(currentInstance);
86
- onUnmounted(() => removeChild(currentInstance));
87
- const index = computed(() => childrens.indexOf(currentInstance));
88
- return {
89
- index,
90
- parent
31
+ }, _ = (t) => {
32
+ const e = `y-${t}`;
33
+ return [e, k(e), H()];
34
+ }, Q = (t) => K.text()[t], X = (t) => {
35
+ const e = z(t, null), i = R();
36
+ if (e && i) {
37
+ const { childrens: r, addChild: d, removeChild: o } = e;
38
+ return d(i), j(() => o(i)), {
39
+ index: p(() => r.indexOf(i)),
40
+ parent: e
91
41
  };
92
42
  }
93
43
  return {
94
44
  parent: null,
95
- index: ref(-1)
96
- };
97
- };
98
- const FORM_ITEM_PROVIDE = "y-form-item";
99
- const setFormItem = () => {
100
- const instance = getCurrentInstance();
101
- const filed = ref();
102
- const initProvide = (value) => {
103
- const setField = (obj) => {
104
- if (obj == null ? void 0 : obj.proxy) {
105
- filed.value = obj;
106
- }
107
- };
108
- provide(FORM_ITEM_PROVIDE, {
109
- setField,
110
- instance,
111
- ...value
112
- });
45
+ index: y(-1)
113
46
  };
47
+ }, Y = "y-form-item", Z = () => {
48
+ const t = R(), e = y();
114
49
  return {
115
- filed,
116
- initProvide
50
+ filed: e,
51
+ initProvide: (r) => {
52
+ W(Y, {
53
+ setField: (o) => {
54
+ o != null && o.proxy && (e.value = o);
55
+ },
56
+ instance: t,
57
+ ...r
58
+ });
59
+ }
117
60
  };
118
- };
119
- const commonProps = {
61
+ }, ee = {
120
62
  size: {
121
63
  type: String,
122
64
  default: null
123
65
  },
124
66
  border: {
125
67
  type: Boolean,
126
- default: true
68
+ default: !0
127
69
  },
128
70
  labelWidth: {
129
71
  type: [Number, String],
@@ -132,7 +74,7 @@ const commonProps = {
132
74
  colon: {
133
75
  // 是否有 ":"
134
76
  type: Boolean,
135
- default: false
77
+ default: !1
136
78
  },
137
79
  labelAlign: {
138
80
  type: String,
@@ -140,11 +82,11 @@ const commonProps = {
140
82
  },
141
83
  showError: {
142
84
  type: Boolean,
143
- default: true
85
+ default: !0
144
86
  },
145
87
  showErrorMessage: {
146
88
  type: Boolean,
147
- default: true
89
+ default: !0
148
90
  },
149
91
  errorMessageAlign: {
150
92
  type: String,
@@ -154,16 +96,10 @@ const commonProps = {
154
96
  type: [Object, Array],
155
97
  default: null
156
98
  }
157
- };
158
- const [name$1, bem$1] = createNamespace("form");
159
- const FORM_PROVIDE = name$1;
160
- const COMPONENT_NAME = "form-item";
161
- const [name, bem, gbem] = createNamespace(COMPONENT_NAME);
162
- const locale = createLocale(COMPONENT_NAME);
163
- const FormItem = /* @__PURE__ */ defineComponent({
164
- name,
99
+ }, [te, oe] = _("form"), re = te, C = "form-item", [ne, b, le] = _(C), ae = Q(C), $ = /* @__PURE__ */ D({
100
+ name: ne,
165
101
  props: {
166
- ...commonProps,
102
+ ...ee,
167
103
  label: {
168
104
  type: [Number, String],
169
105
  default: ""
@@ -178,189 +114,103 @@ const FormItem = /* @__PURE__ */ defineComponent({
178
114
  default: ""
179
115
  }
180
116
  },
181
- setup(props, {
182
- slots,
183
- expose
117
+ setup(t, {
118
+ slots: e,
119
+ expose: i
184
120
  }) {
185
121
  const {
186
- parent
187
- } = useRelation(FORM_PROVIDE);
188
- const {
189
- initProvide: initFormItemProvide,
190
- filed
191
- } = setFormItem();
192
- const validateFailed = ref(false);
193
- const validateMessage = ref(locale.validateMessage);
194
- const getProp = (propName) => {
195
- if (props[propName] && props[propName] !== null)
196
- return props[propName];
197
- const parentProps = parent && parent.props;
198
- return parentProps && parentProps[propName] || null;
199
- };
200
- const rules = computed(() => {
201
- const parentRules = parent && parent.props.rules;
202
- const curRules = props.rules || (parentRules == null ? void 0 : parentRules[props.prop]);
203
- return isObject(curRules) ? [curRules] : curRules;
204
- });
205
- const required = computed(() => rules.value && rules.value.some((item) => item.required));
206
- const formValue = computed(() => {
207
- if (filed.value) {
208
- const filedInstance = filed.value.proxy;
209
- return filedInstance.modelValue;
210
- }
211
- return null;
212
- });
213
- const errorStatus = computed(() => {
214
- return getProp("showError") && validateFailed.value;
215
- });
216
- const runSyncRule = (value, rule) => {
217
- if (rule.required) {
218
- if (filed.value && filed.value.exposed && typeof filed.value.exposed.isRequired !== "undefined" && !filed.value.exposed.isRequired) {
219
- return false;
220
- }
221
- if (!(Array.isArray(value) ? value.length : value)) {
222
- return false;
223
- }
224
- }
225
- if (rule.pattern && isString(value) && !rule.pattern.test(value)) {
226
- return false;
227
- }
228
- return true;
229
- };
230
- const getRuleMessage = (value, rule) => {
122
+ parent: r
123
+ } = X(re), {
124
+ initProvide: d,
125
+ filed: o
126
+ } = Z(), c = y(!1), v = y(ae.validateMessage), f = (n) => {
127
+ if (t[n] && t[n] !== null)
128
+ return t[n];
129
+ const l = r && r.props;
130
+ return l && l[n] || null;
131
+ }, g = p(() => {
132
+ const n = r && r.props.rules, l = t.rules || (n == null ? void 0 : n[t.prop]);
133
+ return U(l) ? [l] : l;
134
+ }), N = p(() => g.value && g.value.some((n) => n.required)), M = p(() => o.value ? o.value.proxy.modelValue : null), A = p(() => f("showError") && c.value), q = (n, l) => !(l.required && (o.value && o.value.exposed && typeof o.value.exposed.isRequired < "u" && !o.value.exposed.isRequired || !(Array.isArray(n) ? n.length : n)) || l.pattern && G(n) && !l.pattern.test(n)), P = (n, l) => {
231
135
  const {
232
- message
233
- } = rule;
234
- if (isFunction(message)) {
235
- return message(value, rule);
236
- }
237
- return message;
238
- };
239
- const runRules = (ruleList) => {
240
- return ruleList.reduce((promise, rule) => promise.then(() => {
241
- if (validateFailed.value)
242
- return null;
243
- const value = rule.formatter ? rule.formatter(formValue.value, rule) : formValue.value;
244
- if (!runSyncRule(value, rule)) {
245
- validateFailed.value = true;
246
- validateMessage.value = getRuleMessage(value, rule);
247
- return null;
248
- }
249
- if (rule.validator) {
250
- const cb = rule.validator(value, rule);
251
- if (typeof cb === "boolean") {
252
- if (!cb) {
253
- validateFailed.value = true;
254
- validateMessage.value = getRuleMessage(value, rule);
255
- }
256
- return Promise.resolve(cb);
257
- }
258
- return cb.then((result) => {
259
- if (!result) {
260
- validateFailed.value = true;
261
- validateMessage.value = getRuleMessage(value, rule);
262
- }
263
- return result;
264
- });
265
- }
136
+ message: a
137
+ } = l;
138
+ return L(a) ? a(n, l) : a;
139
+ }, B = (n) => n.reduce((l, a) => l.then(() => {
140
+ if (c.value)
266
141
  return null;
267
- }), Promise.resolve());
268
- };
269
- const validate = async (ruleList) => {
270
- const ruleArr = ruleList || rules.value;
271
- if (!ruleArr) {
272
- return Promise.resolve();
273
- }
274
- await runRules(ruleArr);
275
- if (validateFailed.value) {
276
- return {
277
- name: props.prop,
278
- message: validateMessage.value
279
- };
142
+ const u = a.formatter ? a.formatter(M.value, a) : M.value;
143
+ if (!q(u, a))
144
+ return c.value = !0, v.value = P(u, a), null;
145
+ if (a.validator) {
146
+ const s = a.validator(u, a);
147
+ return typeof s == "boolean" ? (s || (c.value = !0, v.value = P(u, a)), Promise.resolve(s)) : s.then((m) => (m || (c.value = !0, v.value = P(u, a)), m));
280
148
  }
281
149
  return null;
282
- };
283
- const validateWithTrigger = (trigger) => {
284
- var _a;
285
- if (parent && rules.value) {
286
- const defaultTrigger = ((_a = parent.props) == null ? void 0 : _a.validateTrigger) === trigger;
287
- const ruleList = rules.value.filter((rule) => {
288
- if (rule.trigger) {
289
- return rule.trigger === trigger;
290
- }
291
- return defaultTrigger;
292
- });
293
- return validate(ruleList);
150
+ }), Promise.resolve()), S = async (n) => {
151
+ const l = n || g.value;
152
+ return l ? (await B(l), c.value ? {
153
+ name: t.prop,
154
+ message: v.value
155
+ } : null) : Promise.resolve();
156
+ }, T = (n) => {
157
+ var l;
158
+ if (r && g.value) {
159
+ const a = ((l = r.props) == null ? void 0 : l.validateTrigger) === n, u = g.value.filter((s) => s.trigger ? s.trigger === n : a);
160
+ return S(u);
294
161
  }
295
162
  return Promise.resolve(null);
163
+ }, E = () => {
164
+ c.value && (c.value = !1, v.value = "");
296
165
  };
297
- const resetValidation = () => {
298
- if (validateFailed.value) {
299
- validateFailed.value = false;
300
- validateMessage.value = "";
301
- }
302
- };
303
- initFormItemProvide({
304
- getProp,
305
- validateWithTrigger,
306
- resetValidation,
307
- change: parent == null ? void 0 : parent.change
308
- });
309
- expose({
310
- resetValidation,
311
- formValue,
312
- validate
166
+ d({
167
+ getProp: f,
168
+ validateWithTrigger: T,
169
+ resetValidation: E,
170
+ change: r == null ? void 0 : r.change
171
+ }), i({
172
+ resetValidation: E,
173
+ formValue: M,
174
+ validate: S
313
175
  });
314
- const _renderError = () => {
315
- if (!errorStatus.value)
316
- return null;
317
- if (slots.error)
318
- return slots.error();
319
- return getProp("showErrorMessage") ? createVNode("p", {
320
- "class": bem("error"),
321
- "style": {
322
- textAlign: "left"
323
- }
324
- }, [validateMessage.value]) : null;
325
- };
176
+ const V = () => A.value ? e.error ? e.error() : f("showErrorMessage") ? h("p", {
177
+ class: b("error"),
178
+ style: {
179
+ textAlign: "left"
180
+ }
181
+ }, [v.value]) : null : null;
326
182
  return () => {
327
- var _a, _b, _c;
183
+ var u, s, m;
328
184
  const {
329
- label,
330
- border,
331
- colon
332
- } = props;
333
- return createVNode("div", {
334
- "class": [bem({
335
- "is-error": errorStatus.value,
336
- [getProp("size")]: getProp("size"),
337
- hairline: border
338
- }), gbem("el", {
339
- "hairline-bottom": border
185
+ label: n,
186
+ border: l,
187
+ colon: a
188
+ } = t;
189
+ return h("div", {
190
+ class: [b({
191
+ "is-error": A.value,
192
+ [f("size")]: f("size"),
193
+ hairline: l
194
+ }), le("el", {
195
+ "hairline-bottom": l
340
196
  })]
341
- }, [createVNode("label", {
342
- "class": bem("label", {
343
- "is-required": required.value
197
+ }, [h("label", {
198
+ class: b("label", {
199
+ "is-required": N.value
344
200
  }),
345
- "style": {
346
- width: getProp("labelWidth"),
347
- textAlign: getProp("labelAlign") || "left"
201
+ style: {
202
+ width: f("labelWidth"),
203
+ textAlign: f("labelAlign") || "left"
348
204
  }
349
- }, [(_a = slots.labelIcon) == null ? void 0 : _a.call(slots), label, colon ? " :" : ""]), createVNode("div", {
350
- "class": bem("content")
351
- }, [(_b = slots.default) == null ? void 0 : _b.call(slots), _renderError()]), (_c = slots.extra) == null ? void 0 : _c.call(slots)]);
205
+ }, [(u = e.labelIcon) == null ? void 0 : u.call(e), n, a ? " :" : ""]), h("div", {
206
+ class: b("content")
207
+ }, [(s = e.default) == null ? void 0 : s.call(e), V()]), (m = e.extra) == null ? void 0 : m.call(e)]);
352
208
  };
353
209
  }
354
210
  });
355
- const reset = "";
356
- const libs = "";
357
- const font = "";
358
- const animation = "";
359
- const theme = "";
360
- const style = "";
361
- FormItem.install = (Vue) => {
362
- Vue.component(FormItem.name, FormItem);
211
+ $.install = (t) => {
212
+ t.component($.name, $);
363
213
  };
364
214
  export {
365
- FormItem as default
215
+ $ as default
366
216
  };