@farm-investimentos/front-mfe-components 6.3.2 → 6.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "6.3.2",
3
+ "version": "6.3.3",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "core-js": "^3.8.3",
25
- "vue": "^2.6.14",
25
+ "vue": "^2.7.0",
26
26
  "vuetify": "^2.4.5",
27
27
  "vuetify-dialog": "^2.0.17"
28
28
  },
@@ -50,7 +50,7 @@
50
50
  "storybook-addon-designs": "^6.2.1",
51
51
  "typescript": "~4.1.5",
52
52
  "v-mask": "^2.3.0",
53
- "vue-template-compiler": "^2.6.14"
53
+ "vue-template-compiler": "^2.7.0"
54
54
  },
55
55
  "browserslist": [
56
56
  "> 1%",
@@ -0,0 +1,30 @@
1
+ @import '../../configurations/functions';
2
+ @import '../../configurations/mixins';
3
+
4
+ .farm-dialog__footer {
5
+ border-top: 1px solid var(--v-gray-lighten2);
6
+ padding: 1rem;
7
+ display: flex;
8
+ flex-direction: row;
9
+ justify-content: flex-end;
10
+ }
11
+
12
+ .farm-btn {
13
+ margin-left: gutter();
14
+ margin-top: 0;
15
+ }
16
+
17
+ @include for-sm-breakpoint {
18
+ .farm-btn {
19
+ margin-left: 0;
20
+ margin-top: gutter();
21
+ }
22
+
23
+ .farm-dialog__footer {
24
+ flex-direction: column;
25
+
26
+ .farm-btn:first-of-type {
27
+ margin-top: 0;
28
+ }
29
+ }
30
+ }
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <div class="v-dialog__footer d-flex flex-column flex-sm-row justify-end">
3
- <farm-btn @click="$emit('onClose')" v-if="hasCancel" color="primary" outlined>
2
+ <div class="farm-dialog__footer">
3
+ <farm-btn v-if="hasCancel" color="primary" outlined @click="$emit('onClose')">
4
4
  {{ closeLabel }}
5
5
  </farm-btn>
6
6
  <farm-btn
@@ -8,15 +8,12 @@
8
8
  :key="button.label"
9
9
  :color="button.color"
10
10
  :outlined="button.outlined"
11
- :depressed="button.outlined"
12
11
  :disabled="button.disabled"
13
- class="ml-sm-3 mt-3 mt-sm-0"
14
12
  @click="$emit(button.listener ? button.listener : '')"
15
13
  >
16
14
  {{ button.label }}
17
15
  </farm-btn>
18
16
  <farm-btn
19
- class="ml-sm-3 mt-3 mt-sm-0"
20
17
  v-if="hasConfirm"
21
18
  :color="confirmColor"
22
19
  :disabled="isConfirmDisabled"
@@ -28,13 +25,16 @@
28
25
  </div>
29
26
  </template>
30
27
 
31
- <script>
28
+ <script lang="ts">
29
+ import Vue, { PropType } from 'vue';
32
30
  import DefaultButton from '../Buttons/DefaultButton';
31
+ import IExtraButton from './IExtraButton';
32
+
33
33
  /**
34
34
  * Footer de dialog/modal
35
35
  */
36
- export default {
37
- name: 'DialogFooter',
36
+ export default Vue.extend({
37
+ name: 'farm-dialog-foote',
38
38
  components: {
39
39
  'farm-btn': DefaultButton,
40
40
  },
@@ -89,12 +89,15 @@ export default {
89
89
  default: false,
90
90
  },
91
91
  /**
92
- * lista de botões extra
92
+ * lista de botões extra (IExtraButton)
93
93
  */
94
94
  extraButtons: {
95
- type: Array,
95
+ type: Array as PropType<Array<IExtraButton>>,
96
96
  default: () => [],
97
97
  },
98
98
  },
99
- };
99
+ });
100
100
  </script>
101
+ <style lang="scss" scoped>
102
+ @import 'DialogFooter';
103
+ </style>
@@ -0,0 +1,9 @@
1
+ interface IExtraButton {
2
+ label: string;
3
+ color: string;
4
+ outlined: boolean;
5
+ disabled: boolean;
6
+ listener: Function | null;
7
+ }
8
+
9
+ export default IExtraButton;
@@ -1,17 +1,25 @@
1
1
  .logger {
2
- display: block;
3
-
4
- .logger__item {
5
- float: left;
6
- clear: both;
7
- }
2
+ display: flex;
3
+ flex-direction: column;
8
4
  }
