jsl-ui 10.1.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/docs/DataBinding.md +19 -0
  2. package/docs/DateTimeComponent.md +1 -0
  3. package/docs/GridComponent.md +8 -5
  4. package/docs/InputComponent.md +1 -1
  5. package/docs/README.md +1 -0
  6. package/examples/showcase/checks-and-expanders.ts +2 -17
  7. package/examples/showcase/data-binding.ts +138 -0
  8. package/examples/showcase/dates.ts +6 -16
  9. package/examples/showcase/fields.ts +14 -26
  10. package/examples/showcase/generate-sources.cjs +104 -0
  11. package/examples/showcase/grids.ts +246 -17
  12. package/examples/showcase/index.html +12 -2
  13. package/examples/showcase/selects.ts +6 -8
  14. package/examples/showcase/showcase-sources.ts +95 -0
  15. package/examples/showcase/showcase.css +23 -2
  16. package/examples/showcase/showcase.ts +28 -5
  17. package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +4 -4
  18. package/lib/components/auto-suggest/AutoSuggestComponent.js +1 -1
  19. package/lib/components/checkbox/CheckBoxComponent.d.ts +2 -3
  20. package/lib/components/checkbox/CheckBoxComponent.js +7 -20
  21. package/lib/components/date/DateComponent.d.ts +4 -4
  22. package/lib/components/date/DateComponent.js +11 -27
  23. package/lib/components/date-time/DateTimeComponent.d.ts +4 -4
  24. package/lib/components/date-time/DateTimeComponent.js +21 -32
  25. package/lib/components/input/InputComponent.d.ts +1 -4
  26. package/lib/components/input/InputComponent.js +14 -32
  27. package/lib/components/number/NumberComponent.d.ts +1 -4
  28. package/lib/components/number/NumberComponent.js +11 -29
  29. package/lib/components/select/SelectComponent.d.ts +1 -3
  30. package/lib/components/select/SelectComponent.js +8 -22
  31. package/lib/components/time/TimeComponent.d.ts +4 -3
  32. package/lib/components/time/TimeComponent.js +11 -24
  33. package/lib/grid/filterDialogs/excelFilter.js +12 -10
  34. package/lib/grid/plugins/slick.headermenu.css +98 -101
  35. package/lib/grid/slick-default-theme.css +10 -2
  36. package/lib/grid/slick.grid.css +112 -1
  37. package/lib/grid.css +852 -3392
  38. package/lib/index.css +260 -124
  39. package/lib/index.css.map +1 -1
  40. package/lib/index.js.map +1 -1
  41. package/lib/interaction/data-binding.d.ts +27 -0
  42. package/lib/interaction/data-binding.js +72 -0
  43. package/package.json +3 -1
@@ -1,15 +1,21 @@
1
1
  import { IJSLVNode, JSLRender } from "jsl-render";
2
2
  import { GridComponent } from "../../components/grid/GridComponent";
3
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";
4
9
  import { TextEditor, MultiLineTextEditor, NumericEditor, BooleanEditor } from "../../grid/slick.editors.core";
5
10
  import { DateEditor, TimeEditor } from "../../grid/slick.editors.date";
6
11
  import { AutoSuggestEditor, LookupEditor, MultiLookupEditor } from "../../grid/slick.editors.lookup";
7
12
  import {
8
13
  CheckboxFormatter, DateFormatter, DateTimeFormatter, LookupFormatter,
9
14
  MultiLineTextFormatter, MultiLookupFormatter, NumericFormatter, TextFormatter, TimeFormatter,
10
- TooltipFormatter, YesNoFormatter
15
+ TooltipFormatter, YesNoFormatter, ComponentFormatter
11
16
  } from "../../grid/slick.formatters";
12
17
  import { ButtonComponent } from "../../components/button/ButtonComponent";
18
+ import { ProgressComponent } from "../../components/progress/ProgressComponent";
13
19
  import { numeric } from "../../core/numeric";
14
20
 
15
21
  interface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }
@@ -33,15 +39,53 @@ function columns(editable = false): ISlickColumn[] {
33
39
  }
34
40
  const text = (tag: string, content: string): IJSLVNode => ({ tag, content });
35
41
  const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
