jsl-ui 10.3.0 → 10.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,7 +22,7 @@ const grid = new GridComponent<Request>(
22
22
  ## Patterns and features
23
23
 
24
24
  - **Identity and lifecycle:** Use a unique, stable `primaryKey` and keep the component instance stable across parent renders. Register setup and event handlers with `initEvents()`; `getRef()` resolves after the grid mounts. A stable `saveColumnsKey` preserves column settings.
25
- - **Columns and editing:** Columns default their `field` to their `id`. Set `sortable` and `filterable` on columns and `showHeaderMenu: true` to expose sorting and filtering in the header menu. Enable `editable` and provide column editors to edit cells; use `onAfterEdit` for application updates. Custom header icons can be supplied through `column.header.buttons`.
25
+ - **Columns and editing:** Columns default their `field` to their `id`. Set `sortable` and `filterable` on columns and `showHeaderMenu: true` to expose sorting and filtering in the header menu. For a custom filter row, set `showHeaderRow: true` and register `onHeaderRowCellRendered` in `initEvents()`; use `explicitInitialization: true` and call `grid.init()` after registering the handler. Enable `editable` and provide column editors to edit cells; use `onAfterEdit` for application updates. Custom header icons can be supplied through `column.header.buttons`.
26
26
  - **Formulas and totals:** Use `addFormula(field, calculate, dependencies)` and `triggerAllFormulas()` for calculated values. For grouped totals, configure DataView grouping with an aggregator such as `SumAggregator`, enable `displayTotalsRow`, and use a column's `groupTotalsFormatter` to format the result. Set `aggregateCollapsed: true` to keep totals visible when groups are collapsed.
27
27
  - **Variable row heights:** Set `variableRowHeight: true` and give individual data items a `__height` in pixels. Rows without a height, including group headers, use `rowHeight` (40 px by default). Heights are explicit, not measured from wrapped content; call `grid.refresh()` after changing them.
28
28
  - **Hierarchical rows:** Use `IndentFormatter` for the tree column and initialize `GridTree` in `initEvents()` with the parent ID field. Keep parents before their descendants in the data, with each subtree contiguous; ordinary sorting can break that order.
@@ -33,7 +33,7 @@ const grid = new GridComponent<Request>(
33
33
 
34
34
  ## Examples
35
35
 
36
- - [GridComponent showcase](../examples/showcase/grids.ts): interactive examples for sorting, editing, grouping and totals, hierarchy, cell components, selection, variable heights, and more. Each example has a **Show code** option.
36
+ - [GridComponent showcase](../examples/showcase/grids.ts): interactive examples for sorting, header-menu filters, a custom filter row, editing, grouping and totals, hierarchy, cell components, selection, variable heights, and more. Each example has a **Show code** option.
37
37
  - [Focused grid demos](../examples/grid/g-01-basic.html): [large-data grouping and filters](../examples/grid/g-02-grouping.html), [custom formatters and editors](../examples/grid/g-03-customformatter-forcefit.html), [JSL cell components](../examples/grid/g-06-cellcomponents.html), [async rendering](../examples/grid/g-07-asyncrender.html), [selection](../examples/grid/g-10-selection.html), [column spans](../examples/grid/g-11-colspan.html), [undo/redo](../examples/grid/g-12-undo-redo.html), [filter row](../examples/grid/g-13-filterrow.html), and [row reordering](../examples/grid/g-14-reorder.html).
38
38
 
39
39
  The focused demos mostly use `createJSLGrid` directly and show the underlying grid APIs; use the showcase for `GridComponent` patterns.
@@ -13,3 +13,24 @@ const teams = new SelectComponent({
13
13
  - `value` / `getValue()` use keys from `keyColumn` (default `"value"`); `getSelected()` returns the matching data objects. Multiple selection uses arrays; single selection uses a scalar.
14
14
  - Omit `multiple` and use `value: "design"` for single selection with the same data.
15
15
  - `setValue()` takes keys and updates the binding without raising change callbacks. The component owns its dropdown; do not create `SelectDDAreaComponent` separately.
16
+
17
+ ## Search on the server
18
+
19
+ For option sets too large to load, let the server search. The dropdown's own search box stays the only search field.
20
+
21
+ ```ts
22
+ let generation = 0;
23
+ const customers = new SelectComponent({
24
+ ariaLabel: "Customer", data: [],
25
+ onOpen: () => search(""), // optional: load the first batch lazily
26
+ onSearch: term => search(term), // after 300 ms without typing; "" when the list reopens
27
+ onLoadMore: () => loadMore() // list scrolled near its end
28
+ });
29
+ ```
30
+
31
+ - With `onSearch`, typed text is not matched against `data` and `matchSearch` is ignored. `searchDelay` (default 300) debounces typing.
32
+ - Answer with `setData(items, hasMore)` and `setLoading(false)`; call `setLoading(true)` when a request starts. `setData` replaces all options, so for `onLoadMore` pass the items so far plus the new batch. The scroll position is kept.
33
+ - `onLoadMore` only fires while the last `setData` reported `hasMore` and the select is not loading, once per batch. Always finish with `setLoading(false)`, also after an error, or no further batch is requested.
34
+ - The chosen item stays selected and shown even if later results do not list it; `getSelected()` and `setValue()` still find it. Preselect by passing it in `data` with `value`, or by calling `setData` before `setValue`.
35
+ - Discard answers of outdated requests yourself, for example with a counter that grows with every search.
36
+ - `loadingText` replaces the "Loading…" hint.
@@ -60,6 +60,44 @@ const basicData = data(100).map((project, index) => ({ ...project, team: basicTe
60
60
  const basic = new GridComponent(basicData, columns().map(column => ({ ...column, filterable: true })), {
61
61
  primaryKey: "id", multiColumnSort: true, numberedMultiColumnSort: true, showHeaderMenu: true
62
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
+ });
63
101
  let projectStarred = false;
64
102
  const projectHeaderButton = {
65
103
  html: "☆", tooltip: "Star project column", cssClass: "grid-header-action",
@@ -389,6 +427,7 @@ export const gridShowcase: IJSLVNode = {
389
427
  { tag: "div", attr: { class: "grid-samples" }, children: [
390
428
  category("grid-browsing", "Browsing & layout", [
391
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),
392
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),
393
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),
394
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),
@@ -439,7 +478,7 @@ export const gridShowcase: IJSLVNode = {
439
478
  { tag: "details", attr: { class: "usage" }, children: [
440
479
  text("summary", "Grid showcase scope"),
441
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.'),
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.")
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.")
443
482
  ] }
444
483
  ]
445
484
  };
@@ -65,6 +65,30 @@ const large = new SelectComponent({
65
65
  value: 5000, ariaLabel: "Large list", dropdownHeight: "18rem", placeholder: "Choose an item",
66
66
  onChange: (value, item) => { largeStatus.content = item ? "Selected " + item.text + ", key " + value : "Selection cleared."; }
67
67
  });
68
+ // A pretend server: 500 customers, searched and paged with a delay.
69
+ const customerNames = Array.from({ length: 500 }, (_, i) => ({ value: i + 1, text: "Customer " + ("000" + (i + 1)).slice(-4) + " " + ["Alpine", "Danube", "Linz", "Graz", "Tyrol"][i % 5] }));
70
+ const remoteStatus = status("Open the list, type a name or scroll for more.");
71
+ let remoteGeneration = 0;
72
+ let remoteFound: typeof customerNames = [];
73
+ let remoteTerm = "";
74
+ function remoteLoad(append: boolean) {
75
+ const generation = ++remoteGeneration;
76
+ remote.setLoading(true);
77
+ setTimeout(() => {
78
+ if (generation !== remoteGeneration) { return; }
79
+ const matches = customerNames.filter(item => item.text.toLowerCase().includes(remoteTerm.toLowerCase()));
80
+ remoteFound = matches.slice(0, append ? remoteFound.length + 25 : 25);
81
+ remote.setData(remoteFound, remoteFound.length < matches.length);
82
+ remote.setLoading(false);
83
+ remoteStatus.content = remoteFound.length + " of " + matches.length + " matches loaded.";
84
+ }, 400);
85
+ }
86
+ const remote: SelectComponent = new SelectComponent({
87
+ id: "select-remote", data: [], ariaLabel: "Customer", placeholder: "Choose a customer", searchPlaceholder: "Search customers…",
88
+ onOpen: () => { if (!remoteFound.length) { remoteLoad(false); } },
89
+ onSearch: term => { remoteTerm = term; remoteLoad(false); },
90
+ onLoadMore: () => remoteLoad(true)
91
+ });
68
92
  function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
69
93
  return { tag: "article", attr: { id, class: "sample-card" }, children: [
70
94
  group([text("span", number, "sample-number"), text("h3", title)], "card-heading"),
@@ -142,6 +166,10 @@ export const selectShowcase: IJSLVNode = {
142
166
  card("select-scale", "06", "Room for a long list", "Ten thousand options, with only the visible rows rendered. Selection stays in view when you open the list.", [
143
167
  field("select-large", "Item", large), largeStatus,
144
168
  text("p", "Type to search. Arrow keys move through results; Ctrl+Home and Ctrl+End jump to either end.", "inline-note")
169
+ ]),
170
+ card("select-server", "07", "Search on the server", "For lists too long to load. The one search box asks the server, and scrolling to the end loads more.", [
171
+ field("select-remote", "Customer", remote), remoteStatus,
172
+ text("pre", '{ onSearch: term => load(term), onLoadMore: () => loadMore() } // answer with select.setData(items, hasMore)', "sample-code")
145
173
  ])
146
174
  ], "sample-grid select-sample-grid"),
147
175
  { tag: "details", attr: { class: "usage" }, children: [
@@ -34,6 +34,7 @@ export const showcaseSources: Record<string, string> = {
34
34
  "select-custom": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { SelectComponent } from \"../../components/select/SelectComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nconst status = (content: string): IJSLVNode => ({ tag: \"p\", content, attr: { class: \"sample-status\", role: \"status\" } });\n\nconst field = (id: string, label: string, control: Content) => group([\n { tag: \"label\", content: label, attr: { for: id } }, control\n], \"select-showcase-field\");\n\nconst people = [\n { value: \"maya\", text: \"Maya Chen\", initials: \"MC\", role: \"Product designer\" },\n { value: \"alex\", text: \"Alex Morgan\", initials: \"AM\", role: \"Frontend engineer\" },\n { value: \"sam\", text: \"Sam Rivera\", initials: \"SR\", role: \"Accessibility specialist\" },\n { value: \"jules\", text: \"Jules Martin\", initials: \"JM\", role: \"Product manager\" }\n];\n\nconst memberStatus = status(\"Selected Maya Chen.\");\n\nconst member = new SelectComponent({\n id: \"select-owner\", data: people, value: \"maya\",\n ariaLabel: \"Project owner\", placeholder: \"Assign an owner\", rowHeight: 56,\n matchSearch: (item, term) => (item.text + \" \" + item.role).toLowerCase().includes(term.toLowerCase()),\n onRender: args => args.isCurrent ? text(\"span\", args.data.text) : group([\n { tag: \"span\", content: args.data.initials, attr: { class: \"select-person-avatar\", \"aria-hidden\": \"true\" } },\n group([text(\"strong\", args.data.text), text(\"span\", args.data.role)], \"select-person-copy\")\n ], \"select-person\"),\n onChange: (_value, item) => { memberStatus.content = item ? \"Selected \" + item.text + \".\" : \"No owner selected.\"; }\n});\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n card(\"select-custom\", \"04\", \"More than a label\", \"Custom rows add useful details about each person.\", [\n field(\"select-owner\", \"Project owner\", member), memberStatus,\n text(\"p\", \"Search also matches each person's role.\", \"inline-note\")\n ])\n);",
35
35
  "select-states": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { SelectComponent } from \"../../components/select/SelectComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nconst field = (id: string, label: string, control: Content) => group([\n { tag: \"label\", content: label, attr: { for: id } }, control\n], \"select-showcase-field\");\n\nconst projects = [\n { value: \"website\", text: \"Website refresh\" }, { value: \"library\", text: \"Component library\" },\n { value: \"workspace\", text: \"Team workspace\" }, { value: \"mobile\", text: \"Mobile experience\" },\n { value: \"research\", text: \"Customer research\" }, { value: \"release\", text: \"Autumn release\" }\n];\n\nconst skills = [\n { value: \"design\", text: \"Design\" }, { value: \"typescript\", text: \"TypeScript\" },\n { value: \"accessibility\", text: \"Accessibility\" }, { value: \"testing\", text: \"Testing\" },\n { value: \"research\", text: \"Research\" }, { value: \"documentation\", text: \"Documentation\" }\n];\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n 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.\", [\n field(\"select-required\", \"Default project\", new SelectComponent({\n id: \"select-required\", data: projects.slice(0, 3), value: \"library\", ariaLabel: \"Default project\",\n enableSearch: false, allowEmpty: false\n })),\n field(\"select-disabled\", \"Unavailable project\", new SelectComponent({\n id: \"select-disabled\", data: projects, value: \"website\", enabled: false, ariaLabel: \"Unavailable project\"\n })),\n field(\"select-disabled-multi\", \"Unavailable skills\", new SelectComponent({\n id: \"select-disabled-multi\", data: skills, multiple: true, value: [\"design\", \"testing\"], enabled: false, ariaLabel: \"Unavailable skills\"\n }))\n ])\n);",
36
36
  "select-scale": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { SelectComponent } from \"../../components/select/SelectComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nconst status = (content: string): IJSLVNode => ({ tag: \"p\", content, attr: { class: \"sample-status\", role: \"status\" } });\n\nconst field = (id: string, label: string, control: Content) => group([\n { tag: \"label\", content: label, attr: { for: id } }, control\n], \"select-showcase-field\");\n\nconst largeStatus = status(\"Search by name or jump through the list with your keyboard.\");\n\nconst large = new SelectComponent({\n id: \"select-large\", data: Array.from({ length: 10000 }, (_, i) => ({ value: i + 1, text: \"Item \" + (\"00000\" + (i + 1)).slice(-5) })),\n value: 5000, ariaLabel: \"Large list\", dropdownHeight: \"18rem\", placeholder: \"Choose an item\",\n onChange: (value, item) => { largeStatus.content = item ? \"Selected \" + item.text + \", key \" + value : \"Selection cleared.\"; }\n});\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n card(\"select-scale\", \"06\", \"Room for a long list\", \"Ten thousand options, with only the visible rows rendered. Selection stays in view when you open the list.\", [\n field(\"select-large\", \"Item\", large), largeStatus,\n text(\"p\", \"Type to search. Arrow keys move through results; Ctrl+Home and Ctrl+End jump to either end.\", \"inline-note\")\n ])\n);",
37
+ "select-server": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { SelectComponent } from \"../../components/select/SelectComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nconst status = (content: string): IJSLVNode => ({ tag: \"p\", content, attr: { class: \"sample-status\", role: \"status\" } });\n\nconst field = (id: string, label: string, control: Content) => group([\n { tag: \"label\", content: label, attr: { for: id } }, control\n], \"select-showcase-field\");\n\nconst customerNames = Array.from({ length: 500 }, (_, i) => ({ value: i + 1, text: \"Customer \" + (\"000\" + (i + 1)).slice(-4) + \" \" + [\"Alpine\", \"Danube\", \"Linz\", \"Graz\", \"Tyrol\"][i % 5] }));\n\nconst remoteStatus = status(\"Open the list, type a name or scroll for more.\");\n\nlet remoteGeneration = 0;\n\nlet remoteFound: typeof customerNames = [];\n\nlet remoteTerm = \"\";\n\nfunction remoteLoad(append: boolean) {\n const generation = ++remoteGeneration;\n remote.setLoading(true);\n setTimeout(() => {\n if (generation !== remoteGeneration) { return; }\n const matches = customerNames.filter(item => item.text.toLowerCase().includes(remoteTerm.toLowerCase()));\n remoteFound = matches.slice(0, append ? remoteFound.length + 25 : 25);\n remote.setData(remoteFound, remoteFound.length < matches.length);\n remote.setLoading(false);\n remoteStatus.content = remoteFound.length + \" of \" + matches.length + \" matches loaded.\";\n }, 400);\n}\n\nconst remote: SelectComponent = new SelectComponent({\n id: \"select-remote\", data: [], ariaLabel: \"Customer\", placeholder: \"Choose a customer\", searchPlaceholder: \"Search customers…\",\n onOpen: () => { if (!remoteFound.length) { remoteLoad(false); } },\n onSearch: term => { remoteTerm = term; remoteLoad(false); },\n onLoadMore: () => remoteLoad(true)\n});\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n card(\"select-server\", \"07\", \"Search on the server\", \"For lists too long to load. The one search box asks the server, and scrolling to the end loads more.\", [\n field(\"select-remote\", \"Customer\", remote), remoteStatus,\n text(\"pre\", '{ onSearch: term => load(term), onLoadMore: () => loadMore() } // answer with select.setData(items, hasMore)', \"sample-code\")\n ])\n);",
37
38
  "checkbox-basic": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { CheckBoxComponent } from \"../../components/checkbox/CheckBoxComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nconst status = (content: string): IJSLVNode => ({ tag: \"p\", content, attr: { class: \"sample-status\", role: \"status\" } });\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\nconst basicStatus = status(\"Email updates are off.\");\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n card(\"checkbox-basic\", \"01\", \"One clear choice\", \"Click the box or its label. Tab focuses the input; Space changes its state.\", [\n new CheckBoxComponent({ id: \"checkbox-basic-input\", label: \"Email me product updates\", onChange: checked => {\n basicStatus.content = checked ? \"Email updates are on.\" : \"Email updates are off.\";\n } }), basicStatus,\n text(\"pre\", '{ label: \"Email me product updates\", onChange: checked => { ... } }', \"sample-code\")\n ])\n);",
38
39
  "checkbox-states": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { CheckBoxComponent } from \"../../components/checkbox/CheckBoxComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n card(\"checkbox-states\", \"02\", \"A little more context\", \"Supporting text explains a choice. Disabled controls keep their labels and current state.\", [\n group([\n new CheckBoxComponent({ id: \"checkbox-description\", label: \"Remember this workspace\", description: \"Open this workspace automatically the next time you sign in.\", value: true }),\n new CheckBoxComponent({ id: \"checkbox-disabled\", label: \"Managed by your administrator\", enabled: false }),\n new CheckBoxComponent({ id: \"checkbox-disabled-checked\", label: \"Security notifications\", value: true, enabled: false })\n ], \"checkbox-stack\")\n ])\n);",
39
40
  "checkbox-partial": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { CheckBoxComponent } from \"../../components/checkbox/CheckBoxComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content = IJSLVNode | IJSLComponent;\n\nconst text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });\n\nconst group = (children: Content[], className?: string): IJSLVNode => ({ tag: \"div\", attr: { class: className }, children });\n\nconst status = (content: string): IJSLVNode => ({ tag: \"p\", content, attr: { class: \"sample-status\", role: \"status\" } });\n\nfunction card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card\" }, children: [\n group([text(\"span\", number, \"sample-number\"), text(\"h3\", title)], \"card-heading\"),\n text(\"p\", description, \"card-description\"), ...children\n ] };\n}\n\nconst partialStatus = status(\"1 of 3 channels selected.\");\n\nconst channels = [\"Product news\", \"Release notes\", \"Community events\"].map((label, index) => new CheckBoxComponent({\n id: \"checkbox-channel-\" + index, label, value: index === 0,\n onChange: () => syncChannels()\n}));\n\nconst allChannels = new CheckBoxComponent({\n id: \"checkbox-all\", label: \"All updates\", indeterminate: true,\n onChange: checked => { channels.forEach(channel => channel.setValue(checked)); syncChannels(); }\n});\n\nfunction syncChannels() {\n const count = channels.filter(channel => channel.getValue()).length;\n allChannels.setValue(count === channels.length);\n allChannels.indeterminate = count > 0 && count < channels.length;\n partialStatus.content = count + \" of \" + channels.length + \" channels selected.\";\n}\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n card(\"checkbox-partial\", \"03\", \"Some, all, or none\", \"A mixed parent summarizes its children. Activating it selects or clears the whole group.\", [\n group([allChannels, group(channels, \"checkbox-child-list\")], \"checkbox-stack\"), partialStatus,\n text(\"pre\", \"checkbox.indeterminate = true;\\ncheckbox.setValue(true); // Silent checked update\", \"sample-code\")\n ])\n);",
@@ -71,6 +72,7 @@ export const showcaseSources: Record<string, string> = {
71
72
  "overlays": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { OverlayComponent } from \"../../components/overlay/OverlayComponent\";\nimport { ButtonComponent } from \"../../components/button/ButtonComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content=IJSLVNode|IJSLComponent;\n\nconst text=(tag:string,content:string):IJSLVNode=>({tag,content});\n\nconst group=(children:Content[],className?:string):IJSLVNode=>({tag:\"div\",attr:{class:className},children});\n\nconst button=(content:string,click:()=>void)=>new ButtonComponent({content,click,type:\"button\",outlined:true,size:\"small\"});\n\nfunction section(id:string,number:string,title:string,copy:string,children:Content[],usage:string):IJSLVNode {\n return {tag:\"section\",attr:{id,class:\"component-section\",\"aria-labelledby\":id+\"-title\"},children:[\n group([text(\"p\",\"THE ESSENTIALS / \"+number),{tag:\"h2\",content:title,attr:{id:id+\"-title\",class:\"section-title\"}},text(\"p\",copy)],\"hero-copy\"),\n group(children,\"sample-card remaining-demo\"),\n {tag:\"details\",attr:{class:\"usage\"},children:[text(\"summary\",title+\" usage & compatibility\"),text(\"p\",usage)]}\n ]};\n}\n\nconst overlayCopy=()=>group([text(\"h2\",\"Workspace settings\"),text(\"p\",\"A little room for secondary tasks, without leaving your current view.\"),new ButtonComponent({content:\"Save settings\",type:\"button\",click:()=>overlay.close()})]);\n\nlet overlay:OverlayComponent;\n\nlet allowClose=false;\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n section(\"overlays\",\"20\",\"Overlays\",\"Focused panels that slide in from the side or the top.\",[\n group([button(\"Open side panel\",()=>{overlay=OverlayComponent.show({content:overlayCopy(),ariaLabel:\"Workspace settings\",size:\"26rem\"});}),button(\"Open top panel\",()=>{overlay=OverlayComponent.show({content:overlayCopy(),direction:\"top\",size:\"20rem\",ariaLabel:\"Workspace settings\"});}),button(\"Try close guard\",()=>{allowClose=false;overlay=OverlayComponent.show({ariaLabel:\"Protected panel\",onClose:()=>allowClose,content:group([text(\"h2\",\"A protected panel\"),text(\"p\",\"Closing is blocked until you choose Allow close.\"),button(\"Allow close\",()=>{allowClose=true;overlay.close();})])});})],\"sample-row\")\n],\"show(), close(), content, direction, size, animation, dismissal flags, and callbacks remain. onClose returning false vetoes dismissal. Native modal dialogs contain keyboard focus, support nested panels, and restore focus on close. ariaLabel and closeButtonLabel provide accessible names.\")\n);",
72
73
  "ribbons": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLComponent, IJSLVNode } from \"jsl-render\";\nimport { RibbonMenuComponent } from \"../../components/ribbon-menu/RibbonMenuComponent\";\nimport { ButtonComponent } from \"../../components/button/ButtonComponent\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ntype Content=IJSLVNode|IJSLComponent;\n\nconst text=(tag:string,content:string):IJSLVNode=>({tag,content});\n\nconst group=(children:Content[],className?:string):IJSLVNode=>({tag:\"div\",attr:{class:className},children});\n\nconst button=(content:string,click:()=>void)=>new ButtonComponent({content,click,type:\"button\",outlined:true,size:\"small\"});\n\nfunction section(id:string,number:string,title:string,copy:string,children:Content[],usage:string):IJSLVNode {\n return {tag:\"section\",attr:{id,class:\"component-section\",\"aria-labelledby\":id+\"-title\"},children:[\n group([text(\"p\",\"THE ESSENTIALS / \"+number),{tag:\"h2\",content:title,attr:{id:id+\"-title\",class:\"section-title\"}},text(\"p\",copy)],\"hero-copy\"),\n group(children,\"sample-card remaining-demo\"),\n {tag:\"details\",attr:{class:\"usage\"},children:[text(\"summary\",title+\" usage & compatibility\"),text(\"p\",usage)]}\n ]};\n}\n\nconst ribbonStatus=text(\"p\",\"Choose an action.\");\n\nribbonStatus.attr={role:\"status\"};\n\nconst ribbonAction=(content:string)=>button(content,()=>{ribbonStatus.content=content+\" selected.\";});\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n section(\"ribbons\",\"21\",\"Ribbon menus\",\"Related actions grouped in a flexible, themed toolbar.\",[\n new RibbonMenuComponent([{title:\"Project\",children:[ribbonAction(\"New\"),ribbonAction(\"Open\"),ribbonAction(\"Save\")]},{title:\"Edit\",children:[ribbonAction(\"Undo\"),ribbonAction(\"Redo\")]},{title:\"View\",children:[new ButtonComponent({content:\"Details\",toggle:true,outlined:true,type:\"button\"}),new ButtonComponent({content:\"Unavailable\",enabled:false,type:\"button\"})]}]),ribbonStatus\n],\"The groups constructor and group title/children interface remain unchanged. Groups wrap with available space and use the normal ButtonComponent styles, including toggles and disabled actions.\")\n);",
73
74
  "grid-basic": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLVNode, JSLRender } from \"jsl-render\";\nimport { GridComponent } from \"../../components/grid/GridComponent\";\nimport { ISlickColumn } from \"../../grid/slick.core\";\nimport { TextEditor, NumericEditor, BooleanEditor } from \"../../grid/slick.editors.core\";\nimport { DateEditor } from \"../../grid/slick.editors.date\";\nimport { CheckboxFormatter, DateFormatter, NumericFormatter } from \"../../grid/slick.formatters\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ninterface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }\n\nfunction data(count: number): Project[] {\n const names = [\"Design system\", \"Website refresh\", \"Customer research\", \"Mobile workspace\", \"Reporting tools\"];\n return Array.from({ length: count }, (_, index) => ({\n id: index + 1, name: names[index % names.length] + \" \" + (index + 1),\n team: [\"Design\", \"Engineering\", \"Operations\"][index % 3], budget: 1500 + index * 125,\n date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0\n }));\n}\n\nfunction columns(editable = false): ISlickColumn[] {\n return [\n { id: \"id\", name: \"ID\", width: 65, sortable: true },\n { id: \"name\", name: \"Project\", width: 250, sortable: true, editor: editable ? TextEditor : undefined },\n { id: \"team\", name: \"Team\", width: 145, sortable: true, editor: editable ? TextEditor : undefined },\n { id: \"budget\", name: \"Budget\", width: 125, sortable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\", editor: editable ? NumericEditor : undefined },\n { id: \"date\", name: \"Start date\", width: 135, sortable: true, formatter: DateFormatter, editor: editable ? DateEditor : undefined },\n { id: \"approved\", name: \"Approved\", width: 100, headerCssClass: \"center\", formatter: CheckboxFormatter, editor: editable ? BooleanEditor : undefined }\n ];\n}\n\nconst text = (tag: string, content: string): IJSLVNode => ({ tag, content });\n\nfunction card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card grid-sample-card\" }, children: [\n text(\"h3\", title), { tag: \"p\", content: description, attr: { class: \"card-description\" } },\n ...extras, { tag: \"div\", attr: { class: \"grid-sample-host\" }, children: [grid] }, ...after,\n ...(source ? [{ tag: \"details\", attr: { class: \"showcase-source\" }, children: [\n text(\"summary\", \"Show code\"),\n { tag: \"pre\", attr: { class: \"sample-code showcase-source-code\" }, children: [{ tag: \"code\", content: source }] }\n ] }] : [])\n ] };\n}\n\nconst basicTeams = [\"Design\", \"Engineering\", \"Operations\", \"Research\", \"Product\", \"Marketing\", \"Finance\", \"Support\", \"Security\", \"Customer Success\"];\n\nconst basicData = data(100).map((project, index) => ({ ...project, team: basicTeams[index % basicTeams.length] }));\n\nconst basic = new GridComponent(basicData, columns().map(column => ({ ...column, filterable: true })), {\n primaryKey: \"id\", multiColumnSort: true, numberedMultiColumnSort: true, showHeaderMenu: true\n}, \"300px\");\n\nconst edits: IJSLVNode = { tag: \"p\", content: \"Edit a project, budget, date, or approval value.\", attr: { role: \"status\", class: \"sample-status\" } };\n\nconst editable = new GridComponent(data(25), columns(true), { primaryKey: \"id\", editable: true, autoEdit: false }, \"300px\");\n\neditable.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {\n edits.content = \"Updated \" + args.column.name + \" for project \" + args.item.id + \".\";\n // Grid events run independently of the showcase renderer.\n JSLRender.lastCreatedRenderer?.refresh();\n}));\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n 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)\n);",
75
+ "grid-filter-row": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLVNode } from \"jsl-render\";\nimport { GridComponent } from \"../../components/grid/GridComponent\";\nimport { DateFormatter, NumericFormatter } from \"../../grid/slick.formatters\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ninterface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }\n\nfunction data(count: number): Project[] {\n const names = [\"Design system\", \"Website refresh\", \"Customer research\", \"Mobile workspace\", \"Reporting tools\"];\n return Array.from({ length: count }, (_, index) => ({\n id: index + 1, name: names[index % names.length] + \" \" + (index + 1),\n team: [\"Design\", \"Engineering\", \"Operations\"][index % 3], budget: 1500 + index * 125,\n date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0\n }));\n}\n\nconst text = (tag: string, content: string): IJSLVNode => ({ tag, content });\n\nfunction card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card grid-sample-card\" }, children: [\n text(\"h3\", title), { tag: \"p\", content: description, attr: { class: \"card-description\" } },\n ...extras, { tag: \"div\", attr: { class: \"grid-sample-host\" }, children: [grid] }, ...after,\n ...(source ? [{ tag: \"details\", attr: { class: \"showcase-source\" }, children: [\n text(\"summary\", \"Show code\"),\n { tag: \"pre\", attr: { class: \"sample-code showcase-source-code\" }, children: [{ tag: \"code\", content: source }] }\n ] }] : [])\n ] };\n}\n\nconst filterRowValues: Record<string, string> = {};\n\nconst filterRow = new GridComponent(data(30), [\n { id: \"id\", name: \"ID\", width: 65, sortable: true },\n { id: \"name\", name: \"Project\", width: 230, sortable: true },\n { id: \"team\", name: \"Team\", width: 140, sortable: true },\n { id: \"budget\", name: \"Budget\", width: 125, sortable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\" },\n { id: \"date\", name: \"Start date\", width: 140, sortable: true, formatter: DateFormatter }\n], {\n primaryKey: \"id\", showHeaderRow: true, headerRowHeight: 36, explicitInitialization: true,\n enableColumnReorder: false\n}, \"320px\");\n\nfilterRow.initEvents(grid => {\n grid.onHeaderRowCellRendered.subscribe((_event, args) => {\n const input = document.createElement(\"input\");\n input.type = \"search\";\n input.placeholder = \"Filter…\";\n input.setAttribute(\"aria-label\", \"Filter \" + args.column.name);\n input.value = filterRowValues[args.column.id] || \"\";\n input.style.width = \"100%\";\n input.style.boxSizing = \"border-box\";\n args.node.textContent = \"\";\n args.node.appendChild(input);\n input.addEventListener(\"input\", () => {\n filterRowValues[args.column.id] = input.value.toLowerCase();\n grid.refreshFilters(true);\n });\n });\n grid.addFilter({ field: \"-\", match: item => Object.keys(filterRowValues).every(id => {\n const query = filterRowValues[id];\n if (!query) return true;\n const column = grid.getColumnById(id);\n if (!column) return true;\n const value = grid.getDataItemValueForColumn(item, column);\n const displayValue = grid.getFormattedValue(column, value, item) || \"\";\n return displayValue.toLowerCase().includes(query);\n }) });\n grid.init();\n});\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n 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)\n);",
74
76
  "grid-header-menu-icons": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLVNode } from \"jsl-render\";\nimport { GridComponent } from \"../../components/grid/GridComponent\";\nimport { NumericFormatter } from \"../../grid/slick.formatters\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ninterface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }\n\nfunction data(count: number): Project[] {\n const names = [\"Design system\", \"Website refresh\", \"Customer research\", \"Mobile workspace\", \"Reporting tools\"];\n return Array.from({ length: count }, (_, index) => ({\n id: index + 1, name: names[index % names.length] + \" \" + (index + 1),\n team: [\"Design\", \"Engineering\", \"Operations\"][index % 3], budget: 1500 + index * 125,\n date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0\n }));\n}\n\nconst text = (tag: string, content: string): IJSLVNode => ({ tag, content });\n\nfunction card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card grid-sample-card\" }, children: [\n text(\"h3\", title), { tag: \"p\", content: description, attr: { class: \"card-description\" } },\n ...extras, { tag: \"div\", attr: { class: \"grid-sample-host\" }, children: [grid] }, ...after,\n ...(source ? [{ tag: \"details\", attr: { class: \"showcase-source\" }, children: [\n text(\"summary\", \"Show code\"),\n { tag: \"pre\", attr: { class: \"sample-code showcase-source-code\" }, children: [{ tag: \"code\", content: source }] }\n ] }] : [])\n ] };\n}\n\nlet projectStarred = false;\n\nconst projectHeaderButton = {\n html: \"☆\", tooltip: \"Star project column\", cssClass: \"grid-header-action\",\n handler: (event: MouseEvent) => {\n projectStarred = !projectStarred;\n projectHeaderButton.html = projectStarred ? \"★\" : \"☆\";\n projectHeaderButton.tooltip = projectStarred ? \"Unstar project column\" : \"Star project column\";\n projectHeaderButton.cssClass = \"grid-header-action\" + (projectStarred ? \" grid-header-starred\" : \"\");\n const button = event.currentTarget as HTMLElement;\n button.textContent = projectHeaderButton.html;\n button.title = projectHeaderButton.tooltip;\n button.classList.toggle(\"grid-header-starred\", projectStarred);\n }\n};\n\nconst headerActions = new GridComponent(data(12), [\n { id: \"id\", name: \"ID\", width: 65, sortable: true, filterable: true },\n { id: \"name\", name: \"Project\", width: 245, sortable: true, filterable: true, header: { buttons: [\n projectHeaderButton\n ] } },\n { id: \"team\", name: \"Team\", width: 145, sortable: true, filterable: true, header: { buttons: [\n { html: \"i\", tooltip: \"About team column\", cssClass: \"grid-header-action\", handler: () => {\n window.alert(\"The Team column shows the team responsible for each project.\");\n } }\n ] } },\n { id: \"budget\", name: \"Budget\", width: 125, sortable: true, filterable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\" }\n], { primaryKey: \"id\", showHeaderMenu: true }, \"300px\");\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n 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)\n);",
75
77
  "grid-frozen": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLVNode, JSLRender } from \"jsl-render\";\nimport { GridComponent } from \"../../components/grid/GridComponent\";\nimport { ISlickColumn } from \"../../grid/slick.core\";\nimport { TextEditor, NumericEditor, BooleanEditor } from \"../../grid/slick.editors.core\";\nimport { DateEditor } from \"../../grid/slick.editors.date\";\nimport { CheckboxFormatter, DateFormatter, NumericFormatter } from \"../../grid/slick.formatters\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ninterface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }\n\nfunction data(count: number): Project[] {\n const names = [\"Design system\", \"Website refresh\", \"Customer research\", \"Mobile workspace\", \"Reporting tools\"];\n return Array.from({ length: count }, (_, index) => ({\n id: index + 1, name: names[index % names.length] + \" \" + (index + 1),\n team: [\"Design\", \"Engineering\", \"Operations\"][index % 3], budget: 1500 + index * 125,\n date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0\n }));\n}\n\nfunction columns(editable = false): ISlickColumn[] {\n return [\n { id: \"id\", name: \"ID\", width: 65, sortable: true },\n { id: \"name\", name: \"Project\", width: 250, sortable: true, editor: editable ? TextEditor : undefined },\n { id: \"team\", name: \"Team\", width: 145, sortable: true, editor: editable ? TextEditor : undefined },\n { id: \"budget\", name: \"Budget\", width: 125, sortable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\", editor: editable ? NumericEditor : undefined },\n { id: \"date\", name: \"Start date\", width: 135, sortable: true, formatter: DateFormatter, editor: editable ? DateEditor : undefined },\n { id: \"approved\", name: \"Approved\", width: 100, headerCssClass: \"center\", formatter: CheckboxFormatter, editor: editable ? BooleanEditor : undefined }\n ];\n}\n\nconst text = (tag: string, content: string): IJSLVNode => ({ tag, content });\n\nfunction card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card grid-sample-card\" }, children: [\n text(\"h3\", title), { tag: \"p\", content: description, attr: { class: \"card-description\" } },\n ...extras, { tag: \"div\", attr: { class: \"grid-sample-host\" }, children: [grid] }, ...after,\n ...(source ? [{ tag: \"details\", attr: { class: \"showcase-source\" }, children: [\n text(\"summary\", \"Show code\"),\n { tag: \"pre\", attr: { class: \"sample-code showcase-source-code\" }, children: [{ tag: \"code\", content: source }] }\n ] }] : [])\n ] };\n}\n\nconst edits: IJSLVNode = { tag: \"p\", content: \"Edit a project, budget, date, or approval value.\", attr: { role: \"status\", class: \"sample-status\" } };\n\nconst editable = new GridComponent(data(25), columns(true), { primaryKey: \"id\", editable: true, autoEdit: false }, \"300px\");\n\neditable.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {\n edits.content = \"Updated \" + args.column.name + \" for project \" + args.item.id + \".\";\n // Grid events run independently of the showcase renderer.\n JSLRender.lastCreatedRenderer?.refresh();\n}));\n\nconst frozenData = data(120).map((project, index) => ({\n ...project,\n owner: [\"Alex Morgan\", \"Sam Weber\", \"Jordan Lee\", \"Robin Taylor\"][index % 4],\n status: [\"Planning\", \"In progress\", \"In review\", \"Complete\"][index % 4],\n due: new Date(2026, 11, 1 + index % 28),\n plannedHours: 80 + index * 4,\n actualHours: 25 + index * 3,\n location: [\"Vienna\", \"London\", \"Berlin\", \"New York\"][index % 4]\n}));\n\nconst frozenColumns: ISlickColumn[] = [\n ...columns().map(column => ({ ...column, width: column.id === \"name\" ? 300 : 180 })),\n { id: \"owner\", name: \"Project owner\", width: 200, sortable: true },\n { id: \"status\", name: \"Status\", width: 180, sortable: true },\n { id: \"due\", name: \"Due date\", width: 180, sortable: true, formatter: DateFormatter },\n { id: \"plannedHours\", name: \"Planned hours\", width: 180, sortable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\" },\n { id: \"actualHours\", name: \"Actual hours\", width: 180, sortable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\" },\n { id: \"location\", name: \"Office\", width: 180, sortable: true }\n];\n\nconst frozen = new GridComponent(frozenData, frozenColumns, {\n primaryKey: \"id\", frozenColumn: 1\n}, \"320px\");\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n 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)\n);",
76
78
  "grid-large": "import \"../../ui/base.css\";\nimport \"./showcase.css\";\nimport { IJSLVNode, JSLRender } from \"jsl-render\";\nimport { GridComponent } from \"../../components/grid/GridComponent\";\nimport { ISlickColumn } from \"../../grid/slick.core\";\nimport { TextEditor, NumericEditor, BooleanEditor } from \"../../grid/slick.editors.core\";\nimport { DateEditor } from \"../../grid/slick.editors.date\";\nimport { CheckboxFormatter, DateFormatter, NumericFormatter } from \"../../grid/slick.formatters\";\nimport { JSLRender as ExampleRenderer } from \"jsl-render\";\n\ninterface Project { id: number; name: string; team: string; budget: number; date: Date; approved: boolean; }\n\nfunction data(count: number): Project[] {\n const names = [\"Design system\", \"Website refresh\", \"Customer research\", \"Mobile workspace\", \"Reporting tools\"];\n return Array.from({ length: count }, (_, index) => ({\n id: index + 1, name: names[index % names.length] + \" \" + (index + 1),\n team: [\"Design\", \"Engineering\", \"Operations\"][index % 3], budget: 1500 + index * 125,\n date: new Date(2026, 9, 1 + index % 28), approved: index % 3 !== 0\n }));\n}\n\nfunction columns(editable = false): ISlickColumn[] {\n return [\n { id: \"id\", name: \"ID\", width: 65, sortable: true },\n { id: \"name\", name: \"Project\", width: 250, sortable: true, editor: editable ? TextEditor : undefined },\n { id: \"team\", name: \"Team\", width: 145, sortable: true, editor: editable ? TextEditor : undefined },\n { id: \"budget\", name: \"Budget\", width: 125, sortable: true, headerCssClass: \"right\", formatter: NumericFormatter, format: \"#,0\", editor: editable ? NumericEditor : undefined },\n { id: \"date\", name: \"Start date\", width: 135, sortable: true, formatter: DateFormatter, editor: editable ? DateEditor : undefined },\n { id: \"approved\", name: \"Approved\", width: 100, headerCssClass: \"center\", formatter: CheckboxFormatter, editor: editable ? BooleanEditor : undefined }\n ];\n}\n\nconst text = (tag: string, content: string): IJSLVNode => ({ tag, content });\n\nfunction card<T>(id: string, title: string, description: string, grid: GridComponent<T>, extras: any[] = [], source?: string, after: IJSLVNode[] = []): IJSLVNode {\n return { tag: \"article\", attr: { id, class: \"sample-card grid-sample-card\" }, children: [\n text(\"h3\", title), { tag: \"p\", content: description, attr: { class: \"card-description\" } },\n ...extras, { tag: \"div\", attr: { class: \"grid-sample-host\" }, children: [grid] }, ...after,\n ...(source ? [{ tag: \"details\", attr: { class: \"showcase-source\" }, children: [\n text(\"summary\", \"Show code\"),\n { tag: \"pre\", attr: { class: \"sample-code showcase-source-code\" }, children: [{ tag: \"code\", content: source }] }\n ] }] : [])\n ] };\n}\n\nconst edits: IJSLVNode = { tag: \"p\", content: \"Edit a project, budget, date, or approval value.\", attr: { role: \"status\", class: \"sample-status\" } };\n\nconst editable = new GridComponent(data(25), columns(true), { primaryKey: \"id\", editable: true, autoEdit: false }, \"300px\");\n\neditable.initEvents(grid => grid.onAfterEdit.subscribe((_event, args) => {\n edits.content = \"Updated \" + args.column.name + \" for project \" + args.item.id + \".\";\n // Grid events run independently of the showcase renderer.\n JSLRender.lastCreatedRenderer?.refresh();\n}));\n\nconst large = new GridComponent(data(10000), columns(), { primaryKey: \"id\", rowHeight: 28 }, \"320px\");\n\n// Add <div id=\"example\"></div> to the page.\nnew ExampleRenderer(document.getElementById(\"example\"), true).render(\n 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)\n);",
@@ -39,6 +39,23 @@ export interface ISelectComponentOptions<T = any, TValue = any, TBinding = any>
39
39
  onRender?: (args: ISelectRenderArg<T>) => void | IJSLVNode;
40
40
  onRenderGroup?: (args: ISelectRenderGroupArg) => void | IJSLVNode;
41
41
  matchSearch?: (data: T, term: string) => boolean;
42
+ /**
43
+ * Switches to server-side search: the typed text is no longer matched against `data`. After `searchDelay` ms of
44
+ * typing (and with "" when the list opens with a stale search) this is called with the term; the owner answers
45
+ * with setData() and setLoading(). `matchSearch` is ignored.
46
+ */
47
+ onSearch?: (term: string) => void;
48
+ /** Milliseconds to wait after the last keystroke before onSearch runs. Default 300. */
49
+ searchDelay?: number;
50
+ /** Called whenever the list opens, for example to load the first batch lazily. */
51
+ onOpen?: () => void;
52
+ /**
53
+ * Called when the list is scrolled near its end while setData() reported more items. Start loading and call
54
+ * setLoading(true) at once; finish with setData(all items so far, hasMore) and setLoading(false).
55
+ */
56
+ onLoadMore?: () => void;
57
+ /** Shown at the end of the list while setLoading(true) is active. */
58
+ loadingText?: string;
42
59
  onAppend?: (dom: HTMLDivElement) => void;
43
60
  enableKeyboard?: boolean;
44
61
  multiple?: boolean;
@@ -72,6 +89,11 @@ export declare class SelectComponent<T = any, TValue = any, TBinding = any> impl
72
89
  private dropdownLimit;
73
90
  private disposed;
74
91
  private expandedBeforePress;
92
+ private loading;
93
+ private hasMore;
94
+ private moreRequested;
95
+ private searchedTerm;
96
+ private searchTimer;
75
97
  constructor(o: ISelectComponentOptions<T, TValue, TBinding>);
76
98
  render(): IJSLVNode;
77
99
  onCreate(node: IJSLVNode): void;
@@ -92,6 +114,19 @@ export declare class SelectComponent<T = any, TValue = any, TBinding = any> impl
92
114
  setValue(value: any): void;
93
115
  getSelected(): T | T[];
94
116
  setSelected(item: T | T[]): void;
117
+ /**
118
+ * Replaces the options, for example with the answer to onSearch or with more items for onLoadMore. The current
119
+ * selection is kept even when it is not part of the new data. `hasMore` tells whether onLoadMore may be called.
120
+ */
121
+ setData(data: T[], hasMore?: boolean): void;
122
+ /** Shows or hides the loading hint at the end of the list. Call with false when a search or load has finished. */
123
+ setLoading(loading: boolean): void;
124
+ /** @internal Used by the dropdown. */
125
+ isLoading(): boolean;
126
+ /** @internal Used by the dropdown: the typed text changed. Runs onSearch after searchDelay unless `immediate`. */
127
+ requestSearch(term: string, immediate?: boolean): void;
128
+ /** @internal Used by the dropdown: the end of the list is near. */
129
+ requestMore(): void;
95
130
  focus(): void;
96
131
  hasSelection(): boolean;
97
132
  protected renderSelection(): IJSLVNode;
@@ -13,6 +13,11 @@ export class SelectComponent {
13
13
  this.dropdownLimit = 0;
14
14
  this.disposed = false;
15
15
  this.expandedBeforePress = false;
16
+ // Server-side search state. searchedTerm is the term onSearch last ran with.
17
+ this.loading = false;
18
+ this.hasMore = false;
19
+ this.moreRequested = false;
20
+ this.searchedTerm = "";
16
21
  this.onOutsidePress = (event) => {
17
22
  var _a, _b;
18
23
  if (!((_a = this.dom) === null || _a === void 0 ? void 0 : _a.contains(event.target)) && !((_b = this.dropdownArea) === null || _b === void 0 ? void 0 : _b.contains(event.target))) {
@@ -63,7 +68,7 @@ export class SelectComponent {
63
68
  enableKeyboard: true, rowHeight: 36, allowEmpty: true, enabled: true,
64
69
  openOnEnter: true, focusFirstItem: true, autoShrink: true, bindMode: "toModel",
65
70
  searchPlaceholder: "Search options…", emptyText: "No matching options",
66
- clearButtonLabel: "Clear selection",
71
+ clearButtonLabel: "Clear selection", searchDelay: 300, loadingText: "Loading…",
67
72
  onRenderGroup: args => { var _a; args.node.content = String((_a = args.groupValue) !== null && _a !== void 0 ? _a : ""); },
68
73
  matchSearch: (data, term) => { var _a; return String((_a = data[this.options.textColumn]) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(term.toLowerCase()); },
69
74
  ...o, data: (_a = o.data) !== null && _a !== void 0 ? _a : []
@@ -147,7 +152,7 @@ export class SelectComponent {
147
152
  isExpanded() { return this.expanded; }
148
153
  getListId() { return this.listId; }
149
154
  show(searchTxt) {
150
- var _a, _b, _c;
155
+ var _a, _b, _c, _d, _e;
151
156
  if (!this.options.enabled || this.disposed || !this.dom || this.expanded) {
152
157
  return;
153
158
  }
@@ -174,7 +179,7 @@ export class SelectComponent {
174
179
  }
175
180
  if (this.options.autoShrink) {
176
181
  const contentHeight = (data.length ? data.length * this.options.rowHeight : 64) +
177
- (this.options.enableSearch ? 48 : 0) + 8;
182
+ (this.options.enableSearch ? 48 : 0) + 8 + (this.loading ? 28 : 0);
178
183
  this.dropdownArea.style.height = Math.min(contentHeight, this.dropdownLimit) + "px";
179
184
  }
180
185
  this.positionDropdown();
@@ -184,12 +189,17 @@ export class SelectComponent {
184
189
  this.dropdownRenderer.render(this.dropdownComponent);
185
190
  JSLRender.lastCreatedRenderer = previousRenderer;
186
191
  this.positionDropdown();
192
+ // A fresh list starts with an empty search; make the owner drop results of an earlier search.
193
+ if (this.options.onSearch && !searchTxt) {
194
+ this.requestSearch("", true);
195
+ }
196
+ (_d = (_c = this.options).onOpen) === null || _d === void 0 ? void 0 : _d.call(_c);
187
197
  document.addEventListener("mousedown", this.onOutsidePress, true);
188
198
  document.addEventListener("touchstart", this.onOutsidePress, true);
189
199
  document.addEventListener("focusin", this.onDocumentFocus);
190
200
  window.addEventListener("resize", this.positionDropdown);
191
201
  window.addEventListener("scroll", this.onWindowScroll, true);
192
- (_c = this.renderer) === null || _c === void 0 ? void 0 : _c.refresh();
202
+ (_e = this.renderer) === null || _e === void 0 ? void 0 : _e.refresh();
193
203
  this.updateTriggerAria();
194
204
  this.focusFrame = requestAnimationFrame(() => {
195
205
  var _a;
@@ -212,6 +222,7 @@ export class SelectComponent {
212
222
  cancelAnimationFrame(this.focusFrame);
213
223
  this.focusFrame = undefined;
214
224
  }
225
+ clearTimeout(this.searchTimer);
215
226
  const wasExpanded = this.expanded;
216
227
  this.expanded = false;
217
228
  this.focused = null;
@@ -264,6 +275,60 @@ export class SelectComponent {
264
275
  this.options.onChange.notify(value, this.selected);
265
276
  this.refresh();
266
277
  }
278
+ /**
279
+ * Replaces the options, for example with the answer to onSearch or with more items for onLoadMore. The current
280
+ * selection is kept even when it is not part of the new data. `hasMore` tells whether onLoadMore may be called.
281
+ */
282
+ setData(data, hasMore = false) {
283
+ var _a;
284
+ const key = this.options.keyColumn;
285
+ this.options.data = data !== null && data !== void 0 ? data : [];
286
+ this.hasMore = hasMore;
287
+ this.moreRequested = false;
288
+ // Selection and focus compare by identity: point them at the new objects.
289
+ const current = (item) => { var _a; return (_a = this.options.data.find(candidate => candidate[key] === item[key])) !== null && _a !== void 0 ? _a : item; };
290
+ if (this.selected != null) {
291
+ this.selected = this.options.multiple ? this.selected.map(current) : current(this.selected);
292
+ }
293
+ (_a = this.dropdownComponent) === null || _a === void 0 ? void 0 : _a.dataChanged();
294
+ this.refresh();
295
+ }
296
+ /** Shows or hides the loading hint at the end of the list. Call with false when a search or load has finished. */
297
+ setLoading(loading) {
298
+ this.loading = loading;
299
+ if (!loading) {
300
+ this.moreRequested = false;
301
+ }
302
+ this.refresh();
303
+ }
304
+ /** @internal Used by the dropdown. */
305
+ isLoading() { return this.loading; }
306
+ /** @internal Used by the dropdown: the typed text changed. Runs onSearch after searchDelay unless `immediate`. */
307
+ requestSearch(term, immediate = false) {
308
+ clearTimeout(this.searchTimer);
309
+ if (term === this.searchedTerm) {
310
+ return;
311
+ }
312
+ const run = () => {
313
+ this.searchedTerm = term;
314
+ this.moreRequested = false;
315
+ this.options.onSearch(term);
316
+ };
317
+ if (immediate) {
318
+ run();
319
+ }
320
+ else {
321
+ this.searchTimer = setTimeout(run, this.options.searchDelay);
322
+ }
323
+ }
324
+ /** @internal Used by the dropdown: the end of the list is near. */
325
+ requestMore() {
326
+ if (!this.options.onLoadMore || !this.hasMore || this.loading || this.moreRequested) {
327
+ return;
328
+ }
329
+ this.moreRequested = true;
330
+ this.options.onLoadMore();
331
+ }
267
332
  focus() {
268
333
  var _a;
269
334
  if (this.dom) {
@@ -315,14 +380,23 @@ export class SelectComponent {
315
380
  return node;
316
381
  }
317
382
  selectValue(value) {
318
- var _a;
383
+ var _a, _b;
319
384
  if (value == null) {
320
385
  this.selected = this.options.multiple ? [] : null;
321
386
  return;
322
387
  }
323
- this.selected = this.options.multiple ?
324
- this.options.data.filter(item => Array.isArray(value) && value.indexOf(item[this.options.keyColumn]) >= 0) :
325
- (_a = this.options.data.find(item => item[this.options.keyColumn] === value)) !== null && _a !== void 0 ? _a : null;
388
+ const key = this.options.keyColumn;
389
+ // Items the current data no longer lists (after setData) stay selectable by their key.
390
+ const previous = this.selected == null ? [] : Array.isArray(this.selected) ? this.selected : [this.selected];
391
+ if (this.options.multiple) {
392
+ const keys = Array.isArray(value) ? value : [];
393
+ const listed = this.options.data.filter(item => keys.indexOf(item[key]) >= 0);
394
+ this.selected = [...listed, ...previous.filter(item => keys.indexOf(item[key]) >= 0 &&
395
+ !listed.some(other => other[key] === item[key]))];
396
+ }
397
+ else {
398
+ this.selected = (_b = (_a = this.options.data.find(item => item[key] === value)) !== null && _a !== void 0 ? _a : previous.find(item => item[key] === value)) !== null && _b !== void 0 ? _b : null;
399
+ }
326
400
  }
327
401
  refresh() { var _a, _b; (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.refresh(); (_b = this.dropdownRenderer) === null || _b === void 0 ? void 0 : _b.refresh(); }
328
402
  focusWithoutOpening() {
@@ -19,14 +19,20 @@ export declare class SelectDDAreaComponent implements IJSLComponent {
19
19
  private searchText;
20
20
  private optionPositions;
21
21
  private optionCount;
22
+ private removed;
22
23
  constructor(options: ISelectComponentOptions<any>, component: SelectComponent, args: IDDArguments);
23
24
  onInit(renderer: JSLRender): void;
24
25
  onCreate(node: IJSLVNode): void;
26
+ onRemove(): void;
25
27
  render(): IJSLVNode;
26
28
  navigateDown(): void;
27
29
  navigateUp(): void;
28
30
  search(term: string): void;
31
+ /** The owner replaced the data: keep the focused item if it is still listed, otherwise focus the first. */
32
+ dataChanged(): void;
29
33
  clearSearch(): void;
34
+ private checkLoadMore;
35
+ private checkLoadMoreSoon;
30
36
  private isGroup;
31
37
  private renderRow;
32
38
  private focusFirst;
@@ -9,6 +9,16 @@ export class SelectDDAreaComponent {
9
9
  this.onRender = new EventHandler();
10
10
  this.optionPositions = new Map();
11
11
  this.optionCount = 0;
12
+ this.removed = false;
13
+ this.checkLoadMore = () => {
14
+ const list = this.scrollContainer;
15
+ if (!list || this.removed) {
16
+ return;
17
+ }
18
+ if (list.scrollTop + list.clientHeight >= list.scrollHeight - this.options.rowHeight * 3) {
19
+ this.component.requestMore();
20
+ }
21
+ };
12
22
  this.searchText = (_a = args.searchTxt) !== null && _a !== void 0 ? _a : "";
13
23
  if (this.searchText) {
14
24
  this.search(this.searchText);
@@ -28,6 +38,13 @@ export class SelectDDAreaComponent {
28
38
  this.scrollContainer = this.dom.querySelector(".sel-dd-items");
29
39
  this.scrollToFocus();
30
40
  this.renderer.refresh();
41
+ this.scrollContainer.addEventListener("scroll", this.checkLoadMore);
42
+ this.checkLoadMoreSoon();
43
+ }
44
+ onRemove() {
45
+ var _a;
46
+ (_a = this.scrollContainer) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", this.checkLoadMore);
47
+ this.removed = true;
31
48
  }
32
49
  render() {
33
50
  var _a, _b, _c, _d;
@@ -60,6 +77,7 @@ export class SelectDDAreaComponent {
60
77
  this.virtualList.setData(data);
61
78
  this.onRender.notify(data);
62
79
  const label = (_d = (_c = (_b = this.options.ariaLabel) !== null && _b !== void 0 ? _b : this.options.placeholder) !== null && _c !== void 0 ? _c : this.options.placehoder) !== null && _d !== void 0 ? _d : "Options";
80
+ const loading = this.component.isLoading();
63
81
  return {
64
82
  tag: "div", attr: {
65
83
  class: "sel-dd-panel" + (this.options.enableAnimation ? " sel-dd-animate" : ""),
@@ -86,8 +104,12 @@ export class SelectDDAreaComponent {
86
104
  "aria-activedescendant": this.options.enableSearch ? undefined : activeId
87
105
  }, children: [
88
106
  this.virtualList,
89
- { tag: "div", attr: { class: "sel-empty", role: "status", hidden: data.length ? "hidden" : undefined }, content: this.options.emptyText }
107
+ { tag: "div", attr: { class: "sel-empty", role: "status", hidden: data.length || loading ? "hidden" : undefined }, content: this.options.emptyText }
90
108
  ]
109
+ },
110
+ {
111
+ tag: "div", attr: { class: "sel-status", role: "status", hidden: loading ? undefined : "hidden" },
112
+ content: loading ? this.options.loadingText : undefined
91
113
  }
92
114
  ]
93
115
  };
@@ -97,17 +119,41 @@ export class SelectDDAreaComponent {
97
119
  search(term) {
98
120
  var _a;
99
121
  this.searchText = term;
100
- this.filteredData = term ? this.options.data.filter(item => this.options.matchSearch(item, term)) : null;
122
+ // With server-side search the owner replaces the data (dataChanged); nothing is filtered here.
123
+ const remote = this.options.onSearch != null;
124
+ this.filteredData = term && !remote ? this.options.data.filter(item => this.options.matchSearch(item, term)) : null;
101
125
  if (this.scrollContainer) {
102
126
  this.scrollContainer.scrollTop = 0;
103
127
  }
104
128
  if (this.virtualList) {
105
129
  this.virtualList.State.scrollPos = 0;
106
130
  }
107
- this.focusFirst();
131
+ if (remote) {
132
+ this.component.requestSearch(term);
133
+ }
134
+ else {
135
+ this.focusFirst();
136
+ }
137
+ (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.refresh();
138
+ }
139
+ /** The owner replaced the data: keep the focused item if it is still listed, otherwise focus the first. */
140
+ dataChanged() {
141
+ var _a;
142
+ const key = this.options.keyColumn;
143
+ const focus = this.component.getFocus();
144
+ const same = focus == null ? undefined : this.options.data.find(item => item[key] === focus[key]);
145
+ if (same) {
146
+ this.component.setFocus(same);
147
+ }
148
+ else {
149
+ this.focusFirst();
150
+ }
108
151
  (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.refresh();
152
+ this.checkLoadMoreSoon();
109
153
  }
110
154
  clearSearch() { this.search(""); }
155
+ // After a render: a list too short to scroll would otherwise never ask for more.
156
+ checkLoadMoreSoon() { requestAnimationFrame(this.checkLoadMore); }
111
157
  isGroup(item) { return this.options.groupProperty != null && (item === null || item === void 0 ? void 0 : item.__isGroup) === true; }
112
158
  renderRow(item, index) {
113
159
  var _a, _b;
@@ -191,8 +191,10 @@
191
191
  font-weight: 600;
192
192
  cursor: default;
193
193
  }
194
- .sel-empty { padding: 1.25rem .625rem; color: var(--jsl-color-text-muted); font-size: .8125rem; text-align: center; }
194
+ .sel-empty { position: absolute; left: 0; right: 0; top: 0; padding: 1.25rem .625rem; color: var(--jsl-color-text-muted); font-size: .8125rem; text-align: center; }
195
195
  .sel-empty[hidden] { display: none; }
196
+ .sel-status { flex: 0 0 auto; padding: .375rem .625rem; color: var(--jsl-color-text-muted); font-size: .75rem; text-align: center; }
197
+ .sel-status[hidden] { display: none; }
196
198
  .sel-dd-animate { animation: jsl-select-appear .12s ease-out; }
197
199
  @keyframes jsl-select-appear { from { opacity: 0; } to { opacity: 1; } }
198
200
  @media (prefers-reduced-motion: reduce) {