@awes-io/ui 2.53.0 → 2.54.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,17 @@
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.54.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.53.0...@awes-io/ui@2.54.0) (2022-07-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * optional menu items translation and tooltip ([8a24879](https://github.com/awes-io/client/commit/8a24879ee5d0b1ff60165567e2b70201b4cfe518))
12
+
13
+
14
+
15
+
16
+
6
17
  # [2.53.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.52.0...@awes-io/ui@2.53.0) (2022-06-29)
7
18
 
8
19
 
@@ -175,6 +175,7 @@ export default {
175
175
  {
176
176
  show,
177
177
  text,
178
+ translate = true,
178
179
  subtitle,
179
180
  description,
180
181
  href,
@@ -203,7 +204,7 @@ export default {
203
204
  href = isType('Function', href)
204
205
  ? href(state, getters)
205
206
  : href
206
- text = this.$t(text)
207
+ text = translate === false ? text : this.$t(text)
207
208
  subtitle = subtitle ? this.$t(subtitle) : undefined
208
209
  description = description ? this.$t(description) : null
209
210
 
@@ -19,7 +19,12 @@
19
19
  "
20
20
  >
21
21
  <AwIcon v-if="item.icon" size="16" :name="item.icon" />
22
- <span>{{ item.text }}</span>
22
+ <span
23
+ v-tooltip="tooltips[i]"
24
+ :[$options.TOOLTIP_EL_ATTR]="i"
25
+ >
26
+ {{ item.text }}
27
+ </span>
23
28
  <AwBadge
24
29
  v-if="item.badge"
25
30
  v-bind="item.badge"
@@ -56,7 +61,12 @@
56
61
  }"
57
62
  class="aw-nav__child truncate aw-nav__child--sub"
58
63
  >
59
- <span>{{ subchild.text }}</span>
64
+ <span
65
+ v-tooltip="tooltips[i + '-' + j]"
66
+ :[$options.TOOLTIP_EL_ATTR]="i + '-' + j"
67
+ >
68
+ {{ subchild.text }}
69
+ </span>
60
70
  <AwBadge
61
71
  v-if="subchild.badge"
62
72
  v-bind="subchild.badge"
@@ -70,12 +80,15 @@
70
80
 
71
81
  <script>
72
82
  import { viewOr, lensProp } from 'rambdax'
83
+ import { supportsPassive } from '@AwUtils/events'
73
84
  import AwNavItem from '@AwLayouts/_AwNavItem.vue'
74
85
 
75
86
  const TOGGLE_CHILDREN_ATTR = 'data-toggle-children'
76
87
 
77
88
  const OPEN_CHILDREN_ATTR = 'data-open-children'
78
89
 
90
+ const TOOLTIP_EL_ATTR = 'data-tooltip-el'
91
+
79
92
  const targetByAttribute = (attr, $event) =>
80
93
  $event.target.hasAttribute(attr)
81
94
  ? $event.target
@@ -92,6 +105,8 @@ export default {
92
105
 
93
106
  OPEN_CHILDREN_ATTR,
94
107
 
108
+ TOOLTIP_EL_ATTR,
109
+
95
110
  props: {
96
111
  title: {
97
112
  type: String,
@@ -112,7 +127,8 @@ export default {
112
127
 
113
128
  data() {
114
129
  return {
115
- openedChildren: []
130
+ openedChildren: [],
131
+ tooltips: {}
116
132
  }
117
133
  },
118
134
 
@@ -137,11 +153,37 @@ export default {
137
153
  )
138
154
  )
139
155
  })
156
+
157
+ if (typeof oldItems !== 'undefined') {
158
+ this.$nextTick(this._calculateOversizedText)
159
+ }
140
160
  },
141
161
  immediate: true
142
162
  }
143
163
  },
144
164
 
165
+ mounted() {
166
+ this.$nextTick(this._calculateOversizedText)
167
+
168
+ const eventOptions = supportsPassive() ? { passive: true } : false
169
+
170
+ window.addEventListener(
171
+ 'resize',
172
+ this._calculateOversizedText,
173
+ eventOptions
174
+ )
175
+
176
+ this.$once('hook:beforeDestroy', () => {
177
+ this.tooltips = {}
178
+
179
+ window.addEventListener(
180
+ 'resize',
181
+ this._calculateOversizedText,
182
+ eventOptions
183
+ )
184
+ })
185
+ },
186
+
145
187
  methods: {
146
188
  _getItemToggleAttr(item) {
147
189
  return item.href ? OPEN_CHILDREN_ATTR : TOGGLE_CHILDREN_ATTR
@@ -175,6 +217,23 @@ export default {
175
217
 
176
218
  return
177
219
  }
220
+ },
221
+
222
+ _calculateOversizedText() {
223
+ this.tooltips = {}
224
+
225
+ const children = this.$el.querySelectorAll(
226
+ '[' + TOOLTIP_EL_ATTR + ']'
227
+ )
228
+
229
+ for (let i = 0; i < children.length; i++) {
230
+ const el = children[i]
231
+
232
+ if (el.scrollWidth > el.clientWidth) {
233
+ this.tooltips[el.getAttribute(TOOLTIP_EL_ATTR)] =
234
+ el.textContent
235
+ }
236
+ }
178
237
  }
179
238
  }
180
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awes-io/ui",
3
- "version": "2.53.0",
3
+ "version": "2.54.0",
4
4
  "description": "User Interface (UI) components",
5
5
  "keywords": [
6
6
  "ui",
@@ -122,5 +122,5 @@
122
122
  "vue-template-compiler": "^2.6.10",
123
123
  "webfonts-generator": "^0.4.0"
124
124
  },
125
- "gitHead": "bdd10f2d121d75c137381357d3dbc72119b40630"
125
+ "gitHead": "fc78eb75d3f2e60b94edaad5977d6772e170ad93"
126
126
  }