@instructure/ui-text-input 8.8.1-snapshot.3 → 8.9.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 +6 -0
- package/es/TextInput/index.js +41 -171
- package/es/TextInput/props.js +151 -0
- package/lib/TextInput/index.js +40 -173
- package/lib/TextInput/props.js +164 -0
- package/package.json +18 -19
- package/src/TextInput/index.tsx +20 -140
- package/src/TextInput/props.ts +206 -0
- package/src/TextInput/styles.ts +1 -1
- package/src/index.ts +1 -1
- package/types/TextInput/index.d.ts +49 -118
- package/types/TextInput/index.d.ts.map +1 -1
- package/types/TextInput/{types.d.ts → props.d.ts} +13 -6
- package/types/TextInput/props.d.ts.map +1 -0
- package/types/TextInput/styles.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/LICENSE.md +0 -27
- package/es/TextInput/types.js +0 -1
- package/lib/TextInput/types.js +0 -1
- package/src/TextInput/types.ts +0 -64
- package/types/TextInput/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-input",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "A styled HTML text input component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@instructure/
|
|
28
|
-
"@instructure/ui-
|
|
29
|
-
"@instructure/ui-
|
|
30
|
-
"@instructure/ui-
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/ui-themes": "8.8.1-snapshot.3+d5d6d4cd8"
|
|
27
|
+
"@instructure/ui-babel-preset": "8.9.0",
|
|
28
|
+
"@instructure/ui-badge": "8.9.0",
|
|
29
|
+
"@instructure/ui-color-utils": "8.9.0",
|
|
30
|
+
"@instructure/ui-test-utils": "8.9.0",
|
|
31
|
+
"@instructure/ui-themes": "8.9.0"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"@babel/runtime": "^7.13.10",
|
|
36
|
-
"@instructure/emotion": "8.
|
|
37
|
-
"@instructure/
|
|
38
|
-
"@instructure/ui-
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-
|
|
42
|
-
"@instructure/ui-
|
|
43
|
-
"@instructure/ui-
|
|
44
|
-
"@instructure/ui-
|
|
45
|
-
"@instructure/
|
|
35
|
+
"@instructure/emotion": "8.9.0",
|
|
36
|
+
"@instructure/shared-types": "8.9.0",
|
|
37
|
+
"@instructure/ui-dom-utils": "8.9.0",
|
|
38
|
+
"@instructure/ui-form-field": "8.9.0",
|
|
39
|
+
"@instructure/ui-icons": "8.9.0",
|
|
40
|
+
"@instructure/ui-prop-types": "8.9.0",
|
|
41
|
+
"@instructure/ui-react-utils": "8.9.0",
|
|
42
|
+
"@instructure/ui-tag": "8.9.0",
|
|
43
|
+
"@instructure/ui-testable": "8.9.0",
|
|
44
|
+
"@instructure/ui-utils": "8.9.0",
|
|
45
|
+
"@instructure/uid": "8.9.0",
|
|
46
46
|
"prop-types": "^15"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -51,6 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"sideEffects": false
|
|
55
|
-
"gitHead": "d5d6d4cd8f300e8635c69248f5d794c002269e08"
|
|
54
|
+
"sideEffects": false
|
|
56
55
|
}
|
package/src/TextInput/index.tsx
CHANGED
|
@@ -24,16 +24,14 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component, InputHTMLAttributes } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
|
-
import { controllable } from '@instructure/ui-prop-types'
|
|
30
28
|
import {
|
|
31
29
|
callRenderProp,
|
|
32
30
|
getInteraction,
|
|
33
31
|
passthroughProps
|
|
34
32
|
} from '@instructure/ui-react-utils'
|
|
35
33
|
import { isActiveElement } from '@instructure/ui-dom-utils'
|
|
36
|
-
import { FormField
|
|
34
|
+
import { FormField } from '@instructure/ui-form-field'
|
|
37
35
|
import { uid } from '@instructure/uid'
|
|
38
36
|
import { testable } from '@instructure/ui-testable'
|
|
39
37
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
@@ -41,7 +39,12 @@ import { OtherHTMLAttributes } from '@instructure/shared-types'
|
|
|
41
39
|
|
|
42
40
|
import generateStyle from './styles'
|
|
43
41
|
import generateComponentTheme from './theme'
|
|
44
|
-
import {
|
|
42
|
+
import type {
|
|
43
|
+
TextInputProps,
|
|
44
|
+
TextInputState,
|
|
45
|
+
TextInputStyleProps
|
|
46
|
+
} from './props'
|
|
47
|
+
import { allowedProps, propTypes } from './props'
|
|
45
48
|
|
|
46
49
|
/**
|
|
47
50
|
---
|
|
@@ -58,136 +61,17 @@ class TextInput extends Component<
|
|
|
58
61
|
> {
|
|
59
62
|
static readonly componentId = 'TextInput'
|
|
60
63
|
|
|
61
|
-
static
|
|
62
|
-
|
|
63
|
-
* The form field label.
|
|
64
|
-
*/
|
|
65
|
-
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
66
|
-
/**
|
|
67
|
-
* Determines the underlying native HTML `<input>` element's `type`.
|
|
68
|
-
* For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
|
|
69
|
-
*/
|
|
70
|
-
type: PropTypes.oneOf([
|
|
71
|
-
'text',
|
|
72
|
-
'email',
|
|
73
|
-
'url',
|
|
74
|
-
'tel',
|
|
75
|
-
'search',
|
|
76
|
-
'password'
|
|
77
|
-
]),
|
|
78
|
-
/**
|
|
79
|
-
* The id of the text input. One is generated if not supplied.
|
|
80
|
-
*/
|
|
81
|
-
id: PropTypes.string,
|
|
82
|
-
/**
|
|
83
|
-
* the selected value (must be accompanied by an `onChange` prop)
|
|
84
|
-
*/
|
|
85
|
-
value: controllable(PropTypes.string),
|
|
86
|
-
/**
|
|
87
|
-
* value to set on initial render
|
|
88
|
-
*/
|
|
89
|
-
defaultValue: PropTypes.string,
|
|
90
|
-
/**
|
|
91
|
-
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
92
|
-
* When "disabled", the input changes visibly to indicate that it cannot
|
|
93
|
-
* receive user interactions. When "readonly" the input still cannot receive
|
|
94
|
-
* user interactions but it keeps the same styles as if it were enabled.
|
|
95
|
-
*/
|
|
96
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
97
|
-
/**
|
|
98
|
-
* object with shape: `{
|
|
99
|
-
* text: PropTypes.string,
|
|
100
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
101
|
-
* }`
|
|
102
|
-
*/
|
|
103
|
-
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
104
|
-
/**
|
|
105
|
-
* The size of the text input.
|
|
106
|
-
*/
|
|
107
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
108
|
-
/**
|
|
109
|
-
* The text alignment of the input.
|
|
110
|
-
*/
|
|
111
|
-
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
112
|
-
/**
|
|
113
|
-
* The width of the input.
|
|
114
|
-
*/
|
|
115
|
-
width: PropTypes.string,
|
|
116
|
-
/**
|
|
117
|
-
* The width of the input, in characters, if a width is not explicitly
|
|
118
|
-
* provided via the `width` prop. Only applicable if `isInline={true}`.
|
|
119
|
-
*/
|
|
120
|
-
htmlSize: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
121
|
-
/**
|
|
122
|
-
* The display of the root element.
|
|
123
|
-
*/
|
|
124
|
-
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
125
|
-
/**
|
|
126
|
-
* Prevents the default behavior of wrapping the input and rendered content
|
|
127
|
-
* when available space is exceeded.
|
|
128
|
-
*/
|
|
129
|
-
shouldNotWrap: PropTypes.bool,
|
|
130
|
-
/**
|
|
131
|
-
* Html placeholder text to display when the input has no value. This should be hint text, not a label
|
|
132
|
-
* replacement.
|
|
133
|
-
*/
|
|
134
|
-
placeholder: PropTypes.string,
|
|
135
|
-
/**
|
|
136
|
-
* Whether or not the text input is required.
|
|
137
|
-
*/
|
|
138
|
-
isRequired: PropTypes.bool,
|
|
139
|
-
/**
|
|
140
|
-
* a function that provides a reference to the actual input element
|
|
141
|
-
*/
|
|
142
|
-
inputRef: PropTypes.func,
|
|
143
|
-
/**
|
|
144
|
-
* a function that provides a reference a parent of the input element
|
|
145
|
-
*/
|
|
146
|
-
inputContainerRef: PropTypes.func,
|
|
147
|
-
/**
|
|
148
|
-
* Content to display before the input text, such as an icon
|
|
149
|
-
*/
|
|
150
|
-
renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
151
|
-
/**
|
|
152
|
-
* Content to display after the input text, such as an icon
|
|
153
|
-
*/
|
|
154
|
-
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
155
|
-
/**
|
|
156
|
-
* Callback executed when the input fires a change event.
|
|
157
|
-
* @param {Object} event - the event object
|
|
158
|
-
* @param {Object} value - the string value of the input
|
|
159
|
-
*/
|
|
160
|
-
onChange: PropTypes.func,
|
|
161
|
-
/**
|
|
162
|
-
* Callback fired when input loses focus.
|
|
163
|
-
*/
|
|
164
|
-
onBlur: PropTypes.func,
|
|
165
|
-
/**
|
|
166
|
-
* Callback fired when input receives focus.
|
|
167
|
-
*/
|
|
168
|
-
onFocus: PropTypes.func,
|
|
169
|
-
|
|
170
|
-
// eslint-disable-next-line react/require-default-props
|
|
171
|
-
makeStyles: PropTypes.func,
|
|
172
|
-
// eslint-disable-next-line react/require-default-props
|
|
173
|
-
styles: PropTypes.object
|
|
174
|
-
}
|
|
64
|
+
static allowedProps = allowedProps
|
|
65
|
+
static propTypes = propTypes
|
|
175
66
|
|
|
176
67
|
static defaultProps = {
|
|
177
|
-
renderLabel: undefined,
|
|
178
68
|
type: 'text',
|
|
179
|
-
id: undefined,
|
|
180
69
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
181
70
|
interaction: undefined,
|
|
182
71
|
isRequired: false,
|
|
183
|
-
value: undefined,
|
|
184
|
-
defaultValue: undefined,
|
|
185
72
|
display: 'block',
|
|
186
73
|
shouldNotWrap: false,
|
|
187
|
-
placeholder: undefined,
|
|
188
|
-
width: undefined,
|
|
189
74
|
size: 'medium',
|
|
190
|
-
htmlSize: undefined,
|
|
191
75
|
textAlign: 'start',
|
|
192
76
|
messages: [],
|
|
193
77
|
// @ts-expect-error ts-migrate(6133) FIXME: 'input' is declared but its value is never read.
|
|
@@ -199,9 +83,7 @@ class TextInput extends Component<
|
|
|
199
83
|
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
200
84
|
onBlur: function (event) {},
|
|
201
85
|
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
202
|
-
onFocus: function (event) {}
|
|
203
|
-
renderBeforeInput: undefined,
|
|
204
|
-
renderAfterInput: undefined
|
|
86
|
+
onFocus: function (event) {}
|
|
205
87
|
}
|
|
206
88
|
|
|
207
89
|
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
|
|
@@ -215,14 +97,12 @@ class TextInput extends Component<
|
|
|
215
97
|
}
|
|
216
98
|
|
|
217
99
|
componentDidMount() {
|
|
218
|
-
|
|
219
|
-
this.props.makeStyles(this.makeStyleProps())
|
|
100
|
+
this.props.makeStyles?.(this.makeStyleProps())
|
|
220
101
|
}
|
|
221
102
|
|
|
222
103
|
// @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
|
|
223
104
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
224
|
-
|
|
225
|
-
this.props.makeStyles(this.makeStyleProps())
|
|
105
|
+
this.props.makeStyles?.(this.makeStyleProps())
|
|
226
106
|
}
|
|
227
107
|
|
|
228
108
|
makeStyleProps = (): TextInputStyleProps => {
|
|
@@ -338,7 +218,7 @@ class TextInput extends Component<
|
|
|
338
218
|
return (
|
|
339
219
|
<input
|
|
340
220
|
{...props}
|
|
341
|
-
css={this.props.styles
|
|
221
|
+
css={this.props.styles?.textInput}
|
|
342
222
|
defaultValue={defaultValue}
|
|
343
223
|
value={value}
|
|
344
224
|
placeholder={placeholder}
|
|
@@ -392,24 +272,24 @@ class TextInput extends Component<
|
|
|
392
272
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'layout' does not exist on type 'Readonly... Remove this comment to see the full error message
|
|
393
273
|
layout={this.props.layout} // eslint-disable-line react/prop-types
|
|
394
274
|
>
|
|
395
|
-
<span css={styles
|
|
275
|
+
<span css={styles?.facade}>
|
|
396
276
|
{renderBeforeOrAfter ? (
|
|
397
277
|
<div>
|
|
398
|
-
<span css={styles
|
|
278
|
+
<span css={styles?.layout}>
|
|
399
279
|
{hasBeforeElement && (
|
|
400
|
-
<span css={styles
|
|
280
|
+
<span css={styles?.beforeElement}>
|
|
401
281
|
{callRenderProp(renderBeforeInput)}
|
|
402
282
|
</span>
|
|
403
283
|
)}
|
|
404
|
-
<span css={styles
|
|
284
|
+
<span css={styles?.innerWrapper}>
|
|
405
285
|
{/*
|
|
406
286
|
The input and content after input should not wrap,
|
|
407
287
|
so they're in their own flex container
|
|
408
288
|
*/}
|
|
409
|
-
<span css={styles
|
|
410
|
-
<span css={styles
|
|
289
|
+
<span css={styles?.inputLayout}>
|
|
290
|
+
<span css={styles?.innerWrapper}>{this.renderInput()}</span>
|
|
411
291
|
{hasAfterElement && (
|
|
412
|
-
<span css={styles
|
|
292
|
+
<span css={styles?.afterElement}>
|
|
413
293
|
{callRenderProp(renderAfterInput)}
|
|
414
294
|
</span>
|
|
415
295
|
)}
|
|
@@ -0,0 +1,206 @@
|
|
|
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 React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { FormPropTypes } from '@instructure/ui-form-field'
|
|
29
|
+
import { controllable } from '@instructure/ui-prop-types'
|
|
30
|
+
|
|
31
|
+
import type { InteractionType } from '@instructure/ui-react-utils'
|
|
32
|
+
import type { FormMessage } from '@instructure/ui-form-field'
|
|
33
|
+
import type { PropValidators } from '@instructure/shared-types'
|
|
34
|
+
import type { WithStyleProps } from '@instructure/emotion'
|
|
35
|
+
|
|
36
|
+
type TextInputOwnProps = {
|
|
37
|
+
renderLabel?: React.ReactNode | ((...args: any[]) => any)
|
|
38
|
+
type?: 'text' | 'email' | 'url' | 'tel' | 'search' | 'password'
|
|
39
|
+
id?: string
|
|
40
|
+
value?: any // TODO: controllable(PropTypes.string)
|
|
41
|
+
defaultValue?: string
|
|
42
|
+
interaction?: InteractionType
|
|
43
|
+
messages?: FormMessage[]
|
|
44
|
+
size?: 'small' | 'medium' | 'large'
|
|
45
|
+
textAlign?: 'start' | 'center'
|
|
46
|
+
width?: string
|
|
47
|
+
htmlSize?: string | number
|
|
48
|
+
display?: 'inline-block' | 'block'
|
|
49
|
+
shouldNotWrap?: boolean
|
|
50
|
+
placeholder?: string
|
|
51
|
+
isRequired?: boolean
|
|
52
|
+
inputRef?: (...args: any[]) => any
|
|
53
|
+
inputContainerRef?: (...args: any[]) => any
|
|
54
|
+
renderBeforeInput?: React.ReactNode | ((...args: any[]) => any)
|
|
55
|
+
renderAfterInput?: React.ReactNode | ((...args: any[]) => any)
|
|
56
|
+
onChange?: (...args: any[]) => any
|
|
57
|
+
onBlur?: (...args: any[]) => any
|
|
58
|
+
onFocus?: (...args: any[]) => any
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type PropKeys = keyof TextInputOwnProps
|
|
62
|
+
|
|
63
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
64
|
+
|
|
65
|
+
type TextInputProps = TextInputOwnProps & WithStyleProps
|
|
66
|
+
|
|
67
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
68
|
+
/**
|
|
69
|
+
* The form field label.
|
|
70
|
+
*/
|
|
71
|
+
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
72
|
+
/**
|
|
73
|
+
* Determines the underlying native HTML `<input>` element's `type`.
|
|
74
|
+
* For more see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
|
|
75
|
+
*/
|
|
76
|
+
type: PropTypes.oneOf(['text', 'email', 'url', 'tel', 'search', 'password']),
|
|
77
|
+
/**
|
|
78
|
+
* The id of the text input. One is generated if not supplied.
|
|
79
|
+
*/
|
|
80
|
+
id: PropTypes.string,
|
|
81
|
+
/**
|
|
82
|
+
* the selected value (must be accompanied by an `onChange` prop)
|
|
83
|
+
*/
|
|
84
|
+
value: controllable(PropTypes.string),
|
|
85
|
+
/**
|
|
86
|
+
* value to set on initial render
|
|
87
|
+
*/
|
|
88
|
+
defaultValue: PropTypes.string,
|
|
89
|
+
/**
|
|
90
|
+
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
91
|
+
* When "disabled", the input changes visibly to indicate that it cannot
|
|
92
|
+
* receive user interactions. When "readonly" the input still cannot receive
|
|
93
|
+
* user interactions but it keeps the same styles as if it were enabled.
|
|
94
|
+
*/
|
|
95
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
96
|
+
/**
|
|
97
|
+
* object with shape: `{
|
|
98
|
+
* text: PropTypes.string,
|
|
99
|
+
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
100
|
+
* }`
|
|
101
|
+
*/
|
|
102
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
103
|
+
/**
|
|
104
|
+
* The size of the text input.
|
|
105
|
+
*/
|
|
106
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
107
|
+
/**
|
|
108
|
+
* The text alignment of the input.
|
|
109
|
+
*/
|
|
110
|
+
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
111
|
+
/**
|
|
112
|
+
* The width of the input.
|
|
113
|
+
*/
|
|
114
|
+
width: PropTypes.string,
|
|
115
|
+
/**
|
|
116
|
+
* The width of the input, in characters, if a width is not explicitly
|
|
117
|
+
* provided via the `width` prop. Only applicable if `isInline={true}`.
|
|
118
|
+
*/
|
|
119
|
+
htmlSize: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
120
|
+
/**
|
|
121
|
+
* The display of the root element.
|
|
122
|
+
*/
|
|
123
|
+
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
124
|
+
/**
|
|
125
|
+
* Prevents the default behavior of wrapping the input and rendered content
|
|
126
|
+
* when available space is exceeded.
|
|
127
|
+
*/
|
|
128
|
+
shouldNotWrap: PropTypes.bool,
|
|
129
|
+
/**
|
|
130
|
+
* Html placeholder text to display when the input has no value. This should be hint text, not a label
|
|
131
|
+
* replacement.
|
|
132
|
+
*/
|
|
133
|
+
placeholder: PropTypes.string,
|
|
134
|
+
/**
|
|
135
|
+
* Whether or not the text input is required.
|
|
136
|
+
*/
|
|
137
|
+
isRequired: PropTypes.bool,
|
|
138
|
+
/**
|
|
139
|
+
* a function that provides a reference to the actual input element
|
|
140
|
+
*/
|
|
141
|
+
inputRef: PropTypes.func,
|
|
142
|
+
/**
|
|
143
|
+
* a function that provides a reference a parent of the input element
|
|
144
|
+
*/
|
|
145
|
+
inputContainerRef: PropTypes.func,
|
|
146
|
+
/**
|
|
147
|
+
* Content to display before the input text, such as an icon
|
|
148
|
+
*/
|
|
149
|
+
renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
150
|
+
/**
|
|
151
|
+
* Content to display after the input text, such as an icon
|
|
152
|
+
*/
|
|
153
|
+
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
154
|
+
/**
|
|
155
|
+
* Callback executed when the input fires a change event.
|
|
156
|
+
* @param {Object} event - the event object
|
|
157
|
+
* @param {Object} value - the string value of the input
|
|
158
|
+
*/
|
|
159
|
+
onChange: PropTypes.func,
|
|
160
|
+
/**
|
|
161
|
+
* Callback fired when input loses focus.
|
|
162
|
+
*/
|
|
163
|
+
onBlur: PropTypes.func,
|
|
164
|
+
/**
|
|
165
|
+
* Callback fired when input receives focus.
|
|
166
|
+
*/
|
|
167
|
+
onFocus: PropTypes.func
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const allowedProps: AllowedPropKeys = [
|
|
171
|
+
'renderLabel',
|
|
172
|
+
'type',
|
|
173
|
+
'id',
|
|
174
|
+
'value',
|
|
175
|
+
'defaultValue',
|
|
176
|
+
'interaction',
|
|
177
|
+
'messages',
|
|
178
|
+
'size',
|
|
179
|
+
'textAlign',
|
|
180
|
+
'width',
|
|
181
|
+
'htmlSize',
|
|
182
|
+
'display',
|
|
183
|
+
'shouldNotWrap',
|
|
184
|
+
'placeholder',
|
|
185
|
+
'isRequired',
|
|
186
|
+
'inputRef',
|
|
187
|
+
'inputContainerRef',
|
|
188
|
+
'renderBeforeInput',
|
|
189
|
+
'renderAfterInput',
|
|
190
|
+
'onChange',
|
|
191
|
+
'onBlur',
|
|
192
|
+
'onFocus'
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
type TextInputState = {
|
|
196
|
+
hasFocus: boolean
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type TextInputStyleProps = {
|
|
200
|
+
disabled: boolean
|
|
201
|
+
invalid: boolean
|
|
202
|
+
focused: TextInputState['hasFocus']
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type { TextInputProps, TextInputState, TextInputStyleProps }
|
|
206
|
+
export { propTypes, allowedProps }
|