File tree Expand file tree Collapse file tree 7 files changed +32
-17
lines changed Expand file tree Collapse file tree 7 files changed +32
-17
lines changed Original file line number Diff line number Diff line change 6
6
import styles from ' ./badge.module.scss'
7
7
8
8
export let theme: SvelteBadgeProps [' theme' ] = null
9
- export let onClick: SvelteBadgeProps [' onClick' ] = null
10
9
export let hover: SvelteBadgeProps [' hover' ] = false
11
10
export let small: SvelteBadgeProps [' small' ] = false
12
11
export let className: SvelteBadgeProps [' className' ] = ' '
12
+ export let onClick: SvelteBadgeProps [' onClick' ] = () => {}
13
13
14
14
const classes = classNames ([
15
15
styles .badge ,
Original file line number Diff line number Diff line change
1
+ import type { MouseEventHandler } from 'svelte/elements'
2
+
1
3
export type BadgeProps = {
2
4
theme ?: 'secondary'
3
5
| 'outline'
@@ -14,10 +16,10 @@ export type BadgeProps = {
14
16
}
15
17
16
18
export type SvelteBadgeProps = {
17
- onClick ?: ( ( event : MouseEvent ) => void ) | null
19
+ onClick ?: MouseEventHandler < HTMLButtonElement >
18
20
} & BadgeProps
19
21
20
22
export type ReactBadgeProps = {
21
- onClick ?: ( event : React . MouseEvent ) => void
23
+ onClick ?: React . MouseEventHandler < HTMLButtonElement >
22
24
children : React . ReactNode
23
25
} & BadgeProps
Original file line number Diff line number Diff line change
1
+ import type { MouseEventHandler } from 'svelte/elements'
2
+
1
3
export type ButtonProps = {
2
4
theme ?: 'secondary'
3
5
| 'outline'
@@ -7,17 +9,24 @@ export type ButtonProps = {
7
9
| 'warning'
8
10
| 'alert'
9
11
| null
12
+ | undefined
13
+ target ?: '_self'
14
+ | '_blank'
15
+ | '_parent'
16
+ | '_top'
17
+ | '_unfencedTop'
18
+ | null
19
+ | undefined
10
20
href ?: string
11
- target ?: '_self' | '_blank' | '_parent' | '_top' | '_unfencedTop' | undefined
12
21
className ?: string
13
22
[ key : string ] : any
14
23
}
15
24
16
25
export type SvelteButtonProps = {
17
- onClick ?: ( ( event : MouseEvent ) => void ) | null
26
+ onClick ?: MouseEventHandler < HTMLButtonElement >
18
27
} & ButtonProps
19
28
20
29
export type ReactButtonProps = {
21
- onClick ?: ( event : React . MouseEvent ) => void
30
+ onClick ?: React . MouseEventHandler < HTMLButtonElement >
22
31
children : React . ReactNode
23
32
} & ButtonProps
Original file line number Diff line number Diff line change
1
+ import type { MouseEventHandler } from 'svelte/elements'
2
+
1
3
export type CheckboxProps = {
2
4
checked ?: boolean
3
5
label ?: string
@@ -8,9 +10,9 @@ export type CheckboxProps = {
8
10
}
9
11
10
12
export type SvelteCheckboxProps = {
11
- onClick ?: ( ( event : MouseEvent ) => void ) | null
13
+ onClick ?: MouseEventHandler < HTMLInputElement >
12
14
} & CheckboxProps
13
15
14
16
export type ReactCheckboxProps = {
15
- onClick ?: ( event : React . MouseEvent ) => void
17
+ onClick ?: React . MouseEventHandler < HTMLInputElement >
16
18
} & CheckboxProps
Original file line number Diff line number Diff line change
1
+ import type { MouseEventHandler } from 'svelte/elements'
2
+
1
3
export type SwitchProps = {
2
4
label ?: string
3
5
reverse ?: boolean
@@ -11,9 +13,9 @@ export type SwitchProps = {
11
13
}
12
14
13
15
export type SvelteSwitchProps = {
14
- onClick ?: ( ( event : MouseEvent ) => void ) | null
16
+ onClick ?: MouseEventHandler < HTMLInputElement >
15
17
} & SwitchProps
16
18
17
19
export type ReactSwitchProps = {
18
- onClick ?: ( event : React . MouseEvent ) => void
20
+ onClick ?: React . MouseEventHandler < HTMLInputElement >
19
21
} & SwitchProps
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ const ReactPlayground = () => {
92
92
< Card title = "Checkbox" >
93
93
< Checkbox
94
94
label = "Accept"
95
- onClick = { e => setCheckbox ( e . target . checked ) }
95
+ onClick = { e => setCheckbox ( e . currentTarget . checked ) }
96
96
/>
97
97
98
98
< span className = { styles . span } > { `${ checkbox } ` } </ span >
@@ -222,7 +222,7 @@ const ReactPlayground = () => {
222
222
223
223
< Card title = "Switch" >
224
224
< Switch
225
- onClick = { e => setToggle ( e . target . checked ) }
225
+ onClick = { e => setToggle ( e . currentTarget . checked ) }
226
226
/>
227
227
228
228
< span className = { styles . span } > { `${ toggle } ` } </ span >
Original file line number Diff line number Diff line change 1
- <script >
1
+ <script lang = " ts " >
2
2
import Accordion from ' @components/Accordion/Accordion.svelte'
3
3
import Badge from ' @components/Badge/Badge.svelte'
4
4
import Button from ' @components/Button/Button.svelte'
90
90
<Card title =" Checkbox" >
91
91
<Checkbox
92
92
label =" Accept"
93
- onClick ={e => checkbox = e .target .checked }
93
+ onClick ={e => checkbox = e .currentTarget .checked }
94
94
/>
95
95
96
96
<span class ={styles .span }>{checkbox }</span >
128
128
<Input
129
129
label =" Enter a value"
130
130
placeholder =" Or change the color below"
131
- onKeyUp ={e => input = e .target .value }
131
+ onKeyUp ={e => input = e .currentTarget .value }
132
132
/>
133
133
134
134
<Input
135
135
type =" color"
136
- onChange ={e => input = e .target .value }
136
+ onChange ={e => input = e .currentTarget .value }
137
137
/>
138
138
139
139
<span class ={styles .span }>{input }</span >
217
217
218
218
<Card title =" Switch" >
219
219
<Switch
220
- onClick ={e => toggle = e .target .checked }
220
+ onClick ={e => toggle = e .currentTarget .checked }
221
221
/>
222
222
223
223
<span class ={styles .span }>{toggle }</span >
You can’t perform that action at this time.
0 commit comments