Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: checkout文档补全以及代码优化补充 #692

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading