apex-grid 3.5.0 → 3.6.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 (197) hide show
  1. package/CHANGELOG.md +338 -0
  2. package/LICENSE.md +125 -0
  3. package/README.md +64 -10
  4. package/components/cell.d.ts +30 -4
  5. package/components/cell.js +199 -53
  6. package/components/cell.js.map +1 -1
  7. package/components/filter-row.d.ts +2 -0
  8. package/components/filter-row.js +82 -28
  9. package/components/filter-row.js.map +1 -1
  10. package/components/grid.d.ts +146 -36
  11. package/components/grid.js +442 -103
  12. package/components/grid.js.map +1 -1
  13. package/components/group-header-row.js +28 -25
  14. package/components/group-header-row.js.map +1 -1
  15. package/components/header-row.d.ts +7 -5
  16. package/components/header-row.js +11 -9
  17. package/components/header-row.js.map +1 -1
  18. package/components/header.js +32 -20
  19. package/components/header.js.map +1 -1
  20. package/components/row.d.ts +19 -3
  21. package/components/row.js +69 -23
  22. package/components/row.js.map +1 -1
  23. package/components/toolbar.js +2 -1
  24. package/components/toolbar.js.map +1 -1
  25. package/components/virtualizer.d.ts +40 -0
  26. package/components/virtualizer.js +116 -5
  27. package/components/virtualizer.js.map +1 -1
  28. package/controllers/dom.d.ts +4 -4
  29. package/controllers/dom.js +40 -22
  30. package/controllers/dom.js.map +1 -1
  31. package/controllers/editing.d.ts +104 -37
  32. package/controllers/editing.js +230 -78
  33. package/controllers/editing.js.map +1 -1
  34. package/controllers/expansion.d.ts +14 -5
  35. package/controllers/expansion.js +24 -1
  36. package/controllers/expansion.js.map +1 -1
  37. package/controllers/filter.d.ts +10 -2
  38. package/controllers/filter.js +62 -17
  39. package/controllers/filter.js.map +1 -1
  40. package/controllers/history.d.ts +45 -8
  41. package/controllers/history.js +58 -20
  42. package/controllers/history.js.map +1 -1
  43. package/controllers/navigation.d.ts +67 -13
  44. package/controllers/navigation.js +191 -51
  45. package/controllers/navigation.js.map +1 -1
  46. package/controllers/pagination.d.ts +6 -0
  47. package/controllers/pagination.js +10 -2
  48. package/controllers/pagination.js.map +1 -1
  49. package/controllers/reorder.js +38 -22
  50. package/controllers/reorder.js.map +1 -1
  51. package/controllers/resize.d.ts +17 -2
  52. package/controllers/resize.js +16 -6
  53. package/controllers/resize.js.map +1 -1
  54. package/controllers/row-pin.d.ts +20 -2
  55. package/controllers/row-pin.js +16 -9
  56. package/controllers/row-pin.js.map +1 -1
  57. package/controllers/row-reorder.d.ts +31 -11
  58. package/controllers/row-reorder.js +117 -37
  59. package/controllers/row-reorder.js.map +1 -1
  60. package/controllers/selection.d.ts +11 -4
  61. package/controllers/selection.js +26 -11
  62. package/controllers/selection.js.map +1 -1
  63. package/controllers/sort.d.ts +22 -2
  64. package/controllers/sort.js +29 -23
  65. package/controllers/sort.js.map +1 -1
  66. package/controllers/state.d.ts +56 -7
  67. package/controllers/state.js +76 -6
  68. package/controllers/state.js.map +1 -1
  69. package/controllers/tree.d.ts +15 -10
  70. package/controllers/tree.js +0 -0
  71. package/controllers/tree.js.map +1 -1
  72. package/custom-elements.json +3156 -277
  73. package/docs/assets/hierarchy.js +1 -1
  74. package/docs/assets/highlight.css +15 -8
  75. package/docs/assets/navigation.js +1 -1
  76. package/docs/assets/search.js +1 -1
  77. package/docs/classes/ApexGrid.html +155 -81
  78. package/docs/classes/ApexGridPaginator.html +1 -1
  79. package/docs/classes/ApexGridToolbar.html +3 -3
  80. package/docs/functions/localize.html +2 -2
  81. package/docs/hierarchy.html +1 -1
  82. package/docs/index.html +74 -11
  83. package/docs/interfaces/ApexCellValidationFailedEvent.html +3 -2
  84. package/docs/interfaces/ApexCellValueChangedEvent.html +4 -2
  85. package/docs/interfaces/ApexCellValueChangingEvent.html +3 -2
  86. package/docs/interfaces/ApexGridEventMap.html +5 -2
  87. package/docs/interfaces/ApexRowEditEndedEvent.html +2 -1
  88. package/docs/interfaces/ApexRowEditStartedEvent.html +2 -1
  89. package/docs/interfaces/ApexRowMovingEvent.html +9 -3
  90. package/docs/interfaces/ApexRowPinningEvent.html +1 -1
  91. package/docs/interfaces/ApexTreeRowExpandedEvent.html +4 -1
  92. package/docs/interfaces/ApexTreeRowExpandingEvent.html +4 -1
  93. package/docs/interfaces/BaseApexCellContext.html +1 -1
  94. package/docs/interfaces/BaseApexEditorContext.html +1 -1
  95. package/docs/interfaces/BaseFilterExpression.html +2 -2
  96. package/docs/interfaces/CSVExportOptions.html +12 -4
  97. package/docs/interfaces/DataPipelineConfiguration.html +1 -1
  98. package/docs/interfaces/ExportOptions.html +5 -3
  99. package/docs/interfaces/GridExpansionConfiguration.html +6 -2
  100. package/docs/interfaces/GridRowReorderingConfiguration.html +1 -1
  101. package/docs/interfaces/PaginationState.html +1 -1
  102. package/docs/interfaces/SetStateResult.html +3 -2
  103. package/docs/interfaces/ValidatorContext.html +7 -2
  104. package/docs/media/_token-values.scss +118 -0
  105. package/docs/media/package.json +3 -2
  106. package/docs/modules.html +1 -1
  107. package/docs/types/ExportSource.html +6 -4
  108. package/docs/types/OperandKeys.html +9 -0
  109. package/docs/variables/EN_LOCALE.html +2 -2
  110. package/i18n/en.d.ts +5 -0
  111. package/i18n/en.js +5 -0
  112. package/i18n/en.js.map +1 -1
  113. package/i18n/es.js +5 -0
  114. package/i18n/es.js.map +1 -1
  115. package/internal/column-types.d.ts +27 -1
  116. package/internal/column-types.js +75 -49
  117. package/internal/column-types.js.map +1 -1
  118. package/internal/constants.d.ts +1 -2
  119. package/internal/constants.js +0 -4
  120. package/internal/constants.js.map +1 -1
  121. package/internal/document-styles.d.ts +30 -0
  122. package/internal/document-styles.js +48 -0
  123. package/internal/document-styles.js.map +1 -0
  124. package/internal/export.d.ts +39 -7
  125. package/internal/export.js +35 -34
  126. package/internal/export.js.map +1 -1
  127. package/internal/feature-module.d.ts +60 -3
  128. package/internal/feature-module.js +6 -0
  129. package/internal/feature-module.js.map +1 -1
  130. package/internal/index.d.ts +6 -4
  131. package/internal/index.js +5 -3
  132. package/internal/index.js.map +1 -1
  133. package/internal/normalize-case.d.ts +8 -1
  134. package/internal/normalize-case.js +3 -2
  135. package/internal/normalize-case.js.map +1 -1
  136. package/internal/state-snapshot.d.ts +60 -8
  137. package/internal/state-snapshot.js +87 -19
  138. package/internal/state-snapshot.js.map +1 -1
  139. package/internal/types.d.ts +17 -2
  140. package/internal/types.js.map +1 -1
  141. package/internal/utils.d.ts +34 -6
  142. package/internal/utils.js +30 -21
  143. package/internal/utils.js.map +1 -1
  144. package/internal/validators.js +1 -0
  145. package/internal/validators.js.map +1 -1
  146. package/operations/filter/operands/number.js +9 -6
  147. package/operations/filter/operands/number.js.map +1 -1
  148. package/operations/filter/operands/string.js +2 -3
  149. package/operations/filter/operands/string.js.map +1 -1
  150. package/operations/filter/types.d.ts +13 -1
  151. package/operations/filter/types.js.map +1 -1
  152. package/operations/filter.d.ts +6 -0
  153. package/operations/filter.js +23 -7
  154. package/operations/filter.js.map +1 -1
  155. package/operations/quick-filter.js +2 -5
  156. package/operations/quick-filter.js.map +1 -1
  157. package/operations/sort.d.ts +21 -2
  158. package/operations/sort.js +41 -14
  159. package/operations/sort.js.map +1 -1
  160. package/package.json +8 -3
  161. package/setup.d.ts +11 -0
  162. package/setup.js +9 -19
  163. package/setup.js.map +1 -1
  164. package/styles/_token-values.css.d.ts +1 -0
  165. package/styles/_token-values.css.js +3 -0
  166. package/styles/_token-values.css.js.map +1 -0
  167. package/styles/_tokens.css.js +1 -1
  168. package/styles/_tokens.css.js.map +1 -1
  169. package/styles/body-cell/body-cell.css.js +1 -1
  170. package/styles/body-cell/body-cell.css.js.map +1 -1
  171. package/styles/body-cell/cell-renderers.css.js +1 -1
  172. package/styles/body-cell/cell-renderers.css.js.map +1 -1
  173. package/styles/body-row/body-row.css.js +1 -1
  174. package/styles/body-row/body-row.css.js.map +1 -1
  175. package/styles/document-tokens.css.d.ts +1 -0
  176. package/styles/document-tokens.css.js +3 -0
  177. package/styles/document-tokens.css.js.map +1 -0
  178. package/styles/filter-row/filter-row.css.js +1 -1
  179. package/styles/filter-row/filter-row.css.js.map +1 -1
  180. package/styles/grid/_grid.base.css.js +1 -1
  181. package/styles/grid/_grid.base.css.js.map +1 -1
  182. package/styles/grid/grid.css.js +1 -1
  183. package/styles/grid/grid.css.js.map +1 -1
  184. package/styles/group-header-row/group-header-row.css.js +1 -1
  185. package/styles/group-header-row/group-header-row.css.js.map +1 -1
  186. package/styles/header-cell/header-cell.css.js +1 -1
  187. package/styles/header-cell/header-cell.css.js.map +1 -1
  188. package/styles/header-row/header-row.base.css.js +1 -1
  189. package/styles/header-row/header-row.base.css.js.map +1 -1
  190. package/styles/paginator/paginator.css.js +1 -1
  191. package/styles/paginator/paginator.css.js.map +1 -1
  192. package/styles/toolbar/toolbar.css.js +1 -1
  193. package/styles/toolbar/toolbar.css.js.map +1 -1
  194. package/tokens.css +78 -0
  195. package/LICENSE +0 -80
  196. package/docs/media/LICENSE +0 -80
  197. package/docs/media/_tokens.scss +0 -214
