@ray-js/smart-ui 2.13.2-beta-0 → 2.13.2-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/@types/config-provider/index.d.ts +7 -2
- package/es/@types/config-provider/theme-vars.d.ts +1 -1
- package/es/action-sheet/README.md +613 -0
- package/es/battery/README.md +149 -0
- package/es/bottom-sheet/README.md +495 -0
- package/es/button/README.md +335 -0
- package/es/calendar/README.md +513 -0
- package/es/cascader/README.md +326 -0
- package/es/cell/README.md +317 -0
- package/es/checkbox/README.md +481 -0
- package/es/circle/README.md +132 -0
- package/es/col/README.md +162 -0
- package/es/collapse/README.md +127 -0
- package/es/config-provider/README.md +150 -0
- package/es/count-down/README.md +201 -0
- package/es/custom-keyboard/README.md +122 -0
- package/es/datetime-picker/README.md +438 -0
- package/es/dialog/README.md +451 -0
- package/es/divider/README.md +132 -0
- package/es/dropdown-menu/README.md +331 -0
- package/es/empty/README.md +119 -0
- package/es/field/README.md +455 -0
- package/es/grid/README.md +273 -0
- package/es/icon/README.md +178 -0
- package/es/image/README.md +225 -0
- package/es/index-bar/README.md +186 -0
- package/es/loading/README.md +120 -0
- package/es/nav-bar/README.md +410 -0
- package/es/notice-bar/README.md +274 -0
- package/es/notify/README.md +121 -0
- package/es/overlay/README.md +128 -0
- package/es/picker/README.md +412 -0
- package/es/popover/README.md +338 -0
- package/es/popup/README.md +272 -0
- package/es/progress/README.md +88 -0
- package/es/radio/README.md +423 -0
- package/es/rate/README.md +248 -0
- package/es/search/README.md +290 -0
- package/es/sidebar/README.md +176 -0
- package/es/skeleton/README.md +141 -0
- package/es/slider/README.md +444 -0
- package/es/stepper/README.md +231 -0
- package/es/sticky/README.md +91 -0
- package/es/swipe-cell/README.md +217 -0
- package/es/switch/README.md +316 -0
- package/es/tab/README.md +501 -0
- package/es/tabbar/README.md +397 -0
- package/es/tag/README.md +215 -0
- package/es/toast/README.md +293 -0
- package/es/transition/README.md +140 -0
- package/es/tree-select/README.md +348 -0
- package/lib/@types/config-provider/index.d.ts +7 -2
- package/lib/@types/config-provider/theme-vars.d.ts +1 -1
- package/lib/action-sheet/README.md +613 -0
- package/lib/battery/README.md +149 -0
- package/lib/bottom-sheet/README.md +495 -0
- package/lib/button/README.md +335 -0
- package/lib/calendar/README.md +513 -0
- package/lib/cascader/README.md +326 -0
- package/lib/cell/README.md +317 -0
- package/lib/checkbox/README.md +481 -0
- package/lib/circle/README.md +132 -0
- package/lib/col/README.md +162 -0
- package/lib/collapse/README.md +127 -0
- package/lib/config-provider/README.md +150 -0
- package/lib/count-down/README.md +201 -0
- package/lib/custom-keyboard/README.md +122 -0
- package/lib/datetime-picker/README.md +438 -0
- package/lib/dialog/README.md +451 -0
- package/lib/divider/README.md +132 -0
- package/lib/dropdown-menu/README.md +331 -0
- package/lib/empty/README.md +119 -0
- package/lib/field/README.md +455 -0
- package/lib/grid/README.md +273 -0
- package/lib/icon/README.md +178 -0
- package/lib/image/README.md +225 -0
- package/lib/index-bar/README.md +186 -0
- package/lib/loading/README.md +120 -0
- package/lib/nav-bar/README.md +410 -0
- package/lib/notice-bar/README.md +274 -0
- package/lib/notify/README.md +121 -0
- package/lib/overlay/README.md +128 -0
- package/lib/picker/README.md +412 -0
- package/lib/popover/README.md +338 -0
- package/lib/popup/README.md +272 -0
- package/lib/progress/README.md +88 -0
- package/lib/radio/README.md +423 -0
- package/lib/rate/README.md +248 -0
- package/lib/search/README.md +290 -0
- package/lib/sidebar/README.md +176 -0
- package/lib/skeleton/README.md +141 -0
- package/lib/slider/README.md +444 -0
- package/lib/stepper/README.md +231 -0
- package/lib/sticky/README.md +91 -0
- package/lib/swipe-cell/README.md +217 -0
- package/lib/switch/README.md +316 -0
- package/lib/tab/README.md +501 -0
- package/lib/tabbar/README.md +397 -0
- package/lib/tag/README.md +215 -0
- package/lib/toast/README.md +293 -0
- package/lib/transition/README.md +140 -0
- package/lib/tree-select/README.md +348 -0
- package/package.json +3 -3
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 反馈
|
|
3
|
+
new: true
|
|
4
|
+
version: v2.3.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Popover 弹出提示
|
|
8
|
+
|
|
9
|
+
### 介绍
|
|
10
|
+
|
|
11
|
+
v2.3.0开始加入,弹出层容器,用于展示弹窗、信息提示等轻量内容。
|
|
12
|
+
|
|
13
|
+
### 引入
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import { Popover } from '@ray-js/smart-ui';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 代码演示
|
|
20
|
+
|
|
21
|
+
### 基础用法
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import { View } from '@ray-js/ray';
|
|
25
|
+
import { Popover, Icon, Button } from '@ray-js/smart-ui';
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import Sun from '@tuya-miniapp/icons/dist/svg/Sun';
|
|
28
|
+
|
|
29
|
+
export default function Demo() {
|
|
30
|
+
const [show, setShow] = React.useState(false);
|
|
31
|
+
const showPopup = () => setShow(true);
|
|
32
|
+
const onClose = () => setShow(false);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<View style={{paddingBottom: '64px'}}>
|
|
36
|
+
<View
|
|
37
|
+
style={{
|
|
38
|
+
padding: '10vh',
|
|
39
|
+
paddingTop: 0,
|
|
40
|
+
paddingLeft: 8,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<Popover
|
|
44
|
+
show={show}
|
|
45
|
+
onClose={() => setShow(false)}
|
|
46
|
+
placement="bottomLeft"
|
|
47
|
+
customStyle={{
|
|
48
|
+
padding: '0px',
|
|
49
|
+
width: '200px',
|
|
50
|
+
}}
|
|
51
|
+
slot={{
|
|
52
|
+
overlay: (
|
|
53
|
+
<View>
|
|
54
|
+
{[1, 2, 3].map(n => (
|
|
55
|
+
<View className={styles.listItem} key={n}>
|
|
56
|
+
<Icon name={Sun} size="24px" color="#3678E3" />
|
|
57
|
+
<Text className={styles.listText}>Title</Text>
|
|
58
|
+
</View>
|
|
59
|
+
))}
|
|
60
|
+
</View>
|
|
61
|
+
),
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<Button>下左弹出</Button>
|
|
65
|
+
</Popover>
|
|
66
|
+
</View>
|
|
67
|
+
<View
|
|
68
|
+
style={{
|
|
69
|
+
padding: '10vh',
|
|
70
|
+
paddingTop: 0,
|
|
71
|
+
paddingLeft: '20vw',
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<Popover
|
|
75
|
+
placement="bottom"
|
|
76
|
+
customStyle={{
|
|
77
|
+
padding: '0px',
|
|
78
|
+
width: '200px',
|
|
79
|
+
}}
|
|
80
|
+
slot={{
|
|
81
|
+
overlay: (
|
|
82
|
+
<View>
|
|
83
|
+
{[1, 2, 3].map(n => (
|
|
84
|
+
<View className={styles.listItem} key={n}>
|
|
85
|
+
<Icon name={Sun} size="24px" color="#3678E3" />
|
|
86
|
+
<Text className={styles.listText}>Title</Text>
|
|
87
|
+
</View>
|
|
88
|
+
))}
|
|
89
|
+
</View>
|
|
90
|
+
),
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<Button>下中弹出</Button>
|
|
94
|
+
</Popover>
|
|
95
|
+
</View>
|
|
96
|
+
<View
|
|
97
|
+
style={{
|
|
98
|
+
padding: '10vh',
|
|
99
|
+
paddingTop: 0,
|
|
100
|
+
paddingLeft: '40vw',
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<Popover
|
|
104
|
+
placement="bottomRight"
|
|
105
|
+
customStyle={{
|
|
106
|
+
padding: '0px',
|
|
107
|
+
width: '200px',
|
|
108
|
+
}}
|
|
109
|
+
slot={{
|
|
110
|
+
overlay: (
|
|
111
|
+
<View>
|
|
112
|
+
{[1, 2, 3].map(n => (
|
|
113
|
+
<View className={styles.listItem} key={n}>
|
|
114
|
+
<Icon name={Sun} size="24px" color="#3678E3" />
|
|
115
|
+
<Text className={styles.listText}>Title</Text>
|
|
116
|
+
</View>
|
|
117
|
+
))}
|
|
118
|
+
</View>
|
|
119
|
+
),
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<Button>下右弹出</Button>
|
|
123
|
+
</Popover>
|
|
124
|
+
</View>
|
|
125
|
+
<View
|
|
126
|
+
style={{
|
|
127
|
+
paddingLeft: 8,
|
|
128
|
+
paddingTop: '10vh',
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
<Popover
|
|
132
|
+
placement="top"
|
|
133
|
+
slot={{
|
|
134
|
+
overlay: <View>tip</View>,
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
<Button>上侧弹出</Button>
|
|
138
|
+
</Popover>
|
|
139
|
+
</View>
|
|
140
|
+
<View
|
|
141
|
+
style={{
|
|
142
|
+
paddingLeft: '20vw',
|
|
143
|
+
paddingTop: '10vh',
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<Popover
|
|
147
|
+
placement="left"
|
|
148
|
+
slot={{
|
|
149
|
+
overlay: <View>tip</View>,
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<Button>左侧弹出</Button>
|
|
153
|
+
</Popover>
|
|
154
|
+
</View>
|
|
155
|
+
<View
|
|
156
|
+
style={{
|
|
157
|
+
paddingLeft: '8px',
|
|
158
|
+
paddingTop: '10vh',
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<Popover
|
|
162
|
+
placement="right"
|
|
163
|
+
slot={{
|
|
164
|
+
overlay: <View>tip</View>,
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<Button>右侧弹出</Button>
|
|
168
|
+
</Popover>
|
|
169
|
+
</View>
|
|
170
|
+
<View
|
|
171
|
+
style={{
|
|
172
|
+
paddingLeft: '8px',
|
|
173
|
+
paddingTop: '10vh',
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
<Popover
|
|
177
|
+
placement="bottom"
|
|
178
|
+
slot={{
|
|
179
|
+
overlay: <View>tip</View>,
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
<Button>下中弹出</Button>
|
|
183
|
+
</Popover>
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
less 样式如下
|
|
191
|
+
|
|
192
|
+
```less
|
|
193
|
+
.listItem {
|
|
194
|
+
height: 96rpx;
|
|
195
|
+
padding: 0 32rpx;
|
|
196
|
+
line-height: 96rpx;
|
|
197
|
+
display: flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
position: relative;
|
|
200
|
+
&:nth-child(n + 2)::after {
|
|
201
|
+
display: block;
|
|
202
|
+
content: '';
|
|
203
|
+
height: 1px;
|
|
204
|
+
background-color: #ebebeb;
|
|
205
|
+
width: 90%;
|
|
206
|
+
position: absolute;
|
|
207
|
+
right: 0;
|
|
208
|
+
top: 0;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.listText {
|
|
213
|
+
margin-left: 20rpx;
|
|
214
|
+
font-size: 16px;
|
|
215
|
+
color: rgba(0, 0, 0, 0.9);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 受控用法
|
|
220
|
+
|
|
221
|
+
通过`show`属性控制弹出层是否展示。
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { View } from '@ray-js/ray';
|
|
225
|
+
import { Popover, Button } from '@ray-js/smart-ui';
|
|
226
|
+
import React from 'react';
|
|
227
|
+
|
|
228
|
+
export default function Demo() {
|
|
229
|
+
const [show, setShow] = React.useState(false);
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<Popover placement="bottom" show={show} onClose={() => setShow(false)} onShowChange={e => setShow(e.detail)} slot={{
|
|
233
|
+
overlay: <View>tip</View>
|
|
234
|
+
}}>
|
|
235
|
+
<Button>下方弹出</Button>
|
|
236
|
+
</Popover>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### 弹出位置
|
|
242
|
+
|
|
243
|
+
通过`position`属性设置弹出位置,默认居右弹出,可以设置为`top`、`topLeft`、`topRight`、`bottom`、`bottomLeft`、`bottomRight`、`left`、`leftTop`、`leftBottom`、`right`、`rightTop`、`rightBottom`。
|
|
244
|
+
|
|
245
|
+
```jsx
|
|
246
|
+
import { View } from '@ray-js/ray';
|
|
247
|
+
import { Popover, Button } from '@ray-js/smart-ui';
|
|
248
|
+
import React from 'react';
|
|
249
|
+
|
|
250
|
+
export default function Demo() {
|
|
251
|
+
return (
|
|
252
|
+
<Popover placement="right" slot={{
|
|
253
|
+
overlay: <View>弹框内容</View>
|
|
254
|
+
}}>
|
|
255
|
+
<Button>右侧弹出</Button>
|
|
256
|
+
</Popover>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### 自定义遮罩样式 `v2.13.1`
|
|
262
|
+
|
|
263
|
+
通过 `overlayStyle` 可自定义遮罩层样式,透传至内部 `smart-overlay` 的 `custom-style`。
|
|
264
|
+
|
|
265
|
+
```jsx
|
|
266
|
+
import { View, Text } from '@ray-js/ray';
|
|
267
|
+
import { Popover, Button } from '@ray-js/smart-ui';
|
|
268
|
+
import React from 'react';
|
|
269
|
+
|
|
270
|
+
export default function Demo() {
|
|
271
|
+
return (
|
|
272
|
+
<View style={{ paddingLeft: 8, paddingTop: '10vh' }}>
|
|
273
|
+
<Popover
|
|
274
|
+
placement="bottom"
|
|
275
|
+
overlayStyle={{
|
|
276
|
+
backgroundColor: 'rgba(64, 128, 255, 0.25)',
|
|
277
|
+
}}
|
|
278
|
+
customStyle={{
|
|
279
|
+
padding: '0px',
|
|
280
|
+
width: '200px',
|
|
281
|
+
}}
|
|
282
|
+
slot={{
|
|
283
|
+
overlay: (
|
|
284
|
+
<View>
|
|
285
|
+
<Text>tip</Text>
|
|
286
|
+
</View>
|
|
287
|
+
),
|
|
288
|
+
}}
|
|
289
|
+
>
|
|
290
|
+
<Button>自定义遮罩样式</Button>
|
|
291
|
+
</Popover>
|
|
292
|
+
</View>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## API
|
|
298
|
+
|
|
299
|
+
### Props
|
|
300
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
301
|
+
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
|
|
302
|
+
| customStyle | 自定义弹出层样式 | _React.CSSProperties_ | - |
|
|
303
|
+
| overlayStyle `v2.13.1` | 自定义遮罩层样式,透传至内部 `smart-overlay` 的 `custom-style` | _React.CSSProperties_ | - |
|
|
304
|
+
| duration | 延迟关闭的时间(ms) | number | `3000` |
|
|
305
|
+
| placement | 弹出层的位置,支持值:`top`、`topLeft`、`topRight`、`bottom`、`bottomLeft`、`bottomRight`、`left`、`leftTop`、`leftBottom`、`right`、`rightTop`、`rightBottom` | _string_ | `right` |
|
|
306
|
+
| show | 控制弹出层是否显示,并监听状态变化,值变更时更新 `currentShow` | _boolean_ | `false` |
|
|
307
|
+
| trigger `v2.5.0` | 控制弹出层触发方式,支持 `tap`、`longpress` | _string_ | `tap` |
|
|
308
|
+
|
|
309
|
+
### Events
|
|
310
|
+
|
|
311
|
+
| 事件名 | 说明 | 参数 |
|
|
312
|
+
| ---------------- | --------------- | ---- |
|
|
313
|
+
| onClose | 关闭时触发 | - |
|
|
314
|
+
| onShowChange | 显示/隐藏时触发 | - |
|
|
315
|
+
|
|
316
|
+
### Popover Slot
|
|
317
|
+
|
|
318
|
+
| 名称 | 说明 |
|
|
319
|
+
| ------- | -------- |
|
|
320
|
+
| overlay | 弹窗内容 |
|
|
321
|
+
|
|
322
|
+
### 外部样式类
|
|
323
|
+
|
|
324
|
+
| 类名 | 说明 |
|
|
325
|
+
| ------------ | ------------ |
|
|
326
|
+
| customClass | 根节点样式类 |
|
|
327
|
+
|
|
328
|
+
### 样式变量
|
|
329
|
+
|
|
330
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
|
|
331
|
+
|
|
332
|
+
| 名称 | 默认值 | 描述 |
|
|
333
|
+
| -------------------------------- | ----------------------------------- | ---------------- |
|
|
334
|
+
| --popover-background-color | #fff | 弹出层背景色 |
|
|
335
|
+
| --popover-border-radius | 12px | 弹出层圆角 |
|
|
336
|
+
| --popover-box-shadow | 0px 6px 12px 0px rgba(0, 0, 0, 0.1) | 弹出层阴影 |
|
|
337
|
+
| --popover-overlay-color `v2.8.0` | var(--app-B1-N1, rgba(0, 0, 0, 1)) | 遮照插槽文字颜色 |
|
|
338
|
+
| --popover-padding | 12px | 弹出层内边距 |
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 反馈
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Popup 弹出层
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
弹出层容器,用于展示弹窗、信息提示等内容,支持多个弹出层叠加展示。
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Popup } from '@ray-js/smart-ui';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 代码演示
|
|
18
|
+
|
|
19
|
+
### 基础用法
|
|
20
|
+
|
|
21
|
+
通过`show`属性控制弹出层是否展示。
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import { View } from '@ray-js/ray';
|
|
25
|
+
import { Popup, Cell } from '@ray-js/smart-ui';
|
|
26
|
+
import React from 'react';
|
|
27
|
+
|
|
28
|
+
export default function Demo() {
|
|
29
|
+
const [show, setShow] = React.useState(false);
|
|
30
|
+
const showPopup = () => setShow(true);
|
|
31
|
+
const onClose = () => setShow(false);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View>
|
|
35
|
+
<Cell title="展示弹出层" isLink onClick={showPopup} />
|
|
36
|
+
<Popup show={show} onClose={onClose}>
|
|
37
|
+
内容
|
|
38
|
+
</Popup>
|
|
39
|
+
</View>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 弹出位置
|
|
45
|
+
|
|
46
|
+
通过`position`属性设置弹出位置,默认居中弹出,可以设置为`top`、`bottom`、`left`、`right`。
|
|
47
|
+
|
|
48
|
+
```jsx
|
|
49
|
+
import { View } from '@ray-js/ray';
|
|
50
|
+
import { Popup, Cell } from '@ray-js/smart-ui';
|
|
51
|
+
import React from 'react';
|
|
52
|
+
|
|
53
|
+
export default function Demo() {
|
|
54
|
+
const [show, setShow] = React.useState(false);
|
|
55
|
+
const showPopup = () => setShow(true);
|
|
56
|
+
const onClose = () => setShow(false);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View>
|
|
60
|
+
<Cell title="展示弹出层" isLink onClick={showPopup} />
|
|
61
|
+
<Popup show={show} position="top" customStyle={{ height: '20%' }} onClose={onClose} />
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 关闭图标
|
|
68
|
+
|
|
69
|
+
设置`closeable`属性后,会在弹出层的右上角显示关闭图标,并且可以通过`closeIcon`属性自定义图标,使用`closeIconPosition`属性可以自定义图标位置。
|
|
70
|
+
|
|
71
|
+
```jsx
|
|
72
|
+
import { View } from '@ray-js/ray';
|
|
73
|
+
import { Popup, Cell } from '@ray-js/smart-ui';
|
|
74
|
+
import Close from '@tuya-miniapp/icons/dist/svg/Close';
|
|
75
|
+
import React from 'react';
|
|
76
|
+
|
|
77
|
+
export default function Demo() {
|
|
78
|
+
const [show, setShow] = React.useState(false);
|
|
79
|
+
const showPopup = () => setShow(true);
|
|
80
|
+
const onClose = () => setShow(false);
|
|
81
|
+
|
|
82
|
+
const [show1, setShow1] = React.useState(false);
|
|
83
|
+
const showPopup1 = () => setShow1(true);
|
|
84
|
+
const onClose1 = () => setShow1(false);
|
|
85
|
+
|
|
86
|
+
const [show2, setShow2] = React.useState(false);
|
|
87
|
+
const showPopup2 = () => setShow2(true);
|
|
88
|
+
const onClose2 = () => setShow2(false);
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<View>
|
|
93
|
+
<Cell title="显示关闭图标" isLink onClick={showPopup} />
|
|
94
|
+
<Cell title="自定义图标" isLink onClick={showPopup1} />
|
|
95
|
+
<Cell title="图标位置" isLink onClick={showPopup2} />
|
|
96
|
+
<Popup
|
|
97
|
+
show={show}
|
|
98
|
+
closeable
|
|
99
|
+
position="bottom"
|
|
100
|
+
customStyle={{ height: '20%' }}
|
|
101
|
+
onClose={onClose}
|
|
102
|
+
/>
|
|
103
|
+
<Popup
|
|
104
|
+
show={show1}
|
|
105
|
+
closeable
|
|
106
|
+
closeIcon={Close}
|
|
107
|
+
position="bottom"
|
|
108
|
+
customStyle={{ height: '20%' }}
|
|
109
|
+
onClose={onClose1}
|
|
110
|
+
/>
|
|
111
|
+
<Popup
|
|
112
|
+
show={show2}
|
|
113
|
+
closeable
|
|
114
|
+
closeIconPosition="top-left"
|
|
115
|
+
position="bottom"
|
|
116
|
+
customStyle={{ height: '20%' }}
|
|
117
|
+
onClose={onClose2}
|
|
118
|
+
/>
|
|
119
|
+
</View>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 圆角弹窗
|
|
125
|
+
|
|
126
|
+
设置`round`属性后,弹窗会根据弹出位置添加不同的圆角样式。
|
|
127
|
+
|
|
128
|
+
```jsx
|
|
129
|
+
import { View } from '@ray-js/ray';
|
|
130
|
+
import { Popup, Cell } from '@ray-js/smart-ui';
|
|
131
|
+
import React from 'react';
|
|
132
|
+
|
|
133
|
+
export default function Demo() {
|
|
134
|
+
const [show, setShow] = React.useState(false);
|
|
135
|
+
const showPopup = () => setShow(true);
|
|
136
|
+
const onClose = () => setShow(false);
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<View>
|
|
140
|
+
<Cell title="显示圆角弹窗" isLink onClick={showPopup} />
|
|
141
|
+
<Popup show={show} round position="bottom" customStyle={{ height: '20%' }} onClose={onClose} />
|
|
142
|
+
</View>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## API
|
|
148
|
+
|
|
149
|
+
### Props
|
|
150
|
+
|
|
151
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
152
|
+
| --- | --- | --- | --- |
|
|
153
|
+
| closeIcon | 关闭图标名称或图片链接 | _string_ | `cross` |
|
|
154
|
+
| closeIconAriaLabel `v2.13.0` | 关闭按钮的无障碍读屏文案,透传至内部 `smart-icon` 的 `aria-label` | _string_ | - |
|
|
155
|
+
| closeIconPosition | 关闭图标位置,可选值为 `top-left`<br>`bottom-left` `bottom-right` | _string_ | `top-right` |
|
|
156
|
+
| closeOnClickOverlay | 是否在点击遮罩层后关闭 | _boolean_ | `true` |
|
|
157
|
+
| closeable | 是否显示关闭图标 | _boolean_ | `false` |
|
|
158
|
+
| customStyle | 自定义弹出层样式 | _React.CSSProperties_ | - |
|
|
159
|
+
| duration | 动画时长,单位为毫秒 | _number \| object_ | `300` |
|
|
160
|
+
| lockScroll | 是否锁定背景滚动 | _boolean_ | `true` |
|
|
161
|
+
| overlay | 是否显示遮罩层 | _boolean_ | `true` |
|
|
162
|
+
| overlayStyle | 自定义遮罩层样式 | _React.CSSProperties_ | - |
|
|
163
|
+
| position | 弹出位置,可选值为 `top` `bottom` `right` `left` | _string_ | `center` |
|
|
164
|
+
| round | 是否显示圆角 | _boolean_ | `false` |
|
|
165
|
+
| safeAreaInsetBottom | 是否留出底部安全距离,v2.7.1 开始默认关闭 | _boolean_ | `false` |
|
|
166
|
+
| safeAreaInsetBottomMin `v1.1.0` | 是否需要预留出一个最小的底部安全距离,用于在 safeArea 底部为 0 时进行追加,需要在 safeAreaInsetBottom 为 true 时生效 | _number_ | `0` |
|
|
167
|
+
| safeAreaInsetTop | 是否留出顶部安全距离(状态栏高度) | _boolean_ | `false` |
|
|
168
|
+
| safeAreaTabBar | 是否留出底部 tabbar 安全距离(在使用 tabbar 组件 & 小程序自定义 tabbar 时,popup 组件层级无法盖住 tabbar) | _boolean_ | `false` |
|
|
169
|
+
| show | 是否显示弹出层 | _boolean_ | `false` |
|
|
170
|
+
| zIndex | z-index 层级 | _number_ | `100` |
|
|
171
|
+
| nativeDisabled `v2.3.8` | 开启弹框期间是否禁用本地手势; 会在弹框开始进入动画时调用 `ty.nativeDisabled(true)`, 在弹框关闭动画结束时调用 `ty.nativeDisabled(false)` 恢复异层组件的点击能力;由于`ty.nativeDisabled` 是全局生效的,所以多个弹框组件同时打开时注意是否传 `native-disabled`属性和关闭的时机,防止 `native-disabled` 属性失效 | _boolean_ | `false` |
|
|
172
|
+
| fullCoverView `v2.11.1` | 是否使用 cover-view 包裹弹层,用于覆盖原生组件(如 map、video)时使用 | _boolean_ | `false` |
|
|
173
|
+
|
|
174
|
+
### Events
|
|
175
|
+
|
|
176
|
+
| 事件名 | 说明 | 参数 |
|
|
177
|
+
| --- | --- | --- |
|
|
178
|
+
| onAfterEnter | 进入后触发 | - |
|
|
179
|
+
| onAfterLeave | 离开后触发 | - |
|
|
180
|
+
| onBeforeEnter | 进入前触发 | - |
|
|
181
|
+
| onBeforeLeave | 离开前触发 | - |
|
|
182
|
+
| onClickOverlay | 点击遮罩层时触发 | - |
|
|
183
|
+
| onClose | 关闭弹出层时触发 | - |
|
|
184
|
+
| onEnter | 进入中触发 | - |
|
|
185
|
+
| onLeave | 离开中触发 | - |
|
|
186
|
+
|
|
187
|
+
### 外部样式类
|
|
188
|
+
|
|
189
|
+
| 类名 | 说明 |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| customClass | 根节点样式类 |
|
|
192
|
+
|
|
193
|
+
### 样式变量
|
|
194
|
+
|
|
195
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
|
|
196
|
+
|
|
197
|
+
| 名称 | 默认值 | 描述 |
|
|
198
|
+
| --- | --- | --- |
|
|
199
|
+
| --popup-background-color | _var(--app-B4, #ffffff)_ | 弹窗背景颜色 |
|
|
200
|
+
| --popup-round-border-radius | _16px_ | 圆形边框半径 |
|
|
201
|
+
| --popup-close-icon-size | _24px_ | 关闭图标大小 |
|
|
202
|
+
| --popup-close-icon-color | _#969799_ | 关闭图标颜色 |
|
|
203
|
+
| --popup-close-icon-margin | _12px_ | 关闭图标边距 |
|
|
204
|
+
| --popup-close-icon-z-index | _1_ | 关闭图标层级 |
|
|
205
|
+
|
|
206
|
+
## 常见问题
|
|
207
|
+
|
|
208
|
+
### Popup 嵌套涉及布局定位的组件时渲染异常,该如何处理?
|
|
209
|
+
|
|
210
|
+
由于一些组件,如 `Slider` 组件、`Textarea` 组件使用到 `auto-height` 属性时,在 `Popup` 打开时可能尚未完全渲染,因此我们无法获取其 DOM,从而导致定位出现问题。解决方案是在 `Popup` 的 `onAfterEnter` 事件回调之后再开始渲染此类组件。这样,我们可以确保此类组件能够在获取 DOM 时被正常渲染。请参考以下示例:
|
|
211
|
+
|
|
212
|
+
```jsx
|
|
213
|
+
import React from 'react';
|
|
214
|
+
import { Cell, Popup } from '@ray-js/smart-ui';
|
|
215
|
+
import { DemoBlock } from '@/components';
|
|
216
|
+
import { View, Slider } from '@ray-js/ray';
|
|
217
|
+
|
|
218
|
+
function Demo() {
|
|
219
|
+
const [show, setShow] = React.useState(false);
|
|
220
|
+
const [isReady, setIsReady] = React.useState(false);
|
|
221
|
+
const showBasic = () => setShow(true);
|
|
222
|
+
const handleChange = e => setValue(e.detail.value);
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<DemoBlock title="基础用法">
|
|
226
|
+
<Cell title="展示弹出层" isLink onClick={showBasic} />
|
|
227
|
+
<Popup
|
|
228
|
+
show={show}
|
|
229
|
+
position="bottom"
|
|
230
|
+
onClose={hideBasic}
|
|
231
|
+
onAfterEnter={() => setIsReady(true)}
|
|
232
|
+
>
|
|
233
|
+
<View style={{ padding: '32px', position: 'relative' }}>
|
|
234
|
+
{isReady && <Slider value={value} max={100} min={0} onChange={handleChange} />}
|
|
235
|
+
</View>
|
|
236
|
+
</Popup>
|
|
237
|
+
</DemoBlock>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Popup 在IDE上内部元素过高时可以滚动为什么到手机上就不行了?
|
|
243
|
+
|
|
244
|
+
`Popup`内部本身没有`ScrollView`能力,所以本身不具备滚动的功能,可以滚动是因为IDE和真实手机的不一致性导致的,所以希望可以滚动需要使用`ScrollView` 包裹内部元素。
|
|
245
|
+
|
|
246
|
+
```jsx
|
|
247
|
+
import React from 'react';
|
|
248
|
+
import { Popup } from '@ray-js/smart-ui';
|
|
249
|
+
import { DemoBlock } from '@/components';
|
|
250
|
+
import { View, ScrollView } from '@ray-js/ray';
|
|
251
|
+
|
|
252
|
+
function Demo() {
|
|
253
|
+
return (
|
|
254
|
+
<DemoBlock title="基础用法">
|
|
255
|
+
<Popup
|
|
256
|
+
show
|
|
257
|
+
position="bottom"
|
|
258
|
+
>
|
|
259
|
+
<ScrollView scrollY style={{ height: '400px' }}>
|
|
260
|
+
<View style={{ height: '1000px' }}>
|
|
261
|
+
test
|
|
262
|
+
</View>
|
|
263
|
+
</ScrollView>
|
|
264
|
+
</Popup>
|
|
265
|
+
</DemoBlock>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Popup 弹出框在真机上底部有空隙怎么回事?
|
|
271
|
+
|
|
272
|
+
`Popup`内置的底部安全距离是会距离底部有一个外边距,会有一种弹框不通底的效果,如果希望弹框和底部是链接在一起的,安全距离是通过内边距的形式请使用 `BottomSheet` 组件。
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!-- ---
|
|
2
|
+
category: 展示
|
|
3
|
+
--- -->
|
|
4
|
+
|
|
5
|
+
# Progress 进度条
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
进度条
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Progress } from '@ray-js/smart-ui';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 代码演示
|
|
18
|
+
|
|
19
|
+
### 基础用法
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import React from 'react';
|
|
23
|
+
import { Progress } from '@ray-js/smart-ui';
|
|
24
|
+
|
|
25
|
+
export default function Demo() {
|
|
26
|
+
return (
|
|
27
|
+
<Progress
|
|
28
|
+
percentage={70}
|
|
29
|
+
color="linear-gradient(to right, #FA709A 0%, #FEDD44 100%)"
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 圆形进度条
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
<Progress.Circle percent={20} />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API
|
|
42
|
+
|
|
43
|
+
### Progress
|
|
44
|
+
|
|
45
|
+
<!-- prettier-ignore -->
|
|
46
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
47
|
+
| ------------ | -------------------------- | ------------------ | ---------------- |
|
|
48
|
+
| color | 进度条颜色 | _string_ | `#1989fa` |
|
|
49
|
+
| inactive | 是否置灰 | _boolean_ | `false` |
|
|
50
|
+
| percentage | 进度百分比 | _number_ | `0` |
|
|
51
|
+
| pivotColor | 文字背景色 | _string_ | 与进度条颜色一致 |
|
|
52
|
+
| pivotText | 文字显示 | _string_ | 百分比文字 |
|
|
53
|
+
| showPivot | 是否显示进度文字 | _boolean_ | `true` |
|
|
54
|
+
| strokeWidth | 进度条粗细,默认单位为`px` | _string \| number_ | `4px` |
|
|
55
|
+
| textColor | 进度文字颜色 | _string_ | `#fff` |
|
|
56
|
+
| trackColor | 轨道颜色 | _string_ | `#e5e5e5` |
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Progress.Circle
|
|
60
|
+
|
|
61
|
+
<!-- prettier-ignore -->
|
|
62
|
+
| 属性名 | 描述 | 类型 | 默认值 |
|
|
63
|
+
| ------ | ---- | ---- | ------ |
|
|
64
|
+
className|类名|string|undefined|
|
|
65
|
+
children|子元素|ReactNode|undefined|
|
|
66
|
+
style|样式|CSSProperties|undefined|
|
|
67
|
+
size|尺寸|string|'100px'|
|
|
68
|
+
trackWidth|滑槽宽度|string|'10px'|
|
|
69
|
+
trackColor|滑槽颜色|string|'#d3d3d3'|
|
|
70
|
+
fillColor|填充颜色|string|'#007AFF'|
|
|
71
|
+
percent|百分比|number|0|
|
|
72
|
+
maskColor|遮罩颜色|string|'#ffffff'|
|
|
73
|
+
|
|
74
|
+
### 样式变量
|
|
75
|
+
|
|
76
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
|
|
77
|
+
|
|
78
|
+
| 名称 | 默认值 | 描述 |
|
|
79
|
+
| --------------------------------- | --------- | ---- |
|
|
80
|
+
| --progress-height | _4px_ | - |
|
|
81
|
+
| --progress-background-color | _#ebedf0_ | - |
|
|
82
|
+
| --progress-pivot-padding | _0 5px_ | - |
|
|
83
|
+
| --progress-color | _#1989fa_ | - |
|
|
84
|
+
| --progress-pivot-font-size | _10px_ | - |
|
|
85
|
+
| --progress-pivot-line-height | _1.6_ | - |
|
|
86
|
+
| --progress-pivot-background-color | _#1989fa_ | - |
|
|
87
|
+
| --progress-pivot-text-color | _#fff_ | - |
|
|
88
|
+
| --circle-text-color | _#323233_ | 圆环内的文字颜色 |
|