vue-devui 1.0.0-beta.9 → 1.0.0-rc.1

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 (294) hide show
  1. package/README.md +100 -72
  2. package/accordion/index.es.js +525 -39
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.es.js +34 -37
  6. package/alert/index.umd.js +1 -1
  7. package/alert/style.css +1 -1
  8. package/{time-axis → auto-complete}/index.d.ts +0 -0
  9. package/auto-complete/index.es.js +983 -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 +5 -3
  14. package/back-top/index.umd.js +1 -1
  15. package/badge/index.es.js +13 -19
  16. package/badge/index.umd.js +1 -1
  17. package/badge/style.css +1 -1
  18. package/breadcrumb/index.es.js +2 -1
  19. package/button/index.es.js +296 -117
  20. package/button/index.umd.js +1 -1
  21. package/button/style.css +1 -1
  22. package/carousel/index.es.js +43 -57
  23. package/carousel/index.umd.js +1 -1
  24. package/cascader/index.es.js +5412 -784
  25. package/cascader/index.umd.js +27 -1
  26. package/cascader/style.css +1 -1
  27. package/checkbox/style.css +1 -1
  28. package/{toast → color-picker}/index.d.ts +0 -0
  29. package/color-picker/index.es.js +8196 -0
  30. package/color-picker/index.umd.js +27 -0
  31. package/color-picker/package.json +7 -0
  32. package/color-picker/style.css +1 -0
  33. package/comment/index.es.js +42 -13
  34. package/comment/index.umd.js +1 -1
  35. package/comment/style.css +1 -1
  36. package/countdown/index.es.js +27 -17
  37. package/countdown/index.umd.js +1 -1
  38. package/countdown/style.css +1 -1
  39. package/date-picker/index.es.js +48 -66
  40. package/date-picker/index.umd.js +1 -1
  41. package/date-picker/style.css +1 -1
  42. package/dragdrop/index.es.js +135 -10
  43. package/dragdrop/index.umd.js +1 -1
  44. package/drawer/index.es.js +169 -223
  45. package/drawer/index.umd.js +1 -1
  46. package/drawer/style.css +1 -1
  47. package/dropdown/index.es.js +463 -300
  48. package/dropdown/index.umd.js +1 -1
  49. package/dropdown/style.css +1 -1
  50. package/editable-select/index.es.js +293 -5660
  51. package/editable-select/index.umd.js +1 -27
  52. package/editable-select/style.css +1 -1
  53. package/form/index.es.js +6210 -531
  54. package/form/index.umd.js +27 -1
  55. package/form/style.css +1 -1
  56. package/fullscreen/index.es.js +112 -133
  57. package/fullscreen/index.umd.js +1 -1
  58. package/fullscreen/style.css +1 -1
  59. package/gantt/index.es.js +6 -18
  60. package/gantt/index.umd.js +1 -1
  61. package/gantt/style.css +1 -1
  62. package/grid/index.es.js +1 -1
  63. package/grid/style.css +1 -1
  64. package/icon/index.es.js +39 -56
  65. package/icon/index.umd.js +1 -1
  66. package/image-preview/index.es.js +35 -16
  67. package/image-preview/index.umd.js +1 -1
  68. package/input/index.es.js +4 -5
  69. package/input/index.umd.js +1 -1
  70. package/input/style.css +1 -1
  71. package/input-icon/index.es.js +42 -41
  72. package/input-icon/index.umd.js +1 -1
  73. package/input-icon/style.css +1 -1
  74. package/input-number/index.es.js +46 -56
  75. package/input-number/index.umd.js +1 -1
  76. package/input-number/style.css +1 -1
  77. package/list/index.d.ts +7 -0
  78. package/list/index.es.js +39 -0
  79. package/list/index.umd.js +1 -0
  80. package/{toast → list}/package.json +1 -1
  81. package/list/style.css +1 -0
  82. package/loading/index.es.js +2 -2
  83. package/modal/index.es.js +304 -765
  84. package/modal/index.umd.js +1 -1
  85. package/modal/style.css +1 -1
  86. package/nav-sprite/index.es.js +1 -675
  87. package/nav-sprite/index.umd.js +1 -1
  88. package/notification/index.d.ts +7 -0
  89. package/notification/index.es.js +284 -0
  90. package/notification/index.umd.js +1 -0
  91. package/notification/package.json +7 -0
  92. package/notification/style.css +1 -0
  93. package/nuxt/components/Accordion.js +3 -0
  94. package/nuxt/components/Alert.js +3 -0
  95. package/nuxt/components/Anchor.js +3 -0
  96. package/nuxt/components/Aside.js +3 -0
  97. package/nuxt/components/AutoComplete.js +3 -0
  98. package/nuxt/components/Avatar.js +3 -0
  99. package/nuxt/components/BackTop.js +3 -0
  100. package/nuxt/components/Badge.js +3 -0
  101. package/nuxt/components/Breadcrumb.js +3 -0
  102. package/nuxt/components/Button.js +3 -0
  103. package/nuxt/components/Card.js +3 -0
  104. package/nuxt/components/Carousel.js +3 -0
  105. package/nuxt/components/CarouselItem.js +3 -0
  106. package/nuxt/components/Cascader.js +3 -0
  107. package/nuxt/components/Checkbox.js +3 -0
  108. package/nuxt/components/Col.js +3 -0
  109. package/nuxt/components/ColorPicker.js +3 -0
  110. package/nuxt/components/Column.js +3 -0
  111. package/nuxt/components/Comment.js +3 -0
  112. package/nuxt/components/Content.js +3 -0
  113. package/nuxt/components/Countdown.js +3 -0
  114. package/nuxt/components/DatePicker.js +3 -0
  115. package/nuxt/components/Drawer.js +3 -0
  116. package/nuxt/components/DrawerService.js +3 -0
  117. package/nuxt/components/Dropdown.js +3 -0
  118. package/nuxt/components/DropdownMenu.js +3 -0
  119. package/nuxt/components/EditableSelect.js +3 -0
  120. package/nuxt/components/FixedOverlay.js +3 -0
  121. package/nuxt/components/FlexibleOverlay.js +3 -0
  122. package/nuxt/components/Footer.js +3 -0
  123. package/nuxt/components/Form.js +3 -0
  124. package/nuxt/components/FormControl.js +3 -0
  125. package/nuxt/components/FormItem.js +3 -0
  126. package/nuxt/components/FormLabel.js +3 -0
  127. package/nuxt/components/FormOperation.js +3 -0
  128. package/nuxt/components/Fullscreen.js +3 -0
  129. package/nuxt/components/Gantt.js +3 -0
  130. package/nuxt/components/Header.js +3 -0
  131. package/nuxt/components/IFileOptions.js +3 -0
  132. package/nuxt/components/IUploadOptions.js +3 -0
  133. package/nuxt/components/Icon.js +2 -0
  134. package/nuxt/components/ImagePreviewService.js +3 -0
  135. package/nuxt/components/Input.js +3 -0
  136. package/nuxt/components/InputIcon.js +3 -0
  137. package/nuxt/components/InputNumber.js +3 -0
  138. package/nuxt/components/Layout.js +3 -0
  139. package/nuxt/components/List.js +3 -0
  140. package/nuxt/components/ListItem.js +3 -0
  141. package/nuxt/components/Loading.js +3 -0
  142. package/nuxt/components/LoadingService.js +3 -0
  143. package/nuxt/components/Modal.js +3 -0
  144. package/nuxt/components/NavSprite.js +2 -0
  145. package/nuxt/components/Notification.js +3 -0
  146. package/nuxt/components/NotificationService.js +3 -0
  147. package/nuxt/components/Pagination.js +3 -0
  148. package/nuxt/components/Panel.js +3 -0
  149. package/nuxt/components/PanelBody.js +3 -0
  150. package/nuxt/components/PanelFooter.js +3 -0
  151. package/nuxt/components/PanelHeader.js +3 -0
  152. package/nuxt/components/Popover.js +3 -0
  153. package/nuxt/components/Progress.js +3 -0
  154. package/nuxt/components/QuadrantDiagram.js +3 -0
  155. package/nuxt/components/Radio.js +3 -0
  156. package/nuxt/components/RadioGroup.js +3 -0
  157. package/nuxt/components/Rate.js +3 -0
  158. package/nuxt/components/ReadTip.js +3 -0
  159. package/nuxt/components/Result.js +3 -0
  160. package/nuxt/components/Row.js +3 -0
  161. package/nuxt/components/Search.js +3 -0
  162. package/nuxt/components/Select.js +3 -0
  163. package/nuxt/components/Skeleton.js +3 -0
  164. package/nuxt/components/SkeletonItem.js +3 -0
  165. package/nuxt/components/Slider.js +3 -0
  166. package/nuxt/components/Splitter.js +3 -0
  167. package/nuxt/components/Statistic.js +3 -0
  168. package/nuxt/components/Status.js +3 -0
  169. package/nuxt/components/StepsGuide.js +3 -0
  170. package/nuxt/components/StickSlider.js +3 -0
  171. package/nuxt/components/Sticky.js +2 -0
  172. package/nuxt/components/Switch.js +3 -0
  173. package/nuxt/components/Table.js +3 -0
  174. package/nuxt/components/Tabs.js +3 -0
  175. package/nuxt/components/Tag.js +3 -0
  176. package/nuxt/components/TagInput.js +3 -0
  177. package/nuxt/components/Textarea.js +3 -0
  178. package/nuxt/components/TimePicker.js +3 -0
  179. package/nuxt/components/Timeline.js +3 -0
  180. package/nuxt/components/TimelineItem.js +3 -0
  181. package/nuxt/components/Tooltip.js +3 -0
  182. package/nuxt/components/Transfer.js +3 -0
  183. package/nuxt/components/Tree.js +3 -0
  184. package/nuxt/components/TreeSelect.js +3 -0
  185. package/nuxt/components/Upload.js +3 -0
  186. package/nuxt/components/UploadStatus.js +3 -0
  187. package/nuxt/components/alertProps.js +3 -0
  188. package/nuxt/components/badgeProps.js +3 -0
  189. package/nuxt/components/buttonProps.js +3 -0
  190. package/nuxt/components/dropdownMenuProps.js +3 -0
  191. package/nuxt/components/fixedOverlayProps.js +3 -0
  192. package/nuxt/components/flexibleOverlayProps.js +3 -0
  193. package/nuxt/components/fullscreenProps.js +3 -0
  194. package/nuxt/components/iconProps.js +2 -0
  195. package/nuxt/components/notificationProps.js +3 -0
  196. package/nuxt/components/overlayEmits.js +3 -0
  197. package/nuxt/components/overlayProps.js +3 -0
  198. package/nuxt/components/paginationProps.js +3 -0
  199. package/nuxt/components/panelProps.js +3 -0
  200. package/nuxt/components/popoverProps.js +3 -0
  201. package/nuxt/components/searchProps.js +3 -0
  202. package/nuxt/components/tooltipProps.js +3 -0
  203. package/nuxt/components/uploadProps.js +3 -0
  204. package/nuxt/index.js +13 -0
  205. package/overlay/index.es.js +156 -205
  206. package/overlay/index.umd.js +1 -1
  207. package/overlay/style.css +1 -1
  208. package/package.json +12 -55
  209. package/pagination/index.es.js +11 -13
  210. package/pagination/index.umd.js +1 -1
  211. package/pagination/style.css +1 -1
  212. package/panel/index.es.js +48 -35
  213. package/panel/index.umd.js +1 -1
  214. package/popover/index.es.js +5954 -189
  215. package/popover/index.umd.js +27 -1
  216. package/popover/style.css +1 -1
  217. package/progress/index.es.js +8 -8
  218. package/progress/index.umd.js +3 -3
  219. package/quadrant-diagram/index.es.js +5405 -166
  220. package/quadrant-diagram/index.umd.js +27 -1
  221. package/radio/index.es.js +8 -14
  222. package/radio/index.umd.js +1 -1
  223. package/radio/style.css +1 -1
  224. package/read-tip/index.es.js +6 -3
  225. package/read-tip/style.css +1 -1
  226. package/result/index.es.js +38 -52
  227. package/result/index.umd.js +1 -1
  228. package/ripple/index.es.js +10 -6
  229. package/search/index.es.js +5428 -200
  230. package/search/index.umd.js +27 -1
  231. package/search/style.css +1 -1
  232. package/select/index.es.js +43 -42
  233. package/select/index.umd.js +1 -1
  234. package/select/style.css +1 -1
  235. package/skeleton/index.es.js +17 -17
  236. package/skeleton/index.umd.js +1 -1
  237. package/slider/index.es.js +4 -6
  238. package/slider/index.umd.js +1 -1
  239. package/slider/style.css +1 -1
  240. package/splitter/index.es.js +5896 -39
  241. package/splitter/index.umd.js +27 -1
  242. package/splitter/style.css +1 -1
  243. package/statistic/index.es.js +19 -32
  244. package/statistic/index.umd.js +1 -1
  245. package/statistic/style.css +1 -1
  246. package/status/index.es.js +1 -4
  247. package/status/index.umd.js +1 -1
  248. package/status/style.css +1 -1
  249. package/steps-guide/index.es.js +6 -3
  250. package/sticky/index.umd.js +1 -1
  251. package/style.css +1 -1
  252. package/table/index.es.js +753 -358
  253. package/table/index.umd.js +1 -1
  254. package/table/style.css +1 -1
  255. package/tabs/index.es.js +3 -4
  256. package/tabs/index.umd.js +1 -1
  257. package/tabs/style.css +1 -1
  258. package/tag/index.es.js +4 -3
  259. package/tag/index.umd.js +1 -1
  260. package/tag/style.css +1 -1
  261. package/tag-input/index.es.js +4 -14
  262. package/tag-input/index.umd.js +1 -1
  263. package/textarea/style.css +1 -1
  264. package/{theme → theme/theme.scss} +0 -0
  265. package/time-picker/index.es.js +309 -123
  266. package/time-picker/index.umd.js +1 -1
  267. package/time-picker/style.css +1 -1
  268. package/timeline/index.d.ts +7 -0
  269. package/{time-axis → timeline}/index.es.js +65 -77
  270. package/timeline/index.umd.js +1 -0
  271. package/{time-axis → timeline}/package.json +1 -1
  272. package/timeline/style.css +1 -0
  273. package/tooltip/index.es.js +5805 -141
  274. package/tooltip/index.umd.js +27 -1
  275. package/tooltip/style.css +1 -1
  276. package/transfer/index.es.js +6521 -630
  277. package/transfer/index.umd.js +27 -1
  278. package/transfer/style.css +1 -1
  279. package/tree/index.es.js +5781 -193
  280. package/tree/index.umd.js +27 -1
  281. package/tree/style.css +1 -1
  282. package/tree-select/index.es.js +138 -39
  283. package/tree-select/index.umd.js +1 -1
  284. package/tree-select/style.css +1 -1
  285. package/upload/index.es.js +450 -2669
  286. package/upload/index.umd.js +1 -1
  287. package/upload/style.css +1 -1
  288. package/vue-devui.es.js +14414 -14096
  289. package/vue-devui.umd.js +19 -19
  290. package/time-axis/index.umd.js +0 -1
  291. package/time-axis/style.css +0 -1
  292. package/toast/index.es.js +0 -2059
  293. package/toast/index.umd.js +0 -1
  294. 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 } 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: {
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
+ 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
  });
