hongluan-ui
Version:
Hongluan Component Library for Vue 3
63 lines (58 loc) • 2.17 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../hooks/index.js');
var carouselIndicator = require('./carousel-indicator.js');
require('../../../tokens/index.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var carousel = require('../../../tokens/carousel.js');
const _sfc_main = vue.defineComponent({
name: "CarouselIndicator",
props: carouselIndicator.carouselIndicatorProps,
emits: ["click", "hover"],
setup(props, { emit }) {
const { namespace } = index.useNamespace("carousel-indicator");
const data = vue.reactive({
active: -1,
indicatorIndex: props.index
});
const injectIndicatorScope = vue.inject(carousel.carouselIndicatorContextKey);
vue.watch(() => injectIndicatorScope.activeIndex.value, (current) => {
data.active = current;
}, { immediate: true });
function handleItemClick() {
if (injectIndicatorScope.handleIndicatorClick) {
injectIndicatorScope.handleIndicatorClick(props.index);
}
emit("click", props.index);
}
function handlethrottledIndicatorHover() {
if (injectIndicatorScope.throttledIndicatorHover) {
injectIndicatorScope.throttledIndicatorHover(props.index);
}
emit("hover", props.index);
}
return {
namespace,
data,
handleItemClick,
handlethrottledIndicatorHover
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([
{ "is-active": _ctx.data.indicatorIndex === _ctx.data.active },
_ctx.namespace
]),
onClick: _ctx.handleItemClick,
onMouseenter: _ctx.handlethrottledIndicatorHover
}, [
vue.renderSlot(_ctx.$slots, "default")
], 42, ["onClick", "onMouseenter"]);
}
var CarouselIndicator = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]);
exports["default"] = CarouselIndicator;
//# sourceMappingURL=carousel-indicator2.js.map