vue-devui 1.0.0-rc.8 → 1.0.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 (228) hide show
  1. package/README.md +188 -149
  2. package/alert/index.es.js +14 -9
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +8392 -418
  6. package/auto-complete/index.umd.js +29 -5
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +59 -74
  9. package/avatar/index.umd.js +1 -1
  10. package/badge/index.es.js +10 -4
  11. package/badge/index.umd.js +1 -1
  12. package/badge/style.css +1 -1
  13. package/button/index.es.js +191 -53
  14. package/button/index.umd.js +17 -17
  15. package/button/style.css +1 -1
  16. package/card/index.es.js +7 -3
  17. package/card/index.umd.js +1 -1
  18. package/card/style.css +1 -1
  19. package/checkbox/index.es.js +8050 -241
  20. package/checkbox/index.umd.js +27 -1
  21. package/checkbox/style.css +1 -1
  22. package/{date-picker → collapse}/index.d.ts +0 -0
  23. package/collapse/index.es.js +213 -0
  24. package/collapse/index.umd.js +1 -0
  25. package/{date-picker → collapse}/package.json +1 -1
  26. package/collapse/style.css +1 -0
  27. package/countdown/index.es.js +56 -13
  28. package/countdown/index.umd.js +1 -1
  29. package/date-picker-pro/index.d.ts +7 -0
  30. package/date-picker-pro/index.es.js +12022 -0
  31. package/date-picker-pro/index.umd.js +27 -0
  32. package/date-picker-pro/package.json +7 -0
  33. package/date-picker-pro/style.css +1 -0
  34. package/drawer/index.es.js +24 -7
  35. package/drawer/index.umd.js +1 -1
  36. package/drawer/style.css +1 -1
  37. package/dropdown/index.es.js +190 -165
  38. package/dropdown/index.umd.js +1 -1
  39. package/dropdown/style.css +1 -1
  40. package/editable-select/index.es.js +785 -145
  41. package/editable-select/index.umd.js +1 -1
  42. package/editable-select/style.css +1 -1
  43. package/form/index.es.js +399 -300
  44. package/form/index.umd.js +16 -16
  45. package/form/style.css +1 -1
  46. package/fullscreen/index.es.js +2 -2
  47. package/fullscreen/index.umd.js +1 -1
  48. package/grid/index.es.js +8 -6
  49. package/grid/index.umd.js +1 -1
  50. package/icon/index.es.js +185 -23
  51. package/icon/index.umd.js +1 -1
  52. package/icon/style.css +1 -0
  53. package/image-preview/index.es.js +2 -2
  54. package/image-preview/index.umd.js +1 -1
  55. package/image-preview/style.css +1 -1
  56. package/input/index.es.js +8220 -45
  57. package/input/index.umd.js +27 -1
  58. package/input/style.css +1 -1
  59. package/input-number/index.es.js +279 -204
  60. package/input-number/index.umd.js +1 -1
  61. package/input-number/style.css +1 -1
  62. package/layout/index.es.js +3 -3
  63. package/layout/index.umd.js +1 -1
  64. package/loading/index.es.js +53 -53
  65. package/loading/index.umd.js +1 -1
  66. package/loading/style.css +1 -1
  67. package/mention/index.d.ts +7 -0
  68. package/mention/index.es.js +8319 -0
  69. package/mention/index.umd.js +36 -0
  70. package/mention/package.json +7 -0
  71. package/mention/style.css +1 -0
  72. package/menu/index.d.ts +7 -0
  73. package/menu/index.es.js +921 -0
  74. package/menu/index.umd.js +1 -0
  75. package/menu/package.json +7 -0
  76. package/menu/style.css +1 -0
  77. package/message/index.d.ts +7 -0
  78. package/message/index.es.js +539 -0
  79. package/message/index.umd.js +1 -0
  80. package/message/package.json +7 -0
  81. package/message/style.css +1 -0
  82. package/modal/index.es.js +451 -173
  83. package/modal/index.umd.js +1 -1
  84. package/modal/style.css +1 -1
  85. package/notification/index.es.js +212 -70
  86. package/notification/index.umd.js +1 -1
  87. package/notification/style.css +1 -1
  88. package/nuxt/components/CheckboxButton.js +3 -0
  89. package/nuxt/components/Collapse.js +3 -0
  90. package/nuxt/components/CollapseItem.js +3 -0
  91. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  92. package/nuxt/components/DatePickerPro.js +3 -0
  93. package/nuxt/components/Icon.js +1 -0
  94. package/nuxt/components/IconGroup.js +3 -0
  95. package/nuxt/components/LABEL_DATA.js +3 -0
  96. package/nuxt/components/Mention.js +3 -0
  97. package/nuxt/components/Menu.js +3 -0
  98. package/nuxt/components/MenuItem.js +3 -0
  99. package/nuxt/components/Message.js +3 -0
  100. package/nuxt/components/Option.js +3 -0
  101. package/nuxt/components/OptionGroup.js +3 -0
  102. package/nuxt/components/RadioButton.js +3 -0
  103. package/nuxt/components/Step.js +3 -0
  104. package/nuxt/components/Steps.js +3 -0
  105. package/nuxt/components/SubMenu.js +3 -0
  106. package/nuxt/components/TABLE_TOKEN.js +3 -0
  107. package/nuxt/components/TimePicker.js +3 -0
  108. package/nuxt/components/TimeSelect.js +3 -0
  109. package/nuxt/components/animationInjectionKey.js +3 -0
  110. package/nuxt/components/collapseItemProps.js +3 -0
  111. package/nuxt/components/collapseProps.js +3 -0
  112. package/nuxt/components/datePickerProCommonProps.js +3 -0
  113. package/nuxt/components/datePickerProPanelProps.js +3 -0
  114. package/nuxt/components/datePickerProProps.js +3 -0
  115. package/nuxt/components/iconProps.js +1 -0
  116. package/nuxt/components/mentionProps.js +3 -0
  117. package/nuxt/components/messageProps.js +3 -0
  118. package/nuxt/components/paginationInjectionKey.js +3 -0
  119. package/nuxt/components/roundInjectionKey.js +3 -0
  120. package/nuxt/components/skeletonItemProps.js +3 -0
  121. package/nuxt/components/stepProps.js +3 -0
  122. package/nuxt/components/stepsProps.js +3 -0
  123. package/nuxt/components/svgIconProps.js +3 -0
  124. package/nuxt/components/tableProps.js +3 -0
  125. package/nuxt/components/timerPickerPanelProps.js +3 -0
  126. package/nuxt/components/treeNodeProps.js +3 -0
  127. package/overlay/index.es.js +89 -142
  128. package/overlay/index.umd.js +1 -1
  129. package/overlay/style.css +1 -1
  130. package/package.json +8 -4
  131. package/pagination/index.es.js +10180 -129
  132. package/pagination/index.umd.js +27 -1
  133. package/pagination/style.css +1 -1
  134. package/panel/index.es.js +4 -0
  135. package/panel/index.umd.js +1 -1
  136. package/panel/style.css +1 -1
  137. package/popover/index.es.js +262 -229
  138. package/popover/index.umd.js +15 -15
  139. package/popover/style.css +1 -1
  140. package/progress/index.es.js +2 -2
  141. package/progress/index.umd.js +2 -2
  142. package/progress/style.css +1 -1
  143. package/radio/index.es.js +7954 -156
  144. package/radio/index.umd.js +27 -1
  145. package/radio/style.css +1 -1
  146. package/rate/index.es.js +16 -8
  147. package/rate/index.umd.js +1 -1
  148. package/rate/style.css +1 -1
  149. package/result/index.es.js +170 -22
  150. package/result/index.umd.js +1 -1
  151. package/result/style.css +1 -1
  152. package/search/index.es.js +3829 -1042
  153. package/search/index.umd.js +18 -18
  154. package/search/style.css +1 -1
  155. package/select/index.es.js +9202 -495
  156. package/select/index.umd.js +27 -1
  157. package/select/style.css +1 -1
  158. package/skeleton/index.es.js +89 -263
  159. package/skeleton/index.umd.js +1 -1
  160. package/skeleton/style.css +1 -1
  161. package/slider/index.es.js +118 -145
  162. package/slider/index.umd.js +1 -1
  163. package/slider/style.css +1 -1
  164. package/splitter/index.es.js +454 -233
  165. package/splitter/index.umd.js +13 -13
  166. package/splitter/style.css +1 -1
  167. package/statistic/index.es.js +34 -16
  168. package/statistic/index.umd.js +1 -1
  169. package/statistic/style.css +1 -1
  170. package/status/index.es.js +6 -2
  171. package/status/index.umd.js +1 -1
  172. package/status/style.css +1 -1
  173. package/steps/index.d.ts +7 -0
  174. package/steps/index.es.js +387 -0
  175. package/steps/index.umd.js +1 -0
  176. package/steps/package.json +7 -0
  177. package/steps/style.css +1 -0
  178. package/style.css +1 -1
  179. package/switch/index.es.js +7787 -62
  180. package/switch/index.umd.js +27 -1
  181. package/switch/style.css +1 -1
  182. package/table/index.es.js +5225 -1726
  183. package/table/index.umd.js +18 -18
  184. package/table/style.css +1 -1
  185. package/tabs/index.es.js +303 -102
  186. package/tabs/index.umd.js +1 -1
  187. package/tabs/style.css +1 -1
  188. package/tag/index.es.js +11 -8
  189. package/tag/index.umd.js +1 -1
  190. package/tag/style.css +1 -1
  191. package/textarea/index.es.js +7876 -41
  192. package/textarea/index.umd.js +35 -1
  193. package/textarea/style.css +1 -1
  194. package/time-picker/index.d.ts +7 -0
  195. package/time-picker/index.es.js +9549 -0
  196. package/time-picker/index.umd.js +27 -0
  197. package/time-picker/package.json +7 -0
  198. package/time-picker/style.css +1 -0
  199. package/time-select/index.d.ts +7 -0
  200. package/time-select/index.es.js +9607 -0
  201. package/time-select/index.umd.js +27 -0
  202. package/time-select/package.json +7 -0
  203. package/time-select/style.css +1 -0
  204. package/timeline/index.es.js +170 -22
  205. package/timeline/index.umd.js +1 -1
  206. package/timeline/style.css +1 -1
  207. package/tooltip/index.es.js +286 -238
  208. package/tooltip/index.umd.js +14 -14
  209. package/tooltip/style.css +1 -1
  210. package/tree/index.es.js +11342 -793
  211. package/tree/index.umd.js +27 -1
  212. package/tree/style.css +1 -1
  213. package/upload/index.es.js +458 -102
  214. package/upload/index.umd.js +1 -1
  215. package/upload/style.css +1 -1
  216. package/vue-devui.es.js +20475 -11072
  217. package/vue-devui.umd.js +31 -24
  218. package/date-picker/index.es.js +0 -1097
  219. package/date-picker/index.umd.js +0 -1
  220. package/date-picker/style.css +0 -1
  221. package/nuxt/components/DatePicker.js +0 -3
  222. package/nuxt/components/FormControl.js +0 -3
  223. package/nuxt/components/FormLabel.js +0 -3
  224. package/nuxt/components/Loading.js +0 -3
  225. package/nuxt/components/StickSlider.js +0 -3
  226. package/nuxt/components/formControlProps.js +0 -3
  227. package/nuxt/components/overlayEmits.js +0 -3
  228. package/nuxt/components/overlayProps.js +0 -3
