Skip to content

Commit

Permalink
docs: checkout文档补全以及代码优化补充
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiangXvFan authored Oct 10, 2024
1 parent eb78b55 commit c0d94d8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vantui/src/checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function Checkbox(

const {
name,
disabled,
disabled = false,
checkedColor = '',
labelPosition = 'right',
labelDisabled,
labelDisabled = false,
shape = 'round',
iconSize = '20px',
renderIcon,
Expand Down Expand Up @@ -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) {
Expand Down
61 changes: 61 additions & 0 deletions packages/vantui/types/checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>
/**
* @description 是否禁用所有复选框
* @default false
*/
disabled?: boolean
/**
* @description 复选框排列方向
* @default vertical
*/
direction?: 'horizontal' | 'vertical'
/**
* @description
*/
children?: ReactNode
/**
* @description 当绑定值变化时触发的事件
*/
onChange?: (event: ITouchEvent) => any
}

Expand Down

0 comments on commit c0d94d8

Please sign in to comment.