@energie360/ui-library 0.1.8 → 0.1.10
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/base/abstracts/_variables.scss +1 -0
- package/components/context-menu/context-menu.scss +28 -0
- package/components/context-menu/u-context-menu.vue +113 -0
- package/components/context-menu-divider/context-menu-divider.scss +6 -0
- package/components/context-menu-divider/u-context-menu-divider.vue +5 -0
- package/components/context-menu-link/context-menu-link.scss +26 -0
- package/components/context-menu-link/u-context-menu-link.vue +27 -0
- package/components/index.js +38 -5
- package/components/navigation-toolbar-link/navigation-toolbar-link.scss +177 -0
- package/components/navigation-toolbar-link/u-navigation-toolbar-link.vue +108 -0
- package/components/text-block/text-block.scss +58 -0
- package/components/text-block/u-text-block.vue +26 -0
- package/components/tooltip/popover.ts +74 -12
- package/dist/base-style.css +1 -0
- package/dist/base-style.css.map +1 -1
- package/dist/elements/text-link.css +1 -0
- package/dist/elements/text-link.css.map +1 -1
- package/dist/layout/split.css +1 -0
- package/dist/layout/split.css.map +1 -1
- package/elements/button-chip/button-chip.scss +2 -2
- package/elements/index.js +13 -0
- package/elements/text-field/u-text-field.vue +9 -1
- package/elements/types.ts +0 -2
- package/i18n/i18n.ts +8 -0
- package/modules/index.js +5 -0
- package/modules/navigation-toolbar-side/navigation-toolbar-side.scss +89 -0
- package/modules/navigation-toolbar-side/u-navigation-toolbar-side.vue +93 -0
- package/modules/navigation-toolbar-top/navigation-toolbar-top.scss +89 -0
- package/modules/navigation-toolbar-top/u-navigation-toolbar-top.vue +130 -0
- package/package.json +4 -7
- package/utils/a11y/focus-trap.js +128 -0
- package/elements/button/index.js +0 -1
- package/elements/button-chip/index.js +0 -1
- package/elements/icon/index.js +0 -1
- package/elements/icon-button/index.js +0 -1
- package/elements/image/index.js +0 -1
- package/elements/loader/index.js +0 -1
- package/elements/numeric-stepper/index.js +0 -1
- package/elements/password-progress/index.js +0 -1
- package/elements/radio/index.js +0 -1
- package/elements/radio-group/index.js +0 -1
- package/elements/select/index.js +0 -1
- package/elements/select-chip/index.js +0 -1
- package/elements/select-chips/index.js +0 -1
- package/elements/spectro/index.js +0 -1
- package/elements/text-field/index.js +0 -1
- package/elements/textarea/index.js +0 -1
- package/elements/toggle-switch/index.js +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { UNavigationToolbarLink } from '../../components'
|
|
3
|
+
import { UIconButton } from '../../elements'
|
|
4
|
+
import { UContextMenu } from '../../components'
|
|
5
|
+
import { Image } from '../../elements/types'
|
|
6
|
+
import { getTranslation } from '../../utils/translations/translate'
|
|
7
|
+
import { ref, watch, useTemplateRef } from 'vue'
|
|
8
|
+
|
|
9
|
+
interface MenuButton {
|
|
10
|
+
icon: string
|
|
11
|
+
label: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
logoLink: {
|
|
16
|
+
href: string
|
|
17
|
+
target: string
|
|
18
|
+
}
|
|
19
|
+
menuButton: MenuButton
|
|
20
|
+
logoImage: Image
|
|
21
|
+
logoMinifiedImage: Image
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
defineProps<Props>()
|
|
25
|
+
|
|
26
|
+
const mobilePanelEl = useTemplateRef('mobile-panel')
|
|
27
|
+
const mobileOpen = ref(false)
|
|
28
|
+
const isMobilePanelOpening = ref(false)
|
|
29
|
+
const isMobilePanelClosing = ref(false)
|
|
30
|
+
|
|
31
|
+
const onToggleMenu = () => {
|
|
32
|
+
mobilePanelEl.value?.addEventListener('transitionend', onMobilePanelTransitionEnd)
|
|
33
|
+
|
|
34
|
+
document.documentElement.classList.toggle('navigation-toolbar-mobile-open', true)
|
|
35
|
+
isMobilePanelOpening.value = true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const onNavClose = () => {
|
|
39
|
+
mobilePanelEl.value?.addEventListener('transitionend', onMobilePanelTransitionEnd)
|
|
40
|
+
|
|
41
|
+
isMobilePanelClosing.value = true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const onMobilePanelTransitionEnd = (e) => {
|
|
45
|
+
if (e.target !== mobilePanelEl.value) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
mobilePanelEl.value?.removeEventListener('transitionend', onMobilePanelTransitionEnd)
|
|
50
|
+
|
|
51
|
+
mobileOpen.value = !mobileOpen.value
|
|
52
|
+
isMobilePanelOpening.value = false
|
|
53
|
+
isMobilePanelClosing.value = false
|
|
54
|
+
|
|
55
|
+
document.documentElement.classList.toggle('navigation-toolbar-mobile-open', !mobileOpen.value)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
watch(mobileOpen, (newV) => {
|
|
59
|
+
document.documentElement.classList.toggle('navigation-toolbar-mobile-open', newV)
|
|
60
|
+
})
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<div
|
|
65
|
+
ref="el"
|
|
66
|
+
:class="[
|
|
67
|
+
'navigation-toolbar-top',
|
|
68
|
+
{
|
|
69
|
+
'mobile-open': mobileOpen,
|
|
70
|
+
},
|
|
71
|
+
]"
|
|
72
|
+
>
|
|
73
|
+
<div class="navigation-toolbar-top__top-bar">
|
|
74
|
+
<a
|
|
75
|
+
class="navigation-toolbar-top__top-bar-logo"
|
|
76
|
+
:href="logoLink.href"
|
|
77
|
+
:target="logoLink.target"
|
|
78
|
+
>
|
|
79
|
+
<img :src="logoImage.src" :alt="logoImage.alt" />
|
|
80
|
+
</a>
|
|
81
|
+
|
|
82
|
+
<div class="navigation-toolbar-top__top-bar-ctas">
|
|
83
|
+
<UContextMenu placement="bottom-full">
|
|
84
|
+
<template #trigger>
|
|
85
|
+
<UNavigationToolbarLink v-bind="menuButton" collapsed label-hidden />
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<slot name="contextMenuLinks"></slot>
|
|
89
|
+
</UContextMenu>
|
|
90
|
+
|
|
91
|
+
<UNavigationToolbarLink
|
|
92
|
+
icon="menu"
|
|
93
|
+
:label="getTranslation('openMenu')"
|
|
94
|
+
collapsed
|
|
95
|
+
label-hidden
|
|
96
|
+
@click="onToggleMenu"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<nav
|
|
102
|
+
ref="mobile-panel"
|
|
103
|
+
class="navigation-toolbar-top__nav-panel"
|
|
104
|
+
:class="{ 'is-opening': isMobilePanelOpening, 'is-closing': isMobilePanelClosing }"
|
|
105
|
+
>
|
|
106
|
+
<a
|
|
107
|
+
class="navigation-toolbar-top__nav-panel-logo"
|
|
108
|
+
:href="logoLink.href"
|
|
109
|
+
:target="logoLink.target"
|
|
110
|
+
>
|
|
111
|
+
<img :src="logoImage.src" :alt="logoImage.alt" />
|
|
112
|
+
</a>
|
|
113
|
+
|
|
114
|
+
<div class="navigation-toolbar-top__nav-panel-close">
|
|
115
|
+
<UIconButton
|
|
116
|
+
icon="close"
|
|
117
|
+
variant="outlined-inverted"
|
|
118
|
+
:label="getTranslation('closeMenu')"
|
|
119
|
+
@click="onNavClose"
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div class="navigation-toolbar-top__nav-links">
|
|
124
|
+
<slot name="navLinks"></slot>
|
|
125
|
+
</div>
|
|
126
|
+
</nav>
|
|
127
|
+
</div>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<style lang="scss" src="./navigation-toolbar-top.scss" scoped></style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@energie360/ui-library",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,16 +9,12 @@
|
|
|
9
9
|
"./package.json": "./package.json",
|
|
10
10
|
"./base-style.css": "./dist/base-style.css",
|
|
11
11
|
"./elements": "./elements/index.js",
|
|
12
|
-
"./elements/*": "./elements/*/index.js",
|
|
13
12
|
"./components": "./components/index.js",
|
|
14
|
-
"./components/*": "./components/*",
|
|
15
13
|
"./modules": "./modules/index.js",
|
|
16
|
-
"./modules/*": "./modules/*",
|
|
17
14
|
"./wizard": "./wizard/index.js",
|
|
18
|
-
"./wizard/*": "./wizard/*",
|
|
19
15
|
"./utility/elements/*": "./dist/elements/*",
|
|
20
16
|
"./utility/layout/*": "./dist/layout/*",
|
|
21
|
-
"./abstracts": "./base/abstracts/index.scss"
|
|
17
|
+
"./base/abstracts": "./base/abstracts/index.scss"
|
|
22
18
|
},
|
|
23
19
|
"keywords": [],
|
|
24
20
|
"author": "",
|
|
@@ -37,7 +33,8 @@
|
|
|
37
33
|
"@energie360/design-tokens": "^1.3.0"
|
|
38
34
|
},
|
|
39
35
|
"peerDependencies": {
|
|
40
|
-
"vue": "^3.5.0"
|
|
36
|
+
"vue": "^3.5.0",
|
|
37
|
+
"sass": "^1.86.3"
|
|
41
38
|
},
|
|
42
39
|
"scripts": {
|
|
43
40
|
"watch": "node ./watch.js",
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const getFocusableElements = (parent) => {
|
|
2
|
+
const focusableElements = [
|
|
3
|
+
'button:not([disabled]):not([tabindex="-1"])',
|
|
4
|
+
'[href]',
|
|
5
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
6
|
+
'select:not([disabled])',
|
|
7
|
+
'textarea:not([disabled])',
|
|
8
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
9
|
+
'iframe',
|
|
10
|
+
'details',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
return Array.from(parent.querySelectorAll(focusableElements.join(', ')))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param parent
|
|
19
|
+
* @param {Object} options
|
|
20
|
+
* @param {Boolean} options.focusFirstElement
|
|
21
|
+
* @param {Boolean} options.allowArrowUpDown
|
|
22
|
+
* @param {Boolean} options.allowArrowLeftRight
|
|
23
|
+
* @returns {{release: release}}
|
|
24
|
+
*/
|
|
25
|
+
export const focusTrap = (parent, options = {}) => {
|
|
26
|
+
const TAB = 'Tab'
|
|
27
|
+
const ARROW_DOWN = 'ArrowDown'
|
|
28
|
+
const ARROW_UP = 'ArrowUp'
|
|
29
|
+
const ARROW_LEFT = 'ArrowLeft'
|
|
30
|
+
const ARROW_RIGHT = 'ArrowRight'
|
|
31
|
+
|
|
32
|
+
const allFocusable = getFocusableElements(parent)
|
|
33
|
+
const firstFocusable = allFocusable[0]
|
|
34
|
+
const lastFocusable = allFocusable[allFocusable.length - 1]
|
|
35
|
+
|
|
36
|
+
const focusNext = () => {
|
|
37
|
+
let currentIdx = allFocusable.findIndex((el) => el === document.activeElement)
|
|
38
|
+
|
|
39
|
+
if (currentIdx === allFocusable.length - 1) {
|
|
40
|
+
currentIdx = 0
|
|
41
|
+
} else {
|
|
42
|
+
currentIdx++
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
allFocusable[currentIdx].focus()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const focusPrevious = () => {
|
|
49
|
+
let currentIdx = allFocusable.findIndex((el) => el === document.activeElement)
|
|
50
|
+
|
|
51
|
+
if (currentIdx === 0) {
|
|
52
|
+
currentIdx = allFocusable.length - 1
|
|
53
|
+
} else {
|
|
54
|
+
currentIdx--
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
allFocusable[currentIdx].focus()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const onKeydown = (e) => {
|
|
61
|
+
// Tab
|
|
62
|
+
if (e.code === TAB && !e.shiftKey) {
|
|
63
|
+
if (document.activeElement === lastFocusable) {
|
|
64
|
+
firstFocusable.focus()
|
|
65
|
+
e.preventDefault()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Shift + Tab
|
|
72
|
+
if (e.code === TAB && e.shiftKey) {
|
|
73
|
+
if (document.activeElement === firstFocusable) {
|
|
74
|
+
lastFocusable.focus()
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (options.allowArrowUpDown) {
|
|
82
|
+
if (e.code === ARROW_DOWN) {
|
|
83
|
+
focusNext()
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (e.code === ARROW_UP) {
|
|
88
|
+
focusPrevious()
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (options.allowArrowLeftRight) {
|
|
94
|
+
if (e.code === ARROW_RIGHT) {
|
|
95
|
+
focusNext()
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (e.code === ARROW_LEFT) {
|
|
100
|
+
focusPrevious()
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const release = () => {
|
|
106
|
+
parent.removeEventListener('keydown', onKeydown)
|
|
107
|
+
|
|
108
|
+
// Is this necessary?
|
|
109
|
+
document.activeElement.blur()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Set initial focus
|
|
113
|
+
if (options.focusFirstElement) {
|
|
114
|
+
firstFocusable.focus()
|
|
115
|
+
} else {
|
|
116
|
+
if (parent.tabIndex < 0) {
|
|
117
|
+
parent.tabIndex = 0
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
parent.focus()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
parent.addEventListener('keydown', onKeydown)
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
release,
|
|
127
|
+
}
|
|
128
|
+
}
|
package/elements/button/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UButton } from './u-button.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UButtonChip } from './u-button-chip.vue'
|
package/elements/icon/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UIcon } from './u-icon.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UIconButton } from './u-icon-button.vue'
|
package/elements/image/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UImage } from './u-image.vue'
|
package/elements/loader/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as ULoader } from './u-loader.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UNumericStepper } from './u-numeric-stepper.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UPasswordProgress } from './u-password-progress.vue'
|
package/elements/radio/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as URadio } from './u-radio.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as URadioGroup } from './u-radio-group.vue'
|
package/elements/select/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as USelect } from './u-select.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as USelectChip } from './u-select-chip.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as USelectChips } from './u-select-chips.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as USpectro } from './u-spectro.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UTextField } from './u-text-field.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UTextarea } from './u-textarea.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UToggleSwitch } from './u-toggle-switch.vue'
|