jsl-ui 10.4.4 → 10.4.5

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 (94) hide show
  1. package/docs/AutoSuggestComponent.md +17 -17
  2. package/docs/ButtonComponent.md +22 -22
  3. package/docs/CheckBoxComponent.md +12 -12
  4. package/docs/DataBinding.md +19 -19
  5. package/docs/DateComponent.md +12 -12
  6. package/docs/DateRangeComponent.md +13 -13
  7. package/docs/DateTimeComponent.md +14 -14
  8. package/docs/DialogComponent.md +15 -15
  9. package/docs/DropdownMenuComponent.md +22 -22
  10. package/docs/ExpanderComponent.md +13 -13
  11. package/docs/FormComponent.md +15 -15
  12. package/docs/FormFieldComponent.md +15 -15
  13. package/docs/GridComponent.md +39 -39
  14. package/docs/InputComponent.md +15 -15
  15. package/docs/IntervalComponent.md +13 -13
  16. package/docs/LoadingComponent.md +12 -12
  17. package/docs/NavigationComponent.md +17 -17
  18. package/docs/Notification.md +14 -14
  19. package/docs/NotificationComponent.md +13 -13
  20. package/docs/NumberComponent.md +12 -12
  21. package/docs/OverlayComponent.md +13 -13
  22. package/docs/ProgressComponent.md +12 -12
  23. package/docs/README.md +27 -27
  24. package/docs/RibbonMenuComponent.md +14 -14
  25. package/docs/SelectComponent.md +36 -36
  26. package/docs/SliderComponent.md +20 -20
  27. package/docs/SplitterComponent.md +14 -14
  28. package/docs/StackPanelComponent.md +13 -13
  29. package/docs/TabsComponent.md +16 -16
  30. package/docs/TimeComponent.md +13 -13
  31. package/docs/TreeViewComponent.md +16 -16
  32. package/examples/showcase/checks-and-expanders.ts +148 -148
  33. package/examples/showcase/cultures.ts +39 -39
  34. package/examples/showcase/data-binding.ts +138 -138
  35. package/examples/showcase/dates.ts +168 -168
  36. package/examples/showcase/dialogs.ts +184 -184
  37. package/examples/showcase/dropdown-menus.ts +99 -99
  38. package/examples/showcase/feedback-and-navigation.ts +173 -173
  39. package/examples/showcase/fields.ts +166 -166
  40. package/examples/showcase/fonts/OFL-BricolageGrotesque.txt +93 -93
  41. package/examples/showcase/fonts/OFL-Figtree.txt +93 -93
  42. package/examples/showcase/fonts/OFL-Jost.txt +93 -93
  43. package/examples/showcase/generate-sources.cjs +104 -104
  44. package/examples/showcase/grids.ts +484 -484
  45. package/examples/showcase/index.html +71 -71
  46. package/examples/showcase/layout-and-navigation.ts +46 -46
  47. package/examples/showcase/nivona.css +98 -98
  48. package/examples/showcase/package.json +10 -10
  49. package/examples/showcase/selects.ts +184 -184
  50. package/examples/showcase/showcase-sources.ts +94 -94
  51. package/examples/showcase/showcase.css +281 -281
  52. package/examples/showcase/showcase.ts +244 -244
  53. package/examples/showcase/tabs.ts +161 -161
  54. package/examples/showcase/themes.css +83 -83
  55. package/examples/showcase/themes.ts +56 -56
  56. package/examples/showcase/wirtshans.css +65 -65
  57. package/lib/components/checkbox/CheckBoxStyle.scss +73 -73
  58. package/lib/components/date-range/DateRangeStyle.scss +35 -35
  59. package/lib/components/date-time/DateTimeStyle.scss +9 -9
  60. package/lib/components/dialog/DialogComponent.d.ts +9 -2
  61. package/lib/components/dialog/DialogComponent.js +17 -51
  62. package/lib/components/dropdown-menu/DropdownMenuStyle.scss +48 -48
  63. package/lib/components/expander/ExpanderStyle.scss +61 -61
  64. package/lib/components/form-field/FormFieldStyle.scss +36 -36
  65. package/lib/components/host/RenderHost.d.ts +25 -0
  66. package/lib/components/host/RenderHost.js +63 -0
  67. package/lib/components/loading/LoadingStyle.css +18 -18
  68. package/lib/components/navigation/NavigationStyle.scss +61 -61
  69. package/lib/components/notification/Notification.scss +102 -102
  70. package/lib/components/overlay/OverlayComponent.d.ts +9 -1
  71. package/lib/components/overlay/OverlayComponent.js +22 -13
  72. package/lib/components/overlay/overlay.css +15 -15
  73. package/lib/components/progress/ProgressStyle.scss +4 -4
  74. package/lib/components/ribbon-menu/RibbonMenuStyle.scss +5 -5
  75. package/lib/components/select/SelectStyle.scss +207 -207
  76. package/lib/components/slider/SliderStyle.scss +21 -21
  77. package/lib/components/slider/nouislider.css +15 -15
  78. package/lib/components/stack-panel/SplitterStyle.scss +8 -8
  79. package/lib/components/stack-panel/StackPanelStyle.scss +10 -10
  80. package/lib/components/tabs/TabsStyle.scss +139 -139
  81. package/lib/components/time/TimeComponent.scss +3 -3
  82. package/lib/components/tree-view/TreeViewStyle.scss +14 -14
  83. package/lib/grid/plugins/slick.headermenu.css +98 -98
  84. package/lib/grid.css +841 -3514
  85. package/lib/index.css.map +1 -1
  86. package/lib/index.js.map +1 -1
  87. package/lib/ui/auto.suggest.css +30 -30
  88. package/lib/ui/button.css +147 -147
  89. package/lib/ui/date-input.css +10 -10
  90. package/lib/ui/date.picker/css/tiny-date-picker.css +124 -124
  91. package/lib/ui/dialog.css +144 -144
  92. package/lib/ui/input.css +35 -35
  93. package/lib/ui/theme.css +28 -28
  94. package/package.json +1 -1
