@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.
@@ -9,7 +9,7 @@ var _react = require("react");
9
9
  var _keycode = _interopRequireDefault(require("keycode"));
10
10
  var _v11_ = require("@instructure/ui-form-field/v11_6");
11
11
  var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenDownLine.js");
12
- var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/generated/IconArrowOpenUpLine.js");
12
+ var _IconArrowOpenUpLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenUpLine.js");
13
13
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
14
14
  var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
15
15
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
@@ -21,7 +21,7 @@ var _styles = _interopRequireDefault(require("./styles"));
21
21
  var _theme = _interopRequireDefault(require("./theme"));
22
22
  var _props = require("./props");
23
23
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
24
- var _dec, _dec2, _class, _NumberInput, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
24
+ var _dec, _dec2, _class;
25
25
  /*
26
26
  * The MIT License (MIT)
27
27
  *
@@ -51,72 +51,31 @@ category: components
51
51
  id: NumberInput
52
52
  ---
53
53
  **/
54
- let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_NumberInput = class NumberInput extends _react.Component {
55
- constructor(...args) {
56
- super(...args);
57
- this.state = {
58
- hasFocus: false
59
- };
60
- this.ref = null;
61
- this._input = null;
62
- this._id = void 0;
63
- this.handleRef = el => {
64
- this.ref = el;
65
- };
66
- this.handleInputRef = element => {
67
- this._input = element;
68
- if (typeof this.props.inputRef === 'function') {
69
- this.props.inputRef(element);
70
- }
71
- };
72
- this.handleFocus = event => {
73
- this.setState({
74
- hasFocus: true
75
- });
76
- if (typeof this.props.onFocus === 'function') {
77
- this.props.onFocus(event);
78
- }
79
- };
80
- this.handleBlur = event => {
81
- this.setState({
82
- hasFocus: false
83
- });
84
- if (typeof this.props.onBlur === 'function') {
85
- this.props.onBlur(event);
86
- }
87
- };
88
- this.handleChange = event => {
89
- if (typeof this.props.onChange === 'function') {
90
- this.props.onChange(event, event.target.value);
91
- }
92
- };
93
- this.handleKeyDown = event => {
94
- const _this$props = this.props,
95
- onKeyDown = _this$props.onKeyDown,
96
- onDecrement = _this$props.onDecrement,
97
- onIncrement = _this$props.onIncrement;
98
- if (typeof onKeyDown === 'function') {
99
- onKeyDown(event);
100
- }
101
- if (event.keyCode === _keycode.default.codes.down) {
102
- event.preventDefault();
103
- if (typeof onDecrement === 'function') {
104
- onDecrement(event);
105
- }
106
- } else if (event.keyCode === _keycode.default.codes.up) {
107
- event.preventDefault();
108
- if (typeof onIncrement === 'function') {
109
- onIncrement(event);
110
- }
111
- }
112
- };
113
- this.handleClickUpArrow = event => {
114
- this.arrowClicked(event, this.props.onIncrement);
115
- };
116
- this.handleClickDownArrow = event => {
117
- this.arrowClicked(event, this.props.onDecrement);
118
- };
119
- }
54
+ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = class NumberInput extends _react.Component {
55
+ static displayName = "NumberInput";
56
+ static componentId = 'NumberInput';
57
+ static allowedProps = _props.allowedProps;
58
+ static defaultProps = {
59
+ // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
60
+ interaction: undefined,
61
+ messages: [],
62
+ isRequired: false,
63
+ showArrows: true,
64
+ size: 'medium',
65
+ display: 'block',
66
+ textAlign: 'start',
67
+ inputMode: 'numeric',
68
+ allowStringValue: false
69
+ };
70
+ state = {
71
+ hasFocus: false
72
+ };
73
+ ref = null;
74
+ _input = null;
75
+ _id;
76
+ handleRef = el => {
77
+ this.ref = el;
78
+ };
120
79
  get id() {
121
80
  if (this.props.id) {
122
81
  return this.props.id;
@@ -135,12 +94,10 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
135
94
  });
136
95
  }
137
96
  componentDidMount() {
138
- var _this$props$makeStyle, _this$props2;
139
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStyleVariables);
97
+ this.props.makeStyles?.(this.makeStyleVariables);
140
98
  }
141
99
  componentDidUpdate() {
142
- var _this$props$makeStyle2, _this$props3;
143
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStyleVariables);
100
+ this.props.makeStyles?.(this.makeStyleVariables);
144
101
  }
