orc-shared 5.10.2-dev.0 → 5.10.2-dev.2

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.
@@ -111,7 +111,7 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
111
111
  };
112
112
  });
113
113
  var StepperModal = function StepperModal(_ref) {
114
- var _steps$currentStep, _steps$currentStep$fu, _steps$currentStep2, _steps$currentStep3, _steps$currentStep4;
114
+ var _steps$currentStep, _steps$currentStep$fu, _steps$currentStep2, _steps$currentStep3, _steps$currentStep4, _steps$currentStep5, _steps$currentStep6;
115
115
  var _ref$steps = _ref.steps,
116
116
  steps = _ref$steps === void 0 ? [] : _ref$steps,
117
117
  _ref$title = _ref.title,
@@ -180,7 +180,7 @@ var StepperModal = function StepperModal(_ref) {
180
180
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
181
181
  variant: "outlined",
182
182
  onClick: closeCallback
183
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.cancel)), currentStep < steps.length - 1 && (((_steps$currentStep4 = steps[currentStep]) == null || (_steps$currentStep4 = _steps$currentStep4.actions) == null ? void 0 : _steps$currentStep4.length) > 0 ? steps[currentStep].actions.map(function (action) {
183
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.cancel)), (currentStep < steps.length - 1 || ((_steps$currentStep4 = steps[currentStep]) == null ? void 0 : _steps$currentStep4.isIntermediate)) && (((_steps$currentStep5 = steps[currentStep]) == null || (_steps$currentStep5 = _steps$currentStep5.actions) == null ? void 0 : _steps$currentStep5.length) > 0 ? steps[currentStep].actions.map(function (action) {
184
184
  return /*#__PURE__*/_react.default.createElement(_Button.default, {
185
185
  key: action.value,
186
186
  variant: "contained",
@@ -199,7 +199,7 @@ var StepperModal = function StepperModal(_ref) {
199
199
  return nextClick();
200
200
  },
201
201
  disableElevation: true
202
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.next))), currentStep === steps.length - 1 && /*#__PURE__*/_react.default.createElement(_Button.default, {
202
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.next))), currentStep === steps.length - 1 && !((_steps$currentStep6 = steps[currentStep]) != null && _steps$currentStep6.isIntermediate) && /*#__PURE__*/_react.default.createElement(_Button.default, {
203
203
  variant: "contained",
204
204
  color: "primary",
205
205
  disabled: nextDisabled,
@@ -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,88 @@ 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
+ controlSpecificSuffix = /*#__PURE__*/_react.default.createElement("div", {
290
+ className: classes.numericSpinnerContainer
291
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
292
+ className: classes.numericSpinnerUp,
293
+ tabIndex: "-1",
294
+ "data-qa": "increase",
295
+ disabled: disabled,
296
+ onClick: function onClick() {
297
+ return increaseNumericValue();
298
+ }
299
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
300
+ id: "chevron-up"
301
+ })), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
302
+ className: classes.numericSpinnerDown,
303
+ tabIndex: "-1",
304
+ "data-qa": "decrease",
305
+ disabled: disabled,
306
+ onClick: function onClick() {
307
+ return decreaseNumericValue();
308
+ }
309
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
310
+ id: "chevron-down"
311
+ })));
312
+ onKeyDown = function onKeyDown(event) {
313
+ if (event.key === "ArrowUp") {
314
+ event.preventDefault();
315
+ event.stopPropagation();
316
+ increaseNumericValue();
317
+ }
318
+ // Note Alex20260119: using an 'else if' caused issue with code coverage
319
+ if (event.key === "ArrowDown") {
320
+ event.preventDefault();
321
+ event.stopPropagation();
322
+ decreaseNumericValue();
323
+ }
324
+ };
325
+ onWheel = function onWheel(event) {
326
+ if (event.deltaY < 0) {
327
+ increaseNumericValue();
328
+ } else {
329
+ decreaseNumericValue();
330
+ }
331
+ };
332
+ }
193
333
  }
