x25 5.1.9 → 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.
@@ -34,7 +34,7 @@ var RouteLoading = function RouteLoading(_ref) {
34
34
  if (theError.name === "ChunkLoadError") {
35
35
  return _react2.default.createElement(_Error.LargeErrorMessage, {
36
36
  onRetry: retry,
37
- error: "Pagina nu a putut fi \xEEnc\u0103rcat\u0103. V\u0103 rug\u0103m s\u0103 face\u021Bi refresh la pagin\u0103"
37
+ message: "Pagina nu a putut fi \xEEnc\u0103rcat\u0103. V\u0103 rug\u0103m s\u0103 face\u021Bi refresh la pagin\u0103"
38
38
  });
39
39
  }
40
40
 
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.NumericInput = undefined;
7
6
 
8
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
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("../utility");
19
+ var _utility = require("x25/utility");
19
20
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
- _this.handleChange = function (_ref) {
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
- return _react2.default.createElement(
117
- "div",
118
- { className: "input-group" },
119
- inputComponent,
120
- _react2.default.createElement(
121
- "div",
122
- { className: "input-group-append" },
123
- _react2.default.createElement(
124
- "span",
125
- { className: "input-group-text" },
126
- currency
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
- return NumericInput;
134
- }(_react2.default.Component);
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
- NumericInput.defaultProps = {
137
- formatValue: _utility.formatZeroValue,
138
- normalizeValue: _utility.normalizeFloat
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 _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
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 _utility = require("../utility");
20
+ var _common = require("./common");
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
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 NumericTemplate = exports.NumericTemplate = function (_React$Component) {
30
- _inherits(NumericTemplate, _React$Component);
31
-
32
- function NumericTemplate(props) {
33
- _classCallCheck(this, NumericTemplate);
34
-
35
- var _this = _possibleConstructorReturn(this, (NumericTemplate.__proto__ || Object.getPrototypeOf(NumericTemplate)).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
- };
50
-
51
- _this.handleChange = function (_ref) {
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(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
- key: "render",
72
- value: function render() {
73
- var _props = this.props,
74
- input = _props.input,
75
- label = _props.label,
76
- onRegisterRef = _props.onRegisterRef,
77
- _props$meta = _props.meta,
78
- submitting = _props$meta.submitting,
79
- touched = _props$meta.touched,
80
- error = _props$meta.error,
81
- formatValue = _props.formatValue,
82
- type = _props.type,
83
- autoFocus = _props.autoFocus,
84
- inputClass = _props.inputClass,
85
- placeholder = _props.placeholder,
86
- left = _props.left,
87
- size = _props.size,
88
- right = _props.right,
89
- tabIndex = _props.tabIndex,
90
- divClass = _props.divClass;
91
-
92
-
93
- var warningClass = "" + (touched && error ? " is-invalid" : ""),
94
- customClass = "" + (inputClass ? " " + inputClass : ""),
95
- classForInput = "form-control " + warningClass + customClass,
96
- classForDiv = "form-group row " + (divClass ? divClass : "");
97
-
98
- return _react2.default.createElement(
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: (0, _classnames2.default)(classForDiv, { "is-invalid": touched && error }) },
101
- _react2.default.createElement(
102
- "label",
103
- {
104
- className: (left ? left : "col-md-4 text-md-right") + " form-control-label",
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
- NumericTemplate.defaultProps = {
146
- formatValue: _utility.formatZeroValue,
147
- normalizeValue: _utility.normalizeFloat
148
- };
112
+ exports.default = NumericTemplate;
@@ -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/Messages/Error.js CHANGED
@@ -99,6 +99,16 @@ var LargeErrorMessage = exports.LargeErrorMessage = function LargeErrorMessage(_
99
99
  type: "button" },
100
100
  "Reîncearcă"
101
101
  )
102
+ ),
103
+ _react2.default.createElement(
104
+ "div",
105
+ { className: "text-center mt-3 border-top pt-2 text-muted small" },
106
+ "Dacă eroarea persistă, vă rugăm să navigați la ",
107
+ _react2.default.createElement(
108
+ "a",
109
+ { href: "/" },
110
+ " această pagină"
111
+ )
102
112
  )
103
113
  )
104
114
  )
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.1.9",
2
+ "version": "5.1.12",
3
3
  "name": "x25",
4
4
  "description": "x25",
5
5
  "scripts": {