@farm-investimentos/front-mfe-components 11.6.2 → 11.7.1
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 +806 -643
- 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 +806 -643
- 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 +1 -1
- package/src/components/DatePicker/DatePicker.stories.js +7 -12
- package/src/components/DatePicker/DatePicker.vue +9 -17
- package/src/components/FilePicker/FilePicker.vue +10 -15
- package/src/components/FilePicker/__tests__/FilePicker.spec.js +12 -4
- package/src/components/Form/Form.stories.js +53 -47
- package/src/components/MainFilter/MainFilter.scss +1 -1
- package/src/components/MainFilter/MainFilter.vue +14 -8
- package/src/components/MainFilter/__tests__/MainFilter.spec.js +4 -0
- package/src/components/RangeDatePicker/RangeDatePicker.stories.js +23 -25
- package/src/components/RangeDatePicker/RangeDatePicker.vue +6 -14
- package/src/components/ResourceMetaInfo/ResourceMetaInfo.scss +14 -0
- package/src/components/ResourceMetaInfo/ResourceMetaInfo.stories.js +119 -0
- package/src/components/ResourceMetaInfo/ResourceMetaInfo.vue +100 -0
- package/src/components/ResourceMetaInfo/__tests__/ResourceMetaInfo.spec.js +128 -0
- package/src/components/ResourceMetaInfo/index.ts +4 -0
- package/src/components/Tabs/Tabs.stories.js +11 -0
- package/src/components/TextFieldV2/TextFieldV2.scss +14 -2
- package/src/components/TextFieldV2/TextFieldV2.stories.js +1 -0
- package/src/components/TextFieldV2/TextFieldV2.vue +7 -4
- package/src/components/Typography/BodyText/BodyText.stories.js +2 -2
- package/src/components/Typography/Caption/Caption.stories.js +2 -1
- package/src/components/Typography/Heading/Heading.stories.js +2 -1
- package/src/components/Typography/OverlayText/OverlayText.stories.js +2 -1
- package/src/components/Typography/Subtitle/Subtitle.stories.js +2 -3
- package/src/components/layout/Basic.stories.js +21 -0
- package/src/components/layout/Container/Container.scss +1 -0
- package/src/main.ts +2 -1
package/package.json
CHANGED
|
@@ -16,42 +16,37 @@ export default {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const Primary = () => ({
|
|
19
|
-
components: { DatePicker },
|
|
20
19
|
data() {
|
|
21
20
|
return {
|
|
22
|
-
|
|
21
|
+
date: '',
|
|
23
22
|
};
|
|
24
23
|
},
|
|
25
24
|
template: `<div style='max-width: 320px'>
|
|
26
|
-
<
|
|
27
|
-
{{
|
|
25
|
+
<farm-input-datepicker inputId="input-custom-id-0" v-model="date" />
|
|
26
|
+
{{ date }}
|
|
28
27
|
</div>`,
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
export const InitValue = () => ({
|
|
32
|
-
|
|
33
|
-
template: `<div style='max-width: 320px'><DatePicker inputId="input-custom-id-1" value="2021-08-01" /></div>`,
|
|
31
|
+
template: `<div style='max-width: 320px'><farm-input-datepicker inputId="input-custom-id-1" value="2021-08-01" /></div>`,
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
export const MinMaxDates = () => ({
|
|
37
|
-
components: { DatePicker },
|
|
38
35
|
template: `<div style='max-width: 320px'>
|
|
39
|
-
<
|
|
36
|
+
<farm-input-datepicker inputId="input-custom-id-2" max="2021-12-02" min="2021-07-01" />
|
|
40
37
|
max="2021-12-02" min="2021-07-01"
|
|
41
38
|
</div>`,
|
|
42
39
|
});
|
|
43
40
|
|
|
44
41
|
export const RequiredDates = () => ({
|
|
45
|
-
components: { DatePicker },
|
|
46
42
|
template: `<div style='max-width: 320px'>
|
|
47
|
-
<
|
|
43
|
+
<farm-input-datepicker inputId="input-custom-id-3" :required="true" />
|
|
48
44
|
</div>`,
|
|
49
45
|
});
|
|
50
46
|
|
|
51
47
|
export const ReadonlyFalse = () => ({
|
|
52
|
-
components: { DatePicker },
|
|
53
48
|
template: `<div style='max-width: 320px'>
|
|
54
|
-
<
|
|
49
|
+
<farm-input-datepicker :readonly="false" inputId="input-custom-id-3"/>
|
|
55
50
|
</div>`,
|
|
56
51
|
});
|
|
57
52
|
|
|
@@ -8,22 +8,18 @@
|
|
|
8
8
|
offset-y
|
|
9
9
|
min-width="290px"
|
|
10
10
|
>
|
|
11
|
-
<template v-slot:activator="{
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
v-mask="`${readonly ? '' : '##/##/####'}`"
|
|
16
|
-
@keyup="keyUpInput"
|
|
11
|
+
<template v-slot:activator="{}">
|
|
12
|
+
<farm-textfield-v2
|
|
13
|
+
icon="calendar"
|
|
14
|
+
v-model="fieldRange"
|
|
17
15
|
:readonly="readonly"
|
|
16
|
+
:mask="`${readonly ? '' : '##/##/####'}`"
|
|
18
17
|
autocomplete="off"
|
|
19
|
-
outlined
|
|
20
|
-
dense
|
|
21
|
-
v-on="on"
|
|
22
|
-
v-model="fieldRange"
|
|
23
18
|
:id="inputId"
|
|
24
19
|
:rules="[checkMax, checkMin, checkRequire]"
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
@keyup="keyUpInput"
|
|
21
|
+
@click="menuField = true"
|
|
22
|
+
/>
|
|
27
23
|
</template>
|
|
28
24
|
<v-date-picker
|
|
29
25
|
v-if="menuField"
|
|
@@ -45,12 +41,10 @@
|
|
|
45
41
|
</v-date-picker>
|
|
46
42
|
</v-menu>
|
|
47
43
|
</template>
|
|
48
|
-
<script>
|
|
44
|
+
<script lang="ts">
|
|
49
45
|
import Vue from 'vue';
|
|
50
|
-
import { VTextField } from 'vuetify/lib/components/VTextField';
|
|
51
46
|
import { VMenu } from 'vuetify/lib/components/VMenu';
|
|
52
47
|
import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
|
|
53
|
-
import DefaultButton from '../Buttons/DefaultButton';
|
|
54
48
|
import { defaultFormat as dateDefaultFormatter, convertDate } from '../../helpers/date';
|
|
55
49
|
/**
|
|
56
50
|
* Componente de input com datepicker para data
|
|
@@ -58,10 +52,8 @@ import { defaultFormat as dateDefaultFormatter, convertDate } from '../../helper
|
|
|
58
52
|
export default Vue.extend({
|
|
59
53
|
name: 'farm-input-datepicker',
|
|
60
54
|
components: {
|
|
61
|
-
VTextField,
|
|
62
55
|
VMenu,
|
|
63
56
|
VDatePicker,
|
|
64
|
-
'farm-btn': DefaultButton,
|
|
65
57
|
},
|
|
66
58
|
props: {
|
|
67
59
|
/**
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<input
|
|
4
4
|
type="file"
|
|
5
5
|
name="file"
|
|
6
|
-
@change="fileChange($event.target.files)"
|
|
7
6
|
:accept="acceptedFileTypes"
|
|
7
|
+
@change="fileChange($event.target.files)"
|
|
8
8
|
/>
|
|
9
9
|
<div v-if="!selectedFile" class="selectfile-container">
|
|
10
|
-
<farm-icon>cloud-upload</farm-icon>
|
|
10
|
+
<farm-icon @click="triggerClick">cloud-upload</farm-icon>
|
|
11
11
|
<p>Clique para selecionar ou arraste o arquivo aqui</p>
|
|
12
12
|
</div>
|
|
13
13
|
<div v-if="selectedFile || maxSizeReach" class="reset-container">
|
|
@@ -19,12 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
<p v-if="maxSizeReach" v-html="maxSizeReachMsg"></p>
|
|
21
21
|
|
|
22
|
-
<farm-btn
|
|
23
|
-
outlined
|
|
24
|
-
class="farm-btn--responsive"
|
|
25
|
-
title="Escolher outro"
|
|
26
|
-
@click="reset"
|
|
27
|
-
>
|
|
22
|
+
<farm-btn outlined class="farm-btn--responsive" title="Escolher outro" @click="reset">
|
|
28
23
|
Escolher outro
|
|
29
24
|
</farm-btn>
|
|
30
25
|
</div>
|
|
@@ -32,8 +27,6 @@
|
|
|
32
27
|
</template>
|
|
33
28
|
<script lang="ts">
|
|
34
29
|
import Vue from 'vue';
|
|
35
|
-
import DefaultButton from '../Buttons/DefaultButton';
|
|
36
|
-
import Icon from '../Icon';
|
|
37
30
|
|
|
38
31
|
export default Vue.extend({
|
|
39
32
|
name: 'farm-filepicker',
|
|
@@ -63,6 +56,9 @@ export default Vue.extend({
|
|
|
63
56
|
maxSizeReachMsg() {
|
|
64
57
|
return `Arquivo ultrapassou o tamanho máximo de ${this.maxFileSize}MB`;
|
|
65
58
|
},
|
|
59
|
+
inputEl() {
|
|
60
|
+
return this.$refs.container.querySelector('input');
|
|
61
|
+
}
|
|
66
62
|
},
|
|
67
63
|
mounted() {
|
|
68
64
|
this.dropArea = this.$refs.container;
|
|
@@ -70,7 +66,7 @@ export default Vue.extend({
|
|
|
70
66
|
},
|
|
71
67
|
methods: {
|
|
72
68
|
reset() {
|
|
73
|
-
this
|
|
69
|
+
this.inputEl.value = '';
|
|
74
70
|
this.$emit('onReset');
|
|
75
71
|
this.maxSizeReach = false;
|
|
76
72
|
this.selectedFile = null;
|
|
@@ -102,10 +98,9 @@ export default Vue.extend({
|
|
|
102
98
|
this.dropArea.addEventListener('dragover', this.handlerFunctionHighlight, false);
|
|
103
99
|
this.dropArea.addEventListener('drop', this.handlerFunctionUnhighlight, false);
|
|
104
100
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'farm-icon': Icon,
|
|
101
|
+
triggerClick() {
|
|
102
|
+
this.inputEl.click();
|
|
103
|
+
}
|
|
109
104
|
},
|
|
110
105
|
});
|
|
111
106
|
</script>
|
|
@@ -3,9 +3,11 @@ import FilePicker from '../FilePicker';
|
|
|
3
3
|
|
|
4
4
|
describe('FilePicker component', () => {
|
|
5
5
|
let wrapper;
|
|
6
|
+
let component;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
wrapper = shallowMount(FilePicker);
|
|
10
|
+
component = wrapper.vm;
|
|
9
11
|
});
|
|
10
12
|
|
|
11
13
|
test('Created hook', () => {
|
|
@@ -15,12 +17,12 @@ describe('FilePicker component', () => {
|
|
|
15
17
|
describe('Component methods', () => {
|
|
16
18
|
describe('fileChange', () => {
|
|
17
19
|
it('Should emit event with a file', () => {
|
|
18
|
-
|
|
20
|
+
component.fileChange([1]);
|
|
19
21
|
expect(wrapper.emitted().onFileChange[0]).toBeDefined();
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
it('Should not emit', () => {
|
|
23
|
-
|
|
25
|
+
component.fileChange([]);
|
|
24
26
|
expect(wrapper.emitted().onFileChange).toBeUndefined();
|
|
25
27
|
});
|
|
26
28
|
|
|
@@ -28,7 +30,7 @@ describe('FilePicker component', () => {
|
|
|
28
30
|
await wrapper.setProps({
|
|
29
31
|
maxFileSize: 5,
|
|
30
32
|
});
|
|
31
|
-
|
|
33
|
+
component.fileChange([{ size: 6 * 1024 * 1024 }]);
|
|
32
34
|
expect(wrapper.vm.maxSizeReach).toBeTruthy();
|
|
33
35
|
});
|
|
34
36
|
});
|
|
@@ -36,7 +38,7 @@ describe('FilePicker component', () => {
|
|
|
36
38
|
describe('handlerFunctionHighlight', () => {
|
|
37
39
|
it('Should add class', () => {
|
|
38
40
|
const spyObj = jest.spyOn(wrapper.vm.dropArea.classList, 'add');
|
|
39
|
-
|
|
41
|
+
component.handlerFunctionHighlight();
|
|
40
42
|
expect(spyObj).toHaveBeenCalled();
|
|
41
43
|
});
|
|
42
44
|
});
|
|
@@ -65,5 +67,11 @@ describe('FilePicker component', () => {
|
|
|
65
67
|
});
|
|
66
68
|
expect(wrapper.vm.maxSizeReachMsg).toContain('Arquivo ultrapassou o tamanho máximo');
|
|
67
69
|
});
|
|
70
|
+
|
|
71
|
+
it('Should have input element', () => {
|
|
72
|
+
expect(component.inputEl).toBeDefined();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
68
76
|
});
|
|
69
77
|
});
|
|
@@ -35,6 +35,7 @@ export const Primary = () => ({
|
|
|
35
35
|
checkbox: true,
|
|
36
36
|
birthDate: new Date('1980/09/20').toISOString(),
|
|
37
37
|
selectId: 1,
|
|
38
|
+
rangeDate: [],
|
|
38
39
|
},
|
|
39
40
|
validForm: false,
|
|
40
41
|
rules: {
|
|
@@ -65,7 +66,7 @@ export const Primary = () => ({
|
|
|
65
66
|
<v-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
|
|
66
67
|
|
|
67
68
|
<farm-label :required="true">Birthdate:</farm-label>
|
|
68
|
-
<
|
|
69
|
+
<farm-input-datepicker
|
|
69
70
|
ref="birthDate"
|
|
70
71
|
inputId="form-pf-birthDate"
|
|
71
72
|
class="mt-4"
|
|
@@ -73,12 +74,22 @@ export const Primary = () => ({
|
|
|
73
74
|
:readonly="true"
|
|
74
75
|
:required="true"
|
|
75
76
|
/>
|
|
77
|
+
|
|
78
|
+
<farm-label :required="true">Range date:</farm-label>
|
|
79
|
+
<farm-input-rangedatepicker
|
|
80
|
+
ref="rangeDate"
|
|
81
|
+
inputId="form-pf-rangeDate"
|
|
82
|
+
class="mt-4"
|
|
83
|
+
v-model="form.rangeDate"
|
|
84
|
+
:required="true"
|
|
85
|
+
/>
|
|
76
86
|
|
|
77
87
|
|
|
78
88
|
<div class="footer" :style="[styles.footer]">
|
|
79
|
-
<farm-btn
|
|
80
|
-
<farm-btn
|
|
89
|
+
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
90
|
+
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
81
91
|
</div>
|
|
92
|
+
form: {{ form }}
|
|
82
93
|
</farm-form>
|
|
83
94
|
`,
|
|
84
95
|
});
|
|
@@ -196,51 +207,9 @@ export const RadioGroupReset = () => ({
|
|
|
196
207
|
`,
|
|
197
208
|
});
|
|
198
209
|
|
|
199
|
-
export const DatePickers = () => ({
|
|
200
|
-
data() {
|
|
201
|
-
return {
|
|
202
|
-
birthDate: '',
|
|
203
|
-
rangeDate: [],
|
|
204
|
-
validForm: false,
|
|
205
|
-
styles,
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
template: `
|
|
209
|
-
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
210
|
-
|
|
211
|
-
<farm-label :required="true">Birthdate: {{ birthDate }}</farm-label>
|
|
212
|
-
<DatePicker
|
|
213
|
-
ref="birthDate"
|
|
214
|
-
inputId="form-pf-birthDate"
|
|
215
|
-
class="mt-4"
|
|
216
|
-
v-model="birthDate"
|
|
217
|
-
:readonly="true"
|
|
218
|
-
:required="true"
|
|
219
|
-
/>
|
|
220
|
-
|
|
221
|
-
<farm-label :required="true">Range: {{ rangeDate }}</farm-label>
|
|
222
|
-
<RangeDatePicker
|
|
223
|
-
ref="rangeDate"
|
|
224
|
-
inputId="form-pf-rangeDate"
|
|
225
|
-
class="mt-4"
|
|
226
|
-
v-model="rangeDate"
|
|
227
|
-
:readonly="true"
|
|
228
|
-
:required="true"
|
|
229
|
-
/>
|
|
230
|
-
|
|
231
|
-
<div class="footer" :style="[styles.footer]">
|
|
232
|
-
<farm-btn color="secondary" outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
233
|
-
<farm-btn color="secondary" :disabled="!validForm">Salvar</farm-btn>
|
|
234
|
-
</div>
|
|
235
|
-
</farm-form>
|
|
236
|
-
`,
|
|
237
|
-
});
|
|
238
|
-
|
|
239
210
|
export const Grid = () => ({
|
|
240
211
|
data() {
|
|
241
|
-
return {
|
|
242
|
-
|
|
243
|
-
};
|
|
212
|
+
return {};
|
|
244
213
|
},
|
|
245
214
|
template: `
|
|
246
215
|
<farm-container>
|
|
@@ -257,7 +226,7 @@ export const Grid = () => ({
|
|
|
257
226
|
</farm-col>
|
|
258
227
|
<farm-col cols="12" md="3">
|
|
259
228
|
<farm-label>Label 3</farm-label>
|
|
260
|
-
<farm-textfield hint="some hint text" persistent-hint="true" />
|
|
229
|
+
<farm-textfield hint="some hint text" :persistent-hint="true" />
|
|
261
230
|
</farm-col>
|
|
262
231
|
<farm-col cols="12" md="3">
|
|
263
232
|
<farm-label>Label 4</farm-label>
|
|
@@ -290,4 +259,41 @@ export const Grid = () => ({
|
|
|
290
259
|
</farm-form>
|
|
291
260
|
</farm-container>
|
|
292
261
|
`,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
export const MigrateTextVieldV2 = () => ({
|
|
265
|
+
data() {
|
|
266
|
+
return {
|
|
267
|
+
form: {
|
|
268
|
+
document: 'Document',
|
|
269
|
+
name: 'Name',
|
|
270
|
+
},
|
|
271
|
+
validForm: false,
|
|
272
|
+
rules: {
|
|
273
|
+
required: value => !!value || 'Campo obrigatório',
|
|
274
|
+
},
|
|
275
|
+
items: [
|
|
276
|
+
{ value: null, text: '' },
|
|
277
|
+
{ value: 1, text: 'label 1' },
|
|
278
|
+
{ value: 2, text: 'label 2' },
|
|
279
|
+
],
|
|
280
|
+
styles,
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
template: `
|
|
284
|
+
<farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
|
|
285
|
+
<div>
|
|
286
|
+
<farm-label :required="true">Documento</farm-label>
|
|
287
|
+
<farm-textfield-v2 v-model="form.document" :rules="[rules.required]" />
|
|
288
|
+
</div>
|
|
289
|
+
<farm-label :required="true">Nome</farm-label>
|
|
290
|
+
<farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
|
|
291
|
+
|
|
292
|
+
<div class="footer" :style="[styles.footer]">
|
|
293
|
+
<farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
|
|
294
|
+
<farm-btn :disabled="!validForm">Salvar</farm-btn>
|
|
295
|
+
</div>
|
|
296
|
+
form: {{ form }}
|
|
297
|
+
</farm-form>
|
|
298
|
+
`,
|
|
293
299
|
});
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
</farm-tooltip>
|
|
14
14
|
</farm-label>
|
|
15
|
-
<farm-textfield v-model="inputValue" :id="elementId" @keyup="onKeyUp" />
|
|
15
|
+
<farm-textfield-v2 v-model="inputValue" :id="elementId" @keyup="onKeyUp" />
|
|
16
16
|
</fieldset>
|
|
17
17
|
<farm-btn
|
|
18
18
|
v-if="hasExtraFilters"
|
|
@@ -64,6 +64,9 @@ export default Vue.extend({
|
|
|
64
64
|
type: String,
|
|
65
65
|
default: '',
|
|
66
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* Toggle filters
|
|
69
|
+
*/
|
|
67
70
|
showFilters: {
|
|
68
71
|
type: Boolean,
|
|
69
72
|
default: false,
|
|
@@ -100,18 +103,20 @@ export default Vue.extend({
|
|
|
100
103
|
onFilterClick() {
|
|
101
104
|
this.$emit('onClick');
|
|
102
105
|
},
|
|
106
|
+
isInvalidKey(keyCode: Number) {
|
|
107
|
+
return (
|
|
108
|
+
(keyCode < 48 && keyCode !== 8 && keyCode !== 46) ||
|
|
109
|
+
(keyCode > 90 && keyCode < 96 && keyCode !== 91) ||
|
|
110
|
+
(keyCode > 105 && keyCode < 186)
|
|
111
|
+
);
|
|
112
|
+
},
|
|
103
113
|
onKeyUp(event: KeyboardEvent) {
|
|
104
114
|
const keyCode = event.keyCode;
|
|
105
115
|
if (keyCode === 13) {
|
|
106
116
|
this.$emit('onEnter', (event.target as HTMLInputElement).value);
|
|
107
117
|
return false;
|
|
108
118
|
}
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
(keyCode < 48 && keyCode !== 8 && keyCode !== 46) ||
|
|
112
|
-
(keyCode > 90 && keyCode < 96 && keyCode !== 91) ||
|
|
113
|
-
(keyCode > 105 && keyCode < 186)
|
|
114
|
-
) {
|
|
119
|
+
if (this.isInvalidKey(keyCode)) {
|
|
115
120
|
return false;
|
|
116
121
|
}
|
|
117
122
|
if (this.timer) {
|
|
@@ -119,7 +124,8 @@ export default Vue.extend({
|
|
|
119
124
|
this.timer = null;
|
|
120
125
|
}
|
|
121
126
|
this.timer = setTimeout(() => {
|
|
122
|
-
this
|
|
127
|
+
console.log(this.inputValue);
|
|
128
|
+
this.$emit('onInputChange', this.inputValue);
|
|
123
129
|
}, 750);
|
|
124
130
|
},
|
|
125
131
|
},
|
|
@@ -19,6 +19,10 @@ describe('MainFilter component', () => {
|
|
|
19
19
|
component.onFilterClick();
|
|
20
20
|
expect(wrapper.emitted().onClick).toBeTruthy();
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
it('Should check if keyCode is valid', () => {
|
|
24
|
+
expect(component.isInvalidKey(120)).toBeTruthy();
|
|
25
|
+
});
|
|
22
26
|
});
|
|
23
27
|
|
|
24
28
|
describe('computed properties', () => {
|
|
@@ -5,40 +5,38 @@ export default {
|
|
|
5
5
|
title: 'Form/RangeDatePicker',
|
|
6
6
|
component: RangeDatePicker,
|
|
7
7
|
decorators: [withDesign],
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: `Range I put Date Picker<br />
|
|
12
|
+
selector: <em>farm-input-rangedatepicker</em>
|
|
13
|
+
`,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
viewMode: 'docs',
|
|
17
|
+
},
|
|
18
|
+
design: {
|
|
19
|
+
type: 'figma',
|
|
20
|
+
url: 'https://www.figma.com/file/1f84J4m1IBghWhozQvdyyt/%E2%9C%8D---Design-System?node-id=1503%3A810',
|
|
21
|
+
},
|
|
8
22
|
};
|
|
9
23
|
|
|
10
24
|
export const Primary = () => ({
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
data() {
|
|
26
|
+
return {
|
|
27
|
+
date: [],
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
template: `<div style='max-width: 320px'>
|
|
31
|
+
<RangeDatePicker inputId="input-custom-id" v-model="date" />
|
|
32
|
+
date: {{ date }}
|
|
33
|
+
</div>`,
|
|
13
34
|
});
|
|
14
35
|
|
|
15
36
|
export const Secondary = () => ({
|
|
16
|
-
components: { RangeDatePicker },
|
|
17
37
|
template: `<RangeDatePicker inputId="input-custom-id" :value="['2021-08-01', '2021-08-05']" />`,
|
|
18
38
|
});
|
|
19
39
|
|
|
20
40
|
export const MinMax = () => ({
|
|
21
|
-
components: { RangeDatePicker },
|
|
22
41
|
template: `<RangeDatePicker inputId="input-custom-id" min="2022-01-17" max="2022-02-15" />`,
|
|
23
42
|
});
|
|
24
|
-
|
|
25
|
-
const parameters = {
|
|
26
|
-
design: {
|
|
27
|
-
type: 'figma',
|
|
28
|
-
url:
|
|
29
|
-
'https://www.figma.com/file/1f84J4m1IBghWhozQvdyyt/%E2%9C%8D---Design-System?node-id=1503%3A810',
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
Primary.story = {
|
|
34
|
-
name: 'Básico',
|
|
35
|
-
parameters
|
|
36
|
-
};
|
|
37
|
-
Secondary.story = {
|
|
38
|
-
name: 'Data Inicial',
|
|
39
|
-
parameters
|
|
40
|
-
};
|
|
41
|
-
MinMax.story = {
|
|
42
|
-
name: 'Data Mínima e Máxima',
|
|
43
|
-
parameters
|
|
44
|
-
};
|
|
@@ -9,18 +9,15 @@
|
|
|
9
9
|
offset-y
|
|
10
10
|
min-width="290px"
|
|
11
11
|
>
|
|
12
|
-
<template v-slot:activator="{
|
|
13
|
-
<
|
|
14
|
-
color="secondary"
|
|
12
|
+
<template v-slot:activator="{}">
|
|
13
|
+
<farm-textfield-v2
|
|
15
14
|
v-model="fieldRange"
|
|
16
|
-
|
|
15
|
+
icon="calendar"
|
|
17
16
|
readonly
|
|
18
|
-
v-on="on"
|
|
19
|
-
outlined
|
|
20
|
-
dense
|
|
21
17
|
:id="inputId"
|
|
22
18
|
:rules="required ? [requiredRule] : []"
|
|
23
|
-
|
|
19
|
+
@click="menuField = true"
|
|
20
|
+
/>
|
|
24
21
|
</template>
|
|
25
22
|
<v-date-picker
|
|
26
23
|
v-if="menuField"
|
|
@@ -45,7 +42,6 @@
|
|
|
45
42
|
</template>
|
|
46
43
|
<script>
|
|
47
44
|
import Vue from 'vue';
|
|
48
|
-
import { VTextField } from 'vuetify/lib/components/VTextField';
|
|
49
45
|
import { VMenu } from 'vuetify/lib/components/VMenu';
|
|
50
46
|
import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
|
|
51
47
|
import DefaultButton from '../Buttons/DefaultButton';
|
|
@@ -56,7 +52,6 @@ import { defaultFormat as dateDefaultFormatter } from '../../helpers/date';
|
|
|
56
52
|
export default Vue.extend({
|
|
57
53
|
name: 'farm-input-rangedatepicker',
|
|
58
54
|
components: {
|
|
59
|
-
VTextField,
|
|
60
55
|
VMenu,
|
|
61
56
|
VDatePicker,
|
|
62
57
|
'farm-btn': DefaultButton,
|
|
@@ -150,10 +145,7 @@ export default Vue.extend({
|
|
|
150
145
|
},
|
|
151
146
|
},
|
|
152
147
|
canConfirm() {
|
|
153
|
-
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
return false;
|
|
148
|
+
return !this.dateField || this.dateField.length == 1;
|
|
157
149
|
},
|
|
158
150
|
},
|
|
159
151
|
});
|