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.
- package/docs/AutoSuggestComponent.md +17 -17
- package/docs/ButtonComponent.md +22 -22
- package/docs/CheckBoxComponent.md +12 -12
- package/docs/DataBinding.md +19 -19
- package/docs/DateComponent.md +12 -12
- package/docs/DateRangeComponent.md +13 -13
- package/docs/DateTimeComponent.md +14 -14
- package/docs/DialogComponent.md +15 -15
- package/docs/DropdownMenuComponent.md +22 -22
- package/docs/ExpanderComponent.md +13 -13
- package/docs/FormComponent.md +15 -15
- package/docs/FormFieldComponent.md +15 -15
- package/docs/GridComponent.md +39 -39
- package/docs/InputComponent.md +15 -15
- package/docs/IntervalComponent.md +13 -13
- package/docs/LoadingComponent.md +12 -12
- package/docs/NavigationComponent.md +17 -17
- package/docs/Notification.md +14 -14
- package/docs/NotificationComponent.md +13 -13
- package/docs/NumberComponent.md +12 -12
- package/docs/OverlayComponent.md +13 -13
- package/docs/ProgressComponent.md +12 -12
- package/docs/README.md +27 -27
- package/docs/RibbonMenuComponent.md +14 -14
- package/docs/SelectComponent.md +36 -36
- package/docs/SliderComponent.md +20 -20
- package/docs/SplitterComponent.md +14 -14
- package/docs/StackPanelComponent.md +13 -13
- package/docs/TabsComponent.md +16 -16
- package/docs/TimeComponent.md +13 -13
- package/docs/TreeViewComponent.md +16 -16
- package/examples/showcase/checks-and-expanders.ts +148 -148
- package/examples/showcase/cultures.ts +39 -39
- package/examples/showcase/data-binding.ts +138 -138
- package/examples/showcase/dates.ts +168 -168
- package/examples/showcase/dialogs.ts +184 -184
- package/examples/showcase/dropdown-menus.ts +99 -99
- package/examples/showcase/feedback-and-navigation.ts +173 -173
- package/examples/showcase/fields.ts +166 -166
- package/examples/showcase/fonts/OFL-BricolageGrotesque.txt +93 -93
- package/examples/showcase/fonts/OFL-Figtree.txt +93 -93
- package/examples/showcase/fonts/OFL-Jost.txt +93 -93
- package/examples/showcase/generate-sources.cjs +104 -104
- package/examples/showcase/grids.ts +484 -484
- package/examples/showcase/index.html +71 -71
- package/examples/showcase/layout-and-navigation.ts +46 -46
- package/examples/showcase/nivona.css +98 -98
- package/examples/showcase/package.json +10 -10
- package/examples/showcase/selects.ts +184 -184
- package/examples/showcase/showcase-sources.ts +94 -94
- package/examples/showcase/showcase.css +281 -281
- package/examples/showcase/showcase.ts +244 -244
- package/examples/showcase/tabs.ts +161 -161
- package/examples/showcase/themes.css +83 -83
- package/examples/showcase/themes.ts +56 -56
- package/examples/showcase/wirtshans.css +65 -65
- package/lib/components/checkbox/CheckBoxStyle.scss +73 -73
- package/lib/components/date-range/DateRangeStyle.scss +35 -35
- package/lib/components/date-time/DateTimeStyle.scss +9 -9
- package/lib/components/dialog/DialogComponent.d.ts +9 -2
- package/lib/components/dialog/DialogComponent.js +17 -51
- package/lib/components/dropdown-menu/DropdownMenuStyle.scss +48 -48
- package/lib/components/expander/ExpanderStyle.scss +61 -61
- package/lib/components/form-field/FormFieldStyle.scss +36 -36
- package/lib/components/host/RenderHost.d.ts +25 -0
- package/lib/components/host/RenderHost.js +63 -0
- package/lib/components/loading/LoadingStyle.css +18 -18
- package/lib/components/navigation/NavigationStyle.scss +61 -61
- package/lib/components/notification/Notification.scss +102 -102
- package/lib/components/overlay/OverlayComponent.d.ts +9 -1
- package/lib/components/overlay/OverlayComponent.js +22 -13
- package/lib/components/overlay/overlay.css +15 -15
- package/lib/components/progress/ProgressStyle.scss +4 -4
- package/lib/components/ribbon-menu/RibbonMenuStyle.scss +5 -5
- package/lib/components/select/SelectStyle.scss +207 -207
- package/lib/components/slider/SliderStyle.scss +21 -21
- package/lib/components/slider/nouislider.css +15 -15
- package/lib/components/stack-panel/SplitterStyle.scss +8 -8
- package/lib/components/stack-panel/StackPanelStyle.scss +10 -10
- package/lib/components/tabs/TabsStyle.scss +139 -139
- package/lib/components/time/TimeComponent.scss +3 -3
- package/lib/components/tree-view/TreeViewStyle.scss +14 -14
- package/lib/core/helper.js +11 -6
- package/lib/grid/plugins/slick.headermenu.css +98 -98
- package/lib/grid.css +840 -3532
- package/lib/index.css.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/ui/auto.suggest.css +30 -30
- package/lib/ui/button.css +147 -147
- package/lib/ui/date-input.css +10 -10
- package/lib/ui/date.picker/css/tiny-date-picker.css +124 -124
- package/lib/ui/dialog.css +144 -144
- package/lib/ui/input.css +35 -35
- package/lib/ui/theme.css +28 -28
- package/package.json +1 -1
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
import { IJSLComponent, IJSLVNode } from "jsl-render";
|
|
2
|
-
import { CheckBoxComponent } from "../../components/checkbox/CheckBoxComponent";
|
|
3
|
-
import { ExpanderComponent } from "../../components/expander/ExpanderComponent";
|
|
4
|
-
import { ButtonComponent } from "../../components/button/ButtonComponent";
|
|
5
|
-
|
|
6
|
-
type Content = IJSLVNode | IJSLComponent;
|
|
7
|
-
const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
|
|
8
|
-
const group = (children: Content[], className?: string): IJSLVNode => ({ tag: "div", attr: { class: className }, children });
|
|
9
|
-
const status = (content: string): IJSLVNode => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
|
|
10
|
-
const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
|
|
11
|
-
const copy = (title: string, content: string) => group([text("h4", title), text("p", content)], "expander-example-copy");
|
|
12
|
-
function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
|
|
13
|
-
return { tag: "article", attr: { id, class: "sample-card" }, children: [
|
|
14
|
-
group([text("span", number, "sample-number"), text("h3", title)], "card-heading"),
|
|
15
|
-
text("p", description, "card-description"), ...children
|
|
16
|
-
] };
|
|
17
|
-
}
|
|
18
|
-
function section(id: string, number: string, title: string, description: string, preview: Content, cards: IJSLVNode[], usage: Content[]): IJSLVNode {
|
|
19
|
-
return { tag: "section", attr: { id, class: "component-section", "aria-labelledby": id + "-title" }, children: [
|
|
20
|
-
group([
|
|
21
|
-
group([text("p", "THE ESSENTIALS / " + number, "eyebrow"),
|
|
22
|
-
{ tag: "h2", content: title, attr: { id: id + "-title", class: "section-title" } },
|
|
23
|
-
text("p", description, "hero-description")], "hero-copy"),
|
|
24
|
-
group([text("span", "INTERACTIVE PREVIEW", "preview-caption"), preview], "hero-preview checks-expander-preview")
|
|
25
|
-
], "hero"),
|
|
26
|
-
group(cards, "sample-grid checks-expander-grid"),
|
|
27
|
-
{ tag: "details", attr: { class: "usage" }, children: [text("summary", title + " usage & compatibility"), ...usage] }
|
|
28
|
-
] };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const basicStatus = status("Email updates are off.");
|
|
32
|
-
const partialStatus = status("1 of 3 channels selected.");
|
|
33
|
-
const channels = ["Product news", "Release notes", "Community events"].map((label, index) => new CheckBoxComponent({
|
|
34
|
-
id: "checkbox-channel-" + index, label, value: index === 0,
|
|
35
|
-
onChange: () => syncChannels()
|
|
36
|
-
}));
|
|
37
|
-
const allChannels = new CheckBoxComponent({
|
|
38
|
-
id: "checkbox-all", label: "All updates", indeterminate: true,
|
|
39
|
-
onChange: checked => { channels.forEach(channel => channel.setValue(checked)); syncChannels(); }
|
|
40
|
-
});
|
|
41
|
-
function syncChannels() {
|
|
42
|
-
const count = channels.filter(channel => channel.getValue()).length;
|
|
43
|
-
allChannels.setValue(count === channels.length);
|
|
44
|
-
allChannels.indeterminate = count > 0 && count < channels.length;
|
|
45
|
-
partialStatus.content = count + " of " + channels.length + " channels selected.";
|
|
46
|
-
}
|
|
47
|
-
export const checkboxShowcase = section("checkboxes", "09", "Checkboxes",
|
|
48
|
-
"Small choices, clearly marked. Comfortable labels and a visible place for focus.",
|
|
49
|
-
group([
|
|
50
|
-
new CheckBoxComponent({ label: "Keep me informed", value: true }),
|
|
51
|
-
new CheckBoxComponent({ label: "Share usage insights" })
|
|
52
|
-
], "checkbox-stack"), [
|
|
53
|
-
card("checkbox-basic", "01", "One clear choice", "Click the box or its label. Tab focuses the input; Space changes its state.", [
|
|
54
|
-
new CheckBoxComponent({ id: "checkbox-basic-input", label: "Email me product updates", onChange: checked => {
|
|
55
|
-
basicStatus.content = checked ? "Email updates are on." : "Email updates are off.";
|
|
56
|
-
} }), basicStatus,
|
|
57
|
-
text("pre", '{ label: "Email me product updates", onChange: checked => { ... } }', "sample-code")
|
|
58
|
-
]),
|
|
59
|
-
card("checkbox-states", "02", "A little more context", "Supporting text explains a choice. Disabled controls keep their labels and current state.", [
|
|
60
|
-
group([
|
|
61
|
-
new CheckBoxComponent({ id: "checkbox-description", label: "Remember this workspace", description: "Open this workspace automatically the next time you sign in.", value: true }),
|
|
62
|
-
new CheckBoxComponent({ id: "checkbox-disabled", label: "Managed by your administrator", enabled: false }),
|
|
63
|
-
new CheckBoxComponent({ id: "checkbox-disabled-checked", label: "Security notifications", value: true, enabled: false })
|
|
64
|
-
], "checkbox-stack")
|
|
65
|
-
]),
|
|
66
|
-
card("checkbox-partial", "03", "Some, all, or none", "A mixed parent summarizes its children. Activating it selects or clears the whole group.", [
|
|
67
|
-
group([allChannels, group(channels, "checkbox-child-list")], "checkbox-stack"), partialStatus,
|
|
68
|
-
text("pre", "checkbox.indeterminate = true;\ncheckbox.setValue(true); // Silent checked update", "sample-code")
|
|
69
|
-
])
|
|
70
|
-
], [
|
|
71
|
-
text("pre", 'new CheckBoxComponent({\n label: "Send a weekly digest",\n value: true,\n onChange: checked => console.log(checked)\n});', "sample-code"),
|
|
72
|
-
text("p", "Existing value, label, enabled, class, style, id, onChange, getValue(), and setValue() APIs are preserved. class still applies to the input and style to its wrapper. setValue() updates the control without raising onChange."),
|
|
73
|
-
text("p", "The optional description is associated with the input as supporting text. Use ariaLabel when the visible label is empty. indeterminate sets an initial mixed state; the indeterminate property can update it later. The next user activation clears mixed state and raises the usual boolean change event.")
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
const basicExpanderStatus = status("Details are expanded.");
|
|
77
|
-
const preservedStatus = status("Collapse and reopen to keep your draft.");
|
|
78
|
-
let allowCollapse = false;
|
|
79
|
-
const guardedStatus = status("Closing is currently blocked.");
|
|
80
|
-
const headerStatus = status("The header action has not been used.");
|
|
81
|
-
const nested = new ExpanderComponent({
|
|
82
|
-
header: "Workspace settings",
|
|
83
|
-
body: group([
|
|
84
|
-
new ExpanderComponent({ header: "Notifications", expanded: false, body: group([
|
|
85
|
-
new CheckBoxComponent({ label: "Email notifications", value: true }),
|
|
86
|
-
new CheckBoxComponent({ label: "Desktop notifications" })
|
|
87
|
-
], "checkbox-stack") }),
|
|
88
|
-
new ExpanderComponent({ header: "Privacy", expanded: false, body: copy("Your preferences", "Choose what you share and how your workspace appears to others.") })
|
|
89
|
-
], "expander-stack")
|
|
90
|
-
});
|
|
91
|
-
const customIcons = new ExpanderComponent({
|
|
92
|
-
header: "A different indicator", body: copy("Make it your own", "Supply custom expandedIcon and collapsedIcon nodes to match your application."),
|
|
93
|
-
expanded: false, expandedIcon: text("span", "−", "expander-custom-icon"), collapsedIcon: text("span", "+", "expander-custom-icon")
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
export const expanderShowcase = section("expanders", "10", "Expanders",
|
|
97
|
-
"Keep the overview clear. Open the details when you need them.",
|
|
98
|
-
new ExpanderComponent({ header: "Project details", body: text("p", "A little more context, close at hand.", "expander-preview-copy") }), [
|
|
99
|
-
card("expander-basic", "01", "Details on demand", "The whole header toggles the section. Its native button also responds to Enter and Space.", [
|
|
100
|
-
new ExpanderComponent({
|
|
101
|
-
header: "About this project", body: copy("A place to get started", "Keep the essentials visible and tuck supporting information into a section that is easy to open."),
|
|
102
|
-
onToggle: expanded => { basicExpanderStatus.content = expanded ? "Details are expanded." : "Details are collapsed."; }
|
|
103
|
-
}), basicExpanderStatus
|
|
104
|
-
]),
|
|
105
|
-
card("expander-preserved", "02", "Keep unfinished work", "Collapsing hides the body while keeping its inputs and components mounted.", [
|
|
106
|
-
new ExpanderComponent({
|
|
107
|
-
header: "Project draft",
|
|
108
|
-
body: group([
|
|
109
|
-
{ tag: "label", content: "Project name", attr: { for: "expander-draft" } },
|
|
110
|
-
{ tag: "input", attr: { id: "expander-draft", class: "tabs-draft-input", placeholder: "Type a draft, then collapse this section" } },
|
|
111
|
-
new CheckBoxComponent({ id: "expander-draft-checkbox", label: "Share with my team" })
|
|
112
|
-
], "expander-example-copy"),
|
|
113
|
-
onToggle: expanded => { preservedStatus.content = expanded ? "Your draft is still here." : "Draft hidden and preserved."; }
|
|
114
|
-
}), preservedStatus
|
|
115
|
-
]),
|
|
116
|
-
card("expander-header", "03", "Room for a header action", "Use isToggleOnHeader: false to toggle only with the indicator and keep header actions independent.", [
|
|
117
|
-
new ExpanderComponent({
|
|
118
|
-
isToggleOnHeader: false,
|
|
119
|
-
header: group([text("span", "Team members"), action("Invite", () => { headerStatus.content = "Invite action used. Expansion is unchanged."; })], "expander-rich-header"),
|
|
120
|
-
body: copy("Work together", "Invite people to the workspace and keep everyone in the same place."),
|
|
121
|
-
ariaLabel: "Team members"
|
|
122
|
-
}), headerStatus
|
|
123
|
-
]),
|
|
124
|
-
card("expander-guarded", "04", "Keep important details open", "Return false from onToggle to veto a change. Allow closing with the checkbox below.", [
|
|
125
|
-
new ExpanderComponent({
|
|
126
|
-
header: "Unsaved changes",
|
|
127
|
-
body: copy("A draft needs your attention", "This section stays open until you allow it to close."),
|
|
128
|
-
onToggle: expanding => {
|
|
129
|
-
if (!expanding && !allowCollapse) { guardedStatus.content = "Still open. Allow closing to continue."; return false; }
|
|
130
|
-
guardedStatus.content = expanding ? "Section opened." : "Section closed.";
|
|
131
|
-
}
|
|
132
|
-
}),
|
|
133
|
-
group([new CheckBoxComponent({ id: "expander-allow-close", label: "Allow closing", onChange: value => { allowCollapse = value; } })], "sample-row"),
|
|
134
|
-
guardedStatus
|
|
135
|
-
]),
|
|
136
|
-
card("expander-nested", "05", "One level at a time", "Nested sections stay independent. Opening Notifications or Privacy keeps the parent in place.", [nested]),
|
|
137
|
-
card("expander-options", "06", "A familiar shape, your details", "Custom indicators and disabled toggles use the same surface and theme.", [
|
|
138
|
-
group([
|
|
139
|
-
customIcons,
|
|
140
|
-
new ExpanderComponent({ header: "Unavailable section", body: "This section is not available yet.", expanded: false, enabled: false })
|
|
141
|
-
], "expander-stack")
|
|
142
|
-
])
|
|
143
|
-
], [
|
|
144
|
-
text("pre", 'new ExpanderComponent({\n header: "Project details", body: content, expanded: true,\n onToggle: expanding => { /* Return false to veto. */ }\n});\n\nexpander.setExpanded(false); // Silent update\nexpander.toggle(); // Consults onToggle', "sample-code"),
|
|
145
|
-
text("p", "Both the options constructor and new ExpanderComponent(header, body, expanded) remain supported. expanded still defaults to true. Existing icons, iconSize, isToggleOnHeader, class, style, getIcon(), onToggle, and State.expanded remain available. Optional id, ariaLabel, and enabled add labeling and disabled behavior."),
|
|
146
|
-
text("p", "isExpanded() reads the current state. setExpanded() changes it silently; toggle() follows the same callback and veto rules as user activation. State and panel IDs survive parent renders that create a new ExpanderComponent instance. Collapsing preserves the body and returns focus to the toggle if focus was inside it."),
|
|
147
|
-
text("p", "Custom headers can contain independent buttons, links, and form inputs. Those controls do not toggle the section. The body is a named region connected to its button. Reduced-motion preferences disable the short reveal animation.")
|
|
148
|
-
]);
|
|
1
|
+
import { IJSLComponent, IJSLVNode } from "jsl-render";
|
|
2
|
+
import { CheckBoxComponent } from "../../components/checkbox/CheckBoxComponent";
|
|
3
|
+
import { ExpanderComponent } from "../../components/expander/ExpanderComponent";
|
|
4
|
+
import { ButtonComponent } from "../../components/button/ButtonComponent";
|
|
5
|
+
|
|
6
|
+
type Content = IJSLVNode | IJSLComponent;
|
|
7
|
+
const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
|
|
8
|
+
const group = (children: Content[], className?: string): IJSLVNode => ({ tag: "div", attr: { class: className }, children });
|
|
9
|
+
const status = (content: string): IJSLVNode => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
|
|
10
|
+
const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
|
|
11
|
+
const copy = (title: string, content: string) => group([text("h4", title), text("p", content)], "expander-example-copy");
|
|
12
|
+
function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
|
|
13
|
+
return { tag: "article", attr: { id, class: "sample-card" }, children: [
|
|
14
|
+
group([text("span", number, "sample-number"), text("h3", title)], "card-heading"),
|
|
15
|
+
text("p", description, "card-description"), ...children
|
|
16
|
+
] };
|
|
17
|
+
}
|
|
18
|
+
function section(id: string, number: string, title: string, description: string, preview: Content, cards: IJSLVNode[], usage: Content[]): IJSLVNode {
|
|
19
|
+
return { tag: "section", attr: { id, class: "component-section", "aria-labelledby": id + "-title" }, children: [
|
|
20
|
+
group([
|
|
21
|
+
group([text("p", "THE ESSENTIALS / " + number, "eyebrow"),
|
|
22
|
+
{ tag: "h2", content: title, attr: { id: id + "-title", class: "section-title" } },
|
|
23
|
+
text("p", description, "hero-description")], "hero-copy"),
|
|
24
|
+
group([text("span", "INTERACTIVE PREVIEW", "preview-caption"), preview], "hero-preview checks-expander-preview")
|
|
25
|
+
], "hero"),
|
|
26
|
+
group(cards, "sample-grid checks-expander-grid"),
|
|
27
|
+
{ tag: "details", attr: { class: "usage" }, children: [text("summary", title + " usage & compatibility"), ...usage] }
|
|
28
|
+
] };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const basicStatus = status("Email updates are off.");
|
|
32
|
+
const partialStatus = status("1 of 3 channels selected.");
|
|
33
|
+
const channels = ["Product news", "Release notes", "Community events"].map((label, index) => new CheckBoxComponent({
|
|
34
|
+
id: "checkbox-channel-" + index, label, value: index === 0,
|
|
35
|
+
onChange: () => syncChannels()
|
|
36
|
+
}));
|
|
37
|
+
const allChannels = new CheckBoxComponent({
|
|
38
|
+
id: "checkbox-all", label: "All updates", indeterminate: true,
|
|
39
|
+
onChange: checked => { channels.forEach(channel => channel.setValue(checked)); syncChannels(); }
|
|
40
|
+
});
|
|
41
|
+
function syncChannels() {
|
|
42
|
+
const count = channels.filter(channel => channel.getValue()).length;
|
|
43
|
+
allChannels.setValue(count === channels.length);
|
|
44
|
+
allChannels.indeterminate = count > 0 && count < channels.length;
|
|
45
|
+
partialStatus.content = count + " of " + channels.length + " channels selected.";
|
|
46
|
+
}
|
|
47
|
+
export const checkboxShowcase = section("checkboxes", "09", "Checkboxes",
|
|
48
|
+
"Small choices, clearly marked. Comfortable labels and a visible place for focus.",
|
|
49
|
+
group([
|
|
50
|
+
new CheckBoxComponent({ label: "Keep me informed", value: true }),
|
|
51
|
+
new CheckBoxComponent({ label: "Share usage insights" })
|
|
52
|
+
], "checkbox-stack"), [
|
|
53
|
+
card("checkbox-basic", "01", "One clear choice", "Click the box or its label. Tab focuses the input; Space changes its state.", [
|
|
54
|
+
new CheckBoxComponent({ id: "checkbox-basic-input", label: "Email me product updates", onChange: checked => {
|
|
55
|
+
basicStatus.content = checked ? "Email updates are on." : "Email updates are off.";
|
|
56
|
+
} }), basicStatus,
|
|
57
|
+
text("pre", '{ label: "Email me product updates", onChange: checked => { ... } }', "sample-code")
|
|
58
|
+
]),
|
|
59
|
+
card("checkbox-states", "02", "A little more context", "Supporting text explains a choice. Disabled controls keep their labels and current state.", [
|
|
60
|
+
group([
|
|
61
|
+
new CheckBoxComponent({ id: "checkbox-description", label: "Remember this workspace", description: "Open this workspace automatically the next time you sign in.", value: true }),
|
|
62
|
+
new CheckBoxComponent({ id: "checkbox-disabled", label: "Managed by your administrator", enabled: false }),
|
|
63
|
+
new CheckBoxComponent({ id: "checkbox-disabled-checked", label: "Security notifications", value: true, enabled: false })
|
|
64
|
+
], "checkbox-stack")
|
|
65
|
+
]),
|
|
66
|
+
card("checkbox-partial", "03", "Some, all, or none", "A mixed parent summarizes its children. Activating it selects or clears the whole group.", [
|
|
67
|
+
group([allChannels, group(channels, "checkbox-child-list")], "checkbox-stack"), partialStatus,
|
|
68
|
+
text("pre", "checkbox.indeterminate = true;\ncheckbox.setValue(true); // Silent checked update", "sample-code")
|
|
69
|
+
])
|
|
70
|
+
], [
|
|
71
|
+
text("pre", 'new CheckBoxComponent({\n label: "Send a weekly digest",\n value: true,\n onChange: checked => console.log(checked)\n});', "sample-code"),
|
|
72
|
+
text("p", "Existing value, label, enabled, class, style, id, onChange, getValue(), and setValue() APIs are preserved. class still applies to the input and style to its wrapper. setValue() updates the control without raising onChange."),
|
|
73
|
+
text("p", "The optional description is associated with the input as supporting text. Use ariaLabel when the visible label is empty. indeterminate sets an initial mixed state; the indeterminate property can update it later. The next user activation clears mixed state and raises the usual boolean change event.")
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
const basicExpanderStatus = status("Details are expanded.");
|
|
77
|
+
const preservedStatus = status("Collapse and reopen to keep your draft.");
|
|
78
|
+
let allowCollapse = false;
|
|
79
|
+
const guardedStatus = status("Closing is currently blocked.");
|
|
80
|
+
const headerStatus = status("The header action has not been used.");
|
|
81
|
+
const nested = new ExpanderComponent({
|
|
82
|
+
header: "Workspace settings",
|
|
83
|
+
body: group([
|
|
84
|
+
new ExpanderComponent({ header: "Notifications", expanded: false, body: group([
|
|
85
|
+
new CheckBoxComponent({ label: "Email notifications", value: true }),
|
|
86
|
+
new CheckBoxComponent({ label: "Desktop notifications" })
|
|
87
|
+
], "checkbox-stack") }),
|
|
88
|
+
new ExpanderComponent({ header: "Privacy", expanded: false, body: copy("Your preferences", "Choose what you share and how your workspace appears to others.") })
|
|
89
|
+
], "expander-stack")
|
|
90
|
+
});
|
|
91
|
+
const customIcons = new ExpanderComponent({
|
|
92
|
+
header: "A different indicator", body: copy("Make it your own", "Supply custom expandedIcon and collapsedIcon nodes to match your application."),
|
|
93
|
+
expanded: false, expandedIcon: text("span", "−", "expander-custom-icon"), collapsedIcon: text("span", "+", "expander-custom-icon")
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const expanderShowcase = section("expanders", "10", "Expanders",
|
|
97
|
+
"Keep the overview clear. Open the details when you need them.",
|
|
98
|
+
new ExpanderComponent({ header: "Project details", body: text("p", "A little more context, close at hand.", "expander-preview-copy") }), [
|
|
99
|
+
card("expander-basic", "01", "Details on demand", "The whole header toggles the section. Its native button also responds to Enter and Space.", [
|
|
100
|
+
new ExpanderComponent({
|
|
101
|
+
header: "About this project", body: copy("A place to get started", "Keep the essentials visible and tuck supporting information into a section that is easy to open."),
|
|
102
|
+
onToggle: expanded => { basicExpanderStatus.content = expanded ? "Details are expanded." : "Details are collapsed."; }
|
|
103
|
+
}), basicExpanderStatus
|
|
104
|
+
]),
|
|
105
|
+
card("expander-preserved", "02", "Keep unfinished work", "Collapsing hides the body while keeping its inputs and components mounted.", [
|
|
106
|
+
new ExpanderComponent({
|
|
107
|
+
header: "Project draft",
|
|
108
|
+
body: group([
|
|
109
|
+
{ tag: "label", content: "Project name", attr: { for: "expander-draft" } },
|
|
110
|
+
{ tag: "input", attr: { id: "expander-draft", class: "tabs-draft-input", placeholder: "Type a draft, then collapse this section" } },
|
|
111
|
+
new CheckBoxComponent({ id: "expander-draft-checkbox", label: "Share with my team" })
|
|
112
|
+
], "expander-example-copy"),
|
|
113
|
+
onToggle: expanded => { preservedStatus.content = expanded ? "Your draft is still here." : "Draft hidden and preserved."; }
|
|
114
|
+
}), preservedStatus
|
|
115
|
+
]),
|
|
116
|
+
card("expander-header", "03", "Room for a header action", "Use isToggleOnHeader: false to toggle only with the indicator and keep header actions independent.", [
|
|
117
|
+
new ExpanderComponent({
|
|
118
|
+
isToggleOnHeader: false,
|
|
119
|
+
header: group([text("span", "Team members"), action("Invite", () => { headerStatus.content = "Invite action used. Expansion is unchanged."; })], "expander-rich-header"),
|
|
120
|
+
body: copy("Work together", "Invite people to the workspace and keep everyone in the same place."),
|
|
121
|
+
ariaLabel: "Team members"
|
|
122
|
+
}), headerStatus
|
|
123
|
+
]),
|
|
124
|
+
card("expander-guarded", "04", "Keep important details open", "Return false from onToggle to veto a change. Allow closing with the checkbox below.", [
|
|
125
|
+
new ExpanderComponent({
|
|
126
|
+
header: "Unsaved changes",
|
|
127
|
+
body: copy("A draft needs your attention", "This section stays open until you allow it to close."),
|
|
128
|
+
onToggle: expanding => {
|
|
129
|
+
if (!expanding && !allowCollapse) { guardedStatus.content = "Still open. Allow closing to continue."; return false; }
|
|
130
|
+
guardedStatus.content = expanding ? "Section opened." : "Section closed.";
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
group([new CheckBoxComponent({ id: "expander-allow-close", label: "Allow closing", onChange: value => { allowCollapse = value; } })], "sample-row"),
|
|
134
|
+
guardedStatus
|
|
135
|
+
]),
|
|
136
|
+
card("expander-nested", "05", "One level at a time", "Nested sections stay independent. Opening Notifications or Privacy keeps the parent in place.", [nested]),
|
|
137
|
+
card("expander-options", "06", "A familiar shape, your details", "Custom indicators and disabled toggles use the same surface and theme.", [
|
|
138
|
+
group([
|
|
139
|
+
customIcons,
|
|
140
|
+
new ExpanderComponent({ header: "Unavailable section", body: "This section is not available yet.", expanded: false, enabled: false })
|
|
141
|
+
], "expander-stack")
|
|
142
|
+
])
|
|
143
|
+
], [
|
|
144
|
+
text("pre", 'new ExpanderComponent({\n header: "Project details", body: content, expanded: true,\n onToggle: expanding => { /* Return false to veto. */ }\n});\n\nexpander.setExpanded(false); // Silent update\nexpander.toggle(); // Consults onToggle', "sample-code"),
|
|
145
|
+
text("p", "Both the options constructor and new ExpanderComponent(header, body, expanded) remain supported. expanded still defaults to true. Existing icons, iconSize, isToggleOnHeader, class, style, getIcon(), onToggle, and State.expanded remain available. Optional id, ariaLabel, and enabled add labeling and disabled behavior."),
|
|
146
|
+
text("p", "isExpanded() reads the current state. setExpanded() changes it silently; toggle() follows the same callback and veto rules as user activation. State and panel IDs survive parent renders that create a new ExpanderComponent instance. Collapsing preserves the body and returns focus to the toggle if focus was inside it."),
|
|
147
|
+
text("p", "Custom headers can contain independent buttons, links, and form inputs. Those controls do not toggle the section. The body is a named region connected to its button. Reduced-motion preferences disable the short reveal animation.")
|
|
148
|
+
]);
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import culture from "../../core/culture";
|
|
2
|
-
import { date } from "../../core/date";
|
|
3
|
-
import { numeric } from "../../core/numeric";
|
|
4
|
-
|
|
5
|
-
export const showcaseCultures = [
|
|
6
|
-
{ id: "", label: "Default (ISO)" },
|
|
7
|
-
{ id: "de", label: "Deutsch (de)" },
|
|
8
|
-
{ id: "en-us", label: "English (en-us)" },
|
|
9
|
-
{ id: "en-gb", label: "English (en-gb)" }
|
|
10
|
-
] as const;
|
|
11
|
-
|
|
12
|
-
const storageKey = "jsl-showcase-culture";
|
|
13
|
-
const picker = document.getElementById("showcase-culture") as HTMLSelectElement;
|
|
14
|
-
const preview = document.getElementById("showcase-format-preview");
|
|
15
|
-
const normalize = (id: string) => showcaseCultures.find(item => item.id === id?.toLowerCase())?.id ?? "";
|
|
16
|
-
let saved = "";
|
|
17
|
-
try { saved = localStorage.getItem(storageKey) ?? ""; } catch { /* URL selection works without storage. */ }
|
|
18
|
-
const selected = normalize(new URL(location.href).searchParams.get("culture") ?? saved);
|
|
19
|
-
|
|
20
|
-
// This module runs before sample modules construct controls with formatted values.
|
|
21
|
-
culture.set(selected);
|
|
22
|
-
picker.replaceChildren(...showcaseCultures.map(item => {
|
|
23
|
-
const option = document.createElement("option");
|
|
24
|
-
option.value = item.id; option.textContent = item.label;
|
|
25
|
-
return option;
|
|
26
|
-
}));
|
|
27
|
-
picker.value = selected;
|
|
28
|
-
preview.textContent = date.format(new Date(2026, 9, 23)) + " · " + numeric.format(1234.56, "#,0.00");
|
|
29
|
-
|
|
30
|
-
/** Reinitialize the examples so existing input strings aren't parsed under a new culture. */
|
|
31
|
-
export function changeCulture(id: string): void {
|
|
32
|
-
const next = normalize(id);
|
|
33
|
-
if (next === selected) { return; }
|
|
34
|
-
try { localStorage.setItem(storageKey, next); } catch { /* Keep selection in the URL instead. */ }
|
|
35
|
-
const url = new URL(location.href);
|
|
36
|
-
url.searchParams.set("culture", next);
|
|
37
|
-
location.assign(url.href);
|
|
38
|
-
}
|
|
39
|
-
picker.addEventListener("change", () => changeCulture(picker.value));
|
|
1
|
+
import culture from "../../core/culture";
|
|
2
|
+
import { date } from "../../core/date";
|
|
3
|
+
import { numeric } from "../../core/numeric";
|
|
4
|
+
|
|
5
|
+
export const showcaseCultures = [
|
|
6
|
+
{ id: "", label: "Default (ISO)" },
|
|
7
|
+
{ id: "de", label: "Deutsch (de)" },
|
|
8
|
+
{ id: "en-us", label: "English (en-us)" },
|
|
9
|
+
{ id: "en-gb", label: "English (en-gb)" }
|
|
10
|
+
] as const;
|
|
11
|
+
|
|
12
|
+
const storageKey = "jsl-showcase-culture";
|
|
13
|
+
const picker = document.getElementById("showcase-culture") as HTMLSelectElement;
|
|
14
|
+
const preview = document.getElementById("showcase-format-preview");
|
|
15
|
+
const normalize = (id: string) => showcaseCultures.find(item => item.id === id?.toLowerCase())?.id ?? "";
|
|
16
|
+
let saved = "";
|
|
17
|
+
try { saved = localStorage.getItem(storageKey) ?? ""; } catch { /* URL selection works without storage. */ }
|
|
18
|
+
const selected = normalize(new URL(location.href).searchParams.get("culture") ?? saved);
|
|
19
|
+
|
|
20
|
+
// This module runs before sample modules construct controls with formatted values.
|
|
21
|
+
culture.set(selected);
|
|
22
|
+
picker.replaceChildren(...showcaseCultures.map(item => {
|
|
23
|
+
const option = document.createElement("option");
|
|
24
|
+
option.value = item.id; option.textContent = item.label;
|
|
25
|
+
return option;
|
|
26
|
+
}));
|
|
27
|
+
picker.value = selected;
|
|
28
|
+
preview.textContent = date.format(new Date(2026, 9, 23)) + " · " + numeric.format(1234.56, "#,0.00");
|
|
29
|
+
|
|
30
|
+
/** Reinitialize the examples so existing input strings aren't parsed under a new culture. */
|
|
31
|
+
export function changeCulture(id: string): void {
|
|
32
|
+
const next = normalize(id);
|
|
33
|
+
if (next === selected) { return; }
|
|
34
|
+
try { localStorage.setItem(storageKey, next); } catch { /* Keep selection in the URL instead. */ }
|
|
35
|
+
const url = new URL(location.href);
|
|
36
|
+
url.searchParams.set("culture", next);
|
|
37
|
+
location.assign(url.href);
|
|
38
|
+
}
|
|
39
|
+
picker.addEventListener("change", () => changeCulture(picker.value));
|