@awes-io/ui 2.50.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,56 @@
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
+
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)
18
+
19
+
20
+ ### Features
21
+
22
+ * new version ([c64a7a1](https://github.com/awes-io/client/commit/c64a7a10bb55e8f5e5196912f8d70bf8350fd831))
23
+
24
+
25
+
26
+
27
+
28
+ # [2.52.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.51.0...@awes-io/ui@2.52.0) (2022-06-29)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **aw-table:** falsy clicks fixed ([ff1004b](https://github.com/awes-io/client/commit/ff1004b47ea527bb71a6d99e44df307be3df4223))
34
+
35
+
36
+ ### Features
37
+
38
+ * set dropdown max height by viewport ([4ec3589](https://github.com/awes-io/client/commit/4ec3589eb6691fad198ff83a99333724e9ae3900))
39
+ * table press event added ([b8bf19a](https://github.com/awes-io/client/commit/b8bf19a4e1262d9e3a0e7044490081020009e3af))
40
+
41
+
42
+
43
+
44
+
45
+ # [2.51.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.50.0...@awes-io/ui@2.51.0) (2022-06-14)
46
+
47
+
48
+ ### Features
49
+
50
+ * **aw-bottom-bar:** fixed position to prevent jumps on ios ([c9b32bb](https://github.com/awes-io/client/commit/c9b32bbbb7c109a9f5c3abede7a2aeb7a7c543b9))
51
+
52
+
53
+
54
+
55
+
6
56
  # [2.50.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.49.1...@awes-io/ui@2.50.0) (2022-06-13)
7
57
 
8
58
 
@@ -6,9 +6,10 @@
6
6
  padding-bottom: env(safe-area-inset-bottom, 0);
7
7
  box-shadow: 0px -2px 2px rgba(var(--c-mono-100-rgb, 50, 50, 50), 0.1);
8
8
 
9
- position: sticky;
9
+ position: fixed;
10
10
  bottom: 0;
11
11
  min-height: 4rem;
12
+ width: 100%;
12
13
  z-index: 20;
13
14
 
14
15
  & > * {
@@ -18,15 +18,13 @@
18
18
  flex-direction: column;
19
19
  justify-content: flex-end;
20
20
 
21
+ max-height: var(--viewport-height, 100vh);
22
+
21
23
  position: fixed;
22
24
  inset: 0;
23
25
  z-index: 200;
24
26
 
25
- /* &:before {
26
- content: '';
27
- display: block;
28
- flex-basis: 50%;
29
- } */
27
+ transform: translateY(var(--viewport-top, 0));
30
28
  }
31
29
 
32
30
  &__overlay {
@@ -41,12 +39,14 @@
41
39
  text-align: center;
42
40
  font-weight: bold;
43
41
  margin: theme('spacing.4', 1rem) auto 0;
42
+ position: relative;
44
43
  }
45
44
 
46
45
  &__description {
47
46
  text-align: center;
48
47
  font-size: theme('fontSize.sm', 0.875rem);
49
48
  margin: theme('spacing.1', 0.5rem) auto 0;
49
+ position: relative;
50
50
  }
51
51
 
52
52
  &__content {
@@ -75,7 +75,8 @@
75
75
  }
76
76
 
77
77
  &__content {
78
- @apply pt-4 pb-20;
78
+ padding-top: 1rem;
79
+ padding-bottom: calc(5rem + var(--page-buttons-bottom, 0px));
79
80
  flex-grow: 1;
80
81
  }
81
82
 
@@ -2,6 +2,8 @@ export const TABLE_INDEX_ATTR = 'data-row-index'
2
2
 
3
3
  export const TABLE_ROW_CLICK_EVENT = 'click:row'
4
4
 
5
+ export const TABLE_ROW_PRESS_EVENT = 'press:row'
6
+
5
7
  export const TABLE_HEAD_CLICK_EVENT = 'click:head'
6
8
 
7
9
  export const TABLE_DATA_FETCHED = 'data-fetched'
@@ -85,3 +85,17 @@ export const supportsPassive = () => {
85
85
 
86
86
  return supports
87
87
  }
88
+
89
+ /**
90
+ * Detects screen distance of pointer events
91
+ * @param {PointerEvent} event1
92
+ * @param {PointerEvent} event2
93
+ * @return {Number} distance between event positions
94
+ */
95
+
96
+ export const pointsDistance = (event1, event2) => {
97
+ return Math.sqrt(
98
+ Math.pow(event1.screenX - event2.screenX, 2) +
99
+ Math.pow(event1.screenY - event2.screenY, 2)
100
+ )
101
+ }
@@ -6,14 +6,21 @@
6
6
  >
7
7
  <Component
8
8
  :is="tag"
9
+ v-show="visible"
9
10
  :class="{
10
11
  'aw-dropdown--desktop': !isMobile,
11
12
  'aw-dropdown--mobile': isMobile
12
13
  }"
13
14
  class="aw-dropdown"
14
- v-show="visible"
15
15
  @mouseup="_onClickAction"
16
16
  >
17
+ <!-- overlay -->
18
+ <div
19
+ v-if="isMobile"
20
+ class="aw-dropdown__overlay"
21
+ @click="close"
22
+ ></div>
23
+
17
24
  <!-- heading -->
18
25
  <slot
19
26
  name="heading"
@@ -32,13 +39,6 @@
32
39
  </p>
33
40
  </slot>
34
41
 
35
- <!-- overlay -->
36
- <div
37
- v-if="isMobile"
38
- class="aw-dropdown__overlay"
39
- @click="close"
40
- ></div>
41
-
42
42
  <!-- content -->
43
43
  <div
44
44
  ref="mobileScroller"
@@ -88,9 +88,15 @@ export default {
88
88
  }
89
89
  },
90
90
 
91
- target: String,
91
+ target: {
92
+ type: String,
93
+ default: ''
94
+ },
92
95
 
93
- options: Object,
96
+ options: {
97
+ type: Object,
98
+ default: null
99
+ },
94
100
 
95
101
  closeOnAction: {
96
102
  type: Boolean,
@@ -99,6 +105,8 @@ export default {
99
105
 
100
106
  show: Boolean,
101
107
 
108
+ attachToBody: Boolean,
109
+
102
110
  closeOutside: {
103
111
  type: Boolean,
104
112
  default: true
@@ -129,6 +137,7 @@ export default {
129
137
  return {
130
138
  popper: null,
131
139
  targetEl: null,
140
+ placeholderEl: null,
132
141
  visible: false
133
142
  }
134
143
  },
@@ -231,7 +240,17 @@ export default {
231
240
  }
232
241
  },
233
242
 
243
+ mounted() {
244
+ if (this.attachToBody) {
245
+ this._attachToBody()
246
+ }
247
+ },
248
+
234
249
  beforeDestroy() {
250
+ if (this.attachToBody || this.placeholderEl) {
251
+ this._detachFromBody()
252
+ }
253
+
235
254
  this.removeOutsideClick()
236
255
  this._destroyPopper()
237
256
  enableBodyScroll(this.$refs.mobileScroller)
@@ -241,8 +260,8 @@ export default {
241
260
  _getTargetEl() {
242
261
  if (this.target) {
243
262
  return document.querySelector(this.target)
244
- } else {
245
- return this.$el && this.$el.previousElementSibling
263
+ } else if (this.placeholderEl || this.$el) {
264
+ return (this.placeholderEl || this.$el).previousElementSibling
246
265
  }
247
266
  },
248
267
 
@@ -285,6 +304,35 @@ export default {
285
304
  }
286
305
  },
287
306
 
307
+ _attachToBody() {
308
+ if (
309
+ this.placeholderEl === null &&
310
+ this.$el.parentElement &&
311
+ this.$el.parentElement !== document.body
312
+ ) {
313
+ this.placeholderEl = document.createComment(
314
+ 'dropdown-placeholder-' + this._uid
315
+ )
316
+
317
+ this.$el.parentElement.insertBefore(
318
+ this.placeholderEl,
319
+ this.$el
320
+ )
321
+
322
+ document.body.appendChild(this.$el)
323
+ }
324
+ },
325
+
326
+ _detachFromBody() {
327
+ if (this.placeholderEl) {
328
+ this.placeholderEl.parentElement.replaceChild(
329
+ this.$el,
330
+ this.placeholderEl
331
+ )
332
+ this.placeholderEl = null
333
+ }
334
+ },
335
+
288
336
  update() {
289
337
  if (this.popper) this.popper.forceUpdate()
290
338
  },
@@ -9,7 +9,7 @@
9
9
  </slot>
10
10
 
11
11
  <!-- body -->
12
- <tbody @click="handleRowClick">
12
+ <tbody @pointerdown="handleRowClick">
13
13
  <!-- Table row component, recieves `rows` prop -->
14
14
  <slot name="tr" :rows="rows">
15
15
  <AwTableRow
@@ -18,7 +18,7 @@
18
18
  v-bind="{
19
19
  rowData,
20
20
  rowIndex,
21
- hasRowClickListener,
21
+ hasRowClickListener: hasRowClickListener || hasRowPressListener,
22
22
  columns,
23
23
  isDesktop,
24
24
  mobileHeaderSlots,
@@ -40,10 +40,12 @@
40
40
  <script>
41
41
  import { keys, path, pathOr, is, isNil, mergeDeepRight } from 'rambdax'
42
42
  import { ucFirst, toPascal, toKebap } from '@AwUtils/string'
43
+ import { pointsDistance } from '@AwUtils/events'
43
44
  import { conf } from '@AwUtils/component'
44
45
  import {
45
46
  TABLE_INDEX_ATTR,
46
47
  TABLE_ROW_CLICK_EVENT,
48
+ TABLE_ROW_PRESS_EVENT,
47
49
  TABLE_HEAD_CLICK_EVENT
48
50
  } from '@AwUtils/constants'
49
51
  import AwTableHead from '@AwOrganisms/AwTable/_AwTableHead.vue'
@@ -210,6 +212,10 @@ export default {
210
212
  return TABLE_ROW_CLICK_EVENT in this.$listeners
211
213
  },
212
214
 
215
+ hasRowPressListener() {
216
+ return TABLE_ROW_PRESS_EVENT in this.$listeners
217
+ },
218
+
213
219
  isDesktop() {
214
220
  return (
215
221
  this.breakpoint === 'default' ||
@@ -307,14 +313,47 @@ export default {
307
313
  if (this.checkIfButtonOrLink(target)) return
308
314
 
309
315
  // if table has no row click listener exit
310
- if (!this.hasRowClickListener) return
316
+ if (!this.hasRowClickListener && !this.hasRowPressListener) return
317
+
318
+ let tm
319
+ let onEnd
320
+ let onMove
311
321
 
312
322
  const row = target.closest(`[${TABLE_INDEX_ATTR}]`)
313
323
 
314
- if (row) {
315
- const index = parseInt(row.getAttribute(TABLE_INDEX_ATTR))
316
- const data = this.rows[index]
317
- this.$emit(TABLE_ROW_CLICK_EVENT, data, index, $event)
324
+ const emitEvent = (eventName) => {
325
+ if (row) {
326
+ const index = parseInt(row.getAttribute(TABLE_INDEX_ATTR))
327
+ const data = this.rows[index]
328
+ this.$emit(eventName, data, index, $event)
329
+ }
330
+ }
331
+
332
+ onEnd = () => {
333
+ cleanup()
334
+ emitEvent(TABLE_ROW_CLICK_EVENT)
335
+ }
336
+
337
+ onMove = ($event2) => {
338
+ if (pointsDistance($event, $event2) > 5) {
339
+ cleanup()
340
+ }
341
+ }
342
+
343
+ const cleanup = () => {
344
+ clearTimeout(tm)
345
+ window.removeEventListener('pointerup', onEnd)
346
+ window.removeEventListener('pointermove', onMove)
347
+ }
348
+
349
+ window.addEventListener('pointerup', onEnd)
350
+ window.addEventListener('pointermove', onMove)
351
+
352
+ if (this.hasRowPressListener) {
353
+ tm = setTimeout(() => {
354
+ cleanup()
355
+ emitEvent(TABLE_ROW_PRESS_EVENT)
356
+ }, 500)
318
357
  }
319
358
  },
320
359
 
@@ -183,6 +183,7 @@ import { pathOr, filter, mergeDeepRight, isType } from 'rambdax'
183
183
  import { mergeRouteQuery } from '@AwUtils/router'
184
184
  import {
185
185
  TABLE_ROW_CLICK_EVENT,
186
+ TABLE_ROW_PRESS_EVENT,
186
187
  TABLE_HEAD_CLICK_EVENT,
187
188
  TABLE_DATA_FETCHED
188
189
  } from '@AwUtils/constants'
@@ -386,7 +387,10 @@ export default {
386
387
 
387
388
  tableListeners() {
388
389
  return filter((val, key) => {
389
- return key === TABLE_ROW_CLICK_EVENT
390
+ return (
391
+ TABLE_ROW_CLICK_EVENT === key ||
392
+ TABLE_ROW_PRESS_EVENT === key
393
+ )
390
394
  }, this.$listeners)
391
395
  },
392
396
 
@@ -46,6 +46,9 @@
46
46
  'aw-page__content_fullscreen': isFullscreen || isFakeFullscreen,
47
47
  'aw-page__content_fake-fullscreen': isFakeFullscreen
48
48
  }"
49
+ :style="{
50
+ '--page-buttons-bottom': _hideBottomBar ? null : '4rem'
51
+ }"
49
52
  >
50
53
  <!-- eslint-disable prettier/prettier -->
51
54
  <div :class="[containerClass, { 'aw-page__grid': hasAside }]">
@@ -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
  }
@@ -37,3 +37,37 @@ export default ({ store }, inject) => {
37
37
  })
38
38
  }
39
39
  }
40
+
41
+ /* visual viewport CSS */
42
+ if (typeof window !== 'undefined' && 'visualViewport' in window) {
43
+ let pendingUpdate = false
44
+
45
+ const root = document.documentElement
46
+
47
+ const viewportHandler = (event) => {
48
+ if (pendingUpdate) return
49
+
50
+ pendingUpdate = true
51
+
52
+ requestAnimationFrame(() => {
53
+ pendingUpdate = false
54
+
55
+ var viewport = event.target
56
+
57
+ root.style.setProperty('--viewport-width', viewport.width + 'px')
58
+ root.style.setProperty('--viewport-height', viewport.height + 'px')
59
+ root.style.setProperty('--viewport-top', viewport.offsetTop + 'px')
60
+ root.style.setProperty(
61
+ '--viewport-left',
62
+ viewport.offsetLeft + 'px'
63
+ )
64
+
65
+ // double check!
66
+ setTimeout(viewportHandler, 60, { target: window.visualViewport })
67
+ })
68
+ }
69
+
70
+ window.visualViewport.addEventListener('resize', viewportHandler)
71
+
72
+ viewportHandler({ target: window.visualViewport })
73
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awes-io/ui",
3
- "version": "2.50.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": "4d526ff6da5642c22061bb4538e1d9ed99378747"
125
+ "gitHead": "fc78eb75d3f2e60b94edaad5977d6772e170ad93"
126
126
  }
package/readme.md CHANGED
@@ -1 +1 @@
1
- Awes.io/Ui
1
+ Awes.io/Ui 3443