bfg-common 1.2.69 → 1.2.71
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/components/atoms/nav/NavBar.vue +128 -116
- package/package.json +1 -1
|
@@ -1,116 +1,128 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<nav
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<nav
|
|
3
|
+
:id="id"
|
|
4
|
+
:class="[
|
|
5
|
+
'nav',
|
|
6
|
+
{ 'not-collapse': notCollapse },
|
|
7
|
+
{ 'is-collapsed': collapsedItems.length && !notCollapse },
|
|
8
|
+
]"
|
|
9
|
+
>
|
|
10
|
+
<ul>
|
|
11
|
+
<li v-for="(item, key) in props.items" :key="key" class="nav-item">
|
|
12
|
+
<atoms-collapse-nav-item
|
|
13
|
+
:test-id="`${props.testId}-item-${key}`"
|
|
14
|
+
:is-link="props.isLink"
|
|
15
|
+
:item="item"
|
|
16
|
+
:value="props.modelValue"
|
|
17
|
+
btn-class="btn btn-link nav-link"
|
|
18
|
+
@change="change"
|
|
19
|
+
/>
|
|
20
|
+
</li>
|
|
21
|
+
<atoms-collapse-nav
|
|
22
|
+
v-show="collapsedItems.length && !notCollapse"
|
|
23
|
+
:test-id="`${props.testId}-container`"
|
|
24
|
+
:items="collapsedItems"
|
|
25
|
+
:is-link="props.isLink"
|
|
26
|
+
:value="props.modelValue"
|
|
27
|
+
@change="change"
|
|
28
|
+
/>
|
|
29
|
+
</ul>
|
|
30
|
+
</nav>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { UI_I_CollapseNavItem } from '~/components/atoms/collapse/models/interfaces'
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(
|
|
37
|
+
defineProps<{
|
|
38
|
+
testId?: string
|
|
39
|
+
items: UI_I_CollapseNavItem[]
|
|
40
|
+
modelValue?: number | string
|
|
41
|
+
isLink?: boolean
|
|
42
|
+
notCollapse?: boolean
|
|
43
|
+
}>(),
|
|
44
|
+
{ testId: 'ui-nav-bar' }
|
|
45
|
+
)
|
|
46
|
+
const emits = defineEmits<{
|
|
47
|
+
(event: 'update:model-value', num: number): void
|
|
48
|
+
(event: 'change', num: number): void
|
|
49
|
+
}>()
|
|
50
|
+
|
|
51
|
+
const change = (value: number): void => {
|
|
52
|
+
emits('update:model-value', value)
|
|
53
|
+
emits('change', value)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const visibleCount = ref(props.items.length)
|
|
57
|
+
const collapsedItems = computed<UI_I_CollapseNavItem[]>(() => {
|
|
58
|
+
return props.items.filter((_, index) => {
|
|
59
|
+
return index >= visibleCount.value
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
let outputSize = (): void => {
|
|
64
|
+
const el = document.getElementById(id.value)
|
|
65
|
+
if (!el) return
|
|
66
|
+
|
|
67
|
+
const elWidth = el.clientWidth
|
|
68
|
+
const elItems = el.children[0].children
|
|
69
|
+
const elItemsMarginLeft = parseInt(getComputedStyle(elItems[0]).marginLeft)
|
|
70
|
+
const elItemsMarginRight = parseInt(getComputedStyle(elItems[0]).marginRight)
|
|
71
|
+
const childrenMarginY = elItemsMarginLeft + elItemsMarginRight
|
|
72
|
+
|
|
73
|
+
let childrenWidth = 0
|
|
74
|
+
let count = 0
|
|
75
|
+
for (let i = 0; i < elItems.length; i++) {
|
|
76
|
+
childrenWidth += elItems[i].clientWidth + childrenMarginY
|
|
77
|
+
const isWrap = elWidth - 25 < childrenWidth
|
|
78
|
+
|
|
79
|
+
if (isWrap) break
|
|
80
|
+
count++
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
visibleCount.value = count
|
|
84
|
+
}
|
|
85
|
+
outputSize = useThrottle(outputSize)
|
|
86
|
+
|
|
87
|
+
const id = ref<string>('')
|
|
88
|
+
const setResizeObserve = (): void => {
|
|
89
|
+
const el = document.getElementById(id.value)
|
|
90
|
+
|
|
91
|
+
if (!el) {
|
|
92
|
+
setTimeout(setResizeObserve, 0)
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
new ResizeObserver(outputSize).observe(el)
|
|
97
|
+
}
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
setResizeObserve()
|
|
100
|
+
id.value = `nav-bar${useUniqueId()}`
|
|
101
|
+
})
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<style scoped lang="scss">
|
|
105
|
+
.nav {
|
|
106
|
+
box-shadow: inset 0 -0.05rem 0 var(--nav-panel-border-color);
|
|
107
|
+
align-items: flex-start;
|
|
108
|
+
|
|
109
|
+
&.not-collapse {
|
|
110
|
+
ul {
|
|
111
|
+
flex-wrap: nowrap;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
&.is-collapsed {
|
|
115
|
+
ul {
|
|
116
|
+
padding-right: 25px;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
ul {
|
|
121
|
+
position: relative;
|
|
122
|
+
height: 36px;
|
|
123
|
+
overflow: hidden;
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-wrap: wrap;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
</style>
|