This commit is contained in:
Ling53666
2025-08-18 09:11:51 +08:00
commit 02554225da
2516 changed files with 133155 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<import-sjs
from="./index.sjs"
name="utils"
></import-sjs>
<view
a:if="{{!destroyOnClose || visible || closing}}"
class="ant-popup {{className || ''}}"
style="{{zIndex ? 'z-index:' + zIndex : ''}};{{style || ''}}"
hidden="{{!destroyOnClose && !visible && !closing}}"
>
<view
a:if="{{showMask}}"
class="ant-popup-mask {{maskClassName || ''}} {{closing && !visible ? 'ant-popup-mask-closing' : ''}}"
onTap="onTapMask"
style="{{animation ? '-webkit-animation-duration:' + duration + 'ms; animation-duration:' + duration + 'ms;' : ''}} {{maskStyle || ''}}"
>
<slot name="mask"></slot>
</view>
<view
class="ant-popup-content ant-popup-{{animationType}}-{{position}} {{closing ? 'ant-popup-' + animationType + '-' + position + '-close' : ''}}"
style="{{utils.getContentStyle(position, animation, duration, width, height)}}"
onAnimationEnd="onAnimationEnd"
>
<slot></slot>
<slot
name="content"
a:if="{{isOldVersion}}"
></slot>
</view>
</view>

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,64 @@
import { __awaiter, __generator } from "tslib";
import { Component, triggerEventOnly, getValueFromProps, } from '../_util/simply';
import { PopupDefaultProps } from './props';
import { isOldSDKVersion } from '../_util/platform';
var isOldVersion = isOldSDKVersion();
Component(PopupDefaultProps, {
onTapMask: function () {
var closing = this.data.closing;
if (closing) {
return;
}
triggerEventOnly(this, 'close');
},
onAnimationEnd: function () {
var closing = this.data.closing;
if (closing) {
this.setData({ closing: false });
}
var _a = getValueFromProps(this, [
'visible',
'duration',
'animation',
]), visible = _a[0], duration = _a[1], animation = _a[2];
var enableAnimation = animation && duration > 0;
if (enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
},
}, {
closing: false,
isOldVersion: isOldVersion,
}, undefined, {
deriveDataFromProps: function (nextProps) {
return __awaiter(this, void 0, void 0, function () {
var _a, visible, duration, animation, enableAnimation;
return __generator(this, function (_b) {
_a = getValueFromProps(this, [
'visible',
'duration',
'animation',
]), visible = _a[0], duration = _a[1], animation = _a[2];
enableAnimation = animation && duration > 0;
if (nextProps.visible !== visible &&
enableAnimation &&
!nextProps.visible &&
!this.data.closing) {
this.setData({ closing: true });
}
return [2 /*return*/];
});
});
},
didUpdate: function (prevProps) {
var _a = getValueFromProps(this, [
'visible',
'duration',
'animation',
]), visible = _a[0], duration = _a[1], animation = _a[2];
var enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible && !enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
},
});

View File

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

View File

@ -0,0 +1,335 @@
@import (reference) './variable.less';
@popupPrefix: ant-popup;
.@{popupPrefix} {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 998;
touch-action: none;
&-mask {
width: 100%;
height: 100%;
background-color: @popup-mask-product;
animation-fill-mode: forwards;
&-closing {
animation-name: ant-popup-mask-close;
}
}
&-content {
position: fixed;
background: @popup-background;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
color: @COLOR_TEXT_PRIMARY;
}
&-transform {
&-top {
top: 0;
left: 0;
right: 0;
animation-name: ant-popup-transform-top;
border-radius: 0 0 @popup-radius @popup-radius;
&-close {
animation-name: ant-popup-transform-top-close;
}
}
&-right {
top: 0;
right: 0;
bottom: 0;
animation-name: ant-popup-transform-right;
&-close {
animation-name: ant-popup-transform-right-close;
}
}
&-bottom {
left: 0;
right: 0;
bottom: 0;
animation-name: ant-popup-transform-bottom;
border-radius: @popup-radius @popup-radius 0 0;
&-close {
animation-name: ant-popup-transform-bottom-close;
}
}
&-left {
top: 0;
left: 0;
bottom: 0;
animation-name: ant-popup-transform-left;
&-close {
animation-name: ant-popup-transform-left-close;
}
}
&-center {
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
animation-name: ant-popup-transform-center;
border-radius: @popup-radius;
background: none;
&-close {
animation-name: ant-popup-transform-center-close;
}
}
}
&-position {
&-top {
top: 0;
left: 0;
right: 0;
animation-name: ant-popup-position-top;
border-radius: 0 0 @popup-radius @popup-radius;
&-close {
animation-name: ant-popup-position-top-close;
}
}
&-right {
top: 0;
right: 0;
bottom: 0;
animation-name: ant-popup-position-right;
&-close {
animation-name: ant-popup-position-right-close;
}
}
&-bottom {
left: 0;
right: 0;
bottom: 0;
animation-name: ant-popup-position-bottom;
border-radius: @popup-radius @popup-radius 0 0;
&-close {
animation-name: ant-popup-position-bottom-close;
}
}
&-left {
top: 0;
left: 0;
bottom: 0;
animation-name: ant-popup-position-left;
&-close {
animation-name: ant-popup-position-left-close;
}
}
&-center {
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
animation-name: ant-popup-position-center;
border-radius: @popup-radius;
background: none;
&-close {
animation-name: ant-popup-position-center-close;
}
}
}
}
@keyframes ant-popup-transform-top {
0% {
transform: translateY(-100%);
}
100% {
transform: translateY(0);
}
}
@keyframes ant-popup-transform-bottom {
0% {
transform: translateY(100%);
}
100% {
transform: translateY(0);
}
}
@keyframes ant-popup-transform-left {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(0);
}
}
@keyframes ant-popup-transform-right {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(0);
}
}
@keyframes ant-popup-transform-center {
0% {
transform: translate3d(-50%, -50%, 0) scale(0.1);
opacity: 0;
}
100% {
transform: translate3d(-50%, -50%, 0) scale(1);
opacity: 1;
}
}
@keyframes ant-popup-transform-top-close {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-100%);
}
}
@keyframes ant-popup-transform-bottom-close {
0% {
transform: translateY(0);
}
100% {
transform: translateY(100%);
}
}
@keyframes ant-popup-transform-left-close {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-100%);
}
}
@keyframes ant-popup-transform-right-close {
0% {
transform: translateX(0);
}
100% {
transform: translateX(100%);
}
}
@keyframes ant-popup-transform-center-close {
0% {
opacity: 1;
transform: translate3d(-50%, -50%, 0) scale(1);
}
20% {
opacity: 0.8;
transform: translate3d(-50%, -50%, 0) scale(0.9);
}
100% {
opacity: 0;
transform: translate3d(-50%, -50%, 0) scale(0.9);
}
}
@keyframes ant-popup-position-top {
0% {
top: -100%;
}
100% {
top: 0;
}
}
@keyframes ant-popup-position-bottom {
0% {
bottom: -100%;
}
100% {
bottom: 0;
}
}
@keyframes ant-popup-position-left {
0% {
left: -100%;
}
100% {
left: 0;
}
}
@keyframes ant-popup-position-right {
0% {
right: -100%;
}
100% {
right: 0;
}
}
@keyframes ant-popup-position-center {
0% {
transform: translate3d(-50%, -50%, 0) scale(0.1);
opacity: 0;
}
100% {
transform: translate3d(-50%, -50%, 0) scale(1);
opacity: 1;
}
}
@keyframes ant-popup-position-top-close {
0% {
top: 0;
}
100% {
top: -100%;
}
}
@keyframes ant-popup-position-bottom-close {
0% {
bottom: 0;
}
100% {
bottom: -100%;
}
}
@keyframes ant-popup-position-left-close {
0% {
left: 0;
}
100% {
left: -100%;
}
}
@keyframes ant-popup-position-right-close {
0% {
right: 0;
}
100% {
right: -100%;
}
}
@keyframes ant-popup-position-center-close {
0% {
opacity: 1;
transform: translate3d(-50%, -50%, 0) scale(1);
}
20% {
opacity: 0.8;
transform: translate3d(-50%, -50%, 0) scale(0.9);
}
100% {
opacity: 0;
transform: translate3d(-50%, -50%, 0) scale(0.9);
}
}
@keyframes ant-popup-mask-close {
0% {
background-color: @popup-mask-product;
}
100% {
background-color: fade(@COLOR_BLACK, 0);
}
}

