@coolon/angular-ui-powerups 16.1.0-alpha.328 → 16.1.0-alpha.330
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/esm2022/lib/components/tables/abstract-table-model.mjs +5 -5
- package/esm2022/lib/components/tables/filter/cell-search.mjs +1 -1
- package/esm2022/lib/components/tables/filter/search-criteria.decorator.mjs +5 -4
- package/esm2022/lib/components/tables/filter/server-search-model.mjs +7 -8
- package/esm2022/lib/components/tables/renderer/table-body/table-body.component.mjs +62 -4
- package/esm2022/lib/components/tables/table/table.component.mjs +40 -5
- package/esm2022/lib/components/tables/tree-table/tree-table-component.mjs +1 -1
- package/fesm2022/coolon-angular-ui-powerups.mjs +114 -21
- package/fesm2022/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/components/tables/abstract-table-model.d.ts +4 -4
- package/lib/components/tables/filter/cell-search.d.ts +11 -9
- package/lib/components/tables/filter/search-criteria.decorator.d.ts +4 -3
- package/lib/components/tables/filter/server-search-model.d.ts +6 -7
- package/lib/components/tables/renderer/table-body/table-body.component.d.ts +20 -1
- package/lib/components/tables/table/table.component.d.ts +17 -1
- package/package.json +1 -1
|
@@ -88,11 +88,11 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
|
|
|
88
88
|
* search class's `dependsOn` change.
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
91
|
-
* const
|
|
92
|
-
* searchCriteriaClass:
|
|
93
|
-
* withSearchCriteria: (
|
|
91
|
+
* const query$ = this.table.useCriteria(base$, {
|
|
92
|
+
* searchCriteriaClass: HeroSearchCriteria,
|
|
93
|
+
* withSearchCriteria: (query, searchCriteria) => query.with({searchCriteria}),
|
|
94
94
|
* });
|
|
95
|
-
* this.
|
|
95
|
+
* chain(query$).subscribe(query => this.send(query));
|
|
96
96
|
*/
|
|
97
97
|
useCriteria<Criteria, S>(base$: ValueModel<Criteria>, placement: SearchCriteriaPlacement<Criteria, S>): ValueModelChain<Criteria>;
|
|
98
98
|
private initialiseSearchCriteria;
|
|
@@ -2,8 +2,9 @@ import type { Constructable, HasValue } from "@coolon/pectin";
|
|
|
2
2
|
import type { TableSearch } from "./table-search";
|
|
3
3
|
/**
|
|
4
4
|
* What a search means for one column, written into search criteria: the part of a server request's
|
|
5
|
-
* criteria that carries the search, shared by every resource that lists the same kind of thing
|
|
6
|
-
* example `
|
|
5
|
+
* criteria that carries the search, shared by every resource that lists the same kind of thing. For
|
|
6
|
+
* example, `HeroSearchCriteria` is what a search asks of any list of heroes, and a page's `HeroQuery`
|
|
7
|
+
* holds it as `searchCriteria`.
|
|
7
8
|
*
|
|
8
9
|
* A cell renderer names its search classes with {@link SearchCriteria}. The table resolves them through
|
|
9
10
|
* the injector, so a search class may inject what it needs to match against, such as the manager that
|
|
@@ -14,12 +15,13 @@ import type { TableSearch } from "./table-search";
|
|
|
14
15
|
* nothing matches.
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
18
|
+
* // The server stores a power's code, not its label, so the search is turned into codes here.
|
|
17
19
|
* @Injectable({providedIn: 'root'})
|
|
18
|
-
* export class
|
|
19
|
-
* readonly searchCriteriaClass =
|
|
20
|
-
* criteriaFor(searchCriteria:
|
|
21
|
-
* const
|
|
22
|
-
* return
|
|
20
|
+
* export class PowerSearch implements CellSearch<HeroSearchCriteria> {
|
|
21
|
+
* readonly searchCriteriaClass = HeroSearchCriteria;
|
|
22
|
+
* criteriaFor(searchCriteria: HeroSearchCriteria, search: TableSearch): HeroSearchCriteria {
|
|
23
|
+
* const powers = Power.ALL.filter(power => search.regex.test(Power.label(power)));
|
|
24
|
+
* return powers.length ? searchCriteria.with({powers}) : searchCriteria;
|
|
23
25
|
* }
|
|
24
26
|
* }
|
|
25
27
|
*/
|
|
@@ -40,8 +42,8 @@ export declare namespace CellSearch {
|
|
|
40
42
|
*
|
|
41
43
|
* @example
|
|
42
44
|
* table.useCriteria(base$, {
|
|
43
|
-
* searchCriteriaClass:
|
|
44
|
-
* withSearchCriteria: (
|
|
45
|
+
* searchCriteriaClass: HeroSearchCriteria,
|
|
46
|
+
* withSearchCriteria: (query, searchCriteria) => query.with({searchCriteria}),
|
|
45
47
|
* });
|
|
46
48
|
*/
|
|
47
49
|
export interface SearchCriteriaPlacement<Criteria, S> {
|
|
@@ -10,9 +10,10 @@ import type { CellSearch } from "./cell-search";
|
|
|
10
10
|
* its own metadata key, so a renderer may carry both.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
*
|
|
13
|
+
* // Shown in tables of heroes and of villains, so it names a search class for each one's search criteria.
|
|
14
|
+
* @SearchCriteria(HeroPowerSearch, VillainPowerSearch)
|
|
15
|
+
* @Component({selector: 'app-power-cell', ...})
|
|
16
|
+
* export class PowerCellComponent { ... }
|
|
16
17
|
*/
|
|
17
18
|
export declare function SearchCriteria(...searchClasses: CellSearch.Class[]): ClassDecorator;
|
|
18
19
|
export declare namespace SearchCriteria {
|
|
@@ -4,18 +4,17 @@ import type { TextSearchPredicate } from "./text-search-predicate";
|
|
|
4
4
|
/**
|
|
5
5
|
* The search model of a table whose rows the server finds, such as one that loads them a step at a
|
|
6
6
|
* time. The rows a table holds are what the server found for the search and the filters, so it shows
|
|
7
|
-
* them all. Its settled search
|
|
8
|
-
*
|
|
9
|
-
* the cells highlight the search text as usual.
|
|
7
|
+
* them all. Its settled search ({@link search$}) becomes the server request's criteria through
|
|
8
|
+
* `AbstractTableModel.useCriteria`, and the cells highlight the search text as usual.
|
|
10
9
|
*
|
|
11
10
|
* It has no row predicate, so a page's filters cannot filter the rows held: they reach the server as
|
|
12
11
|
* criteria, as the search does.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
|
-
* this.search = new ServerSearchModel<
|
|
16
|
-
* const
|
|
17
|
-
* searchCriteriaClass:
|
|
18
|
-
* withSearchCriteria: (
|
|
14
|
+
* this.search = new ServerSearchModel<Hero>({disposedWith: this, searchText$: this.searchText$});
|
|
15
|
+
* const query$ = this.table.useCriteria(base$, {
|
|
16
|
+
* searchCriteriaClass: HeroSearchCriteria,
|
|
17
|
+
* withSearchCriteria: (query, searchCriteria) => query.with({searchCriteria}),
|
|
19
18
|
* });
|
|
20
19
|
*
|
|
21
20
|
* <aup-table [tableModel]="table" [filterModel]="search"></aup-table>
|
|
@@ -29,7 +29,10 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
|
|
|
29
29
|
trackBy: (index: number, item: Row) => any;
|
|
30
30
|
accessor scrollMode$: ValueModel<TableBodyComponent.ScrollMode>;
|
|
31
31
|
accessor scrollMode: TableBodyComponent.ScrollMode;
|
|
32
|
+
/** Keeps the rows in view where they are when rows change above them: see `TableComponent.holdScrollPosition`. */
|
|
33
|
+
holdScrollPosition: boolean;
|
|
32
34
|
scrollViewport: CdkVirtualScrollViewport;
|
|
35
|
+
private classicScrollContainer?;
|
|
33
36
|
columns$: ListModelChain<ColumnModel<Row>>;
|
|
34
37
|
columnIds$: ListModelChain<string>;
|
|
35
38
|
footerRowDefs$: ValueModel<ResolvedFooterRow[]>;
|
|
@@ -82,6 +85,17 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
|
|
|
82
85
|
protected takeHeightsFromTheme(): void;
|
|
83
86
|
/** A length custom property as resolved on an element, in px; undefined when unset or not a length. */
|
|
84
87
|
private readCssPixels;
|
|
88
|
+
/**
|
|
89
|
+
* Where each row in view sits, by its id, when [holdScrollPosition] applies and the table is scrolled down;
|
|
90
|
+
* otherwise undefined. A row behind the sticky header is not in view.
|
|
91
|
+
*/
|
|
92
|
+
private rowsInViewToHold;
|
|
93
|
+
/**
|
|
94
|
+
* Renders the new rows now, then scrolls by however far the first of [rowsInView] still in the table has
|
|
95
|
+
* moved, so it is drawn where it was. Both happen before the browser paints, so the reader never sees the
|
|
96
|
+
* rows move.
|
|
97
|
+
*/
|
|
98
|
+
private holdInView;
|
|
85
99
|
private scheduleTableHeightCheck;
|
|
86
100
|
private notifyScrolled;
|
|
87
101
|
private notifyScrollEnded;
|
|
@@ -89,8 +103,13 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
|
|
|
89
103
|
private resetAnimationsAfterFrame;
|
|
90
104
|
private clearScrollTimeout;
|
|
91
105
|
static ɵfac: i0.ɵɵFactoryDeclaration<TableBodyComponent<any>, [{ optional: true; }]>;
|
|
92
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<TableBodyComponent<any>, "aup-table-body", never, { "data$": { "alias": "data$"; "required": false; }; "tableModel": { "alias": "tableModel"; "required": false; }; "footerRows": { "alias": "footerRows"; "required": false; }; "showHeader$": { "alias": "showHeader$"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "scrollMode$": { "alias": "scrollMode$"; "required": false; }; "scrollMode": { "alias": "scrollMode"; "required": false; }; }, {}, never, never, false, never>;
|
|
106
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TableBodyComponent<any>, "aup-table-body", never, { "data$": { "alias": "data$"; "required": false; }; "tableModel": { "alias": "tableModel"; "required": false; }; "footerRows": { "alias": "footerRows"; "required": false; }; "showHeader$": { "alias": "showHeader$"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "scrollMode$": { "alias": "scrollMode$"; "required": false; }; "scrollMode": { "alias": "scrollMode"; "required": false; }; "holdScrollPosition": { "alias": "holdScrollPosition"; "required": false; }; }, {}, never, never, false, never>;
|
|
93
107
|
}
|
|
94
108
|
export declare namespace TableBodyComponent {
|
|
95
109
|
type ScrollMode = "none" | "classic" | "virtual";
|
|
110
|
+
/** A row in view, by the id it is drawn with, and the top of its box in the viewport. */
|
|
111
|
+
interface RowInView {
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly top: number;
|
|
114
|
+
}
|
|
96
115
|
}
|
|
@@ -85,11 +85,27 @@ export declare class TableComponent<Row extends object> extends AbstractTableCom
|
|
|
85
85
|
*/
|
|
86
86
|
accessor scrollMode$: ValueModel<TableComponent.ScrollMode>;
|
|
87
87
|
accessor scrollMode: TableComponent.ScrollMode;
|
|
88
|
+
/**
|
|
89
|
+
* Set to true to keep the rows in view where they are when rows are inserted, removed or resized above
|
|
90
|
+
* them, so a reader scrolled down the table is not moved. At the top of the table nothing is held, so a
|
|
91
|
+
* row inserted there comes into view. Applies with `scrollMode="classic"` only, and only to rows with an
|
|
92
|
+
* identity of their own (a list `identifiedBy` an id), because a row is found again by its id. In
|
|
93
|
+
* development, a table set to hold without either warns in the console.
|
|
94
|
+
*
|
|
95
|
+
* The element that scrolls the rows, in either scroll mode, carries the attribute `aup-scroll-container`,
|
|
96
|
+
* and each row its id as `aup-row-id`, so a test can scroll the table and find a row where it is drawn.
|
|
97
|
+
*/
|
|
98
|
+
holdScrollPosition: boolean;
|
|
88
99
|
private _footerContentAdded;
|
|
89
100
|
private readonly _filteredRows$;
|
|
90
101
|
protected readonly tableBodyScrollMode$: ValueModel<TableBodyComponent.ScrollMode>;
|
|
91
102
|
constructor(injector: Injector);
|
|
92
103
|
ngOnInit(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Warns of a table set to hold its scroll position where it cannot. Nothing fails otherwise: the
|
|
106
|
+
* table moves the rows the reader is on, or holds the wrong one.
|
|
107
|
+
*/
|
|
108
|
+
private warnWhereHoldingCannotWork;
|
|
93
109
|
protected getModel(): AbstractTableModel<Row>;
|
|
94
110
|
/**
|
|
95
111
|
* True while the filters leave no row and the host gave content for the empty slot. A host that
|
|
@@ -99,7 +115,7 @@ export declare class TableComponent<Row extends object> extends AbstractTableCom
|
|
|
99
115
|
protected get showsEmptyContent(): boolean;
|
|
100
116
|
footerContentChanged($event: unknown): void;
|
|
101
117
|
static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent<any>, never>;
|
|
102
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent<any>, "aup-table", never, { "tableModel": { "alias": "tableModel"; "required": false; }; "filterModel": { "alias": "filterModel"; "required": false; }; "scrollMode$": { "alias": "scrollMode$"; "required": false; }; "scrollMode": { "alias": "scrollMode"; "required": false; }; }, {}, never, ["[empty], [slot=empty]", "[footer], [slot=footer]"], false, never>;
|
|
118
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent<any>, "aup-table", never, { "tableModel": { "alias": "tableModel"; "required": false; }; "filterModel": { "alias": "filterModel"; "required": false; }; "scrollMode$": { "alias": "scrollMode$"; "required": false; }; "scrollMode": { "alias": "scrollMode"; "required": false; }; "holdScrollPosition": { "alias": "holdScrollPosition"; "required": false; }; }, {}, never, ["[empty], [slot=empty]", "[footer], [slot=footer]"], false, never>;
|
|
103
119
|
}
|
|
104
120
|
export declare namespace TableComponent {
|
|
105
121
|
type ScrollMode = Omit<TableBodyComponent.ScrollMode, 'none'>;
|