|
1 | 1 | import { IPUIProps } from 'pragmate-ui/base';
|
2 | 2 | import React, { MutableRefObject, useRef } from 'react';
|
3 |
| -import { IFormProps } from './types'; |
| 3 | +import { IFormProps } from './types/interfaces'; |
4 | 4 |
|
5 |
| -interface IPropsRadio extends InputHTMLAttributes<HTMLInputElement> { |
6 |
| - label?: string; |
7 |
| -} |
8 |
| - |
9 |
| -type CombinedProps = IPropsRadio & IPUIProps<HTMLInputElement>; |
10 |
| - |
11 |
| -export /*bundle*/ function Radio(props: CombinedProps): JSX.Element { |
12 |
| - const input: MutableRefObject<HTMLInputElement> = useRef<HTMLInputElement>(null); |
| 5 | +export /*bundle*/ function Radio(props: IFormProps): JSX.Element { |
| 6 | + const input: MutableRefObject<HTMLInputElement> = useRef<HTMLInputElement>(null); |
13 | 7 |
|
14 |
| - const onClick = (event): void => { |
15 |
| - event.stopPropagation(); |
16 |
| - input.current.checked = true; |
17 |
| - if (!!props.onChange) props.onChange(event); |
18 |
| - }; |
| 8 | + const onClick = (event): void => { |
| 9 | + event.stopPropagation(); |
| 10 | + input.current.checked = true; |
| 11 | + if (!!props.onChange) props.onChange(event); |
| 12 | + }; |
19 | 13 |
|
20 | 14 | const properties: IFormProps = { ...props };
|
21 | 15 | delete properties.onChange;
|
22 | 16 |
|
23 |
| - const cls: string = `pragmate-element-radio ${properties.className ? properties.className : ''}`; |
| 17 | + const cls: string = `pragmate-element-radio ${properties.className ? properties.className : ''}`; |
24 | 18 |
|
25 |
| - return ( |
26 |
| - <label className={cls} onClick={onClick}> |
27 |
| - <input ref={input} {...properties} type='radio' onChange={onClick} /> |
28 |
| - {properties.label && <span>{properties.label}</span>} |
29 |
| - </label> |
30 |
| - ); |
| 19 | + return ( |
| 20 | + <label className={cls} onClick={onClick}> |
| 21 | + <input ref={input} {...properties} type='radio' onChange={onClick} /> |
| 22 | + {properties.label && <span>{properties.label}</span>} |
| 23 | + </label> |
| 24 | + ); |
31 | 25 | }
|
0 commit comments