apex-grid 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -0
- package/README.md +74 -6
- package/components/cell.d.ts +2 -2
- package/components/cell.js +30 -2
- package/components/cell.js.map +1 -1
- package/components/filter-row.js +65 -6
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +132 -0
- package/components/grid.js +59 -2
- package/components/grid.js.map +1 -1
- package/components/header-row.js +8 -0
- package/components/header-row.js.map +1 -1
- package/components/header.js +85 -12
- package/components/header.js.map +1 -1
- package/components/row.js +32 -4
- package/components/row.js.map +1 -1
- package/components/virtualizer.d.ts +5 -1
- package/components/virtualizer.js +72 -2
- package/components/virtualizer.js.map +1 -1
- package/controllers/expansion.js +4 -4
- package/controllers/expansion.js.map +1 -1
- package/controllers/filter.js +11 -0
- package/controllers/filter.js.map +1 -1
- package/controllers/history.js +11 -4
- package/controllers/history.js.map +1 -1
- package/controllers/navigation.d.ts +35 -2
- package/controllers/navigation.js +102 -8
- package/controllers/navigation.js.map +1 -1
- package/controllers/pagination.js +1 -1
- package/controllers/pagination.js.map +1 -1
- package/controllers/reorder.js +4 -2
- package/controllers/reorder.js.map +1 -1
- package/controllers/row-pin.js +2 -2
- package/controllers/row-pin.js.map +1 -1
- package/controllers/row-reorder.js +6 -6
- package/controllers/row-reorder.js.map +1 -1
- package/controllers/selection.js +3 -3
- package/controllers/selection.js.map +1 -1
- package/controllers/sort.js +4 -2
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +9 -3
- package/controllers/state.js +11 -1
- package/controllers/state.js.map +1 -1
- package/custom-elements.json +664 -190
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/ApexGrid.html +586 -0
- package/docs/classes/ApexGridPaginator.html +36 -0
- package/docs/classes/ApexGridToolbar.html +67 -0
- package/docs/functions/localize.html +2 -2
- package/docs/functions/setup.html +1 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +94 -6
- package/docs/interfaces/ApexCellValidationFailedEvent.html +1 -1
- package/docs/interfaces/ApexCellValueChangedEvent.html +1 -1
- package/docs/interfaces/ApexCellValueChangingEvent.html +2 -2
- package/docs/interfaces/ApexColumnMovedEvent.html +2 -2
- package/docs/interfaces/ApexColumnMovingEvent.html +1 -1
- package/docs/interfaces/ApexDetailContext.html +2 -2
- package/docs/interfaces/ApexGridEventMap.html +5 -5
- package/docs/interfaces/ApexRowMovingEvent.html +1 -1
- package/docs/interfaces/ApexRowPinningEvent.html +1 -1
- package/docs/interfaces/BaseApexCellContext.html +1 -1
- package/docs/interfaces/BaseApexEditorContext.html +1 -1
- package/docs/interfaces/BaseColumnConfiguration.html +3 -3
- package/docs/interfaces/CSVExportOptions.html +2 -2
- package/docs/interfaces/DataPipelineConfiguration.html +2 -2
- package/docs/interfaces/EditingHistoryConfiguration.html +1 -1
- package/docs/interfaces/ExportFormat.html +2 -2
- package/docs/interfaces/ExportOptions.html +1 -1
- package/docs/interfaces/GridRowPinningConfiguration.html +1 -1
- package/docs/interfaces/GridRowReorderingConfiguration.html +2 -2
- package/docs/interfaces/PaginationConfiguration.html +1 -1
- package/docs/interfaces/PaginationState.html +1 -1
- package/docs/media/_tokens.scss +29 -8
- package/docs/media/package.json +4 -5
- package/docs/media/state-persistence.html +0 -10
- package/docs/modules.html +1 -1
- package/docs/types/DataPipelineParams.html +2 -2
- package/docs/types/EditMode.html +2 -2
- package/docs/types/GridLocaleText.html +1 -1
- package/docs/types/PaginationMode.html +1 -1
- package/docs/variables/EN_LOCALE.html +3 -3
- package/docs/variables/esLocale.html +1 -1
- package/i18n/en.d.ts +109 -1
- package/i18n/en.js +109 -1
- package/i18n/en.js.map +1 -1
- package/i18n/es.js +109 -1
- package/i18n/es.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/internal/column-types.js +1 -1
- package/internal/column-types.js.map +1 -1
- package/internal/feature-module.d.ts +22 -0
- package/internal/feature-module.js +5 -0
- package/internal/feature-module.js.map +1 -1
- package/internal/index.d.ts +2 -2
- package/internal/index.js +1 -1
- package/internal/index.js.map +1 -1
- package/internal/utils.d.ts +14 -0
- package/internal/utils.js +5 -0
- package/internal/utils.js.map +1 -1
- package/package.json +1 -2
- package/setup.d.ts +12 -11
- package/setup.js +12 -4
- package/setup.js.map +1 -1
- package/styles/_common.css.js +1 -1
- package/styles/_common.css.js.map +1 -1
- package/styles/_tokens.css.js +1 -1
- package/styles/_tokens.css.js.map +1 -1
- package/styles/body-cell/body-cell.css.js +1 -1
- package/styles/body-cell/body-cell.css.js.map +1 -1
- package/styles/body-row/body-row.css.js +1 -1
- package/styles/body-row/body-row.css.js.map +1 -1
- package/styles/filter-row/filter-row.css.js +1 -1
- package/styles/filter-row/filter-row.css.js.map +1 -1
- package/styles/grid/_grid.base.css.js +1 -1
- package/styles/grid/_grid.base.css.js.map +1 -1
- package/styles/grid/grid.css.js +1 -1
- package/styles/grid/grid.css.js.map +1 -1
- package/styles/group-header-row/group-header-row.css.js +1 -1
- package/styles/group-header-row/group-header-row.css.js.map +1 -1
- package/styles/header-cell/header-cell.css.js +1 -1
- package/styles/header-cell/header-cell.css.js.map +1 -1
- package/styles/header-row/header-row.base.css.js +1 -1
- package/styles/header-row/header-row.base.css.js.map +1 -1
- package/styles/paginator/paginator.css.js +1 -1
- package/styles/paginator/paginator.css.js.map +1 -1
- package/styles/toolbar/toolbar.css.js +1 -1
- package/styles/toolbar/toolbar.css.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,149 @@ All notable changes to the `apex-grid` (community) package are documented here.
|
|
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
|
|
5
5
|
and the format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
6
|
|
|
7
|
+
## [3.5.0] - 2026-09-12
|
|
8
|
+
|
|
9
|
+
A feature and accessibility release. No exported symbol was removed or renamed.
|
|
10
|
+
Two consumer-visible changes are listed under Changed and Removed: the Ignite UI
|
|
11
|
+
dependencies are gone, and `setup({ theme })` is now inert.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- **Right-to-left support.** `dir="rtl"` on the grid or any ancestor mirrors it
|
|
15
|
+
completely. Direction is read from the computed style rather than the `dir`
|
|
16
|
+
attribute, so an inherited direction works. The stylesheets were already
|
|
17
|
+
written in logical properties; what changed is the code that reasoned in
|
|
18
|
+
physical pixels or physical key names: ArrowLeft / ArrowRight map onto
|
|
19
|
+
previous / next column by inline order, column resize takes width off the
|
|
20
|
+
inline-start edge, and column reorder flips its midpoint comparison. (The
|
|
21
|
+
enterprise range and chart-range handles had a matching fix; see that
|
|
22
|
+
package's 0.7.0 entry.)
|
|
23
|
+
- **`grid.applyEdits(edits)`**, a programmatic batch write. Previously the only
|
|
24
|
+
write path was `editCell` + `commitEdit`, which drives the editor, so a bulk
|
|
25
|
+
write meant a thousand undo entries and a thousand re-renders. Each write still
|
|
26
|
+
emits cancellable `cellValueChanging` then `cellValueChanged` and still runs
|
|
27
|
+
the column's validators, while the batch lands as one undo step and one
|
|
28
|
+
pipeline run. It returns a tally rather than a count, splitting `applied` from
|
|
29
|
+
`unchanged`, `invalid`, `cancelled` and `skipped`, since "nothing changed" and
|
|
30
|
+
"everything was rejected" are different answers. Out-of-range rows and
|
|
31
|
+
non-editable columns are skipped rather than thrown on, so a partially stale
|
|
32
|
+
batch still applies what it can.
|
|
33
|
+
- **Reduced-motion support.** Every transition now routes through one of the
|
|
34
|
+
`--ag-dur-*` tokens, and those zero under `prefers-reduced-motion: reduce`:
|
|
35
|
+
24 transitions across 9 stylesheets go instant with their end states
|
|
36
|
+
unchanged. The JS-driven row reorder and expansion animations already bailed
|
|
37
|
+
out.
|
|
38
|
+
- **Forced-colors support.** Forced colors paints no `box-shadow`, and the grid
|
|
39
|
+
leaned on inset shadows for exactly the indicators that matter most, so in
|
|
40
|
+
Windows High Contrast a keyboard user had no visible cursor and no visible
|
|
41
|
+
selection. The active-cell ring, invalid-cell ring, selected-row bar and every
|
|
42
|
+
toolbar and filter focus ring are restated as outlines, which forced colors
|
|
43
|
+
recolours rather than drops and which sit outside layout, so nothing shifts.
|
|
44
|
+
- **The Custom Elements Manifest is now authoritative for `<apex-grid>`.** The
|
|
45
|
+
element was missing from `custom-elements.json` entirely: no `tagName`, not
|
|
46
|
+
flagged `customElement`, and zero named events. It now resolves
|
|
47
|
+
`customElement`, `tagName`, all 29 `ApexGridEventMap` events, the `theme`
|
|
48
|
+
attribute and the public `@property` fields, and a build-time drift check
|
|
49
|
+
fails the build when any of them diverge. This is what the new
|
|
50
|
+
`react-apex-grid` wrapper package generates from, and what editor tooling
|
|
51
|
+
reads for completions.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- **Target sizes meet WCAG 2.2 AA 2.5.8 (24x24).** The selection cell and the
|
|
55
|
+
select-all header cell forward clicks to their checkbox rather than growing a
|
|
56
|
+
deliberately small 14x14 mark. The header sort / filter / menu buttons reach
|
|
57
|
+
24x24 through the invisible chip that already expanded them, so the visible
|
|
58
|
+
16px box and the packed header layout are unchanged and nothing paints at
|
|
59
|
+
rest. **Paginator buttons grow from 22 to 24, which makes the paginator bar
|
|
60
|
+
2px taller.** The range fill handle stays a 10px grab band, now documented as
|
|
61
|
+
a criterion-permitted exception rather than a gap: it is reachable through
|
|
62
|
+
controls that do meet 24x24, and its position at the range corner is
|
|
63
|
+
essential to what it means.
|
|
64
|
+
- **`setup({ theme })` is inert and warns once.** It only ever forwarded to
|
|
65
|
+
Ignite UI's `configureTheme()`, which was already documented as not affecting
|
|
66
|
+
the grid's appearance. It still compiles, so no consumer code breaks; the
|
|
67
|
+
warning is there because silently dropping the forwarding would leave an
|
|
68
|
+
Ignite UI host app unthemed with no clue why.
|
|
69
|
+
|
|
70
|
+
### Removed
|
|
71
|
+
- **The `igniteui-webcomponents` and `igniteui-theming` dependencies.** Core
|
|
72
|
+
carried the first as a runtime dependency and enterprise as a peer, so every
|
|
73
|
+
consumer installed a whole component library (plus `@floating-ui`) for one
|
|
74
|
+
inert pass-through. The grid registers no Ignite UI element.
|
|
75
|
+
`igniteui-theming` was a Sass dependency for exactly one function, `rem()`,
|
|
76
|
+
now reimplemented locally with the same conversion, and it emitted 55 Sass
|
|
77
|
+
deprecation warnings per build. Five packages leave the lockfile, and the
|
|
78
|
+
compiled CSS is 3,718 bytes smaller with every `rem()` output byte-identical.
|
|
79
|
+
- **The `--igx-*` custom-property level.** Every colour rule resolved through
|
|
80
|
+
three levels and the first never fired: `--igx-*` is the igniteui-angular
|
|
81
|
+
naming convention, not the web-components one, so it was dead indirection in
|
|
82
|
+
front of the two levels that work. `--ag-*` overrides and the unprefixed
|
|
83
|
+
semantic variables behave exactly as before. The `--ig-primary-*` and
|
|
84
|
+
`--ig-font-family` hooks stay, since those are what an Ignite UI theme
|
|
85
|
+
actually sets and reading a variable with a default costs nothing when absent.
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
88
|
+
- **A grid could settle with zero rendered rows at first paint**, silently,
|
|
89
|
+
while reporting a correct `ariaRowCount` and a correctly sized scroll region
|
|
90
|
+
([#31](https://github.com/apexcharts/apex-grid/issues/31)). The virtualizer
|
|
91
|
+
derives its viewport from the intersection of the body, its clipping ancestors
|
|
92
|
+
and the window, and clears the rendered range when that intersection is
|
|
93
|
+
zero-height while still sizing the scroll extent from the full item count. It
|
|
94
|
+
could not recover, because the only invalidation signals it listens for are
|
|
95
|
+
size changes and scroll events: a body that moves into view, or a window that
|
|
96
|
+
resizes around a fixed-size host, fires neither. An iframe sized by its host
|
|
97
|
+
page after load hits this, as does content above the grid that is still
|
|
98
|
+
settling. The body now watches its own intersection with the window and
|
|
99
|
+
re-measures when it gains a visible slice with nothing rendered, bounded to
|
|
100
|
+
three attempts per geometry change and skipped entirely when there is no
|
|
101
|
+
visible slice.
|
|
102
|
+
- **A grid moved to another parent left its body permanently stale**, still
|
|
103
|
+
rendering the old rows after `data` was reassigned. The body awaited
|
|
104
|
+
virtualizer state before calling `super.connectedCallback()`, which deadlocks
|
|
105
|
+
on a reconnect: the promise waits on a layout that only runs once the update
|
|
106
|
+
cycle that call starts.
|
|
107
|
+
|
|
108
|
+
## [3.4.0] - 2026-07-17
|
|
109
|
+
|
|
110
|
+
An accessibility-focused release. The public module API is unchanged (no
|
|
111
|
+
exported symbol was added, removed, or renamed); two keyboard and editing
|
|
112
|
+
behaviors changed, listed under Changed below.
|
|
113
|
+
|
|
114
|
+
### Added
|
|
115
|
+
- **Keyboard editing and navigation.** Enter or F2 opens the active cell's
|
|
116
|
+
editor (previously editing was pointer-only); PageUp / PageDown move by a
|
|
117
|
+
viewport page; Ctrl/Cmd+Home and Ctrl/Cmd+End jump to the grid's first and
|
|
118
|
+
last cell.
|
|
119
|
+
- **Roving-tabindex focus model.** The active cell is the grid body's single
|
|
120
|
+
tab stop, so real focus follows arrow-key navigation and screen readers
|
|
121
|
+
track cell-to-cell movement. Keyboard-driven commit or cancel returns focus
|
|
122
|
+
to the cell.
|
|
123
|
+
- **Localized live-region announcements** for sorting, filtering, selection,
|
|
124
|
+
paging, row pinning, row reorder, expansion, and undo / redo, plus localized
|
|
125
|
+
header control labels and sort-state descriptions. New locale keys under
|
|
126
|
+
`announce.*` and `header.*`, along with `grid.label` and `editor.rating`
|
|
127
|
+
(English and Spanish).
|
|
128
|
+
- The grid host now applies a localized `aria-label` ("Data grid") unless the
|
|
129
|
+
author sets `aria-label` / `aria-labelledby`, and reflects
|
|
130
|
+
`aria-multiselectable` when multi-row selection is enabled.
|
|
131
|
+
- **Locale keys for the enterprise chart panel** (`chart.*`) and the reworked
|
|
132
|
+
enterprise AI surface (`ai.*`). Inert in the community grid.
|
|
133
|
+
- **Error-value rendering.** A spreadsheet-style error value (an object with a
|
|
134
|
+
`#...` code, such as the enterprise formula engine's `#VALUE!`) now renders
|
|
135
|
+
as its code in typed (number / currency) columns instead of being coerced to
|
|
136
|
+
`NaN` and showing an empty cell.
|
|
137
|
+
|
|
138
|
+
### Changed
|
|
139
|
+
- **Home / End now move within the row** (first / last cell of the active
|
|
140
|
+
row), matching the common data-grid convention; previously they jumped to
|
|
141
|
+
the first / last row. Use Ctrl/Cmd+Home / Ctrl/Cmd+End for the grid corners.
|
|
142
|
+
- **Clearing a number or currency editor commits `null`, not `NaN`.** An empty
|
|
143
|
+
or unparseable numeric input previously wrote `NaN` into the row.
|
|
144
|
+
|
|
145
|
+
### Removed
|
|
146
|
+
- The `ai.noAdapter` locale key (the enterprise AI adapter API it supported
|
|
147
|
+
was replaced; see the `apex-grid-enterprise` 0.6.0 changelog). If you
|
|
148
|
+
overrode this key in `localeText`, remove it.
|
|
149
|
+
|
|
7
150
|
## [3.3.0] - 2026-07-02
|
|
8
151
|
|
|
9
152
|
A large, additive, backward-compatible release. The public `.` / `./define` API
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ A Lit-based, framework-agnostic web component data grid. Ships as a single custo
|
|
|
29
29
|
- **CSV export**: programmatic method plus an optional toolbar dropdown. (Excel/XLSX export is in `apex-grid-enterprise`.)
|
|
30
30
|
- **Toolbar**: opt-in `<apex-grid-toolbar>` with debounced quick filter and export menu.
|
|
31
31
|
- **Templating**: slot-based templates for cells, headers, editors, and detail panels.
|
|
32
|
-
- **Theming**: styled out-of-the-box; fully customizable through `--ag-*` CSS custom properties (no theme import or build step). Auto-
|
|
32
|
+
- **Theming**: styled out-of-the-box; fully customizable through `--ag-*` CSS custom properties (no theme import or build step). Auto-tints to an Ignite UI host app's palette when one is present, with no dependency on it.
|
|
33
33
|
- **Accessibility**: WCAG 2.2 AA semantics (`role="grid"` / `role="treegrid"`, `aria-rowcount`, `aria-colcount`, focus + keyboard navigation).
|
|
34
34
|
- **Provenance-signed npm releases** with OIDC trusted publishing.
|
|
35
35
|
|
|
@@ -94,8 +94,6 @@ If you'd rather not use `setup()`, this is what it does under the hood. Skipping
|
|
|
94
94
|
npm install apex-grid lit
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
`igniteui-webcomponents` ships as a transitive dependency; no separate install.
|
|
98
|
-
|
|
99
97
|
### 2. Register the custom element
|
|
100
98
|
|
|
101
99
|
```ts
|
|
@@ -133,7 +131,7 @@ apex-grid { --ag-grid-shadow: var(--ag-shadow-card); } /* elevated floating-card
|
|
|
133
131
|
apex-grid { --ag-grid-shadow: none; } /* remove the edge entirely */
|
|
134
132
|
```
|
|
135
133
|
|
|
136
|
-
If you embed the grid
|
|
134
|
+
If you embed the grid in an Ignite UI app, the brand tokens automatically re-tint from its palette: they read `--ig-primary-500` with the grid's own default as the fallback. That is a plain CSS variable lookup, so the grid neither depends on nor bundles Ignite UI.
|
|
137
135
|
|
|
138
136
|
### 4. Size the host
|
|
139
137
|
|
|
@@ -281,7 +279,7 @@ A persistent vertical divider on each column header's trailing edge, on by defau
|
|
|
281
279
|
grid.columnSeparator = false; // hide the dividers
|
|
282
280
|
```
|
|
283
281
|
|
|
284
|
-
Theme the line with `--ag-header-separator` (or the `--header-separator-color`
|
|
282
|
+
Theme the line with `--ag-header-separator` (or the `--header-separator-color` override hook) and set its vertical inset with `--apex-header-separator-inset`. Because the default is `true`, disable it through the property rather than markup (a default-on boolean attribute cannot be turned off by attribute alone). Attribute: `column-separator`.
|
|
285
283
|
|
|
286
284
|
### Column groups (spanning headers)
|
|
287
285
|
|
|
@@ -317,6 +315,54 @@ grid.cancelEdit();
|
|
|
317
315
|
|
|
318
316
|
`mode: 'row'` puts all editable cells in the row into edit together. Properties: `editingCell`, `editingRow`. Events: `cellValueChanging` (cancellable), `cellValueChanged`, plus `rowEditStarted` / `rowEditEnded` in row mode.
|
|
319
317
|
|
|
318
|
+
For programmatic writes, `applyEdits()` takes many cells at once:
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
const { applied, invalid, skipped } = grid.applyEdits([
|
|
322
|
+
{ rowIndex: 0, column: 'name', value: 'Ada' },
|
|
323
|
+
{ rowIndex: 1, column: 'age', value: 36 },
|
|
324
|
+
]);
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Each write goes through the same choke point interactive editing uses, so it
|
|
328
|
+
emits `cellValueChanging` / `cellValueChanged` and runs the column's validators.
|
|
329
|
+
What differs from looping over `editCell` + `commitEdit` is that the whole batch
|
|
330
|
+
lands as **one** undo step and triggers **one** pipeline run — a thousand
|
|
331
|
+
round-trips would otherwise mean a thousand undo entries and a thousand
|
|
332
|
+
re-renders. The returned tally splits `applied` from `unchanged`, `invalid`,
|
|
333
|
+
`cancelled`, and `skipped`, so a rejected batch is distinguishable from a no-op
|
|
334
|
+
one. Edits naming a row out of range or a column the user could not edit either
|
|
335
|
+
are skipped rather than throwing.
|
|
336
|
+
|
|
337
|
+
### Keyboard navigation and accessibility
|
|
338
|
+
|
|
339
|
+
The grid body is a single tab stop: Tab enters the grid, and the active cell
|
|
340
|
+
holds real focus (a roving tabindex), so screen readers follow the cursor as
|
|
341
|
+
it moves. Keys, with editing enabled where relevant:
|
|
342
|
+
|
|
343
|
+
| Keys | Action |
|
|
344
|
+
|---|---|
|
|
345
|
+
| Arrow keys | Move the active cell |
|
|
346
|
+
| Home / End | First / last cell **in the row** |
|
|
347
|
+
| Ctrl/Cmd+Home / Ctrl/Cmd+End | First / last cell of the grid |
|
|
348
|
+
| PageUp / PageDown | Move up / down by a viewport page |
|
|
349
|
+
| Enter or F2 | Open the active cell's editor |
|
|
350
|
+
| Enter / Tab (while editing) | Commit (Tab commits and moves) |
|
|
351
|
+
| Escape (while editing) | Cancel the edit |
|
|
352
|
+
| Space | Toggle row selection (selection column) |
|
|
353
|
+
| Ctrl/Cmd+Z / Ctrl/Cmd+Y | Undo / redo (with history enabled) |
|
|
354
|
+
|
|
355
|
+
A keyboard-driven commit or cancel returns focus to the cell, so navigation
|
|
356
|
+
continues from where you were. Sorting, filtering, selection, paging, row
|
|
357
|
+
pinning, reorder, expansion, and undo / redo are announced through a polite
|
|
358
|
+
live region, and every announcement and control label is localizable (the
|
|
359
|
+
`announce.*` and `header.*` locale keys). The host gets a localized
|
|
360
|
+
`aria-label` ("Data grid") unless you provide `aria-label` /
|
|
361
|
+
`aria-labelledby` yourself.
|
|
362
|
+
|
|
363
|
+
> Changed in 3.4.0: Home / End used to jump to the first / last row; they now
|
|
364
|
+
> stay within the row. Use Ctrl/Cmd+Home / Ctrl/Cmd+End for the grid corners.
|
|
365
|
+
|
|
320
366
|
### Cell validation
|
|
321
367
|
|
|
322
368
|
```ts
|
|
@@ -468,7 +514,7 @@ Search input has a `debounce` attribute (default `200`ms).
|
|
|
468
514
|
|
|
469
515
|
### Theming
|
|
470
516
|
|
|
471
|
-
The grid styles itself through `--ag-*` CSS custom properties; override them on `apex-grid` (or any ancestor) to rebrand; see [`src/styles/_tokens.scss`](src/styles/_tokens.scss) for the full list.
|
|
517
|
+
The grid styles itself through `--ag-*` CSS custom properties; override them on `apex-grid` (or any ancestor) to rebrand; see [`src/styles/_tokens.scss`](src/styles/_tokens.scss) for the full list. Where an Ignite UI palette is present, the brand tokens auto-tint from `--ig-primary-500`.
|
|
472
518
|
|
|
473
519
|
Style with CSS parts on the grid, paginator, and toolbar:
|
|
474
520
|
|
|
@@ -477,6 +523,28 @@ apex-grid::part(paginator) { background: var(--surface-2); }
|
|
|
477
523
|
apex-grid-toolbar::part(search-input) { font-family: var(--font-mono); }
|
|
478
524
|
```
|
|
479
525
|
|
|
526
|
+
### Right-to-left
|
|
527
|
+
|
|
528
|
+
Set `dir="rtl"` on the grid or any ancestor and the whole grid mirrors — no
|
|
529
|
+
separate stylesheet, build flag, or option:
|
|
530
|
+
|
|
531
|
+
```html
|
|
532
|
+
<html dir="rtl">
|
|
533
|
+
<apex-grid id="grid"></apex-grid>
|
|
534
|
+
</html>
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
The stylesheets are written entirely in logical properties (`inline-size`,
|
|
538
|
+
`inset-inline-start`, `border-inline-end`, …), so layout, pinning, and the fill
|
|
539
|
+
handle follow the text direction on their own. The direction is read from the
|
|
540
|
+
*computed* style, so inheriting it from `<html>` or a wrapper works as well as
|
|
541
|
+
setting it on the grid.
|
|
542
|
+
|
|
543
|
+
Behaviour that reasons in physical directions mirrors too: ArrowLeft moves to the
|
|
544
|
+
next column rather than the previous one, column resize grows the column as the
|
|
545
|
+
pointer moves toward the (now left-hand) inline-end edge, and a column drag drops
|
|
546
|
+
on the side the cursor actually crossed.
|
|
547
|
+
|
|
480
548
|
### Spreadsheet coordinates
|
|
481
549
|
|
|
482
550
|
```ts
|
package/components/cell.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
2
|
import { type StateController } from '../controllers/state.js';
|
|
3
3
|
import type { ApexCellContext, ColumnConfiguration, PropertyType } from '../internal/types.js';
|
|
4
4
|
import type ApexGridRow from './row.js';
|
|
@@ -69,7 +69,7 @@ export default class ApexGridCell<T extends object> extends LitElement {
|
|
|
69
69
|
* an `aria-errormessage` IDREF on the host can't reach this node.
|
|
70
70
|
*/
|
|
71
71
|
protected renderError(): import("lit-html").TemplateResult<1> | null;
|
|
72
|
-
protected updated(): void;
|
|
72
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
73
73
|
protected renderDefaultEditor(): import("lit-html").TemplateResult<1>;
|
|
74
74
|
protected renderEditor(): unknown;
|
|
75
75
|
/**
|
package/components/cell.js
CHANGED
|
@@ -13,6 +13,12 @@ import { getColumnTypeRenderer } from '../internal/column-types.js';
|
|
|
13
13
|
import { registerComponent } from '../internal/register.js';
|
|
14
14
|
import { GRID_CELL_TAG } from '../internal/tags.js';
|
|
15
15
|
import { styles } from '../styles/body-cell/body-cell.css.js';
|
|
16
|
+
function isErrorLike(value) {
|
|
17
|
+
return (typeof value === 'object' &&
|
|
18
|
+
value !== null &&
|
|
19
|
+
typeof value.code === 'string' &&
|
|
20
|
+
value.code.startsWith('#'));
|
|
21
|
+
}
|
|
16
22
|
class ApexGridCell extends LitElement {
|
|
17
23
|
constructor() {
|
|
18
24
|
super(...arguments);
|
|
@@ -49,6 +55,7 @@ class ApexGridCell extends LitElement {
|
|
|
49
55
|
return;
|
|
50
56
|
this.#startEdit();
|
|
51
57
|
};
|
|
58
|
+
this.#refocusAfterEdit = false;
|
|
52
59
|
this.#commitWith = async (value) => {
|
|
53
60
|
return this.editingController.commitCell(value ?? this.#pendingValue);
|
|
54
61
|
};
|
|
@@ -60,14 +67,17 @@ class ApexGridCell extends LitElement {
|
|
|
60
67
|
switch (event.key) {
|
|
61
68
|
case 'Enter':
|
|
62
69
|
event.preventDefault();
|
|
70
|
+
this.#refocusAfterEdit = true;
|
|
63
71
|
this.#commitWith();
|
|
64
72
|
return;
|
|
65
73
|
case 'Escape':
|
|
66
74
|
event.preventDefault();
|
|
75
|
+
this.#refocusAfterEdit = true;
|
|
67
76
|
this.#cancel();
|
|
68
77
|
return;
|
|
69
78
|
case 'Tab':
|
|
70
79
|
event.preventDefault();
|
|
80
|
+
this.#refocusAfterEdit = true;
|
|
71
81
|
this.#commitWith();
|
|
72
82
|
return;
|
|
73
83
|
default:
|
|
@@ -89,11 +99,13 @@ class ApexGridCell extends LitElement {
|
|
|
89
99
|
return;
|
|
90
100
|
if (event.key === 'Escape') {
|
|
91
101
|
event.preventDefault();
|
|
102
|
+
this.#refocusAfterEdit = true;
|
|
92
103
|
this.#cancel();
|
|
93
104
|
return;
|
|
94
105
|
}
|
|
95
106
|
if (event.key === 'Tab') {
|
|
96
107
|
event.preventDefault();
|
|
108
|
+
this.#refocusAfterEdit = true;
|
|
97
109
|
this.#commitWith();
|
|
98
110
|
}
|
|
99
111
|
};
|
|
@@ -112,7 +124,12 @@ class ApexGridCell extends LitElement {
|
|
|
112
124
|
};
|
|
113
125
|
this.#handleTextInput = (event) => {
|
|
114
126
|
const target = event.target;
|
|
115
|
-
|
|
127
|
+
if (this.column.type === 'number') {
|
|
128
|
+
const numeric = target.valueAsNumber;
|
|
129
|
+
this.#pendingValue = target.value === '' || Number.isNaN(numeric) ? null : numeric;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.#pendingValue = target.value;
|
|
116
133
|
};
|
|
117
134
|
this.#handleCheckboxChange = (event) => {
|
|
118
135
|
const target = event.target;
|
|
@@ -175,6 +192,7 @@ class ApexGridCell extends LitElement {
|
|
|
175
192
|
else {
|
|
176
193
|
this.removeAttribute('aria-colindex');
|
|
177
194
|
}
|
|
195
|
+
this.tabIndex = this.active ? 0 : -1;
|
|
178
196
|
if (this.active) {
|
|
179
197
|
this.setAttribute('aria-current', 'true');
|
|
180
198
|
}
|
|
@@ -246,7 +264,7 @@ class ApexGridCell extends LitElement {
|
|
|
246
264
|
}
|
|
247
265
|
this.#decoratedKeys = applied;
|
|
248
266
|
}
|
|
249
|
-
updated() {
|
|
267
|
+
updated(changed) {
|
|
250
268
|
if (this.isEditing) {
|
|
251
269
|
const editor = this.editorElement;
|
|
252
270
|
editor?.focus();
|
|
@@ -255,6 +273,11 @@ class ApexGridCell extends LitElement {
|
|
|
255
273
|
editor.select();
|
|
256
274
|
}
|
|
257
275
|
}
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (changed.get('editing') === true && this.#refocusAfterEdit) {
|
|
279
|
+
this.#refocusAfterEdit = false;
|
|
280
|
+
this.focus();
|
|
258
281
|
}
|
|
259
282
|
}
|
|
260
283
|
#handleClick;
|
|
@@ -265,6 +288,7 @@ class ApexGridCell extends LitElement {
|
|
|
265
288
|
this.editingController.editCell(this.row.index, this.column.key);
|
|
266
289
|
}
|
|
267
290
|
#pendingValue;
|
|
291
|
+
#refocusAfterEdit;
|
|
268
292
|
#commitWith;
|
|
269
293
|
#cancel;
|
|
270
294
|
#handleKeydown;
|
|
@@ -394,6 +418,10 @@ class ApexGridCell extends LitElement {
|
|
|
394
418
|
if (this.column.cellTemplate) {
|
|
395
419
|
return this.column.cellTemplate(this.context);
|
|
396
420
|
}
|
|
421
|
+
const value = this.resolveDisplayValue();
|
|
422
|
+
if (isErrorLike(value)) {
|
|
423
|
+
return html `${value.code}`;
|
|
424
|
+
}
|
|
397
425
|
const typeRenderer = getColumnTypeRenderer(this.column.type);
|
|
398
426
|
if (typeRenderer?.display) {
|
|
399
427
|
const tree = this.state?.tree;
|
package/components/cell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell.js","sourceRoot":"","sources":["../../src/components/cell.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAwB,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAS9D,MAAqB,YAA+B,SAAQ,UAAU;IAAtE;;QA4BS,WAAM,GAAG,KAAK,CAAC;QAOf,YAAO,GAAG,KAAK,CAAC;QAsDhB,aAAQ,GAAG,CAAC,CAAC;QASb,sBAAiB,GAAG,CAAC,CAAC;QAStB,sBAAiB,GAAG,CAAC,CAAC;QAG7B,mBAAc,GAAa,EAAE,CAAC;QAM9B,YAAO,GAA6B,IAAI,CAAC;QAqIzC,iBAAY,GAAG,CAAC,KAAiB,EAAE,EAAE;YACnC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBAEnB,KAAK,CAAC,eAAe,EAAE,CAAC;gBACxB,OAAO;YACT,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,UAAU;gBAAE,OAAO;YAK7B,IAAI,IAA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AAE,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,KAAK,EAAE,CAAC;IAChD,CAAC;;;eAjiBkB,YAAY;AAexB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACA;AAMxB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CACQ;AAOhC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACrB;AAOf;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACpB;AAIhB;IAFN,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACG;AAQxB;IADT,KAAK,CAAC,2BAA2B,CAAC;mDACU;AA0CtC;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACzB;AASb;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB;AAStB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { gridStateContext, type StateController } from '../controllers/state.js';\nimport { getColumnTypeRenderer } from '../internal/column-types.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_CELL_TAG } from '../internal/tags.js';\nimport type {\n ApexCellContext,\n ApexEditorContext,\n ColumnConfiguration,\n PropertyType,\n} from '../internal/types.js';\nimport { styles } from '../styles/body-cell/body-cell.css.js';\nimport type ApexGridRow from './row.js';\n\n/**\n * Component representing a DOM cell of the Apex grid.\n *\n * @csspart cell - The cell host element.\n * @csspart editor - The editor wrapper rendered while the cell is in edit mode.\n */\nexport default class ApexGridCell<T extends object> extends LitElement {\n public static get tagName() {\n return GRID_CELL_TAG;\n }\n\n public static override styles = styles;\n\n public static register(): void {\n registerComponent(ApexGridCell);\n }\n\n /**\n * The value which will be rendered by the component.\n */\n @property({ attribute: false })\n public value!: PropertyType<T>;\n\n /**\n * A reference to the column configuration object.\n */\n @property({ attribute: false })\n public column!: ColumnConfiguration<T>;\n\n /**\n * Indicates whether this is the active cell in the grid.\n *\n */\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * Whether the cell is currently in edit mode. Set by the parent row from the\n * editing controller's state so cells re-render on edit state changes.\n */\n @property({ type: Boolean, reflect: true })\n public editing = false;\n\n @consume({ context: gridStateContext, subscribe: true })\n @property({ attribute: false })\n public state!: StateController<T>;\n\n /**\n * The parent row component holding this cell.\n */\n public row!: ApexGridRow<T>;\n\n @query('input, [data-apex-editor]')\n protected editorElement!: HTMLElement | null;\n\n protected get context(): ApexCellContext<T> {\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.value,\n } as unknown as {\n parent: ApexGridCell<T>;\n row: ApexGridRow<T>;\n column: ColumnConfiguration<T>;\n value: PropertyType<T>;\n commit?: (value: unknown) => Promise<boolean>;\n };\n // Only expose `commit` when the column is editable — non-editable\n // interactive widgets should render as read-only.\n if (this.isEditable) {\n ctx.commit = (next: unknown) =>\n this.editingController.commitImmediate(this.row.index, this.column.key, next);\n }\n return ctx as unknown as ApexCellContext<T>;\n }\n\n protected get editingController() {\n return this.state.editing;\n }\n\n protected get isEditing(): boolean {\n return this.editing;\n }\n\n protected get isEditable(): boolean {\n if (!this.editingController) return false;\n return this.editingController.isEditable(this.column);\n }\n\n /**\n * 1-based column index used to populate `aria-colindex`. Accounts for the\n * auto-rendered selection + expansion columns ahead of the data columns.\n */\n @property({ attribute: false, type: Number })\n public colindex = 0;\n\n /**\n * Reactive token forwarded from {@link StateController.decorationVersion}.\n * Changing it re-runs {@link willUpdate} so module-driven cell decoration is\n * re-evaluated when it changes (e.g. while dragging a selection range). Stays\n * `0` for the community grid, so cells are never re-decorated there.\n */\n @property({ attribute: false, type: Number })\n public decorationVersion = 0;\n\n /**\n * Reactive token forwarded from {@link EditingController.validationVersion}.\n * Changing it re-runs {@link willUpdate} so the cell re-reads its validation\n * errors and toggles `aria-invalid` / the inline error node. Stays `0` until\n * the first validation failure.\n */\n @property({ attribute: false, type: Number })\n public validationVersion = 0;\n\n /** Decoration attribute keys applied on the previous update, for cleanup. */\n #decoratedKeys: string[] = [];\n\n /** DOM id of the inline error node, referenced by `aria-errormessage`. */\n static readonly #ERROR_ID = 'apex-cell-error';\n\n /** Validation errors resolved in {@link willUpdate}, consumed in render. */\n #errors: readonly string[] | null = null;\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('role', 'gridcell');\n this.addEventListener('click', this.#handleClick);\n this.addEventListener('dblclick', this.#handleDoubleClick);\n this.addEventListener('keydown', this.#handleCellKeydown);\n this.addEventListener('focusout', this.#handleCellFocusOut);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.#handleClick);\n this.removeEventListener('dblclick', this.#handleDoubleClick);\n this.removeEventListener('keydown', this.#handleCellKeydown);\n this.removeEventListener('focusout', this.#handleCellFocusOut);\n super.disconnectedCallback();\n }\n\n protected override willUpdate() {\n if (this.colindex > 0) {\n this.setAttribute('aria-colindex', String(this.colindex));\n } else {\n this.removeAttribute('aria-colindex');\n }\n if (this.active) {\n this.setAttribute('aria-current', 'true');\n } else {\n this.removeAttribute('aria-current');\n }\n // Reflect tree-expanded state on the group cell so the SCSS chevron\n // rotation triggers from this attribute (cheaper than per-render style\n // mutations and keeps the SVG transform purely declarative).\n const tree = this.state?.tree;\n const isGroup = tree?.enabled && this.row?.data && tree.isGroupColumn(this.column.key);\n if (isGroup && tree.isExpanded(this.row.data)) {\n this.setAttribute('data-tree-expanded', '');\n } else {\n this.removeAttribute('data-tree-expanded');\n }\n\n this.#applyValidation();\n this.#applyDecoration();\n }\n\n /**\n * Reflects the cell's validation state from the editing controller: stores the\n * current error messages for {@link render} and toggles `aria-invalid` +\n * `aria-errormessage` + `data-invalid` on the host. Inert for cells whose\n * column has no validators (the lookup returns `null`).\n */\n #applyValidation(): void {\n const errors =\n this.state && this.row?.data\n ? (this.editingController?.getCellErrors(this.row.data, this.column.key) ?? null)\n : null;\n this.#errors = errors && errors.length > 0 ? errors : null;\n\n if (this.#errors) {\n this.setAttribute('aria-invalid', 'true');\n this.setAttribute('aria-errormessage', ApexGridCell.#ERROR_ID);\n this.setAttribute('data-invalid', '');\n this.setAttribute('title', this.#errors.join('; '));\n } else {\n this.removeAttribute('aria-invalid');\n this.removeAttribute('aria-errormessage');\n this.removeAttribute('data-invalid');\n this.removeAttribute('title');\n }\n }\n\n /**\n * The inline error node surfaced when the cell is invalid. `role=\"alert\"`\n * announces the message when it appears, covering the cross-shadow gap where\n * an `aria-errormessage` IDREF on the host can't reach this node.\n */\n protected renderError() {\n if (!this.#errors) return null;\n return html`<span\n part=\"cell-error\"\n id=${ApexGridCell.#ERROR_ID}\n role=\"alert\"\n >${this.#errors.join('; ')}</span\n >`;\n }\n\n /**\n * Reflects module-contributed decoration attributes (see {@link CellDecorator})\n * onto the cell host, reconciling against the previous update so attributes\n * that are no longer present are removed. Inert for the community grid:\n * `state.decorateCell` returns `null` with no modules, so nothing is set.\n */\n #applyDecoration(): void {\n const decoration =\n this.state && this.row\n ? this.state.decorateCell({\n row: this.row.data,\n rowIndex: this.row.index,\n column: this.column,\n value: this.value as unknown,\n })\n : null;\n const next = decoration?.attributes ?? {};\n\n // Remove anything we set last time that's gone (or explicitly cleared).\n for (const key of this.#decoratedKeys) {\n if (next[key] == null) this.removeAttribute(key);\n }\n\n const applied: string[] = [];\n for (const [key, value] of Object.entries(next)) {\n if (value == null) {\n this.removeAttribute(key);\n } else {\n this.setAttribute(key, value);\n applied.push(key);\n }\n }\n this.#decoratedKeys = applied;\n }\n\n protected override updated() {\n if (this.isEditing) {\n const editor = this.editorElement;\n editor?.focus();\n if (editor instanceof HTMLInputElement) {\n if (editor.type === 'text' || editor.type === 'number') {\n editor.select();\n }\n }\n }\n }\n\n #handleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n // Don't let clicks inside the editor bubble into navigation / outside-click commits.\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n // Boolean cells handle interaction in their display widget — clicking the\n // checkbox commits inline via `ctx.commit`. We never enter edit mode for\n // booleans, which avoids the visual reflow between display/editor markup\n // and lets a single click toggle the value.\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'click') return;\n this.#startEdit();\n };\n\n #handleDoubleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'doubleClick') return;\n this.#startEdit();\n };\n\n #startEdit() {\n if (!this.row) return;\n this.editingController.editCell(this.row.index, this.column.key);\n }\n\n #pendingValue: unknown;\n\n #commitWith = async (value?: unknown): Promise<boolean> => {\n return this.editingController.commitCell(value ?? this.#pendingValue);\n };\n\n #cancel = () => {\n this.editingController.cancelCell();\n };\n\n #handleKeydown = (event: KeyboardEvent) => {\n event.stopPropagation();\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n this.#commitWith();\n return;\n case 'Escape':\n event.preventDefault();\n this.#cancel();\n return;\n case 'Tab':\n // Commit first; navigation moves to the next/prev cell. Editing of the\n // landed cell stays manual (Enter to re-edit) for predictability.\n event.preventDefault();\n this.#commitWith();\n return;\n default:\n return;\n }\n };\n\n #handleBlur = () => {\n if (!this.isEditing) return;\n if (this.editingController.mode === 'cell') {\n this.#commitWith();\n } else {\n // Row mode — stash the value and exit the cell editor; the row stays open.\n this.editingController.commitCell(this.#pendingValue);\n }\n };\n\n /**\n * Cell-level keydown that catches keys bubbling out of registry-built\n * editors (the default editor stops propagation on its own input).\n *\n * - Escape always cancels the edit.\n * - Tab commits (or closes when there's no draft — `commitCell()` with\n * `undefined` value is treated as \"no change\" by the controller).\n *\n * Per-editor `keydown` handlers that need to consume Enter (e.g. the\n * built-in `<select>` editor) still get the first crack — they call\n * `event.stopPropagation()` and we never see those keys here.\n */\n #handleCellKeydown = (event: KeyboardEvent) => {\n if (!this.isEditing) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n this.#cancel();\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n this.#commitWith();\n }\n };\n\n /**\n * Cell-level focus-out: commits the active edit when focus truly leaves\n * the cell (clicking another cell, tabbing past the editor, blurring to\n * the document body). The default editor's input also has `@blur` which\n * commits first; by that time `isEditing` is false and this is a no-op.\n *\n * For built-in registry editors `commitCell()` with no explicit value\n * resolves to the current data value — same shape as \"no change\", so\n * losing focus without picking discards the open editor without writing\n * spurious data.\n */\n #handleCellFocusOut = (event: FocusEvent) => {\n if (!this.isEditing) return;\n const next = event.relatedTarget as Node | null;\n if (next && (this.contains(next) || this.shadowRoot?.contains(next))) return;\n if (this.editingController.mode === 'cell') {\n this.#commitWith();\n } else {\n this.editingController.commitCell(this.#pendingValue);\n }\n };\n\n #handleTextInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.#pendingValue = this.column.type === 'number' ? target.valueAsNumber : target.value;\n };\n\n #handleCheckboxChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.#pendingValue = target.checked;\n // Booleans commit immediately — toggling is the whole interaction.\n this.#commitWith(target.checked);\n };\n\n protected renderDefaultEditor() {\n const value = this.value as unknown;\n if (this.column.type === 'boolean') {\n this.#pendingValue = Boolean(value);\n return html`<input\n type=\"checkbox\"\n part=\"editor\"\n data-apex-editor\n ?checked=${Boolean(value)}\n @change=${this.#handleCheckboxChange}\n @keydown=${this.#handleKeydown}\n @blur=${this.#handleBlur}\n />`;\n }\n if (this.column.type === 'number') {\n this.#pendingValue = value;\n return html`<input\n type=\"number\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n @blur=${this.#handleBlur}\n />`;\n }\n this.#pendingValue = value;\n return html`<input\n type=\"text\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n @blur=${this.#handleBlur}\n />`;\n }\n\n protected renderEditor() {\n const template = this.column.editorTemplate;\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.value,\n commit: (next: unknown) => this.editingController.commitCell(next),\n cancel: () => this.editingController.cancelCell(),\n };\n if (template) {\n // For custom editors we don't know the draft shape; reset pending so\n // cell-level commit doesn't write a stale value from a previous edit.\n this.#pendingValue = this.value;\n return template(ctx as unknown as ApexEditorContext<T> as never);\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.editor) {\n this.#pendingValue = this.value;\n return typeRenderer.editor(ctx as never);\n }\n return this.renderDefaultEditor();\n }\n\n /**\n * Renders the tree affordance — depth-based indent + a chevron toggle (or\n * leaf spacer) — that prefixes the group cell when {@link ApexGrid.tree}\n * is enabled. Returns `nothing` for every other cell.\n */\n protected renderTreeAffordance() {\n const tree = this.state?.tree;\n if (!tree?.enabled) return null;\n if (!this.row?.data) return null;\n if (!tree.isGroupColumn(this.column.key)) return null;\n\n const data = this.row.data;\n const meta = tree.getMeta(data);\n if (!meta) return null;\n\n const indent = meta.depth * tree.childIndent;\n const expanded = tree.isExpanded(data);\n const handleClick = (event: MouseEvent) => {\n event.stopPropagation();\n if (!meta.hasChildren) return;\n void tree.toggleRow(data);\n };\n\n const chevron = meta.hasChildren\n ? html`<button\n type=\"button\"\n part=\"tree-toggle\"\n aria-label=${\n expanded ? this.state.localize('row.collapse') : this.state.localize('row.expand')\n }\n aria-expanded=${expanded ? 'true' : 'false'}\n @click=${handleClick}\n >\n <svg\n part=\"tree-chevron\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n width=\"14\"\n height=\"14\"\n >\n <path\n d=\"M9 6l6 6-6 6\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </button>`\n : html`<span part=\"tree-spacer\" aria-hidden=\"true\"></span>`;\n\n return html`<span\n part=\"tree-indent\"\n aria-hidden=\"true\"\n style=${`inline-size: ${indent}px`}\n ></span>${chevron}`;\n }\n\n /**\n * Resolves the value to display for the cell. Synthesized tree parents\n * (those that appear only as a path segment with no backing data) render\n * their last path segment in the group column and nothing elsewhere.\n */\n protected resolveDisplayValue(): unknown {\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return tree.isGroupColumn(this.column.key) ? tree.getLabel(this.row.data) : '';\n }\n return this.value;\n }\n\n protected renderCellBody() {\n if (this.column.cellTemplate) {\n return this.column.cellTemplate(this.context as ApexCellContext<T> as never);\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.display) {\n // Synthesized parents have no real backing data — route them through\n // a plain text render instead of the typed renderer.\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return html`${this.resolveDisplayValue()}`;\n }\n return typeRenderer.display(this.context as never);\n }\n return html`${this.resolveDisplayValue()}`;\n }\n\n protected override render() {\n const error = this.renderError();\n if (this.isEditing) {\n return html`${this.renderEditor()}${error}`;\n }\n const affordance = this.renderTreeAffordance();\n if (affordance) {\n return html`${affordance}<span part=\"tree-cell-content\"\n >${this.renderCellBody()}</span\n >${error}`;\n }\n return html`${this.renderCellBody()}${error}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [ApexGridCell.tagName]: ApexGridCell<object>;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cell.js","sourceRoot":"","sources":["../../src/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EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACrB;AAOf;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACpB;AAIhB;IAFN,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACG;AAQxB;IADT,KAAK,CAAC,2BAA2B,CAAC;mDACU;AA0CtC;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACzB;AASb;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB;AAStB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { gridStateContext, type StateController } from '../controllers/state.js';\nimport { getColumnTypeRenderer } from '../internal/column-types.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_CELL_TAG } from '../internal/tags.js';\nimport type {\n ApexCellContext,\n ApexEditorContext,\n ColumnConfiguration,\n PropertyType,\n} from '../internal/types.js';\nimport { styles } from '../styles/body-cell/body-cell.css.js';\nimport type ApexGridRow from './row.js';\n\n/**\n * A spreadsheet-style error value (e.g. the enterprise formula engine's\n * `#VALUE!` / `#DIV/0!`). Duck-typed so core carries no dependency on the\n * enterprise layer: any value that is an object carrying a `#...` string `code`\n * is rendered as that code, even in a typed (currency / number) column whose\n * numeric renderer would otherwise coerce it to `NaN` and show nothing.\n */\nfunction isErrorLike(value: unknown): value is { code: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { code?: unknown }).code === 'string' &&\n (value as { code: string }).code.startsWith('#')\n );\n}\n\n/**\n * Component representing a DOM cell of the Apex grid.\n *\n * @csspart cell - The cell host element.\n * @csspart editor - The editor wrapper rendered while the cell is in edit mode.\n */\nexport default class ApexGridCell<T extends object> extends LitElement {\n public static get tagName() {\n return GRID_CELL_TAG;\n }\n\n public static override styles = styles;\n\n public static register(): void {\n registerComponent(ApexGridCell);\n }\n\n /**\n * The value which will be rendered by the component.\n */\n @property({ attribute: false })\n public value!: PropertyType<T>;\n\n /**\n * A reference to the column configuration object.\n */\n @property({ attribute: false })\n public column!: ColumnConfiguration<T>;\n\n /**\n * Indicates whether this is the active cell in the grid.\n *\n */\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * Whether the cell is currently in edit mode. Set by the parent row from the\n * editing controller's state so cells re-render on edit state changes.\n */\n @property({ type: Boolean, reflect: true })\n public editing = false;\n\n @consume({ context: gridStateContext, subscribe: true })\n @property({ attribute: false })\n public state!: StateController<T>;\n\n /**\n * The parent row component holding this cell.\n */\n public row!: ApexGridRow<T>;\n\n @query('input, [data-apex-editor]')\n protected editorElement!: HTMLElement | null;\n\n protected get context(): ApexCellContext<T> {\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.value,\n } as unknown as {\n parent: ApexGridCell<T>;\n row: ApexGridRow<T>;\n column: ColumnConfiguration<T>;\n value: PropertyType<T>;\n commit?: (value: unknown) => Promise<boolean>;\n };\n // Only expose `commit` when the column is editable — non-editable\n // interactive widgets should render as read-only.\n if (this.isEditable) {\n ctx.commit = (next: unknown) =>\n this.editingController.commitImmediate(this.row.index, this.column.key, next);\n }\n return ctx as unknown as ApexCellContext<T>;\n }\n\n protected get editingController() {\n return this.state.editing;\n }\n\n protected get isEditing(): boolean {\n return this.editing;\n }\n\n protected get isEditable(): boolean {\n if (!this.editingController) return false;\n return this.editingController.isEditable(this.column);\n }\n\n /**\n * 1-based column index used to populate `aria-colindex`. Accounts for the\n * auto-rendered selection + expansion columns ahead of the data columns.\n */\n @property({ attribute: false, type: Number })\n public colindex = 0;\n\n /**\n * Reactive token forwarded from {@link StateController.decorationVersion}.\n * Changing it re-runs {@link willUpdate} so module-driven cell decoration is\n * re-evaluated when it changes (e.g. while dragging a selection range). Stays\n * `0` for the community grid, so cells are never re-decorated there.\n */\n @property({ attribute: false, type: Number })\n public decorationVersion = 0;\n\n /**\n * Reactive token forwarded from {@link EditingController.validationVersion}.\n * Changing it re-runs {@link willUpdate} so the cell re-reads its validation\n * errors and toggles `aria-invalid` / the inline error node. Stays `0` until\n * the first validation failure.\n */\n @property({ attribute: false, type: Number })\n public validationVersion = 0;\n\n /** Decoration attribute keys applied on the previous update, for cleanup. */\n #decoratedKeys: string[] = [];\n\n /** DOM id of the inline error node, referenced by `aria-errormessage`. */\n static readonly #ERROR_ID = 'apex-cell-error';\n\n /** Validation errors resolved in {@link willUpdate}, consumed in render. */\n #errors: readonly string[] | null = null;\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('role', 'gridcell');\n this.addEventListener('click', this.#handleClick);\n this.addEventListener('dblclick', this.#handleDoubleClick);\n this.addEventListener('keydown', this.#handleCellKeydown);\n this.addEventListener('focusout', this.#handleCellFocusOut);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.#handleClick);\n this.removeEventListener('dblclick', this.#handleDoubleClick);\n this.removeEventListener('keydown', this.#handleCellKeydown);\n this.removeEventListener('focusout', this.#handleCellFocusOut);\n super.disconnectedCallback();\n }\n\n protected override willUpdate() {\n if (this.colindex > 0) {\n this.setAttribute('aria-colindex', String(this.colindex));\n } else {\n this.removeAttribute('aria-colindex');\n }\n // Roving tabindex: the active cell is the grid body's single tab stop, so\n // real focus (not just `aria-current`) tracks keyboard navigation and\n // screen readers follow arrow-key movement cell to cell.\n this.tabIndex = this.active ? 0 : -1;\n if (this.active) {\n this.setAttribute('aria-current', 'true');\n } else {\n this.removeAttribute('aria-current');\n }\n // Reflect tree-expanded state on the group cell so the SCSS chevron\n // rotation triggers from this attribute (cheaper than per-render style\n // mutations and keeps the SVG transform purely declarative).\n const tree = this.state?.tree;\n const isGroup = tree?.enabled && this.row?.data && tree.isGroupColumn(this.column.key);\n if (isGroup && tree.isExpanded(this.row.data)) {\n this.setAttribute('data-tree-expanded', '');\n } else {\n this.removeAttribute('data-tree-expanded');\n }\n\n this.#applyValidation();\n this.#applyDecoration();\n }\n\n /**\n * Reflects the cell's validation state from the editing controller: stores the\n * current error messages for {@link render} and toggles `aria-invalid` +\n * `aria-errormessage` + `data-invalid` on the host. Inert for cells whose\n * column has no validators (the lookup returns `null`).\n */\n #applyValidation(): void {\n const errors =\n this.state && this.row?.data\n ? (this.editingController?.getCellErrors(this.row.data, this.column.key) ?? null)\n : null;\n this.#errors = errors && errors.length > 0 ? errors : null;\n\n if (this.#errors) {\n this.setAttribute('aria-invalid', 'true');\n this.setAttribute('aria-errormessage', ApexGridCell.#ERROR_ID);\n this.setAttribute('data-invalid', '');\n this.setAttribute('title', this.#errors.join('; '));\n } else {\n this.removeAttribute('aria-invalid');\n this.removeAttribute('aria-errormessage');\n this.removeAttribute('data-invalid');\n this.removeAttribute('title');\n }\n }\n\n /**\n * The inline error node surfaced when the cell is invalid. `role=\"alert\"`\n * announces the message when it appears, covering the cross-shadow gap where\n * an `aria-errormessage` IDREF on the host can't reach this node.\n */\n protected renderError() {\n if (!this.#errors) return null;\n return html`<span\n part=\"cell-error\"\n id=${ApexGridCell.#ERROR_ID}\n role=\"alert\"\n >${this.#errors.join('; ')}</span\n >`;\n }\n\n /**\n * Reflects module-contributed decoration attributes (see {@link CellDecorator})\n * onto the cell host, reconciling against the previous update so attributes\n * that are no longer present are removed. Inert for the community grid:\n * `state.decorateCell` returns `null` with no modules, so nothing is set.\n */\n #applyDecoration(): void {\n const decoration =\n this.state && this.row\n ? this.state.decorateCell({\n row: this.row.data,\n rowIndex: this.row.index,\n column: this.column,\n value: this.value as unknown,\n })\n : null;\n const next = decoration?.attributes ?? {};\n\n // Remove anything we set last time that's gone (or explicitly cleared).\n for (const key of this.#decoratedKeys) {\n if (next[key] == null) this.removeAttribute(key);\n }\n\n const applied: string[] = [];\n for (const [key, value] of Object.entries(next)) {\n if (value == null) {\n this.removeAttribute(key);\n } else {\n this.setAttribute(key, value);\n applied.push(key);\n }\n }\n this.#decoratedKeys = applied;\n }\n\n protected override updated(changed: PropertyValues<this>) {\n if (this.isEditing) {\n const editor = this.editorElement;\n editor?.focus();\n if (editor instanceof HTMLInputElement) {\n if (editor.type === 'text' || editor.type === 'number') {\n editor.select();\n }\n }\n return;\n }\n // A keyboard-committed (or cancelled) edit removes the focused editor from\n // the DOM; hand focus back to the cell host so grid navigation continues\n // from where the user was. Pointer-driven exits (blur / outside click)\n // never set the flag, so they don't steal focus from the click target.\n if (changed.get('editing') === true && this.#refocusAfterEdit) {\n this.#refocusAfterEdit = false;\n this.focus();\n }\n }\n\n #handleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n // Don't let clicks inside the editor bubble into navigation / outside-click commits.\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n // Boolean cells handle interaction in their display widget — clicking the\n // checkbox commits inline via `ctx.commit`. We never enter edit mode for\n // booleans, which avoids the visual reflow between display/editor markup\n // and lets a single click toggle the value.\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'click') return;\n this.#startEdit();\n };\n\n #handleDoubleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'doubleClick') return;\n this.#startEdit();\n };\n\n #startEdit() {\n if (!this.row) return;\n this.editingController.editCell(this.row.index, this.column.key);\n }\n\n #pendingValue: unknown;\n\n /** Set by keyboard-driven commit/cancel so `updated` refocuses the cell host. */\n #refocusAfterEdit = false;\n\n #commitWith = async (value?: unknown): Promise<boolean> => {\n return this.editingController.commitCell(value ?? this.#pendingValue);\n };\n\n #cancel = () => {\n this.editingController.cancelCell();\n };\n\n #handleKeydown = (event: KeyboardEvent) => {\n event.stopPropagation();\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#commitWith();\n return;\n case 'Escape':\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#cancel();\n return;\n case 'Tab':\n // Commit first; navigation moves to the next/prev cell. Editing of the\n // landed cell stays manual (Enter to re-edit) for predictability.\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#commitWith();\n return;\n default:\n return;\n }\n };\n\n #handleBlur = () => {\n if (!this.isEditing) return;\n if (this.editingController.mode === 'cell') {\n this.#commitWith();\n } else {\n // Row mode — stash the value and exit the cell editor; the row stays open.\n this.editingController.commitCell(this.#pendingValue);\n }\n };\n\n /**\n * Cell-level keydown that catches keys bubbling out of registry-built\n * editors (the default editor stops propagation on its own input).\n *\n * - Escape always cancels the edit.\n * - Tab commits (or closes when there's no draft — `commitCell()` with\n * `undefined` value is treated as \"no change\" by the controller).\n *\n * Per-editor `keydown` handlers that need to consume Enter (e.g. the\n * built-in `<select>` editor) still get the first crack — they call\n * `event.stopPropagation()` and we never see those keys here.\n */\n #handleCellKeydown = (event: KeyboardEvent) => {\n if (!this.isEditing) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#cancel();\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#commitWith();\n }\n };\n\n /**\n * Cell-level focus-out: commits the active edit when focus truly leaves\n * the cell (clicking another cell, tabbing past the editor, blurring to\n * the document body). The default editor's input also has `@blur` which\n * commits first; by that time `isEditing` is false and this is a no-op.\n *\n * For built-in registry editors `commitCell()` with no explicit value\n * resolves to the current data value — same shape as \"no change\", so\n * losing focus without picking discards the open editor without writing\n * spurious data.\n */\n #handleCellFocusOut = (event: FocusEvent) => {\n if (!this.isEditing) return;\n const next = event.relatedTarget as Node | null;\n if (next && (this.contains(next) || this.shadowRoot?.contains(next))) return;\n if (this.editingController.mode === 'cell') {\n this.#commitWith();\n } else {\n this.editingController.commitCell(this.#pendingValue);\n }\n };\n\n #handleTextInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (this.column.type === 'number') {\n // An empty (or non-parseable) number field clears the value to null rather\n // than committing NaN, which would render as the text \"NaN\".\n const numeric = target.valueAsNumber;\n this.#pendingValue = target.value === '' || Number.isNaN(numeric) ? null : numeric;\n return;\n }\n this.#pendingValue = target.value;\n };\n\n #handleCheckboxChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.#pendingValue = target.checked;\n // Booleans commit immediately — toggling is the whole interaction.\n this.#commitWith(target.checked);\n };\n\n protected renderDefaultEditor() {\n const value = this.value as unknown;\n if (this.column.type === 'boolean') {\n this.#pendingValue = Boolean(value);\n return html`<input\n type=\"checkbox\"\n part=\"editor\"\n data-apex-editor\n ?checked=${Boolean(value)}\n @change=${this.#handleCheckboxChange}\n @keydown=${this.#handleKeydown}\n @blur=${this.#handleBlur}\n />`;\n }\n if (this.column.type === 'number') {\n this.#pendingValue = value;\n return html`<input\n type=\"number\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n @blur=${this.#handleBlur}\n />`;\n }\n this.#pendingValue = value;\n return html`<input\n type=\"text\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n @blur=${this.#handleBlur}\n />`;\n }\n\n protected renderEditor() {\n const template = this.column.editorTemplate;\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.value,\n commit: (next: unknown) => this.editingController.commitCell(next),\n cancel: () => this.editingController.cancelCell(),\n };\n if (template) {\n // For custom editors we don't know the draft shape; reset pending so\n // cell-level commit doesn't write a stale value from a previous edit.\n this.#pendingValue = this.value;\n return template(ctx as unknown as ApexEditorContext<T> as never);\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.editor) {\n this.#pendingValue = this.value;\n return typeRenderer.editor(ctx as never);\n }\n return this.renderDefaultEditor();\n }\n\n /**\n * Renders the tree affordance — depth-based indent + a chevron toggle (or\n * leaf spacer) — that prefixes the group cell when {@link ApexGrid.tree}\n * is enabled. Returns `nothing` for every other cell.\n */\n protected renderTreeAffordance() {\n const tree = this.state?.tree;\n if (!tree?.enabled) return null;\n if (!this.row?.data) return null;\n if (!tree.isGroupColumn(this.column.key)) return null;\n\n const data = this.row.data;\n const meta = tree.getMeta(data);\n if (!meta) return null;\n\n const indent = meta.depth * tree.childIndent;\n const expanded = tree.isExpanded(data);\n const handleClick = (event: MouseEvent) => {\n event.stopPropagation();\n if (!meta.hasChildren) return;\n void tree.toggleRow(data);\n };\n\n const chevron = meta.hasChildren\n ? html`<button\n type=\"button\"\n part=\"tree-toggle\"\n aria-label=${\n expanded ? this.state.localize('row.collapse') : this.state.localize('row.expand')\n }\n aria-expanded=${expanded ? 'true' : 'false'}\n @click=${handleClick}\n >\n <svg\n part=\"tree-chevron\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n width=\"14\"\n height=\"14\"\n >\n <path\n d=\"M9 6l6 6-6 6\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </button>`\n : html`<span part=\"tree-spacer\" aria-hidden=\"true\"></span>`;\n\n return html`<span\n part=\"tree-indent\"\n aria-hidden=\"true\"\n style=${`inline-size: ${indent}px`}\n ></span>${chevron}`;\n }\n\n /**\n * Resolves the value to display for the cell. Synthesized tree parents\n * (those that appear only as a path segment with no backing data) render\n * their last path segment in the group column and nothing elsewhere.\n */\n protected resolveDisplayValue(): unknown {\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return tree.isGroupColumn(this.column.key) ? tree.getLabel(this.row.data) : '';\n }\n return this.value;\n }\n\n protected renderCellBody() {\n if (this.column.cellTemplate) {\n return this.column.cellTemplate(this.context as ApexCellContext<T> as never);\n }\n // A formula error is a first-class cell value: render its code as text so it\n // stays visible in typed columns (a currency/number renderer would coerce it\n // to NaN and show an empty cell).\n const value = this.resolveDisplayValue();\n if (isErrorLike(value)) {\n return html`${value.code}`;\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.display) {\n // Synthesized parents have no real backing data — route them through\n // a plain text render instead of the typed renderer.\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return html`${this.resolveDisplayValue()}`;\n }\n return typeRenderer.display(this.context as never);\n }\n return html`${this.resolveDisplayValue()}`;\n }\n\n protected override render() {\n const error = this.renderError();\n if (this.isEditing) {\n return html`${this.renderEditor()}${error}`;\n }\n const affordance = this.renderTreeAffordance();\n if (affordance) {\n return html`${affordance}<span part=\"tree-cell-content\"\n >${this.renderCellBody()}</span\n >${error}`;\n }\n return html`${this.renderCellBody()}${error}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [ApexGridCell.tagName]: ApexGridCell<object>;\n }\n}\n"]}
|