From c0d94d8029847c6ac312ceb6b8669a8f76606e5f Mon Sep 17 00:00:00 2001 From: MrXiangXvFan <74048960+MrXiangXvFan@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:17:57 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20checkout=E6=96=87=E6=A1=A3=E8=A1=A5?= =?UTF-8?q?=E5=85=A8=E4=BB=A5=E5=8F=8A=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vantui/src/checkbox/index.tsx | 6 +-- packages/vantui/types/checkbox.d.ts | 61 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/packages/vantui/src/checkbox/index.tsx b/packages/vantui/src/checkbox/index.tsx index 59eccf64b..baca1c16f 100644 --- a/packages/vantui/src/checkbox/index.tsx +++ b/packages/vantui/src/checkbox/index.tsx @@ -21,10 +21,10 @@ export function Checkbox( const { name, - disabled, + disabled = false, checkedColor = '', labelPosition = 'right', - labelDisabled, + labelDisabled = false, shape = 'round', iconSize = '20px', renderIcon, @@ -83,7 +83,7 @@ export function Checkbox( const setParentValue = useCallback( (parent: any, event: ITouchEvent) => { const value = event.detail - const { max, value: parentValue_ } = parent + const { max = 0, value: parentValue_ } = parent const parentValue = parentValue_ ? [].concat(parentValue_) : parentValue_ if (value) { if (max && parentValue.length >= max) { diff --git a/packages/vantui/types/checkbox.d.ts b/packages/vantui/types/checkbox.d.ts index 3cd11dced..14665517a 100644 --- a/packages/vantui/types/checkbox.d.ts +++ b/packages/vantui/types/checkbox.d.ts @@ -2,25 +2,86 @@ import { FunctionComponent, ReactNode } from 'react' import { ITouchEvent, ViewProps } from '@tarojs/components' export interface CheckboxProps extends ViewProps { + /** + * @description 标识符 + */ name?: ReactNode + /** + * @description 是否为选中状态 + * @default false + */ value?: boolean + /** + * @description 是否禁用复选框 + * @default false + */ disabled?: boolean + /** + * @description 选中状态颜色 + * @default #07c160 + */ checkedColor?: string + /** + * @description 文本位置 + * @default right + */ labelPosition?: string + /** + * @description 是否禁用复选框文本点击 + * @default false + */ labelDisabled?: boolean + /** + * @description 形状,可选值为 square + * @default round + */ shape?: 'round' | 'square' + /** + * @description 图标大小,默认单位为px + * @default 20px + */ iconSize?: string | number + /** + * @description + */ children?: ReactNode + /** + * @description 自定义图标 + */ renderIcon?: ReactNode + /** + * @description 当绑定值变化时触发的事件 + */ onChange?: (event: ITouchEvent) => any } export interface CheckboxGroupProps extends ViewProps { + /** + * @description 最大可选数,0 为无限制 + * @default 0 + */ max?: number + /** + * @description 所有选中项的标识符 + */ value?: Array + /** + * @description 是否禁用所有复选框 + * @default false + */ disabled?: boolean + /** + * @description 复选框排列方向 + * @default vertical + */ direction?: 'horizontal' | 'vertical' + /** + * @description + */ children?: ReactNode + /** + * @description 当绑定值变化时触发的事件 + */ onChange?: (event: ITouchEvent) => any }