Download tabler-react/src/components/Form/FormSelectGroupItem.react.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Form/FormSelectGroupItem.react.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Form/FormSelectGroupItem.react.js
-
curl -L -o FormSelectGroupItem.react.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/src/components/Form/FormSelectGroupItem.react.js
2.04 kB
| // @flow | |
| import * as React from "react"; | |
| import cn from "classnames"; | |
| import { Icon } from "../"; | |
| import type { | |
| FormEvents, | |
| FocusEvents, | |
| MouseEvents, | |
| PointerEvents, | |
| } from "../../"; | |
| type Props = {| | |
| ...FormEvents, | |
| ...FocusEvents, | |
| ...MouseEvents, | |
| ...PointerEvents, | |
| +className?: string, | |
| +label?: string, | |
| +value?: string | number | boolean, | |
| +name: string, | |
| +checked?: boolean, | |
| +icon?: string, | |
| +type?: "radio" | "checkbox", | |
| |}; | |
| function FormSelectGroupItem({ | |
| className, | |
| label, | |
| name, | |
| value, | |
| checked, | |
| icon, | |
| type, | |
| onChange, | |
| onFocus, | |
| onBlur, | |
| onClick, | |
| onMouseEnter, | |
| onMouseLeave, | |
| onPointerEnter, | |
| onPointerLeave, | |
| }: Props): React.Node { | |
| const classes = cn({ "selectgroup-item": true }, className); | |
| const btnClasses = cn("selectgroup-button", { | |
| "selectgroup-button-icon": icon, | |
| }); | |
| const outputLabel = icon ? <Icon name={icon} /> : label; | |
| return ( | |
| <label className={classes}> | |
| {type === "checkbox" ? ( | |
| <input | |
| type="checkbox" | |
| name={name} | |
| value={value} | |
| className="selectgroup-input" | |
| checked={checked} | |
| onChange={onChange} | |
| onClick={onClick} | |
| onFocus={onFocus} | |
| onBlur={onBlur} | |
| onMouseEnter={onMouseEnter} | |
| onMouseLeave={onMouseLeave} | |
| onPointerEnter={onPointerEnter} | |
| onPointerLeave={onPointerLeave} | |
| /> | |
| ) : ( | |
| <input | |
| type="radio" | |
| name={name} | |
| value={value} | |
| className="selectgroup-input" | |
| checked={checked} | |
| onChange={onChange} | |
| onClick={onClick} | |
| onFocus={onFocus} | |
| onBlur={onBlur} | |
| onMouseEnter={onMouseEnter} | |
| onMouseLeave={onMouseLeave} | |
| onPointerEnter={onPointerEnter} | |
| onPointerLeave={onPointerLeave} | |
| /> | |
| )} | |
| <span className={btnClasses}>{outputLabel}</span> | |
| </label> | |
| ); | |
| } | |
| FormSelectGroupItem.displayName = "Form.SelectGroupItem"; | |
| export default FormSelectGroupItem; | |