Skip to content

Commit

Permalink
fix(Radio, Checkbox): export required prop type
Browse files Browse the repository at this point in the history
  • Loading branch information
nnmax committed Nov 22, 2023
1 parent 110e1b3 commit e797f21
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions components/checkbox/Checkbox.tsx
Expand Up @@ -35,6 +35,7 @@ export interface AbstractCheckboxProps<T> {
autoFocus?: boolean;
type?: string;
skipGroup?: boolean;
required?: boolean;
}

export interface CheckboxChangeEventTarget extends CheckboxProps {
Expand Down
2 changes: 2 additions & 0 deletions components/checkbox/Group.tsx
Expand Up @@ -18,6 +18,7 @@ export interface CheckboxOptionType {
title?: string;
id?: string;
onChange?: (e: CheckboxChangeEvent) => void;
required?: boolean;
}

export interface AbstractCheckboxGroupProps {
Expand Down Expand Up @@ -126,6 +127,7 @@ const InternalGroup: React.ForwardRefRenderFunction<HTMLDivElement, CheckboxGrou
style={option.style}
title={option.title}
id={option.id}
required={option.required}
>
{option.label}
</Checkbox>
Expand Down
2 changes: 2 additions & 0 deletions components/checkbox/index.en-US.md
Expand Up @@ -41,6 +41,7 @@ Common props ref:[Common props](/docs/react/common-props)
| disabled | If disable checkbox | boolean | false | |
| indeterminate | The indeterminate checked state of checkbox | boolean | false | |
| onChange | The callback function that is triggered when the state changes | (e: CheckboxChangeEvent) => void | - | |
| required | If set to `true`, a non-null value must be specified when submitting the form. the browser's native form validation will be triggered. | boolean | - | |

#### Checkbox Group

Expand All @@ -60,6 +61,7 @@ interface Option {
label: string;
value: string;
disabled?: boolean;
required?: boolean;
}
```

Expand Down
2 changes: 2 additions & 0 deletions components/checkbox/index.zh-CN.md
Expand Up @@ -42,6 +42,7 @@ demo:
| disabled | 失效状态 | boolean | false | |
| indeterminate | 设置 indeterminate 状态,只负责样式控制 | boolean | false | |
| onChange | 变化时的回调函数 | (e: CheckboxChangeEvent) => void | - | |
| required | 如果设置为 `true`,则提交表单时必须指定一个非空值。这将会触发浏览器原生表单验证功能 | boolean | - | |

#### Checkbox Group

Expand All @@ -61,6 +62,7 @@ interface Option {
label: string;
value: string;
disabled?: boolean;
required?: boolean;
}
```

Expand Down
1 change: 1 addition & 0 deletions components/radio/group.tsx
Expand Up @@ -80,6 +80,7 @@ const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>((props, ref
title={option.title}
style={option.style}
id={option.id}
required={option.required}
>
{option.label}
</Radio>
Expand Down
5 changes: 3 additions & 2 deletions components/radio/index.en-US.md
Expand Up @@ -39,12 +39,13 @@ Common props ref:[Common props](/docs/react/common-props)
### Radio/Radio.Button

| Property | Description | Type | Default |
| --- | --- | --- | --- |
| --- | --- | --- | --- | --- |
| autoFocus | Whether get focus when component mounted | boolean | false |
| checked | Specifies whether the radio is selected | boolean | false |
| defaultChecked | Specifies the initial state: whether or not the radio is selected | boolean | false |
| disabled | Disable radio | boolean | false |
| value | According to value for comparison, to determine whether the selected | any | - |
| required | If set to `true`, a non-null value must be specified when submitting the form. the browser's native form validation will be triggered. | boolean | - | |

### RadioGroup

Expand All @@ -56,7 +57,7 @@ Radio group can wrap a group of `Radio`。
| defaultValue | Default selected value | any | - | |
| disabled | Disable all radio buttons | boolean | false | |
| name | The `name` property of all `input[type="radio"]` children | string | - | |
| options | Set children optional | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; }> | - | |
| options | Set children optional | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; required?: boolean; }> | - | |
| optionType | Set Radio optionType | `default` \| `button` | `default` | 4.4.0 |
| size | The size of radio button style | `large` \| `middle` \| `small` | - | |
| value | Used for setting the currently selected value | any | - | |
Expand Down
3 changes: 2 additions & 1 deletion components/radio/index.zh-CN.md
Expand Up @@ -47,6 +47,7 @@ demo:
| defaultChecked | 初始是否选中 | boolean | false |
| disabled | 禁用 Radio | boolean | false |
| value | 根据 value 进行比较,判断是否选中 | any | - |
| required | 如果设置为 `true`,则提交表单时必须指定一个非空值。这将会触发浏览器原生表单验证功能 | boolean | - | |

### Radio.Group

Expand All @@ -59,7 +60,7 @@ demo:
| defaultValue | 默认选中的值 | any | - | | |
| disabled | 禁选所有子单选器 | boolean | false | | |
| name | RadioGroup 下所有 `input[type="radio"]``name` 属性 | string | - | | |
| options | 以配置形式设置子元素 | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; }> | - | | |
| options | 以配置形式设置子元素 | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; required?: boolean; }> | - | | |
| optionType | 用于设置 Radio `options` 类型 | `default` \| `button` | `default` | 4.4.0 | |
| size | 大小,只对按钮样式生效 | `large` \| `middle` \| `small` | - | | |
| value | 用于设置当前选中的值 | any | - | | |
Expand Down

0 comments on commit e797f21

Please sign in to comment.