@instructure/ui-text-area 11.6.0 → 11.6.1-pr-snapshot-1779894247159
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/props.js → babel.config.cjs} +13 -7
- package/package.json +16 -18
- package/lib/TextArea/index.js +0 -335
- package/lib/TextArea/styles.js +0 -125
- package/lib/TextArea/theme.js +0 -82
- package/lib/index.js +0 -12
- package/lib/package.json +0 -1
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
|
+
## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-text-area
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-text-area
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
1
|
/*
|
|
8
2
|
* The MIT License (MIT)
|
|
9
3
|
*
|
|
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
|
|
|
28
22
|
* SOFTWARE.
|
|
29
23
|
*/
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
module.exports = {
|
|
26
|
+
presets: [
|
|
27
|
+
[
|
|
28
|
+
require('@instructure/ui-babel-preset'),
|
|
29
|
+
{
|
|
30
|
+
coverage: Boolean(process.env.COVERAGE),
|
|
31
|
+
esModules: Boolean(process.env.ES_MODULES),
|
|
32
|
+
removeConsole: process.env.NODE_ENV === 'production',
|
|
33
|
+
transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-area",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-pr-snapshot-1779894247159",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A styled HTML text area component",
|
|
5
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
7
|
"module": "./es/index.js",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -15,25 +15,25 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
|
-
"@instructure/
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/shared-types": "11.6.
|
|
21
|
-
"@instructure/ui-a11y-utils": "11.6.
|
|
22
|
-
"@instructure/ui-dom-utils": "11.6.
|
|
23
|
-
"@instructure/ui-react-utils": "11.6.
|
|
24
|
-
"@instructure/ui-
|
|
25
|
-
"@instructure/uid": "11.6.
|
|
26
|
-
"@instructure/ui-
|
|
18
|
+
"@instructure/debounce": "11.6.1-pr-snapshot-1779894247159",
|
|
19
|
+
"@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
|
|
20
|
+
"@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
|
|
21
|
+
"@instructure/ui-a11y-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
22
|
+
"@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
23
|
+
"@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
24
|
+
"@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
|
|
25
|
+
"@instructure/uid": "11.6.1-pr-snapshot-1779894247159",
|
|
26
|
+
"@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
30
|
"@testing-library/react": "15.0.7",
|
|
31
31
|
"@testing-library/user-event": "^14.6.1",
|
|
32
32
|
"vitest": "^3.2.2",
|
|
33
|
-
"@instructure/ui-
|
|
34
|
-
"@instructure/ui-
|
|
35
|
-
"@instructure/ui-color-utils": "11.6.
|
|
36
|
-
"@instructure/ui-themes": "11.6.
|
|
33
|
+
"@instructure/ui-axe-check": "11.6.1-pr-snapshot-1779894247159",
|
|
34
|
+
"@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
|
|
35
|
+
"@instructure/ui-color-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
36
|
+
"@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": ">=18 <=19"
|
|
@@ -46,10 +46,8 @@
|
|
|
46
46
|
".": {
|
|
47
47
|
"types": "./types/index.d.ts",
|
|
48
48
|
"import": "./es/index.js",
|
|
49
|
-
"require": "./lib/index.js",
|
|
50
49
|
"default": "./es/index.js"
|
|
51
50
|
},
|
|
52
|
-
"./lib/*": "./lib/*",
|
|
53
51
|
"./es/*": "./es/*",
|
|
54
52
|
"./types/*": "./types/*",
|
|
55
53
|
"./package.json": "./package.json",
|
|
@@ -59,7 +57,7 @@
|
|
|
59
57
|
"lint": "ui-scripts lint",
|
|
60
58
|
"lint:fix": "ui-scripts lint --fix",
|
|
61
59
|
"clean": "ui-scripts clean",
|
|
62
|
-
"build": "ui-scripts build
|
|
60
|
+
"build": "ui-scripts build",
|
|
63
61
|
"build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
|
|
64
62
|
"build:types": "tsc -p tsconfig.build.json",
|
|
65
63
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
package/lib/TextArea/index.js
DELETED
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.TextArea = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _FormField = require("@instructure/ui-form-field/lib/FormField");
|
|
10
|
-
var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
|
|
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");
|
|
14
|
-
var _debounce = require("@instructure/debounce");
|
|
15
|
-
var _emotion = require("@instructure/emotion");
|
|
16
|
-
var _px = require("@instructure/ui-utils/lib/px.js");
|
|
17
|
-
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
18
|
-
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
19
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
20
|
-
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
21
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
22
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
23
|
-
var _props = require("./props");
|
|
24
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
25
|
-
var _dec, _dec2, _class, _TextArea;
|
|
26
|
-
/*
|
|
27
|
-
* The MIT License (MIT)
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
30
|
-
*
|
|
31
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
33
|
-
* in the Software without restriction, including without limitation the rights
|
|
34
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
36
|
-
* furnished to do so, subject to the following conditions:
|
|
37
|
-
*
|
|
38
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
39
|
-
* copies or substantial portions of the Software.
|
|
40
|
-
*
|
|
41
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
44
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
|
-
* SOFTWARE.
|
|
48
|
-
*/
|
|
49
|
-
/**
|
|
50
|
-
---
|
|
51
|
-
category: components
|
|
52
|
-
---
|
|
53
|
-
**/
|
|
54
|
-
let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_TextArea = class TextArea extends _react.Component {
|
|
55
|
-
constructor(props) {
|
|
56
|
-
super(props);
|
|
57
|
-
this._listener = void 0;
|
|
58
|
-
this._request = void 0;
|
|
59
|
-
this._defaultId = void 0;
|
|
60
|
-
this._textareaResizeListener = void 0;
|
|
61
|
-
this._debounced = void 0;
|
|
62
|
-
this._textarea = null;
|
|
63
|
-
this._container = null;
|
|
64
|
-
this._height = void 0;
|
|
65
|
-
this._manuallyResized = false;
|
|
66
|
-
this._highlightRef = null;
|
|
67
|
-
this.myObserver = null;
|
|
68
|
-
this.resizeTimeout = void 0;
|
|
69
|
-
this.ref = null;
|
|
70
|
-
this._textareaResize = () => {
|
|
71
|
-
const textareaHeight = this._textarea.style.height;
|
|
72
|
-
if (textareaHeight !== '' && textareaHeight !== this._height) {
|
|
73
|
-
this._manuallyResized = true;
|
|
74
|
-
this._textarea.style.overflowY = 'auto';
|
|
75
|
-
|
|
76
|
-
// update container minHeight to ensure focus ring always wraps input
|
|
77
|
-
this._container.style.minHeight = textareaHeight;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
this.grow = () => {
|
|
81
|
-
if (!this._textarea || this._manuallyResized) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const offset = this._textarea.offsetHeight - this._textarea.clientHeight;
|
|
85
|
-
let height = '';
|
|
86
|
-
|
|
87
|
-
// Notes:
|
|
88
|
-
// 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
|
|
89
|
-
// 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
|
|
90
|
-
this._textarea.style.height = 'auto';
|
|
91
|
-
this._textarea.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
|
|
92
|
-
height = this._textarea.scrollHeight + offset + 'px';
|
|
93
|
-
const maxHeight = this.props.maxHeight ? (0, _px.px)(this.props.maxHeight, this._container) : void 0;
|
|
94
|
-
if (this.props.maxHeight && maxHeight !== void 0 && this._textarea.scrollHeight > maxHeight) {
|
|
95
|
-
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
96
|
-
} else if (this.props.height) {
|
|
97
|
-
if (this._textarea.value === '') {
|
|
98
|
-
height = this.props.height;
|
|
99
|
-
} else if ((0, _px.px)(this.props.height, this._container) > this._textarea.scrollHeight) {
|
|
100
|
-
this._textarea.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
|
|
101
|
-
height = this.props.height;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// preserve container height to prevent scroll jumping on long textareas,
|
|
106
|
-
// but make sure container doesn't exceed maxHeight prop
|
|
107
|
-
const heightExceedsMax = maxHeight !== void 0 && (0, _px.px)(height) > maxHeight;
|
|
108
|
-
if (!heightExceedsMax) {
|
|
109
|
-
this._container.style.minHeight = height;
|
|
110
|
-
}
|
|
111
|
-
this._height = height;
|
|
112
|
-
this._textarea.style.height = height;
|
|
113
|
-
};
|
|
114
|
-
this.handleChange = event => {
|
|
115
|
-
const _this$props = this.props,
|
|
116
|
-
onChange = _this$props.onChange,
|
|
117
|
-
value = _this$props.value,
|
|
118
|
-
disabled = _this$props.disabled,
|
|
119
|
-
readOnly = _this$props.readOnly;
|
|
120
|
-
if (disabled || readOnly) {
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (typeof value === 'undefined') {
|
|
125
|
-
// if uncontrolled
|
|
126
|
-
this.autoGrow();
|
|
127
|
-
}
|
|
128
|
-
if (typeof onChange === 'function') {
|
|
129
|
-
onChange(event);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
this.handleContainerRef = node => {
|
|
133
|
-
this._container = node;
|
|
134
|
-
};
|
|
135
|
-
this._defaultId = props.deterministicId();
|
|
136
|
-
|
|
137
|
-
//mock ResizeObserver for ssr
|
|
138
|
-
if (typeof window === 'undefined') {
|
|
139
|
-
global.ResizeObserver = class ResizeObserver {
|
|
140
|
-
observe() {
|
|
141
|
-
// do nothing
|
|
142
|
-
}
|
|
143
|
-
unobserve() {
|
|
144
|
-
// do nothing
|
|
145
|
-
}
|
|
146
|
-
disconnect() {
|
|
147
|
-
// do nothing
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
componentDidMount() {
|
|
153
|
-
var _this$props$makeStyle, _this$props2;
|
|
154
|
-
this.myObserver = new ResizeObserver(entries => {
|
|
155
|
-
for (const entry of entries) {
|
|
156
|
-
if (this._highlightRef) {
|
|
157
|
-
const entryStyle = window.getComputedStyle(entry.target);
|
|
158
|
-
this._highlightRef.style.transition = 'none';
|
|
159
|
-
this._highlightRef.style.width = `calc(${entryStyle.width} + 0.5rem)`;
|
|
160
|
-
this._highlightRef.style.height = `calc(${entryStyle.height} + 0.5rem)`;
|
|
161
|
-
clearTimeout(this.resizeTimeout);
|
|
162
|
-
this.resizeTimeout = setTimeout(() => {
|
|
163
|
-
if (this._highlightRef) {
|
|
164
|
-
this._highlightRef.style.transition = 'all 0.2s';
|
|
165
|
-
}
|
|
166
|
-
}, 500);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
this.autoGrow();
|
|
171
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
172
|
-
}
|
|
173
|
-
componentDidUpdate() {
|
|
174
|
-
var _this$props$makeStyle2, _this$props3;
|
|
175
|
-
this.autoGrow();
|
|
176
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
177
|
-
}
|
|
178
|
-
componentWillUnmount() {
|
|
179
|
-
if (this._listener) {
|
|
180
|
-
this._listener.remove();
|
|
181
|
-
}
|
|
182
|
-
if (this._textareaResizeListener) {
|
|
183
|
-
this._textareaResizeListener.disconnect();
|
|
184
|
-
}
|
|
185
|
-
if (this._request) {
|
|
186
|
-
this._request.cancel();
|
|
187
|
-
}
|
|
188
|
-
if (this._debounced) {
|
|
189
|
-
this._debounced.cancel();
|
|
190
|
-
}
|
|
191
|
-
if (this.myObserver) {
|
|
192
|
-
this.myObserver.disconnect();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
autoGrow() {
|
|
196
|
-
if (this.props.autoGrow) {
|
|
197
|
-
if (!this._debounced) {
|
|
198
|
-
this._debounced = (0, _debounce.debounce)(this.grow, 200, {
|
|
199
|
-
leading: false,
|
|
200
|
-
trailing: true
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
if (!this._listener) {
|
|
204
|
-
this._listener = (0, _addEventListener.addEventListener)(window, 'resize', this._debounced);
|
|
205
|
-
}
|
|
206
|
-
if (this._textarea && !this._textareaResizeListener) {
|
|
207
|
-
const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this._textarea),
|
|
208
|
-
origHeight = _getBoundingClientRec.height;
|
|
209
|
-
this._textareaResizeListener = new ResizeObserver(entries => {
|
|
210
|
-
for (const entry of entries) {
|
|
211
|
-
const height = entry.contentRect.height;
|
|
212
|
-
if (origHeight !== height) {
|
|
213
|
-
this._textareaResize();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
this._textareaResizeListener.observe(this._textarea);
|
|
218
|
-
}
|
|
219
|
-
this._request = (0, _requestAnimationFrame.requestAnimationFrame)(this.grow);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
focus() {
|
|
223
|
-
this._textarea.focus();
|
|
224
|
-
}
|
|
225
|
-
get minHeight() {
|
|
226
|
-
return this._textarea.style.minHeight;
|
|
227
|
-
}
|
|
228
|
-
get invalid() {
|
|
229
|
-
return this.props.messages && this.props.messages.findIndex(message => {
|
|
230
|
-
return message.type === 'error' || message.type === 'newError';
|
|
231
|
-
}) >= 0;
|
|
232
|
-
}
|
|
233
|
-
get id() {
|
|
234
|
-
return this.props.id || this._defaultId;
|
|
235
|
-
}
|
|
236
|
-
get focused() {
|
|
237
|
-
return (0, _isActiveElement.isActiveElement)(this._textarea);
|
|
238
|
-
}
|
|
239
|
-
get value() {
|
|
240
|
-
return this._textarea.value;
|
|
241
|
-
}
|
|
242
|
-
render() {
|
|
243
|
-
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
244
|
-
const _this$props4 = this.props,
|
|
245
|
-
autoGrow = _this$props4.autoGrow,
|
|
246
|
-
placeholder = _this$props4.placeholder,
|
|
247
|
-
value = _this$props4.value,
|
|
248
|
-
defaultValue = _this$props4.defaultValue,
|
|
249
|
-
disabled = _this$props4.disabled,
|
|
250
|
-
readOnly = _this$props4.readOnly,
|
|
251
|
-
required = _this$props4.required,
|
|
252
|
-
width = _this$props4.width,
|
|
253
|
-
height = _this$props4.height,
|
|
254
|
-
maxHeight = _this$props4.maxHeight,
|
|
255
|
-
textareaRef = _this$props4.textareaRef,
|
|
256
|
-
resize = _this$props4.resize,
|
|
257
|
-
styles = _this$props4.styles,
|
|
258
|
-
margin = _this$props4.margin;
|
|
259
|
-
const props = (0, _omitProps.omitProps)(this.props, TextArea.allowedProps);
|
|
260
|
-
const style = {
|
|
261
|
-
width,
|
|
262
|
-
resize,
|
|
263
|
-
height: !autoGrow ? height : void 0,
|
|
264
|
-
maxHeight
|
|
265
|
-
};
|
|
266
|
-
const textarea = (0, _jsxRuntime.jsx)("textarea", {
|
|
267
|
-
...props,
|
|
268
|
-
value: value,
|
|
269
|
-
defaultValue: defaultValue,
|
|
270
|
-
placeholder: placeholder,
|
|
271
|
-
ref: textarea => {
|
|
272
|
-
if (textarea) {
|
|
273
|
-
var _this$myObserver;
|
|
274
|
-
(_this$myObserver = this.myObserver) === null || _this$myObserver === void 0 ? void 0 : _this$myObserver.observe(textarea);
|
|
275
|
-
}
|
|
276
|
-
this._textarea = textarea;
|
|
277
|
-
if (typeof textareaRef === 'function') {
|
|
278
|
-
textareaRef(textarea);
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
style: style,
|
|
282
|
-
id: this.id,
|
|
283
|
-
required: required,
|
|
284
|
-
"aria-required": required,
|
|
285
|
-
"aria-invalid": this.invalid ? 'true' : void 0,
|
|
286
|
-
disabled: disabled || readOnly,
|
|
287
|
-
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.textArea,
|
|
288
|
-
onChange: this.handleChange
|
|
289
|
-
});
|
|
290
|
-
const label = (0, _hasVisibleChildren.hasVisibleChildren)(this.props.label) ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
291
|
-
children: [this.props.label, required && (0, _jsxRuntime.jsxs)("span", {
|
|
292
|
-
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
293
|
-
"aria-hidden": true,
|
|
294
|
-
children: [' ', "*"]
|
|
295
|
-
})]
|
|
296
|
-
}) : this.props.label;
|
|
297
|
-
return (0, _jsxRuntime.jsx)(_FormField.FormField, {
|
|
298
|
-
...(0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps),
|
|
299
|
-
label: label,
|
|
300
|
-
vAlign: "top",
|
|
301
|
-
id: this.id,
|
|
302
|
-
elementRef: el => {
|
|
303
|
-
this.ref = el;
|
|
304
|
-
},
|
|
305
|
-
margin: margin,
|
|
306
|
-
"data-cid": "TextArea",
|
|
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 => {
|
|
318
|
-
this._highlightRef = e;
|
|
319
|
-
}
|
|
320
|
-
}) : null]
|
|
321
|
-
})
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}, _TextArea.displayName = "TextArea", _TextArea.componentId = 'TextArea', _TextArea.allowedProps = _props.allowedProps, _TextArea.defaultProps = {
|
|
325
|
-
size: 'medium',
|
|
326
|
-
autoGrow: true,
|
|
327
|
-
resize: 'none',
|
|
328
|
-
inline: false,
|
|
329
|
-
messages: [],
|
|
330
|
-
disabled: false,
|
|
331
|
-
readOnly: false,
|
|
332
|
-
layout: 'stacked',
|
|
333
|
-
required: false
|
|
334
|
-
}, _TextArea)) || _class) || _class);
|
|
335
|
-
var _default = exports.default = TextArea;
|
package/lib/TextArea/styles.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* ---
|
|
33
|
-
* private: true
|
|
34
|
-
* ---
|
|
35
|
-
* Generates the style object from the theme and provided additional information
|
|
36
|
-
* @param {Object} componentTheme The theme variable object.
|
|
37
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
39
|
-
* @return {Object} The final style object, which will be used in the component
|
|
40
|
-
*/
|
|
41
|
-
const generateStyle = (componentTheme, props) => {
|
|
42
|
-
const disabled = props.disabled,
|
|
43
|
-
size = props.size;
|
|
44
|
-
const fontSizeVariants = {
|
|
45
|
-
small: {
|
|
46
|
-
fontSize: componentTheme.smallFontSize
|
|
47
|
-
},
|
|
48
|
-
medium: {
|
|
49
|
-
fontSize: componentTheme.mediumFontSize
|
|
50
|
-
},
|
|
51
|
-
large: {
|
|
52
|
-
fontSize: componentTheme.largeFontSize
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
requiredInvalid: {
|
|
57
|
-
color: componentTheme.requiredInvalidColor
|
|
58
|
-
},
|
|
59
|
-
textArea: {
|
|
60
|
-
label: 'textArea',
|
|
61
|
-
all: 'initial',
|
|
62
|
-
WebkitFontSmoothing: 'antialiased',
|
|
63
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
64
|
-
appearance: 'none',
|
|
65
|
-
height: 'auto',
|
|
66
|
-
margin: 0,
|
|
67
|
-
width: '100%',
|
|
68
|
-
display: 'block',
|
|
69
|
-
boxSizing: 'border-box',
|
|
70
|
-
padding: componentTheme.padding,
|
|
71
|
-
fontFamily: componentTheme.fontFamily,
|
|
72
|
-
fontWeight: componentTheme.fontWeight,
|
|
73
|
-
borderWidth: componentTheme.borderWidth,
|
|
74
|
-
borderStyle: componentTheme.borderStyle,
|
|
75
|
-
borderTopColor: componentTheme.borderTopColor,
|
|
76
|
-
borderRightColor: componentTheme.borderRightColor,
|
|
77
|
-
borderBottomColor: componentTheme.borderBottomColor,
|
|
78
|
-
borderLeftColor: componentTheme.borderLeftColor,
|
|
79
|
-
borderRadius: componentTheme.borderRadius,
|
|
80
|
-
color: componentTheme.color,
|
|
81
|
-
background: componentTheme.background,
|
|
82
|
-
whiteSpace: 'pre-wrap',
|
|
83
|
-
wordWrap: 'break-word',
|
|
84
|
-
textAlign: 'start',
|
|
85
|
-
...fontSizeVariants[size],
|
|
86
|
-
'&:focus + [class$=-textArea__outline]': {
|
|
87
|
-
transform: 'scale(1)',
|
|
88
|
-
opacity: 1
|
|
89
|
-
},
|
|
90
|
-
'&[aria-invalid], &[aria-invalid]:focus, &[aria-invalid]:focus + [class$=-textArea__outline]': {
|
|
91
|
-
borderColor: componentTheme.errorBorderColor
|
|
92
|
-
},
|
|
93
|
-
'&::placeholder': {
|
|
94
|
-
color: componentTheme.placeholderColor
|
|
95
|
-
},
|
|
96
|
-
...(disabled && {
|
|
97
|
-
cursor: 'not-allowed',
|
|
98
|
-
pointerEvents: 'none',
|
|
99
|
-
opacity: 0.5
|
|
100
|
-
})
|
|
101
|
-
},
|
|
102
|
-
textAreaLayout: {
|
|
103
|
-
label: 'textArea__layout',
|
|
104
|
-
position: 'relative'
|
|
105
|
-
},
|
|
106
|
-
textAreaOutline: {
|
|
107
|
-
label: 'textArea__outline',
|
|
108
|
-
pointerEvents: 'none',
|
|
109
|
-
position: 'absolute',
|
|
110
|
-
display: 'block',
|
|
111
|
-
boxSizing: 'border-box',
|
|
112
|
-
top: '-0.25rem',
|
|
113
|
-
bottom: '-0.25rem',
|
|
114
|
-
left: '-0.25rem',
|
|
115
|
-
right: '-0.25rem',
|
|
116
|
-
border: `${componentTheme.focusOutlineWidth} ${componentTheme.focusOutlineStyle} ${componentTheme.focusOutlineColor}`,
|
|
117
|
-
borderRadius: `calc(${componentTheme.borderRadius} * 1.5)`,
|
|
118
|
-
transition: 'all 0.2s',
|
|
119
|
-
// properties to transition on :focus
|
|
120
|
-
opacity: 0,
|
|
121
|
-
transform: 'scale(0.95)'
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
var _default = exports.default = generateStyle;
|
package/lib/TextArea/theme.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
33
|
-
* @param {Object} theme The actual theme object.
|
|
34
|
-
* @return {Object} The final theme object with the overrides and component variables
|
|
35
|
-
*/
|
|
36
|
-
const generateComponentTheme = theme => {
|
|
37
|
-
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1;
|
|
38
|
-
const colors = theme.colors,
|
|
39
|
-
typography = theme.typography,
|
|
40
|
-
borders = theme.borders,
|
|
41
|
-
spacing = theme.spacing,
|
|
42
|
-
forms = theme.forms,
|
|
43
|
-
themeName = theme.key;
|
|
44
|
-
const themeSpecificStyle = {
|
|
45
|
-
canvas: {
|
|
46
|
-
color: theme['ic-brand-font-color-dark'],
|
|
47
|
-
focusOutlineColor: theme['ic-brand-primary']
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const componentVariables = {
|
|
51
|
-
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
52
|
-
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
|
|
53
|
-
color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
|
|
54
|
-
background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
|
|
55
|
-
requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.red5782,
|
|
56
|
-
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
57
|
-
borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
58
|
-
borderTopColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey3045,
|
|
59
|
-
borderRightColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey3045,
|
|
60
|
-
borderBottomColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.grey3045,
|
|
61
|
-
borderLeftColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.grey3045,
|
|
62
|
-
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
63
|
-
padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
64
|
-
focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.blue4570,
|
|
65
|
-
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
66
|
-
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
67
|
-
errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.red4570,
|
|
68
|
-
errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.red4570,
|
|
69
|
-
placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.grey4570,
|
|
70
|
-
smallFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
|
|
71
|
-
smallHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall,
|
|
72
|
-
mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
73
|
-
mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
|
|
74
|
-
largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
|
|
75
|
-
largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
...componentVariables,
|
|
79
|
-
...themeSpecificStyle[themeName]
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
var _default = exports.default = generateComponentTheme;
|
package/lib/index.js
DELETED
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|