tdesign-mobile-vue
Version:
tdesign-mobile-vue
172 lines (166 loc) • 5.64 kB
JavaScript
/**
* tdesign v1.9.3
* (c) 2025 TDesign Group
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var isString = require('../_chunks/dep-c3cb976c.js');
var shared_render = require('../shared/render.js');
var isFunction = require('../_chunks/dep-88fe047a.js');
require('../_chunks/dep-2f809ed9.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-757b152c.js');
require('../_chunks/dep-5be9198d.js');
require('../_chunks/dep-a7319409.js');
require('../_chunks/dep-afa9f3f2.js');
require('../_chunks/dep-ae809b86.js');
require('../_chunks/dep-2b08c0a6.js');
require('../_chunks/dep-288156c7.js');
require('../_chunks/dep-3d4c38f1.js');
require('../_chunks/dep-ef223206.js');
function useSureConfirm(instance, initData) {
var sureRightRef = vue.ref();
var sureLeftRef = vue.ref();
var showSureRight = vue.ref(false);
var showSureLeft = vue.ref(false);
var sureMarginRight = vue.ref(0);
var sureMarginLeft = vue.ref(0);
var closedSure = vue.ref(false);
var sureRightContent = vue.ref();
var sureLeftContent = vue.ref();
var handleSureClick = vue.ref();
var sureRightBgStyle = vue.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 = vue.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 = vue.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 = vue.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;
});
vue.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;
}
}
});
vue.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.isString(sure) && instance !== null && instance !== void 0 && instance.slots[sure]) {
sureContent.value = shared_render.renderTNode(instance, sure);
} else if (isFunction.isFunction(sure)) {
vue.setBlockTracking(-1);
sureContent.value = sure(vue.h);
vue.setBlockTracking(1);
} else {
sureContent.value = sure;
}
vue.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
};
}
exports.useSureConfirm = useSureConfirm;
//# sourceMappingURL=useSureConfirm.js.map