vue-devui 1.0.0-rc.1 → 1.0.0-rc.10

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 (328) hide show
  1. package/README.md +149 -200
  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 +8166 -287
  6. package/auto-complete/index.umd.js +29 -1
  7. package/auto-complete/style.css +1 -1
  8. package/avatar/index.es.js +153 -146
  9. package/avatar/index.umd.js +1 -1
  10. package/avatar/style.css +1 -1
  11. package/badge/index.es.js +29 -4
  12. package/badge/index.umd.js +1 -1
  13. package/badge/style.css +1 -1
  14. package/button/index.es.js +5726 -111
  15. package/button/index.umd.js +27 -1
  16. package/button/style.css +1 -1
  17. package/card/index.es.js +59 -35
  18. package/card/index.umd.js +1 -1
  19. package/card/style.css +1 -1
  20. package/checkbox/index.es.js +8060 -255
  21. package/checkbox/index.umd.js +27 -1
  22. package/checkbox/style.css +1 -1
  23. package/{accordion → collapse}/index.d.ts +0 -0
  24. package/collapse/index.es.js +379 -0
  25. package/collapse/index.umd.js +1 -0
  26. package/{anchor → collapse}/package.json +1 -1
  27. package/collapse/style.css +1 -0
  28. package/countdown/index.es.js +3 -6
  29. package/countdown/index.umd.js +1 -1
  30. package/date-picker/index.es.js +8130 -242
  31. package/date-picker/index.umd.js +27 -1
  32. package/date-picker/style.css +1 -1
  33. package/drawer/index.es.js +31 -4
  34. package/drawer/index.umd.js +1 -1
  35. package/drawer/style.css +1 -1
  36. package/dropdown/index.es.js +209 -148
  37. package/dropdown/index.umd.js +1 -1
  38. package/dropdown/style.css +1 -1
  39. package/editable-select/index.es.js +521 -153
  40. package/editable-select/index.umd.js +1 -1
  41. package/editable-select/style.css +1 -1
  42. package/form/index.es.js +1040 -1187
  43. package/form/index.umd.js +16 -16
  44. package/form/style.css +1 -1
  45. package/fullscreen/index.es.js +29 -5
  46. package/fullscreen/index.umd.js +1 -1
  47. package/fullscreen/style.css +1 -1
  48. package/grid/index.es.js +101 -86
  49. package/grid/index.umd.js +1 -1
  50. package/grid/style.css +1 -1
  51. package/icon/index.es.js +182 -23
  52. package/icon/index.umd.js +1 -1
  53. package/icon/style.css +1 -0
  54. package/image-preview/index.es.js +53 -30
  55. package/image-preview/index.umd.js +1 -1
  56. package/image-preview/style.css +1 -1
  57. package/input/index.es.js +8066 -144
  58. package/input/index.umd.js +27 -1
  59. package/input/style.css +1 -1
  60. package/input-number/index.es.js +274 -177
  61. package/input-number/index.umd.js +1 -1
  62. package/input-number/style.css +1 -1
  63. package/layout/index.es.js +40 -25
  64. package/layout/index.umd.js +1 -1
  65. package/layout/style.css +1 -1
  66. package/loading/index.es.js +74 -35
  67. package/loading/index.umd.js +1 -1
  68. package/loading/style.css +1 -1
  69. package/modal/index.es.js +374 -171
  70. package/modal/index.umd.js +1 -1
  71. package/modal/style.css +1 -1
  72. package/notification/index.es.js +292 -40
  73. package/notification/index.umd.js +1 -1
  74. package/notification/style.css +1 -1
  75. package/nuxt/components/ButtonGroup.js +3 -0
  76. package/nuxt/components/CheckboxButton.js +3 -0
  77. package/nuxt/components/CheckboxGroup.js +3 -0
  78. package/nuxt/components/Collapse.js +3 -0
  79. package/nuxt/components/CollapseItem.js +3 -0
  80. package/nuxt/components/DropdownPropsKey.js +3 -0
  81. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  82. package/nuxt/components/FORM_TOKEN.js +3 -0
  83. package/nuxt/components/Icon.js +1 -0
  84. package/nuxt/components/IconGroup.js +3 -0
  85. package/nuxt/components/LABEL_DATA.js +3 -0
  86. package/nuxt/components/LoadingOptions.js +3 -0
  87. package/nuxt/components/Option.js +3 -0
  88. package/nuxt/components/RadioButton.js +3 -0
  89. package/nuxt/components/Tab.js +3 -0
  90. package/nuxt/components/autoCompleteProps.js +3 -0
  91. package/nuxt/components/avatarProps.js +3 -0
  92. package/nuxt/components/buttonGroupInjectionKey.js +3 -0
  93. package/nuxt/components/buttonGroupProps.js +3 -0
  94. package/nuxt/components/cardProps.js +3 -0
  95. package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
  96. package/nuxt/components/checkboxGroupProps.js +3 -0
  97. package/nuxt/components/checkboxProps.js +3 -0
  98. package/nuxt/components/colProps.js +3 -0
  99. package/nuxt/components/colPropsBaseClass.js +3 -0
  100. package/nuxt/components/colPropsBaseStyle.js +3 -0
  101. package/nuxt/components/collapseItemProps.js +3 -0
  102. package/nuxt/components/collapseProps.js +3 -0
  103. package/nuxt/components/countdownProps.js +3 -0
  104. package/nuxt/components/editableSelectProps.js +3 -0
  105. package/nuxt/components/formItemProps.js +3 -0
  106. package/nuxt/components/formProps.js +3 -0
  107. package/nuxt/components/iconProps.js +1 -0
  108. package/nuxt/components/imagePreviewProps.js +3 -0
  109. package/nuxt/components/inputProps.js +3 -0
  110. package/nuxt/components/loadingProps.js +3 -0
  111. package/nuxt/components/modalProps.js +3 -0
  112. package/nuxt/components/progressProps.js +3 -0
  113. package/nuxt/components/rateProps.js +3 -0
  114. package/nuxt/components/resultProps.js +3 -0
  115. package/nuxt/components/rowProps.js +3 -0
  116. package/nuxt/components/screenSizes.js +3 -0
  117. package/nuxt/components/skeletonProps.js +3 -0
  118. package/nuxt/components/sliderProps.js +3 -0
  119. package/nuxt/components/splitterProps.js +3 -0
  120. package/nuxt/components/statisticProps.js +3 -0
  121. package/nuxt/components/svgIconProps.js +3 -0
  122. package/nuxt/components/switchProps.js +3 -0
  123. package/nuxt/components/tabsProps.js +3 -0
  124. package/nuxt/components/tagProps.js +3 -0
  125. package/nuxt/components/textareaProps.js +3 -0
  126. package/nuxt/components/timeAxisProps.js +3 -0
  127. package/nuxt/components/treeProps.js +3 -0
  128. package/overlay/index.es.js +104 -133
  129. package/overlay/index.umd.js +1 -1
  130. package/overlay/style.css +1 -1
  131. package/package.json +3 -2
  132. package/pagination/index.es.js +148 -136
  133. package/pagination/index.umd.js +1 -1
  134. package/pagination/style.css +1 -1
  135. package/panel/style.css +1 -1
  136. package/popover/index.es.js +294 -230
  137. package/popover/index.umd.js +15 -15
  138. package/popover/style.css +1 -1
  139. package/progress/index.es.js +110 -56
  140. package/progress/index.umd.js +3 -3
  141. package/progress/style.css +1 -1
  142. package/radio/index.es.js +7959 -146
  143. package/radio/index.umd.js +27 -1
  144. package/radio/style.css +1 -1
  145. package/rate/index.es.js +77 -55
  146. package/rate/index.umd.js +1 -1
  147. package/rate/style.css +1 -1
  148. package/result/index.es.js +169 -27
  149. package/result/index.umd.js +1 -1
  150. package/result/style.css +1 -1
  151. package/ripple/index.es.js +43 -42
  152. package/ripple/index.umd.js +1 -1
  153. package/search/index.es.js +3620 -1095
  154. package/search/index.umd.js +18 -18
  155. package/search/style.css +1 -1
  156. package/select/index.es.js +9131 -584
  157. package/select/index.umd.js +27 -1
  158. package/select/style.css +1 -1
  159. package/skeleton/index.es.js +46 -24
  160. package/skeleton/index.umd.js +1 -1
  161. package/skeleton/style.css +1 -1
  162. package/slider/index.es.js +108 -75
  163. package/slider/index.umd.js +1 -1
  164. package/slider/style.css +1 -1
  165. package/splitter/index.es.js +443 -335
  166. package/splitter/index.umd.js +15 -15
  167. package/splitter/style.css +1 -1
  168. package/statistic/index.es.js +7 -18
  169. package/statistic/index.umd.js +1 -1
  170. package/status/index.es.js +26 -2
  171. package/status/index.umd.js +1 -1
  172. package/status/style.css +1 -1
  173. package/style.css +1 -1
  174. package/switch/index.es.js +7794 -64
  175. package/switch/index.umd.js +27 -1
  176. package/switch/style.css +1 -1
  177. package/table/index.es.js +10038 -1180
  178. package/table/index.umd.js +27 -1
  179. package/table/style.css +1 -1
  180. package/tabs/index.es.js +342 -141
  181. package/tabs/index.umd.js +1 -1
  182. package/tabs/style.css +1 -1
  183. package/tag/index.es.js +47 -23
  184. package/tag/index.umd.js +1 -1
  185. package/tag/style.css +1 -1
  186. package/textarea/index.es.js +7913 -83
  187. package/textarea/index.umd.js +35 -1
  188. package/textarea/style.css +1 -1
  189. package/timeline/index.es.js +176 -37
  190. package/timeline/index.umd.js +1 -1
  191. package/timeline/style.css +1 -1
  192. package/tooltip/index.es.js +285 -220
  193. package/tooltip/index.umd.js +15 -15
  194. package/tooltip/style.css +1 -1
  195. package/tree/index.es.js +4190 -1857
  196. package/tree/index.umd.js +18 -18
  197. package/tree/style.css +1 -1
  198. package/upload/index.es.js +365 -106
  199. package/upload/index.umd.js +1 -1
  200. package/upload/style.css +1 -1
  201. package/vue-devui.es.js +20102 -25264
  202. package/vue-devui.umd.js +25 -15
  203. package/accordion/index.es.js +0 -723
  204. package/accordion/index.umd.js +0 -1
  205. package/accordion/package.json +0 -7
  206. package/accordion/style.css +0 -1
  207. package/anchor/index.d.ts +0 -7
  208. package/anchor/index.es.js +0 -263
  209. package/anchor/index.umd.js +0 -1
  210. package/anchor/style.css +0 -1
  211. package/back-top/index.d.ts +0 -7
  212. package/back-top/index.es.js +0 -130
  213. package/back-top/index.umd.js +0 -1
  214. package/back-top/package.json +0 -7
  215. package/back-top/style.css +0 -1
  216. package/breadcrumb/index.d.ts +0 -7
  217. package/breadcrumb/index.es.js +0 -128
  218. package/breadcrumb/index.umd.js +0 -1
  219. package/breadcrumb/package.json +0 -7
  220. package/breadcrumb/style.css +0 -1
  221. package/carousel/index.d.ts +0 -7
  222. package/carousel/index.es.js +0 -314
  223. package/carousel/index.umd.js +0 -1
  224. package/carousel/package.json +0 -7
  225. package/carousel/style.css +0 -1
  226. package/cascader/index.d.ts +0 -7
  227. package/cascader/index.es.js +0 -5971
  228. package/cascader/index.umd.js +0 -27
  229. package/cascader/package.json +0 -7
  230. package/cascader/style.css +0 -1
  231. package/color-picker/index.d.ts +0 -7
  232. package/color-picker/index.es.js +0 -8196
  233. package/color-picker/index.umd.js +0 -27
  234. package/color-picker/package.json +0 -7
  235. package/color-picker/style.css +0 -1
  236. package/comment/index.d.ts +0 -7
  237. package/comment/index.es.js +0 -86
  238. package/comment/index.umd.js +0 -1
  239. package/comment/package.json +0 -7
  240. package/comment/style.css +0 -1
  241. package/dragdrop/index.d.ts +0 -7
  242. package/dragdrop/index.es.js +0 -157
  243. package/dragdrop/index.umd.js +0 -1
  244. package/dragdrop/package.json +0 -7
  245. package/gantt/index.d.ts +0 -7
  246. package/gantt/index.es.js +0 -523
  247. package/gantt/index.umd.js +0 -1
  248. package/gantt/package.json +0 -7
  249. package/gantt/style.css +0 -1
  250. package/input-icon/index.d.ts +0 -7
  251. package/input-icon/index.es.js +0 -332
  252. package/input-icon/index.umd.js +0 -1
  253. package/input-icon/package.json +0 -7
  254. package/input-icon/style.css +0 -1
  255. package/list/index.d.ts +0 -7
  256. package/list/index.es.js +0 -39
  257. package/list/index.umd.js +0 -1
  258. package/list/package.json +0 -7
  259. package/list/style.css +0 -1
  260. package/nav-sprite/index.d.ts +0 -7
  261. package/nav-sprite/index.es.js +0 -68
  262. package/nav-sprite/index.umd.js +0 -1
  263. package/nav-sprite/package.json +0 -7
  264. package/nuxt/components/Accordion.js +0 -3
  265. package/nuxt/components/Anchor.js +0 -3
  266. package/nuxt/components/BackTop.js +0 -3
  267. package/nuxt/components/Breadcrumb.js +0 -3
  268. package/nuxt/components/Carousel.js +0 -3
  269. package/nuxt/components/CarouselItem.js +0 -3
  270. package/nuxt/components/Cascader.js +0 -3
  271. package/nuxt/components/ColorPicker.js +0 -3
  272. package/nuxt/components/Comment.js +0 -3
  273. package/nuxt/components/FormControl.js +0 -3
  274. package/nuxt/components/FormLabel.js +0 -3
  275. package/nuxt/components/Gantt.js +0 -3
  276. package/nuxt/components/InputIcon.js +0 -3
  277. package/nuxt/components/List.js +0 -3
  278. package/nuxt/components/ListItem.js +0 -3
  279. package/nuxt/components/NavSprite.js +0 -2
  280. package/nuxt/components/QuadrantDiagram.js +0 -3
  281. package/nuxt/components/ReadTip.js +0 -3
  282. package/nuxt/components/StepsGuide.js +0 -3
  283. package/nuxt/components/Sticky.js +0 -2
  284. package/nuxt/components/TagInput.js +0 -3
  285. package/nuxt/components/TimePicker.js +0 -3
  286. package/nuxt/components/Transfer.js +0 -3
  287. package/nuxt/components/TreeSelect.js +0 -3
  288. package/nuxt/components/overlayEmits.js +0 -3
  289. package/nuxt/components/overlayProps.js +0 -3
  290. package/quadrant-diagram/index.d.ts +0 -7
  291. package/quadrant-diagram/index.es.js +0 -5728
  292. package/quadrant-diagram/index.umd.js +0 -27
  293. package/quadrant-diagram/package.json +0 -7
  294. package/quadrant-diagram/style.css +0 -1
  295. package/read-tip/index.d.ts +0 -7
  296. package/read-tip/index.es.js +0 -261
  297. package/read-tip/index.umd.js +0 -1
  298. package/read-tip/package.json +0 -7
  299. package/read-tip/style.css +0 -1
  300. package/steps-guide/index.d.ts +0 -7
  301. package/steps-guide/index.es.js +0 -242
  302. package/steps-guide/index.umd.js +0 -1
  303. package/steps-guide/package.json +0 -7
  304. package/steps-guide/style.css +0 -1
  305. package/sticky/index.d.ts +0 -7
  306. package/sticky/index.es.js +0 -197
  307. package/sticky/index.umd.js +0 -1
  308. package/sticky/package.json +0 -7
  309. package/tag-input/index.d.ts +0 -7
  310. package/tag-input/index.es.js +0 -331
  311. package/tag-input/index.umd.js +0 -1
  312. package/tag-input/package.json +0 -7
  313. package/tag-input/style.css +0 -1
  314. package/time-picker/index.d.ts +0 -7
  315. package/time-picker/index.es.js +0 -1238
  316. package/time-picker/index.umd.js +0 -1
  317. package/time-picker/package.json +0 -7
  318. package/time-picker/style.css +0 -1
  319. package/transfer/index.d.ts +0 -7
  320. package/transfer/index.es.js +0 -7615
  321. package/transfer/index.umd.js +0 -27
  322. package/transfer/package.json +0 -7
  323. package/transfer/style.css +0 -1
  324. package/tree-select/index.d.ts +0 -7
  325. package/tree-select/index.es.js +0 -627
  326. package/tree-select/index.umd.js +0 -1
  327. package/tree-select/package.json +0 -7
  328. package/tree-select/style.css +0 -1