36
- function card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = []): IJSLVNode {
42
+ function card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {
37
43
  return { tag: "article", attr: { id, class: "sample-card grid-sample-card" }, children: [
38
44
  text("h3", title), { tag: "p", content: description, attr: { class: "card-description" } },
39
- ...extras, { tag: "div", attr: { class: "grid-sample-host" }, children: [grid] }
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
+ ] }] : [])
40
50
  ] };
41
51
  }
42
- const basic = new GridComponent(data(30), columns(), {
43
- primaryKey: "id", multiColumnSort: true, numberedMultiColumnSort: true
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
44
62
  }, "300px");
63
+ let projectStarred = false;
64
+ const projectHeaderButton = {
65
+ html: "☆", tooltip: "Star project column", cssClass: "grid-header-action",
66
+ handler: (event: MouseEvent) => {
67
+ projectStarred = !projectStarred;
68
+ projectHeaderButton.html = projectStarred ? "★" : "☆";
69
+ projectHeaderButton.tooltip = projectStarred ? "Unstar project column" : "Star project column";
70
+ projectHeaderButton.cssClass = "grid-header-action" + (projectStarred ? " grid-header-starred" : "");
71
+ const button = event.currentTarget as HTMLElement;
72
+ button.textContent = projectHeaderButton.html;
73
+ button.title = projectHeaderButton.tooltip;
74
+ button.classList.toggle("grid-header-starred", projectStarred);
75
+ }
76
+ };
77
+ const headerActions = new GridComponent(data(12), [
78
+ { id: "id", name: "ID", width: 65, sortable: true, filterable: true },
79
+ { id: "name", name: "Project", width: 245, sortable: true, filterable: true, header: { buttons: [
80
+ projectHeaderButton
81
+ ] } },
82
+ { id: "team", name: "Team", width: 145, sortable: true, filterable: true, header: { buttons: [
83
+ { html: "i", tooltip: "About team column", cssClass: "grid-header-action", handler: () => {
84
+ window.alert("The Team column shows the team responsible for each project.");
85
+ } }
86
+ ] } },
87
+ { id: "budget", name: "Budget", width: 125, sortable: true, filterable: true, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" }
88
+ ], { primaryKey: "id", showHeaderMenu: true }, "300px");
45
89
  const edits: IJSLVNode = { tag: "p", content: "Edit a project, budget, date, or approval value.", attr: { role: "status", class: "sample-status" } };
46
90
  const editable = new GridComponent(data(25), columns(true), { primaryKey: "id", editable: true, autoEdit: false }, "300px");
47
91
  editable.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {
@@ -109,10 +153,112 @@ editorCatalog.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {
109
153
  editorCatalogStatus.content = "Updated " + args.column.name + " for sample " + args.item.id + ".";
110
154
  JSLRender.lastCreatedRenderer?.refresh();
111
155
  }));
112
- const grouped = new GridComponent(data(45), columns(), { primaryKey: "id" }, "320px");
156
+ const grouped = new GridComponent(data(45), columns().map(column => column.id === "budget" ? {
157
+ ...column, groupTotalsFormatter: totals => ({ text: numeric.format(totals.sum.budget, "#,0"), addClasses: ["right", "tabular-nums"] })
158
+ } : column.id === "name" ? { ...column, groupTotalsFormatter: () => "Team total" } : column), { primaryKey: "id" }, "320px");
113
159
  grouped.initEvents(grid => grid.dataView.setGrouping({
114
- getter: "team", formatter: group => group.value + " · " + group.count + " projects", aggregators: [], displayTotalsRow: false
160
+ getter: "team", formatter: group => group.value + " · " + group.count + " projects",
161
+ aggregators: [new SumAggregator("budget")], displayTotalsRow: true, aggregateCollapsed: true
162
+ }));
163
+
164
+ interface HierarchyItem { id: number; parent?: number; name: string; owner: string; }
165
+ const hierarchyData: HierarchyItem[] = [
166
+ { id: 1, name: "Website refresh", owner: "Design" },
167
+ { id: 2, parent: 1, name: "Research", owner: "Research" },
168
+ { id: 3, parent: 2, name: "Interview customers", owner: "Sam" },
169
+ { id: 4, parent: 2, name: "Summarize findings", owner: "Alex" },
170
+ { id: 5, parent: 1, name: "Design new pages", owner: "Design" },
171
+ { id: 6, name: "Mobile workspace", owner: "Engineering" },
172
+ { id: 7, parent: 6, name: "Build prototype", owner: "Jordan" },
173
+ { id: 8, parent: 6, name: "Review accessibility", owner: "Robin" }
174
+ ];
175
+ const hierarchy = new GridComponent(hierarchyData, [
176
+ { id: "name", name: "Project / task", width: 320, formatter: IndentFormatter },
177
+ { id: "owner", name: "Owner", width: 160 }
178
+ ], { primaryKey: "id", enableColumnReorder: false }, "320px");
179
+ hierarchy.initEvents(grid => { new GridTree(grid, { parentColumn: "parent" }); });
180
+
181
+ interface ProgressRow { id: number; task: string; progress: number | null; }
182
+ const progressRows: ProgressRow[] = Array.from({ length: 8 }, (_, index) => ({
183
+ id: index + 1, task: "Process project " + (index + 1), progress: null
115
184
  }));
