@keenmate/web-grid 1.0.0-rc15 → 1.0.1

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.
@@ -0,0 +1,142 @@
1
+ FROZEN COLUMNS
2
+ ==============
3
+ @keenmate/web-grid - Freeze columns to the left during horizontal scroll.
4
+
5
+
6
+ OVERVIEW
7
+ --------
8
+ Frozen columns use CSS position: sticky to pin columns to the left edge of
9
+ the scroll container. They remain visible while the user scrolls horizontally.
10
+ Two mechanisms exist: per-column (isFrozen on Column) and grid-level
11
+ (freezeColumns count).
12
+
13
+
14
+ GRID-LEVEL PROPERTY
15
+ -------------------
16
+ freezeColumns (number, default: 0)
17
+ Freeze the first N columns. Applied after visual reorder from per-column
18
+ isFrozen settings. Set on the grid element:
19
+
20
+ grid.freezeColumns = 3
21
+
22
+
23
+ PER-COLUMN PROPERTY
24
+ -------------------
25
+ isFrozen (boolean) on Column<T>
26
+ Marks an individual column as frozen. Frozen columns are reordered to the
27
+ left side before the freezeColumns count is applied.
28
+
29
+ grid.columns = [
30
+ { field: 'id', title: 'ID', isFrozen: true },
31
+ { field: 'name', title: 'Name' },
32
+ { field: 'email', title: 'Email' }
33
+ ]
34
+
35
+
36
+ STICKY ROW NUMBERS
37
+ ------------------
38
+ isStickyRowNumbers (boolean, default: false)
39
+ When true, the row number column sticks to the left during horizontal scroll.
40
+ Works independently of frozen columns.
41
+
42
+ grid.isRowNumbersVisible = true
43
+ grid.isStickyRowNumbers = true
44
+
45
+
46
+ HOW IT WORKS (CSS)
47
+ ------------------
48
+ Frozen columns use position: sticky with left offsets calculated per column.
49
+ Each frozen column gets a left value equal to the cumulative width of all
50
+ preceding frozen columns, so they stack side by side.
51
+
52
+ Z-index stacking order:
53
+ - Regular body cells: default (no z-index)
54
+ - Frozen body cells: z-index 1
55
+ - Frozen row number cells: z-index 2
56
+ - Header cells (sticky top): z-index 1
57
+ - Frozen header cells: z-index 3
58
+ - Corner cell (row number header, both frozen and sticky): z-index 4
59
+
60
+ This ensures that:
61
+ - Frozen columns stay above scrolling body cells
62
+ - Headers stay above frozen body cells
63
+ - The corner cell (top-left) stays above everything
64
+
65
+
66
+ OPAQUE BACKGROUNDS REQUIREMENT
67
+ -------------------------------
68
+ Frozen cells MUST have opaque backgrounds. The normal selection/focus variables
69
+ use semi-transparent values (color-mix with transparent), which would let
70
+ non-frozen content show through when it scrolls behind sticky columns.
71
+
72
+ For frozen cells in selected/focused/in-range states, the CSS mixes the accent
73
+ color against the opaque frozen column base color instead of transparent:
74
+
75
+ .wg__row--selected > .wg__cell--frozen {
76
+ background: color-mix(in srgb, var(--wg-accent-color) 15%,
77
+ var(--wg-frozen-column-bg, var(--wg-surface-1))) !important;
78
+ }
79
+
80
+
81
+ AUTO-SCROLL WHEN NAVIGATING BEHIND FROZEN COLUMNS
82
+ --------------------------------------------------
83
+ When keyboard navigation (arrow keys) moves focus to a cell that is hidden
84
+ behind frozen columns, the grid auto-scrolls horizontally to reveal it. The
85
+ ensureCellNotBehindFrozen function detects when a focused cell's left edge is
86
+ behind the last frozen column's right edge and scrolls the container to fix it.
87
+
88
+
89
+ FROZEN COLUMN SHADOW
90
+ --------------------
91
+ A visual shadow appears on the last frozen column when the grid is scrolled
92
+ horizontally. The shadow is rendered as a ::after pseudo-element.
93
+
94
+ CSS variables controlling the shadow:
95
+
96
+ --wg-frozen-column-shadow-gradient
97
+ Default: linear-gradient(to right, rgba(0, 0, 0, 0.15), transparent)
98
+ The gradient used for the shadow effect.
99
+
100
+ --wg-frozen-column-shadow-width
101
+ Default: 8px
102
+ Width of the shadow pseudo-element.
103
+
104
+ The shadow only appears when the wg--scrolled-horizontal class is present
105
+ on the container (set when scrollLeft > 0).
106
+
107
+ Other frozen column CSS variables:
108
+ --wg-frozen-column-bg Default: var(--wg-surface-1)
109
+ --wg-frozen-header-bg Default: color-mix(in srgb, accent 8%, header-bg)
110
+ --wg-frozen-column-border Default: 2px solid var(--wg-border-color)
111
+ --wg-cell-splitter-color Border color for frozen column separator
112
+ --wg-cell-splitter-width Width of frozen column separator (1px)
113
+
114
+
115
+ HEADER CONTEXT MENU ACTIONS
116
+ ----------------------------
117
+ Two predefined header context menu items for freeze management:
118
+
119
+ 'freezeColumn' Freezes the right-clicked column
120
+ 'unfreezeColumn' Unfreezes the right-clicked column
121
+
122
+ Usage:
123
+ grid.headerContextMenu = [
124
+ 'freezeColumn',
125
+ 'unfreezeColumn',
126
+ 'sortAsc',
127
+ 'sortDesc'
128
+ ]
129
+
130
+ The header context menu context includes an isFrozen boolean indicating
131
+ whether the clicked column is currently frozen.
132
+
133
+
134
+ STRIPED AND HOVER STATES
135
+ -------------------------
136
+ Frozen cells maintain correct styling for:
137
+ - Striped rows: even rows use --wg-row-bg-even
138
+ - Hover: uses --wg-row-bg-hover
139
+ - Row focus: opaque mix of accent + frozen bg
140
+ - Row selection: opaque mix of accent + frozen bg
141
+ - Column selection: opaque mix of accent + frozen bg
142
+ - Cell range selection: opaque mix of accent + frozen bg
@@ -0,0 +1,267 @@
1
+ GRID MODES IN @keenmate/web-grid
2
+ =================================
3
+
4
+ The mode property configures the grid for common interaction patterns.
5
+ Setting mode applies a set of defaults. Individual properties can be
6
+ overridden after setting mode.
7
+
8
+
9
+ THE MODE PROPERTY
10
+ -----------------
11
+
12
+ Type: GridMode = "read-only" | "excel" | "input-matrix"
13
+
14
+ Set on the grid element:
15
+
16
+ grid.mode = "excel"
17
+
18
+ Or via HTML attribute:
19
+
20
+ <web-grid mode="excel"></web-grid>
21
+
22
+ Setting mode calls applyModeDefaults() internally, which sets
23
+ isEditable, editTrigger, cellSelectionMode, dropdownToggleVisibility,
24
+ and shouldShowDropdownOnFocus to mode-appropriate values.
25
+
26
+
27
+ READ-ONLY MODE
28
+ --------------
29
+
30
+ grid.mode = "read-only"
31
+
32
+ Defaults applied:
33
+ isEditable = false
34
+ cellSelectionMode = "click"
35
+ dropdownToggleVisibility = "on-focus"
36
+ shouldShowDropdownOnFocus = false
37
+
38
+ Use case: Display grids with copy support. Users can browse data,
39
+ select cell ranges by clicking and dragging, and copy selections to
40
+ clipboard with Ctrl+C.
41
+
42
+ Behavior:
43
+ - No editing. Cells are never editable.
44
+ - Arrow keys move the focused cell highlight between cells.
45
+ - Click a cell to focus it; click+drag to select a range of cells.
46
+ - Ctrl+C copies the selected cell range as TSV (Excel-compatible).
47
+ - Dropdown toggles appear only when a cell is focused (on-focus).
48
+ - editTrigger="always" is not supported and logs a console warning.
49
+
50
+ Common configuration:
51
+
52
+ grid.mode = "read-only"
53
+ grid.sortMode = "multi"
54
+ grid.isFilterable = true
55
+ grid.isHoverable = true
56
+
57
+
58
+ EXCEL MODE
59
+ ----------
60
+
61
+ grid.mode = "excel"
62
+
63
+ Defaults applied:
64
+ isEditable = true
65
+ editTrigger = "navigate"
66
+ cellSelectionMode = "click"
67
+ dropdownToggleVisibility = "always"
68
+ shouldShowDropdownOnFocus = false
69
+
70
+ Use case: Spreadsheet-like editing. Navigate cells with arrow keys,
71
+ type to start editing, Escape to cancel. Click+drag for cell range
72
+ selection.
73
+
74
+ Behavior:
75
+ - Cells start in "navigate" state (focused but not editing).
76
+ - Arrow keys move focus between cells without entering edit mode.
77
+ - Typing a printable character starts editing with that character as
78
+ initial input (replaces cell content).
79
+ - F2 starts editing with the current cell value preserved.
80
+ - Enter on a text cell moves focus down (does not start editing).
81
+ - Enter on a dropdown cell opens the dropdown if
82
+ shouldOpenDropdownOnEnter is true; otherwise moves down.
83
+ - Space toggles checkboxes; Space on dropdown/date cells starts editing.
84
+ - Double-click also starts editing (dblclick is handled for navigate
85
+ mode as well).
86
+ - Escape cancels the current edit and returns to navigate state.
87
+ - Tab/Shift+Tab move to the next/previous editable cell, committing
88
+ any active edit first.
89
+ - When editing a dropdown in navigate mode, Left/Right arrow keys
90
+ cancel the edit and navigate to the adjacent cell (allowing quick
91
+ horizontal traversal).
92
+ - Click+drag selects a rectangular cell range.
93
+ - Delete clears the focused cell content.
94
+ - Ctrl+C copies the selected range to clipboard.
95
+ - Dropdown toggle buttons are always visible on dropdown columns.
96
+
97
+ Common configuration:
98
+
99
+ grid.mode = "excel"
100
+ grid.isRowToolbarVisible = true
101
+ grid.rowToolbar = ["add", "delete", "duplicate"]
102
+ grid.fillDragCallback = (detail) => { /* handle fill */ }
103
+ grid.isCheckboxAlwaysEditable = true
104
+
105
+
106
+ INPUT-MATRIX MODE
107
+ -----------------
108
+
109
+ grid.mode = "input-matrix"
110
+
111
+ Defaults applied:
112
+ isEditable = true
113
+ editTrigger = "always"
114
+ cellSelectionMode = "shift"
115
+ dropdownToggleVisibility = "always"
116
+ shouldShowDropdownOnFocus = true
117
+
118
+ Use case: All editable cells are always in edit mode. The grid behaves
119
+ like a form with a table layout. Every cell renders its editor (text
120
+ input, dropdown, checkbox, etc.) at all times.
121
+
122
+ Behavior:
123
+ - All editable cells render their editors immediately (no navigate
124
+ state for those cells).
125
+ - Clicking a cell focuses its editor input directly.
126
+ - Tab/Shift+Tab move between editor inputs across cells, behaving like
127
+ a form tab order.
128
+ - Arrow keys behave as cursor navigation within text inputs (left/right
129
+ move the text cursor, up/down move between cells).
130
+ - For dropdown columns, focusing the cell automatically opens the
131
+ dropdown (shouldShowDropdownOnFocus = true).
132
+ - Dropdown toggle buttons are always visible.
133
+ - Escape within a cell cancels the edit and restores the previous value.
134
+ - Cell range selection uses Shift+Click (not plain click), because plain
135
+ click is needed to focus editor inputs.
136
+ - Non-editable columns still display as read-only text.
137
+
138
+ Common configuration:
139
+
140
+ grid.mode = "input-matrix"
141
+ grid.isRowToolbarVisible = true
142
+ grid.rowToolbar = ["add", "delete"]
143
+ grid.shouldOpenDropdownOnEnter = true
144
+
145
+
146
+ OVERRIDING MODE DEFAULTS
147
+ -------------------------
148
+
149
+ Setting mode applies defaults, but any property can be overridden
150
+ afterward. The override persists until mode is set again.
151
+
152
+ grid.mode = "excel"
153
+ grid.cellSelectionMode = "shift" // Override: use Shift+Click for selection
154
+ grid.shouldShowDropdownOnFocus = true // Override: auto-open dropdowns
155
+
156
+ grid.mode = "read-only"
157
+ grid.isEditable = true // Override: allow editing in "read-only" layout
158
+ grid.editTrigger = "dblclick" // Override: double-click to edit
159
+
160
+ grid.mode = "input-matrix"
161
+ grid.shouldShowDropdownOnFocus = false // Override: don't auto-open dropdowns
162
+
163
+ Per-column overrides also work. Column-level editTrigger and
164
+ dropdownToggleVisibility take precedence over grid-level values:
165
+
166
+ grid.columns = [
167
+ { field: "name", editor: "text" },
168
+ { field: "status", editor: "select", editTrigger: "always" }, // Always-editing in excel mode
169
+ { field: "notes", editor: "text", dropdownToggleVisibility: "on-focus" }
170
+ ]
171
+
172
+
173
+ KEYBOARD NAVIGATION BY MODE
174
+ ----------------------------
175
+
176
+ Read-only mode:
177
+ Arrow keys Move focus between cells
178
+ Tab Move focus to next cell (wraps to next row)
179
+ Shift+Tab Move focus to previous cell
180
+ Home Move focus to first cell in row
181
+ End Move focus to last cell in row
182
+ PageUp/Down Move focus up/down by visible page height
183
+ Ctrl+C Copy selected cell range to clipboard
184
+ No editing keys are active
185
+
186
+ Excel mode (navigate state, not editing):
187
+ Arrow keys Move focus between cells
188
+ Tab Move to next editable cell (commits any edit)
189
+ Shift+Tab Move to previous editable cell
190
+ Home Move to first cell in row
191
+ End Move to last cell in row
192
+ PageUp/Down Move up/down by visible page height
193
+ Enter Move focus down (or open dropdown if configured)
194
+ F2 Start editing current cell (preserves value)
195
+ Delete Clear cell content
196
+ Space Toggle checkbox / open dropdown / start date edit
197
+ Printable char Start editing with that character (replaces value)
198
+ Escape (no effect when not editing)
199
+ Ctrl+C Copy selected range
200
+
201
+ Excel mode (editing state):
202
+ Escape Cancel edit, return to navigate state
203
+ Enter Commit edit, move focus down
204
+ Tab Commit edit, move to next editable cell
205
+ Shift+Tab Commit edit, move to previous editable cell
206
+ Arrow Up/Down Commit edit, move focus (for text editors)
207
+ Arrow Left/Right Cursor movement in text input (native browser)
208
+ Arrow Left/Right Cancel edit and navigate (dropdown editors only)
209
+
210
+ Input-matrix mode:
211
+ Tab Move to next editor input (like form tabbing)
212
+ Shift+Tab Move to previous editor input
213
+ Enter Commit and move down (or open dropdown if configured)
214
+ Escape Cancel current edit, restore previous value
215
+ Arrow Up/Down Move between cells (commits current edit)
216
+ Arrow Left/Right Cursor movement within text input (native)
217
+ Printable chars Typed directly into the active editor input
218
+
219
+
220
+ CELL SELECTION BY MODE
221
+ ----------------------
222
+
223
+ cellSelectionMode = "click" (read-only, excel):
224
+ Click+drag on cells to select a rectangular range.
225
+ Click a single cell to focus it (clears any selection).
226
+ Shift+Click extends the selection from the focused cell.
227
+ Ctrl+C copies the selection as TSV text.
228
+ Note: if editTrigger="click" conflicts with cellSelectionMode="click",
229
+ cell selection takes priority. A console warning is logged.
230
+
231
+ cellSelectionMode = "shift" (input-matrix):
232
+ Plain click focuses the cell (and its editor in input-matrix mode).
233
+ Shift+Click starts or extends a cell range selection.
234
+ This avoids conflict with always-editing cells that need plain clicks
235
+ to position the cursor in their editor inputs.
236
+
237
+ cellSelectionMode = "disabled":
238
+ No cell range selection. Clicks only focus cells or start editing.
239
+
240
+ For all modes, the shouldCopyWithHeaders property controls whether
241
+ column headers are included when copying cell selections:
242
+
243
+ grid.shouldCopyWithHeaders = true
244
+
245
+
246
+ PROPERTIES REFERENCE
247
+ --------------------
248
+
249
+ Properties set by mode (grid-level):
250
+
251
+ Property read-only excel input-matrix
252
+ ---------------------------- ---------- ---------- ------------
253
+ isEditable false true true
254
+ editTrigger (unchanged) "navigate" "always"
255
+ cellSelectionMode "click" "click" "shift"
256
+ dropdownToggleVisibility "on-focus" "always" "always"
257
+ shouldShowDropdownOnFocus (unchanged) false true
258
+
259
+ Note: "unchanged" means the property is not set by the mode and retains
260
+ its current value (or its default if never explicitly set).
261
+
262
+ Related properties not set by mode but commonly configured alongside:
263
+ isCheckboxAlwaysEditable - Checkboxes clickable even in navigate state
264
+ shouldOpenDropdownOnEnter - Enter key opens dropdown vs moves down
265
+ editStartSelection - Cursor position on edit start: "selectAll",
266
+ "cursorAtStart", "cursorAtEnd", "mousePosition"
267
+ shouldCopyWithHeaders - Include headers when copying cell selection