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/slider/index.mjs
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
import { ref
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
import { ref, reactive, defineComponent, computed, 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,39 +46,94 @@ const $ = (e, a) => a ? typeof a == "string" ? ` ${e}--${a}` : Array.isArray(a)
|
|
|
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
|
-
|
|
53
|
+
const createNamespace = (name) => {
|
|
54
|
+
const prefixedName = `y-${name}`;
|
|
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 MIN_DISTANCE = 10;
|
|
64
|
+
const getDirection = (x, y) => {
|
|
65
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
66
|
+
return "horizontal";
|
|
67
|
+
}
|
|
68
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
69
|
+
return "vertical";
|
|
70
|
+
}
|
|
71
|
+
return "";
|
|
72
|
+
};
|
|
73
|
+
const getTouchDirection = (x, y) => {
|
|
74
|
+
if (Math.abs(x) > Math.abs(y)) {
|
|
75
|
+
if (x > 0)
|
|
76
|
+
return "right";
|
|
77
|
+
return "left";
|
|
78
|
+
}
|
|
79
|
+
if (y > 0)
|
|
80
|
+
return "bottom";
|
|
81
|
+
return "top";
|
|
82
|
+
};
|
|
83
|
+
const useTouch = () => {
|
|
84
|
+
const startX = ref(0);
|
|
85
|
+
const startY = ref(0);
|
|
86
|
+
const deltaX = ref(0);
|
|
87
|
+
const deltaY = ref(0);
|
|
88
|
+
const offsetX = ref(0);
|
|
89
|
+
const offsetY = ref(0);
|
|
90
|
+
const direction = ref("");
|
|
91
|
+
const touchDirection = ref("");
|
|
92
|
+
const isVertical = () => direction.value === "vertical";
|
|
93
|
+
const isHorizontal = () => direction.value === "horizontal";
|
|
94
|
+
const reset2 = () => {
|
|
95
|
+
deltaX.value = 0;
|
|
96
|
+
deltaY.value = 0;
|
|
97
|
+
offsetX.value = 0;
|
|
98
|
+
offsetY.value = 0;
|
|
99
|
+
direction.value = "";
|
|
100
|
+
touchDirection.value = "";
|
|
101
|
+
};
|
|
102
|
+
const start = (event) => {
|
|
103
|
+
reset2();
|
|
104
|
+
startX.value = event.touches[0].clientX;
|
|
105
|
+
startY.value = event.touches[0].clientY;
|
|
106
|
+
};
|
|
107
|
+
const move = (event) => {
|
|
108
|
+
const touch = event.touches[0];
|
|
109
|
+
deltaX.value = touch.clientX < 0 ? 0 : touch.clientX - startX.value;
|
|
110
|
+
deltaY.value = touch.clientY - startY.value;
|
|
111
|
+
offsetX.value = Math.abs(deltaX.value);
|
|
112
|
+
offsetY.value = Math.abs(deltaY.value);
|
|
113
|
+
if (!direction.value) {
|
|
114
|
+
direction.value = getDirection(offsetX.value, offsetY.value);
|
|
115
|
+
}
|
|
116
|
+
touchDirection.value = getTouchDirection(deltaX.value, deltaY.value);
|
|
30
117
|
};
|
|
31
118
|
return {
|
|
32
|
-
move
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
offsetY: i,
|
|
46
|
-
direction: c,
|
|
47
|
-
touchDirection: C,
|
|
48
|
-
isVertical: h,
|
|
49
|
-
isHorizontal: b
|
|
119
|
+
move,
|
|
120
|
+
start,
|
|
121
|
+
reset: reset2,
|
|
122
|
+
startX,
|
|
123
|
+
startY,
|
|
124
|
+
deltaX,
|
|
125
|
+
deltaY,
|
|
126
|
+
offsetX,
|
|
127
|
+
offsetY,
|
|
128
|
+
direction,
|
|
129
|
+
touchDirection,
|
|
130
|
+
isVertical,
|
|
131
|
+
isHorizontal
|
|
50
132
|
};
|
|
51
|
-
}
|
|
52
|
-
|
|
133
|
+
};
|
|
134
|
+
const [cname, bem] = createNamespace("slider");
|
|
135
|
+
const Slider = /* @__PURE__ */ defineComponent({
|
|
136
|
+
name: cname,
|
|
53
137
|
props: {
|
|
54
138
|
modelValue: {
|
|
55
139
|
type: [Number, Array],
|
|
@@ -81,11 +165,11 @@ const j = (e) => {
|
|
|
81
165
|
},
|
|
82
166
|
disabled: {
|
|
83
167
|
type: Boolean,
|
|
84
|
-
default:
|
|
168
|
+
default: false
|
|
85
169
|
},
|
|
86
170
|
showTooltip: {
|
|
87
171
|
type: Boolean,
|
|
88
|
-
default:
|
|
172
|
+
default: false
|
|
89
173
|
},
|
|
90
174
|
step: {
|
|
91
175
|
type: Number,
|
|
@@ -105,147 +189,259 @@ const j = (e) => {
|
|
|
105
189
|
}
|
|
106
190
|
},
|
|
107
191
|
emits: ["change", "drag-start", "drag-end", "update:modelValue"],
|
|
108
|
-
setup(
|
|
109
|
-
emit
|
|
110
|
-
slots
|
|
192
|
+
setup(props, {
|
|
193
|
+
emit,
|
|
194
|
+
slots
|
|
111
195
|
}) {
|
|
112
|
-
const
|
|
196
|
+
const rootRef = ref();
|
|
197
|
+
const startRef = ref(0);
|
|
198
|
+
const curRef = ref(0);
|
|
199
|
+
const moveStatusRef = ref("");
|
|
200
|
+
const touch = useTouch();
|
|
201
|
+
const isRangeRef = computed(() => Array.isArray(props.modelValue));
|
|
202
|
+
const formatValue = (value) => {
|
|
113
203
|
const {
|
|
114
|
-
min
|
|
115
|
-
max
|
|
116
|
-
step
|
|
117
|
-
} =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
204
|
+
min,
|
|
205
|
+
max,
|
|
206
|
+
step
|
|
207
|
+
} = props;
|
|
208
|
+
const val = Math.max(min, Math.min(value, max));
|
|
209
|
+
return Math.round(val / step) * step;
|
|
210
|
+
};
|
|
211
|
+
const handleClick = (event) => {
|
|
212
|
+
event.stopPropagation();
|
|
213
|
+
if (props.disabled)
|
|
121
214
|
return;
|
|
122
215
|
const {
|
|
123
|
-
min
|
|
124
|
-
modelValue
|
|
125
|
-
} =
|
|
126
|
-
left: f,
|
|
127
|
-
width: v
|
|
128
|
-
} = n.value.getBoundingClientRect(), S = t.clientX - f, T = Math.floor(r + S / v * M.value);
|
|
129
|
-
if (h.value) {
|
|
130
|
-
const X = l[0], x = l[1], W = (X + x) / 2;
|
|
131
|
-
T <= W ? m([T, x]) : m([X, T]);
|
|
132
|
-
} else
|
|
133
|
-
m(T);
|
|
134
|
-
}, w = (t) => t[0] > t[1] ? [t[1], t[0]] : t, k = (t, r) => JSON.stringify(t) === JSON.stringify(r), m = (t, r) => {
|
|
135
|
-
let l = 0;
|
|
136
|
-
h.value ? l = w(t).map(b) : l = b(t), a("update:modelValue", l), typeof r > "u" && !k(u.value, i.value) && a("change", l);
|
|
137
|
-
}, y = V(() => {
|
|
216
|
+
min,
|
|
217
|
+
modelValue
|
|
218
|
+
} = props;
|
|
138
219
|
const {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
220
|
+
left: rootLeft,
|
|
221
|
+
width: rootWidth
|
|
222
|
+
} = rootRef.value.getBoundingClientRect();
|
|
223
|
+
const delta = event.clientX - rootLeft;
|
|
224
|
+
const curValue = Math.floor(min + delta / rootWidth * numberGapRef.value);
|
|
225
|
+
if (isRangeRef.value) {
|
|
226
|
+
const left = modelValue[0];
|
|
227
|
+
const right = modelValue[1];
|
|
228
|
+
const middle = (left + right) / 2;
|
|
229
|
+
if (curValue <= middle) {
|
|
230
|
+
updateValue([curValue, right]);
|
|
231
|
+
} else {
|
|
232
|
+
updateValue([left, curValue]);
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
updateValue(curValue);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const handlePositionOrder = (value) => {
|
|
239
|
+
if (value[0] > value[1]) {
|
|
240
|
+
return [value[1], value[0]];
|
|
241
|
+
}
|
|
242
|
+
return value;
|
|
243
|
+
};
|
|
244
|
+
const isSameValue = (beforeValue, curValue) => JSON.stringify(beforeValue) === JSON.stringify(curValue);
|
|
245
|
+
const updateValue = (value, unfinished) => {
|
|
246
|
+
let newValue = 0;
|
|
247
|
+
if (isRangeRef.value) {
|
|
248
|
+
newValue = handlePositionOrder(value).map(formatValue);
|
|
249
|
+
} else {
|
|
250
|
+
newValue = formatValue(value);
|
|
251
|
+
}
|
|
252
|
+
emit("update:modelValue", newValue);
|
|
253
|
+
if (typeof unfinished === "undefined" && !isSameValue(startRef.value, curRef.value)) {
|
|
254
|
+
emit("change", newValue);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const getInnerLengthPercentRef = computed(() => {
|
|
145
258
|
const {
|
|
146
|
-
modelValue
|
|
147
|
-
min
|
|
148
|
-
} =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
259
|
+
modelValue,
|
|
260
|
+
min
|
|
261
|
+
} = props;
|
|
262
|
+
let tmpVal = null;
|
|
263
|
+
if (isRangeRef.value) {
|
|
264
|
+
tmpVal = Math.floor((formatValue(modelValue[1]) - formatValue(modelValue[0])) * 100 / numberGapRef.value);
|
|
265
|
+
} else {
|
|
266
|
+
tmpVal = Math.floor((formatValue(modelValue) - min) * 100 / numberGapRef.value);
|
|
267
|
+
}
|
|
268
|
+
return `${tmpVal}%`;
|
|
269
|
+
});
|
|
270
|
+
const getOffsetRef = computed(() => {
|
|
271
|
+
const {
|
|
272
|
+
modelValue,
|
|
273
|
+
min
|
|
274
|
+
} = props;
|
|
275
|
+
if (isRangeRef.value) {
|
|
276
|
+
return `${Math.floor((formatValue(modelValue[0]) - min) * 100 / numberGapRef.value)}%`;
|
|
277
|
+
}
|
|
278
|
+
return "0%";
|
|
279
|
+
});
|
|
280
|
+
const toolTipStyle = computed(() => {
|
|
281
|
+
return {
|
|
282
|
+
left: getInnerLengthPercentRef.value,
|
|
283
|
+
transition: moveStatusRef.value === "moving" ? "none" : `${props.transitionTime}ms ease-in-out`
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
const numberGapRef = computed(() => props.max - props.min);
|
|
287
|
+
const handleTouchStart = (event) => {
|
|
288
|
+
if (props.disabled)
|
|
289
|
+
return;
|
|
290
|
+
touch.start(event);
|
|
291
|
+
moveStatusRef.value = "startMove";
|
|
292
|
+
curRef.value = props.modelValue;
|
|
293
|
+
if (isRangeRef.value) {
|
|
294
|
+
startRef.value = [...curRef.value];
|
|
295
|
+
} else {
|
|
296
|
+
startRef.value = curRef.value;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const handleTouchMove = (event, pos) => {
|
|
300
|
+
if (props.disabled)
|
|
157
301
|
return;
|
|
158
|
-
|
|
302
|
+
touch.move(event);
|
|
303
|
+
if (moveStatusRef.value === "startMove") {
|
|
304
|
+
emit("drag-start");
|
|
305
|
+
}
|
|
306
|
+
moveStatusRef.value = "moving";
|
|
159
307
|
const {
|
|
160
|
-
width
|
|
161
|
-
} =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
backgroundColor: Array.isArray(e.buttonBgColor) ? e.buttonBgColor[0] : e.buttonBgColor
|
|
170
|
-
}, f = e.modelValue[t], v = d("button-wrapper", "left")) : t === 1 ? (r = "right", f = e.modelValue[t], l = {
|
|
171
|
-
left: `${parseInt(y.value) + parseInt(A.value)}%`,
|
|
172
|
-
backgroundColor: Array.isArray(e.buttonBgColor) ? e.buttonBgColor[1] : e.buttonBgColor
|
|
173
|
-
}, v = d("button-wrapper", "right")) : (f = e.modelValue, l = {
|
|
174
|
-
left: y.value,
|
|
175
|
-
backgroundColor: e.buttonBgColor
|
|
176
|
-
}), g("div", {
|
|
177
|
-
role: "slider",
|
|
178
|
-
"aria-valuemin": e.min,
|
|
179
|
-
"aria-valuemax": e.max,
|
|
180
|
-
"aria-valuenow": f,
|
|
181
|
-
class: v,
|
|
182
|
-
onTouchstart: D,
|
|
183
|
-
onTouchmove: (S) => I(S, r),
|
|
184
|
-
onTouchend: O,
|
|
185
|
-
style: {
|
|
186
|
-
...l,
|
|
187
|
-
transition: c.value === "moving" ? "none" : `${e.transitionTime}ms ease-in-out`
|
|
308
|
+
width
|
|
309
|
+
} = rootRef.value.getBoundingClientRect();
|
|
310
|
+
const delta = touch.deltaX.value;
|
|
311
|
+
const diff = Math.floor(delta / width * numberGapRef.value);
|
|
312
|
+
if (Array.isArray(startRef.value) && Array.isArray(curRef.value)) {
|
|
313
|
+
if (pos === "left") {
|
|
314
|
+
curRef.value[0] = startRef.value[0] + diff;
|
|
315
|
+
} else {
|
|
316
|
+
curRef.value[1] = startRef.value[1] + diff;
|
|
188
317
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
318
|
+
} else {
|
|
319
|
+
curRef.value = startRef.value + diff;
|
|
320
|
+
}
|
|
321
|
+
updateValue(curRef.value, true);
|
|
322
|
+
};
|
|
323
|
+
const handleTouchEnd = () => {
|
|
324
|
+
if (props.disabled)
|
|
325
|
+
return;
|
|
326
|
+
if (moveStatusRef.value === "moving") {
|
|
327
|
+
updateValue(curRef.value);
|
|
328
|
+
emit("drag-end");
|
|
329
|
+
}
|
|
330
|
+
moveStatusRef.value = "endMove";
|
|
331
|
+
};
|
|
332
|
+
const renderButton = (index) => {
|
|
333
|
+
let pos = "";
|
|
334
|
+
let posStyle = {};
|
|
335
|
+
let curValue = 0;
|
|
336
|
+
let buttonWrapperClass = bem("button-wrapper");
|
|
337
|
+
if (index === 0) {
|
|
338
|
+
pos = "left";
|
|
339
|
+
posStyle = {
|
|
340
|
+
left: getOffsetRef.value,
|
|
341
|
+
backgroundColor: Array.isArray(props.buttonBgColor) ? props.buttonBgColor[0] : props.buttonBgColor
|
|
342
|
+
};
|
|
343
|
+
curValue = props.modelValue[index];
|
|
344
|
+
buttonWrapperClass = bem("button-wrapper", "left");
|
|
345
|
+
} else if (index === 1) {
|
|
346
|
+
pos = "right";
|
|
347
|
+
curValue = props.modelValue[index];
|
|
348
|
+
posStyle = {
|
|
349
|
+
left: `${parseInt(getInnerLengthPercentRef.value) + parseInt(getOffsetRef.value)}%`,
|
|
350
|
+
backgroundColor: Array.isArray(props.buttonBgColor) ? props.buttonBgColor[1] : props.buttonBgColor
|
|
351
|
+
};
|
|
352
|
+
buttonWrapperClass = bem("button-wrapper", "right");
|
|
353
|
+
} else {
|
|
354
|
+
curValue = props.modelValue;
|
|
355
|
+
posStyle = {
|
|
356
|
+
left: getInnerLengthPercentRef.value,
|
|
357
|
+
backgroundColor: props.buttonBgColor
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return createVNode("div", {
|
|
361
|
+
"role": "slider",
|
|
362
|
+
"aria-valuemin": props.min,
|
|
363
|
+
"aria-valuemax": props.max,
|
|
364
|
+
"aria-valuenow": curValue,
|
|
365
|
+
"class": buttonWrapperClass,
|
|
366
|
+
"onTouchstart": handleTouchStart,
|
|
367
|
+
"onTouchmove": (e) => handleTouchMove(e, pos),
|
|
368
|
+
"onTouchend": handleTouchEnd,
|
|
369
|
+
"style": {
|
|
370
|
+
...posStyle,
|
|
371
|
+
transition: moveStatusRef.value === "moving" ? "none" : `${props.transitionTime}ms ease-in-out`
|
|
372
|
+
}
|
|
373
|
+
}, [slots.button ? slots.button() : createVNode("div", {
|
|
374
|
+
"class": bem("inner-button"),
|
|
375
|
+
"style": posStyle
|
|
192
376
|
}, null)]);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
377
|
+
};
|
|
378
|
+
const getDotListRef = computed(() => {
|
|
379
|
+
const arr = Array((props.max - props.min) / props.step).fill({});
|
|
380
|
+
return arr.map((_, index) => ({
|
|
381
|
+
position: `${index * props.step}%`
|
|
382
|
+
}));
|
|
383
|
+
});
|
|
196
384
|
return () => {
|
|
197
|
-
var
|
|
198
|
-
return
|
|
199
|
-
class:
|
|
200
|
-
}, [
|
|
201
|
-
class:
|
|
202
|
-
left:
|
|
385
|
+
var _a;
|
|
386
|
+
return createVNode("div", {
|
|
387
|
+
"class": bem()
|
|
388
|
+
}, [slots.iconLeft && createVNode("div", {
|
|
389
|
+
"class": bem("icon", {
|
|
390
|
+
left: true
|
|
203
391
|
})
|
|
204
|
-
}, [
|
|
205
|
-
role: "presentation",
|
|
206
|
-
ref:
|
|
207
|
-
class:
|
|
208
|
-
disabled:
|
|
392
|
+
}, [slots.iconLeft()]), createVNode("div", {
|
|
393
|
+
"role": "presentation",
|
|
394
|
+
"ref": rootRef,
|
|
395
|
+
"class": bem("wrapper-main", {
|
|
396
|
+
disabled: props.disabled
|
|
209
397
|
}),
|
|
210
|
-
style: {
|
|
211
|
-
background:
|
|
212
|
-
height:
|
|
398
|
+
"style": {
|
|
399
|
+
background: props.inactiveColor,
|
|
400
|
+
height: parseUnit(props.barHeight)
|
|
213
401
|
},
|
|
214
|
-
onClick:
|
|
215
|
-
}, [
|
|
216
|
-
class:
|
|
217
|
-
}, [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
402
|
+
"onClick": handleClick
|
|
403
|
+
}, [props.step !== 1 && createVNode("div", {
|
|
404
|
+
"class": bem("dots")
|
|
405
|
+
}, [getDotListRef.value.map((item) => {
|
|
406
|
+
return createVNode("div", {
|
|
407
|
+
"class": bem("dot"),
|
|
408
|
+
"style": {
|
|
409
|
+
left: item.position,
|
|
410
|
+
background: props.gapColor,
|
|
411
|
+
width: parseUnit(props.gapWidth)
|
|
412
|
+
}
|
|
413
|
+
}, null);
|
|
414
|
+
})]), props.showTooltip && createVNode("div", {
|
|
415
|
+
"class": bem("tooltip", {
|
|
416
|
+
wrapper: slots.toolTip
|
|
227
417
|
}),
|
|
228
|
-
style:
|
|
229
|
-
}, [((
|
|
230
|
-
style: {
|
|
231
|
-
left:
|
|
232
|
-
width:
|
|
233
|
-
background:
|
|
234
|
-
transition:
|
|
418
|
+
"style": toolTipStyle.value
|
|
419
|
+
}, [((_a = slots.toolTip) == null ? void 0 : _a.call(slots)) || props.modelValue]), createVNode("div", {
|
|
420
|
+
"style": {
|
|
421
|
+
left: getOffsetRef.value,
|
|
422
|
+
width: getInnerLengthPercentRef.value,
|
|
423
|
+
background: props.activeColor,
|
|
424
|
+
transition: moveStatusRef.value === "moving" ? "none" : `${props.transitionTime}ms ease-in-out`
|
|
235
425
|
},
|
|
236
|
-
class:
|
|
237
|
-
}, null),
|
|
238
|
-
class:
|
|
239
|
-
right:
|
|
426
|
+
"class": bem("inner")
|
|
427
|
+
}, null), isRangeRef.value ? [renderButton(0), renderButton(1)] : renderButton()]), slots.iconRight && createVNode("div", {
|
|
428
|
+
"class": bem("icon", {
|
|
429
|
+
right: true
|
|
240
430
|
})
|
|
241
|
-
}, [
|
|
431
|
+
}, [slots.iconRight()])]);
|
|
242
432
|
};
|
|
243
433
|
}
|
|
244
434
|
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
435
|
+
const reset = "";
|
|
436
|
+
const libs = "";
|
|
437
|
+
const font = "";
|
|
438
|
+
const animation = "";
|
|
439
|
+
const theme = "";
|
|
440
|
+
const style = "";
|
|
441
|
+
Slider.install = (Vue) => {
|
|
442
|
+
const { name } = Slider;
|
|
443
|
+
Vue.component(name, Slider);
|
|
248
444
|
};
|
|
249
445
|
export {
|
|
250
|
-
|
|
446
|
+
Slider as default
|
|
251
447
|
};
|