@coolon/angular-ui-powerups 16.1.0-alpha.277 → 16.1.0-alpha.278

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.
@@ -41,6 +41,8 @@ export * from "./forms/password-input/password-input.component";
41
41
  export * from "./forms/search-input/search-input.component";
42
42
  export * from "./forms/select-input/select-input.component";
43
43
  export * from "./forms/string-input/string-input.component";
44
+ export * from "./forms/sub-form-list/sub-form-list-column";
45
+ export * from "./forms/sub-form-list/sub-form-list-columns";
44
46
  export * from "./forms/sub-form-list/sub-form-list.component";
45
47
  export * from "./forms/sub-form-list/sub-form-row.directive";
46
48
  export * from "./forms/text-input/text-input.component";
@@ -0,0 +1,63 @@
1
+ import type { ColumnTextProperties } from "../../tables/column/column-text-properties";
2
+ /**
3
+ * One column of an `aup-sub-form-list` — the same `columnId` + {@link ColumnTextProperties} idiom a
4
+ * table column carries, minus everything a table column carries *because* it renders its own cell.
5
+ *
6
+ * A sub-form-list cell is whatever element the row template put in this position, so this declares
7
+ * only what the list itself can know: the column's identity, the grid track it occupies, and the
8
+ * text that titles it. There is no cell renderer, no visibility chain and no text-search formatter,
9
+ * because none of them have anything to act on here.
10
+ *
11
+ * Built by {@link SubFormListColumns#addColumn} rather than directly.
12
+ */
13
+ export declare class SubFormListColumn {
14
+ readonly columnId: string;
15
+ private readonly textPropertiesProvider;
16
+ private _columnTextProperties;
17
+ private _track;
18
+ constructor(columnId: string, textPropertiesProvider: SubFormListColumn.TextPropertiesProvider);
19
+ /**
20
+ * Titles this column on its own, winning over the bulk map passed to
21
+ * {@link SubFormListColumns#columnTextProperties} — the same precedence `ColumnModel` gives it.
22
+ */
23
+ columnTextProperties(columnTextProperties: ColumnTextProperties): this;
24
+ /** Memoised as `ColumnModel`'s is, so the bulk map is looked up once rather than per pass. */
25
+ getColumnTextProperties(): ColumnTextProperties | undefined;
26
+ /**
27
+ * Deliberately *not* memoised, unlike `ColumnModel#getHeaderText`: a table renders its header once
28
+ * into a portal, whereas this is a template expression re-evaluated every pass, so caching the
29
+ * string would pin the locale for the life of the list.
30
+ *
31
+ * Also guards `headerText` itself. It is optional on {@link ColumnTextProperties}, and
32
+ * `ColumnModel#getHeaderText` throws on a properties object that omits it.
33
+ */
34
+ getHeaderText(): string;
35
+ /**
36
+ * Empty, where `ColumnModel`'s is the column id.
37
+ *
38
+ * A table always draws a header band, so falling back to the id there is a harmless "you forgot
39
+ * the yml" tell. This band is optional, and an id fallback would conjure a header reading
40
+ * `priority color description` out of a `[columns]` binding the consumer supplied only to size
41
+ * the tracks. {@link SubFormListColumns#hasDeclaredHeader} decides whether a band is drawn at
42
+ * all, so an untitled column inside a titled list still renders its (empty) cell.
43
+ */
44
+ protected getDefaultHeaderText(): string;
45
+ /**
46
+ * Gives this column the leftover width — a `1fr` track. Named for `ColumnModel#flex`, and means
47
+ * the same thing.
48
+ */
49
+ flex(flex?: boolean): this;
50
+ /**
51
+ * Any `grid-template-columns` track value — `var(--indicator-width)`, `minmax(0, 20ch)`, `120px`.
52
+ *
53
+ * Not part of {@link ColumnTextProperties} deliberately: a track width is not translatable, so it
54
+ * has no business in a locale bundle. It is declared here, beside the title it belongs to, which
55
+ * is the point — a column cannot gain a header without gaining a track.
56
+ */
57
+ width(track: string): this;
58
+ getTrack(): string;
59
+ }
60
+ export declare namespace SubFormListColumn {
61
+ /** Resolves the bulk map entry for this column, if the list was given one. */
62
+ type TextPropertiesProvider = () => ColumnTextProperties | undefined;
63
+ }
@@ -0,0 +1,70 @@
1
+ import type { ColumnTextProperties } from "../../tables/column/column-text-properties";
2
+ import { SubFormListColumn } from "./sub-form-list-column";
3
+ /**
4
+ * The columns of an `aup-sub-form-list` under `rowLayout="subgrid"`: their order, their grid tracks,
5
+ * and — through {@link columnTextProperties} — their titles.
6
+ *
7
+ * It exists because a subgrid column was otherwise declared in three places that nothing tied
8
+ * together: a cell in the `aupSubFormListHeader` template, a track in the consumer's
9
+ * `--aup-sub-form-list-columns`, and a cell position in the row template. Cells are auto-placed in
10
+ * source order, so the three drift silently — adding a cell without a track walks every later cell
11
+ * one column left, and nothing complains.
12
+ *
13
+ * The builder is the one `TableModel` takes, and the last line of it is the same line, against a
14
+ * `columns(ColumnTextProperties[])` i18n block of the same shape:
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * readonly levelColumns = new SubFormListColumns(c => {
19
+ * c.addColumn('priority');
20
+ * c.addColumn('color').width('var(--indicator-width)');
21
+ * c.addColumn('description').flex();
22
+ * c.addColumn('edit'); // untitled: a heading over a button names a
23
+ * // control, not a column
24
+ * c.columnTextProperties(this.i18n.columns); // titles every column, from one yml block
25
+ * });
26
+ * ```
27
+ *
28
+ * Not a `GarbageCollector`, unlike `AbstractTableModel`: this holds no pectin models and subscribes
29
+ * to nothing, so it carries no disposal obligation. It also does not own the rows — a
30
+ * sub-form-list's data is the `SubFormList` bound to `[list]`.
31
+ */
32
+ export declare class SubFormListColumns {
33
+ private readonly _columns;
34
+ private bulkTextProperties;
35
+ constructor(builder?: (columns: SubFormListColumns) => void);
36
+ /**
37
+ * Declares a column. Declaration order is column order, matching the order the row template's
38
+ * top-level cells are written in.
39
+ *
40
+ * The analogue of `AbstractTableModel#addTemplateColumn`: the cell is the caller's, so this names
41
+ * the column it lands in and nothing more.
42
+ */
43
+ addColumn(columnId: string): SubFormListColumn;
44
+ /**
45
+ * Titles every declared column from one map keyed by column id — identical in shape and effect to
46
+ * `AbstractTableModel#columnTextProperties`, so a generated `columns(ColumnTextProperties[])`
47
+ * block passes straight through.
48
+ *
49
+ * A column with no entry stays untitled; a per-column {@link SubFormListColumn#columnTextProperties}
50
+ * wins over this.
51
+ */
52
+ columnTextProperties(columnTextProperties: {
53
+ [columnId: string]: ColumnTextProperties;
54
+ }): this;
55
+ getColumnTextProperties(columnId: string): ColumnTextProperties | undefined;
56
+ get columns(): readonly SubFormListColumn[];
57
+ /**
58
+ * The content track list for `--aup-sub-form-list-columns`, in declaration order. Undefined while
59
+ * no column is declared, so the component knows to leave the variable alone entirely.
60
+ */
61
+ get tracks(): string | undefined;
62
+ /**
63
+ * Whether any column resolved text properties — what decides if a header band is drawn at all.
64
+ *
65
+ * Keyed on the properties resolving rather than on the text being non-empty, so a table's
66
+ * `headerText: ''` blank-column convention still counts as "this list has a header", while a
67
+ * declaration made purely to size the tracks draws nothing.
68
+ */
69
+ get hasDeclaredHeader(): boolean;
70
+ }
@@ -1,8 +1,10 @@
1
1
  import { CdkDragDrop } from '@angular/cdk/drag-drop';
