@farm-investimentos/front-mfe-components 11.1.1 → 11.2.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.
Files changed (31) hide show
  1. package/dist/front-mfe-components.common.js +497 -475
  2. package/dist/front-mfe-components.common.js.map +1 -1
  3. package/dist/front-mfe-components.css +2 -2
  4. package/dist/front-mfe-components.umd.js +497 -475
  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/Buttons/ExportButton/ExportButton.stories.js +11 -4
  10. package/src/components/Buttons/ExportButton/ExportButton.vue +29 -70
  11. package/src/components/Card/Card.scss +2 -2
  12. package/src/components/Card/Card.stories.js +0 -1
  13. package/src/components/Card/Card.vue +4 -1
  14. package/src/components/Card/CardComposition.stories.ts +1 -2
  15. package/src/components/Card/CardContent/CardContent.stories.js +13 -2
  16. package/src/components/Card/CardContent/CardContent.vue +6 -3
  17. package/src/components/ContextMenu/ContextMenu.vue +18 -8
  18. package/src/components/DataTableHeader/DataTableHeader.scss +1 -1
  19. package/src/components/DataTablePaginator/DataTablePaginator.scss +27 -7
  20. package/src/components/DataTablePaginator/DataTablePaginator.vue +45 -11
  21. package/src/components/Form/Form.stories.js +11 -0
  22. package/src/components/IconBox/IconBox.scss +8 -0
  23. package/src/components/Loader/Loader.stories.ts +1 -1
  24. package/src/components/Loader/Loader.vue +50 -58
  25. package/src/components/Modal/Modal.scss +0 -1
  26. package/src/components/Modal/Modal.vue +13 -4
  27. package/src/components/TableContextMenu/TableContextMenu.stories.js +15 -0
  28. package/src/components/Typography/Typography.scss +2 -1
  29. package/src/helpers/calculateMainZindex.js +10 -0
  30. package/src/helpers/date.js +1 -1
  31. package/src/helpers/index.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "11.1.1",
3
+ "version": "11.2.1",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -3,6 +3,17 @@ import ExportButton from './ExportButton.vue';
3
3
  export default {
4
4
  title: 'Buttons/Export',
5
5
  component: ExportButton,
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: `Export Button<br />
10
+ selector: <em>farm-btn-export</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
12
+ `,
13
+ },
14
+ },
15
+ viewMode: 'docs',
16
+ },
6
17
  };
7
18
 
