@instructure/ui-number-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 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
 
@@ -30,6 +30,7 @@ import { FormField } from '@instructure/ui-form-field';
30
30
  import { IconArrowOpenDownLine, IconArrowOpenUpLine } from '@instructure/ui-icons';
31
31
  import { testable } from '@instructure/ui-testable';
32
32
  import { omitProps, pickProps, callRenderProp, getInteraction, withDeterministicId } from '@instructure/ui-react-utils';
33
+ import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
33
34
  import { withStyle, jsx } from '@instructure/emotion';
34
35
  import generateStyle from './styles';
35
36
  import generateComponentTheme from './theme';
@@ -179,10 +180,12 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
179
180
  width = _this$props4.width,
180
181
  styles = _this$props4.styles;
181
182
  const interaction = this.interaction;
183
+ const rawLabel = callRenderProp(renderLabel);
184
+ const label = hasVisibleChildren(rawLabel) ? jsx(React.Fragment, null, rawLabel, isRequired && jsx("span", {
185
+ css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
186
+ }, " *")) : rawLabel;
182
187
  return jsx(FormField, Object.assign({}, pickProps(this.props, FormField.allowedProps), {
183
- label: jsx(React.Fragment, null, callRenderProp(renderLabel), isRequired && jsx("span", {
184
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
185
- }, " *")),
188
+ label: label,
186
189
  inline: display === 'inline-block',
187
190
  id: this.id,
188
191
  elementRef: this.handleRef
@@ -17,6 +17,7 @@ var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
17
17
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
18
18
  var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
19
19
  var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
20
+ var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
20
21
  var _emotion = require("@instructure/emotion");
21
22
  var _styles = _interopRequireDefault(require("./styles"));
22
23
  var _theme = _interopRequireDefault(require("./theme"));
@@ -191,10 +192,12 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
191
192
  width = _this$props4.width,
192
193
  styles = _this$props4.styles;
193
194
  const interaction = this.interaction;
195
+ const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
196
+ const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _emotion.jsx)(_react.default.Fragment, null, rawLabel, isRequired && (0, _emotion.jsx)("span", {
197
+ css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
198
+ }, " *")) : rawLabel;
194
199
  return (0, _emotion.jsx)(_FormField.FormField, Object.assign({}, (0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps), {
195
- label: (0, _emotion.jsx)(_react.default.Fragment, null, (0, _callRenderProp.callRenderProp)(renderLabel), isRequired && (0, _emotion.jsx)("span", {
196
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
197
- }, " *")),
200
+ label: label,
198
201
  inline: display === 'inline-block',
199
202
  id: this.id,
200
203
  elementRef: this.handleRef
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-number-input",
3
- "version": "10.5.0",
3
+ "version": "10.5.1-snapshot-1",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "homepage": "https://instructure.github.io/instructure-ui/",
@@ -23,11 +23,11 @@
23
23
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
24
24
  },
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "10.5.0",
27
- "@instructure/ui-babel-preset": "10.5.0",
28
- "@instructure/ui-scripts": "10.5.0",
29
- "@instructure/ui-test-utils": "10.5.0",
30
- "@instructure/ui-themes": "10.5.0",
26
+ "@instructure/ui-axe-check": "10.5.1-snapshot-1",
27
+ "@instructure/ui-babel-preset": "10.5.1-snapshot-1",
28
+ "@instructure/ui-scripts": "10.5.1-snapshot-1",
29
+ "@instructure/ui-test-utils": "10.5.1-snapshot-1",
30
+ "@instructure/ui-themes": "10.5.1-snapshot-1",
31
31
  "@testing-library/jest-dom": "^6.4.6",
32
32
  "@testing-library/react": "^16.0.1",
33
33
  "@testing-library/user-event": "^14.5.2",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/runtime": "^7.25.6",
38
- "@instructure/emotion": "10.5.0",
39
- "@instructure/shared-types": "10.5.0",
40
- "@instructure/ui-form-field": "10.5.0",
41
- "@instructure/ui-icons": "10.5.0",
42
- "@instructure/ui-react-utils": "10.5.0",
43
- "@instructure/ui-testable": "10.5.0",
44
- "@instructure/ui-utils": "10.5.0",
45
- "@instructure/uid": "10.5.0",
38
+ "@instructure/emotion": "10.5.1-snapshot-1",
39
+ "@instructure/shared-types": "10.5.1-snapshot-1",
40
+ "@instructure/ui-form-field": "10.5.1-snapshot-1",
41
+ "@instructure/ui-icons": "10.5.1-snapshot-1",
42
+ "@instructure/ui-react-utils": "10.5.1-snapshot-1",
43
+ "@instructure/ui-testable": "10.5.1-snapshot-1",
44
+ "@instructure/ui-utils": "10.5.1-snapshot-1",
45
+ "@instructure/uid": "10.5.1-snapshot-1",
46
46
  "keycode": "^2",
47
47
  "prop-types": "^15.8.1"
48
48
  },
@@ -39,6 +39,7 @@ import {
39
39
  getInteraction,
40
40
  withDeterministicId
41
41
  } from '@instructure/ui-react-utils'
42
+ import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
42
43
 
43
44
  import { withStyle, jsx } from '@instructure/emotion'
44
45
 
@@ -101,7 +102,9 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
101
102
  get invalid() {
102
103
  return (
103
104
  !!this.props.messages &&
104
- this.props.messages.some((message) => message.type === 'error' || message.type === 'newError')
105
+ this.props.messages.some(
106
+ (message) => message.type === 'error' || message.type === 'newError'
107
+ )
105
108
  )
106
109
  }
107
110
 
@@ -238,17 +241,22 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
238
241
 
239
242
  const { interaction } = this
240
243
 
244
+ const rawLabel = callRenderProp(renderLabel)
245
+ const label = hasVisibleChildren(rawLabel) ? (
246
+ <React.Fragment>
247
+ {rawLabel}
248
+ {isRequired && (
249
+ <span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
250
+ )}
251
+ </React.Fragment>
252
+ ) : (
253
+ rawLabel
254
+ )
255
+
241
256
  return (
242
257
  <FormField
243
258
  {...pickProps(this.props, FormField.allowedProps)}
244
- label={
245
- <React.Fragment>
246
- {callRenderProp(renderLabel)}
247
- {isRequired && (
248
- <span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
249
- )}
250
- </React.Fragment>
251
- }
259
+ label={label}
252
260
  inline={display === 'inline-block'}
253
261
  id={this.id}
254
262
  elementRef={this.handleRef}
@@ -64,7 +64,7 @@ type NumberInputOwnProps = {
64
64
  /**
65
65
  * Array of objects with shape: `{
66
66
  * text: ReactNode,
67
- * type: One of: ['error', 'hint', 'success', 'screenreader-only']
67
+ * type: One of: ['newError', 'error', 'hint', 'success', 'screenreader-only']
68
68
  * }`
69
69
  */
70
70
  messages?: FormMessage[]