UNPKG

various-ui

Version:

This is a test version of the Vue 3 component library

113 lines (110 loc) 4.54 kB
import { defineComponent, onMounted, onBeforeUnmount, openBlock, createElementBlock, mergeProps, unref, toHandlers, createCommentVNode, createElementVNode, renderSlot, createVNode, Fragment, renderList, normalizeClass } from 'vue'; import { UiCarouselPropsOption, UiCarouselEmits } from './index.mjs'; import { useComposable } from './src/composable.mjs'; import { UiIcon } from '../../icon/index.mjs'; const _hoisted_1 = { key: 2, class: "ui-carousel-schedules" }; const _hoisted_2 = ["onClick"]; const __default__ = defineComponent({ name: "UiCarousel" }); var _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: UiCarouselPropsOption, emits: UiCarouselEmits, setup(__props, { expose: __expose, emit: __emit }) { const define = __props; const emits = __emit; const { ons, refs, watchs, methods, computeds, variable } = useComposable(define, emits); const { main, active, container, childrens } = refs; const { switchCarousel, switchBack, switchNext, init } = methods; const { style, className, isLastControl, isFirstControl } = computeds; onMounted(() => { variable.observer = new ResizeObserver(() => methods.init()); if (main.value) { variable.observer.observe(main.value); } }); onBeforeUnmount(() => { variable.observer && variable.observer.disconnect(); refs.autoTimer.value && clearInterval(refs.autoTimer.value); watchs.stopAutoPlay && watchs.stopAutoPlay(); }); ; __expose({ init, switchBack, switchNext, switchCarousel }); return (_ctx, _cache) => { return openBlock(), createElementBlock( "div", mergeProps({ class: ["ui-carousel", unref(className)], style: unref(style) }, toHandlers(unref(ons).main, true)), [ createCommentVNode(" \u8F6E\u64AD\u56FE\u5BB9\u5668, \u7528\u6765\u63A7\u5236\u8F6E\u64AD\u6EDA\u52A8 "), createElementVNode( "div", { class: "ui-carousel-main", ref_key: "main", ref: main }, [ createElementVNode( "div", mergeProps({ class: "ui-carousel-container", ref_key: "container", ref: container }, toHandlers(unref(ons).container, true)), [ renderSlot(_ctx.$slots, "default") ], 16 /* FULL_PROPS */ ) ], 512 /* NEED_PATCH */ ), createCommentVNode(" \u8F6E\u64AD\u56FE\u5DE6\u4FA7\u7BAD\u5934 "), unref(isFirstControl) ? renderSlot(_ctx.$slots, "arrow-back", { key: 0 }, () => [ createElementVNode("div", { class: "ui-carousel-control ui-carousel-left-control", onClick: _cache[0] || (_cache[0] = ($event) => unref(switchCarousel)(unref(active) - 1)) }, [ createVNode(unref(UiIcon), { name: "arrow" }) ]) ]) : createCommentVNode("v-if", true), createCommentVNode(" \u8F6E\u64AD\u56FE\u53F3\u4FA7\u7BAD\u5934 "), unref(isLastControl) ? renderSlot(_ctx.$slots, "arrow-next", { key: 1 }, () => [ createElementVNode("div", { class: "ui-carousel-control ui-carousel-right-control", onClick: _cache[1] || (_cache[1] = ($event) => unref(switchCarousel)(unref(active) + 1)) }, [ createVNode(unref(UiIcon), { name: "arrow" }) ]) ]) : createCommentVNode("v-if", true), createCommentVNode(" \u8F6E\u64AD\u56FE\u5206\u9875\u5668 "), _ctx.pagination ? (openBlock(), createElementBlock("div", _hoisted_1, [ (openBlock(true), createElementBlock( Fragment, null, renderList(unref(childrens), (value, index) => { return openBlock(), createElementBlock("div", { class: normalizeClass(["ui-carousel-schedule", { active: index == unref(active) }]), onClick: ($event) => unref(switchCarousel)(index, value) }, null, 10, _hoisted_2); }), 256 /* UNKEYED_FRAGMENT */ )) ])) : createCommentVNode("v-if", true) ], 16 /* FULL_PROPS */ ); }; } }); export { _sfc_main as default }; //# sourceMappingURL=index.vue2.mjs.map