@invoicebox/ui 0.1.0-alpha.154 → 0.1.0-alpha.156

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.
@@ -9,7 +9,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
9
9
  var IconWrapper = exports.IconWrapper = _styledComponents["default"].div.withConfig({
10
10
  displayName: "styles__IconWrapper",
11
11
  componentId: "sc-1fsrle6-0"
12
- })(["position:absolute;right:14px;height:100%;top:0;display:flex;align-items:center;"]);
12
+ })(["position:absolute;right:14px;height:100%;top:0;display:flex;align-items:center;pointer-events:none;"]);
13
13
  var ControlWrapper = exports.ControlWrapper = _styledComponents["default"].div.withConfig({
14
14
  displayName: "styles__ControlWrapper",
15
15
  componentId: "sc-1fsrle6-1"
@@ -1,8 +1,8 @@
1
- import * as yup from 'yup';
1
+ import { TCreateErrorFunc } from './types';
2
2
  export declare class Validate {
3
- static bic(value: string, path: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
4
- static website(value: string, path: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
5
- static vatNumber(value: string, path: string, countryId: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
6
- static taxRegistrationReasonCode(value: string, path: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
7
- static registrationNumber(value: string, path: string, vatNumber: string, countryId: string, createError: (params?: yup.CreateErrorOptions) => yup.ValidationError): true | yup.ValidationError;
3
+ static bic(value: string, createError: TCreateErrorFunc): any;
4
+ static website(value: string, createError: TCreateErrorFunc): any;
5
+ static vatNumber(value: string, countryId: string, createError: TCreateErrorFunc): any;
6
+ static taxRegistrationReasonCode(value: string, createError: TCreateErrorFunc): any;
7
+ static registrationNumber(value: string, vatNumber: string, countryId: string, createError: TCreateErrorFunc): any;
8
8
  }
@@ -18,101 +18,86 @@ var Validate = exports.Validate = /*#__PURE__*/function () {
18
18
  }
19
19
  return _createClass(Validate, null, [{
20
20
  key: "bic",
21
- value: function bic(value, path, createError) {
21
+ value: function bic(value, createError) {
22
22
  if (value === '') {
23
23
  return true;
24
24
  }
25
25
  if (/[^0-9]/.test(value)) {
26
- return createError({
27
- path: path,
28
- message: 'БИК может состоять только из цифр'
29
- });
26
+ return createError('БИК может состоять только из цифр');
30
27
  }
31
28
  if (value.length !== 9) {
32
- return createError({
33
- path: path,
34
- message: 'БИК может состоять только из 9 цифр'
35
- });
29
+ return createError('БИК может состоять только из 9 цифр');
36
30
  }
37
31
  return true;
38
32
  }
39
33
  }, {
40
34
  key: "website",
41
- value: function website(value, path, createError) {
35
+ value: function website(value, createError) {
42
36
  if (value === '') {
43
37
  return true;
44
38
  }
45
39
  if (value.match(/^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm)) {
46
40
  return true;
47
41
  }
48
- return createError({
49
- path: path,
50
- message: 'Некорректный адрес'
51
- });
42
+ return createError('Некорректный адрес');
52
43
  }
53
44
  }, {
54
45
  key: "vatNumber",
55
- value: function vatNumber(value, path, countryId, createError) {
46
+ value: function vatNumber(value, countryId, createError) {
56
47
  switch (countryId) {
57
48
  case 'KAZ':
58
49
  {
59
- return (0, _vatNumberValidateHelpers.KAZValidate)(value, path, createError);
50
+ return (0, _vatNumberValidateHelpers.KAZValidate)(value, createError);
60
51
  }
61
52
  case 'BLR':
62
53
  {
63
- return (0, _vatNumberValidateHelpers.BLRValidate)(value, path, createError);
54
+ return (0, _vatNumberValidateHelpers.BLRValidate)(value, createError);
64
55
  }
65
56
  case 'MDA':
66
57
  {
67
- return (0, _vatNumberValidateHelpers.MDAValidate)(value, path, createError);
58
+ return (0, _vatNumberValidateHelpers.MDAValidate)(value, createError);
68
59
  }
69
60
  case 'AZE':
70
61
  {
71
- return (0, _vatNumberValidateHelpers.AZEValidate)(value, path, createError);
62
+ return (0, _vatNumberValidateHelpers.AZEValidate)(value, createError);
72
63
  }
73
64
  case 'ARM':
74
65
  {
75
- return (0, _vatNumberValidateHelpers.ARMValidate)(value, path, createError);
66
+ return (0, _vatNumberValidateHelpers.ARMValidate)(value, createError);
76
67
  }
77
68
  case 'UZB':
78
69
  {
79
- return (0, _vatNumberValidateHelpers.UZBValidate)(value, path, createError);
70
+ return (0, _vatNumberValidateHelpers.UZBValidate)(value, createError);
80
71
  }
81
72
  case 'TJK':
82
73
  {
83
- return (0, _vatNumberValidateHelpers.TJKValidate)(value, path, createError);
74
+ return (0, _vatNumberValidateHelpers.TJKValidate)(value, createError);
84
75
  }
85
76
  case 'KGZ':
86
77
  {
87
- return (0, _vatNumberValidateHelpers.KGZValidate)(value, path, createError);
78
+ return (0, _vatNumberValidateHelpers.KGZValidate)(value, createError);
88
79
  }
89
80
  default:
90
- return (0, _vatNumberValidateHelpers.RUSValidate)(value, path, createError);
81
+ return (0, _vatNumberValidateHelpers.RUSValidate)(value, createError);
91
82
  }
92
83
  }
93
84
  }, {
94
85
  key: "taxRegistrationReasonCode",
95
- value: function taxRegistrationReasonCode(value, path, createError) {
86
+ value: function taxRegistrationReasonCode(value, createError) {
96
87
  if (value === '') {
97
88
  return true;
98
89
  }
99
90
  if (value.length !== 9) {
100
- return createError({
101
- path: path,
102
- message: 'КПП может состоять только из 9 знаков'
103
- });
91
+ return createError('КПП может состоять только из 9 знаков');
104
92
  }
105
93
  if (!/^[0-9]{4}[0-9A-Z]{2}[0-9]{3}$/.test(value)) {
106
- return createError({
107
- path: path,
108
- message: 'Неправильный формат КПП'
109
- });
94
+ return createError('Неправильный формат КПП');
110
95
  }
111
96
  return true;
112
97
  }
113
98
  }, {
114
99
  key: "registrationNumber",
115
- value: function registrationNumber(value, path, vatNumber, countryId, createError) {
100
+ value: function registrationNumber(value, vatNumber, countryId, createError) {
116
101
  if (!vatNumber || !countryId) {
117
102
  // eslint-disable-next-line no-console
118
103
  console.error('Form dont have vatNumber or countryId');
@@ -126,10 +111,7 @@ var Validate = exports.Validate = /*#__PURE__*/function () {
126
111
  if (n13 === parseInt(value[12], 10)) {
127
112
  return true;
128
113
  } else {
129
- return createError({
130
- path: path,
131
- message: 'Неправильное контрольное число'
132
- });
114
+ return createError('Неправильное контрольное число');
133
115
  }
134
116
  }
135
117
  if (value.length === 15 && vatNumber.length === _vatNumberValidateHelpers.LENGTH_VAT_NUMBER.RUS_INDIVIDUAL_ENTREPRENEUR) {
@@ -137,16 +119,10 @@ var Validate = exports.Validate = /*#__PURE__*/function () {
137
119
  if (n15 === parseInt(value[14], 10)) {
138
120
  return true;
139
121
  } else {
140
- return createError({
141
- path: path,
142
- message: 'Неправильное контрольное число'
143
- });
122
+ return createError('Неправильное контрольное число');
144
123
  }
145
124
  }
146
- return createError({
147
- path: path,
148
- message: 'ОГРН состоит из 13 или 15 знаков'
149
- });
125
+ return createError('ОГРН состоит из 13 или 15 знаков');
150
126
  }
151
127
  return true;
152
128
  }
@@ -0,0 +1 @@
1
+ export type TCreateErrorFunc = (message: string) => any;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,4 +1,4 @@
1
- import * as yup from 'yup';
1
+ import { TCreateErrorFunc } from '../types';
2
2
  export declare const LENGTH_VAT_NUMBER: {
3
3
  RUS_INDIVIDUAL_ENTREPRENEUR: number;
4
4
  RUS_LEGAL_ENTREPRENEUR: number;
@@ -12,12 +12,12 @@ export declare const LENGTH_VAT_NUMBER: {
12
12
  TJK_VAT_NUMBER_LONG: number;
13
13
  UZB_VAT_NUMBER: number;
14
14
  };
15
- export declare const BLRValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
16
- export declare const AZEValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
17
- export declare const MDAValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
18
- export declare const KAZValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
19
- export declare const ARMValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
20
- export declare const UZBValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
21
- export declare const TJKValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
22
- export declare const KGZValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
23
- export declare const RUSValidate: (value: string, path: string, createError: (params?: yup.CreateErrorOptions | undefined) => yup.ValidationError) => true | yup.ValidationError;
15
+ export declare const BLRValidate: (value: string, createError: TCreateErrorFunc) => any;
16
+ export declare const AZEValidate: (value: string, createError: TCreateErrorFunc) => any;
17
+ export declare const MDAValidate: (value: string, createError: TCreateErrorFunc) => any;
18
+ export declare const KAZValidate: (value: string, createError: TCreateErrorFunc) => any;
19
+ export declare const ARMValidate: (value: string, createError: TCreateErrorFunc) => any;
20
+ export declare const UZBValidate: (value: string, createError: TCreateErrorFunc) => any;
21
+ export declare const TJKValidate: (value: string, createError: TCreateErrorFunc) => any;
22
+ export declare const KGZValidate: (value: string, createError: TCreateErrorFunc) => any;
23
+ export declare const RUSValidate: (value: string, createError: TCreateErrorFunc) => any;
@@ -22,140 +22,92 @@ var checkDigitFunc = function checkDigitFunc(inn, coefficients, valueDigit) {
22
22
  return sum + current * Number(inn[index]);
23
23
  }, 0) % valueDigit;
24
24
  };
25
- var checkKaz = function checkKaz(value, path, createError) {
25
+ var checkKaz = function checkKaz(value, createError) {
26
26
  var checkNumber = checkDigitFunc(value, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 11);
27
27
  if (checkNumber === 10) {
28
28
  var replyCheckNumber = checkDigitFunc(value, [3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2], 11);
29
29
  if (replyCheckNumber === 10 || replyCheckNumber !== Number(value[11])) {
30
- return createError({
31
- path: path,
32
- message: 'Неверное контрольное число'
33
- });
30
+ return createError('Неверное контрольное число');
34
31
  }
35
32
  return true;
36
33
  }
37
34
  if (checkNumber !== Number(value[11])) {
38
- return createError({
39
- path: path,
40
- message: 'Неверное контрольное число'
41
- });
35
+ return createError('Неверное контрольное число');
42
36
  }
43
37
  return true;
44
38
  };
45
- var BLRValidate = exports.BLRValidate = function BLRValidate(value, path, createError) {
39
+ var BLRValidate = exports.BLRValidate = function BLRValidate(value, createError) {
46
40
  if (value.length !== LENGTH_VAT_NUMBER.BLR_VAT_NUMBER) {
47
- return createError({
48
- path: path,
49
- message: 'УНБ должен состоять из 9 цифр'
50
- });
41
+ return createError('УНБ должен состоять из 9 цифр');
51
42
  }
52
43
  if (checkDigitFunc(value, [29, 23, 19, 17, 13, 7, 5, 3], 11) === Number(value[8])) {
53
44
  return true;
54
45
  }
55
- return createError({
56
- path: path,
57
- message: 'Неверное контрольное число'
58
- });
46
+ return createError('Неверное контрольное число');
59
47
  };
60
- var AZEValidate = exports.AZEValidate = function AZEValidate(value, path, createError) {
48
+ var AZEValidate = exports.AZEValidate = function AZEValidate(value, createError) {
61
49
  if (value.length !== LENGTH_VAT_NUMBER.AZE_VAT_NUMBER) {
62
- return createError({
63
- path: path,
64
- message: 'ИНН должен состоять из 10 цифр'
65
- });
50
+ return createError('ИНН должен состоять из 10 цифр');
66
51
  }
67
52
  if (Number(value[value.length - 1]) === 1) {
68
53
  return true;
69
54
  }
70
- return createError({
71
- path: path,
72
- message: 'Неверное контрольное число'
73
- });
55
+ return createError('Неверное контрольное число');
74
56
  };
75
- var MDAValidate = exports.MDAValidate = function MDAValidate(value, path, createError) {
57
+ var MDAValidate = exports.MDAValidate = function MDAValidate(value, createError) {
76
58
  if (value.length !== LENGTH_VAT_NUMBER.MDA_VAT_NUMBER) {
77
- return createError({
78
- path: path,
79
- message: 'IDNO должен состоять из 13 цифр'
80
- });
59
+ return createError('IDNO должен состоять из 13 цифр');
81
60
  }
82
61
  if (Number(value[0]) === 1 && checkDigitFunc(value, [7, 3, 1, 7, 3, 1, 7, 3, 1, 7, 3, 1], 10) === Number(value[12])) {
83
62
  return true;
84
63
  }
85
- return createError({
86
- path: path,
87
- message: 'Неверное контрольное число'
88
- });
64
+ return createError('Неверное контрольное число');
89
65
  };
90
- var KAZValidate = exports.KAZValidate = function KAZValidate(value, path, createError) {
66
+ var KAZValidate = exports.KAZValidate = function KAZValidate(value, createError) {
91
67
  if (value.length !== LENGTH_VAT_NUMBER.KAZ_VAT_NUMBER) {
92
- return createError({
93
- path: path,
94
- message: 'ИИН/БИН должен состоять из 12 цифр'
95
- });
68
+ return createError('ИИН/БИН должен состоять из 12 цифр');
96
69
  }
97
70
  var iinFourthValue = ['0', '1', '2', '3'];
98
71
  var binFourthValue = ['4', '5', '6'];
99
72
  if (iinFourthValue.includes(value[4])) {
100
73
  var centuryBirthdayCode = value[6];
101
74
  if (Number(centuryBirthdayCode) > 6 || Number(value.substring(2, 3)) > 12 || Number(value.substring(0, 1)) > 31) {
102
- return createError({
103
- path: path,
104
- message: 'Неверное контрольное число'
105
- });
75
+ return createError('Неверное контрольное число');
106
76
  }
107
- return checkKaz(value, path, createError);
77
+ return checkKaz(value, createError);
108
78
  }
109
79
  if (binFourthValue.includes(value[4])) {
110
- return checkKaz(value, path, createError);
80
+ return checkKaz(value, createError);
111
81
  }
112
- return createError({
113
- path: path,
114
- message: 'Неверное контрольное число'
115
- });
82
+ return createError('Неверное контрольное число');
116
83
  };
117
- var ARMValidate = exports.ARMValidate = function ARMValidate(value, path, createError) {
84
+ var ARMValidate = exports.ARMValidate = function ARMValidate(value, createError) {
118
85
  if (value.length !== LENGTH_VAT_NUMBER.ARM_VAT_NUMBER) {
119
- return createError({
120
- path: path,
121
- message: 'УНН должен состоять из 8 цифр'
122
- });
86
+ return createError('УНН должен состоять из 8 цифр');
123
87
  }
124
88
  return true;
125
89
  };
126
- var UZBValidate = exports.UZBValidate = function UZBValidate(value, path, createError) {
90
+ var UZBValidate = exports.UZBValidate = function UZBValidate(value, createError) {
127
91
  if (value.length !== LENGTH_VAT_NUMBER.UZB_VAT_NUMBER) {
128
- return createError({
129
- path: path,
130
- message: 'ИНН должен состоять из 9 цифр'
131
- });
92
+ return createError('ИНН должен состоять из 9 цифр');
132
93
  }
133
94
  return true;
134
95
  };
135
- var TJKValidate = exports.TJKValidate = function TJKValidate(value, path, createError) {
96
+ var TJKValidate = exports.TJKValidate = function TJKValidate(value, createError) {
136
97
  if (value.length !== LENGTH_VAT_NUMBER.TJK_VAT_NUMBER_LONG && value.length !== LENGTH_VAT_NUMBER.TJK_VAT_NUMBER_SHORT) {
137
- return createError({
138
- path: path,
139
- message: 'ИНН должен состоять из 9 или 10 цифр'
140
- });
98
+ return createError('ИНН должен состоять из 9 или 10 цифр');
141
99
  }
142
100
  return true;
143
101
  };
144
- var KGZValidate = exports.KGZValidate = function KGZValidate(value, path, createError) {
102
+ var KGZValidate = exports.KGZValidate = function KGZValidate(value, createError) {
145
103
  if (value.length !== LENGTH_VAT_NUMBER.KGZ_VAT_NUMBER) {
146
- return createError({
147
- path: path,
148
- message: 'ИНН должен состоять из 14 цифр'
149
- });
104
+ return createError('ИНН должен состоять из 14 цифр');
150
105
  }
151
106
  return true;
152
107
  };
153
- var RUSValidate = exports.RUSValidate = function RUSValidate(value, path, createError) {
108
+ var RUSValidate = exports.RUSValidate = function RUSValidate(value, createError) {
154
109
  if ([LENGTH_VAT_NUMBER.RUS_LEGAL_ENTREPRENEUR, LENGTH_VAT_NUMBER.RUS_INDIVIDUAL_ENTREPRENEUR].indexOf(value.length) === -1) {
155
- return createError({
156
- path: path,
157
- message: 'ИНН должен состоять из 10 или 12 цифр'
158
- });
110
+ return createError('ИНН должен состоять из 10 или 12 цифр');
159
111
  } else {
160
112
  switch (value.length) {
161
113
  case LENGTH_VAT_NUMBER.RUS_LEGAL_ENTREPRENEUR:
@@ -176,14 +128,8 @@ var RUSValidate = exports.RUSValidate = function RUSValidate(value, path, create
176
128
  break;
177
129
  }
178
130
  default:
179
- return createError({
180
- path: path,
181
- message: 'Неверное контрольное число'
182
- });
131
+ return createError('Неверное контрольное число');
183
132
  }
184
- return createError({
185
- path: path,
186
- message: 'Неверное контрольное число'
187
- });
133
+ return createError('Неверное контрольное число');
188
134
  }
189
135
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoicebox/ui",
3
- "version": "0.1.0-alpha.154",
3
+ "version": "0.1.0-alpha.156",
4
4
  "description": "Invoicebox UI",
5
5
  "license": "Apache License 2.0",
6
6
  "scripts": {
@@ -63,8 +63,7 @@
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": "^18.2.0",
66
- "styled-components": "^6.1.8",
67
- "yup": "^0.32.11"
66
+ "styled-components": "^6.1.8"
68
67
  },
69
68
  "engines": {
70
69
  "node": ">=16.0.0"