@ray-js/smart-ui 2.13.2-beta-0 → 2.13.2-beta-2

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.
Files changed (103) hide show
  1. package/es/@types/config-provider/index.d.ts +6 -2
  2. package/es/@types/config-provider/theme-vars.d.ts +1 -1
  3. package/es/action-sheet/README.md +613 -0
  4. package/es/battery/README.md +149 -0
  5. package/es/bottom-sheet/README.md +495 -0
  6. package/es/button/README.md +335 -0
  7. package/es/calendar/README.md +513 -0
  8. package/es/cascader/README.md +326 -0
  9. package/es/cell/README.md +317 -0
  10. package/es/checkbox/README.md +481 -0
  11. package/es/circle/README.md +132 -0
  12. package/es/col/README.md +162 -0
  13. package/es/collapse/README.md +127 -0
  14. package/es/config-provider/README.md +150 -0
  15. package/es/count-down/README.md +201 -0
  16. package/es/custom-keyboard/README.md +122 -0
  17. package/es/datetime-picker/README.md +438 -0
  18. package/es/dialog/README.md +451 -0
  19. package/es/divider/README.md +132 -0
  20. package/es/dropdown-menu/README.md +331 -0
  21. package/es/empty/README.md +119 -0
  22. package/es/field/README.md +455 -0
  23. package/es/grid/README.md +273 -0
  24. package/es/icon/README.md +178 -0
  25. package/es/image/README.md +225 -0
  26. package/es/index-bar/README.md +186 -0
  27. package/es/loading/README.md +120 -0
  28. package/es/nav-bar/README.md +410 -0
  29. package/es/notice-bar/README.md +274 -0
  30. package/es/notify/README.md +121 -0
  31. package/es/overlay/README.md +128 -0
  32. package/es/picker/README.md +412 -0
  33. package/es/popover/README.md +338 -0
  34. package/es/popup/README.md +272 -0
  35. package/es/progress/README.md +88 -0
  36. package/es/radio/README.md +423 -0
  37. package/es/rate/README.md +248 -0
  38. package/es/search/README.md +290 -0
  39. package/es/sidebar/README.md +176 -0
  40. package/es/skeleton/README.md +141 -0
  41. package/es/slider/README.md +444 -0
  42. package/es/stepper/README.md +231 -0
  43. package/es/sticky/README.md +91 -0
  44. package/es/swipe-cell/README.md +217 -0
  45. package/es/switch/README.md +316 -0
  46. package/es/tab/README.md +501 -0
  47. package/es/tabbar/README.md +397 -0
  48. package/es/tag/README.md +215 -0
  49. package/es/toast/README.md +293 -0
  50. package/es/transition/README.md +140 -0
  51. package/es/tree-select/README.md +348 -0
  52. package/lib/@types/config-provider/index.d.ts +6 -2
  53. package/lib/@types/config-provider/theme-vars.d.ts +1 -1
  54. package/lib/action-sheet/README.md +613 -0
  55. package/lib/battery/README.md +149 -0
  56. package/lib/bottom-sheet/README.md +495 -0
  57. package/lib/button/README.md +335 -0
  58. package/lib/calendar/README.md +513 -0
  59. package/lib/cascader/README.md +326 -0
  60. package/lib/cell/README.md +317 -0
  61. package/lib/checkbox/README.md +481 -0
  62. package/lib/circle/README.md +132 -0
  63. package/lib/col/README.md +162 -0
  64. package/lib/collapse/README.md +127 -0
  65. package/lib/config-provider/README.md +150 -0
  66. package/lib/count-down/README.md +201 -0
  67. package/lib/custom-keyboard/README.md +122 -0
  68. package/lib/datetime-picker/README.md +438 -0
  69. package/lib/dialog/README.md +451 -0
  70. package/lib/divider/README.md +132 -0
  71. package/lib/dropdown-menu/README.md +331 -0
  72. package/lib/empty/README.md +119 -0
  73. package/lib/field/README.md +455 -0
  74. package/lib/grid/README.md +273 -0
  75. package/lib/icon/README.md +178 -0
  76. package/lib/image/README.md +225 -0
  77. package/lib/index-bar/README.md +186 -0
  78. package/lib/loading/README.md +120 -0
  79. package/lib/nav-bar/README.md +410 -0
  80. package/lib/notice-bar/README.md +274 -0
  81. package/lib/notify/README.md +121 -0
  82. package/lib/overlay/README.md +128 -0
  83. package/lib/picker/README.md +412 -0
  84. package/lib/popover/README.md +338 -0
  85. package/lib/popup/README.md +272 -0
  86. package/lib/progress/README.md +88 -0
  87. package/lib/radio/README.md +423 -0
  88. package/lib/rate/README.md +248 -0
  89. package/lib/search/README.md +290 -0
  90. package/lib/sidebar/README.md +176 -0
  91. package/lib/skeleton/README.md +141 -0
  92. package/lib/slider/README.md +444 -0
  93. package/lib/stepper/README.md +231 -0
  94. package/lib/sticky/README.md +91 -0
  95. package/lib/swipe-cell/README.md +217 -0
  96. package/lib/switch/README.md +316 -0
  97. package/lib/tab/README.md +501 -0
  98. package/lib/tabbar/README.md +397 -0
  99. package/lib/tag/README.md +215 -0
  100. package/lib/toast/README.md +293 -0
  101. package/lib/transition/README.md +140 -0
  102. package/lib/tree-select/README.md +348 -0
  103. package/package.json +3 -3
