@instructure/ui-text-input 9.8.1 → 9.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 +11 -0
- package/es/TextInput/index.js +8 -2
- package/es/TextInput/styles.js +5 -0
- package/es/TextInput/theme.js +1 -0
- package/lib/TextInput/index.js +8 -2
- package/lib/TextInput/styles.js +5 -0
- package/lib/TextInput/theme.js +1 -0
- package/package.json +16 -15
- package/src/TextInput/index.tsx +16 -2
- package/src/TextInput/props.ts +1 -0
- package/src/TextInput/styles.ts +5 -0
- package/src/TextInput/theme.ts +2 -0
- package/tsconfig.build.json +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TextInput/index.d.ts.map +1 -1
- package/types/TextInput/props.d.ts +1 -1
- package/types/TextInput/props.d.ts.map +1 -1
- package/types/TextInput/styles.d.ts.map +1 -1
- package/types/TextInput/theme.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# [9.9.0](https://github.com/instructure/instructure-ui/compare/v9.8.1...v9.9.0) (2024-11-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **many:** backport new error messages from v10 ([9003d19](https://github.com/instructure/instructure-ui/commit/9003d19cc66022dfdeecc2e2c8c8d9d2a7300e3f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [9.8.1](https://github.com/instructure/instructure-ui/compare/v9.8.0...v9.8.1) (2024-10-28)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @instructure/ui-text-input
|
package/es/TextInput/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import { isActiveElement, addEventListener } from '@instructure/ui-dom-utils';
|
|
|
32
32
|
import { FormField } from '@instructure/ui-form-field';
|
|
33
33
|
import { testable } from '@instructure/ui-testable';
|
|
34
34
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
35
|
+
import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
35
36
|
import generateStyle from './styles';
|
|
36
37
|
import generateComponentTheme from './theme';
|
|
37
38
|
import { allowedProps, propTypes } from './props';
|
|
@@ -161,7 +162,7 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
161
162
|
}
|
|
162
163
|
get invalid() {
|
|
163
164
|
return !!this.props.messages && this.props.messages.findIndex(message => {
|
|
164
|
-
return message.type === 'error';
|
|
165
|
+
return message.type === 'error' || message.type === 'newError';
|
|
165
166
|
}) >= 0;
|
|
166
167
|
}
|
|
167
168
|
get focused() {
|
|
@@ -242,13 +243,18 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
242
243
|
renderAfterInput = _this$props4.renderAfterInput,
|
|
243
244
|
messages = _this$props4.messages,
|
|
244
245
|
inputContainerRef = _this$props4.inputContainerRef,
|
|
246
|
+
isRequired = _this$props4.isRequired,
|
|
245
247
|
styles = _this$props4.styles;
|
|
246
248
|
const beforeElement = renderBeforeInput ? callRenderProp(renderBeforeInput) : null;
|
|
247
249
|
const afterElement = renderAfterInput ? callRenderProp(renderAfterInput) : null;
|
|
248
250
|
const renderBeforeOrAfter = !!beforeElement || !!afterElement;
|
|
251
|
+
const rawLabel = callRenderProp(renderLabel);
|
|
252
|
+
const label = hasVisibleChildren(rawLabel) ? jsx(React.Fragment, null, rawLabel, isRequired && jsx("span", {
|
|
253
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
|
|
254
|
+
}, " *")) : rawLabel;
|
|
249
255
|
return jsx(FormField, {
|
|
250
256
|
id: this.id,
|
|
251
|
-
label:
|
|
257
|
+
label: label,
|
|
252
258
|
messagesId: this._messagesId,
|
|
253
259
|
messages: messages,
|
|
254
260
|
inline: display === 'inline-block',
|
package/es/TextInput/styles.js
CHANGED
|
@@ -127,6 +127,9 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
127
127
|
flexShrink: 0
|
|
128
128
|
};
|
|
129
129
|
return {
|
|
130
|
+
requiredInvalid: {
|
|
131
|
+
color: componentTheme.requiredInvalidColor
|
|
132
|
+
},
|
|
130
133
|
textInput: {
|
|
131
134
|
label: 'textInput',
|
|
132
135
|
...inputStyle,
|
|
@@ -170,6 +173,8 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
170
173
|
})
|
|
171
174
|
},
|
|
172
175
|
beforeElement: {
|
|
176
|
+
display: 'inline-flex',
|
|
177
|
+
alignItems: 'center',
|
|
173
178
|
label: 'textInput__beforeElement',
|
|
174
179
|
...flexItemBase,
|
|
175
180
|
paddingInlineStart: componentTheme.padding,
|
package/es/TextInput/theme.js
CHANGED
|
@@ -50,6 +50,7 @@ const generateComponentTheme = theme => {
|
|
|
50
50
|
color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
51
51
|
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
52
52
|
padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
53
|
+
requiredInvalidColor: colors === null || colors === void 0 ? void 0 : colors.textDanger,
|
|
53
54
|
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
54
55
|
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
55
56
|
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
package/lib/TextInput/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.
|
|
|
17
17
|
var _FormField = require("@instructure/ui-form-field/lib/FormField");
|
|
18
18
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
19
19
|
var _emotion = require("@instructure/emotion");
|
|
20
|
+
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
20
21
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
21
22
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
22
23
|
var _props = require("./props");
|
|
@@ -171,7 +172,7 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
171
172
|
}
|
|
172
173
|
get invalid() {
|
|
173
174
|
return !!this.props.messages && this.props.messages.findIndex(message => {
|
|
174
|
-
return message.type === 'error';
|
|
175
|
+
return message.type === 'error' || message.type === 'newError';
|
|
175
176
|
}) >= 0;
|
|
176
177
|
}
|
|
177
178
|
get focused() {
|
|
@@ -252,13 +253,18 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
252
253
|
renderAfterInput = _this$props4.renderAfterInput,
|
|
253
254
|
messages = _this$props4.messages,
|
|
254
255
|
inputContainerRef = _this$props4.inputContainerRef,
|
|
256
|
+
isRequired = _this$props4.isRequired,
|
|
255
257
|
styles = _this$props4.styles;
|
|
256
258
|
const beforeElement = renderBeforeInput ? (0, _callRenderProp.callRenderProp)(renderBeforeInput) : null;
|
|
257
259
|
const afterElement = renderAfterInput ? (0, _callRenderProp.callRenderProp)(renderAfterInput) : null;
|
|
258
260
|
const renderBeforeOrAfter = !!beforeElement || !!afterElement;
|
|
261
|
+
const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
262
|
+
const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _emotion.jsx)(_react.default.Fragment, null, rawLabel, isRequired && (0, _emotion.jsx)("span", {
|
|
263
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
|
|
264
|
+
}, " *")) : rawLabel;
|
|
259
265
|
return (0, _emotion.jsx)(_FormField.FormField, {
|
|
260
266
|
id: this.id,
|
|
261
|
-
label:
|
|
267
|
+
label: label,
|
|
262
268
|
messagesId: this._messagesId,
|
|
263
269
|
messages: messages,
|
|
264
270
|
inline: display === 'inline-block',
|
package/lib/TextInput/styles.js
CHANGED
|
@@ -133,6 +133,9 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
133
133
|
flexShrink: 0
|
|
134
134
|
};
|
|
135
135
|
return {
|
|
136
|
+
requiredInvalid: {
|
|
137
|
+
color: componentTheme.requiredInvalidColor
|
|
138
|
+
},
|
|
136
139
|
textInput: {
|
|
137
140
|
label: 'textInput',
|
|
138
141
|
...inputStyle,
|
|
@@ -176,6 +179,8 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
176
179
|
})
|
|
177
180
|
},
|
|
178
181
|
beforeElement: {
|
|
182
|
+
display: 'inline-flex',
|
|
183
|
+
alignItems: 'center',
|
|
179
184
|
label: 'textInput__beforeElement',
|
|
180
185
|
...flexItemBase,
|
|
181
186
|
paddingInlineStart: componentTheme.padding,
|
package/lib/TextInput/theme.js
CHANGED
|
@@ -56,6 +56,7 @@ const generateComponentTheme = theme => {
|
|
|
56
56
|
color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
57
57
|
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
58
58
|
padding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
59
|
+
requiredInvalidColor: colors === null || colors === void 0 ? void 0 : colors.textDanger,
|
|
59
60
|
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
60
61
|
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
61
62
|
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-input",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.0",
|
|
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,24 +23,25 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "9.
|
|
27
|
-
"@instructure/ui-badge": "9.
|
|
28
|
-
"@instructure/ui-color-utils": "9.
|
|
29
|
-
"@instructure/ui-test-utils": "9.
|
|
30
|
-
"@instructure/ui-themes": "9.
|
|
26
|
+
"@instructure/ui-babel-preset": "9.9.0",
|
|
27
|
+
"@instructure/ui-badge": "9.9.0",
|
|
28
|
+
"@instructure/ui-color-utils": "9.9.0",
|
|
29
|
+
"@instructure/ui-test-utils": "9.9.0",
|
|
30
|
+
"@instructure/ui-themes": "9.9.0",
|
|
31
31
|
"react-dom": "^18.3.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.24.5",
|
|
35
|
-
"@instructure/emotion": "9.
|
|
36
|
-
"@instructure/shared-types": "9.
|
|
37
|
-
"@instructure/ui-
|
|
38
|
-
"@instructure/ui-
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-
|
|
42
|
-
"@instructure/ui-
|
|
43
|
-
"@instructure/ui-
|
|
35
|
+
"@instructure/emotion": "9.9.0",
|
|
36
|
+
"@instructure/shared-types": "9.9.0",
|
|
37
|
+
"@instructure/ui-a11y-utils": "9.9.0",
|
|
38
|
+
"@instructure/ui-dom-utils": "9.9.0",
|
|
39
|
+
"@instructure/ui-form-field": "9.9.0",
|
|
40
|
+
"@instructure/ui-icons": "9.9.0",
|
|
41
|
+
"@instructure/ui-prop-types": "9.9.0",
|
|
42
|
+
"@instructure/ui-react-utils": "9.9.0",
|
|
43
|
+
"@instructure/ui-tag": "9.9.0",
|
|
44
|
+
"@instructure/ui-testable": "9.9.0",
|
|
44
45
|
"prop-types": "^15.8.1"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
package/src/TextInput/index.tsx
CHANGED
|
@@ -35,6 +35,7 @@ import { isActiveElement, addEventListener } from '@instructure/ui-dom-utils'
|
|
|
35
35
|
import { FormField } from '@instructure/ui-form-field'
|
|
36
36
|
import { testable } from '@instructure/ui-testable'
|
|
37
37
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
38
|
+
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
38
39
|
|
|
39
40
|
import generateStyle from './styles'
|
|
40
41
|
import generateComponentTheme from './theme'
|
|
@@ -179,7 +180,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
179
180
|
return (
|
|
180
181
|
!!this.props.messages &&
|
|
181
182
|
this.props.messages.findIndex((message) => {
|
|
182
|
-
return message.type === 'error'
|
|
183
|
+
return message.type === 'error' || message.type === 'newError'
|
|
183
184
|
}) >= 0
|
|
184
185
|
)
|
|
185
186
|
}
|
|
@@ -314,6 +315,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
314
315
|
renderAfterInput,
|
|
315
316
|
messages,
|
|
316
317
|
inputContainerRef,
|
|
318
|
+
isRequired,
|
|
317
319
|
styles
|
|
318
320
|
} = this.props
|
|
319
321
|
|
|
@@ -326,10 +328,22 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
326
328
|
|
|
327
329
|
const renderBeforeOrAfter = !!beforeElement || !!afterElement
|
|
328
330
|
|
|
331
|
+
const rawLabel = callRenderProp(renderLabel)
|
|
332
|
+
const label = hasVisibleChildren(rawLabel) ? (
|
|
333
|
+
<React.Fragment>
|
|
334
|
+
{rawLabel}
|
|
335
|
+
{isRequired && (
|
|
336
|
+
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
|
|
337
|
+
)}
|
|
338
|
+
</React.Fragment>
|
|
339
|
+
) : (
|
|
340
|
+
rawLabel
|
|
341
|
+
)
|
|
342
|
+
|
|
329
343
|
return (
|
|
330
344
|
<FormField
|
|
331
345
|
id={this.id}
|
|
332
|
-
label={
|
|
346
|
+
label={label}
|
|
333
347
|
messagesId={this._messagesId}
|
|
334
348
|
messages={messages}
|
|
335
349
|
inline={display === 'inline-block'}
|
package/src/TextInput/props.ts
CHANGED
package/src/TextInput/styles.ts
CHANGED
|
@@ -157,6 +157,9 @@ const generateStyle = (
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
return {
|
|
160
|
+
requiredInvalid: {
|
|
161
|
+
color: componentTheme.requiredInvalidColor
|
|
162
|
+
},
|
|
160
163
|
textInput: {
|
|
161
164
|
label: 'textInput',
|
|
162
165
|
...inputStyle,
|
|
@@ -199,6 +202,8 @@ const generateStyle = (
|
|
|
199
202
|
...(!shouldNotWrap && { flexWrap: 'wrap' })
|
|
200
203
|
},
|
|
201
204
|
beforeElement: {
|
|
205
|
+
display: 'inline-flex',
|
|
206
|
+
alignItems: 'center',
|
|
202
207
|
label: 'textInput__beforeElement',
|
|
203
208
|
...flexItemBase,
|
|
204
209
|
paddingInlineStart: componentTheme.padding,
|
package/src/TextInput/theme.ts
CHANGED
|
@@ -54,6 +54,8 @@ const generateComponentTheme = (theme: Theme): TextInputTheme => {
|
|
|
54
54
|
|
|
55
55
|
padding: spacing?.small,
|
|
56
56
|
|
|
57
|
+
requiredInvalidColor: colors?.textDanger,
|
|
58
|
+
|
|
57
59
|
focusOutlineWidth: borders?.widthMedium,
|
|
58
60
|
focusOutlineStyle: borders?.style,
|
|
59
61
|
focusOutlineColor: colors?.borderBrand,
|
package/tsconfig.build.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
{ "path": "../ui-icons/tsconfig.build.json" },
|
|
20
20
|
{ "path": "../ui-prop-types/tsconfig.build.json" },
|
|
21
21
|
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
22
|
+
{ "path": "../ui-a11y-utils/tsconfig.build.json" },
|
|
22
23
|
{ "path": "../ui-tag/tsconfig.build.json" },
|
|
23
24
|
{ "path": "../ui-testable/tsconfig.build.json" }
|
|
24
25
|
]
|