@coolon/angular-ui-powerups 16.1.0-alpha.329 → 16.1.0-alpha.331

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.
@@ -40,6 +40,15 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
40
40
  readonly selectableRows$: ListModel<Row>;
41
41
  readonly leadSelection$: ValueModel<Row>;
42
42
  readonly hasSelection$: BooleanValueModelChain;
43
+ private readonly _endInView$;
44
+ /**
45
+ * Whether the end of a classic-scrolling table's rows is in view: the reader has scrolled to within a
46
+ * few rows of the last, or the rows do not fill the table. A page that loads its rows a step at a time
47
+ * loads the next step while it is true. Once the rows fill the table and the reader is above their
48
+ * end, it turns false; while they still do not, it stays true, so the page loads again when its step
49
+ * lands. A table that does not scroll, or scrolls virtually, leaves it false.
50
+ */
51
+ readonly endInView$: ValueModel<boolean>;
43
52
  readonly footerRowModels: FooterRowModel.Impl[];
44
53
  private readonly _viewDependencies;
45
54
  /** The table's settled search, once a table with a filter model binds (`useSearch`). */
@@ -88,11 +97,11 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
88
97
  * search class's `dependsOn` change.
89
98
  *
90
99
  * @example
91
- * const criteria$ = this.table.useCriteria(base$, {
92
- * searchCriteriaClass: AlarmSearchCriteriaDto,
93
- * withSearchCriteria: (criteria, searchCriteria) => criteria.copy({searchCriteria}),
100
+ * const query$ = this.table.useCriteria(base$, {
101
+ * searchCriteriaClass: HeroSearchCriteria,
102
+ * withSearchCriteria: (query, searchCriteria) => query.with({searchCriteria}),
94
103
  * });
95
- * this.history.useCriteria(criteria$);
104
+ * chain(query$).subscribe(query => this.send(query));
96
105
  */
97
106
  useCriteria<Criteria, S>(base$: ValueModel<Criteria>, placement: SearchCriteriaPlacement<Criteria, S>): ValueModelChain<Criteria>;
98
107
  private initialiseSearchCriteria;
@@ -175,5 +184,7 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
175
184
  isCursorEnabledForRow(column: ColumnModel<Row>, row: Row): boolean;
176
185
  selectRow(row: Row): void;
177
186
  onRowClicked(callback: (row: Row) => void): Disposable;
187
+ /** Called by the table body as the end of its rows comes into view or leaves it. */
188
+ _notifyEndInView(inView: boolean): void;
178
189
  _notifyCellClicked(columnModel: ColumnModel<Row>, row: Row): void;
179
190
  }
@@ -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 (for
6
- * example `AlarmSearchCriteriaDto`, which the Alarm history page's criteria hold as `searchCriteria`).
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 AlarmTypeSearch implements CellSearch<AlarmSearchCriteriaDto> {
19
- * readonly searchCriteriaClass = AlarmSearchCriteriaDto;
20
- * criteriaFor(searchCriteria: AlarmSearchCriteriaDto, search: TableSearch): AlarmSearchCriteriaDto {
21
- * const types = AlarmType.values().filter(type => search.regex.test(type.label));
22
- * return types.length ? searchCriteria.copy(c => c.types = types) : searchCriteria;
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: AlarmSearchCriteriaDto,
44
- * withSearchCriteria: (criteria, searchCriteria) => criteria.copy({searchCriteria}),
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
- * @SearchCriteria(AlarmSourceSearch, DeviceNameSearch)
14
- * @Component({selector: 'frontend-alarm-source-cell-renderer', ...})
15
- * export class AlarmSourceCellRendererComponent { ... }
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
- * ({@link search$}) becomes the server request's criteria through `AbstractTableModel.useCriteria`, and
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<DecoratedAlarm>({disposedWith: this, searchText$: this.searchText$});
16
- * const criteria$ = this.table.useCriteria(base$, {
17
- * searchCriteriaClass: AlarmSearchCriteriaDto,
18
- * withSearchCriteria: (criteria, searchCriteria) => criteria.copy({searchCriteria}),
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>
@@ -33,6 +33,11 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
33
33
  holdScrollPosition: boolean;
34
34
  scrollViewport: CdkVirtualScrollViewport;
35
35
  private classicScrollContainer?;
36
+ /** The marker after the last row, watched so the table model knows when the end of the rows is in view. */
37
+ private set endOfRows(value);
38
+ private endOfRowsMarker?;
39
+ private endOfRowsObserver?;
40
+ private readonly zone;
36
41
  columns$: ListModelChain<ColumnModel<Row>>;
37
42
  columnIds$: ListModelChain<string>;
38
43
  footerRowDefs$: ValueModel<ResolvedFooterRow[]>;
@@ -100,6 +105,12 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
100
105
  private notifyScrolled;
101
106
  private notifyScrollEnded;
102
107
  ngOnDestroy(): void;
108
+ /**
109
+ * Watches the marker after the last row while the table scrolls classically, and tells the table model
110
+ * whether it is in view (`AbstractTableModel.endInView$`). The marker counts as in view from a few rows
111
+ * below the visible bottom, so a page that loads more has the rows ready by the time they are reached.
112
+ */
113
+ private watchEndOfRows;
103
114
  private resetAnimationsAfterFrame;
104
115
  private clearScrollTimeout;
105
116
  static ɵfac: i0.ɵɵFactoryDeclaration<TableBodyComponent<any>, [{ optional: true; }]>;
@@ -107,6 +118,8 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
107
118
  }
108
119
  export declare namespace TableBodyComponent {
109
120
  type ScrollMode = "none" | "classic" | "virtual";
121
+ /** How far below the visible bottom the end of the rows counts as in view: about four rows. */
122
+ const END_OF_ROWS_MARGIN_PIXELS = 200;
110
123
  /** A row in view, by the id it is drawn with, and the top of its box in the viewport. */
111
124
  interface RowInView {
112
125
  readonly id: string;
@@ -89,7 +89,11 @@ export declare class TableComponent<Row extends object> extends AbstractTableCom
89
89
  * Set to true to keep the rows in view where they are when rows are inserted, removed or resized above
90
90
  * them, so a reader scrolled down the table is not moved. At the top of the table nothing is held, so a
91
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.
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.
93
97
  */
94
98
  holdScrollPosition: boolean;
95
99
  private _footerContentAdded;
@@ -97,6 +101,11 @@ export declare class TableComponent<Row extends object> extends AbstractTableCom
97
101
  protected readonly tableBodyScrollMode$: ValueModel<TableBodyComponent.ScrollMode>;
98
102
  constructor(injector: Injector);
99
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;
100
109
  protected getModel(): AbstractTableModel<Row>;
101
110
  /**
102
111
  * True while the filters leave no row and the host gave content for the empty slot. A host that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.329",
3
+ "version": "16.1.0-alpha.331",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",