@farm-investimentos/front-mfe-components 15.10.0 → 15.10.2
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/dist/front-mfe-components.common.js +1270 -133
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +1270 -133
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +4 -1
- package/src/components/Icon/icons_list.ts +2 -1
- package/src/components/IdCaption/IdCaption.scss +8 -4
- package/src/components/IdCaption/IdCaption.stories.js +24 -6
- package/src/components/IdCaption/IdCaption.vue +10 -3
- package/src/components/Logger/LoggerItem/LoggerItem.scss +1 -1
- package/src/components/RangeDatePicker/RangeDatePicker.stories.js +41 -0
- package/src/components/RangeDatePicker/RangeDatePicker.vue +42 -2
- package/src/components/RangeDatePicker/__tests__/RangeDatePicker.spec.js +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm-investimentos/front-mfe-components",
|
|
3
|
-
"version": "15.10.
|
|
3
|
+
"version": "15.10.2",
|
|
4
4
|
"author": "farm investimentos",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/front-mfe-components.common.js",
|
|
@@ -73,5 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=14.0.0 <15.0.0"
|
|
76
|
+
},
|
|
77
|
+
"volta": {
|
|
78
|
+
"node": "14.21.3"
|
|
76
79
|
}
|
|
77
80
|
}
|
|
@@ -61,7 +61,6 @@ export default [
|
|
|
61
61
|
'alpha',
|
|
62
62
|
'alphabetical',
|
|
63
63
|
'altimeter',
|
|
64
|
-
|
|
65
64
|
'ambulance',
|
|
66
65
|
'amplifier',
|
|
67
66
|
'anchor',
|
|
@@ -182,6 +181,7 @@ export default [
|
|
|
182
181
|
'arrow-up-drop-circle-outline',
|
|
183
182
|
'arrow-up-thick',
|
|
184
183
|
'artist',
|
|
184
|
+
'assessment',
|
|
185
185
|
'assistant',
|
|
186
186
|
'asterisk',
|
|
187
187
|
'at',
|
|
@@ -1954,6 +1954,7 @@ export default [
|
|
|
1954
1954
|
'rowing',
|
|
1955
1955
|
'rss',
|
|
1956
1956
|
'rss-box',
|
|
1957
|
+
'rule',
|
|
1957
1958
|
'ruler',
|
|
1958
1959
|
'run',
|
|
1959
1960
|
'run-fast',
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
&__body {
|
|
17
|
-
|
|
18
17
|
display: flex;
|
|
19
18
|
flex-direction: column;
|
|
20
19
|
justify-content: space-between;
|
|
@@ -26,7 +25,6 @@
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
.farm-typography {
|
|
29
|
-
|
|
30
28
|
margin-bottom: 0;
|
|
31
29
|
display: flex;
|
|
32
30
|
flex: none;
|
|
@@ -34,7 +32,7 @@
|
|
|
34
32
|
align-items: center;
|
|
35
33
|
height: 18px;
|
|
36
34
|
|
|
37
|
-
>span {
|
|
35
|
+
> span {
|
|
38
36
|
max-width: 100%;
|
|
39
37
|
@include ellipsis;
|
|
40
38
|
}
|
|
@@ -48,4 +46,10 @@
|
|
|
48
46
|
&.farm-idcaption--noheight {
|
|
49
47
|
min-height: auto;
|
|
50
48
|
}
|
|
51
|
-
|
|
49
|
+
|
|
50
|
+
.farm-idcaption--hide-copy-btn {
|
|
51
|
+
.farm-tooltip:has(.mdi-content-copy) {
|
|
52
|
+
display: none;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -23,11 +23,11 @@ export default {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const Primary = () => ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
methods: {
|
|
27
|
+
onLinkClick() {
|
|
28
|
+
alert('onLinkClick');
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
31
|
template: `
|
|
32
32
|
<farm-idcaption
|
|
33
33
|
icon="account-box-outline"
|
|
@@ -62,6 +62,24 @@ export const Linkless = () => ({
|
|
|
62
62
|
`,
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
export const CopyBtnHidden = () => ({
|
|
66
|
+
template: `
|
|
67
|
+
<farm-idcaption
|
|
68
|
+
icon="account-box-outline"
|
|
69
|
+
copyText="texto a copiar"
|
|
70
|
+
hide-copy-btn
|
|
71
|
+
>
|
|
72
|
+
<template v-slot:title>
|
|
73
|
+
Upper Line Text
|
|
74
|
+
</template>
|
|
75
|
+
<template v-slot:subtitle>
|
|
76
|
+
Lower:Line Text
|
|
77
|
+
</template>
|
|
78
|
+
</farm-idcaption>
|
|
79
|
+
|
|
80
|
+
`,
|
|
81
|
+
});
|
|
82
|
+
|
|
65
83
|
export const Iconless = () => ({
|
|
66
84
|
template: `
|
|
67
85
|
<farm-idcaption
|
|
@@ -221,4 +239,4 @@ export const NoHeight = () => ({
|
|
|
221
239
|
</template>
|
|
222
240
|
</farm-idcaption>
|
|
223
241
|
</farm-col>`,
|
|
224
|
-
});
|
|
242
|
+
});
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
<slot name="subtitle"></slot>
|
|
42
42
|
</span>
|
|
43
43
|
<farm-copytoclipboard
|
|
44
|
-
v-if="copyText"
|
|
44
|
+
v-if="copyText && !hideCopyBtn"
|
|
45
45
|
sizeIcon="16px"
|
|
46
46
|
:toCopy="copyText"
|
|
47
47
|
:successMessage="successMessage"
|
|
@@ -126,6 +126,13 @@ export default defineComponent({
|
|
|
126
126
|
type: String,
|
|
127
127
|
default: 'Conteúdo copiado para a área de trabalho',
|
|
128
128
|
},
|
|
129
|
+
/**
|
|
130
|
+
* Hides copy button
|
|
131
|
+
*/
|
|
132
|
+
hideCopyBtn: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
default: false,
|
|
135
|
+
},
|
|
129
136
|
/**
|
|
130
137
|
* Tooltip color
|
|
131
138
|
*/
|
|
@@ -154,11 +161,11 @@ export default defineComponent({
|
|
|
154
161
|
},
|
|
155
162
|
},
|
|
156
163
|
|
|
157
|
-
setup(
|
|
164
|
+
setup({ hideCopyBtn }, { slots }) {
|
|
158
165
|
const hasTitle = computed(() => slots.title);
|
|
159
166
|
const hasSubtitle = computed(() => slots.subtitle);
|
|
160
167
|
|
|
161
|
-
return { hasSubtitle, hasTitle };
|
|
168
|
+
return { hasSubtitle, hasTitle, hideCopyBtn };
|
|
162
169
|
},
|
|
163
170
|
});
|
|
164
171
|
</script>
|
|
@@ -93,3 +93,44 @@ export const disabled = () => ({
|
|
|
93
93
|
date: {{ date }}
|
|
94
94
|
</div>`,
|
|
95
95
|
});
|
|
96
|
+
|
|
97
|
+
export const ValidacaoInputPadrao = () => ({
|
|
98
|
+
data() {
|
|
99
|
+
return {
|
|
100
|
+
date: null,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
template: `<div style='max-width: 320px'>
|
|
104
|
+
<farm-label>Selecione uma data entre 01/01/2025 e 31/12/2025</farm-label>
|
|
105
|
+
<RangeDatePicker
|
|
106
|
+
inputId="input-custom-id"
|
|
107
|
+
v-model="date"
|
|
108
|
+
min="2025-01-01"
|
|
109
|
+
max="2025-12-31"
|
|
110
|
+
validateInput
|
|
111
|
+
required
|
|
112
|
+
/>
|
|
113
|
+
date: {{ date }}
|
|
114
|
+
</div>`,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const ValidacaoInputCustomizada = () => ({
|
|
118
|
+
data() {
|
|
119
|
+
return {
|
|
120
|
+
date: null,
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
template: `<div style='max-width: 320px'>
|
|
124
|
+
<farm-label>Selecione uma data do primeiro semestre de 2025</farm-label>
|
|
125
|
+
<RangeDatePicker
|
|
126
|
+
inputId="input-custom-id"
|
|
127
|
+
v-model="date"
|
|
128
|
+
min="2025-01-01"
|
|
129
|
+
max="2025-06-30"
|
|
130
|
+
validateInput
|
|
131
|
+
required
|
|
132
|
+
outOfRangeMessage="Por favor, selecione datas dentro do primeiro semestre de 2025 ({min} até {max})"
|
|
133
|
+
/>
|
|
134
|
+
date: {{ date }}
|
|
135
|
+
</div>`,
|
|
136
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<template>
|
|
1
|
+
<template>
|
|
2
2
|
<farm-contextmenu
|
|
3
3
|
stay-open
|
|
4
4
|
v-model="menuField"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
:readonly="readonly"
|
|
49
49
|
:id="inputId"
|
|
50
50
|
:mask="`${readonly ? [''] : ['##/##/####' + ' a ' + '##/##/####']}`"
|
|
51
|
-
:rules="[checkDateValid, checkRequire]"
|
|
51
|
+
:rules="[checkDateValid, checkRequire, ...(validateInput ? [checkMinMax] : [])]"
|
|
52
52
|
:disabled="disabled"
|
|
53
53
|
@keyup="keyUpInput"
|
|
54
54
|
/>
|
|
@@ -123,6 +123,20 @@ export default defineComponent({
|
|
|
123
123
|
type: Boolean,
|
|
124
124
|
default: false,
|
|
125
125
|
},
|
|
126
|
+
/**
|
|
127
|
+
* Habilita a validação de min/max no input
|
|
128
|
+
*/
|
|
129
|
+
validateInput: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false,
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Mensagem de erro customizada para data fora do período permitido
|
|
135
|
+
*/
|
|
136
|
+
outOfRangeMessage: {
|
|
137
|
+
type: String,
|
|
138
|
+
default: 'A data selecionada deve ser entre {min} e {max}',
|
|
139
|
+
},
|
|
126
140
|
},
|
|
127
141
|
data() {
|
|
128
142
|
const s = this.formatDateRange(this.value);
|
|
@@ -141,6 +155,32 @@ export default defineComponent({
|
|
|
141
155
|
}
|
|
142
156
|
return true;
|
|
143
157
|
},
|
|
158
|
+
checkMinMax: value => {
|
|
159
|
+
if (!this.validateInput || !value || value.length === 0) return true;
|
|
160
|
+
if (!this.min || !this.max) {
|
|
161
|
+
if (process.env.NODE_ENV === 'development') {
|
|
162
|
+
console.warn('[RangeDatePicker] Para usar validateInput é necessário definir as props min e max');
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const [startDateStr, endDateStr] = value.split(' a ');
|
|
168
|
+
|
|
169
|
+
const startDate = new Date(convertDate(startDateStr));
|
|
170
|
+
const endDate = new Date(convertDate(endDateStr));
|
|
171
|
+
const minDate = new Date(this.min);
|
|
172
|
+
const maxDate = new Date(this.max);
|
|
173
|
+
|
|
174
|
+
const isValid = startDate.getTime() >= minDate.getTime() && endDate.getTime() <= maxDate.getTime();
|
|
175
|
+
|
|
176
|
+
if (!isValid) {
|
|
177
|
+
return this.outOfRangeMessage
|
|
178
|
+
.replace('{min}', dateDefaultFormatter(this.min))
|
|
179
|
+
.replace('{max}', dateDefaultFormatter(this.max));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return true;
|
|
183
|
+
},
|
|
144
184
|
};
|
|
145
185
|
},
|
|
146
186
|
watch: {
|
|
@@ -104,4 +104,49 @@ describe('RangeDatePicker component', () => {
|
|
|
104
104
|
expect(component.fieldRange).toEqual('27/02/2023 a 28/02/2023');
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
|
+
|
|
108
|
+
describe('range validation', () => {
|
|
109
|
+
beforeEach(async () => {
|
|
110
|
+
await wrapper.setProps({
|
|
111
|
+
min: '2023-02-01',
|
|
112
|
+
max: '2023-02-28',
|
|
113
|
+
validateInput: true
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should return true when date range is within min and max', () => {
|
|
118
|
+
const result = component.checkMinMax('15/02/2023 a 20/02/2023');
|
|
119
|
+
expect(result).toBe(true);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should return error message when start date is before min date', () => {
|
|
123
|
+
const result = component.checkMinMax('31/01/2023 a 15/02/2023');
|
|
124
|
+
expect(result).toBe('A data selecionada deve ser entre 01/02/2023 e 28/02/2023');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should return error message when end date is after max date', () => {
|
|
128
|
+
const result = component.checkMinMax('15/02/2023 a 01/03/2023');
|
|
129
|
+
expect(result).toBe('A data selecionada deve ser entre 01/02/2023 e 28/02/2023');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should return true when validateInput is false', async () => {
|
|
133
|
+
await wrapper.setProps({ validateInput: false });
|
|
134
|
+
const result = component.checkMinMax('31/01/2023 a 01/03/2023');
|
|
135
|
+
expect(result).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should return true when value is empty', () => {
|
|
139
|
+
const result = component.checkMinMax('');
|
|
140
|
+
expect(result).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should return true when min and max are not set', async () => {
|
|
144
|
+
await wrapper.setProps({
|
|
145
|
+
min: null,
|
|
146
|
+
max: null
|
|
147
|
+
});
|
|
148
|
+
const result = component.checkMinMax('15/02/2023 a 20/02/2023');
|
|
149
|
+
expect(result).toBe(true);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
107
152
|
});
|