@instructure/ui-text-area 8.25.1-snapshot-10 → 8.25.1-snapshot-13
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 +1 -1
- package/es/TextArea/index.js +105 -109
- package/lib/TextArea/index.js +105 -109
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.25.1-snapshot-
|
|
6
|
+
## [8.25.1-snapshot-13](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-13) (2022-06-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-text-area
|
|
9
9
|
|
package/es/TextArea/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _dec3, _class;
|
|
1
|
+
var _dec, _dec2, _dec3, _class, _class2;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -43,50 +43,112 @@ category: components
|
|
|
43
43
|
@tsProps
|
|
44
44
|
**/
|
|
45
45
|
|
|
46
|
-
let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = class TextArea extends Component {
|
|
47
|
-
static displayName = "TextArea";
|
|
48
|
-
static componentId = 'TextArea';
|
|
49
|
-
static allowedProps = allowedProps;
|
|
50
|
-
static propTypes = propTypes;
|
|
51
|
-
static defaultProps = {
|
|
52
|
-
size: 'medium',
|
|
53
|
-
autoGrow: true,
|
|
54
|
-
resize: 'none',
|
|
55
|
-
inline: false,
|
|
56
|
-
messages: [],
|
|
57
|
-
disabled: false,
|
|
58
|
-
readOnly: false,
|
|
59
|
-
layout: 'stacked',
|
|
60
|
-
required: false
|
|
61
|
-
};
|
|
62
|
-
_listener;
|
|
63
|
-
_request;
|
|
64
|
-
_defaultId;
|
|
65
|
-
_textareaResizeListener;
|
|
66
|
-
_debounced;
|
|
67
|
-
_textarea = null;
|
|
68
|
-
_container = null;
|
|
69
|
-
_height;
|
|
70
|
-
_manuallyResized = false;
|
|
71
|
-
ref = null;
|
|
72
|
-
|
|
46
|
+
let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TextArea extends Component {
|
|
73
47
|
constructor(props) {
|
|
74
48
|
super(props);
|
|
49
|
+
this._listener = void 0;
|
|
50
|
+
this._request = void 0;
|
|
51
|
+
this._defaultId = void 0;
|
|
52
|
+
this._textareaResizeListener = void 0;
|
|
53
|
+
this._debounced = void 0;
|
|
54
|
+
this._textarea = null;
|
|
55
|
+
this._container = null;
|
|
56
|
+
this._height = void 0;
|
|
57
|
+
this._manuallyResized = false;
|
|
58
|
+
this.ref = null;
|
|
59
|
+
|
|
60
|
+
this._textareaResize = () => {
|
|
61
|
+
const textareaHeight = this._textarea.style.height;
|
|
62
|
+
|
|
63
|
+
if (textareaHeight !== '' && textareaHeight !== this._height) {
|
|
64
|
+
this._manuallyResized = true;
|
|
65
|
+
this._textarea.style.overflowY = 'auto'; // update container minHeight to ensure focus ring always wraps input
|
|
66
|
+
|
|
67
|
+
this._container.style.minHeight = textareaHeight;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
this.grow = () => {
|
|
72
|
+
if (!this._textarea || this._manuallyResized) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
|
|
77
|
+
let height = ''; // Notes:
|
|
78
|
+
// 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
|
|
79
|
+
// 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
|
|
80
|
+
|
|
81
|
+
this._textarea.style.height = 'auto';
|
|
82
|
+
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
83
|
+
|
|
84
|
+
height = this._textarea.scrollHeight + offset + 'px';
|
|
85
|
+
const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : void 0;
|
|
86
|
+
|
|
87
|
+
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
88
|
+
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
89
|
+
} else if (this.props.height) {
|
|
90
|
+
if (this._textarea.value === '') {
|
|
91
|
+
height = this.props.height;
|
|
92
|
+
} else if (px(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
93
|
+
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
94
|
+
|
|
95
|
+
height = this.props.height;
|
|
96
|
+
}
|
|
97
|
+
} // preserve container height to prevent scroll jumping on long textareas,
|
|
98
|
+
// but make sure container doesn't exceed maxHeight prop
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
const heightExceedsMax = maxHeight !== void 0 && px(height) > maxHeight;
|
|
102
|
+
|
|
103
|
+
if (!heightExceedsMax) {
|
|
104
|
+
this._container.style.minHeight = height;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this._height = height;
|
|
108
|
+
this._textarea.style.height = height;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
this.handleChange = event => {
|
|
112
|
+
const _this$props = this.props,
|
|
113
|
+
onChange = _this$props.onChange,
|
|
114
|
+
value = _this$props.value,
|
|
115
|
+
disabled = _this$props.disabled,
|
|
116
|
+
readOnly = _this$props.readOnly;
|
|
117
|
+
|
|
118
|
+
if (disabled || readOnly) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (typeof value === 'undefined') {
|
|
124
|
+
// if uncontrolled
|
|
125
|
+
this.autoGrow();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (typeof onChange === 'function') {
|
|
129
|
+
onChange(event);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
this.handleContainerRef = node => {
|
|
134
|
+
this._container = node;
|
|
135
|
+
};
|
|
136
|
+
|
|
75
137
|
this._defaultId = props.deterministicId();
|
|
76
138
|
}
|
|
77
139
|
|
|
78
140
|
componentDidMount() {
|
|
79
|
-
var _this$props$makeStyle, _this$
|
|
141
|
+
var _this$props$makeStyle, _this$props2;
|
|
80
142
|
|
|
81
143
|
this.autoGrow();
|
|
82
|
-
(_this$props$makeStyle = (_this$
|
|
144
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
83
145
|
}
|
|
84
146
|
|
|
85
147
|
componentDidUpdate() {
|
|
86
|
-
var _this$props$makeStyle2, _this$
|
|
148
|
+
var _this$props$makeStyle2, _this$props3;
|
|
87
149
|
|
|
88
150
|
this.autoGrow();
|
|
89
|
-
(_this$props$makeStyle2 = (_this$
|
|
151
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
90
152
|
}
|
|
91
153
|
|
|
92
154
|
componentWillUnmount() {
|
|
@@ -107,17 +169,6 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
107
169
|
}
|
|
108
170
|
}
|
|
109
171
|
|
|
110
|
-
_textareaResize = () => {
|
|
111
|
-
const textareaHeight = this._textarea.style.height;
|
|
112
|
-
|
|
113
|
-
if (textareaHeight !== '' && textareaHeight !== this._height) {
|
|
114
|
-
this._manuallyResized = true;
|
|
115
|
-
this._textarea.style.overflowY = 'auto'; // update container minHeight to ensure focus ring always wraps input
|
|
116
|
-
|
|
117
|
-
this._container.style.minHeight = textareaHeight;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
172
|
autoGrow() {
|
|
122
173
|
if (this.props.autoGrow) {
|
|
123
174
|
if (!this._debounced) {
|
|
@@ -152,75 +203,10 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
152
203
|
}
|
|
153
204
|
}
|
|
154
205
|
|
|
155
|
-
grow = () => {
|
|
156
|
-
if (!this._textarea || this._manuallyResized) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
|
|
161
|
-
let height = ''; // Notes:
|
|
162
|
-
// 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
|
|
163
|
-
// 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
|
|
164
|
-
|
|
165
|
-
this._textarea.style.height = 'auto';
|
|
166
|
-
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
167
|
-
|
|
168
|
-
height = this._textarea.scrollHeight + offset + 'px';
|
|
169
|
-
const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : void 0;
|
|
170
|
-
|
|
171
|
-
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
172
|
-
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
173
|
-
} else if (this.props.height) {
|
|
174
|
-
if (this._textarea.value === '') {
|
|
175
|
-
height = this.props.height;
|
|
176
|
-
} else if (px(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
177
|
-
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
178
|
-
|
|
179
|
-
height = this.props.height;
|
|
180
|
-
}
|
|
181
|
-
} // preserve container height to prevent scroll jumping on long textareas,
|
|
182
|
-
// but make sure container doesn't exceed maxHeight prop
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const heightExceedsMax = maxHeight !== void 0 && px(height) > maxHeight;
|
|
186
|
-
|
|
187
|
-
if (!heightExceedsMax) {
|
|
188
|
-
this._container.style.minHeight = height;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
this._height = height;
|
|
192
|
-
this._textarea.style.height = height;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
206
|
focus() {
|
|
196
207
|
this._textarea.focus();
|
|
197
208
|
}
|
|
198
209
|
|
|
199
|
-
handleChange = event => {
|
|
200
|
-
const _this$props3 = this.props,
|
|
201
|
-
onChange = _this$props3.onChange,
|
|
202
|
-
value = _this$props3.value,
|
|
203
|
-
disabled = _this$props3.disabled,
|
|
204
|
-
readOnly = _this$props3.readOnly;
|
|
205
|
-
|
|
206
|
-
if (disabled || readOnly) {
|
|
207
|
-
event.preventDefault();
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (typeof value === 'undefined') {
|
|
212
|
-
// if uncontrolled
|
|
213
|
-
this.autoGrow();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (typeof onChange === 'function') {
|
|
217
|
-
onChange(event);
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
handleContainerRef = node => {
|
|
221
|
-
this._container = node;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
210
|
get minHeight() {
|
|
225
211
|
return this._textarea.style.minHeight;
|
|
226
212
|
}
|
|
@@ -306,6 +292,16 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
306
292
|
}) : null));
|
|
307
293
|
}
|
|
308
294
|
|
|
309
|
-
}
|
|
295
|
+
}, _class2.displayName = "TextArea", _class2.componentId = 'TextArea', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
296
|
+
size: 'medium',
|
|
297
|
+
autoGrow: true,
|
|
298
|
+
resize: 'none',
|
|
299
|
+
inline: false,
|
|
300
|
+
messages: [],
|
|
301
|
+
disabled: false,
|
|
302
|
+
readOnly: false,
|
|
303
|
+
layout: 'stacked',
|
|
304
|
+
required: false
|
|
305
|
+
}, _class2)) || _class) || _class) || _class);
|
|
310
306
|
export default TextArea;
|
|
311
307
|
export { TextArea };
|
package/lib/TextArea/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
39
39
|
|
|
40
40
|
var _props = require("./props");
|
|
41
41
|
|
|
42
|
-
var _dec, _dec2, _dec3, _class;
|
|
42
|
+
var _dec, _dec2, _dec3, _class, _class2;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
---
|
|
@@ -47,50 +47,112 @@ category: components
|
|
|
47
47
|
---
|
|
48
48
|
@tsProps
|
|
49
49
|
**/
|
|
50
|
-
let TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = class TextArea extends _react.Component {
|
|
51
|
-
static displayName = "TextArea";
|
|
52
|
-
static componentId = 'TextArea';
|
|
53
|
-
static allowedProps = _props.allowedProps;
|
|
54
|
-
static propTypes = _props.propTypes;
|
|
55
|
-
static defaultProps = {
|
|
56
|
-
size: 'medium',
|
|
57
|
-
autoGrow: true,
|
|
58
|
-
resize: 'none',
|
|
59
|
-
inline: false,
|
|
60
|
-
messages: [],
|
|
61
|
-
disabled: false,
|
|
62
|
-
readOnly: false,
|
|
63
|
-
layout: 'stacked',
|
|
64
|
-
required: false
|
|
65
|
-
};
|
|
66
|
-
_listener;
|
|
67
|
-
_request;
|
|
68
|
-
_defaultId;
|
|
69
|
-
_textareaResizeListener;
|
|
70
|
-
_debounced;
|
|
71
|
-
_textarea = null;
|
|
72
|
-
_container = null;
|
|
73
|
-
_height;
|
|
74
|
-
_manuallyResized = false;
|
|
75
|
-
ref = null;
|
|
76
|
-
|
|
50
|
+
let TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TextArea extends _react.Component {
|
|
77
51
|
constructor(props) {
|
|
78
52
|
super(props);
|
|
53
|
+
this._listener = void 0;
|
|
54
|
+
this._request = void 0;
|
|
55
|
+
this._defaultId = void 0;
|
|
56
|
+
this._textareaResizeListener = void 0;
|
|
57
|
+
this._debounced = void 0;
|
|
58
|
+
this._textarea = null;
|
|
59
|
+
this._container = null;
|
|
60
|
+
this._height = void 0;
|
|
61
|
+
this._manuallyResized = false;
|
|
62
|
+
this.ref = null;
|
|
63
|
+
|
|
64
|
+
this._textareaResize = () => {
|
|
65
|
+
const textareaHeight = this._textarea.style.height;
|
|
66
|
+
|
|
67
|
+
if (textareaHeight !== '' && textareaHeight !== this._height) {
|
|
68
|
+
this._manuallyResized = true;
|
|
69
|
+
this._textarea.style.overflowY = 'auto'; // update container minHeight to ensure focus ring always wraps input
|
|
70
|
+
|
|
71
|
+
this._container.style.minHeight = textareaHeight;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
this.grow = () => {
|
|
76
|
+
if (!this._textarea || this._manuallyResized) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
|
|
81
|
+
let height = ''; // Notes:
|
|
82
|
+
// 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
|
|
83
|
+
// 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
|
|
84
|
+
|
|
85
|
+
this._textarea.style.height = 'auto';
|
|
86
|
+
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
87
|
+
|
|
88
|
+
height = this._textarea.scrollHeight + offset + 'px';
|
|
89
|
+
const maxHeight = this.props.maxHeight ? (0, _px.px)(this.props.maxHeight, this._container) : void 0;
|
|
90
|
+
|
|
91
|
+
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
92
|
+
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
93
|
+
} else if (this.props.height) {
|
|
94
|
+
if (this._textarea.value === '') {
|
|
95
|
+
height = this.props.height;
|
|
96
|
+
} else if ((0, _px.px)(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
97
|
+
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
98
|
+
|
|
99
|
+
height = this.props.height;
|
|
100
|
+
}
|
|
101
|
+
} // preserve container height to prevent scroll jumping on long textareas,
|
|
102
|
+
// but make sure container doesn't exceed maxHeight prop
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
const heightExceedsMax = maxHeight !== void 0 && (0, _px.px)(height) > maxHeight;
|
|
106
|
+
|
|
107
|
+
if (!heightExceedsMax) {
|
|
108
|
+
this._container.style.minHeight = height;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this._height = height;
|
|
112
|
+
this._textarea.style.height = height;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
this.handleChange = event => {
|
|
116
|
+
const _this$props = this.props,
|
|
117
|
+
onChange = _this$props.onChange,
|
|
118
|
+
value = _this$props.value,
|
|
119
|
+
disabled = _this$props.disabled,
|
|
120
|
+
readOnly = _this$props.readOnly;
|
|
121
|
+
|
|
122
|
+
if (disabled || readOnly) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof value === 'undefined') {
|
|
128
|
+
// if uncontrolled
|
|
129
|
+
this.autoGrow();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (typeof onChange === 'function') {
|
|
133
|
+
onChange(event);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
this.handleContainerRef = node => {
|
|
138
|
+
this._container = node;
|
|
139
|
+
};
|
|
140
|
+
|
|
79
141
|
this._defaultId = props.deterministicId();
|
|
80
142
|
}
|
|
81
143
|
|
|
82
144
|
componentDidMount() {
|
|
83
|
-
var _this$props$makeStyle, _this$
|
|
145
|
+
var _this$props$makeStyle, _this$props2;
|
|
84
146
|
|
|
85
147
|
this.autoGrow();
|
|
86
|
-
(_this$props$makeStyle = (_this$
|
|
148
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
87
149
|
}
|
|
88
150
|
|
|
89
151
|
componentDidUpdate() {
|
|
90
|
-
var _this$props$makeStyle2, _this$
|
|
152
|
+
var _this$props$makeStyle2, _this$props3;
|
|
91
153
|
|
|
92
154
|
this.autoGrow();
|
|
93
|
-
(_this$props$makeStyle2 = (_this$
|
|
155
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
94
156
|
}
|
|
95
157
|
|
|
96
158
|
componentWillUnmount() {
|
|
@@ -111,17 +173,6 @@ let TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
111
173
|
}
|
|
112
174
|
}
|
|
113
175
|
|
|
114
|
-
_textareaResize = () => {
|
|
115
|
-
const textareaHeight = this._textarea.style.height;
|
|
116
|
-
|
|
117
|
-
if (textareaHeight !== '' && textareaHeight !== this._height) {
|
|
118
|
-
this._manuallyResized = true;
|
|
119
|
-
this._textarea.style.overflowY = 'auto'; // update container minHeight to ensure focus ring always wraps input
|
|
120
|
-
|
|
121
|
-
this._container.style.minHeight = textareaHeight;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
176
|
autoGrow() {
|
|
126
177
|
if (this.props.autoGrow) {
|
|
127
178
|
if (!this._debounced) {
|
|
@@ -156,75 +207,10 @@ let TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
156
207
|
}
|
|
157
208
|
}
|
|
158
209
|
|
|
159
|
-
grow = () => {
|
|
160
|
-
if (!this._textarea || this._manuallyResized) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
|
|
165
|
-
let height = ''; // Notes:
|
|
166
|
-
// 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
|
|
167
|
-
// 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
|
|
168
|
-
|
|
169
|
-
this._textarea.style.height = 'auto';
|
|
170
|
-
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
171
|
-
|
|
172
|
-
height = this._textarea.scrollHeight + offset + 'px';
|
|
173
|
-
const maxHeight = this.props.maxHeight ? (0, _px.px)(this.props.maxHeight, this._container) : void 0;
|
|
174
|
-
|
|
175
|
-
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
176
|
-
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
177
|
-
} else if (this.props.height) {
|
|
178
|
-
if (this._textarea.value === '') {
|
|
179
|
-
height = this.props.height;
|
|
180
|
-
} else if ((0, _px.px)(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
181
|
-
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
182
|
-
|
|
183
|
-
height = this.props.height;
|
|
184
|
-
}
|
|
185
|
-
} // preserve container height to prevent scroll jumping on long textareas,
|
|
186
|
-
// but make sure container doesn't exceed maxHeight prop
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const heightExceedsMax = maxHeight !== void 0 && (0, _px.px)(height) > maxHeight;
|
|
190
|
-
|
|
191
|
-
if (!heightExceedsMax) {
|
|
192
|
-
this._container.style.minHeight = height;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this._height = height;
|
|
196
|
-
this._textarea.style.height = height;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
210
|
focus() {
|
|
200
211
|
this._textarea.focus();
|
|
201
212
|
}
|
|
202
213
|
|
|
203
|
-
handleChange = event => {
|
|
204
|
-
const _this$props3 = this.props,
|
|
205
|
-
onChange = _this$props3.onChange,
|
|
206
|
-
value = _this$props3.value,
|
|
207
|
-
disabled = _this$props3.disabled,
|
|
208
|
-
readOnly = _this$props3.readOnly;
|
|
209
|
-
|
|
210
|
-
if (disabled || readOnly) {
|
|
211
|
-
event.preventDefault();
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (typeof value === 'undefined') {
|
|
216
|
-
// if uncontrolled
|
|
217
|
-
this.autoGrow();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (typeof onChange === 'function') {
|
|
221
|
-
onChange(event);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
handleContainerRef = node => {
|
|
225
|
-
this._container = node;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
214
|
get minHeight() {
|
|
229
215
|
return this._textarea.style.minHeight;
|
|
230
216
|
}
|
|
@@ -310,7 +296,17 @@ let TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
310
296
|
}) : null));
|
|
311
297
|
}
|
|
312
298
|
|
|
313
|
-
}
|
|
299
|
+
}, _class2.displayName = "TextArea", _class2.componentId = 'TextArea', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
300
|
+
size: 'medium',
|
|
301
|
+
autoGrow: true,
|
|
302
|
+
resize: 'none',
|
|
303
|
+
inline: false,
|
|
304
|
+
messages: [],
|
|
305
|
+
disabled: false,
|
|
306
|
+
readOnly: false,
|
|
307
|
+
layout: 'stacked',
|
|
308
|
+
required: false
|
|
309
|
+
}, _class2)) || _class) || _class) || _class);
|
|
314
310
|
exports.TextArea = TextArea;
|
|
315
311
|
var _default = TextArea;
|
|
316
312
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-area",
|
|
3
|
-
"version": "8.25.1-snapshot-
|
|
3
|
+
"version": "8.25.1-snapshot-13",
|
|
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.13.10",
|
|
27
|
-
"@instructure/debounce": "8.25.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "8.25.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "8.25.1-snapshot-
|
|
30
|
-
"@instructure/ui-dom-utils": "8.25.1-snapshot-
|
|
31
|
-
"@instructure/ui-form-field": "8.25.1-snapshot-
|
|
32
|
-
"@instructure/ui-prop-types": "8.25.1-snapshot-
|
|
33
|
-
"@instructure/ui-react-utils": "8.25.1-snapshot-
|
|
34
|
-
"@instructure/ui-testable": "8.25.1-snapshot-
|
|
35
|
-
"@instructure/ui-utils": "8.25.1-snapshot-
|
|
36
|
-
"@instructure/uid": "8.25.1-snapshot-
|
|
27
|
+
"@instructure/debounce": "8.25.1-snapshot-13",
|
|
28
|
+
"@instructure/emotion": "8.25.1-snapshot-13",
|
|
29
|
+
"@instructure/shared-types": "8.25.1-snapshot-13",
|
|
30
|
+
"@instructure/ui-dom-utils": "8.25.1-snapshot-13",
|
|
31
|
+
"@instructure/ui-form-field": "8.25.1-snapshot-13",
|
|
32
|
+
"@instructure/ui-prop-types": "8.25.1-snapshot-13",
|
|
33
|
+
"@instructure/ui-react-utils": "8.25.1-snapshot-13",
|
|
34
|
+
"@instructure/ui-testable": "8.25.1-snapshot-13",
|
|
35
|
+
"@instructure/ui-utils": "8.25.1-snapshot-13",
|
|
36
|
+
"@instructure/uid": "8.25.1-snapshot-13",
|
|
37
37
|
"prop-types": "^15"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-babel-preset": "8.25.1-snapshot-
|
|
41
|
-
"@instructure/ui-color-utils": "8.25.1-snapshot-
|
|
42
|
-
"@instructure/ui-test-locator": "8.25.1-snapshot-
|
|
43
|
-
"@instructure/ui-test-utils": "8.25.1-snapshot-
|
|
44
|
-
"@instructure/ui-themes": "8.25.1-snapshot-
|
|
40
|
+
"@instructure/ui-babel-preset": "8.25.1-snapshot-13",
|
|
41
|
+
"@instructure/ui-color-utils": "8.25.1-snapshot-13",
|
|
42
|
+
"@instructure/ui-test-locator": "8.25.1-snapshot-13",
|
|
43
|
+
"@instructure/ui-test-utils": "8.25.1-snapshot-13",
|
|
44
|
+
"@instructure/ui-themes": "8.25.1-snapshot-13"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=16.8 <=17"
|