-
Notifications
You must be signed in to change notification settings - Fork 557
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
ea36386
commit 08b75f8
Showing
4 changed files
with
83 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createSnapComponent } from '../../component'; | ||
|
||
/** | ||
* The props of the {@link Checkbox} component. | ||
* | ||
* @property name - The name of the input field. This is used to identify the | ||
* input field in the form data. | ||
* @property type - The type of the input field. Defaults to `text`. | ||
* @property value - The value of the input field. | ||
* @property placeholder - The placeholder text of the input field. | ||
*/ | ||
export type CheckboxProps = { | ||
name: string; | ||
value?: boolean | undefined; | ||
}; | ||
|
||
const TYPE = 'Checkbox'; | ||
|
||
/** | ||
* A checkbox component, which is used to create a checkbox. | ||
* | ||
* @param props - The props of the component. | ||
* @param props.name - The name of the checkboxd. This is used to identify the | ||
* state in the form data. | ||
* @param props.value - The value of the input field. | ||
* @returns An input element. | ||
* @example | ||
* <Checkbox name="accept-terms" /> | ||
*/ | ||
export const Checkbox = createSnapComponent<CheckboxProps, typeof TYPE>(TYPE); | ||
|
||
/** | ||
* A checkbox element. | ||
* | ||
* @see Checkbox | ||
*/ | ||
export type CheckboxElement = ReturnType<typeof Checkbox>; |
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