vue-devui 1.0.0-beta.8 → 1.0.0-rc.0

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 (278) hide show
  1. package/README.md +81 -66
  2. package/accordion/index.es.js +522 -39
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.es.js +6 -7
  6. package/alert/index.umd.js +1 -1
  7. package/alert/style.css +1 -1
  8. package/{toast → auto-complete}/index.d.ts +0 -0
  9. package/auto-complete/index.es.js +976 -0
  10. package/auto-complete/index.umd.js +1 -0
  11. package/auto-complete/package.json +7 -0
  12. package/auto-complete/style.css +1 -0
  13. package/back-top/index.es.js +1 -1
  14. package/back-top/index.umd.js +1 -1
  15. package/badge/index.es.js +12 -18
  16. package/badge/index.umd.js +1 -1
  17. package/button/index.es.js +262 -82
  18. package/button/index.umd.js +1 -1
  19. package/button/style.css +1 -1
  20. package/carousel/index.es.js +7 -6
  21. package/carousel/index.umd.js +1 -1
  22. package/cascader/index.es.js +5392 -772
  23. package/cascader/index.umd.js +27 -1
  24. package/checkbox/style.css +1 -1
  25. package/color-picker/index.d.ts +7 -0
  26. package/color-picker/index.es.js +8187 -0
  27. package/color-picker/index.umd.js +27 -0
  28. package/color-picker/package.json +7 -0
  29. package/color-picker/style.css +1 -0
  30. package/comment/index.es.js +42 -13
  31. package/comment/index.umd.js +1 -1
  32. package/comment/style.css +1 -1
  33. package/countdown/index.es.js +27 -18
  34. package/countdown/index.umd.js +1 -1
  35. package/countdown/style.css +1 -1
  36. package/date-picker/index.es.js +10 -11
  37. package/date-picker/index.umd.js +1 -1
  38. package/date-picker/style.css +1 -1
  39. package/dragdrop/index.es.js +135 -10
  40. package/dragdrop/index.umd.js +1 -1
  41. package/drawer/index.es.js +169 -223
  42. package/drawer/index.umd.js +1 -1
  43. package/drawer/style.css +1 -1
  44. package/dropdown/index.es.js +408 -300
  45. package/dropdown/index.umd.js +1 -1
  46. package/dropdown/style.css +1 -1
  47. package/editable-select/index.es.js +275 -5610
  48. package/editable-select/index.umd.js +1 -27
  49. package/editable-select/style.css +1 -1
  50. package/form/index.es.js +6129 -461
  51. package/form/index.umd.js +27 -1
  52. package/form/style.css +1 -1
  53. package/fullscreen/index.es.js +110 -118
  54. package/fullscreen/index.umd.js +1 -1
  55. package/fullscreen/style.css +1 -1
  56. package/gantt/index.es.js +6 -18
  57. package/gantt/index.umd.js +1 -1
  58. package/gantt/style.css +1 -1
  59. package/grid/index.es.js +1 -1
  60. package/grid/style.css +1 -1
  61. package/icon/index.es.js +2 -1
  62. package/icon/index.umd.js +1 -1
  63. package/image-preview/index.es.js +77 -19
  64. package/image-preview/index.umd.js +1 -1
  65. package/image-preview/style.css +1 -1
  66. package/input/index.es.js +4 -5
  67. package/input/index.umd.js +1 -1
  68. package/input/style.css +1 -1
  69. package/input-icon/index.es.js +6 -6
  70. package/input-icon/index.umd.js +1 -1
  71. package/input-icon/style.css +1 -1
  72. package/input-number/index.es.js +2 -1
  73. package/input-number/index.umd.js +1 -1
  74. package/list/index.d.ts +7 -0
  75. package/list/index.es.js +39 -0
  76. package/list/index.umd.js +1 -0
  77. package/{toast → list}/package.json +1 -1
  78. package/list/style.css +1 -0
  79. package/loading/index.es.js +2 -2
  80. package/modal/index.es.js +293 -759
  81. package/modal/index.umd.js +1 -1
  82. package/modal/style.css +1 -1
  83. package/nav-sprite/index.es.js +1 -675
  84. package/nav-sprite/index.umd.js +1 -1
  85. package/notification/index.d.ts +7 -0
  86. package/notification/index.es.js +286 -0
  87. package/notification/index.umd.js +1 -0
  88. package/notification/package.json +7 -0
  89. package/notification/style.css +1 -0
  90. package/nuxt/components/Accordion.js +3 -0
  91. package/nuxt/components/Alert.js +3 -0
  92. package/nuxt/components/Anchor.js +3 -0
  93. package/nuxt/components/Aside.js +3 -0
  94. package/nuxt/components/AutoComplete.js +3 -0
  95. package/nuxt/components/Avatar.js +3 -0
  96. package/nuxt/components/BackTop.js +3 -0
  97. package/nuxt/components/Badge.js +3 -0
  98. package/nuxt/components/Breadcrumb.js +3 -0
  99. package/nuxt/components/Button.js +3 -0
  100. package/nuxt/components/Card.js +3 -0
  101. package/nuxt/components/Carousel.js +3 -0
  102. package/nuxt/components/CarouselItem.js +3 -0
  103. package/nuxt/components/Cascader.js +3 -0
  104. package/nuxt/components/Checkbox.js +3 -0
  105. package/nuxt/components/Col.js +3 -0
  106. package/nuxt/components/ColorPicker.js +3 -0
  107. package/nuxt/components/Column.js +3 -0
  108. package/nuxt/components/Comment.js +3 -0
  109. package/nuxt/components/Content.js +3 -0
  110. package/nuxt/components/Countdown.js +3 -0
  111. package/nuxt/components/DatePicker.js +3 -0
  112. package/nuxt/components/Drawer.js +3 -0
  113. package/nuxt/components/DrawerService.js +3 -0
  114. package/nuxt/components/Dropdown.js +3 -0
  115. package/nuxt/components/DropdownMenu.js +3 -0
  116. package/nuxt/components/EditableSelect.js +3 -0
  117. package/nuxt/components/FixedOverlay.js +3 -0
  118. package/nuxt/components/FlexibleOverlay.js +3 -0
  119. package/nuxt/components/Footer.js +3 -0
  120. package/nuxt/components/Form.js +3 -0
  121. package/nuxt/components/FormControl.js +3 -0
  122. package/nuxt/components/FormItem.js +3 -0
  123. package/nuxt/components/FormLabel.js +3 -0
  124. package/nuxt/components/FormOperation.js +3 -0
  125. package/nuxt/components/Fullscreen.js +3 -0
  126. package/nuxt/components/Gantt.js +3 -0
  127. package/nuxt/components/Header.js +3 -0
  128. package/nuxt/components/IFileOptions.js +3 -0
  129. package/nuxt/components/IUploadOptions.js +3 -0
  130. package/nuxt/components/Icon.js +2 -0
  131. package/nuxt/components/ImagePreviewService.js +3 -0
  132. package/nuxt/components/Input.js +3 -0
  133. package/nuxt/components/InputIcon.js +3 -0
  134. package/nuxt/components/InputNumber.js +3 -0
  135. package/nuxt/components/Layout.js +3 -0
  136. package/nuxt/components/List.js +3 -0
  137. package/nuxt/components/ListItem.js +3 -0
  138. package/nuxt/components/Loading.js +3 -0
  139. package/nuxt/components/LoadingService.js +3 -0
  140. package/nuxt/components/Modal.js +3 -0
  141. package/nuxt/components/NavSprite.js +2 -0
  142. package/nuxt/components/Notification.js +3 -0
  143. package/nuxt/components/NotificationService.js +3 -0
  144. package/nuxt/components/Pagination.js +3 -0
  145. package/nuxt/components/Panel.js +3 -0
  146. package/nuxt/components/Popover.js +3 -0
  147. package/nuxt/components/Progress.js +3 -0
  148. package/nuxt/components/QuadrantDiagram.js +3 -0
  149. package/nuxt/components/Radio.js +3 -0
  150. package/nuxt/components/RadioGroup.js +3 -0
  151. package/nuxt/components/Rate.js +3 -0
  152. package/nuxt/components/ReadTip.js +3 -0
  153. package/nuxt/components/Result.js +3 -0
  154. package/nuxt/components/Row.js +3 -0
  155. package/nuxt/components/Search.js +3 -0
  156. package/nuxt/components/Select.js +3 -0
  157. package/nuxt/components/Skeleton.js +3 -0
  158. package/nuxt/components/SkeletonItem.js +3 -0
  159. package/nuxt/components/Slider.js +3 -0
  160. package/nuxt/components/Splitter.js +3 -0
  161. package/nuxt/components/Statistic.js +3 -0
  162. package/nuxt/components/Status.js +3 -0
  163. package/nuxt/components/StepsGuide.js +3 -0
  164. package/nuxt/components/StickSlider.js +3 -0
  165. package/nuxt/components/Sticky.js +2 -0
  166. package/nuxt/components/Switch.js +3 -0
  167. package/nuxt/components/Table.js +3 -0
  168. package/nuxt/components/Tabs.js +3 -0
  169. package/nuxt/components/Tag.js +3 -0
  170. package/nuxt/components/TagInput.js +3 -0
  171. package/nuxt/components/Textarea.js +3 -0
  172. package/nuxt/components/TimeAxis.js +3 -0
  173. package/nuxt/components/TimeAxisItem.js +3 -0
  174. package/nuxt/components/TimePicker.js +3 -0
  175. package/nuxt/components/Tooltip.js +3 -0
  176. package/nuxt/components/Transfer.js +3 -0
  177. package/nuxt/components/Tree.js +3 -0
  178. package/nuxt/components/TreeSelect.js +3 -0
  179. package/nuxt/components/Upload.js +3 -0
  180. package/nuxt/components/UploadStatus.js +3 -0
  181. package/nuxt/components/badgeProps.js +3 -0
  182. package/nuxt/components/buttonProps.js +3 -0
  183. package/nuxt/components/dropdownMenuProps.js +3 -0
  184. package/nuxt/components/fixedOverlayProps.js +3 -0
  185. package/nuxt/components/flexibleOverlayProps.js +3 -0
  186. package/nuxt/components/notificationProps.js +3 -0
  187. package/nuxt/components/overlayEmits.js +3 -0
  188. package/nuxt/components/overlayProps.js +3 -0
  189. package/nuxt/components/popoverProps.js +3 -0
  190. package/nuxt/components/tooltipProps.js +3 -0
  191. package/nuxt/components/uploadProps.js +3 -0
  192. package/nuxt/index.js +13 -0
  193. package/overlay/index.es.js +142 -198
  194. package/overlay/index.umd.js +1 -1
  195. package/overlay/style.css +1 -1
  196. package/package.json +10 -18
  197. package/pagination/index.es.js +1 -1
  198. package/pagination/style.css +1 -1
  199. package/panel/index.es.js +3 -3
  200. package/panel/index.umd.js +1 -1
  201. package/popover/index.es.js +5947 -189
  202. package/popover/index.umd.js +27 -1
  203. package/popover/style.css +1 -1
  204. package/progress/index.es.js +8 -8
  205. package/progress/index.umd.js +3 -3
  206. package/quadrant-diagram/index.es.js +5405 -166
  207. package/quadrant-diagram/index.umd.js +27 -1
  208. package/radio/index.es.js +5 -5
  209. package/radio/index.umd.js +1 -1
  210. package/radio/style.css +1 -1
  211. package/read-tip/index.es.js +17 -4
  212. package/read-tip/index.umd.js +1 -1
  213. package/read-tip/style.css +1 -1
  214. package/result/index.es.js +2 -1
  215. package/result/index.umd.js +1 -1
  216. package/ripple/index.es.js +1 -1
  217. package/search/index.es.js +5432 -198
  218. package/search/index.umd.js +27 -1
  219. package/search/style.css +1 -1
  220. package/select/index.es.js +3 -2
  221. package/select/index.umd.js +1 -1
  222. package/select/style.css +1 -1
  223. package/slider/index.es.js +2 -5
  224. package/slider/index.umd.js +1 -1
  225. package/slider/style.css +1 -1
  226. package/splitter/index.es.js +5881 -36
  227. package/splitter/index.umd.js +27 -1
  228. package/splitter/style.css +1 -1
  229. package/statistic/index.d.ts +7 -0
  230. package/statistic/index.es.js +267 -0
  231. package/statistic/index.umd.js +1 -0
  232. package/statistic/package.json +7 -0
  233. package/statistic/style.css +1 -0
  234. package/status/index.es.js +1 -1
  235. package/status/index.umd.js +1 -1
  236. package/status/style.css +1 -1
  237. package/steps-guide/index.es.js +8 -6
  238. package/steps-guide/index.umd.js +1 -1
  239. package/sticky/index.umd.js +1 -1
  240. package/style.css +1 -1
  241. package/table/index.es.js +698 -358
  242. package/table/index.umd.js +1 -1
  243. package/table/style.css +1 -1
  244. package/tabs/index.es.js +3 -4
  245. package/tabs/index.umd.js +1 -1
  246. package/tabs/style.css +1 -1
  247. package/tag/index.es.js +2 -2
  248. package/tag/index.umd.js +1 -1
  249. package/tag/style.css +1 -1
  250. package/tag-input/index.es.js +0 -12
  251. package/tag-input/index.umd.js +1 -1
  252. package/textarea/style.css +1 -1
  253. package/{theme → theme/theme.scss} +0 -0
  254. package/time-axis/index.es.js +2 -1
  255. package/time-axis/index.umd.js +1 -1
  256. package/time-picker/index.es.js +269 -84
  257. package/time-picker/index.umd.js +1 -1
  258. package/time-picker/style.css +1 -1
  259. package/tooltip/index.es.js +5798 -141
  260. package/tooltip/index.umd.js +27 -1
  261. package/tooltip/style.css +1 -1
  262. package/transfer/index.es.js +6522 -635
  263. package/transfer/index.umd.js +27 -1
  264. package/transfer/style.css +1 -1
  265. package/tree/index.es.js +5775 -192
  266. package/tree/index.umd.js +27 -1
  267. package/tree/style.css +1 -1
  268. package/tree-select/index.es.js +130 -35
  269. package/tree-select/index.umd.js +1 -1
  270. package/tree-select/style.css +1 -1
  271. package/upload/index.es.js +463 -2680
  272. package/upload/index.umd.js +1 -1
  273. package/upload/style.css +1 -1
  274. package/vue-devui.es.js +14630 -14010
  275. package/vue-devui.umd.js +18 -18
  276. package/toast/index.es.js +0 -2059
  277. package/toast/index.umd.js +0 -1
  278. package/toast/style.css +0 -1
package/modal/index.es.js CHANGED
@@ -33,66 +33,80 @@ 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 } from "vue";
36
+ import { defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, ref, nextTick, unref, mergeProps, toRefs, h, render } from "vue";
37
+ import { 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: {
66
- type: Boolean,
67
- default: true
68
- },
69
- backdropCloseable: {
39
+ modelValue: {
70
40
  type: Boolean,
71
41
  default: false
72
42
  },
73
- bodyScrollable: {
43
+ title: {
44
+ type: String,
45
+ default: ""
46
+ },
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
+ var Icon = defineComponent({
60
+ name: "DIcon",
61
+ props: {
62
+ name: {
63
+ type: String,
64
+ required: true
65
+ },
66
+ size: {
67
+ type: String,
68
+ default: "inherit"
69
+ },
70
+ color: {
71
+ type: String,
72
+ default: "inherit"
73
+ },
74
+ classPrefix: {
75
+ type: String,
76
+ default: "icon"
77
+ }
83
78
  },
84
- beforeHidden: {
85
- type: [Object, Function]
86
- },
87
- modelValue: {
88
- type: Boolean
79
+ setup(props) {
80
+ return __spreadValues({}, props);
89
81
  },
90
- "onUpdate:modelValue": {
91
- type: Function
82
+ render() {
83
+ const {
84
+ name,
85
+ size,
86
+ color,
87
+ classPrefix
88
+ } = this;
89
+ return /^((https?):)?\/\//.test(name) ? createVNode("img", {
90
+ "src": name,
91
+ "alt": name.split("/")[name.split("/").length - 1],
92
+ "style": {
93
+ width: size,
94
+ verticalAlign: "text-bottom"
95
+ }
96
+ }, null) : createVNode("i", {
97
+ "class": `${classPrefix} ${classPrefix}-${name}`,
98
+ "style": {
99
+ fontSize: size,
100
+ color
101
+ }
102
+ }, null);
92
103
  }
104
+ });
105
+ Icon.install = function(app) {
106
+ app.component(Icon.name, Icon);
93
107
  };
94
108
  var overlay = "";
95
- function _isSlot$1(s) {
109
+ function _isSlot(s) {
96
110
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
97
111
  }
98
112
  const CommonOverlay = defineComponent({
@@ -104,7 +118,7 @@ const CommonOverlay = defineComponent({
104
118
  }, {
105
119
  default: () => [createVNode(Transition, {
106
120
  "name": "devui-overlay-fade"
107
- }, _isSlot$1(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
121
+ }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
108
122
  default: () => [_slot]
109
123
  })]
110
124
  });
@@ -115,9 +129,6 @@ const overlayProps = {
115
129
  visible: {
116
130
  type: Boolean
117
131
  },
118
- "onUpdate:visible": {
119
- type: Function
120
- },
121
132
  backgroundBlock: {
122
133
  type: Boolean,
123
134
  default: false
@@ -141,29 +152,44 @@ const overlayProps = {
141
152
  default: true
142
153
  }
143
154
  };
144
- const overlayEmits = ["onUpdate:visible", "backdropClick"];
155
+ const overlayEmits = ["update:visible", "backdropClick"];
145
156
  const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
146
157
  overlayStyle: {
147
158
  type: [String, Object],
148
159
  default: void 0
149
160
  }
150
161
  });
151
- const flexibleOverlayProps = __spreadValues({
162
+ const flexibleOverlayProps = {
163
+ modelValue: {
164
+ type: Boolean,
165
+ default: false
166
+ },
152
167
  origin: {
153
168
  type: Object,
154
169
  require: true
155
170
  },
156
171
  position: {
157
- type: Object,
158
- default: () => ({
159
- originX: "left",
160
- originY: "top",
161
- overlayX: "left",
162
- overlayY: "top"
163
- })
172
+ type: Array,
173
+ default: ["bottom"]
174
+ },
175
+ offset: {
176
+ type: [Number, Object],
177
+ default: 8
178
+ },
179
+ align: {
180
+ type: String,
181
+ default: null
182
+ },
183
+ showArrow: {
184
+ type: Boolean,
185
+ default: false
186
+ },
187
+ isArrowCenter: {
188
+ type: Boolean,
189
+ default: true
164
190
  }
165
- }, overlayProps);
166
- function useOverlayLogic(props) {
191
+ };
192
+ function useOverlayLogic(props, ctx) {
167
193
  const backgroundClass = computed(() => {
168
194
  return [
169
195
  "devui-overlay-background",
@@ -175,11 +201,11 @@ function useOverlayLogic(props) {
175
201
  return "devui-overlay";
176
202
  });
177
203
  const handleBackdropClick = (event) => {
178
- var _a, _b;
204
+ var _a;
179
205
  event.preventDefault();
180
206
  (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
181
207
  if (props.backdropClose) {
182
- (_b = props["onUpdate:visible"]) == null ? void 0 : _b.call(props, false);
208
+ ctx.emit("update:visible", false);
183
209
  }
184
210
  };
185
211
  const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
@@ -223,9 +249,9 @@ const FixedOverlay = defineComponent({
223
249
  overlayClass,
224
250
  handleBackdropClick,
225
251
  handleOverlayBubbleCancel
226
- } = useOverlayLogic(props);
252
+ } = useOverlayLogic(props, ctx);
227
253
  return () => createVNode(CommonOverlay, null, {
228
- default: () => [withDirectives(createVNode("div", {
254
+ default: () => [props.visible && createVNode("div", {
229
255
  "class": backgroundClass.value,
230
256
  "style": props.backgroundStyle,
231
257
  "onClick": handleBackdropClick
@@ -233,248 +259,233 @@ const FixedOverlay = defineComponent({
233
259
  "class": overlayClass.value,
234
260
  "style": props.overlayStyle,
235
261
  "onClick": handleOverlayBubbleCancel
236
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
262
+ }, [renderSlot(ctx.slots, "default")])])]
237
263
  });
238
264
  }
239
265
  });
240
- function isComponent(target) {
241
- return !!(target == null ? void 0 : target.$el);
242
- }
243
- function getElement(element) {
244
- if (element instanceof Element) {
245
- return element;
266
+ function getScrollParent(element) {
267
+ const overflowRegex = /(auto|scroll|hidden)/;
268
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
269
+ const style = window.getComputedStyle(parent);
270
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
271
+ return parent;
272
+ }
246
273
  }
247
- if (element && typeof element === "object" && element.$el instanceof Element) {
248
- return element.$el;
274
+ return window;
275
+ }
276
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
277
+ let { x, y } = point;
278
+ if (!isArrowCenter) {
279
+ const { width, height } = originRect;
280
+ if (x && placement.includes("start")) {
281
+ x = 12;
282
+ }
283
+ if (x && placement.includes("end")) {
284
+ x = Math.round(width - 24);
285
+ }
286
+ if (y && placement.includes("start")) {
287
+ y = 10;
288
+ }
289
+ if (y && placement.includes("end")) {
290
+ y = height - 14;
291
+ }
249
292
  }
250
- return null;
293
+ return { x, y };
251
294
  }
252
- const FlexibleOverlay = defineComponent({
253
- name: "DFlexibleOverlay",
254
- props: flexibleOverlayProps,
255
- emits: overlayEmits,
256
- setup(props, ctx) {
257
- const overlayRef = ref(null);
258
- const positionedStyle = reactive({
259
- position: "absolute"
295
+ function useOverlay(props, emit) {
296
+ const overlayRef = ref();
297
+ const arrowRef = ref();
298
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
299
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
300
+ const staticSide = {
301
+ top: "bottom",
302
+ right: "left",
303
+ bottom: "top",
304
+ left: "right"
305
+ }[placement.split("-")[0]];
306
+ Object.assign(arrowEl.style, {
307
+ left: x ? `${x}px` : "",
308
+ top: y ? `${y}px` : "",
309
+ right: "",
310
+ bottom: "",
311
+ [staticSide]: "-4px"
260
312
  });
261
- onMounted(async () => {
262
- const handleRectChange = (position, rect, origin) => {
263
- const point = calculatePosition(position, rect, origin);
264
- positionedStyle.left = `${point.x}px`;
265
- positionedStyle.top = `${point.y}px`;
266
- };
267
- const locationElements = computed(() => {
268
- const overlay2 = overlayRef.value;
269
- const origin = getOrigin(props.origin);
270
- if (!overlay2 || !origin) {
271
- return;
272
- }
273
- return {
274
- origin,
275
- overlay: overlay2
276
- };
277
- });
278
- const visibleRef = toRef(props, "visible");
279
- const positionRef = toRef(props, "position");
280
- watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
281
- if (!visible || !locationElements2) {
282
- return;
283
- }
284
- const {
285
- origin,
286
- overlay: overlay2
287
- } = locationElements2;
288
- handleRectChange(position, overlay2.getBoundingClientRect(), origin);
289
- const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
290
- onInvalidate(() => {
291
- unsubscriptions.forEach((fn) => fn());
292
- });
293
- });
313
+ };
314
+ const updatePosition = async () => {
315
+ const hostEl = props.origin;
316
+ const overlayEl = unref(overlayRef.value);
317
+ const arrowEl = unref(arrowRef.value);
318
+ const middleware = [
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
294
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 };
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
+ }) {
295
366
  const {
296
- backgroundClass,
297
- overlayClass,
298
- handleBackdropClick,
299
- handleOverlayBubbleCancel
300
- } = useOverlayLogic(props);
301
- return () => createVNode(CommonOverlay, null, {
302
- default: () => [withDirectives(createVNode("div", {
303
- "style": props.backgroundStyle,
304
- "class": backgroundClass.value,
305
- "onClick": handleBackdropClick
306
- }, [createVNode("div", {
367
+ arrowRef,
368
+ overlayRef
369
+ } = useOverlay(props, emit);
370
+ return () => {
371
+ var _a;
372
+ return props.modelValue && createVNode("div", mergeProps({
307
373
  "ref": overlayRef,
308
- "class": overlayClass.value,
309
- "style": positionedStyle,
310
- "onClick": handleOverlayBubbleCancel
311
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
312
- });
374
+ "class": "devui-flexible-overlay"
375
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
376
+ "ref": arrowRef,
377
+ "class": "devui-flexible-overlay-arrow"
378
+ }, null)]);
379
+ };
313
380
  }
314
381
  });
315
- function getOrigin(origin) {
316
- if (origin instanceof Element) {
317
- return origin;
318
- }
319
- if (isRef(origin)) {
320
- return getElement(origin.value);
321
- }
322
- if (isComponent(origin)) {
323
- return getElement(origin);
324
- }
325
- return origin;
326
- }
327
- function calculatePosition(position, rect, origin) {
328
- const originRect = getOriginRect(origin);
329
- const originPoint = getOriginRelativePoint(originRect, position);
330
- return getOverlayPoint(originPoint, rect, position);
331
- }
332
- function getOriginRect(origin) {
333
- if (origin instanceof Element) {
334
- return origin.getBoundingClientRect();
335
- }
336
- const width = origin.width || 0;
337
- const height = origin.height || 0;
338
- return {
339
- top: origin.y,
340
- bottom: origin.y + height,
341
- left: origin.x,
342
- right: origin.x + width,
343
- height,
344
- width
345
- };
346
- }
347
- function getOverlayPoint(originPoint, rect, position) {
348
- let x;
349
- const {
350
- width,
351
- height
352
- } = rect;
353
- if (position.overlayX == "center") {
354
- x = originPoint.x - width / 2;
355
- } else {
356
- x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
357
- }
358
- let y;
359
- if (position.overlayY == "center") {
360
- y = originPoint.y - height / 2;
361
- } else {
362
- y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
363
- }
364
- return {
365
- x,
366
- y
367
- };
368
- }
369
- function getOriginRelativePoint(originRect, position) {
370
- let x;
371
- if (position.originX == "center") {
372
- x = originRect.left + originRect.width / 2;
373
- } else {
374
- const startX = originRect.left;
375
- const endX = originRect.right;
376
- x = position.originX == "left" ? startX : endX;
382
+ const inBrowser = typeof window !== "undefined";
383
+ function useModal(props, emit) {
384
+ function close() {
385
+ emit("update:modelValue", false);
377
386
  }
378
- let y;
379
- if (position.originY == "center") {
380
- y = originRect.top + originRect.height / 2;
381
- } else {
382
- y = position.originY == "top" ? originRect.top : originRect.bottom;
387
+ function handleVisibleChange(val) {
388
+ if (!val) {
389
+ props.beforeClose ? props.beforeClose(close) : close();
390
+ }
383
391
  }
384
- return {
385
- x,
386
- y
387
- };
388
- }
389
- function subscribeLayoutEvent(event) {
390
- window.addEventListener("scroll", event, true);
391
- window.addEventListener("resize", event);
392
- window.addEventListener("orientationchange", event);
393
- return () => {
394
- window.removeEventListener("scroll", event, true);
395
- window.removeEventListener("resize", event);
396
- window.removeEventListener("orientationchange", event);
397
- };
392
+ return { handleVisibleChange };
398
393
  }
399
- function subscribeOverlayResize(overlay2, callback) {
400
- if (overlay2 instanceof Element) {
401
- const resizeObserver = new ResizeObserver(callback);
402
- resizeObserver.observe(overlay2);
403
- return () => resizeObserver.disconnect();
394
+ var Header = defineComponent({
395
+ name: "DModalHeader",
396
+ setup(props, {
397
+ slots
398
+ }) {
399
+ return () => {
400
+ var _a;
401
+ return createVNode("div", {
402
+ "class": "devui-modal-header"
403
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
404
+ };
404
405
  }
405
- return () => {
406
- };
407
- }
408
- function subscribeOriginResize(origin, callback) {
409
- if (origin instanceof Element) {
410
- const observer = new MutationObserver(callback);
411
- observer.observe(origin, {
412
- attributeFilter: ["style"]
413
- });
414
- return () => observer.disconnect();
406
+ });
407
+ var Body = defineComponent({
408
+ name: "DModalBody",
409
+ setup(props, {
410
+ slots
411
+ }) {
412
+ return () => {
413
+ var _a;
414
+ return createVNode("div", {
415
+ "class": "devui-modal-body"
416
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
417
+ };
415
418
  }
416
- return () => {
417
- };
418
- }
419
- const inBrowser = typeof window !== "undefined";
420
- FlexibleOverlay.install = function(app) {
421
- app.component(FlexibleOverlay.name, FlexibleOverlay);
422
- };
423
- FixedOverlay.install = function(app) {
424
- app.component(FixedOverlay.name, FixedOverlay);
425
- };
419
+ });
426
420
  var modal = "";
427
421
  var Modal = defineComponent({
428
422
  name: "DModal",
423
+ inheritAttrs: false,
429
424
  props: modalProps,
430
- emits: ["onUpdate:modelValue"],
431
- setup(props, ctx) {
432
- const animatedVisible = computed(() => {
433
- return props.showAnimation ? props.modelValue : true;
434
- });
435
- const onVisibleChange = (value) => {
436
- var _a;
437
- const update = props["onUpdate:modelValue"];
438
- if (value) {
439
- update == null ? void 0 : update(value);
440
- } else {
441
- const beforeHidden = props.beforeHidden;
442
- const close = (enabledClose) => {
443
- var _a2;
444
- if (enabledClose) {
445
- update == null ? void 0 : update(false);
446
- (_a2 = props.onClose) == null ? void 0 : _a2.call(props);
447
- }
448
- };
449
- const result = (_a = typeof beforeHidden === "function" ? beforeHidden() : beforeHidden) != null ? _a : true;
450
- if (result instanceof Promise) {
451
- result.then(close);
452
- } else {
453
- close(result);
454
- }
455
- }
456
- };
457
- ctx.expose({
458
- onVisibleChange
425
+ emits: ["update:modelValue"],
426
+ setup(props, {
427
+ slots,
428
+ attrs,
429
+ emit,
430
+ expose
431
+ }) {
432
+ const {
433
+ modelValue,
434
+ lockScroll,
435
+ closeOnClickOverlay,
436
+ title
437
+ } = toRefs(props);
438
+ const {
439
+ handleVisibleChange
440
+ } = useModal(props, emit);
441
+ expose({
442
+ handleVisibleChange
459
443
  });
460
444
  return () => createVNode(FixedOverlay, {
461
- "visible": props.modelValue,
462
- "onUpdate:visible": onVisibleChange,
463
- "backgroundClass": "devui-modal-wrapper",
464
- "backgroundBlock": !props.bodyScrollable,
465
- "backdropClose": props.backdropCloseable
445
+ "visible": modelValue.value,
446
+ "onUpdate:visible": handleVisibleChange,
447
+ "background-class": "devui-modal-mask",
448
+ "background-block": lockScroll.value,
449
+ "backdrop-close": closeOnClickOverlay.value
466
450
  }, {
467
451
  default: () => [createVNode(Transition, {
468
452
  "name": "devui-modal-wipe"
469
453
  }, {
470
454
  default: () => {
471
- var _a, _b;
472
- return [animatedVisible.value ? (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a) : null];
455
+ var _a;
456
+ return [createVNode("div", mergeProps({
457
+ "class": "devui-modal"
458
+ }, attrs), [createVNode(Icon, {
459
+ "name": "close",
460
+ "class": "btn-close",
461
+ "size": "var(--devui-font-size-md,12px)",
462
+ "onClick": () => handleVisibleChange(false)
463
+ }, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
464
+ default: () => [title.value]
465
+ }), createVNode(Body, null, {
466
+ default: () => {
467
+ var _a2;
468
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
469
+ }
470
+ }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
473
471
  }
474
472
  })]
475
473
  });
476
474
  }
477
475
  });
476
+ var Footer = defineComponent({
477
+ name: "DModalFooter",
478
+ setup(props, {
479
+ slots
480
+ }) {
481
+ return () => {
482
+ var _a;
483
+ return createVNode("div", {
484
+ "class": "devui-modal-footer"
485
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
486
+ };
487
+ }
488
+ });
478
489
  class CommonModalService {
479
490
  constructor(anchorContainer) {
480
491
  this.anchorContainer = anchorContainer;
@@ -490,6 +501,7 @@ class CommonModalService {
490
501
  }, 500);
491
502
  }
492
503
  }
504
+ let vm;
493
505
  class ModalService extends CommonModalService {
494
506
  component() {
495
507
  return Modal;
@@ -497,7 +509,7 @@ class ModalService extends CommonModalService {
497
509
  open(props = {}) {
498
510
  const anchor = document.createElement("div");
499
511
  this.anchorContainer.appendChild(anchor);
500
- const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
512
+ const _a = props, { header, content, footer } = _a, resProps = __objRest(_a, ["header", "content", "footer"]);
501
513
  const needHideOrNot = (value) => {
502
514
  if (!value) {
503
515
  hide();
@@ -507,11 +519,11 @@ class ModalService extends CommonModalService {
507
519
  return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
508
520
  modelValue: true,
509
521
  "onUpdate:modelValue": onUpdateModelValue
510
- }), { default: content });
522
+ }), { header, default: content, footer });
511
523
  };
512
524
  const hide = () => {
513
525
  var _a2, _b;
514
- const vnode = renderOrigin(resProps, (value) => {
526
+ renderOrigin(resProps, (value) => {
515
527
  if (!value) {
516
528
  this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
517
529
  this.renderNull(anchor);
@@ -519,500 +531,23 @@ class ModalService extends CommonModalService {
519
531
  renderOrigin(resProps);
520
532
  }
521
533
  });
522
- (_b = (_a2 = vnode.component.exposed).onVisibleChange) == null ? void 0 : _b.call(_a2, false);
534
+ (_b = (_a2 = vm.component.exposed).handleVisibleChange) == null ? void 0 : _b.call(_a2, false);
523
535
  };
524
536
  this.renderModal(anchor, { modelValue: false });
525
- renderOrigin(resProps);
537
+ vm = renderOrigin(resProps);
526
538
  return { hide };
527
539
  }
528
540
  }
529
541
  __publicField(ModalService, "token", "MODAL_SERVICE_TOKEN");
530
- const dialogProps = {
531
- width: {
532
- type: String,
533
- default: "300px"
534
- },
535
- maxHeight: {
536
- type: String
537
- },
538
- zIndex: {
539
- type: Number,
540
- default: 1050
541
- },
542
- backdropZIndex: {
543
- type: Number,
544
- default: 1049
545
- },
546
- placement: {
547
- type: String,
548
- default: "center"
549
- },
550
- offsetX: {
551
- type: String,
552
- default: "0px"
553
- },
554
- offsetY: {
555
- type: String,
556
- default: "0px"
557
- },
558
- title: {
559
- type: String
560
- },
561
- showAnimation: {
562
- type: Boolean,
563
- default: true
564
- },
565
- backdropCloseable: {
566
- type: Boolean,
567
- default: false
568
- },
569
- bodyScrollable: {
570
- type: Boolean,
571
- default: true
572
- },
573
- escapeable: {
574
- type: Boolean,
575
- default: true
576
- },
577
- onClose: {
578
- type: Function
579
- },
580
- beforeHidden: {
581
- type: [Promise, Function]
582
- },
583
- buttons: {
584
- type: Array,
585
- default: []
586
- },
587
- dialogType: {
588
- type: String,
589
- default: "standard"
590
- },
591
- modelValue: {
592
- type: Boolean
593
- },
594
- "onUpdate:modelValue": {
595
- type: Function
596
- }
597
- };
598
- const useMoveable = (moveable = true) => {
599
- const movingX = ref(0);
600
- const movingY = ref(0);
601
- const reset = () => {
602
- movingX.value = 0;
603
- movingY.value = 0;
604
- };
605
- const handleRef = ref();
606
- const moveElRef = ref();
607
- const enabledMoving = isRef(moveable) ? moveable : ref(moveable);
608
- watch([moveElRef, handleRef], ([container, target], ov, onInvalidate) => {
609
- if (!(target instanceof HTMLElement && container instanceof HTMLElement)) {
610
- return;
611
- }
612
- target.style.cursor = "all-scroll";
613
- let startX = 0;
614
- let startY = 0;
615
- let prevMovingX = 0;
616
- let prevMovingY = 0;
617
- let containerRect = container.getBoundingClientRect();
618
- let bodyRect = document.body.getBoundingClientRect();
619
- let isDown = false;
620
- const handleMouseDown = (event) => {
621
- event.preventDefault();
622
- if (!enabledMoving.value) {
623
- return;
624
- }
625
- startX = event.clientX;
626
- startY = event.clientY;
627
- const targetRect = target.getBoundingClientRect();
628
- if ((target === event.target || target.contains(event.target)) && targetRect.x < startX && targetRect.y < startY && targetRect.width + targetRect.x >= startX && targetRect.height + targetRect.y >= startY) {
629
- isDown = true;
630
- prevMovingX = movingX.value;
631
- prevMovingY = movingY.value;
632
- bodyRect = document.body.getBoundingClientRect();
633
- containerRect = container.getBoundingClientRect();
634
- }
635
- };
636
- const handleMouseMove = (event) => {
637
- event.preventDefault();
638
- if (!isDown) {
639
- return;
640
- }
641
- const currentX = prevMovingX + event.clientX - startX;
642
- const currentY = prevMovingY + event.clientY - startY;
643
- const containerOriginX = containerRect.x - prevMovingX;
644
- const containerOriginY = containerRect.y - prevMovingY;
645
- movingX.value = getRangeValueOf(currentX, -containerOriginX, bodyRect.width - containerRect.width - containerOriginX);
646
- movingY.value = getRangeValueOf(currentY, -containerOriginY, bodyRect.height - containerRect.height - containerOriginY);
647
- };
648
- const handleMouseUp = (event) => {
649
- event.preventDefault();
650
- if (!isDown) {
651
- return;
652
- }
653
- isDown = false;
654
- };
655
- window.addEventListener("mousedown", handleMouseDown);
656
- window.addEventListener("mousemove", handleMouseMove);
657
- window.addEventListener("mouseup", handleMouseUp);
658
- onInvalidate(() => {
659
- window.removeEventListener("mousedown", handleMouseDown);
660
- window.removeEventListener("mousemove", handleMouseMove);
661
- window.removeEventListener("mouseup", handleMouseUp);
662
- });
663
- });
664
- return {
665
- movingX: readonly(movingX),
666
- movingY: readonly(movingY),
667
- handleRef,
668
- moveElRef,
669
- reset
670
- };
671
- };
672
- const getRangeValueOf = (value, min, max) => {
673
- if (value < min) {
674
- return min;
675
- }
676
- if (value > max) {
677
- return max;
678
- }
679
- return value;
680
- };
681
- var Icon = defineComponent({
682
- name: "DIcon",
683
- props: {
684
- name: {
685
- type: String,
686
- required: true
687
- },
688
- size: {
689
- type: String,
690
- default: "inherit"
691
- },
692
- color: {
693
- type: String,
694
- default: "inherit"
695
- },
696
- classPrefix: {
697
- type: String,
698
- default: "icon"
699
- }
700
- },
701
- setup(props) {
702
- return __spreadValues({}, props);
703
- },
704
- render() {
705
- const {
706
- name,
707
- size,
708
- color,
709
- classPrefix
710
- } = this;
711
- return /^((https?):)?\/\//.test(name) ? createVNode("img", {
712
- "src": name,
713
- "alt": name.split("/")[name.split("/").length - 1],
714
- "style": {
715
- width: size
716
- }
717
- }, null) : createVNode("i", {
718
- "class": `${classPrefix} ${classPrefix}-${name}`,
719
- "style": {
720
- fontSize: size,
721
- color
722
- }
723
- }, null);
724
- }
725
- });
726
- Icon.install = function(app) {
727
- app.component(Icon.name, Icon);
728
- };
729
- const buttonProps = {
730
- type: {
731
- type: String,
732
- default: "button"
733
- },
734
- btnStyle: {
735
- type: String,
736
- default: "primary"
737
- },
738
- size: {
739
- type: String,
740
- default: "md"
741
- },
742
- position: {
743
- type: String,
744
- default: "default"
745
- },
746
- bordered: {
747
- type: Boolean,
748
- default: false
749
- },
750
- icon: {
751
- type: String,
752
- default: ""
753
- },
754
- showLoading: {
755
- type: Boolean,
756
- default: false
757
- },
758
- width: {
759
- type: String
760
- },
761
- disabled: {
762
- type: Boolean,
763
- default: false
764
- },
765
- autofocus: {
766
- type: Boolean,
767
- default: false
768
- },
769
- onClick: {
770
- type: Function
771
- }
772
- };
773
- var button = "";
774
- var Button = defineComponent({
775
- name: "DButton",
776
- props: buttonProps,
777
- setup(props, ctx) {
778
- const buttonContent = ref(null);
779
- const onClick = (e) => {
780
- var _a;
781
- if (props.showLoading) {
782
- return;
783
- }
784
- (_a = props.onClick) == null ? void 0 : _a.call(props, e);
785
- };
786
- const hasContent = computed(() => ctx.slots.default);
787
- const btnClass = computed(() => {
788
- const {
789
- btnStyle,
790
- size,
791
- position,
792
- bordered,
793
- icon
794
- } = props;
795
- const origin = `devui-btn devui-btn-${btnStyle} devui-btn-${size} devui-btn-${position}`;
796
- const borderedClass = bordered ? "bordered" : "";
797
- const btnIcon = !!icon && !hasContent.value && btnStyle !== "primary" ? "d-btn-icon" : "";
798
- const btnIconWrap = !!icon ? "d-btn-icon-wrap" : "";
799
- return `${origin} ${borderedClass} ${btnIcon} ${btnIconWrap}`;
800
- });
801
- const iconClass = computed(() => {
802
- if (!props.icon) {
803
- return;
804
- }
805
- const origin = "devui-icon-fix icon";
806
- if (hasContent.value) {
807
- return `${origin} clear-right-5`;
808
- } else {
809
- return origin;
810
- }
811
- });
812
- return () => {
813
- var _a, _b;
814
- const {
815
- icon,
816
- type,
817
- disabled,
818
- showLoading,
819
- width
820
- } = props;
821
- return createVNode("div", mergeProps({
822
- "class": "devui-btn-host"
823
- }, ctx.attrs), [createVNode("button", {
824
- "class": btnClass.value,
825
- "type": type,
826
- "disabled": disabled,
827
- "style": {
828
- width
829
- },
830
- "onClick": onClick
831
- }, [!!icon ? createVNode(Icon, {
832
- "name": props.icon,
833
- "class": iconClass.value
834
- }, null) : null, createVNode("span", {
835
- "class": "button-content",
836
- "ref": buttonContent
837
- }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])])]);
838
- };
839
- }
840
- });
841
- Button.install = function(app) {
842
- app.component(Button.name, Button);
843
- };
844
- function _isSlot(s) {
845
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
846
- }
847
- var Dialog = defineComponent({
848
- name: "DModal",
849
- inheritAttrs: false,
850
- props: dialogProps,
851
- emits: ["onUpdate:modelValue"],
852
- setup(props, ctx) {
853
- const {
854
- movingX,
855
- movingY,
856
- handleRef,
857
- moveElRef,
858
- reset
859
- } = useMoveable();
860
- watch(() => props.modelValue, (value) => {
861
- if (value) {
862
- reset();
863
- }
864
- });
865
- const movingStyle = computed(() => ({
866
- position: "relative",
867
- left: `${movingX.value}px`,
868
- top: `${movingY.value}px`
869
- }));
870
- const containerStyle = computed(() => ({
871
- width: props.width,
872
- maxHeight: props.maxHeight,
873
- transform: `translate(${props.offsetX}, ${props.offsetY})`,
874
- zIndex: props.zIndex
875
- }));
876
- const iconName = computed(() => {
877
- switch (props.dialogType) {
878
- case "standard":
879
- return "";
880
- case "info":
881
- return "icon-info-o";
882
- case "success":
883
- return "icon-right-o";
884
- case "warning":
885
- return "icon-warning-o";
886
- case "failed":
887
- return "icon-error-o";
888
- default:
889
- return "";
890
- }
891
- });
892
- const buttonsRef = computed(() => {
893
- return props.buttons.map((buttonProps2, index2) => {
894
- const {
895
- btnStyle,
896
- disabled,
897
- handler,
898
- text
899
- } = buttonProps2;
900
- return createVNode(Button, {
901
- "key": index2,
902
- "style": {
903
- display: "inline-block",
904
- margin: "0 5px"
905
- },
906
- "btnStyle": btnStyle,
907
- "disabled": disabled,
908
- "onClick": handler
909
- }, _isSlot(text) ? text : {
910
- default: () => [text]
911
- });
912
- });
913
- });
914
- const modalRef = ref();
915
- const closeModal = () => {
916
- var _a, _b;
917
- (_b = (_a = modalRef.value) == null ? void 0 : _a.onVisibleChange) == null ? void 0 : _b.call(_a, false);
918
- };
919
- ctx.expose({
920
- closeModal
921
- });
922
- return () => createVNode(Modal, {
923
- "ref": modalRef,
924
- "width": props.width,
925
- "maxHeight": props.maxHeight,
926
- "offsetX": props.offsetX,
927
- "offsetY": props.offsetY,
928
- "zIndex": props.zIndex,
929
- "backdropZIndex": props.backdropZIndex,
930
- "backdropCloseable": props.backdropCloseable,
931
- "bodyScrollable": props.bodyScrollable,
932
- "placement": props.placement,
933
- "onClose": props.onClose,
934
- "beforeHidden": props.beforeHidden,
935
- "modelValue": props.modelValue,
936
- "onUpdate:modelValue": props["onUpdate:modelValue"]
937
- }, {
938
- default: () => {
939
- var _a, _b;
940
- return [createVNode("div", {
941
- "class": "devui-modal-content",
942
- "style": [containerStyle.value, movingStyle.value],
943
- "ref": moveElRef
944
- }, [createVNode("div", {
945
- "class": "devui-modal-header",
946
- "ref": handleRef
947
- }, [!!iconName.value ? createVNode(Icon, {
948
- "name": iconName.value,
949
- "size": "24px",
950
- "class": "header-alert-icon"
951
- }, null) : null, createVNode("span", null, [props.title]), createVNode(Button, {
952
- "class": "btn-close",
953
- "icon": "close",
954
- "btnStyle": "text-dark",
955
- "onClick": closeModal
956
- }, null)]), createVNode("div", {
957
- "class": "devui-modal-body"
958
- }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createVNode("div", {
959
- "class": "devui-modal-footer"
960
- }, [buttonsRef.value])])];
961
- }
962
- });
963
- }
964
- });
965
- class DialogService extends CommonModalService {
966
- component() {
967
- return Dialog;
968
- }
969
- open(props = {}) {
970
- const anchor = document.createElement("div");
971
- this.anchorContainer.appendChild(anchor);
972
- const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
973
- const needHideOrNot = (value) => {
974
- if (!value) {
975
- hide();
976
- }
977
- };
978
- const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
979
- return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
980
- modelValue: true,
981
- "onUpdate:modelValue": onUpdateModelValue
982
- }), { default: content });
983
- };
984
- const hide = () => {
985
- var _a2, _b;
986
- const vnode = renderOrigin(resProps, (value) => {
987
- if (!value) {
988
- this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
989
- this.renderNull(anchor);
990
- } else {
991
- renderOrigin(resProps);
992
- }
993
- });
994
- (_b = (_a2 = vnode.component.exposed).closeModal) == null ? void 0 : _b.call(_a2);
995
- };
996
- const updateButtonOptions = (buttonOptions) => {
997
- const _a2 = resProps, { buttons } = _a2, innerResProps = __objRest(_a2, ["buttons"]);
998
- const newButtonOptions = buttons.map((option, index2) => __spreadValues(__spreadValues({}, option), buttonOptions[index2]));
999
- renderOrigin(__spreadProps(__spreadValues({}, innerResProps), { buttons: newButtonOptions }));
1000
- };
1001
- this.renderModal(anchor, { modelValue: false });
1002
- renderOrigin(resProps);
1003
- return { hide, updateButtonOptions };
1004
- }
1005
- }
1006
- __publicField(DialogService, "token", "DIALOG_SERVICE_TOKEN");
1007
- Modal.install = function(app) {
1008
- app.component(Modal.name, Modal);
1009
- };
1010
542
  var index = {
1011
543
  title: "Modal \u5F39\u7A97",
1012
544
  category: "\u53CD\u9988",
1013
545
  status: "100%",
1014
546
  install(app) {
1015
- app.use(Modal);
547
+ app.component(Modal.name, Modal);
548
+ app.component(Header.name, Header);
549
+ app.component(Body.name, Body);
550
+ app.component(Footer.name, Footer);
1016
551
  if (!inBrowser) {
1017
552
  return;
1018
553
  }
@@ -1023,7 +558,6 @@ var index = {
1023
558
  document.body.appendChild(anchorsContainer);
1024
559
  }
1025
560
  app.provide(ModalService.token, new ModalService(anchorsContainer));
1026
- app.provide(DialogService.token, new DialogService(anchorsContainer));
1027
561
  }
1028
562
  };
1029
563
  export { Modal, index as default };