@@ -115,9 +127,6 @@ const overlayProps = {
115
127
  visible: {
116
128
  type: Boolean
117
129
  },
118
- "onUpdate:visible": {
119
- type: Function
120
- },
121
130
  backgroundBlock: {
122
131
  type: Boolean,
123
132
  default: false
@@ -141,29 +150,14 @@ const overlayProps = {
141
150
  default: true
142
151
  }
143
152
  };
144
- const overlayEmits = ["onUpdate:visible", "backdropClick"];
145
153
  const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
146
154
  overlayStyle: {
147
155
  type: [String, Object],
148
156
  default: void 0
149
157
  }
150
158
  });
151
- const flexibleOverlayProps = __spreadValues({
152
- origin: {
153
- type: Object,
154
- require: true
155
- },
156
- position: {
157
- type: Object,
158
- default: () => ({
159
- originX: "left",
160
- originY: "top",
161
- overlayX: "left",
162
- overlayY: "top"
163
- })
164
- }
165
- }, overlayProps);
166
- function useOverlayLogic(props) {
159
+ const overlayEmits = ["update:visible", "backdropClick"];
160
+ function useOverlayLogic(props, ctx) {
167
161
  const backgroundClass = computed(() => {
168
162
  return [
169
163
  "devui-overlay-background",
@@ -175,11 +169,11 @@ function useOverlayLogic(props) {
175
169
  return "devui-overlay";
176
170
  });
177
171
  const handleBackdropClick = (event) => {
178
- var _a, _b;
172
+ var _a;
179
173
  event.preventDefault();
180
174
  (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
181
175
  if (props.backdropClose) {
182
- (_b = props["onUpdate:visible"]) == null ? void 0 : _b.call(props, false);
176
+ ctx.emit("update:visible", false);
183
177
  }
184
178
  };
185
179
  const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
@@ -213,6 +207,7 @@ function useOverlayLogic(props) {
213
207
  handleOverlayBubbleCancel
214
208
  };
215
209
  }
210
+ var fixedOverlay = "";
216
211
  const FixedOverlay = defineComponent({
217
212
  name: "DFixedOverlay",
218
213
  props: fixedOverlayProps,
@@ -223,9 +218,9 @@ const FixedOverlay = defineComponent({
223
218
  overlayClass,
224
219
  handleBackdropClick,
225
220
  handleOverlayBubbleCancel
226
- } = useOverlayLogic(props);
221
+ } = useOverlayLogic(props, ctx);
227
222
  return () => createVNode(CommonOverlay, null, {
228
- default: () => [withDirectives(createVNode("div", {
223
+ default: () => [props.visible && createVNode("div", {
229
224
  "class": backgroundClass.value,
230
225
  "style": props.backgroundStyle,
231
226
  "onClick": handleBackdropClick
@@ -233,248 +228,269 @@ const FixedOverlay = defineComponent({
233
228
  "class": overlayClass.value,
234
229
  "style": props.overlayStyle,
235
230
  "onClick": handleOverlayBubbleCancel
236
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
231
+ }, [renderSlot(ctx.slots, "default")])])]
237
232
  });
238
233
  }
239
234
  });
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;
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
246
263
  }
247
- if (element && typeof element === "object" && element.$el instanceof Element) {
248
- 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
+ }
249
272
  }
250
- return null;
273
+ return window;
251
274
  }
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"
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"
260
311
  });
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
- });
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
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, 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
+ }) {
295
367
  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", {
307
- "ref": overlayRef,
308
- "class": overlayClass.value,
309
- "style": positionedStyle,
310
- "onClick": handleOverlayBubbleCancel
311
- }, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
368
+ arrowRef,
369
+ overlayRef,
370
+ updatePosition
371
+ } = useOverlay(props, emit);
372
+ expose({
373
+ updatePosition
312
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
+ };
313
385
  }
