@farm-investimentos/front-mfe-components-vue3 0.7.1 → 1.0.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 +164 -163
- 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 +164 -163
- 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 +2 -2
- package/src/components/Buttons/DefaultButton/DefaultButton.vue +1 -2
- package/src/components/ContextMenu/ContextMenu.scss +8 -1
- package/src/components/ContextMenu/ContextMenu.vue +8 -0
- package/src/components/DataTableHeader/DataTableHeader.scss +1 -1
- package/src/components/DataTableHeader/DataTableHeader.stories.js +8 -8
- package/src/components/DataTableHeader/DataTableHeader.vue +66 -59
- package/src/components/DataTableHeader/__tests__/{DataTableHeader.spec.js → DataTableHeader.spec.ts} +6 -5
- package/src/components/DatePicker/DatePicker.stories.js +23 -0
- package/src/components/DatePicker/DatePicker.vue +10 -1
- package/src/components/Icon/__tests__/Icon.spec.js +3 -0
- package/src/components/IconBox/IconBox.vue +18 -9
- package/src/components/IconBox/__tests__/IconBox.spec.js +20 -6
- package/src/components/ListItem/__tests__/ListItem.spec.js +24 -0
- package/src/components/Modal/Modal.vue +9 -6
- package/src/components/Modal/__tests__/{Modal.spec.js → Modal.spec.ts} +1 -0
- package/src/components/ModalPromptUser/ModalPromptUser.stories.js +0 -2
- package/src/components/ModalPromptUser/__tests__/{ModalPromptUser.spec.js → ModalPromptUser.spec.ts} +4 -1
- package/src/components/ProgressBar/ProgressBar.vue +11 -20
- package/src/components/ProgressBar/__tests__/ProgressBar.spec.ts +53 -0
- package/src/components/RangeDatePicker/RangeDatePicker.stories.js +9 -0
- package/src/components/RangeDatePicker/RangeDatePicker.vue +8 -1
- package/src/examples/Table.stories.js +177 -15
- package/src/helpers/date.ts +21 -39
- package/src/components/ListItem/ListItem.vue.bkpv2 +0 -84
- package/src/components/ProgressBar/__tests__/ProgressBar.spec.js +0 -32
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
3
|
+
import ProgressBar from '../ProgressBar.vue';
|
|
4
|
+
|
|
5
|
+
describe('ProgressBar component', () => {
|
|
6
|
+
let wrapper;
|
|
7
|
+
let component;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
wrapper = shallowMount(ProgressBar, {
|
|
11
|
+
propsData: { value: 40 },
|
|
12
|
+
});
|
|
13
|
+
component = wrapper.vm;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('Created hook', () => {
|
|
17
|
+
expect(wrapper).toBeDefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('mount component', () => {
|
|
21
|
+
it('renders correctly', () => {
|
|
22
|
+
expect(wrapper.element).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('computed properties', () => {
|
|
27
|
+
describe('classes', () => {
|
|
28
|
+
it('Should have basic values', () => {
|
|
29
|
+
expect(component.classes).toBeDefined();
|
|
30
|
+
expect(component.classes).toHaveProperty('farm-progressbar');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('Should have color and background values', async () => {
|
|
34
|
+
await wrapper.setProps({
|
|
35
|
+
backgroundColor: 'secondary',
|
|
36
|
+
valueColor: 'neutral'
|
|
37
|
+
});
|
|
38
|
+
expect(component.classes).toHaveProperty('farm-progressbar--secondary');
|
|
39
|
+
expect(component.classes).toHaveProperty('farm-progressbar--value-neutral');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('Should not have color and background values using hexa', async () => {
|
|
43
|
+
await wrapper.setProps({
|
|
44
|
+
backgroundColor: '#FF0000',
|
|
45
|
+
valueColor: '#FF0000'
|
|
46
|
+
});
|
|
47
|
+
expect(component.classes).not.toHaveProperty('farm-progressbar--#FF0000');
|
|
48
|
+
expect(component.classes).not.toHaveProperty('farm-progressbar--value-#FF0000');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -74,3 +74,12 @@ export const Reset = () => ({
|
|
|
74
74
|
</farm-btn>
|
|
75
75
|
</div>`,
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
export const Disabled = () => ({
|
|
79
|
+
data() {
|
|
80
|
+
return {
|
|
81
|
+
date: null,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
template: `<farm-input-rangedatepicker disabled inputId="input-custom-id" min="2023-09-17" max="2023-11-15" v-model="date" />`,
|
|
85
|
+
});
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
readonly
|
|
55
55
|
:id="inputId"
|
|
56
56
|
:rules="required ? [requiredRule] : []"
|
|
57
|
+
:disabled="disabled"
|
|
57
58
|
/>
|
|
58
59
|
</template>
|
|
59
60
|
</farm-contextmenu>
|
|
@@ -103,6 +104,13 @@ export default {
|
|
|
103
104
|
type: Boolean,
|
|
104
105
|
default: false,
|
|
105
106
|
},
|
|
107
|
+
/**
|
|
108
|
+
* Disabled field
|
|
109
|
+
*/
|
|
110
|
+
disabled: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: false,
|
|
113
|
+
},
|
|
106
114
|
},
|
|
107
115
|
data() {
|
|
108
116
|
const s = this.formatDateRange(this.modelValue);
|
|
@@ -138,7 +146,6 @@ export default {
|
|
|
138
146
|
return dateDefaultFormatter(dateStart) + ' a ' + dateDefaultFormatter(dateEnd);
|
|
139
147
|
},
|
|
140
148
|
save() {
|
|
141
|
-
|
|
142
149
|
this.formatDateRange(this.dateField);
|
|
143
150
|
this.inputVal = this.dateField;
|
|
144
151
|
this.menuField = false;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// import { withDesign } from 'storybook-addon-designs';
|
|
2
2
|
import { VDataTable } from 'vuetify/components/VDataTable';
|
|
3
3
|
|
|
4
|
+
import DataTableHeader from '../components/DataTableHeader/DataTableHeader.vue';
|
|
5
|
+
|
|
4
6
|
const headers = [
|
|
5
7
|
{
|
|
6
8
|
title: 'ID',
|
|
@@ -14,6 +16,12 @@ const headers = [
|
|
|
14
16
|
sortable: false,
|
|
15
17
|
key: 'name',
|
|
16
18
|
width: 160,
|
|
19
|
+
align: 'center',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Description',
|
|
23
|
+
sortable: false,
|
|
24
|
+
key: 'description',
|
|
17
25
|
align: 'end',
|
|
18
26
|
},
|
|
19
27
|
];
|
|
@@ -186,39 +194,193 @@ export const TableSampleDataWithFarmCheckbox = () => ({
|
|
|
186
194
|
};
|
|
187
195
|
},
|
|
188
196
|
methods: {
|
|
189
|
-
onSelect({ item }) {
|
|
190
|
-
if (item.id === 2)
|
|
191
|
-
this.selectedItems = [...this.selectedItems].filter(
|
|
192
|
-
innerItem => innerItem.id !== 2
|
|
193
|
-
);
|
|
194
|
-
},
|
|
195
197
|
isItemSelected(item) {
|
|
196
|
-
return this.selectedItems.some(innerItem => innerItem
|
|
198
|
+
return this.selectedItems.some(innerItem => innerItem === item.id);
|
|
197
199
|
},
|
|
198
200
|
select(item) {
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
if (item.id === 2) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (this.selectedItems.some(innerItem => innerItem === item.id)) {
|
|
205
|
+
this.selectedItems = this.selectedItems.filter(innerItem => innerItem !== item.id);
|
|
203
206
|
return;
|
|
204
207
|
}
|
|
205
|
-
this.selectedItems.push(item);
|
|
208
|
+
this.selectedItems.push(item.id);
|
|
206
209
|
},
|
|
207
210
|
},
|
|
208
211
|
template: `<div>{{selectedItems}}
|
|
209
212
|
<v-data-table
|
|
210
|
-
|
|
213
|
+
show-select
|
|
211
214
|
id="v-data-table--default"
|
|
212
215
|
v-model="selectedItems"
|
|
213
216
|
:headers="headers"
|
|
214
217
|
:items="items"
|
|
215
|
-
@item-selected="onSelect"
|
|
216
218
|
>
|
|
217
219
|
<template v-slot:item.data-table-select="{ isSelected, item }">
|
|
218
|
-
<farm-checkbox :value="item.id" :checked="isItemSelected(item)" @click="select(item)"/>
|
|
220
|
+
<farm-checkbox :value="item.id" :disabled="item.id === 2" :checked="isItemSelected(item)" @click="select(item)"/>
|
|
219
221
|
</template>
|
|
220
222
|
<template v-slot:bottom>
|
|
221
223
|
</template>
|
|
222
224
|
</v-data-table>
|
|
223
225
|
</div>`,
|
|
224
226
|
});
|
|
227
|
+
|
|
228
|
+
export const TableWithCustomHeader = () => ({
|
|
229
|
+
components: { 'v-data-table': VDataTable, 'farm-datatable-header': DataTableHeader },
|
|
230
|
+
data() {
|
|
231
|
+
return {
|
|
232
|
+
headers,
|
|
233
|
+
items: [
|
|
234
|
+
{ id: 1, name: 'name 1' },
|
|
235
|
+
{ id: 2, name: 'name 2' },
|
|
236
|
+
{ id: 3, name: 'name 3' },
|
|
237
|
+
],
|
|
238
|
+
sortClicked: [],
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
methods: {
|
|
242
|
+
onSort: function () {},
|
|
243
|
+
},
|
|
244
|
+
template: `<div>
|
|
245
|
+
<v-data-table
|
|
246
|
+
id="v-data-table--default"
|
|
247
|
+
:headers="headers"
|
|
248
|
+
:items="items"
|
|
249
|
+
>
|
|
250
|
+
<template v-slot:headers="{ someSelected, allSelected }">
|
|
251
|
+
<farm-datatable-header
|
|
252
|
+
:headers="headers"
|
|
253
|
+
:sortClick="sortClicked"
|
|
254
|
+
:selectedIndex="1"
|
|
255
|
+
:headerProps="{ someItems: someSelected, everyItem: allSelected}"
|
|
256
|
+
:showCheckbox="false"
|
|
257
|
+
@onClickSort="onSort"
|
|
258
|
+
/>
|
|
259
|
+
</template>
|
|
260
|
+
<template v-slot:bottom>
|
|
261
|
+
</template>
|
|
262
|
+
</v-data-table>
|
|
263
|
+
</div>`,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
export const TableWithCustomHeaderAndSelect = () => ({
|
|
267
|
+
components: { 'v-data-table': VDataTable, 'farm-datatable-header': DataTableHeader },
|
|
268
|
+
data() {
|
|
269
|
+
return {
|
|
270
|
+
headers: [
|
|
271
|
+
{
|
|
272
|
+
title: 'check',
|
|
273
|
+
sortable: true,
|
|
274
|
+
key: 'data-table-select',
|
|
275
|
+
align: 'left',
|
|
276
|
+
},
|
|
277
|
+
...headers,
|
|
278
|
+
],
|
|
279
|
+
items: [
|
|
280
|
+
{ id: 1, name: 'name 1' },
|
|
281
|
+
{ id: 2, name: 'name 2' },
|
|
282
|
+
{ id: 3, name: 'name 3' },
|
|
283
|
+
],
|
|
284
|
+
sortClicked: [],
|
|
285
|
+
selectedItems: [],
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
methods: {
|
|
289
|
+
onSort: function () {},
|
|
290
|
+
toggleSelectAll: function (event) {
|
|
291
|
+
if (event) {
|
|
292
|
+
this.selectedItems = [...this.selectedItems, ...this.items.map(item => item.id)];
|
|
293
|
+
} else {
|
|
294
|
+
this.selectedItems = this.selectedItems.filter(
|
|
295
|
+
selectedItem => this.items.indexOf(selectedItem) >= 0
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
template: `<farm-box>
|
|
301
|
+
{{ selectedItems }}
|
|
302
|
+
<v-data-table
|
|
303
|
+
id="v-data-table--default"
|
|
304
|
+
show-select
|
|
305
|
+
:headers="headers"
|
|
306
|
+
:items="items"
|
|
307
|
+
v-model="selectedItems"
|
|
308
|
+
>
|
|
309
|
+
<template v-slot:headers="{ someSelected, allSelected }">
|
|
310
|
+
<farm-datatable-header
|
|
311
|
+
:headers="headers"
|
|
312
|
+
:sortClick="sortClicked"
|
|
313
|
+
:selectedIndex="1"
|
|
314
|
+
:headerProps="{ someItems: someSelected, everyItem: allSelected}"
|
|
315
|
+
:showCheckbox="true"
|
|
316
|
+
@toggleSelectAll="toggleSelectAll"
|
|
317
|
+
@onClickSort="onSort"
|
|
318
|
+
/>
|
|
319
|
+
</template>
|
|
320
|
+
<template v-slot:bottom>
|
|
321
|
+
</template>
|
|
322
|
+
</v-data-table>
|
|
323
|
+
</farm-box>`,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
export const TableWithCustomHeaderAndSort = () => ({
|
|
327
|
+
components: { 'v-data-table': VDataTable, 'farm-datatable-header': DataTableHeader },
|
|
328
|
+
data() {
|
|
329
|
+
return {
|
|
330
|
+
headers: [
|
|
331
|
+
{
|
|
332
|
+
title: 'check',
|
|
333
|
+
sortable: true,
|
|
334
|
+
key: 'data-table-select',
|
|
335
|
+
align: 'left',
|
|
336
|
+
},
|
|
337
|
+
...headers.map(h => ({ ...h, sortable: true })),
|
|
338
|
+
],
|
|
339
|
+
items: [
|
|
340
|
+
{ id: 1, name: 'name 1' },
|
|
341
|
+
{ id: 2, name: 'name 2' },
|
|
342
|
+
{ id: 3, name: 'name 3' },
|
|
343
|
+
],
|
|
344
|
+
sortClicked: [],
|
|
345
|
+
selectedItems: [],
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
methods: {
|
|
349
|
+
onSort: function (event) {
|
|
350
|
+
console.log(event);
|
|
351
|
+
},
|
|
352
|
+
toggleSelectAll: function (event) {
|
|
353
|
+
if (event) {
|
|
354
|
+
this.selectedItems = [...this.selectedItems, ...this.items.map(item => item.id)];
|
|
355
|
+
} else {
|
|
356
|
+
this.selectedItems = this.selectedItems.filter(
|
|
357
|
+
selectedItem => this.items.indexOf(selectedItem) >= 0
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
template: `<farm-box>
|
|
363
|
+
{{ selectedItems }}
|
|
364
|
+
<v-data-table
|
|
365
|
+
id="v-data-table--default"
|
|
366
|
+
show-select
|
|
367
|
+
:headers="headers"
|
|
368
|
+
:items="items"
|
|
369
|
+
v-model="selectedItems"
|
|
370
|
+
>
|
|
371
|
+
<template v-slot:headers="{ someSelected, allSelected }">
|
|
372
|
+
<farm-datatable-header
|
|
373
|
+
:headers="headers"
|
|
374
|
+
:sortClick="sortClicked"
|
|
375
|
+
:selectedIndex="1"
|
|
376
|
+
:headerProps="{ someItems: someSelected, everyItem: allSelected}"
|
|
377
|
+
:showCheckbox="false"
|
|
378
|
+
@toggleSelectAll="toggleSelectAll"
|
|
379
|
+
@onClickSort="onSort"
|
|
380
|
+
/>
|
|
381
|
+
</template>
|
|
382
|
+
<template v-slot:bottom>
|
|
383
|
+
</template>
|
|
384
|
+
</v-data-table>
|
|
385
|
+
</farm-box>`,
|
|
386
|
+
});
|
package/src/helpers/date.ts
CHANGED
|
@@ -5,90 +5,72 @@ export const defaultFormat = (data, UTCTimeZone = true) => {
|
|
|
5
5
|
return data ? new Date(data).toLocaleDateString('pt-BR', UTCTimeZone ? options : {}) : null;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export const convertDate = (data) => {
|
|
9
|
-
if(!data) {
|
|
8
|
+
export const convertDate = (data: string): string => {
|
|
9
|
+
if (!data) {
|
|
10
10
|
return '';
|
|
11
11
|
}
|
|
12
|
-
const newdate = data.split(
|
|
12
|
+
const newdate = data.split('/').reverse().join('-');
|
|
13
13
|
return newdate;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const revertDate = (data: string): string => {
|
|
17
|
-
if(!data) {
|
|
17
|
+
if (!data) {
|
|
18
18
|
return '';
|
|
19
19
|
}
|
|
20
|
-
const newdate = data.split(
|
|
20
|
+
const newdate = data.split('-').reverse().join('/');
|
|
21
21
|
return newdate;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
const checkLength = (value, length) => {
|
|
26
25
|
return parseInt(value.length, 10) === length;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
const dateFormatting =
|
|
30
|
-
if(date.includes('/')){
|
|
28
|
+
const dateFormatting = date => {
|
|
29
|
+
if (date.includes('/')) {
|
|
31
30
|
const dateSplit = date.split('/');
|
|
32
31
|
return {
|
|
33
32
|
day: dateSplit[0],
|
|
34
33
|
month: dateSplit[1],
|
|
35
|
-
year: dateSplit[2]
|
|
34
|
+
year: dateSplit[2],
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
const dateSplit = date.split('-');
|
|
39
38
|
return {
|
|
40
39
|
day: dateSplit[2],
|
|
41
40
|
month: dateSplit[1],
|
|
42
|
-
year: dateSplit[0]
|
|
41
|
+
year: dateSplit[0],
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
const checkLeapYear =
|
|
47
|
-
if (parseInt(year, 10) % 400 === 0){
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
if(parseInt(year, 10) % 4 === 0 && parseInt(year, 10) % 100 !== 0) {
|
|
45
|
+
export const checkLeapYear = year => {
|
|
46
|
+
if (parseInt(year, 10) % 400 === 0) {
|
|
51
47
|
return true;
|
|
52
|
-
}else{
|
|
53
|
-
return false;
|
|
54
48
|
}
|
|
49
|
+
return parseInt(year, 10) % 4 === 0 && parseInt(year, 10) % 100 !== 0;
|
|
55
50
|
};
|
|
56
51
|
|
|
57
|
-
const getTotalDays = (month, isLeapYear) => {
|
|
52
|
+
export const getTotalDays = (month, isLeapYear) => {
|
|
58
53
|
const numberMonth = parseInt(month, 10);
|
|
59
|
-
if(numberMonth === 2) {
|
|
54
|
+
if (numberMonth === 2) {
|
|
60
55
|
return isLeapYear ? 29 : 28;
|
|
61
56
|
}
|
|
62
57
|
const monthsWith31Days = [1, 3, 5, 7, 8, 10, 12];
|
|
63
58
|
return monthsWith31Days.includes(numberMonth) ? 31 : 30;
|
|
64
59
|
};
|
|
65
60
|
|
|
66
|
-
const checkDay = (day, totalDays) =>
|
|
67
|
-
if(parseInt(day, 10) > 0 && parseInt(day, 10) <= totalDays) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
};
|
|
61
|
+
export const checkDay = (day, totalDays) => parseInt(day, 10) > 0 && parseInt(day, 10) <= totalDays;
|
|
72
62
|
|
|
73
|
-
const checkMonth = (month)
|
|
74
|
-
if(parseInt(month, 10) > 0 && parseInt(month, 10) <= 12) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
};
|
|
63
|
+
export const checkMonth = month => parseInt(month, 10) > 0 && parseInt(month, 10) <= 12;
|
|
79
64
|
|
|
80
|
-
export const checkDateValid =
|
|
81
|
-
if(!checkLength(date, 10)){
|
|
65
|
+
export const checkDateValid = date => {
|
|
66
|
+
if (!checkLength(date, 10)) {
|
|
82
67
|
return false;
|
|
83
68
|
}
|
|
84
|
-
const {day, month, year} = dateFormatting(date);
|
|
85
|
-
if(!checkMonth(month)){
|
|
69
|
+
const { day, month, year } = dateFormatting(date);
|
|
70
|
+
if (!checkMonth(month)) {
|
|
86
71
|
return false;
|
|
87
72
|
}
|
|
88
73
|
const isLeapYear = checkLeapYear(year);
|
|
89
74
|
const totalDays = getTotalDays(month, isLeapYear);
|
|
90
|
-
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
75
|
+
return checkDay(day, totalDays);
|
|
94
76
|
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<li
|
|
3
|
-
@click="onClick"
|
|
4
|
-
:class="{
|
|
5
|
-
'farm-listitem': true,
|
|
6
|
-
[cssColorWithVariation]: cssColorWithVariation,
|
|
7
|
-
'farm-listitem--clickable': clickable || to,
|
|
8
|
-
}"
|
|
9
|
-
>
|
|
10
|
-
<router-link :to="to" v-if="to">
|
|
11
|
-
<slot></slot>
|
|
12
|
-
</router-link>
|
|
13
|
-
<template v-else>
|
|
14
|
-
<slot></slot>
|
|
15
|
-
</template>
|
|
16
|
-
</li>
|
|
17
|
-
</template>
|
|
18
|
-
<script lang="ts">
|
|
19
|
-
import { computed, PropType, toRefs } from 'vue';
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
name: 'farm-listitem',
|
|
23
|
-
props: {
|
|
24
|
-
to: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: null,
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* Color on hover
|
|
30
|
-
*/
|
|
31
|
-
hoverColor: {
|
|
32
|
-
type: [String, null] as PropType<
|
|
33
|
-
| 'primary'
|
|
34
|
-
| 'secondary'
|
|
35
|
-
| 'secondary-green'
|
|
36
|
-
| 'secondary-golden'
|
|
37
|
-
| 'neutral'
|
|
38
|
-
| 'error'
|
|
39
|
-
| 'warning'
|
|
40
|
-
| 'info'
|
|
41
|
-
| 'extra-1'
|
|
42
|
-
| 'extra-2'
|
|
43
|
-
>,
|
|
44
|
-
default: null,
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Color variation on hover
|
|
48
|
-
*/
|
|
49
|
-
hoverColorVariation: {
|
|
50
|
-
type: [String, null] as PropType<'base' | 'lighten' | 'darken'>,
|
|
51
|
-
default: 'base',
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Is clickable
|
|
55
|
-
*/
|
|
56
|
-
clickable: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
setup(props, { emit }) {
|
|
62
|
-
const { hoverColor, hoverColorVariation } = toRefs(props);
|
|
63
|
-
|
|
64
|
-
const cssColorWithVariation = computed((): String => {
|
|
65
|
-
if (!hoverColor.value) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return `farm-listitem--${hoverColor.value}-${hoverColorVariation.value}`;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const onClick = () => {
|
|
72
|
-
emit('click');
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
cssColorWithVariation,
|
|
77
|
-
onClick,
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
</script>
|
|
82
|
-
<style lang="scss" scoped>
|
|
83
|
-
@import './ListItem';
|
|
84
|
-
</style>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
|
|
3
|
-
import ProgressBar from '../ProgressBar';
|
|
4
|
-
|
|
5
|
-
describe('ProgressBar component', () => {
|
|
6
|
-
let wrapper;
|
|
7
|
-
let component;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
wrapper = shallowMount(ProgressBar, {
|
|
11
|
-
propsData: { value: 40 },
|
|
12
|
-
});
|
|
13
|
-
component = wrapper.vm;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('Created hook', () => {
|
|
17
|
-
expect(wrapper).toBeDefined();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('mount component', () => {
|
|
21
|
-
it('renders correctly', () => {
|
|
22
|
-
expect(wrapper.element).toBeDefined();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('computed properties', () => {
|
|
27
|
-
it('classes', () => {
|
|
28
|
-
expect(component.classes).toBeDefined();
|
|
29
|
-
expect(component.classes).toHaveProperty('farm-progressbar');
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|