vue-devui 1.0.0-rc.7 → 1.0.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 (231) hide show
  1. package/README.md +163 -146
  2. package/alert/index.es.js +46 -15
  3. package/alert/index.umd.js +1 -1
  4. package/alert/style.css +1 -1
  5. package/auto-complete/index.es.js +8230 -231
  6. package/auto-complete/index.umd.js +29 -5
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +81 -70
  9. package/avatar/index.umd.js +1 -1
  10. package/avatar/style.css +1 -1
  11. package/badge/index.es.js +34 -4
  12. package/badge/index.umd.js +1 -1
  13. package/badge/style.css +1 -1
  14. package/button/index.es.js +5706 -98
  15. package/button/index.umd.js +27 -1
  16. package/button/style.css +1 -1
  17. package/card/index.es.js +38 -13
  18. package/card/index.umd.js +1 -1
  19. package/card/style.css +1 -1
  20. package/checkbox/index.es.js +8066 -245
  21. package/checkbox/index.umd.js +27 -1
  22. package/checkbox/style.css +1 -1
  23. package/{date-picker → collapse}/index.d.ts +0 -0
  24. package/collapse/index.es.js +213 -0
  25. package/collapse/index.umd.js +1 -0
  26. package/{date-picker → collapse}/package.json +1 -1
  27. package/collapse/style.css +1 -0
  28. package/countdown/index.es.js +56 -13
  29. package/countdown/index.umd.js +1 -1
  30. package/date-picker-pro/index.d.ts +7 -0
  31. package/date-picker-pro/index.es.js +12020 -0
  32. package/date-picker-pro/index.umd.js +27 -0
  33. package/date-picker-pro/package.json +7 -0
  34. package/date-picker-pro/style.css +1 -0
  35. package/drawer/index.es.js +29 -4
  36. package/drawer/index.umd.js +1 -1
  37. package/drawer/style.css +1 -1
  38. package/dropdown/index.es.js +178 -142
  39. package/dropdown/index.umd.js +1 -1
  40. package/dropdown/style.css +1 -1
  41. package/editable-select/index.es.js +742 -107
  42. package/editable-select/index.umd.js +1 -1
  43. package/editable-select/style.css +1 -1
  44. package/form/index.es.js +544 -316
  45. package/form/index.umd.js +17 -17
  46. package/form/style.css +1 -1
  47. package/fullscreen/index.es.js +28 -4
  48. package/fullscreen/index.umd.js +1 -1
  49. package/fullscreen/style.css +1 -1
  50. package/grid/index.es.js +71 -50
  51. package/grid/index.umd.js +1 -1
  52. package/grid/style.css +1 -1
  53. package/icon/index.es.js +184 -23
  54. package/icon/index.umd.js +1 -1
  55. package/icon/style.css +1 -0
  56. package/image-preview/index.es.js +34 -11
  57. package/image-preview/index.umd.js +1 -1
  58. package/image-preview/style.css +1 -1
  59. package/input/index.es.js +8250 -131
  60. package/input/index.umd.js +27 -1
  61. package/input/style.css +1 -1
  62. package/input-number/index.es.js +275 -203
  63. package/input-number/index.umd.js +1 -1
  64. package/input-number/style.css +1 -1
  65. package/layout/index.es.js +34 -6
  66. package/layout/index.umd.js +1 -1
  67. package/layout/style.css +1 -1
  68. package/loading/index.es.js +34 -10
  69. package/loading/index.umd.js +1 -1
  70. package/loading/style.css +1 -1
  71. package/mention/index.d.ts +7 -0
  72. package/mention/index.es.js +8310 -0
  73. package/mention/index.umd.js +36 -0
  74. package/mention/package.json +7 -0
  75. package/mention/style.css +1 -0
  76. package/menu/index.d.ts +7 -0
  77. package/menu/index.es.js +934 -0
  78. package/menu/index.umd.js +1 -0
  79. package/menu/package.json +7 -0
  80. package/menu/style.css +1 -0
  81. package/message/index.d.ts +7 -0
  82. package/message/index.es.js +538 -0
  83. package/message/index.umd.js +1 -0
  84. package/message/package.json +7 -0
  85. package/message/style.css +1 -0
  86. package/modal/index.es.js +359 -170
  87. package/modal/index.umd.js +1 -1
  88. package/modal/style.css +1 -1
  89. package/notification/index.es.js +236 -65
  90. package/notification/index.umd.js +1 -1
  91. package/notification/style.css +1 -1
  92. package/nuxt/components/ButtonGroup.js +3 -0
  93. package/nuxt/components/CheckboxButton.js +3 -0
  94. package/nuxt/components/Collapse.js +3 -0
  95. package/nuxt/components/CollapseItem.js +3 -0
  96. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  97. package/nuxt/components/DatePickerPro.js +3 -0
  98. package/nuxt/components/Icon.js +1 -0
  99. package/nuxt/components/IconGroup.js +3 -0
  100. package/nuxt/components/LABEL_DATA.js +3 -0
  101. package/nuxt/components/Mention.js +3 -0
  102. package/nuxt/components/Menu.js +3 -0
  103. package/nuxt/components/MenuItem.js +3 -0
  104. package/nuxt/components/Message.js +3 -0
  105. package/nuxt/components/Option.js +3 -0
  106. package/nuxt/components/OptionGroup.js +3 -0
  107. package/nuxt/components/RadioButton.js +3 -0
  108. package/nuxt/components/Step.js +3 -0
  109. package/nuxt/components/Steps.js +3 -0
  110. package/nuxt/components/SubMenu.js +3 -0
  111. package/nuxt/components/TABLE_TOKEN.js +3 -0
  112. package/nuxt/components/TimePicker.js +3 -0
  113. package/nuxt/components/TimeSelect.js +3 -0
  114. package/nuxt/components/animationInjectionKey.js +3 -0
  115. package/nuxt/components/buttonGroupInjectionKey.js +3 -0
  116. package/nuxt/components/buttonGroupProps.js +3 -0
  117. package/nuxt/components/collapseItemProps.js +3 -0
  118. package/nuxt/components/collapseProps.js +3 -0
  119. package/nuxt/components/datePickerProCommonProps.js +3 -0
  120. package/nuxt/components/datePickerProPanelProps.js +3 -0
  121. package/nuxt/components/datePickerProProps.js +3 -0
  122. package/nuxt/components/iconProps.js +1 -0
  123. package/nuxt/components/mentionProps.js +3 -0
  124. package/nuxt/components/messageProps.js +3 -0
  125. package/nuxt/components/roundInjectionKey.js +3 -0
  126. package/nuxt/components/skeletonItemProps.js +3 -0
  127. package/nuxt/components/stepProps.js +3 -0
  128. package/nuxt/components/stepsProps.js +3 -0
  129. package/nuxt/components/svgIconProps.js +3 -0
  130. package/nuxt/components/tableProps.js +3 -0
  131. package/nuxt/components/timerPickerPanelProps.js +3 -0
  132. package/nuxt/components/treeNodeProps.js +3 -0
  133. package/overlay/index.es.js +84 -125
  134. package/overlay/index.umd.js +1 -1
  135. package/overlay/style.css +1 -1
  136. package/package.json +7 -3
  137. package/pagination/index.es.js +234 -39
  138. package/pagination/index.umd.js +1 -1
  139. package/pagination/style.css +1 -1
  140. package/panel/style.css +1 -1
  141. package/popover/index.es.js +274 -220
  142. package/popover/index.umd.js +13 -13
  143. package/popover/style.css +1 -1
  144. package/progress/index.es.js +31 -9
  145. package/progress/index.umd.js +3 -3
  146. package/progress/style.css +1 -1
  147. package/radio/index.es.js +7969 -152
  148. package/radio/index.umd.js +27 -1
  149. package/radio/style.css +1 -1
  150. package/rate/index.es.js +46 -14
  151. package/rate/index.umd.js +1 -1
  152. package/rate/style.css +1 -1
  153. package/result/index.es.js +169 -22
  154. package/result/index.umd.js +1 -1
  155. package/result/style.css +1 -1
  156. package/search/index.es.js +3823 -1090
  157. package/search/index.umd.js +18 -18
  158. package/search/style.css +1 -1
  159. package/select/index.es.js +9186 -478
  160. package/select/index.umd.js +27 -1
  161. package/select/style.css +1 -1
  162. package/skeleton/index.es.js +110 -259
  163. package/skeleton/index.umd.js +1 -1
  164. package/skeleton/style.css +1 -1
  165. package/slider/index.es.js +143 -146
  166. package/slider/index.umd.js +1 -1
  167. package/slider/style.css +1 -1
  168. package/splitter/index.es.js +433 -207
  169. package/splitter/index.umd.js +17 -17
  170. package/splitter/style.css +1 -1
  171. package/statistic/index.es.js +34 -16
  172. package/statistic/index.umd.js +1 -1
  173. package/statistic/style.css +1 -1
  174. package/status/index.es.js +26 -2
  175. package/status/index.umd.js +1 -1
  176. package/status/style.css +1 -1
  177. package/steps/index.d.ts +7 -0
  178. package/steps/index.es.js +386 -0
  179. package/steps/index.umd.js +1 -0
  180. package/steps/package.json +7 -0
  181. package/steps/style.css +1 -0
  182. package/style.css +1 -1
  183. package/switch/index.es.js +7802 -59
  184. package/switch/index.umd.js +27 -1
  185. package/switch/style.css +1 -1
  186. package/table/index.es.js +9769 -919
  187. package/table/index.umd.js +27 -1
  188. package/table/style.css +1 -1
  189. package/tabs/index.es.js +309 -96
  190. package/tabs/index.umd.js +1 -1
  191. package/tabs/style.css +1 -1
  192. package/tag/index.es.js +35 -7
  193. package/tag/index.umd.js +1 -1
  194. package/tag/style.css +1 -1
  195. package/textarea/index.es.js +7922 -78
  196. package/textarea/index.umd.js +35 -1
  197. package/textarea/style.css +1 -1
  198. package/time-picker/index.d.ts +7 -0
  199. package/time-picker/index.es.js +9549 -0
  200. package/time-picker/index.umd.js +27 -0
  201. package/time-picker/package.json +7 -0
  202. package/time-picker/style.css +1 -0
  203. package/time-select/index.d.ts +7 -0
  204. package/time-select/index.es.js +9585 -0
  205. package/time-select/index.umd.js +27 -0
  206. package/time-select/package.json +7 -0
  207. package/time-select/style.css +1 -0
  208. package/timeline/index.es.js +169 -22
  209. package/timeline/index.umd.js +1 -1
  210. package/timeline/style.css +1 -1
  211. package/tooltip/index.es.js +265 -212
  212. package/tooltip/index.umd.js +15 -15
  213. package/tooltip/style.css +1 -1
  214. package/tree/index.es.js +11343 -795
  215. package/tree/index.umd.js +27 -1
  216. package/tree/style.css +1 -1
  217. package/upload/index.es.js +494 -106
  218. package/upload/index.umd.js +1 -1
  219. package/upload/style.css +1 -1
  220. package/vue-devui.es.js +22849 -13614
  221. package/vue-devui.umd.js +30 -23
  222. package/date-picker/index.es.js +0 -1145
  223. package/date-picker/index.umd.js +0 -1
  224. package/date-picker/style.css +0 -1
  225. package/nuxt/components/DatePicker.js +0 -3
  226. package/nuxt/components/FormControl.js +0 -3
  227. package/nuxt/components/FormLabel.js +0 -3
  228. package/nuxt/components/StickSlider.js +0 -3
  229. package/nuxt/components/formControlProps.js +0 -3
  230. package/nuxt/components/overlayEmits.js +0 -3
  231. 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, onMounted, Teleport, h, render } from "vue";
