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.
- package/libs/button/index.css +579 -1
- package/libs/button/index.mjs +111 -66
- package/libs/button/index.umd.js +203 -2
- package/libs/cell/index.css +1077 -1
- package/libs/cell/index.mjs +167 -104
- package/libs/cell/index.umd.js +300 -2
- package/libs/checkbox/index.css +1053 -1
- package/libs/checkbox/index.mjs +242 -127
- package/libs/checkbox/index.umd.js +369 -2
- package/libs/checkboxGroup/index.css +422 -1
- package/libs/checkboxGroup/index.mjs +173 -87
- package/libs/checkboxGroup/index.umd.js +265 -2
- package/libs/col/index.css +615 -1
- package/libs/col/index.mjs +246 -81
- package/libs/col/index.umd.js +305 -2
- package/libs/countdown/index.css +417 -1
- package/libs/countdown/index.mjs +179 -71
- package/libs/countdown/index.umd.js +231 -2
- package/libs/dialog/index.css +1405 -1
- package/libs/dialog/index.mjs +646 -476
- package/libs/dialog/index.umd.js +1128 -2
- package/libs/empty/index.css +457 -1
- package/libs/empty/index.mjs +91 -44
- package/libs/empty/index.umd.js +139 -2
- package/libs/form/index.css +477 -1
- package/libs/form/index.mjs +226 -126
- package/libs/form/index.umd.js +319 -2
- package/libs/formItem/index.css +477 -1
- package/libs/formItem/index.mjs +276 -126
- package/libs/formItem/index.umd.js +372 -2
- package/libs/icon/index.css +982 -1
- package/libs/icon/index.mjs +107 -58
- package/libs/icon/index.umd.js +186 -2
- package/libs/index.css +2902 -1
- package/libs/index.mjs +3785 -2344
- package/libs/index.umd.js +5509 -2
- package/libs/input/index.css +483 -1
- package/libs/input/index.mjs +183 -92
- package/libs/input/index.umd.js +274 -2
- package/libs/layout/index.css +684 -1
- package/libs/layout/index.mjs +230 -130
- package/libs/layout/index.umd.js +318 -2
- package/libs/list/index.css +440 -1
- package/libs/list/index.mjs +388 -207
- package/libs/list/index.umd.js +571 -2
- package/libs/loading/index.css +548 -1
- package/libs/loading/index.mjs +196 -118
- package/libs/loading/index.umd.js +321 -2
- package/libs/mask/index.css +426 -1
- package/libs/mask/index.mjs +131 -70
- package/libs/mask/index.umd.js +201 -2
- package/libs/popup/index.css +465 -1
- package/libs/popup/index.mjs +210 -134
- package/libs/popup/index.umd.js +358 -2
- package/libs/progress/index.css +488 -1
- package/libs/progress/index.mjs +200 -128
- package/libs/progress/index.umd.js +322 -2
- package/libs/pullrefresh/index.css +441 -1
- package/libs/pullrefresh/index.mjs +241 -111
- package/libs/pullrefresh/index.umd.js +302 -2
- package/libs/row/index.css +485 -1
- package/libs/row/index.mjs +181 -89
- package/libs/row/index.umd.js +237 -2
- package/libs/slider/index.css +558 -1
- package/libs/slider/index.mjs +356 -160
- package/libs/slider/index.umd.js +453 -2
- package/libs/stepper/index.css +489 -1
- package/libs/stepper/index.mjs +181 -101
- package/libs/stepper/index.umd.js +269 -2
- package/libs/swipe/index.css +506 -1
- package/libs/swipe/index.mjs +542 -259
- package/libs/swipe/index.umd.js +703 -2
- package/libs/swipeItem/index.css +424 -1
- package/libs/swipeItem/index.mjs +111 -52
- package/libs/swipeItem/index.umd.js +154 -2
- package/libs/switch/index.css +472 -1
- package/libs/switch/index.mjs +121 -62
- package/libs/switch/index.umd.js +200 -2
- package/libs/tab/index.mjs +131 -68
- package/libs/tab/index.umd.js +190 -1
- package/libs/tabs/index.css +514 -1
- package/libs/tabs/index.mjs +751 -410
- package/libs/tabs/index.umd.js +1020 -2
- package/libs/toast/index.css +1050 -1
- package/libs/toast/index.mjs +183 -114
- package/libs/toast/index.umd.js +306 -2
- package/libs/tooltip/index.css +514 -1
- package/libs/tooltip/index.mjs +293 -155
- package/libs/tooltip/index.umd.js +416 -2
- package/package.json +5 -4
- package/libs/button/package.json +0 -5
- package/libs/cell/package.json +0 -5
- package/libs/checkbox/package.json +0 -5
- package/libs/checkboxGroup/package.json +0 -5
- package/libs/col/package.json +0 -5
- package/libs/countdown/package.json +0 -5
- package/libs/dialog/package.json +0 -5
- package/libs/empty/package.json +0 -5
- package/libs/form/package.json +0 -5
- package/libs/formItem/package.json +0 -5
- package/libs/icon/package.json +0 -5
- package/libs/input/package.json +0 -5
- package/libs/layout/package.json +0 -5
- package/libs/list/package.json +0 -5
- package/libs/loading/package.json +0 -5
- package/libs/mask/package.json +0 -5
- package/libs/popup/package.json +0 -5
- package/libs/progress/package.json +0 -5
- package/libs/pullrefresh/package.json +0 -5
- package/libs/row/package.json +0 -5
- package/libs/slider/package.json +0 -5
- package/libs/stepper/package.json +0 -5
- package/libs/swipe/package.json +0 -5
- package/libs/swipeItem/package.json +0 -5
- package/libs/switch/package.json +0 -5
- package/libs/tab/package.json +0 -5
- package/libs/tabs/package.json +0 -5
- package/libs/toast/package.json +0 -5
- package/libs/tooltip/package.json +0 -5
package/libs/toast/index.mjs
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
import { ref
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
"zh-CN":
|
|
49
|
+
ref("zh-CN");
|
|
50
|
+
reactive({
|
|
51
|
+
"zh-CN": defaultLang
|
|
23
52
|
});
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
return [
|
|
27
|
-
}
|
|
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:
|
|
88
|
+
required: true
|
|
52
89
|
},
|
|
53
90
|
// 动画时长
|
|
54
91
|
animationDuration: {
|
|
55
92
|
type: [Number, String],
|
|
56
93
|
default: 300
|
|
57
94
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
};
|
|
96
|
+
const Toast = /* @__PURE__ */ defineComponent({
|
|
97
|
+
name,
|
|
98
|
+
props: _props,
|
|
99
|
+
setup(props, {
|
|
100
|
+
slots
|
|
63
101
|
}) {
|
|
64
|
-
const
|
|
65
|
-
visible:
|
|
102
|
+
const state = reactive({
|
|
103
|
+
visible: false
|
|
66
104
|
// 控制v-show
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
105
|
+
});
|
|
106
|
+
const show = () => {
|
|
107
|
+
const timer = setTimeout(() => {
|
|
108
|
+
state.visible = false;
|
|
109
|
+
clearTimeout(timer);
|
|
110
|
+
}, Number(props.duration));
|
|
71
111
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
112
|
+
onMounted(() => {
|
|
113
|
+
state.visible = true;
|
|
114
|
+
show();
|
|
115
|
+
});
|
|
116
|
+
return () => {
|
|
75
117
|
const {
|
|
76
|
-
title
|
|
77
|
-
message
|
|
78
|
-
position
|
|
79
|
-
animationDuration
|
|
80
|
-
onClose
|
|
81
|
-
} =
|
|
82
|
-
return
|
|
83
|
-
name:
|
|
84
|
-
onAfterLeave:
|
|
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
|
|
88
|
-
return [
|
|
89
|
-
class:
|
|
90
|
-
[
|
|
129
|
+
var _a;
|
|
130
|
+
return [withDirectives(createVNode("div", {
|
|
131
|
+
"class": bem$1({
|
|
132
|
+
[position]: true
|
|
91
133
|
}),
|
|
92
|
-
style: {
|
|
93
|
-
animationDuration: typeof
|
|
134
|
+
"style": {
|
|
135
|
+
animationDuration: typeof animationDuration === "number" ? `${animationDuration}ms` : animationDuration
|
|
94
136
|
}
|
|
95
|
-
}, [
|
|
96
|
-
class:
|
|
97
|
-
}, [((
|
|
98
|
-
class:
|
|
99
|
-
}, [
|
|
100
|
-
class:
|
|
101
|
-
}, [
|
|
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
|
-
})
|
|
107
|
-
|
|
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:
|
|
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(
|
|
155
|
-
slots
|
|
156
|
-
emit
|
|
202
|
+
setup(props, {
|
|
203
|
+
slots,
|
|
204
|
+
emit
|
|
157
205
|
}) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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:
|
|
167
|
-
classPrefix
|
|
168
|
-
badge
|
|
169
|
-
dot
|
|
170
|
-
subColor
|
|
171
|
-
subBg
|
|
172
|
-
tag:
|
|
173
|
-
} =
|
|
174
|
-
return
|
|
175
|
-
class: `${
|
|
176
|
-
style:
|
|
177
|
-
onClick:
|
|
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
|
|
181
|
-
return [
|
|
182
|
-
class:
|
|
183
|
-
}, [
|
|
184
|
-
class:
|
|
185
|
-
src:
|
|
186
|
-
alt: "icon"
|
|
187
|
-
}, null)]) : null,
|
|
188
|
-
class:
|
|
189
|
-
style: {
|
|
190
|
-
backgroundColor:
|
|
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,
|
|
193
|
-
class:
|
|
194
|
-
style: {
|
|
195
|
-
color:
|
|
196
|
-
backgroundColor:
|
|
242
|
+
}, null) : null, badge ? createVNode("em", {
|
|
243
|
+
"class": bem("badge"),
|
|
244
|
+
"style": {
|
|
245
|
+
color: subColor,
|
|
246
|
+
backgroundColor: subBg
|
|
197
247
|
}
|
|
198
|
-
}, [
|
|
248
|
+
}, [badge]) : null, ((_a = slots.default) == null ? void 0 : _a.call(slots)) || null];
|
|
199
249
|
}
|
|
200
250
|
});
|
|
201
251
|
};
|
|
202
252
|
}
|
|
203
253
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
|
|
226
|
-
|
|
293
|
+
const style = "";
|
|
294
|
+
Toast.install = (app) => {
|
|
295
|
+
app.provide("toast", toastCreate);
|
|
227
296
|
};
|
|
228
297
|
export {
|
|
229
|
-
|
|
230
|
-
|
|
298
|
+
Toast as default,
|
|
299
|
+
toastCreate
|
|
231
300
|
};
|