@farm-investimentos/front-mfe-components 15.3.3 → 15.3.5

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": "15.3.3",
3
+ "version": "15.3.5",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -26,7 +26,39 @@ export const Title = () => ({
26
26
 
27
27
  export const Icon = () => ({
28
28
  template:
29
- '<farm-collapsible icon="plus" title="With Icon">collapsible content</farm-collapsible>',
29
+ '<farm-collapsible icon="clipboard" title="With Icon">collapsible content</farm-collapsible>',
30
+ });
31
+
32
+ export const ColorIcons = () => ({
33
+ data() {
34
+ return {
35
+ colors,
36
+ };
37
+ },
38
+ template: `
39
+ <farm-row>
40
+ <farm-col cols="12" md="4" v-for="color in colors" :key="'color_' + color">
41
+ <h4 style="margin:15px">{{ color }}</h4>
42
+ <farm-collapsible
43
+ style="margin-top:15px"
44
+ icon="clipboard"
45
+ title="color icon"
46
+ :colorIcon="color"
47
+ >
48
+ </farm-collapsible>
49
+ </farm-col>
50
+ </farm-row>`,
51
+ });
52
+
53
+ export const Export = () => ({
54
+ data() {
55
+ return {
56
+ clicked: false,
57
+ };
58
+ },
59
+ template: `<div>
60
+ clicked: {{clicked}} <farm-collapsible icon="clipboard" title="With Button" :hasButton="true" @onClick="value => clicked = !clicked" >collapsible content</farm-collapsible>
61
+ </div>`,
30
62
  });
31
63
 
32
64
  export const Opened = () => ({
@@ -110,7 +142,9 @@ export const Dense = () => ({
110
142
  Primary.storyName = 'Basic';
111
143
  Title.storyName = 'Title';
112
144
  Icon.storyName = 'Icon';
145
+ Export.storyName = 'Export';
113
146
  Opened.storyName = 'Opened';
114
- ColorsChips.storyName = 'Colors';
147
+ ColorIcons.storyName = 'Icon Colors';
148
+ ColorsChips.storyName = 'Chip Colors';
115
149
  ColorsOutlinedChips.storyName = 'Outlined';
116
150
  Dense.storyName = 'Dense';
@@ -4,13 +4,16 @@
4
4
  <div class="collapsible__header" @click="onToggleCollapsible(status)">
5
5
  <div class="collapsible__content-title">
6
6
  <div class="collapsible__icon collapsible__icon--main" v-if="icon !== ''">
7
- <farm-icon size="md" color="secondary-green">
7
+ <farm-icon size="md" :color="colorIcon">
8
8
  {{ icon }}
9
9
  </farm-icon>
10
10
  </div>
11
11
  <farm-heading type="6" color="black">
12
12
  {{ title }}
13
13
  </farm-heading>
14
+ <farm-btn outlined class="ml-6" v-if="hasButton" @click.stop="onClick()">
15
+ {{ labelButton }}
16
+ </farm-btn>
14
17
  </div>
15
18
  <div class="collapsible__content-right">
16
19
  <div class="collapsible__icon" v-if="showChip">
@@ -82,6 +85,27 @@ export default defineComponent({
82
85
  type: String,
83
86
  default: '',
84
87
  },
88
+ /**
89
+ * has butotn
90
+ */
91
+ hasButton: {
92
+ type: Boolean,
93
+ default: false,
94
+ },
95
+ /**
96
+ * export button
97
+ */
98
+ onExport: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+ /**
103
+ * label button
104
+ */
105
+ labelButton: {
106
+ type: String,
107
+ default: 'Exportar',
108
+ },
85
109
  /**
86
110
  * color of Chip
87
111
  */
@@ -101,6 +125,25 @@ export default defineComponent({
101
125
  >,
102
126
  default: 'primary',
103
127
  },
128
+ colorIcon: {
129
+ type: String as PropType<
130
+ | 'primary'
131
+ | 'secondary'
132
+ | 'secondary-green'
133
+ | 'secondary-golden'
134
+ | 'neutral'
135
+ | 'info'
136
+ | 'success'
137
+ | 'error'
138
+ | 'warning'
139
+ | 'extra-1'
140
+ | 'extra-2'
141
+ >,
142
+ default: 'secondary-green',
143
+ },
144
+ /**
145
+ * Is dense
146
+ */
104
147
  dense: {
105
148
  type: Boolean,
106
149
  default: false,
@@ -112,6 +155,9 @@ export default defineComponent({
112
155
  type: Boolean,
113
156
  default: false,
114
157
  },
158
+ /**
159
+ * Is variation
160
+ */
115
161
  variation: {
116
162
  type: String,
117
163
  default: 'base',
@@ -134,6 +180,9 @@ export default defineComponent({
134
180
  this.status = !status;
135
181
  this.$emit('open', this.status);
136
182
  },
183
+ onClick(): void {
184
+ this.$emit('onClick');
185
+ },
137
186
  },
138
187
  });
139
188
  </script>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  </template>
19
19
  <script lang="ts">
20
- import { ref, watch, reactive, onBeforeUnmount, toRefs, defineComponent } from 'vue';
20
+ import { ref, watch, reactive, onBeforeUnmount, toRefs, defineComponent, nextTick } from 'vue';
21
21
  import { calculateMainZindex, isChildOfFixedElement } from '../../helpers';
22
22
 
23
23
  export default defineComponent({
@@ -38,6 +38,13 @@ export default defineComponent({
38
38
  type: Boolean,
39
39
  default: false,
40
40
  },
41
+ /**
42
+ * Aligns the component towards the top
43
+ */
44
+ top: {
45
+ type: Boolean,
46
+ default: false,
47
+ },
41
48
  /**
42
49
  * Max height
43
50
  */
@@ -64,7 +71,7 @@ export default defineComponent({
64
71
  const parent = ref(null);
65
72
  const popup = ref(null);
66
73
  const activator = ref(null);
67
- const { bottom, maxHeight, stayOpen } = toRefs(props);
74
+ const { top, bottom, maxHeight, stayOpen } = toRefs(props);
68
75
 
69
76
  const styles = reactive({
70
77
  minWidth: 0,
@@ -74,7 +81,7 @@ export default defineComponent({
74
81
  } as any);
75
82
 
76
83
  const inputValue = ref(props.value);
77
-
84
+
78
85
  let hasBeenBoostrapped = false;
79
86
 
80
87
  const outClick = event => {
@@ -114,8 +121,17 @@ export default defineComponent({
114
121
  hasBeenBoostrapped = true;
115
122
  }
116
123
  window.addEventListener('click', outClick);
117
- window.addEventListener('resize', resizeWindowHandler);
124
+ window.addEventListener('resize', resizeWindowHandler, {
125
+ passive: true,
126
+ });
118
127
  calculatePosition();
128
+
129
+ if (top.value) {
130
+ nextTick(() => {
131
+ const offsetTop = calculateOffsetTop();
132
+ styles.top = `${offsetTop}px`;
133
+ });
134
+ }
119
135
  } else {
120
136
  styles.top = '-10000px';
121
137
  styles.left = '-10000px';
@@ -125,20 +141,36 @@ export default defineComponent({
125
141
  }
126
142
  );
127
143
 
144
+ const getElementClientRects = () => ({
145
+ parentBoundingClientRect: parent.value.getBoundingClientRect(),
146
+ activatorBoundingClientRect: activator.value.children[0].getBoundingClientRect(),
147
+ popupClientRect: popup.value.getBoundingClientRect(), // Only has height when popup is showing on screen
148
+ });
149
+
150
+ const calculateOffsetTop = () => {
151
+ const { parentBoundingClientRect, activatorBoundingClientRect, popupClientRect } =
152
+ getElementClientRects();
153
+
154
+ let offsetTop =
155
+ window.scrollY +
156
+ parentBoundingClientRect.top +
157
+ (!bottom.value ? 0 : activatorBoundingClientRect.height);
158
+
159
+ offsetTop = top.value ? offsetTop - popupClientRect.height - 12 : offsetTop;
160
+
161
+ return offsetTop;
162
+ };
163
+
128
164
  const calculatePosition = () => {
129
165
  if (!parent.value || !activator.value.children[0]) {
130
166
  return;
131
167
  }
132
168
  const activatorChildOfFixedElement = isChildOfFixedElement(activator.value);
133
169
 
134
- const parentBoundingClientRect = parent.value.getBoundingClientRect();
135
- const activatorBoundingClientRect = activator.value.children[0].getBoundingClientRect();
136
- const popupClientRect = popup.value.getBoundingClientRect();
170
+ const { parentBoundingClientRect, activatorBoundingClientRect, popupClientRect } =
171
+ getElementClientRects();
137
172
 
138
- let offsetTop =
139
- parentBoundingClientRect.top +
140
- window.scrollY +
141
- (!bottom.value ? 0 : activatorBoundingClientRect.height);
173
+ let offsetTop = calculateOffsetTop();
142
174
 
143
175
  let offsetLeft = activatorBoundingClientRect.left;
144
176
 
@@ -76,3 +76,15 @@ export const IsNull = () => ({
76
76
  <farm-input-datepicker inputId="input-custom-id-8" v-model="date" :required="true" />
77
77
  </div>`,
78
78
  });
79
+
80
+ export const TopPositioned = () => ({
81
+ data() {
82
+ return {
83
+ date: '',
84
+ };
85
+ },
86
+ template: `<div style='max-width: 320px'>
87
+ <farm-input-datepicker inputId="input-custom-id-0" v-model="date" position="top" />
88
+ {{ date }}
89
+ </div>`,
90
+ });
@@ -4,7 +4,8 @@
4
4
  v-model="menuField"
5
5
  ref="contextmenu"
6
6
  maxHeight="auto"
7
- bottom
7
+ :bottom="position === 'bottom'"
8
+ :top="position === 'top'"
8
9
  popup-width="320"
9
10
  >
10
11
  <v-date-picker
@@ -51,9 +52,13 @@
51
52
  </farm-contextmenu>
52
53
  </template>
53
54
  <script lang="ts">
54
- import { defineComponent } from 'vue';
55
+ import { PropType, defineComponent } from 'vue';
55
56
  import { VDatePicker } from 'vuetify/lib/components/VDatePicker';
56
- import { defaultFormat as dateDefaultFormatter, convertDate, checkDateValid } from '../../helpers/date';
57
+ import {
58
+ defaultFormat as dateDefaultFormatter,
59
+ convertDate,
60
+ checkDateValid,
61
+ } from '../../helpers/date';
57
62
  import { formatDatePickerHeader } from '../../helpers';
58
63
  /**
59
64
  * Componente de input com datepicker para data
@@ -92,6 +97,13 @@ export default defineComponent({
92
97
  type: String,
93
98
  default: null,
94
99
  },
100
+ /**
101
+ * Min date (ISO format)
102
+ */
103
+ position: {
104
+ type: String as PropType<'top' | 'bottom'>,
105
+ default: 'bottom',
106
+ },
95
107
  /**
96
108
  * Required field (inside form)
97
109
  */
@@ -111,9 +123,9 @@ export default defineComponent({
111
123
  dateField: this.value,
112
124
  fieldRange: s,
113
125
  checkDateValid: value => {
114
- if(value.length > 0) {
126
+ if (value.length > 0) {
115
127
  const isValid = checkDateValid(value);
116
- return isValid ? true : 'Data inválida';
128
+ return isValid ? true : 'Data inválida';
117
129
  }
118
130
  return true;
119
131
  },
@@ -121,7 +133,7 @@ export default defineComponent({
121
133
  return this.required ? !!value || value != '' || 'Campo obrigatório' : true;
122
134
  },
123
135
  checkMax: value => {
124
- if(!this.required && value.length === 0) {
136
+ if (!this.required && value.length === 0) {
125
137
  return true;
126
138
  }
127
139
  return this.max && new Date(convertDate(value)) > new Date(this.max)
@@ -129,13 +141,13 @@ export default defineComponent({
129
141
  : true;
130
142
  },
131
143
  checkMin: value => {
132
- if(!this.required && value.length === 0) {
144
+ if (!this.required && value.length === 0) {
133
145
  return true;
134
146
  }
135
- if(this.min) {
147
+ if (this.min) {
136
148
  const dateSelected = new Date(convertDate(value));
137
149
  const dateMin = new Date(convertDate(this.min));
138
- if(dateSelected.getTime() >= dateMin.getTime()){
150
+ if (dateSelected.getTime() >= dateMin.getTime()) {
139
151
  return true;
140
152
  }
141
153
  return 'A data está fora do período permitido';