37
37
  import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
38
38
  const modalProps = {
39
39
  modelValue: {
@@ -54,8 +54,25 @@ const modalProps = {
54
54
  },
55
55
  beforeClose: {
56
56
  type: Function
57
+ },
58
+ escapable: {
59
+ type: Boolean,
60
+ default: true
61
+ },
62
+ showClose: {
63
+ type: Boolean,
64
+ default: true
65
+ },
66
+ showOverlay: {
67
+ type: Boolean,
68
+ default: true
69
+ },
70
+ appendToBody: {
71
+ type: Boolean,
72
+ default: true
57
73
  }
58
74
  };
75
+ const DEFAULT_PREFIX = "icon";
59
76
  const iconProps = {
60
77
  name: {
61
78
  type: String,
@@ -63,172 +80,285 @@ const iconProps = {
63
80
  required: true
64
81
  },
65
82
  size: {
66
- type: String,
83
+ type: [Number, String],
67
84
  default: "inherit"
68
85
  },
69
86
  color: {
70
87
  type: String,
71
88
  default: "inherit"
72
89
  },
90
+ component: {
91
+ type: Object,
92
+ default: null
93
+ },
73
94
  classPrefix: {
74
95
  type: String,
75
- default: "icon"
96
+ default: DEFAULT_PREFIX
97
+ },
98
+ operable: {
99
+ type: Boolean,
100
+ default: false
101
+ },
102
+ disabled: {
103
+ type: Boolean,
104
+ default: false
105
+ },
106
+ rotate: {
107
+ type: [Number, String]
76
108
  }
77
109
  };
78
- var Icon = defineComponent({
79
- name: "DIcon",
80
- props: iconProps,
110
+ const svgIconProps = {
111
+ name: {
112
+ type: String,
113
+ default: "",
114
+ required: true
115
+ },
116
+ color: {
117
+ type: String,
118
+ default: "inherit"
119
+ },
120
+ size: {
121
+ type: [Number, String],
122
+ default: "inherit"
123
+ }
124
+ };
125
+ function createBem(namespace, element, modifier) {
126
+ let cls = namespace;
127
+ if (element) {
128
+ cls += `__${element}`;
129
+ }
130
+ if (modifier) {
131
+ cls += `--${modifier}`;
132
+ }
133
+ return cls;
134
+ }
135
+ function useNamespace(block, needDot = false) {
136
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
137
+ const b = () => createBem(namespace);
138
+ const e = (element) => element ? createBem(namespace, element) : "";
139
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
140
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
141
+ return {
142
+ b,
143
+ e,
144
+ m,
145
+ em
146
+ };
147
+ }
148
+ var icon = "";
149
+ var svgIcon = defineComponent({
150
+ name: "DSvgIcon",
151
+ props: svgIconProps,
81
152
  setup(props) {
82
153
  const {
83
154
  name,
84
- size,
85
155
  color,
86
- classPrefix
156
+ size
87
157
  } = toRefs(props);
158
+ const ns = useNamespace("svg-icon");
159
+ const iconName = computed(() => `#icon-${name.value}`);
160
+ const iconSize = computed(() => {
161
+ return typeof size.value === "number" ? `${size.value}px` : size.value;
162
+ });
163
+ const styles = {
164
+ width: iconSize.value,
165
+ height: iconSize.value
166
+ };
88
167
  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);
168
+ return createVNode("svg", {
169
+ "class": ns.b(),
170
+ "style": styles
171
+ }, [createVNode("use", {
172
+ "xlink:href": iconName.value,
173
+ "fill": color.value
174
+ }, null)]);
103
175
  };
104
176
  }
105
177
  });
106
- var baseOverlay = "";
107
- function _isSlot(s) {
108
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
178
+ function isUrl(value) {
179
+ return /^((http|https):)?\/\//.test(value);
109
180
  }
110
- const CommonOverlay = defineComponent({
181
+ function useIconDom(props, ctx) {
182
+ const {
183
+ component,
184
+ name,
185
+ size,
186
+ color,
187
+ classPrefix,
188
+ rotate
189
+ } = toRefs(props);
190
+ const ns = useNamespace("icon");
191
+ const iconSize = computed(() => {
192
+ return typeof size.value === "number" ? `${size.value}px` : size.value;
193
+ });
194
+ const IconComponent = component.value ? resolveDynamicComponent(component.value) : resolveDynamicComponent(svgIcon);
195
+ const imgIconDom = () => {
196
+ return createVNode("img", mergeProps({
197
+ "src": name.value,
198
+ "alt": name.value.split("/")[name.value.split("/").length - 1],
199
+ "class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
200
+ "style": {
201
+ width: iconSize.value || "",
202
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`,
203
+ verticalAlign: "middle"
204
+ }
205
+ }, ctx.attrs), null);
206
+ };
207
+ const svgIconDom = () => {
208
+ return createVNode(IconComponent, mergeProps({
209
+ "name": name.value,
210
+ "color": color.value,
211
+ "size": iconSize.value,
212
+ "class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
213
+ "style": {
214
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
215
+ }
216
+ }, ctx.attrs), null);
217
+ };
218
+ const fontIconDom = () => {
219
+ const fontIconClass = /^icon-/.test(name.value) ? name.value : `${classPrefix.value}-${name.value}`;
220
+ return createVNode("i", mergeProps({
221
+ "class": [classPrefix.value, fontIconClass, (rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
222
+ "style": {
223
+ fontSize: iconSize.value,
224
+ color: color.value,
225
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
226
+ }
227
+ }, ctx.attrs), null);
228
+ };
229
+ const iconDom = () => {
230
+ return component.value ? svgIconDom() : isUrl(name.value) ? imgIconDom() : fontIconDom();
231
+ };
232
+ return {
233
+ iconDom
234
+ };
235
+ }
236
+ var Icon = defineComponent({
237
+ name: "DIcon",
238
+ props: iconProps,
239
+ emits: ["click"],
111
240
  setup(props, ctx) {
241
+ const {
242
+ disabled,
243
+ operable
244
+ } = toRefs(props);
245
+ const {
246
+ iconDom
247
+ } = useIconDom(props, ctx);
248
+ const ns = useNamespace("icon");
249
+ const wrapClassed = computed(() => ({
250
+ [ns.e("container")]: true,
251
+ [ns.m("disabled")]: disabled.value,
252
+ [ns.m("operable")]: operable.value
253
+ }));
254
+ const onClick = (e) => {
255
+ if (disabled.value) {
256
+ return;
257
+ }
258
+ ctx.emit("click", e);
259
+ };
112
260
  return () => {
113
- let _slot;
114
- return createVNode(Teleport, {
115
- "to": "#d-overlay-anchor"
116
- }, {
117
- default: () => [createVNode(Transition, {
118
- "name": "devui-overlay-fade"
119
- }, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
120
- default: () => [_slot]
121
- })]
122
- });
261
+ var _a, _b, _c, _d;
262
+ return createVNode("div", {
263
+ "class": wrapClassed.value,
264
+ "onClick": onClick
265
+ }, [(_b = (_a = ctx.slots).prefix) == null ? void 0 : _b.call(_a), iconDom(), (_d = (_c = ctx.slots).suffix) == null ? void 0 : _d.call(_c)]);
123
266
  };
124
267
  }
125
268
  });
126
- const overlayProps = {
127
- visible: {
128
- type: Boolean
129
- },
130
- backgroundBlock: {
269
+ var iconGroup = "";
270
+ defineComponent({
271
+ name: "DIconGroup",
272
+ setup(_, ctx) {
273
+ const ns = useNamespace("icon-group");
274
+ return () => {
275
+ var _a, _b;
276
+ return createVNode("div", {
277
+ "class": ns.b()
278
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
279
+ };
280
+ }
281
+ });
282
+ const fixedOverlayProps = {
283
+ modelValue: {
131
284
  type: Boolean,
132
285
  default: false
133
286
  },
134
- backgroundClass: {
135
- type: String,
136
- default: ""
137
- },
138
- backgroundStyle: {
139
- type: [String, Object]
140
- },
141
- onBackdropClick: {
142
- type: Function
143
- },
144
- backdropClose: {
287
+ lockScroll: {
145
288
  type: Boolean,
146
289
  default: true
147
290
  },
148
- hasBackdrop: {
291
+ closeOnClickOverlay: {
149
292
  type: Boolean,
150
293
  default: true
151
294
  }
152
295
  };
153
- const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
154
- overlayStyle: {
155
- type: [String, Object],
156
- default: void 0
296
+ function lockScroll() {
297
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
298
+ const scrollTop = document.documentElement.scrollTop;
299
+ const style = document.documentElement.getAttribute("style");
300
+ document.documentElement.style.position = "fixed";
301
+ document.documentElement.style.top = `-${scrollTop}px`;
302
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
303
+ document.documentElement.style.overflowY = "scroll";
304
+ return () => {
305
+ if (style) {
306
+ document.documentElement.setAttribute("style", style);
307
+ } else {
308
+ document.documentElement.removeAttribute("style");
309
+ }
310
+ document.documentElement.scrollTop = scrollTop;
311
+ };
157
312
  }
158
- });
159
- const overlayEmits = ["update:visible", "backdropClick"];
160
- function useOverlayLogic(props, ctx) {
161
- const backgroundClass = computed(() => {
162
- return [
163
- "devui-overlay-background",
164
- props.backgroundClass,
165
- !props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
166
- ];
167
- });
168
- const overlayClass = computed(() => {
169
- return "devui-overlay";
170
- });
171
- const handleBackdropClick = (event) => {
172
- var _a;
313
+ return;
314
+ }
315
+ function useFixedOverlay(props, ctx) {
316
+ let lockScrollCb;
317
+ const onClick = (event) => {
173
318
  event.preventDefault();
174
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
175
- if (props.backdropClose) {
176
- ctx.emit("update:visible", false);
319
+ ctx.emit("click", event);
320
+ if (props.closeOnClickOverlay) {
321
+ ctx.emit("update:modelValue", false);
177
322
  }
178
323
  };
179
- const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
180
- onMounted(() => {
181
- const body = document.body;
182
- const originOverflow = body.style.overflow;
183
- const originPosition = body.style.position;
184
- watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
185
- if (backgroundBlock) {
186
- const top = body.getBoundingClientRect().y;
187
- if (visible) {
188
- body.style.overflowY = "scroll";
189
- body.style.position = visible ? "fixed" : "";
190
- body.style.top = `${top}px`;
191
- } else {
192
- body.style.overflowY = originOverflow;
193
- body.style.position = originPosition;
194
- body.style.top = "";
195
- window.scrollTo(0, -top);
196
- }
197
- }
198
- });
199
- onUnmounted(() => {
200
- document.body.style.overflow = originOverflow;
201
- });
202
- });
203
- return {
204
- backgroundClass,
205
- overlayClass,
206
- handleBackdropClick,
207
- handleOverlayBubbleCancel
324
+ const removeBodyAdditions = () => {
325
+ lockScrollCb == null ? void 0 : lockScrollCb();
208
326
  };
327
+ watch(() => props.modelValue, (val) => {
328
+ if (val) {
329
+ props.lockScroll && (lockScrollCb = lockScroll());
330
+ } else {
331
+ removeBodyAdditions();
332
+ }
333
+ });
334
+ onUnmounted(removeBodyAdditions);
335
+ return { onClick };
209
336
  }
210
337
  var fixedOverlay = "";
211
338
  const FixedOverlay = defineComponent({
212
339
  name: "DFixedOverlay",
340
+ inheritAttrs: false,
213
341
  props: fixedOverlayProps,
214
- emits: overlayEmits,
342
+ emits: ["update:modelValue", "click"],
215
343
  setup(props, ctx) {
216
344
  const {
217
- backgroundClass,
218
- overlayClass,
219
- handleBackdropClick,
220
- handleOverlayBubbleCancel
221
- } = useOverlayLogic(props, ctx);
222
- return () => createVNode(CommonOverlay, null, {
223
- default: () => [props.visible && createVNode("div", {
224
- "class": backgroundClass.value,
225
- "style": props.backgroundStyle,
226
- "onClick": handleBackdropClick
227
- }, [createVNode("div", {
228
- "class": overlayClass.value,
229
- "style": props.overlayStyle,
230
- "onClick": handleOverlayBubbleCancel
231
- }, [renderSlot(ctx.slots, "default")])])]
345
+ modelValue
346
+ } = toRefs(props);
347
+ const ns = useNamespace("fixed-overlay");
348
+ const {
349
+ onClick
350
+ } = useFixedOverlay(props, ctx);
351
+ return () => createVNode(Transition, {
352
+ "name": ns.m("fade")
353
+ }, {
354
+ default: () => {
355
+ var _a, _b;
356
+ return [modelValue.value && createVNode("div", mergeProps({
357
+ "class": ns.b()
358
+ }, ctx.attrs, {
359
+ "onClick": onClick
360
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
361
+ }
232
362
  });
233
363
  }
234
364
  });
@@ -376,6 +506,7 @@ defineComponent({
376
506
  emit,
377
507
  expose
378
508
  }) {
509
+ const ns = useNamespace("flexible-overlay");
379
510
  const {
380
511
  arrowRef,
381
512
  overlayRef,
@@ -388,10 +519,10 @@ defineComponent({
388
519
  var _a;
389
520
  return props.modelValue && createVNode("div", mergeProps({
390
521
  "ref": overlayRef,
391
- "class": "devui-flexible-overlay"
522
+ "class": ns.b()
392
523
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
393
524
  "ref": arrowRef,
394
- "class": "devui-flexible-overlay-arrow"
525
+ "class": ns.e("arrow")
395
526
  }, null)]);
396
527
  };
397
528
  }
@@ -401,22 +532,69 @@ function useModal(props, emit) {
401
532
  function close() {
402
533
  emit("update:modelValue", false);
403
534
  }
404
- function handleVisibleChange(val) {
405
- if (!val) {
406
- props.beforeClose ? props.beforeClose(close) : close();
535
+ function execClose() {
536
+ props.beforeClose ? props.beforeClose(close) : close();
537
+ }
538
+ function onOverlayClick() {
539
+ props.closeOnClickOverlay && execClose();
540
+ }
541
+ function onCloseBtnClick() {
542
+ execClose();
543
+ }
544
+ function onKeydown(event) {
545
+ if (event["keyCode"] === 27) {
546
+ execClose();
407
547
  }
408
548
  }
409
- return { handleVisibleChange };
549
+ onMounted(() => {
550
+ if (props.escapable) {
551
+ window.addEventListener("keydown", onKeydown);
552
+ }
553
+ });
554
+ onUnmounted(() => {
555
+ if (props.escapable) {
556
+ window.addEventListener("keydown", onKeydown);
557
+ }
558
+ });
559
+ return { onCloseBtnClick, onOverlayClick };
560
+ }
561
+ function useModalRender(props) {
562
+ const showContainer = ref(false);
563
+ const showModal = ref(false);
564
+ let lockScrollCb;
565
+ const removeBodyAdditions = () => {
566
+ lockScrollCb == null ? void 0 : lockScrollCb();
567
+ };
568
+ watch(() => props.modelValue, (val) => {
569
+ if (val) {
570
+ props.lockScroll && (lockScrollCb = lockScroll());
571
+ showContainer.value = true;
572
+ nextTick(() => {
573
+ showModal.value = true;
574
+ });
575
+ } else {
576
+ removeBodyAdditions();
577
+ showModal.value = false;
578
+ setTimeout(() => {
579
+ showContainer.value = false;
580
+ }, 100);
581
+ }
582
+ }, {
583
+ immediate: true
584
+ });
585
+ onUnmounted(removeBodyAdditions);
586
+ return { showContainer, showModal };
410
587
  }
411
588
  var Header = defineComponent({
412
589
  name: "DModalHeader",
413
590
  setup(props, {
414
591
  slots
415
592
  }) {
593
+ const ns = useNamespace("modal");
416
594
  return () => {
417
595
  var _a;
418
596
  return createVNode("div", {
419
- "class": "devui-modal-header"
597
+ "class": ns.e("header")
420
598
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
421
599
  };
422
600
  }
@@ -426,10 +604,11 @@ var Body = defineComponent({
426
604
  setup(props, {
427
605
  slots
428
606
  }) {
607
+ const ns = useNamespace("modal");
429
608
  return () => {
430
609
  var _a;
431
610
  return createVNode("div", {
432
- "class": "devui-modal-body"
611
+ "class": ns.e("body")
433
612
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
434
613
  };
435
614
  }
@@ -443,54 +622,63 @@ var Modal = defineComponent({
443
622
  setup(props, {
444
623
  slots,
445
624
  attrs,
446
- emit,
447
- expose
625
+ emit
448
626
  }) {
627
+ const ns = useNamespace("modal");
449
628
  const {
450
629
  modelValue,
451
- lockScroll,
452
- closeOnClickOverlay,
453
- title
630
+ title,
631
+ showClose,
632
+ showOverlay,
633
+ appendToBody
454
634
  } = toRefs(props);
455
635
  const {
456
- handleVisibleChange
636
+ onCloseBtnClick,
637
+ onOverlayClick
457
638
  } = useModal(props, emit);
458
- expose({
459
- handleVisibleChange
639
+ const {
640
+ showContainer,
641
+ showModal
642
+ } = useModalRender(props);
643
+ return () => createVNode(Teleport, {
644
+ "to": "body",
645
+ "disabled": !appendToBody.value
646
+ }, {
647
+ default: () => [showOverlay.value && createVNode(FixedOverlay, {
648
+ "modelValue": modelValue.value,
649
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
650
+ "lock-scroll": false,
651
+ "style": {
652
+ zIndex: "calc(var(--devui-z-index-modal, 1050) - 1)"
653
+ }
654
+ }, null), showContainer.value && createVNode("div", {
655
+ "class": ns.e("container"),
656
+ "onClick": onOverlayClick
657
+ }, [createVNode(Transition, {
658
+ "name": ns.m("wipe")
659
+ }, {
660
+ default: () => {
661
+ var _a;
662
+ return [showModal.value && createVNode("div", mergeProps({
663
+ "class": ns.b()
664
+ }, attrs, {
665
+ "onClick": (e) => e.stopPropagation()
666
+ }), [showClose.value && createVNode(Icon, {
667
+ "name": "close",
668
+ "class": "btn-close",
669
+ "size": "var(--devui-font-size-md,12px)",
670
+ "onClick": onCloseBtnClick
671
+ }, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
672
+ default: () => [title.value]
673
+ }), createVNode(Body, null, {
674
+ default: () => {
675
+ var _a2;
676
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
677
+ }
678
+ }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
679
+ }
680
+ })])]
460
681
  });
461
- return () => {
462
- const fixedOverlayProps2 = {
463
- visible: modelValue.value,
464
- "onUpdate:visible": handleVisibleChange,
465
- "background-class": "devui-modal-mask",
466
- "background-block": lockScroll.value,
467
- "backdrop-close": closeOnClickOverlay.value
468
- };
469
- return createVNode(FixedOverlay, fixedOverlayProps2, {
470
- default: () => [createVNode(Transition, {
471
- "name": "devui-modal-wipe"
472
- }, {
473
- default: () => {
474
- var _a;
475
- return [createVNode("div", mergeProps({
476
- "class": "devui-modal"
477
- }, attrs), [createVNode(Icon, {
478
- "name": "close",
479
- "class": "btn-close",
480
- "size": "var(--devui-font-size-md,12px)",
481
- "onClick": () => handleVisibleChange(false)
482
- }, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
483
- default: () => [title.value]
484
- }), createVNode(Body, null, {
485
- default: () => {
486
- var _a2;
487
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
488
- }
489
- }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
490
- }
491
- })]
492
- });
493
- };
494
682
  }
495
683
  });
496
684
  var Footer = defineComponent({
@@ -498,10 +686,11 @@ var Footer = defineComponent({
498
686
  setup(props, {
499
687
  slots
500
688
  }) {
689
+ const ns = useNamespace("modal");
501
690
  return () => {
502
691
  var _a;
503
692
  return createVNode("div", {
504
- "class": "devui-modal-footer"
693
+ "class": ns.e("footer")
505
694
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
506
695
  };
507
696
  }