ng-hub-ui-spreadsheet 22.4.0 → 22.5.0
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/README.md
CHANGED
|
@@ -205,6 +205,27 @@ what keeps `Enter` for the cell:
|
|
|
205
205
|
itself. An editable cell keeps `Enter` for editing, and the clipboard still carries the value rather
|
|
206
206
|
than the drawing.
|
|
207
207
|
|
|
208
|
+
`hubSpreadsheetCellAction` may also be **a function of the row**, for a column where only some cells
|
|
209
|
+
open — a product whose folded row opens its variants while its own row is only read:
|
|
210
|
+
|
|
211
|
+
```html
|
|
212
|
+
<ng-template
|
|
213
|
+
hubSpreadsheetCell="name"
|
|
214
|
+
[hubSpreadsheetCellRows]="products()"
|
|
215
|
+
[hubSpreadsheetCellAction]="opensItsVariants"
|
|
216
|
+
let-row="row"
|
|
217
|
+
let-open="open"
|
|
218
|
+
>
|
|
219
|
+
@if (opensItsVariants(row)) {
|
|
220
|
+
<a (click)="open()">{{ row.name }}</a>
|
|
221
|
+
} @else {
|
|
222
|
+
{{ row.name }}
|
|
223
|
+
}
|
|
224
|
+
</ng-template>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Then `Enter` opens the rows the function answers for, and leaves every other cell the sheet's.
|
|
228
|
+
|
|
208
229
|
For a cell that opens the row's own detail, put the detail in an `expansion` template and let `expandedRow` name the open row:
|
|
209
230
|
|
|
210
231
|
```html
|
|
@@ -523,13 +523,17 @@ class HubSpreadsheetCellDirective {
|
|
|
523
523
|
*/
|
|
524
524
|
rows = input([], { ...(ngDevMode ? { debugName: "rows" } : /* istanbul ignore next */ {}), alias: 'hubSpreadsheetCellRows' });
|
|
525
525
|
/**
|
|
526
|
-
*
|
|
527
|
-
*
|
|
526
|
+
* Whether the cells of this column open onto something rather than being typed into, and the
|
|
527
|
+
* accessible name of the way in.
|
|
528
528
|
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
* a
|
|
532
|
-
*
|
|
529
|
+
* A string means the whole column opens. A function answers per row, for a column where only
|
|
530
|
+
* some cells do — a product whose folded row opens its variants while its own row is typed
|
|
531
|
+
* into, a figure that opens the tiers behind it while the cells beside it are edited.
|
|
532
|
+
*
|
|
533
|
+
* Either way the sheet keeps `Enter` for a cell that opens instead of opening an editor the
|
|
534
|
+
* cell has not got, and reports the press through `opened`; the template draws the way in
|
|
535
|
+
* itself — a link, a button — and calls `open()` from its context. Left out, the cell is only
|
|
536
|
+
* read or typed into, and `Enter` does what the sheet would have done on its own.
|
|
533
537
|
*/
|
|
534
538
|
action = input('', { ...(ngDevMode ? { debugName: "action" } : /* istanbul ignore next */ {}), alias: 'hubSpreadsheetCellAction' });
|
|
535
539
|
template = inject(TemplateRef);
|
|
@@ -3539,14 +3543,16 @@ class HubSpreadsheetComponent {
|
|
|
3539
3543
|
this.expandedRow.set(null);
|
|
3540
3544
|
}
|
|
3541
3545
|
/**
|
|
3542
|
-
* Whether
|
|
3546
|
+
* Whether a cell opens onto something rather than being typed into.
|
|
3543
3547
|
*
|
|
3544
|
-
* A cell template says so with
|
|
3545
|
-
* sheet draws nothing itself, but it has to know,
|
|
3546
|
-
* cell instead of opening an editor the cell has not
|
|
3548
|
+
* A cell template says so — with a name for the whole column, or a function that answers per
|
|
3549
|
+
* row — and only the template does: the sheet draws nothing itself, but it has to know,
|
|
3550
|
+
* because it is what keeps `Enter` for the cell instead of opening an editor the cell has not
|
|
3551
|
+
* got.
|
|
3547
3552
|
*/
|
|
3548
|
-
cellOpens(col) {
|
|
3549
|
-
|
|
3553
|
+
cellOpens(row, col) {
|
|
3554
|
+
const action = this.cellTemplateFor(col)?.action();
|
|
3555
|
+
return typeof action === 'function' ? action(this.rows()[row]) : !!action;
|
|
3550
3556
|
}
|
|
3551
3557
|
/** Reports that the reader asked to open what a cell points at. */
|
|
3552
3558
|
openCell(row, col) {
|
|
@@ -3667,7 +3673,7 @@ class HubSpreadsheetComponent {
|
|
|
3667
3673
|
// A cell that opens onto something, with no field to write in, answers Enter with
|
|
3668
3674
|
// that rather than with an editor it does not have. Typing a character is left
|
|
3669
3675
|
// alone: such a cell holds no value to write over.
|
|
3670
|
-
if (!intent.seed && !this.canEdit(active.row, active.col) && this.cellOpens(active.col)) {
|
|
3676
|
+
if (!intent.seed && !this.canEdit(active.row, active.col) && this.cellOpens(active.row, active.col)) {
|
|
3671
3677
|
this.openCell(active.row, active.col);
|
|
3672
3678
|
break;
|
|
3673
3679
|
}
|