package/modal/index.es.js CHANGED
@@ -33,7 +33,7 @@ var __publicField = (obj, key, value) => {
33
33
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
34
  return value;
35
35
  };
36
- import { defineComponent, toRefs, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, ref, unref, nextTick, mergeProps, h, render } from "vue";
36
+ import { defineComponent, toRefs, computed, createVNode, resolveDynamicComponent, mergeProps, watch, onUnmounted, Transition, ref, unref, nextTick, withModifiers, onMounted, watchEffect, onBeforeUnmount, Teleport, h, render } from "vue";
37
37
  import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
38
38
  const modalProps = {
39
39
  modelValue: {
@@ -48,14 +48,43 @@ const modalProps = {
48
48
  type: Boolean,
49
49
  default: true
50
50
  },
51
+ draggable: {
52
+ type: Boolean,
53
+ default: true
54
+ },
51
55
  closeOnClickOverlay: {
52
56
  type: Boolean,
53
57
  default: true
54
58
  },
55
59
  beforeClose: {
56
60
  type: Function
61
+ },
62
+ escapable: {
63
+ type: Boolean,
64
+ default: true
65
+ },
66
+ showClose: {
67
+ type: Boolean,
68
+ default: true
69
+ },
70
+ showAnimation: {
71
+ type: Boolean,
72
+ default: true
73
+ },
74
+ showOverlay: {
75
+ type: Boolean,
76
+ default: true
77
+ },
78
+ appendToBody: {
79
+ type: Boolean,
80
+ default: true
81
+ },
82
+ type: {
83
+ type: String,
84
+ default: ""
57
85
  }
58
86
  };
87
+ const DEFAULT_PREFIX = "icon";
59
88
  const iconProps = {
60
89
  name: {
61
90
  type: String,
@@ -63,46 +92,48 @@ const iconProps = {
63
92
  required: true
64
93
  },
65
94
  size: {
66
- type: String,
95
+ type: [Number, String],
67
96
  default: "inherit"
68
97
  },
69
98
  color: {
70
99
  type: String,
71
100
  default: "inherit"
72
101
  },
102
+ component: {
103
+ type: Object,
104
+ default: null
105
+ },
73
106
  classPrefix: {
74
107
  type: String,
75
- default: "icon"
108
+ default: DEFAULT_PREFIX
109
+ },
110
+ operable: {
111
+ type: Boolean,
112
+ default: false
113
+ },
114
+ disabled: {
115
+ type: Boolean,
116
+ default: false
117
+ },
118
+ rotate: {
119
+ type: [Number, String]
76
120
  }
77
121
  };
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
- };
122
+ const svgIconProps = {
123
+ name: {
124
+ type: String,
125
+ default: "",
126
+ required: true
127
+ },
128
+ color: {
129
+ type: String,
130
+ default: "inherit"
131
+ },
132
+ size: {
133
+ type: [Number, String],
134
+ default: "inherit"
104
135
  }
105
- });
136
+ };
106
137
  function createBem(namespace, element, modifier) {
107
138
  let cls = namespace;
108
139
  if (element) {
@@ -113,8 +144,8 @@ function createBem(namespace, element, modifier) {
113
144
  }
114
145
  return cls;
115
146
  }
116
- function useNamespace(block) {
117
- const namespace = `devui-${block}`;
147
+ function useNamespace(block, needDot = false) {
148
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
118
149
  const b = () => createBem(namespace);
119
150
  const e = (element) => element ? createBem(namespace, element) : "";
120
151
  const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
@@ -126,130 +157,221 @@ function useNamespace(block) {
126
157
  em
127
158
  };
128
159
  }
129
- var baseOverlay = "";
130
- function _isSlot(s) {
131
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
160
+ var icon = "";
161
+ var svgIcon = defineComponent({
162
+ name: "DSvgIcon",
163
+ props: svgIconProps,
164
+ setup(props) {
165
+ const {
166
+ name,
167
+ color,
168
+ size
169
+ } = toRefs(props);
170
+ const ns = useNamespace("svg-icon");
171
+ const iconName = computed(() => `#icon-${name.value}`);
172
+ const iconSize = computed(() => {
173
+ return typeof size.value === "number" ? `${size.value}px` : size.value;
174
+ });
175
+ const styles = {
176
+ width: iconSize.value,
177
+ height: iconSize.value
178
+ };
179
+ return () => {
180
+ return createVNode("svg", {
181
+ "class": ns.b(),
182
+ "style": styles
183
+ }, [createVNode("use", {
184
+ "xlink:href": iconName.value,
185
+ "fill": color.value
186
+ }, null)]);
187
+ };
188
+ }
189
+ });
190
+ function isUrl(value) {
191
+ return /^((http|https):)?\/\//.test(value);
192
+ }
193
+ function useIconDom(props, ctx) {
194
+ const {
195
+ component,
196
+ name,
197
+ size,
198
+ color,
199
+ classPrefix,
200
+ rotate
201
+ } = toRefs(props);
202
+ const ns = useNamespace("icon");
203
+ const iconSize = computed(() => {
204
+ return typeof size.value === "number" ? `${size.value}px` : size.value;
205
+ });
206
+ const IconComponent = component.value ? resolveDynamicComponent(component.value) : resolveDynamicComponent(svgIcon);
207
+ const imgIconDom = () => {
208
+ return createVNode("img", mergeProps({
209
+ "src": name.value,
210
+ "alt": name.value.split("/")[name.value.split("/").length - 1],
211
+ "class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
212
+ "style": {
213
+ width: iconSize.value || "",
214
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`,
215
+ verticalAlign: "middle"
216
+ }
217
+ }, ctx.attrs), null);
218
+ };
219
+ const svgIconDom = () => {
220
+ return createVNode(IconComponent, mergeProps({
221
+ "name": name.value,
222
+ "color": color.value,
223
+ "size": iconSize.value,
224
+ "class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
225
+ "style": {
226
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
227
+ }
228
+ }, ctx.attrs), null);
229
+ };
230
+ const fontIconDom = () => {
231
+ const fontIconClass = /^icon-/.test(name.value) ? name.value : `${classPrefix.value}-${name.value}`;
232
+ return createVNode("i", mergeProps({
233
+ "class": [classPrefix.value, fontIconClass, (rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
234
+ "style": {
235
+ fontSize: iconSize.value,
236
+ color: color.value,
237
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
238
+ }
239
+ }, ctx.attrs), null);
240
+ };
241
+ const iconDom = () => {
242
+ return component.value ? svgIconDom() : isUrl(name.value) ? imgIconDom() : fontIconDom();
243
+ };
244
+ return {
245
+ iconDom
246
+ };
132
247
  }
133
- const CommonOverlay = defineComponent({
248
+ var Icon = defineComponent({
249
+ name: "DIcon",
250
+ props: iconProps,
251
+ emits: ["click"],
134
252
  setup(props, ctx) {
135
- const ns = useNamespace("overlay");
253
+ const {
254
+ disabled,
255
+ operable
256
+ } = toRefs(props);
257
+ const {
258
+ iconDom
259
+ } = useIconDom(props, ctx);
260
+ const ns = useNamespace("icon");
261
+ const wrapClassed = computed(() => ({
262
+ [ns.e("container")]: true,
263
+ [ns.m("disabled")]: disabled.value,
264
+ [ns.m("operable")]: operable.value,
265
+ [ns.m("no-slots")]: !Object.keys(ctx.slots).length
266
+ }));
267
+ const onClick = (e) => {
268
+ if (disabled.value) {
269
+ return;
270
+ }
271
+ ctx.emit("click", e);
272
+ };
136
273
  return () => {
137
- let _slot;
138
- return createVNode(Teleport, {
139
- "to": "#d-overlay-anchor"
140
- }, {
141
- default: () => [createVNode(Transition, {
142
- "name": ns.e("fade")
143
- }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
144
- default: () => [_slot]
145
- })]
146
- });
274
+ var _a, _b, _c, _d;
275
+ return createVNode("div", {
276
+ "class": wrapClassed.value,
277
+ "onClick": onClick
278
+ }, [(_b = (_a = ctx.slots).prefix) == null ? void 0 : _b.call(_a), iconDom(), (_d = (_c = ctx.slots).suffix) == null ? void 0 : _d.call(_c)]);
147
279
  };
148
280
  }
149
281
  });
150
- const overlayProps = {
151
- visible: {
152
- type: Boolean
153
- },
154
- backgroundBlock: {
282
+ var iconGroup = "";
283
+ defineComponent({
284
+ name: "DIconGroup",
285
+ setup(_, ctx) {
286
+ const ns = useNamespace("icon-group");
287
+ return () => {
288
+ var _a, _b;
289
+ return createVNode("div", {
290
+ "class": ns.b()
291
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
292
+ };
293
+ }
294
+ });
295
+ const fixedOverlayProps = {
296
+ modelValue: {
155
297
  type: Boolean,
156
298
  default: false
157
299
  },
158
- backgroundClass: {
159
- type: String,
160
- default: ""
161
- },
162
- backgroundStyle: {
163
- type: [String, Object]
164
- },
165
- onBackdropClick: {
166
- type: Function
167
- },
168
- backdropClose: {
300
+ lockScroll: {
169
301
  type: Boolean,
170
302
  default: true
171
303
  },
172
- hasBackdrop: {
304
+ closeOnClickOverlay: {
173
305
  type: Boolean,
174
306
  default: true
175
307
  }
176
308
  };
177
- const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
178
- overlayStyle: {
179
- type: [String, Object],
180
- default: void 0
309
+ function lockScroll() {
310
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
311
+ const scrollTop = document.documentElement.scrollTop;
312
+ const style = document.documentElement.getAttribute("style");
313
+ document.documentElement.style.position = "fixed";
314
+ document.documentElement.style.top = `-${scrollTop}px`;
315
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
316
+ document.documentElement.style.overflowY = "scroll";
317
+ return () => {
318
+ if (style) {
319
+ document.documentElement.setAttribute("style", style);
320
+ } else {
321
+ document.documentElement.removeAttribute("style");
322
+ }
323
+ document.documentElement.scrollTop = scrollTop;
324
+ };
181
325
  }
182
- });
183
- const overlayEmits = ["update:visible", "backdropClick"];
184
- function useOverlayLogic(props, ctx) {
185
- const ns = useNamespace("overlay");
186
- const backgroundClass = computed(() => {
187
- return [ns.e("background"), props.backgroundClass, !props.hasBackdrop ? ns.em("background", "disabled") : ns.em("background", "color")];
188
- });
189
- const overlayClass = computed(() => {
190
- return ns.b();
191
- });
192
- const handleBackdropClick = (event) => {
193
- var _a;
326
+ return;
327
+ }
328
+ function useFixedOverlay(props, ctx) {
329
+ let lockScrollCb;
330
+ const onClick = (event) => {
194
331
  event.preventDefault();
195
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
196
- if (props.backdropClose) {
197
- ctx.emit("update:visible", false);
332
+ ctx.emit("click", event);
333
+ if (props.closeOnClickOverlay) {
334
+ ctx.emit("update:modelValue", false);
198
335
  }
199
336
  };
200
- const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
201
- onMounted(() => {
202
- const body = document.body;
203
- const originOverflow = body.style.overflow;
204
- const originPosition = body.style.position;
205
- watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
206
- if (backgroundBlock) {
207
- const top = body.getBoundingClientRect().y;
208
- if (visible) {
209
- body.style.overflowY = "scroll";
210
- body.style.position = visible ? "fixed" : "";
211
- body.style.top = `${top}px`;
212
- } else {
213
- body.style.overflowY = originOverflow;
214
- body.style.position = originPosition;
215
- body.style.top = "";
216
- window.scrollTo(0, -top);
217
- }
218
- }
219
- });
220
- onUnmounted(() => {
221
- document.body.style.overflow = originOverflow;
222
- });
223
- });
224
- return {
225
- backgroundClass,
226
- overlayClass,
227
- handleBackdropClick,
228
- handleOverlayBubbleCancel
337
+ const removeBodyAdditions = () => {
338
+ lockScrollCb == null ? void 0 : lockScrollCb();
229
339
  };
340
+ watch(() => props.modelValue, (val) => {
341
+ if (val) {
342
+ props.lockScroll && (lockScrollCb = lockScroll());
343
+ } else {
344
+ removeBodyAdditions();
345
+ }
346
+ });
347
+ onUnmounted(removeBodyAdditions);
348
+ return { onClick };
230
349
  }
231
350
  var fixedOverlay = "";
232
351
  const FixedOverlay = defineComponent({
233
352
  name: "DFixedOverlay",
353
+ inheritAttrs: false,
234
354
  props: fixedOverlayProps,
235
- emits: overlayEmits,
355
+ emits: ["update:modelValue", "click"],
236
356
  setup(props, ctx) {
237
357
  const {
238
- backgroundClass,
239
- overlayClass,
240
- handleBackdropClick,
241
- handleOverlayBubbleCancel
242
- } = useOverlayLogic(props, ctx);
243
- return () => createVNode(CommonOverlay, null, {
244
- default: () => [props.visible && createVNode("div", {
245
- "class": backgroundClass.value,
246
- "style": props.backgroundStyle,
247
- "onClick": handleBackdropClick
248
- }, [createVNode("div", {
249
- "class": overlayClass.value,
250
- "style": props.overlayStyle,
251
- "onClick": handleOverlayBubbleCancel
252
- }, [renderSlot(ctx.slots, "default")])])]
358
+ modelValue
359
+ } = toRefs(props);
360
+ const ns = useNamespace("fixed-overlay");
361
+ const {
362
+ onClick
363
+ } = useFixedOverlay(props, ctx);
364
+ return () => createVNode(Transition, {
365
+ "name": ns.m("fade")
366
+ }, {
367
+ default: () => {
368
+ var _a, _b;
369
+ return [modelValue.value && createVNode("div", mergeProps({
370
+ "class": ns.b()
371
+ }, ctx.attrs, {
372
+ "onClick": onClick
373
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
374
+ }
253
375
  });
254
376
  }
255
377
  });
@@ -284,6 +406,10 @@ const flexibleOverlayProps = {
284
406
  isArrowCenter: {
285
407
  type: Boolean,
286
408
  default: true
409
+ },
410
+ clickEventBubble: {
411
+ type: Boolean,
412
+ default: false
287
413
  }
288
414
  };
289
415
  function getScrollParent(element) {
@@ -398,6 +524,9 @@ defineComponent({
398
524
  expose
399
525
  }) {
400
526
  const ns = useNamespace("flexible-overlay");
527
+ const {
528
+ clickEventBubble
529
+ } = toRefs(props);
401
530
  const {
402
531
  arrowRef,
403
532
  overlayRef,
@@ -411,7 +540,10 @@ defineComponent({
411
540
  return props.modelValue && createVNode("div", mergeProps({
412
541
  "ref": overlayRef,
413
542
  "class": ns.b()
414
- }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
543
+ }, attrs, {
544
+ "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
545
+ "onPointerup": withModifiers(() => ({}), ["stop"])
546
+ }), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
415
547
  "ref": arrowRef,
416
548
  "class": ns.e("arrow")
417
549
  }, null)]);
@@ -423,13 +555,113 @@ function useModal(props, emit) {
423
555
  function close() {
424
556
  emit("update:modelValue", false);
425
557
  }
426
- function handleVisibleChange(val) {
427
- if (!val) {
428
- props.beforeClose ? props.beforeClose(close) : close();
558
+ function execClose() {
559
+ props.beforeClose ? props.beforeClose(close) : close();
560
+ }
561
+ function onKeydown(event) {
562
+ if (event.code === "Escape") {
563
+ execClose();
429
564
  }
430
565
  }
431
- return { handleVisibleChange };
566
+ onMounted(() => {
567
+ if (props.escapable) {
568
+ window.addEventListener("keydown", onKeydown);
569
+ }
570
+ });
571
+ onUnmounted(() => {
572
+ if (props.escapable) {
573
+ window.addEventListener("keydown", onKeydown);
574
+ }
575
+ });
576
+ return { execClose };
432
577
  }
578
+ function useModalRender(props) {
579
+ let lockScrollCb;
580
+ const removeBodyAdditions = () => {
581
+ lockScrollCb == null ? void 0 : lockScrollCb();
582
+ };
583
+ watch(() => props.modelValue, (val) => {
584
+ if (val) {
585
+ props.lockScroll && (lockScrollCb = lockScroll());
586
+ } else {
587
+ removeBodyAdditions();
588
+ }
589
+ }, {
590
+ immediate: true
591
+ });
592
+ onUnmounted(removeBodyAdditions);
593
+ }
594
+ function addUnit(value, defaultUnit = "px") {
595
+ if (!value) {
596
+ return "";
597
+ }
598
+ if (typeof value === "string") {
599
+ return value;
600
+ } else if (typeof value === "number") {
601
+ return `${value}${defaultUnit}`;
602
+ } else {
603
+ return "";
604
+ }
605
+ }
606
+ const useDraggable = (targetRef, dragRef, draggable) => {
607
+ let transform = {
608
+ offsetX: 0,
609
+ offsetY: 0
610
+ };
611
+ const onMousedown = (e) => {
612
+ const downX = e.clientX;
613
+ const downY = e.clientY;
614
+ const { offsetX, offsetY } = transform;
615
+ const targetRect = targetRef.value.getBoundingClientRect();
616
+ const targetLeft = targetRect.left;
617
+ const targetTop = targetRect.top;
618
+ const targetWidth = targetRect.width;
619
+ const targetHeight = targetRect.height;
620
+ const clientWidth = document.documentElement.clientWidth;
621
+ const clientHeight = document.documentElement.clientHeight;
622
+ const minLeft = -targetLeft + offsetX;
623
+ const minTop = -targetTop + offsetY;
624
+ const maxLeft = clientWidth - targetLeft - targetWidth + offsetX;
625
+ const maxTop = clientHeight - targetTop - targetHeight + offsetY;
626
+ const onMousemove = (ev) => {
627
+ const moveX = Math.min(Math.max(offsetX + ev.clientX - downX, minLeft), maxLeft);
628
+ const moveY = Math.min(Math.max(offsetY + ev.clientY - downY, minTop), maxTop);
629
+ transform = {
630
+ offsetX: moveX,
631
+ offsetY: moveY
632
+ };
633
+ targetRef.value.style.transform = `translate(${addUnit(moveX)}, ${addUnit(moveY)})`;
634
+ };
635
+ const onMouseup = () => {
636
+ document.removeEventListener("mousemove", onMousemove);
637
+ document.removeEventListener("mouseup", onMouseup);
638
+ };
639
+ document.addEventListener("mousemove", onMousemove);
640
+ document.addEventListener("mouseup", onMouseup);
641
+ };
642
+ const onDraggable = () => {
643
+ if (dragRef.value && targetRef.value) {
644
+ dragRef.value.addEventListener("mousedown", onMousedown);
645
+ }
646
+ };
647
+ const offDraggable = () => {
648
+ if (dragRef.value && targetRef.value) {
649
+ dragRef.value.removeEventListener("mousedown", onMousedown);
650
+ }
651
+ };
652
+ onMounted(() => {
653
+ watchEffect(() => {
654
+ if (draggable.value) {
655
+ onDraggable();
656
+ } else {
657
+ offDraggable();
658
+ }
659
+ });
660
+ });
661
+ onBeforeUnmount(() => {
662
+ offDraggable();
663
+ });
664
+ };
433
665
  var Header = defineComponent({
434
666
  name: "DModalHeader",
435
667
  setup(props, {
@@ -467,55 +699,101 @@ var Modal = defineComponent({
467
699
  setup(props, {
468
700
  slots,
469
701
  attrs,
470
- emit,
471
- expose
702
+ emit
472
703
  }) {
473
704
  const ns = useNamespace("modal");
474
705
  const {
475
706
  modelValue,
476
- lockScroll,
477
- closeOnClickOverlay,
478
- title
707
+ title,
708
+ showClose,
709
+ showOverlay,
710
+ appendToBody,
711
+ closeOnClickOverlay
479
712
  } = toRefs(props);
480
713
  const {
481
- handleVisibleChange
714
+ execClose
482
715
  } = useModal(props, emit);
483
- expose({
484
- handleVisibleChange
485
- });
486
- return () => {
487
- const fixedOverlayProps2 = {
488
- visible: modelValue.value,
489
- "onUpdate:visible": handleVisibleChange,
490
- "background-class": ns.e("mask"),
491
- "background-block": lockScroll.value,
492
- "backdrop-close": closeOnClickOverlay.value
493
- };
494
- return createVNode(FixedOverlay, fixedOverlayProps2, {
495
- default: () => [createVNode(Transition, {
496
- "name": ns.m("wipe")
497
- }, {
498
- default: () => {
499
- var _a;
500
- return [createVNode("div", mergeProps({
501
- "class": ns.b()
502
- }, attrs), [createVNode(Icon, {
503
- "name": "close",
504
- "class": "btn-close",
505
- "size": "var(--devui-font-size-md,12px)",
506
- "onClick": () => handleVisibleChange(false)
507
- }, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
508
- default: () => [title.value]
509
- }), createVNode(Body, null, {
510
- default: () => {
511
- var _a2;
512
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
513
- }
514
- }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
515
- }
516
- })]
716
+ useModalRender(props);
717
+ const dialogRef = ref();
718
+ const headerRef = ref();
719
+ const draggable = computed(() => props.draggable);
720
+ useDraggable(dialogRef, headerRef, draggable);
721
+ const renderType = () => {
722
+ const typeList = [{
723
+ type: "success",
724
+ text: "\u6210\u529F",
725
+ icon: "right-o"
726
+ }, {
727
+ type: "failed",
728
+ text: "\u9519\u8BEF",
729
+ icon: "error-o"
730
+ }, {
731
+ type: "warning",
732
+ text: "\u8B66\u544A",
733
+ icon: "warning-o"
734
+ }, {
735
+ type: "info",
736
+ text: "\u4FE1\u606F",
737
+ icon: "info-o"
738
+ }];
739
+ const item = typeList.find((i) => i.type === props.type);
740
+ return createVNode(Header, null, {
741
+ default: () => [createVNode("div", {
742
+ "class": "type-content"
743
+ }, [createVNode("div", {
744
+ "class": "type-content-icon"
745
+ }, [createVNode(Icon, {
746
+ "name": item == null ? void 0 : item.icon
747
+ }, null)]), createVNode("div", {
748
+ "class": "type-content-text"
749
+ }, [item == null ? void 0 : item.text])])]
517
750
  });
518
751
  };
752
+ return () => createVNode(Teleport, {
753
+ "to": "body",
754
+ "disabled": !appendToBody.value
755
+ }, {
756
+ default: () => [showOverlay.value && createVNode(FixedOverlay, {
757
+ "modelValue": modelValue.value,
758
+ "onUpdate:modelValue": execClose,
759
+ "class": ns.e("overlay"),
760
+ "lock-scroll": false,
761
+ "close-on-click-overlay": closeOnClickOverlay.value,
762
+ "style": {
763
+ zIndex: "calc(var(--devui-z-index-modal, 1050) - 1)"
764
+ }
765
+ }, null), createVNode(Transition, {
766
+ "name": props.showAnimation ? ns.m("wipe") : ""
767
+ }, {
768
+ default: () => {
769
+ var _a;
770
+ return [modelValue.value && createVNode("div", mergeProps({
771
+ "ref": dialogRef,
772
+ "class": ns.b()
773
+ }, attrs, {
774
+ "onClick": (e) => e.stopPropagation()
775
+ }), [showClose.value && createVNode("div", {
776
+ "onClick": execClose,
777
+ "class": "btn-close"
778
+ }, [createVNode(Icon, {
779
+ "name": "close",
780
+ "size": "20px"
781
+ }, null)]), props.type ? renderType() : createVNode("div", {
782
+ "style": {
783
+ cursor: props.draggable ? "move" : "default"
784
+ },
785
+ "ref": headerRef
786
+ }, [slots.header ? slots.header() : title.value && createVNode(Header, null, {
787
+ default: () => [title.value]
788
+ })]), createVNode(Body, null, {
789
+ default: () => {
790
+ var _a2;
791
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
792
+ }
793
+ }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
794
+ }
795
+ })]
796
+ });
519
797
  }
520
798
  });
521
799
  var Footer = defineComponent({