UNPKG

2.39 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps, CommonEventFunction, FormItemProps } from './common'
3
4interface CheckboxGroupProps extends StandardProps, FormItemProps {
5 /** 表单组件中加上 name 来作为 key
6 * @supported h5, tt
7 */
8 name?: string
9
10 /** `<CheckboxGroup/>` 中选中项发生改变是触发 change 事件
11 *
12 * event.detail = { value: [选中的checkbox的 value 的数组] }
13 * @supported weapp, h5, rn, tt
14 */
15 onChange?: CommonEventFunction<{ value: string[] }>
16}
17
18/** 多项选择器,内部由多个checkbox组成
19 * @classification forms
20 * @supported weapp, h5, rn, tt
21 * @example
22 * ```tsx
23 * export default class PageCheckbox extends Component {
24 * state = {
25 * list: [
26 * {
27 * value: '美国',
28 * text: '美国',
29 * checked: false
30 * },
31 * {
32 * value: '中国',
33 * text: '中国',
34 * checked: true
35 * },
36 * {
37 * value: '巴西',
38 * text: '巴西',
39 * checked: false
40 * },
41 * {
42 * value: '日本',
43 * text: '日本',
44 * checked: false
45 * },
46 * {
47 * value: '英国',
48 * text: '英国',
49 * checked: false
50 * },
51 * {
52 * value: '法国',
53 * text: '法国',
54 * checked: false
55 * }
56 * ]
57 * }
58 * render () {
59 * return (
60 * <View className='page-body'>
61 * <View className='page-section'>
62 * <Text>默认样式</Text>
63 * <Checkbox value='选中' checked>选中</Checkbox>
64 * <Checkbox style='margin-left: 20rpx' value='未选中'>未选中</Checkbox>
65 * </View>
66 * <View className='page-section'>
67 * <Text>推荐展示样式</Text>
68 * {this.state.list.map((item, i) => {
69 * return (
70 * <Label className='checkbox-list__label' for={i} key={i}>
71 * <Checkbox className='checkbox-list__checkbox' value={item.value} checked={item.checked}>{item.text}</Checkbox>
72 * </Label>
73 * )
74 * })}
75 * </View>
76 * </View>
77 * )
78 * }
79 * }
80 * ```
81 * @see https://developers.weixin.qq.com/miniprogram/dev/component/checkbox-group.html
82 */
83declare const CheckboxGroup: ComponentType<CheckboxGroupProps>
84
85export { CheckboxGroup, CheckboxGroupProps }