9
-
10
5
  .logger__divider {
11
- float: left;
12
- clear: both;
13
- height: 40px;
14
- margin: -4px 0 -4px 16px;
15
- width: 1px;
16
- background-color: var(--v-gray-lighten1);
17
- }
6
+ height: 40px;
7
+ margin: -4px 0 -4px 16px;
8
+ width: 1px;
9
+
10
+ &.logger__divider--success {
11
+ background: var(--v-secondary-base);
12
+ }
13
+
14
+ &.logger__divider--error {
15
+ background: var(--v-error-base);
16
+ }
17
+
18
+ &.logger__divider--error-to-success {
19
+ background: linear-gradient(to bottom, var(--v-error-base), var(--v-secondary-base));
20
+ }
21
+
22
+ &.logger__divider--success-to-error {
23
+ background: linear-gradient(to bottom, var(--v-secondary-base), var(--v-error-base));
24
+ }
25
+ }
@@ -21,13 +21,11 @@ export default {
21
21
  };
22
22
 
23
23
  export const Primary = () => ({
24
- components: { Logger },
24
+ components: { 'farm-logger': Logger },
25
25
  data() {
26
26
  return {};
27
27
  },
28
- template: `<Logger>
29
-
30
- </Logger>`,
28
+ template: `<farm-logger />`,
31
29
  });
32
30
 
33
31
  Primary.storyName = 'Básico';
@@ -2,8 +2,19 @@
2
2
  <section class="logger">
3
3
  <template v-for="(item, index) in items">
4
4
  <LoggerItem :item="item" :key="index" />
5
- <div v-if="hasDivider(index)" class="logger__divider" :key="'divider_' + index">
6
- </div>
5
+ <div
6
+ :class="{
7
+ 'logger__divider--success': isPreviousLogAndCurrentLogSuccess(index),
8
+ 'logger__divider--error': isPreviousLogAndCurrentLogError(index),
9
+ 'logger__divider--success-to-error':
10
+ isPreviousLogErrorAndCurrentLogSuccess(index),
11
+ 'logger__divider--error-to-success':
12
+ isPreviousLogSuccessAndCurrentLogError(index),
13
+ }"
14
+ v-if="hasDivider(index)"
15
+ class="logger__divider"
16
+ :key="'divider_' + index"
17
+ ></div>
7
18
  </template>
8
19
  </section>
9
20
  </template>
@@ -15,11 +26,34 @@ import LoggerItem from './LoggerItem/';
15
26
  export default Vue.extend({
16
27
  name: 'farm-logger',
17
28
  components: { LoggerItem },
18
- props: { items: { required: true, type: Array as PropType<Array<ILoggerItem>> } },
29
+ props: {
30
+ /*
31
+ * List of logger items
32
+ */
33
+ items: { required: true, type: Array as PropType<Array<ILoggerItem>> },
34
+ },
19
35
  methods: {
20
36
  hasDivider(index: number): boolean {
21
37
  return index < this.items.length - 1;
22
38
  },
39
+ isPreviousLogAndCurrentLogError(index: number): boolean {
40
+ return this.isError(index) && this.isError(index + 1);
41
+ },
42
+ isPreviousLogAndCurrentLogSuccess(index: number): boolean {
43
+ return this.isSuccess(index) && this.isSuccess(index + 1);
44
+ },
45
+ isPreviousLogErrorAndCurrentLogSuccess(index: number): boolean {
46
+ return this.isSuccess(index) && this.isError(index + 1);
47
+ },
48
+ isPreviousLogSuccessAndCurrentLogError(index: number): boolean {
49
+ return this.isError(index) && this.isSuccess(index + 1);
50
+ },
51
+ isError(index: number): boolean {
52
+ return this.items[index].status === 'error';
53
+ },
54
+ isSuccess(index: number): boolean {
55
+ return this.items[index].status === 'success';
56
+ },
23
57
  },
24
58
  });
25
59
  </script>
@@ -20,7 +20,7 @@ export default {
20
20
  };
21
21
 
