vue-devui 1.0.0-beta.16 → 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.
Files changed (190) hide show
  1. package/README.md +29 -21
  2. package/accordion/index.es.js +229 -14
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.es.js +28 -30
  6. package/alert/index.umd.js +1 -1
  7. package/alert/style.css +1 -1
  8. package/auto-complete/index.es.js +133 -271
  9. package/auto-complete/index.umd.js +1 -1
  10. package/auto-complete/style.css +1 -1
  11. package/back-top/index.es.js +5 -3
  12. package/back-top/index.umd.js +1 -1
  13. package/badge/index.es.js +13 -19
  14. package/badge/index.umd.js +1 -1
  15. package/badge/style.css +1 -1
  16. package/breadcrumb/index.es.js +2 -1
  17. package/button/index.es.js +95 -122
  18. package/button/index.umd.js +1 -1
  19. package/button/style.css +1 -1
  20. package/carousel/index.es.js +38 -53
  21. package/carousel/index.umd.js +1 -1
  22. package/cascader/index.es.js +5412 -784
  23. package/cascader/index.umd.js +27 -1
  24. package/cascader/style.css +1 -1
  25. package/checkbox/style.css +1 -1
  26. package/color-picker/index.es.js +5517 -281
  27. package/color-picker/index.umd.js +27 -1
  28. package/color-picker/style.css +1 -1
  29. package/countdown/index.es.js +9 -8
  30. package/date-picker/index.es.js +44 -62
  31. package/date-picker/index.umd.js +1 -1
  32. package/date-picker/style.css +1 -1
  33. package/drawer/index.es.js +159 -324
  34. package/drawer/index.umd.js +1 -1
  35. package/drawer/style.css +1 -1
  36. package/dropdown/index.es.js +459 -301
  37. package/dropdown/index.umd.js +1 -1
  38. package/dropdown/style.css +1 -1
  39. package/editable-select/index.es.js +293 -5724
  40. package/editable-select/index.umd.js +1 -27
  41. package/editable-select/style.css +1 -1
  42. package/form/index.es.js +6125 -535
  43. package/form/index.umd.js +27 -1
  44. package/form/style.css +1 -1
  45. package/fullscreen/index.es.js +112 -133
  46. package/fullscreen/index.umd.js +1 -1
  47. package/fullscreen/style.css +1 -1
  48. package/gantt/index.es.js +3 -15
  49. package/gantt/index.umd.js +1 -1
  50. package/gantt/style.css +1 -1
  51. package/grid/index.es.js +1 -1
  52. package/grid/style.css +1 -1
  53. package/icon/index.es.js +39 -57
  54. package/icon/index.umd.js +1 -1
  55. package/image-preview/index.es.js +2 -1
  56. package/input/index.es.js +4 -5
  57. package/input/index.umd.js +1 -1
  58. package/input/style.css +1 -1
  59. package/input-icon/index.es.js +42 -42
  60. package/input-icon/index.umd.js +1 -1
  61. package/input-icon/style.css +1 -1
  62. package/input-number/index.es.js +46 -57
  63. package/input-number/index.umd.js +1 -1
  64. package/input-number/style.css +1 -1
  65. package/{time-axis → list}/index.d.ts +0 -0
  66. package/list/index.es.js +39 -0
  67. package/list/index.umd.js +1 -0
  68. package/{toast → list}/package.json +1 -1
  69. package/list/style.css +1 -0
  70. package/loading/index.es.js +2 -2
  71. package/modal/index.es.js +300 -960
  72. package/modal/index.umd.js +1 -1
  73. package/modal/style.css +1 -1
  74. package/nav-sprite/index.es.js +1 -675
  75. package/nav-sprite/index.umd.js +1 -1
  76. package/{toast → notification}/index.d.ts +0 -0
  77. package/notification/index.es.js +284 -0
  78. package/notification/index.umd.js +1 -0
  79. package/notification/package.json +7 -0
  80. package/notification/style.css +1 -0
  81. package/nuxt/components/DropdownMenu.js +3 -0
  82. package/nuxt/components/IFileOptions.js +3 -0
  83. package/nuxt/components/IUploadOptions.js +3 -0
  84. package/nuxt/components/List.js +3 -0
  85. package/nuxt/components/ListItem.js +3 -0
  86. package/nuxt/components/Notification.js +3 -0
  87. package/nuxt/components/NotificationService.js +3 -0
  88. package/nuxt/components/PanelBody.js +3 -0
  89. package/nuxt/components/PanelFooter.js +3 -0
  90. package/nuxt/components/PanelHeader.js +3 -0
  91. package/nuxt/components/Timeline.js +3 -0
  92. package/nuxt/components/TimelineItem.js +3 -0
  93. package/nuxt/components/UploadStatus.js +3 -0
  94. package/nuxt/components/alertProps.js +3 -0
  95. package/nuxt/components/badgeProps.js +3 -0
  96. package/nuxt/components/dropdownMenuProps.js +3 -0
  97. package/nuxt/components/fixedOverlayProps.js +3 -0
  98. package/nuxt/components/flexibleOverlayProps.js +3 -0
  99. package/nuxt/components/fullscreenProps.js +3 -0
  100. package/nuxt/components/iconProps.js +2 -0
  101. package/nuxt/components/notificationProps.js +3 -0
  102. package/nuxt/components/overlayEmits.js +3 -0
  103. package/nuxt/components/overlayProps.js +3 -0
  104. package/nuxt/components/paginationProps.js +3 -0
  105. package/nuxt/components/panelProps.js +3 -0
  106. package/nuxt/components/popoverProps.js +3 -0
  107. package/nuxt/components/searchProps.js +3 -0
  108. package/nuxt/components/tooltipProps.js +3 -0
  109. package/nuxt/components/uploadProps.js +3 -0
  110. package/overlay/index.es.js +152 -198
  111. package/overlay/index.umd.js +1 -1
  112. package/overlay/style.css +1 -1
  113. package/package.json +12 -60
  114. package/pagination/index.es.js +11 -13
  115. package/pagination/index.umd.js +1 -1
  116. package/pagination/style.css +1 -1
  117. package/panel/index.es.js +48 -35
  118. package/panel/index.umd.js +1 -1
  119. package/popover/index.es.js +5954 -201
  120. package/popover/index.umd.js +27 -1
  121. package/popover/style.css +1 -1
  122. package/quadrant-diagram/index.es.js +5405 -166
  123. package/quadrant-diagram/index.umd.js +27 -1
  124. package/radio/style.css +1 -1
  125. package/read-tip/index.es.js +6 -3
  126. package/read-tip/style.css +1 -1
  127. package/result/index.es.js +38 -53
  128. package/result/index.umd.js +1 -1
  129. package/ripple/index.es.js +10 -6
  130. package/search/index.es.js +5428 -200
  131. package/search/index.umd.js +27 -1
  132. package/search/style.css +1 -1
  133. package/select/index.es.js +43 -43
  134. package/select/index.umd.js +1 -1
  135. package/select/style.css +1 -1
  136. package/skeleton/index.es.js +17 -17
  137. package/skeleton/index.umd.js +1 -1
  138. package/slider/index.es.js +2 -1
  139. package/splitter/index.es.js +5815 -99
  140. package/splitter/index.umd.js +27 -1
  141. package/splitter/style.css +1 -1
  142. package/status/index.es.js +1 -4
  143. package/status/index.umd.js +1 -1
  144. package/status/style.css +1 -1
  145. package/steps-guide/index.es.js +6 -3
  146. package/sticky/index.umd.js +1 -1
  147. package/style.css +1 -1
  148. package/table/index.es.js +548 -360
  149. package/table/index.umd.js +1 -1
  150. package/table/style.css +1 -1
  151. package/tabs/index.es.js +3 -4
  152. package/tabs/index.umd.js +1 -1
  153. package/tabs/style.css +1 -1
  154. package/tag/index.es.js +2 -1
  155. package/tag-input/index.es.js +4 -2
  156. package/textarea/style.css +1 -1
  157. package/{theme → theme/theme.scss} +0 -0
  158. package/time-picker/index.es.js +98 -123
  159. package/time-picker/index.umd.js +1 -1
  160. package/time-picker/style.css +1 -1
  161. package/timeline/index.d.ts +7 -0
  162. package/{time-axis → timeline}/index.es.js +65 -78
  163. package/timeline/index.umd.js +1 -0
  164. package/{time-axis → timeline}/package.json +1 -1
  165. package/timeline/style.css +1 -0
  166. package/tooltip/index.es.js +5804 -94
  167. package/tooltip/index.umd.js +27 -1
  168. package/tooltip/style.css +1 -1
  169. package/transfer/index.es.js +5896 -404
  170. package/transfer/index.umd.js +27 -1
  171. package/transfer/style.css +1 -1
  172. package/tree/index.es.js +5439 -814
  173. package/tree/index.umd.js +27 -1
  174. package/tree/style.css +1 -1
  175. package/tree-select/index.es.js +11 -7
  176. package/tree-select/style.css +1 -1
  177. package/upload/index.es.js +335 -2213
  178. package/upload/index.umd.js +1 -1
  179. package/upload/style.css +1 -1
  180. package/vue-devui.es.js +9709 -12248
  181. package/vue-devui.umd.js +20 -20
  182. package/nuxt/components/TimeAxis.js +0 -3
  183. package/nuxt/components/TimeAxisItem.js +0 -3
  184. package/nuxt/components/Toast.js +0 -3
  185. package/nuxt/components/ToastService.js +0 -3
  186. package/time-axis/index.umd.js +0 -1
  187. package/time-axis/style.css +0 -1
  188. package/toast/index.es.js +0 -2063
  189. package/toast/index.umd.js +0 -1
  190. 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, withDirectives, vShow, ref, reactive, toRef, isRef, h, render, readonly, mergeProps, resolveDirective } from "vue";
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
- width: {
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: true
41
+ default: false
68
42
  },
