vue-devui 1.0.0-beta.12 → 1.0.0-beta.16
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 +41 -18
- package/accordion/style.css +1 -1
- package/alert/index.es.js +0 -3
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.d.ts +7 -0
- package/auto-complete/index.es.js +1121 -0
- package/auto-complete/index.umd.js +1 -0
- package/auto-complete/package.json +7 -0
- package/auto-complete/style.css +1 -0
- package/button/index.es.js +116 -113
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +5 -5
- package/carousel/index.umd.js +1 -1
- package/color-picker/index.d.ts +7 -0
- package/color-picker/index.es.js +2960 -0
- package/color-picker/index.umd.js +1 -0
- package/color-picker/package.json +7 -0
- package/color-picker/style.css +1 -0
- package/comment/index.es.js +3 -2
- package/comment/index.umd.js +1 -1
- package/comment/style.css +1 -1
- package/dragdrop/index.es.js +135 -10
- package/dragdrop/index.umd.js +1 -1
- package/drawer/index.es.js +142 -30
- package/drawer/index.umd.js +1 -1
- package/form/index.es.js +59 -17
- package/form/index.umd.js +1 -1
- package/gantt/index.es.js +3 -3
- package/gantt/index.umd.js +1 -1
- package/modal/index.es.js +120 -117
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nuxt/components/AutoComplete.js +3 -0
- package/nuxt/components/CarouselItem.js +3 -0
- package/nuxt/components/ColorPicker.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/package.json +21 -1
- package/popover/index.es.js +13 -4
- package/popover/index.umd.js +1 -1
- package/slider/index.es.js +2 -5
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +145 -14
- package/splitter/index.umd.js +1 -1
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +17 -30
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +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/time-picker/index.es.js +117 -114
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.es.js +7 -4
- package/toast/index.umd.js +1 -1
- package/tooltip/index.es.js +70 -116
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.es.js +570 -172
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +984 -21
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +129 -34
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +8 -5
- package/upload/index.umd.js +1 -1
- package/vue-devui.es.js +15984 -13220
- package/vue-devui.umd.js +17 -17
package/drawer/index.es.js
CHANGED
|
@@ -14,7 +14,11 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
var __publicField = (obj, key, value) => {
|
|
18
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
import { defineComponent, ref, inject, computed, createVNode, createTextVNode, toRefs, watch, provide, onUnmounted, Teleport, createApp } from "vue";
|
|
18
22
|
const drawerProps = {
|
|
19
23
|
width: {
|
|
20
24
|
type: String,
|
|
@@ -44,8 +48,18 @@ const drawerProps = {
|
|
|
44
48
|
type: Boolean,
|
|
45
49
|
default: true
|
|
46
50
|
},
|
|
51
|
+
destroyOnHide: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
47
55
|
beforeHidden: {
|
|
48
56
|
type: [Promise, Function]
|
|
57
|
+
},
|
|
58
|
+
content: {
|
|
59
|
+
type: [Object, Function]
|
|
60
|
+
},
|
|
61
|
+
header: {
|
|
62
|
+
type: [Object, Function]
|
|
49
63
|
}
|
|
50
64
|
};
|
|
51
65
|
var drawerHeader = "";
|
|
@@ -55,6 +69,7 @@ var DrawerHeader = defineComponent({
|
|
|
55
69
|
setup(props, ctx) {
|
|
56
70
|
const isFullScreen = ref(false);
|
|
57
71
|
const visible = inject("visible");
|
|
72
|
+
const destroyOnHide = inject("destroyOnHide");
|
|
58
73
|
const fullScreenClassName = computed(() => isFullScreen.value ? "icon icon-minimize" : "icon icon-maxmize");
|
|
59
74
|
const handleFullScreen = (e) => {
|
|
60
75
|
e.stopPropagation();
|
|
@@ -68,7 +83,8 @@ var DrawerHeader = defineComponent({
|
|
|
68
83
|
fullScreenClassName,
|
|
69
84
|
visible,
|
|
70
85
|
handleFullScreen,
|
|
71
|
-
handleDrawerClose
|
|
86
|
+
handleDrawerClose,
|
|
87
|
+
destroyOnHide
|
|
72
88
|
};
|
|
73
89
|
},
|
|
74
90
|
render() {
|
|
@@ -76,12 +92,18 @@ var DrawerHeader = defineComponent({
|
|
|
76
92
|
handleFullScreen,
|
|
77
93
|
handleDrawerClose,
|
|
78
94
|
visible,
|
|
79
|
-
fullScreenClassName
|
|
95
|
+
fullScreenClassName,
|
|
96
|
+
destroyOnHide
|
|
80
97
|
} = this;
|
|
81
|
-
if (!visible)
|
|
98
|
+
if (destroyOnHide.value && !visible) {
|
|
82
99
|
return null;
|
|
100
|
+
}
|
|
101
|
+
const visibleVal = visible ? "visible" : "hidden";
|
|
83
102
|
return createVNode("div", {
|
|
84
|
-
"class": "devui-drawer-header"
|
|
103
|
+
"class": "devui-drawer-header",
|
|
104
|
+
"style": {
|
|
105
|
+
visibility: visibleVal
|
|
106
|
+
}
|
|
85
107
|
}, [createVNode("div", {
|
|
86
108
|
"class": "devui-drawer-header-item"
|
|
87
109
|
}, [createVNode("span", {
|
|
@@ -103,17 +125,26 @@ var DrawerContainer = defineComponent({
|
|
|
103
125
|
name: "DrawerContainer",
|
|
104
126
|
setup() {
|
|
105
127
|
const visible = inject("visible");
|
|
128
|
+
const destroyOnHide = inject("destroyOnHide");
|
|
106
129
|
return {
|
|
107
|
-
visible
|
|
130
|
+
visible,
|
|
131
|
+
destroyOnHide
|
|
108
132
|
};
|
|
109
133
|
},
|
|
110
134
|
render() {
|
|
111
135
|
const {
|
|
112
|
-
visible
|
|
136
|
+
visible,
|
|
137
|
+
destroyOnHide
|
|
113
138
|
} = this;
|
|
114
|
-
if (!visible)
|
|
139
|
+
if (destroyOnHide.value && !visible) {
|
|
115
140
|
return null;
|
|
116
|
-
|
|
141
|
+
}
|
|
142
|
+
const visibleVal = this.visible ? "visible" : "hidden";
|
|
143
|
+
return createVNode("div", {
|
|
144
|
+
"style": {
|
|
145
|
+
visibility: visibleVal
|
|
146
|
+
}
|
|
147
|
+
}, [createTextVNode("\u5185\u5BB9\u533A\u57DF")]);
|
|
117
148
|
}
|
|
118
149
|
});
|
|
119
150
|
var drawerBody = "";
|
|
@@ -130,6 +161,7 @@ var DrawerBody = defineComponent({
|
|
|
130
161
|
const width = inject("width");
|
|
131
162
|
const visible = inject("visible");
|
|
132
163
|
const backdropCloseable = inject("backdropCloseable");
|
|
164
|
+
const destroyOnHide = inject("destroyOnHide");
|
|
133
165
|
const navRight = computed(() => position.value === "right" ? {
|
|
134
166
|
"right": 0
|
|
135
167
|
} : {
|
|
@@ -152,7 +184,8 @@ var DrawerBody = defineComponent({
|
|
|
152
184
|
navWidth,
|
|
153
185
|
visible,
|
|
154
186
|
clickContent,
|
|
155
|
-
handleDrawerClose
|
|
187
|
+
handleDrawerClose,
|
|
188
|
+
destroyOnHide
|
|
156
189
|
};
|
|
157
190
|
},
|
|
158
191
|
render() {
|
|
@@ -163,14 +196,18 @@ var DrawerBody = defineComponent({
|
|
|
163
196
|
navRight,
|
|
164
197
|
navWidth,
|
|
165
198
|
visible,
|
|
166
|
-
handleDrawerClose
|
|
199
|
+
handleDrawerClose,
|
|
200
|
+
destroyOnHide
|
|
167
201
|
} = this;
|
|
168
|
-
if (!visible)
|
|
202
|
+
if (destroyOnHide.value && !visible) {
|
|
169
203
|
return null;
|
|
204
|
+
}
|
|
205
|
+
const visibleVal = visible ? "visible" : "hidden";
|
|
170
206
|
return createVNode("div", {
|
|
171
207
|
"class": "devui-drawer",
|
|
172
208
|
"style": {
|
|
173
|
-
zIndex: zindex
|
|
209
|
+
zIndex: zindex,
|
|
210
|
+
visibility: visibleVal
|
|
174
211
|
},
|
|
175
212
|
"onClick": handleDrawerClose
|
|
176
213
|
}, [isCover ? createVNode("div", {
|
|
@@ -188,7 +225,7 @@ var DrawerBody = defineComponent({
|
|
|
188
225
|
}, [slots.default ? slots.default() : null])])])]);
|
|
189
226
|
}
|
|
190
227
|
});
|
|
191
|
-
var Drawer = defineComponent({
|
|
228
|
+
var Drawer$1 = defineComponent({
|
|
192
229
|
name: "DDrawer",
|
|
193
230
|
props: drawerProps,
|
|
194
231
|
emits: ["close", "update:visible", "afterOpened"],
|
|
@@ -203,10 +240,11 @@ var Drawer = defineComponent({
|
|
|
203
240
|
isCover,
|
|
204
241
|
escKeyCloseable,
|
|
205
242
|
position,
|
|
206
|
-
backdropCloseable
|
|
243
|
+
backdropCloseable,
|
|
244
|
+
destroyOnHide
|
|
207
245
|
} = toRefs(props);
|
|
208
246
|
const isFullScreen = ref(false);
|
|
209
|
-
const
|
|
247
|
+
const fullscreen = () => {
|
|
210
248
|
isFullScreen.value = !isFullScreen.value;
|
|
211
249
|
};
|
|
212
250
|
const closeDrawer = async () => {
|
|
@@ -229,7 +267,9 @@ var Drawer = defineComponent({
|
|
|
229
267
|
watch(visible, (val) => {
|
|
230
268
|
if (val) {
|
|
231
269
|
emit("afterOpened");
|
|
232
|
-
|
|
270
|
+
if (destroyOnHide.value) {
|
|
271
|
+
isFullScreen.value = false;
|
|
272
|
+
}
|
|
233
273
|
}
|
|
234
274
|
if (escKeyCloseable && val) {
|
|
235
275
|
document.addEventListener("keyup", escCloseDrawer);
|
|
@@ -245,6 +285,7 @@ var Drawer = defineComponent({
|
|
|
245
285
|
provide("visible", visible);
|
|
246
286
|
provide("isFullScreen", isFullScreen);
|
|
247
287
|
provide("backdropCloseable", backdropCloseable);
|
|
288
|
+
provide("destroyOnHide", destroyOnHide);
|
|
248
289
|
onUnmounted(() => {
|
|
249
290
|
document.removeEventListener("keyup", escCloseDrawer);
|
|
250
291
|
});
|
|
@@ -252,36 +293,107 @@ var Drawer = defineComponent({
|
|
|
252
293
|
isFullScreen,
|
|
253
294
|
visible,
|
|
254
295
|
slots,
|
|
255
|
-
|
|
296
|
+
fullscreen,
|
|
256
297
|
closeDrawer
|
|
257
298
|
};
|
|
258
299
|
},
|
|
259
300
|
render() {
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
301
|
+
const {
|
|
302
|
+
fullscreen,
|
|
303
|
+
closeDrawer,
|
|
304
|
+
visible,
|
|
305
|
+
destroyOnHide
|
|
306
|
+
} = this;
|
|
307
|
+
if (destroyOnHide.value && !visible) {
|
|
263
308
|
return null;
|
|
309
|
+
}
|
|
310
|
+
const visibleVal = visible ? "visible" : "hidden";
|
|
264
311
|
return createVNode(Teleport, {
|
|
265
312
|
"to": "body"
|
|
266
313
|
}, {
|
|
267
|
-
default: () => [createVNode(DrawerBody,
|
|
268
|
-
|
|
269
|
-
|
|
314
|
+
default: () => [createVNode(DrawerBody, {
|
|
315
|
+
"style": {
|
|
316
|
+
visibility: visibleVal
|
|
317
|
+
}
|
|
318
|
+
}, {
|
|
319
|
+
default: () => [this.slots.header ? this.slots.header({
|
|
320
|
+
fullscreen,
|
|
321
|
+
closeDrawer
|
|
322
|
+
}) : createVNode(DrawerHeader, {
|
|
323
|
+
"onToggleFullScreen": fullscreen,
|
|
270
324
|
"onClose": closeDrawer
|
|
271
|
-
}, null), this.slots.
|
|
325
|
+
}, null), this.slots.content ? this.slots.content() : createVNode(DrawerContainer, null, null)]
|
|
272
326
|
})]
|
|
273
327
|
});
|
|
274
328
|
}
|
|
275
329
|
});
|
|
276
|
-
|
|
277
|
-
|
|
330
|
+
function createDrawerApp(props, drawer, el) {
|
|
331
|
+
if (drawer) {
|
|
332
|
+
return drawer;
|
|
333
|
+
}
|
|
334
|
+
const res = createApp(createVNode(Drawer$1, {
|
|
335
|
+
"visible": props.visible,
|
|
336
|
+
"onUpdate:visible": ($event) => props.visible = $event
|
|
337
|
+
}, {
|
|
338
|
+
header: props.header,
|
|
339
|
+
content: props.content
|
|
340
|
+
}));
|
|
341
|
+
res.mount(el);
|
|
342
|
+
return res;
|
|
343
|
+
}
|
|
344
|
+
class DrawerService {
|
|
345
|
+
static create(props, drawer) {
|
|
346
|
+
if (!drawer) {
|
|
347
|
+
drawer = new Drawer(props);
|
|
348
|
+
}
|
|
349
|
+
return drawer;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
class Drawer {
|
|
353
|
+
constructor(props) {
|
|
354
|
+
__publicField(this, "drawer", null);
|
|
355
|
+
__publicField(this, "div", null);
|
|
356
|
+
__publicField(this, "props", null);
|
|
357
|
+
__publicField(this, "hide", async () => {
|
|
358
|
+
var _a;
|
|
359
|
+
const beforeHidden = this.props.beforeHidden;
|
|
360
|
+
let result = (_a = typeof beforeHidden === "function" ? beforeHidden() : beforeHidden) != null ? _a : false;
|
|
361
|
+
if (result instanceof Promise) {
|
|
362
|
+
result = await result;
|
|
363
|
+
}
|
|
364
|
+
if (!result)
|
|
365
|
+
this.hideDirectly();
|
|
366
|
+
});
|
|
367
|
+
__publicField(this, "hideDirectly", () => {
|
|
368
|
+
this.drawer._instance.props.visible = false;
|
|
369
|
+
});
|
|
370
|
+
__publicField(this, "destroy", () => {
|
|
371
|
+
if (this.drawer) {
|
|
372
|
+
this.drawer.unmount();
|
|
373
|
+
this.drawer = null;
|
|
374
|
+
this.div.remove();
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
this.props = props;
|
|
378
|
+
}
|
|
379
|
+
show() {
|
|
380
|
+
if (!this.drawer) {
|
|
381
|
+
this.div = document.createElement("div");
|
|
382
|
+
this.drawer = createDrawerApp(this.props, this.drawer, this.div);
|
|
383
|
+
}
|
|
384
|
+
this.drawer._instance.props.visible = true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
Drawer$1.install = function(app) {
|
|
388
|
+
app.component(Drawer$1.name, Drawer$1);
|
|
278
389
|
};
|
|
279
390
|
var index = {
|
|
280
391
|
title: "Drawer \u62BD\u5C49\u677F",
|
|
281
392
|
category: "\u53CD\u9988",
|
|
282
|
-
status: "
|
|
393
|
+
status: "75%",
|
|
283
394
|
install(app) {
|
|
284
|
-
app.use(Drawer);
|
|
395
|
+
app.use(Drawer$1);
|
|
396
|
+
app.config.globalProperties.$drawerService = DrawerService;
|
|
285
397
|
}
|
|
286
398
|
};
|
|
287
|
-
export { Drawer, index as default };
|
|
399
|
+
export { Drawer$1 as Drawer, DrawerService, index as default };
|
package/drawer/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var z=Object.defineProperty;var S=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var V=(r,e,o)=>e in r?z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,g=(r,e)=>{for(var o in e||(e={}))P.call(e,o)&&V(r,o,e[o]);if(S)for(var o of S(e))T.call(e,o)&&V(r,o,e[o]);return r};var p=(r,e,o)=>(V(r,typeof e!="symbol"?e+"":e,o),o);(function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.index={},r.Vue))})(this,function(r,e){"use strict";const o={width:{type:String,default:"300px"},visible:{type:Boolean,default:!1},zIndex:{type:Number,default:1e3},isCover:{type:Boolean,default:!0},escKeyCloseable:{type:Boolean,default:!0},position:{type:String,default:"left"},backdropCloseable:{type:Boolean,default:!0},destroyOnHide:{type:Boolean,default:!1},beforeHidden:{type:[Promise,Function]},content:{type:[Object,Function]},header:{type:[Object,Function]}};var E="",O=e.defineComponent({name:"DrawerHeader",emits:["toggleFullScreen","close"],setup(n,i){const t=e.ref(!1),s=e.inject("visible"),l=e.inject("destroyOnHide");return{fullScreenClassName:e.computed(()=>t.value?"icon icon-minimize":"icon icon-maxmize"),visible:s,handleFullScreen:c=>{c.stopPropagation(),t.value=!t.value,i.emit("toggleFullScreen")},handleDrawerClose:()=>{i.emit("close")},destroyOnHide:l}},render(){const{handleFullScreen:n,handleDrawerClose:i,visible:t,fullScreenClassName:s,destroyOnHide:l}=this;if(l.value&&!t)return null;const d=t?"visible":"hidden";return e.createVNode("div",{class:"devui-drawer-header",style:{visibility:d}},[e.createVNode("div",{class:"devui-drawer-header-item"},[e.createVNode("span",{class:"devui-drawer-header-item icon icon-more-operate"},null)]),e.createVNode("div",{class:"devui-drawer-header-item",onClick:n},[e.createVNode("span",{class:s},null)]),e.createVNode("div",{class:"devui-drawer-header-item",onClick:i},[e.createVNode("span",{class:"icon icon-close"},null)])])}}),j=e.defineComponent({name:"DrawerContainer",setup(){const n=e.inject("visible"),i=e.inject("destroyOnHide");return{visible:n,destroyOnHide:i}},render(){const{visible:n,destroyOnHide:i}=this;if(i.value&&!n)return null;const t=this.visible?"visible":"hidden";return e.createVNode("div",{style:{visibility:t}},[e.createTextVNode("\u5185\u5BB9\u533A\u57DF")])}}),_="",k=e.defineComponent({name:"DrawerBody",setup(n,{slots:i}){const t=e.inject("isFullScreen"),s=e.inject("closeDrawer"),l=e.inject("zindex"),d=e.inject("isCover"),h=e.inject("position"),v=e.inject("width"),c=e.inject("visible"),C=e.inject("backdropCloseable"),b=e.inject("destroyOnHide"),u=e.computed(()=>h.value==="right"?{right:0}:{left:0}),D=e.computed(()=>t.value?"100vw":v.value);return{zindex:l,slots:i,isCover:d,navRight:u,navWidth:D,visible:c,clickContent:a=>{a.stopPropagation()},handleDrawerClose:()=>{!C.value||s()},destroyOnHide:b}},render(){const{zindex:n,slots:i,isCover:t,navRight:s,navWidth:l,visible:d,handleDrawerClose:h,destroyOnHide:v}=this;if(v.value&&!d)return null;const c=d?"visible":"hidden";return e.createVNode("div",{class:"devui-drawer",style:{zIndex:n,visibility:c},onClick:h},[t?e.createVNode("div",{class:"devui-overlay-backdrop"},null):null,e.createVNode("div",{class:"devui-overlay-wrapper"},[e.createVNode("div",{class:"devui-drawer-nav",style:g({width:l},s)},[e.createVNode("div",{class:"devui-drawer-content",onClick:this.clickContent},[i.default?i.default():null])])])])}}),f=e.defineComponent({name:"DDrawer",props:o,emits:["close","update:visible","afterOpened"],setup(n,{emit:i,slots:t}){const{width:s,visible:l,zIndex:d,isCover:h,escKeyCloseable:v,position:c,backdropCloseable:C,destroyOnHide:b}=e.toRefs(n),u=e.ref(!1),D=()=>{u.value=!u.value},w=async()=>{var H;const a=n.beforeHidden;let m=(H=typeof a=="function"?a():a)!=null?H:!1;m instanceof Promise&&(m=await m),!m&&(i("update:visible",!1),i("close"))},y=a=>{a.code==="Escape"&&w()};return e.watch(l,a=>{a&&(i("afterOpened"),b.value&&(u.value=!1)),v&&a?document.addEventListener("keyup",y):document.removeEventListener("keyup",y)}),e.provide("closeDrawer",w),e.provide("zindex",d),e.provide("isCover",h),e.provide("position",c),e.provide("width",s),e.provide("visible",l),e.provide("isFullScreen",u),e.provide("backdropCloseable",C),e.provide("destroyOnHide",b),e.onUnmounted(()=>{document.removeEventListener("keyup",y)}),{isFullScreen:u,visible:l,slots:t,fullscreen:D,closeDrawer:w}},render(){const{fullscreen:n,closeDrawer:i,visible:t,destroyOnHide:s}=this;if(s.value&&!t)return null;const l=t?"visible":"hidden";return e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(k,{style:{visibility:l}},{default:()=>[this.slots.header?this.slots.header({fullscreen:n,closeDrawer:i}):e.createVNode(O,{onToggleFullScreen:n,onClose:i},null),this.slots.content?this.slots.content():e.createVNode(j,null,null)]})]})}});function F(n,i,t){if(i)return i;const s=e.createApp(e.createVNode(f,{visible:n.visible,"onUpdate:visible":l=>n.visible=l},{header:n.header,content:n.content}));return s.mount(t),s}class N{static create(i,t){return t||(t=new B(i)),t}}class B{constructor(i){p(this,"drawer",null);p(this,"div",null);p(this,"props",null);p(this,"hide",async()=>{var s;const i=this.props.beforeHidden;let t=(s=typeof i=="function"?i():i)!=null?s:!1;t instanceof Promise&&(t=await t),t||this.hideDirectly()});p(this,"hideDirectly",()=>{this.drawer._instance.props.visible=!1});p(this,"destroy",()=>{this.drawer&&(this.drawer.unmount(),this.drawer=null,this.div.remove())});this.props=i}show(){this.drawer||(this.div=document.createElement("div"),this.drawer=F(this.props,this.drawer,this.div)),this.drawer._instance.props.visible=!0}}f.install=function(n){n.component(f.name,f)};var x={title:"Drawer \u62BD\u5C49\u677F",category:"\u53CD\u9988",status:"75%",install(n){n.use(f),n.config.globalProperties.$drawerService=N}};r.Drawer=f,r.DrawerService=N,r.default=x,Object.defineProperty(r,"__esModule",{value:!0}),r[Symbol.toStringTag]="Module"});
|
package/form/index.es.js
CHANGED
|
@@ -351,6 +351,10 @@ var Popover = defineComponent({
|
|
|
351
351
|
type: Number,
|
|
352
352
|
default: 1060
|
|
353
353
|
},
|
|
354
|
+
controlled: {
|
|
355
|
+
type: Boolean,
|
|
356
|
+
default: false
|
|
357
|
+
},
|
|
354
358
|
popType: {
|
|
355
359
|
type: String,
|
|
356
360
|
default: "default"
|
|
@@ -391,7 +395,8 @@ var Popover = defineComponent({
|
|
|
391
395
|
mouseEnterDelay,
|
|
392
396
|
mouseLeaveDelay,
|
|
393
397
|
showAnimation,
|
|
394
|
-
popMaxWidth
|
|
398
|
+
popMaxWidth,
|
|
399
|
+
controlled
|
|
395
400
|
} = toRefs(props);
|
|
396
401
|
const style2 = __spreadValues({
|
|
397
402
|
zIndex: zIndex.value
|
|
@@ -405,20 +410,24 @@ var Popover = defineComponent({
|
|
|
405
410
|
}
|
|
406
411
|
visible.value = true;
|
|
407
412
|
};
|
|
408
|
-
const onClick = isClick ? event : null;
|
|
413
|
+
const onClick = isClick && controlled.value ? event : null;
|
|
409
414
|
const enter = debounce$1(() => {
|
|
410
415
|
visible.value = true;
|
|
411
416
|
}, mouseEnterDelay.value);
|
|
412
417
|
const leave = debounce$1(() => {
|
|
413
418
|
visible.value = false;
|
|
414
419
|
}, mouseLeaveDelay.value);
|
|
415
|
-
const onMouseenter = isClick ?
|
|
416
|
-
const onMouseleave = isClick ?
|
|
420
|
+
const onMouseenter = !isClick && controlled.value ? enter : null;
|
|
421
|
+
const onMouseleave = !isClick && controlled.value ? leave : null;
|
|
417
422
|
const hiddenContext = () => {
|
|
423
|
+
if (!controlled.value)
|
|
424
|
+
return;
|
|
418
425
|
visible.value = false;
|
|
419
426
|
};
|
|
420
427
|
popMaxWidth.value && (style2.maxWidth = `${popMaxWidth.value}px`);
|
|
421
428
|
watch(() => props.visible, (newVal) => {
|
|
429
|
+
if (controlled.value)
|
|
430
|
+
return;
|
|
422
431
|
visible.value = newVal;
|
|
423
432
|
});
|
|
424
433
|
return () => {
|
|
@@ -1503,7 +1512,11 @@ var FormItem = defineComponent({
|
|
|
1503
1512
|
const labelData = reactive(dForm.labelData);
|
|
1504
1513
|
const rules2 = reactive(dForm.rules);
|
|
1505
1514
|
const resetField = () => {
|
|
1506
|
-
|
|
1515
|
+
if (Array.isArray(initFormItemData)) {
|
|
1516
|
+
formData[props.prop] = [...initFormItemData];
|
|
1517
|
+
} else {
|
|
1518
|
+
formData[props.prop] = initFormItemData;
|
|
1519
|
+
}
|
|
1507
1520
|
};
|
|
1508
1521
|
const formItem2 = reactive({
|
|
1509
1522
|
dHasFeedback: props.dHasFeedback,
|
|
@@ -1791,6 +1804,9 @@ function uniqueId(prefix) {
|
|
|
1791
1804
|
var formControl = "";
|
|
1792
1805
|
var FormControl = defineComponent({
|
|
1793
1806
|
name: "DFormControl",
|
|
1807
|
+
directives: {
|
|
1808
|
+
clickoutside: clickoutsideDirective
|
|
1809
|
+
},
|
|
1794
1810
|
props: formControlProps,
|
|
1795
1811
|
setup(props, ctx2) {
|
|
1796
1812
|
const formControl2 = ref();
|
|
@@ -1799,6 +1815,7 @@ var FormControl = defineComponent({
|
|
|
1799
1815
|
const isHorizontal = labelData.layout === "horizontal";
|
|
1800
1816
|
const uid = uniqueId("dfc-");
|
|
1801
1817
|
const showPopover = ref(false);
|
|
1818
|
+
const updateOn = ref("change");
|
|
1802
1819
|
const tipMessage = ref("");
|
|
1803
1820
|
const popPosition = ref("bottom");
|
|
1804
1821
|
let rectInfo = {
|
|
@@ -1815,13 +1832,15 @@ var FormControl = defineComponent({
|
|
|
1815
1832
|
const el = document.getElementById(uid);
|
|
1816
1833
|
elOffset = getElOffset(el);
|
|
1817
1834
|
EventBus.on("showPopoverErrorMessage", (data) => {
|
|
1835
|
+
var _a;
|
|
1818
1836
|
if (uid === data.uid) {
|
|
1819
1837
|
rectInfo = el.getBoundingClientRect();
|
|
1820
|
-
popoverLeftPosition = popPosition.value === "top" || popPosition.value === "bottom" ? rectInfo.right - rectInfo.width / 2 : rectInfo.right;
|
|
1821
|
-
popoverTopPosition = popPosition.value === "top" ? elOffset.top + rectInfo.height / 2 - rectInfo.height : elOffset.top + rectInfo.height / 2;
|
|
1822
1838
|
showPopover.value = data.showPopover;
|
|
1823
1839
|
tipMessage.value = data.message;
|
|
1824
1840
|
popPosition.value = data.popPosition;
|
|
1841
|
+
popoverLeftPosition = popPosition.value === "top" || popPosition.value === "bottom" ? rectInfo.right - rectInfo.width / 2 : rectInfo.right;
|
|
1842
|
+
popoverTopPosition = popPosition.value === "top" ? elOffset.top + rectInfo.height / 2 - rectInfo.height : elOffset.top + rectInfo.height / 2;
|
|
1843
|
+
updateOn.value = (_a = data.updateOn) != null ? _a : "change";
|
|
1825
1844
|
}
|
|
1826
1845
|
});
|
|
1827
1846
|
});
|
|
@@ -1849,17 +1868,22 @@ var FormControl = defineComponent({
|
|
|
1849
1868
|
};
|
|
1850
1869
|
}
|
|
1851
1870
|
});
|
|
1871
|
+
const handleClickOutside = () => {
|
|
1872
|
+
if (updateOn.value !== "change") {
|
|
1873
|
+
showPopover.value = false;
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1852
1876
|
return () => {
|
|
1853
1877
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1854
1878
|
const {
|
|
1855
1879
|
feedbackStatus,
|
|
1856
1880
|
extraInfo
|
|
1857
1881
|
} = props;
|
|
1858
|
-
return createVNode("div", {
|
|
1882
|
+
return withDirectives(createVNode("div", {
|
|
1859
1883
|
"class": "form-control",
|
|
1860
1884
|
"ref": formControl2,
|
|
1861
1885
|
"data-uid": uid
|
|
1862
|
-
}, [createVNode(Teleport, {
|
|
1886
|
+
}, [showPopover.value && createVNode(Teleport, {
|
|
1863
1887
|
"to": "body"
|
|
1864
1888
|
}, {
|
|
1865
1889
|
default: () => [createVNode("div", {
|
|
@@ -1871,6 +1895,7 @@ var FormControl = defineComponent({
|
|
|
1871
1895
|
height: rectInfo.height + "px"
|
|
1872
1896
|
}
|
|
1873
1897
|
}, [createVNode(Popover, {
|
|
1898
|
+
"controlled": updateOn.value !== "change",
|
|
1874
1899
|
"visible": showPopover.value,
|
|
1875
1900
|
"content": tipMessage.value,
|
|
1876
1901
|
"popType": "error",
|
|
@@ -1888,7 +1913,7 @@ var FormControl = defineComponent({
|
|
|
1888
1913
|
"color": iconData.value.color
|
|
1889
1914
|
}, null)])]), extraInfo && createVNode("div", {
|
|
1890
1915
|
"class": "devui-form-control-extra-info"
|
|
1891
|
-
}, [extraInfo])]);
|
|
1916
|
+
}, [extraInfo])]), [[resolveDirective("clickoutside"), handleClickOutside]]);
|
|
1892
1917
|
};
|
|
1893
1918
|
}
|
|
1894
1919
|
});
|
|
@@ -2057,13 +2082,25 @@ function handleErrorStrategyPass(el) {
|
|
|
2057
2082
|
index2 !== -1 && classList.splice(index2, 1);
|
|
2058
2083
|
el.setAttribute("class", classList.join(" "));
|
|
2059
2084
|
}
|
|
2060
|
-
function
|
|
2085
|
+
function getFormControlUID(el) {
|
|
2086
|
+
if (el.tagName.toLocaleLowerCase() === "body")
|
|
2087
|
+
return "";
|
|
2088
|
+
if (el.parentElement.id.startsWith("dfc-")) {
|
|
2089
|
+
return el.parentElement.id;
|
|
2090
|
+
} else {
|
|
2091
|
+
getFormControlUID(el.parentElement);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
function handleValidateError({ el, tipEl, message = "", isFormTag, messageShowType, dfcUID, popPosition = "right-bottom", updateOn }) {
|
|
2061
2095
|
if (isFormTag && messageShowType === MessageShowTypeEnum.toast) {
|
|
2062
2096
|
alert(message);
|
|
2063
2097
|
return;
|
|
2064
2098
|
}
|
|
2099
|
+
if (!dfcUID) {
|
|
2100
|
+
dfcUID = getFormControlUID(el);
|
|
2101
|
+
}
|
|
2065
2102
|
if (MessageShowTypeEnum.popover === messageShowType) {
|
|
2066
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: true, message, uid: dfcUID, popPosition });
|
|
2103
|
+
EventBus.emit("showPopoverErrorMessage", { showPopover: true, message, uid: dfcUID, popPosition, updateOn });
|
|
2067
2104
|
return;
|
|
2068
2105
|
}
|
|
2069
2106
|
tipEl.innerText = "" + message;
|
|
@@ -2085,7 +2122,7 @@ function getFormName(binding) {
|
|
|
2085
2122
|
const key = Object.keys(_refs)[0];
|
|
2086
2123
|
return _refs[key]["name"];
|
|
2087
2124
|
}
|
|
2088
|
-
function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, dfcUID, popPosition }) {
|
|
2125
|
+
function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, dfcUID, popPosition, updateOn }) {
|
|
2089
2126
|
validator.validate({ modelName: modelValue }).then(() => {
|
|
2090
2127
|
handleValidatePass(el, tipEl);
|
|
2091
2128
|
}).catch((err) => {
|
|
@@ -2098,7 +2135,7 @@ function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowTy
|
|
|
2098
2135
|
} else {
|
|
2099
2136
|
msg = errors[0].message;
|
|
2100
2137
|
}
|
|
2101
|
-
handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition });
|
|
2138
|
+
handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition, updateOn });
|
|
2102
2139
|
});
|
|
2103
2140
|
}
|
|
2104
2141
|
function checkValidPopsition(positionStr) {
|
|
@@ -2197,11 +2234,16 @@ var dValidateRules = {
|
|
|
2197
2234
|
const htmlEventValidateHandler = (e) => {
|
|
2198
2235
|
const modelValue = e.target.value;
|
|
2199
2236
|
if (messageShowType === MessageShowTypeEnum.popover) {
|
|
2200
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, message: "", uid: dfcUID, popPosition });
|
|
2237
|
+
EventBus.emit("showPopoverErrorMessage", { showPopover: false, message: "", uid: dfcUID, popPosition, updateOn });
|
|
2201
2238
|
}
|
|
2202
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition });
|
|
2239
|
+
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
2203
2240
|
};
|
|
2204
2241
|
vnode.children[0].el.addEventListener(updateOn, htmlEventValidateHandler);
|
|
2242
|
+
if (messageShowType === MessageShowTypeEnum.popover && updateOn === UpdateOnEnum.change) {
|
|
2243
|
+
vnode.children[0].el.addEventListener("focus", () => {
|
|
2244
|
+
EventBus.emit("showPopoverErrorMessage", { showPopover: false, uid: dfcUID, updateOn });
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2205
2247
|
if (errorStrategy === ErrorStrategyEnum.pristine) {
|
|
2206
2248
|
handleErrorStrategy(el);
|
|
2207
2249
|
vnode.children[0].props.value = "" + vnode.children[0].props.value;
|
|
@@ -2209,7 +2251,7 @@ var dValidateRules = {
|
|
|
2209
2251
|
const formName = getFormName(binding);
|
|
2210
2252
|
formName && EventBus.on(`formSubmit:${formName}`, () => {
|
|
2211
2253
|
const modelValue = isFormTag ? "" : vnode.children[0].el.value;
|
|
2212
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType });
|
|
2254
|
+
validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, updateOn: "submit" });
|
|
2213
2255
|
});
|
|
2214
2256
|
}
|
|
2215
2257
|
};
|