@instructure/ui-text-area 10.13.0 → 10.13.1-pr-snapshot-1741357986437
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 +8 -0
- package/lib/TextArea/__new-tests__/TextArea.test.js +2 -2
- package/lib/TextArea/index.js +17 -22
- package/lib/TextArea/props.js +4 -4
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [10.13.1-pr-snapshot-1741357986437](https://github.com/instructure/instructure-ui/compare/v10.13.0...v10.13.1-pr-snapshot-1741357986437) (2025-03-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-text-area
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [10.13.0](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.13.0) (2025-03-06)
|
|
7
15
|
|
|
8
16
|
|
|
@@ -5,7 +5,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
6
|
var _vitest = require("vitest");
|
|
7
7
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
-
var
|
|
8
|
+
var _uiAxeCheck = require("@instructure/ui-axe-check");
|
|
9
9
|
require("@testing-library/jest-dom");
|
|
10
10
|
var _index = require("../index");
|
|
11
11
|
var _TextArea, _TextArea2, _TextArea3, _TextArea4;
|
|
@@ -200,7 +200,7 @@ describe('TextArea', () => {
|
|
|
200
200
|
autoGrow: false
|
|
201
201
|
}))),
|
|
202
202
|
container = _render2.container;
|
|
203
|
-
const axeCheck = await (0,
|
|
203
|
+
const axeCheck = await (0, _uiAxeCheck.runAxeCheck)(container);
|
|
204
204
|
expect(axeCheck).toBe(true);
|
|
205
205
|
});
|
|
206
206
|
it('should set aria-invalid when errors prop is set', async () => {
|
package/lib/TextArea/index.js
CHANGED
|
@@ -7,19 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.TextArea = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
13
|
-
var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
|
|
14
|
-
var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
|
|
10
|
+
var _uiFormField = require("@instructure/ui-form-field");
|
|
11
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
15
12
|
var _debounce = require("@instructure/debounce");
|
|
16
13
|
var _emotion = require("@instructure/emotion");
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
22
|
-
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
14
|
+
var _uiUtils = require("@instructure/ui-utils");
|
|
15
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
16
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
17
|
+
var _uiA11yUtils = require("@instructure/ui-a11y-utils");
|
|
23
18
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
24
19
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
20
|
var _props = require("./props");
|
|
@@ -53,7 +48,7 @@ var _dec, _dec2, _dec3, _class, _TextArea;
|
|
|
53
48
|
category: components
|
|
54
49
|
---
|
|
55
50
|
**/
|
|
56
|
-
let TextArea = exports.TextArea = (_dec = (0,
|
|
51
|
+
let TextArea = exports.TextArea = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_TextArea = class TextArea extends _react.Component {
|
|
57
52
|
constructor(props) {
|
|
58
53
|
super(props);
|
|
59
54
|
this._listener = void 0;
|
|
@@ -92,13 +87,13 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
92
87
|
this._textarea.style.height = 'auto';
|
|
93
88
|
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
94
89
|
height = this._textarea.scrollHeight + offset + 'px';
|
|
95
|
-
const maxHeight = this.props.maxHeight ? (0,
|
|
90
|
+
const maxHeight = this.props.maxHeight ? (0, _uiUtils.px)(this.props.maxHeight, this._container) : void 0;
|
|
96
91
|
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
97
92
|
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
98
93
|
} else if (this.props.height) {
|
|
99
94
|
if (this._textarea.value === '') {
|
|
100
95
|
height = this.props.height;
|
|
101
|
-
} else if ((0,
|
|
96
|
+
} else if ((0, _uiUtils.px)(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
102
97
|
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
103
98
|
height = this.props.height;
|
|
104
99
|
}
|
|
@@ -106,7 +101,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
106
101
|
|
|
107
102
|
// preserve container height to prevent scroll jumping on long textareas,
|
|
108
103
|
// but make sure container doesn't exceed maxHeight prop
|
|
109
|
-
const heightExceedsMax = maxHeight !== void 0 && (0,
|
|
104
|
+
const heightExceedsMax = maxHeight !== void 0 && (0, _uiUtils.px)(height) > maxHeight;
|
|
110
105
|
if (!heightExceedsMax) {
|
|
111
106
|
this._container.style.minHeight = height;
|
|
112
107
|
}
|
|
@@ -203,10 +198,10 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
203
198
|
});
|
|
204
199
|
}
|
|
205
200
|
if (!this._listener) {
|
|
206
|
-
this._listener = (0,
|
|
201
|
+
this._listener = (0, _uiDomUtils.addEventListener)(window, 'resize', this._debounced);
|
|
207
202
|
}
|
|
208
203
|
if (this._textarea && !this._textareaResizeListener) {
|
|
209
|
-
const _getBoundingClientRec = (0,
|
|
204
|
+
const _getBoundingClientRec = (0, _uiDomUtils.getBoundingClientRect)(this._textarea),
|
|
210
205
|
origHeight = _getBoundingClientRec.height;
|
|
211
206
|
this._textareaResizeListener = new ResizeObserver(entries => {
|
|
212
207
|
for (const entry of entries) {
|
|
@@ -218,7 +213,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
218
213
|
});
|
|
219
214
|
this._textareaResizeListener.observe(this._textarea);
|
|
220
215
|
}
|
|
221
|
-
this._request = (0,
|
|
216
|
+
this._request = (0, _uiDomUtils.requestAnimationFrame)(this.grow);
|
|
222
217
|
}
|
|
223
218
|
}
|
|
224
219
|
focus() {
|
|
@@ -236,7 +231,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
236
231
|
return this.props.id || this._defaultId;
|
|
237
232
|
}
|
|
238
233
|
get focused() {
|
|
239
|
-
return (0,
|
|
234
|
+
return (0, _uiDomUtils.isActiveElement)(this._textarea);
|
|
240
235
|
}
|
|
241
236
|
get value() {
|
|
242
237
|
return this._textarea.value;
|
|
@@ -258,7 +253,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
258
253
|
resize = _this$props4.resize,
|
|
259
254
|
styles = _this$props4.styles,
|
|
260
255
|
margin = _this$props4.margin;
|
|
261
|
-
const props = (0,
|
|
256
|
+
const props = (0, _uiReactUtils.omitProps)(this.props, TextArea.allowedProps);
|
|
262
257
|
const style = {
|
|
263
258
|
width,
|
|
264
259
|
resize,
|
|
@@ -288,11 +283,11 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
288
283
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
|
|
289
284
|
onChange: this.handleChange
|
|
290
285
|
}));
|
|
291
|
-
const label = (0,
|
|
286
|
+
const label = (0, _uiA11yUtils.hasVisibleChildren)(this.props.label) ? (0, _emotion.jsx)(_react.default.Fragment, null, this.props.label, required && (0, _emotion.jsx)("span", {
|
|
292
287
|
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
293
288
|
"aria-hidden": true
|
|
294
289
|
}, ' ', "*")) : this.props.label;
|
|
295
|
-
return (0, _emotion.jsx)(
|
|
290
|
+
return (0, _emotion.jsx)(_uiFormField.FormField, Object.assign({}, (0, _uiReactUtils.pickProps)(this.props, _uiFormField.FormField.allowedProps), {
|
|
296
291
|
label: label,
|
|
297
292
|
vAlign: "top",
|
|
298
293
|
id: this.id,
|
package/lib/TextArea/props.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
|
10
|
+
var _uiFormField = require("@instructure/ui-form-field");
|
|
11
11
|
/*
|
|
12
12
|
* The MIT License (MIT)
|
|
13
13
|
*
|
|
@@ -42,7 +42,7 @@ const propTypes = exports.propTypes = {
|
|
|
42
42
|
width: _propTypes.default.string,
|
|
43
43
|
height: _propTypes.default.string,
|
|
44
44
|
maxHeight: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
45
|
-
messages: _propTypes.default.arrayOf(
|
|
45
|
+
messages: _propTypes.default.arrayOf(_uiFormField.FormPropTypes.message),
|
|
46
46
|
inline: _propTypes.default.bool,
|
|
47
47
|
placeholder: _propTypes.default.string,
|
|
48
48
|
disabled: _propTypes.default.bool,
|
|
@@ -50,7 +50,7 @@ const propTypes = exports.propTypes = {
|
|
|
50
50
|
required: _propTypes.default.bool,
|
|
51
51
|
textareaRef: _propTypes.default.func,
|
|
52
52
|
defaultValue: _propTypes.default.string,
|
|
53
|
-
value: (0,
|
|
53
|
+
value: (0, _uiPropTypes.controllable)(_propTypes.default.string),
|
|
54
54
|
onChange: _propTypes.default.func,
|
|
55
55
|
margin: _propTypes.default.string
|
|
56
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-area",
|
|
3
|
-
"version": "10.13.
|
|
3
|
+
"version": "10.13.1-pr-snapshot-1741357986437",
|
|
4
4
|
"description": "A styled HTML text area component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/debounce": "10.13.
|
|
28
|
-
"@instructure/emotion": "10.13.
|
|
29
|
-
"@instructure/shared-types": "10.13.
|
|
30
|
-
"@instructure/ui-dom-utils": "10.13.
|
|
31
|
-
"@instructure/ui-form-field": "10.13.
|
|
32
|
-
"@instructure/ui-prop-types": "10.13.
|
|
33
|
-
"@instructure/ui-react-utils": "10.13.
|
|
34
|
-
"@instructure/ui-testable": "10.13.
|
|
35
|
-
"@instructure/ui-utils": "10.13.
|
|
36
|
-
"@instructure/uid": "10.13.
|
|
27
|
+
"@instructure/debounce": "10.13.1-pr-snapshot-1741357986437",
|
|
28
|
+
"@instructure/emotion": "10.13.1-pr-snapshot-1741357986437",
|
|
29
|
+
"@instructure/shared-types": "10.13.1-pr-snapshot-1741357986437",
|
|
30
|
+
"@instructure/ui-dom-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
31
|
+
"@instructure/ui-form-field": "10.13.1-pr-snapshot-1741357986437",
|
|
32
|
+
"@instructure/ui-prop-types": "10.13.1-pr-snapshot-1741357986437",
|
|
33
|
+
"@instructure/ui-react-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
34
|
+
"@instructure/ui-testable": "10.13.1-pr-snapshot-1741357986437",
|
|
35
|
+
"@instructure/ui-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
36
|
+
"@instructure/uid": "10.13.1-pr-snapshot-1741357986437",
|
|
37
37
|
"prop-types": "^15.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-axe-check": "10.13.
|
|
41
|
-
"@instructure/ui-babel-preset": "10.13.
|
|
42
|
-
"@instructure/ui-color-utils": "10.13.
|
|
43
|
-
"@instructure/ui-test-utils": "10.13.
|
|
44
|
-
"@instructure/ui-themes": "10.13.
|
|
40
|
+
"@instructure/ui-axe-check": "10.13.1-pr-snapshot-1741357986437",
|
|
41
|
+
"@instructure/ui-babel-preset": "10.13.1-pr-snapshot-1741357986437",
|
|
42
|
+
"@instructure/ui-color-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
43
|
+
"@instructure/ui-test-utils": "10.13.1-pr-snapshot-1741357986437",
|
|
44
|
+
"@instructure/ui-themes": "10.13.1-pr-snapshot-1741357986437",
|
|
45
45
|
"@testing-library/jest-dom": "^6.6.3",
|
|
46
46
|
"@testing-library/react": "^16.0.1",
|
|
47
47
|
"@testing-library/user-event": "^14.5.2",
|