vue-devui 1.0.0-rc.1 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -200
- package/auto-complete/index.es.js +55 -77
- package/auto-complete/index.umd.js +3 -1
- package/auto-complete/style.css +1 -1
- package/editable-select/index.es.js +118 -162
- package/editable-select/index.umd.js +1 -1
- package/nuxt/components/tagProps.js +3 -0
- package/package.json +1 -1
- package/popover/index.es.js +2 -2
- package/popover/index.umd.js +4 -4
- package/progress/index.es.js +1 -1
- package/progress/index.umd.js +1 -1
- package/progress/style.css +1 -1
- package/radio/index.es.js +8 -2
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/ripple/index.es.js +43 -42
- package/ripple/index.umd.js +1 -1
- package/slider/index.es.js +58 -58
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +168 -125
- package/splitter/index.umd.js +11 -11
- package/style.css +1 -1
- package/tag/index.es.js +13 -17
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/vue-devui.es.js +765 -605
- package/vue-devui.umd.js +18 -16
- package/accordion/index.d.ts +0 -7
- package/accordion/index.es.js +0 -723
- package/accordion/index.umd.js +0 -1
- package/accordion/package.json +0 -7
- package/accordion/style.css +0 -1
- package/anchor/index.d.ts +0 -7
- package/anchor/index.es.js +0 -263
- package/anchor/index.umd.js +0 -1
- package/anchor/package.json +0 -7
- package/anchor/style.css +0 -1
- package/back-top/index.d.ts +0 -7
- package/back-top/index.es.js +0 -130
- package/back-top/index.umd.js +0 -1
- package/back-top/package.json +0 -7
- package/back-top/style.css +0 -1
- package/breadcrumb/index.d.ts +0 -7
- package/breadcrumb/index.es.js +0 -128
- package/breadcrumb/index.umd.js +0 -1
- package/breadcrumb/package.json +0 -7
- package/breadcrumb/style.css +0 -1
- package/carousel/index.d.ts +0 -7
- package/carousel/index.es.js +0 -314
- package/carousel/index.umd.js +0 -1
- package/carousel/package.json +0 -7
- package/carousel/style.css +0 -1
- package/cascader/index.d.ts +0 -7
- package/cascader/index.es.js +0 -5971
- package/cascader/index.umd.js +0 -27
- package/cascader/package.json +0 -7
- package/cascader/style.css +0 -1
- package/color-picker/index.d.ts +0 -7
- package/color-picker/index.es.js +0 -8196
- package/color-picker/index.umd.js +0 -27
- package/color-picker/package.json +0 -7
- package/color-picker/style.css +0 -1
- package/date-picker/index.d.ts +0 -7
- package/date-picker/index.es.js +0 -1154
- 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/drawer/index.d.ts +0 -7
- package/drawer/index.es.js +0 -234
- package/drawer/index.umd.js +0 -1
- package/drawer/package.json +0 -7
- package/drawer/style.css +0 -1
- package/dropdown/index.d.ts +0 -7
- package/dropdown/index.es.js +0 -693
- package/dropdown/index.umd.js +0 -1
- package/dropdown/package.json +0 -7
- package/dropdown/style.css +0 -1
- package/form/index.d.ts +0 -7
- package/form/index.es.js +0 -7876
- package/form/index.umd.js +0 -27
- package/form/package.json +0 -7
- package/form/style.css +0 -1
- package/gantt/index.d.ts +0 -7
- package/gantt/index.es.js +0 -523
- package/gantt/index.umd.js +0 -1
- package/gantt/package.json +0 -7
- package/gantt/style.css +0 -1
- package/input-icon/index.d.ts +0 -7
- package/input-icon/index.es.js +0 -332
- package/input-icon/index.umd.js +0 -1
- package/input-icon/package.json +0 -7
- package/input-icon/style.css +0 -1
- package/input-number/index.d.ts +0 -7
- package/input-number/index.es.js +0 -229
- package/input-number/index.umd.js +0 -1
- package/input-number/package.json +0 -7
- package/input-number/style.css +0 -1
- package/list/index.d.ts +0 -7
- package/list/index.es.js +0 -39
- package/list/index.umd.js +0 -1
- package/list/package.json +0 -7
- package/list/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/Column.js +0 -3
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/Drawer.js +0 -3
- package/nuxt/components/DrawerService.js +0 -3
- package/nuxt/components/Dropdown.js +0 -3
- package/nuxt/components/DropdownMenu.js +0 -3
- package/nuxt/components/Form.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormItem.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/FormOperation.js +0 -3
- package/nuxt/components/Gantt.js +0 -3
- package/nuxt/components/InputIcon.js +0 -3
- package/nuxt/components/InputNumber.js +0 -3
- package/nuxt/components/List.js +0 -3
- package/nuxt/components/ListItem.js +0 -3
- package/nuxt/components/NavSprite.js +0 -2
- package/nuxt/components/QuadrantDiagram.js +0 -3
- package/nuxt/components/Select.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/Table.js +0 -3
- package/nuxt/components/Tabs.js +0 -3
- package/nuxt/components/TimePicker.js +0 -3
- package/nuxt/components/Tooltip.js +0 -3
- package/nuxt/components/Transfer.js +0 -3
- package/nuxt/components/Tree.js +0 -3
- package/nuxt/components/TreeSelect.js +0 -3
- package/nuxt/components/dropdownMenuProps.js +0 -3
- package/nuxt/components/tooltipProps.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/select/index.d.ts +0 -7
- package/select/index.es.js +0 -706
- package/select/index.umd.js +0 -1
- package/select/package.json +0 -7
- package/select/style.css +0 -1
- package/steps-guide/index.d.ts +0 -7
- package/steps-guide/index.es.js +0 -242
- 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/table/index.d.ts +0 -7
- package/table/index.es.js +0 -2024
- package/table/index.umd.js +0 -1
- package/table/package.json +0 -7
- package/table/style.css +0 -1
- package/tabs/index.d.ts +0 -7
- package/tabs/index.es.js +0 -194
- package/tabs/index.umd.js +0 -1
- package/tabs/package.json +0 -7
- package/tabs/style.css +0 -1
- package/time-picker/index.d.ts +0 -7
- package/time-picker/index.es.js +0 -1238
- package/time-picker/index.umd.js +0 -1
- package/time-picker/package.json +0 -7
- package/time-picker/style.css +0 -1
- package/tooltip/index.d.ts +0 -7
- package/tooltip/index.es.js +0 -5835
- package/tooltip/index.umd.js +0 -27
- package/tooltip/package.json +0 -7
- package/tooltip/style.css +0 -1
- package/transfer/index.d.ts +0 -7
- package/transfer/index.es.js +0 -7615
- package/transfer/index.umd.js +0 -27
- package/transfer/package.json +0 -7
- package/transfer/style.css +0 -1
- package/tree/index.d.ts +0 -7
- package/tree/index.es.js +0 -6495
- package/tree/index.umd.js +0 -27
- package/tree/package.json +0 -7
- package/tree/style.css +0 -1
- package/tree-select/index.d.ts +0 -7
- package/tree-select/index.es.js +0 -627
- package/tree-select/index.umd.js +0 -1
- package/tree-select/package.json +0 -7
- package/tree-select/style.css +0 -1
package/ripple/index.es.js
CHANGED
|
@@ -19,9 +19,9 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
19
19
|
color: "currentColor",
|
|
20
20
|
initialOpacity: 0.2,
|
|
21
21
|
finalOpacity: 0.1,
|
|
22
|
-
duration:
|
|
22
|
+
duration: 400,
|
|
23
23
|
easing: "ease-out",
|
|
24
|
-
|
|
24
|
+
delay: 75,
|
|
25
25
|
disabled: false
|
|
26
26
|
};
|
|
27
27
|
const createContainer = ({
|
|
@@ -53,7 +53,7 @@ const createrippleElement = (x, y, size, options) => {
|
|
|
53
53
|
rippleElement.style.borderRadius = "50%";
|
|
54
54
|
rippleElement.style.opacity = `${options.initialOpacity}`;
|
|
55
55
|
rippleElement.style.transform = `translate(-50%,-50%) scale(0)`;
|
|
56
|
-
rippleElement.style.transition = `transform ${options.duration}s ${options.easing}, opacity ${options.duration}s ${options.easing}`;
|
|
56
|
+
rippleElement.style.transition = `transform ${options.duration / 1e3}s ${options.easing}, opacity ${options.duration / 1e3}s ${options.easing}`;
|
|
57
57
|
return rippleElement;
|
|
58
58
|
};
|
|
59
59
|
function magnitude(x1, y1, x2, y2) {
|
|
@@ -73,6 +73,13 @@ const getRelativePointer = ({ x, y }, { top, left }) => ({
|
|
|
73
73
|
y: y - top
|
|
74
74
|
});
|
|
75
75
|
const RIPPLE_COUNT = "vRippleCountInternal";
|
|
76
|
+
function setRippleCount(el, count) {
|
|
77
|
+
el.dataset[RIPPLE_COUNT] = count.toString();
|
|
78
|
+
}
|
|
79
|
+
function getRippleCount(el) {
|
|
80
|
+
var _a;
|
|
81
|
+
return parseInt((_a = el.dataset[RIPPLE_COUNT]) != null ? _a : "0", 10);
|
|
82
|
+
}
|
|
76
83
|
function incrementRippleCount(el) {
|
|
77
84
|
const count = getRippleCount(el);
|
|
78
85
|
setRippleCount(el, count + 1);
|
|
@@ -81,13 +88,6 @@ function decrementRippleCount(el) {
|
|
|
81
88
|
const count = getRippleCount(el);
|
|
82
89
|
setRippleCount(el, count - 1);
|
|
83
90
|
}
|
|
84
|
-
function setRippleCount(el, count) {
|
|
85
|
-
el.dataset[RIPPLE_COUNT] = count.toString();
|
|
86
|
-
}
|
|
87
|
-
function getRippleCount(el) {
|
|
88
|
-
var _a;
|
|
89
|
-
return parseInt((_a = el.dataset[RIPPLE_COUNT]) != null ? _a : "0", 10);
|
|
90
|
-
}
|
|
91
91
|
function deleteRippleCount(el) {
|
|
92
92
|
delete el.dataset[RIPPLE_COUNT];
|
|
93
93
|
}
|
|
@@ -99,29 +99,10 @@ const ripple = (event, el, options) => {
|
|
|
99
99
|
const size = MULTIPLE_NUMBER * getDistanceToFurthestCorner(x, y, rect);
|
|
100
100
|
const rippleContainer = createContainer(computedStyles);
|
|
101
101
|
const rippleEl = createrippleElement(x, y, size, options);
|
|
102
|
-
incrementRippleCount(el);
|
|
103
102
|
let originalPositionValue = "";
|
|
104
|
-
if (computedStyles.position === "static") {
|
|
105
|
-
if (el.style.position) {
|
|
106
|
-
originalPositionValue = el.style.position;
|
|
107
|
-
}
|
|
108
|
-
el.style.position = "relative";
|
|
109
|
-
}
|
|
110
|
-
rippleContainer.appendChild(rippleEl);
|
|
111
|
-
el.appendChild(rippleContainer);
|
|
112
103
|
let shouldDissolveripple = false;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
document.removeEventListener("pointerup", releaseripple);
|
|
116
|
-
document.removeEventListener("pointercancel", releaseripple);
|
|
117
|
-
}
|
|
118
|
-
if (shouldDissolveripple) {
|
|
119
|
-
dissolveripple();
|
|
120
|
-
} else {
|
|
121
|
-
shouldDissolveripple = true;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
const dissolveripple = () => {
|
|
104
|
+
let token = null;
|
|
105
|
+
function dissolveripple() {
|
|
125
106
|
rippleEl.style.transition = "opacity 150ms linear";
|
|
126
107
|
rippleEl.style.opacity = "0";
|
|
127
108
|
setTimeout(() => {
|
|
@@ -132,24 +113,44 @@ const ripple = (event, el, options) => {
|
|
|
132
113
|
el.style.position = originalPositionValue;
|
|
133
114
|
}
|
|
134
115
|
}, 150);
|
|
135
|
-
}
|
|
116
|
+
}
|
|
117
|
+
function releaseripple(e) {
|
|
118
|
+
if (typeof e !== "undefined") {
|
|
119
|
+
document.removeEventListener("pointerup", releaseripple);
|
|
120
|
+
document.removeEventListener("pointercancel", releaseripple);
|
|
121
|
+
}
|
|
122
|
+
if (shouldDissolveripple) {
|
|
123
|
+
dissolveripple();
|
|
124
|
+
} else {
|
|
125
|
+
shouldDissolveripple = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function cancelripple() {
|
|
129
|
+
clearTimeout(token);
|
|
130
|
+
rippleContainer.remove();
|
|
131
|
+
document.removeEventListener("pointerup", releaseripple);
|
|
132
|
+
document.removeEventListener("pointercancel", releaseripple);
|
|
133
|
+
document.removeEventListener("pointercancel", cancelripple);
|
|
134
|
+
}
|
|
135
|
+
incrementRippleCount(el);
|
|
136
|
+
if (computedStyles.position === "static") {
|
|
137
|
+
if (el.style.position) {
|
|
138
|
+
originalPositionValue = el.style.position;
|
|
139
|
+
}
|
|
140
|
+
el.style.position = "relative";
|
|
141
|
+
}
|
|
142
|
+
rippleContainer.appendChild(rippleEl);
|
|
143
|
+
el.appendChild(rippleContainer);
|
|
136
144
|
document.addEventListener("pointerup", releaseripple);
|
|
137
145
|
document.addEventListener("pointercancel", releaseripple);
|
|
138
|
-
|
|
146
|
+
token = setTimeout(() => {
|
|
139
147
|
document.removeEventListener("pointercancel", cancelripple);
|
|
140
148
|
requestAnimationFrame(() => {
|
|
141
149
|
rippleEl.style.transform = `translate(-50%,-50%) scale(1)`;
|
|
142
150
|
rippleEl.style.opacity = `${options.finalOpacity}`;
|
|
143
|
-
setTimeout(() => releaseripple(), options.duration
|
|
151
|
+
setTimeout(() => releaseripple(), options.duration);
|
|
144
152
|
});
|
|
145
|
-
}, options.
|
|
146
|
-
const cancelripple = () => {
|
|
147
|
-
clearTimeout(token);
|
|
148
|
-
rippleContainer.remove();
|
|
149
|
-
document.removeEventListener("pointerup", releaseripple);
|
|
150
|
-
document.removeEventListener("pointercancel", releaseripple);
|
|
151
|
-
document.removeEventListener("pointercancel", cancelripple);
|
|
152
|
-
};
|
|
153
|
+
}, options.delay);
|
|
153
154
|
document.addEventListener("pointercancel", cancelripple);
|
|
154
155
|
};
|
|
155
156
|
const optionMap = /* @__PURE__ */ new WeakMap();
|
package/ripple/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var B=Object.defineProperty;var T=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var
|
|
1
|
+
var B=Object.defineProperty;var T=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var w=(s,r,l)=>r in s?B(s,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[r]=l,f=(s,r)=>{for(var l in r||(r={}))F.call(r,l)&&w(s,l,r[l]);if(T)for(var l of T(r))j.call(r,l)&&w(s,l,r[l]);return s};(function(s,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis!="undefined"?globalThis:s||self,r(s.index={}))})(this,function(s){"use strict";const r={directive:"ripple",color:"currentColor",initialOpacity:.2,finalOpacity:.1,duration:400,easing:"ease-out",delay:75,disabled:!1},l=({borderTopLeftRadius:t,borderTopRightRadius:e,borderBottomLeftRadius:i,borderBottomRightRadius:o})=>{const n=document.createElement("div");return n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.position="absolute",n.style.borderRadius=`${t} ${e} ${o} ${i}`,n.style.overflow="hidden",n.style.pointerEvents="none",n.style.webkitMaskImage="-webkit-radial-gradient(white, black)",n},M=(t,e,i,o)=>{const n=document.createElement("div");return n.style.position="absolute",n.style.width=`${i}px`,n.style.height=`${i}px`,n.style.top=`${e}px`,n.style.left=`${t}px`,n.style.background=o.color,n.style.borderRadius="50%",n.style.opacity=`${o.initialOpacity}`,n.style.transform="translate(-50%,-50%) scale(0)",n.style.transition=`transform ${o.duration/1e3}s ${o.easing}, opacity ${o.duration/1e3}s ${o.easing}`,n};function u(t,e,i,o){const n=t-i,a=e-o;return Math.sqrt(n*n+a*a)}function O(t,e,{width:i,height:o}){const n=u(t,e,0,0),a=u(t,e,i,0),d=u(t,e,0,o),g=u(t,e,i,o);return Math.max(n,a,d,g)}const P=({x:t,y:e},{top:i,left:o})=>({x:t-o,y:e-i}),y="vRippleCountInternal";function R(t,e){t.dataset[y]=e.toString()}function v(t){var e;return parseInt((e=t.dataset[y])!=null?e:"0",10)}function k(t){const e=v(t);R(t,e+1)}function I(t){const e=v(t);R(t,e-1)}function x(t){delete t.dataset[y]}const S=2.05,_=(t,e,i)=>{const o=e.getBoundingClientRect(),n=window.getComputedStyle(e),{x:a,y:d}=P(t,o),g=S*O(a,d,o),m=l(n),p=M(a,d,g,i);let h="",b=!1,$=null;function N(){p.style.transition="opacity 150ms linear",p.style.opacity="0",setTimeout(()=>{m.remove(),I(e),v(e)===0&&(x(e),e.style.position=h)},150)}function c(A){typeof A!="undefined"&&(document.removeEventListener("pointerup",c),document.removeEventListener("pointercancel",c)),b?N():b=!0}function C(){clearTimeout($),m.remove(),document.removeEventListener("pointerup",c),document.removeEventListener("pointercancel",c),document.removeEventListener("pointercancel",C)}k(e),n.position==="static"&&(e.style.position&&(h=e.style.position),e.style.position="relative"),m.appendChild(p),e.appendChild(m),document.addEventListener("pointerup",c),document.addEventListener("pointercancel",c),$=setTimeout(()=>{document.removeEventListener("pointercancel",C),requestAnimationFrame(()=>{p.style.transform="translate(-50%,-50%) scale(1)",p.style.opacity=`${i.finalOpacity}`,setTimeout(()=>c(),i.duration)})},i.delay),document.addEventListener("pointercancel",C)},E=new WeakMap,D=f({},r);var L={mounted(t,e){var i;E.set(t,(i=e.value)!=null?i:{}),t.addEventListener("pointerdown",o=>{const n=E.get(t);e.value&&e.value.disabled||n!==!1&&_(o,t,f(f({},D),n))})},updated(t,e){var i;E.set(t,(i=e.value)!=null?i:{})}},U={title:"Ripple \u6C34\u6CE2\u7EB9",category:"\u901A\u7528",status:"100%",install(t){t.directive("Ripple",L)}};s.RippleDirective=L,s.default=U,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module"});
|
package/slider/index.es.js
CHANGED
|
@@ -44,6 +44,63 @@ var Slider = defineComponent({
|
|
|
44
44
|
const currentPosition = ref(0);
|
|
45
45
|
const newPostion = ref(0);
|
|
46
46
|
const percentDispaly = ref("");
|
|
47
|
+
function handleOnInput(event) {
|
|
48
|
+
inputValue.value = parseInt(event.target.value);
|
|
49
|
+
if (!inputValue.value) {
|
|
50
|
+
inputValue.value = props.min;
|
|
51
|
+
percentDispaly.value = "0%";
|
|
52
|
+
} else {
|
|
53
|
+
if (inputValue.value < props.min || inputValue.value > props.max) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const re = /^(?:[1-9]?\d|100)$/;
|
|
57
|
+
if (re.test(`${inputValue.value}`)) {
|
|
58
|
+
percentDispaly.value = (inputValue.value - props.min) * 100 / (props.max - props.min) + "%";
|
|
59
|
+
ctx.emit("update:modelValue", inputValue.value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function setPostion(newPosition) {
|
|
64
|
+
const sliderWidth = Math.round(sliderRunway.value.clientWidth);
|
|
65
|
+
if (newPosition < 0) {
|
|
66
|
+
newPosition = 0;
|
|
67
|
+
}
|
|
68
|
+
const LengthPerStep = sliderWidth / ((props.max - props.min) / props.step);
|
|
69
|
+
const steps = Math.round(newPosition / LengthPerStep);
|
|
70
|
+
const value = steps * LengthPerStep;
|
|
71
|
+
if (Math.round(value) >= sliderWidth) {
|
|
72
|
+
currentPosition.value = sliderWidth;
|
|
73
|
+
inputValue.value = props.max;
|
|
74
|
+
percentDispaly.value = "100%";
|
|
75
|
+
ctx.emit("update:modelValue", props.max);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
percentDispaly.value = Math.round(value * 100 / sliderWidth) + "%";
|
|
79
|
+
inputValue.value = Math.round(value * (props.max - props.min) / sliderWidth) + props.min;
|
|
80
|
+
currentPosition.value = newPosition;
|
|
81
|
+
ctx.emit("update:modelValue", inputValue.value);
|
|
82
|
+
}
|
|
83
|
+
function dragStart(event) {
|
|
84
|
+
isClick = false;
|
|
85
|
+
startX = event.clientX;
|
|
86
|
+
startPosition = currentPosition.value;
|
|
87
|
+
newPostion.value = startPosition;
|
|
88
|
+
}
|
|
89
|
+
function onDragging(event) {
|
|
90
|
+
popoverShow.value = true;
|
|
91
|
+
const currentX = event.clientX;
|
|
92
|
+
const pxOffset = currentX - startX;
|
|
93
|
+
newPostion.value = startPosition + pxOffset;
|
|
94
|
+
setPostion(newPostion.value);
|
|
95
|
+
}
|
|
96
|
+
function onDragEnd() {
|
|
97
|
+
popoverShow.value = false;
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
isClick = true;
|
|
100
|
+
}, 100);
|
|
101
|
+
window.removeEventListener("mousemove", onDragging);
|
|
102
|
+
window.removeEventListener("mouseup", onDragEnd);
|
|
103
|
+
}
|
|
47
104
|
const renderShowInput = () => {
|
|
48
105
|
return props.showInput ? createVNode("div", {
|
|
49
106
|
"class": "devui-input__out-wrap"
|
|
@@ -73,47 +130,6 @@ var Slider = defineComponent({
|
|
|
73
130
|
window.addEventListener("mousemove", onDragging);
|
|
74
131
|
window.addEventListener("mouseup", onDragEnd);
|
|
75
132
|
}
|
|
76
|
-
function dragStart(event) {
|
|
77
|
-
isClick = false;
|
|
78
|
-
startX = event.clientX;
|
|
79
|
-
startPosition = currentPosition.value;
|
|
80
|
-
newPostion.value = startPosition;
|
|
81
|
-
}
|
|
82
|
-
function onDragging(event) {
|
|
83
|
-
popoverShow.value = true;
|
|
84
|
-
const currentX = event.clientX;
|
|
85
|
-
const pxOffset = currentX - startX;
|
|
86
|
-
newPostion.value = startPosition + pxOffset;
|
|
87
|
-
setPostion(newPostion.value);
|
|
88
|
-
}
|
|
89
|
-
function onDragEnd() {
|
|
90
|
-
popoverShow.value = false;
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
isClick = true;
|
|
93
|
-
}, 100);
|
|
94
|
-
window.removeEventListener("mousemove", onDragging);
|
|
95
|
-
window.removeEventListener("mouseup", onDragEnd);
|
|
96
|
-
}
|
|
97
|
-
function setPostion(newPosition) {
|
|
98
|
-
const sliderWidth = Math.round(sliderRunway.value.clientWidth);
|
|
99
|
-
if (newPosition < 0) {
|
|
100
|
-
newPosition = 0;
|
|
101
|
-
}
|
|
102
|
-
const LengthPerStep = sliderWidth / ((props.max - props.min) / props.step);
|
|
103
|
-
const steps = Math.round(newPosition / LengthPerStep);
|
|
104
|
-
const value = steps * LengthPerStep;
|
|
105
|
-
if (Math.round(value) >= sliderWidth) {
|
|
106
|
-
currentPosition.value = sliderWidth;
|
|
107
|
-
inputValue.value = props.max;
|
|
108
|
-
percentDispaly.value = "100%";
|
|
109
|
-
ctx.emit("update:modelValue", props.max);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
percentDispaly.value = Math.round(value * 100 / sliderWidth) + "%";
|
|
113
|
-
inputValue.value = Math.round(value * (props.max - props.min) / sliderWidth) + props.min;
|
|
114
|
-
currentPosition.value = newPosition;
|
|
115
|
-
ctx.emit("update:modelValue", inputValue.value);
|
|
116
|
-
}
|
|
117
133
|
function handleRunwayMousedown(event) {
|
|
118
134
|
if (!props.disabled && isClick) {
|
|
119
135
|
startX = event.target.getBoundingClientRect().left;
|
|
@@ -124,22 +140,6 @@ var Slider = defineComponent({
|
|
|
124
140
|
return;
|
|
125
141
|
}
|
|
126
142
|
}
|
|
127
|
-
function handleOnInput(event) {
|
|
128
|
-
inputValue.value = parseInt(event.target.value);
|
|
129
|
-
if (!inputValue.value) {
|
|
130
|
-
inputValue.value = props.min;
|
|
131
|
-
percentDispaly.value = "0%";
|
|
132
|
-
} else {
|
|
133
|
-
if (inputValue.value < props.min || inputValue.value > props.max) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const re = /^(?:[1-9]?\d|100)$/;
|
|
137
|
-
if (re.test(`${inputValue.value}`)) {
|
|
138
|
-
percentDispaly.value = (inputValue.value - props.min) * 100 / (props.max - props.min) + "%";
|
|
139
|
-
ctx.emit("update:modelValue", inputValue.value);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
143
|
const disableClass = computed(() => {
|
|
144
144
|
return props.disabled ? " disabled" : "";
|
|
145
145
|
});
|
|
@@ -191,7 +191,7 @@ var index = {
|
|
|
191
191
|
category: "\u6570\u636E\u5F55\u5165",
|
|
192
192
|
status: "100%",
|
|
193
193
|
install(app) {
|
|
194
|
-
app.
|
|
194
|
+
app.component(Slider.name, Slider);
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
export { Slider, index as default };
|
package/slider/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis!="undefined"?globalThis:a||self,t(a.index={},a.Vue))})(this,function(a,t){"use strict";const g={disabled:{type:Boolean,default:!1},max:{type:Number,default:100},min:{type:Number,default:0},modelValue:{type:Number,default:0},showInput:{type:Boolean,default:!1},step:{type:Number,default:1},tipsRenderer:{type:String,default:""}};var R="",o=t.defineComponent({name:"DSlider",props:g,emits:["update:modelValue"],setup(e,
|
|
1
|
+
(function(a,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis!="undefined"?globalThis:a||self,t(a.index={},a.Vue))})(this,function(a,t){"use strict";const g={disabled:{type:Boolean,default:!1},max:{type:Number,default:100},min:{type:Number,default:0},modelValue:{type:Number,default:0},showInput:{type:Boolean,default:!1},step:{type:Number,default:1},tipsRenderer:{type:String,default:""}};var R="",o=t.defineComponent({name:"DSlider",props:g,emits:["update:modelValue"],setup(e,m){let v=!0,f=0,s=0;const d=t.ref(!1),V=t.ref(null),l=t.ref(e.modelValue),r=t.ref(0),h=t.ref(0),u=t.ref("");function S(n){if(l.value=parseInt(n.target.value),!l.value)l.value=e.min,u.value="0%";else{if(l.value<e.min||l.value>e.max)return;/^(?:[1-9]?\d|100)$/.test(`${l.value}`)&&(u.value=(l.value-e.min)*100/(e.max-e.min)+"%",m.emit("update:modelValue",l.value))}}function M(n){const i=Math.round(V.value.clientWidth);n<0&&(n=0);const c=i/((e.max-e.min)/e.step),y=Math.round(n/c)*c;if(Math.round(y)>=i){r.value=i,l.value=e.max,u.value="100%",m.emit("update:modelValue",e.max);return}u.value=Math.round(y*100/i)+"%",l.value=Math.round(y*(e.max-e.min)/i)+e.min,r.value=n,m.emit("update:modelValue",l.value)}function E(n){v=!1,s=n.clientX,f=r.value,h.value=f}function N(n){d.value=!0;const c=n.clientX-s;h.value=f+c,M(h.value)}function _(){d.value=!1,setTimeout(()=>{v=!0},100),window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",_)}const X=()=>e.showInput?t.createVNode("div",{class:"devui-input__out-wrap"},[t.createVNode("input",{onInput:S,value:l.value+""},null)]):"";e.modelValue>e.max?u.value="100%":e.modelValue<e.min?u.value="0%":u.value=(e.modelValue-e.min)*100/(e.max-e.min)+"%",t.onMounted(()=>{const n=V.value.clientWidth;r.value=n*(l.value-e.min)/(e.max-e.min)});function b(n){d.value=!0,!e.disabled&&(n.preventDefault(),E(n),window.addEventListener("mousemove",N),window.addEventListener("mouseup",_))}function D(n){if(!e.disabled&&v){s=n.target.getBoundingClientRect().left;const i=n.clientX;M(i-s),b(n)}else return}const w=t.computed(()=>e.disabled?" disabled":""),I=()=>t.createVNode("div",{class:"devui-slider_popover",style:{left:u.value,opacity:d.value?1:0}},[t.createVNode("div",{class:"devui-slider_popover-arrow"},null),t.createVNode("div",{class:"devui-slider_popover-content"},[l.value+" "+e.tipsRenderer])]);return()=>t.createVNode("div",{class:"devui-slider"},[t.createVNode("div",{ref:V,class:"devui-slider__runway"+w.value,onMousedown:D,onMouseout:()=>d.value=!1},[t.createVNode("div",{class:"devui-slider__bar"+w.value,style:{width:u.value}},null),t.createVNode("div",{class:"devui-slider__button"+w.value,style:{left:u.value},onMousedown:b,onMouseenter:()=>d.value=!0,onMouseout:()=>d.value=!1},null),e.tipsRenderer==="null"?"":I()]),t.createVNode("span",{class:"devui-min_count"},[e.min]),t.createVNode("span",{class:"devui-max_count"},[e.max]),X()])}});o.install=function(e){e.component(o.name,o)};var x={title:"Slider \u6ED1\u5757",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(e){e.component(o.name,o)}};a.Slider=o,a.default=x,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"});
|