314
386
  });
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;
387
+ const inBrowser = typeof window !== "undefined";
388
+ function useModal(props, emit) {
389
+ function close() {
390
+ emit("update:modelValue", false);
377
391
  }
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;
392
+ function handleVisibleChange(val) {
393
+ if (!val) {
394
+ props.beforeClose ? props.beforeClose(close) : close();
395
+ }
383
396
  }
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
- };
397
+ return { handleVisibleChange };
398
398
  }
399
- function subscribeOverlayResize(overlay2, callback) {
400
- if (overlay2 instanceof Element) {
401
- const resizeObserver = new ResizeObserver(callback);
402
- resizeObserver.observe(overlay2);
403
- 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
+ };
404
410
  }
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();
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
+ };
415
423
  }
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
- };
424
+ });
426
425
  var modal = "";
427
426
  var Modal = defineComponent({
428
427
  name: "DModal",
428
+ inheritAttrs: false,
429
429
  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
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
459
448
  });
460
449
  return () => createVNode(FixedOverlay, {
461
- "visible": props.modelValue,
462
- "onUpdate:visible": onVisibleChange,
463
- "backgroundClass": "devui-modal-wrapper",
464
- "backgroundBlock": !props.bodyScrollable,
465
- "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
466
455
  }, {
467
456
  default: () => [createVNode(Transition, {
468
457
  "name": "devui-modal-wipe"
469
458
  }, {
470
459
  default: () => {
471
- var _a, _b;
472
- 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)])];
473
476
  }
474
477
  })]
