3cd8884e450897be43bc762dc700a9bad4342e6f1867cc5e47252c947f2440d1bd7710a734485001a3195c7ced010460d6b6ca9f9c57b7f2271cdd9a19b03a 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var index$2 = require('../../icon/index.js');
  5. var iconsVue = require('@element-plus/icons-vue');
  6. var carousel = require('./carousel.js');
  7. var useCarousel = require('./use-carousel.js');
  8. var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
  9. var index = require('../../../hooks/use-namespace/index.js');
  10. var index$1 = require('../../../hooks/use-locale/index.js');
  11. const COMPONENT_NAME = "ElCarousel";
  12. const __default__ = vue.defineComponent({
  13. name: COMPONENT_NAME
  14. });
  15. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  16. ...__default__,
  17. props: carousel.carouselProps,
  18. emits: carousel.carouselEmits,
  19. setup(__props, { expose, emit }) {
  20. const props = __props;
  21. const {
  22. root,
  23. activeIndex,
  24. exposeActiveIndex,
  25. arrowDisplay,
  26. hasLabel,
  27. hover,
  28. isCardType,
  29. items,
  30. isVertical,
  31. containerStyle,
  32. handleButtonEnter,
  33. handleButtonLeave,
  34. handleIndicatorClick,
  35. handleMouseEnter,
  36. handleMouseLeave,
  37. setActiveItem,
  38. prev,
  39. next,
  40. PlaceholderItem,
  41. isTwoLengthShow,
  42. ItemsSorter,
  43. throttledArrowClick,
  44. throttledIndicatorHover
  45. } = useCarousel.useCarousel(props, emit);
  46. const ns = index.useNamespace("carousel");
  47. const { t } = index$1.useLocale();
  48. const carouselClasses = vue.computed(() => {
  49. const classes = [ns.b(), ns.m(props.direction)];
  50. if (vue.unref(isCardType)) {
  51. classes.push(ns.m("card"));
  52. }
  53. return classes;
  54. });
  55. const indicatorsClasses = vue.computed(() => {
  56. const classes = [ns.e("indicators"), ns.em("indicators", props.direction)];
  57. if (vue.unref(hasLabel)) {
  58. classes.push(ns.em("indicators", "labels"));
  59. }
  60. if (props.indicatorPosition === "outside") {
  61. classes.push(ns.em("indicators", "outside"));
  62. }
  63. if (vue.unref(isVertical)) {
  64. classes.push(ns.em("indicators", "right"));
  65. }
  66. return classes;
  67. });
  68. function handleTransitionStart(e) {
  69. if (!props.motionBlur)
  70. return;
  71. const kls = vue.unref(isVertical) ? `${ns.namespace.value}-transitioning-vertical` : `${ns.namespace.value}-transitioning`;
  72. e.currentTarget.classList.add(kls);
  73. }
  74. function handleTransitionEnd(e) {
  75. if (!props.motionBlur)
  76. return;
  77. const kls = vue.unref(isVertical) ? `${ns.namespace.value}-transitioning-vertical` : `${ns.namespace.value}-transitioning`;
  78. e.currentTarget.classList.remove(kls);
  79. }
  80. expose({
  81. activeIndex: exposeActiveIndex,
  82. setActiveItem,
  83. prev,
  84. next
  85. });
  86. return (_ctx, _cache) => {
  87. return vue.openBlock(), vue.createElementBlock("div", {
  88. ref_key: "root",
  89. ref: root,
  90. class: vue.normalizeClass(vue.unref(carouselClasses)),
  91. onMouseenter: vue.withModifiers(vue.unref(handleMouseEnter), ["stop"]),
  92. onMouseleave: vue.withModifiers(vue.unref(handleMouseLeave), ["stop"])
  93. }, [
  94. vue.unref(arrowDisplay) ? (vue.openBlock(), vue.createBlock(vue.Transition, {
  95. key: 0,
  96. name: "carousel-arrow-left",
  97. persisted: ""
  98. }, {
  99. default: vue.withCtx(() => [
  100. vue.withDirectives(vue.createElementVNode("button", {
  101. type: "button",
  102. class: vue.normalizeClass([vue.unref(ns).e("arrow"), vue.unref(ns).em("arrow", "left")]),
  103. "aria-label": vue.unref(t)("el.carousel.leftArrow"),
  104. onMouseenter: ($event) => vue.unref(handleButtonEnter)("left"),
  105. onMouseleave: vue.unref(handleButtonLeave),
  106. onClick: vue.withModifiers(($event) => vue.unref(throttledArrowClick)(vue.unref(activeIndex) - 1), ["stop"])
  107. }, [
  108. vue.createVNode(vue.unref(index$2.ElIcon), null, {
  109. default: vue.withCtx(() => [
  110. vue.createVNode(vue.unref(iconsVue.ArrowLeft))
  111. ]),
  112. _: 1
  113. })
  114. ], 42, ["aria-label", "onMouseenter", "onMouseleave", "onClick"]), [
  115. [
  116. vue.vShow,
  117. (_ctx.arrow === "always" || vue.unref(hover)) && (props.loop || vue.unref(activeIndex) > 0)
  118. ]
  119. ])
  120. ]),
  121. _: 1
  122. })) : vue.createCommentVNode("v-if", true),
  123. vue.unref(arrowDisplay) ? (vue.openBlock(), vue.createBlock(vue.Transition, {
  124. key: 1,
  125. name: "carousel-arrow-right",
  126. persisted: ""
  127. }, {
  128. default: vue.withCtx(() => [
  129. vue.withDirectives(vue.createElementVNode("button", {
  130. type: "button",
  131. class: vue.normalizeClass([vue.unref(ns).e("arrow"), vue.unref(ns).em("arrow", "right")]),
  132. "aria-label": vue.unref(t)("el.carousel.rightArrow"),
  133. onMouseenter: ($event) => vue.unref(handleButtonEnter)("right"),
  134. onMouseleave: vue.unref(handleButtonLeave),
  135. onClick: vue.withModifiers(($event) => vue.unref(throttledArrowClick)(vue.unref(activeIndex) + 1), ["stop"])
  136. }, [
  137. vue.createVNode(vue.unref(index$2.ElIcon), null, {
  138. default: vue.withCtx(() => [
  139. vue.createVNode(vue.unref(iconsVue.ArrowRight))
  140. ]),
  141. _: 1
  142. })
  143. ], 42, ["aria-label", "onMouseenter", "onMouseleave", "onClick"]), [
  144. [
  145. vue.vShow,
  146. (_ctx.arrow === "always" || vue.unref(hover)) && (props.loop || vue.unref(activeIndex) < vue.unref(items).length - 1)
  147. ]
  148. ])
  149. ]),
  150. _: 1
  151. })) : vue.createCommentVNode("v-if", true),
  152. vue.createElementVNode("div", {
  153. class: vue.normalizeClass(vue.unref(ns).e("container")),
  154. style: vue.normalizeStyle(vue.unref(containerStyle)),
  155. onTransitionstart: handleTransitionStart,
  156. onTransitionend: handleTransitionEnd
  157. }, [
  158. vue.createVNode(vue.unref(PlaceholderItem)),
  159. vue.renderSlot(_ctx.$slots, "default")
  160. ], 38),
  161. vue.createVNode(vue.unref(ItemsSorter), null, {
  162. default: vue.withCtx(() => [
  163. _ctx.indicatorPosition !== "none" ? (vue.openBlock(), vue.createElementBlock("ul", {
  164. key: 0,
  165. class: vue.normalizeClass(vue.unref(indicatorsClasses))
  166. }, [
  167. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(items), (item, index) => {
  168. return vue.withDirectives((vue.openBlock(), vue.createElementBlock("li", {
  169. key: index,
  170. class: vue.normalizeClass([
  171. vue.unref(ns).e("indicator"),
  172. vue.unref(ns).em("indicator", _ctx.direction),
  173. vue.unref(ns).is("active", index === vue.unref(activeIndex))
  174. ]),
  175. onMouseenter: ($event) => vue.unref(throttledIndicatorHover)(index),
  176. onClick: vue.withModifiers(($event) => vue.unref(handleIndicatorClick)(index), ["stop"])
  177. }, [
  178. vue.createElementVNode("button", {
  179. class: vue.normalizeClass(vue.unref(ns).e("button")),
  180. "aria-label": vue.unref(t)("el.carousel.indicator", { index: index + 1 })
  181. }, [
  182. vue.unref(hasLabel) ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, vue.toDisplayString(item.props.label), 1)) : vue.createCommentVNode("v-if", true)
  183. ], 10, ["aria-label"])
  184. ], 42, ["onMouseenter", "onClick"])), [
  185. [vue.vShow, vue.unref(isTwoLengthShow)(index)]
  186. ]);
  187. }), 128))
  188. ], 2)) : vue.createCommentVNode("v-if", true)
  189. ]),
  190. _: 1
  191. }),
  192. props.motionBlur ? (vue.openBlock(), vue.createElementBlock("svg", {
  193. key: 2,
  194. xmlns: "http://www.w3.org/2000/svg",
  195. version: "1.1",
  196. style: { "display": "none" }
  197. }, [
  198. vue.createElementVNode("defs", null, [
  199. vue.createElementVNode("filter", { id: "elCarouselHorizontal" }, [
  200. vue.createElementVNode("feGaussianBlur", {
  201. in: "SourceGraphic",
  202. stdDeviation: "12,0"
  203. })
  204. ]),
  205. vue.createElementVNode("filter", { id: "elCarouselVertical" }, [
  206. vue.createElementVNode("feGaussianBlur", {
  207. in: "SourceGraphic",
  208. stdDeviation: "0,10"
  209. })
  210. ])
  211. ])
  212. ])) : vue.createCommentVNode("v-if", true)
  213. ], 42, ["onMouseenter", "onMouseleave"]);
  214. };
  215. }
  216. });
  217. var Carousel = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "carousel.vue"]]);
  218. exports["default"] = Carousel;
  219. //# sourceMappingURL=carousel2.js.map