element-plus 1.3.0-beta.8 → 1.3.0-beta.9

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 (287) hide show
  1. package/attributes.json +1 -1
  2. package/dist/index.css +1 -1
  3. package/dist/index.full.js +211 -206
  4. package/dist/index.full.min.js +7 -7
  5. package/dist/index.full.min.js.map +1 -1
  6. package/dist/index.full.min.mjs +7 -7
  7. package/dist/index.full.min.mjs.map +1 -1
  8. package/dist/index.full.mjs +211 -206
  9. package/dist/locale/af.js +1 -1
  10. package/dist/locale/af.min.js +1 -1
  11. package/dist/locale/af.min.mjs +1 -1
  12. package/dist/locale/af.mjs +1 -1
  13. package/dist/locale/ar.js +1 -1
  14. package/dist/locale/ar.min.js +1 -1
  15. package/dist/locale/ar.min.mjs +1 -1
  16. package/dist/locale/ar.mjs +1 -1
  17. package/dist/locale/bg.js +1 -1
  18. package/dist/locale/bg.min.js +1 -1
  19. package/dist/locale/bg.min.mjs +1 -1
  20. package/dist/locale/bg.mjs +1 -1
  21. package/dist/locale/bn.js +1 -1
  22. package/dist/locale/bn.min.js +1 -1
  23. package/dist/locale/bn.min.mjs +1 -1
  24. package/dist/locale/bn.mjs +1 -1
  25. package/dist/locale/ca.js +1 -1
  26. package/dist/locale/ca.min.js +1 -1
  27. package/dist/locale/ca.min.mjs +1 -1
  28. package/dist/locale/ca.mjs +1 -1
  29. package/dist/locale/cs.js +1 -1
  30. package/dist/locale/cs.min.js +1 -1
  31. package/dist/locale/cs.min.mjs +1 -1
  32. package/dist/locale/cs.mjs +1 -1
  33. package/dist/locale/da.js +1 -1
  34. package/dist/locale/da.min.js +1 -1
  35. package/dist/locale/da.min.mjs +1 -1
  36. package/dist/locale/da.mjs +1 -1
  37. package/dist/locale/de.js +1 -1
  38. package/dist/locale/de.min.js +1 -1
  39. package/dist/locale/de.min.mjs +1 -1
  40. package/dist/locale/de.mjs +1 -1
  41. package/dist/locale/el.js +1 -1
  42. package/dist/locale/el.min.js +1 -1
  43. package/dist/locale/el.min.mjs +1 -1
  44. package/dist/locale/el.mjs +1 -1
  45. package/dist/locale/en.js +1 -1
  46. package/dist/locale/en.min.js +1 -1
  47. package/dist/locale/en.min.mjs +1 -1
  48. package/dist/locale/en.mjs +1 -1
  49. package/dist/locale/eo.js +1 -1
  50. package/dist/locale/eo.min.js +1 -1
  51. package/dist/locale/eo.min.mjs +1 -1
  52. package/dist/locale/eo.mjs +1 -1
  53. package/dist/locale/es.js +1 -1
  54. package/dist/locale/es.min.js +1 -1
  55. package/dist/locale/es.min.mjs +1 -1
  56. package/dist/locale/es.mjs +1 -1
  57. package/dist/locale/et.js +1 -1
  58. package/dist/locale/et.min.js +1 -1
  59. package/dist/locale/et.min.mjs +1 -1
  60. package/dist/locale/et.mjs +1 -1
  61. package/dist/locale/eu.js +1 -1
  62. package/dist/locale/eu.min.js +1 -1
  63. package/dist/locale/eu.min.mjs +1 -1
  64. package/dist/locale/eu.mjs +1 -1
  65. package/dist/locale/fa.js +1 -1
  66. package/dist/locale/fa.min.js +1 -1
  67. package/dist/locale/fa.min.mjs +1 -1
  68. package/dist/locale/fa.mjs +1 -1
  69. package/dist/locale/fi.js +1 -1
  70. package/dist/locale/fi.min.js +1 -1
  71. package/dist/locale/fi.min.mjs +1 -1
  72. package/dist/locale/fi.mjs +1 -1
  73. package/dist/locale/fr.js +1 -1
  74. package/dist/locale/fr.min.js +1 -1
  75. package/dist/locale/fr.min.mjs +1 -1
  76. package/dist/locale/fr.mjs +1 -1
  77. package/dist/locale/he.js +1 -1
  78. package/dist/locale/he.min.js +1 -1
  79. package/dist/locale/he.min.mjs +1 -1
  80. package/dist/locale/he.mjs +1 -1
  81. package/dist/locale/hr.js +1 -1
  82. package/dist/locale/hr.min.js +1 -1
  83. package/dist/locale/hr.min.mjs +1 -1
  84. package/dist/locale/hr.mjs +1 -1
  85. package/dist/locale/hu.js +1 -1
  86. package/dist/locale/hu.min.js +1 -1
  87. package/dist/locale/hu.min.mjs +1 -1
  88. package/dist/locale/hu.mjs +1 -1
  89. package/dist/locale/hy-am.js +1 -1
  90. package/dist/locale/hy-am.min.js +1 -1
  91. package/dist/locale/hy-am.min.mjs +1 -1
  92. package/dist/locale/hy-am.mjs +1 -1
  93. package/dist/locale/id.js +1 -1
  94. package/dist/locale/id.min.js +1 -1
  95. package/dist/locale/id.min.mjs +1 -1
  96. package/dist/locale/id.mjs +1 -1
  97. package/dist/locale/it.js +1 -1
  98. package/dist/locale/it.min.js +1 -1
  99. package/dist/locale/it.min.mjs +1 -1
  100. package/dist/locale/it.mjs +1 -1
  101. package/dist/locale/ja.js +1 -1
  102. package/dist/locale/ja.min.js +1 -1
  103. package/dist/locale/ja.min.mjs +1 -1
  104. package/dist/locale/ja.mjs +1 -1
  105. package/dist/locale/kk.js +1 -1
  106. package/dist/locale/kk.min.js +1 -1
  107. package/dist/locale/kk.min.mjs +1 -1
  108. package/dist/locale/kk.mjs +1 -1
  109. package/dist/locale/km.js +1 -1
  110. package/dist/locale/km.min.js +1 -1
  111. package/dist/locale/km.min.mjs +1 -1
  112. package/dist/locale/km.mjs +1 -1
  113. package/dist/locale/ko.js +1 -1
  114. package/dist/locale/ko.min.js +1 -1
  115. package/dist/locale/ko.min.mjs +1 -1
  116. package/dist/locale/ko.mjs +1 -1
  117. package/dist/locale/ku.js +1 -1
  118. package/dist/locale/ku.min.js +1 -1
  119. package/dist/locale/ku.min.mjs +1 -1
  120. package/dist/locale/ku.mjs +1 -1
  121. package/dist/locale/ky.js +1 -1
  122. package/dist/locale/ky.min.js +1 -1
  123. package/dist/locale/ky.min.mjs +1 -1
  124. package/dist/locale/ky.mjs +1 -1
  125. package/dist/locale/lt.js +1 -1
  126. package/dist/locale/lt.min.js +1 -1
  127. package/dist/locale/lt.min.mjs +1 -1
  128. package/dist/locale/lt.mjs +1 -1
  129. package/dist/locale/lv.js +1 -1
  130. package/dist/locale/lv.min.js +1 -1
  131. package/dist/locale/lv.min.mjs +1 -1
  132. package/dist/locale/lv.mjs +1 -1
  133. package/dist/locale/mn.js +1 -1
  134. package/dist/locale/mn.min.js +1 -1
  135. package/dist/locale/mn.min.mjs +1 -1
  136. package/dist/locale/mn.mjs +1 -1
  137. package/dist/locale/nb-no.js +1 -1
  138. package/dist/locale/nb-no.min.js +1 -1
  139. package/dist/locale/nb-no.min.mjs +1 -1
  140. package/dist/locale/nb-no.mjs +1 -1
  141. package/dist/locale/nl.js +1 -1
  142. package/dist/locale/nl.min.js +1 -1
  143. package/dist/locale/nl.min.mjs +1 -1
  144. package/dist/locale/nl.mjs +1 -1
  145. package/dist/locale/pa.js +1 -1
  146. package/dist/locale/pa.min.js +1 -1
  147. package/dist/locale/pa.min.mjs +1 -1
  148. package/dist/locale/pa.mjs +1 -1
  149. package/dist/locale/pl.js +1 -1
  150. package/dist/locale/pl.min.js +1 -1
  151. package/dist/locale/pl.min.mjs +1 -1
  152. package/dist/locale/pl.mjs +1 -1
  153. package/dist/locale/pt-br.js +1 -1
  154. package/dist/locale/pt-br.min.js +1 -1
  155. package/dist/locale/pt-br.min.mjs +1 -1
  156. package/dist/locale/pt-br.mjs +1 -1
  157. package/dist/locale/pt.js +1 -1
  158. package/dist/locale/pt.min.js +1 -1
  159. package/dist/locale/pt.min.mjs +1 -1
  160. package/dist/locale/pt.mjs +1 -1
  161. package/dist/locale/ro.js +1 -1
  162. package/dist/locale/ro.min.js +1 -1
  163. package/dist/locale/ro.min.mjs +1 -1
  164. package/dist/locale/ro.mjs +1 -1
  165. package/dist/locale/ru.js +1 -1
  166. package/dist/locale/ru.min.js +1 -1
  167. package/dist/locale/ru.min.mjs +1 -1
  168. package/dist/locale/ru.mjs +1 -1
  169. package/dist/locale/sk.js +1 -1
  170. package/dist/locale/sk.min.js +1 -1
  171. package/dist/locale/sk.min.mjs +1 -1
  172. package/dist/locale/sk.mjs +1 -1
  173. package/dist/locale/sl.js +1 -1
  174. package/dist/locale/sl.min.js +1 -1
  175. package/dist/locale/sl.min.mjs +1 -1
  176. package/dist/locale/sl.mjs +1 -1
  177. package/dist/locale/sr.js +1 -1
  178. package/dist/locale/sr.min.js +1 -1
  179. package/dist/locale/sr.min.mjs +1 -1
  180. package/dist/locale/sr.mjs +1 -1
  181. package/dist/locale/sv.js +1 -1
  182. package/dist/locale/sv.min.js +1 -1
  183. package/dist/locale/sv.min.mjs +1 -1
  184. package/dist/locale/sv.mjs +1 -1
  185. package/dist/locale/ta.js +1 -1
  186. package/dist/locale/ta.min.js +1 -1
  187. package/dist/locale/ta.min.mjs +1 -1
  188. package/dist/locale/ta.mjs +1 -1
  189. package/dist/locale/th.js +1 -1
  190. package/dist/locale/th.min.js +1 -1
  191. package/dist/locale/th.min.mjs +1 -1
  192. package/dist/locale/th.mjs +1 -1
  193. package/dist/locale/tk.js +1 -1
  194. package/dist/locale/tk.min.js +1 -1
  195. package/dist/locale/tk.min.mjs +1 -1
  196. package/dist/locale/tk.mjs +1 -1
  197. package/dist/locale/tr.js +1 -1
  198. package/dist/locale/tr.min.js +1 -1
  199. package/dist/locale/tr.min.mjs +1 -1
  200. package/dist/locale/tr.mjs +1 -1
  201. package/dist/locale/ug-cn.js +1 -1
  202. package/dist/locale/ug-cn.min.js +1 -1
  203. package/dist/locale/ug-cn.min.mjs +1 -1
  204. package/dist/locale/ug-cn.mjs +1 -1
  205. package/dist/locale/uk.js +1 -1
  206. package/dist/locale/uk.min.js +1 -1
  207. package/dist/locale/uk.min.mjs +1 -1
  208. package/dist/locale/uk.mjs +1 -1
  209. package/dist/locale/uz-uz.js +1 -1
  210. package/dist/locale/uz-uz.min.js +1 -1
  211. package/dist/locale/uz-uz.min.mjs +1 -1
  212. package/dist/locale/uz-uz.mjs +1 -1
  213. package/dist/locale/vi.js +1 -1
  214. package/dist/locale/vi.min.js +1 -1
  215. package/dist/locale/vi.min.mjs +1 -1
  216. package/dist/locale/vi.mjs +1 -1
  217. package/dist/locale/zh-cn.js +1 -1
  218. package/dist/locale/zh-cn.min.js +1 -1
  219. package/dist/locale/zh-cn.min.mjs +1 -1
  220. package/dist/locale/zh-cn.mjs +1 -1
  221. package/dist/locale/zh-tw.js +1 -1
  222. package/dist/locale/zh-tw.min.js +1 -1
  223. package/dist/locale/zh-tw.min.mjs +1 -1
  224. package/dist/locale/zh-tw.mjs +1 -1
  225. package/es/components/carousel/index.d.ts +11 -0
  226. package/es/components/carousel/src/item.mjs +17 -13
  227. package/es/components/carousel/src/item.mjs.map +1 -1
  228. package/es/components/carousel/src/main.mjs +25 -23
  229. package/es/components/carousel/src/main.mjs.map +1 -1
  230. package/es/components/carousel/src/main.vue.d.ts +11 -0
  231. package/es/components/checkbox/index.d.ts +3 -3
  232. package/es/components/checkbox/src/checkbox-button.vue.d.ts +1 -1
  233. package/es/components/checkbox/src/checkbox.vue.d.ts +1 -1
  234. package/es/components/checkbox/src/useCheckbox.d.ts +1 -1
  235. package/es/components/checkbox/src/useCheckbox.mjs +2 -2
  236. package/es/components/checkbox/src/useCheckbox.mjs.map +1 -1
  237. package/es/components/message-box/src/index.mjs +5 -2
  238. package/es/components/message-box/src/index.mjs.map +1 -1
  239. package/es/components/message-box/src/index.vue.d.ts +1 -0
  240. package/es/components/popover/index.d.ts +0 -6
  241. package/es/components/popover/src/index.vue.d.ts +0 -3
  242. package/es/components/popover/src/popover.d.ts +0 -1
  243. package/es/components/popover/src/popover.mjs +0 -4
  244. package/es/components/popover/src/popover.mjs.map +1 -1
  245. package/es/components/transfer/index.d.ts +492 -0
  246. package/es/components/transfer/src/index.mjs +11 -6
  247. package/es/components/transfer/src/index.mjs.map +1 -1
  248. package/es/components/transfer/src/index.vue.d.ts +246 -0
  249. package/es/version.d.ts +1 -1
  250. package/es/version.mjs +1 -1
  251. package/es/version.mjs.map +1 -1
  252. package/lib/components/carousel/index.d.ts +11 -0
  253. package/lib/components/carousel/src/item.js +17 -13
  254. package/lib/components/carousel/src/item.js.map +1 -1
  255. package/lib/components/carousel/src/main.js +25 -23
  256. package/lib/components/carousel/src/main.js.map +1 -1
  257. package/lib/components/carousel/src/main.vue.d.ts +11 -0
  258. package/lib/components/checkbox/index.d.ts +3 -3
  259. package/lib/components/checkbox/src/checkbox-button.vue.d.ts +1 -1
  260. package/lib/components/checkbox/src/checkbox.vue.d.ts +1 -1
  261. package/lib/components/checkbox/src/useCheckbox.d.ts +1 -1
  262. package/lib/components/checkbox/src/useCheckbox.js +2 -2
  263. package/lib/components/checkbox/src/useCheckbox.js.map +1 -1
  264. package/lib/components/message-box/src/index.js +13 -10
  265. package/lib/components/message-box/src/index.js.map +1 -1
  266. package/lib/components/message-box/src/index.vue.d.ts +1 -0
  267. package/lib/components/popover/index.d.ts +0 -6
  268. package/lib/components/popover/src/index.vue.d.ts +0 -3
  269. package/lib/components/popover/src/popover.d.ts +0 -1
  270. package/lib/components/popover/src/popover.js +0 -4
  271. package/lib/components/popover/src/popover.js.map +1 -1
  272. package/lib/components/transfer/index.d.ts +492 -0
  273. package/lib/components/transfer/src/index.js +11 -6
  274. package/lib/components/transfer/src/index.js.map +1 -1
  275. package/lib/components/transfer/src/index.vue.d.ts +246 -0
  276. package/lib/version.d.ts +1 -1
  277. package/lib/version.js +1 -1
  278. package/lib/version.js.map +1 -1
  279. package/package.json +2 -2
  280. package/tags.json +1 -1
  281. package/theme-chalk/el-popper.css +1 -1
  282. package/theme-chalk/el-tooltip.css +0 -1
  283. package/theme-chalk/index.css +1 -1
  284. package/theme-chalk/src/common/var.scss +0 -15
  285. package/theme-chalk/src/popper.scss +20 -2
  286. package/theme-chalk/src/tooltip.scss +0 -95
  287. package/web-types.json +1 -1