@@ -1,6 +1,6 @@
1
1
  import type { ReactiveController } from 'lit';
2
2
  import type { ColumnConfiguration, EditMode, EditTrigger, GridHost, Keys } from '../internal/types.js';
3
- import type { HistoryController } from './history.js';
3
+ import type { EditCommand, HistoryController } from './history.js';
4
4
  /**
5
5
  * The default editing configuration used when the grid has none set.
6
6
  */
@@ -10,11 +10,17 @@ export declare const DEFAULT_EDITING_CONFIG: Readonly<{
10
10
  trigger: EditTrigger;
11
11
  }>;
12
12
  interface ActiveCell<T> {
13
+ /**
14
+ * The record's view index (matches {@link ApexGrid.pageItems}), refreshed
15
+ * after every grid update; `-1` for a pinned record or one on another page.
16
+ */
13
17
  rowIndex: number;
14
18
  columnKey: Keys<T>;
15
19
  /**
16
20
  * Live reference to the underlying record (preserved through the pipeline so
17
- * the source array can be mutated on commit).
21
+ * the source array can be mutated on commit). The edit is bound to this
22
+ * record, never to the view index, so a sort, filter, page or data change
23
+ * cannot move the editor onto another record.
18
24
  */
19
25
  data: T;
20
26
  }
