@instructure/ui-number-input 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/NumberInput/v1/index.js +114 -112
- package/es/NumberInput/v1/styles.js +9 -5
- package/es/NumberInput/v1/theme.js +33 -32
- package/es/NumberInput/v2/index.js +45 -67
- package/es/NumberInput/v2/styles.js +7 -5
- package/lib/NumberInput/v1/index.js +115 -113
- package/lib/NumberInput/v1/styles.js +9 -5
- package/lib/NumberInput/v1/theme.js +33 -32
- package/lib/NumberInput/v2/index.js +46 -67
- package/lib/NumberInput/v2/styles.js +7 -5
- package/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [11.7.3-snapshot-
|
|
6
|
+
## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -40,72 +40,31 @@ category: components
|
|
|
40
40
|
id: NumberInput
|
|
41
41
|
---
|
|
42
42
|
**/
|
|
43
|
-
let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
this.handleBlur = event => {
|
|
70
|
-
this.setState({
|
|
71
|
-
hasFocus: false
|
|
72
|
-
});
|
|
73
|
-
if (typeof this.props.onBlur === 'function') {
|
|
74
|
-
this.props.onBlur(event);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
this.handleChange = event => {
|
|
78
|
-
if (typeof this.props.onChange === 'function') {
|
|
79
|
-
this.props.onChange(event, event.target.value);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
this.handleKeyDown = event => {
|
|
83
|
-
const _this$props = this.props,
|
|
84
|
-
onKeyDown = _this$props.onKeyDown,
|
|
85
|
-
onDecrement = _this$props.onDecrement,
|
|
86
|
-
onIncrement = _this$props.onIncrement;
|
|
87
|
-
if (typeof onKeyDown === 'function') {
|
|
88
|
-
onKeyDown(event);
|
|
89
|
-
}
|
|
90
|
-
if (event.keyCode === keycode.codes.down) {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
if (typeof onDecrement === 'function') {
|
|
93
|
-
onDecrement(event);
|
|
94
|
-
}
|
|
95
|
-
} else if (event.keyCode === keycode.codes.up) {
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
if (typeof onIncrement === 'function') {
|
|
98
|
-
onIncrement(event);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
this.handleClickUpArrow = event => {
|
|
103
|
-
this.arrowClicked(event, this.props.onIncrement);
|
|
104
|
-
};
|
|
105
|
-
this.handleClickDownArrow = event => {
|
|
106
|
-
this.arrowClicked(event, this.props.onDecrement);
|
|
107
|
-
};
|
|
108
|
-
}
|
|
43
|
+
let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class NumberInput extends Component {
|
|
44
|
+
static displayName = "NumberInput";
|
|
45
|
+
static componentId = 'NumberInput';
|
|
46
|
+
static allowedProps = allowedProps;
|
|
47
|
+
static defaultProps = {
|
|
48
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
49
|
+
interaction: undefined,
|
|
50
|
+
messages: [],
|
|
51
|
+
isRequired: false,
|
|
52
|
+
showArrows: true,
|
|
53
|
+
size: 'medium',
|
|
54
|
+
display: 'block',
|
|
55
|
+
textAlign: 'start',
|
|
56
|
+
inputMode: 'numeric',
|
|
57
|
+
allowStringValue: false
|
|
58
|
+
};
|
|
59
|
+
state = {
|
|
60
|
+
hasFocus: false
|
|
61
|
+
};
|
|
62
|
+
ref = null;
|
|
63
|
+
_input = null;
|
|
64
|
+
_id;
|
|
65
|
+
handleRef = el => {
|
|
66
|
+
this.ref = el;
|
|
67
|
+
};
|
|
109
68
|
get id() {
|
|
110
69
|
if (this.props.id) {
|
|
111
70
|
return this.props.id;
|
|
@@ -124,12 +83,10 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
|
|
|
124
83
|
});
|
|
125
84
|
}
|
|
126
85
|
componentDidMount() {
|
|
127
|
-
|
|
128
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStyleVariables);
|
|
86
|
+
this.props.makeStyles?.(this.makeStyleVariables);
|
|
129
87
|
}
|
|
130
88
|
componentDidUpdate() {
|
|
131
|
-
|
|
132
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStyleVariables);
|
|
89
|
+
this.props.makeStyles?.(this.makeStyleVariables);
|
|
133
90
|
}
|
|
134
91
|
get makeStyleVariables() {
|
|
135
92
|
return {
|
|
@@ -138,57 +95,113 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
|
|
|
138
95
|
invalid: this.invalid
|
|
139
96
|
};
|
|
140
97
|
}
|
|
98
|
+
handleInputRef = element => {
|
|
99
|
+
this._input = element;
|
|
100
|
+
if (typeof this.props.inputRef === 'function') {
|
|
101
|
+
this.props.inputRef(element);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
handleFocus = event => {
|
|
105
|
+
this.setState({
|
|
106
|
+
hasFocus: true
|
|
107
|
+
});
|
|
108
|
+
if (typeof this.props.onFocus === 'function') {
|
|
109
|
+
this.props.onFocus(event);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
handleBlur = event => {
|
|
113
|
+
this.setState({
|
|
114
|
+
hasFocus: false
|
|
115
|
+
});
|
|
116
|
+
if (typeof this.props.onBlur === 'function') {
|
|
117
|
+
this.props.onBlur(event);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
handleChange = event => {
|
|
121
|
+
if (typeof this.props.onChange === 'function') {
|
|
122
|
+
this.props.onChange(event, event.target.value);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
handleKeyDown = event => {
|
|
126
|
+
const {
|
|
127
|
+
onKeyDown,
|
|
128
|
+
onDecrement,
|
|
129
|
+
onIncrement
|
|
130
|
+
} = this.props;
|
|
131
|
+
if (typeof onKeyDown === 'function') {
|
|
132
|
+
onKeyDown(event);
|
|
133
|
+
}
|
|
134
|
+
if (event.keyCode === keycode.codes.down) {
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
if (typeof onDecrement === 'function') {
|
|
137
|
+
onDecrement(event);
|
|
138
|
+
}
|
|
139
|
+
} else if (event.keyCode === keycode.codes.up) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
if (typeof onIncrement === 'function') {
|
|
142
|
+
onIncrement(event);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
handleClickUpArrow = event => {
|
|
147
|
+
this.arrowClicked(event, this.props.onIncrement);
|
|
148
|
+
};
|
|
149
|
+
handleClickDownArrow = event => {
|
|
150
|
+
this.arrowClicked(event, this.props.onDecrement);
|
|
151
|
+
};
|
|
141
152
|
arrowClicked(event, callback) {
|
|
142
|
-
const
|
|
153
|
+
const {
|
|
154
|
+
interaction
|
|
155
|
+
} = this;
|
|
143
156
|
event.preventDefault();
|
|
144
157
|
if (interaction === 'enabled') {
|
|
145
|
-
|
|
146
|
-
(_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
|
|
158
|
+
this._input?.focus();
|
|
147
159
|
if (typeof callback === 'function') {
|
|
148
160
|
callback(event);
|
|
149
161
|
}
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
164
|
renderArrows(customIcons) {
|
|
153
|
-
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
154
165
|
return _jsxs("span", {
|
|
155
|
-
css:
|
|
166
|
+
css: this.props.styles?.arrowContainer,
|
|
156
167
|
children: [_jsx("button", {
|
|
157
168
|
"aria-hidden": true,
|
|
158
|
-
css:
|
|
169
|
+
css: this.props.styles?.arrow,
|
|
159
170
|
onMouseDown: this.handleClickUpArrow,
|
|
160
171
|
tabIndex: -1,
|
|
161
172
|
type: "button",
|
|
162
|
-
children: customIcons
|
|
173
|
+
children: customIcons?.increase ? callRenderProp(customIcons.increase) : _jsx(IconArrowOpenUpLine, {})
|
|
163
174
|
}), _jsx("button", {
|
|
164
175
|
"aria-hidden": true,
|
|
165
|
-
css:
|
|
176
|
+
css: this.props.styles?.arrow,
|
|
166
177
|
onMouseDown: this.handleClickDownArrow,
|
|
167
178
|
tabIndex: -1,
|
|
168
179
|
type: "button",
|
|
169
|
-
children: customIcons
|
|
180
|
+
children: customIcons?.decrease ? callRenderProp(customIcons.decrease) : _jsx(IconArrowOpenDownLine, {})
|
|
170
181
|
})]
|
|
171
182
|
});
|
|
172
183
|
}
|
|
173
184
|
render() {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
185
|
+
const {
|
|
186
|
+
renderLabel,
|
|
187
|
+
display,
|
|
188
|
+
placeholder,
|
|
189
|
+
isRequired,
|
|
190
|
+
showArrows,
|
|
191
|
+
value,
|
|
192
|
+
width,
|
|
193
|
+
styles,
|
|
194
|
+
allowStringValue,
|
|
195
|
+
renderIcons,
|
|
196
|
+
margin
|
|
197
|
+
} = this.props;
|
|
198
|
+
const {
|
|
199
|
+
interaction
|
|
200
|
+
} = this;
|
|
188
201
|
const rawLabel = callRenderProp(renderLabel);
|
|
189
202
|
const label = hasVisibleChildren(rawLabel) ? _jsxs(Fragment, {
|
|
190
203
|
children: [rawLabel, isRequired && _jsxs("span", {
|
|
191
|
-
css: this.invalid ? styles
|
|
204
|
+
css: this.invalid ? styles?.requiredInvalid : {},
|
|
192
205
|
"aria-hidden": true,
|
|
193
206
|
children: [' ', "*"]
|
|
194
207
|
})]
|
|
@@ -202,16 +215,16 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
|
|
|
202
215
|
margin: margin,
|
|
203
216
|
"data-cid": "NumberInput",
|
|
204
217
|
children: _jsx("span", {
|
|
205
|
-
css:
|
|
218
|
+
css: this.props.styles?.inputWidth,
|
|
206
219
|
style: width ? {
|
|
207
220
|
width
|
|
208
|
-
} :
|
|
221
|
+
} : undefined,
|
|
209
222
|
children: _jsxs("span", {
|
|
210
|
-
css:
|
|
223
|
+
css: this.props.styles?.inputContainer,
|
|
211
224
|
children: [_jsx("input", {
|
|
212
225
|
...omitProps(this.props, [...FormField.allowedProps, ...NumberInput.allowedProps]),
|
|
213
|
-
css:
|
|
214
|
-
"aria-invalid": this.invalid ? 'true' :
|
|
226
|
+
css: this.props.styles?.input,
|
|
227
|
+
"aria-invalid": this.invalid ? 'true' : undefined,
|
|
215
228
|
id: this.id,
|
|
216
229
|
type: allowStringValue ? 'text' : 'number',
|
|
217
230
|
inputMode: this.props.inputMode,
|
|
@@ -230,17 +243,6 @@ let NumberInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle
|
|
|
230
243
|
})
|
|
231
244
|
});
|
|
232
245
|
}
|
|
233
|
-
}
|
|
234
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
235
|
-
interaction: void 0,
|
|
236
|
-
messages: [],
|
|
237
|
-
isRequired: false,
|
|
238
|
-
showArrows: true,
|
|
239
|
-
size: 'medium',
|
|
240
|
-
display: 'block',
|
|
241
|
-
textAlign: 'start',
|
|
242
|
-
inputMode: 'numeric',
|
|
243
|
-
allowStringValue: false
|
|
244
|
-
}, _NumberInput)) || _class) || _class);
|
|
246
|
+
}) || _class) || _class);
|
|
245
247
|
export default NumberInput;
|
|
246
248
|
export { NumberInput };
|
|
@@ -33,11 +33,15 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const {
|
|
37
|
+
size,
|
|
38
|
+
textAlign
|
|
39
|
+
} = props;
|
|
40
|
+
const {
|
|
41
|
+
interaction,
|
|
42
|
+
hasFocus,
|
|
43
|
+
invalid
|
|
44
|
+
} = state;
|
|
41
45
|
const disabledStyles = interaction === 'disabled' ? {
|
|
42
46
|
cursor: 'not-allowed',
|
|
43
47
|
pointerEvents: 'none',
|
|
@@ -28,13 +28,14 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
spacing
|
|
34
|
-
borders
|
|
35
|
-
typography
|
|
36
|
-
forms
|
|
37
|
-
themeName
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
spacing,
|
|
34
|
+
borders,
|
|
35
|
+
typography,
|
|
36
|
+
forms,
|
|
37
|
+
key: themeName
|
|
38
|
+
} = theme;
|
|
38
39
|
const themeSpecificStyle = {
|
|
39
40
|
canvas: {
|
|
40
41
|
color: theme['ic-brand-font-color-dark'],
|
|
@@ -43,32 +44,32 @@ const generateComponentTheme = theme => {
|
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
const componentVariables = {
|
|
46
|
-
fontFamily: typography
|
|
47
|
-
fontWeight: typography
|
|
48
|
-
borderWidth: borders
|
|
49
|
-
borderStyle: borders
|
|
50
|
-
borderColor: colors
|
|
51
|
-
borderRadius: borders
|
|
52
|
-
color: colors
|
|
53
|
-
background: colors
|
|
54
|
-
requiredInvalidColor: colors
|
|
55
|
-
padding: `0 ${spacing
|
|
47
|
+
fontFamily: typography?.fontFamily,
|
|
48
|
+
fontWeight: typography?.fontWeightNormal,
|
|
49
|
+
borderWidth: borders?.widthSmall,
|
|
50
|
+
borderStyle: borders?.style,
|
|
51
|
+
borderColor: colors?.contrasts?.grey3045,
|
|
52
|
+
borderRadius: borders?.radiusMedium,
|
|
53
|
+
color: colors?.contrasts?.grey125125,
|
|
54
|
+
background: colors?.contrasts?.white1010,
|
|
55
|
+
requiredInvalidColor: colors?.contrasts?.red5782,
|
|
56
|
+
padding: `0 ${spacing?.small}`,
|
|
56
57
|
arrowsContainerWidth: '2rem',
|
|
57
|
-
arrowsColor: colors
|
|
58
|
-
arrowsBackgroundColor: colors
|
|
59
|
-
arrowsHoverBackgroundColor: colors
|
|
60
|
-
arrowsBorderColor: colors
|
|
61
|
-
arrowsActiveBoxShadow: `inset 0 0 3px 1px ${colors
|
|
62
|
-
focusOutlineWidth: borders
|
|
63
|
-
focusOutlineStyle: borders
|
|
64
|
-
focusOutlineColor: colors
|
|
65
|
-
errorBorderColor: colors
|
|
66
|
-
errorOutlineColor: colors
|
|
67
|
-
placeholderColor: colors
|
|
68
|
-
mediumFontSize: typography
|
|
69
|
-
mediumHeight: forms
|
|
70
|
-
largeFontSize: typography
|
|
71
|
-
largeHeight: forms
|
|
58
|
+
arrowsColor: colors?.contrasts?.grey125125,
|
|
59
|
+
arrowsBackgroundColor: colors?.contrasts?.grey1111,
|
|
60
|
+
arrowsHoverBackgroundColor: colors?.contrasts?.grey1214,
|
|
61
|
+
arrowsBorderColor: colors?.contrasts?.grey3045,
|
|
62
|
+
arrowsActiveBoxShadow: `inset 0 0 3px 1px ${colors?.contrasts?.grey1214}`,
|
|
63
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
64
|
+
focusOutlineStyle: borders?.style,
|
|
65
|
+
focusOutlineColor: colors?.contrasts?.blue4570,
|
|
66
|
+
errorBorderColor: colors?.contrasts?.red4570,
|
|
67
|
+
errorOutlineColor: colors?.contrasts?.red4570,
|
|
68
|
+
placeholderColor: colors?.contrasts?.grey4570,
|
|
69
|
+
mediumFontSize: typography?.fontSizeMedium,
|
|
70
|
+
mediumHeight: forms?.inputHeightMedium,
|
|
71
|
+
largeFontSize: typography?.fontSizeLarge,
|
|
72
|
+
largeHeight: forms?.inputHeightLarge
|
|
72
73
|
};
|
|
73
74
|
return {
|
|
74
75
|
...componentVariables,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["messages", "isRequired", "showArrows", "size", "display", "textAlign", "inputMode", "allowStringValue", "renderLabel", "placeholder", "value", "width", "renderIcons", "margin", "inputRef", "onFocus", "onBlur", "onChange", "onKeyDown", "onDecrement", "onIncrement", "id", "themeOverride"];
|
|
4
1
|
/*
|
|
5
2
|
* The MIT License (MIT)
|
|
6
3
|
*
|
|
@@ -40,58 +37,42 @@ id: NumberInput
|
|
|
40
37
|
---
|
|
41
38
|
**/
|
|
42
39
|
const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
onChange = props.onChange,
|
|
70
|
-
onKeyDown = props.onKeyDown,
|
|
71
|
-
onDecrement = props.onDecrement,
|
|
72
|
-
onIncrement = props.onIncrement,
|
|
73
|
-
idProp = props.id,
|
|
74
|
-
themeOverride = props.themeOverride,
|
|
75
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
40
|
+
const {
|
|
41
|
+
messages = [],
|
|
42
|
+
isRequired = false,
|
|
43
|
+
showArrows = true,
|
|
44
|
+
size = 'medium',
|
|
45
|
+
display = 'block',
|
|
46
|
+
textAlign = 'start',
|
|
47
|
+
inputMode = 'numeric',
|
|
48
|
+
allowStringValue = false,
|
|
49
|
+
renderLabel,
|
|
50
|
+
placeholder,
|
|
51
|
+
value,
|
|
52
|
+
width,
|
|
53
|
+
renderIcons,
|
|
54
|
+
margin,
|
|
55
|
+
inputRef: inputRefProp,
|
|
56
|
+
onFocus,
|
|
57
|
+
onBlur,
|
|
58
|
+
onChange,
|
|
59
|
+
onKeyDown,
|
|
60
|
+
onDecrement,
|
|
61
|
+
onIncrement,
|
|
62
|
+
id: idProp,
|
|
63
|
+
themeOverride,
|
|
64
|
+
...rest
|
|
65
|
+
} = props;
|
|
76
66
|
// these are icon tokens
|
|
77
67
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
upButtonState = _useState2[0],
|
|
81
|
-
setUpButtonState = _useState2[1];
|
|
82
|
-
const _useState3 = useState('actionSecondaryBaseColor'),
|
|
83
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
84
|
-
downButtonState = _useState4[0],
|
|
85
|
-
setDownButtonState = _useState4[1];
|
|
68
|
+
const [upButtonState, setUpButtonState] = useState('actionSecondaryBaseColor');
|
|
69
|
+
const [downButtonState, setDownButtonState] = useState('actionSecondaryBaseColor');
|
|
86
70
|
// Refs
|
|
87
71
|
const containerRef = useRef(null);
|
|
88
72
|
const inputRef = useRef(null);
|
|
89
73
|
|
|
90
74
|
// Deterministic ID generation
|
|
91
|
-
const
|
|
92
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
93
|
-
deterministicId = _useState6[0],
|
|
94
|
-
setDeterministicId = _useState6[1];
|
|
75
|
+
const [deterministicId, setDeterministicId] = useState();
|
|
95
76
|
const getId = useDeterministicId('NumberInput');
|
|
96
77
|
useEffect(() => {
|
|
97
78
|
setDeterministicId(getId());
|
|
@@ -172,8 +153,7 @@ const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
172
153
|
const arrowClicked = useCallback((event, callback) => {
|
|
173
154
|
event.preventDefault();
|
|
174
155
|
if (interaction === 'enabled') {
|
|
175
|
-
|
|
176
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
156
|
+
inputRef.current?.focus();
|
|
177
157
|
if (typeof callback === 'function') {
|
|
178
158
|
callback(event);
|
|
179
159
|
}
|
|
@@ -191,8 +171,7 @@ const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
191
171
|
// Expose imperative API via ref
|
|
192
172
|
useImperativeHandle(ref, () => ({
|
|
193
173
|
focus: () => {
|
|
194
|
-
|
|
195
|
-
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
174
|
+
inputRef.current?.focus();
|
|
196
175
|
},
|
|
197
176
|
get id() {
|
|
198
177
|
return id;
|
|
@@ -204,8 +183,7 @@ const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
204
183
|
return interaction;
|
|
205
184
|
},
|
|
206
185
|
get value() {
|
|
207
|
-
|
|
208
|
-
return (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value;
|
|
186
|
+
return inputRef.current?.value;
|
|
209
187
|
},
|
|
210
188
|
ref: containerRef
|
|
211
189
|
}), [id, invalid, interaction]);
|
|
@@ -213,31 +191,31 @@ const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
213
191
|
// Render methods
|
|
214
192
|
const renderArrows = customIcons => {
|
|
215
193
|
return _jsxs("span", {
|
|
216
|
-
css: styles
|
|
194
|
+
css: styles?.arrowContainer,
|
|
217
195
|
children: [_jsx("button", {
|
|
218
196
|
"aria-hidden": true,
|
|
219
|
-
css: styles
|
|
197
|
+
css: styles?.arrow,
|
|
220
198
|
onMouseDown: handleClickUpArrow,
|
|
221
199
|
onMouseOver: () => setUpButtonState('actionSecondaryHoverColor'),
|
|
222
200
|
onMouseOut: () => setUpButtonState('actionSecondaryBaseColor'),
|
|
223
201
|
tabIndex: -1,
|
|
224
202
|
type: "button",
|
|
225
|
-
children: customIcons
|
|
203
|
+
children: customIcons?.increase ? callRenderProp(customIcons.increase) : _jsx(ChevronUpInstUIIcon, {
|
|
226
204
|
size: "sm",
|
|
227
205
|
color: upButtonState
|
|
228
|
-
})
|
|
206
|
+
})
|
|
229
207
|
}), _jsx("button", {
|
|
230
208
|
"aria-hidden": true,
|
|
231
|
-
css: styles
|
|
209
|
+
css: styles?.arrow,
|
|
232
210
|
onMouseDown: handleClickDownArrow,
|
|
233
211
|
onMouseOver: () => setDownButtonState('actionSecondaryHoverColor'),
|
|
234
212
|
onMouseOut: () => setDownButtonState('actionSecondaryBaseColor'),
|
|
235
213
|
tabIndex: -1,
|
|
236
214
|
type: "button",
|
|
237
|
-
children: customIcons
|
|
215
|
+
children: customIcons?.decrease ? callRenderProp(customIcons.decrease) : _jsx(ChevronDownInstUIIcon, {
|
|
238
216
|
size: "sm",
|
|
239
217
|
color: downButtonState
|
|
240
|
-
})
|
|
218
|
+
})
|
|
241
219
|
})]
|
|
242
220
|
});
|
|
243
221
|
};
|
|
@@ -260,20 +238,20 @@ const NumberInput = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
260
238
|
readOnly: interaction === 'readonly',
|
|
261
239
|
"data-cid": "NumberInput",
|
|
262
240
|
children: _jsx("span", {
|
|
263
|
-
css: styles
|
|
241
|
+
css: styles?.inputWidth,
|
|
264
242
|
style: width ? {
|
|
265
243
|
width
|
|
266
|
-
} :
|
|
244
|
+
} : undefined,
|
|
267
245
|
children: _jsxs("span", {
|
|
268
|
-
css: styles
|
|
246
|
+
css: styles?.inputContainer,
|
|
269
247
|
children: [_jsx("input", {
|
|
270
248
|
...passedProps,
|
|
271
|
-
css: styles
|
|
272
|
-
"aria-invalid": invalid ? 'true' :
|
|
249
|
+
css: styles?.input,
|
|
250
|
+
"aria-invalid": invalid ? 'true' : undefined,
|
|
273
251
|
id: id,
|
|
274
252
|
type: allowStringValue ? 'text' : 'number',
|
|
275
253
|
inputMode: inputMode,
|
|
276
|
-
placeholder: interaction === 'enabled' ? placeholder :
|
|
254
|
+
placeholder: interaction === 'enabled' ? placeholder : undefined,
|
|
277
255
|
ref: handleInputRef,
|
|
278
256
|
required: isRequired,
|
|
279
257
|
value: value,
|
|
@@ -34,11 +34,13 @@ import { calcFocusOutlineStyles } from '@instructure/emotion';
|
|
|
34
34
|
* @return The final style object, which will be used in the component
|
|
35
35
|
*/
|
|
36
36
|
const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
const {
|
|
38
|
+
size,
|
|
39
|
+
textAlign,
|
|
40
|
+
interaction,
|
|
41
|
+
success,
|
|
42
|
+
invalid
|
|
43
|
+
} = params;
|
|
42
44
|
const containerInteractionStates = {
|
|
43
45
|
...(interaction === 'enabled' && {
|
|
44
46
|
backgroundColor: componentTheme.backgroundColor,
|