react-artasys-ui 0.1.8 → 0.1.11
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/lib/Form/Element/Element.d.ts +2 -1
- package/lib/Form/types.d.ts +5 -1
- package/lib/Input/Input.d.ts +2 -1
- package/lib/Select/Option.d.ts +1 -1
- package/lib/Select/Select.d.ts +2 -2
- package/package.json +2 -2
- package/src/Dropdown/Dropdown.tsx +9 -2
- package/src/File/File.tsx +1 -0
- package/src/Form/Element/Element.tsx +2 -1
- package/src/Form/Element/style.module.css +14 -0
- package/src/Form/types.ts +7 -0
- package/src/Form/useForm.tsx +12 -4
- package/src/Input/Input.tsx +6 -5
- package/src/Select/Option.tsx +4 -2
- package/src/Select/Select.tsx +12 -11
- package/src/Select/style.module.css +12 -5
- package/src/Spinner/style.module.css +4 -0
- package/src/TextArea/TextArea.tsx +3 -3
|
@@ -2,6 +2,7 @@ import { AllHTMLAttributes, ReactElement } from "react";
|
|
|
2
2
|
export interface IElement<T = any> extends Omit<AllHTMLAttributes<T>, 'children'> {
|
|
3
3
|
children?: ((props: AllHTMLAttributes<T>) => ReactElement) | AllHTMLAttributes<T>["children"];
|
|
4
4
|
error?: string;
|
|
5
|
+
formValue?: string | number;
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
placeholder?: string;
|
|
7
8
|
styleContainer?: React.HTMLAttributes<T>["style"];
|
|
@@ -10,5 +11,5 @@ export interface IElement<T = any> extends Omit<AllHTMLAttributes<T>, 'children'
|
|
|
10
11
|
afterElement?: React.ReactElement;
|
|
11
12
|
hiddenContainer?: boolean;
|
|
12
13
|
}
|
|
13
|
-
declare const Element: ({ children, beforeElement, afterElement, error, placeholder, styleContainer, classNameContainer, hiddenContainer, ...props }: IElement) => JSX.Element;
|
|
14
|
+
declare const Element: ({ children, beforeElement, afterElement, error, placeholder, styleContainer, classNameContainer, hiddenContainer, formValue, ...props }: IElement) => JSX.Element;
|
|
14
15
|
export default Element;
|
package/lib/Form/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { FieldValues } from "react-hook-form";
|
|
1
|
+
import type { FieldValues, UseFormRegisterReturn, FieldPath } from "react-hook-form";
|
|
2
|
+
export type TUseFormRegisterReturn<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseFormRegisterReturn<TFieldName> & {
|
|
3
|
+
error?: string;
|
|
4
|
+
formValue: TFieldValues;
|
|
5
|
+
};
|
|
2
6
|
export type TError<TFieldValues extends FieldValues> = {
|
|
3
7
|
errors?: {
|
|
4
8
|
[key in keyof TFieldValues]: string[];
|
package/lib/Input/Input.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { type HTMLInputTypeAttribute } from "react";
|
|
2
2
|
import { IElement } from "../Form/Element";
|
|
3
3
|
interface IInput extends IElement<HTMLInputElement> {
|
|
4
4
|
onChangeText?: (text: string) => void;
|
|
5
|
+
type?: HTMLInputTypeAttribute;
|
|
5
6
|
}
|
|
6
7
|
declare const Input: import("react").ForwardRefExoticComponent<IInput & import("react").RefAttributes<HTMLInputElement>>;
|
|
7
8
|
export default Input;
|
package/lib/Select/Option.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export interface IOption extends LiHTMLAttributes<HTMLLIElement> {
|
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
children?: string | React.ReactElement;
|
|
6
6
|
}
|
|
7
|
-
declare const Option: ({ children, value, disabled, onClick, ...props }: IOption) => JSX.Element;
|
|
7
|
+
declare const Option: ({ children, value, disabled, hidden, onClick, ...props }: IOption) => JSX.Element | null;
|
|
8
8
|
export default Option;
|
package/lib/Select/Select.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionComponentElement } from "react";
|
|
1
|
+
import { FunctionComponentElement, ReactNode } from "react";
|
|
2
2
|
import { IElement } from "../Form/Element";
|
|
3
3
|
import type { IOptgroup } from "./Optgroup";
|
|
4
4
|
import type { IOption } from "./Option";
|
|
@@ -9,7 +9,7 @@ export declare const Context: import("react").Context<{
|
|
|
9
9
|
setSelected: (value: string) => void;
|
|
10
10
|
setTitle: (title: IOption['children']) => void;
|
|
11
11
|
}>;
|
|
12
|
-
export type TOptionElement = FunctionComponentElement<IOption> | FunctionComponentElement<IOption>[];
|
|
12
|
+
export type TOptionElement = FunctionComponentElement<IOption> | FunctionComponentElement<IOption>[] | ReactNode;
|
|
13
13
|
export interface ISelect extends Omit<IElement, 'children'> {
|
|
14
14
|
children?: TOptionElement | FunctionComponentElement<IOptgroup> | FunctionComponentElement<IOptgroup>[];
|
|
15
15
|
onChangeSelect?: (value: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-artasys-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-hook-form": "^7.47.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
|
|
49
|
+
"react": "^18.2.0",
|
|
50
50
|
"react-dom": "^18.2.0"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -28,6 +28,7 @@ export interface IDropdown extends AllHTMLAttributes<HTMLDivElement> {
|
|
|
28
28
|
|
|
29
29
|
const Dropdown = ({children, className, items, direction = 'down', position = 'right', split = false, disabled, hover = false, ...props}: IDropdown) => {
|
|
30
30
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
31
|
+
const hoverTimeout = useRef<ReturnType<typeof setTimeout>>();
|
|
31
32
|
const [isOpen, setOpen] = useState(false);
|
|
32
33
|
|
|
33
34
|
const close = () => {
|
|
@@ -61,7 +62,13 @@ const Dropdown = ({children, className, items, direction = 'down', position = 'r
|
|
|
61
62
|
|
|
62
63
|
const handleMouseEnter = () => {
|
|
63
64
|
if (!hover || isOpen) return;
|
|
64
|
-
toggle
|
|
65
|
+
hoverTimeout.current = setTimeout(toggle, 50);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const handleMouseOut = () => {
|
|
69
|
+
if (hoverTimeout.current) {
|
|
70
|
+
clearTimeout(hoverTimeout.current);
|
|
71
|
+
}
|
|
65
72
|
};
|
|
66
73
|
|
|
67
74
|
useEffect(() => {
|
|
@@ -84,7 +91,7 @@ const Dropdown = ({children, className, items, direction = 'down', position = 'r
|
|
|
84
91
|
return(<Context.Provider value={{
|
|
85
92
|
close
|
|
86
93
|
}}>
|
|
87
|
-
<div {...props} className={classes.join(' ')} ref={containerRef} onMouseEnter={handleMouseEnter} tabIndex={1} onBlur={handleBlur}>
|
|
94
|
+
<div {...props} className={classes.join(' ')} ref={containerRef} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseOut} tabIndex={1} onBlur={handleBlur}>
|
|
88
95
|
{(position === 'left' && !disabled) && <Arrow className={styles['arrow']} onClick={handleClickArrow}/>}
|
|
89
96
|
<div onClick={handleClick}>
|
|
90
97
|
{children}
|
package/src/File/File.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import styles from "./style.module.css";
|
|
|
10
10
|
export interface IElement<T = any> extends Omit<AllHTMLAttributes<T>, 'children'> {
|
|
11
11
|
children?: ((props: AllHTMLAttributes<T>) => ReactElement) | AllHTMLAttributes<T>["children"];
|
|
12
12
|
error?: string;
|
|
13
|
+
formValue?: string | number;
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
placeholder?: string;
|
|
15
16
|
styleContainer?: React.HTMLAttributes<T>["style"];
|
|
@@ -19,7 +20,7 @@ export interface IElement<T = any> extends Omit<AllHTMLAttributes<T>, 'children'
|
|
|
19
20
|
hiddenContainer?: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const Element = ({children, beforeElement, afterElement, error, placeholder, styleContainer, classNameContainer, hiddenContainer, ...props}: IElement) => {
|
|
23
|
+
const Element = ({children, beforeElement, afterElement, error, placeholder, styleContainer, classNameContainer, hiddenContainer, formValue, ...props}: IElement) => {
|
|
23
24
|
const [currentError, setCurrentError] = useState('');
|
|
24
25
|
|
|
25
26
|
useEffect(() => {
|
|
@@ -83,6 +83,20 @@
|
|
|
83
83
|
content: "*";
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/* Date */
|
|
87
|
+
.element > input[type="date"]::-webkit-calendar-picker-indicator {
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
border-radius: 4px;
|
|
90
|
+
margin-right: 2px;
|
|
91
|
+
opacity: 0.7;
|
|
92
|
+
filter: invert(0.8);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.element > input[type="date"]::-webkit-calendar-picker-indicator:hover {
|
|
96
|
+
opacity: 1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.element > input[type="date"] ~ .placeholder,
|
|
86
100
|
.element > input:focus ~ .placeholder,
|
|
87
101
|
.element > textarea:focus ~ .placeholder,
|
|
88
102
|
.element > input:not([value=""]) ~ .placeholder,
|
package/src/Form/types.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
FieldValues,
|
|
3
|
+
UseFormRegisterReturn,
|
|
4
|
+
FieldPath
|
|
3
5
|
} from "react-hook-form";
|
|
4
6
|
|
|
7
|
+
export type TUseFormRegisterReturn<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = UseFormRegisterReturn<TFieldName> & {
|
|
8
|
+
error?: string;
|
|
9
|
+
formValue: TFieldValues;
|
|
10
|
+
};
|
|
11
|
+
|
|
5
12
|
export type TError<TFieldValues extends FieldValues> = {
|
|
6
13
|
errors?: {
|
|
7
14
|
[key in keyof TFieldValues]: string[];
|
package/src/Form/useForm.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, FunctionComponent } from "react";
|
|
2
|
-
import type { TError } from "./types";
|
|
2
|
+
import type { TError, TUseFormRegisterReturn } from "./types";
|
|
3
3
|
import styles from "./style.module.css";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
RegisterOptions,
|
|
9
9
|
UseFormRegisterReturn,
|
|
10
10
|
FieldValues,
|
|
11
|
-
|
|
11
|
+
SetValueConfig,
|
|
12
|
+
FieldPathValue,
|
|
12
13
|
FieldPath
|
|
13
14
|
} from "react-hook-form";
|
|
14
15
|
|
|
@@ -24,7 +25,7 @@ const useForm = <TFieldValues extends FieldValues = FieldValues>(): TuseErrors<T
|
|
|
24
25
|
reValidateMode: 'onChange'
|
|
25
26
|
});
|
|
26
27
|
|
|
27
|
-
const register = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: RegisterOptions<TFieldValues, TFieldName>):
|
|
28
|
+
const register = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: RegisterOptions<TFieldValues, TFieldName>): TUseFormRegisterReturn<TFieldValues, TFieldName> => {
|
|
28
29
|
const inputRegister = form.register<TFieldName>(name, options);
|
|
29
30
|
const onChange = (e: {
|
|
30
31
|
target: any;
|
|
@@ -34,8 +35,15 @@ const useForm = <TFieldValues extends FieldValues = FieldValues>(): TuseErrors<T
|
|
|
34
35
|
form.clearErrors(name);
|
|
35
36
|
return inputRegister.onChange(e);
|
|
36
37
|
};
|
|
38
|
+
const formValue = form.watch(name);
|
|
37
39
|
const errors = form?.formState.errors;
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...inputRegister,
|
|
43
|
+
onChange,
|
|
44
|
+
formValue,
|
|
45
|
+
error: errors?.[name]?.message?.toString()
|
|
46
|
+
};
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
const setErrors = (e: TError<TFieldValues>) => {
|
package/src/Input/Input.tsx
CHANGED
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
forwardRef,
|
|
3
3
|
useState,
|
|
4
4
|
ChangeEvent,
|
|
5
|
-
useEffect
|
|
5
|
+
useEffect,
|
|
6
|
+
type HTMLInputTypeAttribute
|
|
6
7
|
} from "react";
|
|
7
8
|
import Element,{
|
|
8
9
|
IElement
|
|
@@ -11,9 +12,10 @@ import Element,{
|
|
|
11
12
|
|
|
12
13
|
interface IInput extends IElement<HTMLInputElement> {
|
|
13
14
|
onChangeText?: (text: string) => void;
|
|
15
|
+
type?: HTMLInputTypeAttribute;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
const Input = forwardRef<HTMLInputElement, IInput>(({onChange, onInput, onChangeText, ...props}, ref) => {
|
|
18
|
+
const Input = forwardRef<HTMLInputElement, IInput>(({onChange, onInput, onChangeText, formValue, ...props}, ref) => {
|
|
17
19
|
const [currentValue, setCurrentValue] = useState<string | undefined>('');
|
|
18
20
|
|
|
19
21
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -35,9 +37,8 @@ const Input = forwardRef<HTMLInputElement, IInput>(({onChange, onInput, onChange
|
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
useEffect(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, [props.value]);
|
|
40
|
+
setCurrentValue(String(props.value ?? formValue));
|
|
41
|
+
}, [props.value, formValue]);
|
|
41
42
|
|
|
42
43
|
return(<Element {...props}>
|
|
43
44
|
{ (props) => <input {...props} placeholder="" onChange={handleChange} value={currentValue} onInput={handleInput} ref={ref}/> }
|
package/src/Select/Option.tsx
CHANGED
|
@@ -13,7 +13,7 @@ export interface IOption extends LiHTMLAttributes<HTMLLIElement> {
|
|
|
13
13
|
children?: string | React.ReactElement;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const Option = ({children, value, disabled, onClick, ...props}: IOption) => {
|
|
16
|
+
const Option = ({children, value, disabled, hidden, onClick, ...props}: IOption) => {
|
|
17
17
|
const context = useContext(Context);
|
|
18
18
|
|
|
19
19
|
const handleClick = (e: MouseEvent<HTMLLIElement>) => {
|
|
@@ -33,12 +33,14 @@ const Option = ({children, value, disabled, onClick, ...props}: IOption) => {
|
|
|
33
33
|
context.emptyValue.current = true;
|
|
34
34
|
}
|
|
35
35
|
}, [context.selected]);
|
|
36
|
+
|
|
37
|
+
if (hidden) return(null);
|
|
36
38
|
|
|
37
39
|
const classes = ['ui-select-option'];
|
|
38
40
|
classes.push(styles['option']);
|
|
39
41
|
if (context.selected === value) classes.push(styles['active'], 'active');
|
|
40
42
|
if (disabled) classes.push(styles['disabled'], 'disabled');
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
return(<li {...props} onClick={handleClick} className={classes.join(' ')}>{children}</li>);
|
|
43
45
|
};
|
|
44
46
|
|
package/src/Select/Select.tsx
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
useRef,
|
|
7
7
|
ChangeEvent,
|
|
8
8
|
useImperativeHandle,
|
|
9
|
-
FunctionComponentElement
|
|
9
|
+
FunctionComponentElement,
|
|
10
|
+
ReactNode
|
|
10
11
|
} from "react";
|
|
11
12
|
import Element,{
|
|
12
13
|
IElement
|
|
@@ -24,14 +25,14 @@ export const Context = createContext({
|
|
|
24
25
|
setTitle: (title: IOption['children']) => {},
|
|
25
26
|
});
|
|
26
27
|
|
|
27
|
-
export type TOptionElement = FunctionComponentElement<IOption> | FunctionComponentElement<IOption>[];
|
|
28
|
+
export type TOptionElement = FunctionComponentElement<IOption> | FunctionComponentElement<IOption>[] | ReactNode;
|
|
28
29
|
|
|
29
30
|
export interface ISelect extends Omit<IElement, 'children'> {
|
|
30
31
|
children?: TOptionElement | FunctionComponentElement<IOptgroup> | FunctionComponentElement<IOptgroup>[];
|
|
31
32
|
onChangeSelect?: (value: string) => void;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
const Select = forwardRef<HTMLInputElement, ISelect>(({children, onChangeSelect, value, ...props}, ref) => {
|
|
35
|
+
const Select = forwardRef<HTMLInputElement, ISelect>(({children, onChangeSelect, value, formValue, ...props}, ref) => {
|
|
35
36
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
36
37
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
37
38
|
const emptyValue = useRef(false);
|
|
@@ -61,12 +62,13 @@ const Select = forwardRef<HTMLInputElement, ISelect>(({children, onChangeSelect,
|
|
|
61
62
|
inputRef.current!.dispatchEvent(event);
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
const setSelect = (
|
|
65
|
+
const setSelect = (val: string) => {
|
|
65
66
|
if (typeof onChangeSelect === 'function') {
|
|
66
|
-
onChangeSelect(
|
|
67
|
+
onChangeSelect(val);
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === 'undefined') {
|
|
70
|
+
setSelected(val);
|
|
67
71
|
}
|
|
68
|
-
|
|
69
|
-
setSelected(value);
|
|
70
72
|
close();
|
|
71
73
|
};
|
|
72
74
|
|
|
@@ -86,11 +88,10 @@ const Select = forwardRef<HTMLInputElement, ISelect>(({children, onChangeSelect,
|
|
|
86
88
|
if (!selected) return;
|
|
87
89
|
triggerNativeEvent(selected);
|
|
88
90
|
}, [selected]);
|
|
89
|
-
|
|
91
|
+
|
|
90
92
|
useEffect(() => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, [value]);
|
|
93
|
+
setSelected(String(value ?? formValue));
|
|
94
|
+
}, [value, formValue]);
|
|
94
95
|
|
|
95
96
|
useEffect(() => {
|
|
96
97
|
const element = containerRef.current;
|
|
@@ -35,25 +35,32 @@
|
|
|
35
35
|
position: absolute;
|
|
36
36
|
display: flex;
|
|
37
37
|
flex-direction: column;
|
|
38
|
-
width: 100%;
|
|
38
|
+
min-width: 100%;
|
|
39
39
|
max-height: 40vh;
|
|
40
|
-
|
|
40
|
+
max-height: 40dvh;
|
|
41
41
|
top: calc(100% - 1px);
|
|
42
|
-
|
|
42
|
+
right: -1px;
|
|
43
43
|
margin: 0;
|
|
44
44
|
padding: 0;
|
|
45
45
|
list-style-type: none;
|
|
46
46
|
background-color: #FFFFFF;
|
|
47
47
|
box-shadow: 0px 4px 5px 0px rgb(0 0 0 / 10%);
|
|
48
|
-
|
|
48
|
+
border: 1px solid #CCCCCC;
|
|
49
49
|
overflow: auto;
|
|
50
|
-
border-top: 0;
|
|
51
50
|
opacity: 0;
|
|
52
51
|
visibility: hidden;
|
|
53
52
|
transform: translateY(-10%);
|
|
54
53
|
transition: transform 0.3s ease-in-out, opacity 0.3s, visibility 0.3s;
|
|
55
54
|
}
|
|
56
55
|
|
|
56
|
+
.container.left > .select-list {
|
|
57
|
+
left: -1px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.container.right > .select-list {
|
|
61
|
+
right: -1px;
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
.container.hidden > .select-list {
|
|
58
65
|
display: none;
|
|
59
66
|
}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
.spinner {
|
|
4
4
|
--color-rgb: 94, 190, 214;
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
5
8
|
width: 100%;
|
|
6
9
|
height: 100%;
|
|
7
10
|
max-width: 100px;
|
|
@@ -9,6 +12,7 @@
|
|
|
9
12
|
aspect-ratio: 1/1;
|
|
10
13
|
padding-left: calc(-0.5rem / 2);
|
|
11
14
|
padding-right: calc(-0.5rem / 2);
|
|
15
|
+
overflow: hidden;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
.spinner::before {
|
|
@@ -14,7 +14,7 @@ interface ITextArea extends IElement<HTMLTextAreaElement> {
|
|
|
14
14
|
onChangeText?: (text: string) => void;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const TextArea = forwardRef<HTMLTextAreaElement, ITextArea>(({onChange, onInput, onChangeText, ...props}, ref) => {
|
|
17
|
+
const TextArea = forwardRef<HTMLTextAreaElement, ITextArea>(({onChange, onInput, onChangeText, formValue, ...props}, ref) => {
|
|
18
18
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
19
19
|
const [currentValue, setCurrentValue] = useState(props.value);
|
|
20
20
|
|
|
@@ -44,8 +44,8 @@ const TextArea = forwardRef<HTMLTextAreaElement, ITextArea>(({onChange, onInput,
|
|
|
44
44
|
},[currentValue]);
|
|
45
45
|
|
|
46
46
|
useEffect(() => {
|
|
47
|
-
setCurrentValue(props.value);
|
|
48
|
-
}, [props.value]);
|
|
47
|
+
setCurrentValue(props.value ?? formValue);
|
|
48
|
+
}, [props.value, formValue]);
|
|
49
49
|
|
|
50
50
|
useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);
|
|
51
51
|
|