@awes-io/ui 2.51.0 → 2.53.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 +28 -0
- package/assets/css/components/dropdown.css +5 -5
- package/assets/js/constants.js +2 -0
- package/assets/js/events.js +14 -0
- package/components/1_atoms/AwDropdown.vue +60 -12
- package/components/3_organisms/AwTable/AwTable.vue +46 -7
- package/components/3_organisms/AwTable/AwTableBuilder.vue +5 -1
- package/nuxt/templates/screen.plugin.js +34 -0
- package/package.json +2 -2
- package/readme.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* new version ([c64a7a1](https://github.com/awes-io/client/commit/c64a7a10bb55e8f5e5196912f8d70bf8350fd831))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **aw-table:** falsy clicks fixed ([ff1004b](https://github.com/awes-io/client/commit/ff1004b47ea527bb71a6d99e44df307be3df4223))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* set dropdown max height by viewport ([4ec3589](https://github.com/awes-io/client/commit/4ec3589eb6691fad198ff83a99333724e9ae3900))
|
|
28
|
+
* table press event added ([b8bf19a](https://github.com/awes-io/client/commit/b8bf19a4e1262d9e3a0e7044490081020009e3af))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
# [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)
|
|
7
35
|
|
|
8
36
|
|
|
@@ -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
|
-
|
|
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 {
|
package/assets/js/constants.js
CHANGED
package/assets/js/events.js
CHANGED
|
@@ -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:
|
|
91
|
+
target: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: ''
|
|
94
|
+
},
|
|
92
95
|
|
|
93
|
-
options:
|
|
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
|
|
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 @
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
|
390
|
+
return (
|
|
391
|
+
TABLE_ROW_CLICK_EVENT === key ||
|
|
392
|
+
TABLE_ROW_PRESS_EVENT === key
|
|
393
|
+
)
|
|
390
394
|
}, this.$listeners)
|
|
391
395
|
},
|
|
392
396
|
|
|
@@ -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.
|
|
3
|
+
"version": "2.53.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": "
|
|
125
|
+
"gitHead": "bdd10f2d121d75c137381357d3dbc72119b40630"
|
|
126
126
|
}
|
package/readme.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Awes.io/Ui
|
|
1
|
+
Awes.io/Ui 3443
|