@awes-io/ui 2.49.1 → 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 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.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
+
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)
35
+
36
+
37
+ ### Features
38
+
39
+ * **aw-bottom-bar:** fixed position to prevent jumps on ios ([c9b32bb](https://github.com/awes-io/client/commit/c9b32bbbb7c109a9f5c3abede7a2aeb7a7c543b9))
40
+
41
+
42
+
43
+
44
+
45
+ # [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)
46
+
47
+
48
+ ### Features
49
+
50
+ * calendar day slots added ([b9b0897](https://github.com/awes-io/client/commit/b9b0897806fe2f86aa51bc1b472482fab017ce91))
51
+
52
+
53
+
54
+
55
+
6
56
  ## [2.49.1](https://github.com/awes-io/client/compare/@awes-io/ui@2.49.0...@awes-io/ui@2.49.1) (2022-05-31)
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
  },
@@ -32,7 +32,11 @@
32
32
  :day-class="_getDayClass"
33
33
  :day-disabled="_isDisabled"
34
34
  :show-today="showToday"
35
- />
35
+ >
36
+ <template v-for="name in _proxiedDaySlots" #[name]="slotData">
37
+ <slot :name="name" v-bind="slotData"></slot>
38
+ </template>
39
+ </AwCalendarDays>
36
40
 
37
41
  <slot name="footer" />
38
42
  </div>
@@ -11,7 +11,14 @@
11
11
  :year="year"
12
12
  :day-class="dayClass"
13
13
  :day-disabled="dayDisabled"
14
- />
14
+ >
15
+ <template
16
+ v-for="name in $options.PROXIED_DAY_SLOTS"
17
+ #[name]="slotData"
18
+ >
19
+ <slot :name="name" v-bind="slotData"></slot>
20
+ </template>
21
+ </AwCalendarDays>
15
22
  </div>
16
23
  </template>
17
24
 
@@ -21,7 +28,7 @@ import { AwCalendar as _config } from '@AwConfig'
21
28
  import { CONFIG_VAR } from '@AwUtils/component'
22
29
  import AwCalendarWeekdays from '@AwOrganisms/AwCalendar/_AwCalendarWeekdays.vue'
23
30
  import AwCalendarDays from '@AwOrganisms/AwCalendar/_AwCalendarDays.vue'
24
- import { getDateFromEvent } from '@AwMixins/calendar'
31
+ import { PROXIED_DAY_SLOTS, getDateFromEvent } from '@AwMixins/calendar'
25
32
 
26
33
  export default {
27
34
  name: '',
@@ -31,6 +38,8 @@ export default {
31
38
  AwCalendarDays
32
39
  },
33
40
 
41
+ PROXIED_DAY_SLOTS,
42
+
34
43
  props: {
35
44
  ...AwCalendarDays.props,
36
45
 
@@ -7,7 +7,14 @@
7
7
  tabindex="-1"
8
8
  class="aw-calendar__day"
9
9
  >
10
- <span> {{ props.day }} </span>
10
+ <slot name="day" v-bind="props">
11
+ <slot v-if="props.isOutside" v-bind="props" name="day-outside">
12
+ <span> {{ props.day }} </span>
13
+ </slot>
14
+ <slot v-else v-bind="props" name="day-inside">
15
+ <span> {{ props.day }} </span>
16
+ </slot>
17
+ </slot>
11
18
  </button>
12
19
  </template>
13
20
 
@@ -24,7 +31,16 @@ export default {
24
31
  timestamp: {
25
32
  type: Number,
26
33
  required: true
27
- }
34
+ },
35
+
36
+ month: {
37
+ type: Number,
38
+ required: true
39
+ },
40
+
41
+ isOutside: Boolean,
42
+
43
+ isToday: Boolean
28
44
  }
29
45
  }
30
46
  </script>
@@ -78,7 +78,7 @@ export default {
78
78
  }
79
79
  },
80
80
 
81
- render(h, { props, parent }) {
81
+ render(h, { props, parent, scopedSlots }) {
82
82
  const {
83
83
  year,
84
84
  month,
@@ -101,24 +101,29 @@ export default {
101
101
 
102
102
  return dates.map((date) => {
103
103
  const timestamp = date.setHours(0, 0, 0, 0)
104
+ const isOutside = date.getMonth() !== month
105
+ const isToday = showToday && timestamp === today
104
106
 
105
107
  return h(AwCalendarDay, {
106
108
  key: timestamp,
107
109
  props: {
108
110
  timestamp,
109
- day: date.getDate()
111
+ day: date.getDate(),
112
+ month,
113
+ isOutside,
114
+ isToday
110
115
  },
111
116
  class: [
112
117
  {
113
- 'aw-calendar__day_outside': date.getMonth() !== month,
114
- 'aw-calendar__day_today':
115
- showToday && timestamp === today
118
+ 'aw-calendar__day_outside': isOutside,
119
+ 'aw-calendar__day_today': isToday
116
120
  },
117
121
  dayClass(date)
118
122
  ],
119
123
  attrs: {
120
124
  disabled: dayDisabled(date)
121
- }
125
+ },
126
+ scopedSlots
122
127
  })
123
128
  })
124
129
  }
@@ -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 }]">
@@ -18,6 +18,8 @@ export function getDateFromEvent($event) {
18
18
  return new Date(timestamp)
19
19
  }
20
20
 
21
+ export const PROXIED_DAY_SLOTS = ['day', 'day-outside', 'day-inside']
22
+
21
23
  export default {
22
24
  props: {
23
25
  /**
@@ -273,6 +275,10 @@ export default {
273
275
  } else {
274
276
  return (_dayjs) => _dayjs.format(this.outputFormat)
275
277
  }
278
+ },
279
+
280
+ _proxiedDaySlots() {
281
+ return PROXIED_DAY_SLOTS
276
282
  }
277
283
  },
278
284
 
@@ -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.49.1",
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": "88e19d99b3529c4da104ff9517679b6fa795d022"
125
+ "gitHead": "bdd10f2d121d75c137381357d3dbc72119b40630"
126
126
  }
package/readme.md CHANGED
@@ -1 +1 @@
1
- Awes.io/Ui
1
+ Awes.io/Ui 3443