@farm-investimentos/front-mfe-components 9.1.2 → 9.2.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.
Files changed (30) hide show
  1. package/dist/front-mfe-components.common.js +300 -155
  2. package/dist/front-mfe-components.common.js.map +1 -1
  3. package/dist/front-mfe-components.css +1 -1
  4. package/dist/front-mfe-components.umd.js +300 -155
  5. package/dist/front-mfe-components.umd.js.map +1 -1
  6. package/dist/front-mfe-components.umd.min.js +1 -1
  7. package/dist/front-mfe-components.umd.min.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/components/ButtonToggle/ButtonToggle.scss +14 -0
  10. package/src/components/ButtonToggle/ButtonToggle.stories.js +49 -0
  11. package/src/components/ButtonToggle/ButtonToggle.vue +52 -0
  12. package/src/components/ButtonToggle/IButtonToggle.ts +5 -0
  13. package/src/components/ButtonToggle/__tests__/ButtonToggle.spec.js +18 -0
  14. package/src/components/ButtonToggle/index.ts +4 -0
  15. package/src/components/DataTablePaginator/DataTablePaginator.scss +5 -1
  16. package/src/components/DataTablePaginator/DataTablePaginator.vue +10 -3
  17. package/src/components/Icon/Icon.scss +1 -1
  18. package/src/components/Icon/Icon.stories.js +28 -14
  19. package/src/components/Icon/Icons.stories.scss +17 -0
  20. package/src/components/Icon/icons_list.ts +2566 -0
  21. package/src/components/Logger/Logger.stories.js +55 -0
  22. package/src/components/Logger/LoggerItem/ILoggerItem.ts +1 -0
  23. package/src/components/Logger/LoggerItem/LoggerItem.stories.js +40 -0
  24. package/src/components/Logger/LoggerItem/LoggerItem.vue +27 -2
  25. package/src/components/Logger/LoggerItem/__tests__/LoggerItem.spec.js +40 -0
  26. package/src/components/MultipleFilePicker/MultipleFilePicker.stories.js +35 -4
  27. package/src/components/MultipleFilePicker/MultipleFilePicker.vue +5 -14
  28. package/src/examples/Modal.stories.js +0 -1
  29. package/src/examples/Table.stories.js +2 -0
  30. package/src/main.ts +1 -0
@@ -59,3 +59,58 @@ export const Primary = () => ({
59
59
  },
60
60
  template: `<farm-logger :items="items" />`,
61
61
  });
62
+
63
+ export const Details = () => ({
64
+ data() {
65
+ return {
66
+ items: [
67
+ {
68
+ message: 'Recusado entre as pré elegíveis',
69
+ userName: 'Cleyton Rasta',
70
+ formattedDate: '13/06/2022 20:40',
71
+ status: 'error',
72
+ details() {
73
+ alert('Ver Detalhes');
74
+ },
75
+ },
76
+ {
77
+ message: 'Aprovado entre as pré elegíveis',
78
+ userName: 'Cleyton Rasta',
79
+ formattedDate: '13/06/2022 20:40',
80
+ status: 'success',
81
+ details() {
82
+ alert('Ver Detalhes');
83
+ },
84
+ },
85
+ {
86
+ message: 'Aprovado entre as pré elegíveis',
87
+ userName: 'Cleyton Rasta',
88
+ formattedDate: '13/06/2022 20:40',
89
+ status: 'success',
90
+ details() {
91
+ alert('Ver Detalhes');
92
+ },
93
+ },
94
+ {
95
+ message: 'Recusado entre as pré elegíveis',
96
+ userName: 'Cleyton Rasta',
97
+ formattedDate: '13/06/2022 20:40',
98
+ status: 'error',
99
+ details() {
100
+ alert('Ver Detalhes');
101
+ },
102
+ },
103
+ {
104
+ message: 'Recusado entre as pré elegíveis',
105
+ userName: 'Cleyton Rasta',
106
+ formattedDate: '13/06/2022 20:40',
107
+ status: 'error',
108
+ details() {
109
+ alert('Ver Detalhes');
110
+ },
111
+ },
112
+ ],
113
+ };
114
+ },
115
+ template: `<farm-logger :items="items" />`,
116
+ });
@@ -4,6 +4,7 @@ interface ILoggerItem {
4
4
  formattedDate: string;
5
5
  message: string;
6
6
  status: string;
7
+ details: Function;
7
8
  }
8
9
 
9
10
  export default ILoggerItem;
@@ -74,3 +74,43 @@ export const CustomIcon = () => ({
74
74
  },
75
75
  template: `<farm-logger-item :item="item" />`,
76
76
  });