22
22
  export const Primary = () => ({
23
- components: { LoggerItem },
23
+ components: { 'farm-logger-item': LoggerItem },
24
24
  data() {
25
25
  return {
26
26
  item: {
@@ -32,7 +32,7 @@ export const Primary = () => ({
32
32
  },
33
33
  };
34
34
  },
35
- template: `<LoggerItem :item="item" />`,
35
+ template: `<farm-logger-item :item="item" />`,
36
36
  });
37
37
 
38
38
  Primary.storyName = 'Básico';
@@ -6,12 +6,7 @@
6
6
  'logger__item--success': item.status === 'success',
7
7
  }"
8
8
  >
9
- <i
10
- :class="{
11
- mdi: true,
12
- [mdiIconName]: true,
13
- }"
14
- />
9
+ <farm-icon>{{ mdiIconName }}</farm-icon>
15
10
  <div>
16
11
  <span class="logger__date">
17
12
  {{ item.formattedDate }}
@@ -29,25 +24,32 @@
29
24
  <script lang="ts">
30
25
  import Vue, { PropType } from 'vue';
31
26
  import ILoggerItem from './ILoggerItem';
27
+ import Icon from '../../Icon';
32
28
 
33
29
  export default Vue.extend({
34
30
  name: 'farm-logger-item',
31
+ components: {
32
+ 'farm-icon': Icon,
33
+ },
35
34
  props: {
35
+ /**
36
+ * Logger item
37
+ */
36
38
  item: { required: true, type: Object as PropType<ILoggerItem> },
37
39
  },
38
40
  computed: {
39
41
  mdiIconName() {
40
42
  if (this.item.icon) {
41
- return `mdi-${this.item.icon}`;
43
+ return `${this.item.icon}`;
42
44
  }
43
- if(!this.item.status) {
45
+ if (!this.item.status) {
44
46
  return '';
45
47
  }
46
- return `mdi-${this.item.status === 'success' ? 'check' : 'close'}`;
48
+ return `${this.item.status === 'success' ? 'check' : 'close'}`;
47
49
  },
48
50
  },
49
51
  });
50
52
  </script>
51
- <style lang="sass" scoped>
53
+ <style lang="scss" scoped>
52
54
  @import './LoggerItem.scss'
53
55
  </style>
@@ -28,7 +28,7 @@ describe('LoggerItem component', () => {
28
28
  icon: 'aaa',
29
29
  },
30
30
  });
31
- expect(component.mdiIconName).toEqual('mdi-aaa');
31
+ expect(component.mdiIconName).toEqual('aaa');
32
32
  });
33
33
 
34
34
  it('Should return success icon', async () => {
@@ -37,7 +37,7 @@ describe('LoggerItem component', () => {
37
37
  status: 'success',
38
38
  },
39
39
  });
40
- expect(component.mdiIconName).toEqual('mdi-check');
40
+ expect(component.mdiIconName).toEqual('check');
41
41
  });
42
42
 
43
43
  it('Should return success icon', async () => {
@@ -46,7 +46,7 @@ describe('LoggerItem component', () => {
46
46
  status: 'error',
47
47
  },
48
48
  });
49
- expect(component.mdiIconName).toEqual('mdi-close');
49
+ expect(component.mdiIconName).toEqual('close');
50
50
  });
51
51
 
52
52
  });
@@ -3,6 +3,7 @@ import Logger from '../Logger';
3
3
 
