@awes-io/ui 2.98.2 → 2.99.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.99.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.98.2...@awes-io/ui@2.99.0) (2024-03-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * toggle show aside moved to organisms ([9783aa1](https://github.com/awes-io/client/commit/9783aa11c288235b1e40f9e08b44ddb4e77b8eb2))
12
+
13
+
14
+ ### Features
15
+
16
+ * aside controls from config ([eb4bd0a](https://github.com/awes-io/client/commit/eb4bd0af6369d4034b727c9ce41f3079e3fdbee9))
17
+ * change prefix style in select ([0b5600a](https://github.com/awes-io/client/commit/0b5600a37599682d3bc82589d0cda4318f4d07ef))
18
+ * create new component for toggle aside ([d5fcb35](https://github.com/awes-io/client/commit/d5fcb35b16f3a0d1e47d8bbf478faa4453db4ae5))
19
+
20
+
21
+
22
+
23
+
6
24
  ## [2.98.2](https://github.com/awes-io/client/compare/@awes-io/ui@2.98.1...@awes-io/ui@2.98.2) (2024-02-27)
7
25
 
8
26
 
@@ -75,6 +75,7 @@
75
75
  @import './page-headline.css';
76
76
  @import './page-single.css';
77
77
  @import './progress.css';
78
+ @import './toggle-show-aside.css';
78
79
 
79
80
  @import './modal.css';
80
81
  @import './modal-buttons.css';
@@ -66,10 +66,6 @@
66
66
  grid-column: 2;
67
67
  grid-row: 1 / 6;
68
68
 
69
- overflow-y: auto;
70
-
71
- scrollbar-width: thin;
72
-
73
69
  &--hidden {
74
70
  width: 0px;
75
71
  }
@@ -19,15 +19,25 @@
19
19
  max-width: 5rem;
20
20
  }
21
21
 
22
+ &.aw-layout-menu--hide-submenu {
23
+ max-width: 6rem;
24
+ }
25
+
22
26
  & ~ * {
23
27
  max-width: calc(100% - 300px);
24
28
  margin-left: 300px;
29
+ transition: max-width ease-in-out 0.3s, margin-left ease-in-out 0.3s;
25
30
  }
26
31
 
27
32
  &.aw-layout-menu--no-submenu ~ * {
28
33
  max-width: calc(100% - 5rem);
29
34
  margin-left: 5rem;
30
35
  }
36
+
37
+ &.aw-layout-menu--hide-submenu ~ * {
38
+ max-width: calc(100% - 6rem);
39
+ margin-left: 6rem;
40
+ }
31
41
  }
32
42
  }
33
43
 
@@ -1,5 +1,26 @@
1
1
  .aw-nav {
2
- @apply py-8;
2
+ @apply pt-8;
3
+
4
+ &__wrapper {
5
+ overflow-y: auto;
6
+ overscroll-behavior: contain;
7
+
8
+ scrollbar-width: thin;
9
+ scrollbar-color: rgba(var(--c-on-surface-rgb), 0.15) rgba(var(--c-on-surface-rgb), 0.1);
10
+
11
+ &::-webkit-scrollbar {
12
+ width: 6px;
13
+ height: 6px;
14
+ background-color: rgba(var(--c-on-surface-rgb), 0.1);
15
+ }
16
+
17
+ &::-webkit-scrollbar-thumb {
18
+ background-color: rgba(var(--c-on-surface-rgb), 0.1);
19
+ }
20
+
21
+ max-height: calc(100vh - 5rem);
22
+ padding-bottom: 2rem;
23
+ }
3
24
 
4
25
  &__title {
5
26
  @apply text-xl font-heading mb-5 truncate;
@@ -69,7 +69,7 @@
69
69
 
70
70
  .aw-text-field__prefix {
71
71
  background: transparent;
72
- padding-left: 0.25rem;
72
+ padding-left: 0.1875rem;
73
73
  }
74
74
  }
75
75
 
@@ -117,7 +117,7 @@
117
117
 
118
118
  .aw-text-field__prefix {
119
119
  background: transparent;
120
- padding-left: 0.25rem;
120
+ padding-left: 0.1875rem;
121
121
  }
122
122
  }
123
123
 
@@ -0,0 +1,80 @@
1
+ .aw-toggle-show-aside {
2
+ transition: width 300ms ease-in-out 0s;
3
+ position: relative;
4
+
5
+ &--hide {
6
+ width: 1rem !important;
7
+ background: var(--c-surface);
8
+
9
+ .aw-toggle-show-aside__btn-wrapper {
10
+ width: 1rem;
11
+
12
+ opacity: 1;
13
+ }
14
+ }
15
+
16
+ &--shadow {
17
+ box-shadow: 0 0 4px rgb(0 0 0 / 20%);
18
+ }
19
+
20
+ .aw-toggle-show-aside__btn-wrapper {
21
+ width: inherit;
22
+ position: fixed;
23
+ top: 0;
24
+
25
+ transition: 300ms opacity;
26
+ }
27
+
28
+ &:where(:not(&--hide)) &__btn-wrapper {
29
+ opacity: 0;
30
+ }
31
+
32
+ &:hover &__btn-wrapper {
33
+ opacity: 1;
34
+ }
35
+
36
+ &__arrow-btn {
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+
41
+ position: absolute;
42
+ top: 2rem;
43
+ right: 0;
44
+
45
+ width: 1.5rem;
46
+ height: 1.5rem;
47
+ padding: 0.25rem;
48
+
49
+ background: var(--c-surface);
50
+ border: 1px solid var(--c-mono-800);
51
+ border-radius: 2rem;
52
+
53
+ color: var(--c-mono-500);
54
+ transition: 100ms background-color, 100ms border-color, 100ms color;
55
+ transform: translateX(50%);
56
+
57
+ &:hover {
58
+ background: var(--c-on-surface);
59
+ border: 1px solid var(--c-on-surface);
60
+ color: var(--c-surface);
61
+ }
62
+
63
+ &-icon {
64
+ flex: none;
65
+ transition: 300ms transform;
66
+
67
+ &--reverse {
68
+ transform: rotate(180deg);
69
+ }
70
+ }
71
+ }
72
+
73
+ &--reverse {
74
+ .aw-toggle-show-aside {
75
+ &__btn-wrapper {
76
+ width: 0;
77
+ }
78
+ }
79
+ }
80
+ }
@@ -160,12 +160,12 @@
160
160
  }
161
161
 
162
162
  kbd {
163
- @apply bg-mono-0 bg-opacity-20 align-middle;
163
+ @apply bg-mono-0 bg-opacity-20;
164
164
  border-radius: 2px;
165
165
  display: inline-block;
166
166
  white-space: nowrap;
167
167
  line-height: 0.875em;
168
- font-size: 0.625em;
168
+ /* font-size: 0.625em; */
169
169
  padding: 4px;
170
170
  min-width: 16px;
171
171
  text-align: center;
@@ -1,8 +1,8 @@
1
1
  export const ICONS = {
2
2
  angle:
3
- 'm14.3 18.7-6-6a1 1 0 0 1-.1-1.3l.1-.1 6-6a1 1 0 0 1 1.5 1.3v.1l-5.1 5.4 5 5.2a1 1 0 0 1 .1 1.3v.1a1 1 0 0 1-1.4.1h-.1Z',
3
+ 'm13.29 18.7-6-5.99a1 1 0 0 1-.1-1.3l.1-.11 6-6a1 1 0 0 1 1.5 1.3l-.09.1-5.04 5.38 5.04 5.21a1 1 0 0 1 .1 1.3l-.1.12a1 1 0 0 1-1.3.1l-.11-.1Z',
4
4
  'angle-r':
5
- 'm9.7 18.7 6-6a1 1 0 0 0 .1-1.3v-.1l-6-6a1 1 0 0 0-1.6 1.3l.1.1 5 5.4-5 5.2a1 1 0 0 0-.1 1.3l.1.1a1 1 0 0 0 1.3.1h.1Z',
5
+ 'm10.7 18.7 6-5.99a1 1 0 0 0 .1-1.3l-.1-.11-6-6a1 1 0 0 0-1.5 1.3l.1.1 5.03 5.38L9.3 17.3a1 1 0 0 0-.1 1.3l.1.12a1 1 0 0 0 1.3.1l.12-.1Z',
6
6
  arrow:
7
7
  'm1.3 12.5 6.2 6.2.1.1a1 1 0 0 0 1.3-.1l.1-.1a1 1 0 0 0 0-1.4l-4.5-4.4h17.6a1 1 0 0 0 .9-1v-.2a1 1 0 0 0-1-.8H4.5L9 6.3H9a1 1 0 0 0-1.5-1.4L1.3 11h-.1a1 1 0 0 0 .1 1.4Z',
8
8
  'arrow-r':
@@ -3,7 +3,12 @@
3
3
  <div class="aw-action-card__header">
4
4
  <slot name="before-title"></slot>
5
5
 
6
- <AwHeadline class="aw-action-card__title">{{ title }}</AwHeadline>
6
+ <AwHeadline
7
+ class="aw-action-card__title"
8
+ :class="{ truncate: !fullTitle }"
9
+ >
10
+ {{ title }}
11
+ </AwHeadline>
7
12
 
8
13
  <slot name="after-title">
9
14
  <AwButton
@@ -39,6 +44,8 @@ export default {
39
44
  default: ''
40
45
  },
41
46
 
47
+ fullTitle: Boolean,
48
+
42
49
  action: {
43
50
  type: Object,
44
51
  default: null
@@ -30,6 +30,11 @@ export default {
30
30
  text: {
31
31
  type: String,
32
32
  required: true
33
+ },
34
+
35
+ icon: {
36
+ type: String,
37
+ default: null
33
38
  }
34
39
  },
35
40
 
@@ -0,0 +1,190 @@
1
+ <template>
2
+ <div
3
+ class="aw-toggle-show-aside"
4
+ :class="{
5
+ 'aw-toggle-show-aside--hide':
6
+ !isShown && !isShownOnMouse && !isShownOnBtn,
7
+ 'aw-toggle-show-aside--reverse': reverse,
8
+ 'aw-toggle-show-aside--shadow':
9
+ (!isShown && isShownOnMouse) || (!isShown && isShownOnBtn)
10
+ }"
11
+ >
12
+ <div class="aw-toggle-show-aside__btn-wrapper">
13
+ <button
14
+ v-tooltip="
15
+ isAttachedKeyListener && isVisibleTooltip
16
+ ? {
17
+ content: $t(
18
+ `${isShown ? 'Collapse' : 'Expand'} {key}`,
19
+ {
20
+ key: toggleKeyHTML
21
+ }
22
+ ),
23
+ placement: reverse ? 'left' : 'right',
24
+ flip: false
25
+ }
26
+ : null
27
+ "
28
+ class="aw-toggle-show-aside__arrow-btn"
29
+ @click="onClickToggleShown"
30
+ @mouseenter="onMouseEnterBtn"
31
+ @mouseleave="onMouseLeaveBtn"
32
+ >
33
+ <AwIconSystemMono
34
+ class="aw-toggle-show-aside__arrow-btn-icon"
35
+ :class="{
36
+ 'aw-toggle-show-aside__arrow-btn-icon--reverse': !isShown
37
+ }"
38
+ :name="reverse ? 'angle-r' : 'angle'"
39
+ size="16"
40
+ />
41
+ </button>
42
+ </div>
43
+
44
+ <div
45
+ class="w-full h-full overflow-hidden"
46
+ @mousemove="onMouseEnterShowSubmenu"
47
+ @mouseleave="onMouseLeaveHideSubmenu"
48
+ >
49
+ <slot v-if="isShown || isShownOnMouse || isShownOnBtn" />
50
+ </div>
51
+ </div>
52
+ </template>
53
+
54
+ <script>
55
+ import { conf } from '@AwUtils/component'
56
+ import { AwToggleShowAside as _config } from '@AwConfig'
57
+ import { toggleEvents } from '@AwUtils/events'
58
+
59
+ export default {
60
+ name: 'AwToggleShowAside',
61
+
62
+ _config,
63
+
64
+ props: {
65
+ name: {
66
+ type: String,
67
+ required: true
68
+ },
69
+
70
+ reverse: Boolean,
71
+
72
+ isAttachedKeyListener: {
73
+ type: Boolean,
74
+ default() {
75
+ return conf(this, 'isAttachedKeyListener')
76
+ }
77
+ },
78
+
79
+ options: {
80
+ type: Object,
81
+ default() {
82
+ return conf(this, 'options')
83
+ }
84
+ }
85
+ },
86
+
87
+ data: () => ({
88
+ isShown: true,
89
+ isShownOnMouse: false,
90
+ isShownOnBtn: false,
91
+ isVisibleTooltip: true
92
+ }),
93
+
94
+ computed: {
95
+ toggleKey() {
96
+ return this.reverse ? ']' : '['
97
+ },
98
+
99
+ toggleKeyHTML() {
100
+ return '<kbd>' + this.toggleKey + '</kbd>'
101
+ }
102
+ },
103
+
104
+ watch: {
105
+ isAttachedKeyListener: {
106
+ handler: 'toggleKeyListener',
107
+ immediate: true
108
+ }
109
+ },
110
+
111
+ beforeMount() {
112
+ let state = localStorage.getItem(this.name)
113
+
114
+ if (!state) {
115
+ localStorage.setItem(this.name, 'true')
116
+ } else {
117
+ this.isShown = state.toLowerCase() === 'true'
118
+ }
119
+ },
120
+
121
+ beforeDestroy() {
122
+ if (this.isAttachedKeyListener) {
123
+ this.toggleKeyListener(false)
124
+ }
125
+ },
126
+
127
+ methods: {
128
+ toggleKeyListener(enable = false) {
129
+ toggleEvents(
130
+ window,
131
+ [['keydown', this.onKeyDownToggleShown]],
132
+ enable
133
+ )
134
+ },
135
+
136
+ toggleShown() {
137
+ this.isShown = !this.isShown
138
+
139
+ if (!this.isShown) {
140
+ this.isShownOnBtn = false
141
+ }
142
+
143
+ localStorage.setItem(this.name, `${this.isShown}`)
144
+
145
+ this.$emit('toggle', this.isShown)
146
+ },
147
+
148
+ onClickToggleShown($event) {
149
+ this.isVisibleTooltip = false
150
+ this.toggleShown()
151
+
152
+ setTimeout(() => {
153
+ this.isVisibleTooltip = true
154
+ }, 0)
155
+ },
156
+
157
+ onKeyDownToggleShown(event) {
158
+ if (event.key === this.toggleKey) {
159
+ this.toggleShown()
160
+ }
161
+ },
162
+
163
+ onMouseEnterShowSubmenu() {
164
+ clearTimeout(this._mouseTm)
165
+
166
+ this._mouseTm = setTimeout(() => {
167
+ this.isShownOnMouse = true
168
+ }, this.options.showTimeout)
169
+ },
170
+
171
+ onMouseLeaveHideSubmenu() {
172
+ clearTimeout(this._mouseTm)
173
+
174
+ this._mouseTm = setTimeout(() => {
175
+ this.isShownOnMouse = false
176
+ }, this.options.hideTimeout)
177
+ },
178
+
179
+ onMouseEnterBtn() {
180
+ if (this.isShownOnMouse) {
181
+ this.isShownOnBtn = true
182
+ }
183
+ },
184
+
185
+ onMouseLeaveBtn() {
186
+ this.isShownOnBtn = false
187
+ }
188
+ }
189
+ }
190
+ </script>
@@ -2,7 +2,9 @@
2
2
  <div
3
3
  class="aw-layout-menu"
4
4
  :class="{
5
- 'aw-layout-menu--no-submenu': hideAside || !hasSubmenu
5
+ 'aw-layout-menu--no-submenu': hideAside || !hasSubmenu,
6
+ 'aw-layout-menu--hide-submenu':
7
+ !isShownSubmenu && !hideAside && hasSubmenu
6
8
  }"
7
9
  >
8
10
  <slot name="logo">
@@ -76,36 +78,63 @@
76
78
  </div>
77
79
 
78
80
  <!-- submenu -->
79
- <div
81
+ <Component
82
+ v-if="!hideAside"
83
+ :is="hasSubmenu && submenuToggler ? 'AwToggleShowAside' : 'div'"
80
84
  class="aw-layout-menu__submenu"
81
85
  :class="{ 'aw-layout-menu__submenu--hidden': !hasSubmenu }"
86
+ :name="toggleAsideName"
87
+ @toggle="isShownSubmenu = $event"
82
88
  >
83
- <slot v-if="!hideAside" name="submenu">
89
+ <slot name="submenu">
84
90
  <AwNav :title="submenuTitle" :items="submenu" />
85
91
  </slot>
86
- </div>
92
+ </Component>
87
93
  </div>
88
94
  </template>
89
95
 
90
96
  <script>
91
97
  import { mapGetters } from 'vuex'
92
98
  import { pathOr, viewOr, lensProp, omit } from 'rambdax'
99
+ import { conf } from '@AwUtils/component'
100
+ import { AwLayoutMenu as _config } from '@AwConfig'
93
101
  import AwMenuItemIcon from '@AwLayouts/_AwMenuItemIcon.vue'
94
102
  import AwUserMenu from '@AwLayouts/_AwUserMenu.vue'
95
- import AwNav from '@AwLayouts/_AwNav.vue'
96
103
 
97
104
  export default {
98
105
  name: 'AwLayoutMenu',
99
106
 
107
+ _config,
108
+
100
109
  components: {
101
110
  AwMenuItemIcon,
102
111
  AwLayoutLogo: () => import('@AwLayouts/_AwLayoutLogo.vue'),
112
+ AwToggleShowAside: () => import('@AwOrganisms/AwToggleShowAside.vue'),
103
113
  AwUserMenu,
104
- AwNav
114
+ AwNav: () => import('@AwLayouts/_AwNav.vue')
105
115
  },
106
116
 
107
117
  props: {
108
- hideAside: Boolean
118
+ hideAside: {
119
+ type: Boolean,
120
+ default() {
121
+ return conf(this, 'hideAside')
122
+ }
123
+ },
124
+
125
+ submenuToggler: {
126
+ type: Boolean,
127
+ default() {
128
+ return conf(this, 'submenuToggler')
129
+ }
130
+ },
131
+
132
+ toggleAsideName: {
133
+ type: String,
134
+ default() {
135
+ return conf(this, 'toggleAsideName')
136
+ }
137
+ }
109
138
  },
110
139
 
111
140
  inject: {
@@ -114,6 +143,18 @@ export default {
114
143
  }
115
144
  },
116
145
 
146
+ data: () => ({
147
+ isShownSubmenu: true
148
+ }),
149
+
150
+ beforeMount() {
151
+ const toggleAsideState = localStorage.getItem(this.toggleAsideName)
152
+
153
+ this.isShownSubmenu = toggleAsideState
154
+ ? toggleAsideState.toLowerCase() === 'true'
155
+ : true
156
+ },
157
+
117
158
  computed: {
118
159
  ...mapGetters('awesIo', ['user', 'logoComponent']),
119
160
 
@@ -2,79 +2,85 @@
2
2
  <nav class="aw-nav" @click="toggleChildren">
3
3
  <h3 v-if="title" class="aw-nav__title">{{ title }}</h3>
4
4
 
5
- <template v-for="(item, i) in items">
6
- <span v-show="!item.abstract" :key="i" class="aw-nav__item">
7
- <AwNavItem
8
- :href="item.href"
9
- :class="{
10
- 'aw-nav__child--sub':
11
- !item.children || !item.children.length,
12
- 'aw-nav__child--active': item === activeMenuItem
13
- }"
14
- class="aw-nav__child"
15
- :[_getItemToggleAttr(item)]="
16
- item.children && item.children.length && !item.expanded
17
- ? i
18
- : null
19
- "
20
- >
21
- <AwIcon v-if="item.icon" size="16" :name="item.icon" />
22
- <span
23
- v-tooltip="tooltips[i]"
24
- :[$options.TOOLTIP_EL_ATTR]="i"
5
+ <div class="aw-nav__wrapper">
6
+ <template v-for="(item, i) in items">
7
+ <span v-show="!item.abstract" :key="i" class="aw-nav__item">
8
+ <AwNavItem
9
+ :href="item.href"
10
+ :class="{
11
+ 'aw-nav__child--sub':
12
+ !item.children || !item.children.length,
13
+ 'aw-nav__child--active': item === activeMenuItem
14
+ }"
15
+ class="aw-nav__child"
16
+ :[_getItemToggleAttr(item)]="
17
+ item.children &&
18
+ item.children.length &&
19
+ !item.expanded
20
+ ? i
21
+ : null
22
+ "
25
23
  >
26
- {{ item.text }}
27
- </span>
28
- <AwBadge
29
- v-if="item.badge"
30
- v-bind="item.badge"
31
- class="flex-shrink-0"
32
- />
33
- </AwNavItem>
34
-
35
- <button
36
- v-if="
37
- item.children && item.children.length && !item.expanded
38
- "
39
- class="aw-nav__toggler"
40
- :class="{ 'aw-nav__toggler--open': openedChildren[i] }"
41
- :[$options.TOGGLE_CHILDREN_ATTR]="i"
42
- >
43
- <AwIconSystemMono name="angle" size="16" />
44
- </button>
45
- </span>
46
- <!-- { children, href, icon, expanded, ...child } -->
47
- <!-- subnav -->
48
- <Component
49
- :is="item.expanded ? 'div' : 'AwAccordionFold'"
50
- v-if="item.children && item.children.length"
51
- :key="'children-' + i"
52
- :show="openedChildren[i]"
53
- >
54
- <AwNavItem
55
- v-for="(subchild, j) in item.children"
56
- v-show="!item.abstract"
57
- :key="j"
58
- :href="subchild.href"
59
- :class="{
60
- 'aw-nav__child--active': subchild === activeMenuItem
61
- }"
62
- class="aw-nav__child truncate aw-nav__child--sub"
24
+ <AwIcon v-if="item.icon" size="16" :name="item.icon" />
25
+ <span
26
+ v-tooltip="tooltips[i]"
27
+ :[$options.TOOLTIP_EL_ATTR]="i"
28
+ >
29
+ {{ item.text }}
30
+ </span>
31
+ <AwBadge
32
+ v-if="item.badge"
33
+ v-bind="item.badge"
34
+ class="flex-shrink-0"
35
+ />
36
+ </AwNavItem>
37
+
38
+ <button
39
+ v-if="
40
+ item.children &&
41
+ item.children.length &&
42
+ !item.expanded
43
+ "
44
+ class="aw-nav__toggler"
45
+ :class="{ 'aw-nav__toggler--open': openedChildren[i] }"
46
+ :[$options.TOGGLE_CHILDREN_ATTR]="i"
47
+ >
48
+ <AwIconSystemMono name="angle" size="16" />
49
+ </button>
50
+ </span>
51
+ <!-- { children, href, icon, expanded, ...child } -->
52
+ <!-- subnav -->
53
+ <Component
54
+ :is="item.expanded ? 'div' : 'AwAccordionFold'"
55
+ v-if="item.children && item.children.length"
56
+ :key="'children-' + i"
57
+ :show="openedChildren[i]"
63
58
  >
64
- <span
65
- v-tooltip="tooltips[i + '-' + j]"
66
- :[$options.TOOLTIP_EL_ATTR]="i + '-' + j"
59
+ <AwNavItem
60
+ v-for="(subchild, j) in item.children"
61
+ v-show="!item.abstract"
62
+ :key="j"
63
+ :href="subchild.href"
64
+ :class="{
65
+ 'aw-nav__child--active': subchild === activeMenuItem
66
+ }"
67
+ class="aw-nav__child truncate aw-nav__child--sub"
67
68
  >
68
- {{ subchild.text }}
69
- </span>
70
- <AwBadge
71
- v-if="subchild.badge"
72
- v-bind="subchild.badge"
73
- class="flex-shrink-0"
74
- />
75
- </AwNavItem>
76
- </Component>
77
- </template>
69
+ <span
70
+ v-tooltip="tooltips[i + '-' + j]"
71
+ :[$options.TOOLTIP_EL_ATTR]="i + '-' + j"
72
+ >
73
+ {{ subchild.text }}
74
+ </span>
75
+ <AwBadge
76
+ v-if="subchild.badge"
77
+ v-bind="subchild.badge"
78
+ class="flex-shrink-0"
79
+ />
80
+ </AwNavItem>
81
+ </Component>
82
+ </template>
83
+ </div>
78
84
  </nav>
79
85
  </template>
80
86
 
@@ -243,6 +243,23 @@ export const AwTel = {
243
243
  filterCountries: []
244
244
  }
245
245
 
246
+ export const AwToggleShowAside = {
247
+ isAttachedKeyListener: true,
248
+
249
+ options: {
250
+ showTimeout: 50,
251
+ hideTimeout: 250
252
+ }
253
+ }
254
+
255
+ export const AwLayoutMenu = {
256
+ hideAside: false,
257
+
258
+ submenuToggler: true,
259
+
260
+ toggleAsideName: 'aw-layout-menu-submenu'
261
+ }
262
+
246
263
  export default {
247
264
  AwAvatar,
248
265
  AwButton,
@@ -261,5 +278,7 @@ export default {
261
278
  AwModal,
262
279
  AwTable,
263
280
  AwTags,
264
- AwTel
281
+ AwTel,
282
+ AwToggleShowAside,
283
+ AwLayoutMenu
265
284
  }
@@ -1,4 +1,5 @@
1
1
  import { createPopper } from '@popperjs/core'
2
+ import { toggleEvents } from '@AwUtils/events'
2
3
  import { isType, pathOr, omit, F, clone, equals } from 'rambdax'
3
4
  import { sanitize } from '../assets/js/string'
4
5
 
@@ -16,12 +17,6 @@ function showTooltip() {
16
17
  name: 'arrow',
17
18
  options: { padding: 6 }
18
19
  },
19
- {
20
- name: 'flip',
21
- options: {
22
- fallbackPlacements: ['top', 'right', 'bottom', 'left']
23
- }
24
- },
25
20
  {
26
21
  name: 'preventOverflow',
27
22
  options: {
@@ -30,6 +25,18 @@ function showTooltip() {
30
25
  }
31
26
  ]
32
27
 
28
+ const flip = pathOr(true, 'flip', options)
29
+
30
+ modifiers.push({
31
+ name: 'flip',
32
+ enabled: flip,
33
+ options: {
34
+ fallbackPlacements: isType('Array', flip)
35
+ ? flip
36
+ : ['top', 'right', 'bottom', 'left']
37
+ }
38
+ })
39
+
33
40
  const offset = pathOr([0, 6], 'offset', options)
34
41
 
35
42
  if (offset) {
@@ -51,32 +58,20 @@ function hideTooltip() {
51
58
  const tooltip = this.__tooltip__
52
59
  const popper = POPPERS.get(tooltip)
53
60
 
54
- popper.destroy()
61
+ if (popper) {
62
+ popper.destroy()
63
+ }
55
64
 
56
65
  tooltip.removeAttribute('data-visible')
57
66
  }
58
67
 
59
68
  const EVENTS = [
60
- {
61
- names: ['pointerenter', 'focus'],
62
- handler: showTooltip
63
- },
64
- {
65
- names: ['pointerleave', 'blur'],
66
- handler: hideTooltip
67
- }
69
+ ['pointerenter', showTooltip],
70
+ ['focus', showTooltip],
71
+ ['pointerleave', hideTooltip],
72
+ ['blur', hideTooltip]
68
73
  ]
69
74
 
70
- function toggleEvents(el, on = false, $events = EVENTS) {
71
- const useMethod = on ? 'addEventListener' : 'removeEventListener'
72
-
73
- $events.forEach(({ names, handler }) => {
74
- names.forEach((name) => {
75
- el[useMethod](name, handler)
76
- })
77
- })
78
- }
79
-
80
75
  function _updateTooltipContent(tooltip, content) {
81
76
  tooltip.__content__ = content
82
77
 
@@ -146,7 +141,7 @@ function unbind(el) {
146
141
  }
147
142
 
148
143
  // remove listeners
149
- toggleEvents(el, false)
144
+ toggleEvents(el, EVENTS, false)
150
145
 
151
146
  // remove tooltip
152
147
  if (tooltip.parentElement) {
@@ -169,8 +164,10 @@ function bind(el, { value, arg = 'top', modifiers }) {
169
164
  if (content) {
170
165
  const options = _getOptions(value)
171
166
 
167
+ const placement = pathOr(arg, 'placement', options)
168
+
172
169
  // create new tooltip
173
- el.__tooltip__ = createTooltip(content, options, arg)
170
+ el.__tooltip__ = createTooltip(content, options, placement)
174
171
 
175
172
  if (modifiers.prepend) {
176
173
  // insert before parent asynchronously
@@ -193,7 +190,7 @@ function bind(el, { value, arg = 'top', modifiers }) {
193
190
  showTooltip.call(el)
194
191
  } else {
195
192
  // add listeners
196
- toggleEvents(el, true)
193
+ toggleEvents(el, EVENTS, true)
197
194
  }
198
195
  }
199
196
  }
@@ -220,7 +217,12 @@ function update(el, { value, arg = 'top', modifiers }) {
220
217
  arg !== el.__tooltip__.__placement__ ||
221
218
  !equals(options, el.__tooltip__.__options__)
222
219
  ) {
223
- updateTooltip(el.__tooltip__, content, options, arg)
220
+ updateTooltip(
221
+ el.__tooltip__,
222
+ content,
223
+ options,
224
+ pathOr(arg, 'placement', options)
225
+ )
224
226
  return
225
227
  }
226
228
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awes-io/ui",
3
- "version": "2.98.2",
3
+ "version": "2.99.0",
4
4
  "description": "User Interface (UI) components",
5
5
  "keywords": [
6
6
  "ui",
@@ -114,5 +114,5 @@
114
114
  "rollup-plugin-visualizer": "^2.6.0",
115
115
  "rollup-plugin-vue": "^5.0.1"
116
116
  },
117
- "gitHead": "c6f6ca32aa9b80f794657bd59959a29cb93e8821"
117
+ "gitHead": "1b79780032eecf84dc91941f9d11fbebcd1f97ae"
118
118
  }