orc-shared 5.10.2-dev.1 → 5.10.2-dev.3

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,6 +9,8 @@ var _InputBaseProps = _interopRequireWildcard(require("./InputBaseProps"));
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _reactNumberFormat = require("react-number-format");
11
11
  var _inputHelper = require("../../../utils/inputHelper");
12
+ var _Icon = _interopRequireDefault(require("../DataDisplay/Icon"));
13
+ var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
12
14
  var _excluded = ["inputRef", "onChange"];
13
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -21,17 +23,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
21
23
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
22
24
  enterModule && enterModule(module);
23
25
  })();
26
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
28
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
29
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
30
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
31
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
25
32
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
33
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
27
34
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
28
35
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
29
36
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
30
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
33
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
34
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
35
37
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
36
38
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
37
39
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
@@ -76,13 +78,21 @@ var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
76
78
  minWidth: 0,
77
79
  border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.grey.borders),
78
80
  borderRadius: function borderRadius(props) {
79
- return props.label ? theme.spacing(0, 0.5, 0.5, 0) : theme.spacing(0.5);
81
+ var topLeft = props.label ? 0 : 0.5;
82
+ var topRight = props.isAdvancedNumericInput ? 0 : 0.5;
83
+ var bottomRight = topRight;
84
+ var bottomLeft = topLeft;
85
+ return theme.spacing(topLeft, topRight, bottomRight, bottomLeft);
80
86
  },
81
87
  paddingLeft: theme.spacing(0.85),
82
88
  "&:focus, &:active": {
83
89
  border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.focus),
84
90
  borderRadius: function borderRadius(props) {
85
- return props.label ? theme.spacing(0, 0.5, 0.5, 0) : theme.spacing(0.5);
91
+ var topLeft = props.label ? 0 : 0.5;
92
+ var topRight = props.isAdvancedNumericInput ? 0 : 0.5;
93
+ var bottomRight = topRight;
94
+ var bottomLeft = topLeft;
95
+ return theme.spacing(topLeft, topRight, bottomRight, bottomLeft);
86
96
  }
87
97
  }
88
98
  },
@@ -119,6 +129,41 @@ var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
119
129
  },
120
130
  inputMultiline: {
121
131
  padding: theme.spacing(0.6, 0.6, 0.6, 0.85)
132
+ },
133
+ numericSpinnerContainer: {
134
+ display: "flex",
135
+ backgroundColor: theme.palette.grey.light,
136
+ flexDirection: "column",
137
+ borderTopLeftRadius: 0,
138
+ borderBottomLeftRadius: 0,
139
+ borderTopRightRadius: theme.shape.borderRadius,
140
+ borderBottomRightRadius: theme.shape.borderRadius,
141
+ border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.grey.borders),
142
+ padding: 0,
143
+ margin: "0 0 0 -1px"
144
+ },
145
+ numericSpinnerUp: {
146
+ fontSize: "8px",
147
+ padding: "0 3px",
148
+ borderBottom: "1px solid #CCCCCC",
149
+ borderRadius: 0,
150
+ flex: 1,
151
+ margin: 0,
152
+ width: "20px",
153
+ "& + .MuiButton-root, & + .MuiIconButton-root, & + .MuiInputBase-root": {
154
+ marginLeft: 0
155
+ }
156
+ },
157
+ numericSpinnerDown: {
158
+ fontSize: "8px",
159
+ padding: "0 3px",
160
+ borderRadius: 0,
161
+ flex: 1,
162
+ margin: 0,
163
+ marginLeft: 0,
164
+ "& + .MuiButton-root, & + .MuiIconButton-root, & + .MuiInputBase-root": {
165
+ marginLeft: 0
166
+ }
122
167
  }
123
168
  };
124
169
  });
