96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
import { useForwardExpose } from "../shared/useForwardExpose.js";
|
|
import { Arrow_default } from "../component/Arrow.js";
|
|
import { injectPopperContentContext } from "./PopperContent.js";
|
|
import { computed, createElementBlock, createVNode, defineComponent, mergeProps, normalizeStyle, openBlock, renderSlot, unref, withCtx } from "vue";
|
|
|
|
//#region src/Popper/PopperArrow.vue?vue&type=script&setup=true&lang.ts
|
|
const OPPOSITE_SIDE = {
|
|
top: "bottom",
|
|
right: "left",
|
|
bottom: "top",
|
|
left: "right"
|
|
};
|
|
var PopperArrow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
inheritAttrs: false,
|
|
__name: "PopperArrow",
|
|
props: {
|
|
width: {
|
|
type: Number,
|
|
required: false
|
|
},
|
|
height: {
|
|
type: Number,
|
|
required: false
|
|
},
|
|
rounded: {
|
|
type: Boolean,
|
|
required: false
|
|
},
|
|
asChild: {
|
|
type: Boolean,
|
|
required: false
|
|
},
|
|
as: {
|
|
type: null,
|
|
required: false,
|
|
default: "svg"
|
|
}
|
|
},
|
|
setup(__props) {
|
|
const { forwardRef } = useForwardExpose();
|
|
const contentContext = injectPopperContentContext();
|
|
const baseSide = computed(() => OPPOSITE_SIDE[contentContext.placedSide.value]);
|
|
return (_ctx, _cache) => {
|
|
return openBlock(), createElementBlock("span", {
|
|
ref: (el) => {
|
|
unref(contentContext).onArrowChange(el);
|
|
return void 0;
|
|
},
|
|
style: normalizeStyle({
|
|
position: "absolute",
|
|
left: unref(contentContext).arrowX?.value ? `${unref(contentContext).arrowX?.value}px` : void 0,
|
|
top: unref(contentContext).arrowY?.value ? `${unref(contentContext).arrowY?.value}px` : void 0,
|
|
[baseSide.value]: 0,
|
|
transformOrigin: {
|
|
top: "",
|
|
right: "0 0",
|
|
bottom: "center 0",
|
|
left: "100% 0"
|
|
}[unref(contentContext).placedSide.value],
|
|
transform: {
|
|
top: "translateY(100%)",
|
|
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
bottom: `rotate(180deg)`,
|
|
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
}[unref(contentContext).placedSide.value],
|
|
visibility: unref(contentContext).shouldHideArrow.value ? "hidden" : void 0
|
|
})
|
|
}, [createVNode(Arrow_default, mergeProps(_ctx.$attrs, {
|
|
ref: unref(forwardRef),
|
|
style: { display: "block" },
|
|
as: _ctx.as,
|
|
"as-child": _ctx.asChild,
|
|
rounded: _ctx.rounded,
|
|
width: _ctx.width,
|
|
height: _ctx.height
|
|
}), {
|
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
_: 3
|
|
}, 16, [
|
|
"as",
|
|
"as-child",
|
|
"rounded",
|
|
"width",
|
|
"height"
|
|
])], 4);
|
|
};
|
|
}
|
|
});
|
|
|
|
//#endregion
|
|
//#region src/Popper/PopperArrow.vue
|
|
var PopperArrow_default = PopperArrow_vue_vue_type_script_setup_true_lang_default;
|
|
|
|
//#endregion
|
|
export { PopperArrow_default };
|
|
//# sourceMappingURL=PopperArrow.js.map
|