@instructure/ui-text-area 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +40 -291
  2. package/es/TextArea/{index.js → v1/index.js} +2 -2
  3. package/es/TextArea/v2/index.js +350 -0
  4. package/es/TextArea/v2/props.js +26 -0
  5. package/es/TextArea/v2/styles.js +129 -0
  6. package/es/TextArea/v2/theme.js +76 -0
  7. package/es/{index.js → exports/a.js} +1 -1
  8. package/{src/index.ts → es/exports/b.js} +1 -2
  9. package/lib/TextArea/{index.js → v1/index.js} +4 -4
  10. package/lib/TextArea/v2/index.js +361 -0
  11. package/lib/TextArea/v2/props.js +31 -0
  12. package/lib/TextArea/v2/styles.js +135 -0
  13. package/lib/TextArea/v2/theme.js +82 -0
  14. package/lib/{index.js → exports/a.js} +2 -2
  15. package/lib/exports/b.js +12 -0
  16. package/package.json +43 -21
  17. package/src/TextArea/{index.tsx → v1/index.tsx} +2 -2
  18. package/src/TextArea/{props.ts → v1/props.ts} +1 -1
  19. package/src/TextArea/{styles.ts → v1/styles.ts} +4 -3
  20. package/src/TextArea/v2/README.md +136 -0
  21. package/src/TextArea/v2/index.tsx +434 -0
  22. package/src/TextArea/v2/props.ts +160 -0
  23. package/src/TextArea/v2/styles.ts +156 -0
  24. package/src/TextArea/v2/theme.ts +87 -0
  25. package/src/exports/a.ts +25 -0
  26. package/src/exports/b.ts +25 -0
  27. package/tsconfig.build.tsbuildinfo +1 -1
  28. package/types/TextArea/{index.d.ts → v1/index.d.ts} +1 -1
  29. package/types/TextArea/v1/index.d.ts.map +1 -0
  30. package/types/TextArea/{props.d.ts → v1/props.d.ts} +1 -1
  31. package/types/TextArea/v1/props.d.ts.map +1 -0
  32. package/types/TextArea/v1/styles.d.ts.map +1 -0
  33. package/types/TextArea/v1/theme.d.ts.map +1 -0
  34. package/types/TextArea/v2/index.d.ts +84 -0
  35. package/types/TextArea/v2/index.d.ts.map +1 -0
  36. package/types/TextArea/v2/props.d.ts +92 -0
  37. package/types/TextArea/v2/props.d.ts.map +1 -0
  38. package/types/TextArea/v2/styles.d.ts +21 -0
  39. package/types/TextArea/v2/styles.d.ts.map +1 -0
  40. package/types/TextArea/v2/theme.d.ts +10 -0
  41. package/types/TextArea/v2/theme.d.ts.map +1 -0
  42. package/types/exports/a.d.ts +3 -0
  43. package/types/exports/a.d.ts.map +1 -0
  44. package/types/exports/b.d.ts +3 -0
  45. package/types/exports/b.d.ts.map +1 -0
  46. package/types/TextArea/index.d.ts.map +0 -1
  47. package/types/TextArea/props.d.ts.map +0 -1
  48. package/types/TextArea/styles.d.ts.map +0 -1
  49. package/types/TextArea/theme.d.ts.map +0 -1
  50. package/types/index.d.ts +0 -3
  51. package/types/index.d.ts.map +0 -1
  52. /package/es/TextArea/{props.js → v1/props.js} +0 -0
  53. /package/es/TextArea/{styles.js → v1/styles.js} +0 -0
  54. /package/es/TextArea/{theme.js → v1/theme.js} +0 -0
  55. /package/lib/TextArea/{props.js → v1/props.js} +0 -0
  56. /package/lib/TextArea/{styles.js → v1/styles.js} +0 -0
  57. /package/lib/TextArea/{theme.js → v1/theme.js} +0 -0
  58. /package/src/TextArea/{README.md → v1/README.md} +0 -0
  59. /package/src/TextArea/{theme.ts → v1/theme.ts} +0 -0
  60. /package/types/TextArea/{styles.d.ts → v1/styles.d.ts} +0 -0
  61. /package/types/TextArea/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,350 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["size", "autoGrow", "resize", "inline", "messages", "disabled", "readOnly", "layout", "required", "placeholder", "value", "defaultValue", "width", "height", "maxHeight", "textareaRef", "margin", "label", "onChange", "id", "themeOverride"];
