@basis-ng/primitives 0.0.1-alpha.145 → 0.0.1-alpha.146
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, output, Component, inject, ElementRef, signal, model, computed, viewChildren, booleanAttribute, ChangeDetectionStrategy, contentChildren, effect, Injectable, contentChild, ViewEncapsulation,
|
|
2
|
+
import { input, output, Component, inject, ElementRef, signal, model, computed, viewChildren, booleanAttribute, ChangeDetectionStrategy, contentChildren, effect, Injectable, contentChild, ViewEncapsulation, viewChild, Directive, linkedSignal, TemplateRef, ChangeDetectorRef, Pipe, afterRenderEffect, RendererFactory2, PLATFORM_ID } from '@angular/core';
|
|
3
3
|
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
4
4
|
import { lucideX, lucideChevronRight, lucideChevronLeft, lucideLoaderCircle, lucideLoader, lucideGripVertical } from '@ng-icons/lucide';
|
|
5
5
|
import { GridCellWidget, Grid, GridRow, GridCell } from '@angular/aria/grid';
|
|
@@ -1468,6 +1468,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
1468
1468
|
* A draggable floating drawer that can slide from any side.
|
|
1469
1469
|
*/
|
|
1470
1470
|
class Drawer {
|
|
1471
|
+
panel = viewChild.required('panel');
|
|
1471
1472
|
/**
|
|
1472
1473
|
* Model indicating whether the drawer is open.
|
|
1473
1474
|
*/
|
|
@@ -1505,32 +1506,13 @@ class Drawer {
|
|
|
1505
1506
|
*/
|
|
1506
1507
|
transform = computed(() => this.getTransform(this.currentProgress()), ...(ngDevMode ? [{ debugName: "transform" }] : []));
|
|
1507
1508
|
/**
|
|
1508
|
-
*
|
|
1509
|
-
*/
|
|
1510
|
-
currentProgress = computed(() => this.isDragging() ? this.dragProgress() : this.isOpen() ? 0 : 100, ...(ngDevMode ? [{ debugName: "currentProgress" }] : []));
|
|
1511
|
-
/**
|
|
1512
|
-
* Element reference to the host component.
|
|
1509
|
+
* Backdrop opacity that tracks the drawer open progress.
|
|
1513
1510
|
*/
|
|
1514
|
-
|
|
1511
|
+
backdropOpacity = computed(() => ((100 - this.currentProgress()) / 100) * 0.14, ...(ngDevMode ? [{ debugName: "backdropOpacity" }] : []));
|
|
1515
1512
|
/**
|
|
1516
|
-
*
|
|
1517
|
-
* The stopPropagation in the drawer-content prevents clicks inside from closing it.
|
|
1518
|
-
* @param event - Click event.
|
|
1513
|
+
* Current progress to use for the rendered transform.
|
|
1519
1514
|
*/
|
|
1520
|
-
|
|
1521
|
-
if (!this.isOpen())
|
|
1522
|
-
return;
|
|
1523
|
-
const target = event.target;
|
|
1524
|
-
// Check if click is inside the drawer
|
|
1525
|
-
if (this.el.nativeElement.contains(target)) {
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
// Check if click is inside a CDK overlay (select dropdown, dialogs, etc.)
|
|
1529
|
-
if (target.closest('.cdk-overlay-container')) {
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
this.close();
|
|
1533
|
-
}
|
|
1515
|
+
currentProgress = computed(() => this.isDragging() ? this.dragProgress() : this.isOpen() ? 0 : 100, ...(ngDevMode ? [{ debugName: "currentProgress" }] : []));
|
|
1534
1516
|
/**
|
|
1535
1517
|
* Begin tracking pointer movement for drag-to-dismiss.
|
|
1536
1518
|
* @param event - Pointer down event.
|
|
@@ -1563,7 +1545,7 @@ class Drawer {
|
|
|
1563
1545
|
* @param event - Current pointer event.
|
|
1564
1546
|
*/
|
|
1565
1547
|
updateDrag(event) {
|
|
1566
|
-
const host = this.
|
|
1548
|
+
const host = this.panel().nativeElement;
|
|
1567
1549
|
const pointerOffset = this.getPointerOffset(event);
|
|
1568
1550
|
const deltaPx = (pointerOffset - this.startOffset()) * this.getCloseDirection();
|
|
1569
1551
|
const size = this.isHorizontal() ? host.offsetWidth : host.offsetHeight;
|
|
@@ -1579,7 +1561,7 @@ class Drawer {
|
|
|
1579
1561
|
*/
|
|
1580
1562
|
snapToOpenOrClose() {
|
|
1581
1563
|
if (this.dragProgress() > this.closeThreshold()) {
|
|
1582
|
-
this.
|
|
1564
|
+
this.requestClose();
|
|
1583
1565
|
}
|
|
1584
1566
|
else {
|
|
1585
1567
|
this.isOpen.set(true);
|
|
@@ -1588,7 +1570,7 @@ class Drawer {
|
|
|
1588
1570
|
/**
|
|
1589
1571
|
* Closes the drawer and emits the close event.
|
|
1590
1572
|
*/
|
|
1591
|
-
|
|
1573
|
+
requestClose() {
|
|
1592
1574
|
this.isOpen.set(false);
|
|
1593
1575
|
this.closeSheet.emit();
|
|
1594
1576
|
}
|
|
@@ -1627,14 +1609,30 @@ class Drawer {
|
|
|
1627
1609
|
return this.side() === 'top' || this.side() === 'left' ? -1 : 1;
|
|
1628
1610
|
}
|
|
1629
1611
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: Drawer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1630
|
-
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: {
|
|
1631
|
-
@if (
|
|
1632
|
-
<div
|
|
1633
|
-
|
|
1634
|
-
|
|
1612
|
+
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: { properties: { "class.bottom": "side() === \"bottom\"", "class.dragging": "isDragging()", "class.left": "side() === \"left\"", "class.open": "isOpen()", "class.right": "side() === \"right\"", "class.top": "side() === \"top\"" } }, viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1613
|
+
@if (isOpen() || isDragging()) {
|
|
1614
|
+
<div
|
|
1615
|
+
class="drawer-backdrop"
|
|
1616
|
+
[style.opacity]="backdropOpacity()"
|
|
1617
|
+
(click)="requestClose()"
|
|
1618
|
+
></div>
|
|
1635
1619
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1620
|
+
|
|
1621
|
+
<div
|
|
1622
|
+
#panel
|
|
1623
|
+
class="drawer-panel"
|
|
1624
|
+
[style.transform]="transform()"
|
|
1625
|
+
(click)="$event.stopPropagation()"
|
|
1626
|
+
>
|
|
1627
|
+
@if (draggable()) {
|
|
1628
|
+
<div class="drag-section" (pointerdown)="startDrag($event)">
|
|
1629
|
+
<div class="drag-indicator"></div>
|
|
1630
|
+
</div>
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
<div class="drawer-content" (click)="$event.stopPropagation()">
|
|
1634
|
+
<ng-content />
|
|
1635
|
+
</div>
|
|
1638
1636
|
</div>
|
|
1639
1637
|
`, isInline: true });
|
|
1640
1638
|
}
|
|
@@ -1645,13 +1643,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
1645
1643
|
standalone: true,
|
|
1646
1644
|
imports: [],
|
|
1647
1645
|
template: `
|
|
1648
|
-
@if (
|
|
1649
|
-
<div
|
|
1650
|
-
|
|
1651
|
-
|
|
1646
|
+
@if (isOpen() || isDragging()) {
|
|
1647
|
+
<div
|
|
1648
|
+
class="drawer-backdrop"
|
|
1649
|
+
[style.opacity]="backdropOpacity()"
|
|
1650
|
+
(click)="requestClose()"
|
|
1651
|
+
></div>
|
|
1652
1652
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1653
|
+
|
|
1654
|
+
<div
|
|
1655
|
+
#panel
|
|
1656
|
+
class="drawer-panel"
|
|
1657
|
+
[style.transform]="transform()"
|
|
1658
|
+
(click)="$event.stopPropagation()"
|
|
1659
|
+
>
|
|
1660
|
+
@if (draggable()) {
|
|
1661
|
+
<div class="drag-section" (pointerdown)="startDrag($event)">
|
|
1662
|
+
<div class="drag-indicator"></div>
|
|
1663
|
+
</div>
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
<div class="drawer-content" (click)="$event.stopPropagation()">
|
|
1667
|
+
<ng-content />
|
|
1668
|
+
</div>
|
|
1655
1669
|
</div>
|
|
1656
1670
|
`,
|
|
1657
1671
|
host: {
|
|
@@ -1661,13 +1675,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
1661
1675
|
'[class.open]': 'isOpen()',
|
|
1662
1676
|
'[class.right]': 'side() === "right"',
|
|
1663
1677
|
'[class.top]': 'side() === "top"',
|
|
1664
|
-
'[style.transform]': 'transform()',
|
|
1665
1678
|
},
|
|
1666
1679
|
}]
|
|
1667
|
-
}], 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 }] }]
|
|
1668
|
-
type: HostListener,
|
|
1669
|
-
args: ['document:click', ['$event']]
|
|
1670
|
-
}] } });
|
|
1680
|
+
}], propDecorators: { panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], 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 }] }] } });
|
|
1671
1681
|
|
|
1672
1682
|
/**
|
|
1673
1683
|
* Wrapper for grouping input-related elements.
|