@webitel/ui-sdk 3.1.98 → 3.1.99

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.98",
3
+ "version": "3.1.99",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -39,7 +39,6 @@
39
39
  "deep-copy": "^1.4.2",
40
40
  "deep-equal": "^2.0.3",
41
41
  "file-saver": "^2.0.2",
42
- "floating-vue": "^2.0.0-beta.20",
43
42
  "jszip": "^3.5.0",
44
43
  "jszip-utils": "^0.1.0",
45
44
  "node-polyfill-webpack-plugin": "^1.1.4",
@@ -1,19 +1,21 @@
1
1
  <template>
2
- <v-dropdown
2
+ <wt-tooltip
3
3
  class="wt-context-menu"
4
- :shown="visible"
4
+ :visible="visible"
5
5
  :triggers="['click', 'touch']"
6
6
  placement="bottom-end"
7
7
  >
8
- <slot name="activator"></slot>
9
- <template #popper="{ hide }">
8
+ <template v-slot:activator>
9
+ <slot name="activator"></slot>
10
+ </template>
11
+ <template v-slot:default="{ hide }">
10
12
  <ul
11
13
  class="wt-context-menu__menu"
12
14
  :style="`width: ${width}; min-width: ${minWidth}; max-width: ${maxWidth};`"
13
15
  >
14
16
  <li
15
17
  class="wt-context-menu__option-wrapper"
16
- v-for="(option, index) in options"
18
+ v-for="(option, index) of options"
17
19
  :key="index"
18
20
  >
19
21
  <!-- <a> click.prevent prevents redirect to # -->
@@ -29,47 +31,47 @@
29
31
  </li>
30
32
  </ul>
31
33
  </template>
32
- </v-dropdown>
34
+ </wt-tooltip>
33
35
  </template>
34
36
 
35
- <script>
36
- export default {
37
- name: 'wt-context-menu',
38
- props: {
39
- options: {
40
- type: Array,
41
- required: true,
42
- description: '[{ text }] or [\'str\']',
43
- },
44
- visible: {
45
- type: Boolean,
46
- default: false,
47
- },
48
- width: {
49
- type: [String],
50
- default: 'auto',
51
- },
52
- minWidth: {
53
- type: [String],
54
- default: '160px',
55
- },
56
- maxWidth: {
57
- type: [String],
58
- default: '300px',
59
- },
37
+ <script setup>
38
+ const props = defineProps({
39
+ options: {
40
+ type: Array,
41
+ required: true,
42
+ description: '[{ text }]',
43
+ },
44
+ visible: {
45
+ type: Boolean,
46
+ },
47
+ width: {
48
+ type: [String],
49
+ default: 'auto',
60
50
  },
61
- methods: {
62
- handleOptionClick({ option, index, hide }) {
63
- this.$emit('click', { option, index });
64
- hide();
65
- },
51
+ minWidth: {
52
+ type: [String],
53
+ default: '160px',
66
54
  },
67
- };
55
+ maxWidth: {
56
+ type: [String],
57
+ default: '300px',
58
+ },
59
+ });
60
+
61
+ function handleOptionClick({ option, index, hide }) {
62
+ this.$emit('click', { option, index });
63
+ hide();
64
+ }
65
+
68
66
  </script>
69
67
 
70
68
  <style lang="scss" scoped>
71
69
  .wt-context-menu {
72
70
  line-height: 0;
71
+
72
+ &.wt-tooltip :deep(.wt-tooltip__floating) {
73
+ padding: 0;
74
+ }
73
75
  }
74
76
 
75
77
  .wt-context-menu__menu {
@@ -85,14 +87,17 @@ export default {
85
87
  &:first-of-type {
86
88
  border-radius: var(--border-radius) var(--border-radius) 0 0;
87
89
  }
90
+
88
91
  &:last-of-type {
89
92
  border-radius: 0 0 var(--border-radius) var(--border-radius);
90
93
  }
94
+
91
95
  &:only-of-type {
92
96
  border-radius: var(--border-radius);
93
97
  }
98
+
94
99
  &:hover {
95
- background-color: var( --context-menu-option-color--hover);
100
+ background-color: var(--context-menu-option-color--hover);
96
101
  transition: var(--transition);
97
102
  }
98
103
  }
@@ -15,16 +15,19 @@
15
15
  <div
16
16
  ref="floating"
17
17
  class="wt-tooltip__floating"
18
+ v-clickaway="hideTooltip"
18
19
  :class="[popperClass]"
19
20
  :style="floatingStyles"
20
21
  >
21
- <slot></slot>
22
+ <slot v-bind="{ hide: hideTooltip }"></slot>
22
23
  </div>
23
24
  </div>
24
25
  </template>
25
26
 
26
27
  <script setup>
27
- import { ref, onMounted, onBeforeUnmount } from 'vue';
28
+ import {
29
+ ref, onMounted, onBeforeUnmount, watch,
30
+ } from 'vue';
28
31
  import {
29
32
  useFloating, autoPlacement, shift, flip, offset,
30
33
  } from '@floating-ui/vue';
@@ -48,6 +51,10 @@ const HIDE_EVENT_MAP = {
48
51
  };
49
52
 
50
53
  const props = defineProps({
54
+ visible: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
51
58
  contrast: {
52
59
  type: Boolean,
53
60
  default: false,
@@ -75,7 +82,7 @@ const floating = ref(null);
75
82
 
76
83
  const isVisible = ref(false);
77
84
 
78
- const showTooltip = (event) => {
85
+ const showTooltip = (event = {}) => {
79
86
  if (isVisible.value) return;
80
87
  isVisible.value = true;
81
88
 
@@ -83,7 +90,7 @@ const showTooltip = (event) => {
83
90
  event.usedByTooltip = true;
84
91
  };
85
92
 
86
- const hideTooltip = (event) => {
93
+ const hideTooltip = (event = {}) => {
87
94
  if (event.usedByTooltip) return;
88
95
  isVisible.value = false;
89
96
  };
@@ -132,11 +139,20 @@ const unsubscribeTriggers = () => {
132
139
  };
133
140
 
134
141
  const { floatingStyles } = useFloating(activator, floating, {
142
+ placement: props.placement,
135
143
  // https://floating-ui.com/docs/middleware
136
- middleware: [autoPlacement(), shift(), flip(), offset(8)],
144
+ middleware: [shift(), flip(), offset(8)],
137
145
  });
138
146
 
139
- onMounted(() => subscribeTriggers());
147
+ watch(props.visible, (value) => {
148
+ if (value) showTooltip();
149
+ else hideTooltip();
150
+ });
151
+
152
+ onMounted(() => {
153
+ subscribeTriggers();
154
+ if (props.visible) showTooltip();
155
+ });
140
156
  onBeforeUnmount(() => unsubscribeTriggers());
141
157
  </script>
142
158