@@ -1,484 +1,484 @@
1
- import { IJSLVNode, JSLRender } from "jsl-render";
2
- import { GridComponent } from "../../components/grid/GridComponent";
3
- import { ISlickColumn } from "../../grid/slick.core";
4
- import { IJSLGrid } from "../../grid/slick.creator";
5
- import { SumAggregator } from "../../grid/slick.dataview";
6
- import { GridTree, IndentFormatter } from "../../grid/slick.tree";
7
- import { CellSelectionModel } from "../../grid/plugins/slick.cellselectionmodel";
8
- import { RowSelectionModel } from "../../grid/plugins/slick.rowselectionmodel";
9
- import { TextEditor, MultiLineTextEditor, NumericEditor, BooleanEditor } from "../../grid/slick.editors.core";
10
- import { DateEditor, TimeEditor } from "../../grid/slick.editors.date";
11
- import { AutoSuggestEditor, LookupEditor, MultiLookupEditor } from "../../grid/slick.editors.lookup";
12
- import {
13
- CheckboxFormatter, DateFormatter, DateTimeFormatter, LookupFormatter,
14
- MultiLineTextFormatter, MultiLookupFormatter, NumericFormatter, TextFormatter, TimeFormatter,
15
- TooltipFormatter, YesNoFormatter, ComponentFormatter
16
- } from "../../grid/slick.formatters";
17
- import { ButtonComponent } from "../../components/button/ButtonComponent";
18
- import { ProgressComponent } from "../../components/progress/ProgressComponent";
19
- import { numeric } from "../../core/numeric";
20
-
21
- interface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }
22
- function data(count: number): Project[] {
23
- const names = ["Design system", "Website refresh", "Customer research", "Mobile workspace", "Reporting tools"];
24
- return Array.from({ length: count }, (_, index) => ({
25
- id: index + 1, name: names[index % names.length] + " " + (index + 1),
26
- team: ["Design", "Engineering", "Operations"][index % 3], budget: 1500 + index * 125,
27
- date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0
28
- }));
29
- }
30
- function columns(editable = false): ISlickColumn[] {
31
- return [
32
- { id: "id", name: "ID", width: 65, sortable: true },
33
- { id: "name", name: "Project", width: 250, sortable: true, editor: editable ? TextEditor : undefined },
34
- { id: "team", name: "Team", width: 145, sortable: true, editor: editable ? TextEditor : undefined },
35
- { id: "budget", name: "Budget", width: 125, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0", editor: editable ? NumericEditor : undefined },
36
- { id: "date", name: "Start date", width: 135, sortable: true, formatter: DateFormatter, editor: editable ? DateEditor : undefined },
37
- { id: "approved", name: "Approved", width: 100, headerCssClass: "center", formatter: CheckboxFormatter, editor: editable ? BooleanEditor : undefined }
38
- ];
39
- }
40
- const text = (tag: string, content: string): IJSLVNode => ({ tag, content });
41
- const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
42
- function card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {
43
- return { tag: "article", attr: { id, class: "sample-card grid-sample-card" }, children: [
44
- text("h3", title), { tag: "p", content: description, attr: { class: "card-description" } },
45
- ...extras, { tag: "div", attr: { class: "grid-sample-host" }, children: [grid] }, ...after,
46
- ...(source ? [{ tag: "details", attr: { class: "showcase-source" }, children: [
47
- text("summary", "Show code"),
48
- { tag: "pre", attr: { class: "sample-code showcase-source-code" }, children: [{ tag: "code", content: source }] }
49
- ] }] : [])
50
- ] };
51
- }
52
- function category(id: string, title: string, cards: IJSLVNode[]): IJSLVNode {
53
- return { tag: "section", attr: { id, class: "grid-category", "aria-labelledby": id + "-title" }, children: [
54
- { tag: "h3", content: title, attr: { id: id + "-title", class: "grid-category-title" } },
55
- { tag: "div", attr: { class: "grid-category-samples" }, children: cards }
56
- ] };
57
- }
58
- const basicTeams = ["Design", "Engineering", "Operations", "Research", "Product", "Marketing", "Finance", "Support", "Security", "Customer Success"];
59
- const basicData = data(100).map((project, index) => ({ ...project, team: basicTeams[index % basicTeams.length] }));
60
- const basic = new GridComponent(basicData, columns().map(column => ({ ...column, filterable: true })), {
61
- primaryKey: "id", multiColumnSort: true, numberedMultiColumnSort: true, showHeaderMenu: true
62
- }, "300px");
63
- const filterRowValues: Record<string, string> = {};
64
- const filterRow = new GridComponent(data(30), [
65
- { id: "id", name: "ID", width: 65, sortable: true },
66
- { id: "name", name: "Project", width: 230, sortable: true },
67
- { id: "team", name: "Team", width: 140, sortable: true },
68
- { id: "budget", name: "Budget", width: 125, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
69
- { id: "date", name: "Start date", width: 140, sortable: true, formatter: DateFormatter }
70
- ], {
71
- primaryKey: "id", showHeaderRow: true, headerRowHeight: 36, explicitInitialization: true,
72
- enableColumnReorder: false
73
- }, "320px");
74
- filterRow.initEvents(grid => {
75
- grid.onHeaderRowCellRendered.subscribe((_event, args) => {
76
- const input = document.createElement("input");
77
- input.type = "search";
78
- input.placeholder = "Filter…";
79
- input.setAttribute("aria-label", "Filter " + args.column.name);
80
- input.value = filterRowValues[args.column.id] || "";
81
- input.style.width = "100%";
82
- input.style.boxSizing = "border-box";
83
- args.node.textContent = "";
84
- args.node.appendChild(input);
85
- input.addEventListener("input", () => {
86
- filterRowValues[args.column.id] = input.value.toLowerCase();
87
- grid.refreshFilters(true);
88
- });
89
- });
90
- grid.addFilter({ field: "-", match: item => Object.keys(filterRowValues).every(id => {
91
- const query = filterRowValues[id];
92
- if (!query) return true;
93
- const column = grid.getColumnById(id);
94
- if (!column) return true;
95
- const value = grid.getDataItemValueForColumn(item, column);
96
- const displayValue = grid.getFormattedValue(column, value, item) || "";
97
- return displayValue.toLowerCase().includes(query);
98
- }) });
99
- grid.init();
100
- });
101
- let projectStarred = false;
102
- const projectHeaderButton = {
103
- html: "☆", tooltip: "Star project column", cssClass: "grid-header-action",
104
- handler: (event: MouseEvent) => {
105
- projectStarred = !projectStarred;
106
- projectHeaderButton.html = projectStarred ? "★" : "☆";
107
- projectHeaderButton.tooltip = projectStarred ? "Unstar project column" : "Star project column";
108
- projectHeaderButton.cssClass = "grid-header-action" + (projectStarred ? " grid-header-starred" : "");
109
- const button = event.currentTarget as HTMLElement;
110
- button.textContent = projectHeaderButton.html;
111
- button.title = projectHeaderButton.tooltip;
112
- button.classList.toggle("grid-header-starred", projectStarred);
113
- }
114
- };
115
- const headerActions = new GridComponent(data(12), [
116
- { id: "id", name: "ID", width: 65, sortable: true, filterable: true },
117
- { id: "name", name: "Project", width: 245, sortable: true, filterable: true, header: { buttons: [
118
- projectHeaderButton
119
- ] } },
120
- { id: "team", name: "Team", width: 145, sortable: true, filterable: true, header: { buttons: [
121
- { html: "i", tooltip: "About team column", cssClass: "grid-header-action", handler: () => {
122
- window.alert("The Team column shows the team responsible for each project.");
123
- } }
124
- ] } },
125
- { id: "budget", name: "Budget", width: 125, sortable: true, filterable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" }
126
- ], { primaryKey: "id", showHeaderMenu: true }, "300px");
127
- const edits: IJSLVNode = { tag: "p", content: "Edit a project, budget, date, or approval value.", attr: { role: "status", class: "sample-status" } };
128
- const editable = new GridComponent(data(25), columns(true), { primaryKey: "id", editable: true, autoEdit: false }, "300px");
129
- editable.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {
130
- edits.content = "Updated " + args.column.name + " for project " + args.item.id + ".";
131
- // Grid events run independently of the showcase renderer.
132
- JSLRender.lastCreatedRenderer?.refresh();
133
- }));
134
-
135
- interface EditorSample {
136
- id: number;
137
- title: string;
138
- notes: string;
139
- amount: number;
140
- start: Date;
141
- startTime: string;
142
- meeting: Date;
143
- approved: boolean;
144
- completed: boolean;
145
- status: string;
146
- tags: string[];
147
- owner: string;
148
- detail: string;
149
- }
150
- const editorValueList = [
151
- { text: "Planning", value: "planning" },
152
- { text: "In progress", value: "in-progress" },
153
- { text: "In review", value: "in-review" },
154
- { text: "Complete", value: "complete" }
155
- ];
156
- const editorSamples: EditorSample[] = Array.from({ length: 8 }, (_, index) => ({
157
- id: index + 1,
158
- title: ["Design system", "Website refresh", "Customer research", "Mobile workspace"][index % 4],
159
- notes: ["Review the latest proposal", "Collect feedback from the team", "Prepare the next milestone"][index % 3],
160
- amount: 1250 + index * 175.5,
161
- start: new Date(2026, 9, 2 + index),
162
- startTime: ["09:00", "10:30", "13:15", "15:45"][index % 4],
163
- meeting: new Date(2026, 9, 2 + index, 9 + index % 8, 30),
164
- approved: index % 2 === 0,
165
- completed: index % 3 === 0,
166
- status: ["planning", "in-progress", "in-review", "complete"][index % 4],
167
- tags: index % 2 === 0 ? ["Design", "Internal"] : ["Customer", "Research"],
168
- owner: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"][index % 4],
169
- detail: "Updated by the project team. Hover this cell to see the full tooltip text."
170
- }));
171
- const editorSampleColumns: ISlickColumn[] = [
172
- { id: "title", name: "Text", width: 155, formatter: TextFormatter, editor: TextEditor },
173
- { id: "notes", name: "Multiline text", width: 185, formatter: MultiLineTextFormatter, editor: MultiLineTextEditor },
174
- { id: "amount", name: "Number", width: 115, headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", editor: NumericEditor },
175
- { id: "start", name: "Date", width: 125, formatter: DateFormatter, editor: DateEditor },
176
- { id: "startTime", name: "Time input", width: 115, formatter: TextFormatter, editor: TimeEditor },
177
- { id: "meeting", name: "Time display", width: 110, formatter: TimeFormatter },
178
- { id: "meetingDateTime", field: "meeting", name: "Date & time", width: 165, formatter: DateTimeFormatter },
179
- { id: "approved", name: "Checkbox", width: 100, headerCssClass: "center", formatter: CheckboxFormatter, editor: BooleanEditor },
180
- { id: "completed", name: "Yes / no", width: 95, formatter: YesNoFormatter, editor: BooleanEditor },
181
- { id: "status", name: "Lookup", width: 130, formatter: LookupFormatter, valueList: editorValueList, editor: LookupEditor },
182
- { id: "tags", name: "Multi-lookup", width: 175, formatter: MultiLookupFormatter, valueList: ["Design", "Internal", "Customer", "Research"], editor: MultiLookupEditor },
183
- { id: "owner", name: "Autosuggest", width: 145, formatter: LookupFormatter, valueList: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"], editor: AutoSuggestEditor },
184
- { id: "detail", name: "Tooltip", width: 230, formatter: TooltipFormatter, editor: TextEditor }
185
- ];
186
- const editorCatalog = new GridComponent(editorSamples, editorSampleColumns, {
187
- primaryKey: "id", editable: true, autoEdit: false, rowHeight: 38
188
- }, "340px");
189
- const editorCatalogStatus: IJSLVNode = { tag: "p", content: "Double-click a cell to edit. Enter commits; Escape cancels.", attr: { role: "status", class: "sample-status" } };
190
- editorCatalog.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {
191
- editorCatalogStatus.content = "Updated " + args.column.name + " for sample " + args.item.id + ".";
192
- JSLRender.lastCreatedRenderer?.refresh();
193
- }));
194
- const grouped = new GridComponent(data(45), columns().map(column => column.id === "budget" ? {
195
- ...column, groupTotalsFormatter: totals => ({ text: numeric.format(totals.sum.budget, "#,0"), addClasses: ["right", "tabular-nums"] })
196
- } : column.id === "name" ? { ...column, groupTotalsFormatter: () => "Team total" } : column), { primaryKey: "id" }, "320px");
197
- grouped.initEvents(grid => grid.dataView.setGrouping({
198
- getter: "team", formatter: group => group.value + " · " + group.count + " projects",
199
- aggregators: [new SumAggregator("budget")], displayTotalsRow: true, aggregateCollapsed: true
200
- }));
201
-
202
- interface HierarchyItem { id: number; parent?: number; name: string; owner: string; }
203
- const hierarchyData: HierarchyItem[] = [
204
- { id: 1, name: "Website refresh", owner: "Design" },
205
- { id: 2, parent: 1, name: "Research", owner: "Research" },
206
- { id: 3, parent: 2, name: "Interview customers", owner: "Sam" },
207
- { id: 4, parent: 2, name: "Summarize findings", owner: "Alex" },
208
- { id: 5, parent: 1, name: "Design new pages", owner: "Design" },
209
- { id: 6, name: "Mobile workspace", owner: "Engineering" },
210
- { id: 7, parent: 6, name: "Build prototype", owner: "Jordan" },
211
- { id: 8, parent: 6, name: "Review accessibility", owner: "Robin" }
212
- ];
213
- const hierarchy = new GridComponent(hierarchyData, [
214
- { id: "name", name: "Project / task", width: 320, formatter: IndentFormatter },
215
- { id: "owner", name: "Owner", width: 160 }
216
- ], { primaryKey: "id", enableColumnReorder: false }, "320px");
217
- hierarchy.initEvents(grid => { new GridTree(grid, { parentColumn: "parent" }); });
218
-
219
- interface ProgressRow { id: number; task: string; progress: number | null; }
220
- const progressRows: ProgressRow[] = Array.from({ length: 8 }, (_, index) => ({
221
- id: index + 1, task: "Process project " + (index + 1), progress: null
222
- }));
223
- const cellComponents = new GridComponent(progressRows, [
224
- { id: "task", name: "Task", width: 230 },
225
- { id: "progress", name: "Progress", width: 240, formatter: ComponentFormatter }
226
- ], { primaryKey: "id", rowHeight: 48 }, "320px");
227
- cellComponents.initEvents(grid => {
228
- grid.onAppendCell.subscribe((_event, args) => {
229
- if (args.column.id !== "progress" || !args.item) return;
230
- const item = args.item;
231
- const renderer = new JSLRender(args.dom);
232
- if (item.progress == null) {
233
- renderer.render(new ButtonComponent({ content: "Start", type: "button", size: "small", click: () => {
234
- if (item.progress != null) return;
235
- const start = performance.now();
236
- item.progress = 0;
237
- grid.refreshDataItem(item);
238
- const tick = () => {
239
- if (!grid.getContainerNode().isConnected) return;
240
- item.progress = Math.min(100, Math.floor((performance.now() - start) / 50));
241
- grid.refreshDataItem(item);
242
- if (item.progress < 100) window.setTimeout(tick, 100);
243
- };
244
- window.setTimeout(tick, 100);
245
- } }));
246
- } else {
247
- renderer.render(new ProgressComponent(item.progress, { showPercent: true, ariaLabel: item.task + " progress" }));
248
- }
249
- });
250
- grid.refresh();
251
- });
252
-
253
- interface SelectionRow { id: number; project: string; hours: number; rate: number; cost: number; }
254
- interface SelectionRange { fromRow: number; toRow: number; fromCell: number; toCell: number; }
255
- const selectionData: SelectionRow[] = Array.from({ length: 8 }, (_, index) => ({
256
- id: index + 1, project: "Project " + (index + 1), hours: 10 + index * 5,
257
- rate: 80 + index * 10, cost: (10 + index * 5) * (80 + index * 10)
258
- }));
259
- const selectionGrid = new GridComponent(selectionData, [
260
- { id: "project", name: "Project", width: 180 },
261
- { id: "hours", name: "Hours", width: 110, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
262
- { id: "rate", name: "Rate", width: 110, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
263
- { id: "cost", name: "Cost", width: 120, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" }
264
- ], { primaryKey: "id", enableColumnReorder: false }, "320px");
265
- const selectionSummary: IJSLVNode = { tag: "p", content: "No rows selected.", attr: { class: "sample-status grid-selection-summary", role: "status" } };
266
- let selectionMode: "row" | "cell" = "row";
267
- function updateSelectionSummary(grid: IJSLGrid<SelectionRow>, ranges: SelectionRange[]) {
268
- const cells = new Map<string, { row: SelectionRow; column: ISlickColumn; value: unknown }>();
269
- for (const range of ranges) {
270
- for (let row = range.fromRow; row <= range.toRow; row++) {
271
- for (let cell = range.fromCell; cell <= range.toCell; cell++) {
272
- const item = grid.getDataItem(row), column = grid.getColumns()[cell];
273
- if (item && column) cells.set(row + ":" + cell, { row: item, column, value: item[column.field || column.id] });
274
- }
275
- }
276
- }
277
- if (selectionMode === "row") {
278
- const rows = Array.from(new Map(Array.from(cells.values(), entry => [entry.row.id, entry.row])).values());
279
- selectionSummary.content = rows.length ? "Selected rows: " + rows.map(row => row.project).join(", ") + "." : "No rows selected.";
280
- } else {
281
- const selected = Array.from(cells.values());
282
- const values = selected.map(entry => entry.value).filter((value): value is number => typeof value === "number" && Number.isFinite(value));
283
- const sum = values.reduce((total, value) => total + value, 0);
284
- selectionSummary.content = selected.length
285
- ? selected.length + " cells selected - Sum: " + numeric.format(sum, "#,0.00") + " - Avg: " + (values.length ? numeric.format(sum / values.length, "#,0.00") : "—")
286
- : "No cells selected.";
287
- }
288
- JSLRender.lastCreatedRenderer?.refresh();
289
- }
290
- function setSelectionMode(grid: IJSLGrid<SelectionRow>, mode: "row" | "cell") {
291
- grid.getSelectionModel().setSelectedRanges([]);
292
- grid.resetActiveCell();
293
- selectionMode = mode;
294
- const model = mode === "row" ? new RowSelectionModel() : new CellSelectionModel();
295
- grid.setSelectionModel(model);
296
- model.onSelectedRangesChanged.subscribe((_event, ranges: SelectionRange[]) => updateSelectionSummary(grid, ranges));
297
- updateSelectionSummary(grid, []);
298
- }
299
- selectionGrid.initEvents(grid => setSelectionMode(grid, selectionMode));
300
- const frozenData = data(120).map((project, index) => ({
301
- ...project,
302
- owner: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"][index % 4],
303
- status: ["Planning", "In progress", "In review", "Complete"][index % 4],
304
- due: new Date(2026, 11, 1 + index % 28),
305
- plannedHours: 80 + index * 4,
306
- actualHours: 25 + index * 3,
307
- location: ["Vienna", "London", "Berlin", "New York"][index % 4]
308
- }));
309
- const frozenColumns: ISlickColumn[] = [
310
- ...columns().map(column => ({ ...column, width: column.id === "name" ? 300 : 180 })),
311
- { id: "owner", name: "Project owner", width: 200, sortable: true },
312
- { id: "status", name: "Status", width: 180, sortable: true },
313
- { id: "due", name: "Due date", width: 180, sortable: true, formatter: DateFormatter },
314
- { id: "plannedHours", name: "Planned hours", width: 180, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
315
- { id: "actualHours", name: "Actual hours", width: 180, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
316
- { id: "location", name: "Office", width: 180, sortable: true }
317
- ];
318
- const frozen = new GridComponent(frozenData, frozenColumns, {
319
- primaryKey: "id", frozenColumn: 1
320
- }, "320px");
321
- const large = new GridComponent(data(10000), columns(), { primaryKey: "id", rowHeight: 28 }, "320px");
322
-
323
- const variableHeightData = Array.from({ length: 60 }, (_, index) => {
324
- const samples = [
325
- { height: 40, note: "Ready for review." },
326
- { height: 80, note: "Collect feedback from the project team and agree on the next milestone." },
327
- { height: 120, note: "Review the research findings with the team. Summarize the open questions and prepare recommendations for the next planning session." }
328
- ];
329
- const sample = samples[index % samples.length];
330
- return { id: index + 1, project: "Project " + (index + 1), note: sample.note, __height: sample.height };
331
- });
332
- const variableHeight = new GridComponent(variableHeightData, [
333
- { id: "id", name: "ID", width: 65 },
334
- { id: "project", name: "Project", width: 150 },
335
- { id: "note", name: "Update", width: 350, formatter: MultiLineTextFormatter },
336
- { id: "__height", name: "Height (px)", width: 110, headerCssClass: "right", formatter: NumericFormatter }
337
- ], { primaryKey: "id", rowHeight: 40, variableRowHeight: true }, "320px");
338
- const variableHeightSource = `import "../../ui/base.css";
339
- import { JSLRender } from "jsl-render";
340
- import { GridComponent } from "../../components/grid/GridComponent";
341
- import { MultiLineTextFormatter, NumericFormatter } from "../../grid/slick.formatters";
342
-
343
- const items = Array.from({ length: 60 }, (_, index) => {
344
- const samples = [
345
- { height: 40, note: "Ready for review." },
346
- { height: 80, note: "Collect feedback from the project team and agree on the next milestone." },
347
- { height: 120, note: "Review the research findings with the team. Summarize the open questions and prepare recommendations for the next planning session." }
348
- ];
349
- const sample = samples[index % samples.length];
350
- return { id: index + 1, project: "Project " + (index + 1), note: sample.note, __height: sample.height };
351
- });
352
-
353
- const grid = new GridComponent(items, [
354
- { id: "id", name: "ID", width: 65 },
355
- { id: "project", name: "Project", width: 150 },
356
- { id: "note", name: "Update", width: 350, formatter: MultiLineTextFormatter },
357
- { id: "__height", name: "Height (px)", width: 110, headerCssClass: "right", formatter: NumericFormatter }
358
- ], { primaryKey: "id", rowHeight: 40, variableRowHeight: true }, "320px");
359
-
360
- // Add <div id="grid"></div> to the page.
361
- new JSLRender(document.getElementById("grid"), true).render(grid);`;
362
-
363
- const groupedVariableHeight = new GridComponent(
364
- data(45).map(project => ({ ...project, __height: 80 })),
365
- columns(),
366
- { primaryKey: "id", rowHeight: 40, variableRowHeight: true },
367
- "320px"
368
- );
369
- groupedVariableHeight.initEvents(grid => grid.dataView.setGrouping({
370
- getter: "team", formatter: group => group.value + " · " + group.count + " projects", aggregators: [], displayTotalsRow: false
371
- }));
372
-
373
- const costingData = data(12).map((project, index) => ({
374
- ...project, hours: 16 + index * 4, rate: 85 + index % 3 * 15, cost: 0
375
- }));
376
- const costingColumns: ISlickColumn[] = [
377
- { id: "id", name: "ID", width: 65, columnGroup: "Project" },
378
- { id: "name", name: "Project", width: 240, columnGroup: "Project", editor: TextEditor },
379
- { id: "team", name: "Team", width: 140, columnGroup: "Project" },
380
- { id: "hours", name: "Hours", width: 120, columnGroup: "Costing", headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", editor: NumericEditor },
381
- { id: "rate", name: "Hourly rate", width: 135, columnGroup: "Costing", headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", editor: NumericEditor },
382
- { id: "cost", name: "Estimated cost", width: 160, columnGroup: "Costing", headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", readonly: true, toolTip: "Calculated: hours × hourly rate" },
383
- { id: "date", name: "Start date", width: 140, columnGroup: "Schedule", formatter: DateFormatter }
384
- ];
385
- const costing = new GridComponent(costingData, costingColumns, {
386
- primaryKey: "id", editable: true, autoEdit: false, showColumnGroups: true,
387
- preHeaderPanelHeight: 37, createFooterRow: true, showFooterRow: true, footerRowHeight: 36,
388
- enableColumnReorder: false
389
- }, "380px");
390
- costing.initEvents(grid => {
391
- grid.addFormula("cost", item => (item.hours || 0) * (item.rate || 0), ["hours", "rate"]);
392
- grid.triggerAllFormulas();
393
- const updateTotals = () => {
394
- const label = grid.getFooterRowColumn("name");
395
- if (label) { label.textContent = "Total"; }
396
- for (const field of ["hours", "cost"] as const) {
397
- const footer = grid.getFooterRowColumn(field);
398
- if (footer) {
399
- footer.classList.add("right", "tabular-nums");
400
- footer.textContent = numeric.format(grid.getData().reduce((sum, item) => sum + item[field], 0), "#,0.00");
401
- }
402
- }
403
- };
404
- grid.onAfterEdit.subscribe(updateTotals);
405
- grid.onFooterRowCellRendered.subscribe(updateTotals);
406
- updateTotals();
407
- });
408
-
409
- const orderStatus: IJSLVNode = { tag: "p", content: "Drag a handle to change the project order.", attr: { role: "status", class: "sample-status" } };
410
- const reorder = new GridComponent(data(15), [
411
- { id: "_move", name: "", width: 36, minWidth: 36, maxWidth: 36, resizable: false, selectable: false,
412
- behavior: "selectAndMove", cssClass: "grid-row-handle", toolTip: "Drag to reorder", formatter: () => '<span aria-hidden="true">⠿</span>' },
413
- { id: "priority", name: "Order", width: 75, headerCssClass: "center", formatter: row => ({ text: String(row + 1), addClasses: ["center", "tabular-nums"] }) },
414
- ...columns().filter(column => column.id !== "id").map(column => ({ ...column, sortable: false }))
415
- ], { primaryKey: "id", allowRowMove: true, enableColumnReorder: false }, "320px");
416
- reorder.initEvents(grid => grid.dataView.onRowsChanged.subscribe(() => {
417
- orderStatus.content = "Project order: " + grid.getData().map(item => item.id).join(", ") + ".";
418
- JSLRender.lastCreatedRenderer?.refresh();
419
- }));
420
- export const gridShowcase: IJSLVNode = {
421
- tag: "section", attr: { id: "grids", class: "component-section", "aria-labelledby": "grids-title" }, children: [
422
- { tag: "div", attr: { class: "hero-copy" }, children: [
423
- { tag: "p", content: "THE ESSENTIALS / 22", attr: { class: "eyebrow" } },
424
- { tag: "h2", content: "Grids", attr: { id: "grids-title", class: "section-title" } },
425
- text("p", "Representative data, formatting, editing, grouping, and scrolling examples for the grid redesign.")
426
- ] },
427
- { tag: "div", attr: { class: "grid-samples" }, children: [
428
- category("grid-browsing", "Browsing & layout", [
429
- card("grid-basic", "Browse, sort & filter", "100 projects across 10 teams. Open a column header menu and choose Filter to select values. Click a heading to sort, then Shift-click other headings to add sort levels. Numbers show sorting priority. Select rows and resize or reorder columns.", basic),
430
- card("grid-filter-row", "Filter row", "Type in one or more fields to filter project, team, budget, or formatted start date. Active fields combine, so each matching row must satisfy every entered filter.", filterRow),
431
- card("grid-header-menu-icons", "Column menus & header icons", "Open a column menu to sort or filter. Click the star in the Project heading to toggle it, or the Team information icon to show a message.", headerActions),
432
- card("grid-frozen", "Frozen columns", "12 columns and 120 projects. The ID and project stay visible while you scroll through ownership, status, dates, hours, and office details, even on wide screens.", frozen),
433
- card("grid-large", "A larger dataset", "10,000 rows with an explicit rowHeight of 28 px. This example also checks that applications can retain the original density.", large),
434
- card("grid-reorder", "Arrange project priorities", "Drag a handle in the first column to move a project. The Order column follows its position while project IDs remain unchanged. Sorting is disabled here so it does not override the manual order.", reorder, [orderStatus])
435
- ]),
436
- category("grid-editing", "Editing", [
437
- card("grid-editable", "Edit in place", "Double-click an editable cell. Enter commits and Escape cancels. Editors retain their existing behavior and styling in this step.", editable, [edits]),
438
- card("grid-editors-formatters", "Formatters and editors", "Try text, multiline, numeric, date, time, boolean, lookup, multi-lookup, and autosuggest editors. The adjacent columns demonstrate the matching display formatters; TimeFormatter displays a Date value, while TimeEditor edits a time string.", editorCatalog, [editorCatalogStatus])
439
- ]),
440
- category("grid-grouping", "Grouping & header groups", [
441
- card("grid-grouped", "Grouped projects & totals", "45 projects grouped by team, with a budget total for each group. Expand and collapse groups independently; totals remain visible when a group is collapsed.", grouped, [
442
- { tag: "div", attr: { class: "sample-row" }, children: [
443
- action("Collapse groups", () => { grouped.getRef().then(grid => grid.dataView.collapseAllGroups()); }),
444
- action("Expand groups", () => { grouped.getRef().then(grid => grid.dataView.expandAllGroups()); })
445
- ] }
446
- ]),
447
- card("grid-costing", "Column groups, formulas & totals", "Project, Costing, and Schedule headers group related columns. Double-click Hours or Hourly rate to edit: the grid formula recalculates Estimated cost, and the footer updates the totals.", costing, [
448
- { tag: "pre", content: 'grid.addFormula("cost", item => item.hours * item.rate, ["hours", "rate"]);', attr: { class: "sample-code" } }
449
- ]),
450
- card("grid-hierarchy", "Hierarchical projects & tasks", "Expand or collapse projects and their nested tasks. The grid uses parent IDs and an indented formatter to show the hierarchy.", hierarchy)
451
- ]),
452
- category("grid-interaction", "Selection & cell components", [
453
- card("grid-cell-components", "Components inside cells", "Click Start to replace the button with a progress bar. Each task progresses independently from 0 to 100% over five seconds.", cellComponents),
454
- card("grid-selection", "Row and cell selection", "Choose a mode, then select rows or drag across cells. Use Ctrl or Command to add selections and Shift to extend them. Cell totals include numeric values only.", selectionGrid, [
455
- { tag: "label", attr: { class: "grid-selection-mode", for: "grid-selection-mode" }, children: [
456
- text("span", "Selection mode"),
457
- { tag: "select", attr: { id: "grid-selection-mode", change: (event: Event) => {
458
- const mode = (event.target as HTMLSelectElement).value as "row" | "cell";
459
- selectionGrid.getRef().then(grid => setSelectionMode(grid, mode));
460
- } }, children: [
461
- { tag: "option", attr: { value: "row" }, content: "Rows" },
462
- { tag: "option", attr: { value: "cell" }, content: "Cells" }
463
- ] }
464
- ] }
465
- ], undefined, [selectionSummary])
466
- ]),
467
- category("grid-variable-rows", "Variable row height", [
468
- card("grid-variable-height", "Variable row heights", "Scroll through 60 projects with 40, 80, and 120 px rows. Each item's __height controls its height; the Update column wraps its text. Row heights are explicit and do not automatically adjust when a column is resized.", variableHeight, [], variableHeightSource),
469
- card("grid-grouped-variable-height", "Grouped rows keep their default height", "Projects are grouped by team. Group headers use the default 40 px row height, while each project row is 80 px. Expand and collapse groups to see the heights remain in place.", groupedVariableHeight, [
470
- { tag: "div", attr: { class: "sample-row" }, children: [
471
- action("Collapse groups", () => { groupedVariableHeight.getRef().then(grid => grid.dataView.collapseAllGroups()); }),
472
- action("Expand groups", () => { groupedVariableHeight.getRef().then(grid => grid.dataView.expandAllGroups()); })
473
- ] },
474
- { tag: "pre", content: 'const items = projects.map(project => ({ ...project, __height: 80 }));\nnew GridComponent(items, columns, {\n primaryKey: "id", rowHeight: 40, variableRowHeight: true\n});', attr: { class: "sample-code" } }
475
- ])
476
- ])
477
- ] },
478
- { tag: "details", attr: { class: "usage" }, children: [
479
- text("summary", "Grid showcase scope"),
480
- text("p", 'NumericFormatter supplies right-aligned cells; NumericFormatter and DateFormatter apply tabular numerals. Set headerCssClass: "right" or "center" explicitly to match a column’s content. Header alignment is never inferred from its formatter.'),
481
- text("p", "These examples use the existing GridComponent constructor, column definitions, editors, and DataView APIs. The default row height is 40 px; rowHeight can retain a different density. Column headers fit up to two lines. Core presentation follows the shared theme and inherits the host's typography. Browse, sort & filter demonstrates the Excel filter from a column header menu; Filter row demonstrates custom inputs on the grid header row.")
482
- ] }
483
- ]
484
- };
1
+ import { IJSLVNode, JSLRender } from "jsl-render";
2
+ import { GridComponent } from "../../components/grid/GridComponent";
3
+ import { ISlickColumn } from "../../grid/slick.core";
4
+ import { IJSLGrid } from "../../grid/slick.creator";
5
+ import { SumAggregator } from "../../grid/slick.dataview";
6
+ import { GridTree, IndentFormatter } from "../../grid/slick.tree";
7
+ import { CellSelectionModel } from "../../grid/plugins/slick.cellselectionmodel";
8
+ import { RowSelectionModel } from "../../grid/plugins/slick.rowselectionmodel";
9
+ import { TextEditor, MultiLineTextEditor, NumericEditor, BooleanEditor } from "../../grid/slick.editors.core";
10
+ import { DateEditor, TimeEditor } from "../../grid/slick.editors.date";
11
+ import { AutoSuggestEditor, LookupEditor, MultiLookupEditor } from "../../grid/slick.editors.lookup";
12
+ import {
13
+ CheckboxFormatter, DateFormatter, DateTimeFormatter, LookupFormatter,
14
+ MultiLineTextFormatter, MultiLookupFormatter, NumericFormatter, TextFormatter, TimeFormatter,
15
+ TooltipFormatter, YesNoFormatter, ComponentFormatter
16
+ } from "../../grid/slick.formatters";
17
+ import { ButtonComponent } from "../../components/button/ButtonComponent";
18
+ import { ProgressComponent } from "../../components/progress/ProgressComponent";
19
+ import { numeric } from "../../core/numeric";
20
+
21
+ interface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }
22
+ function data(count: number): Project[] {
23
+ const names = ["Design system", "Website refresh", "Customer research", "Mobile workspace", "Reporting tools"];
24
+ return Array.from({ length: count }, (_, index) => ({
25
+ id: index + 1, name: names[index % names.length] + " " + (index + 1),
26
+ team: ["Design", "Engineering", "Operations"][index % 3], budget: 1500 + index * 125,
27
+ date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0
28
+ }));
29
+ }
30
+ function columns(editable = false): ISlickColumn[] {
31
+ return [
32
+ { id: "id", name: "ID", width: 65, sortable: true },
33
+ { id: "name", name: "Project", width: 250, sortable: true, editor: editable ? TextEditor : undefined },
34
+ { id: "team", name: "Team", width: 145, sortable: true, editor: editable ? TextEditor : undefined },
35
+ { id: "budget", name: "Budget", width: 125, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0", editor: editable ? NumericEditor : undefined },
36
+ { id: "date", name: "Start date", width: 135, sortable: true, formatter: DateFormatter, editor: editable ? DateEditor : undefined },
37
+ { id: "approved", name: "Approved", width: 100, headerCssClass: "center", formatter: CheckboxFormatter, editor: editable ? BooleanEditor : undefined }
38
+ ];
39
+ }
40
+ const text = (tag: string, content: string): IJSLVNode => ({ tag, content });
41
+ const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
42
+ function card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {
43
+ return { tag: "article", attr: { id, class: "sample-card grid-sample-card" }, children: [
44
+ text("h3", title), { tag: "p", content: description, attr: { class: "card-description" } },
45
+ ...extras, { tag: "div", attr: { class: "grid-sample-host" }, children: [grid] }, ...after,
46
+ ...(source ? [{ tag: "details", attr: { class: "showcase-source" }, children: [
47
+ text("summary", "Show code"),
48
+ { tag: "pre", attr: { class: "sample-code showcase-source-code" }, children: [{ tag: "code", content: source }] }
49
+ ] }] : [])
50
+ ] };
51
+ }
52
+ function category(id: string, title: string, cards: IJSLVNode[]): IJSLVNode {
53
+ return { tag: "section", attr: { id, class: "grid-category", "aria-labelledby": id + "-title" }, children: [
54
+ { tag: "h3", content: title, attr: { id: id + "-title", class: "grid-category-title" } },
55
+ { tag: "div", attr: { class: "grid-category-samples" }, children: cards }
56
+ ] };
57
+ }
58
+ const basicTeams = ["Design", "Engineering", "Operations", "Research", "Product", "Marketing", "Finance", "Support", "Security", "Customer Success"];
59
+ const basicData = data(100).map((project, index) => ({ ...project, team: basicTeams[index % basicTeams.length] }));
60
+ const basic = new GridComponent(basicData, columns().map(column => ({ ...column, filterable: true })), {
61
+ primaryKey: "id", multiColumnSort: true, numberedMultiColumnSort: true, showHeaderMenu: true
62
+ }, "300px");
63
+ const filterRowValues: Record<string, string> = {};
64
+ const filterRow = new GridComponent(data(30), [
65
+ { id: "id", name: "ID", width: 65, sortable: true },
66
+ { id: "name", name: "Project", width: 230, sortable: true },
67
+ { id: "team", name: "Team", width: 140, sortable: true },
68
+ { id: "budget", name: "Budget", width: 125, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
69
+ { id: "date", name: "Start date", width: 140, sortable: true, formatter: DateFormatter }
70
+ ], {
71
+ primaryKey: "id", showHeaderRow: true, headerRowHeight: 36, explicitInitialization: true,
72
+ enableColumnReorder: false
73
+ }, "320px");
74
+ filterRow.initEvents(grid => {
75
+ grid.onHeaderRowCellRendered.subscribe((_event, args) => {
76
+ const input = document.createElement("input");
77
+ input.type = "search";
78
+ input.placeholder = "Filter…";
79
+ input.setAttribute("aria-label", "Filter " + args.column.name);
80
+ input.value = filterRowValues[args.column.id] || "";
81
+ input.style.width = "100%";
82
+ input.style.boxSizing = "border-box";
83
+ args.node.textContent = "";
84
+ args.node.appendChild(input);
85
+ input.addEventListener("input", () => {
86
+ filterRowValues[args.column.id] = input.value.toLowerCase();
87
+ grid.refreshFilters(true);
88
+ });
89
+ });
90
+ grid.addFilter({ field: "-", match: item => Object.keys(filterRowValues).every(id => {
91
+ const query = filterRowValues[id];
92
+ if (!query) return true;
93
+ const column = grid.getColumnById(id);
94
+ if (!column) return true;
95
+ const value = grid.getDataItemValueForColumn(item, column);
96
+ const displayValue = grid.getFormattedValue(column, value, item) || "";
97
+ return displayValue.toLowerCase().includes(query);
98
+ }) });
99
+ grid.init();
100
+ });
101
+ let projectStarred = false;
102
+ const projectHeaderButton = {
103
+ html: "☆", tooltip: "Star project column", cssClass: "grid-header-action",
104
+ handler: (event: MouseEvent) => {
105
+ projectStarred = !projectStarred;
106
+ projectHeaderButton.html = projectStarred ? "★" : "☆";
107
+ projectHeaderButton.tooltip = projectStarred ? "Unstar project column" : "Star project column";
108
+ projectHeaderButton.cssClass = "grid-header-action" + (projectStarred ? " grid-header-starred" : "");
109
+ const button = event.currentTarget as HTMLElement;
110
+ button.textContent = projectHeaderButton.html;
111
+ button.title = projectHeaderButton.tooltip;
112
+ button.classList.toggle("grid-header-starred", projectStarred);
113
+ }
114
+ };
115
+ const headerActions = new GridComponent(data(12), [
116
+ { id: "id", name: "ID", width: 65, sortable: true, filterable: true },
117
+ { id: "name", name: "Project", width: 245, sortable: true, filterable: true, header: { buttons: [
118
+ projectHeaderButton
119
+ ] } },
120
+ { id: "team", name: "Team", width: 145, sortable: true, filterable: true, header: { buttons: [
121
+ { html: "i", tooltip: "About team column", cssClass: "grid-header-action", handler: () => {
122
+ window.alert("The Team column shows the team responsible for each project.");
123
+ } }
124
+ ] } },
125
+ { id: "budget", name: "Budget", width: 125, sortable: true, filterable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" }
126
+ ], { primaryKey: "id", showHeaderMenu: true }, "300px");
127
+ const edits: IJSLVNode = { tag: "p", content: "Edit a project, budget, date, or approval value.", attr: { role: "status", class: "sample-status" } };
128
+ const editable = new GridComponent(data(25), columns(true), { primaryKey: "id", editable: true, autoEdit: false }, "300px");
129
+ editable.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {
130
+ edits.content = "Updated " + args.column.name + " for project " + args.item.id + ".";
131
+ // Grid events run independently of the showcase renderer.
132
+ JSLRender.lastCreatedRenderer?.refresh();
133
+ }));
134
+
135
+ interface EditorSample {
136
+ id: number;
137
+ title: string;
138
+ notes: string;
139
+ amount: number;
140
+ start: Date;
141
+ startTime: string;
142
+ meeting: Date;
143
+ approved: boolean;
144
+ completed: boolean;
145
+ status: string;
146
+ tags: string[];
147
+ owner: string;
148
+ detail: string;
149
+ }
150
+ const editorValueList = [
151
+ { text: "Planning", value: "planning" },
152
+ { text: "In progress", value: "in-progress" },
153
+ { text: "In review", value: "in-review" },
154
+ { text: "Complete", value: "complete" }
155
+ ];
156
+ const editorSamples: EditorSample[] = Array.from({ length: 8 }, (_, index) => ({
157
+ id: index + 1,
158
+ title: ["Design system", "Website refresh", "Customer research", "Mobile workspace"][index % 4],
159
+ notes: ["Review the latest proposal", "Collect feedback from the team", "Prepare the next milestone"][index % 3],
160
+ amount: 1250 + index * 175.5,
161
+ start: new Date(2026, 9, 2 + index),
162
+ startTime: ["09:00", "10:30", "13:15", "15:45"][index % 4],
163
+ meeting: new Date(2026, 9, 2 + index, 9 + index % 8, 30),
164
+ approved: index % 2 === 0,
165
+ completed: index % 3 === 0,
166
+ status: ["planning", "in-progress", "in-review", "complete"][index % 4],
167
+ tags: index % 2 === 0 ? ["Design", "Internal"] : ["Customer", "Research"],
168
+ owner: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"][index % 4],
169
+ detail: "Updated by the project team. Hover this cell to see the full tooltip text."
170
+ }));
171
+ const editorSampleColumns: ISlickColumn[] = [
172
+ { id: "title", name: "Text", width: 155, formatter: TextFormatter, editor: TextEditor },
173
+ { id: "notes", name: "Multiline text", width: 185, formatter: MultiLineTextFormatter, editor: MultiLineTextEditor },
174
+ { id: "amount", name: "Number", width: 115, headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", editor: NumericEditor },
175
+ { id: "start", name: "Date", width: 125, formatter: DateFormatter, editor: DateEditor },
176
+ { id: "startTime", name: "Time input", width: 115, formatter: TextFormatter, editor: TimeEditor },
177
+ { id: "meeting", name: "Time display", width: 110, formatter: TimeFormatter },
178
+ { id: "meetingDateTime", field: "meeting", name: "Date & time", width: 165, formatter: DateTimeFormatter },
179
+ { id: "approved", name: "Checkbox", width: 100, headerCssClass: "center", formatter: CheckboxFormatter, editor: BooleanEditor },
180
+ { id: "completed", name: "Yes / no", width: 95, formatter: YesNoFormatter, editor: BooleanEditor },
181
+ { id: "status", name: "Lookup", width: 130, formatter: LookupFormatter, valueList: editorValueList, editor: LookupEditor },
182
+ { id: "tags", name: "Multi-lookup", width: 175, formatter: MultiLookupFormatter, valueList: ["Design", "Internal", "Customer", "Research"], editor: MultiLookupEditor },
183
+ { id: "owner", name: "Autosuggest", width: 145, formatter: LookupFormatter, valueList: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"], editor: AutoSuggestEditor },
184
+ { id: "detail", name: "Tooltip", width: 230, formatter: TooltipFormatter, editor: TextEditor }
185
+ ];
186
+ const editorCatalog = new GridComponent(editorSamples, editorSampleColumns, {
187
+ primaryKey: "id", editable: true, autoEdit: false, rowHeight: 38
188
+ }, "340px");
189
+ const editorCatalogStatus: IJSLVNode = { tag: "p", content: "Double-click a cell to edit. Enter commits; Escape cancels.", attr: { role: "status", class: "sample-status" } };
190
+ editorCatalog.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {
191
+ editorCatalogStatus.content = "Updated " + args.column.name + " for sample " + args.item.id + ".";
192
+ JSLRender.lastCreatedRenderer?.refresh();
193
+ }));
194
+ const grouped = new GridComponent(data(45), columns().map(column => column.id === "budget" ? {
195
+ ...column, groupTotalsFormatter: totals => ({ text: numeric.format(totals.sum.budget, "#,0"), addClasses: ["right", "tabular-nums"] })
196
+ } : column.id === "name" ? { ...column, groupTotalsFormatter: () => "Team total" } : column), { primaryKey: "id" }, "320px");
197
+ grouped.initEvents(grid => grid.dataView.setGrouping({
198
+ getter: "team", formatter: group => group.value + " · " + group.count + " projects",
199
+ aggregators: [new SumAggregator("budget")], displayTotalsRow: true, aggregateCollapsed: true
200
+ }));
201
+
202
+ interface HierarchyItem { id: number; parent?: number; name: string; owner: string; }
203
+ const hierarchyData: HierarchyItem[] = [
204
+ { id: 1, name: "Website refresh", owner: "Design" },
205
+ { id: 2, parent: 1, name: "Research", owner: "Research" },
206
+ { id: 3, parent: 2, name: "Interview customers", owner: "Sam" },
207
+ { id: 4, parent: 2, name: "Summarize findings", owner: "Alex" },
208
+ { id: 5, parent: 1, name: "Design new pages", owner: "Design" },
209
+ { id: 6, name: "Mobile workspace", owner: "Engineering" },
210
+ { id: 7, parent: 6, name: "Build prototype", owner: "Jordan" },
211
+ { id: 8, parent: 6, name: "Review accessibility", owner: "Robin" }
212
+ ];
213
+ const hierarchy = new GridComponent(hierarchyData, [
214
+ { id: "name", name: "Project / task", width: 320, formatter: IndentFormatter },
215
+ { id: "owner", name: "Owner", width: 160 }
216
+ ], { primaryKey: "id", enableColumnReorder: false }, "320px");
217
+ hierarchy.initEvents(grid => { new GridTree(grid, { parentColumn: "parent" }); });
218
+
219
+ interface ProgressRow { id: number; task: string; progress: number | null; }
220
+ const progressRows: ProgressRow[] = Array.from({ length: 8 }, (_, index) => ({
221
+ id: index + 1, task: "Process project " + (index + 1), progress: null
222
+ }));
223
+ const cellComponents = new GridComponent(progressRows, [
224
+ { id: "task", name: "Task", width: 230 },
225
+ { id: "progress", name: "Progress", width: 240, formatter: ComponentFormatter }
226
+ ], { primaryKey: "id", rowHeight: 48 }, "320px");
227
+ cellComponents.initEvents(grid => {
228
+ grid.onAppendCell.subscribe((_event, args) => {
229
+ if (args.column.id !== "progress" || !args.item) return;
230
+ const item = args.item;
231
+ const renderer = new JSLRender(args.dom);
232
+ if (item.progress == null) {
233
+ renderer.render(new ButtonComponent({ content: "Start", type: "button", size: "small", click: () => {
234
+ if (item.progress != null) return;
235
+ const start = performance.now();
236
+ item.progress = 0;
237
+ grid.refreshDataItem(item);
238
+ const tick = () => {
239
+ if (!grid.getContainerNode().isConnected) return;
240
+ item.progress = Math.min(100, Math.floor((performance.now() - start) / 50));
241
+ grid.refreshDataItem(item);
242
+ if (item.progress < 100) window.setTimeout(tick, 100);
243
+ };
244
+ window.setTimeout(tick, 100);
245
+ } }));
246
+ } else {
247
+ renderer.render(new ProgressComponent(item.progress, { showPercent: true, ariaLabel: item.task + " progress" }));
248
+ }
249
+ });
250
+ grid.refresh();
251
+ });
252
+
253
+ interface SelectionRow { id: number; project: string; hours: number; rate: number; cost: number; }
254
+ interface SelectionRange { fromRow: number; toRow: number; fromCell: number; toCell: number; }
255
+ const selectionData: SelectionRow[] = Array.from({ length: 8 }, (_, index) => ({
256
+ id: index + 1, project: "Project " + (index + 1), hours: 10 + index * 5,
257
+ rate: 80 + index * 10, cost: (10 + index * 5) * (80 + index * 10)
258
+ }));
259
+ const selectionGrid = new GridComponent(selectionData, [
260
+ { id: "project", name: "Project", width: 180 },
261
+ { id: "hours", name: "Hours", width: 110, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
262
+ { id: "rate", name: "Rate", width: 110, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
263
+ { id: "cost", name: "Cost", width: 120, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" }
264
+ ], { primaryKey: "id", enableColumnReorder: false }, "320px");
265
+ const selectionSummary: IJSLVNode = { tag: "p", content: "No rows selected.", attr: { class: "sample-status grid-selection-summary", role: "status" } };
266
+ let selectionMode: "row" | "cell" = "row";
267
+ function updateSelectionSummary(grid: IJSLGrid<SelectionRow>, ranges: SelectionRange[]) {
268
+ const cells = new Map<string, { row: SelectionRow; column: ISlickColumn; value: unknown }>();
269
+ for (const range of ranges) {
270
+ for (let row = range.fromRow; row <= range.toRow; row++) {
271
+ for (let cell = range.fromCell; cell <= range.toCell; cell++) {
272
+ const item = grid.getDataItem(row), column = grid.getColumns()[cell];
273
+ if (item && column) cells.set(row + ":" + cell, { row: item, column, value: item[column.field || column.id] });
274
+ }
275
+ }
276
+ }
277
+ if (selectionMode === "row") {
278
+ const rows = Array.from(new Map(Array.from(cells.values(), entry => [entry.row.id, entry.row])).values());
279
+ selectionSummary.content = rows.length ? "Selected rows: " + rows.map(row => row.project).join(", ") + "." : "No rows selected.";
280
+ } else {
281
+ const selected = Array.from(cells.values());
282
+ const values = selected.map(entry => entry.value).filter((value): value is number => typeof value === "number" && Number.isFinite(value));
283
+ const sum = values.reduce((total, value) => total + value, 0);
284
+ selectionSummary.content = selected.length
285
+ ? selected.length + " cells selected - Sum: " + numeric.format(sum, "#,0.00") + " - Avg: " + (values.length ? numeric.format(sum / values.length, "#,0.00") : "—")
286
+ : "No cells selected.";
287
+ }
288
+ JSLRender.lastCreatedRenderer?.refresh();
289
+ }
290
+ function setSelectionMode(grid: IJSLGrid<SelectionRow>, mode: "row" | "cell") {
291
+ grid.getSelectionModel().setSelectedRanges([]);
292
+ grid.resetActiveCell();
293
+ selectionMode = mode;
294
+ const model = mode === "row" ? new RowSelectionModel() : new CellSelectionModel();
295
+ grid.setSelectionModel(model);
296
+ model.onSelectedRangesChanged.subscribe((_event, ranges: SelectionRange[]) => updateSelectionSummary(grid, ranges));
297
+ updateSelectionSummary(grid, []);
298
+ }
299
+ selectionGrid.initEvents(grid => setSelectionMode(grid, selectionMode));
300
+ const frozenData = data(120).map((project, index) => ({
301
+ ...project,
302
+ owner: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"][index % 4],
303
+ status: ["Planning", "In progress", "In review", "Complete"][index % 4],
304
+ due: new Date(2026, 11, 1 + index % 28),
305
+ plannedHours: 80 + index * 4,
306
+ actualHours: 25 + index * 3,
307
+ location: ["Vienna", "London", "Berlin", "New York"][index % 4]
308
+ }));
309
+ const frozenColumns: ISlickColumn[] = [
310
+ ...columns().map(column => ({ ...column, width: column.id === "name" ? 300 : 180 })),
311
+ { id: "owner", name: "Project owner", width: 200, sortable: true },
312
+ { id: "status", name: "Status", width: 180, sortable: true },
313
+ { id: "due", name: "Due date", width: 180, sortable: true, formatter: DateFormatter },
314
+ { id: "plannedHours", name: "Planned hours", width: 180, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
315
+ { id: "actualHours", name: "Actual hours", width: 180, sortable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
316
+ { id: "location", name: "Office", width: 180, sortable: true }
317
+ ];
318
+ const frozen = new GridComponent(frozenData, frozenColumns, {
319
+ primaryKey: "id", frozenColumn: 1
320
+ }, "320px");
321
+ const large = new GridComponent(data(10000), columns(), { primaryKey: "id", rowHeight: 28 }, "320px");
322
+
323
+ const variableHeightData = Array.from({ length: 60 }, (_, index) => {
324
+ const samples = [
325
+ { height: 40, note: "Ready for review." },
326
+ { height: 80, note: "Collect feedback from the project team and agree on the next milestone." },
327
+ { height: 120, note: "Review the research findings with the team. Summarize the open questions and prepare recommendations for the next planning session." }
328
+ ];
329
+ const sample = samples[index % samples.length];
330
+ return { id: index + 1, project: "Project " + (index + 1), note: sample.note, __height: sample.height };
331
+ });
332
+ const variableHeight = new GridComponent(variableHeightData, [
333
+ { id: "id", name: "ID", width: 65 },
334
+ { id: "project", name: "Project", width: 150 },
335
+ { id: "note", name: "Update", width: 350, formatter: MultiLineTextFormatter },
336
+ { id: "__height", name: "Height (px)", width: 110, headerCssClass: "right", formatter: NumericFormatter }
337
+ ], { primaryKey: "id", rowHeight: 40, variableRowHeight: true }, "320px");
338
+ const variableHeightSource = `import "../../ui/base.css";
339
+ import { JSLRender } from "jsl-render";
340
+ import { GridComponent } from "../../components/grid/GridComponent";
341
+ import { MultiLineTextFormatter, NumericFormatter } from "../../grid/slick.formatters";
342
+
343
+ const items = Array.from({ length: 60 }, (_, index) => {
344
+ const samples = [
345
+ { height: 40, note: "Ready for review." },
346
+ { height: 80, note: "Collect feedback from the project team and agree on the next milestone." },
347
+ { height: 120, note: "Review the research findings with the team. Summarize the open questions and prepare recommendations for the next planning session." }
348
+ ];
349
+ const sample = samples[index % samples.length];
350
+ return { id: index + 1, project: "Project " + (index + 1), note: sample.note, __height: sample.height };
351
+ });
352
+
353
+ const grid = new GridComponent(items, [
354
+ { id: "id", name: "ID", width: 65 },
355
+ { id: "project", name: "Project", width: 150 },
356
+ { id: "note", name: "Update", width: 350, formatter: MultiLineTextFormatter },
357
+ { id: "__height", name: "Height (px)", width: 110, headerCssClass: "right", formatter: NumericFormatter }
358
+ ], { primaryKey: "id", rowHeight: 40, variableRowHeight: true }, "320px");
359
+
360
+ // Add <div id="grid"></div> to the page.
361
+ new JSLRender(document.getElementById("grid"), true).render(grid);`;
362
+
363
+ const groupedVariableHeight = new GridComponent(
364
+ data(45).map(project => ({ ...project, __height: 80 })),
365
+ columns(),
366
+ { primaryKey: "id", rowHeight: 40, variableRowHeight: true },
367
+ "320px"
368
+ );
369
+ groupedVariableHeight.initEvents(grid => grid.dataView.setGrouping({
370
+ getter: "team", formatter: group => group.value + " · " + group.count + " projects", aggregators: [], displayTotalsRow: false
371
+ }));
372
+
373
+ const costingData = data(12).map((project, index) => ({
374
+ ...project, hours: 16 + index * 4, rate: 85 + index % 3 * 15, cost: 0
375
+ }));
376
+ const costingColumns: ISlickColumn[] = [
377
+ { id: "id", name: "ID", width: 65, columnGroup: "Project" },
378
+ { id: "name", name: "Project", width: 240, columnGroup: "Project", editor: TextEditor },
379
+ { id: "team", name: "Team", width: 140, columnGroup: "Project" },
380
+ { id: "hours", name: "Hours", width: 120, columnGroup: "Costing", headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", editor: NumericEditor },
381
+ { id: "rate", name: "Hourly rate", width: 135, columnGroup: "Costing", headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", editor: NumericEditor },
382
+ { id: "cost", name: "Estimated cost", width: 160, columnGroup: "Costing", headerCssClass: "right", formatter: NumericFormatter, format: "#,0.00", readonly: true, toolTip: "Calculated: hours × hourly rate" },
383
+ { id: "date", name: "Start date", width: 140, columnGroup: "Schedule", formatter: DateFormatter }
384
+ ];
385
+ const costing = new GridComponent(costingData, costingColumns, {
386
+ primaryKey: "id", editable: true, autoEdit: false, showColumnGroups: true,
387
+ preHeaderPanelHeight: 37, createFooterRow: true, showFooterRow: true, footerRowHeight: 36,
388
+ enableColumnReorder: false
389
+ }, "380px");
390
+ costing.initEvents(grid => {
391
+ grid.addFormula("cost", item => (item.hours || 0) * (item.rate || 0), ["hours", "rate"]);
392
+ grid.triggerAllFormulas();
393
+ const updateTotals = () => {
394
+ const label = grid.getFooterRowColumn("name");
395
+ if (label) { label.textContent = "Total"; }
396
+ for (const field of ["hours", "cost"] as const) {
397
+ const footer = grid.getFooterRowColumn(field);
398
+ if (footer) {
399
+ footer.classList.add("right", "tabular-nums");
400
+ footer.textContent = numeric.format(grid.getData().reduce((sum, item) => sum + item[field], 0), "#,0.00");
401
+ }
402
+ }
403
+ };
404
+ grid.onAfterEdit.subscribe(updateTotals);
405
+ grid.onFooterRowCellRendered.subscribe(updateTotals);
406
+ updateTotals();
407
+ });
408
+
409
+ const orderStatus: IJSLVNode = { tag: "p", content: "Drag a handle to change the project order.", attr: { role: "status", class: "sample-status" } };
410
+ const reorder = new GridComponent(data(15), [
411
+ { id: "_move", name: "", width: 36, minWidth: 36, maxWidth: 36, resizable: false, selectable: false,
412
+ behavior: "selectAndMove", cssClass: "grid-row-handle", toolTip: "Drag to reorder", formatter: () => '<span aria-hidden="true">⠿</span>' },
413
+ { id: "priority", name: "Order", width: 75, headerCssClass: "center", formatter: row => ({ text: String(row + 1), addClasses: ["center", "tabular-nums"] }) },
414
+ ...columns().filter(column => column.id !== "id").map(column => ({ ...column, sortable: false }))
415
+ ], { primaryKey: "id", allowRowMove: true, enableColumnReorder: false }, "320px");
416
+ reorder.initEvents(grid => grid.dataView.onRowsChanged.subscribe(() => {
417
+ orderStatus.content = "Project order: " + grid.getData().map(item => item.id).join(", ") + ".";
418
+ JSLRender.lastCreatedRenderer?.refresh();
419
+ }));
420
+ export const gridShowcase: IJSLVNode = {
421
+ tag: "section", attr: { id: "grids", class: "component-section", "aria-labelledby": "grids-title" }, children: [
422
+ { tag: "div", attr: { class: "hero-copy" }, children: [
423
+ { tag: "p", content: "THE ESSENTIALS / 22", attr: { class: "eyebrow" } },
424
+ { tag: "h2", content: "Grids", attr: { id: "grids-title", class: "section-title" } },
425
+ text("p", "Representative data, formatting, editing, grouping, and scrolling examples for the grid redesign.")
426
+ ] },
427
+ { tag: "div", attr: { class: "grid-samples" }, children: [
428
+ category("grid-browsing", "Browsing & layout", [
429
+ card("grid-basic", "Browse, sort & filter", "100 projects across 10 teams. Open a column header menu and choose Filter to select values. Click a heading to sort, then Shift-click other headings to add sort levels. Numbers show sorting priority. Select rows and resize or reorder columns.", basic),
430
+ card("grid-filter-row", "Filter row", "Type in one or more fields to filter project, team, budget, or formatted start date. Active fields combine, so each matching row must satisfy every entered filter.", filterRow),
431
+ card("grid-header-menu-icons", "Column menus & header icons", "Open a column menu to sort or filter. Click the star in the Project heading to toggle it, or the Team information icon to show a message.", headerActions),
432
+ card("grid-frozen", "Frozen columns", "12 columns and 120 projects. The ID and project stay visible while you scroll through ownership, status, dates, hours, and office details, even on wide screens.", frozen),
433
+ card("grid-large", "A larger dataset", "10,000 rows with an explicit rowHeight of 28 px. This example also checks that applications can retain the original density.", large),
434
+ card("grid-reorder", "Arrange project priorities", "Drag a handle in the first column to move a project. The Order column follows its position while project IDs remain unchanged. Sorting is disabled here so it does not override the manual order.", reorder, [orderStatus])
435
+ ]),
436
+ category("grid-editing", "Editing", [
437
+ card("grid-editable", "Edit in place", "Double-click an editable cell. Enter commits and Escape cancels. Editors retain their existing behavior and styling in this step.", editable, [edits]),
438
+ card("grid-editors-formatters", "Formatters and editors", "Try text, multiline, numeric, date, time, boolean, lookup, multi-lookup, and autosuggest editors. The adjacent columns demonstrate the matching display formatters; TimeFormatter displays a Date value, while TimeEditor edits a time string.", editorCatalog, [editorCatalogStatus])
439
+ ]),
440
+ category("grid-grouping", "Grouping & header groups", [
441
+ card("grid-grouped", "Grouped projects & totals", "45 projects grouped by team, with a budget total for each group. Expand and collapse groups independently; totals remain visible when a group is collapsed.", grouped, [
442
+ { tag: "div", attr: { class: "sample-row" }, children: [
443
+ action("Collapse groups", () => { grouped.getRef().then(grid => grid.dataView.collapseAllGroups()); }),
444
+ action("Expand groups", () => { grouped.getRef().then(grid => grid.dataView.expandAllGroups()); })
445
+ ] }
446
+ ]),
447
+ card("grid-costing", "Column groups, formulas & totals", "Project, Costing, and Schedule headers group related columns. Double-click Hours or Hourly rate to edit: the grid formula recalculates Estimated cost, and the footer updates the totals.", costing, [
448
+ { tag: "pre", content: 'grid.addFormula("cost", item => item.hours * item.rate, ["hours", "rate"]);', attr: { class: "sample-code" } }
449
+ ]),
450
+ card("grid-hierarchy", "Hierarchical projects & tasks", "Expand or collapse projects and their nested tasks. The grid uses parent IDs and an indented formatter to show the hierarchy.", hierarchy)
451
+ ]),
452
+ category("grid-interaction", "Selection & cell components", [
453
+ card("grid-cell-components", "Components inside cells", "Click Start to replace the button with a progress bar. Each task progresses independently from 0 to 100% over five seconds.", cellComponents),
454
+ card("grid-selection", "Row and cell selection", "Choose a mode, then select rows or drag across cells. Use Ctrl or Command to add selections and Shift to extend them. Cell totals include numeric values only.", selectionGrid, [
455
+ { tag: "label", attr: { class: "grid-selection-mode", for: "grid-selection-mode" }, children: [
456
+ text("span", "Selection mode"),
457
+ { tag: "select", attr: { id: "grid-selection-mode", change: (event: Event) => {
458
+ const mode = (event.target as HTMLSelectElement).value as "row" | "cell";
459
+ selectionGrid.getRef().then(grid => setSelectionMode(grid, mode));
460
+ } }, children: [
461
+ { tag: "option", attr: { value: "row" }, content: "Rows" },
462
+ { tag: "option", attr: { value: "cell" }, content: "Cells" }
463
+ ] }
464
+ ] }
465
+ ], undefined, [selectionSummary])
466
+ ]),
467
+ category("grid-variable-rows", "Variable row height", [
468
+ card("grid-variable-height", "Variable row heights", "Scroll through 60 projects with 40, 80, and 120 px rows. Each item's __height controls its height; the Update column wraps its text. Row heights are explicit and do not automatically adjust when a column is resized.", variableHeight, [], variableHeightSource),
469
+ card("grid-grouped-variable-height", "Grouped rows keep their default height", "Projects are grouped by team. Group headers use the default 40 px row height, while each project row is 80 px. Expand and collapse groups to see the heights remain in place.", groupedVariableHeight, [
470
+ { tag: "div", attr: { class: "sample-row" }, children: [
471
+ action("Collapse groups", () => { groupedVariableHeight.getRef().then(grid => grid.dataView.collapseAllGroups()); }),
472
+ action("Expand groups", () => { groupedVariableHeight.getRef().then(grid => grid.dataView.expandAllGroups()); })
473
+ ] },
474
+ { tag: "pre", content: 'const items = projects.map(project => ({ ...project, __height: 80 }));\nnew GridComponent(items, columns, {\n primaryKey: "id", rowHeight: 40, variableRowHeight: true\n});', attr: { class: "sample-code" } }
475
+ ])
476
+ ])
477
+ ] },
478
+ { tag: "details", attr: { class: "usage" }, children: [
479
+ text("summary", "Grid showcase scope"),
480
+ text("p", 'NumericFormatter supplies right-aligned cells; NumericFormatter and DateFormatter apply tabular numerals. Set headerCssClass: "right" or "center" explicitly to match a column’s content. Header alignment is never inferred from its formatter.'),
481
+ text("p", "These examples use the existing GridComponent constructor, column definitions, editors, and DataView APIs. The default row height is 40 px; rowHeight can retain a different density. Column headers fit up to two lines. Core presentation follows the shared theme and inherits the host's typography. Browse, sort & filter demonstrates the Excel filter from a column header menu; Filter row demonstrates custom inputs on the grid header row.")
482
+ ] }
483
+ ]
484
+ };