carousel2.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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, COMPONENT_NAME);
  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. [vue.vShow, (_ctx.arrow === "always" || vue.unref(hover)) && (_ctx.loop || vue.unref(activeIndex) > 0)]
  116. ])
  117. ]),
  118. _: 1
  119. })) : vue.createCommentVNode("v-if", true),
  120. vue.unref(arrowDisplay) ? (vue.openBlock(), vue.createBlock(vue.Transition, {
  121. key: 1,
  122. name: "carousel-arrow-right",
  123. persisted: ""
  124. }, {
  125. default: vue.withCtx(() => [
  126. vue.withDirectives(vue.createElementVNode("button", {
  127. type: "button",
  128. class: vue.normalizeClass([vue.unref(ns).e("arrow"), vue.unref(ns).em("arrow", "right")]),
  129. "aria-label": vue.unref(t)("el.carousel.rightArrow"),
  130. onMouseenter: ($event) => vue.unref(handleButtonEnter)("right"),
  131. onMouseleave: vue.unref(handleButtonLeave),
  132. onClick: vue.withModifiers(($event) => vue.unref(throttledArrowClick)(vue.unref(activeIndex) + 1), ["stop"])
  133. }, [
  134. vue.createVNode(vue.unref(index$2.ElIcon), null, {
  135. default: vue.withCtx(() => [
  136. vue.createVNode(vue.unref(iconsVue.ArrowRight))
  137. ]),
  138. _: 1
  139. })
  140. ], 42, ["aria-label", "onMouseenter", "onMouseleave", "onClick"]), [
  141. [
  142. vue.vShow,
  143. (_ctx.arrow === "always" || vue.unref(hover)) && (_ctx.loop || vue.unref(activeIndex) < vue.unref(items).length - 1)
  144. ]
  145. ])
  146. ]),
  147. _: 1
  148. })) : vue.createCommentVNode("v-if", true),
  149. vue.createElementVNode("div", {
  150. class: vue.normalizeClass(vue.unref(ns).e("container")),
  151. style: vue.normalizeStyle(vue.unref(containerStyle)),
  152. onTransitionstart: handleTransitionStart,
  153. onTransitionend: handleTransitionEnd
  154. }, [
  155. vue.createVNode(vue.unref(PlaceholderItem)),
  156. vue.renderSlot(_ctx.$slots, "default")
  157. ], 38),
  158. vue.createVNode(vue.unref(ItemsSorter), null, {
  159. default: vue.withCtx(() => [
  160. _ctx.indicatorPosition !== "none" ? (vue.openBlock(), vue.createElementBlock("ul", {
  161. key: 0,
  162. class: vue.normalizeClass(vue.unref(indicatorsClasses))
  163. }, [
  164. (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(items), (item, index) => {
  165. return vue.withDirectives((vue.openBlock(), vue.createElementBlock("li", {
  166. key: index,
  167. class: vue.normalizeClass([
  168. vue.unref(ns).e("indicator"),
  169. vue.unref(ns).em("indicator", _ctx.direction),
  170. vue.unref(ns).is("active", index === vue.unref(activeIndex))
  171. ]),
  172. onMouseenter: ($event) => vue.unref(throttledIndicatorHover)(index),
  173. onClick: vue.withModifiers(($event) => vue.unref(handleIndicatorClick)(index), ["stop"])
  174. }, [
  175. vue.createElementVNode("button", {
  176. class: vue.normalizeClass(vue.unref(ns).e("button")),
  177. "aria-label": vue.unref(t)("el.carousel.indicator", { index: index + 1 })
  178. }, [
  179. vue.unref(hasLabel) ? (vue.openBlock(), vue.createElementBlock("span", { key: 0 }, vue.toDisplayString(item.props.label), 1)) : vue.createCommentVNode("v-if", true)
  180. ], 10, ["aria-label"])
  181. ], 42, ["onMouseenter", "onClick"])), [
  182. [vue.vShow, vue.unref(isTwoLengthShow)(index)]
  183. ]);
  184. }), 128))
  185. ], 2)) : vue.createCommentVNode("v-if", true)
  186. ]),
  187. _: 1
  188. }),
  189. _ctx.motionBlur ? (vue.openBlock(), vue.createElementBlock("svg", {
  190. key: 2,
  191. xmlns: "http://www.w3.org/2000/svg",
  192. version: "1.1",
  193. style: { "display": "none" }
  194. }, [
  195. vue.createElementVNode("defs", null, [
  196. vue.createElementVNode("filter", { id: "elCarouselHorizontal" }, [
  197. vue.createElementVNode("feGaussianBlur", {
  198. in: "SourceGraphic",
  199. stdDeviation: "12,0"
  200. })
  201. ]),
  202. vue.createElementVNode("filter", { id: "elCarouselVertical" }, [
  203. vue.createElementVNode("feGaussianBlur", {
  204. in: "SourceGraphic",
  205. stdDeviation: "0,10"
  206. })
  207. ])
  208. ])
  209. ])) : vue.createCommentVNode("v-if", true)
  210. ], 42, ["onMouseenter", "onMouseleave"]);
  211. };
  212. }
  213. });
  214. var Carousel = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "carousel.vue"]]);
  215. exports["default"] = Carousel;
  216. //# sourceMappingURL=carousel2.js.map