jsl-ui 10.4.3 → 10.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/docs/AutoSuggestComponent.md +17 -17
  2. package/docs/ButtonComponent.md +22 -22
  3. package/docs/CheckBoxComponent.md +12 -12
  4. package/docs/DataBinding.md +19 -19
  5. package/docs/DateComponent.md +12 -12
  6. package/docs/DateRangeComponent.md +13 -13
  7. package/docs/DateTimeComponent.md +14 -14
  8. package/docs/DialogComponent.md +15 -15
  9. package/docs/DropdownMenuComponent.md +22 -22
  10. package/docs/ExpanderComponent.md +13 -13
  11. package/docs/FormComponent.md +15 -15
  12. package/docs/FormFieldComponent.md +15 -15
  13. package/docs/GridComponent.md +39 -39
  14. package/docs/InputComponent.md +15 -15
  15. package/docs/IntervalComponent.md +13 -13
  16. package/docs/LoadingComponent.md +12 -12
  17. package/docs/NavigationComponent.md +17 -17
  18. package/docs/Notification.md +14 -14
  19. package/docs/NotificationComponent.md +13 -13
  20. package/docs/NumberComponent.md +12 -12
  21. package/docs/OverlayComponent.md +13 -13
  22. package/docs/ProgressComponent.md +12 -12
  23. package/docs/README.md +27 -27
  24. package/docs/RibbonMenuComponent.md +14 -14
  25. package/docs/SelectComponent.md +36 -36
  26. package/docs/SliderComponent.md +20 -20
  27. package/docs/SplitterComponent.md +14 -14
  28. package/docs/StackPanelComponent.md +13 -13
  29. package/docs/TabsComponent.md +16 -16
  30. package/docs/TimeComponent.md +13 -13
  31. package/docs/TreeViewComponent.md +16 -16
  32. package/examples/showcase/checks-and-expanders.ts +148 -148
  33. package/examples/showcase/cultures.ts +39 -39
  34. package/examples/showcase/data-binding.ts +138 -138
  35. package/examples/showcase/dates.ts +168 -168
  36. package/examples/showcase/dialogs.ts +184 -184
  37. package/examples/showcase/dropdown-menus.ts +99 -99
  38. package/examples/showcase/feedback-and-navigation.ts +173 -173
  39. package/examples/showcase/fields.ts +166 -166
  40. package/examples/showcase/fonts/OFL-BricolageGrotesque.txt +93 -93
  41. package/examples/showcase/fonts/OFL-Figtree.txt +93 -93
  42. package/examples/showcase/fonts/OFL-Jost.txt +93 -93
  43. package/examples/showcase/generate-sources.cjs +104 -104
  44. package/examples/showcase/grids.ts +484 -484
  45. package/examples/showcase/index.html +71 -71
  46. package/examples/showcase/layout-and-navigation.ts +46 -46
  47. package/examples/showcase/nivona.css +98 -98
  48. package/examples/showcase/package.json +10 -10
  49. package/examples/showcase/selects.ts +184 -184
  50. package/examples/showcase/showcase-sources.ts +94 -94
  51. package/examples/showcase/showcase.css +281 -281
  52. package/examples/showcase/showcase.ts +244 -244
  53. package/examples/showcase/tabs.ts +161 -161
  54. package/examples/showcase/themes.css +83 -83
  55. package/examples/showcase/themes.ts +56 -56
  56. package/examples/showcase/wirtshans.css +65 -65
  57. package/lib/components/checkbox/CheckBoxStyle.scss +73 -73
  58. package/lib/components/date-range/DateRangeStyle.scss +35 -35
  59. package/lib/components/date-time/DateTimeStyle.scss +9 -9
  60. package/lib/components/dialog/DialogComponent.d.ts +9 -2
  61. package/lib/components/dialog/DialogComponent.js +17 -51
  62. package/lib/components/dropdown-menu/DropdownMenuStyle.scss +48 -48
  63. package/lib/components/expander/ExpanderStyle.scss +61 -61
  64. package/lib/components/form-field/FormFieldStyle.scss +36 -36
  65. package/lib/components/host/RenderHost.d.ts +25 -0
  66. package/lib/components/host/RenderHost.js +63 -0
  67. package/lib/components/loading/LoadingStyle.css +18 -18
  68. package/lib/components/navigation/NavigationStyle.scss +61 -61
  69. package/lib/components/notification/Notification.scss +102 -102
  70. package/lib/components/overlay/OverlayComponent.d.ts +9 -1
  71. package/lib/components/overlay/OverlayComponent.js +22 -13
  72. package/lib/components/overlay/overlay.css +15 -15
  73. package/lib/components/progress/ProgressStyle.scss +4 -4
  74. package/lib/components/ribbon-menu/RibbonMenuStyle.scss +5 -5
  75. package/lib/components/select/SelectStyle.scss +207 -207
  76. package/lib/components/slider/SliderStyle.scss +21 -21
  77. package/lib/components/slider/nouislider.css +15 -15
  78. package/lib/components/stack-panel/SplitterStyle.scss +8 -8
  79. package/lib/components/stack-panel/StackPanelStyle.scss +10 -10
  80. package/lib/components/tabs/TabsStyle.scss +139 -139
  81. package/lib/components/time/TimeComponent.scss +3 -3
  82. package/lib/components/tree-view/TreeViewStyle.scss +14 -14
  83. package/lib/core/helper.js +11 -6
  84. package/lib/grid/plugins/slick.headermenu.css +98 -98
  85. package/lib/grid.css +840 -3532
  86. package/lib/index.css.map +1 -1
  87. package/lib/index.js.map +1 -1
  88. package/lib/ui/auto.suggest.css +30 -30
  89. package/lib/ui/button.css +147 -147
  90. package/lib/ui/date-input.css +10 -10
  91. package/lib/ui/date.picker/css/tiny-date-picker.css +124 -124
  92. package/lib/ui/dialog.css +144 -144
  93. package/lib/ui/input.css +35 -35
  94. package/lib/ui/theme.css +28 -28
  95. package/package.json +1 -1