@@ -3,8 +3,10 @@ import throttle from 'lodash/throttle';
3
3
  import { addResizeListener, removeResizeListener } from '../../../utils/resize-event.mjs';
4
4
  import { ElIcon } from '../../icon/index.mjs';
5
5
  import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue';
6
+ import '../../../hooks/index.mjs';
6
7
  import { debugWarn } from '../../../utils/error.mjs';
7
8
  import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
9
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
8
10
 
9
11
  const _sfc_main = defineComponent({
10
12
  name: "ElCarousel",
@@ -59,6 +61,7 @@ const _sfc_main = defineComponent({
59
61
  },
60
62
  emits: ["change"],
61
63
  setup(props, { emit }) {
64
+ const ns = useNamespace("carousel");
62
65
  const data = reactive({
63
66
  activeIndex: -1,
64
67
  containerWidth: 0,
@@ -72,22 +75,19 @@ const _sfc_main = defineComponent({
72
75
  return items.value.some((item) => item.label.toString().length > 0);
73
76
  });
74
77
  const carouselClasses = computed(() => {
75
- const classes = ["el-carousel", `el-carousel--${props.direction}`];
78
+ const classes = [ns.b(), ns.m(props.direction)];
76
79
  if (props.type === "card") {
77
- classes.push("el-carousel--card");
80
+ classes.push(ns.m("card"));
78
81
  }
79
82
  return classes;
80
83
  });
81
84
  const indicatorsClasses = computed(() => {
82
- const classes = [
83
- "el-carousel__indicators",
84
- `el-carousel__indicators--${props.direction}`
85
- ];
85
+ const classes = [ns.e("indicators"), ns.em("indicators", props.direction)];
86
86
  if (hasLabel.value) {
87
- classes.push("el-carousel__indicators--labels");
87
+ classes.push(ns.em("indicators", "labels"));
88
88
  }
89
89
  if (props.indicatorPosition === "outside" || props.type === "card") {
90
- classes.push("el-carousel__indicators--outside");
90
+ classes.push(ns.em("indicators", "outside"));
91
91
  }
92
92
  return classes;
93
93
  });
@@ -259,13 +259,13 @@ const _sfc_main = defineComponent({
259
259
  prev,
260
260
  next,
261
261
  setActiveItem,
262
- root
262
+ root,
263
+ ns
263
264
  };
264
265
  }
265
266
  });
266
267
  const _hoisted_1 = ["onMouseenter", "onClick"];
267
- const _hoisted_2 = { class: "el-carousel__button" };
268
- const _hoisted_3 = { key: 0 };
268
+ const _hoisted_2 = { key: 0 };
269
269
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
270
270
  const _component_arrow_left = resolveComponent("arrow-left");
271
271
  const _component_el_icon = resolveComponent("el-icon");
@@ -277,7 +277,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
277
277
  onMouseleave: _cache[7] || (_cache[7] = withModifiers((...args) => _ctx.handleMouseLeave && _ctx.handleMouseLeave(...args), ["stop"]))
278
278
  }, [
279
279
  createElementVNode("div", {
280
- class: "el-carousel__container",
280
+ class: normalizeClass(_ctx.ns.e("container")),
281
281
  style: normalizeStyle({ height: _ctx.height })
282
282
  }, [
283
283
  _ctx.arrowDisplay ? (openBlock(), createBlock(Transition, {
@@ -287,7 +287,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
287
287
  default: withCtx(() => [
288
288
  withDirectives(createElementVNode("button", {
289
289
  type: "button",
290
- class: "el-carousel__arrow el-carousel__arrow--left",
290
+ class: normalizeClass([_ctx.ns.e("arrow"), _ctx.ns.em("arrow", "left")]),
291
291
  onMouseenter: _cache[0] || (_cache[0] = ($event) => _ctx.handleButtonEnter("left")),
292
292
  onMouseleave: _cache[1] || (_cache[1] = (...args) => _ctx.handleButtonLeave && _ctx.handleButtonLeave(...args)),
293
293
  onClick: _cache[2] || (_cache[2] = withModifiers(($event) => _ctx.throttledArrowClick(_ctx.data.activeIndex - 1), ["stop"]))
@@ -298,7 +298,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
298
298
  ]),
299
299
  _: 1
300
300
  })
301
- ], 544), [
301
+ ], 34), [
302
302
  [
303
303
  vShow,
304
304
  (_ctx.arrow === "always" || _ctx.data.hover) && (_ctx.props.loop || _ctx.data.activeIndex > 0)
@@ -314,7 +314,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
314
314
  default: withCtx(() => [
315
315
  withDirectives(createElementVNode("button", {
316
316
  type: "button",
317
- class: "el-carousel__arrow el-carousel__arrow--right",
317
+ class: normalizeClass([_ctx.ns.e("arrow"), _ctx.ns.em("arrow", "right")]),
318
318
  onMouseenter: _cache[3] || (_cache[3] = ($event) => _ctx.handleButtonEnter("right")),
319
319
  onMouseleave: _cache[4] || (_cache[4] = (...args) => _ctx.handleButtonLeave && _ctx.handleButtonLeave(...args)),
320
320
  onClick: _cache[5] || (_cache[5] = withModifiers(($event) => _ctx.throttledArrowClick(_ctx.data.activeIndex + 1), ["stop"]))
@@ -325,7 +325,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
325
325
  ]),
326
326
  _: 1
327
327
  })
328
- ], 544), [
328
+ ], 34), [
329
329
  [
330
330
  vShow,
331
331
  (_ctx.arrow === "always" || _ctx.data.hover) && (_ctx.props.loop || _ctx.data.activeIndex < _ctx.items.length - 1)
@@ -335,7 +335,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
335
335
  _: 1
336
336
  })) : createCommentVNode("v-if", true),
337
337
  renderSlot(_ctx.$slots, "default")
338
- ], 4),
338
+ ], 6),
339
339
  _ctx.indicatorPosition !== "none" ? (openBlock(), createElementBlock("ul", {
340
340
  key: 0,
341
341
  class: normalizeClass(_ctx.indicatorsClasses)
@@ -344,16 +344,18 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
344
344
  return openBlock(), createElementBlock("li", {
345
345
  key: index,
346
346
  class: normalizeClass([
347
- "el-carousel__indicator",
348
- "el-carousel__indicator--" + _ctx.direction,
349
- { "is-active": index === _ctx.data.activeIndex }
347
+ _ctx.ns.e("indicator"),
348
+ _ctx.ns.em("indicator", _ctx.direction),
349
+ _ctx.ns.is("active", index === _ctx.data.activeIndex)
350
350
  ]),
351
351
  onMouseenter: ($event) => _ctx.throttledIndicatorHover(index),
352
352
  onClick: withModifiers(($event) => _ctx.handleIndicatorClick(index), ["stop"])
353
353
  }, [
354
- createElementVNode("button", _hoisted_2, [
355
- _ctx.hasLabel ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(item.label), 1)) : createCommentVNode("v-if", true)
356
- ])
354
+ createElementVNode("button", {
355
+ class: normalizeClass(_ctx.ns.e("button"))
356
+ }, [
357
+ _ctx.hasLabel ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(item.label), 1)) : createCommentVNode("v-if", true)
358
+ ], 2)
357
359
  ], 42, _hoisted_1);
358
360
  }), 128))
359
361
  ], 2)) : createCommentVNode("v-if", true)
