@instructure/ui-text-area 11.7.3-snapshot-25 → 11.7.3-snapshot-26

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/CHANGELOG.md CHANGED
@@ -3,9 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [11.7.3-snapshot-25](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-25) (2026-04-30)
6
+ ## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-text-area
8
+
9
+ ### Bug Fixes
10
+
11
+ * **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
9
12
 
10
13
 
11
14
 
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class, _TextArea;
1
+ var _dec, _dec2, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -40,87 +40,36 @@ category: components
40
40
  ---
41
41
  **/
42
42
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
43
- let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_TextArea = class TextArea extends Component {
43
+ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class TextArea extends Component {
44
+ static displayName = "TextArea";
45
+ static componentId = 'TextArea';
46
+ static allowedProps = allowedProps;
47
+ static defaultProps = {
48
+ size: 'medium',
49
+ autoGrow: true,
50
+ resize: 'none',
51
+ inline: false,
52
+ messages: [],
53
+ disabled: false,
54
+ readOnly: false,
55
+ layout: 'stacked',
56
+ required: false
57
+ };
58
+ _listener;
59
+ _request;
60
+ _defaultId;
61
+ _textareaResizeListener;
62
+ _debounced;
63
+ _textarea = null;
64
+ _container = null;
65
+ _height;
66
+ _manuallyResized = false;
67
+ _highlightRef = null;
68
+ myObserver = null;
69
+ resizeTimeout;
70
+ ref = null;
44
71
  constructor(props) {
45
72
  super(props);
46
- this._listener = void 0;
47
- this._request = void 0;
48
- this._defaultId = void 0;
49
- this._textareaResizeListener = void 0;
50
- this._debounced = void 0;
51
- this._textarea = null;
52
- this._container = null;
53
- this._height = void 0;
54
- this._manuallyResized = false;
55
- this._highlightRef = null;
56
- this.myObserver = null;
57
- this.resizeTimeout = void 0;
58
- this.ref = null;
59
- this._textareaResize = () => {
60
- const textareaHeight = this._textarea.style.height;
61
- if (textareaHeight !== '' && textareaHeight !== this._height) {
62
- this._manuallyResized = true;
63
- this._textarea.style.overflowY = 'auto';
64
-
65
- // update container minHeight to ensure focus ring always wraps input
66
- this._container.style.minHeight = textareaHeight;
67
- }
68
- };
69
- this.grow = () => {
70
- if (!this._textarea || this._manuallyResized) {
71
- return;
72
- }
73
- const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
74
- let height = '';
75
-
76
- // Notes:
77
- // 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
78
- // 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
79
- this._textarea.style.height = 'auto';
80
- this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
81
- height = this._textarea.scrollHeight + offset + 'px';
82
- const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : void 0;
83
- if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
84
- this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
85
- } else if (this.props.height) {
86
- if (this._textarea.value === '') {
87
- height = this.props.height;
88
- } else if (px(this.props.height, this._container) > this._textarea.scrollHeight) {
89
- this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
90
- height = this.props.height;
91
- }
92
- }
93
-
94
- // preserve container height to prevent scroll jumping on long textareas,
95
- // but make sure container doesn't exceed maxHeight prop
96
- const heightExceedsMax = maxHeight !== void 0 && px(height) > maxHeight;
97
- if (!heightExceedsMax) {
98
- this._container.style.minHeight = height;
99
- }
100
- this._height = height;
101
- this._textarea.style.height = height;
102
- };
103
- this.handleChange = event => {
104
- const _this$props = this.props,
105
- onChange = _this$props.onChange,
106
- value = _this$props.value,
107
- disabled = _this$props.disabled,
108
- readOnly = _this$props.readOnly;
109
- if (disabled || readOnly) {
110
- event.preventDefault();
111
- return;
112
- }
113
- if (typeof value === 'undefined') {
114
- // if uncontrolled
115
- this.autoGrow();
116
- }
117
- if (typeof onChange === 'function') {
118
- onChange(event);
119
- }
120
- };
121
- this.handleContainerRef = node => {
122
- this._container = node;
123
- };
124
73
  this._defaultId = props.deterministicId();
125
74
 
126
75
  //mock ResizeObserver for ssr
@@ -139,7 +88,6 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
139
88
  }
140
89
  }
