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 z, reactive as E, inject as I, getCurrentInstance as N, watch as j, onUnmounted as B, defineComponent as V, createVNode as i, computed as f, onBeforeUnmount as w } from "vue";
2
- const C = (e, n) => n ? typeof n == "string" ? ` ${e}--${n}` : Array.isArray(n) ? n.reduce((a, l) => a + C(e, l), "") : Object.keys(n).reduce(
3
- (a, l) => a + (n[l] ? C(e, l) : ""),
4
- ""
5
- ) : "", M = (e) => (n, a) => {
6
- let l = n, t = a;
7
- return l && typeof l != "string" && (t = l, l = ""), l = l ? `${e}__${l}` : e, `${l}${C(l, t)}`;
8
- }, q = () => (e, n) => n ? `${C(`y-${e}`, n)}` : `y-${e}`, F = {
1
+ import { ref, reactive, inject, getCurrentInstance, watch, onUnmounted, defineComponent, createVNode, computed, onBeforeUnmount } 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,35 +46,58 @@ const C = (e, n) => n ? typeof n == "string" ? ` ${e}--${n}` : Array.isArray(n)
17
46
  validateMessage: "请输入正确内容"
18
47
  }
19
48
  };
20
- z("zh-CN");
21
- E({
22
- "zh-CN": F
49
+ ref("zh-CN");
50
+ reactive({
51
+ "zh-CN": defaultLang
23
52
  });
24
- const $ = (e) => {
25
- const n = `y-${e}`;
26
- return [n, M(n), q()];
27
- }, O = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, P = "y-form-item", R = () => {
28
- const e = I(P, null), n = N();
29
- if (e && (n != null && n.proxy)) {
30
- const { setField: a } = e, { resetValidation: l, change: t, validateWithTrigger: u } = e;
31
- return j(
32
- () => n.proxy.modelValue,
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 FORM_ITEM_PROVIDE = "y-form-item";
64
+ const useFormItem = () => {
65
+ const parent = inject(FORM_ITEM_PROVIDE, null);
66
+ const instance = getCurrentInstance();
67
+ if (parent && (instance == null ? void 0 : instance.proxy)) {
68
+ const { setField } = parent;
69
+ const { resetValidation, change, validateWithTrigger } = parent;
70
+ watch(
71
+ () => instance.proxy.modelValue,
33
72
  () => {
34
- e.instance && e.instance.exposed && (l(), t(), u("onChange"));
73
+ if (parent.instance && parent.instance.exposed) {
74
+ resetValidation();
75
+ change();
76
+ validateWithTrigger("onChange");
77
+ }
35
78
  }
36
- ), a(n), B(() => a(null)), {
37
- parent: e
79
+ );
80
+ setField(instance);
81
+ onUnmounted(() => setField(null));
82
+ return {
83
+ parent
38
84
  };
39
85
  }
40
86
  return {
41
87
  parent: null
42
88
  };
43
- }, [T, b] = $("icon"), U = (e) => new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/).test(e.toLowerCase()), p = /* @__PURE__ */ V({
44
- name: T,
89
+ };
90
+ const [cname, bem$2] = createNamespace("icon");
91
+ const isImage = (name2) => {
92
+ const re = new RegExp(/\.(https|png|jpg|gif|jpeg|webp|apng)$/);
93
+ return re.test(name2.toLowerCase());
94
+ };
95
+ const Icon = /* @__PURE__ */ defineComponent({
96
+ name: cname,
45
97
  props: {
46
98
  dot: {
47
99
  type: Boolean,
48
- default: !1
100
+ default: false
49
101
  },
50
102
  name: {
51
103
  type: String,
@@ -88,79 +140,95 @@ const $ = (e) => {
88
140
  }
89
141
  },
90
142
  emits: ["click"],
91
- setup(e, {
92
- slots: n,
93
- emit: a
143
+ setup(props, {
144
+ slots,
145
+ emit
94
146
  }) {
95
- const l = U(e.name), t = () => ({
96
- fontSize: O(e.size),
97
- color: e.color
98
- }), u = (o) => {
99
- a("click", o);
147
+ const isImg = isImage(props.name);
148
+ const getStyle = () => ({
149
+ fontSize: parseUnit(props.size),
150
+ color: props.color
151
+ });
152
+ const onClick = (event) => {
153
+ emit("click", event);
100
154
  };
101
155
  return () => {
102
156
  const {
103
- name: o,
104
- classPrefix: m,
105
- badge: g,
106
- dot: y,
107
- subColor: v,
108
- subBg: c,
109
- tag: h
110
- } = e;
111
- return i(h, {
112
- class: `${m}${l ? "" : ` y-icon--${o}`}`,
113
- style: t(),
114
- onClick: u
157
+ name: name2,
158
+ classPrefix,
159
+ badge,
160
+ dot,
161
+ subColor,
162
+ subBg,
163
+ tag: Tag
164
+ } = props;
165
+ return createVNode(Tag, {
166
+ "class": `${classPrefix}${isImg ? "" : ` y-icon--${name2}`}`,
167
+ "style": getStyle(),
168
+ "onClick": onClick
115
169
  }, {
116
170
  default: () => {
117
- var d;
118
- return [l ? i("em", {
119
- class: b("node")
120
- }, [i("img", {
121
- class: b("image"),
122
- src: o,
123
- alt: "icon"
124
- }, null)]) : null, y ? i("em", {
125
- class: b("dot"),
126
- style: {
127
- backgroundColor: c
171
+ var _a;
172
+ return [isImg ? createVNode("em", {
173
+ "class": bem$2("node")
174
+ }, [createVNode("img", {
175
+ "class": bem$2("image"),
176
+ "src": name2,
177
+ "alt": "icon"
178
+ }, null)]) : null, dot ? createVNode("em", {
179
+ "class": bem$2("dot"),
180
+ "style": {
181
+ backgroundColor: subBg
128
182
  }
129
- }, null) : null, g ? i("em", {
130
- class: b("badge"),
131
- style: {
132
- color: v,
133
- backgroundColor: c
183
+ }, null) : null, badge ? createVNode("em", {
184
+ "class": bem$2("badge"),
185
+ "style": {
186
+ color: subColor,
187
+ backgroundColor: subBg
134
188
  }
135
- }, [g]) : null, ((d = n.default) == null ? void 0 : d.call(n)) || null];
189
+ }, [badge]) : null, ((_a = slots.default) == null ? void 0 : _a.call(slots)) || null];
136
190
  }
137
191
  });
138
192
  };
139
193
  }
140
194
  });
141
- p.install = (e) => {
142
- const { name: n } = p;
143
- e.component(n, p);
195
+ const reset = "";
196
+ const libs = "";
197
+ const font = "";
198
+ const animation = "";
199
+ const theme = "";
200
+ const style$1 = "";
201
+ Icon.install = (app) => {
202
+ const { name: name2 } = Icon;
203
+ app.component(name2, Icon);
144
204
  };
145
- const A = (e) => {
146
- const n = I(e, null), a = N();
147
- if (n && a) {
148
- const { childrens: l, addChild: t, removeChild: u } = n;
149
- return t(a), B(() => u(a)), {
150
- index: f(() => l.indexOf(a)),
151
- parent: n
205
+ const useRelation = (key) => {
206
+ const parent = inject(key, null);
207
+ const currentInstance = getCurrentInstance();
208
+ if (parent && currentInstance) {
209
+ const { childrens, addChild, removeChild } = parent;
210
+ addChild(currentInstance);
211
+ onUnmounted(() => removeChild(currentInstance));
212
+ const index = computed(() => childrens.indexOf(currentInstance));
213
+ return {
214
+ index,
215
+ parent
152
216
  };
153
217
  }
154
218
  return {
155
219
  parent: null,
156
- index: z(-1)
220
+ index: ref(-1)
157
221
  };
158
- }, [K, H] = $("checkbox-group"), L = K, [D, k] = $("checkbox"), x = /* @__PURE__ */ V({
159
- name: D,
222
+ };
223
+ const [name$1, bem$1] = createNamespace("checkbox-group");
224
+ const CHECKBOX_KEY = name$1;
225
+ const [name, bem] = createNamespace("checkbox");
226
+ const Checkbox = /* @__PURE__ */ defineComponent({
227
+ name,
160
228
  props: {
161
229
  modelValue: {
162
230
  type: Boolean,
163
- default: !1
231
+ default: false
164
232
  },
165
233
  name: {
166
234
  type: String,
@@ -168,7 +236,7 @@ const A = (e) => {
168
236
  },
169
237
  disabled: {
170
238
  type: Boolean,
171
- default: !1
239
+ default: false
172
240
  },
173
241
  size: {
174
242
  type: [String, Number],
@@ -176,73 +244,120 @@ const A = (e) => {
176
244
  },
177
245
  square: {
178
246
  type: Boolean,
179
- default: !0
247
+ default: true
180
248
  },
181
249
  checkedColor: {
182
250
  type: String,
183
251
  default: ""
184
252
  }
185
253
  },
186
- setup(e, {
187
- slots: n,
188
- emit: a,
189
- expose: l
254
+ setup(props, {
255
+ slots,
256
+ emit,
257
+ expose
190
258
  }) {
191
259
  const {
192
- parent: t
193
- } = A(L), u = t === null ? R().parent : null;
194
- t && t.allItemNames.push(e.name);
195
- const o = (r, s = null) => f(() => t && t.props[r] !== null ? t.props[r] : Object.keys(e).includes(r) ? e[r] : s), m = o("disabled"), g = o("square"), y = o("checkedColor"), v = o("horizontal", !1), c = f(() => t ? t.props.modelValue.includes(e.name) : e.modelValue), h = (r) => {
196
- var s;
197
- m.value || typeof r < "u" && c.value === r || ((s = t == null ? void 0 : t.onItemChange) == null || s.call(t, e.name), a("update:modelValue", !e.modelValue), a("change", !e.modelValue));
260
+ parent
261
+ } = useRelation(CHECKBOX_KEY);
262
+ const formParent = parent === null ? useFormItem().parent : null;
263
+ if (parent) {
264
+ parent.allItemNames.push(props.name);
265
+ }
266
+ const getComputedFromParent = (propsName, defaultValue = null) => {
267
+ return computed(() => {
268
+ if (parent && parent.props[propsName] !== null) {
269
+ return parent.props[propsName];
270
+ }
271
+ if (Object.keys(props).includes(propsName)) {
272
+ return props[propsName];
273
+ }
274
+ return defaultValue;
275
+ });
198
276
  };
199
- l({
200
- toggle: h
277
+ const disabled = getComputedFromParent("disabled");
278
+ const square = getComputedFromParent("square");
279
+ const checkedColor = getComputedFromParent("checkedColor");
280
+ const horizontal = getComputedFromParent("horizontal", false);
281
+ const checked = computed(() => {
282
+ if (parent) {
283
+ return parent.props.modelValue.includes(props.name);
284
+ }
285
+ return props.modelValue;
201
286
  });
202
- const d = f(() => ["mini", "small", "middle", "large"].includes(e.size.toString() || (u == null ? void 0 : u.getProp("size"))) ? null : O(e.size)), _ = f(() => {
203
- const r = {};
204
- return d.value && (r.width = d.value, r.height = d.value), c.value && y.value && (r.backgroundColor = y.value), r;
287
+ const toggle = (toChecked) => {
288
+ var _a;
289
+ if (disabled.value)
290
+ return;
291
+ if (typeof toChecked !== "undefined" && checked.value === toChecked)
292
+ return;
293
+ (_a = parent == null ? void 0 : parent.onItemChange) == null ? void 0 : _a.call(parent, props.name);
294
+ emit("update:modelValue", !props.modelValue);
295
+ emit("change", !props.modelValue);
296
+ };
297
+ expose({
298
+ toggle
205
299
  });
206
- return w(() => {
207
- if (!t)
300
+ const iconSize = computed(() => {
301
+ if (["mini", "small", "middle", "large"].includes(props.size.toString() || (formParent == null ? void 0 : formParent.getProp("size")))) {
302
+ return null;
303
+ }
304
+ return parseUnit(props.size);
305
+ });
306
+ const iconStyle = computed(() => {
307
+ const style2 = {};
308
+ if (iconSize.value) {
309
+ style2.width = iconSize.value;
310
+ style2.height = iconSize.value;
311
+ }
312
+ if (checked.value && checkedColor.value) {
313
+ style2.backgroundColor = checkedColor.value;
314
+ }
315
+ return style2;
316
+ });
317
+ onBeforeUnmount(() => {
318
+ if (!parent)
208
319
  return;
209
- const r = t.allItemNames.indexOf(e.name);
210
- r >= 0 && t.allItemNames.splice(r, 1);
211
- }), () => {
212
- var s, S;
320
+ const index = parent.allItemNames.indexOf(props.name);
321
+ if (index >= 0) {
322
+ parent.allItemNames.splice(index, 1);
323
+ }
324
+ });
325
+ return () => {
326
+ var _a, _b;
213
327
  const {
214
- size: r
215
- } = e;
216
- return i("div", {
217
- class: k({
218
- disabled: m.value,
219
- checked: c.value,
220
- horizontal: v.value,
221
- [r]: ["mini", "small", "middle", "large"].includes(r.toString())
328
+ size
329
+ } = props;
330
+ return createVNode("div", {
331
+ "class": bem({
332
+ disabled: disabled.value,
333
+ checked: checked.value,
334
+ horizontal: horizontal.value,
335
+ [size]: ["mini", "small", "middle", "large"].includes(size.toString())
222
336
  }),
223
- onClick: () => h(),
224
- role: "checkbox",
225
- "aria-checked": c.value
226
- }, [((s = n.icon) == null ? void 0 : s.call(n, {
227
- checked: c.value
228
- })) || i("div", {
229
- class: k("icon", {
230
- checked: c.value,
231
- square: g.value
337
+ "onClick": () => toggle(),
338
+ "role": "checkbox",
339
+ "aria-checked": checked.value
340
+ }, [((_a = slots.icon) == null ? void 0 : _a.call(slots, {
341
+ checked: checked.value
342
+ })) || createVNode("div", {
343
+ "class": bem("icon", {
344
+ checked: checked.value,
345
+ square: square.value
232
346
  }),
233
- style: _.value
234
- }, [c.value ? i(p, {
235
- name: "done"
236
- }, null) : null]), i("div", {
237
- class: k("label")
238
- }, [(S = n.default) == null ? void 0 : S.call(n)])]);
347
+ "style": iconStyle.value
348
+ }, [checked.value ? createVNode(Icon, {
349
+ "name": "done"
350
+ }, null) : null]), createVNode("div", {
351
+ "class": bem("label")
352
+ }, [(_b = slots.default) == null ? void 0 : _b.call(slots)])]);
239
353
  };
240
354
  }
241
355
  });
242
- x.install = (e) => {
243
- const { name: n } = x;
244
- e.component(n, x);
356
+ const style = "";
357
+ Checkbox.install = (Vue) => {
358
+ const { name: name2 } = Checkbox;
359
+ Vue.component(name2, Checkbox);
245
360
  };
246
361
  export {
247
- x as default
362
+ Checkbox as default
248
363
  };