Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 712a5df

Browse files
committed
feat(Form): Add event handling to FormSelect and children
fix #219
1 parent a30c3df commit 712a5df

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/components/Form/FormSelectGroup.react.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22

33
import * as React from "react";
44
import cn from "classnames";
5+
import type {
6+
FormEvents,
7+
FocusEvents,
8+
MouseEvents,
9+
PointerEvents,
10+
} from "../../";
511

612
type Props = {|
13+
...FormEvents,
14+
...FocusEvents,
15+
...MouseEvents,
16+
...PointerEvents,
717
+children: Array<React.Element<any>>,
818
+className?: string,
919
+pills?: boolean,
@@ -15,13 +25,31 @@ function FormSelectGroup({
1525
children,
1626
pills,
1727
canSelectMultiple,
28+
onChange,
29+
onFocus,
30+
onBlur,
31+
onClick,
32+
onMouseEnter,
33+
onMouseLeave,
34+
onPointerEnter,
35+
onPointerLeave,
1836
}: Props): React.Node {
1937
const classes = cn(
2038
{ selectgroup: true, "w-100": true, "selectgroup-pills": pills },
2139
className
2240
);
2341
return (
24-
<div className={classes}>
42+
<div
43+
className={classes}
44+
onChange={onChange}
45+
onClick={onClick}
46+
onFocus={onFocus}
47+
onBlur={onBlur}
48+
onMouseEnter={onMouseEnter}
49+
onMouseLeave={onMouseLeave}
50+
onPointerEnter={onPointerEnter}
51+
onPointerLeave={onPointerLeave}
52+
>
2553
{canSelectMultiple
2654
? children.map(itm => React.cloneElement(itm, { type: "checkbox" }))
2755
: children}

src/components/Form/FormSelectGroupItem.react.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
import * as React from "react";
44
import cn from "classnames";
55
import { Icon } from "../";
6+
import type {
7+
FormEvents,
8+
FocusEvents,
9+
MouseEvents,
10+
PointerEvents,
11+
} from "../../";
612

713
type Props = {|
14+
...FormEvents,
15+
...FocusEvents,
16+
...MouseEvents,
17+
...PointerEvents,
818
+className?: string,
919
+label?: string,
1020
+value?: string | number | boolean,
@@ -22,6 +32,14 @@ function FormSelectGroupItem({
2232
checked,
2333
icon,
2434
type,
35+
onChange,
36+
onFocus,
37+
onBlur,
38+
onClick,
39+
onMouseEnter,
40+
onMouseLeave,
41+
onPointerEnter,
42+
onPointerLeave,
2543
}: Props): React.Node {
2644
const classes = cn({ "selectgroup-item": true }, className);
2745
const btnClasses = cn("selectgroup-button", {
@@ -37,6 +55,14 @@ function FormSelectGroupItem({
3755
value={value}
3856
className="selectgroup-input"
3957
checked={checked}
58+
onChange={onChange}
59+
onClick={onClick}
60+
onFocus={onFocus}
61+
onBlur={onBlur}
62+
onMouseEnter={onMouseEnter}
63+
onMouseLeave={onMouseLeave}
64+
onPointerEnter={onPointerEnter}
65+
onPointerLeave={onPointerLeave}
4066
/>
4167
) : (
4268
<input
@@ -45,6 +71,14 @@ function FormSelectGroupItem({
4571
value={value}
4672
className="selectgroup-input"
4773
checked={checked}
74+
onChange={onChange}
75+
onClick={onClick}
76+
onFocus={onFocus}
77+
onBlur={onBlur}
78+
onMouseEnter={onMouseEnter}
79+
onMouseLeave={onMouseLeave}
80+
onPointerEnter={onPointerEnter}
81+
onPointerLeave={onPointerLeave}
4882
/>
4983
)}
5084
<span className={btnClasses}>{outputLabel}</span>

0 commit comments

Comments
 (0)