package/modal/index.es.js CHANGED
@@ -33,8 +33,8 @@ 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";
37
- import { shift, offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
36
+ import { defineComponent, toRefs, computed, createVNode, resolveDynamicComponent, mergeProps, watch, onUnmounted, Transition, ref, unref, nextTick, onMounted, Teleport, h, render } from "vue";
37
+ import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
38
38
  const modalProps = {
39
39
  modelValue: {
40
40
  type: Boolean,
@@ -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,283 @@ 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
+ }
204
+ }, ctx.attrs), null);
205
+ };
206
+ const svgIconDom = () => {
207
+ return createVNode(IconComponent, mergeProps({
208
+ "name": name.value,
209
+ "color": color.value,
210
+ "size": iconSize.value,
211
+ "class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
212
+ "style": {
213
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
214
+ }
215
+ }, ctx.attrs), null);
216
+ };
217
+ const fontIconDom = () => {
218
+ const fontIconClass = /^icon-/.test(name.value) ? name.value : `${classPrefix.value}-${name.value}`;
219
+ return createVNode("i", mergeProps({
220
+ "class": [classPrefix.value, fontIconClass, (rotate == null ? void 0 : rotate.value) === "infinite" && ns.m("spin")],
221
+ "style": {
222
+ fontSize: iconSize.value,
223
+ color: color.value,
224
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
225
+ }
226
+ }, ctx.attrs), null);
227
+ };
228
+ const iconDom = () => {
229
+ return component.value ? svgIconDom() : isUrl(name.value) ? imgIconDom() : fontIconDom();
230
+ };
231
+ return {
232
+ iconDom
233
+ };
234
+ }
235
+ var Icon = defineComponent({
236
+ name: "DIcon",
237
+ props: iconProps,
111
238
  setup(props, ctx) {
239
+ const {
240
+ disabled,
241
+ operable
242
+ } = toRefs(props);
243
+ const {
244
+ iconDom
245
+ } = useIconDom(props, ctx);
246
+ const ns = useNamespace("icon");
247
+ const wrapClassed = computed(() => ({
248
+ [ns.e("container")]: true,
249
+ [ns.m("disabled")]: disabled.value,
250
+ [ns.m("operable")]: operable.value
251
+ }));
252
+ const onClick = (e) => {
253
+ if (disabled.value) {
254
+ e.preventDefault();
255
+ e.stopImmediatePropagation();
256
+ }
257
+ };
112
258
  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
- });
259
+ var _a, _b, _c, _d;
260
+ return createVNode("div", {
261
+ "class": wrapClassed.value,
262
+ "onClick": onClick
263
+ }, [(_b = (_a = ctx.slots).prefix) == null ? void 0 : _b.call(_a), iconDom(), (_d = (_c = ctx.slots).suffix) == null ? void 0 : _d.call(_c)]);
123
264
  };
