-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Showing
7 changed files
with
82 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,69 @@ | ||
import type { HTMLButtonAttributes } from "svelte/elements"; | ||
import type { Snippet } from "svelte"; | ||
import type { | ||
EventCallback, | ||
HTMLDivAttributes, | ||
OnChangeFn, | ||
WithAsChild, | ||
} from "$lib/internal/index.js"; | ||
|
||
export type CheckboxRootPropsWithoutHTML = WithAsChild<{ | ||
/** | ||
* Whether the checkbox is disabled. | ||
* | ||
* @defaultValue false | ||
*/ | ||
disabled?: boolean; | ||
|
||
/** | ||
* Whether the checkbox is required (for form validation). | ||
* | ||
* @defaultValue false | ||
*/ | ||
required?: boolean; | ||
|
||
/** | ||
* The name of the checkbox used in form submission. | ||
* If not provided, the hidden input will not be rendered. | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
name?: string; | ||
|
||
/** | ||
* The value of the checkbox used in form submission. | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
value?: string; | ||
|
||
/** | ||
* The checked state of the checkbox. It can be one of: | ||
* - `true` for checked | ||
* - `false` for unchecked | ||
* - `"indeterminate"` for indeterminate | ||
* | ||
* @defaultValue false | ||
*/ | ||
checked?: boolean | "indeterminate"; | ||
|
||
/** | ||
* A callback function called when the checked state changes. | ||
*/ | ||
onCheckedChange?: OnChangeFn<boolean | "indeterminate">; | ||
}>; | ||
export type CheckboxRootPropsWithoutHTML = WithAsChild< | ||
{ | ||
/** | ||
* Whether the checkbox is disabled. | ||
* | ||
* @defaultValue false | ||
*/ | ||
disabled?: boolean; | ||
|
||
/** | ||
* Whether the checkbox is required (for form validation). | ||
* | ||
* @defaultValue false | ||
*/ | ||
required?: boolean; | ||
|
||
/** | ||
* The name of the checkbox used in form submission. | ||
* If not provided, the hidden input will not be rendered. | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
name?: string; | ||
|
||
/** | ||
* The value of the checkbox used in form submission. | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
value?: string; | ||
|
||
/** | ||
* The checked state of the checkbox. It can be one of: | ||
* - `true` for checked | ||
* - `false` for unchecked | ||
* - `"indeterminate"` for indeterminate | ||
* | ||
* @defaultValue false | ||
*/ | ||
checked?: boolean | "indeterminate"; | ||
|
||
/** | ||
* A callback function called when the checked state changes. | ||
*/ | ||
onCheckedChange?: OnChangeFn<boolean | "indeterminate">; | ||
|
||
indicator?: Snippet<[{ checked: boolean | "indeterminate" }]>; | ||
}, | ||
{ props: Record<PropertyKey, unknown>; checked: boolean | "indeterminate" } | ||
>; | ||
|
||
export type CheckboxRootProps = CheckboxRootPropsWithoutHTML & | ||
Omit<HTMLButtonAttributes, "value" | "disabled" | "name" | "onclick" | "onkeydown"> & { | ||
onclick?: EventCallback<MouseEvent>; | ||
onkeydown?: EventCallback<KeyboardEvent>; | ||
}; | ||
|
||
export type CheckboxIndicatorPropsWithoutHTML = WithAsChild<object>; | ||
export type CheckboxIndicatorPropsWithoutHTML = WithAsChild<{ checked: boolean | "indeterminate" }>; | ||
|
||
export type CheckboxIndicatorProps = CheckboxIndicatorPropsWithoutHTML & HTMLDivAttributes; |
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