-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b25d2b2
commit b870ad1
Showing
18 changed files
with
75 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
import { Control, Controller, FieldValues, RegisterOptions } from "react-hook-form"; | ||
import { Toggle } from "./toggle"; | ||
import { | ||
Control, | ||
Controller, | ||
FieldValues, | ||
RegisterOptions, | ||
} from 'react-hook-form'; | ||
import { Toggle } from './toggle'; | ||
|
||
|
||
export function RHFToggle({ name, control, rules, ...rest }: { | ||
name: string | ||
control: Control; | ||
rules: Omit< | ||
RegisterOptions<FieldValues, string>, | ||
'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled' | ||
> | ||
export function RHFToggle({ | ||
name, | ||
control, | ||
rules, | ||
...rest | ||
}: { | ||
name: string; | ||
control: Control; | ||
rules: Omit< | ||
RegisterOptions<FieldValues, string>, | ||
'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled' | ||
>; | ||
}) { | ||
return ( | ||
<Controller | ||
name={name} | ||
control={control} | ||
rules={rules} | ||
render={({ field: { name, onChange, ref, value = "", disabled, onBlur } }) => ( | ||
<Toggle | ||
id={name} | ||
onPressedChange={onChange} | ||
ref={ref} | ||
value={value} | ||
disabled={disabled} | ||
onBlur={onBlur} | ||
{...rest} | ||
/> | ||
)} /> | ||
) | ||
return ( | ||
<Controller | ||
name={name} | ||
control={control} | ||
rules={rules} | ||
render={({ | ||
field: { name, onChange, ref, value = '', disabled, onBlur }, | ||
}) => ( | ||
<Toggle | ||
id={name} | ||
onPressedChange={onChange} | ||
ref={ref} | ||
value={value} | ||
disabled={disabled} | ||
onBlur={onBlur} | ||
{...rest} | ||
/> | ||
)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters