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,11 +1,40 @@
1
- import { ref as B, reactive as S, defineComponent as N, onMounted as z, createVNode as a, Transition as A, withDirectives as T, vShow as _, createApp as h, h as $ } from "vue";
2
- const f = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((r, n) => r + f(e, n), "") : Object.keys(t).reduce(
3
- (r, n) => r + (t[n] ? f(e, n) : ""),
4
- ""
5
- ) : "", D = (e) => (t, r) => {
6
- let n = t, o = r;
7
- return n && typeof n != "string" && (o = n, n = ""), n = n ? `${e}__${n}` : e, `${n}${f(n, o)}`;
8
- }, E = () => (e, t) => t ? `${f(`y-${e}`, t)}` : `y-${e}`, M = {
1
+ import { ref, reactive, defineComponent, onMounted, createVNode, Transition, withDirectives, vShow, createApp, h } 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,14 +46,22 @@ const f = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t)
17
46
  validateMessage: "请输入正确内容"
18
47
  }
19
48
  };
20
- B("zh-CN");
21
- S({
22
- "zh-CN": M
49
+ ref("zh-CN");
50
+ reactive({
51
+ "zh-CN": defaultLang
23
52
  });
24
- const v = (e) => {
25
- const t = `y-${e}`;
26
- return [t, D(t), E()];
27
- }, I = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, [L, d, j] = v("toast"), q = {
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$1, gBem] = createNamespace("toast");
64
+ const _props = {
28
65
  // 主文案
29
66
  title: {
30
67
  type: String,
@@ -48,67 +85,78 @@ const v = (e) => {
48
85
  // 关闭时回调
49
86
  onClose: {
50
87
  type: Function,
51
- required: !0
88
+ required: true
52
89
  },
53
90
  // 动画时长
54
91
  animationDuration: {
55
92
  type: [Number, String],
56
93
  default: 300
57
94
  }
58
- }, C = /* @__PURE__ */ N({
59
- name: L,
60
- props: q,
61
- setup(e, {
62
- slots: t
95
+ };
96
+ const Toast = /* @__PURE__ */ defineComponent({
97
+ name,
98
+ props: _props,
99
+ setup(props, {
100
+ slots
63
101
  }) {
64
- const r = S({
65
- visible: !1
102
+ const state = reactive({
103
+ visible: false
66
104
  // 控制v-show
67
- }), n = () => {
68
- const o = setTimeout(() => {
69
- r.visible = !1, clearTimeout(o);
70
- }, Number(e.duration));
105
+ });
106
+ const show = () => {
107
+ const timer = setTimeout(() => {
108
+ state.visible = false;
109
+ clearTimeout(timer);
110
+ }, Number(props.duration));
71
111
  };
72
- return z(() => {
73
- r.visible = !0, n();
74
- }), () => {
112
+ onMounted(() => {
113
+ state.visible = true;
114
+ show();
115
+ });
116
+ return () => {
75
117
  const {
76
- title: o,
77
- message: l,
78
- position: i,
79
- animationDuration: s,
80
- onClose: c
81
- } = e;
82
- return a(A, {
83
- name: j("animation", "fade"),
84
- onAfterLeave: c
118
+ title,
119
+ message,
120
+ position,
121
+ animationDuration,
122
+ onClose
123
+ } = props;
124
+ return createVNode(Transition, {
125
+ "name": gBem("animation", "fade"),
126
+ "onAfterLeave": onClose
85
127
  }, {
86
128
  default: () => {
87
- var u;
88
- return [T(a("div", {
89
- class: d({
90
- [i]: !0
129
+ var _a;
130
+ return [withDirectives(createVNode("div", {
131
+ "class": bem$1({
132
+ [position]: true
91
133
  }),
92
- style: {
93
- animationDuration: typeof s == "number" ? `${s}ms` : s
134
+ "style": {
135
+ animationDuration: typeof animationDuration === "number" ? `${animationDuration}ms` : animationDuration
94
136
  }
95
- }, [a("div", {
96
- class: d("content")
97
- }, [((u = t.icon) == null ? void 0 : u.call(t)) || null, a("div", {
98
- class: d("text")
99
- }, [o]), l && a("div", {
100
- class: d("message")
101
- }, [l])])]), [[_, r.visible]])];
137
+ }, [createVNode("div", {
138
+ "class": bem$1("content")
139
+ }, [((_a = slots.icon) == null ? void 0 : _a.call(slots)) || null, createVNode("div", {
140
+ "class": bem$1("text")
141
+ }, [title]), message && createVNode("div", {
142
+ "class": bem$1("message")
143
+ }, [message])])]), [[vShow, state.visible]])];
102
144
  }
103
145
  });
104
146
  };
105
147
  }
106
- }), [F, p] = v("icon"), G = (e) => new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/).test(e.toLowerCase()), m = /* @__PURE__ */ N({
107
- name: F,
148
+ });
149
+ const [cname, bem] = createNamespace("icon");
150
+ const isImage = (name2) => {
151
+ const re = new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/);
152
+ return re.test(name2.toLowerCase());
153
+ };
154
+ const Icon = /* @__PURE__ */ defineComponent({
155
+ name: cname,
108
156
  props: {
109
157
  dot: {
110
158
  type: Boolean,
111
- default: !1
159
+ default: false
112
160
  },
113
161
  name: {
114
162
  type: String,
@@ -151,81 +199,102 @@ const v = (e) => {
151
199
  }
152
200
  },
153
201
  emits: ["click"],
154
- setup(e, {
155
- slots: t,
156
- emit: r
202
+ setup(props, {
203
+ slots,
204
+ emit
157
205
  }) {
158
- const n = G(e.name), o = () => ({
159
- fontSize: I(e.size),
160
- color: e.color
161
- }), l = (i) => {
162
- r("click", i);
206
+ const isImg = isImage(props.name);
207
+ const getStyle = () => ({
208
+ fontSize: parseUnit(props.size),
209
+ color: props.color
210
+ });
211
+ const onClick = (event) => {
212
+ emit("click", event);
163
213
  };
164
214
  return () => {
165
215
  const {
166
- name: i,
167
- classPrefix: s,
168
- badge: c,
169
- dot: u,
170
- subColor: x,
171
- subBg: y,
172
- tag: k
173
- } = e;
174
- return a(k, {
175
- class: `${s}${n ? "" : ` y-icon--${i}`}`,
176
- style: o(),
177
- onClick: l
216
+ name: name2,
217
+ classPrefix,
218
+ badge,
219
+ dot,
220
+ subColor,
221
+ subBg,
222
+ tag: Tag
223
+ } = props;
224
+ return createVNode(Tag, {
225
+ "class": `${classPrefix}${isImg ? "" : ` y-icon--${name2}`}`,
226
+ "style": getStyle(),
227
+ "onClick": onClick
178
228
  }, {
179
229
  default: () => {
180
- var b;
181
- return [n ? a("em", {
182
- class: p("node")
183
- }, [a("img", {
184
- class: p("image"),
185
- src: i,
186
- alt: "icon"
187
- }, null)]) : null, u ? a("em", {
188
- class: p("dot"),
189
- style: {
190
- backgroundColor: y
230
+ var _a;
231
+ return [isImg ? createVNode("em", {
232
+ "class": bem("node")
233
+ }, [createVNode("img", {
234
+ "class": bem("image"),
235
+ "src": name2,
236
+ "alt": "icon"
237
+ }, null)]) : null, dot ? createVNode("em", {
238
+ "class": bem("dot"),
239
+ "style": {
240
+ backgroundColor: subBg
191
241
  }
192
- }, null) : null, c ? a("em", {
193
- class: p("badge"),
194
- style: {
195
- color: x,
196
- backgroundColor: y
242
+ }, null) : null, badge ? createVNode("em", {
243
+ "class": bem("badge"),
244
+ "style": {
245
+ color: subColor,
246
+ backgroundColor: subBg
197
247
  }
198
- }, [c]) : null, ((b = t.default) == null ? void 0 : b.call(t)) || null];
248
+ }, [badge]) : null, ((_a = slots.default) == null ? void 0 : _a.call(slots)) || null];
199
249
  }
200
250
  });
201
251
  };
202
252
  }
203
253
  });
204
- m.install = (e) => {
205
- const { name: t } = m;
206
- e.component(t, m);
254
+ const reset = "";
255
+ const libs = "";
256
+ const font = "";
257
+ const animation = "";
258
+ const theme = "";
259
+ const style$1 = "";
260
+ Icon.install = (app) => {
261
+ const { name: name2 } = Icon;
262
+ app.component(name2, Icon);
207
263
  };
208
- let g = h({}), P = 0;
209
- const w = [], R = (e, t) => {
210
- const r = `toast${P += 1}`;
211
- g = h({
212
- render: () => $(
213
- C,
214
- { ...e, onClose: () => U(r, e.onClose) },
215
- { icon: () => $(m, { ...t }) }
216
- )
217
- });
218
- const o = document.createElement("div");
219
- w.push({ id: r, app: g, el: o }), g.mount(o), document.body.appendChild(o);
220
- }, U = (e, t) => {
221
- w.forEach((r) => {
222
- e === r.id && (r.app.unmount(), document.body.removeChild(r.el), t == null || t());
264
+ let toastApp = createApp({});
265
+ let num = 0;
266
+ const treasures = [];
267
+ const toastCreate = (customProps, iconProps) => {
268
+ const id = `toast${num += 1}`;
269
+ const wrapper = {
270
+ render: () => {
271
+ return h(
272
+ Toast,
273
+ { ...customProps, onClose: () => close(id, customProps.onClose) },
274
+ { icon: () => h(Icon, { ...iconProps }) }
275
+ );
276
+ }
277
+ };
278
+ toastApp = createApp(wrapper);
279
+ const element = document.createElement("div");
280
+ treasures.push({ id, app: toastApp, el: element });
281
+ toastApp.mount(element);
282
+ document.body.appendChild(element);
283
+ };
284
+ const close = (id, userOnClose) => {
285
+ treasures.forEach((obj) => {
286
+ if (id === obj.id) {
287
+ obj.app.unmount();
288
+ document.body.removeChild(obj.el);
289
+ userOnClose == null ? void 0 : userOnClose();
290
+ }
223
291
  });
224
292
  };
225
- C.install = (e) => {
226
- e.provide("toast", R);
293
+ const style = "";
294
+ Toast.install = (app) => {
295
+ app.provide("toast", toastCreate);
227
296
  };
228
297
  export {
229
- C as default,
230
- R as toastCreate
298
+ Toast as default,
299
+ toastCreate
231
300
  };