@nanahoshi/mona-ui 0.27.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/popup.md +1 -1
  3. package/docs/api/theme.md +2 -2
  4. package/docs/chart.md +14 -0
  5. package/docs/editor.md +2 -0
  6. package/docs/installation.md +147 -15
  7. package/docs/introduction.md +37 -15
  8. package/docs/theming-built-in-themes.md +67 -0
  9. package/docs/theming-custom-colors.md +274 -0
  10. package/docs/theming-custom-themes.md +168 -0
  11. package/docs/theming.md +164 -248
  12. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  13. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  14. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  15. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  16. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  17. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
  18. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  19. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  20. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  21. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  22. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  23. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  24. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  25. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  26. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  27. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  28. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  29. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  30. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  31. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  32. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  33. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  34. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  35. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  37. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  38. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  39. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  40. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  41. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  42. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  49. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  50. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  51. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  52. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  53. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  54. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  55. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  56. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  57. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  58. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  59. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  60. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  61. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  62. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  63. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  65. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  66. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  67. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  68. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  70. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  71. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  72. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  73. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  74. package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
  75. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  76. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  77. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  78. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  79. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  80. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  81. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  82. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  83. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  84. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  85. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  86. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  87. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  88. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  89. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  90. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  91. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  92. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  93. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  94. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  95. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  96. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  97. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  98. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  99. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  100. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  101. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  102. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  103. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  104. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  105. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  106. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  107. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  108. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  109. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  110. package/llms.txt +6 -2
  111. package/package.json +62 -23
  112. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  113. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  114. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  115. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  116. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  117. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  118. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  119. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  120. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  121. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  122. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  123. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  124. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  125. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  126. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  127. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  128. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  129. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  130. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  131. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  132. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  133. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  134. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  135. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  136. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  137. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  138. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  139. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  140. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  141. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  142. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  143. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  144. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  145. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  146. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  147. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  148. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  149. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  150. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  151. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  152. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  153. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  154. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  155. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  156. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  157. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  158. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  159. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  168. package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
  169. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  170. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  171. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  172. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  173. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  174. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  175. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  176. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  177. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  178. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  179. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  180. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  181. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  182. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  183. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  184. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  185. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  186. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  187. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  188. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  189. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  190. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  191. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  192. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  193. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  194. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  195. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  196. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  197. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  198. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  199. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  200. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  201. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  202. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  203. package/types/nanahoshi-mona-ui.d.ts +1 -2
  204. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  205. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  206. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  207. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  208. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -0,0 +1,3766 @@