69
- backdropCloseable: {
70
- type: Boolean,
71
- default: true
43
+ title: {
44
+ type: String,
45
+ default: ""
72
46
  },
73
- bodyScrollable: {
47
+ lockScroll: {
74
48
  type: Boolean,
75
49
  default: true
76
50
  },
77
- escapeable: {
51
+ closeOnClickOverlay: {
78
52
  type: Boolean,
79
53
  default: true
80
54
  },
81
- onClose: {
55
+ beforeClose: {
82
56
  type: Function
57
+ }
58
+ };
59
+ const iconProps = {
60
+ name: {
61
+ type: String,
62
+ default: "",
63
+ required: true
83
64
  },
84
- beforeHidden: {
85
- type: [Object, Function]
65
+ size: {
66
+ type: String,
67
+ default: "inherit"
86
68
  },
87
- modelValue: {
88
- type: Boolean
69
+ color: {
70
+ type: String,
71
+ default: "inherit"
89
72
  },
90
- "onUpdate:modelValue": {
91
- type: Function
73
+ classPrefix: {
74
+ type: String,
75
+ default: "icon"
92
76
  }
93
77
  };
94
- var overlay = "";
95
- function _isSlot$1(s) {
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$1(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
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 flexibleOverlayProps = __spreadValues({
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: () => [withDirectives(createVNode("div", {
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")])]), [[vShow, props.visible]])]
231
+ }, [renderSlot(ctx.slots, "default")])])]
234
232
  });
235
233
  }
236
234
  });
237
- function isComponent(target) {
238
- return !!(target == null ? void 0 : target.$el);
239
- }
240
- function getElement(element) {
241
- if (element instanceof Element) {
242
- return element;
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
- if (element && typeof element === "object" && element.$el instanceof Element) {
245
- return element.$el;
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 null;
273
+ return window;
248
274
  }
249
- const FlexibleOverlay = defineComponent({
250
- name: "DFlexibleOverlay",
251
- props: flexibleOverlayProps,
252
- emits: overlayEmits,
253
- setup(props, ctx) {
254
- const overlayRef = ref(null);
255
- const positionedStyle = reactive({
256
- position: "absolute"
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
- onMounted(async () => {
259
- const handleRectChange = (position, rect, origin) => {
260
- const point = calculatePosition(position, rect, origin);
261
- positionedStyle.left = `${point.x}px`;
262
- positionedStyle.top = `${point.y}px`;
263
- };
264
- const locationElements = computed(() => {
265
- const overlay2 = overlayRef.value;
266
- const origin = getOrigin(props.origin);
267
- if (!overlay2 || !origin) {
268
- return;
269
- }
270
- return {
271
- origin,
272
- overlay: overlay2
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
- backgroundClass,
294
- overlayClass,
295
- handleBackdropClick,
296
- handleOverlayBubbleCancel
297
- } = useOverlayLogic(props, ctx);
298
- return () => createVNode(CommonOverlay, null, {
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
- function getOrigin(origin) {
313
- if (origin instanceof Element) {
314
- return origin;
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
- let y;
376
- if (position.originY == "center") {
377
- y = originRect.top + originRect.height / 2;
378
- } else {
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
- };
385
- }
386
- function subscribeLayoutEvent(event) {
387
- window.addEventListener("scroll", event, true);
388
- window.addEventListener("resize", event);
389
- window.addEventListener("orientationchange", event);
390
- return () => {
391
- window.removeEventListener("scroll", event, true);
392
- window.removeEventListener("resize", event);
393
- window.removeEventListener("orientationchange", event);
394
- };
397
+ return { handleVisibleChange };
395
398
  }
396
- function subscribeOverlayResize(overlay2, callback) {
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
- return () => {
403
- };
404
- }
405
- function subscribeOriginResize(origin, callback) {
406
- if (origin instanceof Element) {
407
- const observer = new MutationObserver(callback);
408
- observer.observe(origin, {
409
- attributeFilter: ["style"]
410
- });
411
- return () => observer.disconnect();
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
- return () => {
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: ["onUpdate:modelValue"],
428
- setup(props, ctx) {
429
- const animatedVisible = computed(() => {
430
- return props.showAnimation ? props.modelValue : true;
431
- });
432
- const onVisibleChange = (value) => {
433
- var _a;
434
- const update = props["onUpdate:modelValue"];
435
- if (value) {
436
- update == null ? void 0 : update(value);
437
- } else {
438
- const beforeHidden = props.beforeHidden;
439
- const close = (enabledClose) => {
440
- var _a2;
441
- if (enabledClose) {
442
- update == null ? void 0 : update(false);
443
- (_a2 = props.onClose) == null ? void 0 : _a2.call(props);
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": props.modelValue,
459
- "onUpdate:visible": onVisibleChange,
460
- "backgroundClass": "devui-modal-wrapper",
461
- "backgroundBlock": !props.bodyScrollable,
462
- "backdropClose": props.backdropCloseable
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, _b;
469
- return [animatedVisible.value ? (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a) : null];
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
- const vnode = renderOrigin(resProps, (value) => {
531
+ renderOrigin(resProps, (value) => {
512
532
  if (!value) {
513
533
  this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
514
534
  this.renderNull(anchor);
@@ -516,702 +536,23 @@ class ModalService extends CommonModalService {
516
536
  renderOrigin(resProps);
517
537
  }
518
538
  });
519
- (_b = (_a2 = vnode.component.exposed).onVisibleChange) == null ? void 0 : _b.call(_a2, false);
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 = 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
- type: {
925
- type: String,
926
- default: "button"
927
- },
928
- variant: {
929
- type: String,
930
- default: "primary"
931
- },
932
- size: {
933
- type: String,
934
- default: "md"
935
- },
936
- position: {
937
- type: String,
938
- default: "default"
939
- },
940
- bordered: {
941
- type: Boolean,
942
- default: false
943
- },
944
- icon: {
945
- type: String,
946
- default: ""
947
- },
948
- showLoading: {
949
- type: Boolean,
950
- default: false
951
- },
952
- width: {
953
- type: String
954
- },
955
- disabled: {
956
- type: Boolean,
957
- default: false
958
- },
959
- autofocus: {
960
- type: Boolean,
961
- default: false
962
- },
963
- onClick: {
964
- type: Function
965
- }
966
- };
967
- var button = "";
968
- var Button = defineComponent({
969
- name: "DButton",
970
- directives: {
971
- devLoading: loadingDirective
972
- },
973
- props: buttonProps,
974
- setup(props, ctx) {
975
- const buttonContent = ref(null);
976
- const onClick = (e) => {
977
- var _a;
978
- if (props.showLoading) {
979
- return;
980
- }
981
- (_a = props.onClick) == null ? void 0 : _a.call(props, e);
982
- };
983
- const hasContent = computed(() => ctx.slots.default);
984
- const btnClass = computed(() => {
985
- const {
986
- variant,
987
- size,
988
- position,
989
- bordered,
990
- icon
991
- } = props;
992
- const origin = `devui-btn devui-btn-${variant} devui-btn-${size} devui-btn-${position}`;
993
- const borderedClass = bordered ? "bordered" : "";
994
- const btnIcon = !!icon && !hasContent.value && variant !== "primary" ? "d-btn-icon" : "";
995
- const btnIconWrap = !!icon ? "d-btn-icon-wrap" : "";
996
- return `${origin} ${borderedClass} ${btnIcon} ${btnIconWrap}`;
997
- });
998
- const iconClass = computed(() => {
999
- if (!props.icon) {
1000
- return;
1001
- }
1002
- const origin = "devui-icon-fix icon";
1003
- if (hasContent.value) {
1004
- return `${origin} clear-right-5`;
1005
- } else {
1006
- return origin;
1007
- }
1008
- });
1009
- return () => {
1010
- var _a, _b;
1011
- const {
1012
- icon,
1013
- type,
1014
- disabled,
1015
- showLoading,
1016
- width
1017
- } = props;
1018
- return createVNode("div", mergeProps({
1019
- "class": "devui-btn-host"
1020
- }, ctx.attrs), [withDirectives(createVNode("button", {
1021
- "class": btnClass.value,
1022
- "type": type,
1023
- "disabled": disabled,
1024
- "style": {
1025
- width
1026
- },
1027
- "onClick": onClick
1028
- }, [!!icon ? createVNode(Icon, {
1029
- "name": icon,
1030
- "class": iconClass.value
1031
- }, null) : null, createVNode("span", {
1032
- "class": "button-content",
1033
- "ref": buttonContent
1034
- }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])]), [[resolveDirective("devLoading"), showLoading]])]);
1035
- };
1036
- }
1037
- });
1038
- defineComponent(Loading);
1039
- Button.install = function(app) {
1040
- app.directive("dLoading", loadingDirective);
1041
- app.component(Button.name, Button);
1042
- };
1043
- function _isSlot(s) {
1044
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
1045
- }
1046
- var Dialog = defineComponent({
1047
- name: "DModal",
1048
- inheritAttrs: false,
1049
- props: dialogProps,
1050
- emits: ["onUpdate:modelValue"],
1051
- setup(props, ctx) {
1052
- const {
1053
- movingX,
1054
- movingY,
1055
- handleRef,
1056
- moveElRef,
1057
- reset
1058
- } = useMoveable();
1059
- watch(() => props.modelValue, (value) => {
1060
- if (value) {
1061
- reset();
1062
- }
1063
- });
1064
- const movingStyle = computed(() => ({
1065
- position: "relative",
1066
- left: `${movingX.value}px`,
1067
- top: `${movingY.value}px`
1068
- }));
1069
- const containerStyle = computed(() => ({
1070
- width: props.width,
1071
- maxHeight: props.maxHeight,
1072
- transform: `translate(${props.offsetX}, ${props.offsetY})`,
1073
- zIndex: props.zIndex
1074
- }));
1075
- const iconName = computed(() => {
1076
- switch (props.dialogType) {
1077
- case "standard":
1078
- return "";
1079
- case "info":
1080
- return "icon-info-o";
1081
- case "success":
1082
- return "icon-right-o";
1083
- case "warning":
1084
- return "icon-warning-o";
1085
- case "failed":
1086
- return "icon-error-o";
1087
- default:
1088
- return "";
1089
- }
1090
- });
1091
- const buttonsRef = computed(() => {
1092
- return props.buttons.map((buttonProps2, index2) => {
1093
- const {
1094
- variant,
1095
- disabled,
1096
- handler,
1097
- text
1098
- } = buttonProps2;
1099
- return createVNode(Button, {
1100
- "key": index2,
1101
- "style": {
1102
- display: "inline-block",
1103
- margin: "0 5px"
1104
- },
1105
- "variant": variant,
1106
- "disabled": disabled,
1107
- "onClick": handler
1108
- }, _isSlot(text) ? text : {
1109
- default: () => [text]
1110
- });
1111
- });
1112
- });
1113
- const modalRef = ref();
1114
- const closeModal = () => {
1115
- var _a, _b;
1116
- (_b = (_a = modalRef.value) == null ? void 0 : _a.onVisibleChange) == null ? void 0 : _b.call(_a, false);
1117
- };
1118
- ctx.expose({
1119
- closeModal
1120
- });
1121
- return () => createVNode(Modal, {
1122
- "ref": modalRef,
1123
- "width": props.width,
1124
- "maxHeight": props.maxHeight,
1125
- "offsetX": props.offsetX,
1126
- "offsetY": props.offsetY,
1127
- "zIndex": props.zIndex,
1128
- "backdropZIndex": props.backdropZIndex,
1129
- "backdropCloseable": props.backdropCloseable,
1130
- "bodyScrollable": props.bodyScrollable,
1131
- "placement": props.placement,
1132
- "onClose": props.onClose,
1133
- "beforeHidden": props.beforeHidden,
1134
- "modelValue": props.modelValue,
1135
- "onUpdate:modelValue": props["onUpdate:modelValue"]
1136
- }, {
1137
- default: () => {
1138
- var _a, _b;
1139
- return [createVNode("div", {
1140
- "class": "devui-modal-content",
1141
- "style": [containerStyle.value, movingStyle.value],
1142
- "ref": moveElRef
1143
- }, [createVNode("div", {
1144
- "class": "devui-modal-header",
1145
- "ref": handleRef
1146
- }, [!!iconName.value ? createVNode(Icon, {
1147
- "name": iconName.value,
1148
- "size": "24px",
1149
- "class": "header-alert-icon"
1150
- }, null) : null, createVNode("span", null, [props.title]), createVNode(Button, {
1151
- "class": "btn-close",
1152
- "icon": "close",
1153
- "variant": "text-dark",
1154
- "onClick": closeModal
1155
- }, null)]), createVNode("div", {
1156
- "class": "devui-modal-body"
1157
- }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createVNode("div", {
1158
- "class": "devui-modal-footer"
1159
- }, [buttonsRef.value])])];
1160
- }
1161
- });
1162
- }
1163
- });
1164
- class DialogService extends CommonModalService {
1165
- component() {
1166
- return Dialog;
1167
- }
1168
- open(props = {}) {
1169
- const anchor = document.createElement("div");
1170
- this.anchorContainer.appendChild(anchor);
1171
- const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
1172
- const needHideOrNot = (value) => {
1173
- if (!value) {
1174
- hide();
1175
- }
1176
- };
1177
- const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
1178
- return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
1179
- modelValue: true,
1180
- "onUpdate:modelValue": onUpdateModelValue
1181
- }), { default: content });
1182
- };
1183
- const hide = () => {
1184
- var _a2, _b;
1185
- const vnode = renderOrigin(resProps, (value) => {
1186
- if (!value) {
1187
- this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
1188
- this.renderNull(anchor);
1189
- } else {
1190
- renderOrigin(resProps);
1191
- }
1192
- });
1193
- (_b = (_a2 = vnode.component.exposed).closeModal) == null ? void 0 : _b.call(_a2);
1194
- };
1195
- const updateButtonOptions = (buttonOptions) => {
1196
- const _a2 = resProps, { buttons } = _a2, innerResProps = __objRest(_a2, ["buttons"]);
1197
- const newButtonOptions = buttons.map((option, index2) => __spreadValues(__spreadValues({}, option), buttonOptions[index2]));
1198
- renderOrigin(__spreadProps(__spreadValues({}, innerResProps), { buttons: newButtonOptions }));
1199
- };
1200
- this.renderModal(anchor, { modelValue: false });
1201
- renderOrigin(resProps);
1202
- return { hide, updateButtonOptions };
1203
- }
1204
- }
1205
- __publicField(DialogService, "token", "DIALOG_SERVICE_TOKEN");
1206
- Modal.install = function(app) {
1207
- app.component(Modal.name, Modal);
1208
- };
1209
547
  var index = {
1210
548
  title: "Modal \u5F39\u7A97",
1211
549
  category: "\u53CD\u9988",
1212
550
  status: "100%",
1213
551
  install(app) {
1214
- app.use(Modal);
552
+ app.component(Modal.name, Modal);
553
+ app.component(Header.name, Header);
554
+ app.component(Body.name, Body);
555
+ app.component(Footer.name, Footer);
1215
556
  if (!inBrowser) {
1216
557
  return;
1217
558
  }
@@ -1222,7 +563,6 @@ var index = {
1222
563
  document.body.appendChild(anchorsContainer);
1223
564
  }
1224
565
  app.provide(ModalService.token, new ModalService(anchorsContainer));
1225
- app.provide(DialogService.token, new DialogService(anchorsContainer));
1226
566
  }
1227
567
  };
1228
568
  export { Modal, index as default };