145
102
  get makeStyleVariables() {
146
103
  return {
@@ -149,57 +106,113 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
149
106
  invalid: this.invalid
150
107
  };
151
108
  }
109
+ handleInputRef = element => {
110
+ this._input = element;
111
+ if (typeof this.props.inputRef === 'function') {
112
+ this.props.inputRef(element);
113
+ }
114
+ };
115
+ handleFocus = event => {
116
+ this.setState({
117
+ hasFocus: true
118
+ });
119
+ if (typeof this.props.onFocus === 'function') {
120
+ this.props.onFocus(event);
121
+ }
122
+ };
123
+ handleBlur = event => {
124
+ this.setState({
125
+ hasFocus: false
126
+ });
127
+ if (typeof this.props.onBlur === 'function') {
128
+ this.props.onBlur(event);
129
+ }
130
+ };
131
+ handleChange = event => {
132
+ if (typeof this.props.onChange === 'function') {
133
+ this.props.onChange(event, event.target.value);
134
+ }
135
+ };
136
+ handleKeyDown = event => {
137
+ const {
138
+ onKeyDown,
139
+ onDecrement,
140
+ onIncrement
141
+ } = this.props;
142
+ if (typeof onKeyDown === 'function') {
143
+ onKeyDown(event);
144
+ }
145
+ if (event.keyCode === _keycode.default.codes.down) {
146
+ event.preventDefault();
147
+ if (typeof onDecrement === 'function') {
148
+ onDecrement(event);
149
+ }
150
+ } else if (event.keyCode === _keycode.default.codes.up) {
151
+ event.preventDefault();
152
+ if (typeof onIncrement === 'function') {
153
+ onIncrement(event);
154
+ }
155
+ }
156
+ };
157
+ handleClickUpArrow = event => {
158
+ this.arrowClicked(event, this.props.onIncrement);
159
+ };
160
+ handleClickDownArrow = event => {
161
+ this.arrowClicked(event, this.props.onDecrement);
162
+ };
152
163
  arrowClicked(event, callback) {
153
- const interaction = this.interaction;
164
+ const {
165
+ interaction
166
+ } = this;
154
167
  event.preventDefault();
155
168
  if (interaction === 'enabled') {
156
- var _this$_input;
157
- (_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
169
+ this._input?.focus();
158
170
  if (typeof callback === 'function') {
159
171
  callback(event);
160
172
  }
161
173
  }
162
174
  }
163
175
  renderArrows(customIcons) {
164
- var _this$props$styles, _this$props$styles2, _this$props$styles3;
165
176
  return (0, _jsxRuntime.jsxs)("span", {
166
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.arrowContainer,
177
+ css: this.props.styles?.arrowContainer,
167
178
  children: [(0, _jsxRuntime.jsx)("button", {
168
179
  "aria-hidden": true,
169
- css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.arrow,
180
+ css: this.props.styles?.arrow,
170
181
  onMouseDown: this.handleClickUpArrow,
171
182
  tabIndex: -1,
172
183
  type: "button",
173
- children: customIcons !== null && customIcons !== void 0 && customIcons.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : _IconArrowOpenUpLine || (_IconArrowOpenUpLine = (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine2.IconArrowOpenUpLine, {}))
184
+ children: customIcons?.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine.IconArrowOpenUpLine, {})
174
185
  }), (0, _jsxRuntime.jsx)("button", {
175
186
  "aria-hidden": true,
176
- css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.arrow,
187
+ css: this.props.styles?.arrow,
177
188
  onMouseDown: this.handleClickDownArrow,
178
189
  tabIndex: -1,
179
190
  type: "button",
180
- children: customIcons !== null && customIcons !== void 0 && customIcons.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : _IconArrowOpenDownLin || (_IconArrowOpenDownLin = (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {}))
191
+ children: customIcons?.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {})
181
192
  })]
182
193
  });
183
194
  }
