orc-shared 5.99.0-dev.3 → 5.99.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
- package/dist/components/MaterialUI/Inputs/InputBase.js +209 -24
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +2 -2
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +74 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +209 -8
- package/src/components/MaterialUI/Inputs/InputBase.test.js +481 -3
|
@@ -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$
|
|
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,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.useStyles = exports.default = exports.AdvancedNumericInput = void 0;
|
|
4
|
+
exports.useStyles = exports.default = exports.AdvancedNumericInput = exports.AdvancedIntegerInput = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _styles = require("@material-ui/core/styles");
|
|
7
7
|
var _InputBase = _interopRequireDefault(require("@material-ui/core/InputBase"));
|
|
@@ -9,7 +9,10 @@ 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
|
|
12
|
+
var _Icon = _interopRequireDefault(require("../DataDisplay/Icon"));
|
|
13
|
+
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
14
|
+
var _excluded = ["inputRef", "onChange"],
|
|
15
|
+
_excluded2 = ["integerButtons"];
|
|
13
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
17
|
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); }
|
|
15
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -21,17 +24,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
21
24
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
22
25
|
enterModule && enterModule(module);
|
|
23
26
|
})();
|
|
27
|
+
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; }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
31
|
+
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
32
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
25
33
|
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
34
|
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
35
|
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
36
|
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
37
|
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
38
|
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
39
|
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
40
|
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 +79,21 @@ var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
76
79
|
minWidth: 0,
|
|
77
80
|
border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.grey.borders),
|
|
78
81
|
borderRadius: function borderRadius(props) {
|
|
79
|
-
|
|
82
|
+
var topLeft = props.label ? 0 : 0.5;
|
|
83
|
+
var topRight = props.isAdvancedNumericInput ? 0 : 0.5;
|
|
84
|
+
var bottomRight = topRight;
|
|
85
|
+
var bottomLeft = topLeft;
|
|
86
|
+
return theme.spacing(topLeft, topRight, bottomRight, bottomLeft);
|
|
80
87
|
},
|
|
81
88
|
paddingLeft: theme.spacing(0.85),
|
|
82
89
|
"&:focus, &:active": {
|
|
83
90
|
border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.focus),
|
|
84
91
|
borderRadius: function borderRadius(props) {
|
|
85
|
-
|
|
92
|
+
var topLeft = props.label ? 0 : 0.5;
|
|
93
|
+
var topRight = props.isAdvancedNumericInput ? 0 : 0.5;
|
|
94
|
+
var bottomRight = topRight;
|
|
95
|
+
var bottomLeft = topLeft;
|
|
96
|
+
return theme.spacing(topLeft, topRight, bottomRight, bottomLeft);
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
},
|
|
@@ -119,6 +130,41 @@ var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
119
130
|
},
|
|
120
131
|
inputMultiline: {
|
|
121
132
|
padding: theme.spacing(0.6, 0.6, 0.6, 0.85)
|
|
133
|
+
},
|
|
134
|
+
numericSpinnerContainer: {
|
|
135
|
+
display: "flex",
|
|
136
|
+
backgroundColor: theme.palette.grey.light,
|
|
137
|
+
flexDirection: "column",
|
|
138
|
+
borderTopLeftRadius: 0,
|
|
139
|
+
borderBottomLeftRadius: 0,
|
|
140
|
+
borderTopRightRadius: theme.shape.borderRadius,
|
|
141
|
+
borderBottomRightRadius: theme.shape.borderRadius,
|
|
142
|
+
border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.grey.borders),
|
|
143
|
+
padding: 0,
|
|
144
|
+
margin: "0 0 0 -1px"
|
|
145
|
+
},
|
|
146
|
+
numericSpinnerUp: {
|
|
147
|
+
fontSize: "8px",
|
|
148
|
+
padding: "0 3px",
|
|
149
|
+
borderBottom: "1px solid #CCCCCC",
|
|
150
|
+
borderRadius: 0,
|
|
151
|
+
flex: 1,
|
|
152
|
+
margin: 0,
|
|
153
|
+
width: "20px",
|
|
154
|
+
"& + .MuiButton-root, & + .MuiIconButton-root, & + .MuiInputBase-root": {
|
|
155
|
+
marginLeft: 0
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
numericSpinnerDown: {
|
|
159
|
+
fontSize: "8px",
|
|
160
|
+
padding: "0 3px",
|
|
161
|
+
borderRadius: 0,
|
|
162
|
+
flex: 1,
|
|
163
|
+
margin: 0,
|
|
164
|
+
marginLeft: 0,
|
|
165
|
+
"& + .MuiButton-root, & + .MuiIconButton-root, & + .MuiInputBase-root": {
|
|
166
|
+
marginLeft: 0
|
|
167
|
+
}
|
|
122
168
|
}
|
|
123
169
|
};
|
|
124
170
|
});
|
|
@@ -141,8 +187,27 @@ var AdvancedNumericInput = exports.AdvancedNumericInput = function AdvancedNumer
|
|
|
141
187
|
}
|
|
142
188
|
}));
|
|
143
189
|
};
|
|
190
|
+
var AdvancedIntegerInput = exports.AdvancedIntegerInput = function AdvancedIntegerInput(props) {
|
|
191
|
+
var integerButtons = props.integerButtons,
|
|
192
|
+
other = _objectWithoutProperties(props, _excluded2);
|
|
193
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
194
|
+
style: {
|
|
195
|
+
display: "flex"
|
|
196
|
+
},
|
|
197
|
+
className: "InputBase-input-wrapper"
|
|
198
|
+
}, /*#__PURE__*/_react.default.createElement(AdvancedNumericInput, other), integerButtons);
|
|
199
|
+
};
|
|
200
|
+
var getInputComponent = function getInputComponent(isAdvancedNumericInput, decimalScale) {
|
|
201
|
+
if (isAdvancedNumericInput) {
|
|
202
|
+
if (decimalScale === 0) {
|
|
203
|
+
return AdvancedIntegerInput;
|
|
204
|
+
}
|
|
205
|
+
return AdvancedNumericInput;
|
|
206
|
+
}
|
|
207
|
+
return undefined;
|
|
208
|
+
};
|
|
144
209
|
var InputBase = function InputBase(_ref) {
|
|
145
|
-
var _inputProps$get;
|
|
210
|
+
var _inputProps$get, _numericInputProps$de;
|
|
146
211
|
var inputProps = _ref.inputProps;
|
|
147
212
|
if ((0, _InputBaseProps.isInputProps)(inputProps) === false) {
|
|
148
213
|
throw new TypeError("inputProps property is not of type InputBaseProps");
|
|
@@ -166,8 +231,21 @@ var InputBase = function InputBase(_ref) {
|
|
|
166
231
|
var rowsProps = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.rows);
|
|
167
232
|
var numericInputProps = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.numericInputProps)) || null;
|
|
168
233
|
var isAdvancedNumericInput = type.toLowerCase() === "advancednumericinput";
|
|
169
|
-
var
|
|
234
|
+
var decimalScale = (_numericInputProps$de = numericInputProps == null ? void 0 : numericInputProps.decimalScale) != null ? _numericInputProps$de : 0;
|
|
235
|
+
var inputComponent = getInputComponent(isAdvancedNumericInput, decimalScale);
|
|
170
236
|
var inputControlType = isAdvancedNumericInput ? "text" : type;
|
|
237
|
+
var _React$useState = _react.default.useState(null),
|
|
238
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
239
|
+
inputText = _React$useState2[0],
|
|
240
|
+
setInputText = _React$useState2[1];
|
|
241
|
+
var textToDisplay = inputText != null ? inputText : value;
|
|
242
|
+
var classes = useStyles({
|
|
243
|
+
label: label,
|
|
244
|
+
errorPosition: errorPosition,
|
|
245
|
+
isAdvancedNumericInput: isAdvancedNumericInput
|
|
246
|
+
});
|
|
247
|
+
var onKeyDown = null;
|
|
248
|
+
var onWheel = null;
|
|
171
249
|
if (isAdvancedNumericInput && numericInputProps) {
|
|
172
250
|
Object.keys(numericInputProps).forEach(function (key) {
|
|
173
251
|
if (key !== "blurFormattingSkipFixedDecimalScale") {
|
|
@@ -176,20 +254,118 @@ var InputBase = function InputBase(_ref) {
|
|
|
176
254
|
});
|
|
177
255
|
}
|
|
178
256
|
if (isAdvancedNumericInput) {
|
|
179
|
-
var _numericInputProps$de;
|
|
180
257
|
if (inputAttributes.max === undefined) {
|
|
181
258
|
inputAttributes.max = 2147483647;
|
|
182
259
|
}
|
|
183
260
|
if (inputAttributes.min === undefined) {
|
|
184
261
|
inputAttributes.min = -2147483648;
|
|
185
262
|
}
|
|
186
|
-
var decimalScale = (_numericInputProps$de = numericInputProps == null ? void 0 : numericInputProps.decimalScale) != null ? _numericInputProps$de : 0;
|
|
187
263
|
var lengthForMin = Math.trunc(inputAttributes.min).toString().length;
|
|
188
264
|
var lengthForMax = Math.trunc(inputAttributes.max).toString().length;
|
|
189
265
|
inputAttributes.maxLength = Math.max(lengthForMin, lengthForMax) + (decimalScale > 0 ? decimalScale + 1 : 0);
|
|
190
266
|
inputAttributes.isAllowed = function (val) {
|
|
191
267
|
return val.value === "" || val.value === "-" || val.value !== null;
|
|
192
268
|
};
|
|
269
|
+
if (decimalScale === 0 && !disabled) {
|
|
270
|
+
var getInitialNumericValue = function getInitialNumericValue() {
|
|
271
|
+
if (0 >= inputAttributes.min && 0 <= inputAttributes.max) {
|
|
272
|
+
return 0;
|
|
273
|
+
}
|
|
274
|
+
if (Math.abs(inputAttributes.min) < Math.abs(inputAttributes.max)) {
|
|
275
|
+
return inputAttributes.min;
|
|
276
|
+
}
|
|
277
|
+
return inputAttributes.max;
|
|
278
|
+
};
|
|
279
|
+
var increaseNumericValue = function increaseNumericValue() {
|
|
280
|
+
if (textToDisplay) {
|
|
281
|
+
var currentValue = parseInt(textToDisplay, 10);
|
|
282
|
+
if (currentValue + 1 <= inputAttributes.max) {
|
|
283
|
+
setInputText((currentValue + 1).toString());
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
var _currentValue = getInitialNumericValue();
|
|
287
|
+
if (_currentValue === 0 && _currentValue + 1 <= inputAttributes.max) {
|
|
288
|
+
_currentValue++;
|
|
289
|
+
}
|
|
290
|
+
setInputText(_currentValue.toString());
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
var decreaseNumericValue = function decreaseNumericValue() {
|
|
294
|
+
if (textToDisplay) {
|
|
295
|
+
var currentValue = parseInt(textToDisplay, 10);
|
|
296
|
+
if (currentValue - 1 >= inputAttributes.min) {
|
|
297
|
+
setInputText((currentValue - 1).toString());
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
var _currentValue2 = getInitialNumericValue();
|
|
301
|
+
if (_currentValue2 === 0 && _currentValue2 - 1 >= inputAttributes.min) {
|
|
302
|
+
_currentValue2--;
|
|
303
|
+
}
|
|
304
|
+
setInputText(_currentValue2.toString());
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var focusInput = function focusInput(target) {
|
|
308
|
+
target.closest(".InputBase-input-wrapper").getElementsByTagName("input")[0].focus();
|
|
309
|
+
};
|
|
310
|
+
inputAttributes.integerButtons = /*#__PURE__*/_react.default.createElement("div", {
|
|
311
|
+
className: classes.numericSpinnerContainer
|
|
312
|
+
}, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
313
|
+
className: classes.numericSpinnerUp,
|
|
314
|
+
tabIndex: "-1",
|
|
315
|
+
"data-qa": "increase",
|
|
316
|
+
disabled: disabled,
|
|
317
|
+
onMouseDown: function onMouseDown(event) {
|
|
318
|
+
return event.preventDefault();
|
|
319
|
+
} // prevent the button from stealing focus
|
|
320
|
+
,
|
|
321
|
+
onClick: function onClick(event) {
|
|
322
|
+
event.preventDefault();
|
|
323
|
+
event.stopPropagation();
|
|
324
|
+
increaseNumericValue();
|
|
325
|
+
focusInput(event.target);
|
|
326
|
+
}
|
|
327
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
328
|
+
id: "chevron-up"
|
|
329
|
+
})), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
330
|
+
className: classes.numericSpinnerDown,
|
|
331
|
+
tabIndex: "-1",
|
|
332
|
+
"data-qa": "decrease",
|
|
333
|
+
disabled: disabled,
|
|
334
|
+
onMouseDown: function onMouseDown(event) {
|
|
335
|
+
return event.preventDefault();
|
|
336
|
+
} // prevent the button from stealing focus
|
|
337
|
+
,
|
|
338
|
+
onClick: function onClick(event) {
|
|
339
|
+
event.preventDefault();
|
|
340
|
+
event.stopPropagation();
|
|
341
|
+
decreaseNumericValue();
|
|
342
|
+
focusInput(event.target);
|
|
343
|
+
}
|
|
344
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
345
|
+
id: "chevron-down"
|
|
346
|
+
})));
|
|
347
|
+
onKeyDown = function onKeyDown(event) {
|
|
348
|
+
if (event.key === "ArrowUp") {
|
|
349
|
+
event.preventDefault();
|
|
350
|
+
event.stopPropagation();
|
|
351
|
+
increaseNumericValue();
|
|
352
|
+
}
|
|
353
|
+
// Note Alex20260119: using an 'else if' caused issue with code coverage
|
|
354
|
+
if (event.key === "ArrowDown") {
|
|
355
|
+
event.preventDefault();
|
|
356
|
+
event.stopPropagation();
|
|
357
|
+
decreaseNumericValue();
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
onWheel = function onWheel(event) {
|
|
361
|
+
if (event.deltaY < 0) {
|
|
362
|
+
increaseNumericValue();
|
|
363
|
+
} else {
|
|
364
|
+
decreaseNumericValue();
|
|
365
|
+
}
|
|
366
|
+
focusInput(event.target);
|
|
367
|
+
};
|
|
368
|
+
}
|
|
193
369
|
}
|
|
194
370
|
var defaultRows = 4;
|
|
195
371
|
var rows = rowsProps;
|
|
@@ -200,10 +376,6 @@ var InputBase = function InputBase(_ref) {
|
|
|
200
376
|
// causing onBlur to never fire
|
|
201
377
|
item.target.focus();
|
|
202
378
|
};
|
|
203
|
-
var classes = useStyles({
|
|
204
|
-
label: label,
|
|
205
|
-
errorPosition: errorPosition
|
|
206
|
-
});
|
|
207
379
|
var onChangeHandler = function onChangeHandler(event) {
|
|
208
380
|
if (event.persist) {
|
|
209
381
|
event.persist();
|
|
@@ -245,11 +417,6 @@ var InputBase = function InputBase(_ref) {
|
|
|
245
417
|
};
|
|
246
418
|
var inputBaseInputStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.input);
|
|
247
419
|
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
420
|
_react.default.useEffect(function () {
|
|
254
421
|
if (inputText === null || window.bypassDebounce === true) {
|
|
255
422
|
return;
|
|
@@ -271,6 +438,19 @@ var InputBase = function InputBase(_ref) {
|
|
|
271
438
|
|
|
272
439
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
273
440
|
}, [inputText, metadata, timeoutDelay, update, value]);
|
|
441
|
+
if (onKeyDown) {
|
|
442
|
+
if (inputAttributes.onKeyDown) {
|
|
443
|
+
var originalKeyDown = inputAttributes.onKeyDown;
|
|
444
|
+
inputAttributes.onKeyDown = function (event) {
|
|
445
|
+
originalKeyDown(event);
|
|
446
|
+
if (!event.isDefaultPrevented()) {
|
|
447
|
+
onKeyDown(event);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
} else {
|
|
451
|
+
inputAttributes.onKeyDown = onKeyDown;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
274
454
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
275
455
|
className: classes.container
|
|
276
456
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -291,6 +471,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
291
471
|
placeholder: placeholder,
|
|
292
472
|
value: textToDisplay,
|
|
293
473
|
fullWidth: true,
|
|
474
|
+
onWheel: onWheel,
|
|
294
475
|
onChange: function onChange(event) {
|
|
295
476
|
return onChangeHandler(event);
|
|
296
477
|
},
|
|
@@ -308,10 +489,10 @@ var InputBase = function InputBase(_ref) {
|
|
|
308
489
|
className: (0, _classnames.default)(classes.errorText, errorTextStyle)
|
|
309
490
|
}, error));
|
|
310
491
|
};
|
|
311
|
-
__signature__(InputBase, "
|
|
492
|
+
__signature__(InputBase, "useState{[inputText, setInputText](null)}\nuseStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseEffect{}", function () {
|
|
312
493
|
return [useStyles];
|
|
313
494
|
});
|
|
314
|
-
__signature__(InputBase, "
|
|
495
|
+
__signature__(InputBase, "useState{[inputText, setInputText](null)}\nuseStyles{classes}\nuseRef{timerId}\nuseEffect{}\nuseEffect{}", function () {
|
|
315
496
|
return [useStyles];
|
|
316
497
|
});
|
|
317
498
|
var compareInputBase = function compareInputBase(prev, next) {
|
|
@@ -328,6 +509,8 @@ var _default3 = exports.default = _default2;
|
|
|
328
509
|
}
|
|
329
510
|
reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
330
511
|
reactHotLoader.register(AdvancedNumericInput, "AdvancedNumericInput", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
512
|
+
reactHotLoader.register(AdvancedIntegerInput, "AdvancedIntegerInput", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
513
|
+
reactHotLoader.register(getInputComponent, "getInputComponent", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
331
514
|
reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
332
515
|
reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
333
516
|
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
@@ -345,6 +528,8 @@ var _default3 = exports.default = _default2;
|
|
|
345
528
|
}
|
|
346
529
|
reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
347
530
|
reactHotLoader.register(AdvancedNumericInput, "AdvancedNumericInput", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
531
|
+
reactHotLoader.register(AdvancedIntegerInput, "AdvancedIntegerInput", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
532
|
+
reactHotLoader.register(getInputComponent, "getInputComponent", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
348
533
|
reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
349
534
|
reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
350
535
|
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
package/package.json
CHANGED
|
@@ -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
|
|
|
@@ -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 =>
|
|
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 =>
|
|
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 => {
|
|
@@ -102,6 +153,29 @@ export const AdvancedNumericInput = props => {
|
|
|
102
153
|
);
|
|
103
154
|
};
|
|
104
155
|
|
|
156
|
+
export const AdvancedIntegerInput = props => {
|
|
157
|
+
const { integerButtons, ...other } = props;
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div style={{ display: "flex" }} className="InputBase-input-wrapper">
|
|
161
|
+
<AdvancedNumericInput {...other} />
|
|
162
|
+
{integerButtons}
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const getInputComponent = (isAdvancedNumericInput, decimalScale) => {
|
|
168
|
+
if (isAdvancedNumericInput) {
|
|
169
|
+
if (decimalScale === 0) {
|
|
170
|
+
return AdvancedIntegerInput;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return AdvancedNumericInput;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return undefined;
|
|
177
|
+
};
|
|
178
|
+
|
|
105
179
|
const InputBase = ({ inputProps }) => {
|
|
106
180
|
if (isInputProps(inputProps) === false) {
|
|
107
181
|
throw new TypeError("inputProps property is not of type InputBaseProps");
|
|
@@ -127,8 +201,15 @@ const InputBase = ({ inputProps }) => {
|
|
|
127
201
|
const numericInputProps = inputProps?.get(InputBaseProps.propNames.numericInputProps) || null;
|
|
128
202
|
|
|
129
203
|
const isAdvancedNumericInput = type.toLowerCase() === "advancednumericinput";
|
|
130
|
-
const
|
|
204
|
+
const decimalScale = numericInputProps?.decimalScale ?? 0;
|
|
205
|
+
const inputComponent = getInputComponent(isAdvancedNumericInput, decimalScale);
|
|
131
206
|
const inputControlType = isAdvancedNumericInput ? "text" : type;
|
|
207
|
+
const [inputText, setInputText] = React.useState(null);
|
|
208
|
+
const textToDisplay = inputText ?? value;
|
|
209
|
+
const classes = useStyles({ label, errorPosition, isAdvancedNumericInput });
|
|
210
|
+
|
|
211
|
+
let onKeyDown = null;
|
|
212
|
+
let onWheel = null;
|
|
132
213
|
|
|
133
214
|
if (isAdvancedNumericInput && numericInputProps) {
|
|
134
215
|
Object.keys(numericInputProps).forEach(key => {
|
|
@@ -147,8 +228,6 @@ const InputBase = ({ inputProps }) => {
|
|
|
147
228
|
inputAttributes.min = -2147483648;
|
|
148
229
|
}
|
|
149
230
|
|
|
150
|
-
const decimalScale = numericInputProps?.decimalScale ?? 0;
|
|
151
|
-
|
|
152
231
|
const lengthForMin = Math.trunc(inputAttributes.min).toString().length;
|
|
153
232
|
const lengthForMax = Math.trunc(inputAttributes.max).toString().length;
|
|
154
233
|
|
|
@@ -157,6 +236,115 @@ const InputBase = ({ inputProps }) => {
|
|
|
157
236
|
inputAttributes.isAllowed = val => {
|
|
158
237
|
return val.value === "" || val.value === "-" || val.value !== null;
|
|
159
238
|
};
|
|
239
|
+
|
|
240
|
+
if (decimalScale === 0 && !disabled) {
|
|
241
|
+
const getInitialNumericValue = () => {
|
|
242
|
+
if (0 >= inputAttributes.min && 0 <= inputAttributes.max) {
|
|
243
|
+
return 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (Math.abs(inputAttributes.min) < Math.abs(inputAttributes.max)) {
|
|
247
|
+
return inputAttributes.min;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return inputAttributes.max;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const increaseNumericValue = () => {
|
|
254
|
+
if (textToDisplay) {
|
|
255
|
+
const currentValue = parseInt(textToDisplay, 10);
|
|
256
|
+
if (currentValue + 1 <= inputAttributes.max) {
|
|
257
|
+
setInputText((currentValue + 1).toString());
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
let currentValue = getInitialNumericValue();
|
|
261
|
+
if (currentValue === 0 && currentValue + 1 <= inputAttributes.max) {
|
|
262
|
+
currentValue++;
|
|
263
|
+
}
|
|
264
|
+
setInputText(currentValue.toString());
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const decreaseNumericValue = () => {
|
|
268
|
+
if (textToDisplay) {
|
|
269
|
+
const currentValue = parseInt(textToDisplay, 10);
|
|
270
|
+
if (currentValue - 1 >= inputAttributes.min) {
|
|
271
|
+
setInputText((currentValue - 1).toString());
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
let currentValue = getInitialNumericValue();
|
|
275
|
+
if (currentValue === 0 && currentValue - 1 >= inputAttributes.min) {
|
|
276
|
+
currentValue--;
|
|
277
|
+
}
|
|
278
|
+
setInputText(currentValue.toString());
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const focusInput = target => {
|
|
283
|
+
target.closest(".InputBase-input-wrapper").getElementsByTagName("input")[0].focus();
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
inputAttributes.integerButtons = (
|
|
287
|
+
<div className={classes.numericSpinnerContainer}>
|
|
288
|
+
<IconButton
|
|
289
|
+
className={classes.numericSpinnerUp}
|
|
290
|
+
tabIndex="-1"
|
|
291
|
+
data-qa="increase"
|
|
292
|
+
disabled={disabled}
|
|
293
|
+
onMouseDown={event => event.preventDefault()} // prevent the button from stealing focus
|
|
294
|
+
onClick={event => {
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
event.stopPropagation();
|
|
297
|
+
increaseNumericValue();
|
|
298
|
+
focusInput(event.target);
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
<Icon id="chevron-up" />
|
|
302
|
+
</IconButton>
|
|
303
|
+
|
|
304
|
+
<IconButton
|
|
305
|
+
className={classes.numericSpinnerDown}
|
|
306
|
+
tabIndex="-1"
|
|
307
|
+
data-qa="decrease"
|
|
308
|
+
disabled={disabled}
|
|
309
|
+
onMouseDown={event => event.preventDefault()} // prevent the button from stealing focus
|
|
310
|
+
onClick={event => {
|
|
311
|
+
event.preventDefault();
|
|
312
|
+
event.stopPropagation();
|
|
313
|
+
decreaseNumericValue();
|
|
314
|
+
focusInput(event.target);
|
|
315
|
+
}}
|
|
316
|
+
>
|
|
317
|
+
<Icon id="chevron-down" />
|
|
318
|
+
</IconButton>
|
|
319
|
+
</div>
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
onKeyDown = event => {
|
|
323
|
+
if (event.key === "ArrowUp") {
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
event.stopPropagation();
|
|
326
|
+
|
|
327
|
+
increaseNumericValue();
|
|
328
|
+
}
|
|
329
|
+
// Note Alex20260119: using an 'else if' caused issue with code coverage
|
|
330
|
+
if (event.key === "ArrowDown") {
|
|
331
|
+
event.preventDefault();
|
|
332
|
+
event.stopPropagation();
|
|
333
|
+
|
|
334
|
+
decreaseNumericValue();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
onWheel = event => {
|
|
339
|
+
if (event.deltaY < 0) {
|
|
340
|
+
increaseNumericValue();
|
|
341
|
+
} else {
|
|
342
|
+
decreaseNumericValue();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
focusInput(event.target);
|
|
346
|
+
};
|
|
347
|
+
}
|
|
160
348
|
}
|
|
161
349
|
|
|
162
350
|
const defaultRows = 4;
|
|
@@ -170,7 +358,6 @@ const InputBase = ({ inputProps }) => {
|
|
|
170
358
|
// causing onBlur to never fire
|
|
171
359
|
item.target.focus();
|
|
172
360
|
};
|
|
173
|
-
const classes = useStyles({ label, errorPosition });
|
|
174
361
|
|
|
175
362
|
const onChangeHandler = event => {
|
|
176
363
|
if (event.persist) {
|
|
@@ -222,8 +409,6 @@ const InputBase = ({ inputProps }) => {
|
|
|
222
409
|
|
|
223
410
|
const inputBaseInputStyle = inputProps?.getStyle(InputBaseProps.ruleNames.input);
|
|
224
411
|
const errorTextStyle = inputProps?.getStyle(InputBaseProps.ruleNames.errorText);
|
|
225
|
-
const [inputText, setInputText] = React.useState(null);
|
|
226
|
-
const textToDisplay = inputText ?? value;
|
|
227
412
|
|
|
228
413
|
React.useEffect(() => {
|
|
229
414
|
if (inputText === null || window.bypassDebounce === true) {
|
|
@@ -249,6 +434,21 @@ const InputBase = ({ inputProps }) => {
|
|
|
249
434
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
250
435
|
}, [inputText, metadata, timeoutDelay, update, value]);
|
|
251
436
|
|
|
437
|
+
if (onKeyDown) {
|
|
438
|
+
if (inputAttributes.onKeyDown) {
|
|
439
|
+
const originalKeyDown = inputAttributes.onKeyDown;
|
|
440
|
+
inputAttributes.onKeyDown = event => {
|
|
441
|
+
originalKeyDown(event);
|
|
442
|
+
|
|
443
|
+
if (!event.isDefaultPrevented()) {
|
|
444
|
+
onKeyDown(event);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
} else {
|
|
448
|
+
inputAttributes.onKeyDown = onKeyDown;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
252
452
|
return (
|
|
253
453
|
<div className={classes.container}>
|
|
254
454
|
<div className={classes.inputContainer}>
|
|
@@ -267,6 +467,7 @@ const InputBase = ({ inputProps }) => {
|
|
|
267
467
|
placeholder={placeholder}
|
|
268
468
|
value={textToDisplay}
|
|
269
469
|
fullWidth={true}
|
|
470
|
+
onWheel={onWheel}
|
|
270
471
|
onChange={event => onChangeHandler(event)}
|
|
271
472
|
error={!!error}
|
|
272
473
|
inputProps={inputAttributes}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { mount } from "enzyme";
|
|
3
|
-
import InputBase, { AdvancedNumericInput } from "./InputBase";
|
|
3
|
+
import InputBase, { AdvancedIntegerInput, AdvancedNumericInput } from "./InputBase";
|
|
4
4
|
import InputBaseMUI from "@material-ui/core/InputBase";
|
|
5
5
|
import sinon from "sinon";
|
|
6
6
|
import { ignoreConsoleError } from "../../../utils/testUtils";
|
|
@@ -317,7 +317,7 @@ describe("InputBase Component", () => {
|
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
|
|
320
|
-
describe("InputBase component
|
|
320
|
+
describe("InputBase component debounce", () => {
|
|
321
321
|
const clock = sinon.useFakeTimers();
|
|
322
322
|
let update, container;
|
|
323
323
|
|
|
@@ -399,7 +399,7 @@ describe("AdvancedNumericInput", () => {
|
|
|
399
399
|
container = null;
|
|
400
400
|
});
|
|
401
401
|
|
|
402
|
-
it("Renders InputBase component as advanced numeric input", () => {
|
|
402
|
+
it("Renders InputBase component as advanced numeric input with decimals", () => {
|
|
403
403
|
const inputProps = new InputBaseProps();
|
|
404
404
|
const aLabel = "aLabel";
|
|
405
405
|
const aValue = "value";
|
|
@@ -408,6 +408,7 @@ describe("AdvancedNumericInput", () => {
|
|
|
408
408
|
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
409
409
|
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
410
410
|
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
411
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
411
412
|
|
|
412
413
|
const component = <InputBase inputProps={inputProps} />;
|
|
413
414
|
|
|
@@ -417,6 +418,24 @@ describe("AdvancedNumericInput", () => {
|
|
|
417
418
|
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
418
419
|
});
|
|
419
420
|
|
|
421
|
+
it("Renders InputBase component as advanced numeric input without decimals", () => {
|
|
422
|
+
const inputProps = new InputBaseProps();
|
|
423
|
+
const aLabel = "aLabel";
|
|
424
|
+
const aValue = "value";
|
|
425
|
+
|
|
426
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
427
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
428
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
429
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
430
|
+
|
|
431
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
432
|
+
|
|
433
|
+
const mountedComponent = mount(component);
|
|
434
|
+
const expected = <InputBaseMUI value={aValue} title="" inputComponent={AdvancedIntegerInput} />;
|
|
435
|
+
|
|
436
|
+
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
437
|
+
});
|
|
438
|
+
|
|
420
439
|
it("Renders InputBase component as advanced numeric input with custom numeric props", () => {
|
|
421
440
|
const inputProps = new InputBaseProps();
|
|
422
441
|
const aLabel = "aLabel";
|
|
@@ -946,4 +965,463 @@ describe("AdvancedNumericInput", () => {
|
|
|
946
965
|
|
|
947
966
|
expect(update, "to have calls satisfying", [{ args: ["", metadata] }]);
|
|
948
967
|
});
|
|
968
|
+
|
|
969
|
+
it("Change advanced numeric input value with decimal does not have the spinner buttons", () => {
|
|
970
|
+
const inputProps = new InputBaseProps();
|
|
971
|
+
const aLabel = "aLabel";
|
|
972
|
+
const aValue = "";
|
|
973
|
+
|
|
974
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
975
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
976
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
977
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
978
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
979
|
+
|
|
980
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
981
|
+
const mountedComponent = mount(component);
|
|
982
|
+
const btn = mountedComponent.find("[data-qa='increase']");
|
|
983
|
+
expect(btn.length, "to be", 0);
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
it("Disabled advanced numeric input value without decimals should not have the increase/decrease buttons", () => {
|
|
987
|
+
const inputProps = new InputBaseProps();
|
|
988
|
+
const aLabel = "aLabel";
|
|
989
|
+
const aValue = "";
|
|
990
|
+
|
|
991
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
992
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
993
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
994
|
+
inputProps.set(InputBaseProps.propNames.disabled, true);
|
|
995
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
996
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
997
|
+
|
|
998
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
999
|
+
const mountedComponent = mount(component);
|
|
1000
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1001
|
+
expect(btn.length, "to equal", 0);
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
it("Advanced numeric input value without decimals, simulate onMouseDown to make code coverage happy", () => {
|
|
1005
|
+
const inputProps = new InputBaseProps();
|
|
1006
|
+
const aLabel = "aLabel";
|
|
1007
|
+
const aValue = "";
|
|
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 btnIncrease = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1018
|
+
const btnDecrease = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1019
|
+
|
|
1020
|
+
btnIncrease.simulate("mouseDown");
|
|
1021
|
+
btnDecrease.simulate("mouseDown");
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
it("Advanced numeric input value without decimals but with custom onKeyDown with prevent default", () => {
|
|
1025
|
+
const keydownSpy = sinon.stub().callsFake(e => {
|
|
1026
|
+
e.preventDefault();
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
const inputProps = new InputBaseProps();
|
|
1030
|
+
const aLabel = "aLabel";
|
|
1031
|
+
const aValue = "";
|
|
1032
|
+
|
|
1033
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1034
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1035
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1036
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1037
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1038
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { onKeyDown: keydownSpy });
|
|
1039
|
+
|
|
1040
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1041
|
+
const mountedComponent = mount(component);
|
|
1042
|
+
const input = mountedComponent.find("input");
|
|
1043
|
+
input.simulate("keydown", { key: "ArrowUp" });
|
|
1044
|
+
|
|
1045
|
+
expect(keydownSpy, "was called once");
|
|
1046
|
+
expect(update, "was not called");
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
it("Advanced numeric input value without decimals but with custom onKeyDown without prevent default", () => {
|
|
1050
|
+
const keydownSpy = sinon.stub().callsFake(e => {});
|
|
1051
|
+
|
|
1052
|
+
const inputProps = new InputBaseProps();
|
|
1053
|
+
const aLabel = "aLabel";
|
|
1054
|
+
const aValue = "";
|
|
1055
|
+
|
|
1056
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1057
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1058
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1059
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1060
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1061
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { onKeyDown: keydownSpy });
|
|
1062
|
+
|
|
1063
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1064
|
+
const mountedComponent = mount(component);
|
|
1065
|
+
const input = mountedComponent.find("input");
|
|
1066
|
+
input.simulate("keydown", { key: "ArrowUp" });
|
|
1067
|
+
|
|
1068
|
+
expect(keydownSpy, "was called once");
|
|
1069
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
it("Change advanced numeric input value, empty initial value with increase button", () => {
|
|
1073
|
+
const inputProps = new InputBaseProps();
|
|
1074
|
+
const aLabel = "aLabel";
|
|
1075
|
+
const aValue = "";
|
|
1076
|
+
|
|
1077
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1078
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1079
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1080
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1081
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1082
|
+
|
|
1083
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1084
|
+
const mountedComponent = mount(component);
|
|
1085
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1086
|
+
btn.simulate("click");
|
|
1087
|
+
|
|
1088
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
it("Change advanced numeric input value, 1 initial value with increase button", () => {
|
|
1092
|
+
const inputProps = new InputBaseProps();
|
|
1093
|
+
const aLabel = "aLabel";
|
|
1094
|
+
const aValue = "1";
|
|
1095
|
+
|
|
1096
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1097
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1098
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1099
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1100
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1101
|
+
|
|
1102
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1103
|
+
const mountedComponent = mount(component);
|
|
1104
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1105
|
+
btn.simulate("click");
|
|
1106
|
+
|
|
1107
|
+
expect(update, "to have calls satisfying", [{ args: ["2", null] }]);
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1110
|
+
it("Change advanced numeric input value, 10 initial value with max 11 with increase button", () => {
|
|
1111
|
+
const inputProps = new InputBaseProps();
|
|
1112
|
+
const aLabel = "aLabel";
|
|
1113
|
+
const aValue = "10";
|
|
1114
|
+
|
|
1115
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1116
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1117
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1118
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1119
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1120
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1121
|
+
|
|
1122
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1123
|
+
const mountedComponent = mount(component);
|
|
1124
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1125
|
+
btn.simulate("click");
|
|
1126
|
+
|
|
1127
|
+
expect(update, "to have calls satisfying", [{ args: ["11", null] }]);
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
it("Change advanced numeric input value, 11 initial value with max 11 with increase button stays at 11", () => {
|
|
1131
|
+
const inputProps = new InputBaseProps();
|
|
1132
|
+
const aLabel = "aLabel";
|
|
1133
|
+
const aValue = "11";
|
|
1134
|
+
|
|
1135
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1136
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1137
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1138
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1139
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1140
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1141
|
+
|
|
1142
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1143
|
+
const mountedComponent = mount(component);
|
|
1144
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1145
|
+
btn.simulate("click");
|
|
1146
|
+
|
|
1147
|
+
expect(update, "was not called");
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
|
|
1151
|
+
const inputProps = new InputBaseProps();
|
|
1152
|
+
const aLabel = "aLabel";
|
|
1153
|
+
const aValue = "";
|
|
1154
|
+
|
|
1155
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1156
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1157
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1158
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1159
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1160
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1161
|
+
|
|
1162
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1163
|
+
const mountedComponent = mount(component);
|
|
1164
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1165
|
+
btn.simulate("click");
|
|
1166
|
+
|
|
1167
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
it("Change advanced numeric input value, empty initial value, min=-15, max=-5, increase button set value to -5", () => {
|
|
1171
|
+
const inputProps = new InputBaseProps();
|
|
1172
|
+
const aLabel = "aLabel";
|
|
1173
|
+
const aValue = "";
|
|
1174
|
+
|
|
1175
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1176
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1177
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1178
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1179
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1180
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -15, max: -5 });
|
|
1181
|
+
|
|
1182
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1183
|
+
const mountedComponent = mount(component);
|
|
1184
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1185
|
+
btn.simulate("click");
|
|
1186
|
+
|
|
1187
|
+
expect(update, "to have calls satisfying", [{ args: ["-5", null] }]);
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
|
|
1191
|
+
const inputProps = new InputBaseProps();
|
|
1192
|
+
const aLabel = "aLabel";
|
|
1193
|
+
const aValue = "";
|
|
1194
|
+
|
|
1195
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1196
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1197
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1198
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1199
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1200
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1201
|
+
|
|
1202
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1203
|
+
const mountedComponent = mount(component);
|
|
1204
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1205
|
+
btn.simulate("click");
|
|
1206
|
+
|
|
1207
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, key up set value to 1", () => {
|
|
1211
|
+
const inputProps = new InputBaseProps();
|
|
1212
|
+
const aLabel = "aLabel";
|
|
1213
|
+
const aValue = "";
|
|
1214
|
+
|
|
1215
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1216
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1217
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1218
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1219
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1220
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1221
|
+
|
|
1222
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1223
|
+
const mountedComponent = mount(component);
|
|
1224
|
+
const input = mountedComponent.find("input");
|
|
1225
|
+
input.simulate("keydown", { key: "ArrowUp" });
|
|
1226
|
+
|
|
1227
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll up set value to 1", () => {
|
|
1231
|
+
const inputProps = new InputBaseProps();
|
|
1232
|
+
const aLabel = "aLabel";
|
|
1233
|
+
const aValue = "";
|
|
1234
|
+
|
|
1235
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1236
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1237
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1238
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1239
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1240
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1241
|
+
|
|
1242
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1243
|
+
const mountedComponent = mount(component);
|
|
1244
|
+
const input = mountedComponent.find("input");
|
|
1245
|
+
input.simulate("wheel", { deltaY: -100 });
|
|
1246
|
+
|
|
1247
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
it("Change advanced numeric input value, empty initial value with decrease button", () => {
|
|
1251
|
+
const inputProps = new InputBaseProps();
|
|
1252
|
+
const aLabel = "aLabel";
|
|
1253
|
+
const aValue = "";
|
|
1254
|
+
|
|
1255
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1256
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1257
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1258
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1259
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1260
|
+
|
|
1261
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1262
|
+
const mountedComponent = mount(component);
|
|
1263
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1264
|
+
btn.simulate("click");
|
|
1265
|
+
|
|
1266
|
+
expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
it("Change advanced numeric input value, -1 initial value with decrease button", () => {
|
|
1270
|
+
const inputProps = new InputBaseProps();
|
|
1271
|
+
const aLabel = "aLabel";
|
|
1272
|
+
const aValue = "-1";
|
|
1273
|
+
|
|
1274
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1275
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1276
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1277
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1278
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1279
|
+
|
|
1280
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1281
|
+
const mountedComponent = mount(component);
|
|
1282
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1283
|
+
btn.simulate("click");
|
|
1284
|
+
|
|
1285
|
+
expect(update, "to have calls satisfying", [{ args: ["-2", null] }]);
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
it("Change advanced numeric input value, -10 initial value with min 11 with decrease button", () => {
|
|
1289
|
+
const inputProps = new InputBaseProps();
|
|
1290
|
+
const aLabel = "aLabel";
|
|
1291
|
+
const aValue = "-10";
|
|
1292
|
+
|
|
1293
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1294
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1295
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1296
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1297
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1298
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1299
|
+
|
|
1300
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1301
|
+
const mountedComponent = mount(component);
|
|
1302
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1303
|
+
btn.simulate("click");
|
|
1304
|
+
|
|
1305
|
+
expect(update, "to have calls satisfying", [{ args: ["-11", null] }]);
|
|
1306
|
+
});
|
|
1307
|
+
|
|
1308
|
+
it("Change advanced numeric input value, -11 initial value with min -11 with decrease button stays at -11", () => {
|
|
1309
|
+
const inputProps = new InputBaseProps();
|
|
1310
|
+
const aLabel = "aLabel";
|
|
1311
|
+
const aValue = "-11";
|
|
1312
|
+
|
|
1313
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1314
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1315
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1316
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1317
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1318
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1319
|
+
|
|
1320
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1321
|
+
const mountedComponent = mount(component);
|
|
1322
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1323
|
+
btn.simulate("click");
|
|
1324
|
+
|
|
1325
|
+
expect(update, "was not called");
|
|
1326
|
+
});
|
|
1327
|
+
|
|
1328
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button should set to 5", () => {
|
|
1329
|
+
const inputProps = new InputBaseProps();
|
|
1330
|
+
const aLabel = "aLabel";
|
|
1331
|
+
const aValue = "";
|
|
1332
|
+
|
|
1333
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1334
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1335
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1336
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1337
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1338
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1339
|
+
|
|
1340
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1341
|
+
const mountedComponent = mount(component);
|
|
1342
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1343
|
+
btn.simulate("click");
|
|
1344
|
+
|
|
1345
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1346
|
+
});
|
|
1347
|
+
|
|
1348
|
+
it("Change advanced numeric input value, empty initial value, min=-15, max=-5, decrease button set value to -5", () => {
|
|
1349
|
+
const inputProps = new InputBaseProps();
|
|
1350
|
+
const aLabel = "aLabel";
|
|
1351
|
+
const aValue = "";
|
|
1352
|
+
|
|
1353
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1354
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1355
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1356
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1357
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1358
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -15, max: -5 });
|
|
1359
|
+
|
|
1360
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1361
|
+
const mountedComponent = mount(component);
|
|
1362
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1363
|
+
btn.simulate("click");
|
|
1364
|
+
|
|
1365
|
+
expect(update, "to have calls satisfying", [{ args: ["-5", null] }]);
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button set value to 5", () => {
|
|
1369
|
+
const inputProps = new InputBaseProps();
|
|
1370
|
+
const aLabel = "aLabel";
|
|
1371
|
+
const aValue = "";
|
|
1372
|
+
|
|
1373
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1374
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1375
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1376
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1377
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1378
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1379
|
+
|
|
1380
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1381
|
+
const mountedComponent = mount(component);
|
|
1382
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1383
|
+
btn.simulate("click");
|
|
1384
|
+
|
|
1385
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1386
|
+
});
|
|
1387
|
+
|
|
1388
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, key down set value to 1", () => {
|
|
1389
|
+
const inputProps = new InputBaseProps();
|
|
1390
|
+
const aLabel = "aLabel";
|
|
1391
|
+
const aValue = "";
|
|
1392
|
+
|
|
1393
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1394
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1395
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1396
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1397
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1398
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1399
|
+
|
|
1400
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1401
|
+
const mountedComponent = mount(component);
|
|
1402
|
+
const input = mountedComponent.find("input");
|
|
1403
|
+
input.simulate("keydown", { key: "ArrowDown" });
|
|
1404
|
+
|
|
1405
|
+
expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll down set value to 1", () => {
|
|
1409
|
+
const inputProps = new InputBaseProps();
|
|
1410
|
+
const aLabel = "aLabel";
|
|
1411
|
+
const aValue = "";
|
|
1412
|
+
|
|
1413
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1414
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1415
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1416
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1417
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1418
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1419
|
+
|
|
1420
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1421
|
+
const mountedComponent = mount(component);
|
|
1422
|
+
const input = mountedComponent.find("input");
|
|
1423
|
+
input.simulate("wheel", { deltaY: 100 });
|
|
1424
|
+
|
|
1425
|
+
expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
|
|
1426
|
+
});
|
|
949
1427
|
});
|