@@ -1 +1 @@
1
- {"version":3,"file":"main.mjs","sources":["../../../../../../packages/components/carousel/src/main.vue"],"sourcesContent":["<template>\n <div\n ref=\"root\"\n :class=\"carouselClasses\"\n @mouseenter.stop=\"handleMouseEnter\"\n @mouseleave.stop=\"handleMouseLeave\"\n >\n <div class=\"el-carousel__container\" :style=\"{ height: height }\">\n <transition v-if=\"arrowDisplay\" name=\"carousel-arrow-left\">\n <button\n v-show=\"\n (arrow === 'always' || data.hover) &&\n (props.loop || data.activeIndex > 0)\n \"\n type=\"button\"\n class=\"el-carousel__arrow el-carousel__arrow--left\"\n @mouseenter=\"handleButtonEnter('left')\"\n @mouseleave=\"handleButtonLeave\"\n @click.stop=\"throttledArrowClick(data.activeIndex - 1)\"\n >\n <el-icon>\n <arrow-left />\n </el-icon>\n </button>\n </transition>\n <transition v-if=\"arrowDisplay\" name=\"carousel-arrow-right\">\n <button\n v-show=\"\n (arrow === 'always' || data.hover) &&\n (props.loop || data.activeIndex < items.length - 1)\n \"\n type=\"button\"\n class=\"el-carousel__arrow el-carousel__arrow--right\"\n @mouseenter=\"handleButtonEnter('right')\"\n @mouseleave=\"handleButtonLeave\"\n @click.stop=\"throttledArrowClick(data.activeIndex + 1)\"\n >\n <el-icon>\n <arrow-right />\n </el-icon>\n </button>\n </transition>\n <slot></slot>\n </div>\n <ul v-if=\"indicatorPosition !== 'none'\" :class=\"indicatorsClasses\">\n <li\n v-for=\"(item, index) in items\"\n :key=\"index\"\n :class=\"[\n 'el-carousel__indicator',\n 'el-carousel__indicator--' + direction,\n { 'is-active': index === data.activeIndex },\n ]\"\n @mouseenter=\"throttledIndicatorHover(index)\"\n @click.stop=\"handleIndicatorClick(index)\"\n >\n <button class=\"el-carousel__button\">\n <span v-if=\"hasLabel\">{{ item.label }}</span>\n </button>\n </li>\n </ul>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n defineComponent,\n reactive,\n computed,\n ref,\n provide,\n onMounted,\n onBeforeUnmount,\n watch,\n nextTick,\n} from 'vue'\nimport throttle from 'lodash/throttle'\nimport {\n addResizeListener,\n removeResizeListener,\n} from '@element-plus/utils/resize-event'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'\n\nimport { debugWarn } from '@element-plus/utils/error'\nimport type {\n ICarouselProps,\n CarouselItem,\n InjectCarouselScope,\n} from './carousel'\n\nexport default defineComponent({\n name: 'ElCarousel',\n components: {\n ElIcon,\n ArrowLeft,\n ArrowRight,\n },\n props: {\n initialIndex: {\n type: Number,\n default: 0,\n },\n height: { type: String, default: '' },\n trigger: {\n type: String,\n default: 'hover',\n },\n autoplay: {\n type: Boolean,\n default: true,\n },\n interval: {\n type: Number,\n default: 3000,\n },\n indicatorPosition: { type: String, default: '' },\n indicator: {\n type: Boolean,\n default: true,\n },\n arrow: {\n type: String,\n default: 'hover',\n },\n type: { type: String, default: '' },\n loop: {\n type: Boolean,\n default: true,\n },\n direction: {\n type: String,\n default: 'horizontal',\n validator(val: string) {\n return ['horizontal', 'vertical'].includes(val)\n },\n },\n pauseOnHover: {\n type: Boolean,\n default: true,\n },\n },\n emits: ['change'],\n setup(props: ICarouselProps, { emit }) {\n // data\n const data = reactive<{\n activeIndex: number\n containerWidth: number\n timer: null | ReturnType<typeof setInterval>\n hover: boolean\n }>({\n activeIndex: -1,\n containerWidth: 0,\n timer: null,\n hover: false,\n })\n\n // refs\n const root = ref(null)\n const items = ref<CarouselItem[]>([])\n\n // computed\n const arrowDisplay = computed(\n () => props.arrow !== 'never' && props.direction !== 'vertical'\n )\n\n const hasLabel = computed(() => {\n return items.value.some((item) => item.label.toString().length > 0)\n })\n\n const carouselClasses = computed(() => {\n const classes = ['el-carousel', `el-carousel--${props.direction}`]\n if (props.type === 'card') {\n classes.push('el-carousel--card')\n }\n return classes\n })\n\n const indicatorsClasses = computed(() => {\n const classes = [\n 'el-carousel__indicators',\n `el-carousel__indicators--${props.direction}`,\n ]\n if (hasLabel.value) {\n classes.push('el-carousel__indicators--labels')\n }\n if (props.indicatorPosition === 'outside' || props.type === 'card') {\n classes.push('el-carousel__indicators--outside')\n }\n return classes\n })\n\n // methods\n const throttledArrowClick = throttle(\n (index) => {\n setActiveItem(index)\n },\n 300,\n { trailing: true }\n )\n\n const throttledIndicatorHover = throttle((index) => {\n handleIndicatorHover(index)\n }, 300)\n\n function pauseTimer() {\n if (data.timer) {\n clearInterval(data.timer)\n data.timer = null\n }\n }\n\n function startTimer() {\n if (props.interval <= 0 || !props.autoplay || data.timer) return\n data.timer = setInterval(() => playSlides(), props.interval)\n }\n\n const playSlides = () => {\n if (data.activeIndex < items.value.length - 1) {\n data.activeIndex = data.activeIndex + 1\n } else if (props.loop) {\n data.activeIndex = 0\n }\n }\n\n function setActiveItem(index) {\n if (typeof index === 'string') {\n const filteredItems = items.value.filter((item) => item.name === index)\n if (filteredItems.length > 0) {\n index = items.value.indexOf(filteredItems[0])\n }\n }\n index = Number(index)\n if (isNaN(index) || index !== Math.floor(index)) {\n debugWarn('Carousel', 'index must be an integer.')\n return\n }\n const length = items.value.length\n const oldIndex = data.activeIndex\n if (index < 0) {\n data.activeIndex = props.loop ? length - 1 : 0\n } else if (index >= length) {\n data.activeIndex = props.loop ? 0 : length - 1\n } else {\n data.activeIndex = index\n }\n if (oldIndex === data.activeIndex) {\n resetItemPosition(oldIndex)\n }\n }\n\n function resetItemPosition(oldIndex) {\n items.value.forEach((item, index) => {\n item.translateItem(index, data.activeIndex, oldIndex)\n })\n }\n\n function addItem(item) {\n items.value.push(item)\n }\n\n function removeItem(uid) {\n const index = items.value.findIndex((item) => item.uid === uid)\n if (index !== -1) {\n items.value.splice(index, 1)\n if (data.activeIndex === index) next()\n }\n }\n\n function itemInStage(item, index) {\n const length = items.value.length\n if (\n (index === length - 1 && item.inStage && items.value[0].active) ||\n (item.inStage &&\n items.value[index + 1] &&\n items.value[index + 1].active)\n ) {\n return 'left'\n } else if (\n (index === 0 && item.inStage && items.value[length - 1].active) ||\n (item.inStage &&\n items.value[index - 1] &&\n items.value[index - 1].active)\n ) {\n return 'right'\n }\n return false\n }\n\n function handleMouseEnter() {\n data.hover = true\n if (props.pauseOnHover) {\n pauseTimer()\n }\n }\n\n function handleMouseLeave() {\n data.hover = false\n startTimer()\n }\n\n function handleButtonEnter(arrow) {\n if (props.direction === 'vertical') return\n items.value.forEach((item, index) => {\n if (arrow === itemInStage(item, index)) {\n item.hover = true\n }\n })\n }\n\n function handleButtonLeave() {\n if (props.direction === 'vertical') return\n items.value.forEach((item) => {\n item.hover = false\n })\n }\n\n function handleIndicatorClick(index) {\n data.activeIndex = index\n }\n\n function handleIndicatorHover(index) {\n if (props.trigger === 'hover' && index !== data.activeIndex) {\n data.activeIndex = index\n }\n }\n\n function prev() {\n setActiveItem(data.activeIndex - 1)\n }\n\n function next() {\n setActiveItem(data.activeIndex + 1)\n }\n\n // watch\n watch(\n () => data.activeIndex,\n (current, prev) => {\n resetItemPosition(prev)\n if (prev > -1) {\n emit('change', current, prev)\n }\n }\n )\n watch(\n () => props.autoplay,\n (current) => {\n current ? startTimer() : pauseTimer()\n }\n )\n watch(\n () => props.loop,\n () => {\n setActiveItem(data.activeIndex)\n }\n )\n\n // lifecycle\n onMounted(() => {\n nextTick(() => {\n addResizeListener(root.value, resetItemPosition)\n if (\n props.initialIndex < items.value.length &&\n props.initialIndex >= 0\n ) {\n data.activeIndex = props.initialIndex\n }\n startTimer()\n })\n })\n\n onBeforeUnmount(() => {\n if (root.value) removeResizeListener(root.value, resetItemPosition)\n pauseTimer()\n })\n\n // provide\n provide<InjectCarouselScope>('injectCarouselScope', {\n root,\n direction: props.direction,\n type: props.type,\n items,\n loop: props.loop,\n addItem,\n removeItem,\n setActiveItem,\n })\n\n return {\n data,\n props,\n items,\n\n arrowDisplay,\n carouselClasses,\n indicatorsClasses,\n hasLabel,\n\n handleMouseEnter,\n handleMouseLeave,\n handleIndicatorClick,\n throttledArrowClick,\n throttledIndicatorHover,\n handleButtonEnter,\n handleButtonLeave,\n\n prev,\n next,\n setActiveItem,\n\n root,\n }\n },\n})\n</script>\n"],"names":["_openBlock","_createElementBlock","_createElementVNode","_withCtx","_createCommentVNode","_Fragment"],"mappings":";;;;;;;;AA2FA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAEF,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,QAAQ,EAAE,MAAM,QAAQ,SAAS;AAAA,IACjC,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,mBAAmB,EAAE,MAAM,QAAQ,SAAS;AAAA,IAC5C,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,MAAM,EAAE,MAAM,QAAQ,SAAS;AAAA,IAC/B,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU,KAAa;AACrB,eAAO,CAAC,cAAc,YAAY,SAAS;AAAA;AAAA;AAAA,IAG/C,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA;AAAA,EAGb,OAAO,CAAC;AAAA,EACR,MAAM,OAAuB,EAAE,QAAQ;AAErC,UAAM,OAAO,SAKV;AAAA,MACD,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,O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MAAM,MAAM;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA;AAGF,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA;AAAA;AAAA;oCAnWgB;;;;;;;SAtDdA,aAAMC;AAAA,IACT,KAAK;AAAA,IACL,sBAAU;AAAA,IACV,cAAU,qDAAO,yDAAgB;AAAA;KAElC;AAAA,uBAAW;AAAA,MAA0B,OAAK;AAAA;OACtB;AAAA;QAAc,KAAI;AAAA;;yBAClC;AAAA,yBAKeC;AAAA,YACb,MAAK;AAAA,YACJ;AAAA,YACA,cAAU,2CAAE;AAAA,YACZ,cAAK,iEAAO,KAAmB,kBAAM;AAAA;aAEtC;AAAA,4CACgB;AAAA,uBAAdC,QAAc;AAAA;;;;;YAXM;AAAA;AAAA,cAAkD,gBAAU,YAAI,KAAK;;;;;YAe7EC,mBAAY;AAAA;QAAE,KAAI;AAAA;;yBAClC;AAAA,yBAKeF;AAAA,YACb,MAAK;AAAA,YACJ;AAAA,YACA,cAAU,2CAAE;AAAA,YACZ,cAAK,iEAAO,KAAmB,kBAAM;AAAA;aAEtC;AAAA,4CACiB;AAAA,uBAAfC,QAAe;AAAA;;;;;YAXK;AAAA;AAAA,cAAkD,gBAAU,YAAI,KAAK;;;;;YAe/FC,mBAAa;AAAA;OAEL;AAAA,+BAAV;MAAyC,KAAK;AAAA;;2CAC5CC,UAcK;eAZGL,aAAKC;AAAA,UACV,KAAK;AAAA;;yCAA6H,KAAI;AAAA;;UAMtI,cAAK,yCAAO;AAAA;WAEb;AAAA,6BACsB;AAAA;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.mjs","sources":["../../../../../../packages/components/carousel/src/main.vue"],"sourcesContent":["<template>\n <div\n ref=\"root\"\n :class=\"carouselClasses\"\n @mouseenter.stop=\"handleMouseEnter\"\n @mouseleave.stop=\"handleMouseLeave\"\n >\n <div :class=\"ns.e('container')\" :style=\"{ height: height }\">\n <transition v-if=\"arrowDisplay\" name=\"carousel-arrow-left\">\n <button\n v-show=\"\n (arrow === 'always' || data.hover) &&\n (props.loop || data.activeIndex > 0)\n \"\n type=\"button\"\n :class=\"[ns.e('arrow'), ns.em('arrow', 'left')]\"\n @mouseenter=\"handleButtonEnter('left')\"\n @mouseleave=\"handleButtonLeave\"\n @click.stop=\"throttledArrowClick(data.activeIndex - 1)\"\n >\n <el-icon>\n <arrow-left />\n </el-icon>\n </button>\n </transition>\n <transition v-if=\"arrowDisplay\" name=\"carousel-arrow-right\">\n <button\n v-show=\"\n (arrow === 'always' || data.hover) &&\n (props.loop || data.activeIndex < items.length - 1)\n \"\n type=\"button\"\n :class=\"[ns.e('arrow'), ns.em('arrow', 'right')]\"\n @mouseenter=\"handleButtonEnter('right')\"\n @mouseleave=\"handleButtonLeave\"\n @click.stop=\"throttledArrowClick(data.activeIndex + 1)\"\n >\n <el-icon>\n <arrow-right />\n </el-icon>\n </button>\n </transition>\n <slot></slot>\n </div>\n <ul v-if=\"indicatorPosition !== 'none'\" :class=\"indicatorsClasses\">\n <li\n v-for=\"(item, index) in items\"\n :key=\"index\"\n :class=\"[\n ns.e('indicator'),\n ns.em('indicator', direction),\n ns.is('active', index === data.activeIndex),\n ]\"\n @mouseenter=\"throttledIndicatorHover(index)\"\n @click.stop=\"handleIndicatorClick(index)\"\n >\n <button :class=\"ns.e('button')\">\n <span v-if=\"hasLabel\">{{ item.label }}</span>\n </button>\n </li>\n </ul>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n defineComponent,\n reactive,\n computed,\n ref,\n provide,\n onMounted,\n onBeforeUnmount,\n watch,\n nextTick,\n} from 'vue'\nimport throttle from 'lodash/throttle'\nimport {\n addResizeListener,\n removeResizeListener,\n} from '@element-plus/utils/resize-event'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\n\nimport { debugWarn } from '@element-plus/utils/error'\nimport type {\n ICarouselProps,\n CarouselItem,\n InjectCarouselScope,\n} from './carousel'\n\nexport default defineComponent({\n name: 'ElCarousel',\n components: {\n ElIcon,\n ArrowLeft,\n ArrowRight,\n },\n props: {\n initialIndex: {\n type: Number,\n default: 0,\n },\n height: { type: String, default: '' },\n trigger: {\n type: String,\n default: 'hover',\n },\n autoplay: {\n type: Boolean,\n default: true,\n },\n interval: {\n type: Number,\n default: 3000,\n },\n indicatorPosition: { type: String, default: '' },\n indicator: {\n type: Boolean,\n default: true,\n },\n arrow: {\n type: String,\n default: 'hover',\n },\n type: { type: String, default: '' },\n loop: {\n type: Boolean,\n default: true,\n },\n direction: {\n type: String,\n default: 'horizontal',\n validator(val: string) {\n return ['horizontal', 'vertical'].includes(val)\n },\n },\n pauseOnHover: {\n type: Boolean,\n default: true,\n },\n },\n emits: ['change'],\n setup(props: ICarouselProps, { emit }) {\n const ns = useNamespace('carousel')\n // data\n const data = reactive<{\n activeIndex: number\n containerWidth: number\n timer: null | ReturnType<typeof setInterval>\n hover: boolean\n }>({\n activeIndex: -1,\n containerWidth: 0,\n timer: null,\n hover: false,\n })\n\n // refs\n const root = ref(null)\n const items = ref<CarouselItem[]>([])\n\n // computed\n const arrowDisplay = computed(\n () => props.arrow !== 'never' && props.direction !== 'vertical'\n )\n\n const hasLabel = computed(() => {\n return items.value.some((item) => item.label.toString().length > 0)\n })\n\n const carouselClasses = computed(() => {\n const classes = [ns.b(), ns.m(props.direction)]\n if (props.type === 'card') {\n classes.push(ns.m('card'))\n }\n return classes\n })\n\n const indicatorsClasses = computed(() => {\n const classes = [ns.e('indicators'), ns.em('indicators', props.direction)]\n if (hasLabel.value) {\n classes.push(ns.em('indicators', 'labels'))\n }\n if (props.indicatorPosition === 'outside' || props.type === 'card') {\n classes.push(ns.em('indicators', 'outside'))\n }\n return classes\n })\n\n // methods\n const throttledArrowClick = throttle(\n (index) => {\n setActiveItem(index)\n },\n 300,\n { trailing: true }\n )\n\n const throttledIndicatorHover = throttle((index) => {\n handleIndicatorHover(index)\n }, 300)\n\n function pauseTimer() {\n if (data.timer) {\n clearInterval(data.timer)\n data.timer = null\n }\n }\n\n function startTimer() {\n if (props.interval <= 0 || !props.autoplay || data.timer) return\n data.timer = setInterval(() => playSlides(), props.interval)\n }\n\n const playSlides = () => {\n if (data.activeIndex < items.value.length - 1) {\n data.activeIndex = data.activeIndex + 1\n } else if (props.loop) {\n data.activeIndex = 0\n }\n }\n\n function setActiveItem(index) {\n if (typeof index === 'string') {\n const filteredItems = items.value.filter((item) => item.name === index)\n if (filteredItems.length > 0) {\n index = items.value.indexOf(filteredItems[0])\n }\n }\n index = Number(index)\n if (isNaN(index) || index !== Math.floor(index)) {\n debugWarn('Carousel', 'index must be an integer.')\n return\n }\n const length = items.value.length\n const oldIndex = data.activeIndex\n if (index < 0) {\n data.activeIndex = props.loop ? length - 1 : 0\n } else if (index >= length) {\n data.activeIndex = props.loop ? 0 : length - 1\n } else {\n data.activeIndex = index\n }\n if (oldIndex === data.activeIndex) {\n resetItemPosition(oldIndex)\n }\n }\n\n function resetItemPosition(oldIndex) {\n items.value.forEach((item, index) => {\n item.translateItem(index, data.activeIndex, oldIndex)\n })\n }\n\n function addItem(item) {\n items.value.push(item)\n }\n\n function removeItem(uid) {\n const index = items.value.findIndex((item) => item.uid === uid)\n if (index !== -1) {\n items.value.splice(index, 1)\n if (data.activeIndex === index) next()\n }\n }\n\n function itemInStage(item, index) {\n const length = items.value.length\n if (\n (index === length - 1 && item.inStage && items.value[0].active) ||\n (item.inStage &&\n items.value[index + 1] &&\n items.value[index + 1].active)\n ) {\n return 'left'\n } else if (\n (index === 0 && item.inStage && items.value[length - 1].active) ||\n (item.inStage &&\n items.value[index - 1] &&\n items.value[index - 1].active)\n ) {\n return 'right'\n }\n return false\n }\n\n function handleMouseEnter() {\n data.hover = true\n if (props.pauseOnHover) {\n pauseTimer()\n }\n }\n\n function handleMouseLeave() {\n data.hover = false\n startTimer()\n }\n\n function handleButtonEnter(arrow) {\n if (props.direction === 'vertical') return\n items.value.forEach((item, index) => {\n if (arrow === itemInStage(item, index)) {\n item.hover = true\n }\n })\n }\n\n function handleButtonLeave() {\n if (props.direction === 'vertical') return\n items.value.forEach((item) => {\n item.hover = false\n })\n }\n\n function handleIndicatorClick(index) {\n data.activeIndex = index\n }\n\n function handleIndicatorHover(index) {\n if (props.trigger === 'hover' && index !== data.activeIndex) {\n data.activeIndex = index\n }\n }\n\n function prev() {\n setActiveItem(data.activeIndex - 1)\n }\n\n function next() {\n setActiveItem(data.activeIndex + 1)\n }\n\n // watch\n watch(\n () => data.activeIndex,\n (current, prev) => {\n resetItemPosition(prev)\n if (prev > -1) {\n emit('change', current, prev)\n }\n }\n )\n watch(\n () => props.autoplay,\n (current) => {\n current ? startTimer() : pauseTimer()\n }\n )\n watch(\n () => props.loop,\n () => {\n setActiveItem(data.activeIndex)\n }\n )\n\n // lifecycle\n onMounted(() => {\n nextTick(() => {\n addResizeListener(root.value, resetItemPosition)\n if (\n props.initialIndex < items.value.length &&\n props.initialIndex >= 0\n ) {\n data.activeIndex = props.initialIndex\n }\n startTimer()\n })\n })\n\n onBeforeUnmount(() => {\n if (root.value) removeResizeListener(root.value, resetItemPosition)\n pauseTimer()\n })\n\n // provide\n provide<InjectCarouselScope>('injectCarouselScope', {\n root,\n direction: props.direction,\n type: props.type,\n items,\n loop: props.loop,\n addItem,\n removeItem,\n setActiveItem,\n })\n\n return {\n data,\n props,\n items,\n\n arrowDisplay,\n carouselClasses,\n indicatorsClasses,\n hasLabel,\n\n handleMouseEnter,\n handleMouseLeave,\n handleIndicatorClick,\n throttledArrowClick,\n throttledIndicatorHover,\n handleButtonEnter,\n handleButtonLeave,\n\n prev,\n next,\n setActiveItem,\n\n root,\n ns,\n }\n },\n})\n</script>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","_createElementVNode","_withCtx","_createCommentVNode","_Fragment"],"mappings":";;;;;;;;;;AA4FA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAEF,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,QAAQ,EAAE,MAAM,QAAQ,SAAS;AAAA,IACjC,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,mBAAmB,EAAE,MAAM,QAAQ,SAAS;AAAA,IAC5C,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,MAAM,EAAE,MAAM,QAAQ,SAAS;AAAA,IAC/B,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU,KAAa;AACrB,eAAO,CAAC,cAAc,YAAY,SAAS;AAAA;AAAA;AAAA,IAG/C,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA;AAAA;AAAA,EAGb,OAAO,CAAC;AAAA,EACR,MAAM,OAAuB,EAAE,QAAQ;AACrC,UAAM,KAAK,aAAa;AAExB,UAAM,OAAO,SAKV;AAAA,MACD,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,OAAO;AAAA;AAIT,UAAM,OAAO,IAAI;AACjB,UAAM,QAAQ,IAAoB;AAGlC,UAAM,eAAe,SACnB,MAAM,MAAM,UAAU,WAAW,MAAM,cAAc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+86,17 @@ declare const _default: import("vue").DefineComponent<{
86
86
  next: () => void;
87
87
  setActiveItem: (index: any) => void;
88
88
  root: import("vue").Ref<null>;
89
+ ns: {
90
+ namespace: import("vue").ComputedRef<string>;
91
+ b: (blockSuffix?: string) => string;
92
+ e: (element?: string | undefined) => string;
93
+ m: (modifier?: string | undefined) => string;
94
+ be: (blockSuffix?: string | undefined, element?: string | undefined) => string;
95
+ em: (element?: string | undefined, modifier?: string | undefined) => string;
96
+ bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;
97
+ bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;
98
+ is: (name: string, state?: boolean) => string;
99
+ };
89
100
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], "change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
90
101
  initialIndex: {
91
102
  type: NumberConstructor;
@@ -37,7 +37,7 @@ export declare const ElCheckbox: import("../../utils/types").SFCWithInstall<impo
37
37
  tabindex: (StringConstructor | NumberConstructor)[];
38
38
  }, {
39
39
  isChecked: import("vue").ComputedRef<boolean>;
40
- isDisabled: import("vue").ComputedRef<boolean | undefined>;
40
+ isDisabled: import("vue").ComputedRef<boolean>;
41
41
  checkboxSize: import("vue").ComputedRef<import("../../utils/types").ComponentSize>;
42
42
  model: import("vue").WritableComputedRef<any>;
43
43
  handleChange: (e: InputEvent) => void;
@@ -134,7 +134,7 @@ export declare const ElCheckbox: import("../../utils/types").SFCWithInstall<impo
134
134
  }, {
135
135
  focus: import("vue").Ref<boolean>;
136
136
  isChecked: import("vue").ComputedRef<boolean>;
137
- isDisabled: import("vue").ComputedRef<boolean | undefined>;
137
+ isDisabled: import("vue").ComputedRef<boolean>;
138
138
  model: import("vue").WritableComputedRef<any>;
139
139
  handleChange: (e: InputEvent) => void;
140
140
  activeStyle: import("vue").ComputedRef<{
@@ -296,7 +296,7 @@ export declare const ElCheckboxButton: import("../../utils/types").SFCWithInstal
296
296
  }, {
297
297
  focus: import("vue").Ref<boolean>;
298
298
  isChecked: import("vue").ComputedRef<boolean>;
299
- isDisabled: import("vue").ComputedRef<boolean | undefined>;
299
+ isDisabled: import("vue").ComputedRef<boolean>;
300
300
  model: import("vue").WritableComputedRef<any>;
301
301
  handleChange: (e: InputEvent) => void;
302
302
  activeStyle: import("vue").ComputedRef<{
@@ -26,7 +26,7 @@ declare const _default: import("vue").DefineComponent<{
26
26
  }, {
27
27
  focus: import("vue").Ref<boolean>;
28
28
  isChecked: import("vue").ComputedRef<boolean>;
29
- isDisabled: import("vue").ComputedRef<boolean | undefined>;
29
+ isDisabled: import("vue").ComputedRef<boolean>;
30
30
  model: import("vue").WritableComputedRef<any>;
31
31
  handleChange: (e: InputEvent) => void;
32
32
  activeStyle: import("vue").ComputedRef<{
@@ -39,7 +39,7 @@ declare const _default: import("vue").DefineComponent<{
39
39
  tabindex: (StringConstructor | NumberConstructor)[];
40
40
  }, {
41
41
  isChecked: import("vue").ComputedRef<boolean>;
42
- isDisabled: import("vue").ComputedRef<boolean | undefined>;
42
+ isDisabled: import("vue").ComputedRef<boolean>;
43
43
  checkboxSize: import("vue").ComputedRef<ComponentSize>;
44
44
  model: import("vue").WritableComputedRef<any>;
45
45
  handleChange: (e: InputEvent) => void;
@@ -37,7 +37,7 @@ export declare const useCheckboxGroup: () => {
37
37
  };
38
38
  export declare const useCheckbox: (props: IUseCheckboxProps) => {
39
39
  isChecked: import("vue").ComputedRef<boolean>;
40
- isDisabled: import("vue").ComputedRef<boolean | undefined>;
40
+ isDisabled: import("vue").ComputedRef<boolean>;
41
41
  checkboxSize: import("vue").ComputedRef<import("element-plus/es/utils/types").ComponentSize>;
42
42
  model: import("vue").WritableComputedRef<any>;
43
43
  handleChange: (e: InputEvent) => void;
@@ -113,9 +113,9 @@ const useDisabled = (props, {
113
113
  return !!(max || min) && model.value.length >= max && !isChecked.value || model.value.length <= min && isChecked.value;
114
114
  });
115
115
  const isDisabled = computed(() => {
116
- var _a;
116
+ var _a, _b;
117
117
  const disabled = props.disabled || elForm.disabled;
118
- return isGroup.value ? ((_a = checkboxGroup.disabled) == null ? void 0 : _a.value) || disabled || isLimitDisabled.value : props.disabled || elForm.disabled;
118
+ return (_b = isGroup.value ? ((_a = checkboxGroup.disabled) == null ? void 0 : _a.value) || disabled || isLimitDisabled.value : props.disabled || elForm.disabled) != null ? _b : false;
119
119
  });
120
120
  return {
121
121
  isDisabled,
@@ -1 +1 @@
1
- {"version":3,"file":"useCheckbox.mjs","sources":["../../../../../../packages/components/checkbox/src/useCheckbox.ts"],"sourcesContent":["import { ref, computed, inject, getCurrentInstance, watch } from 'vue'\nimport { toTypeString } from '@vue/shared'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { elFormKey, elFormItemKey } from '@element-plus/tokens'\n\nimport { useSize } from '@element-plus/hooks'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ElFormContext, ElFormItemContext } from '@element-plus/tokens'\nimport type { PartialReturnType } from '@element-plus/utils/types'\nimport type { ICheckboxGroupInstance } from './checkbox.type'\n\nexport const useCheckboxProps = {\n modelValue: {\n type: [Boolean, Number, String],\n default: () => undefined,\n },\n label: {\n type: [String, Boolean, Number, Object],\n },\n indeterminate: Boolean,\n disabled: Boolean,\n checked: Boolean,\n name: {\n type: String,\n default: undefined,\n },\n trueLabel: {\n type: [String, Number],\n default: undefined,\n },\n falseLabel: {\n type: [String, Number],\n default: undefined,\n },\n tabindex: [String, Number],\n size: String,\n}\n\nexport type IUseCheckboxProps = ExtractPropTypes<typeof useCheckboxProps>\n\nexport const useCheckboxGroup = () => {\n const elForm = inject(elFormKey, {} as ElFormContext)\n const elFormItem = inject(elFormItemKey, {} as ElFormItemContext)\n const checkboxGroup = inject<ICheckboxGroupInstance>('CheckboxGroup', {})\n const isGroup = computed(\n () => checkboxGroup && checkboxGroup?.name === 'ElCheckboxGroup'\n )\n const elFormItemSize = computed(() => {\n return elFormItem.size\n })\n return {\n isGroup,\n checkboxGroup,\n elForm,\n elFormItemSize,\n elFormItem,\n }\n}\n\nconst useModel = (props: IUseCheckboxProps) => {\n const selfModel = ref(false)\n const { emit } = getCurrentInstance()\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitExceeded = ref(false)\n const model = computed({\n get() {\n return isGroup.value\n ? checkboxGroup.modelValue?.value\n : props.modelValue ?? selfModel.value\n },\n\n set(val: unknown) {\n if (isGroup.value && Array.isArray(val)) {\n isLimitExceeded.value =\n checkboxGroup.max !== undefined &&\n val.length > checkboxGroup.max.value\n isLimitExceeded.value === false && checkboxGroup?.changeEvent?.(val)\n } else {\n emit(UPDATE_MODEL_EVENT, val)\n selfModel.value = val as boolean\n }\n },\n })\n\n return {\n model,\n isLimitExceeded,\n }\n}\n\nconst useCheckboxStatus = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const focus = ref(false)\n const size = useSize(checkboxGroup?.checkboxGroupSize, { prop: true })\n const isChecked = computed<boolean>(() => {\n const value = model.value\n if (toTypeString(value) === '[object Boolean]') {\n return value\n } else if (Array.isArray(value)) {\n return value.includes(props.label)\n } else if (value !== null && value !== undefined) {\n return value === props.trueLabel\n } else {\n return !!value\n }\n })\n\n const checkboxSize = useSize(\n computed(() =>\n isGroup.value ? checkboxGroup?.checkboxGroupSize?.value : undefined\n )\n )\n\n return {\n isChecked,\n focus,\n size,\n checkboxSize,\n }\n}\n\nconst useDisabled = (\n props: IUseCheckboxProps,\n {\n model,\n isChecked,\n }: PartialReturnType<typeof useModel> &\n PartialReturnType<typeof useCheckboxStatus>\n) => {\n const { elForm, isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitDisabled = computed(() => {\n const max = checkboxGroup.max?.value\n const min = checkboxGroup.min?.value\n return (\n (!!(max || min) && model.value.length >= max && !isChecked.value) ||\n (model.value.length <= min && isChecked.value)\n )\n })\n const isDisabled = computed(() => {\n const disabled = props.disabled || elForm.disabled\n return isGroup.value\n ? checkboxGroup.disabled?.value || disabled || isLimitDisabled.value\n : props.disabled || elForm.disabled\n })\n\n return {\n isDisabled,\n isLimitDisabled,\n }\n}\n\nconst setStoreValue = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n function addToStore() {\n if (Array.isArray(model.value) && !model.value.includes(props.label)) {\n model.value.push(props.label)\n } else {\n model.value = props.trueLabel || true\n }\n }\n props.checked && addToStore()\n}\n\nconst useEvent = (\n props: IUseCheckboxProps,\n { isLimitExceeded }: PartialReturnType<typeof useModel>\n) => {\n const { elFormItem } = useCheckboxGroup()\n const { emit } = getCurrentInstance()\n function handleChange(e: InputEvent) {\n if (isLimitExceeded.value) return\n const target = e.target as HTMLInputElement\n const value = target.checked\n ? props.trueLabel ?? true\n : props.falseLabel ?? false\n\n emit('change', value, e)\n }\n\n watch(\n () => props.modelValue,\n () => {\n elFormItem.validate?.('change')\n }\n )\n\n return {\n handleChange,\n }\n}\n\nexport const useCheckbox = (props: IUseCheckboxProps) => {\n const { model, isLimitExceeded } = useModel(props)\n const { focus, size, isChecked, checkboxSize } = useCheckboxStatus(props, {\n model,\n })\n const { isDisabled } = useDisabled(props, { model, isChecked })\n const { handleChange } = useEvent(props, { isLimitExceeded })\n\n setStoreValue(props, { model })\n\n return {\n isChecked,\n isDisabled,\n checkboxSize,\n model,\n handleChange,\n focus,\n size,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAKY,MAAC,gBAAgB,GAAG;AAChC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC;AACzB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AAC3C,GAAG;AACH,E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I,KAAK;AACT,IAAI,IAAI;AACR,GAAG,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"useCheckbox.mjs","sources":["../../../../../../packages/components/checkbox/src/useCheckbox.ts"],"sourcesContent":["import { ref, computed, inject, getCurrentInstance, watch } from 'vue'\nimport { toTypeString } from '@vue/shared'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { elFormKey, elFormItemKey } from '@element-plus/tokens'\n\nimport { useSize } from '@element-plus/hooks'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ElFormContext, ElFormItemContext } from '@element-plus/tokens'\nimport type { PartialReturnType } from '@element-plus/utils/types'\nimport type { ICheckboxGroupInstance } from './checkbox.type'\n\nexport const useCheckboxProps = {\n modelValue: {\n type: [Boolean, Number, String],\n default: () => undefined,\n },\n label: {\n type: [String, Boolean, Number, Object],\n },\n indeterminate: Boolean,\n disabled: Boolean,\n checked: Boolean,\n name: {\n type: String,\n default: undefined,\n },\n trueLabel: {\n type: [String, Number],\n default: undefined,\n },\n falseLabel: {\n type: [String, Number],\n default: undefined,\n },\n tabindex: [String, Number],\n size: String,\n}\n\nexport type IUseCheckboxProps = ExtractPropTypes<typeof useCheckboxProps>\n\nexport const useCheckboxGroup = () => {\n const elForm = inject(elFormKey, {} as ElFormContext)\n const elFormItem = inject(elFormItemKey, {} as ElFormItemContext)\n const checkboxGroup = inject<ICheckboxGroupInstance>('CheckboxGroup', {})\n const isGroup = computed(\n () => checkboxGroup && checkboxGroup?.name === 'ElCheckboxGroup'\n )\n const elFormItemSize = computed(() => {\n return elFormItem.size\n })\n return {\n isGroup,\n checkboxGroup,\n elForm,\n elFormItemSize,\n elFormItem,\n }\n}\n\nconst useModel = (props: IUseCheckboxProps) => {\n const selfModel = ref(false)\n const { emit } = getCurrentInstance()\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitExceeded = ref(false)\n const model = computed({\n get() {\n return isGroup.value\n ? checkboxGroup.modelValue?.value\n : props.modelValue ?? selfModel.value\n },\n\n set(val: unknown) {\n if (isGroup.value && Array.isArray(val)) {\n isLimitExceeded.value =\n checkboxGroup.max !== undefined &&\n val.length > checkboxGroup.max.value\n isLimitExceeded.value === false && checkboxGroup?.changeEvent?.(val)\n } else {\n emit(UPDATE_MODEL_EVENT, val)\n selfModel.value = val as boolean\n }\n },\n })\n\n return {\n model,\n isLimitExceeded,\n }\n}\n\nconst useCheckboxStatus = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const focus = ref(false)\n const size = useSize(checkboxGroup?.checkboxGroupSize, { prop: true })\n const isChecked = computed<boolean>(() => {\n const value = model.value\n if (toTypeString(value) === '[object Boolean]') {\n return value\n } else if (Array.isArray(value)) {\n return value.includes(props.label)\n } else if (value !== null && value !== undefined) {\n return value === props.trueLabel\n } else {\n return !!value\n }\n })\n\n const checkboxSize = useSize(\n computed(() =>\n isGroup.value ? checkboxGroup?.checkboxGroupSize?.value : undefined\n )\n )\n\n return {\n isChecked,\n focus,\n size,\n checkboxSize,\n }\n}\n\nconst useDisabled = (\n props: IUseCheckboxProps,\n {\n model,\n isChecked,\n }: PartialReturnType<typeof useModel> &\n PartialReturnType<typeof useCheckboxStatus>\n) => {\n const { elForm, isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitDisabled = computed(() => {\n const max = checkboxGroup.max?.value\n const min = checkboxGroup.min?.value\n return (\n (!!(max || min) && model.value.length >= max && !isChecked.value) ||\n (model.value.length <= min && isChecked.value)\n )\n })\n const isDisabled = computed(() => {\n const disabled = props.disabled || elForm.disabled\n return (\n (isGroup.value\n ? checkboxGroup.disabled?.value || disabled || isLimitDisabled.value\n : props.disabled || elForm.disabled) ?? false\n )\n })\n\n return {\n isDisabled,\n isLimitDisabled,\n }\n}\n\nconst setStoreValue = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n function addToStore() {\n if (Array.isArray(model.value) && !model.value.includes(props.label)) {\n model.value.push(props.label)\n } else {\n model.value = props.trueLabel || true\n }\n }\n props.checked && addToStore()\n}\n\nconst useEvent = (\n props: IUseCheckboxProps,\n { isLimitExceeded }: PartialReturnType<typeof useModel>\n) => {\n const { elFormItem } = useCheckboxGroup()\n const { emit } = getCurrentInstance()\n function handleChange(e: InputEvent) {\n if (isLimitExceeded.value) return\n const target = e.target as HTMLInputElement\n const value = target.checked\n ? props.trueLabel ?? true\n : props.falseLabel ?? false\n\n emit('change', value, e)\n }\n\n watch(\n () => props.modelValue,\n () => {\n elFormItem.validate?.('change')\n }\n )\n\n return {\n handleChange,\n }\n}\n\nexport const useCheckbox = (props: IUseCheckboxProps) => {\n const { model, isLimitExceeded } = useModel(props)\n const { focus, size, isChecked, checkboxSize } = useCheckboxStatus(props, {\n model,\n })\n const { isDisabled } = useDisabled(props, { model, isChecked })\n const { handleChange } = useEvent(props, { isLimitExceeded })\n\n setStoreValue(props, { model })\n\n return {\n isChecked,\n isDisabled,\n checkboxSize,\n model,\n handleChange,\n focus,\n size,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAKY,MAAC,gBAAgB,GAAG;AAChC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC;AACzB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AAC3C,GAAG;AACH,EAAE,aAAa,EAAE,OAAO;AACxB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,OAAO,EAAE,OAAO;AAClB,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;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C,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAC7B,GAAG;AACH,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,UAAU,EAAE,MAAM;AACtC,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,QAAQ,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAChF,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,YAAY;AAChB,GAAG,CAAC;AACJ,CAAC,CAAC;AACU,MAAC,WAAW,GAAG,CAAC,KAAK,KAAK;AACtC,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC,KAAK,EAAE;AAC5E,IAAI,KAAK;AACT,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAClE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;AAChE,EAAE,aAAa,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAClC,EAAE,OAAO;AACT,IAAI,SAAS;AACb,IAAI,UAAU;AACd,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,IAAI;AACR,GAAG,CAAC;AACJ;;;;"}
@@ -13,6 +13,7 @@ import { TypeComponents, TypeComponentsMap } from '../../../utils/icon.mjs';
13
13
  import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
14
14
  import TrapFocus from '../../../directives/trap-focus/index.mjs';
15
15
  import { useLocale } from '../../../hooks/use-locale/index.mjs';
16
+ import { useSize } from '../../../hooks/use-common-props/index.mjs';
16
17
  import { useModal } from '../../../hooks/use-modal/index.mjs';
17
18
  import { usePreventGlobal } from '../../../hooks/use-prevent-global/index.mjs';
18
19
  import { useLockscreen } from '../../../hooks/use-lockscreen/index.mjs';
@@ -116,6 +117,7 @@ const _sfc_main = defineComponent({
116
117
  const type = state.type;
117
118
  return type && TypeComponentsMap[type] ? `el-message-box-icon--${type}` : "";
118
119
  });
120
+ const btnSize = useSize(computed(() => props.buttonSize), { prop: true, form: true, formItem: true });
119
121
  const iconComponent = computed(() => state.icon || TypeComponentsMap[state.type] || "");
120
122
  const hasMessage = computed(() => !!state.message);
121
123
  const inputRef = ref(null);
@@ -242,6 +244,7 @@ const _sfc_main = defineComponent({
242
244
  visible,
243
245
  hasMessage,
244
246
  typeClass,
247
+ btnSize,
245
248
  iconComponent,
246
249
  confirmButtonClasses,
247
250
  inputRef,
@@ -377,7 +380,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
377
380
  loading: _ctx.cancelButtonLoading,
378
381
  class: normalizeClass([_ctx.cancelButtonClass]),
379
382
  round: _ctx.roundButton,
380
- size: _ctx.buttonSize || "",
383
+ size: _ctx.btnSize,
381
384
  onClick: _cache[3] || (_cache[3] = ($event) => _ctx.handleAction("cancel")),
382
385
  onKeydown: _cache[4] || (_cache[4] = withKeys(withModifiers(($event) => _ctx.handleAction("cancel"), ["prevent"]), ["enter"]))
383
386
  }, {
@@ -393,7 +396,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
393
396
  class: normalizeClass([_ctx.confirmButtonClasses]),
394
397
  round: _ctx.roundButton,
395
398
  disabled: _ctx.confirmButtonDisabled,
396
- size: _ctx.buttonSize || "",
399
+ size: _ctx.btnSize,
397
400
  onClick: _cache[5] || (_cache[5] = ($event) => _ctx.handleAction("confirm")),
398
401
  onKeydown: _cache[6] || (_cache[6] = withKeys(withModifiers(($event) => _ctx.handleAction("confirm"), ["prevent"]), ["enter"]))
399
402
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/message-box/src/index.vue"],"sourcesContent":["<template>\n <transition name=\"fade-in-linear\" @after-leave=\"$emit('vanish')\">\n <el-overlay\n v-show=\"visible\"\n :z-index=\"zIndex\"\n :overlay-class=\"['is-message-box', modalClass]\"\n :mask=\"modal\"\n @click.self=\"handleWrapperClick\"\n >\n <div\n ref=\"root\"\n v-trap-focus\n role=\"dialog\"\n :aria-label=\"title || 'dialog'\"\n aria-modal=\"true\"\n :class=\"[\n 'el-message-box',\n customClass,\n { 'el-message-box--center': center },\n ]\"\n :style=\"customStyle\"\n >\n <div\n v-if=\"title !== null && title !== undefined\"\n class=\"el-message-box__header\"\n >\n <div class=\"el-message-box__title\">\n <el-icon\n v-if=\"iconComponent && center\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <span>{{ title }}</span>\n </div>\n <button\n v-if=\"showClose\"\n type=\"button\"\n class=\"el-message-box__headerbtn\"\n aria-label=\"Close\"\n @click=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n @keydown.prevent.enter=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n >\n <el-icon class=\"el-message-box__close\"><close /></el-icon>\n </button>\n </div>\n <div class=\"el-message-box__content\">\n <div class=\"el-message-box__container\">\n <el-icon\n v-if=\"iconComponent && !center && hasMessage\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <div v-if=\"hasMessage\" class=\"el-message-box__message\">\n <slot>\n <p v-if=\"!dangerouslyUseHTMLString\">{{ message }}</p>\n <p v-else v-html=\"message\"></p>\n </slot>\n </div>\n </div>\n <div v-show=\"showInput\" class=\"el-message-box__input\">\n <el-input\n ref=\"inputRef\"\n v-model=\"inputValue\"\n :type=\"inputType\"\n :placeholder=\"inputPlaceholder\"\n :class=\"{ invalid: validateError }\"\n @keydown.prevent.enter=\"handleInputEnter\"\n />\n <div\n class=\"el-message-box__errormsg\"\n :style=\"{\n visibility: !!editorErrorMessage ? 'visible' : 'hidden',\n }\"\n >\n {{ editorErrorMessage }}\n </div>\n </div>\n </div>\n <div class=\"el-message-box__btns\">\n <el-button\n v-if=\"showCancelButton\"\n :loading=\"cancelButtonLoading\"\n :class=\"[cancelButtonClass]\"\n :round=\"roundButton\"\n :size=\"buttonSize || ''\"\n @click=\"handleAction('cancel')\"\n @keydown.prevent.enter=\"handleAction('cancel')\"\n >\n {{ cancelButtonText || t('el.messagebox.cancel') }}\n </el-button>\n <el-button\n v-show=\"showConfirmButton\"\n ref=\"confirmRef\"\n type=\"primary\"\n :loading=\"confirmButtonLoading\"\n :class=\"[confirmButtonClasses]\"\n :round=\"roundButton\"\n :disabled=\"confirmButtonDisabled\"\n :size=\"buttonSize || ''\"\n @click=\"handleAction('confirm')\"\n @keydown.prevent.enter=\"handleAction('confirm')\"\n >\n {{ confirmButtonText || t('el.messagebox.confirm') }}\n </el-button>\n </div>\n </div>\n </el-overlay>\n </transition>\n</template>\n<script lang=\"ts\">\nimport {\n defineComponent,\n nextTick,\n onMounted,\n onBeforeUnmount,\n computed,\n watch,\n reactive,\n ref,\n toRefs,\n} from 'vue'\nimport ElButton from '@element-plus/components/button'\nimport { TrapFocus } from '@element-plus/directives'\nimport {\n useModal,\n useLockscreen,\n useLocale,\n useRestoreActive,\n usePreventGlobal,\n} from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { ElOverlay } from '@element-plus/components/overlay'\nimport { PopupManager } from '@element-plus/utils/popup-manager'\nimport { on, off } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { TypeComponents, TypeComponentsMap } from '@element-plus/utils/icon'\n\nimport type { ComponentPublicInstance, PropType } from 'vue'\nimport type { ComponentSize } from '@element-plus/utils/types'\nimport type {\n Action,\n MessageBoxState,\n MessageBoxType,\n} from './message-box.type'\n\nexport default defineComponent({\n name: 'ElMessageBox',\n directives: {\n TrapFocus,\n },\n components: {\n ElButton,\n ElInput,\n ElOverlay,\n ElIcon,\n ...TypeComponents,\n },\n inheritAttrs: false,\n props: {\n buttonSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n modal: {\n type: Boolean,\n default: true,\n },\n lockScroll: {\n type: Boolean,\n default: true,\n },\n showClose: {\n type: Boolean,\n default: true,\n },\n closeOnClickModal: {\n type: Boolean,\n default: true,\n },\n closeOnPressEscape: {\n type: Boolean,\n default: true,\n },\n closeOnHashChange: {\n type: Boolean,\n default: true,\n },\n center: Boolean,\n roundButton: {\n default: false,\n type: Boolean,\n },\n container: {\n type: String, // default append to body\n default: 'body',\n },\n boxType: {\n type: String as PropType<MessageBoxType>,\n default: '',\n },\n },\n emits: ['vanish', 'action'],\n setup(props, { emit }) {\n // const popup = usePopup(props, doClose)\n const { t } = useLocale()\n const visible = ref(false)\n // s represents state\n const state = reactive<MessageBoxState>({\n beforeClose: null,\n callback: null,\n cancelButtonText: '',\n cancelButtonClass: '',\n confirmButtonText: '',\n confirmButtonClass: '',\n customClass: '',\n customStyle: {},\n dangerouslyUseHTMLString: false,\n distinguishCancelAndClose: false,\n icon: '',\n inputPattern: null,\n inputPlaceholder: '',\n inputType: 'text',\n inputValue: null,\n inputValidator: null,\n inputErrorMessage: '',\n message: null,\n modalFade: true,\n modalClass: '',\n showCancelButton: false,\n showConfirmButton: true,\n type: '',\n title: undefined,\n showInput: false,\n action: '' as Action,\n confirmButtonLoading: false,\n cancelButtonLoading: false,\n confirmButtonDisabled: false,\n editorErrorMessage: '',\n // refer to: https://github.com/ElemeFE/element/commit/2999279ae34ef10c373ca795c87b020ed6753eed\n // seemed ok for now without this state.\n // isOnComposition: false, // temporary remove\n validateError: false,\n zIndex: PopupManager.nextZIndex(),\n })\n\n const typeClass = computed(() => {\n const type = state.type\n return type && TypeComponentsMap[type]\n ? `el-message-box-icon--${type}`\n : ''\n })\n\n const iconComponent = computed(\n () => state.icon || TypeComponentsMap[state.type] || ''\n )\n const hasMessage = computed(() => !!state.message)\n const inputRef = ref<ComponentPublicInstance>(null)\n const confirmRef = ref<ComponentPublicInstance>(null)\n\n const confirmButtonClasses = computed(() => state.confirmButtonClass)\n\n watch(\n () => state.inputValue,\n async (val) => {\n await nextTick()\n if (props.boxType === 'prompt' && val !== null) {\n validate()\n }\n },\n { immediate: true }\n )\n\n watch(\n () => visible.value,\n (val) => {\n if (val) {\n if (props.boxType === 'alert' || props.boxType === 'confirm') {\n nextTick().then(() => {\n confirmRef.value?.$el?.focus?.()\n })\n }\n state.zIndex = PopupManager.nextZIndex()\n }\n if (props.boxType !== 'prompt') return\n if (val) {\n nextTick().then(() => {\n if (inputRef.value && inputRef.value.$el) {\n getInputElement().focus()\n }\n })\n } else {\n state.editorErrorMessage = ''\n state.validateError = false\n }\n }\n )\n\n onMounted(async () => {\n await nextTick()\n if (props.closeOnHashChange) {\n on(window, 'hashchange', doClose)\n }\n })\n\n onBeforeUnmount(() => {\n if (props.closeOnHashChange) {\n off(window, 'hashchange', doClose)\n }\n })\n\n function doClose() {\n if (!visible.value) return\n visible.value = false\n nextTick(() => {\n if (state.action) emit('action', state.action)\n })\n }\n\n const handleWrapperClick = () => {\n if (props.closeOnClickModal) {\n handleAction(state.distinguishCancelAndClose ? 'close' : 'cancel')\n }\n }\n\n const handleInputEnter = () => {\n if (state.inputType !== 'textarea') {\n return handleAction('confirm')\n }\n }\n\n const handleAction = (action: Action) => {\n if (props.boxType === 'prompt' && action === 'confirm' && !validate()) {\n return\n }\n\n state.action = action\n\n if (state.beforeClose) {\n state.beforeClose?.(action, state, doClose)\n } else {\n doClose()\n }\n }\n\n const validate = () => {\n if (props.boxType === 'prompt') {\n const inputPattern = state.inputPattern\n if (inputPattern && !inputPattern.test(state.inputValue || '')) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n const inputValidator = state.inputValidator\n if (typeof inputValidator === 'function') {\n const validateResult = inputValidator(state.inputValue)\n if (validateResult === false) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n if (typeof validateResult === 'string') {\n state.editorErrorMessage = validateResult\n state.validateError = true\n return false\n }\n }\n }\n state.editorErrorMessage = ''\n state.validateError = false\n return true\n }\n\n const getInputElement = () => {\n const inputRefs = inputRef.value.$refs\n return (inputRefs.input || inputRefs.textarea) as HTMLElement\n }\n\n const handleClose = () => {\n handleAction('close')\n }\n\n // when close on press escape is disabled, pressing esc should not callout\n // any other message box and close any other dialog-ish elements\n // e.g. Dialog has a close on press esc feature, and when it closes, it calls\n // props.beforeClose method to make a intermediate state by callout a message box\n // for some verification or alerting. then if we allow global event liek this\n // to dispatch, it could callout another message box.\n if (props.closeOnPressEscape) {\n useModal(\n {\n handleClose,\n },\n visible\n )\n } else {\n usePreventGlobal(\n visible,\n 'keydown',\n (e: KeyboardEvent) => e.code === EVENT_CODE.esc\n )\n }\n\n // locks the screen to prevent scroll\n if (props.lockScroll) {\n useLockscreen(visible)\n }\n\n // restore to prev active element.\n useRestoreActive(visible)\n\n return {\n ...toRefs(state),\n visible,\n hasMessage,\n typeClass,\n iconComponent,\n confirmButtonClasses,\n inputRef,\n confirmRef,\n doClose, // for outside usage\n handleClose, // for out side usage\n handleWrapperClick,\n handleInputEnter,\n handleAction,\n t,\n }\n },\n})\n</script>\n"],"names":["_withCtx"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2JA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA;AAAA,EAEF,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA;AAAA,EAEL,cAAc;AA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ACrB,kEAC6B;AAC7B;AACA;AAAO;AAET;AACE;AACA;AACA;AAAO;AAAA;AAAA;AAIb;AACA;AACA;AAAO;AAGT;AACE;AACA;AAAqC;AAGvC;AACE;AAAa;AASf;AACE;AACE,QACE;AAAA;AAEF;AAGF;AAG8C;AAKhD;AACE;AAAc;AAIhB;AAEA;AAAO;AACK;AACV,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA;;;;AA5ZS;;;;;;;AAoCyB;;;;;;;;;;;;;;AA3DL;AAAE;;;AACjC;AAEkB;AACF;AACF,QACX,WAAK;AAAA;;;;AAGM,iBAENA;AAAA;AACH,YACD;AAAiB,YAChB,cAAK;AAAA;;AAA0C;;;;aAQxC;AAAA,kCADR;AAaQ;AAP2B;;AACxB;;;AAGL;;;;AAEsB;;;gBAIxB;AAAI;AACC,gBACL;AAAA,gBACC,cAAK;AAAA,gBAAiB;gBAGgB;;AAIvC,iDAAgD;AAAA;AAAA;;;;;kBAGpD;AAAA;AAeQ;AAZ4B;;AACzB;;;AAGL;;;;AAEmB;AAIZ,8BAFK;AAAwB,kEAClC,oBAA+B;;AAArB;;;;;;AAYZ;AANc;;kBAEb;AAAe,kBACf;AAAW,kBACX;AAAK,kBACL;AAAuB;;AASpB;AANE,yBACA;AAAA,wCAAkC;AAAA;;;;AAXtB;;;;AAqBE;;AACrB;AACK,gBACL;AAAkB,gBAClB,OAAM;AAAA,gBACN;AAAK,gBACL;AAAO;;;;;;;AAiBE;AAXM,qBACZ;AAAA;AACH,gBACA;AAAK,gBACL;AAAkB,gBAClB;AAAU,gBACV;AAAM,gBACN,WAAK;AAAA,gBACL;AAAO;;;;;;;AATiB;;;;;;;;;AAhGhB;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/message-box/src/index.vue"],"sourcesContent":["<template>\n <transition name=\"fade-in-linear\" @after-leave=\"$emit('vanish')\">\n <el-overlay\n v-show=\"visible\"\n :z-index=\"zIndex\"\n :overlay-class=\"['is-message-box', modalClass]\"\n :mask=\"modal\"\n @click.self=\"handleWrapperClick\"\n >\n <div\n ref=\"root\"\n v-trap-focus\n role=\"dialog\"\n :aria-label=\"title || 'dialog'\"\n aria-modal=\"true\"\n :class=\"[\n 'el-message-box',\n customClass,\n { 'el-message-box--center': center },\n ]\"\n :style=\"customStyle\"\n >\n <div\n v-if=\"title !== null && title !== undefined\"\n class=\"el-message-box__header\"\n >\n <div class=\"el-message-box__title\">\n <el-icon\n v-if=\"iconComponent && center\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <span>{{ title }}</span>\n </div>\n <button\n v-if=\"showClose\"\n type=\"button\"\n class=\"el-message-box__headerbtn\"\n aria-label=\"Close\"\n @click=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n @keydown.prevent.enter=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n >\n <el-icon class=\"el-message-box__close\"><close /></el-icon>\n </button>\n </div>\n <div class=\"el-message-box__content\">\n <div class=\"el-message-box__container\">\n <el-icon\n v-if=\"iconComponent && !center && hasMessage\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <div v-if=\"hasMessage\" class=\"el-message-box__message\">\n <slot>\n <p v-if=\"!dangerouslyUseHTMLString\">{{ message }}</p>\n <p v-else v-html=\"message\"></p>\n </slot>\n </div>\n </div>\n <div v-show=\"showInput\" class=\"el-message-box__input\">\n <el-input\n ref=\"inputRef\"\n v-model=\"inputValue\"\n :type=\"inputType\"\n :placeholder=\"inputPlaceholder\"\n :class=\"{ invalid: validateError }\"\n @keydown.prevent.enter=\"handleInputEnter\"\n />\n <div\n class=\"el-message-box__errormsg\"\n :style=\"{\n visibility: !!editorErrorMessage ? 'visible' : 'hidden',\n }\"\n >\n {{ editorErrorMessage }}\n </div>\n </div>\n </div>\n <div class=\"el-message-box__btns\">\n <el-button\n v-if=\"showCancelButton\"\n :loading=\"cancelButtonLoading\"\n :class=\"[cancelButtonClass]\"\n :round=\"roundButton\"\n :size=\"btnSize\"\n @click=\"handleAction('cancel')\"\n @keydown.prevent.enter=\"handleAction('cancel')\"\n >\n {{ cancelButtonText || t('el.messagebox.cancel') }}\n </el-button>\n <el-button\n v-show=\"showConfirmButton\"\n ref=\"confirmRef\"\n type=\"primary\"\n :loading=\"confirmButtonLoading\"\n :class=\"[confirmButtonClasses]\"\n :round=\"roundButton\"\n :disabled=\"confirmButtonDisabled\"\n :size=\"btnSize\"\n @click=\"handleAction('confirm')\"\n @keydown.prevent.enter=\"handleAction('confirm')\"\n >\n {{ confirmButtonText || t('el.messagebox.confirm') }}\n </el-button>\n </div>\n </div>\n </el-overlay>\n </transition>\n</template>\n<script lang=\"ts\">\nimport {\n defineComponent,\n nextTick,\n onMounted,\n onBeforeUnmount,\n computed,\n watch,\n reactive,\n ref,\n toRefs,\n} from 'vue'\nimport ElButton from '@element-plus/components/button'\nimport { TrapFocus } from '@element-plus/directives'\nimport {\n useModal,\n useLockscreen,\n useLocale,\n useRestoreActive,\n usePreventGlobal,\n useSize,\n} from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { ElOverlay } from '@element-plus/components/overlay'\nimport { PopupManager } from '@element-plus/utils/popup-manager'\nimport { on, off } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { TypeComponents, TypeComponentsMap } from '@element-plus/utils/icon'\n\nimport type { ComponentPublicInstance, PropType } from 'vue'\nimport type { ComponentSize } from '@element-plus/utils/types'\nimport type {\n Action,\n MessageBoxState,\n MessageBoxType,\n} from './message-box.type'\n\nexport default defineComponent({\n name: 'ElMessageBox',\n directives: {\n TrapFocus,\n },\n components: {\n ElButton,\n ElInput,\n ElOverlay,\n ElIcon,\n ...TypeComponents,\n },\n inheritAttrs: false,\n props: {\n buttonSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n modal: {\n type: Boolean,\n default: true,\n },\n lockScroll: {\n type: Boolean,\n default: true,\n },\n showClose: {\n type: Boolean,\n default: true,\n },\n closeOnClickModal: {\n type: Boolean,\n default: true,\n },\n closeOnPressEscape: {\n type: Boolean,\n default: true,\n },\n closeOnHashChange: {\n type: Boolean,\n default: true,\n },\n center: Boolean,\n roundButton: {\n default: false,\n type: Boolean,\n },\n container: {\n type: String, // default append to body\n default: 'body',\n },\n boxType: {\n type: String as PropType<MessageBoxType>,\n default: '',\n },\n },\n emits: ['vanish', 'action'],\n setup(props, { emit }) {\n // const popup = usePopup(props, doClose)\n const { t } = useLocale()\n const visible = ref(false)\n // s represents state\n const state = reactive<MessageBoxState>({\n beforeClose: null,\n callback: null,\n cancelButtonText: '',\n cancelButtonClass: '',\n confirmButtonText: '',\n confirmButtonClass: '',\n customClass: '',\n customStyle: {},\n dangerouslyUseHTMLString: false,\n distinguishCancelAndClose: false,\n icon: '',\n inputPattern: null,\n inputPlaceholder: '',\n inputType: 'text',\n inputValue: null,\n inputValidator: null,\n inputErrorMessage: '',\n message: null,\n modalFade: true,\n modalClass: '',\n showCancelButton: false,\n showConfirmButton: true,\n type: '',\n title: undefined,\n showInput: false,\n action: '' as Action,\n confirmButtonLoading: false,\n cancelButtonLoading: false,\n confirmButtonDisabled: false,\n editorErrorMessage: '',\n // refer to: https://github.com/ElemeFE/element/commit/2999279ae34ef10c373ca795c87b020ed6753eed\n // seemed ok for now without this state.\n // isOnComposition: false, // temporary remove\n validateError: false,\n zIndex: PopupManager.nextZIndex(),\n })\n\n const typeClass = computed(() => {\n const type = state.type\n return type && TypeComponentsMap[type]\n ? `el-message-box-icon--${type}`\n : ''\n })\n\n const btnSize = useSize(\n computed(() => props.buttonSize),\n { prop: true, form: true, formItem: true }\n )\n\n const iconComponent = computed(\n () => state.icon || TypeComponentsMap[state.type] || ''\n )\n const hasMessage = computed(() => !!state.message)\n const inputRef = ref<ComponentPublicInstance>(null)\n const confirmRef = ref<ComponentPublicInstance>(null)\n\n const confirmButtonClasses = computed(() => state.confirmButtonClass)\n\n watch(\n () => state.inputValue,\n async (val) => {\n await nextTick()\n if (props.boxType === 'prompt' && val !== null) {\n validate()\n }\n },\n { immediate: true }\n )\n\n watch(\n () => visible.value,\n (val) => {\n if (val) {\n if (props.boxType === 'alert' || props.boxType === 'confirm') {\n nextTick().then(() => {\n confirmRef.value?.$el?.focus?.()\n })\n }\n state.zIndex = PopupManager.nextZIndex()\n }\n if (props.boxType !== 'prompt') return\n if (val) {\n nextTick().then(() => {\n if (inputRef.value && inputRef.value.$el) {\n getInputElement().focus()\n }\n })\n } else {\n state.editorErrorMessage = ''\n state.validateError = false\n }\n }\n )\n\n onMounted(async () => {\n await nextTick()\n if (props.closeOnHashChange) {\n on(window, 'hashchange', doClose)\n }\n })\n\n onBeforeUnmount(() => {\n if (props.closeOnHashChange) {\n off(window, 'hashchange', doClose)\n }\n })\n\n function doClose() {\n if (!visible.value) return\n visible.value = false\n nextTick(() => {\n if (state.action) emit('action', state.action)\n })\n }\n\n const handleWrapperClick = () => {\n if (props.closeOnClickModal) {\n handleAction(state.distinguishCancelAndClose ? 'close' : 'cancel')\n }\n }\n\n const handleInputEnter = () => {\n if (state.inputType !== 'textarea') {\n return handleAction('confirm')\n }\n }\n\n const handleAction = (action: Action) => {\n if (props.boxType === 'prompt' && action === 'confirm' && !validate()) {\n return\n }\n\n state.action = action\n\n if (state.beforeClose) {\n state.beforeClose?.(action, state, doClose)\n } else {\n doClose()\n }\n }\n\n const validate = () => {\n if (props.boxType === 'prompt') {\n const inputPattern = state.inputPattern\n if (inputPattern && !inputPattern.test(state.inputValue || '')) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n const inputValidator = state.inputValidator\n if (typeof inputValidator === 'function') {\n const validateResult = inputValidator(state.inputValue)\n if (validateResult === false) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n if (typeof validateResult === 'string') {\n state.editorErrorMessage = validateResult\n state.validateError = true\n return false\n }\n }\n }\n state.editorErrorMessage = ''\n state.validateError = false\n return true\n }\n\n const getInputElement = () => {\n const inputRefs = inputRef.value.$refs\n return (inputRefs.input || inputRefs.textarea) as HTMLElement\n }\n\n const handleClose = () => {\n handleAction('close')\n }\n\n // when close on press escape is disabled, pressing esc should not callout\n // any other message box and close any other dialog-ish elements\n // e.g. Dialog has a close on press esc feature, and when it closes, it calls\n // props.beforeClose method to make a intermediate state by callout a message box\n // for some verification or alerting. then if we allow global event liek this\n // to dispatch, it could callout another message box.\n if (props.closeOnPressEscape) {\n useModal(\n {\n handleClose,\n },\n visible\n )\n } else {\n usePreventGlobal(\n visible,\n 'keydown',\n (e: KeyboardEvent) => e.code === EVENT_CODE.esc\n )\n }\n\n // locks the screen to prevent scroll\n if (props.lockScroll) {\n useLockscreen(visible)\n }\n\n // restore to prev active element.\n useRestoreActive(visible)\n\n return {\n ...toRefs(state),\n visible,\n hasMessage,\n typeClass,\n btnSize,\n iconComponent,\n confirmButtonClasses,\n inputRef,\n confirmRef,\n doClose, // for outside usage\n handleClose, // for out side usage\n handleWrapperClick,\n handleInputEnter,\n handleAction,\n t,\n }\n },\n})\n</script>\n"],"names":["_withCtx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4JA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA;AAAA,EAEF,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA;AAAA,EAEL,cAAc;AAAA,EACd,OAAO;AAAA,IACL,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA;AAAA,IAE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B;AACrB,kEAC6B;AAC7B;AACA;AAAO;AAET;AACE;AACA;AACA;AAAO;AAAA;AAAA;AAIb;AACA;AACA;AAAO;AAGT;AACE;AACA;AAAqC;AAGvC;AACE;AAAa;AASf;AACE;AACE,QACE;AAAA;AAEF;AAGF;AAG8C;AAKhD;AACE;AAAc;AAIhB;AAEA;AAAO;AACK;AACV,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA;;;;AAnaS;;;;;;;AAoCyB;;;;;;;;;;;;;;AA3DL;AAAE;;;AACjC;AAEkB;AACF;AACF,QACX,WAAK;AAAA;;;;AAGM,iBAENA;AAAA;AACH,YACD;AAAiB,YAChB,cAAK;AAAA;;AAA0C;;;;aAQxC;AAAA,kCADR;AAaQ;AAP2B;;AACxB;;;AAGL;;;;AAEsB;;;gBAIxB;AAAI;AACC,gBACL;AAAA,gBACC,cAAK;AAAA,gBAAiB;gBAGgB;;AAIvC,iDAAgD;AAAA;AAAA;;;;;kBAGpD;AAAA;AAeQ;AAZ4B;;AACzB;;;AAGL;;;;AAEmB;AAIZ,8BAFK;AAAwB,kEAClC,oBAA+B;;AAArB;;;;;;AAYZ;AANc;;kBAEb;AAAe,kBACf;AAAW,kBACX;AAAK,kBACL;AAAuB;;AASpB;AANE,yBACA;AAAA,wCAAkC;AAAA;;;;AAXtB;;;;AAqBE;;AACrB;AACK,gBACL;AAAkB,gBAClB,OAAM;AAAA,gBACN;AAAK,gBACL;AAAO;;;;;;;AAiBE;AAXM,qBACZ;AAAA;AACH,gBACA;AAAK,gBACL;AAAkB,gBAClB;AAAU,gBACV;AAAM,gBACN,WAAK;AAAA,gBACL;AAAO;;;;;;;AATiB;;;;;;;;;AAhGhB;;;;;;;;;;;;"}
@@ -47,6 +47,7 @@ declare const _default: import("vue").DefineComponent<{
47
47
  visible: import("vue").Ref<boolean>;
48
48
  hasMessage: import("vue").ComputedRef<boolean>;
49
49
  typeClass: import("vue").ComputedRef<string>;
50
+ btnSize: import("vue").ComputedRef<ComponentSize>;
50
51
  iconComponent: import("vue").ComputedRef<any>;
51
52
  confirmButtonClasses: import("vue").ComputedRef<string>;
52
53
  inputRef: import("vue").Ref<ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>>;
@@ -2,7 +2,6 @@ import type { SFCWithInstall } from 'element-plus/es/utils/types';
2
2
  declare const _PopoverDirective: SFCWithInstall<import("vue").ObjectDirective<any, any>>;
3
3
  declare const _Popover: SFCWithInstall<import("vue").DefineComponent<{
4
4
  title: StringConstructor;
5
- hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
6
5
  width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
7
6
  content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
8
7
  popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -842,7 +841,6 @@ declare const _Popover: SFCWithInstall<import("vue").DefineComponent<{
842
841
  hide: () => void;
843
842
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
844
843
  title: StringConstructor;
845
- hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
846
844
  width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
847
845
  content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
848
846
  popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -942,14 +940,12 @@ declare const _Popover: SFCWithInstall<import("vue").DefineComponent<{
942
940
  } | any)[])[])[])[])[])[])[])[])[])[])[];
943
941
  popperStyle: import("vue").StyleValue;
944
942
  content: string;
945
- hideAfter: number;
946
943
  }>> & {
947
944
  directive: typeof _PopoverDirective;
948
945
  };
949
946
  export default _Popover;
950
947
  export declare const ElPopover: SFCWithInstall<import("vue").DefineComponent<{
951
948
  title: StringConstructor;
952
- hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
953
949
  width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
954
950
  content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
955
951
  popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -1789,7 +1785,6 @@ export declare const ElPopover: SFCWithInstall<import("vue").DefineComponent<{
1789
1785
  hide: () => void;
1790
1786
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
1791
1787
  title: StringConstructor;
1792
- hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
1793
1788
  width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
1794
1789
  content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
1795
1790
  popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -1889,7 +1884,6 @@ export declare const ElPopover: SFCWithInstall<import("vue").DefineComponent<{
1889
1884
  } | any)[])[])[])[])[])[])[])[])[])[])[];
