@hh.ru/magritte-ui-textarea 3.3.53 → 3.3.55

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/TextArea.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { type TextAreaLayout, type ControlledTextAreaProps } from '@hh.ru/magritte-ui-textarea/types';
3
- declare const TextArea: (<Layout extends TextAreaLayout>(props: ControlledTextAreaProps<Layout> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof ControlledTextAreaProps<"fixed">> & {
2
+ import { type TextAreaLayout, type ControlledTextAreaProps } from './types';
3
+ declare const TextArea: (<Layout extends TextAreaLayout>(props: ControlledTextAreaProps<Layout> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof ControlledTextAreaProps<'fixed'>> & {
4
4
  ref?: React.ForwardedRef<HTMLTextAreaElement>;
5
5
  }) => ReactElement | null) & {
6
6
  displayName: string;
package/TextArea.js CHANGED
@@ -19,145 +19,254 @@ import './types.js';
19
19
  import './TextAreaGrowLimiter.js';
20
20
  import '@hh.ru/magritte-common-func-utils';
21
21
 
22
- var styles = {"textarea":"magritte-textarea___ugvor_3-3-53","textarea-elevated":"magritte-textarea-elevated___S0jk-_3-3-53","textareaElevated":"magritte-textarea-elevated___S0jk-_3-3-53","textarea-small":"magritte-textarea-small___Q-tsg_3-3-53","textareaSmall":"magritte-textarea-small___Q-tsg_3-3-53","textarea-medium":"magritte-textarea-medium___GNzAm_3-3-53","textareaMedium":"magritte-textarea-medium___GNzAm_3-3-53","textarea-large":"magritte-textarea-large___ugT-5_3-3-53","textareaLarge":"magritte-textarea-large___ugT-5_3-3-53","has-grip":"magritte-has-grip___ATMYQ_3-3-53","hasGrip":"magritte-has-grip___ATMYQ_3-3-53","textarea-limited":"magritte-textarea-limited___cU1Rg_3-3-53","textareaLimited":"magritte-textarea-limited___cU1Rg_3-3-53","maxed-height":"magritte-maxed-height___v1wYG_3-3-53","maxedHeight":"magritte-maxed-height___v1wYG_3-3-53","textarea-focused":"magritte-textarea-focused___eiGyC_3-3-53","textareaFocused":"magritte-textarea-focused___eiGyC_3-3-53","textarea-invalid":"magritte-textarea-invalid___iKOPh_3-3-53","textareaInvalid":"magritte-textarea-invalid___iKOPh_3-3-53","textarea-disabled":"magritte-textarea-disabled___XN0cg_3-3-53","textareaDisabled":"magritte-textarea-disabled___XN0cg_3-3-53","textarea-position-container-wrapper":"magritte-textarea-position-container-wrapper___4Dsui_3-3-53","textareaPositionContainerWrapper":"magritte-textarea-position-container-wrapper___4Dsui_3-3-53","textarea-position-container":"magritte-textarea-position-container___cEpbv_3-3-53","textareaPositionContainer":"magritte-textarea-position-container___cEpbv_3-3-53","native-element":"magritte-native-element___a0RAE_3-3-53","nativeElement":"magritte-native-element___a0RAE_3-3-53","textarea-label":"magritte-textarea-label___sgTIH_3-3-53","textareaLabel":"magritte-textarea-label___sgTIH_3-3-53","textarea-label-elevated":"magritte-textarea-label-elevated___0lxOI_3-3-53","textareaLabelElevated":"magritte-textarea-label-elevated___0lxOI_3-3-53","textarea-limit":"magritte-textarea-limit___IjPJy_3-3-53","textareaLimit":"magritte-textarea-limit___IjPJy_3-3-53","textarea-limit-error":"magritte-textarea-limit-error___vLvZU_3-3-53","textareaLimitError":"magritte-textarea-limit-error___vLvZU_3-3-53","textarea-layout-fill-both":"magritte-textarea-layout-fill-both___ERS-q_3-3-53","textareaLayoutFillBoth":"magritte-textarea-layout-fill-both___ERS-q_3-3-53","textarea-layout-fill-vertical":"magritte-textarea-layout-fill-vertical___HmNtp_3-3-53","textareaLayoutFillVertical":"magritte-textarea-layout-fill-vertical___HmNtp_3-3-53","textarea-layout-fill-horizontal":"magritte-textarea-layout-fill-horizontal___imBH2_3-3-53","textareaLayoutFillHorizontal":"magritte-textarea-layout-fill-horizontal___imBH2_3-3-53","textarea-layout-hug":"magritte-textarea-layout-hug___tdCMY_3-3-53","textareaLayoutHug":"magritte-textarea-layout-hug___tdCMY_3-3-53","textarea-wrapper":"magritte-textarea-wrapper___yD7G6_3-3-53","textareaWrapper":"magritte-textarea-wrapper___yD7G6_3-3-53","value-clone-wrapper":"magritte-value-clone-wrapper___2ZZvS_3-3-53","valueCloneWrapper":"magritte-value-clone-wrapper___2ZZvS_3-3-53","value-clone-container":"magritte-value-clone-container___PVM97_3-3-53","valueCloneContainer":"magritte-value-clone-container___PVM97_3-3-53","side-padding":"magritte-side-padding___O-HUP_3-3-53","sidePadding":"magritte-side-padding___O-HUP_3-3-53","textarea-animation-timeout":"magritte-textarea-animation-timeout___zudbr_3-3-53","textareaAnimationTimeout":"magritte-textarea-animation-timeout___zudbr_3-3-53","textarea-rigging-container":"magritte-textarea-rigging-container___-1S6i_3-3-53","textareaRiggingContainer":"magritte-textarea-rigging-container___-1S6i_3-3-53","label-no-wrap":"magritte-label-no-wrap___RxZ3A_3-3-53","labelNoWrap":"magritte-label-no-wrap___RxZ3A_3-3-53","textarea-grip":"magritte-textarea-grip___iL7lq_3-3-53","textareaGrip":"magritte-textarea-grip___iL7lq_3-3-53","textarea-grip-icon":"magritte-textarea-grip-icon___YK-9w_3-3-53","textareaGripIcon":"magritte-textarea-grip-icon___YK-9w_3-3-53","textarea-limit-enter":"magritte-textarea-limit-enter___CygGz_3-3-53","textareaLimitEnter":"magritte-textarea-limit-enter___CygGz_3-3-53","textarea-limit-exit":"magritte-textarea-limit-exit___RMp-R_3-3-53","textareaLimitExit":"magritte-textarea-limit-exit___RMp-R_3-3-53","textarea-limit-enter-active":"magritte-textarea-limit-enter-active___8vN-t_3-3-53","textareaLimitEnterActive":"magritte-textarea-limit-enter-active___8vN-t_3-3-53","textarea-limit-exit-active":"magritte-textarea-limit-exit-active___a5kBr_3-3-53","textareaLimitExitActive":"magritte-textarea-limit-exit-active___a5kBr_3-3-53"};
22
+ var styles = {"textarea":"magritte-textarea___ugvor_3-3-55","textarea-elevated":"magritte-textarea-elevated___S0jk-_3-3-55","textareaElevated":"magritte-textarea-elevated___S0jk-_3-3-55","textarea-small":"magritte-textarea-small___Q-tsg_3-3-55","textareaSmall":"magritte-textarea-small___Q-tsg_3-3-55","textarea-medium":"magritte-textarea-medium___GNzAm_3-3-55","textareaMedium":"magritte-textarea-medium___GNzAm_3-3-55","textarea-large":"magritte-textarea-large___ugT-5_3-3-55","textareaLarge":"magritte-textarea-large___ugT-5_3-3-55","has-grip":"magritte-has-grip___ATMYQ_3-3-55","hasGrip":"magritte-has-grip___ATMYQ_3-3-55","textarea-limited":"magritte-textarea-limited___cU1Rg_3-3-55","textareaLimited":"magritte-textarea-limited___cU1Rg_3-3-55","maxed-height":"magritte-maxed-height___v1wYG_3-3-55","maxedHeight":"magritte-maxed-height___v1wYG_3-3-55","textarea-focused":"magritte-textarea-focused___eiGyC_3-3-55","textareaFocused":"magritte-textarea-focused___eiGyC_3-3-55","textarea-invalid":"magritte-textarea-invalid___iKOPh_3-3-55","textareaInvalid":"magritte-textarea-invalid___iKOPh_3-3-55","textarea-disabled":"magritte-textarea-disabled___XN0cg_3-3-55","textareaDisabled":"magritte-textarea-disabled___XN0cg_3-3-55","textarea-position-container-wrapper":"magritte-textarea-position-container-wrapper___4Dsui_3-3-55","textareaPositionContainerWrapper":"magritte-textarea-position-container-wrapper___4Dsui_3-3-55","textarea-position-container":"magritte-textarea-position-container___cEpbv_3-3-55","textareaPositionContainer":"magritte-textarea-position-container___cEpbv_3-3-55","native-element":"magritte-native-element___a0RAE_3-3-55","nativeElement":"magritte-native-element___a0RAE_3-3-55","textarea-label":"magritte-textarea-label___sgTIH_3-3-55","textareaLabel":"magritte-textarea-label___sgTIH_3-3-55","textarea-label-elevated":"magritte-textarea-label-elevated___0lxOI_3-3-55","textareaLabelElevated":"magritte-textarea-label-elevated___0lxOI_3-3-55","textarea-limit":"magritte-textarea-limit___IjPJy_3-3-55","textareaLimit":"magritte-textarea-limit___IjPJy_3-3-55","textarea-limit-error":"magritte-textarea-limit-error___vLvZU_3-3-55","textareaLimitError":"magritte-textarea-limit-error___vLvZU_3-3-55","textarea-layout-fill-both":"magritte-textarea-layout-fill-both___ERS-q_3-3-55","textareaLayoutFillBoth":"magritte-textarea-layout-fill-both___ERS-q_3-3-55","textarea-layout-fill-vertical":"magritte-textarea-layout-fill-vertical___HmNtp_3-3-55","textareaLayoutFillVertical":"magritte-textarea-layout-fill-vertical___HmNtp_3-3-55","textarea-layout-fill-horizontal":"magritte-textarea-layout-fill-horizontal___imBH2_3-3-55","textareaLayoutFillHorizontal":"magritte-textarea-layout-fill-horizontal___imBH2_3-3-55","textarea-layout-hug":"magritte-textarea-layout-hug___tdCMY_3-3-55","textareaLayoutHug":"magritte-textarea-layout-hug___tdCMY_3-3-55","textarea-wrapper":"magritte-textarea-wrapper___yD7G6_3-3-55","textareaWrapper":"magritte-textarea-wrapper___yD7G6_3-3-55","value-clone-wrapper":"magritte-value-clone-wrapper___2ZZvS_3-3-55","valueCloneWrapper":"magritte-value-clone-wrapper___2ZZvS_3-3-55","value-clone-container":"magritte-value-clone-container___PVM97_3-3-55","valueCloneContainer":"magritte-value-clone-container___PVM97_3-3-55","side-padding":"magritte-side-padding___O-HUP_3-3-55","sidePadding":"magritte-side-padding___O-HUP_3-3-55","textarea-animation-timeout":"magritte-textarea-animation-timeout___zudbr_3-3-55","textareaAnimationTimeout":"magritte-textarea-animation-timeout___zudbr_3-3-55","textarea-rigging-container":"magritte-textarea-rigging-container___-1S6i_3-3-55","textareaRiggingContainer":"magritte-textarea-rigging-container___-1S6i_3-3-55","label-no-wrap":"magritte-label-no-wrap___RxZ3A_3-3-55","labelNoWrap":"magritte-label-no-wrap___RxZ3A_3-3-55","textarea-grip":"magritte-textarea-grip___iL7lq_3-3-55","textareaGrip":"magritte-textarea-grip___iL7lq_3-3-55","textarea-grip-icon":"magritte-textarea-grip-icon___YK-9w_3-3-55","textareaGripIcon":"magritte-textarea-grip-icon___YK-9w_3-3-55","textarea-limit-enter":"magritte-textarea-limit-enter___CygGz_3-3-55","textareaLimitEnter":"magritte-textarea-limit-enter___CygGz_3-3-55","textarea-limit-exit":"magritte-textarea-limit-exit___RMp-R_3-3-55","textareaLimitExit":"magritte-textarea-limit-exit___RMp-R_3-3-55","textarea-limit-enter-active":"magritte-textarea-limit-enter-active___8vN-t_3-3-55","textareaLimitEnterActive":"magritte-textarea-limit-enter-active___8vN-t_3-3-55","textarea-limit-exit-active":"magritte-textarea-limit-exit-active___a5kBr_3-3-55","textareaLimitExitActive":"magritte-textarea-limit-exit-active___a5kBr_3-3-55"};
23
23
 
24
- const ZERO_WIDTH_SPACE = '\u200B';
25
- const TextAreaComponent = ({ onChange, onFocus, onBlur, onValidate, value, placeholder, disabled = false, elevatePlaceholder = false, invalid = false, invalidLimit = false, maxLength, description, errorMessage, resize = 'none', layout = 'fixed', size = 'large', minHeight: _minHeight, maxHeight, 'aria-describedby': ariaDescribedBy, ...restProps }, ref) => {
26
- const { isMobile } = useBreakpoint();
27
- const forceDisabled = useDisabled();
28
- const isComponentDisabled = forceDisabled || !!disabled;
29
- const [internalInvalid, setInternalInvalid] = useState(false);
30
- const [isFocusVisible, setFocusVisible] = useState(false);
31
- const limitRef = useRef(null);
32
- const previousInvalid = useRef(internalInvalid);
33
- const textAreaRef = useRef(null);
34
- const resizableDivRef = useRef(null);
35
- const resizableDivSizes = useRef(null);
36
- const resizableDivWasResized = useRef(false);
37
- const { hasVerticalScroll, verticalScrollbarProps, ...scrollbar } = useScrollbar({
38
- axis: isComponentDisabled ? 'none' : 'vertical',
39
- });
40
- const textAreaRefCallback = useMultipleRefs(ref, textAreaRef, scrollbar.scrollContainerRef);
41
- const descriptionId = useId();
42
- const labelId = useId();
43
- const [animationTimeout, setAnimationTimeout] = useState(100);
44
- const currentResizeValue = isMobile ? 'none' : resize;
45
- const isResizable = currentResizeValue !== 'none';
46
- const contentCloneRef = useRef(null);
47
- const contentCloneWrapperRef = useRef(null);
48
- const { minHeight, maxedHeight } = useHeightObserver({
49
- size,
50
- minHeight: _minHeight,
51
- layout,
52
- contentCloneRef,
53
- onHeightChange: () => scrollbar.resizeCallbackRef.current?.(),
54
- });
55
- const { maxHeightRef, allowScrollRef } = useLimitGrow({
56
- layout,
57
- contentCloneRef,
58
- contentCloneWrapperRef,
59
- textAreaRef,
60
- resizableDivRef,
61
- minHeight,
62
- });
63
- const trlOf = useTranslation('TextArea', 'of');
64
- useEffect(() => {
65
- const animationTimeoutElement = document.createElement('div');
66
- animationTimeoutElement.classList.add(styles.textareaAnimationTimeout);
67
- document.body.appendChild(animationTimeoutElement);
68
- const style = window.getComputedStyle(animationTimeoutElement);
69
- const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);
70
- if (Number.isInteger(animationTimeout)) {
71
- setAnimationTimeout(animationTimeout);
72
- }
73
- document.body.removeChild(animationTimeoutElement);
74
- }, []);
75
- const { focusHandler, blurHandler, isFocused } = useFocus(onFocus, onBlur);
76
- const handleClick = () => {
77
- if (resizableDivWasResized.current) {
78
- resizableDivWasResized.current = false;
79
- return;
80
- }
81
- textAreaRef.current?.focus();
24
+ const ZERO_WIDTH_SPACE = "\u200B";
25
+ const TextAreaComponent = ({
26
+ onChange,
27
+ onFocus,
28
+ onBlur,
29
+ onValidate,
30
+ value,
31
+ placeholder,
32
+ disabled = false,
33
+ elevatePlaceholder = false,
34
+ invalid = false,
35
+ invalidLimit = false,
36
+ maxLength,
37
+ description,
38
+ errorMessage,
39
+ resize = "none",
40
+ layout = "fixed",
41
+ size = "large",
42
+ minHeight: _minHeight,
43
+ maxHeight,
44
+ "aria-describedby": ariaDescribedBy,
45
+ ...restProps
46
+ }, ref) => {
47
+ const { isMobile } = useBreakpoint();
48
+ const forceDisabled = useDisabled();
49
+ const isComponentDisabled = forceDisabled || !!disabled;
50
+ const [internalInvalid, setInternalInvalid] = useState(false);
51
+ const [isFocusVisible, setFocusVisible] = useState(false);
52
+ const limitRef = useRef(null);
53
+ const previousInvalid = useRef(internalInvalid);
54
+ const textAreaRef = useRef(null);
55
+ const resizableDivRef = useRef(null);
56
+ const resizableDivSizes = useRef(null);
57
+ const resizableDivWasResized = useRef(false);
58
+ const { hasVerticalScroll, verticalScrollbarProps, ...scrollbar } = useScrollbar({
59
+ axis: isComponentDisabled ? "none" : "vertical"
60
+ });
61
+ const textAreaRefCallback = useMultipleRefs(ref, textAreaRef, scrollbar.scrollContainerRef);
62
+ const descriptionId = useId();
63
+ const labelId = useId();
64
+ const [animationTimeout, setAnimationTimeout] = useState(100);
65
+ const currentResizeValue = isMobile ? "none" : resize;
66
+ const isResizable = currentResizeValue !== "none";
67
+ const contentCloneRef = useRef(null);
68
+ const contentCloneWrapperRef = useRef(null);
69
+ const { minHeight, maxedHeight } = useHeightObserver({
70
+ size,
71
+ minHeight: _minHeight,
72
+ layout,
73
+ contentCloneRef,
74
+ onHeightChange: () => scrollbar.resizeCallbackRef.current?.()
75
+ });
76
+ const { maxHeightRef, allowScrollRef } = useLimitGrow({
77
+ layout,
78
+ contentCloneRef,
79
+ contentCloneWrapperRef,
80
+ textAreaRef,
81
+ resizableDivRef,
82
+ minHeight
83
+ });
84
+ const trlOf = useTranslation("TextArea", "of");
85
+ useEffect(() => {
86
+ const animationTimeoutElement = document.createElement("div");
87
+ animationTimeoutElement.classList.add(styles.textareaAnimationTimeout);
88
+ document.body.appendChild(animationTimeoutElement);
89
+ const style = window.getComputedStyle(animationTimeoutElement);
90
+ const animationTimeout2 = parseInt(style.getPropertyValue(`--animation-duration`), 10);
91
+ if (Number.isInteger(animationTimeout2)) {
92
+ setAnimationTimeout(animationTimeout2);
93
+ }
94
+ document.body.removeChild(animationTimeoutElement);
95
+ }, []);
96
+ const { focusHandler, blurHandler, isFocused } = useFocus(onFocus, onBlur);
97
+ const handleClick = () => {
98
+ if (resizableDivWasResized.current) {
99
+ resizableDivWasResized.current = false;
100
+ return;
101
+ }
102
+ textAreaRef.current?.focus();
103
+ };
104
+ const handleMouseUp = () => {
105
+ if (resizableDivRef.current?.offsetWidth !== resizableDivSizes.current?.width || resizableDivRef.current?.offsetHeight !== resizableDivSizes.current?.height) {
106
+ resizableDivWasResized.current = true;
107
+ }
108
+ };
109
+ const handleMouseDown = () => {
110
+ resizableDivSizes.current = {
111
+ width: resizableDivRef.current?.offsetWidth,
112
+ height: resizableDivRef.current?.offsetHeight
82
113
  };
83
- const handleMouseUp = () => {
84
- if (resizableDivRef.current?.offsetWidth !== resizableDivSizes.current?.width ||
85
- resizableDivRef.current?.offsetHeight !== resizableDivSizes.current?.height) {
86
- resizableDivWasResized.current = true;
87
- }
88
- };
89
- const handleMouseDown = () => {
90
- resizableDivSizes.current = {
91
- width: resizableDivRef.current?.offsetWidth,
92
- height: resizableDivRef.current?.offsetHeight,
93
- };
94
- };
95
- useEffect(() => {
96
- if (maxLength) {
97
- const invalid = !isFocused && value.length > maxLength;
98
- setInternalInvalid(invalid);
99
- if (previousInvalid.current !== invalid) {
100
- onValidate?.({ invalidLimit: invalid });
101
- }
102
- previousInvalid.current = invalid;
103
- }
104
- }, [onValidate, value, internalInvalid, maxLength, isFocused]);
105
- useEffect(() => {
106
- if (textAreaRef.current) {
107
- setFocusVisible(isFocused && textAreaRef.current.classList.contains('focus-visible'));
108
- }
109
- }, [isFocused]);
110
- useEffect(() => {
111
- // для layout === 'hug' resizeCallback вызывается в useHeightObserver, т.к. нужно ожидать перерисовку оберток
112
- if (layout !== 'hug') {
113
- scrollbar.resizeCallbackRef.current?.();
114
- }
115
- }, [layout, scrollbar.resizeCallbackRef, value]);
116
- const placeholderIsElevated = !!elevatePlaceholder && !!placeholder && size === 'large';
117
- const showLabel = placeholderIsElevated || value === '';
118
- const invalidState = invalid || invalidLimit;
119
- const ariaProps = useInputAriaProps({
120
- invalid: invalidState || internalInvalid,
121
- hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,
122
- hasPlaceholder: !!placeholder,
123
- descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,
124
- labelId,
125
- });
126
- const hasElevatedPlaceholderClass = (isFocused || value !== '') && placeholderIsElevated;
127
- return (jsxs("div", { "data-qa": "textarea-wrapper", "data-interactive": true, className: classnames(styles.textarea, styles[`textarea-${size}`], {
128
- [styles.textareaFocused]: isFocused,
129
- [styles.textareaDisabled]: isComponentDisabled,
130
- [styles.textareaInvalid]: !!(invalidState || internalInvalid),
131
- [styles.textareaLimitError]: invalidLimit || internalInvalid || (maxLength ? value.length > maxLength : false),
132
- [styles.textareaLimited]: !!maxLength && maxedHeight,
133
- [styles.textareaLayoutFillBoth]: layout === 'fill-both',
134
- [styles.textareaLayoutFillVertical]: layout === 'fill-vertical',
135
- [styles.textareaLayoutFillHorizontal]: layout === 'fill-horizontal',
136
- [styles.textareaLayoutHug]: layout === 'hug',
137
- [styles.textareaElevated]: placeholderIsElevated,
138
- [styles.hasGrip]: isResizable,
139
- [styles.maxedHeight]: size === 'large' && maxedHeight,
140
- }), children: [jsxs("div", { className: classnames(styles.textareaPositionContainerWrapper, scrollbar.hoverContainerCssClass, {
141
- 'focus-visible': isFocusVisible,
142
- }), children: [jsxs("div", { className: classnames(styles.textareaPositionContainer), onClick: handleClick, onMouseDown: isResizable ? handleMouseDown : undefined, onMouseUp: isResizable ? handleMouseUp : undefined, style: {
143
- height: maxHeightRef.current || (maxedHeight ? 'auto' : minHeight),
144
- minHeight,
145
- '--magritte-textarea-max-height': maxHeight
146
- ? `${Math.max(maxHeight, minHeight)}px`
147
- : 'auto',
148
- resize: currentResizeValue,
149
- }, ref: resizableDivRef, children: [jsxs("div", { className: styles.textareaWrapper, "data-qa": "textarea-native-wrapper", children: [jsx("textarea", { ...restProps, ...ariaProps, disabled: isComponentDisabled, suppressHydrationWarning: true, className: classnames(styles.nativeElement, styles.sidePadding), value: value, onChange: onChange, onFocus: focusHandler, onBlur: blurHandler, style: { overflowY: layout !== 'hug' || allowScrollRef.current ? 'auto' : 'hidden' }, ref: textAreaRefCallback }), layout === 'hug' && (jsx("div", { className: classnames(styles.valueCloneWrapper, styles.sidePadding), ref: contentCloneWrapperRef, children: jsx("pre", { className: styles.valueCloneContainer, ref: contentCloneRef, children: `${value}${ZERO_WIDTH_SPACE}` }) })), showLabel && (jsx("div", { className: classnames(styles.textareaRiggingContainer, styles.sidePadding), children: jsx("label", { className: classnames(styles.textareaLabel, {
150
- [styles.labelNoWrap]: elevatePlaceholder,
151
- [styles.textareaLabelElevated]: hasElevatedPlaceholderClass,
152
- }), id: ariaProps['aria-labelledby'], children: placeholder }) }))] }), hasVerticalScroll && jsx(Scrollbar, { ...verticalScrollbarProps })] }), !!maxLength && maxedHeight && (jsx(CSSTransition, { in: isFocused || value.length > maxLength, timeout: animationTimeout, classNames: {
153
- enter: styles.textareaLimitEnter,
154
- enterActive: styles.textareaLimitEnterActive,
155
- exit: styles.textareaLimitExit,
156
- exitActive: styles.textareaLimitExitActive,
157
- }, unmountOnExit: true, nodeRef: limitRef, children: jsx("div", { className: styles.textareaLimit, ref: limitRef, children: jsxs(Text, { typography: "label-3-regular", children: [value.length, trlOf, maxLength] }) }) })), isResizable && (jsx("div", { className: styles.textareaGrip, children: jsx("div", { className: styles.textareaGripIcon, children: jsx(GripSize24, {}) }) }))] }), jsx(FormHelper, { description: description, errorMessage: errorMessage, descriptionId: ariaProps['aria-describedby'], disabled: isComponentDisabled, invalid: invalidState, "data-qa": "textarea-hint-container" })] }));
114
+ };
115
+ useEffect(() => {
116
+ if (maxLength) {
117
+ const invalid2 = !isFocused && value.length > maxLength;
118
+ setInternalInvalid(invalid2);
119
+ if (previousInvalid.current !== invalid2) {
120
+ onValidate?.({ invalidLimit: invalid2 });
121
+ }
122
+ previousInvalid.current = invalid2;
123
+ }
124
+ }, [onValidate, value, internalInvalid, maxLength, isFocused]);
125
+ useEffect(() => {
126
+ if (textAreaRef.current) {
127
+ setFocusVisible(isFocused && textAreaRef.current.classList.contains("focus-visible"));
128
+ }
129
+ }, [isFocused]);
130
+ useEffect(() => {
131
+ if (layout !== "hug") {
132
+ scrollbar.resizeCallbackRef.current?.();
133
+ }
134
+ }, [layout, scrollbar.resizeCallbackRef, value]);
135
+ const placeholderIsElevated = !!elevatePlaceholder && !!placeholder && size === "large";
136
+ const showLabel = placeholderIsElevated || value === "";
137
+ const invalidState = invalid || invalidLimit;
138
+ const ariaProps = useInputAriaProps({
139
+ invalid: invalidState || internalInvalid,
140
+ hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,
141
+ hasPlaceholder: !!placeholder,
142
+ descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,
143
+ labelId
144
+ });
145
+ const hasElevatedPlaceholderClass = (isFocused || value !== "") && placeholderIsElevated;
146
+ return /* @__PURE__ */ jsxs(
147
+ "div",
148
+ {
149
+ "data-qa": "textarea-wrapper",
150
+ "data-interactive": true,
151
+ className: classnames(styles.textarea, styles[`textarea-${size}`], {
152
+ [styles.textareaFocused]: isFocused,
153
+ [styles.textareaDisabled]: isComponentDisabled,
154
+ [styles.textareaInvalid]: !!(invalidState || internalInvalid),
155
+ [styles.textareaLimitError]: invalidLimit || internalInvalid || (maxLength ? value.length > maxLength : false),
156
+ [styles.textareaLimited]: !!maxLength && maxedHeight,
157
+ [styles.textareaLayoutFillBoth]: layout === "fill-both",
158
+ [styles.textareaLayoutFillVertical]: layout === "fill-vertical",
159
+ [styles.textareaLayoutFillHorizontal]: layout === "fill-horizontal",
160
+ [styles.textareaLayoutHug]: layout === "hug",
161
+ [styles.textareaElevated]: placeholderIsElevated,
162
+ [styles.hasGrip]: isResizable,
163
+ [styles.maxedHeight]: size === "large" && maxedHeight
164
+ }),
165
+ children: [
166
+ /* @__PURE__ */ jsxs(
167
+ "div",
168
+ {
169
+ className: classnames(styles.textareaPositionContainerWrapper, scrollbar.hoverContainerCssClass, {
170
+ "focus-visible": isFocusVisible
171
+ }),
172
+ children: [
173
+ /* @__PURE__ */ jsxs(
174
+ "div",
175
+ {
176
+ className: classnames(styles.textareaPositionContainer),
177
+ onClick: handleClick,
178
+ onMouseDown: isResizable ? handleMouseDown : void 0,
179
+ onMouseUp: isResizable ? handleMouseUp : void 0,
180
+ style: {
181
+ height: maxHeightRef.current || (maxedHeight ? "auto" : minHeight),
182
+ minHeight,
183
+ "--magritte-textarea-max-height": maxHeight ? `${Math.max(maxHeight, minHeight)}px` : "auto",
184
+ resize: currentResizeValue
185
+ },
186
+ ref: resizableDivRef,
187
+ children: [
188
+ /* @__PURE__ */ jsxs("div", { className: styles.textareaWrapper, "data-qa": "textarea-native-wrapper", children: [
189
+ /* @__PURE__ */ jsx(
190
+ "textarea",
191
+ {
192
+ ...restProps,
193
+ ...ariaProps,
194
+ disabled: isComponentDisabled,
195
+ suppressHydrationWarning: true,
196
+ className: classnames(styles.nativeElement, styles.sidePadding),
197
+ value,
198
+ onChange,
199
+ onFocus: focusHandler,
200
+ onBlur: blurHandler,
201
+ style: { overflowY: layout !== "hug" || allowScrollRef.current ? "auto" : "hidden" },
202
+ ref: textAreaRefCallback
203
+ }
204
+ ),
205
+ layout === "hug" && /* @__PURE__ */ jsx(
206
+ "div",
207
+ {
208
+ className: classnames(styles.valueCloneWrapper, styles.sidePadding),
209
+ ref: contentCloneWrapperRef,
210
+ children: /* @__PURE__ */ jsx("pre", { className: styles.valueCloneContainer, ref: contentCloneRef, children: `${value}${ZERO_WIDTH_SPACE}` })
211
+ }
212
+ ),
213
+ showLabel && /* @__PURE__ */ jsx("div", { className: classnames(styles.textareaRiggingContainer, styles.sidePadding), children: /* @__PURE__ */ jsx(
214
+ "label",
215
+ {
216
+ className: classnames(styles.textareaLabel, {
217
+ [styles.labelNoWrap]: elevatePlaceholder,
218
+ [styles.textareaLabelElevated]: hasElevatedPlaceholderClass
219
+ }),
220
+ id: ariaProps["aria-labelledby"],
221
+ children: placeholder
222
+ }
223
+ ) })
224
+ ] }),
225
+ hasVerticalScroll && /* @__PURE__ */ jsx(Scrollbar, { ...verticalScrollbarProps })
226
+ ]
227
+ }
228
+ ),
229
+ !!maxLength && maxedHeight && /* @__PURE__ */ jsx(
230
+ CSSTransition,
231
+ {
232
+ in: isFocused || value.length > maxLength,
233
+ timeout: animationTimeout,
234
+ classNames: {
235
+ enter: styles.textareaLimitEnter,
236
+ enterActive: styles.textareaLimitEnterActive,
237
+ exit: styles.textareaLimitExit,
238
+ exitActive: styles.textareaLimitExitActive
239
+ },
240
+ unmountOnExit: true,
241
+ nodeRef: limitRef,
242
+ children: /* @__PURE__ */ jsx("div", { className: styles.textareaLimit, ref: limitRef, children: /* @__PURE__ */ jsxs(Text, { typography: "label-3-regular", children: [
243
+ value.length,
244
+ trlOf,
245
+ maxLength
246
+ ] }) })
247
+ }
248
+ ),
249
+ isResizable && /* @__PURE__ */ jsx("div", { className: styles.textareaGrip, children: /* @__PURE__ */ jsx("div", { className: styles.textareaGripIcon, children: /* @__PURE__ */ jsx(GripSize24, {}) }) })
250
+ ]
251
+ }
252
+ ),
253
+ /* @__PURE__ */ jsx(
254
+ FormHelper,
255
+ {
256
+ description,
257
+ errorMessage,
258
+ descriptionId: ariaProps["aria-describedby"],
259
+ disabled: isComponentDisabled,
260
+ invalid: invalidState,
261
+ "data-qa": "textarea-hint-container"
262
+ }
263
+ )
264
+ ]
265
+ }
266
+ );
158
267
  };
159
268
  const TextArea = forwardRef(TextAreaComponent);
160
- TextArea.displayName = 'TextArea';
269
+ TextArea.displayName = "TextArea";
161
270
 
162
271
  export { TextArea };
163
272
  //# sourceMappingURL=TextArea.js.map
package/TextArea.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["src/TextArea.tsx"],"sourcesContent":["import {\n forwardRef,\n ReactElement,\n useEffect,\n useId,\n useRef,\n useState,\n type TextareaHTMLAttributes,\n type ForwardedRef,\n type CSSProperties,\n} from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { FormHelper } from '@hh.ru/magritte-ui-form-helper';\nimport { GripSize24 } from '@hh.ru/magritte-ui-icon/private';\nimport { useInputAriaProps } from '@hh.ru/magritte-ui-input/useInputAriaProps';\nimport { Scrollbar, useScrollbar } from '@hh.ru/magritte-ui-scrollbar';\nimport { type TextAreaLayout, type ControlledTextAreaProps } from '@hh.ru/magritte-ui-textarea/types';\nimport { useFocus } from '@hh.ru/magritte-ui-textarea/useFocus';\nimport { useHeightObserver } from '@hh.ru/magritte-ui-textarea/useHeightObserver';\nimport { useLimitGrow } from '@hh.ru/magritte-ui-textarea/useLimitGrow';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './textarea.less';\n\nconst ZERO_WIDTH_SPACE = '\\u200B';\n\nconst TextAreaComponent = <Layout extends TextAreaLayout>(\n {\n onChange,\n onFocus,\n onBlur,\n onValidate,\n value,\n placeholder,\n disabled = false,\n elevatePlaceholder = false,\n invalid = false,\n invalidLimit = false,\n maxLength,\n description,\n errorMessage,\n resize = 'none',\n layout = 'fixed' as Layout,\n size = 'large',\n minHeight: _minHeight,\n maxHeight,\n 'aria-describedby': ariaDescribedBy,\n ...restProps\n }: ControlledTextAreaProps<Layout> &\n Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, keyof ControlledTextAreaProps<'fixed'>>,\n ref: ForwardedRef<HTMLTextAreaElement>\n) => {\n const { isMobile } = useBreakpoint();\n const forceDisabled = useDisabled();\n const isComponentDisabled = forceDisabled || !!disabled;\n const [internalInvalid, setInternalInvalid] = useState(false);\n const [isFocusVisible, setFocusVisible] = useState(false);\n const limitRef = useRef<HTMLDivElement>(null);\n const previousInvalid = useRef(internalInvalid);\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n const resizableDivRef = useRef<HTMLDivElement>(null);\n const resizableDivSizes = useRef<{ width?: number; height?: number } | null>(null);\n const resizableDivWasResized = useRef(false);\n const { hasVerticalScroll, verticalScrollbarProps, ...scrollbar } = useScrollbar({\n axis: isComponentDisabled ? 'none' : 'vertical',\n });\n const textAreaRefCallback = useMultipleRefs(ref, textAreaRef, scrollbar.scrollContainerRef);\n const descriptionId = useId();\n const labelId = useId();\n const [animationTimeout, setAnimationTimeout] = useState(100);\n const currentResizeValue = isMobile ? 'none' : resize;\n const isResizable = currentResizeValue !== 'none';\n const contentCloneRef = useRef<HTMLPreElement>(null);\n const contentCloneWrapperRef = useRef<HTMLDivElement>(null);\n const { minHeight, maxedHeight } = useHeightObserver({\n size,\n minHeight: _minHeight,\n layout,\n contentCloneRef,\n onHeightChange: () => scrollbar.resizeCallbackRef.current?.(),\n });\n const { maxHeightRef, allowScrollRef } = useLimitGrow({\n layout,\n contentCloneRef,\n contentCloneWrapperRef,\n textAreaRef,\n resizableDivRef,\n minHeight,\n });\n const trlOf = useTranslation('TextArea', 'of');\n\n useEffect(() => {\n const animationTimeoutElement = document.createElement('div');\n animationTimeoutElement.classList.add(styles.textareaAnimationTimeout);\n document.body.appendChild(animationTimeoutElement);\n const style = window.getComputedStyle(animationTimeoutElement);\n const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n document.body.removeChild(animationTimeoutElement);\n }, []);\n\n const { focusHandler, blurHandler, isFocused } = useFocus<HTMLTextAreaElement>(onFocus, onBlur);\n\n const handleClick = () => {\n if (resizableDivWasResized.current) {\n resizableDivWasResized.current = false;\n return;\n }\n textAreaRef.current?.focus();\n };\n\n const handleMouseUp = () => {\n if (\n resizableDivRef.current?.offsetWidth !== resizableDivSizes.current?.width ||\n resizableDivRef.current?.offsetHeight !== resizableDivSizes.current?.height\n ) {\n resizableDivWasResized.current = true;\n }\n };\n\n const handleMouseDown = () => {\n resizableDivSizes.current = {\n width: resizableDivRef.current?.offsetWidth,\n height: resizableDivRef.current?.offsetHeight,\n };\n };\n\n useEffect(() => {\n if (maxLength) {\n const invalid = !isFocused && value.length > maxLength;\n setInternalInvalid(invalid);\n\n if (previousInvalid.current !== invalid) {\n onValidate?.({ invalidLimit: invalid });\n }\n previousInvalid.current = invalid;\n }\n }, [onValidate, value, internalInvalid, maxLength, isFocused]);\n\n useEffect(() => {\n if (textAreaRef.current) {\n setFocusVisible(isFocused && textAreaRef.current.classList.contains('focus-visible'));\n }\n }, [isFocused]);\n\n useEffect(() => {\n // для layout === 'hug' resizeCallback вызывается в useHeightObserver, т.к. нужно ожидать перерисовку оберток\n if (layout !== 'hug') {\n scrollbar.resizeCallbackRef.current?.();\n }\n }, [layout, scrollbar.resizeCallbackRef, value]);\n\n const placeholderIsElevated = !!elevatePlaceholder && !!placeholder && size === 'large';\n const showLabel = placeholderIsElevated || value === '';\n\n const invalidState = invalid || invalidLimit;\n const ariaProps = useInputAriaProps({\n invalid: invalidState || internalInvalid,\n hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,\n hasPlaceholder: !!placeholder,\n descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,\n labelId,\n });\n\n const hasElevatedPlaceholderClass = (isFocused || value !== '') && placeholderIsElevated;\n\n return (\n <div\n data-qa=\"textarea-wrapper\"\n data-interactive={true}\n className={classnames(styles.textarea, styles[`textarea-${size}`], {\n [styles.textareaFocused]: isFocused,\n [styles.textareaDisabled]: isComponentDisabled,\n [styles.textareaInvalid]: !!(invalidState || internalInvalid),\n [styles.textareaLimitError]:\n invalidLimit || internalInvalid || (maxLength ? value.length > maxLength : false),\n [styles.textareaLimited]: !!maxLength && maxedHeight,\n [styles.textareaLayoutFillBoth]: layout === 'fill-both',\n [styles.textareaLayoutFillVertical]: layout === 'fill-vertical',\n [styles.textareaLayoutFillHorizontal]: layout === 'fill-horizontal',\n [styles.textareaLayoutHug]: layout === 'hug',\n [styles.textareaElevated]: placeholderIsElevated,\n [styles.hasGrip]: isResizable,\n [styles.maxedHeight]: size === 'large' && maxedHeight,\n })}\n >\n <div\n className={classnames(styles.textareaPositionContainerWrapper, scrollbar.hoverContainerCssClass, {\n 'focus-visible': isFocusVisible,\n })}\n >\n <div\n className={classnames(styles.textareaPositionContainer)}\n onClick={handleClick}\n onMouseDown={isResizable ? handleMouseDown : undefined}\n onMouseUp={isResizable ? handleMouseUp : undefined}\n style={\n {\n height: maxHeightRef.current || (maxedHeight ? 'auto' : minHeight),\n minHeight,\n '--magritte-textarea-max-height': maxHeight\n ? `${Math.max(maxHeight, minHeight)}px`\n : 'auto',\n resize: currentResizeValue,\n } as CSSProperties\n }\n ref={resizableDivRef}\n >\n <div className={styles.textareaWrapper} data-qa=\"textarea-native-wrapper\">\n <textarea\n {...restProps}\n {...ariaProps}\n disabled={isComponentDisabled}\n suppressHydrationWarning\n className={classnames(styles.nativeElement, styles.sidePadding)}\n value={value}\n onChange={onChange}\n onFocus={focusHandler}\n onBlur={blurHandler}\n style={{ overflowY: layout !== 'hug' || allowScrollRef.current ? 'auto' : 'hidden' }}\n ref={textAreaRefCallback}\n />\n {layout === 'hug' && (\n <div\n className={classnames(styles.valueCloneWrapper, styles.sidePadding)}\n ref={contentCloneWrapperRef}\n >\n <pre className={styles.valueCloneContainer} ref={contentCloneRef}>\n {`${value}${ZERO_WIDTH_SPACE}`}\n </pre>\n </div>\n )}\n {showLabel && (\n <div className={classnames(styles.textareaRiggingContainer, styles.sidePadding)}>\n <label\n className={classnames(styles.textareaLabel, {\n [styles.labelNoWrap]: elevatePlaceholder,\n [styles.textareaLabelElevated]: hasElevatedPlaceholderClass,\n })}\n id={ariaProps['aria-labelledby']}\n >\n {placeholder}\n </label>\n </div>\n )}\n </div>\n {hasVerticalScroll && <Scrollbar {...verticalScrollbarProps} />}\n </div>\n {!!maxLength && maxedHeight && (\n <CSSTransition\n in={isFocused || value.length > maxLength}\n timeout={animationTimeout}\n classNames={{\n enter: styles.textareaLimitEnter,\n enterActive: styles.textareaLimitEnterActive,\n exit: styles.textareaLimitExit,\n exitActive: styles.textareaLimitExitActive,\n }}\n unmountOnExit\n nodeRef={limitRef}\n >\n <div className={styles.textareaLimit} ref={limitRef}>\n <Text typography=\"label-3-regular\">\n {value.length}\n {trlOf}\n {maxLength}\n </Text>\n </div>\n </CSSTransition>\n )}\n {isResizable && (\n <div className={styles.textareaGrip}>\n <div className={styles.textareaGripIcon}>\n <GripSize24 />\n </div>\n </div>\n )}\n </div>\n <FormHelper\n description={description}\n errorMessage={errorMessage}\n descriptionId={ariaProps['aria-describedby']}\n disabled={isComponentDisabled}\n invalid={invalidState}\n data-qa=\"textarea-hint-container\"\n />\n </div>\n );\n};\n\nconst TextArea = forwardRef(TextAreaComponent) as (<Layout extends TextAreaLayout>(\n props: ControlledTextAreaProps<Layout> &\n Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof ControlledTextAreaProps<'fixed'>> & {\n ref?: React.ForwardedRef<HTMLTextAreaElement>;\n }\n) => ReactElement | null) & { displayName: string };\n\nTextArea.displayName = 'TextArea';\n\nexport { TextArea };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC,MAAM,iBAAiB,GAAG,CACtB,EACI,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,EACV,KAAK,EACL,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,kBAAkB,GAAG,KAAK,EAC1B,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,KAAK,EACpB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,GAAG,MAAM,EACf,MAAM,GAAG,OAAiB,EAC1B,IAAI,GAAG,OAAO,EACd,SAAS,EAAE,UAAU,EACrB,SAAS,EACT,kBAAkB,EAAE,eAAe,EACnC,GAAG,SAAS,EAE6E,EAC7F,GAAsC,KACtC;AACA,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;AACrC,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AACpC,IAAA,MAAM,mBAAmB,GAAG,aAAa,IAAI,CAAC,CAAC,QAAQ,CAAC;IACxD,MAAM,CAAC,eAAe,EAAE,kBAAkB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AAC,kBAAkB,CAAC,EAC5C,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,YAAY,EAAA,SAAA,EACb,yBAAyB,EACnC,CAAA,CAAA,EAAA,CACA,EACR;AACN,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,UAAU,CAAC,iBAAiB,EAKO;AAEpD,QAAQ,CAAC,WAAW,GAAG,UAAU;;;;"}
1
+ {"version":3,"file":"TextArea.js","sources":["src/TextArea.tsx"],"sourcesContent":["import {\n forwardRef,\n ReactElement,\n useEffect,\n useId,\n useRef,\n useState,\n type TextareaHTMLAttributes,\n type ForwardedRef,\n type CSSProperties,\n} from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { FormHelper } from '@hh.ru/magritte-ui-form-helper';\nimport { GripSize24 } from '@hh.ru/magritte-ui-icon/private';\nimport { useInputAriaProps } from '@hh.ru/magritte-ui-input/useInputAriaProps';\nimport { Scrollbar, useScrollbar } from '@hh.ru/magritte-ui-scrollbar';\nimport { type TextAreaLayout, type ControlledTextAreaProps } from '@hh.ru/magritte-ui-textarea/types';\nimport { useFocus } from '@hh.ru/magritte-ui-textarea/useFocus';\nimport { useHeightObserver } from '@hh.ru/magritte-ui-textarea/useHeightObserver';\nimport { useLimitGrow } from '@hh.ru/magritte-ui-textarea/useLimitGrow';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './textarea.less';\n\nconst ZERO_WIDTH_SPACE = '\\u200B';\n\nconst TextAreaComponent = <Layout extends TextAreaLayout>(\n {\n onChange,\n onFocus,\n onBlur,\n onValidate,\n value,\n placeholder,\n disabled = false,\n elevatePlaceholder = false,\n invalid = false,\n invalidLimit = false,\n maxLength,\n description,\n errorMessage,\n resize = 'none',\n layout = 'fixed' as Layout,\n size = 'large',\n minHeight: _minHeight,\n maxHeight,\n 'aria-describedby': ariaDescribedBy,\n ...restProps\n }: ControlledTextAreaProps<Layout> &\n Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, keyof ControlledTextAreaProps<'fixed'>>,\n ref: ForwardedRef<HTMLTextAreaElement>\n) => {\n const { isMobile } = useBreakpoint();\n const forceDisabled = useDisabled();\n const isComponentDisabled = forceDisabled || !!disabled;\n const [internalInvalid, setInternalInvalid] = useState(false);\n const [isFocusVisible, setFocusVisible] = useState(false);\n const limitRef = useRef<HTMLDivElement>(null);\n const previousInvalid = useRef(internalInvalid);\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n const resizableDivRef = useRef<HTMLDivElement>(null);\n const resizableDivSizes = useRef<{ width?: number; height?: number } | null>(null);\n const resizableDivWasResized = useRef(false);\n const { hasVerticalScroll, verticalScrollbarProps, ...scrollbar } = useScrollbar({\n axis: isComponentDisabled ? 'none' : 'vertical',\n });\n const textAreaRefCallback = useMultipleRefs(ref, textAreaRef, scrollbar.scrollContainerRef);\n const descriptionId = useId();\n const labelId = useId();\n const [animationTimeout, setAnimationTimeout] = useState(100);\n const currentResizeValue = isMobile ? 'none' : resize;\n const isResizable = currentResizeValue !== 'none';\n const contentCloneRef = useRef<HTMLPreElement>(null);\n const contentCloneWrapperRef = useRef<HTMLDivElement>(null);\n const { minHeight, maxedHeight } = useHeightObserver({\n size,\n minHeight: _minHeight,\n layout,\n contentCloneRef,\n onHeightChange: () => scrollbar.resizeCallbackRef.current?.(),\n });\n const { maxHeightRef, allowScrollRef } = useLimitGrow({\n layout,\n contentCloneRef,\n contentCloneWrapperRef,\n textAreaRef,\n resizableDivRef,\n minHeight,\n });\n const trlOf = useTranslation('TextArea', 'of');\n\n useEffect(() => {\n const animationTimeoutElement = document.createElement('div');\n animationTimeoutElement.classList.add(styles.textareaAnimationTimeout);\n document.body.appendChild(animationTimeoutElement);\n const style = window.getComputedStyle(animationTimeoutElement);\n const animationTimeout = parseInt(style.getPropertyValue(`--animation-duration`), 10);\n if (Number.isInteger(animationTimeout)) {\n setAnimationTimeout(animationTimeout);\n }\n document.body.removeChild(animationTimeoutElement);\n }, []);\n\n const { focusHandler, blurHandler, isFocused } = useFocus<HTMLTextAreaElement>(onFocus, onBlur);\n\n const handleClick = () => {\n if (resizableDivWasResized.current) {\n resizableDivWasResized.current = false;\n return;\n }\n textAreaRef.current?.focus();\n };\n\n const handleMouseUp = () => {\n if (\n resizableDivRef.current?.offsetWidth !== resizableDivSizes.current?.width ||\n resizableDivRef.current?.offsetHeight !== resizableDivSizes.current?.height\n ) {\n resizableDivWasResized.current = true;\n }\n };\n\n const handleMouseDown = () => {\n resizableDivSizes.current = {\n width: resizableDivRef.current?.offsetWidth,\n height: resizableDivRef.current?.offsetHeight,\n };\n };\n\n useEffect(() => {\n if (maxLength) {\n const invalid = !isFocused && value.length > maxLength;\n setInternalInvalid(invalid);\n\n if (previousInvalid.current !== invalid) {\n onValidate?.({ invalidLimit: invalid });\n }\n previousInvalid.current = invalid;\n }\n }, [onValidate, value, internalInvalid, maxLength, isFocused]);\n\n useEffect(() => {\n if (textAreaRef.current) {\n setFocusVisible(isFocused && textAreaRef.current.classList.contains('focus-visible'));\n }\n }, [isFocused]);\n\n useEffect(() => {\n // для layout === 'hug' resizeCallback вызывается в useHeightObserver, т.к. нужно ожидать перерисовку оберток\n if (layout !== 'hug') {\n scrollbar.resizeCallbackRef.current?.();\n }\n }, [layout, scrollbar.resizeCallbackRef, value]);\n\n const placeholderIsElevated = !!elevatePlaceholder && !!placeholder && size === 'large';\n const showLabel = placeholderIsElevated || value === '';\n\n const invalidState = invalid || invalidLimit;\n const ariaProps = useInputAriaProps({\n invalid: invalidState || internalInvalid,\n hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,\n hasPlaceholder: !!placeholder,\n descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,\n labelId,\n });\n\n const hasElevatedPlaceholderClass = (isFocused || value !== '') && placeholderIsElevated;\n\n return (\n <div\n data-qa=\"textarea-wrapper\"\n data-interactive={true}\n className={classnames(styles.textarea, styles[`textarea-${size}`], {\n [styles.textareaFocused]: isFocused,\n [styles.textareaDisabled]: isComponentDisabled,\n [styles.textareaInvalid]: !!(invalidState || internalInvalid),\n [styles.textareaLimitError]:\n invalidLimit || internalInvalid || (maxLength ? value.length > maxLength : false),\n [styles.textareaLimited]: !!maxLength && maxedHeight,\n [styles.textareaLayoutFillBoth]: layout === 'fill-both',\n [styles.textareaLayoutFillVertical]: layout === 'fill-vertical',\n [styles.textareaLayoutFillHorizontal]: layout === 'fill-horizontal',\n [styles.textareaLayoutHug]: layout === 'hug',\n [styles.textareaElevated]: placeholderIsElevated,\n [styles.hasGrip]: isResizable,\n [styles.maxedHeight]: size === 'large' && maxedHeight,\n })}\n >\n <div\n className={classnames(styles.textareaPositionContainerWrapper, scrollbar.hoverContainerCssClass, {\n 'focus-visible': isFocusVisible,\n })}\n >\n <div\n className={classnames(styles.textareaPositionContainer)}\n onClick={handleClick}\n onMouseDown={isResizable ? handleMouseDown : undefined}\n onMouseUp={isResizable ? handleMouseUp : undefined}\n style={\n {\n height: maxHeightRef.current || (maxedHeight ? 'auto' : minHeight),\n minHeight,\n '--magritte-textarea-max-height': maxHeight\n ? `${Math.max(maxHeight, minHeight)}px`\n : 'auto',\n resize: currentResizeValue,\n } as CSSProperties\n }\n ref={resizableDivRef}\n >\n <div className={styles.textareaWrapper} data-qa=\"textarea-native-wrapper\">\n <textarea\n {...restProps}\n {...ariaProps}\n disabled={isComponentDisabled}\n suppressHydrationWarning\n className={classnames(styles.nativeElement, styles.sidePadding)}\n value={value}\n onChange={onChange}\n onFocus={focusHandler}\n onBlur={blurHandler}\n style={{ overflowY: layout !== 'hug' || allowScrollRef.current ? 'auto' : 'hidden' }}\n ref={textAreaRefCallback}\n />\n {layout === 'hug' && (\n <div\n className={classnames(styles.valueCloneWrapper, styles.sidePadding)}\n ref={contentCloneWrapperRef}\n >\n <pre className={styles.valueCloneContainer} ref={contentCloneRef}>\n {`${value}${ZERO_WIDTH_SPACE}`}\n </pre>\n </div>\n )}\n {showLabel && (\n <div className={classnames(styles.textareaRiggingContainer, styles.sidePadding)}>\n <label\n className={classnames(styles.textareaLabel, {\n [styles.labelNoWrap]: elevatePlaceholder,\n [styles.textareaLabelElevated]: hasElevatedPlaceholderClass,\n })}\n id={ariaProps['aria-labelledby']}\n >\n {placeholder}\n </label>\n </div>\n )}\n </div>\n {hasVerticalScroll && <Scrollbar {...verticalScrollbarProps} />}\n </div>\n {!!maxLength && maxedHeight && (\n <CSSTransition\n in={isFocused || value.length > maxLength}\n timeout={animationTimeout}\n classNames={{\n enter: styles.textareaLimitEnter,\n enterActive: styles.textareaLimitEnterActive,\n exit: styles.textareaLimitExit,\n exitActive: styles.textareaLimitExitActive,\n }}\n unmountOnExit\n nodeRef={limitRef}\n >\n <div className={styles.textareaLimit} ref={limitRef}>\n <Text typography=\"label-3-regular\">\n {value.length}\n {trlOf}\n {maxLength}\n </Text>\n </div>\n </CSSTransition>\n )}\n {isResizable && (\n <div className={styles.textareaGrip}>\n <div className={styles.textareaGripIcon}>\n <GripSize24 />\n </div>\n </div>\n )}\n </div>\n <FormHelper\n description={description}\n errorMessage={errorMessage}\n descriptionId={ariaProps['aria-describedby']}\n disabled={isComponentDisabled}\n invalid={invalidState}\n data-qa=\"textarea-hint-container\"\n />\n </div>\n );\n};\n\nconst TextArea = forwardRef(TextAreaComponent) as (<Layout extends TextAreaLayout>(\n props: ControlledTextAreaProps<Layout> &\n Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof ControlledTextAreaProps<'fixed'>> & {\n ref?: React.ForwardedRef<HTMLTextAreaElement>;\n }\n) => ReactElement | null) & { displayName: string };\n\nTextArea.displayName = 'TextArea';\n\nexport { TextArea };\n"],"names":["animationTimeout","invalid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,gBAAmB,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B,CACJ,EAAA,CAAA;AAAA,aAAA;AAAA,WAAA;AAAA,SAER;AAAA,wBACA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACG,WAAA;AAAA,YACA,YAAA;AAAA,YACA,aAAA,EAAe,UAAU,kBAAkB,CAAA;AAAA,YAC3C,QAAU,EAAA,mBAAA;AAAA,YACV,OAAS,EAAA,YAAA;AAAA,YACT,SAAQ,EAAA,yBAAA;AAAA,WAAA;AAAA,SACZ;AAAA,OAAA;AAAA,KAAA;AAAA,GACJ,CAAA;AAER,CAAA,CAAA;AAEM,MAAA,QAAA,GAAW,WAAW,iBAAiB,EAAA;AAO7C,QAAA,CAAS,WAAc,GAAA,UAAA;;;;"}
@@ -11,8 +11,8 @@ export declare const TextAreaGrowLimiter: import("react").ForwardRefExoticCompon
11
11
  debounce?: boolean;
12
12
  preMeasurement?: VoidFunction;
13
13
  postMeasurement?: VoidFunction;
14
- style?: import("react").HTMLAttributes<HTMLDivElement>["style"];
15
- className?: import("react").HTMLAttributes<HTMLDivElement>["className"];
14
+ style?: import("react").HTMLAttributes<HTMLDivElement>['style'];
15
+ className?: import("react").HTMLAttributes<HTMLDivElement>['className'];
16
16
  } & {
17
17
  children?: import("react").ReactNode | undefined;
18
18
  } & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;