forstok-ui-lib 7.6.1 → 7.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/emoji/styles.ts +2 -2
- package/src/components/radio/index.tsx +27 -4
package/package.json
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { useEffect, useState, type ChangeEvent, type InputHTMLAttributes, type ReactNode } from 'react';
|
|
2
2
|
import { RadioContainer, RadioInput, RadioSpan } from './styles';
|
|
3
|
+
import { TState } from '../../typeds/base.typed';
|
|
3
4
|
|
|
4
5
|
type TRadio = InputHTMLAttributes<HTMLInputElement> & {
|
|
5
6
|
children?: ReactNode
|
|
6
7
|
$mode?: string
|
|
7
8
|
evChange?: (e: ChangeEvent<HTMLInputElement>) => void
|
|
9
|
+
reset?: boolean
|
|
10
|
+
setReset?: TState<boolean>
|
|
11
|
+
isForceUpdate?: boolean
|
|
12
|
+
setForceUpdate?: TState<boolean>
|
|
8
13
|
'data-qa-id'?: string
|
|
9
14
|
};
|
|
10
15
|
|
|
11
|
-
const RadioComponent = ({ children, $mode, evChange
|
|
12
|
-
const { id } = props;
|
|
16
|
+
const RadioComponent = ({ children, $mode, evChange, reset, setReset, isForceUpdate, setForceUpdate, ...props }: TRadio) => {
|
|
17
|
+
const { id, defaultChecked } = props;
|
|
18
|
+
|
|
19
|
+
const [inputChecked, evInputChecked] = useState<boolean>(defaultChecked||false);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isForceUpdate) {
|
|
23
|
+
evInputChecked(defaultChecked||false);
|
|
24
|
+
setForceUpdate && setForceUpdate(false);
|
|
25
|
+
}
|
|
26
|
+
if (reset) {
|
|
27
|
+
evInputChecked(false);
|
|
28
|
+
setReset && setReset(false);
|
|
29
|
+
}
|
|
30
|
+
}, [isForceUpdate, setForceUpdate, reset, setReset, defaultChecked, evInputChecked])
|
|
31
|
+
|
|
32
|
+
let parseProps = {...props};
|
|
33
|
+
delete parseProps.defaultChecked;
|
|
34
|
+
|
|
13
35
|
return (
|
|
14
36
|
<RadioContainer>
|
|
15
37
|
<label htmlFor={id}>
|
|
@@ -17,10 +39,11 @@ const RadioComponent = ({ children, $mode, evChange,...props }: TRadio) => {
|
|
|
17
39
|
type='radio'
|
|
18
40
|
id={id}
|
|
19
41
|
$mode={$mode}
|
|
42
|
+
checked={inputChecked}
|
|
20
43
|
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
21
44
|
evChange && evChange(e)
|
|
22
45
|
}}
|
|
23
|
-
{...
|
|
46
|
+
{...parseProps} />
|
|
24
47
|
<RadioSpan $mode={$mode} {...props['data-qa-id'] && { 'data-qa-id': props['data-qa-id'] }}>{children}</RadioSpan>
|
|
25
48
|
</label>
|
|
26
49
|
</RadioContainer>
|