185
+ const cellComponents = new GridComponent(progressRows, [
186
+ { id: "task", name: "Task", width: 230 },
187
+ { id: "progress", name: "Progress", width: 240, formatter: ComponentFormatter }
188
+ ], { primaryKey: "id", rowHeight: 48 }, "320px");
189
+ cellComponents.initEvents(grid => {
190
+ grid.onAppendCell.subscribe((_event, args) => {
191
+ if (args.column.id !== "progress" || !args.item) return;
192
+ const item = args.item;
193
+ const renderer = new JSLRender(args.dom);
194
+ if (item.progress == null) {
195
+ renderer.render(new ButtonComponent({ content: "Start", type: "button", size: "small", click: () => {
196
+ if (item.progress != null) return;
197
+ const start = performance.now();
198
+ item.progress = 0;
199
+ grid.refreshDataItem(item);
200
+ const tick = () => {
201
+ if (!grid.getContainerNode().isConnected) return;
202
+ item.progress = Math.min(100, Math.floor((performance.now() - start) / 50));
203
+ grid.refreshDataItem(item);
204
+ if (item.progress < 100) window.setTimeout(tick, 100);
205
+ };
206
+ window.setTimeout(tick, 100);
207
+ } }));
208
+ } else {
209
+ renderer.render(new ProgressComponent(item.progress, { showPercent: true, ariaLabel: item.task + " progress" }));
210
+ }
211
+ });
212
+ grid.refresh();
213
+ });
214
+
215
+ interface SelectionRow { id: number; project: string; hours: number; rate: number; cost: number; }
216
+ interface SelectionRange { fromRow: number; toRow: number; fromCell: number; toCell: number; }
217
+ const selectionData: SelectionRow[] = Array.from({ length: 8 }, (_, index) => ({
218
+ id: index + 1, project: "Project " + (index + 1), hours: 10 + index * 5,
219
+ rate: 80 + index * 10, cost: (10 + index * 5) * (80 + index * 10)
220
+ }));
221
+ const selectionGrid = new GridComponent(selectionData, [
222
+ { id: "project", name: "Project", width: 180 },
223
+ { id: "hours", name: "Hours", width: 110, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
224
+ { id: "rate", name: "Rate", width: 110, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" },
225
+ { id: "cost", name: "Cost", width: 120, headerCssClass: "right", formatter: NumericFormatter, format: "#,0" }
226
+ ], { primaryKey: "id", enableColumnReorder: false }, "320px");
227
+ const selectionSummary: IJSLVNode = { tag: "p", content: "No rows selected.", attr: { class: "sample-status grid-selection-summary", role: "status" } };
228
+ let selectionMode: "row" | "cell" = "row";
229
+ function updateSelectionSummary(grid: IJSLGrid<SelectionRow>, ranges: SelectionRange[]) {
230
+ const cells = new Map<string, { row: SelectionRow; column: ISlickColumn; value: unknown }>();
231
+ for (const range of ranges) {
232
+ for (let row = range.fromRow; row <= range.toRow; row++) {
233
+ for (let cell = range.fromCell; cell <= range.toCell; cell++) {
234
+ const item = grid.getDataItem(row), column = grid.getColumns()[cell];
235
+ if (item && column) cells.set(row + ":" + cell, { row: item, column, value: item[column.field || column.id] });
236
+ }
237
+ }
238
+ }
239
+ if (selectionMode === "row") {
240
+ const rows = Array.from(new Map(Array.from(cells.values(), entry => [entry.row.id, entry.row])).values());
241
+ selectionSummary.content = rows.length ? "Selected rows: " + rows.map(row => row.project).join(", ") + "." : "No rows selected.";
242
+ } else {
243
+ const selected = Array.from(cells.values());
244
+ const values = selected.map(entry => entry.value).filter((value): value is number => typeof value === "number" && Number.isFinite(value));
245
+ const sum = values.reduce((total, value) => total + value, 0);
246
+ selectionSummary.content = selected.length
247
+ ? selected.length + " cells selected - Sum: " + numeric.format(sum, "#,0.00") + " - Avg: " + (values.length ? numeric.format(sum / values.length, "#,0.00") : "—")
248
+ : "No cells selected.";
249
+ }
250
+ JSLRender.lastCreatedRenderer?.refresh();
251
+ }
252
+ function setSelectionMode(grid: IJSLGrid<SelectionRow>, mode: "row" | "cell") {
253
+ grid.getSelectionModel().setSelectedRanges([]);
254
+ grid.resetActiveCell();
255
+ selectionMode = mode;
256
+ const model = mode === "row" ? new RowSelectionModel() : new CellSelectionModel();
257
+ grid.setSelectionModel(model);
258
+ model.onSelectedRangesChanged.subscribe((_event, ranges: SelectionRange[]) => updateSelectionSummary(grid, ranges));
259
+ updateSelectionSummary(grid, []);
260
+ }
261
+ selectionGrid.initEvents(grid => setSelectionMode(grid, selectionMode));
116
262
  const frozenData = data(120).map((project, index) => ({
117
263
  ...project,
118
264
  owner: ["Alex Morgan", "Sam Weber", "Jordan Lee", "Robin Taylor"][index % 4],
@@ -136,6 +282,56 @@ const frozen = new GridComponent(frozenData, frozenColumns, {
136
282
  }, "320px");
137
283
  const large = new GridComponent(data(10000), columns(), { primaryKey: "id", rowHeight: 28 }, "320px");
138
284
 
285
+ const variableHeightData = Array.from({ length: 60 }, (_, index) => {
286
+ const samples = [
287
+ { height: 40, note: "Ready for review." },
288
+ { height: 80, note: "Collect feedback from the project team and agree on the next milestone." },
289
+ { height: 120, note: "Review the research findings with the team. Summarize the open questions and prepare recommendations for the next planning session." }
290
+ ];
291
+ const sample = samples[index % samples.length];
292
+ return { id: index + 1, project: "Project " + (index + 1), note: sample.note, __height: sample.height };
293
+ });
294
+ const variableHeight = new GridComponent(variableHeightData, [
295
+ { id: "id", name: "ID", width: 65 },
296
+ { id: "project", name: "Project", width: 150 },
297
+ { id: "note", name: "Update", width: 350, formatter: MultiLineTextFormatter },
298
+ { id: "__height", name: "Height (px)", width: 110, headerCssClass: "right", formatter: NumericFormatter }
299
+ ], { primaryKey: "id", rowHeight: 40, variableRowHeight: true }, "320px");
300
+ const variableHeightSource = `import "../../ui/base.css";
301
+ import { JSLRender } from "jsl-render";
302
+ import { GridComponent } from "../../components/grid/GridComponent";
303
+ import { MultiLineTextFormatter, NumericFormatter } from "../../grid/slick.formatters";
304
+
305
+ const items = Array.from({ length: 60 }, (_, index) => {
306
+ const samples = [
307
+ { height: 40, note: "Ready for review." },
308
+ { height: 80, note: "Collect feedback from the project team and agree on the next milestone." },
309
+ { height: 120, note: "Review the research findings with the team. Summarize the open questions and prepare recommendations for the next planning session." }
310
+ ];
311
+ const sample = samples[index % samples.length];
312
+ return { id: index + 1, project: "Project " + (index + 1), note: sample.note, __height: sample.height };
313
+ });
314
+
315
+ const grid = new GridComponent(items, [
316
+ { id: "id", name: "ID", width: 65 },
317
+ { id: "project", name: "Project", width: 150 },
318
+ { id: "note", name: "Update", width: 350, formatter: MultiLineTextFormatter },
319
+ { id: "__height", name: "Height (px)", width: 110, headerCssClass: "right", formatter: NumericFormatter }
320
+ ], { primaryKey: "id", rowHeight: 40, variableRowHeight: true }, "320px");
321
+
322
+ // Add <div id="grid"></div> to the page.
323
+ new JSLRender(document.getElementById("grid"), true).render(grid);`;
324
+
325
+ const groupedVariableHeight = new GridComponent(
326
+ data(45).map(project => ({ ...project, __height: 80 })),
327
+ columns(),
328
+ { primaryKey: "id", rowHeight: 40, variableRowHeight: true },
329
+ "320px"
330
+ );
331
+ groupedVariableHeight.initEvents(grid => grid.dataView.setGrouping({
332
+ getter: "team", formatter: group => group.value + " · " + group.count + " projects", aggregators: [], displayTotalsRow: false
333
+ }));
334
+
139
335
  const costingData = data(12).map((project, index) => ({
140
336
  ...project, hours: 16 + index * 4, rate: 85 + index % 3 * 15, cost: 0
141
337
  }));
@@ -191,26 +387,59 @@ export const gridShowcase: IJSLVNode = {
191
387
  text("p", "Representative data, formatting, editing, grouping, and scrolling examples for the grid redesign.")
192
388
  ] },
193
389
  { tag: "div", attr: { class: "grid-samples" }, children: [
194
- card("grid-basic", "Browse and sort", "30 projects. 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),
195
- 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]),
196
- 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]),
197
- card("grid-grouped", "Grouped projects", "45 projects grouped by team. Expand and collapse groups independently.", grouped, [
390
+ category("grid-browsing", "Browsing & layout", [
391
+ 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),
392
+ 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),
393
+ 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),
394
+ 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),
395
+ 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])
396
+ ]),
397
+ category("grid-editing", "Editing", [
398
+ 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]),
399
+ 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])
400
+ ]),
401
+ category("grid-grouping", "Grouping & header groups", [
402
+ 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, [
198
403
  { tag: "div", attr: { class: "sample-row" }, children: [
199
404
  action("Collapse groups", () => { grouped.getRef().then(grid => grid.dataView.collapseAllGroups()); }),
200
405
  action("Expand groups", () => { grouped.getRef().then(grid => grid.dataView.expandAllGroups()); })
201
406
  ] }
407
+ ]),
408
+ 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, [
409
+ { tag: "pre", content: 'grid.addFormula("cost", item => item.hours * item.rate, ["hours", "rate"]);', attr: { class: "sample-code" } }
410
+ ]),
411
+ 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)
202
412
  ]),
