@instructure/ui-text-area 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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,6 +3,19 @@
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.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-text-area
@@ -1,28 +1,5 @@
1
- var _dec, _dec2, _class;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
3
  import { Fragment, Component } from 'react';
27
4
  import { FormField } from '@instructure/ui-form-field/v11_6';
28
5
  import { addEventListener, isActiveElement, requestAnimationFrame, getBoundingClientRect } from '@instructure/ui-dom-utils';
@@ -34,298 +11,253 @@ import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
34
11
  import generateStyle from './styles.js';
35
12
  import generateComponentTheme from './theme.js';
36
13
  import { allowedProps } from './props.js';
37
-
38
- /**
39
- ---
40
- category: components
41
- ---
42
- **/
43
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
44
- let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class TextArea extends Component {
45
- static displayName = 'TextArea';
46
- static componentId = 'TextArea';
47
- static allowedProps = allowedProps;
48
- static defaultProps = {
49
- size: 'medium',
50
- autoGrow: true,
51
- resize: 'none',
52
- inline: false,
53
- messages: [],
54
- disabled: false,
55
- readOnly: false,
56
- layout: 'stacked',
57
- required: false
58
- };
59
- _listener;
60
- _request;
61
- _defaultId;
62
- _textareaResizeListener;
63
- _debounced;
64
- _textarea = null;
65
- _container = null;
66
- _height;
67
- _manuallyResized = false;
68
- _highlightRef = null;
69
- myObserver = null;
70
- resizeTimeout;
71
- ref = null;
72
- constructor(props) {
73
- super(props);
74
- this._defaultId = props.deterministicId();
75
-
76
- //mock ResizeObserver for ssr
77
- if (typeof window === 'undefined') {
78
- globalThis.ResizeObserver = class ResizeObserver {
79
- observe() {
80
- // do nothing
81
- }
82
- unobserve() {
83
- // do nothing
84
- }
85
- disconnect() {
86
- // do nothing
87
- }
88
- };
14
+ class TextArea extends Component {
15
+ static{
16
+ this.displayName = 'TextArea';
89
17
  }
90
- }
91
- componentDidMount() {
92
- this.myObserver = new ResizeObserver(entries => {
93
- for (const entry of entries) {
94
- if (this._highlightRef) {
95
- const entryStyle = window.getComputedStyle(entry.target);
96
- this._highlightRef.style.transition = 'none';
97
- this._highlightRef.style.width = `calc(${entryStyle.width} + 0.5rem)`;
98
- this._highlightRef.style.height = `calc(${entryStyle.height} + 0.5rem)`;
99
- clearTimeout(this.resizeTimeout);
100
- this.resizeTimeout = setTimeout(() => {
101
- if (this._highlightRef) {
102
- this._highlightRef.style.transition = 'all 0.2s';
103
- }
104
- }, 500);
105
- }
106
- }
107
- });
108
- this.autoGrow();
109
- this.props.makeStyles?.();
110
- }
111
- componentDidUpdate() {
112
- this.autoGrow();
113
- this.props.makeStyles?.();
114
- }
115
- componentWillUnmount() {
116
- if (this._listener) {
117
- this._listener.remove();
18
+ static{
19
+ this.componentId = 'TextArea';
118
20
  }
119
- if (this._textareaResizeListener) {
120
- this._textareaResizeListener.disconnect();
21
+ static{
22
+ this.allowedProps = allowedProps;
121
23
  }
122
- if (this._request) {
123
- this._request.cancel();
24
+ static{
25
+ this.defaultProps = {
26
+ size: 'medium',
27
+ autoGrow: true,
28
+ resize: 'none',
29
+ inline: false,
30
+ messages: [],
31
+ disabled: false,
32
+ readOnly: false,
33
+ layout: 'stacked',
34
+ required: false
35
+ };
124
36
  }
125
- if (this._debounced) {
126
- this._debounced.cancel();
37
+ constructor(props){
38
+ super(props), this._textarea = null, this._container = null, this._manuallyResized = false, this._highlightRef = null, this.myObserver = null, this.ref = null, this._textareaResize = ()=>{
39
+ const textareaHeight = this._textarea.style.height;
40
+ if (textareaHeight !== '' && textareaHeight !== this._height) {
41
+ this._manuallyResized = true;
42
+ this._textarea.style.overflowY = 'auto';
43
+ this._container.style.minHeight = textareaHeight;
44
+ }
45
+ }, this.grow = ()=>{
46
+ if (!this._textarea || this._manuallyResized) {
47
+ return;
48
+ }
49
+ const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
50
+ let height = '';
51
+ this._textarea.style.height = 'auto';
52
+ this._textarea.style.overflowY = 'hidden';
53
+ height = this._textarea.scrollHeight + offset + 'px';
54
+ const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : undefined;
55
+ if (this.props.maxHeight && maxHeight !== undefined && this._textarea.scrollHeight > maxHeight) {
56
+ this._textarea.style.overflowY = 'auto';
57
+ } else if (this.props.height) {
58
+ if (this._textarea.value === '') {
59
+ height = this.props.height;
60
+ } else if (px(this.props.height, this._container) > this._textarea.scrollHeight) {
61
+ this._textarea.style.overflowY = 'auto';
62
+ height = this.props.height;
63
+ }
64
+ }
65
+ const heightExceedsMax = maxHeight !== undefined && px(height) > maxHeight;
66
+ if (!heightExceedsMax) {
67
+ this._container.style.minHeight = height;
68
+ }
69
+ this._height = height;
70
+ this._textarea.style.height = height;
71
+ }, this.handleChange = (event)=>{
72
+ const { onChange, value, disabled, readOnly } = this.props;
73
+ if (disabled || readOnly) {
74
+ event.preventDefault();
75
+ return;
76
+ }
77
+ if (typeof value === 'undefined') {
78
+ this.autoGrow();
79
+ }
80
+ if (typeof onChange === 'function') {
81
+ onChange(event);
82
+ }
83
+ }, this.handleContainerRef = (node)=>{
84
+ this._container = node;
85
+ };
86
+ this._defaultId = props.deterministicId();
87
+ if (typeof window === 'undefined') {
88
+ globalThis.ResizeObserver = class ResizeObserver1 {
89
+ observe() {}
90
+ unobserve() {}
91
+ disconnect() {}
92
+ };
93
+ }
127
94
  }
128
- if (this.myObserver) {
129
- this.myObserver.disconnect();
95
+ componentDidMount() {
96
+ this.myObserver = new ResizeObserver((entries)=>{
97
+ for (const entry of entries){
98
+ if (this._highlightRef) {
99
+ const entryStyle = window.getComputedStyle(entry.target);
100
+ this._highlightRef.style.transition = 'none';
101
+ this._highlightRef.style.width = `calc(${entryStyle.width} + 0.5rem)`;
102
+ this._highlightRef.style.height = `calc(${entryStyle.height} + 0.5rem)`;
103
+ clearTimeout(this.resizeTimeout);
104
+ this.resizeTimeout = setTimeout(()=>{
105
+ if (this._highlightRef) {
106
+ this._highlightRef.style.transition = 'all 0.2s';
107
+ }
108
+ }, 500);
109
+ }
110
+ }
111
+ });
112
+ this.autoGrow();
113
+ this.props.makeStyles?.();
130
114
  }
131
- }
132
- _textareaResize = () => {
133
- const textareaHeight = this._textarea.style.height;
134
- if (textareaHeight !== '' && textareaHeight !== this._height) {
135
- this._manuallyResized = true;
136
- this._textarea.style.overflowY = 'auto';
137
-
138
- // update container minHeight to ensure focus ring always wraps input
139
- this._container.style.minHeight = textareaHeight;
115
+ componentDidUpdate() {
116
+ this.autoGrow();
117
+ this.props.makeStyles?.();
140
118
  }
141
- };
142
- autoGrow() {
143
- if (this.props.autoGrow) {
144
- if (!this._debounced) {
145
- this._debounced = debounce(this.grow, 200, {
146
- leading: false,
147
- trailing: true
148
- });
149
- }
150
- if (!this._listener) {
151
- this._listener = addEventListener(window, 'resize', this._debounced);
152
- }
153
- if (this._textarea && !this._textareaResizeListener) {
154
- const {
155
- height: origHeight
156
- } = getBoundingClientRect(this._textarea);
157
- this._textareaResizeListener = new ResizeObserver(entries => {
158
- for (const entry of entries) {
159
- const {
160
- height
161
- } = entry.contentRect;
162
- if (origHeight !== height) {
163
- this._textareaResize();
119
+ componentWillUnmount() {
120
+ if (this._listener) {
121
+ this._listener.remove();
122
+ }
123
+ if (this._textareaResizeListener) {
124
+ this._textareaResizeListener.disconnect();
125
+ }
126
+ if (this._request) {
127
+ this._request.cancel();
128
+ }
129
+ if (this._debounced) {
130
+ this._debounced.cancel();
131
+ }
132
+ if (this.myObserver) {
133
+ this.myObserver.disconnect();
134
+ }
135
+ }
136
+ autoGrow() {
137
+ if (this.props.autoGrow) {
138
+ if (!this._debounced) {
139
+ this._debounced = debounce(this.grow, 200, {
140
+ leading: false,
141
+ trailing: true
142
+ });
164
143
  }
165
- }
166
- });
167
- this._textareaResizeListener.observe(this._textarea);
168
- }
169
- this._request = requestAnimationFrame(this.grow);
144
+ if (!this._listener) {
145
+ this._listener = addEventListener(window, 'resize', this._debounced);
146
+ }
147
+ if (this._textarea && !this._textareaResizeListener) {
148
+ const { height: origHeight } = getBoundingClientRect(this._textarea);
149
+ this._textareaResizeListener = new ResizeObserver((entries)=>{
150
+ for (const entry of entries){
151
+ const { height } = entry.contentRect;
152
+ if (origHeight !== height) {
153
+ this._textareaResize();
154
+ }
155
+ }
156
+ });
157
+ this._textareaResizeListener.observe(this._textarea);
158
+ }
159
+ this._request = requestAnimationFrame(this.grow);
160
+ }
170
161
  }
171
- }
172
- grow = () => {
173
- if (!this._textarea || this._manuallyResized) {
174
- return;
162
+ focus() {
163
+ this._textarea.focus();
175
164
  }
176
- const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
177
- let height = '';
178
-
179
- // Notes:
180
- // 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
181
- // 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
182
- this._textarea.style.height = 'auto';
183
- this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
184
- height = this._textarea.scrollHeight + offset + 'px';
185
- const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : undefined;
186
- if (this.props.maxHeight && maxHeight !== undefined && this._textarea.scrollHeight > maxHeight) {
187
- this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
188
- } else if (this.props.height) {
189
- if (this._textarea.value === '') {
190
- height = this.props.height;
191
- } else if (px(this.props.height, this._container) > this._textarea.scrollHeight) {
192
- this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
193
- height = this.props.height;
194
- }
165
+ get minHeight() {
166
+ return this._textarea.style.minHeight;
195
167
  }
196
-
197
- // preserve container height to prevent scroll jumping on long textareas,
198
- // but make sure container doesn't exceed maxHeight prop
199
- const heightExceedsMax = maxHeight !== undefined && px(height) > maxHeight;
200
- if (!heightExceedsMax) {
201
- this._container.style.minHeight = height;
168
+ get invalid() {
169
+ return this.props.messages && this.props.messages.findIndex((message)=>{
170
+ return message.type === 'error' || message.type === 'newError';
171
+ }) >= 0;
202
172
  }
203
- this._height = height;
204
- this._textarea.style.height = height;
205
- };
206
- focus() {
207
- this._textarea.focus();
208
- }
209
- handleChange = event => {
210
- const {
211
- onChange,
212
- value,
213
- disabled,
214
- readOnly
215
- } = this.props;
216
- if (disabled || readOnly) {
217
- event.preventDefault();
218
- return;
173
+ get id() {
174
+ return this.props.id || this._defaultId;
219
175
  }
220
- if (typeof value === 'undefined') {
221
- // if uncontrolled
222
- this.autoGrow();
176
+ get focused() {
177
+ return isActiveElement(this._textarea);
223
178
  }
224
- if (typeof onChange === 'function') {
225
- onChange(event);
179
+ get value() {
180
+ return this._textarea.value;
226
181
  }
227
- };
228
- handleContainerRef = node => {
229
- this._container = node;
230
- };
231
- get minHeight() {
232
- return this._textarea.style.minHeight;
233
- }
234
- get invalid() {
235
- return this.props.messages && this.props.messages.findIndex(message => {
236
- return message.type === 'error' || message.type === 'newError';
237
- }) >= 0;
238
- }
239
- get id() {
240
- return this.props.id || this._defaultId;
241
- }
242
- get focused() {
243
- return isActiveElement(this._textarea);
244
- }
245
- get value() {
246
- return this._textarea.value;
247
- }
248
- render() {
249
- const {
250
- autoGrow,
251
- placeholder,
252
- value,
253
- defaultValue,
254
- disabled,
255
- readOnly,
256
- required,
257
- width,
258
- height,
259
- maxHeight,
260
- textareaRef,
261
- resize,
262
- styles,
263
- margin
264
- } = this.props;
265
- const props = omitProps(this.props, TextArea.allowedProps);
266
- const style = {
267
- width,
268
- resize,
269
- height: !autoGrow ? height : undefined,
270
- maxHeight
271
- };
272
- const textarea = _jsx("textarea", {
273
- ...props,
274
- value: value,
275
- defaultValue: defaultValue,
276
- placeholder: placeholder,
277
- ref: textarea => {
278
- if (textarea) {
279
- this.myObserver?.observe(textarea);
280
- }
281
- this._textarea = textarea;
282
- if (typeof textareaRef === 'function') {
283
- textareaRef(textarea);
284
- }
285
- },
286
- style: style,
287
- id: this.id,
288
- required: required,
289
- "aria-required": required,
290
- "aria-invalid": this.invalid ? 'true' : undefined,
291
- disabled: disabled || readOnly,
292
- css: this.props.styles?.textArea,
293
- onChange: this.handleChange
294
- });
295
- const label = hasVisibleChildren(this.props.label) ? _jsxs(Fragment, {
296
- children: [this.props.label, required && _jsxs("span", {
297
- css: this.invalid ? styles?.requiredInvalid : {},
298
- "aria-hidden": true,
299
- children: [' ', "*"]
300
- })]
301
- }) : this.props.label;
302
- return _jsx(FormField, {
303
- ...pickProps(this.props, FormField.allowedProps),
304
- label: label,
305
- vAlign: "top",
306
- id: this.id,
307
- elementRef: el => {
308
- this.ref = el;
309
- },
310
- margin: margin,
311
- "data-cid": "TextArea",
312
- children: _jsxs("div", {
313
- css: this.props.styles?.textAreaLayout,
314
- style: {
315
- width,
316
- maxHeight
317
- },
318
- ref: this.handleContainerRef,
319
- children: [textarea, !disabled && !readOnly ? _jsx("span", {
320
- css: this.props.styles?.textAreaOutline,
321
- "aria-hidden": "true",
322
- ref: e => {
323
- this._highlightRef = e;
324
- }
325
- }) : null]
326
- })
327
- });
328
- }
329
- }) || _class) || _class);
182
+ render() {
183
+ const { autoGrow, placeholder, value, defaultValue, disabled, readOnly, required, width, height, maxHeight, textareaRef, resize, styles, margin } = this.props;
184
+ const props = omitProps(this.props, TextArea.allowedProps);
185
+ const style = {
186
+ width,
187
+ resize,
188
+ height: !autoGrow ? height : undefined,
189
+ maxHeight
190
+ };
191
+ const textarea = /*#__PURE__*/ _jsx("textarea", {
192
+ ...props,
193
+ value: value,
194
+ defaultValue: defaultValue,
195
+ placeholder: placeholder,
196
+ ref: (textarea)=>{
197
+ if (textarea) {
198
+ this.myObserver?.observe(textarea);
199
+ }
200
+ this._textarea = textarea;
201
+ if (typeof textareaRef === 'function') {
202
+ textareaRef(textarea);
203
+ }
204
+ },
205
+ style: style,
206
+ id: this.id,
207
+ required: required,
208
+ "aria-required": required,
209
+ "aria-invalid": this.invalid ? 'true' : undefined,
210
+ disabled: disabled || readOnly,
211
+ css: this.props.styles?.textArea,
212
+ onChange: this.handleChange
213
+ });
214
+ const label = hasVisibleChildren(this.props.label) ? /*#__PURE__*/ _jsxs(Fragment, {
215
+ children: [
216
+ this.props.label,
217
+ required && /*#__PURE__*/ _jsxs("span", {
218
+ css: this.invalid ? styles?.requiredInvalid : {},
219
+ "aria-hidden": true,
220
+ children: [
221
+ ' ',
222
+ "*"
223
+ ]
224
+ })
225
+ ]
226
+ }) : this.props.label;
227
+ return /*#__PURE__*/ _jsx(FormField, {
228
+ ...pickProps(this.props, FormField.allowedProps),
229
+ label: label,
230
+ vAlign: "top",
231
+ id: this.id,
232
+ elementRef: (el)=>{
233
+ this.ref = el;
234
+ },
235
+ margin: margin,
236
+ "data-cid": "TextArea",
237
+ children: /*#__PURE__*/ _jsxs("div", {
238
+ css: this.props.styles?.textAreaLayout,
239
+ style: {
240
+ width,
241
+ maxHeight
242
+ },
243
+ ref: this.handleContainerRef,
244
+ children: [
245
+ textarea,
246
+ !disabled && !readOnly ? /*#__PURE__*/ _jsx("span", {
247
+ css: this.props.styles?.textAreaOutline,
248
+ "aria-hidden": "true",
249
+ ref: (e)=>{
250
+ this._highlightRef = e;
251
+ }
252
+ }) : null
253
+ ]
254
+ })
255
+ });
256
+ }
257
+ }
258
+ TextArea = _ts_decorate([
259
+ withDeterministicId(),
260
+ withStyle(generateStyle, generateComponentTheme)
261
+ ], TextArea);
330
262
  export default TextArea;
331
- export { TextArea };
263
+ export { TextArea };
@@ -1,26 +1,23 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- const allowedProps = ['label', 'id', 'size', 'layout', 'autoGrow', 'resize', 'width', 'height', 'maxHeight', 'messages', 'inline', 'placeholder', 'disabled', 'readOnly', 'required', 'textareaRef', 'defaultValue', 'value', 'onChange', 'margin'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'label',
3
+ 'id',
4
+ 'size',
5
+ 'layout',
6
+ 'autoGrow',
7
+ 'resize',
8
+ 'width',
9
+ 'height',
10
+ 'maxHeight',
11
+ 'messages',
12
+ 'inline',
13
+ 'placeholder',
14
+ 'disabled',
15
+ 'readOnly',
16
+ 'required',
17
+ 'textareaRef',
18
+ 'defaultValue',
19
+ 'value',
20
+ 'onChange',
21
+ 'margin'
22
+ ];
23
+ export { allowedProps };