New Huajishe Check ChaoXing

This commit is contained in:
e2hang
2025-10-01 10:01:52 +08:00
parent 240b884eac
commit 80be8ae3cf
1094 changed files with 61709 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
:: BASE_DOC ::
## API
### Popup Props
name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets)used to set style on virtual component | N
close-btn | Boolean / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
close-on-overlay-click | Boolean | true | \- | N
content | String / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
duration | Number | 240 | \- | N
overlay-props | Object | {} | Typescript`OverlayProps`[Overlay API Documents](./overlay?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/popup/type.ts) | N
placement | String | top | options: top/left/right/bottom/center | N
prevent-scroll-through | Boolean | true | \- | N
show-overlay | Boolean | true | \- | N
using-custom-navbar | Boolean | false | \- | N
visible | Boolean | - | Typescript`boolean` | N
default-visible | Boolean | undefined | uncontrolled property。Typescript`boolean` | N
z-index | Number | 11500 | \- | N
### Popup Events
name | params | description
-- | -- | --
visible-change | `(visible: boolean, trigger: PopupSource) ` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/popup/type.ts)。<br/>`type PopupSource = 'close-btn' \| 'overlay'`<br/>
### Popup External Classes
className | Description
-- | --
t-class | \-
t-class-content | \-
### CSS Variables
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-popup-bg-color | @bg-color-container | -
--td-popup-border-radius | @radius-default | -
--td-popup-close-btn-color | @text-color-primary | -

View File

