x25 17.2.25 → 17.2.26
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/Inputs/DateInput.d.ts +2 -17
- package/Inputs/DateInput.js +32 -83
- package/Inputs/DateInput.js.map +1 -1
- package/Inputs/DateTemplate.d.ts +6 -21
- package/Inputs/DateTemplate.js +36 -89
- package/Inputs/DateTemplate.js.map +1 -1
- package/Inputs/DelayInputChange.d.ts +2 -16
- package/Inputs/DelayInputChange.js +53 -89
- package/Inputs/DelayInputChange.js.map +1 -1
- package/Inputs/NumericInput.d.ts +17 -32
- package/Inputs/NumericInput.js +23 -64
- package/Inputs/NumericInput.js.map +1 -1
- package/Inputs/NumericTemplate.d.ts +22 -37
- package/Inputs/NumericTemplate.js +22 -64
- package/Inputs/NumericTemplate.js.map +1 -1
- package/Inputs/common.d.ts +2 -0
- package/Inputs/common.js +27 -0
- package/Inputs/common.js.map +1 -0
- package/package.json +1 -1
package/Inputs/DateInput.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare type DateInputPropTypes = {
|
|
2
3
|
readonly customClass?: any;
|
|
3
4
|
readonly input: any;
|
|
@@ -16,21 +17,5 @@ declare type DateInputPropTypes = {
|
|
|
16
17
|
readonly onChange?: (event: any) => void;
|
|
17
18
|
readonly onRegisterRef?: (callback: (node: any) => void) => void;
|
|
18
19
|
};
|
|
19
|
-
declare
|
|
20
|
-
value: string;
|
|
21
|
-
};
|
|
22
|
-
import React from "react";
|
|
23
|
-
export declare class DateInput extends React.Component<DateInputPropTypes, DateInputStateTypes> {
|
|
24
|
-
static defaultProps: {
|
|
25
|
-
formatValue: (raw: string) => string;
|
|
26
|
-
normalizeValue: (raw: string) => string;
|
|
27
|
-
};
|
|
28
|
-
state: DateInputStateTypes;
|
|
29
|
-
handleBlur: () => void;
|
|
30
|
-
handleKeyDown: (event: any) => void;
|
|
31
|
-
handleChange: ({ target: { value } }: any) => void;
|
|
32
|
-
UNSAFE_componentWillReceiveProps(nextProps: DateInputPropTypes): void;
|
|
33
|
-
constructor(props: DateInputPropTypes);
|
|
34
|
-
render(): JSX.Element;
|
|
35
|
-
}
|
|
20
|
+
export declare const DateInput: (props: DateInputPropTypes) => JSX.Element;
|
|
36
21
|
export {};
|
package/Inputs/DateInput.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable react/no-unsafe */
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
2
|
var __assign = (this && this.__assign) || function () {
|
|
19
3
|
__assign = Object.assign || function(t) {
|
|
20
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -34,82 +18,47 @@ exports.DateInput = void 0;
|
|
|
34
18
|
var react_1 = __importDefault(require("react"));
|
|
35
19
|
var classnames_1 = __importDefault(require("classnames"));
|
|
36
20
|
var utility_1 = require("../utility");
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
var validation_1 = require("../utility/validation");
|
|
22
|
+
var addZeroIfNeeded = function (raw) {
|
|
23
|
+
var nrOfElements = 3, canAddZero = ((typeof raw === "string") &&
|
|
24
|
+
(raw.split(".").length === nrOfElements));
|
|
25
|
+
if (!canAddZero) {
|
|
26
|
+
return raw;
|
|
27
|
+
}
|
|
28
|
+
var perform = function (value) { return (value.length === 1 ? "0".concat(value) : value); }, parts = raw.split("."), part1 = perform(parts[0]), part2 = perform(parts[1]), part3 = parts[2], newValue = [part1, part2, part3].join(".");
|
|
29
|
+
if ((0, validation_1.isValidDate)(newValue)) {
|
|
30
|
+
return newValue;
|
|
41
31
|
}
|
|
42
32
|
return raw;
|
|
33
|
+
}, normalizeRawDate = function (raw) {
|
|
34
|
+
if ((0, validation_1.isValidDate)(raw)) {
|
|
35
|
+
return (0, utility_1.normalizeDate)(raw);
|
|
36
|
+
}
|
|
37
|
+
return "";
|
|
43
38
|
}, formatRawDate = function (raw) {
|
|
44
|
-
/* eslint-disable no-magic-numbers */
|
|
45
39
|
if (typeof raw !== "undefined") {
|
|
46
40
|
return (0, utility_1.formatDate)(raw);
|
|
47
41
|
}
|
|
48
42
|
return "";
|
|
49
43
|
};
|
|
50
|
-
var DateInput =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
_this.handleBlur = function () {
|
|
63
|
-
var onBlur = _this.props.input.onBlur, _a = _this.props, input = _a.input, normalizeValue = _a.normalizeValue, currentValue = _this.state.value, normalizedValue = normalizeValue(currentValue), shouldRenderAgain = normalizedValue !== "" && currentValue !== normalizedValue;
|
|
64
|
-
input.onChange(normalizedValue);
|
|
65
|
-
/*
|
|
66
|
-
* Swallow the event to prevent Redux Form from
|
|
67
|
-
* extracting the form value
|
|
68
|
-
*/
|
|
69
|
-
onBlur();
|
|
70
|
-
if (shouldRenderAgain) {
|
|
71
|
-
_this.setState({
|
|
72
|
-
value: (0, utility_1.formatDate)(normalizedValue),
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
_this.handleChange = function (_a) {
|
|
77
|
-
var value = _a.target.value;
|
|
78
|
-
_this.props.input.onChange();
|
|
79
|
-
/*
|
|
80
|
-
* Update the internal state to trigger a re-render
|
|
81
|
-
* using the formatted value
|
|
82
|
-
*/
|
|
83
|
-
_this.setState({
|
|
84
|
-
value: value,
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
return _this;
|
|
88
|
-
}
|
|
89
|
-
DateInput.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
90
|
-
var newValue = nextProps.input.value, currentValue = this.state.value, shouldRenderAgain = (0, utility_1.isValidDate)(newValue) && currentValue !== newValue;
|
|
91
|
-
if (newValue === "") {
|
|
92
|
-
this.setState({
|
|
93
|
-
value: "",
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if (shouldRenderAgain) {
|
|
97
|
-
this.setState({
|
|
98
|
-
value: (0, utility_1.formatDate)(newValue),
|
|
99
|
-
});
|
|
44
|
+
var DateInput = function (props) {
|
|
45
|
+
var customClass = props.customClass, input = props.input, onRegisterRef = props.onRegisterRef, tabIndex = props.tabIndex, placeholder = props.placeholder, _a = props.meta, submitting = _a.submitting, touched = _a.touched, error = _a.error, _b = react_1.default.useState(input.value), value = _b[0], setValue = _b[1], valueToShow = formatRawDate(value), updateValue = function (targetValue) {
|
|
46
|
+
var normalizedValue = normalizeRawDate(addZeroIfNeeded(targetValue));
|
|
47
|
+
setValue(targetValue);
|
|
48
|
+
props.input.onChange(normalizedValue);
|
|
49
|
+
}, handleBlur = function (_a) {
|
|
50
|
+
var targetValue = _a.target.value;
|
|
51
|
+
var newValue = addZeroIfNeeded(targetValue), hasChanged = targetValue !== newValue;
|
|
52
|
+
if (hasChanged) {
|
|
53
|
+
updateValue(newValue);
|
|
100
54
|
}
|
|
55
|
+
}, handleChange = function (_a) {
|
|
56
|
+
var targetValue = _a.target.value;
|
|
57
|
+
updateValue(targetValue);
|
|
101
58
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}), disabled: submitting, id: input.name, onBlur: this.handleBlur, onChange: this.handleChange, onKeyDown: this.handleKeyDown, placeholder: placeholder || utility_1.words.DateFormat, ref: onRegisterRef, tabIndex: tabIndex, type: "text", value: formatValue(this.state.value) })));
|
|
107
|
-
};
|
|
108
|
-
DateInput.defaultProps = {
|
|
109
|
-
formatValue: formatRawDate,
|
|
110
|
-
normalizeValue: normalizeRawDate,
|
|
111
|
-
};
|
|
112
|
-
return DateInput;
|
|
113
|
-
}(react_1.default.Component));
|
|
59
|
+
return (react_1.default.createElement("input", __assign({}, input, { className: (0, classnames_1.default)("form-control ".concat(customClass || ""), {
|
|
60
|
+
"is-invalid": touched && error,
|
|
61
|
+
}), disabled: submitting, id: input.name, onBlur: handleBlur, onChange: handleChange, placeholder: placeholder || utility_1.words.DateFormat, ref: onRegisterRef, tabIndex: tabIndex, type: "text", value: valueToShow })));
|
|
62
|
+
};
|
|
114
63
|
exports.DateInput = DateInput;
|
|
115
64
|
//# sourceMappingURL=DateInput.js.map
|
package/Inputs/DateInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../src/Inputs/DateInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../src/Inputs/DateInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAkBA,gDAA0B;AAC1B,0DAAoC;AACpC,sCAA8D;AAC9D,oDAAoD;AAEpD,IACE,eAAe,GAAG,UAAC,GAAY;IAC7B,IACE,YAAY,GAAG,CAAC,EAChB,UAAU,GAAG,CACX,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC;QACzB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,YAAY,CAAC,CACzC,CAAC;IAEJ,IAAI,CAAC,U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
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type DateInputPropTypes = {
|
|
2
3
|
readonly customClass?: any;
|
|
3
4
|
readonly input: any;
|
|
4
|
-
readonly label?: string;
|
|
5
5
|
readonly meta: {
|
|
6
6
|
error?: string;
|
|
7
7
|
submitting: boolean;
|
|
8
8
|
touched: boolean;
|
|
9
9
|
};
|
|
10
|
-
readonly left?: string;
|
|
11
|
-
readonly right?: string;
|
|
12
10
|
readonly placeholder?: string;
|
|
13
11
|
readonly value?: string;
|
|
14
12
|
readonly tabIndex?: string;
|
|
@@ -18,22 +16,9 @@ declare type DateTemplatePropTypes = {
|
|
|
18
16
|
readonly onBlur?: () => void;
|
|
19
17
|
readonly onChange?: (event: any) => void;
|
|
20
18
|
readonly onRegisterRef?: (callback: (node: any) => void) => void;
|
|
19
|
+
right?: string;
|
|
20
|
+
left?: string;
|
|
21
|
+
label: string;
|
|
21
22
|
};
|
|
22
|
-
declare
|
|
23
|
-
value: string;
|
|
24
|
-
};
|
|
25
|
-
import React from "react";
|
|
26
|
-
export declare class DateTemplate extends React.Component<DateTemplatePropTypes, DateTemplateStateTypes> {
|
|
27
|
-
static defaultProps: {
|
|
28
|
-
formatValue: (raw: string) => string;
|
|
29
|
-
normalizeValue: (raw: string) => string;
|
|
30
|
-
};
|
|
31
|
-
state: DateTemplateStateTypes;
|
|
32
|
-
handleBlur: () => void;
|
|
33
|
-
handleKeyDown: (event: any) => void;
|
|
34
|
-
handleChange: ({ target: { value } }: any) => void;
|
|
35
|
-
UNSAFE_componentWillReceiveProps(nextProps: DateTemplatePropTypes): void;
|
|
36
|
-
constructor(props: DateTemplatePropTypes);
|
|
37
|
-
render(): JSX.Element;
|
|
38
|
-
}
|
|
23
|
+
export declare const DateTemplate: (props: DateInputPropTypes) => JSX.Element;
|
|
39
24
|
export {};
|
package/Inputs/DateTemplate.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable react/no-unsafe */
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
2
|
var __assign = (this && this.__assign) || function () {
|
|
19
3
|
__assign = Object.assign || function(t) {
|
|
20
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -34,88 +18,51 @@ exports.DateTemplate = void 0;
|
|
|
34
18
|
var react_1 = __importDefault(require("react"));
|
|
35
19
|
var classnames_1 = __importDefault(require("classnames"));
|
|
36
20
|
var utility_1 = require("../utility");
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
var validation_1 = require("../utility/validation");
|
|
22
|
+
var addZeroIfNeeded = function (raw) {
|
|
23
|
+
var nrOfElements = 3, canAddZero = ((typeof raw === "string") &&
|
|
24
|
+
(raw.split(".").length === nrOfElements));
|
|
25
|
+
if (!canAddZero) {
|
|
26
|
+
return raw;
|
|
27
|
+
}
|
|
28
|
+
var perform = function (value) { return (value.length === 1 ? "0".concat(value) : value); }, parts = raw.split("."), part1 = perform(parts[0]), part2 = perform(parts[1]), part3 = parts[2], newValue = [part1, part2, part3].join(".");
|
|
29
|
+
if ((0, validation_1.isValidDate)(newValue)) {
|
|
30
|
+
return newValue;
|
|
41
31
|
}
|
|
42
32
|
return raw;
|
|
33
|
+
}, normalizeRawDate = function (raw) {
|
|
34
|
+
if ((0, validation_1.isValidDate)(raw)) {
|
|
35
|
+
return (0, utility_1.normalizeDate)(raw);
|
|
36
|
+
}
|
|
37
|
+
return "";
|
|
43
38
|
}, formatRawDate = function (raw) {
|
|
44
|
-
/* eslint-disable no-magic-numbers */
|
|
45
39
|
if (typeof raw !== "undefined") {
|
|
46
40
|
return (0, utility_1.formatDate)(raw);
|
|
47
41
|
}
|
|
48
42
|
return "";
|
|
49
43
|
};
|
|
50
|
-
var DateTemplate =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
_this.handleBlur = function () {
|
|
63
|
-
var onBlur = _this.props.input.onBlur, _a = _this.props, input = _a.input, normalizeValue = _a.normalizeValue, currentValue = _this.state.value, normalizedValue = normalizeValue(currentValue), shouldRenderAgain = normalizedValue !== "" && currentValue !== normalizedValue;
|
|
64
|
-
input.onChange(normalizedValue);
|
|
65
|
-
/*
|
|
66
|
-
* Swallow the event to prevent Redux Form from
|
|
67
|
-
* extracting the form value
|
|
68
|
-
*/
|
|
69
|
-
onBlur();
|
|
70
|
-
if (shouldRenderAgain) {
|
|
71
|
-
_this.setState({
|
|
72
|
-
value: (0, utility_1.formatDate)(normalizedValue),
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
_this.handleChange = function (_a) {
|
|
77
|
-
var value = _a.target.value;
|
|
78
|
-
_this.props.input.onChange();
|
|
79
|
-
/*
|
|
80
|
-
* Update the internal state to trigger a re-render
|
|
81
|
-
* using the formatted value
|
|
82
|
-
*/
|
|
83
|
-
_this.setState({
|
|
84
|
-
value: value,
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
return _this;
|
|
88
|
-
}
|
|
89
|
-
DateTemplate.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
90
|
-
var newValue = nextProps.input.value, currentValue = this.state.value, shouldRenderAgain = (0, utility_1.isValidDate)(newValue) && currentValue !== newValue;
|
|
91
|
-
if (newValue === "") {
|
|
92
|
-
this.setState({
|
|
93
|
-
value: "",
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if (shouldRenderAgain) {
|
|
97
|
-
this.setState({
|
|
98
|
-
value: (0, utility_1.formatDate)(newValue),
|
|
99
|
-
});
|
|
44
|
+
var DateTemplate = function (props) {
|
|
45
|
+
var customClass = props.customClass, input = props.input, onRegisterRef = props.onRegisterRef, tabIndex = props.tabIndex, placeholder = props.placeholder, _a = props.meta, submitting = _a.submitting, touched = _a.touched, error = _a.error, right = props.right, left = props.left, label = props.label, _b = react_1.default.useState(input.value), value = _b[0], setValue = _b[1], valueToShow = formatRawDate(value), updateValue = function (targetValue) {
|
|
46
|
+
var normalizedValue = normalizeRawDate(addZeroIfNeeded(targetValue));
|
|
47
|
+
setValue(targetValue);
|
|
48
|
+
props.input.onChange(normalizedValue);
|
|
49
|
+
}, handleBlur = function (_a) {
|
|
50
|
+
var targetValue = _a.target.value;
|
|
51
|
+
var newValue = addZeroIfNeeded(targetValue), hasChanged = targetValue !== newValue;
|
|
52
|
+
if (hasChanged) {
|
|
53
|
+
updateValue(newValue);
|
|
100
54
|
}
|
|
55
|
+
}, handleChange = function (_a) {
|
|
56
|
+
var targetValue = _a.target.value;
|
|
57
|
+
updateValue(targetValue);
|
|
101
58
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
react_1.default.createElement("div", { className:
|
|
109
|
-
|
|
110
|
-
"is-invalid": touched && error,
|
|
111
|
-
}), disabled: submitting, id: input.name, onBlur: this.handleBlur, onChange: this.handleChange, onKeyDown: this.handleKeyDown, placeholder: placeholder || utility_1.words.DateFormat, ref: onRegisterRef, tabIndex: tabIndex, type: "text", value: formatValue(this.state.value) })),
|
|
112
|
-
react_1.default.createElement("div", { className: "invalid-feedback" }, touched && error && (react_1.default.createElement("span", null, error))))));
|
|
113
|
-
};
|
|
114
|
-
DateTemplate.defaultProps = {
|
|
115
|
-
formatValue: formatRawDate,
|
|
116
|
-
normalizeValue: normalizeRawDate,
|
|
117
|
-
};
|
|
118
|
-
return DateTemplate;
|
|
119
|
-
}(react_1.default.Component));
|
|
59
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)("form-group row", { "is-invalid": touched && error }) },
|
|
60
|
+
react_1.default.createElement("label", { className: "".concat(left ? left : "col-md-4 text-md-right", " form-control-label"), htmlFor: input.name }, label),
|
|
61
|
+
react_1.default.createElement("div", { className: right ? right : "col-md-8" },
|
|
62
|
+
react_1.default.createElement("input", __assign({}, input, { "aria-label": label, className: (0, classnames_1.default)("form-control ".concat(customClass || ""), {
|
|
63
|
+
"is-invalid": touched && error,
|
|
64
|
+
}), disabled: submitting, id: input.name, onBlur: handleBlur, onChange: handleChange, placeholder: placeholder || utility_1.words.DateFormat, ref: onRegisterRef, tabIndex: tabIndex, type: "text", value: valueToShow })),
|
|
65
|
+
react_1.default.createElement("div", { className: "invalid-feedback" }, touched && error && (react_1.default.createElement("span", null, error))))));
|
|
66
|
+
};
|
|
120
67
|
exports.DateTemplate = DateTemplate;
|
|
121
68
|
//# sourceMappingURL=DateTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTemplate.js","sourceRoot":"","sources":["../../src/Inputs/DateTemplate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateTemplate.js","sourceRoot":"","sources":["../../src/Inputs/DateTemplate.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAqBA,gDAA0B;AAC1B,0DAAoC;AACpC,sCAA8D;AAC9D,oDAAoD;AAEpD,IACE,eAAe,GAAG,UAAC,GAAY;IAC7B,IACE,YAAY,GAAG,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K,CACA;QACR,uCAAK,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU;YACxC,oDACM,KAAK,kBACG,KAAK,EACjB,SAAS,EAAE,IAAA,oBAAU,EAAC,uBAAgB,WAAW,IAAI,EAAE,CAAE,EAAE;oBACzD,YAAY,EAAE,OAAO,IAAI,KAAK;iBAC/B,CAAC,EACF,QAAQ,EAAE,UAAU,EACpB,EAAE,EAAE,KAAK,CAAC,IAAI,EACd,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,WAAW,IAAI,eAAK,CAAC,UAAU,EAC5C,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,WAAW,IAClB;YACF,uCACE,SAAS,EAAC,kBAAkB,IAC3B,OAAO,IAAI,KAAK,IAAI,CACnB,4CACG,KAAK,CACD,CACR,CACG,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AArEW,QAAA,YAAY,gBAqEvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
declare type TypeInputPropTypes = {
|
|
3
3
|
readonly change: (event: any) => void;
|
|
4
4
|
readonly value: any;
|
|
@@ -10,19 +10,5 @@ declare type TypeInputPropTypes = {
|
|
|
10
10
|
readonly name?: string;
|
|
11
11
|
readonly placeholder?: string;
|
|
12
12
|
};
|
|
13
|
-
declare
|
|
14
|
-
value: string;
|
|
15
|
-
isWaiting: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare class DelayInputChange extends React.Component<TypeInputPropTypes, TypeInputStateTypes> {
|
|
18
|
-
state: TypeInputStateTypes;
|
|
19
|
-
timeout: any;
|
|
20
|
-
delayChange: (event: any) => void;
|
|
21
|
-
handleKeyPressed: (event: any) => void;
|
|
22
|
-
stopWaiting: (value: string) => void;
|
|
23
|
-
UNSAFE_componentWillReceiveProps(nextProps: TypeInputPropTypes): void;
|
|
24
|
-
constructor(props: TypeInputPropTypes);
|
|
25
|
-
shouldComponentUpdate(nextProps: TypeInputPropTypes, nextState: TypeInputStateTypes): boolean;
|
|
26
|
-
render(): JSX.Element;
|
|
27
|
-
}
|
|
13
|
+
export declare const DelayInputChange: (props: TypeInputPropTypes) => JSX.Element;
|
|
28
14
|
export {};
|
|
@@ -1,101 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.DelayInputChange = void 0;
|
|
23
|
-
var react_1 =
|
|
24
|
-
var delay = 700;
|
|
23
|
+
var react_1 = __importStar(require("react"));
|
|
25
24
|
var Messages_1 = require("../Messages");
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
var delay = 700;
|
|
26
|
+
var DelayInputChange = function (props) {
|
|
27
|
+
var _a = (0, react_1.useState)(0), timeoutValue = _a[0], setTimeoutValue = _a[1], _b = (0, react_1.useState)(false), isWaiting = _b[0], setIsWaiting = _b[1], _c = (0, react_1.useState)(props.value), value = _c[0], setValue = _c[1], stopWaiting = function (newValue) {
|
|
28
|
+
clearTimeout(timeoutValue);
|
|
29
|
+
setIsWaiting(false);
|
|
30
|
+
setValue(newValue);
|
|
31
|
+
props.change({
|
|
32
|
+
target: {
|
|
33
|
+
value: newValue,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}, handleKeyPressed = function (event) {
|
|
37
|
+
if (event.key === "Enter") {
|
|
38
|
+
stopWaiting(value);
|
|
39
|
+
}
|
|
40
|
+
}, delayChange = function (_a) {
|
|
41
|
+
var newValue = _a.target.value;
|
|
42
|
+
clearTimeout(timeoutValue);
|
|
43
|
+
if (value === "") {
|
|
44
|
+
stopWaiting(newValue);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setIsWaiting(true);
|
|
48
|
+
setValue(newValue);
|
|
49
|
+
var newTimeout = setTimeout(function () {
|
|
50
|
+
setIsWaiting(false);
|
|
51
|
+
props.change({
|
|
47
52
|
target: {
|
|
48
|
-
value:
|
|
53
|
+
value: newValue,
|
|
49
54
|
},
|
|
50
55
|
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
_this.delayChange = function (_a) {
|
|
54
|
-
var value = _a.target.value;
|
|
55
|
-
clearTimeout(_this.timeout);
|
|
56
|
-
if (value === "") {
|
|
57
|
-
_this.stopWaiting(value);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
var that_1 = _this;
|
|
61
|
-
that_1.setState({
|
|
62
|
-
isWaiting: true,
|
|
63
|
-
value: value,
|
|
64
|
-
}, function () {
|
|
65
|
-
that_1.timeout = setTimeout(function () {
|
|
66
|
-
that_1.setState({
|
|
67
|
-
isWaiting: false,
|
|
68
|
-
});
|
|
69
|
-
that_1.props.change({
|
|
70
|
-
target: {
|
|
71
|
-
value: value,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}, _this.props.delay || delay);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
return _this;
|
|
79
|
-
}
|
|
80
|
-
DelayInputChange.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
81
|
-
if (this.props.value !== nextProps.value) {
|
|
82
|
-
this.setState({
|
|
83
|
-
value: nextProps.value,
|
|
84
|
-
});
|
|
56
|
+
}, props.delay || delay);
|
|
57
|
+
setTimeoutValue(newTimeout);
|
|
85
58
|
}
|
|
86
59
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
DelayInputChange.prototype.render = function () {
|
|
93
|
-
var _a = this.state, value = _a.value, isWaiting = _a.isWaiting;
|
|
94
|
-
return (react_1.default.createElement("div", { className: "delay-input" },
|
|
95
|
-
react_1.default.createElement("input", { autoComplete: this.props.autoComplete, className: this.props.className, id: this.props.id, name: this.props.name, onChange: this.delayChange, onKeyPress: this.handleKeyPressed, placeholder: this.props.placeholder, tabIndex: this.props.tabIndex, value: value }),
|
|
96
|
-
isWaiting ? react_1.default.createElement(Messages_1.LoadingMessage, { className: "loading-spinner d-inline-block", sm: true }) : null));
|
|
97
|
-
};
|
|
98
|
-
return DelayInputChange;
|
|
99
|
-
}(react_1.default.Component));
|
|
60
|
+
return (react_1.default.createElement("div", { className: "delay-input" },
|
|
61
|
+
react_1.default.createElement("input", { autoComplete: props.autoComplete, className: props.className, id: props.id, name: props.name, onChange: delayChange, onKeyPress: handleKeyPressed, placeholder: props.placeholder, tabIndex: props.tabIndex, value: value }),
|
|
62
|
+
isWaiting ? react_1.default.createElement(Messages_1.LoadingMessage, { className: "loading-spinner d-inline-block", sm: true }) : null));
|
|
63
|
+
};
|
|
100
64
|
exports.DelayInputChange = DelayInputChange;
|
|
101
65
|
//# sourceMappingURL=DelayInputChange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DelayInputChange.js","sourceRoot":"","sources":["../../src/Inputs/DelayInputChange.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DelayInputChange.js","sourceRoot":"","sources":["../../src/Inputs/DelayInputChange.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AAcxC,wCAA6C;AAE7C,IAAM,KAAK,GAAG,GAAG,CAAC;AAEX,IACL,gBAAgB,GAAG,UAAC,KAA0B;IAE1C,IAAA,KAAkC,IAAA,gBAAQ,EAAC,CAAQ,CAAC,EAAnD,YAAY,QAAA,EAAE,eAAe,QAAA,EAC9B,KAA4B,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAA,EACxB,KAAoB,IAAA,gBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,EAAxC,KAAK,QAAA,EAAE,QAAQ,QAAA,EAEhB,WAAW,GAAG,UAAC,QAAgB;QAC7B,YAAY,CAAC,YAAY,CAAC,CAAC;QAE3B,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEnB,KAAK,CAAC,MAAM,CAAC;YACX,MAAM,EAAE;gBACN,KAAK,E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QAAA,gBAAgB,oBA6Dd"}
|
package/Inputs/NumericInput.d.ts
CHANGED
|
@@ -1,39 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare type NumericPropTypes = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
currency?: boolean;
|
|
4
|
+
optional?: boolean;
|
|
5
|
+
size?: number;
|
|
6
|
+
customClass?: any;
|
|
7
|
+
input: any;
|
|
8
|
+
label?: string;
|
|
9
|
+
meta: {
|
|
9
10
|
error?: string;
|
|
10
11
|
submitting: boolean;
|
|
11
12
|
touched: boolean;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
tabIndex?: number;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
value?: string;
|
|
17
|
+
formatValue: (raw: any, optional?: boolean) => string;
|
|
18
|
+
normalizeValue: (raw: any) => any;
|
|
19
|
+
onBlur?: () => void;
|
|
20
|
+
onChange?: (event: any) => void;
|
|
21
|
+
onRegisterRef?: any;
|
|
21
22
|
};
|
|
22
|
-
declare
|
|
23
|
-
value: any;
|
|
24
|
-
};
|
|
25
|
-
import React from "react";
|
|
26
|
-
export declare class NumericInput extends React.Component<NumericPropTypes, NumericStateTypes> {
|
|
27
|
-
static defaultProps: {
|
|
28
|
-
formatValue: (word: any, optional?: boolean | undefined) => string;
|
|
29
|
-
normalizeValue: (raw: string) => number;
|
|
30
|
-
};
|
|
31
|
-
state: NumericStateTypes;
|
|
32
|
-
handleBlur: () => any;
|
|
33
|
-
handleKeyDown: (event: any) => void;
|
|
34
|
-
handleChange: ({ target: { value } }: any) => void;
|
|
35
|
-
UNSAFE_componentWillReceiveProps(nextProps: NumericPropTypes): void;
|
|
36
|
-
constructor(props: NumericPropTypes);
|
|
37
|
-
render(): JSX.Element;
|
|
38
|
-
}
|
|
23
|
+
export declare const NumericInput: (props: NumericPropTypes) => JSX.Element;
|
|
39
24
|
export {};
|
package/Inputs/NumericInput.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable react/no-unsafe */
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
@@ -23,54 +7,29 @@ exports.NumericInput = void 0;
|
|
|
23
7
|
var react_1 = __importDefault(require("react"));
|
|
24
8
|
var classnames_1 = __importDefault(require("classnames"));
|
|
25
9
|
var utility_1 = require("../utility");
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_this.handleBlur();
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
_this.handleBlur = function () {
|
|
39
|
-
(0, utility_1.handleBlur)(_this);
|
|
40
|
-
};
|
|
41
|
-
_this.handleChange = function (_a) {
|
|
42
|
-
var value = _a.target.value;
|
|
43
|
-
_this.props.input.onChange();
|
|
44
|
-
/*
|
|
45
|
-
* Update the internal state to trigger a re-render
|
|
46
|
-
* using the formatted value
|
|
47
|
-
*/
|
|
48
|
-
_this.setState({
|
|
49
|
-
value: value,
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
return _this;
|
|
53
|
-
}
|
|
54
|
-
NumericInput.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
55
|
-
(0, utility_1.cwrp)(this, nextProps);
|
|
56
|
-
};
|
|
57
|
-
NumericInput.prototype.render = function () {
|
|
58
|
-
var _a = this.props, customClass = _a.customClass, input = _a.input, label = _a.label, currency = _a.currency, tabIndex = _a.tabIndex, onRegisterRef = _a.onRegisterRef, _b = _a.meta, submitting = _b.submitting, touched = _b.touched, error = _b.error, formatValue = _a.formatValue, size = _a.size, placeholder = _a.placeholder, inputComponent = (react_1.default.createElement("input", { "aria-label": label, className: (0, classnames_1.default)("form-control ".concat(customClass || ""), {
|
|
59
|
-
"is-invalid": touched && error,
|
|
60
|
-
}), disabled: submitting, id: input.name, maxLength: size, onBlur: this.handleBlur, onChange: this.handleChange, onFocus: input.onFocus, onKeyDown: this.handleKeyDown, placeholder: placeholder || label, ref: onRegisterRef, tabIndex: tabIndex, type: "text", value: formatValue(this.state.value, this.props.optional) }));
|
|
61
|
-
if (typeof currency === "undefined" || currency === false) {
|
|
62
|
-
return (react_1.default.createElement("div", { className: "form-group-inline" }, inputComponent));
|
|
10
|
+
var common_1 = require("./common");
|
|
11
|
+
var NumericInput = function (props) {
|
|
12
|
+
var customClass = props.customClass, input = props.input, label = props.label, currency = props.currency, tabIndex = props.tabIndex, onRegisterRef = props.onRegisterRef, _a = props.formatValue, formatValue = _a === void 0 ? utility_1.formatZeroValue : _a, size = props.size, placeholder = props.placeholder, _b = props.meta, submitting = _b.submitting, touched = _b.touched, error = _b.error, _c = react_1.default.useState(props.input.value), value = _c[0], setValue = _c[1], noCurrency = (typeof currency === "undefined" || currency === false), valueToShow = formatValue(value, props.optional), updateValue = function (targetValue) {
|
|
13
|
+
setValue(targetValue);
|
|
14
|
+
props.input.onChange((0, common_1.getFloatValueToStore)(targetValue));
|
|
15
|
+
}, handleBlur = function () {
|
|
16
|
+
var newValue = (0, common_1.clearFloatOnBlur)(value), hasChanged = value !== newValue;
|
|
17
|
+
if (hasChanged) {
|
|
18
|
+
updateValue(newValue);
|
|
63
19
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
return
|
|
74
|
-
|
|
20
|
+
}, handleChange = function (_a) {
|
|
21
|
+
var targetValue = _a.target.value;
|
|
22
|
+
updateValue(targetValue);
|
|
23
|
+
}, inputComponent = (react_1.default.createElement("input", { "aria-label": label, className: (0, classnames_1.default)("form-control ".concat(customClass || ""), {
|
|
24
|
+
"is-invalid": touched && error,
|
|
25
|
+
}), disabled: submitting, id: input.name, maxLength: size, onBlur: handleBlur, onChange: handleChange, placeholder: placeholder || label, ref: onRegisterRef, tabIndex: tabIndex, type: "text", value: valueToShow }));
|
|
26
|
+
if (noCurrency) {
|
|
27
|
+
return (react_1.default.createElement("div", { className: "form-group-inline" }, inputComponent));
|
|
28
|
+
}
|
|
29
|
+
return (react_1.default.createElement("div", { className: "input-group" },
|
|
30
|
+
inputComponent,
|
|
31
|
+
react_1.default.createElement("div", { className: "input-group-append" },
|
|
32
|
+
react_1.default.createElement("span", { className: "input-group-text" }, currency))));
|
|
33
|
+
};
|
|
75
34
|
exports.NumericInput = NumericInput;
|
|
76
35
|
//# sourceMappingURL=NumericInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericInput.js","sourceRoot":"","sources":["../../src/Inputs/NumericInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NumericInput.js","sourceRoot":"","sources":["../../src/Inputs/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C,CAAC;IAC3B,CAAC,EAED,cAAc,GAAG,CACf,uDACc,KAAK,EACjB,SAAS,EAAE,IAAA,oBAAU,EAAC,uBAAgB,WAAW,IAAI,EAAE,CAAE,EAAE;YACzD,YAAY,EAAE,OAAO,IAAI,KAAK;SAC/B,CAAC,EACF,QAAQ,EAAE,UAAU,EACpB,EAAE,EAAE,KAAK,CAAC,IAAI,EACd,SAAS,EAAE,IAAI,EACf,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,WAAW,IAAI,KAAK,EACjC,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,WAAW,GAClB,CACH,CAAC;IAEJ,IAAI,UAAU,EAAE;QACd,OAAO,CACL,uCAAK,SAAS,EAAC,mBAAmB,IAC/B,cAAc,CACX,CACP,CAAC;KACH;IAED,OAAO,CACL,uCAAK,SAAS,EAAC,aAAa;QACzB,cAAc;QACf,uCAAK,SAAS,EAAC,oBAAoB;YACjC,wCAAM,SAAS,EAAC,kBAAkB,IAC/B,QAAQ,CACJ,CACH,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AApEF,QAAA,YAAY,gBAoEV"}
|
|
@@ -1,44 +1,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare type NumericPropTypes = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
optional?: boolean;
|
|
4
|
+
size?: number;
|
|
5
|
+
customClass?: any;
|
|
6
|
+
divClass?: any;
|
|
7
|
+
input: any;
|
|
8
|
+
label?: string;
|
|
9
|
+
meta: {
|
|
9
10
|
error?: string;
|
|
10
11
|
submitting: boolean;
|
|
11
12
|
touched: boolean;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
autoFocus?: boolean;
|
|
17
|
+
type: string;
|
|
18
|
+
inputClass?: string;
|
|
19
|
+
left?: string;
|
|
20
|
+
tabIndex?: number;
|
|
21
|
+
right?: string;
|
|
22
|
+
formatValue: (raw: any, optional?: boolean) => string;
|
|
23
|
+
normalizeValue: (raw: string | null) => any;
|
|
24
|
+
onBlur?: () => void;
|
|
25
|
+
onChange?: (event: any) => void;
|
|
26
|
+
onRegisterRef?: any;
|
|
26
27
|
};
|
|
27
|
-
declare
|
|
28
|
-
value: any;
|
|
29
|
-
};
|
|
30
|
-
import React from "react";
|
|
31
|
-
export declare class NumericTemplate extends React.Component<NumericPropTypes, NumericStateTypes> {
|
|
32
|
-
static defaultProps: {
|
|
33
|
-
formatValue: (word: any, optional?: boolean | undefined) => string;
|
|
34
|
-
normalizeValue: (raw: string) => number;
|
|
35
|
-
};
|
|
36
|
-
state: NumericStateTypes;
|
|
37
|
-
handleBlur: () => void;
|
|
38
|
-
handleKeyDown: (event: any) => void;
|
|
39
|
-
handleChange: ({ target: { value } }: any) => void;
|
|
40
|
-
UNSAFE_componentWillReceiveProps(nextProps: NumericPropTypes): void;
|
|
41
|
-
constructor(props: NumericPropTypes);
|
|
42
|
-
render(): JSX.Element;
|
|
43
|
-
}
|
|
28
|
+
export declare const NumericTemplate: (props: NumericPropTypes) => JSX.Element;
|
|
44
29
|
export {};
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable react/no-unsafe */
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
@@ -22,53 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
6
|
exports.NumericTemplate = void 0;
|
|
23
7
|
var react_1 = __importDefault(require("react"));
|
|
24
8
|
var classnames_1 = __importDefault(require("classnames"));
|
|
25
|
-
var
|
|
26
|
-
var NumericTemplate =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*/
|
|
48
|
-
_this.setState({
|
|
49
|
-
value: value,
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
return _this;
|
|
53
|
-
}
|
|
54
|
-
NumericTemplate.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
55
|
-
(0, utility_1.cwrp)(this, nextProps);
|
|
56
|
-
};
|
|
57
|
-
NumericTemplate.prototype.render = function () {
|
|
58
|
-
var _a = this.props, input = _a.input, label = _a.label, onRegisterRef = _a.onRegisterRef, _b = _a.meta, submitting = _b.submitting, touched = _b.touched, error = _b.error, formatValue = _a.formatValue, type = _a.type, autoFocus = _a.autoFocus, inputClass = _a.inputClass, placeholder = _a.placeholder, left = _a.left, size = _a.size, right = _a.right, tabIndex = _a.tabIndex, divClass = _a.divClass, warningClass = "".concat(touched && error ? " is-invalid" : ""), customClass = "".concat(inputClass ? " ".concat(inputClass) : ""), classForInput = "form-control ".concat(warningClass).concat(customClass), classForDiv = "form-group row ".concat(divClass ? divClass : "");
|
|
59
|
-
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(classForDiv, {
|
|
60
|
-
"is-invalid": touched && error,
|
|
61
|
-
}) },
|
|
62
|
-
react_1.default.createElement("label", { className: "".concat(left ? left : "col-md-4 text-md-right", " form-control-label"), htmlFor: input.name }, label),
|
|
63
|
-
react_1.default.createElement("div", { className: right ? right : "col-md-8" },
|
|
64
|
-
react_1.default.createElement("input", { "aria-label": label, autoFocus: autoFocus, className: classForInput, disabled: submitting, id: input.name, maxLength: size, onBlur: this.handleBlur, onChange: this.handleChange, onFocus: input.onFocus, onKeyDown: this.handleKeyDown, placeholder: placeholder, ref: onRegisterRef, tabIndex: tabIndex, type: type, value: formatValue(this.state.value, this.props.optional) }),
|
|
65
|
-
react_1.default.createElement("div", { className: "invalid-feedback" }, touched && error && (react_1.default.createElement("span", null, error))))));
|
|
66
|
-
};
|
|
67
|
-
NumericTemplate.defaultProps = {
|
|
68
|
-
formatValue: utility_1.formatZeroValue,
|
|
69
|
-
normalizeValue: utility_1.normalizeFloat,
|
|
70
|
-
};
|
|
71
|
-
return NumericTemplate;
|
|
72
|
-
}(react_1.default.Component));
|
|
9
|
+
var common_1 = require("./common");
|
|
10
|
+
var NumericTemplate = function (props) {
|
|
11
|
+
var input = props.input, right = props.right, tabIndex = props.tabIndex, divClass = props.divClass, label = props.label, onRegisterRef = props.onRegisterRef, _a = props.meta, submitting = _a.submitting, touched = _a.touched, error = _a.error, formatValue = props.formatValue, type = props.type, autoFocus = props.autoFocus, inputClass = props.inputClass, placeholder = props.placeholder, left = props.left, size = props.size, _b = react_1.default.useState(props.input.value), value = _b[0], setValue = _b[1], valueToShow = formatValue(value, props.optional), updateValue = function (targetValue) {
|
|
12
|
+
setValue(targetValue);
|
|
13
|
+
props.input.onChange((0, common_1.getFloatValueToStore)(targetValue));
|
|
14
|
+
}, handleBlur = function () {
|
|
15
|
+
var newValue = (0, common_1.clearFloatOnBlur)(value), hasChanged = value !== newValue;
|
|
16
|
+
if (hasChanged) {
|
|
17
|
+
updateValue(newValue);
|
|
18
|
+
}
|
|
19
|
+
}, handleChange = function (_a) {
|
|
20
|
+
var targetValue = _a.target.value;
|
|
21
|
+
updateValue(targetValue);
|
|
22
|
+
}, warningClass = "".concat(touched && error ? " is-invalid" : ""), customClass = "".concat(inputClass ? " ".concat(inputClass) : ""), classForInput = "form-control ".concat(warningClass).concat(customClass), classForDiv = "form-group row ".concat(divClass ? divClass : "");
|
|
23
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(classForDiv, {
|
|
24
|
+
"is-invalid": touched && error,
|
|
25
|
+
}) },
|
|
26
|
+
react_1.default.createElement("label", { className: "".concat(left ? left : "col-md-4 text-md-right", " form-control-label"), htmlFor: input.name }, label),
|
|
27
|
+
react_1.default.createElement("div", { className: right ? right : "col-md-8" },
|
|
28
|
+
react_1.default.createElement("input", { "aria-label": label, autoFocus: autoFocus, className: classForInput, disabled: submitting, id: input.name, maxLength: size, onBlur: handleBlur, onChange: handleChange, placeholder: placeholder, ref: onRegisterRef, tabIndex: tabIndex, type: type, value: formatValue(valueToShow, props.optional) }),
|
|
29
|
+
react_1.default.createElement("div", { className: "invalid-feedback" }, touched && error && (react_1.default.createElement("span", null, error))))));
|
|
30
|
+
};
|
|
73
31
|
exports.NumericTemplate = NumericTemplate;
|
|
74
32
|
//# sourceMappingURL=NumericTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericTemplate.js","sourceRoot":"","sources":["../../src/Inputs/NumericTemplate.tsx"],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ACD,CACR,CACG,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAvEF,QAAA,eAAe,mBAuEb"}
|
package/Inputs/common.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable require-unicode-regexp */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearFloatOnBlur = exports.getFloatValueToStore = void 0;
|
|
5
|
+
var isFloat = function (raw) {
|
|
6
|
+
var floatRegex = /^-?\d+(?:[.]\d*?)?$/;
|
|
7
|
+
return floatRegex.test(raw);
|
|
8
|
+
}, floatToEnglishComma = function (raw) { return String(raw).replace(",", "."); }, floatToLocalComma = function (raw) { return String(raw).replace(".", ","); };
|
|
9
|
+
var getFloatValueToStore = function (raw) {
|
|
10
|
+
var parsedFloat = floatToEnglishComma(raw), parsedValue = parseFloat(parsedFloat), canGetNumericValue = isFloat(parsedFloat) && !isNaN(parsedValue);
|
|
11
|
+
if (canGetNumericValue) {
|
|
12
|
+
return parsedValue;
|
|
13
|
+
}
|
|
14
|
+
return 0;
|
|
15
|
+
}, clearFloatOnBlur = function (value) {
|
|
16
|
+
var parts = floatToLocalComma(value).split(","), shouldRemoveComma = parts.length === 2 && (parts[1] === "" || Number(parts[1]) === 0), shouldCutTo2Decimals = parts.length === 2 && parts[1].length > 2;
|
|
17
|
+
if (shouldRemoveComma) {
|
|
18
|
+
return parts[0];
|
|
19
|
+
}
|
|
20
|
+
if (shouldCutTo2Decimals) {
|
|
21
|
+
var beforeDot = parts[0], afterDot = parts[1].substring(0, 2);
|
|
22
|
+
return "".concat(beforeDot, ",").concat(afterDot);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
exports.getFloatValueToStore = getFloatValueToStore, exports.clearFloatOnBlur = clearFloatOnBlur;
|
|
27
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js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