bfg-common 1.3.280 → 1.3.281

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.
@@ -1,97 +1,96 @@
1
- <template>
2
- <div
3
- class="context-popup"
4
- :style="{
5
- top: currentContextMenuY,
6
- left: currentContextMenuX,
7
- }"
8
- >
9
- <common-context-recursion
10
- :action-loading="props.actionLoading"
11
- :items="props.contextMenu.items"
12
- @select-item="selectItem"
13
- />
14
- </div>
15
- </template>
16
-
17
- <script setup lang="ts">
18
- import {
19
- UI_I_ContextMenuItem,
20
- UI_I_ContextMenu,
21
- } from '~/components/common/context/lib/models/interfaces'
22
-
23
- const props = defineProps<{
24
- contextMenu: UI_I_ContextMenu
25
- actionLoading: string | null
26
- }>()
27
- const emits = defineEmits<{
28
- (event: 'select-item', value: UI_I_ContextMenuItem): void
29
- (event: 'hide'): void
30
- }>()
31
- const selectItem = (item: UI_I_ContextMenuItem): void => {
32
- emits('select-item', item)
33
- }
34
-
35
- const windowMousedown = (): void => {
36
- emits('hide')
37
- }
38
- onMounted(() => {
39
- window.addEventListener('mousedown', windowMousedown)
40
- })
41
- onUnmounted(() => {
42
- window.removeEventListener('mousedown', windowMousedown)
43
- })
44
-
45
- const currentContextMenuY = ref<string>('')
46
- const currentContextMenuX = ref<string>('')
47
- const setCurrentPositionsPopup = (): void => {
48
- const contextMenuY = props.contextMenu.y
49
- const contextMenuX = props.contextMenu.x
50
-
51
- const contextWrap: HTMLElement | null =
52
- document.querySelector('.context-wrap')
53
- const contextW = contextWrap?.offsetWidth || 0
54
- const contextH = contextWrap?.offsetHeight || 0
55
-
56
- const windowW = window.innerWidth
57
- const windowH = window.innerHeight
58
-
59
- if (contextMenuY + contextH >= windowH) {
60
- currentContextMenuY.value = 'auto'
61
- } else {
62
- currentContextMenuY.value = `${contextMenuY}px`
63
- }
64
-
65
- if (contextMenuX + contextW >= windowW) {
66
- const divisionW = windowW - contextW
67
- currentContextMenuX.value = `${divisionW}px`
68
- } else {
69
- currentContextMenuX.value = `${contextMenuX}px`
70
- }
71
- }
72
-
73
- watch(
74
- () => props.contextMenu.y,
75
- (newValue) => {
76
- if (!newValue) return
77
-
78
- setTimeout(() => {
79
- setCurrentPositionsPopup()
80
- }, 0)
81
- }
82
- )
83
- </script>
84
-
85
- <style scoped lang="scss">
86
- .context-popup {
87
- top: -9999px;
88
- left: -9999px;
89
- bottom: 0;
90
- border: none;
91
- box-sizing: content-box;
92
- overflow: visible;
93
- display: block;
94
- position: fixed;
95
- z-index: 10002;
96
- }
97
- </style>
1
+ <template>
2
+ <div
3
+ class="context-popup"
4
+ :style="{
5
+ top: currentContextMenuY,
6
+ left: currentContextMenuX,
7
+ }"
8
+ >
9
+ <common-context-recursion
10
+ :action-loading="props.actionLoading"
11
+ :items="props.contextMenu.items"
12
+ @select-item="selectItem"
13
+ />
14
+ </div>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ import {
19
+ UI_I_ContextMenuItem,
20
+ UI_I_ContextMenu,
21
+ } from '~/components/common/context/lib/models/interfaces'
22
+
23
+ const props = defineProps<{
24
+ contextMenu: UI_I_ContextMenu
25
+ actionLoading: string | null
26
+ }>()
27
+ const emits = defineEmits<{
28
+ (event: 'select-item', value: UI_I_ContextMenuItem): void
29
+ (event: 'hide'): void
30
+ }>()
31
+ const selectItem = (item: UI_I_ContextMenuItem): void => {
32
+ emits('select-item', item)
33
+ }
34
+
35
+ const currentContextMenuY = ref<string>('')
36
+ const currentContextMenuX = ref<string>('')
37
+ const setCurrentPositionsPopup = (): void => {
38
+ const contextMenuY = props.contextMenu.y
39
+ const contextMenuX = props.contextMenu.x
40
+
41
+ const contextWrap: HTMLElement | null =
42
+ document.querySelector('.context-wrap')
43
+ const contextW = contextWrap?.offsetWidth || 0
44
+ const contextH = contextWrap?.offsetHeight || 0
45
+
46
+ const windowW = window.innerWidth
47
+ const windowH = window.innerHeight
48
+
49
+ if (contextMenuY + contextH >= windowH) {
50
+ currentContextMenuY.value = 'auto'
51
+ } else {
52
+ currentContextMenuY.value = `${contextMenuY}px`
53
+ }
54
+
55
+ if (contextMenuX + contextW >= windowW) {
56
+ const divisionW = windowW - contextW
57
+ currentContextMenuX.value = `${divisionW}px`
58
+ } else {
59
+ currentContextMenuX.value = `${contextMenuX}px`
60
+ }
61
+ }
62
+
63
+ const windowMousedown = (): void => {
64
+ emits('hide')
65
+ }
66
+ watch(
67
+ () => props.contextMenu.y,
68
+ (newValue: number) => {
69
+ if (!newValue) return
70
+
71
+ if (newValue < 0) {
72
+ window.removeEventListener('mousedown', windowMousedown)
73
+ } else {
74
+ window.addEventListener('mousedown', windowMousedown)
75
+ }
76
+
77
+ setTimeout(() => {
78
+ setCurrentPositionsPopup()
79
+ }, 0)
80
+ }
81
+ )
82
+ </script>
83
+
84
+ <style scoped lang="scss">
85
+ .context-popup {
86
+ top: -9999px;
87
+ left: -9999px;
88
+ bottom: 0;
89
+ border: none;
90
+ box-sizing: content-box;
91
+ overflow: visible;
92
+ display: block;
93
+ position: fixed;
94
+ z-index: 10002;
95
+ }
96
+ </style>