184
195
  render() {
185
- var _this$props$styles4, _this$props$styles5, _this$props$styles6;
186
- const _this$props4 = this.props,
187
- renderLabel = _this$props4.renderLabel,
188
- display = _this$props4.display,
189
- placeholder = _this$props4.placeholder,
190
- isRequired = _this$props4.isRequired,
191
- showArrows = _this$props4.showArrows,
192
- value = _this$props4.value,
193
- width = _this$props4.width,
194
- styles = _this$props4.styles,
195
- allowStringValue = _this$props4.allowStringValue,
196
- renderIcons = _this$props4.renderIcons,
197
- margin = _this$props4.margin;
198
- const interaction = this.interaction;
196
+ const {
197
+ renderLabel,
198
+ display,
199
+ placeholder,
200
+ isRequired,
201
+ showArrows,
202
+ value,
203
+ width,
204
+ styles,
205
+ allowStringValue,
206
+ renderIcons,
207
+ margin
208
+ } = this.props;
209
+ const {
210
+ interaction
211
+ } = this;
199
212
  const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
200
213
  const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _jsxRuntime.jsxs)(_react.Fragment, {
201
214
  children: [rawLabel, isRequired && (0, _jsxRuntime.jsxs)("span", {
202
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
215
+ css: this.invalid ? styles?.requiredInvalid : {},
203
216
  "aria-hidden": true,
204
217
  children: [' ', "*"]
205
218
  })]
@@ -213,16 +226,16 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
213
226
  margin: margin,
214
227
  "data-cid": "NumberInput",
215
228
  children: (0, _jsxRuntime.jsx)("span", {
216
- css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.inputWidth,
229
+ css: this.props.styles?.inputWidth,
217
230
  style: width ? {
218
231
  width
219
- } : void 0,
232
+ } : undefined,
220
233
  children: (0, _jsxRuntime.jsxs)("span", {
221
- css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.inputContainer,
234
+ css: this.props.styles?.inputContainer,
222
235
  children: [(0, _jsxRuntime.jsx)("input", {
223
236
  ...(0, _omitProps.omitProps)(this.props, [..._v11_.FormField.allowedProps, ...NumberInput.allowedProps]),
224
- css: (_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.input,
225
- "aria-invalid": this.invalid ? 'true' : void 0,
237
+ css: this.props.styles?.input,
238
+ "aria-invalid": this.invalid ? 'true' : undefined,
226
239
  id: this.id,
227
240
  type: allowStringValue ? 'text' : 'number',
228
241
  inputMode: this.props.inputMode,
@@ -241,16 +254,5 @@ let NumberInput = exports.NumberInput = (_dec = (0, _withDeterministicId.withDet
241
254
  })
242
255
  });
243
256
  }
244
- }, _NumberInput.displayName = "NumberInput", _NumberInput.componentId = 'NumberInput', _NumberInput.allowedProps = _props.allowedProps, _NumberInput.defaultProps = {
245
- // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
246
- interaction: void 0,
247
- messages: [],
248
- isRequired: false,
249
- showArrows: true,
250
- size: 'medium',
251
- display: 'block',
252
- textAlign: 'start',
253
- inputMode: 'numeric',
254
- allowStringValue: false
255
- }, _NumberInput)) || _class) || _class);
257
+ }) || _class) || _class);
256
258
  var _default = exports.default = NumberInput;
@@ -39,11 +39,15 @@ exports.default = void 0;
39
39
  * @return {Object} The final style object, which will be used in the component
40
40
  */
