@invoicebox/ui 0.1.0-alpha.139 → 0.1.0-alpha.140

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.
@@ -30,7 +30,8 @@ var TextInput = exports.TextInput = function TextInput(_ref) {
30
30
  type = _ref.type,
31
31
  children = _ref.children,
32
32
  _ref$size = _ref.size,
33
- size = _ref$size === void 0 ? 'L' : _ref$size;
33
+ size = _ref$size === void 0 ? 'L' : _ref$size,
34
+ isOnlyNumbers = _ref.isOnlyNumbers;
34
35
  var _useInputFocus = (0, _useInputFocus2.useInputFocus)({
35
36
  onFocus: onFocus,
36
37
  onBlur: onBlur
@@ -56,6 +57,7 @@ var TextInput = exports.TextInput = function TextInput(_ref) {
56
57
  onChange: handleChange,
57
58
  placeholder: placeholder,
58
59
  paddingRight: paddingRight,
59
- type: type
60
+ type: type,
61
+ isOnlyNumbers: isOnlyNumbers
60
62
  }, _constants.SIZE_PADDING_MAP[size])), children && /*#__PURE__*/_react["default"].createElement(S.ChildrenWrapper, null, children)));
61
63
  };
@@ -2,4 +2,5 @@ import * as yup from 'yup';
2
2
  export declare class Validate {
3
3
  static vatNumber(value: string, path: string, countryId: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
4
4
  static taxRegistrationReasonCode(value: string, path: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
5
+ static registrationNumber(value: string, path: string, vatNumber: string, countryId: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
5
6
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Validate = void 0;
7
7
  var _vatNumberValidateHelpers = require("./utils/vatNumberValidateHelpers");
8
+ var _types = require("../components/form/PhoneInput/types");
8
9
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
10
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
11
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
@@ -75,5 +76,41 @@ var Validate = exports.Validate = /*#__PURE__*/function () {
75
76
  }
76
77
  return true;
77
78
  }
79
+ }, {
80
+ key: "registrationNumber",
81
+ value: function registrationNumber(value, path, vatNumber, countryId, createError) {
82
+ if (value === '') {
83
+ return true;
84
+ }
85
+ if (countryId === _types.RUS_COUNTRY_CODE) {
86
+ if (value.length === 13 && vatNumber.length === _vatNumberValidateHelpers.LENGTH_VAT_NUMBER.RUS_LEGAL_ENTREPRENEUR) {
87
+ var n13 = parseInt((parseInt(value.slice(0, -1), 10) % 11).toString().slice(-1), 10);
88
+ if (n13 === parseInt(value[12], 10)) {
89
+ return true;
90
+ } else {
91
+ return createError({
92
+ path: path,
93
+ message: 'Неправильное контрольное число'
94
+ });
95
+ }
96
+ }
97
+ if (value.length === 15 && vatNumber.length === _vatNumberValidateHelpers.LENGTH_VAT_NUMBER.RUS_INDIVIDUAL_ENTREPRENEUR) {
98
+ var n15 = parseInt((parseInt(value.slice(0, -1), 10) % 13).toString().slice(-1), 10);
99
+ if (n15 === parseInt(value[14], 10)) {
100
+ return true;
101
+ } else {
102
+ return createError({
103
+ path: path,
104
+ message: 'Неправильное контрольное число'
105
+ });
106
+ }
107
+ }
108
+ return createError({
109
+ path: path,
110
+ message: 'ОГРН состоит из 13 или 15 знаков'
111
+ });
112
+ }
113
+ return true;
114
+ }
78
115
  }]);
79
116
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoicebox/ui",
3
- "version": "0.1.0-alpha.139",
3
+ "version": "0.1.0-alpha.140",
4
4
  "description": "Invoicebox UI",
5
5
  "license": "Apache License 2.0",
6
6
  "scripts": {