@farm-investimentos/front-mfe-components 11.5.3 → 11.5.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": "11.5.3",
3
+ "version": "11.5.5",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -142,6 +142,10 @@ export const DisabledButtons = () => ({
142
142
  <farm-btn v-for="color of colors":key="color + '_disabled_icon'" :color="color" plain disabled>
143
143
  <farm-icon>book</farm-icon> {{ color }}
144
144
  </farm-btn>
145
+ <farm-btn v-for="color of colors":key="'random_icon_' + color" :color="color" disabled>
146
+ <farm-icon>book</farm-icon>
147
+ {{ color }}
148
+ </farm-btn>
145
149
  </div>`,
146
150
  });
147
151
 
@@ -19,6 +19,39 @@ export default {
19
19
  };
20
20
 
21
21
  export const Primary = () => ({
22
+ template: `<div style="padding-left: 120px; padding-top: 80px; display: flex;">
23
+ <farm-contextmenu>
24
+ some text
25
+ <template v-slot:activator="{ on, attrs }">
26
+ <farm-btn
27
+ v-bind="attrs"
28
+ v-on="on"
29
+ >
30
+ toggle
31
+ </farm-btn>
32
+ </template>
33
+ </farm-contextmenu>
34
+ </div>`,
35
+ });
36
+
37
+ export const IconActivator = () => ({
38
+ template: `<div style="padding-left: 120px; padding-top: 80px; display: flex;">
39
+ <farm-contextmenu>
40
+ some text
41
+ <template v-slot:activator="{ on, attrs }">
42
+ <farm-btn
43
+ v-bind="attrs"
44
+ v-on="on"
45
+ icon
46
+ >
47
+ <farm-icon>help-circle</farm-icon>
48
+ </farm-btn>
49
+ </template>
50
+ </farm-contextmenu>
51
+ </div>`,
52
+ });
53
+
54
+ export const VModel = () => ({
22
55
  data() {
23
56
  return {
24
57
  value: false,
@@ -160,4 +193,4 @@ export const MaxHeight = () => ({
160
193
  </template>
161
194
  </farm-contextmenu>
162
195
  </div>`,
163
- });
196
+ });
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="farm-contextmenu" ref="parent">
3
- <span ref="activator">
3
+ <span ref="activator" @click="click">
4
4
  <slot name="activator"></slot>
5
5
  </span>
6
6
 
