@nanahoshi/mona-ui 0.22.1 → 0.23.1
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/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-CIMXz60d.mjs +169 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-CpeheGXU.mjs +176 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-toggle.component-DZDeYdqc.mjs → nanahoshi-mona-ui-grid-grid-row.component-B_5ay_Nz.mjs} +201 -192
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-BzKywU5b.mjs +173 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C_mj53LF.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-IewqeT4m.mjs} +554 -667
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +47 -7
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +386 -180
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +266 -99
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +35 -32
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1 -1
- package/package.json +1 -1
- package/types/nanahoshi-mona-ui-grid.d.ts +126 -26
- package/types/nanahoshi-mona-ui-i18n.d.ts +1 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +35 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +82 -16
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +50 -3
- package/types/nanahoshi-mona-ui-internal.d.ts +18 -4
- package/types/nanahoshi-mona-ui-locales.d.ts +13 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-blRlw0Ie.mjs +0 -108
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-Cviex3cR.mjs +0 -44
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-H38ZTj-_.mjs +0 -164
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-b1W7r45p.mjs +0 -239
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, computed, input, Directive, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { a as GridService, v as gridFooterTableCellThemeVariants, w as gridFooterTableRowThemeVariants, m as GridLockedCellDirective } from './nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-IewqeT4m.mjs';
|
|
4
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
5
|
+
import { ImmutableDictionary } from '@mirei/ts-collections';
|
|
6
|
+
|
|
7
|
+
class GridFooterTableCellDirective {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.#gridService = inject(GridService, { optional: true });
|
|
10
|
+
this.className = computed(() => {
|
|
11
|
+
return (gridFooterTableCellThemeVariants() +
|
|
12
|
+
(this.#gridService?.virtualScrollOptions().enabled
|
|
13
|
+
? " h-(--mona-grid-row-height) max-h-(--mona-grid-row-height) overflow-hidden py-0! align-middle"
|
|
14
|
+
: ""));
|
|
15
|
+
}, /* @ts-ignore */
|
|
16
|
+
...(ngDevMode ? [{ debugName: "className" }] : /* istanbul ignore next */ []));
|
|
17
|
+
this.minWidth = computed(() => this.footerColumn()?.minWidth ?? this.footerCellMinWidth(), /* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [{ debugName: "minWidth" }] : /* istanbul ignore next */ []));
|
|
19
|
+
this.width = computed(() => this.footerColumn()?.calculatedWidth ?? this.footerCellWidth(), /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
21
|
+
this.footerCellMinWidth = input(null, /* @ts-ignore */
|
|
22
|
+
...(ngDevMode ? [{ debugName: "footerCellMinWidth" }] : /* istanbul ignore next */ []));
|
|
23
|
+
this.footerCellWidth = input(null, /* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [{ debugName: "footerCellWidth" }] : /* istanbul ignore next */ []));
|
|
25
|
+
this.footerColumn = input(null, /* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "footerColumn" }] : /* istanbul ignore next */ []));
|
|
27
|
+
}
|
|
28
|
+
#gridService;
|
|
29
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridFooterTableCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
30
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: GridFooterTableCellDirective, isStandalone: true, selector: "td[monaGridFooterTableCell]", inputs: { footerCellMinWidth: { classPropertyName: "footerCellMinWidth", publicName: "footerCellMinWidth", isSignal: true, isRequired: false, transformFunction: null }, footerCellWidth: { classPropertyName: "footerCellWidth", publicName: "footerCellWidth", isSignal: true, isRequired: false, transformFunction: null }, footerColumn: { classPropertyName: "footerColumn", publicName: "footerColumn", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "gridcell" }, properties: { "class": "className()", "style.width.px": "width()", "style.min-width.px": "minWidth()" } }, ngImport: i0 }); }
|
|
31
|
+
}
|
|
32
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridFooterTableCellDirective, decorators: [{
|
|
33
|
+
type: Directive,
|
|
34
|
+
args: [{
|
|
35
|
+
selector: "td[monaGridFooterTableCell]",
|
|
36
|
+
host: {
|
|
37
|
+
"[class]": "className()",
|
|
38
|
+
"[style.width.px]": "width()",
|
|
39
|
+
"[style.min-width.px]": "minWidth()",
|
|
40
|
+
role: "gridcell"
|
|
41
|
+
}
|
|
42
|
+
}]
|
|
43
|
+
}], propDecorators: { footerCellMinWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "footerCellMinWidth", required: false }] }], footerCellWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "footerCellWidth", required: false }] }], footerColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "footerColumn", required: false }] }] } });
|
|
44
|
+
|
|
45
|
+
class GridFooterCellComponent {
|
|
46
|
+
constructor() {
|
|
47
|
+
this.#gridService = inject(GridService);
|
|
48
|
+
this.aggregate = computed(() => {
|
|
49
|
+
const field = this.column().field;
|
|
50
|
+
const groupKey = this.groupKey();
|
|
51
|
+
if (groupKey == null) {
|
|
52
|
+
return this.aggregateMap().get(field) ?? null;
|
|
53
|
+
}
|
|
54
|
+
return this.#gridService.groupAggregateMap().get(groupKey)?.aggregates.get(field) ?? null;
|
|
55
|
+
}, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "aggregate" }] : /* istanbul ignore next */ []));
|
|
57
|
+
this.aggregateMap = computed(() => {
|
|
58
|
+
const groupKey = this.groupKey();
|
|
59
|
+
if (groupKey == null) {
|
|
60
|
+
return this.#gridService.aggregateMap();
|
|
61
|
+
}
|
|
62
|
+
return (this.#gridService.groupAggregateMap().get(groupKey)?.aggregates ??
|
|
63
|
+
ImmutableDictionary.create());
|
|
64
|
+
}, /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "aggregateMap" }] : /* istanbul ignore next */ []));
|
|
66
|
+
this.displayValue = computed(() => {
|
|
67
|
+
return this.#gridService.resolveAggregateValue(this.aggregate(), this.column().aggregate);
|
|
68
|
+
}, /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
|
|
70
|
+
this.templateContext = computed(() => {
|
|
71
|
+
const column = this.column();
|
|
72
|
+
const columnIndex = this.columnIndex();
|
|
73
|
+
const aggregate = this.aggregate();
|
|
74
|
+
const aggregates = this.aggregateMap().toObject(e => e.key, e => e.value);
|
|
75
|
+
const value = this.displayValue();
|
|
76
|
+
const groupKey = this.groupKey();
|
|
77
|
+
if (groupKey == null) {
|
|
78
|
+
return {
|
|
79
|
+
$implicit: value,
|
|
80
|
+
aggregate,
|
|
81
|
+
aggregates,
|
|
82
|
+
column,
|
|
83
|
+
columnIndex,
|
|
84
|
+
rows: this.#gridService.aggregateRows()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const groupFooterAggregate = this.#gridService.groupAggregateMap().get(groupKey);
|
|
88
|
+
return {
|
|
89
|
+
$implicit: value,
|
|
90
|
+
aggregate,
|
|
91
|
+
aggregates,
|
|
92
|
+
column,
|
|
93
|
+
columnIndex,
|
|
94
|
+
count: groupFooterAggregate?.count ?? 0,
|
|
95
|
+
depth: groupFooterAggregate?.depth ?? 0,
|
|
96
|
+
groupKey,
|
|
97
|
+
groupValue: groupFooterAggregate?.groupValue,
|
|
98
|
+
rows: groupFooterAggregate?.rows ?? []
|
|
99
|
+
};
|
|
100
|
+
}, /* @ts-ignore */
|
|
101
|
+
...(ngDevMode ? [{ debugName: "templateContext" }] : /* istanbul ignore next */ []));
|
|
102
|
+
this.templateRef = computed(() => {
|
|
103
|
+
if (this.groupKey() != null) {
|
|
104
|
+
return this.column().groupFooterTemplate;
|
|
105
|
+
}
|
|
106
|
+
return this.column().footerTemplate;
|
|
107
|
+
}, /* @ts-ignore */
|
|
108
|
+
...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
|
|
109
|
+
this.column = input.required(/* @ts-ignore */
|
|
110
|
+
...(ngDevMode ? [{ debugName: "column" }] : /* istanbul ignore next */ []));
|
|
111
|
+
this.columnIndex = input.required(/* @ts-ignore */
|
|
112
|
+
...(ngDevMode ? [{ debugName: "columnIndex" }] : /* istanbul ignore next */ []));
|
|
113
|
+
this.groupKey = input(null, /* @ts-ignore */
|
|
114
|
+
...(ngDevMode ? [{ debugName: "groupKey" }] : /* istanbul ignore next */ []));
|
|
115
|
+
}
|
|
116
|
+
#gridService;
|
|
117
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridFooterCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
118
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridFooterCellComponent, isStandalone: true, selector: "mona-grid-footer-cell", inputs: { column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null }, columnIndex: { classPropertyName: "columnIndex", publicName: "columnIndex", isSignal: true, isRequired: true, transformFunction: null }, groupKey: { classPropertyName: "groupKey", publicName: "groupKey", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "flex items-center h-full" }, ngImport: i0, template: `
|
|
119
|
+
@if (templateRef(); as templateRef) {
|
|
120
|
+
<ng-container [ngTemplateOutlet]="templateRef" [ngTemplateOutletContext]="templateContext()"></ng-container>
|
|
121
|
+
} @else if (displayValue() != null) {
|
|
122
|
+
<span class="block truncate font-medium">{{ displayValue() }}</span>
|
|
123
|
+
}
|
|
124
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
125
|
+
}
|
|
126
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridFooterCellComponent, decorators: [{
|
|
127
|
+
type: Component,
|
|
128
|
+
args: [{
|
|
129
|
+
selector: "mona-grid-footer-cell",
|
|
130
|
+
template: `
|
|
131
|
+
@if (templateRef(); as templateRef) {
|
|
132
|
+
<ng-container [ngTemplateOutlet]="templateRef" [ngTemplateOutletContext]="templateContext()"></ng-container>
|
|
133
|
+
} @else if (displayValue() != null) {
|
|
134
|
+
<span class="block truncate font-medium">{{ displayValue() }}</span>
|
|
135
|
+
}
|
|
136
|
+
`,
|
|
137
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
138
|
+
imports: [NgTemplateOutlet],
|
|
139
|
+
host: {
|
|
140
|
+
class: "flex items-center h-full"
|
|
141
|
+
}
|
|
142
|
+
}]
|
|
143
|
+
}], propDecorators: { column: [{ type: i0.Input, args: [{ isSignal: true, alias: "column", required: true }] }], columnIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnIndex", required: true }] }], groupKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupKey", required: false }] }] } });
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* An aggregate footer row. Without a group key it shows the grid-wide aggregates,
|
|
147
|
+
* otherwise the aggregates of that group.
|
|
148
|
+
*/
|
|
149
|
+
class GridFooterRowComponent {
|
|
150
|
+
constructor() {
|
|
151
|
+
this.gridService = inject(GridService);
|
|
152
|
+
this.rowClass = computed(() => gridFooterTableRowThemeVariants({ virtual: this.gridService.virtualScrollOptions().enabled }), /* @ts-ignore */
|
|
153
|
+
...(ngDevMode ? [{ debugName: "rowClass" }] : /* istanbul ignore next */ []));
|
|
154
|
+
this.groupKey = input(null, /* @ts-ignore */
|
|
155
|
+
...(ngDevMode ? [{ debugName: "groupKey" }] : /* istanbul ignore next */ []));
|
|
156
|
+
}
|
|
157
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridFooterRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
158
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridFooterRowComponent, isStandalone: true, selector: "tr[monaGridFooterRow]", inputs: { groupKey: { classPropertyName: "groupKey", publicName: "groupKey", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "row" }, properties: { "class": "rowClass()" } }, ngImport: i0, template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridFooterTableCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [lockedCellHeader]=\"true\"\n [footerColumn]=\"layoutColumn.column\">\n <mona-grid-footer-cell\n [column]=\"layoutColumn.column\"\n [columnIndex]=\"layoutColumn.columnIndex\"\n [groupKey]=\"groupKey()\" />\n </td>\n } @else {\n <td\n monaGridFooterTableCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [lockedCellHeader]=\"true\"\n [footerCellWidth]=\"layoutColumn.width\"></td>\n }\n}\n", dependencies: [{ kind: "component", type: GridFooterCellComponent, selector: "mona-grid-footer-cell", inputs: ["column", "columnIndex", "groupKey"] }, { kind: "directive", type: GridFooterTableCellDirective, selector: "td[monaGridFooterTableCell]", inputs: ["footerCellMinWidth", "footerCellWidth", "footerColumn"] }, { kind: "directive", type: GridLockedCellDirective, selector: "td[monaGridLockedCell], th[monaGridLockedCell]", inputs: ["monaGridLockedCell", "lockedCellHeader"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
159
|
+
}
|
|
160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridFooterRowComponent, decorators: [{
|
|
161
|
+
type: Component,
|
|
162
|
+
args: [{ selector: "tr[monaGridFooterRow]", changeDetection: ChangeDetectionStrategy.OnPush, imports: [GridFooterCellComponent, GridFooterTableCellDirective, GridLockedCellDirective], host: {
|
|
163
|
+
"[class]": "rowClass()",
|
|
164
|
+
role: "row"
|
|
165
|
+
}, template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridFooterTableCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [lockedCellHeader]=\"true\"\n [footerColumn]=\"layoutColumn.column\">\n <mona-grid-footer-cell\n [column]=\"layoutColumn.column\"\n [columnIndex]=\"layoutColumn.columnIndex\"\n [groupKey]=\"groupKey()\" />\n </td>\n } @else {\n <td\n monaGridFooterTableCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [lockedCellHeader]=\"true\"\n [footerCellWidth]=\"layoutColumn.width\"></td>\n }\n}\n" }]
|
|
166
|
+
}], propDecorators: { groupKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupKey", required: false }] }] } });
|
|
167
|
+
|
|
168
|
+
export { GridFooterRowComponent };
|
|
169
|
+
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-footer-row.component-CIMXz60d.mjs.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { CdkDropList, CdkDrag, CdkDragPreview } from '@angular/cdk/drag-drop';
|
|
2
|
+
import { LucideGripVertical } from '@lucide/angular';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { inject, DestroyRef, ElementRef, viewChild, computed, input, afterNextRender, afterRenderEffect, Component } from '@angular/core';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import { ImmutableList } from '@mirei/ts-collections';
|
|
7
|
+
import { fromEvent } from 'rxjs';
|
|
8
|
+
import { G as GridNavigationService, g as gridListBaseThemeVariants, a as GridService, b as gridRowDragPreviewThemeVariants, c as gridListTableThemeVariants, d as GridColgroupComponent } from './nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-IewqeT4m.mjs';
|
|
9
|
+
import { G as GridAddRowComponent, a as GridDetailRowComponent, b as GridGroupRowComponent, c as GridRowComponent } from './nanahoshi-mona-ui-grid-grid-row.component-B_5ay_Nz.mjs';
|
|
10
|
+
import { GridFooterRowComponent } from './nanahoshi-mona-ui-grid-grid-footer-row.component-CIMXz60d.mjs';
|
|
11
|
+
|
|
12
|
+
const ROW_MOVE_DURATION = 200;
|
|
13
|
+
const ROW_MOVE_EASING = "cubic-bezier(0.2, 0, 0, 1)";
|
|
14
|
+
/** Data that arrives later than this after a move request is not animated, since rows may have moved for other reasons. */
|
|
15
|
+
const ROW_MOVE_SNAPSHOT_LIFETIME = 1000;
|
|
16
|
+
class GridListComponent {
|
|
17
|
+
#destroyRef;
|
|
18
|
+
#gridNavigationService;
|
|
19
|
+
#hostElementRef;
|
|
20
|
+
#rowMoveAnimations;
|
|
21
|
+
#dropping;
|
|
22
|
+
#rowPositionsBeforeMove;
|
|
23
|
+
constructor() {
|
|
24
|
+
this.#destroyRef = inject(DestroyRef);
|
|
25
|
+
this.#gridNavigationService = inject(GridNavigationService);
|
|
26
|
+
this.#hostElementRef = inject((ElementRef));
|
|
27
|
+
this.#rowMoveAnimations = new Map();
|
|
28
|
+
this.#dropping = false;
|
|
29
|
+
this.#rowPositionsBeforeMove = null;
|
|
30
|
+
this.bodyTableElementRef = viewChild.required("bodyTable", /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "bodyTableElementRef" }] : /* istanbul ignore next */ []));
|
|
32
|
+
this.baseClass = gridListBaseThemeVariants({ virtual: false });
|
|
33
|
+
this.bodyRows = computed(() => this.gridService.createBodyRows(this.data()), /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "bodyRows" }] : /* istanbul ignore next */ []));
|
|
35
|
+
this.gridService = inject(GridService);
|
|
36
|
+
this.rowDragPreviewClass = gridRowDragPreviewThemeVariants();
|
|
37
|
+
this.tableClass = gridListTableThemeVariants();
|
|
38
|
+
this.data = input(ImmutableList.create(), /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
40
|
+
afterNextRender({
|
|
41
|
+
read: () => {
|
|
42
|
+
const bodyTableElement = this.bodyTableElementRef().nativeElement;
|
|
43
|
+
const bodyScrollElement = this.#hostElementRef.nativeElement;
|
|
44
|
+
this.gridService.bodyTableElement.set(bodyTableElement);
|
|
45
|
+
this.gridService.bodyScrollElement.set(bodyScrollElement);
|
|
46
|
+
this.setSubscriptions();
|
|
47
|
+
this.#destroyRef.onDestroy(() => {
|
|
48
|
+
if (this.gridService.bodyTableElement() === bodyTableElement) {
|
|
49
|
+
this.gridService.bodyTableElement.set(null);
|
|
50
|
+
}
|
|
51
|
+
if (this.gridService.bodyScrollElement() === bodyScrollElement) {
|
|
52
|
+
this.gridService.bodyScrollElement.set(null);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// Rows moved from the keyboard slide from where they were drawn to their new place.
|
|
58
|
+
afterRenderEffect({
|
|
59
|
+
earlyRead: () => {
|
|
60
|
+
this.bodyRows();
|
|
61
|
+
return this.#measureRowMoves();
|
|
62
|
+
},
|
|
63
|
+
write: moves => this.#playRowMoves(moves())
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
onRowDragEnded(_event) {
|
|
67
|
+
this.gridService.draggingRowUid.set(null);
|
|
68
|
+
}
|
|
69
|
+
onRowDragStarted(event) {
|
|
70
|
+
this.gridService.draggingRowUid.set(event.source.data.uid);
|
|
71
|
+
}
|
|
72
|
+
onRowDrop(event) {
|
|
73
|
+
this.gridService.draggingRowUid.set(null);
|
|
74
|
+
// The drag already showed the rows in their new order, so the move must not be animated again.
|
|
75
|
+
this.#dropping = true;
|
|
76
|
+
try {
|
|
77
|
+
this.gridService.requestRowReorder(event.item.data, event.previousIndex, event.currentIndex);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
this.#dropping = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
onBodyFocus() {
|
|
84
|
+
this.#gridNavigationService.focusActiveCellOrFirstHeader();
|
|
85
|
+
}
|
|
86
|
+
#canAnimateRowMoves() {
|
|
87
|
+
const view = this.#hostElementRef.nativeElement.ownerDocument.defaultView;
|
|
88
|
+
if (view == null || typeof this.#hostElementRef.nativeElement.animate !== "function") {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return !view.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
92
|
+
}
|
|
93
|
+
#measureRowMoves() {
|
|
94
|
+
const snapshot = this.#rowPositionsBeforeMove;
|
|
95
|
+
this.#rowPositionsBeforeMove = null;
|
|
96
|
+
if (snapshot == null || performance.now() - snapshot.time > ROW_MOVE_SNAPSHOT_LIFETIME) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
// Rows still sliding from an earlier move are measured where they finally belong.
|
|
100
|
+
for (const animation of this.#rowMoveAnimations.values()) {
|
|
101
|
+
animation.cancel();
|
|
102
|
+
}
|
|
103
|
+
this.#rowMoveAnimations.clear();
|
|
104
|
+
const moves = [];
|
|
105
|
+
for (const [uid, position] of this.#readRowPositions()) {
|
|
106
|
+
const previousTop = snapshot.positions.get(uid);
|
|
107
|
+
if (previousTop != null && Math.abs(previousTop - position.top) >= 0.5) {
|
|
108
|
+
moves.push({ element: position.element, offset: previousTop - position.top });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return moves;
|
|
112
|
+
}
|
|
113
|
+
#playRowMoves(moves) {
|
|
114
|
+
for (const { element, offset } of moves) {
|
|
115
|
+
const animation = element.animate([{ transform: `translateY(${offset}px)` }, { transform: "translateY(0)" }], { duration: ROW_MOVE_DURATION, easing: ROW_MOVE_EASING });
|
|
116
|
+
this.#rowMoveAnimations.set(element, animation);
|
|
117
|
+
animation.addEventListener("finish", () => {
|
|
118
|
+
if (this.#rowMoveAnimations.get(element) === animation) {
|
|
119
|
+
this.#rowMoveAnimations.delete(element);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Reads where each data row is drawn, relative to the top of the body table. */
|
|
125
|
+
#readRowPositions() {
|
|
126
|
+
const table = this.bodyTableElementRef().nativeElement;
|
|
127
|
+
const tableTop = table.getBoundingClientRect().top;
|
|
128
|
+
const positions = new Map();
|
|
129
|
+
for (const element of table.querySelectorAll(":scope > tbody > tr[data-ruid]")) {
|
|
130
|
+
const uid = element.dataset["ruid"];
|
|
131
|
+
if (uid != null) {
|
|
132
|
+
positions.set(uid, { element, top: element.getBoundingClientRect().top - tableTop });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return positions;
|
|
136
|
+
}
|
|
137
|
+
setSubscriptions() {
|
|
138
|
+
fromEvent(this.#hostElementRef.nativeElement, "focus")
|
|
139
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
140
|
+
.subscribe(() => {
|
|
141
|
+
this.#gridNavigationService.focusActiveCellOrFirstHeader();
|
|
142
|
+
});
|
|
143
|
+
this.gridService.rowReorder$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
144
|
+
if (this.#dropping || !this.#canAnimateRowMoves()) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const positions = new Map();
|
|
148
|
+
for (const [uid, position] of this.#readRowPositions()) {
|
|
149
|
+
positions.set(uid, position.top);
|
|
150
|
+
}
|
|
151
|
+
this.#rowPositionsBeforeMove = { positions, time: performance.now() };
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
155
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridListComponent, isStandalone: true, selector: "mona-grid-list", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "baseClass" } }, viewQueries: [{ propertyName: "bodyTableElementRef", first: true, predicate: ["bodyTable"], descendants: true, isSignal: true }], ngImport: i0, template: "<table role=\"presentation\" #bodyTable [class]=\"tableClass\" [style.width.px]=\"gridService.tableWidth()\">\n <colgroup monaGridColgroup></colgroup>\n <tbody\n role=\"rowgroup\"\n tabindex=\"0\"\n (focus)=\"onBodyFocus()\"\n cdkDropList\n [cdkDropListData]=\"data().toArray()\"\n [cdkDropListDisabled]=\"!gridService.rowReorderInteractionEnabled()\"\n (cdkDropListDropped)=\"onRowDrop($event)\">\n @if (gridService.addRowVisible()) {\n <tr monaGridAddRow></tr>\n }\n @for (bodyRow of bodyRows(); track bodyRow.key; let rowIndex = $index) {\n @if (bodyRow.type === \"group\") {\n <tr monaGridGroupRow [group]=\"bodyRow\" [rowIndex]=\"rowIndex\"></tr>\n } @else if (bodyRow.type === \"groupFooter\") {\n <tr monaGridFooterRow [groupKey]=\"bodyRow.groupAggregate.groupKey\"></tr>\n } @else {\n <tr\n monaGridRow\n [row]=\"bodyRow.row\"\n [index]=\"rowIndex\"\n cdkDrag\n cdkDragLockAxis=\"y\"\n [cdkDragData]=\"bodyRow.row\"\n [cdkDragDisabled]=\"!gridService.canReorderRow(bodyRow.row)\"\n (cdkDragStarted)=\"onRowDragStarted($event)\"\n (cdkDragEnded)=\"onRowDragEnded($event)\">\n <ng-template cdkDragPreview>\n <div [class]=\"rowDragPreviewClass\">\n <svg lucideGripVertical [size]=\"16\" aria-hidden=\"true\"></svg>\n <span>{{\n gridService.getRowReorderAriaLabel(\n bodyRow.row,\n rowIndex + gridService.paginationState().skip\n )\n }}</span>\n </div>\n </ng-template>\n </tr>\n @if (gridService.isRowExpanded(bodyRow.row) && !gridService.rowDragInProgress()) {\n <tr monaGridDetailRow [row]=\"bodyRow.row\"></tr>\n }\n }\n }\n </tbody>\n</table>\n", dependencies: [{ kind: "component", type: LucideGripVertical, selector: "svg[lucideGripVertical]" }, { kind: "component", type: GridAddRowComponent, selector: "tr[monaGridAddRow]" }, { kind: "component", type: GridColgroupComponent, selector: "colgroup[monaGridColgroup]" }, { kind: "component", type: GridDetailRowComponent, selector: "tr[monaGridDetailRow]", inputs: ["row"] }, { kind: "component", type: GridFooterRowComponent, selector: "tr[monaGridFooterRow]", inputs: ["groupKey"] }, { kind: "component", type: GridGroupRowComponent, selector: "tr[monaGridGroupRow]", inputs: ["group", "rowIndex"] }, { kind: "component", type: GridRowComponent, selector: "tr[monaGridRow]", inputs: ["index", "row"], exportAs: ["monaGridRow"] }, { kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: CdkDragPreview, selector: "ng-template[cdkDragPreview]", inputs: ["data", "matchSize"] }] }); }
|
|
156
|
+
}
|
|
157
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridListComponent, decorators: [{
|
|
158
|
+
type: Component,
|
|
159
|
+
args: [{ selector: "mona-grid-list", imports: [
|
|
160
|
+
LucideGripVertical,
|
|
161
|
+
GridAddRowComponent,
|
|
162
|
+
GridColgroupComponent,
|
|
163
|
+
GridDetailRowComponent,
|
|
164
|
+
GridFooterRowComponent,
|
|
165
|
+
GridGroupRowComponent,
|
|
166
|
+
GridRowComponent,
|
|
167
|
+
CdkDropList,
|
|
168
|
+
CdkDrag,
|
|
169
|
+
CdkDragPreview
|
|
170
|
+
], host: {
|
|
171
|
+
"[class]": "baseClass"
|
|
172
|
+
}, template: "<table role=\"presentation\" #bodyTable [class]=\"tableClass\" [style.width.px]=\"gridService.tableWidth()\">\n <colgroup monaGridColgroup></colgroup>\n <tbody\n role=\"rowgroup\"\n tabindex=\"0\"\n (focus)=\"onBodyFocus()\"\n cdkDropList\n [cdkDropListData]=\"data().toArray()\"\n [cdkDropListDisabled]=\"!gridService.rowReorderInteractionEnabled()\"\n (cdkDropListDropped)=\"onRowDrop($event)\">\n @if (gridService.addRowVisible()) {\n <tr monaGridAddRow></tr>\n }\n @for (bodyRow of bodyRows(); track bodyRow.key; let rowIndex = $index) {\n @if (bodyRow.type === \"group\") {\n <tr monaGridGroupRow [group]=\"bodyRow\" [rowIndex]=\"rowIndex\"></tr>\n } @else if (bodyRow.type === \"groupFooter\") {\n <tr monaGridFooterRow [groupKey]=\"bodyRow.groupAggregate.groupKey\"></tr>\n } @else {\n <tr\n monaGridRow\n [row]=\"bodyRow.row\"\n [index]=\"rowIndex\"\n cdkDrag\n cdkDragLockAxis=\"y\"\n [cdkDragData]=\"bodyRow.row\"\n [cdkDragDisabled]=\"!gridService.canReorderRow(bodyRow.row)\"\n (cdkDragStarted)=\"onRowDragStarted($event)\"\n (cdkDragEnded)=\"onRowDragEnded($event)\">\n <ng-template cdkDragPreview>\n <div [class]=\"rowDragPreviewClass\">\n <svg lucideGripVertical [size]=\"16\" aria-hidden=\"true\"></svg>\n <span>{{\n gridService.getRowReorderAriaLabel(\n bodyRow.row,\n rowIndex + gridService.paginationState().skip\n )\n }}</span>\n </div>\n </ng-template>\n </tr>\n @if (gridService.isRowExpanded(bodyRow.row) && !gridService.rowDragInProgress()) {\n <tr monaGridDetailRow [row]=\"bodyRow.row\"></tr>\n }\n }\n }\n </tbody>\n</table>\n" }]
|
|
173
|
+
}], ctorParameters: () => [], propDecorators: { bodyTableElementRef: [{ type: i0.ViewChild, args: ["bodyTable", { isSignal: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
|
|
174
|
+
|
|
175
|
+
export { GridListComponent };
|
|
176
|
+
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-list.component-CpeheGXU.mjs.map
|