@pumpkin-tech/pumpkin-tech-ng 0.2.62 → 0.2.64
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/README.md
CHANGED
|
@@ -26,6 +26,19 @@ ng build pumpkin-tech-ng
|
|
|
26
26
|
|
|
27
27
|
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
28
|
|
|
29
|
+
## PTech table pagination
|
|
30
|
+
|
|
31
|
+
`ptech-table` paginates local arrays when `paginator` is enabled. Set
|
|
32
|
+
`serverSidePagination` (or the legacy alias `backendPagination`) when `data`
|
|
33
|
+
already contains a backend page; in that mode the component preserves all
|
|
34
|
+
received rows and emits `page`/`pageChange` for the consumer to load the next
|
|
35
|
+
page. Existing consumers are also recognized automatically when the declared
|
|
36
|
+
total is larger than `data.length` or a non-zero page index is supplied.
|
|
37
|
+
|
|
38
|
+
`responsiveCards` uses the same page as the desktop table. Optional
|
|
39
|
+
`tableAriaLabel`, `paginatorAriaLabel`, and `emptyAriaLabel` inputs provide
|
|
40
|
+
context when a visible title is not enough.
|
|
41
|
+
|
|
29
42
|
### Publishing the Library
|
|
30
43
|
|
|
31
44
|
Once the project is built, you can publish your library by following these steps:
|
|
@@ -6804,6 +6804,9 @@ class TableComponent {
|
|
|
6804
6804
|
shadow = true;
|
|
6805
6805
|
disabled = false;
|
|
6806
6806
|
emptyText = 'Sem dados.';
|
|
6807
|
+
emptyAriaLabel = '';
|
|
6808
|
+
tableAriaLabel = '';
|
|
6809
|
+
paginatorAriaLabel = '';
|
|
6807
6810
|
stickyHeader = false;
|
|
6808
6811
|
rowClickable = false;
|
|
6809
6812
|
data = [];
|
|
@@ -6853,6 +6856,8 @@ class TableComponent {
|
|
|
6853
6856
|
selection = new SelectionModel(this.selectMultipleRow, []);
|
|
6854
6857
|
selectedIdSet = new Set();
|
|
6855
6858
|
dataDiffer;
|
|
6859
|
+
clientPageIndex = 0;
|
|
6860
|
+
clientPageSize = 10;
|
|
6856
6861
|
matTable;
|
|
6857
6862
|
cellTemplates;
|
|
6858
6863
|
actionsTemplate;
|
|
@@ -6887,13 +6892,27 @@ class TableComponent {
|
|
|
6887
6892
|
return !!this.actionsTemplate || !!this.actions?.length;
|
|
6888
6893
|
}
|
|
6889
6894
|
get resolvedTotal() {
|
|
6890
|
-
|
|
6895
|
+
if (!this.usesServerPagination) {
|
|
6896
|
+
return this.data?.length ?? 0;
|
|
6897
|
+
}
|
|
6898
|
+
return this.totalElements ?? this.paginatorLength ?? this.total ?? this.data?.length ?? 0;
|
|
6891
6899
|
}
|
|
6892
6900
|
get resolvedPageIndex() {
|
|
6893
|
-
return this.
|
|
6901
|
+
return this.usesServerPagination
|
|
6902
|
+
? (this.paginatorPageIndex ?? this.pageIndex ?? 0)
|
|
6903
|
+
: this.clientPageIndex;
|
|
6894
6904
|
}
|
|
6895
6905
|
get resolvedPageSize() {
|
|
6896
|
-
return this.
|
|
6906
|
+
return this.usesServerPagination
|
|
6907
|
+
? (this.paginatorPageSize ?? this.pageSize ?? 10)
|
|
6908
|
+
: this.clientPageSize;
|
|
6909
|
+
}
|
|
6910
|
+
get usesServerPagination() {
|
|
6911
|
+
const declaredTotal = this.totalElements ?? this.paginatorLength ?? this.total ?? 0;
|
|
6912
|
+
const declaredPage = this.paginatorPageIndex ?? this.pageIndex ?? 0;
|
|
6913
|
+
return this.serverSidePagination || this.backendPagination
|
|
6914
|
+
|| declaredTotal > (this.data?.length ?? 0)
|
|
6915
|
+
|| declaredPage > 0;
|
|
6897
6916
|
}
|
|
6898
6917
|
normalizeColumn(column) {
|
|
6899
6918
|
const key = this.columnKey(column);
|
|
@@ -6933,6 +6952,12 @@ class TableComponent {
|
|
|
6933
6952
|
if (this.hasActionsColumn)
|
|
6934
6953
|
cols.push('__actions');
|
|
6935
6954
|
this.displayedColumns = cols;
|
|
6955
|
+
if (changes['pageIndex'] || changes['paginatorPageIndex']) {
|
|
6956
|
+
this.clientPageIndex = this.paginatorPageIndex ?? this.pageIndex ?? 0;
|
|
6957
|
+
}
|
|
6958
|
+
if (changes['pageSize'] || changes['paginatorPageSize']) {
|
|
6959
|
+
this.clientPageSize = this.paginatorPageSize ?? this.pageSize ?? 10;
|
|
6960
|
+
}
|
|
6936
6961
|
if (changes['data']) {
|
|
6937
6962
|
this.dataDiffer = this.iterableDiffers.find(this.data || []).create();
|
|
6938
6963
|
this.syncRenderData();
|
|
@@ -6961,7 +6986,16 @@ class TableComponent {
|
|
|
6961
6986
|
}
|
|
6962
6987
|
}
|
|
6963
6988
|
syncRenderData() {
|
|
6964
|
-
|
|
6989
|
+
const rows = this.data || [];
|
|
6990
|
+
if (!this.paginator || this.usesServerPagination) {
|
|
6991
|
+
this.renderData = [...rows];
|
|
6992
|
+
return;
|
|
6993
|
+
}
|
|
6994
|
+
const pageSize = Math.max(1, this.clientPageSize || 10);
|
|
6995
|
+
const lastPageIndex = Math.max(0, Math.ceil(rows.length / pageSize) - 1);
|
|
6996
|
+
this.clientPageIndex = Math.min(Math.max(0, this.clientPageIndex), lastPageIndex);
|
|
6997
|
+
const start = this.clientPageIndex * pageSize;
|
|
6998
|
+
this.renderData = rows.slice(start, start + pageSize);
|
|
6965
6999
|
}
|
|
6966
7000
|
// selecionar/deselecionar todos da PÁGINA atual
|
|
6967
7001
|
toggleAllRows() {
|
|
@@ -7037,6 +7071,12 @@ class TableComponent {
|
|
|
7037
7071
|
return this.selectedIdSet.has(this.getRowId(row));
|
|
7038
7072
|
}
|
|
7039
7073
|
onPage(ev) {
|
|
7074
|
+
if (!this.usesServerPagination) {
|
|
7075
|
+
this.clientPageIndex = ev.pageIndex;
|
|
7076
|
+
this.clientPageSize = ev.pageSize;
|
|
7077
|
+
this.syncRenderData();
|
|
7078
|
+
this.matTable?.renderRows();
|
|
7079
|
+
}
|
|
7040
7080
|
const pageEvent = {
|
|
7041
7081
|
pageIndex: ev.pageIndex,
|
|
7042
7082
|
pageSize: ev.pageSize,
|
|
@@ -7191,7 +7231,7 @@ class TableComponent {
|
|
|
7191
7231
|
});
|
|
7192
7232
|
}
|
|
7193
7233
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TableComponent, deps: [{ token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Component });
|
|
7194
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: TableComponent, isStandalone: true, selector: "ptech-table", inputs: { title: "title", loading: "loading", shadow: "shadow", disabled: "disabled", emptyText: "emptyText", stickyHeader: "stickyHeader", rowClickable: "rowClickable", data: "data", total: "total", pageIndex: "pageIndex", pageSize: "pageSize", pageSizeOptions: "pageSizeOptions", totalElements: "totalElements", paginatorLength: "paginatorLength", paginatorPageIndex: "paginatorPageIndex", paginatorPageSize: "paginatorPageSize", serverSidePagination: "serverSidePagination", backendPagination: "backendPagination", paginator: "paginator", sortField: "sortField", sortDirection: "sortDirection", serverSideSorting: "serverSideSorting", columns: "columns", actions: "actions", actionsDisplay: "actionsDisplay", actionsMenuLabel: "actionsMenuLabel", actionsTriggerColor: "actionsTriggerColor", selectRow: "selectRow", selectMultipleRow: "selectMultipleRow", selectionMode: "selectionMode", usePtechSelectionControls: "usePtechSelectionControls", getRowId: "getRowId", imageFallback: "imageFallback", responsiveCards: "responsiveCards", reorderable: "reorderable" }, outputs: { selectedRows: "selectedRows", selectedRow: "selectedRow", selectedIds: "selectedIds", selectionChange: "selectionChange", page: "page", pageChange: "pageChange", sortChange: "sortChange", rowClick: "rowClick", reorder: "reorder", toggleChange: "toggleChange" }, queries: [{ propertyName: "actionsTemplate", first: true, predicate: ["actions"], descendants: true }, { propertyName: "footerTemplate", first: true, predicate: ["footer"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["empty"], descendants: true }, { propertyName: "cellTemplates", predicate: TableCellDirective }], viewQueries: [{ propertyName: "matTable", first: true, predicate: MatTable, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
7234
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: TableComponent, isStandalone: true, selector: "ptech-table", inputs: { title: "title", loading: "loading", shadow: "shadow", disabled: "disabled", emptyText: "emptyText", emptyAriaLabel: "emptyAriaLabel", tableAriaLabel: "tableAriaLabel", paginatorAriaLabel: "paginatorAriaLabel", stickyHeader: "stickyHeader", rowClickable: "rowClickable", data: "data", total: "total", pageIndex: "pageIndex", pageSize: "pageSize", pageSizeOptions: "pageSizeOptions", totalElements: "totalElements", paginatorLength: "paginatorLength", paginatorPageIndex: "paginatorPageIndex", paginatorPageSize: "paginatorPageSize", serverSidePagination: "serverSidePagination", backendPagination: "backendPagination", paginator: "paginator", sortField: "sortField", sortDirection: "sortDirection", serverSideSorting: "serverSideSorting", columns: "columns", actions: "actions", actionsDisplay: "actionsDisplay", actionsMenuLabel: "actionsMenuLabel", actionsTriggerColor: "actionsTriggerColor", selectRow: "selectRow", selectMultipleRow: "selectMultipleRow", selectionMode: "selectionMode", usePtechSelectionControls: "usePtechSelectionControls", getRowId: "getRowId", imageFallback: "imageFallback", responsiveCards: "responsiveCards", reorderable: "reorderable" }, outputs: { selectedRows: "selectedRows", selectedRow: "selectedRow", selectedIds: "selectedIds", selectionChange: "selectionChange", page: "page", pageChange: "pageChange", sortChange: "sortChange", rowClick: "rowClick", reorder: "reorder", toggleChange: "toggleChange" }, queries: [{ propertyName: "actionsTemplate", first: true, predicate: ["actions"], descendants: true }, { propertyName: "footerTemplate", first: true, predicate: ["footer"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["empty"], descendants: true }, { propertyName: "cellTemplates", predicate: TableCellDirective }], viewQueries: [{ propertyName: "matTable", first: true, predicate: MatTable, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
7195
7235
|
<div class="table-container mat-elevation-z8" [class.disabled]="disabled">
|
|
7196
7236
|
<div class="header-row" *ngIf="title">
|
|
7197
7237
|
<h3>{{ title }}</h3>
|
|
@@ -7213,6 +7253,7 @@ class TableComponent {
|
|
|
7213
7253
|
<div class="table-scroll" [class.hide-on-mobile]="responsiveCards">
|
|
7214
7254
|
<table
|
|
7215
7255
|
mat-table
|
|
7256
|
+
[attr.aria-label]="tableAriaLabel || title || null"
|
|
7216
7257
|
matSort
|
|
7217
7258
|
[matSortActive]="sortField"
|
|
7218
7259
|
[matSortDirection]="sortDirection"
|
|
@@ -7278,7 +7319,6 @@ class TableComponent {
|
|
|
7278
7319
|
[style.width]="cssWidth(c.width)"
|
|
7279
7320
|
[mat-sort-header]="columnKey(c)"
|
|
7280
7321
|
[disabled]="!c.sortable"
|
|
7281
|
-
[sticky]="stickyHeader"
|
|
7282
7322
|
>
|
|
7283
7323
|
<ng-container *ngIf="c.templateHeader; else defaultHeader">
|
|
7284
7324
|
<ng-container *ngTemplateOutlet="c.templateHeader; context: { $implicit: data, column: c }"></ng-container>
|
|
@@ -7433,11 +7473,13 @@ class TableComponent {
|
|
|
7433
7473
|
<div
|
|
7434
7474
|
*ngIf="responsiveCards"
|
|
7435
7475
|
class="cards-container hide-on-desktop"
|
|
7476
|
+
role="list"
|
|
7436
7477
|
>
|
|
7437
7478
|
<div
|
|
7438
7479
|
*ngFor="let row of renderData; let rowIndex = index"
|
|
7439
7480
|
class="card mat-elevation-z8"
|
|
7440
7481
|
[class.selected]="isSelected(row)"
|
|
7482
|
+
role="listitem"
|
|
7441
7483
|
>
|
|
7442
7484
|
<!-- seleção no card -->
|
|
7443
7485
|
<div *ngIf="selectRow" class="card-select">
|
|
@@ -7604,6 +7646,7 @@ class TableComponent {
|
|
|
7604
7646
|
<mat-paginator
|
|
7605
7647
|
*ngIf="paginator"
|
|
7606
7648
|
class="mat-paginator"
|
|
7649
|
+
[attr.aria-label]="paginatorAriaLabel || null"
|
|
7607
7650
|
[length]="resolvedTotal"
|
|
7608
7651
|
[pageIndex]="resolvedPageIndex"
|
|
7609
7652
|
[pageSize]="resolvedPageSize"
|
|
@@ -7614,7 +7657,8 @@ class TableComponent {
|
|
|
7614
7657
|
>
|
|
7615
7658
|
</mat-paginator>
|
|
7616
7659
|
|
|
7617
|
-
<div *ngIf="!renderData?.length" class="muted" style="padding: 12px"
|
|
7660
|
+
<div *ngIf="!renderData?.length" class="muted" style="padding: 12px"
|
|
7661
|
+
role="status" [attr.aria-label]="emptyAriaLabel || null">
|
|
7618
7662
|
<ng-container *ngIf="emptyTemplate; else defaultEmpty">
|
|
7619
7663
|
<ng-container *ngTemplateOutlet="emptyTemplate"></ng-container>
|
|
7620
7664
|
</ng-container>
|
|
@@ -7652,6 +7696,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
7652
7696
|
<div class="table-scroll" [class.hide-on-mobile]="responsiveCards">
|
|
7653
7697
|
<table
|
|
7654
7698
|
mat-table
|
|
7699
|
+
[attr.aria-label]="tableAriaLabel || title || null"
|
|
7655
7700
|
matSort
|
|
7656
7701
|
[matSortActive]="sortField"
|
|
7657
7702
|
[matSortDirection]="sortDirection"
|
|
@@ -7717,7 +7762,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
7717
7762
|
[style.width]="cssWidth(c.width)"
|
|
7718
7763
|
[mat-sort-header]="columnKey(c)"
|
|
7719
7764
|
[disabled]="!c.sortable"
|
|
7720
|
-
[sticky]="stickyHeader"
|
|
7721
7765
|
>
|
|
7722
7766
|
<ng-container *ngIf="c.templateHeader; else defaultHeader">
|
|
7723
7767
|
<ng-container *ngTemplateOutlet="c.templateHeader; context: { $implicit: data, column: c }"></ng-container>
|
|
@@ -7872,11 +7916,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
7872
7916
|
<div
|
|
7873
7917
|
*ngIf="responsiveCards"
|
|
7874
7918
|
class="cards-container hide-on-desktop"
|
|
7919
|
+
role="list"
|
|
7875
7920
|
>
|
|
7876
7921
|
<div
|
|
7877
7922
|
*ngFor="let row of renderData; let rowIndex = index"
|
|
7878
7923
|
class="card mat-elevation-z8"
|
|
7879
7924
|
[class.selected]="isSelected(row)"
|
|
7925
|
+
role="listitem"
|
|
7880
7926
|
>
|
|
7881
7927
|
<!-- seleção no card -->
|
|
7882
7928
|
<div *ngIf="selectRow" class="card-select">
|
|
@@ -8043,6 +8089,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
8043
8089
|
<mat-paginator
|
|
8044
8090
|
*ngIf="paginator"
|
|
8045
8091
|
class="mat-paginator"
|
|
8092
|
+
[attr.aria-label]="paginatorAriaLabel || null"
|
|
8046
8093
|
[length]="resolvedTotal"
|
|
8047
8094
|
[pageIndex]="resolvedPageIndex"
|
|
8048
8095
|
[pageSize]="resolvedPageSize"
|
|
@@ -8053,7 +8100,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
8053
8100
|
>
|
|
8054
8101
|
</mat-paginator>
|
|
8055
8102
|
|
|
8056
|
-
<div *ngIf="!renderData?.length" class="muted" style="padding: 12px"
|
|
8103
|
+
<div *ngIf="!renderData?.length" class="muted" style="padding: 12px"
|
|
8104
|
+
role="status" [attr.aria-label]="emptyAriaLabel || null">
|
|
8057
8105
|
<ng-container *ngIf="emptyTemplate; else defaultEmpty">
|
|
8058
8106
|
<ng-container *ngTemplateOutlet="emptyTemplate"></ng-container>
|
|
8059
8107
|
</ng-container>
|
|
@@ -8076,6 +8124,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
8076
8124
|
type: Input
|
|
8077
8125
|
}], emptyText: [{
|
|
8078
8126
|
type: Input
|
|
8127
|
+
}], emptyAriaLabel: [{
|
|
8128
|
+
type: Input
|
|
8129
|
+
}], tableAriaLabel: [{
|
|
8130
|
+
type: Input
|
|
8131
|
+
}], paginatorAriaLabel: [{
|
|
8132
|
+
type: Input
|
|
8079
8133
|
}], stickyHeader: [{
|
|
8080
8134
|
type: Input
|
|
8081
8135
|
}], rowClickable: [{
|
|
@@ -9610,15 +9664,57 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9610
9664
|
}] } });
|
|
9611
9665
|
|
|
9612
9666
|
class PtechPopoverComponent {
|
|
9667
|
+
host;
|
|
9668
|
+
cdr;
|
|
9613
9669
|
contentTemplate;
|
|
9670
|
+
panel;
|
|
9614
9671
|
position = 'auto';
|
|
9615
9672
|
trigger = 'click';
|
|
9616
9673
|
align = 'start';
|
|
9617
9674
|
dark = false;
|
|
9618
9675
|
opened = false;
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9676
|
+
closeOnScroll = true;
|
|
9677
|
+
closeOnResize = true;
|
|
9678
|
+
viewportSafe = true;
|
|
9679
|
+
viewportMargin = 12;
|
|
9680
|
+
openedChange = new EventEmitter();
|
|
9681
|
+
panelStyle = {};
|
|
9682
|
+
shouldUpdatePosition = false;
|
|
9683
|
+
constructor(host, cdr) {
|
|
9684
|
+
this.host = host;
|
|
9685
|
+
this.cdr = cdr;
|
|
9686
|
+
}
|
|
9687
|
+
ngOnChanges(changes) {
|
|
9688
|
+
if (changes['opened'] && this.opened) {
|
|
9689
|
+
this.markPositionForUpdate();
|
|
9690
|
+
}
|
|
9691
|
+
}
|
|
9692
|
+
ngAfterViewChecked() {
|
|
9693
|
+
if (!this.opened || !this.shouldUpdatePosition)
|
|
9694
|
+
return;
|
|
9695
|
+
this.shouldUpdatePosition = false;
|
|
9696
|
+
this.updatePanelPosition();
|
|
9697
|
+
}
|
|
9698
|
+
onWindowScroll() {
|
|
9699
|
+
if (this.closeOnScroll)
|
|
9700
|
+
this.close();
|
|
9701
|
+
}
|
|
9702
|
+
onWindowResize() {
|
|
9703
|
+
if (this.closeOnResize) {
|
|
9704
|
+
this.close();
|
|
9705
|
+
return;
|
|
9706
|
+
}
|
|
9707
|
+
this.markPositionForUpdate();
|
|
9708
|
+
}
|
|
9709
|
+
open() {
|
|
9710
|
+
this.setOpened(true);
|
|
9711
|
+
}
|
|
9712
|
+
close() {
|
|
9713
|
+
this.setOpened(false);
|
|
9714
|
+
}
|
|
9715
|
+
toggle() {
|
|
9716
|
+
this.setOpened(!this.opened);
|
|
9717
|
+
}
|
|
9622
9718
|
onClick() {
|
|
9623
9719
|
if (this.trigger === 'click')
|
|
9624
9720
|
this.toggle();
|
|
@@ -9631,15 +9727,95 @@ class PtechPopoverComponent {
|
|
|
9631
9727
|
if (this.trigger === 'hover')
|
|
9632
9728
|
this.close();
|
|
9633
9729
|
}
|
|
9634
|
-
|
|
9635
|
-
|
|
9730
|
+
setOpened(opened) {
|
|
9731
|
+
if (this.opened === opened)
|
|
9732
|
+
return;
|
|
9733
|
+
this.opened = opened;
|
|
9734
|
+
this.openedChange.emit(this.opened);
|
|
9735
|
+
if (opened) {
|
|
9736
|
+
this.markPositionForUpdate();
|
|
9737
|
+
}
|
|
9738
|
+
else {
|
|
9739
|
+
this.panelStyle = {};
|
|
9740
|
+
}
|
|
9741
|
+
this.cdr.markForCheck();
|
|
9742
|
+
}
|
|
9743
|
+
markPositionForUpdate() {
|
|
9744
|
+
this.shouldUpdatePosition = true;
|
|
9745
|
+
this.cdr.markForCheck();
|
|
9746
|
+
}
|
|
9747
|
+
updatePanelPosition() {
|
|
9748
|
+
if (!this.viewportSafe || !this.panel?.nativeElement)
|
|
9749
|
+
return;
|
|
9750
|
+
const panel = this.panel.nativeElement;
|
|
9751
|
+
const anchor = this.host.nativeElement.querySelector('.anchor');
|
|
9752
|
+
if (!anchor)
|
|
9753
|
+
return;
|
|
9754
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
9755
|
+
const panelRect = panel.getBoundingClientRect();
|
|
9756
|
+
const viewportWidth = window.innerWidth;
|
|
9757
|
+
const viewportHeight = window.innerHeight;
|
|
9758
|
+
const margin = Math.max(0, this.viewportMargin);
|
|
9759
|
+
const gap = 8;
|
|
9760
|
+
const width = Math.min(panelRect.width, viewportWidth - margin * 2);
|
|
9761
|
+
const height = Math.min(panelRect.height, viewportHeight - margin * 2);
|
|
9762
|
+
let top = this.resolveTop(anchorRect, height, viewportHeight, margin, gap);
|
|
9763
|
+
let left = this.resolveLeft(anchorRect, width, viewportWidth, margin);
|
|
9764
|
+
top = this.clamp(top, margin, viewportHeight - height - margin);
|
|
9765
|
+
left = this.clamp(left, margin, viewportWidth - width - margin);
|
|
9766
|
+
this.panelStyle = {
|
|
9767
|
+
position: 'fixed',
|
|
9768
|
+
top: `${top}px`,
|
|
9769
|
+
left: `${left}px`,
|
|
9770
|
+
right: 'auto',
|
|
9771
|
+
bottom: 'auto',
|
|
9772
|
+
width: `${width}px`,
|
|
9773
|
+
maxWidth: `calc(100vw - ${margin * 2}px)`,
|
|
9774
|
+
maxHeight: `calc(100vh - ${margin * 2}px)`,
|
|
9775
|
+
overflow: 'auto',
|
|
9776
|
+
transform: 'none',
|
|
9777
|
+
};
|
|
9778
|
+
this.cdr.markForCheck();
|
|
9779
|
+
}
|
|
9780
|
+
resolveTop(anchor, panelHeight, viewportHeight, margin, gap) {
|
|
9781
|
+
if (this.position === 'top')
|
|
9782
|
+
return anchor.top - panelHeight - gap;
|
|
9783
|
+
if (this.position === 'left' || this.position === 'right')
|
|
9784
|
+
return anchor.top;
|
|
9785
|
+
const bottomTop = anchor.bottom + gap;
|
|
9786
|
+
const topTop = anchor.top - panelHeight - gap;
|
|
9787
|
+
if (this.position === 'auto' && bottomTop + panelHeight > viewportHeight - margin && topTop >= margin) {
|
|
9788
|
+
return topTop;
|
|
9789
|
+
}
|
|
9790
|
+
return bottomTop;
|
|
9791
|
+
}
|
|
9792
|
+
resolveLeft(anchor, panelWidth, viewportWidth, margin) {
|
|
9793
|
+
if (this.position === 'left')
|
|
9794
|
+
return anchor.left - panelWidth - 8;
|
|
9795
|
+
if (this.position === 'right')
|
|
9796
|
+
return anchor.right + 8;
|
|
9797
|
+
if (this.align === 'end')
|
|
9798
|
+
return anchor.right - panelWidth;
|
|
9799
|
+
if (this.align === 'center')
|
|
9800
|
+
return anchor.left + (anchor.width - panelWidth) / 2;
|
|
9801
|
+
return anchor.left;
|
|
9802
|
+
}
|
|
9803
|
+
clamp(value, min, max) {
|
|
9804
|
+
if (max < min)
|
|
9805
|
+
return min;
|
|
9806
|
+
return Math.min(Math.max(value, min), max);
|
|
9807
|
+
}
|
|
9808
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechPopoverComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
9809
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: PtechPopoverComponent, isStandalone: true, selector: "ptech-popover", inputs: { position: "position", trigger: "trigger", align: "align", dark: "dark", opened: "opened", closeOnScroll: "closeOnScroll", closeOnResize: "closeOnResize", viewportSafe: "viewportSafe", viewportMargin: "viewportMargin" }, outputs: { openedChange: "openedChange" }, host: { listeners: { "window:scroll": "onWindowScroll()", "window:resize": "onWindowResize()" } }, queries: [{ propertyName: "contentTemplate", first: true, predicate: ["content"], descendants: true }], viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
9636
9810
|
<span class="anchor"
|
|
9637
9811
|
(click)="onClick()"
|
|
9638
9812
|
(mouseenter)="onMouseEnter()"
|
|
9639
9813
|
(mouseleave)="onMouseLeave()">
|
|
9640
9814
|
<ng-content select="[trigger]"></ng-content>
|
|
9641
9815
|
<span class="panel"
|
|
9816
|
+
#panel
|
|
9642
9817
|
*ngIf="opened"
|
|
9818
|
+
[ngStyle]="panelStyle"
|
|
9643
9819
|
[class.dark]="dark"
|
|
9644
9820
|
[class.top]="position === 'top'"
|
|
9645
9821
|
[class.bottom]="position === 'bottom' || position === 'auto'"
|
|
@@ -9653,7 +9829,7 @@ class PtechPopoverComponent {
|
|
|
9653
9829
|
<ng-template #projected><ng-content></ng-content></ng-template>
|
|
9654
9830
|
</span>
|
|
9655
9831
|
</span>
|
|
9656
|
-
`, isInline: true, styles: [":host{display:inline-block;position:relative}.anchor{position:relative;display:inline-flex}.panel{position:absolute;z-index:1000;min-width:180px;max-width:min(360px,calc(100vw - 24px));padding:10px 12px;border-radius:8px;background:var(--app-surface, #fff);color:var(--app-text, inherit);border:1px solid var(--app-border-color, rgba(0,0,0,.12));box-shadow:0 14px 36px #0000002e}.panel.dark{background:#1f2937;color:#fff;border-color:#ffffff1f}.bottom{top:calc(100% + 8px);left:0}.top{bottom:calc(100% + 8px);left:0}.left{right:calc(100% + 8px);top:0}.right{left:calc(100% + 8px);top:0}.bottom.align-end,.top.align-end{left:auto;right:0}.bottom.align-center,.top.align-center{left:50%;transform:translate(-50%)}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
9832
|
+
`, isInline: true, styles: [":host{display:inline-block;position:relative}.anchor{position:relative;display:inline-flex}.panel{position:absolute;z-index:1000;min-width:180px;max-width:min(360px,calc(100vw - 24px));padding:10px 12px;border-radius:8px;background:var(--app-surface, #fff);color:var(--app-text, inherit);border:1px solid var(--app-border-color, rgba(0,0,0,.12));box-shadow:0 14px 36px #0000002e}.panel.dark{background:#1f2937;color:#fff;border-color:#ffffff1f}.bottom{top:calc(100% + 8px);left:0}.top{bottom:calc(100% + 8px);left:0}.left{right:calc(100% + 8px);top:0}.right{left:calc(100% + 8px);top:0}.bottom.align-end,.top.align-end{left:auto;right:0}.bottom.align-center,.top.align-center{left:50%;transform:translate(-50%)}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
9657
9833
|
}
|
|
9658
9834
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechPopoverComponent, decorators: [{
|
|
9659
9835
|
type: Component,
|
|
@@ -9664,7 +9840,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9664
9840
|
(mouseleave)="onMouseLeave()">
|
|
9665
9841
|
<ng-content select="[trigger]"></ng-content>
|
|
9666
9842
|
<span class="panel"
|
|
9843
|
+
#panel
|
|
9667
9844
|
*ngIf="opened"
|
|
9845
|
+
[ngStyle]="panelStyle"
|
|
9668
9846
|
[class.dark]="dark"
|
|
9669
9847
|
[class.top]="position === 'top'"
|
|
9670
9848
|
[class.bottom]="position === 'bottom' || position === 'auto'"
|
|
@@ -9679,9 +9857,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9679
9857
|
</span>
|
|
9680
9858
|
</span>
|
|
9681
9859
|
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:inline-block;position:relative}.anchor{position:relative;display:inline-flex}.panel{position:absolute;z-index:1000;min-width:180px;max-width:min(360px,calc(100vw - 24px));padding:10px 12px;border-radius:8px;background:var(--app-surface, #fff);color:var(--app-text, inherit);border:1px solid var(--app-border-color, rgba(0,0,0,.12));box-shadow:0 14px 36px #0000002e}.panel.dark{background:#1f2937;color:#fff;border-color:#ffffff1f}.bottom{top:calc(100% + 8px);left:0}.top{bottom:calc(100% + 8px);left:0}.left{right:calc(100% + 8px);top:0}.right{left:calc(100% + 8px);top:0}.bottom.align-end,.top.align-end{left:auto;right:0}.bottom.align-center,.top.align-center{left:50%;transform:translate(-50%)}\n"] }]
|
|
9682
|
-
}], propDecorators: { contentTemplate: [{
|
|
9860
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { contentTemplate: [{
|
|
9683
9861
|
type: ContentChild,
|
|
9684
9862
|
args: ['content', { static: false }]
|
|
9863
|
+
}], panel: [{
|
|
9864
|
+
type: ViewChild,
|
|
9865
|
+
args: ['panel']
|
|
9685
9866
|
}], position: [{
|
|
9686
9867
|
type: Input
|
|
9687
9868
|
}], trigger: [{
|
|
@@ -9692,6 +9873,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9692
9873
|
type: Input
|
|
9693
9874
|
}], opened: [{
|
|
9694
9875
|
type: Input
|
|
9876
|
+
}], closeOnScroll: [{
|
|
9877
|
+
type: Input
|
|
9878
|
+
}], closeOnResize: [{
|
|
9879
|
+
type: Input
|
|
9880
|
+
}], viewportSafe: [{
|
|
9881
|
+
type: Input
|
|
9882
|
+
}], viewportMargin: [{
|
|
9883
|
+
type: Input
|
|
9884
|
+
}], openedChange: [{
|
|
9885
|
+
type: Output
|
|
9886
|
+
}], onWindowScroll: [{
|
|
9887
|
+
type: HostListener,
|
|
9888
|
+
args: ['window:scroll']
|
|
9889
|
+
}], onWindowResize: [{
|
|
9890
|
+
type: HostListener,
|
|
9891
|
+
args: ['window:resize']
|
|
9695
9892
|
}] } });
|
|
9696
9893
|
|
|
9697
9894
|
class PtechWidgetMenuComponent {
|