77
+
78
+ export const Details = () => ({
79
+ data() {
80
+ return {
81
+ items: [
82
+ {
83
+ icon: 'book',
84
+ message: 'Aprovado entre as pré elegíveis',
85
+ userName: 'Cleyton Rasta',
86
+ formattedDate: '13/06/2022 20:40',
87
+ status: 'success',
88
+ details() {
89
+ alert('Ver Detalhes');
90
+ },
91
+ },
92
+ {
93
+ icon: 'book',
94
+ message: 'Reprovado entre as pré elegíveis',
95
+ userName: 'Cleyton Rasta',
96
+ formattedDate: '13/06/2022 20:40',
97
+ status: 'error',
98
+ details() {
99
+ alert('Ver Detalhes');
100
+ },
101
+ },
102
+ {
103
+ icon: 'book',
104
+ message: 'Reprovado entre as pré elegíveis',
105
+ userName: 'Cleyton Rasta',
106
+ formattedDate: '13/06/2022 20:40',
107
+ status: 'primary',
108
+ details() {
109
+ alert('Ver Detalhes');
110
+ },
111
+ },
112
+ ],
113
+ };
114
+ },
115
+ template: `<div><farm-logger-item v-for="item of items" :key="item.status" :item="item" /></div>`,
116
+ });
@@ -19,6 +19,14 @@
19
19
  {{ item.userName }}
20
20
  </span>
21
21
  </div>
22
+ <farm-btn
23
+ v-if="hasDetails"
24
+ :color="buttonColor"
25
+ plain
26
+ title="Ver Detalhes"
27
+ @click="callDetails"
28
+ >Ver Detalhes</farm-btn
29
+ >
22
30
  </section>
23
31
  </template>
24
32
  <script lang="ts">
@@ -33,8 +41,13 @@ export default Vue.extend({
33
41
  */
34
42
  item: { required: true, type: Object as PropType<ILoggerItem> },
35
43
  },
44
+ methods: {
45
+ callDetails(): void {
46
+ this.item.details();
47
+ },
48
+ },
36
49
  computed: {
37
- mdiIconName() {
50
+ mdiIconName(): string {
38
51
  if (this.item.icon) {
39
52
  return `${this.item.icon}`;
40
53
  }
@@ -43,9 +56,21 @@ export default Vue.extend({
43
56
  }
44
57
  return `${this.item.status === 'success' ? 'check' : 'close'}`;
45
58
  },
59
+ buttonColor(): string {
60
+ if (this.item.status === 'success') {
61
+ return 'secondary';
62
+ } else if (this.item.status === 'error') {
63
+ return 'error';
64
+ }
65
+
66
+ return 'primary';
67
+ },
68
+ hasDetails(): boolean {
69
+ return !!this.item.details;
70
+ },
46
71
  },
47
72
  });
48
73
  </script>
49
74
  <style lang="scss" scoped>
50
- @import './LoggerItem.scss'
75
+ @import './LoggerItem.scss';
51
76
  </style>
@@ -49,5 +49,45 @@ describe('LoggerItem component', () => {
49
49
  expect(component.mdiIconName).toEqual('close');
50
50
  });
51
51
 
52
+ it('Should return success button color', async () => {
53
+ await wrapper.setProps({
54
+ item: {
55
+ status: 'success',
56
+ },
57
+ });
58
+ expect(component.buttonColor).toEqual('secondary');
59
+ });
60
+
61
+ it('Should return error button color', async () => {
62
+ await wrapper.setProps({
63
+ item: {
64
+ status: 'error',
65
+ },
66
+ });
67
+ expect(component.buttonColor).toEqual('error');
68
+ });
69
+
70
+ it('Should return default button color', async () => {
71
+ await wrapper.setProps({
72
+ item: {
73
+ status: 'primary',
74
+ },
75
+ });
76
+ expect(component.buttonColor).toEqual('primary');
77
+ });
78
+
79
+ it('Should not have a detail button', async () => {
80
+ await wrapper.setProps({
81
+ item: {
82
+ details: () => {},
83
+ },
84
+ });
85
+
86
+ expect(component.hasDetails).toBeTruthy();
87
+ });
88
+
89
+ it('Should not have a detail button', () => {
90
+ expect(component.hasDetails).toBeFalsy();
91
+ });
52
92
  });
53
93
  });
@@ -3,21 +3,52 @@ import MultipleFilePicker from './MultipleFilePicker.vue';
3
3
  export default {
4
4
  title: 'Form/MultipleFilePicker',
5
5
  component: MultipleFilePicker,
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: `Multiple File Picker<br />
10
+ selector: <em>farm-multiple-filepicker</em>
11
+ `,
12
+ },
13
+ },
14
+ viewMode: 'docs',
15
+ },
6
16
  };
