@itfin/components 1.2.114 → 1.2.116
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 +2 -2
- package/src/assets/scss/components/_button.scss +18 -0
- package/src/components/checkbox/Radio.vue +5 -3
- package/src/components/filter/Rule.vue +107 -0
- package/src/components/filter/RuleGroup.vue +195 -0
- package/src/components/filter/index.stories.js +69 -0
- package/src/helpers/validators.js +32 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itfin/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.116",
|
|
4
4
|
"author": "Vitalii Savchuk <esvit666@gmail.com>",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"luxon": "^3.3.0",
|
|
35
35
|
"pdfjs-dist": "^2.10.377",
|
|
36
36
|
"tippy.js": "^6.3.2",
|
|
37
|
-
"vue": "^2.6.12",
|
|
38
37
|
"vue-imask": "^6.6.3",
|
|
39
38
|
"vue-property-decorator": "^9.1.2",
|
|
40
39
|
"vue-swatches": "^2.1.1",
|
|
41
40
|
"vue-virtual-scroller": "^1.1.2"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
43
|
+
"vue": "^2.6.12",
|
|
44
44
|
"@babel/eslint-parser": "^7.19.1",
|
|
45
45
|
"@babel/plugin-proposal-numeric-separator": "^7.18.6",
|
|
46
46
|
"@babel/plugin-syntax-numeric-separator": "^7.10.4",
|
|
@@ -61,6 +61,24 @@
|
|
|
61
61
|
cursor: pointer;
|
|
62
62
|
transition: background-color 0.16s linear 0s;
|
|
63
63
|
|
|
64
|
+
&:focus {
|
|
65
|
+
-webkit-mask-image: none!important;
|
|
66
|
+
}
|
|
67
|
+
&:focus:after {
|
|
68
|
+
-webkit-mask-image: paint(squircle);
|
|
69
|
+
--squircle-smooth: 0.6;
|
|
70
|
+
--squircle-radius: 10px;
|
|
71
|
+
--squircle-outline: 3px;
|
|
72
|
+
--squircle-corners: top-left top-right bottom-left bottom-right;
|
|
73
|
+
content: '';
|
|
74
|
+
background: rgb(103, 146, 244);
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: -3px;
|
|
77
|
+
left: -3px;
|
|
78
|
+
right: -3px;
|
|
79
|
+
bottom: -3px;
|
|
80
|
+
outline: none;
|
|
81
|
+
}
|
|
64
82
|
&.itf-button__block {
|
|
65
83
|
display: block;
|
|
66
84
|
width: 100%;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="itf-radio form-check" :class="{ 'itf-radio__large': large, 'itf-radio__medium': medium }">
|
|
3
3
|
<input class="form-check-input" :id="id" type="radio" :name="radioName" v-model="isChecked" :value="true" :disabled="disabled" />
|
|
4
|
-
<label :for="id"
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
<label :for="id" class="form-check-label">
|
|
5
|
+
<slot name="label">
|
|
6
|
+
{{label}}
|
|
7
|
+
<slot name="icon"></slot>
|
|
8
|
+
</slot>
|
|
7
9
|
</label>
|
|
8
10
|
</div>
|
|
9
11
|
</template>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="form-group and-or-rule row">
|
|
3
|
+
<div class="col-3">
|
|
4
|
+
<select class="form-control input-sm" v-model="key">
|
|
5
|
+
<option v-for="option in options.keys" :value="option.id">
|
|
6
|
+
{{option.name}}
|
|
7
|
+
</option>
|
|
8
|
+
</select>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="col-3">
|
|
12
|
+
<select class="form-control input-sm" v-model="operator">
|
|
13
|
+
<option v-for="option in options.operators" :value="option.id">
|
|
14
|
+
{{option.name}}
|
|
15
|
+
</option>
|
|
16
|
+
</select>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div class="col-3">
|
|
20
|
+
<input type="text" class="form-control input-sm" v-model="value" placeholder="">
|
|
21
|
+
</div>
|
|
22
|
+
<div class="col-3">
|
|
23
|
+
<itf-button small @click.prevent="deleteSelf()">
|
|
24
|
+
<itf-icon name="close" />
|
|
25
|
+
</itf-button>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
<style>
|
|
30
|
+
.and-or-rule {
|
|
31
|
+
position: relative;
|
|
32
|
+
margin-left: 15px !important;
|
|
33
|
+
padding-left: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.and-or-rule:before,
|
|
37
|
+
.and-or-rule:after {
|
|
38
|
+
content: '';
|
|
39
|
+
position: absolute;
|
|
40
|
+
left: -1px;
|
|
41
|
+
width: 16px;
|
|
42
|
+
height: calc(50% + 15px);
|
|
43
|
+
border-color: #c0c5e2;
|
|
44
|
+
border-style: solid;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.and-or-rule:before {
|
|
48
|
+
top: -15px;
|
|
49
|
+
border-width: 0 0 2px 2px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.and-or-rule:after {
|
|
53
|
+
top: 50%;
|
|
54
|
+
border-width: 0 0 0 2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.and-or-rule:last-child:after {
|
|
58
|
+
border: none;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
61
|
+
<script>
|
|
62
|
+
import { Component, Prop, Watch, Vue } from "vue-property-decorator";
|
|
63
|
+
import itfButton from '../button/Button.vue';
|
|
64
|
+
import itfIcon from '../icon/Icon.vue';
|
|
65
|
+
|
|
66
|
+
export default @Component({
|
|
67
|
+
name: 'itfRule',
|
|
68
|
+
components: { itfButton, itfIcon }
|
|
69
|
+
})
|
|
70
|
+
class itfRule extends Vue {
|
|
71
|
+
@Prop() options;
|
|
72
|
+
|
|
73
|
+
key = -99;
|
|
74
|
+
|
|
75
|
+
operator = -99;
|
|
76
|
+
|
|
77
|
+
value = '';
|
|
78
|
+
|
|
79
|
+
@Watch('options.keys.options')
|
|
80
|
+
onOptionUpdated() {
|
|
81
|
+
this.key = -99;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Watch('options.conditions.options')
|
|
85
|
+
onOption2Updated() {
|
|
86
|
+
this.condition = -99;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
deleteSelf () {
|
|
90
|
+
this.$emit('delete-rule');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
queryFormStatus () {
|
|
94
|
+
return {
|
|
95
|
+
'key': this.key,
|
|
96
|
+
'operator': this.operator,
|
|
97
|
+
'value': this.value
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fillRuleStatus (data) {
|
|
102
|
+
this.key = data.key;
|
|
103
|
+
this.operator = data.operator;
|
|
104
|
+
this.value = data.value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="and-or-template col-12" :class="first ? 'and-or-first' : '' ">
|
|
3
|
+
<div class="form-group and-or-top col-12">
|
|
4
|
+
<div class="col-5" style="padding: 0">
|
|
5
|
+
<button class="btn btn-xs btn-purple-outline btn-radius"
|
|
6
|
+
:class=" isAnd ? 'btn-purple-outline-focus' : '' " @click.prevent="clickAnd">
|
|
7
|
+
And
|
|
8
|
+
</button>
|
|
9
|
+
<button class="btn btn-xs btn-purple-outline btn-radius"
|
|
10
|
+
:class=" !isAnd ? 'btn-purple-outline-focus' : '' " @click.prevent="clickOr">
|
|
11
|
+
Or
|
|
12
|
+
</button>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="col-7 btn-and-or">
|
|
16
|
+
<itf-button v-if="!first" class="btn btn-xs btn-purple pull-right" @click.prevent="deleteSelf()">
|
|
17
|
+
<i class="fa fa-fw fa-close"></i>
|
|
18
|
+
</itf-button>
|
|
19
|
+
<button class="btn btn-xs btn-purple pull-right" @click.prevent="addGroup"> + ( group ) </button>
|
|
20
|
+
<button class="btn btn-xs btn-purple add-rule pull-right" @click.prevent="addRule"> + add </button>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<rule
|
|
25
|
+
v-for="(rule, index) in rules" ref="rules"
|
|
26
|
+
:options="options" :key="rule" @delete-rule="deleteRule(index)">
|
|
27
|
+
</rule>
|
|
28
|
+
|
|
29
|
+
<itf-rule-group
|
|
30
|
+
class="and-or-offset col-11"
|
|
31
|
+
v-for="(group, index) in groups" ref="groups"
|
|
32
|
+
:options="options" :key="group" @delete-group="deleteGroup(index)">
|
|
33
|
+
</itf-rule-group>
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
<style>
|
|
38
|
+
.and-or-template {
|
|
39
|
+
padding: 8px;
|
|
40
|
+
position: relative;
|
|
41
|
+
border-radius: 3px;
|
|
42
|
+
border: 1px solid #6d77b8;
|
|
43
|
+
border-top: 3px solid #d2d6de;
|
|
44
|
+
margin-bottom: 20px;
|
|
45
|
+
/* width: 100%; */
|
|
46
|
+
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
|
|
47
|
+
border-top-color: #6d77b8;
|
|
48
|
+
background-color: rgba(255, 255, 255, 0.9);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.and-or-template:before,
|
|
52
|
+
.and-or-template:after {
|
|
53
|
+
content: '';
|
|
54
|
+
position: absolute;
|
|
55
|
+
left: -17px;
|
|
56
|
+
width: 16px;
|
|
57
|
+
height: calc(50% + 18px);
|
|
58
|
+
border-color: #c0c5e2;
|
|
59
|
+
border-style: solid;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.and-or-template:before {
|
|
63
|
+
top: -18px;
|
|
64
|
+
border-width: 0 0 2px 2px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.and-or-template:after {
|
|
68
|
+
top: 50%;
|
|
69
|
+
border-width: 0 0 0 2px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.and-or-first:before,
|
|
73
|
+
.and-or-first:after,
|
|
74
|
+
.and-or-template:last-child:after {
|
|
75
|
+
border: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.and-or-top,
|
|
79
|
+
.btn-and-or {
|
|
80
|
+
padding: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.btn-and-or button {
|
|
84
|
+
margin-left: 4px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.and-or-offset {
|
|
88
|
+
margin-left: 30px;
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
91
|
+
<script>
|
|
92
|
+
import { Component, Prop, Watch, Vue } from 'vue-property-decorator';
|
|
93
|
+
import itfButton from '../button/Button.vue';
|
|
94
|
+
import Rule from './Rule'
|
|
95
|
+
|
|
96
|
+
export default @Component({
|
|
97
|
+
name: 'itfRuleGroup',
|
|
98
|
+
components: { itfButton, Rule }
|
|
99
|
+
})
|
|
100
|
+
class itfRule extends Vue {
|
|
101
|
+
@Prop({ type: Object, required: true }) options;
|
|
102
|
+
@Prop({ type: Boolean, default: false }) first;
|
|
103
|
+
|
|
104
|
+
isAnd = true;
|
|
105
|
+
groups = [];
|
|
106
|
+
rules = [];
|
|
107
|
+
|
|
108
|
+
created () {
|
|
109
|
+
this.addRule();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
clickAnd () {
|
|
113
|
+
this.isAnd = true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
clickOr () {
|
|
117
|
+
this.isAnd = false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
addRule () {
|
|
121
|
+
var id = this.generateId();
|
|
122
|
+
this.rules.push(id);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
addGroup () {
|
|
126
|
+
var id = this.generateId();
|
|
127
|
+
this.groups.push(id);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
deleteSelf () {
|
|
131
|
+
this.$emit('delete-group');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
deleteRule (index) {
|
|
135
|
+
this.rules.splice(index, 1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
deleteGroup (index) {
|
|
139
|
+
this.groups.splice(index, 1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
queryFormStatus () {
|
|
143
|
+
var query = {};
|
|
144
|
+
var rules = this.$refs.rules || {};
|
|
145
|
+
var groups = this.$refs.groups || {};
|
|
146
|
+
var i, j;
|
|
147
|
+
|
|
148
|
+
query['condition'] = this.isAnd ? 'AND' : 'OR';
|
|
149
|
+
query['rules'] = [];
|
|
150
|
+
for(i = 0; i < rules.length; i++){
|
|
151
|
+
query.rules.push(rules[i].queryFormStatus ());
|
|
152
|
+
}
|
|
153
|
+
for(j = 0; j < groups.length; j++){
|
|
154
|
+
query.rules[query.rules.length] = groups[j].queryFormStatus();
|
|
155
|
+
}
|
|
156
|
+
return query;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fillFormStatus (data) {
|
|
160
|
+
var i, len;
|
|
161
|
+
var group = this;
|
|
162
|
+
group.rules = [];
|
|
163
|
+
group.groups = [];
|
|
164
|
+
if(data){
|
|
165
|
+
group.isAnd = /and/i.test(data.condition);
|
|
166
|
+
len = data.rules.length;
|
|
167
|
+
for(i = 0; i < len; i++){
|
|
168
|
+
if(data.rules[i].condition){
|
|
169
|
+
group.groups.push(group.generateId());
|
|
170
|
+
(function (i, index) {
|
|
171
|
+
group.$nextTick(function () {
|
|
172
|
+
group.$refs.groups[index].fillFormStatus(data.rules[i]);
|
|
173
|
+
});
|
|
174
|
+
})(i, group.groups.length - 1);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
group.rules.push(group.generateId());
|
|
178
|
+
(function (i, index) {
|
|
179
|
+
group.$nextTick(function () {
|
|
180
|
+
group.$refs.rules[index].fillRuleStatus(data.rules[i]);
|
|
181
|
+
});
|
|
182
|
+
})(i, group.rules.length - 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
generateId () {
|
|
189
|
+
return 'xxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
190
|
+
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
|
191
|
+
return v.toString(16);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
</script>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { storiesOf } from '@storybook/vue';
|
|
2
|
+
import itfRule from './Rule.vue';
|
|
3
|
+
import itfRuleGroup from './RuleGroup.vue';
|
|
4
|
+
|
|
5
|
+
storiesOf('Common', module)
|
|
6
|
+
.add('Filter', () => ({
|
|
7
|
+
components: {
|
|
8
|
+
itfRule,
|
|
9
|
+
itfRuleGroup
|
|
10
|
+
},
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
options: {
|
|
14
|
+
keys: [{
|
|
15
|
+
name: 'Choose Key',
|
|
16
|
+
id: -99
|
|
17
|
+
},{
|
|
18
|
+
name: 'Crash Number',
|
|
19
|
+
id: 134
|
|
20
|
+
},{
|
|
21
|
+
name: 'Daily Startup',
|
|
22
|
+
id: 256
|
|
23
|
+
}],
|
|
24
|
+
operators: [{
|
|
25
|
+
name: 'Choose Operator',
|
|
26
|
+
id: -99
|
|
27
|
+
},{
|
|
28
|
+
name: 'equal to',
|
|
29
|
+
id: '>'
|
|
30
|
+
},{
|
|
31
|
+
name: 'not equal to',
|
|
32
|
+
id: '='
|
|
33
|
+
},{
|
|
34
|
+
name: 'less',
|
|
35
|
+
id: '<'
|
|
36
|
+
}]
|
|
37
|
+
},
|
|
38
|
+
isVisible: false,
|
|
39
|
+
isItemEdit: false,
|
|
40
|
+
from: '2021-01-16',
|
|
41
|
+
to: null,
|
|
42
|
+
dates: [],
|
|
43
|
+
customDays: {
|
|
44
|
+
'2021-10-21': { text: '🎉', class: 'test' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
submit() {
|
|
50
|
+
console.info('saved');
|
|
51
|
+
},
|
|
52
|
+
reset() {
|
|
53
|
+
this.$refs.form.resetValidation();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
template: `<div>
|
|
57
|
+
<p>You need wrap whole application with this tag</p>
|
|
58
|
+
|
|
59
|
+
<h2>Usage</h2>
|
|
60
|
+
|
|
61
|
+
<pre>
|
|
62
|
+
|
|
63
|
+
</pre>
|
|
64
|
+
|
|
65
|
+
<h2>Example</h2>
|
|
66
|
+
|
|
67
|
+
<itf-rule-group :options="options" first />
|
|
68
|
+
</div>`,
|
|
69
|
+
}));
|
|
@@ -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*(<(\/?[^>]+)>| |[^\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*(<(\/?[^>]+)>| |[^\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
|
}
|