UNPKG

tdesign-mobile-vue

Version:
168 lines (160 loc) 5.54 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var isFunction = require('lodash/isFunction'); var isString = require('lodash/isString'); var shared_render = require('../shared/render.js'); require('@babel/runtime/helpers/typeof'); require('lodash/camelCase'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction); var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString); 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__default["default"](sure) && instance !== null && instance !== void 0 && instance.slots[sure]) { sureContent.value = shared_render.renderTNode(instance, sure); } else if (isFunction__default["default"](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