@nanahoshi/mona-ui 0.24.6 → 0.24.8

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.
Files changed (78) hide show
  1. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  2. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +14 -4
  3. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  4. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1 -1
  5. package/fesm2022/nanahoshi-mona-ui-filter.mjs +233 -231
  6. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-CD_ODHpU.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DdyHnUIr.mjs} +24 -12
  7. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-B6gq7Hu3.mjs +208 -0
  8. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DdUY3I7P.mjs +1100 -0
  9. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-Sa1aAtJ-.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-DG8Bu4Dy.mjs} +34 -21
  10. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BvUM9nPt.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CVqpbMcb.mjs} +2565 -928
  11. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  12. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +79 -11
  13. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +20 -4
  14. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +335 -45
  15. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +565 -197
  16. package/fesm2022/nanahoshi-mona-ui-internal.mjs +28 -2
  17. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +598 -208
  18. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +193 -74
  19. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +58 -11
  20. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +62 -11
  21. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +62 -11
  22. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +69 -11
  23. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +58 -11
  24. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +62 -11
  25. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +58 -11
  26. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +58 -11
  27. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +62 -11
  28. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +78 -11
  29. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +58 -11
  30. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +58 -11
  31. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +58 -11
  32. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1 -1
  33. package/fesm2022/nanahoshi-mona-ui-pager.mjs +367 -463
  34. package/fesm2022/nanahoshi-mona-ui-query.mjs +317 -122
  35. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +205 -140
  36. package/i18n/catalogs/en-US.messages.json +64 -17
  37. package/locales/ar-sa/ar-sa.messages.json +58 -11
  38. package/locales/de-de/de-de.messages.json +58 -11
  39. package/locales/es-es/es-es.messages.json +58 -11
  40. package/locales/fr-fr/fr-fr.messages.json +58 -11
  41. package/locales/id-id/id-id.messages.json +58 -11
  42. package/locales/it-it/it-it.messages.json +58 -11
  43. package/locales/ja-jp/ja-jp.messages.json +58 -11
  44. package/locales/ko-kr/ko-kr.messages.json +58 -11
  45. package/locales/pt-br/pt-br.messages.json +58 -11
  46. package/locales/ru-ru/ru-ru.messages.json +58 -11
  47. package/locales/tr-tr/tr-tr.messages.json +58 -11
  48. package/locales/zh-cn/zh-cn.messages.json +58 -11
  49. package/locales/zh-tw/zh-tw.messages.json +58 -11
  50. package/package.json +1 -1
  51. package/types/nanahoshi-mona-ui-check-box.d.ts +11 -1
  52. package/types/nanahoshi-mona-ui-filter.d.ts +54 -32
  53. package/types/nanahoshi-mona-ui-grid.d.ts +359 -110
  54. package/types/nanahoshi-mona-ui-i18n.d.ts +97 -6
  55. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +14 -2
  56. package/types/nanahoshi-mona-ui-internal-list.d.ts +89 -10
  57. package/types/nanahoshi-mona-ui-internal-tree.d.ts +155 -40
  58. package/types/nanahoshi-mona-ui-internal.d.ts +10 -2
  59. package/types/nanahoshi-mona-ui-list-box.d.ts +148 -47
  60. package/types/nanahoshi-mona-ui-list-view.d.ts +111 -21
  61. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +53 -6
  62. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +53 -6
  63. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +53 -6
  64. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +53 -6
  65. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +53 -6
  66. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +53 -6
  67. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +53 -6
  68. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +53 -6
  69. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +53 -6
  70. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +53 -6
  71. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +53 -6
  72. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +53 -6
  73. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +53 -6
  74. package/types/nanahoshi-mona-ui-pager.d.ts +159 -76
  75. package/types/nanahoshi-mona-ui-query.d.ts +45 -14
  76. package/types/nanahoshi-mona-ui-tree-view.d.ts +84 -40
  77. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-0jN7I1jo.mjs +0 -176
  78. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BI_iE7pl.mjs +0 -946
