tdesign-mobile-vue
Version:
tdesign-mobile-vue
200 lines (196 loc) • 6.66 kB
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
import { ref, computed, watch, setBlockTracking, h, nextTick } from 'vue';
import { i as isFunction_1 } from '../_chunks/dep-91d696ea.mjs';
import { i as isString_1 } from '../_chunks/dep-6303c50c.mjs';
import '../shared/index.mjs';
import { renderTNode } from '../shared/render.mjs';
import '../_chunks/dep-8bf3054e.mjs';
import '../_chunks/dep-3d249f65.mjs';
import '../_chunks/dep-620d73f7.mjs';
import '../_chunks/dep-e6c129ab.mjs';
import '../_chunks/dep-019e292f.mjs';
import '../_chunks/dep-32364550.mjs';
import '../_chunks/dep-9b2de386.mjs';
import '../shared/functions.mjs';
import '../shared/util.mjs';
import '../_chunks/dep-cd74809c.mjs';
import '../_chunks/dep-8d37dbf8.mjs';
import '../_chunks/dep-52fdc8e1.mjs';
import '../config.mjs';
import '../shared/component.mjs';
import '../shared/constants.mjs';
import '../shared/dom.mjs';
import '../shared/render-tnode.mjs';
import '../shared/useToggle/index.mjs';
import '../shared/useCountDown/index.mjs';
import '../_chunks/dep-80e4de18.mjs';
import '@vueuse/core';
import '../shared/useCountDown/utils.mjs';
import '../shared/useDefault/index.mjs';
import '../_chunks/dep-60cadef8.mjs';
import '../_chunks/dep-8140c29b.mjs';
import '../_chunks/dep-0d52e58f.mjs';
import '../_chunks/dep-a836a38c.mjs';
import '../_chunks/dep-0ea7bbde.mjs';
import '../_chunks/dep-b437ef0b.mjs';
import '../shared/useChildSlots/index.mjs';
import '../_chunks/dep-f0f403be.mjs';
import '../shared/useVModel/index.mjs';
import '../_chunks/dep-6917b9bc.mjs';
import '../shared/useTouch/index.mjs';
import '../shared/useScrollParent/index.mjs';
import '../shared/useExpose/index.mjs';
import '../shared/useTest/index.mjs';
import '../_chunks/dep-219bb5a7.mjs';
import '../shared/useClickAway/index.mjs';
import '../shared/useGesture/index.mjs';
import '@use-gesture/vanilla';
import '../shared/hover.mjs';
function useSureConfirm(instance, initData) {
var sureRightRef = ref();
var sureLeftRef = ref();
var showSureRight = ref(false);
var showSureLeft = ref(false);
var sureMarginRight = ref(0);
var sureMarginLeft = ref(0);
var closedSure = ref(false);
var sureRightContent = ref();
var sureLeftContent = ref();
var handleSureClick = ref();
var sureRightBgStyle = computed(function () {
var style = {
display: "inline-block",
position: "absolute",
width: "100%",
height: "100%",
backgroundColor: "rgba(0,0,0,0)",
transition: closedSure.value ? "none" : "background-color .6s cubic-bezier(0.18, 0.89, 0.32, 1)",
transform: "translate3d(".concat(initData.rightWidth, "px, 0, 0)"),
pointerEvents: "none"
};
if (showSureRight.value) {
style.backgroundColor = "rgba(0,0,0,.5)";
} else {
style.backgroundColor = "rgba(0,0,0,0)";
}
return style;
});
var sureLeftBgStyle = computed(function () {
var style = {
display: "inline-block",
position: "absolute",
width: "100%",
height: "100%",
backgroundColor: "rgba(0,0,0,0)",
transition: closedSure.value ? "none" : "background-color .6s cubic-bezier(0.18, 0.89, 0.32, 1)",
transform: "translate3d(0, 0, 0)",
pointerEvents: "none"
};
if (showSureLeft.value) {
style.backgroundColor = "rgba(0,0,0,.5)";
} else {
style.backgroundColor = "rgba(0,0,0,0)";
}
return style;
});
var sureRightStyle = computed(function () {
var style = {
display: "inline-block",
position: "absolute",
height: "100%",
top: 0,
minWidth: "100%",
transition: closedSure.value ? "none" : "transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)",
transform: "translate3d(0, 0, 0)"
};
if (showSureRight.value) {
style.transform = "translate3d(0, 0, 0)";
} else {
style.transform = "translate3d(".concat(initData.rightWidth, "px, 0, 0)");
}
return style;
});
var sureLeftStyle = computed(function () {
var style = {
display: "inline-block",
position: "absolute",
height: "100%",
top: 0,
minWidth: "100%",
transition: closedSure.value ? "none" : "transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)",
transform: "translate3d(0, 0, 0)"
};
if (showSureLeft.value) {
style.transform = "translate3d(0, 0, 0)";
} else {
style.transform = "translate3d(".concat(-initData.leftWidth, "px, 0, 0)");
}
return style;
});
watch(showSureRight, function () {
if (initData.pos < 0) {
if (showSureRight.value) {
var _sureRightRef$value;
var sureRightWidth = (_sureRightRef$value = sureRightRef.value) === null || _sureRightRef$value === void 0 ? void 0 : _sureRightRef$value.clientWidth;
sureMarginRight.value = Math.max(initData.rightWidth, sureRightWidth) - initData.rightWidth;
} else {
sureMarginRight.value = 0;
}
}
});
watch(showSureLeft, function () {
if (initData.pos > 0) {
if (showSureLeft.value) {
var _sureLeftRef$value;
var sureLeftWidth = (_sureLeftRef$value = sureLeftRef.value) === null || _sureLeftRef$value === void 0 ? void 0 : _sureLeftRef$value.clientWidth;
sureMarginLeft.value = Math.max(initData.leftWidth, sureLeftWidth) - initData.leftWidth;
} else {
sureMarginLeft.value = 0;
}
}
});
var showSure = function showSure(sure, onClick) {
handleSureClick.value = onClick;
var sureContent = sureRightContent;
var sureVisible = showSureRight;
if (initData.pos > 0) {
sureContent = sureLeftContent;
sureVisible = showSureLeft;
}
if (isString_1(sure) && instance !== null && instance !== void 0 && instance.slots[sure]) {
sureContent.value = renderTNode(instance, sure);
} else if (isFunction_1(sure)) {
setBlockTracking(-1);
sureContent.value = sure(h);
setBlockTracking(1);
} else {
sureContent.value = sure;
}
nextTick(function () {
sureVisible.value = true;
});
};
return {
sureRightRef: sureRightRef,
sureLeftRef: sureLeftRef,
showSureRight: showSureRight,
showSureLeft: showSureLeft,
sureMarginRight: sureMarginRight,
sureMarginLeft: sureMarginLeft,
closedSure: closedSure,
sureRightContent: sureRightContent,
sureLeftContent: sureLeftContent,
sureLeftBgStyle: sureLeftBgStyle,
sureRightBgStyle: sureRightBgStyle,
sureRightStyle: sureRightStyle,
sureLeftStyle: sureLeftStyle,
showSure: showSure,
handleSureClick: handleSureClick
};
}
export { useSureConfirm };
//# sourceMappingURL=useSureConfirm.mjs.map