@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 +4 -0
- package/es/TextArea/TextAreaLocator.js +2 -1
- package/es/TextArea/index.js +27 -27
- package/es/TextArea/props.js +0 -66
- package/lib/TextArea/TextAreaLocator.js +1 -0
- package/lib/TextArea/index.js +27 -27
- package/lib/TextArea/props.js +0 -66
- package/package.json +17 -18
- package/src/TextArea/index.tsx +41 -77
- package/src/TextArea/props.ts +63 -59
- package/tsconfig.build.json +21 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/TextArea/TextAreaLocator.d.ts +117 -117
- package/types/TextArea/index.d.ts +25 -21
- package/types/TextArea/index.d.ts.map +1 -1
- package/types/TextArea/props.d.ts +58 -6
- package/types/TextArea/props.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/src/TextArea/index.tsx
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from '@instructure/ui-dom-utils'
|
|
34
34
|
import type { RequestAnimationFrameType } from '@instructure/ui-dom-utils'
|
|
35
35
|
import { debounce } from '@instructure/debounce'
|
|
36
|
+
import type { Debounced } from '@instructure/debounce'
|
|
36
37
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
37
38
|
import { uid } from '@instructure/uid'
|
|
38
39
|
import { px } from '@instructure/ui-utils'
|
|
@@ -48,6 +49,7 @@ import { allowedProps, propTypes } from './props'
|
|
|
48
49
|
---
|
|
49
50
|
category: components
|
|
50
51
|
---
|
|
52
|
+
@tsProps
|
|
51
53
|
**/
|
|
52
54
|
@withStyle(generateStyle, generateComponentTheme)
|
|
53
55
|
@testable()
|
|
@@ -65,20 +67,23 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
65
67
|
messages: [],
|
|
66
68
|
disabled: false,
|
|
67
69
|
readOnly: false,
|
|
68
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'textarea' is declared but its value is never read... Remove this comment to see the full error message
|
|
69
|
-
textareaRef: function (textarea) {},
|
|
70
70
|
layout: 'stacked',
|
|
71
71
|
required: false
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
_listener
|
|
75
|
-
_request
|
|
74
|
+
private _listener?: { remove(): void }
|
|
75
|
+
private _request?: RequestAnimationFrameType
|
|
76
|
+
private _defaultId: string
|
|
77
|
+
private _textareaResizeListener?: ResizeObserver
|
|
78
|
+
private _debounced?: Debounced
|
|
79
|
+
private _textarea: HTMLTextAreaElement | null = null
|
|
80
|
+
private _container: HTMLDivElement | null = null
|
|
81
|
+
private _height?: string
|
|
82
|
+
private _manuallyResized = false
|
|
76
83
|
|
|
77
|
-
constructor() {
|
|
78
|
-
|
|
79
|
-
super()
|
|
84
|
+
constructor(props: TextAreaProps) {
|
|
85
|
+
super(props)
|
|
80
86
|
|
|
81
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_defaultId' does not exist on type 'Text... Remove this comment to see the full error message
|
|
82
87
|
this._defaultId = uid('TextArea')
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -87,8 +92,7 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
87
92
|
this.props.makeStyles?.()
|
|
88
93
|
}
|
|
89
94
|
|
|
90
|
-
|
|
91
|
-
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
95
|
+
componentDidUpdate() {
|
|
92
96
|
this.autoGrow()
|
|
93
97
|
this.props.makeStyles?.()
|
|
94
98
|
}
|
|
@@ -98,9 +102,7 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
98
102
|
this._listener.remove()
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textareaResizeListener' does not exist ... Remove this comment to see the full error message
|
|
102
105
|
if (this._textareaResizeListener) {
|
|
103
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textareaResizeListener' does not exist ... Remove this comment to see the full error message
|
|
104
106
|
this._textareaResizeListener.disconnect()
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -108,35 +110,25 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
108
110
|
this._request.cancel()
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_debounced' does not exist on type 'Text... Remove this comment to see the full error message
|
|
112
113
|
if (this._debounced) {
|
|
113
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_debounced' does not exist on type 'Text... Remove this comment to see the full error message
|
|
114
114
|
this._debounced.cancel()
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
121
|
-
const textareaHeight = this._textarea.style.height
|
|
122
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_height' does not exist on type 'TextAre... Remove this comment to see the full error message
|
|
118
|
+
_textareaResize = () => {
|
|
119
|
+
const textareaHeight = this._textarea!.style.height
|
|
123
120
|
if (textareaHeight !== '' && textareaHeight !== this._height) {
|
|
124
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_manuallyResized' does not exist on type... Remove this comment to see the full error message
|
|
125
121
|
this._manuallyResized = true
|
|
126
|
-
|
|
127
|
-
this._textarea.style.overflowY = 'auto'
|
|
122
|
+
this._textarea!.style.overflowY = 'auto'
|
|
128
123
|
|
|
129
124
|
// update container minHeight to ensure focus ring always wraps input
|
|
130
|
-
|
|
131
|
-
this._container.style.minHeight = textareaHeight
|
|
125
|
+
this._container!.style.minHeight = textareaHeight
|
|
132
126
|
}
|
|
133
127
|
}
|
|
134
128
|
|
|
135
129
|
autoGrow() {
|
|
136
130
|
if (this.props.autoGrow) {
|
|
137
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_debounced' does not exist on type 'Text... Remove this comment to see the full error message
|
|
138
131
|
if (!this._debounced) {
|
|
139
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_debounced' does not exist on type 'Text... Remove this comment to see the full error message
|
|
140
132
|
this._debounced = debounce(this.grow, 200, {
|
|
141
133
|
leading: false,
|
|
142
134
|
trailing: true
|
|
@@ -144,27 +136,21 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
144
136
|
}
|
|
145
137
|
|
|
146
138
|
if (!this._listener) {
|
|
147
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_debounced' does not exist on type 'Text... Remove this comment to see the full error message
|
|
148
139
|
this._listener = addEventListener(window, 'resize', this._debounced)
|
|
149
140
|
}
|
|
150
141
|
|
|
151
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
152
142
|
if (this._textarea && !this._textareaResizeListener) {
|
|
153
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'height' does not exist on type '{}'.
|
|
154
143
|
const { height: origHeight } = getBoundingClientRect(this._textarea)
|
|
155
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textareaResizeListener' does not exist ... Remove this comment to see the full error message
|
|
156
144
|
this._textareaResizeListener = new ResizeObserver((entries) => {
|
|
157
145
|
for (const entry of entries) {
|
|
158
146
|
const { height } = entry.contentRect
|
|
159
147
|
|
|
160
148
|
if (origHeight !== height) {
|
|
161
|
-
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
|
162
149
|
this._textareaResize()
|
|
163
150
|
}
|
|
164
151
|
}
|
|
165
152
|
})
|
|
166
153
|
|
|
167
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textareaResizeListener' does not exist ... Remove this comment to see the full error message
|
|
168
154
|
this._textareaResizeListener.observe(this._textarea)
|
|
169
155
|
}
|
|
170
156
|
|
|
@@ -172,42 +158,36 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
172
158
|
}
|
|
173
159
|
}
|
|
174
160
|
|
|
175
|
-
|
|
176
|
-
grow = (evt) => {
|
|
177
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
161
|
+
grow = () => {
|
|
178
162
|
if (!this._textarea || this._manuallyResized) {
|
|
179
163
|
return
|
|
180
164
|
}
|
|
181
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
182
165
|
const offset = this._textarea.offsetHeight - this._textarea.clientHeight
|
|
183
166
|
let height = ''
|
|
184
167
|
|
|
185
168
|
// Notes:
|
|
186
169
|
// 1. height has to be reset to `auto` every time this method runs, or scrollHeight will not reset
|
|
187
170
|
// 2. `this._textarea.scrollHeight` will not reset if assigned to a variable; it needs to be written out each time
|
|
188
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
189
171
|
this._textarea.style.height = 'auto'
|
|
190
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
191
172
|
this._textarea.style.overflowY = 'hidden' // hide scrollbars for autoGrow textareas
|
|
192
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
193
173
|
height = this._textarea.scrollHeight + offset + 'px'
|
|
194
174
|
|
|
195
|
-
|
|
196
|
-
|
|
175
|
+
const maxHeight = this.props.maxHeight
|
|
176
|
+
? px(this.props.maxHeight, this._container)
|
|
177
|
+
: undefined
|
|
197
178
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
179
|
+
if (
|
|
180
|
+
this.props.maxHeight &&
|
|
181
|
+
maxHeight !== undefined &&
|
|
182
|
+
this._textarea.scrollHeight > maxHeight
|
|
183
|
+
) {
|
|
201
184
|
this._textarea.style.overflowY = 'auto' // add scroll if scrollHeight exceeds maxHeight in pixels
|
|
202
185
|
} else if (this.props.height) {
|
|
203
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
204
186
|
if (this._textarea.value === '') {
|
|
205
187
|
height = this.props.height
|
|
206
188
|
} else if (
|
|
207
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_container' does not exist on type 'Text... Remove this comment to see the full error message
|
|
208
189
|
px(this.props.height, this._container) > this._textarea.scrollHeight
|
|
209
190
|
) {
|
|
210
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
211
191
|
this._textarea.style.overflowY = 'auto' // add scroll if scrollHeight exceeds height in pixels
|
|
212
192
|
height = this.props.height
|
|
213
193
|
}
|
|
@@ -215,25 +195,20 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
215
195
|
|
|
216
196
|
// preserve container height to prevent scroll jumping on long textareas,
|
|
217
197
|
// but make sure container doesn't exceed maxHeight prop
|
|
218
|
-
const heightExceedsMax = px(height) > maxHeight
|
|
198
|
+
const heightExceedsMax = maxHeight !== undefined && px(height) > maxHeight
|
|
219
199
|
if (!heightExceedsMax) {
|
|
220
|
-
|
|
221
|
-
this._container.style.minHeight = height
|
|
200
|
+
this._container!.style.minHeight = height
|
|
222
201
|
}
|
|
223
202
|
|
|
224
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_height' does not exist on type 'TextAre... Remove this comment to see the full error message
|
|
225
203
|
this._height = height
|
|
226
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
227
204
|
this._textarea.style.height = height
|
|
228
205
|
}
|
|
229
206
|
|
|
230
207
|
focus() {
|
|
231
|
-
|
|
232
|
-
this._textarea.focus()
|
|
208
|
+
this._textarea!.focus()
|
|
233
209
|
}
|
|
234
210
|
|
|
235
|
-
|
|
236
|
-
handleChange = (event) => {
|
|
211
|
+
handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
237
212
|
const { onChange, value, disabled, readOnly } = this.props
|
|
238
213
|
|
|
239
214
|
if (disabled || readOnly) {
|
|
@@ -251,15 +226,12 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
251
226
|
}
|
|
252
227
|
}
|
|
253
228
|
|
|
254
|
-
|
|
255
|
-
handleContainerRef = (node) => {
|
|
256
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_container' does not exist on type 'Text... Remove this comment to see the full error message
|
|
229
|
+
handleContainerRef = (node: HTMLDivElement | null) => {
|
|
257
230
|
this._container = node
|
|
258
231
|
}
|
|
259
232
|
|
|
260
233
|
get minHeight() {
|
|
261
|
-
|
|
262
|
-
return this._textarea.style.minHeight
|
|
234
|
+
return this._textarea!.style.minHeight
|
|
263
235
|
}
|
|
264
236
|
|
|
265
237
|
get invalid() {
|
|
@@ -272,18 +244,15 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
272
244
|
}
|
|
273
245
|
|
|
274
246
|
get id() {
|
|
275
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_defaultId' does not exist on type 'Text... Remove this comment to see the full error message
|
|
276
247
|
return this.props.id || this._defaultId
|
|
277
248
|
}
|
|
278
249
|
|
|
279
250
|
get focused() {
|
|
280
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
281
251
|
return isActiveElement(this._textarea)
|
|
282
252
|
}
|
|
283
253
|
|
|
284
254
|
get value() {
|
|
285
|
-
|
|
286
|
-
return this._textarea.value
|
|
255
|
+
return this._textarea!.value
|
|
287
256
|
}
|
|
288
257
|
|
|
289
258
|
render() {
|
|
@@ -307,7 +276,7 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
307
276
|
const style = {
|
|
308
277
|
width,
|
|
309
278
|
resize,
|
|
310
|
-
height: !autoGrow ? height :
|
|
279
|
+
height: !autoGrow ? height : undefined,
|
|
311
280
|
maxHeight
|
|
312
281
|
}
|
|
313
282
|
|
|
@@ -317,18 +286,17 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
317
286
|
value={value}
|
|
318
287
|
defaultValue={defaultValue}
|
|
319
288
|
placeholder={placeholder}
|
|
320
|
-
ref={(textarea
|
|
321
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_textarea' does not exist on type 'TextA... Remove this comment to see the full error message
|
|
289
|
+
ref={(textarea) => {
|
|
322
290
|
this._textarea = textarea
|
|
323
|
-
|
|
324
|
-
|
|
291
|
+
if (typeof textareaRef === 'function') {
|
|
292
|
+
textareaRef(textarea)
|
|
293
|
+
}
|
|
325
294
|
}}
|
|
326
|
-
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ width: string | undefined; resize: "none" ... Remove this comment to see the full error message
|
|
327
295
|
style={style}
|
|
328
296
|
id={this.id}
|
|
329
297
|
required={required}
|
|
330
298
|
aria-required={required}
|
|
331
|
-
aria-invalid={this.invalid ? 'true' :
|
|
299
|
+
aria-invalid={this.invalid ? 'true' : undefined}
|
|
332
300
|
disabled={disabled || readOnly}
|
|
333
301
|
css={this.props.styles?.textArea}
|
|
334
302
|
onChange={this.handleChange}
|
|
@@ -336,15 +304,11 @@ class TextArea extends Component<TextAreaProps> {
|
|
|
336
304
|
)
|
|
337
305
|
|
|
338
306
|
return (
|
|
339
|
-
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
|
340
307
|
<FormField
|
|
341
308
|
{...pickProps(this.props, FormField.allowedProps)}
|
|
309
|
+
label={this.props.label}
|
|
342
310
|
vAlign="top"
|
|
343
311
|
id={this.id}
|
|
344
|
-
ref={(el) => {
|
|
345
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_node' does not exist on type 'TextArea'... Remove this comment to see the full error message
|
|
346
|
-
this._node = el
|
|
347
|
-
}}
|
|
348
312
|
>
|
|
349
313
|
<div
|
|
350
314
|
css={this.props.styles?.textAreaLayout}
|
package/src/TextArea/props.ts
CHANGED
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import type { TextareaHTMLAttributes } from 'react'
|
|
25
27
|
import PropTypes from 'prop-types'
|
|
26
28
|
|
|
27
29
|
import { controllable } from '@instructure/ui-prop-types'
|
|
@@ -32,117 +34,119 @@ import type {
|
|
|
32
34
|
PropValidators,
|
|
33
35
|
TextAreaTheme
|
|
34
36
|
} from '@instructure/shared-types'
|
|
35
|
-
import type { FormMessage } from '@instructure/ui-form-field'
|
|
37
|
+
import type { FormMessage, FormFieldOwnProps } from '@instructure/ui-form-field'
|
|
36
38
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
37
|
-
import { TextareaHTMLAttributes } from 'react'
|
|
38
39
|
|
|
39
40
|
type TextAreaOwnProps = {
|
|
40
41
|
label: React.ReactNode
|
|
41
42
|
id?: string
|
|
42
|
-
size?: 'small' | 'medium' | 'large'
|
|
43
|
-
layout?: 'stacked' | 'inline'
|
|
44
|
-
autoGrow?: boolean
|
|
45
|
-
resize?: 'none' | 'both' | 'horizontal' | 'vertical'
|
|
46
|
-
width?: string
|
|
47
|
-
height?: string
|
|
48
|
-
maxHeight?: number | string
|
|
49
|
-
messages?: FormMessage[]
|
|
50
|
-
inline?: boolean
|
|
51
|
-
placeholder?: string
|
|
52
|
-
disabled?: boolean
|
|
53
|
-
readOnly?: boolean
|
|
54
|
-
required?: boolean
|
|
55
|
-
textareaRef?: (...args: any[]) => any
|
|
56
|
-
defaultValue?: string
|
|
57
|
-
value?: any // TODO: controllable(PropTypes.string)
|
|
58
|
-
onChange?: (...args: any[]) => any
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type PropKeys = keyof TextAreaOwnProps
|
|
62
|
-
|
|
63
|
-
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
64
|
-
|
|
65
|
-
type TextAreaProps = TextAreaOwnProps &
|
|
66
|
-
WithStyleProps<TextAreaTheme, TextAreaStyle> &
|
|
67
|
-
OtherHTMLAttributes<
|
|
68
|
-
TextAreaOwnProps,
|
|
69
|
-
TextareaHTMLAttributes<TextAreaOwnProps>
|
|
70
|
-
>
|
|
71
|
-
|
|
72
|
-
type TextAreaStyle = ComponentStyle<
|
|
73
|
-
'textArea' | 'textAreaLayout' | 'textAreaOutline'
|
|
74
|
-
>
|
|
75
|
-
|
|
76
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
77
|
-
label: PropTypes.node.isRequired,
|
|
78
|
-
id: PropTypes.string,
|
|
79
43
|
/**
|
|
80
44
|
* sets the font-size for the textarea
|
|
81
45
|
*/
|
|
82
|
-
size
|
|
83
|
-
layout
|
|
46
|
+
size?: 'small' | 'medium' | 'large'
|
|
47
|
+
layout?: 'stacked' | 'inline'
|
|
84
48
|
/**
|
|
85
49
|
* the textarea will expand vertically to fit the height of the content,
|
|
86
50
|
* unless its content exceeds `maxHeight`
|
|
87
51
|
*/
|
|
88
|
-
autoGrow
|
|
52
|
+
autoGrow?: boolean
|
|
89
53
|
/**
|
|
90
54
|
* is the textarea resizable (in supported browsers)
|
|
91
55
|
*/
|
|
92
|
-
resize
|
|
56
|
+
resize?: 'none' | 'both' | 'horizontal' | 'vertical'
|
|
93
57
|
/**
|
|
94
58
|
* a fixed width for the textarea
|
|
95
59
|
*/
|
|
96
|
-
width
|
|
60
|
+
width?: string
|
|
97
61
|
/**
|
|
98
62
|
* Initial height for the textarea (if autoGrow is true it will grow vertically)
|
|
99
63
|
* Accepts CSS units, e.g. '55px'
|
|
100
64
|
*/
|
|
101
|
-
height
|
|
65
|
+
height?: string
|
|
102
66
|
/**
|
|
103
67
|
* when autoGrow is true, the textarea will never grow beyond this value
|
|
104
68
|
*/
|
|
105
|
-
maxHeight
|
|
69
|
+
maxHeight?: number | string
|
|
106
70
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
71
|
+
* Array of objects with shape: `{
|
|
72
|
+
* text: React.ReactNode,
|
|
73
|
+
* type: One of: ['error', 'hint', 'success', 'screenreader-only']
|
|
74
|
+
* }`
|
|
111
75
|
*/
|
|
112
|
-
messages
|
|
113
|
-
inline
|
|
76
|
+
messages?: FormMessage[]
|
|
77
|
+
inline?: boolean
|
|
114
78
|
/**
|
|
115
79
|
* Html placeholder text to display when the input has no value. This should be hint text, not a label
|
|
116
80
|
* replacement.
|
|
117
81
|
*/
|
|
118
|
-
placeholder
|
|
82
|
+
placeholder?: string
|
|
119
83
|
/**
|
|
120
84
|
* Whether or not to disable the textarea
|
|
121
85
|
*/
|
|
122
|
-
disabled
|
|
86
|
+
disabled?: boolean
|
|
123
87
|
/**
|
|
124
88
|
* Works just like disabled but keeps the same styles as if it were active
|
|
125
89
|
*/
|
|
126
|
-
readOnly
|
|
90
|
+
readOnly?: boolean
|
|
127
91
|
/**
|
|
128
92
|
* Sets the required property on the underlying native textArea
|
|
129
93
|
*/
|
|
130
|
-
required
|
|
94
|
+
required?: boolean
|
|
131
95
|
/**
|
|
132
96
|
* a function that provides a reference to the actual textarea element
|
|
133
97
|
*/
|
|
134
|
-
textareaRef:
|
|
98
|
+
textareaRef?: (textarea: HTMLTextAreaElement | null) => void
|
|
135
99
|
/**
|
|
136
100
|
* value to set on initial render
|
|
137
101
|
*/
|
|
138
|
-
defaultValue
|
|
102
|
+
defaultValue?: string
|
|
139
103
|
/**
|
|
140
104
|
* the selected value (must be accompanied by an `onChange` prop)
|
|
141
105
|
*/
|
|
142
|
-
value: controllable(PropTypes.string)
|
|
106
|
+
value?: string // TODO: controllable(PropTypes.string)
|
|
143
107
|
/**
|
|
144
108
|
* when used with the `value` prop, the component will not control its own state
|
|
145
109
|
*/
|
|
110
|
+
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
type PropKeys = keyof TextAreaOwnProps
|
|
114
|
+
|
|
115
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
116
|
+
|
|
117
|
+
type TextAreaProps =
|
|
118
|
+
// pickProps passes through FormField.allowedProps, except the ones set manually
|
|
119
|
+
Omit<FormFieldOwnProps, 'label' | 'inline' | 'id' | 'elementRef'> &
|
|
120
|
+
TextAreaOwnProps &
|
|
121
|
+
WithStyleProps<TextAreaTheme, TextAreaStyle> &
|
|
122
|
+
OtherHTMLAttributes<
|
|
123
|
+
TextAreaOwnProps,
|
|
124
|
+
TextareaHTMLAttributes<TextAreaOwnProps>
|
|
125
|
+
>
|
|
126
|
+
|
|
127
|
+
type TextAreaStyle = ComponentStyle<
|
|
128
|
+
'textArea' | 'textAreaLayout' | 'textAreaOutline'
|
|
129
|
+
>
|
|
130
|
+
|
|
131
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
132
|
+
label: PropTypes.node.isRequired,
|
|
133
|
+
id: PropTypes.string,
|
|
134
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
135
|
+
layout: PropTypes.oneOf(['stacked', 'inline']),
|
|
136
|
+
autoGrow: PropTypes.bool,
|
|
137
|
+
resize: PropTypes.oneOf(['none', 'both', 'horizontal', 'vertical']),
|
|
138
|
+
width: PropTypes.string,
|
|
139
|
+
height: PropTypes.string,
|
|
140
|
+
maxHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
141
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
142
|
+
inline: PropTypes.bool,
|
|
143
|
+
placeholder: PropTypes.string,
|
|
144
|
+
disabled: PropTypes.bool,
|
|
145
|
+
readOnly: PropTypes.bool,
|
|
146
|
+
required: PropTypes.bool,
|
|
147
|
+
textareaRef: PropTypes.func,
|
|
148
|
+
defaultValue: PropTypes.string,
|
|
149
|
+
value: controllable(PropTypes.string),
|
|
146
150
|
onChange: PropTypes.func
|
|
147
151
|
}
|
|
148
152
|
|
package/tsconfig.build.json
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.build.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "./types"
|
|
4
|
+
"outDir": "./types",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"composite": true
|
|
5
7
|
},
|
|
6
|
-
"include": ["src
|
|
8
|
+
"include": ["src"],
|
|
9
|
+
"references": [
|
|
10
|
+
{ "path": "../debounce/tsconfig.build.json" },
|
|
11
|
+
{ "path": "../emotion/tsconfig.build.json" },
|
|
12
|
+
{ "path": "../shared-types/tsconfig.build.json" },
|
|
13
|
+
{ "path": "../ui-dom-utils/tsconfig.build.json" },
|
|
14
|
+
{ "path": "../ui-form-field/tsconfig.build.json" },
|
|
15
|
+
{ "path": "../ui-prop-types/tsconfig.build.json" },
|
|
16
|
+
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
17
|
+
{ "path": "../ui-testable/tsconfig.build.json" },
|
|
18
|
+
{ "path": "../ui-utils/tsconfig.build.json" },
|
|
19
|
+
{ "path": "../uid/tsconfig.build.json" },
|
|
20
|
+
{ "path": "../ui-babel-preset/tsconfig.build.json" },
|
|
21
|
+
{ "path": "../ui-color-utils/tsconfig.build.json" },
|
|
22
|
+
{ "path": "../ui-test-locator/tsconfig.build.json" },
|
|
23
|
+
{ "path": "../ui-test-utils/tsconfig.build.json" },
|
|
24
|
+
{ "path": "../ui-themes/tsconfig.build.json" }
|
|
25
|
+
]
|
|
7
26
|
}
|