UNPKG

3.03 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps, CommonEventFunction, BaseEventOrigFunction } from './common'
3
4interface PageContainerProps extends StandardProps {
5 /** 是否显示容器组件
6 * @default false
7 * @supported weapp, rn
8 */
9 show?: boolean
10
11 /** 动画时长,单位毫秒
12 * @default 300
13 * @supported weapp, rn
14 */
15 duration?: number
16
17 /** z-index 层级
18 * @default 100
19 * @supported weapp
20 */
21 zIndex?: number
22
23 /** 是否显示遮罩层
24 * @default true
25 * @supported weapp, rn
26 */
27 overlay?: boolean
28
29 /** 弹出位置,可选值为 top bottom right center
30 * @default bottom
31 * @supported weapp, rn
32 */
33 position?: keyof PageContainerProps.Position
34
35 /** 是否显示圆角
36 * @default false
37 * @supported weapp, rn
38 */
39 round?: boolean
40
41 /** 是否在下滑一段距离后关闭
42 * @default false
43 * @supported weapp
44 */
45 closeOnSlideDown?: boolean
46
47 /** 自定义遮罩层样式
48 * @supported weapp, rn
49 */
50 overlayStyle?: string
51
52 /** 自定义弹出层样式
53 * @supported weapp, rn
54 */
55 customStyle?: string
56
57 /** 进入前触发
58 * @supported weapp, rn
59 */
60 onBeforeEnter?: CommonEventFunction
61
62 /** 进入中触发
63 * @supported weapp, rn
64 */
65 onEnter?: CommonEventFunction
66
67 /** 进入后触发
68 * @supported weapp, rn
69 */
70 onAfterEnter?: CommonEventFunction
71
72 /** 离开前触发
73 * @supported weapp, rn
74 */
75 onBeforeLeave?: CommonEventFunction
76
77 /** 离开中触发
78 * @supported weapp, rn
79 */
80 onLeave?: CommonEventFunction
81
82 /** 离开后触发
83 * @supported weapp, rn
84 */
85 onAfterLeave?: CommonEventFunction
86
87 /** 点击遮罩层时触发
88 * @supported weapp
89 */
90 onClickOverlay?: CommonEventFunction
91}
92
93declare namespace PageContainerProps {
94 /** 弹出位置 */
95 interface Position {
96 /** 上方弹出 */
97 top
98 /** 下方弹出 */
99 bottom
100 /** 右边弹出 */
101 right
102 /** 中央弹出 */
103 center
104 }
105}
106
107/** 页面容器
108 *
109 * 小程序如果在页面内进行复杂的界面设计(如在页面内弹出半屏的弹窗、在页面内加载一个全屏的子页面等),用户进行返回操作会直接离开当前页面,不符合用户预期,预期应为关闭当前弹出的组件。
110 * 为此提供“假页”容器组件,效果类似于 `popup` 弹出层,页面内存在该容器时,当用户进行返回操作,关闭该容器不关闭页面。返回操作包括三种情形,右滑手势、安卓物理返回键和调用 `navigateBack` 接口。
111 *
112 * Bug & Tip
113 * 1. tip: 当前页面最多只有 1 个容器,若已存在容器的情况下,无法增加新的容器
114 * 2. tip: wx.navigateBack 无法在页面栈顶调用,此时没有上一级页面
115 * @classification viewContainer
116 * @supported weapp, rn
117 * @see https://developers.weixin.qq.com/miniprogram/dev/component/page-container.html
118 */
119declare const PageContainer: ComponentType<PageContainerProps>
120
121export { PageContainer, PageContainerProps }