203
- 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),
204
- 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),
205
- 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, [
206
- { tag: "pre", content: 'grid.addFormula("cost", item => item.hours * item.rate, ["hours", "rate"]);', attr: { class: "sample-code" } }
413
+ category("grid-interaction", "Selection & cell components", [
414
+ 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),
415
+ 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, [
416
+ { tag: "label", attr: { class: "grid-selection-mode", for: "grid-selection-mode" }, children: [
417
+ text("span", "Selection mode"),
418
+ { tag: "select", attr: { id: "grid-selection-mode", change: (event: Event) => {
419
+ const mode = (event.target as HTMLSelectElement).value as "row" | "cell";
420
+ selectionGrid.getRef().then(grid => setSelectionMode(grid, mode));
421
+ } }, children: [
422
+ { tag: "option", attr: { value: "row" }, content: "Rows" },
423
+ { tag: "option", attr: { value: "cell" }, content: "Cells" }
424
+ ] }
425
+ ] }
426
+ ], undefined, [selectionSummary])
207
427
  ]),
208
- 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])
428
+ category("grid-variable-rows", "Variable row height", [
429
+ 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),
430
+ 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, [
431
+ { tag: "div", attr: { class: "sample-row" }, children: [
432
+ action("Collapse groups", () => { groupedVariableHeight.getRef().then(grid => grid.dataView.collapseAllGroups()); }),
433
+ action("Expand groups", () => { groupedVariableHeight.getRef().then(grid => grid.dataView.expandAllGroups()); })
434
+ ] },
435
+ { 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" } }
436
+ ])
437
+ ])
209
438
  ] },