141
90
  componentDidMount() {
142
- var _this$props$makeStyle, _this$props2;
143
91
  this.myObserver = new ResizeObserver(entries => {
144
92
  for (const entry of entries) {
145
93
  if (this._highlightRef) {
@@ -157,12 +105,11 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
157
105
  }
158
106
  });
159
107
  this.autoGrow();
160
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
108
+ this.props.makeStyles?.();
161
109
  }
162
110
  componentDidUpdate() {
163
- var _this$props$makeStyle2, _this$props3;
164
111
  this.autoGrow();
165
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
112
+ this.props.makeStyles?.();
166
113
  }
167
114
  componentWillUnmount() {
168
115
  if (this._listener) {
@@ -181,6 +128,16 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
181
128
  this.myObserver.disconnect();
182
129
  }
183
130
  }
131
+ _textareaResize = () => {
132
+ const textareaHeight = this._textarea.style.height;
133
+ if (textareaHeight !== '' && textareaHeight !== this._height) {
134
+ this._manuallyResized = true;
135
+ this._textarea.style.overflowY = 'auto';
136
+
137
+ // update container minHeight to ensure focus ring always wraps input
138
+ this._container.style.minHeight = textareaHeight;
139
+ }
140
+ };
184
141
  autoGrow() {
185
142
  if (this.props.autoGrow) {
186
143
  if (!this._debounced) {
@@ -193,11 +150,14 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
193
150
  this._listener = addEventListener(window, 'resize', this._debounced);
194
151
  }
195
152
  if (this._textarea && !this._textareaResizeListener) {
196
- const _getBoundingClientRec = getBoundingClientRect(this._textarea),
197
- origHeight = _getBoundingClientRec.height;
153
+ const {
154
+ height: origHeight
155
+ } = getBoundingClientRect(this._textarea);
198
156
  this._textareaResizeListener = new ResizeObserver(entries => {
199
157
  for (const entry of entries) {
200
- const height = entry.contentRect.height;
158
+ const {
159
+ height
160
+ } = entry.contentRect;
201
161
  if (origHeight !== height) {
202
162
  this._textareaResize();
203
163
  }
@@ -208,9 +168,65 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
208
168
  this._request = requestAnimationFrame(this.grow);
209
169
  }
210
170
  }
171
+ grow = () => {
172
+ if (!this._textarea || this._manuallyResized) {
173
+ return;
174
+ }
175
+ const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
176
+ let height = '';
177
+
178
+ // Notes:
179
+ // 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
180
+ // 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
181
+ this._textarea.style.height = 'auto';
182
+ this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
183
+ height = this._textarea.scrollHeight + offset + 'px';
184
+ const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : undefined;
185
+ if (this.props.maxHeight && maxHeight !== undefined && this._textarea.scrollHeight > maxHeight) {
186
+ this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
187
+ } else if (this.props.height) {
188
+ if (this._textarea.value === '') {
189
+ height = this.props.height;
190
+ } else if (px(this.props.height, this._container) > this._textarea.scrollHeight) {
191
+ this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
192
+ height = this.props.height;
193
+ }
194
+ }
195
+
196
+ // preserve container height to prevent scroll jumping on long textareas,
197
+ // but make sure container doesn't exceed maxHeight prop
198
+ const heightExceedsMax = maxHeight !== undefined && px(height) > maxHeight;
199
+ if (!heightExceedsMax) {
200
+ this._container.style.minHeight = height;
201
+ }
202
+ this._height = height;
203
+ this._textarea.style.height = height;
204
+ };
211
205
  focus() {
212
206
  this._textarea.focus();
213
207
  }
208
+ handleChange = event => {
209
+ const {
210
+ onChange,
211
+ value,
212
+ disabled,
213
+ readOnly
214
+ } = this.props;
215
+ if (disabled || readOnly) {
216
+ event.preventDefault();
217
+ return;
218
+ }
219
+ if (typeof value === 'undefined') {
220
+ // if uncontrolled
221
+ this.autoGrow();
222
+ }
223
+ if (typeof onChange === 'function') {
224
+ onChange(event);
225
+ }
226
+ };
227
+ handleContainerRef = node => {
228
+ this._container = node;
229
+ };
214
230
  get minHeight() {
215
231
  return this._textarea.style.minHeight;
216
232
  }
@@ -229,27 +245,27 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
229
245
  return this._textarea.value;
230
246
  }
231
247
  render() {
232
- var _this$props$styles, _this$props$styles2, _this$props$styles3;
233
- const _this$props4 = this.props,
234
- autoGrow = _this$props4.autoGrow,
235
- placeholder = _this$props4.placeholder,
236
- value = _this$props4.value,
237
- defaultValue = _this$props4.defaultValue,
238
- disabled = _this$props4.disabled,
239
- readOnly = _this$props4.readOnly,
240
- required = _this$props4.required,
241
- width = _this$props4.width,
242
- height = _this$props4.height,
243
- maxHeight = _this$props4.maxHeight,
244
- textareaRef = _this$props4.textareaRef,
245
- resize = _this$props4.resize,
246
- styles = _this$props4.styles,
247
- margin = _this$props4.margin;
248
+ const {
249
+ autoGrow,
250
+ placeholder,
251
+ value,
252
+ defaultValue,
253
+ disabled,
254
+ readOnly,
255
+ required,
256
+ width,
257
+ height,
258
+ maxHeight,
259
+ textareaRef,
260
+ resize,
261
+ styles,
262
+ margin
263
+ } = this.props;
248
264
  const props = omitProps(this.props, TextArea.allowedProps);
249
265
  const style = {
250
266
  width,
251
267
  resize,
252
- height: !autoGrow ? height : void 0,
268
+ height: !autoGrow ? height : undefined,
253
269
  maxHeight
254
270
  };
255
271
  const textarea = _jsx("textarea", {
@@ -259,8 +275,7 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
259
275
  placeholder: placeholder,
260
276
  ref: textarea => {
261
277
  if (textarea) {
262
- var _this$myObserver;
263
- (_this$myObserver = this.myObserver) === null || _this$myObserver === void 0 ? void 0 : _this$myObserver.observe(textarea);
278
+ this.myObserver?.observe(textarea);
264
279
  }
265
280
  this._textarea = textarea;
266
281
  if (typeof textareaRef === 'function') {
@@ -271,14 +286,14 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
271
286
  id: this.id,
272
287
  required: required,
273
288
  "aria-required": required,
274
- "aria-invalid": this.invalid ? 'true' : void 0,
289
+ "aria-invalid": this.invalid ? 'true' : undefined,
275
290
  disabled: disabled || readOnly,
276
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
291
+ css: this.props.styles?.textArea,
277
292
  onChange: this.handleChange
278
293
  });
279
294
  const label = hasVisibleChildren(this.props.label) ? _jsxs(Fragment, {
280
295
  children: [this.props.label, required && _jsxs("span", {
281
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
296
+ css: this.invalid ? styles?.requiredInvalid : {},
282
297
  "aria-hidden": true,
283
298
  children: [' ', "*"]
284
299
  })]
@@ -294,14 +309,14 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
294
309
  margin: margin,
295
310
  "data-cid": "TextArea",
296
311
  children: _jsxs("div", {
297
- css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.textAreaLayout,
312
+ css: this.props.styles?.textAreaLayout,
298
313
  style: {
299
314
  width,
300
315
  maxHeight
301
316
  },
302
317
  ref: this.handleContainerRef,
303
318
  children: [textarea, !disabled && !readOnly ? _jsx("span", {
304
- css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.textAreaOutline,
319
+ css: this.props.styles?.textAreaOutline,
305
320
  "aria-hidden": "true",
306
321
  ref: e => {
307
322
  this._highlightRef = e;
@@ -310,16 +325,6 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
310
325
  })
311
326
  });
312
327
  }
313
- }, _TextArea.displayName = "TextArea", _TextArea.componentId = 'TextArea', _TextArea.allowedProps = allowedProps, _TextArea.defaultProps = {
314
- size: 'medium',
315
- autoGrow: true,
316
- resize: 'none',
317
- inline: false,
318
- messages: [],
319
- disabled: false,
320
- readOnly: false,
321
- layout: 'stacked',
322
- required: false
323
- }, _TextArea)) || _class) || _class);
328
+ }) || _class) || _class);
324
329
  export default TextArea;
325
330
  export { TextArea };
@@ -33,8 +33,10 @@
33
33
  * @return {Object} The final style object, which will be used in the component
34
34
  */
35
35
  const generateStyle = (componentTheme, props) => {
36
- const disabled = props.disabled,
37
- size = props.size;
36
+ const {
37
+ disabled,
38
+ size
39
+ } = props;
38
40
  const fontSizeVariants = {
39
41
  small: {
40
42
  fontSize: componentTheme.smallFontSize
@@ -28,13 +28,14 @@
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1;
32
- const colors = theme.colors,
33
- typography = theme.typography,
34
- borders = theme.borders,
35
- spacing = theme.spacing,
36
- forms = theme.forms,
37
- themeName = theme.key;
31
+ const {
32
+ colors,
33
+ typography,
34
+ borders,
35
+ spacing,
36
+ forms,
37
+ key: themeName
38
+ } = theme;
38
39
  const themeSpecificStyle = {
39
40
  canvas: {
40
41
  color: theme['ic-brand-font-color-dark'],
@@ -42,31 +43,31 @@ const generateComponentTheme = theme => {
42
43
  }
43
44
  };
44
45
  const componentVariables = {
45
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
46
- fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
47
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
48
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
49
- requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.red5782,
50
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
51
- borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
52
- borderTopColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey3045,
53
- borderRightColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey3045,
54
- borderBottomColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.grey3045,
55
- borderLeftColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.grey3045,
56
- borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
57
- padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
58
- focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.blue4570,
59
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
60
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
61
- errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.red4570,
62
- errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.red4570,
63
- placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.grey4570,
64
- smallFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
65
- smallHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall,
66
- mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
67
- mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
68
- largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
69
- largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
46
+ fontFamily: typography?.fontFamily,
47
+ fontWeight: typography?.fontWeightNormal,
48
+ color: colors?.contrasts?.grey125125,
49
+ background: colors?.contrasts?.white1010,
50
+ requiredInvalidColor: colors?.contrasts?.red5782,
51
+ borderWidth: borders?.widthSmall,
52
+ borderStyle: borders?.style,
53
+ borderTopColor: colors?.contrasts?.grey3045,
54
+ borderRightColor: colors?.contrasts?.grey3045,
55
+ borderBottomColor: colors?.contrasts?.grey3045,
56
+ borderLeftColor: colors?.contrasts?.grey3045,
57
+ borderRadius: borders?.radiusMedium,
58
+ padding: spacing?.small,
59
+ focusOutlineColor: colors?.contrasts?.blue4570,
60
+ focusOutlineWidth: borders?.widthMedium,
61
+ focusOutlineStyle: borders?.style,
62
+ errorBorderColor: colors?.contrasts?.red4570,
63
+ errorOutlineColor: colors?.contrasts?.red4570,
64
+ placeholderColor: colors?.contrasts?.grey4570,
65
+ smallFontSize: typography?.fontSizeSmall,
66
+ smallHeight: forms?.inputHeightSmall,
67
+ mediumFontSize: typography?.fontSizeMedium,
68
+ mediumHeight: forms?.inputHeightMedium,
69
+ largeFontSize: typography?.fontSizeLarge,
70
+ largeHeight: forms?.inputHeightLarge
70
71
  };
71
72
  return {
72
73
  ...componentVariables,
@@ -1,5 +1,3 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["size", "autoGrow", "resize", "inline", "messages", "disabled", "readOnly", "layout", "required", "placeholder", "value", "defaultValue", "width", "height", "maxHeight", "textareaRef", "margin", "label", "onChange", "id", "themeOverride"];
3
1
  /*
4
2
  * The MIT License (MIT)
5
3
  *
@@ -39,37 +37,30 @@ category: components
39
37
  ---
40
38
  **/
41
39
  const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
42
- const _props$size = props.size,
43
- size = _props$size === void 0 ? 'medium' : _props$size,
44
- _props$autoGrow = props.autoGrow,
45
- autoGrow = _props$autoGrow === void 0 ? true : _props$autoGrow,
46
- _props$resize = props.resize,
47
- resize = _props$resize === void 0 ? 'none' : _props$resize,
48
- _props$inline = props.inline,
49
- inline = _props$inline === void 0 ? false : _props$inline,
50
- _props$messages = props.messages,
51
- messages = _props$messages === void 0 ? [] : _props$messages,
52
- _props$disabled = props.disabled,
53
- disabled = _props$disabled === void 0 ? false : _props$disabled,
54
- _props$readOnly = props.readOnly,
55
- readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
56
- _props$layout = props.layout,
57
- layout = _props$layout === void 0 ? 'stacked' : _props$layout,
58
- _props$required = props.required,
59
- required = _props$required === void 0 ? false : _props$required,
60
- placeholder = props.placeholder,
61
- value = props.value,
62
- defaultValue = props.defaultValue,
63
- width = props.width,
64
- height = props.height,
65
- maxHeight = props.maxHeight,
66
- textareaRef = props.textareaRef,
67
- margin = props.margin,
68
- label = props.label,
69
- onChange = props.onChange,
70
- propId = props.id,
71
- themeOverride = props.themeOverride,
72
- rest = _objectWithoutProperties(props, _excluded);
40
+ const {
41
+ size = 'medium',
42
+ autoGrow = true,
43
+ resize = 'none',
44
+ inline = false,
45
+ messages = [],
46
+ disabled = false,
47
+ readOnly = false,
48
+ layout = 'stacked',
49
+ required = false,
50
+ placeholder,
51
+ value,
52
+ defaultValue,
53
+ width,
54
+ height,
55
+ maxHeight,
56
+ textareaRef,
57
+ margin,
58
+ label,
59
+ onChange,
60
+ id: propId,
61
+ themeOverride,
62
+ ...rest
63
+ } = props;
73
64
 
74
65
  // Use deterministic ID
75
66
  const instanceCounterMap = useContext(DeterministicIdContext);
@@ -88,16 +79,17 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
88
79
  const formFieldRef = useRef(null);
89
80
 
90
81
  // Compute invalid state
91
- const _useMemo = useMemo(() => {
92
- const isInvalid = messages && messages.findIndex(message => message.type === 'error' || message.type === 'newError') >= 0;
93
- const isSuccess = messages && messages.findIndex(message => message.type === 'success') >= 0;
94
- return {
95
- isInvalid,
96
- isSuccess
97
- };
98
- }, [messages]),
99
- isInvalid = _useMemo.isInvalid,
100
- isSuccess = _useMemo.isSuccess;
82
+ const {
83
+ isInvalid,
84
+ isSuccess
85
+ } = useMemo(() => {
86
+ const isInvalid = messages && messages.findIndex(message => message.type === 'error' || message.type === 'newError') >= 0;
87
+ const isSuccess = messages && messages.findIndex(message => message.type === 'success') >= 0;
88
+ return {
89
+ isInvalid,
90
+ isSuccess
91
+ };
92
+ }, [messages]);
101
93
 
102
94
  // Use styles
103
95
  const styles = useStyle({
@@ -145,8 +137,8 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
145
137
  _textarea.current.style.height = 'auto';
146
138
  _textarea.current.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
147
139
  heightValue = _textarea.current.scrollHeight + offset + 'px';
148
- const maxHeightPx = maxHeight ? px(maxHeight, _container.current) : void 0;
149
- if (maxHeight && maxHeightPx !== void 0 && _textarea.current.scrollHeight > maxHeightPx) {
140
+ const maxHeightPx = maxHeight ? px(maxHeight, _container.current) : undefined;
141
+ if (maxHeight && maxHeightPx !== undefined && _textarea.current.scrollHeight > maxHeightPx) {
150
142
  _textarea.current.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
151
143
  } else if (height) {
152
144
  if (_textarea.current.value === '') {
@@ -159,7 +151,7 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
159
151
 
160
152
  // preserve container height to prevent scroll jumping on long textareas,
161
153
  // but make sure container doesn't exceed maxHeight prop
162
- const heightExceedsMax = maxHeightPx !== void 0 && px(heightValue) > maxHeightPx;
154
+ const heightExceedsMax = maxHeightPx !== undefined && px(heightValue) > maxHeightPx;
163
155
  if (!heightExceedsMax && _container.current) {
164
156
  _container.current.style.minHeight = heightValue;
165
157
  }
@@ -195,11 +187,14 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
195
187
  _listener.current = addEventListener(window, 'resize', _debounced.current);
196
188
  }
197
189
  if (_textarea.current && !_textareaResizeListener.current) {
198
- const _getBoundingClientRec = getBoundingClientRect(_textarea.current),
199
- origHeight = _getBoundingClientRec.height;
190
+ const {
191
+ height: origHeight
192
+ } = getBoundingClientRect(_textarea.current);
200
193
  _textareaResizeListener.current = new ResizeObserver(entries => {
201
194
  for (const entry of entries) {
202
- const entryHeight = entry.contentRect.height;
195
+ const {
196
+ height: entryHeight
197
+ } = entry.contentRect;
203
198
  if (origHeight !== entryHeight) {
204
199
  _textareaResize();
205
200
  }
@@ -248,11 +243,14 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
248
243
  _listener.current = addEventListener(window, 'resize', _debounced.current);
249
244
  }
250
245
  if (_textarea.current && !_textareaResizeListener.current) {
251
- const _getBoundingClientRec2 = getBoundingClientRect(_textarea.current),
252
- origHeight = _getBoundingClientRec2.height;
246
+ const {
247
+ height: origHeight
248
+ } = getBoundingClientRect(_textarea.current);
253
249
  _textareaResizeListener.current = new ResizeObserver(entries => {
254
250
  for (const entry of entries) {
255
- const entryHeight = entry.contentRect.height;
251
+ const {
252
+ height: entryHeight
253
+ } = entry.contentRect;
256
254
  if (origHeight !== entryHeight) {
257
255
  _textareaResize();
258
256
  }
@@ -271,16 +269,13 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
271
269
  // Expose API through ref using useImperativeHandle
272
270
  useImperativeHandle(ref, () => ({
273
271
  focus: () => {
274
- var _textarea$current;
275
- (_textarea$current = _textarea.current) === null || _textarea$current === void 0 ? void 0 : _textarea$current.focus();
272
+ _textarea.current?.focus();
276
273
  },
277
274
  get value() {
278
- var _textarea$current2;
279
- return ((_textarea$current2 = _textarea.current) === null || _textarea$current2 === void 0 ? void 0 : _textarea$current2.value) || '';
275
+ return _textarea.current?.value || '';
280
276
  },
281
277
  get minHeight() {
282
- var _textarea$current3;
283
- return ((_textarea$current3 = _textarea.current) === null || _textarea$current3 === void 0 ? void 0 : _textarea$current3.style.minHeight) || '';
278
+ return _textarea.current?.style.minHeight || '';
284
279
  },
285
280
  get focused() {
286
281
  return isActiveElement(_textarea.current);
@@ -296,7 +291,7 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
296
291
  const style = {
297
292
  width,
298
293
  resize,
299
- height: !autoGrow ? height : void 0,
294
+ height: !autoGrow ? height : undefined,
300
295
  maxHeight
301
296
  };
302
297
  const textarea = _jsx("textarea", {
@@ -314,10 +309,10 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
314
309
  id: id,
315
310
  required: required,
316
311
  "aria-required": required,
317
- "aria-invalid": isInvalid ? 'true' : void 0,
312
+ "aria-invalid": isInvalid ? 'true' : undefined,
318
313
  disabled: disabled,
319
314
  readOnly: readOnly,
320
- css: styles === null || styles === void 0 ? void 0 : styles.textArea,
315
+ css: styles?.textArea,
321
316
  onChange: handleChange
322
317
  });
323
318
  return _jsx(FormField, {
@@ -334,7 +329,7 @@ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
334
329
  readOnly: readOnly,
335
330
  "data-cid": "TextArea",
336
331
  children: _jsx("div", {
337
- css: styles === null || styles === void 0 ? void 0 : styles.textAreaLayout,
332
+ css: styles?.textAreaLayout,
338
333
  style: {
339
334
  width,
340
335
  maxHeight