jsl-ui 10.4.4 → 10.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/docs/AutoSuggestComponent.md +17 -17
  2. package/docs/ButtonComponent.md +22 -22
  3. package/docs/CheckBoxComponent.md +12 -12
  4. package/docs/DataBinding.md +19 -19
  5. package/docs/DateComponent.md +12 -12
  6. package/docs/DateRangeComponent.md +13 -13
  7. package/docs/DateTimeComponent.md +14 -14
  8. package/docs/DialogComponent.md +15 -15
  9. package/docs/DropdownMenuComponent.md +22 -22
  10. package/docs/ExpanderComponent.md +13 -13
  11. package/docs/FormComponent.md +15 -15
  12. package/docs/FormFieldComponent.md +15 -15
  13. package/docs/GridComponent.md +39 -39
  14. package/docs/InputComponent.md +15 -15
  15. package/docs/IntervalComponent.md +13 -13
  16. package/docs/LoadingComponent.md +12 -12
  17. package/docs/NavigationComponent.md +17 -17
  18. package/docs/Notification.md +14 -14
  19. package/docs/NotificationComponent.md +13 -13
  20. package/docs/NumberComponent.md +12 -12
  21. package/docs/OverlayComponent.md +13 -13
  22. package/docs/ProgressComponent.md +12 -12
  23. package/docs/README.md +27 -27
  24. package/docs/RibbonMenuComponent.md +14 -14
  25. package/docs/SelectComponent.md +36 -36
  26. package/docs/SliderComponent.md +20 -20
  27. package/docs/SplitterComponent.md +14 -14
  28. package/docs/StackPanelComponent.md +13 -13
  29. package/docs/TabsComponent.md +16 -16
  30. package/docs/TimeComponent.md +13 -13
  31. package/docs/TreeViewComponent.md +16 -16
  32. package/examples/showcase/checks-and-expanders.ts +148 -148
  33. package/examples/showcase/cultures.ts +39 -39
  34. package/examples/showcase/data-binding.ts +138 -138
  35. package/examples/showcase/dates.ts +168 -168
  36. package/examples/showcase/dialogs.ts +184 -184
  37. package/examples/showcase/dropdown-menus.ts +99 -99
  38. package/examples/showcase/feedback-and-navigation.ts +173 -173
  39. package/examples/showcase/fields.ts +166 -166
  40. package/examples/showcase/fonts/OFL-BricolageGrotesque.txt +93 -93
  41. package/examples/showcase/fonts/OFL-Figtree.txt +93 -93
  42. package/examples/showcase/fonts/OFL-Jost.txt +93 -93
  43. package/examples/showcase/generate-sources.cjs +104 -104
  44. package/examples/showcase/grids.ts +484 -484
  45. package/examples/showcase/index.html +71 -71
  46. package/examples/showcase/layout-and-navigation.ts +46 -46
  47. package/examples/showcase/nivona.css +98 -98
  48. package/examples/showcase/package.json +10 -10
  49. package/examples/showcase/selects.ts +184 -184
  50. package/examples/showcase/showcase-sources.ts +94 -94
  51. package/examples/showcase/showcase.css +281 -281
  52. package/examples/showcase/showcase.ts +244 -244
  53. package/examples/showcase/tabs.ts +161 -161
  54. package/examples/showcase/themes.css +83 -83
  55. package/examples/showcase/themes.ts +56 -56
  56. package/examples/showcase/wirtshans.css +65 -65
  57. package/lib/components/checkbox/CheckBoxStyle.scss +73 -73
  58. package/lib/components/date-range/DateRangeStyle.scss +35 -35
  59. package/lib/components/date-time/DateTimeStyle.scss +9 -9
  60. package/lib/components/dialog/DialogComponent.d.ts +9 -2
  61. package/lib/components/dialog/DialogComponent.js +17 -51
  62. package/lib/components/dropdown-menu/DropdownMenuStyle.scss +48 -48
  63. package/lib/components/expander/ExpanderStyle.scss +61 -61
  64. package/lib/components/form-field/FormFieldStyle.scss +36 -36
  65. package/lib/components/host/RenderHost.d.ts +25 -0
  66. package/lib/components/host/RenderHost.js +63 -0
  67. package/lib/components/loading/LoadingStyle.css +18 -18
  68. package/lib/components/navigation/NavigationStyle.scss +61 -61
  69. package/lib/components/notification/Notification.scss +102 -102
  70. package/lib/components/overlay/OverlayComponent.d.ts +9 -1
  71. package/lib/components/overlay/OverlayComponent.js +22 -13
  72. package/lib/components/overlay/overlay.css +15 -15
  73. package/lib/components/progress/ProgressStyle.scss +4 -4
  74. package/lib/components/ribbon-menu/RibbonMenuStyle.scss +5 -5
  75. package/lib/components/select/SelectStyle.scss +207 -207
  76. package/lib/components/slider/SliderStyle.scss +21 -21
  77. package/lib/components/slider/nouislider.css +15 -15
  78. package/lib/components/stack-panel/SplitterStyle.scss +8 -8
  79. package/lib/components/stack-panel/StackPanelStyle.scss +10 -10
  80. package/lib/components/tabs/TabsStyle.scss +139 -139
  81. package/lib/components/time/TimeComponent.scss +3 -3
  82. package/lib/components/tree-view/TreeViewStyle.scss +14 -14
  83. package/lib/grid/plugins/slick.headermenu.css +98 -98
  84. package/lib/grid.css +841 -3514
  85. package/lib/index.css.map +1 -1
  86. package/lib/index.js.map +1 -1
  87. package/lib/ui/auto.suggest.css +30 -30
  88. package/lib/ui/button.css +147 -147
  89. package/lib/ui/date-input.css +10 -10
  90. package/lib/ui/date.picker/css/tiny-date-picker.css +124 -124
  91. package/lib/ui/dialog.css +144 -144
  92. package/lib/ui/input.css +35 -35
  93. package/lib/ui/theme.css +28 -28
  94. package/package.json +1 -1
