Files
appco_dist/.output/server/chunks/build/index-DN2Eqyc3.mjs
T
2026-02-23 12:50:59 +03:30

2460 lines
72 KiB
JavaScript

import { V as withInstall, z as useConfigInject, R as filterEmpty, W as isValidElement, X as isFragment, A as classNames, Y as getTransitionName, Z as cloneElement, Q as initDefaultProps, $ as getStyle$1, P as PropTypes, B as genComponentStyleHook, C as merge, a0 as initZoomMotion, S as getPropsSlot, a1 as getSlot, a2 as getEvents, a3 as contains, a4 as Portal, a5 as hasProp, a6 as getComponent, a7 as findDOMNode, a8 as useProvidePortal, a9 as objectType, J as resetComponent, aa as getOptionProps, ab as flattenChildren, ac as getMotion$1, ad as getTransitionProps } from './server.mjs';
import _extends from '@babel/runtime/helpers/esm/extends';
import { defineComponent, computed, ref, watch, createVNode, shallowRef, watchEffect, Fragment, provide, inject, nextTick, Transition, toRef, withDirectives, withModifiers, vShow, resolveDirective } from 'vue';
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
import { alignElement, alignPoint } from 'dom-align';
let raf = (callback) => setTimeout(callback, 16);
let caf = (num) => clearTimeout(num);
let rafUUID = 0;
const rafIds = /* @__PURE__ */ new Map();
function cleanup(id) {
rafIds.delete(id);
}
function wrapperRaf(callback) {
let times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
rafUUID += 1;
const id = rafUUID;
function callRef(leftTimes) {
if (leftTimes === 0) {
cleanup(id);
callback();
} else {
const realId = raf(() => {
callRef(leftTimes - 1);
});
rafIds.set(id, realId);
}
}
callRef(times);
return id;
}
wrapperRaf.cancel = (id) => {
const realId = rafIds.get(id);
cleanup(realId);
return caf(realId);
};
let supportsPassive = false;
try {
const opts = Object.defineProperty({}, "passive", {
get() {
supportsPassive = true;
}
});
(void 0).addEventListener("testPassive", null, opts);
(void 0).removeEventListener("testPassive", null, opts);
} catch (e) {
}
function addEventListenerWrap(target, eventType, cb, option) {
if (target && target.addEventListener) {
let opt = option;
if (opt === void 0 && supportsPassive && (eventType === "touchstart" || eventType === "touchmove" || eventType === "wheel")) {
opt = {
passive: false
};
}
target.addEventListener(eventType, cb, opt);
}
return {
remove: () => {
if (target && target.removeEventListener) {
target.removeEventListener(eventType, cb);
}
}
};
}
const PresetColors = ["blue", "purple", "cyan", "green", "magenta", "pink", "red", "orange", "yellow", "volcano", "geekblue", "lime", "gold"];
const roundedArrow = (width, innerRadius, outerRadius, bgColor, boxShadow) => {
const unitWidth = width / 2;
const ax = 0;
const ay = unitWidth;
const bx = outerRadius * 1 / Math.sqrt(2);
const by = unitWidth - outerRadius * (1 - 1 / Math.sqrt(2));
const cx = unitWidth - innerRadius * (1 / Math.sqrt(2));
const cy = outerRadius * (Math.sqrt(2) - 1) + innerRadius * (1 / Math.sqrt(2));
const dx = 2 * unitWidth - cx;
const dy = cy;
const ex = 2 * unitWidth - bx;
const ey = by;
const fx = 2 * unitWidth - ax;
const fy = ay;
const shadowWidth = unitWidth * Math.sqrt(2) + outerRadius * (Math.sqrt(2) - 2);
const polygonOffset = outerRadius * (Math.sqrt(2) - 1);
return {
pointerEvents: "none",
width,
height: width,
overflow: "hidden",
"&::after": {
content: '""',
position: "absolute",
width: shadowWidth,
height: shadowWidth,
bottom: 0,
insetInline: 0,
margin: "auto",
borderRadius: {
_skip_check_: true,
value: `0 0 ${innerRadius}px 0`
},
transform: "translateY(50%) rotate(-135deg)",
boxShadow,
zIndex: 0,
background: "transparent"
},
"&::before": {
position: "absolute",
bottom: 0,
insetInlineStart: 0,
width,
height: width / 2,
background: bgColor,
clipPath: {
_multi_value_: true,
value: [`polygon(${polygonOffset}px 100%, 50% ${polygonOffset}px, ${2 * unitWidth - polygonOffset}px 100%, ${polygonOffset}px 100%)`, `path('M ${ax} ${ay} A ${outerRadius} ${outerRadius} 0 0 0 ${bx} ${by} L ${cx} ${cy} A ${innerRadius} ${innerRadius} 0 0 1 ${dx} ${dy} L ${ex} ${ey} A ${outerRadius} ${outerRadius} 0 0 0 ${fx} ${fy} Z')`]
},
content: '""'
}
};
};
function genPresetColor(token, genCss) {
return PresetColors.reduce((prev, colorKey) => {
const lightColor = token[`${colorKey}-1`];
const lightBorderColor = token[`${colorKey}-3`];
const darkColor = token[`${colorKey}-6`];
const textColor = token[`${colorKey}-7`];
return _extends(_extends({}, prev), genCss(colorKey, {
lightColor,
lightBorderColor,
darkColor,
textColor
}));
}, {});
}
function returnEmptyString() {
return "";
}
function returnDocument(element) {
if (element) {
return element.ownerDocument;
}
return (void 0).document;
}
function noop$1() {
}
const triggerProps = () => ({
action: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]).def([]),
showAction: PropTypes.any.def([]),
hideAction: PropTypes.any.def([]),
getPopupClassNameFromAlign: PropTypes.any.def(returnEmptyString),
onPopupVisibleChange: Function,
afterPopupVisibleChange: PropTypes.func.def(noop$1),
popup: PropTypes.any,
popupStyle: {
type: Object,
default: void 0
},
prefixCls: PropTypes.string.def("rc-trigger-popup"),
popupClassName: PropTypes.string.def(""),
popupPlacement: String,
builtinPlacements: PropTypes.object,
popupTransitionName: String,
popupAnimation: PropTypes.any,
mouseEnterDelay: PropTypes.number.def(0),
mouseLeaveDelay: PropTypes.number.def(0.1),
zIndex: Number,
focusDelay: PropTypes.number.def(0),
blurDelay: PropTypes.number.def(0.15),
getPopupContainer: Function,
getDocument: PropTypes.func.def(returnDocument),
forceRender: {
type: Boolean,
default: void 0
},
destroyPopupOnHide: {
type: Boolean,
default: false
},
mask: {
type: Boolean,
default: false
},
maskClosable: {
type: Boolean,
default: true
},
// onPopupAlign: PropTypes.func.def(noop),
popupAlign: PropTypes.object.def(() => ({})),
popupVisible: {
type: Boolean,
default: void 0
},
defaultPopupVisible: {
type: Boolean,
default: false
},
maskTransitionName: String,
maskAnimation: String,
stretch: String,
alignPoint: {
type: Boolean,
default: void 0
},
autoDestroy: {
type: Boolean,
default: false
},
mobile: Object,
getTriggerDOMNode: Function
});
const innerProps = {
visible: Boolean,
prefixCls: String,
zIndex: Number,
destroyPopupOnHide: Boolean,
forceRender: Boolean,
// Legacy Motion
animation: [String, Object],
transitionName: String,
// Measure
stretch: {
type: String
},
// Align
align: {
type: Object
},
point: {
type: Object
},
getRootDomNode: {
type: Function
},
getClassNameFromAlign: {
type: Function
},
onAlign: {
type: Function
},
onMouseenter: {
type: Function
},
onMouseleave: {
type: Function
},
onMousedown: {
type: Function
},
onTouchstart: {
type: Function
}
};
const mobileProps = _extends(_extends({}, innerProps), {
mobile: {
type: Object
}
});
const popupProps = _extends(_extends({}, innerProps), {
mask: Boolean,
mobile: {
type: Object
},
maskAnimation: String,
maskTransitionName: String
});
function Mask(props) {
const {
prefixCls,
visible,
zIndex,
mask,
maskAnimation,
maskTransitionName
} = props;
if (!mask) {
return null;
}
let motion = {};
if (maskTransitionName || maskAnimation) {
motion = getMotion$1({
prefixCls,
transitionName: maskTransitionName,
animation: maskAnimation
});
}
return createVNode(Transition, _objectSpread({
"appear": true
}, motion), {
default: () => [withDirectives(createVNode("div", {
"style": {
zIndex
},
"class": `${prefixCls}-mask`
}, null), [[resolveDirective("if"), visible]])]
});
}
Mask.displayName = "Mask";
const MobilePopupInner = defineComponent({
compatConfig: {
MODE: 3
},
name: "MobilePopupInner",
inheritAttrs: false,
props: mobileProps,
emits: ["mouseenter", "mouseleave", "mousedown", "touchstart", "align"],
setup(props, _ref) {
let {
expose,
slots
} = _ref;
const elementRef = ref();
expose({
forceAlign: () => {
},
getElement: () => elementRef.value
});
return () => {
var _a;
const {
zIndex,
visible,
prefixCls,
mobile: {
popupClassName,
popupStyle,
popupMotion = {},
popupRender
} = {}
} = props;
const mergedStyle = _extends({
zIndex
}, popupStyle);
let childNode = flattenChildren((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots));
if (childNode.length > 1) {
childNode = createVNode("div", {
"class": `${prefixCls}-content`
}, [childNode]);
}
if (popupRender) {
childNode = popupRender(childNode);
}
const mergedClassName = classNames(prefixCls, popupClassName);
return createVNode(Transition, _objectSpread({
"ref": elementRef
}, popupMotion), {
default: () => [visible ? createVNode("div", {
"class": mergedClassName,
"style": mergedStyle
}, [childNode]) : null]
});
};
}
});
const useVisibleStatus = ((visible, doMeasure) => {
const status = shallowRef(null);
const rafRef = shallowRef();
const destroyRef = shallowRef(false);
function setStatus(nextStatus) {
if (!destroyRef.value) {
status.value = nextStatus;
}
}
function cancelRaf() {
wrapperRaf.cancel(rafRef.value);
}
function goNextStatus(callback) {
cancelRaf();
rafRef.value = wrapperRaf(() => {
let newStatus = status.value;
switch (status.value) {
case "align":
newStatus = "motion";
break;
case "motion":
newStatus = "stable";
break;
}
setStatus(newStatus);
callback === null || callback === void 0 ? void 0 : callback();
});
}
watch(visible, () => {
setStatus("measure");
}, {
immediate: true,
flush: "post"
});
return [status, goNextStatus];
});
const useStretchStyle = ((stretch) => {
const targetSize = shallowRef({
width: 0,
height: 0
});
function measureStretch(element) {
targetSize.value = {
width: element.offsetWidth,
height: element.offsetHeight
};
}
const style = computed(() => {
const sizeStyle = {};
if (stretch.value) {
const {
width,
height
} = targetSize.value;
if (stretch.value.indexOf("height") !== -1 && height) {
sizeStyle.height = `${height}px`;
} else if (stretch.value.indexOf("minHeight") !== -1 && height) {
sizeStyle.minHeight = `${height}px`;
}
if (stretch.value.indexOf("width") !== -1 && width) {
sizeStyle.width = `${width}px`;
} else if (stretch.value.indexOf("minWidth") !== -1 && width) {
sizeStyle.minWidth = `${width}px`;
}
}
return sizeStyle;
});
return [style, measureStretch];
});
const isVisible = ((element) => {
if (!element) {
return false;
}
if (element.offsetParent) {
return true;
}
if (element.getBBox) {
const box = element.getBBox();
if (box.width || box.height) {
return true;
}
}
if (element.getBoundingClientRect) {
const box = element.getBoundingClientRect();
if (box.width || box.height) {
return true;
}
}
return false;
});
function restoreFocus(activeElement, container) {
if (activeElement !== (void 0).activeElement && contains(container, activeElement) && typeof activeElement.focus === "function") {
activeElement.focus();
}
}
const useBuffer = ((callback, buffer) => {
let called = false;
let timeout = null;
function cancelTrigger() {
clearTimeout(timeout);
}
function trigger(force) {
if (!called || force === true) {
if (callback() === false) {
return;
}
called = true;
cancelTrigger();
timeout = setTimeout(() => {
called = false;
}, buffer.value);
} else {
cancelTrigger();
timeout = setTimeout(() => {
called = false;
trigger();
}, buffer.value);
}
}
return [trigger, () => {
called = false;
cancelTrigger();
}];
});
const alignProps = {
align: Object,
target: [Object, Function],
onAlign: Function,
monitorBufferTime: Number,
monitorWindowResize: Boolean,
disabled: Boolean
};
function getElement(func) {
if (typeof func !== "function") return null;
return func();
}
function getPoint(point) {
if (typeof point !== "object" || !point) return null;
return point;
}
const Align = defineComponent({
compatConfig: {
MODE: 3
},
name: "Align",
props: alignProps,
emits: ["align"],
setup(props, _ref) {
let {
expose,
slots
} = _ref;
const cacheRef = ref({});
const nodeRef = ref();
const [forceAlign, cancelForceAlign] = useBuffer(() => {
const {
disabled: latestDisabled,
target: latestTarget,
align: latestAlign,
onAlign: latestOnAlign
} = props;
if (!latestDisabled && latestTarget && nodeRef.value) {
const source = nodeRef.value;
let result;
const element = getElement(latestTarget);
const point = getPoint(latestTarget);
cacheRef.value.element = element;
cacheRef.value.point = point;
cacheRef.value.align = latestAlign;
const {
activeElement
} = void 0;
if (element && isVisible(element)) {
result = alignElement(source, element, latestAlign);
} else if (point) {
result = alignPoint(source, point, latestAlign);
}
restoreFocus(activeElement, source);
if (latestOnAlign && result) {
latestOnAlign(source, result);
}
return true;
}
return false;
}, computed(() => props.monitorBufferTime));
ref({
cancel: () => {
}
});
ref({
cancel: () => {
}
});
watch(() => props.disabled, (disabled) => {
if (!disabled) {
forceAlign();
} else {
cancelForceAlign();
}
}, {
immediate: true,
flush: "post"
});
const winResizeRef = ref(null);
watch(() => props.monitorWindowResize, (monitorWindowResize) => {
if (monitorWindowResize) {
if (!winResizeRef.value) {
winResizeRef.value = addEventListenerWrap(void 0, "resize", forceAlign);
}
} else if (winResizeRef.value) {
winResizeRef.value.remove();
winResizeRef.value = null;
}
}, {
flush: "post"
});
expose({
forceAlign: () => forceAlign(true)
});
return () => {
const child = slots === null || slots === void 0 ? void 0 : slots.default();
if (child) {
return cloneElement(child[0], {
ref: nodeRef
}, true, true);
}
return null;
};
}
});
const PopupInner = defineComponent({
compatConfig: {
MODE: 3
},
name: "PopupInner",
inheritAttrs: false,
props: innerProps,
emits: ["mouseenter", "mouseleave", "mousedown", "touchstart", "align"],
setup(props, _ref) {
let {
expose,
attrs,
slots
} = _ref;
const alignRef = shallowRef();
const elementRef = shallowRef();
const alignedClassName = shallowRef();
const [stretchStyle] = useStretchStyle(toRef(props, "stretch"));
const visible = shallowRef(false);
let timeoutId;
watch(() => props.visible, (val) => {
clearTimeout(timeoutId);
if (val) {
timeoutId = setTimeout(() => {
visible.value = props.visible;
});
} else {
visible.value = false;
}
}, {
immediate: true
});
const [status, goNextStatus] = useVisibleStatus(visible);
const prepareResolveRef = shallowRef();
const getAlignTarget = () => {
if (props.point) {
return props.point;
}
return props.getRootDomNode;
};
const forceAlign = () => {
var _a;
(_a = alignRef.value) === null || _a === void 0 ? void 0 : _a.forceAlign();
};
const onInternalAlign = (popupDomNode, matchAlign) => {
var _a;
const nextAlignedClassName = props.getClassNameFromAlign(matchAlign);
const preAlignedClassName = alignedClassName.value;
if (alignedClassName.value !== nextAlignedClassName) {
alignedClassName.value = nextAlignedClassName;
}
if (status.value === "align") {
if (preAlignedClassName !== nextAlignedClassName) {
Promise.resolve().then(() => {
forceAlign();
});
} else {
goNextStatus(() => {
var _a2;
(_a2 = prepareResolveRef.value) === null || _a2 === void 0 ? void 0 : _a2.call(prepareResolveRef);
});
}
(_a = props.onAlign) === null || _a === void 0 ? void 0 : _a.call(props, popupDomNode, matchAlign);
}
};
const motion = computed(() => {
const m = typeof props.animation === "object" ? props.animation : getMotion$1(props);
["onAfterEnter", "onAfterLeave"].forEach((eventName) => {
const originFn = m[eventName];
m[eventName] = (node) => {
goNextStatus();
status.value = "stable";
originFn === null || originFn === void 0 ? void 0 : originFn(node);
};
});
return m;
});
const onShowPrepare = () => {
return new Promise((resolve) => {
prepareResolveRef.value = resolve;
});
};
watch([motion, status], () => {
if (!motion.value && status.value === "motion") {
goNextStatus();
}
}, {
immediate: true
});
expose({
forceAlign,
getElement: () => {
return elementRef.value.$el || elementRef.value;
}
});
const alignDisabled = computed(() => {
var _a;
if (((_a = props.align) === null || _a === void 0 ? void 0 : _a.points) && (status.value === "align" || status.value === "stable")) {
return false;
}
return true;
});
return () => {
var _a;
const {
zIndex,
align,
prefixCls,
destroyPopupOnHide,
onMouseenter,
onMouseleave,
onTouchstart = () => {
},
onMousedown
} = props;
const statusValue = status.value;
const mergedStyle = [_extends(_extends({}, stretchStyle.value), {
zIndex,
opacity: statusValue === "motion" || statusValue === "stable" || !visible.value ? null : 0,
// pointerEvents: statusValue === 'stable' ? null : 'none',
pointerEvents: !visible.value && statusValue !== "stable" ? "none" : null
}), attrs.style];
let childNode = flattenChildren((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots, {
visible: props.visible
}));
if (childNode.length > 1) {
childNode = createVNode("div", {
"class": `${prefixCls}-content`
}, [childNode]);
}
const mergedClassName = classNames(prefixCls, attrs.class, alignedClassName.value);
const hasAnimate = visible.value || !props.visible;
const transitionProps = hasAnimate ? getTransitionProps(motion.value.name, motion.value) : {};
return createVNode(Transition, _objectSpread(_objectSpread({
"ref": elementRef
}, transitionProps), {}, {
"onBeforeEnter": onShowPrepare
}), {
default: () => {
return !destroyPopupOnHide || props.visible ? withDirectives(createVNode(Align, {
"target": getAlignTarget(),
"key": "popup",
"ref": alignRef,
"monitorWindowResize": true,
"disabled": alignDisabled.value,
"align": align,
"onAlign": onInternalAlign
}, {
default: () => createVNode("div", {
"class": mergedClassName,
"onMouseenter": onMouseenter,
"onMouseleave": onMouseleave,
"onMousedown": withModifiers(onMousedown, ["capture"]),
[supportsPassive ? "onTouchstartPassive" : "onTouchstart"]: withModifiers(onTouchstart, ["capture"]),
"style": mergedStyle
}, [childNode])
}), [[vShow, visible.value]]) : null;
}
});
};
}
});
const Popup = defineComponent({
compatConfig: {
MODE: 3
},
name: "Popup",
inheritAttrs: false,
props: popupProps,
setup(props, _ref) {
let {
attrs,
slots,
expose
} = _ref;
const innerVisible = shallowRef(false);
const inMobile = shallowRef(false);
const popupRef = shallowRef();
const rootRef = shallowRef();
watch([() => props.visible, () => props.mobile], () => {
innerVisible.value = props.visible;
if (props.visible && props.mobile) {
inMobile.value = true;
}
}, {
immediate: true,
flush: "post"
});
expose({
forceAlign: () => {
var _a;
(_a = popupRef.value) === null || _a === void 0 ? void 0 : _a.forceAlign();
},
getElement: () => {
var _a;
return (_a = popupRef.value) === null || _a === void 0 ? void 0 : _a.getElement();
}
});
return () => {
const cloneProps = _extends(_extends(_extends({}, props), attrs), {
visible: innerVisible.value
});
const popupNode = inMobile.value ? createVNode(MobilePopupInner, _objectSpread(_objectSpread({}, cloneProps), {}, {
"mobile": props.mobile,
"ref": popupRef
}), {
default: slots.default
}) : createVNode(PopupInner, _objectSpread(_objectSpread({}, cloneProps), {}, {
"ref": popupRef
}), {
default: slots.default
});
return createVNode("div", {
"ref": rootRef
}, [createVNode(Mask, cloneProps, null), popupNode]);
};
}
});
function isPointsEq(a1, a2, isAlignPoint) {
if (isAlignPoint) {
return a1[0] === a2[0];
}
return a1[0] === a2[0] && a1[1] === a2[1];
}
function getAlignFromPlacement(builtinPlacements, placementStr, align) {
const baseAlign = builtinPlacements[placementStr] || {};
return _extends(_extends({}, baseAlign), align);
}
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
const {
points
} = align;
const placements2 = Object.keys(builtinPlacements);
for (let i = 0; i < placements2.length; i += 1) {
const placement = placements2[i];
if (isPointsEq(builtinPlacements[placement].points, points, isAlignPoint)) {
return `${prefixCls}-placement-${placement}`;
}
}
return "";
}
const BaseMixin = {
methods: {
setState() {
let state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
let callback = arguments.length > 1 ? arguments[1] : void 0;
let newState = typeof state === "function" ? state(this.$data, this.$props) : state;
if (this.getDerivedStateFromProps) {
const s = this.getDerivedStateFromProps(getOptionProps(this), _extends(_extends({}, this.$data), newState));
if (s === null) {
return;
} else {
newState = _extends(_extends({}, newState), s || {});
}
}
_extends(this.$data, newState);
if (this._.isMounted) {
this.$forceUpdate();
}
nextTick(() => {
callback && callback();
});
},
__emit() {
const args = [].slice.call(arguments, 0);
let eventName = args[0];
eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;
const event = this.$props[eventName] || this.$attrs[eventName];
if (args.length && event) {
if (Array.isArray(event)) {
for (let i = 0, l = event.length; i < l; i++) {
event[i](...args.slice(1));
}
} else {
event(...args.slice(1));
}
}
}
}
};
const ALL_HANDLERS = ["onClick", "onMousedown", "onTouchstart", "onMouseenter", "onMouseleave", "onFocus", "onBlur", "onContextmenu"];
const Trigger = defineComponent({
compatConfig: {
MODE: 3
},
name: "Trigger",
mixins: [BaseMixin],
inheritAttrs: false,
props: triggerProps(),
setup(props) {
const align = computed(() => {
const {
popupPlacement,
popupAlign,
builtinPlacements
} = props;
if (popupPlacement && builtinPlacements) {
return getAlignFromPlacement(builtinPlacements, popupPlacement, popupAlign);
}
return popupAlign;
});
const popupRef = shallowRef(null);
const setPopupRef = (val) => {
popupRef.value = val;
};
return {
vcTriggerContext: inject("vcTriggerContext", {}),
popupRef,
setPopupRef,
triggerRef: shallowRef(null),
align,
focusTime: null,
clickOutsideHandler: null,
contextmenuOutsideHandler1: null,
contextmenuOutsideHandler2: null,
touchOutsideHandler: null,
attachId: null,
delayTimer: null,
hasPopupMouseDown: false,
preClickTime: null,
preTouchTime: null,
mouseDownTimeout: null,
childOriginEvents: {}
};
},
data() {
const props = this.$props;
let popupVisible;
if (this.popupVisible !== void 0) {
popupVisible = !!props.popupVisible;
} else {
popupVisible = !!props.defaultPopupVisible;
}
ALL_HANDLERS.forEach((h) => {
this[`fire${h}`] = (e) => {
this.fireEvents(h, e);
};
});
return {
prevPopupVisible: popupVisible,
sPopupVisible: popupVisible,
point: null
};
},
watch: {
popupVisible(val) {
if (val !== void 0) {
this.prevPopupVisible = this.sPopupVisible;
this.sPopupVisible = val;
}
}
},
created() {
provide("vcTriggerContext", {
onPopupMouseDown: this.onPopupMouseDown,
onPopupMouseenter: this.onPopupMouseenter,
onPopupMouseleave: this.onPopupMouseleave
});
useProvidePortal(this);
},
deactivated() {
this.setPopupVisible(false);
},
mounted() {
this.$nextTick(() => {
this.updatedCal();
});
},
updated() {
this.$nextTick(() => {
this.updatedCal();
});
},
beforeUnmount() {
this.clearDelayTimer();
this.clearOutsideHandler();
clearTimeout(this.mouseDownTimeout);
wrapperRaf.cancel(this.attachId);
},
methods: {
updatedCal() {
const props = this.$props;
const state = this.$data;
if (state.sPopupVisible) {
let currentDocument;
if (!this.clickOutsideHandler && (this.isClickToHide() || this.isContextmenuToShow())) {
currentDocument = props.getDocument(this.getRootDomNode());
this.clickOutsideHandler = addEventListenerWrap(currentDocument, "mousedown", this.onDocumentClick);
}
if (!this.touchOutsideHandler) {
currentDocument = currentDocument || props.getDocument(this.getRootDomNode());
this.touchOutsideHandler = addEventListenerWrap(currentDocument, "touchstart", this.onDocumentClick, supportsPassive ? {
passive: false
} : false);
}
if (!this.contextmenuOutsideHandler1 && this.isContextmenuToShow()) {
currentDocument = currentDocument || props.getDocument(this.getRootDomNode());
this.contextmenuOutsideHandler1 = addEventListenerWrap(currentDocument, "scroll", this.onContextmenuClose);
}
if (!this.contextmenuOutsideHandler2 && this.isContextmenuToShow()) {
this.contextmenuOutsideHandler2 = addEventListenerWrap(void 0, "blur", this.onContextmenuClose);
}
} else {
this.clearOutsideHandler();
}
},
onMouseenter(e) {
const {
mouseEnterDelay
} = this.$props;
this.fireEvents("onMouseenter", e);
this.delaySetPopupVisible(true, mouseEnterDelay, mouseEnterDelay ? null : e);
},
onMouseMove(e) {
this.fireEvents("onMousemove", e);
this.setPoint(e);
},
onMouseleave(e) {
this.fireEvents("onMouseleave", e);
this.delaySetPopupVisible(false, this.$props.mouseLeaveDelay);
},
onPopupMouseenter() {
const {
vcTriggerContext = {}
} = this;
if (vcTriggerContext.onPopupMouseenter) {
vcTriggerContext.onPopupMouseenter();
}
this.clearDelayTimer();
},
onPopupMouseleave(e) {
var _a;
if (e && e.relatedTarget && !e.relatedTarget.setTimeout && contains((_a = this.popupRef) === null || _a === void 0 ? void 0 : _a.getElement(), e.relatedTarget)) {
return;
}
if (this.isMouseLeaveToHide()) {
this.delaySetPopupVisible(false, this.$props.mouseLeaveDelay);
}
const {
vcTriggerContext = {}
} = this;
if (vcTriggerContext.onPopupMouseleave) {
vcTriggerContext.onPopupMouseleave(e);
}
},
onFocus(e) {
this.fireEvents("onFocus", e);
this.clearDelayTimer();
if (this.isFocusToShow()) {
this.focusTime = Date.now();
this.delaySetPopupVisible(true, this.$props.focusDelay);
}
},
onMousedown(e) {
this.fireEvents("onMousedown", e);
this.preClickTime = Date.now();
},
onTouchstart(e) {
this.fireEvents("onTouchstart", e);
this.preTouchTime = Date.now();
},
onBlur(e) {
if (!contains(e.target, e.relatedTarget || (void 0).activeElement)) {
this.fireEvents("onBlur", e);
this.clearDelayTimer();
if (this.isBlurToHide()) {
this.delaySetPopupVisible(false, this.$props.blurDelay);
}
}
},
onContextmenu(e) {
e.preventDefault();
this.fireEvents("onContextmenu", e);
this.setPopupVisible(true, e);
},
onContextmenuClose() {
if (this.isContextmenuToShow()) {
this.close();
}
},
onClick(event) {
this.fireEvents("onClick", event);
if (this.focusTime) {
let preTime;
if (this.preClickTime && this.preTouchTime) {
preTime = Math.min(this.preClickTime, this.preTouchTime);
} else if (this.preClickTime) {
preTime = this.preClickTime;
} else if (this.preTouchTime) {
preTime = this.preTouchTime;
}
if (Math.abs(preTime - this.focusTime) < 20) {
return;
}
this.focusTime = 0;
}
this.preClickTime = 0;
this.preTouchTime = 0;
if (this.isClickToShow() && (this.isClickToHide() || this.isBlurToHide()) && event && event.preventDefault) {
event.preventDefault();
}
if (event && event.domEvent) {
event.domEvent.preventDefault();
}
const nextVisible = !this.$data.sPopupVisible;
if (this.isClickToHide() && !nextVisible || nextVisible && this.isClickToShow()) {
this.setPopupVisible(!this.$data.sPopupVisible, event);
}
},
onPopupMouseDown() {
const {
vcTriggerContext = {}
} = this;
this.hasPopupMouseDown = true;
clearTimeout(this.mouseDownTimeout);
this.mouseDownTimeout = setTimeout(() => {
this.hasPopupMouseDown = false;
}, 0);
if (vcTriggerContext.onPopupMouseDown) {
vcTriggerContext.onPopupMouseDown(...arguments);
}
},
onDocumentClick(event) {
if (this.$props.mask && !this.$props.maskClosable) {
return;
}
const target = event.target;
const root = this.getRootDomNode();
const popupNode = this.getPopupDomNode();
if (
// mousedown on the target should also close popup when action is contextMenu.
// https://github.com/ant-design/ant-design/issues/29853
(!contains(root, target) || this.isContextMenuOnly()) && !contains(popupNode, target) && !this.hasPopupMouseDown
) {
this.delaySetPopupVisible(false, 0.1);
}
},
getPopupDomNode() {
var _a;
return ((_a = this.popupRef) === null || _a === void 0 ? void 0 : _a.getElement()) || null;
},
getRootDomNode() {
var _a, _b, _c, _d;
const {
getTriggerDOMNode
} = this.$props;
if (getTriggerDOMNode) {
const domNode = ((_b = (_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.$el) === null || _b === void 0 ? void 0 : _b.nodeName) === "#comment" ? null : findDOMNode(this.triggerRef);
return findDOMNode(getTriggerDOMNode(domNode));
}
try {
const domNode = ((_d = (_c = this.triggerRef) === null || _c === void 0 ? void 0 : _c.$el) === null || _d === void 0 ? void 0 : _d.nodeName) === "#comment" ? null : findDOMNode(this.triggerRef);
if (domNode) {
return domNode;
}
} catch (err) {
}
return findDOMNode(this);
},
handleGetPopupClassFromAlign(align) {
const className = [];
const props = this.$props;
const {
popupPlacement,
builtinPlacements,
prefixCls,
alignPoint: alignPoint2,
getPopupClassNameFromAlign
} = props;
if (popupPlacement && builtinPlacements) {
className.push(getAlignPopupClassName(builtinPlacements, prefixCls, align, alignPoint2));
}
if (getPopupClassNameFromAlign) {
className.push(getPopupClassNameFromAlign(align));
}
return className.join(" ");
},
getPopupAlign() {
const props = this.$props;
const {
popupPlacement,
popupAlign,
builtinPlacements
} = props;
if (popupPlacement && builtinPlacements) {
return getAlignFromPlacement(builtinPlacements, popupPlacement, popupAlign);
}
return popupAlign;
},
getComponent() {
const mouseProps = {};
if (this.isMouseEnterToShow()) {
mouseProps.onMouseenter = this.onPopupMouseenter;
}
if (this.isMouseLeaveToHide()) {
mouseProps.onMouseleave = this.onPopupMouseleave;
}
mouseProps.onMousedown = this.onPopupMouseDown;
mouseProps[supportsPassive ? "onTouchstartPassive" : "onTouchstart"] = this.onPopupMouseDown;
const {
handleGetPopupClassFromAlign,
getRootDomNode,
$attrs
} = this;
const {
prefixCls,
destroyPopupOnHide,
popupClassName,
popupAnimation,
popupTransitionName,
popupStyle,
mask,
maskAnimation,
maskTransitionName,
zIndex,
stretch,
alignPoint: alignPoint2,
mobile,
forceRender
} = this.$props;
const {
sPopupVisible,
point
} = this.$data;
const popupProps2 = _extends(_extends({
prefixCls,
destroyPopupOnHide,
visible: sPopupVisible,
point: alignPoint2 ? point : null,
align: this.align,
animation: popupAnimation,
getClassNameFromAlign: handleGetPopupClassFromAlign,
stretch,
getRootDomNode,
mask,
zIndex,
transitionName: popupTransitionName,
maskAnimation,
maskTransitionName,
class: popupClassName,
style: popupStyle,
onAlign: $attrs.onPopupAlign || noop$1
}, mouseProps), {
ref: this.setPopupRef,
mobile,
forceRender
});
return createVNode(Popup, popupProps2, {
default: this.$slots.popup || (() => getComponent(this, "popup"))
});
},
attachParent(popupContainer) {
wrapperRaf.cancel(this.attachId);
const {
getPopupContainer,
getDocument
} = this.$props;
const domNode = this.getRootDomNode();
let mountNode;
if (!getPopupContainer) {
mountNode = getDocument(this.getRootDomNode()).body;
} else if (domNode || getPopupContainer.length === 0) {
mountNode = getPopupContainer(domNode);
}
if (mountNode) {
mountNode.appendChild(popupContainer);
} else {
this.attachId = wrapperRaf(() => {
this.attachParent(popupContainer);
});
}
},
getContainer() {
const {
$props: props
} = this;
const {
getDocument
} = props;
const popupContainer = getDocument(this.getRootDomNode()).createElement("div");
popupContainer.style.position = "absolute";
popupContainer.style.top = "0";
popupContainer.style.left = "0";
popupContainer.style.width = "100%";
this.attachParent(popupContainer);
return popupContainer;
},
setPopupVisible(sPopupVisible, event) {
const {
alignPoint: alignPoint2,
sPopupVisible: prevPopupVisible,
onPopupVisibleChange
} = this;
this.clearDelayTimer();
if (prevPopupVisible !== sPopupVisible) {
if (!hasProp(this, "popupVisible")) {
this.setState({
sPopupVisible,
prevPopupVisible
});
}
onPopupVisibleChange && onPopupVisibleChange(sPopupVisible);
}
if (alignPoint2 && event && sPopupVisible) {
this.setPoint(event);
}
},
setPoint(point) {
const {
alignPoint: alignPoint2
} = this.$props;
if (!alignPoint2 || !point) return;
this.setState({
point: {
pageX: point.pageX,
pageY: point.pageY
}
});
},
handlePortalUpdate() {
if (this.prevPopupVisible !== this.sPopupVisible) {
this.afterPopupVisibleChange(this.sPopupVisible);
}
},
delaySetPopupVisible(visible, delayS, event) {
const delay = delayS * 1e3;
this.clearDelayTimer();
if (delay) {
const point = event ? {
pageX: event.pageX,
pageY: event.pageY
} : null;
this.delayTimer = setTimeout(() => {
this.setPopupVisible(visible, point);
this.clearDelayTimer();
}, delay);
} else {
this.setPopupVisible(visible, event);
}
},
clearDelayTimer() {
if (this.delayTimer) {
clearTimeout(this.delayTimer);
this.delayTimer = null;
}
},
clearOutsideHandler() {
if (this.clickOutsideHandler) {
this.clickOutsideHandler.remove();
this.clickOutsideHandler = null;
}
if (this.contextmenuOutsideHandler1) {
this.contextmenuOutsideHandler1.remove();
this.contextmenuOutsideHandler1 = null;
}
if (this.contextmenuOutsideHandler2) {
this.contextmenuOutsideHandler2.remove();
this.contextmenuOutsideHandler2 = null;
}
if (this.touchOutsideHandler) {
this.touchOutsideHandler.remove();
this.touchOutsideHandler = null;
}
},
createTwoChains(event) {
let fn = () => {
};
const events = getEvents(this);
if (this.childOriginEvents[event] && events[event]) {
return this[`fire${event}`];
}
fn = this.childOriginEvents[event] || events[event] || fn;
return fn;
},
isClickToShow() {
const {
action,
showAction
} = this.$props;
return action.indexOf("click") !== -1 || showAction.indexOf("click") !== -1;
},
isContextMenuOnly() {
const {
action
} = this.$props;
return action === "contextmenu" || action.length === 1 && action[0] === "contextmenu";
},
isContextmenuToShow() {
const {
action,
showAction
} = this.$props;
return action.indexOf("contextmenu") !== -1 || showAction.indexOf("contextmenu") !== -1;
},
isClickToHide() {
const {
action,
hideAction
} = this.$props;
return action.indexOf("click") !== -1 || hideAction.indexOf("click") !== -1;
},
isMouseEnterToShow() {
const {
action,
showAction
} = this.$props;
return action.indexOf("hover") !== -1 || showAction.indexOf("mouseenter") !== -1;
},
isMouseLeaveToHide() {
const {
action,
hideAction
} = this.$props;
return action.indexOf("hover") !== -1 || hideAction.indexOf("mouseleave") !== -1;
},
isFocusToShow() {
const {
action,
showAction
} = this.$props;
return action.indexOf("focus") !== -1 || showAction.indexOf("focus") !== -1;
},
isBlurToHide() {
const {
action,
hideAction
} = this.$props;
return action.indexOf("focus") !== -1 || hideAction.indexOf("blur") !== -1;
},
forcePopupAlign() {
var _a;
if (this.$data.sPopupVisible) {
(_a = this.popupRef) === null || _a === void 0 ? void 0 : _a.forceAlign();
}
},
fireEvents(type, e) {
if (this.childOriginEvents[type]) {
this.childOriginEvents[type](e);
}
const event = this.$props[type] || this.$attrs[type];
if (event) {
event(e);
}
},
close() {
this.setPopupVisible(false);
}
},
render() {
const {
$attrs
} = this;
const children = filterEmpty(getSlot(this));
const {
alignPoint: alignPoint2,
getPopupContainer
} = this.$props;
const child = children[0];
this.childOriginEvents = getEvents(child);
const newChildProps = {
key: "trigger"
};
if (this.isContextmenuToShow()) {
newChildProps.onContextmenu = this.onContextmenu;
} else {
newChildProps.onContextmenu = this.createTwoChains("onContextmenu");
}
if (this.isClickToHide() || this.isClickToShow()) {
newChildProps.onClick = this.onClick;
newChildProps.onMousedown = this.onMousedown;
newChildProps[supportsPassive ? "onTouchstartPassive" : "onTouchstart"] = this.onTouchstart;
} else {
newChildProps.onClick = this.createTwoChains("onClick");
newChildProps.onMousedown = this.createTwoChains("onMousedown");
newChildProps[supportsPassive ? "onTouchstartPassive" : "onTouchstart"] = this.createTwoChains("onTouchstart");
}
if (this.isMouseEnterToShow()) {
newChildProps.onMouseenter = this.onMouseenter;
if (alignPoint2) {
newChildProps.onMousemove = this.onMouseMove;
}
} else {
newChildProps.onMouseenter = this.createTwoChains("onMouseenter");
}
if (this.isMouseLeaveToHide()) {
newChildProps.onMouseleave = this.onMouseleave;
} else {
newChildProps.onMouseleave = this.createTwoChains("onMouseleave");
}
if (this.isFocusToShow() || this.isBlurToHide()) {
newChildProps.onFocus = this.onFocus;
newChildProps.onBlur = this.onBlur;
} else {
newChildProps.onFocus = this.createTwoChains("onFocus");
newChildProps.onBlur = (e) => {
if (e && (!e.relatedTarget || !contains(e.target, e.relatedTarget))) {
this.createTwoChains("onBlur")(e);
}
};
}
const childrenClassName = classNames(child && child.props && child.props.class, $attrs.class);
if (childrenClassName) {
newChildProps.class = childrenClassName;
}
const trigger = cloneElement(child, _extends(_extends({}, newChildProps), {
ref: "triggerRef"
}), true, true);
const portal = createVNode(Portal, {
"key": "portal",
"getContainer": getPopupContainer && (() => getPopupContainer(this.getRootDomNode())),
"didUpdate": this.handlePortalUpdate,
"visible": this.$data.sPopupVisible
}, {
default: this.getComponent
});
return createVNode(Fragment, null, [trigger, portal]);
}
});
const autoAdjustOverflow = {
adjustX: 1,
adjustY: 1
};
const targetOffset$1 = [0, 0];
const placements = {
left: {
points: ["cr", "cl"],
overflow: autoAdjustOverflow,
offset: [-4, 0],
targetOffset: targetOffset$1
},
right: {
points: ["cl", "cr"],
overflow: autoAdjustOverflow,
offset: [4, 0],
targetOffset: targetOffset$1
},
top: {
points: ["bc", "tc"],
overflow: autoAdjustOverflow,
offset: [0, -4],
targetOffset: targetOffset$1
},
bottom: {
points: ["tc", "bc"],
overflow: autoAdjustOverflow,
offset: [0, 4],
targetOffset: targetOffset$1
},
topLeft: {
points: ["bl", "tl"],
overflow: autoAdjustOverflow,
offset: [0, -4],
targetOffset: targetOffset$1
},
leftTop: {
points: ["tr", "tl"],
overflow: autoAdjustOverflow,
offset: [-4, 0],
targetOffset: targetOffset$1
},
topRight: {
points: ["br", "tr"],
overflow: autoAdjustOverflow,
offset: [0, -4],
targetOffset: targetOffset$1
},
rightTop: {
points: ["tl", "tr"],
overflow: autoAdjustOverflow,
offset: [4, 0],
targetOffset: targetOffset$1
},
bottomRight: {
points: ["tr", "br"],
overflow: autoAdjustOverflow,
offset: [0, 4],
targetOffset: targetOffset$1
},
rightBottom: {
points: ["bl", "br"],
overflow: autoAdjustOverflow,
offset: [4, 0],
targetOffset: targetOffset$1
},
bottomLeft: {
points: ["tl", "bl"],
overflow: autoAdjustOverflow,
offset: [0, 4],
targetOffset: targetOffset$1
},
leftBottom: {
points: ["br", "bl"],
overflow: autoAdjustOverflow,
offset: [-4, 0],
targetOffset: targetOffset$1
}
};
const tooltipContentProps = {
prefixCls: String,
id: String,
overlayInnerStyle: PropTypes.any
};
const Content = defineComponent({
compatConfig: {
MODE: 3
},
name: "TooltipContent",
props: tooltipContentProps,
setup(props, _ref) {
let {
slots
} = _ref;
return () => {
var _a;
return createVNode("div", {
"class": `${props.prefixCls}-inner`,
"id": props.id,
"role": "tooltip",
"style": props.overlayInnerStyle
}, [(_a = slots.overlay) === null || _a === void 0 ? void 0 : _a.call(slots)]);
};
}
});
var __rest = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
function noop() {
}
const Tooltip = defineComponent({
compatConfig: {
MODE: 3
},
name: "Tooltip",
inheritAttrs: false,
props: {
trigger: PropTypes.any.def(["hover"]),
defaultVisible: {
type: Boolean,
default: void 0
},
visible: {
type: Boolean,
default: void 0
},
placement: PropTypes.string.def("right"),
transitionName: String,
animation: PropTypes.any,
afterVisibleChange: PropTypes.func.def(() => {
}),
overlayStyle: {
type: Object,
default: void 0
},
overlayClassName: String,
prefixCls: PropTypes.string.def("rc-tooltip"),
mouseEnterDelay: PropTypes.number.def(0.1),
mouseLeaveDelay: PropTypes.number.def(0.1),
getPopupContainer: Function,
destroyTooltipOnHide: {
type: Boolean,
default: false
},
align: PropTypes.object.def(() => ({})),
arrowContent: PropTypes.any.def(null),
tipId: String,
builtinPlacements: PropTypes.object,
overlayInnerStyle: {
type: Object,
default: void 0
},
popupVisible: {
type: Boolean,
default: void 0
},
onVisibleChange: Function,
onPopupAlign: Function
},
setup(props, _ref) {
let {
slots,
attrs,
expose
} = _ref;
const triggerDOM = shallowRef();
const getPopupElement = () => {
const {
prefixCls,
tipId,
overlayInnerStyle
} = props;
return [createVNode("div", {
"class": `${prefixCls}-arrow`,
"key": "arrow"
}, [getPropsSlot(slots, props, "arrowContent")]), createVNode(Content, {
"key": "content",
"prefixCls": prefixCls,
"id": tipId,
"overlayInnerStyle": overlayInnerStyle
}, {
overlay: slots.overlay
})];
};
const getPopupDomNode = () => {
return triggerDOM.value.getPopupDomNode();
};
expose({
getPopupDomNode,
triggerDOM,
forcePopupAlign: () => {
var _a;
return (_a = triggerDOM.value) === null || _a === void 0 ? void 0 : _a.forcePopupAlign();
}
});
const destroyTooltip = shallowRef(false);
const autoDestroy = shallowRef(false);
watchEffect(() => {
const {
destroyTooltipOnHide
} = props;
if (typeof destroyTooltipOnHide === "boolean") {
destroyTooltip.value = destroyTooltipOnHide;
} else if (destroyTooltipOnHide && typeof destroyTooltipOnHide === "object") {
const {
keepParent
} = destroyTooltipOnHide;
destroyTooltip.value = keepParent === true;
autoDestroy.value = keepParent === false;
}
});
return () => {
const {
overlayClassName,
trigger,
mouseEnterDelay,
mouseLeaveDelay,
overlayStyle,
prefixCls,
afterVisibleChange,
transitionName,
animation,
placement,
align,
destroyTooltipOnHide,
defaultVisible
} = props, restProps = __rest(props, ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "afterVisibleChange", "transitionName", "animation", "placement", "align", "destroyTooltipOnHide", "defaultVisible"]);
const extraProps = _extends({}, restProps);
if (props.visible !== void 0) {
extraProps.popupVisible = props.visible;
}
const triggerProps2 = _extends(_extends(_extends({
popupClassName: overlayClassName,
prefixCls,
action: trigger,
builtinPlacements: placements,
popupPlacement: placement,
popupAlign: align,
afterPopupVisibleChange: afterVisibleChange,
popupTransitionName: transitionName,
popupAnimation: animation,
defaultPopupVisible: defaultVisible,
destroyPopupOnHide: destroyTooltip.value,
autoDestroy: autoDestroy.value,
mouseLeaveDelay,
popupStyle: overlayStyle,
mouseEnterDelay
}, extraProps), attrs), {
onPopupVisibleChange: props.onVisibleChange || noop,
onPopupAlign: props.onPopupAlign || noop,
ref: triggerDOM,
popup: getPopupElement()
});
return createVNode(Trigger, triggerProps2, {
default: slots.default
});
};
}
});
const abstractTooltipProps = (() => ({
trigger: [String, Array],
open: {
type: Boolean,
default: void 0
},
/** @deprecated Please use `open` instead. */
visible: {
type: Boolean,
default: void 0
},
placement: String,
color: String,
transitionName: String,
overlayStyle: objectType(),
overlayInnerStyle: objectType(),
overlayClassName: String,
openClassName: String,
prefixCls: String,
mouseEnterDelay: Number,
mouseLeaveDelay: Number,
getPopupContainer: Function,
arrowPointAtCenter: {
type: Boolean,
default: void 0
},
autoAdjustOverflow: {
type: [Boolean, Object],
default: void 0
},
destroyTooltipOnHide: {
type: Boolean,
default: void 0
},
align: objectType(),
builtinPlacements: objectType(),
children: Array,
/** @deprecated Please use `onOpenChange` instead. */
onVisibleChange: Function,
/** @deprecated Please use `onUpdate:open` instead. */
"onUpdate:visible": Function,
onOpenChange: Function,
"onUpdate:open": Function
}));
const autoAdjustOverflowEnabled = {
adjustX: 1,
adjustY: 1
};
const autoAdjustOverflowDisabled = {
adjustX: 0,
adjustY: 0
};
const targetOffset = [0, 0];
function getOverflowOptions(autoAdjustOverflow2) {
if (typeof autoAdjustOverflow2 === "boolean") {
return autoAdjustOverflow2 ? autoAdjustOverflowEnabled : autoAdjustOverflowDisabled;
}
return _extends(_extends({}, autoAdjustOverflowDisabled), autoAdjustOverflow2);
}
function getPlacements(config) {
const {
arrowWidth = 4,
horizontalArrowShift = 16,
verticalArrowShift = 8,
autoAdjustOverflow: autoAdjustOverflow2,
arrowPointAtCenter
} = config;
const placementMap = {
left: {
points: ["cr", "cl"],
offset: [-4, 0]
},
right: {
points: ["cl", "cr"],
offset: [4, 0]
},
top: {
points: ["bc", "tc"],
offset: [0, -4]
},
bottom: {
points: ["tc", "bc"],
offset: [0, 4]
},
topLeft: {
points: ["bl", "tc"],
offset: [-(horizontalArrowShift + arrowWidth), -4]
},
leftTop: {
points: ["tr", "cl"],
offset: [-4, -(verticalArrowShift + arrowWidth)]
},
topRight: {
points: ["br", "tc"],
offset: [horizontalArrowShift + arrowWidth, -4]
},
rightTop: {
points: ["tl", "cr"],
offset: [4, -(verticalArrowShift + arrowWidth)]
},
bottomRight: {
points: ["tr", "bc"],
offset: [horizontalArrowShift + arrowWidth, 4]
},
rightBottom: {
points: ["bl", "cr"],
offset: [4, verticalArrowShift + arrowWidth]
},
bottomLeft: {
points: ["tl", "bc"],
offset: [-(horizontalArrowShift + arrowWidth), 4]
},
leftBottom: {
points: ["br", "cl"],
offset: [-4, verticalArrowShift + arrowWidth]
}
};
Object.keys(placementMap).forEach((key) => {
placementMap[key] = arrowPointAtCenter ? _extends(_extends({}, placementMap[key]), {
overflow: getOverflowOptions(autoAdjustOverflow2),
targetOffset
}) : _extends(_extends({}, placements[key]), {
overflow: getOverflowOptions(autoAdjustOverflow2)
});
placementMap[key].ignoreShake = true;
});
return placementMap;
}
function firstNotUndefined() {
let arr = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
for (let i = 0, len = arr.length; i < len; i++) {
if (arr[i] !== void 0) {
return arr[i];
}
}
return void 0;
}
const inverseColors = PresetColors.map((color) => `${color}-inverse`);
const PresetStatusColorTypes = ["success", "processing", "error", "default", "warning"];
function isPresetColor(color) {
let includeInverse = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
if (includeInverse) {
return [...inverseColors, ...PresetColors].includes(color);
}
return PresetColors.includes(color);
}
function isPresetStatusColor(color) {
return PresetStatusColorTypes.includes(color);
}
function parseColor(prefixCls, color) {
const isInternalColor = isPresetColor(color);
const className = classNames({
[`${prefixCls}-${color}`]: color && isInternalColor
});
const overlayStyle = {};
const arrowStyle = {};
if (color && !isInternalColor) {
overlayStyle.background = color;
arrowStyle["--antd-arrow-background-color"] = color;
}
return {
className,
overlayStyle,
arrowStyle
};
}
function connectArrowCls(classList) {
let showArrowCls = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
return classList.map((cls) => `${showArrowCls}${cls}`).join(",");
}
const MAX_VERTICAL_CONTENT_RADIUS = 8;
function getArrowOffset(options) {
const maxVerticalContentRadius = MAX_VERTICAL_CONTENT_RADIUS;
const {
sizePopupArrow,
contentRadius,
borderRadiusOuter,
limitVerticalRadius
} = options;
const arrowInnerOffset = sizePopupArrow / 2 - Math.ceil(borderRadiusOuter * (Math.sqrt(2) - 1));
const dropdownArrowOffset = (contentRadius > 12 ? contentRadius + 2 : 12) - arrowInnerOffset;
const dropdownArrowOffsetVertical = limitVerticalRadius ? maxVerticalContentRadius - arrowInnerOffset : dropdownArrowOffset;
return {
dropdownArrowOffset,
dropdownArrowOffsetVertical
};
}
function getArrowStyle(token, options) {
const {
componentCls,
sizePopupArrow,
marginXXS,
borderRadiusXS,
borderRadiusOuter,
boxShadowPopoverArrow
} = token;
const {
colorBg,
showArrowCls,
contentRadius = token.borderRadiusLG,
limitVerticalRadius
} = options;
const {
dropdownArrowOffsetVertical,
dropdownArrowOffset
} = getArrowOffset({
sizePopupArrow,
contentRadius,
borderRadiusOuter,
limitVerticalRadius
});
const dropdownArrowDistance = sizePopupArrow / 2 + marginXXS;
return {
[componentCls]: {
// ============================ Basic ============================
[`${componentCls}-arrow`]: [_extends(_extends({
position: "absolute",
zIndex: 1,
display: "block"
}, roundedArrow(sizePopupArrow, borderRadiusXS, borderRadiusOuter, colorBg, boxShadowPopoverArrow)), {
"&:before": {
background: colorBg
}
})],
// ========================== Placement ==========================
// Here handle the arrow position and rotate stuff
// >>>>> Top
[[`&-placement-top ${componentCls}-arrow`, `&-placement-topLeft ${componentCls}-arrow`, `&-placement-topRight ${componentCls}-arrow`].join(",")]: {
bottom: 0,
transform: "translateY(100%) rotate(180deg)"
},
[`&-placement-top ${componentCls}-arrow`]: {
left: {
_skip_check_: true,
value: "50%"
},
transform: "translateX(-50%) translateY(100%) rotate(180deg)"
},
[`&-placement-topLeft ${componentCls}-arrow`]: {
left: {
_skip_check_: true,
value: dropdownArrowOffset
}
},
[`&-placement-topRight ${componentCls}-arrow`]: {
right: {
_skip_check_: true,
value: dropdownArrowOffset
}
},
// >>>>> Bottom
[[`&-placement-bottom ${componentCls}-arrow`, `&-placement-bottomLeft ${componentCls}-arrow`, `&-placement-bottomRight ${componentCls}-arrow`].join(",")]: {
top: 0,
transform: `translateY(-100%)`
},
[`&-placement-bottom ${componentCls}-arrow`]: {
left: {
_skip_check_: true,
value: "50%"
},
transform: `translateX(-50%) translateY(-100%)`
},
[`&-placement-bottomLeft ${componentCls}-arrow`]: {
left: {
_skip_check_: true,
value: dropdownArrowOffset
}
},
[`&-placement-bottomRight ${componentCls}-arrow`]: {
right: {
_skip_check_: true,
value: dropdownArrowOffset
}
},
// >>>>> Left
[[`&-placement-left ${componentCls}-arrow`, `&-placement-leftTop ${componentCls}-arrow`, `&-placement-leftBottom ${componentCls}-arrow`].join(",")]: {
right: {
_skip_check_: true,
value: 0
},
transform: "translateX(100%) rotate(90deg)"
},
[`&-placement-left ${componentCls}-arrow`]: {
top: {
_skip_check_: true,
value: "50%"
},
transform: "translateY(-50%) translateX(100%) rotate(90deg)"
},
[`&-placement-leftTop ${componentCls}-arrow`]: {
top: dropdownArrowOffsetVertical
},
[`&-placement-leftBottom ${componentCls}-arrow`]: {
bottom: dropdownArrowOffsetVertical
},
// >>>>> Right
[[`&-placement-right ${componentCls}-arrow`, `&-placement-rightTop ${componentCls}-arrow`, `&-placement-rightBottom ${componentCls}-arrow`].join(",")]: {
left: {
_skip_check_: true,
value: 0
},
transform: "translateX(-100%) rotate(-90deg)"
},
[`&-placement-right ${componentCls}-arrow`]: {
top: {
_skip_check_: true,
value: "50%"
},
transform: "translateY(-50%) translateX(-100%) rotate(-90deg)"
},
[`&-placement-rightTop ${componentCls}-arrow`]: {
top: dropdownArrowOffsetVertical
},
[`&-placement-rightBottom ${componentCls}-arrow`]: {
bottom: dropdownArrowOffsetVertical
},
// =========================== Offset ============================
// Offset the popover to account for the dropdown arrow
// >>>>> Top
[connectArrowCls([`&-placement-topLeft`, `&-placement-top`, `&-placement-topRight`], showArrowCls)]: {
paddingBottom: dropdownArrowDistance
},
// >>>>> Bottom
[connectArrowCls([`&-placement-bottomLeft`, `&-placement-bottom`, `&-placement-bottomRight`], showArrowCls)]: {
paddingTop: dropdownArrowDistance
},
// >>>>> Left
[connectArrowCls([`&-placement-leftTop`, `&-placement-left`, `&-placement-leftBottom`], showArrowCls)]: {
paddingRight: {
_skip_check_: true,
value: dropdownArrowDistance
}
},
// >>>>> Right
[connectArrowCls([`&-placement-rightTop`, `&-placement-right`, `&-placement-rightBottom`], showArrowCls)]: {
paddingLeft: {
_skip_check_: true,
value: dropdownArrowDistance
}
}
}
};
}
const genTooltipStyle = (token) => {
const {
componentCls,
// ant-tooltip
tooltipMaxWidth,
tooltipColor,
tooltipBg,
tooltipBorderRadius,
zIndexPopup,
controlHeight,
boxShadowSecondary,
paddingSM,
paddingXS,
tooltipRadiusOuter
} = token;
return [
{
[componentCls]: _extends(_extends(_extends(_extends({}, resetComponent(token)), {
position: "absolute",
zIndex: zIndexPopup,
display: "block",
"&": [{
width: "max-content"
}, {
width: "intrinsic"
}],
maxWidth: tooltipMaxWidth,
visibility: "visible",
"&-hidden": {
display: "none"
},
"--antd-arrow-background-color": tooltipBg,
// Wrapper for the tooltip content
[`${componentCls}-inner`]: {
minWidth: controlHeight,
minHeight: controlHeight,
padding: `${paddingSM / 2}px ${paddingXS}px`,
color: tooltipColor,
textAlign: "start",
textDecoration: "none",
wordWrap: "break-word",
backgroundColor: tooltipBg,
borderRadius: tooltipBorderRadius,
boxShadow: boxShadowSecondary
},
// Limit left and right placement radius
[[`&-placement-left`, `&-placement-leftTop`, `&-placement-leftBottom`, `&-placement-right`, `&-placement-rightTop`, `&-placement-rightBottom`].join(",")]: {
[`${componentCls}-inner`]: {
borderRadius: Math.min(tooltipBorderRadius, MAX_VERTICAL_CONTENT_RADIUS)
}
},
[`${componentCls}-content`]: {
position: "relative"
}
}), genPresetColor(token, (colorKey, _ref) => {
let {
darkColor
} = _ref;
return {
[`&${componentCls}-${colorKey}`]: {
[`${componentCls}-inner`]: {
backgroundColor: darkColor
},
[`${componentCls}-arrow`]: {
"--antd-arrow-background-color": darkColor
}
}
};
})), {
// RTL
"&-rtl": {
direction: "rtl"
}
})
},
// Arrow Style
getArrowStyle(merge(token, {
borderRadiusOuter: tooltipRadiusOuter
}), {
colorBg: "var(--antd-arrow-background-color)",
showArrowCls: "",
contentRadius: tooltipBorderRadius,
limitVerticalRadius: true
}),
// Pure Render
{
[`${componentCls}-pure`]: {
position: "relative",
maxWidth: "none"
}
}
];
};
const useStyle = ((prefixCls, injectStyle) => {
const useOriginHook = genComponentStyleHook("Tooltip", (token) => {
if ((injectStyle === null || injectStyle === void 0 ? void 0 : injectStyle.value) === false) {
return [];
}
const {
borderRadius,
colorTextLightSolid,
colorBgDefault,
borderRadiusOuter
} = token;
const TooltipToken = merge(token, {
// default variables
tooltipMaxWidth: 250,
tooltipColor: colorTextLightSolid,
tooltipBorderRadius: borderRadius,
tooltipBg: colorBgDefault,
tooltipRadiusOuter: borderRadiusOuter > 4 ? 4 : borderRadiusOuter
});
return [genTooltipStyle(TooltipToken), initZoomMotion(token, "zoom-big-fast")];
}, (_ref2) => {
let {
zIndexPopupBase,
colorBgSpotlight
} = _ref2;
return {
zIndexPopup: zIndexPopupBase + 70,
colorBgDefault: colorBgSpotlight
};
});
return useOriginHook(prefixCls);
});
const splitObject = (obj, keys) => {
const picked = {};
const omitted = _extends({}, obj);
keys.forEach((key) => {
if (obj && key in obj) {
picked[key] = obj[key];
delete omitted[key];
}
});
return {
picked,
omitted
};
};
const tooltipProps = () => _extends(_extends({}, abstractTooltipProps()), {
title: PropTypes.any
});
const tooltipDefaultProps = () => ({
trigger: "hover",
align: {},
placement: "top",
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
arrowPointAtCenter: false,
autoAdjustOverflow: true
});
const ToolTip = defineComponent({
compatConfig: {
MODE: 3
},
name: "ATooltip",
inheritAttrs: false,
props: initDefaultProps(tooltipProps(), {
trigger: "hover",
align: {},
placement: "top",
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
arrowPointAtCenter: false,
autoAdjustOverflow: true
}),
slots: Object,
// emits: ['update:visible', 'visibleChange'],
setup(props, _ref) {
let {
slots,
emit,
attrs,
expose
} = _ref;
const {
prefixCls,
getPopupContainer,
direction,
rootPrefixCls
} = useConfigInject("tooltip", props);
const mergedOpen = computed(() => {
var _a;
return (_a = props.open) !== null && _a !== void 0 ? _a : props.visible;
});
const innerOpen = ref(firstNotUndefined([props.open, props.visible]));
const tooltip = ref();
let rafId;
watch(mergedOpen, (val) => {
wrapperRaf.cancel(rafId);
rafId = wrapperRaf(() => {
innerOpen.value = !!val;
});
});
const isNoTitle = () => {
var _a;
const title = (_a = props.title) !== null && _a !== void 0 ? _a : slots.title;
return !title && title !== 0;
};
const handleVisibleChange = (val) => {
const noTitle = isNoTitle();
if (mergedOpen.value === void 0) {
innerOpen.value = noTitle ? false : val;
}
if (!noTitle) {
emit("update:visible", val);
emit("visibleChange", val);
emit("update:open", val);
emit("openChange", val);
}
};
const getPopupDomNode = () => {
return tooltip.value.getPopupDomNode();
};
expose({
getPopupDomNode,
open: innerOpen,
forcePopupAlign: () => {
var _a;
return (_a = tooltip.value) === null || _a === void 0 ? void 0 : _a.forcePopupAlign();
}
});
const tooltipPlacements = computed(() => {
const {
builtinPlacements,
arrowPointAtCenter,
autoAdjustOverflow: autoAdjustOverflow2
} = props;
return builtinPlacements || getPlacements({
arrowPointAtCenter,
autoAdjustOverflow: autoAdjustOverflow2
});
});
const isTrueProps = (val) => {
return val || val === "";
};
const getDisabledCompatibleChildren = (ele) => {
const elementType = ele.type;
if (typeof elementType === "object" && ele.props) {
if ((elementType.__ANT_BUTTON === true || elementType === "button") && isTrueProps(ele.props.disabled) || elementType.__ANT_SWITCH === true && (isTrueProps(ele.props.disabled) || isTrueProps(ele.props.loading)) || elementType.__ANT_RADIO === true && isTrueProps(ele.props.disabled)) {
const {
picked,
omitted
} = splitObject(getStyle$1(ele), ["position", "left", "right", "top", "bottom", "float", "display", "zIndex"]);
const spanStyle = _extends(_extends({
display: "inline-block"
}, picked), {
cursor: "not-allowed",
lineHeight: 1,
width: ele.props && ele.props.block ? "100%" : void 0
});
const buttonStyle = _extends(_extends({}, omitted), {
pointerEvents: "none"
});
const child = cloneElement(ele, {
style: buttonStyle
}, true);
return createVNode("span", {
"style": spanStyle,
"class": `${prefixCls.value}-disabled-compatible-wrapper`
}, [child]);
}
}
return ele;
};
const getOverlay = () => {
var _a, _b;
return (_a = props.title) !== null && _a !== void 0 ? _a : (_b = slots.title) === null || _b === void 0 ? void 0 : _b.call(slots);
};
const onPopupAlign = (domNode, align) => {
const placements2 = tooltipPlacements.value;
const placement = Object.keys(placements2).find((key) => {
var _a, _b;
return placements2[key].points[0] === ((_a = align.points) === null || _a === void 0 ? void 0 : _a[0]) && placements2[key].points[1] === ((_b = align.points) === null || _b === void 0 ? void 0 : _b[1]);
});
if (placement) {
const rect = domNode.getBoundingClientRect();
const transformOrigin = {
top: "50%",
left: "50%"
};
if (placement.indexOf("top") >= 0 || placement.indexOf("Bottom") >= 0) {
transformOrigin.top = `${rect.height - align.offset[1]}px`;
} else if (placement.indexOf("Top") >= 0 || placement.indexOf("bottom") >= 0) {
transformOrigin.top = `${-align.offset[1]}px`;
}
if (placement.indexOf("left") >= 0 || placement.indexOf("Right") >= 0) {
transformOrigin.left = `${rect.width - align.offset[0]}px`;
} else if (placement.indexOf("right") >= 0 || placement.indexOf("Left") >= 0) {
transformOrigin.left = `${-align.offset[0]}px`;
}
domNode.style.transformOrigin = `${transformOrigin.left} ${transformOrigin.top}`;
}
};
const colorInfo = computed(() => parseColor(prefixCls.value, props.color));
const injectFromPopover = computed(() => attrs["data-popover-inject"]);
const [wrapSSR, hashId] = useStyle(prefixCls, computed(() => !injectFromPopover.value));
return () => {
var _a, _b;
const {
openClassName,
overlayClassName,
overlayStyle,
overlayInnerStyle
} = props;
let children = (_b = filterEmpty((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots))) !== null && _b !== void 0 ? _b : null;
children = children.length === 1 ? children[0] : children;
let tempVisible = innerOpen.value;
if (mergedOpen.value === void 0 && isNoTitle()) {
tempVisible = false;
}
if (!children) {
return null;
}
const child = getDisabledCompatibleChildren(isValidElement(children) && !isFragment(children) ? children : createVNode("span", null, [children]));
const childCls = classNames({
[openClassName || `${prefixCls.value}-open`]: true,
[child.props && child.props.class]: child.props && child.props.class
});
const customOverlayClassName = classNames(overlayClassName, {
[`${prefixCls.value}-rtl`]: direction.value === "rtl"
}, colorInfo.value.className, hashId.value);
const formattedOverlayInnerStyle = _extends(_extends({}, colorInfo.value.overlayStyle), overlayInnerStyle);
const arrowContentStyle = colorInfo.value.arrowStyle;
const vcTooltipProps = _extends(_extends(_extends({}, attrs), props), {
prefixCls: prefixCls.value,
getPopupContainer: getPopupContainer === null || getPopupContainer === void 0 ? void 0 : getPopupContainer.value,
builtinPlacements: tooltipPlacements.value,
visible: tempVisible,
ref: tooltip,
overlayClassName: customOverlayClassName,
overlayStyle: _extends(_extends({}, arrowContentStyle), overlayStyle),
overlayInnerStyle: formattedOverlayInnerStyle,
onVisibleChange: handleVisibleChange,
onPopupAlign,
transitionName: getTransitionName(rootPrefixCls.value, "zoom-big-fast", props.transitionName)
});
return wrapSSR(createVNode(Tooltip, vcTooltipProps, {
default: () => [innerOpen.value ? cloneElement(child, {
class: childCls
}) : child],
arrowContent: () => createVNode("span", {
"class": `${prefixCls.value}-arrow-content`
}, null),
overlay: getOverlay
}));
};
}
});
const __nuxt_component_2 = withInstall(ToolTip);
export { BaseMixin as B, PresetColors as P, Trigger as T, __nuxt_component_2 as _, isPresetStatusColor as a, abstractTooltipProps as b, getArrowStyle as c, addEventListenerWrap as d, tooltipProps as e, firstNotUndefined as f, genPresetColor as g, isVisible as h, isPresetColor as i, roundedArrow as r, supportsPassive as s, tooltipDefaultProps as t, wrapperRaf as w };