@@ -66,6 +66,7 @@ export default Vue.extend({
66
66
  const outClick = (event: Event) => {
67
67
  if (activator && !activator.value.contains(event.target)) {
68
68
  emit('input', false);
69
+ inputValue.value = false;
69
70
  }
70
71
  };
71
72
 
@@ -74,12 +75,11 @@ export default Vue.extend({
74
75
  };
75
76
 
76
77
  watch(
77
- () => props.value,
78
+ () => inputValue.value,
78
79
  newValue => {
79
80
  if (newValue) {
80
81
  if (!hasBeenBoostrapped) {
81
82
  document.querySelector('body').appendChild(popup.value);
82
-
83
83
  hasBeenBoostrapped = true;
84
84
  }
85
85
  window.addEventListener('click', outClick);
@@ -88,11 +88,13 @@ export default Vue.extend({
88
88
  } else {
89
89
  window.removeEventListener('click', outClick);
90
90
  }
91
- inputValue.value = newValue;
92
91
  }
93
92
  );
94
93
 
95
94
  const calculatePosition = () => {
95
+ if (!parent.value || !activator.value.children[0]) {
96
+ return;
97
+ }
96
98
  const parentBoundingClientRect = parent.value.getBoundingClientRect();
97
99
  const activatorBoundingClientRect = activator.value.children[0].getBoundingClientRect();
98
100
  const popupClientRect = popup.value.getBoundingClientRect();
@@ -102,14 +104,9 @@ export default Vue.extend({
102
104
  window.scrollY +
103
105
  (!bottom.value ? 0 : activatorBoundingClientRect.height);
104
106
 
105
- let offsetLeft = activatorBoundingClientRect.left;
106
- if (popupClientRect.width > activatorBoundingClientRect.width) {
107
- const w = popupClientRect.width < 96 ? 96 : popupClientRect.width;
108
- offsetLeft =
109
- activatorBoundingClientRect.left +
110
- activatorBoundingClientRect.width / 2 -
111
- w / 2;
112
- }
107
+ const w = popupClientRect.width < 96 ? 96 : popupClientRect.width;
108
+ let offsetLeft =
109
+ activatorBoundingClientRect.left + activatorBoundingClientRect.width / 2 - w / 2;
113
110
 
114
111
  styles.minWidth =
115
112
  (activatorBoundingClientRect.width > 96
@@ -117,10 +114,10 @@ export default Vue.extend({
117
114
  : 96) + 'px';
118
115
 
119
116
  //Do not allow to open outside window
120
-
117
+
121
118
  const rightEdge = offsetLeft + popupClientRect.width;
122
119
  const clientWidth = document.documentElement.clientWidth;
123
-
120
+
124
121
  if (rightEdge > clientWidth - 12) {
125
122
  offsetLeft = clientWidth - 12 - popupClientRect.width;
126
123
  }
@@ -131,7 +128,6 @@ export default Vue.extend({
131
128
  offsetTop -= bottomEdge - window.scrollY - clientHeight + 12;
132
129
  }
133
130
 
134
-
135
131
  styles.top = `${offsetTop}px`;
136
132
  styles.left = `${offsetLeft}px`;
137
133
  styles.zIndex = calculateMainZindex();
@@ -145,12 +141,18 @@ export default Vue.extend({
145
141
  }
146
142
  });
147
143
 
144
+ const click = () => {
145
+ inputValue.value = !inputValue.value;
146
+ emit('input', inputValue.value);
147
+ };
148
+
148
149
  return {
149
150
  parent,
150
151
  popup,
151
152
  activator,
152
153
  styles,
153
154
  inputValue,
155
+ click,
154
156
  };
155
157
  },
156
158
  });
@@ -3,9 +3,11 @@ import ContextMenu from '../ContextMenu';
3
3
 
4
4
  describe('ContextMenu component', () => {
5
5
  let wrapper;
6
+ let component;
6
7
 
7
8
  beforeEach(() => {
8
9
  wrapper = shallowMount(ContextMenu, {});
10
+ component = wrapper.vm;
9
11
  });
10
12
 
11
13
  test('Created hook', () => {
@@ -17,4 +19,11 @@ describe('ContextMenu component', () => {
17
19
  expect(wrapper.element).toMatchSnapshot();
18
20
  });
19
21
  });
22
+
23
+ describe('Methods', () =>{
24
+ it('Should handle click', () =>{
25
+ component.click();
26
+ expect(component.inputValue).toBeTruthy();
27
+ })
28
+ })
20
29
  });
@@ -19,22 +19,25 @@ export default {
19
19
  };
20
20
 
21
21
  export const Primary = () => ({
22
- components: { 'farm-copytoclipboard': CopyToClipboard },
23
22
  template: `<div style="max-width: 480px; padding-top: 80px; padding-left: 80px;">
24
23
  <farm-copytoclipboard toCopy="To be copied" />
25
24
  </div>`,
26
25
  });
27
26
 
28
27
  export const NoIcon = () => ({
29
- components: { 'farm-copytoclipboard': CopyToClipboard },
30
28
  template: `<div style="max-width: 480px; padding-top: 80px; padding-left: 80px;">
31
29
  <farm-copytoclipboard toCopy="To be copied" :isIcon="false" />
32
30
  </div>`,
33
31
  });
34
32
 
35
33
  export const CustomSuccessMessage = () => ({
36
- components: { 'farm-copytoclipboard': CopyToClipboard },
37
34
  template: `<div style="max-width: 480px; padding-top: 80px; padding-left: 80px;">
38
- <farm-copytoclipboard toCopy="To be copied" success-message="Custom Succes Message" />
35
+ <farm-copytoclipboard toCopy="To be copied" success-message="Custom Success Message" />
36
+ </div>`,
37
+ });
38
+
39
+ export const CustomTooltipColor = () => ({
40
+ template: `<div style="max-width: 480px; padding-top: 80px; padding-left: 80px;">
41
+ <farm-copytoclipboard toCopy="To be copied" tooltip-color="info" />
39
42
  </div>`,
40
43
  });
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <farm-tooltip v-model="show">
2
+ <farm-tooltip v-model="show" :color="tooltipColor">
3
3
  {{ feedbackMessage }}
4
4
  <template v-slot:activator="{}">
5
5
  <farm-btn v-if="isIcon" title="Copiar" icon :disabled="disabled" @click="onClick">
@@ -14,7 +14,7 @@
14
14
  </template>
15
15
 
16
16
  <script lang="ts">
17
- import Vue, { ref, toRefs } from 'vue';
17
+ import Vue, { PropType, ref, toRefs } from 'vue';
18
18
  import { toClipboard } from '@farm-investimentos/front-mfe-libs-ts';
19
19
 
20
20
  export default Vue.extend({
@@ -35,6 +35,24 @@ export default Vue.extend({
35
35
  type: String,
36
36
  default: 'Conteúdo copiado para a área de trabalho',
37
37
  },
38
+ /**
39
+ * Tooltip color
40
+ */
41
+ tooltipColor: {
42
+ type: String as PropType<
43
+ | 'primary'
44
+ | 'secondary'
45
+ | 'neutral'
46
+ | 'info'
47
+ | 'success'
48
+ | 'error'
49
+ | 'warning'
50
+ | 'success'
51
+ | 'extra-1'
52
+ | 'extra-2'
53
+ >,
54
+ default: 'secondary',
55
+ },
38
56
  },
39
57
  setup(props) {
40
58
  const show = ref(false);
@@ -2,7 +2,7 @@
2
2
  @import '../../configurations/mixins';
3
3
 
4
4
  .farm-dialog__footer {
5
- border-top: 1px solid var(--v-gray-lighten2);
5
+ border-top: 1px solid var(--farm-stroke-base);
6
6
  padding: gutter('md');
7
7
  display: flex;
8
8
  flex-direction: row;
@@ -10,7 +10,7 @@
10
10
  }
11
11
 
12
12
  .farm-btn {
13
- margin-left: gutter();
13
+ margin-left: gutter('sm');
14
14
  margin-top: 0;
15
15
 
16
16
  .farm-icon {
@@ -234,4 +234,60 @@ export const DatePickers = () => ({
234
234
  </div>
235
235
  </farm-form>
236
236
  `,
237
+ });
238
+
239
+ export const Grid = () => ({
240
+ data() {
241
+ return {
242
+
243
+ };
244
+ },
245
+ template: `
246
+ <farm-container>
247
+ <farm-form ref="form">
248
+
249
+ <farm-row>
250
+ <farm-col cols="12" md="3">
251
+ <farm-label>Label 1</farm-label>
252
+ <farm-textfield />
253
+ </farm-col>
254
+ <farm-col cols="12" md="3">
255
+ <farm-label>Label 2</farm-label>
256
+ <farm-textfield />
257
+ </farm-col>
258
+ <farm-col cols="12" md="3">
259
+ <farm-label>Label 3</farm-label>
260
+ <farm-textfield />
261
+ </farm-col>
262
+ <farm-col cols="12" md="3">
263
+ <farm-label>Label 4</farm-label>
264
+ <farm-textfield />
265
+ </farm-col>
266
+ <farm-col cols="12" md="6">
267
+ <farm-label>Label 6</farm-label>
268
+ <farm-textfield />
269
+ </farm-col>
270
+ <farm-col cols="12" md="2">
271
+ <farm-label>Label 7</farm-label>
272
+ <farm-textfield />
273
+ </farm-col>
274
+ <farm-col cols="12" md="4">
275
+ <farm-label>Label 4</farm-label>
276
+ <farm-textfield />
277
+ </farm-col>
278
+ </farm-row>
279
+
280
+ <farm-row extra-decrease>
281
+ <farm-container-footer>
282
+ <farm-row>
283
+ <farm-col align="right">
284
+ <farm-btn color="secondary" outlined @click="$refs.form.reset()" class="mr-2">Reset</farm-btn>
285
+ <farm-btn>Salvar</farm-btn>
286
+ </farm-col>
287
+ </farm-row>
288
+ </farm-container-footer>
289
+ </farm-row>
290
+ </farm-form>
291
+ </farm-container>
292
+ `,
237
293
  });
@@ -149,3 +149,37 @@ export const CustomTag = () => ({
149
149
  </farm-idcaption>
150
150
  `,
151
151
  });
152
+
153
+ export const CustomSuccessMessageAfterCopyToClipboard = () => ({
154
+ template: `
155
+ <farm-idcaption
156
+ icon="account-box-outline"
157
+ copy-text="Custom Success Message to be copied"
158
+ success-message="Custom Success Message"
159
+ >
160
+ <template v-slot:title>
161
+ <b>Upper Line Text</b>
162
+ </template>
163
+ <template v-slot:subtitle>
164
+ <b>Lower:</b> Line Text Line Text Line Text
165
+ </template>
166
+ </farm-idcaption>
167
+ `,
168
+ });
169
+
170
+ export const CustomTooltipColor = () => ({
171
+ template: `
172
+ <farm-idcaption
173
+ icon="account-box-outline"
174
+ copy-text="Custom Success Message to be copied"
175
+ tooltip-color="info"
176
+ >
177
+ <template v-slot:title>
178
+ <b>Upper Line Text</b>
179
+ </template>
180
+ <template v-slot:subtitle>
181
+ <b>Lower:</b> Line Text Line Text Line Text
182
+ </template>
183
+ </farm-idcaption>
184
+ `,
185
+ });
@@ -16,7 +16,12 @@
16
16
  <farm-caption variation="regular" color="gray" v-if="hasSubtitle">
17
17
  <span>
18
18
  <slot name="subtitle"></slot>
19
- <farm-copytoclipboard v-if="copyText" :toCopy="copyText" />
19
+ <farm-copytoclipboard
20
+ v-if="copyText"
21
+ :toCopy="copyText"
22
+ :successMessage="successMessage"
23
+ :tooltipColor="tooltipColor"
24
+ />
20
25
  </span>
21
26
  </farm-caption>
22
27
  </div>
@@ -59,6 +64,7 @@ export default Vue.extend({
59
64
  */
60
65
  copyText: {
61
66
  type: String,
67
+ default: 'Conteúdo copiado para a área de trabalho',
62
68
  },
63
69
  /**
64
70
  * Has link?
@@ -67,6 +73,31 @@ export default Vue.extend({
67
73
  type: Boolean,
68
74
  default: false,
69
75
  },
76
+ /**
77
+ * Success message content after copy
78
+ */
79
+ successMessage: {
80
+ type: String,
81
+ default: 'Conteúdo copiado para a área de trabalho',
82
+ },
83
+ /**
84
+ * Tooltip color
85
+ */
86
+ tooltipColor: {
87
+ type: String as PropType<
88
+ | 'primary'
89
+ | 'secondary'
90
+ | 'neutral'
91
+ | 'info'
92
+ | 'success'
93
+ | 'error'
94
+ | 'warning'
95
+ | 'success'
96
+ | 'extra-1'
97
+ | 'extra-2'
98
+ >,
99
+ default: 'secondary',
100
+ },
70
101
  },
71
102
 
72
103
  setup(_, { slots }) {
@@ -79,5 +110,5 @@ export default Vue.extend({
79
110
  </script>
80
111
 
81
112
  <style lang="scss" scoped>
82
- @import './IdCaption.scss';
113
+ @import './IdCaption';
83
114
  </style>
@@ -4,8 +4,6 @@ import { Meta } from '@storybook/addon-docs';
4
4
 
5
5
  # Display Breakpoints
6
6
 
7
- <farm-col>aaa</farm-col>
8
-
9
7
  <table width="100%">
10
8
  <thead>
11
9
  <tr>
@@ -1,7 +1,7 @@
1
1
  .farm-line {
2
2
  width: 100%;
3
3
  border: none;
4
- border-bottom: 1px solid var(--v-gray-lighten2);
4
+ border-bottom: 1px solid var(--farm-stroke-base);
5
5
  height: 1px;
6
6
  margin-top: 0;
7
7
  &--spacing {