x25 5.1.11 → 5.1.12
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/NumericInput.js +84 -119
- package/Inputs/NumericTemplate.js +90 -126
- package/Inputs/common.js +52 -0
- package/package.json +1 -1
package/Inputs/NumericInput.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.NumericInput = undefined;
|
|
7
6
|
|
|
8
|
-
var
|
|
7
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /* eslint-disable require-unicode-regexp */
|
|
8
|
+
/* eslint-disable no-magic-numbers */
|
|
9
|
+
/* eslint-disable react/no-unsafe */
|
|
9
10
|
|
|
10
11
|
var _react = require("react");
|
|
11
12
|
|
|
@@ -15,125 +16,89 @@ var _classnames = require("classnames");
|
|
|
15
16
|
|
|
16
17
|
var _classnames2 = _interopRequireDefault(_classnames);
|
|
17
18
|
|
|
18
|
-
var _utility = require("
|
|
19
|
+
var _utility = require("x25/utility");
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
25
|
-
|
|
26
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var NumericInput = exports.NumericInput = function (_React$Component) {
|
|
30
|
-
_inherits(NumericInput, _React$Component);
|
|
31
|
-
|
|
32
|
-
function NumericInput(props) {
|
|
33
|
-
_classCallCheck(this, NumericInput);
|
|
34
|
-
|
|
35
|
-
var _this = _possibleConstructorReturn(this, (NumericInput.__proto__ || Object.getPrototypeOf(NumericInput)).call(this));
|
|
36
|
-
|
|
37
|
-
_this.state = {
|
|
38
|
-
value: props.input.value
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
_this.handleKeyDown = function (event) {
|
|
42
|
-
if (event.key === "Enter") {
|
|
43
|
-
_this.handleBlur();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
_this.handleBlur = function () {
|
|
48
|
-
(0, _utility.handleBlur)(_this);
|
|
49
|
-
};
|
|
21
|
+
var _common = require("./common");
|
|
50
22
|
|
|
51
|
-
|
|
52
|
-
var value = _ref.target.value;
|
|
53
|
-
|
|
54
|
-
_this.props.input.onChange();
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
* Update the internal state to trigger a re-render
|
|
58
|
-
* using the formatted value
|
|
59
|
-
*/
|
|
60
|
-
_this.setState({ value: value });
|
|
61
|
-
};
|
|
62
|
-
return _this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_createClass(NumericInput, [{
|
|
66
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
67
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
68
|
-
(0, _utility.cwrp)(this, nextProps);
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "render",
|
|
72
|
-
value: function render() {
|
|
73
|
-
var _props = this.props,
|
|
74
|
-
customClass = _props.customClass,
|
|
75
|
-
input = _props.input,
|
|
76
|
-
label = _props.label,
|
|
77
|
-
currency = _props.currency,
|
|
78
|
-
tabIndex = _props.tabIndex,
|
|
79
|
-
onRegisterRef = _props.onRegisterRef,
|
|
80
|
-
_props$meta = _props.meta,
|
|
81
|
-
submitting = _props$meta.submitting,
|
|
82
|
-
touched = _props$meta.touched,
|
|
83
|
-
error = _props$meta.error,
|
|
84
|
-
formatValue = _props.formatValue,
|
|
85
|
-
size = _props.size,
|
|
86
|
-
placeholder = _props.placeholder;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var inputComponent = _react2.default.createElement("input", {
|
|
90
|
-
"aria-label": label,
|
|
91
|
-
className: (0, _classnames2.default)("form-control " + (customClass || ""), {
|
|
92
|
-
"is-invalid": touched && error
|
|
93
|
-
}),
|
|
94
|
-
disabled: submitting,
|
|
95
|
-
id: input.name,
|
|
96
|
-
maxLength: size,
|
|
97
|
-
onBlur: this.handleBlur,
|
|
98
|
-
onChange: this.handleChange,
|
|
99
|
-
onFocus: input.onFocus,
|
|
100
|
-
onKeyDown: this.handleKeyDown,
|
|
101
|
-
placeholder: placeholder || label,
|
|
102
|
-
ref: onRegisterRef,
|
|
103
|
-
tabIndex: tabIndex,
|
|
104
|
-
type: "text",
|
|
105
|
-
value: formatValue(this.state.value, this.props.optional)
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
if (typeof currency === "undefined" || currency === false) {
|
|
109
|
-
return _react2.default.createElement(
|
|
110
|
-
"div",
|
|
111
|
-
{ className: "form-group-inline" },
|
|
112
|
-
inputComponent
|
|
113
|
-
);
|
|
114
|
-
}
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
115
24
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
25
|
+
var NumericInput = function NumericInput(props) {
|
|
26
|
+
var customClass = props.customClass,
|
|
27
|
+
input = props.input,
|
|
28
|
+
label = props.label,
|
|
29
|
+
currency = props.currency,
|
|
30
|
+
tabIndex = props.tabIndex,
|
|
31
|
+
onRegisterRef = props.onRegisterRef,
|
|
32
|
+
_props$formatValue = props.formatValue,
|
|
33
|
+
formatValue = _props$formatValue === undefined ? _utility.formatZeroValue : _props$formatValue,
|
|
34
|
+
size = props.size,
|
|
35
|
+
placeholder = props.placeholder,
|
|
36
|
+
_props$meta = props.meta,
|
|
37
|
+
submitting = _props$meta.submitting,
|
|
38
|
+
touched = _props$meta.touched,
|
|
39
|
+
error = _props$meta.error,
|
|
40
|
+
_React$useState = _react2.default.useState(props.input.value),
|
|
41
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
42
|
+
value = _React$useState2[0],
|
|
43
|
+
setValue = _React$useState2[1],
|
|
44
|
+
noCurrency = typeof currency === "undefined" || currency === false,
|
|
45
|
+
valueToShow = formatValue(value, props.optional),
|
|
46
|
+
updateValue = function updateValue(targetValue) {
|
|
47
|
+
setValue(targetValue);
|
|
48
|
+
props.input.onChange((0, _common.getFloatValueToStore)(targetValue));
|
|
49
|
+
},
|
|
50
|
+
handleBlur = function handleBlur() {
|
|
51
|
+
var newValue = (0, _common.clearFloatOnBlur)(value),
|
|
52
|
+
hasChanged = value !== newValue;
|
|
53
|
+
|
|
54
|
+
if (hasChanged) {
|
|
55
|
+
updateValue(newValue);
|
|
130
56
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
57
|
+
},
|
|
58
|
+
handleChange = function handleChange(_ref) {
|
|
59
|
+
var targetValue = _ref.target.value;
|
|
60
|
+
|
|
61
|
+
updateValue(targetValue);
|
|
62
|
+
},
|
|
63
|
+
inputComponent = _react2.default.createElement("input", {
|
|
64
|
+
"aria-label": label,
|
|
65
|
+
className: (0, _classnames2.default)("form-control " + (customClass || ""), {
|
|
66
|
+
"is-invalid": touched && error
|
|
67
|
+
}),
|
|
68
|
+
disabled: submitting,
|
|
69
|
+
id: input.name,
|
|
70
|
+
maxLength: size,
|
|
71
|
+
onBlur: handleBlur,
|
|
72
|
+
onChange: handleChange,
|
|
73
|
+
placeholder: placeholder || label,
|
|
74
|
+
ref: onRegisterRef,
|
|
75
|
+
tabIndex: tabIndex,
|
|
76
|
+
type: "text",
|
|
77
|
+
value: valueToShow
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (noCurrency) {
|
|
81
|
+
return _react2.default.createElement(
|
|
82
|
+
"div",
|
|
83
|
+
{ className: "form-group-inline" },
|
|
84
|
+
inputComponent
|
|
85
|
+
);
|
|
86
|
+
}
|
|
135
87
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
88
|
+
return _react2.default.createElement(
|
|
89
|
+
"div",
|
|
90
|
+
{ className: "input-group" },
|
|
91
|
+
inputComponent,
|
|
92
|
+
_react2.default.createElement(
|
|
93
|
+
"div",
|
|
94
|
+
{ className: "input-group-append" },
|
|
95
|
+
_react2.default.createElement(
|
|
96
|
+
"span",
|
|
97
|
+
{ className: "input-group-text" },
|
|
98
|
+
currency
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
exports.default = NumericInput;
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.NumericTemplate = undefined;
|
|
7
6
|
|
|
8
|
-
var
|
|
7
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
8
|
+
/* eslint-disable require-unicode-regexp */
|
|
9
|
+
/* eslint-disable no-magic-numbers */
|
|
10
|
+
/* eslint-disable react/no-unsafe */
|
|
9
11
|
|
|
10
12
|
var _react = require("react");
|
|
11
13
|
|
|
@@ -15,134 +17,96 @@ var _classnames = require("classnames");
|
|
|
15
17
|
|
|
16
18
|
var _classnames2 = _interopRequireDefault(_classnames);
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _common = require("./common");
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
* Update the internal state to trigger a re-render
|
|
58
|
-
* using the formatted value
|
|
59
|
-
*/
|
|
60
|
-
_this.setState({ value: value });
|
|
61
|
-
};
|
|
62
|
-
return _this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_createClass(NumericTemplate, [{
|
|
66
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
67
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
68
|
-
(0, _utility.cwrp)(this, nextProps);
|
|
24
|
+
var NumericTemplate = function NumericTemplate(props) {
|
|
25
|
+
var input = props.input,
|
|
26
|
+
right = props.right,
|
|
27
|
+
tabIndex = props.tabIndex,
|
|
28
|
+
divClass = props.divClass,
|
|
29
|
+
label = props.label,
|
|
30
|
+
onRegisterRef = props.onRegisterRef,
|
|
31
|
+
_props$meta = props.meta,
|
|
32
|
+
submitting = _props$meta.submitting,
|
|
33
|
+
touched = _props$meta.touched,
|
|
34
|
+
error = _props$meta.error,
|
|
35
|
+
formatValue = props.formatValue,
|
|
36
|
+
type = props.type,
|
|
37
|
+
autoFocus = props.autoFocus,
|
|
38
|
+
inputClass = props.inputClass,
|
|
39
|
+
placeholder = props.placeholder,
|
|
40
|
+
left = props.left,
|
|
41
|
+
size = props.size,
|
|
42
|
+
_React$useState = _react2.default.useState(props.input.value),
|
|
43
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
44
|
+
value = _React$useState2[0],
|
|
45
|
+
setValue = _React$useState2[1],
|
|
46
|
+
valueToShow = formatValue(value, props.optional),
|
|
47
|
+
updateValue = function updateValue(targetValue) {
|
|
48
|
+
setValue(targetValue);
|
|
49
|
+
props.input.onChange((0, _common.getFloatValueToStore)(targetValue));
|
|
50
|
+
},
|
|
51
|
+
handleBlur = function handleBlur() {
|
|
52
|
+
var newValue = (0, _common.clearFloatOnBlur)(value),
|
|
53
|
+
hasChanged = value !== newValue;
|
|
54
|
+
|
|
55
|
+
if (hasChanged) {
|
|
56
|
+
updateValue(newValue);
|
|
69
57
|
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
58
|
+
},
|
|
59
|
+
handleChange = function handleChange(_ref) {
|
|
60
|
+
var targetValue = _ref.target.value;
|
|
61
|
+
|
|
62
|
+
updateValue(targetValue);
|
|
63
|
+
},
|
|
64
|
+
warningClass = "" + (touched && error ? " is-invalid" : ""),
|
|
65
|
+
customClass = "" + (inputClass ? " " + inputClass : ""),
|
|
66
|
+
classForInput = "form-control " + warningClass + customClass,
|
|
67
|
+
classForDiv = "form-group row " + (divClass ? divClass : "");
|
|
68
|
+
|
|
69
|
+
return _react2.default.createElement(
|
|
70
|
+
"div",
|
|
71
|
+
{ className: (0, _classnames2.default)(classForDiv, {
|
|
72
|
+
"is-invalid": touched && error
|
|
73
|
+
}) },
|
|
74
|
+
_react2.default.createElement(
|
|
75
|
+
"label",
|
|
76
|
+
{
|
|
77
|
+
className: (left ? left : "col-md-4 text-md-right") + " form-control-label",
|
|
78
|
+
htmlFor: input.name },
|
|
79
|
+
label
|
|
80
|
+
),
|
|
81
|
+
_react2.default.createElement(
|
|
82
|
+
"div",
|
|
83
|
+
{ className: right ? right : "col-md-8" },
|
|
84
|
+
_react2.default.createElement("input", {
|
|
85
|
+
"aria-label": label,
|
|
86
|
+
autoFocus: autoFocus,
|
|
87
|
+
className: classForInput,
|
|
88
|
+
disabled: submitting,
|
|
89
|
+
id: input.name,
|
|
90
|
+
maxLength: size,
|
|
91
|
+
onBlur: handleBlur,
|
|
92
|
+
onChange: handleChange,
|
|
93
|
+
placeholder: placeholder,
|
|
94
|
+
ref: onRegisterRef,
|
|
95
|
+
tabIndex: tabIndex,
|
|
96
|
+
type: type,
|
|
97
|
+
value: formatValue(valueToShow, props.optional)
|
|
98
|
+
}),
|
|
99
|
+
_react2.default.createElement(
|
|
99
100
|
"div",
|
|
100
|
-
{ className:
|
|
101
|
-
_react2.default.createElement(
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
htmlFor: input.name },
|
|
106
|
-
label
|
|
107
|
-
),
|
|
108
|
-
_react2.default.createElement(
|
|
109
|
-
"div",
|
|
110
|
-
{ className: right ? right : "col-md-8" },
|
|
111
|
-
_react2.default.createElement("input", {
|
|
112
|
-
"aria-label": label,
|
|
113
|
-
autoFocus: autoFocus,
|
|
114
|
-
className: classForInput,
|
|
115
|
-
disabled: submitting,
|
|
116
|
-
id: input.name,
|
|
117
|
-
maxLength: size,
|
|
118
|
-
onBlur: this.handleBlur,
|
|
119
|
-
onChange: this.handleChange,
|
|
120
|
-
onFocus: input.onFocus,
|
|
121
|
-
onKeyDown: this.handleKeyDown,
|
|
122
|
-
placeholder: placeholder,
|
|
123
|
-
ref: onRegisterRef,
|
|
124
|
-
tabIndex: tabIndex,
|
|
125
|
-
type: type,
|
|
126
|
-
value: formatValue(this.state.value, this.props.optional)
|
|
127
|
-
}),
|
|
128
|
-
_react2.default.createElement(
|
|
129
|
-
"div",
|
|
130
|
-
{ className: "invalid-feedback" },
|
|
131
|
-
touched && error && _react2.default.createElement(
|
|
132
|
-
"span",
|
|
133
|
-
null,
|
|
134
|
-
error
|
|
135
|
-
)
|
|
136
|
-
)
|
|
101
|
+
{ className: "invalid-feedback" },
|
|
102
|
+
touched && error && _react2.default.createElement(
|
|
103
|
+
"span",
|
|
104
|
+
null,
|
|
105
|
+
error
|
|
137
106
|
)
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return NumericTemplate;
|
|
143
|
-
}(_react2.default.Component);
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
};
|
|
144
111
|
|
|
145
|
-
|
|
146
|
-
formatValue: _utility.formatZeroValue,
|
|
147
|
-
normalizeValue: _utility.normalizeFloat
|
|
148
|
-
};
|
|
112
|
+
exports.default = NumericTemplate;
|
package/Inputs/common.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
8
|
+
|
|
9
|
+
/* eslint-disable require-unicode-regexp */
|
|
10
|
+
|
|
11
|
+
var isFloat = function isFloat(raw) {
|
|
12
|
+
var floatRegex = /^-?\d+(?:[.]\d*?)?$/;
|
|
13
|
+
|
|
14
|
+
return floatRegex.test(raw);
|
|
15
|
+
},
|
|
16
|
+
floatToEnglishComma = function floatToEnglishComma(raw) {
|
|
17
|
+
return String(raw).replace(",", ".");
|
|
18
|
+
},
|
|
19
|
+
floatToLocalComma = function floatToLocalComma(raw) {
|
|
20
|
+
return String(raw).replace(".", ",");
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var getFloatValueToStore = exports.getFloatValueToStore = function getFloatValueToStore(raw) {
|
|
24
|
+
var parsedFloat = floatToEnglishComma(raw),
|
|
25
|
+
parsedValue = parseFloat(parsedFloat),
|
|
26
|
+
canGetNumericValue = isFloat(parsedFloat) && !isNaN(parsedValue);
|
|
27
|
+
|
|
28
|
+
if (canGetNumericValue) {
|
|
29
|
+
return parsedValue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return 0;
|
|
33
|
+
},
|
|
34
|
+
clearFloatOnBlur = exports.clearFloatOnBlur = function clearFloatOnBlur(value) {
|
|
35
|
+
var parts = floatToLocalComma(value).split(","),
|
|
36
|
+
shouldRemoveComma = parts.length === 2 && (parts[1] === "" || Number(parts[1]) === 0),
|
|
37
|
+
shouldCutTo2Decimals = parts.length === 2 && parts[1].length > 2;
|
|
38
|
+
|
|
39
|
+
if (shouldRemoveComma) {
|
|
40
|
+
return parts[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (shouldCutTo2Decimals) {
|
|
44
|
+
var _parts = _slicedToArray(parts, 1),
|
|
45
|
+
beforeDot = _parts[0],
|
|
46
|
+
afterDot = parts[1].substring(0, 2);
|
|
47
|
+
|
|
48
|
+
return beforeDot + "," + afterDot;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return value;
|
|
52
|
+
};
|
package/package.json
CHANGED