1890
1885
  popperStyle: import("vue").StyleValue;
1891
1886
  content: string;
1892
- hideAfter: number;
1893
1887
  }>> & {
1894
1888
  directive: typeof _PopoverDirective;
1895
1889
  };
@@ -1,7 +1,6 @@
1
1
  import type { StyleValue } from 'vue';
2
2
  declare const _default: import("vue").DefineComponent<{
3
3
  title: StringConstructor;
4
- hideAfter: import("../../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
5
4
  width: import("../../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
6
5
  content: import("../../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
7
6
  popperStyle: import("../../../utils/props").BuildPropReturn<import("../../../utils/props").PropWrapper<StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -841,7 +840,6 @@ declare const _default: import("vue").DefineComponent<{
841
840
  hide: () => void;
842
841
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
843
842
  title: StringConstructor;
844
- hideAfter: import("../../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
845
843
  width: import("../../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
846
844
  content: import("../../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
847
845
  popperStyle: import("../../../utils/props").BuildPropReturn<import("../../../utils/props").PropWrapper<StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -941,6 +939,5 @@ declare const _default: import("vue").DefineComponent<{
941
939
  } | any)[])[])[])[])[])[])[])[])[])[])[];
942
940
  popperStyle: StyleValue;
943
941
  content: string;
944
- hideAfter: number;
945
942
  }>;
946
943
  export default _default;
@@ -1,6 +1,5 @@
1
1
  export declare const usePopoverProps: {
2
2
  title: StringConstructor;
3
- hideAfter: import("element-plus/es/utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
4
3
  width: import("element-plus/es/utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
5
4
  content: import("element-plus/es/utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
6
5
  popperStyle: import("element-plus/es/utils/props").BuildPropReturn<import("element-plus/es/utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
@@ -16,10 +16,6 @@ const usePopoverProps = {
16
16
  },
17
17
  ...buildProps({
18
18
  title: String,
19
- hideAfter: {
20
- type: Number,
21
- default: 200
22
- },
23
19
  width: {
24
20
  type: [String, Number],
25
21
  default: 150