vue-devui 1.0.0-beta.18 → 1.0.0-beta.220801
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 +94 -118
- package/alert/index.es.js +74 -45
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +8349 -426
- package/auto-complete/index.umd.js +29 -1
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +153 -146
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +45 -20
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5743 -127
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +63 -35
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +8070 -255
- package/checkbox/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/{accordion → collapse}/index.d.ts +0 -0
- package/collapse/index.es.js +213 -0
- package/collapse/index.umd.js +1 -0
- package/{back-top → collapse}/package.json +1 -1
- package/collapse/style.css +1 -0
- package/countdown/index.es.js +60 -19
- package/countdown/index.umd.js +1 -1
- package/{anchor → date-picker-pro}/index.d.ts +0 -0
- package/date-picker-pro/index.es.js +12018 -0
- package/date-picker-pro/index.umd.js +27 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.es.js +184 -5736
- package/drawer/index.umd.js +1 -27
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +615 -396
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +786 -195
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +2360 -2094
- package/form/index.umd.js +17 -17
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +137 -134
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +101 -86
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +199 -56
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +55 -31
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +8254 -144
- package/input/index.umd.js +27 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +270 -187
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +40 -25
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +74 -35
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/{back-top → mention}/index.d.ts +0 -0
- package/{color-picker → mention}/index.es.js +2983 -2861
- package/mention/index.umd.js +36 -0
- package/{anchor → mention}/package.json +1 -1
- package/mention/style.css +1 -0
- package/{breadcrumb → menu}/index.d.ts +0 -0
- package/menu/index.es.js +870 -0
- package/menu/index.umd.js +1 -0
- package/{toast → menu}/package.json +1 -1
- package/menu/style.css +1 -0
- package/{carousel → message}/index.d.ts +0 -0
- package/message/index.es.js +538 -0
- package/message/index.umd.js +1 -0
- package/{comment → message}/package.json +1 -1
- package/message/style.css +1 -0
- package/modal/index.es.js +598 -1025
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/{cascader → notification}/index.d.ts +0 -0
- package/notification/index.es.js +545 -0
- package/notification/index.umd.js +1 -0
- package/{accordion → notification}/package.json +1 -1
- package/notification/style.css +1 -0
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/CheckboxGroup.js +3 -0
- package/nuxt/components/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/DRangeDatePickerPro.js +3 -0
- package/nuxt/components/DatePickerPro.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/DropdownPropsKey.js +3 -0
- package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
- package/nuxt/components/FORM_TOKEN.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/Icon.js +1 -0
- package/nuxt/components/IconGroup.js +3 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/LoadingOptions.js +3 -0
- package/nuxt/components/Mention.js +3 -0
- package/nuxt/components/Menu.js +3 -0
- package/nuxt/components/MenuItem.js +3 -0
- package/nuxt/components/Message.js +3 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/OptionGroup.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/Step.js +3 -0
- package/nuxt/components/Steps.js +3 -0
- package/nuxt/components/SubMenu.js +3 -0
- package/nuxt/components/TABLE_TOKEN.js +3 -0
- package/nuxt/components/Tab.js +3 -0
- package/nuxt/components/TimeSelect.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/animationInjectionKey.js +3 -0
- package/nuxt/components/autoCompleteProps.js +3 -0
- package/nuxt/components/avatarProps.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/cardProps.js +3 -0
- package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
- package/nuxt/components/checkboxGroupProps.js +3 -0
- package/nuxt/components/checkboxProps.js +3 -0
- package/nuxt/components/colProps.js +3 -0
- package/nuxt/components/colPropsBaseClass.js +3 -0
- package/nuxt/components/colPropsBaseStyle.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/countdownProps.js +3 -0
- package/nuxt/components/datePickerProCommonProps.js +3 -0
- package/nuxt/components/datePickerProPanelProps.js +3 -0
- package/nuxt/components/datePickerProProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/editableSelectProps.js +3 -0
- package/nuxt/components/fixedOverlayProps.js +3 -0
- package/nuxt/components/flexibleOverlayProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +3 -0
- package/nuxt/components/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/loadingProps.js +3 -0
- package/nuxt/components/mentionProps.js +3 -0
- package/nuxt/components/messageProps.js +3 -0
- package/nuxt/components/modalProps.js +3 -0
- package/nuxt/components/notificationProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/progressProps.js +3 -0
- package/nuxt/components/rateProps.js +3 -0
- package/nuxt/components/resultProps.js +3 -0
- package/nuxt/components/roundInjectionKey.js +3 -0
- package/nuxt/components/rowProps.js +3 -0
- package/nuxt/components/screenSizes.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/skeletonItemProps.js +3 -0
- package/nuxt/components/skeletonProps.js +3 -0
- package/nuxt/components/sliderProps.js +3 -0
- package/nuxt/components/splitterProps.js +3 -0
- package/nuxt/components/statisticProps.js +3 -0
- package/nuxt/components/stepProps.js +3 -0
- package/nuxt/components/stepsProps.js +3 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/nuxt/components/switchProps.js +3 -0
- package/nuxt/components/tableProps.js +3 -0
- package/nuxt/components/tabsProps.js +3 -0
- package/nuxt/components/tagProps.js +3 -0
- package/nuxt/components/textareaProps.js +3 -0
- package/nuxt/components/timeAxisProps.js +3 -0
- package/nuxt/components/timerPickerPanelProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/treeNodeProps.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/overlay/index.es.js +239 -314
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +44 -87
- package/pagination/index.es.js +331 -153
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +45 -32
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.es.js +6034 -215
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/progress/index.es.js +110 -56
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +7974 -157
- package/radio/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +77 -55
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +186 -57
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/ripple/index.es.js +47 -42
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +3868 -1149
- package/search/index.umd.js +18 -18
- package/search/style.css +1 -1
- package/select/index.es.js +9191 -493
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +113 -265
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +144 -137
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +6220 -226
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +41 -34
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +27 -6
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/{color-picker → steps}/index.d.ts +0 -0
- package/steps/index.es.js +386 -0
- package/steps/index.umd.js +1 -0
- package/{gantt → steps}/package.json +1 -1
- package/steps/style.css +1 -0
- package/style.css +1 -1
- package/switch/index.es.js +7804 -64
- package/switch/index.umd.js +27 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +11010 -1367
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +356 -144
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +49 -24
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +7924 -83
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/time-picker/index.es.js +8914 -602
- package/time-picker/index.umd.js +27 -1
- package/time-picker/style.css +1 -1
- package/{comment → time-select}/index.d.ts +0 -0
- package/{transfer → time-select}/index.es.js +4912 -2667
- package/time-select/index.umd.js +27 -0
- package/{breadcrumb → time-select}/package.json +1 -1
- package/time-select/style.css +1 -0
- package/{date-picker → timeline}/index.d.ts +0 -0
- package/timeline/index.es.js +427 -0
- package/timeline/index.umd.js +1 -0
- package/{carousel → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +5871 -96
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +7556 -2491
- package/tree/index.umd.js +18 -18
- package/tree/style.css +1 -1
- package/upload/index.es.js +865 -6117
- package/upload/index.umd.js +1 -27
- package/upload/style.css +1 -1
- package/vue-devui.es.js +20283 -18856
- package/vue-devui.umd.js +30 -19
- package/accordion/index.es.js +0 -508
- package/accordion/index.umd.js +0 -1
- package/accordion/style.css +0 -1
- package/anchor/index.es.js +0 -263
- package/anchor/index.umd.js +0 -1
- package/anchor/style.css +0 -1
- package/back-top/index.es.js +0 -128
- package/back-top/index.umd.js +0 -1
- package/back-top/style.css +0 -1
- package/breadcrumb/index.es.js +0 -127
- package/breadcrumb/index.umd.js +0 -1
- package/breadcrumb/style.css +0 -1
- package/carousel/index.es.js +0 -329
- package/carousel/index.umd.js +0 -1
- package/carousel/style.css +0 -1
- package/cascader/index.es.js +0 -5963
- package/cascader/index.umd.js +0 -27
- package/cascader/package.json +0 -7
- package/cascader/style.css +0 -1
- package/color-picker/index.umd.js +0 -27
- package/color-picker/package.json +0 -7
- package/color-picker/style.css +0 -1
- package/comment/index.es.js +0 -86
- package/comment/index.umd.js +0 -1
- package/comment/style.css +0 -1
- package/date-picker/index.es.js +0 -1171
- package/date-picker/index.umd.js +0 -1
- package/date-picker/package.json +0 -7
- package/date-picker/style.css +0 -1
- package/dragdrop/index.d.ts +0 -7
- package/dragdrop/index.es.js +0 -157
- package/dragdrop/index.umd.js +0 -1
- package/dragdrop/package.json +0 -7
- package/gantt/index.d.ts +0 -7
- package/gantt/index.es.js +0 -523
- package/gantt/index.umd.js +0 -1
- package/gantt/style.css +0 -1
- package/input-icon/index.d.ts +0 -7
- package/input-icon/index.es.js +0 -331
- package/input-icon/index.umd.js +0 -1
- package/input-icon/package.json +0 -7
- package/input-icon/style.css +0 -1
- package/nav-sprite/index.d.ts +0 -7
- package/nav-sprite/index.es.js +0 -68
- package/nav-sprite/index.umd.js +0 -1
- package/nav-sprite/package.json +0 -7
- package/nuxt/components/Accordion.js +0 -3
- package/nuxt/components/Anchor.js +0 -3
- package/nuxt/components/BackTop.js +0 -3
- package/nuxt/components/Breadcrumb.js +0 -3
- package/nuxt/components/Carousel.js +0 -3
- package/nuxt/components/CarouselItem.js +0 -3
- package/nuxt/components/Cascader.js +0 -3
- package/nuxt/components/ColorPicker.js +0 -3
- package/nuxt/components/Comment.js +0 -3
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/Gantt.js +0 -3
- package/nuxt/components/InputIcon.js +0 -3
- package/nuxt/components/NavSprite.js +0 -2
- package/nuxt/components/QuadrantDiagram.js +0 -3
- package/nuxt/components/ReadTip.js +0 -3
- package/nuxt/components/StepsGuide.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/Sticky.js +0 -2
- package/nuxt/components/TagInput.js +0 -3
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/Toast.js +0 -3
- package/nuxt/components/ToastService.js +0 -3
- package/nuxt/components/Transfer.js +0 -3
- package/nuxt/components/TreeSelect.js +0 -3
- package/quadrant-diagram/index.d.ts +0 -7
- package/quadrant-diagram/index.es.js +0 -5728
- package/quadrant-diagram/index.umd.js +0 -27
- package/quadrant-diagram/package.json +0 -7
- package/quadrant-diagram/style.css +0 -1
- package/read-tip/index.d.ts +0 -7
- package/read-tip/index.es.js +0 -258
- package/read-tip/index.umd.js +0 -1
- package/read-tip/package.json +0 -7
- package/read-tip/style.css +0 -1
- package/steps-guide/index.d.ts +0 -7
- package/steps-guide/index.es.js +0 -239
- package/steps-guide/index.umd.js +0 -1
- package/steps-guide/package.json +0 -7
- package/steps-guide/style.css +0 -1
- package/sticky/index.d.ts +0 -7
- package/sticky/index.es.js +0 -197
- package/sticky/index.umd.js +0 -1
- package/sticky/package.json +0 -7
- package/tag-input/index.d.ts +0 -7
- package/tag-input/index.es.js +0 -329
- package/tag-input/index.umd.js +0 -1
- package/tag-input/package.json +0 -7
- package/tag-input/style.css +0 -1
- package/time-axis/index.d.ts +0 -7
- package/time-axis/index.es.js +0 -299
- package/time-axis/index.umd.js +0 -1
- package/time-axis/package.json +0 -7
- package/time-axis/style.css +0 -1
- package/toast/index.d.ts +0 -7
- package/toast/index.es.js +0 -5918
- package/toast/index.umd.js +0 -27
- package/toast/style.css +0 -1
- package/transfer/index.d.ts +0 -7
- package/transfer/index.umd.js +0 -27
- package/transfer/package.json +0 -7
- package/transfer/style.css +0 -1
- package/tree-select/index.d.ts +0 -7
- package/tree-select/index.es.js +0 -623
- package/tree-select/index.umd.js +0 -1
- package/tree-select/package.json +0 -7
- package/tree-select/style.css +0 -1
package/slider/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ref, watch, onMounted, defineComponent, computed, createVNode } from "vue";
|
|
2
2
|
const sliderProps = {
|
|
3
3
|
disabled: {
|
|
4
4
|
type: Boolean,
|
|
@@ -16,181 +16,188 @@ const sliderProps = {
|
|
|
16
16
|
type: Number,
|
|
17
17
|
default: 0
|
|
18
18
|
},
|
|
19
|
-
showInput: {
|
|
20
|
-
type: Boolean,
|
|
21
|
-
default: false
|
|
22
|
-
},
|
|
23
19
|
step: {
|
|
24
20
|
type: Number,
|
|
25
21
|
default: 1
|
|
26
22
|
},
|
|
27
23
|
tipsRenderer: {
|
|
28
|
-
type:
|
|
29
|
-
default:
|
|
24
|
+
type: [Function, null],
|
|
25
|
+
default: () => (value) => `${value}`
|
|
30
26
|
}
|
|
31
27
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
28
|
+
function createBem(namespace, element, modifier) {
|
|
29
|
+
let cls = namespace;
|
|
30
|
+
if (element) {
|
|
31
|
+
cls += `__${element}`;
|
|
32
|
+
}
|
|
33
|
+
if (modifier) {
|
|
34
|
+
cls += `--${modifier}`;
|
|
35
|
+
}
|
|
36
|
+
return cls;
|
|
37
|
+
}
|
|
38
|
+
function useNamespace(block, needDot = false) {
|
|
39
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
40
|
+
const b = () => createBem(namespace);
|
|
41
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
42
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
43
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
44
|
+
return {
|
|
45
|
+
b,
|
|
46
|
+
e,
|
|
47
|
+
m,
|
|
48
|
+
em
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const isFunction = (value) => Object.prototype.toString.call(value) === "[object Function]";
|
|
52
|
+
function useSliderEvent(props, ctx) {
|
|
53
|
+
let isClick = true;
|
|
54
|
+
let startPosition = 0;
|
|
55
|
+
let startX = 0;
|
|
56
|
+
const sliderRunway = ref();
|
|
57
|
+
const currentValue = ref(Number(props.modelValue));
|
|
58
|
+
const currentPosition = ref(0);
|
|
59
|
+
const percentDisplay = ref("");
|
|
60
|
+
const popoverShow = ref(false);
|
|
61
|
+
const newPosition = ref(0);
|
|
62
|
+
function getSliderWidth() {
|
|
63
|
+
var _a;
|
|
64
|
+
return Boolean(sliderRunway.value) ? ((_a = sliderRunway.value) == null ? void 0 : _a.clientWidth) || 0 : 0;
|
|
65
|
+
}
|
|
66
|
+
function initCurrentPosition() {
|
|
67
|
+
const sliderWidth = getSliderWidth();
|
|
68
|
+
currentPosition.value = sliderWidth * (currentValue.value - props.min) / (props.max - props.min);
|
|
69
|
+
}
|
|
70
|
+
function setPosition(position) {
|
|
71
|
+
const clientWidth = getSliderWidth();
|
|
72
|
+
const sliderWidth = Math.round(clientWidth);
|
|
73
|
+
if (position < 0) {
|
|
74
|
+
position = 0;
|
|
61
75
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
const LengthPerStep = sliderWidth / ((props.max - props.min) / props.step);
|
|
77
|
+
const steps = Math.round(position / LengthPerStep);
|
|
78
|
+
const value = steps * LengthPerStep;
|
|
79
|
+
if (Math.round(value) >= sliderWidth) {
|
|
80
|
+
currentPosition.value = sliderWidth;
|
|
81
|
+
currentValue.value = props.max;
|
|
82
|
+
percentDisplay.value = "100%";
|
|
83
|
+
ctx.emit("update:modelValue", props.max);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
percentDisplay.value = Math.round(value * 100 / sliderWidth) + "%";
|
|
87
|
+
currentValue.value = Math.round(value * (props.max - props.min) / sliderWidth) + props.min;
|
|
88
|
+
currentPosition.value = position;
|
|
89
|
+
ctx.emit("update:modelValue", currentValue.value);
|
|
90
|
+
}
|
|
91
|
+
function dragStart(event) {
|
|
92
|
+
isClick = false;
|
|
93
|
+
startX = event.clientX;
|
|
94
|
+
startPosition = currentPosition.value;
|
|
95
|
+
newPosition.value = startPosition;
|
|
96
|
+
}
|
|
97
|
+
function onDragging(event) {
|
|
98
|
+
popoverShow.value = true;
|
|
99
|
+
const currentX = event.clientX;
|
|
100
|
+
const pxOffset = currentX - startX;
|
|
101
|
+
newPosition.value = startPosition + pxOffset;
|
|
102
|
+
setPosition(newPosition.value);
|
|
103
|
+
}
|
|
104
|
+
function onDragEnd() {
|
|
105
|
+
popoverShow.value = false;
|
|
106
|
+
setTimeout(() => {
|
|
107
|
+
isClick = true;
|
|
108
|
+
}, 100);
|
|
109
|
+
window.removeEventListener("mousemove", onDragging);
|
|
110
|
+
window.removeEventListener("mouseup", onDragEnd);
|
|
111
|
+
}
|
|
112
|
+
function handleButtonMousedown(event) {
|
|
113
|
+
popoverShow.value = true;
|
|
114
|
+
if (!props.disabled) {
|
|
70
115
|
event.preventDefault();
|
|
71
116
|
dragStart(event);
|
|
72
117
|
window.addEventListener("mousemove", onDragging);
|
|
73
118
|
window.addEventListener("mouseup", onDragEnd);
|
|
74
119
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
function onDragging(event) {
|
|
82
|
-
popoverShow.value = true;
|
|
120
|
+
}
|
|
121
|
+
function handleRunwayMousedown(event) {
|
|
122
|
+
if (!props.disabled && isClick) {
|
|
123
|
+
const _e = event.target;
|
|
124
|
+
startX = _e.getBoundingClientRect().left;
|
|
83
125
|
const currentX = event.clientX;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setPostion(newPostion.value);
|
|
87
|
-
}
|
|
88
|
-
function onDragEnd() {
|
|
89
|
-
popoverShow.value = false;
|
|
90
|
-
setTimeout(() => {
|
|
91
|
-
isClick = true;
|
|
92
|
-
}, 100);
|
|
93
|
-
window.removeEventListener("mousemove", onDragging);
|
|
94
|
-
window.removeEventListener("mouseup", onDragEnd);
|
|
95
|
-
}
|
|
96
|
-
function setPostion(newPosition) {
|
|
97
|
-
const sliderWidth = Math.round(sliderRunway.value.clientWidth);
|
|
98
|
-
if (newPosition < 0) {
|
|
99
|
-
newPosition = 0;
|
|
100
|
-
}
|
|
101
|
-
const LengthPerStep = sliderWidth / ((props.max - props.min) / props.step);
|
|
102
|
-
const steps = Math.round(newPosition / LengthPerStep);
|
|
103
|
-
const value = steps * LengthPerStep;
|
|
104
|
-
if (Math.round(value) >= sliderWidth) {
|
|
105
|
-
currentPosition.value = sliderWidth;
|
|
106
|
-
inputValue.value = props.max;
|
|
107
|
-
percentDispaly.value = "100%";
|
|
108
|
-
ctx.emit("update:modelValue", props.max);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
percentDispaly.value = Math.round(value * 100 / sliderWidth) + "%";
|
|
112
|
-
inputValue.value = Math.round(value * (props.max - props.min) / sliderWidth) + props.min;
|
|
113
|
-
currentPosition.value = newPosition;
|
|
114
|
-
ctx.emit("update:modelValue", inputValue.value);
|
|
126
|
+
setPosition(currentX - startX);
|
|
127
|
+
handleButtonMousedown(event);
|
|
115
128
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
function handleOnInput(event) {
|
|
127
|
-
inputValue.value = parseInt(event.target.value);
|
|
128
|
-
if (!inputValue.value) {
|
|
129
|
-
inputValue.value = props.min;
|
|
130
|
-
percentDispaly.value = "0%";
|
|
131
|
-
} else {
|
|
132
|
-
if (inputValue.value < props.min || inputValue.value > props.max) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const re = /^(?:[1-9]?\d|100)$/;
|
|
136
|
-
if (re.test(`${inputValue.value}`)) {
|
|
137
|
-
percentDispaly.value = (inputValue.value - props.min) * 100 / (props.max - props.min) + "%";
|
|
138
|
-
ctx.emit("update:modelValue", inputValue.value);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
129
|
+
}
|
|
130
|
+
watch(() => props.modelValue, () => {
|
|
131
|
+
currentValue.value = Number(props.modelValue);
|
|
132
|
+
if (currentValue.value > props.max) {
|
|
133
|
+
percentDisplay.value = "100%";
|
|
134
|
+
} else if (currentValue.value < props.min) {
|
|
135
|
+
percentDisplay.value = "0%";
|
|
136
|
+
} else {
|
|
137
|
+
percentDisplay.value = (currentValue.value - props.min) * 100 / (props.max - props.min) + "%";
|
|
141
138
|
}
|
|
139
|
+
initCurrentPosition();
|
|
140
|
+
}, { immediate: true });
|
|
141
|
+
onMounted(initCurrentPosition);
|
|
142
|
+
return { sliderRunway, popoverShow, percentDisplay, currentValue, handleRunwayMousedown, handleButtonMousedown };
|
|
143
|
+
}
|
|
144
|
+
var slider = "";
|
|
145
|
+
var Slider = defineComponent({
|
|
146
|
+
name: "DSlider",
|
|
147
|
+
props: sliderProps,
|
|
148
|
+
emits: ["update:modelValue"],
|
|
149
|
+
setup(props, ctx) {
|
|
150
|
+
const ns = useNamespace("slider");
|
|
151
|
+
const {
|
|
152
|
+
sliderRunway,
|
|
153
|
+
popoverShow,
|
|
154
|
+
percentDisplay,
|
|
155
|
+
currentValue,
|
|
156
|
+
handleRunwayMousedown,
|
|
157
|
+
handleButtonMousedown
|
|
158
|
+
} = useSliderEvent(props, ctx);
|
|
142
159
|
const disableClass = computed(() => {
|
|
143
160
|
return props.disabled ? " disabled" : "";
|
|
144
161
|
});
|
|
145
|
-
const
|
|
146
|
-
return createVNode("div", {
|
|
147
|
-
"class": "devui-slider_popover",
|
|
148
|
-
"style": {
|
|
149
|
-
left: percentDispaly.value,
|
|
150
|
-
opacity: popoverShow.value ? 1 : 0
|
|
151
|
-
}
|
|
152
|
-
}, [createVNode("div", {
|
|
153
|
-
"class": "devui-slider_popover-arrow"
|
|
154
|
-
}, null), createVNode("div", {
|
|
155
|
-
"class": "devui-slider_popover-content"
|
|
156
|
-
}, [inputValue.value + " " + props.tipsRenderer])]);
|
|
157
|
-
};
|
|
162
|
+
const tipsContent = computed(() => isFunction(props.tipsRenderer) ? props.tipsRenderer(currentValue.value) : "");
|
|
158
163
|
return () => createVNode("div", {
|
|
159
|
-
"class":
|
|
164
|
+
"class": ns.b()
|
|
160
165
|
}, [createVNode("div", {
|
|
161
166
|
"ref": sliderRunway,
|
|
162
|
-
"class": "
|
|
167
|
+
"class": [ns.e("runway"), disableClass.value],
|
|
163
168
|
"onMousedown": handleRunwayMousedown,
|
|
164
169
|
"onMouseout": () => popoverShow.value = false
|
|
165
170
|
}, [createVNode("div", {
|
|
166
|
-
"class": "
|
|
171
|
+
"class": [ns.e("bar"), disableClass.value],
|
|
167
172
|
"style": {
|
|
168
|
-
width:
|
|
173
|
+
width: percentDisplay.value
|
|
169
174
|
}
|
|
170
175
|
}, null), createVNode("div", {
|
|
171
|
-
"class": "
|
|
176
|
+
"class": [ns.e("button"), disableClass.value],
|
|
172
177
|
"style": {
|
|
173
|
-
left:
|
|
178
|
+
left: percentDisplay.value
|
|
174
179
|
},
|
|
175
180
|
"onMousedown": handleButtonMousedown,
|
|
176
181
|
"onMouseenter": () => popoverShow.value = true,
|
|
177
182
|
"onMouseout": () => popoverShow.value = false
|
|
178
|
-
}, null), props.tipsRenderer ===
|
|
179
|
-
"class": "
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
}, null), props.tipsRenderer === null ? null : popoverShow.value ? createVNode("div", {
|
|
184
|
+
"class": ns.e("popover"),
|
|
185
|
+
"style": {
|
|
186
|
+
left: percentDisplay.value
|
|
187
|
+
}
|
|
188
|
+
}, [createVNode("div", {
|
|
189
|
+
"class": ns.e("popover-arrow")
|
|
190
|
+
}, null), createVNode("div", {
|
|
191
|
+
"class": ns.e("popover-content")
|
|
192
|
+
}, [tipsContent.value])]) : null])]);
|
|
183
193
|
}
|
|
184
194
|
});
|
|
185
|
-
Slider.install = function(app) {
|
|
186
|
-
app.component(Slider.name, Slider);
|
|
187
|
-
};
|
|
188
195
|
var index = {
|
|
189
196
|
title: "Slider \u6ED1\u5757",
|
|
190
197
|
category: "\u6570\u636E\u5F55\u5165",
|
|
191
198
|
status: "100%",
|
|
192
199
|
install(app) {
|
|
193
|
-
app.
|
|
200
|
+
app.component(Slider.name, Slider);
|
|
194
201
|
}
|
|
195
202
|
};
|
|
196
|
-
export { Slider, index as default };
|
|
203
|
+
export { Slider, index as default, sliderProps };
|
package/slider/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(i,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(i=typeof globalThis!="undefined"?globalThis:i||self,t(i.index={},i.Vue))})(this,function(i,t){"use strict";const M={disabled:{type:Boolean,default:!1},max:{type:Number,default:100},min:{type:Number,default:0},modelValue:{type:Number,default:0},step:{type:Number,default:1},tipsRenderer:{type:[Function,null],default:()=>e=>`${e}`}};function w(e,r,u){let d=e;return r&&(d+=`__${r}`),u&&(d+=`--${u}`),d}function E(e,r=!1){const u=r?`.devui-${e}`:`devui-${e}`;return{b:()=>w(u),e:l=>l?w(u,l):"",m:l=>l?w(u,"",l):"",em:(l,o)=>l&&o?w(u,l,o):""}}const D=e=>Object.prototype.toString.call(e)==="[object Function]";function X(e,r){let u=!0,d=0,s=0;const f=t.ref(),a=t.ref(Number(e.modelValue)),l=t.ref(0),o=t.ref(""),m=t.ref(!1),v=t.ref(0);function V(){var n;return Boolean(f.value)&&((n=f.value)==null?void 0:n.clientWidth)||0}function N(){const n=V();l.value=n*(a.value-e.min)/(e.max-e.min)}function g(n){const y=V(),c=Math.round(y);n<0&&(n=0);const R=c/((e.max-e.min)/e.step),b=Math.round(n/R)*R;if(Math.round(b)>=c){l.value=c,a.value=e.max,o.value="100%",r.emit("update:modelValue",e.max);return}o.value=Math.round(b*100/c)+"%",a.value=Math.round(b*(e.max-e.min)/c)+e.min,l.value=n,r.emit("update:modelValue",a.value)}function C(n){u=!1,s=n.clientX,d=l.value,v.value=d}function S(n){m.value=!0;const c=n.clientX-s;v.value=d+c,g(v.value)}function x(){m.value=!1,setTimeout(()=>{u=!0},100),window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",x)}function P(n){m.value=!0,e.disabled||(n.preventDefault(),C(n),window.addEventListener("mousemove",S),window.addEventListener("mouseup",x))}function _(n){if(!e.disabled&&u){s=n.target.getBoundingClientRect().left;const c=n.clientX;g(c-s),P(n)}}return t.watch(()=>e.modelValue,()=>{a.value=Number(e.modelValue),a.value>e.max?o.value="100%":a.value<e.min?o.value="0%":o.value=(a.value-e.min)*100/(e.max-e.min)+"%",N()},{immediate:!0}),t.onMounted(N),{sliderRunway:f,popoverShow:m,percentDisplay:o,currentValue:a,handleRunwayMousedown:_,handleButtonMousedown:P}}var L="",h=t.defineComponent({name:"DSlider",props:M,emits:["update:modelValue"],setup(e,r){const u=E("slider"),{sliderRunway:d,popoverShow:s,percentDisplay:f,currentValue:a,handleRunwayMousedown:l,handleButtonMousedown:o}=X(e,r),m=t.computed(()=>e.disabled?" disabled":""),v=t.computed(()=>D(e.tipsRenderer)?e.tipsRenderer(a.value):"");return()=>t.createVNode("div",{class:u.b()},[t.createVNode("div",{ref:d,class:[u.e("runway"),m.value],onMousedown:l,onMouseout:()=>s.value=!1},[t.createVNode("div",{class:[u.e("bar"),m.value],style:{width:f.value}},null),t.createVNode("div",{class:[u.e("button"),m.value],style:{left:f.value},onMousedown:o,onMouseenter:()=>s.value=!0,onMouseout:()=>s.value=!1},null),e.tipsRenderer===null?null:s.value?t.createVNode("div",{class:u.e("popover"),style:{left:f.value}},[t.createVNode("div",{class:u.e("popover-arrow")},null),t.createVNode("div",{class:u.e("popover-content")},[v.value])]):null])])}}),B={title:"Slider \u6ED1\u5757",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(e){e.component(h.name,h)}};i.Slider=h,i.default=B,i.sliderProps=M,Object.defineProperty(i,"__esModule",{value:!0}),i[Symbol.toStringTag]="Module"});
|
package/slider/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.devui-slider{position:relative;width:
|
|
1
|
+
.devui-slider{position:relative;width:100%;display:block}.devui-slider.disabled{cursor:not-allowed;background-color:var(--devui-disabled-line, #dfe1e6);border-color:var(--devui-disabled-line, #dfe1e6)}.devui-slider__runway{position:relative;width:100%;padding:4px 0;margin:4px 0;cursor:pointer;box-sizing:border-box;height:5px;display:flex;align-items:center;border-radius:var(--devui-border-radius-full, 100px);background-color:var(--devui-area, #f8f8f8)}.devui-slider__runway.disabled{background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.devui-slider__runway:hover .devui-slider__bar:not(.disabled){background-color:var(--devui-brand-hover, #7693f5)}.devui-slider__runway .devui-slider__bar{height:6px;background-color:var(--devui-brand, #5e7ce0);border-top-left-radius:var(--devui-border-radius-full, 100px);border-bottom-left-radius:var(--devui-border-radius-full, 100px);position:absolute}.devui-slider__runway .devui-slider__bar.disabled{background-color:var(--devui-disabled-line, #dfe1e6);border-color:var(--devui-disabled-line, #dfe1e6)}.devui-slider__runway .devui-slider__bar.disabled:hover{cursor:not-allowed}.devui-slider__runway .devui-slider__button{position:absolute;width:14px;height:14px;border:2px solid var(--devui-brand, #5e7ce0);background-color:var(--devui-base-bg, #ffffff);border-radius:50%;margin-left:-7px;transition:transform .2s ease-in-out}.devui-slider__runway .devui-slider__button:hover:not(.disabled){border-color:var(--devui-brand-hover, #7693f5);transform:scale(1.3)}.devui-slider__runway .devui-slider__button.disabled{border-color:var(--devui-disabled-line, #dfe1e6)}.devui-slider__runway .devui-slider__button.disabled{cursor:not-allowed}.devui-slider__runway .devui-slider__popover{position:relative;bottom:26px;transform:translate(-50%);border-radius:var(--devui-border-radius-feedback, 4px);font-size:var(--devui-font-size-sm, 12px);color:var(--devui-feedback-overlay-text, #dfe1e6)}.devui-slider__runway .devui-slider__popover .devui-slider__popover-arrow{position:absolute;left:50%;margin-left:-4px;bottom:-4px;width:8px;height:8px;transform:rotate(45deg);display:block;z-index:-1;background-color:var(--devui-feedback-overlay-bg, #464d6e)}.devui-slider__runway .devui-slider__popover .devui-slider__popover-content{padding:5px 14px;text-align:center;border-radius:var(--devui-border-radius-feedback, 4px);background-color:var(--devui-feedback-overlay-bg, #464d6e)}
|