4
4
  describe('Logger component', () => {
5
5
  let wrapper;
6
+ let component;
6
7
 
7
8
  beforeEach(() => {
8
9
  wrapper = shallowMount(Logger, {
@@ -15,12 +16,107 @@ describe('Logger component', () => {
15
16
  formattedDate: '13/06/2022 20:40',
16
17
  status: 'error',
17
18
  },
19
+ {
20
+ icon: 'book',
21
+ message: 'Recusado entre as pré elegíveis',
22
+ userName: 'Cleyton Rasta',
23
+ formattedDate: '13/06/2022 20:40',
24
+ status: 'error',
25
+ },
26
+ {
27
+ icon: 'book',
28
+ message: 'Aceito entre as pré elegíveis',
29
+ userName: 'Cleyton Rasta',
30
+ formattedDate: '13/06/2022 20:40',
31
+ status: 'success',
32
+ },
33
+ {
34
+ icon: 'book',
35
+ message: 'Aceito entre as pré elegíveis',
36
+ userName: 'Cleyton Rasta',
37
+ formattedDate: '13/06/2022 20:40',
38
+ status: 'success',
39
+ },
40
+ {
41
+ icon: 'book',
42
+ message: 'Recusado entre as pré elegíveis',
43
+ userName: 'Cleyton Rasta',
44
+ formattedDate: '13/06/2022 20:40',
45
+ status: 'error',
46
+ },
18
47
  ],
19
48
  },
20
49
  });
50
+ component = wrapper.vm;
21
51
  });
22
52
 
23
53
  test('Logger created', () => {
24
54
  expect(wrapper).toBeDefined();
25
55
  });
56
+
57
+ describe('Methods', () => {
58
+ describe('hasDivider', () => {
59
+ it('should return true when it has a next item', () => {
60
+ expect(component.hasDivider(0)).toBeTruthy();
61
+ });
62
+
63
+ it('should return false when it has not a next item', () => {
64
+ expect(component.hasDivider(4)).toBeFalsy();
65
+ });
66
+ });
67
+
68
+ describe('isPreviousLogAndCurrentLogError', () => {
69
+ it('should return true', () => {
70
+ expect(component.isPreviousLogAndCurrentLogError(0)).toBeTruthy();
71
+ });
72
+
73
+ it('should return false', () => {
74
+ expect(component.isPreviousLogAndCurrentLogError(1)).toBeFalsy();
75
+ });
76
+ });
77
+
78
+ describe('isPreviousLogAndCurrentLogSuccess', () => {
79
+ it('should return true', () => {
80
+ expect(component.isPreviousLogAndCurrentLogSuccess(2)).toBeTruthy();
81
+ });
82
+ it('should return false', () => {
83
+ expect(component.isPreviousLogAndCurrentLogSuccess(0)).toBeFalsy();
84
+ });
85
+ });
86
+
87
+ describe('isPreviousLogErrorAndCurrentLogSuccess', () => {
88
+ it('should return true', () => {
89
+ expect(component.isPreviousLogErrorAndCurrentLogSuccess(3)).toBeTruthy();
90
+ });
91
+ it('should return false', () => {
92
+ expect(component.isPreviousLogErrorAndCurrentLogSuccess(2)).toBeFalsy();
93
+ });
94
+ });
95
+ describe('isPreviousLogSuccessAndCurrentLogError', () => {
96
+ it('should return true', () => {
97
+ expect(component.isPreviousLogSuccessAndCurrentLogError(1)).toBeTruthy();
98
+ });
99
+ it('should false', () => {
100
+ expect(component.isPreviousLogSuccessAndCurrentLogError(2)).toBeFalsy();
101
+ });
102
+ });
103
+
104
+ describe('isError', () => {
105
+ it('should true when the status is error', () => {
106
+ expect(component.isError(1)).toBeTruthy();
107
+ });
108
+ it('should false when the status is success', () => {
109
+ expect(component.isError(2)).toBeFalsy();
110
+ });
111
+ });
112
+
113
+ describe('isSuccess', () => {
114
+ it('should return true when the status is success', () => {
115
+ expect(component.isSuccess(2)).toBeTruthy();
116
+ });
117
+ it('should false when the status is error', () => {
118
+ expect(component.isSuccess(1)).toBeFalsy();
119
+ });
120
+ });
121
+ });
26
122
  });
@@ -1,12 +1,12 @@
1
1
  $step-height: 64px;
2
2
 
