@instructure/ui-text-area 8.56.0 → 8.56.2-pr-snapshot-1721749364069
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 +16 -0
- package/lib/TextArea/TextAreaLocator.js +3 -3
- package/lib/TextArea/index.js +15 -20
- package/lib/TextArea/props.js +4 -4
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## [8.56.2-pr-snapshot-1721749364069](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2-pr-snapshot-1721749364069) (2024-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-text-area
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [8.56.1](https://github.com/instructure/instructure-ui/compare/v8.56.0...v8.56.1) (2024-06-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @instructure/ui-text-area
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [8.56.0](https://github.com/instructure/instructure-ui/compare/v8.55.1...v8.56.0) (2024-05-06)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @instructure/ui-text-area
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TextAreaLocator = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _uiTestLocator = require("@instructure/ui-test-locator");
|
|
8
8
|
var _index = require("./index");
|
|
9
9
|
/*
|
|
10
10
|
* The MIT License (MIT)
|
|
@@ -31,6 +31,6 @@ var _index = require("./index");
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
34
|
-
const TextAreaLocator = exports.TextAreaLocator = (0,
|
|
35
|
-
findInput: (...args) => (0,
|
|
34
|
+
const TextAreaLocator = exports.TextAreaLocator = (0, _uiTestLocator.locator)(_index.TextArea.selector, {
|
|
35
|
+
findInput: (...args) => (0, _uiTestLocator.locator)('textarea').find(...args)
|
|
36
36
|
});
|
package/lib/TextArea/index.js
CHANGED
|
@@ -6,18 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.TextArea = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
12
|
-
var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
|
|
13
|
-
var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
|
|
9
|
+
var _uiFormField = require("@instructure/ui-form-field");
|
|
10
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
14
11
|
var _debounce = require("@instructure/debounce");
|
|
15
12
|
var _emotion = require("@instructure/emotion");
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
20
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
13
|
+
var _uiUtils = require("@instructure/ui-utils");
|
|
14
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
15
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
21
16
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
22
17
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
23
18
|
var _props = require("./props");
|
|
@@ -51,7 +46,7 @@ var _dec, _dec2, _dec3, _class, _class2;
|
|
|
51
46
|
category: components
|
|
52
47
|
---
|
|
53
48
|
**/
|
|
54
|
-
let TextArea = exports.TextArea = (_dec = (0,
|
|
49
|
+
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 = (_class2 = class TextArea extends _react.Component {
|
|
55
50
|
constructor(props) {
|
|
56
51
|
super(props);
|
|
57
52
|
this._listener = void 0;
|
|
@@ -90,13 +85,13 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
90
85
|
this._textarea.style.height = 'auto';
|
|
91
86
|
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
92
87
|
height = this._textarea.scrollHeight + offset + 'px';
|
|
93
|
-
const maxHeight = this.props.maxHeight ? (0,
|
|
88
|
+
const maxHeight = this.props.maxHeight ? (0, _uiUtils.px)(this.props.maxHeight, this._container) : void 0;
|
|
94
89
|
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
95
90
|
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
96
91
|
} else if (this.props.height) {
|
|
97
92
|
if (this._textarea.value === '') {
|
|
98
93
|
height = this.props.height;
|
|
99
|
-
} else if ((0,
|
|
94
|
+
} else if ((0, _uiUtils.px)(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
100
95
|
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
101
96
|
height = this.props.height;
|
|
102
97
|
}
|
|
@@ -104,7 +99,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
104
99
|
|
|
105
100
|
// preserve container height to prevent scroll jumping on long textareas,
|
|
106
101
|
// but make sure container doesn't exceed maxHeight prop
|
|
107
|
-
const heightExceedsMax = maxHeight !== void 0 && (0,
|
|
102
|
+
const heightExceedsMax = maxHeight !== void 0 && (0, _uiUtils.px)(height) > maxHeight;
|
|
108
103
|
if (!heightExceedsMax) {
|
|
109
104
|
this._container.style.minHeight = height;
|
|
110
105
|
}
|
|
@@ -201,10 +196,10 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
201
196
|
});
|
|
202
197
|
}
|
|
203
198
|
if (!this._listener) {
|
|
204
|
-
this._listener = (0,
|
|
199
|
+
this._listener = (0, _uiDomUtils.addEventListener)(window, 'resize', this._debounced);
|
|
205
200
|
}
|
|
206
201
|
if (this._textarea && !this._textareaResizeListener) {
|
|
207
|
-
const _getBoundingClientRec = (0,
|
|
202
|
+
const _getBoundingClientRec = (0, _uiDomUtils.getBoundingClientRect)(this._textarea),
|
|
208
203
|
origHeight = _getBoundingClientRec.height;
|
|
209
204
|
this._textareaResizeListener = new ResizeObserver(entries => {
|
|
210
205
|
for (const entry of entries) {
|
|
@@ -216,7 +211,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
216
211
|
});
|
|
217
212
|
this._textareaResizeListener.observe(this._textarea);
|
|
218
213
|
}
|
|
219
|
-
this._request = (0,
|
|
214
|
+
this._request = (0, _uiDomUtils.requestAnimationFrame)(this.grow);
|
|
220
215
|
}
|
|
221
216
|
}
|
|
222
217
|
focus() {
|
|
@@ -234,7 +229,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
234
229
|
return this.props.id || this._defaultId;
|
|
235
230
|
}
|
|
236
231
|
get focused() {
|
|
237
|
-
return (0,
|
|
232
|
+
return (0, _uiDomUtils.isActiveElement)(this._textarea);
|
|
238
233
|
}
|
|
239
234
|
get value() {
|
|
240
235
|
return this._textarea.value;
|
|
@@ -254,7 +249,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
254
249
|
maxHeight = _this$props4.maxHeight,
|
|
255
250
|
textareaRef = _this$props4.textareaRef,
|
|
256
251
|
resize = _this$props4.resize;
|
|
257
|
-
const props = (0,
|
|
252
|
+
const props = (0, _uiReactUtils.omitProps)(this.props, TextArea.allowedProps);
|
|
258
253
|
const style = {
|
|
259
254
|
width,
|
|
260
255
|
resize,
|
|
@@ -284,7 +279,7 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
284
279
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
|
|
285
280
|
onChange: this.handleChange
|
|
286
281
|
}));
|
|
287
|
-
return (0, _emotion.jsx)(
|
|
282
|
+
return (0, _emotion.jsx)(_uiFormField.FormField, Object.assign({}, (0, _uiReactUtils.pickProps)(this.props, _uiFormField.FormField.allowedProps), {
|
|
288
283
|
label: this.props.label,
|
|
289
284
|
vAlign: "top",
|
|
290
285
|
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
|
};
|
|
56
56
|
const allowedProps = exports.allowedProps = ['label', 'id', 'size', 'layout', 'autoGrow', 'resize', 'width', 'height', 'maxHeight', 'messages', 'inline', 'placeholder', 'disabled', 'readOnly', 'required', 'textareaRef', 'defaultValue', 'value', 'onChange'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-area",
|
|
3
|
-
"version": "8.56.
|
|
3
|
+
"version": "8.56.2-pr-snapshot-1721749364069",
|
|
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.23.2",
|
|
27
|
-
"@instructure/debounce": "8.56.
|
|
28
|
-
"@instructure/emotion": "8.56.
|
|
29
|
-
"@instructure/shared-types": "8.56.
|
|
30
|
-
"@instructure/ui-dom-utils": "8.56.
|
|
31
|
-
"@instructure/ui-form-field": "8.56.
|
|
32
|
-
"@instructure/ui-prop-types": "8.56.
|
|
33
|
-
"@instructure/ui-react-utils": "8.56.
|
|
34
|
-
"@instructure/ui-testable": "8.56.
|
|
35
|
-
"@instructure/ui-utils": "8.56.
|
|
36
|
-
"@instructure/uid": "8.56.
|
|
27
|
+
"@instructure/debounce": "8.56.2-pr-snapshot-1721749364069",
|
|
28
|
+
"@instructure/emotion": "8.56.2-pr-snapshot-1721749364069",
|
|
29
|
+
"@instructure/shared-types": "8.56.2-pr-snapshot-1721749364069",
|
|
30
|
+
"@instructure/ui-dom-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
31
|
+
"@instructure/ui-form-field": "8.56.2-pr-snapshot-1721749364069",
|
|
32
|
+
"@instructure/ui-prop-types": "8.56.2-pr-snapshot-1721749364069",
|
|
33
|
+
"@instructure/ui-react-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
34
|
+
"@instructure/ui-testable": "8.56.2-pr-snapshot-1721749364069",
|
|
35
|
+
"@instructure/ui-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
36
|
+
"@instructure/uid": "8.56.2-pr-snapshot-1721749364069",
|
|
37
37
|
"prop-types": "^15.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-babel-preset": "8.56.
|
|
41
|
-
"@instructure/ui-color-utils": "8.56.
|
|
42
|
-
"@instructure/ui-test-locator": "8.56.
|
|
43
|
-
"@instructure/ui-test-utils": "8.56.
|
|
44
|
-
"@instructure/ui-themes": "8.56.
|
|
40
|
+
"@instructure/ui-babel-preset": "8.56.2-pr-snapshot-1721749364069",
|
|
41
|
+
"@instructure/ui-color-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
42
|
+
"@instructure/ui-test-locator": "8.56.2-pr-snapshot-1721749364069",
|
|
43
|
+
"@instructure/ui-test-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
44
|
+
"@instructure/ui-themes": "8.56.2-pr-snapshot-1721749364069"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=16.8 <=18"
|