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.
- 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 +2 -2
package/libs/checkbox/index.mjs
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
import { ref
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
"zh-CN":
|
|
49
|
+
ref("zh-CN");
|
|
50
|
+
reactive({
|
|
51
|
+
"zh-CN": defaultLang
|
|
23
52
|
});
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
return [
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
73
|
+
if (parent.instance && parent.instance.exposed) {
|
|
74
|
+
resetValidation();
|
|
75
|
+
change();
|
|
76
|
+
validateWithTrigger("onChange");
|
|
77
|
+
}
|
|
35
78
|
}
|
|
36
|
-
)
|
|
37
|
-
|
|
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
|
-
}
|
|
44
|
-
|
|
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:
|
|
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(
|
|
92
|
-
slots
|
|
93
|
-
emit
|
|
143
|
+
setup(props, {
|
|
144
|
+
slots,
|
|
145
|
+
emit
|
|
94
146
|
}) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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:
|
|
104
|
-
classPrefix
|
|
105
|
-
badge
|
|
106
|
-
dot
|
|
107
|
-
subColor
|
|
108
|
-
subBg
|
|
109
|
-
tag:
|
|
110
|
-
} =
|
|
111
|
-
return
|
|
112
|
-
class: `${
|
|
113
|
-
style:
|
|
114
|
-
onClick:
|
|
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
|
|
118
|
-
return [
|
|
119
|
-
class:
|
|
120
|
-
}, [
|
|
121
|
-
class:
|
|
122
|
-
src:
|
|
123
|
-
alt: "icon"
|
|
124
|
-
}, null)]) : null,
|
|
125
|
-
class:
|
|
126
|
-
style: {
|
|
127
|
-
backgroundColor:
|
|
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,
|
|
130
|
-
class:
|
|
131
|
-
style: {
|
|
132
|
-
color:
|
|
133
|
-
backgroundColor:
|
|
183
|
+
}, null) : null, badge ? createVNode("em", {
|
|
184
|
+
"class": bem$2("badge"),
|
|
185
|
+
"style": {
|
|
186
|
+
color: subColor,
|
|
187
|
+
backgroundColor: subBg
|
|
134
188
|
}
|
|
135
|
-
}, [
|
|
189
|
+
}, [badge]) : null, ((_a = slots.default) == null ? void 0 : _a.call(slots)) || null];
|
|
136
190
|
}
|
|
137
191
|
});
|
|
138
192
|
};
|
|
139
193
|
}
|
|
140
194
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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:
|
|
220
|
+
index: ref(-1)
|
|
157
221
|
};
|
|
158
|
-
}
|
|
159
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
247
|
+
default: true
|
|
180
248
|
},
|
|
181
249
|
checkedColor: {
|
|
182
250
|
type: String,
|
|
183
251
|
default: ""
|
|
184
252
|
}
|
|
185
253
|
},
|
|
186
|
-
setup(
|
|
187
|
-
slots
|
|
188
|
-
emit
|
|
189
|
-
expose
|
|
254
|
+
setup(props, {
|
|
255
|
+
slots,
|
|
256
|
+
emit,
|
|
257
|
+
expose
|
|
190
258
|
}) {
|
|
191
259
|
const {
|
|
192
|
-
parent
|
|
193
|
-
} =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
200
|
-
|
|
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
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
207
|
-
if (
|
|
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
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
|
215
|
-
} =
|
|
216
|
-
return
|
|
217
|
-
class:
|
|
218
|
-
disabled:
|
|
219
|
-
checked:
|
|
220
|
-
horizontal:
|
|
221
|
-
[
|
|
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: () =>
|
|
224
|
-
role: "checkbox",
|
|
225
|
-
"aria-checked":
|
|
226
|
-
}, [((
|
|
227
|
-
checked:
|
|
228
|
-
})) ||
|
|
229
|
-
class:
|
|
230
|
-
checked:
|
|
231
|
-
square:
|
|
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:
|
|
234
|
-
}, [
|
|
235
|
-
name: "done"
|
|
236
|
-
}, null) : null]),
|
|
237
|
-
class:
|
|
238
|
-
}, [(
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
356
|
+
const style = "";
|
|
357
|
+
Checkbox.install = (Vue) => {
|
|
358
|
+
const { name: name2 } = Checkbox;
|
|
359
|
+
Vue.component(name2, Checkbox);
|
|
245
360
|
};
|
|
246
361
|
export {
|
|
247
|
-
|
|
362
|
+
Checkbox as default
|
|
248
363
|
};
|