orc-shared 5.10.2-dev.3 → 5.10.2-dev.5
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/Inputs/InputBase.js +45 -16
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +6 -18
- package/src/components/MaterialUI/Inputs/InputBase.js +68 -36
- package/src/components/MaterialUI/Inputs/InputBase.test.js +69 -2
|
@@ -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"));
|
|
@@ -11,7 +11,8 @@ var _reactNumberFormat = require("react-number-format");
|
|
|
11
11
|
var _inputHelper = require("../../../utils/inputHelper");
|
|
12
12
|
var _Icon = _interopRequireDefault(require("../DataDisplay/Icon"));
|
|
13
13
|
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
14
|
-
var _excluded = ["inputRef", "onChange"]
|
|
14
|
+
var _excluded = ["inputRef", "onChange"],
|
|
15
|
+
_excluded2 = ["integerButtons"];
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
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); }
|
|
17
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; }
|
|
@@ -186,8 +187,27 @@ var AdvancedNumericInput = exports.AdvancedNumericInput = function AdvancedNumer
|
|
|
186
187
|
}
|
|
187
188
|
}));
|
|
188
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
|
+
};
|
|
189
209
|
var InputBase = function InputBase(_ref) {
|
|
190
|
-
var _inputProps$get;
|
|
210
|
+
var _inputProps$get, _numericInputProps$de;
|
|
191
211
|
var inputProps = _ref.inputProps;
|
|
192
212
|
if ((0, _InputBaseProps.isInputProps)(inputProps) === false) {
|
|
193
213
|
throw new TypeError("inputProps property is not of type InputBaseProps");
|
|
@@ -211,7 +231,8 @@ var InputBase = function InputBase(_ref) {
|
|
|
211
231
|
var rowsProps = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.rows);
|
|
212
232
|
var numericInputProps = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.numericInputProps)) || null;
|
|
213
233
|
var isAdvancedNumericInput = type.toLowerCase() === "advancednumericinput";
|
|
214
|
-
var
|
|
234
|
+
var decimalScale = (_numericInputProps$de = numericInputProps == null ? void 0 : numericInputProps.decimalScale) != null ? _numericInputProps$de : 0;
|
|
235
|
+
var inputComponent = getInputComponent(isAdvancedNumericInput, decimalScale);
|
|
215
236
|
var inputControlType = isAdvancedNumericInput ? "text" : type;
|
|
216
237
|
var _React$useState = _react.default.useState(null),
|
|
217
238
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -223,7 +244,6 @@ var InputBase = function InputBase(_ref) {
|
|
|
223
244
|
errorPosition: errorPosition,
|
|
224
245
|
isAdvancedNumericInput: isAdvancedNumericInput
|
|
225
246
|
});
|
|
226
|
-
var controlSpecificSuffix = null;
|
|
227
247
|
var onKeyDown = null;
|
|
228
248
|
var onWheel = null;
|
|
229
249
|
if (isAdvancedNumericInput && numericInputProps) {
|
|
@@ -234,14 +254,12 @@ var InputBase = function InputBase(_ref) {
|
|
|
234
254
|
});
|
|
235
255
|
}
|
|
236
256
|
if (isAdvancedNumericInput) {
|
|
237
|
-
var _numericInputProps$de;
|
|
238
257
|
if (inputAttributes.max === undefined) {
|
|
239
258
|
inputAttributes.max = 2147483647;
|
|
240
259
|
}
|
|
241
260
|
if (inputAttributes.min === undefined) {
|
|
242
261
|
inputAttributes.min = -2147483648;
|
|
243
262
|
}
|
|
244
|
-
var decimalScale = (_numericInputProps$de = numericInputProps == null ? void 0 : numericInputProps.decimalScale) != null ? _numericInputProps$de : 0;
|
|
245
263
|
var lengthForMin = Math.trunc(inputAttributes.min).toString().length;
|
|
246
264
|
var lengthForMax = Math.trunc(inputAttributes.max).toString().length;
|
|
247
265
|
inputAttributes.maxLength = Math.max(lengthForMin, lengthForMax) + (decimalScale > 0 ? decimalScale + 1 : 0);
|
|
@@ -289,7 +307,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
289
307
|
var focusInput = function focusInput(target) {
|
|
290
308
|
target.closest(".InputBase-input-wrapper").getElementsByTagName("input")[0].focus();
|
|
291
309
|
};
|
|
292
|
-
|
|
310
|
+
inputAttributes.integerButtons = /*#__PURE__*/_react.default.createElement("div", {
|
|
293
311
|
className: classes.numericSpinnerContainer
|
|
294
312
|
}, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
295
313
|
className: classes.numericSpinnerUp,
|
|
@@ -420,18 +438,26 @@ var InputBase = function InputBase(_ref) {
|
|
|
420
438
|
|
|
421
439
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
422
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
|
+
}
|
|
423
454
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
424
455
|
className: classes.container
|
|
425
456
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
426
457
|
className: classes.inputContainer
|
|
427
458
|
}, label && /*#__PURE__*/_react.default.createElement("label", {
|
|
428
459
|
className: "".concat(classes.prepend, " ").concat(disabled && classes.disabledPrepend)
|
|
429
|
-
}, label), /*#__PURE__*/_react.default.createElement(
|
|
430
|
-
style: {
|
|
431
|
-
display: "flex"
|
|
432
|
-
},
|
|
433
|
-
className: "InputBase-input-wrapper"
|
|
434
|
-
}, /*#__PURE__*/_react.default.createElement(_InputBase.default, {
|
|
460
|
+
}, label), /*#__PURE__*/_react.default.createElement(_InputBase.default, {
|
|
435
461
|
classes: {
|
|
436
462
|
input: (0, _classnames.default)(classes.controlInput, inputBaseInputStyle),
|
|
437
463
|
error: classes.errorInput,
|
|
@@ -445,7 +471,6 @@ var InputBase = function InputBase(_ref) {
|
|
|
445
471
|
placeholder: placeholder,
|
|
446
472
|
value: textToDisplay,
|
|
447
473
|
fullWidth: true,
|
|
448
|
-
onKeyDown: onKeyDown,
|
|
449
474
|
onWheel: onWheel,
|
|
450
475
|
onChange: function onChange(event) {
|
|
451
476
|
return onChangeHandler(event);
|
|
@@ -460,7 +485,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
460
485
|
minRows: rows,
|
|
461
486
|
title: tooltipText,
|
|
462
487
|
autoComplete: autoComplete
|
|
463
|
-
})
|
|
488
|
+
})), error && /*#__PURE__*/_react.default.createElement("div", {
|
|
464
489
|
className: (0, _classnames.default)(classes.errorText, errorTextStyle)
|
|
465
490
|
}, error));
|
|
466
491
|
};
|
|
@@ -484,6 +509,8 @@ var _default3 = exports.default = _default2;
|
|
|
484
509
|
}
|
|
485
510
|
reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
486
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");
|
|
487
514
|
reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
488
515
|
reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
489
516
|
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
@@ -501,6 +528,8 @@ var _default3 = exports.default = _default2;
|
|
|
501
528
|
}
|
|
502
529
|
reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
503
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");
|
|
504
533
|
reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
505
534
|
reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
506
535
|
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
package/package.json
CHANGED
|
@@ -50,9 +50,7 @@ describe("Translations ", () => {
|
|
|
50
50
|
<div>
|
|
51
51
|
<div>
|
|
52
52
|
<label>{"en-US"}</label>
|
|
53
|
-
<
|
|
54
|
-
<InputBase />
|
|
55
|
-
</div>
|
|
53
|
+
<InputBase />
|
|
56
54
|
</div>
|
|
57
55
|
</div>
|
|
58
56
|
</div>
|
|
@@ -63,9 +61,7 @@ describe("Translations ", () => {
|
|
|
63
61
|
<div>
|
|
64
62
|
<div>
|
|
65
63
|
<label>{"en-CA"}</label>
|
|
66
|
-
<
|
|
67
|
-
<InputBase />
|
|
68
|
-
</div>
|
|
64
|
+
<InputBase />
|
|
69
65
|
</div>
|
|
70
66
|
</div>
|
|
71
67
|
</div>,
|
|
@@ -73,9 +69,7 @@ describe("Translations ", () => {
|
|
|
73
69
|
<div>
|
|
74
70
|
<div>
|
|
75
71
|
<label>{"fr-CA"}</label>
|
|
76
|
-
<
|
|
77
|
-
<InputBase />
|
|
78
|
-
</div>
|
|
72
|
+
<InputBase />
|
|
79
73
|
</div>
|
|
80
74
|
</div>
|
|
81
75
|
</div>,
|
|
@@ -108,9 +102,7 @@ describe("Translations ", () => {
|
|
|
108
102
|
<div>
|
|
109
103
|
<div>
|
|
110
104
|
<label>{"en-US"}</label>
|
|
111
|
-
<
|
|
112
|
-
<InputBase />
|
|
113
|
-
</div>
|
|
105
|
+
<InputBase />
|
|
114
106
|
</div>
|
|
115
107
|
<div>{aError}</div>
|
|
116
108
|
</div>
|
|
@@ -122,9 +114,7 @@ describe("Translations ", () => {
|
|
|
122
114
|
<div>
|
|
123
115
|
<div>
|
|
124
116
|
<label>{"en-CA"}</label>
|
|
125
|
-
<
|
|
126
|
-
<InputBase />
|
|
127
|
-
</div>
|
|
117
|
+
<InputBase />
|
|
128
118
|
</div>
|
|
129
119
|
</div>
|
|
130
120
|
</div>,
|
|
@@ -132,9 +122,7 @@ describe("Translations ", () => {
|
|
|
132
122
|
<div>
|
|
133
123
|
<div>
|
|
134
124
|
<label>{"fr-CA"}</label>
|
|
135
|
-
<
|
|
136
|
-
<InputBase />
|
|
137
|
-
</div>
|
|
125
|
+
<InputBase />
|
|
138
126
|
</div>
|
|
139
127
|
</div>
|
|
140
128
|
</div>,
|
|
@@ -153,6 +153,29 @@ export const AdvancedNumericInput = props => {
|
|
|
153
153
|
);
|
|
154
154
|
};
|
|
155
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
|
+
|
|
156
179
|
const InputBase = ({ inputProps }) => {
|
|
157
180
|
if (isInputProps(inputProps) === false) {
|
|
158
181
|
throw new TypeError("inputProps property is not of type InputBaseProps");
|
|
@@ -178,13 +201,13 @@ const InputBase = ({ inputProps }) => {
|
|
|
178
201
|
const numericInputProps = inputProps?.get(InputBaseProps.propNames.numericInputProps) || null;
|
|
179
202
|
|
|
180
203
|
const isAdvancedNumericInput = type.toLowerCase() === "advancednumericinput";
|
|
181
|
-
const
|
|
204
|
+
const decimalScale = numericInputProps?.decimalScale ?? 0;
|
|
205
|
+
const inputComponent = getInputComponent(isAdvancedNumericInput, decimalScale);
|
|
182
206
|
const inputControlType = isAdvancedNumericInput ? "text" : type;
|
|
183
207
|
const [inputText, setInputText] = React.useState(null);
|
|
184
208
|
const textToDisplay = inputText ?? value;
|
|
185
209
|
const classes = useStyles({ label, errorPosition, isAdvancedNumericInput });
|
|
186
210
|
|
|
187
|
-
let controlSpecificSuffix = null;
|
|
188
211
|
let onKeyDown = null;
|
|
189
212
|
let onWheel = null;
|
|
190
213
|
|
|
@@ -205,8 +228,6 @@ const InputBase = ({ inputProps }) => {
|
|
|
205
228
|
inputAttributes.min = -2147483648;
|
|
206
229
|
}
|
|
207
230
|
|
|
208
|
-
const decimalScale = numericInputProps?.decimalScale ?? 0;
|
|
209
|
-
|
|
210
231
|
const lengthForMin = Math.trunc(inputAttributes.min).toString().length;
|
|
211
232
|
const lengthForMax = Math.trunc(inputAttributes.max).toString().length;
|
|
212
233
|
|
|
@@ -262,7 +283,7 @@ const InputBase = ({ inputProps }) => {
|
|
|
262
283
|
target.closest(".InputBase-input-wrapper").getElementsByTagName("input")[0].focus();
|
|
263
284
|
};
|
|
264
285
|
|
|
265
|
-
|
|
286
|
+
inputAttributes.integerButtons = (
|
|
266
287
|
<div className={classes.numericSpinnerContainer}>
|
|
267
288
|
<IconButton
|
|
268
289
|
className={classes.numericSpinnerUp}
|
|
@@ -413,41 +434,52 @@ const InputBase = ({ inputProps }) => {
|
|
|
413
434
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
414
435
|
}, [inputText, metadata, timeoutDelay, update, value]);
|
|
415
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
|
+
|
|
416
452
|
return (
|
|
417
453
|
<div className={classes.container}>
|
|
418
454
|
<div className={classes.inputContainer}>
|
|
419
455
|
{label && <label className={`${classes.prepend} ${disabled && classes.disabledPrepend}`}>{label}</label>}
|
|
420
|
-
<
|
|
421
|
-
|
|
422
|
-
classes
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
autoComplete={autoComplete}
|
|
448
|
-
/>
|
|
449
|
-
{controlSpecificSuffix}
|
|
450
|
-
</div>
|
|
456
|
+
<InputBaseMUI
|
|
457
|
+
classes={{
|
|
458
|
+
input: classNames(classes.controlInput, inputBaseInputStyle),
|
|
459
|
+
error: classes.errorInput,
|
|
460
|
+
disabled: classes.disabled,
|
|
461
|
+
multiline: classes.multiline,
|
|
462
|
+
inputMultiline: classes.inputMultiline,
|
|
463
|
+
}}
|
|
464
|
+
onBlur={onBlurInternal}
|
|
465
|
+
onClick={onClick}
|
|
466
|
+
type={inputControlType}
|
|
467
|
+
placeholder={placeholder}
|
|
468
|
+
value={textToDisplay}
|
|
469
|
+
fullWidth={true}
|
|
470
|
+
onWheel={onWheel}
|
|
471
|
+
onChange={event => onChangeHandler(event)}
|
|
472
|
+
error={!!error}
|
|
473
|
+
inputProps={inputAttributes}
|
|
474
|
+
inputComponent={inputComponent}
|
|
475
|
+
disabled={disabled}
|
|
476
|
+
multiline={multiline}
|
|
477
|
+
startAdornment={startAdornment}
|
|
478
|
+
endAdornment={endAdornment}
|
|
479
|
+
minRows={rows}
|
|
480
|
+
title={tooltipText}
|
|
481
|
+
autoComplete={autoComplete}
|
|
482
|
+
/>
|
|
451
483
|
</div>
|
|
452
484
|
{error && <div className={classNames(classes.errorText, errorTextStyle)}>{error}</div>}
|
|
453
485
|
</div>
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -1002,6 +1021,54 @@ describe("AdvancedNumericInput", () => {
|
|
|
1002
1021
|
btnDecrease.simulate("mouseDown");
|
|
1003
1022
|
});
|
|
1004
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
|
+
|
|
1005
1072
|
it("Change advanced numeric input value, empty initial value with increase button", () => {
|
|
1006
1073
|
const inputProps = new InputBaseProps();
|
|
1007
1074
|
const aLabel = "aLabel";
|