@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,613 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 反馈
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# ActionSheet 动作面板
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
底部弹起的模态面板,包含与当前情境相关的多个选项。
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { ActionSheet } from '@ray-js/smart-ui';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 代码演示
|
|
18
|
+
|
|
19
|
+
### 基础用法
|
|
20
|
+
|
|
21
|
+
需要传入一个`actions`的数组,数组的每一项是一个对象,对象属性见文档下方表格。
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { ActionSheet, 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 [actions, setActions] = React.useState([
|
|
31
|
+
{ id: 0, name: 'Action', checked: true },
|
|
32
|
+
{ id: 1, name: 'Action', checked: false },
|
|
33
|
+
{ id: 2, name: 'Action', checked: false },
|
|
34
|
+
{ id: 3, name: 'Action', checked: false },
|
|
35
|
+
{ id: 4, name: 'Action', checked: false },
|
|
36
|
+
{ id: 5, name: 'Action', checked: false },
|
|
37
|
+
{ id: 6, name: 'Action', checked: false },
|
|
38
|
+
{ id: 7, name: 'Action', checked: false },
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const onCancel = () => setShow(false);
|
|
42
|
+
const onClose = () => console.log('close');
|
|
43
|
+
const onSelect = evt => {
|
|
44
|
+
const { id } = evt.detail;
|
|
45
|
+
const newActions = actions.map(item => {
|
|
46
|
+
if (item.id === id) return { ...item, checked: true };
|
|
47
|
+
return { ...item, checked: false };
|
|
48
|
+
});
|
|
49
|
+
setActions(newActions);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View>
|
|
54
|
+
<ActionSheet
|
|
55
|
+
show={show}
|
|
56
|
+
title="Title"
|
|
57
|
+
cancelText="取消"
|
|
58
|
+
actions={actions}
|
|
59
|
+
onClose={onClose}
|
|
60
|
+
onSelect={onSelect}
|
|
61
|
+
onCancel={onCancel}
|
|
62
|
+
/>
|
|
63
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
64
|
+
</View>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 无选中列表
|
|
70
|
+
|
|
71
|
+
设置`actions[idx].checked`属性为`false`后,可以展示无选中状态的列表。
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
import React from 'react';
|
|
75
|
+
import { ActionSheet, Button } from '@ray-js/smart-ui';
|
|
76
|
+
import { View } from '@ray-js/ray';
|
|
77
|
+
|
|
78
|
+
export default function Demo() {
|
|
79
|
+
const actions = [{ name: 'Action' }, { name: 'Action' }, { name: 'Action', subname: '描述信息' }];
|
|
80
|
+
const [show, setShow] = React.useState(false);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View>
|
|
84
|
+
<ActionSheet
|
|
85
|
+
show={show}
|
|
86
|
+
actions={actions}
|
|
87
|
+
title="Title"
|
|
88
|
+
cancelText="取消"
|
|
89
|
+
onCancel={() => setShow(false)}
|
|
90
|
+
/>
|
|
91
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
92
|
+
</View>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### 选项状态
|
|
99
|
+
|
|
100
|
+
选项可以设置为加载状态或禁用状态。
|
|
101
|
+
|
|
102
|
+
```jsx
|
|
103
|
+
import React from 'react';
|
|
104
|
+
import { ActionSheet, Button } from '@ray-js/smart-ui';
|
|
105
|
+
import { View } from '@ray-js/ray';
|
|
106
|
+
|
|
107
|
+
export default function Demo() {
|
|
108
|
+
const actions = [
|
|
109
|
+
{ name: '着色选项', color: '#ee0a24' },
|
|
110
|
+
{ loading: true },
|
|
111
|
+
{ name: '禁用选项', disabled: true },
|
|
112
|
+
];
|
|
113
|
+
const [show, setShow] = React.useState(false);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<View>
|
|
117
|
+
<ActionSheet
|
|
118
|
+
show={show}
|
|
119
|
+
actions={actions}
|
|
120
|
+
cancelText="取消"
|
|
121
|
+
confirmText="确认"
|
|
122
|
+
onCancel={() => setShow(false)}
|
|
123
|
+
onClose={() => setShow(false)}
|
|
124
|
+
onConfirm={() => setShow(false)}
|
|
125
|
+
/>
|
|
126
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
127
|
+
</View>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
### 展示确认按钮
|
|
134
|
+
|
|
135
|
+
设置`cancelText`、`confirmText`属性后,会在底部展示取消或确认按钮,点击后关闭当前菜单。
|
|
136
|
+
|
|
137
|
+
```jsx
|
|
138
|
+
import React from 'react';
|
|
139
|
+
import { ActionSheet, Button } from '@ray-js/smart-ui';
|
|
140
|
+
import { View } from '@ray-js/ray';
|
|
141
|
+
|
|
142
|
+
export default function Demo() {
|
|
143
|
+
const [show, setShow] = React.useState(false);
|
|
144
|
+
const actions = [{ name: 'Action' }, { name: 'Action' }, { name: 'Action' }];
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<View>
|
|
148
|
+
<ActionSheet
|
|
149
|
+
show={show}
|
|
150
|
+
actions={actions}
|
|
151
|
+
cancelText="取消"
|
|
152
|
+
confirmText="确认"
|
|
153
|
+
onCancel={() => setShow(false)}
|
|
154
|
+
onClose={() => setShow(false)}
|
|
155
|
+
onConfirm={() => setShow(false)}
|
|
156
|
+
/>
|
|
157
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 展示描述信息
|
|
164
|
+
|
|
165
|
+
设置`description`属性后,会在选项上方显示描述信息。
|
|
166
|
+
|
|
167
|
+
```jsx
|
|
168
|
+
import React from 'react';
|
|
169
|
+
import { ActionSheet, Button } from '@ray-js/smart-ui';
|
|
170
|
+
import { View } from '@ray-js/ray';
|
|
171
|
+
|
|
172
|
+
export default function Demo() {
|
|
173
|
+
const [show, setShow] = React.useState(false);
|
|
174
|
+
const actions = [{ name: 'Action' }, { name: 'Action' }, { name: 'Action' }];
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<View>
|
|
178
|
+
<ActionSheet
|
|
179
|
+
show={show}
|
|
180
|
+
actions={actions}
|
|
181
|
+
description="这是一段描述信息"
|
|
182
|
+
onCancel={() => setShow(false)}
|
|
183
|
+
onClose={() => setShow(false)}
|
|
184
|
+
onConfirm={() => setShow(false)}
|
|
185
|
+
/>
|
|
186
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
187
|
+
</View>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 自定义
|
|
193
|
+
|
|
194
|
+
通过设置`title`属性展示标题栏,同时可以使用插槽自定义菜单内容。
|
|
195
|
+
|
|
196
|
+
```jsx
|
|
197
|
+
import React from 'react';
|
|
198
|
+
import { ActionSheet, Button } from '@ray-js/smart-ui';
|
|
199
|
+
import { View } from '@ray-js/ray';
|
|
200
|
+
|
|
201
|
+
export default function Demo() {
|
|
202
|
+
const [show, setShow] = React.useState(false);
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<View>
|
|
206
|
+
<ActionSheet
|
|
207
|
+
show={show}
|
|
208
|
+
title="标题"
|
|
209
|
+
onCancel={() => setShow(false)}
|
|
210
|
+
onClose={() => setShow(false)}
|
|
211
|
+
onConfirm={() => setShow(false)}
|
|
212
|
+
>
|
|
213
|
+
<View>内容</View>
|
|
214
|
+
</ActionSheet>
|
|
215
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
216
|
+
</View>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 自定义数值
|
|
222
|
+
|
|
223
|
+
内部嵌套 Slider 组件使用,注意 Slider 组件的渲染时机要在弹框完全进入后,否则会影响其定位。
|
|
224
|
+
|
|
225
|
+
```jsx
|
|
226
|
+
import React from 'react';
|
|
227
|
+
import { ActionSheet, Button, Slider } from '@ray-js/smart-ui';
|
|
228
|
+
import { View, Text } from '@ray-js/ray';
|
|
229
|
+
import { useDebounce } from 'ahooks';
|
|
230
|
+
import styles from './index.module.less';
|
|
231
|
+
|
|
232
|
+
export default function Demo() {
|
|
233
|
+
const [show, setShow] = React.useState(false);
|
|
234
|
+
const [ready, setReady] = React.useState(false);
|
|
235
|
+
const [currentNumber, setCurrentNumber] = React.useState(100);
|
|
236
|
+
|
|
237
|
+
const currentNumberForSlider = useDebounce(currentNumber, { wait: 500 });
|
|
238
|
+
|
|
239
|
+
const onChange = React.useCallback(value => {
|
|
240
|
+
setCurrentNumber(value);
|
|
241
|
+
}, []);
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<View>
|
|
245
|
+
<ActionSheet
|
|
246
|
+
show={show}
|
|
247
|
+
title="标题"
|
|
248
|
+
onCancel={() => setShow(false)}
|
|
249
|
+
onClose={() => setShow(false)}
|
|
250
|
+
onConfirm={() => setShow(false)}
|
|
251
|
+
onAfterEnter={() => setReady(true)}
|
|
252
|
+
onAfterLeave={() => setReady(false)}
|
|
253
|
+
>
|
|
254
|
+
<View className={styles['content-number']}>
|
|
255
|
+
<View className={styles['demo-header']}>
|
|
256
|
+
<Text className={styles['demo-text']}>{`${currentNumber}%`}</Text>
|
|
257
|
+
</View>
|
|
258
|
+
<View className={styles['demo-slider']}>
|
|
259
|
+
{ready && (
|
|
260
|
+
<Slider
|
|
261
|
+
minTrackRadius="8px"
|
|
262
|
+
minTrackHeight="45px"
|
|
263
|
+
maxTrackRadius="8px"
|
|
264
|
+
maxTrackHeight="45px"
|
|
265
|
+
value={currentNumberForSlider}
|
|
266
|
+
onChange={onChange}
|
|
267
|
+
thumbWidth={15}
|
|
268
|
+
thumbHeight={50}
|
|
269
|
+
thumbRadius={2}
|
|
270
|
+
thumbStyle={{
|
|
271
|
+
background: '#BBC5D4',
|
|
272
|
+
border: '2px solid #FFFFFF',
|
|
273
|
+
boxShadow: '0px 0px 2px 0px rgba(0, 0, 0, 0.5)',
|
|
274
|
+
}}
|
|
275
|
+
/>
|
|
276
|
+
)}
|
|
277
|
+
</View>
|
|
278
|
+
</View>
|
|
279
|
+
</ActionSheet>
|
|
280
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
281
|
+
</View>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
index.module.less
|
|
287
|
+
|
|
288
|
+
```css
|
|
289
|
+
.content-number {
|
|
290
|
+
padding: 10px 39px;
|
|
291
|
+
background: var(--app-B1, #f6f7fb);
|
|
292
|
+
text-align: center;
|
|
293
|
+
color: var(--app-B4-N1, #000);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.demo-header {
|
|
297
|
+
padding: 10px 39px;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.demo-text {
|
|
301
|
+
font-size: 40px;
|
|
302
|
+
font-weight: 600;
|
|
303
|
+
line-height: 46px;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.demo-slider {
|
|
307
|
+
margin: 23px 0;
|
|
308
|
+
min-height: 45px;
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
### 自定义滚动
|
|
314
|
+
|
|
315
|
+
```jsx
|
|
316
|
+
import React from 'react';
|
|
317
|
+
import { ActionSheet, Button, DateTimePicker } from '@ray-js/smart-ui';
|
|
318
|
+
import { View } from '@ray-js/ray';
|
|
319
|
+
|
|
320
|
+
export default function Demo() {
|
|
321
|
+
const [show, setShow] = React.useState(false);
|
|
322
|
+
const [currentDate, setCurrentDate] = React.useState(new Date(2018, 0, 1));
|
|
323
|
+
|
|
324
|
+
const onInput = React.useCallback(event => {
|
|
325
|
+
const { detail } = event;
|
|
326
|
+
const date = new Date(detail);
|
|
327
|
+
setCurrentDate(date);
|
|
328
|
+
}, []);
|
|
329
|
+
|
|
330
|
+
return (
|
|
331
|
+
<View>
|
|
332
|
+
<ActionSheet
|
|
333
|
+
show={show}
|
|
334
|
+
title="标题"
|
|
335
|
+
onCancel={() => setShow(false)}
|
|
336
|
+
onClose={() => setShow(false)}
|
|
337
|
+
onConfirm={() => setShow(false)}
|
|
338
|
+
>
|
|
339
|
+
<DateTimePicker
|
|
340
|
+
showToolbar={false}
|
|
341
|
+
type="date"
|
|
342
|
+
minDate={new Date(2018, 0, 1).getTime()}
|
|
343
|
+
value={currentDate}
|
|
344
|
+
onInput={onInput}
|
|
345
|
+
/>
|
|
346
|
+
</ActionSheet>
|
|
347
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
348
|
+
</View>
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
### 自定义双列选择器 `v2.6.0`
|
|
356
|
+
|
|
357
|
+
当 `useTitleSlot` 为 `true` 时,可以使用插槽自定义标题内容,支持复杂的双选择器场景。
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
```jsx
|
|
361
|
+
import React from 'react';
|
|
362
|
+
import { ActionSheet, Button, DateTimePicker, Picker, SmartEventHandler, SmartPickerBaseEventDetail } from '@ray-js/smart-ui';
|
|
363
|
+
import { View } from '@ray-js/ray';
|
|
364
|
+
import styles from './index.module.less';
|
|
365
|
+
|
|
366
|
+
export default function Demo() {
|
|
367
|
+
const [show, setShow] = React.useState(false);
|
|
368
|
+
const [current12Date, setCurrent12Date] = useState('12:00');
|
|
369
|
+
const [tempColumnIdx, setTempColumnIdx] = useState(3);
|
|
370
|
+
|
|
371
|
+
const onCurrent12DateInput: SmartEventHandler<string> = event => {
|
|
372
|
+
setCurrent12Date(event.detail);
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
const onTempColumnChange: SmartEventHandler<SmartPickerBaseEventDetail> = event => {
|
|
376
|
+
const { index } = event.detail;
|
|
377
|
+
setTempColumnIdx(index as number);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
return (
|
|
381
|
+
<View>
|
|
382
|
+
<ActionSheet
|
|
383
|
+
show={show}
|
|
384
|
+
cancelText="Cancel"
|
|
385
|
+
confirmText="Confirm"
|
|
386
|
+
slot={{
|
|
387
|
+
title: (
|
|
388
|
+
<View className={styles['demo-custom-double-select-header']}>
|
|
389
|
+
<View>Time</View>
|
|
390
|
+
<View>Temp</View>
|
|
391
|
+
</View>
|
|
392
|
+
),
|
|
393
|
+
}}
|
|
394
|
+
useTitleSlot
|
|
395
|
+
onCancel={() => setShow(false)}
|
|
396
|
+
onClose={() => setShow(false)}
|
|
397
|
+
onConfirm={() => setShow(false)}
|
|
398
|
+
>
|
|
399
|
+
<View className={styles['demo-custom-double-select-content']}>
|
|
400
|
+
<DateTimePicker
|
|
401
|
+
className={styles.flex1}
|
|
402
|
+
type="time"
|
|
403
|
+
is12HourClock
|
|
404
|
+
showToolbar={false}
|
|
405
|
+
value={current12Date}
|
|
406
|
+
onInput={onCurrent12DateInput}
|
|
407
|
+
/>
|
|
408
|
+
<Picker
|
|
409
|
+
className={styles.flex1}
|
|
410
|
+
unit="℃"
|
|
411
|
+
activeIndex={tempColumnIdx}
|
|
412
|
+
columns={tempColumns}
|
|
413
|
+
onChange={onTempColumnChange}
|
|
414
|
+
/>
|
|
415
|
+
</View>
|
|
416
|
+
</ActionSheet>
|
|
417
|
+
<Button onClick={() => setShow(true)}>点击展示</Button>
|
|
418
|
+
</View>
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
index.module.less
|
|
424
|
+
```css
|
|
425
|
+
.demo-custom-double-select-header {
|
|
426
|
+
display: flex;
|
|
427
|
+
align-items: center;
|
|
428
|
+
justify-content: space-around;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.demo-custom-double-select-content {
|
|
432
|
+
display: flex;
|
|
433
|
+
align-items: center;
|
|
434
|
+
justify-content: space-between;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.flex1 {
|
|
438
|
+
flex: 1;
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
## API
|
|
443
|
+
|
|
444
|
+
### Props
|
|
445
|
+
|
|
446
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
447
|
+
| ----------------------- | -------------------------------------------- | --------- | ------------------- |
|
|
448
|
+
| actions | 菜单选项 | _Array_ | `[]` |
|
|
449
|
+
| activeColor | 列表选项中 icon 的选中态颜色 | _string_ | `--app-M1` |
|
|
450
|
+
| cancelText | 取消按钮文字 | _string_ | - |
|
|
451
|
+
| closeOnClickAction | 是否在点击选项后关闭 | _boolean_ | `true` |
|
|
452
|
+
| closeOnClickOverlay | 点击遮罩是否关闭菜单 | _boolean_ | `true` |
|
|
453
|
+
| confirmText | 确认按钮文字 | _string_ | - |
|
|
454
|
+
| description | 选项上方的描述信息 | _string_ | - |
|
|
455
|
+
| overlay | 是否显示遮罩层 | _boolean_ | `true` |
|
|
456
|
+
| round | 是否显示圆角 | _boolean_ | `true` |
|
|
457
|
+
| safeAreaInsetBottom | 是否为 iPhoneX 留出底部安全距离 | _boolean_ | `true` |
|
|
458
|
+
| safeAreaInsetBottomMin `v1.1.0` | 是否需要预留出一个最小的底部安全距离,用于在 safeArea 底部为 0 时进行追加,需要在 safeAreaInsetBottom 为 true 时生效 | _number_ | `16` |
|
|
459
|
+
| show | 是否显示动作面板 | _boolean_ | - |
|
|
460
|
+
| title | 标题 | _string_ | - |
|
|
461
|
+
| useTitleSlot `v2.6.0` | 是否启用标题 Slot | _boolean_ | `false` |
|
|
462
|
+
| zIndex | z-index 层级 | _number_ | `100` |
|
|
463
|
+
| nativeDisabled `v2.5.0` | 开启弹框期间是否禁用本地手势; 会在弹框开始进入动画时调用 `ty.nativeDisabled(true)`, 在弹框关闭动画结束时调用 `ty.nativeDisabled(false)` 恢复异层组件的点击能力;由于`ty.nativeDisabled` 是全局生效的,所以多个弹框组件同时打开时注意是否传 `native-disabled`属性和关闭的时机,防止 `native-disabled` 属性失效 | _boolean_ | `false` |
|
|
464
|
+
| fullCoverView `v2.11.1` | 是否使用 cover-view 包裹弹层,用于覆盖原生组件(如 map、video)时使用 | _boolean_ | `false` |
|
|
465
|
+
|
|
466
|
+
### Events
|
|
467
|
+
|
|
468
|
+
| 事件名 | 说明 | 参数 |
|
|
469
|
+
| ------------------ | ---------------------------------------- | ---------------------------- |
|
|
470
|
+
| onAfterEnter | 遮罩进入后触发 | - |
|
|
471
|
+
| onAfterLeave | 遮罩离开后触发 | - |
|
|
472
|
+
| onBeforeEnter | 遮罩进入前触发 | - |
|
|
473
|
+
| onBeforeLeave | 遮罩离开前触发 | - |
|
|
474
|
+
| onCancel | 取消按钮点击时触发 | - |
|
|
475
|
+
| onClickOverlay | 点击遮罩层时触发 | - |
|
|
476
|
+
| onClose | 关闭时触发 | - |
|
|
477
|
+
| onConfirm | 确认按钮点击时触发 | - |
|
|
478
|
+
| onEnter | 遮罩进入中触发 | - |
|
|
479
|
+
| onLeave | 遮罩离开中触发 | - |
|
|
480
|
+
| onSelect | 选中选项时触发,禁用或加载状态下不会触发 | event.detail: 选项对应的对象 |
|
|
481
|
+
|
|
482
|
+
### Slot
|
|
483
|
+
|
|
484
|
+
| 名称 | 说明 |
|
|
485
|
+
| ------- | ---- |
|
|
486
|
+
| default | 自定义面板内容,通常用于插入自定义菜单内容 |
|
|
487
|
+
| title | 自定义标题内容,需要 `use-title-slot` 为 `true`,且未设置 `title` 属性时生效 |
|
|
488
|
+
|
|
489
|
+
### actions
|
|
490
|
+
|
|
491
|
+
`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`:
|
|
492
|
+
|
|
493
|
+
| 键名 | 说明 | 类型 | 默认值 |
|
|
494
|
+
| --------- | ----------------------------- | --------- | ------ |
|
|
495
|
+
| className | 为对应列添加额外的 class 类名 | _string_ | - |
|
|
496
|
+
| color | 选项文字颜色 | _string_ | - |
|
|
497
|
+
| checked | 是否为选中状态,显示选中图标 | _boolean_ | - |
|
|
498
|
+
| disabled | 是否为禁用状态 | _boolean_ | - |
|
|
499
|
+
| loading | 是否为加载状态 | _boolean_ | - |
|
|
500
|
+
| name | 标题 | _string_ | - |
|
|
501
|
+
| subname | 二级标题 | _string_ | - |
|
|
502
|
+
|
|
503
|
+
### 外部样式类
|
|
504
|
+
|
|
505
|
+
| 类名 | 说明 |
|
|
506
|
+
| ------------ | ------------------- |
|
|
507
|
+
| customClass | 根节点样式类 |
|
|
508
|
+
| listClass | `actions`容器样式类 |
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
### 样式变量
|
|
512
|
+
|
|
513
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
|
|
514
|
+
|
|
515
|
+
| 名称 | 默认值 | 描述 |
|
|
516
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
517
|
+
| --action-sheet-width | _calc(100% - 32px)_ | 弹窗的宽度 |
|
|
518
|
+
| --action-sheet-left | _16px_ | 弹窗绝对定位左侧的位置 |
|
|
519
|
+
| --action-sheet-max-height | _90%_ | 弹窗的最大高度 |
|
|
520
|
+
| --action-sheet-margin | _0 0 16px_ | 弹窗的边距 |
|
|
521
|
+
| --action-sheet-active-color | _var(--app-B1, #f6f7fb)_ | 选中图标的颜色,以及按下时列表的背景色 |
|
|
522
|
+
| --action-sheet-item-disabled-opacity | _0.3_ | 禁用列表的透明度 |
|
|
523
|
+
| --action-sheet-header-border-color | _var(--app-B4-N7, rgba(0, 0, 0, 0.1))_ | 头部的边框色 |
|
|
524
|
+
| --action-sheet-header-height | _56px_ | 头部的高度 |
|
|
525
|
+
| --action-sheet-header-color | _var(--app-B4-N3, rgba(0, 0, 0, 0.5))_ | 头部的字体颜色 |
|
|
526
|
+
| --action-sheet-header-font-size | _16px_ | 头部的字体大小 |
|
|
527
|
+
| --action-sheet-header-font-weight | _normal_ | 头部的字重 |
|
|
528
|
+
| --action-sheet-description-color | _var(--app-B4-N3, rgba(0, 0, 0, 0.5))_ | 说明文字的颜色 |
|
|
529
|
+
| --action-sheet-description-font-size | _14px_ | 说明文字的字体大小 |
|
|
530
|
+
| --action-sheet-description-line-height | _20px_ | 说明文字的行高 |
|
|
531
|
+
| --action-sheet-item-background | _var(--app-B4, #ffffff)_ | 列表的背景色 |
|
|
532
|
+
| --action-sheet-item-border-radius | _0_ | 列表的边框圆角 |
|
|
533
|
+
| --action-sheet-item-icon-margin | _0px 16px 0 0_ | 列表的图标大小边距 |
|
|
534
|
+
| --action-sheet-item-icon-color | _var(--app-M1, #3678e3)_ | 列表的图标颜色 |
|
|
535
|
+
| --action-sheet-item-icon-size | _28px_ | 列表的图标大小 |
|
|
536
|
+
| --action-sheet-item-font-size | _16px_ | 列表的文字字体大小 |
|
|
537
|
+
| --action-sheet-item-font-weight | _normal_ | 列表的文字字重 |
|
|
538
|
+
| --action-sheet-item-line-height | _24px_ | 列表的文字的行高 |
|
|
539
|
+
| --action-sheet-item-text-color | _var(--app-B4-N1, rgba(0, 0, 0, 1))_ | 列表的文字的颜色 |
|
|
540
|
+
| --action-sheet-subname-color | _var(--app-B4-N3, rgba(0, 0, 0, 0.5))_ | 列表二级名称的字体颜色 |
|
|
541
|
+
| --action-sheet-subname-font-size | _12px_ | 列表二级名称的字体大小 |
|
|
542
|
+
| --action-sheet-subname-line-height | _20px_ | - |
|
|
543
|
+
| --action-sheet-confirm-text-color | _var(--app-B4-N1, rgba(0, 0, 0, 1))_ | 确认按钮的字体颜色 |
|
|
544
|
+
| --action-sheet-confirm-font-weight | _500_ | 确认按钮的字体字重 |
|
|
545
|
+
| --action-sheet-cancel-text-color | _var(--app-B4-N3, rgba(0, 0, 0, 0.5))_ | 取消按钮的字体颜色 |
|
|
546
|
+
| --action-sheet-footer-padding-top | _8px_ | 底部内容的顶部内边距 |
|
|
547
|
+
| --action-sheet-footer-padding-color | _var(--app-B4-N9, rgba(0, 0, 0, 0.05))_ | 底部内容的距离列表的间隔色 |
|
|
548
|
+
| --action-sheet-active-icon-color `v2.2.0` | _var(--app-M1, #3678e3)_ | 列表选中图标的颜色 |
|
|
549
|
+
|
|
550
|
+
## 常见问题
|
|
551
|
+
|
|
552
|
+
### ActionSheet 子组件使用 Slider 渲染定位异常,是什么情况?
|
|
553
|
+
|
|
554
|
+
由于 `Slider` 组件在 `ActionSheet` 打开时可能尚未完全渲染,因此我们无法获取其 DOM,从而导致定位出现问题。解决方案是在 `ActionSheet` 的 `onAfterEnter` 事件回调之后再开始渲染 `Slider` 组件。这样,我们可以确保 `Slider` 能够在获取 DOM 时被正常渲染。请参考以下示例:
|
|
555
|
+
|
|
556
|
+
```tsx
|
|
557
|
+
import React from 'react';
|
|
558
|
+
import { View, Text } from '@ray-js/ray';
|
|
559
|
+
import { useDebounce } from 'ahooks';
|
|
560
|
+
import { ActionSheet, Slider } from '@ray-js/smart-ui';
|
|
561
|
+
import styles from './index.module.less';
|
|
562
|
+
|
|
563
|
+
function Demo() {
|
|
564
|
+
const [ready, setReady] = React.useState(false);
|
|
565
|
+
const [currentNumber, setCurrentNumber] = React.useState(100);
|
|
566
|
+
const currentNumberForSlider = useDebounce(currentNumber, { wait: 500 });
|
|
567
|
+
const onActionSheetReady = React.useCallback(() => setReady(true), []);
|
|
568
|
+
const [showNumber, setShowNumber] = React.useState(false);
|
|
569
|
+
const onChange = React.useCallback(value => {
|
|
570
|
+
setCurrentNumber(value);
|
|
571
|
+
}, []);
|
|
572
|
+
const toggleActionSheetNumber = React.useCallback(() => setShowNumber(!showNumber), [showNumber]);
|
|
573
|
+
|
|
574
|
+
return (
|
|
575
|
+
<ActionSheet
|
|
576
|
+
show={showNumber}
|
|
577
|
+
title="Title"
|
|
578
|
+
cancelText="Action"
|
|
579
|
+
confirmText="Action"
|
|
580
|
+
onClose={toggleActionSheetNumber}
|
|
581
|
+
onCancel={toggleActionSheetNumber}
|
|
582
|
+
onConfirm={toggleActionSheetNumber}
|
|
583
|
+
onAfterEnter={onActionSheetReady}
|
|
584
|
+
>
|
|
585
|
+
<View className={styles['content-number']}>
|
|
586
|
+
<View className={styles['demo-header']}>
|
|
587
|
+
<Text className={styles['demo-text']}>{`${currentNumber}%`}</Text>
|
|
588
|
+
</View>
|
|
589
|
+
<View className={styles['demo-slider']}>
|
|
590
|
+
{ready && (
|
|
591
|
+
<Slider
|
|
592
|
+
minTrackRadius="8px"
|
|
593
|
+
minTrackHeight="45px"
|
|
594
|
+
maxTrackRadius="8px"
|
|
595
|
+
maxTrackHeight="45px"
|
|
596
|
+
value={currentNumberForSlider}
|
|
597
|
+
onChange={onChange}
|
|
598
|
+
thumbWidth={15}
|
|
599
|
+
thumbHeight={50}
|
|
600
|
+
thumbRadius={2}
|
|
601
|
+
thumbStyle={{
|
|
602
|
+
background: '#BBC5D4',
|
|
603
|
+
border: '2px solid #FFFFFF',
|
|
604
|
+
boxShadow: '0px 0px 2px 0px rgba(0, 0, 0, 0.5)',
|
|
605
|
+
}}
|
|
606
|
+
/>
|
|
607
|
+
)}
|
|
608
|
+
</View>
|
|
609
|
+
</View>
|
|
610
|
+
</ActionSheet>
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
```
|