@instructure/ui-text-area 10.16.1-snapshot-0 → 10.16.1-snapshot-1
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/__new-tests__/TextArea.test.js +15 -15
- package/es/TextArea/index.js +30 -23
- package/lib/TextArea/__new-tests__/TextArea.test.js +31 -31
- package/lib/TextArea/index.js +29 -23
- package/package.json +16 -16
- package/src/TextArea/__new-tests__/TextArea.test.tsx +0 -1
- package/src/TextArea/index.tsx +4 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TextArea/__new-tests__/TextArea.test.d.ts.map +1 -1
- package/types/TextArea/index.d.ts +2 -4
- package/types/TextArea/index.d.ts.map +1 -1
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
|
-
## [10.16.1-snapshot-
|
|
6
|
+
## [10.16.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-text-area
|
|
9
9
|
|
|
@@ -23,13 +23,13 @@ var _TextArea, _TextArea2, _TextArea3, _TextArea4;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
30
29
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
30
|
import '@testing-library/jest-dom';
|
|
32
31
|
import { TextArea } from '../index';
|
|
32
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
33
33
|
describe('TextArea', () => {
|
|
34
34
|
let consoleWarningMock;
|
|
35
35
|
let consoleErrorMock;
|
|
@@ -43,7 +43,7 @@ describe('TextArea', () => {
|
|
|
43
43
|
consoleErrorMock.mockRestore();
|
|
44
44
|
});
|
|
45
45
|
it('should accept a default value', async () => {
|
|
46
|
-
render(_TextArea || (_TextArea =
|
|
46
|
+
render(_TextArea || (_TextArea = _jsx(TextArea, {
|
|
47
47
|
label: "Name",
|
|
48
48
|
autoGrow: false,
|
|
49
49
|
defaultValue: "Tom Servo"
|
|
@@ -52,7 +52,7 @@ describe('TextArea', () => {
|
|
|
52
52
|
expect(input).toHaveTextContent('Tom Servo');
|
|
53
53
|
});
|
|
54
54
|
it('should include a label', async () => {
|
|
55
|
-
const _render = render(_TextArea2 || (_TextArea2 =
|
|
55
|
+
const _render = render(_TextArea2 || (_TextArea2 = _jsx(TextArea, {
|
|
56
56
|
label: "Name",
|
|
57
57
|
autoGrow: false
|
|
58
58
|
}))),
|
|
@@ -61,7 +61,7 @@ describe('TextArea', () => {
|
|
|
61
61
|
expect(textArea).toHaveTextContent('Name');
|
|
62
62
|
});
|
|
63
63
|
it('should set an initial height', async () => {
|
|
64
|
-
render(_TextArea3 || (_TextArea3 =
|
|
64
|
+
render(_TextArea3 || (_TextArea3 = _jsx(TextArea, {
|
|
65
65
|
label: "Name",
|
|
66
66
|
autoGrow: false,
|
|
67
67
|
height: "100px"
|
|
@@ -71,7 +71,7 @@ describe('TextArea', () => {
|
|
|
71
71
|
});
|
|
72
72
|
it('should focus the textarea when focus is called', async () => {
|
|
73
73
|
let ref;
|
|
74
|
-
render(
|
|
74
|
+
render(_jsx(TextArea, {
|
|
75
75
|
label: "Name",
|
|
76
76
|
autoGrow: false
|
|
77
77
|
// @ts-expect-error this is managed by the testing framework
|
|
@@ -84,7 +84,7 @@ describe('TextArea', () => {
|
|
|
84
84
|
});
|
|
85
85
|
it('provides a focused getter', async () => {
|
|
86
86
|
let ref;
|
|
87
|
-
render(
|
|
87
|
+
render(_jsx(TextArea, {
|
|
88
88
|
label: "Name",
|
|
89
89
|
autoGrow: false,
|
|
90
90
|
ref: el => ref = el
|
|
@@ -94,7 +94,7 @@ describe('TextArea', () => {
|
|
|
94
94
|
});
|
|
95
95
|
it('should provide an textareaRef prop', async () => {
|
|
96
96
|
const textareaRef = vi.fn();
|
|
97
|
-
render(
|
|
97
|
+
render(_jsx(TextArea, {
|
|
98
98
|
label: "Name",
|
|
99
99
|
autoGrow: false,
|
|
100
100
|
textareaRef: textareaRef
|
|
@@ -104,7 +104,7 @@ describe('TextArea', () => {
|
|
|
104
104
|
});
|
|
105
105
|
it('should provide a value getter', async () => {
|
|
106
106
|
let ref;
|
|
107
|
-
render(
|
|
107
|
+
render(_jsx(TextArea, {
|
|
108
108
|
label: "Name",
|
|
109
109
|
autoGrow: false,
|
|
110
110
|
defaultValue: "bar"
|
|
@@ -117,7 +117,7 @@ describe('TextArea', () => {
|
|
|
117
117
|
describe('events', () => {
|
|
118
118
|
it('responds to onChange event', async () => {
|
|
119
119
|
const onChange = vi.fn();
|
|
120
|
-
render(
|
|
120
|
+
render(_jsx(TextArea, {
|
|
121
121
|
label: "Name",
|
|
122
122
|
autoGrow: false,
|
|
123
123
|
onChange: onChange
|
|
@@ -134,7 +134,7 @@ describe('TextArea', () => {
|
|
|
134
134
|
});
|
|
135
135
|
it('does not respond to onChange event when disabled', async () => {
|
|
136
136
|
const onChange = vi.fn();
|
|
137
|
-
render(
|
|
137
|
+
render(_jsx(TextArea, {
|
|
138
138
|
disabled: true,
|
|
139
139
|
label: "Name",
|
|
140
140
|
autoGrow: false,
|
|
@@ -150,7 +150,7 @@ describe('TextArea', () => {
|
|
|
150
150
|
});
|
|
151
151
|
it('does not respond to onChange event when readOnly', async () => {
|
|
152
152
|
const onChange = vi.fn();
|
|
153
|
-
render(
|
|
153
|
+
render(_jsx(TextArea, {
|
|
154
154
|
readOnly: true,
|
|
155
155
|
label: "Name",
|
|
156
156
|
autoGrow: false,
|
|
@@ -166,7 +166,7 @@ describe('TextArea', () => {
|
|
|
166
166
|
});
|
|
167
167
|
it('responds to onBlur event', async () => {
|
|
168
168
|
const onBlur = vi.fn();
|
|
169
|
-
render(
|
|
169
|
+
render(_jsx(TextArea, {
|
|
170
170
|
label: "Name",
|
|
171
171
|
autoGrow: false,
|
|
172
172
|
onBlur: onBlur
|
|
@@ -179,7 +179,7 @@ describe('TextArea', () => {
|
|
|
179
179
|
});
|
|
180
180
|
it('responds to onFocus event', async () => {
|
|
181
181
|
const onFocus = vi.fn();
|
|
182
|
-
render(
|
|
182
|
+
render(_jsx(TextArea, {
|
|
183
183
|
label: "Name",
|
|
184
184
|
autoGrow: false,
|
|
185
185
|
onFocus: onFocus
|
|
@@ -193,7 +193,7 @@ describe('TextArea', () => {
|
|
|
193
193
|
});
|
|
194
194
|
describe('for a11y', () => {
|
|
195
195
|
it('should meet standards', async () => {
|
|
196
|
-
const _render2 = render(_TextArea4 || (_TextArea4 =
|
|
196
|
+
const _render2 = render(_TextArea4 || (_TextArea4 = _jsx(TextArea, {
|
|
197
197
|
label: "Name",
|
|
198
198
|
autoGrow: false
|
|
199
199
|
}))),
|
|
@@ -202,7 +202,7 @@ describe('TextArea', () => {
|
|
|
202
202
|
expect(axeCheck).toBe(true);
|
|
203
203
|
});
|
|
204
204
|
it('should set aria-invalid when errors prop is set', async () => {
|
|
205
|
-
render(
|
|
205
|
+
render(_jsx(TextArea, {
|
|
206
206
|
label: "Name",
|
|
207
207
|
autoGrow: false,
|
|
208
208
|
messages: [{
|
package/es/TextArea/index.js
CHANGED
|
@@ -23,12 +23,11 @@ var _dec, _dec2, _dec3, _class, _TextArea;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
import React, { Component } from 'react';
|
|
26
|
+
import { Fragment, Component } from 'react';
|
|
28
27
|
import { FormField } from '@instructure/ui-form-field';
|
|
29
28
|
import { addEventListener, isActiveElement, requestAnimationFrame, getBoundingClientRect } from '@instructure/ui-dom-utils';
|
|
30
29
|
import { debounce } from '@instructure/debounce';
|
|
31
|
-
import { withStyle
|
|
30
|
+
import { withStyle } from '@instructure/emotion';
|
|
32
31
|
import { px } from '@instructure/ui-utils';
|
|
33
32
|
import { testable } from '@instructure/ui-testable';
|
|
34
33
|
import { omitProps, pickProps, withDeterministicId } from '@instructure/ui-react-utils';
|
|
@@ -42,6 +41,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
42
41
|
category: components
|
|
43
42
|
---
|
|
44
43
|
**/
|
|
44
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
45
45
|
let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_TextArea = class TextArea extends Component {
|
|
46
46
|
constructor(props) {
|
|
47
47
|
super(props);
|
|
@@ -254,7 +254,8 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
254
254
|
height: !autoGrow ? height : void 0,
|
|
255
255
|
maxHeight
|
|
256
256
|
};
|
|
257
|
-
const textarea =
|
|
257
|
+
const textarea = _jsx("textarea", {
|
|
258
|
+
...props,
|
|
258
259
|
value: value,
|
|
259
260
|
defaultValue: defaultValue,
|
|
260
261
|
placeholder: placeholder,
|
|
@@ -276,31 +277,37 @@ let TextArea = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
276
277
|
disabled: disabled || readOnly,
|
|
277
278
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
|
|
278
279
|
onChange: this.handleChange
|
|
279
|
-
})
|
|
280
|
-
const label = hasVisibleChildren(this.props.label) ?
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
280
|
+
});
|
|
281
|
+
const label = hasVisibleChildren(this.props.label) ? _jsxs(Fragment, {
|
|
282
|
+
children: [this.props.label, required && _jsxs("span", {
|
|
283
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
284
|
+
"aria-hidden": true,
|
|
285
|
+
children: [' ', "*"]
|
|
286
|
+
})]
|
|
287
|
+
}) : this.props.label;
|
|
288
|
+
return _jsx(FormField, {
|
|
289
|
+
...pickProps(this.props, FormField.allowedProps),
|
|
285
290
|
label: label,
|
|
286
291
|
vAlign: "top",
|
|
287
292
|
id: this.id,
|
|
288
293
|
elementRef: el => {
|
|
289
294
|
this.ref = el;
|
|
290
295
|
},
|
|
291
|
-
margin: margin
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
296
|
+
margin: margin,
|
|
297
|
+
children: _jsxs("div", {
|
|
298
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.textAreaLayout,
|
|
299
|
+
style: {
|
|
300
|
+
width,
|
|
301
|
+
maxHeight
|
|
302
|
+
},
|
|
303
|
+
ref: this.handleContainerRef,
|
|
304
|
+
children: [textarea, !disabled && !readOnly ? _jsx("span", {
|
|
305
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.textAreaOutline,
|
|
306
|
+
"aria-hidden": "true",
|
|
307
|
+
ref: e => this._highlightRef = e
|
|
308
|
+
}) : null]
|
|
309
|
+
})
|
|
310
|
+
});
|
|
304
311
|
}
|
|
305
312
|
}, _TextArea.displayName = "TextArea", _TextArea.componentId = 'TextArea', _TextArea.allowedProps = allowedProps, _TextArea.propTypes = propTypes, _TextArea.defaultProps = {
|
|
306
313
|
size: 'medium',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _react =
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
6
5
|
var _vitest = require("vitest");
|
|
7
6
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
7
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
9
8
|
require("@testing-library/jest-dom");
|
|
10
9
|
var _index = require("../index");
|
|
10
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
11
|
var _TextArea, _TextArea2, _TextArea3, _TextArea4;
|
|
12
12
|
/*
|
|
13
13
|
* The MIT License (MIT)
|
|
@@ -45,16 +45,16 @@ describe('TextArea', () => {
|
|
|
45
45
|
consoleErrorMock.mockRestore();
|
|
46
46
|
});
|
|
47
47
|
it('should accept a default value', async () => {
|
|
48
|
-
(0,
|
|
48
|
+
(0, _react.render)(_TextArea || (_TextArea = (0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
49
49
|
label: "Name",
|
|
50
50
|
autoGrow: false,
|
|
51
51
|
defaultValue: "Tom Servo"
|
|
52
52
|
})));
|
|
53
|
-
const input =
|
|
53
|
+
const input = _react.screen.getByRole('textbox');
|
|
54
54
|
expect(input).toHaveTextContent('Tom Servo');
|
|
55
55
|
});
|
|
56
56
|
it('should include a label', async () => {
|
|
57
|
-
const _render = (0,
|
|
57
|
+
const _render = (0, _react.render)(_TextArea2 || (_TextArea2 = (0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
58
58
|
label: "Name",
|
|
59
59
|
autoGrow: false
|
|
60
60
|
}))),
|
|
@@ -63,30 +63,30 @@ describe('TextArea', () => {
|
|
|
63
63
|
expect(textArea).toHaveTextContent('Name');
|
|
64
64
|
});
|
|
65
65
|
it('should set an initial height', async () => {
|
|
66
|
-
(0,
|
|
66
|
+
(0, _react.render)(_TextArea3 || (_TextArea3 = (0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
67
67
|
label: "Name",
|
|
68
68
|
autoGrow: false,
|
|
69
69
|
height: "100px"
|
|
70
70
|
})));
|
|
71
|
-
const input =
|
|
71
|
+
const input = _react.screen.getByRole('textbox');
|
|
72
72
|
expect(input).toHaveStyle('height: 100px');
|
|
73
73
|
});
|
|
74
74
|
it('should focus the textarea when focus is called', async () => {
|
|
75
75
|
let ref;
|
|
76
|
-
(0,
|
|
76
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
77
77
|
label: "Name",
|
|
78
78
|
autoGrow: false
|
|
79
79
|
// @ts-expect-error this is managed by the testing framework
|
|
80
80
|
,
|
|
81
81
|
textareaRef: el => ref = el
|
|
82
82
|
}));
|
|
83
|
-
const input =
|
|
83
|
+
const input = _react.screen.getByRole('textbox');
|
|
84
84
|
ref.focus();
|
|
85
85
|
expect(input).toHaveFocus();
|
|
86
86
|
});
|
|
87
87
|
it('provides a focused getter', async () => {
|
|
88
88
|
let ref;
|
|
89
|
-
(0,
|
|
89
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
90
90
|
label: "Name",
|
|
91
91
|
autoGrow: false,
|
|
92
92
|
ref: el => ref = el
|
|
@@ -96,17 +96,17 @@ describe('TextArea', () => {
|
|
|
96
96
|
});
|
|
97
97
|
it('should provide an textareaRef prop', async () => {
|
|
98
98
|
const textareaRef = _vitest.vi.fn();
|
|
99
|
-
(0,
|
|
99
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
100
100
|
label: "Name",
|
|
101
101
|
autoGrow: false,
|
|
102
102
|
textareaRef: textareaRef
|
|
103
103
|
}));
|
|
104
|
-
const input =
|
|
104
|
+
const input = _react.screen.getByRole('textbox');
|
|
105
105
|
expect(textareaRef).toHaveBeenCalledWith(input);
|
|
106
106
|
});
|
|
107
107
|
it('should provide a value getter', async () => {
|
|
108
108
|
let ref;
|
|
109
|
-
(0,
|
|
109
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
110
110
|
label: "Name",
|
|
111
111
|
autoGrow: false,
|
|
112
112
|
defaultValue: "bar"
|
|
@@ -119,31 +119,31 @@ describe('TextArea', () => {
|
|
|
119
119
|
describe('events', () => {
|
|
120
120
|
it('responds to onChange event', async () => {
|
|
121
121
|
const onChange = _vitest.vi.fn();
|
|
122
|
-
(0,
|
|
122
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
123
123
|
label: "Name",
|
|
124
124
|
autoGrow: false,
|
|
125
125
|
onChange: onChange
|
|
126
126
|
}));
|
|
127
|
-
const input =
|
|
128
|
-
|
|
127
|
+
const input = _react.screen.getByRole('textbox');
|
|
128
|
+
_react.fireEvent.change(input, {
|
|
129
129
|
target: {
|
|
130
130
|
value: 'foo'
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
-
await (0,
|
|
133
|
+
await (0, _react.waitFor)(() => {
|
|
134
134
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
it('does not respond to onChange event when disabled', async () => {
|
|
138
138
|
const onChange = _vitest.vi.fn();
|
|
139
|
-
(0,
|
|
139
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
140
140
|
disabled: true,
|
|
141
141
|
label: "Name",
|
|
142
142
|
autoGrow: false,
|
|
143
143
|
onChange: onChange
|
|
144
144
|
}));
|
|
145
|
-
const input =
|
|
146
|
-
|
|
145
|
+
const input = _react.screen.getByRole('textbox');
|
|
146
|
+
_react.fireEvent.change(input, {
|
|
147
147
|
target: {
|
|
148
148
|
value: 'foo'
|
|
149
149
|
}
|
|
@@ -152,14 +152,14 @@ describe('TextArea', () => {
|
|
|
152
152
|
});
|
|
153
153
|
it('does not respond to onChange event when readOnly', async () => {
|
|
154
154
|
const onChange = _vitest.vi.fn();
|
|
155
|
-
(0,
|
|
155
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
156
156
|
readOnly: true,
|
|
157
157
|
label: "Name",
|
|
158
158
|
autoGrow: false,
|
|
159
159
|
onChange: onChange
|
|
160
160
|
}));
|
|
161
|
-
const input =
|
|
162
|
-
|
|
161
|
+
const input = _react.screen.getByRole('textbox');
|
|
162
|
+
_react.fireEvent.change(input, {
|
|
163
163
|
target: {
|
|
164
164
|
value: 'foo'
|
|
165
165
|
}
|
|
@@ -168,34 +168,34 @@ describe('TextArea', () => {
|
|
|
168
168
|
});
|
|
169
169
|
it('responds to onBlur event', async () => {
|
|
170
170
|
const onBlur = _vitest.vi.fn();
|
|
171
|
-
(0,
|
|
171
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
172
172
|
label: "Name",
|
|
173
173
|
autoGrow: false,
|
|
174
174
|
onBlur: onBlur
|
|
175
175
|
}));
|
|
176
176
|
_userEvent.default.tab();
|
|
177
177
|
_userEvent.default.tab();
|
|
178
|
-
await (0,
|
|
178
|
+
await (0, _react.waitFor)(() => {
|
|
179
179
|
expect(onBlur).toHaveBeenCalled();
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
182
|
it('responds to onFocus event', async () => {
|
|
183
183
|
const onFocus = _vitest.vi.fn();
|
|
184
|
-
(0,
|
|
184
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
185
185
|
label: "Name",
|
|
186
186
|
autoGrow: false,
|
|
187
187
|
onFocus: onFocus
|
|
188
188
|
}));
|
|
189
|
-
const input =
|
|
189
|
+
const input = _react.screen.getByRole('textbox');
|
|
190
190
|
input.focus();
|
|
191
|
-
await (0,
|
|
191
|
+
await (0, _react.waitFor)(() => {
|
|
192
192
|
expect(onFocus).toHaveBeenCalled();
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
196
|
describe('for a11y', () => {
|
|
197
197
|
it('should meet standards', async () => {
|
|
198
|
-
const _render2 = (0,
|
|
198
|
+
const _render2 = (0, _react.render)(_TextArea4 || (_TextArea4 = (0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
199
199
|
label: "Name",
|
|
200
200
|
autoGrow: false
|
|
201
201
|
}))),
|
|
@@ -204,7 +204,7 @@ describe('TextArea', () => {
|
|
|
204
204
|
expect(axeCheck).toBe(true);
|
|
205
205
|
});
|
|
206
206
|
it('should set aria-invalid when errors prop is set', async () => {
|
|
207
|
-
(0,
|
|
207
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.TextArea, {
|
|
208
208
|
label: "Name",
|
|
209
209
|
autoGrow: false,
|
|
210
210
|
messages: [{
|
|
@@ -212,7 +212,7 @@ describe('TextArea', () => {
|
|
|
212
212
|
text: 'some error message'
|
|
213
213
|
}]
|
|
214
214
|
}));
|
|
215
|
-
const input =
|
|
215
|
+
const input = _react.screen.getByRole('textbox');
|
|
216
216
|
expect(input).toHaveAttribute('aria-invalid');
|
|
217
217
|
});
|
|
218
218
|
});
|
package/lib/TextArea/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.TextArea = void 0;
|
|
9
|
-
var _react =
|
|
8
|
+
var _react = require("react");
|
|
10
9
|
var _FormField = require("@instructure/ui-form-field/lib/FormField");
|
|
11
10
|
var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
|
|
12
11
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
@@ -23,6 +22,7 @@ var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChil
|
|
|
23
22
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
24
23
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
24
|
var _props = require("./props");
|
|
25
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
26
26
|
var _dec, _dec2, _dec3, _class, _TextArea;
|
|
27
27
|
/*
|
|
28
28
|
* The MIT License (MIT)
|
|
@@ -47,7 +47,6 @@ var _dec, _dec2, _dec3, _class, _TextArea;
|
|
|
47
47
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
48
|
* SOFTWARE.
|
|
49
49
|
*/
|
|
50
|
-
/** @jsx jsx */
|
|
51
50
|
/**
|
|
52
51
|
---
|
|
53
52
|
category: components
|
|
@@ -265,7 +264,8 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
265
264
|
height: !autoGrow ? height : void 0,
|
|
266
265
|
maxHeight
|
|
267
266
|
};
|
|
268
|
-
const textarea = (0,
|
|
267
|
+
const textarea = (0, _jsxRuntime.jsx)("textarea", {
|
|
268
|
+
...props,
|
|
269
269
|
value: value,
|
|
270
270
|
defaultValue: defaultValue,
|
|
271
271
|
placeholder: placeholder,
|
|
@@ -287,31 +287,37 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
287
287
|
disabled: disabled || readOnly,
|
|
288
288
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
|
|
289
289
|
onChange: this.handleChange
|
|
290
|
-
})
|
|
291
|
-
const label = (0, _hasVisibleChildren.hasVisibleChildren)(this.props.label) ? (0,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
});
|
|
291
|
+
const label = (0, _hasVisibleChildren.hasVisibleChildren)(this.props.label) ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
292
|
+
children: [this.props.label, required && (0, _jsxRuntime.jsxs)("span", {
|
|
293
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
294
|
+
"aria-hidden": true,
|
|
295
|
+
children: [' ', "*"]
|
|
296
|
+
})]
|
|
297
|
+
}) : this.props.label;
|
|
298
|
+
return (0, _jsxRuntime.jsx)(_FormField.FormField, {
|
|
299
|
+
...(0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps),
|
|
296
300
|
label: label,
|
|
297
301
|
vAlign: "top",
|
|
298
302
|
id: this.id,
|
|
299
303
|
elementRef: el => {
|
|
300
304
|
this.ref = el;
|
|
301
305
|
},
|
|
302
|
-
margin: margin
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
306
|
+
margin: margin,
|
|
307
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
308
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.textAreaLayout,
|
|
309
|
+
style: {
|
|
310
|
+
width,
|
|
311
|
+
maxHeight
|
|
312
|
+
},
|
|
313
|
+
ref: this.handleContainerRef,
|
|
314
|
+
children: [textarea, !disabled && !readOnly ? (0, _jsxRuntime.jsx)("span", {
|
|
315
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.textAreaOutline,
|
|
316
|
+
"aria-hidden": "true",
|
|
317
|
+
ref: e => this._highlightRef = e
|
|
318
|
+
}) : null]
|
|
319
|
+
})
|
|
320
|
+
});
|
|
315
321
|
}
|
|
316
322
|
}, _TextArea.displayName = "TextArea", _TextArea.componentId = 'TextArea', _TextArea.allowedProps = _props.allowedProps, _TextArea.propTypes = _props.propTypes, _TextArea.defaultProps = {
|
|
317
323
|
size: 'medium',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-area",
|
|
3
|
-
"version": "10.16.1-snapshot-
|
|
3
|
+
"version": "10.16.1-snapshot-1",
|
|
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.16.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "10.16.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "10.16.1-snapshot-
|
|
30
|
-
"@instructure/ui-dom-utils": "10.16.1-snapshot-
|
|
31
|
-
"@instructure/ui-form-field": "10.16.1-snapshot-
|
|
32
|
-
"@instructure/ui-prop-types": "10.16.1-snapshot-
|
|
33
|
-
"@instructure/ui-react-utils": "10.16.1-snapshot-
|
|
34
|
-
"@instructure/ui-testable": "10.16.1-snapshot-
|
|
35
|
-
"@instructure/ui-utils": "10.16.1-snapshot-
|
|
36
|
-
"@instructure/uid": "10.16.1-snapshot-
|
|
27
|
+
"@instructure/debounce": "10.16.1-snapshot-1",
|
|
28
|
+
"@instructure/emotion": "10.16.1-snapshot-1",
|
|
29
|
+
"@instructure/shared-types": "10.16.1-snapshot-1",
|
|
30
|
+
"@instructure/ui-dom-utils": "10.16.1-snapshot-1",
|
|
31
|
+
"@instructure/ui-form-field": "10.16.1-snapshot-1",
|
|
32
|
+
"@instructure/ui-prop-types": "10.16.1-snapshot-1",
|
|
33
|
+
"@instructure/ui-react-utils": "10.16.1-snapshot-1",
|
|
34
|
+
"@instructure/ui-testable": "10.16.1-snapshot-1",
|
|
35
|
+
"@instructure/ui-utils": "10.16.1-snapshot-1",
|
|
36
|
+
"@instructure/uid": "10.16.1-snapshot-1",
|
|
37
37
|
"prop-types": "^15.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@instructure/ui-axe-check": "10.16.1-snapshot-
|
|
41
|
-
"@instructure/ui-babel-preset": "10.16.1-snapshot-
|
|
42
|
-
"@instructure/ui-color-utils": "10.16.1-snapshot-
|
|
43
|
-
"@instructure/ui-test-utils": "10.16.1-snapshot-
|
|
44
|
-
"@instructure/ui-themes": "10.16.1-snapshot-
|
|
40
|
+
"@instructure/ui-axe-check": "10.16.1-snapshot-1",
|
|
41
|
+
"@instructure/ui-babel-preset": "10.16.1-snapshot-1",
|
|
42
|
+
"@instructure/ui-color-utils": "10.16.1-snapshot-1",
|
|
43
|
+
"@instructure/ui-test-utils": "10.16.1-snapshot-1",
|
|
44
|
+
"@instructure/ui-themes": "10.16.1-snapshot-1",
|
|
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",
|
package/src/TextArea/index.tsx
CHANGED
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
import React, { Component } from 'react'
|
|
25
|
+
import { Fragment, Component } from 'react'
|
|
27
26
|
import { FormField } from '@instructure/ui-form-field'
|
|
28
27
|
import {
|
|
29
28
|
addEventListener,
|
|
@@ -34,7 +33,7 @@ import {
|
|
|
34
33
|
import type { RequestAnimationFrameType } from '@instructure/ui-dom-utils'
|
|
35
34
|
import { debounce } from '@instructure/debounce'
|
|
36
35
|
import type { Debounced } from '@instructure/debounce'
|
|
37
|
-
import { withStyle
|
|
36
|
+
import { withStyle } from '@instructure/emotion'
|
|
38
37
|
import { px } from '@instructure/ui-utils'
|
|
39
38
|
import { testable } from '@instructure/ui-testable'
|
|
40
39
|
import {
|
|
@@ -356,7 +355,7 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
356
355
|
)
|
|
357
356
|
|
|
358
357
|
const label = hasVisibleChildren(this.props.label) ? (
|
|
359
|
-
<
|
|
358
|
+
<Fragment>
|
|
360
359
|
{this.props.label}
|
|
361
360
|
{required && (
|
|
362
361
|
<span
|
|
@@ -367,7 +366,7 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
367
366
|
*
|
|
368
367
|
</span>
|
|
369
368
|
)}
|
|
370
|
-
</
|
|
369
|
+
</Fragment>
|
|
371
370
|
) : (
|
|
372
371
|
this.props.label
|
|
373
372
|
)
|