allaw-ui 4.5.4 → 4.5.5
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.
|
@@ -20,6 +20,9 @@ export interface TextAreaProps {
|
|
|
20
20
|
}
|
|
21
21
|
export interface TextAreaRef {
|
|
22
22
|
validate: () => boolean;
|
|
23
|
+
focus: () => void;
|
|
24
|
+
setCursorToEnd: () => void;
|
|
25
|
+
getTextarea: () => HTMLTextAreaElement | null;
|
|
23
26
|
}
|
|
24
27
|
declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<TextAreaRef>>;
|
|
25
28
|
export default TextArea;
|
|
@@ -37,6 +37,19 @@ var TextArea = forwardRef(function (_a, ref) {
|
|
|
37
37
|
}, [isRequired, value, validate, onError]);
|
|
38
38
|
useImperativeHandle(ref, function () { return ({
|
|
39
39
|
validate: validateTextArea,
|
|
40
|
+
focus: function () {
|
|
41
|
+
var _a;
|
|
42
|
+
(_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
43
|
+
},
|
|
44
|
+
setCursorToEnd: function () {
|
|
45
|
+
var textarea = textareaRef.current;
|
|
46
|
+
if (textarea) {
|
|
47
|
+
textarea.focus();
|
|
48
|
+
var length_1 = textarea.value.length;
|
|
49
|
+
textarea.setSelectionRange(length_1, length_1);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
getTextarea: function () { return textareaRef.current; },
|
|
40
53
|
}); });
|
|
41
54
|
var handleChange = function (e) {
|
|
42
55
|
var newValue = e.target.value;
|