@eturnity/eturnity_reusable_components 9.25.16 → 9.25.17
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/package.json
CHANGED
|
@@ -382,8 +382,9 @@
|
|
|
382
382
|
position: absolute;
|
|
383
383
|
z-index: 99;
|
|
384
384
|
top: 8px;
|
|
385
|
-
left
|
|
386
|
-
|
|
385
|
+
/* Anchor to the trigger's left and grow rightward; clampBoxToViewport()
|
|
386
|
+
shifts it back in when wide content would overflow the viewport. */
|
|
387
|
+
left: 0;
|
|
387
388
|
width: max-content;
|
|
388
389
|
max-width: calc(100vw - 32px);
|
|
389
390
|
background-color: ${(props) => props.theme.colors.white};
|
|
@@ -501,6 +502,7 @@
|
|
|
501
502
|
data() {
|
|
502
503
|
return {
|
|
503
504
|
isOptionsVisible: false,
|
|
505
|
+
boxResizeObserver: null,
|
|
504
506
|
}
|
|
505
507
|
},
|
|
506
508
|
computed: {
|
|
@@ -514,10 +516,63 @@
|
|
|
514
516
|
return getDateFormat(this.activeLanguage)
|
|
515
517
|
},
|
|
516
518
|
},
|
|
519
|
+
watch: {
|
|
520
|
+
// Keep the filter box on screen: clamp on open and whenever its content
|
|
521
|
+
// resizes (e.g. a wide value is selected) or the window resizes.
|
|
522
|
+
isOptionsVisible(visible) {
|
|
523
|
+
if (visible) {
|
|
524
|
+
this.$nextTick(() => {
|
|
525
|
+
this.clampBoxToViewport()
|
|
526
|
+
this.observeBoxResize()
|
|
527
|
+
window.addEventListener('resize', this.clampBoxToViewport)
|
|
528
|
+
})
|
|
529
|
+
} else {
|
|
530
|
+
this.teardownBoxObservers()
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
},
|
|
517
534
|
beforeUnmount() {
|
|
518
535
|
document.removeEventListener('click', this.handleClickOutside)
|
|
536
|
+
this.teardownBoxObservers()
|
|
519
537
|
},
|
|
520
538
|
methods: {
|
|
539
|
+
// Shift the absolutely-positioned filter box left when its right edge
|
|
540
|
+
// would overflow the viewport, then clamp so the left edge stays visible.
|
|
541
|
+
clampBoxToViewport() {
|
|
542
|
+
const el = this.$refs.boxContainer?.$el
|
|
543
|
+
if (!el) {
|
|
544
|
+
return
|
|
545
|
+
}
|
|
546
|
+
el.style.transform = 'none'
|
|
547
|
+
const rect = el.getBoundingClientRect()
|
|
548
|
+
const margin = 16
|
|
549
|
+
const viewportWidth = window.innerWidth
|
|
550
|
+
let shift = 0
|
|
551
|
+
if (rect.right > viewportWidth - margin) {
|
|
552
|
+
shift = viewportWidth - margin - rect.right
|
|
553
|
+
}
|
|
554
|
+
if (rect.left + shift < margin) {
|
|
555
|
+
shift = margin - rect.left
|
|
556
|
+
}
|
|
557
|
+
el.style.transform = shift !== 0 ? `translateX(${shift}px)` : 'none'
|
|
558
|
+
},
|
|
559
|
+
observeBoxResize() {
|
|
560
|
+
const el = this.$refs.boxContainer?.$el
|
|
561
|
+
if (!el || typeof ResizeObserver === 'undefined') {
|
|
562
|
+
return
|
|
563
|
+
}
|
|
564
|
+
this.boxResizeObserver = new ResizeObserver(() =>
|
|
565
|
+
this.clampBoxToViewport()
|
|
566
|
+
)
|
|
567
|
+
this.boxResizeObserver.observe(el)
|
|
568
|
+
},
|
|
569
|
+
teardownBoxObservers() {
|
|
570
|
+
if (this.boxResizeObserver) {
|
|
571
|
+
this.boxResizeObserver.disconnect()
|
|
572
|
+
this.boxResizeObserver = null
|
|
573
|
+
}
|
|
574
|
+
window.removeEventListener('resize', this.clampBoxToViewport)
|
|
575
|
+
},
|
|
521
576
|
isDateColumn(column) {
|
|
522
577
|
if (column === 'updated') {
|
|
523
578
|
return true
|