@instructure/ui-number-input 9.8.1 → 9.9.1-pr-snapshot-1731682046909
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 +22 -0
- package/es/NumberInput/index.js +9 -3
- package/es/NumberInput/styles.js +3 -0
- package/es/NumberInput/theme.js +1 -0
- package/lib/NumberInput/index.js +9 -3
- package/lib/NumberInput/styles.js +3 -0
- package/lib/NumberInput/theme.js +1 -0
- package/package.json +16 -15
- package/src/NumberInput/index.tsx +19 -3
- package/src/NumberInput/props.ts +2 -1
- package/src/NumberInput/styles.ts +3 -0
- package/src/NumberInput/theme.ts +2 -0
- package/tsconfig.build.json +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/NumberInput/index.d.ts.map +1 -1
- package/types/NumberInput/props.d.ts +2 -2
- package/types/NumberInput/props.d.ts.map +1 -1
- package/types/NumberInput/styles.d.ts.map +1 -1
- package/types/NumberInput/theme.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.1-pr-snapshot-1731682046909](https://github.com/instructure/instructure-ui/compare/v9.9.0...v9.9.1-pr-snapshot-1731682046909) (2024-11-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-number-input:** fix regression and allow string type for NumberInput again ([4bae58d](https://github.com/instructure/instructure-ui/commit/4bae58d9aa0c6b05a47bf08720eed09334d88dcc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [9.9.0](https://github.com/instructure/instructure-ui/compare/v9.8.1...v9.9.0) (2024-11-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **many:** backport new error messages from v10 ([9003d19](https://github.com/instructure/instructure-ui/commit/9003d19cc66022dfdeecc2e2c8c8d9d2a7300e3f))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [9.8.1](https://github.com/instructure/instructure-ui/compare/v9.8.0...v9.8.1) (2024-10-28)
|
|
7
29
|
|
|
8
30
|
|
package/es/NumberInput/index.js
CHANGED
|
@@ -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';
|
|
@@ -116,7 +117,7 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
|
|
|
116
117
|
return this._id;
|
|
117
118
|
}
|
|
118
119
|
get invalid() {
|
|
119
|
-
return !!this.props.messages && this.props.messages.some(message => message.type === 'error');
|
|
120
|
+
return !!this.props.messages && this.props.messages.some(message => message.type === 'error' || message.type === 'newError');
|
|
120
121
|
}
|
|
121
122
|
get interaction() {
|
|
122
123
|
return getInteraction({
|
|
@@ -177,10 +178,15 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
|
|
|
177
178
|
showArrows = _this$props4.showArrows,
|
|
178
179
|
value = _this$props4.value,
|
|
179
180
|
width = _this$props4.width,
|
|
180
|
-
allowStringValue = _this$props4.allowStringValue
|
|
181
|
+
allowStringValue = _this$props4.allowStringValue,
|
|
182
|
+
styles = _this$props4.styles;
|
|
181
183
|
const interaction = this.interaction;
|
|
184
|
+
const rawLabel = callRenderProp(renderLabel);
|
|
185
|
+
const label = hasVisibleChildren(rawLabel) ? jsx(React.Fragment, null, rawLabel, isRequired && jsx("span", {
|
|
186
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
|
|
187
|
+
}, " *")) : rawLabel;
|
|
182
188
|
return jsx(FormField, Object.assign({}, pickProps(this.props, FormField.allowedProps), {
|
|
183
|
-
label:
|
|
189
|
+
label: label,
|
|
184
190
|
inline: display === 'inline-block',
|
|
185
191
|
id: this.id,
|
|
186
192
|
elementRef: this.handleRef
|
package/es/NumberInput/styles.js
CHANGED
package/es/NumberInput/theme.js
CHANGED
|
@@ -50,6 +50,7 @@ const generateComponentTheme = theme => {
|
|
|
50
50
|
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
51
51
|
color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
52
52
|
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
53
|
+
requiredInvalidColor: colors === null || colors === void 0 ? void 0 : colors.textDanger,
|
|
53
54
|
padding: `0 ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`,
|
|
54
55
|
arrowsContainerWidth: '2rem',
|
|
55
56
|
arrowsColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
package/lib/NumberInput/index.js
CHANGED
|
@@ -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"));
|
|
@@ -128,7 +129,7 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
|
|
|
128
129
|
return this._id;
|
|
129
130
|
}
|
|
130
131
|
get invalid() {
|
|
131
|
-
return !!this.props.messages && this.props.messages.some(message => message.type === 'error');
|
|
132
|
+
return !!this.props.messages && this.props.messages.some(message => message.type === 'error' || message.type === 'newError');
|
|
132
133
|
}
|
|
133
134
|
get interaction() {
|
|
134
135
|
return (0, _getInteraction.getInteraction)({
|
|
@@ -189,10 +190,15 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
|
|
|
189
190
|
showArrows = _this$props4.showArrows,
|
|
190
191
|
value = _this$props4.value,
|
|
191
192
|
width = _this$props4.width,
|
|
192
|
-
allowStringValue = _this$props4.allowStringValue
|
|
193
|
+
allowStringValue = _this$props4.allowStringValue,
|
|
194
|
+
styles = _this$props4.styles;
|
|
193
195
|
const interaction = this.interaction;
|
|
196
|
+
const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
197
|
+
const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _emotion.jsx)(_react.default.Fragment, null, rawLabel, isRequired && (0, _emotion.jsx)("span", {
|
|
198
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {}
|
|
199
|
+
}, " *")) : rawLabel;
|
|
194
200
|
return (0, _emotion.jsx)(_FormField.FormField, Object.assign({}, (0, _pickProps.pickProps)(this.props, _FormField.FormField.allowedProps), {
|
|
195
|
-
label:
|
|
201
|
+
label: label,
|
|
196
202
|
inline: display === 'inline-block',
|
|
197
203
|
id: this.id,
|
|
198
204
|
elementRef: this.handleRef
|
package/lib/NumberInput/theme.js
CHANGED
|
@@ -56,6 +56,7 @@ const generateComponentTheme = theme => {
|
|
|
56
56
|
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
57
57
|
color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
58
58
|
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
59
|
+
requiredInvalidColor: colors === null || colors === void 0 ? void 0 : colors.textDanger,
|
|
59
60
|
padding: `0 ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`,
|
|
60
61
|
arrowsContainerWidth: '2rem',
|
|
61
62
|
arrowsColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-number-input",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.1-pr-snapshot-1731682046909",
|
|
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,25 +23,26 @@
|
|
|
23
23
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "9.
|
|
27
|
-
"@instructure/ui-babel-preset": "9.
|
|
28
|
-
"@instructure/ui-scripts": "9.
|
|
29
|
-
"@instructure/ui-test-locator": "9.
|
|
30
|
-
"@instructure/ui-test-utils": "9.
|
|
31
|
-
"@instructure/ui-themes": "9.
|
|
26
|
+
"@instructure/ui-axe-check": "9.9.1-pr-snapshot-1731682046909",
|
|
27
|
+
"@instructure/ui-babel-preset": "9.9.1-pr-snapshot-1731682046909",
|
|
28
|
+
"@instructure/ui-scripts": "9.9.1-pr-snapshot-1731682046909",
|
|
29
|
+
"@instructure/ui-test-locator": "9.9.1-pr-snapshot-1731682046909",
|
|
30
|
+
"@instructure/ui-test-utils": "9.9.1-pr-snapshot-1731682046909",
|
|
31
|
+
"@instructure/ui-themes": "9.9.1-pr-snapshot-1731682046909",
|
|
32
32
|
"@testing-library/react": "^15.0.7",
|
|
33
33
|
"vitest": "^2.0.2"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.24.5",
|
|
37
|
-
"@instructure/emotion": "9.
|
|
38
|
-
"@instructure/shared-types": "9.
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-
|
|
42
|
-
"@instructure/ui-
|
|
43
|
-
"@instructure/ui-
|
|
44
|
-
"@instructure/
|
|
37
|
+
"@instructure/emotion": "9.9.1-pr-snapshot-1731682046909",
|
|
38
|
+
"@instructure/shared-types": "9.9.1-pr-snapshot-1731682046909",
|
|
39
|
+
"@instructure/ui-a11y-utils": "9.9.1-pr-snapshot-1731682046909",
|
|
40
|
+
"@instructure/ui-form-field": "9.9.1-pr-snapshot-1731682046909",
|
|
41
|
+
"@instructure/ui-icons": "9.9.1-pr-snapshot-1731682046909",
|
|
42
|
+
"@instructure/ui-react-utils": "9.9.1-pr-snapshot-1731682046909",
|
|
43
|
+
"@instructure/ui-testable": "9.9.1-pr-snapshot-1731682046909",
|
|
44
|
+
"@instructure/ui-utils": "9.9.1-pr-snapshot-1731682046909",
|
|
45
|
+
"@instructure/uid": "9.9.1-pr-snapshot-1731682046909",
|
|
45
46
|
"keycode": "^2",
|
|
46
47
|
"prop-types": "^15.8.1"
|
|
47
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
|
|
|
@@ -102,7 +103,9 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
|
|
|
102
103
|
get invalid() {
|
|
103
104
|
return (
|
|
104
105
|
!!this.props.messages &&
|
|
105
|
-
this.props.messages.some(
|
|
106
|
+
this.props.messages.some(
|
|
107
|
+
(message) => message.type === 'error' || message.type === 'newError'
|
|
108
|
+
)
|
|
106
109
|
)
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -234,15 +237,28 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
|
|
|
234
237
|
showArrows,
|
|
235
238
|
value,
|
|
236
239
|
width,
|
|
237
|
-
allowStringValue
|
|
240
|
+
allowStringValue,
|
|
241
|
+
styles
|
|
238
242
|
} = this.props
|
|
239
243
|
|
|
240
244
|
const { interaction } = this
|
|
241
245
|
|
|
246
|
+
const rawLabel = callRenderProp(renderLabel)
|
|
247
|
+
const label = hasVisibleChildren(rawLabel) ? (
|
|
248
|
+
<React.Fragment>
|
|
249
|
+
{rawLabel}
|
|
250
|
+
{isRequired && (
|
|
251
|
+
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
|
|
252
|
+
)}
|
|
253
|
+
</React.Fragment>
|
|
254
|
+
) : (
|
|
255
|
+
rawLabel
|
|
256
|
+
)
|
|
257
|
+
|
|
242
258
|
return (
|
|
243
259
|
<FormField
|
|
244
260
|
{...pickProps(this.props, FormField.allowedProps)}
|
|
245
|
-
label={
|
|
261
|
+
label={label}
|
|
246
262
|
inline={display === 'inline-block'}
|
|
247
263
|
id={this.id}
|
|
248
264
|
elementRef={this.handleRef}
|
package/src/NumberInput/props.ts
CHANGED
|
@@ -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[]
|
|
@@ -202,6 +202,7 @@ type NumberInputStyle = ComponentStyle<
|
|
|
202
202
|
| 'inputWidth'
|
|
203
203
|
| 'inputContainer'
|
|
204
204
|
| 'input'
|
|
205
|
+
| 'requiredInvalid'
|
|
205
206
|
>
|
|
206
207
|
|
|
207
208
|
const propTypes: PropValidators<PropKeys> = {
|
package/src/NumberInput/theme.ts
CHANGED
|
@@ -53,6 +53,8 @@ const generateComponentTheme = (theme: Theme): NumberInputTheme => {
|
|
|
53
53
|
color: colors?.textDarkest,
|
|
54
54
|
background: colors?.backgroundLightest,
|
|
55
55
|
|
|
56
|
+
requiredInvalidColor: colors?.textDanger,
|
|
57
|
+
|
|
56
58
|
padding: `0 ${spacing?.small}`,
|
|
57
59
|
|
|
58
60
|
arrowsContainerWidth: '2rem',
|
package/tsconfig.build.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
{ "path": "../ui-form-field/tsconfig.build.json" },
|
|
19
19
|
{ "path": "../ui-icons/tsconfig.build.json" },
|
|
20
20
|
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
21
|
+
{ "path": "../ui-a11y-utils/tsconfig.build.json" },
|
|
21
22
|
{ "path": "../ui-testable/tsconfig.build.json" },
|
|
22
23
|
{ "path": "../ui-utils/tsconfig.build.json" },
|
|
23
24
|
{ "path": "../uid/tsconfig.build.json" }
|