@farm-investimentos/front-mfe-components 15.14.12 → 15.14.14

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.14.12",
3
+ "version": "15.14.14",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -37,4 +37,4 @@
37
37
  left: 50% !important;
38
38
  transform: translate(-50%, -50%) !important;
39
39
  }
40
- }
40
+ }
@@ -21,6 +21,8 @@
21
21
  import { ref, watch, reactive, onBeforeUnmount, toRefs, defineComponent, nextTick } from 'vue';
22
22
  import { calculateMainZindex, isChildOfFixedElement } from '../../helpers';
23
23
 
24
+ const CLOSE_ALL_CONTEXT_MENUS_EVENT = 'farm-contextmenu:close-all';
25
+
24
26
  export default defineComponent({
25
27
  name: 'farm-contextmenu',
26
28
  props: {
@@ -89,6 +91,7 @@ export default defineComponent({
89
91
  } as any);
90
92
 
91
93
  const inputValue = ref(props.value);
94
+ const instanceContextId = Math.random().toString(36).substring(7);
92
95
 
93
96
  let hasBeenBoostrapped = false;
94
97
 
@@ -112,6 +115,15 @@ export default defineComponent({
112
115
  calculatePosition();
113
116
  };
114
117
 
118
+ const closeAllHandler = (event: CustomEvent) => {
119
+ if (event.detail?.exceptId !== instanceContextId && inputValue.value) {
120
+ inputValue.value = false;
121
+ emit('input', false);
122
+ }
123
+ };
124
+
125
+ window.addEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeAllHandler as any);
126
+
115
127
  watch(
116
128
  () => props.value,
117
129
  newValue => {
@@ -234,10 +246,20 @@ export default defineComponent({
234
246
  window.removeEventListener('click', outClick);
235
247
  document.querySelector('body').removeChild(popup.value);
236
248
  }
249
+ window.removeEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeAllHandler as any);
237
250
  });
238
251
 
239
252
  const click = () => {
240
- inputValue.value = !inputValue.value;
253
+ const willOpen = !inputValue.value;
254
+
255
+ if (willOpen) {
256
+ const closeEvent = new CustomEvent(CLOSE_ALL_CONTEXT_MENUS_EVENT, {
257
+ detail: { exceptId: instanceContextId }
258
+ });
259
+ window.dispatchEvent(closeEvent);
260
+ }
261
+
262
+ inputValue.value = willOpen;
241
263
  emit('input', inputValue.value);
242
264
  };
243
265
 
@@ -1,7 +1,8 @@
1
1
  <template>
2
2
  <farm-contextmenu
3
3
  :class="{ 'farm-context-menu': true, 'farm-context-menu--disabled': disabled }"
4
- v-model="value"
4
+ :value="value"
5
+ @input="value = $event"
5
6
  >
6
7
  <template v-slot:activator>
7
8
  <farm-btn
@@ -9,7 +10,6 @@
9
10
  title="Ver opções"
10
11
  color="secondary-green"
11
12
  :disabled="disabled"
12
- @click="toggleValue"
13
13
  >
14
14
  <farm-icon size="md">dots-horizontal</farm-icon>
15
15
  </farm-btn>
@@ -70,15 +70,11 @@ export default defineComponent({
70
70
  };
71
71
  },
72
72
  methods: {
73
- onClick(handler) {
73
+ onClick(handler: string) {
74
74
  if (handler !== undefined) {
75
75
  this.$emit(handler);
76
76
  }
77
77
  },
78
- toggleValue(event: MouseEvent) {
79
- this.value = !this.value;
80
- event.stopPropagation();
81
- },
82
78
  },
83
79
  });
84
80
  </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="farm-tabs-wrapper">
3
- <button
4
- class="farm-tabs-nav farm-tabs-nav--left"
3
+ <button
4
+ class="farm-tabs-nav farm-tabs-nav--left"
5
5
  @click="scrollLeft"
6
6
  @mouseenter="hoverLeft = true"
7
7
  @mouseleave="hoverLeft = false"
@@ -9,7 +9,7 @@
9
9
  >
10
10
  <farm-icon color="primary" size="24px">chevron-left</farm-icon>
11
11
  </button>
12
-
12
+
13
13
  <div class="farm-tabs" ref="tabsContainer">
14
14
  <div class="tabs" :class="{ 'tabs--disabled': !allowUserChange }">
15
15
  <div
@@ -51,9 +51,9 @@
51
51
  </div>
52
52
  </div>
53
53
  </div>
54
-
55
- <button
56
- class="farm-tabs-nav farm-tabs-nav--right"
54
+
55
+ <button
56
+ class="farm-tabs-nav farm-tabs-nav--right"
57
57
  @click="scrollRight"
58
58
  @mouseenter="hoverRight = true"
59
59
  @mouseleave="hoverRight = false"
@@ -142,7 +142,7 @@ export default defineComponent({
142
142
  const container = this.$refs.tabsContainer as HTMLElement;
143
143
  if (container) {
144
144
  const { scrollLeft, scrollWidth, clientWidth } = container;
145
-
145
+
146
146
  this.canScrollLeft = scrollLeft > 0;
147
147
  this.canScrollRight = scrollLeft < scrollWidth - clientWidth - 1;
148
148
  }
@@ -173,9 +173,11 @@ export default defineComponent({
173
173
  this.selected = this.initialSelect;
174
174
  },
175
175
  mounted() {
176
- this.updateScrollButtons();
176
+ this.$nextTick(() => {
177
+ this.updateScrollButtons();
178
+ });
177
179
  window.addEventListener('resize', this.updateScrollButtons);
178
-
180
+
179
181
  const container = this.$refs.tabsContainer as HTMLElement;
180
182
  if (container) {
181
183
  container.addEventListener('scroll', this.updateScrollButtons);
@@ -183,7 +185,7 @@ export default defineComponent({
183
185
  },
184
186
  beforeUnmount() {
185
187
  window.removeEventListener('resize', this.updateScrollButtons);
186
-
188
+
187
189
  const container = this.$refs.tabsContainer as HTMLElement;
188
190
  if (container) {
189
191
  container.removeEventListener('scroll', this.updateScrollButtons);