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