vue-devui 1.0.0-rc.9 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -149
- package/alert/index.es.js +12 -7
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +8036 -260
- package/auto-complete/index.umd.js +29 -3
- package/auto-complete/style.css +1 -1
- package/badge/index.es.js +8 -2
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +110 -45
- package/button/index.umd.js +15 -15
- package/button/style.css +1 -1
- package/card/index.es.js +5 -1
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +7778 -81
- package/checkbox/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/{date-picker → collapse}/index.d.ts +0 -0
- package/collapse/index.es.js +213 -0
- package/collapse/index.umd.js +1 -0
- package/{date-picker → collapse}/package.json +1 -1
- package/collapse/style.css +1 -0
- package/countdown/index.es.js +56 -13
- package/countdown/index.umd.js +1 -1
- package/date-picker-pro/index.d.ts +7 -0
- package/date-picker-pro/index.es.js +12022 -0
- package/date-picker-pro/index.umd.js +27 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.es.js +22 -5
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +92 -123
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +374 -149
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +102 -123
- package/form/index.umd.js +14 -14
- package/form/style.css +1 -1
- package/icon/index.es.js +107 -41
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +8097 -170
- package/input/index.umd.js +27 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +34 -32
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +1 -1
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +51 -51
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/mention/index.d.ts +7 -0
- package/mention/index.es.js +8326 -0
- package/mention/index.umd.js +36 -0
- package/mention/package.json +7 -0
- package/mention/style.css +1 -0
- package/menu/index.d.ts +7 -0
- package/menu/index.es.js +921 -0
- package/menu/index.umd.js +1 -0
- package/menu/package.json +7 -0
- package/menu/style.css +1 -0
- package/message/index.d.ts +7 -0
- package/message/index.es.js +539 -0
- package/message/index.umd.js +1 -0
- package/message/package.json +7 -0
- package/message/style.css +1 -0
- package/modal/index.es.js +390 -185
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +148 -79
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/DRangeDatePickerPro.js +3 -0
- package/nuxt/components/DatePickerPro.js +3 -0
- package/nuxt/components/IconGroup.js +3 -0
- package/nuxt/components/Mention.js +3 -0
- package/nuxt/components/Menu.js +3 -0
- package/nuxt/components/MenuItem.js +3 -0
- package/nuxt/components/Message.js +3 -0
- package/nuxt/components/OptionGroup.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/Step.js +3 -0
- package/nuxt/components/Steps.js +3 -0
- package/nuxt/components/SubMenu.js +3 -0
- package/nuxt/components/TABLE_TOKEN.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/TimeSelect.js +3 -0
- package/nuxt/components/animationInjectionKey.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/datePickerProCommonProps.js +3 -0
- package/nuxt/components/datePickerProPanelProps.js +3 -0
- package/nuxt/components/datePickerProProps.js +3 -0
- package/nuxt/components/mentionProps.js +3 -0
- package/nuxt/components/messageProps.js +3 -0
- package/nuxt/components/paginationInjectionKey.js +3 -0
- package/nuxt/components/roundInjectionKey.js +3 -0
- package/nuxt/components/skeletonItemProps.js +3 -0
- package/nuxt/components/stepProps.js +3 -0
- package/nuxt/components/stepsProps.js +3 -0
- package/nuxt/components/tableProps.js +3 -0
- package/nuxt/components/timerPickerPanelProps.js +3 -0
- package/nuxt/components/treeNodeProps.js +3 -0
- package/overlay/index.es.js +87 -140
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +7 -4
- package/pagination/index.es.js +10180 -129
- package/pagination/index.umd.js +27 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +4 -0
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.es.js +111 -164
- package/popover/index.umd.js +16 -16
- package/popover/style.css +1 -1
- package/progress/style.css +1 -1
- package/radio/index.es.js +7860 -58
- package/radio/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +93 -41
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/search/index.es.js +3737 -1206
- package/search/index.umd.js +18 -18
- package/search/style.css +1 -1
- package/select/index.es.js +4446 -2499
- package/select/index.umd.js +17 -17
- package/select/style.css +1 -1
- package/skeleton/index.es.js +87 -261
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +116 -143
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +284 -152
- package/splitter/index.umd.js +16 -16
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +34 -16
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +4 -0
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps/index.d.ts +7 -0
- package/steps/index.es.js +387 -0
- package/steps/index.umd.js +1 -0
- package/steps/package.json +7 -0
- package/steps/style.css +1 -0
- package/style.css +1 -1
- package/switch/index.es.js +7785 -60
- package/switch/index.umd.js +27 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +4224 -1502
- package/table/index.umd.js +17 -17
- package/table/style.css +1 -1
- package/tabs/index.es.js +281 -83
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +5 -1
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +3362 -1061
- package/textarea/index.umd.js +19 -19
- package/textarea/style.css +1 -1
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +9549 -0
- package/time-picker/index.umd.js +27 -0
- package/time-picker/package.json +7 -0
- package/time-picker/style.css +1 -0
- package/time-select/index.d.ts +7 -0
- package/time-select/index.es.js +9610 -0
- package/time-select/index.umd.js +27 -0
- package/time-select/package.json +7 -0
- package/time-select/style.css +1 -0
- package/timeline/index.es.js +93 -41
- package/timeline/index.umd.js +1 -1
- package/timeline/style.css +1 -1
- package/tooltip/index.es.js +127 -168
- package/tooltip/index.umd.js +16 -16
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +11045 -607
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +394 -111
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +19687 -11762
- package/vue-devui.umd.js +24 -23
- package/date-picker/index.es.js +0 -1298
- package/date-picker/index.umd.js +0 -1
- package/date-picker/style.css +0 -1
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/Loading.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/formControlProps.js +0 -3
- package/nuxt/components/overlayEmits.js +0 -3
- package/nuxt/components/overlayProps.js +0 -3
package/modal/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ var __publicField = (obj, key, value) => {
|
|
|
33
33
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
34
|
return value;
|
|
35
35
|
};
|
|
36
|
-
import { defineComponent, toRefs, computed, createVNode, resolveDynamicComponent, mergeProps,
|
|
36
|
+
import { defineComponent, toRefs, computed, createVNode, resolveDynamicComponent, mergeProps, watch, onUnmounted, Transition, ref, unref, nextTick, withModifiers, onMounted, watchEffect, onBeforeUnmount, Teleport, h, render } from "vue";
|
|
37
37
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
38
38
|
const modalProps = {
|
|
39
39
|
modelValue: {
|
|
@@ -48,17 +48,42 @@ const modalProps = {
|
|
|
48
48
|
type: Boolean,
|
|
49
49
|
default: true
|
|
50
50
|
},
|
|
51
|
+
draggable: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
51
55
|
closeOnClickOverlay: {
|
|
52
56
|
type: Boolean,
|
|
53
57
|
default: true
|
|
54
58
|
},
|
|
55
59
|
beforeClose: {
|
|
56
60
|
type: Function
|
|
61
|
+
},
|
|
62
|
+
escapable: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: true
|
|
65
|
+
},
|
|
66
|
+
showClose: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: true
|
|
69
|
+
},
|
|
70
|
+
showAnimation: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: true
|
|
73
|
+
},
|
|
74
|
+
showOverlay: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: true
|
|
77
|
+
},
|
|
78
|
+
appendToBody: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: true
|
|
81
|
+
},
|
|
82
|
+
type: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: ""
|
|
57
85
|
}
|
|
58
86
|
};
|
|
59
|
-
function isUrl(value) {
|
|
60
|
-
return /^((http|https):)?\/\//.test(value);
|
|
61
|
-
}
|
|
62
87
|
const DEFAULT_PREFIX = "icon";
|
|
63
88
|
const iconProps = {
|
|
64
89
|
name: {
|
|
@@ -81,6 +106,17 @@ const iconProps = {
|
|
|
81
106
|
classPrefix: {
|
|
82
107
|
type: String,
|
|
83
108
|
default: DEFAULT_PREFIX
|
|
109
|
+
},
|
|
110
|
+
operable: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: false
|
|
113
|
+
},
|
|
114
|
+
disabled: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: false
|
|
117
|
+
},
|
|
118
|
+
rotate: {
|
|
119
|
+
type: [Number, String]
|
|
84
120
|
}
|
|
85
121
|
};
|
|
86
122
|
const svgIconProps = {
|
|
@@ -151,178 +187,191 @@ var svgIcon = defineComponent({
|
|
|
151
187
|
};
|
|
152
188
|
}
|
|
153
189
|
});
|
|
190
|
+
function isUrl(value) {
|
|
191
|
+
return /^((http|https):)?\/\//.test(value);
|
|
192
|
+
}
|
|
193
|
+
function useIconDom(props, ctx) {
|
|
194
|
+
const {
|
|
195
|
+
component,
|
|
196
|
+
name,
|
|
197
|
+
size,
|
|
198
|
+
color,
|
|
199
|
+
classPrefix,
|
|
200
|
+
rotate
|
|
201
|
+
} = toRefs(props);
|
|
202
|
+
const ns = useNamespace("icon");
|
|
203
|
+
const iconSize = computed(() => {
|
|
204
|
+
return typeof size.value === "number" ? `${size.value}px` : size.value;
|
|
205
|
+
});
|
|
206
|
+
const IconComponent = component.value ? resolveDynamicComponent(component.value) : resolveDynamicComponent(svgIcon);
|
|
207
|
+
const imgIconDom = () => {
|
|
208
|
+
return createVNode("img", mergeProps({
|
|
209
|
+
"src": name.value,
|
|
210
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
211
|
+
"class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
|
|
212
|
+
"style": {
|
|
213
|
+
width: iconSize.value || "",
|
|
214
|
+
transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`,
|
|
215
|
+
verticalAlign: "middle"
|
|
216
|
+
}
|
|
217
|
+
}, ctx.attrs), null);
|
|
218
|
+
};
|
|
219
|
+
const svgIconDom = () => {
|
|
220
|
+
return createVNode(IconComponent, mergeProps({
|
|
221
|
+
"name": name.value,
|
|
222
|
+
"color": color.value,
|
|
223
|
+
"size": iconSize.value,
|
|
224
|
+
"class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
|
|
225
|
+
"style": {
|
|
226
|
+
transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
|
|
227
|
+
}
|
|
228
|
+
}, ctx.attrs), null);
|
|
229
|
+
};
|
|
230
|
+
const fontIconDom = () => {
|
|
231
|
+
const fontIconClass = /^icon-/.test(name.value) ? name.value : `${classPrefix.value}-${name.value}`;
|
|
232
|
+
return createVNode("i", mergeProps({
|
|
233
|
+
"class": [classPrefix.value, fontIconClass, (rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
|
|
234
|
+
"style": {
|
|
235
|
+
fontSize: iconSize.value,
|
|
236
|
+
color: color.value,
|
|
237
|
+
transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
|
|
238
|
+
}
|
|
239
|
+
}, ctx.attrs), null);
|
|
240
|
+
};
|
|
241
|
+
const iconDom = () => {
|
|
242
|
+
return component.value ? svgIconDom() : isUrl(name.value) ? imgIconDom() : fontIconDom();
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
iconDom
|
|
246
|
+
};
|
|
247
|
+
}
|
|
154
248
|
var Icon = defineComponent({
|
|
155
249
|
name: "DIcon",
|
|
156
250
|
props: iconProps,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}) {
|
|
251
|
+
emits: ["click"],
|
|
252
|
+
setup(props, ctx) {
|
|
160
253
|
const {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
size,
|
|
164
|
-
color,
|
|
165
|
-
classPrefix
|
|
254
|
+
disabled,
|
|
255
|
+
operable
|
|
166
256
|
} = toRefs(props);
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
"style": {
|
|
183
|
-
width: iconSize.value || ""
|
|
184
|
-
}
|
|
185
|
-
}, attrs), null);
|
|
186
|
-
};
|
|
187
|
-
const fontIconDom = () => {
|
|
188
|
-
const fontIconClass = /^icon-/.test(name.value) ? name.value : `${classPrefix.value}-${name.value}`;
|
|
189
|
-
return createVNode("i", mergeProps({
|
|
190
|
-
"class": [classPrefix.value, fontIconClass],
|
|
191
|
-
"style": {
|
|
192
|
-
fontSize: iconSize.value,
|
|
193
|
-
color: color.value
|
|
194
|
-
}
|
|
195
|
-
}, attrs), null);
|
|
257
|
+
const {
|
|
258
|
+
iconDom
|
|
259
|
+
} = useIconDom(props, ctx);
|
|
260
|
+
const ns = useNamespace("icon");
|
|
261
|
+
const wrapClassed = computed(() => ({
|
|
262
|
+
[ns.e("container")]: true,
|
|
263
|
+
[ns.m("disabled")]: disabled.value,
|
|
264
|
+
[ns.m("operable")]: operable.value,
|
|
265
|
+
[ns.m("no-slots")]: !Object.keys(ctx.slots).length
|
|
266
|
+
}));
|
|
267
|
+
const onClick = (e) => {
|
|
268
|
+
if (disabled.value) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
ctx.emit("click", e);
|
|
196
272
|
};
|
|
197
273
|
return () => {
|
|
198
|
-
|
|
274
|
+
var _a, _b, _c, _d;
|
|
275
|
+
return createVNode("div", {
|
|
276
|
+
"class": wrapClassed.value,
|
|
277
|
+
"onClick": onClick
|
|
278
|
+
}, [(_b = (_a = ctx.slots).prefix) == null ? void 0 : _b.call(_a), iconDom(), (_d = (_c = ctx.slots).suffix) == null ? void 0 : _d.call(_c)]);
|
|
199
279
|
};
|
|
200
280
|
}
|
|
201
281
|
});
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
setup(props, ctx) {
|
|
208
|
-
const ns = useNamespace("overlay");
|
|
282
|
+
var iconGroup = "";
|
|
283
|
+
defineComponent({
|
|
284
|
+
name: "DIconGroup",
|
|
285
|
+
setup(_, ctx) {
|
|
286
|
+
const ns = useNamespace("icon-group");
|
|
209
287
|
return () => {
|
|
210
|
-
|
|
211
|
-
return createVNode(
|
|
212
|
-
"
|
|
213
|
-
},
|
|
214
|
-
default: () => [createVNode(Transition, {
|
|
215
|
-
"name": ns.e("fade")
|
|
216
|
-
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
217
|
-
default: () => [_slot]
|
|
218
|
-
})]
|
|
219
|
-
});
|
|
288
|
+
var _a, _b;
|
|
289
|
+
return createVNode("div", {
|
|
290
|
+
"class": ns.b()
|
|
291
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
220
292
|
};
|
|
221
293
|
}
|
|
222
294
|
});
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
type: Boolean
|
|
226
|
-
},
|
|
227
|
-
backgroundBlock: {
|
|
295
|
+
const fixedOverlayProps = {
|
|
296
|
+
modelValue: {
|
|
228
297
|
type: Boolean,
|
|
229
298
|
default: false
|
|
230
299
|
},
|
|
231
|
-
|
|
232
|
-
type: String,
|
|
233
|
-
default: ""
|
|
234
|
-
},
|
|
235
|
-
backgroundStyle: {
|
|
236
|
-
type: [String, Object]
|
|
237
|
-
},
|
|
238
|
-
onBackdropClick: {
|
|
239
|
-
type: Function
|
|
240
|
-
},
|
|
241
|
-
backdropClose: {
|
|
300
|
+
lockScroll: {
|
|
242
301
|
type: Boolean,
|
|
243
302
|
default: true
|
|
244
303
|
},
|
|
245
|
-
|
|
304
|
+
closeOnClickOverlay: {
|
|
246
305
|
type: Boolean,
|
|
247
306
|
default: true
|
|
248
307
|
}
|
|
249
308
|
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
309
|
+
function lockScroll() {
|
|
310
|
+
if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
|
|
311
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
312
|
+
const style = document.documentElement.getAttribute("style");
|
|
313
|
+
document.documentElement.style.position = "fixed";
|
|
314
|
+
document.documentElement.style.top = `-${scrollTop}px`;
|
|
315
|
+
document.documentElement.style.width = document.documentElement.style.width || "100%";
|
|
316
|
+
document.documentElement.style.overflowY = "scroll";
|
|
317
|
+
return () => {
|
|
318
|
+
if (style) {
|
|
319
|
+
document.documentElement.setAttribute("style", style);
|
|
320
|
+
} else {
|
|
321
|
+
document.documentElement.removeAttribute("style");
|
|
322
|
+
}
|
|
323
|
+
document.documentElement.scrollTop = scrollTop;
|
|
324
|
+
};
|
|
254
325
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
return [ns.e("background"), props.backgroundClass, !props.hasBackdrop ? ns.em("background", "disabled") : ns.em("background", "color")];
|
|
261
|
-
});
|
|
262
|
-
const overlayClass = computed(() => {
|
|
263
|
-
return ns.b();
|
|
264
|
-
});
|
|
265
|
-
const handleBackdropClick = (event) => {
|
|
266
|
-
var _a;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
function useFixedOverlay(props, ctx) {
|
|
329
|
+
let lockScrollCb;
|
|
330
|
+
const onClick = (event) => {
|
|
267
331
|
event.preventDefault();
|
|
268
|
-
(
|
|
269
|
-
if (props.
|
|
270
|
-
ctx.emit("update:
|
|
332
|
+
ctx.emit("click", event);
|
|
333
|
+
if (props.closeOnClickOverlay) {
|
|
334
|
+
ctx.emit("update:modelValue", false);
|
|
271
335
|
}
|
|
272
336
|
};
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
const body = document.body;
|
|
276
|
-
const originOverflow = body.style.overflow;
|
|
277
|
-
const originPosition = body.style.position;
|
|
278
|
-
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
279
|
-
if (backgroundBlock) {
|
|
280
|
-
const top = body.getBoundingClientRect().y;
|
|
281
|
-
if (visible) {
|
|
282
|
-
body.style.overflowY = "scroll";
|
|
283
|
-
body.style.position = visible ? "fixed" : "";
|
|
284
|
-
body.style.top = `${top}px`;
|
|
285
|
-
} else {
|
|
286
|
-
body.style.overflowY = originOverflow;
|
|
287
|
-
body.style.position = originPosition;
|
|
288
|
-
body.style.top = "";
|
|
289
|
-
window.scrollTo(0, -top);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
onUnmounted(() => {
|
|
294
|
-
document.body.style.overflow = originOverflow;
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
return {
|
|
298
|
-
backgroundClass,
|
|
299
|
-
overlayClass,
|
|
300
|
-
handleBackdropClick,
|
|
301
|
-
handleOverlayBubbleCancel
|
|
337
|
+
const removeBodyAdditions = () => {
|
|
338
|
+
lockScrollCb == null ? void 0 : lockScrollCb();
|
|
302
339
|
};
|
|
340
|
+
watch(() => props.modelValue, (val) => {
|
|
341
|
+
if (val) {
|
|
342
|
+
props.lockScroll && (lockScrollCb = lockScroll());
|
|
343
|
+
} else {
|
|
344
|
+
removeBodyAdditions();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
onUnmounted(removeBodyAdditions);
|
|
348
|
+
return { onClick };
|
|
303
349
|
}
|
|
304
350
|
var fixedOverlay = "";
|
|
305
351
|
const FixedOverlay = defineComponent({
|
|
306
352
|
name: "DFixedOverlay",
|
|
353
|
+
inheritAttrs: false,
|
|
307
354
|
props: fixedOverlayProps,
|
|
308
|
-
emits:
|
|
355
|
+
emits: ["update:modelValue", "click"],
|
|
309
356
|
setup(props, ctx) {
|
|
310
357
|
const {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
358
|
+
modelValue
|
|
359
|
+
} = toRefs(props);
|
|
360
|
+
const ns = useNamespace("fixed-overlay");
|
|
361
|
+
const {
|
|
362
|
+
onClick
|
|
363
|
+
} = useFixedOverlay(props, ctx);
|
|
364
|
+
return () => createVNode(Transition, {
|
|
365
|
+
"name": ns.m("fade")
|
|
366
|
+
}, {
|
|
367
|
+
default: () => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
return [modelValue.value && createVNode("div", mergeProps({
|
|
370
|
+
"class": ns.b()
|
|
371
|
+
}, ctx.attrs, {
|
|
372
|
+
"onClick": onClick
|
|
373
|
+
}), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
|
|
374
|
+
}
|
|
326
375
|
});
|
|
327
376
|
}
|
|
328
377
|
});
|
|
@@ -357,6 +406,10 @@ const flexibleOverlayProps = {
|
|
|
357
406
|
isArrowCenter: {
|
|
358
407
|
type: Boolean,
|
|
359
408
|
default: true
|
|
409
|
+
},
|
|
410
|
+
clickEventBubble: {
|
|
411
|
+
type: Boolean,
|
|
412
|
+
default: false
|
|
360
413
|
}
|
|
361
414
|
};
|
|
362
415
|
function getScrollParent(element) {
|
|
@@ -471,6 +524,9 @@ defineComponent({
|
|
|
471
524
|
expose
|
|
472
525
|
}) {
|
|
473
526
|
const ns = useNamespace("flexible-overlay");
|
|
527
|
+
const {
|
|
528
|
+
clickEventBubble
|
|
529
|
+
} = toRefs(props);
|
|
474
530
|
const {
|
|
475
531
|
arrowRef,
|
|
476
532
|
overlayRef,
|
|
@@ -484,7 +540,10 @@ defineComponent({
|
|
|
484
540
|
return props.modelValue && createVNode("div", mergeProps({
|
|
485
541
|
"ref": overlayRef,
|
|
486
542
|
"class": ns.b()
|
|
487
|
-
}, attrs
|
|
543
|
+
}, attrs, {
|
|
544
|
+
"onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
|
|
545
|
+
"onPointerup": withModifiers(() => ({}), ["stop"])
|
|
546
|
+
}), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
488
547
|
"ref": arrowRef,
|
|
489
548
|
"class": ns.e("arrow")
|
|
490
549
|
}, null)]);
|
|
@@ -496,13 +555,113 @@ function useModal(props, emit) {
|
|
|
496
555
|
function close() {
|
|
497
556
|
emit("update:modelValue", false);
|
|
498
557
|
}
|
|
499
|
-
function
|
|
500
|
-
|
|
501
|
-
|
|
558
|
+
function execClose() {
|
|
559
|
+
props.beforeClose ? props.beforeClose(close) : close();
|
|
560
|
+
}
|
|
561
|
+
function onKeydown(event) {
|
|
562
|
+
if (event.code === "Escape") {
|
|
563
|
+
execClose();
|
|
502
564
|
}
|
|
503
565
|
}
|
|
504
|
-
|
|
566
|
+
onMounted(() => {
|
|
567
|
+
if (props.escapable) {
|
|
568
|
+
window.addEventListener("keydown", onKeydown);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
onUnmounted(() => {
|
|
572
|
+
if (props.escapable) {
|
|
573
|
+
window.addEventListener("keydown", onKeydown);
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
return { execClose };
|
|
505
577
|
}
|
|
578
|
+
function useModalRender(props) {
|
|
579
|
+
let lockScrollCb;
|
|
580
|
+
const removeBodyAdditions = () => {
|
|
581
|
+
lockScrollCb == null ? void 0 : lockScrollCb();
|
|
582
|
+
};
|
|
583
|
+
watch(() => props.modelValue, (val) => {
|
|
584
|
+
if (val) {
|
|
585
|
+
props.lockScroll && (lockScrollCb = lockScroll());
|
|
586
|
+
} else {
|
|
587
|
+
removeBodyAdditions();
|
|
588
|
+
}
|
|
589
|
+
}, {
|
|
590
|
+
immediate: true
|
|
591
|
+
});
|
|
592
|
+
onUnmounted(removeBodyAdditions);
|
|
593
|
+
}
|
|
594
|
+
function addUnit(value, defaultUnit = "px") {
|
|
595
|
+
if (!value) {
|
|
596
|
+
return "";
|
|
597
|
+
}
|
|
598
|
+
if (typeof value === "string") {
|
|
599
|
+
return value;
|
|
600
|
+
} else if (typeof value === "number") {
|
|
601
|
+
return `${value}${defaultUnit}`;
|
|
602
|
+
} else {
|
|
603
|
+
return "";
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
const useDraggable = (targetRef, dragRef, draggable) => {
|
|
607
|
+
let transform = {
|
|
608
|
+
offsetX: 0,
|
|
609
|
+
offsetY: 0
|
|
610
|
+
};
|
|
611
|
+
const onMousedown = (e) => {
|
|
612
|
+
const downX = e.clientX;
|
|
613
|
+
const downY = e.clientY;
|
|
614
|
+
const { offsetX, offsetY } = transform;
|
|
615
|
+
const targetRect = targetRef.value.getBoundingClientRect();
|
|
616
|
+
const targetLeft = targetRect.left;
|
|
617
|
+
const targetTop = targetRect.top;
|
|
618
|
+
const targetWidth = targetRect.width;
|
|
619
|
+
const targetHeight = targetRect.height;
|
|
620
|
+
const clientWidth = document.documentElement.clientWidth;
|
|
621
|
+
const clientHeight = document.documentElement.clientHeight;
|
|
622
|
+
const minLeft = -targetLeft + offsetX;
|
|
623
|
+
const minTop = -targetTop + offsetY;
|
|
624
|
+
const maxLeft = clientWidth - targetLeft - targetWidth + offsetX;
|
|
625
|
+
const maxTop = clientHeight - targetTop - targetHeight + offsetY;
|
|
626
|
+
const onMousemove = (ev) => {
|
|
627
|
+
const moveX = Math.min(Math.max(offsetX + ev.clientX - downX, minLeft), maxLeft);
|
|
628
|
+
const moveY = Math.min(Math.max(offsetY + ev.clientY - downY, minTop), maxTop);
|
|
629
|
+
transform = {
|
|
630
|
+
offsetX: moveX,
|
|
631
|
+
offsetY: moveY
|
|
632
|
+
};
|
|
633
|
+
targetRef.value.style.transform = `translate(${addUnit(moveX)}, ${addUnit(moveY)})`;
|
|
634
|
+
};
|
|
635
|
+
const onMouseup = () => {
|
|
636
|
+
document.removeEventListener("mousemove", onMousemove);
|
|
637
|
+
document.removeEventListener("mouseup", onMouseup);
|
|
638
|
+
};
|
|
639
|
+
document.addEventListener("mousemove", onMousemove);
|
|
640
|
+
document.addEventListener("mouseup", onMouseup);
|
|
641
|
+
};
|
|
642
|
+
const onDraggable = () => {
|
|
643
|
+
if (dragRef.value && targetRef.value) {
|
|
644
|
+
dragRef.value.addEventListener("mousedown", onMousedown);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
const offDraggable = () => {
|
|
648
|
+
if (dragRef.value && targetRef.value) {
|
|
649
|
+
dragRef.value.removeEventListener("mousedown", onMousedown);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
onMounted(() => {
|
|
653
|
+
watchEffect(() => {
|
|
654
|
+
if (draggable.value) {
|
|
655
|
+
onDraggable();
|
|
656
|
+
} else {
|
|
657
|
+
offDraggable();
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
onBeforeUnmount(() => {
|
|
662
|
+
offDraggable();
|
|
663
|
+
});
|
|
664
|
+
};
|
|
506
665
|
var Header = defineComponent({
|
|
507
666
|
name: "DModalHeader",
|
|
508
667
|
setup(props, {
|
|
@@ -540,55 +699,101 @@ var Modal = defineComponent({
|
|
|
540
699
|
setup(props, {
|
|
541
700
|
slots,
|
|
542
701
|
attrs,
|
|
543
|
-
emit
|
|
544
|
-
expose
|
|
702
|
+
emit
|
|
545
703
|
}) {
|
|
546
704
|
const ns = useNamespace("modal");
|
|
547
705
|
const {
|
|
548
706
|
modelValue,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
707
|
+
title,
|
|
708
|
+
showClose,
|
|
709
|
+
showOverlay,
|
|
710
|
+
appendToBody,
|
|
711
|
+
closeOnClickOverlay
|
|
552
712
|
} = toRefs(props);
|
|
553
713
|
const {
|
|
554
|
-
|
|
714
|
+
execClose
|
|
555
715
|
} = useModal(props, emit);
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
"
|
|
565
|
-
"
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
})]
|
|
716
|
+
useModalRender(props);
|
|
717
|
+
const dialogRef = ref();
|
|
718
|
+
const headerRef = ref();
|
|
719
|
+
const draggable = computed(() => props.draggable);
|
|
720
|
+
useDraggable(dialogRef, headerRef, draggable);
|
|
721
|
+
const renderType = () => {
|
|
722
|
+
const typeList = [{
|
|
723
|
+
type: "success",
|
|
724
|
+
text: "\u6210\u529F",
|
|
725
|
+
icon: "right-o"
|
|
726
|
+
}, {
|
|
727
|
+
type: "failed",
|
|
728
|
+
text: "\u9519\u8BEF",
|
|
729
|
+
icon: "error-o"
|
|
730
|
+
}, {
|
|
731
|
+
type: "warning",
|
|
732
|
+
text: "\u8B66\u544A",
|
|
733
|
+
icon: "warning-o"
|
|
734
|
+
}, {
|
|
735
|
+
type: "info",
|
|
736
|
+
text: "\u4FE1\u606F",
|
|
737
|
+
icon: "info-o"
|
|
738
|
+
}];
|
|
739
|
+
const item = typeList.find((i) => i.type === props.type);
|
|
740
|
+
return createVNode(Header, null, {
|
|
741
|
+
default: () => [createVNode("div", {
|
|
742
|
+
"class": "type-content"
|
|
743
|
+
}, [createVNode("div", {
|
|
744
|
+
"class": "type-content-icon"
|
|
745
|
+
}, [createVNode(Icon, {
|
|
746
|
+
"name": item == null ? void 0 : item.icon
|
|
747
|
+
}, null)]), createVNode("div", {
|
|
748
|
+
"class": "type-content-text"
|
|
749
|
+
}, [item == null ? void 0 : item.text])])]
|
|
590
750
|
});
|
|
591
751
|
};
|
|
752
|
+
return () => createVNode(Teleport, {
|
|
753
|
+
"to": "body",
|
|
754
|
+
"disabled": !appendToBody.value
|
|
755
|
+
}, {
|
|
756
|
+
default: () => [showOverlay.value && createVNode(FixedOverlay, {
|
|
757
|
+
"modelValue": modelValue.value,
|
|
758
|
+
"onUpdate:modelValue": execClose,
|
|
759
|
+
"class": ns.e("overlay"),
|
|
760
|
+
"lock-scroll": false,
|
|
761
|
+
"close-on-click-overlay": closeOnClickOverlay.value,
|
|
762
|
+
"style": {
|
|
763
|
+
zIndex: "calc(var(--devui-z-index-modal, 1050) - 1)"
|
|
764
|
+
}
|
|
765
|
+
}, null), createVNode(Transition, {
|
|
766
|
+
"name": props.showAnimation ? ns.m("wipe") : ""
|
|
767
|
+
}, {
|
|
768
|
+
default: () => {
|
|
769
|
+
var _a;
|
|
770
|
+
return [modelValue.value && createVNode("div", mergeProps({
|
|
771
|
+
"ref": dialogRef,
|
|
772
|
+
"class": ns.b()
|
|
773
|
+
}, attrs, {
|
|
774
|
+
"onClick": (e) => e.stopPropagation()
|
|
775
|
+
}), [showClose.value && createVNode("div", {
|
|
776
|
+
"onClick": execClose,
|
|
777
|
+
"class": "btn-close"
|
|
778
|
+
}, [createVNode(Icon, {
|
|
779
|
+
"name": "close",
|
|
780
|
+
"size": "20px"
|
|
781
|
+
}, null)]), props.type ? renderType() : createVNode("div", {
|
|
782
|
+
"style": {
|
|
783
|
+
cursor: props.draggable ? "move" : "default"
|
|
784
|
+
},
|
|
785
|
+
"ref": headerRef
|
|
786
|
+
}, [slots.header ? slots.header() : title.value && createVNode(Header, null, {
|
|
787
|
+
default: () => [title.value]
|
|
788
|
+
})]), createVNode(Body, null, {
|
|
789
|
+
default: () => {
|
|
790
|
+
var _a2;
|
|
791
|
+
return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
|
|
792
|
+
}
|
|
793
|
+
}), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
|
|
794
|
+
}
|
|
795
|
+
})]
|
|
796
|
+
});
|
|
592
797
|
}
|
|
593
798
|
});
|
|
594
799
|
var Footer = defineComponent({
|