@@ -168,6 +213,19 @@ var InputBase = function InputBase(_ref) {
168
213
  var isAdvancedNumericInput = type.toLowerCase() === "advancednumericinput";
169
214
  var inputComponent = isAdvancedNumericInput ? AdvancedNumericInput : undefined;
170
215
  var inputControlType = isAdvancedNumericInput ? "text" : type;
216
+ var _React$useState = _react.default.useState(null),
217
+ _React$useState2 = _slicedToArray(_React$useState, 2),
218
+ inputText = _React$useState2[0],
219
+ setInputText = _React$useState2[1];
220
+ var textToDisplay = inputText != null ? inputText : value;
221
+ var classes = useStyles({
222
+ label: label,
223
+ errorPosition: errorPosition,
224
+ isAdvancedNumericInput: isAdvancedNumericInput
225
+ });
226
+ var controlSpecificSuffix = null;
227
+ var onKeyDown = null;
228
+ var onWheel = null;
171
229
  if (isAdvancedNumericInput && numericInputProps) {
172
230
  Object.keys(numericInputProps).forEach(function (key) {
173
231
  if (key !== "blurFormattingSkipFixedDecimalScale") {
@@ -190,6 +248,106 @@ var InputBase = function InputBase(_ref) {
190
248
  inputAttributes.isAllowed = function (val) {
191
249
  return val.value === "" || val.value === "-" || val.value !== null;
192
250
  };
251
+ if (decimalScale === 0 && !disabled) {
252
+ var getInitialNumericValue = function getInitialNumericValue() {
253
+ if (0 >= inputAttributes.min && 0 <= inputAttributes.max) {
254
+ return 0;
255
+ }
256
+ if (Math.abs(inputAttributes.min) < Math.abs(inputAttributes.max)) {
257
+ return inputAttributes.min;
258
+ }
259
+ return inputAttributes.max;
260
+ };
261
+ var increaseNumericValue = function increaseNumericValue() {
262
+ if (textToDisplay) {
263
+ var currentValue = parseInt(textToDisplay, 10);
264
+ if (currentValue + 1 <= inputAttributes.max) {
265
+ setInputText((currentValue + 1).toString());
266
+ }
267
+ } else {
268
+ var _currentValue = getInitialNumericValue();
269
+ if (_currentValue === 0 && _currentValue + 1 <= inputAttributes.max) {
270
+ _currentValue++;
271
+ }
272
+ setInputText(_currentValue.toString());
273
+ }
274
+ };
275
+ var decreaseNumericValue = function decreaseNumericValue() {
276
+ if (textToDisplay) {
277
+ var currentValue = parseInt(textToDisplay, 10);
278
+ if (currentValue - 1 >= inputAttributes.min) {
279
+ setInputText((currentValue - 1).toString());
280
+ }
281
+ } else {
282
+ var _currentValue2 = getInitialNumericValue();
283
+ if (_currentValue2 === 0 && _currentValue2 - 1 >= inputAttributes.min) {
284
+ _currentValue2--;
285
+ }
286
+ setInputText(_currentValue2.toString());
287
+ }
288
+ };
289
+ var focusInput = function focusInput(target) {
290
+ target.closest(".InputBase-input-wrapper").getElementsByTagName("input")[0].focus();
291
+ };
292
+ controlSpecificSuffix = /*#__PURE__*/_react.default.createElement("div", {
293
+ className: classes.numericSpinnerContainer
294
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
295
+ className: classes.numericSpinnerUp,
296
+ tabIndex: "-1",
297
+ "data-qa": "increase",
298
+ disabled: disabled,
299
+ onMouseDown: function onMouseDown(event) {
300
+ return event.preventDefault();
301
+ } // prevent the button from stealing focus
302
+ ,
303
+ onClick: function onClick(event) {
304
+ event.preventDefault();
305
+ event.stopPropagation();
306
+ increaseNumericValue();
307
+ focusInput(event.target);
308
+ }
309
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
310
+ id: "chevron-up"
311
+ })), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
312
+ className: classes.numericSpinnerDown,
313
+ tabIndex: "-1",
314
+ "data-qa": "decrease",
315
+ disabled: disabled,
316
+ onMouseDown: function onMouseDown(event) {
317
+ return event.preventDefault();
318
+ } // prevent the button from stealing focus
319
+ ,
320
+ onClick: function onClick(event) {
321
+ event.preventDefault();
322
+ event.stopPropagation();
323
+ decreaseNumericValue();
324
+ focusInput(event.target);
325
+ }
326
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
327
+ id: "chevron-down"
328
+ })));
329
+ onKeyDown = function onKeyDown(event) {
330
+ if (event.key === "ArrowUp") {
331
+ event.preventDefault();
332
+ event.stopPropagation();
333
+ increaseNumericValue();
334
+ }
335
+ // Note Alex20260119: using an 'else if' caused issue with code coverage
336
+ if (event.key === "ArrowDown") {
337
+ event.preventDefault();
338
+ event.stopPropagation();
339
+ decreaseNumericValue();
340
+ }
341
+ };
342
+ onWheel = function onWheel(event) {
343
+ if (event.deltaY < 0) {
344
+ increaseNumericValue();
345
+ } else {
346
+ decreaseNumericValue();
347
+ }
348
+ focusInput(event.target);
349
+ };
350
+ }
193
351
  }
194
352
  var defaultRows = 4;
195
353
  var rows = rowsProps;
@@ -200,10 +358,6 @@ var InputBase = function InputBase(_ref) {
200
358
  // causing onBlur to never fire
201
359
  item.target.focus();
202
360
  };
203
- var classes = useStyles({
204
- label: label,
205
- errorPosition: errorPosition
206
- });
207
361
  var onChangeHandler = function onChangeHandler(event) {
208
362
  if (event.persist) {
209
363
  event.persist();
@@ -245,11 +399,6 @@ var InputBase = function InputBase(_ref) {
245
399
  };
246
400
  var inputBaseInputStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.input);
247
401
  var errorTextStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.errorText);
