@expressms/smartapp-ui 3.0.0-alpha.87 → 3.0.0-alpha.88
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ITextareaProps } from './types';
|
|
2
2
|
import '../../styles/styles.scss';
|
|
3
|
-
declare const Textarea: ({ fontFamily, isAdjustToTextHeight, textareaRef: outerTextareaRef, title, icon, error, minHeight, containerClassName, className, style, containerStyles, onChange, ...props }: ITextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const Textarea: ({ fontFamily, isAdjustToTextHeight, isFocused, textareaRef: outerTextareaRef, title, icon, error, minHeight, containerClassName, className, style, containerStyles, onChange, ...props }: ITextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default Textarea;
|
|
@@ -28,7 +28,7 @@ import { generateFontFamilyStyle } from '../../helpers';
|
|
|
28
28
|
import { DEFAULT_MIN_TEXTAREA_HEIGHT, MIN_TEXTAREA_HEIGHT } from '../../constants';
|
|
29
29
|
import '../../styles/styles.scss';
|
|
30
30
|
var Textarea = function (_a) {
|
|
31
|
-
var fontFamily = _a.fontFamily, _b = _a.isAdjustToTextHeight, isAdjustToTextHeight = _b === void 0 ? false : _b, outerTextareaRef = _a.textareaRef, title = _a.title, icon = _a.icon, error = _a.error, minHeight = _a.minHeight, containerClassName = _a.containerClassName, className = _a.className, style = _a.style, containerStyles = _a.containerStyles, onChange = _a.onChange, props = __rest(_a, ["fontFamily", "isAdjustToTextHeight", "textareaRef", "title", "icon", "error", "minHeight", "containerClassName", "className", "style", "containerStyles", "onChange"]);
|
|
31
|
+
var fontFamily = _a.fontFamily, _b = _a.isAdjustToTextHeight, isAdjustToTextHeight = _b === void 0 ? false : _b, _c = _a.isFocused, isFocused = _c === void 0 ? false : _c, outerTextareaRef = _a.textareaRef, title = _a.title, icon = _a.icon, error = _a.error, minHeight = _a.minHeight, containerClassName = _a.containerClassName, className = _a.className, style = _a.style, containerStyles = _a.containerStyles, onChange = _a.onChange, props = __rest(_a, ["fontFamily", "isAdjustToTextHeight", "isFocused", "textareaRef", "title", "icon", "error", "minHeight", "containerClassName", "className", "style", "containerStyles", "onChange"]);
|
|
32
32
|
var localTextareaRef = useRef(null);
|
|
33
33
|
var textareaRef = outerTextareaRef || localTextareaRef;
|
|
34
34
|
var textareaMinHeight = minHeight ? Math.max(minHeight, MIN_TEXTAREA_HEIGHT) : DEFAULT_MIN_TEXTAREA_HEIGHT;
|
|
@@ -53,6 +53,31 @@ var Textarea = function (_a) {
|
|
|
53
53
|
isAdjustToTextHeight && handleInput();
|
|
54
54
|
// eslint-disable-next-line
|
|
55
55
|
}, [isAdjustToTextHeight]);
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
if (!isFocused || props.disabled)
|
|
58
|
+
return;
|
|
59
|
+
var focusTextarea = function () {
|
|
60
|
+
var textareaRefCurrent = textareaRef.current;
|
|
61
|
+
if (!textareaRefCurrent)
|
|
62
|
+
return;
|
|
63
|
+
var textareaValueLength = textareaRefCurrent.value.length;
|
|
64
|
+
textareaRefCurrent.focus({ preventScroll: true });
|
|
65
|
+
if (document.activeElement !== textareaRefCurrent)
|
|
66
|
+
textareaRefCurrent.focus();
|
|
67
|
+
try {
|
|
68
|
+
textareaRefCurrent.setSelectionRange(textareaValueLength, textareaValueLength);
|
|
69
|
+
}
|
|
70
|
+
catch (_a) {
|
|
71
|
+
// noop
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var animationFrameId = requestAnimationFrame(focusTextarea);
|
|
75
|
+
var focusTimeoutId = setTimeout(focusTextarea, 80);
|
|
76
|
+
return function () {
|
|
77
|
+
cancelAnimationFrame(animationFrameId);
|
|
78
|
+
clearTimeout(focusTimeoutId);
|
|
79
|
+
};
|
|
80
|
+
}, [isFocused, props.disabled, textareaRef]);
|
|
56
81
|
return (_jsxs("div", __assign({ className: classNames('smartapp-textarea', containerClassName), style: __assign(__assign({}, generateFontFamilyStyle(fontFamily)), containerStyles) }, { children: [title && _jsx("div", __assign({ className: "smartapp-textarea__title" }, { children: title })), _jsxs("div", __assign({ className: "smartapp-textarea__container" }, { children: [_jsx("textarea", __assign({ ref: textareaRef, className: classNames('smartapp-textarea__container--field', { 'smartapp-textarea__container--field__with-icon': !isNil(icon), 'smartapp-textarea__container--field__error': !isEmpty(error) }, className), style: __assign({ '--textarea-min-height': textareaMinHeightPx }, style), onChange: handleChange, onInput: handleInput }, props), textareaMinHeightPx), icon && _jsx("div", __assign({ className: "smartapp-textarea__container--icon" }, { children: icon }))] })), error && _jsx("div", __assign({ className: "smartapp-textarea__error" }, { children: error }))] })));
|
|
57
82
|
};
|
|
58
83
|
export default Textarea;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../../../src/сomponents/Textarea/Textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAiB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAElF,OAAO,0BAA0B,CAAA;AAEjC,IAAM,QAAQ,GAAG,UAAC,
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../../../src/сomponents/Textarea/Textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAiB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,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AAO,CACL,wBAAK,SAAS,EAAE,UAAU,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,EAAE,KAAK,wBAAO,uBAAuB,CAAC,UAAU,CAAC,GAAK,eAAe,kBACrI,KAAK,IAAI,uBAAK,SAAS,EAAC,0BAA0B,gBAAE,KAAK,IAAO,EACjE,wBAAK,SAAS,EAAC,8BAA8B,iBAC3C,4BAEE,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,UAAU,CACnB,qCAAqC,EACrC,EAAE,gDAAgD,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,4CAA4C,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EACjI,SAAS,CACV,EACD,KAAK,EAAE,WAAE,uBAAuB,EAAE,mBAAmB,IAAK,KAAK,CAAmB,EAClF,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,WAAW,IAChB,KAAK,GAVJ,mBAAmB,CAWxB,EACD,IAAI,IAAI,uBAAK,SAAS,EAAC,oCAAoC,gBAAE,IAAI,IAAO,KACrE,EACL,KAAK,IAAI,uBAAK,SAAS,EAAC,0BAA0B,gBAAE,KAAK,IAAO,KAC7D,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { ChangeEvent, ReactElement, RefObject, TextareaHTMLAttributes } from 're
|
|
|
2
2
|
import { IFontFamilyProps, TStyles } from '../../constants';
|
|
3
3
|
export interface ITextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement>, IFontFamilyProps {
|
|
4
4
|
isAdjustToTextHeight?: boolean;
|
|
5
|
+
isFocused?: boolean;
|
|
5
6
|
textareaRef?: RefObject<HTMLTextAreaElement | null>;
|
|
6
7
|
title?: string;
|
|
7
8
|
icon?: ReactElement;
|