@itfin/components 1.2.19 → 1.2.22
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.
|
|
3
|
+
"version": "1.2.22",
|
|
4
4
|
"author": "Vitalii Savchuk <esvit666@gmail.com>",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@storybook/vue": "=6.3.8",
|
|
48
48
|
"@vue/cli-plugin-babel": "^4.5.8",
|
|
49
49
|
"@vue/cli-plugin-eslint": "^4.5.8",
|
|
50
|
-
"@vue/cli-plugin-unit-jest": "^4.5.
|
|
50
|
+
"@vue/cli-plugin-unit-jest": "^4.5.19",
|
|
51
51
|
"@vue/eslint-config-airbnb": "^5.1.0",
|
|
52
52
|
"@vue/test-utils": "^1.1.1",
|
|
53
53
|
"babel-eslint": "^10.1.0",
|
|
@@ -92,7 +92,20 @@
|
|
|
92
92
|
"not dead"
|
|
93
93
|
],
|
|
94
94
|
"jest": {
|
|
95
|
-
"preset": "@vue/cli-plugin-unit-jest"
|
|
95
|
+
"preset": "@vue/cli-plugin-unit-jest",
|
|
96
|
+
"testMatch": [
|
|
97
|
+
"**/src/**/*.spec.js"
|
|
98
|
+
],
|
|
99
|
+
"testPathIgnorePatterns": [
|
|
100
|
+
"dist/"
|
|
101
|
+
],
|
|
102
|
+
"modulePathIgnorePatterns": [
|
|
103
|
+
"dist/"
|
|
104
|
+
],
|
|
105
|
+
"collectCoverage": true,
|
|
106
|
+
"coverageReporters": [
|
|
107
|
+
"html"
|
|
108
|
+
]
|
|
96
109
|
},
|
|
97
110
|
"license": "ISC"
|
|
98
111
|
}
|
|
@@ -37,13 +37,13 @@ export default @Component({
|
|
|
37
37
|
})
|
|
38
38
|
class itfConfirmPopover extends Vue {
|
|
39
39
|
@PropSync('visible') value;
|
|
40
|
-
@Prop({ type: String, default: function() { this.$t('components.areYouSureToDeleteThis'); } }) title;
|
|
40
|
+
@Prop({ type: String, default: function() { return this.$t('components.areYouSureToDeleteThis'); } }) title;
|
|
41
41
|
@Prop({ type: String, default: '' }) message;
|
|
42
42
|
@Prop({ type: String, default: 'bottom', validator: (value) => ['bottom', 'left', 'right', 'top'].includes(value) }) placement;
|
|
43
43
|
@Prop({ type: String, default: 'click', validator: (value) => ['click', 'focus', 'hover', 'manual'].includes(value) }) trigger;
|
|
44
44
|
|
|
45
|
-
@Prop({ type: String, default: function() { this.$t('components.noKeepIt'); } }) cancelCaption;
|
|
46
|
-
@Prop({ type: String, default: function() { this.$t('components.yesDelete'); } }) confirmCaption;
|
|
45
|
+
@Prop({ type: String, default: function() { return this.$t('components.noKeepIt'); } }) cancelCaption;
|
|
46
|
+
@Prop({ type: String, default: function() { return this.$t('components.yesDelete'); } }) confirmCaption;
|
|
47
47
|
@Prop({ type: String, default: '' }) cancelClass;
|
|
48
48
|
@Prop({ type: String, default: 'text-danger' }) confirmClass;
|
|
49
49
|
|
|
@@ -58,7 +58,7 @@ export function formatRangeDates(begin, end = null) {
|
|
|
58
58
|
|
|
59
59
|
export function firstLetters(name) {
|
|
60
60
|
const [first, second] = (name || '').trim()
|
|
61
|
-
.replace(/[\u0250-\ue0070-9]/g, '')
|
|
61
|
+
.replace(/[\u0250-\u0400\u04FF-\ue0070-9]/g, '')
|
|
62
62
|
.replace(/ +/g, ' ')
|
|
63
63
|
.split(' ')
|
|
64
64
|
;
|
|
@@ -15,6 +15,10 @@ const HEX_REGEXP = /[0-9A-Fa-f]{6}/;
|
|
|
15
15
|
|
|
16
16
|
export const MEDIUM_TEXT_LENGTH = 16777215;
|
|
17
17
|
|
|
18
|
+
function isEmpty(v) {
|
|
19
|
+
return v === '' || typeof v === 'undefined' || v === null;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
export function differentValidation (value, message) {
|
|
19
23
|
return (v, $t) => !v || !(v === value) || (message || $t('components.theValueMustBeDifferent'));
|
|
20
24
|
}
|
|
@@ -48,7 +52,7 @@ export function passMatchValidation (password, message) {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export function emptyValidation (message) {
|
|
51
|
-
return (v, $t) => (v
|
|
55
|
+
return (v, $t) => !isEmpty(v) || (message || $t('components.thisFieldIsRequired'));
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
export function emptyArrayValidation (message) {
|
|
@@ -64,11 +68,11 @@ export function minMaxValidation (min = 0, max = 100, message) {
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export function minValidation (min = 0, message) {
|
|
67
|
-
return (v, $t) => !v
|
|
71
|
+
return (v, $t) => (!isEmpty(v) && (Number(v) >= min)) || (message || $t('components.theValueMustBeGreaterThanOrEqualToMin', {min}));
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
export function maxValidation (max, message) {
|
|
71
|
-
return (v, $t) => (v <= max) || (message || $t('components.mustBeLessThanMax'));
|
|
75
|
+
return (v, $t) => (!isEmpty(v) && (Number(v) <= max)) || (message || $t('components.mustBeLessThanMax'));
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
export function preventStuffingValidation (message) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {emptyValidation, minValidation, maxValidation} from './validators';
|
|
2
|
+
|
|
3
|
+
describe('Validators', () => {
|
|
4
|
+
const $t = (str) => str;
|
|
5
|
+
|
|
6
|
+
test('emptyValidation', () => {
|
|
7
|
+
expect(emptyValidation()('', $t)).toEqual('components.thisFieldIsRequired');
|
|
8
|
+
expect(emptyValidation()(null, $t)).toEqual('components.thisFieldIsRequired');
|
|
9
|
+
expect(emptyValidation()(undefined, $t)).toEqual('components.thisFieldIsRequired');
|
|
10
|
+
expect(emptyValidation()('1', $t)).toEqual(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('minValidation', () => {
|
|
14
|
+
expect(minValidation()(0, $t)).toEqual(true);
|
|
15
|
+
expect(minValidation()(null, $t)).toEqual('components.theValueMustBeGreaterThanOrEqualToMin');
|
|
16
|
+
expect(minValidation()(undefined, $t)).toEqual('components.theValueMustBeGreaterThanOrEqualToMin');
|
|
17
|
+
expect(minValidation(1)(0, $t)).toEqual('components.theValueMustBeGreaterThanOrEqualToMin');
|
|
18
|
+
expect(minValidation(1)('0', $t)).toEqual('components.theValueMustBeGreaterThanOrEqualToMin');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('maxValidation', () => {
|
|
22
|
+
expect(maxValidation(1)(0, $t)).toEqual(true);
|
|
23
|
+
expect(maxValidation()(null, $t)).toEqual('components.mustBeLessThanMax');
|
|
24
|
+
expect(maxValidation()(undefined, $t)).toEqual('components.mustBeLessThanMax');
|
|
25
|
+
expect(maxValidation(1)(0, $t)).toEqual(true);
|
|
26
|
+
expect(maxValidation(1)('0', $t)).toEqual(true);
|
|
27
|
+
});
|
|
28
|
+
});
|