210
439
  { tag: "details", attr: { class: "usage" }, children: [
211
440
  text("summary", "Grid showcase scope"),
212
441
  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.'),
213
- 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. Filter dialogs, menus, and lifecycle behavior are reserved for later steps.")
442
+ 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. The Browse, sort & filter example demonstrates the Excel filter from a column header menu.")
214
443
  ] }
215
444
  ]
216
445
  };
@@ -11,7 +11,7 @@
11
11
  <a class="skip-link" href="#main">Skip to components</a>
12
12
  <aside class="sidebar" aria-label="Component navigation">
13
13
  <a class="brand" href="#main"><span class="brand-mark">j.</span><span>JSL UI<span class="brand-caption">Component showcase</span></span></a>
14
- <p class="nav-label">COMPONENTS <span>23</span></p>
14
+ <p class="nav-label">COMPONENTS <span>24</span></p>
15
15
  <nav>
16
16
  <a class="nav-item" href="#buttons" aria-current="location"><span class="nav-icon" aria-hidden="true">▣</span> Buttons <span class="nav-number">01</span></a>
17
17
  <a class="nav-item" href="#dialogs"><span class="nav-icon" aria-hidden="true">▢</span> Dialogs <span class="nav-number">02</span></a>
@@ -34,8 +34,18 @@
34
34
  <a class="nav-item" href="#trees"><span class="nav-icon" aria-hidden="true">&#8627;</span> Tree views <span class="nav-number">19</span></a>