View File

@ -0,0 +1,20 @@
function getContentStyle(position, animation, duration, width, height) {
var style = '';
if (animation) {
style += "-webkit-animation-duration:".concat(duration, "ms; animation-duration:").concat(duration, "ms;");
}
if (position === 'top' || position === 'bottom') {
if (typeof height !== 'undefined' && height !== null) {
style += "height:".concat(height, "px");
}
}
if (position === 'left' || position === 'right') {
if (typeof width !== 'undefined' && width !== null) {
style += "width:".concat(width, "px");
}
}
return style;
}
export default {
getContentStyle: getContentStyle
};

View File

@ -0,0 +1,69 @@
import { IBaseProps } from '../_util/base';
/**
* @description 弹窗,可在其中加入具体内容,展示更多信息供用户使用。
*/
export interface IPopupProps extends IBaseProps {
/**
* @description 是否显示
* @default false
*/
visible: boolean;
/**
* @description 是否关闭后销毁内部元素
* @default false
*/
destroyOnClose: boolean;
/**
* @description 是否展示蒙层
* @default true
*/
showMask: boolean;
/**
* @description 弹窗布局
* @default "bottom"
*/
position: 'center' | 'top' | 'bottom' | 'left' | 'right';
/**
* @description 是否开启过渡动画
*/
animation: boolean;
/**
* @description 动画类型
* @default "transform"
*/
animationType: 'transform' | 'position';
/**
* @description 过渡动画时长,单位毫秒
*/
duration: number;
/**
* @description 内容区高度单位px
*/
height: number;
/**
* @description 内容区宽度单位px
*/
width: number;
/**
* @description 遮罩层类名
*/
maskClassName: string;
/**
* @description 遮罩层样式
*/
maskStyle: string;
zIndex: number;
/**
* @description 关闭时回调
*/
onClose?: () => void;
/**
* @description 完全打开时回调
*/
onAfterShow?: () => void;
/**
* @description 完全关闭时回调
*/
onAfterClose?: () => void;
}
export declare const PopupDefaultProps: Partial<IPopupProps>;

View File

@ -0,0 +1,17 @@
export var PopupDefaultProps = {
visible: false,
destroyOnClose: false,
showMask: true,
position: 'bottom',
// 是否开启动画
animation: true,
animationType: 'transform',
// 动画持续时间
duration: 300,
height: null,
width: null,
maskClassName: '',
maskStyle: '',
// 弹窗层级
zIndex: 998,
};

View File

@ -0,0 +1,8 @@
@import (reference) '../style/themes/index.less';
// popup 背景色
@popup-background: @COLOR_CARD;
// 产品蒙层
@popup-mask-product: @color-product-mask;
// popup 圆角
@popup-radius: @corner-radius-lg;