@itfin/components 1.2.114 → 1.2.115

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "1.2.114",
3
+ "version": "1.2.115",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -22,120 +22,120 @@ function isEmpty(v) {
22
22
  }
23
23
 
24
24
  export function differentValidation (value, message) {
25
- return (v, $t) => !v || !(v === value) || (message || $t('components.theValueMustBeDifferent'));
25
+ return (v, $t = (s) => s) => !v || !(v === value) || (message || $t('components.theValueMustBeDifferent'));
26
26
  }
27
27
 
28
28
  export function mediumTextValidation (message) {
29
- return (v, $t) => !v || ((v || '').toString().trim().length <= MEDIUM_TEXT_LENGTH) || (message || $t('components.mediumTextLength'));
29
+ return (v, $t = (s) => s) => !v || ((v || '').toString().trim().length <= MEDIUM_TEXT_LENGTH) || (message || $t('components.mediumTextLength'));
30
30
  }
31
31
 
32
32
  export function lengthValidation (length, message) {
33
- return (v, $t) => !v || ((v || '').toString().trim().length <= length) || (message || $t('components.mustBeLessThanLengthCharacters', {length}));
33
+ return (v, $t = (s) => s) => !v || ((v || '').toString().trim().length <= length) || (message || $t('components.mustBeLessThanLengthCharacters', {length}));
34
34
  }
35
35
 
36
36
  export function minLengthValidation (length, message) {
37
- return (v, $t) => !v || ((v || '').toString().trim().length >= length) || (message || $t('components.mustBeMoreThanLengthCharacters', {length}));
37
+ return (v, $t = (s) => s) => !v || ((v || '').toString().trim().length >= length) || (message || $t('components.mustBeMoreThanLengthCharacters', {length}));
38
38
  }
39
39
 
40
40
  export function emailValidation (message) {
41
- return (v, $t) => !v || !!v.toString().match(EMAIL_REGEXP) || (message || $t('components.pleaseEnterAValidEmail'));
41
+ return (v, $t = (s) => s) => !v || !!v.toString().match(EMAIL_REGEXP) || (message || $t('components.pleaseEnterAValidEmail'));
42
42
  }
43
43
 
44
44
  export function emailListValidation (message) {
45
- return (v, $t) => !v || !!v.toString().match(EMAIL_LIST_REGEXP) || (message || $t('components.pleaseEnterValidCommaSeparatedEmailAddressesToSendInvoicing'));
45
+ return (v, $t = (s) => s) => !v || !!v.toString().match(EMAIL_LIST_REGEXP) || (message || $t('components.pleaseEnterValidCommaSeparatedEmailAddressesToSendInvoicing'));
46
46
  }
47
47
 
48
48
  export function urlValidation (message) {
49
- return (v, $t) => !v || !!v.toString().match(URL_REGEXP) || (message || $t('components.pleaseEnterValidURL'));
49
+ return (v, $t = (s) => s) => !v || !!v.toString().match(URL_REGEXP) || (message || $t('components.pleaseEnterValidURL'));
50
50
  }
51
51
 
52
52
  export function hexValidation (message) {
53
- return (v, $t) => !v || !!v.toString().match(HEX_REGEXP) || (message || $t('components.pleaseEnteraValidHex'));
53
+ return (v, $t = (s) => s) => !v || !!v.toString().match(HEX_REGEXP) || (message || $t('components.pleaseEnteraValidHex'));
54
54
  }
55
55
 
56
56
  export function passMatchValidation (password, message) {
57
- return (v, $t) => !v || !!v.toString().match(`^${password}$`) || (message || $t('components.passwordsDontMatch'));
57
+ return (v, $t = (s) => s) => !v || !!v.toString().match(`^${password}$`) || (message || $t('components.passwordsDontMatch'));
58
58
  }
59
59
 
60
60
  export function emptyValidation (message) {
61
- return (v, $t) => !isEmpty(v) || (message || $t('components.thisFieldIsRequired'));
61
+ return (v, $t = (s) => s) => !isEmpty(v) || (message || $t('components.thisFieldIsRequired'));
62
62
  }
63
63
 
64
64
  export function emptyArrayValidation (message) {
65
- return (v, $t) => (Array.isArray(v) && v.length > 0) || (message || $t('components.thisFieldIsRequired'));
65
+ return (v, $t = (s) => s) => (Array.isArray(v) && v.length > 0) || (message || $t('components.thisFieldIsRequired'));
66
66
  }
67
67
 
68
68
  export function doubleValidation (message) {
69
- return (v, $t) => !v || !!(v + '').match(DOUBLE_REGEXP) || (message || $t('components.thisFieldMustBeANumberFormatZero'));
69
+ return (v, $t = (s) => s) => !v || !!(v + '').match(DOUBLE_REGEXP) || (message || $t('components.thisFieldMustBeANumberFormatZero'));
70
70
  }