248
- var _React$useState = _react.default.useState(null),
249
- _React$useState2 = _slicedToArray(_React$useState, 2),
250
- inputText = _React$useState2[0],
251
- setInputText = _React$useState2[1];
252
- var textToDisplay = inputText != null ? inputText : value;
253
402
  _react.default.useEffect(function () {
254
403
  if (inputText === null || window.bypassDebounce === true) {
255
404
  return;
@@ -277,7 +426,12 @@ var InputBase = function InputBase(_ref) {
277
426
  className: classes.inputContainer
278
427
  }, label && /*#__PURE__*/_react.default.createElement("label", {
279
428
  className: "".concat(classes.prepend, " ").concat(disabled && classes.disabledPrepend)
280
- }, label), /*#__PURE__*/_react.default.createElement(_InputBase.default, {
429
+ }, label), /*#__PURE__*/_react.default.createElement("div", {
430
+ style: {
431
+ display: "flex"
432
+ },
433
+ className: "InputBase-input-wrapper"
434
+ }, /*#__PURE__*/_react.default.createElement(_InputBase.default, {
281
435
  classes: {
282
436
  input: (0, _classnames.default)(classes.controlInput, inputBaseInputStyle),
283
437
  error: classes.errorInput,
@@ -291,6 +445,8 @@ var InputBase = function InputBase(_ref) {
291
445
  placeholder: placeholder,
292
446
  value: textToDisplay,
293
447
  fullWidth: true,
448
+ onKeyDown: onKeyDown,
449
+ onWheel: onWheel,
294
450
  onChange: function onChange(event) {
295
451
  return onChangeHandler(event);
296
452
  },
@@ -304,14 +460,14 @@ var InputBase = function InputBase(_ref) {
304
460
  minRows: rows,
305
461
  title: tooltipText,
306
462
  autoComplete: autoComplete
307
- })), error && /*#__PURE__*/_react.default.createElement("div", {
463
+ }), controlSpecificSuffix)), error && /*#__PURE__*/_react.default.createElement("div", {
308
464
  className: (0, _classnames.default)(classes.errorText, errorTextStyle)
309
465
  }, error));
310
466
  };
311
- __signature__(InputBase, "useStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseState{[inputText, setInputText](null)}\nuseEffect{}", function () {
467
+ __signature__(InputBase, "useState{[inputText, setInputText](null)}\nuseStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseEffect{}", function () {
312
468
  return [useStyles];
313
469
  });
314
- __signature__(InputBase, "useStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseState{[inputText, setInputText](null)}\nuseEffect{}", function () {
470
+ __signature__(InputBase, "useState{[inputText, setInputText](null)}\nuseStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseEffect{}", function () {
315
471
  return [useStyles];
316
472
  });
317
473
  var compareInputBase = function compareInputBase(prev, next) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.10.2-dev.1",
3
+ "version": "5.10.2-dev.3",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -50,7 +50,9 @@ describe("Translations ", () => {
50
50
  <div>
51
51
  <div>
52
52
  <label>{"en-US"}</label>
53
- <InputBase />
53
+ <div>
54
+ <InputBase />
55
+ </div>
54
56
  </div>
55
57
  </div>
56
58
  </div>
@@ -61,7 +63,9 @@ describe("Translations ", () => {
61
63
  <div>
62
64
  <div>
63
65
  <label>{"en-CA"}</label>
64
- <InputBase />
66
+ <div>
67
+ <InputBase />
68
+ </div>
65
69
  </div>
66
70
  </div>
67
71
  </div>,
@@ -69,7 +73,9 @@ describe("Translations ", () => {
69
73
  <div>
70
74
  <div>
71
75
  <label>{"fr-CA"}</label>
72
- <InputBase />
76
+ <div>
77
+ <InputBase />
78
+ </div>
73
79
  </div>
74
80
  </div>
75
81
  </div>,
@@ -102,7 +108,9 @@ describe("Translations ", () => {
102
108
  <div>
103
109
  <div>
104
110
  <label>{"en-US"}</label>
105
- <InputBase />
111
+ <div>
112
+ <InputBase />
113
+ </div>
106
114
  </div>
107
115
  <div>{aError}</div>
108
116
  </div>
@@ -114,7 +122,9 @@ describe("Translations ", () => {
114
122
  <div>
115
123
  <div>
116
124
  <label>{"en-CA"}</label>
117
- <InputBase />
125
+ <div>
126
+ <InputBase />
127
+ </div>
118
128
  </div>
119
129
  </div>
120
130
  </div>,
@@ -122,7 +132,9 @@ describe("Translations ", () => {
122
132
  <div>
123
133
  <div>
124
134
  <label>{"fr-CA"}</label>
125
- <InputBase />
135
+ <div>
136
+ <InputBase />
137
+ </div>
126
138
  </div>
127
139
  </div>
128
140
  </div>,
@@ -5,6 +5,8 @@ import InputBaseProps, { isInputProps } from "./InputBaseProps";
5
5
  import classNames from "classnames";
6
6
  import { NumericFormat, numericFormatter } from "react-number-format";
7
7
  import { trimSpacesAndLeadingZeros } from "../../../utils/inputHelper";
8
+ import Icon from "../DataDisplay/Icon";
9
+ import IconButton from "@material-ui/core/IconButton";
8
10
 
9
11
  export const useStyles = makeStyles(theme => ({
10
12
  container: {
@@ -39,11 +41,25 @@ export const useStyles = makeStyles(theme => ({
39
41
  maxWidth: "unset",
40
42
  minWidth: 0,
41
43
  border: `${theme.spacing(0.1)} solid ${theme.palette.grey.borders}`,
42
- borderRadius: props => (props.label ? theme.spacing(0, 0.5, 0.5, 0) : theme.spacing(0.5)),
44
+ borderRadius: props => {
45
+ const topLeft = props.label ? 0 : 0.5;
46
+ const topRight = props.isAdvancedNumericInput ? 0 : 0.5;
47
+ const bottomRight = topRight;
48
+ const bottomLeft = topLeft;
49
+
50
+ return theme.spacing(topLeft, topRight, bottomRight, bottomLeft);
51
+ },
43
52
  paddingLeft: theme.spacing(0.85),
44
53
  "&:focus, &:active": {
45
54
  border: `${theme.spacing(0.1)} solid ${theme.palette.focus}`,
46
- borderRadius: props => (props.label ? theme.spacing(0, 0.5, 0.5, 0) : theme.spacing(0.5)),
55
+ borderRadius: props => {
56
+ const topLeft = props.label ? 0 : 0.5;
57
+ const topRight = props.isAdvancedNumericInput ? 0 : 0.5;
58
+ const bottomRight = topRight;
59
+ const bottomLeft = topLeft;
60
+
61
+ return theme.spacing(topLeft, topRight, bottomRight, bottomLeft);
62
+ },
47
63
  },
48
64
  },
49
65
  errorInput: {
@@ -79,6 +95,41 @@ export const useStyles = makeStyles(theme => ({
79
95
  inputMultiline: {
80
96
  padding: theme.spacing(0.6, 0.6, 0.6, 0.85),
81
97
  },
98
+ numericSpinnerContainer: {
99
+ display: "flex",
100
+ backgroundColor: theme.palette.grey.light,
101
+ flexDirection: "column",
102
+ borderTopLeftRadius: 0,
103
+ borderBottomLeftRadius: 0,
104
+ borderTopRightRadius: theme.shape.borderRadius,
105
+ borderBottomRightRadius: theme.shape.borderRadius,
106
+ border: `${theme.spacing(0.1)} solid ${theme.palette.grey.borders}`,
107
+ padding: 0,
108
+ margin: "0 0 0 -1px",
109
+ },
110
+ numericSpinnerUp: {
111
+ fontSize: "8px",
112
+ padding: "0 3px",
113
+ borderBottom: "1px solid #CCCCCC",
114
+ borderRadius: 0,
115
+ flex: 1,
116
+ margin: 0,
117
+ width: "20px",
118
+ "& + .MuiButton-root, & + .MuiIconButton-root, & + .MuiInputBase-root": {
119
+ marginLeft: 0,
120
+ },
121
+ },
122
+ numericSpinnerDown: {
123
+ fontSize: "8px",
124
+ padding: "0 3px",
125
+ borderRadius: 0,
126
+ flex: 1,
127
+ margin: 0,
128
+ marginLeft: 0,
129
+ "& + .MuiButton-root, & + .MuiIconButton-root, & + .MuiInputBase-root": {
130
+ marginLeft: 0,
131
+ },
132
+ },
82
133
  }));
83
134
 
84
135
  export const AdvancedNumericInput = props => {
@@ -129,6 +180,13 @@ const InputBase = ({ inputProps }) => {
129
180
  const isAdvancedNumericInput = type.toLowerCase() === "advancednumericinput";
130
181
  const inputComponent = isAdvancedNumericInput ? AdvancedNumericInput : undefined;
131
182
  const inputControlType = isAdvancedNumericInput ? "text" : type;
183
+ const [inputText, setInputText] = React.useState(null);
184
+ const textToDisplay = inputText ?? value;
185
+ const classes = useStyles({ label, errorPosition, isAdvancedNumericInput });
186
+
187
+ let controlSpecificSuffix = null;
188
+ let onKeyDown = null;
189
+ let onWheel = null;
132
190
 
133
191
  if (isAdvancedNumericInput && numericInputProps) {
134
192
  Object.keys(numericInputProps).forEach(key => {
@@ -157,6 +215,115 @@ const InputBase = ({ inputProps }) => {
157
215
  inputAttributes.isAllowed = val => {
158
216
  return val.value === "" || val.value === "-" || val.value !== null;
159
217
  };
218
+
219
+ if (decimalScale === 0 && !disabled) {
220
+ const getInitialNumericValue = () => {
221
+ if (0 >= inputAttributes.min && 0 <= inputAttributes.max) {
222
+ return 0;
223
+ }
224
+
225
+ if (Math.abs(inputAttributes.min) < Math.abs(inputAttributes.max)) {
226
+ return inputAttributes.min;
227
+ }
228
+
229
+ return inputAttributes.max;
230
+ };
231
+
232
+ const increaseNumericValue = () => {
233
+ if (textToDisplay) {
234
+ const currentValue = parseInt(textToDisplay, 10);
235
+ if (currentValue + 1 <= inputAttributes.max) {
236
+ setInputText((currentValue + 1).toString());
237
+ }
238
+ } else {
239
+ let currentValue = getInitialNumericValue();
240
+ if (currentValue === 0 && currentValue + 1 <= inputAttributes.max) {
241
+ currentValue++;
242
+ }
243
+ setInputText(currentValue.toString());
244
+ }
245
+ };
246
+ const decreaseNumericValue = () => {
247
+ if (textToDisplay) {
248
+ const currentValue = parseInt(textToDisplay, 10);
249
+ if (currentValue - 1 >= inputAttributes.min) {
250
+ setInputText((currentValue - 1).toString());
251
+ }
252
+ } else {
253
+ let currentValue = getInitialNumericValue();
254
+ if (currentValue === 0 && currentValue - 1 >= inputAttributes.min) {
255
+ currentValue--;
256
+ }
257
+ setInputText(currentValue.toString());
258
+ }
259
+ };
260
+
261
+ const focusInput = target => {
262
+ target.closest(".InputBase-input-wrapper").getElementsByTagName("input")[0].focus();
263
+ };
264
+
265
+ controlSpecificSuffix = (
266
+ <div className={classes.numericSpinnerContainer}>
267
+ <IconButton
268
+ className={classes.numericSpinnerUp}
269
+ tabIndex="-1"
270
+ data-qa="increase"
271
+ disabled={disabled}
272
+ onMouseDown={event => event.preventDefault()} // prevent the button from stealing focus
273
+ onClick={event => {
274
+ event.preventDefault();
275
+ event.stopPropagation();
276
+ increaseNumericValue();
277
+ focusInput(event.target);
278
+ }}
279
+ >
280
+ <Icon id="chevron-up" />
281
+ </IconButton>
282
+
283
+ <IconButton
284
+ className={classes.numericSpinnerDown}
285
+ tabIndex="-1"
286
+ data-qa="decrease"
287
+ disabled={disabled}
288
+ onMouseDown={event => event.preventDefault()} // prevent the button from stealing focus
289
+ onClick={event => {
290
+ event.preventDefault();
291
+ event.stopPropagation();
292
+ decreaseNumericValue();
293
+ focusInput(event.target);
294
+ }}
295
+ >
296
+ <Icon id="chevron-down" />
297
+ </IconButton>
298
+ </div>
299
+ );
300
+
301
+ onKeyDown = event => {
302
+ if (event.key === "ArrowUp") {
303
+ event.preventDefault();
304
+ event.stopPropagation();
305
+
306
+ increaseNumericValue();
307
+ }
308
+ // Note Alex20260119: using an 'else if' caused issue with code coverage
309
+ if (event.key === "ArrowDown") {
310
+ event.preventDefault();
311
+ event.stopPropagation();
312
+
313
+ decreaseNumericValue();
314
+ }
315
+ };
316
+
317
+ onWheel = event => {
318
+ if (event.deltaY < 0) {
319
+ increaseNumericValue();
320
+ } else {
321
+ decreaseNumericValue();
322
+ }
323
+
324
+ focusInput(event.target);
325
+ };
326
+ }
160
327
  }
161
328
 
162
329
  const defaultRows = 4;
@@ -170,7 +337,6 @@ const InputBase = ({ inputProps }) => {
170
337
  // causing onBlur to never fire
171
338
  item.target.focus();
172
339
  };
173
- const classes = useStyles({ label, errorPosition });
174
340
 
175
341
  const onChangeHandler = event => {
176
342
  if (event.persist) {
@@ -222,8 +388,6 @@ const InputBase = ({ inputProps }) => {
222
388
 
223
389
  const inputBaseInputStyle = inputProps?.getStyle(InputBaseProps.ruleNames.input);
224
390
  const errorTextStyle = inputProps?.getStyle(InputBaseProps.ruleNames.errorText);
225
- const [inputText, setInputText] = React.useState(null);
226
- const textToDisplay = inputText ?? value;
227
391
 
228
392
  React.useEffect(() => {
229
393
  if (inputText === null || window.bypassDebounce === true) {
@@ -253,32 +417,37 @@ const InputBase = ({ inputProps }) => {
253
417
  <div className={classes.container}>
254
418
  <div className={classes.inputContainer}>
255
419
  {label && <label className={`${classes.prepend} ${disabled && classes.disabledPrepend}`}>{label}</label>}
256
- <InputBaseMUI
257
- classes={{
258
- input: classNames(classes.controlInput, inputBaseInputStyle),
259
- error: classes.errorInput,
260
- disabled: classes.disabled,
261
- multiline: classes.multiline,
262
- inputMultiline: classes.inputMultiline,
263
- }}
264
- onBlur={onBlurInternal}
265
- onClick={onClick}
266
- type={inputControlType}
267
- placeholder={placeholder}
268
- value={textToDisplay}
269
- fullWidth={true}
270
- onChange={event => onChangeHandler(event)}
271
- error={!!error}
272
- inputProps={inputAttributes}
273
- inputComponent={inputComponent}
274
- disabled={disabled}
275
- multiline={multiline}
276
- startAdornment={startAdornment}
277
- endAdornment={endAdornment}
278
- minRows={rows}
279
- title={tooltipText}
280
- autoComplete={autoComplete}
281
- />
420
+ <div style={{ display: "flex" }} className="InputBase-input-wrapper">
421
+ <InputBaseMUI
422
+ classes={{
423
+ input: classNames(classes.controlInput, inputBaseInputStyle),
424
+ error: classes.errorInput,
425
+ disabled: classes.disabled,
426
+ multiline: classes.multiline,
427
+ inputMultiline: classes.inputMultiline,
428
+ }}
429
+ onBlur={onBlurInternal}
430
+ onClick={onClick}
431
+ type={inputControlType}
432
+ placeholder={placeholder}
433
+ value={textToDisplay}
434
+ fullWidth={true}
435
+ onKeyDown={onKeyDown}
436
+ onWheel={onWheel}
437
+ onChange={event => onChangeHandler(event)}
438
+ error={!!error}
439
+ inputProps={inputAttributes}
440
+ inputComponent={inputComponent}
441
+ disabled={disabled}
442
+ multiline={multiline}
443
+ startAdornment={startAdornment}
444
+ endAdornment={endAdornment}
445
+ minRows={rows}
446
+ title={tooltipText}
447
+ autoComplete={autoComplete}
448
+ />
449
+ {controlSpecificSuffix}
450
+ </div>
282
451
  </div>
283
452
  {error && <div className={classNames(classes.errorText, errorTextStyle)}>{error}</div>}
284
453
  </div>
@@ -317,7 +317,7 @@ describe("InputBase Component", () => {
317
317
  });
318
318
  });
319
319
 
320
- describe("InputBase component debouce", () => {
320
+ describe("InputBase component debounce", () => {
321
321
  const clock = sinon.useFakeTimers();
322
322
  let update, container;
323
323
 
@@ -946,4 +946,415 @@ describe("AdvancedNumericInput", () => {
946
946
 
947
947
  expect(update, "to have calls satisfying", [{ args: ["", metadata] }]);
948
948
  });
949
+
950
+ it("Change advanced numeric input value with decimal does not have the spinner buttons", () => {
951
+ const inputProps = new InputBaseProps();
952
+ const aLabel = "aLabel";
953
+ const aValue = "";
954
+
955
+ inputProps.set(InputBaseProps.propNames.update, update);
956
+ inputProps.set(InputBaseProps.propNames.value, aValue);
957
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
958
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
959
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
960
+
961
+ const component = <InputBase inputProps={inputProps} />;
962
+ const mountedComponent = mount(component);
963
+ const btn = mountedComponent.find("[data-qa='increase']");
964
+ expect(btn.length, "to be", 0);
965
+ });
966
+
967
+ it("Disabled advanced numeric input value without decimals should not have the increase/decrease buttons", () => {
968
+ const inputProps = new InputBaseProps();
969
+ const aLabel = "aLabel";
970
+ const aValue = "";
971
+
972
+ inputProps.set(InputBaseProps.propNames.update, update);
973
+ inputProps.set(InputBaseProps.propNames.value, aValue);
974
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
975
+ inputProps.set(InputBaseProps.propNames.disabled, true);
976
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
977
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
978
+
979
+ const component = <InputBase inputProps={inputProps} />;
980
+ const mountedComponent = mount(component);
981
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
982
+ expect(btn.length, "to equal", 0);
983
+ });
984
+
985
+ it("Advanced numeric input value without decimals, simulate onMouseDown to make code coverage happy", () => {
986
+ const inputProps = new InputBaseProps();
987
+ const aLabel = "aLabel";
988
+ const aValue = "";
989
+
990
+ inputProps.set(InputBaseProps.propNames.update, update);
991
+ inputProps.set(InputBaseProps.propNames.value, aValue);
992
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
993
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
994
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
995
+
996
+ const component = <InputBase inputProps={inputProps} />;
997
+ const mountedComponent = mount(component);
998
+ const btnIncrease = mountedComponent.find("[data-qa='increase']").hostNodes();
999
+ const btnDecrease = mountedComponent.find("[data-qa='decrease']").hostNodes();
1000
+
1001
+ btnIncrease.simulate("mouseDown");
1002
+ btnDecrease.simulate("mouseDown");
1003
+ });
1004
+
1005
+ it("Change advanced numeric input value, empty initial value with increase button", () => {
1006
+ const inputProps = new InputBaseProps();
1007
+ const aLabel = "aLabel";
1008
+ const aValue = "";
1009
+
1010
+ inputProps.set(InputBaseProps.propNames.update, update);
1011
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1012
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1013
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1014
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1015
+
1016
+ const component = <InputBase inputProps={inputProps} />;
1017
+ const mountedComponent = mount(component);
1018
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1019
+ btn.simulate("click");
1020
+
1021
+ expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
1022
+ });
1023
+
1024
+ it("Change advanced numeric input value, 1 initial value with increase button", () => {
1025
+ const inputProps = new InputBaseProps();
1026
+ const aLabel = "aLabel";
1027
+ const aValue = "1";
1028
+
1029
+ inputProps.set(InputBaseProps.propNames.update, update);
1030
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1031
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1032
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1033
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1034
+
1035
+ const component = <InputBase inputProps={inputProps} />;
1036
+ const mountedComponent = mount(component);
1037
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1038
+ btn.simulate("click");
1039
+
1040
+ expect(update, "to have calls satisfying", [{ args: ["2", null] }]);
1041
+ });
1042
+
1043
+ it("Change advanced numeric input value, 10 initial value with max 11 with increase button", () => {
1044
+ const inputProps = new InputBaseProps();
1045
+ const aLabel = "aLabel";
1046
+ const aValue = "10";
1047
+
1048
+ inputProps.set(InputBaseProps.propNames.update, update);
1049
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1050
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1051
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1052
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1053
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
1054
+
1055
+ const component = <InputBase inputProps={inputProps} />;
1056
+ const mountedComponent = mount(component);
1057
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1058
+ btn.simulate("click");
1059
+
1060
+ expect(update, "to have calls satisfying", [{ args: ["11", null] }]);
1061
+ });
1062
+
1063
+ it("Change advanced numeric input value, 11 initial value with max 11 with increase button stays at 11", () => {
1064
+ const inputProps = new InputBaseProps();
1065
+ const aLabel = "aLabel";
1066
+ const aValue = "11";
1067
+
1068
+ inputProps.set(InputBaseProps.propNames.update, update);
1069
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1070
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1071
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1072
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1073
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
1074
+
1075
+ const component = <InputBase inputProps={inputProps} />;
1076
+ const mountedComponent = mount(component);
1077
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1078
+ btn.simulate("click");
1079
+
1080
+ expect(update, "was not called");
1081
+ });
1082
+
1083
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
1084
+ const inputProps = new InputBaseProps();
1085
+ const aLabel = "aLabel";
1086
+ const aValue = "";
1087
+
1088
+ inputProps.set(InputBaseProps.propNames.update, update);
1089
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1090
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1091
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1092
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1093
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
1094
+
1095
+ const component = <InputBase inputProps={inputProps} />;
1096
+ const mountedComponent = mount(component);
1097
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1098
+ btn.simulate("click");
1099
+
1100
+ expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
1101
+ });
1102
+
1103
+ it("Change advanced numeric input value, empty initial value, min=-15, max=-5, increase button set value to -5", () => {
1104
+ const inputProps = new InputBaseProps();
1105
+ const aLabel = "aLabel";
1106
+ const aValue = "";
1107
+
1108
+ inputProps.set(InputBaseProps.propNames.update, update);
1109
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1110
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1111
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1112
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1113
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -15, max: -5 });
1114
+
1115
+ const component = <InputBase inputProps={inputProps} />;
1116
+ const mountedComponent = mount(component);
1117
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1118
+ btn.simulate("click");
1119
+
1120
+ expect(update, "to have calls satisfying", [{ args: ["-5", null] }]);
1121
+ });
1122
+
1123
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
1124
+ const inputProps = new InputBaseProps();
1125
+ const aLabel = "aLabel";
1126
+ const aValue = "";
1127
+
1128
+ inputProps.set(InputBaseProps.propNames.update, update);
1129
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1130
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1131
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1132
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1133
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
1134
+
1135
+ const component = <InputBase inputProps={inputProps} />;
1136
+ const mountedComponent = mount(component);
1137
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1138
+ btn.simulate("click");
1139
+
1140
+ expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
1141
+ });
1142
+
1143
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, key up set value to 1", () => {
1144
+ const inputProps = new InputBaseProps();
1145
+ const aLabel = "aLabel";
1146
+ const aValue = "";
1147
+
1148
+ inputProps.set(InputBaseProps.propNames.update, update);
1149
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1150
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1151
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1152
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1153
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
1154
+
1155
+ const component = <InputBase inputProps={inputProps} />;
1156
+ const mountedComponent = mount(component);
1157
+ const input = mountedComponent.find("input");
1158
+ input.simulate("keydown", { key: "ArrowUp" });
1159
+
1160
+ expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
1161
+ });
1162
+
1163
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll up set value to 1", () => {
1164
+ const inputProps = new InputBaseProps();
1165
+ const aLabel = "aLabel";
1166
+ const aValue = "";
1167
+
1168
+ inputProps.set(InputBaseProps.propNames.update, update);
1169
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1170
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1171
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1172
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1173
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
1174
+
1175
+ const component = <InputBase inputProps={inputProps} />;
1176
+ const mountedComponent = mount(component);
1177
+ const input = mountedComponent.find("input");
1178
+ input.simulate("wheel", { deltaY: -100 });
1179
+
1180
+ expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
1181
+ });
1182
+
1183
+ it("Change advanced numeric input value, empty initial value with decrease button", () => {
1184
+ const inputProps = new InputBaseProps();
1185
+ const aLabel = "aLabel";
1186
+ const aValue = "";
1187
+
1188
+ inputProps.set(InputBaseProps.propNames.update, update);
1189
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1190
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1191
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1192
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1193
+
1194
+ const component = <InputBase inputProps={inputProps} />;
1195
+ const mountedComponent = mount(component);
1196
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1197
+ btn.simulate("click");
1198
+
1199
+ expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
1200
+ });
1201
+
1202
+ it("Change advanced numeric input value, -1 initial value with decrease button", () => {
1203
+ const inputProps = new InputBaseProps();
1204
+ const aLabel = "aLabel";
1205
+ const aValue = "-1";
1206
+
1207
+ inputProps.set(InputBaseProps.propNames.update, update);
1208
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1209
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1210
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1211
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1212
+
1213
+ const component = <InputBase inputProps={inputProps} />;
1214
+ const mountedComponent = mount(component);
1215
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1216
+ btn.simulate("click");
1217
+
1218
+ expect(update, "to have calls satisfying", [{ args: ["-2", null] }]);
1219
+ });
1220
+
1221
+ it("Change advanced numeric input value, -10 initial value with min 11 with decrease button", () => {
1222
+ const inputProps = new InputBaseProps();
1223
+ const aLabel = "aLabel";
1224
+ const aValue = "-10";
1225
+
1226
+ inputProps.set(InputBaseProps.propNames.update, update);
1227
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1228
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1229
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1230
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1231
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
1232
+
1233
+ const component = <InputBase inputProps={inputProps} />;
1234
+ const mountedComponent = mount(component);
1235
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1236
+ btn.simulate("click");
1237
+
1238
+ expect(update, "to have calls satisfying", [{ args: ["-11", null] }]);
1239
+ });
1240
+
1241
+ it("Change advanced numeric input value, -11 initial value with min -11 with decrease button stays at -11", () => {
1242
+ const inputProps = new InputBaseProps();
1243
+ const aLabel = "aLabel";
1244
+ const aValue = "-11";
1245
+
1246
+ inputProps.set(InputBaseProps.propNames.update, update);
1247
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1248
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1249
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1250
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1251
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
1252
+
1253
+ const component = <InputBase inputProps={inputProps} />;
1254
+ const mountedComponent = mount(component);
1255
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1256
+ btn.simulate("click");
1257
+
1258
+ expect(update, "was not called");
1259
+ });
1260
+
1261
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button should set to 5", () => {
1262
+ const inputProps = new InputBaseProps();
1263
+ const aLabel = "aLabel";
1264
+ const aValue = "";
1265
+
1266
+ inputProps.set(InputBaseProps.propNames.update, update);
1267
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1268
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1269
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1270
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1271
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
1272
+
1273
+ const component = <InputBase inputProps={inputProps} />;
1274
+ const mountedComponent = mount(component);
1275
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1276
+ btn.simulate("click");
1277
+
1278
+ expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
1279
+ });
1280
+
1281
+ it("Change advanced numeric input value, empty initial value, min=-15, max=-5, decrease button set value to -5", () => {
1282
+ const inputProps = new InputBaseProps();
1283
+ const aLabel = "aLabel";
1284
+ const aValue = "";
1285
+
1286
+ inputProps.set(InputBaseProps.propNames.update, update);
1287
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1288
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1289
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1290
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1291
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -15, max: -5 });
1292
+
1293
+ const component = <InputBase inputProps={inputProps} />;
1294
+ const mountedComponent = mount(component);
1295
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1296
+ btn.simulate("click");
1297
+
1298
+ expect(update, "to have calls satisfying", [{ args: ["-5", null] }]);
1299
+ });
1300
+
1301
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button set value to 5", () => {
1302
+ const inputProps = new InputBaseProps();
1303
+ const aLabel = "aLabel";
1304
+ const aValue = "";
1305
+
1306
+ inputProps.set(InputBaseProps.propNames.update, update);
1307
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1308
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1309
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1310
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1311
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
1312
+
1313
+ const component = <InputBase inputProps={inputProps} />;
1314
+ const mountedComponent = mount(component);
1315
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1316
+ btn.simulate("click");
1317
+
1318
+ expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
1319
+ });
1320
+
1321
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, key down set value to 1", () => {
1322
+ const inputProps = new InputBaseProps();
1323
+ const aLabel = "aLabel";
1324
+ const aValue = "";
1325
+
1326
+ inputProps.set(InputBaseProps.propNames.update, update);
1327
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1328
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1329
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1330
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1331
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
1332
+
1333
+ const component = <InputBase inputProps={inputProps} />;
1334
+ const mountedComponent = mount(component);
1335
+ const input = mountedComponent.find("input");
1336
+ input.simulate("keydown", { key: "ArrowDown" });
1337
+
1338
+ expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
1339
+ });
1340
+
1341
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll down set value to 1", () => {
1342
+ const inputProps = new InputBaseProps();
1343
+ const aLabel = "aLabel";
1344
+ const aValue = "";
1345
+
1346
+ inputProps.set(InputBaseProps.propNames.update, update);
1347
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1348
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1349
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1350
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1351
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
1352
+
1353
+ const component = <InputBase inputProps={inputProps} />;
1354
+ const mountedComponent = mount(component);
1355
+ const input = mountedComponent.find("input");
1356
+ input.simulate("wheel", { deltaY: 100 });
1357
+
1358
+ expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
1359
+ });
949
1360
  });