@wfrog/vc-ui 1.11.10 → 1.11.12
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/dist/es/chunk/Bw0Rhd-r.mjs +110 -0
- package/dist/es/chunk/CqTdDZkE.mjs +31 -0
- package/dist/es/chunk/{DAnWZLYj.mjs → CzWfBa_8.mjs} +96 -2
- package/dist/es/chunk/D229kQ56.mjs +28 -0
- package/dist/es/chunk/{Cxx_YWUC.mjs → DcouM6gM.mjs} +6 -548
- package/dist/es/chunk/Fo0dZYnz.mjs +128 -0
- package/dist/es/chunk/KanuIcmc.mjs +412 -0
- package/dist/es/chunk/{B71xEPfK.mjs → uuUHUjSk.mjs} +4 -35
- package/dist/es/components/backbottom/backbottom.mjs +3 -2
- package/dist/es/components/button/button.mjs +14 -13
- package/dist/es/components/choice/choice.mjs +11 -9
- package/dist/es/components/choice/index.css +1 -1
- package/dist/es/components/choice-boolean/choice-boolean.mjs +3 -3
- package/dist/es/components/color-switch/color-switch.mjs +73 -1046
- package/dist/es/components/color-switch/index.css +1 -1
- package/dist/es/components/cropper/cropper.mjs +11 -117
- package/dist/es/components/cropper/index.css +1 -1
- package/dist/es/components/currency/currency.mjs +10 -12
- package/dist/es/components/daterange-picker/daterange-picker.mjs +10 -6255
- package/dist/es/components/dialog/dialog.mjs +14 -408
- package/dist/es/components/dialog/index.css +1 -1
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.mjs +11 -14
- package/dist/es/components/dialog-map-point/dialog-map-point.mjs +4 -4
- package/dist/es/components/dialog-upload-images/dialog-upload-images.mjs +14 -1380
- package/dist/es/components/dialog-upload-images/index.css +1 -1
- package/dist/es/components/drag-verify/drag-verify.mjs +3 -2
- package/dist/es/components/drawer/drawer.mjs +16 -359
- package/dist/es/components/drawer/index.css +3 -3
- package/dist/es/components/easy-pagination/easy-pagination.mjs +3 -2
- package/dist/es/components/explorer/explorer.mjs +8 -8
- package/dist/es/components/explorer-column-table/explorer-column-table.mjs +5 -7
- package/dist/es/components/explorer-column-table/index.css +1 -1
- package/dist/es/components/explorer-container/explorer-container.d.ts +1 -1
- package/dist/es/components/explorer-container/explorer-container.mjs +4 -3
- package/dist/es/components/explorer-filter/explorer-filter.mjs +5 -4
- package/dist/es/components/explorer-footer/explorer-footer.mjs +4 -8
- package/dist/es/components/explorer-form/explorer-form.mjs +4 -3
- package/dist/es/components/explorer-list/explorer-list.mjs +18 -13
- package/dist/es/components/explorer-list/explorer-list.vue.d.ts +1 -1
- package/dist/es/components/explorer-list/index.css +16 -16
- package/dist/es/components/explorer-modal-form/explorer-modal-form.mjs +8 -7
- package/dist/es/components/explorer-panel/explorer-panel.mjs +3 -3
- package/dist/es/components/explorer-query/explorer-query.mjs +9 -2201
- package/dist/es/components/explorer-query/index.css +1 -1
- package/dist/es/components/explorer-table/explorer-table.mjs +5 -8
- package/dist/es/components/explorer-tools/explorer-tools.mjs +23 -271
- package/dist/es/components/explorer-tools/index.css +9 -9
- package/dist/es/components/explorer-tree/explorer-tree.mjs +4 -5
- package/dist/es/components/explorer-tree/explorer-tree.vue.d.ts +1 -1
- package/dist/es/components/form-item/form-item.mjs +3 -3
- package/dist/es/components/icon-picker/icon-picker.mjs +8 -12
- package/dist/es/components/image/image.mjs +4 -4
- package/dist/es/components/info-tooltip/info-tooltip.mjs +336 -4
- package/dist/es/components/input/input.mjs +3 -2
- package/dist/es/components/input-number/input-number.mjs +3 -3
- package/dist/es/components/pca-picker/index.css +1 -1
- package/dist/es/components/pca-picker/pca-picker.mjs +443 -601
- package/dist/es/components/screenfull/screenfull.mjs +4 -3
- package/dist/es/components/scrollbar/index.css +1 -1
- package/dist/es/components/scrollbar/scrollbar.mjs +10 -10
- package/dist/es/components/select/index.css +1 -1
- package/dist/es/components/select/select.mjs +9 -10
- package/dist/es/components/single-player/index.css +1 -1
- package/dist/es/components/single-player/single-player.mjs +10 -1087
- package/dist/es/components/splitter/splitter.mjs +3 -3
- package/dist/es/components/splitter-panel/splitter-panel.mjs +3 -3
- package/dist/es/components/switch/index.css +1 -1
- package/dist/es/components/switch/switch.mjs +9 -395
- package/dist/es/components/tags/tags.mjs +7 -9
- package/dist/es/components/text-ellipsis/text-ellipsis.mjs +3 -3
- package/dist/es/components/thousand-input/thousand-input.mjs +39 -8
- package/dist/es/components/tinymce/tinymce.mjs +4 -3
- package/dist/es/components/transfer/transfer.mjs +3 -4
- package/dist/es/components/transfer-panel/transfer-panel.mjs +5 -4
- package/dist/es/components/tree-picker/popover-cascader.css +1 -1
- package/dist/es/components/tree-picker/tree-picker.mjs +5 -10
- package/dist/es/index.mjs +1 -1
- package/dist/index.css +41 -68
- package/package.json +1 -1
- package/dist/es/chunk/B-rxnVJv.mjs +0 -3
- package/dist/es/chunk/B5HpgPRt.mjs +0 -69
- package/dist/es/chunk/BBhZKpIc.mjs +0 -2179
- package/dist/es/chunk/BDcsaNYa.mjs +0 -59
- package/dist/es/chunk/BTSSEFfD.mjs +0 -319
- package/dist/es/chunk/BTpNRPQW.mjs +0 -55
- package/dist/es/chunk/BVBK1U57.mjs +0 -96
- package/dist/es/chunk/Bc6yUGLs.mjs +0 -45
- package/dist/es/chunk/BjVI1XMz.mjs +0 -40
- package/dist/es/chunk/BlzQCBDu.mjs +0 -5741
- package/dist/es/chunk/BpJKnxlF.mjs +0 -476
- package/dist/es/chunk/Brp-qSBw.mjs +0 -2003
- package/dist/es/chunk/BunQI8Jb.mjs +0 -390
- package/dist/es/chunk/C0XgBrDz.mjs +0 -775
- package/dist/es/chunk/C0pTANRX.mjs +0 -109
- package/dist/es/chunk/CBMjhoFP.mjs +0 -101
- package/dist/es/chunk/CBiNtNvQ.mjs +0 -242
- package/dist/es/chunk/CBlJeNBO.mjs +0 -890
- package/dist/es/chunk/CCVL_Zj-.mjs +0 -427
- package/dist/es/chunk/CEl4MyfJ.mjs +0 -252
- package/dist/es/chunk/CJK5_jsA.mjs +0 -53
- package/dist/es/chunk/CKOcwq5V.mjs +0 -44
- package/dist/es/chunk/COs9dJZa.mjs +0 -66
- package/dist/es/chunk/CPt6MxJW.mjs +0 -375
- package/dist/es/chunk/CVqW0jzp.mjs +0 -107
- package/dist/es/chunk/CccIsEqA.mjs +0 -128
- package/dist/es/chunk/CjLR27-a.mjs +0 -582
- package/dist/es/chunk/CoGexPPD.mjs +0 -2192
- package/dist/es/chunk/CsLIbnzG.mjs +0 -64
- package/dist/es/chunk/Ct6q2FXg.mjs +0 -5
- package/dist/es/chunk/Cuq5meQh.mjs +0 -184
- package/dist/es/chunk/CvYIOfT1.mjs +0 -23
- package/dist/es/chunk/CxHJBf4l.mjs +0 -31
- package/dist/es/chunk/CzdaOBtA.mjs +0 -66
- package/dist/es/chunk/D0QTifnI.mjs +0 -54
- package/dist/es/chunk/D1QnA2iT.mjs +0 -229
- package/dist/es/chunk/D3AvJlVX.mjs +0 -188
- package/dist/es/chunk/D9Lr0Bzb.mjs +0 -1136
- package/dist/es/chunk/DCkPv0hy.mjs +0 -29
- package/dist/es/chunk/DRwwUUhy.mjs +0 -49
- package/dist/es/chunk/DX-2VRY2.mjs +0 -836
- package/dist/es/chunk/DZ2oTFad.mjs +0 -687
- package/dist/es/chunk/D_bou1py.mjs +0 -55
- package/dist/es/chunk/Da199A5L.mjs +0 -314
- package/dist/es/chunk/DbhQlaOz.mjs +0 -94
- package/dist/es/chunk/Dgu95mOy.mjs +0 -237
- package/dist/es/chunk/DhGOsWxx.mjs +0 -6
- package/dist/es/chunk/Dm_Sj5aH.mjs +0 -487
- package/dist/es/chunk/Dmi-1GRO.mjs +0 -163
- package/dist/es/chunk/DodoD9a9.mjs +0 -52
- package/dist/es/chunk/DrrVDcwm.mjs +0 -955
- package/dist/es/chunk/Du_zJ1Fz.mjs +0 -49
- package/dist/es/chunk/DxxbB5jY.mjs +0 -34
- package/dist/es/chunk/Gk1J52Yw.mjs +0 -207
- package/dist/es/chunk/NsldgdCh.mjs +0 -704
- package/dist/es/chunk/V6KjsUQN.mjs +0 -35
- package/dist/es/chunk/eEsLFV3s.mjs +0 -76
- package/dist/es/chunk/fqiLhk0V.mjs +0 -2065
- package/dist/es/chunk/nxVM7re4.mjs +0 -35
- package/dist/es/chunk/s7HLrANj.mjs +0 -215
- package/dist/es/chunk/vPhxogl3.mjs +0 -19
- package/dist/es/components/icon/icon2.mjs +0 -27
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import './index.css'
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { _ as
|
|
9
|
-
import { useEventListener } from '@vueuse/core';
|
|
10
|
-
import { u as useSizeProp } from '../../chunk/vPhxogl3.mjs';
|
|
11
|
-
import { u as useAriaProps } from '../../chunk/BunQI8Jb.mjs';
|
|
12
|
-
import { C as CHANGE_EVENT, I as INPUT_EVENT, U as UPDATE_MODEL_EVENT } from '../../chunk/Ct6q2FXg.mjs';
|
|
13
|
-
import { b as isNumber } from '../../chunk/Bc6yUGLs.mjs';
|
|
14
|
-
import { _ as _export_sfc, w as withInstall } from '../../chunk/V6KjsUQN.mjs';
|
|
15
|
-
import { g as getEventCode, E as EVENT_CODE } from '../../chunk/BTpNRPQW.mjs';
|
|
16
|
-
import { d as debounce } from '../../chunk/DAnWZLYj.mjs';
|
|
17
|
-
import { c as clamp } from '../../chunk/BDcsaNYa.mjs';
|
|
18
|
-
import { u as useFormItem, a as useFormDisabled, b as useFormItemInputId, c as useFormSize } from '../../chunk/CBMjhoFP.mjs';
|
|
19
|
-
import { u as useLocale } from '../../chunk/CEl4MyfJ.mjs';
|
|
20
|
-
import { i as isObjectLike, b as baseGetTag } from '../../chunk/Cxx_YWUC.mjs';
|
|
21
|
-
import { _ as _export_sfc$1 } from '../../chunk/pcqpp-6-.mjs';
|
|
2
|
+
import { ElSlider } from 'element-plus/es';
|
|
3
|
+
import 'element-plus/es/components/base/style/css';
|
|
4
|
+
import 'element-plus/es/components/slider/style/css';
|
|
5
|
+
import { defineComponent, ref, computed, watch, nextTick, onMounted, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createVNode, createElementVNode, isRef } from 'vue';
|
|
6
|
+
import { _ as _sfc_main$1 } from '../awesome-icon/awesome-icon.mjs';
|
|
7
|
+
import { i as isObjectLike, b as baseGetTag } from '../../chunk/Fo0dZYnz.mjs';
|
|
8
|
+
import { _ as _export_sfc } from '../../chunk/pcqpp-6-.mjs';
|
|
22
9
|
|
|
23
10
|
/** `Object#toString` result references. */
|
|
24
11
|
var boolTag = '[object Boolean]';
|
|
@@ -45,1070 +32,6 @@ function isBoolean(value) {
|
|
|
45
32
|
(isObjectLike(value) && baseGetTag(value) == boolTag);
|
|
46
33
|
}
|
|
47
34
|
|
|
48
|
-
const sliderContextKey = Symbol("sliderContextKey");
|
|
49
|
-
|
|
50
|
-
const sliderProps = buildProps({
|
|
51
|
-
modelValue: {
|
|
52
|
-
type: definePropType([Number, Array]),
|
|
53
|
-
default: 0
|
|
54
|
-
},
|
|
55
|
-
id: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: void 0
|
|
58
|
-
},
|
|
59
|
-
min: {
|
|
60
|
-
type: Number,
|
|
61
|
-
default: 0
|
|
62
|
-
},
|
|
63
|
-
max: {
|
|
64
|
-
type: Number,
|
|
65
|
-
default: 100
|
|
66
|
-
},
|
|
67
|
-
step: {
|
|
68
|
-
type: Number,
|
|
69
|
-
default: 1
|
|
70
|
-
},
|
|
71
|
-
showInput: Boolean,
|
|
72
|
-
showInputControls: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
default: true
|
|
75
|
-
},
|
|
76
|
-
size: useSizeProp,
|
|
77
|
-
inputSize: useSizeProp,
|
|
78
|
-
showStops: Boolean,
|
|
79
|
-
showTooltip: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
default: true
|
|
82
|
-
},
|
|
83
|
-
formatTooltip: {
|
|
84
|
-
type: definePropType(Function),
|
|
85
|
-
default: void 0
|
|
86
|
-
},
|
|
87
|
-
disabled: {
|
|
88
|
-
type: Boolean,
|
|
89
|
-
default: void 0
|
|
90
|
-
},
|
|
91
|
-
range: Boolean,
|
|
92
|
-
vertical: Boolean,
|
|
93
|
-
height: String,
|
|
94
|
-
rangeStartLabel: {
|
|
95
|
-
type: String,
|
|
96
|
-
default: void 0
|
|
97
|
-
},
|
|
98
|
-
rangeEndLabel: {
|
|
99
|
-
type: String,
|
|
100
|
-
default: void 0
|
|
101
|
-
},
|
|
102
|
-
formatValueText: {
|
|
103
|
-
type: definePropType(Function),
|
|
104
|
-
default: void 0
|
|
105
|
-
},
|
|
106
|
-
tooltipClass: {
|
|
107
|
-
type: String,
|
|
108
|
-
default: void 0
|
|
109
|
-
},
|
|
110
|
-
placement: {
|
|
111
|
-
type: String,
|
|
112
|
-
values: Ee,
|
|
113
|
-
default: "top"
|
|
114
|
-
},
|
|
115
|
-
marks: {
|
|
116
|
-
type: definePropType(Object)
|
|
117
|
-
},
|
|
118
|
-
validateEvent: {
|
|
119
|
-
type: Boolean,
|
|
120
|
-
default: true
|
|
121
|
-
},
|
|
122
|
-
persistent: {
|
|
123
|
-
type: Boolean,
|
|
124
|
-
default: true
|
|
125
|
-
},
|
|
126
|
-
...useAriaProps(["ariaLabel"])
|
|
127
|
-
});
|
|
128
|
-
const isValidValue = (value) => isNumber(value) || isArray(value) && value.every(isNumber);
|
|
129
|
-
const sliderEmits = {
|
|
130
|
-
[UPDATE_MODEL_EVENT]: isValidValue,
|
|
131
|
-
[INPUT_EVENT]: isValidValue,
|
|
132
|
-
[CHANGE_EVENT]: isValidValue
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const sliderButtonProps = buildProps({
|
|
136
|
-
modelValue: {
|
|
137
|
-
type: Number,
|
|
138
|
-
default: 0
|
|
139
|
-
},
|
|
140
|
-
vertical: Boolean,
|
|
141
|
-
tooltipClass: String,
|
|
142
|
-
placement: {
|
|
143
|
-
type: String,
|
|
144
|
-
values: Ee,
|
|
145
|
-
default: "top"
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
const sliderButtonEmits = {
|
|
149
|
-
[UPDATE_MODEL_EVENT]: (value) => isNumber(value)
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const useTooltip = (props, formatTooltip, showTooltip) => {
|
|
153
|
-
const tooltip = ref();
|
|
154
|
-
const tooltipVisible = ref(false);
|
|
155
|
-
const enableFormat = computed(() => {
|
|
156
|
-
return formatTooltip.value instanceof Function;
|
|
157
|
-
});
|
|
158
|
-
const formatValue = computed(() => {
|
|
159
|
-
return enableFormat.value && formatTooltip.value(props.modelValue) || props.modelValue;
|
|
160
|
-
});
|
|
161
|
-
const displayTooltip = debounce(() => {
|
|
162
|
-
showTooltip.value && (tooltipVisible.value = true);
|
|
163
|
-
}, 50);
|
|
164
|
-
const hideTooltip = debounce(() => {
|
|
165
|
-
showTooltip.value && (tooltipVisible.value = false);
|
|
166
|
-
}, 50);
|
|
167
|
-
return {
|
|
168
|
-
tooltip,
|
|
169
|
-
tooltipVisible,
|
|
170
|
-
formatValue,
|
|
171
|
-
displayTooltip,
|
|
172
|
-
hideTooltip
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
const useSliderButton = (props, initData, emit) => {
|
|
176
|
-
const {
|
|
177
|
-
disabled,
|
|
178
|
-
min,
|
|
179
|
-
max,
|
|
180
|
-
step,
|
|
181
|
-
showTooltip,
|
|
182
|
-
persistent,
|
|
183
|
-
precision,
|
|
184
|
-
sliderSize,
|
|
185
|
-
formatTooltip,
|
|
186
|
-
emitChange,
|
|
187
|
-
resetSize,
|
|
188
|
-
updateDragging
|
|
189
|
-
} = inject(sliderContextKey);
|
|
190
|
-
const { tooltip, tooltipVisible, formatValue, displayTooltip, hideTooltip } = useTooltip(props, formatTooltip, showTooltip);
|
|
191
|
-
const button = ref();
|
|
192
|
-
const currentPosition = computed(() => {
|
|
193
|
-
return `${(props.modelValue - min.value) / (max.value - min.value) * 100}%`;
|
|
194
|
-
});
|
|
195
|
-
const wrapperStyle = computed(() => {
|
|
196
|
-
return props.vertical ? { bottom: currentPosition.value } : { left: currentPosition.value };
|
|
197
|
-
});
|
|
198
|
-
const handleMouseEnter = () => {
|
|
199
|
-
initData.hovering = true;
|
|
200
|
-
displayTooltip();
|
|
201
|
-
};
|
|
202
|
-
const handleMouseLeave = () => {
|
|
203
|
-
initData.hovering = false;
|
|
204
|
-
if (!initData.dragging) {
|
|
205
|
-
hideTooltip();
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
const onButtonDown = (event) => {
|
|
209
|
-
if (disabled.value)
|
|
210
|
-
return;
|
|
211
|
-
event.preventDefault();
|
|
212
|
-
onDragStart(event);
|
|
213
|
-
window.addEventListener("mousemove", onDragging);
|
|
214
|
-
window.addEventListener("touchmove", onDragging);
|
|
215
|
-
window.addEventListener("mouseup", onDragEnd);
|
|
216
|
-
window.addEventListener("touchend", onDragEnd);
|
|
217
|
-
window.addEventListener("contextmenu", onDragEnd);
|
|
218
|
-
button.value.focus();
|
|
219
|
-
};
|
|
220
|
-
const incrementPosition = (amount) => {
|
|
221
|
-
if (disabled.value)
|
|
222
|
-
return;
|
|
223
|
-
initData.newPosition = Number.parseFloat(currentPosition.value) + amount / (max.value - min.value) * 100;
|
|
224
|
-
setPosition(initData.newPosition);
|
|
225
|
-
emitChange();
|
|
226
|
-
};
|
|
227
|
-
const onLeftKeyDown = () => {
|
|
228
|
-
incrementPosition(-step.value);
|
|
229
|
-
};
|
|
230
|
-
const onRightKeyDown = () => {
|
|
231
|
-
incrementPosition(step.value);
|
|
232
|
-
};
|
|
233
|
-
const onPageDownKeyDown = () => {
|
|
234
|
-
incrementPosition(-step.value * 4);
|
|
235
|
-
};
|
|
236
|
-
const onPageUpKeyDown = () => {
|
|
237
|
-
incrementPosition(step.value * 4);
|
|
238
|
-
};
|
|
239
|
-
const onHomeKeyDown = () => {
|
|
240
|
-
if (disabled.value)
|
|
241
|
-
return;
|
|
242
|
-
setPosition(0);
|
|
243
|
-
emitChange();
|
|
244
|
-
};
|
|
245
|
-
const onEndKeyDown = () => {
|
|
246
|
-
if (disabled.value)
|
|
247
|
-
return;
|
|
248
|
-
setPosition(100);
|
|
249
|
-
emitChange();
|
|
250
|
-
};
|
|
251
|
-
const onKeyDown = (event) => {
|
|
252
|
-
const code = getEventCode(event);
|
|
253
|
-
let isPreventDefault = true;
|
|
254
|
-
switch (code) {
|
|
255
|
-
case EVENT_CODE.left:
|
|
256
|
-
case EVENT_CODE.down:
|
|
257
|
-
onLeftKeyDown();
|
|
258
|
-
break;
|
|
259
|
-
case EVENT_CODE.right:
|
|
260
|
-
case EVENT_CODE.up:
|
|
261
|
-
onRightKeyDown();
|
|
262
|
-
break;
|
|
263
|
-
case EVENT_CODE.home:
|
|
264
|
-
onHomeKeyDown();
|
|
265
|
-
break;
|
|
266
|
-
case EVENT_CODE.end:
|
|
267
|
-
onEndKeyDown();
|
|
268
|
-
break;
|
|
269
|
-
case EVENT_CODE.pageDown:
|
|
270
|
-
onPageDownKeyDown();
|
|
271
|
-
break;
|
|
272
|
-
case EVENT_CODE.pageUp:
|
|
273
|
-
onPageUpKeyDown();
|
|
274
|
-
break;
|
|
275
|
-
default:
|
|
276
|
-
isPreventDefault = false;
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
isPreventDefault && event.preventDefault();
|
|
280
|
-
};
|
|
281
|
-
const getClientXY = (event) => {
|
|
282
|
-
let clientX;
|
|
283
|
-
let clientY;
|
|
284
|
-
if (event.type.startsWith("touch")) {
|
|
285
|
-
clientY = event.touches[0].clientY;
|
|
286
|
-
clientX = event.touches[0].clientX;
|
|
287
|
-
} else {
|
|
288
|
-
clientY = event.clientY;
|
|
289
|
-
clientX = event.clientX;
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
clientX,
|
|
293
|
-
clientY
|
|
294
|
-
};
|
|
295
|
-
};
|
|
296
|
-
const onDragStart = (event) => {
|
|
297
|
-
initData.dragging = true;
|
|
298
|
-
initData.isClick = true;
|
|
299
|
-
const { clientX, clientY } = getClientXY(event);
|
|
300
|
-
if (props.vertical) {
|
|
301
|
-
initData.startY = clientY;
|
|
302
|
-
} else {
|
|
303
|
-
initData.startX = clientX;
|
|
304
|
-
}
|
|
305
|
-
initData.startPosition = Number.parseFloat(currentPosition.value);
|
|
306
|
-
initData.newPosition = initData.startPosition;
|
|
307
|
-
};
|
|
308
|
-
const onDragging = (event) => {
|
|
309
|
-
if (initData.dragging) {
|
|
310
|
-
initData.isClick = false;
|
|
311
|
-
displayTooltip();
|
|
312
|
-
resetSize();
|
|
313
|
-
let diff;
|
|
314
|
-
const { clientX, clientY } = getClientXY(event);
|
|
315
|
-
if (props.vertical) {
|
|
316
|
-
initData.currentY = clientY;
|
|
317
|
-
diff = (initData.startY - initData.currentY) / sliderSize.value * 100;
|
|
318
|
-
} else {
|
|
319
|
-
initData.currentX = clientX;
|
|
320
|
-
diff = (initData.currentX - initData.startX) / sliderSize.value * 100;
|
|
321
|
-
}
|
|
322
|
-
initData.newPosition = initData.startPosition + diff;
|
|
323
|
-
setPosition(initData.newPosition);
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
const onDragEnd = () => {
|
|
327
|
-
if (initData.dragging) {
|
|
328
|
-
setTimeout(() => {
|
|
329
|
-
initData.dragging = false;
|
|
330
|
-
if (!initData.hovering) {
|
|
331
|
-
hideTooltip();
|
|
332
|
-
}
|
|
333
|
-
if (!initData.isClick) {
|
|
334
|
-
setPosition(initData.newPosition);
|
|
335
|
-
}
|
|
336
|
-
emitChange();
|
|
337
|
-
}, 0);
|
|
338
|
-
window.removeEventListener("mousemove", onDragging);
|
|
339
|
-
window.removeEventListener("touchmove", onDragging);
|
|
340
|
-
window.removeEventListener("mouseup", onDragEnd);
|
|
341
|
-
window.removeEventListener("touchend", onDragEnd);
|
|
342
|
-
window.removeEventListener("contextmenu", onDragEnd);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
const setPosition = async (newPosition) => {
|
|
346
|
-
if (newPosition === null || Number.isNaN(+newPosition))
|
|
347
|
-
return;
|
|
348
|
-
newPosition = clamp(newPosition, 0, 100);
|
|
349
|
-
const fullSteps = Math.floor((max.value - min.value) / step.value);
|
|
350
|
-
const fullRangePercentage = fullSteps * step.value / (max.value - min.value) * 100;
|
|
351
|
-
const threshold = fullRangePercentage + (100 - fullRangePercentage) / 2;
|
|
352
|
-
let value;
|
|
353
|
-
if (newPosition < fullRangePercentage) {
|
|
354
|
-
const valueBetween = fullRangePercentage / fullSteps;
|
|
355
|
-
const steps = Math.round(newPosition / valueBetween);
|
|
356
|
-
value = min.value + steps * step.value;
|
|
357
|
-
} else if (newPosition < threshold) {
|
|
358
|
-
value = min.value + fullSteps * step.value;
|
|
359
|
-
} else {
|
|
360
|
-
value = max.value;
|
|
361
|
-
}
|
|
362
|
-
value = Number.parseFloat(value.toFixed(precision.value));
|
|
363
|
-
if (value !== props.modelValue) {
|
|
364
|
-
emit(UPDATE_MODEL_EVENT, value);
|
|
365
|
-
}
|
|
366
|
-
if (!initData.dragging && props.modelValue !== initData.oldValue) {
|
|
367
|
-
initData.oldValue = props.modelValue;
|
|
368
|
-
}
|
|
369
|
-
await nextTick();
|
|
370
|
-
initData.dragging && displayTooltip();
|
|
371
|
-
tooltip.value.updatePopper();
|
|
372
|
-
};
|
|
373
|
-
watch(
|
|
374
|
-
() => initData.dragging,
|
|
375
|
-
(val) => {
|
|
376
|
-
updateDragging(val);
|
|
377
|
-
}
|
|
378
|
-
);
|
|
379
|
-
useEventListener(button, "touchstart", onButtonDown, { passive: false });
|
|
380
|
-
return {
|
|
381
|
-
disabled,
|
|
382
|
-
button,
|
|
383
|
-
tooltip,
|
|
384
|
-
tooltipVisible,
|
|
385
|
-
showTooltip,
|
|
386
|
-
persistent,
|
|
387
|
-
wrapperStyle,
|
|
388
|
-
formatValue,
|
|
389
|
-
handleMouseEnter,
|
|
390
|
-
handleMouseLeave,
|
|
391
|
-
onButtonDown,
|
|
392
|
-
onKeyDown,
|
|
393
|
-
setPosition
|
|
394
|
-
};
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
const _hoisted_1$2 = ["tabindex"];
|
|
398
|
-
const _sfc_main$2 = defineComponent({
|
|
399
|
-
...{
|
|
400
|
-
name: "ElSliderButton"
|
|
401
|
-
},
|
|
402
|
-
__name: "button",
|
|
403
|
-
props: sliderButtonProps,
|
|
404
|
-
emits: sliderButtonEmits,
|
|
405
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
406
|
-
const props = __props;
|
|
407
|
-
const emit = __emit;
|
|
408
|
-
const ns = useNamespace("slider");
|
|
409
|
-
const initData = reactive({
|
|
410
|
-
hovering: false,
|
|
411
|
-
dragging: false,
|
|
412
|
-
isClick: false,
|
|
413
|
-
startX: 0,
|
|
414
|
-
currentX: 0,
|
|
415
|
-
startY: 0,
|
|
416
|
-
currentY: 0,
|
|
417
|
-
startPosition: 0,
|
|
418
|
-
newPosition: 0,
|
|
419
|
-
oldValue: props.modelValue
|
|
420
|
-
});
|
|
421
|
-
const tooltipPersistent = computed(
|
|
422
|
-
() => !showTooltip.value ? false : persistent.value
|
|
423
|
-
);
|
|
424
|
-
const {
|
|
425
|
-
disabled,
|
|
426
|
-
button,
|
|
427
|
-
tooltip,
|
|
428
|
-
showTooltip,
|
|
429
|
-
persistent,
|
|
430
|
-
tooltipVisible,
|
|
431
|
-
wrapperStyle,
|
|
432
|
-
formatValue,
|
|
433
|
-
handleMouseEnter,
|
|
434
|
-
handleMouseLeave,
|
|
435
|
-
onButtonDown,
|
|
436
|
-
onKeyDown,
|
|
437
|
-
setPosition
|
|
438
|
-
} = useSliderButton(props, initData, emit);
|
|
439
|
-
const { hovering, dragging } = toRefs(initData);
|
|
440
|
-
__expose({
|
|
441
|
-
onButtonDown,
|
|
442
|
-
onKeyDown,
|
|
443
|
-
setPosition,
|
|
444
|
-
hovering,
|
|
445
|
-
dragging
|
|
446
|
-
});
|
|
447
|
-
return (_ctx, _cache) => {
|
|
448
|
-
return openBlock(), createElementBlock("div", {
|
|
449
|
-
ref_key: "button",
|
|
450
|
-
ref: button,
|
|
451
|
-
class: normalizeClass([unref(ns).e("button-wrapper"), { hover: unref(hovering), dragging: unref(dragging) }]),
|
|
452
|
-
style: normalizeStyle(unref(wrapperStyle)),
|
|
453
|
-
tabindex: unref(disabled) ? void 0 : 0,
|
|
454
|
-
onMouseenter: _cache[0] || (_cache[0] = (...args) => unref(handleMouseEnter) && unref(handleMouseEnter)(...args)),
|
|
455
|
-
onMouseleave: _cache[1] || (_cache[1] = (...args) => unref(handleMouseLeave) && unref(handleMouseLeave)(...args)),
|
|
456
|
-
onMousedown: _cache[2] || (_cache[2] = (...args) => unref(onButtonDown) && unref(onButtonDown)(...args)),
|
|
457
|
-
onFocus: _cache[3] || (_cache[3] = (...args) => unref(handleMouseEnter) && unref(handleMouseEnter)(...args)),
|
|
458
|
-
onBlur: _cache[4] || (_cache[4] = (...args) => unref(handleMouseLeave) && unref(handleMouseLeave)(...args)),
|
|
459
|
-
onKeydown: _cache[5] || (_cache[5] = (...args) => unref(onKeyDown) && unref(onKeyDown)(...args))
|
|
460
|
-
}, [
|
|
461
|
-
createVNode(unref(ElTooltip), {
|
|
462
|
-
ref_key: "tooltip",
|
|
463
|
-
ref: tooltip,
|
|
464
|
-
visible: unref(tooltipVisible),
|
|
465
|
-
placement: _ctx.placement,
|
|
466
|
-
"fallback-placements": ["top", "bottom", "right", "left"],
|
|
467
|
-
"stop-popper-mouse-event": false,
|
|
468
|
-
"popper-class": _ctx.tooltipClass,
|
|
469
|
-
disabled: !unref(showTooltip),
|
|
470
|
-
persistent: tooltipPersistent.value
|
|
471
|
-
}, {
|
|
472
|
-
content: withCtx(() => [
|
|
473
|
-
createElementVNode(
|
|
474
|
-
"span",
|
|
475
|
-
null,
|
|
476
|
-
toDisplayString(unref(formatValue)),
|
|
477
|
-
1
|
|
478
|
-
)
|
|
479
|
-
]),
|
|
480
|
-
default: withCtx(() => [
|
|
481
|
-
createElementVNode(
|
|
482
|
-
"div",
|
|
483
|
-
{
|
|
484
|
-
class: normalizeClass([unref(ns).e("button"), { hover: unref(hovering), dragging: unref(dragging) }])
|
|
485
|
-
},
|
|
486
|
-
null,
|
|
487
|
-
2
|
|
488
|
-
)
|
|
489
|
-
]),
|
|
490
|
-
_: 1
|
|
491
|
-
}, 8, ["visible", "placement", "popper-class", "disabled", "persistent"])
|
|
492
|
-
], 46, _hoisted_1$2);
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
var SliderButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/slider/src/button.vue"]]);
|
|
497
|
-
|
|
498
|
-
const sliderMarkerProps = buildProps({
|
|
499
|
-
mark: {
|
|
500
|
-
type: definePropType([String, Object]),
|
|
501
|
-
default: void 0
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
var SliderMarker = defineComponent({
|
|
505
|
-
name: "ElSliderMarker",
|
|
506
|
-
props: sliderMarkerProps,
|
|
507
|
-
setup(props) {
|
|
508
|
-
const ns = useNamespace("slider");
|
|
509
|
-
const label = computed(() => {
|
|
510
|
-
return isString(props.mark) ? props.mark : props.mark.label;
|
|
511
|
-
});
|
|
512
|
-
const style = computed(
|
|
513
|
-
() => isString(props.mark) ? void 0 : props.mark.style
|
|
514
|
-
);
|
|
515
|
-
return () => h(
|
|
516
|
-
"div",
|
|
517
|
-
{
|
|
518
|
-
class: ns.e("marks-text"),
|
|
519
|
-
style: style.value
|
|
520
|
-
},
|
|
521
|
-
label.value
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
const useSlide = (props, initData, emit) => {
|
|
527
|
-
const { formItem: elFormItem } = useFormItem();
|
|
528
|
-
const slider = shallowRef();
|
|
529
|
-
const firstButton = ref();
|
|
530
|
-
const secondButton = ref();
|
|
531
|
-
const buttonRefs = {
|
|
532
|
-
firstButton,
|
|
533
|
-
secondButton
|
|
534
|
-
};
|
|
535
|
-
const sliderDisabled = useFormDisabled();
|
|
536
|
-
const minValue = computed(() => {
|
|
537
|
-
return Math.min(initData.firstValue, initData.secondValue);
|
|
538
|
-
});
|
|
539
|
-
const maxValue = computed(() => {
|
|
540
|
-
return Math.max(initData.firstValue, initData.secondValue);
|
|
541
|
-
});
|
|
542
|
-
const barSize = computed(() => {
|
|
543
|
-
return props.range ? `${100 * (maxValue.value - minValue.value) / (props.max - props.min)}%` : `${100 * (initData.firstValue - props.min) / (props.max - props.min)}%`;
|
|
544
|
-
});
|
|
545
|
-
const barStart = computed(() => {
|
|
546
|
-
return props.range ? `${100 * (minValue.value - props.min) / (props.max - props.min)}%` : "0%";
|
|
547
|
-
});
|
|
548
|
-
const runwayStyle = computed(() => {
|
|
549
|
-
return props.vertical ? { height: props.height } : {};
|
|
550
|
-
});
|
|
551
|
-
const barStyle = computed(() => {
|
|
552
|
-
return props.vertical ? {
|
|
553
|
-
height: barSize.value,
|
|
554
|
-
bottom: barStart.value
|
|
555
|
-
} : {
|
|
556
|
-
width: barSize.value,
|
|
557
|
-
left: barStart.value
|
|
558
|
-
};
|
|
559
|
-
});
|
|
560
|
-
const resetSize = () => {
|
|
561
|
-
if (slider.value) {
|
|
562
|
-
const rect = slider.value.getBoundingClientRect();
|
|
563
|
-
initData.sliderSize = rect[props.vertical ? "height" : "width"];
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
const getButtonRefByPercent = (percent) => {
|
|
567
|
-
const targetValue = props.min + percent * (props.max - props.min) / 100;
|
|
568
|
-
if (!props.range) {
|
|
569
|
-
return firstButton;
|
|
570
|
-
}
|
|
571
|
-
let buttonRefName;
|
|
572
|
-
if (Math.abs(minValue.value - targetValue) < Math.abs(maxValue.value - targetValue)) {
|
|
573
|
-
buttonRefName = initData.firstValue < initData.secondValue ? "firstButton" : "secondButton";
|
|
574
|
-
} else {
|
|
575
|
-
buttonRefName = initData.firstValue > initData.secondValue ? "firstButton" : "secondButton";
|
|
576
|
-
}
|
|
577
|
-
return buttonRefs[buttonRefName];
|
|
578
|
-
};
|
|
579
|
-
const setPosition = (percent) => {
|
|
580
|
-
const buttonRef = getButtonRefByPercent(percent);
|
|
581
|
-
buttonRef.value.setPosition(percent);
|
|
582
|
-
return buttonRef;
|
|
583
|
-
};
|
|
584
|
-
const setFirstValue = (firstValue) => {
|
|
585
|
-
initData.firstValue = firstValue != null ? firstValue : props.min;
|
|
586
|
-
_emit(
|
|
587
|
-
props.range ? [minValue.value, maxValue.value] : firstValue != null ? firstValue : props.min
|
|
588
|
-
);
|
|
589
|
-
};
|
|
590
|
-
const setSecondValue = (secondValue) => {
|
|
591
|
-
initData.secondValue = secondValue;
|
|
592
|
-
if (props.range) {
|
|
593
|
-
_emit([minValue.value, maxValue.value]);
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
const _emit = (val) => {
|
|
597
|
-
emit(UPDATE_MODEL_EVENT, val);
|
|
598
|
-
emit(INPUT_EVENT, val);
|
|
599
|
-
};
|
|
600
|
-
const emitChange = async () => {
|
|
601
|
-
await nextTick();
|
|
602
|
-
emit(
|
|
603
|
-
CHANGE_EVENT,
|
|
604
|
-
props.range ? [minValue.value, maxValue.value] : props.modelValue
|
|
605
|
-
);
|
|
606
|
-
};
|
|
607
|
-
const handleSliderPointerEvent = (event) => {
|
|
608
|
-
var _a, _b, _c, _d, _e, _f;
|
|
609
|
-
if (sliderDisabled.value || initData.dragging)
|
|
610
|
-
return;
|
|
611
|
-
resetSize();
|
|
612
|
-
let newPercent = 0;
|
|
613
|
-
if (props.vertical) {
|
|
614
|
-
const clientY = (_c = (_b = (_a = event.touches) == null ? void 0 : _a.item(0)) == null ? void 0 : _b.clientY) != null ? _c : event.clientY;
|
|
615
|
-
const sliderOffsetBottom = slider.value.getBoundingClientRect().bottom;
|
|
616
|
-
newPercent = (sliderOffsetBottom - clientY) / initData.sliderSize * 100;
|
|
617
|
-
} else {
|
|
618
|
-
const clientX = (_f = (_e = (_d = event.touches) == null ? void 0 : _d.item(0)) == null ? void 0 : _e.clientX) != null ? _f : event.clientX;
|
|
619
|
-
const sliderOffsetLeft = slider.value.getBoundingClientRect().left;
|
|
620
|
-
newPercent = (clientX - sliderOffsetLeft) / initData.sliderSize * 100;
|
|
621
|
-
}
|
|
622
|
-
if (newPercent < 0 || newPercent > 100)
|
|
623
|
-
return;
|
|
624
|
-
return setPosition(newPercent);
|
|
625
|
-
};
|
|
626
|
-
const onSliderWrapperPrevent = (event) => {
|
|
627
|
-
var _a, _b;
|
|
628
|
-
if (((_a = buttonRefs["firstButton"].value) == null ? void 0 : _a.dragging) || ((_b = buttonRefs["secondButton"].value) == null ? void 0 : _b.dragging)) {
|
|
629
|
-
event.preventDefault();
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
const onSliderDown = async (event) => {
|
|
633
|
-
const buttonRef = handleSliderPointerEvent(event);
|
|
634
|
-
if (buttonRef) {
|
|
635
|
-
await nextTick();
|
|
636
|
-
buttonRef.value.onButtonDown(event);
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
const onSliderClick = (event) => {
|
|
640
|
-
const buttonRef = handleSliderPointerEvent(event);
|
|
641
|
-
if (buttonRef) {
|
|
642
|
-
emitChange();
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
const onSliderMarkerDown = (position) => {
|
|
646
|
-
if (sliderDisabled.value || initData.dragging)
|
|
647
|
-
return;
|
|
648
|
-
const buttonRef = setPosition(position);
|
|
649
|
-
if (buttonRef) {
|
|
650
|
-
emitChange();
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
return {
|
|
654
|
-
elFormItem,
|
|
655
|
-
slider,
|
|
656
|
-
firstButton,
|
|
657
|
-
secondButton,
|
|
658
|
-
sliderDisabled,
|
|
659
|
-
minValue,
|
|
660
|
-
maxValue,
|
|
661
|
-
runwayStyle,
|
|
662
|
-
barStyle,
|
|
663
|
-
resetSize,
|
|
664
|
-
setPosition,
|
|
665
|
-
emitChange,
|
|
666
|
-
onSliderWrapperPrevent,
|
|
667
|
-
onSliderClick,
|
|
668
|
-
onSliderDown,
|
|
669
|
-
onSliderMarkerDown,
|
|
670
|
-
setFirstValue,
|
|
671
|
-
setSecondValue
|
|
672
|
-
};
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
const useStops = (props, initData, minValue, maxValue) => {
|
|
676
|
-
const stops = computed(() => {
|
|
677
|
-
if (!props.showStops || props.min > props.max)
|
|
678
|
-
return [];
|
|
679
|
-
if (props.step === 0) {
|
|
680
|
-
debugWarn("ElSlider", "step should not be 0.");
|
|
681
|
-
return [];
|
|
682
|
-
}
|
|
683
|
-
const stopCount = Math.ceil((props.max - props.min) / props.step);
|
|
684
|
-
const stepWidth = 100 * props.step / (props.max - props.min);
|
|
685
|
-
const result = Array.from({ length: stopCount - 1 }).map(
|
|
686
|
-
(_, index) => (index + 1) * stepWidth
|
|
687
|
-
);
|
|
688
|
-
if (props.range) {
|
|
689
|
-
return result.filter((step) => {
|
|
690
|
-
return step < 100 * (minValue.value - props.min) / (props.max - props.min) || step > 100 * (maxValue.value - props.min) / (props.max - props.min);
|
|
691
|
-
});
|
|
692
|
-
} else {
|
|
693
|
-
return result.filter(
|
|
694
|
-
(step) => step > 100 * (initData.firstValue - props.min) / (props.max - props.min)
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
const getStopStyle = (position) => {
|
|
699
|
-
return props.vertical ? { bottom: `${position}%` } : { left: `${position}%` };
|
|
700
|
-
};
|
|
701
|
-
return {
|
|
702
|
-
stops,
|
|
703
|
-
getStopStyle
|
|
704
|
-
};
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
const useMarks = (props) => {
|
|
708
|
-
return computed(() => {
|
|
709
|
-
if (!props.marks) {
|
|
710
|
-
return [];
|
|
711
|
-
}
|
|
712
|
-
const marksKeys = Object.keys(props.marks);
|
|
713
|
-
return marksKeys.map(Number.parseFloat).sort((a, b) => a - b).filter((point) => point <= props.max && point >= props.min).map(
|
|
714
|
-
(point) => ({
|
|
715
|
-
point,
|
|
716
|
-
position: (point - props.min) * 100 / (props.max - props.min),
|
|
717
|
-
mark: props.marks[point]
|
|
718
|
-
})
|
|
719
|
-
);
|
|
720
|
-
});
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
const useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {
|
|
724
|
-
const _emit = (val) => {
|
|
725
|
-
emit(UPDATE_MODEL_EVENT, val);
|
|
726
|
-
emit(INPUT_EVENT, val);
|
|
727
|
-
};
|
|
728
|
-
const valueChanged = () => {
|
|
729
|
-
if (props.range) {
|
|
730
|
-
return ![minValue.value, maxValue.value].every(
|
|
731
|
-
(item, index) => item === initData.oldValue[index]
|
|
732
|
-
);
|
|
733
|
-
} else {
|
|
734
|
-
return props.modelValue !== initData.oldValue;
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
const setValues = () => {
|
|
738
|
-
var _a, _b;
|
|
739
|
-
if (props.min > props.max) {
|
|
740
|
-
throwError("Slider", "min should not be greater than max.");
|
|
741
|
-
}
|
|
742
|
-
const val = props.modelValue;
|
|
743
|
-
if (props.range && isArray(val)) {
|
|
744
|
-
if (val[1] < props.min) {
|
|
745
|
-
_emit([props.min, props.min]);
|
|
746
|
-
} else if (val[0] > props.max) {
|
|
747
|
-
_emit([props.max, props.max]);
|
|
748
|
-
} else if (val[0] < props.min) {
|
|
749
|
-
_emit([props.min, val[1]]);
|
|
750
|
-
} else if (val[1] > props.max) {
|
|
751
|
-
_emit([val[0], props.max]);
|
|
752
|
-
} else {
|
|
753
|
-
initData.firstValue = val[0];
|
|
754
|
-
initData.secondValue = val[1];
|
|
755
|
-
if (valueChanged()) {
|
|
756
|
-
if (props.validateEvent) {
|
|
757
|
-
(_a = elFormItem == null ? void 0 : elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "change").catch((err) => debugWarn(err));
|
|
758
|
-
}
|
|
759
|
-
initData.oldValue = val.slice();
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
} else if (!props.range && isNumber(val) && !Number.isNaN(val)) {
|
|
763
|
-
if (val < props.min) {
|
|
764
|
-
_emit(props.min);
|
|
765
|
-
} else if (val > props.max) {
|
|
766
|
-
_emit(props.max);
|
|
767
|
-
} else {
|
|
768
|
-
initData.firstValue = val;
|
|
769
|
-
if (valueChanged()) {
|
|
770
|
-
if (props.validateEvent) {
|
|
771
|
-
(_b = elFormItem == null ? void 0 : elFormItem.validate) == null ? void 0 : _b.call(elFormItem, "change").catch((err) => debugWarn(err));
|
|
772
|
-
}
|
|
773
|
-
initData.oldValue = val;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
setValues();
|
|
779
|
-
watch(
|
|
780
|
-
() => initData.dragging,
|
|
781
|
-
(val) => {
|
|
782
|
-
if (!val) {
|
|
783
|
-
setValues();
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
);
|
|
787
|
-
watch(
|
|
788
|
-
() => props.modelValue,
|
|
789
|
-
(val, oldVal) => {
|
|
790
|
-
if (initData.dragging || isArray(val) && isArray(oldVal) && val.every((item, index) => item === oldVal[index]) && initData.firstValue === val[0] && initData.secondValue === val[1]) {
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
setValues();
|
|
794
|
-
},
|
|
795
|
-
{
|
|
796
|
-
deep: true
|
|
797
|
-
}
|
|
798
|
-
);
|
|
799
|
-
watch(
|
|
800
|
-
() => [props.min, props.max],
|
|
801
|
-
() => {
|
|
802
|
-
setValues();
|
|
803
|
-
}
|
|
804
|
-
);
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
const useLifecycle = (props, initData, resetSize) => {
|
|
808
|
-
const sliderWrapper = ref();
|
|
809
|
-
onMounted(async () => {
|
|
810
|
-
if (props.range) {
|
|
811
|
-
if (isArray(props.modelValue)) {
|
|
812
|
-
initData.firstValue = Math.max(props.min, props.modelValue[0]);
|
|
813
|
-
initData.secondValue = Math.min(props.max, props.modelValue[1]);
|
|
814
|
-
} else {
|
|
815
|
-
initData.firstValue = props.min;
|
|
816
|
-
initData.secondValue = props.max;
|
|
817
|
-
}
|
|
818
|
-
initData.oldValue = [initData.firstValue, initData.secondValue];
|
|
819
|
-
} else {
|
|
820
|
-
if (!isNumber(props.modelValue) || Number.isNaN(props.modelValue)) {
|
|
821
|
-
initData.firstValue = props.min;
|
|
822
|
-
} else {
|
|
823
|
-
initData.firstValue = Math.min(
|
|
824
|
-
props.max,
|
|
825
|
-
Math.max(props.min, props.modelValue)
|
|
826
|
-
);
|
|
827
|
-
}
|
|
828
|
-
initData.oldValue = initData.firstValue;
|
|
829
|
-
}
|
|
830
|
-
useEventListener(window, "resize", resetSize);
|
|
831
|
-
await nextTick();
|
|
832
|
-
resetSize();
|
|
833
|
-
});
|
|
834
|
-
return {
|
|
835
|
-
sliderWrapper
|
|
836
|
-
};
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
const _hoisted_1$1 = ["id", "role", "aria-label", "aria-labelledby"];
|
|
840
|
-
const _hoisted_2 = { key: 1 };
|
|
841
|
-
const _sfc_main$1 = defineComponent({
|
|
842
|
-
...{
|
|
843
|
-
name: "ElSlider"
|
|
844
|
-
},
|
|
845
|
-
__name: "slider",
|
|
846
|
-
props: sliderProps,
|
|
847
|
-
emits: sliderEmits,
|
|
848
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
849
|
-
const props = __props;
|
|
850
|
-
const emit = __emit;
|
|
851
|
-
const ns = useNamespace("slider");
|
|
852
|
-
const { t } = useLocale();
|
|
853
|
-
const initData = reactive({
|
|
854
|
-
firstValue: 0,
|
|
855
|
-
secondValue: 0,
|
|
856
|
-
oldValue: 0,
|
|
857
|
-
dragging: false,
|
|
858
|
-
sliderSize: 1
|
|
859
|
-
});
|
|
860
|
-
const {
|
|
861
|
-
elFormItem,
|
|
862
|
-
slider,
|
|
863
|
-
firstButton,
|
|
864
|
-
secondButton,
|
|
865
|
-
sliderDisabled,
|
|
866
|
-
minValue,
|
|
867
|
-
maxValue,
|
|
868
|
-
runwayStyle,
|
|
869
|
-
barStyle,
|
|
870
|
-
resetSize,
|
|
871
|
-
emitChange,
|
|
872
|
-
onSliderWrapperPrevent,
|
|
873
|
-
onSliderClick,
|
|
874
|
-
onSliderDown,
|
|
875
|
-
onSliderMarkerDown,
|
|
876
|
-
setFirstValue,
|
|
877
|
-
setSecondValue
|
|
878
|
-
} = useSlide(props, initData, emit);
|
|
879
|
-
const { stops, getStopStyle } = useStops(props, initData, minValue, maxValue);
|
|
880
|
-
const { inputId, isLabeledByFormItem } = useFormItemInputId(props, {
|
|
881
|
-
formItemContext: elFormItem
|
|
882
|
-
});
|
|
883
|
-
const sliderWrapperSize = useFormSize();
|
|
884
|
-
const sliderInputSize = computed(
|
|
885
|
-
() => props.inputSize || sliderWrapperSize.value
|
|
886
|
-
);
|
|
887
|
-
const groupLabel = computed(() => {
|
|
888
|
-
return props.ariaLabel || t("el.slider.defaultLabel", {
|
|
889
|
-
min: props.min,
|
|
890
|
-
max: props.max
|
|
891
|
-
});
|
|
892
|
-
});
|
|
893
|
-
const firstButtonLabel = computed(() => {
|
|
894
|
-
if (props.range) {
|
|
895
|
-
return props.rangeStartLabel || t("el.slider.defaultRangeStartLabel");
|
|
896
|
-
} else {
|
|
897
|
-
return groupLabel.value;
|
|
898
|
-
}
|
|
899
|
-
});
|
|
900
|
-
const firstValueText = computed(() => {
|
|
901
|
-
return props.formatValueText ? props.formatValueText(firstValue.value) : `${firstValue.value}`;
|
|
902
|
-
});
|
|
903
|
-
const secondButtonLabel = computed(() => {
|
|
904
|
-
return props.rangeEndLabel || t("el.slider.defaultRangeEndLabel");
|
|
905
|
-
});
|
|
906
|
-
const secondValueText = computed(() => {
|
|
907
|
-
return props.formatValueText ? props.formatValueText(secondValue.value) : `${secondValue.value}`;
|
|
908
|
-
});
|
|
909
|
-
const sliderKls = computed(() => [
|
|
910
|
-
ns.b(),
|
|
911
|
-
ns.m(sliderWrapperSize.value),
|
|
912
|
-
ns.is("vertical", props.vertical),
|
|
913
|
-
{ [ns.m("with-input")]: props.showInput }
|
|
914
|
-
]);
|
|
915
|
-
const markList = useMarks(props);
|
|
916
|
-
useWatch(props, initData, minValue, maxValue, emit, elFormItem);
|
|
917
|
-
const precision = computed(() => {
|
|
918
|
-
const precisions = [props.min, props.max, props.step].map((item) => {
|
|
919
|
-
const decimal = `${item}`.split(".")[1];
|
|
920
|
-
return decimal ? decimal.length : 0;
|
|
921
|
-
});
|
|
922
|
-
return Math.max.apply(null, precisions);
|
|
923
|
-
});
|
|
924
|
-
const { sliderWrapper } = useLifecycle(props, initData, resetSize);
|
|
925
|
-
const { firstValue, secondValue, sliderSize } = toRefs(initData);
|
|
926
|
-
const updateDragging = (val) => {
|
|
927
|
-
initData.dragging = val;
|
|
928
|
-
};
|
|
929
|
-
useEventListener(sliderWrapper, "touchstart", onSliderWrapperPrevent, {
|
|
930
|
-
passive: false
|
|
931
|
-
});
|
|
932
|
-
useEventListener(sliderWrapper, "touchmove", onSliderWrapperPrevent, {
|
|
933
|
-
passive: false
|
|
934
|
-
});
|
|
935
|
-
provide(sliderContextKey, {
|
|
936
|
-
...toRefs(props),
|
|
937
|
-
sliderSize,
|
|
938
|
-
disabled: sliderDisabled,
|
|
939
|
-
precision,
|
|
940
|
-
emitChange,
|
|
941
|
-
resetSize,
|
|
942
|
-
updateDragging
|
|
943
|
-
});
|
|
944
|
-
__expose({
|
|
945
|
-
onSliderClick
|
|
946
|
-
});
|
|
947
|
-
return (_ctx, _cache) => {
|
|
948
|
-
var _a, _b;
|
|
949
|
-
return openBlock(), createElementBlock("div", {
|
|
950
|
-
id: _ctx.range ? unref(inputId) : void 0,
|
|
951
|
-
ref_key: "sliderWrapper",
|
|
952
|
-
ref: sliderWrapper,
|
|
953
|
-
class: normalizeClass(sliderKls.value),
|
|
954
|
-
role: _ctx.range ? "group" : void 0,
|
|
955
|
-
"aria-label": _ctx.range && !unref(isLabeledByFormItem) ? groupLabel.value : void 0,
|
|
956
|
-
"aria-labelledby": _ctx.range && unref(isLabeledByFormItem) ? (_a = unref(elFormItem)) == null ? void 0 : _a.labelId : void 0
|
|
957
|
-
}, [
|
|
958
|
-
createElementVNode(
|
|
959
|
-
"div",
|
|
960
|
-
{
|
|
961
|
-
ref_key: "slider",
|
|
962
|
-
ref: slider,
|
|
963
|
-
class: normalizeClass([
|
|
964
|
-
unref(ns).e("runway"),
|
|
965
|
-
{ "show-input": _ctx.showInput && !_ctx.range },
|
|
966
|
-
unref(ns).is("disabled", unref(sliderDisabled))
|
|
967
|
-
]),
|
|
968
|
-
style: normalizeStyle(unref(runwayStyle)),
|
|
969
|
-
onMousedown: _cache[0] || (_cache[0] = (...args) => unref(onSliderDown) && unref(onSliderDown)(...args)),
|
|
970
|
-
onTouchstartPassive: _cache[1] || (_cache[1] = (...args) => unref(onSliderDown) && unref(onSliderDown)(...args))
|
|
971
|
-
},
|
|
972
|
-
[
|
|
973
|
-
createElementVNode(
|
|
974
|
-
"div",
|
|
975
|
-
{
|
|
976
|
-
class: normalizeClass(unref(ns).e("bar")),
|
|
977
|
-
style: normalizeStyle(unref(barStyle))
|
|
978
|
-
},
|
|
979
|
-
null,
|
|
980
|
-
6
|
|
981
|
-
),
|
|
982
|
-
createVNode(SliderButton, {
|
|
983
|
-
id: !_ctx.range ? unref(inputId) : void 0,
|
|
984
|
-
ref_key: "firstButton",
|
|
985
|
-
ref: firstButton,
|
|
986
|
-
"model-value": unref(firstValue),
|
|
987
|
-
vertical: _ctx.vertical,
|
|
988
|
-
"tooltip-class": _ctx.tooltipClass,
|
|
989
|
-
placement: _ctx.placement,
|
|
990
|
-
role: "slider",
|
|
991
|
-
"aria-label": _ctx.range || !unref(isLabeledByFormItem) ? firstButtonLabel.value : void 0,
|
|
992
|
-
"aria-labelledby": !_ctx.range && unref(isLabeledByFormItem) ? (_b = unref(elFormItem)) == null ? void 0 : _b.labelId : void 0,
|
|
993
|
-
"aria-valuemin": _ctx.min,
|
|
994
|
-
"aria-valuemax": _ctx.range ? unref(secondValue) : _ctx.max,
|
|
995
|
-
"aria-valuenow": unref(firstValue),
|
|
996
|
-
"aria-valuetext": firstValueText.value,
|
|
997
|
-
"aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
|
|
998
|
-
"aria-disabled": unref(sliderDisabled),
|
|
999
|
-
"onUpdate:modelValue": unref(setFirstValue)
|
|
1000
|
-
}, null, 8, ["id", "model-value", "vertical", "tooltip-class", "placement", "aria-label", "aria-labelledby", "aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-valuetext", "aria-orientation", "aria-disabled", "onUpdate:modelValue"]),
|
|
1001
|
-
_ctx.range ? (openBlock(), createBlock(SliderButton, {
|
|
1002
|
-
key: 0,
|
|
1003
|
-
ref_key: "secondButton",
|
|
1004
|
-
ref: secondButton,
|
|
1005
|
-
"model-value": unref(secondValue),
|
|
1006
|
-
vertical: _ctx.vertical,
|
|
1007
|
-
"tooltip-class": _ctx.tooltipClass,
|
|
1008
|
-
placement: _ctx.placement,
|
|
1009
|
-
role: "slider",
|
|
1010
|
-
"aria-label": secondButtonLabel.value,
|
|
1011
|
-
"aria-valuemin": unref(firstValue),
|
|
1012
|
-
"aria-valuemax": _ctx.max,
|
|
1013
|
-
"aria-valuenow": unref(secondValue),
|
|
1014
|
-
"aria-valuetext": secondValueText.value,
|
|
1015
|
-
"aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
|
|
1016
|
-
"aria-disabled": unref(sliderDisabled),
|
|
1017
|
-
"onUpdate:modelValue": unref(setSecondValue)
|
|
1018
|
-
}, null, 8, ["model-value", "vertical", "tooltip-class", "placement", "aria-label", "aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-valuetext", "aria-orientation", "aria-disabled", "onUpdate:modelValue"])) : createCommentVNode("v-if", true),
|
|
1019
|
-
_ctx.showStops ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
1020
|
-
(openBlock(true), createElementBlock(
|
|
1021
|
-
Fragment,
|
|
1022
|
-
null,
|
|
1023
|
-
renderList(unref(stops), (item, key) => {
|
|
1024
|
-
return openBlock(), createElementBlock(
|
|
1025
|
-
"div",
|
|
1026
|
-
{
|
|
1027
|
-
key,
|
|
1028
|
-
class: normalizeClass(unref(ns).e("stop")),
|
|
1029
|
-
style: normalizeStyle(unref(getStopStyle)(item))
|
|
1030
|
-
},
|
|
1031
|
-
null,
|
|
1032
|
-
6
|
|
1033
|
-
);
|
|
1034
|
-
}),
|
|
1035
|
-
128
|
|
1036
|
-
))
|
|
1037
|
-
])) : createCommentVNode("v-if", true),
|
|
1038
|
-
unref(markList).length > 0 ? (openBlock(), createElementBlock(
|
|
1039
|
-
Fragment,
|
|
1040
|
-
{ key: 2 },
|
|
1041
|
-
[
|
|
1042
|
-
createElementVNode("div", null, [
|
|
1043
|
-
(openBlock(true), createElementBlock(
|
|
1044
|
-
Fragment,
|
|
1045
|
-
null,
|
|
1046
|
-
renderList(unref(markList), (item, key) => {
|
|
1047
|
-
return openBlock(), createElementBlock(
|
|
1048
|
-
"div",
|
|
1049
|
-
{
|
|
1050
|
-
key,
|
|
1051
|
-
style: normalizeStyle(unref(getStopStyle)(item.position)),
|
|
1052
|
-
class: normalizeClass([unref(ns).e("stop"), unref(ns).e("marks-stop")])
|
|
1053
|
-
},
|
|
1054
|
-
null,
|
|
1055
|
-
6
|
|
1056
|
-
);
|
|
1057
|
-
}),
|
|
1058
|
-
128
|
|
1059
|
-
))
|
|
1060
|
-
]),
|
|
1061
|
-
createElementVNode(
|
|
1062
|
-
"div",
|
|
1063
|
-
{
|
|
1064
|
-
class: normalizeClass(unref(ns).e("marks"))
|
|
1065
|
-
},
|
|
1066
|
-
[
|
|
1067
|
-
(openBlock(true), createElementBlock(
|
|
1068
|
-
Fragment,
|
|
1069
|
-
null,
|
|
1070
|
-
renderList(unref(markList), (item, key) => {
|
|
1071
|
-
return openBlock(), createBlock(unref(SliderMarker), {
|
|
1072
|
-
key,
|
|
1073
|
-
mark: item.mark,
|
|
1074
|
-
style: normalizeStyle(unref(getStopStyle)(item.position)),
|
|
1075
|
-
onMousedown: withModifiers(($event) => unref(onSliderMarkerDown)(item.position), ["stop"])
|
|
1076
|
-
}, null, 8, ["mark", "style", "onMousedown"]);
|
|
1077
|
-
}),
|
|
1078
|
-
128
|
|
1079
|
-
))
|
|
1080
|
-
],
|
|
1081
|
-
2
|
|
1082
|
-
)
|
|
1083
|
-
],
|
|
1084
|
-
64
|
|
1085
|
-
)) : createCommentVNode("v-if", true)
|
|
1086
|
-
],
|
|
1087
|
-
38
|
|
1088
|
-
),
|
|
1089
|
-
_ctx.showInput && !_ctx.range ? (openBlock(), createBlock(unref(ElInputNumber), {
|
|
1090
|
-
key: 0,
|
|
1091
|
-
ref: "input",
|
|
1092
|
-
"model-value": unref(firstValue),
|
|
1093
|
-
class: normalizeClass(unref(ns).e("input")),
|
|
1094
|
-
step: _ctx.step,
|
|
1095
|
-
disabled: unref(sliderDisabled),
|
|
1096
|
-
controls: _ctx.showInputControls,
|
|
1097
|
-
min: _ctx.min,
|
|
1098
|
-
max: _ctx.max,
|
|
1099
|
-
precision: precision.value,
|
|
1100
|
-
size: sliderInputSize.value,
|
|
1101
|
-
"onUpdate:modelValue": unref(setFirstValue),
|
|
1102
|
-
onChange: unref(emitChange)
|
|
1103
|
-
}, null, 8, ["model-value", "class", "step", "disabled", "controls", "min", "max", "precision", "size", "onUpdate:modelValue", "onChange"])) : createCommentVNode("v-if", true)
|
|
1104
|
-
], 10, _hoisted_1$1);
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
var Slider = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/slider/src/slider.vue"]]);
|
|
1109
|
-
|
|
1110
|
-
const ElSlider = withInstall(Slider);
|
|
1111
|
-
|
|
1112
35
|
const _hoisted_1 = ["src"];
|
|
1113
36
|
const DEFAULT_VOLUME = 50;
|
|
1114
37
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1226,13 +149,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1226
149
|
"show-tooltip": false,
|
|
1227
150
|
class: normalizeClass(_ctx.$style.volume)
|
|
1228
151
|
}, null, 8, ["modelValue", "class"]),
|
|
1229
|
-
createVNode(_sfc_main$
|
|
152
|
+
createVNode(_sfc_main$1, {
|
|
1230
153
|
name: "fas",
|
|
1231
154
|
class: normalizeClass([_ctx.$style["volume-controll"], unref(volumeIcon)]),
|
|
1232
155
|
onClick: toggleVolume
|
|
1233
156
|
}, null, 8, ["class"])
|
|
1234
157
|
], 2),
|
|
1235
|
-
createVNode(_sfc_main$
|
|
158
|
+
createVNode(_sfc_main$1, {
|
|
1236
159
|
name: "fas",
|
|
1237
160
|
class: normalizeClass([_ctx.$style.play, unref(playClass)]),
|
|
1238
161
|
onClick: togglePlay
|
|
@@ -1262,7 +185,7 @@ const style0 = {
|
|
|
1262
185
|
const cssModules = {
|
|
1263
186
|
"$style": style0
|
|
1264
187
|
};
|
|
1265
|
-
const Component = /* @__PURE__ */ _export_sfc
|
|
188
|
+
const Component = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
|
|
1266
189
|
|
|
1267
190
|
const __vite_glob_0_47 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1268
191
|
__proto__: null,
|