aranlucas / react-hook-form-mantine

React Hook Form bindings for Mantine components
https://aranlucas.github.io/react-hook-form-mantine/
90 stars 12 forks source link

Not support export ts.SyntaxKind.Identifier #21

Closed StringKe closed 9 months ago

StringKe commented 11 months ago
import { Checkbox as $Checkbox } from '@mantine/core';
import { useController } from 'react-hook-form';

import type { CheckboxProps as $CheckboxProps } from '@mantine/core';
import type { FieldValues, UseControllerProps } from 'react-hook-form';

import { CheckboxGroup } from './CheckBoxGroup/CheckBoxGroup';

export type CheckboxProps<T extends FieldValues> = UseControllerProps<T> &
    Omit<$CheckboxProps, 'checked' | 'defaultValue'>;

export const Checkbox = <T extends FieldValues>({
    name,
    control,
    defaultValue,
    rules,
    shouldUnregister,
    onChange,
    ...props
}: CheckboxProps<T>) => {
    const {
        field: { value, onChange: fieldOnChange, ...field },
        fieldState,
    } = useController<T>({
        name,
        control,
        defaultValue,
        rules,
        shouldUnregister,
    });

    return (
        <$Checkbox
            error={fieldState.error?.message}
            value={value}
            checked={value}
            onChange={(e) => {
                fieldOnChange(e);
                onChange?.(e);
            }}
            {...field}
            {...props}
        />
    );
};

Checkbox.Group = CheckboxGroup;
Checkbox.Item = $Checkbox;

error log:

[23-10-18 04:05:20] error: Cannot support type: (79) Checkbox
[23-10-18 04:05:20] error: Error: Cannot support type: (79) Checkbox

full project: https://github.com/aranlucas/react-hook-form-mantine

github-actions[bot] commented 9 months ago

Stale issue message