@@ -0,0 +1,149 @@
1
+ ---
2
+ category: 通用
3
+ assets: Battery
4
+ ---
5
+
6
+ # Battery 电池
7
+
8
+ ### 介绍
9
+
10
+ 电池,可自定义颜色
11
+
12
+ ### 引入
13
+
14
+ ```jsx
15
+ import { Battery } from '@ray-js/smart-ui';
16
+ ```
17
+
18
+ ## 代码演示
19
+
20
+ ### 基础用法
21
+
22
+ ```jsx
23
+ import React from 'react';
24
+ import { View } from '@ray-js/ray';
25
+ import { Battery } from '@ray-js/smart-ui';
26
+
27
+ export default function Demo() {
28
+ return (
29
+ <View>
30
+ <Battery value={80} />
31
+ <Battery value={50} />
32
+ <Battery value={20} />
33
+ <Battery value={0} />
34
+ <Battery inCharging value={80} />
35
+ </View>
36
+ );
37
+ }
38
+ ```
39
+
40
+ ### 水平
41
+
42
+ ```jsx
43
+ import React from 'react';
44
+ import { View } from '@ray-js/ray';
45
+ import { Battery } from '@ray-js/smart-ui';
46
+
47
+ export default function Demo() {
48
+ return (
49
+ <View>
50
+ <Battery type="horizontal" value={100} />
51
+ <Battery type="horizontal" />
52
+ <Battery type="horizontal" value={10} />
53
+ <Battery type="horizontal" value={3} />
54
+ <Battery type="horizontal" value={0} />
55
+ </View>
56
+ );
57
+ }
58
+ ```
59
+
60
+ ### 显示百分比
61
+
62
+ ```jsx
63
+ import React from 'react';
64
+ import { View } from '@ray-js/ray';
65
+ import { Battery } from '@ray-js/smart-ui';
66
+
67
+ export default function Demo() {
68
+ return (
69
+ <View>
70
+ <Battery showText value={80} />
71
+ <Battery showText value={50} />
72
+ <Battery showText value={20} />
73
+ <Battery showText value={0} />
74
+ <Battery showText inCharging value={80} />
75
+ </View>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ### 水平(显示百分比)
81
+
82
+ ```jsx
83
+ import React from 'react';
84
+ import { View } from '@ray-js/ray';
85
+ import { Battery } from '@ray-js/smart-ui';
86
+
87
+ export default function Demo() {
88
+ return (
89
+ <View>
90
+ <Battery showText type="horizontal" value={100} />
91
+ <Battery showText type="horizontal" />
92
+ <Battery showText type="horizontal" value={10} />
93
+ <Battery showText type="horizontal" value={3} />
94
+ <Battery showText type="horizontal" value={0} />
95
+ </View>
96
+ );
97
+ }
98
+ ```
99
+
100
+ ### 自定义大小
101
+
102
+ ```jsx
103
+ import React from 'react';
104
+ import { View } from '@ray-js/ray';
105
+ import { Battery } from '@ray-js/smart-ui';
106
+
107
+ export default function Demo() {
108
+ return (
109
+ <View>
110
+ <Battery type="horizontal" size={28} value={100} />
111
+ <Battery showText type="horizontal" size={28} value={100} />
112
+ <Battery size={28} value={100} />
113
+ <Battery showText size={28} value={100} />
114
+ </View>
115
+ );
116
+ }
117
+ ```
118
+
119
+ ## API
120
+
121
+ ### Props
122
+
123
+ | 参数 | 说明 | 类型 | 默认值 |
124
+ | ---------------- | ------------------------ | -------------------------- | ---------- |
125
+ | backgroundColor | 电量背景色 | _string_ | - |
126
+ | color `v2.6.2` | 电量的颜色(优先级最高) | _string_ | - |
127
+ | highColor | 电量高的颜色 | _string_ | `var(--app-B1-N1, rgba(0, 0, 0, 0.9))` |
128
+ | middleColor | 电量中的颜色 | _string_ | `#ffcb00` |
129
+ | lowColor | 电量低的颜色 | _string_ | `#ee652e` |
130
+ | inCharging `v2.10.0` | 是否处于充电状态 | _boolean_ | `false` |
131
+ | chargingColor `v2.10.0` | 充电颜色 | _string_ | `#2fc755` |
132
+ | showText `v2.10.0` | 是否显示电量文本 | _boolean_ | `false` |
133
+ | size | 尺寸 | _number_ | 10 `v2.0.0` 24 `2.10.0` |
134
+ | type | 电池方向 | `vertical` \| `horizontal` | `vertical` |
135
+ | value | 电量值 | _number_ | 70 |
136
+
137
+ ### 样式变量
138
+
139
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
140
+
141
+ | 名称 | 默认值 | 描述 |
142
+ | ------------------------------------------- | --------------------- | -------------- |
143
+ | --battery-body-base-background `v2.10.0` | _var(--smart-ui-battery-body-base-background, rgba(0, 0, 0, 0.25))_ | 电池主体背景色 |
144
+ | --battery-body-charging-background `v2.10.0` | _#2fc755_ | 充电状态背景色 |
145
+ | --battery-body-high-background `v2.10.0` | _var(--app-B1-N1, rgba(0, 0, 0, 0.9))_ | 高电量背景色 |
146
+ | --battery-body-middle-background `v2.10.0` | _#ffcb00_ | 中电量背景色 |
147
+ | --battery-body-low-background `v2.10.0` | _#ee652e_ | 低电量背景色 |
148
+ | --battery-slash-border-color `v2.10.0` | _var(--smart-ui-battery-slash-border-color, #ffffff)_ | 斜线边框颜色 |
149
+ | --battery-text-color `v2.10.0` | _var(--smart-ui-battery-text-color, rgba(0, 0, 0, 0.6))_ | 电量文本颜色 |
@@ -0,0 +1,495 @@
1
+ ---
2
+ category: 反馈
3
+ ---
4
+
5
+ # BottomSheet 底部弹窗
6
+
7
+ ### 介绍
8
+
9
+ 通底的底部弹窗面板;与 `Popup` 和 `ActionSheet` 的区别在于,安全区通过内边距覆盖,适用于需要和底部无缝粘合的场景,v2.0.0 开始加入。
10
+
11
+ ### 引入
12
+
13
+ ```jsx
14
+ import { BottomSheet } from '@ray-js/smart-ui';
15
+ ```
16
+
17
+ ## 代码演示
18
+
19
+ ### 基础用法
20
+
21
+ 传入一个 `title` 文本,将会往上弹出现一个带标题的底部弹窗。
22
+
23
+ ```jsx
24
+ import React from 'react';
25
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
26
+ import { View } from '@ray-js/ray';
27
+
28
+ export default function Demo() {
29
+ const [show, setShow] = React.useState(false);
30
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
31
+
32
+ return (
33
+ <View>
34
+ <Button type="primary" onClick={toggleBottomSheet}>
35
+ 弹出菜单
36
+ </Button>
37
+ <BottomSheet title="Title" show={show} onClose={toggleBottomSheet} />
38
+ </View>
39
+ );
40
+ }
41
+ ```
42
+
43
+ ### 自定义
44
+
45
+ 通过传入子元素节点来自定义面板
46
+
47
+ ```jsx
48
+ import React from 'react';
49
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
50
+ import { View } from '@ray-js/ray';
51
+
52
+ export default function Demo() {
53
+ const [show, setShow] = React.useState(false);
54
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
55
+
56
+ return (
57
+ <View>
58
+ <Button type="primary" onClick={toggleBottomSheet}>
59
+ 弹出菜单
60
+ </Button>
61
+ <BottomSheet show={show} title="Title" onClose={toggleBottomSheet}>
62
+ <View className="content" />
63
+ <View className="footer">
64
+ <Button type="info" block>完成</Button>
65
+ </View>
66
+ </BottomSheet>
67
+ </View>
68
+ );
69
+ }
70
+ ```
71
+
72
+ ```css
73
+ .content {
74
+ display: flex;
75
+ justify-content: center;
76
+ font-size: 20px;
77
+ background: var(--app-B1, #f6f7fb);
78
+ color: var(--app-B4-N1, #3d3d3d);
79
+ }
80
+
81
+ .footer {
82
+ margin: 16px 0;
83
+ }
84
+ ```
85
+
86
+ ### 最大高度限制
87
+
88
+ 底部弹窗默认最大高度不允许超过屏幕的 50%,但可以通过 `--bottom-sheet-max-height` 自定义最大高度,在 v2.5.0 版本及之后内容触发最大高度组件内部会自动滚动!
89
+
90
+ ```jsx
91
+ import React from 'react';
92
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
93
+ import { View } from '@ray-js/ray';
94
+
95
+ export default function Demo() {
96
+ const [show, setShow] = React.useState(false);
97
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
98
+
99
+ return (
100
+ <View>
101
+ <Button type="primary" onClick={toggleBottomSheet}>
102
+ 弹出菜单
103
+ </Button>
104
+ <BottomSheet show={show} title="Title" onClose={toggleBottomSheet}>
105
+ <View style={{ backgroundColor: 'red', height: '100px' }} />
106
+ <View style={{ backgroundColor: 'blue', height: '100px' }} />
107
+ <View style={{ backgroundColor: 'black', height: '100px' }} />
108
+ <View style={{ backgroundColor: 'yellow', height: '100px' }} />
109
+ <View style={{ backgroundColor: 'pink', height: '100px' }} />
110
+ </BottomSheet>
111
+ </View>
112
+ );
113
+ }
114
+ ```
115
+
116
+ ### 固定高度 `v2.5.0`
117
+
118
+ `contentHeight` 可以设置内容区域的高度;当设置了 `contentHeight` 后, 组件的最大高度就会失效,可以自定义在内部书写内容。
119
+
120
+ ```jsx
121
+ import React from 'react';
122
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
123
+ import { View, ScrollView } from '@ray-js/ray';
124
+
125
+ export default function Demo() {
126
+ const [show, setShow] = React.useState(false);
127
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
128
+
129
+ return (
130
+ <View>
131
+ <Button type="primary" onClick={toggleBottomSheet}>
132
+ 弹出菜单
133
+ </Button>
134
+ <BottomSheet
135
+ show={show}
136
+ title="Title"
137
+ content-height="500px"
138
+ onClose={toggleBottomSheet}
139
+ >
140
+ <ScrollView scroll-y style={{ height: '300px' }}>
141
+ <View style={{ backgroundColor: 'red', height: '100px' }} />
142
+ <View style={{ backgroundColor: 'blue', height: '100px' }} />
143
+ <View style={{ backgroundColor: 'black', height: '100px' }} />
144
+ <View style={{ backgroundColor: 'yellow', height: '100px' }} />
145
+ <View style={{ backgroundColor: 'pink', height: '100px' }} />
146
+ </ScrollView>
147
+ <View style={{ backgroundColor: 'white', height: '100px' }} />
148
+ <View style={{ backgroundColor: 'orange', height: '100px' }} />
149
+ </BottomSheet>
150
+ </View>
151
+ );
152
+ }
153
+ ```
154
+
155
+
156
+ ### 使用插槽插入标题 `v2.6.1`
157
+
158
+ ```jsx
159
+ import React from 'react';
160
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
161
+ import { View } from '@ray-js/ray';
162
+
163
+ export default function Demo() {
164
+ const [show, setShow] = React.useState(false);
165
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
166
+
167
+ return (
168
+ <View>
169
+ <Button type="primary" onClick={toggleBottomSheet}>
170
+ 弹出菜单
171
+ </Button>
172
+ <BottomSheet
173
+ show={show}
174
+ slot={{
175
+ title: <View>Slot Title</View>
176
+ }}
177
+ onClose={toggleBottomSheet}
178
+ >
179
+ <View style={{ backgroundColor: 'orange', height: '100px' }} />
180
+ </BottomSheet>
181
+ </View>
182
+ );
183
+ }
184
+ ```
185
+
186
+ ### 可拖拽 `v2.7.2`
187
+
188
+ 通过设置 `draggable` 属性,可以让底部弹窗支持拖拽调整高度。
189
+
190
+ ```jsx
191
+ import React, { useEffect, useState } from 'react';
192
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
193
+ import { View, getSystemInfoSync } from '@ray-js/ray';
194
+
195
+ export default function Demo() {
196
+ const [show, setShow] = React.useState(false);
197
+ const [closeDragHeight, setCloseDragHeight] = useState(0);
198
+
199
+ useEffect(() => {
200
+ const systemInfo = getSystemInfoSync();
201
+ setCloseDragHeight(systemInfo.windowHeight * 0.4);
202
+ }, []);
203
+
204
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
205
+
206
+ return (
207
+ <View>
208
+ <Button type="primary" onClick={toggleBottomSheet}>
209
+ 弹出菜单
210
+ </Button>
211
+ <BottomSheet
212
+ show={show}
213
+ draggable
214
+ closeDragHeight={closeDragHeight}
215
+ midDragHeight={300}
216
+ onClose={toggleBottomSheet}
217
+ >
218
+ <View style={{ backgroundColor: 'red', height: '300px' }} />
219
+ </BottomSheet>
220
+ </View>
221
+ );
222
+ }
223
+ ```
224
+
225
+ ### 设置拖拽范围 `v2.7.2`
226
+
227
+ 通过设置 `minDragHeight`、`maxDragHeight`、`midDragHeight` 和 `closeDragHeight` 来控制拖拽的范围。
228
+
229
+ ```jsx
230
+ import React from 'react';
231
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
232
+ import { View } from '@ray-js/ray';
233
+
234
+ export default function Demo() {
235
+ const [show, setShow] = React.useState(false);
236
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
237
+
238
+ return (
239
+ <View>
240
+ <Button type="primary" onClick={toggleBottomSheet}>
241
+ 弹出菜单
242
+ </Button>
243
+ <BottomSheet
244
+ show={show}
245
+ draggable
246
+ midDragHeight={300}
247
+ minDragHeight={300}
248
+ maxDragHeight={300}
249
+ closeDragHeight={300}
250
+ onClose={toggleBottomSheet}
251
+ >
252
+ <View style={{ backgroundColor: 'red', height: '300px' }} />
253
+ </BottomSheet>
254
+ </View>
255
+ );
256
+ }
257
+ ```
258
+
259
+ ### 带标题的拖拽 `v2.7.2`
260
+
261
+ 拖拽功能可以与标题一起使用。
262
+
263
+ ```jsx
264
+ import React from 'react';
265
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
266
+ import { View } from '@ray-js/ray';
267
+
268
+ export default function Demo() {
269
+ const [show, setShow] = React.useState(false);
270
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
271
+
272
+ return (
273
+ <View>
274
+ <Button type="primary" onClick={toggleBottomSheet}>
275
+ 弹出菜单
276
+ </Button>
277
+ <BottomSheet
278
+ title="带标题的拖拽"
279
+ show={show}
280
+ draggable
281
+ midDragHeight={300}
282
+ minDragHeight={300}
283
+ maxDragHeight={300}
284
+ closeDragHeight={300}
285
+ onClose={toggleBottomSheet}
286
+ >
287
+ <View style={{ backgroundColor: 'red', height: '300px' }} />
288
+ </BottomSheet>
289
+ </View>
290
+ );
291
+ }
292
+ ```
293
+
294
+ ### 监听拖拽位置 `v2.7.2`
295
+
296
+ 通过 `onDragPosition` 事件可以监听拖拽结束时的面板位置。
297
+
298
+ ```jsx
299
+ import React, { useState } from 'react';
300
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
301
+ import { View, Text } from '@ray-js/ray';
302
+
303
+ export default function Demo() {
304
+ const [show, setShow] = React.useState(false);
305
+ const [dragPosition, setDragPosition] = useState<'max' | 'mid' | 'min' | ''>('');
306
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
307
+
308
+ const onDragPosition = React.useCallback((e: any) => {
309
+ const position = e.detail; // 'max' | 'mid' | 'min'
310
+ setDragPosition(position);
311
+ }, []);
312
+
313
+ const getDragPositionText = () => {
314
+ const positionMap = {
315
+ max: '最大',
316
+ mid: '中间',
317
+ min: '最小',
318
+ };
319
+ return positionMap[dragPosition as keyof typeof positionMap] || dragPosition;
320
+ };
321
+
322
+ return (
323
+ <View>
324
+ <Button type="primary" onClick={toggleBottomSheet}>
325
+ 弹出菜单
326
+ </Button>
327
+ <BottomSheet
328
+ show={show}
329
+ draggable
330
+ midDragHeight={300}
331
+ minDragHeight={100}
332
+ maxDragHeight={600}
333
+ onDragPosition={onDragPosition}
334
+ onClose={toggleBottomSheet}
335
+ >
336
+ {dragPosition && (
337
+ <View
338
+ style={{
339
+ marginTop: '16px',
340
+ padding: '12px',
341
+ backgroundColor: '#f0f0f0',
342
+ borderRadius: '4px',
343
+ }}
344
+ >
345
+ <Text>当前面板位置: {getDragPositionText()}</Text>
346
+ </View>
347
+ )}
348
+ </BottomSheet>
349
+ </View>
350
+ );
351
+ }
352
+ ```
353
+
354
+ ### 锁定最大拖拽高度 `v2.9.0`
355
+
356
+ 通过设置 `lockMaxDrag` 属性为 `true`,可以锁定最大拖拽高度,拖拽过程中面板高度不会超过 `maxDragHeight`。
357
+
358
+ ```jsx
359
+ import React from 'react';
360
+ import { BottomSheet, Button } from '@ray-js/smart-ui';
361
+ import { View } from '@ray-js/ray';
362
+
363
+ export default function Demo() {
364
+ const [show, setShow] = React.useState(false);
365
+ const toggleBottomSheet = React.useCallback(() => setShow(!show), [show]);
366
+
367
+ return (
368
+ <View>
369
+ <Button type="primary" onClick={toggleBottomSheet}>
370
+ 弹出菜单
371
+ </Button>
372
+ <BottomSheet
373
+ show={show}
374
+ draggable
375
+ lockMaxDrag
376
+ midDragHeight={300}
377
+ minDragHeight={100}
378
+ maxDragHeight={500}
379
+ closeDragHeight={200}
380
+ onClose={toggleBottomSheet}
381
+ >
382
+ <View style={{ backgroundColor: 'red', height: '300px' }} />
383
+ </BottomSheet>
384
+ </View>
385
+ );
386
+ }
387
+ ```
388
+
389
+ ## API
390
+
391
+ ### Props
392
+
393
+ | 参数 | 说明 | 类型 | 默认值 |
394
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | --------------------------------------- |
395
+ | closeIconAriaLabel `v2.13.0` | 标题关闭按钮的无障碍读屏文案,透传至内部 `smart-icon` 的 `aria-label`;不传时关闭图标仍为 `button` 角色(由 `aria-role` 声明),便于业务按需传入多语言 | _string_ | - |
396
+ | closeDragHeight `v2.7.2` | 拖拽关闭时的临界高度,低于该高度将自动关闭 | _number_ | `windowHeight * 0.4` |
397
+ | closeOnClickOverlay | 点击遮罩是否关闭菜单 | _boolean_ | `true` |
398
+ | contentHeight `v2.5.0` | 内容区域高度,当设置此值时,组件的 max-height 将会失效。当设置 draggable 时此值无效。 | _number \| string_ | `false` |
399
+ | draggable `v2.7.2` | 是否支持拖拽,可用于实现拖拽调整面板高度 | _boolean_ | `false` |
400
+ | iconColor | 标题中关闭按钮的颜色 | _string_ | `--app-B4-N3` \|\| `rgba(0, 0, 0, 0.5)` |
401
+ | iconSize | 标题中关闭按钮的大小 | _string \| number_ | `24` |
402
+ | lockMaxDrag `v2.9.0` | 是否锁定最大拖拽高度,设置为 `true` 时,拖拽过程中面板高度不会超过 `max-drag-height` | _boolean_ | `false` |
403
+ | lockScroll `v2.9.0` | 是否锁定背景滚动 | _boolean_ | `true` |
404
+ | maxDragHeight `v2.7.2` | 拖拽时允许的最大高度 | _number_ | `windowHeight * 0.5` |
405
+ | maxHeight `v2.6.0` | 整个组件的最大高度 | _number \| string_ | - |
406
+ | midDragHeight `v2.7.2` | 拖拽时中间态高度 | _number_ | `windowHeight * 0.1` |
407
+ | minDragHeight `v2.7.2` | 拖拽时允许的最小高度 | _number_ | `windowHeight * 0.8` |
408
+ | nativeDisabled `v2.5.0` | 开启弹框期间是否禁用本地手势; 会在弹框开始进入动画时调用 `ty.nativeDisabled(true)`, 在弹框关闭动画结束时调用 `ty.nativeDisabled(false)` 恢复异层组件的点击能力;由于`ty.nativeDisabled` 是全局生效的,所以多个弹框组件同时打开时注意是否传 `native-disabled`属性和关闭的时机,防止 `native-disabled` 属性失效 | _boolean_ | `false` |
409
+ | overlay | 是否显示遮罩层 | _boolean_ | `true` |
410
+ | round | 是否显示圆角 | _boolean_ | `true` |
411
+ | show | 是否显示底部弹窗 | _boolean_ | `false` |
412
+ | showClose `v2.6.1` | 是否展示关闭图标。当设置 draggable 时此值无效。 | _boolean_ | `true` |
413
+ | title | 标题 | _string_ | - |
414
+ | zIndex | z-index 层级 | _number_ | `100` |
415
+ | fullCoverView `v2.11.1` | 是否使用 cover-view 包裹弹层,用于覆盖原生组件(如 map、video)时使用 | _boolean_ | `false` |
416
+
417
+ ### Events
418
+
419
+ | 事件名 | 说明 | 参数 |
420
+ | --------------------------- | -------------------------------- | --------------------------------------------- |
421
+ | onAfterEnter | 遮罩进入后触发 | - |
422
+ | onAfterLeave | 遮罩离开后触发 | - |
423
+ | onBeforeEnter | 遮罩进入前触发 | - |
424
+ | onBeforeLeave | 遮罩离开前触发 | - |
425
+ | onClickOverlay | 点击遮罩层时触发 | - |
426
+ | onClose | 点击关闭按钮时触发 | - |
427
+ | onDragPosition `v2.7.2` | 拖拽结束时触发,返回当前面板位置 | _event.detail_: `'max'` \| `'mid'` \| `'min'` |
428
+ | onEnter | 遮罩进入中触发 | - |
429
+ | onLeave | 遮罩离开中触发 | - |
430
+
431
+ ### Slot
432
+
433
+ | 名称 | 说明 |
434
+ | -------------- | -------- |
435
+ | - | 内容 |
436
+ | title `v2.6.1` | 标题插槽 |
437
+
438
+ ### 外部样式类
439
+
440
+ | 类名 | 说明 |
441
+ | ------------ | ------------ |
442
+ | customClass | 根节点样式类 |
443
+
444
+ ### 样式变量
445
+
446
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
447
+
448
+ | 名称 | 默认值 | 描述 |
449
+ | -------------------------------------------------- | ------------------------------------ | -------------------------- |
450
+ | --bottom-sheet-dragger-node-background `v2.7.2` | _rgba(0, 0, 0, 0.3)_ | 拖拽手柄的背景色 |
451
+ | --bottom-sheet-dragger-node-border-radius `v2.7.2` | _2px_ | 拖拽手柄的圆角 |
452
+ | --bottom-sheet-dragger-node-height `v2.7.2` | _4px_ | 拖拽手柄的高度 |
453
+ | --bottom-sheet-dragger-node-width `v2.7.2` | _30px_ | 拖拽手柄的宽度 |
454
+ | --bottom-sheet-dragger-padding `v2.7.2` | _8px 0_ | 拖拽手柄区域的内边距 |
455
+ | --bottom-sheet-font-color | _var(--app-B4-N1, rgba(0, 0, 0, 1))_ | 底部弹窗的文字颜色 |
456
+ | --bottom-sheet-header-color | _var(--app-B4-N1, rgba(0, 0, 0, 1))_ | 底部弹窗的头部文字颜色 |
457
+ | --bottom-sheet-header-font-size | _17px_ | 底部弹窗的头部文字大小 |
458
+ | --bottom-sheet-header-font-weight | _600_ | 底部弹窗的头部字重 |
459
+ | --bottom-sheet-header-height | _56px_ | 底部弹窗的头部高度 |
460
+ | --bottom-sheet-header-padding `v2.5.0` | _0 16px_ | 底部弹窗头部的内边距 |
461
+ | --bottom-sheet-icon-margin | _16px 16px 0 0_ | 底部弹窗的关闭 icon 外边距 |
462
+ | --bottom-sheet-max-height | _50%_ | 底部弹窗的最大高度 |
463
+ | --bottom-sheet-min-height | _auto_ | 底部弹窗的最小高度 |
464
+ | --bottom-sheet-padding | _0 16px_ | 底部弹窗内容区域的内边距 |
465
+ | --bottom-sheet-width | _100%_ | 底部弹窗的宽度 |
466
+ | --popup-background-color | _var(--app-B4, #ffffff)_ | 弹框背景色 |
467
+
468
+ ## 常见问题
469
+
470
+ ### 组件内容高度到一定程度无法增加
471
+
472
+ BottomSheet 组件内部有 max-height 限制组件的最大高度需要覆盖组件的样式才可以实现例如:
473
+ ```css
474
+ .my-bottom-sheet {
475
+ --bottom-sheet-max-height: 100%;
476
+ }
477
+ ```
478
+ 在 v2.5.0 及之后版本可以设置 `contentHeight` 设置内容区域的高度,此时 max-height 将会失效
479
+
480
+ ### 组件内容过高后在真机上无法滚动问题
481
+
482
+ 1. 可以升级到最新的 v2.5.0 修复了此问题, 过高后会自动滚动
483
+ 2. 或者在内容区域套一个 ScrollView 组件,下面为 max-height 为 50% 为例,其中 `env(safe-area-inset-bottom)` 为底部安全距离
484
+
485
+ ```jsx
486
+ <BottomSheet show>
487
+ <ScrollView style={{ height: 'calc(50vh - 56px - env(safe-area-inset-bottom))'}} scrollY>
488
+ <View style={{ height: 2000 }}><View>
489
+ <ScrollView>
490
+ </BottomSheet>
491
+ ```
492
+
493
+ ### 组件内容中绝对定位在底部的内容在真机上会被遮挡
494
+
495
+ 升级到最新的 v2.5.0 后,可以参考 固定高度 例子,将需要绝对定位的内容放置在底部,将其余内容用 ScrollView 包裹