@instructure/ui-text-input 10.5.0 → 10.5.1-snapshot-1
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 +6 -3
- package/lib/TextInput/index.js +6 -3
- package/package.json +16 -16
- package/src/TextInput/index.tsx +14 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TextInput/index.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
|
+
## [10.5.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.5.0...v10.5.1-snapshot-1) (2024-11-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** fix regression where form elements without label got misaligned ([139f7f1](https://github.com/instructure/instructure-ui/commit/139f7f130cd7e8372af869a13cfd50cd6a97fd85))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [10.5.0](https://github.com/instructure/instructure-ui/compare/v10.4.1...v10.5.0) (2024-11-07)
|
|
7
18
|
|
|
8
19
|
|
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';
|
|
@@ -247,11 +248,13 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
247
248
|
const beforeElement = renderBeforeInput ? callRenderProp(renderBeforeInput) : null;
|
|
248
249
|
const afterElement = renderAfterInput ? callRenderProp(renderAfterInput) : null;
|
|
249
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;
|
|
250
255
|
return jsx(FormField, {
|
|
251
256
|
id: this.id,
|
|
252
|
-
label:
|
|
253
|
-
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
|
|
254
|
-
}, " *")),
|
|
257
|
+
label: label,
|
|
255
258
|
messagesId: this._messagesId,
|
|
256
259
|
messages: messages,
|
|
257
260
|
inline: display === 'inline-block',
|
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");
|
|
@@ -257,11 +258,13 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
257
258
|
const beforeElement = renderBeforeInput ? (0, _callRenderProp.callRenderProp)(renderBeforeInput) : null;
|
|
258
259
|
const afterElement = renderAfterInput ? (0, _callRenderProp.callRenderProp)(renderAfterInput) : null;
|
|
259
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;
|
|
260
265
|
return (0, _emotion.jsx)(_FormField.FormField, {
|
|
261
266
|
id: this.id,
|
|
262
|
-
label:
|
|
263
|
-
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
|
|
264
|
-
}, " *")),
|
|
267
|
+
label: label,
|
|
265
268
|
messagesId: this._messagesId,
|
|
266
269
|
messages: messages,
|
|
267
270
|
inline: display === 'inline-block',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-input",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.1-snapshot-1",
|
|
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.5.
|
|
27
|
-
"@instructure/ui-babel-preset": "10.5.
|
|
28
|
-
"@instructure/ui-badge": "10.5.
|
|
29
|
-
"@instructure/ui-color-utils": "10.5.
|
|
30
|
-
"@instructure/ui-test-utils": "10.5.
|
|
31
|
-
"@instructure/ui-themes": "10.5.
|
|
26
|
+
"@instructure/ui-axe-check": "10.5.1-snapshot-1",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.5.1-snapshot-1",
|
|
28
|
+
"@instructure/ui-badge": "10.5.1-snapshot-1",
|
|
29
|
+
"@instructure/ui-color-utils": "10.5.1-snapshot-1",
|
|
30
|
+
"@instructure/ui-test-utils": "10.5.1-snapshot-1",
|
|
31
|
+
"@instructure/ui-themes": "10.5.1-snapshot-1",
|
|
32
32
|
"@testing-library/jest-dom": "^6.4.6",
|
|
33
33
|
"@testing-library/react": "^16.0.1",
|
|
34
34
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@babel/runtime": "^7.25.6",
|
|
39
|
-
"@instructure/emotion": "10.5.
|
|
40
|
-
"@instructure/shared-types": "10.5.
|
|
41
|
-
"@instructure/ui-dom-utils": "10.5.
|
|
42
|
-
"@instructure/ui-form-field": "10.5.
|
|
43
|
-
"@instructure/ui-icons": "10.5.
|
|
44
|
-
"@instructure/ui-prop-types": "10.5.
|
|
45
|
-
"@instructure/ui-react-utils": "10.5.
|
|
46
|
-
"@instructure/ui-tag": "10.5.
|
|
47
|
-
"@instructure/ui-testable": "10.5.
|
|
39
|
+
"@instructure/emotion": "10.5.1-snapshot-1",
|
|
40
|
+
"@instructure/shared-types": "10.5.1-snapshot-1",
|
|
41
|
+
"@instructure/ui-dom-utils": "10.5.1-snapshot-1",
|
|
42
|
+
"@instructure/ui-form-field": "10.5.1-snapshot-1",
|
|
43
|
+
"@instructure/ui-icons": "10.5.1-snapshot-1",
|
|
44
|
+
"@instructure/ui-prop-types": "10.5.1-snapshot-1",
|
|
45
|
+
"@instructure/ui-react-utils": "10.5.1-snapshot-1",
|
|
46
|
+
"@instructure/ui-tag": "10.5.1-snapshot-1",
|
|
47
|
+
"@instructure/ui-testable": "10.5.1-snapshot-1",
|
|
48
48
|
"prop-types": "^15.8.1"
|
|
49
49
|
},
|
|
50
50
|
"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'
|
|
@@ -327,17 +328,22 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
327
328
|
|
|
328
329
|
const renderBeforeOrAfter = !!beforeElement || !!afterElement
|
|
329
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
|
+
|
|
330
343
|
return (
|
|
331
344
|
<FormField
|
|
332
345
|
id={this.id}
|
|
333
|
-
label={
|
|
334
|
-
<React.Fragment>
|
|
335
|
-
{callRenderProp(renderLabel)}
|
|
336
|
-
{isRequired && (
|
|
337
|
-
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
|
|
338
|
-
)}
|
|
339
|
-
</React.Fragment>
|
|
340
|
-
}
|
|
346
|
+
label={label}
|
|
341
347
|
messagesId={this._messagesId}
|
|
342
348
|
messages={messages}
|
|
343
349
|
inline={display === 'inline-block'}
|