File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed
packages/headless/src/components/checkbox Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change 1
- import { component$ , Slot , QwikChangeEvent } from '@builder.io/qwik' ;
1
+ import {
2
+ component$ ,
3
+ Slot ,
4
+ QwikChangeEvent ,
5
+ PropFunction ,
6
+ } from '@builder.io/qwik' ;
7
+
2
8
interface StyleProps {
3
9
class ?: string ;
4
10
style ?: string ;
@@ -7,7 +13,7 @@ interface LabelProps extends StyleProps {
7
13
htmlFor ?: string ;
8
14
}
9
15
10
- const Label = component$ ( ( { ...props } : LabelProps ) => {
16
+ export const Label = component$ ( ( { ...props } : LabelProps ) => {
11
17
return (
12
18
< label { ...props } >
13
19
< Slot />
@@ -23,13 +29,15 @@ export interface CheckboxProps extends StyleProps {
23
29
id ?: string ;
24
30
value ?: string ;
25
31
tabIndex ?: number ;
26
- onChange ?: (
27
- event : QwikChangeEvent < HTMLInputElement > ,
28
- element : HTMLInputElement
29
- ) => any ;
32
+ onChange ?: PropFunction <
33
+ (
34
+ event : QwikChangeEvent < HTMLInputElement > ,
35
+ element : HTMLInputElement
36
+ ) => void
37
+ > ;
30
38
}
31
39
32
- const Root = component$ (
40
+ export const Root = component$ (
33
41
( {
34
42
checked,
35
43
disabled,
@@ -53,11 +61,13 @@ const Root = component$(
53
61
aria-checked = { checked }
54
62
value = { value }
55
63
tabIndex = { tabIndex }
56
- onChange$ = { onChange }
64
+ onChange$ = { ( event , element ) => {
65
+ if ( onChange ) {
66
+ onChange ( event , element ) ;
67
+ }
68
+ } }
57
69
{ ...props }
58
70
/>
59
71
) ;
60
72
}
61
73
) ;
62
-
63
- export { Label , Root } ;
You can’t perform that action at this time.
0 commit comments