41
41
  const generateStyle = (componentTheme, props, state) => {
42
- const size = props.size,
43
- textAlign = props.textAlign;
44
- const interaction = state.interaction,
45
- hasFocus = state.hasFocus,
46
- invalid = state.invalid;
42
+ const {
43
+ size,
44
+ textAlign
45
+ } = props;
46
+ const {
47
+ interaction,
48
+ hasFocus,
49
+ invalid
50
+ } = state;
47
51
  const disabledStyles = interaction === 'disabled' ? {
48
52
  cursor: 'not-allowed',
49
53
  pointerEvents: 'none',
@@ -34,13 +34,14 @@ exports.default = void 0;
34
34
  * @return {Object} The final theme object with the overrides and component variables
35
35
  */
36
36
  const generateComponentTheme = theme => {
37
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1, _colors$contrasts10, _colors$contrasts11;
38
- const colors = theme.colors,
39
- spacing = theme.spacing,
40
- borders = theme.borders,
41
- typography = theme.typography,
42
- forms = theme.forms,
43
- themeName = theme.key;
37
+ const {
38
+ colors,
39
+ spacing,
40
+ borders,
41
+ typography,
42
+ forms,
43
+ key: themeName
44
+ } = theme;
44
45
  const themeSpecificStyle = {
45
46
  canvas: {
46
47
  color: theme['ic-brand-font-color-dark'],
@@ -49,32 +50,32 @@ const generateComponentTheme = theme => {
49
50
  }
50
51
  };
51
52
  const componentVariables = {
52
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
53
- fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
54
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
55
- borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
56
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045,
57
- borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
58
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey125125,
59
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.white1010,
60
- requiredInvalidColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.red5782,
61
- padding: `0 ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`,
53
+ fontFamily: typography?.fontFamily,
54
+ fontWeight: typography?.fontWeightNormal,
55
+ borderWidth: borders?.widthSmall,
56
+ borderStyle: borders?.style,
57
+ borderColor: colors?.contrasts?.grey3045,
58
+ borderRadius: borders?.radiusMedium,
59
+ color: colors?.contrasts?.grey125125,
60
+ background: colors?.contrasts?.white1010,
61
+ requiredInvalidColor: colors?.contrasts?.red5782,
62
+ padding: `0 ${spacing?.small}`,
62
63
  arrowsContainerWidth: '2rem',
63
- arrowsColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey125125,
64
- arrowsBackgroundColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.grey1111,
65
- arrowsHoverBackgroundColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.grey1214,
66
- arrowsBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.grey3045,
67
- arrowsActiveBoxShadow: `inset 0 0 3px 1px ${colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.grey1214}`,
68
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
69
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
70
- focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.blue4570,
71
- errorBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.red4570,
72
- errorOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts10 = colors.contrasts) === null || _colors$contrasts10 === void 0 ? void 0 : _colors$contrasts10.red4570,
73
- placeholderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts11 = colors.contrasts) === null || _colors$contrasts11 === void 0 ? void 0 : _colors$contrasts11.grey4570,
74
- mediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
75
- mediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
76
- largeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
77
- largeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge
64
+ arrowsColor: colors?.contrasts?.grey125125,
65
+ arrowsBackgroundColor: colors?.contrasts?.grey1111,
66
+ arrowsHoverBackgroundColor: colors?.contrasts?.grey1214,
67
+ arrowsBorderColor: colors?.contrasts?.grey3045,
68
+ arrowsActiveBoxShadow: `inset 0 0 3px 1px ${colors?.contrasts?.grey1214}`,
69
+ focusOutlineWidth: borders?.widthMedium,
70
+ focusOutlineStyle: borders?.style,
71
+ focusOutlineColor: colors?.contrasts?.blue4570,
72
+ errorBorderColor: colors?.contrasts?.red4570,
73
+ errorOutlineColor: colors?.contrasts?.red4570,
74
+ placeholderColor: colors?.contrasts?.grey4570,
75
+ mediumFontSize: typography?.fontSizeMedium,
76
+ mediumHeight: forms?.inputHeightMedium,
77
+ largeFontSize: typography?.fontSizeLarge,
78
+ largeHeight: forms?.inputHeightLarge
78
79
  };
79
80
  return {
80
81
  ...componentVariables,
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.NumberInput = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
8
  var _react = require("react");
11
9
  var _keycode = _interopRequireDefault(require("keycode"));
12
10
  var _latest = require("@instructure/ui-form-field/latest");
@@ -19,7 +17,6 @@ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProp
19
17
  var _emotion = require("@instructure/emotion");
20
18
  var _styles = _interopRequireDefault(require("./styles"));
21
19
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
- 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"];
23
20
  /*
24
21
  * The MIT License (MIT)
25
22
  *
@@ -43,6 +40,7 @@ const _excluded = ["messages", "isRequired", "showArrows", "size", "display", "t
43
40
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44
41
  * SOFTWARE.
45
42
  */
43
+
46
44
  /**
47
45
  ---
48
46
  category: components
@@ -50,58 +48,42 @@ id: NumberInput
50
48
  ---
51
49
  **/
52
50
  const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
53
- var _ChevronUpInstUIIcon, _ChevronDownInstUIIco;
54
- const _props$messages = props.messages,
55
- messages = _props$messages === void 0 ? [] : _props$messages,
56
- _props$isRequired = props.isRequired,
57
- isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
58
- _props$showArrows = props.showArrows,
59
- showArrows = _props$showArrows === void 0 ? true : _props$showArrows,
60
- _props$size = props.size,
61
- size = _props$size === void 0 ? 'medium' : _props$size,
62
- _props$display = props.display,
63
- display = _props$display === void 0 ? 'block' : _props$display,
64
- _props$textAlign = props.textAlign,
65
- textAlign = _props$textAlign === void 0 ? 'start' : _props$textAlign,
66
- _props$inputMode = props.inputMode,
67
- inputMode = _props$inputMode === void 0 ? 'numeric' : _props$inputMode,
68
- _props$allowStringVal = props.allowStringValue,
69
- allowStringValue = _props$allowStringVal === void 0 ? false : _props$allowStringVal,
70
- renderLabel = props.renderLabel,
71
- placeholder = props.placeholder,
72
- value = props.value,
73
- width = props.width,
74
- renderIcons = props.renderIcons,
75
- margin = props.margin,
76
- inputRefProp = props.inputRef,
77
- onFocus = props.onFocus,
78
- onBlur = props.onBlur,
79
- onChange = props.onChange,
80
- onKeyDown = props.onKeyDown,
81
- onDecrement = props.onDecrement,
82
- onIncrement = props.onIncrement,
83
- idProp = props.id,
84
- themeOverride = props.themeOverride,
85
- rest = (0, _objectWithoutProperties2.default)(props, _excluded);
51
+ const {
52
+ messages = [],
53
+ isRequired = false,
54
+ showArrows = true,
55
+ size = 'medium',
56
+ display = 'block',
57
+ textAlign = 'start',
58
+ inputMode = 'numeric',
59
+ allowStringValue = false,
60
+ renderLabel,
61
+ placeholder,
62
+ value,
63
+ width,
64
+ renderIcons,
65
+ margin,
66
+ inputRef: inputRefProp,
67
+ onFocus,
68
+ onBlur,
69
+ onChange,
70
+ onKeyDown,
71
+ onDecrement,
72
+ onIncrement,
73
+ id: idProp,
74
+ themeOverride,
75
+ ...rest
76
+ } = props;
86
77
  // these are icon tokens
87
78
 
88
- const _useState = (0, _react.useState)('actionSecondaryBaseColor'),
89
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
90
- upButtonState = _useState2[0],
91
- setUpButtonState = _useState2[1];
92
- const _useState3 = (0, _react.useState)('actionSecondaryBaseColor'),
93
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
94
- downButtonState = _useState4[0],
95
- setDownButtonState = _useState4[1];
79
+ const [upButtonState, setUpButtonState] = (0, _react.useState)('actionSecondaryBaseColor');
80
+ const [downButtonState, setDownButtonState] = (0, _react.useState)('actionSecondaryBaseColor');
96
81
  // Refs
97
82
  const containerRef = (0, _react.useRef)(null);
98
83
  const inputRef = (0, _react.useRef)(null);
99
84
 
100
85
  // Deterministic ID generation
101
- const _useState5 = (0, _react.useState)(),
102
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
103
- deterministicId = _useState6[0],
104
- setDeterministicId = _useState6[1];
86
+ const [deterministicId, setDeterministicId] = (0, _react.useState)();
105
87
  const getId = (0, _useDeterministicId.useDeterministicId)('NumberInput');
106
88
  (0, _react.useEffect)(() => {
107
89
  setDeterministicId(getId());
@@ -182,8 +164,7 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
182
164
  const arrowClicked = (0, _react.useCallback)((event, callback) => {
183
165
  event.preventDefault();
184
166
  if (interaction === 'enabled') {
185
- var _inputRef$current;
186
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
167
+ inputRef.current?.focus();
187
168
  if (typeof callback === 'function') {
188
169
  callback(event);
189
170
  }
@@ -201,8 +182,7 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
201
182
  // Expose imperative API via ref
202
183
  (0, _react.useImperativeHandle)(ref, () => ({
203
184
  focus: () => {
204
- var _inputRef$current2;
205
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
185
+ inputRef.current?.focus();
206
186
  },
207
187
  get id() {
208
188
  return id;
@@ -214,8 +194,7 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
214
194
  return interaction;
215
195
  },
216
196
  get value() {
217
- var _inputRef$current3;
218
- return (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value;
197
+ return inputRef.current?.value;
219
198
  },
220
199
  ref: containerRef
221
200
  }), [id, invalid, interaction]);
@@ -223,31 +202,31 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
223
202
  // Render methods
224
203
  const renderArrows = customIcons => {
225
204
  return (0, _jsxRuntime.jsxs)("span", {
226
- css: styles === null || styles === void 0 ? void 0 : styles.arrowContainer,
205
+ css: styles?.arrowContainer,
227
206
  children: [(0, _jsxRuntime.jsx)("button", {
228
207
  "aria-hidden": true,
229
- css: styles === null || styles === void 0 ? void 0 : styles.arrow,
208
+ css: styles?.arrow,
230
209
  onMouseDown: handleClickUpArrow,
231
210
  onMouseOver: () => setUpButtonState('actionSecondaryHoverColor'),
232
211
  onMouseOut: () => setUpButtonState('actionSecondaryBaseColor'),
233
212
  tabIndex: -1,
234
213
  type: "button",
235
- children: customIcons !== null && customIcons !== void 0 && customIcons.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : _ChevronUpInstUIIcon || (_ChevronUpInstUIIcon = (0, _jsxRuntime.jsx)(_uiIcons.ChevronUpInstUIIcon, {
214
+ children: customIcons?.increase ? (0, _callRenderProp.callRenderProp)(customIcons.increase) : (0, _jsxRuntime.jsx)(_uiIcons.ChevronUpInstUIIcon, {
236
215
  size: "sm",
237
216
  color: upButtonState
238
- }))
217
+ })
239
218
  }), (0, _jsxRuntime.jsx)("button", {
240
219
  "aria-hidden": true,
241
- css: styles === null || styles === void 0 ? void 0 : styles.arrow,
220
+ css: styles?.arrow,
242
221
  onMouseDown: handleClickDownArrow,
243
222
  onMouseOver: () => setDownButtonState('actionSecondaryHoverColor'),
244
223
  onMouseOut: () => setDownButtonState('actionSecondaryBaseColor'),
245
224
  tabIndex: -1,
246
225
  type: "button",
247
- children: customIcons !== null && customIcons !== void 0 && customIcons.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : _ChevronDownInstUIIco || (_ChevronDownInstUIIco = (0, _jsxRuntime.jsx)(_uiIcons.ChevronDownInstUIIcon, {
226
+ children: customIcons?.decrease ? (0, _callRenderProp.callRenderProp)(customIcons.decrease) : (0, _jsxRuntime.jsx)(_uiIcons.ChevronDownInstUIIcon, {
248
227
  size: "sm",
249
228
  color: downButtonState
250
- }))
229
+ })
251
230
  })]
252
231
  });
253
232
  };
@@ -270,20 +249,20 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
270
249
  readOnly: interaction === 'readonly',
271
250
  "data-cid": "NumberInput",
272
251
  children: (0, _jsxRuntime.jsx)("span", {
273
- css: styles === null || styles === void 0 ? void 0 : styles.inputWidth,
252
+ css: styles?.inputWidth,
274
253
  style: width ? {
275
254
  width
276
- } : void 0,
255
+ } : undefined,
277
256
  children: (0, _jsxRuntime.jsxs)("span", {
278
- css: styles === null || styles === void 0 ? void 0 : styles.inputContainer,
257
+ css: styles?.inputContainer,
279
258
  children: [(0, _jsxRuntime.jsx)("input", {
280
259
  ...passedProps,
281
- css: styles === null || styles === void 0 ? void 0 : styles.input,
282
- "aria-invalid": invalid ? 'true' : void 0,
260
+ css: styles?.input,
261
+ "aria-invalid": invalid ? 'true' : undefined,
283
262
  id: id,
284
263
  type: allowStringValue ? 'text' : 'number',
285
264
  inputMode: inputMode,
286
- placeholder: interaction === 'enabled' ? placeholder : void 0,
265
+ placeholder: interaction === 'enabled' ? placeholder : undefined,
287
266
  ref: handleInputRef,
288
267
  required: isRequired,
289
268
  value: value,
@@ -40,11 +40,13 @@ var _emotion = require("@instructure/emotion");
40
40
  * @return The final style object, which will be used in the component
41
41
  */
42
42
  const generateStyle = (componentTheme, params, sharedTokens) => {
43
- const size = params.size,
44
- textAlign = params.textAlign,
45
- interaction = params.interaction,
46
- success = params.success,
47
- invalid = params.invalid;
43
+ const {
44
+ size,
45
+ textAlign,
46
+ interaction,
47
+ success,
48
+ invalid
49
+ } = params;
48
50
  const containerInteractionStates = {
49
51
  ...(interaction === 'enabled' && {
50
52
  backgroundColor: componentTheme.backgroundColor,