7
17
 
8
18
  export const Primary = () => ({
9
- template: '<MultipleFilePicker />',
19
+ template: '<farm-multiple-filepicker />',
10
20
  });
11
21
 
12
22
  export const MaxFileSize = () => ({
13
- template: '<MultipleFilePicker :maxFileSize="5" />',
23
+ template: '<farm-multiple-filepicker :maxFileSize="5" />',
14
24
  });
15
25
 
16
26
  export const MaxFilesNumber = () => ({
17
- template: '<MultipleFilePicker :maxFileSize="5" :maxFilesNumber="1" />',
27
+ template: '<farm-multiple-filepicker :maxFileSize="5" :maxFilesNumber="1" />',
18
28
  });
19
29
 
20
30
  export const Download = () => ({
21
31
  template:
22
- '<MultipleFilePicker :maxFileSize="5" :downloadFiles="[{ id: 1, name: `Arquivo 1`, size: 10000 }, { id: 2, name: `Arquivo 2`, size: 15000 }]" />',
32
+ '<farm-multiple-filepicker :maxFileSize="5" :downloadFiles="[{ id: 1, name: `Arquivo 1`, size: 10000 }, { id: 2, name: `Arquivo 2`, size: 15000 }]" />',
33
+ });
34
+
35
+ export const InvalidFiles = () => ({
36
+ data() {
37
+ return {
38
+ fileTypes:
39
+ '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel',
40
+ };
41
+ },
42
+ methods: {
43
+ onInvalidFiles(files) {
44
+ alert(`${files.length} invalid file(s)`);
45
+ },
46
+ },
47
+ template: `<div>
48
+ <farm-multiple-filepicker
49
+ :maxFileSize="5"
50
+ :maxFilesNumber="3"
51
+ :acceptedFileTypes="fileTypes"
52
+ @onInvalidFiles="onInvalidFiles" />
53
+ </div>`,
23
54
  });
@@ -94,8 +94,6 @@
94
94
  </template>
95
95
  <script lang="ts">
96
96
  import Vue, { PropType } from 'vue';
97
- import DefaultButton from '../Buttons/DefaultButton';
98
- import Icon from '../Icon';
99
97
  import { sizeOf } from '@farm-investimentos/front-mfe-libs-ts';
100
98
 
101
99
  export type DownloadFiles = {
@@ -106,10 +104,7 @@ export type DownloadFiles = {
106
104
 
107
105
  export default Vue.extend({
108
106
  name: 'farm-multiple-filepicker',
109
- components: {
110
- 'farm-btn': DefaultButton,
111
- 'farm-icon': Icon,
112
- },
107
+
113
108
  props: {
114
109
  /*
115
110
  * Accepted file types
@@ -200,15 +195,11 @@ export default Vue.extend({
200
195
  this.$emit('onFileChange', newValue);
201
196
  return;
202
197
  }
203
- const invalidTypeArray = newValue.filter(file => {
204
- if (
198
+ const invalidTypeArray = newValue.filter(
199
+ file =>
205
200
  this.acceptedFileTypes !== '*' &&
206
201
  this.acceptedFileTypes.indexOf(file.type) === -1
207
- ) {
208
- return true;
209
- }
210
- return false;
211
- });
202
+ );
212
203
 
213
204
  if (invalidTypeArray.length > 0) {
214
205
  const validTypeArray = newValue.filter(file => {
@@ -217,7 +208,7 @@ export default Vue.extend({
217
208
  }
218
209
  return true;
219
210
  });
220
-
211
+ this.$emit('onInvalidFiles', [...invalidTypeArray]);
221
212
  this.files = validTypeArray;
222
213
  return;
223
214
  }
@@ -1,5 +1,4 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
- import { DialogHeader, DialogFooter } from '../main';
3
2
 
4
3
  export default {
5
4
  title: 'Display/Dialog/Examples',
@@ -1,4 +1,6 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
+ import DataTableEmptyWrapper from '../components/DataTableEmptyWrapper';
3
+ import DataTablePaginator from '../components/DataTablePaginator';
2
4
 
3
5
  const headers = [
4
6
  {
package/src/main.ts CHANGED
@@ -50,6 +50,7 @@ export {
50
50
  };
51
51
 
52
52
  export * from './components/AlertReload';
53
+ export * from './components/ButtonToggle';
53
54
  export * from './components/Buttons/DefaultButton';
54
55
  export * from './components/Buttons/DangerButton';
55
56
  export * from './components/Buttons/ConfirmButton';