1
+ import { PreventableEvent, deepEquals } from "@nanahoshi/mona-ui/common";
2
+ import * as i0 from "@angular/core";
3
+ import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, PLATFORM_ID, afterNextRender, afterRenderEffect, computed, effect, inject, input, isDevMode, output, signal, untracked } from "@angular/core";
4
+ import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
5
+ import { v4 } from "uuid";
6
+ import { DOCUMENT as DOCUMENT$1, isPlatformBrowser } from "@angular/common";
7
+ import { Dictionary, ImmutableDictionary, ImmutableList, ImmutableSet, KeyValuePair, select } from "@mirei/ts-collections";
8
+ import { BehaviorSubject, Subject, fromEvent } from "rxjs";
9
+ import { LiveAnnouncer } from "@angular/cdk/a11y";
10
+ import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
11
+ import { form } from "@angular/forms/signals";
12
+ import { Query, compareValues } from "@nanahoshi/mona-ui/query";
13
+ import { Clipboard } from "@angular/cdk/clipboard";
14
+ import { cva } from "class-variance-authority";
15
+ var CellEditEvent = class extends PreventableEvent {
16
+ #options;
17
+ constructor(options) {
18
+ super("cellEdit");
19
+ this.#options = options;
20
+ }
21
+ get field() {
22
+ return this.#options.field;
23
+ }
24
+ get newValue() {
25
+ return this.#options.newValue;
26
+ }
27
+ get oldValue() {
28
+ return this.#options.oldValue;
29
+ }
30
+ get rowData() {
31
+ return this.#options.rowData;
32
+ }
33
+ get session() {
34
+ return this.#options.session;
35
+ }
36
+ };
37
+ var RowEditEvent = class extends PreventableEvent {
38
+ #options;
39
+ constructor(options) {
40
+ super("rowEdit");
41
+ this.#options = options;
42
+ }
43
+ get rowData() {
44
+ return this.#options.rowData;
45
+ }
46
+ get originalRowData() {
47
+ return this.#options.originalRowData ?? null;
48
+ }
49
+ get session() {
50
+ return this.#options.session;
51
+ }
52
+ };
53
+ var GridAddEvent = class extends PreventableEvent {
54
+ #options;
55
+ constructor(options) {
56
+ super("gridAdd", options.originalEvent);
57
+ this.#options = options;
58
+ }
59
+ get rowData() {
60
+ return this.#options.rowData;
61
+ }
62
+ get session() {
63
+ return this.#options.session;
64
+ }
65
+ };
66
+ var GridCancelEvent = class extends PreventableEvent {
67
+ #options;
68
+ constructor(options) {
69
+ super("gridCancel", options.originalEvent);
70
+ this.#options = options;
71
+ }
72
+ get operation() {
73
+ return this.#options.operation;
74
+ }
75
+ get reason() {
76
+ return this.#options.reason ?? "command";
77
+ }
78
+ get rowData() {
79
+ return this.#options.rowData;
80
+ }
81
+ get session() {
82
+ return this.#options.session;
83
+ }
84
+ };
85
+ var GridEditEvent = class extends PreventableEvent {
86
+ #options;
87
+ constructor(options) {
88
+ super("gridEdit", options.originalEvent);
89
+ this.#options = options;
90
+ }
91
+ get rowData() {
92
+ return this.#options.rowData;
93
+ }
94
+ get session() {
95
+ return this.#options.session;
96
+ }
97
+ };
98
+ var GridRemoveEvent = class extends PreventableEvent {
99
+ #options;
100
+ constructor(options) {
101
+ super("gridRemove", options.originalEvent);
102
+ this.#options = options;
103
+ }
104
+ get index() {
105
+ return this.#options.index ?? -1;
106
+ }
107
+ get key() {
108
+ return this.#options.key ?? this.#options.rowData;
109
+ }
110
+ get rowData() {
111
+ return this.#options.rowData;
112
+ }
113
+ };
114
+ var GridSaveEvent = class extends PreventableEvent {
115
+ #options;
116
+ constructor(options) {
117
+ super("gridSave", options.originalEvent);
118
+ this.#options = options;
119
+ }
120
+ get operation() {
121
+ return this.#options.operation;
122
+ }
123
+ get originalRowData() {
124
+ return this.#options.originalRowData ?? null;
125
+ }
126
+ get rowData() {
127
+ return this.#options.rowData;
128
+ }
129
+ get session() {
130
+ return this.#options.session;
131
+ }
132
+ };
133
+ function localizeNumber(value, options) {
134
+ return formatNumber(value, "en-US", options);
135
+ }
136
+ const GRID_DEFAULT_MESSAGES = {
137
+ all: "(All)",
138
+ apply: "Apply",
139
+ cancel: "Cancel",
140
+ cancelNewRow: "Cancel new row",
141
+ cancelRowEdit: (rowNumber) => `Cancel editing row ${localizeNumber(rowNumber)}`,
142
+ clearFilter: (column) => `Clear filter for ${column}`,
143
+ collapseDetail: (rowNumber) => `Collapse details of row ${localizeNumber(rowNumber)}`,
144
+ columnGrouped: (column) => `Grouped by ${column}`,
145
+ columnMoved: (column, position) => `${column} moved to position ${localizeNumber(position)}`,
146
+ columns: "Columns",
147
+ columnsSelected: (count) => `${localizeNumber(count)} selected columns`,
148
+ commandColumnTitle: "Commands",
149
+ delete: "Delete",
150
+ deleteRowConfirmation: (rowNumber) => `Are you sure you want to delete row ${localizeNumber(rowNumber)}?`,
151
+ deleteRowTitle: "Delete row?",
152
+ details: "Details",
153
+ dragColumnHeaderToGroup: "Drag a column header here to group",
154
+ edit: "Edit",
155
+ editRow: (rowNumber) => `Edit row ${localizeNumber(rowNumber)}`,
156
+ expandDetail: (rowNumber) => `Expand details of row ${localizeNumber(rowNumber)}`,
157
+ fieldValidationError: "Invalid value.",
158
+ filterByColumn: (column) => `Filter by ${column}`,
159
+ filterByColumnFiltered: (column) => `Filter by ${column}, filtered`,
160
+ filterOperator: (column, operator) => `Filter operator for ${column}: ${operator}`,
161
+ filterPlaceholder: "Filter...",
162
+ group: "Group",
163
+ groupOptions: (column) => `Group options for ${column}`,
164
+ loading: "Loading",
165
+ modified: "Modified",
166
+ moveAsNext: "Move as next",
167
+ moveAsPrevious: "Move as previous",
168
+ moveRow: "Move row",
169
+ noData: "No data",
170
+ remove: "Remove",
171
+ removeRow: (rowNumber) => `Remove row ${localizeNumber(rowNumber)}`,
172
+ reorderRow: (rowNumber) => `Reorder row ${localizeNumber(rowNumber)}`,
173
+ resizeColumn: (column) => `Resize ${column}`,
174
+ rowReorder: "Row reorder",
175
+ rowReorderDisabled: "Row reordering is disabled.",
176
+ rowReorderDisabledEditing: "Finish editing to reorder rows.",
177
+ rowReorderDisabledFiltered: "Clear filters to reorder rows.",
178
+ rowReorderDisabledGrouped: "Clear grouping to reorder rows.",
179
+ rowReorderDisabledServerBinding: "Row reordering isn't available with server binding.",
180
+ rowReorderDisabledSingleRow: "At least two rows are needed to reorder.",
181
+ rowReorderDisabledSorted: "Clear sorting to reorder rows.",
182
+ rowReorderDisabledVirtualScroll: "Row reordering isn't available while virtual scrolling is enabled.",
183
+ rowReorderHandleAriaLabel: (rowLabel, keyboardHint, disabledReason) => `${rowLabel}. ${keyboardHint}${disabledReason ? ` ${disabledReason}` : ""}`,
184
+ rowReorderKeyboardHint: "Use Alt plus Up Arrow or Alt plus Down Arrow to move.",
185
+ rowReorderMoved: (fromRowNumber, toPosition) => `Moved row ${localizeNumber(fromRowNumber)} to position ${localizeNumber(toPosition)}.`,
186
+ rowValidationError: "This row has validation errors.",
187
+ save: "Save",
188
+ saveNewRow: "Save new row",
189
+ saveRow: (rowNumber) => `Save row ${localizeNumber(rowNumber)}`,
190
+ selectAllRows: "Select all rows",
191
+ selectRow: (rowNumber) => `Select row ${localizeNumber(rowNumber)}`,
192
+ sortOrder: (position) => `Sort order ${localizeNumber(position)}`,
193
+ toolbar: "Grid toolbar"
194
+ };
195
+ const FALLBACK_PAGE_ROWS = 10;
196
+ var GridNavigationService = class GridNavigationService {
197
+ #cellElementDict = signal(ImmutableDictionary.create(), ...ngDevMode ? [{ debugName: "#cellElementDict" }] : /* istanbul ignore next */ []);
198
+ #document = inject(DOCUMENT$1);
199
+ #injector = inject(Injector);
200
+ #lastFocusedCellKey = signal(null, ...ngDevMode ? [{ debugName: "#lastFocusedCellKey" }] : /* istanbul ignore next */ []);
201
+ #lastFocusedCellSnapshot = signal(null, ...ngDevMode ? [{ debugName: "#lastFocusedCellSnapshot" }] : /* istanbul ignore next */ []);
202
+ #lastNonGroupCellKey = signal(null, ...ngDevMode ? [{ debugName: "#lastNonGroupCellKey" }] : /* istanbul ignore next */ []);
203
+ #cellHasFocus = false;
204
+ #defaultTabStop = false;
205
+ #lostFocus = null;
206
+ #pendingFocus = null;
207
+ #pendingFocusScheduled = false;
208
+ #rowScroller = null;
209
+ #viewport = null;
210
+ focusActiveCellOrFirstHeader() {
211
+ const focusedCell = this.#getFocusedCell();
212
+ if (focusedCell) {
213
+ this.#focusCell(focusedCell.key, focusedCell.value);
214
+ return true;
215
+ }
216
+ const fallback = this.#findFallbackCell(this.#lastFocusedCellSnapshot());
217
+ if (!fallback) return false;
218
+ this.#focusCell(fallback.key, fallback.value);
219
+ return true;
220
+ }
221
+ focusAdjacentEditableCell(rowUid, columnId, direction) {
222
+ const editableCells = this.#cells().where((e) => e.value.section === "body" && e.value.cellKind === "data" && e.value.editable && e.value.rowUid != null && e.value.columnId != null).orderBy((e) => e.value.rowIndex).thenBy((e) => e.value.colIndex).toArray();
223
+ const currentIndex = editableCells.findIndex((e) => e.value.rowUid === rowUid && e.value.columnId === columnId);
224
+ if (currentIndex === -1) return false;
225
+ const target = editableCells[currentIndex + (direction === "next" ? 1 : -1)];
226
+ if (!target) return false;
227
+ this.#focusCell(target.key, target.value);
228
+ target.value.startEdit?.();
229
+ return true;
230
+ }
231
+ focusFirstCell() {
232
+ const firstCell = this.#findFirstHeaderCell() ?? this.#findFirstCell();
233
+ if (firstCell) this.#focusCell(firstCell.key, firstCell.value);
234
+ }
235
+ focusHeaderCell(columnId) {
236
+ const cell = this.#cells().firstOrDefault((e) => e.value.section === "header" && e.value.columnId === columnId);
237
+ if (!cell) return false;
238
+ this.#focusCell(cell.key, cell.value);
239
+ return true;
240
+ }
241
+ getFocusedCell() {
242
+ return this.#getFocusedCell()?.value ?? null;
243
+ }
244
+ isFocused(cellKey) {
245
+ return this.#lastFocusedCellKey() === cellKey;
246
+ }
247
+ navigate(cellKey, navigationKey) {
248
+ this.#pendingFocus = null;
249
+ switch (navigationKey) {
250
+ case "ArrowDown": return this.#navigateVertically("down", cellKey);
251
+ case "ArrowUp": return this.#navigateVertically("up", cellKey);
252
+ case "ArrowLeft": return this.#navigateHorizontally("previous", cellKey);
253
+ case "ArrowRight": return this.#navigateHorizontally("next", cellKey);
254
+ case "Home": return this.#navigateToRowEdge("first", cellKey);
255
+ case "End": return this.#navigateToRowEdge("last", cellKey);
256
+ case "CtrlHome": return this.#navigateToGridEdge("first");
257
+ case "CtrlEnd": return this.#navigateToGridEdge("last");
258
+ case "PageDown": return this.#navigateByPage("down", cellKey);
259
+ case "PageUp": return this.#navigateByPage("up", cellKey);
260
+ default: return false;
261
+ }
262
+ }
263
+ notifyCellBlur() {
264
+ this.#cellHasFocus = false;
265
+ }
266
+ refocusAfterRender() {
267
+ afterNextRender({ write: () => {
268
+ if (this.#focusIsLost(null)) this.focusActiveCellOrFirstHeader();
269
+ } }, { injector: this.#injector });
270
+ }
271
+ registerCell(data) {
272
+ const cellKey = this.#createCellKey(data);
273
+ const currentData = this.#cellElementDict().get(cellKey);
274
+ if (!currentData || !this.#navigationDataEqual(currentData, data)) this.#cellElementDict.update((dict) => dict.put(cellKey, data));
275
+ this.#ensureFocusedCell();
276
+ if (this.#pendingFocus?.rowIndex === data.rowIndex && data.section === "body") this.#schedulePendingFocus();
277
+ if (this.#lostFocus != null && this.#sameIdentity(data, this.#lostFocus.snapshot)) queueMicrotask(() => this.restoreLostFocus());
278
+ return cellKey;
279
+ }
280
+ restoreLostFocus() {
281
+ if (this.#lostFocus == null) {
282
+ const key = this.#lastFocusedCellKey();
283
+ const focused = key == null ? null : this.#cellElementDict().get(key);
284
+ if (focused != null && !focused.element.isConnected && this.#cellHasFocus && this.#focusIsLost(null)) this.#lostFocus = {
285
+ element: focused.element,
286
+ snapshot: this.#createSnapshot(focused)
287
+ };
288
+ return;
289
+ }
290
+ const lostFocus = this.#lostFocus;
291
+ if (!this.#focusIsLost(lostFocus.element)) {
292
+ this.#lostFocus = null;
293
+ return;
294
+ }
295
+ const cell = this.#cells().firstOrDefault((e) => this.#sameIdentity(e.value, lostFocus.snapshot));
296
+ if (cell == null) return;
297
+ this.#lostFocus = null;
298
+ cell.value.element.focus({ preventScroll: true });
299
+ this.#setFocusedCell(cell.key, cell.value);
300
+ }
301
+ setLastFocusedCellKey(key) {
302
+ const data = this.#cellElementDict().get(key);
303
+ if (data) {
304
+ this.#cellHasFocus = true;
305
+ this.#lostFocus = null;
306
+ this.#setFocusedCell(key, data);
307
+ }
308
+ }
309
+ setRowScroller(scroller) {
310
+ this.#rowScroller = scroller;
311
+ this.#pendingFocus = null;
312
+ }
313
+ setViewport(viewport) {
314
+ this.#viewport = viewport;
315
+ }
316
+ unregisterCell(cellKey, element) {
317
+ const data = this.#cellElementDict().get(cellKey);
318
+ if (!data || element != null && data.element !== element) return;
319
+ this.#cellElementDict.update((dict) => dict.remove(cellKey));
320
+ if (this.#lastFocusedCellKey() !== cellKey) return;
321
+ if (this.#cellHasFocus && this.#focusIsLost(data.element)) this.#lostFocus = {
322
+ element: data.element,
323
+ snapshot: this.#createSnapshot(data)
324
+ };
325
+ const fallback = this.#findFallbackCell(this.#createSnapshot(data));
326
+ if (fallback) this.#setFocusedCell(fallback.key, fallback.value);
327
+ else this.#lastFocusedCellKey.set(null);
328
+ }
329
+ #cells() {
330
+ return this.#cellElementDict().where((e) => e.value.element.isConnected);
331
+ }
332
+ #createCellKey(data) {
333
+ if (data.groupHeader) return `group:${data.groupKey ?? v4()}`;
334
+ if (data.section === "header" || data.section === "filter" || data.section === "add" || data.section === "footer") return `${data.section}:${data.columnId ?? data.colIndex}`;
335
+ if (data.rowUid != null || data.columnId != null) return `body:${data.rowUid ?? data.rowIndex}:${data.columnId ?? data.colIndex}`;
336
+ return `${data.section}:${data.rowIndex}:${data.colIndex}`;
337
+ }
338
+ #createSnapshot(data) {
339
+ return {
340
+ cellKind: data.cellKind,
341
+ colIndex: data.colIndex,
342
+ columnId: data.columnId,
343
+ groupHeader: data.groupHeader,
344
+ groupKey: data.groupKey,
345
+ rowIndex: data.rowIndex,
346
+ rowUid: data.rowUid,
347
+ section: data.section
348
+ };
349
+ }
350
+ #ensureFocusedCell() {
351
+ const current = this.#getFocusedCell();
352
+ if (current && !this.#defaultTabStop) return;
353
+ const snapshot = current ? null : this.#lastFocusedCellSnapshot();
354
+ const fallback = this.#findFallbackCell(snapshot);
355
+ if (fallback && fallback.key !== current?.key) {
356
+ this.#setFocusedCell(fallback.key, fallback.value);
357
+ this.#defaultTabStop = snapshot == null;
358
+ }
359
+ }
360
+ #findCellsInRow(rowIndex, section) {
361
+ return this.#cells().where((e) => e.value.section === section && e.value.rowIndex === rowIndex).orderBy((e) => e.value.colIndex).toArray();
362
+ }
363
+ #findFallbackCell(snapshot) {
364
+ const dict = this.#cells();
365
+ if (dict.none()) return null;
366
+ if (snapshot) {
367
+ const sameIdentity = dict.firstOrDefault((e) => this.#sameIdentity(e.value, snapshot));
368
+ if (sameIdentity) return sameIdentity;
369
+ const sameColumn = dict.where((e) => e.value.section === snapshot.section && e.value.columnId === snapshot.columnId).orderBy((e) => Math.abs(e.value.rowIndex - snapshot.rowIndex)).thenBy((e) => e.value.colIndex).firstOrDefault();
370
+ if (sameColumn) return sameColumn;
371
+ const sameSection = dict.where((e) => e.value.section === snapshot.section).orderBy((e) => Math.abs(e.value.rowIndex - snapshot.rowIndex)).thenBy((e) => Math.abs(e.value.colIndex - snapshot.colIndex)).firstOrDefault();
372
+ if (sameSection) return sameSection;
373
+ }
374
+ return this.#findFirstBodyCell() ?? this.#findFirstHeaderCell() ?? this.#findFirstCell();
375
+ }
376
+ #findFirstBodyCell() {
377
+ return this.#cells().where((d) => d.value.section === "body").orderBy((d) => d.value.rowIndex).thenBy((d) => d.value.colIndex).firstOrDefault();
378
+ }
379
+ #findFirstCell() {
380
+ return this.#cells().orderBy((d) => this.#sectionOrder(d.value.section)).thenBy((d) => d.value.rowIndex).thenBy((d) => d.value.colIndex).firstOrDefault();
381
+ }
382
+ #findFirstHeaderCell() {
383
+ return this.#cells().where((d) => d.value.section === "header").orderBy((d) => d.value.colIndex).firstOrDefault();
384
+ }
385
+ #findNextRow(section, rowIndex, direction) {
386
+ const current = [this.#sectionOrder(section), rowIndex];
387
+ const isAfter = (order, index) => order > current[0] || order === current[0] && index > current[1];
388
+ const isBefore = (order, index) => order < current[0] || order === current[0] && index < current[1];
389
+ let best = null;
390
+ for (const entry of this.#cells()) {
391
+ const order = this.#sectionOrder(entry.value.section);
392
+ const index = entry.value.rowIndex;
393
+ if (direction === "down" ? !isAfter(order, index) : !isBefore(order, index)) continue;
394
+ if (best == null || (direction === "down" ? order < best.order || order === best.order && index < best.rowIndex : order > best.order || order === best.order && index > best.rowIndex)) best = {
395
+ order,
396
+ rowIndex: index,
397
+ section: entry.value.section
398
+ };
399
+ }
400
+ return best == null ? null : {
401
+ rowIndex: best.rowIndex,
402
+ section: best.section
403
+ };
404
+ }
405
+ #focusCell(key, data) {
406
+ this.#focusElement(data.element);
407
+ this.#setFocusedCell(key, data);
408
+ }
409
+ #focusElement(element) {
410
+ element.focus({ preventScroll: true });
411
+ element.scrollIntoView({
412
+ block: "nearest",
413
+ inline: "nearest"
414
+ });
415
+ this.#revealFromPinnedColumns(element);
416
+ }
417
+ #focusIsLost(previousElement) {
418
+ const activeElement = this.#document.activeElement;
419
+ return activeElement == null || activeElement === this.#document.body || !activeElement.isConnected || activeElement === previousElement;
420
+ }
421
+ #focusRow(rowIndex, colIndex) {
422
+ const rowCells = this.#findCellsInRow(rowIndex, "body");
423
+ if (rowCells.length !== 0) {
424
+ const target = this.#pickCellInRow(rowCells, colIndex);
425
+ this.#focusCell(target.key, target.value);
426
+ if (!target.value.groupHeader) this.#lastNonGroupCellKey.set(target.key);
427
+ return true;
428
+ }
429
+ if (this.#rowScroller == null) return false;
430
+ this.#pendingFocus = {
431
+ colIndex,
432
+ rowIndex
433
+ };
434
+ this.#rowScroller.scrollToRow(rowIndex);
435
+ return true;
436
+ }
437
+ #getFocusedCell() {
438
+ const key = this.#lastFocusedCellKey();
439
+ if (!key) return null;
440
+ const data = this.#cellElementDict().get(key);
441
+ return data && data.element.isConnected ? {
442
+ key,
443
+ value: data
444
+ } : null;
445
+ }
446
+ #getTargetColumn() {
447
+ const lastNonGroupCellKey = this.#lastNonGroupCellKey();
448
+ return (lastNonGroupCellKey ? this.#cellElementDict().get(lastNonGroupCellKey) : null)?.colIndex ?? 0;
449
+ }
450
+ #navigateByPage(direction, cellKey) {
451
+ const data = this.#cellElementDict().get(cellKey);
452
+ if (!data || data.section !== "body") return false;
453
+ if (!data.groupHeader) this.#lastNonGroupCellKey.set(cellKey);
454
+ const step = this.#pageRows(data.element) * (direction === "down" ? 1 : -1);
455
+ const rowCount = this.#rowScroller?.rowCount() ?? 0;
456
+ const target = this.#rowScroller ? this.#navigableRowNear(Math.min(Math.max(data.rowIndex + step, 0), rowCount - 1), direction === "down" ? "up" : "down") : this.#registeredRowNear(data.rowIndex + step, direction);
457
+ if (target == null || target === data.rowIndex) return false;
458
+ return this.#focusRow(target, this.#getTargetColumn());
459
+ }
460
+ #navigateHorizontally(direction, cellKey) {
461
+ const data = this.#cellElementDict().get(cellKey);
462
+ if (!data || data.groupHeader) return false;
463
+ if (direction === "previous" ? data.firstInRow : data.lastInRow) return false;
464
+ const rowCells = this.#findCellsInRow(data.rowIndex, data.section);
465
+ const target = direction === "previous" ? rowCells.filter((cell) => cell.value.colIndex < data.colIndex).at(-1) : rowCells.find((cell) => cell.value.colIndex > data.colIndex);
466
+ if (!target) return false;
467
+ this.#focusCell(target.key, target.value);
468
+ return true;
469
+ }
470
+ #navigateToGridEdge(edge) {
471
+ if (edge === "last" && this.#rowScroller != null) {
472
+ const lastRow = this.#navigableRowNear(this.#rowScroller.rowCount() - 1, "up");
473
+ if (lastRow != null) return this.#focusRow(lastRow, "last");
474
+ }
475
+ const sorted = this.#cells().orderBy((d) => this.#sectionOrder(d.value.section)).thenBy((d) => d.value.rowIndex).thenBy((d) => d.value.colIndex);
476
+ const target = edge === "first" ? sorted.firstOrDefault() : sorted.lastOrDefault();
477
+ if (!target) return false;
478
+ this.#focusCell(target.key, target.value);
479
+ if (!target.value.groupHeader) this.#lastNonGroupCellKey.set(target.key);
480
+ return true;
481
+ }
482
+ #navigateToRowEdge(edge, cellKey) {
483
+ const data = this.#cellElementDict().get(cellKey);
484
+ if (!data || data.groupHeader) return false;
485
+ const rowCells = this.#findCellsInRow(data.rowIndex, data.section);
486
+ if (rowCells.length === 0) return false;
487
+ const target = edge === "first" ? rowCells[0] : rowCells[rowCells.length - 1];
488
+ if (target.key === cellKey) return false;
489
+ this.#focusCell(target.key, target.value);
490
+ if (!target.value.groupHeader) this.#lastNonGroupCellKey.set(target.key);
491
+ return true;
492
+ }
493
+ #navigateVertically(direction, cellKey) {
494
+ const data = this.#cellElementDict().get(cellKey);
495
+ if (!data) return false;
496
+ if (!data.groupHeader) this.#lastNonGroupCellKey.set(cellKey);
497
+ const targetColIndex = this.#getTargetColumn();
498
+ if (data.section === "body" && this.#rowScroller != null) {
499
+ const step = direction === "down" ? 1 : -1;
500
+ const nextRow = this.#navigableRowNear(data.rowIndex + step, direction);
501
+ if (nextRow != null) return this.#focusRow(nextRow, targetColIndex);
502
+ if (direction === "down") return false;
503
+ }
504
+ const nextRow = this.#findNextRow(data.section, data.rowIndex, direction);
505
+ if (nextRow == null) return false;
506
+ if (nextRow.section === "body") return this.#focusRow(nextRow.rowIndex, targetColIndex);
507
+ const targetRowCells = this.#findCellsInRow(nextRow.rowIndex, nextRow.section);
508
+ const targetCell = this.#pickCellInRow(targetRowCells, targetColIndex);
509
+ this.#focusCell(targetCell.key, targetCell.value);
510
+ return true;
511
+ }
512
+ #navigableRowNear(rowIndex, direction) {
513
+ const scroller = this.#rowScroller;
514
+ if (scroller == null) return null;
515
+ const rowCount = scroller.rowCount();
516
+ const step = direction === "down" ? 1 : -1;
517
+ for (let index = rowIndex; index >= 0 && index < rowCount; index += step) if (scroller.isNavigableRow(index)) return index;
518
+ return null;
519
+ }
520
+ #navigationDataEqual(left, right) {
521
+ return left.cellKind === right.cellKind && left.colIndex === right.colIndex && left.columnId === right.columnId && left.editable === right.editable && left.element === right.element && left.firstInRow === right.firstInRow && left.groupHeader === right.groupHeader && left.groupKey === right.groupKey && left.lastInRow === right.lastInRow && left.rowIndex === right.rowIndex && left.rowUid === right.rowUid && left.section === right.section && left.startEdit === right.startEdit;
522
+ }
523
+ #pageRows(element) {
524
+ const scrollElement = this.#viewport?.scrollElement() ?? null;
525
+ const rowHeight = element.closest("tr")?.getBoundingClientRect().height ?? 0;
526
+ if (scrollElement == null || rowHeight <= 0 || scrollElement.clientHeight <= 0) return FALLBACK_PAGE_ROWS;
527
+ return Math.max(1, Math.floor(scrollElement.clientHeight / rowHeight));
528
+ }
529
+ #pickCellInRow(rowCells, colIndex) {
530
+ if (colIndex === "last" || rowCells[0].value.groupHeader) return colIndex === "last" ? rowCells[rowCells.length - 1] : rowCells[0];
531
+ return rowCells.find((e) => e.value.colIndex === colIndex) ?? rowCells.find((e) => e.value.colIndex >= colIndex) ?? rowCells[rowCells.length - 1];
532
+ }
533
+ #registeredRowNear(rowIndex, direction) {
534
+ const rows = this.#cells().where((e) => e.value.section === "body").select((e) => e.value.rowIndex).distinct().orderBy((index) => index).toArray();
535
+ if (rows.length === 0) return null;
536
+ if (direction === "down") return rows.filter((index) => index <= rowIndex).at(-1) ?? rows[0];
537
+ return rows.find((index) => index >= rowIndex) ?? rows[rows.length - 1];
538
+ }
539
+ #revealFromPinnedColumns(element) {
540
+ const viewport = this.#viewport;
541
+ const scrollElement = viewport?.scrollElement() ?? null;
542
+ if (viewport == null || scrollElement == null || element.style.position === "sticky") return;
543
+ const inset = viewport.stickyInset();
544
+ if (inset.start === 0 && inset.end === 0) return;
545
+ const cell = element.getBoundingClientRect();
546
+ const left = scrollElement.getBoundingClientRect().left + scrollElement.clientLeft;
547
+ const right = left + scrollElement.clientWidth;
548
+ const [visibleLeft, visibleRight] = this.#document.defaultView?.getComputedStyle(scrollElement).direction === "rtl" ? [left + inset.end, right - inset.start] : [left + inset.start, right - inset.end];
549
+ let delta = 0;
550
+ if (cell.left < visibleLeft) delta = cell.left - visibleLeft;
551
+ else if (cell.right > visibleRight) delta = Math.min(cell.right - visibleRight, cell.left - visibleLeft);
552
+ if (delta !== 0) scrollElement.scrollBy({ left: delta });
553
+ }
554
+ #sameIdentity(data, snapshot) {
555
+ return data.section === snapshot.section && data.columnId === snapshot.columnId && data.rowUid === snapshot.rowUid && data.groupKey === snapshot.groupKey;
556
+ }
557
+ #schedulePendingFocus() {
558
+ if (this.#pendingFocusScheduled) return;
559
+ this.#pendingFocusScheduled = true;
560
+ queueMicrotask(() => {
561
+ this.#pendingFocusScheduled = false;
562
+ const pending = this.#pendingFocus;
563
+ if (pending == null) return;
564
+ const rowCells = this.#findCellsInRow(pending.rowIndex, "body");
565
+ if (rowCells.length === 0) return;
566
+ this.#pendingFocus = null;
567
+ const target = this.#pickCellInRow(rowCells, pending.colIndex);
568
+ this.#focusCell(target.key, target.value);
569
+ if (!target.value.groupHeader) this.#lastNonGroupCellKey.set(target.key);
570
+ });
571
+ }
572
+ #sectionOrder(section) {
573
+ switch (section) {
574
+ case "header": return 0;
575
+ case "filter": return 1;
576
+ case "add": return 2;
577
+ case "body": return 3;
578
+ case "footer": return 4;
579
+ }
580
+ }
581
+ #setFocusedCell(key, data) {
582
+ this.#defaultTabStop = false;
583
+ this.#lastFocusedCellKey.set(key);
584
+ this.#lastFocusedCellSnapshot.set(this.#createSnapshot(data));
585
+ }
586
+ static {
587
+ this.ɵfac = i0.ɵɵngDeclareFactory({
588
+ minVersion: "12.0.0",
589
+ version: "22.2.6",
590
+ ngImport: i0,
591
+ type: GridNavigationService,
592
+ deps: [],
593
+ target: i0.ɵɵFactoryTarget.Injectable
594
+ });
595
+ }
596
+ static {
597
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
598
+ minVersion: "12.0.0",
599
+ version: "22.2.6",
600
+ ngImport: i0,
601
+ type: GridNavigationService
602
+ });
603
+ }
604
+ };
605
+ i0.ɵɵngDeclareClassMetadata({
606
+ minVersion: "12.0.0",
607
+ version: "22.2.6",
608
+ ngImport: i0,
609
+ type: GridNavigationService,
610
+ decorators: [{ type: Injectable }]
611
+ });
612
+ var ColumnReorderEvent = class extends PreventableEvent {
613
+ #column;
614
+ #newIndex;
615
+ #oldIndex;
616
+ constructor(column, oldIndex, newIndex) {
617
+ super("columnReorder");
618
+ this.#column = column;
619
+ this.#oldIndex = oldIndex;
620
+ this.#newIndex = newIndex;
621
+ }
622
+ get column() {
623
+ return this.#column;
624
+ }
625
+ get newIndex() {
626
+ return this.#newIndex;
627
+ }
628
+ get oldIndex() {
629
+ return this.#oldIndex;
630
+ }
631
+ };
632
+ var Row = class {
633
+ constructor(data, uid = v4()) {
634
+ this.data = data;
635
+ this.uid = uid;
636
+ }
637
+ };
638
+ var RowReorderEvent = class extends PreventableEvent {
639
+ #options;
640
+ constructor(options) {
641
+ super("rowReorder");
642
+ this.#options = options;
643
+ }
644
+ get currentIndex() {
645
+ return this.#options.currentIndex;
646
+ }
647
+ get currentPageIndex() {
648
+ return this.#options.currentPageIndex;
649
+ }
650
+ get previousIndex() {
651
+ return this.#options.previousIndex;
652
+ }
653
+ get previousPageIndex() {
654
+ return this.#options.previousPageIndex;
655
+ }
656
+ get reorderedData() {
657
+ return this.#options.reorderedData;
658
+ }
659
+ get rowData() {
660
+ return this.#options.rowData;
661
+ }
662
+ };
663
+ const FILTER_OPERATORS = /* @__PURE__ */ new Set([
664
+ "between",
665
+ "contains",
666
+ "doesnotcontain",
667
+ "endswith",
668
+ "eq",
669
+ "function",
670
+ "gt",
671
+ "gte",
672
+ "in",
673
+ "isempty",
674
+ "isfalse",
675
+ "isnotempty",
676
+ "isnotnull",
677
+ "isnotnullorempty",
678
+ "isnull",
679
+ "isnullorempty",
680
+ "istrue",
681
+ "lt",
682
+ "lte",
683
+ "neq",
684
+ "notbetween",
685
+ "notin",
686
+ "startswith"
687
+ ]);
688
+ function isKnownFilterOperator(operator) {
689
+ return typeof operator === "string" && FILTER_OPERATORS.has(operator);
690
+ }
691
+ function isValidFilterDescriptor(value) {
692
+ if (value == null || typeof value !== "object") return false;
693
+ const descriptor = value;
694
+ if (typeof descriptor.field !== "string" || descriptor.field === "") return false;
695
+ if (!isKnownFilterOperator(descriptor.operator)) return false;
696
+ return descriptor.operator !== "function" || typeof descriptor.predicate === "function";
697
+ }
698
+ function sanitizeCompositeFilter(value) {
699
+ if (value == null || typeof value !== "object") return null;
700
+ const composite = value;
701
+ if (!Array.isArray(composite.filters)) return null;
702
+ const filters = [];
703
+ for (const child of composite.filters) {
704
+ if (isValidFilterDescriptor(child)) {
705
+ filters.push(child);
706
+ continue;
707
+ }
708
+ const nested = sanitizeCompositeFilter(child);
709
+ if (nested != null) filters.push(nested);
710
+ }
711
+ if (filters.length === 0) return null;
712
+ return {
713
+ logic: composite.logic === "or" ? "or" : "and",
714
+ filters
715
+ };
716
+ }
717
+ function partitionFilters(filters) {
718
+ const partsByField = /* @__PURE__ */ new Map();
719
+ const external = [];
720
+ for (const value of filters ?? []) {
721
+ const composite = sanitizeCompositeFilter(value);
722
+ if (composite != null) collectFieldParts(composite, partsByField, external);
723
+ }
724
+ const byField = /* @__PURE__ */ new Map();
725
+ for (const [field, parts] of partsByField) byField.set(field, parts.length === 1 ? parts[0] : combineWithAnd(parts));
726
+ return {
727
+ byField,
728
+ external
729
+ };
730
+ }
731
+ function toFilterMenuValue(filter) {
732
+ const [first, second, ...rest] = filter.filters;
733
+ if (rest.length > 0 || first == null || !isLeaf(first) || second != null && !isLeaf(second)) return;
734
+ return {
735
+ logic: filter.logic,
736
+ operator1: first.operator,
737
+ operator2: second?.operator,
738
+ value1: "value" in first ? first.value : void 0,
739
+ value2: second != null && "value" in second ? second.value : void 0
740
+ };
741
+ }
742
+ function collectFieldParts(composite, partsByField, external) {
743
+ const fields = collectFields(composite, /* @__PURE__ */ new Set());
744
+ if (fields.size === 1) {
745
+ addPart(partsByField, [...fields][0], composite);
746
+ return;
747
+ }
748
+ if (composite.logic !== "and") {
749
+ external.push(composite);
750
+ return;
751
+ }
752
+ const leavesByField = /* @__PURE__ */ new Map();
753
+ for (const child of composite.filters) if (isLeaf(child)) {
754
+ const leaves = leavesByField.get(child.field) ?? [];
755
+ leaves.push(child);
756
+ leavesByField.set(child.field, leaves);
757
+ } else collectFieldParts(child, partsByField, external);
758
+ for (const [field, leaves] of leavesByField) addPart(partsByField, field, {
759
+ logic: "and",
760
+ filters: leaves
761
+ });
762
+ }
763
+ function addPart(partsByField, field, part) {
764
+ const parts = partsByField.get(field) ?? [];
765
+ parts.push(part);
766
+ partsByField.set(field, parts);
767
+ }
768
+ function collectFields(composite, fields) {
769
+ for (const child of composite.filters) if (isLeaf(child)) fields.add(child.field);
770
+ else collectFields(child, fields);
771
+ return fields;
772
+ }
773
+ function combineWithAnd(parts) {
774
+ return {
775
+ logic: "and",
776
+ filters: parts.flatMap((part) => part.logic === "and" ? part.filters : [part])
777
+ };
778
+ }
779
+ function isLeaf(filter) {
780
+ return !("filters" in filter);
781
+ }
782
+ const objectIds = /* @__PURE__ */ new WeakMap();
783
+ const symbolIds = /* @__PURE__ */ new Map();
784
+ let nextReferenceId = 0;
785
+ function escapeGroupKeyPart(text) {
786
+ return text.replace(/[%/:]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
787
+ }
788
+ function getGroupValueToken(value) {
789
+ if (value == null || value === "") return "e:";
790
+ switch (typeof value) {
791
+ case "string": return `s:${escapeGroupKeyPart(value)}`;
792
+ case "number": return Number.isNaN(value) ? "e:" : `n:${String(value)}`;
793
+ case "bigint": return `n:${value.toString()}`;
794
+ case "boolean": return `b:${String(value)}`;
795
+ case "symbol": return `y:${getSymbolId(value)}`;
796
+ default:
797
+ if (value instanceof Date) {
798
+ const time = value.getTime();
799
+ return Number.isNaN(time) ? "e:" : `d:${time}`;
800
+ }
801
+ return `o:${getObjectId(value)}`;
802
+ }
803
+ }
804
+ function buildGroupKey(parentKey, field, value) {
805
+ const segment = `${escapeGroupKeyPart(field)}:${getGroupValueToken(value)}`;
806
+ return parentKey != null ? `${parentKey}/${segment}` : segment;
807
+ }
808
+ function groupKeyHasField(groupKey, field) {
809
+ const prefix = `${escapeGroupKeyPart(field)}:`;
810
+ return groupKey.split("/").some((segment) => segment.startsWith(prefix));
811
+ }
812
+ function groupRowsByField(rows, field) {
813
+ const groups = /* @__PURE__ */ new Map();
814
+ for (const row of rows) {
815
+ const value = row.data[field];
816
+ const token = getGroupValueToken(value);
817
+ const group = groups.get(token);
818
+ if (group == null) groups.set(token, {
819
+ rows: [row],
820
+ token,
821
+ value
822
+ });
823
+ else group.rows.push(row);
824
+ }
825
+ return [...groups.values()];
826
+ }
827
+ function getObjectId(value) {
828
+ let id = objectIds.get(value);
829
+ if (id == null) {
830
+ id = ++nextReferenceId;
831
+ objectIds.set(value, id);
832
+ }
833
+ return id;
834
+ }
835
+ function getSymbolId(value) {
836
+ let id = symbolIds.get(value);
837
+ if (id == null) {
838
+ id = ++nextReferenceId;
839
+ symbolIds.set(value, id);
840
+ }
841
+ return id;
842
+ }
843
+ var GridRowFlattenerService = class GridRowFlattenerService {
844
+ buildGroupKey(parentKey, field, value) {
845
+ return buildGroupKey(parentKey, field, value);
846
+ }
847
+ flatten(rows, groupColumns, collapsedKeys, showFooter, groupAggregates = new Dictionary(), orderGroups = true, options = {}) {
848
+ const columnArray = [...groupColumns];
849
+ if (columnArray.length === 0) return [];
850
+ const result = [];
851
+ this.#flattenRecursive([...rows], columnArray, groupAggregates, 0, null, collapsedKeys, showFooter, orderGroups ? options : null, result);
852
+ return result;
853
+ }
854
+ toDataRows(rows) {
855
+ return Array.from(rows, (row) => this.#createDataRow(row, 0, null));
856
+ }
857
+ #createDataRow(row, depth, groupKey) {
858
+ return {
859
+ depth,
860
+ groupKey,
861
+ key: `row:${row.uid}`,
862
+ row,
863
+ type: "data"
864
+ };
865
+ }
866
+ #flattenRecursive(rows, groupColumns, groupAggregates, depth, parentKey, collapsedKeys, showFooter, groupOrder, result) {
867
+ const column = groupColumns[depth];
868
+ if (column == null) return;
869
+ const field = column.field;
870
+ const entries = groupRowsByField(rows, field).map((group, index) => ({
871
+ ...group,
872
+ index
873
+ }));
874
+ const direction = column.groupSortDirection;
875
+ if (groupOrder != null && direction != null) entries.sort((left, right) => {
876
+ const comparison = compareValues(left.value, right.value, groupOrder);
877
+ return (direction === "asc" ? comparison : -comparison) || left.index - right.index;
878
+ });
879
+ for (const { rows: groupRows, value: groupValue } of entries) {
880
+ const groupKey = buildGroupKey(parentKey, field, groupValue);
881
+ const groupRow = {
882
+ count: groupRows.length,
883
+ depth,
884
+ field,
885
+ groupKey,
886
+ groupValue,
887
+ key: `group:${groupKey}`,
888
+ title: column.title,
889
+ type: "group"
890
+ };
891
+ result.push(groupRow);
892
+ const isCollapsed = collapsedKeys.has(groupKey);
893
+ if (!isCollapsed) {
894
+ if (depth < groupColumns.length - 1) this.#flattenRecursive(groupRows, groupColumns, groupAggregates, depth + 1, groupKey, collapsedKeys, showFooter, groupOrder, result);
895
+ else for (const row of groupRows) result.push(this.#createDataRow(row, depth, groupKey));
896
+ }
897
+ const groupAggregate = groupAggregates.get(groupKey);
898
+ if (groupAggregate != null && (!isCollapsed || showFooter)) {
899
+ const groupFooterRow = {
900
+ depth,
901
+ groupAggregate,
902
+ key: `groupFooter:${groupKey}`,
903
+ type: "groupFooter"
904
+ };
905
+ result.push(groupFooterRow);
906
+ }
907
+ }
908
+ }
909
+ static {
910
+ this.ɵfac = i0.ɵɵngDeclareFactory({
911
+ minVersion: "12.0.0",
912
+ version: "22.2.6",
913
+ ngImport: i0,
914
+ type: GridRowFlattenerService,
915
+ deps: [],
916
+ target: i0.ɵɵFactoryTarget.Injectable
917
+ });
918
+ }
919
+ static {
920
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
921
+ minVersion: "12.0.0",
922
+ version: "22.2.6",
923
+ ngImport: i0,
924
+ type: GridRowFlattenerService,
925
+ providedIn: "root"
926
+ });
927
+ }
928
+ };
929
+ i0.ɵɵngDeclareClassMetadata({
930
+ minVersion: "12.0.0",
931
+ version: "22.2.6",
932
+ ngImport: i0,
933
+ type: GridRowFlattenerService,
934
+ decorators: [{
935
+ type: Injectable,
936
+ args: [{ providedIn: "root" }]
937
+ }]
938
+ });
939
+ function isWellFormedGridState(state) {
940
+ if (!isRecord(state)) return false;
941
+ const { columns, filter, group, pageSize, sort } = state;
942
+ if (!Array.isArray(columns) || !Array.isArray(filter) || !Array.isArray(group) || !Array.isArray(sort)) return false;
943
+ if (pageSize !== void 0 && !(Number.isSafeInteger(pageSize) && pageSize > 0)) return false;
944
+ const columnIds = /* @__PURE__ */ new Set();
945
+ for (const column of columns) {
946
+ if (!isRecord(column) || typeof column["id"] !== "string" || column["id"] === "" || columnIds.has(column["id"])) return false;
947
+ columnIds.add(column["id"]);
948
+ const width = column["width"];
949
+ if (!Number.isFinite(column["order"]) || typeof column["hidden"] !== "boolean" || !(width == null || typeof width === "number" && Number.isFinite(width) && width >= 0)) return false;
950
+ }
951
+ const isSort = (value, dirRequired) => isRecord(value) && typeof value["field"] === "string" && value["field"] !== "" && (value["dir"] === "asc" || value["dir"] === "desc" || !dirRequired && value["dir"] == null);
952
+ return sort.every((item) => isSort(item, true)) && group.every((item) => isSort(item, false)) && filter.every(isStateCompositeFilter);
953
+ }
954
+ function isRecord(value) {
955
+ return value != null && typeof value === "object" && !Array.isArray(value);
956
+ }
957
+ function isStateCompositeFilter(value) {
958
+ if (!isRecord(value) || value["logic"] !== "and" && value["logic"] !== "or" || !Array.isArray(value["filters"])) return false;
959
+ return value["filters"].every((child) => {
960
+ if (isRecord(child) && "filters" in child) return isStateCompositeFilter(child);
961
+ return isRecord(child) && typeof child["field"] === "string" && child["field"] !== "" && child["operator"] !== "function" && isKnownFilterOperator(child["operator"]);
962
+ });
963
+ }
964
+ const GRID_STATE_VERSION = 1;
965
+ const TEXT_MEASURE_CACHE_LIMIT = 1e3;
966
+ const AGGREGATE_COLUMN_KEYS = [
967
+ "aggregate",
968
+ "field",
969
+ "id"
970
+ ];
971
+ const GROUP_COLUMN_KEYS = [
972
+ "dataType",
973
+ "field",
974
+ "groupFooterTemplate",
975
+ "groupSortDirection",
976
+ "id",
977
+ "title"
978
+ ];
979
+ function sameCellValue(left, right) {
980
+ if (left instanceof Date && right instanceof Date) return left.getTime() === right.getTime() || Number.isNaN(left.getTime()) && Number.isNaN(right.getTime());
981
+ return Object.is(left, right);
982
+ }
983
+ function hasChangedFields(original, edited) {
984
+ const keys = /* @__PURE__ */ new Set([...Reflect.ownKeys(original), ...Reflect.ownKeys(edited)]);
985
+ for (const key of keys) if (!sameCellValue(original[key], edited[key])) return true;
986
+ return false;
987
+ }
988
+ function sameColumns(left, right, keys) {
989
+ if (left.length !== right.length) return false;
990
+ const leftColumns = left.toArray();
991
+ const rightColumns = right.toArray();
992
+ return leftColumns.every((column, index) => column === rightColumns[index] || keys.every((key) => column[key] === rightColumns[index][key]));
993
+ }
994
+ function isAggregateComparable(value) {
995
+ switch (typeof value) {
996
+ case "bigint":
997
+ case "boolean":
998
+ case "string": return true;
999
+ case "number": return !Number.isNaN(value);
1000
+ default: return value instanceof Date && !Number.isNaN(value.getTime());
1001
+ }
1002
+ }
1003
+ function toAggregateNumber(value) {
1004
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
1005
+ if (typeof value === "string" && value.trim() !== "") {
1006
+ const parsed = Number(value);
1007
+ return Number.isFinite(parsed) ? parsed : null;
1008
+ }
1009
+ return null;
1010
+ }
1011
+ var GridService = class GridService {
1012
+ #anchorRowKey;
1013
+ #bulkSelectionRowKeys;
1014
+ #bulkSelectionSelectedCount;
1015
+ #document;
1016
+ #editContext;
1017
+ #editSession;
1018
+ #externalFilters;
1019
+ #filterableOptions;
1020
+ #groupColumnIds;
1021
+ #horizontalScrollLeft;
1022
+ #i18n;
1023
+ #injector;
1024
+ #liveAnnouncer;
1025
+ #platformId;
1026
+ #reorderableOptions;
1027
+ #resizableOptions;
1028
+ #rowFlattener;
1029
+ #rowReorderableOptions;
1030
+ #rowUidByData;
1031
+ #rowUidByKeyObject;
1032
+ #scrollbarGutterMeasurementSource;
1033
+ #scrollbarGutterWidth;
1034
+ #seededFields;
1035
+ #serverBindingEnabled;
1036
+ #serverLoading;
1037
+ #serverTotal;
1038
+ #sortDescriptors;
1039
+ #textMeasureCache;
1040
+ #viewRowIndexByUid;
1041
+ #dataStateEmissionPending;
1042
+ #groupRequest;
1043
+ #loadedSelectedKeys;
1044
+ constructor() {
1045
+ this.#anchorRowKey = signal(null, ...ngDevMode ? [{ debugName: "#anchorRowKey" }] : /* istanbul ignore next */ []);
1046
+ this.#bulkSelectionRowKeys = computed(() => {
1047
+ const keys = /* @__PURE__ */ new Set();
1048
+ for (const row of this.bulkSelectionRows()) keys.add(this.getRowSelectionKey(row));
1049
+ return keys;
1050
+ }, ...ngDevMode ? [{ debugName: "#bulkSelectionRowKeys" }] : /* istanbul ignore next */ []);
1051
+ this.#bulkSelectionSelectedCount = computed(() => {
1052
+ const scopeKeys = this.#bulkSelectionRowKeys();
1053
+ if (scopeKeys.size === 0) return 0;
1054
+ let count = 0;
1055
+ for (const key of this.selectedKeys()) if (scopeKeys.has(key)) count++;
1056
+ return count;
1057
+ }, ...ngDevMode ? [{ debugName: "#bulkSelectionSelectedCount" }] : /* istanbul ignore next */ []);
1058
+ this.#document = inject(DOCUMENT);
1059
+ this.#editContext = signal(null, ...ngDevMode ? [{ debugName: "#editContext" }] : /* istanbul ignore next */ []);
1060
+ this.#editSession = signal(null, ...ngDevMode ? [{ debugName: "#editSession" }] : /* istanbul ignore next */ []);
1061
+ this.#externalFilters = signal([], ...ngDevMode ? [{ debugName: "#externalFilters" }] : /* istanbul ignore next */ []);
1062
+ this.#filterableOptions = signal({
1063
+ enabled: false,
1064
+ type: "menu"
1065
+ }, ...ngDevMode ? [{ debugName: "#filterableOptions" }] : /* istanbul ignore next */ []);
1066
+ this.#groupColumnIds = signal(ImmutableList.create(), ...ngDevMode ? [{ debugName: "#groupColumnIds" }] : /* istanbul ignore next */ []);
1067
+ this.#horizontalScrollLeft = signal(0, ...ngDevMode ? [{ debugName: "#horizontalScrollLeft" }] : /* istanbul ignore next */ []);
1068
+ this.#i18n = inject(MonaI18nService);
1069
+ this.#injector = inject(Injector);
1070
+ this.#liveAnnouncer = inject(LiveAnnouncer);
1071
+ this.#platformId = inject(PLATFORM_ID);
1072
+ this.#reorderableOptions = signal({ enabled: false }, ...ngDevMode ? [{ debugName: "#reorderableOptions" }] : /* istanbul ignore next */ []);
1073
+ this.#resizableOptions = signal({ enabled: false }, ...ngDevMode ? [{ debugName: "#resizableOptions" }] : /* istanbul ignore next */ []);
1074
+ this.#rowFlattener = inject(GridRowFlattenerService);
1075
+ this.#rowReorderableOptions = signal({ enabled: false }, ...ngDevMode ? [{ debugName: "#rowReorderableOptions" }] : /* istanbul ignore next */ []);
1076
+ this.#rowUidByData = /* @__PURE__ */ new WeakMap();
1077
+ this.#rowUidByKeyObject = /* @__PURE__ */ new WeakMap();
1078
+ this.#scrollbarGutterMeasurementSource = signal("fallback", ...ngDevMode ? [{ debugName: "#scrollbarGutterMeasurementSource" }] : /* istanbul ignore next */ []);
1079
+ this.#scrollbarGutterWidth = signal(0, ...ngDevMode ? [{ debugName: "#scrollbarGutterWidth" }] : /* istanbul ignore next */ []);
1080
+ this.#seededFields = /* @__PURE__ */ new WeakMap();
1081
+ this.#serverBindingEnabled = signal(false, ...ngDevMode ? [{ debugName: "#serverBindingEnabled" }] : /* istanbul ignore next */ []);
1082
+ this.#serverLoading = signal(false, ...ngDevMode ? [{ debugName: "#serverLoading" }] : /* istanbul ignore next */ []);
1083
+ this.#serverTotal = signal(0, ...ngDevMode ? [{ debugName: "#serverTotal" }] : /* istanbul ignore next */ []);
1084
+ this.#sortDescriptors = signal([], ...ngDevMode ? [{ debugName: "#sortDescriptors" }] : /* istanbul ignore next */ []);
1085
+ this.#textMeasureCache = /* @__PURE__ */ new Map();
1086
+ this.#viewRowIndexByUid = computed(() => {
1087
+ const indices = /* @__PURE__ */ new Map();
1088
+ let index = 0;
1089
+ for (const row of this.viewRows()) indices.set(row.uid, index++);
1090
+ return indices;
1091
+ }, ...ngDevMode ? [{ debugName: "#viewRowIndexByUid" }] : /* istanbul ignore next */ []);
1092
+ this.#dataStateEmissionPending = false;
1093
+ this.#groupRequest = [];
1094
+ this.#loadedSelectedKeys = null;
1095
+ this.add$ = new Subject();
1096
+ this.addRowData = computed(() => {
1097
+ const session = this.#editSession();
1098
+ return session?.operation === "create" ? session.model() : null;
1099
+ }, ...ngDevMode ? [{ debugName: "addRowData" }] : /* istanbul ignore next */ []);
1100
+ this.addRowVisible = computed(() => this.addRowData() != null, ...ngDevMode ? [{ debugName: "addRowVisible" }] : /* istanbul ignore next */ []);
1101
+ this.aggregateColumns = computed(() => this.visibleColumns().where((column) => column.kind === "data" && column.aggregate != null).toImmutableList(), {
1102
+ ...ngDevMode ? { debugName: "aggregateColumns" } : /* istanbul ignore next */ {},
1103
+ equal: (left, right) => sameColumns(left, right, AGGREGATE_COLUMN_KEYS)
1104
+ });
1105
+ this.aggregateMap = computed(() => {
1106
+ const aggregateColumns = this.aggregateColumns();
1107
+ if (!aggregateColumns.any()) return ImmutableDictionary.create();
1108
+ return this.createAggregateMap(this.viewRows().toArray(), aggregateColumns.toArray());
1109
+ }, ...ngDevMode ? [{ debugName: "aggregateMap" }] : /* istanbul ignore next */ []);
1110
+ this.aggregateRows = computed(() => this.viewRows().select((row) => row.data).toArray(), ...ngDevMode ? [{ debugName: "aggregateRows" }] : /* istanbul ignore next */ []);
1111
+ this.allBulkSelectionRowsSelected = computed(() => {
1112
+ const scopeSize = this.#bulkSelectionRowKeys().size;
1113
+ return scopeSize > 0 && this.#bulkSelectionSelectedCount() === scopeSize;
1114
+ }, ...ngDevMode ? [{ debugName: "allBulkSelectionRowsSelected" }] : /* istanbul ignore next */ []);
1115
+ this.appliedFilters = signal(ImmutableDictionary.create(), ...ngDevMode ? [{ debugName: "appliedFilters" }] : /* istanbul ignore next */ []);
1116
+ this.bodyAriaRowStart = computed(() => this.headerRowCount() + (this.addRowVisible() ? 1 : 0) + (this.virtualScrollOptions().enabled ? 0 : this.paginationState().skip), ...ngDevMode ? [{ debugName: "bodyAriaRowStart" }] : /* istanbul ignore next */ []);
1117
+ this.bodyScrollElement = signal(null, ...ngDevMode ? [{ debugName: "bodyScrollElement" }] : /* istanbul ignore next */ []);
1118
+ this.bodyTableElement = signal(null, ...ngDevMode ? [{ debugName: "bodyTableElement" }] : /* istanbul ignore next */ []);
1119
+ this.bulkSelectionRows = computed(() => {
1120
+ if (this.selectableOptions().selectAllScope === "page" && !this.virtualScrollOptions().enabled) return this.viewPageRows();
1121
+ return this.viewRows();
1122
+ }, ...ngDevMode ? [{ debugName: "bulkSelectionRows" }] : /* istanbul ignore next */ []);
1123
+ this.cancel$ = new Subject();
1124
+ this.cellEdit$ = new Subject();
1125
+ this.collapsedGroupKeys = signal(ImmutableSet.create(), ...ngDevMode ? [{ debugName: "collapsedGroupKeys" }] : /* istanbul ignore next */ []);
1126
+ this.columnReorder$ = new Subject();
1127
+ this.columnResize$ = new Subject();
1128
+ this.columnResizeActive = signal(false, ...ngDevMode ? [{ debugName: "columnResizeActive" }] : /* istanbul ignore next */ []);
1129
+ this.columnSort$ = new Subject();
1130
+ this.columns = signal(ImmutableList.create(), ...ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []);
1131
+ this.contextMenuItems = signal(ImmutableSet.create(), ...ngDevMode ? [{ debugName: "contextMenuItems" }] : /* istanbul ignore next */ []);
1132
+ this.dataStateChange$ = new Subject();
1133
+ this.detailColumnWidth = 36;
1134
+ this.draggingRowUid = signal(null, ...ngDevMode ? [{ debugName: "draggingRowUid" }] : /* istanbul ignore next */ []);
1135
+ this.edit$ = new Subject();
1136
+ this.editContext = this.#editContext.asReadonly();
1137
+ this.editSession = this.#editSession.asReadonly();
1138
+ this.editViewDict = computed(() => {
1139
+ const session = this.#editSession();
1140
+ if (session == null || session.operation !== "update" || session.rowUid == null) return ImmutableDictionary.create();
1141
+ const item = {
1142
+ $rowId: session.rowUid,
1143
+ ...this.sessionRowData(session)
1144
+ };
1145
+ const pairs = [new KeyValuePair(item.$rowId, item)];
1146
+ return ImmutableDictionary.create(pairs);
1147
+ }, ...ngDevMode ? [{ debugName: "editViewDict" }] : /* istanbul ignore next */ []);
1148
+ this.editableOptions = signal({
1149
+ enabled: false,
1150
+ mode: "cell"
1151
+ }, ...ngDevMode ? [{ debugName: "editableOptions" }] : /* istanbul ignore next */ []);
1152
+ this.editingRowUid = computed(() => this.#editContext()?.rowUid ?? null, ...ngDevMode ? [{ debugName: "editingRowUid" }] : /* istanbul ignore next */ []);
1153
+ this.expandedKeys = signal(ImmutableSet.create(), ...ngDevMode ? [{ debugName: "expandedKeys" }] : /* istanbul ignore next */ []);
1154
+ this.expandedKeysChange$ = new Subject();
1155
+ this.filterChange$ = new Subject();
1156
+ this.filterRowEnabled = computed(() => {
1157
+ const options = this.#filterableOptions();
1158
+ return options.enabled && (options.type === "row" || options.type === "menu, row");
1159
+ }, ...ngDevMode ? [{ debugName: "filterRowEnabled" }] : /* istanbul ignore next */ []);
1160
+ this.filterableOptions = this.#filterableOptions.asReadonly();
1161
+ this.footerScrollElement = signal(null, ...ngDevMode ? [{ debugName: "footerScrollElement" }] : /* istanbul ignore next */ []);
1162
+ this.gridHeaderElement = signal(null, ...ngDevMode ? [{ debugName: "gridHeaderElement" }] : /* istanbul ignore next */ []);
1163
+ this.groupAggregateMap = computed(() => {
1164
+ const aggregateColumns = this.aggregateColumns();
1165
+ const groupColumns = this.groupColumns();
1166
+ if (!aggregateColumns.any() || !groupColumns.any()) return ImmutableDictionary.create();
1167
+ const aggregates = new Dictionary();
1168
+ this.buildGroupAggregates(this.viewRows().toArray(), groupColumns.toArray(), aggregateColumns.toArray(), 0, null, aggregates);
1169
+ return aggregates.toImmutableDictionary((e) => e.key, (e) => e.value);
1170
+ }, ...ngDevMode ? [{ debugName: "groupAggregateMap" }] : /* istanbul ignore next */ []);
1171
+ this.groupChange$ = new Subject();
1172
+ this.groupColumnWidth = 36;
1173
+ this.groupColumns = computed(() => {
1174
+ const columnsById = new Map(this.columns().select((column) => [column.id, column]));
1175
+ return this.#groupColumnIds().select((id) => columnsById.get(id)).where((column) => column != null).toImmutableList();
1176
+ }, {
1177
+ ...ngDevMode ? { debugName: "groupColumns" } : /* istanbul ignore next */ {},
1178
+ equal: (left, right) => sameColumns(left, right, GROUP_COLUMN_KEYS)
1179
+ });
1180
+ this.groupStructuralWidth = computed(() => this.groupColumns().length * this.groupColumnWidth, ...ngDevMode ? [{ debugName: "groupStructuralWidth" }] : /* istanbul ignore next */ []);
1181
+ this.groupableOptions = signal({
1182
+ enabled: false,
1183
+ showFooter: false
1184
+ }, ...ngDevMode ? [{ debugName: "groupableOptions" }] : /* istanbul ignore next */ []);
1185
+ this.hasFooter = computed(() => this.aggregateColumns().any(), ...ngDevMode ? [{ debugName: "hasFooter" }] : /* istanbul ignore next */ []);
1186
+ this.hasLeftLockedColumns = computed(() => this.rowReorderColumnVisible() || this.selectionColumnVisible() || this.visibleColumns().any((column) => column.locked && column.lockedPosition === "left"), ...ngDevMode ? [{ debugName: "hasLeftLockedColumns" }] : /* istanbul ignore next */ []);
1187
+ this.hasLiveScrollbarGutterWidth = computed(() => this.#scrollbarGutterMeasurementSource() === "body", ...ngDevMode ? [{ debugName: "hasLiveScrollbarGutterWidth" }] : /* istanbul ignore next */ []);
1188
+ this.headerRowCount = computed(() => this.filterRowEnabled() ? 2 : 1, ...ngDevMode ? [{ debugName: "headerRowCount" }] : /* istanbul ignore next */ []);
1189
+ this.headerTableElement = signal(null, ...ngDevMode ? [{ debugName: "headerTableElement" }] : /* istanbul ignore next */ []);
1190
+ this.horizontalScrollLeft = this.#horizontalScrollLeft.asReadonly();
1191
+ this.isInEditMode = computed(() => this.#editSession() != null, ...ngDevMode ? [{ debugName: "isInEditMode" }] : /* istanbul ignore next */ []);
1192
+ this.layout = computed(() => {
1193
+ const columns = this.visibleColumns().toArray();
1194
+ const startLockedColumns = columns.filter((column) => column.locked && column.lockedPosition === "left");
1195
+ const endLockedColumns = columns.filter((column) => column.locked && column.lockedPosition === "right");
1196
+ const groupCount = this.groupColumns().length;
1197
+ const structuralColumns = this.visibleStructuralColumns();
1198
+ const leadingColumnCount = groupCount + structuralColumns.length;
1199
+ const leadingSticky = this.hasLeftLockedColumns();
1200
+ const leadingEdgeIndex = startLockedColumns.length === 0 ? leadingColumnCount - 1 : -1;
1201
+ let startOffset = 0;
1202
+ const nextLeadingSticky = (index, width) => {
1203
+ const offset = startOffset;
1204
+ startOffset += width;
1205
+ return leadingSticky ? {
1206
+ edge: index === leadingEdgeIndex,
1207
+ offset,
1208
+ side: "start"
1209
+ } : null;
1210
+ };
1211
+ const layout = [];
1212
+ for (let depth = 0; depth < groupCount; depth++) layout.push({
1213
+ depth,
1214
+ key: `group:${depth}`,
1215
+ kind: "group",
1216
+ logicalIndex: null,
1217
+ sticky: nextLeadingSticky(depth, this.groupColumnWidth),
1218
+ width: this.groupColumnWidth
1219
+ });
1220
+ for (const [index, structuralColumn] of structuralColumns.entries()) layout.push({
1221
+ firstInRow: index === 0,
1222
+ key: `structural:${structuralColumn.kind}`,
1223
+ kind: structuralColumn.kind,
1224
+ lastInRow: columns.length === 0 && index === structuralColumns.length - 1,
1225
+ logicalIndex: index,
1226
+ sticky: nextLeadingSticky(groupCount + index, structuralColumn.width),
1227
+ width: structuralColumn.width
1228
+ });
1229
+ let logicalIndex = structuralColumns.length;
1230
+ const stickyByColumn = /* @__PURE__ */ new Map();
1231
+ for (const [index, column] of startLockedColumns.entries()) {
1232
+ stickyByColumn.set(column, {
1233
+ edge: index === startLockedColumns.length - 1,
1234
+ offset: startOffset,
1235
+ side: "start"
1236
+ });
1237
+ startOffset += this.getColumnWidth(column);
1238
+ }
1239
+ let endOffset = 0;
1240
+ for (const column of [...endLockedColumns].reverse()) {
1241
+ stickyByColumn.set(column, {
1242
+ edge: column === endLockedColumns[0],
1243
+ offset: endOffset,
1244
+ side: "end"
1245
+ });
1246
+ endOffset += this.getColumnWidth(column);
1247
+ }
1248
+ for (const [columnIndex, column] of columns.entries()) layout.push({
1249
+ column,
1250
+ columnIndex,
1251
+ firstInRow: structuralColumns.length === 0 && columnIndex === 0,
1252
+ key: `column:${column.id}`,
1253
+ kind: "column",
1254
+ lastInRow: columnIndex === columns.length - 1,
1255
+ logicalIndex: logicalIndex++,
1256
+ sticky: stickyByColumn.get(column) ?? null,
1257
+ width: column.calculatedWidth
1258
+ });
1259
+ return layout;
1260
+ }, ...ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []);
1261
+ this.layoutColumnByKey = computed(() => new Map(this.layout().map((layoutColumn) => [layoutColumn.key, layoutColumn])), ...ngDevMode ? [{ debugName: "layoutColumnByKey" }] : /* istanbul ignore next */ []);
1262
+ this.leadingStructuralWidth = computed(() => this.groupStructuralWidth() + this.visibleStructuralColumns().reduce((total, column) => total + column.width, 0), ...ngDevMode ? [{ debugName: "leadingStructuralWidth" }] : /* istanbul ignore next */ []);
1263
+ this.masterDetailRowWidth = computed(() => {
1264
+ const columnListWidth = this.visibleColumns().aggregate((acc, c) => acc + this.getColumnWidth(c), 0);
1265
+ return this.normalizeRenderedWidth(this.leadingStructuralWidth() + columnListWidth);
1266
+ }, ...ngDevMode ? [{ debugName: "masterDetailRowWidth" }] : /* istanbul ignore next */ []);
1267
+ this.masterDetailTemplate = signal(null, ...ngDevMode ? [{ debugName: "masterDetailTemplate" }] : /* istanbul ignore next */ []);
1268
+ this.messages = this.#i18n.componentMessages("grid", GRID_DEFAULT_MESSAGES);
1269
+ this.newRowFactory = signal(() => ({}), ...ngDevMode ? [{ debugName: "newRowFactory" }] : /* istanbul ignore next */ []);
1270
+ this.pageReset$ = new Subject();
1271
+ this.pagerTotal = computed(() => this.serverBindingEnabled() ? this.serverTotal() : this.viewRowCount(), ...ngDevMode ? [{ debugName: "pagerTotal" }] : /* istanbul ignore next */ []);
1272
+ this.paginationState = signal({
1273
+ page: 1,
1274
+ skip: 0,
1275
+ take: 10
1276
+ }, ...ngDevMode ? [{ debugName: "paginationState" }] : /* istanbul ignore next */ []);
1277
+ this.remove$ = new Subject();
1278
+ this.renderedBodyRowCount = signal(0, ...ngDevMode ? [{ debugName: "renderedBodyRowCount" }] : /* istanbul ignore next */ []);
1279
+ this.reorderableOptions = this.#reorderableOptions.asReadonly();
1280
+ this.resizableOptions = this.#resizableOptions.asReadonly();
1281
+ this.rowClass = signal(null, ...ngDevMode ? [{ debugName: "rowClass" }] : /* istanbul ignore next */ []);
1282
+ this.rowDragInProgress = computed(() => this.draggingRowUid() != null, ...ngDevMode ? [{ debugName: "rowDragInProgress" }] : /* istanbul ignore next */ []);
1283
+ this.rowEdit$ = new Subject();
1284
+ this.rowKey = signal(null, ...ngDevMode ? [{ debugName: "rowKey" }] : /* istanbul ignore next */ []);
1285
+ this.rowReorder$ = new Subject();
1286
+ this.rowReorderColumnVisible = computed(() => this.rowReorderableOptions().enabled === true, ...ngDevMode ? [{ debugName: "rowReorderColumnVisible" }] : /* istanbul ignore next */ []);
1287
+ this.rowReorderColumnWidth = 36;
1288
+ this.rowReorderDisabledReason = computed(() => {
1289
+ if (!this.rowReorderableOptions().enabled) return "disabled";
1290
+ if (this.serverBindingEnabled()) return "server-binding";
1291
+ if (this.virtualScrollOptions().enabled) return "virtual-scroll";
1292
+ if (this.groupColumns().any()) return "grouped";
1293
+ if (this.#sortDescriptors().length > 0) return "sorted";
1294
+ if (!this.appliedFilters().isEmpty()) return "filtered";
1295
+ if (this.isInEditMode()) return "editing";
1296
+ if (this.viewPageRows().length < 2) return "single-row";
1297
+ return null;
1298
+ }, ...ngDevMode ? [{ debugName: "rowReorderDisabledReason" }] : /* istanbul ignore next */ []);
1299
+ this.rowReorderInteractionEnabled = computed(() => this.rowReorderDisabledReason() == null, ...ngDevMode ? [{ debugName: "rowReorderInteractionEnabled" }] : /* istanbul ignore next */ []);
1300
+ this.rowReorderableOptions = this.#rowReorderableOptions.asReadonly();
1301
+ this.rows = signal(ImmutableList.create(), ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
1302
+ this.save$ = new Subject();
1303
+ this.scrollEnd$ = new Subject();
1304
+ this.scrollEndThreshold = signal(5, ...ngDevMode ? [{ debugName: "scrollEndThreshold" }] : /* istanbul ignore next */ []);
1305
+ this.scrollbarGutterWidth = this.#scrollbarGutterWidth.asReadonly();
1306
+ this.selectBy = signal("", ...ngDevMode ? [{ debugName: "selectBy" }] : /* istanbul ignore next */ []);
1307
+ this.selectableOptions = signal({
1308
+ enabled: false,
1309
+ mode: "single",
1310
+ selectAllScope: "page",
1311
+ selectOnRowClick: false,
1312
+ showCheckboxes: false,
1313
+ showSelectAll: true
1314
+ }, ...ngDevMode ? [{ debugName: "selectableOptions" }] : /* istanbul ignore next */ []);
1315
+ this.selectedKeys = signal(ImmutableSet.create(), ...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
1316
+ this.selectedKeysChange$ = toObservable(this.selectedKeys);
1317
+ this.selectedKeysLoad$ = new BehaviorSubject(ImmutableSet.create());
1318
+ this.selectionColumnVisible = computed(() => {
1319
+ const options = this.selectableOptions();
1320
+ return options.enabled === true && options.showCheckboxes === true;
1321
+ }, ...ngDevMode ? [{ debugName: "selectionColumnVisible" }] : /* istanbul ignore next */ []);
1322
+ this.selectionColumnWidth = 40;
1323
+ this.serverBindingEnabled = this.#serverBindingEnabled.asReadonly();
1324
+ this.serverLoading = this.#serverLoading.asReadonly();
1325
+ this.serverTotal = this.#serverTotal.asReadonly();
1326
+ this.someBulkSelectionRowsSelected = computed(() => {
1327
+ const scopeSize = this.#bulkSelectionRowKeys().size;
1328
+ const count = this.#bulkSelectionSelectedCount();
1329
+ return count > 0 && count < scopeSize;
1330
+ }, ...ngDevMode ? [{ debugName: "someBulkSelectionRowsSelected" }] : /* istanbul ignore next */ []);
1331
+ this.sortChange$ = new Subject();
1332
+ this.sortableOptions = signal({
1333
+ enabled: false,
1334
+ mode: "single",
1335
+ allowUnsort: true,
1336
+ showIndices: true
1337
+ }, ...ngDevMode ? [{ debugName: "sortableOptions" }] : /* istanbul ignore next */ []);
1338
+ this.stickyInset = computed(() => {
1339
+ let start = 0;
1340
+ let end = 0;
1341
+ for (const layoutColumn of this.layout()) if (layoutColumn.sticky?.side === "start") start += layoutColumn.width ?? 0;
1342
+ else if (layoutColumn.sticky?.side === "end") end += layoutColumn.width ?? 0;
1343
+ return {
1344
+ end,
1345
+ start
1346
+ };
1347
+ }, {
1348
+ ...ngDevMode ? { debugName: "stickyInset" } : /* istanbul ignore next */ {},
1349
+ equal: (left, right) => left.start === right.start && left.end === right.end
1350
+ });
1351
+ this.structuralColumns = computed(() => [
1352
+ {
1353
+ kind: "reorder",
1354
+ visible: this.rowReorderColumnVisible(),
1355
+ width: this.rowReorderColumnWidth
1356
+ },
1357
+ {
1358
+ kind: "detail",
1359
+ visible: this.masterDetailTemplate() != null,
1360
+ width: this.detailColumnWidth
1361
+ },
1362
+ {
1363
+ kind: "selection",
1364
+ visible: this.selectionColumnVisible(),
1365
+ width: this.selectionColumnWidth
1366
+ }
1367
+ ], ...ngDevMode ? [{ debugName: "structuralColumns" }] : /* istanbul ignore next */ []);
1368
+ this.tableWidth = computed(() => {
1369
+ const columns = this.visibleColumns();
1370
+ if (!columns.any()) return null;
1371
+ if (columns.any((c) => c.calculatedWidth == null && c.width == null)) return null;
1372
+ const dataWidth = columns.aggregate((acc, c) => acc + this.getColumnWidth(c), 0);
1373
+ return this.normalizeRenderedWidth(dataWidth + this.leadingStructuralWidth());
1374
+ }, ...ngDevMode ? [{ debugName: "tableWidth" }] : /* istanbul ignore next */ []);
1375
+ this.viewPageRows = computed(() => {
1376
+ if (this.serverBindingEnabled()) return this.viewRows();
1377
+ const skip = this.paginationState().skip;
1378
+ const take = this.paginationState().take;
1379
+ const viewRows = this.viewRows();
1380
+ if (!viewRows.any()) return ImmutableList.create();
1381
+ return viewRows.skip(skip).take(take).toImmutableList();
1382
+ }, ...ngDevMode ? [{ debugName: "viewPageRows" }] : /* istanbul ignore next */ []);
1383
+ this.viewRowCount = computed(() => this.viewRows().size(), ...ngDevMode ? [{ debugName: "viewRowCount" }] : /* istanbul ignore next */ []);
1384
+ this.viewRows = computed(() => {
1385
+ const rows = this.rows();
1386
+ if (this.serverBindingEnabled()) return rows;
1387
+ let queryEnumerable = Query.from(rows, { locale: this.#i18n.localeId() });
1388
+ for (const filter of this.getFilterDescriptors()) queryEnumerable = queryEnumerable.filter(filter, (r) => r.data);
1389
+ const groupSorts = this.getGroupDescriptors(this.groupColumns()).map((d) => ({
1390
+ field: d.field,
1391
+ dir: d.dir ?? "asc"
1392
+ }));
1393
+ const groupFields = new Set(groupSorts.map((sort) => sort.field));
1394
+ const columnSorts = this.#sortDescriptors().filter((sort) => !groupFields.has(sort.field));
1395
+ queryEnumerable = queryEnumerable.sort([...groupSorts, ...columnSorts], (r) => r.data);
1396
+ return ImmutableList.create(queryEnumerable.run());
1397
+ }, ...ngDevMode ? [{ debugName: "viewRows" }] : /* istanbul ignore next */ []);
1398
+ this.virtualGridMaxBuffer = computed(() => this.virtualGridMinBuffer() * 1.42857, ...ngDevMode ? [{ debugName: "virtualGridMaxBuffer" }] : /* istanbul ignore next */ []);
1399
+ this.virtualGridMinBuffer = signal(0, ...ngDevMode ? [{ debugName: "virtualGridMinBuffer" }] : /* istanbul ignore next */ []);
1400
+ this.virtualScrollOptions = signal({
1401
+ enabled: false,
1402
+ height: 36
1403
+ }, ...ngDevMode ? [{ debugName: "virtualScrollOptions" }] : /* istanbul ignore next */ []);
1404
+ this.visibleColumns = computed(() => this.columns().where((column) => !column.hidden).toImmutableList(), ...ngDevMode ? [{ debugName: "visibleColumns" }] : /* istanbul ignore next */ []);
1405
+ this.visibleStructuralColumns = computed(() => this.structuralColumns().filter((c) => c.visible), ...ngDevMode ? [{ debugName: "visibleStructuralColumns" }] : /* istanbul ignore next */ []);
1406
+ this.#scrollbarGutterWidth.set(this.measureFallbackScrollbarGutter());
1407
+ this.setHorizontalScrollSyncEffects();
1408
+ this.setScrollbarGutterEffects();
1409
+ }
1410
+ addGroupColumn(column) {
1411
+ if (column.kind === "command" || this.#groupColumnIds().contains(column.id)) return;
1412
+ this.#groupColumnIds.update((ids) => ids.add(column.id));
1413
+ this.setColumnGroupSortDirection(column.id, "asc");
1414
+ this.emitGroupChange();
1415
+ }
1416
+ applyState(state, options = {}) {
1417
+ if (state == null) return {
1418
+ ignoredColumns: [],
1419
+ missingColumns: [],
1420
+ status: "empty"
1421
+ };
1422
+ if (state.version !== GRID_STATE_VERSION) return {
1423
+ ignoredColumns: [],
1424
+ missingColumns: [],
1425
+ status: "rejected-version"
1426
+ };
1427
+ if (options.schemaVersion != null && state.schemaVersion !== options.schemaVersion) return {
1428
+ ignoredColumns: [],
1429
+ missingColumns: [],
1430
+ status: "rejected-schema"
1431
+ };
1432
+ if (!isWellFormedGridState(state)) return {
1433
+ ignoredColumns: [],
1434
+ missingColumns: [],
1435
+ status: "rejected-invalid"
1436
+ };
1437
+ const previousDataState = this.getDataState();
1438
+ let columns = this.columns().toArray();
1439
+ const columnById = /* @__PURE__ */ new Map();
1440
+ for (const column of columns) {
1441
+ const id = this.getColumnStateId(column);
1442
+ if (id != null) columnById.set(id, column);
1443
+ }
1444
+ const stateColumnById = new Map(state.columns.map((column) => [column.id, column]));
1445
+ const ignoredColumns = state.columns.filter((column) => !columnById.has(column.id)).map((column) => column.id);
1446
+ const missingColumns = columns.map((column) => this.getColumnStateId(column)).filter((id) => id != null && !stateColumnById.has(id));
1447
+ columns = columns.map((column) => {
1448
+ const id = this.getColumnStateId(column);
1449
+ const columnState = id == null ? void 0 : stateColumnById.get(id);
1450
+ return columnState == null ? column : {
1451
+ ...column,
1452
+ calculatedWidth: columnState.width,
1453
+ hidden: columnState.hidden
1454
+ };
1455
+ });
1456
+ const updatedColumnById = /* @__PURE__ */ new Map();
1457
+ for (const column of columns) {
1458
+ const id = this.getColumnStateId(column);
1459
+ if (id != null) updatedColumnById.set(id, column);
1460
+ }
1461
+ const orderedColumns = state.columns.slice().sort((left, right) => left.order - right.order).map((columnState) => updatedColumnById.get(columnState.id)).filter((column) => column != null);
1462
+ const orderedSet = new Set(orderedColumns);
1463
+ orderedColumns.push(...columns.filter((column) => !orderedSet.has(column)));
1464
+ this.columns.set(ImmutableList.create(this.withColumnIndices(this.orderColumnsByLockBucket(orderedColumns))));
1465
+ this.loadSorts(state.sort.map((sort) => ({
1466
+ dir: sort.dir,
1467
+ field: sort.field
1468
+ })));
1469
+ this.loadGroupColumns(state.group);
1470
+ this.loadFilters(this.deserializeFilters(state.filter));
1471
+ this.sortChange$.next(this.getSortDescriptors());
1472
+ this.groupChange$.next(this.getGroupDescriptors(this.groupColumns()));
1473
+ this.filterChange$.next(this.getFilterDescriptors());
1474
+ if (options.persistPageSize !== false && state.pageSize != null) this.setPageState({
1475
+ page: 1,
1476
+ skip: 0,
1477
+ take: state.pageSize
1478
+ });
1479
+ if (this.serverBindingEnabled()) this.setPageState({ skip: 0 });
1480
+ if (!deepEquals(previousDataState, this.getDataState())) this.requestDataStateChange({ resetPage: true });
1481
+ return {
1482
+ ignoredColumns,
1483
+ missingColumns,
1484
+ status: "applied"
1485
+ };
1486
+ }
1487
+ canReorderRow(row) {
1488
+ if (!this.rowReorderInteractionEnabled()) return false;
1489
+ const predicate = this.rowReorderableOptions().canReorder;
1490
+ return predicate?.(row.data) !== false;
1491
+ }
1492
+ cancelAddRow(originalEvent, reason = "command") {
1493
+ const session = this.#editSession();
1494
+ if (session == null || session.operation !== "create") return true;
1495
+ const event = new GridCancelEvent({
1496
+ operation: "create",
1497
+ originalEvent,
1498
+ reason,
1499
+ rowData: this.resolveSessionRowData(session),
1500
+ session
1501
+ });
1502
+ this.cancel$.next(event);
1503
+ if (event.isDefaultPrevented()) return false;
1504
+ this.clearEditSession();
1505
+ return true;
1506
+ }
1507
+ cancelEdit(originalEvent, reason = "command") {
1508
+ const context = this.#editContext();
1509
+ const session = this.#editSession();
1510
+ if (context == null || session == null || session.operation !== "update") return true;
1511
+ const event = new GridCancelEvent({
1512
+ operation: "update",
1513
+ originalEvent,
1514
+ reason,
1515
+ rowData: this.resolveEditedRowData(context.rowUid, context.row.data),
1516
+ session
1517
+ });
1518
+ this.cancel$.next(event);
1519
+ if (event.isDefaultPrevented()) return false;
1520
+ this.clearEditSession();
1521
+ return true;
1522
+ }
1523
+ captureState(options = {}) {
1524
+ const state = {
1525
+ columns: this.columns().toArray().map((column, index) => {
1526
+ const id = this.getColumnStateId(column);
1527
+ return id == null ? null : {
1528
+ hidden: column.hidden,
1529
+ id,
1530
+ order: index,
1531
+ width: this.getColumnWidth(column)
1532
+ };
1533
+ }).filter((column) => column != null),
1534
+ filter: this.getFilterDescriptors().map((filter) => this.serializeFilter(filter)).filter((filter) => filter != null),
1535
+ group: this.getGroupDescriptors(this.groupColumns()),
1536
+ sort: this.getSortDescriptors().map((sort) => ({
1537
+ dir: sort.dir,
1538
+ field: sort.field
1539
+ })),
1540
+ version: GRID_STATE_VERSION
1541
+ };
1542
+ if (options.schemaVersion != null) state.schemaVersion = options.schemaVersion;
1543
+ if (options.persistPageSize !== false) state.pageSize = this.paginationState().take;
1544
+ return state;
1545
+ }
1546
+ clearCollapsedGroups(predicate) {
1547
+ if (predicate) this.collapsedGroupKeys.update((keys) => keys.where((k) => !predicate(k)).toImmutableSet());
1548
+ else this.collapsedGroupKeys.update((keys) => keys.clear());
1549
+ }
1550
+ clearColumnGrouping(column) {
1551
+ this.#groupColumnIds.update((ids) => ids.remove(column.id));
1552
+ this.setColumnGroupSortDirection(column.id, null);
1553
+ this.clearCollapsedGroups((key) => groupKeyHasField(key, column.field));
1554
+ this.emitGroupChange();
1555
+ }
1556
+ commitRowEdit(originalEvent) {
1557
+ const context = this.#editContext();
1558
+ const session = this.#editSession();
1559
+ if (!context || context.mode !== "row" || session == null) return false;
1560
+ if (!this.validateSessionForSave(session)) return false;
1561
+ const rowData = this.resolveEditedRowData(context.rowUid, context.row.data);
1562
+ if (!hasChangedFields(context.row.data, rowData)) {
1563
+ this.clearEditSession();
1564
+ return true;
1565
+ }
1566
+ const saveEvent = new GridSaveEvent({
1567
+ operation: "update",
1568
+ originalEvent,
1569
+ originalRowData: context.row.data,
1570
+ rowData,
1571
+ session
1572
+ });
1573
+ this.save$.next(saveEvent);
1574
+ if (saveEvent.isDefaultPrevented()) return false;
1575
+ this.clearEditSession();
1576
+ this.rowEdit$.next(new RowEditEvent({
1577
+ originalRowData: context.row.data,
1578
+ rowData,
1579
+ session
1580
+ }));
1581
+ return true;
1582
+ }
1583
+ createBodyRows(rows) {
1584
+ const groupColumns = this.groupColumns();
1585
+ if (groupColumns.length === 0) return this.#rowFlattener.toDataRows(rows);
1586
+ return this.#rowFlattener.flatten(rows, groupColumns, new Set(this.collapsedGroupKeys()), this.groupableOptions().showFooter, this.groupAggregateMap(), this.serverBindingEnabled(), { locale: this.#i18n.localeId() });
1587
+ }
1588
+ deselectAllRows() {
1589
+ this.selectedKeys.update((set) => set.clear());
1590
+ }
1591
+ deselectRow(row) {
1592
+ this.setRowSelected(row, false);
1593
+ }
1594
+ endEdit() {
1595
+ this.clearEditSession();
1596
+ }
1597
+ findTextWidthOfColumn(column, element) {
1598
+ if (!isPlatformBrowser(this.#platformId)) return 0;
1599
+ let longestValue = this.findLongestCellContentOfColumn(column);
1600
+ if (column.title.length > longestValue.length) longestValue = column.title;
1601
+ const documentBodyStyle = window.getComputedStyle(this.#document.body);
1602
+ const fontFamily = documentBodyStyle.getPropertyValue("font-family");
1603
+ const fontSize = documentBodyStyle.getPropertyValue("font-size");
1604
+ const titleElement = element.querySelector("[data-column-title]");
1605
+ const actionsElement = element.querySelector("[data-column-actions]");
1606
+ const totalAdditionalWidth = (actionsElement ? actionsElement.clientWidth : 0) + (titleElement ? parseInt(window.getComputedStyle(titleElement).paddingLeft, 10) + parseInt(window.getComputedStyle(titleElement).paddingRight, 10) : 0);
1607
+ const fontKey = `${fontSize} ${fontFamily}`;
1608
+ const cacheKey = `${fontKey}|${longestValue}`;
1609
+ const cached = this.#textMeasureCache.get(cacheKey);
1610
+ if (cached != null) return this.normalizeRenderedWidth(cached + totalAdditionalWidth);
1611
+ const context = this.#document.createElement("canvas").getContext("2d");
1612
+ if (context == null) return 0;
1613
+ context.font = fontKey;
1614
+ const measured = context.measureText(longestValue).width;
1615
+ if (this.#textMeasureCache.size >= TEXT_MEASURE_CACHE_LIMIT) this.#textMeasureCache.clear();
1616
+ this.#textMeasureCache.set(cacheKey, measured);
1617
+ return this.normalizeRenderedWidth(measured + totalAdditionalWidth);
1618
+ }
1619
+ getBodyAriaRowIndices(bodyRows) {
1620
+ const start = this.bodyAriaRowStart();
1621
+ const details = this.masterDetailTemplate() != null && !this.virtualScrollOptions().enabled;
1622
+ const indices = [];
1623
+ let count = 0;
1624
+ for (const bodyRow of bodyRows) {
1625
+ count++;
1626
+ indices.push(start + count);
1627
+ if (details && bodyRow.type === "data" && this.isRowExpanded(bodyRow.row)) count++;
1628
+ }
1629
+ return {
1630
+ count,
1631
+ indices
1632
+ };
1633
+ }
1634
+ getColumnStateId(column) {
1635
+ return column.stateKey || column.field || null;
1636
+ }
1637
+ getColumnWidth(column) {
1638
+ return this.normalizeRenderedWidth(column.calculatedWidth ?? column.width ?? column.minWidth ?? 0);
1639
+ }
1640
+ getDataState() {
1641
+ const { skip, take } = this.paginationState();
1642
+ return {
1643
+ skip,
1644
+ take,
1645
+ sort: this.getSortDescriptors(),
1646
+ filter: this.getFilterDescriptors().map((filter) => this.cloneFilter(filter))
1647
+ };
1648
+ }
1649
+ getFilterDescriptors() {
1650
+ return [...this.appliedFilters().values().select((state) => state.filter).where((filter) => filter != null).toArray(), ...this.#externalFilters()];
1651
+ }
1652
+ getGroupDescriptors(columns) {
1653
+ return select(columns, (c) => ({
1654
+ field: c.field,
1655
+ dir: c.groupSortDirection ?? void 0
1656
+ })).toArray();
1657
+ }
1658
+ getRowCommandAriaLabel(command, row) {
1659
+ const messages = this.messages();
1660
+ if (row == null) return command === "cancel" ? messages.cancelNewRow : messages.saveNewRow;
1661
+ const rowNumber = this.getRowNumber(row);
1662
+ const label = this.editableOptions().commandAriaLabel?.(command, row.data, rowNumber - 1);
1663
+ if (label) return label;
1664
+ switch (command) {
1665
+ case "cancel": return messages.cancelRowEdit(rowNumber);
1666
+ case "edit": return messages.editRow(rowNumber);
1667
+ case "remove": return messages.removeRow(rowNumber);
1668
+ case "save": return messages.saveRow(rowNumber);
1669
+ }
1670
+ }
1671
+ getRowNumber(row) {
1672
+ return (this.#viewRowIndexByUid().get(row.uid) ?? 0) + 1 + (this.serverBindingEnabled() ? this.paginationState().skip : 0);
1673
+ }
1674
+ getRowReorderAriaLabel(row, absoluteIndex) {
1675
+ return this.rowReorderableOptions().rowAriaLabel?.(row.data, absoluteIndex) ?? this.messages().reorderRow(absoluteIndex + 1);
1676
+ }
1677
+ getSortDescriptors() {
1678
+ return this.#sortDescriptors().map((sort) => ({ ...sort }));
1679
+ }
1680
+ handleMultipleSelection(event, row) {
1681
+ if (event.shiftKey) {
1682
+ this.selectRowRange(row);
1683
+ return;
1684
+ }
1685
+ if (event.ctrlKey || event.metaKey) {
1686
+ if (this.isRowSelected(row)) this.deselectRow(row);
1687
+ else this.selectRow(row);
1688
+ this.#anchorRowKey.set(this.getRowSelectionKey(row));
1689
+ return;
1690
+ }
1691
+ this.deselectAllRows();
1692
+ this.selectRow(row);
1693
+ this.#anchorRowKey.set(this.getRowSelectionKey(row));
1694
+ }
1695
+ handleRowClick(event, row) {
1696
+ const options = this.selectableOptions();
1697
+ if (!options.enabled || options.selectOnRowClick === false) return;
1698
+ if (options.mode === "single") this.handleSingleSelection(event, row);
1699
+ else this.handleMultipleSelection(event, row);
1700
+ }
1701
+ handleSingleSelection(event, row) {
1702
+ if (this.isRowSelected(row) && (event.ctrlKey || event.metaKey)) {
1703
+ this.deselectAllRows();
1704
+ return;
1705
+ }
1706
+ this.deselectAllRows();
1707
+ this.selectRow(row);
1708
+ }
1709
+ isGroupCollapsed(groupKey) {
1710
+ return this.collapsedGroupKeys().contains(groupKey);
1711
+ }
1712
+ isLoadedSelection(keys) {
1713
+ return keys === this.#loadedSelectedKeys;
1714
+ }
1715
+ isRowExpanded(row) {
1716
+ return this.expandedKeys().contains(this.getRowIdentityKey(row));
1717
+ }
1718
+ isRowSelected(row) {
1719
+ return this.selectedKeys().contains(this.getRowSelectionKey(row));
1720
+ }
1721
+ loadExpandedKeys(keys) {
1722
+ const next = ImmutableSet.create(keys ?? []);
1723
+ const current = this.expandedKeys();
1724
+ if (next.size() !== current.size() || !next.all((key) => current.contains(key))) this.expandedKeys.set(next);
1725
+ }
1726
+ loadFilters(filters) {
1727
+ const requested = [...filters ?? []];
1728
+ if (deepEquals(requested, this.getFilterDescriptors())) return;
1729
+ const { byField, external } = partitionFilters(requested);
1730
+ const newAppliedFilters = new Dictionary();
1731
+ for (const [field, filter] of byField) newAppliedFilters.put(field, {
1732
+ filter,
1733
+ filterMenuValue: toFilterMenuValue(filter)
1734
+ });
1735
+ this.appliedFilters.set(newAppliedFilters.toImmutableDictionary((p) => p.key, (p) => p.value));
1736
+ this.#externalFilters.set(external);
1737
+ this.syncColumnFilterState();
1738
+ }
1739
+ loadGroupColumns(descriptors) {
1740
+ const columns = this.columns();
1741
+ const byField = /* @__PURE__ */ new Map();
1742
+ for (const descriptor of descriptors ?? []) {
1743
+ if (descriptor == null || typeof descriptor.field !== "string" || descriptor.field === "") continue;
1744
+ byField.delete(descriptor.field);
1745
+ byField.set(descriptor.field, {
1746
+ field: descriptor.field,
1747
+ dir: descriptor.dir === "desc" ? "desc" : "asc"
1748
+ });
1749
+ }
1750
+ this.#groupRequest = [...byField.values()];
1751
+ const descriptorList = this.#groupRequest.filter((descriptor) => columns.any((column) => column.field === descriptor.field && column.kind !== "command"));
1752
+ const groupColumns = descriptorList.map((descriptor) => columns.firstOrDefault((c) => c.field === descriptor.field && c.kind !== "command")).filter((column) => column != null);
1753
+ const currentGroupColumns = this.groupColumns();
1754
+ const currentDescriptors = this.getGroupDescriptors(currentGroupColumns);
1755
+ if (currentDescriptors.length === descriptorList.length && currentDescriptors.every((descriptor, index) => {
1756
+ const nextDescriptor = descriptorList[index];
1757
+ return nextDescriptor != null && descriptor.field === nextDescriptor.field && (descriptor.dir ?? "asc") === (nextDescriptor.dir ?? "asc");
1758
+ })) return;
1759
+ const groupSortDirections = /* @__PURE__ */ new Map();
1760
+ for (const [index, column] of groupColumns.entries()) groupSortDirections.set(column.id, descriptorList[index].dir ?? "asc");
1761
+ this.updateColumns((column) => ({
1762
+ ...column,
1763
+ groupSortDirection: groupSortDirections.get(column.id) ?? null
1764
+ }));
1765
+ this.#groupColumnIds.set(ImmutableList.create(groupColumns.map((column) => column.id)));
1766
+ }
1767
+ loadSelectedKeys(selectedKeys) {
1768
+ this.selectedKeys.update((set) => set.clear().addAll(selectedKeys));
1769
+ this.#loadedSelectedKeys = this.selectedKeys();
1770
+ this.selectedKeysLoad$.next(this.selectedKeys());
1771
+ }
1772
+ loadSorts(sorts) {
1773
+ const requested = [...sorts ?? []];
1774
+ if (deepEquals(requested, this.#sortDescriptors())) return;
1775
+ const byField = /* @__PURE__ */ new Map();
1776
+ for (const sort of requested) {
1777
+ if (sort == null || typeof sort.field !== "string" || sort.field === "") continue;
1778
+ if (sort.dir !== "asc" && sort.dir !== "desc") continue;
1779
+ byField.delete(sort.field);
1780
+ byField.set(sort.field, { ...sort });
1781
+ }
1782
+ this.#sortDescriptors.set([...byField.values()]);
1783
+ this.syncColumnSortState();
1784
+ }
1785
+ moveGroupColumn(column, moveAs) {
1786
+ const previous = this.#groupColumnIds();
1787
+ this.#groupColumnIds.update((ids) => {
1788
+ const list = ids.toArray();
1789
+ const index = list.indexOf(column.id);
1790
+ const newIndex = moveAs === "prev" ? index - 1 : index + 1;
1791
+ if (index < 0 || newIndex < 0 || newIndex >= list.length) return ids;
1792
+ const [movedId] = list.splice(index, 1);
1793
+ list.splice(newIndex, 0, movedId);
1794
+ return ImmutableList.create(list);
1795
+ });
1796
+ if (this.#groupColumnIds() !== previous) this.emitGroupChange();
1797
+ }
1798
+ normalizeRenderedWidth(width) {
1799
+ if (!Number.isFinite(width)) return 0;
1800
+ const devicePixelRatio = this.#document.defaultView?.devicePixelRatio ?? 1;
1801
+ return Math.max(0, Math.round(width * devicePixelRatio) / devicePixelRatio);
1802
+ }
1803
+ reconcileEditSession() {
1804
+ const context = this.#editContext();
1805
+ const session = this.#editSession();
1806
+ if (context == null || session == null || session.operation !== "update") return;
1807
+ const row = this.rows().firstOrDefault((candidate) => candidate.uid === context.rowUid);
1808
+ const shownRows = this.virtualScrollOptions().enabled ? this.viewRows() : this.viewPageRows();
1809
+ if (row == null || !shownRows.any((candidate) => candidate.uid === context.rowUid)) {
1810
+ const rowData = this.sessionRowData(session);
1811
+ this.cancel$.next(new GridCancelEvent({
1812
+ operation: "update",
1813
+ reason: "removed",
1814
+ rowData,
1815
+ session
1816
+ }));
1817
+ this.clearEditSession();
1818
+ return;
1819
+ }
1820
+ if (row === context.row) return;
1821
+ const rebased = {
1822
+ ...session,
1823
+ originalRowData: row.data,
1824
+ row
1825
+ };
1826
+ this.#editSession.set(rebased);
1827
+ this.#editContext.set({
1828
+ ...context,
1829
+ row,
1830
+ session: rebased
1831
+ });
1832
+ }
1833
+ removeRow(row, originalEvent) {
1834
+ const event = new GridRemoveEvent({
1835
+ index: this.rows().toArray().findIndex((candidate) => candidate.uid === row.uid),
1836
+ key: this.getRowUidKey(row.data, this.rowKey()) ?? row.data,
1837
+ originalEvent,
1838
+ rowData: row.data
1839
+ });
1840
+ this.remove$.next(event);
1841
+ return !event.isDefaultPrevented();
1842
+ }
1843
+ reorderColumn(column, beforeIndex) {
1844
+ if (!this.reorderableOptions().enabled) return false;
1845
+ const columnIds = this.columns().select((candidate) => candidate.id).toArray();
1846
+ const oldIndex = columnIds.indexOf(column.id);
1847
+ if (oldIndex < 0 || beforeIndex < 0 || beforeIndex > columnIds.length || beforeIndex === oldIndex || beforeIndex === oldIndex + 1) return false;
1848
+ const event = new ColumnReorderEvent(column, oldIndex, beforeIndex);
1849
+ this.columnReorder$.next(event);
1850
+ if (event.isDefaultPrevented()) return false;
1851
+ const [columnId] = columnIds.splice(oldIndex, 1);
1852
+ columnIds.splice(beforeIndex > oldIndex ? beforeIndex - 1 : beforeIndex, 0, columnId);
1853
+ this.setColumnOrder(columnIds);
1854
+ return true;
1855
+ }
1856
+ requestDataStateChange(options = {}) {
1857
+ if (options.resetPage) {
1858
+ const previousSkip = this.paginationState().skip;
1859
+ this.setPageState({ skip: 0 });
1860
+ if (!this.serverBindingEnabled() && previousSkip !== 0) this.pageReset$.next();
1861
+ }
1862
+ if (!this.serverBindingEnabled()) return;
1863
+ if (this.#dataStateEmissionPending) return;
1864
+ this.#dataStateEmissionPending = true;
1865
+ queueMicrotask(() => {
1866
+ this.#dataStateEmissionPending = false;
1867
+ if (this.serverBindingEnabled()) this.dataStateChange$.next(this.getDataState());
1868
+ });
1869
+ }
1870
+ requestRowReorder(row, previousPageIndex, currentPageIndex) {
1871
+ if (!this.rowReorderInteractionEnabled()) return false;
1872
+ if (previousPageIndex === currentPageIndex) return false;
1873
+ if (!this.canReorderRow(row)) return false;
1874
+ const pageRows = this.viewPageRows();
1875
+ if (previousPageIndex < 0 || previousPageIndex >= pageRows.length || currentPageIndex < 0 || currentPageIndex >= pageRows.length) return false;
1876
+ const pageRow = pageRows.get(previousPageIndex);
1877
+ if (pageRow == null || pageRow.uid !== row.uid) return false;
1878
+ const skip = this.paginationState().skip;
1879
+ const previousIndex = skip + previousPageIndex;
1880
+ const currentIndex = skip + currentPageIndex;
1881
+ const reorderedData = this.rows().select((sourceRow) => sourceRow.data).toArray();
1882
+ const [moved] = reorderedData.splice(previousIndex, 1);
1883
+ if (moved == null) return false;
1884
+ reorderedData.splice(currentIndex, 0, moved);
1885
+ const event = new RowReorderEvent({
1886
+ currentIndex,
1887
+ currentPageIndex,
1888
+ previousIndex,
1889
+ previousPageIndex,
1890
+ reorderedData,
1891
+ rowData: row.data
1892
+ });
1893
+ this.rowReorder$.next(event);
1894
+ return !event.isDefaultPrevented();
1895
+ }
1896
+ resolveAggregateValue(bucket, aggregateFunction) {
1897
+ if (bucket == null || aggregateFunction == null || aggregateFunction === "custom") return null;
1898
+ switch (aggregateFunction) {
1899
+ case "avg": return bucket.avg ?? null;
1900
+ case "count": return bucket.count ?? 0;
1901
+ case "max": return bucket.max ?? null;
1902
+ case "min": return bucket.min ?? null;
1903
+ case "sum": return bucket.sum ?? null;
1904
+ }
1905
+ }
1906
+ saveAddRow(originalEvent) {
1907
+ const session = this.#editSession();
1908
+ if (session == null || session.operation !== "create") return false;
1909
+ if (!this.validateSessionForSave(session)) return false;
1910
+ const event = new GridSaveEvent({
1911
+ operation: "create",
1912
+ originalEvent,
1913
+ rowData: this.resolveSessionRowData(session),
1914
+ session
1915
+ });
1916
+ this.save$.next(event);
1917
+ if (event.isDefaultPrevented()) return false;
1918
+ this.clearEditSession();
1919
+ return true;
1920
+ }
1921
+ selectAllRowsFromKeyboard() {
1922
+ const options = this.selectableOptions();
1923
+ if (!options.enabled || options.mode !== "multiple") return false;
1924
+ this.setBulkSelection(true);
1925
+ return true;
1926
+ }
1927
+ selectRow(row) {
1928
+ this.setRowSelected(row, true);
1929
+ }
1930
+ selectRowFromKeyboard(rowUid, extend) {
1931
+ const options = this.selectableOptions();
1932
+ if (!options.enabled) return false;
1933
+ const row = this.viewRows().firstOrDefault((viewRow) => viewRow.uid === rowUid);
1934
+ if (row == null) return false;
1935
+ if (options.mode === "single") this.handleSingleSelection({
1936
+ ctrlKey: true,
1937
+ metaKey: false,
1938
+ shiftKey: false
1939
+ }, row);
1940
+ else this.handleMultipleSelection({
1941
+ ctrlKey: !extend,
1942
+ metaKey: false,
1943
+ shiftKey: extend
1944
+ }, row);
1945
+ return true;
1946
+ }
1947
+ setBulkSelection(selected) {
1948
+ if (this.selectableOptions().mode !== "multiple") return;
1949
+ const keys = this.bulkSelectionRows().select((row) => this.getRowSelectionKey(row)).toArray();
1950
+ if (selected) {
1951
+ this.selectedKeys.update((currentKeys) => currentKeys.addAll(keys));
1952
+ return;
1953
+ }
1954
+ const keysToRemove = new Set(keys);
1955
+ this.selectedKeys.update((currentKeys) => ImmutableSet.create([...currentKeys].filter((key) => !keysToRemove.has(key))));
1956
+ }
1957
+ setCalculatedWidth(columnId, value) {
1958
+ this.updateColumn(columnId, { calculatedWidth: value });
1959
+ }
1960
+ setCalculatedWidths(widthByColumnId) {
1961
+ this.updateColumns((column) => widthByColumnId.has(column.id) ? {
1962
+ ...column,
1963
+ calculatedWidth: widthByColumnId.get(column.id) ?? null
1964
+ } : column);
1965
+ }
1966
+ setColumnDefinitions(configs) {
1967
+ const currentColumns = this.columns().toArray();
1968
+ const currentById = new Map(currentColumns.map((column) => [column.id, column]));
1969
+ const configsById = new Map(configs.map((config) => [config.id, config]));
1970
+ const currentConfigIds = new Set(currentColumns.map((column) => column.id));
1971
+ const orderedConfigs = [...currentColumns.map((column) => configsById.get(column.id)).filter((config) => config != null), ...configs.filter((config) => !currentConfigIds.has(config.id))];
1972
+ const nextColumns = this.withColumnIndices(this.orderColumnsByLockBucket(orderedConfigs.map((config) => this.reconcileColumn(config, currentById.get(config.id)))));
1973
+ const nextColumnIds = new Set(nextColumns.map((column) => column.id));
1974
+ this.columns.set(ImmutableList.create(nextColumns));
1975
+ this.#groupColumnIds.update((ids) => ids.where((id) => nextColumnIds.has(id)).toImmutableList());
1976
+ this.syncColumnSortState();
1977
+ this.syncColumnFilterState();
1978
+ const groupedFields = new Set(this.groupColumns().select((column) => column.field));
1979
+ if (this.#groupRequest.some((descriptor) => !groupedFields.has(descriptor.field) && nextColumns.some((column) => column.field === descriptor.field && column.kind !== "command"))) this.loadGroupColumns(this.#groupRequest);
1980
+ }
1981
+ setColumnFiltered(columnId, value) {
1982
+ this.updateColumn(columnId, { filtered: value });
1983
+ }
1984
+ setColumnGroupSortDirection(columnId, value) {
1985
+ this.updateColumn(columnId, { groupSortDirection: value });
1986
+ }
1987
+ setColumnHidden(columnId, value) {
1988
+ this.updateColumn(columnId, { hidden: value });
1989
+ }
1990
+ setColumnOrder(columnIds) {
1991
+ const columnsById = new Map(this.columns().select((column) => [column.id, column]));
1992
+ const orderedColumns = columnIds.map((id) => columnsById.get(id)).filter((column) => column != null);
1993
+ const orderedIds = new Set(orderedColumns.map((column) => column.id));
1994
+ orderedColumns.push(...this.columns().where((column) => !orderedIds.has(column.id)).toArray());
1995
+ this.columns.set(ImmutableList.create(this.withColumnIndices(this.orderColumnsByLockBucket(orderedColumns))));
1996
+ }
1997
+ setColumnSortDirection(columnId, value) {
1998
+ this.updateColumn(columnId, { columnSortDirection: value });
1999
+ }
2000
+ setColumnSortIndex(columnId, value) {
2001
+ this.updateColumn(columnId, { sortIndex: value });
2002
+ }
2003
+ setColumnVisibilityByFields(visibleFields) {
2004
+ this.updateColumns((column) => ({
2005
+ ...column,
2006
+ hidden: !visibleFields.contains(column.field)
2007
+ }));
2008
+ }
2009
+ setEditableOptions(options) {
2010
+ this.editableOptions.set({
2011
+ mode: "cell",
2012
+ ...options,
2013
+ enabled: options.enabled !== false
2014
+ });
2015
+ }
2016
+ setFilterableOptions(options) {
2017
+ this.#filterableOptions.set({
2018
+ type: "menu",
2019
+ ...options,
2020
+ enabled: options.enabled !== false
2021
+ });
2022
+ }
2023
+ setGroupSortDirection(column, dir) {
2024
+ this.setColumnGroupSortDirection(column.id, dir);
2025
+ this.emitGroupChange();
2026
+ }
2027
+ setGroupableOptions(options) {
2028
+ this.groupableOptions.set({
2029
+ showFooter: false,
2030
+ ...options,
2031
+ enabled: options.enabled !== false
2032
+ });
2033
+ }
2034
+ setNewRowFactory(factory) {
2035
+ this.newRowFactory.set(factory);
2036
+ }
2037
+ setPageState(state) {
2038
+ const current = this.paginationState();
2039
+ let take = state.take ?? current.take;
2040
+ let skip = state.skip ?? (state.page != null ? (state.page - 1) * take : current.skip);
2041
+ if (this.serverBindingEnabled()) {
2042
+ this.validateServerInteger(skip, "skip");
2043
+ if (!Number.isSafeInteger(take) || take <= 0) throw new Error("monaGridServerBinding: pageSize must be a finite positive integer.");
2044
+ } else {
2045
+ take = Number.isSafeInteger(take) && take > 0 ? take : current.take;
2046
+ skip = Number.isFinite(skip) && skip > 0 ? Math.floor(skip) : 0;
2047
+ }
2048
+ const page = Math.floor(skip / take) + 1;
2049
+ if (current.skip !== skip || current.take !== take || current.page !== page) this.paginationState.set({
2050
+ skip,
2051
+ take,
2052
+ page
2053
+ });
2054
+ }
2055
+ setReorderableOptions(options) {
2056
+ this.#reorderableOptions.set({
2057
+ ...options,
2058
+ enabled: options.enabled !== false
2059
+ });
2060
+ }
2061
+ setResizableOptions(options) {
2062
+ this.#resizableOptions.set({
2063
+ ...options,
2064
+ enabled: options.enabled !== false
2065
+ });
2066
+ }
2067
+ setRowExpanded(row, expanded) {
2068
+ const key = this.getRowIdentityKey(row);
2069
+ const keys = this.expandedKeys();
2070
+ if (keys.contains(key) === expanded) return;
2071
+ this.expandedKeys.set(expanded ? keys.add(key) : keys.remove(key));
2072
+ this.expandedKeysChange$.next(this.expandedKeys().toArray());
2073
+ }
2074
+ setRowKey(rowKey) {
2075
+ if (this.rowKey() === rowKey) return;
2076
+ this.rowKey.set(rowKey);
2077
+ this.updateColumns((column) => {
2078
+ const editable = this.resolveEditable(column);
2079
+ return editable === column.editable ? column : {
2080
+ ...column,
2081
+ editable
2082
+ };
2083
+ });
2084
+ }
2085
+ setRowReorderableOptions(options) {
2086
+ this.#rowReorderableOptions.set(options);
2087
+ }
2088
+ setRowSelected(row, selected) {
2089
+ const key = this.getRowSelectionKey(row);
2090
+ const mode = this.selectableOptions().mode;
2091
+ if (selected) {
2092
+ if (mode === "single") this.selectedKeys.set(ImmutableSet.create([key]));
2093
+ else this.selectedKeys.update((keys) => keys.add(key));
2094
+ return;
2095
+ }
2096
+ this.selectedKeys.update((keys) => keys.remove(key));
2097
+ }
2098
+ setRows(value, rowKey = null) {
2099
+ const occurrences = /* @__PURE__ */ new Map();
2100
+ let duplicateKey = false;
2101
+ const rows = [];
2102
+ for (const data of value) {
2103
+ const uid = this.getRowUid(data, rowKey);
2104
+ const occurrence = (occurrences.get(uid) ?? 0) + 1;
2105
+ occurrences.set(uid, occurrence);
2106
+ if (occurrence > 1 && rowKey) duplicateKey = true;
2107
+ rows.push(new Row(data, occurrence === 1 ? uid : `${uid}#${occurrence}`));
2108
+ }
2109
+ if (duplicateKey && isDevMode()) console.warn("mona-grid: several rows have the same rowKey value. Selection, editing and detail rows follow the key, so give every row a unique key.");
2110
+ this.rows.set(ImmutableList.create(rows));
2111
+ }
2112
+ setScrollEndThreshold(threshold) {
2113
+ this.scrollEndThreshold.set(threshold);
2114
+ }
2115
+ setSelectableOptions(options) {
2116
+ this.selectableOptions.set({
2117
+ mode: "single",
2118
+ selectAllScope: "page",
2119
+ selectOnRowClick: false,
2120
+ showCheckboxes: false,
2121
+ showSelectAll: true,
2122
+ ...options,
2123
+ enabled: options.enabled !== false
2124
+ });
2125
+ }
2126
+ setServerBindingEnabled(enabled) {
2127
+ if (enabled && this.virtualScrollOptions().enabled) throw new Error("monaGridServerBinding and monaGridVirtualScroll cannot be enabled together.");
2128
+ this.#serverBindingEnabled.set(enabled);
2129
+ }
2130
+ setServerLoading(loading) {
2131
+ this.#serverLoading.set(loading);
2132
+ }
2133
+ setServerSkip(skip) {
2134
+ this.validateServerInteger(skip, "skip");
2135
+ this.setPageState({
2136
+ skip,
2137
+ page: Math.floor(skip / this.paginationState().take) + 1
2138
+ });
2139
+ }
2140
+ setServerTotal(total) {
2141
+ this.validateServerInteger(total, "total");
2142
+ this.#serverTotal.set(total);
2143
+ }
2144
+ setSortableOptions(options) {
2145
+ this.sortableOptions.set({
2146
+ mode: "single",
2147
+ allowUnsort: true,
2148
+ showIndices: true,
2149
+ ...options,
2150
+ enabled: options.enabled !== false
2151
+ });
2152
+ }
2153
+ setVirtualScrollOptions(options) {
2154
+ const height = options.height ?? this.virtualScrollOptions().height ?? 36;
2155
+ if (!Number.isFinite(height) || height <= 0) throw new Error("monaGridVirtualScroll: height must be finite and greater than zero.");
2156
+ if (options.enabled && this.serverBindingEnabled()) throw new Error("monaGridServerBinding and monaGridVirtualScroll cannot be enabled together.");
2157
+ this.virtualScrollOptions.update((v) => ({
2158
+ ...v,
2159
+ ...options,
2160
+ height
2161
+ }));
2162
+ }
2163
+ startAddRow(originalEvent) {
2164
+ const activeSession = this.#editSession();
2165
+ if (activeSession?.operation === "create") return true;
2166
+ if (activeSession?.operation === "update" && !this.cancelEdit(originalEvent, "switch")) return false;
2167
+ const rowData = this.newRowFactory()();
2168
+ const session = this.createEditSession({
2169
+ column: null,
2170
+ field: null,
2171
+ isNew: true,
2172
+ mode: this.editableOptions().mode,
2173
+ operation: "create",
2174
+ originalRowData: null,
2175
+ row: null,
2176
+ rowData,
2177
+ rowUid: null
2178
+ });
2179
+ const addEvent = new GridAddEvent({
2180
+ originalEvent,
2181
+ rowData: this.resolveSessionRowData(session),
2182
+ session
2183
+ });
2184
+ this.add$.next(addEvent);
2185
+ if (addEvent.isDefaultPrevented()) return false;
2186
+ this.#editSession.set(session);
2187
+ return true;
2188
+ }
2189
+ startCellEdit(uid, row, column, originalEvent) {
2190
+ if (this.editableOptions().mode !== "cell") return false;
2191
+ const activeSession = this.#editSession();
2192
+ if (activeSession?.operation === "create" && !this.cancelAddRow(originalEvent, "switch")) return false;
2193
+ if (activeSession?.operation === "update" && !this.cancelEdit(originalEvent, "switch")) return false;
2194
+ const session = this.createEditSession({
2195
+ column,
2196
+ field: column.field,
2197
+ isNew: false,
2198
+ mode: "cell",
2199
+ operation: "update",
2200
+ originalRowData: row.data,
2201
+ row,
2202
+ rowData: row.data,
2203
+ rowUid: row.uid
2204
+ });
2205
+ const editEvent = new GridEditEvent({
2206
+ originalEvent,
2207
+ rowData: row.data,
2208
+ session
2209
+ });
2210
+ this.edit$.next(editEvent);
2211
+ if (editEvent.isDefaultPrevented()) return false;
2212
+ this.#editSession.set(session);
2213
+ this.#editContext.set({
2214
+ cellUid: uid,
2215
+ columnId: column.id,
2216
+ mode: "cell",
2217
+ row,
2218
+ rowUid: row.uid,
2219
+ session
2220
+ });
2221
+ return true;
2222
+ }
2223
+ startRowEdit(row, originalEvent, focusColumnId = null) {
2224
+ if (this.editableOptions().mode !== "row") return false;
2225
+ const activeSession = this.#editSession();
2226
+ if (activeSession?.operation === "create" && !this.cancelAddRow(originalEvent, "switch")) return false;
2227
+ if (activeSession?.operation === "update" && !this.cancelEdit(originalEvent, "switch")) return false;
2228
+ const session = this.createEditSession({
2229
+ column: null,
2230
+ field: null,
2231
+ isNew: false,
2232
+ mode: "row",
2233
+ operation: "update",
2234
+ originalRowData: row.data,
2235
+ row,
2236
+ rowData: row.data,
2237
+ rowUid: row.uid
2238
+ });
2239
+ const editEvent = new GridEditEvent({
2240
+ originalEvent,
2241
+ rowData: row.data,
2242
+ session
2243
+ });
2244
+ this.edit$.next(editEvent);
2245
+ if (editEvent.isDefaultPrevented()) return false;
2246
+ this.#editSession.set(session);
2247
+ this.#editContext.set({
2248
+ focusColumnId,
2249
+ mode: "row",
2250
+ row,
2251
+ rowUid: row.uid,
2252
+ session
2253
+ });
2254
+ return true;
2255
+ }
2256
+ stopCellEdit(originalEvent) {
2257
+ const context = this.#editContext();
2258
+ const session = this.#editSession();
2259
+ if (!context || context.mode !== "cell" || session == null) return false;
2260
+ const column = this.getColumnById(context.columnId);
2261
+ if (column == null) return false;
2262
+ if (!this.validateSessionForSave(session)) return false;
2263
+ const rowData = this.resolveEditedRowData(context.rowUid, context.row.data);
2264
+ const oldValue = context.row.data[column.field];
2265
+ const resolvedValue = rowData[column.field];
2266
+ if (sameCellValue(oldValue, resolvedValue)) {
2267
+ this.clearEditSession();
2268
+ return true;
2269
+ }
2270
+ const event = new CellEditEvent({
2271
+ field: column.field,
2272
+ newValue: resolvedValue,
2273
+ oldValue,
2274
+ rowData: context.row.data,
2275
+ session
2276
+ });
2277
+ this.cellEdit$.next(event);
2278
+ if (event.isDefaultPrevented()) return false;
2279
+ const saveEvent = new GridSaveEvent({
2280
+ operation: "update",
2281
+ originalEvent,
2282
+ originalRowData: context.row.data,
2283
+ rowData,
2284
+ session
2285
+ });
2286
+ this.save$.next(saveEvent);
2287
+ if (saveEvent.isDefaultPrevented()) return false;
2288
+ this.clearEditSession();
2289
+ return true;
2290
+ }
2291
+ toggleGroupCollapse(groupKey) {
2292
+ this.collapsedGroupKeys.update((keys) => keys.contains(groupKey) ? keys.remove(groupKey) : keys.add(groupKey));
2293
+ }
2294
+ updateColumn(columnId, patch) {
2295
+ this.updateColumns((column) => {
2296
+ if (column.id !== columnId) return column;
2297
+ return Object.keys(patch).some((key) => column[key] !== patch[key]) ? {
2298
+ ...column,
2299
+ ...patch
2300
+ } : column;
2301
+ });
2302
+ }
2303
+ announceInvalid(session) {
2304
+ const messages = this.messages();
2305
+ const field = session.mode === "cell" && session.field != null ? session.form[session.field] : null;
2306
+ const message = (field != null ? [...field().errors(), ...session.form().errors()] : session.form().errorSummary()).find((error) => !!error.message)?.message || (field != null ? messages.fieldValidationError : messages.rowValidationError);
2307
+ if (message) this.#liveAnnouncer.announce(message, "polite");
2308
+ }
2309
+ applyColumnIndexes(columns) {
2310
+ return this.withColumnIndices(columns);
2311
+ }
2312
+ buildGroupAggregates(rows, groupColumns, aggregateColumns, depth, parentKey, aggregates) {
2313
+ const column = groupColumns[depth];
2314
+ if (column == null) return;
2315
+ for (const { rows: groupRows, value: groupValue } of groupRowsByField(rows, column.field)) {
2316
+ const groupKey = buildGroupKey(parentKey, column.field, groupValue);
2317
+ if (depth < groupColumns.length - 1) this.buildGroupAggregates(groupRows, groupColumns, aggregateColumns, depth + 1, groupKey, aggregates);
2318
+ aggregates.put(groupKey, {
2319
+ aggregates: this.createAggregateMap(groupRows, aggregateColumns),
2320
+ count: groupRows.length,
2321
+ depth,
2322
+ groupKey,
2323
+ groupValue,
2324
+ rows: groupRows.map((row) => row.data)
2325
+ });
2326
+ }
2327
+ }
2328
+ clearEditSession() {
2329
+ this.#editContext.set(null);
2330
+ this.#editSession.set(null);
2331
+ }
2332
+ cloneFilter(filter) {
2333
+ return {
2334
+ ...filter,
2335
+ filters: filter.filters.map((descriptor) => "filters" in descriptor ? this.cloneFilter(descriptor) : "value" in descriptor ? {
2336
+ ...descriptor,
2337
+ value: this.cloneFilterValue(descriptor.value)
2338
+ } : { ...descriptor })
2339
+ };
2340
+ }
2341
+ cloneFilterValue(value) {
2342
+ if (value instanceof Date) return new Date(value.getTime());
2343
+ if (Array.isArray(value)) return value.map((item) => this.cloneFilterValue(item));
2344
+ if (value != null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, this.cloneFilterValue(item)]));
2345
+ return value;
2346
+ }
2347
+ createAggregateBucket(rows, column) {
2348
+ const field = column.field;
2349
+ if (column.aggregate === "custom" || column.aggregate == null) return { field };
2350
+ let count = 0;
2351
+ let max;
2352
+ let min;
2353
+ let numericCount = 0;
2354
+ let sumValue = 0;
2355
+ for (const row of rows) {
2356
+ const value = row.data[field];
2357
+ if (value == null) continue;
2358
+ count += 1;
2359
+ const numeric = toAggregateNumber(value);
2360
+ if (numeric != null) {
2361
+ sumValue += numeric;
2362
+ numericCount += 1;
2363
+ }
2364
+ if (!isAggregateComparable(value)) continue;
2365
+ const options = { locale: this.#i18n.localeId() };
2366
+ if (min == null || compareValues(value, min, options) < 0) min = value;
2367
+ if (max == null || compareValues(value, max, options) > 0) max = value;
2368
+ }
2369
+ return {
2370
+ avg: numericCount > 0 ? sumValue / numericCount : void 0,
2371
+ count,
2372
+ field,
2373
+ max,
2374
+ min,
2375
+ sum: sumValue
2376
+ };
2377
+ }
2378
+ createAggregateMap(rows, columns) {
2379
+ const aggregates = new Dictionary();
2380
+ for (const column of columns) aggregates.put(column.field, this.createAggregateBucket(rows, column));
2381
+ return aggregates.toImmutableDictionary((e) => e.key, (e) => e.value);
2382
+ }
2383
+ createEditSession(options) {
2384
+ const seeded = /* @__PURE__ */ new Map();
2385
+ const values = { ...options.rowData };
2386
+ for (const column of this.columns()) {
2387
+ if (column.kind !== "data" || !column.editable || column.field === "" || values[column.field] !== void 0) continue;
2388
+ seeded.set(column.field, column.field in values);
2389
+ values[column.field] = null;
2390
+ }
2391
+ const model = signal(values, ...ngDevMode ? [{ debugName: "model" }] : /* istanbul ignore next */ []);
2392
+ if (seeded.size > 0) this.#seededFields.set(model, seeded);
2393
+ const context = {
2394
+ column: options.column,
2395
+ field: options.field,
2396
+ isNew: options.isNew,
2397
+ mode: options.mode,
2398
+ operation: options.operation,
2399
+ originalRowData: options.originalRowData,
2400
+ rowData: options.rowData
2401
+ };
2402
+ const schema = this.editableOptions().schema?.(context) ?? null;
2403
+ const editForm = schema == null ? form(model, { injector: this.#injector }) : form(model, schema, { injector: this.#injector });
2404
+ return {
2405
+ column: options.column,
2406
+ field: options.field,
2407
+ form: editForm,
2408
+ isNew: options.isNew,
2409
+ mode: options.mode,
2410
+ model,
2411
+ operation: options.operation,
2412
+ originalRowData: options.originalRowData,
2413
+ row: options.row,
2414
+ rowUid: options.rowUid
2415
+ };
2416
+ }
2417
+ deserializeCompositeFilter(filter) {
2418
+ const filters = filter.filters.map((child) => "filters" in child ? this.deserializeCompositeFilter(child) : this.deserializeFilterDescriptor(child)).filter((child) => child != null);
2419
+ return filters.length === 0 ? null : {
2420
+ filters,
2421
+ logic: filter.logic
2422
+ };
2423
+ }
2424
+ deserializeFilterDescriptor(filter) {
2425
+ const column = this.columns().firstOrDefault((column) => column.field === filter.field);
2426
+ if (column == null) return null;
2427
+ if ("value" in filter) return {
2428
+ field: filter.field,
2429
+ operator: filter.operator,
2430
+ value: this.deserializeFilterValue(filter.value, column)
2431
+ };
2432
+ return {
2433
+ field: filter.field,
2434
+ operator: filter.operator
2435
+ };
2436
+ }
2437
+ deserializeFilterValue(value, column) {
2438
+ if (Array.isArray(value)) return value.map((item) => this.deserializeFilterValue(item, column));
2439
+ if (typeof value === "string" && column.dataType === "date") return new Date(value);
2440
+ return value;
2441
+ }
2442
+ deserializeFilters(filters) {
2443
+ return filters.map((filter) => this.deserializeCompositeFilter(filter)).filter((filter) => filter != null);
2444
+ }
2445
+ emitGroupChange() {
2446
+ const groups = this.getGroupDescriptors(this.groupColumns());
2447
+ this.#groupRequest = groups;
2448
+ this.groupChange$.next(groups);
2449
+ }
2450
+ findLongestCellContentOfColumn(column) {
2451
+ let maxLength = 0;
2452
+ let longestValue = "";
2453
+ for (const row of this.rows()) {
2454
+ const value = row.data[column.field];
2455
+ if (value != null) {
2456
+ maxLength = Math.max(maxLength, value.toString().length);
2457
+ if (maxLength === value.toString().length) longestValue = value.toString();
2458
+ }
2459
+ }
2460
+ return longestValue;
2461
+ }
2462
+ getColumnById(columnId) {
2463
+ return this.columns().firstOrDefault((column) => column.id === columnId);
2464
+ }
2465
+ getColumnLockBucket(column) {
2466
+ return column.locked ? column.lockedPosition : "unlocked";
2467
+ }
2468
+ getRowDataItemSelectionKey(data) {
2469
+ const selectBy = this.selectBy();
2470
+ if (!selectBy) return this.getRowUidKey(data, this.rowKey()) ?? data;
2471
+ if (typeof selectBy === "string") return data[selectBy];
2472
+ return selectBy(data);
2473
+ }
2474
+ getRowIdentityKey(row) {
2475
+ return this.getRowUidKey(row.data, this.rowKey()) ?? row.data;
2476
+ }
2477
+ getRowSelectionKey(row) {
2478
+ return this.getRowDataItemSelectionKey(row.data);
2479
+ }
2480
+ getRowUid(data, rowKey) {
2481
+ const key = this.getRowUidKey(data, rowKey);
2482
+ if (key != null) {
2483
+ if (typeof key === "object" || typeof key === "function") {
2484
+ const cachedKeyUid = this.#rowUidByKeyObject.get(key);
2485
+ if (cachedKeyUid != null) return cachedKeyUid;
2486
+ const keyUid = v4();
2487
+ this.#rowUidByKeyObject.set(key, keyUid);
2488
+ return keyUid;
2489
+ }
2490
+ return `key:${typeof key}:${String(key)}`;
2491
+ }
2492
+ const cachedUid = this.#rowUidByData.get(data);
2493
+ if (cachedUid != null) return cachedUid;
2494
+ const uid = v4();
2495
+ this.#rowUidByData.set(data, uid);
2496
+ return uid;
2497
+ }
2498
+ getRowUidKey(data, rowKey) {
2499
+ if (!rowKey) return null;
2500
+ if (typeof rowKey === "string") return data[rowKey];
2501
+ return rowKey(data);
2502
+ }
2503
+ measureElementScrollbarGutter(element) {
2504
+ return Math.max(0, element.offsetWidth - element.clientWidth) - 1;
2505
+ }
2506
+ measureFallbackScrollbarGutter() {
2507
+ if (!isPlatformBrowser(this.#platformId)) return 0;
2508
+ const measurementElement = this.#document.createElement("div");
2509
+ measurementElement.style.position = "absolute";
2510
+ measurementElement.style.top = "-9999px";
2511
+ measurementElement.style.width = "100px";
2512
+ measurementElement.style.height = "100px";
2513
+ measurementElement.style.overflow = "scroll";
2514
+ measurementElement.style.border = "0";
2515
+ measurementElement.style.padding = "0";
2516
+ this.#document.body.appendChild(measurementElement);
2517
+ const gutterWidth = this.measureElementScrollbarGutter(measurementElement);
2518
+ measurementElement.remove();
2519
+ return gutterWidth;
2520
+ }
2521
+ orderColumnsByLockBucket(columns) {
2522
+ const leftLockedColumns = columns.filter((column) => this.getColumnLockBucket(column) === "left");
2523
+ const unlockedColumns = columns.filter((column) => this.getColumnLockBucket(column) === "unlocked");
2524
+ const rightLockedColumns = columns.filter((column) => this.getColumnLockBucket(column) === "right");
2525
+ return [
2526
+ ...leftLockedColumns,
2527
+ ...unlockedColumns,
2528
+ ...rightLockedColumns
2529
+ ];
2530
+ }
2531
+ reconcileColumn(config, previous) {
2532
+ const hidden = previous != null && previous.configuredHidden === config.hidden ? previous.hidden : config.hidden;
2533
+ return {
2534
+ ...config,
2535
+ calculatedWidth: previous?.calculatedWidth ?? null,
2536
+ columnSortDirection: previous?.columnSortDirection ?? null,
2537
+ configuredHidden: config.hidden,
2538
+ filtered: previous?.filtered ?? false,
2539
+ groupSortDirection: previous?.groupSortDirection ?? null,
2540
+ hidden,
2541
+ index: previous?.index ?? 0,
2542
+ editable: this.resolveEditable(config),
2543
+ minWidth: config.minWidth,
2544
+ sortIndex: previous?.sortIndex ?? null
2545
+ };
2546
+ }
2547
+ resolveEditable(column) {
2548
+ if (column.configuredEditable === void 0) return column.editable;
2549
+ if (column.configuredEditable !== null) return column.configuredEditable;
2550
+ const rowKey = this.rowKey();
2551
+ return !(typeof rowKey === "string" && rowKey === column.field);
2552
+ }
2553
+ resolveEditedRowData(rowUid, fallbackRowData) {
2554
+ const editedRowData = this.editViewDict().get(rowUid);
2555
+ if (editedRowData == null) return fallbackRowData;
2556
+ const { $rowId: _rowId, ...rowData } = editedRowData;
2557
+ return rowData;
2558
+ }
2559
+ resolveSessionRowData(session) {
2560
+ return this.sessionRowData(session);
2561
+ }
2562
+ selectRowRange(row) {
2563
+ const anchorKey = this.#anchorRowKey();
2564
+ const targetKey = this.getRowSelectionKey(row);
2565
+ if (anchorKey == null) {
2566
+ this.deselectAllRows();
2567
+ this.selectRow(row);
2568
+ this.#anchorRowKey.set(targetKey);
2569
+ return;
2570
+ }
2571
+ const rows = this.bulkSelectionRows().toArray();
2572
+ const anchorIndex = rows.findIndex((r) => this.getRowSelectionKey(r) === anchorKey);
2573
+ const targetIndex = rows.findIndex((r) => this.getRowSelectionKey(r) === targetKey);
2574
+ if (anchorIndex === -1 || targetIndex === -1) {
2575
+ this.deselectAllRows();
2576
+ this.selectRow(row);
2577
+ this.#anchorRowKey.set(targetKey);
2578
+ return;
2579
+ }
2580
+ const [start, end] = anchorIndex <= targetIndex ? [anchorIndex, targetIndex] : [targetIndex, anchorIndex];
2581
+ const rangeKeys = rows.slice(start, end + 1).map((r) => this.getRowSelectionKey(r));
2582
+ this.selectedKeys.set(ImmutableSet.create(rangeKeys));
2583
+ }
2584
+ serializeFilter(filter) {
2585
+ if (filter == null) return null;
2586
+ const filters = filter.filters.map((child) => "filters" in child ? this.serializeFilter(child) : this.serializeFilterDescriptor(child)).filter((child) => child != null);
2587
+ return filters.length === 0 ? null : {
2588
+ filters,
2589
+ logic: filter.logic
2590
+ };
2591
+ }
2592
+ serializeFilterDescriptor(filter) {
2593
+ if (filter.operator === "function") return null;
2594
+ const descriptor = {
2595
+ field: filter.field,
2596
+ operator: filter.operator
2597
+ };
2598
+ if ("value" in filter) {
2599
+ const value = this.serializeFilterValue(filter.value);
2600
+ if (value === void 0) return null;
2601
+ descriptor.value = value;
2602
+ }
2603
+ return descriptor;
2604
+ }
2605
+ serializeFilterValue(value) {
2606
+ if (value instanceof Date) return value.toISOString();
2607
+ if (Array.isArray(value)) {
2608
+ const values = value.map((item) => this.serializeFilterValue(item));
2609
+ return values.every((item) => item !== void 0) ? values : void 0;
2610
+ }
2611
+ if (value == null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") return value;
2612
+ }
2613
+ sessionRowData(session) {
2614
+ const rowData = { ...session.model() };
2615
+ const seeded = this.#seededFields.get(session.model);
2616
+ if (seeded == null) return rowData;
2617
+ for (const [field, hadKey] of seeded) {
2618
+ if (rowData[field] !== null) continue;
2619
+ if (hadKey) rowData[field] = void 0;
2620
+ else delete rowData[field];
2621
+ }
2622
+ return rowData;
2623
+ }
2624
+ setElementScrollLeft(element, scrollLeft) {
2625
+ if (element != null && element.scrollLeft !== scrollLeft) element.scrollLeft = scrollLeft;
2626
+ }
2627
+ setHorizontalScrollLeft(scrollLeft) {
2628
+ if (this.#horizontalScrollLeft() !== scrollLeft) this.#horizontalScrollLeft.set(scrollLeft);
2629
+ }
2630
+ setHorizontalScrollSyncEffects() {
2631
+ effect((onCleanup) => {
2632
+ const headerElement = this.gridHeaderElement();
2633
+ const bodyElement = this.bodyScrollElement();
2634
+ const footerElement = this.footerScrollElement();
2635
+ const cleanups = [];
2636
+ if (headerElement != null) {
2637
+ const onHeaderScroll = () => this.setHorizontalScrollLeft(headerElement.scrollLeft);
2638
+ headerElement.addEventListener("scroll", onHeaderScroll);
2639
+ cleanups.push(() => headerElement.removeEventListener("scroll", onHeaderScroll));
2640
+ }
2641
+ if (bodyElement != null) {
2642
+ const onBodyScroll = () => this.setHorizontalScrollLeft(bodyElement.scrollLeft);
2643
+ bodyElement.addEventListener("scroll", onBodyScroll);
2644
+ cleanups.push(() => bodyElement.removeEventListener("scroll", onBodyScroll));
2645
+ }
2646
+ if (footerElement != null) {
2647
+ const onFooterScroll = () => this.setHorizontalScrollLeft(footerElement.scrollLeft);
2648
+ footerElement.addEventListener("scroll", onFooterScroll);
2649
+ cleanups.push(() => footerElement.removeEventListener("scroll", onFooterScroll));
2650
+ }
2651
+ onCleanup(() => cleanups.forEach((cleanup) => cleanup()));
2652
+ });
2653
+ effect(() => {
2654
+ const scrollLeft = this.#horizontalScrollLeft();
2655
+ this.setElementScrollLeft(this.gridHeaderElement(), scrollLeft);
2656
+ this.setElementScrollLeft(this.bodyScrollElement(), scrollLeft);
2657
+ this.setElementScrollLeft(this.footerScrollElement(), scrollLeft);
2658
+ });
2659
+ }
2660
+ setScrollbarGutterEffects() {
2661
+ effect((onCleanup) => {
2662
+ const bodyElement = this.bodyScrollElement();
2663
+ if (bodyElement == null) {
2664
+ this.#scrollbarGutterMeasurementSource.set("fallback");
2665
+ this.#scrollbarGutterWidth.set(this.measureFallbackScrollbarGutter());
2666
+ return;
2667
+ }
2668
+ const updateScrollbarGutter = () => {
2669
+ this.#scrollbarGutterMeasurementSource.set("body");
2670
+ this.#scrollbarGutterWidth.set(this.measureElementScrollbarGutter(bodyElement));
2671
+ };
2672
+ updateScrollbarGutter();
2673
+ if (typeof ResizeObserver === "undefined") return;
2674
+ const resizeObserver = new ResizeObserver(() => updateScrollbarGutter());
2675
+ resizeObserver.observe(bodyElement);
2676
+ onCleanup(() => resizeObserver.disconnect());
2677
+ });
2678
+ }
2679
+ syncColumnFilterState() {
2680
+ const filters = this.appliedFilters();
2681
+ this.updateColumns((column) => {
2682
+ const filtered = filters.containsKey(column.field);
2683
+ return column.filtered === filtered ? column : {
2684
+ ...column,
2685
+ filtered
2686
+ };
2687
+ });
2688
+ }
2689
+ syncColumnSortState() {
2690
+ const sorts = this.#sortDescriptors();
2691
+ this.updateColumns((column) => {
2692
+ const index = sorts.findIndex((sort) => sort.field === column.field);
2693
+ const columnSortDirection = index < 0 ? null : sorts[index].dir;
2694
+ const sortIndex = index < 0 ? null : index + 1;
2695
+ return column.columnSortDirection === columnSortDirection && column.sortIndex === sortIndex ? column : {
2696
+ ...column,
2697
+ columnSortDirection,
2698
+ sortIndex
2699
+ };
2700
+ });
2701
+ }
2702
+ updateColumns(updater) {
2703
+ this.columns.update((columns) => {
2704
+ const current = columns.toArray();
2705
+ const next = current.map(updater);
2706
+ if (next.every((column, index) => column === current[index])) return columns;
2707
+ return ImmutableList.create(this.applyColumnIndexes(next));
2708
+ });
2709
+ }
2710
+ validateServerInteger(value, name) {
2711
+ if (!Number.isSafeInteger(value) || value < 0) throw new Error(`monaGridServerBinding: ${name} must be a finite non-negative integer.`);
2712
+ }
2713
+ validateSessionForSave(session) {
2714
+ const rootField = session.form();
2715
+ const editedField = session.mode === "cell" && session.field != null ? session.form[session.field] : null;
2716
+ if (editedField == null) {
2717
+ rootField.markAsTouched();
2718
+ const valid = !rootField.invalid() && !rootField.pending();
2719
+ if (!valid && !rootField.pending()) this.announceInvalid(session);
2720
+ return valid;
2721
+ }
2722
+ const field = editedField();
2723
+ field.markAsTouched();
2724
+ const valid = !field.invalid() && !field.pending() && rootField.errors().length === 0;
2725
+ if (!valid && !field.pending()) this.announceInvalid(session);
2726
+ return valid;
2727
+ }
2728
+ withColumnIndices(columns) {
2729
+ return columns.map((column, index) => column.index === index ? column : {
2730
+ ...column,
2731
+ index
2732
+ });
2733
+ }
2734
+ static {
2735
+ this.ɵfac = i0.ɵɵngDeclareFactory({
2736
+ minVersion: "12.0.0",
2737
+ version: "22.2.6",
2738
+ ngImport: i0,
2739
+ type: GridService,
2740
+ deps: [],
2741
+ target: i0.ɵɵFactoryTarget.Injectable
2742
+ });
2743
+ }
2744
+ static {
2745
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
2746
+ minVersion: "12.0.0",
2747
+ version: "22.2.6",
2748
+ ngImport: i0,
2749
+ type: GridService
2750
+ });
2751
+ }
2752
+ };
2753
+ i0.ɵɵngDeclareClassMetadata({
2754
+ minVersion: "12.0.0",
2755
+ version: "22.2.6",
2756
+ ngImport: i0,
2757
+ type: GridService,
2758
+ decorators: [{ type: Injectable }],
2759
+ ctorParameters: () => []
2760
+ });
2761
+ const STICKY_EDGE_BORDER = "1px solid var(--color-border)";
2762
+ var GridLockedCellDirective = class GridLockedCellDirective {
2763
+ constructor() {
2764
+ this.#gridService = inject(GridService);
2765
+ this.#hostElementRef = inject(ElementRef);
2766
+ this.bodyLocked = computed(() => this.state() != null && !this.lockedCellHeader(), ...ngDevMode ? [{ debugName: "bodyLocked" }] : /* istanbul ignore next */ []);
2767
+ this.endEdge = computed(() => this.state()?.side === "end" && this.state()?.edge === true, ...ngDevMode ? [{ debugName: "endEdge" }] : /* istanbul ignore next */ []);
2768
+ this.endOffset = computed(() => {
2769
+ const state = this.state();
2770
+ return state?.side === "end" ? state.offset : null;
2771
+ }, ...ngDevMode ? [{ debugName: "endOffset" }] : /* istanbul ignore next */ []);
2772
+ this.footerCell = this.#hostElementRef.nativeElement.hasAttribute("monaGridFooterTableCell");
2773
+ this.headerLocked = computed(() => this.state() != null && this.lockedCellHeader(), ...ngDevMode ? [{ debugName: "headerLocked" }] : /* istanbul ignore next */ []);
2774
+ this.startEdge = computed(() => this.state()?.side === "start" && this.state()?.edge === true, ...ngDevMode ? [{ debugName: "startEdge" }] : /* istanbul ignore next */ []);
2775
+ this.startOffset = computed(() => {
2776
+ const state = this.state();
2777
+ return state?.side === "start" ? state.offset : null;
2778
+ }, ...ngDevMode ? [{ debugName: "startOffset" }] : /* istanbul ignore next */ []);
2779
+ this.state = computed(() => {
2780
+ const layoutKey = this.layoutKey();
2781
+ return layoutKey ? this.#gridService.layoutColumnByKey().get(layoutKey)?.sticky ?? null : null;
2782
+ }, ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
2783
+ this.stickyEdgeBorder = STICKY_EDGE_BORDER;
2784
+ this.zIndex = computed(() => {
2785
+ if (this.state() == null) return null;
2786
+ return this.lockedCellHeader() ? 4 : 2;
2787
+ }, ...ngDevMode ? [{ debugName: "zIndex" }] : /* istanbul ignore next */ []);
2788
+ this.layoutKey = input(null, {
2789
+ ...ngDevMode ? { debugName: "layoutKey" } : /* istanbul ignore next */ {},
2790
+ alias: "monaGridLockedCell"
2791
+ });
2792
+ this.lockedCellHeader = input(false, ...ngDevMode ? [{ debugName: "lockedCellHeader" }] : /* istanbul ignore next */ []);
2793
+ }
2794
+ #gridService;
2795
+ #hostElementRef;
2796
+ static {
2797
+ this.ɵfac = i0.ɵɵngDeclareFactory({
2798
+ minVersion: "12.0.0",
2799
+ version: "22.2.6",
2800
+ ngImport: i0,
2801
+ type: GridLockedCellDirective,
2802
+ deps: [],
2803
+ target: i0.ɵɵFactoryTarget.Directive
2804
+ });
2805
+ }
2806
+ static {
2807
+ this.ɵdir = i0.ɵɵngDeclareDirective({
2808
+ minVersion: "17.1.0",
2809
+ version: "22.2.6",
2810
+ type: GridLockedCellDirective,
2811
+ isStandalone: true,
2812
+ selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
2813
+ inputs: {
2814
+ layoutKey: {
2815
+ classPropertyName: "layoutKey",
2816
+ publicName: "monaGridLockedCell",
2817
+ isSignal: true,
2818
+ isRequired: false,
2819
+ transformFunction: null
2820
+ },
2821
+ lockedCellHeader: {
2822
+ classPropertyName: "lockedCellHeader",
2823
+ publicName: "lockedCellHeader",
2824
+ isSignal: true,
2825
+ isRequired: false,
2826
+ transformFunction: null
2827
+ }
2828
+ },
2829
+ host: { properties: {
2830
+ "style.position": "state() == null ? null : 'sticky'",
2831
+ "style.inset-inline-start.px": "startOffset()",
2832
+ "style.inset-inline-end.px": "endOffset()",
2833
+ "style.z-index": "zIndex()",
2834
+ "class.bg-header-background": "headerLocked() || footerCell",
2835
+ "class.bg-inherit": "bodyLocked()",
2836
+ "style.border-inline-start": "endEdge() ? stickyEdgeBorder : null",
2837
+ "style.border-inline-end": "startEdge() ? stickyEdgeBorder : null"
2838
+ } },
2839
+ ngImport: i0
2840
+ });
2841
+ }
2842
+ };
2843
+ i0.ɵɵngDeclareClassMetadata({
2844
+ minVersion: "12.0.0",
2845
+ version: "22.2.6",
2846
+ ngImport: i0,
2847
+ type: GridLockedCellDirective,
2848
+ decorators: [{
2849
+ type: Directive,
2850
+ args: [{
2851
+ selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
2852
+ host: {
2853
+ "[style.position]": "state() == null ? null : 'sticky'",
2854
+ "[style.inset-inline-start.px]": "startOffset()",
2855
+ "[style.inset-inline-end.px]": "endOffset()",
2856
+ "[style.z-index]": "zIndex()",
2857
+ "[class.bg-header-background]": "headerLocked() || footerCell",
2858
+ "[class.bg-inherit]": "bodyLocked()",
2859
+ "[style.border-inline-start]": "endEdge() ? stickyEdgeBorder : null",
2860
+ "[style.border-inline-end]": "startEdge() ? stickyEdgeBorder : null"
2861
+ }
2862
+ }]
2863
+ }],
2864
+ propDecorators: {
2865
+ layoutKey: [{
2866
+ type: i0.Input,
2867
+ args: [{
2868
+ isSignal: true,
2869
+ alias: "monaGridLockedCell",
2870
+ required: false
2871
+ }]
2872
+ }],
2873
+ lockedCellHeader: [{
2874
+ type: i0.Input,
2875
+ args: [{
2876
+ isSignal: true,
2877
+ alias: "lockedCellHeader",
2878
+ required: false
2879
+ }]
2880
+ }]
2881
+ }
2882
+ });
2883
+ const GRID_CELL_FOCUSABLE_SELECTOR = "button, input, select, textarea, a[href], [tabindex]";
2884
+ const LOGICAL_CELL_SELECTOR = "[monaGridLogicalCell], [monagridlogicalcell]";
2885
+ const BUTTON_LIKE_INPUT_TYPES = /* @__PURE__ */ new Set([
2886
+ "button",
2887
+ "checkbox",
2888
+ "color",
2889
+ "file",
2890
+ "image",
2891
+ "reset",
2892
+ "submit"
2893
+ ]);
2894
+ const KEYBOARD_ENTRY_ROLES = /* @__PURE__ */ new Set([
2895
+ "combobox",
2896
+ "listbox",
2897
+ "radiogroup",
2898
+ "slider",
2899
+ "spinbutton",
2900
+ "textbox"
2901
+ ]);
2902
+ function isKeyboardEntryElement(element) {
2903
+ if (element instanceof HTMLInputElement) return !BUTTON_LIKE_INPUT_TYPES.has(element.type);
2904
+ if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) return true;
2905
+ if (element instanceof HTMLElement && element.isContentEditable) return true;
2906
+ const role = element.getAttribute("role");
2907
+ return role != null && KEYBOARD_ENTRY_ROLES.has(role);
2908
+ }
2909
+ function observeGridCellTabStops(root) {
2910
+ removeTabStops(root);
2911
+ if (typeof MutationObserver === "undefined") return () => void 0;
2912
+ const observer = new MutationObserver((records) => {
2913
+ for (const record of records) {
2914
+ if (record.type === "attributes") {
2915
+ removeTabStop(record.target);
2916
+ continue;
2917
+ }
2918
+ for (const node of record.addedNodes) if (node instanceof Element) {
2919
+ removeTabStop(node);
2920
+ removeTabStops(node);
2921
+ }
2922
+ }
2923
+ });
2924
+ observer.observe(root, {
2925
+ attributeFilter: ["tabindex", "href"],
2926
+ attributes: true,
2927
+ childList: true,
2928
+ subtree: true
2929
+ });
2930
+ return () => observer.disconnect();
2931
+ }
2932
+ function removeTabStops(container) {
2933
+ for (const element of container.querySelectorAll(GRID_CELL_FOCUSABLE_SELECTOR)) removeTabStop(element);
2934
+ }
2935
+ function removeTabStop(node) {
2936
+ if (!(node instanceof Element) || !node.matches("button, input, select, textarea, a[href], [tabindex]")) return;
2937
+ if (node.matches(LOGICAL_CELL_SELECTOR) || node.getAttribute("tabindex") === "-1") return;
2938
+ if (node.parentElement?.closest(LOGICAL_CELL_SELECTOR) != null) node.setAttribute("tabindex", "-1");
2939
+ }
2940
+ const PAGE_TABBABLE_SELECTOR = `${GRID_CELL_FOCUSABLE_SELECTOR}, summary, [contenteditable]`;
2941
+ var GridLogicalCellDirective = class GridLogicalCellDirective {
2942
+ #cellData;
2943
+ #cellKey;
2944
+ #clipboard;
2945
+ #destroyRef;
2946
+ #gridNavigationService;
2947
+ #gridService;
2948
+ #hostElementRef;
2949
+ #startEdit;
2950
+ constructor() {
2951
+ this.#cellData = computed(() => {
2952
+ return {
2953
+ cellKind: this.resolvedCellKind(),
2954
+ colIndex: this.colIndex(),
2955
+ columnId: this.columnId(),
2956
+ editable: this.editable(),
2957
+ element: this.#hostElementRef.nativeElement,
2958
+ firstInRow: this.firstInRow(),
2959
+ groupHeader: this.groupHeader(),
2960
+ groupKey: this.groupKey(),
2961
+ lastInRow: this.lastInRow(),
2962
+ rowIndex: this.rowIndex(),
2963
+ rowUid: this.rowUid(),
2964
+ section: this.resolvedSection(),
2965
+ startEdit: this.editable() ? this.#startEdit : void 0
2966
+ };
2967
+ }, ...ngDevMode ? [{ debugName: "#cellData" }] : /* istanbul ignore next */ []);
2968
+ this.#cellKey = signal(null, ...ngDevMode ? [{ debugName: "#cellKey" }] : /* istanbul ignore next */ []);
2969
+ this.#clipboard = inject(Clipboard);
2970
+ this.#destroyRef = inject(DestroyRef);
2971
+ this.#gridNavigationService = inject(GridNavigationService);
2972
+ this.#gridService = inject(GridService);
2973
+ this.#hostElementRef = inject(ElementRef);
2974
+ this.#startEdit = () => {
2975
+ this.edit.emit();
2976
+ };
2977
+ this.focused = computed(() => {
2978
+ const key = this.#cellKey();
2979
+ if (!key) return false;
2980
+ return this.#gridNavigationService.isFocused(key);
2981
+ }, ...ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []);
2982
+ this.resolvedAriaColIndex = computed(() => this.ariaColIndex() ?? this.colIndex() + this.#gridService.groupColumns().length + 1, ...ngDevMode ? [{ debugName: "resolvedAriaColIndex" }] : /* istanbul ignore next */ []);
2983
+ this.resolvedCellKind = computed(() => {
2984
+ const cellKind = this.cellKind();
2985
+ if (cellKind != null) return cellKind;
2986
+ if (this.groupHeader()) return "group";
2987
+ if (this.#hostElementRef.nativeElement.tagName === "TH") return "header";
2988
+ return "data";
2989
+ }, ...ngDevMode ? [{ debugName: "resolvedCellKind" }] : /* istanbul ignore next */ []);
2990
+ this.resolvedSection = computed(() => {
2991
+ const section = this.section();
2992
+ if (section != null) return section;
2993
+ return this.#hostElementRef.nativeElement.tagName === "TH" ? "header" : "body";
2994
+ }, ...ngDevMode ? [{ debugName: "resolvedSection" }] : /* istanbul ignore next */ []);
2995
+ this.ariaColIndex = input(null, ...ngDevMode ? [{ debugName: "ariaColIndex" }] : /* istanbul ignore next */ []);
2996
+ this.cellKind = input(null, ...ngDevMode ? [{ debugName: "cellKind" }] : /* istanbul ignore next */ []);
2997
+ this.colIndex = input.required(...ngDevMode ? [{ debugName: "colIndex" }] : /* istanbul ignore next */ []);
2998
+ this.columnId = input(...ngDevMode ? [void 0, { debugName: "columnId" }] : /* istanbul ignore next */ []);
2999
+ this.edit = output();
3000
+ this.editable = input(false, ...ngDevMode ? [{ debugName: "editable" }] : /* istanbul ignore next */ []);
3001
+ this.expanded = input(null, ...ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []);
3002
+ this.firstInRow = input.required(...ngDevMode ? [{ debugName: "firstInRow" }] : /* istanbul ignore next */ []);
3003
+ this.groupHeader = input(false, ...ngDevMode ? [{ debugName: "groupHeader" }] : /* istanbul ignore next */ []);
3004
+ this.groupKey = input(...ngDevMode ? [void 0, { debugName: "groupKey" }] : /* istanbul ignore next */ []);
3005
+ this.lastInRow = input.required(...ngDevMode ? [{ debugName: "lastInRow" }] : /* istanbul ignore next */ []);
3006
+ this.menuOpen = output();
3007
+ this.readOnly = input(null, ...ngDevMode ? [{ debugName: "readOnly" }] : /* istanbul ignore next */ []);
3008
+ this.rowIndex = input.required(...ngDevMode ? [{ debugName: "rowIndex" }] : /* istanbul ignore next */ []);
3009
+ this.rowUid = input(...ngDevMode ? [void 0, { debugName: "rowUid" }] : /* istanbul ignore next */ []);
3010
+ this.section = input(null, ...ngDevMode ? [{ debugName: "section" }] : /* istanbul ignore next */ []);
3011
+ this.toggleExpand = output();
3012
+ afterRenderEffect({ mixedReadWrite: () => {
3013
+ const data = this.#cellData();
3014
+ untracked(() => {
3015
+ const previousCellKey = this.#cellKey();
3016
+ const nextCellKey = this.#gridNavigationService.registerCell(data);
3017
+ if (previousCellKey && previousCellKey !== nextCellKey) this.#gridNavigationService.unregisterCell(previousCellKey, data.element);
3018
+ this.#cellKey.set(nextCellKey);
3019
+ });
3020
+ } });
3021
+ afterNextRender({ read: () => this.#setKeyboardNavigation() });
3022
+ this.#destroyRef.onDestroy(() => {
3023
+ const cellKey = this.#cellKey();
3024
+ if (!cellKey) return;
3025
+ this.#gridNavigationService.unregisterCell(cellKey, this.#hostElementRef.nativeElement);
3026
+ });
3027
+ }
3028
+ leaveGrid(backwards) {
3029
+ const host = this.#hostElementRef.nativeElement;
3030
+ const document = host.ownerDocument;
3031
+ const position = backwards ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
3032
+ const candidates = Array.from(document.querySelectorAll(PAGE_TABBABLE_SELECTOR)).filter((candidate) => candidate.tabIndex >= 0 && !host.contains(candidate) && !candidate.contains(host) && (host.compareDocumentPosition(candidate) & position) !== 0 && !this.#isElementDisabled(candidate) && !this.#isElementHidden(candidate));
3033
+ for (const candidate of backwards ? candidates.reverse() : candidates) {
3034
+ candidate.focus();
3035
+ if (document.activeElement === candidate) return true;
3036
+ }
3037
+ return false;
3038
+ }
3039
+ #copyCellText(event) {
3040
+ if (!(event.ctrlKey || event.metaKey) || event.altKey || event.code !== "KeyC") return;
3041
+ if (this.rowIndex() < 0 || this.#gridService.isInEditMode()) return;
3042
+ const selection = this.#hostElementRef.nativeElement.ownerDocument.getSelection();
3043
+ if (selection != null && !selection.isCollapsed && selection.toString() !== "") return;
3044
+ const host = this.#hostElementRef.nativeElement;
3045
+ const text = (host.innerText ?? host.textContent ?? "").trim();
3046
+ if (text) this.#clipboard.copy(text);
3047
+ }
3048
+ #enterCell() {
3049
+ const target = this.#getInnerFocusableTargets()[0];
3050
+ if (!target) return false;
3051
+ target.focus();
3052
+ return true;
3053
+ }
3054
+ #focusNextInnerTarget(currentTarget, backwards, wrap) {
3055
+ const targets = this.#getInnerFocusableTargets();
3056
+ if (targets.length === 0) return false;
3057
+ const currentIndex = targets.findIndex((target) => target === currentTarget || target.contains(currentTarget));
3058
+ let nextIndex = currentIndex === -1 ? 0 : currentIndex + (backwards ? -1 : 1);
3059
+ if (nextIndex < 0 || nextIndex >= targets.length) {
3060
+ if (!wrap) return false;
3061
+ nextIndex = (nextIndex + targets.length) % targets.length;
3062
+ }
3063
+ targets[nextIndex].focus();
3064
+ return true;
3065
+ }
3066
+ #getInnerFocusableTargets() {
3067
+ const host = this.#hostElementRef.nativeElement;
3068
+ return Array.from(host.querySelectorAll(GRID_CELL_FOCUSABLE_SELECTOR)).filter((target) => target !== host && !this.#isElementDisabled(target) && !this.#isElementHidden(target));
3069
+ }
3070
+ #handleInnerKeydown(event, target) {
3071
+ if (this.#gridService.isInEditMode() && this.resolvedCellKind() !== "command") return;
3072
+ const host = this.#hostElementRef.nativeElement;
3073
+ if (event.key === "Escape") {
3074
+ event.preventDefault();
3075
+ host.focus();
3076
+ return;
3077
+ }
3078
+ if (event.key === "Tab") {
3079
+ event.preventDefault();
3080
+ if (this.#focusNextInnerTarget(target, event.shiftKey, false)) return;
3081
+ host.focus();
3082
+ if (!event.shiftKey) this.#navigate("ArrowRight");
3083
+ return;
3084
+ }
3085
+ if (isKeyboardEntryElement(target)) return;
3086
+ const key = this.#toLogicalArrowKey(event.key);
3087
+ if (key === "ArrowRight" || key === "ArrowDown") {
3088
+ event.preventDefault();
3089
+ this.#focusNextInnerTarget(target, false, true);
3090
+ } else if (key === "ArrowLeft" || key === "ArrowUp") {
3091
+ event.preventDefault();
3092
+ this.#focusNextInnerTarget(target, true, true);
3093
+ }
3094
+ }
3095
+ #handleSelectionKey(event) {
3096
+ const rowUid = this.rowUid();
3097
+ if (this.resolvedSection() !== "body" || this.groupHeader() || rowUid == null) return false;
3098
+ if (event.key === " " && !event.ctrlKey && !event.metaKey && !event.altKey) {
3099
+ if (this.#gridService.selectRowFromKeyboard(rowUid, event.shiftKey)) event.preventDefault();
3100
+ return true;
3101
+ }
3102
+ if ((event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey && event.code === "KeyA") {
3103
+ if (this.#gridService.selectAllRowsFromKeyboard()) event.preventDefault();
3104
+ return true;
3105
+ }
3106
+ if (event.shiftKey && !event.altKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
3107
+ event.preventDefault();
3108
+ if (!this.#navigate(event.key)) return true;
3109
+ const next = this.#gridNavigationService.getFocusedCell();
3110
+ if (next?.section === "body" && !next.groupHeader && next.rowUid != null) this.#gridService.selectRowFromKeyboard(next.rowUid, true);
3111
+ return true;
3112
+ }
3113
+ return false;
3114
+ }
3115
+ #isElementDisabled(element) {
3116
+ if ((element instanceof HTMLButtonElement || element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) && element.disabled) return true;
3117
+ return element.getAttribute("aria-disabled") === "true" || element.hasAttribute("disabled");
3118
+ }
3119
+ #isElementHidden(element) {
3120
+ return element.closest("[hidden], [inert]") != null || element.getAttribute("aria-hidden") === "true";
3121
+ }
3122
+ #navigate(navigationKey) {
3123
+ const cellKey = this.#cellKey();
3124
+ if (!cellKey) return false;
3125
+ return this.#gridNavigationService.navigate(cellKey, navigationKey);
3126
+ }
3127
+ #onEnterKey() {
3128
+ if (this.groupHeader() || this.resolvedSection() === "header" || this.resolvedCellKind() === "detail") {
3129
+ this.toggleExpand.emit();
3130
+ return;
3131
+ }
3132
+ this.#onF2Key();
3133
+ }
3134
+ #onF2Key() {
3135
+ if (this.editable()) {
3136
+ this.edit.emit();
3137
+ return;
3138
+ }
3139
+ if (this.#enterCell()) return;
3140
+ if (this.resolvedCellKind() === "data") this.edit.emit();
3141
+ }
3142
+ #onHostKeydown(event) {
3143
+ if (event.defaultPrevented || event.isComposing) return;
3144
+ const target = event.target;
3145
+ const host = this.#hostElementRef.nativeElement;
3146
+ if (target && target !== host) {
3147
+ this.#handleInnerKeydown(event, target);
3148
+ return;
3149
+ }
3150
+ this.#copyCellText(event);
3151
+ if (this.#handleSelectionKey(event)) return;
3152
+ const command = event.ctrlKey || event.metaKey;
3153
+ switch (event.key) {
3154
+ case "ArrowDown":
3155
+ event.preventDefault();
3156
+ if (event.altKey) {
3157
+ this.#onAltArrowDown();
3158
+ return;
3159
+ }
3160
+ this.#navigate("ArrowDown");
3161
+ return;
3162
+ case "ArrowUp":
3163
+ event.preventDefault();
3164
+ this.#navigate("ArrowUp");
3165
+ return;
3166
+ case "ArrowLeft":
3167
+ case "ArrowRight": {
3168
+ const key = this.#toLogicalArrowKey(event.key);
3169
+ const expanded = this.expanded();
3170
+ if (this.groupHeader() && expanded === (key === "ArrowLeft")) {
3171
+ event.preventDefault();
3172
+ this.toggleExpand.emit();
3173
+ return;
3174
+ }
3175
+ if (this.#navigate(key)) event.preventDefault();
3176
+ return;
3177
+ }
3178
+ case "Enter":
3179
+ event.preventDefault();
3180
+ this.#onEnterKey();
3181
+ return;
3182
+ case "F2":
3183
+ event.preventDefault();
3184
+ this.#onF2Key();
3185
+ return;
3186
+ case "Home":
3187
+ event.preventDefault();
3188
+ this.#navigate(command ? "CtrlHome" : "Home");
3189
+ return;
3190
+ case "End":
3191
+ event.preventDefault();
3192
+ this.#navigate(command ? "CtrlEnd" : "End");
3193
+ return;
3194
+ case "PageDown":
3195
+ case "PageUp":
3196
+ if (this.#navigate(event.key)) event.preventDefault();
3197
+ return;
3198
+ }
3199
+ }
3200
+ #onAltArrowDown() {
3201
+ if (this.resolvedSection() === "header") {
3202
+ this.menuOpen.emit();
3203
+ return;
3204
+ }
3205
+ this.toggleExpand.emit();
3206
+ }
3207
+ #setKeyboardNavigation() {
3208
+ const host = this.#hostElementRef.nativeElement;
3209
+ fromEvent(host, "focus").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
3210
+ const key = this.#cellKey();
3211
+ if (key) this.#gridNavigationService.setLastFocusedCellKey(key);
3212
+ });
3213
+ fromEvent(host, "blur").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => this.#gridNavigationService.notifyCellBlur());
3214
+ fromEvent(host, "keydown").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((e) => this.#onHostKeydown(e));
3215
+ }
3216
+ #toLogicalArrowKey(key) {
3217
+ const host = this.#hostElementRef.nativeElement;
3218
+ if (host.ownerDocument.defaultView?.getComputedStyle(host).direction !== "rtl") return key;
3219
+ if (key === "ArrowLeft") return "ArrowRight";
3220
+ return key === "ArrowRight" ? "ArrowLeft" : key;
3221
+ }
3222
+ static {
3223
+ this.ɵfac = i0.ɵɵngDeclareFactory({
3224
+ minVersion: "12.0.0",
3225
+ version: "22.2.6",
3226
+ ngImport: i0,
3227
+ type: GridLogicalCellDirective,
3228
+ deps: [],
3229
+ target: i0.ɵɵFactoryTarget.Directive
3230
+ });
3231
+ }
3232
+ static {
3233
+ this.ɵdir = i0.ɵɵngDeclareDirective({
3234
+ minVersion: "17.1.0",
3235
+ version: "22.2.6",
3236
+ type: GridLogicalCellDirective,
3237
+ isStandalone: true,
3238
+ selector: "td[monaGridLogicalCell], th[monaGridLogicalCell]",
3239
+ inputs: {
3240
+ ariaColIndex: {
3241
+ classPropertyName: "ariaColIndex",
3242
+ publicName: "ariaColIndex",
3243
+ isSignal: true,
3244
+ isRequired: false,
3245
+ transformFunction: null
3246
+ },
3247
+ cellKind: {
3248
+ classPropertyName: "cellKind",
3249
+ publicName: "cellKind",
3250
+ isSignal: true,
3251
+ isRequired: false,
3252
+ transformFunction: null
3253
+ },
3254
+ colIndex: {
3255
+ classPropertyName: "colIndex",
3256
+ publicName: "colIndex",
3257
+ isSignal: true,
3258
+ isRequired: true,
3259
+ transformFunction: null
3260
+ },
3261
+ columnId: {
3262
+ classPropertyName: "columnId",
3263
+ publicName: "columnId",
3264
+ isSignal: true,
3265
+ isRequired: false,
3266
+ transformFunction: null
3267
+ },
3268
+ editable: {
3269
+ classPropertyName: "editable",
3270
+ publicName: "editable",
3271
+ isSignal: true,
3272
+ isRequired: false,
3273
+ transformFunction: null
3274
+ },
3275
+ expanded: {
3276
+ classPropertyName: "expanded",
3277
+ publicName: "expanded",
3278
+ isSignal: true,
3279
+ isRequired: false,
3280
+ transformFunction: null
3281
+ },
3282
+ firstInRow: {
3283
+ classPropertyName: "firstInRow",
3284
+ publicName: "firstInRow",
3285
+ isSignal: true,
3286
+ isRequired: true,
3287
+ transformFunction: null
3288
+ },
3289
+ groupHeader: {
3290
+ classPropertyName: "groupHeader",
3291
+ publicName: "groupHeader",
3292
+ isSignal: true,
3293
+ isRequired: false,
3294
+ transformFunction: null
3295
+ },
3296
+ groupKey: {
3297
+ classPropertyName: "groupKey",
3298
+ publicName: "groupKey",
3299
+ isSignal: true,
3300
+ isRequired: false,
3301
+ transformFunction: null
3302
+ },
3303
+ lastInRow: {
3304
+ classPropertyName: "lastInRow",
3305
+ publicName: "lastInRow",
3306
+ isSignal: true,
3307
+ isRequired: true,
3308
+ transformFunction: null
3309
+ },
3310
+ readOnly: {
3311
+ classPropertyName: "readOnly",
3312
+ publicName: "readOnly",
3313
+ isSignal: true,
3314
+ isRequired: false,
3315
+ transformFunction: null
3316
+ },
3317
+ rowIndex: {
3318
+ classPropertyName: "rowIndex",
3319
+ publicName: "rowIndex",
3320
+ isSignal: true,
3321
+ isRequired: true,
3322
+ transformFunction: null
3323
+ },
3324
+ rowUid: {
3325
+ classPropertyName: "rowUid",
3326
+ publicName: "rowUid",
3327
+ isSignal: true,
3328
+ isRequired: false,
3329
+ transformFunction: null
3330
+ },
3331
+ section: {
3332
+ classPropertyName: "section",
3333
+ publicName: "section",
3334
+ isSignal: true,
3335
+ isRequired: false,
3336
+ transformFunction: null
3337
+ }
3338
+ },
3339
+ outputs: {
3340
+ edit: "edit",
3341
+ menuOpen: "menuOpen",
3342
+ toggleExpand: "toggleExpand"
3343
+ },
3344
+ host: { properties: {
3345
+ "attr.tabindex": "focused() ? 0 : -1",
3346
+ "attr.aria-colindex": "resolvedAriaColIndex()",
3347
+ "attr.aria-readonly": "readOnly()"
3348
+ } },
3349
+ ngImport: i0
3350
+ });
3351
+ }
3352
+ };
3353
+ i0.ɵɵngDeclareClassMetadata({
3354
+ minVersion: "12.0.0",
3355
+ version: "22.2.6",
3356
+ ngImport: i0,
3357
+ type: GridLogicalCellDirective,
3358
+ decorators: [{
3359
+ type: Directive,
3360
+ args: [{
3361
+ selector: "td[monaGridLogicalCell], th[monaGridLogicalCell]",
3362
+ host: {
3363
+ "[attr.tabindex]": "focused() ? 0 : -1",
3364
+ "[attr.aria-colindex]": "resolvedAriaColIndex()",
3365
+ "[attr.aria-readonly]": "readOnly()"
3366
+ }
3367
+ }]
3368
+ }],
3369
+ ctorParameters: () => [],
3370
+ propDecorators: {
3371
+ ariaColIndex: [{
3372
+ type: i0.Input,
3373
+ args: [{
3374
+ isSignal: true,
3375
+ alias: "ariaColIndex",
3376
+ required: false
3377
+ }]
3378
+ }],
3379
+ cellKind: [{
3380
+ type: i0.Input,
3381
+ args: [{
3382
+ isSignal: true,
3383
+ alias: "cellKind",
3384
+ required: false
3385
+ }]
3386
+ }],
3387
+ colIndex: [{
3388
+ type: i0.Input,
3389
+ args: [{
3390
+ isSignal: true,
3391
+ alias: "colIndex",
3392
+ required: true
3393
+ }]
3394
+ }],
3395
+ columnId: [{
3396
+ type: i0.Input,
3397
+ args: [{
3398
+ isSignal: true,
3399
+ alias: "columnId",
3400
+ required: false
3401
+ }]
3402
+ }],
3403
+ edit: [{
3404
+ type: i0.Output,
3405
+ args: ["edit"]
3406
+ }],
3407
+ editable: [{
3408
+ type: i0.Input,
3409
+ args: [{
3410
+ isSignal: true,
3411
+ alias: "editable",
3412
+ required: false
3413
+ }]
3414
+ }],
3415
+ expanded: [{
3416
+ type: i0.Input,
3417
+ args: [{
3418
+ isSignal: true,
3419
+ alias: "expanded",
3420
+ required: false
3421
+ }]
3422
+ }],
3423
+ firstInRow: [{
3424
+ type: i0.Input,
3425
+ args: [{
3426
+ isSignal: true,
3427
+ alias: "firstInRow",
3428
+ required: true
3429
+ }]
3430
+ }],
3431
+ groupHeader: [{
3432
+ type: i0.Input,
3433
+ args: [{
3434
+ isSignal: true,
3435
+ alias: "groupHeader",
3436
+ required: false
3437
+ }]
3438
+ }],
3439
+ groupKey: [{
3440
+ type: i0.Input,
3441
+ args: [{
3442
+ isSignal: true,
3443
+ alias: "groupKey",
3444
+ required: false
3445
+ }]
3446
+ }],
3447
+ lastInRow: [{
3448
+ type: i0.Input,
3449
+ args: [{
3450
+ isSignal: true,
3451
+ alias: "lastInRow",
3452
+ required: true
3453
+ }]
3454
+ }],
3455
+ menuOpen: [{
3456
+ type: i0.Output,
3457
+ args: ["menuOpen"]
3458
+ }],
3459
+ readOnly: [{
3460
+ type: i0.Input,
3461
+ args: [{
3462
+ isSignal: true,
3463
+ alias: "readOnly",
3464
+ required: false
3465
+ }]
3466
+ }],
3467
+ rowIndex: [{
3468
+ type: i0.Input,
3469
+ args: [{
3470
+ isSignal: true,
3471
+ alias: "rowIndex",
3472
+ required: true
3473
+ }]
3474
+ }],
3475
+ rowUid: [{
3476
+ type: i0.Input,
3477
+ args: [{
3478
+ isSignal: true,
3479
+ alias: "rowUid",
3480
+ required: false
3481
+ }]
3482
+ }],
3483
+ section: [{
3484
+ type: i0.Input,
3485
+ args: [{
3486
+ isSignal: true,
3487
+ alias: "section",
3488
+ required: false
3489
+ }]
3490
+ }],
3491
+ toggleExpand: [{
3492
+ type: i0.Output,
3493
+ args: ["toggleExpand"]
3494
+ }]
3495
+ }
3496
+ });
3497
+ const gridRowMinHeightClass = "min-h-9";
3498
+ const gridVirtualRowHeightClass = "h-(--mona-grid-row-height) min-h-(--mona-grid-row-height) max-h-(--mona-grid-row-height)";
3499
+ const gridBaseThemeVariants = cva(`
3500
+ relative flex flex-col
3501
+ h-full overflow-hidden
3502
+ text-foreground text-sm
3503
+ bg-surface border border-border
3504
+ `, { variants: { rounded: {
3505
+ small: "rounded-sm",
3506
+ medium: "rounded-md",
3507
+ large: "rounded-lg",
3508
+ none: "rounded-none"
3509
+ } } });
3510
+ const gridCellBaseThemeVariants = cva("flex w-full min-w-0", {
3511
+ variants: { virtual: {
3512
+ true: "absolute inset-0 overflow-hidden",
3513
+ false: `relative ${gridRowMinHeightClass}`
3514
+ } },
3515
+ defaultVariants: { virtual: false }
3516
+ });
3517
+ const gridCellContainerThemeVariants = cva(`
3518
+ flex w-full min-w-0 items-center
3519
+ flex-1 outline-none focus-visible:outline-hidden
3520
+ `, {
3521
+ variants: {
3522
+ virtual: {
3523
+ true: "h-full overflow-hidden",
3524
+ false: gridRowMinHeightClass
3525
+ },
3526
+ editing: {
3527
+ true: "px-0",
3528
+ false: "px-2"
3529
+ }
3530
+ },
3531
+ defaultVariants: {
3532
+ editing: false,
3533
+ virtual: false
3534
+ },
3535
+ compoundVariants: [{
3536
+ virtual: false,
3537
+ editing: false,
3538
+ class: "py-1"
3539
+ }]
3540
+ });
3541
+ const gridCellDirtyIndicatorThemeVariants = cva(`
3542
+ absolute top-0 end-0 w-0 h-0
3543
+ border-t-[8px] border-s-[8px]
3544
+ border-t-destructive border-s-transparent
3545
+ pointer-events-none
3546
+ `);
3547
+ const gridCellEditorBaseThemeVariants = cva(`
3548
+ flex w-full min-w-0 items-center
3549
+ bg-input-background border border-focus-indicator/40
3550
+ `, {
3551
+ variants: { virtual: {
3552
+ true: "h-full overflow-hidden",
3553
+ false: gridRowMinHeightClass
3554
+ } },
3555
+ defaultVariants: { virtual: false }
3556
+ });
3557
+ const gridCellEditorInputThemeVariants = cva(`
3558
+ w-full border-transparent
3559
+ data-[expanded='true']:border-focus-indicator
3560
+ data-[expanded='true']:focus-within:border-focus-indicator/40
3561
+ `, {
3562
+ variants: { virtual: {
3563
+ true: "h-full",
3564
+ false: "min-h-8"
3565
+ } },
3566
+ defaultVariants: { virtual: false }
3567
+ });
3568
+ const gridCellTextThemeVariants = cva(`
3569
+ truncate cursor-default select-none
3570
+ `);
3571
+ const gridSelectAllCellThemeVariants = cva(`
3572
+ absolute inset-0 flex h-full w-full items-center justify-center
3573
+ `);
3574
+ const gridSelectionCellThemeVariants = cva("flex w-full items-center justify-center", {
3575
+ variants: { virtual: {
3576
+ true: "absolute inset-0 h-full",
3577
+ false: gridRowMinHeightClass
3578
+ } },
3579
+ defaultVariants: { virtual: false }
3580
+ });
3581
+ const gridColumnActionsThemeVariants = cva(`
3582
+ flex items-center justify-center
3583
+ text-xs [&_i]:text-xs
3584
+ `);
3585
+ const gridColumnDragPreviewThemeVariants = cva(`
3586
+ flex items-center justify-center
3587
+ px-2! py-0.5!
3588
+ bg-surface-raised! text-foreground!
3589
+ border! border-border! rounded-md shadow-(--shadow-overlay)!
3590
+ `);
3591
+ const gridColumnDropHintThemeVariants = cva(`
3592
+ absolute flex w-1 h-full bg-[var(--mona-indicator-color,var(--color-primary))] z-10! top-0 bottom-0
3593
+ `);
3594
+ const gridColumnResizerThemeVariants = cva(`
3595
+ absolute top-0 bottom-0 w-3 bg-transparent cursor-col-resize z-10 -end-1.5 touch-none
3596
+ outline-none focus-visible:outline-hidden focus-visible:bg-focus-indicator/40
3597
+ `);
3598
+ const gridRowReorderHandleThemeVariants = cva(`
3599
+ flex min-h-9 w-full items-center justify-center
3600
+ cursor-grab select-none touch-none
3601
+ text-muted-foreground
3602
+ hover:text-foreground
3603
+ active:cursor-grabbing
3604
+ focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-indicator/50
3605
+ disabled:cursor-not-allowed disabled:text-muted-foreground/35 disabled:hover:text-muted-foreground/35
3606
+ `);
3607
+ const gridRowDragPreviewThemeVariants = cva(`
3608
+ flex items-center gap-2
3609
+ px-2! py-1!
3610
+ bg-surface-raised! text-foreground!
3611
+ border! border-border! rounded-md shadow-(--shadow-overlay)!
3612
+ [&.cdk-drag-animating]:opacity-0
3613
+ [&.cdk-drag-animating]:transition-[transform,opacity] [&.cdk-drag-animating]:duration-200
3614
+ [&.cdk-drag-animating]:ease-[cubic-bezier(0.2,0,0,1)]
3615
+ motion-reduce:[&.cdk-drag-animating]:transition-none
3616
+ `);
3617
+ const gridFilterRowCellThemeVariants = cva(`
3618
+ flex items-center px-1 py-0.5 w-full
3619
+ [--mona-effect-control-background-color:var(--mona-effect-raised-background-color,var(--color-surface-raised))]
3620
+ [--mona-effect-control-fallback-background-color:var(--mona-effect-raised-fallback-background-color,var(--color-surface-raised))]
3621
+ [--mona-effect-control-background-image:var(--mona-effect-raised-background-image,none)]
3622
+ [--mona-effect-control-backdrop-filter:var(--mona-effect-raised-backdrop-filter,none)]
3623
+ `);
3624
+ const gridFooterThemeVariants = cva(`
3625
+ flex flex-row grow-0 shrink-0 basis-auto
3626
+ overflow-hidden
3627
+ bg-surface-muted border-e border-e-border-subtle border-t border-t-border-subtle
3628
+ `);
3629
+ const gridFooterTableThemeVariants = cva(`
3630
+ border-separate border-spacing-0 table-fixed
3631
+ `);
3632
+ const gridFooterTableRowThemeVariants = cva(`relative inline-flex [&>td:last-child]:border-e-0`, {
3633
+ variants: { virtual: {
3634
+ true: `${gridVirtualRowHeightClass} overflow-hidden`,
3635
+ false: ""
3636
+ } },
3637
+ defaultVariants: { virtual: false }
3638
+ });
3639
+ const gridFooterTableCellThemeVariants = cva(`
3640
+ relative overflow-hidden outline-none focus-visible:outline-hidden
3641
+ text-start align-middle px-2 py-2
3642
+ bg-surface-muted
3643
+ border-e border-e-border-subtle border-b border-b-border-subtle
3644
+ font-medium
3645
+ after:absolute after:inset-0 after:pointer-events-none
3646
+ focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus-indicator
3647
+ `);
3648
+ const gridGroupPanelPlaceholderThemeVariants = cva(`
3649
+ truncate text-muted-foreground
3650
+ `);
3651
+ const gridGroupPanelThemeVariants = cva(`
3652
+ flex items-center flex-wrap
3653
+ p-1 h-auto gap-1
3654
+ bg-surface-muted border-b border-b-border-subtle
3655
+ `);
3656
+ const gridGroupRowThemeVariants = cva(`
3657
+ relative z-10
3658
+ w-full
3659
+ bg-surface-muted border-e border-e-border-subtle
3660
+ `, {
3661
+ variants: { virtual: {
3662
+ true: gridVirtualRowHeightClass,
3663
+ false: ""
3664
+ } },
3665
+ defaultVariants: { virtual: false }
3666
+ });
3667
+ const gridHeaderThemeVariants = cva(`
3668
+ flex flex-row grow-0 shrink-0 basis-auto
3669
+ overflow-hidden
3670
+ bg-surface-muted border-e border-e-border-subtle
3671
+ `);
3672
+ const gridHeaderTableThemeVariants = cva(`
3673
+ border-separate border-spacing-0 table-fixed
3674
+ `);
3675
+ const gridHeaderTableRowThemeVariants = cva(`relative inline-flex not-first:border-t not-first:border-t-border-subtle [&>th:last-child]:border-e-0`);
3676
+ const gridHeaderTableCellThemeVariants = cva(`
3677
+ relative select-none
3678
+ text-start overflow-visible
3679
+ outline-none focus-visible:outline-hidden border-e border-e-border-subtle
3680
+ after:absolute after:inset-0 after:pointer-events-none
3681
+ focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus-indicator
3682
+ `);
3683
+ const gridFilterRowHeaderCellThemeVariants = cva(`
3684
+ relative overflow-hidden
3685
+ outline-none focus-visible:outline-hidden border-e border-border
3686
+ after:absolute after:inset-0 after:pointer-events-none
3687
+ focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus-indicator
3688
+ `);
3689
+ const gridHeaderTableColumnWrapThemeVariants = cva(`
3690
+ w-full h-full px-1
3691
+ flex items-center justify-between
3692
+ overflow-hidden
3693
+ `);
3694
+ const gridHeaderTableColumnTitleThemeVariants = cva(`
3695
+ flex-1 px-1 py-2 truncate
3696
+ font-medium
3697
+ `);
3698
+ const gridListBaseThemeVariants = cva(`
3699
+ w-full h-full
3700
+ outline-none focus-visible:outline-hidden
3701
+ border-t border-t-border-subtle
3702
+ [scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)] [scrollbar-width:thin]
3703
+ `, { variants: { virtual: {
3704
+ true: "overflow-x-hidden overflow-y-hidden flex flex-col min-h-0",
3705
+ false: "block overflow-x-auto overflow-y-scroll"
3706
+ } } });
3707
+ const gridListTableThemeVariants = cva(`
3708
+ border-separate border-spacing-0 w-full table-fixed
3709
+ [&_.cdk-drop-list-dragging>.cdk-drag]:transition-transform
3710
+ [&_.cdk-drop-list-dragging>.cdk-drag]:duration-200
3711
+ [&_.cdk-drop-list-dragging>.cdk-drag]:ease-[cubic-bezier(0.2,0,0,1)]
3712
+ motion-reduce:[&_.cdk-drop-list-dragging>.cdk-drag]:transition-none
3713
+ [&_.cdk-drag-placeholder]:opacity-60 [&_.cdk-drag-placeholder>td]:bg-hover!
3714
+ `);
3715
+ const gridListTableRowThemeVariants = cva(``, {
3716
+ variants: {
3717
+ selected: {
3718
+ true: `
3719
+ bg-(--color-selected) text-(--color-selected-foreground) hover:bg-(--color-selected-active)
3720
+ [&>td:first-child]:before:absolute [&>td:first-child]:before:inset-y-0
3721
+ [&>td:first-child]:before:start-0 [&>td:first-child]:before:w-0.5
3722
+ [&>td:first-child]:before:bg-(--color-selected-border)
3723
+ [&>td:first-child]:before:forced-color-adjust-none
3724
+ forced-colors:[&>td:first-child]:before:bg-[Highlight]
3725
+ `,
3726
+ false: "bg-surface hover:bg-hover"
3727
+ },
3728
+ virtual: {
3729
+ true: gridVirtualRowHeightClass,
3730
+ false: ""
3731
+ }
3732
+ },
3733
+ defaultVariants: { virtual: false }
3734
+ });
3735
+ const gridListTableCellThemeVariants = cva(`
3736
+ relative
3737
+ outline-none focus-visible:outline-hidden z-1
3738
+ align-middle
3739
+ border-b border-b-border-subtle
3740
+ after:content-[''] after:block
3741
+ after:absolute after:inset-0 after:pointer-events-none
3742
+ focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-focus-indicator
3743
+ `, {
3744
+ variants: {
3745
+ virtual: {
3746
+ true: gridVirtualRowHeightClass,
3747
+ false: ""
3748
+ },
3749
+ groupIndent: {
3750
+ true: "bg-surface-muted",
3751
+ false: ""
3752
+ },
3753
+ lastInRow: {
3754
+ true: "",
3755
+ false: "border-e border-e-border-subtle"
3756
+ }
3757
+ },
3758
+ defaultVariants: { virtual: false }
3759
+ });
3760
+ const gridNoDataThemeVariants = cva(`
3761
+ flex items-center justify-center h-full
3762
+ text-muted-foreground border-t border-t-border-subtle
3763
+ `);
3764
+ export { gridListTableThemeVariants as A, GridLockedCellDirective as B, gridHeaderTableColumnWrapThemeVariants as C, gridListBaseThemeVariants as D, gridHeaderThemeVariants as E, gridSelectionCellThemeVariants as F, GridSaveEvent as G, RowReorderEvent as H, GridLogicalCellDirective as I, GridCancelEvent as J, GridRemoveEvent as K, GRID_CELL_FOCUSABLE_SELECTOR as L, gridRowDragPreviewThemeVariants as M, gridRowReorderHandleThemeVariants as N, gridListTableCellThemeVariants as O, gridSelectAllCellThemeVariants as P, isKeyboardEntryElement as R, gridHeaderTableColumnTitleThemeVariants as S, gridHeaderTableThemeVariants as T, GridNavigationService as U, GridService as V, GRID_DEFAULT_MESSAGES as W, RowEditEvent as X, GridAddEvent as Y, CellEditEvent as Z, gridFooterThemeVariants as _, gridCellEditorBaseThemeVariants as a, gridGroupRowThemeVariants as b, gridColumnActionsThemeVariants as c, gridColumnResizerThemeVariants as d, gridFilterRowCellThemeVariants as f, gridFooterTableThemeVariants as g, gridFooterTableRowThemeVariants as h, gridCellDirtyIndicatorThemeVariants as i, gridNoDataThemeVariants as j, gridListTableRowThemeVariants as k, gridColumnDragPreviewThemeVariants as l, gridFooterTableCellThemeVariants as m, gridCellBaseThemeVariants as n, gridCellEditorInputThemeVariants as o, gridFilterRowHeaderCellThemeVariants as p, GridEditEvent as q, gridCellContainerThemeVariants as r, gridCellTextThemeVariants as s, gridBaseThemeVariants as t, gridColumnDropHintThemeVariants as u, gridGroupPanelPlaceholderThemeVariants as v, gridHeaderTableRowThemeVariants as w, gridHeaderTableCellThemeVariants as x, gridGroupPanelThemeVariants as y, observeGridCellTabStops as z };
3765
+
3766
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs.map