orc-shared 5.10.2-dev.4 → 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 +32 -15
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +6 -18
- package/src/components/MaterialUI/Inputs/InputBase.js +53 -35
- package/src/components/MaterialUI/Inputs/InputBase.test.js +21 -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,
|
|
@@ -439,12 +457,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
439
457
|
className: classes.inputContainer
|
|
440
458
|
}, label && /*#__PURE__*/_react.default.createElement("label", {
|
|
441
459
|
className: "".concat(classes.prepend, " ").concat(disabled && classes.disabledPrepend)
|
|
442
|
-
}, label), /*#__PURE__*/_react.default.createElement(
|
|
443
|
-
style: {
|
|
444
|
-
display: "flex"
|
|
445
|
-
},
|
|
446
|
-
className: "InputBase-input-wrapper"
|
|
447
|
-
}, /*#__PURE__*/_react.default.createElement(_InputBase.default, {
|
|
460
|
+
}, label), /*#__PURE__*/_react.default.createElement(_InputBase.default, {
|
|
448
461
|
classes: {
|
|
449
462
|
input: (0, _classnames.default)(classes.controlInput, inputBaseInputStyle),
|
|
450
463
|
error: classes.errorInput,
|
|
@@ -472,7 +485,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
472
485
|
minRows: rows,
|
|
473
486
|
title: tooltipText,
|
|
474
487
|
autoComplete: autoComplete
|
|
475
|
-
})
|
|
488
|
+
})), error && /*#__PURE__*/_react.default.createElement("div", {
|
|
476
489
|
className: (0, _classnames.default)(classes.errorText, errorTextStyle)
|
|
477
490
|
}, error));
|
|
478
491
|
};
|
|
@@ -496,6 +509,8 @@ var _default3 = exports.default = _default2;
|
|
|
496
509
|
}
|
|
497
510
|
reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
498
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");
|
|
499
514
|
reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
500
515
|
reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
501
516
|
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
@@ -513,6 +528,8 @@ var _default3 = exports.default = _default2;
|
|
|
513
528
|
}
|
|
514
529
|
reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
515
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");
|
|
516
533
|
reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
517
534
|
reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
|
|
518
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}
|
|
@@ -432,36 +453,33 @@ const InputBase = ({ inputProps }) => {
|
|
|
432
453
|
<div className={classes.container}>
|
|
433
454
|
<div className={classes.inputContainer}>
|
|
434
455
|
{label && <label className={`${classes.prepend} ${disabled && classes.disabledPrepend}`}>{label}</label>}
|
|
435
|
-
<
|
|
436
|
-
|
|
437
|
-
classes
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
/>
|
|
463
|
-
{controlSpecificSuffix}
|
|
464
|
-
</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
|
+
/>
|
|
465
483
|
</div>
|
|
466
484
|
{error && <div className={classNames(classes.errorText, errorTextStyle)}>{error}</div>}
|
|
467
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";
|