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.
Files changed (208) hide show
  1. package/README.md +189 -149
  2. package/alert/index.es.js +12 -7
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +8036 -260
  6. package/auto-complete/index.umd.js +29 -3
  7. package/auto-complete/style.css +1 -1
  8. package/badge/index.es.js +8 -2
  9. package/badge/index.umd.js +1 -1
  10. package/badge/style.css +1 -1
  11. package/button/index.es.js +110 -45
  12. package/button/index.umd.js +15 -15
  13. package/button/style.css +1 -1
  14. package/card/index.es.js +5 -1
  15. package/card/index.umd.js +1 -1
  16. package/card/style.css +1 -1
  17. package/checkbox/index.es.js +7778 -81
  18. package/checkbox/index.umd.js +27 -1
  19. package/checkbox/style.css +1 -1
  20. package/{date-picker → collapse}/index.d.ts +0 -0
  21. package/collapse/index.es.js +213 -0
  22. package/collapse/index.umd.js +1 -0
  23. package/{date-picker → collapse}/package.json +1 -1
  24. package/collapse/style.css +1 -0
  25. package/countdown/index.es.js +56 -13
  26. package/countdown/index.umd.js +1 -1
  27. package/date-picker-pro/index.d.ts +7 -0
  28. package/date-picker-pro/index.es.js +12022 -0
  29. package/date-picker-pro/index.umd.js +27 -0
  30. package/date-picker-pro/package.json +7 -0
  31. package/date-picker-pro/style.css +1 -0
  32. package/drawer/index.es.js +22 -5
  33. package/drawer/index.umd.js +1 -1
  34. package/drawer/style.css +1 -1
  35. package/dropdown/index.es.js +92 -123
  36. package/dropdown/index.umd.js +1 -1
  37. package/dropdown/style.css +1 -1
  38. package/editable-select/index.es.js +374 -149
  39. package/editable-select/index.umd.js +1 -1
  40. package/editable-select/style.css +1 -1
  41. package/form/index.es.js +102 -123
  42. package/form/index.umd.js +14 -14
  43. package/form/style.css +1 -1
  44. package/icon/index.es.js +107 -41
  45. package/icon/index.umd.js +1 -1
  46. package/icon/style.css +1 -1
  47. package/image-preview/style.css +1 -1
  48. package/input/index.es.js +8097 -170
  49. package/input/index.umd.js +27 -1
  50. package/input/style.css +1 -1
  51. package/input-number/index.es.js +34 -32
  52. package/input-number/index.umd.js +1 -1
  53. package/input-number/style.css +1 -1
  54. package/layout/index.es.js +1 -1
  55. package/layout/index.umd.js +1 -1
  56. package/loading/index.es.js +51 -51
  57. package/loading/index.umd.js +1 -1
  58. package/loading/style.css +1 -1
  59. package/mention/index.d.ts +7 -0
  60. package/mention/index.es.js +8326 -0
  61. package/mention/index.umd.js +36 -0
  62. package/mention/package.json +7 -0
  63. package/mention/style.css +1 -0
  64. package/menu/index.d.ts +7 -0
  65. package/menu/index.es.js +921 -0
  66. package/menu/index.umd.js +1 -0
  67. package/menu/package.json +7 -0
  68. package/menu/style.css +1 -0
  69. package/message/index.d.ts +7 -0
  70. package/message/index.es.js +539 -0
  71. package/message/index.umd.js +1 -0
  72. package/message/package.json +7 -0
  73. package/message/style.css +1 -0
  74. package/modal/index.es.js +390 -185
  75. package/modal/index.umd.js +1 -1
  76. package/modal/style.css +1 -1
  77. package/notification/index.es.js +148 -79
  78. package/notification/index.umd.js +1 -1
  79. package/notification/style.css +1 -1
  80. package/nuxt/components/Collapse.js +3 -0
  81. package/nuxt/components/CollapseItem.js +3 -0
  82. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  83. package/nuxt/components/DatePickerPro.js +3 -0
  84. package/nuxt/components/IconGroup.js +3 -0
  85. package/nuxt/components/Mention.js +3 -0
  86. package/nuxt/components/Menu.js +3 -0
  87. package/nuxt/components/MenuItem.js +3 -0
  88. package/nuxt/components/Message.js +3 -0
  89. package/nuxt/components/OptionGroup.js +3 -0
  90. package/nuxt/components/RadioButton.js +3 -0
  91. package/nuxt/components/Step.js +3 -0
  92. package/nuxt/components/Steps.js +3 -0
  93. package/nuxt/components/SubMenu.js +3 -0
  94. package/nuxt/components/TABLE_TOKEN.js +3 -0
  95. package/nuxt/components/TimePicker.js +3 -0
  96. package/nuxt/components/TimeSelect.js +3 -0
  97. package/nuxt/components/animationInjectionKey.js +3 -0
  98. package/nuxt/components/collapseItemProps.js +3 -0
  99. package/nuxt/components/collapseProps.js +3 -0
  100. package/nuxt/components/datePickerProCommonProps.js +3 -0
  101. package/nuxt/components/datePickerProPanelProps.js +3 -0
  102. package/nuxt/components/datePickerProProps.js +3 -0
  103. package/nuxt/components/mentionProps.js +3 -0
  104. package/nuxt/components/messageProps.js +3 -0
  105. package/nuxt/components/paginationInjectionKey.js +3 -0
  106. package/nuxt/components/roundInjectionKey.js +3 -0
  107. package/nuxt/components/skeletonItemProps.js +3 -0
  108. package/nuxt/components/stepProps.js +3 -0
  109. package/nuxt/components/stepsProps.js +3 -0
  110. package/nuxt/components/tableProps.js +3 -0
  111. package/nuxt/components/timerPickerPanelProps.js +3 -0
  112. package/nuxt/components/treeNodeProps.js +3 -0
  113. package/overlay/index.es.js +87 -140
  114. package/overlay/index.umd.js +1 -1
  115. package/overlay/style.css +1 -1
  116. package/package.json +7 -4
  117. package/pagination/index.es.js +10180 -129
  118. package/pagination/index.umd.js +27 -1
  119. package/pagination/style.css +1 -1
  120. package/panel/index.es.js +4 -0
  121. package/panel/index.umd.js +1 -1
  122. package/panel/style.css +1 -1
  123. package/popover/index.es.js +111 -164
  124. package/popover/index.umd.js +16 -16
  125. package/popover/style.css +1 -1
  126. package/progress/style.css +1 -1
  127. package/radio/index.es.js +7860 -58
  128. package/radio/index.umd.js +27 -1
  129. package/radio/style.css +1 -1
  130. package/rate/style.css +1 -1
  131. package/result/index.es.js +93 -41
  132. package/result/index.umd.js +1 -1
  133. package/result/style.css +1 -1
  134. package/search/index.es.js +3737 -1206
  135. package/search/index.umd.js +18 -18
  136. package/search/style.css +1 -1
  137. package/select/index.es.js +4446 -2499
  138. package/select/index.umd.js +17 -17
  139. package/select/style.css +1 -1
  140. package/skeleton/index.es.js +87 -261
  141. package/skeleton/index.umd.js +1 -1
  142. package/skeleton/style.css +1 -1
  143. package/slider/index.es.js +116 -143
  144. package/slider/index.umd.js +1 -1
  145. package/slider/style.css +1 -1
  146. package/splitter/index.es.js +284 -152
  147. package/splitter/index.umd.js +16 -16
  148. package/splitter/style.css +1 -1
  149. package/statistic/index.es.js +34 -16
  150. package/statistic/index.umd.js +1 -1
  151. package/statistic/style.css +1 -1
  152. package/status/index.es.js +4 -0
  153. package/status/index.umd.js +1 -1
  154. package/status/style.css +1 -1
  155. package/steps/index.d.ts +7 -0
  156. package/steps/index.es.js +387 -0
  157. package/steps/index.umd.js +1 -0
  158. package/steps/package.json +7 -0
  159. package/steps/style.css +1 -0
  160. package/style.css +1 -1
  161. package/switch/index.es.js +7785 -60
  162. package/switch/index.umd.js +27 -1
  163. package/switch/style.css +1 -1
  164. package/table/index.es.js +4224 -1502
  165. package/table/index.umd.js +17 -17
  166. package/table/style.css +1 -1
  167. package/tabs/index.es.js +281 -83
  168. package/tabs/index.umd.js +1 -1
  169. package/tabs/style.css +1 -1
  170. package/tag/index.es.js +5 -1
  171. package/tag/index.umd.js +1 -1
  172. package/tag/style.css +1 -1
  173. package/textarea/index.es.js +3362 -1061
  174. package/textarea/index.umd.js +19 -19
  175. package/textarea/style.css +1 -1
  176. package/time-picker/index.d.ts +7 -0
  177. package/time-picker/index.es.js +9549 -0
  178. package/time-picker/index.umd.js +27 -0
  179. package/time-picker/package.json +7 -0
  180. package/time-picker/style.css +1 -0
  181. package/time-select/index.d.ts +7 -0
  182. package/time-select/index.es.js +9610 -0
  183. package/time-select/index.umd.js +27 -0
  184. package/time-select/package.json +7 -0
  185. package/time-select/style.css +1 -0
  186. package/timeline/index.es.js +93 -41
  187. package/timeline/index.umd.js +1 -1
  188. package/timeline/style.css +1 -1
  189. package/tooltip/index.es.js +127 -168
  190. package/tooltip/index.umd.js +16 -16
  191. package/tooltip/style.css +1 -1
  192. package/tree/index.es.js +11045 -607
  193. package/tree/index.umd.js +27 -1
  194. package/tree/style.css +1 -1
  195. package/upload/index.es.js +394 -111
  196. package/upload/index.umd.js +1 -1
  197. package/upload/style.css +1 -1
  198. package/vue-devui.es.js +19687 -11762
  199. package/vue-devui.umd.js +24 -23
  200. package/date-picker/index.es.js +0 -1298
  201. package/date-picker/index.umd.js +0 -1
  202. package/date-picker/style.css +0 -1
  203. package/nuxt/components/DatePicker.js +0 -3
  204. package/nuxt/components/Loading.js +0 -3
  205. package/nuxt/components/StickSlider.js +0 -3
  206. package/nuxt/components/formControlProps.js +0 -3
  207. package/nuxt/components/overlayEmits.js +0 -3
  208. 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, Teleport, Transition, renderSlot, isVNode, onMounted, watch, onUnmounted, ref, unref, nextTick, h, render } from "vue";
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
- setup(props, {
158
- attrs
159
- }) {
251
+ emits: ["click"],
252
+ setup(props, ctx) {
160
253
  const {
161
- component,
162
- name,
163
- size,
164
- color,
165
- classPrefix
254
+ disabled,
255
+ operable
166
256
  } = toRefs(props);
167
- const IconComponent = component.value ? resolveDynamicComponent(component.value) : resolveDynamicComponent(svgIcon);
168
- const iconSize = computed(() => {
169
- return typeof size.value === "number" ? `${size.value}px` : size.value;
170
- });
171
- const svgIconDom = () => {
172
- return createVNode(IconComponent, mergeProps({
173
- "name": name.value,
174
- "color": color.value,
175
- "size": iconSize.value
176
- }, attrs), null);
177
- };
178
- const imgIconDom = () => {
179
- return createVNode("img", mergeProps({
180
- "src": name.value,
181
- "alt": name.value.split("/")[name.value.split("/").length - 1],
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
- return component.value ? svgIconDom() : isUrl(name.value) ? imgIconDom() : fontIconDom();
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 baseOverlay = "";
203
- function _isSlot(s) {
204
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
205
- }
206
- const CommonOverlay = defineComponent({
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
- let _slot;
211
- return createVNode(Teleport, {
212
- "to": "#d-overlay-anchor"
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 overlayProps = {
224
- visible: {
225
- type: Boolean
226
- },
227
- backgroundBlock: {
295
+ const fixedOverlayProps = {
296
+ modelValue: {
228
297
  type: Boolean,
229
298
  default: false
230
299
  },
231
- backgroundClass: {
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
- hasBackdrop: {
304
+ closeOnClickOverlay: {
246
305
  type: Boolean,
247
306
  default: true
248
307
  }
249
308
  };
250
- const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
251
- overlayStyle: {
252
- type: [String, Object],
253
- default: void 0
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
- const overlayEmits = ["update:visible", "backdropClick"];
257
- function useOverlayLogic(props, ctx) {
258
- const ns = useNamespace("overlay");
259
- const backgroundClass = computed(() => {
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
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
269
- if (props.backdropClose) {
270
- ctx.emit("update:visible", false);
332
+ ctx.emit("click", event);
333
+ if (props.closeOnClickOverlay) {
334
+ ctx.emit("update:modelValue", false);
271
335
  }
272
336
  };
273
- const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
274
- onMounted(() => {
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: overlayEmits,
355
+ emits: ["update:modelValue", "click"],
309
356
  setup(props, ctx) {
310
357
  const {
311
- backgroundClass,
312
- overlayClass,
313
- handleBackdropClick,
314
- handleOverlayBubbleCancel
315
- } = useOverlayLogic(props, ctx);
316
- return () => createVNode(CommonOverlay, null, {
317
- default: () => [props.visible && createVNode("div", {
318
- "class": backgroundClass.value,
319
- "style": props.backgroundStyle,
320
- "onClick": handleBackdropClick
321
- }, [createVNode("div", {
322
- "class": overlayClass.value,
323
- "style": props.overlayStyle,
324
- "onClick": handleOverlayBubbleCancel
325
- }, [renderSlot(ctx.slots, "default")])])]
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), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
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 handleVisibleChange(val) {
500
- if (!val) {
501
- props.beforeClose ? props.beforeClose(close) : close();
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
- return { handleVisibleChange };
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
- lockScroll,
550
- closeOnClickOverlay,
551
- title
707
+ title,
708
+ showClose,
709
+ showOverlay,
710
+ appendToBody,
711
+ closeOnClickOverlay
552
712
  } = toRefs(props);
553
713
  const {
554
- handleVisibleChange
714
+ execClose
555
715
  } = useModal(props, emit);
556
- expose({
557
- handleVisibleChange
558
- });
559
- return () => {
560
- const fixedOverlayProps2 = {
561
- visible: modelValue.value,
562
- "onUpdate:visible": handleVisibleChange,
563
- "background-class": ns.e("mask"),
564
- "background-block": lockScroll.value,
565
- "backdrop-close": closeOnClickOverlay.value
566
- };
567
- return createVNode(FixedOverlay, fixedOverlayProps2, {
568
- default: () => [createVNode(Transition, {
569
- "name": ns.m("wipe")
570
- }, {
571
- default: () => {
572
- var _a;
573
- return [createVNode("div", mergeProps({
574
- "class": ns.b()
575
- }, attrs), [createVNode(Icon, {
576
- "name": "close",
577
- "class": "btn-close",
578
- "size": "var(--devui-font-size-md,12px)",
579
- "onClick": () => handleVisibleChange(false)
580
- }, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
581
- default: () => [title.value]
582
- }), createVNode(Body, null, {
583
- default: () => {
584
- var _a2;
585
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
586
- }
587
- }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
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({