35
35
  <a class="nav-item" href="#overlays"><span class="nav-icon" aria-hidden="true">&#9703;</span> Overlays <span class="nav-number">20</span></a>
36
36
  <a class="nav-item" href="#ribbons"><span class="nav-icon" aria-hidden="true">&#9637;</span> Ribbon menus <span class="nav-number">21</span></a>
37
- <a class="nav-item" href="#grids"><span class="nav-icon" aria-hidden="true">&#9638;</span> Grids <span class="nav-number">22</span></a>
37
+ <div class="nav-group">
38
+ <a class="nav-item" href="#grids"><span class="nav-icon" aria-hidden="true">&#9638;</span> Grids <span class="nav-number">22</span></a>
39
+ <div class="nav-submenu" aria-label="Grid showcase categories">
40
+ <a class="nav-subitem" href="#grid-browsing">Browsing &amp; layout</a>
41
+ <a class="nav-subitem" href="#grid-editing">Editing</a>
42
+ <a class="nav-subitem" href="#grid-grouping">Grouping &amp; header groups</a>
43
+ <a class="nav-subitem" href="#grid-interaction">Selection &amp; cell components</a>
44
+ <a class="nav-subitem" href="#grid-variable-rows">Variable row height</a>
45
+ </div>
46
+ </div>
38
47
  <a class="nav-item" href="#dropdown-menus"><span class="nav-icon" aria-hidden="true">&#8942;</span> Dropdown menus <span class="nav-number">23</span></a>
48
+ <a class="nav-item" href="#data-binding"><span class="nav-icon" aria-hidden="true">&#8644;</span> Data binding <span class="nav-number">24</span></a>
39
49
  </nav>
40
50
  <div class="sidebar-note"><span class="status-dot"></span> A growing collection<p>Redesigned components will be added here as the library evolves.</p></div>
41
51
  </aside>
@@ -48,17 +48,16 @@ const people = [
48
48
  { value: "sam", text: "Sam Rivera", initials: "SR", role: "Accessibility specialist" },
49
49
  { value: "jules", text: "Jules Martin", initials: "JM", role: "Product manager" }
50
50
  ];
