@instructure/ui-text-input 10.2.2-snapshot-2 → 10.2.2-snapshot-5

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [10.2.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.2.1...v10.2.2-snapshot-2) (2024-09-03)
6
+ ## [10.2.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v10.2.1...v10.2.2-snapshot-5) (2024-09-10)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-text-input
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-text-input",
3
- "version": "10.2.2-snapshot-2",
3
+ "version": "10.2.2-snapshot-5",
4
4
  "description": "A styled HTML text input component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "10.2.2-snapshot-2",
27
- "@instructure/ui-babel-preset": "10.2.2-snapshot-2",
28
- "@instructure/ui-badge": "10.2.2-snapshot-2",
29
- "@instructure/ui-color-utils": "10.2.2-snapshot-2",
30
- "@instructure/ui-test-utils": "10.2.2-snapshot-2",
31
- "@instructure/ui-themes": "10.2.2-snapshot-2",
26
+ "@instructure/ui-axe-check": "10.2.2-snapshot-5",
27
+ "@instructure/ui-babel-preset": "10.2.2-snapshot-5",
28
+ "@instructure/ui-badge": "10.2.2-snapshot-5",
29
+ "@instructure/ui-color-utils": "10.2.2-snapshot-5",
30
+ "@instructure/ui-test-utils": "10.2.2-snapshot-5",
31
+ "@instructure/ui-themes": "10.2.2-snapshot-5",
32
32
  "@testing-library/jest-dom": "^6.4.6",
33
33
  "@testing-library/react": "^15.0.7",
34
34
  "@testing-library/user-event": "^14.5.2",
@@ -36,15 +36,15 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.24.5",
39
- "@instructure/emotion": "10.2.2-snapshot-2",
40
- "@instructure/shared-types": "10.2.2-snapshot-2",
41
- "@instructure/ui-dom-utils": "10.2.2-snapshot-2",
42
- "@instructure/ui-form-field": "10.2.2-snapshot-2",
43
- "@instructure/ui-icons": "10.2.2-snapshot-2",
44
- "@instructure/ui-prop-types": "10.2.2-snapshot-2",
45
- "@instructure/ui-react-utils": "10.2.2-snapshot-2",
46
- "@instructure/ui-tag": "10.2.2-snapshot-2",
47
- "@instructure/ui-testable": "10.2.2-snapshot-2",
39
+ "@instructure/emotion": "10.2.2-snapshot-5",
40
+ "@instructure/shared-types": "10.2.2-snapshot-5",
41
+ "@instructure/ui-dom-utils": "10.2.2-snapshot-5",
42
+ "@instructure/ui-form-field": "10.2.2-snapshot-5",
43
+ "@instructure/ui-icons": "10.2.2-snapshot-5",
44
+ "@instructure/ui-prop-types": "10.2.2-snapshot-5",
45
+ "@instructure/ui-react-utils": "10.2.2-snapshot-5",
46
+ "@instructure/ui-tag": "10.2.2-snapshot-5",
47
+ "@instructure/ui-testable": "10.2.2-snapshot-5",
48
48
  "prop-types": "^15.8.1"
49
49
  },
