vue-devui 1.0.0-beta.18 → 1.0.0-beta.19
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 +200 -187
- package/accordion/index.es.js +221 -6
- package/accordion/index.umd.js +1 -1
- package/alert/index.es.js +28 -30
- package/alert/index.umd.js +1 -1
- package/auto-complete/index.es.js +131 -269
- package/auto-complete/index.umd.js +1 -1
- package/auto-complete/style.css +1 -1
- package/back-top/index.es.js +4 -2
- package/badge/index.es.js +13 -19
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/breadcrumb/index.es.js +2 -1
- package/button/index.es.js +39 -40
- package/button/index.umd.js +1 -1
- package/carousel/index.es.js +38 -53
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +16 -8
- package/cascader/style.css +1 -1
- package/color-picker/index.es.js +97 -89
- package/color-picker/index.umd.js +7 -7
- package/countdown/index.es.js +2 -1
- package/date-picker/index.es.js +40 -57
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +162 -5741
- package/drawer/index.umd.js +1 -27
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +459 -301
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +6 -3
- package/form/index.es.js +1953 -1550
- package/form/index.umd.js +18 -18
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +112 -133
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/icon/index.es.js +39 -57
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +2 -1
- package/input/style.css +1 -1
- package/input-icon/index.es.js +38 -37
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +46 -57
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/{time-axis → list}/index.d.ts +0 -0
- package/list/index.es.js +39 -0
- package/list/index.umd.js +1 -0
- package/{toast → list}/package.json +1 -1
- package/list/style.css +1 -0
- package/modal/index.es.js +300 -934
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/{toast → notification}/index.d.ts +0 -0
- package/notification/index.es.js +284 -0
- package/notification/index.umd.js +1 -0
- package/notification/package.json +7 -0
- package/notification/style.css +1 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/List.js +3 -0
- package/nuxt/components/ListItem.js +3 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/fixedOverlayProps.js +3 -0
- package/nuxt/components/flexibleOverlayProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/overlay/index.es.js +152 -198
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +40 -87
- package/pagination/index.es.js +10 -12
- package/pagination/index.umd.js +1 -1
- package/panel/index.es.js +45 -32
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5954 -201
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/read-tip/index.es.js +6 -3
- package/result/index.es.js +38 -53
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +9 -5
- package/search/index.es.js +19 -29
- package/search/index.umd.js +6 -6
- package/search/style.css +1 -1
- package/select/index.es.js +42 -42
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +17 -17
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +2 -1
- package/splitter/index.es.js +5814 -98
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +6 -3
- package/style.css +1 -1
- package/table/index.es.js +456 -299
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +3 -4
- package/tabs/index.umd.js +1 -1
- package/tag/index.es.js +2 -1
- package/tag-input/index.es.js +4 -2
- package/textarea/style.css +1 -1
- package/time-picker/index.es.js +43 -42
- package/time-picker/index.umd.js +1 -1
- package/timeline/index.d.ts +7 -0
- package/{time-axis → timeline}/index.es.js +65 -78
- package/timeline/index.umd.js +1 -0
- package/{time-axis → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +5804 -94
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +440 -165
- package/transfer/index.umd.js +17 -17
- package/transfer/style.css +1 -1
- package/tree/index.es.js +12 -7
- package/tree/index.umd.js +10 -10
- package/tree-select/index.es.js +10 -6
- package/tree-select/index.umd.js +1 -1
- package/upload/index.es.js +335 -6068
- package/upload/index.umd.js +1 -27
- package/upload/style.css +1 -1
- package/vue-devui.es.js +2555 -2799
- package/vue-devui.umd.js +16 -16
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/Toast.js +0 -3
- package/nuxt/components/ToastService.js +0 -3
- package/time-axis/index.umd.js +0 -1
- package/time-axis/style.css +0 -1
- package/toast/index.es.js +0 -5918
- package/toast/index.umd.js +0 -27
- package/toast/style.css +0 -1
package/modal/index.es.js
CHANGED
|
@@ -33,66 +33,78 @@ var __publicField = (obj, key, value) => {
|
|
|
33
33
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
34
|
return value;
|
|
35
35
|
};
|
|
36
|
-
import { defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted,
|
|
36
|
+
import { defineComponent, toRefs, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, ref, unref, nextTick, mergeProps, h, render } from "vue";
|
|
37
|
+
import { shift, offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
37
38
|
const modalProps = {
|
|
38
|
-
|
|
39
|
-
type: String,
|
|
40
|
-
default: "300px"
|
|
41
|
-
},
|
|
42
|
-
maxHeight: {
|
|
43
|
-
type: String
|
|
44
|
-
},
|
|
45
|
-
zIndex: {
|
|
46
|
-
type: Number,
|
|
47
|
-
default: 1050
|
|
48
|
-
},
|
|
49
|
-
backdropZIndex: {
|
|
50
|
-
type: Number,
|
|
51
|
-
default: 1049
|
|
52
|
-
},
|
|
53
|
-
placement: {
|
|
54
|
-
type: String,
|
|
55
|
-
default: "center"
|
|
56
|
-
},
|
|
57
|
-
offsetX: {
|
|
58
|
-
type: String,
|
|
59
|
-
default: "0px"
|
|
60
|
-
},
|
|
61
|
-
offsetY: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: "0px"
|
|
64
|
-
},
|
|
65
|
-
showAnimation: {
|
|
39
|
+
modelValue: {
|
|
66
40
|
type: Boolean,
|
|
67
|
-
default:
|
|
41
|
+
default: false
|
|
68
42
|
},
|
|
69
|
-
|
|
70
|
-
type:
|
|
71
|
-
default:
|
|
43
|
+
title: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ""
|
|
72
46
|
},
|
|
73
|
-
|
|
47
|
+
lockScroll: {
|
|
74
48
|
type: Boolean,
|
|
75
49
|
default: true
|
|
76
50
|
},
|
|
77
|
-
|
|
51
|
+
closeOnClickOverlay: {
|
|
78
52
|
type: Boolean,
|
|
79
53
|
default: true
|
|
80
54
|
},
|
|
81
|
-
|
|
55
|
+
beforeClose: {
|
|
82
56
|
type: Function
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const iconProps = {
|
|
60
|
+
name: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "",
|
|
63
|
+
required: true
|
|
83
64
|
},
|
|
84
|
-
|
|
85
|
-
type:
|
|
65
|
+
size: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: "inherit"
|
|
86
68
|
},
|
|
87
|
-
|
|
88
|
-
type:
|
|
69
|
+
color: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: "inherit"
|
|
89
72
|
},
|
|
90
|
-
|
|
91
|
-
type:
|
|
73
|
+
classPrefix: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: "icon"
|
|
92
76
|
}
|
|
93
77
|
};
|
|
94
|
-
var
|
|
95
|
-
|
|
78
|
+
var Icon = defineComponent({
|
|
79
|
+
name: "DIcon",
|
|
80
|
+
props: iconProps,
|
|
81
|
+
setup(props) {
|
|
82
|
+
const {
|
|
83
|
+
name,
|
|
84
|
+
size,
|
|
85
|
+
color,
|
|
86
|
+
classPrefix
|
|
87
|
+
} = toRefs(props);
|
|
88
|
+
return () => {
|
|
89
|
+
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
90
|
+
"src": name.value,
|
|
91
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
92
|
+
"style": {
|
|
93
|
+
width: size.value,
|
|
94
|
+
verticalAlign: "text-bottom"
|
|
95
|
+
}
|
|
96
|
+
}, null) : createVNode("i", {
|
|
97
|
+
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
98
|
+
"style": {
|
|
99
|
+
fontSize: size.value,
|
|
100
|
+
color: color.value
|
|
101
|
+
}
|
|
102
|
+
}, null);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
var baseOverlay = "";
|
|
107
|
+
function _isSlot(s) {
|
|
96
108
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
97
109
|
}
|
|
98
110
|
const CommonOverlay = defineComponent({
|
|
@@ -104,7 +116,7 @@ const CommonOverlay = defineComponent({
|
|
|
104
116
|
}, {
|
|
105
117
|
default: () => [createVNode(Transition, {
|
|
106
118
|
"name": "devui-overlay-fade"
|
|
107
|
-
}, _isSlot
|
|
119
|
+
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
108
120
|
default: () => [_slot]
|
|
109
121
|
})]
|
|
110
122
|
});
|
|
@@ -138,28 +150,13 @@ const overlayProps = {
|
|
|
138
150
|
default: true
|
|
139
151
|
}
|
|
140
152
|
};
|
|
141
|
-
const overlayEmits = ["update:visible", "backdropClick"];
|
|
142
153
|
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
143
154
|
overlayStyle: {
|
|
144
155
|
type: [String, Object],
|
|
145
156
|
default: void 0
|
|
146
157
|
}
|
|
147
158
|
});
|
|
148
|
-
const
|
|
149
|
-
origin: {
|
|
150
|
-
type: Object,
|
|
151
|
-
require: true
|
|
152
|
-
},
|
|
153
|
-
position: {
|
|
154
|
-
type: Object,
|
|
155
|
-
default: () => ({
|
|
156
|
-
originX: "left",
|
|
157
|
-
originY: "top",
|
|
158
|
-
overlayX: "left",
|
|
159
|
-
overlayY: "top"
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
}, overlayProps);
|
|
159
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
163
160
|
function useOverlayLogic(props, ctx) {
|
|
164
161
|
const backgroundClass = computed(() => {
|
|
165
162
|
return [
|
|
@@ -210,6 +207,7 @@ function useOverlayLogic(props, ctx) {
|
|
|
210
207
|
handleOverlayBubbleCancel
|
|
211
208
|
};
|
|
212
209
|
}
|
|
210
|
+
var fixedOverlay = "";
|
|
213
211
|
const FixedOverlay = defineComponent({
|
|
214
212
|
name: "DFixedOverlay",
|
|
215
213
|
props: fixedOverlayProps,
|
|
@@ -222,7 +220,7 @@ const FixedOverlay = defineComponent({
|
|
|
222
220
|
handleOverlayBubbleCancel
|
|
223
221
|
} = useOverlayLogic(props, ctx);
|
|
224
222
|
return () => createVNode(CommonOverlay, null, {
|
|
225
|
-
default: () => [
|
|
223
|
+
default: () => [props.visible && createVNode("div", {
|
|
226
224
|
"class": backgroundClass.value,
|
|
227
225
|
"style": props.backgroundStyle,
|
|
228
226
|
"onClick": handleBackdropClick
|
|
@@ -230,248 +228,269 @@ const FixedOverlay = defineComponent({
|
|
|
230
228
|
"class": overlayClass.value,
|
|
231
229
|
"style": props.overlayStyle,
|
|
232
230
|
"onClick": handleOverlayBubbleCancel
|
|
233
|
-
}, [renderSlot(ctx.slots, "default")])])
|
|
231
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
234
232
|
});
|
|
235
233
|
}
|
|
236
234
|
});
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
const flexibleOverlayProps = {
|
|
236
|
+
modelValue: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default: false
|
|
239
|
+
},
|
|
240
|
+
origin: {
|
|
241
|
+
type: Object,
|
|
242
|
+
require: true
|
|
243
|
+
},
|
|
244
|
+
position: {
|
|
245
|
+
type: Array,
|
|
246
|
+
default: ["bottom"]
|
|
247
|
+
},
|
|
248
|
+
offset: {
|
|
249
|
+
type: [Number, Object],
|
|
250
|
+
default: 8
|
|
251
|
+
},
|
|
252
|
+
align: {
|
|
253
|
+
type: String,
|
|
254
|
+
default: null
|
|
255
|
+
},
|
|
256
|
+
showArrow: {
|
|
257
|
+
type: Boolean,
|
|
258
|
+
default: false
|
|
259
|
+
},
|
|
260
|
+
isArrowCenter: {
|
|
261
|
+
type: Boolean,
|
|
262
|
+
default: true
|
|
243
263
|
}
|
|
244
|
-
|
|
245
|
-
|
|
264
|
+
};
|
|
265
|
+
function getScrollParent(element) {
|
|
266
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
267
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
268
|
+
const style = window.getComputedStyle(parent);
|
|
269
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
270
|
+
return parent;
|
|
271
|
+
}
|
|
246
272
|
}
|
|
247
|
-
return
|
|
273
|
+
return window;
|
|
248
274
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
275
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
276
|
+
let { x, y } = point;
|
|
277
|
+
if (!isArrowCenter) {
|
|
278
|
+
const { width, height } = originRect;
|
|
279
|
+
if (x && placement.includes("start")) {
|
|
280
|
+
x = 12;
|
|
281
|
+
}
|
|
282
|
+
if (x && placement.includes("end")) {
|
|
283
|
+
x = Math.round(width - 24);
|
|
284
|
+
}
|
|
285
|
+
if (y && placement.includes("start")) {
|
|
286
|
+
y = 10;
|
|
287
|
+
}
|
|
288
|
+
if (y && placement.includes("end")) {
|
|
289
|
+
y = height - 14;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return { x, y };
|
|
293
|
+
}
|
|
294
|
+
function useOverlay(props, emit) {
|
|
295
|
+
const overlayRef = ref();
|
|
296
|
+
const arrowRef = ref();
|
|
297
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
298
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
299
|
+
const staticSide = {
|
|
300
|
+
top: "bottom",
|
|
301
|
+
right: "left",
|
|
302
|
+
bottom: "top",
|
|
303
|
+
left: "right"
|
|
304
|
+
}[placement.split("-")[0]];
|
|
305
|
+
Object.assign(arrowEl.style, {
|
|
306
|
+
left: x ? `${x}px` : "",
|
|
307
|
+
top: y ? `${y}px` : "",
|
|
308
|
+
right: "",
|
|
309
|
+
bottom: "",
|
|
310
|
+
[staticSide]: "-4px"
|
|
257
311
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const visibleRef = toRef(props, "visible");
|
|
276
|
-
const positionRef = toRef(props, "position");
|
|
277
|
-
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
278
|
-
if (!visible || !locationElements2) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const {
|
|
282
|
-
origin,
|
|
283
|
-
overlay: overlay2
|
|
284
|
-
} = locationElements2;
|
|
285
|
-
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
286
|
-
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
287
|
-
onInvalidate(() => {
|
|
288
|
-
unsubscriptions.forEach((fn) => fn());
|
|
289
|
-
});
|
|
290
|
-
});
|
|
312
|
+
};
|
|
313
|
+
const updatePosition = async () => {
|
|
314
|
+
const hostEl = props.origin;
|
|
315
|
+
const overlayEl = unref(overlayRef.value);
|
|
316
|
+
const arrowEl = unref(arrowRef.value);
|
|
317
|
+
const middleware = [
|
|
318
|
+
shift(),
|
|
319
|
+
offset(props.offset),
|
|
320
|
+
autoPlacement({
|
|
321
|
+
alignment: props.align,
|
|
322
|
+
allowedPlacements: props.position
|
|
323
|
+
})
|
|
324
|
+
];
|
|
325
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
326
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
327
|
+
strategy: "fixed",
|
|
328
|
+
middleware
|
|
291
329
|
});
|
|
330
|
+
emit("positionChange", placement);
|
|
331
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
332
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
333
|
+
};
|
|
334
|
+
watch(() => props.modelValue, () => {
|
|
335
|
+
const originParent = getScrollParent(props.origin);
|
|
336
|
+
if (props.modelValue && props.origin) {
|
|
337
|
+
nextTick(updatePosition);
|
|
338
|
+
originParent.addEventListener("scroll", updatePosition);
|
|
339
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
340
|
+
window.addEventListener("resize", updatePosition);
|
|
341
|
+
} else {
|
|
342
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
343
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
344
|
+
window.removeEventListener("resize", updatePosition);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
onUnmounted(() => {
|
|
348
|
+
const originParent = getScrollParent(props.origin);
|
|
349
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
350
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
351
|
+
window.removeEventListener("resize", updatePosition);
|
|
352
|
+
});
|
|
353
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
354
|
+
}
|
|
355
|
+
var flexibleOverlay = "";
|
|
356
|
+
defineComponent({
|
|
357
|
+
name: "DFlexibleOverlay",
|
|
358
|
+
inheritAttrs: false,
|
|
359
|
+
props: flexibleOverlayProps,
|
|
360
|
+
emits: ["update:modelValue", "positionChange"],
|
|
361
|
+
setup(props, {
|
|
362
|
+
slots,
|
|
363
|
+
attrs,
|
|
364
|
+
emit,
|
|
365
|
+
expose
|
|
366
|
+
}) {
|
|
292
367
|
const {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
default: () => [withDirectives(createVNode("div", {
|
|
300
|
-
"style": props.backgroundStyle,
|
|
301
|
-
"class": backgroundClass.value,
|
|
302
|
-
"onClick": handleBackdropClick
|
|
303
|
-
}, [createVNode("div", {
|
|
304
|
-
"ref": overlayRef,
|
|
305
|
-
"class": overlayClass.value,
|
|
306
|
-
"style": positionedStyle,
|
|
307
|
-
"onClick": handleOverlayBubbleCancel
|
|
308
|
-
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
368
|
+
arrowRef,
|
|
369
|
+
overlayRef,
|
|
370
|
+
updatePosition
|
|
371
|
+
} = useOverlay(props, emit);
|
|
372
|
+
expose({
|
|
373
|
+
updatePosition
|
|
309
374
|
});
|
|
375
|
+
return () => {
|
|
376
|
+
var _a;
|
|
377
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
378
|
+
"ref": overlayRef,
|
|
379
|
+
"class": "devui-flexible-overlay"
|
|
380
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
381
|
+
"ref": arrowRef,
|
|
382
|
+
"class": "devui-flexible-overlay-arrow"
|
|
383
|
+
}, null)]);
|
|
384
|
+
};
|
|
310
385
|
}
|
|
311
386
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (isRef(origin)) {
|
|
317
|
-
return getElement(origin.value);
|
|
318
|
-
}
|
|
319
|
-
if (isComponent(origin)) {
|
|
320
|
-
return getElement(origin);
|
|
321
|
-
}
|
|
322
|
-
return origin;
|
|
323
|
-
}
|
|
324
|
-
function calculatePosition(position, rect, origin) {
|
|
325
|
-
const originRect = getOriginRect(origin);
|
|
326
|
-
const originPoint = getOriginRelativePoint(originRect, position);
|
|
327
|
-
return getOverlayPoint(originPoint, rect, position);
|
|
328
|
-
}
|
|
329
|
-
function getOriginRect(origin) {
|
|
330
|
-
if (origin instanceof Element) {
|
|
331
|
-
return origin.getBoundingClientRect();
|
|
332
|
-
}
|
|
333
|
-
const width = origin.width || 0;
|
|
334
|
-
const height = origin.height || 0;
|
|
335
|
-
return {
|
|
336
|
-
top: origin.y,
|
|
337
|
-
bottom: origin.y + height,
|
|
338
|
-
left: origin.x,
|
|
339
|
-
right: origin.x + width,
|
|
340
|
-
height,
|
|
341
|
-
width
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function getOverlayPoint(originPoint, rect, position) {
|
|
345
|
-
let x;
|
|
346
|
-
const {
|
|
347
|
-
width,
|
|
348
|
-
height
|
|
349
|
-
} = rect;
|
|
350
|
-
if (position.overlayX == "center") {
|
|
351
|
-
x = originPoint.x - width / 2;
|
|
352
|
-
} else {
|
|
353
|
-
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
354
|
-
}
|
|
355
|
-
let y;
|
|
356
|
-
if (position.overlayY == "center") {
|
|
357
|
-
y = originPoint.y - height / 2;
|
|
358
|
-
} else {
|
|
359
|
-
y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
x,
|
|
363
|
-
y
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
function getOriginRelativePoint(originRect, position) {
|
|
367
|
-
let x;
|
|
368
|
-
if (position.originX == "center") {
|
|
369
|
-
x = originRect.left + originRect.width / 2;
|
|
370
|
-
} else {
|
|
371
|
-
const startX = originRect.left;
|
|
372
|
-
const endX = originRect.right;
|
|
373
|
-
x = position.originX == "left" ? startX : endX;
|
|
387
|
+
const inBrowser = typeof window !== "undefined";
|
|
388
|
+
function useModal(props, emit) {
|
|
389
|
+
function close() {
|
|
390
|
+
emit("update:modelValue", false);
|
|
374
391
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
y = position.originY == "top" ? originRect.top : originRect.bottom;
|
|
392
|
+
function handleVisibleChange(val) {
|
|
393
|
+
if (!val) {
|
|
394
|
+
props.beforeClose ? props.beforeClose(close) : close();
|
|
395
|
+
}
|
|
380
396
|
}
|
|
381
|
-
return {
|
|
382
|
-
x,
|
|
383
|
-
y
|
|
384
|
-
};
|
|
397
|
+
return { handleVisibleChange };
|
|
385
398
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (overlay2 instanceof Element) {
|
|
398
|
-
const resizeObserver = new ResizeObserver(callback);
|
|
399
|
-
resizeObserver.observe(overlay2);
|
|
400
|
-
return () => resizeObserver.disconnect();
|
|
399
|
+
var Header = defineComponent({
|
|
400
|
+
name: "DModalHeader",
|
|
401
|
+
setup(props, {
|
|
402
|
+
slots
|
|
403
|
+
}) {
|
|
404
|
+
return () => {
|
|
405
|
+
var _a;
|
|
406
|
+
return createVNode("div", {
|
|
407
|
+
"class": "devui-modal-header"
|
|
408
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
409
|
+
};
|
|
401
410
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
411
|
+
});
|
|
412
|
+
var Body = defineComponent({
|
|
413
|
+
name: "DModalBody",
|
|
414
|
+
setup(props, {
|
|
415
|
+
slots
|
|
416
|
+
}) {
|
|
417
|
+
return () => {
|
|
418
|
+
var _a;
|
|
419
|
+
return createVNode("div", {
|
|
420
|
+
"class": "devui-modal-body"
|
|
421
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
422
|
+
};
|
|
412
423
|
}
|
|
413
|
-
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
const inBrowser = typeof window !== "undefined";
|
|
417
|
-
FlexibleOverlay.install = function(app) {
|
|
418
|
-
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
419
|
-
};
|
|
420
|
-
FixedOverlay.install = function(app) {
|
|
421
|
-
app.component(FixedOverlay.name, FixedOverlay);
|
|
422
|
-
};
|
|
424
|
+
});
|
|
423
425
|
var modal = "";
|
|
424
426
|
var Modal = defineComponent({
|
|
425
427
|
name: "DModal",
|
|
428
|
+
inheritAttrs: false,
|
|
426
429
|
props: modalProps,
|
|
427
|
-
emits: ["
|
|
428
|
-
setup(props,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
};
|
|
446
|
-
const result = (_a = typeof beforeHidden === "function" ? beforeHidden() : beforeHidden) != null ? _a : true;
|
|
447
|
-
if (result instanceof Promise) {
|
|
448
|
-
result.then(close);
|
|
449
|
-
} else {
|
|
450
|
-
close(result);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
ctx.expose({
|
|
455
|
-
onVisibleChange
|
|
430
|
+
emits: ["update:modelValue"],
|
|
431
|
+
setup(props, {
|
|
432
|
+
slots,
|
|
433
|
+
attrs,
|
|
434
|
+
emit,
|
|
435
|
+
expose
|
|
436
|
+
}) {
|
|
437
|
+
const {
|
|
438
|
+
modelValue,
|
|
439
|
+
lockScroll,
|
|
440
|
+
closeOnClickOverlay,
|
|
441
|
+
title
|
|
442
|
+
} = toRefs(props);
|
|
443
|
+
const {
|
|
444
|
+
handleVisibleChange
|
|
445
|
+
} = useModal(props, emit);
|
|
446
|
+
expose({
|
|
447
|
+
handleVisibleChange
|
|
456
448
|
});
|
|
457
449
|
return () => createVNode(FixedOverlay, {
|
|
458
|
-
"visible":
|
|
459
|
-
"onUpdate:visible":
|
|
460
|
-
"
|
|
461
|
-
"
|
|
462
|
-
"
|
|
450
|
+
"visible": modelValue.value,
|
|
451
|
+
"onUpdate:visible": handleVisibleChange,
|
|
452
|
+
"background-class": "devui-modal-mask",
|
|
453
|
+
"background-block": lockScroll.value,
|
|
454
|
+
"backdrop-close": closeOnClickOverlay.value
|
|
463
455
|
}, {
|
|
464
456
|
default: () => [createVNode(Transition, {
|
|
465
457
|
"name": "devui-modal-wipe"
|
|
466
458
|
}, {
|
|
467
459
|
default: () => {
|
|
468
|
-
var _a
|
|
469
|
-
return [
|
|
460
|
+
var _a;
|
|
461
|
+
return [createVNode("div", mergeProps({
|
|
462
|
+
"class": "devui-modal"
|
|
463
|
+
}, attrs), [createVNode(Icon, {
|
|
464
|
+
"name": "close",
|
|
465
|
+
"class": "btn-close",
|
|
466
|
+
"size": "var(--devui-font-size-md,12px)",
|
|
467
|
+
"onClick": () => handleVisibleChange(false)
|
|
468
|
+
}, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
|
|
469
|
+
default: () => [title.value]
|
|
470
|
+
}), createVNode(Body, null, {
|
|
471
|
+
default: () => {
|
|
472
|
+
var _a2;
|
|
473
|
+
return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
|
|
474
|
+
}
|
|
475
|
+
}), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
|
|
470
476
|
}
|
|
471
477
|
})]
|
|
472
478
|
});
|
|
473
479
|
}
|
|
474
480
|
});
|
|
481
|
+
var Footer = defineComponent({
|
|
482
|
+
name: "DModalFooter",
|
|
483
|
+
setup(props, {
|
|
484
|
+
slots
|
|
485
|
+
}) {
|
|
486
|
+
return () => {
|
|
487
|
+
var _a;
|
|
488
|
+
return createVNode("div", {
|
|
489
|
+
"class": "devui-modal-footer"
|
|
490
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
});
|
|
475
494
|
class CommonModalService {
|
|
476
495
|
constructor(anchorContainer) {
|
|
477
496
|
this.anchorContainer = anchorContainer;
|
|
@@ -487,6 +506,7 @@ class CommonModalService {
|
|
|
487
506
|
}, 500);
|
|
488
507
|
}
|
|
489
508
|
}
|
|
509
|
+
let vm;
|
|
490
510
|
class ModalService extends CommonModalService {
|
|
491
511
|
component() {
|
|
492
512
|
return Modal;
|
|
@@ -494,7 +514,7 @@ class ModalService extends CommonModalService {
|
|
|
494
514
|
open(props = {}) {
|
|
495
515
|
const anchor = document.createElement("div");
|
|
496
516
|
this.anchorContainer.appendChild(anchor);
|
|
497
|
-
const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
|
|
517
|
+
const _a = props, { header, content, footer } = _a, resProps = __objRest(_a, ["header", "content", "footer"]);
|
|
498
518
|
const needHideOrNot = (value) => {
|
|
499
519
|
if (!value) {
|
|
500
520
|
hide();
|
|
@@ -504,11 +524,11 @@ class ModalService extends CommonModalService {
|
|
|
504
524
|
return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
|
|
505
525
|
modelValue: true,
|
|
506
526
|
"onUpdate:modelValue": onUpdateModelValue
|
|
507
|
-
}), { default: content });
|
|
527
|
+
}), { header, default: content, footer });
|
|
508
528
|
};
|
|
509
529
|
const hide = () => {
|
|
510
530
|
var _a2, _b;
|
|
511
|
-
|
|
531
|
+
renderOrigin(resProps, (value) => {
|
|
512
532
|
if (!value) {
|
|
513
533
|
this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
|
|
514
534
|
this.renderNull(anchor);
|
|
@@ -516,676 +536,23 @@ class ModalService extends CommonModalService {
|
|
|
516
536
|
renderOrigin(resProps);
|
|
517
537
|
}
|
|
518
538
|
});
|
|
519
|
-
(_b = (_a2 =
|
|
539
|
+
(_b = (_a2 = vm.component.exposed).handleVisibleChange) == null ? void 0 : _b.call(_a2, false);
|
|
520
540
|
};
|
|
521
541
|
this.renderModal(anchor, { modelValue: false });
|
|
522
|
-
renderOrigin(resProps);
|
|
542
|
+
vm = renderOrigin(resProps);
|
|
523
543
|
return { hide };
|
|
524
544
|
}
|
|
525
545
|
}
|
|
526
546
|
__publicField(ModalService, "token", "MODAL_SERVICE_TOKEN");
|
|
527
|
-
const dialogProps = {
|
|
528
|
-
width: {
|
|
529
|
-
type: String,
|
|
530
|
-
default: "300px"
|
|
531
|
-
},
|
|
532
|
-
maxHeight: {
|
|
533
|
-
type: String
|
|
534
|
-
},
|
|
535
|
-
zIndex: {
|
|
536
|
-
type: Number,
|
|
537
|
-
default: 1050
|
|
538
|
-
},
|
|
539
|
-
backdropZIndex: {
|
|
540
|
-
type: Number,
|
|
541
|
-
default: 1049
|
|
542
|
-
},
|
|
543
|
-
placement: {
|
|
544
|
-
type: String,
|
|
545
|
-
default: "center"
|
|
546
|
-
},
|
|
547
|
-
offsetX: {
|
|
548
|
-
type: String,
|
|
549
|
-
default: "0px"
|
|
550
|
-
},
|
|
551
|
-
offsetY: {
|
|
552
|
-
type: String,
|
|
553
|
-
default: "0px"
|
|
554
|
-
},
|
|
555
|
-
title: {
|
|
556
|
-
type: String
|
|
557
|
-
},
|
|
558
|
-
showAnimation: {
|
|
559
|
-
type: Boolean,
|
|
560
|
-
default: true
|
|
561
|
-
},
|
|
562
|
-
backdropCloseable: {
|
|
563
|
-
type: Boolean,
|
|
564
|
-
default: true
|
|
565
|
-
},
|
|
566
|
-
bodyScrollable: {
|
|
567
|
-
type: Boolean,
|
|
568
|
-
default: true
|
|
569
|
-
},
|
|
570
|
-
escapeable: {
|
|
571
|
-
type: Boolean,
|
|
572
|
-
default: true
|
|
573
|
-
},
|
|
574
|
-
onClose: {
|
|
575
|
-
type: Function
|
|
576
|
-
},
|
|
577
|
-
beforeHidden: {
|
|
578
|
-
type: [Promise, Function]
|
|
579
|
-
},
|
|
580
|
-
buttons: {
|
|
581
|
-
type: Array,
|
|
582
|
-
default: []
|
|
583
|
-
},
|
|
584
|
-
dialogType: {
|
|
585
|
-
type: String,
|
|
586
|
-
default: "standard"
|
|
587
|
-
},
|
|
588
|
-
modelValue: {
|
|
589
|
-
type: Boolean
|
|
590
|
-
},
|
|
591
|
-
"onUpdate:modelValue": {
|
|
592
|
-
type: Function
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
const useMoveable = (moveable = true) => {
|
|
596
|
-
const movingX = ref(0);
|
|
597
|
-
const movingY = ref(0);
|
|
598
|
-
const reset = () => {
|
|
599
|
-
movingX.value = 0;
|
|
600
|
-
movingY.value = 0;
|
|
601
|
-
};
|
|
602
|
-
const handleRef = ref();
|
|
603
|
-
const moveElRef = ref();
|
|
604
|
-
const enabledMoving = isRef(moveable) ? moveable : ref(moveable);
|
|
605
|
-
watch([moveElRef, handleRef], ([container, target], ov, onInvalidate) => {
|
|
606
|
-
if (!(target instanceof HTMLElement && container instanceof HTMLElement)) {
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
target.style.cursor = "all-scroll";
|
|
610
|
-
let startX = 0;
|
|
611
|
-
let startY = 0;
|
|
612
|
-
let prevMovingX = 0;
|
|
613
|
-
let prevMovingY = 0;
|
|
614
|
-
let containerRect = container.getBoundingClientRect();
|
|
615
|
-
let bodyRect = document.body.getBoundingClientRect();
|
|
616
|
-
let isDown = false;
|
|
617
|
-
const handleMouseDown = (event) => {
|
|
618
|
-
event.preventDefault();
|
|
619
|
-
if (!enabledMoving.value) {
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
startX = event.clientX;
|
|
623
|
-
startY = event.clientY;
|
|
624
|
-
const targetRect = target.getBoundingClientRect();
|
|
625
|
-
if ((target === event.target || target.contains(event.target)) && targetRect.x < startX && targetRect.y < startY && targetRect.width + targetRect.x >= startX && targetRect.height + targetRect.y >= startY) {
|
|
626
|
-
isDown = true;
|
|
627
|
-
prevMovingX = movingX.value;
|
|
628
|
-
prevMovingY = movingY.value;
|
|
629
|
-
bodyRect = document.body.getBoundingClientRect();
|
|
630
|
-
containerRect = container.getBoundingClientRect();
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
const handleMouseMove = (event) => {
|
|
634
|
-
event.preventDefault();
|
|
635
|
-
if (!isDown) {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
const currentX = prevMovingX + event.clientX - startX;
|
|
639
|
-
const currentY = prevMovingY + event.clientY - startY;
|
|
640
|
-
const containerOriginX = containerRect.x - prevMovingX;
|
|
641
|
-
const containerOriginY = containerRect.y - prevMovingY;
|
|
642
|
-
movingX.value = getRangeValueOf(currentX, -containerOriginX, bodyRect.width - containerRect.width - containerOriginX);
|
|
643
|
-
movingY.value = getRangeValueOf(currentY, -containerOriginY, bodyRect.height - containerRect.height - containerOriginY);
|
|
644
|
-
};
|
|
645
|
-
const handleMouseUp = (event) => {
|
|
646
|
-
event.preventDefault();
|
|
647
|
-
if (!isDown) {
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
isDown = false;
|
|
651
|
-
};
|
|
652
|
-
window.addEventListener("mousedown", handleMouseDown);
|
|
653
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
654
|
-
window.addEventListener("mouseup", handleMouseUp);
|
|
655
|
-
onInvalidate(() => {
|
|
656
|
-
window.removeEventListener("mousedown", handleMouseDown);
|
|
657
|
-
window.removeEventListener("mousemove", handleMouseMove);
|
|
658
|
-
window.removeEventListener("mouseup", handleMouseUp);
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
return {
|
|
662
|
-
movingX: readonly(movingX),
|
|
663
|
-
movingY: readonly(movingY),
|
|
664
|
-
handleRef,
|
|
665
|
-
moveElRef,
|
|
666
|
-
reset
|
|
667
|
-
};
|
|
668
|
-
};
|
|
669
|
-
const getRangeValueOf = (value, min, max) => {
|
|
670
|
-
if (value < min) {
|
|
671
|
-
return min;
|
|
672
|
-
}
|
|
673
|
-
if (value > max) {
|
|
674
|
-
return max;
|
|
675
|
-
}
|
|
676
|
-
return value;
|
|
677
|
-
};
|
|
678
|
-
var Icon = defineComponent({
|
|
679
|
-
name: "DIcon",
|
|
680
|
-
props: {
|
|
681
|
-
name: {
|
|
682
|
-
type: String,
|
|
683
|
-
required: true
|
|
684
|
-
},
|
|
685
|
-
size: {
|
|
686
|
-
type: String,
|
|
687
|
-
default: "inherit"
|
|
688
|
-
},
|
|
689
|
-
color: {
|
|
690
|
-
type: String,
|
|
691
|
-
default: "inherit"
|
|
692
|
-
},
|
|
693
|
-
classPrefix: {
|
|
694
|
-
type: String,
|
|
695
|
-
default: "icon"
|
|
696
|
-
}
|
|
697
|
-
},
|
|
698
|
-
setup(props) {
|
|
699
|
-
return __spreadValues({}, props);
|
|
700
|
-
},
|
|
701
|
-
render() {
|
|
702
|
-
const {
|
|
703
|
-
name,
|
|
704
|
-
size,
|
|
705
|
-
color,
|
|
706
|
-
classPrefix
|
|
707
|
-
} = this;
|
|
708
|
-
return /^((https?):)?\/\//.test(name) ? createVNode("img", {
|
|
709
|
-
"src": name,
|
|
710
|
-
"alt": name.split("/")[name.split("/").length - 1],
|
|
711
|
-
"style": {
|
|
712
|
-
width: size,
|
|
713
|
-
verticalAlign: "text-bottom"
|
|
714
|
-
}
|
|
715
|
-
}, null) : createVNode("i", {
|
|
716
|
-
"class": `${classPrefix} ${classPrefix}-${name}`,
|
|
717
|
-
"style": {
|
|
718
|
-
fontSize: size,
|
|
719
|
-
color
|
|
720
|
-
}
|
|
721
|
-
}, null);
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
Icon.install = function(app) {
|
|
725
|
-
app.component(Icon.name, Icon);
|
|
726
|
-
};
|
|
727
|
-
class View {
|
|
728
|
-
constructor() {
|
|
729
|
-
__publicField(this, "top", "50%");
|
|
730
|
-
__publicField(this, "left", "50%");
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
const componentProps = {
|
|
734
|
-
message: String,
|
|
735
|
-
backdrop: Boolean,
|
|
736
|
-
view: {
|
|
737
|
-
type: Object,
|
|
738
|
-
default: () => new View()
|
|
739
|
-
},
|
|
740
|
-
zIndex: Number,
|
|
741
|
-
isFull: {
|
|
742
|
-
type: Boolean,
|
|
743
|
-
default: false
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
class LoadingProps {
|
|
747
|
-
constructor() {
|
|
748
|
-
__publicField(this, "target");
|
|
749
|
-
__publicField(this, "message");
|
|
750
|
-
__publicField(this, "loadingTemplateRef");
|
|
751
|
-
__publicField(this, "backdrop", true);
|
|
752
|
-
__publicField(this, "positionType", "relative");
|
|
753
|
-
__publicField(this, "view", new View());
|
|
754
|
-
__publicField(this, "zIndex");
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
var loading = "";
|
|
758
|
-
var Loading = defineComponent({
|
|
759
|
-
name: "DLoading",
|
|
760
|
-
inheritAttrs: false,
|
|
761
|
-
props: componentProps,
|
|
762
|
-
setup(props) {
|
|
763
|
-
const style = {
|
|
764
|
-
top: props.view.top,
|
|
765
|
-
left: props.view.left,
|
|
766
|
-
zIndex: props.zIndex
|
|
767
|
-
};
|
|
768
|
-
if (!props.message) {
|
|
769
|
-
style.background = "none";
|
|
770
|
-
}
|
|
771
|
-
const isShow = ref(false);
|
|
772
|
-
const open = () => {
|
|
773
|
-
isShow.value = true;
|
|
774
|
-
};
|
|
775
|
-
const close = () => {
|
|
776
|
-
isShow.value = false;
|
|
777
|
-
};
|
|
778
|
-
return {
|
|
779
|
-
style,
|
|
780
|
-
isShow,
|
|
781
|
-
open,
|
|
782
|
-
close
|
|
783
|
-
};
|
|
784
|
-
},
|
|
785
|
-
render() {
|
|
786
|
-
var _a;
|
|
787
|
-
const {
|
|
788
|
-
isShow,
|
|
789
|
-
isFull,
|
|
790
|
-
backdrop,
|
|
791
|
-
style,
|
|
792
|
-
message,
|
|
793
|
-
$slots
|
|
794
|
-
} = this;
|
|
795
|
-
return isShow && createVNode("div", {
|
|
796
|
-
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
797
|
-
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
798
|
-
"class": "devui-loading-wrapper"
|
|
799
|
-
}, [backdrop ? createVNode("div", {
|
|
800
|
-
"class": "devui-loading-mask"
|
|
801
|
-
}, null) : null, createVNode("div", {
|
|
802
|
-
"style": style,
|
|
803
|
-
"class": "devui-loading-area"
|
|
804
|
-
}, [createVNode("div", {
|
|
805
|
-
"class": "devui-busy-default-spinner"
|
|
806
|
-
}, [createVNode("div", {
|
|
807
|
-
"class": "devui-loading-bar1"
|
|
808
|
-
}, null), createVNode("div", {
|
|
809
|
-
"class": "devui-loading-bar2"
|
|
810
|
-
}, null), createVNode("div", {
|
|
811
|
-
"class": "devui-loading-bar3"
|
|
812
|
-
}, null), createVNode("div", {
|
|
813
|
-
"class": "devui-loading-bar4"
|
|
814
|
-
}, null)]), message ? createVNode("span", {
|
|
815
|
-
"class": "devui-loading-text"
|
|
816
|
-
}, [message]) : null])])]);
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
820
|
-
function createComponent(Component, props, children = null) {
|
|
821
|
-
const vnode = h(Component, __spreadValues({}, props), children);
|
|
822
|
-
const container = document.createElement("div");
|
|
823
|
-
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
824
|
-
render(vnode, container);
|
|
825
|
-
return vnode.component;
|
|
826
|
-
}
|
|
827
|
-
function unmountComponent(ComponnetInstance) {
|
|
828
|
-
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
829
|
-
}
|
|
830
|
-
const loadingConstructor = defineComponent(Loading);
|
|
831
|
-
const cacheInstance = /* @__PURE__ */ new WeakSet();
|
|
832
|
-
const isEmpty = (val) => {
|
|
833
|
-
if (!val)
|
|
834
|
-
return true;
|
|
835
|
-
if (Array.isArray(val))
|
|
836
|
-
return val.length === 0;
|
|
837
|
-
if (val instanceof Set || val instanceof Map)
|
|
838
|
-
return val.size === 0;
|
|
839
|
-
if (val instanceof Promise)
|
|
840
|
-
return false;
|
|
841
|
-
if (typeof val === "object") {
|
|
842
|
-
try {
|
|
843
|
-
return Object.keys(val).length === 0;
|
|
844
|
-
} catch (e) {
|
|
845
|
-
return false;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
return false;
|
|
849
|
-
};
|
|
850
|
-
const getType = (vari) => {
|
|
851
|
-
return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
|
|
852
|
-
};
|
|
853
|
-
const isPromise = (value) => {
|
|
854
|
-
const type = getType(value);
|
|
855
|
-
switch (type) {
|
|
856
|
-
case "promise":
|
|
857
|
-
return [value];
|
|
858
|
-
case "array":
|
|
859
|
-
if (value.some((val) => getType(val) !== "promise")) {
|
|
860
|
-
console.error(new TypeError("Binding values should all be of type Promise"));
|
|
861
|
-
return "error";
|
|
862
|
-
}
|
|
863
|
-
return value;
|
|
864
|
-
default:
|
|
865
|
-
return false;
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
const unmount = (el) => {
|
|
869
|
-
cacheInstance.delete(el);
|
|
870
|
-
el.instance.proxy.close();
|
|
871
|
-
unmountComponent(el.instance);
|
|
872
|
-
};
|
|
873
|
-
const toggleLoading = (el, binding) => {
|
|
874
|
-
if (binding.value) {
|
|
875
|
-
const vals = isPromise(binding.value);
|
|
876
|
-
if (vals === "error")
|
|
877
|
-
return;
|
|
878
|
-
el.instance.proxy.open();
|
|
879
|
-
el.appendChild(el.mask);
|
|
880
|
-
cacheInstance.add(el);
|
|
881
|
-
if (vals) {
|
|
882
|
-
Promise.all(vals).catch((err) => {
|
|
883
|
-
console.error(new Error("Promise handling errors"), err);
|
|
884
|
-
}).finally(() => {
|
|
885
|
-
unmount(el);
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
} else {
|
|
889
|
-
unmount(el);
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
const removeAttribute = (el) => {
|
|
893
|
-
el.removeAttribute("zindex");
|
|
894
|
-
el.removeAttribute("positiontype");
|
|
895
|
-
el.removeAttribute("backdrop");
|
|
896
|
-
el.removeAttribute("message");
|
|
897
|
-
el.removeAttribute("view");
|
|
898
|
-
el.removeAttribute("loadingtemplateref");
|
|
899
|
-
};
|
|
900
|
-
const handleProps = (el, vprops) => {
|
|
901
|
-
const props = __spreadValues(__spreadValues({}, new LoadingProps()), vprops);
|
|
902
|
-
const loadingTemplateRef = props.loadingTemplateRef;
|
|
903
|
-
const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
|
|
904
|
-
el.style.position = props.positionType;
|
|
905
|
-
el.options = props;
|
|
906
|
-
el.instance = loadingInstance;
|
|
907
|
-
el.mask = loadingInstance.proxy.$el;
|
|
908
|
-
};
|
|
909
|
-
const loadingDirective = {
|
|
910
|
-
mounted: function(el, binding, vnode) {
|
|
911
|
-
handleProps(el, vnode.props);
|
|
912
|
-
removeAttribute(el);
|
|
913
|
-
!isEmpty(binding.value) && toggleLoading(el, binding);
|
|
914
|
-
},
|
|
915
|
-
updated: function(el, binding, vnode) {
|
|
916
|
-
if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el))
|
|
917
|
-
return;
|
|
918
|
-
!cacheInstance.has(el) && handleProps(el, vnode.props);
|
|
919
|
-
removeAttribute(el);
|
|
920
|
-
toggleLoading(el, binding);
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
const buttonProps = {
|
|
924
|
-
variant: {
|
|
925
|
-
type: String,
|
|
926
|
-
default: "outline"
|
|
927
|
-
},
|
|
928
|
-
size: {
|
|
929
|
-
type: String,
|
|
930
|
-
default: "md"
|
|
931
|
-
},
|
|
932
|
-
color: {
|
|
933
|
-
type: String
|
|
934
|
-
},
|
|
935
|
-
icon: {
|
|
936
|
-
type: String,
|
|
937
|
-
default: ""
|
|
938
|
-
},
|
|
939
|
-
loading: {
|
|
940
|
-
type: Boolean,
|
|
941
|
-
default: false
|
|
942
|
-
},
|
|
943
|
-
disabled: {
|
|
944
|
-
type: Boolean,
|
|
945
|
-
default: false
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
function useButton(props, ctx) {
|
|
949
|
-
const hasContent = computed(() => ctx.slots.default);
|
|
950
|
-
const colorMap = {
|
|
951
|
-
solid: "primary",
|
|
952
|
-
outline: "secondary",
|
|
953
|
-
text: "secondary"
|
|
954
|
-
};
|
|
955
|
-
const defaultColor = colorMap[props.variant];
|
|
956
|
-
const classes = computed(() => ({
|
|
957
|
-
"devui-btn": true,
|
|
958
|
-
[`devui-btn-${props.variant}`]: true,
|
|
959
|
-
[`devui-btn-${props.variant}-${props.color || defaultColor}`]: true,
|
|
960
|
-
[`devui-btn-${props.size}`]: true,
|
|
961
|
-
"devui-btn-icon-wrap": props.icon,
|
|
962
|
-
"devui-btn-icon": props.icon && !hasContent.value && props.variant !== "solid"
|
|
963
|
-
}));
|
|
964
|
-
const iconClass = computed(() => {
|
|
965
|
-
if (!props.icon) {
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
const origin = "devui-icon-fix icon";
|
|
969
|
-
if (hasContent.value) {
|
|
970
|
-
return `${origin} clear-right-5`;
|
|
971
|
-
} else {
|
|
972
|
-
return origin;
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
return { classes, iconClass };
|
|
976
|
-
}
|
|
977
|
-
var button = "";
|
|
978
|
-
var Button = defineComponent({
|
|
979
|
-
name: "DButton",
|
|
980
|
-
directives: {
|
|
981
|
-
devLoading: loadingDirective
|
|
982
|
-
},
|
|
983
|
-
props: buttonProps,
|
|
984
|
-
emits: ["click"],
|
|
985
|
-
setup(props, ctx) {
|
|
986
|
-
const {
|
|
987
|
-
icon,
|
|
988
|
-
disabled,
|
|
989
|
-
loading: loading2
|
|
990
|
-
} = toRefs(props);
|
|
991
|
-
const {
|
|
992
|
-
classes,
|
|
993
|
-
iconClass
|
|
994
|
-
} = useButton(props, ctx);
|
|
995
|
-
const onClick = (e) => {
|
|
996
|
-
if (loading2.value) {
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
ctx.emit("click", e);
|
|
1000
|
-
};
|
|
1001
|
-
return () => {
|
|
1002
|
-
var _a, _b;
|
|
1003
|
-
return withDirectives(createVNode("button", {
|
|
1004
|
-
"class": classes.value,
|
|
1005
|
-
"disabled": disabled.value,
|
|
1006
|
-
"onClick": onClick
|
|
1007
|
-
}, [icon.value && createVNode(Icon, {
|
|
1008
|
-
"name": icon.value,
|
|
1009
|
-
"size": "12px",
|
|
1010
|
-
"class": iconClass.value
|
|
1011
|
-
}, null), createVNode("span", {
|
|
1012
|
-
"class": "button-content"
|
|
1013
|
-
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])]), [[resolveDirective("dLoading"), loading2.value]]);
|
|
1014
|
-
};
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
function _isSlot(s) {
|
|
1018
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1019
|
-
}
|
|
1020
|
-
var Dialog = defineComponent({
|
|
1021
|
-
name: "DModal",
|
|
1022
|
-
inheritAttrs: false,
|
|
1023
|
-
props: dialogProps,
|
|
1024
|
-
emits: ["onUpdate:modelValue"],
|
|
1025
|
-
setup(props, ctx) {
|
|
1026
|
-
const {
|
|
1027
|
-
movingX,
|
|
1028
|
-
movingY,
|
|
1029
|
-
handleRef,
|
|
1030
|
-
moveElRef,
|
|
1031
|
-
reset
|
|
1032
|
-
} = useMoveable();
|
|
1033
|
-
watch(() => props.modelValue, (value) => {
|
|
1034
|
-
if (value) {
|
|
1035
|
-
reset();
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
const movingStyle = computed(() => ({
|
|
1039
|
-
position: "relative",
|
|
1040
|
-
left: `${movingX.value}px`,
|
|
1041
|
-
top: `${movingY.value}px`
|
|
1042
|
-
}));
|
|
1043
|
-
const containerStyle = computed(() => ({
|
|
1044
|
-
width: props.width,
|
|
1045
|
-
maxHeight: props.maxHeight,
|
|
1046
|
-
transform: `translate(${props.offsetX}, ${props.offsetY})`,
|
|
1047
|
-
zIndex: props.zIndex
|
|
1048
|
-
}));
|
|
1049
|
-
const iconName = computed(() => {
|
|
1050
|
-
switch (props.dialogType) {
|
|
1051
|
-
case "standard":
|
|
1052
|
-
return "";
|
|
1053
|
-
case "info":
|
|
1054
|
-
return "icon-info-o";
|
|
1055
|
-
case "success":
|
|
1056
|
-
return "icon-right-o";
|
|
1057
|
-
case "warning":
|
|
1058
|
-
return "icon-warning-o";
|
|
1059
|
-
case "failed":
|
|
1060
|
-
return "icon-error-o";
|
|
1061
|
-
default:
|
|
1062
|
-
return "";
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1065
|
-
const buttonsRef = computed(() => {
|
|
1066
|
-
return props.buttons.map((buttonProps2, index2) => {
|
|
1067
|
-
const {
|
|
1068
|
-
variant,
|
|
1069
|
-
disabled,
|
|
1070
|
-
handler,
|
|
1071
|
-
text
|
|
1072
|
-
} = buttonProps2;
|
|
1073
|
-
return createVNode(Button, {
|
|
1074
|
-
"key": index2,
|
|
1075
|
-
"style": {
|
|
1076
|
-
display: "inline-block",
|
|
1077
|
-
margin: "0 5px"
|
|
1078
|
-
},
|
|
1079
|
-
"variant": variant,
|
|
1080
|
-
"disabled": disabled,
|
|
1081
|
-
"onClick": handler
|
|
1082
|
-
}, _isSlot(text) ? text : {
|
|
1083
|
-
default: () => [text]
|
|
1084
|
-
});
|
|
1085
|
-
});
|
|
1086
|
-
});
|
|
1087
|
-
const modalRef = ref();
|
|
1088
|
-
const closeModal = () => {
|
|
1089
|
-
var _a, _b;
|
|
1090
|
-
(_b = (_a = modalRef.value) == null ? void 0 : _a.onVisibleChange) == null ? void 0 : _b.call(_a, false);
|
|
1091
|
-
};
|
|
1092
|
-
ctx.expose({
|
|
1093
|
-
closeModal
|
|
1094
|
-
});
|
|
1095
|
-
return () => createVNode(Modal, {
|
|
1096
|
-
"ref": modalRef,
|
|
1097
|
-
"width": props.width,
|
|
1098
|
-
"maxHeight": props.maxHeight,
|
|
1099
|
-
"offsetX": props.offsetX,
|
|
1100
|
-
"offsetY": props.offsetY,
|
|
1101
|
-
"zIndex": props.zIndex,
|
|
1102
|
-
"backdropZIndex": props.backdropZIndex,
|
|
1103
|
-
"backdropCloseable": props.backdropCloseable,
|
|
1104
|
-
"bodyScrollable": props.bodyScrollable,
|
|
1105
|
-
"placement": props.placement,
|
|
1106
|
-
"onClose": props.onClose,
|
|
1107
|
-
"beforeHidden": props.beforeHidden,
|
|
1108
|
-
"modelValue": props.modelValue,
|
|
1109
|
-
"onUpdate:modelValue": props["onUpdate:modelValue"]
|
|
1110
|
-
}, {
|
|
1111
|
-
default: () => {
|
|
1112
|
-
var _a, _b;
|
|
1113
|
-
return [createVNode("div", {
|
|
1114
|
-
"class": "devui-modal-content",
|
|
1115
|
-
"style": [containerStyle.value, movingStyle.value],
|
|
1116
|
-
"ref": moveElRef
|
|
1117
|
-
}, [createVNode("div", {
|
|
1118
|
-
"class": "devui-modal-header",
|
|
1119
|
-
"ref": handleRef
|
|
1120
|
-
}, [!!iconName.value ? createVNode(Icon, {
|
|
1121
|
-
"name": iconName.value,
|
|
1122
|
-
"size": "24px",
|
|
1123
|
-
"class": "header-alert-icon"
|
|
1124
|
-
}, null) : null, createVNode("span", null, [props.title]), createVNode(Button, {
|
|
1125
|
-
"class": "btn-close",
|
|
1126
|
-
"icon": "close",
|
|
1127
|
-
"variant": "text-dark",
|
|
1128
|
-
"onClick": closeModal
|
|
1129
|
-
}, null)]), createVNode("div", {
|
|
1130
|
-
"class": "devui-modal-body"
|
|
1131
|
-
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createVNode("div", {
|
|
1132
|
-
"class": "devui-modal-footer"
|
|
1133
|
-
}, [buttonsRef.value])])];
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
class DialogService extends CommonModalService {
|
|
1139
|
-
component() {
|
|
1140
|
-
return Dialog;
|
|
1141
|
-
}
|
|
1142
|
-
open(props = {}) {
|
|
1143
|
-
const anchor = document.createElement("div");
|
|
1144
|
-
this.anchorContainer.appendChild(anchor);
|
|
1145
|
-
const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
|
|
1146
|
-
const needHideOrNot = (value) => {
|
|
1147
|
-
if (!value) {
|
|
1148
|
-
hide();
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
|
|
1152
|
-
return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
|
|
1153
|
-
modelValue: true,
|
|
1154
|
-
"onUpdate:modelValue": onUpdateModelValue
|
|
1155
|
-
}), { default: content });
|
|
1156
|
-
};
|
|
1157
|
-
const hide = () => {
|
|
1158
|
-
var _a2, _b;
|
|
1159
|
-
const vnode = renderOrigin(resProps, (value) => {
|
|
1160
|
-
if (!value) {
|
|
1161
|
-
this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
|
|
1162
|
-
this.renderNull(anchor);
|
|
1163
|
-
} else {
|
|
1164
|
-
renderOrigin(resProps);
|
|
1165
|
-
}
|
|
1166
|
-
});
|
|
1167
|
-
(_b = (_a2 = vnode.component.exposed).closeModal) == null ? void 0 : _b.call(_a2);
|
|
1168
|
-
};
|
|
1169
|
-
const updateButtonOptions = (buttonOptions) => {
|
|
1170
|
-
const _a2 = resProps, { buttons } = _a2, innerResProps = __objRest(_a2, ["buttons"]);
|
|
1171
|
-
const newButtonOptions = buttons.map((option, index2) => __spreadValues(__spreadValues({}, option), buttonOptions[index2]));
|
|
1172
|
-
renderOrigin(__spreadProps(__spreadValues({}, innerResProps), { buttons: newButtonOptions }));
|
|
1173
|
-
};
|
|
1174
|
-
this.renderModal(anchor, { modelValue: false });
|
|
1175
|
-
renderOrigin(resProps);
|
|
1176
|
-
return { hide, updateButtonOptions };
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
__publicField(DialogService, "token", "DIALOG_SERVICE_TOKEN");
|
|
1180
|
-
Modal.install = function(app) {
|
|
1181
|
-
app.component(Modal.name, Modal);
|
|
1182
|
-
};
|
|
1183
547
|
var index = {
|
|
1184
548
|
title: "Modal \u5F39\u7A97",
|
|
1185
549
|
category: "\u53CD\u9988",
|
|
1186
550
|
status: "100%",
|
|
1187
551
|
install(app) {
|
|
1188
|
-
app.
|
|
552
|
+
app.component(Modal.name, Modal);
|
|
553
|
+
app.component(Header.name, Header);
|
|
554
|
+
app.component(Body.name, Body);
|
|
555
|
+
app.component(Footer.name, Footer);
|
|
1189
556
|
if (!inBrowser) {
|
|
1190
557
|
return;
|
|
1191
558
|
}
|
|
@@ -1196,7 +563,6 @@ var index = {
|
|
|
1196
563
|
document.body.appendChild(anchorsContainer);
|
|
1197
564
|
}
|
|
1198
565
|
app.provide(ModalService.token, new ModalService(anchorsContainer));
|
|
1199
|
-
app.provide(DialogService.token, new DialogService(anchorsContainer));
|
|
1200
566
|
}
|
|
1201
567
|
};
|
|
1202
568
|
export { Modal, index as default };
|