@@ -1,244 +1,244 @@
1
- import "../../ui/base.css";
2
- import "./cultures";
3
- import { gridShowcase } from "./grids";
4
- import "./themes";
5
- import { dialogShowcase } from "./dialogs";
6
- import { tabsShowcase } from "./tabs";
7
- import { selectShowcase } from "./selects";
8
- import { checkboxShowcase, expanderShowcase } from "./checks-and-expanders";
9
- import { inputShowcase, numberShowcase, formFieldShowcase } from "./fields";
10
- import { notificationShowcase, loadingShowcase, navigationShowcase } from "./feedback-and-navigation";
11
- import { progressShowcase, stackShowcase, treeShowcase, overlayShowcase, ribbonShowcase } from "./layout-and-navigation";
12
- import { sliderShowcase, dateShowcase, dateRangeShowcase, dateTimeShowcase } from "./dates";
13
- import { dropdownMenuShowcase } from "./dropdown-menus";
14
- import { dataBindingShowcase } from "./data-binding";
15
- import { showcaseSources } from "./showcase-sources";
16
- import { IJSLComponent, IJSLVNode, JSLRender } from "jsl-render";
17
- import { ButtonComponent, IButtonOptions } from "../../components/button/ButtonComponent";
18
-
19
- // Add each redesigned component as a section below, with its own navigation entry.
20
- type Content = IJSLVNode | IJSLComponent;
21
- const node = (tag: string, content: string, className?: string): IJSLVNode => ({
22
- tag, content, attr: { class: className }
23
- });
24
- const group = (children: Content[], className = "sample-row"): IJSLVNode => ({
25
- tag: "div", attr: { class: className }, children
26
- });
27
- const button = (options: IButtonOptions) => new ButtonComponent({ type: "button", ...options });
28
-
29
- // Self-contained sample icons. Applications can supply their own VNodes, images,
30
- // icon components, or plain strings; ButtonComponent has no icon-library dependency.
31
- const paths = {
32
- plus: '<path d="M12 5v14M5 12h14"/>',
33
- arrow: '<path d="M5 12h14m-6-6 6 6-6 6"/>',
34
- download: '<path d="M12 3v12m-5-5 5 5 5-5M5 16v4h14v-4"/>',
35
- refresh: '<path d="M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-1l2 6M4 12l2 6a7 7 0 0 0 12-1"/>',
36
- more: '<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',
37
- bookmark: '<path d="M6 3h12v18l-6-4-6 4z"/>',
38
- check: '<path d="m5 12 4 4L19 6"/>'
39
- };
40
- function icon(name: keyof typeof paths): IJSLVNode {
41
- const svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' + paths[name] + '</svg>';
42
- const url = 'url("data:image/svg+xml,' + encodeURIComponent(svg) + '")';
43
- return { tag: "span", attr: { class: "showcase-icon", style: "mask-image:" + url + ";-webkit-mask-image:" + url } };
44
- }
45
-
46
- function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
47
- return {
48
- tag: "article", attr: { class: "sample-card", id, "aria-labelledby": id + "-title" },
49
- children: [
50
- group([node("span", number, "sample-number"), { tag: "h2", content: title, attr: { id: id + "-title" } }], "card-heading"),
51
- node("p", description, "card-description"),
52
- ...children
53
- ]
54
- };
55
- }
56
-
57
- const actionStatus = node("p", "Choose an action to try it.", "sample-status");
58
- actionStatus.attr.role = "status";
59
- const action = (text: string) => () => { actionStatus.content = text; };
60
-
61
- const toggleStatus = node("p", "No formatting selected.", "sample-status");
62
- toggleStatus.attr.role = "status";
63
- const formatting: ButtonComponent[] = [];
64
- const labels = ["Bold", "Italic", "Underline"];
65
- const updateFormatting = () => {
66
- const selected = labels.filter((_, index) => formatting[index].pressed);
67
- toggleStatus.content = selected.length ? "Selected: " + selected.join(", ") + "." : "No formatting selected.";
68
- };
69
- labels.forEach((label, index) => formatting.push(button({
70
- content: label,
71
- icon: { tag: "span", content: label[0], attr: { class: ["format-bold", "format-italic", "format-underline"][index] } },
72
- iconOnly: true, outlined: true, title: label, toggle: true, onToggle: updateFormatting
73
- })));
74
-
75
- const bookmarkStatus = node("p", "Save this view for later.", "sample-status");
76
- bookmarkStatus.attr.role = "status";
77
- const bookmark = button({
78
- content: "Save view", icon: icon("bookmark"), variant: "outline", toggle: true,
79
- onToggle: pressed => { bookmarkStatus.content = pressed ? "View saved. Click again to remove it." : "Save this view for later."; }
80
- });
81
-
82
- const saveStatus = node("p", "Your changes are ready to save.", "context-copy");
83
- saveStatus.attr.role = "status";
84
-
85
- const cards = [
86
- card("hierarchy", "01", "A clear hierarchy", "Three treatments for primary, secondary, and quieter actions.", [
87
- group([
88
- button({ content: "Save changes", click: action("Changes saved.") }),
89
- button({ content: "Cancel", outlined: true, click: action("Action cancelled.") }),
90
- button({ content: "Learn more", variant: "ghost", click: action("Choose solid for the main action, outline for alternatives, and ghost for quieter actions.") })
91
- ]), actionStatus,
92
- node("pre", 'new ButtonComponent({ content: "Save changes" })', "sample-code")
93
- ]),
94
- card("icons", "02", "Icons, with or without text", "Bring your own icons. Place them before or after the label.", [
95
- group([
96
- button({ content: "Create project", icon: icon("plus"), click: action("Project created.") }),
97
- button({ content: "Download", icon: icon("download"), outlined: true, click: action("Download action clicked.") }),
98
- button({ content: "Continue", icon: icon("arrow"), iconPosition: "end", variant: "ghost", click: action("Continue action clicked.") })
99
- ]),
100
- group([
101
- button({ icon: icon("plus"), ariaLabel: "Add item", title: "Add item", click: action("Item added.") }),
102
- button({ icon: icon("refresh"), ariaLabel: "Refresh", title: "Refresh", outlined: true, click: action("View refreshed.") }),
103
- button({ icon: icon("more"), ariaLabel: "More options", title: "More options", variant: "ghost", click: action("More options action clicked.") }),
104
- node("span", "Icon-only buttons have accessible names.", "inline-note")
105
- ]),
106
- node("pre", '{ icon: myIcon, ariaLabel: "Add item" }', "sample-code")
107
- ]),
108
- card("toggles", "03", "Actions that stay selected", "Toggle buttons expose their state to assistive technology. Try a few.", [
109
- { tag: "div", attr: { class: "sample-row", role: "group", "aria-label": "Text formatting" }, children: [
110
- ...formatting,
111
- node("span", "", "sample-divider"),
112
- button({ content: "Reset", variant: "ghost", click: () => {
113
- formatting.forEach(item => { item.pressed = false; });
114
- updateFormatting();
115
- } })
116
- ] },
117
- toggleStatus,
118
- group([bookmark]), bookmarkStatus,
119
- node("pre", '{ toggle: true, pressed: false, onToggle: pressed => { … } }', "sample-code")
120
- ]),
121
- card("sizes", "04", "The right amount of space", "Compact controls for toolbars, comfortable actions for forms.", [
122
- group([
123
- group([button({ content: "Small", icon: icon("plus"), size: "small" }), node("span", "28 px", "size-caption")], "size-sample"),
124
- group([button({ content: "Medium", icon: icon("plus") }), node("span", "32 px · default", "size-caption")], "size-sample"),
125
- group([button({ content: "Large", icon: icon("plus"), size: "large" }), node("span", "40 px", "size-caption")], "size-sample")
126
- ], "sample-row size-row"),
127
- group([
128
- button({ icon: icon("plus"), ariaLabel: "Small add", title: "Small add", size: "small", outlined: true }),
129
- button({ icon: icon("plus"), ariaLabel: "Medium add", title: "Medium add", outlined: true }),
130
- button({ icon: icon("plus"), ariaLabel: "Large add", title: "Large add", size: "large", outlined: true })
131
- ]),
132
- node("pre", '{ size: "small" | "medium" | "large" }', "sample-code")
133
- ]),
134
- card("states", "05", "Every state considered", "Native disabled behavior, a visible keyboard focus ring, and pressed states.", [
135
- group([
136
- button({ content: "Available" }),
137
- button({ content: "Unavailable", enabled: false }),
138
- button({ content: "Unavailable", outlined: true, enabled: false })
139
- ]),
140
- group([
141
- button({ content: "Selected", icon: icon("check"), outlined: true, toggle: true, pressed: true }),
142
- button({ content: "Selected", icon: icon("check"), outlined: true, toggle: true, pressed: true, enabled: false }),
143
- button({ icon: icon("plus"), ariaLabel: "Unavailable add", title: "Unavailable add", variant: "ghost", enabled: false })
144
- ]),
145
- node("p", "Use Tab to explore keyboard focus. Enter and Space activate a focused button.", "inline-note"),
146
- node("pre", '{ enabled: false }', "sample-code")
147
- ]),
148
- card("context", "06", "At home in an application", "Consistent actions, whether they appear on their own or in a footer.", [
149
- group([
150
- group([node("span", "PROJECT SETTINGS", "context-eyebrow"), node("h3", "Keep everything up to date"), saveStatus], "context-body"),
151
- group([
152
- button({ content: "Discard", outlined: true, click: () => { saveStatus.content = "Changes discarded."; } }),
153
- button({ content: "Save changes", icon: icon("check"), click: () => { saveStatus.content = "All changes saved."; } })
154
- ], "context-footer")
155
- ], "context-panel"),
156
- node("p", "The same classes style component buttons, manual buttons, and links.", "inline-note"),
157
- ...["", " jsl-button-outline", " jsl-button-ghost"].map(variant => group([
158
- button({ content: "View projects", variant: variant.includes("outline") ? "outline" : variant.includes("ghost") ? "ghost" : "solid" }),
159
- { tag: "button", attr: { type: "button", class: "jsl-button" + variant }, content: "View projects" },
160
- { tag: "a", attr: { href: "#grids", class: "jsl-button" + variant }, content: "View projects" }
161
- ])),
162
- node("p", "Each row shows a ButtonComponent, a manual <button>, and an <a> link.", "inline-note")
163
- ]),
164
- card("customization", "07", "Make it yours", "Custom content and application colors still fit the same button API.", [
165
- group([
166
- button({ content: { tag: "span", children: [node("span", "Inbox"), node("span", "8", "count-badge")] }, outlined: true }),
167
- button({ content: "Publish", icon: icon("arrow"), iconPosition: "end", class: "brand-teal" })
168
- ]),
169
- node("pre", '.brand-teal {\n --jsl-button-primary: #0f766e;\n --jsl-button-on-primary: #fff;\n --jsl-button-primary-hover: #115e59;\n --jsl-button-primary-active: #134e4a;\n --jsl-button-focus: #0f766e;\n}', "sample-code")
170
- ])
171
- ];
172
-
173
- const usage: IJSLVNode = {
174
- tag: "details", attr: { class: "usage" }, children: [
175
- node("summary", "Usage & compatibility"),
176
- node("p", "Existing content, enabled, class, outlined, style, and click options continue to work. variant takes precedence over outlined when both are supplied."),
177
- node("pre", 'import { ButtonComponent } from "jsl-ui";\n\nnew ButtonComponent({\n content: "Save view",\n icon: myBookmarkIcon,\n outlined: true,\n toggle: true,\n pressed: false,\n type: "button",\n onToggle: pressed => console.log(pressed),\n click: event => console.log(event)\n});', "sample-code"),
178
- node("p", "For an icon-only button, omit content and supply ariaLabel, or set iconOnly: true to visually hide the content while keeping its accessible name. Icons can be strings, VNodes, or IJSLComponents. Keep icons decorative; place interactive elements outside the button."),
179
- node("p", "The pressed option sets the initial toggle state. Read or assign button.pressed to update it later without firing events. User activation updates pressed, then raises onToggle and the existing click event. Toggle state survives jsl-render refreshes, including when a parent creates a new ButtonComponent instance during render."),
180
- node("p", "The native button type is unchanged when type is omitted, including form submission. Use type: 'button' for actions inside a form that should not submit it. Disabled buttons are now natively disabled and skipped during keyboard navigation."),
181
- node("p", "The neutral base palette lives in ui/theme.css. Override --jsl-color-* CSS variables on a container to theme components together, or --jsl-button-* variables to customize just buttons. ButtonComponent imports its own CSS. Vanilla controls receive the same styles through ui/base.css.")
182
- ]
183
- };
184
-
185
- const showcaseContent: IJSLVNode = {
186
- tag: "div", children: [{
187
- tag: "section", attr: { id: "buttons", "aria-labelledby": "buttons-title" }, children: [
188
- group([
189
- group([node("p", "THE ESSENTIALS / 01", "eyebrow"), { tag: "h1", content: "Buttons", attr: { id: "buttons-title" } }, node("p", "A clear next step. A quiet alternative. An action that feels right.", "hero-description")], "hero-copy"),
190
- group([node("span", "INTERACTIVE PREVIEW", "preview-caption"), button({ content: "Create something", icon: icon("plus"), size: "large", click: action("Something created. Your next step starts here.") }), node("span", "Simple by default. Flexible by design.", "preview-note")], "hero-preview")
191
- ], "hero"),
192
- group([node("span", "Overview", "overview-label"), node("span", "3 variants", "overview-stat"), node("span", "3 sizes", "overview-stat"), node("span", "Keyboard accessible", "overview-stat")], "overview-bar"),
193
- group(cards, "sample-grid"), usage
194
- ]
195
- }, dialogShowcase, tabsShowcase, sliderShowcase, dateShowcase, dateRangeShowcase, dateTimeShowcase, selectShowcase, checkboxShowcase, expanderShowcase, inputShowcase, numberShowcase, formFieldShowcase, notificationShowcase, loadingShowcase, navigationShowcase, progressShowcase, stackShowcase, treeShowcase, overlayShowcase, ribbonShowcase, gridShowcase, dropdownMenuShowcase, dataBindingShowcase]
196
- };
197
-
198
- function addCodeViews(content: Content, sectionId?: string): void {
199
- if (!("tag" in content)) return;
200
- const id = content.tag === "section" && content.attr?.id ? content.attr.id : sectionId;
201
- const classes = typeof content.attr?.class === "string" ? content.attr.class.split(/\s+/) : [];
202
- if (classes.includes("sample-card")) {
203
- const source = showcaseSources[content.attr.id || id];
204
- const alreadyHasCode = content.children?.some(child => "tag" in child && child.attr?.class === "showcase-source");
205
- if (source && !alreadyHasCode) {
206
- content.children = content.children || [];
207
- content.children.push({ tag: "details", attr: { class: "showcase-source" }, children: [
208
- node("summary", "Show code"),
209
- { tag: "pre", attr: { class: "sample-code showcase-source-code" }, children: [{ tag: "code", content: source }] }
210
- ] });
211
- }
212
- }
213
- content.children?.forEach(child => addCodeViews(child, id));
214
- }
215
-
216
- addCodeViews(showcaseContent);
217
- JSLRender.PrintRenderTime = false;
218
- new JSLRender(document.getElementById("showcase"), true).render(showcaseContent);
219
-
220
- const navigation = Array.from(document.querySelectorAll<HTMLAnchorElement>(".nav-item, .nav-subitem"));
221
- let navigationScheduled = false;
222
- function updateNavigation() {
223
- navigationScheduled = false;
224
- let current = navigation[0];
225
- for (const link of navigation) {
226
- if (document.querySelector(link.hash).getBoundingClientRect().top <= window.innerHeight * 0.35) {
227
- current = link;
228
- }
229
- }
230
- for (const link of navigation) {
231
- if (link === current) {
232
- link.setAttribute("aria-current", "location");
233
- } else {
234
- link.removeAttribute("aria-current");
235
- }
236
- }
237
- }
238
- window.addEventListener("scroll", () => {
239
- if (!navigationScheduled) {
240
- navigationScheduled = true;
241
- requestAnimationFrame(updateNavigation);
242
- }
243
- }, { passive: true });
244
- updateNavigation();
1
+ import "../../ui/base.css";
2
+ import "./cultures";
3
+ import { gridShowcase } from "./grids";
4
+ import "./themes";
5
+ import { dialogShowcase } from "./dialogs";
6
+ import { tabsShowcase } from "./tabs";
7
+ import { selectShowcase } from "./selects";
8
+ import { checkboxShowcase, expanderShowcase } from "./checks-and-expanders";
9
+ import { inputShowcase, numberShowcase, formFieldShowcase } from "./fields";
10
+ import { notificationShowcase, loadingShowcase, navigationShowcase } from "./feedback-and-navigation";
11
+ import { progressShowcase, stackShowcase, treeShowcase, overlayShowcase, ribbonShowcase } from "./layout-and-navigation";
12
+ import { sliderShowcase, dateShowcase, dateRangeShowcase, dateTimeShowcase } from "./dates";
13
+ import { dropdownMenuShowcase } from "./dropdown-menus";
14
+ import { dataBindingShowcase } from "./data-binding";
15
+ import { showcaseSources } from "./showcase-sources";
16
+ import { IJSLComponent, IJSLVNode, JSLRender } from "jsl-render";
17
+ import { ButtonComponent, IButtonOptions } from "../../components/button/ButtonComponent";
18
+
19
+ // Add each redesigned component as a section below, with its own navigation entry.
20
+ type Content = IJSLVNode | IJSLComponent;
21
+ const node = (tag: string, content: string, className?: string): IJSLVNode => ({
22
+ tag, content, attr: { class: className }
23
+ });
24
+ const group = (children: Content[], className = "sample-row"): IJSLVNode => ({
25
+ tag: "div", attr: { class: className }, children
26
+ });
27
+ const button = (options: IButtonOptions) => new ButtonComponent({ type: "button", ...options });
28
+
29
+ // Self-contained sample icons. Applications can supply their own VNodes, images,
30
+ // icon components, or plain strings; ButtonComponent has no icon-library dependency.
31
+ const paths = {
32
+ plus: '<path d="M12 5v14M5 12h14"/>',
33
+ arrow: '<path d="M5 12h14m-6-6 6 6-6 6"/>',
34
+ download: '<path d="M12 3v12m-5-5 5 5 5-5M5 16v4h14v-4"/>',
35
+ refresh: '<path d="M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-1l2 6M4 12l2 6a7 7 0 0 0 12-1"/>',
36
+ more: '<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',
37
+ bookmark: '<path d="M6 3h12v18l-6-4-6 4z"/>',
38
+ check: '<path d="m5 12 4 4L19 6"/>'
39
+ };
40
+ function icon(name: keyof typeof paths): IJSLVNode {
41
+ const svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' + paths[name] + '</svg>';
42
+ const url = 'url("data:image/svg+xml,' + encodeURIComponent(svg) + '")';
43
+ return { tag: "span", attr: { class: "showcase-icon", style: "mask-image:" + url + ";-webkit-mask-image:" + url } };
44
+ }
45
+
46
+ function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
47
+ return {
48
+ tag: "article", attr: { class: "sample-card", id, "aria-labelledby": id + "-title" },
49
+ children: [
50
+ group([node("span", number, "sample-number"), { tag: "h2", content: title, attr: { id: id + "-title" } }], "card-heading"),
51
+ node("p", description, "card-description"),
52
+ ...children
53
+ ]
54
+ };
55
+ }
56
+
57
+ const actionStatus = node("p", "Choose an action to try it.", "sample-status");
58
+ actionStatus.attr.role = "status";
59
+ const action = (text: string) => () => { actionStatus.content = text; };
60
+
61
+ const toggleStatus = node("p", "No formatting selected.", "sample-status");
62
+ toggleStatus.attr.role = "status";
63
+ const formatting: ButtonComponent[] = [];
64
+ const labels = ["Bold", "Italic", "Underline"];
65
+ const updateFormatting = () => {
66
+ const selected = labels.filter((_, index) => formatting[index].pressed);
67
+ toggleStatus.content = selected.length ? "Selected: " + selected.join(", ") + "." : "No formatting selected.";
68
+ };
69
+ labels.forEach((label, index) => formatting.push(button({
70
+ content: label,
71
+ icon: { tag: "span", content: label[0], attr: { class: ["format-bold", "format-italic", "format-underline"][index] } },
72
+ iconOnly: true, outlined: true, title: label, toggle: true, onToggle: updateFormatting
73
+ })));
74
+
75
+ const bookmarkStatus = node("p", "Save this view for later.", "sample-status");
76
+ bookmarkStatus.attr.role = "status";
77
+ const bookmark = button({
78
+ content: "Save view", icon: icon("bookmark"), variant: "outline", toggle: true,
79
+ onToggle: pressed => { bookmarkStatus.content = pressed ? "View saved. Click again to remove it." : "Save this view for later."; }
80
+ });
81
+
82
+ const saveStatus = node("p", "Your changes are ready to save.", "context-copy");
83
+ saveStatus.attr.role = "status";
84
+
85
+ const cards = [
86
+ card("hierarchy", "01", "A clear hierarchy", "Three treatments for primary, secondary, and quieter actions.", [
87
+ group([
88
+ button({ content: "Save changes", click: action("Changes saved.") }),
89
+ button({ content: "Cancel", outlined: true, click: action("Action cancelled.") }),
90
+ button({ content: "Learn more", variant: "ghost", click: action("Choose solid for the main action, outline for alternatives, and ghost for quieter actions.") })
91
+ ]), actionStatus,
92
+ node("pre", 'new ButtonComponent({ content: "Save changes" })', "sample-code")
93
+ ]),
94
+ card("icons", "02", "Icons, with or without text", "Bring your own icons. Place them before or after the label.", [
95
+ group([
96
+ button({ content: "Create project", icon: icon("plus"), click: action("Project created.") }),
97
+ button({ content: "Download", icon: icon("download"), outlined: true, click: action("Download action clicked.") }),
98
+ button({ content: "Continue", icon: icon("arrow"), iconPosition: "end", variant: "ghost", click: action("Continue action clicked.") })
99
+ ]),
100
+ group([
101
+ button({ icon: icon("plus"), ariaLabel: "Add item", title: "Add item", click: action("Item added.") }),
102
+ button({ icon: icon("refresh"), ariaLabel: "Refresh", title: "Refresh", outlined: true, click: action("View refreshed.") }),
103
+ button({ icon: icon("more"), ariaLabel: "More options", title: "More options", variant: "ghost", click: action("More options action clicked.") }),
104
+ node("span", "Icon-only buttons have accessible names.", "inline-note")
105
+ ]),
106
+ node("pre", '{ icon: myIcon, ariaLabel: "Add item" }', "sample-code")
107
+ ]),
108
+ card("toggles", "03", "Actions that stay selected", "Toggle buttons expose their state to assistive technology. Try a few.", [
109
+ { tag: "div", attr: { class: "sample-row", role: "group", "aria-label": "Text formatting" }, children: [
110
+ ...formatting,
111
+ node("span", "", "sample-divider"),
112
+ button({ content: "Reset", variant: "ghost", click: () => {
113
+ formatting.forEach(item => { item.pressed = false; });
114
+ updateFormatting();
115
+ } })
116
+ ] },
117
+ toggleStatus,
118
+ group([bookmark]), bookmarkStatus,
119
+ node("pre", '{ toggle: true, pressed: false, onToggle: pressed => { … } }', "sample-code")
120
+ ]),
121
+ card("sizes", "04", "The right amount of space", "Compact controls for toolbars, comfortable actions for forms.", [
122
+ group([
123
+ group([button({ content: "Small", icon: icon("plus"), size: "small" }), node("span", "28 px", "size-caption")], "size-sample"),
124
+ group([button({ content: "Medium", icon: icon("plus") }), node("span", "32 px · default", "size-caption")], "size-sample"),
125
+ group([button({ content: "Large", icon: icon("plus"), size: "large" }), node("span", "40 px", "size-caption")], "size-sample")
126
+ ], "sample-row size-row"),
127
+ group([
128
+ button({ icon: icon("plus"), ariaLabel: "Small add", title: "Small add", size: "small", outlined: true }),
129
+ button({ icon: icon("plus"), ariaLabel: "Medium add", title: "Medium add", outlined: true }),
130
+ button({ icon: icon("plus"), ariaLabel: "Large add", title: "Large add", size: "large", outlined: true })
131
+ ]),
132
+ node("pre", '{ size: "small" | "medium" | "large" }', "sample-code")
133
+ ]),
134
+ card("states", "05", "Every state considered", "Native disabled behavior, a visible keyboard focus ring, and pressed states.", [
135
+ group([
136
+ button({ content: "Available" }),
137
+ button({ content: "Unavailable", enabled: false }),
138
+ button({ content: "Unavailable", outlined: true, enabled: false })
139
+ ]),
140
+ group([
141
+ button({ content: "Selected", icon: icon("check"), outlined: true, toggle: true, pressed: true }),
142
+ button({ content: "Selected", icon: icon("check"), outlined: true, toggle: true, pressed: true, enabled: false }),
143
+ button({ icon: icon("plus"), ariaLabel: "Unavailable add", title: "Unavailable add", variant: "ghost", enabled: false })
144
+ ]),
145
+ node("p", "Use Tab to explore keyboard focus. Enter and Space activate a focused button.", "inline-note"),
146
+ node("pre", '{ enabled: false }', "sample-code")
147
+ ]),
148
+ card("context", "06", "At home in an application", "Consistent actions, whether they appear on their own or in a footer.", [
149
+ group([
150
+ group([node("span", "PROJECT SETTINGS", "context-eyebrow"), node("h3", "Keep everything up to date"), saveStatus], "context-body"),
151
+ group([
152
+ button({ content: "Discard", outlined: true, click: () => { saveStatus.content = "Changes discarded."; } }),
153
+ button({ content: "Save changes", icon: icon("check"), click: () => { saveStatus.content = "All changes saved."; } })
154
+ ], "context-footer")
155
+ ], "context-panel"),
156
+ node("p", "The same classes style component buttons, manual buttons, and links.", "inline-note"),
157
+ ...["", " jsl-button-outline", " jsl-button-ghost"].map(variant => group([
158
+ button({ content: "View projects", variant: variant.includes("outline") ? "outline" : variant.includes("ghost") ? "ghost" : "solid" }),
159
+ { tag: "button", attr: { type: "button", class: "jsl-button" + variant }, content: "View projects" },
160
+ { tag: "a", attr: { href: "#grids", class: "jsl-button" + variant }, content: "View projects" }
161
+ ])),
162
+ node("p", "Each row shows a ButtonComponent, a manual <button>, and an <a> link.", "inline-note")
163
+ ]),
164
+ card("customization", "07", "Make it yours", "Custom content and application colors still fit the same button API.", [
165
+ group([
166
+ button({ content: { tag: "span", children: [node("span", "Inbox"), node("span", "8", "count-badge")] }, outlined: true }),
167
+ button({ content: "Publish", icon: icon("arrow"), iconPosition: "end", class: "brand-teal" })
168
+ ]),
169
+ node("pre", '.brand-teal {\n --jsl-button-primary: #0f766e;\n --jsl-button-on-primary: #fff;\n --jsl-button-primary-hover: #115e59;\n --jsl-button-primary-active: #134e4a;\n --jsl-button-focus: #0f766e;\n}', "sample-code")
170
+ ])
171
+ ];
172
+
173
+ const usage: IJSLVNode = {
174
+ tag: "details", attr: { class: "usage" }, children: [
175
+ node("summary", "Usage & compatibility"),
176
+ node("p", "Existing content, enabled, class, outlined, style, and click options continue to work. variant takes precedence over outlined when both are supplied."),
177
+ node("pre", 'import { ButtonComponent } from "jsl-ui";\n\nnew ButtonComponent({\n content: "Save view",\n icon: myBookmarkIcon,\n outlined: true,\n toggle: true,\n pressed: false,\n type: "button",\n onToggle: pressed => console.log(pressed),\n click: event => console.log(event)\n});', "sample-code"),
178
+ node("p", "For an icon-only button, omit content and supply ariaLabel, or set iconOnly: true to visually hide the content while keeping its accessible name. Icons can be strings, VNodes, or IJSLComponents. Keep icons decorative; place interactive elements outside the button."),
179
+ node("p", "The pressed option sets the initial toggle state. Read or assign button.pressed to update it later without firing events. User activation updates pressed, then raises onToggle and the existing click event. Toggle state survives jsl-render refreshes, including when a parent creates a new ButtonComponent instance during render."),
180
+ node("p", "The native button type is unchanged when type is omitted, including form submission. Use type: 'button' for actions inside a form that should not submit it. Disabled buttons are now natively disabled and skipped during keyboard navigation."),
181
+ node("p", "The neutral base palette lives in ui/theme.css. Override --jsl-color-* CSS variables on a container to theme components together, or --jsl-button-* variables to customize just buttons. ButtonComponent imports its own CSS. Vanilla controls receive the same styles through ui/base.css.")
182
+ ]
183
+ };
184
+
185
+ const showcaseContent: IJSLVNode = {
186
+ tag: "div", children: [{
187
+ tag: "section", attr: { id: "buttons", "aria-labelledby": "buttons-title" }, children: [
188
+ group([
189
+ group([node("p", "THE ESSENTIALS / 01", "eyebrow"), { tag: "h1", content: "Buttons", attr: { id: "buttons-title" } }, node("p", "A clear next step. A quiet alternative. An action that feels right.", "hero-description")], "hero-copy"),
190
+ group([node("span", "INTERACTIVE PREVIEW", "preview-caption"), button({ content: "Create something", icon: icon("plus"), size: "large", click: action("Something created. Your next step starts here.") }), node("span", "Simple by default. Flexible by design.", "preview-note")], "hero-preview")
191
+ ], "hero"),
192
+ group([node("span", "Overview", "overview-label"), node("span", "3 variants", "overview-stat"), node("span", "3 sizes", "overview-stat"), node("span", "Keyboard accessible", "overview-stat")], "overview-bar"),
193
+ group(cards, "sample-grid"), usage
194
+ ]
195
+ }, dialogShowcase, tabsShowcase, sliderShowcase, dateShowcase, dateRangeShowcase, dateTimeShowcase, selectShowcase, checkboxShowcase, expanderShowcase, inputShowcase, numberShowcase, formFieldShowcase, notificationShowcase, loadingShowcase, navigationShowcase, progressShowcase, stackShowcase, treeShowcase, overlayShowcase, ribbonShowcase, gridShowcase, dropdownMenuShowcase, dataBindingShowcase]
196
+ };
197
+
198
+ function addCodeViews(content: Content, sectionId?: string): void {
199
+ if (!("tag" in content)) return;
200
+ const id = content.tag === "section" && content.attr?.id ? content.attr.id : sectionId;
201
+ const classes = typeof content.attr?.class === "string" ? content.attr.class.split(/\s+/) : [];
202
+ if (classes.includes("sample-card")) {
203
+ const source = showcaseSources[content.attr.id || id];
204
+ const alreadyHasCode = content.children?.some(child => "tag" in child && child.attr?.class === "showcase-source");
205
+ if (source && !alreadyHasCode) {
206
+ content.children = content.children || [];
207
+ content.children.push({ tag: "details", attr: { class: "showcase-source" }, children: [
208
+ node("summary", "Show code"),
209
+ { tag: "pre", attr: { class: "sample-code showcase-source-code" }, children: [{ tag: "code", content: source }] }
210
+ ] });
211
+ }
212
+ }
213
+ content.children?.forEach(child => addCodeViews(child, id));
214
+ }
215
+
216
+ addCodeViews(showcaseContent);
217
+ JSLRender.PrintRenderTime = false;
218
+ new JSLRender(document.getElementById("showcase"), true).render(showcaseContent);
219
+
220
+ const navigation = Array.from(document.querySelectorAll<HTMLAnchorElement>(".nav-item, .nav-subitem"));
221
+ let navigationScheduled = false;
222
+ function updateNavigation() {
223
+ navigationScheduled = false;
224
+ let current = navigation[0];
225
+ for (const link of navigation) {
226
+ if (document.querySelector(link.hash).getBoundingClientRect().top <= window.innerHeight * 0.35) {
227
+ current = link;
228
+ }
229
+ }
230
+ for (const link of navigation) {
231
+ if (link === current) {
232
+ link.setAttribute("aria-current", "location");
233
+ } else {
234
+ link.removeAttribute("aria-current");
235
+ }
236
+ }
237
+ }
238
+ window.addEventListener("scroll", () => {
239
+ if (!navigationScheduled) {
240
+ navigationScheduled = true;
241
+ requestAnimationFrame(updateNavigation);
242
+ }
243
+ }, { passive: true });
244
+ updateNavigation();