@instructure/ui-text-area 8.13.1-snapshot.9 → 8.14.0

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,10 @@
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.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-text-area
9
+
6
10
  # [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
7
11
 
8
12
  ### Bug Fixes
@@ -22,7 +22,8 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import { locator } from '@instructure/ui-test-locator';
25
- import { TextArea } from './index';
25
+ import { TextArea } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
26
+
26
27
  export const TextAreaLocator = locator(TextArea.selector, {
27
28
  findInput: function () {
28
29
  return locator('textarea').find(...arguments);
@@ -41,15 +41,23 @@ import { allowedProps, propTypes } from './props';
41
41
  ---
42
42
  category: components
43
43
  ---
44
+ @tsProps
44
45
  **/
45
46
 
46
47
  let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class TextArea extends Component {
47
- constructor() {
48
- super();
49
- this._listener = null;
48
+ constructor(props) {
49
+ super(props);
50
+ this._listener = void 0;
50
51
  this._request = void 0;
51
-
52
- this._textareaResize = evt => {
52
+ this._defaultId = void 0;
53
+ this._textareaResizeListener = void 0;
54
+ this._debounced = void 0;
55
+ this._textarea = null;
56
+ this._container = null;
57
+ this._height = void 0;
58
+ this._manuallyResized = false;
59
+
60
+ this._textareaResize = () => {
53
61
  const textareaHeight = this._textarea.style.height;
54
62
 
55
63
  if (textareaHeight !== '' && textareaHeight !== this._height) {
@@ -60,7 +68,7 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
60
68
  }
61
69
  };
62
70
 
63
- this.grow = evt => {
71
+ this.grow = () => {
64
72
  if (!this._textarea || this._manuallyResized) {
65
73
  return;
66
74
  }
@@ -74,9 +82,9 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
74
82
  this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
75
83
 
76
84
  height = this._textarea.scrollHeight + offset + 'px';
77
- const maxHeight = px(this.props.maxHeight, this._container);
85
+ const maxHeight = this.props.maxHeight ? px(this.props.maxHeight, this._container) : void 0;
78
86
 
79
- if (this.props.maxHeight && this._textarea.scrollHeight > maxHeight) {
87
+ if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
80
88
  this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
81
89
  } else if (this.props.height) {
82
90
  if (this._textarea.value === '') {
@@ -90,7 +98,7 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
90
98
  // but make sure container doesn't exceed maxHeight prop
91
99
 
92
100
 
93
- const heightExceedsMax = px(height) > maxHeight;
101
+ const heightExceedsMax = maxHeight !== void 0 && px(height) > maxHeight;
94
102
 
95
103
  if (!heightExceedsMax) {
96
104
  this._container.style.minHeight = height;
@@ -136,7 +144,7 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
136
144
  (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
137
145
  }
138
146
 
139
- componentDidUpdate(prevProps, prevState, snapshot) {
147
+ componentDidUpdate() {
140
148
  var _this$props$makeStyle2, _this$props3;
141
149
 
142
150
  this.autoGrow();
@@ -222,10 +230,7 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
222
230
  }
223
231
 
224
232
  render() {
225
- var _this = this,
226
- _this$props$styles,
227
- _this$props$styles2,
228
- _this$props$styles3;
233
+ var _this$props$styles, _this$props$styles2, _this$props$styles3;
229
234
 
230
235
  const _this$props4 = this.props,
231
236
  autoGrow = _this$props4.autoGrow,
@@ -244,37 +249,33 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
244
249
  const style = {
245
250
  width,
246
251
  resize,
247
- height: !autoGrow ? height : null,
252
+ height: !autoGrow ? height : void 0,
248
253
  maxHeight
249
254
  };
250
255
  const textarea = jsx("textarea", Object.assign({}, props, {
251
256
  value: value,
252
257
  defaultValue: defaultValue,
253
258
  placeholder: placeholder,
254
- ref: function (textarea) {
255
- _this._textarea = textarea;
259
+ ref: textarea => {
260
+ this._textarea = textarea;
256
261
 
257
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
258
- args[_key - 1] = arguments[_key];
262
+ if (typeof textareaRef === 'function') {
263
+ textareaRef(textarea);
259
264
  }
260
-
261
- textareaRef.apply(_this, [textarea].concat(args));
262
265
  },
263
266
  style: style,
264
267
  id: this.id,
265
268
  required: required,
266
269
  "aria-required": required,
267
- "aria-invalid": this.invalid ? 'true' : null,
270
+ "aria-invalid": this.invalid ? 'true' : void 0,
268
271
  disabled: disabled || readOnly,
269
272
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
270
273
  onChange: this.handleChange
271
274
  }));
272
275
  return jsx(FormField, Object.assign({}, pickProps(this.props, FormField.allowedProps), {
276
+ label: this.props.label,
273
277
  vAlign: "top",
274
- id: this.id,
275
- ref: el => {
276
- this._node = el;
277
- }
278
+ id: this.id
278
279
  }), jsx("div", {
279
280
  css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.textAreaLayout,
280
281
  style: {
@@ -296,7 +297,6 @@ let TextArea = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
296
297
  messages: [],
297
298
  disabled: false,
298
299
  readOnly: false,
299
- textareaRef: function (textarea) {},
300
300
  layout: 'stacked',
301
301
  required: false
302
302
  }, _temp)) || _class) || _class);
@@ -27,88 +27,22 @@ import { FormPropTypes } from '@instructure/ui-form-field';
27
27
  const propTypes = {
28
28
  label: PropTypes.node.isRequired,
29
29
  id: PropTypes.string,
30
-
31
- /**
32
- * sets the font-size for the textarea
33
- */
34
30
  size: PropTypes.oneOf(['small', 'medium', 'large']),
35
31
  layout: PropTypes.oneOf(['stacked', 'inline']),
36
-
37
- /**
38
- * the textarea will expand vertically to fit the height of the content,
39
- * unless its content exceeds `maxHeight`
40
- */
41
32
  autoGrow: PropTypes.bool,
42
-
43
- /**
44
- * is the textarea resizable (in supported browsers)
45
- */
46
33
  resize: PropTypes.oneOf(['none', 'both', 'horizontal', 'vertical']),
47
-
48
- /**
49
- * a fixed width for the textarea
50
- */
51
34
  width: PropTypes.string,
52
-
53
- /**
54
- * Initial height for the textarea (if autoGrow is true it will grow vertically)
55
- * Accepts CSS units, e.g. '55px'
56
- */
57
35
  height: PropTypes.string,
58
-
59
- /**
60
- * when autoGrow is true, the textarea will never grow beyond this value
61
- */
62
36
  maxHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
63
-
64
- /**
65
- * object with shape: `{
66
- * text: PropTypes.node,
67
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
68
- * }`
69
- */
70
37
  messages: PropTypes.arrayOf(FormPropTypes.message),
71
38
  inline: PropTypes.bool,
72
-
73
- /**
74
- * Html placeholder text to display when the input has no value. This should be hint text, not a label
75
- * replacement.
76
- */
77
39
  placeholder: PropTypes.string,
78
-
79
- /**
80
- * Whether or not to disable the textarea
81
- */
82
40
  disabled: PropTypes.bool,
83
-
84
- /**
85
- * Works just like disabled but keeps the same styles as if it were active
86
- */
87
41
  readOnly: PropTypes.bool,
88
-
89
- /**
90
- * Sets the required property on the underlying native textArea
91
- */
92
42
  required: PropTypes.bool,
93
-
94
- /**
95
- * a function that provides a reference to the actual textarea element
96
- */
97
43
  textareaRef: PropTypes.func,
98
-
99
- /**
100
- * value to set on initial render
101
- */
102
44
  defaultValue: PropTypes.string,
103
-
104
- /**
105
- * the selected value (must be accompanied by an `onChange` prop)
106
- */
107
45
  value: controllable(PropTypes.string),
108
-
109
- /**
110
- * when used with the `value` prop, the component will not control its own state
111
- */
112
46
  onChange: PropTypes.func
113
47
  };
114
48
  const allowedProps = ['label', 'id', 'size', 'layout', 'autoGrow', 'resize', 'width', 'height', 'maxHeight', 'messages', 'inline', 'placeholder', 'disabled', 'readOnly', 'required', 'textareaRef', 'defaultValue', 'value', 'onChange'];
@@ -32,6 +32,7 @@ var _index = require("./index");
32
32
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
33
  * SOFTWARE.
34
34
  */
35
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
35
36
  const TextAreaLocator = (0, _locator.locator)(_index.TextArea.selector, {
36
37
  findInput: function () {
37
38
  return (0, _locator.locator)('textarea').find(...arguments);
@@ -45,14 +45,22 @@ var _dec, _dec2, _class, _class2, _temp;
45
45
  ---
46
46
  category: components
47
47
  ---
48
+ @tsProps
48
49
  **/
49
50
  let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class TextArea extends _react.Component {
50
- constructor() {
51
- super();
52
- this._listener = null;
51
+ constructor(props) {
52
+ super(props);
53
+ this._listener = void 0;
53
54
  this._request = void 0;
54
-
55
- this._textareaResize = evt => {
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
+
63
+ this._textareaResize = () => {
56
64
  const textareaHeight = this._textarea.style.height;
57
65
 
58
66
  if (textareaHeight !== '' && textareaHeight !== this._height) {
@@ -63,7 +71,7 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
63
71
  }
64
72
  };
65
73
 
66
- this.grow = evt => {
74
+ this.grow = () => {
67
75
  if (!this._textarea || this._manuallyResized) {
68
76
  return;
69
77
  }
@@ -77,9 +85,9 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
77
85
  this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
78
86
 
79
87
  height = this._textarea.scrollHeight + offset + 'px';
80
- const maxHeight = (0, _px.px)(this.props.maxHeight, this._container);
88
+ const maxHeight = this.props.maxHeight ? (0, _px.px)(this.props.maxHeight, this._container) : void 0;
81
89
 
82
- if (this.props.maxHeight && this._textarea.scrollHeight > maxHeight) {
90
+ if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
83
91
  this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
84
92
  } else if (this.props.height) {
85
93
  if (this._textarea.value === '') {
@@ -93,7 +101,7 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
93
101
  // but make sure container doesn't exceed maxHeight prop
94
102
 
95
103
 
96
- const heightExceedsMax = (0, _px.px)(height) > maxHeight;
104
+ const heightExceedsMax = maxHeight !== void 0 && (0, _px.px)(height) > maxHeight;
97
105
 
98
106
  if (!heightExceedsMax) {
99
107
  this._container.style.minHeight = height;
@@ -139,7 +147,7 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
139
147
  (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
140
148
  }
141
149
 
142
- componentDidUpdate(prevProps, prevState, snapshot) {
150
+ componentDidUpdate() {
143
151
  var _this$props$makeStyle2, _this$props3;
144
152
 
145
153
  this.autoGrow();
@@ -225,10 +233,7 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
225
233
  }
226
234
 
227
235
  render() {
228
- var _this = this,
229
- _this$props$styles,
230
- _this$props$styles2,
231
- _this$props$styles3;
236
+ var _this$props$styles, _this$props$styles2, _this$props$styles3;
232
237
 
233
238
  const _this$props4 = this.props,
234
239
  autoGrow = _this$props4.autoGrow,
@@ -247,37 +252,33 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
247
252
  const style = {
248
253
  width,
249
254
  resize,
250
- height: !autoGrow ? height : null,
255
+ height: !autoGrow ? height : void 0,
251
256
  maxHeight
252
257
  };
253
258
  const textarea = (0, _emotion.jsx)("textarea", Object.assign({}, props, {
254
259
  value: value,
255
260
  defaultValue: defaultValue,
256
261
  placeholder: placeholder,
257
- ref: function (textarea) {
258
- _this._textarea = textarea;
262
+ ref: textarea => {
263
+ this._textarea = textarea;
259
264
 
260
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
261
- args[_key - 1] = arguments[_key];
265
+ if (typeof textareaRef === 'function') {
266
+ textareaRef(textarea);
262
267
  }
263
-
264
- textareaRef.apply(_this, [textarea].concat(args));
265
268
  },
266
269
  style: style,
267
270
  id: this.id,
268
271
  required: required,
269
272
  "aria-required": required,
270
- "aria-invalid": this.invalid ? 'true' : null,
273
+ "aria-invalid": this.invalid ? 'true' : void 0,
271
274
  disabled: disabled || readOnly,
272
275
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
273
276
  onChange: this.handleChange
274
277
  }));
275
278
  return (0, _emotion.jsx)(_FormField.FormField, Object.assign({}, (0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps), {
279
+ label: this.props.label,
276
280
  vAlign: "top",
277
- id: this.id,
278
- ref: el => {
279
- this._node = el;
280
- }
281
+ id: this.id
281
282
  }), (0, _emotion.jsx)("div", {
282
283
  css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.textAreaLayout,
283
284
  style: {
@@ -299,7 +300,6 @@ let TextArea = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
299
300
  messages: [],
300
301
  disabled: false,
301
302
  readOnly: false,
302
- textareaRef: function (textarea) {},
303
303
  layout: 'stacked',
304
304
  required: false
305
305
  }, _temp)) || _class) || _class);
@@ -39,88 +39,22 @@ var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
39
39
  const propTypes = {
40
40
  label: _propTypes.default.node.isRequired,
41
41
  id: _propTypes.default.string,
42
-
43
- /**
44
- * sets the font-size for the textarea
45
- */
46
42
  size: _propTypes.default.oneOf(['small', 'medium', 'large']),
47
43
  layout: _propTypes.default.oneOf(['stacked', 'inline']),
48
-
49
- /**
50
- * the textarea will expand vertically to fit the height of the content,
51
- * unless its content exceeds `maxHeight`
52
- */
53
44
  autoGrow: _propTypes.default.bool,
54
-
55
- /**
56
- * is the textarea resizable (in supported browsers)
57
- */
58
45
  resize: _propTypes.default.oneOf(['none', 'both', 'horizontal', 'vertical']),
59
-
60
- /**
61
- * a fixed width for the textarea
62
- */
63
46
  width: _propTypes.default.string,
64
-
65
- /**
66
- * Initial height for the textarea (if autoGrow is true it will grow vertically)
67
- * Accepts CSS units, e.g. '55px'
68
- */
69
47
  height: _propTypes.default.string,
70
-
71
- /**
72
- * when autoGrow is true, the textarea will never grow beyond this value
73
- */
74
48
  maxHeight: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
75
-
76
- /**
77
- * object with shape: `{
78
- * text: PropTypes.node,
79
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
80
- * }`
81
- */
82
49
  messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
83
50
  inline: _propTypes.default.bool,
84
-
85
- /**
86
- * Html placeholder text to display when the input has no value. This should be hint text, not a label
87
- * replacement.
88
- */
89
51
  placeholder: _propTypes.default.string,
90
-
91
- /**
92
- * Whether or not to disable the textarea
93
- */
94
52
  disabled: _propTypes.default.bool,
95
-
96
- /**
97
- * Works just like disabled but keeps the same styles as if it were active
98
- */
99
53
  readOnly: _propTypes.default.bool,
100
-
101
- /**
102
- * Sets the required property on the underlying native textArea
103
- */
104
54
  required: _propTypes.default.bool,
105
-
106
- /**
107
- * a function that provides a reference to the actual textarea element
108
- */
109
55
  textareaRef: _propTypes.default.func,
110
-
111
- /**
112
- * value to set on initial render
113
- */
114
56
  defaultValue: _propTypes.default.string,
115
-
116
- /**
117
- * the selected value (must be accompanied by an `onChange` prop)
118
- */
119
57
  value: (0, _controllable.controllable)(_propTypes.default.string),
120
-
121
- /**
122
- * when used with the `value` prop, the component will not control its own state
123
- */
124
58
  onChange: _propTypes.default.func
125
59
  };
126
60
  exports.propTypes = propTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-text-area",
3
- "version": "8.13.1-snapshot.9+f32ba918e",
3
+ "version": "8.14.0",
4
4
  "description": "A styled HTML text area component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,24 +25,24 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/debounce": "8.13.1-snapshot.9+f32ba918e",
29
- "@instructure/emotion": "8.13.1-snapshot.9+f32ba918e",
30
- "@instructure/shared-types": "8.13.1-snapshot.9+f32ba918e",
31
- "@instructure/ui-dom-utils": "8.13.1-snapshot.9+f32ba918e",
32
- "@instructure/ui-form-field": "8.13.1-snapshot.9+f32ba918e",
33
- "@instructure/ui-prop-types": "8.13.1-snapshot.9+f32ba918e",
34
- "@instructure/ui-react-utils": "8.13.1-snapshot.9+f32ba918e",
35
- "@instructure/ui-testable": "8.13.1-snapshot.9+f32ba918e",
36
- "@instructure/ui-utils": "8.13.1-snapshot.9+f32ba918e",
37
- "@instructure/uid": "8.13.1-snapshot.9+f32ba918e",
28
+ "@instructure/debounce": "8.14.0",
29
+ "@instructure/emotion": "8.14.0",
30
+ "@instructure/shared-types": "8.14.0",
31
+ "@instructure/ui-dom-utils": "8.14.0",
32
+ "@instructure/ui-form-field": "8.14.0",
33
+ "@instructure/ui-prop-types": "8.14.0",
34
+ "@instructure/ui-react-utils": "8.14.0",
35
+ "@instructure/ui-testable": "8.14.0",
36
+ "@instructure/ui-utils": "8.14.0",
37
+ "@instructure/uid": "8.14.0",
38
38
  "prop-types": "^15"
39
39
  },
40
40
  "devDependencies": {
41
- "@instructure/ui-babel-preset": "8.13.1-snapshot.9+f32ba918e",
42
- "@instructure/ui-color-utils": "8.13.1-snapshot.9+f32ba918e",
43
- "@instructure/ui-test-locator": "8.13.1-snapshot.9+f32ba918e",
44
- "@instructure/ui-test-utils": "8.13.1-snapshot.9+f32ba918e",
45
- "@instructure/ui-themes": "8.13.1-snapshot.9+f32ba918e"
41
+ "@instructure/ui-babel-preset": "8.14.0",
42
+ "@instructure/ui-color-utils": "8.14.0",
43
+ "@instructure/ui-test-locator": "8.14.0",
44
+ "@instructure/ui-test-utils": "8.14.0",
45
+ "@instructure/ui-themes": "8.14.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "react": ">=16.8 <=17"
@@ -50,6 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "sideEffects": false,
54
- "gitHead": "f32ba918e4d3ce76c6ee95c856584d00a9d80958"
53
+ "sideEffects": false
55
54
  }