1
1
import { srOnlyStyles , styleToString , useRefById } from "svelte-toolbelt" ;
2
+ import type { HTMLButtonAttributes } from "svelte/elements" ;
2
3
import type { ReadableBoxedValues , WritableBoxedValues } from "$lib/internal/box.svelte.js" ;
3
4
import type { WithRefProps } from "$lib/internal/types.js" ;
4
5
import { getAriaChecked , getAriaRequired , getDataDisabled } from "$lib/internal/attrs.js" ;
@@ -13,6 +14,7 @@ type CheckboxRootStateProps = WithRefProps<
13
14
required : boolean ;
14
15
name : string | undefined ;
15
16
value : string | undefined ;
17
+ type : HTMLButtonAttributes [ "type" ] ;
16
18
} > &
17
19
WritableBoxedValues < {
18
20
checked : boolean ;
@@ -23,6 +25,7 @@ type CheckboxRootStateProps = WithRefProps<
23
25
class CheckboxRootState {
24
26
#id: CheckboxRootStateProps [ "id" ] ;
25
27
#ref: CheckboxRootStateProps [ "ref" ] ;
28
+ #type: CheckboxRootStateProps [ "type" ] ;
26
29
checked : CheckboxRootStateProps [ "checked" ] ;
27
30
disabled : CheckboxRootStateProps [ "disabled" ] ;
28
31
required : CheckboxRootStateProps [ "required" ] ;
@@ -39,6 +42,7 @@ class CheckboxRootState {
39
42
this . #ref = props . ref ;
40
43
this . #id = props . id ;
41
44
this . indeterminate = props . indeterminate ;
45
+ this . #type = props . type ;
42
46
43
47
useRefById ( {
44
48
id : this . #id,
@@ -74,7 +78,7 @@ class CheckboxRootState {
74
78
( {
75
79
id : this . #id. current ,
76
80
role : "checkbox" ,
77
- type : "button" ,
81
+ type : this . #type . current ,
78
82
disabled : this . disabled . current ,
79
83
"aria-checked" : getAriaChecked ( this . checked . current , this . indeterminate . current ) ,
80
84
"aria-required" : getAriaRequired ( this . required . current ) ,
0 commit comments