@@ -1,184 +1,184 @@
1
- import { IJSLVNode } from "jsl-render";
2
- import { DialogComponent } from "../../components/dialog/DialogComponent";
3
- import { ButtonComponent } from "../../components/button/ButtonComponent";
4
-
5
- const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
6
- const actions = (...children: IJSLVNode[]): IJSLVNode => ({ tag: "div", children });
7
- const message = (content: string): IJSLVNode => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
8
- const launch = (content: string, id: string, click: () => void) => new ButtonComponent({ content, class: id, type: "button", outlined: true, click });
9
-
10
- const confirmationStatus = message("Choose an action inside the dialog.");
11
- function showConfirmation() {
12
- DialogComponent.show({
13
- header: "Save your changes?",
14
- content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
15
- text("p", "Your workspace has been updated. Save your changes to keep everything in sync."),
16
- { tag: "div", attr: { class: "dialog-summary" }, children: [
17
- text("span", "Workspace", "dialog-summary-label"), text("strong", "Product design"),
18
- text("span", "Changes", "dialog-summary-label"), text("span", "Settings and permissions")
19
- ] }
20
- ] },
21
- footer: actions(DialogComponent.Cancel(), DialogComponent.Button({
22
- content: "Save changes", class: "dlg-ok-btn",
23
- onClick: () => { confirmationStatus.content = "Changes saved."; }
24
- })),
25
- width: "29rem", showCloseButton: true
26
- });
27
- }
28
-
29
- const formStatus = message("Create a project without leaving the page.");
30
- function showForm() {
31
- const nameId = "showcase-project-name";
32
- const formId = "showcase-project-form";
33
- DialogComponent.show({
34
- header: "Create a project",
35
- content: { tag: "form", attr: { id: formId, class: "showcase-dialog-copy", submit: (event: Event) => event.preventDefault() }, children: [
36
- text("p", "Give your team a place to organize its next idea."),
37
- { tag: "div", attr: { class: "dialog-form-field" }, children: [
38
- { tag: "label", content: "Project name", attr: { for: nameId } },
39
- { tag: "input", attr: { id: nameId, name: "name", type: "text", required: "required", placeholder: "e.g. Website refresh", maxlength: 80 } }
40
- ] },
41
- { tag: "div", attr: { class: "dialog-form-field" }, children: [
42
- { tag: "label", content: "Description (optional)", attr: { for: "showcase-project-notes" } },
43
- { tag: "textarea", attr: { id: "showcase-project-notes", name: "notes", rows: 3, placeholder: "What are you working on?" } }
44
- ] }
45
- ] },
46
- footer: actions(DialogComponent.Cancel(), DialogComponent.Button({
47
- content: "Create project", class: "dlg-ok-btn", onClick: () => {
48
- const form = document.getElementById(formId) as HTMLFormElement;
49
- const name = document.getElementById(nameId) as HTMLInputElement;
50
- if (!form.reportValidity() || !name.value.trim()) {
51
- return false;
52
- }
53
- formStatus.content = 'Project "' + name.value.trim() + '" created.';
54
- }
55
- })),
56
- showCloseButton: true, autoFocus: "#" + nameId, OkOnEnter: true
57
- });
58
- }
59
-
60
- function showLongContent() {
61
- DialogComponent.show({
62
- header: "Workspace access",
63
- content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
64
- text("p", "Review who can access this workspace. The actions stay in view while this list scrolls."),
65
- ...Array.from({ length: 18 }, (_, index): IJSLVNode => ({
66
- tag: "div", attr: { class: "dialog-member" }, children: [
67
- text("span", ("0" + (index + 1)).slice(-2), "dialog-member-avatar"),
68
- { tag: "div", children: [text("strong", "Team member " + (index + 1)), text("span", "member" + (index + 1) + "@example.com")] },
69
- text("span", index === 0 ? "Owner" : "Member", "dialog-member-role")
70
- ]
71
- }))
72
- ] },
73
- footer: actions(DialogComponent.Button({ content: "Done", class: "dlg-ok-btn" })),
74
- width: "36rem", height: "22rem", showCloseButton: true
75
- });
76
- }
77
-
78
- function showWorkspace(modal = true) {
79
- DialogComponent.show({
80
- header: "Workspace details",
81
- content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
82
- text("p", "Drag the title bar to move this dialog. Use the handle in the bottom-right corner to resize it."),
83
- { tag: "div", attr: { class: "dialog-summary" }, children: [
84
- text("span", "Workspace", "dialog-summary-label"), text("strong", "Product design"),
85
- text("span", "Visibility", "dialog-summary-label"), text("span", "Private"),
86
- text("span", "Members", "dialog-summary-label"), text("span", "18 people")
87
- ] },
88
- text("p", modal ? "The background stays still while you work." : "This is a non-modal dialog. You can still use the showcase and change its theme.", "dialog-help")
89
- ] },
90
- footer: actions(DialogComponent.Button({ content: "Done" })),
91
- width: "36rem", height: "15rem", showCloseButton: true,
92
- allowMove: true, allowResize: true, modal,
93
- resizeOptions: { minWidth: 280, minHeight: 240, maxWidth: 960, maxHeight: 760 }
94
- });
95
- }
96
-
97
- const nestedStatus = message("Open a second dialog from the first.");
98
- function showNested() {
99
- DialogComponent.show({
100
- header: "Manage workspace",
101
- content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
102
- text("p", "Review a permission before making changes. Closing the second dialog returns you here."),
103
- new ButtonComponent({ content: "Review permissions", outlined: true, type: "button", class: "dialog-open-nested", click: () => {
104
- DialogComponent.show({
105
- header: "Confirm access",
106
- content: "Allow team members to invite others to this workspace?",
107
- footer: actions(DialogComponent.Cancel(), DialogComponent.Ok(() => { nestedStatus.content = "Permission confirmed."; })),
108
- width: "27rem", showCloseButton: true
109
- });
110
- } })
111
- ] },
112
- footer: actions(DialogComponent.Cancel(), DialogComponent.Button({ content: "Done" })),
113
- width: "30rem", showCloseButton: true
114
- });
115
- }
116
-
117
- const asyncStatus = message("Try saving, or simulate a failed save.");
118
- function showAsync() {
119
- const notice = message("Your changes are ready to save.");
120
- DialogComponent.show({
121
- header: "Save workspace",
122
- content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
123
- text("p", "The save action waits for the result before closing. A failed save keeps the dialog open so you can try again."),
124
- { tag: "label", attr: { class: "dialog-check" }, children: [
125
- { tag: "input", attr: { id: "showcase-failed-save", type: "checkbox" } }, text("span", "Simulate a failed save")
126
- ] }, notice
127
- ] },
128
- footer: actions(DialogComponent.Cancel(), DialogComponent.Button({
129
- content: "Save changes", class: "dlg-ok-btn", onClick: async () => {
130
- const fail = (document.getElementById("showcase-failed-save") as HTMLInputElement).checked;
131
- notice.content = "Saving changes...";
132
- await new Promise(resolve => setTimeout(resolve, 750));
133
- if (fail) {
134
- notice.content = "Could not save. Uncheck the option and try again.";
135
- return false;
136
- }
137
- asyncStatus.content = "Workspace saved successfully.";
138
- }
139
- })),
140
- showCloseButton: true, closeOnOverlayClick: false
141
- });
142
- }
143
-
144
- function card(id: string, number: string, title: string, description: string, children: Array<IJSLVNode | ButtonComponent>): IJSLVNode {
145
- return { tag: "article", attr: { class: "sample-card", id, "aria-labelledby": id + "-title" }, children: [
146
- { tag: "div", attr: { class: "card-heading" }, children: [text("span", number, "sample-number"), { tag: "h3", content: title, attr: { id: id + "-title" } }] },
147
- text("p", description, "card-description"), ...children
148
- ] };
149
- }
150
-
151
- export const dialogShowcase: IJSLVNode = {
152
- tag: "section", attr: { id: "dialogs", class: "component-section", "aria-labelledby": "dialogs-title" }, children: [
153
- { tag: "div", attr: { class: "hero" }, children: [
154
- { tag: "div", attr: { class: "hero-copy" }, children: [
155
- text("p", "THE ESSENTIALS / 02", "eyebrow"),
156
- { tag: "h2", content: "Dialogs", attr: { id: "dialogs-title", class: "section-title" } },
157
- text("p", "A little focus for the task at hand. Clear content, accessible controls, and room to work.", "hero-description")
158
- ] },
159
- { tag: "div", attr: { class: "hero-preview" }, children: [
160
- text("span", "INTERACTIVE PREVIEW", "preview-caption"),
161
- new ButtonComponent({ content: "Open a dialog", size: "large", type: "button", class: "dialog-launch-hero", click: showConfirmation }),
162
- text("span", "Try it in any theme.", "preview-note")
163
- ] }
164
- ] },
165
- { tag: "div", attr: { class: "overview-bar" }, children: [text("span", "Overview", "overview-label"), text("span", "Responsive layout", "overview-stat"), text("span", "Keyboard accessible", "overview-stat")] },
166
- { tag: "div", attr: { class: "sample-grid dialog-sample-grid" }, children: [
167
- card("dialogs-basic", "01", "Focused decisions", "A title, a short explanation, and a clear next step.", [launch("Open confirmation", "dialog-launch-basic", showConfirmation), confirmationStatus]),
168
- card("dialogs-form", "02", "Collect a little more", "Autofocus, native validation, and Enter to confirm. Textareas keep their line breaks.", [launch("Open project form", "dialog-launch-form", showForm), formStatus]),
169
- card("dialogs-scroll", "03", "Room for more", "Long content scrolls within the dialog while the title and actions stay visible.", [launch("Open long content", "dialog-launch-scroll", showLongContent)]),
170
- card("dialogs-resize", "04", "Make room", "Move and resize a dialog, or keep the page interactive with a non-modal version.", [
171
- { tag: "div", attr: { class: "sample-row" }, children: [launch("Move & resize", "dialog-launch-resize", () => showWorkspace()), launch("Non-modal", "dialog-launch-nonmodal", () => showWorkspace(false))] }
172
- ]),
173
- card("dialogs-nested", "05", "One decision at a time", "Nested dialogs keep keyboard focus and Escape scoped to the active dialog.", [launch("Open nested dialogs", "dialog-launch-nested", showNested), nestedStatus]),
174
- card("dialogs-async", "06", "Wait for the result", "Async actions prevent duplicate submissions. Return false to keep the dialog open.", [launch("Try async save", "dialog-launch-async", showAsync), asyncStatus])
175
- ] },
176
- { tag: "details", attr: { class: "usage" }, children: [
177
- text("summary", "Dialog usage & compatibility"),
178
- text("pre", 'DialogComponent.show({\n header: "Save your changes?",\n content: "Your workspace has been updated.",\n footer: { tag: "div", children: [\n DialogComponent.Cancel(),\n DialogComponent.Ok(async () => {\n // Await your save. Return false to keep the dialog open.\n })\n ] },\n showCloseButton: true\n});', "sample-code"),
179
- text("p", "Existing options, getRef().open()/close(), and Button/Ok/Cancel helpers are preserved. Width defaults to 32rem and is constrained to the viewport. Height options still size the content area. Empty footers collapse without reserving space."),
180
- text("p", "Modal dialogs contain Tab navigation, prevent background scrolling, and restore focus to the opener. Non-modal dialogs leave the background interactive. Escape closes only the top dialog. onClose returning false cancels every close route."),
181
- text("p", "The close control is a native button. Use closeButtonLabel to translate its accessible label, or ariaLabel when the header does not provide a suitable dialog name. Dragging and resizing are optional and retain moveOptions and resizeOptions callbacks.")
182
- ] }
183
- ]
184
- };
1
+ import { IJSLVNode } from "jsl-render";
2
+ import { DialogComponent } from "../../components/dialog/DialogComponent";
3
+ import { ButtonComponent } from "../../components/button/ButtonComponent";
4
+
5
+ const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
6
+ const actions = (...children: IJSLVNode[]): IJSLVNode => ({ tag: "div", children });
7
+ const message = (content: string): IJSLVNode => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
8
+ const launch = (content: string, id: string, click: () => void) => new ButtonComponent({ content, class: id, type: "button", outlined: true, click });
9
+
10
+ const confirmationStatus = message("Choose an action inside the dialog.");
11
+ function showConfirmation() {
12
+ DialogComponent.show({
13
+ header: "Save your changes?",
14
+ content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
15
+ text("p", "Your workspace has been updated. Save your changes to keep everything in sync."),
16
+ { tag: "div", attr: { class: "dialog-summary" }, children: [
17
+ text("span", "Workspace", "dialog-summary-label"), text("strong", "Product design"),
18
+ text("span", "Changes", "dialog-summary-label"), text("span", "Settings and permissions")
19
+ ] }
20
+ ] },
21
+ footer: actions(DialogComponent.Cancel(), DialogComponent.Button({
22
+ content: "Save changes", class: "dlg-ok-btn",
23
+ onClick: () => { confirmationStatus.content = "Changes saved."; }
24
+ })),
25
+ width: "29rem", showCloseButton: true
26
+ });
27
+ }
28
+
29
+ const formStatus = message("Create a project without leaving the page.");
30
+ function showForm() {
31
+ const nameId = "showcase-project-name";
32
+ const formId = "showcase-project-form";
33
+ DialogComponent.show({
34
+ header: "Create a project",
35
+ content: { tag: "form", attr: { id: formId, class: "showcase-dialog-copy", submit: (event: Event) => event.preventDefault() }, children: [
36
+ text("p", "Give your team a place to organize its next idea."),
37
+ { tag: "div", attr: { class: "dialog-form-field" }, children: [
38
+ { tag: "label", content: "Project name", attr: { for: nameId } },
39
+ { tag: "input", attr: { id: nameId, name: "name", type: "text", required: "required", placeholder: "e.g. Website refresh", maxlength: 80 } }
40
+ ] },
41
+ { tag: "div", attr: { class: "dialog-form-field" }, children: [
42
+ { tag: "label", content: "Description (optional)", attr: { for: "showcase-project-notes" } },
43
+ { tag: "textarea", attr: { id: "showcase-project-notes", name: "notes", rows: 3, placeholder: "What are you working on?" } }
44
+ ] }
45
+ ] },
46
+ footer: actions(DialogComponent.Cancel(), DialogComponent.Button({
47
+ content: "Create project", class: "dlg-ok-btn", onClick: () => {
48
+ const form = document.getElementById(formId) as HTMLFormElement;
49
+ const name = document.getElementById(nameId) as HTMLInputElement;
50
+ if (!form.reportValidity() || !name.value.trim()) {
51
+ return false;
52
+ }
53
+ formStatus.content = 'Project "' + name.value.trim() + '" created.';
54
+ }
55
+ })),
56
+ showCloseButton: true, autoFocus: "#" + nameId, OkOnEnter: true
57
+ });
58
+ }
59
+
60
+ function showLongContent() {
61
+ DialogComponent.show({
62
+ header: "Workspace access",
63
+ content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
64
+ text("p", "Review who can access this workspace. The actions stay in view while this list scrolls."),
65
+ ...Array.from({ length: 18 }, (_, index): IJSLVNode => ({
66
+ tag: "div", attr: { class: "dialog-member" }, children: [
67
+ text("span", ("0" + (index + 1)).slice(-2), "dialog-member-avatar"),
68
+ { tag: "div", children: [text("strong", "Team member " + (index + 1)), text("span", "member" + (index + 1) + "@example.com")] },
69
+ text("span", index === 0 ? "Owner" : "Member", "dialog-member-role")
70
+ ]
71
+ }))
72
+ ] },
73
+ footer: actions(DialogComponent.Button({ content: "Done", class: "dlg-ok-btn" })),
74
+ width: "36rem", height: "22rem", showCloseButton: true
75
+ });
76
+ }
77
+
78
+ function showWorkspace(modal = true) {
79
+ DialogComponent.show({
80
+ header: "Workspace details",
81
+ content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
82
+ text("p", "Drag the title bar to move this dialog. Use the handle in the bottom-right corner to resize it."),
83
+ { tag: "div", attr: { class: "dialog-summary" }, children: [
84
+ text("span", "Workspace", "dialog-summary-label"), text("strong", "Product design"),
85
+ text("span", "Visibility", "dialog-summary-label"), text("span", "Private"),
86
+ text("span", "Members", "dialog-summary-label"), text("span", "18 people")
87
+ ] },
88
+ text("p", modal ? "The background stays still while you work." : "This is a non-modal dialog. You can still use the showcase and change its theme.", "dialog-help")
89
+ ] },
90
+ footer: actions(DialogComponent.Button({ content: "Done" })),
91
+ width: "36rem", height: "15rem", showCloseButton: true,
92
+ allowMove: true, allowResize: true, modal,
93
+ resizeOptions: { minWidth: 280, minHeight: 240, maxWidth: 960, maxHeight: 760 }
94
+ });
95
+ }
96
+
97
+ const nestedStatus = message("Open a second dialog from the first.");
98
+ function showNested() {
99
+ DialogComponent.show({
100
+ header: "Manage workspace",
101
+ content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
102
+ text("p", "Review a permission before making changes. Closing the second dialog returns you here."),
103
+ new ButtonComponent({ content: "Review permissions", outlined: true, type: "button", class: "dialog-open-nested", click: () => {
104
+ DialogComponent.show({
105
+ header: "Confirm access",
106
+ content: "Allow team members to invite others to this workspace?",
107
+ footer: actions(DialogComponent.Cancel(), DialogComponent.Ok(() => { nestedStatus.content = "Permission confirmed."; })),
108
+ width: "27rem", showCloseButton: true
109
+ });
110
+ } })
111
+ ] },
112
+ footer: actions(DialogComponent.Cancel(), DialogComponent.Button({ content: "Done" })),
113
+ width: "30rem", showCloseButton: true
114
+ });
115
+ }
116
+
117
+ const asyncStatus = message("Try saving, or simulate a failed save.");
118
+ function showAsync() {
119
+ const notice = message("Your changes are ready to save.");
120
+ DialogComponent.show({
121
+ header: "Save workspace",
122
+ content: { tag: "div", attr: { class: "showcase-dialog-copy" }, children: [
123
+ text("p", "The save action waits for the result before closing. A failed save keeps the dialog open so you can try again."),
124
+ { tag: "label", attr: { class: "dialog-check" }, children: [
125
+ { tag: "input", attr: { id: "showcase-failed-save", type: "checkbox" } }, text("span", "Simulate a failed save")
126
+ ] }, notice
127
+ ] },
128
+ footer: actions(DialogComponent.Cancel(), DialogComponent.Button({
129
+ content: "Save changes", class: "dlg-ok-btn", onClick: async () => {
130
+ const fail = (document.getElementById("showcase-failed-save") as HTMLInputElement).checked;
131
+ notice.content = "Saving changes...";
132
+ await new Promise(resolve => setTimeout(resolve, 750));
133
+ if (fail) {
134
+ notice.content = "Could not save. Uncheck the option and try again.";
135
+ return false;
136
+ }
137
+ asyncStatus.content = "Workspace saved successfully.";
138
+ }
139
+ })),
140
+ showCloseButton: true, closeOnOverlayClick: false
141
+ });
142
+ }
143
+
144
+ function card(id: string, number: string, title: string, description: string, children: Array<IJSLVNode | ButtonComponent>): IJSLVNode {
145
+ return { tag: "article", attr: { class: "sample-card", id, "aria-labelledby": id + "-title" }, children: [
146
+ { tag: "div", attr: { class: "card-heading" }, children: [text("span", number, "sample-number"), { tag: "h3", content: title, attr: { id: id + "-title" } }] },
147
+ text("p", description, "card-description"), ...children
148
+ ] };
149
+ }
150
+
151
+ export const dialogShowcase: IJSLVNode = {
152
+ tag: "section", attr: { id: "dialogs", class: "component-section", "aria-labelledby": "dialogs-title" }, children: [
153
+ { tag: "div", attr: { class: "hero" }, children: [
154
+ { tag: "div", attr: { class: "hero-copy" }, children: [
155
+ text("p", "THE ESSENTIALS / 02", "eyebrow"),
156
+ { tag: "h2", content: "Dialogs", attr: { id: "dialogs-title", class: "section-title" } },
157
+ text("p", "A little focus for the task at hand. Clear content, accessible controls, and room to work.", "hero-description")
158
+ ] },
159
+ { tag: "div", attr: { class: "hero-preview" }, children: [
160
+ text("span", "INTERACTIVE PREVIEW", "preview-caption"),
161
+ new ButtonComponent({ content: "Open a dialog", size: "large", type: "button", class: "dialog-launch-hero", click: showConfirmation }),
162
+ text("span", "Try it in any theme.", "preview-note")
163
+ ] }
164
+ ] },
165
+ { tag: "div", attr: { class: "overview-bar" }, children: [text("span", "Overview", "overview-label"), text("span", "Responsive layout", "overview-stat"), text("span", "Keyboard accessible", "overview-stat")] },
166
+ { tag: "div", attr: { class: "sample-grid dialog-sample-grid" }, children: [
167
+ card("dialogs-basic", "01", "Focused decisions", "A title, a short explanation, and a clear next step.", [launch("Open confirmation", "dialog-launch-basic", showConfirmation), confirmationStatus]),
168
+ card("dialogs-form", "02", "Collect a little more", "Autofocus, native validation, and Enter to confirm. Textareas keep their line breaks.", [launch("Open project form", "dialog-launch-form", showForm), formStatus]),
169
+ card("dialogs-scroll", "03", "Room for more", "Long content scrolls within the dialog while the title and actions stay visible.", [launch("Open long content", "dialog-launch-scroll", showLongContent)]),
170
+ card("dialogs-resize", "04", "Make room", "Move and resize a dialog, or keep the page interactive with a non-modal version.", [
171
+ { tag: "div", attr: { class: "sample-row" }, children: [launch("Move & resize", "dialog-launch-resize", () => showWorkspace()), launch("Non-modal", "dialog-launch-nonmodal", () => showWorkspace(false))] }
172
+ ]),
173
+ card("dialogs-nested", "05", "One decision at a time", "Nested dialogs keep keyboard focus and Escape scoped to the active dialog.", [launch("Open nested dialogs", "dialog-launch-nested", showNested), nestedStatus]),
174
+ card("dialogs-async", "06", "Wait for the result", "Async actions prevent duplicate submissions. Return false to keep the dialog open.", [launch("Try async save", "dialog-launch-async", showAsync), asyncStatus])
175
+ ] },
176
+ { tag: "details", attr: { class: "usage" }, children: [
177
+ text("summary", "Dialog usage & compatibility"),
178
+ text("pre", 'DialogComponent.show({\n header: "Save your changes?",\n content: "Your workspace has been updated.",\n footer: { tag: "div", children: [\n DialogComponent.Cancel(),\n DialogComponent.Ok(async () => {\n // Await your save. Return false to keep the dialog open.\n })\n ] },\n showCloseButton: true\n});', "sample-code"),
179
+ text("p", "Existing options, getRef().open()/close(), and Button/Ok/Cancel helpers are preserved. Width defaults to 32rem and is constrained to the viewport. Height options still size the content area. Empty footers collapse without reserving space."),
180
+ text("p", "Modal dialogs contain Tab navigation, prevent background scrolling, and restore focus to the opener. Non-modal dialogs leave the background interactive. Escape closes only the top dialog. onClose returning false cancels every close route."),
181
+ text("p", "The close control is a native button. Use closeButtonLabel to translate its accessible label, or ariaLabel when the header does not provide a suitable dialog name. Dragging and resizing are optional and retain moveOptions and resizeOptions callbacks.")
182
+ ] }
183
+ ]
184
+ };
@@ -1,99 +1,99 @@
1
- import { IJSLComponent, IJSLVNode, JSLRender } from "jsl-render";
2
- import { ButtonComponent } from "../../components/button/ButtonComponent";
3
- import { DropdownMenuComponent } from "../../components/dropdown-menu/DropdownMenuComponent";
4
-
5
- type Content = IJSLVNode | IJSLComponent;
6
- const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
7
- const group = (children: Content[], className = "sample-row"): IJSLVNode => ({ tag: "div", attr: { class: className }, children });
8
- const status = (content: string): IJSLVNode => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
9
- const action = (content: string, click: () => void) => new ButtonComponent({
10
- content, type: "button", class: "jsl-button jsl-button-ghost", click
11
- });
12
- function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
13
- return { tag: "article", attr: { class: "sample-card", id, "aria-labelledby": id + "-title" }, children: [
14
- group([text("span", number, "sample-number"), { tag: "h3", content: title, attr: { id: id + "-title" } }], "card-heading"),
15
- text("p", description, "card-description"), ...children
16
- ] };
17
- }
18
- function updateMessage(target: IJSLVNode, message: string): void {
19
- target.content = message;
20
- JSLRender.lastCreatedRenderer?.refresh();
21
- }
22
-
23
- const previewStatus = status("Choose a menu action.");
24
- const dynamicStatus = status("Open the menu to refresh its items.");
25
- let openCount = 0;
26
-
27
- export const dropdownMenuShowcase: IJSLVNode = {
28
- tag: "section", attr: { id: "dropdown-menus", class: "component-section", "aria-labelledby": "dropdown-menus-title" }, children: [
29
- { tag: "div", attr: { class: "hero" }, children: [
30
- { tag: "div", attr: { class: "hero-copy" }, children: [
31
- text("p", "THE ESSENTIALS / 23", "eyebrow"),
32
- { tag: "h2", content: "Dropdown menus", attr: { id: "dropdown-menus-title", class: "section-title" } },
33
- text("p", "A button opens a compact list of actions, positioned where the button lives.", "hero-description")
34
- ] },
35
- { tag: "div", attr: { class: "hero-preview" }, children: [
36
- text("span", "INTERACTIVE PREVIEW", "preview-caption"),
37
- new DropdownMenuComponent({
38
- content: "Project actions", class: "jsl-button jsl-button-outline", menuLabel: "Project actions",
39
- children: [
40
- action("Edit project", () => updateMessage(previewStatus, "Edit project selected.")),
41
- action("Duplicate project", () => updateMessage(previewStatus, "Project duplicated.")),
42
- action("Archive project", () => updateMessage(previewStatus, "Project archived."))
43
- ],
44
- closeOnClick: true
45
- }),
46
- text("span", "Use Arrow Down to open and explore the menu.", "preview-note")
47
- ] }
48
- ] },
49
- { tag: "div", attr: { class: "overview-bar" }, children: [
50
- text("span", "Trigger-anchored", "overview-label"),
51
- text("span", "Keyboard accessible", "overview-stat"),
52
- text("span", "Dynamic items", "overview-stat")
53
- ] },
54
- { tag: "div", attr: { class: "sample-grid" }, children: [
55
- card("dropdown-actions", "01", "Choose an action", "Menu items can be buttons or links. closeOnClick closes after selection and returns focus to the trigger.", [
56
- group([new DropdownMenuComponent({
57
- content: "More actions", class: "jsl-button jsl-button-outline", menuLabel: "More actions",
58
- closeOnClick: true, placement: "bottom-start", width: "13rem",
59
- children: [
60
- action("Share", () => updateMessage(previewStatus, "Share selected.")),
61
- action("Copy link", () => updateMessage(previewStatus, "Link copied.")),
62
- action("Delete", () => updateMessage(previewStatus, "Delete selected."))
63
- ]
64
- }), previewStatus])
65
- ]),
66
- card("dropdown-dynamic", "02", "Refresh items when opened", "Use onOpen to build a menu from current application data. Return false from the callback to veto opening.", [
67
- group([new DropdownMenuComponent({
68
- content: "Recent reports", class: "jsl-button jsl-button-outline", menuLabel: "Recent reports",
69
- children: [], closeOnClick: true,
70
- onOpen: options => {
71
- openCount++;
72
- options.children = [
73
- action("Report " + openCount, () => updateMessage(dynamicStatus, "Report " + openCount + " opened.")),
74
- action("Refresh list", () => updateMessage(dynamicStatus, "Report list refreshed."))
75
- ];
76
- }
77
- }), dynamicStatus])
78
- ]),
79
- card("dropdown-placement", "03", "Placement and disabled state", "The menu follows its trigger and adjusts near viewport edges. Custom trigger tags remain available for migration.", [
80
- group([
81
- new DropdownMenuComponent({
82
- content: "Top aligned", class: "jsl-button jsl-button-outline", menuLabel: "Top aligned actions",
83
- placement: "top-end", offsetY: -4, children: [action("First action", () => updateMessage(dynamicStatus, "First action selected."))]
84
- }),
85
- new DropdownMenuComponent({
86
- content: "Unavailable", class: "jsl-button jsl-button-outline", disabled: true,
87
- children: [action("Hidden action", () => undefined)]
88
- })
89
- ])
90
- ])
91
- ] },
92
- { tag: "details", attr: { class: "usage" }, children: [
93
- text("summary", "Dropdown menu usage & compatibility"),
94
- text("pre", 'new DropdownMenuComponent({\n content: "Actions", class: "jsl-button jsl-button-outline",\n children: [new ButtonComponent({ content: "Edit", click: edit })],\n closeOnClick: true,\n onOpen: options => { options.children = buildCurrentItems(); }\n});', "sample-code"),
95
- text("p", "The component retains the existing content, rawContent, children, tag, class, style, width, offsetX, disabled, title, closeOnClick, maxHeight, maxWidth, height, onOpen, and close() names. Menus are anchored to the trigger, flip and clamp to the viewport, and stay open by default to support multi-select actions."),
96
- text("p", "Arrow Up/Down opens the menu and places focus on the first or last enabled item. Within the menu, Arrow keys, Home, End, type-ahead, Escape, and Tab are supported. Native button and anchor children receive menu item semantics; custom items can opt in with data-menu-item.")
97
- ] }
98
- ]
99
- };
1
+ import { IJSLComponent, IJSLVNode, JSLRender } from "jsl-render";
2
+ import { ButtonComponent } from "../../components/button/ButtonComponent";
3
+ import { DropdownMenuComponent } from "../../components/dropdown-menu/DropdownMenuComponent";
4
+
5
+ type Content = IJSLVNode | IJSLComponent;
6
+ const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
7
+ const group = (children: Content[], className = "sample-row"): IJSLVNode => ({ tag: "div", attr: { class: className }, children });
8
+ const status = (content: string): IJSLVNode => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
9
+ const action = (content: string, click: () => void) => new ButtonComponent({
10
+ content, type: "button", class: "jsl-button jsl-button-ghost", click
11
+ });
12
+ function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
13
+ return { tag: "article", attr: { class: "sample-card", id, "aria-labelledby": id + "-title" }, children: [
14
+ group([text("span", number, "sample-number"), { tag: "h3", content: title, attr: { id: id + "-title" } }], "card-heading"),
15
+ text("p", description, "card-description"), ...children
16
+ ] };
17
+ }
18
+ function updateMessage(target: IJSLVNode, message: string): void {
19
+ target.content = message;
20
+ JSLRender.lastCreatedRenderer?.refresh();
21
+ }
22
+
23
+ const previewStatus = status("Choose a menu action.");
24
+ const dynamicStatus = status("Open the menu to refresh its items.");
25
+ let openCount = 0;
26
+
27
+ export const dropdownMenuShowcase: IJSLVNode = {
28
+ tag: "section", attr: { id: "dropdown-menus", class: "component-section", "aria-labelledby": "dropdown-menus-title" }, children: [
29
+ { tag: "div", attr: { class: "hero" }, children: [
30
+ { tag: "div", attr: { class: "hero-copy" }, children: [
31
+ text("p", "THE ESSENTIALS / 23", "eyebrow"),
32
+ { tag: "h2", content: "Dropdown menus", attr: { id: "dropdown-menus-title", class: "section-title" } },
33
+ text("p", "A button opens a compact list of actions, positioned where the button lives.", "hero-description")
34
+ ] },
35
+ { tag: "div", attr: { class: "hero-preview" }, children: [
36
+ text("span", "INTERACTIVE PREVIEW", "preview-caption"),
37
+ new DropdownMenuComponent({
38
+ content: "Project actions", class: "jsl-button jsl-button-outline", menuLabel: "Project actions",
39
+ children: [
40
+ action("Edit project", () => updateMessage(previewStatus, "Edit project selected.")),
41
+ action("Duplicate project", () => updateMessage(previewStatus, "Project duplicated.")),
42
+ action("Archive project", () => updateMessage(previewStatus, "Project archived."))
43
+ ],
44
+ closeOnClick: true
45
+ }),
46
+ text("span", "Use Arrow Down to open and explore the menu.", "preview-note")
47
+ ] }
48
+ ] },
49
+ { tag: "div", attr: { class: "overview-bar" }, children: [
50
+ text("span", "Trigger-anchored", "overview-label"),
51
+ text("span", "Keyboard accessible", "overview-stat"),
52
+ text("span", "Dynamic items", "overview-stat")
53
+ ] },
54
+ { tag: "div", attr: { class: "sample-grid" }, children: [
55
+ card("dropdown-actions", "01", "Choose an action", "Menu items can be buttons or links. closeOnClick closes after selection and returns focus to the trigger.", [
56
+ group([new DropdownMenuComponent({
57
+ content: "More actions", class: "jsl-button jsl-button-outline", menuLabel: "More actions",
58
+ closeOnClick: true, placement: "bottom-start", width: "13rem",
59
+ children: [
60
+ action("Share", () => updateMessage(previewStatus, "Share selected.")),
61
+ action("Copy link", () => updateMessage(previewStatus, "Link copied.")),
62
+ action("Delete", () => updateMessage(previewStatus, "Delete selected."))
63
+ ]
64
+ }), previewStatus])
65
+ ]),
66
+ card("dropdown-dynamic", "02", "Refresh items when opened", "Use onOpen to build a menu from current application data. Return false from the callback to veto opening.", [
67
+ group([new DropdownMenuComponent({
68
+ content: "Recent reports", class: "jsl-button jsl-button-outline", menuLabel: "Recent reports",
69
+ children: [], closeOnClick: true,
70
+ onOpen: options => {
71
+ openCount++;
72
+ options.children = [
73
+ action("Report " + openCount, () => updateMessage(dynamicStatus, "Report " + openCount + " opened.")),
74
+ action("Refresh list", () => updateMessage(dynamicStatus, "Report list refreshed."))
75
+ ];
76
+ }
77
+ }), dynamicStatus])
78
+ ]),
79
+ card("dropdown-placement", "03", "Placement and disabled state", "The menu follows its trigger and adjusts near viewport edges. Custom trigger tags remain available for migration.", [
80
+ group([
81
+ new DropdownMenuComponent({
82
+ content: "Top aligned", class: "jsl-button jsl-button-outline", menuLabel: "Top aligned actions",
83
+ placement: "top-end", offsetY: -4, children: [action("First action", () => updateMessage(dynamicStatus, "First action selected."))]
84
+ }),
85
+ new DropdownMenuComponent({
86
+ content: "Unavailable", class: "jsl-button jsl-button-outline", disabled: true,
87
+ children: [action("Hidden action", () => undefined)]
88
+ })
89
+ ])
90
+ ])
91
+ ] },
92
+ { tag: "details", attr: { class: "usage" }, children: [
93
+ text("summary", "Dropdown menu usage & compatibility"),
94
+ text("pre", 'new DropdownMenuComponent({\n content: "Actions", class: "jsl-button jsl-button-outline",\n children: [new ButtonComponent({ content: "Edit", click: edit })],\n closeOnClick: true,\n onOpen: options => { options.children = buildCurrentItems(); }\n});', "sample-code"),
95
+ text("p", "The component retains the existing content, rawContent, children, tag, class, style, width, offsetX, disabled, title, closeOnClick, maxHeight, maxWidth, height, onOpen, and close() names. Menus are anchored to the trigger, flip and clamp to the viewport, and stay open by default to support multi-select actions."),
96
+ text("p", "Arrow Up/Down opens the menu and places focus on the first or last enabled item. Within the menu, Arrow keys, Home, End, type-ahead, Escape, and Tab are supported. Native button and anchor children receive menu item semantics; custom items can opt in with data-menu-item.")
97
+ ] }
98
+ ]
99
+ };