hongluan-ui
Version:
Hongluan Component Library for Vue 3
71 lines (68 loc) • 2.47 kB
JavaScript
import { defineComponent, ref, watch, toRef, computed, openBlock, createElementBlock, normalizeStyle, unref, createVNode, withCtx, renderSlot, createCommentVNode } from 'vue';
import '../../focus-trap/index.mjs';
import { tourContentProps, tourContentEmits } from './content2.mjs';
import { useFloating } from './helper.mjs';
import HlFocusTrap from '../../focus-trap/src/focus-trap.mjs';
const __default__ = defineComponent({
name: "TourContent"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: tourContentProps,
emits: tourContentEmits,
setup(__props, { emit }) {
const props = __props;
const placement = ref(props.placement);
const strategy = ref(props.strategy);
const contentRef = ref(null);
const arrowRef = ref(null);
watch(() => props.placement, () => {
placement.value = props.placement;
});
const { contentStyle, arrowStyle } = useFloating(toRef(props, "reference"), contentRef, arrowRef, placement, strategy, toRef(props, "offset"), toRef(props, "zIndex"), toRef(props, "showArrow"));
const side = computed(() => {
return placement.value.split("-")[0];
});
const onCloseRequested = () => {
emit("close");
};
const onFocusoutPrevented = (event) => {
if (event.detail.focusReason === "pointer") {
event.preventDefault();
}
};
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
ref_key: "contentRef",
ref: contentRef,
style: normalizeStyle(unref(contentStyle)),
class: "tour-content",
"data-side": unref(side),
tabindex: "-1"
}, [
createVNode(unref(HlFocusTrap), {
loop: "",
trapped: "",
"focus-start-el": "container",
"focus-trap-el": contentRef.value || void 0,
onReleaseRequested: onCloseRequested,
onFocusoutPrevented
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["focus-trap-el"]),
_ctx.showArrow ? (openBlock(), createElementBlock("span", {
key: 0,
ref_key: "arrowRef",
ref: arrowRef,
style: normalizeStyle(unref(arrowStyle)),
class: "tour-arrow"
}, null, 4)) : createCommentVNode("v-if", true)
], 12, ["data-side"]);
};
}
});
export { _sfc_main as default };
//# sourceMappingURL=content.mjs.map