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.
- 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/grid/plugins/slick.headermenu.css +98 -98
- package/lib/grid.css +841 -3514
- 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,168 +1,168 @@
|
|
|
1
|
-
import { IJSLComponent, IJSLVNode, JSLRender } from "jsl-render";
|
|
2
|
-
import { SliderComponent, ISliderValue } from "../../components/slider/SliderComponent";
|
|
3
|
-
import { DateComponent } from "../../components/date/DateComponent";
|
|
4
|
-
import { DateRangeComponent } from "../../components/date-range/DateRangeComponent";
|
|
5
|
-
import { DateTimeComponent } from "../../components/date-time/DateTimeComponent";
|
|
6
|
-
import { ButtonComponent } from "../../components/button/ButtonComponent";
|
|
7
|
-
import { DialogComponent } from "../../components/dialog/DialogComponent";
|
|
8
|
-
import { DatePicker, IDatePicker } from "../../ui/date.picker";
|
|
9
|
-
import { date } from "../../core/date";
|
|
10
|
-
|
|
11
|
-
type Content = IJSLVNode | IJSLComponent;
|
|
12
|
-
const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
|
|
13
|
-
const group = (children: Content[], className?: string): IJSLVNode => ({ tag: "div", attr: { class: className }, children });
|
|
14
|
-
const status = (content: string) => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
|
|
15
|
-
const format = (value: Date) => value ? date.format(value) : "No date selected";
|
|
16
|
-
const day = (n: number, hours = 9, minutes = 30, seconds = 0) => new Date(2026, 9, n, hours, minutes, seconds);
|
|
17
|
-
const code = (content: string) => text("pre", content, "sample-code");
|
|
18
|
-
const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
|
|
19
|
-
const field = (id: string, label: string, control: Content) => group([
|
|
20
|
-
{ tag: "label", content: label, attr: { for: id } }, control
|
|
21
|
-
], "date-showcase-field");
|
|
22
|
-
|
|
23
|
-
const sliderValueText = (value: ISliderValue, suffix = "%") =>
|
|
24
|
-
(Array.isArray(value) ? value : [value]).map(part => Math.round(part) + suffix).join(" - ");
|
|
25
|
-
const sliderChange = (target: IJSLVNode, prefix = "Current value: ", suffix = "%") => (value: ISliderValue) => {
|
|
26
|
-
target.content = prefix + sliderValueText(value, suffix);
|
|
27
|
-
JSLRender.lastCreatedRenderer?.refresh();
|
|
28
|
-
};
|
|
29
|
-
class CalendarSample implements IJSLComponent {
|
|
30
|
-
private picker: IDatePicker;
|
|
31
|
-
render(): IJSLVNode { return group([], "showcase-calendar"); }
|
|
32
|
-
onCreate(node: IJSLVNode) {
|
|
33
|
-
this.picker = DatePicker(node.dom, { mode: "dp-permanent", hilightedDate: day(15) });
|
|
34
|
-
}
|
|
35
|
-
onRemove() { this.picker?.destroy(); }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
|
|
39
|
-
return { tag: "article", attr: { class: "sample-card", id }, children: [
|
|
40
|
-
group([text("span", number, "sample-number"), text("h3", title)], "card-heading"),
|
|
41
|
-
text("p", description, "card-description"), ...children
|
|
42
|
-
] };
|
|
43
|
-
}
|
|
44
|
-
function section(id: string, number: string, title: string, description: string, preview: Content, cards: IJSLVNode[], usage: Content[]): IJSLVNode {
|
|
45
|
-
return { tag: "section", attr: { id, class: "component-section", "aria-labelledby": id + "-title" }, children: [
|
|
46
|
-
group([
|
|
47
|
-
group([text("p", "THE ESSENTIALS / " + number, "eyebrow"),
|
|
48
|
-
{ tag: "h2", content: title, attr: { id: id + "-title", class: "section-title" } },
|
|
49
|
-
text("p", description, "hero-description")], "hero-copy"),
|
|
50
|
-
group([text("span", "INTERACTIVE PREVIEW", "preview-caption"), preview], "hero-preview date-hero-preview")
|
|
51
|
-
], "hero"),
|
|
52
|
-
group(cards, "sample-grid date-sample-grid"),
|
|
53
|
-
{ tag: "details", attr: { class: "usage" }, children: [text("summary", title + " usage & compatibility"), ...usage] }
|
|
54
|
-
] };
|
|
55
|
-
}
|
|
56
|
-
const sliderPreviewStatus = status("Current range: 30% - 75%");
|
|
57
|
-
const sliderSingleStatus = status("Current value: 45%");
|
|
58
|
-
const sliderRangeStatus = status("Selected budget: $25 - $70");
|
|
59
|
-
const sliderPreview = group([new SliderComponent({
|
|
60
|
-
start: [30, 75], range: { min: 0, max: 100 }, connect: true, step: 1,
|
|
61
|
-
tooltips: true, ariaLabel: ["Minimum value", "Maximum value"], class: "showcase-slider",
|
|
62
|
-
onChange: sliderChange(sliderPreviewStatus, "Current range: ")
|
|
63
|
-
}), sliderPreviewStatus], "slider-sample");
|
|
64
|
-
export const sliderShowcase = section("sliders", "04", "Sliders",
|
|
65
|
-
"A lighter track, a precise handle. Move a value or narrow a range.", sliderPreview, [
|
|
66
|
-
card("slider-single", "01", "A single value", "Click the track, drag the handle, or use the arrow keys. Home and End reach the limits.", [
|
|
67
|
-
group([new SliderComponent({
|
|
68
|
-
start: 45, range: { min: 0, max: 100 }, step: 5, tooltips: true,
|
|
69
|
-
ariaLabel: "Notification volume", class: "showcase-slider",
|
|
70
|
-
onChange: sliderChange(sliderSingleStatus)
|
|
71
|
-
}), sliderSingleStatus], "slider-sample slider-with-tooltip")
|
|
72
|
-
]),
|
|
73
|
-
card("slider-range", "02", "Ranges and formatting", "Connect the handles and format their tooltips while values stay numeric in callbacks.", [
|
|
74
|
-
new SliderComponent({
|
|
75
|
-
start: [25, 70], range: { min: 0, max: 100 }, connect: true, step: 5,
|
|
76
|
-
tooltips: [{ to: value => "$" + Math.round(value) }, { to: value => "$" + Math.round(value) }],
|
|
77
|
-
ariaLabel: ["Minimum budget", "Maximum budget"], class: "showcase-slider",
|
|
78
|
-
onChange: sliderChange(sliderRangeStatus, "Selected budget: ", "")
|
|
79
|
-
}), sliderRangeStatus
|
|
80
|
-
]),
|
|
81
|
-
card("slider-states", "03", "Different directions", "Vertical orientation and disabled state are available through component options.", [
|
|
82
|
-
group([new SliderComponent({
|
|
83
|
-
start: 65, range: { min: 0, max: 100 }, orientation: "vertical", direction: "rtl",
|
|
84
|
-
ariaLabel: "Vertical value", class: "showcase-slider-vertical"
|
|
85
|
-
}), group([text("p", "Unavailable range", "inline-note"), new SliderComponent({
|
|
86
|
-
start: [20, 80], range: { min: 0, max: 100 }, connect: true, enabled: false,
|
|
87
|
-
ariaLabel: ["Unavailable minimum", "Unavailable maximum"], class: "showcase-slider"
|
|
88
|
-
})], "slider-disabled-example")
|
|
89
|
-
], "slider-orientations")
|
|
90
|
-
])
|
|
91
|
-
], [
|
|
92
|
-
code('new SliderComponent({\n start: [25, 75], connect: true, step: 1,\n range: { min: 0, max: 100 },\n ariaLabel: ["Minimum value", "Maximum value"],\n onChange: value => console.log(value)\n});'),
|
|
93
|
-
text("p", "SliderComponent wraps the bundled noUiSlider 14.6 API and destroys it when the component is removed. Values are numeric: getValue() returns a number for one handle and a number array for multiple handles. setValue(value) updates silently; pass true as its second argument to fire noUiSlider's set event. onUpdate runs on initialization and every update; onSlide runs while moving; onChange runs after user interaction. Each callback receives (value, handleIndex, allValues)."),
|
|
94
|
-
text("p", "Use ariaLabel for one handle or an ariaLabel array for multiple handles. enabled can be changed later with setEnabled(). getRef() exposes the underlying noUiSlider instance for its full API. Override --jsl-slider-track and --jsl-slider-connect to theme a slider.")
|
|
95
|
-
]);
|
|
96
|
-
const dateStatus = status("Choose a day or enter a date.");
|
|
97
|
-
const customStatus = status("Uses day/month/year formatting.");
|
|
98
|
-
export const dateShowcase = section("dates", "05", "Dates",
|
|
99
|
-
"Type a date or pick a day. A calmer calendar for everyday planning.", new CalendarSample(), [
|
|
100
|
-
card("date-basic", "01", "A date, simply", "Focus the field to open the calendar. Arrow Down moves into it; Escape returns to the field.", [
|
|
101
|
-
field("showcase-date-basic", "Due date", new DateComponent({ id: "showcase-date-basic", value: day(15), onChange: value => { dateStatus.content = format(value); } })),
|
|
102
|
-
dateStatus,
|
|
103
|
-
field("showcase-date-disabled", "Unavailable date", new DateComponent({ id: "showcase-date-disabled", value: day(20), enabled: false }))
|
|
104
|
-
]),
|
|
105
|
-
card("date-custom", "02", "Your format, your availability", "A custom formatter and parser, with October weekdays available for selection.", [
|
|
106
|
-
field("showcase-date-custom", "Appointment date (DD/MM/YYYY)", new DateComponent({
|
|
107
|
-
id: "showcase-date-custom", value: day(19), min: day(1), max: day(31),
|
|
108
|
-
format: value => date.format(value, "dd/mm/yy"),
|
|
109
|
-
parse: value => date.parse(value, "dd/mm/yy"),
|
|
110
|
-
inRange: value => value.getDay() !== 0 && value.getDay() !== 6,
|
|
111
|
-
onChange: value => { customStatus.content = value ? date.format(value, "dd/mm/yy") : "No date selected"; }
|
|
112
|
-
})), customStatus,
|
|
113
|
-
text("p", "Invalid or unavailable dates stay in the field for correction and do not raise onChange.", "inline-note")
|
|
114
|
-
])
|
|
115
|
-
], [
|
|
116
|
-
code('new DateComponent({\n value: new Date(2026, 9, 15),\n min: new Date(2026, 9, 1), max: new Date(2026, 9, 31),\n onChange: value => console.log(value)\n});'),
|
|
117
|
-
text("p", "Formatting, parsing, localization, dateClass, inRange, and getRef options remain available. Empty fields return null. setValue(date) updates the field and calendar silently. getRef().setState(state) retains its selection events; pass true as a second argument for a silent update."),
|
|
118
|
-
text("p", "Calendar controls support Tab, Enter, Space, arrow keys, and Escape. Use ariaLabel or an associated label for the field. Popups within dialogs stay inside the dialog; appendTo allows an explicit popup container.")
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
|
-
const rangeStatus = status("October 8 – October 22, 2026");
|
|
122
|
-
const mainRange = new DateRangeComponent({
|
|
123
|
-
min: day(1), max: day(31), minValue: day(8), maxValue: day(22), increment: "days",
|
|
124
|
-
onChange: value => { rangeStatus.content = format(value.minValue) + " – " + format(value.maxValue); }
|
|
125
|
-
});
|
|
126
|
-
export const dateRangeShowcase = section("date-ranges", "06", "Date ranges",
|
|
127
|
-
"Two dates, one selection. Fine-tune either endpoint or move the handles.", new DateRangeComponent({
|
|
128
|
-
min: day(1), max: day(31), minValue: day(10), maxValue: day(24), increment: "days"
|
|
129
|
-
}), [
|
|
130
|
-
card("range-basic", "01", "Choose a window", "The fields and slider stay in sync. Endpoints stay ordered and within the available dates.", [mainRange, rangeStatus]),
|
|
131
|
-
card("range-disabled", "02", "Fixed and unavailable", "Disabled inputs and handles preserve a range. A single available day is supported too.", [
|
|
132
|
-
new DateRangeComponent({ min: day(1), max: day(31), minValue: day(8), maxValue: day(22), increment: "days", enabled: false }),
|
|
133
|
-
text("p", "One available day", "inline-note"),
|
|
134
|
-
new DateRangeComponent({ min: day(15), max: day(15), increment: "days", ariaLabel: "Single available day" })
|
|
135
|
-
])
|
|
136
|
-
], [
|
|
137
|
-
code('new DateRangeComponent({\n min, max, minValue: start, maxValue: end,\n increment: "days",\n onChange: ({ minValue, maxValue }) => { /* Selected dates */ }\n});'),
|
|
138
|
-
text("p", "getMin(), getMax(), and the existing range options are preserved. Daily increments remain the supported mode. onChange reports both endpoints once for each changed range, and is silent during initialization. enabled, ariaLabel, startLabel, and endLabel are optional additions.")
|
|
139
|
-
]);
|
|
140
|
-
|
|
141
|
-
const timeStatus = status("Pick a date and enter a time.");
|
|
142
|
-
export const dateTimeShowcase = section("date-times", "07", "Date & time",
|
|
143
|
-
"A day and a moment, together. Familiar fields with room for precision.", new DateTimeComponent({
|
|
144
|
-
id: "showcase-datetime-preview", value: day(15, 10, 30), ariaLabel: "Preview appointment"
|
|
145
|
-
}), [
|
|
146
|
-
card("datetime-basic", "01", "Plan a precise moment", "Use hours and minutes, or include seconds when the details matter.", [
|
|
147
|
-
field("showcase-datetime-seconds", "Scheduled start", new DateTimeComponent({
|
|
148
|
-
id: "showcase-datetime-seconds", inputMode: "HourMinuteSecond", value: day(15, 9, 30, 15),
|
|
149
|
-
onChange: value => { timeStatus.content = value ? format(value) + " at " + date.formatTime(value, "HourMinuteSecond") : "No complete date and time"; }
|
|
150
|
-
})), timeStatus,
|
|
151
|
-
field("showcase-datetime-disabled", "Unavailable schedule", new DateTimeComponent({ id: "showcase-datetime-disabled", value: day(15), enabled: false }))
|
|
152
|
-
]),
|
|
153
|
-
card("datetime-dialog", "02", "Schedule in context", "The date picker stays within its dialog while you choose a time.", [
|
|
154
|
-
action("Open scheduler", () => {
|
|
155
|
-
DialogComponent.show({
|
|
156
|
-
header: "Schedule an appointment", width: "28rem",
|
|
157
|
-
content: group([
|
|
158
|
-
text("p", "Choose a date and time. Escape closes the calendar first.", "card-description"),
|
|
159
|
-
field("showcase-dialog-date", "Appointment", new DateTimeComponent({ id: "showcase-dialog-date", value: day(21, 14, 45) }))
|
|
160
|
-
]), footer: group([DialogComponent.Cancel(), DialogComponent.Ok()], "sample-row")
|
|
161
|
-
});
|
|
162
|
-
}), text("p", "Date and time binding modes are shown together in the Data binding section.", "inline-note")
|
|
163
|
-
])
|
|
164
|
-
], [
|
|
165
|
-
code('new DateTimeComponent({\n value: new Date(2026, 9, 15, 9, 30),\n inputMode: "HourMinute", // Or "HourMinuteSecond"\n onChange: value => console.log(value)\n});'),
|
|
166
|
-
text("p", "The existing Date-valued callbacks, converters, getValue(), and getValueAsDate() remain available. An incomplete value returns null; malformed dates and times do not update the model. setValue(date) silently updates both fields. Binding modes are demonstrated in the Data binding section."),
|
|
167
|
-
text("p", "The supplied id belongs to the date field; the time field gets an id with '-time' appended. ariaLabel names the group, and dateAriaLabel and timeAriaLabel can name its fields. Date-only formatting and parsing options apply to the date field.")
|
|
168
|
-
]);
|
|
1
|
+
import { IJSLComponent, IJSLVNode, JSLRender } from "jsl-render";
|
|
2
|
+
import { SliderComponent, ISliderValue } from "../../components/slider/SliderComponent";
|
|
3
|
+
import { DateComponent } from "../../components/date/DateComponent";
|
|
4
|
+
import { DateRangeComponent } from "../../components/date-range/DateRangeComponent";
|
|
5
|
+
import { DateTimeComponent } from "../../components/date-time/DateTimeComponent";
|
|
6
|
+
import { ButtonComponent } from "../../components/button/ButtonComponent";
|
|
7
|
+
import { DialogComponent } from "../../components/dialog/DialogComponent";
|
|
8
|
+
import { DatePicker, IDatePicker } from "../../ui/date.picker";
|
|
9
|
+
import { date } from "../../core/date";
|
|
10
|
+
|
|
11
|
+
type Content = IJSLVNode | IJSLComponent;
|
|
12
|
+
const text = (tag: string, content: string, className?: string): IJSLVNode => ({ tag, content, attr: { class: className } });
|
|
13
|
+
const group = (children: Content[], className?: string): IJSLVNode => ({ tag: "div", attr: { class: className }, children });
|
|
14
|
+
const status = (content: string) => ({ tag: "p", content, attr: { class: "sample-status", role: "status" } });
|
|
15
|
+
const format = (value: Date) => value ? date.format(value) : "No date selected";
|
|
16
|
+
const day = (n: number, hours = 9, minutes = 30, seconds = 0) => new Date(2026, 9, n, hours, minutes, seconds);
|
|
17
|
+
const code = (content: string) => text("pre", content, "sample-code");
|
|
18
|
+
const action = (content: string, click: () => void) => new ButtonComponent({ content, click, type: "button", outlined: true, size: "small" });
|
|
19
|
+
const field = (id: string, label: string, control: Content) => group([
|
|
20
|
+
{ tag: "label", content: label, attr: { for: id } }, control
|
|
21
|
+
], "date-showcase-field");
|
|
22
|
+
|
|
23
|
+
const sliderValueText = (value: ISliderValue, suffix = "%") =>
|
|
24
|
+
(Array.isArray(value) ? value : [value]).map(part => Math.round(part) + suffix).join(" - ");
|
|
25
|
+
const sliderChange = (target: IJSLVNode, prefix = "Current value: ", suffix = "%") => (value: ISliderValue) => {
|
|
26
|
+
target.content = prefix + sliderValueText(value, suffix);
|
|
27
|
+
JSLRender.lastCreatedRenderer?.refresh();
|
|
28
|
+
};
|
|
29
|
+
class CalendarSample implements IJSLComponent {
|
|
30
|
+
private picker: IDatePicker;
|
|
31
|
+
render(): IJSLVNode { return group([], "showcase-calendar"); }
|
|
32
|
+
onCreate(node: IJSLVNode) {
|
|
33
|
+
this.picker = DatePicker(node.dom, { mode: "dp-permanent", hilightedDate: day(15) });
|
|
34
|
+
}
|
|
35
|
+
onRemove() { this.picker?.destroy(); }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function card(id: string, number: string, title: string, description: string, children: Content[]): IJSLVNode {
|
|
39
|
+
return { tag: "article", attr: { class: "sample-card", id }, children: [
|
|
40
|
+
group([text("span", number, "sample-number"), text("h3", title)], "card-heading"),
|
|
41
|
+
text("p", description, "card-description"), ...children
|
|
42
|
+
] };
|
|
43
|
+
}
|
|
44
|
+
function section(id: string, number: string, title: string, description: string, preview: Content, cards: IJSLVNode[], usage: Content[]): IJSLVNode {
|
|
45
|
+
return { tag: "section", attr: { id, class: "component-section", "aria-labelledby": id + "-title" }, children: [
|
|
46
|
+
group([
|
|
47
|
+
group([text("p", "THE ESSENTIALS / " + number, "eyebrow"),
|
|
48
|
+
{ tag: "h2", content: title, attr: { id: id + "-title", class: "section-title" } },
|
|
49
|
+
text("p", description, "hero-description")], "hero-copy"),
|
|
50
|
+
group([text("span", "INTERACTIVE PREVIEW", "preview-caption"), preview], "hero-preview date-hero-preview")
|
|
51
|
+
], "hero"),
|
|
52
|
+
group(cards, "sample-grid date-sample-grid"),
|
|
53
|
+
{ tag: "details", attr: { class: "usage" }, children: [text("summary", title + " usage & compatibility"), ...usage] }
|
|
54
|
+
] };
|
|
55
|
+
}
|
|
56
|
+
const sliderPreviewStatus = status("Current range: 30% - 75%");
|
|
57
|
+
const sliderSingleStatus = status("Current value: 45%");
|
|
58
|
+
const sliderRangeStatus = status("Selected budget: $25 - $70");
|
|
59
|
+
const sliderPreview = group([new SliderComponent({
|
|
60
|
+
start: [30, 75], range: { min: 0, max: 100 }, connect: true, step: 1,
|
|
61
|
+
tooltips: true, ariaLabel: ["Minimum value", "Maximum value"], class: "showcase-slider",
|
|
62
|
+
onChange: sliderChange(sliderPreviewStatus, "Current range: ")
|
|
63
|
+
}), sliderPreviewStatus], "slider-sample");
|
|
64
|
+
export const sliderShowcase = section("sliders", "04", "Sliders",
|
|
65
|
+
"A lighter track, a precise handle. Move a value or narrow a range.", sliderPreview, [
|
|
66
|
+
card("slider-single", "01", "A single value", "Click the track, drag the handle, or use the arrow keys. Home and End reach the limits.", [
|
|
67
|
+
group([new SliderComponent({
|
|
68
|
+
start: 45, range: { min: 0, max: 100 }, step: 5, tooltips: true,
|
|
69
|
+
ariaLabel: "Notification volume", class: "showcase-slider",
|
|
70
|
+
onChange: sliderChange(sliderSingleStatus)
|
|
71
|
+
}), sliderSingleStatus], "slider-sample slider-with-tooltip")
|
|
72
|
+
]),
|
|
73
|
+
card("slider-range", "02", "Ranges and formatting", "Connect the handles and format their tooltips while values stay numeric in callbacks.", [
|
|
74
|
+
new SliderComponent({
|
|
75
|
+
start: [25, 70], range: { min: 0, max: 100 }, connect: true, step: 5,
|
|
76
|
+
tooltips: [{ to: value => "$" + Math.round(value) }, { to: value => "$" + Math.round(value) }],
|
|
77
|
+
ariaLabel: ["Minimum budget", "Maximum budget"], class: "showcase-slider",
|
|
78
|
+
onChange: sliderChange(sliderRangeStatus, "Selected budget: ", "")
|
|
79
|
+
}), sliderRangeStatus
|
|
80
|
+
]),
|
|
81
|
+
card("slider-states", "03", "Different directions", "Vertical orientation and disabled state are available through component options.", [
|
|
82
|
+
group([new SliderComponent({
|
|
83
|
+
start: 65, range: { min: 0, max: 100 }, orientation: "vertical", direction: "rtl",
|
|
84
|
+
ariaLabel: "Vertical value", class: "showcase-slider-vertical"
|
|
85
|
+
}), group([text("p", "Unavailable range", "inline-note"), new SliderComponent({
|
|
86
|
+
start: [20, 80], range: { min: 0, max: 100 }, connect: true, enabled: false,
|
|
87
|
+
ariaLabel: ["Unavailable minimum", "Unavailable maximum"], class: "showcase-slider"
|
|
88
|
+
})], "slider-disabled-example")
|
|
89
|
+
], "slider-orientations")
|
|
90
|
+
])
|
|
91
|
+
], [
|
|
92
|
+
code('new SliderComponent({\n start: [25, 75], connect: true, step: 1,\n range: { min: 0, max: 100 },\n ariaLabel: ["Minimum value", "Maximum value"],\n onChange: value => console.log(value)\n});'),
|
|
93
|
+
text("p", "SliderComponent wraps the bundled noUiSlider 14.6 API and destroys it when the component is removed. Values are numeric: getValue() returns a number for one handle and a number array for multiple handles. setValue(value) updates silently; pass true as its second argument to fire noUiSlider's set event. onUpdate runs on initialization and every update; onSlide runs while moving; onChange runs after user interaction. Each callback receives (value, handleIndex, allValues)."),
|
|
94
|
+
text("p", "Use ariaLabel for one handle or an ariaLabel array for multiple handles. enabled can be changed later with setEnabled(). getRef() exposes the underlying noUiSlider instance for its full API. Override --jsl-slider-track and --jsl-slider-connect to theme a slider.")
|
|
95
|
+
]);
|
|
96
|
+
const dateStatus = status("Choose a day or enter a date.");
|
|
97
|
+
const customStatus = status("Uses day/month/year formatting.");
|
|
98
|
+
export const dateShowcase = section("dates", "05", "Dates",
|
|
99
|
+
"Type a date or pick a day. A calmer calendar for everyday planning.", new CalendarSample(), [
|
|
100
|
+
card("date-basic", "01", "A date, simply", "Focus the field to open the calendar. Arrow Down moves into it; Escape returns to the field.", [
|
|
101
|
+
field("showcase-date-basic", "Due date", new DateComponent({ id: "showcase-date-basic", value: day(15), onChange: value => { dateStatus.content = format(value); } })),
|
|
102
|
+
dateStatus,
|
|
103
|
+
field("showcase-date-disabled", "Unavailable date", new DateComponent({ id: "showcase-date-disabled", value: day(20), enabled: false }))
|
|
104
|
+
]),
|
|
105
|
+
card("date-custom", "02", "Your format, your availability", "A custom formatter and parser, with October weekdays available for selection.", [
|
|
106
|
+
field("showcase-date-custom", "Appointment date (DD/MM/YYYY)", new DateComponent({
|
|
107
|
+
id: "showcase-date-custom", value: day(19), min: day(1), max: day(31),
|
|
108
|
+
format: value => date.format(value, "dd/mm/yy"),
|
|
109
|
+
parse: value => date.parse(value, "dd/mm/yy"),
|
|
110
|
+
inRange: value => value.getDay() !== 0 && value.getDay() !== 6,
|
|
111
|
+
onChange: value => { customStatus.content = value ? date.format(value, "dd/mm/yy") : "No date selected"; }
|
|
112
|
+
})), customStatus,
|
|
113
|
+
text("p", "Invalid or unavailable dates stay in the field for correction and do not raise onChange.", "inline-note")
|
|
114
|
+
])
|
|
115
|
+
], [
|
|
116
|
+
code('new DateComponent({\n value: new Date(2026, 9, 15),\n min: new Date(2026, 9, 1), max: new Date(2026, 9, 31),\n onChange: value => console.log(value)\n});'),
|
|
117
|
+
text("p", "Formatting, parsing, localization, dateClass, inRange, and getRef options remain available. Empty fields return null. setValue(date) updates the field and calendar silently. getRef().setState(state) retains its selection events; pass true as a second argument for a silent update."),
|
|
118
|
+
text("p", "Calendar controls support Tab, Enter, Space, arrow keys, and Escape. Use ariaLabel or an associated label for the field. Popups within dialogs stay inside the dialog; appendTo allows an explicit popup container.")
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
const rangeStatus = status("October 8 – October 22, 2026");
|
|
122
|
+
const mainRange = new DateRangeComponent({
|
|
123
|
+
min: day(1), max: day(31), minValue: day(8), maxValue: day(22), increment: "days",
|
|
124
|
+
onChange: value => { rangeStatus.content = format(value.minValue) + " – " + format(value.maxValue); }
|
|
125
|
+
});
|
|
126
|
+
export const dateRangeShowcase = section("date-ranges", "06", "Date ranges",
|
|
127
|
+
"Two dates, one selection. Fine-tune either endpoint or move the handles.", new DateRangeComponent({
|
|
128
|
+
min: day(1), max: day(31), minValue: day(10), maxValue: day(24), increment: "days"
|
|
129
|
+
}), [
|
|
130
|
+
card("range-basic", "01", "Choose a window", "The fields and slider stay in sync. Endpoints stay ordered and within the available dates.", [mainRange, rangeStatus]),
|
|
131
|
+
card("range-disabled", "02", "Fixed and unavailable", "Disabled inputs and handles preserve a range. A single available day is supported too.", [
|
|
132
|
+
new DateRangeComponent({ min: day(1), max: day(31), minValue: day(8), maxValue: day(22), increment: "days", enabled: false }),
|
|
133
|
+
text("p", "One available day", "inline-note"),
|
|
134
|
+
new DateRangeComponent({ min: day(15), max: day(15), increment: "days", ariaLabel: "Single available day" })
|
|
135
|
+
])
|
|
136
|
+
], [
|
|
137
|
+
code('new DateRangeComponent({\n min, max, minValue: start, maxValue: end,\n increment: "days",\n onChange: ({ minValue, maxValue }) => { /* Selected dates */ }\n});'),
|
|
138
|
+
text("p", "getMin(), getMax(), and the existing range options are preserved. Daily increments remain the supported mode. onChange reports both endpoints once for each changed range, and is silent during initialization. enabled, ariaLabel, startLabel, and endLabel are optional additions.")
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
const timeStatus = status("Pick a date and enter a time.");
|
|
142
|
+
export const dateTimeShowcase = section("date-times", "07", "Date & time",
|
|
143
|
+
"A day and a moment, together. Familiar fields with room for precision.", new DateTimeComponent({
|
|
144
|
+
id: "showcase-datetime-preview", value: day(15, 10, 30), ariaLabel: "Preview appointment"
|
|
145
|
+
}), [
|
|
146
|
+
card("datetime-basic", "01", "Plan a precise moment", "Use hours and minutes, or include seconds when the details matter.", [
|
|
147
|
+
field("showcase-datetime-seconds", "Scheduled start", new DateTimeComponent({
|
|
148
|
+
id: "showcase-datetime-seconds", inputMode: "HourMinuteSecond", value: day(15, 9, 30, 15),
|
|
149
|
+
onChange: value => { timeStatus.content = value ? format(value) + " at " + date.formatTime(value, "HourMinuteSecond") : "No complete date and time"; }
|
|
150
|
+
})), timeStatus,
|
|
151
|
+
field("showcase-datetime-disabled", "Unavailable schedule", new DateTimeComponent({ id: "showcase-datetime-disabled", value: day(15), enabled: false }))
|
|
152
|
+
]),
|
|
153
|
+
card("datetime-dialog", "02", "Schedule in context", "The date picker stays within its dialog while you choose a time.", [
|
|
154
|
+
action("Open scheduler", () => {
|
|
155
|
+
DialogComponent.show({
|
|
156
|
+
header: "Schedule an appointment", width: "28rem",
|
|
157
|
+
content: group([
|
|
158
|
+
text("p", "Choose a date and time. Escape closes the calendar first.", "card-description"),
|
|
159
|
+
field("showcase-dialog-date", "Appointment", new DateTimeComponent({ id: "showcase-dialog-date", value: day(21, 14, 45) }))
|
|
160
|
+
]), footer: group([DialogComponent.Cancel(), DialogComponent.Ok()], "sample-row")
|
|
161
|
+
});
|
|
162
|
+
}), text("p", "Date and time binding modes are shown together in the Data binding section.", "inline-note")
|
|
163
|
+
])
|
|
164
|
+
], [
|
|
165
|
+
code('new DateTimeComponent({\n value: new Date(2026, 9, 15, 9, 30),\n inputMode: "HourMinute", // Or "HourMinuteSecond"\n onChange: value => console.log(value)\n});'),
|
|
166
|
+
text("p", "The existing Date-valued callbacks, converters, getValue(), and getValueAsDate() remain available. An incomplete value returns null; malformed dates and times do not update the model. setValue(date) silently updates both fields. Binding modes are demonstrated in the Data binding section."),
|
|
167
|
+
text("p", "The supplied id belongs to the date field; the time field gets an id with '-time' appended. ariaLabel names the group, and dateAriaLabel and timeAriaLabel can name its fields. Date-only formatting and parsing options apply to the date field.")
|
|
168
|
+
]);
|