@farm-investimentos/front-mfe-components-vue3 0.7.1 → 1.0.0
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 +127 -144
- 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 +127 -144
- 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/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 +12 -0
- package/src/components/DatePicker/DatePicker.vue +2 -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/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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm-investimentos/front-mfe-components-vue3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@storybook/vue3": "^8.0.0",
|
|
56
56
|
"@storybook/vue3-vite": "^8.0.0",
|
|
57
57
|
"@tsconfig/node18": "^18.2.2",
|
|
58
|
-
"@types/jest": "^29.
|
|
58
|
+
"@types/jest": "^29.5.12",
|
|
59
59
|
"@types/node": "^18.17.17",
|
|
60
60
|
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
61
61
|
"@typescript-eslint/parser": "^4.18.0",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
:class="{
|
|
16
16
|
'farm-contextmenu__popup': true,
|
|
17
17
|
'farm-contextmenu__popup--visible': inputValue,
|
|
18
|
+
'farm-contextmenu__popup--fixed': fixedCentered,
|
|
18
19
|
}"
|
|
19
20
|
:style="styles"
|
|
20
21
|
>
|
|
@@ -73,6 +74,13 @@ export default {
|
|
|
73
74
|
type: [Number, String],
|
|
74
75
|
default: null,
|
|
75
76
|
},
|
|
77
|
+
/**
|
|
78
|
+
* Should be in the center of the screen
|
|
79
|
+
*/
|
|
80
|
+
fixedCentered: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false,
|
|
83
|
+
},
|
|
76
84
|
},
|
|
77
85
|
setup(props, { emit }) {
|
|
78
86
|
const parent = ref(null);
|
|
@@ -59,9 +59,9 @@ export const CheckBox = () => ({
|
|
|
59
59
|
return {
|
|
60
60
|
headers: [
|
|
61
61
|
{
|
|
62
|
-
|
|
62
|
+
title: 'check',
|
|
63
63
|
sortable: true,
|
|
64
|
-
|
|
64
|
+
key: 'data-table-select',
|
|
65
65
|
align: 'left',
|
|
66
66
|
},
|
|
67
67
|
...headers,
|
|
@@ -84,23 +84,23 @@ const headerProps = { someItems: true, everyItem: true };
|
|
|
84
84
|
|
|
85
85
|
const headers = [
|
|
86
86
|
{
|
|
87
|
-
|
|
87
|
+
title: 'Grupo',
|
|
88
88
|
sortable: true,
|
|
89
|
-
|
|
89
|
+
key: 'name',
|
|
90
90
|
align: 'left',
|
|
91
91
|
width: 120,
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
|
-
|
|
94
|
+
title: 'Aprovado',
|
|
95
95
|
sortable: true,
|
|
96
|
-
|
|
96
|
+
key: 'approvedAmount',
|
|
97
97
|
align: 'center',
|
|
98
98
|
width: 160,
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
|
-
|
|
101
|
+
title: 'Disponível',
|
|
102
102
|
sortable: false,
|
|
103
|
-
|
|
103
|
+
key: 'availableAmount',
|
|
104
104
|
align: 'center',
|
|
105
105
|
width: 160,
|
|
106
106
|
},
|
|
@@ -1,67 +1,74 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
<tr>
|
|
3
|
+
<th
|
|
4
|
+
v-for="(item, $index) in headers"
|
|
5
|
+
:key="item.key"
|
|
6
|
+
v-bind:class="[
|
|
7
|
+
item.sortable ? 'sortable' : '',
|
|
8
|
+
sortClick[$index].clicked ? 'active' : '',
|
|
9
|
+
item.sortable ? (sortClick[$index].descending === 'DESC' ? 'DESC' : 'ASC') : '',
|
|
10
|
+
showCheckbox && $index == 0 ? 'checkbox-container' : '',
|
|
11
|
+
]"
|
|
12
|
+
v-bind:style="{
|
|
13
|
+
textAlign: item.align ? item.align : '',
|
|
14
|
+
width: thWidth(item),
|
|
15
|
+
minWidth: thWidth(item),
|
|
16
|
+
}"
|
|
17
|
+
@click="item.sortable ? clickSort(item.key, $index) : ''"
|
|
18
|
+
@mouseover="changeShow($index)"
|
|
19
|
+
@mouseout="changeHidden($index)"
|
|
20
|
+
>
|
|
21
|
+
<span
|
|
22
|
+
class="header-text"
|
|
23
|
+
v-if="!isTHDataTableSelect(item)"
|
|
24
|
+
:title="
|
|
25
|
+
item.sortable && sortClick[$index].show ? `Ordernar por ${item.title}` : null
|
|
26
|
+
"
|
|
21
27
|
>
|
|
22
|
-
|
|
23
|
-
class="header-text"
|
|
24
|
-
v-if="!isTHDataTableSelect(item)"
|
|
25
|
-
:title="
|
|
26
|
-
item.sortable && sortClick[$index].show ? `Ordernar por ${item.text}` : null
|
|
27
|
-
"
|
|
28
|
-
>
|
|
29
|
-
{{ item.text }}
|
|
30
|
-
|
|
31
|
-
<farm-icon
|
|
32
|
-
v-show="item.sortable"
|
|
33
|
-
v-bind:class="[
|
|
34
|
-
sortClick[$index][item.value] ? 'farm-icon--desc' : 'farm-icon--asc',
|
|
35
|
-
]"
|
|
36
|
-
class="ml-2"
|
|
37
|
-
size="16px"
|
|
38
|
-
color="black"
|
|
39
|
-
variation="30"
|
|
40
|
-
>
|
|
41
|
-
sort-reverse-variant
|
|
42
|
-
</farm-icon>
|
|
43
|
-
</span>
|
|
28
|
+
{{ item.title }}
|
|
44
29
|
|
|
45
|
-
<
|
|
46
|
-
v-
|
|
47
|
-
class="
|
|
30
|
+
<farm-icon
|
|
31
|
+
v-show="item.sortable"
|
|
32
|
+
v-bind:class="[
|
|
33
|
+
sortClick[$index][item.key] ? 'farm-icon--desc' : 'farm-icon--asc',
|
|
34
|
+
]"
|
|
35
|
+
class="ml-2"
|
|
36
|
+
size="16px"
|
|
37
|
+
color="black"
|
|
38
|
+
variation="30"
|
|
48
39
|
>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
sort-reverse-variant
|
|
41
|
+
</farm-icon>
|
|
42
|
+
</span>
|
|
43
|
+
|
|
44
|
+
<span
|
|
45
|
+
v-if="isTHDataTableSelect(item) && showCheckbox"
|
|
46
|
+
class="span-checkbox"
|
|
47
|
+
>
|
|
48
|
+
<farm-checkbox
|
|
49
|
+
size="sm"
|
|
50
|
+
:modelValue="headerProps.someItems || headerProps.everyItem"
|
|
51
|
+
:value="true"
|
|
52
|
+
:indeterminate="headerProps.someItems && !headerProps.everyItem"
|
|
53
|
+
@update:modelValue="selectAll"
|
|
54
|
+
/>
|
|
55
|
+
</span>
|
|
56
|
+
</th>
|
|
57
|
+
</tr>
|
|
60
58
|
</template>
|
|
61
59
|
|
|
62
60
|
<script lang="ts">
|
|
61
|
+
import { PropType } from 'vue';
|
|
62
|
+
|
|
63
63
|
/* eslint-disable */
|
|
64
64
|
|
|
65
|
+
interface IDataTableHeader {
|
|
66
|
+
title: string;
|
|
67
|
+
key: string | number;
|
|
68
|
+
align?: string;
|
|
69
|
+
sortable?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
65
72
|
export default {
|
|
66
73
|
name: 'farm-datatable-header',
|
|
67
74
|
props: {
|
|
@@ -69,7 +76,7 @@ export default {
|
|
|
69
76
|
* Headers
|
|
70
77
|
*/
|
|
71
78
|
headers: {
|
|
72
|
-
type: Array
|
|
79
|
+
type: Array as PropType<Array<IDataTableHeader>>,
|
|
73
80
|
required: true,
|
|
74
81
|
},
|
|
75
82
|
/**
|
|
@@ -170,7 +177,7 @@ export default {
|
|
|
170
177
|
return item.width ? item.width + 'px' : 'auto';
|
|
171
178
|
},
|
|
172
179
|
isTHDataTableSelect(item) {
|
|
173
|
-
return item.
|
|
180
|
+
return item.key === 'data-table-select';
|
|
174
181
|
},
|
|
175
182
|
selectAll(value) {
|
|
176
183
|
this.$emit('toggleSelectAll', value);
|
|
@@ -180,12 +187,12 @@ export default {
|
|
|
180
187
|
created() {
|
|
181
188
|
for (let i = 0; i < this.headers.length; i += 1) {
|
|
182
189
|
this.sortClick.push({
|
|
183
|
-
[this.headers[i].
|
|
190
|
+
[this.headers[i].key]:
|
|
184
191
|
this.firstSelected &&
|
|
185
192
|
i === this.selectedIndex &&
|
|
186
193
|
this.headers[i].order === 'DESC',
|
|
187
194
|
descending: this.headers[i].order || 'ASC',
|
|
188
|
-
field: this.headers[i].
|
|
195
|
+
field: this.headers[i].key,
|
|
189
196
|
clicked: this.checkFirstSelected(i),
|
|
190
197
|
show: this.checkFirstSelected(i),
|
|
191
198
|
});
|
package/src/components/DataTableHeader/__tests__/{DataTableHeader.spec.js → DataTableHeader.spec.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
|
|
3
|
-
import DataTableHeader from '../DataTableHeader';
|
|
3
|
+
import DataTableHeader from '../DataTableHeader.vue';
|
|
4
4
|
|
|
5
5
|
describe('DataTableHeader component', () => {
|
|
6
6
|
let wrapper;
|
|
@@ -11,7 +11,8 @@ describe('DataTableHeader component', () => {
|
|
|
11
11
|
propsData: {
|
|
12
12
|
headers: [
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
key: 'A',
|
|
15
|
+
title: 'A',
|
|
15
16
|
},
|
|
16
17
|
],
|
|
17
18
|
sortClick: [
|
|
@@ -44,12 +45,12 @@ describe('DataTableHeader component', () => {
|
|
|
44
45
|
|
|
45
46
|
describe('Methods', () => {
|
|
46
47
|
it('Should check if item is data-table-select column', () => {
|
|
47
|
-
expect(component.isTHDataTableSelect({
|
|
48
|
-
expect(component.isTHDataTableSelect({
|
|
48
|
+
expect(component.isTHDataTableSelect({ key: 'data-table-select' })).toBeTruthy();
|
|
49
|
+
expect(component.isTHDataTableSelect({ key: 'anything else' })).toBeFalsy();
|
|
49
50
|
});
|
|
50
51
|
|
|
51
52
|
it('Should get th width', () => {
|
|
52
|
-
expect(component.thWidth({
|
|
53
|
+
expect(component.thWidth({ key: 'data-table-select' })).toEqual('72px');
|
|
53
54
|
expect(component.thWidth({ width: 24 })).toEqual('24px');
|
|
54
55
|
expect(component.thWidth({})).toEqual('auto');
|
|
55
56
|
});
|
|
@@ -172,6 +172,18 @@ export const CenterPositioned = () => ({
|
|
|
172
172
|
</div>`,
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
+
export const FixedCenterPositioned = () => ({
|
|
176
|
+
data() {
|
|
177
|
+
return {
|
|
178
|
+
date: '',
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
template: `<div style='max-width: 320px'>
|
|
182
|
+
<farm-input-datepicker inputId="input-custom-id-0" v-model="date" position="fixed-centered" />
|
|
183
|
+
{{ date }}
|
|
184
|
+
</div>`,
|
|
185
|
+
});
|
|
186
|
+
|
|
175
187
|
export const RequiredMessage = () => ({
|
|
176
188
|
data() {
|
|
177
189
|
return {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
popup-width="320"
|
|
8
8
|
:bottom="position === 'bottom'"
|
|
9
9
|
:top="position === 'top'"
|
|
10
|
+
:fixedCentered="position === 'fixed-centered'"
|
|
10
11
|
>
|
|
11
12
|
<VueDatePicker
|
|
12
13
|
calendar-class-name="dp-custom-calendar"
|
|
@@ -117,7 +118,7 @@ export default {
|
|
|
117
118
|
* Min date (ISO format)
|
|
118
119
|
*/
|
|
119
120
|
position: {
|
|
120
|
-
type: String as PropType<'top' | 'bottom' | 'center'>,
|
|
121
|
+
type: String as PropType<'top' | 'bottom' | 'center' | 'fixed-centered'>,
|
|
121
122
|
default: 'bottom',
|
|
122
123
|
},
|
|
123
124
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import disableTestWarning from 'tests/unit/disableTestWarning';
|
|
2
3
|
|
|
3
4
|
import Icon from '../Icon';
|
|
4
5
|
|
|
@@ -6,6 +7,8 @@ describe('Icon component', () => {
|
|
|
6
7
|
let wrapper;
|
|
7
8
|
let component;
|
|
8
9
|
|
|
10
|
+
disableTestWarning(beforeEach, afterEach);
|
|
11
|
+
|
|
9
12
|
beforeEach(() => {
|
|
10
13
|
wrapper = shallowMount(Icon, {
|
|
11
14
|
slots: {
|
|
@@ -7,14 +7,18 @@
|
|
|
7
7
|
}"
|
|
8
8
|
:size="size"
|
|
9
9
|
>
|
|
10
|
-
<farm-icon
|
|
10
|
+
<farm-icon
|
|
11
|
+
:color="inverted ? 'white' : color"
|
|
12
|
+
:variation="variation"
|
|
13
|
+
:size="size"
|
|
14
|
+
>
|
|
11
15
|
{{ iconParsed }}
|
|
12
16
|
</farm-icon>
|
|
13
17
|
</div>
|
|
14
18
|
</template>
|
|
15
19
|
|
|
16
20
|
<script lang="ts">
|
|
17
|
-
import { PropType } from 'vue';
|
|
21
|
+
import { PropType, computed, toRefs } from 'vue';
|
|
18
22
|
|
|
19
23
|
export default {
|
|
20
24
|
name: 'farm-icon-box',
|
|
@@ -62,13 +66,18 @@ export default {
|
|
|
62
66
|
default: false,
|
|
63
67
|
},
|
|
64
68
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
setup(props) {
|
|
70
|
+
const { color, icon } = toRefs(props);
|
|
71
|
+
|
|
72
|
+
const cssColorClass = computed(() => `farm-icon-box--${color.value}`);
|
|
73
|
+
const iconParsed = computed(() =>
|
|
74
|
+
icon.value.indexOf('mdi-') === 0 ? icon.value.split('mdi-')[1] : icon.value
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
cssColorClass,
|
|
79
|
+
iconParsed,
|
|
80
|
+
};
|
|
72
81
|
},
|
|
73
82
|
};
|
|
74
83
|
</script>
|
|
@@ -9,7 +9,7 @@ describe('IconBox component', () => {
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
wrapper = shallowMount(IconBox, {
|
|
11
11
|
propsData: {
|
|
12
|
-
icon: '
|
|
12
|
+
icon: 'book',
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
15
|
component = wrapper.vm;
|
|
@@ -26,13 +26,27 @@ describe('IconBox component', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
describe('computed properties', () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
describe('iconParsed', () => {
|
|
30
|
+
it('get iconParsed without mdi prefix', () => {
|
|
31
|
+
expect(component.iconParsed).toBeDefined();
|
|
32
|
+
expect(component.iconParsed).toEqual('book');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('get iconParsed with mdi prefix', async () => {
|
|
36
|
+
await wrapper.setProps({ icon: 'mdi-book' });
|
|
37
|
+
expect(component.iconParsed).toEqual('book');
|
|
38
|
+
});
|
|
32
39
|
});
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
describe('cssColorClass', () => {
|
|
42
|
+
it('get default value', () => {
|
|
43
|
+
expect(component.cssColorClass).toEqual('farm-icon-box--primary');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('get secondary color', async () => {
|
|
47
|
+
await wrapper.setProps({ color: 'secondary' });
|
|
48
|
+
expect(component.cssColorClass).toEqual('farm-icon-box--secondary');
|
|
49
|
+
});
|
|
36
50
|
});
|
|
37
51
|
});
|
|
38
52
|
});
|
|
@@ -4,9 +4,11 @@ import ListItem from '../ListItem';
|
|
|
4
4
|
|
|
5
5
|
describe('ListItem component', () => {
|
|
6
6
|
let wrapper;
|
|
7
|
+
let component;
|
|
7
8
|
|
|
8
9
|
beforeEach(() => {
|
|
9
10
|
wrapper = shallowMount(ListItem);
|
|
11
|
+
component = wrapper.vm;
|
|
10
12
|
});
|
|
11
13
|
|
|
12
14
|
test('Created hook', () => {
|
|
@@ -18,4 +20,26 @@ describe('ListItem component', () => {
|
|
|
18
20
|
expect(wrapper.element).toBeDefined();
|
|
19
21
|
});
|
|
20
22
|
});
|
|
23
|
+
|
|
24
|
+
describe('computed properties', () => {
|
|
25
|
+
describe('cssColorWithVariation', () => {
|
|
26
|
+
it('get default value', () => {
|
|
27
|
+
expect(component.cssColorWithVariation).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('get value with hoverColor', async () => {
|
|
31
|
+
await wrapper.setProps({ hoverColor: 'secondary' });
|
|
32
|
+
expect(component.cssColorWithVariation).toEqual('farm-listitem--secondary-base');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('methods', () => {
|
|
38
|
+
describe('onClick', () => {
|
|
39
|
+
it('should emit event', () => {
|
|
40
|
+
component.onClick({ prop: 'value' });
|
|
41
|
+
expect(wrapper.emitted()['click:item'][0]).toEqual([{ prop: 'value' }]);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
21
45
|
});
|
|
@@ -70,8 +70,8 @@ export default {
|
|
|
70
70
|
const inputValue = ref(props.modelValue);
|
|
71
71
|
const styleObject = reactive({ zIndex: 1 });
|
|
72
72
|
const styles = {
|
|
73
|
-
marginTop: offsetTop.value
|
|
74
|
-
marginBottom: offsetBottom.value
|
|
73
|
+
marginTop: `${offsetTop.value}px`,
|
|
74
|
+
marginBottom: `${offsetBottom.value}px`,
|
|
75
75
|
maxHeight: `calc(100vh - ${offsetTop.value + offsetBottom.value + 48}px)`,
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -99,17 +99,17 @@ export default {
|
|
|
99
99
|
bootstrap();
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
function escHandler(event: KeyboardEvent) {
|
|
103
103
|
if (event.key === 'Escape') {
|
|
104
104
|
close();
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
function bootstrap() {
|
|
109
109
|
styleObject.zIndex = calculateMainZindex();
|
|
110
110
|
window.addEventListener('keyup', escHandler);
|
|
111
111
|
hasBeenBoostrapped = true;
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
|
|
114
114
|
onBeforeUnmount(() => {
|
|
115
115
|
if (hasBeenBoostrapped) {
|
|
@@ -122,7 +122,10 @@ export default {
|
|
|
122
122
|
styles,
|
|
123
123
|
styleObject,
|
|
124
124
|
size,
|
|
125
|
+
hasBeenBoostrapped,
|
|
125
126
|
close,
|
|
127
|
+
escHandler,
|
|
128
|
+
bootstrap,
|
|
126
129
|
};
|
|
127
130
|
},
|
|
128
131
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
// import { withDesign } from 'storybook-addon-designs';
|
|
2
1
|
import ModalPromptUser from './ModalPromptUser.vue';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
title: 'Interactions/ModalPromptUser',
|
|
6
5
|
component: ModalPromptUser,
|
|
7
|
-
// decorators: [withDesign],
|
|
8
6
|
parameters: {
|
|
9
7
|
viewMode: 'docs',
|
|
10
8
|
docs: {
|
package/src/components/ModalPromptUser/__tests__/{ModalPromptUser.spec.js → ModalPromptUser.spec.ts}
RENAMED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import disableTestWarning from 'tests/unit/disableTestWarning';
|
|
2
3
|
|
|
3
|
-
import ModalPromptUser from '../ModalPromptUser';
|
|
4
|
+
import ModalPromptUser from '../ModalPromptUser.vue';
|
|
4
5
|
|
|
5
6
|
describe('ModalPromptUser component', () => {
|
|
6
7
|
let wrapper;
|
|
7
8
|
|
|
9
|
+
disableTestWarning(beforeEach, afterEach);
|
|
10
|
+
|
|
8
11
|
beforeEach(() => {
|
|
9
12
|
wrapper = shallowMount(ModalPromptUser, {
|
|
10
13
|
props: {
|
|
@@ -76,30 +76,24 @@ export default {
|
|
|
76
76
|
const { backgroundColor, valueColor, value, indeterminate } = toRefs(props);
|
|
77
77
|
|
|
78
78
|
const classes = computed(() => {
|
|
79
|
-
const obj = {
|
|
80
|
-
|
|
81
|
-
if (!backgroundColor.value.startsWith('#')) {
|
|
82
|
-
obj['farm-progressbar--' + backgroundColor.value] = true;
|
|
83
|
-
}
|
|
84
|
-
if (!valueColor.value.startsWith('#')) {
|
|
85
|
-
obj['farm-progressbar--value-' + valueColor.value] = true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
79
|
+
const obj = {
|
|
89
80
|
'farm-progressbar': true,
|
|
90
|
-
...
|
|
81
|
+
...(!backgroundColor.value.startsWith('#') && {
|
|
82
|
+
['farm-progressbar--' + backgroundColor.value]: true,
|
|
83
|
+
}),
|
|
84
|
+
...(!valueColor.value.startsWith('#') && {
|
|
85
|
+
['farm-progressbar--value-' + valueColor.value]: true,
|
|
86
|
+
}),
|
|
91
87
|
};
|
|
88
|
+
|
|
89
|
+
return obj;
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
const valueStyle = computed(() => {
|
|
95
|
-
|
|
93
|
+
return {
|
|
96
94
|
width: indeterminate.value ? '100%' : `${value.value}%`,
|
|
95
|
+
...(valueColor.value.startsWith('#') && { 'background-color': valueColor.value }),
|
|
97
96
|
};
|
|
98
|
-
|
|
99
|
-
if (valueColor.value.startsWith('#')) {
|
|
100
|
-
obj['background-color'] = valueColor.value;
|
|
101
|
-
}
|
|
102
|
-
return obj;
|
|
103
97
|
});
|
|
104
98
|
|
|
105
99
|
const containerStyle = computed(() => {
|
|
@@ -117,9 +111,6 @@ export default {
|
|
|
117
111
|
};
|
|
118
112
|
</script>
|
|
119
113
|
|
|
120
|
-
|
|
121
114
|
<style lang="scss" scoped>
|
|
122
115
|
@import 'ProgressBar.scss';
|
|
123
116
|
</style>
|
|
124
|
-
|
|
125
|
-
|
|
@@ -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
|
+
});
|