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 m, reactive as v, getCurrentInstance as y, provide as _, isVNode as j, inject as A, onUnmounted as L, computed as l, defineComponent as $, createVNode as x } from "vue";
2
- const p = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((n, r) => n + p(e, r), "") : Object.keys(t).reduce(
3
- (n, r) => n + (t[r] ? p(e, r) : ""),
4
- ""
5
- ) : "", P = (e) => (t, n) => {
6
- let r = t, i = n;
7
- return r && typeof r != "string" && (i = r, r = ""), r = r ? `${e}__${r}` : e, `${r}${p(r, i)}`;
8
- }, B = () => (e, t) => t ? `${p(`y-${e}`, t)}` : `y-${e}`, M = {
1
+ import { ref, reactive, getCurrentInstance, provide, isVNode, inject, onUnmounted, computed, defineComponent, createVNode } 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,61 +46,106 @@ const p = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t)
17
46
  validateMessage: "请输入正确内容"
18
47
  }
19
48
  };
20
- m("zh-CN");
21
- v({
22
- "zh-CN": M
49
+ ref("zh-CN");
50
+ reactive({
51
+ "zh-CN": defaultLang
23
52
  });
24
- const b = (e) => {
25
- const t = `y-${e}`;
26
- return [t, P(t), B()];
53
+ const createNamespace = (name2) => {
54
+ const prefixedName = `y-${name2}`;
55
+ return [prefixedName, createBEM(prefixedName), createGlobalBem()];
27
56
  };
28
- var C = /* @__PURE__ */ ((e) => (e.Top = "top", e.Middle = "middle", e.Bottom = "bottom", e))(C || {});
29
- const S = Symbol("Y-Row");
30
- var T = /* @__PURE__ */ ((e) => (e.Flex = "flex", e.Default = "", e))(T || {}), N = /* @__PURE__ */ ((e) => (e.Start = "start", e.Center = "center", e.End = "end", e.SpaceBetween = "space-between", e.SpaceAround = "space-around", e))(N || {});
31
- const I = (e) => {
32
- const t = [], n = (r) => {
33
- Array.isArray(r) && r.forEach((i) => {
34
- var a;
35
- j(i) && (t.push(i), (a = i.component) != null && a.subTree && n(i.component.subTree.children), i.children && n(i.children));
57
+ var Vertical = /* @__PURE__ */ ((Vertical2) => {
58
+ Vertical2["Top"] = "top";
59
+ Vertical2["Middle"] = "middle";
60
+ Vertical2["Bottom"] = "bottom";
61
+ return Vertical2;
62
+ })(Vertical || {});
63
+ const ROW_PROVIDE = Symbol("Y-Row");
64
+ var RowType = /* @__PURE__ */ ((RowType2) => {
65
+ RowType2["Flex"] = "flex";
66
+ RowType2["Default"] = "";
67
+ return RowType2;
68
+ })(RowType || {});
69
+ var RowJustify = /* @__PURE__ */ ((RowJustify2) => {
70
+ RowJustify2["Start"] = "start";
71
+ RowJustify2["Center"] = "center";
72
+ RowJustify2["End"] = "end";
73
+ RowJustify2["SpaceBetween"] = "space-between";
74
+ RowJustify2["SpaceAround"] = "space-around";
75
+ return RowJustify2;
76
+ })(RowJustify || {});
77
+ const filterChildren = (children) => {
78
+ const vnodes = [];
79
+ const _filterChildren = (childrens) => {
80
+ if (Array.isArray(childrens)) {
81
+ childrens.forEach((child) => {
82
+ var _a;
83
+ if (isVNode(child)) {
84
+ vnodes.push(child);
85
+ if ((_a = child.component) == null ? void 0 : _a.subTree) {
86
+ _filterChildren(child.component.subTree.children);
87
+ }
88
+ if (child.children) {
89
+ _filterChildren(child.children);
90
+ }
91
+ }
92
+ });
93
+ }
94
+ };
95
+ _filterChildren(children);
96
+ return vnodes;
97
+ };
98
+ const sortChildren = (childrens, instance) => {
99
+ const vnodes = filterChildren(instance.subTree.children);
100
+ childrens.sort((a, b) => vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode));
101
+ };
102
+ const setRelation = (key) => {
103
+ const instance = getCurrentInstance();
104
+ const childrens = reactive([]);
105
+ const initProvide = (value) => {
106
+ const addChild = (child) => {
107
+ if (child.proxy) {
108
+ childrens.push(child);
109
+ instance && sortChildren(childrens, instance);
110
+ }
111
+ };
112
+ const removeChild = (child) => {
113
+ const index = childrens.indexOf(child);
114
+ childrens.splice(index, 1);
115
+ };
116
+ provide(key, {
117
+ addChild,
118
+ removeChild,
119
+ childrens,
120
+ ...value
36
121
  });
37
122
  };
38
- return n(e), t;
39
- }, z = (e, t) => {
40
- const n = I(t.subTree.children);
41
- e.sort((r, i) => n.indexOf(r.vnode) - n.indexOf(i.vnode));
42
- }, D = (e) => {
43
- const t = y(), n = v([]);
44
123
  return {
45
- childrens: n,
46
- initProvide: (i) => {
47
- _(e, {
48
- addChild: (o) => {
49
- o.proxy && (n.push(o), t && z(n, t));
50
- },
51
- removeChild: (o) => {
52
- const c = n.indexOf(o);
53
- n.splice(c, 1);
54
- },
55
- childrens: n,
56
- ...i
57
- });
58
- }
124
+ childrens,
125
+ initProvide
59
126
  };
60
- }, R = (e) => {
61
- const t = A(e, null), n = y();
62
- if (t && n) {
63
- const { childrens: r, addChild: i, removeChild: a } = t;
64
- return i(n), L(() => a(n)), {
65
- index: l(() => r.indexOf(n)),
66
- parent: t
127
+ };
128
+ const useRelation = (key) => {
129
+ const parent = inject(key, null);
130
+ const currentInstance = getCurrentInstance();
131
+ if (parent && currentInstance) {
132
+ const { childrens, addChild, removeChild } = parent;
133
+ addChild(currentInstance);
134
+ onUnmounted(() => removeChild(currentInstance));
135
+ const index = computed(() => childrens.indexOf(currentInstance));
136
+ return {
137
+ index,
138
+ parent
67
139
  };
68
140
  }
69
141
  return {
70
142
  parent: null,
71
- index: m(-1)
143
+ index: ref(-1)
72
144
  };
73
- }, [F, G] = b("row"), f = /* @__PURE__ */ $({
74
- name: F,
145
+ };
146
+ const [name$1, bem$1] = createNamespace("row");
147
+ const Row = /* @__PURE__ */ defineComponent({
148
+ name: name$1,
75
149
  props: {
76
150
  type: {
77
151
  type: String,
@@ -84,66 +158,83 @@ const I = (e) => {
84
158
  },
85
159
  align: {
86
160
  type: String,
87
- default: C.Top
161
+ default: Vertical.Top
88
162
  },
89
163
  justify: {
90
164
  type: String,
91
- default: N.Start
165
+ default: RowJustify.Start
92
166
  }
93
167
  },
94
- setup(e, {
95
- slots: t
168
+ setup(props, {
169
+ slots
96
170
  }) {
97
171
  const {
98
- childrens: n,
99
- initProvide: r
100
- } = D(S), i = l(() => {
101
- const s = [[]];
102
- let o = 0;
103
- return n.forEach((c, u) => {
104
- var d;
105
- o += Number((d = c.proxy) == null ? void 0 : d.span), o > 24 ? (s.push([u]), o -= 24) : s[s.length - 1].push(u);
106
- }), s;
107
- }), a = l(() => {
108
- const s = Number(e.gutter), o = [];
109
- return s && i.value.forEach((c) => {
110
- const u = s * (c.length - 1) / c.length;
111
- c.forEach((d, E) => {
112
- if (E === 0)
113
- o.push({
114
- right: u,
172
+ childrens,
173
+ initProvide
174
+ } = setRelation(ROW_PROVIDE);
175
+ const groupList = computed(() => {
176
+ const groups = [[]];
177
+ let totalSpan = 0;
178
+ childrens.forEach((child, index) => {
179
+ var _a;
180
+ totalSpan += Number((_a = child.proxy) == null ? void 0 : _a.span);
181
+ if (totalSpan > 24) {
182
+ groups.push([index]);
183
+ totalSpan -= 24;
184
+ } else {
185
+ groups[groups.length - 1].push(index);
186
+ }
187
+ });
188
+ return groups;
189
+ });
190
+ const spaceList = computed(() => {
191
+ const gutter = Number(props.gutter);
192
+ const spaces = [];
193
+ if (!gutter)
194
+ return spaces;
195
+ groupList.value.forEach((group) => {
196
+ const averagePadding = gutter * (group.length - 1) / group.length;
197
+ group.forEach((item, index) => {
198
+ if (index === 0) {
199
+ spaces.push({
200
+ right: averagePadding,
115
201
  left: 0
116
202
  });
117
- else {
118
- const h = s - o[d - 1].right, O = u - h;
119
- o.push({
120
- left: h,
121
- right: O
203
+ } else {
204
+ const left = gutter - spaces[item - 1].right;
205
+ const right = averagePadding - left;
206
+ spaces.push({
207
+ left,
208
+ right
122
209
  });
123
210
  }
124
211
  });
125
- }), o;
212
+ });
213
+ return spaces;
126
214
  });
127
- return r({
128
- spaceList: a
129
- }), () => {
130
- var u;
215
+ initProvide({
216
+ spaceList
217
+ });
218
+ return () => {
219
+ var _a;
131
220
  const {
132
- type: s,
133
- align: o,
134
- justify: c
135
- } = e;
136
- return x("div", {
137
- class: G({
138
- [s]: s,
139
- [`align-${o}`]: s && o,
140
- [`justify-${c}`]: s && c
221
+ type,
222
+ align,
223
+ justify
224
+ } = props;
225
+ return createVNode("div", {
226
+ "class": bem$1({
227
+ [type]: type,
228
+ [`align-${align}`]: type && align,
229
+ [`justify-${justify}`]: type && justify
141
230
  })
142
- }, [(u = t.default) == null ? void 0 : u.call(t)]);
231
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
143
232
  };
144
233
  }
145
- }), [U, V] = b("col"), g = /* @__PURE__ */ $({
146
- name: U,
234
+ });
235
+ const [name, bem] = createNamespace("col");
236
+ const Col = /* @__PURE__ */ defineComponent({
237
+ name,
147
238
  props: {
148
239
  // 列数
149
240
  span: {
@@ -156,57 +247,66 @@ const I = (e) => {
156
247
  default: 0
157
248
  }
158
249
  },
159
- setup(e, {
160
- slots: t
250
+ setup(props, {
251
+ slots
161
252
  }) {
162
253
  const {
163
- parent: n,
164
- index: r
165
- } = R(S), i = l(() => {
166
- if (!n)
254
+ parent,
255
+ index
256
+ } = useRelation(ROW_PROVIDE);
257
+ const style2 = computed(() => {
258
+ if (!parent) {
167
259
  return {};
260
+ }
168
261
  const {
169
- spaceList: a
170
- } = n, s = a.value;
171
- if (s.length === 0)
262
+ spaceList
263
+ } = parent;
264
+ const spaces = spaceList.value;
265
+ if (spaces.length === 0)
172
266
  return {};
173
267
  const {
174
- left: o,
175
- right: c
176
- } = s[r.value];
268
+ left,
269
+ right
270
+ } = spaces[index.value];
177
271
  return {
178
- paddingLeft: o ? `${o}px` : 0,
179
- paddingRight: c ? `${c}px` : 0
272
+ paddingLeft: left ? `${left}px` : 0,
273
+ paddingRight: right ? `${right}px` : 0
180
274
  };
181
275
  });
182
276
  return () => {
183
- var o;
277
+ var _a;
184
278
  const {
185
- span: a,
186
- offset: s
187
- } = e;
188
- return x("div", {
189
- style: i.value,
190
- class: V({
191
- [a]: a,
192
- [`offset-${s}`]: s
279
+ span,
280
+ offset
281
+ } = props;
282
+ return createVNode("div", {
283
+ "style": style2.value,
284
+ "class": bem({
285
+ [span]: span,
286
+ [`offset-${offset}`]: offset
193
287
  })
194
- }, [(o = t.default) == null ? void 0 : o.call(t)]);
288
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
195
289
  };
196
290
  }
197
291
  });
198
- f.install = (e) => {
199
- const { name: t } = f;
200
- e.component(t, f);
292
+ const reset = "";
293
+ const libs = "";
294
+ const font = "";
295
+ const animation = "";
296
+ const theme = "";
297
+ const style = "";
298
+ Row.install = (app) => {
299
+ const { name: name2 } = Row;
300
+ app.component(name2, Row);
201
301
  };
202
- g.install = (e) => {
203
- const { name: t } = g;
204
- e.component(t, g);
302
+ Col.install = (app) => {
303
+ const { name: name2 } = Col;
304
+ app.component(name2, Col);
205
305
  };
206
306
  export {
207
- g as Col,
208
- S as ROW_PROVIDE,
209
- f as Row,
210
- N as RowJustify,
211
- T as RowType
307
+ Col,
308
+ ROW_PROVIDE,
309
+ Row,
310
+ RowJustify,
311
+ RowType
212
312
  };