71
71
 
72
72
  export function minMaxValidation (min = 0, max = 100, message) {
73
- return (v, $t) => !v || (v >= min && v <= max) || (message || $t('components.theValueMustBeGreaterThanOrEqualToMinAndMax', {min, max}));
73
+ return (v, $t = (s) => s) => !v || (v >= min && v <= max) || (message || $t('components.theValueMustBeGreaterThanOrEqualToMinAndMax', {min, max}));
74
74
  }
75
75
 
76
76
  export function minValidation (min = 0, message) {
77
- return (v, $t) => (!isEmpty(v) && (Number(v) >= min)) || (message || $t('components.theValueMustBeGreaterThanOrEqualToMin', {min}));
77
+ return (v, $t = (s) => s) => (!isEmpty(v) && (Number(v) >= min)) || (message || $t('components.theValueMustBeGreaterThanOrEqualToMin', {min}));
78
78
  }
79
79
 
80
80
  export function maxValidation (max, message) {
81
- return (v, $t) => (!isEmpty(v) && (Number(v) <= max)) || (message || $t('components.mustBeLessThanMax'));
81
+ return (v, $t = (s) => s) => (!isEmpty(v) && (Number(v) <= max)) || (message || $t('components.mustBeLessThanMax'));
82
82
  }
83
83
 
84
84
  export function preventStuffingValidation (message) {
85
- return (v, $t) => !v || (v.replace(/(.{4,}?)(?:\1{3,})/g, (text, subtext) => /^(\s*(<(\/?[^>]+)>|&nbsp;|[^\s]{0,3})\s*|(.)\4+)$/.test(subtext) ? text : '') === v) || (message || $t('components.thisIsntABalidDescription'));
85
+ return (v, $t = (s) => s) => !v || (v.replace(/(.{4,}?)(?:\1{3,})/g, (text, subtext) => /^(\s*(<(\/?[^>]+)>|&nbsp;|[^\s]{0,3})\s*|(.)\4+)$/.test(subtext) ? text : '') === v) || (message || $t('components.thisIsntABalidDescription'));
86
86
  }
87
87
 
88
88
  export function preventUrlsValidation (message) {
89
- return (v, $t) => !v || !v.match(LINK_URL_REGEXP) || (message || $t('components.linksAreNotAllowedInThisField'));
89
+ return (v, $t = (s) => s) => !v || !v.match(LINK_URL_REGEXP) || (message || $t('components.linksAreNotAllowedInThisField'));
90
90
  }
91
91
 
92
92
  export function financeAccountCodeValidation (message) {
93
- return (v, $t) => !v || v.match(/^\d+(\.\d+)*$/g) || (message || $t('components.theValueMustBeginAndEndWithANumberAndContainOnlyNumbersOrDots'));
93
+ return (v, $t = (s) => s) => !v || v.match(/^\d+(\.\d+)*$/g) || (message || $t('components.theValueMustBeginAndEndWithANumberAndContainOnlyNumbersOrDots'));
94
94
  }
95
95
 
96
96
  export function preventHtmlValidation (message) {
97
- return (v, $t) => !v || !v.match(HTML_MARKUP_REGEXP) || (message || $t('components.pleaseDontUseHTMLMarkup'));
97
+ return (v, $t = (s) => s) => !v || !v.match(HTML_MARKUP_REGEXP) || (message || $t('components.pleaseDontUseHTMLMarkup'));
98
98
  }
99
99
 
100
100
  export function preventLinkedinValidation (message) {
101
- return (v, $t) => !v || !v.match(LINKED_IN_REGEXP) || (message || $t('components.beforeYouContinueMakeSureYourProfileDoesNotIncludeYourLinkedInContactInformation'));
101
+ return (v, $t = (s) => s) => !v || !v.match(LINKED_IN_REGEXP) || (message || $t('components.beforeYouContinueMakeSureYourProfileDoesNotIncludeYourLinkedInContactInformation'));
102
102
  }
103
103
 
104
104
  export function preventCapitalsValidation (message) {
105
- return (v, $t) => !v || !(v.replace(/[A-Z]/g, '').length < v.length / 2) || (message || $t('components.tooManyCapitalLetters'));
105
+ return (v, $t = (s) => s) => !v || !(v.replace(/[A-Z]/g, '').length < v.length / 2) || (message || $t('components.tooManyCapitalLetters'));
106
106
  }
107
107
 