3
+ /*
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2015 - present Instructure, Inc.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ import { forwardRef, useRef, useEffect, useContext, useImperativeHandle, useCallback, useMemo } from 'react';
28
+ import { FormField } from '@instructure/ui-form-field/latest';
29
+ import { addEventListener, isActiveElement, requestAnimationFrame, getBoundingClientRect } from '@instructure/ui-dom-utils';
30
+ import { debounce } from '@instructure/debounce';
31
+ import { useStyle } from '@instructure/emotion';
32
+ import { generateId, px } from '@instructure/ui-utils';
33
+ import { passthroughProps, pickProps, DeterministicIdContext } from '@instructure/ui-react-utils';
34
+ import generateStyle from "./styles.js";
35
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
36
+ /**
37
+ ---
38
+ category: components
39
+ ---
40
+ **/
41
+ const TextArea = /*#__PURE__*/forwardRef((props, ref) => {
42
+ const _props$size = props.size,
43
+ size = _props$size === void 0 ? 'medium' : _props$size,
44
+ _props$autoGrow = props.autoGrow,
45
+ autoGrow = _props$autoGrow === void 0 ? true : _props$autoGrow,
46
+ _props$resize = props.resize,
47
+ resize = _props$resize === void 0 ? 'none' : _props$resize,
48
+ _props$inline = props.inline,
49
+ inline = _props$inline === void 0 ? false : _props$inline,
50
+ _props$messages = props.messages,
51
+ messages = _props$messages === void 0 ? [] : _props$messages,
52
+ _props$disabled = props.disabled,
53
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
54
+ _props$readOnly = props.readOnly,
55
+ readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
56
+ _props$layout = props.layout,
57
+ layout = _props$layout === void 0 ? 'stacked' : _props$layout,
58
+ _props$required = props.required,
59
+ required = _props$required === void 0 ? false : _props$required,
60
+ placeholder = props.placeholder,
61
+ value = props.value,
62
+ defaultValue = props.defaultValue,
63
+ width = props.width,
64
+ height = props.height,
65
+ maxHeight = props.maxHeight,
66
+ textareaRef = props.textareaRef,
67
+ margin = props.margin,
68
+ label = props.label,
69
+ onChange = props.onChange,
70
+ propId = props.id,
71
+ themeOverride = props.themeOverride,
72
+ rest = _objectWithoutProperties(props, _excluded);
73
+
74
+ // Use deterministic ID
75
+ const instanceCounterMap = useContext(DeterministicIdContext);
76
+ const defaultId = useMemo(() => generateId('TextArea', instanceCounterMap), [instanceCounterMap]);
77
+ const id = propId || defaultId;
78
+
79
+ // Use refs for mutable values
80
+ const _listener = useRef();
81
+ const _request = useRef();
82
+ const _textareaResizeListener = useRef();
83
+ const _debounced = useRef();
84
+ const _textarea = useRef(null);
85
+ const _container = useRef(null);
86
+ const _height = useRef();
87
+ const _manuallyResized = useRef(false);
88
+ const formFieldRef = useRef(null);
89
+
90
+ // Compute invalid state
91
+ const _useMemo = useMemo(() => {
92
+ const isInvalid = messages && messages.findIndex(message => message.type === 'error' || message.type === 'newError') >= 0;
93
+ const isSuccess = messages && messages.findIndex(message => message.type === 'success') >= 0;
94
+ return {
95
+ isInvalid,
96
+ isSuccess
97
+ };
98
+ }, [messages]),
99
+ isInvalid = _useMemo.isInvalid,
100
+ isSuccess = _useMemo.isSuccess;
101
+
102
+ // Use styles
103
+ const styles = useStyle({
104
+ generateStyle,
105
+ themeOverride,
106
+ params: {
107
+ size,
108
+ disabled,
109
+ readOnly,
110
+ success: isSuccess,
111
+ invalid: isInvalid
112
+ },
113
+ componentId: 'TextArea',
114
+ displayName: 'TextArea'
115
+ });
116
+
117
+ // Mock ResizeObserver for SSR
118
+ useEffect(() => {
119
+ if (typeof window === 'undefined') {
120
+ global.ResizeObserver = class ResizeObserver {
121
+ observe() {
122
+ // do nothing
123
+ }
124
+ unobserve() {
125
+ // do nothing
126
+ }
127
+ disconnect() {
128
+ // do nothing
129
+ }
130
+ };
131
+ }
132
+ }, []);
133
+
134
+ // Grow function
135
+ const grow = useCallback(() => {
136
+ if (!_textarea.current || _manuallyResized.current) {
137
+ return;
138
+ }
139
+ const offset = _textarea.current.offsetHeight - _textarea.current.clientHeight;
140
+ let heightValue = '';
141
+
142
+ // Notes:
143
+ // 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
144
+ // 2. `_textarea.current.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
145
+ _textarea.current.style.height = 'auto';
146
+ _textarea.current.style.overflowY = 'hidden'; // hide scrollbars for autoGrow textareas
147
+ heightValue = _textarea.current.scrollHeight + offset + 'px';
148
+ const maxHeightPx = maxHeight ? px(maxHeight, _container.current) : void 0;
149
+ if (maxHeight && maxHeightPx !== void 0 && _textarea.current.scrollHeight > maxHeightPx) {
150
+ _textarea.current.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds maxHeight in pixels
151
+ } else if (height) {
152
+ if (_textarea.current.value === '') {
153
+ heightValue = height;
154
+ } else if (px(height, _container.current) > _textarea.current.scrollHeight) {
155
+ _textarea.current.style.overflowY = 'auto'; // add scroll if scrollHeight exceeds height in pixels
156
+ heightValue = height;
157
+ }
158
+ }
159
+
160
+ // preserve container height to prevent scroll jumping on long textareas,
161
+ // but make sure container doesn't exceed maxHeight prop
162
+ const heightExceedsMax = maxHeightPx !== void 0 && px(heightValue) > maxHeightPx;
163
+ if (!heightExceedsMax && _container.current) {
164
+ _container.current.style.minHeight = heightValue;
165
+ }
166
+ _height.current = heightValue;
167
+ _textarea.current.style.height = heightValue;
168
+ }, [height, maxHeight]);
169
+
170
+ // Textarea resize handler
171
+ const _textareaResize = useCallback(() => {
172
+ if (!_textarea.current) return;
173
+ const textareaHeight = _textarea.current.style.height;
174
+ if (textareaHeight !== '' && textareaHeight !== _height.current) {
175
+ _manuallyResized.current = true;
176
+ _textarea.current.style.overflowY = 'auto';
177
+
178
+ // update container minHeight to ensure focus ring always wraps input
179
+ if (_container.current) {
180
+ _container.current.style.minHeight = textareaHeight;
181
+ }
182
+ }
183
+ }, []);
184
+
185
+ // AutoGrow effect
186
+ useEffect(() => {
187
+ if (autoGrow) {
188
+ if (!_debounced.current) {
189
+ _debounced.current = debounce(grow, 200, {
190
+ leading: false,
191
+ trailing: true
192
+ });
193
+ }
194
+ if (!_listener.current) {
195
+ _listener.current = addEventListener(window, 'resize', _debounced.current);
196
+ }
197
+ if (_textarea.current && !_textareaResizeListener.current) {
198
+ const _getBoundingClientRec = getBoundingClientRect(_textarea.current),
199
+ origHeight = _getBoundingClientRec.height;
200
+ _textareaResizeListener.current = new ResizeObserver(entries => {
201
+ for (const entry of entries) {
202
+ const entryHeight = entry.contentRect.height;
203
+ if (origHeight !== entryHeight) {
204
+ _textareaResize();
205
+ }
206
+ }
207
+ });
208
+ _textareaResizeListener.current.observe(_textarea.current);
209
+ }
210
+ _request.current = requestAnimationFrame(grow);
211
+ }
212
+ }, [autoGrow, grow, _textareaResize]);
213
+
214
+ // Cleanup effect
215
+ useEffect(() => {
216
+ return () => {
217
+ if (_listener.current) {
218
+ _listener.current.remove();
219
+ }
220
+ if (_textareaResizeListener.current) {
221
+ _textareaResizeListener.current.disconnect();
222
+ }
223
+ if (_request.current) {
224
+ _request.current.cancel();
225
+ }
226
+ if (_debounced.current) {
227
+ _debounced.current.cancel();
228
+ }
229
+ };
230
+ }, []);
231
+
232
+ // Handle change
233
+ const handleChange = useCallback(event => {
234
+ if (disabled || readOnly) {
235
+ event.preventDefault();
236
+ return;
237
+ }
238
+ if (typeof value === 'undefined') {
239
+ // if uncontrolled
240
+ if (autoGrow) {
241
+ if (!_debounced.current) {
242
+ _debounced.current = debounce(grow, 200, {
243
+ leading: false,
244
+ trailing: true
245
+ });
246
+ }
247
+ if (!_listener.current) {
248
+ _listener.current = addEventListener(window, 'resize', _debounced.current);
249
+ }
250
+ if (_textarea.current && !_textareaResizeListener.current) {
251
+ const _getBoundingClientRec2 = getBoundingClientRect(_textarea.current),
252
+ origHeight = _getBoundingClientRec2.height;
253
+ _textareaResizeListener.current = new ResizeObserver(entries => {
254
+ for (const entry of entries) {
255
+ const entryHeight = entry.contentRect.height;
256
+ if (origHeight !== entryHeight) {
257
+ _textareaResize();
258
+ }
259
+ }
260
+ });
261
+ _textareaResizeListener.current.observe(_textarea.current);
262
+ }
263
+ _request.current = requestAnimationFrame(grow);
264
+ }
265
+ }
266
+ if (typeof onChange === 'function') {
267
+ onChange(event);
268
+ }
269
+ }, [disabled, readOnly, value, onChange, autoGrow, grow, _textareaResize]);
270
+
271
+ // Expose API through ref using useImperativeHandle
272
+ useImperativeHandle(ref, () => ({
273
+ focus: () => {
274
+ var _textarea$current;
275
+ (_textarea$current = _textarea.current) === null || _textarea$current === void 0 ? void 0 : _textarea$current.focus();
276
+ },
277
+ get value() {
278
+ var _textarea$current2;
279
+ return ((_textarea$current2 = _textarea.current) === null || _textarea$current2 === void 0 ? void 0 : _textarea$current2.value) || '';
280
+ },
281
+ get minHeight() {
282
+ var _textarea$current3;
283
+ return ((_textarea$current3 = _textarea.current) === null || _textarea$current3 === void 0 ? void 0 : _textarea$current3.style.minHeight) || '';
284
+ },
285
+ get focused() {
286
+ return isActiveElement(_textarea.current);
287
+ },
288
+ get invalid() {
289
+ return messages && messages.findIndex(message => message.type === 'error' || message.type === 'newError') >= 0;
290
+ },
291
+ get id() {
292
+ return id;
293
+ }
294
+ }), [id, messages]);
295
+ const style = {
296
+ width,
297
+ resize,
298
+ height: !autoGrow ? height : void 0,
299
+ maxHeight
300
+ };
301
+ const textarea = _jsx("textarea", {
302
+ ...passthroughProps(rest),
303
+ value: value,
304
+ defaultValue: defaultValue,
305
+ placeholder: placeholder,
306
+ ref: textarea => {
307
+ _textarea.current = textarea;
308
+ if (typeof textareaRef === 'function') {
309
+ textareaRef(textarea);
310
+ }
311
+ },
312
+ style: style,
313
+ id: id,
314
+ required: required,
315
+ "aria-required": required,
316
+ "aria-invalid": isInvalid ? 'true' : void 0,
317
+ disabled: disabled,
318
+ readOnly: readOnly,
319
+ css: styles === null || styles === void 0 ? void 0 : styles.textArea,
320
+ onChange: handleChange
321
+ });
322
+ return _jsx(FormField, {
323
+ ...pickProps(props, FormField.allowedProps),
324
+ label: label,
325
+ vAlign: "top",
326
+ id: id,
327
+ elementRef: el => {
328
+ formFieldRef.current = el;
329
+ },
330
+ margin: margin,
331
+ isRequired: required,
332
+ disabled: disabled,
333
+ readOnly: readOnly,
334
+ "data-cid": "TextArea",
335
+ children: _jsx("div", {
336
+ css: styles === null || styles === void 0 ? void 0 : styles.textAreaLayout,
337
+ style: {
338
+ width,
339
+ maxHeight
340
+ },
341
+ ref: node => {
342
+ _container.current = node;
343
+ },
344
+ children: textarea
345
+ })
346
+ });
347
+ });
348
+ TextArea.displayName = 'TextArea';
349
+ export default TextArea;
350
+ export { TextArea };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['label', 'id', 'size', 'layout', 'autoGrow', 'resize', 'width', 'height', 'maxHeight', 'messages', 'inline', 'placeholder', 'disabled', 'readOnly', 'required', 'textareaRef', 'defaultValue', 'value', 'onChange', 'margin'];
26
+ export { allowedProps };
@@ -0,0 +1,129 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { calcFocusOutlineStyles } from '@instructure/emotion';
26
+ /**
27
+ * ---
28
+ * private: true
29
+ * ---
30
+ * Generates the style object from the theme and provided additional information
31
+ * @param {Object} componentTheme The theme variable object.
32
+ * @param {Object} params Additional parameters to customize the style.
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (componentTheme, params, sharedTokens) => {
36
+ const disabled = params.disabled,
37
+ size = params.size,
38
+ success = params.success,
39
+ invalid = params.invalid,
40
+ readOnly = params.readOnly;
41
+ const fontSizeVariants = {
42
+ small: {
43
+ fontSize: componentTheme.fontSizeSm
44
+ },
45
+ medium: {
46
+ fontSize: componentTheme.fontSizeMd
47
+ },
48
+ large: {
49
+ fontSize: componentTheme.fontSizeLg
50
+ }
51
+ };
52
+ const focusColor = disabled || readOnly ? 'info' : invalid ? 'danger' : success ? 'success' : 'info';
53
+ return {
54
+ textArea: {
55
+ label: 'textArea',
56
+ all: 'initial',
57
+ WebkitFontSmoothing: 'antialiased',
58
+ MozOsxFontSmoothing: 'grayscale',
59
+ appearance: 'none',
60
+ height: 'auto',
61
+ margin: 0,
62
+ width: '100%',
63
+ display: 'block',
64
+ boxSizing: 'border-box',
65
+ padding: componentTheme.padding,
66
+ fontFamily: componentTheme.fontFamily,
67
+ fontWeight: componentTheme.fontWeight,
68
+ borderWidth: componentTheme.borderWidth,
69
+ borderStyle: 'solid',
70
+ borderColor: componentTheme.borderColor,
71
+ borderRadius: componentTheme.borderRadius,
72
+ color: componentTheme.textColor,
73
+ background: componentTheme.backgroundColor,
74
+ whiteSpace: 'pre-wrap',
75
+ wordWrap: 'break-word',
76
+ textAlign: 'start',
77
+ ...(!disabled && !readOnly && {
78
+ '&:hover': {
79
+ background: componentTheme.backgroundHoverColor,
80
+ borderColor: componentTheme.borderHoverColor,
81
+ '&::placeholder': {
82
+ color: componentTheme.placeholderHoverColor
83
+ }
84
+ }
85
+ }),
86
+ ...(readOnly && {
87
+ color: componentTheme.textReadonlyColor,
88
+ background: componentTheme.backgroundReadonlyColor,
89
+ borderColor: componentTheme.borderReadonlyColor
90
+ }),
91
+ ...(disabled && {
92
+ color: componentTheme.textDisabledColor,
93
+ background: componentTheme.backgroundDisabledColor,
94
+ borderColor: componentTheme.borderDisabledColor,
95
+ cursor: 'not-allowed',
96
+ pointerEvents: 'none',
97
+ opacity: 0.5
98
+ }),
99
+ ...(!disabled && !readOnly && success && {
100
+ borderColor: componentTheme.successBorderColor
101
+ }),
102
+ ...fontSizeVariants[size],
103
+ ...calcFocusOutlineStyles(sharedTokens.focusOutline, {
104
+ focusColor
105
+ }),
106
+ ...(!disabled && !readOnly && {
107
+ '&[aria-invalid], &[aria-invalid]:focus': {
108
+ borderColor: componentTheme.errorBorderColor
109
+ }
110
+ }),
111
+ '&::placeholder': {
112
+ color: componentTheme.placeholderColor
113
+ },
114
+ '&::-webkit-resizer': {
115
+ backgroundImage: `url("data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="9" height="9" viewBox="0 0 9 9" fill="none"><path d="M8.35352 0.353516L0.353516 8.35352M8.35352 4.35352L4.35352 8.35352" stroke="#8D959F"/></svg>')}")`,
116
+ backgroundColor: 'transparent',
117
+ backgroundPosition: 'bottom 2px right 2px',
118
+ // Position away from edges
119
+ backgroundRepeat: 'no-repeat',
120
+ backgroundSize: '10px 10px'
121
+ }
122
+ },
123
+ textAreaLayout: {
124
+ label: 'textArea__layout',
125
+ position: 'relative'
126
+ }
127
+ };
128
+ };
129
+ export default generateStyle;
@@ -0,0 +1,76 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * Generates the theme object for the component from the theme and provided additional information
27
+ * @param {Object} theme The actual theme object.
28
+ * @return {Object} The final theme object with the overrides and component variables
29
+ */
30
+ const generateComponentTheme = theme => {
31
+ var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1;
32
+ const colors = theme.colors,
33
+ typography = theme.typography,
34
+ borders = theme.borders,
35
+ spacing = theme.spacing,
36
+ forms = theme.forms,
37
+ themeName = theme.key;
38
+ const themeSpecificStyle = {
39
+ canvas: {
40
+ color: theme['ic-brand-font-color-dark'],
41
+ focusOutlineColor: theme['ic-brand-primary']
42
+ }
43
+ };
44
+ const componentVariables = {
45
+ fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
46
+ fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
47
+ color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
48
+ background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
49
+ requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.red5782,
50
+ borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
51
+ borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
52
+ borderTopColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey3045,
53
+ borderRightColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey3045,
54
+ borderBottomColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.grey3045,
55
+ borderLeftColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.grey3045,
56
+ borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
57
+ padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
58
+ focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.blue4570,
59
+ focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
60
+ focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
61
+ errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.red4570,
62
+ errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.red4570,
63
+ placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.grey4570,
64
+ smallFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
65
+ smallHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall,
66
+ mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
67
+ mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
68
+ largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
69
+ largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
70
+ };
71
+ return {
72
+ ...componentVariables,
73
+ ...themeSpecificStyle[themeName]
74
+ };
75
+ };
76
+ export default generateComponentTheme;
@@ -21,4 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { TextArea } from "./TextArea/index.js";
24
+ export { TextArea } from "../TextArea/v1/index.js";
@@ -21,5 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { TextArea } from './TextArea'
25
- export type { TextAreaProps } from './TextArea/props'
24
+ export { TextArea } from "../TextArea/v2/index.js";
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = exports.TextArea = void 0;
8
8
  var _react = require("react");
9
- var _FormField = require("@instructure/ui-form-field/lib/FormField");
9
+ var _v11_ = require("@instructure/ui-form-field/v11_6");
10
10
  var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
11
11
  var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
12
12
  var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
@@ -51,7 +51,7 @@ var _dec, _dec2, _class, _TextArea;
51
51
  category: components
52
52
  ---
53
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 {
54
+ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_TextArea = class TextArea extends _react.Component {
55
55
  constructor(props) {
56
56
  super(props);
57
57
  this._listener = void 0;
@@ -294,8 +294,8 @@ let TextArea = exports.TextArea = (_dec = (0, _withDeterministicId.withDetermini
294
294
  children: [' ', "*"]
295
295
  })]
296
296
  }) : this.props.label;
297
- return (0, _jsxRuntime.jsx)(_FormField.FormField, {
298
- ...(0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps),
297
+ return (0, _jsxRuntime.jsx)(_v11_.FormField, {
298
+ ...(0, _pickProps.pickProps)(this.props, _v11_.FormField.allowedProps),
299
299
  label: label,
300
300
  vAlign: "top",
301
301
  id: this.id,