@@ -39,6 +45,12 @@ export interface ApplyCellEditOptions {
39
45
  * previously valid value during undo/redo).
40
46
  */
41
47
  validate?: boolean;
48
+ /**
49
+ * Emit the cancellable `cellValueChanging` before writing. Defaults to
50
+ * `true`. Set to `false` when the caller already ran the gate for this
51
+ * write (a row commit gates every cell before writing any).
52
+ */
53
+ gate?: boolean;
42
54
  }
43
55
  /**
44
56
  * Reactive controller backing inline cell + row editing.
@@ -56,7 +68,10 @@ export declare class EditingController<T extends object> implements ReactiveCont
56
68
  protected history?: HistoryController<T> | undefined;
57
69
  /** The cell currently in edit mode, or `null`. */
58
70
  activeCell: ActiveCell<T> | null;
59
- /** The row currently in edit mode (row mode only), or `null`. */
71
+ /**
72
+ * The row currently in edit mode (row mode only), or `null`. Bound to its
73
+ * record like {@link activeCell}.
74
+ */
60
75
  activeRow: {
61
76
  rowIndex: number;
62
77
  data: T;
@@ -64,18 +79,27 @@ export declare class EditingController<T extends object> implements ReactiveCont
64
79
  /**
65
80
  * Pending values keyed by column for the currently editing row. Populated in
66
81
  * row mode as the user edits individual cells; flushed on
67
- * {@link commitRow}.
82
+ * {@link commitRow}. Holds only values that differ from the record.
68
83
  */
69
84
  pending: Map<Keys<T>, unknown>;
70
85
  /**
71
- * Monotonic token bumped whenever the validation-error set changes. Forwarded
72
- * down to each cell as a reactive property so a validation-only change
73
- * re-renders the affected cells (toggling `aria-invalid` and the error node)
74
- * without re-running the data pipeline. Stays `0` until the first failure.
86
+ * Monotonic token bumped whenever the validation-error set or the staged
87
+ * row-mode values change. Forwarded down to each cell as a reactive property
88
+ * so such a change re-renders the affected cells (toggling `aria-invalid`
89
+ * and the error node, showing a staged value) without re-running the data
90
+ * pipeline. Stays `0` until the first failure or staged value.
75
91
  */
76
92
  get validationVersion(): number;
77
93
  constructor(host: GridHost<T>, history?: HistoryController<T> | undefined);
78
94
  hostConnected(): void;
95
+ /**
96
+ * Keeps an open edit bound to its record after the view changed: refreshes
97
+ * the reported view index, and cancels the edit when the record left the
98
+ * view (removed, filtered out, replaced by a copy), so no hidden editor can
99
+ * commit later. A record on another page or in a pinned band stays open.
100
+ * Runs only while an edit is open.
101
+ */
102
+ hostUpdated(): void;
79
103
  /**
80
104
  * Whether editing is enabled at the grid level.
81
105
  */
@@ -93,22 +117,29 @@ export declare class EditingController<T extends object> implements ReactiveCont
93
117
  */
94
118
  isEditable(column: ColumnConfiguration<T>): boolean;
95
119
  /**
96
- * Whether the cell `(rowIndex, columnKey)` is currently in edit mode.
120
+ * Whether the cell `(data, columnKey)` is currently in edit mode.
97
121
  */
98
- isCellEditing(rowIndex: number, columnKey: Keys<T>): boolean;
122
+ isCellEditing(data: T, columnKey: Keys<T>): boolean;
99
123
  /**
100
- * Whether the given row is currently in edit mode (row mode).
124
+ * Begins editing the cell at `(rowIndex, columnKey)`, where `rowIndex` is
125
+ * the view index (matches {@link ApexGrid.pageItems}). See
126
+ * {@link editRecord}.
101
127
  */
102
- isRowEditing(rowIndex: number): boolean;
128
+ editCell(rowIndex: number, columnKey: Keys<T>): Promise<boolean>;
103
129
  /**
104
- * Begins editing the cell at `(rowIndex, columnKey)`. Auto-commits any cell
105
- * already in edit mode (in cell mode); in row mode it switches the active
106
- * cell within the same row and rejects cross-row moves.
130
+ * Begins editing the `columnKey` cell of the record `data`, a body or a
131
+ * pinned row. Auto-commits any cell already in edit mode (in cell mode); in
132
+ * row mode it stages that cell and commits the row first on a cross-row
133
+ * move.
107
134
  *
108
- * @returns `true` if edit started, `false` if rejected (column not editable
109
- * or row-mode constraint violated).
135
+ * @returns `true` if edit started, `false` if rejected (column not editable,
136
+ * `data` a row a feature synthesized, the in-flight cell's commit was
137
+ * rejected, or the previous row could not be committed). A rejected commit
138
+ * keeps the in-flight editor open, unless its record is on another page:
139
+ * an edit the user cannot see or correct is cancelled instead, so it cannot
140
+ * block every other edit.
110
141
  */
111
- editCell(rowIndex: number, columnKey: Keys<T>): Promise<boolean>;
142
+ editRecord(data: T, columnKey: Keys<T>): Promise<boolean>;
112
143
  /**
113
144
  * Begins editing the given row in row mode. Emits `rowEditStarted` on
114
145
  * success. No-op in cell mode.
@@ -133,8 +164,18 @@ export declare class EditingController<T extends object> implements ReactiveCont
133
164
  * Runs the column's declarative validators against a candidate value and
134
165
  * returns the collected error messages (empty when the value passes or the
135
166
  * column has no validators).
167
+ *
168
+ * @param row - What validators see as `ctx.data`: the record itself, or in
169
+ * a row commit the staged row (the record with the staged values applied).
136
170
  */
137
- validateCell(rowIndex: number, columnKey: Keys<T>, data: T, value: unknown): string[];
171
+ validateCell(rowIndex: number, columnKey: Keys<T>, data: T, value: unknown, row?: T): string[];
172
+ /**
173
+ * The staged row-mode values of `data` keyed by column, or `null` when
174
+ * `data` is not the row in edit. Cells read it to show staged values.
175
+ */
176
+ stagedValues(data: T): ReadonlyMap<Keys<T>, unknown> | null;
177
+ /** The command staged with the row edit of `data` for `columnKey`, if any. */
178
+ stagedEffect(data: T, columnKey: Keys<T>): EditCommand | undefined;
138
179
  /**
139
180
  * The current validation errors for `(data, columnKey)`, or `null` when the
140
181
  * cell is valid. Read by {@link ApexGridCell} to drive `aria-invalid` and the
@@ -149,26 +190,51 @@ export declare class EditingController<T extends object> implements ReactiveCont
149
190
  * Clears every validation error recorded for a record (all columns).
150
191
  */
151
192
  clearRecordErrors(data: T): void;
193
+ /**
194
+ * Records the open editor's current, uncommitted value. A later
195
+ * {@link commitCell} without an argument commits it. No-op while no cell is
196
+ * in edit mode.
197
+ */
198
+ setDraft(value: unknown): void;
199
+ /**
200
+ * The draft held for the open editor of `(data, columnKey)`, or `null` when
201
+ * that cell is not in edit or nothing was typed. An editor rendered again
202
+ * for an edit already open (its record paged or scrolled back into view)
203
+ * resumes from it, so it shows what a bare {@link commitCell} commits.
204
+ */
205
+ heldDraft(data: T, columnKey: Keys<T>): {
206
+ value: unknown;
207
+ } | null;
152
208
  /**
153
209
  * Commits a candidate value for the currently editing cell. In cell mode the
154
210
  * value is written through to {@link ApexGrid.data}; in row mode it is staged
155
211
  * in {@link pending} until {@link commitRow} is called.
156
212
  *
157
- * @param value - The candidate value.
213
+ * @param args - The candidate value, committed as given (`undefined`
214
+ * included). Called with no argument, it commits the open editor's draft
215
+ * (see {@link setDraft}), or keeps the current value when nothing was typed.
216
+ * An optional command rides with the value: it runs once the value is
217
+ * accepted (or, in row mode, when the row commits), joins the same undo
218
+ * step, and is dropped when the edit is rejected or the row cancelled.
158
219
  * @returns `true` if accepted (or staged), `false` if rejected by
159
- * `cellValueChanging.preventDefault()`.
220
+ * `cellValueChanging.preventDefault()` or a validator.
160
221
  */
161
- commitCell(value?: unknown): Promise<boolean>;
222
+ commitCell(...args: [value?: unknown, effect?: EditCommand]): Promise<boolean>;
162
223
  /**
163
- * Writes `value` directly to the cell at `(rowIndex, columnKey)` without
164
- * entering edit mode. Used by interactive display widgets (e.g. the boolean
165
- * checkbox) that handle their own input. Goes through the same
166
- * `cellValueChanging` / `cellValueChanged` event path as a normal commit.
224
+ * Writes `value` directly to the `columnKey` cell of the record `data` (a
225
+ * body or a pinned row) without entering edit mode. Used by interactive
226
+ * display widgets (e.g. the boolean checkbox) that handle their own input.
227
+ * Goes through the same `cellValueChanging` / `cellValueChanged` event path
228
+ * as a normal commit. In row mode the value joins the row's staged values
229
+ * instead (opening the row edit first), so it commits or cancels with the
230
+ * rest of the row.
167
231
  *
168
- * @returns `true` if the value was applied, `false` if rejected by
169
- * `cellValueChanging.preventDefault()` or the column is not editable.
232
+ * @returns `true` if the value was applied (or staged), `false` if rejected
233
+ * by `cellValueChanging.preventDefault()`, a validator, a previous row that
234
+ * could not be committed, the column is not editable, or `data` is a row a
235
+ * feature synthesized (as in {@link editRecord}).
170
236
  */
171
- commitImmediate(rowIndex: number, columnKey: Keys<T>, value: unknown): Promise<boolean>;
237
+ commitImmediate(data: T, columnKey: Keys<T>, value: unknown): Promise<boolean>;
172
238
  /**
173
239
  * Discards the current cell edit without writing. In row mode the row edit
174
240
  * stays open.
@@ -178,8 +244,15 @@ export declare class EditingController<T extends object> implements ReactiveCont
178
244
  * Commits all pending edits for the currently editing row. Emits
179
245
  * `cellValueChanging` for every changed cell and `rowEditEnded` at the end.
180
246
  *
181
- * @returns `true` if the row was applied, `false` if any cell change was
182
- * cancelled (the row remains in edit mode in that case).
247
+ * @remarks
248
+ * Validators see the staged row as `ctx.data`, and once any value is staged
249
+ * the other editable cells of the row are validated too, so a cross-field
250
+ * rule judges the row being saved. Every cell passes its `cellValueChanging`
251
+ * gate before any is written: an invalid or cancelled cell aborts the whole
252
+ * row.
253
+ *
254
+ * @returns `true` if the row was applied, `false` if any cell failed
255
+ * validation or its change was cancelled (the row remains in edit mode).
183
256
  */
184
257
  commitRow(): Promise<boolean>;
185
258
  /**
@@ -187,11 +260,5 @@ export declare class EditingController<T extends object> implements ReactiveCont
187
260
  * Emits `rowEditEnded` with `committed: false`.
188
261
  */
189
262
  cancelRow(): void;
190
- /**
191
- * Returns the current pending or committed value for `(rowIndex, columnKey)`.
192
- * Cells in row mode read this so unstaged-but-pending values are reflected
193
- * during the edit.
194
- */
195
- getValue(rowIndex: number, columnKey: Keys<T>): unknown;
196
263
  }
197
264
  export {};