@@ -0,0 +1,1100 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, computed, input, Directive, ElementRef, Component, signal, viewChild, output, effect, isDevMode, untracked, afterNextRender, model, Injector, LOCALE_ID } from '@angular/core';
3
+ import { G as GridService, j as gridListTableCellThemeVariants, e as GridNavigationService, k as GridLogicalCellDirective, l as gridCellEditorBaseThemeVariants, m as gridCellEditorInputThemeVariants, n as GRID_CELL_FOCUSABLE_SELECTOR, o as gridListTableRowThemeVariants, a as GridLockedCellDirective, p as gridGroupRowThemeVariants, q as gridCellBaseThemeVariants, r as gridCellContainerThemeVariants, s as gridCellDirtyIndicatorThemeVariants, t as gridCellTextThemeVariants, u as gridRowReorderHandleThemeVariants, v as gridSelectionCellThemeVariants } from './nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CVqpbMcb.mjs';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { NgTemplateOutlet, formatDate } from '@angular/common';
6
+ import { LucideCheck, LucideOctagonAlert, LucideX, LucidePencil, LucideTrash2, LucideMinus, LucideChevronDown, LucidePlus, LucideChevronRight, LucideDynamicIcon, LucideGripVertical } from '@lucide/angular';
7
+ import { ButtonDirective } from '@nanahoshi/mona-ui/button';
8
+ import { DialogService } from '@nanahoshi/mona-ui/dialog';
9
+ import { TooltipComponent } from '@nanahoshi/mona-ui/tooltip';
10
+ import { take } from 'rxjs';
11
+ import { v4 } from 'uuid';
12
+ import { FormField } from '@angular/forms/signals';
13
+ import { CheckBoxComponent } from '@nanahoshi/mona-ui/check-box';
14
+ import { DatePickerComponent } from '@nanahoshi/mona-ui/date-picker';
15
+ import { MonaI18nService, parseLocalizedNumber } from '@nanahoshi/mona-ui/i18n';
16
+ import { NumericTextBoxComponent } from '@nanahoshi/mona-ui/numeric-text-box';
17
+ import { TextBoxComponent } from '@nanahoshi/mona-ui/text-box';
18
+ import { LiveAnnouncer } from '@angular/cdk/a11y';
19
+ import { CdkDragHandle } from '@angular/cdk/drag-drop';
20
+
21
+ class GridCellDirective {
22
+ constructor() {
23
+ this.#gridService = inject(GridService, { optional: true });
24
+ this.baseClass = computed(() => gridListTableCellThemeVariants({
25
+ virtual: this.#gridService?.virtualScrollOptions().enabled ?? false,
26
+ groupIndent: this.groupIndent(),
27
+ lastInRow: this.lastInRow() || this.groupHeader()
28
+ }), /* @ts-ignore */
29
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
30
+ /** Marks a group header title cell. It spans to the end of the row, so it draws no end border. */
31
+ this.groupHeader = input(false, /* @ts-ignore */
32
+ ...(ngDevMode ? [{ debugName: "groupHeader" }] : /* istanbul ignore next */ []));
33
+ /** Marks an indent cell under a group, which uses the muted group background. */
34
+ this.groupIndent = input(false, /* @ts-ignore */
35
+ ...(ngDevMode ? [{ debugName: "groupIndent" }] : /* istanbul ignore next */ []));
36
+ this.lastInRow = input(false, /* @ts-ignore */
37
+ ...(ngDevMode ? [{ debugName: "lastInRow" }] : /* istanbul ignore next */ []));
38
+ }
39
+ #gridService;
40
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
41
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: GridCellDirective, isStandalone: true, selector: "td[monaGridCell]", inputs: { groupHeader: { classPropertyName: "groupHeader", publicName: "groupHeader", isSignal: true, isRequired: false, transformFunction: null }, groupIndent: { classPropertyName: "groupIndent", publicName: "groupIndent", isSignal: true, isRequired: false, transformFunction: null }, lastInRow: { classPropertyName: "lastInRow", publicName: "lastInRow", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "gridcell" }, properties: { "class": "baseClass()" } }, ngImport: i0 }); }
42
+ }
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridCellDirective, decorators: [{
44
+ type: Directive,
45
+ args: [{
46
+ selector: "td[monaGridCell]",
47
+ host: {
48
+ "[class]": "baseClass()",
49
+ role: "gridcell"
50
+ }
51
+ }]
52
+ }], propDecorators: { groupHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupHeader", required: false }] }], groupIndent: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupIndent", required: false }] }], lastInRow: [{ type: i0.Input, args: [{ isSignal: true, alias: "lastInRow", required: false }] }] } });
53
+
54
+ /** The delete dialog's confirming action, told apart by this id rather than by its (translated) text. */
55
+ const DELETE_ACTION = "delete";
56
+ class GridCommandCellComponent {
57
+ constructor() {
58
+ this.#dialogService = inject(DialogService);
59
+ this.#elementRef = inject((ElementRef));
60
+ this.#gridNavigationService = inject(GridNavigationService);
61
+ this.canEditRows = computed(() => {
62
+ const editableOptions = this.gridService.editableOptions();
63
+ return editableOptions.enabled === true && editableOptions.mode === "row";
64
+ }, /* @ts-ignore */
65
+ ...(ngDevMode ? [{ debugName: "canEditRows" }] : /* istanbul ignore next */ []));
66
+ this.commandContext = computed(() => ({
67
+ $implicit: this.row()?.data ?? this.gridService.addRowData(),
68
+ cancel: (event) => this.cancel(event),
69
+ edit: (event) => this.edit(event),
70
+ isEditing: this.isEditing(),
71
+ isNew: this.newRow(),
72
+ remove: (event) => this.remove(event),
73
+ row: this.row(),
74
+ rowData: this.row()?.data ?? this.gridService.addRowData(),
75
+ save: (event) => this.save(event)
76
+ }), /* @ts-ignore */
77
+ ...(ngDevMode ? [{ debugName: "commandContext" }] : /* istanbul ignore next */ []));
78
+ this.gridService = inject(GridService);
79
+ this.hasRowError = computed(() => this.rowErrorMessages().length > 0, /* @ts-ignore */
80
+ ...(ngDevMode ? [{ debugName: "hasRowError" }] : /* istanbul ignore next */ []));
81
+ this.isEditing = computed(() => {
82
+ const row = this.row();
83
+ const context = this.gridService.editContext();
84
+ return this.newRow() || (row != null && context?.mode === "row" && context.rowUid === row.uid);
85
+ }, /* @ts-ignore */
86
+ ...(ngDevMode ? [{ debugName: "isEditing" }] : /* istanbul ignore next */ []));
87
+ /** Button names that say which row they act on. */
88
+ this.labels = computed(() => {
89
+ const row = this.newRow() ? null : this.row();
90
+ return {
91
+ cancel: this.gridService.getRowCommandAriaLabel("cancel", row),
92
+ edit: row == null ? "" : this.gridService.getRowCommandAriaLabel("edit", row),
93
+ remove: row == null ? "" : this.gridService.getRowCommandAriaLabel("remove", row),
94
+ save: this.gridService.getRowCommandAriaLabel("save", row)
95
+ };
96
+ }, /* @ts-ignore */
97
+ ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
98
+ this.messages = computed(() => this.gridService.messages(), /* @ts-ignore */
99
+ ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
100
+ this.rowErrorId = `mona-grid-row-error-${v4()}`;
101
+ this.rowErrorMessages = computed(() => {
102
+ if (!this.isEditing()) {
103
+ return [];
104
+ }
105
+ const session = this.gridService.editSession();
106
+ if (session == null) {
107
+ return [];
108
+ }
109
+ return session
110
+ .form()
111
+ .errorSummary()
112
+ .map(error => error.message)
113
+ .filter((message) => !!message);
114
+ }, /* @ts-ignore */
115
+ ...(ngDevMode ? [{ debugName: "rowErrorMessages" }] : /* istanbul ignore next */ []));
116
+ this.rowErrorTooltip = computed(() => this.rowErrorMessages().join("\n") || this.messages().rowValidationError, /* @ts-ignore */
117
+ ...(ngDevMode ? [{ debugName: "rowErrorTooltip" }] : /* istanbul ignore next */ []));
118
+ this.column = input.required(/* @ts-ignore */
119
+ ...(ngDevMode ? [{ debugName: "column" }] : /* istanbul ignore next */ []));
120
+ this.newRow = input(false, /* @ts-ignore */
121
+ ...(ngDevMode ? [{ debugName: "newRow" }] : /* istanbul ignore next */ []));
122
+ this.row = input(null, /* @ts-ignore */
123
+ ...(ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []));
124
+ }
125
+ #dialogService;
126
+ #elementRef;
127
+ #gridNavigationService;
128
+ cancel(event) {
129
+ event?.stopPropagation();
130
+ const canceled = this.newRow() ? this.gridService.cancelAddRow(event) : this.gridService.cancelEdit(event);
131
+ if (canceled) {
132
+ this.#afterRowCommand();
133
+ }
134
+ }
135
+ edit(event) {
136
+ event?.stopPropagation();
137
+ if (!this.canEditRows()) {
138
+ return;
139
+ }
140
+ const row = this.row();
141
+ if (row != null) {
142
+ this.gridService.startRowEdit(row, event);
143
+ }
144
+ }
145
+ remove(event) {
146
+ event?.stopPropagation();
147
+ const row = this.row();
148
+ if (row == null) {
149
+ return;
150
+ }
151
+ if (!this.column().removeConfirmation) {
152
+ this.#removeRow(row, event);
153
+ return;
154
+ }
155
+ const dialogRef = this.#dialogService.show({
156
+ actions: [
157
+ { data: DELETE_ACTION, look: "error", text: this.messages().delete },
158
+ { look: "default", text: this.messages().cancel }
159
+ ],
160
+ closeOnEscape: true,
161
+ text: this.messages().deleteRowConfirmation(this.gridService.getRowNumber(row)),
162
+ title: this.messages().deleteRowTitle,
163
+ type: "warning",
164
+ modal: true,
165
+ width: 360
166
+ });
167
+ dialogRef.result.pipe(take(1)).subscribe(result => {
168
+ if (!result.viaClose && result.action.data === DELETE_ACTION) {
169
+ this.#removeRow(row, event);
170
+ }
171
+ dialogRef.close();
172
+ });
173
+ }
174
+ save(event) {
175
+ event?.stopPropagation();
176
+ const saved = this.newRow() ? this.gridService.saveAddRow(event) : this.gridService.commitRowEdit(event);
177
+ if (saved) {
178
+ this.#afterRowCommand();
179
+ }
180
+ }
181
+ /**
182
+ * The Save and Cancel buttons go away with the editor: focus their cell, or once the add row is gone, the
183
+ * nearest cell.
184
+ */
185
+ #afterRowCommand() {
186
+ this.#focusCell();
187
+ if (this.newRow()) {
188
+ this.#gridNavigationService.refocusAfterRender();
189
+ }
190
+ }
191
+ #focusCell() {
192
+ this.#elementRef.nativeElement.closest("td")?.focus();
193
+ }
194
+ /** The row may leave the grid: focus its cell first, so focus moves on to the nearest row's. */
195
+ #removeRow(row, event) {
196
+ this.#focusCell();
197
+ if (this.gridService.removeRow(row, event)) {
198
+ this.#gridNavigationService.refocusAfterRender();
199
+ }
200
+ }
201
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridCommandCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
202
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridCommandCellComponent, isStandalone: true, selector: "mona-grid-command-cell", inputs: { column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null }, newRow: { classPropertyName: "newRow", publicName: "newRow", isSignal: true, isRequired: false, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "flex items-center w-full min-h-9" }, ngImport: i0, template: "@if (column().commandTemplate) {\n <ng-container\n [ngTemplateOutlet]=\"column().commandTemplate\"\n [ngTemplateOutletContext]=\"commandContext()\"></ng-container>\n} @else {\n <div class=\"flex min-h-9 items-center gap-1 px-1\">\n @if (isEditing()) {\n @if (hasRowError()) {\n <span class=\"shrink-0 px-1 text-error\" aria-hidden=\"true\" #rowErrorIcon>\n <svg lucideOctagonAlert [size]=\"14\"></svg>\n </span>\n <mona-tooltip [target]=\"rowErrorIcon\">\n <span class=\"p-1 whitespace-pre-line\">{{ rowErrorTooltip() }}</span>\n </mona-tooltip>\n <span class=\"sr-only\" [id]=\"rowErrorId\">{{ rowErrorTooltip() }}</span>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().save\"\n [attr.aria-describedby]=\"hasRowError() ? rowErrorId : null\"\n [attr.title]=\"messages().save\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"save($event)\">\n <svg lucideCheck [size]=\"14\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().cancel\"\n [attr.title]=\"messages().cancel\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"cancel($event)\">\n <svg lucideX [size]=\"14\"></svg>\n </button>\n } @else {\n @if (canEditRows()) {\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().edit\"\n [attr.title]=\"messages().edit\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"edit($event)\">\n <svg lucidePencil [size]=\"14\"></svg>\n </button>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().remove\"\n [attr.title]=\"messages().remove\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"remove($event)\">\n <svg lucideTrash2 [size]=\"14\"></svg>\n </button>\n }\n </div>\n}\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: LucideCheck, selector: "svg[lucideCheck]" }, { kind: "component", type: LucideOctagonAlert, selector: "svg[lucideOctagonAlert], svg[lucideAlertOctagon]" }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }, { kind: "component", type: LucidePencil, selector: "svg[lucidePencil]" }, { kind: "component", type: LucideTrash2, selector: "svg[lucideTrash2]" }, { kind: "component", type: TooltipComponent, selector: "mona-tooltip", inputs: ["disabled", "hideDelay", "position", "rounded", "showDelay", "target"], outputs: ["hidden", "shown"] }] }); }
203
+ }
204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridCommandCellComponent, decorators: [{
205
+ type: Component,
206
+ args: [{ selector: "mona-grid-command-cell", imports: [
207
+ ButtonDirective,
208
+ NgTemplateOutlet,
209
+ LucideCheck,
210
+ LucideOctagonAlert,
211
+ LucideX,
212
+ LucidePencil,
213
+ LucideTrash2,
214
+ TooltipComponent
215
+ ], host: {
216
+ class: "flex items-center w-full min-h-9"
217
+ }, template: "@if (column().commandTemplate) {\n <ng-container\n [ngTemplateOutlet]=\"column().commandTemplate\"\n [ngTemplateOutletContext]=\"commandContext()\"></ng-container>\n} @else {\n <div class=\"flex min-h-9 items-center gap-1 px-1\">\n @if (isEditing()) {\n @if (hasRowError()) {\n <span class=\"shrink-0 px-1 text-error\" aria-hidden=\"true\" #rowErrorIcon>\n <svg lucideOctagonAlert [size]=\"14\"></svg>\n </span>\n <mona-tooltip [target]=\"rowErrorIcon\">\n <span class=\"p-1 whitespace-pre-line\">{{ rowErrorTooltip() }}</span>\n </mona-tooltip>\n <span class=\"sr-only\" [id]=\"rowErrorId\">{{ rowErrorTooltip() }}</span>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().save\"\n [attr.aria-describedby]=\"hasRowError() ? rowErrorId : null\"\n [attr.title]=\"messages().save\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"save($event)\">\n <svg lucideCheck [size]=\"14\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().cancel\"\n [attr.title]=\"messages().cancel\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"cancel($event)\">\n <svg lucideX [size]=\"14\"></svg>\n </button>\n } @else {\n @if (canEditRows()) {\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().edit\"\n [attr.title]=\"messages().edit\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"edit($event)\">\n <svg lucidePencil [size]=\"14\"></svg>\n </button>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"labels().remove\"\n [attr.title]=\"messages().remove\"\n class=\"w-6 h-6\"\n [tabindex]=\"-1\"\n (click)=\"remove($event)\">\n <svg lucideTrash2 [size]=\"14\"></svg>\n </button>\n }\n </div>\n}\n" }]
218
+ }], propDecorators: { column: [{ type: i0.Input, args: [{ isSignal: true, alias: "column", required: true }] }], newRow: [{ type: i0.Input, args: [{ isSignal: true, alias: "newRow", required: false }] }], row: [{ type: i0.Input, args: [{ isSignal: true, alias: "row", required: false }] }] } });
219
+
220
+ /** The controls Tab moves between in an edited row: each editor's first control and the row's command buttons. */
221
+ const ROW_EDITOR_SELECTOR = "mona-grid-editor, mona-grid-command-cell";
222
+ /** A number written the way JavaScript writes it, such as data from a server: `1234.5`, `-2e3`. */
223
+ const MACHINE_NUMBER_PATTERN = /^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;
224
+ class GridEditorComponent {
225
+ #datePopupOpen;
226
+ #elementRef;
227
+ #gridService;
228
+ #i18n;
229
+ #logicalCell;
230
+ /** Tab and Enter work on the whole row: in row edit mode and in the add row. */
231
+ #rowEditing;
232
+ #ignoreNextBooleanFocusOut;
233
+ /** The date before the last change, whose time of day a picked day keeps. */
234
+ #lastDateValue;
235
+ constructor() {
236
+ this.#datePopupOpen = signal(false, /* @ts-ignore */
237
+ ...(ngDevMode ? [{ debugName: "#datePopupOpen" }] : /* istanbul ignore next */ []));
238
+ this.#elementRef = inject((ElementRef));
239
+ this.#gridService = inject(GridService, { optional: true });
240
+ this.#i18n = inject(MonaI18nService, { optional: true });
241
+ this.#logicalCell = inject(GridLogicalCellDirective, { optional: true });
242
+ /** Tab and Enter work on the whole row: in row edit mode and in the add row. */
243
+ this.#rowEditing = computed(() => this.isNew() || this.#gridService?.editContext()?.mode === "row", /* @ts-ignore */
244
+ ...(ngDevMode ? [{ debugName: "#rowEditing" }] : /* istanbul ignore next */ []));
245
+ this.#ignoreNextBooleanFocusOut = false;
246
+ /** The date before the last change, whose time of day a picked day keeps. */
247
+ this.#lastDateValue = null;
248
+ this.numericTextBoxRef = viewChild(NumericTextBoxComponent, /* @ts-ignore */
249
+ ...(ngDevMode ? [{ debugName: "numericTextBoxRef" }] : /* istanbul ignore next */ []));
250
+ this.textBoxRef = viewChild(TextBoxComponent, /* @ts-ignore */
251
+ ...(ngDevMode ? [{ debugName: "textBoxRef" }] : /* istanbul ignore next */ []));
252
+ this.baseClass = computed(() => {
253
+ return gridCellEditorBaseThemeVariants({ virtual: this.#gridService?.virtualScrollOptions().enabled ?? false });
254
+ }, /* @ts-ignore */
255
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
256
+ /**
257
+ * The form field typed for the editor that the column's data type picks. The column's type is the contract
258
+ * for its values, so these narrow the field for the template instead of turning off its type checks.
259
+ */
260
+ this.booleanField = computed(() => this.formField(), /* @ts-ignore */
261
+ ...(ngDevMode ? [{ debugName: "booleanField" }] : /* istanbul ignore next */ []));
262
+ this.dateField = computed(() => this.formField(), /* @ts-ignore */
263
+ ...(ngDevMode ? [{ debugName: "dateField" }] : /* istanbul ignore next */ []));
264
+ this.editTemplateContext = computed(() => {
265
+ const field = this.formField();
266
+ if (field == null) {
267
+ return null;
268
+ }
269
+ return {
270
+ cancel: () => this.cancelEdit.emit(),
271
+ column: this.column().field,
272
+ commit: () => this.commit.emit("enter"),
273
+ dataField: this.column().field,
274
+ dataItem: this.session().model(),
275
+ errors: field().errors(),
276
+ field,
277
+ form: this.session().form,
278
+ invalid: field().invalid(),
279
+ isNew: this.isNew(),
280
+ session: this.session(),
281
+ setValue: (value) => field().value.set(value),
282
+ touched: field().touched(),
283
+ value: field().value()
284
+ };
285
+ }, /* @ts-ignore */
286
+ ...(ngDevMode ? [{ debugName: "editTemplateContext" }] : /* istanbul ignore next */ []));
287
+ this.editorInputClass = computed(() => {
288
+ return gridCellEditorInputThemeVariants({
289
+ virtual: this.#gridService?.virtualScrollOptions().enabled ?? false
290
+ });
291
+ }, /* @ts-ignore */
292
+ ...(ngDevMode ? [{ debugName: "editorInputClass" }] : /* istanbul ignore next */ []));
293
+ /** The editor's accessible name: the column title, as the header that would name it is in another table. */
294
+ this.editorLabel = computed(() => this.column().title || this.column().field, /* @ts-ignore */
295
+ ...(ngDevMode ? [{ debugName: "editorLabel" }] : /* istanbul ignore next */ []));
296
+ this.errorDescribedBy = computed(() => (this.hasFieldError() ? this.errorId : ""), /* @ts-ignore */
297
+ ...(ngDevMode ? [{ debugName: "errorDescribedBy" }] : /* istanbul ignore next */ []));
298
+ this.errorId = `mona-grid-editor-error-${v4()}`;
299
+ this.fieldErrorMessage = computed(() => {
300
+ const [firstError] = this.formField()?.().errors() ?? [];
301
+ return firstError?.message ?? this.#gridService?.messages().fieldValidationError ?? "";
302
+ }, /* @ts-ignore */
303
+ ...(ngDevMode ? [{ debugName: "fieldErrorMessage" }] : /* istanbul ignore next */ []));
304
+ /** The column's form field; null when the session has none, as for a value a signal form can't hold. */
305
+ this.formField = computed(() => this.session().form[this.column().field] ?? null, /* @ts-ignore */
306
+ ...(ngDevMode ? [{ debugName: "formField" }] : /* istanbul ignore next */ []));
307
+ this.hasFieldError = computed(() => {
308
+ const field = this.formField()?.();
309
+ return field != null && field.invalid() && field.touched();
310
+ }, /* @ts-ignore */
311
+ ...(ngDevMode ? [{ debugName: "hasFieldError" }] : /* istanbul ignore next */ []));
312
+ this.numberField = computed(() => this.formField(), /* @ts-ignore */
313
+ ...(ngDevMode ? [{ debugName: "numberField" }] : /* istanbul ignore next */ []));
314
+ this.readOnlyValue = computed(() => this.session().model()[this.column().field], /* @ts-ignore */
315
+ ...(ngDevMode ? [{ debugName: "readOnlyValue" }] : /* istanbul ignore next */ []));
316
+ this.stringField = computed(() => this.formField(), /* @ts-ignore */
317
+ ...(ngDevMode ? [{ debugName: "stringField" }] : /* istanbul ignore next */ []));
318
+ /**
319
+ * @description Controls whether the editor focuses its input after it renders.
320
+ */
321
+ this.autoFocus = input(true, /* @ts-ignore */
322
+ ...(ngDevMode ? [{ debugName: "autoFocus" }] : /* istanbul ignore next */ []));
323
+ this.cancelEdit = output();
324
+ this.column = input.required(/* @ts-ignore */
325
+ ...(ngDevMode ? [{ debugName: "column" }] : /* istanbul ignore next */ []));
326
+ this.commit = output();
327
+ this.isNew = input(false, /* @ts-ignore */
328
+ ...(ngDevMode ? [{ debugName: "isNew" }] : /* istanbul ignore next */ []));
329
+ this.session = input.required(/* @ts-ignore */
330
+ ...(ngDevMode ? [{ debugName: "session" }] : /* istanbul ignore next */ []));
331
+ this.tabNavigate = output();
332
+ /**
333
+ * @description Enables Tab and Shift+Tab traversal between editable cells while cell editing.
334
+ */
335
+ this.tabNavigationEnabled = input(false, /* @ts-ignore */
336
+ ...(ngDevMode ? [{ debugName: "tabNavigationEnabled" }] : /* istanbul ignore next */ []));
337
+ effect(() => {
338
+ if (this.formField() == null && isDevMode()) {
339
+ console.warn(`mona-grid: column '${this.column().field}' has no form field in the edit session, so it is ` +
340
+ "shown read-only. Give the row a value for the field, or set the column's editable to false.");
341
+ }
342
+ });
343
+ effect(() => {
344
+ if (this.column().dataType !== "number") {
345
+ return;
346
+ }
347
+ const field = this.formField();
348
+ if (field == null) {
349
+ return;
350
+ }
351
+ const value = field().value();
352
+ const coercedValue = this.#coerceNumberValue(value);
353
+ if (Object.is(value, coercedValue)) {
354
+ return;
355
+ }
356
+ untracked(() => field().value.set(coercedValue));
357
+ });
358
+ effect(() => {
359
+ if (this.column().dataType !== "date") {
360
+ return;
361
+ }
362
+ const field = this.formField();
363
+ if (field == null) {
364
+ return;
365
+ }
366
+ const value = field().value();
367
+ untracked(() => this.#keepTimeOfDay(field, value));
368
+ });
369
+ afterNextRender({
370
+ read: () => this.#focusEditor()
371
+ });
372
+ }
373
+ onBooleanEditorClick() {
374
+ this.#focusBooleanInput();
375
+ }
376
+ onBooleanEditorFocusOut(event) {
377
+ const relatedTarget = event.relatedTarget;
378
+ const editorHost = event.currentTarget;
379
+ if (relatedTarget && editorHost.contains(relatedTarget)) {
380
+ return;
381
+ }
382
+ if (this.#ignoreNextBooleanFocusOut) {
383
+ return;
384
+ }
385
+ this.commit.emit("blur");
386
+ }
387
+ onBooleanEditorPointerDown() {
388
+ this.#ignoreNextBooleanFocusOut = true;
389
+ setTimeout(() => {
390
+ this.#ignoreNextBooleanFocusOut = false;
391
+ });
392
+ }
393
+ onDatePickerClose() {
394
+ this.#datePopupOpen.set(false);
395
+ }
396
+ onDatePickerOpen() {
397
+ this.#datePopupOpen.set(true);
398
+ }
399
+ /** Enter commits and Escape cancels, except while an IME composes or the date popup is open. */
400
+ onEditorKeydown(event) {
401
+ if (event.isComposing || event.keyCode === 229 || this.#datePopupOpen()) {
402
+ return;
403
+ }
404
+ if (event.key === "Enter") {
405
+ event.preventDefault();
406
+ this.commit.emit("enter");
407
+ }
408
+ else if (event.key === "Escape" && !event.defaultPrevented) {
409
+ event.preventDefault();
410
+ this.cancelEdit.emit();
411
+ }
412
+ }
413
+ onHostKeydown(event) {
414
+ if (event.key !== "Tab" || event.defaultPrevented || event.isComposing) {
415
+ return;
416
+ }
417
+ if (this.tabNavigationEnabled()) {
418
+ event.preventDefault();
419
+ event.stopPropagation();
420
+ this.tabNavigate.emit(event.shiftKey ? "previous" : "next");
421
+ return;
422
+ }
423
+ if (!this.#rowEditing()) {
424
+ return;
425
+ }
426
+ // Tab moves between the row's editors and commands; past either end it leaves the grid.
427
+ event.preventDefault();
428
+ event.stopPropagation();
429
+ if (!this.#focusSiblingControl(event.shiftKey)) {
430
+ this.#logicalCell?.leaveGrid(event.shiftKey);
431
+ }
432
+ }
433
+ #coerceNumberValue(value) {
434
+ if (typeof value === "number") {
435
+ return Number.isFinite(value) ? value : null;
436
+ }
437
+ if (typeof value !== "string") {
438
+ return null;
439
+ }
440
+ const text = value.trim();
441
+ if (text === "") {
442
+ return null;
443
+ }
444
+ if (MACHINE_NUMBER_PATTERN.test(text)) {
445
+ const numberValue = Number(text);
446
+ return Number.isFinite(numberValue) ? numberValue : null;
447
+ }
448
+ // Text as a person writes it in the grid's locale: "1.234,5" in de-DE.
449
+ return parseLocalizedNumber(text, this.#i18n?.localeId() ?? "en-US");
450
+ }
451
+ #focusBooleanInput() {
452
+ const checkbox = this.#elementRef.nativeElement.querySelector('input[type="checkbox"]');
453
+ checkbox?.focus();
454
+ }
455
+ #focusEditor() {
456
+ if (!this.autoFocus()) {
457
+ return;
458
+ }
459
+ if (this.column().editTemplate) {
460
+ this.#focusTemplateTarget();
461
+ return;
462
+ }
463
+ this.textBoxRef()?.focus();
464
+ this.numericTextBoxRef()?.focus();
465
+ const type = this.column().dataType;
466
+ if (type === "date") {
467
+ const inputElement = this.#elementRef.nativeElement.querySelector("input");
468
+ inputElement?.focus();
469
+ }
470
+ if (type === "boolean") {
471
+ this.#focusBooleanInput();
472
+ }
473
+ }
474
+ /** Focuses the next or previous editor or command button in the row; false at either end. */
475
+ #focusSiblingControl(backwards) {
476
+ const host = this.#elementRef.nativeElement;
477
+ const row = host.closest("tr");
478
+ if (row == null) {
479
+ return false;
480
+ }
481
+ const controls = [];
482
+ let current = -1;
483
+ for (const container of Array.from(row.querySelectorAll(ROW_EDITOR_SELECTOR))) {
484
+ const targets = this.#focusTargets(container);
485
+ if (container === host) {
486
+ current = controls.length;
487
+ }
488
+ // An editor is one stop; the command cell's buttons are one each.
489
+ controls.push(...(container.localName === "mona-grid-editor" ? targets.slice(0, 1) : targets));
490
+ }
491
+ if (current < 0) {
492
+ return false;
493
+ }
494
+ const target = controls[backwards ? current - 1 : current + 1];
495
+ if (target == null) {
496
+ return false;
497
+ }
498
+ target.focus();
499
+ return true;
500
+ }
501
+ #focusTargets(container) {
502
+ return Array.from(container.querySelectorAll(GRID_CELL_FOCUSABLE_SELECTOR)).filter(candidate => !candidate.hasAttribute("disabled") &&
503
+ candidate.getAttribute("aria-hidden") !== "true" &&
504
+ candidate.closest("[aria-hidden='true'], [hidden], [inert]") == null);
505
+ }
506
+ #focusTemplateTarget() {
507
+ this.#focusTargets(this.#elementRef.nativeElement)[0]?.focus();
508
+ }
509
+ /**
510
+ * Keeps the time of day when a new day is picked: the date picker gives midnight, which would drop the time a
511
+ * value had.
512
+ */
513
+ #keepTimeOfDay(field, value) {
514
+ const previous = this.#lastDateValue;
515
+ this.#lastDateValue = value instanceof Date ? value : null;
516
+ if (!(value instanceof Date) || previous == null || value === previous || Number.isNaN(value.getTime())) {
517
+ return;
518
+ }
519
+ const midnight = (date) => date.getHours() === 0 && date.getMinutes() === 0 && date.getSeconds() === 0 && date.getMilliseconds() === 0;
520
+ if (!midnight(value) || midnight(previous)) {
521
+ return;
522
+ }
523
+ const withTime = new Date(value);
524
+ withTime.setHours(previous.getHours(), previous.getMinutes(), previous.getSeconds(), previous.getMilliseconds());
525
+ this.#lastDateValue = withTime;
526
+ field().value.set(withTime);
527
+ }
528
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
529
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridEditorComponent, isStandalone: true, selector: "mona-grid-editor", inputs: { autoFocus: { classPropertyName: "autoFocus", publicName: "autoFocus", isSignal: true, isRequired: false, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null }, isNew: { classPropertyName: "isNew", publicName: "isNew", isSignal: true, isRequired: false, transformFunction: null }, session: { classPropertyName: "session", publicName: "session", isSignal: true, isRequired: true, transformFunction: null }, tabNavigationEnabled: { classPropertyName: "tabNavigationEnabled", publicName: "tabNavigationEnabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cancelEdit: "cancelEdit", commit: "commit", tabNavigate: "tabNavigate" }, host: { listeners: { "keydown": "onHostKeydown($event)" }, properties: { "class": "baseClass()" } }, viewQueries: [{ propertyName: "numericTextBoxRef", first: true, predicate: NumericTextBoxComponent, descendants: true, isSignal: true }, { propertyName: "textBoxRef", first: true, predicate: TextBoxComponent, descendants: true, isSignal: true }], ngImport: i0, template: "@if (formField()) {\n @if (column().editTemplate) {\n <ng-container\n [ngTemplateOutlet]=\"column().editTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: editTemplateContext() }\"></ng-container>\n } @else {\n <div class=\"relative flex items-center w-full min-h-8\">\n @switch (column().dataType) {\n @case (\"string\") {\n @if (stringField(); as field) {\n <mona-text-box\n [class]=\"editorInputClass()\"\n [inputAttributes]=\"{ autocomplete: 'off' }\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (keydown)=\"onEditorKeydown($event)\"\n (inputBlur)=\"commit.emit('blur')\"\n [size]=\"'small'\"></mona-text-box>\n }\n }\n @case (\"number\") {\n @if (numberField(); as field) {\n <mona-numeric-text-box\n [class]=\"editorInputClass()\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (keydown)=\"onEditorKeydown($event)\"\n (inputBlur)=\"commit.emit('blur')\"\n [size]=\"'small'\"></mona-numeric-text-box>\n }\n }\n @case (\"boolean\") {\n @if (booleanField(); as field) {\n <mona-check-box\n class=\"{{ editorInputClass() }} ms-2\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (click)=\"onBooleanEditorClick()\"\n (focusout)=\"onBooleanEditorFocusOut($event)\"\n (pointerdown)=\"onBooleanEditorPointerDown()\"\n (keydown)=\"onEditorKeydown($event)\"></mona-check-box>\n }\n }\n @case (\"date\") {\n @if (dateField(); as field) {\n <mona-date-picker\n [class]=\"editorInputClass()\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (keydown)=\"onEditorKeydown($event)\"\n (touch)=\"commit.emit('blur')\"\n (opened)=\"onDatePickerOpen()\"\n (closed)=\"onDatePickerClose()\"\n size=\"small\"></mona-date-picker>\n }\n }\n }\n @if (hasFieldError()) {\n <span class=\"shrink-0 px-1 text-error\" aria-hidden=\"true\" #fieldErrorIcon>\n <svg lucideOctagonAlert [size]=\"12\"></svg>\n </span>\n <mona-tooltip [target]=\"fieldErrorIcon\">\n <span class=\"p-1\">{{ fieldErrorMessage() }}</span>\n </mona-tooltip>\n <span class=\"sr-only\" [id]=\"errorId\">{{ fieldErrorMessage() }}</span>\n }\n </div>\n }\n} @else {\n <span class=\"block truncate px-2\">{{ readOnlyValue() }}</span>\n}\n", dependencies: [{ kind: "component", type: CheckBoxComponent, selector: "mona-check-box", inputs: ["aria-describedby", "aria-label", "checked", "disabled", "indeterminate", "invalid", "label", "labelPosition", "labelSize", "required", "rounded", "tabIndex", "touched", "class"], outputs: ["checkedChange", "inputBlur", "inputChange", "inputFocus", "touch"] }, { kind: "component", type: DatePickerComponent, selector: "mona-date-picker", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "disabled", "disabledDates", "firstDay", "format", "inputId", "invalid", "max", "min", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "readonlyInput", "required", "rounded", "showClearButton", "size", "touched", "class", "value", "weekNumber"], outputs: ["close", "closed", "open", "opened", "touch", "valueChange"] }, { kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "component", type: LucideOctagonAlert, selector: "svg[lucideOctagonAlert], svg[lucideAlertOctagon]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NumericTextBoxComponent, selector: "mona-numeric-text-box", inputs: ["formatter", "maxValue", "minValue", "step", "value"], outputs: ["valueChange"] }, { kind: "component", type: TextBoxComponent, selector: "mona-text-box", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "clearButton", "disabled", "inputAttributes", "inputClass", "inputId", "inputStyle", "invalid", "maxLength", "minLength", "name", "placeholder", "readonly", "required", "rounded", "size", "touched", "type", "class", "value"], outputs: ["inputBlur", "inputFocus", "touch", "valueChange"] }, { kind: "component", type: TooltipComponent, selector: "mona-tooltip", inputs: ["disabled", "hideDelay", "position", "rounded", "showDelay", "target"], outputs: ["hidden", "shown"] }] }); }
530
+ }
531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridEditorComponent, decorators: [{
532
+ type: Component,
533
+ args: [{ selector: "mona-grid-editor", imports: [
534
+ CheckBoxComponent,
535
+ DatePickerComponent,
536
+ FormField,
537
+ LucideOctagonAlert,
538
+ NgTemplateOutlet,
539
+ NumericTextBoxComponent,
540
+ TextBoxComponent,
541
+ TooltipComponent
542
+ ], host: {
543
+ "[class]": "baseClass()",
544
+ "(keydown)": "onHostKeydown($event)"
545
+ }, template: "@if (formField()) {\n @if (column().editTemplate) {\n <ng-container\n [ngTemplateOutlet]=\"column().editTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: editTemplateContext() }\"></ng-container>\n } @else {\n <div class=\"relative flex items-center w-full min-h-8\">\n @switch (column().dataType) {\n @case (\"string\") {\n @if (stringField(); as field) {\n <mona-text-box\n [class]=\"editorInputClass()\"\n [inputAttributes]=\"{ autocomplete: 'off' }\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (keydown)=\"onEditorKeydown($event)\"\n (inputBlur)=\"commit.emit('blur')\"\n [size]=\"'small'\"></mona-text-box>\n }\n }\n @case (\"number\") {\n @if (numberField(); as field) {\n <mona-numeric-text-box\n [class]=\"editorInputClass()\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (keydown)=\"onEditorKeydown($event)\"\n (inputBlur)=\"commit.emit('blur')\"\n [size]=\"'small'\"></mona-numeric-text-box>\n }\n }\n @case (\"boolean\") {\n @if (booleanField(); as field) {\n <mona-check-box\n class=\"{{ editorInputClass() }} ms-2\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (click)=\"onBooleanEditorClick()\"\n (focusout)=\"onBooleanEditorFocusOut($event)\"\n (pointerdown)=\"onBooleanEditorPointerDown()\"\n (keydown)=\"onEditorKeydown($event)\"></mona-check-box>\n }\n }\n @case (\"date\") {\n @if (dateField(); as field) {\n <mona-date-picker\n [class]=\"editorInputClass()\"\n [rounded]=\"'none'\"\n [formField]=\"field\"\n [aria-label]=\"editorLabel()\"\n [aria-describedby]=\"errorDescribedBy()\"\n (keydown)=\"onEditorKeydown($event)\"\n (touch)=\"commit.emit('blur')\"\n (opened)=\"onDatePickerOpen()\"\n (closed)=\"onDatePickerClose()\"\n size=\"small\"></mona-date-picker>\n }\n }\n }\n @if (hasFieldError()) {\n <span class=\"shrink-0 px-1 text-error\" aria-hidden=\"true\" #fieldErrorIcon>\n <svg lucideOctagonAlert [size]=\"12\"></svg>\n </span>\n <mona-tooltip [target]=\"fieldErrorIcon\">\n <span class=\"p-1\">{{ fieldErrorMessage() }}</span>\n </mona-tooltip>\n <span class=\"sr-only\" [id]=\"errorId\">{{ fieldErrorMessage() }}</span>\n }\n </div>\n }\n} @else {\n <span class=\"block truncate px-2\">{{ readOnlyValue() }}</span>\n}\n" }]
546
+ }], ctorParameters: () => [], propDecorators: { numericTextBoxRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => NumericTextBoxComponent), { isSignal: true }] }], textBoxRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TextBoxComponent), { isSignal: true }] }], autoFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoFocus", required: false }] }], cancelEdit: [{ type: i0.Output, args: ["cancelEdit"] }], column: [{ type: i0.Input, args: [{ isSignal: true, alias: "column", required: true }] }], commit: [{ type: i0.Output, args: ["commit"] }], isNew: [{ type: i0.Input, args: [{ isSignal: true, alias: "isNew", required: false }] }], session: [{ type: i0.Input, args: [{ isSignal: true, alias: "session", required: true }] }], tabNavigate: [{ type: i0.Output, args: ["tabNavigate"] }], tabNavigationEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabNavigationEnabled", required: false }] }] } });
547
+
548
+ class GridAddRowComponent {
549
+ constructor() {
550
+ this.#gridNavigationService = inject(GridNavigationService);
551
+ this.baseClass = computed(() => {
552
+ return gridListTableRowThemeVariants({ selected: false });
553
+ }, /* @ts-ignore */
554
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
555
+ this.firstEditableColumn = computed(() => this.gridService.visibleColumns().firstOrDefault(column => column.kind === "data" && column.editable), /* @ts-ignore */
556
+ ...(ngDevMode ? [{ debugName: "firstEditableColumn" }] : /* istanbul ignore next */ []));
557
+ this.gridService = inject(GridService);
558
+ this.structuralColumnIds = {
559
+ detail: undefined,
560
+ reorder: "$rowReorder",
561
+ selection: "$selection"
562
+ };
563
+ }
564
+ #gridNavigationService;
565
+ /** Escape discards the new row; focus goes to the nearest cell once the row is gone. */
566
+ onCancel() {
567
+ if (this.gridService.cancelAddRow(undefined, "escape")) {
568
+ this.#gridNavigationService.refocusAfterRender();
569
+ }
570
+ }
571
+ /** Enter saves the new row (validated); leaving an editor keeps the row open. */
572
+ onCommit(trigger) {
573
+ if (trigger === "enter" && this.gridService.saveAddRow()) {
574
+ this.#gridNavigationService.refocusAfterRender();
575
+ }
576
+ }
577
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridAddRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
578
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridAddRowComponent, isStandalone: true, selector: "tr[monaGridAddRow]", host: { attributes: { "role": "row", "data-grid-add-row": "true" }, properties: { "class": "baseClass()", "attr.aria-rowindex": "gridService.headerRowCount() + 1" } }, ngImport: i0, template: "@if (gridService.addRowData(); as rowData) {\n @let session = gridService.editSession();\n @for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n @let column = layoutColumn.column;\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"column.id\"\n [rowIndex]=\"-1\"\n [section]=\"'add'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n @if (column.kind === \"command\") {\n <mona-grid-command-cell [column]=\"column\" [newRow]=\"true\"></mona-grid-command-cell>\n } @else if (column.editable && session) {\n <mona-grid-editor\n [column]=\"column\"\n [autoFocus]=\"column === firstEditableColumn()\"\n [isNew]=\"true\"\n [session]=\"session\"\n (commit)=\"onCommit($event)\"\n (cancelEdit)=\"onCancel()\"></mona-grid-editor>\n } @else {\n <span class=\"block truncate px-2\">{{ rowData[column.field] }}</span>\n }\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [lockedCellHeader]=\"true\"\n [groupIndent]=\"true\"></td>\n } @else {\n <td\n monaGridCell\n monaGridLogicalCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [rowIndex]=\"-1\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [cellKind]=\"layoutColumn.kind === 'detail' ? 'detail' : 'command'\"\n [columnId]=\"structuralColumnIds[layoutColumn.kind]\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [section]=\"'add'\"></td>\n }\n }\n}\n", dependencies: [{ kind: "directive", type: GridCellDirective, selector: "td[monaGridCell]", inputs: ["groupHeader", "groupIndent", "lastInRow"] }, { kind: "component", type: GridCommandCellComponent, selector: "mona-grid-command-cell", inputs: ["column", "newRow", "row"] }, { kind: "component", type: GridEditorComponent, selector: "mona-grid-editor", inputs: ["autoFocus", "column", "isNew", "session", "tabNavigationEnabled"], outputs: ["cancelEdit", "commit", "tabNavigate"] }, { kind: "directive", type: GridLockedCellDirective, selector: "td[monaGridLockedCell], th[monaGridLockedCell]", inputs: ["monaGridLockedCell", "lockedCellHeader"] }, { kind: "directive", type: GridLogicalCellDirective, selector: "td[monaGridLogicalCell], th[monaGridLogicalCell]", inputs: ["ariaColIndex", "cellKind", "colIndex", "columnId", "editable", "expanded", "firstInRow", "groupHeader", "groupKey", "lastInRow", "readOnly", "rowIndex", "rowUid", "section"], outputs: ["edit", "menuOpen", "toggleExpand"] }] }); }
579
+ }
580
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridAddRowComponent, decorators: [{
581
+ type: Component,
582
+ args: [{ selector: "tr[monaGridAddRow]", imports: [
583
+ GridCellDirective,
584
+ GridCommandCellComponent,
585
+ GridEditorComponent,
586
+ GridLockedCellDirective,
587
+ GridLogicalCellDirective
588
+ ], host: {
589
+ "[class]": "baseClass()",
590
+ role: "row",
591
+ "[attr.aria-rowindex]": "gridService.headerRowCount() + 1",
592
+ "data-grid-add-row": "true"
593
+ }, template: "@if (gridService.addRowData(); as rowData) {\n @let session = gridService.editSession();\n @for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n @let column = layoutColumn.column;\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"column.id\"\n [rowIndex]=\"-1\"\n [section]=\"'add'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n @if (column.kind === \"command\") {\n <mona-grid-command-cell [column]=\"column\" [newRow]=\"true\"></mona-grid-command-cell>\n } @else if (column.editable && session) {\n <mona-grid-editor\n [column]=\"column\"\n [autoFocus]=\"column === firstEditableColumn()\"\n [isNew]=\"true\"\n [session]=\"session\"\n (commit)=\"onCommit($event)\"\n (cancelEdit)=\"onCancel()\"></mona-grid-editor>\n } @else {\n <span class=\"block truncate px-2\">{{ rowData[column.field] }}</span>\n }\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [lockedCellHeader]=\"true\"\n [groupIndent]=\"true\"></td>\n } @else {\n <td\n monaGridCell\n monaGridLogicalCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n [rowIndex]=\"-1\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [cellKind]=\"layoutColumn.kind === 'detail' ? 'detail' : 'command'\"\n [columnId]=\"structuralColumnIds[layoutColumn.kind]\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [section]=\"'add'\"></td>\n }\n }\n}\n" }]
594
+ }] });
595
+
596
+ class GridToggleComponent {
597
+ constructor() {
598
+ this.collapseIcon = computed(() => {
599
+ const type = this.type();
600
+ return type === "detail" ? LucideMinus : LucideChevronDown;
601
+ }, /* @ts-ignore */
602
+ ...(ngDevMode ? [{ debugName: "collapseIcon" }] : /* istanbul ignore next */ []));
603
+ this.expandIcon = computed(() => {
604
+ const type = this.type();
605
+ return type === "detail" ? LucidePlus : LucideChevronRight;
606
+ }, /* @ts-ignore */
607
+ ...(ngDevMode ? [{ debugName: "expandIcon" }] : /* istanbul ignore next */ []));
608
+ this.expanded = model.required(/* @ts-ignore */
609
+ ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
610
+ /** The detail toggle button's name, such as "Expand details of row 3". */
611
+ this.label = input(null, /* @ts-ignore */
612
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
613
+ this.type = input.required(/* @ts-ignore */
614
+ ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
615
+ this.width = input.required(/* @ts-ignore */
616
+ ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
617
+ }
618
+ onToggleDetailClick(event) {
619
+ event.stopPropagation();
620
+ this.expanded.update(v => !v);
621
+ }
622
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridToggleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
623
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridToggleComponent, isStandalone: true, selector: "mona-grid-toggle", inputs: { expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { expanded: "expandedChange" }, ngImport: i0, template: "@if (type() === \"detail\") {\n <button\n type=\"button\"\n [style.width.px]=\"width()\"\n class=\"inline-flex items-center justify-center min-h-9 aspect-square cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-indicator\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-label]=\"label()\"\n (click)=\"onToggleDetailClick($event)\">\n @if (expanded()) {\n <svg [lucideIcon]=\"collapseIcon()\" [size]=\"16\" aria-hidden=\"true\"></svg>\n } @else {\n <svg [lucideIcon]=\"expandIcon()\" [size]=\"16\" aria-hidden=\"true\"></svg>\n }\n </button>\n} @else {\n <!-- The group row carries aria-expanded, and its cell expands with Enter and the arrows. -->\n <span\n [style.width.px]=\"width()\"\n class=\"inline-flex items-center justify-center min-h-9 aspect-square\"\n aria-hidden=\"true\"\n (click)=\"onToggleDetailClick($event)\">\n @if (expanded()) {\n <svg [lucideIcon]=\"collapseIcon()\" [size]=\"16\"></svg>\n } @else {\n <svg [lucideIcon]=\"expandIcon()\" [size]=\"16\"></svg>\n }\n </span>\n}\n", dependencies: [{ kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] }); }
624
+ }
625
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridToggleComponent, decorators: [{
626
+ type: Component,
627
+ args: [{ selector: "mona-grid-toggle", imports: [LucideDynamicIcon], template: "@if (type() === \"detail\") {\n <button\n type=\"button\"\n [style.width.px]=\"width()\"\n class=\"inline-flex items-center justify-center min-h-9 aspect-square cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-indicator\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-label]=\"label()\"\n (click)=\"onToggleDetailClick($event)\">\n @if (expanded()) {\n <svg [lucideIcon]=\"collapseIcon()\" [size]=\"16\" aria-hidden=\"true\"></svg>\n } @else {\n <svg [lucideIcon]=\"expandIcon()\" [size]=\"16\" aria-hidden=\"true\"></svg>\n }\n </button>\n} @else {\n <!-- The group row carries aria-expanded, and its cell expands with Enter and the arrows. -->\n <span\n [style.width.px]=\"width()\"\n class=\"inline-flex items-center justify-center min-h-9 aspect-square\"\n aria-hidden=\"true\"\n (click)=\"onToggleDetailClick($event)\">\n @if (expanded()) {\n <svg [lucideIcon]=\"collapseIcon()\" [size]=\"16\"></svg>\n } @else {\n <svg [lucideIcon]=\"expandIcon()\" [size]=\"16\"></svg>\n }\n </span>\n}\n" }]
628
+ }], propDecorators: { expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: true }] }, { type: i0.Output, args: ["expandedChange"] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: true }] }] } });
629
+
630
+ /**
631
+ * A group header row. It indents by the group depth, and its title cell spans the remaining columns.
632
+ */
633
+ class GridGroupRowComponent {
634
+ constructor() {
635
+ this.collapsed = computed(() => this.gridService.isGroupCollapsed(this.group().groupKey), /* @ts-ignore */
636
+ ...(ngDevMode ? [{ debugName: "collapsed" }] : /* istanbul ignore next */ []));
637
+ this.gridService = inject(GridService);
638
+ this.indentColumns = computed(() => this.gridService.layout().filter(column => column.kind === "group" && column.depth < this.group().depth), /* @ts-ignore */
639
+ ...(ngDevMode ? [{ debugName: "indentColumns" }] : /* istanbul ignore next */ []));
640
+ this.rowClass = computed(() => gridGroupRowThemeVariants({ virtual: this.gridService.virtualScrollOptions().enabled }), /* @ts-ignore */
641
+ ...(ngDevMode ? [{ debugName: "rowClass" }] : /* istanbul ignore next */ []));
642
+ this.titleClass = computed(() => this.gridService.virtualScrollOptions().enabled
643
+ ? "absolute inset-0 flex items-center text-sm whitespace-nowrap overflow-hidden"
644
+ : "flex min-h-9 items-center text-sm whitespace-nowrap", /* @ts-ignore */
645
+ ...(ngDevMode ? [{ debugName: "titleClass" }] : /* istanbul ignore next */ []));
646
+ /** The title cell comes after the indents and the reorder placeholder. */
647
+ this.titleColIndex = computed(() => this.group().depth + (this.gridService.rowReorderColumnVisible() ? 1 : 0) + 1, /* @ts-ignore */
648
+ ...(ngDevMode ? [{ debugName: "titleColIndex" }] : /* istanbul ignore next */ []));
649
+ // Everything after the indents and the reorder placeholder.
650
+ this.titleColspan = computed(() => this.gridService.layout().length - this.group().depth - (this.gridService.rowReorderColumnVisible() ? 1 : 0), /* @ts-ignore */
651
+ ...(ngDevMode ? [{ debugName: "titleColspan" }] : /* istanbul ignore next */ []));
652
+ this.ariaRowIndex = input(null, /* @ts-ignore */
653
+ ...(ngDevMode ? [{ debugName: "ariaRowIndex" }] : /* istanbul ignore next */ []));
654
+ this.group = input.required(/* @ts-ignore */
655
+ ...(ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []));
656
+ /** The index of this row among the rendered body rows. */
657
+ this.rowIndex = input.required(/* @ts-ignore */
658
+ ...(ngDevMode ? [{ debugName: "rowIndex" }] : /* istanbul ignore next */ []));
659
+ }
660
+ toggle() {
661
+ this.gridService.toggleGroupCollapse(this.group().groupKey);
662
+ }
663
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridGroupRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
664
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridGroupRowComponent, isStandalone: true, selector: "tr[monaGridGroupRow]", inputs: { ariaRowIndex: { classPropertyName: "ariaRowIndex", publicName: "ariaRowIndex", isSignal: true, isRequired: false, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: true, transformFunction: null }, rowIndex: { classPropertyName: "rowIndex", publicName: "rowIndex", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "row" }, properties: { "class": "rowClass()", "attr.aria-level": "group().depth + 1", "attr.aria-expanded": "!collapsed()", "attr.aria-rowindex": "ariaRowIndex()" } }, ngImport: i0, template: "@for (layoutColumn of indentColumns(); track layoutColumn.key) {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n}\n@if (gridService.rowReorderColumnVisible()) {\n <!-- Sits right after the indents, so it pins like the group column at this depth. -->\n <td\n monaGridCell\n [monaGridLockedCell]=\"'group:' + group().depth\"\n [lockedCellHeader]=\"true\"\n [groupIndent]=\"true\"></td>\n}\n<td\n monaGridCell\n monaGridLogicalCell\n [cellKind]=\"'group'\"\n [rowIndex]=\"rowIndex()\"\n [colIndex]=\"0\"\n [section]=\"'body'\"\n [groupHeader]=\"true\"\n [firstInRow]=\"true\"\n [lastInRow]=\"gridService.visibleColumns().length === 0\"\n [groupKey]=\"group().groupKey\"\n [expanded]=\"!collapsed()\"\n [ariaColIndex]=\"titleColIndex()\"\n [attr.colspan]=\"titleColspan()\"\n (toggleExpand)=\"toggle()\">\n <p [class]=\"titleClass()\">\n <mona-grid-toggle\n [expanded]=\"!collapsed()\"\n [width]=\"gridService.groupColumnWidth\"\n [type]=\"'group'\"\n (expandedChange)=\"toggle()\" />\n <span class=\"font-bold\">{{ group().title }}: {{ group().groupValue }}</span>\n </p>\n</td>\n", dependencies: [{ kind: "directive", type: GridCellDirective, selector: "td[monaGridCell]", inputs: ["groupHeader", "groupIndent", "lastInRow"] }, { kind: "directive", type: GridLockedCellDirective, selector: "td[monaGridLockedCell], th[monaGridLockedCell]", inputs: ["monaGridLockedCell", "lockedCellHeader"] }, { kind: "directive", type: GridLogicalCellDirective, selector: "td[monaGridLogicalCell], th[monaGridLogicalCell]", inputs: ["ariaColIndex", "cellKind", "colIndex", "columnId", "editable", "expanded", "firstInRow", "groupHeader", "groupKey", "lastInRow", "readOnly", "rowIndex", "rowUid", "section"], outputs: ["edit", "menuOpen", "toggleExpand"] }, { kind: "component", type: GridToggleComponent, selector: "mona-grid-toggle", inputs: ["expanded", "label", "type", "width"], outputs: ["expandedChange"] }] }); }
665
+ }
666
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridGroupRowComponent, decorators: [{
667
+ type: Component,
668
+ args: [{ selector: "tr[monaGridGroupRow]", imports: [GridCellDirective, GridLockedCellDirective, GridLogicalCellDirective, GridToggleComponent], host: {
669
+ "[class]": "rowClass()",
670
+ role: "row",
671
+ "[attr.aria-level]": "group().depth + 1",
672
+ "[attr.aria-expanded]": "!collapsed()",
673
+ "[attr.aria-rowindex]": "ariaRowIndex()"
674
+ }, template: "@for (layoutColumn of indentColumns(); track layoutColumn.key) {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n}\n@if (gridService.rowReorderColumnVisible()) {\n <!-- Sits right after the indents, so it pins like the group column at this depth. -->\n <td\n monaGridCell\n [monaGridLockedCell]=\"'group:' + group().depth\"\n [lockedCellHeader]=\"true\"\n [groupIndent]=\"true\"></td>\n}\n<td\n monaGridCell\n monaGridLogicalCell\n [cellKind]=\"'group'\"\n [rowIndex]=\"rowIndex()\"\n [colIndex]=\"0\"\n [section]=\"'body'\"\n [groupHeader]=\"true\"\n [firstInRow]=\"true\"\n [lastInRow]=\"gridService.visibleColumns().length === 0\"\n [groupKey]=\"group().groupKey\"\n [expanded]=\"!collapsed()\"\n [ariaColIndex]=\"titleColIndex()\"\n [attr.colspan]=\"titleColspan()\"\n (toggleExpand)=\"toggle()\">\n <p [class]=\"titleClass()\">\n <mona-grid-toggle\n [expanded]=\"!collapsed()\"\n [width]=\"gridService.groupColumnWidth\"\n [type]=\"'group'\"\n (expandedChange)=\"toggle()\" />\n <span class=\"font-bold\">{{ group().title }}: {{ group().groupValue }}</span>\n </p>\n</td>\n" }]
675
+ }], propDecorators: { ariaRowIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaRowIndex", required: false }] }], group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: true }] }], rowIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowIndex", required: true }] }] } });
676
+
677
+ class GridCellComponent {
678
+ constructor() {
679
+ this.#elementRef = inject((ElementRef));
680
+ this.#gridNavigationService = inject(GridNavigationService);
681
+ this.#injector = inject(Injector);
682
+ this.#locale = inject(LOCALE_ID);
683
+ this.#logicalCell = inject(GridLogicalCellDirective, { optional: true });
684
+ this.baseClass = computed(() => {
685
+ return gridCellBaseThemeVariants({ virtual: this.gridService.virtualScrollOptions().enabled });
686
+ }, /* @ts-ignore */
687
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
688
+ this.cellContainerClass = computed(() => {
689
+ const editing = this.isEditing();
690
+ return gridCellContainerThemeVariants({ editing, virtual: this.gridService.virtualScrollOptions().enabled });
691
+ }, /* @ts-ignore */
692
+ ...(ngDevMode ? [{ debugName: "cellContainerClass" }] : /* istanbul ignore next */ []));
693
+ this.cellDirtyIndicatorClass = computed(() => {
694
+ return gridCellDirtyIndicatorThemeVariants();
695
+ }, /* @ts-ignore */
696
+ ...(ngDevMode ? [{ debugName: "cellDirtyIndicatorClass" }] : /* istanbul ignore next */ []));
697
+ this.cellTextClass = computed(() => {
698
+ return gridCellTextThemeVariants();
699
+ }, /* @ts-ignore */
700
+ ...(ngDevMode ? [{ debugName: "cellTextClass" }] : /* istanbul ignore next */ []));
701
+ this.cellUid = computed(() => `${this.row().uid}_${this.column().id}`, /* @ts-ignore */
702
+ ...(ngDevMode ? [{ debugName: "cellUid" }] : /* istanbul ignore next */ []));
703
+ this.displayValue = computed(() => {
704
+ const editedRowData = this.gridService.editViewDict().get(this.row().uid);
705
+ const rowData = this.row().data;
706
+ const effectiveRowData = editedRowData ?? rowData;
707
+ return effectiveRowData[this.column().field];
708
+ }, /* @ts-ignore */
709
+ ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
710
+ this.editContextIsCellMode = computed(() => this.gridService.editContext()?.mode === "cell", /* @ts-ignore */
711
+ ...(ngDevMode ? [{ debugName: "editContextIsCellMode" }] : /* istanbul ignore next */ []));
712
+ this.formattedDisplayValue = computed(() => {
713
+ const column = this.column();
714
+ const value = this.displayValue();
715
+ const format = column.format;
716
+ if (format == null) {
717
+ return value;
718
+ }
719
+ if (typeof format === "function") {
720
+ return format(value, this.row().data, column);
721
+ }
722
+ if (column.dataType === "date") {
723
+ return this.formatDateValue(value, format);
724
+ }
725
+ return value;
726
+ }, /* @ts-ignore */
727
+ ...(ngDevMode ? [{ debugName: "formattedDisplayValue" }] : /* istanbul ignore next */ []));
728
+ this.gridService = inject(GridService);
729
+ this.isCellPristine = computed(() => {
730
+ const row = this.row();
731
+ const editedRowData = this.gridService.editViewDict().get(row.uid);
732
+ if (!editedRowData) {
733
+ return true;
734
+ }
735
+ const field = this.column().field;
736
+ return row.data[field] === editedRowData[field];
737
+ }, /* @ts-ignore */
738
+ ...(ngDevMode ? [{ debugName: "isCellPristine" }] : /* istanbul ignore next */ []));
739
+ this.isEditing = computed(() => {
740
+ const context = this.gridService.editContext();
741
+ if (context == null) {
742
+ return false;
743
+ }
744
+ if (context.mode === "cell") {
745
+ return context.cellUid === this.cellUid();
746
+ }
747
+ return context.rowUid === this.row().uid && this.column().editable;
748
+ }, /* @ts-ignore */
749
+ ...(ngDevMode ? [{ debugName: "isEditing" }] : /* istanbul ignore next */ []));
750
+ this.shouldAutoFocusEditor = computed(() => {
751
+ const context = this.gridService.editContext();
752
+ if (context?.mode === "cell") {
753
+ return context.cellUid === this.cellUid();
754
+ }
755
+ if (context?.mode !== "row" || context.rowUid !== this.row().uid) {
756
+ return false;
757
+ }
758
+ if (context.focusColumnId != null) {
759
+ return context.focusColumnId === this.column().id;
760
+ }
761
+ return (this.gridService.visibleColumns().firstOrDefault(column => column.kind === "data" && column.editable) ===
762
+ this.column());
763
+ }, /* @ts-ignore */
764
+ ...(ngDevMode ? [{ debugName: "shouldAutoFocusEditor" }] : /* istanbul ignore next */ []));
765
+ this.column = input.required(/* @ts-ignore */
766
+ ...(ngDevMode ? [{ debugName: "column" }] : /* istanbul ignore next */ []));
767
+ this.row = input.required(/* @ts-ignore */
768
+ ...(ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []));
769
+ }
770
+ #elementRef;
771
+ #gridNavigationService;
772
+ #injector;
773
+ #locale;
774
+ #logicalCell;
775
+ /** Enter or F2: edits the cell in cell mode; in row mode, edits the row from this cell's editor. */
776
+ handleLogicalCellEnter(originalEvent) {
777
+ const editableOptions = this.gridService.editableOptions();
778
+ if (!editableOptions.enabled || this.column().kind !== "data") {
779
+ return;
780
+ }
781
+ if (editableOptions.mode === "cell") {
782
+ this.startEdit(originalEvent);
783
+ return;
784
+ }
785
+ const context = this.gridService.editContext();
786
+ if (context?.mode === "row" && context.rowUid === this.row().uid) {
787
+ this.focusInnerEditor();
788
+ return;
789
+ }
790
+ const column = this.column();
791
+ this.gridService.startRowEdit(this.row(), originalEvent, column.editable ? column.id : null);
792
+ }
793
+ onCellDoubleClick(event) {
794
+ if (this.gridService.editableOptions().mode === "cell") {
795
+ this.startEdit(event);
796
+ }
797
+ }
798
+ /** Escape: cancels the cell or row edit. Focus stays in the editor when the cancel is prevented. */
799
+ onEditCancel() {
800
+ if (this.gridService.editContext() != null && this.gridService.cancelEdit(undefined, "escape")) {
801
+ this.focusHostCell();
802
+ }
803
+ }
804
+ /** Ends a cell edit on Enter or blur; a row edit only on Enter, as focus moves between its editors. */
805
+ onEditCommit(trigger) {
806
+ const context = this.gridService.editContext();
807
+ if (context?.mode === "cell") {
808
+ if (this.gridService.stopCellEdit()) {
809
+ this.focusHostCell();
810
+ }
811
+ return;
812
+ }
813
+ if (context?.mode === "row" && trigger === "enter" && this.gridService.commitRowEdit()) {
814
+ this.focusHostCell();
815
+ }
816
+ }
817
+ onEditTabNavigate(direction) {
818
+ const context = this.gridService.editContext();
819
+ if (context?.mode !== "cell") {
820
+ return;
821
+ }
822
+ const rowUid = this.row().uid;
823
+ const columnId = this.column().id;
824
+ if (!this.gridService.stopCellEdit()) {
825
+ return;
826
+ }
827
+ // The commit may replace the row data, so wait for the grid to re-render before starting the next edit.
828
+ afterNextRender({
829
+ read: () => {
830
+ if (this.#gridNavigationService.focusAdjacentEditableCell(rowUid, columnId, direction)) {
831
+ return;
832
+ }
833
+ // The last editable cell: Tab leaves the grid, or stays on the cell when nothing follows it.
834
+ if (!this.#logicalCell?.leaveGrid(direction === "previous")) {
835
+ this.focusHostCell();
836
+ }
837
+ }
838
+ }, { injector: this.#injector });
839
+ }
840
+ focusHostCell() {
841
+ const cellElement = this.#elementRef.nativeElement.closest("td");
842
+ cellElement?.focus();
843
+ }
844
+ focusInnerEditor() {
845
+ const target = this.#elementRef.nativeElement.querySelector(GRID_CELL_FOCUSABLE_SELECTOR);
846
+ target?.focus();
847
+ }
848
+ formatDateValue(value, format) {
849
+ if (value == null) {
850
+ return value;
851
+ }
852
+ if (value instanceof Date || typeof value === "number" || typeof value === "string") {
853
+ try {
854
+ return formatDate(value, format, this.#locale);
855
+ }
856
+ catch {
857
+ return value;
858
+ }
859
+ }
860
+ return value;
861
+ }
862
+ startEdit(originalEvent) {
863
+ if (!this.gridService.editableOptions().enabled || !this.column().editable || this.column().kind !== "data") {
864
+ return;
865
+ }
866
+ this.gridService.startCellEdit(this.cellUid(), this.row(), this.column(), originalEvent);
867
+ }
868
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
869
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridCellComponent, isStandalone: true, selector: "mona-grid-cell", inputs: { column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class": "baseClass()" } }, ngImport: i0, template: "@let dataItem = row().data;\n@let dataKey = column().field;\n\n@if (column().kind === \"command\") {\n <mona-grid-command-cell [column]=\"column()\" [row]=\"row()\"></mona-grid-command-cell>\n} @else {\n <div\n [class]=\"cellContainerClass()\"\n [attr.data-uid]=\"cellUid()\"\n [attr.data-ruid]=\"row().uid\"\n [attr.data-field]=\"dataKey\"\n [attr.data-col-index]=\"column().index\"\n (dblclick)=\"onCellDoubleClick($event)\">\n @if (isEditing() && gridService.editSession(); as session) {\n <mona-grid-editor\n [column]=\"column()\"\n [autoFocus]=\"shouldAutoFocusEditor()\"\n [session]=\"session\"\n [tabNavigationEnabled]=\"editContextIsCellMode()\"\n (commit)=\"onEditCommit($event)\"\n (cancelEdit)=\"onEditCancel()\"\n (tabNavigate)=\"onEditTabNavigate($event)\"></mona-grid-editor>\n } @else if (column().cellTemplate) {\n <ng-container\n [ngTemplateOutlet]=\"column().cellTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem, column: column().field }\"></ng-container>\n } @else {\n <span [class]=\"cellTextClass()\">{{ formattedDisplayValue() }}</span>\n }\n @if (!isCellPristine()) {\n <span\n aria-hidden=\"true\"\n [class]=\"cellDirtyIndicatorClass()\"\n [title]=\"gridService.messages().modified\"></span>\n }\n </div>\n}\n", dependencies: [{ kind: "component", type: GridCommandCellComponent, selector: "mona-grid-command-cell", inputs: ["column", "newRow", "row"] }, { kind: "component", type: GridEditorComponent, selector: "mona-grid-editor", inputs: ["autoFocus", "column", "isNew", "session", "tabNavigationEnabled"], outputs: ["cancelEdit", "commit", "tabNavigate"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
870
+ }
871
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridCellComponent, decorators: [{
872
+ type: Component,
873
+ args: [{ selector: "mona-grid-cell", imports: [GridCommandCellComponent, GridEditorComponent, NgTemplateOutlet], host: {
874
+ "[class]": "baseClass()"
875
+ }, template: "@let dataItem = row().data;\n@let dataKey = column().field;\n\n@if (column().kind === \"command\") {\n <mona-grid-command-cell [column]=\"column()\" [row]=\"row()\"></mona-grid-command-cell>\n} @else {\n <div\n [class]=\"cellContainerClass()\"\n [attr.data-uid]=\"cellUid()\"\n [attr.data-ruid]=\"row().uid\"\n [attr.data-field]=\"dataKey\"\n [attr.data-col-index]=\"column().index\"\n (dblclick)=\"onCellDoubleClick($event)\">\n @if (isEditing() && gridService.editSession(); as session) {\n <mona-grid-editor\n [column]=\"column()\"\n [autoFocus]=\"shouldAutoFocusEditor()\"\n [session]=\"session\"\n [tabNavigationEnabled]=\"editContextIsCellMode()\"\n (commit)=\"onEditCommit($event)\"\n (cancelEdit)=\"onEditCancel()\"\n (tabNavigate)=\"onEditTabNavigate($event)\"></mona-grid-editor>\n } @else if (column().cellTemplate) {\n <ng-container\n [ngTemplateOutlet]=\"column().cellTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem, column: column().field }\"></ng-container>\n } @else {\n <span [class]=\"cellTextClass()\">{{ formattedDisplayValue() }}</span>\n }\n @if (!isCellPristine()) {\n <span\n aria-hidden=\"true\"\n [class]=\"cellDirtyIndicatorClass()\"\n [title]=\"gridService.messages().modified\"></span>\n }\n </div>\n}\n" }]
876
+ }], propDecorators: { column: [{ type: i0.Input, args: [{ isSignal: true, alias: "column", required: true }] }], row: [{ type: i0.Input, args: [{ isSignal: true, alias: "row", required: true }] }] } });
877
+
878
+ class GridRowReorderHandleComponent {
879
+ constructor() {
880
+ this.#gridService = inject(GridService);
881
+ this.#hostElement = inject(ElementRef).nativeElement;
882
+ this.#injector = inject(Injector);
883
+ this.#liveAnnouncer = inject(LiveAnnouncer);
884
+ this.ariaLabel = computed(() => {
885
+ const absoluteIndex = this.pageIndex() + this.#gridService.paginationState().skip;
886
+ const label = this.#gridService.getRowReorderAriaLabel(this.row(), absoluteIndex);
887
+ const reasonText = this.disabledReasonText();
888
+ const messages = this.#gridService.messages();
889
+ return messages.rowReorderHandleAriaLabel(label, messages.rowReorderKeyboardHint, reasonText ?? undefined);
890
+ }, /* @ts-ignore */
891
+ ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
892
+ this.disabled = computed(() => !this.#gridService.canReorderRow(this.row()), /* @ts-ignore */
893
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
894
+ this.disabledReasonText = computed(() => {
895
+ const reason = this.#gridService.rowReorderDisabledReason();
896
+ const messages = this.#gridService.messages();
897
+ switch (reason) {
898
+ case null:
899
+ return null;
900
+ case "disabled":
901
+ return messages.rowReorderDisabled;
902
+ case "editing":
903
+ return messages.rowReorderDisabledEditing;
904
+ case "filtered":
905
+ return messages.rowReorderDisabledFiltered;
906
+ case "grouped":
907
+ return messages.rowReorderDisabledGrouped;
908
+ case "single-row":
909
+ return messages.rowReorderDisabledSingleRow;
910
+ case "server-binding":
911
+ return messages.rowReorderDisabledServerBinding;
912
+ case "sorted":
913
+ return messages.rowReorderDisabledSorted;
914
+ case "virtual-scroll":
915
+ return messages.rowReorderDisabledVirtualScroll;
916
+ }
917
+ }, /* @ts-ignore */
918
+ ...(ngDevMode ? [{ debugName: "disabledReasonText" }] : /* istanbul ignore next */ []));
919
+ this.handleClass = gridRowReorderHandleThemeVariants();
920
+ /**
921
+ * @description The row's position within the current page, used to move the row and derive its accessible label.
922
+ */
923
+ this.pageIndex = input.required(/* @ts-ignore */
924
+ ...(ngDevMode ? [{ debugName: "pageIndex" }] : /* istanbul ignore next */ []));
925
+ /**
926
+ * @description The grid row whose reorder handle this button controls.
927
+ */
928
+ this.row = input.required(/* @ts-ignore */
929
+ ...(ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []));
930
+ }
931
+ #gridService;
932
+ #hostElement;
933
+ #injector;
934
+ #liveAnnouncer;
935
+ onKeydown(event) {
936
+ if ((event.key !== "ArrowUp" && event.key !== "ArrowDown") || !event.altKey) {
937
+ return;
938
+ }
939
+ event.preventDefault();
940
+ event.stopPropagation();
941
+ const direction = event.key === "ArrowUp" ? -1 : 1;
942
+ const targetIndex = this.pageIndex() + direction;
943
+ if (targetIndex < 0 || targetIndex >= this.#gridService.viewPageRows().length) {
944
+ return;
945
+ }
946
+ const moved = this.#gridService.requestRowReorder(this.row(), this.pageIndex(), targetIndex);
947
+ if (moved) {
948
+ // Re-rendering the new order moves this row in the DOM, which drops focus. Keep it so the row can move again.
949
+ afterNextRender({
950
+ write: () => {
951
+ const button = this.#hostElement.querySelector("button");
952
+ if (button != null && this.#hostElement.ownerDocument.activeElement !== button) {
953
+ button.focus();
954
+ }
955
+ }
956
+ }, { injector: this.#injector });
957
+ const skip = this.#gridService.paginationState().skip;
958
+ const fromRowNumber = skip + this.pageIndex() + 1;
959
+ const toPosition = skip + targetIndex + 1;
960
+ this.#liveAnnouncer.announce(this.#gridService.messages().rowReorderMoved(fromRowNumber, toPosition));
961
+ }
962
+ }
963
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridRowReorderHandleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
964
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: GridRowReorderHandleComponent, isStandalone: true, selector: "mona-grid-row-reorder-handle", inputs: { pageIndex: { classPropertyName: "pageIndex", publicName: "pageIndex", isSignal: true, isRequired: true, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "$event.stopPropagation()", "contextmenu": "$event.stopPropagation()", "dblclick": "$event.stopPropagation()" } }, ngImport: i0, template: "<button\n type=\"button\"\n cdkDragHandle\n [class]=\"handleClass\"\n [disabled]=\"disabled()\"\n [attr.title]=\"disabledReasonText()\"\n [attr.aria-label]=\"ariaLabel()\"\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown\"\n (keydown)=\"onKeydown($event)\">\n <svg lucideGripVertical [size]=\"16\" aria-hidden=\"true\"></svg>\n</button>\n", dependencies: [{ kind: "component", type: LucideGripVertical, selector: "svg[lucideGripVertical]" }, { kind: "directive", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }] }); }
965
+ }
966
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridRowReorderHandleComponent, decorators: [{
967
+ type: Component,
968
+ args: [{ selector: "mona-grid-row-reorder-handle", imports: [LucideGripVertical, CdkDragHandle], host: {
969
+ "(click)": "$event.stopPropagation()",
970
+ "(contextmenu)": "$event.stopPropagation()",
971
+ "(dblclick)": "$event.stopPropagation()"
972
+ }, template: "<button\n type=\"button\"\n cdkDragHandle\n [class]=\"handleClass\"\n [disabled]=\"disabled()\"\n [attr.title]=\"disabledReasonText()\"\n [attr.aria-label]=\"ariaLabel()\"\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown\"\n (keydown)=\"onKeydown($event)\">\n <svg lucideGripVertical [size]=\"16\" aria-hidden=\"true\"></svg>\n</button>\n" }]
973
+ }], propDecorators: { pageIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageIndex", required: true }] }], row: [{ type: i0.Input, args: [{ isSignal: true, alias: "row", required: true }] }] } });
974
+
975
+ class GridSelectionCheckboxComponent {
976
+ constructor() {
977
+ this.#gridService = inject(GridService);
978
+ this.ariaLabel = computed(() => {
979
+ const labelFn = this.#gridService.selectableOptions().rowAriaLabel;
980
+ if (labelFn) {
981
+ return labelFn(this.row().data);
982
+ }
983
+ return this.#gridService.messages().selectRow(this.rowIndex() + 1);
984
+ }, /* @ts-ignore */
985
+ ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
986
+ this.checked = computed(() => this.#gridService.isRowSelected(this.row()), /* @ts-ignore */
987
+ ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
988
+ this.hostClass = computed(() => gridSelectionCellThemeVariants({ virtual: this.#gridService.virtualScrollOptions().enabled }), /* @ts-ignore */
989
+ ...(ngDevMode ? [{ debugName: "hostClass" }] : /* istanbul ignore next */ []));
990
+ /**
991
+ * @description The grid row whose selected state this checkbox controls.
992
+ */
993
+ this.row = input.required(/* @ts-ignore */
994
+ ...(ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []));
995
+ /**
996
+ * @description The row's position within its rendered list, used to derive a default accessible label.
997
+ */
998
+ this.rowIndex = input.required(/* @ts-ignore */
999
+ ...(ngDevMode ? [{ debugName: "rowIndex" }] : /* istanbul ignore next */ []));
1000
+ }
1001
+ #gridService;
1002
+ onCheckedChange(checked) {
1003
+ this.#gridService.setRowSelected(this.row(), checked);
1004
+ }
1005
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridSelectionCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1006
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: GridSelectionCheckboxComponent, isStandalone: true, selector: "mona-grid-selection-checkbox", inputs: { row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null }, rowIndex: { classPropertyName: "rowIndex", publicName: "rowIndex", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "$event.stopPropagation()" }, properties: { "class": "hostClass()" } }, ngImport: i0, template: "<mona-check-box\n [checked]=\"checked()\"\n (checkedChange)=\"onCheckedChange($event)\">\n <span class=\"sr-only\">{{ ariaLabel() }}</span>\n</mona-check-box>\n", dependencies: [{ kind: "component", type: CheckBoxComponent, selector: "mona-check-box", inputs: ["aria-describedby", "aria-label", "checked", "disabled", "indeterminate", "invalid", "label", "labelPosition", "labelSize", "required", "rounded", "tabIndex", "touched", "class"], outputs: ["checkedChange", "inputBlur", "inputChange", "inputFocus", "touch"] }] }); }
1007
+ }
1008
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridSelectionCheckboxComponent, decorators: [{
1009
+ type: Component,
1010
+ args: [{ selector: "mona-grid-selection-checkbox", imports: [CheckBoxComponent], host: {
1011
+ "[class]": "hostClass()",
1012
+ "(click)": "$event.stopPropagation()"
1013
+ }, template: "<mona-check-box\n [checked]=\"checked()\"\n (checkedChange)=\"onCheckedChange($event)\">\n <span class=\"sr-only\">{{ ariaLabel() }}</span>\n</mona-check-box>\n" }]
1014
+ }], propDecorators: { row: [{ type: i0.Input, args: [{ isSignal: true, alias: "row", required: true }] }], rowIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowIndex", required: true }] }] } });
1015
+
1016
+ /** A data row of the grid body, with one cell per layout column. */
1017
+ class GridRowComponent {
1018
+ constructor() {
1019
+ /** Rows under groups sit one level below the innermost group (treegrid). */
1020
+ this.ariaLevel = computed(() => {
1021
+ const groupCount = this.gridService.groupColumns().length;
1022
+ return groupCount === 0 ? null : groupCount + 1;
1023
+ }, /* @ts-ignore */
1024
+ ...(ngDevMode ? [{ debugName: "ariaLevel" }] : /* istanbul ignore next */ []));
1025
+ this.baseClass = computed(() => {
1026
+ const variantClass = gridListTableRowThemeVariants({
1027
+ selected: this.selected(),
1028
+ virtual: this.gridService.virtualScrollOptions().enabled
1029
+ });
1030
+ const userClass = this.gridService.rowClass()?.(this.row().data);
1031
+ return twMerge(variantClass, typeof userClass === "string" ? userClass : userClass?.join(" "));
1032
+ }, /* @ts-ignore */
1033
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
1034
+ this.cellEditMode = computed(() => {
1035
+ const options = this.gridService.editableOptions();
1036
+ return options.enabled === true && options.mode === "cell";
1037
+ }, /* @ts-ignore */
1038
+ ...(ngDevMode ? [{ debugName: "cellEditMode" }] : /* istanbul ignore next */ []));
1039
+ this.detailToggleClass = computed(() => this.gridService.virtualScrollOptions().enabled
1040
+ ? "flex h-full w-full items-stretch justify-center"
1041
+ : "flex min-h-9 w-full items-center justify-center", /* @ts-ignore */
1042
+ ...(ngDevMode ? [{ debugName: "detailToggleClass" }] : /* istanbul ignore next */ []));
1043
+ this.detailToggleLabel = computed(() => {
1044
+ const messages = this.gridService.messages();
1045
+ const rowNumber = this.index() + this.gridService.paginationState().skip + 1;
1046
+ return this.expanded() ? messages.collapseDetail(rowNumber) : messages.expandDetail(rowNumber);
1047
+ }, /* @ts-ignore */
1048
+ ...(ngDevMode ? [{ debugName: "detailToggleLabel" }] : /* istanbul ignore next */ []));
1049
+ /** With editing on, data cells say whether their column can be edited, in either edit mode. */
1050
+ this.editingEnabled = computed(() => this.gridService.editableOptions().enabled === true, /* @ts-ignore */
1051
+ ...(ngDevMode ? [{ debugName: "editingEnabled" }] : /* istanbul ignore next */ []));
1052
+ this.gridService = inject(GridService);
1053
+ this.selectable = computed(() => this.gridService.selectableOptions().enabled, /* @ts-ignore */
1054
+ ...(ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []));
1055
+ /** The row's `aria-rowindex`, counted by the body list across every row of the grid. */
1056
+ this.ariaRowIndex = input(null, /* @ts-ignore */
1057
+ ...(ngDevMode ? [{ debugName: "ariaRowIndex" }] : /* istanbul ignore next */ []));
1058
+ this.expanded = computed(() => this.gridService.isRowExpanded(this.row()), /* @ts-ignore */
1059
+ ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
1060
+ /** The index of this row among the rendered body rows. */
1061
+ this.index = input.required(/* @ts-ignore */
1062
+ ...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
1063
+ this.row = input.required(/* @ts-ignore */
1064
+ ...(ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []));
1065
+ this.selected = computed(() => this.gridService.isRowSelected(this.row()), /* @ts-ignore */
1066
+ ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
1067
+ }
1068
+ onClick(event) {
1069
+ this.gridService.handleRowClick(event, this.row());
1070
+ }
1071
+ toggleDetail() {
1072
+ this.gridService.setRowExpanded(this.row(), !this.expanded());
1073
+ }
1074
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1075
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: GridRowComponent, isStandalone: true, selector: "tr[monaGridRow]", inputs: { ariaRowIndex: { classPropertyName: "ariaRowIndex", publicName: "ariaRowIndex", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: true, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "row" }, listeners: { "click": "onClick($event)" }, properties: { "class": "baseClass()", "attr.data-ruid": "row().uid", "attr.data-row-view-index": "index()", "attr.aria-selected": "selectable() ? selected() : null", "attr.aria-rowindex": "ariaRowIndex()", "attr.aria-level": "ariaLevel()" } }, exportAs: ["monaGridRow"], ngImport: i0, template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"layoutColumn.column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"layoutColumn.column.id\"\n [editable]=\"cellEditMode() && layoutColumn.column.kind === 'data' && layoutColumn.column.editable === true\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [readOnly]=\"editingEnabled() && layoutColumn.column.kind === 'data' ? !layoutColumn.column.editable : null\"\n (edit)=\"gridCell.handleLogicalCellEnter()\">\n <mona-grid-cell #gridCell [column]=\"layoutColumn.column\" [row]=\"row()\" />\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n } @else if (layoutColumn.kind === \"reorder\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$rowReorder'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-row-reorder-handle [row]=\"row()\" [pageIndex]=\"index()\" />\n </td>\n } @else if (layoutColumn.kind === \"detail\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'detail'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (toggleExpand)=\"toggleDetail()\">\n <span [class]=\"detailToggleClass()\">\n <mona-grid-toggle\n [expanded]=\"expanded()\"\n [label]=\"detailToggleLabel()\"\n [type]=\"'detail'\"\n [width]=\"gridService.detailColumnWidth\"\n (expandedChange)=\"toggleDetail()\" />\n </span>\n </td>\n } @else if (layoutColumn.kind === \"selection\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$selection'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-selection-checkbox [row]=\"row()\" [rowIndex]=\"index()\" />\n </td>\n }\n}\n", dependencies: [{ kind: "component", type: GridCellComponent, selector: "mona-grid-cell", inputs: ["column", "row"] }, { kind: "directive", type: GridCellDirective, selector: "td[monaGridCell]", inputs: ["groupHeader", "groupIndent", "lastInRow"] }, { kind: "directive", type: GridLockedCellDirective, selector: "td[monaGridLockedCell], th[monaGridLockedCell]", inputs: ["monaGridLockedCell", "lockedCellHeader"] }, { kind: "directive", type: GridLogicalCellDirective, selector: "td[monaGridLogicalCell], th[monaGridLogicalCell]", inputs: ["ariaColIndex", "cellKind", "colIndex", "columnId", "editable", "expanded", "firstInRow", "groupHeader", "groupKey", "lastInRow", "readOnly", "rowIndex", "rowUid", "section"], outputs: ["edit", "menuOpen", "toggleExpand"] }, { kind: "component", type: GridRowReorderHandleComponent, selector: "mona-grid-row-reorder-handle", inputs: ["pageIndex", "row"] }, { kind: "component", type: GridSelectionCheckboxComponent, selector: "mona-grid-selection-checkbox", inputs: ["row", "rowIndex"] }, { kind: "component", type: GridToggleComponent, selector: "mona-grid-toggle", inputs: ["expanded", "label", "type", "width"], outputs: ["expandedChange"] }] }); }
1076
+ }
1077
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: GridRowComponent, decorators: [{
1078
+ type: Component,
1079
+ args: [{ selector: "tr[monaGridRow]", exportAs: "monaGridRow", imports: [
1080
+ GridCellComponent,
1081
+ GridCellDirective,
1082
+ GridLockedCellDirective,
1083
+ GridLogicalCellDirective,
1084
+ GridRowReorderHandleComponent,
1085
+ GridSelectionCheckboxComponent,
1086
+ GridToggleComponent
1087
+ ], host: {
1088
+ "[class]": "baseClass()",
1089
+ "[attr.data-ruid]": "row().uid",
1090
+ "[attr.data-row-view-index]": "index()",
1091
+ role: "row",
1092
+ "[attr.aria-selected]": "selectable() ? selected() : null",
1093
+ "[attr.aria-rowindex]": "ariaRowIndex()",
1094
+ "[attr.aria-level]": "ariaLevel()",
1095
+ "(click)": "onClick($event)"
1096
+ }, template: "@for (layoutColumn of gridService.layout(); track layoutColumn.key) {\n @if (layoutColumn.kind === \"column\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"layoutColumn.column.kind\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [columnId]=\"layoutColumn.column.id\"\n [editable]=\"cellEditMode() && layoutColumn.column.kind === 'data' && layoutColumn.column.editable === true\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n [readOnly]=\"editingEnabled() && layoutColumn.column.kind === 'data' ? !layoutColumn.column.editable : null\"\n (edit)=\"gridCell.handleLogicalCellEnter()\">\n <mona-grid-cell #gridCell [column]=\"layoutColumn.column\" [row]=\"row()\" />\n </td>\n } @else if (layoutColumn.kind === \"group\") {\n <td monaGridCell [monaGridLockedCell]=\"layoutColumn.key\" [lockedCellHeader]=\"true\" [groupIndent]=\"true\"></td>\n } @else if (layoutColumn.kind === \"reorder\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$rowReorder'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-row-reorder-handle [row]=\"row()\" [pageIndex]=\"index()\" />\n </td>\n } @else if (layoutColumn.kind === \"detail\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'detail'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\"\n (toggleExpand)=\"toggleDetail()\">\n <span [class]=\"detailToggleClass()\">\n <mona-grid-toggle\n [expanded]=\"expanded()\"\n [label]=\"detailToggleLabel()\"\n [type]=\"'detail'\"\n [width]=\"gridService.detailColumnWidth\"\n (expandedChange)=\"toggleDetail()\" />\n </span>\n </td>\n } @else if (layoutColumn.kind === \"selection\") {\n <td\n monaGridCell\n [monaGridLockedCell]=\"layoutColumn.key\"\n monaGridLogicalCell\n [cellKind]=\"'command'\"\n [columnId]=\"'$selection'\"\n [colIndex]=\"layoutColumn.logicalIndex\"\n [rowIndex]=\"index()\"\n [rowUid]=\"row().uid\"\n [section]=\"'body'\"\n [firstInRow]=\"layoutColumn.firstInRow\"\n [lastInRow]=\"layoutColumn.lastInRow\">\n <mona-grid-selection-checkbox [row]=\"row()\" [rowIndex]=\"index()\" />\n </td>\n }\n}\n" }]
1097
+ }], propDecorators: { ariaRowIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaRowIndex", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: true }] }], row: [{ type: i0.Input, args: [{ isSignal: true, alias: "row", required: true }] }] } });
1098
+
1099
+ export { GridCellDirective as G, GridAddRowComponent as a, GridGroupRowComponent as b, GridRowComponent as c };
1100
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-row.component-DdUY3I7P.mjs.map