tdesign-mobile-vue
Version:
tdesign-mobile-vue
172 lines (166 loc) • 5.64 kB
JavaScript
/**
* tdesign v1.13.2
* (c) 2026 TDesign Group
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var Vue = require('vue');
var isString = require('../_chunks/dep-db763263.js');
var shared_render = require('../shared/render.js');
var isFunction = require('../_chunks/dep-abe9931d.js');
require('../_chunks/dep-d16bf091.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-c6554877.js');
require('../_chunks/dep-a8725fec.js');
require('../_chunks/dep-88660f08.js');
require('../_chunks/dep-bcc78903.js');
require('../_chunks/dep-e1cc657b.js');
require('../_chunks/dep-a58ecafb.js');
require('../_chunks/dep-04cf2308.js');
require('../_chunks/dep-ea3a180f.js');
require('../_chunks/dep-c041cd95.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