124
265
  }
125
266
  });
126
- const overlayProps = {
127
- visible: {
128
- type: Boolean
129
- },
130
- backgroundBlock: {
267
+ var iconGroup = "";
268
+ defineComponent({
269
+ name: "DIconGroup",
270
+ setup(_, ctx) {
271
+ const ns = useNamespace("icon-group");
272
+ return () => {
273
+ var _a, _b;
274
+ return createVNode("div", {
275
+ "class": ns.b()
276
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
277
+ };
278
+ }
279
+ });
280
+ const fixedOverlayProps = {
281
+ modelValue: {
131
282
  type: Boolean,
132
283
  default: false
133
284
  },
134
- backgroundClass: {
135
- type: String,
136
- default: ""
137
- },
138
- backgroundStyle: {
139
- type: [String, Object]
140
- },
141
- onBackdropClick: {
142
- type: Function
143
- },
144
- backdropClose: {
285
+ lockScroll: {
145
286
  type: Boolean,
146
287
  default: true
147
288
  },
148
- hasBackdrop: {
289
+ closeOnClickOverlay: {
149
290
  type: Boolean,
150
291
  default: true
151
292
  }
152
293
  };
153
- const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
154
- overlayStyle: {
155
- type: [String, Object],
156
- default: void 0
294
+ function lockScroll() {
295
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
296
+ const scrollTop = document.documentElement.scrollTop;
297
+ const style = document.documentElement.getAttribute("style");
298
+ document.documentElement.style.position = "fixed";
299
+ document.documentElement.style.top = `-${scrollTop}px`;
300
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
301
+ document.documentElement.style.overflowY = "scroll";
302
+ return () => {
303
+ if (style) {
304
+ document.documentElement.setAttribute("style", style);
305
+ } else {
306
+ document.documentElement.removeAttribute("style");
307
+ }
308
+ document.documentElement.scrollTop = scrollTop;
309
+ };
157
310
  }
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;
311
+ return;
312
+ }
313
+ function useFixedOverlay(props, ctx) {
314
+ let lockScrollCb;
315
+ const onClick = (event) => {
173
316
  event.preventDefault();
174
- (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
175
- if (props.backdropClose) {
176
- ctx.emit("update:visible", false);
317
+ ctx.emit("click", event);
318
+ if (props.closeOnClickOverlay) {
319
+ ctx.emit("update:modelValue", false);
177
320
  }
178
321
  };
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
322
+ const removeBodyAdditions = () => {
323
+ lockScrollCb == null ? void 0 : lockScrollCb();
208
324
  };
325
+ watch(() => props.modelValue, (val) => {
326
+ if (val) {
327
+ props.lockScroll && (lockScrollCb = lockScroll());
328
+ } else {
329
+ removeBodyAdditions();
330
+ }
331
+ });
332
+ onUnmounted(removeBodyAdditions);
333
+ return { onClick };
209
334
  }
210
335
  var fixedOverlay = "";
211
336
  const FixedOverlay = defineComponent({
212
337
  name: "DFixedOverlay",
338
+ inheritAttrs: false,
213
339
  props: fixedOverlayProps,
214
- emits: overlayEmits,
340
+ emits: ["update:modelValue", "click"],
215
341
  setup(props, ctx) {
216
342
  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")])])]
343
+ modelValue
344
+ } = toRefs(props);
345
+ const ns = useNamespace("fixed-overlay");
346
+ const {
347
+ onClick
348
+ } = useFixedOverlay(props, ctx);
349
+ return () => createVNode(Transition, {
350
+ "name": ns.m("fade")
351
+ }, {
352
+ default: () => {
353
+ var _a, _b;
354
+ return [modelValue.value && createVNode("div", mergeProps({
355
+ "class": ns.b()
356
+ }, ctx.attrs, {
357
+ "onClick": onClick
358
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
359
+ }
232
360
  });
233
361
  }
234
362
  });
@@ -249,6 +377,9 @@ const flexibleOverlayProps = {
249
377
  type: [Number, Object],
250
378
  default: 8
251
379
  },
380
+ shiftOffset: {
381
+ type: Number
382
+ },
252
383
  align: {
253
384
  type: String,
254
385
  default: null
@@ -294,6 +425,7 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
294
425
  function useOverlay(props, emit) {
295
426
  const overlayRef = ref();
296
427
  const arrowRef = ref();
428
+ let originParent = null;
297
429
  const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
298
430
  const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
299
431
  const staticSide = {
@@ -315,7 +447,6 @@ function useOverlay(props, emit) {
315
447
  const overlayEl = unref(overlayRef.value);
316
448
  const arrowEl = unref(arrowRef.value);
317
449
  const middleware = [
318
- shift(),
319
450
  offset(props.offset),
320
451
  autoPlacement({
321
452
  alignment: props.align,
@@ -323,30 +454,39 @@ function useOverlay(props, emit) {
323
454
  })
324
455
  ];
325
456
  props.showArrow && middleware.push(arrow({ element: arrowEl }));
457
+ props.shiftOffset !== void 0 && middleware.push(shift());
326
458
  const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
327
459
  strategy: "fixed",
328
460
  middleware
329
461
  });
462
+ let applyX = x;
463
+ let applyY = y;
464
+ if (props.shiftOffset !== void 0) {
465
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
466
+ shiftX < 0 && (applyX -= props.shiftOffset);
467
+ shiftX > 0 && (applyX += props.shiftOffset);
468
+ shiftY < 0 && (applyY -= props.shiftOffset);
469
+ shiftY > 0 && (applyY += props.shiftOffset);
470
+ }
330
471
  emit("positionChange", placement);
331
- Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
472
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
332
473
  props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
333
474
  };
334
475
  watch(() => props.modelValue, () => {
335
- const originParent = getScrollParent(props.origin);
336
476
  if (props.modelValue && props.origin) {
477
+ originParent = getScrollParent(props.origin);
337
478
  nextTick(updatePosition);
338
- originParent.addEventListener("scroll", updatePosition);
479
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
339
480
  originParent !== window && window.addEventListener("scroll", updatePosition);
340
481
  window.addEventListener("resize", updatePosition);
341
482
  } else {
342
- originParent.removeEventListener("scroll", updatePosition);
483
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
343
484
  originParent !== window && window.removeEventListener("scroll", updatePosition);
344
485
  window.removeEventListener("resize", updatePosition);
345
486
  }
346
487
  });
347
488
  onUnmounted(() => {
348
- const originParent = getScrollParent(props.origin);
349
- originParent.removeEventListener("scroll", updatePosition);
489
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
350
490
  originParent !== window && window.removeEventListener("scroll", updatePosition);
351
491
  window.removeEventListener("resize", updatePosition);
352
492
  });
@@ -364,6 +504,7 @@ defineComponent({
364
504
  emit,
365
505
  expose
366
506
  }) {
507
+ const ns = useNamespace("flexible-overlay");
367
508
  const {
368
509
  arrowRef,
369
510
  overlayRef,
@@ -376,10 +517,10 @@ defineComponent({
376
517
  var _a;
377
518
  return props.modelValue && createVNode("div", mergeProps({
378
519
  "ref": overlayRef,
379
- "class": "devui-flexible-overlay"
520
+ "class": ns.b()
380
521
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
381
522
  "ref": arrowRef,
382
- "class": "devui-flexible-overlay-arrow"
523
+ "class": ns.e("arrow")
383
524
  }, null)]);
384
525
  };
385
526
  }
@@ -389,22 +530,67 @@ function useModal(props, emit) {
389
530
  function close() {
390
531
  emit("update:modelValue", false);
391
532
  }
392
- function handleVisibleChange(val) {
393
- if (!val) {
394
- props.beforeClose ? props.beforeClose(close) : close();
533
+ function execClose() {
534
+ props.beforeClose ? props.beforeClose(close) : close();
535
+ }
536
+ function onOverlayClick() {
537
+ props.closeOnClickOverlay && execClose();
538
+ }
539
+ function onCloseBtnClick() {
540
+ execClose();
541
+ }
542
+ function onKeydown(event) {
543
+ if (event["keyCode"] === 27) {
544
+ execClose();
395
545
  }
396
546
  }
397
- return { handleVisibleChange };
547
+ onMounted(() => {
548
+ if (props.escapable) {
549
+ window.addEventListener("keydown", onKeydown);
550
+ }
551
+ });
552
+ onUnmounted(() => {
553
+ if (props.escapable) {
554
+ window.addEventListener("keydown", onKeydown);
555
+ }
556
+ });
557
+ return { onCloseBtnClick, onOverlayClick };
558
+ }
559
+ function useModalRender(props) {
560
+ const showContainer = ref(false);
561
+ const showModal = ref(false);
562
+ let lockScrollCb;
563
+ const removeBodyAdditions = () => {
564
+ lockScrollCb == null ? void 0 : lockScrollCb();
565
+ };
566
+ watch(() => props.modelValue, (val) => {
567
+ if (val) {
568
+ props.lockScroll && (lockScrollCb = lockScroll());
569
+ showContainer.value = true;
570
+ nextTick(() => {
571
+ showModal.value = true;
572
+ });
573
+ } else {
574
+ removeBodyAdditions();
575
+ showModal.value = false;
576
+ setTimeout(() => {
577
+ showContainer.value = false;
578
+ }, 100);
579
+ }
580
+ });
581
+ onUnmounted(removeBodyAdditions);
582
+ return { showContainer, showModal };
398
583
  }
399
584
  var Header = defineComponent({
400
585
  name: "DModalHeader",
401
586
  setup(props, {
402
587
  slots
403
588
  }) {
589
+ const ns = useNamespace("modal");
404
590
  return () => {
405
591
  var _a;
406
592
  return createVNode("div", {
407
- "class": "devui-modal-header"
593
+ "class": ns.e("header")
408
594
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
409
595
  };
410
596
  }
@@ -414,10 +600,11 @@ var Body = defineComponent({
414
600
  setup(props, {
415
601
  slots
416
602
  }) {
603
+ const ns = useNamespace("modal");
417
604
  return () => {
418
605
  var _a;
419
606
  return createVNode("div", {
420
- "class": "devui-modal-body"
607
+ "class": ns.e("body")
421
608
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
422
609
  };
423
610
  }
@@ -431,40 +618,50 @@ var Modal = defineComponent({
431
618
  setup(props, {
432
619
  slots,
433
620
  attrs,
434
- emit,
435
- expose
621
+ emit
436
622
  }) {
623
+ const ns = useNamespace("modal");
437
624
  const {
438
625
  modelValue,
439
- lockScroll,
440
- closeOnClickOverlay,
441
- title
626
+ title,
627
+ showClose,
628
+ showOverlay,
629
+ appendToBody
442
630
  } = toRefs(props);
443
631
  const {
444
- handleVisibleChange
632
+ onCloseBtnClick,
633
+ onOverlayClick
445
634
  } = useModal(props, emit);
446
- expose({
447
- handleVisibleChange
448
- });
449
- return () => createVNode(FixedOverlay, {
450
- "visible": modelValue.value,
451
- "onUpdate:visible": handleVisibleChange,
452
- "background-class": "devui-modal-mask",
453
- "background-block": lockScroll.value,
454
- "backdrop-close": closeOnClickOverlay.value
635
+ const {
636
+ showContainer,
637
+ showModal
638
+ } = useModalRender(props);
639
+ return () => createVNode(Teleport, {
640
+ "to": "body",
641
+ "disabled": !appendToBody.value
455
642
  }, {
456
- default: () => [createVNode(Transition, {
457
- "name": "devui-modal-wipe"
643
+ default: () => [showOverlay.value && createVNode(FixedOverlay, {
644
+ "modelValue": modelValue.value,
645
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
646
+ "lock-scroll": false,
647
+ "style": {
648
+ zIndex: "calc(var(--devui-z-index-modal, 1050) - 1)"
649
+ }
650
+ }, null), showContainer.value && createVNode("div", {
651
+ "class": ns.e("container"),
652
+ "onClick": onOverlayClick
653
+ }, [createVNode(Transition, {
654
+ "name": ns.m("wipe")
458
655
  }, {
459
656
  default: () => {
460
657
  var _a;
461
- return [createVNode("div", mergeProps({
462
- "class": "devui-modal"
463
- }, attrs), [createVNode(Icon, {
658
+ return [showModal.value && createVNode("div", mergeProps({
659
+ "class": ns.b()
660
+ }, attrs), [showClose.value && createVNode(Icon, {
464
661
  "name": "close",
465
662
  "class": "btn-close",
466
663
  "size": "var(--devui-font-size-md,12px)",
467
- "onClick": () => handleVisibleChange(false)
664
+ "onClick": onCloseBtnClick
468
665
  }, null), slots.header ? slots.header() : title.value && createVNode(Header, null, {
469
666
  default: () => [title.value]
470
667
  }), createVNode(Body, null, {
@@ -474,7 +671,7 @@ var Modal = defineComponent({
474
671
  }
475
672
  }), (_a = slots.footer) == null ? void 0 : _a.call(slots)])];
476
673
  }
477
- })]
674
+ })])]
478
675
  });
479
676
  }
480
677
  });
@@ -483,10 +680,11 @@ var Footer = defineComponent({
483
680
  setup(props, {
484
681
  slots
485
682
  }) {
683
+ const ns = useNamespace("modal");
486
684
  return () => {
487
685
  var _a;
488
686
  return createVNode("div", {
489
- "class": "devui-modal-footer"
687
+ "class": ns.e("footer")
490
688
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
491
689
  };
492
690
  }
@@ -515,31 +713,36 @@ class ModalService extends CommonModalService {
515
713
  const anchor = document.createElement("div");
516
714
  this.anchorContainer.appendChild(anchor);
517
715
  const _a = props, { header, content, footer } = _a, resProps = __objRest(_a, ["header", "content", "footer"]);
518
- const needHideOrNot = (value) => {
519
- if (!value) {
520
- hide();
521
- }
522
- };
523
- const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
524
- return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
716
+ const renderOrigin = (propsValue, onUpdateModelValue) => {
717
+ return this.renderModal(anchor, __spreadProps(__spreadValues({}, propsValue), {
525
718
  modelValue: true,
526
719
  "onUpdate:modelValue": onUpdateModelValue
527
720
  }), { header, default: content, footer });
528
721
  };
529
722
  const hide = () => {
530
- var _a2, _b;
723
+ var _a2, _b, _c;
724
+ const innerNeedHideOrNot = (value) => {
725
+ if (!value) {
726
+ hide();
727
+ }
728
+ };
531
729
  renderOrigin(resProps, (value) => {
532
730
  if (!value) {
533
731
  this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
534
732
  this.renderNull(anchor);
535
733
  } else {
536
- renderOrigin(resProps);
734
+ renderOrigin(resProps, innerNeedHideOrNot);
537
735
  }
538
736
  });
539
- (_b = (_a2 = vm.component.exposed).handleVisibleChange) == null ? void 0 : _b.call(_a2, false);
737
+ (_c = (_b = (_a2 = vm == null ? void 0 : vm.component) == null ? void 0 : _a2.exposed) == null ? void 0 : _b.handleVisibleChange) == null ? void 0 : _c.call(_b, false);
738
+ };
739
+ const needHideOrNot = (value) => {
740
+ if (!value) {
741
+ hide();
742
+ }
540
743
  };
541
744
  this.renderModal(anchor, { modelValue: false });
542
- vm = renderOrigin(resProps);
745
+ vm = renderOrigin(resProps, needHideOrNot);
543
746
  return { hide };
544
747
  }
545
748
  }
@@ -565,4 +768,4 @@ var index = {
565
768
  app.provide(ModalService.token, new ModalService(anchorsContainer));
566
769
  }
567
770
  };
568
- export { Modal, index as default };
771
+ export { Modal, index as default, modalProps };