UNPKG

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