108
108
  export function preventSpecialCharsValidation (message) {
109
- return (v, $t) => !v || !!v.match(SPECIAL_CHARS_REGEXP) || (message || $t('components.yourtitleCannotIncludeSpecialCharactersLike'));
109
+ return (v, $t = (s) => s) => !v || !!v.match(SPECIAL_CHARS_REGEXP) || (message || $t('components.yourtitleCannotIncludeSpecialCharactersLike'));
110
110
  }
111
111
 
112
112
  export function preventGreetingsValidation (message) {
113
- return (v, $t) => !v || !v.match(GREETINGS_REGEXP) || (message || $t('components.yourTitleShouldDescribeTheWorkYouDo'));
113
+ return (v, $t = (s) => s) => !v || !v.match(GREETINGS_REGEXP) || (message || $t('components.yourTitleShouldDescribeTheWorkYouDo'));
114
114
  }
115
115
 
116
116
  export function preventPhoneValidation (message) {
117
- return (v, $t) => !v || !v.match(PHONE_REGEXP) || (message || $t('components.pleaseRemoveAnyPhoneNumberFromThisField'));
117
+ return (v, $t = (s) => s) => !v || !v.match(PHONE_REGEXP) || (message || $t('components.pleaseRemoveAnyPhoneNumberFromThisField'));
118
118
  }
119
119
 
120
120
  export function allowDigitsOnlyValidation (message) {
121
- return (v, $t) => !v || !!v.match(/^\d+$/) || (message || $t('components.thisFieldMustContainsDigits'));
121
+ return (v, $t = (s) => s) => !v || !!v.match(/^\d+$/) || (message || $t('components.thisFieldMustContainsDigits'));
122
122
  }
123
123
 
124
124
  export function dateSameOrBeforeValidationLuxon (dateCompare, message) {
125
- return (v, $t) => !v || DateTime.fromISO(v) <= DateTime.fromISO(dateCompare) || (message || $t('components.thedateShouldBeSameOrBefore', {date: DateTime.fromISO(dateCompare).toFormat('dd-MM-yyyy')}));
125
+ return (v, $t = (s) => s) => !v || DateTime.fromISO(v) <= DateTime.fromISO(dateCompare) || (message || $t('components.thedateShouldBeSameOrBefore', {date: DateTime.fromISO(dateCompare).toFormat('dd-MM-yyyy')}));
126
126
  }
127
127
 
128
128
  export function dateAfterValidationLuxon (dateCompare, message) {
129
- return (v, $t) => !v || DateTime.fromISO(v) > DateTime.fromISO(dateCompare) || (message || $t('components.thedateShouldBeSameOrAfter', {date: DateTime.fromISO(dateCompare).toFormat('yyyy-MM-dd')}));
129
+ return (v, $t = (s) => s) => !v || DateTime.fromISO(v) > DateTime.fromISO(dateCompare) || (message || $t('components.thedateShouldBeSameOrAfter', {date: DateTime.fromISO(dateCompare).toFormat('yyyy-MM-dd')}));
130
130
  }
131
131
 
132
132
  export function hoursValidation (message) {
133
- return (v, $t) => !v || parseHours(v) !== false || (message || $t('components.invalidTimeValueShouldBeInFormat'));
133
+ return (v, $t = (s) => s) => !v || parseHours(v) !== false || (message || $t('components.invalidTimeValueShouldBeInFormat'));
134
134
  }
135
135
 
136
136
 
137
137
  export function dateBeforeValidation (dateCompare, message) {
138
- return (v, $t) => {
138
+ return (v, $t = (s) => s) => {
139
139
  if (!v || !dateCompare || typeof dateCompare !== 'string') {
140
140
  return true;
141
141
  }
@@ -147,7 +147,7 @@ export function dateBeforeValidation (dateCompare, message) {
147
147
  }
148
148
 
149
149
  export function dateAfterValidation (dateCompare, message) {
150
- return (v, $t) => {
150
+ return (v, $t = (s) => s) => {
151
151
  if (!v || !dateCompare || typeof dateCompare !== 'string') {
152
152
  return true;
153
153
  }
@@ -159,7 +159,7 @@ export function dateAfterValidation (dateCompare, message) {
159
159
  }
160
160
 
161
161
  export function dateSameOrAfterValidation (dateCompare, message) {
162
- return (v, $t) => {
162
+ return (v, $t = (s) => s) => {
163
163
  if (!v || !dateCompare || typeof dateCompare !== 'string') {
164
164
  return true;
165
165
  }
@@ -171,7 +171,7 @@ export function dateSameOrAfterValidation (dateCompare, message) {
171
171
  }
172
172
 
173
173
  export function dateSameOrBeforeValidation (dateCompare, message) {
174
- return (v, $t) => {
174
+ return (v, $t = (s) => s) => {
175
175
  if (!v || !dateCompare || typeof dateCompare !== 'string') {
176
176
  return true;
177
177
  }