first commit

This commit is contained in:
PC-202306242200\Administrator
2026-03-28 23:10:55 +08:00
commit 1c24452b6c
1735 changed files with 150474 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
"use strict";
const uni_modules_wotDesignUni_components_common_props = require("../common/props.js");
const transitionProps = {
...uni_modules_wotDesignUni_components_common_props.baseProps,
/**
* 是否展示组件
* 类型boolean
* 默认值false
*/
show: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
/**
* 动画执行时间
* 类型number | boolean | Record<string, number>
* 默认值300 (毫秒)
*/
duration: {
type: [Object, Number, Boolean],
default: 300
},
/**
* 弹层内容懒渲染,触发展示时才渲染内容
* 类型boolean
* 默认值false
*/
lazyRender: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
/**
* 动画类型
* 类型string
* 可选值fade / fade-up / fade-down / fade-left / fade-right / slide-up / slide-down / slide-left / slide-right / zoom-in
* 默认值:'fade'
*/
name: [String, Array],
/**
* 是否在动画结束时销毁子节点display: none)
* 类型boolean
* 默认值false
*/
destroy: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(true),
/**
* 进入过渡的开始状态
* 类型string
*/
enterClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
/**
* 进入过渡的激活状态
* 类型string
*/
enterActiveClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
/**
* 进入过渡的结束状态
* 类型string
*/
enterToClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
/**
* 离开过渡的开始状态
* 类型string
*/
leaveClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
/**
* 离开过渡的激活状态
* 类型string
*/
leaveActiveClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
/**
* 离开过渡的结束状态
* 类型string
*/
leaveToClass: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
/**
* 是否阻止触摸滚动
* 类型boolean
* 默认值false
*/
disableTouchMove: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false)
};
exports.transitionProps = transitionProps;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/wd-transition/types.js.map

View File