194
334
  var defaultRows = 4;
195
335
  var rows = rowsProps;
@@ -200,10 +340,6 @@ var InputBase = function InputBase(_ref) {
200
340
  // causing onBlur to never fire
201
341
  item.target.focus();
202
342
  };
203
- var classes = useStyles({
204
- label: label,
205
- errorPosition: errorPosition
206
- });
207
343
  var onChangeHandler = function onChangeHandler(event) {
208
344
  if (event.persist) {
209
345
  event.persist();
@@ -245,11 +381,6 @@ var InputBase = function InputBase(_ref) {
245
381
  };
246
382
  var inputBaseInputStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.input);
247
383
  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
384
  _react.default.useEffect(function () {
254
385
  if (inputText === null || window.bypassDebounce === true) {
255
386
  return;
@@ -277,7 +408,11 @@ var InputBase = function InputBase(_ref) {
277
408
  className: classes.inputContainer
278
409
  }, label && /*#__PURE__*/_react.default.createElement("label", {
279
410
  className: "".concat(classes.prepend, " ").concat(disabled && classes.disabledPrepend)
280
- }, label), /*#__PURE__*/_react.default.createElement(_InputBase.default, {
411
+ }, label), /*#__PURE__*/_react.default.createElement("div", {
412
+ style: {
413
+ display: "flex"
414
+ }
415
+ }, /*#__PURE__*/_react.default.createElement(_InputBase.default, {
281
416
  classes: {
282
417
  input: (0, _classnames.default)(classes.controlInput, inputBaseInputStyle),
283
418
  error: classes.errorInput,
@@ -291,6 +426,8 @@ var InputBase = function InputBase(_ref) {
291
426
  placeholder: placeholder,
292
427
  value: textToDisplay,
293
428
  fullWidth: true,
429
+ onKeyDown: onKeyDown,
430
+ onWheel: onWheel,
294
431
  onChange: function onChange(event) {
295
432
  return onChangeHandler(event);
296
433
  },
@@ -304,14 +441,14 @@ var InputBase = function InputBase(_ref) {
304
441
  minRows: rows,
305
442
  title: tooltipText,
306
443
  autoComplete: autoComplete
307
- })), error && /*#__PURE__*/_react.default.createElement("div", {
444
+ }), controlSpecificSuffix)), error && /*#__PURE__*/_react.default.createElement("div", {
308
445
  className: (0, _classnames.default)(classes.errorText, errorTextStyle)
309
446
  }, error));
310
447
  };
311
- __signature__(InputBase, "useStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseState{[inputText, setInputText](null)}\nuseEffect{}", function () {
448
+ __signature__(InputBase, "useState{[inputText, setInputText](null)}\nuseStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseEffect{}", function () {
312
449
  return [useStyles];
313
450
  });
314
- __signature__(InputBase, "useStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseState{[inputText, setInputText](null)}\nuseEffect{}", function () {
451
+ __signature__(InputBase, "useState{[inputText, setInputText](null)}\nuseStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseEffect{}", function () {
315
452
  return [useStyles];
316
453
  });
317
454
  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.0",
3
+ "version": "5.10.2-dev.2",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -165,7 +165,7 @@ const StepperModal = ({
165
165
  <FormattedMessage {...sharedMessages.cancel} />
166
166
  </Button>
167
167
 
168
- {currentStep < steps.length - 1 &&
168
+ {(currentStep < steps.length - 1 || steps[currentStep]?.isIntermediate) &&
169
169
  (steps[currentStep]?.actions?.length > 0 ? (
170
170
  steps[currentStep].actions.map(action => (
171
171
  <Button
@@ -191,7 +191,7 @@ const StepperModal = ({
191
191
  </Button>
192
192
  ))}
193
193
 
194
- {currentStep === steps.length - 1 && (
194
+ {currentStep === steps.length - 1 && !steps[currentStep]?.isIntermediate && (
195
195
  <Button
196
196
  variant="contained"
197
197
  color="primary"
@@ -335,6 +335,80 @@ describe("StepperModal", () => {
335
335
  expect(okCallback, "was called");
336
336
  });
337
337
 
338
+ it("Renders StepperModal correctly without confirm button for an intermediate step", () => {
339
+ const open = true;
340
+ const title = "title";
341
+ const backdropClickCallback = jest.fn();
342
+ const okCallback = jest.fn();
343
+ const cancelCallback = jest.fn();
344
+ const modalProps = new ModalProps();
345
+ const actions = [
346
+ {
347
+ value: "first value",
348
+ label: "first action",
349
+ Handler: () => {},
350
+ },
351
+ {
352
+ value: "second value",
353
+ label: "second action",
354
+ Handler: () => {},
355
+ },
356
+ ];
357
+ const steps = [{ title: "step1", content: <div>content</div>, actions, isIntermediate: true }];
358
+
359
+ const titleComponent = (
360
+ <div>
361
+ <div>{title}</div>
362
+ <div>step1</div>
363
+ </div>
364
+ );
365
+ const messageComponent = <div>{steps[0].content}</div>;
366
+
367
+ modalProps.set(ModalProps.propNames.title, titleComponent);
368
+ modalProps.set(ModalProps.propNames.open, open);
369
+ modalProps.set(ModalProps.propNames.backdropClickCallback, backdropClickCallback);
370
+ modalProps.set(ModalProps.propNames.type, "wide");
371
+
372
+ const actionPanel = (
373
+ <div>
374
+ <div></div>
375
+ <div>
376
+ <Button variant="outlined" disabled={false} onClick={() => cancelCallback()}>
377
+ {sharedMessages.cancel.defaultMessage}
378
+ </Button>
379
+ <Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
380
+ first action
381
+ </Button>
382
+ <Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
383
+ second action
384
+ </Button>
385
+ </div>
386
+ </div>
387
+ );
388
+
389
+ modalProps.set(ModalProps.propNames.actionPanel, actionPanel);
390
+
391
+ const component = (
392
+ <IntlProvider locale="en-US" messages={messages}>
393
+ <StepperModal
394
+ steps={steps}
395
+ title={title}
396
+ open={open}
397
+ confirmCallback={okCallback}
398
+ closeCallback={cancelCallback}
399
+ />
400
+ </IntlProvider>
401
+ );
402
+
403
+ const expected = (
404
+ <IntlProvider locale="en-US" messages={messages}>
405
+ <Modal message={messageComponent} modalProps={modalProps} />
406
+ </IntlProvider>
407
+ );
408
+
409
+ expect(component, "when mounted", "to satisfy", expected);
410
+ });
411
+
338
412
  it("Render closed modal", () => {
339
413
  const open = false;
340
414
 
@@ -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,97 @@ 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
+ controlSpecificSuffix = (
262
+ <div className={classes.numericSpinnerContainer}>
263
+ <IconButton
264
+ className={classes.numericSpinnerUp}
265
+ tabIndex="-1"
266
+ data-qa="increase"
267
+ disabled={disabled}
268
+ onClick={() => increaseNumericValue()}
269
+ >
270
+ <Icon id="chevron-up" />
271
+ </IconButton>
272
+
273
+ <IconButton
274
+ className={classes.numericSpinnerDown}
275
+ tabIndex="-1"
276
+ data-qa="decrease"
277
+ disabled={disabled}
278
+ onClick={() => decreaseNumericValue()}
279
+ >
280
+ <Icon id="chevron-down" />
281
+ </IconButton>
282
+ </div>
283
+ );
284
+
285
+ onKeyDown = event => {
286
+ if (event.key === "ArrowUp") {
287
+ event.preventDefault();
288
+ event.stopPropagation();
289
+
290
+ increaseNumericValue();
291
+ }
292
+ // Note Alex20260119: using an 'else if' caused issue with code coverage
293
+ if (event.key === "ArrowDown") {
294
+ event.preventDefault();
295
+ event.stopPropagation();
296
+
297
+ decreaseNumericValue();
298
+ }
299
+ };
300
+
301
+ onWheel = event => {
302
+ if (event.deltaY < 0) {
303
+ increaseNumericValue();
304
+ } else {
305
+ decreaseNumericValue();
306
+ }
307
+ };
308
+ }
160
309
  }
161
310
 
162
311
  const defaultRows = 4;
@@ -170,7 +319,6 @@ const InputBase = ({ inputProps }) => {
170
319
  // causing onBlur to never fire
171
320
  item.target.focus();
172
321
  };
173
- const classes = useStyles({ label, errorPosition });
174
322
 
175
323
  const onChangeHandler = event => {
176
324
  if (event.persist) {
@@ -222,8 +370,6 @@ const InputBase = ({ inputProps }) => {
222
370
 
223
371
  const inputBaseInputStyle = inputProps?.getStyle(InputBaseProps.ruleNames.input);
224
372
  const errorTextStyle = inputProps?.getStyle(InputBaseProps.ruleNames.errorText);
225
- const [inputText, setInputText] = React.useState(null);
226
- const textToDisplay = inputText ?? value;
227
373
 
228
374
  React.useEffect(() => {
229
375
  if (inputText === null || window.bypassDebounce === true) {
@@ -253,32 +399,37 @@ const InputBase = ({ inputProps }) => {
253
399
  <div className={classes.container}>
254
400
  <div className={classes.inputContainer}>
255
401
  {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
- />
402
+ <div style={{ display: "flex" }}>
403
+ <InputBaseMUI
404
+ classes={{
405
+ input: classNames(classes.controlInput, inputBaseInputStyle),
406
+ error: classes.errorInput,
407
+ disabled: classes.disabled,
408
+ multiline: classes.multiline,
409
+ inputMultiline: classes.inputMultiline,
410
+ }}
411
+ onBlur={onBlurInternal}
412
+ onClick={onClick}
413
+ type={inputControlType}
414
+ placeholder={placeholder}
415
+ value={textToDisplay}
416
+ fullWidth={true}
417
+ onKeyDown={onKeyDown}
418
+ onWheel={onWheel}
419
+ onChange={event => onChangeHandler(event)}
420
+ error={!!error}
421
+ inputProps={inputAttributes}
422
+ inputComponent={inputComponent}
423
+ disabled={disabled}
424
+ multiline={multiline}
425
+ startAdornment={startAdornment}
426
+ endAdornment={endAdornment}
427
+ minRows={rows}
428
+ title={tooltipText}
429
+ autoComplete={autoComplete}
430
+ />
431
+ {controlSpecificSuffix}
432
+ </div>
282
433
  </div>
283
434
  {error && <div className={classNames(classes.errorText, errorTextStyle)}>{error}</div>}
284
435
  </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,395 @@ 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("Change advanced numeric input value, empty initial value with increase button", () => {
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 btn = mountedComponent.find("[data-qa='increase']").hostNodes();
999
+ btn.simulate("click");
1000
+
1001
+ expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
1002
+ });
1003
+
1004
+ it("Change advanced numeric input value, 1 initial value with increase button", () => {
1005
+ const inputProps = new InputBaseProps();
1006
+ const aLabel = "aLabel";
1007
+ const aValue = "1";
1008
+
1009
+ inputProps.set(InputBaseProps.propNames.update, update);
1010
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1011
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1012
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1013
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1014
+
1015
+ const component = <InputBase inputProps={inputProps} />;
1016
+ const mountedComponent = mount(component);
1017
+ const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
1018
+ btn.simulate("click");
1019
+
1020
+ expect(update, "to have calls satisfying", [{ args: ["2", null] }]);
1021
+ });
1022
+
1023
+ it("Change advanced numeric input value, 10 initial value with max 11 with increase button", () => {
1024
+ const inputProps = new InputBaseProps();
1025
+ const aLabel = "aLabel";
1026
+ const aValue = "10";
1027
+
1028
+ inputProps.set(InputBaseProps.propNames.update, update);
1029
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1030
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1031
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1032
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1033
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
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: ["11", null] }]);
1041
+ });
1042
+
1043
+ it("Change advanced numeric input value, 11 initial value with max 11 with increase button stays at 11", () => {
1044
+ const inputProps = new InputBaseProps();
1045
+ const aLabel = "aLabel";
1046
+ const aValue = "11";
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, "was not called");
1061
+ });
1062
+
1063
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
1064
+ const inputProps = new InputBaseProps();
1065
+ const aLabel = "aLabel";
1066
+ const aValue = "";
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: 5, max: 15 });
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, "to have calls satisfying", [{ args: ["5", null] }]);
1081
+ });
1082
+
1083
+ it("Change advanced numeric input value, empty initial value, min=-15, max=-5, 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: -15, max: -5 });
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=5, max=15, 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: 5, max: 15 });
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, key up set value to 1", () => {
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 input = mountedComponent.find("input");
1138
+ input.simulate("keydown", { key: "ArrowUp" });
1139
+
1140
+ expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
1141
+ });
1142
+
1143
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll 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("wheel", { deltaY: -100 });
1159
+
1160
+ expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
1161
+ });
1162
+
1163
+ it("Change advanced numeric input value, empty initial value with decrease button", () => {
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
+
1174
+ const component = <InputBase inputProps={inputProps} />;
1175
+ const mountedComponent = mount(component);
1176
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1177
+ btn.simulate("click");
1178
+
1179
+ expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
1180
+ });
1181
+
1182
+ it("Change advanced numeric input value, -1 initial value with decrease button", () => {
1183
+ const inputProps = new InputBaseProps();
1184
+ const aLabel = "aLabel";
1185
+ const aValue = "-1";
1186
+
1187
+ inputProps.set(InputBaseProps.propNames.update, update);
1188
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1189
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1190
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1191
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1192
+
1193
+ const component = <InputBase inputProps={inputProps} />;
1194
+ const mountedComponent = mount(component);
1195
+ const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
1196
+ btn.simulate("click");
1197
+
1198
+ expect(update, "to have calls satisfying", [{ args: ["-2", null] }]);
1199
+ });
1200
+
1201
+ it("Change advanced numeric input value, -10 initial value with min 11 with decrease button", () => {
1202
+ const inputProps = new InputBaseProps();
1203
+ const aLabel = "aLabel";
1204
+ const aValue = "-10";
1205
+
1206
+ inputProps.set(InputBaseProps.propNames.update, update);
1207
+ inputProps.set(InputBaseProps.propNames.value, aValue);
1208
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
1209
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
1210
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
1211
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
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: ["-11", null] }]);
1219
+ });
1220
+
1221
+ it("Change advanced numeric input value, -11 initial value with min -11 with decrease button stays at -11", () => {
1222
+ const inputProps = new InputBaseProps();
1223
+ const aLabel = "aLabel";
1224
+ const aValue = "-11";
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, "was not called");
1239
+ });
1240
+
1241
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button should set to 5", () => {
1242
+ const inputProps = new InputBaseProps();
1243
+ const aLabel = "aLabel";
1244
+ const aValue = "";
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: 5, max: 15 });
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, "to have calls satisfying", [{ args: ["5", null] }]);
1259
+ });
1260
+
1261
+ it("Change advanced numeric input value, empty initial value, min=-15, max=-5, decrease button set value 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: -15, max: -5 });
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=5, max=15, 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: 5, max: 15 });
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, key down set value to 1", () => {
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 input = mountedComponent.find("input");
1316
+ input.simulate("keydown", { key: "ArrowDown" });
1317
+
1318
+ expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
1319
+ });
1320
+
1321
+ it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll 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("wheel", { deltaY: 100 });
1337
+
1338
+ expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
1339
+ });
949
1340
  });