8
19
  export const Primary = () => ({
@@ -16,7 +27,3 @@ export const Disabled = () => ({
16
27
  export const List = () => ({
17
28
  template: `<farm-btn-export :optionsList="[{ key: 1, label: 'XLS teste'}, { key: 2, label: 'CSV teste novo'}]" />`,
18
29
  });
19
-
20
- Primary.storyName = 'Básico';
21
- Disabled.storyName = 'Desabilitado';
22
- List.storyName = 'Lista';
@@ -12,77 +12,51 @@
12
12
  <i :class="{ 'mr-2': true, 'mdi-file-export-outline': true, mdi: true }"></i>
13
13
  Exportar
14
14
  </farm-btn>
15
- <v-menu
16
- v-else
17
- content-class="elevation-1"
18
- v-model="togglePopover"
19
- :offset-y="true"
20
- :rounded="'b t-0'"
21
- >
22
- <template v-slot:activator="{ on, attrs }">
23
- <farm-btn
24
- v-bind="attrs"
25
- v-on="on"
26
- dense
27
- class="farm-btn--responsive"
28
- outlined
29
- title="Exportar"
30
- color="secondary"
31
- @onClick="togglePopover = true"
32
- :disabled="disabled"
33
- >
15
+ <farm-contextmenu v-else v-model="value" :bottom="true">
16
+ <template v-slot:activator="{}">
17
+ <farm-btn outlined title="Exportar" color="secondary" @click="toggleValue">
34
18
  Exportar
35
- <i
36
- :class="{
37
- 'ml-2': true,
38
- 'mr-0': true,
39
- mdi: true,
40
- 'mdi-chevron-up': togglePopover,
41
- 'mdi-chevron-down': !togglePopover,
42
- }"
43
- >
44
- </i>
19
+ <farm-icon class="ml-2"> chevron-{{ value ? 'up' : 'down' }} </farm-icon>
45
20
  </farm-btn>
46
21
  </template>
47
-
48
- <v-list dense class="pa-0">
49
- <v-list-item
22
+ <farm-list>
23
+ <farm-listitem
50
24
  v-for="item in optionsList"
51
- :key="item.key"
52
- link
25
+ clickable
26
+ hoverColor="primary"
27
+ hoverColorVariation="lighten"
28
+ :key="'exportbutton_key_' + item.label"
53
29
  :title="item.label"
54
30
  @click="onClick(item.key)"
55
31
  >
56
- <v-list-item-content>
57
- <v-list-item-title v-text="item.label" />
58
- </v-list-item-content>
59
- </v-list-item>
60
- </v-list>
61
- </v-menu>
32
+ <farm-caption bold tag="span">{{ item.label }}</farm-caption>
33
+ </farm-listitem>
34
+ </farm-list>
35
+ </farm-contextmenu>
62
36
  </template>
63
- <script>
64
- import Vue from 'vue';
65
- import VList from 'vuetify/lib/components/VList/VList';
66
- import VMenu from 'vuetify/lib/components/VMenu';
67
- import VListItem from 'vuetify/lib/components/VList/VListItem';
68
- import { VListItemContent, VListItemTitle } from 'vuetify/lib';
37
+ <script lang="ts">
38
+ import Vue, { PropType } from 'vue';
39
+
40
+ export interface IExportOption {
41
+ label: String;
42
+ key: String;
43
+ }
69
44
 
70
45
  /**
71
- * Botão de Exportação, com opção de gerar menu dropdown
46
+ * BExport Button: standalone or menu list
72
47
  */
73
48
  export default Vue.extend({
74
49
  name: 'farm-btn-export',
75
50
  props: {
76
51
  /**
77
- * Lista de opções para o menu dropdown
78
- * Se não informado, o botão emite evento no clique
52
+ * Options list
79
53
  */
80
54
  optionsList: {
81
- type: Array,
55
+ type: Array as PropType<Array<IExportOption>>,
82
56
  default: () => [],
83
57
  },
84
58
  /**
85
- * Desabilita o botão
59
+ * Is disabled?
86
60
  */
87
61
  disabled: {
88
62
  type: Boolean,
@@ -91,31 +65,16 @@ export default Vue.extend({
91
65
  },
92
66
  data() {
93
67
  return {
94
- togglePopover: false,
68
+ value: false,
95
69
  };
96
70
  },
97
- components: {
98
- VList,
99
- VListItem,
100
- VMenu,
101
- VListItemContent,
102
- VListItemTitle,
103
- },
104
71
  methods: {
105
72
  onClick(key) {
106
73
  this.$emit('onClick', key);
107
74
  },
75
+ toggleValue() {
76
+ this.value = !this.value;
77
+ },
108
78
  },
109
79
  });
110
80
  </script>
111
- <style scoped lang="scss">
112
- .v-list-item {
113
- border-bottom: 1px solid var(--v-gray-lighten2);
114
- &:last-child {
115
- border-bottom: none;
116
- }
117
- }
118
- .v-list-item--link {
119
- font-size: 0.875rem;
120
- }
121
- </style>
@@ -3,8 +3,8 @@
3
3
  .farm-card {
4
4
  width: 100%;
5
5
  background: #ffffff;
6
- border: 1px solid #D6D6D6;
7
- border-radius: 8px;
6
+ border: 1px solid var(--farm-stroke-base);
7
+ border-radius: 5px;
8
8
 
9
9
  &[shadow] {
10
10
  @include addShadow;
@@ -17,7 +17,6 @@ export default {
17
17
  };
18
18
 
19
19
  export const Primary = () => ({
20
- components: { 'farm-card': Card },
21
20
  template: `
22
21
  <farm-card>
23
22
  Conteúdo do Card
@@ -11,11 +11,14 @@ export default Vue.extend({
11
11
  name: 'farm-card',
12
12
  inheritAttrs: true,
13
13
  props: {
14
+ /**
15
+ * Html tag
16
+ */
14
17
  tag: { type: String, default: 'div' },
15
18
  },
16
19
  });
17
20
  </script>
18
21
 
19
22
  <style lang="scss" scoped>
20
- @import './Card.scss';
23
+ @import './Card';
21
24
  </style>
@@ -1,5 +1,4 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
- import gutters from '../../configurations/gutters';
3
2
 
4
3
  export default {
5
4
  title: 'Surfaces/Card/Molecules',
@@ -32,7 +31,7 @@ export const MultipleContents = () => ({
32
31
 
33
32
  export const Gutters = () => ({
34
33
  data() {
35
- return { gutters };
34
+ return { gutters: ['none', 'xs', 'sm', 'vuetify', 'md', 'lg', 'xl'] };
36
35
  },
37
36
  template: `<div style="width: 480px;">
38
37
  <farm-card v-for="gutter in gutters" :key="gutter" style="margin-bottom: 16px">
@@ -7,7 +7,8 @@ export default {
7
7
  docs: {
8
8
  description: {
9
9
  component: `Card Content<br />
10
- selector: <em>farm-card-content</em>
10
+ selector: <em>farm-card-content</em><br />
11
+ <span style="color: var(--farm-primary-base);">ready for use</span>
11
12
  `,
12
13
  },
13
14
  },
@@ -16,10 +17,20 @@ export default {
16
17
  };
17
18
 
18
19
  export const Primary = () => ({
19
- components: { 'farm-card-content': CardContent },
20
20
  template: `
21
21
  <farm-card-content>
22
22
  Conteúdo do Card Content
23
23
  </farm-card-content>
24
24
  `,
25
25
  });
26
+
27
+ export const Gutters = () => ({
28
+ data() {
29
+ return { gutters: ['none', 'xs', 'sm', 'vuetify', 'md', 'lg', 'xl'] };
30
+ },
31
+ template: `<div style="width: 480px;">
32
+ <farm-card-content v-for="gutter in gutters" :key="gutter" style="margin-bottom: 16px" :gutter="gutter">
33
+ Content with {{ gutter }} gutter
34
+ </farm-card-content>
35
+ </div>`,
36
+ });
@@ -10,13 +10,16 @@ import Vue, { PropType } from 'vue';
10
10
  export default Vue.extend({
11
11
  name: 'farm-card-content',
12
12
  props: {
13
+ /**
14
+ * Html tag
15
+ */
13
16
  tag: { type: String, default: 'div' },
14
17
  /**
15
18
  * Add gutter
16
19
  */
17
20
  gutter: {
18
- type: String as PropType<'none' | 'xs' | 'sm' | 'default' | 'md' | 'lg' | 'xl'>,
19
- default: 'default',
21
+ type: String as PropType<'none' | 'xs' | 'sm' | 'vuetify' | 'md' | 'lg' | 'xl'>,
22
+ default: 'md',
20
23
  },
21
24
  },
22
25
  inheritAttrs: true,
@@ -24,5 +27,5 @@ export default Vue.extend({
24
27
  </script>
25
28
 
26
29
  <style lang="scss" scoped>
27
- @import './CardContent.scss';
30
+ @import './CardContent';
28
31
  </style>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  </template>
19
19
  <script lang="ts">
20
- import Vue, { onMounted, ref, watch, reactive, onBeforeUnmount, toRefs } from 'vue';
20
+ import Vue, { ref, watch, reactive, onBeforeUnmount, toRefs } from 'vue';
21
21
 
22
22
  export default Vue.extend({
23
23
  name: 'farm-contextmenu',
@@ -83,7 +83,7 @@ export default Vue.extend({
83
83
  const parentBoundingClientRect = parent.value.getBoundingClientRect();
84
84
  const popupClientRect = popup.value.getBoundingClientRect();
85
85
 
86
- const offsetTop =
86
+ let offsetTop =
87
87
  parentBoundingClientRect.top +
88
88
  window.scrollY +
89
89
  (!bottom.value ? 0 : parentBoundingClientRect.height);
@@ -94,17 +94,27 @@ export default Vue.extend({
94
94
  offsetLeft + parentBoundingClientRect.width / 2 - popupClientRect.width / 2;
95
95
  }
96
96
  styles.minWidth =
97
- parentBoundingClientRect.width > 96
97
+ (parentBoundingClientRect.width > 96
98
98
  ? parseInt(parentBoundingClientRect.width)
99
- : 96 + 'px';
99
+ : 96) + 'px';
100
+
101
+ //Do not allow to open outside window
102
+ const rightEdge = offsetLeft + popupClientRect.width;
103
+ const clientWidth = document.documentElement.clientWidth;
104
+ if (rightEdge > clientWidth - 12) {
105
+ offsetLeft = clientWidth - 12 - popupClientRect.width;
106
+ }
107
+
108
+ const bottomEdge = offsetTop + popupClientRect.height;
109
+ const clientHeight = document.documentElement.clientHeight;
110
+ if (bottomEdge - window.scrollY > clientHeight) {
111
+ offsetTop -= bottomEdge - window.scrollY - clientHeight + 12;
112
+ }
113
+
100
114
  styles.top = offsetTop + 'px';
101
115
  styles.left = offsetLeft + 'px';
102
116
  };
103
117
 
104
- onMounted(() => {
105
- calculatePosition();
106
- });
107
-
108
118
  onBeforeUnmount(() => {
109
119
  if (hasBeenBoostrapped) {
110
120
  window.removeEventListener('resize', resizeWindowHandler);
@@ -30,6 +30,6 @@ th.sortable {
30
30
 
31
31
  th span.span-checkbox {
32
32
  display: flex;
33
- justify-content: start;
33
+ justify-content: flex-start;
34
34
  padding-left: 4px;
35
35
  }
@@ -17,13 +17,27 @@ ul.farm-paginator {
17
17
  border-right: 0;
18
18
  height: 36px;
19
19
  min-width: 36px;
20
- padding-inline: 4px;
21
20
  display: inline-flex;
22
21
  justify-content: center;
23
22
  align-items: center;
24
23
  font-size: 12px;
25
24
  transition: all ease 0.5s;
25
+ padding: 4px 12px;
26
26
 
27
+ p {
28
+ color: var(--farm-neutral-darken);
29
+ margin: 0;
30
+ }
31
+
32
+ .farm-icon {
33
+ color: var(--farm-text-primary);
34
+ }
35
+
36
+ &:disabled {
37
+ .farm-icon {
38
+ color: var(--farm-neutral-base);
39
+ }
40
+ }
27
41
  }
28
42
 
29
43
  &:first-child button {
@@ -37,16 +51,18 @@ ul.farm-paginator {
37
51
 
38
52
  &.farm-paginator__item--selected {
39
53
  button {
40
- background-color: var(--v-secondary-base);
41
- color: white;
54
+ background-color: var(--farm-primary-base);
55
+
56
+ p{
57
+ color: #FFFFFF;
58
+ }
59
+
42
60
  }
43
61
  }
44
62
 
45
63
  &:hover {
46
-
47
- button:not([disabled="disabled"]),
48
- button:not([disabled="disabled"]) i.farm-icon {
49
- color: var(--v-secondary-base);
64
+ button:not([disabled="disabled"]) {
65
+ background-color: var(--farm-primary-lighten);
50
66
  }
51
67
  }
52
68
  }
@@ -65,4 +81,8 @@ ul.farm-paginator {
65
81
 
66
82
  .farm-paginator--gutter {
67
83
  margin: 16px 24px 0;
84
+ }
85
+
86
+ .farm-typography.button {
87
+ font-size: 14px;
68
88
  }
@@ -16,10 +16,20 @@
16
16
  ></v-select>
17
17
  </div>
18
18
 
19
- <ul :class="{ 'farm-paginator': true, 'farm-paginator--disabled': disabled || totalPages == null }">
19
+ <ul
20
+ :class="{
21
+ 'farm-paginator': true,
22
+ 'farm-paginator--disabled': disabled || totalPages == null,
23
+ }"
24
+ >
20
25
  <li>
21
- <button :disabled="currentPage === 1 || disabled || totalPages == null" @click="previousPage">
22
- <farm-icon color="gray" size="sm">chevron-left</farm-icon>
26
+ <button :disabled="canGoBack" @click="firstPage">
27
+ <farm-icon size="sm">chevron-double-left</farm-icon>
28
+ </button>
29
+ </li>
30
+ <li>
31
+ <button :disabled="canGoBack" @click="previousPage">
32
+ <farm-icon size="sm">chevron-left</farm-icon>
23
33
  </button>
24
34
  </li>
25
35
 
@@ -32,13 +42,18 @@
32
42
  :disabled="currentPage === item || item === '...' || disabled"
33
43
  @click="currentPage = item"
34
44
  >
35
- {{ item }}
45
+ <farm-bodytext :type="2" variation="regular">{{ item }}</farm-bodytext>
36
46
  </button>
37
47
  </li>
38
48
 
39
49
  <li>
40
- <button :disabled="currentPage === totalPages || disabled || totalPages == null || totalPages === 0" @click="nextPage">
41
- <farm-icon color="gray" size="sm">chevron-right</farm-icon>
50
+ <button :disabled="canGoForward" @click="nextPage">
51
+ <farm-icon size="sm">chevron-right</farm-icon>
52
+ </button>
53
+ </li>
54
+ <li>
55
+ <button :disabled="canGoForward" @click="lastPage">
56
+ <farm-icon size="sm">chevron-double-right</farm-icon>
42
57
  </button>
43
58
  </li>
44
59
  </ul>
@@ -47,7 +62,6 @@
47
62
  <script lang="ts">
48
63
  import Vue from 'vue';
49
64
  import { VSelect } from 'vuetify/lib/components/VSelect';
50
- import Icon from '../Icon';
51
65
 
52
66
  /**
53
67
  * Componente de paginação usado em tabelas e listas
@@ -55,6 +69,9 @@ import Icon from '../Icon';
55
69
  */
56
70
  export default Vue.extend({
57
71
  name: 'farm-datatable-paginator',
72
+ components: {
73
+ VSelect,
74
+ },
58
75
  props: {
59
76
  /**
60
77
  * Lista de opções para o controle de registros por página
@@ -118,6 +135,12 @@ export default Vue.extend({
118
135
  nextPage() {
119
136
  this.currentPage++;
120
137
  },
138
+ firstPage() {
139
+ this.currentPage = 1;
140
+ },
141
+ lastPage() {
142
+ this.currentPage = this.totalPages;
143
+ },
121
144
  },
122
145
  data() {
123
146
  return {
@@ -161,6 +184,20 @@ export default Vue.extend({
161
184
  return [...this.range(1, left), '...', ...this.range(right, this.totalPages)];
162
185
  }
163
186
  },
187
+ canGoBack: function () {
188
+ const goBack = this.currentPage === 1 || this.disabled || this.totalPages == null;
189
+
190
+ return goBack;
191
+ },
192
+ canGoForward: function () {
193
+ const goNext =
194
+ this.currentPage === this.totalPages ||
195
+ this.disabled ||
196
+ this.totalPages == null ||
197
+ this.totalPages === 0;
198
+
199
+ return goNext;
200
+ },
164
201
  },
165
202
  watch: {
166
203
  selectedLimit(newValue) {
@@ -176,10 +213,7 @@ export default Vue.extend({
176
213
  this.selectedLimit = newValue;
177
214
  },
178
215
  },
179
- components: {
180
- VSelect,
181
- 'farm-icon': Icon,
182
- },
216
+
183
217
  });
184
218
  </script>
185
219
 
@@ -33,6 +33,7 @@ export const Primary = () => ({
33
33
  document: 'Document',
34
34
  name: 'Name',
35
35
  checkbox: true,
36
+ birthDate: new Date('1980/09/20').toISOString()
36
37
  },
37
38
  validForm: false,
38
39
  rules: {
@@ -53,6 +54,16 @@ export const Primary = () => ({
53
54
 
54
55
  <farm-label :required="true">True/false</farm-label>
55
56
  <farm-checkbox v-model="form.checkbox" :rules="[rules.checked]" />
57
+
58
+ <farm-label :required="true">Birthdate:</farm-label>
59
+ <DatePicker
60
+ ref="birthDate"
61
+ inputId="form-pf-birthDate"
62
+ class="mt-4"
63
+ v-model="form.birthDate"
64
+ :readonly="true"
65
+ :required="true"
66
+ />
56
67
 
57
68
 
58
69
  <div class="footer" :style="[styles.footer]">
@@ -14,6 +14,10 @@
14
14
  background: var(--farm-#{$color}-lighten);
15
15
  }
16
16
  }
17
+
18
+ &--neutral .farm-icon.farm-icon {
19
+ color: var(--farm-neutral-darken);
20
+ }
17
21
  }
18
22
 
19
23
  .farm-icon-box--inverted.farm-icon-box {
@@ -27,4 +31,8 @@
27
31
  color: white;
28
32
  }
29
33
 
34
+ &--neutral .farm-icon.farm-icon--white {
35
+ color: var(--farm-neutral-darken);
36
+ }
37
+
30
38
  }
@@ -43,7 +43,7 @@ export const Overlay = () => ({
43
43
  this.show = true;
44
44
  setTimeout(() => {
45
45
  this.show = false;
46
- }, 2000);
46
+ }, 5000);
47
47
  },
48
48
  },
49
49
  });