2
- import { AfterContentInit, QueryList } from '@angular/core';
2
+ import { AfterContentInit, AfterViewChecked, QueryList } from '@angular/core';
3
3
  import { Command, CommandFace, SubFormList, ValueModel } from '@coolon/pectin';
4
4
  import { Enum } from 'typescript-string-enums';
5
5
  import { DisposableComponent } from '../../disposable-component';
6
+ import { SubFormListColumn } from './sub-form-list-column';
7
+ import { SubFormListColumns } from './sub-form-list-columns';
6
8
  import { SubFormListEmptyDirective, SubFormListFooterDirective, SubFormListHeaderDirective, SubFormRowActionsDirective, SubFormRowContext, SubFormRowDirective } from './sub-form-row.directive';
7
9
  import * as i0 from "@angular/core";
8
10
  /**
@@ -28,7 +30,7 @@ import * as i0 from "@angular/core";
28
30
  * previous list, which is not a scenario a form has — the list is built in the component's
29
31
  * constructor and lives as long as the form does.
30
32
  */
31
- export declare class SubFormListComponent<T extends object = any, B extends SubFormList.Fields = SubFormList.Fields> extends DisposableComponent implements AfterContentInit {
33
+ export declare class SubFormListComponent<T extends object = any, B extends SubFormList.Fields = SubFormList.Fields> extends DisposableComponent implements AfterContentInit, AfterViewChecked {
32
34
  list: SubFormList<T, B>;
33
35
  /**
34
36
  * Which reordering affordances to offer. `AUTO` — the default — resolves to {@link Reorder.BOTH}
@@ -77,6 +79,37 @@ export declare class SubFormListComponent<T extends object = any, B extends SubF
77
79
  * context memoisation exists to keep stable.
78
80
  */
79
81
  rowLayout: SubFormListComponent.RowLayout;
82
+ /**
83
+ * Declares the list's columns — their order, their grid tracks, and their titles — as an
84
+ * alternative to naming them in an `aupSubFormListHeader` template and sizing them in a
85
+ * stylesheet. See {@link SubFormListColumns} for why the two-places-plus-an-implicit-third
86
+ * arrangement is worth replacing.
87
+ *
88
+ * `rowLayout="subgrid"` only, for the same reason the header template is: every other layout lays
89
+ * a row out within itself, so there are no shared columns to declare.
90
+ *
91
+ * Opt-in, and the older template slot outranks it: supplying both leaves the rendered header
92
+ * exactly as it was and warns, so adding this input to a list that already has a header template
93
+ * can never silently rewrite it. The declared *tracks* still apply in that case — declaring
94
+ * columns purely to size them is a legitimate reason to bind both.
95
+ *
96
+ * Bind a stable object, built once in the consumer's constructor or as a field initialiser.
97
+ */
98
+ columns: SubFormListColumns;
99
+ /**
100
+ * Whether the list wears the library's table chrome: a bordered, rounded box around the rows with
101
+ * each row ruled off from the next rather than floated apart, and — under `subgrid`, the only
102
+ * layout with a header — a shaded band over the column titles.
103
+ *
104
+ * {@link Appearance.PLAIN} is the default and leaves the list exactly as it has always looked.
105
+ *
106
+ * It exists because the alternative was every consumer reaching through `::ng-deep` for `.rows`,
107
+ * `.row + .row` and `.header-row` — and losing a specificity fight with the library's own
108
+ * `.rows.layout-subgrid` row-gap on the way. Retune it with the `--aup-sub-form-list-border`,
109
+ * `-radius`, `-cell-padding`, `-header-background` and `-header-color` variables rather than by
110
+ * overriding the rules.
111
+ */
112
+ appearance: SubFormListComponent.Appearance;
80
113
  rowTemplate: SubFormRowDirective;
81
114
  actionsTemplate: SubFormRowActionsDirective;
82
115
  emptyTemplate: SubFormListEmptyDirective;
@@ -84,9 +117,14 @@ export declare class SubFormListComponent<T extends object = any, B extends SubF
84
117
  headerTemplate: SubFormListHeaderDirective;
85
118
  /** One row per template, in template order — see the directive for why it repeats. */
86
119
  footerTemplates: QueryList<SubFormListFooterDirective>;
120
+ /** The rows' content wrappers, whose element children are the caller's cells — see {@link verifyRowCellCount}. */
121
+ private rowContents;
122
+ private readonly elementRef;
87
123
  /** The array `rows` was last built from — see the comment there. */
88
124
  private renderedSource;
89
125
  private renderedRows;
126
+ /** The shape {@link verifyRowCellCount} last ran against, so it costs one compare per pass. */
127
+ private cellCountCheckedFor;
90
128
  constructor();
91
129
  /**
92
130
  * The row contexts, rebuilt only when the list's shape changes.
@@ -136,8 +174,14 @@ export declare class SubFormListComponent<T extends object = any, B extends SubF
136
174
  /**
137
175
  * Only under `subgrid`. Every other layout lays a row out within itself, so there are no shared
138
176
  * tracks for a header to sit above and its cells would line up with nothing.
177
+ *
178
+ * Either source will draw the band: an `aupSubFormListHeader` template, or a {@link columns}
179
+ * declaration in which at least one column resolved text properties. A declaration made only to
180
+ * size the tracks draws nothing — see {@link SubFormListColumns#hasDeclaredHeader}.
139
181
  */
140
182
  get headerVisible(): boolean;
183
+ /** The declared columns, or empty when none were bound. Empty is the "nothing changes" path. */
184
+ get headerColumns(): readonly SubFormListColumn[];
141
185
  /** Whether anything trails the content — drives the content cell's trailing spacing. */
142
186
  get hasActions(): boolean;
143
187
  /**
@@ -145,7 +189,31 @@ export declare class SubFormListComponent<T extends object = any, B extends SubF
145
189
  * `ngAfterContentInit`, so {@link actionsTemplate} is still undefined during `ngOnInit`.
146
190
  */
147
191
  ngAfterContentInit(): void;
192
+ ngAfterViewChecked(): void;
148
193
  trackByRow(index: number, context: SubFormRowContext): unknown;
194
+ /**
195
+ * Writes the declared tracks to the *private* half of the pair the stylesheet reads, so a
196
+ * consumer's own `--aup-sub-form-list-columns` still wins — the escape hatch survives, and a
197
+ * stylesheet that has not been migrated keeps working. Same two-tier idiom the row already uses
198
+ * for `--aup-sub-form-row-areas`.
199
+ *
200
+ * Set imperatively rather than through a host binding: it is a bind-once value, and one
201
+ * `setProperty` on init is cheaper and more predictable than a getter evaluated every pass.
202
+ */
203
+ private applyColumnTracks;
204
+ /**
205
+ * Warns when the row template's cell count disagrees with the declared column count.
206
+ *
207
+ * The subgrid layout already requires one top-level element per track — cells are auto-placed, so
208
+ * a missing one silently walks every later cell a column left. This asserts that invariant rather
209
+ * than adding one; declaring the columns is simply the first time the component knows what the
210
+ * count should be.
211
+ *
212
+ * Two things it cannot see, both pre-existing hazards of auto-placement rather than new ones: a
213
+ * *reordering* (the count still matches), and a top-level cell behind an `*ngIf` (absent when the
214
+ * condition is false, which reads here as a miscount). Hence a warning rather than an assert.
215
+ */
216
+ private verifyRowCellCount;
149
217
  /**
150
218
  * CDK reports `currentIndex` after the dragged row has been taken out of the list, which is the
151
219
  * same convention {@link SubFormList#move} splices with — so the index passes straight through,
@@ -169,9 +237,16 @@ export declare class SubFormListComponent<T extends object = any, B extends SubF
169
237
  */
170
238
  private warnAboutIgnoredSubgridInputs;
171
239
  private warnAboutIgnoredHeader;
240
+ /**
241
+ * The template slot wins over `[columns]` deliberately: it is the older contract, so a list that
242
+ * has both is a migration half-done, and leaving the rendered header untouched is the debuggable
243
+ * outcome. Only the *titles* are dropped — the declared tracks still apply, since sizing the
244
+ * columns while a template names them is a legitimate pairing.
245
+ */
246
+ private warnAboutIgnoredColumns;
172
247
  private warnAboutUnsupportedReordering;
173
248
  static ɵfac: i0.ɵɵFactoryDeclaration<SubFormListComponent<any, any>, never>;
174
- static ɵcmp: i0.ɵɵComponentDeclaration<SubFormListComponent<any, any>, "aup-sub-form-list", never, { "list": { "alias": "list"; "required": false; }; "reorder": { "alias": "reorder"; "required": false; }; "removable$": { "alias": "removable$"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "removeFace": { "alias": "removeFace"; "required": false; }; "moveUpFace": { "alias": "moveUpFace"; "required": false; }; "moveDownFace": { "alias": "moveDownFace"; "required": false; }; "dragHandleIcon": { "alias": "dragHandleIcon"; "required": false; }; "addCommand": { "alias": "addCommand"; "required": false; }; "emptyText": { "alias": "emptyText"; "required": false; }; "dense": { "alias": "dense"; "required": false; }; "fill": { "alias": "fill"; "required": false; }; "rowLayout": { "alias": "rowLayout"; "required": false; }; }, {}, ["rowTemplate", "actionsTemplate", "emptyTemplate", "headerTemplate", "footerTemplates"], never, false, never>;
249
+ static ɵcmp: i0.ɵɵComponentDeclaration<SubFormListComponent<any, any>, "aup-sub-form-list", never, { "list": { "alias": "list"; "required": false; }; "reorder": { "alias": "reorder"; "required": false; }; "removable$": { "alias": "removable$"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "removeFace": { "alias": "removeFace"; "required": false; }; "moveUpFace": { "alias": "moveUpFace"; "required": false; }; "moveDownFace": { "alias": "moveDownFace"; "required": false; }; "dragHandleIcon": { "alias": "dragHandleIcon"; "required": false; }; "addCommand": { "alias": "addCommand"; "required": false; }; "emptyText": { "alias": "emptyText"; "required": false; }; "dense": { "alias": "dense"; "required": false; }; "fill": { "alias": "fill"; "required": false; }; "rowLayout": { "alias": "rowLayout"; "required": false; }; "columns": { "alias": "columns"; "required": false; }; "appearance": { "alias": "appearance"; "required": false; }; }, {}, ["rowTemplate", "actionsTemplate", "emptyTemplate", "headerTemplate", "footerTemplates"], never, false, never>;
175
250
  }
176
251
  export declare namespace SubFormListComponent {
177
252
  const Reorder: {
@@ -184,6 +259,24 @@ export declare namespace SubFormListComponent {
184
259
  BOTH: "both";
185
260
  };
186
261
  type Reorder = Enum<typeof Reorder>;
262
+ const Appearance: {
263
+ /** No chrome of the library's own — rows float apart on the row gap. The default. */
264
+ PLAIN: "plain";
265
+ /**
266
+ * One bordered, rounded box holding every row, rows ruled off from one another rather than
267
+ * separated, and the header band shaded and ruled so it reads as a table head rather than as a
268
+ * first row.
269
+ *
270
+ * Reach for it when the rows are read *against each other* — ranked, compared, or titled by
271
+ * columns — which is also when a titled column means anything: a heading only holds if the box
272
+ * it heads holds every row.
273
+ *
274
+ * The header band needs {@link RowLayout.SUBGRID}, since that is the only layout with a header
275
+ * at all; the box and the rules apply in any layout.
276
+ */
277
+ TABLE: "table";
278
+ };
279
+ type Appearance = Enum<typeof Appearance>;
187
280
  const RowLayout: {
188
281
  /** One line: `handle · content · up · down · actions`. The default. */
189
282
  INLINE: "inline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.277",
3
+ "version": "16.1.0-alpha.278",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",