@instructure/ui-text-input 8.13.0 → 8.13.1-snapshot.2
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/LICENSE.md +27 -0
- package/es/TextInput/index.js +32 -19
- package/es/TextInput/props.js +1 -104
- package/lib/TextInput/index.js +34 -19
- package/lib/TextInput/props.js +1 -104
- package/package.json +19 -18
- package/src/TextInput/index.tsx +34 -52
- package/src/TextInput/props.ts +108 -76
- package/types/TextInput/index.d.ts +34 -35
- package/types/TextInput/index.d.ts.map +1 -1
- package/types/TextInput/props.d.ts +97 -12
- package/types/TextInput/props.d.ts.map +1 -1
package/src/TextInput/index.tsx
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
|
-
import { Component } from 'react'
|
|
26
|
+
import React, { Component } from 'react'
|
|
27
27
|
|
|
28
28
|
import {
|
|
29
29
|
callRenderProp,
|
|
@@ -50,6 +50,7 @@ import { allowedProps, propTypes } from './props'
|
|
|
50
50
|
category: components
|
|
51
51
|
tags: form, field
|
|
52
52
|
---
|
|
53
|
+
@tsProps
|
|
53
54
|
**/
|
|
54
55
|
@withStyle(generateStyle, generateComponentTheme)
|
|
55
56
|
@testable()
|
|
@@ -68,31 +69,22 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
68
69
|
shouldNotWrap: false,
|
|
69
70
|
size: 'medium',
|
|
70
71
|
textAlign: 'start',
|
|
71
|
-
messages: []
|
|
72
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'input' is declared but its value is never read.
|
|
73
|
-
inputRef: function (input) {},
|
|
74
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'container' is declared but its value is never rea... Remove this comment to see the full error message
|
|
75
|
-
inputContainerRef: function (container) {},
|
|
76
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
77
|
-
onChange: function (event, value) {},
|
|
78
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
79
|
-
onBlur: function (event) {},
|
|
80
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
81
|
-
onFocus: function (event) {}
|
|
72
|
+
messages: []
|
|
82
73
|
}
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
constructor(props) {
|
|
75
|
+
constructor(props: TextInputProps) {
|
|
86
76
|
super(props)
|
|
87
77
|
this.state = { hasFocus: false }
|
|
88
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_defaultId' does not exist on type 'Text... Remove this comment to see the full error message
|
|
89
78
|
this._defaultId = uid('TextInput')
|
|
90
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_messagesId' does not exist on type 'Tex... Remove this comment to see the full error message
|
|
91
79
|
this._messagesId = uid('TextInput-messages')
|
|
92
80
|
}
|
|
93
81
|
|
|
94
82
|
ref: Element | null = null
|
|
95
83
|
|
|
84
|
+
private _input: HTMLInputElement | null = null
|
|
85
|
+
private _defaultId: string
|
|
86
|
+
private _messagesId: string
|
|
87
|
+
|
|
96
88
|
handleRef = (el: Element | null) => {
|
|
97
89
|
const { elementRef } = this.props
|
|
98
90
|
|
|
@@ -106,8 +98,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
106
98
|
this.props.makeStyles?.(this.makeStyleProps())
|
|
107
99
|
}
|
|
108
100
|
|
|
109
|
-
|
|
110
|
-
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
101
|
+
componentDidUpdate() {
|
|
111
102
|
this.props.makeStyles?.(this.makeStyleProps())
|
|
112
103
|
}
|
|
113
104
|
|
|
@@ -121,8 +112,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
121
112
|
}
|
|
122
113
|
|
|
123
114
|
focus() {
|
|
124
|
-
|
|
125
|
-
this._input.focus()
|
|
115
|
+
this._input?.focus()
|
|
126
116
|
}
|
|
127
117
|
|
|
128
118
|
get interaction() {
|
|
@@ -130,7 +120,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
130
120
|
}
|
|
131
121
|
|
|
132
122
|
get hasMessages() {
|
|
133
|
-
return this.props.messages && this.props.messages.length > 0
|
|
123
|
+
return !!this.props.messages && this.props.messages.length > 0
|
|
134
124
|
}
|
|
135
125
|
|
|
136
126
|
get invalid() {
|
|
@@ -143,47 +133,44 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
143
133
|
}
|
|
144
134
|
|
|
145
135
|
get focused() {
|
|
146
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_input' does not exist on type 'TextInpu... Remove this comment to see the full error message
|
|
147
136
|
return isActiveElement(this._input)
|
|
148
137
|
}
|
|
149
138
|
|
|
150
139
|
get value() {
|
|
151
|
-
|
|
152
|
-
return this._input.value
|
|
140
|
+
return this._input?.value
|
|
153
141
|
}
|
|
154
142
|
|
|
155
143
|
get id() {
|
|
156
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_defaultId' does not exist on type 'Text... Remove this comment to see the full error message
|
|
157
144
|
return this.props.id || this._defaultId
|
|
158
145
|
}
|
|
159
146
|
|
|
160
|
-
|
|
161
|
-
handleInputRef = (node) => {
|
|
162
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_input' does not exist on type 'TextInpu... Remove this comment to see the full error message
|
|
147
|
+
handleInputRef = (node: HTMLInputElement | null) => {
|
|
163
148
|
this._input = node
|
|
164
|
-
|
|
165
|
-
this.props.inputRef
|
|
149
|
+
|
|
150
|
+
if (typeof this.props.inputRef === 'function') {
|
|
151
|
+
this.props.inputRef(node)
|
|
152
|
+
}
|
|
166
153
|
}
|
|
167
154
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
155
|
+
handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {
|
|
156
|
+
if (typeof this.props.onChange === 'function') {
|
|
157
|
+
this.props.onChange(event, event.target.value)
|
|
158
|
+
}
|
|
172
159
|
}
|
|
173
160
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
161
|
+
handleBlur: React.FocusEventHandler<HTMLInputElement> = (event) => {
|
|
162
|
+
if (typeof this.props.onBlur === 'function') {
|
|
163
|
+
this.props.onBlur(event)
|
|
164
|
+
}
|
|
178
165
|
this.setState({
|
|
179
166
|
hasFocus: false
|
|
180
167
|
})
|
|
181
168
|
}
|
|
182
169
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
170
|
+
handleFocus: React.FocusEventHandler<HTMLInputElement> = (event) => {
|
|
171
|
+
if (typeof this.props.onFocus === 'function') {
|
|
172
|
+
this.props.onFocus(event)
|
|
173
|
+
}
|
|
187
174
|
this.setState({
|
|
188
175
|
hasFocus: true
|
|
189
176
|
})
|
|
@@ -215,10 +202,8 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
215
202
|
if (this.hasMessages) {
|
|
216
203
|
descriptionIds =
|
|
217
204
|
descriptionIds !== ''
|
|
218
|
-
?
|
|
219
|
-
|
|
220
|
-
: // @ts-expect-error ts-migrate(2339) FIXME: Property '_messagesId' does not exist on type 'Tex... Remove this comment to see the full error message
|
|
221
|
-
this._messagesId
|
|
205
|
+
? `${descriptionIds} ${this._messagesId}`
|
|
206
|
+
: this._messagesId
|
|
222
207
|
}
|
|
223
208
|
|
|
224
209
|
return (
|
|
@@ -232,11 +217,10 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
232
217
|
type={type}
|
|
233
218
|
id={this.id}
|
|
234
219
|
required={isRequired}
|
|
235
|
-
aria-invalid={this.invalid ? 'true' :
|
|
220
|
+
aria-invalid={this.invalid ? 'true' : undefined}
|
|
236
221
|
disabled={interaction === 'disabled'}
|
|
237
222
|
readOnly={interaction === 'readonly'}
|
|
238
|
-
aria-describedby={descriptionIds !== '' ? descriptionIds :
|
|
239
|
-
//@ts-expect-error can't be string
|
|
223
|
+
aria-describedby={descriptionIds !== '' ? descriptionIds : undefined}
|
|
240
224
|
size={htmlSize}
|
|
241
225
|
onChange={this.handleChange}
|
|
242
226
|
onBlur={this.handleBlur}
|
|
@@ -267,14 +251,12 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
267
251
|
<FormField
|
|
268
252
|
id={this.id}
|
|
269
253
|
label={callRenderProp(renderLabel)}
|
|
270
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property '_messagesId' does not exist on type 'Tex... Remove this comment to see the full error message
|
|
271
254
|
messagesId={this._messagesId}
|
|
272
255
|
messages={messages}
|
|
273
256
|
inline={display === 'inline-block'}
|
|
274
257
|
width={width}
|
|
275
258
|
inputContainerRef={inputContainerRef}
|
|
276
|
-
|
|
277
|
-
layout={this.props.layout} // eslint-disable-line react/prop-types
|
|
259
|
+
layout={this.props.layout}
|
|
278
260
|
elementRef={this.handleRef}
|
|
279
261
|
>
|
|
280
262
|
<span css={styles?.facade}>
|
package/src/TextInput/props.ts
CHANGED
|
@@ -29,7 +29,7 @@ import { FormPropTypes } from '@instructure/ui-form-field'
|
|
|
29
29
|
import { controllable } from '@instructure/ui-prop-types'
|
|
30
30
|
|
|
31
31
|
import type { InteractionType } from '@instructure/ui-react-utils'
|
|
32
|
-
import type { FormMessage } from '@instructure/ui-form-field'
|
|
32
|
+
import type { FormFieldProps, FormMessage } from '@instructure/ui-form-field'
|
|
33
33
|
import type {
|
|
34
34
|
OtherHTMLAttributes,
|
|
35
35
|
PropValidators,
|
|
@@ -38,153 +38,185 @@ import type {
|
|
|
38
38
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
39
39
|
|
|
40
40
|
type TextInputOwnProps = {
|
|
41
|
-
renderLabel?: React.ReactNode | ((...args: any[]) => any)
|
|
42
|
-
type?: 'text' | 'email' | 'url' | 'tel' | 'search' | 'password'
|
|
43
|
-
id?: string
|
|
44
|
-
value?: any // TODO: controllable(PropTypes.string)
|
|
45
|
-
defaultValue?: string
|
|
46
|
-
interaction?: InteractionType
|
|
47
|
-
messages?: FormMessage[]
|
|
48
|
-
size?: 'small' | 'medium' | 'large'
|
|
49
|
-
textAlign?: 'start' | 'center'
|
|
50
|
-
width?: string
|
|
51
|
-
htmlSize?: string | number
|
|
52
|
-
display?: 'inline-block' | 'block'
|
|
53
|
-
shouldNotWrap?: boolean
|
|
54
|
-
placeholder?: string
|
|
55
|
-
isRequired?: boolean
|
|
56
|
-
elementRef?: (element: Element | null) => void
|
|
57
|
-
inputRef?: (...args: any[]) => any
|
|
58
|
-
inputContainerRef?: (...args: any[]) => any
|
|
59
|
-
renderBeforeInput?: React.ReactNode | ((...args: any[]) => any)
|
|
60
|
-
renderAfterInput?: React.ReactNode | ((...args: any[]) => any)
|
|
61
|
-
onChange?: (...args: any[]) => any
|
|
62
|
-
onBlur?: (...args: any[]) => any
|
|
63
|
-
onFocus?: (...args: any[]) => any
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type PropKeys = keyof TextInputOwnProps
|
|
67
|
-
|
|
68
|
-
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
69
|
-
|
|
70
|
-
type TextInputProps = TextInputOwnProps &
|
|
71
|
-
WithStyleProps<TextInputTheme, TextInputStyle> &
|
|
72
|
-
OtherHTMLAttributes<TextInputOwnProps, InputHTMLAttributes<TextInputOwnProps>>
|
|
73
|
-
|
|
74
|
-
type TextInputStyle = ComponentStyle<
|
|
75
|
-
| 'textInput'
|
|
76
|
-
| 'facade'
|
|
77
|
-
| 'layout'
|
|
78
|
-
| 'beforeElement'
|
|
79
|
-
| 'innerWrapper'
|
|
80
|
-
| 'inputLayout'
|
|
81
|
-
| 'afterElement'
|
|
82
|
-
>
|
|
83
|
-
|
|
84
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
85
41
|
/**
|
|
86
42
|
* The form field label.
|
|
87
43
|
*/
|
|
88
|
-
renderLabel
|
|
44
|
+
renderLabel?: React.ReactNode | (() => React.ReactNode)
|
|
45
|
+
|
|
89
46
|
/**
|
|
90
47
|
* Determines the underlying native HTML `<input>` element's `type`.
|
|
48
|
+
*
|
|
91
49
|
* For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
|
|
92
50
|
*/
|
|
93
|
-
type
|
|
51
|
+
type?: 'text' | 'email' | 'url' | 'tel' | 'search' | 'password'
|
|
52
|
+
|
|
94
53
|
/**
|
|
95
54
|
* The id of the text input. One is generated if not supplied.
|
|
96
55
|
*/
|
|
97
|
-
id
|
|
56
|
+
id?: string
|
|
57
|
+
|
|
98
58
|
/**
|
|
99
59
|
* the selected value (must be accompanied by an `onChange` prop)
|
|
100
60
|
*/
|
|
101
|
-
value: controllable(PropTypes.string)
|
|
61
|
+
value?: string // TODO: controllable(PropTypes.string)
|
|
62
|
+
|
|
102
63
|
/**
|
|
103
64
|
* value to set on initial render
|
|
104
65
|
*/
|
|
105
|
-
defaultValue
|
|
66
|
+
defaultValue?: string
|
|
67
|
+
|
|
106
68
|
/**
|
|
107
69
|
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
108
70
|
* When "disabled", the input changes visibly to indicate that it cannot
|
|
109
71
|
* receive user interactions. When "readonly" the input still cannot receive
|
|
110
72
|
* user interactions but it keeps the same styles as if it were enabled.
|
|
111
73
|
*/
|
|
112
|
-
interaction
|
|
74
|
+
interaction?: InteractionType
|
|
75
|
+
|
|
113
76
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
77
|
+
* Array of objects with shape: `{
|
|
78
|
+
* text: React.ReactNode,
|
|
79
|
+
* type: One of ['error', 'hint', 'success', 'screenreader-only']
|
|
80
|
+
* }`
|
|
118
81
|
*/
|
|
119
|
-
messages
|
|
82
|
+
messages?: FormMessage[]
|
|
83
|
+
|
|
120
84
|
/**
|
|
121
85
|
* The size of the text input.
|
|
122
86
|
*/
|
|
123
|
-
size
|
|
87
|
+
size?: 'small' | 'medium' | 'large'
|
|
88
|
+
|
|
124
89
|
/**
|
|
125
90
|
* The text alignment of the input.
|
|
126
91
|
*/
|
|
127
|
-
textAlign
|
|
92
|
+
textAlign?: 'start' | 'center'
|
|
93
|
+
|
|
128
94
|
/**
|
|
129
95
|
* The width of the input.
|
|
130
96
|
*/
|
|
131
|
-
width
|
|
97
|
+
width?: string
|
|
98
|
+
|
|
132
99
|
/**
|
|
133
|
-
* The width of the input
|
|
134
|
-
* provided via the `width` prop.
|
|
100
|
+
* The width of the input (integer value 0 or higher), if a width is not explicitly
|
|
101
|
+
* provided via the `width` prop.
|
|
102
|
+
*
|
|
103
|
+
* Only applicable if `display="inline-block"`.
|
|
104
|
+
*
|
|
105
|
+
* For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size
|
|
135
106
|
*/
|
|
136
|
-
htmlSize
|
|
107
|
+
htmlSize?: number
|
|
108
|
+
|
|
137
109
|
/**
|
|
138
110
|
* The display of the root element.
|
|
139
111
|
*/
|
|
140
|
-
display
|
|
112
|
+
display?: 'inline-block' | 'block'
|
|
113
|
+
|
|
141
114
|
/**
|
|
142
115
|
* Prevents the default behavior of wrapping the input and rendered content
|
|
143
116
|
* when available space is exceeded.
|
|
144
117
|
*/
|
|
145
|
-
shouldNotWrap
|
|
118
|
+
shouldNotWrap?: boolean
|
|
119
|
+
|
|
146
120
|
/**
|
|
147
|
-
* Html placeholder text to display when the input has no value. This should be hint text, not a label
|
|
148
|
-
* replacement.
|
|
121
|
+
* Html placeholder text to display when the input has no value. This should be hint text, not a label replacement.
|
|
149
122
|
*/
|
|
150
|
-
placeholder
|
|
123
|
+
placeholder?: string
|
|
124
|
+
|
|
151
125
|
/**
|
|
152
126
|
* Whether or not the text input is required.
|
|
153
127
|
*/
|
|
154
|
-
isRequired
|
|
128
|
+
isRequired?: boolean
|
|
129
|
+
|
|
155
130
|
/**
|
|
156
131
|
* provides a reference to the underlying html root element
|
|
157
132
|
*/
|
|
158
|
-
elementRef:
|
|
133
|
+
elementRef?: (element: Element | null) => void
|
|
134
|
+
|
|
159
135
|
/**
|
|
160
136
|
* a function that provides a reference to the actual input element
|
|
161
137
|
*/
|
|
162
|
-
inputRef:
|
|
138
|
+
inputRef?: (inputElement: HTMLInputElement | null) => void
|
|
139
|
+
|
|
163
140
|
/**
|
|
164
141
|
* a function that provides a reference a parent of the input element
|
|
165
142
|
*/
|
|
166
|
-
inputContainerRef:
|
|
143
|
+
inputContainerRef?: (element: Element | null) => void
|
|
144
|
+
|
|
167
145
|
/**
|
|
168
146
|
* Content to display before the input text, such as an icon
|
|
169
147
|
*/
|
|
170
|
-
renderBeforeInput
|
|
148
|
+
renderBeforeInput?: React.ReactNode | (() => React.ReactNode)
|
|
149
|
+
|
|
171
150
|
/**
|
|
172
151
|
* Content to display after the input text, such as an icon
|
|
173
152
|
*/
|
|
174
|
-
renderAfterInput
|
|
153
|
+
renderAfterInput?: React.ReactNode | (() => React.ReactNode)
|
|
154
|
+
|
|
175
155
|
/**
|
|
176
156
|
* Callback executed when the input fires a change event.
|
|
177
157
|
* @param {Object} event - the event object
|
|
178
|
-
* @param {
|
|
158
|
+
* @param {string} value - the string value of the input
|
|
179
159
|
*/
|
|
180
|
-
onChange:
|
|
160
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: string) => void
|
|
161
|
+
|
|
181
162
|
/**
|
|
182
163
|
* Callback fired when input loses focus.
|
|
183
164
|
*/
|
|
184
|
-
onBlur:
|
|
165
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void
|
|
166
|
+
|
|
185
167
|
/**
|
|
186
168
|
* Callback fired when input receives focus.
|
|
187
169
|
*/
|
|
170
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type PropKeys = keyof TextInputOwnProps
|
|
174
|
+
|
|
175
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
176
|
+
|
|
177
|
+
type TextInputProps = TextInputOwnProps &
|
|
178
|
+
WithStyleProps<TextInputTheme, TextInputStyle> &
|
|
179
|
+
OtherHTMLAttributes<
|
|
180
|
+
TextInputOwnProps,
|
|
181
|
+
InputHTMLAttributes<TextInputOwnProps>
|
|
182
|
+
> &
|
|
183
|
+
// The component will handle pass this prop to FormField, but it shouldn't be
|
|
184
|
+
// listed as a prop
|
|
185
|
+
Pick<FormFieldProps, 'layout'>
|
|
186
|
+
|
|
187
|
+
type TextInputStyle = ComponentStyle<
|
|
188
|
+
| 'textInput'
|
|
189
|
+
| 'facade'
|
|
190
|
+
| 'layout'
|
|
191
|
+
| 'beforeElement'
|
|
192
|
+
| 'innerWrapper'
|
|
193
|
+
| 'inputLayout'
|
|
194
|
+
| 'afterElement'
|
|
195
|
+
>
|
|
196
|
+
|
|
197
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
198
|
+
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
199
|
+
type: PropTypes.oneOf(['text', 'email', 'url', 'tel', 'search', 'password']),
|
|
200
|
+
id: PropTypes.string,
|
|
201
|
+
value: controllable(PropTypes.string),
|
|
202
|
+
defaultValue: PropTypes.string,
|
|
203
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
204
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
205
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
206
|
+
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
207
|
+
width: PropTypes.string,
|
|
208
|
+
htmlSize: PropTypes.number,
|
|
209
|
+
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
210
|
+
shouldNotWrap: PropTypes.bool,
|
|
211
|
+
placeholder: PropTypes.string,
|
|
212
|
+
isRequired: PropTypes.bool,
|
|
213
|
+
elementRef: PropTypes.func,
|
|
214
|
+
inputRef: PropTypes.func,
|
|
215
|
+
inputContainerRef: PropTypes.func,
|
|
216
|
+
renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
217
|
+
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
218
|
+
onChange: PropTypes.func,
|
|
219
|
+
onBlur: PropTypes.func,
|
|
188
220
|
onFocus: PropTypes.func
|
|
189
221
|
}
|
|
190
222
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { Component } from 'react';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
3
|
import { jsx } from '@instructure/emotion';
|
|
4
4
|
import type { TextInputProps, TextInputState, TextInputStyleProps } from './props';
|
|
5
5
|
/**
|
|
@@ -7,58 +7,59 @@ import type { TextInputProps, TextInputState, TextInputStyleProps } from './prop
|
|
|
7
7
|
category: components
|
|
8
8
|
tags: form, field
|
|
9
9
|
---
|
|
10
|
+
@tsProps
|
|
10
11
|
**/
|
|
11
12
|
declare class TextInput extends Component<TextInputProps, TextInputState> {
|
|
12
13
|
static readonly componentId = "TextInput";
|
|
13
14
|
static allowedProps: readonly (keyof {
|
|
14
|
-
renderLabel?:
|
|
15
|
+
renderLabel?: React.ReactNode | (() => React.ReactNode);
|
|
15
16
|
type?: "text" | "email" | "url" | "tel" | "search" | "password" | undefined;
|
|
16
17
|
id?: string | undefined;
|
|
17
|
-
value?:
|
|
18
|
+
value?: string | undefined;
|
|
18
19
|
defaultValue?: string | undefined;
|
|
19
20
|
interaction?: import("@instructure/ui-react-utils").InteractionType | undefined;
|
|
20
21
|
messages?: import("@instructure/ui-form-field/types/FormPropTypes").FormMessage[] | undefined;
|
|
21
22
|
size?: "small" | "medium" | "large" | undefined;
|
|
22
23
|
textAlign?: "start" | "center" | undefined;
|
|
23
24
|
width?: string | undefined;
|
|
24
|
-
htmlSize?:
|
|
25
|
+
htmlSize?: number | undefined;
|
|
25
26
|
display?: "inline-block" | "block" | undefined;
|
|
26
27
|
shouldNotWrap?: boolean | undefined;
|
|
27
28
|
placeholder?: string | undefined;
|
|
28
29
|
isRequired?: boolean | undefined;
|
|
29
30
|
elementRef?: ((element: Element | null) => void) | undefined;
|
|
30
|
-
inputRef?: ((
|
|
31
|
-
inputContainerRef?: ((
|
|
32
|
-
renderBeforeInput?:
|
|
33
|
-
renderAfterInput?:
|
|
34
|
-
onChange?: ((
|
|
35
|
-
onBlur?: ((
|
|
36
|
-
onFocus?: ((
|
|
31
|
+
inputRef?: ((inputElement: HTMLInputElement | null) => void) | undefined;
|
|
32
|
+
inputContainerRef?: ((element: Element | null) => void) | undefined;
|
|
33
|
+
renderBeforeInput?: React.ReactNode | (() => React.ReactNode);
|
|
34
|
+
renderAfterInput?: React.ReactNode | (() => React.ReactNode);
|
|
35
|
+
onChange?: ((event: React.ChangeEvent<HTMLInputElement>, value: string) => void) | undefined;
|
|
36
|
+
onBlur?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
37
|
+
onFocus?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
37
38
|
})[];
|
|
38
39
|
static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
|
|
39
|
-
renderLabel?:
|
|
40
|
+
renderLabel?: React.ReactNode | (() => React.ReactNode);
|
|
40
41
|
type?: "text" | "email" | "url" | "tel" | "search" | "password" | undefined;
|
|
41
42
|
id?: string | undefined;
|
|
42
|
-
value?:
|
|
43
|
+
value?: string | undefined;
|
|
43
44
|
defaultValue?: string | undefined;
|
|
44
45
|
interaction?: import("@instructure/ui-react-utils").InteractionType | undefined;
|
|
45
46
|
messages?: import("@instructure/ui-form-field/types/FormPropTypes").FormMessage[] | undefined;
|
|
46
47
|
size?: "small" | "medium" | "large" | undefined;
|
|
47
48
|
textAlign?: "start" | "center" | undefined;
|
|
48
49
|
width?: string | undefined;
|
|
49
|
-
htmlSize?:
|
|
50
|
+
htmlSize?: number | undefined;
|
|
50
51
|
display?: "inline-block" | "block" | undefined;
|
|
51
52
|
shouldNotWrap?: boolean | undefined;
|
|
52
53
|
placeholder?: string | undefined;
|
|
53
54
|
isRequired?: boolean | undefined;
|
|
54
55
|
elementRef?: ((element: Element | null) => void) | undefined;
|
|
55
|
-
inputRef?: ((
|
|
56
|
-
inputContainerRef?: ((
|
|
57
|
-
renderBeforeInput?:
|
|
58
|
-
renderAfterInput?:
|
|
59
|
-
onChange?: ((
|
|
60
|
-
onBlur?: ((
|
|
61
|
-
onFocus?: ((
|
|
56
|
+
inputRef?: ((inputElement: HTMLInputElement | null) => void) | undefined;
|
|
57
|
+
inputContainerRef?: ((element: Element | null) => void) | undefined;
|
|
58
|
+
renderBeforeInput?: React.ReactNode | (() => React.ReactNode);
|
|
59
|
+
renderAfterInput?: React.ReactNode | (() => React.ReactNode);
|
|
60
|
+
onChange?: ((event: React.ChangeEvent<HTMLInputElement>, value: string) => void) | undefined;
|
|
61
|
+
onBlur?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
62
|
+
onFocus?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
62
63
|
}>;
|
|
63
64
|
static defaultProps: {
|
|
64
65
|
type: string;
|
|
@@ -69,29 +70,27 @@ declare class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
69
70
|
size: string;
|
|
70
71
|
textAlign: string;
|
|
71
72
|
messages: never[];
|
|
72
|
-
inputRef: (input: any) => void;
|
|
73
|
-
inputContainerRef: (container: any) => void;
|
|
74
|
-
onChange: (event: any, value: any) => void;
|
|
75
|
-
onBlur: (event: any) => void;
|
|
76
|
-
onFocus: (event: any) => void;
|
|
77
73
|
};
|
|
78
|
-
constructor(props:
|
|
74
|
+
constructor(props: TextInputProps);
|
|
79
75
|
ref: Element | null;
|
|
76
|
+
private _input;
|
|
77
|
+
private _defaultId;
|
|
78
|
+
private _messagesId;
|
|
80
79
|
handleRef: (el: Element | null) => void;
|
|
81
80
|
componentDidMount(): void;
|
|
82
|
-
componentDidUpdate(
|
|
81
|
+
componentDidUpdate(): void;
|
|
83
82
|
makeStyleProps: () => TextInputStyleProps;
|
|
84
83
|
focus(): void;
|
|
85
84
|
get interaction(): import("@instructure/ui-react-utils").InteractionType;
|
|
86
|
-
get hasMessages(): boolean
|
|
85
|
+
get hasMessages(): boolean;
|
|
87
86
|
get invalid(): boolean;
|
|
88
87
|
get focused(): boolean;
|
|
89
|
-
get value():
|
|
90
|
-
get id():
|
|
91
|
-
handleInputRef: (node:
|
|
92
|
-
handleChange:
|
|
93
|
-
handleBlur:
|
|
94
|
-
handleFocus:
|
|
88
|
+
get value(): string | undefined;
|
|
89
|
+
get id(): string;
|
|
90
|
+
handleInputRef: (node: HTMLInputElement | null) => void;
|
|
91
|
+
handleChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
92
|
+
handleBlur: React.FocusEventHandler<HTMLInputElement>;
|
|
93
|
+
handleFocus: React.FocusEventHandler<HTMLInputElement>;
|
|
95
94
|
renderInput(): jsx.JSX.Element;
|
|
96
95
|
render(): jsx.JSX.Element;
|
|
97
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TextInput/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TextInput/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAWxC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,mBAAmB,EACpB,MAAM,SAAS,CAAA;AAGhB;;;;;;GAMG;AACH,cAEM,SAAU,SAAQ,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAC/D,MAAM,CAAC,QAAQ,CAAC,WAAW,eAAc;IAEzC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;;;;;MAUlB;gBAEW,KAAK,EAAE,cAAc;IAOjC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,WAAW,CAAQ;IAE3B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAQ9B;IACD,iBAAiB;IAIjB,kBAAkB;IAIlB,cAAc,QAAO,mBAAmB,CAOvC;IAED,KAAK;IAIL,IAAI,WAAW,0DAEd;IAED,IAAI,WAAW,YAEd;IAED,IAAI,OAAO,YAOV;IAED,IAAI,OAAO,YAEV;IAED,IAAI,KAAK,uBAER;IAED,IAAI,EAAE,WAEL;IAED,cAAc,SAAU,gBAAgB,GAAG,IAAI,UAM9C;IAED,YAAY,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAIvD;IAED,UAAU,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAOpD;IAED,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAOrD;IAED,WAAW;IAqDX,MAAM;CA+DP;AAED,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,CAAA"}
|