vue-devui 1.0.0-beta.14 → 1.0.0-beta.15
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 +3 -0
- package/auto-complete/style.css +1 -1
- package/carousel/index.es.js +5 -5
- package/carousel/index.umd.js +1 -1
- package/comment/index.es.js +3 -2
- package/comment/index.umd.js +1 -1
- package/comment/style.css +1 -1
- package/drawer/index.es.js +137 -58
- package/drawer/index.umd.js +1 -1
- package/nuxt/components/CarouselItem.js +3 -0
- package/package.json +21 -1
- package/splitter/index.es.js +69 -115
- package/splitter/index.umd.js +1 -1
- package/style.css +1 -1
- package/tag/index.es.js +2 -2
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tooltip/index.es.js +69 -115
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.es.js +68 -114
- package/transfer/index.umd.js +1 -1
- package/vue-devui.es.js +213 -178
- package/vue-devui.umd.js +5 -5
package/splitter/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { defineComponent, reactive, ref, onMounted,
|
|
7
|
+
import { defineComponent, reactive, ref, onMounted, onBeforeUnmount, renderSlot, useSlots, createVNode, inject, watch, computed, withDirectives, provide, onUnmounted, resolveComponent, onUpdated } from "vue";
|
|
8
8
|
const splitterProps = {
|
|
9
9
|
orientation: {
|
|
10
10
|
type: String,
|
|
@@ -44,140 +44,94 @@ const tooltipProps = {
|
|
|
44
44
|
default: "100"
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
const EventListener = {
|
|
48
|
-
listen: function(target, eventType, callback) {
|
|
49
|
-
if (target.addEventListener) {
|
|
50
|
-
target.addEventListener(eventType, callback, false);
|
|
51
|
-
return {
|
|
52
|
-
remove() {
|
|
53
|
-
target.removeEventListener(target, callback, false);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
} else {
|
|
57
|
-
target.attchEvent(eventType, callback);
|
|
58
|
-
return {
|
|
59
|
-
remove() {
|
|
60
|
-
target.detachEvent(eventType, callback);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
47
|
var tooltip = "";
|
|
67
48
|
var DToolTip = defineComponent({
|
|
68
49
|
name: "DTooltip",
|
|
69
50
|
props: tooltipProps,
|
|
70
|
-
setup(props
|
|
51
|
+
setup(props) {
|
|
71
52
|
const position = reactive({
|
|
72
53
|
left: 0,
|
|
73
54
|
top: 0
|
|
74
55
|
});
|
|
75
|
-
const show = ref(false);
|
|
76
|
-
const slotElement = ref(null);
|
|
77
|
-
const tooltip2 = ref(null);
|
|
78
|
-
const arrow = ref(null);
|
|
79
|
-
const tooltipcontent = ref(null);
|
|
80
|
-
let enterEvent;
|
|
81
|
-
let leaveEvent;
|
|
82
56
|
const arrowStyle = (attr, value) => {
|
|
83
|
-
arrow.
|
|
84
|
-
};
|
|
85
|
-
const delayShowTrue = function(fn, delay = props.mouseEnterDelay) {
|
|
86
|
-
let start;
|
|
87
|
-
if (parseInt(delay) >= 0) {
|
|
88
|
-
return function() {
|
|
89
|
-
if (start) {
|
|
90
|
-
clearTimeout(start);
|
|
91
|
-
}
|
|
92
|
-
start = setTimeout(fn, parseInt(delay));
|
|
93
|
-
};
|
|
94
|
-
} else {
|
|
95
|
-
console.error("the value of delay is bigger than 0 and the type of delay must be string!");
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
57
|
+
document.getElementById("devui-arrow").style[attr] = value;
|
|
98
58
|
};
|
|
59
|
+
const slotElement = ref(null);
|
|
99
60
|
onMounted(() => {
|
|
100
|
-
|
|
101
|
-
tooltip2
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
61
|
+
slotElement.value.children[0].onmouseenter = function() {
|
|
62
|
+
const tooltip2 = document.createElement("div");
|
|
63
|
+
const arrow = document.createElement("div");
|
|
64
|
+
const tooltipcontent = document.createElement("div");
|
|
65
|
+
tooltip2.classList.add("tooltip");
|
|
66
|
+
arrow.classList.add("arrow");
|
|
67
|
+
tooltipcontent.classList.add("tooltipcontent");
|
|
68
|
+
arrow.id = "devui-arrow";
|
|
69
|
+
tooltip2.id = "devui-tooltip1";
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
document.getElementById("devui-tooltip").appendChild(tooltip2);
|
|
72
|
+
tooltip2.appendChild(arrow);
|
|
73
|
+
tooltip2.appendChild(tooltipcontent);
|
|
74
|
+
tooltipcontent.innerHTML = props.content;
|
|
75
|
+
tooltip2.style.opacity = "1";
|
|
76
|
+
tooltip2.style.zIndex = "999";
|
|
77
|
+
arrow.style.border = "5px solid transparent";
|
|
78
|
+
switch (props.position) {
|
|
79
|
+
case "top":
|
|
80
|
+
position.left = slotElement.value.children[0].offsetLeft - tooltip2.offsetWidth / 2 + slotElement.value.children[0].offsetWidth / 2 - 5;
|
|
81
|
+
position.top = slotElement.value.children[0].offsetTop - 10 - tooltipcontent.offsetHeight;
|
|
82
|
+
arrow.style.top = `${tooltipcontent.offsetHeight}px`;
|
|
83
|
+
arrow.style.left = `${tooltipcontent.offsetWidth / 2 + 5}px`;
|
|
84
|
+
arrow.style.borderTop = "5px solid rgb(70, 77, 110)";
|
|
85
|
+
break;
|
|
86
|
+
case "bottom":
|
|
87
|
+
position.top = slotElement.value.children[0].offsetHeight + slotElement.value.children[0].offsetTop + 10;
|
|
88
|
+
position.left = slotElement.value.children[0].offsetLeft + slotElement.value.children[0].offsetWidth / 2 - tooltipcontent.offsetWidth / 2 - 5;
|
|
89
|
+
arrowStyle("borderBottom", "5px solid rgb(70, 77, 110)");
|
|
90
|
+
arrow.style.top = "-10px";
|
|
91
|
+
arrow.style.left = `${tooltipcontent.offsetWidth / 2 + 5}px`;
|
|
92
|
+
arrow.style.borderBottom = "5px solid rgb(70, 77, 110)";
|
|
93
|
+
break;
|
|
94
|
+
case "left":
|
|
95
|
+
position.top = slotElement.value.children[0].offsetTop + slotElement.value.children[0].offsetHeight / 2 - tooltipcontent.offsetHeight / 2;
|
|
96
|
+
position.left = slotElement.value.children[0].offsetLeft - 20 - tooltipcontent.offsetWidth;
|
|
97
|
+
arrowStyle("borderLeft", "5px solid rgb(70, 77, 110)");
|
|
98
|
+
arrow.style.left = `${tooltipcontent.offsetWidth + 10}px`;
|
|
99
|
+
arrow.style.top = `${tooltipcontent.offsetHeight / 2 - 5}px`;
|
|
100
|
+
arrow.style.borderLeft = "5px solid rgb(70, 77, 110)";
|
|
101
|
+
break;
|
|
102
|
+
case "right":
|
|
103
|
+
position.left = slotElement.value.children[0].offsetLeft + slotElement.value.children[0].offsetWidth;
|
|
104
|
+
position.top = slotElement.value.children[0].offsetTop + slotElement.value.children[0].offsetHeight / 2 - tooltipcontent.offsetHeight / 2;
|
|
105
|
+
arrowStyle("borderRight", "5px solid rgb(70, 77, 110)");
|
|
106
|
+
arrow.style.top = `${tooltipcontent.offsetHeight / 2 - 5}px`;
|
|
107
|
+
arrow.style.left = "-0px";
|
|
108
|
+
arrow.style.borderRight = "5px solid rgb(70, 77, 110)";
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
tooltip2.style.top = position.top + 5 + "px";
|
|
112
|
+
tooltip2.style.left = position.left + "px";
|
|
113
|
+
}, props.mouseEnterDelay);
|
|
114
|
+
};
|
|
115
|
+
slotElement.value.children[0].onmouseleave = function() {
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
document.getElementById("devui-tooltip1").removeChild(document.getElementById("devui-arrow"));
|
|
118
|
+
document.getElementById("devui-tooltip").removeChild(document.getElementById("devui-tooltip1"));
|
|
119
|
+
}, props.mouseLeaveDelay);
|
|
120
|
+
};
|
|
159
121
|
});
|
|
160
122
|
onBeforeUnmount(() => {
|
|
161
|
-
|
|
162
|
-
|
|
123
|
+
slotElement.value.children[0].onmouseenter = null;
|
|
124
|
+
slotElement.value.children[0].onmouseleave = null;
|
|
163
125
|
});
|
|
164
126
|
return () => {
|
|
165
127
|
const defaultSlot = renderSlot(useSlots(), "default");
|
|
166
128
|
return createVNode("div", {
|
|
167
|
-
"class": "devui-tooltip"
|
|
129
|
+
"class": "devui-tooltip",
|
|
130
|
+
"id": "devui-tooltip"
|
|
168
131
|
}, [createVNode("div", {
|
|
169
132
|
"class": "slotElement",
|
|
170
133
|
"ref": slotElement
|
|
171
|
-
}, [defaultSlot])
|
|
172
|
-
"class": "tooltip",
|
|
173
|
-
"ref": tooltip2
|
|
174
|
-
}, [createVNode("div", {
|
|
175
|
-
"class": "arrow",
|
|
176
|
-
"ref": arrow
|
|
177
|
-
}, null), createVNode("div", {
|
|
178
|
-
"class": "tooltipcontent",
|
|
179
|
-
"ref": tooltipcontent
|
|
180
|
-
}, [props.content])])]);
|
|
134
|
+
}, [defaultSlot])]);
|
|
181
135
|
};
|
|
182
136
|
}
|
|
183
137
|
});
|
package/splitter/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var I=Object.defineProperty;var J=(v,s,C)=>s in v?I(v,s,{enumerable:!0,configurable:!0,writable:!0,value:C}):v[s]=C;var j=(v,s,C)=>(J(v,typeof s!="symbol"?s+"":s,C),C);(function(v,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(v=typeof globalThis!="undefined"?globalThis:v||self,s(v.index={},v.Vue))})(this,function(v,s){"use strict";const C={orientation:{type:String,default:"horizontal"},splitBarSize:{type:String,default:"2px"},disabledBarSize:{type:String,default:"1px"},showCollapseButton:{type:Boolean,default:!0}},F={position:{type:String,default:"top"},showAnimation:{type:Boolean,default:!0},content:{type:String},mouseLeaveDelay:{type:String,default:"150"},mouseEnterDelay:{type:String,default:"100"}},R={listen:function(e,n,o){return e.addEventListener?(e.addEventListener(n,o,!1),{remove(){e.removeEventListener(e,o,!1)}}):(e.attchEvent(n,o),{remove(){e.detachEvent(n,o)}})}};var Q="",$=s.defineComponent({name:"DTooltip",props:F,setup(e,n){const o=s.reactive({left:0,top:0}),i=s.ref(!1),t=s.ref(null),r=s.ref(null),c=s.ref(null),p=s.ref(null);let h,m;const g=(a,u)=>{c.value.style[a]=u},d=function(a,u=e.mouseEnterDelay){let z;if(parseInt(u)>=0)return function(){z&&clearTimeout(z),z=setTimeout(a,parseInt(u))};console.error("the value of delay is bigger than 0 and the type of delay must be string!")};return s.onMounted(()=>{i.value||(r.value.style.opacity="0"),h=R.listen(t.value.children[0],"mouseenter",d(function(){i.value=!0},e.mouseEnterDelay)),m=R.listen(t.value.children[0],"mouseleave",function(){i.value&&setTimeout(function(){i.value=!1},e.mouseLeaveDelay)})}),s.watch(i,function(a,u){if(a){switch(r.value.style.opacity="1",r.value.style.zIndex="999",c.value.style.border="5px solid transparent",e.position){case"top":o.left=t.value.children[0].offsetLeft-r.value.offsetWidth/2+t.value.children[0].offsetWidth/2-5,o.top=t.value.children[0].offsetTop-10-p.value.offsetHeight,g("borderTop","5px solid rgb(70, 77, 110)"),c.value.style.top=`${p.value.offsetHeight}px`,c.value.style.left=`${p.value.offsetWidth/2+5}px`;break;case"right":o.left=t.value.children[0].offsetLeft+t.value.children[0].offsetWidth,o.top=t.value.children[0].offsetTop+t.value.children[0].offsetHeight/2-p.value.offsetHeight/2,g("borderRight","5px solid rgb(70, 77, 110)"),c.value.style.top=`${p.value.offsetHeight/2-5}px`,c.value.style.left="-0px";break;case"bottom":o.top=t.value.children[0].offsetHeight+t.value.children[0].offsetTop+10,o.left=t.value.children[0].offsetLeft+t.value.children[0].offsetWidth/2-p.value.offsetWidth/2-5,g("borderBottom","5px solid rgb(70, 77, 110)"),c.value.style.top="-10px",c.value.style.left=`${p.value.offsetWidth/2+5}px`;break;case"left":o.top=t.value.children[0].offsetTop+t.value.children[0].offsetHeight/2-p.value.offsetHeight/2,o.left=t.value.children[0].offsetLeft-20-p.value.offsetWidth,g("borderLeft","5px solid rgb(70, 77, 110)"),c.value.style.left=`${p.value.offsetWidth+10}px`,c.value.style.top=`${p.value.offsetHeight/2-5}px`;break;default:console.error("The attribute position value is wrong, the value is one of top\u3001right\u3001left\u3001bottom");break}r.value.style.top=o.top+"px",r.value.style.left=o.left+"px"}else o.top=0,o.left=0,r.value.style.opacity="0"}),s.onBeforeUnmount(()=>{h.remove(),m.remove()}),()=>{const a=s.renderSlot(s.useSlots(),"default");return s.createVNode("div",{class:"devui-tooltip"},[s.createVNode("div",{class:"slotElement",ref:t},[a]),s.createVNode("div",{class:"tooltip",ref:r},[s.createVNode("div",{class:"arrow",ref:c},null),s.createVNode("div",{class:"tooltipcontent",ref:p},[e.content])])])}}});function B(e,n){const o={},i=Object.keys(n);return i.forEach(t=>{o[t]=e.style[t]}),i.forEach(t=>{e.style[t]=n[t]}),o}function D(e,n){return e.classList?e.classList.contains(n):` ${e.className} `.indexOf(` ${n} `)>-1}function N(e,n){e.classList?e.classList.add(n):D(e,n)||(e.className=`${e.className} ${n}`)}function E(e,n){if(e.classList)e.classList.remove(n);else if(D(e,n)){const o=e.className;e.className=` ${o} `.replace(` ${n} `," ")}}const q={mounted(e,{value:n}){e.$value=n,n.enableResize&&G(e)},unmounted(e,{value:n}){n.enableResize&&Y(e,"mousedown",V)}};function G(e){X(e,"mousedown",V)}function X(e,n,o){e.addEventListener&&e.addEventListener(n,o)}function Y(e,n,o){e.removeEventListener&&e.removeEventListener(n,o)}function V(e){var t;const n=(t=e==null?void 0:e.target)==null?void 0:t.$value;if(!n)return;X(document,"mousemove",o),X(document,"mouseup",i),n.onPressEvent(T(e));function o(r){n.onDragEvent(T(r))}function i(r){Y(document,"mousemove",o),Y(document,"mouseup",i),n.onReleaseEvent(T(r))}}function T(e){return{pageX:e.pageX,pageY:e.pageY,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,type:e.type,originalEvent:e}}const O={index:{type:Number},orientation:{type:String,required:!0},splitBarSize:{type:String,required:!0},disabledBarSize:{type:String,default:"1px"},showCollapseButton:{type:Boolean}};var Z="",U=s.defineComponent({name:"DSplitterBar",props:O,components:{DToolTip:$},setup(e){const n=s.inject("splitterStore"),o=s.reactive({wrapperClass:`devui-splitter-bar devui-splitter-bar-${e.orientation}`}),i=s.ref();s.watch([()=>e.splitBarSize,i],([l,f])=>{f instanceof HTMLElement&&B(f,{flexBasis:l})},{immediate:!0}),s.watch([()=>n.state.panes,i],([l,f])=>{n.isStaticBar(e.index)?B(f,{flexBasis:e.disabledBarSize}):o.wrapperClass+=" resizable"},{deep:!0});const t={pageX:0,pageY:0,originalX:0,originalY:0};let r;const c={enableResize:!0,onPressEvent:function({originalEvent:l}){l.stopPropagation(),!!n.isResizable(e.index)&&(r=n.dragState(e.index),t.originalX=l.pageX,t.originalY=l.pageY)},onDragEvent:function({originalEvent:l}){if(l.stopPropagation(),!n.isResizable(e.index))return;t.pageX=l.pageX,t.pageY=l.pageY;let f;e.orientation==="vertical"?f=t.pageY-t.originalY:f=t.pageX-t.originalX,n.setSize(r,f)},onReleaseEvent:function({originalEvent:l}){if(l.stopPropagation(),!n.isResizable(e.index))return;t.pageX=l.pageX,t.pageY=l.pageY;let f;e.orientation==="vertical"?f=t.pageY-t.originalY:f=t.pageX-t.originalX,n.setSize(r,f)}},p=(l,f)=>{const y=n.getPane(l),S=n.getPane(f);return{pane:y,nearPane:S}},h=(l,f,y)=>{var P,W,M,k;const S=((W=(P=l==null?void 0:l.component)==null?void 0:P.props)==null?void 0:W.collapsible)&&y,x=(k=(M=l==null?void 0:l.component)==null?void 0:M.props)==null?void 0:k.collapsed,w=f.collapsed;return{"devui-collapse":S,collapsed:x,hidden:w}},m=s.computed(()=>{var S,x;const{pane:l,nearPane:f}=p(e.index,e.index+1),y=((x=(S=l==null?void 0:l.component)==null?void 0:S.props)==null?void 0:x.collapseDirection)!=="after"||e.index===0;return h(l,f,y)}),g=s.computed(()=>{var S,x;const{pane:l,nearPane:f}=p(e.index+1,e.index),y=((x=(S=l==null?void 0:l.component)==null?void 0:S.props)==null?void 0:x.collapseDirection)!=="before"||e.index+1===n.state.paneCount-1;return h(l,f,y)}),d=()=>{var S,x,w,P;const{pane:l,nearPane:f}=p(e.index,e.index+1);((x=(S=l==null?void 0:l.component)==null?void 0:S.props)==null?void 0:x.collapsed)||((P=(w=f==null?void 0:f.component)==null?void 0:w.props)==null?void 0:P.collapsed)?N(i.value,"none-resizable"):E(i.value,"none-resizable")},a=l=>{n.tooglePane(e.index,e.index+1,l),d()},u=l=>{n.tooglePane(e.index+1,e.index,l),d()},z=()=>{a(!0),u(!0)};s.onMounted(()=>{z()});const b=()=>{var S,x,w,P;const{pane:l,nearPane:f}=p(e.index,e.index+1);return((x=(S=l==null?void 0:l.component)==null?void 0:S.props)==null?void 0:x.collapsed)||((P=(w=f==null?void 0:f.component)==null?void 0:w.props)==null?void 0:P.collapsed)?"\u5C55\u5F00":"\u6536\u8D77"};return()=>s.withDirectives(s.createVNode("div",{class:o.wrapperClass,ref:i},[e.showCollapseButton&&s.createVNode($,{content:b()},{default:()=>[s.createVNode("div",{class:["prev",m.value],onClick:()=>{a()}},null)]}),s.createVNode("div",{class:"devui-resize-handle"},null),e.showCollapseButton&&s.createVNode($,{content:b()},{default:()=>[s.createVNode("div",{class:["next",g.value],onClick:()=>u()},null)]})]),[[q,c]])}});class _{constructor(){j(this,"state");this.state=s.reactive({panes:[],splitterContainerSize:0,paneCount:0})}setPanes({panes:n}){this.state.panes=n.map((o,i)=>{var t;return o.component&&(o.component.exposed.order.value=i*2),o.getPaneSize=(t=o==null?void 0:o.component)==null?void 0:t.exposed.getPaneSize,o}),this.state.paneCount=n.length}setSplitter({containerSize:n}){this.state.splitterContainerSize=n}getPane(n){if(!this.state.panes||n<0||n>=this.state.panes.length)throw new Error("no pane can return.");return this.state.panes[n]}dragState(n){const o=this.getPane(n),i=this.getPane(n+1),t=o.getPaneSize()+i.getPaneSize();return{prev:{index:n,initialSize:o.getPaneSize(),minSize:this.toPixels(o.component.props.minSize)||t-this.toPixels(i.component.props.maxSize)||0,maxSize:this.toPixels(o.component.props.maxSize)||t-this.toPixels(i.component.props.minSize)||t},next:{index:n+1,initialSize:i.getPaneSize(),minSize:this.toPixels(i.component.props.minSize)||t-this.toPixels(o.component.props.maxSize)||0,maxSize:this.toPixels(i.component.props.maxSize)||t-this.toPixels(o.component.props.minSize)||t}}}clamp(n,o,i){return Math.min(o,Math.max(n,i))}resize(n,o){const i=this.getPane(n.index),t=this.state.splitterContainerSize,r=this.clamp(n.minSize,n.maxSize,n.initialSize+o);let c="";this.isPercent(i.component.props.size)?c=r/t*100+"%":c=r+"px",i.component.props.size=c,i.component.emit("sizeChange",c)}isResizable(n){var r,c,p,h,m,g,d,a;const o=this.getPane(n),i=this.getPane(n+1),t=((c=(r=o==null?void 0:o.component)==null?void 0:r.props)==null?void 0:c.collapsed)||((h=(p=i==null?void 0:i.component)==null?void 0:p.props)==null?void 0:h.collapsed);return((g=(m=o==null?void 0:o.component)==null?void 0:m.props)==null?void 0:g.resizable)&&((a=(d=i==null?void 0:i.component)==null?void 0:d.props)==null?void 0:a.resizable)&&!t}isStaticBar(n){var t,r,c,p;const o=this.getPane(n),i=this.getPane(n+1);return!(((r=(t=o==null?void 0:o.component)==null?void 0:t.props)==null?void 0:r.resizable)&&((p=(c=i==null?void 0:i.component)==null?void 0:c.props)==null?void 0:p.resizable))}isPercent(n){return/%$/.test(n)}toPixels(n){let o=parseFloat(n);return this.isPercent(n)&&(o=this.state.splitterContainerSize*o/100),o}tooglePane(n,o,i){var c,p,h,m,g,d,a,u,z,b,l,f,y;const t=this.getPane(n),r=this.getPane(o);((p=(c=t==null?void 0:t.component)==null?void 0:c.props)==null?void 0:p.collapsible)&&(t.component.props.collapsed=i?(m=(h=t==null?void 0:t.component)==null?void 0:h.props)==null?void 0:m.collapsed:!((d=(g=t==null?void 0:t.component)==null?void 0:g.props)==null?void 0:d.collapsed),(b=(a=r==null?void 0:r.component)==null?void 0:a.exposed)==null||b.toggleNearPaneFlexGrow((z=(u=t==null?void 0:t.component)==null?void 0:u.props)==null?void 0:z.collapsed),(y=t==null?void 0:t.component)==null||y.emit("collapsedChange",(f=(l=t==null?void 0:t.component)==null?void 0:l.props)==null?void 0:f.collapsed))}setSize(n,o){const i=this.getPane(n.prev.index),t=this.getPane(n.next.index);i.component.props.size&&t.component.props.size?(this.resize(n.prev,o),this.resize(n.next,-o)):t.component.props.size?this.resize(n.next,-o):this.resize(n.prev,o)}}var ee="",L=s.defineComponent({name:"DSplitter",components:{DSplitterBar:U},props:C,emits:[],setup(e,n){var p,h;const o=new _,i=s.reactive({panes:[]});i.panes=((h=(p=n.slots).DSplitterPane)==null?void 0:h.call(p))||[],o.setPanes({panes:i.panes}),s.provide("orientation",e.orientation),s.provide("splitterStore",o);const t=s.ref(),r=()=>{if(!t)return;let m=0;e.orientation==="vertical"?m=t.value.clientHeight:m=t.value.clientWidth,o.setSplitter({containerSize:m})},c=new ResizeObserver(r);return s.watch(t,m=>{!m||(r(),c.observe(t.value))}),s.onUnmounted(()=>{c.disconnect()}),()=>{const{splitBarSize:m,orientation:g,showCollapseButton:d}=e,a=["devui-splitter",`devui-splitter-${g}`];return s.createVNode("div",{class:a,ref:t},[i.panes,i.panes.filter((u,z,b)=>z!==b.length-1).map((u,z)=>s.createVNode(s.resolveComponent("d-splitter-bar"),{key:z,style:`order: ${z*2+1}`,splitBarSize:m,orientation:g,index:z,showCollapseButton:d},null))])}}});const A={size:{type:String},minSize:{type:String},maxSize:{type:String},resizable:{type:Boolean,default:!0},collapsible:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!1},collapseDirection:{type:String,default:"both"},shrink:{type:Boolean,default:!1},shrinkWidth:{type:Number,default:36}};var te="",H=s.defineComponent({name:"DSplitterPane",props:A,emits:["sizeChange","collapsedChange"],setup(e,{slots:n,expose:o}){const i=s.inject("splitterStore"),t=s.ref(),r=s.ref();s.watch([r,t],([d,a])=>{!a||B(a,{order:d})});const c=(d,a)=>{if(!a)return;a.style.flexBasis=d;const u="devui-splitter-pane-fixed";d?N(a,u):E(a,u)};s.watch([()=>e.size,t],([d,a])=>{c(d,a)},{immediate:!0});const p=s.inject("orientation");let h="";s.onMounted(()=>{h=e.size,i.setPanes({panes:i.state.panes})}),s.onUpdated(()=>{i.setPanes({panes:i.state.panes})});const m=()=>{const d=t.value;if(!!d)return p==="vertical"?d.offsetHeight:d.offsetWidth};return s.watch([()=>e.collapsed,t],([d,a])=>{if(!a)return;const u="devui-splitter-pane-hidden";d?N(a,u):E(a,u),d&&e.shrink?(E(a,u),B(a,{flexBasis:`${e.shrinkWidth}px`})):B(a,{flexBasis:h})},{immediate:!0}),o({order:r,getPaneSize:m,toggleNearPaneFlexGrow:d=>{const a=t.value;if(!(a instanceof HTMLElement))return;const u="devui-splitter-pane-grow";D(a,u)?E(a,u):d&&N(a,u)}}),()=>{var d;return s.createVNode("div",{class:"devui-splitter-pane",ref:t},[(d=n.default)==null?void 0:d.call(n)])}}});L.install=function(e){e.component(L.name,L),e.component(H.name,H)};var K={title:"Splitter \u5206\u5272\u5668",category:"\u5E03\u5C40",status:"100%",install(e){e.use(L)}};v.Splitter=L,v.default=K,Object.defineProperty(v,"__esModule",{value:!0}),v[Symbol.toStringTag]="Module"});
|
|
1
|
+
var A=Object.defineProperty;var K=(h,s,P)=>s in h?A(h,s,{enumerable:!0,configurable:!0,writable:!0,value:P}):h[s]=P;var k=(h,s,P)=>(K(h,typeof s!="symbol"?s+"":s,P),P);(function(h,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(h=typeof globalThis!="undefined"?globalThis:h||self,s(h.index={},h.Vue))})(this,function(h,s){"use strict";const P={orientation:{type:String,default:"horizontal"},splitBarSize:{type:String,default:"2px"},disabledBarSize:{type:String,default:"1px"},showCollapseButton:{type:Boolean,default:!0}},j={position:{type:String,default:"top"},showAnimation:{type:Boolean,default:!0},content:{type:String},mouseLeaveDelay:{type:String,default:"150"},mouseEnterDelay:{type:String,default:"100"}};var J="",N=s.defineComponent({name:"DTooltip",props:j,setup(t){const e=s.reactive({left:0,top:0}),i=(o,r)=>{document.getElementById("devui-arrow").style[o]=r},n=s.ref(null);return s.onMounted(()=>{n.value.children[0].onmouseenter=function(){const o=document.createElement("div"),r=document.createElement("div"),a=document.createElement("div");o.classList.add("tooltip"),r.classList.add("arrow"),a.classList.add("tooltipcontent"),r.id="devui-arrow",o.id="devui-tooltip1",setTimeout(()=>{switch(document.getElementById("devui-tooltip").appendChild(o),o.appendChild(r),o.appendChild(a),a.innerHTML=t.content,o.style.opacity="1",o.style.zIndex="999",r.style.border="5px solid transparent",t.position){case"top":e.left=n.value.children[0].offsetLeft-o.offsetWidth/2+n.value.children[0].offsetWidth/2-5,e.top=n.value.children[0].offsetTop-10-a.offsetHeight,r.style.top=`${a.offsetHeight}px`,r.style.left=`${a.offsetWidth/2+5}px`,r.style.borderTop="5px solid rgb(70, 77, 110)";break;case"bottom":e.top=n.value.children[0].offsetHeight+n.value.children[0].offsetTop+10,e.left=n.value.children[0].offsetLeft+n.value.children[0].offsetWidth/2-a.offsetWidth/2-5,i("borderBottom","5px solid rgb(70, 77, 110)"),r.style.top="-10px",r.style.left=`${a.offsetWidth/2+5}px`,r.style.borderBottom="5px solid rgb(70, 77, 110)";break;case"left":e.top=n.value.children[0].offsetTop+n.value.children[0].offsetHeight/2-a.offsetHeight/2,e.left=n.value.children[0].offsetLeft-20-a.offsetWidth,i("borderLeft","5px solid rgb(70, 77, 110)"),r.style.left=`${a.offsetWidth+10}px`,r.style.top=`${a.offsetHeight/2-5}px`,r.style.borderLeft="5px solid rgb(70, 77, 110)";break;case"right":e.left=n.value.children[0].offsetLeft+n.value.children[0].offsetWidth,e.top=n.value.children[0].offsetTop+n.value.children[0].offsetHeight/2-a.offsetHeight/2,i("borderRight","5px solid rgb(70, 77, 110)"),r.style.top=`${a.offsetHeight/2-5}px`,r.style.left="-0px",r.style.borderRight="5px solid rgb(70, 77, 110)";break}o.style.top=e.top+5+"px",o.style.left=e.left+"px"},t.mouseEnterDelay)},n.value.children[0].onmouseleave=function(){setTimeout(()=>{document.getElementById("devui-tooltip1").removeChild(document.getElementById("devui-arrow")),document.getElementById("devui-tooltip").removeChild(document.getElementById("devui-tooltip1"))},t.mouseLeaveDelay)}}),s.onBeforeUnmount(()=>{n.value.children[0].onmouseenter=null,n.value.children[0].onmouseleave=null}),()=>{const o=s.renderSlot(s.useSlots(),"default");return s.createVNode("div",{class:"devui-tooltip",id:"devui-tooltip"},[s.createVNode("div",{class:"slotElement",ref:n},[o])])}}});function B(t,e){const i={},n=Object.keys(e);return n.forEach(o=>{i[o]=t.style[o]}),n.forEach(o=>{t.style[o]=e[o]}),i}function X(t,e){return t.classList?t.classList.contains(e):` ${t.className} `.indexOf(` ${e} `)>-1}function $(t,e){t.classList?t.classList.add(e):X(t,e)||(t.className=`${t.className} ${e}`)}function E(t,e){if(t.classList)t.classList.remove(e);else if(X(t,e)){const i=t.className;t.className=` ${i} `.replace(` ${e} `," ")}}const F={mounted(t,{value:e}){t.$value=e,e.enableResize&&q(t)},unmounted(t,{value:e}){e.enableResize&&D(t,"mousedown",T)}};function q(t){Y(t,"mousedown",T)}function Y(t,e,i){t.addEventListener&&t.addEventListener(e,i)}function D(t,e,i){t.removeEventListener&&t.removeEventListener(e,i)}function T(t){var o;const e=(o=t==null?void 0:t.target)==null?void 0:o.$value;if(!e)return;Y(document,"mousemove",i),Y(document,"mouseup",n),e.onPressEvent(R(t));function i(r){e.onDragEvent(R(r))}function n(r){D(document,"mousemove",i),D(document,"mouseup",n),e.onReleaseEvent(R(r))}}function R(t){return{pageX:t.pageX,pageY:t.pageY,clientX:t.clientX,clientY:t.clientY,offsetX:t.offsetX,offsetY:t.offsetY,type:t.type,originalEvent:t}}const G={index:{type:Number},orientation:{type:String,required:!0},splitBarSize:{type:String,required:!0},disabledBarSize:{type:String,default:"1px"},showCollapseButton:{type:Boolean}};var Q="",I=s.defineComponent({name:"DSplitterBar",props:G,components:{DToolTip:N},setup(t){const e=s.inject("splitterStore"),i=s.reactive({wrapperClass:`devui-splitter-bar devui-splitter-bar-${t.orientation}`}),n=s.ref();s.watch([()=>t.splitBarSize,n],([l,p])=>{p instanceof HTMLElement&&B(p,{flexBasis:l})},{immediate:!0}),s.watch([()=>e.state.panes,n],([l,p])=>{e.isStaticBar(t.index)?B(p,{flexBasis:t.disabledBarSize}):i.wrapperClass+=" resizable"},{deep:!0});const o={pageX:0,pageY:0,originalX:0,originalY:0};let r;const a={enableResize:!0,onPressEvent:function({originalEvent:l}){l.stopPropagation(),!!e.isResizable(t.index)&&(r=e.dragState(t.index),o.originalX=l.pageX,o.originalY=l.pageY)},onDragEvent:function({originalEvent:l}){if(l.stopPropagation(),!e.isResizable(t.index))return;o.pageX=l.pageX,o.pageY=l.pageY;let p;t.orientation==="vertical"?p=o.pageY-o.originalY:p=o.pageX-o.originalX,e.setSize(r,p)},onReleaseEvent:function({originalEvent:l}){if(l.stopPropagation(),!e.isResizable(t.index))return;o.pageX=l.pageX,o.pageY=l.pageY;let p;t.orientation==="vertical"?p=o.pageY-o.originalY:p=o.pageX-o.originalX,e.setSize(r,p)}},f=(l,p)=>{const x=e.getPane(l),g=e.getPane(p);return{pane:x,nearPane:g}},S=(l,p,x)=>{var C,M,W,V;const g=((M=(C=l==null?void 0:l.component)==null?void 0:C.props)==null?void 0:M.collapsible)&&x,z=(V=(W=l==null?void 0:l.component)==null?void 0:W.props)==null?void 0:V.collapsed,w=p.collapsed;return{"devui-collapse":g,collapsed:z,hidden:w}},m=s.computed(()=>{var g,z;const{pane:l,nearPane:p}=f(t.index,t.index+1),x=((z=(g=l==null?void 0:l.component)==null?void 0:g.props)==null?void 0:z.collapseDirection)!=="after"||t.index===0;return S(l,p,x)}),y=s.computed(()=>{var g,z;const{pane:l,nearPane:p}=f(t.index+1,t.index),x=((z=(g=l==null?void 0:l.component)==null?void 0:g.props)==null?void 0:z.collapseDirection)!=="before"||t.index+1===e.state.paneCount-1;return S(l,p,x)}),d=()=>{var g,z,w,C;const{pane:l,nearPane:p}=f(t.index,t.index+1);((z=(g=l==null?void 0:l.component)==null?void 0:g.props)==null?void 0:z.collapsed)||((C=(w=p==null?void 0:p.component)==null?void 0:w.props)==null?void 0:C.collapsed)?$(n.value,"none-resizable"):E(n.value,"none-resizable")},c=l=>{e.tooglePane(t.index,t.index+1,l),d()},u=l=>{e.tooglePane(t.index+1,t.index,l),d()},v=()=>{c(!0),u(!0)};s.onMounted(()=>{v()});const b=()=>{var g,z,w,C;const{pane:l,nearPane:p}=f(t.index,t.index+1);return((z=(g=l==null?void 0:l.component)==null?void 0:g.props)==null?void 0:z.collapsed)||((C=(w=p==null?void 0:p.component)==null?void 0:w.props)==null?void 0:C.collapsed)?"\u5C55\u5F00":"\u6536\u8D77"};return()=>s.withDirectives(s.createVNode("div",{class:i.wrapperClass,ref:n},[t.showCollapseButton&&s.createVNode(N,{content:b()},{default:()=>[s.createVNode("div",{class:["prev",m.value],onClick:()=>{c()}},null)]}),s.createVNode("div",{class:"devui-resize-handle"},null),t.showCollapseButton&&s.createVNode(N,{content:b()},{default:()=>[s.createVNode("div",{class:["next",y.value],onClick:()=>u()},null)]})]),[[F,a]])}});class O{constructor(){k(this,"state");this.state=s.reactive({panes:[],splitterContainerSize:0,paneCount:0})}setPanes({panes:e}){this.state.panes=e.map((i,n)=>{var o;return i.component&&(i.component.exposed.order.value=n*2),i.getPaneSize=(o=i==null?void 0:i.component)==null?void 0:o.exposed.getPaneSize,i}),this.state.paneCount=e.length}setSplitter({containerSize:e}){this.state.splitterContainerSize=e}getPane(e){if(!this.state.panes||e<0||e>=this.state.panes.length)throw new Error("no pane can return.");return this.state.panes[e]}dragState(e){const i=this.getPane(e),n=this.getPane(e+1),o=i.getPaneSize()+n.getPaneSize();return{prev:{index:e,initialSize:i.getPaneSize(),minSize:this.toPixels(i.component.props.minSize)||o-this.toPixels(n.component.props.maxSize)||0,maxSize:this.toPixels(i.component.props.maxSize)||o-this.toPixels(n.component.props.minSize)||o},next:{index:e+1,initialSize:n.getPaneSize(),minSize:this.toPixels(n.component.props.minSize)||o-this.toPixels(i.component.props.maxSize)||0,maxSize:this.toPixels(n.component.props.maxSize)||o-this.toPixels(i.component.props.minSize)||o}}}clamp(e,i,n){return Math.min(i,Math.max(e,n))}resize(e,i){const n=this.getPane(e.index),o=this.state.splitterContainerSize,r=this.clamp(e.minSize,e.maxSize,e.initialSize+i);let a="";this.isPercent(n.component.props.size)?a=r/o*100+"%":a=r+"px",n.component.props.size=a,n.component.emit("sizeChange",a)}isResizable(e){var r,a,f,S,m,y,d,c;const i=this.getPane(e),n=this.getPane(e+1),o=((a=(r=i==null?void 0:i.component)==null?void 0:r.props)==null?void 0:a.collapsed)||((S=(f=n==null?void 0:n.component)==null?void 0:f.props)==null?void 0:S.collapsed);return((y=(m=i==null?void 0:i.component)==null?void 0:m.props)==null?void 0:y.resizable)&&((c=(d=n==null?void 0:n.component)==null?void 0:d.props)==null?void 0:c.resizable)&&!o}isStaticBar(e){var o,r,a,f;const i=this.getPane(e),n=this.getPane(e+1);return!(((r=(o=i==null?void 0:i.component)==null?void 0:o.props)==null?void 0:r.resizable)&&((f=(a=n==null?void 0:n.component)==null?void 0:a.props)==null?void 0:f.resizable))}isPercent(e){return/%$/.test(e)}toPixels(e){let i=parseFloat(e);return this.isPercent(e)&&(i=this.state.splitterContainerSize*i/100),i}tooglePane(e,i,n){var a,f,S,m,y,d,c,u,v,b,l,p,x;const o=this.getPane(e),r=this.getPane(i);((f=(a=o==null?void 0:o.component)==null?void 0:a.props)==null?void 0:f.collapsible)&&(o.component.props.collapsed=n?(m=(S=o==null?void 0:o.component)==null?void 0:S.props)==null?void 0:m.collapsed:!((d=(y=o==null?void 0:o.component)==null?void 0:y.props)==null?void 0:d.collapsed),(b=(c=r==null?void 0:r.component)==null?void 0:c.exposed)==null||b.toggleNearPaneFlexGrow((v=(u=o==null?void 0:o.component)==null?void 0:u.props)==null?void 0:v.collapsed),(x=o==null?void 0:o.component)==null||x.emit("collapsedChange",(p=(l=o==null?void 0:o.component)==null?void 0:l.props)==null?void 0:p.collapsed))}setSize(e,i){const n=this.getPane(e.prev.index),o=this.getPane(e.next.index);n.component.props.size&&o.component.props.size?(this.resize(e.prev,i),this.resize(e.next,-i)):o.component.props.size?this.resize(e.next,-i):this.resize(e.prev,i)}}var Z="",L=s.defineComponent({name:"DSplitter",components:{DSplitterBar:I},props:P,emits:[],setup(t,e){var f,S;const i=new O,n=s.reactive({panes:[]});n.panes=((S=(f=e.slots).DSplitterPane)==null?void 0:S.call(f))||[],i.setPanes({panes:n.panes}),s.provide("orientation",t.orientation),s.provide("splitterStore",i);const o=s.ref(),r=()=>{if(!o)return;let m=0;t.orientation==="vertical"?m=o.value.clientHeight:m=o.value.clientWidth,i.setSplitter({containerSize:m})},a=new ResizeObserver(r);return s.watch(o,m=>{!m||(r(),a.observe(o.value))}),s.onUnmounted(()=>{a.disconnect()}),()=>{const{splitBarSize:m,orientation:y,showCollapseButton:d}=t,c=["devui-splitter",`devui-splitter-${y}`];return s.createVNode("div",{class:c,ref:o},[n.panes,n.panes.filter((u,v,b)=>v!==b.length-1).map((u,v)=>s.createVNode(s.resolveComponent("d-splitter-bar"),{key:v,style:`order: ${v*2+1}`,splitBarSize:m,orientation:y,index:v,showCollapseButton:d},null))])}}});const U={size:{type:String},minSize:{type:String},maxSize:{type:String},resizable:{type:Boolean,default:!0},collapsible:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!1},collapseDirection:{type:String,default:"both"},shrink:{type:Boolean,default:!1},shrinkWidth:{type:Number,default:36}};var ee="",H=s.defineComponent({name:"DSplitterPane",props:U,emits:["sizeChange","collapsedChange"],setup(t,{slots:e,expose:i}){const n=s.inject("splitterStore"),o=s.ref(),r=s.ref();s.watch([r,o],([d,c])=>{!c||B(c,{order:d})});const a=(d,c)=>{if(!c)return;c.style.flexBasis=d;const u="devui-splitter-pane-fixed";d?$(c,u):E(c,u)};s.watch([()=>t.size,o],([d,c])=>{a(d,c)},{immediate:!0});const f=s.inject("orientation");let S="";s.onMounted(()=>{S=t.size,n.setPanes({panes:n.state.panes})}),s.onUpdated(()=>{n.setPanes({panes:n.state.panes})});const m=()=>{const d=o.value;if(!!d)return f==="vertical"?d.offsetHeight:d.offsetWidth};return s.watch([()=>t.collapsed,o],([d,c])=>{if(!c)return;const u="devui-splitter-pane-hidden";d?$(c,u):E(c,u),d&&t.shrink?(E(c,u),B(c,{flexBasis:`${t.shrinkWidth}px`})):B(c,{flexBasis:S})},{immediate:!0}),i({order:r,getPaneSize:m,toggleNearPaneFlexGrow:d=>{const c=o.value;if(!(c instanceof HTMLElement))return;const u="devui-splitter-pane-grow";X(c,u)?E(c,u):d&&$(c,u)}}),()=>{var d;return s.createVNode("div",{class:"devui-splitter-pane",ref:o},[(d=e.default)==null?void 0:d.call(e)])}}});L.install=function(t){t.component(L.name,L),t.component(H.name,H)};var _={title:"Splitter \u5206\u5272\u5668",category:"\u5E03\u5C40",status:"100%",install(t){t.use(L)}};h.Splitter=L,h.default=_,Object.defineProperty(h,"__esModule",{value:!0}),h[Symbol.toStringTag]="Module"});
|