chore(components): improve props

This commit is contained in:
Benjamin Canac
2024-06-28 18:13:03 +02:00
parent c9f9a248b7
commit 673064dee5
38 changed files with 260 additions and 137 deletions

View File

@@ -12,20 +12,20 @@ const checkbox = tv({ extend: tv(theme), ...(appConfig.ui?.checkbox || {}) })
type CheckboxVariants = VariantProps<typeof checkbox>
export interface CheckboxProps extends Omit<CheckboxRootProps, 'asChild' | 'checked' | 'defaultChecked'> {
export interface CheckboxProps extends Pick<CheckboxRootProps, 'disabled' | 'required' | 'name' | 'value' | 'id'> {
label?: string
description?: string
color?: CheckboxVariants['color']
size?: CheckboxVariants['size']
/**
* The icon displayed when checked.
* @defaultValue `appConfig.ui.icons.check`
* @defaultValue appConfig.ui.icons.check
*/
icon?: string
indeterminate?: InputHTMLAttributes['indeterminate']
/**
* The icon displayed when the checkbox is indeterminate.
* @defaultValue `appConfig.ui.icons.minus`
* @defaultValue appConfig.ui.icons.minus
*/
indeterminateIcon?: string
/** The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state. */
@@ -56,7 +56,7 @@ defineEmits<CheckboxEmits>()
const modelValue = defineModel<boolean | undefined>({ default: undefined })
const rootProps = useForwardProps(reactivePick(props, 'as', 'required', 'value'))
const rootProps = useForwardProps(reactivePick(props, 'required', 'value'))
const appConfig = useAppConfig()
const { id: _id, emitFormChange, size, color, name, disabled } = useFormField<CheckboxProps>(props)