y-design-ssr 0.2.1 → 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 (90) 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 +2 -2
@@ -1,11 +1,40 @@
1
- import { ref as h, reactive as b, defineComponent as B, onMounted as E, onBeforeUpdate as _, onUnmounted as D, watch as P, nextTick as k, createVNode as d, Fragment as R } from "vue";
2
- const v = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((c, n) => c + v(e, n), "") : Object.keys(t).reduce(
3
- (c, n) => c + (t[n] ? v(e, n) : ""),
4
- ""
5
- ) : "", L = (e) => (t, c) => {
6
- let n = t, f = c;
7
- return n && typeof n != "string" && (f = n, n = ""), n = n ? `${e}__${n}` : e, `${n}${v(n, f)}`;
8
- }, T = () => (e, t) => t ? `${v(`y-${e}`, t)}` : `y-${e}`, U = {
1
+ import { ref, reactive, defineComponent, onMounted, onBeforeUpdate, onUnmounted, watch, nextTick, createVNode, Fragment } from "vue";
2
+ const getMods = (el, mods) => {
3
+ if (!mods) {
4
+ return "";
5
+ }
6
+ if (typeof mods === "string") {
7
+ return ` ${el}--${mods}`;
8
+ }
9
+ if (Array.isArray(mods)) {
10
+ return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
11
+ }
12
+ return Object.keys(mods).reduce(
13
+ (acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
14
+ ""
15
+ );
16
+ };
17
+ const createBEM = (block) => {
18
+ return (el, mods) => {
19
+ let _el = el;
20
+ let _mods = mods;
21
+ if (_el && typeof _el !== "string") {
22
+ _mods = _el;
23
+ _el = "";
24
+ }
25
+ _el = _el ? `${block}__${_el}` : block;
26
+ return `${_el}${getMods(_el, _mods)}`;
27
+ };
28
+ };
29
+ const createGlobalBem = () => {
30
+ return (el, mods) => {
31
+ if (!mods) {
32
+ return `y-${el}`;
33
+ }
34
+ return `${getMods(`y-${el}`, mods)}`;
35
+ };
36
+ };
37
+ const defaultLang = {
9
38
  "pull-refresh": {
10
39
  pulling: "下拉刷新...",
11
40
  loosing: "释放刷新...",
@@ -17,15 +46,23 @@ const v = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t)
17
46
  validateMessage: "请输入正确内容"
18
47
  }
19
48
  };
20
- h("zh-CN");
21
- b({
22
- "zh-CN": U
49
+ ref("zh-CN");
50
+ reactive({
51
+ "zh-CN": defaultLang
23
52
  });
24
- const q = (e) => {
25
- const t = `y-${e}`;
26
- return [t, L(t), T()];
27
- }, x = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, [j, g] = q("progress"), $ = /* @__PURE__ */ B({
28
- name: j,
53
+ const createNamespace = (name2) => {
54
+ const prefixedName = `y-${name2}`;
55
+ return [prefixedName, createBEM(prefixedName), createGlobalBem()];
56
+ };
57
+ const parseUnit = (val) => {
58
+ if (isNaN(Number(val)) && typeof val === "string") {
59
+ return val;
60
+ }
61
+ return `${val}px`;
62
+ };
63
+ const [name, bem] = createNamespace("progress");
64
+ const Progress = /* @__PURE__ */ defineComponent({
65
+ name,
29
66
  props: {
30
67
  // 进度
31
68
  percent: {
@@ -65,12 +102,12 @@ const q = (e) => {
65
102
  // 展示默认pivot
66
103
  defaultPivot: {
67
104
  type: Boolean,
68
- default: !1
105
+ default: false
69
106
  },
70
107
  // 里程碑模式
71
108
  modeMilestone: {
72
109
  type: Boolean,
73
- default: !1
110
+ default: false
74
111
  },
75
112
  // 里程碑节点
76
113
  mileages: {
@@ -80,7 +117,7 @@ const q = (e) => {
80
117
  // 动画
81
118
  animation: {
82
119
  type: Boolean,
83
- default: !1
120
+ default: false
84
121
  },
85
122
  // 动画时长
86
123
  duration: {
@@ -98,147 +135,182 @@ const q = (e) => {
98
135
  default: "%"
99
136
  }
100
137
  },
101
- setup(e, {
102
- slots: t
138
+ setup(props, {
139
+ slots
103
140
  }) {
104
- const c = h(null), n = h(null), f = h([]), m = b({
141
+ const progressRef = ref(null);
142
+ const pivotContentRef = ref(null);
143
+ const mileageRef = ref([]);
144
+ const widthData = reactive({
105
145
  progressWidth: 0,
106
146
  pivotContentWidth: 0,
107
147
  mileageWidth: []
108
- }), i = b({
148
+ });
149
+ const growData = reactive({
109
150
  number: 0,
110
151
  oldPercent: 0,
111
152
  timer: 0
112
153
  });
113
- E(() => {
114
- y(), e.animation && W(), window.addEventListener("resize", y);
115
- }), _(() => {
116
- f.value = [];
117
- }), D(() => {
118
- i.timer && cancelAnimationFrame(i.timer), window.removeEventListener("resize", y);
119
- }), P(() => e.percent, () => {
120
- W(), w();
154
+ onMounted(() => {
155
+ resize();
156
+ props.animation && grow();
157
+ window.addEventListener("resize", resize);
158
+ });
159
+ onBeforeUpdate(() => {
160
+ mileageRef.value = [];
161
+ });
162
+ onUnmounted(() => {
163
+ growData.timer && cancelAnimationFrame(growData.timer);
164
+ window.removeEventListener("resize", resize);
165
+ });
166
+ watch(() => props.percent, () => {
167
+ grow();
168
+ resizeWidth();
121
169
  });
122
- const W = () => {
170
+ const grow = () => {
123
171
  const {
124
- duration: o,
125
- percent: r
126
- } = e, u = Math.abs(r - i.oldPercent) / (o / 16);
127
- if (u === 0)
172
+ duration,
173
+ percent
174
+ } = props;
175
+ const step = Math.abs(percent - growData.oldPercent) / (duration / 16);
176
+ if (step === 0)
128
177
  return;
129
- let a = Number(i.oldPercent);
130
- const l = () => {
131
- r > i.oldPercent ? a += u : a -= u, r > i.oldPercent && a > r || r < i.oldPercent && a < r ? a = r : i.timer = requestAnimationFrame(l), i.oldPercent = a, i.number = parseInt(a.toString());
178
+ let current = Number(growData.oldPercent);
179
+ const update = () => {
180
+ percent > growData.oldPercent ? current += step : current -= step;
181
+ if (percent > growData.oldPercent && current > percent || percent < growData.oldPercent && current < percent) {
182
+ current = percent;
183
+ } else {
184
+ growData.timer = requestAnimationFrame(update);
185
+ }
186
+ growData.oldPercent = current;
187
+ growData.number = parseInt(current.toString());
132
188
  };
133
- i.timer && cancelAnimationFrame(i.timer), i.timer = requestAnimationFrame(l);
189
+ growData.timer && cancelAnimationFrame(growData.timer);
190
+ growData.timer = requestAnimationFrame(update);
191
+ };
192
+ watch(() => props.mileages, () => resizeMileage);
193
+ const resize = () => {
194
+ resizeWidth();
195
+ resizeMileage();
134
196
  };
135
- P(() => e.mileages, () => C);
136
- const y = () => {
137
- w(), C();
138
- }, w = () => {
139
- k(() => {
140
- m.progressWidth = c.value && c.value.offsetWidth || 0, m.pivotContentWidth = n.value && n.value.offsetWidth || 0;
141
- }).catch((o) => {
142
- throw new Error(o);
197
+ const resizeWidth = () => {
198
+ nextTick(() => {
199
+ widthData.progressWidth = progressRef.value && progressRef.value.offsetWidth || 0;
200
+ widthData.pivotContentWidth = pivotContentRef.value && pivotContentRef.value.offsetWidth || 0;
201
+ }).catch((e) => {
202
+ throw new Error(e);
143
203
  });
144
- }, C = () => {
145
- k(() => {
146
- e.mileages.forEach((o, r) => {
147
- m.mileageWidth[r] = f.value[r] && f.value[r].offsetWidth || 0;
204
+ };
205
+ const resizeMileage = () => {
206
+ nextTick(() => {
207
+ props.mileages.forEach((_, i) => {
208
+ widthData.mileageWidth[i] = mileageRef.value[i] && mileageRef.value[i].offsetWidth || 0;
148
209
  });
149
- }).catch((o) => {
150
- throw new Error(o);
210
+ }).catch((e) => {
211
+ throw new Error(e);
151
212
  });
152
- }, M = () => {
153
- var l;
213
+ };
214
+ const renderMileage = () => {
215
+ var _a;
154
216
  const {
155
- mileages: o,
156
- percent: r,
157
- animation: u
158
- } = e, a = [];
159
- for (let s = 0; s < o.length; s++)
160
- a[s] = d("div", {
161
- ref: (p) => {
162
- p && (f.value[s] = p);
217
+ mileages,
218
+ percent,
219
+ animation: animation2
220
+ } = props;
221
+ const doms = [];
222
+ for (let i = 0; i < mileages.length; i++) {
223
+ doms[i] = createVNode("div", {
224
+ "ref": (el) => {
225
+ if (el)
226
+ mileageRef.value[i] = el;
163
227
  },
164
- class: [g("pivot-content", (u ? i.number : r) >= o[s] ? "arrive" : "no-arrive")],
165
- key: `mileage${s}`,
166
- style: {
167
- left: `${(m.progressWidth - m.mileageWidth[s]) * o[s] / 100}px`
228
+ "class": [bem("pivot-content", (animation2 ? growData.number : percent) >= mileages[i] ? "arrive" : "no-arrive")],
229
+ "key": `mileage${i}`,
230
+ "style": {
231
+ left: `${(widthData.progressWidth - widthData.mileageWidth[i]) * mileages[i] / 100}px`
168
232
  }
169
- }, [((l = t.mileage) == null ? void 0 : l.call(t)) || d("div", {
170
- class: g("pivot")
171
- }, [`${o[s]}%`])]);
172
- return a;
173
- }, S = () => {
174
- var s;
233
+ }, [((_a = slots.mileage) == null ? void 0 : _a.call(slots)) || createVNode("div", {
234
+ "class": bem("pivot")
235
+ }, [`${mileages[i]}%`])]);
236
+ }
237
+ return doms;
238
+ };
239
+ const renderPivot = () => {
240
+ var _a;
175
241
  const {
176
- defaultPivot: o,
177
- textColor: r,
178
- percent: u,
179
- animation: a,
180
- unit: l
181
- } = e;
182
- return d(R, null, [((s = t.pivot) == null ? void 0 : s.call(t)) || o && d("div", {
183
- class: g("pivot"),
184
- style: {
185
- color: r
242
+ defaultPivot,
243
+ textColor,
244
+ percent,
245
+ animation: animation2,
246
+ unit
247
+ } = props;
248
+ return createVNode(Fragment, null, [((_a = slots.pivot) == null ? void 0 : _a.call(slots)) || defaultPivot && createVNode("div", {
249
+ "class": bem("pivot"),
250
+ "style": {
251
+ color: textColor
186
252
  }
187
- }, [a ? d("div", {
188
- class: g("number")
189
- }, [d("span", null, [i.number, l])]) : `${u}${l}`])]);
253
+ }, [animation2 ? createVNode("div", {
254
+ "class": bem("number")
255
+ }, [createVNode("span", null, [growData.number, unit])]) : `${percent}${unit}`])]);
190
256
  };
191
257
  return () => {
192
258
  const {
193
- strokeWidth: o,
194
- trackColor: r,
195
- radius: u,
196
- percent: a,
197
- color: l,
198
- animation: s,
199
- duration: p,
200
- timing: N,
201
- defaultPivot: z,
202
- pivotColor: A,
203
- modeMilestone: F
204
- } = e;
205
- return d("div", {
206
- class: g(),
207
- ref: c,
208
- style: {
209
- height: x(o),
210
- background: r,
211
- borderRadius: x(u)
259
+ strokeWidth,
260
+ trackColor,
261
+ radius,
262
+ percent,
263
+ color,
264
+ animation: animation2,
265
+ duration,
266
+ timing,
267
+ defaultPivot,
268
+ pivotColor,
269
+ modeMilestone
270
+ } = props;
271
+ return createVNode("div", {
272
+ "class": bem(),
273
+ "ref": progressRef,
274
+ "style": {
275
+ height: parseUnit(strokeWidth),
276
+ background: trackColor,
277
+ borderRadius: parseUnit(radius)
212
278
  }
213
- }, [d("span", {
214
- class: g("portion", {
215
- animation: s
279
+ }, [createVNode("span", {
280
+ "class": bem("portion", {
281
+ animation: animation2
216
282
  }),
217
- style: {
218
- width: `${m.progressWidth * a / 100}px`,
219
- background: l,
220
- transitionDuration: `${p}ms`,
221
- transitionTimingFunction: N
283
+ "style": {
284
+ width: `${widthData.progressWidth * percent / 100}px`,
285
+ background: color,
286
+ transitionDuration: `${duration}ms`,
287
+ transitionTimingFunction: timing
222
288
  }
223
- }, [d("div", {
224
- ref: n,
225
- class: g("pivot-content", {
226
- animation: s
289
+ }, [createVNode("div", {
290
+ "ref": pivotContentRef,
291
+ "class": bem("pivot-content", {
292
+ animation: animation2
227
293
  }),
228
- style: {
229
- left: `${(m.progressWidth - m.pivotContentWidth) * a / 100}px`,
230
- background: z ? A || l : "none",
231
- transitionDuration: `${p}ms`,
232
- transitionTimingFunction: N
294
+ "style": {
295
+ left: `${(widthData.progressWidth - widthData.pivotContentWidth) * percent / 100}px`,
296
+ background: defaultPivot ? pivotColor || color : "none",
297
+ transitionDuration: `${duration}ms`,
298
+ transitionTimingFunction: timing
233
299
  }
234
- }, [S()])]), F && M()]);
300
+ }, [renderPivot()])]), modeMilestone && renderMileage()]);
235
301
  };
236
302
  }
237
303
  });
238
- $.install = (e) => {
239
- const { name: t } = $;
240
- e.component(t, $);
304
+ const reset = "";
305
+ const libs = "";
306
+ const font = "";
307
+ const animation = "";
308
+ const theme = "";
309
+ const style = "";
310
+ Progress.install = (Vue) => {
311
+ const { name: name2 } = Progress;
312
+ Vue.component(name2, Progress);
241
313
  };
242
314
  export {
243
- $ as default
315
+ Progress as default
244
316
  };