51
- const memberModel = { owner: "maya" };
52
- const memberStatus = status("Model value: maya");
51
+ const memberStatus = status("Selected Maya Chen.");
53
52
  const member = new SelectComponent({
54
- id: "select-owner", data: people, bindTo: memberModel, property: "owner", bindMode: "both",
53
+ id: "select-owner", data: people, value: "maya",
55
54
  ariaLabel: "Project owner", placeholder: "Assign an owner", rowHeight: 56,
56
55
  matchSearch: (item, term) => (item.text + " " + item.role).toLowerCase().includes(term.toLowerCase()),
57
56
  onRender: args => args.isCurrent ? text("span", args.data.text) : group([
58
57
  { tag: "span", content: args.data.initials, attr: { class: "select-person-avatar", "aria-hidden": "true" } },
59
58
  group([text("strong", args.data.text), text("span", args.data.role)], "select-person-copy")
60
59
  ], "select-person"),
61
- onChange: () => { memberStatus.content = "Model value: " + (memberModel.owner ?? "empty"); }
60
+ onChange: (_value, item) => { memberStatus.content = item ? "Selected " + item.text + "." : "No owner selected."; }
62
61
  });
63
62
  const largeStatus = status("Search by name or jump through the list with your keyboard.");
64
63
  const large = new SelectComponent({
@@ -124,9 +123,8 @@ export const selectShowcase: IJSLVNode = {
124
123
  });
125
124
  })
126
125
  ]),
127
- card("select-custom", "04", "More than a label", "Custom rows add useful details. This field also reads and writes a bound model.", [
126
+ card("select-custom", "04", "More than a label", "Custom rows add useful details about each person.", [
128
127
  field("select-owner", "Project owner", member), memberStatus,
129
- action("Assign Alex from the model", () => { memberModel.owner = "alex"; memberStatus.content = "Model value: alex"; }),
130
128
  text("p", "Search also matches each person's role.", "inline-note")
131
129
  ]),
132
130
  card("select-states", "05", "The right level of choice", "Search can be omitted for short lists. Required selections and disabled controls share the same design.", [
@@ -149,8 +147,8 @@ export const selectShowcase: IJSLVNode = {
149
147
  { tag: "details", attr: { class: "usage" }, children: [
150
148
  text("summary", "Select usage & compatibility"),
151
149
  text("pre", 'new SelectComponent({\n data: [{ value: "design", text: "Design" }, { value: "code", text: "Code" }],\n multiple: true,\n value: ["design"],\n placeholder: "Choose skills",\n ariaLabel: "Skills",\n onChange: (keys, items) => console.log(keys, items)\n});', "sample-code"),
152
- text("p", "Existing data, keyColumn, textColumn, grouping, render callbacks, converters, binding modes, popup sizing, and onAppend options remain available. The original placehoder spelling remains supported; placeholder takes precedence. Optional id, ariaLabel, ariaLabelledBy, searchPlaceholder, emptyText, and clearButtonLabel help label and translate the control."),
153
- text("p", "getValue() returns a key or an array of keys. getSelected() returns the corresponding item or items. setValue() updates the selection and writable model silently; setSelected() also raises onChange. toggle(), show(), close(), focus(), isExpanded(), and destroy() are retained. Unmounting cleans up the owning popup."),
150
+ text("p", "Existing data, keyColumn, textColumn, grouping, render callbacks, converters, popup sizing, and onAppend options remain available. The original placehoder spelling remains supported; placeholder takes precedence. Optional id, ariaLabel, ariaLabelledBy, searchPlaceholder, emptyText, and clearButtonLabel help label and translate the control."),
151
+ text("p", "getValue() returns a key or an array of keys. getSelected() returns the corresponding item or items. setValue() updates the selection silently; setSelected() also raises onChange. toggle(), show(), close(), focus(), isExpanded(), and destroy() are retained. Unmounting cleans up the owning popup."),
154
152
  text("p", "Arrow Down, Arrow Up, Enter, and Space open the list. Type to search, use arrow keys to navigate, and Enter to select. Multi-select stays open as options are toggled. Escape returns to the field; Tab continues to the next control. In a list without search, Home/End jump to the ends and Space toggles an option. With search, use Ctrl+Home/End."),
155
153
  text("p", "The default multi-select display shows up to three chips and a count for additional items. Custom onRender callbacks still receive the full selected array when isCurrent is true. Keep custom row content decorative; selection is handled by the option itself.")
156
154
  ] }