3
3
  @mixin stepperHeaderStepColor($color) {
4
- i.mdi {
4
+ .farm-icon, .farm-icon__number {
5
5
  background-color: $color;
6
6
  border-color: $color;
7
7
  }
8
8
 
9
- i.mdi:before {
9
+ .farm-icon:before, .farm-icon__number {
10
10
  color: white;
11
11
  }
12
12
  }
@@ -43,12 +43,12 @@ $step-height: 64px;
43
43
  }
44
44
 
45
45
  &.stepper__header-step--next {
46
- i.mdi {
46
+ .farm-icon, .farm-icon__number {
47
47
  color: var(--v-gray-lighten1);
48
48
  }
49
49
  }
50
50
 
51
- span {
51
+ span:not(.farm-icon__number) {
52
52
  margin-top: 8px;
53
53
  text-align: center;
54
54
  }
@@ -78,7 +78,8 @@ $step-height: 64px;
78
78
  }
79
79
 
80
80
  &.stepper__header--vertical {
81
- display: block;
81
+ display: flex;
82
+ flex-direction: column;
82
83
 
83
84
  div.stepper__header-step {
84
85
  width: 100%;
@@ -86,11 +87,11 @@ $step-height: 64px;
86
87
  clear: both;
87
88
  height: 64px;
88
89
 
89
- i.mdi {
90
+ .farm-icon {
90
91
  float: left;
91
92
  }
92
93
 
93
- span {
94
+ span:not(.farm-icon__number) {
94
95
  display: flex;
95
96
  align-items: center;
96
97
  width: calc(100% - 40px);
@@ -130,7 +131,8 @@ $step-height: 64px;
130
131
  }
131
132
  }
132
133
 
133
- i.mdi {
134
+ .farm-icon,
135
+ .farm-icon__number {
134
136
  border: 1px solid var(--v-gray-lighten2);
135
137
  border-radius: 50%;
136
138
  width: 32px;
@@ -20,7 +20,7 @@ export default {
20
20
  };
21
21
 
22
22
  export const Primary = () => ({
23
- components: { StepperHeader },
23
+ components: { 'farm-stepper-header': StepperHeader },
24
24
  data() {
25
25
  return {
26
26
  steps: [
@@ -32,9 +32,7 @@ export const Primary = () => ({
32
32
  currentStep: 3,
33
33
  };
34
34
  },
35
- template: '<StepperHeader :steps="steps" :currentStep="currentStep" />',
35
+ template: '<farm-stepper-header :steps="steps" :currentStep="currentStep" />',
36
36
  });
37
37
 
38
38
  Primary.storyName = 'Básico';
39
-
40
- //
@@ -12,14 +12,12 @@
12
12
  }"
13
13
  :key="step.label"
14
14
  >
15
- <i
16
- :class="{
17
- mdi: true,
18
- ['mdi-' + step.icon]: true,
19
- }"
20
- >
21
- {{ step.icon ? '' : index + 1 }}
22
- </i>
15
+ <farm-icon v-if="step.icon">
16
+ {{ step.icon }}
17
+ </farm-icon>
18
+ <span v-else class="farm-icon__number">
19
+ {{ index + 1 }}
20
+ </span>
23
21
  <span>
24
22
  {{ step.label }}
25
23
  </span>
@@ -42,9 +40,13 @@
42
40
  <script lang="ts">
43
41
  import Vue, { PropType } from 'vue';
44
42
  import IStep from './IStep';
43
+ import Icon from '../../Icon';
45
44
 
46
45
  export default Vue.extend({
47
46
  name: 'farm-stepper-header',
47
+ components: {
48
+ 'farm-icon': Icon,
49
+ },
48
50
  props: {
49
51
  /**
50
52
  * Steps
@@ -0,0 +1,5 @@
1
+ @import './variables';
2
+
3
+ @function gutter($key: 'default') {
4
+ @return map-get($gutters, $key)
5
+ }
@@ -0,0 +1,5 @@
1
+ @mixin for-sm-breakpoint {
2
+ @media (max-width: 599px) {
3
+ @content;
4
+ }
5
+ }
@@ -1,2 +1,15 @@
1
1
  $colors: primary, secondary, error, extra, accent, info, success, gray, yellow, white;
2
- $sizes: ("xs": 12px, "sm": 16px , "md": 24px, "lg": 36px, "xl": 40px);
2
+ $sizes: (
3
+ "xs": 12px,
4
+ "sm": 16px,
5
+ "md": 24px,
6
+ "lg": 36px,
7
+ "xl": 40px
8
+ );
9
+ $gutters: (
10
+ "xs": 4px,
11
+ 'sm': 8px,
12
+ "default": 12px,
13
+ 'md': 16px,
14
+ "lg": 36px,
15
+ "xl": 40px);
@@ -38,6 +38,18 @@ export const Primary = () => ({
38
38
  formattedDate: '13/06/2022 20:40',
39
39
  status: 'success',
40
40
  },
41
+ {
42
+ message: 'Recusado entre as pré elegíveis',
43
+ userName: 'Cleyton Rasta',
44
+ formattedDate: '13/06/2022 20:40',
45
+ status: 'error',
46
+ },
47
+ {
48
+ message: 'Recusado entre as pré elegíveis',
49
+ userName: 'Cleyton Rasta',
50
+ formattedDate: '13/06/2022 20:40',
51
+ status: 'error',
52
+ },
41
53
  ],
42
54
  };
43
55
  },