@webitel/ui-sdk 3.1.103 → 3.1.105

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": "@webitel/ui-sdk",
3
- "version": "3.1.103",
3
+ "version": "3.1.105",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -13,6 +13,7 @@
13
13
  <slot name="activator"></slot>
14
14
  </div>
15
15
  <div
16
+ v-if="isVisible"
16
17
  ref="floating"
17
18
  class="wt-tooltip__floating"
18
19
  v-clickaway="hideTooltip"
@@ -29,7 +30,7 @@ import {
29
30
  ref, onMounted, onBeforeUnmount, watch,
30
31
  } from 'vue';
31
32
  import {
32
- useFloating, autoPlacement, shift, flip, offset,
33
+ useFloating, autoPlacement, shift, flip, offset, autoUpdate,
33
34
  } from '@floating-ui/vue';
34
35
 
35
36
  // https://github.com/Akryum/floating-vue/blob/main/packages/floating-vue/src/util/events.ts
@@ -138,12 +139,18 @@ const unsubscribeTriggers = () => {
138
139
  unsetEventListeners(floating.value, props.popperTriggers);
139
140
  };
140
141
 
142
+ // https://floating-ui.com/docs/misc#clipping
141
143
  const { floatingStyles } = useFloating(activator, floating, {
142
144
  placement: props.placement === 'auto' ? null : props.placement,
143
- strategy: 'fixed',
145
+ strategy: 'fixed', // https://floating-ui.com/docs/computeposition#strategy
144
146
  // https://floating-ui.com/docs/middleware
147
+
148
+ /* WE SHOULD USE v-if INSTEAD OF OPACITY VISIBILITY
149
+ TOGGLE BECAUSE OF PERFORMANCE ISSUES, RELATED TO USAGE OF AUTO_UPDATE OF POSITIONS
150
+ */
151
+ whileElementsMounted: autoUpdate, // https://floating-ui.com/docs/vue#anchoring
145
152
  middleware: [
146
- shift(), offset(8),
153
+ shift(), offset(4),
147
154
  props.placement === 'auto' ? autoPlacement() : flip(),
148
155
  ],
149
156
  });
@@ -177,7 +184,6 @@ onBeforeUnmount(() => unsubscribeTriggers());
177
184
  border-radius: var(--border-radius);
178
185
  box-shadow: var(--elevation-10);
179
186
  z-index: 1000;
180
- transition: var(--transition);
181
187
  }
182
188
 
183
189
  &--contrast {
@@ -187,18 +193,4 @@ onBeforeUnmount(() => unsubscribeTriggers());
187
193
  }
188
194
  }
189
195
  }
190
-
191
- .wt-tooltip {
192
- .wt-tooltip__floating {
193
- opacity: 0;
194
- pointer-events: none;
195
- }
196
-
197
- &--visible {
198
- .wt-tooltip__floating {
199
- opacity: 1;
200
- pointer-events: auto;
201
- }
202
- }
203
- }
204
196
  </style>
@@ -1,6 +1,13 @@
1
1
  import { shallowMount, mount } from '@vue/test-utils';
2
2
  import WtSelectButton from '../wt-button-select.vue';
3
3
 
4
+ // helps to mock @floating-ui/vue autoUpdate method
5
+ global.ResizeObserver = jest.fn().mockImplementation(() => ({
6
+ observe: jest.fn(),
7
+ unobserve: jest.fn(),
8
+ disconnect: jest.fn(),
9
+ }));
10
+
4
11
  describe('WtSelectButton', () => {
5
12
  it('renders a component', () => {
6
13
  const wrapper = shallowMount(WtSelectButton);
@@ -22,6 +29,9 @@ describe('WtSelectButton', () => {
22
29
  data: () => ({
23
30
  isOpened: true,
24
31
  }),
32
+ props: {
33
+ options: [],
34
+ },
25
35
  });
26
36
  const wtIcon = wrapper.find('.wt-button-select__select-arrow');
27
37
  expect(wtIcon.classes()).toContain('wt-button-select__select-arrow--active');