tdesign-mobile-vue
Version:
tdesign-mobile-vue
172 lines (166 loc) • 5.64 kB
JavaScript
/**
* tdesign v1.8.3
* (c) 2025 TDesign Group
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var isString = require('../_chunks/dep-be12e3cf.js');
var shared_render = require('../shared/render.js');
var isFunction = require('../_chunks/dep-502b30ed.js');
require('../_chunks/dep-dcb71613.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-0c65c975.js');
require('../_chunks/dep-489cc4a7.js');
require('../_chunks/dep-73971288.js');
require('../_chunks/dep-3063ebb4.js');
require('../_chunks/dep-fe4c83ed.js');
require('../_chunks/dep-2a740630.js');
require('../_chunks/dep-efffe4f1.js');
require('../_chunks/dep-12a11698.js');
require('../_chunks/dep-2785f324.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