bfg-common 1.3.611 → 1.3.613

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,21 +1,21 @@
1
- <template>
2
- <div>
3
- <span>{{ props.title }}:</span>
4
- <span>{{ formattedDateString }}</span>
5
- </div>
6
- </template>
7
-
8
- <script setup lang="ts">
9
- import { format } from 'date-fns'
10
- const props = defineProps<{
11
- title: string
12
- value: number
13
- }>()
14
-
15
- const getDateString = (dateAlias: number): string =>
16
- format(new Date(dateAlias), 'MM/dd/yyyy HH:mm:ss a')
17
-
18
- const formattedDateString = computed<string>(() => getDateString(props.value))
19
- </script>
20
-
21
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <div>
3
+ <span>{{ props.title }}:</span>
4
+ <span>{{ formattedDateString }}</span>
5
+ </div>
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import { format } from 'date-fns'
10
+ const props = defineProps<{
11
+ title: string
12
+ value: number
13
+ }>()
14
+
15
+ const getDateString = (dateAlias: number): string =>
16
+ format(new Date(dateAlias), 'MM/dd/yyyy HH:mm:ss a')
17
+
18
+ const formattedDateString = computed<string>(() => getDateString(props.value))
19
+ </script>
20
+
21
+ <style scoped lang="scss"></style>
@@ -1,86 +1,86 @@
1
- <template>
2
- <common-context-recursion-new
3
- v-if="isNewView"
4
- :items="props.items"
5
- :action-loading="props.actionLoading"
6
- :is-loading="isLoading"
7
- :test-id="props.testId"
8
- @select-item="selectItem"
9
- @toggle-items="toggleItems"
10
- />
11
- <common-context-recursion-old
12
- v-else
13
- :items="props.items"
14
- :action-loading="props.actionLoading"
15
- :is-loading="isLoading"
16
- :test-id="props.testId"
17
- @select-item="selectItem"
18
- @toggle-items="toggleItems"
19
- />
20
- </template>
21
-
22
- <script setup lang="ts">
23
- import type { UI_I_ContextMenuItem } from '~/components/common/context/lib/models/interfaces'
24
- import type { I_HTMLLiElement } from '~/components/common/context/recursion/lib/models/interfaces'
25
-
26
- const props = defineProps<{
27
- items: UI_I_ContextMenuItem[]
28
- actionLoading: string | null
29
- testId?: string
30
- }>()
31
- const emits = defineEmits<{
32
- (event: 'select-item', value: UI_I_ContextMenuItem): void
33
- }>()
34
-
35
- const { $store }: any = useNuxtApp()
36
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
37
-
38
- const isLoading = computed<boolean>(
39
- () => !!props.items.find((item) => item.actionType === props.actionLoading)
40
- )
41
-
42
- const selectItem = (item: UI_I_ContextMenuItem): void => {
43
- if (item.disabled) return
44
-
45
- emits('select-item', item)
46
- }
47
-
48
- const setElementPosition = (event: I_HTMLLiElement): void => {
49
- const top = event.target.getBoundingClientRect().top
50
- const childMenu = event.target.children[1].children[0]
51
- childMenu.style.top = `${top}px`
52
-
53
- const childMenuRect = (childMenu.getBoundingClientRect() as DOMRect) || null
54
-
55
- // Обрабатываем, если попап вишел за viewport (с права)
56
- if (childMenuRect.right > window.innerWidth) {
57
- event.target.classList.add('left')
58
- } else {
59
- event.target.classList.remove('left')
60
- }
61
-
62
- // Обрабатываем, если попап вишел за viewport (с низу)
63
- if (childMenuRect.bottom > window.innerHeight) {
64
- childMenu.style.top = 'auto'
65
- childMenu.style.bottom = '0px'
66
- } else {
67
- childMenu.style.bottom = 'unset'
68
- }
69
- }
70
-
71
- const toggleItems = (
72
- data: [UI_I_ContextMenuItem, boolean, I_HTMLLiElement]
73
- ): void => {
74
- const [item, show, e] = data
75
- if (!item.items.length || item.disabled) {
76
- return
77
- }
78
- item.isShowItems = show
79
-
80
- nextTick(() => {
81
- setElementPosition(e)
82
- })
83
- }
84
- </script>
85
-
86
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-context-recursion-new
3
+ v-if="isNewView"
4
+ :items="props.items"
5
+ :action-loading="props.actionLoading"
6
+ :is-loading="isLoading"
7
+ :test-id="props.testId"
8
+ @select-item="selectItem"
9
+ @toggle-items="toggleItems"
10
+ />
11
+ <common-context-recursion-old
12
+ v-else
13
+ :items="props.items"
14
+ :action-loading="props.actionLoading"
15
+ :is-loading="isLoading"
16
+ :test-id="props.testId"
17
+ @select-item="selectItem"
18
+ @toggle-items="toggleItems"
19
+ />
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import type { UI_I_ContextMenuItem } from '~/components/common/context/lib/models/interfaces'
24
+ import type { I_HTMLLiElement } from '~/components/common/context/recursion/lib/models/interfaces'
25
+
26
+ const props = defineProps<{
27
+ items: UI_I_ContextMenuItem[]
28
+ actionLoading: string | null
29
+ testId?: string
30
+ }>()
31
+ const emits = defineEmits<{
32
+ (event: 'select-item', value: UI_I_ContextMenuItem): void
33
+ }>()
34
+
35
+ const { $store }: any = useNuxtApp()
36
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
37
+
38
+ const isLoading = computed<boolean>(
39
+ () => !!props.items.find((item) => item.actionType === props.actionLoading)
40
+ )
41
+
42
+ const selectItem = (item: UI_I_ContextMenuItem): void => {
43
+ if (item.disabled) return
44
+
45
+ emits('select-item', item)
46
+ }
47
+
48
+ const setElementPosition = (event: I_HTMLLiElement): void => {
49
+ const top = event.target.getBoundingClientRect().top
50
+ const childMenu = event.target.children[1].children[0]
51
+ childMenu.style.top = `${top}px`
52
+
53
+ const childMenuRect = (childMenu.getBoundingClientRect() as DOMRect) || null
54
+
55
+ // Обрабатываем, если попап вишел за viewport (с права)
56
+ if (childMenuRect.right > window.innerWidth) {
57
+ event.target.classList.add('left')
58
+ } else {
59
+ event.target.classList.remove('left')
60
+ }
61
+
62
+ // Обрабатываем, если попап вишел за viewport (с низу)
63
+ if (childMenuRect.bottom > window.innerHeight) {
64
+ childMenu.style.top = 'auto'
65
+ childMenu.style.bottom = '0px'
66
+ } else {
67
+ childMenu.style.bottom = 'unset'
68
+ }
69
+ }
70
+
71
+ const toggleItems = (
72
+ data: [UI_I_ContextMenuItem, boolean, I_HTMLLiElement]
73
+ ): void => {
74
+ const [item, show, e] = data
75
+ if (!item.items.length || item.disabled) {
76
+ return
77
+ }
78
+ item.isShowItems = show
79
+
80
+ nextTick(() => {
81
+ setElementPosition(e)
82
+ })
83
+ }
84
+ </script>
85
+
86
+ <style scoped lang="scss"></style>
@@ -1,198 +1,198 @@
1
- <template>
2
- <ul class="context-wrap relative">
3
- <span v-if="props.isLoading">
4
- <ui-loader2 class="context-loader" test-id="context-menu" />
5
- </span>
6
- <li
7
- v-for="(item, key) in props.items"
8
- :key="key"
9
- :class="[
10
- 'menu-item',
11
- { disabled: item.disabled || isLoading },
12
- { 'show-children': item.isShowItems },
13
- { 'has-divider': item.hasBorderTop },
14
- ]"
15
- @mouseenter="emits('toggle-items', [item, true, $event])"
16
- @mouseleave="emits('toggle-items', [item, false, $event])"
17
- >
18
- <span
19
- class="context-link"
20
- :data-id="`${item.testId}-context-link`"
21
- @mousedown="emits('select-item', item)"
22
- >
23
- <span :class="['context-icon', item.iconClassName]" />
24
- <span class="menu-item-text">{{ item.name }}</span>
25
- <ui-icon v-if="item.items.length" name="arrow" class="arrow-icon" />
26
- <span v-if="item.shortcut" class="shortcut">{{ item.shortcut }}</span>
27
- </span>
28
-
29
- <div class="context-children">
30
- <common-context-recursion
31
- v-show="item.isShowItems"
32
- :action-loading="props.actionLoading"
33
- :items="item.items"
34
- @select-item="emits('select-item', $event)"
35
- />
36
- </div>
37
- </li>
38
- </ul>
39
- </template>
40
-
41
- <script setup lang="ts">
42
- import type { UI_I_ContextMenuItem } from '~/components/common/context/lib/models/interfaces'
43
- import type { I_HTMLLiElement } from '~/components/common/context/recursion/lib/models/interfaces'
44
-
45
- const props = defineProps<{
46
- items: UI_I_ContextMenuItem[]
47
- actionLoading: string | null
48
- isLoading: boolean
49
- testId?: string
50
- }>()
51
-
52
- const emits = defineEmits<{
53
- (event: 'select-item', value: UI_I_ContextMenuItem): void
54
- (
55
- event: 'toggle-items',
56
- value: [UI_I_ContextMenuItem, boolean, I_HTMLLiElement]
57
- ): void
58
- }>()
59
- </script>
60
-
61
- <style scoped lang="scss">
62
- .context-wrap {
63
- width: auto;
64
- max-width: 400px;
65
- background: var(--context-menu-bg-color);
66
- border-radius: 8px;
67
- user-select: none;
68
- list-style: none;
69
- max-height: 100vh;
70
- box-shadow: 0 4px 20px 0 #0000001f;
71
- padding: 8px;
72
-
73
- .context-loader {
74
- position: absolute;
75
- width: 60px;
76
- top: calc(50% - 30px);
77
- left: calc(50% - 30px);
78
- }
79
-
80
- .menu-item {
81
- position: relative;
82
- color: var(--context-menu-text-color);
83
- cursor: pointer;
84
- border-radius: 4px;
85
-
86
- &.show-children::after {
87
- content: '';
88
- position: absolute;
89
- top: 0;
90
- left: 100%;
91
- width: 12px;
92
- height: 100%;
93
- }
94
-
95
- &:not(:last-child) {
96
- margin-bottom: 8px;
97
- }
98
-
99
- &:not(.disabled) > .context-link:hover {
100
- background-color: var(--context-menu-item-bg-hover-color);
101
- color: var(--context-menu-text-hover-color);
102
- }
103
- &.disabled {
104
- opacity: 0.5;
105
- user-select: none;
106
- cursor: default;
107
- }
108
- &.left {
109
- &.show-children::after {
110
- left: -12px;
111
- }
112
- :deep(.context-children) {
113
- left: -12px;
114
-
115
- .context-wrap {
116
- transform: translateX(-100%);
117
- left: auto;
118
- }
119
- }
120
- }
121
-
122
- &.has-divider::before {
123
- content: '';
124
- display: block;
125
- height: 0.03rem;
126
- background-color: var(--context-menu-border-color);
127
- margin-bottom: 8px;
128
- }
129
-
130
- .context-link {
131
- position: relative;
132
- overflow: hidden;
133
- text-overflow: ellipsis;
134
- white-space: nowrap;
135
- display: flex;
136
- align-items: center;
137
- user-select: none;
138
- border-radius: 4px;
139
- padding: 6px 8px;
140
-
141
- .menu-item-text {
142
- flex: 1 1 0;
143
- font-size: 13px;
144
- font-weight: 400;
145
- line-height: 15.73px;
146
- }
147
-
148
- .context-icon {
149
- margin-right: 8px;
150
- width: 20px;
151
- height: 20px;
152
- }
153
-
154
- .arrow-icon {
155
- position: absolute;
156
- top: 50%;
157
- margin-top: -8px;
158
- right: 4px;
159
- display: inline-block;
160
- width: 16px;
161
- height: 16px;
162
- overflow: hidden;
163
- transform: rotate(90deg);
164
- }
165
-
166
- .shortcut {
167
- padding-left: 10px;
168
- }
169
- }
170
-
171
- .context-children {
172
- position: absolute;
173
- top: 0;
174
- left: calc(100% + 12px);
175
-
176
- .context-wrap {
177
- position: fixed;
178
- }
179
- }
180
- }
181
- }
182
- </style>
183
- <style>
184
- :root.is-new-view {
185
- --context-menu-bg-color: #ffffff;
186
- --context-menu-item-bg-hover-color: rgba(233, 235, 237, 0.4);
187
- --context-menu-text-color: #4d5d69;
188
- --context-menu-text-hover-color: #182531;
189
- --context-menu-border-color: #e9ebed;
190
- }
191
- :root.is-new-view.dark-theme {
192
- --context-menu-bg-color: #334453;
193
- --context-menu-item-bg-hover-color: rgba(233, 235, 237, 0.06);
194
- --context-menu-text-color: #e9eaec;
195
- --context-menu-text-hover-color: #ffffff;
196
- --context-menu-border-color: rgba(233, 235, 237, 0.12);
197
- }
198
- </style>
1
+ <template>
2
+ <ul class="context-wrap relative">
3
+ <span v-if="props.isLoading">
4
+ <ui-loader2 class="context-loader" test-id="context-menu" />
5
+ </span>
6
+ <li
7
+ v-for="(item, key) in props.items"
8
+ :key="key"
9
+ :class="[
10
+ 'menu-item',
11
+ { disabled: item.disabled || isLoading },
12
+ { 'show-children': item.isShowItems },
13
+ { 'has-divider': item.hasBorderTop },
14
+ ]"
15
+ @mouseenter="emits('toggle-items', [item, true, $event])"
16
+ @mouseleave="emits('toggle-items', [item, false, $event])"
17
+ >
18
+ <span
19
+ class="context-link"
20
+ :data-id="`${item.testId}-context-link`"
21
+ @mousedown="emits('select-item', item)"
22
+ >
23
+ <span :class="['context-icon', item.iconClassName]" />
24
+ <span class="menu-item-text">{{ item.name }}</span>
25
+ <ui-icon v-if="item.items.length" name="arrow" class="arrow-icon" />
26
+ <span v-if="item.shortcut" class="shortcut">{{ item.shortcut }}</span>
27
+ </span>
28
+
29
+ <div class="context-children">
30
+ <common-context-recursion
31
+ v-show="item.isShowItems"
32
+ :action-loading="props.actionLoading"
33
+ :items="item.items"
34
+ @select-item="emits('select-item', $event)"
35
+ />
36
+ </div>
37
+ </li>
38
+ </ul>
39
+ </template>
40
+
41
+ <script setup lang="ts">
42
+ import type { UI_I_ContextMenuItem } from '~/components/common/context/lib/models/interfaces'
43
+ import type { I_HTMLLiElement } from '~/components/common/context/recursion/lib/models/interfaces'
44
+
45
+ const props = defineProps<{
46
+ items: UI_I_ContextMenuItem[]
47
+ actionLoading: string | null
48
+ isLoading: boolean
49
+ testId?: string
50
+ }>()
51
+
52
+ const emits = defineEmits<{
53
+ (event: 'select-item', value: UI_I_ContextMenuItem): void
54
+ (
55
+ event: 'toggle-items',
56
+ value: [UI_I_ContextMenuItem, boolean, I_HTMLLiElement]
57
+ ): void
58
+ }>()
59
+ </script>
60
+
61
+ <style scoped lang="scss">
62
+ .context-wrap {
63
+ width: auto;
64
+ max-width: 400px;
65
+ background: var(--context-menu-bg-color);
66
+ border-radius: 8px;
67
+ user-select: none;
68
+ list-style: none;
69
+ max-height: 100vh;
70
+ box-shadow: 0 4px 20px 0 #0000001f;
71
+ padding: 8px;
72
+
73
+ .context-loader {
74
+ position: absolute;
75
+ width: 60px;
76
+ top: calc(50% - 30px);
77
+ left: calc(50% - 30px);
78
+ }
79
+
80
+ .menu-item {
81
+ position: relative;
82
+ color: var(--context-menu-text-color);
83
+ cursor: pointer;
84
+ border-radius: 4px;
85
+
86
+ &.show-children::after {
87
+ content: '';
88
+ position: absolute;
89
+ top: 0;
90
+ left: 100%;
91
+ width: 12px;
92
+ height: 100%;
93
+ }
94
+
95
+ &:not(:last-child) {
96
+ margin-bottom: 8px;
97
+ }
98
+
99
+ &:not(.disabled) > .context-link:hover {
100
+ background-color: var(--context-menu-item-bg-hover-color);
101
+ color: var(--context-menu-text-hover-color);
102
+ }
103
+ &.disabled {
104
+ opacity: 0.5;
105
+ user-select: none;
106
+ cursor: default;
107
+ }
108
+ &.left {
109
+ &.show-children::after {
110
+ left: -12px;
111
+ }
112
+ :deep(.context-children) {
113
+ left: -12px;
114
+
115
+ .context-wrap {
116
+ transform: translateX(-100%);
117
+ left: auto;
118
+ }
119
+ }
120
+ }
121
+
122
+ &.has-divider::before {
123
+ content: '';
124
+ display: block;
125
+ height: 0.03rem;
126
+ background-color: var(--context-menu-border-color);
127
+ margin-bottom: 8px;
128
+ }
129
+
130
+ .context-link {
131
+ position: relative;
132
+ overflow: hidden;
133
+ text-overflow: ellipsis;
134
+ white-space: nowrap;
135
+ display: flex;
136
+ align-items: center;
137
+ user-select: none;
138
+ border-radius: 4px;
139
+ padding: 6px 8px;
140
+
141
+ .menu-item-text {
142
+ flex: 1 1 0;
143
+ font-size: 13px;
144
+ font-weight: 400;
145
+ line-height: 15.73px;
146
+ }
147
+
148
+ .context-icon {
149
+ margin-right: 8px;
150
+ width: 20px;
151
+ height: 20px;
152
+ }
153
+
154
+ .arrow-icon {
155
+ position: absolute;
156
+ top: 50%;
157
+ margin-top: -8px;
158
+ right: 4px;
159
+ display: inline-block;
160
+ width: 16px;
161
+ height: 16px;
162
+ overflow: hidden;
163
+ transform: rotate(90deg);
164
+ }
165
+
166
+ .shortcut {
167
+ padding-left: 10px;
168
+ }
169
+ }
170
+
171
+ .context-children {
172
+ position: absolute;
173
+ top: 0;
174
+ left: calc(100% + 12px);
175
+
176
+ .context-wrap {
177
+ position: fixed;
178
+ }
179
+ }
180
+ }
181
+ }
182
+ </style>
183
+ <style>
184
+ :root.is-new-view {
185
+ --context-menu-bg-color: #ffffff;
186
+ --context-menu-item-bg-hover-color: rgba(233, 235, 237, 0.4);
187
+ --context-menu-text-color: #4d5d69;
188
+ --context-menu-text-hover-color: #182531;
189
+ --context-menu-border-color: #e9ebed;
190
+ }
191
+ :root.is-new-view.dark-theme {
192
+ --context-menu-bg-color: #334453;
193
+ --context-menu-item-bg-hover-color: rgba(233, 235, 237, 0.06);
194
+ --context-menu-text-color: #e9eaec;
195
+ --context-menu-text-hover-color: #ffffff;
196
+ --context-menu-border-color: rgba(233, 235, 237, 0.12);
197
+ }
198
+ </style>