@farm-investimentos/front-mfe-components 11.5.4 → 11.5.6

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.4",
3
+ "version": "11.5.6",
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,55 @@ 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
+ open
31
+ </farm-btn>
32
+ </template>
33
+ </farm-contextmenu>
34
+ </div>`,
35
+ });
36
+
37
+ export const LongActivator = () => ({
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
+ >
46
+ Very long Activator
47
+ </farm-btn>
48
+ </template>
49
+ </farm-contextmenu>
50
+ </div>`,
51
+ });
52
+
53
+ export const IconActivator = () => ({
54
+ template: `<div style="padding-left: 120px; padding-top: 80px; display: flex;">
55
+ <farm-contextmenu>
56
+ some text
57
+ <template v-slot:activator="{ on, attrs }">
58
+ <farm-btn
59
+ v-bind="attrs"
60
+ v-on="on"
61
+ icon
62
+ >
63
+ <farm-icon>help-circle</farm-icon>
64
+ </farm-btn>
65
+ </template>
66
+ </farm-contextmenu>
67
+ </div>`,
68
+ });
69
+
70
+ export const VModel = () => ({
22
71
  data() {
23
72
  return {
24
73
  value: false,
@@ -160,4 +209,4 @@ export const MaxHeight = () => ({
160
209
  </template>
161
210
  </farm-contextmenu>
162
211
  </div>`,
163
- });
212
+ });
@@ -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,8 +104,16 @@ export default Vue.extend({
102
104
  window.scrollY +
103
105
  (!bottom.value ? 0 : activatorBoundingClientRect.height);
104
106
 
107
+ //
108
+
105
109
  let offsetLeft = activatorBoundingClientRect.left;
106
- if (popupClientRect.width > activatorBoundingClientRect.width) {
110
+
111
+ styles.minWidth =
112
+ (activatorBoundingClientRect.width > 96
113
+ ? parseInt(activatorBoundingClientRect.width)
114
+ : 96) + 'px';
115
+
116
+ if(activatorBoundingClientRect.width < 96) {
107
117
  const w = popupClientRect.width < 96 ? 96 : popupClientRect.width;
108
118
  offsetLeft =
109
119
  activatorBoundingClientRect.left +
@@ -111,16 +121,11 @@ export default Vue.extend({
111
121
  w / 2;
112
122
  }
113
123
 
114
- styles.minWidth =
115
- (activatorBoundingClientRect.width > 96
116
- ? parseInt(activatorBoundingClientRect.width)
117
- : 96) + 'px';
118
-
119
124
  //Do not allow to open outside window
120
-
125
+
121
126
  const rightEdge = offsetLeft + popupClientRect.width;
122
127
  const clientWidth = document.documentElement.clientWidth;
123
-
128
+
124
129
  if (rightEdge > clientWidth - 12) {
125
130
  offsetLeft = clientWidth - 12 - popupClientRect.width;
126
131
  }
@@ -131,7 +136,6 @@ export default Vue.extend({
131
136
  offsetTop -= bottomEdge - window.scrollY - clientHeight + 12;
132
137
  }
133
138
 
134
-
135
139
  styles.top = `${offsetTop}px`;
136
140
  styles.left = `${offsetLeft}px`;
137
141
  styles.zIndex = calculateMainZindex();
@@ -145,12 +149,18 @@ export default Vue.extend({
145
149
  }
146
150
  });
147
151
 
152
+ const click = () => {
153
+ inputValue.value = !inputValue.value;
154
+ emit('input', inputValue.value);
155
+ };
156
+
148
157
  return {
149
158
  parent,
150
159
  popup,
151
160
  activator,
152
161
  styles,
153
162
  inputValue,
163
+ click,
154
164
  };
155
165
  },
156
166
  });
@@ -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);
@@ -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>