@@ -0,0 +1,82 @@
---
title: Popup 弹出层
description: 由其他控件触发,屏幕滑出或弹出一块自定义内容区域。
spline: message
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-popup": "tdesign-miniprogram/popup/popup"
}
```
## 代码演示
<a href="https://developers.weixin.qq.com/s/AB8Cvim37eS6" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后依次执行npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
</blockquote>
### 组件类型
基础弹出层
{{ base }}
### 组件示例
应用示例
{{ with-title }}
{{ custom-close }}
## API
### Popup Props
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
close-btn | Boolean / Slot | - | 关闭按钮,值类型为 Boolean 时表示是否显示关闭按钮。也可以自定义关闭按钮。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
close-on-overlay-click | Boolean | true | 点击遮罩层是否关闭 | N
content | String / Slot | - | 浮层里面的内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
duration | Number | 240 | 动画过渡时间 | N
overlay-props | Object | {} | 遮罩层的属性,透传至 overlay。TS 类型:`OverlayProps`[Overlay API Documents](./overlay?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/popup/type.ts) | N
placement | String | top | 浮层出现位置。可选项top/left/right/bottom/center | N
prevent-scroll-through | Boolean | true | 是否阻止背景滚动 | N
show-overlay | Boolean | true | 是否显示遮罩层 | N
using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
visible | Boolean | - | 是否显示浮层。TS 类型:`boolean` | N
default-visible | Boolean | undefined | 是否显示浮层。非受控属性。TS 类型:`boolean` | N
z-index | Number | 11500 | 组件层级Web 侧样式默认为 5500移动端样式默认为 1500小程序样式默认为11500 | N
### Popup Events
名称 | 参数 | 描述
-- | -- | --
visible-change | `(visible: boolean, trigger: PopupSource) ` | 当浮层隐藏或显示时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/popup/type.ts)。<br/>`type PopupSource = 'close-btn' \| 'overlay'`<br/>
### Popup External Classes
类名 | 描述
-- | --
t-class | 根节点样式类
t-class-content | 内容样式类
### CSS Variables
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-popup-bg-color | @bg-color-container | -
--td-popup-border-radius | @radius-default | -
--td-popup-close-btn-color | @text-color-primary | -

View File

@@ -0,0 +1,3 @@
export * from './props';
export * from './type';
export * from './popup';

View File

@@ -0,0 +1,3 @@
export * from './props';
export * from './type';
export * from './popup';

View File

@@ -0,0 +1,19 @@
import { TdPopupProps } from './type';
import { SuperComponent } from '../common/src/index';
export declare type PopupProps = TdPopupProps;
export default class Popup extends SuperComponent {
externalClasses: string[];
behaviors: string[];
options: {
multipleSlots: boolean;
};
properties: TdPopupProps;
data: {
prefix: string;
classPrefix: string;
};
methods: {
handleOverlayClick(): void;
handleClose(): void;
};
}

View File

@@ -0,0 +1,44 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { SuperComponent, wxComponent } from '../common/src/index';
import config from '../common/config';
import props from './props';
import transition from '../mixins/transition';
import useCustomNavbar from '../mixins/using-custom-navbar';
delete props.visible;
const { prefix } = config;
const name = `${prefix}-popup`;
let Popup = class Popup extends SuperComponent {
constructor() {
super(...arguments);
this.externalClasses = [`${prefix}-class`, `${prefix}-class-content`];
this.behaviors = [transition(), useCustomNavbar];
this.options = {
multipleSlots: true,
};
this.properties = props;
this.data = {
prefix,
classPrefix: name,
};
this.methods = {
handleOverlayClick() {
const { closeOnOverlayClick } = this.properties;
if (closeOnOverlayClick) {
this.triggerEvent('visible-change', { visible: false, trigger: 'overlay' });
}
},
handleClose() {
this.triggerEvent('visible-change', { visible: false, trigger: 'close-btn' });
},
};
}
};
Popup = __decorate([
wxComponent()
], Popup);
export default Popup;

View File

@@ -0,0 +1,8 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {
"t-overlay": "../overlay/overlay",
"t-icon": "../icon/icon"
}
}

View File

@@ -0,0 +1,36 @@
<wxs src="./popup.wxs" module="popup" />
<wxs src="../common/utils.wxs" module="_" />
<view
wx:if="{{realVisible}}"
style="{{_._style([popup.getPopupStyles(zIndex, distanceTop, placement), style, customStyle])}}"
class="{{_.cls(classPrefix, [placement])}} {{transitionClass}} class {{prefix}}-class"
bind:transitionend="onTransitionEnd"
>
<!-- 暂时移除aria-role="dialog" aria-modal="{{ true }}"关联https://github.com/Tencent/tdesign-miniprogram/issues/2142 -->
<view
data-prevention="{{preventScrollThrough || (overlayProps ? !!overlayProps.preventScrollThrough : false)}}"
bind:touchmove="{{popup.onContentTouchMove}}"
class="{{classPrefix}}__content {{prefix}}-class-content"
>
<slot name="content" />
<slot />
<view class="{{classPrefix}}__close" bind:tap="handleClose">
<t-icon name="close" wx:if="{{closeBtn}}" size="64rpx" />
<slot name="close-btn" class="{{classPrefix}}-slot" />
</view>
</view>
</view>
<t-overlay
id="popup-overlay"
wx:if="{{showOverlay}}"
visible="{{visible}}"
usingCustomNavbar="{{usingCustomNavbar}}"
z-index="{{overlayProps && overlayProps.zIndex || 11000}}"
duration="{{overlayProps && overlayProps.duration || 300}}"
background-color="{{overlayProps && overlayProps.backgroundColor || ''}}"
prevent-scroll-through="{{preventScrollThrough || (overlayProps ? !!overlayProps.preventScrollThrough : false)}}"
bind:tap="handleOverlayClick"
custom-style="{{overlayProps && overlayProps.style || ''}}"
/>

View File

@@ -0,0 +1,18 @@
function getPopupStyles(zIndex, distanceTop, placement) {
var zIndexStyle = zIndex ? 'z-index:' + zIndex + ';' : '';
if ((placement === 'top' || placement === 'left' || placement === 'right') && distanceTop) {
zIndexStyle = zIndexStyle + 'top:' + distanceTop + 'px;';
}
return zIndexStyle;
}
function onContentTouchMove(e) {
if (e.target && e.target.dataset.prevention) {
return false;
}
}
module.exports = {
getPopupStyles: getPopupStyles,
onContentTouchMove: onContentTouchMove,
};

View File

@@ -0,0 +1,105 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
.t-popup {
position: fixed;
z-index: 11500;
max-height: 100vh;
transition: all 300ms ease;
background-color: var(--td-popup-bg-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff)));
}
.t-popup__content {
position: relative;
z-index: 1;
}
.t-popup__close {
position: absolute;
top: 0;
right: 0;
padding: 20rpx;
line-height: 1;
color: var(--td-popup-close-btn-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
}
.t-popup--top {
top: 0;
left: 0;
width: 100%;
border-bottom-left-radius: var(--td-popup-border-radius, var(--td-radius-extra-large, 24rpx));
border-bottom-right-radius: var(--td-popup-border-radius, var(--td-radius-extra-large, 24rpx));
}
.t-popup--bottom {
bottom: 0;
left: 0;
width: 100%;
border-top-left-radius: var(--td-popup-border-radius, var(--td-radius-extra-large, 24rpx));
border-top-right-radius: var(--td-popup-border-radius, var(--td-radius-extra-large, 24rpx));
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
.t-popup--left {
top: 0;
left: 0;
height: 100vh;
}
.t-popup--right {
top: 0;
right: 0;
height: 100vh;
}
.t-popup--center {
top: 50%;
left: 50%;
transform: scale(1) translate3d(-50%, -50%, 0);
transform-origin: 0% 0%;
border-radius: var(--td-popup-border-radius, var(--td-radius-extra-large, 24rpx));
}
.t-popup.t-fade-enter.t-popup--top,
.t-popup.t-fade-leave-to.t-popup--top {
transform: translateY(-100%);
}
.t-popup.t-fade-enter.t-popup--bottom,
.t-popup.t-fade-leave-to.t-popup--bottom {
transform: translateY(100%);
}
.t-popup.t-fade-enter.t-popup--left,
.t-popup.t-fade-leave-to.t-popup--left {
transform: translateX(-100%);
}
.t-popup.t-fade-enter.t-popup--right,
.t-popup.t-fade-leave-to.t-popup--right {
transform: translateX(100%);
}
.t-popup.t-fade-enter.t-popup--center,
.t-popup.t-fade-leave-to.t-popup--center {
transform: scale(0.6) translate3d(-50%, -50%, 0);
opacity: 0;
}
.t-popup.t-dialog-enter.t-popup--center,
.t-popup.t-dialog-leave-to.t-popup--center {
transform: scale(0.6) translate3d(-50%, -50%, 0);
opacity: 0;
}

View File

@@ -0,0 +1,3 @@
import { TdPopupProps } from './type';
declare const props: TdPopupProps;
export default props;

View File

@@ -0,0 +1,51 @@
const props = {
closeBtn: {
type: Boolean,
},
closeOnOverlayClick: {
type: Boolean,
value: true,
},
content: {
type: String,
},
duration: {
type: Number,
value: 240,
},
externalClasses: {
type: Array,
},
overlayProps: {
type: Object,
value: {},
},
placement: {
type: String,
value: 'top',
},
preventScrollThrough: {
type: Boolean,
value: true,
},
showOverlay: {
type: Boolean,
value: true,
},
usingCustomNavbar: {
type: Boolean,
value: false,
},
visible: {
type: Boolean,
value: null,
},
defaultVisible: {
type: Boolean,
},
zIndex: {
type: Number,
value: 11500,
},
};
export default props;

View File

@@ -0,0 +1,55 @@
import { OverlayProps } from '../overlay/index';
export interface TdPopupProps {
closeBtn?: {
type: BooleanConstructor;
value?: boolean;
};
closeOnOverlayClick?: {
type: BooleanConstructor;
value?: boolean;
};
content?: {
type: StringConstructor;
value?: string;
};
duration?: {
type: NumberConstructor;
value?: number;
};
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class', 't-class-overlay', 't-class-content'];
};
overlayProps?: {
type: ObjectConstructor;
value?: OverlayProps;
};
placement?: {
type: StringConstructor;
value?: 'top' | 'left' | 'right' | 'bottom' | 'center';
};
preventScrollThrough?: {
type: BooleanConstructor;
value?: boolean;
};
showOverlay?: {
type: BooleanConstructor;
value?: boolean;
};
usingCustomNavbar?: {
type: BooleanConstructor;
value?: boolean;
};
visible?: {
type: BooleanConstructor;
value?: boolean;
};
defaultVisible?: {
type: BooleanConstructor;
value?: boolean;
};
zIndex?: {
type: NumberConstructor;
value?: number;
};
}

View File

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