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