@@ -0,0 +1,196 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
const uni_modules_wotDesignUni_components_wdTransition_types = require("./types.js");
const uni_modules_wotDesignUni_components_common_AbortablePromise = require("../common/AbortablePromise.js");
const __default__ = {
name: "wd-transition",
options: {
addGlobalClass: true,
virtualHost: true,
styleIsolation: "shared"
}
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
...__default__,
props: uni_modules_wotDesignUni_components_wdTransition_types.transitionProps,
emits: ["click", "before-enter", "enter", "before-leave", "leave", "after-leave", "after-enter"],
setup(__props, { emit: __emit }) {
const getClassNames = (name) => {
let enter2 = `${props.enterClass} ${props.enterActiveClass}`;
let enterTo = `${props.enterToClass} ${props.enterActiveClass}`;
let leave2 = `${props.leaveClass} ${props.leaveActiveClass}`;
let leaveTo = `${props.leaveToClass} ${props.leaveActiveClass}`;
if (Array.isArray(name)) {
for (let index = 0; index < name.length; index++) {
enter2 = `wd-${name[index]}-enter wd-${name[index]}-enter-active ${enter2}`;
enterTo = `wd-${name[index]}-enter-to wd-${name[index]}-enter-active ${enterTo}`;
leave2 = `wd-${name[index]}-leave wd-${name[index]}-leave-active ${leave2}`;
leaveTo = `wd-${name[index]}-leave-to wd-${name[index]}-leave-active ${leaveTo}`;
}
} else if (name) {
enter2 = `wd-${name}-enter wd-${name}-enter-active ${enter2}`;
enterTo = `wd-${name}-enter-to wd-${name}-enter-active ${enterTo}`;
leave2 = `wd-${name}-leave wd-${name}-leave-active ${leave2}`;
leaveTo = `wd-${name}-leave-to wd-${name}-leave-active ${leaveTo}`;
}
return {
enter: enter2,
"enter-to": enterTo,
leave: leave2,
"leave-to": leaveTo
};
};
const props = __props;
const emit = __emit;
const inited = common_vendor.ref(false);
const display = common_vendor.ref(false);
const status = common_vendor.ref("");
const transitionEnded = common_vendor.ref(false);
const currentDuration = common_vendor.ref(300);
const classes = common_vendor.ref("");
const enterPromise = common_vendor.ref(null);
const enterLifeCyclePromises = common_vendor.ref(null);
const leaveLifeCyclePromises = common_vendor.ref(null);
const style = common_vendor.computed(() => {
return `-webkit-transition-duration:${currentDuration.value}ms;transition-duration:${currentDuration.value}ms;${display.value || !props.destroy ? "" : "display: none;"}${props.customStyle}`;
});
const rootClass = common_vendor.computed(() => {
return `wd-transition ${props.customClass} ${classes.value}`;
});
const isShow = common_vendor.computed(() => {
return !props.lazyRender || inited.value;
});
common_vendor.onBeforeMount(() => {
if (props.show) {
enter();
}
});
common_vendor.watch(
() => props.show,
(newVal) => {
handleShow(newVal);
},
{ deep: true }
);
function handleClick() {
emit("click");
}
function handleShow(value) {
if (value) {
handleAbortPromise();
enter();
} else {
leave();
}
}
function handleAbortPromise() {
uni_modules_wotDesignUni_components_common_util.isPromise(enterPromise.value) && enterPromise.value.abort();
uni_modules_wotDesignUni_components_common_util.isPromise(enterLifeCyclePromises.value) && enterLifeCyclePromises.value.abort();
uni_modules_wotDesignUni_components_common_util.isPromise(leaveLifeCyclePromises.value) && leaveLifeCyclePromises.value.abort();
enterPromise.value = null;
enterLifeCyclePromises.value = null;
leaveLifeCyclePromises.value = null;
}
function enter() {
enterPromise.value = new uni_modules_wotDesignUni_components_common_AbortablePromise.AbortablePromise(async (resolve) => {
try {
const classNames = getClassNames(props.name);
const duration = uni_modules_wotDesignUni_components_common_util.isObj(props.duration) ? props.duration.enter : props.duration;
status.value = "enter";
emit("before-enter");
enterLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
await enterLifeCyclePromises.value;
emit("enter");
classes.value = classNames.enter;
currentDuration.value = duration;
enterLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
await enterLifeCyclePromises.value;
inited.value = true;
display.value = true;
enterLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
await enterLifeCyclePromises.value;
enterLifeCyclePromises.value = null;
transitionEnded.value = false;
classes.value = classNames["enter-to"];
resolve();
} catch (error) {
}
});
}
async function leave() {
if (!enterPromise.value) {
transitionEnded.value = false;
return onTransitionEnd();
}
try {
await enterPromise.value;
if (!display.value)
return;
const classNames = getClassNames(props.name);
const duration = uni_modules_wotDesignUni_components_common_util.isObj(props.duration) ? props.duration.leave : props.duration;
status.value = "leave";
emit("before-leave");
currentDuration.value = duration;
leaveLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
await leaveLifeCyclePromises.value;
emit("leave");
classes.value = classNames.leave;
leaveLifeCyclePromises.value = uni_modules_wotDesignUni_components_common_util.pause();
await leaveLifeCyclePromises.value;
transitionEnded.value = false;
classes.value = classNames["leave-to"];
leaveLifeCyclePromises.value = setPromise(currentDuration.value);
await leaveLifeCyclePromises.value;
leaveLifeCyclePromises.value = null;
onTransitionEnd();
enterPromise.value = null;
} catch (error) {
}
}
function setPromise(duration) {
return new uni_modules_wotDesignUni_components_common_AbortablePromise.AbortablePromise((resolve) => {
const timer = setTimeout(() => {
clearTimeout(timer);
resolve();
}, duration);
});
}
function onTransitionEnd() {
if (transitionEnded.value)
return;
transitionEnded.value = true;
if (status.value === "leave") {
emit("after-leave");
} else if (status.value === "enter") {
emit("after-enter");
}
if (!props.show && display.value) {
display.value = false;
}
}
function noop() {
}
return (_ctx, _cache) => {
return common_vendor.e({
a: isShow.value && _ctx.disableTouchMove
}, isShow.value && _ctx.disableTouchMove ? {
b: common_vendor.n(rootClass.value),
c: common_vendor.s(style.value),
d: common_vendor.o(onTransitionEnd),
e: common_vendor.o(handleClick),
f: common_vendor.o(noop)
} : isShow.value && !_ctx.disableTouchMove ? {
h: common_vendor.n(rootClass.value),
i: common_vendor.s(style.value),
j: common_vendor.o(onTransitionEnd),
k: common_vendor.o(handleClick)
} : {}, {
g: isShow.value && !_ctx.disableTouchMove
});
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-af59a128"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/wd-transition/wd-transition.js.map

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view wx:if="{{a}}" class="{{['data-v-af59a128', b]}}" style="{{c}}" bindtransitionend="{{d}}" bindtap="{{e}}" catchtouchmove="{{f}}"><slot/></view><view wx:elif="{{g}}" class="{{['data-v-af59a128', h]}}" style="{{i}}" bindtransitionend="{{j}}" bindtap="{{k}}"><slot/></view>

View File

@@ -0,0 +1,83 @@
/* 水平间距 */
/* 水平间距 */
.wd-transition.data-v-af59a128 {
transition-timing-function: ease;
}
.wd-fade-enter.data-v-af59a128,
.wd-fade-leave-to.data-v-af59a128 {
opacity: 0;
}
.wd-fade-enter-active.data-v-af59a128,
.wd-fade-leave-active.data-v-af59a128 {
transition-property: opacity;
}
.wd-fade-up-enter.data-v-af59a128,
.wd-fade-up-leave-to.data-v-af59a128 {
transform: translate3d(0, 100%, 0);
opacity: 0;
}
.wd-fade-down-enter.data-v-af59a128,
.wd-fade-down-leave-to.data-v-af59a128 {
transform: translate3d(0, -100%, 0);
opacity: 0;
}
.wd-fade-left-enter.data-v-af59a128,
.wd-fade-left-leave-to.data-v-af59a128 {
transform: translate3d(-100%, 0, 0);
opacity: 0;
}
.wd-fade-right-enter.data-v-af59a128,
.wd-fade-right-leave-to.data-v-af59a128 {
transform: translate3d(100%, 0, 0);
opacity: 0;
}
.wd-slide-up-enter.data-v-af59a128,
.wd-slide-up-leave-to.data-v-af59a128 {
transform: translate3d(0, 100%, 0);
}
.wd-slide-down-enter.data-v-af59a128,
.wd-slide-down-leave-to.data-v-af59a128 {
transform: translate3d(0, -100%, 0);
}
.wd-slide-left-enter.data-v-af59a128,
.wd-slide-left-leave-to.data-v-af59a128 {
transform: translate3d(-100%, 0, 0);
}
.wd-slide-right-enter.data-v-af59a128,
.wd-slide-right-leave-to.data-v-af59a128 {
transform: translate3d(100%, 0, 0);
}
.wd-zoom-in-enter.data-v-af59a128,
.wd-zoom-in-leave-to.data-v-af59a128 {
opacity: 0;
transform: scale(0.8);
}
.wd-zoom-out-enter.data-v-af59a128,
.wd-zoom-out-leave-to.data-v-af59a128 {
transform: scale(1.2);
opacity: 0;
}
.wd-zoom-in-enter-active.data-v-af59a128,
.wd-zoom-in-leave-active.data-v-af59a128,
.wd-zoom-out-enter-active.data-v-af59a128,
.wd-zoom-out-leave-active.data-v-af59a128,
.wd-fade-up-enter-active.data-v-af59a128,
.wd-fade-up-leave-active.data-v-af59a128,
.wd-fade-down-enter-active.data-v-af59a128,
.wd-fade-down-leave-active.data-v-af59a128,
.wd-fade-left-enter-active.data-v-af59a128,
.wd-fade-left-leave-active.data-v-af59a128,
.wd-fade-right-enter-active.data-v-af59a128,
.wd-fade-right-leave-active.data-v-af59a128 {
transition-property: opacity, transform;
}
.wd-slide-up-enter-active.data-v-af59a128,
.wd-slide-up-leave-active.data-v-af59a128,
.wd-slide-down-enter-active.data-v-af59a128,
.wd-slide-down-leave-active.data-v-af59a128,
.wd-slide-left-enter-active.data-v-af59a128,
.wd-slide-left-leave-active.data-v-af59a128,
.wd-slide-right-enter-active.data-v-af59a128,
.wd-slide-right-leave-active.data-v-af59a128 {
transition-property: transform;
}