Skip to content

Commit a247a2f

Browse files
committed
docs:update & refactor: checkbox type
1 parent a6fdee1 commit a247a2f

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

components/checkbox/index.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
category: Components
33
type: Data Entry
44
title: Checkbox
5-
cover: https://gw.alipayobjects.com/zos/alicdn/8nbVbHEm_/CheckBox.svg
5+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*DzgiRbW3khIAAAAAAAAAAAAADrJ8AQ/original
66
---
77

88
Checkbox component.

components/checkbox/index.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
subtitle: 多选框
44
type: 数据录入
55
title: Checkbox
6-
cover: https://gw.alipayobjects.com/zos/alicdn/8nbVbHEm_/CheckBox.svg
6+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*DzgiRbW3khIAAAAAAAAAAAAADrJ8AQ/original
77
---
88

99
多选框。

components/checkbox/interface.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import type { ExtractPropTypes, InjectionKey, PropType, Ref } from 'vue';
1+
import type { ExtractPropTypes, InjectionKey, Ref } from 'vue';
22
import type { MouseEventHandler } from '../_util/EventInterface';
33
import type { VueNode } from '../_util/type';
44
import PropTypes from '../_util/vue-types';
5+
import { booleanType, functionType, stringType, arrayType } from '../_util/type';
56

67
export type CheckboxValueType = string | number | boolean;
78
export interface CheckboxOptionType {
@@ -27,10 +28,9 @@ export const abstractCheckboxGroupProps = () => {
2728
return {
2829
name: String,
2930
prefixCls: String,
30-
options: {
31-
type: Array as PropType<Array<CheckboxOptionType | string | number>>,
32-
default: () => [] as Array<CheckboxOptionType | string | number>,
33-
},
31+
options: arrayType<Array<CheckboxOptionType | string | number>>(
32+
[] as Array<CheckboxOptionType | string | number>,
33+
),
3434
disabled: Boolean,
3535
id: String,
3636
};
@@ -39,12 +39,10 @@ export const abstractCheckboxGroupProps = () => {
3939
export const checkboxGroupProps = () => {
4040
return {
4141
...abstractCheckboxGroupProps(),
42-
defaultValue: { type: Array as PropType<Array<CheckboxValueType>> },
43-
value: { type: Array as PropType<Array<CheckboxValueType>> },
44-
onChange: { type: Function as PropType<(checkedValue: Array<CheckboxValueType>) => void> },
45-
'onUpdate:value': {
46-
type: Function as PropType<(checkedValue: Array<CheckboxValueType>) => void>,
47-
},
42+
defaultValue: arrayType<Array<CheckboxValueType>>(),
43+
value: arrayType<Array<CheckboxValueType>>(),
44+
onChange: functionType<(checkedValue: Array<CheckboxValueType>) => void>(),
45+
'onUpdate:value': functionType<(checkedValue: Array<CheckboxValueType>) => void>(),
4846
};
4947
};
5048

@@ -53,27 +51,27 @@ export type CheckboxGroupProps = Partial<ExtractPropTypes<ReturnType<typeof chec
5351
export const abstractCheckboxProps = () => {
5452
return {
5553
prefixCls: String,
56-
defaultChecked: { type: Boolean, default: undefined },
57-
checked: { type: Boolean, default: undefined },
58-
disabled: { type: Boolean, default: undefined },
59-
isGroup: { type: Boolean, default: undefined },
54+
defaultChecked: booleanType(),
55+
checked: booleanType(),
56+
disabled: booleanType(),
57+
isGroup: booleanType(),
6058
value: PropTypes.any,
6159
name: String,
6260
id: String,
63-
indeterminate: { type: Boolean, default: undefined },
64-
type: { type: String, default: 'checkbox' },
65-
autofocus: { type: Boolean, default: undefined },
66-
onChange: Function as PropType<(e: CheckboxChangeEvent) => void>,
67-
'onUpdate:checked': Function as PropType<(checked: boolean) => void>,
68-
onClick: Function as PropType<MouseEventHandler>,
69-
skipGroup: { type: Boolean, default: false },
61+
indeterminate: booleanType(),
62+
type: stringType('checkbox'),
63+
autofocus: booleanType(),
64+
onChange: functionType<(e: CheckboxChangeEvent) => void>(),
65+
'onUpdate:checked': functionType<(checked: boolean) => void>(),
66+
onClick: functionType<MouseEventHandler>(),
67+
skipGroup: booleanType(false),
7068
};
7169
};
7270

7371
export const checkboxProps = () => {
7472
return {
7573
...abstractCheckboxProps(),
76-
indeterminate: { type: Boolean, default: false },
74+
indeterminate: booleanType(false),
7775
};
7876
};
7977

0 commit comments

Comments
 (0)