@basis-ng/primitives 0.0.1-alpha.148 → 0.0.1-alpha.149
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.
|
@@ -1480,6 +1480,12 @@ class Drawer {
|
|
|
1480
1480
|
* Whether the drawer can be dragged closed.
|
|
1481
1481
|
*/
|
|
1482
1482
|
draggable = input(true, { ...(ngDevMode ? { debugName: "draggable" } : {}), transform: booleanAttribute });
|
|
1483
|
+
/**
|
|
1484
|
+
* Whether clicking outside closes the drawer.
|
|
1485
|
+
* When false, a full-viewport blocking overlay is mounted at body level
|
|
1486
|
+
* so outside clicks (and pointer events) cannot reach other elements.
|
|
1487
|
+
*/
|
|
1488
|
+
closable = input(true, { ...(ngDevMode ? { debugName: "closable" } : {}), transform: booleanAttribute });
|
|
1483
1489
|
/**
|
|
1484
1490
|
* Emitted when the sheet is closed.
|
|
1485
1491
|
*/
|
|
@@ -1512,6 +1518,24 @@ class Drawer {
|
|
|
1512
1518
|
* Element reference to the host component.
|
|
1513
1519
|
*/
|
|
1514
1520
|
el = inject(ElementRef);
|
|
1521
|
+
/**
|
|
1522
|
+
* Body-level blocking overlay used when closable=false to prevent
|
|
1523
|
+
* pointer events from reaching elements behind the open drawer.
|
|
1524
|
+
*/
|
|
1525
|
+
blockingOverlay = null;
|
|
1526
|
+
constructor() {
|
|
1527
|
+
effect(() => {
|
|
1528
|
+
if (this.isOpen() && !this.closable()) {
|
|
1529
|
+
this.mountBlockingOverlay();
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
this.removeBlockingOverlay();
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
ngOnDestroy() {
|
|
1537
|
+
this.removeBlockingOverlay();
|
|
1538
|
+
}
|
|
1515
1539
|
/**
|
|
1516
1540
|
* Close the drawer when clicking outside of it.
|
|
1517
1541
|
* The stopPropagation in the drawer-content prevents clicks inside from closing it.
|
|
@@ -1520,6 +1544,8 @@ class Drawer {
|
|
|
1520
1544
|
closeOnOutsideClick(event) {
|
|
1521
1545
|
if (!this.isOpen())
|
|
1522
1546
|
return;
|
|
1547
|
+
if (!this.closable())
|
|
1548
|
+
return;
|
|
1523
1549
|
const target = event.target;
|
|
1524
1550
|
if (this.el.nativeElement.contains(target)) {
|
|
1525
1551
|
return;
|
|
@@ -1624,8 +1650,35 @@ class Drawer {
|
|
|
1624
1650
|
getCloseDirection() {
|
|
1625
1651
|
return this.side() === 'top' || this.side() === 'left' ? -1 : 1;
|
|
1626
1652
|
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Mounts a transparent full-viewport div at body level that captures all
|
|
1655
|
+
* pointer events, preventing them from reaching elements behind the drawer.
|
|
1656
|
+
*/
|
|
1657
|
+
mountBlockingOverlay() {
|
|
1658
|
+
if (this.blockingOverlay)
|
|
1659
|
+
return;
|
|
1660
|
+
const div = document.createElement('div');
|
|
1661
|
+
div.style.cssText = 'position:fixed;inset:0;z-index:998;';
|
|
1662
|
+
div.addEventListener('pointerdown', (e) => {
|
|
1663
|
+
e.preventDefault();
|
|
1664
|
+
e.stopPropagation();
|
|
1665
|
+
});
|
|
1666
|
+
div.addEventListener('click', (e) => {
|
|
1667
|
+
e.preventDefault();
|
|
1668
|
+
e.stopPropagation();
|
|
1669
|
+
});
|
|
1670
|
+
document.body.appendChild(div);
|
|
1671
|
+
this.blockingOverlay = div;
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Removes the blocking overlay from the DOM if present.
|
|
1675
|
+
*/
|
|
1676
|
+
removeBlockingOverlay() {
|
|
1677
|
+
this.blockingOverlay?.remove();
|
|
1678
|
+
this.blockingOverlay = null;
|
|
1679
|
+
}
|
|
1627
1680
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: Drawer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1628
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.8", type: Drawer, isStandalone: true, selector: "b-drawer", inputs: { isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, draggable: { classPropertyName: "draggable", publicName: "draggable", isSignal: true, isRequired: false, transformFunction: null }, closeThreshold: { classPropertyName: "closeThreshold", publicName: "closeThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isOpen: "isOpenChange", closeSheet: "closeSheet" }, host: { listeners: { "document:click": "closeOnOutsideClick($event)" }, properties: { "class.bottom": "side() === \"bottom\"", "class.draggable": "draggable()", "class.dragging": "isDragging()", "class.left": "side() === \"left\"", "class.open": "isOpen()", "class.right": "side() === \"right\"", "class.top": "side() === \"top\"", "style.transform": "transform()" } }, ngImport: i0, template: `
|
|
1681
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.8", type: Drawer, isStandalone: true, selector: "b-drawer", inputs: { isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, draggable: { classPropertyName: "draggable", publicName: "draggable", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, closeThreshold: { classPropertyName: "closeThreshold", publicName: "closeThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isOpen: "isOpenChange", closeSheet: "closeSheet" }, host: { listeners: { "document:click": "closeOnOutsideClick($event)" }, properties: { "class.bottom": "side() === \"bottom\"", "class.draggable": "draggable()", "class.dragging": "isDragging()", "class.left": "side() === \"left\"", "class.open": "isOpen()", "class.right": "side() === \"right\"", "class.top": "side() === \"top\"", "style.transform": "transform()" } }, ngImport: i0, template: `
|
|
1629
1682
|
@if (draggable()) {
|
|
1630
1683
|
<div class="drag-section" (pointerdown)="startDrag($event)">
|
|
1631
1684
|
<div class="drag-indicator"></div>
|
|
@@ -1665,7 +1718,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
1665
1718
|
'[style.transform]': 'transform()',
|
|
1666
1719
|
},
|
|
1667
1720
|
}]
|
|
1668
|
-
}], propDecorators: { isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }, { type: i0.Output, args: ["isOpenChange"] }], side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], draggable: [{ type: i0.Input, args: [{ isSignal: true, alias: "draggable", required: false }] }], closeSheet: [{ type: i0.Output, args: ["closeSheet"] }], closeThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeThreshold", required: false }] }], closeOnOutsideClick: [{
|
|
1721
|
+
}], ctorParameters: () => [], propDecorators: { isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }, { type: i0.Output, args: ["isOpenChange"] }], side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], draggable: [{ type: i0.Input, args: [{ isSignal: true, alias: "draggable", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], closeSheet: [{ type: i0.Output, args: ["closeSheet"] }], closeThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeThreshold", required: false }] }], closeOnOutsideClick: [{
|
|
1669
1722
|
type: HostListener,
|
|
1670
1723
|
args: ['document:click', ['$event']]
|
|
1671
1724
|
}] } });
|