@coolon/angular-ui-powerups 16.1.0-alpha.333 → 16.1.0-alpha.335

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.
@@ -57,6 +57,7 @@ export * from "./section-header/section-header.component";
57
57
  export * from "./switch-case/switch-case.component";
58
58
  export * from "./tables/abstract-table-model";
59
59
  export * from "./tables/end-of-rows/end-of-rows";
60
+ export * from "./tables/top-of-rows/top-of-rows";
60
61
  export * from "./tables/abstract-table.component";
61
62
  export * from "./tables/column/column-manager";
62
63
  export * from "./tables/column/column-model";
@@ -9,6 +9,7 @@ import { CustomTemplateColumnModel } from './column/custom-template-column-model
9
9
  import { CustomValueColumnModel } from './column/custom-value-column-model';
10
10
  import { ListPropertyColumnModel } from './column/list-propery-column-model';
11
11
  import { EndOfRows } from './end-of-rows/end-of-rows';
12
+ import { TopOfRows } from './top-of-rows/top-of-rows';
12
13
  import { PropertyColumnModel } from './column/property-column-model';
13
14
  import { SelectionColumnModel } from './column/selection-column-model';
14
15
  import type { SearchCriteriaPlacement } from './filter/cell-search';
@@ -50,6 +51,8 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
50
51
  readonly hasSelection$: BooleanValueModelChain;
51
52
  /** The measurements a page asked for with {@link watchEndOfRows}, if it did. */
52
53
  private endOfRowsAskedFor;
54
+ /** What a page asked for with {@link watchTopOfRows}, if it did. */
55
+ private topOfRowsAskedFor;
53
56
  /** The loading row a page asked for with {@link showLoadingRowWhile}, if it did. */
54
57
  private loadingRowAskedFor;
55
58
  readonly footerRowModels: FooterRowModel.Impl[];
@@ -177,6 +180,21 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
177
180
  watchEndOfRows(): EndOfRows;
178
181
  /** The measurements {@link watchEndOfRows} started, if a page asked for them. Read by the table body. */
179
182
  get _endOfRows(): EndOfRows | undefined;
183
+ /**
184
+ * Starts telling the page whether the reader is at the top of the rows, and returns what it is told. A page that
185
+ * finds it has missed rows can then load them again at once while the reader is at the top, where loading again
186
+ * moves nothing, and offer to further down. A table that is not asked watches nothing. A table's rows have one top,
187
+ * so asking again returns the same.
188
+ *
189
+ * Only a table that scrolls classically, with enableScrolling and scrollMode="classic", tells. In any other the
190
+ * reader never counts as at the top.
191
+ *
192
+ * The table reads it as it initialises, in its ngOnInit, so ask where the model is built, not from a directive on
193
+ * the aup-table, which initialises after the table does.
194
+ */
195
+ watchTopOfRows(): TopOfRows;
196
+ /** What {@link watchTopOfRows} started, if a page asked for it. Read by the table body. */
197
+ get _topOfRows(): TopOfRows | undefined;
180
198
  pluck<P extends Types.ValuePropertiesOf<Row>>(property: P, options?: {
181
199
  columnId: string;
182
200
  }): PropertyColumnModel<Row, P>;
@@ -33,6 +33,13 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
33
33
  holdScrollPosition: boolean;
34
34
  scrollViewport: CdkVirtualScrollViewport;
35
35
  private classicScrollContainer?;
36
+ /**
37
+ * The container that contains the rows unless the table scrolls virtually. It comes and goes as the scroll mode
38
+ * changes, and the top of the rows is watched in whichever is drawn.
39
+ */
40
+ private set classicScrollContainerRef(value);
41
+ /** Stops listening to the last container's scrolling, for `AbstractTableModel.watchTopOfRows`. */
42
+ private topOfRowsListening?;
36
43
  /**
37
44
  * Measures whether the end of the rows is in view and how many rows fit, when the page asked for it with
38
45
  * `AbstractTableModel.watchEndOfRows`.
@@ -126,6 +133,14 @@ export declare class TableBodyComponent<Row extends object> extends ResizeAwareC
126
133
  * the loading row (`AbstractTableModel.showLoadingRowWhile`), or both, which work together.
127
134
  */
128
135
  private setUpEndOfRowsAndLoadingRow;
136
+ /**
137
+ * Tells the page whether the reader is at the top of the rows, when it asked with `AbstractTableModel.watchTopOfRows`:
138
+ * each time the reader scrolls [container], and once it is drawn. Scroll events come many to a second, so they are
139
+ * heard outside Angular's zone. A change is reported inside it, so a page that reacts is checked.
140
+ */
141
+ private watchTopOfRowsIn;
142
+ /** Reports whether the reader is at the top of the rows: see `TopOfRows.inView$`. */
143
+ private reportTopOfRows;
129
144
  /** Scrolls back to the first row, in whichever scroll mode the table is in. */
130
145
  private scrollToTop;
131
146
  private resetAnimationsAfterFrame;
@@ -0,0 +1,26 @@
1
+ import { ValueModel } from '@coolon/pectin';
2
+ /**
3
+ * Whether the reader is at the top of a table's rows, which a page asks for with `AbstractTableModel.watchTopOfRows`.
4
+ * At the top, nothing is scrolled out of view, so a page can load its rows again without moving the reader. Further
5
+ * down, it can only offer to, since loading again returns the reader to the top. The table body reports it here.
6
+ *
7
+ * Only a classic-scrolling table reports it. In any other table the reader never counts as at the top, because a page
8
+ * that cannot tell must not load the rows again under a reader who may be reading them.
9
+ *
10
+ * @example
11
+ * const topOfRows = table.watchTopOfRows();
12
+ * // Rows the page missed are loaded again at once when the reader is at the top, and offered further down.
13
+ * when(chain(missed$).map(missed => missed > 0 && topOfRows.inView$.value, {dependsOn: topOfRows.inView$}))
14
+ * .becomesTruthy(() => reload());
15
+ */
16
+ export declare class TopOfRows {
17
+ private readonly _inView$;
18
+ /**
19
+ * Whether the table is scrolled all the way up, so no row is above the visible part. It follows the reader as they
20
+ * scroll, and is false until the table has drawn. This is the rule `TableComponent.holdScrollPosition` uses too: at
21
+ * the top the table holds nothing, and rows that join above the first push the others down.
22
+ */
23
+ readonly inView$: ValueModel<boolean>;
24
+ /** Called by the table body with what it has measured. */
25
+ _report(inView: boolean): void;
26
+ }
@@ -10,7 +10,8 @@ import * as i0 from "@angular/core";
10
10
  * does: the chosen option tinted and checked, an optional icon before each label and an optional count after it.
11
11
  * Choosing one finishes the activity with it, or with undefined for the nil option. Started over another activity it
12
12
  * slides in over it, under a title whose Back leaves it. In a popup of its own it has no title and is as wide as its
13
- * options, as a select's panel is, and Esc or a click outside closes it. As in a select's panel,
13
+ * options, as a select's panel is, and Esc or a click outside closes it. Its options are at most as tall as a select's
14
+ * panel, and scroll under the search box. As in a select's panel,
14
15
  * focus stays on the list while the arrow keys, Home, End and typing a label's start move between the options, and
15
16
  * Enter or Space chooses one.
16
17
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.333",
3
+ "version": "16.1.0-alpha.335",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",