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