50
50
  "peerDependencies": {
@@ -19,41 +19,120 @@ type: example
19
19
 
20
20
  #### Controlled TextInput
21
21
 
22
- ```javascript
23
- ---
24
- type: example
25
- ---
26
- class ControlledTextInputExample extends React.Component {
27
- constructor (props) {
28
- super(props)
29
-
30
- this.state = {
31
- value: 'Supertramp',
32
- disabled: false,
33
- readOnly: false,
34
- inline: false,
35
- messages: null
36
- }
37
- }
22
+ - ```javascript
23
+ class ControlledTextInputExample extends React.Component {
24
+ constructor(props) {
25
+ super(props)
38
26
 
39
- handleChange = (e, value) => this.setState({
40
- value,
41
- messages: null
42
- })
27
+ this.state = {
28
+ value: 'Supertramp',
29
+ disabled: false,
30
+ readOnly: false,
31
+ inline: false,
32
+ messages: null
33
+ }
34
+ }
43
35
 
44
- handleBlur = (e) => {
45
- if (this.state.value === 'Supertramp') {
36
+ handleChange = (e, value) =>
46
37
  this.setState({
47
- messages: [{ text: `Come on. There's no way your favorite band is really Supertramp.`, type: 'error' }]
38
+ value,
39
+ messages: null
48
40
  })
41
+
42
+ handleBlur = (e) => {
43
+ if (this.state.value === 'Supertramp') {
44
+ this.setState({
45
+ messages: [
46
+ {
47
+ text: `Come on. There's no way your favorite band is really Supertramp.`,
48
+ type: 'error'
49
+ }
50
+ ]
51
+ })
52
+ }
53
+ }
54
+
55
+ toggleDisabled = (e) => this.setState({ disabled: !this.state.disabled })
56
+ toggleReadOnly = (e) => this.setState({ readOnly: !this.state.readOnly })
57
+ toggleInline = (e) => this.setState({ inline: !this.state.inline })
58
+
59
+ render() {
60
+ return (
61
+ <div>
62
+ <FormFieldGroup
63
+ description="Controlled TextInput state"
64
+ layout="columns"
65
+ >
66
+ <Checkbox
67
+ checked={this.state.disabled}
68
+ label="disabled"
69
+ onChange={this.toggleDisabled}
70
+ />
71
+ <Checkbox
72
+ checked={this.state.readOnly}
73
+ label="readOnly"
74
+ onChange={this.toggleReadOnly}
75
+ />
76
+ <Checkbox
77
+ checked={this.state.inline}
78
+ label="inline display"
79
+ onChange={this.toggleInline}
80
+ />
81
+ </FormFieldGroup>
82
+ <View display="block" margin="medium 0 0">
83
+ <TextInput
84
+ renderLabel="What is your favorite band?"
85
+ display={this.state.inline ? 'inline-block' : null}
86
+ value={this.state.value}
87
+ onChange={this.handleChange}
88
+ onBlur={this.handleBlur}
89
+ interaction={
90
+ this.state.disabled
91
+ ? 'disabled'
92
+ : this.state.readOnly
93
+ ? 'readonly'
94
+ : 'enabled'
95
+ }
96
+ messages={this.state.messages}
97
+ renderAfterInput={<SVGIcon src={iconExample} />}
98
+ />
99
+ </View>
100
+ </div>
101
+ )
49
102
  }
50
103
  }
51
104
 
52
- toggleDisabled = (e) => this.setState(({ disabled: !this.state.disabled }))
53
- toggleReadOnly = (e) => this.setState(({ readOnly: !this.state.readOnly }))
54
- toggleInline = (e) => this.setState(({ inline: !this.state.inline }))
105
+ render(<ControlledTextInputExample />)
106
+ ```
107
+
108
+ - ```javascript
109
+ const ControlledTextInputExample = () => {
110
+ const [value, setValue] = useState('Supertramp')
111
+ const [disabled, setDisabled] = useState(false)
112
+ const [readOnly, setReadOnly] = useState(false)
113
+ const [inline, setInline] = useState(false)
114
+ const [messages, setMessages] = useState(null)
115
+
116
+ const handleChange = (e, value) => {
117
+ setValue(value)
118
+ setMessages(null)
119
+ }
120
+
121
+ const handleBlur = (e) => {
122
+ if (value === 'Supertramp') {
123
+ setMessages([
124
+ {
125
+ text: "Come on. There's no way your favorite band is really Supertramp.",
126
+ type: 'error'
127
+ }
128
+ ])
129
+ }
130
+ }
131
+
132
+ const toggleDisabled = () => setDisabled((prev) => !prev)
133
+ const toggleReadOnly = () => setReadOnly((prev) => !prev)
134
+ const toggleInline = () => setInline((prev) => !prev)
55
135
 
56
- render () {
57
136
  return (
58
137
  <div>
59
138
  <FormFieldGroup
@@ -61,43 +140,41 @@ class ControlledTextInputExample extends React.Component {
61
140
  layout="columns"
62
141
  >
63
142
  <Checkbox
64
- checked={this.state.disabled}
143
+ checked={disabled}
65
144
  label="disabled"
66
- onChange={this.toggleDisabled}
145
+ onChange={toggleDisabled}
67
146
  />
68
147
  <Checkbox
69
- checked={this.state.readOnly}
148
+ checked={readOnly}
70
149
  label="readOnly"
71
- onChange={this.toggleReadOnly}
150
+ onChange={toggleReadOnly}
72
151
  />
73
152
  <Checkbox
74
- checked={this.state.inline}
153
+ checked={inline}
75
154
  label="inline display"
76
- onChange={this.toggleInline}
155
+ onChange={toggleInline}
77
156
  />
78
157
  </FormFieldGroup>
79
158
  <View display="block" margin="medium 0 0">
80
159
  <TextInput
81
160
  renderLabel="What is your favorite band?"
82
- display={this.state.inline ? 'inline-block' : null}
83
- value={this.state.value}
84
- onChange={this.handleChange}
85
- onBlur={this.handleBlur}
86
- interaction={this.state.disabled
87
- ? 'disabled'
88
- : this.state.readOnly ? 'readonly' : 'enabled'
161
+ display={inline ? 'inline-block' : null}
162
+ value={value}
163
+ onChange={handleChange}
164
+ onBlur={handleBlur}
165
+ interaction={
166
+ disabled ? 'disabled' : readOnly ? 'readonly' : 'enabled'
89
167
  }
90
- messages={this.state.messages}
168
+ messages={messages}
91
169
  renderAfterInput={<SVGIcon src={iconExample} />}
92
170
  />
93
171
  </View>
94
172
  </div>
95
173
  )
96
174
  }
97
- }
98
175
 
99
- render(<ControlledTextInputExample />)
100
- ```
176
+ render(<ControlledTextInputExample />)
177
+ ```
101
178
 
102
179
  ### Prepending and appending content
103
180
 
@@ -108,79 +185,121 @@ Focusable content will be focused separately from the input itself.
108
185
  > Note: For any content larger than an icon or small avatar (multiple [Tags](#Tag), for example),
109
186
  > use the `renderBeforeInput` property.
110
187
 
111
- ```javascript
112
- ---
113
- type: example
114
- ---
115
- class ExtraContentExample extends React.Component {
116
- constructor (props) {
117
- super(props)
188
+ - ```javascript
189
+ class ExtraContentExample extends React.Component {
190
+ constructor(props) {
191
+ super(props)
118
192
 
119
- this.state = {
120
- value: ''
193
+ this.state = {
194
+ value: ''
195
+ }
196
+ }
197
+
198
+ handleChange = (e, value) => this.setState({ value })
199
+
200
+ render() {
201
+ return (
202
+ <View as="div">
203
+ <TextInput
204
+ renderLabel="What are Paula Panda's favorite ice cream flavors?"
205
+ value={this.state.value}
206
+ onChange={this.handleChange}
207
+ renderBeforeInput={
208
+ <View display="block" padding="xxx-small 0">
209
+ {this.state.value !== '' && (
210
+ <Tag
211
+ text={this.state.value}
212
+ margin="xxx-small xxx-small xxx-small none"
213
+ onClick={() => console.log(this.state.value)}
214
+ />
215
+ )}
216
+ <Tag
217
+ text="Rocky road"
218
+ margin="xxx-small xxx-small xxx-small none"
219
+ onClick={() => console.log('Rocky road')}
220
+ />
221
+ <Tag
222
+ text="Vanilla"
223
+ margin="xxx-small xxx-small xxx-small none"
224
+ onClick={() => console.log('Vanilla')}
225
+ />
226
+ <Tag
227
+ text="Coffee"
228
+ margin="xxx-small xxx-small xxx-small none"
229
+ onClick={() => console.log('Coffee')}
230
+ />
231
+ <Tag
232
+ text="Strawberry"
233
+ margin="xxx-small xxx-small xxx-small none"
234
+ onClick={() => console.log('Strawberry')}
235
+ />
236
+ </View>
237
+ }
238
+ renderAfterInput={() => (
239
+ <Avatar name="Paula Panda" src={avatarSquare} size="x-small" />
240
+ )}
241
+ />
242
+ </View>
243
+ )
121
244
  }
122
245
  }
123
246
 
124
- handleChange = (e, value) => this.setState({ value })
247
+ render(<ExtraContentExample />)
248
+ ```
249
+
250
+ - ```javascript
251
+ const ExtraContentExample = () => {
252
+ const [value, setValue] = useState('')
253
+
254
+ const handleChange = (e, value) => setValue(value)
125
255
 
126
- render () {
127
256
  return (
128
257
  <View as="div">
129
258
  <TextInput
130
259
  renderLabel="What are Paula Panda's favorite ice cream flavors?"
131
- value={this.state.value}
132
- onChange={this.handleChange}
260
+ value={value}
261
+ onChange={handleChange}
133
262
  renderBeforeInput={
134
263
  <View display="block" padding="xxx-small 0">
135
- {
136
- (this.state.value !== '') &&
264
+ {value !== '' && (
137
265
  <Tag
138
- text={this.state.value}
266
+ text={value}
139
267
  margin="xxx-small xxx-small xxx-small none"
140
- onClick={function () {
141
- console.log(this.state.value)
142
- }}
268
+ onClick={() => console.log(value)}
143
269
  />
144
- }
270
+ )}
145
271
  <Tag
146
272
  text="Rocky road"
147
273
  margin="xxx-small xxx-small xxx-small none"
148
- onClick={function () {
149
- console.log('Rocky road')
150
- }}
274
+ onClick={() => console.log('Rocky road')}
151
275
  />
152
276
  <Tag
153
277
  text="Vanilla"
154
278
  margin="xxx-small xxx-small xxx-small none"
155
- onClick={function () {
156
- console.log('Vanilla')
157
- }}
279
+ onClick={() => console.log('Vanilla')}
158
280
  />
159
281
  <Tag
160
282
  text="Coffee"
161
283
  margin="xxx-small xxx-small xxx-small none"
162
- onClick={function () {
163
- console.log('Coffee')
164
- }}
284
+ onClick={() => console.log('Coffee')}
165
285
  />
166
286
  <Tag
167
287
  text="Strawberry"
168
288
  margin="xxx-small xxx-small xxx-small none"
169
- onClick={function () {
170
- console.log('Strawberry')
171
- }}
289
+ onClick={() => console.log('Strawberry')}
172
290
  />
173
291
  </View>
174
292
  }
175
- renderAfterInput={() => <Avatar name="Paula Panda" src={avatarSquare} size="x-small" />}
293
+ renderAfterInput={() => (
294
+ <Avatar name="Paula Panda" src={avatarSquare} size="x-small" />
295
+ )}
176
296
  />
177
297
  </View>
178
298
  )
179
299
  }
180
- }
181
300
 
182
- render(<ExtraContentExample />)
183
- ```
301
+ render(<ExtraContentExample />)
302
+ ```
184
303
 
185
304
  ### Setting width and display
186
305