475
478
  });
476
479
  }
477
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
+ });
478
494
  class CommonModalService {
479
495
  constructor(anchorContainer) {
480
496
  this.anchorContainer = anchorContainer;
@@ -490,6 +506,7 @@ class CommonModalService {
490
506
  }, 500);
491
507
  }
492
508
  }
509
+ let vm;
493
510
  class ModalService extends CommonModalService {
494
511
  component() {
495
512
  return Modal;
@@ -497,7 +514,7 @@ class ModalService extends CommonModalService {
497
514
  open(props = {}) {
498
515
  const anchor = document.createElement("div");
499
516
  this.anchorContainer.appendChild(anchor);
500
- const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
517
+ const _a = props, { header, content, footer } = _a, resProps = __objRest(_a, ["header", "content", "footer"]);
501
518
  const needHideOrNot = (value) => {
502
519
  if (!value) {
503
520
  hide();
@@ -507,11 +524,11 @@ class ModalService extends CommonModalService {
507
524
  return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
508
525
  modelValue: true,
509
526
  "onUpdate:modelValue": onUpdateModelValue
510
- }), { default: content });
527
+ }), { header, default: content, footer });
511
528
  };
512
529
  const hide = () => {
513
530
  var _a2, _b;
514
- const vnode = renderOrigin(resProps, (value) => {
531
+ renderOrigin(resProps, (value) => {
515
532
  if (!value) {
516
533
  this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
517
534
  this.renderNull(anchor);
@@ -519,500 +536,23 @@ class ModalService extends CommonModalService {
519
536
  renderOrigin(resProps);
520
537
  }
521
538
  });
522
- (_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);
523
540
  };
524
541
  this.renderModal(anchor, { modelValue: false });
525
- renderOrigin(resProps);
542
+ vm = renderOrigin(resProps);
526
543
  return { hide };
527
544
  }
528
545
  }
529
546
  __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
547
  var index = {
1011
548
  title: "Modal \u5F39\u7A97",
1012
549
  category: "\u53CD\u9988",
1013
550
  status: "100%",
1014
551
  install(app) {
1015
- 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);
1016
556
  if (!inBrowser) {
1017
557
  return;
1018
558
  }
@@ -1023,7 +563,6 @@ var index = {
1023
563
  document.body.appendChild(anchorsContainer);
1024
564
  }
1025
565
  app.provide(ModalService.token, new ModalService(anchorsContainer));
1026
- app.provide(DialogService.token, new DialogService(anchorsContainer));
1027
566
  }
1028
567
  };
1029
568
  export { Modal, index as default };