intelicoreact 0.1.53 → 0.1.54

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.
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.filterNumeric = exports.filterPhone = exports.filterToLimitLength = exports.filterFloat = exports.formatToCutOffDotAtTheEnd = exports.formatToRemoveComa = exports.formatToOnlyASCIICodeText = exports.formatToLetters = exports.formatToTwoDigitAfterDot = exports.formatToAddBitDepthPoints = exports.formatOnlyNumbers = void 0;
8
+ exports.filterNumeric = exports.filterPhone = exports.filterToLimitLength = exports.filterFloat = exports.formatNumberValueToMask = exports.formatToCutOffDotAtTheEnd = exports.formatToRemoveComa = exports.formatToOnlyASCIICodeText = exports.formatToLetters = exports.formatToTwoDigitAfterDot = exports.formatToAddBitDepthPoints = exports.formatOnlyNumbers = void 0;
9
9
 
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
@@ -13,7 +13,7 @@ var _index = require("../Constants/index.constants");
13
13
 
14
14
  // The first word "format" in the function name means a logic in which the function transforms the incoming value in any case.
15
15
  // The first word "filter" in the function name means a logic in which the function works as a changer for sequential input
16
- // format
16
+ // *** format ***
17
17
  var formatOnlyNumbers = function formatOnlyNumbers(value) {
18
18
  return (!!value ? value.toString() : '').replace(/\D/g, '');
19
19
  };
@@ -75,11 +75,44 @@ exports.formatToRemoveComa = formatToRemoveComa;
75
75
  var formatToCutOffDotAtTheEnd = function formatToCutOffDotAtTheEnd(inputValue) {
76
76
  var value = !!inputValue ? inputValue.toString() : '';
77
77
  return value.toString().slice(-1) === '.' ? value.slice(0, -1) : value;
78
- }; // filter
78
+ }; // eslint-disable-next-line default-param-last
79
79
 
80
80
 
81
81
  exports.formatToCutOffDotAtTheEnd = formatToCutOffDotAtTheEnd;
82
82
 
83
+ var formatNumberValueToMask = function formatNumberValueToMask() {
84
+ var inputValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
85
+ var settings = arguments.length > 1 ? arguments[1] : undefined;
86
+
87
+ // default valueSymbol === 'n', default mask === 'nnn-nnn-nnnn'
88
+ var _ref = settings || {},
89
+ _ref$mask = _ref.mask,
90
+ mask = _ref$mask === void 0 ? 'XXX-XXX-XXXX' : _ref$mask,
91
+ _ref$valueSymbol = _ref.valueSymbol,
92
+ valueSymbol = _ref$valueSymbol === void 0 ? 'X' : _ref$valueSymbol,
93
+ _ref$isReturnAdvanced = _ref.isReturnAdvanced,
94
+ isReturnAdvanced = _ref$isReturnAdvanced === void 0 ? false : _ref$isReturnAdvanced;
95
+
96
+ var processing = mask.split('').reduce(function (acc, item) {
97
+ if (acc.value.length) ++acc.cursorPosition;
98
+ acc.newValue.push(item === valueSymbol && acc.value.length ? acc.value.shift() : item);
99
+ return acc;
100
+ }, {
101
+ value: inputValue.split('').filter(function (sym) {
102
+ return /[0-9]/g.test(sym);
103
+ }),
104
+ newValue: [],
105
+ cursorPosition: 0
106
+ });
107
+ return isReturnAdvanced ? {
108
+ value: processing.newValue.join(''),
109
+ cursorPosition: processing.cursorPosition
110
+ } : processing.newValue.join('');
111
+ }; // *** filter ***
112
+
113
+
114
+ exports.formatNumberValueToMask = formatNumberValueToMask;
115
+
83
116
  var filterFloat = function filterFloat(inputValue) {
84
117
  var decimalPlaces = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
85
118
  var value = !!inputValue ? inputValue.toString() : '';
@@ -113,10 +146,10 @@ var filterPhone = function filterPhone(value) {
113
146
  exports.filterPhone = filterPhone;
114
147
 
115
148
  var filterNumeric = function filterNumeric(value, settings) {
116
- var _ref = settings || {},
117
- _ref$type = _ref.type,
118
- type = _ref$type === void 0 ? 'float' : _ref$type,
119
- decimalPlaces = _ref.decimalPlaces;
149
+ var _ref2 = settings || {},
150
+ _ref2$type = _ref2.type,
151
+ type = _ref2$type === void 0 ? 'float' : _ref2$type,
152
+ decimalPlaces = _ref2.decimalPlaces;
120
153
 
121
154
  var executor = type === 'float' ? filterFloat : formatOnlyNumbers;
122
155
  return executor(!!value ? value.toString() : '', decimalPlaces);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "description": "fix UserBox crush",
5
5
  "main": "dist/index.js",
6
6
  "files": ["dist/*", "node_modules/anme/*", "node_modules/moment/*", "node_modules/moment-timezone/*"],