@idealyst/components 1.2.66 → 1.2.68
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.68",
|
|
4
4
|
"description": "Shared component library for React and React Native",
|
|
5
5
|
"documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/components#readme",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"publish:npm": "npm publish"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@idealyst/theme": "^1.2.
|
|
59
|
+
"@idealyst/theme": "^1.2.68",
|
|
60
60
|
"@mdi/js": ">=7.0.0",
|
|
61
61
|
"@mdi/react": ">=1.0.0",
|
|
62
62
|
"@react-native-vector-icons/common": ">=12.0.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@idealyst/blur": "^1.2.40",
|
|
110
|
-
"@idealyst/theme": "^1.2.
|
|
110
|
+
"@idealyst/theme": "^1.2.68",
|
|
111
111
|
"@idealyst/tooling": "^1.2.30",
|
|
112
112
|
"@mdi/react": "^1.6.1",
|
|
113
113
|
"@types/react": "^19.1.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, forwardRef, useMemo } from 'react';
|
|
1
|
+
import { useState, forwardRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import { View, TextInput, NativeSyntheticEvent, TextInputContentSizeChangeEventData } from 'react-native';
|
|
3
3
|
import { textAreaStyles } from './TextArea.styles';
|
|
4
4
|
import Text from '../Text';
|
|
@@ -141,6 +141,14 @@ const TextArea = forwardRef<IdealystElement, TextAreaProps>(({
|
|
|
141
141
|
setContentHeight(newHeight);
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
// Reset contentHeight when value is cleared externally (controlled component)
|
|
145
|
+
// This forces the TextInput to recalculate its size
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (autoGrow && value === '') {
|
|
148
|
+
setContentHeight(undefined);
|
|
149
|
+
}
|
|
150
|
+
}, [value, autoGrow]);
|
|
151
|
+
|
|
144
152
|
const showFooter = (error || helperText) || (showCharacterCount && maxLength);
|
|
145
153
|
|
|
146
154
|
// Get dynamic styles - call as functions for theme reactivity
|
|
@@ -172,10 +180,15 @@ const TextArea = forwardRef<IdealystElement, TextAreaProps>(({
|
|
|
172
180
|
textAlignVertical: autoGrow ? 'center' : 'top',
|
|
173
181
|
backgroundColor: 'transparent',
|
|
174
182
|
},
|
|
175
|
-
// For autoGrow:
|
|
183
|
+
// For autoGrow: use contentHeight if available, otherwise minHeight constraint
|
|
176
184
|
// For fixed height: use rows-based height
|
|
177
185
|
autoGrow
|
|
178
|
-
? {
|
|
186
|
+
? {
|
|
187
|
+
minHeight: minHeight ?? 44,
|
|
188
|
+
maxHeight: maxHeight,
|
|
189
|
+
// Set explicit height when we have a calculated contentHeight
|
|
190
|
+
...(contentHeight !== undefined && { height: contentHeight }),
|
|
191
|
+
}
|
|
179
192
|
: { height: rows * 24 },
|
|
180
193
|
textareaStyle,
|
|
181
194
|
]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, forwardRef, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect, forwardRef, useMemo, useCallback } from 'react';
|
|
2
2
|
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
3
|
import { textAreaStyles } from './TextArea.styles';
|
|
4
4
|
import type { TextAreaProps } from './types';
|
|
@@ -156,7 +156,7 @@ const TextArea = forwardRef<IdealystElement, TextAreaProps>(({
|
|
|
156
156
|
const helperTextProps = getWebProps([helperTextStyleComputed]);
|
|
157
157
|
const characterCountProps = getWebProps([characterCountStyleComputed]);
|
|
158
158
|
|
|
159
|
-
const adjustHeight = () => {
|
|
159
|
+
const adjustHeight = useCallback(() => {
|
|
160
160
|
if (!autoGrow || !textareaRef.current) return;
|
|
161
161
|
|
|
162
162
|
const textarea = textareaRef.current;
|
|
@@ -175,11 +175,11 @@ const TextArea = forwardRef<IdealystElement, TextAreaProps>(({
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
textarea.style.height = `${newHeight}px`;
|
|
178
|
-
};
|
|
178
|
+
}, [autoGrow, minHeight, maxHeight]);
|
|
179
179
|
|
|
180
180
|
useEffect(() => {
|
|
181
181
|
adjustHeight();
|
|
182
|
-
}, [value,
|
|
182
|
+
}, [value, adjustHeight]);
|
|
183
183
|
|
|
184
184
|
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
185
185
|
e.stopPropagation();
|