@syware/jlib 0.12.0 → 0.13.0
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/README.md +1 -1
- package/dist/atoms/jl-avatar.css.js +1 -1
- package/dist/atoms/jl-avatar.js +1 -8
- package/dist/atoms/jl-button.css.js +1 -1
- package/dist/atoms/jl-button.js +4 -6
- package/dist/atoms/jl-checkbox.css.js +1 -1
- package/dist/atoms/jl-checkbox.js +8 -10
- package/dist/atoms/jl-chip.css.js +1 -1
- package/dist/atoms/jl-chip.js +3 -11
- package/dist/atoms/jl-divider.css.js +1 -1
- package/dist/atoms/jl-divider.js +1 -5
- package/dist/atoms/jl-icon.css.js +1 -1
- package/dist/atoms/jl-icon.d.ts +2 -0
- package/dist/atoms/jl-icon.js +5 -1
- package/dist/atoms/jl-input.d.ts +7 -2
- package/dist/atoms/jl-input.js +36 -31
- package/dist/atoms/jl-link.css.js +1 -1
- package/dist/atoms/jl-link.js +3 -6
- package/dist/atoms/jl-rating.css.js +1 -1
- package/dist/atoms/jl-rating.d.ts +2 -2
- package/dist/atoms/jl-rating.js +17 -35
- package/dist/atoms/jl-select.d.ts +8 -3
- package/dist/atoms/jl-select.js +26 -13
- package/dist/atoms/jl-skeleton.d.ts +1 -0
- package/dist/atoms/jl-skeleton.js +4 -1
- package/dist/atoms/jl-slider.d.ts +4 -0
- package/dist/atoms/jl-slider.js +29 -15
- package/dist/atoms/jl-switch.css.js +1 -1
- package/dist/atoms/jl-switch.js +2 -8
- package/dist/atoms/jl-textarea.css.js +1 -1
- package/dist/atoms/jl-textarea.d.ts +4 -5
- package/dist/atoms/jl-textarea.js +15 -30
- package/dist/lib/calendar.js +3 -2
- package/dist/lib/floating.d.ts +10 -0
- package/dist/lib/floating.js +27 -8
- package/dist/lib/flow.d.ts +7 -3
- package/dist/lib/flow.js +19 -8
- package/dist/lib/indicator.d.ts +16 -0
- package/dist/lib/indicator.js +32 -6
- package/dist/lib/intl.d.ts +6 -0
- package/dist/lib/intl.js +19 -0
- package/dist/lib/palette.js +1 -6
- package/dist/lib/table.d.ts +14 -2
- package/dist/lib/table.js +50 -39
- package/dist/molecules/jl-accordion-item.css.js +1 -1
- package/dist/molecules/jl-accordion-item.js +1 -5
- package/dist/molecules/jl-account-button.css.js +1 -1
- package/dist/molecules/jl-account-button.js +1 -5
- package/dist/molecules/jl-alert.css.js +1 -1
- package/dist/molecules/jl-alert.d.ts +5 -5
- package/dist/molecules/jl-alert.js +4 -13
- package/dist/molecules/jl-avatar-group.d.ts +7 -5
- package/dist/molecules/jl-avatar-group.js +15 -5
- package/dist/molecules/jl-breadcrumb.d.ts +7 -4
- package/dist/molecules/jl-breadcrumb.js +32 -8
- package/dist/molecules/jl-calendar.d.ts +12 -3
- package/dist/molecules/jl-calendar.js +79 -48
- package/dist/molecules/jl-card.css.js +1 -1
- package/dist/molecules/jl-card.js +2 -8
- package/dist/molecules/jl-chip-group.css.js +1 -1
- package/dist/molecules/jl-chip-group.d.ts +6 -2
- package/dist/molecules/jl-chip-group.js +13 -18
- package/dist/molecules/jl-code-block.css.js +1 -1
- package/dist/molecules/jl-code-block.d.ts +7 -5
- package/dist/molecules/jl-code-block.js +19 -22
- package/dist/molecules/jl-combobox.css.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +4 -0
- package/dist/molecules/jl-combobox.js +33 -19
- package/dist/molecules/jl-date-picker.d.ts +6 -0
- package/dist/molecules/jl-date-picker.js +29 -9
- package/dist/molecules/jl-empty.css.js +1 -1
- package/dist/molecules/jl-empty.js +4 -19
- package/dist/molecules/jl-field.css.js +1 -1
- package/dist/molecules/jl-field.d.ts +7 -1
- package/dist/molecules/jl-field.js +35 -23
- package/dist/molecules/jl-file-drop.css.js +1 -1
- package/dist/molecules/jl-file-drop.js +1 -3
- package/dist/molecules/jl-input-list.css.js +1 -1
- package/dist/molecules/jl-input-list.d.ts +12 -1
- package/dist/molecules/jl-input-list.js +81 -51
- package/dist/molecules/jl-list-item.css.js +1 -1
- package/dist/molecules/jl-list-item.d.ts +3 -1
- package/dist/molecules/jl-list-item.js +26 -27
- package/dist/molecules/jl-load-state.css.js +1 -1
- package/dist/molecules/jl-load-state.d.ts +6 -1
- package/dist/molecules/jl-load-state.js +15 -18
- package/dist/molecules/jl-menu.d.ts +1 -0
- package/dist/molecules/jl-menu.js +9 -2
- package/dist/molecules/jl-pagination.css.js +1 -1
- package/dist/molecules/jl-pagination.d.ts +7 -1
- package/dist/molecules/jl-pagination.js +43 -35
- package/dist/molecules/jl-search.css.js +1 -1
- package/dist/molecules/jl-search.js +4 -12
- package/dist/molecules/jl-segmented.css.js +1 -1
- package/dist/molecules/jl-segmented.d.ts +4 -2
- package/dist/molecules/jl-segmented.js +19 -26
- package/dist/molecules/jl-stat.css.js +1 -1
- package/dist/molecules/jl-stat.js +2 -8
- package/dist/molecules/jl-steps.d.ts +10 -3
- package/dist/molecules/jl-steps.js +82 -49
- package/dist/molecules/jl-tabs.d.ts +5 -2
- package/dist/molecules/jl-tabs.js +31 -25
- package/dist/molecules/jl-tag-input.css.js +1 -1
- package/dist/molecules/jl-tag-input.d.ts +13 -1
- package/dist/molecules/jl-tag-input.js +57 -30
- package/dist/molecules/jl-timeline.css.js +1 -1
- package/dist/molecules/jl-timeline.d.ts +3 -1
- package/dist/molecules/jl-timeline.js +9 -14
- package/dist/molecules/jl-toast.css.js +1 -1
- package/dist/molecules/jl-toast.js +2 -10
- package/dist/molecules/jl-tooltip.d.ts +2 -1
- package/dist/molecules/jl-tooltip.js +11 -15
- package/dist/organisms/jl-command-palette.css.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +8 -1
- package/dist/organisms/jl-command-palette.js +73 -42
- package/dist/organisms/jl-confirm.css.js +1 -1
- package/dist/organisms/jl-confirm.js +1 -5
- package/dist/organisms/jl-dialog.css.js +1 -1
- package/dist/organisms/jl-dialog.js +1 -5
- package/dist/organisms/jl-drawer.css.js +1 -1
- package/dist/organisms/jl-drawer.js +1 -3
- package/dist/organisms/jl-flow.d.ts +18 -2
- package/dist/organisms/jl-flow.js +128 -44
- package/dist/organisms/jl-navbar.css.js +1 -1
- package/dist/organisms/jl-navbar.d.ts +1 -1
- package/dist/organisms/jl-navbar.js +3 -5
- package/dist/organisms/jl-page-header.css.js +1 -1
- package/dist/organisms/jl-page-header.js +1 -5
- package/dist/organisms/jl-page-outlet.d.ts +4 -3
- package/dist/organisms/jl-page-outlet.js +7 -8
- package/dist/organisms/jl-side-nav.css.js +1 -1
- package/dist/organisms/jl-side-nav.d.ts +9 -2
- package/dist/organisms/jl-side-nav.js +44 -16
- package/dist/organisms/jl-tab-bar.css.js +1 -1
- package/dist/organisms/jl-tab-bar.js +0 -2
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +18 -6
- package/dist/organisms/jl-table.js +91 -57
- package/dist/organisms/jl-tree.css.js +1 -1
- package/dist/organisms/jl-tree.d.ts +22 -2
- package/dist/organisms/jl-tree.js +101 -41
- package/package.json +1 -1
|
@@ -10,20 +10,21 @@ export declare class JlBreadcrumb<Id extends string = string> extends JlElement
|
|
|
10
10
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
11
11
|
select: Id;
|
|
12
12
|
}>>;
|
|
13
|
-
readonly items: Readonly<Readonly<{
|
|
14
|
-
get(): BreadcrumbItem<Id>[];
|
|
15
|
-
set(setter: BreadcrumbItem<Id>[] | ((prevState: BreadcrumbItem<Id>[]) => BreadcrumbItem<Id>[])): void;
|
|
16
|
-
}>>;
|
|
17
13
|
/** The most items shown before the middle folds; 0 never folds. */
|
|
18
14
|
readonly max: Readonly<Readonly<{
|
|
19
15
|
get(): number;
|
|
20
16
|
set(setter: number | ((prevState: number) => number)): void;
|
|
21
17
|
}>>;
|
|
18
|
+
readonly items: Readonly<Readonly<{
|
|
19
|
+
get(): BreadcrumbItem<Id>[];
|
|
20
|
+
set(setter: BreadcrumbItem<Id>[] | ((prevState: BreadcrumbItem<Id>[]) => BreadcrumbItem<Id>[])): void;
|
|
21
|
+
}>>;
|
|
22
22
|
/** The trail's name for screen readers. */
|
|
23
23
|
readonly label: Readonly<Readonly<{
|
|
24
24
|
get(): string;
|
|
25
25
|
set(setter: string | ((prevState: string) => string)): void;
|
|
26
26
|
}>>;
|
|
27
|
+
/** `drawn` is what the trail was made from: the inputs call back with what they hold as the trail connects. */
|
|
27
28
|
private readonly _state;
|
|
28
29
|
private readonly _refs;
|
|
29
30
|
templateHtml(): Node;
|
|
@@ -34,6 +35,8 @@ export declare class JlBreadcrumb<Id extends string = string> extends JlElement
|
|
|
34
35
|
/** A new trail starts folded. */
|
|
35
36
|
private renderTrail;
|
|
36
37
|
private render;
|
|
38
|
+
/** The folding button says how many items it holds, in jlib's language. */
|
|
39
|
+
private renderMoreLabel;
|
|
37
40
|
/** An item the app follows, found among the items by the id its button carries. */
|
|
38
41
|
private follow;
|
|
39
42
|
private crumb;
|
|
@@ -38,15 +38,23 @@ function visibleCrumbs(items, max, expanded) {
|
|
|
38
38
|
var JlBreadcrumb = class extends JlElement {
|
|
39
39
|
static selector = "jl-breadcrumb";
|
|
40
40
|
events = this.useEvents();
|
|
41
|
+
/** The most items shown before the middle folds; 0 never folds. */
|
|
42
|
+
max = this.useChange(0, () => this.render(), { attribute: "max" });
|
|
41
43
|
items = this.useChange([], () => this.renderTrail(), {
|
|
42
44
|
attribute: "items",
|
|
43
45
|
parse: jsonOf([])
|
|
44
46
|
});
|
|
45
|
-
/** The most items shown before the middle folds; 0 never folds. */
|
|
46
|
-
max = this.useChange(0, () => this.render(), { attribute: "max" });
|
|
47
47
|
/** The trail's name for screen readers. */
|
|
48
48
|
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
49
|
-
|
|
49
|
+
/** `drawn` is what the trail was made from: the inputs call back with what they hold as the trail connects. */
|
|
50
|
+
_state = {
|
|
51
|
+
drawn: {
|
|
52
|
+
expanded: false,
|
|
53
|
+
items: null,
|
|
54
|
+
max: 0
|
|
55
|
+
},
|
|
56
|
+
expanded: false
|
|
57
|
+
};
|
|
50
58
|
_refs = this.useRefs((ref) => ({
|
|
51
59
|
list: ref("ol"),
|
|
52
60
|
nav: ref("nav")
|
|
@@ -72,7 +80,7 @@ var JlBreadcrumb = class extends JlElement {
|
|
|
72
80
|
}
|
|
73
81
|
drawTexts() {
|
|
74
82
|
this.renderLabel();
|
|
75
|
-
this.
|
|
83
|
+
this.renderMoreLabel();
|
|
76
84
|
}
|
|
77
85
|
renderLabel() {
|
|
78
86
|
this._refs.nav.setAttribute("aria-label", this.label.get() || jlText("breadcrumb"));
|
|
@@ -84,13 +92,31 @@ var JlBreadcrumb = class extends JlElement {
|
|
|
84
92
|
}
|
|
85
93
|
render() {
|
|
86
94
|
const items = this.items.get();
|
|
87
|
-
const
|
|
95
|
+
const max = this.max.get();
|
|
96
|
+
const expanded = this._state.expanded;
|
|
97
|
+
const drawn = this._state.drawn;
|
|
98
|
+
if (items === drawn.items && max === drawn.max && expanded === drawn.expanded) return;
|
|
99
|
+
this._state.drawn = {
|
|
100
|
+
expanded,
|
|
101
|
+
items,
|
|
102
|
+
max
|
|
103
|
+
};
|
|
104
|
+
const crumbs = visibleCrumbs(items, max, expanded);
|
|
88
105
|
const lastIndex = items.length - 1;
|
|
89
106
|
this._refs.list.replaceChildren(...crumbs.map((crumb, position) => /* @__PURE__ */ jsxs("li", { children: [position > 0 ? /* @__PURE__ */ jsx(JlIcon, {
|
|
90
107
|
class: "separator",
|
|
91
108
|
name: "chevron-right",
|
|
92
109
|
size: SEPARATOR_SIZE
|
|
93
110
|
}) : "", "hidden" in crumb ? this.moreButton(crumb.hidden) : this.crumb(crumb.item, crumb.index === lastIndex)] })));
|
|
111
|
+
this.renderMoreLabel();
|
|
112
|
+
}
|
|
113
|
+
/** The folding button says how many items it holds, in jlib's language. */
|
|
114
|
+
renderMoreLabel() {
|
|
115
|
+
const more = this._refs.list.querySelector(".more");
|
|
116
|
+
if (more === null) return;
|
|
117
|
+
const label = jlText("showMoreCount", { count: Number(more.dataset.count) });
|
|
118
|
+
more.setAttribute("aria-label", label);
|
|
119
|
+
more.title = label;
|
|
94
120
|
}
|
|
95
121
|
/** An item the app follows, found among the items by the id its button carries. */
|
|
96
122
|
follow(id) {
|
|
@@ -129,12 +155,10 @@ var JlBreadcrumb = class extends JlElement {
|
|
|
129
155
|
});
|
|
130
156
|
}
|
|
131
157
|
moreButton(hidden) {
|
|
132
|
-
const label = jlText("showMoreCount", { count: hidden });
|
|
133
158
|
return /* @__PURE__ */ jsx("button", {
|
|
134
159
|
type: "button",
|
|
135
160
|
class: "more",
|
|
136
|
-
"
|
|
137
|
-
title: label,
|
|
161
|
+
"data-count": String(hidden),
|
|
138
162
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
139
163
|
name: "ellipsis",
|
|
140
164
|
size: ICON_SIZE
|
|
@@ -61,7 +61,11 @@ export declare class JlCalendar extends JlFormControl {
|
|
|
61
61
|
set(setter: ((prevState: ControlSize) => ControlSize) | ControlSize): void;
|
|
62
62
|
}>>;
|
|
63
63
|
private readonly _titleId;
|
|
64
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* The month shown, the day the arrows move from (the one focusable cell of the grid), and the dates the cells show.
|
|
66
|
+
* `drawn` holds what the cells and the weekdays were written for: every input calls back as the calendar connects,
|
|
67
|
+
* and choosing a day changes only two cells.
|
|
68
|
+
*/
|
|
65
69
|
private readonly _state;
|
|
66
70
|
private readonly _refs;
|
|
67
71
|
/** Focuses the day the arrows move from: the chosen one, or today, or the first of the month. */
|
|
@@ -92,9 +96,14 @@ export declare class JlCalendar extends JlFormControl {
|
|
|
92
96
|
/** The title is a live region: written only when the month changes, so it is announced once. */
|
|
93
97
|
private renderTitle;
|
|
94
98
|
private renderWeekdays;
|
|
99
|
+
/** Writes the page's dates in the cells: only for another month, language, first day, or today. */
|
|
100
|
+
private renderDays;
|
|
101
|
+
private writeDay;
|
|
102
|
+
/** The chosen day, the days out of bounds, and the one in the tab order (the arrows reach the others). */
|
|
103
|
+
private renderStates;
|
|
104
|
+
private forEachDay;
|
|
105
|
+
/** A day of the grid, made once: the page's dates are written in it. */
|
|
95
106
|
private dayCell;
|
|
96
|
-
/** Only the remembered day is in the tab order: the arrows reach the others. */
|
|
97
|
-
private renderFocus;
|
|
98
107
|
/** The arrows of the header stop where no day of the next month could be chosen. */
|
|
99
108
|
private renderNavigation;
|
|
100
109
|
private renderValidity;
|
|
@@ -21,10 +21,16 @@ var NAV_ICON_SIZE = 16;
|
|
|
21
21
|
var MONDAY = 1;
|
|
22
22
|
var SUNDAY = 0;
|
|
23
23
|
var SATURDAY = 6;
|
|
24
|
+
var DAYS_PER_WEEK = 7;
|
|
24
25
|
var SELECT_KEYS = ["Enter", " "];
|
|
25
26
|
var FULL_DATE = { dateStyle: "full" };
|
|
26
27
|
/** The first day of the week from its attribute: 0 (Sunday) to 6 (Saturday), Monday when absent. */
|
|
27
28
|
var parseWeekday = (value) => Math.round(clampedNumber(MONDAY, SUNDAY, SATURDAY)(value));
|
|
29
|
+
/** Writes an attribute only when it changes: the same value written again is still a change, styles checked again. */
|
|
30
|
+
function setAttributeIfChanged(element, name, value) {
|
|
31
|
+
if (element.getAttribute(name) === value) return;
|
|
32
|
+
value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
|
|
33
|
+
}
|
|
28
34
|
/**
|
|
29
35
|
* A month to pick a day from. Arrows move by day and week, Page Up and Page Down by month (by year with Shift),
|
|
30
36
|
* Home and End to the ends of the week, Enter chooses. Month and weekday names follow the `locale`; days outside
|
|
@@ -58,10 +64,19 @@ var JlCalendar = class extends JlFormControl {
|
|
|
58
64
|
parse: oneOf(CONTROL_SIZES, "md")
|
|
59
65
|
});
|
|
60
66
|
_titleId = uniqueId("jl-calendar-title");
|
|
61
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The month shown, the day the arrows move from (the one focusable cell of the grid), and the dates the cells show.
|
|
69
|
+
* `drawn` holds what the cells and the weekdays were written for: every input calls back as the calendar connects,
|
|
70
|
+
* and choosing a day changes only two cells.
|
|
71
|
+
*/
|
|
62
72
|
_state = {
|
|
73
|
+
drawn: {
|
|
74
|
+
days: "",
|
|
75
|
+
weekdays: ""
|
|
76
|
+
},
|
|
63
77
|
focus: null,
|
|
64
78
|
formDisabled: false,
|
|
79
|
+
page: [],
|
|
65
80
|
view: calendarDateOf(/* @__PURE__ */ new Date())
|
|
66
81
|
};
|
|
67
82
|
_refs = this.useRefs((ref) => ({
|
|
@@ -116,7 +131,7 @@ var JlCalendar = class extends JlFormControl {
|
|
|
116
131
|
] }), /* @__PURE__ */ jsxs("table", {
|
|
117
132
|
role: "grid",
|
|
118
133
|
"aria-labelledby": this._titleId,
|
|
119
|
-
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", {}) }), /* @__PURE__ */ jsx("tbody", {})]
|
|
134
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: Array.from({ length: DAYS_PER_WEEK }, () => /* @__PURE__ */ jsx("th", { scope: "col" })) }) }), /* @__PURE__ */ jsx("tbody", { children: Array.from({ length: 6 }, () => /* @__PURE__ */ jsx("tr", { children: Array.from({ length: DAYS_PER_WEEK }, () => this.dayCell()) })) })]
|
|
120
135
|
})]
|
|
121
136
|
});
|
|
122
137
|
}
|
|
@@ -171,12 +186,9 @@ var JlCalendar = class extends JlFormControl {
|
|
|
171
186
|
}
|
|
172
187
|
/** Moves the focus to a day, turning the page when it is in another month. */
|
|
173
188
|
moveFocus(date) {
|
|
174
|
-
const turn = !isSameMonth(date, this._state.view);
|
|
175
189
|
this._state.focus = date;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
this.renderPage();
|
|
179
|
-
} else this.renderFocus();
|
|
190
|
+
this._state.view = date;
|
|
191
|
+
this.renderPage();
|
|
180
192
|
this.focus();
|
|
181
193
|
}
|
|
182
194
|
turnPage(months) {
|
|
@@ -229,22 +241,11 @@ var JlCalendar = class extends JlFormControl {
|
|
|
229
241
|
renderPage() {
|
|
230
242
|
const { min, max } = this.bounds();
|
|
231
243
|
this._state.view = this.viewWithin(min, max);
|
|
232
|
-
|
|
244
|
+
this._state.focus = this.rovingDate(min, max);
|
|
233
245
|
const locale = pageLocale(this.locale.get());
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
label: dateFormatter(locale, FULL_DATE),
|
|
238
|
-
max,
|
|
239
|
-
min,
|
|
240
|
-
month,
|
|
241
|
-
selected: parseIsoDate(this.value.get()),
|
|
242
|
-
today: calendarDateOf(/* @__PURE__ */ new Date())
|
|
243
|
-
};
|
|
244
|
-
this._state.focus = context.focus;
|
|
245
|
-
this.renderTitle(formatMonthTitle(year, month, locale));
|
|
246
|
-
this.renderWeekdays(locale, firstDay);
|
|
247
|
-
this._refs.days.replaceChildren(...monthGrid(year, month, firstDay).map((week) => /* @__PURE__ */ jsx("tr", { children: week.map((date) => this.dayCell(date, context)) })));
|
|
246
|
+
this.renderWeekdays(locale, this.firstDay.get());
|
|
247
|
+
this.renderDays(locale);
|
|
248
|
+
this.renderStates(min, max);
|
|
248
249
|
this.renderNavigation(min, max);
|
|
249
250
|
}
|
|
250
251
|
/** The title is a live region: written only when the month changes, so it is announced once. */
|
|
@@ -253,38 +254,68 @@ var JlCalendar = class extends JlFormControl {
|
|
|
253
254
|
if (title.textContent !== text) title.textContent = text;
|
|
254
255
|
}
|
|
255
256
|
renderWeekdays(locale, firstDay) {
|
|
256
|
-
const
|
|
257
|
+
const drawn = `${locale}|${firstDay}`;
|
|
258
|
+
if (drawn === this._state.drawn.weekdays) return;
|
|
259
|
+
this._state.drawn.weekdays = drawn;
|
|
257
260
|
const long = weekdayNames(locale, firstDay, "long");
|
|
258
|
-
this._refs.weekdays.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
const headers = this._refs.weekdays.querySelectorAll("th");
|
|
262
|
+
weekdayNames(locale, firstDay, "short").forEach((name, index) => {
|
|
263
|
+
const header = headers.item(index);
|
|
264
|
+
header.textContent = name;
|
|
265
|
+
header.abbr = long[index] ?? name;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/** Writes the page's dates in the cells: only for another month, language, first day, or today. */
|
|
269
|
+
renderDays(locale) {
|
|
270
|
+
const { year, month } = this._state.view;
|
|
271
|
+
const firstDay = this.firstDay.get();
|
|
272
|
+
const today = calendarDateOf(/* @__PURE__ */ new Date());
|
|
273
|
+
const drawn = `${locale}|${firstDay}|${year}-${month}|${toIsoDate(today)}`;
|
|
274
|
+
if (drawn === this._state.drawn.days) return;
|
|
275
|
+
this._state.drawn.days = drawn;
|
|
276
|
+
this._state.page = monthGrid(year, month, firstDay).flat();
|
|
277
|
+
this.renderTitle(formatMonthTitle(year, month, locale));
|
|
278
|
+
const context = {
|
|
279
|
+
label: dateFormatter(locale, FULL_DATE),
|
|
280
|
+
month,
|
|
281
|
+
today
|
|
282
|
+
};
|
|
283
|
+
this.forEachDay((cell, date) => this.writeDay(cell, date, context));
|
|
284
|
+
}
|
|
285
|
+
writeDay(cell, date, context) {
|
|
286
|
+
cell.dataset.date = toIsoDate(date);
|
|
287
|
+
cell.setAttribute("aria-label", context.label(date));
|
|
288
|
+
cell.classList.toggle("outside", date.month !== context.month);
|
|
289
|
+
setAttributeIfChanged(cell, "aria-current", isSameDate(date, context.today) ? "date" : null);
|
|
290
|
+
const number = cell.firstElementChild;
|
|
291
|
+
if (number !== null) number.textContent = String(date.day);
|
|
263
292
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
293
|
+
/** The chosen day, the days out of bounds, and the one in the tab order (the arrows reach the others). */
|
|
294
|
+
renderStates(min, max) {
|
|
295
|
+
const selected = parseIsoDate(this.value.get());
|
|
296
|
+
const focus = this.isOff() ? null : this._state.focus;
|
|
297
|
+
this.forEachDay((cell, date) => {
|
|
298
|
+
setAttributeIfChanged(cell, "aria-selected", String(isSameDate(date, selected)));
|
|
299
|
+
setAttributeIfChanged(cell, "aria-disabled", isWithin(date, min, max) ? null : "true");
|
|
300
|
+
setAttributeIfChanged(cell, "tabindex", isSameDate(date, focus) ? "0" : "-1");
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
forEachDay(write) {
|
|
304
|
+
const cells = this._refs.days.querySelectorAll("td");
|
|
305
|
+
this._state.page.forEach((date, index) => {
|
|
306
|
+
write(cells.item(index), date);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/** A day of the grid, made once: the page's dates are written in it. */
|
|
310
|
+
dayCell() {
|
|
267
311
|
return /* @__PURE__ */ jsx("td", {
|
|
268
|
-
class:
|
|
312
|
+
class: "day",
|
|
269
313
|
role: "gridcell",
|
|
270
|
-
tabIndex:
|
|
271
|
-
"
|
|
272
|
-
"
|
|
273
|
-
"aria-selected": String(isSameDate(date, context.selected)),
|
|
274
|
-
"aria-disabled": enabled ? void 0 : "true",
|
|
275
|
-
"aria-current": isSameDate(date, context.today) ? "date" : void 0,
|
|
276
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
277
|
-
class: "number",
|
|
278
|
-
children: String(date.day)
|
|
279
|
-
})
|
|
314
|
+
tabIndex: -1,
|
|
315
|
+
"aria-selected": "false",
|
|
316
|
+
children: /* @__PURE__ */ jsx("span", { class: "number" })
|
|
280
317
|
});
|
|
281
318
|
}
|
|
282
|
-
/** Only the remembered day is in the tab order: the arrows reach the others. */
|
|
283
|
-
renderFocus() {
|
|
284
|
-
const focus = this._state.focus;
|
|
285
|
-
const iso = focus === null ? "" : toIsoDate(focus);
|
|
286
|
-
for (const cell of this._refs.days.querySelectorAll("[data-date]")) cell.tabIndex = cell.dataset.date === iso && !this.isOff() ? 0 : -1;
|
|
287
|
-
}
|
|
288
319
|
/** The arrows of the header stop where no day of the next month could be chosen. */
|
|
289
320
|
renderNavigation(min, max) {
|
|
290
321
|
const view = this._state.view;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-card.css?inline
|
|
2
|
-
var jl_card_default = ":host{--pad:20px;--edge:20px;--gap:12px;--radius:var(--jl-radius-lg);display:block}:host([padding=none]){--pad:0px;--edge:16px}:host([padding=sm]){--pad:12px;--edge:12px;--gap:8px}:host([padding=lg]){--pad:28px;--edge:28px;--gap:16px}.card{border:1px solid var(--jl-line);border-radius:var(--radius);background:var(--jl-surface);height:100%;color:var(--jl-text);font-size:var(--jl-font-md);transition:border-color var(--jl-fast) var(--jl-ease);flex-direction:column;line-height:1.55;display:flex;position:relative;overflow:hidden}:host([clickable]) .card{cursor:pointer}:host([clickable]) .card:hover{border-color:var(--jl-accent-line)}.link{z-index:1;border-radius:inherit;position:absolute;inset:0}.link:focus-visible{box-shadow:none}.card:has(.link:focus-visible){box-shadow:var(--jl-focus-ring)}.actions,footer{z-index:2;position:relative}.media ::slotted(*){width:100%;display:block}.media ::slotted(img){object-fit:cover}header{padding:var(--edge) var(--edge) 0;align-items:flex-start;gap:12px;display:flex}:host([floating-actions]) header{z-index:2;position:absolute;top:0;right:0}:host([has-header]:not([has-body])) header{padding-bottom:var(--edge)}.titles{flex:1;gap:2px;min-width:0;display:grid}h3{font-size:var(--jl-font-lg);letter-spacing:-.01em;font-weight:650;line-height:1.35}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.5}.actions{flex:none;align-items:center;gap:6px;margin:-4px -6px -4px 0;display:flex}.body{padding:var(--pad);flex:1}:host([has-header]) .body{padding-top:var(--gap)}:host([has-header][padding=none]) .body{margin-top:var(--gap);border-top:1px solid var(--jl-line);padding-top:0}footer{padding:12px var(--edge);border-top:1px solid var(--jl-line);flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}:host(:not([has-body]):not([has-header])) footer{border-top:0}";
|
|
2
|
+
var jl_card_default = ":host{--pad:20px;--edge:20px;--gap:12px;--radius:var(--jl-radius-lg);display:block}:host([padding=none]){--pad:0px;--edge:16px}:host([padding=sm]){--pad:12px;--edge:12px;--gap:8px}:host([padding=lg]){--pad:28px;--edge:28px;--gap:16px}.card{border:1px solid var(--jl-line);border-radius:var(--radius);background:var(--jl-surface);height:100%;color:var(--jl-text);font-size:var(--jl-font-md);transition:border-color var(--jl-fast) var(--jl-ease);flex-direction:column;line-height:1.55;display:flex;position:relative;overflow:hidden}:host([clickable]) .card{cursor:pointer}:host([clickable]) .card:hover{border-color:var(--jl-accent-line)}.link{z-index:1;border-radius:inherit;position:absolute;inset:0}.link:focus-visible{box-shadow:none}.card:has(.link:focus-visible){box-shadow:var(--jl-focus-ring)}.actions,footer{z-index:2;position:relative}.media ::slotted(*){width:100%;display:block}.media ::slotted(img){object-fit:cover}header{padding:var(--edge) var(--edge) 0;align-items:flex-start;gap:12px;display:flex}:host([floating-actions]) header{z-index:2;position:absolute;top:0;right:0}:host([has-header]:not([has-body])) header{padding-bottom:var(--edge)}.titles{flex:1;gap:2px;min-width:0;display:grid}h3{font-size:var(--jl-font-lg);letter-spacing:-.01em;font-weight:650;line-height:1.35}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.5}h3:empty,.description:empty{display:none}.actions{flex:none;align-items:center;gap:6px;margin:-4px -6px -4px 0;display:flex}.body{padding:var(--pad);flex:1}:host([has-header]) .body{padding-top:var(--gap)}:host([has-header][padding=none]) .body{margin-top:var(--gap);border-top:1px solid var(--jl-line);padding-top:0}footer{padding:12px var(--edge);border-top:1px solid var(--jl-line);flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}:host(:not([has-body]):not([has-header])) footer{border-top:0}";
|
|
3
3
|
export { jl_card_default as default };
|
|
@@ -24,13 +24,11 @@ var JlCard = class extends JlElement {
|
|
|
24
24
|
events = this.useEvents();
|
|
25
25
|
heading = this.useChange("", (value) => {
|
|
26
26
|
this._refs.heading.textContent = value;
|
|
27
|
-
this._refs.heading.hidden = value === "";
|
|
28
27
|
this._refs.linkName.textContent = value || DEFAULT_LINK_NAME;
|
|
29
28
|
this.renderSections();
|
|
30
29
|
}, { attribute: "heading" });
|
|
31
30
|
description = this.useChange("", (value) => {
|
|
32
31
|
this._refs.description.textContent = value;
|
|
33
|
-
this._refs.description.hidden = value === "";
|
|
34
32
|
this.renderSections();
|
|
35
33
|
}, { attribute: "description" });
|
|
36
34
|
/** The room around the content; `none` leaves the body edge to edge, for a list or a table. */
|
|
@@ -81,13 +79,9 @@ var JlCard = class extends JlElement {
|
|
|
81
79
|
hidden: true,
|
|
82
80
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
83
81
|
class: "titles",
|
|
84
|
-
children: [/* @__PURE__ */ jsx("h3", {
|
|
85
|
-
id: "heading",
|
|
86
|
-
hidden: true
|
|
87
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
82
|
+
children: [/* @__PURE__ */ jsx("h3", { id: "heading" }), /* @__PURE__ */ jsx("p", {
|
|
88
83
|
class: "description",
|
|
89
|
-
id: "description"
|
|
90
|
-
hidden: true
|
|
84
|
+
id: "description"
|
|
91
85
|
})]
|
|
92
86
|
}), /* @__PURE__ */ jsx("div", {
|
|
93
87
|
class: "actions",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-chip-group.css?inline
|
|
2
|
-
var jl_chip_group_default = ":host{--height:28px;--pad:10px;--font-size:var(--jl-font-sm);min-width:0;display:block}:host([size=sm]){--height:24px;--pad:8px;--font-size:var(--jl-font-xs)}:host([size=lg]){--height:36px;--pad:14px;--font-size:var(--jl-font-md)}.group{scrollbar-width:none;contain:inline-size;gap:8px;min-width:0;margin:-3px;padding:3px;display:flex;overflow-x:auto}.group::-webkit-scrollbar{display:none}:host([wrap]) .group{contain:none;flex-wrap:wrap;overflow:visible}.chip{max-width:100%;height:var(--height);padding:0 var(--pad);border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface);color:var(--jl-text-2);font-size:var(--font-size);white-space:nowrap;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);flex:none;align-items:center;gap:6px;font-weight:600;line-height:1;display:inline-flex}.chip:hover:not(:disabled){background:var(--jl-surface-2)}.chip
|
|
2
|
+
var jl_chip_group_default = ":host{--height:28px;--pad:10px;--font-size:var(--jl-font-sm);min-width:0;display:block}:host([size=sm]){--height:24px;--pad:8px;--font-size:var(--jl-font-xs)}:host([size=lg]){--height:36px;--pad:14px;--font-size:var(--jl-font-md)}.group{scrollbar-width:none;contain:inline-size;gap:8px;min-width:0;margin:-3px;padding:3px;display:flex;overflow-x:auto}.group::-webkit-scrollbar{display:none}:host([wrap]) .group{contain:none;flex-wrap:wrap;overflow:visible}.chip{max-width:100%;height:var(--height);padding:0 var(--pad);border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface);color:var(--jl-text-2);font-size:var(--font-size);white-space:nowrap;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);flex:none;align-items:center;gap:6px;font-weight:600;line-height:1;display:inline-flex}.chip:hover:not(:disabled){background:var(--jl-surface-2)}.chip:is([aria-checked=true],[aria-pressed=true]),.chip:is([aria-checked=true],[aria-pressed=true]):hover:not(:disabled){border-color:var(--jl-accent-line);background:var(--jl-accent-soft);color:var(--jl-accent)}.chip:not([data-icon],[aria-checked=true],[aria-pressed=true]) .icon{display:none}.chip:disabled{cursor:not-allowed;opacity:.5}.label{text-overflow:ellipsis;line-height:1.4;overflow:hidden}.badge{border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);min-width:18px;color:var(--jl-muted);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;text-align:center;margin-right:-4px;padding:0 6px;font-weight:650;line-height:18px}.chip:is([aria-checked=true],[aria-pressed=true]) .badge{background:color-mix(in srgb, var(--jl-accent) 14%, transparent);color:var(--jl-accent)}jl-icon{--icon-size:14px}:host([size=sm]) jl-icon{--icon-size:12px}:host([size=lg]) jl-icon{--icon-size:16px}";
|
|
3
3
|
export { jl_chip_group_default as default };
|
|
@@ -49,7 +49,10 @@ export declare class JlChipGroup<Value extends string = string> extends JlFormCo
|
|
|
49
49
|
get(): boolean;
|
|
50
50
|
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
51
51
|
}>>;
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* The chip that holds the Tab stop with several choices: the last one people reached. `drawn` is the list the chips
|
|
54
|
+
* were made from: the options call back with the same list as the group connects.
|
|
55
|
+
*/
|
|
53
56
|
private readonly _state;
|
|
54
57
|
private readonly _nameWatch;
|
|
55
58
|
private readonly _refs;
|
|
@@ -71,8 +74,9 @@ export declare class JlChipGroup<Value extends string = string> extends JlFormCo
|
|
|
71
74
|
private commit;
|
|
72
75
|
private onKeydown;
|
|
73
76
|
private renderOptions;
|
|
77
|
+
/** A chip without an icon of its own has a check, which the CSS shows while it is chosen. */
|
|
74
78
|
private chip;
|
|
75
|
-
/** Radios with one choice, toggle buttons with several
|
|
79
|
+
/** Radios with one choice, toggle buttons with several. */
|
|
76
80
|
private renderValue;
|
|
77
81
|
/** Tab reaches one chip: the chosen one with one choice, the last one reached with several, else the first. */
|
|
78
82
|
private renderTabStop;
|
|
@@ -13,11 +13,6 @@ import { Check } from "lucide";
|
|
|
13
13
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
14
14
|
// src/molecules/jl-chip-group.tsx
|
|
15
15
|
registerIcons({ check: Check });
|
|
16
|
-
var ICON_SIZES = {
|
|
17
|
-
lg: 16,
|
|
18
|
-
md: 14,
|
|
19
|
-
sm: 12
|
|
20
|
-
};
|
|
21
16
|
var SELECTED_ICON = "check";
|
|
22
17
|
var CHIP_SELECTOR = ".chip";
|
|
23
18
|
/** The keys that move between the chips; with one choice, the choice moves too, as with native radios. */
|
|
@@ -61,7 +56,6 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
61
56
|
wrap = this.useChange(false, (value) => this.reflect("wrap", value), { attribute: "wrap" });
|
|
62
57
|
size = this.useChange("md", (value) => {
|
|
63
58
|
this.reflect("size", value);
|
|
64
|
-
this.renderOptions();
|
|
65
59
|
}, {
|
|
66
60
|
attribute: "size",
|
|
67
61
|
parse: oneOf(CONTROL_SIZES, "md")
|
|
@@ -78,9 +72,13 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
78
72
|
this.reflect("disabled", value);
|
|
79
73
|
this.renderValue();
|
|
80
74
|
}, { attribute: "disabled" });
|
|
81
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* The chip that holds the Tab stop with several choices: the last one people reached. `drawn` is the list the chips
|
|
77
|
+
* were made from: the options call back with the same list as the group connects.
|
|
78
|
+
*/
|
|
82
79
|
_state = {
|
|
83
80
|
disabledByForm: false,
|
|
81
|
+
drawn: null,
|
|
84
82
|
stop: ""
|
|
85
83
|
};
|
|
86
84
|
_nameWatch = new MutationObserver(() => this.renderFormValue());
|
|
@@ -173,11 +171,14 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
173
171
|
this.press(target);
|
|
174
172
|
}
|
|
175
173
|
renderOptions() {
|
|
176
|
-
const
|
|
177
|
-
|
|
174
|
+
const options = this.options.get();
|
|
175
|
+
if (options === this._state.drawn) return;
|
|
176
|
+
this._state.drawn = options;
|
|
177
|
+
this._refs.group.replaceChildren(...options.map((option) => this.chip(option)));
|
|
178
178
|
this.renderValue();
|
|
179
179
|
}
|
|
180
|
-
chip
|
|
180
|
+
/** A chip without an icon of its own has a check, which the CSS shows while it is chosen. */
|
|
181
|
+
chip(option) {
|
|
181
182
|
const badge = option.badge === void 0 ? "" : String(option.badge);
|
|
182
183
|
return /* @__PURE__ */ jsxs("button", {
|
|
183
184
|
type: "button",
|
|
@@ -189,8 +190,7 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
189
190
|
children: [
|
|
190
191
|
/* @__PURE__ */ jsx(JlIcon, {
|
|
191
192
|
class: "icon",
|
|
192
|
-
|
|
193
|
-
hidden: true
|
|
193
|
+
name: option.icon ?? SELECTED_ICON
|
|
194
194
|
}),
|
|
195
195
|
/* @__PURE__ */ jsx("span", {
|
|
196
196
|
class: "label",
|
|
@@ -203,7 +203,7 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
203
203
|
]
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
/** Radios with one choice, toggle buttons with several
|
|
206
|
+
/** Radios with one choice, toggle buttons with several. */
|
|
207
207
|
renderValue() {
|
|
208
208
|
const chosen = new Set(this.chosen());
|
|
209
209
|
const multiple = this.multiple.get();
|
|
@@ -216,11 +216,6 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
216
216
|
setOrRemove(chip, "role", multiple ? "" : "radio");
|
|
217
217
|
setOrRemove(chip, "aria-checked", multiple ? "" : String(selected));
|
|
218
218
|
setOrRemove(chip, "aria-pressed", multiple ? String(selected) : "");
|
|
219
|
-
chip.classList.toggle("selected", selected);
|
|
220
|
-
const icon = chip.querySelector(".icon");
|
|
221
|
-
const name = chip.dataset.icon ?? (selected ? SELECTED_ICON : "");
|
|
222
|
-
icon?.name.set(name);
|
|
223
|
-
if (icon !== null) icon.hidden = name === "";
|
|
224
219
|
}
|
|
225
220
|
this.renderTabStop();
|
|
226
221
|
this.renderFormValue();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-code-block.css?inline
|
|
2
|
-
var jl_code_block_default = ":host{--max-height:none;min-width:0;display:block}figure{border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface-2);position:relative;overflow:hidden}header{border-bottom:1px solid var(--jl-line);height:38px;color:var(--jl-muted);font-size:var(--jl-font-xs);justify-content:space-between;align-items:center;gap:12px;padding:0 52px 0 14px;display:flex}.heading{color:var(--jl-text-2);font-family:var(--jl-font-mono);text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}.language{letter-spacing:.06em;text-transform:uppercase;font-weight:600}.body{min-width:0;max-height:var(--max-height);display:flex;overflow-y:auto}.gutter,pre{font-family:var(--jl-font-mono);font-variant-ligatures:no-contextual;padding:14px 16px;font-size:12.5px;line-height:1.7}.gutter{color:var(--jl-faint);text-align:right;white-space:pre;-webkit-user-select:none;user-select:none;flex:none;padding-right:4px}pre{min-width:0;color:var(--jl-text);tab-size:2;flex:1;margin:0;padding-right:48px;overflow-x:auto}:host([wrap]) pre{white-space:pre-wrap;overflow-wrap:anywhere}.copy{background:var(--jl-surface-2);border-radius:var(--jl-radius-sm);position:absolute;top:6px;right:6px}:host(:not([has-header])) .copy{opacity:.6;transition:opacity var(--jl-fast) var(--jl-ease)}:host(:not([has-header])) figure:hover .copy,.copy:focus-within{opacity:1}.tok-comment{color:var(--jl-code-comment);font-style:italic}.tok-string{color:var(--jl-code-string)}.tok-number{color:var(--jl-code-number)}.tok-keyword{color:var(--jl-code-keyword)}.tok-tag{color:var(--jl-code-tag)}.tok-attribute{color:var(--jl-code-attribute)}.tok-property{color:var(--jl-code-property)}.tok-function{color:var(--jl-code-function)}.tok-punctuation{color:var(--jl-muted)}";
|
|
2
|
+
var jl_code_block_default = ":host{--max-height:none;min-width:0;display:block}figure{border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface-2);position:relative;overflow:hidden}header{border-bottom:1px solid var(--jl-line);height:38px;color:var(--jl-muted);font-size:var(--jl-font-xs);justify-content:space-between;align-items:center;gap:12px;padding:0 52px 0 14px;display:flex}.heading{color:var(--jl-text-2);font-family:var(--jl-font-mono);text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}.language{letter-spacing:.06em;text-transform:uppercase;font-weight:600}.body{min-width:0;max-height:var(--max-height);display:flex;overflow-y:auto}.gutter,pre{font-family:var(--jl-font-mono);font-variant-ligatures:no-contextual;padding:14px 16px;font-size:12.5px;line-height:1.7}.gutter{color:var(--jl-faint);text-align:right;white-space:pre;-webkit-user-select:none;user-select:none;flex:none;padding-right:4px;display:none}pre{min-width:0;color:var(--jl-text);tab-size:2;flex:1;margin:0;padding-right:48px;overflow-x:auto}:host([line-numbers]) .gutter{display:block}:host(:not([has-header])) header{display:none}:host([wrap]) pre{white-space:pre-wrap;overflow-wrap:anywhere}.copy{background:var(--jl-surface-2);border-radius:var(--jl-radius-sm);position:absolute;top:6px;right:6px}:host(:not([has-header])) .copy{opacity:.6;transition:opacity var(--jl-fast) var(--jl-ease)}:host(:not([has-header])) figure:hover .copy,.copy:focus-within{opacity:1}.tok-comment{color:var(--jl-code-comment);font-style:italic}.tok-string{color:var(--jl-code-string)}.tok-number{color:var(--jl-code-number)}.tok-keyword{color:var(--jl-code-keyword)}.tok-tag{color:var(--jl-code-tag)}.tok-attribute{color:var(--jl-code-attribute)}.tok-property{color:var(--jl-code-property)}.tok-function{color:var(--jl-code-function)}.tok-punctuation{color:var(--jl-muted)}";
|
|
3
3
|
export { jl_code_block_default as default };
|
|
@@ -7,14 +7,14 @@ export declare const CODE_LANGUAGES: readonly CodeLanguage[];
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class JlCodeBlock extends JlElement {
|
|
9
9
|
static readonly selector = "jl-code-block";
|
|
10
|
-
readonly code: Readonly<Readonly<{
|
|
11
|
-
get(): string;
|
|
12
|
-
set(setter: string | ((prevState: string) => string)): void;
|
|
13
|
-
}>>;
|
|
14
10
|
readonly language: Readonly<Readonly<{
|
|
15
11
|
get(): CodeLanguage;
|
|
16
12
|
set(setter: ((prevState: CodeLanguage) => CodeLanguage) | CodeLanguage): void;
|
|
17
13
|
}>>;
|
|
14
|
+
readonly code: Readonly<Readonly<{
|
|
15
|
+
get(): string;
|
|
16
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
17
|
+
}>>;
|
|
18
18
|
/** A file name or a title over the code. */
|
|
19
19
|
readonly heading: Readonly<Readonly<{
|
|
20
20
|
get(): string;
|
|
@@ -38,12 +38,14 @@ export declare class JlCodeBlock extends JlElement {
|
|
|
38
38
|
get(): string;
|
|
39
39
|
set(setter: string | ((prevState: string) => string)): void;
|
|
40
40
|
}>>;
|
|
41
|
+
/** What the code was coloured from: the inputs call back with what they hold as the block connects. */
|
|
42
|
+
private readonly _drawn;
|
|
41
43
|
private readonly _refs;
|
|
42
44
|
templateHtml(): Node;
|
|
43
45
|
templateCss(): string;
|
|
44
46
|
/** The code shown: the `code` input, or else the text the page wrote inside the element. */
|
|
45
47
|
private source;
|
|
46
48
|
private render;
|
|
49
|
+
/** The line numbers, which the CSS shows with `line-numbers`. */
|
|
47
50
|
private renderGutter;
|
|
48
|
-
private renderHeader;
|
|
49
51
|
}
|
|
@@ -29,14 +29,17 @@ var LANGUAGE_LABELS = {
|
|
|
29
29
|
*/
|
|
30
30
|
var JlCodeBlock = class extends JlElement {
|
|
31
31
|
static selector = "jl-code-block";
|
|
32
|
-
code = this.useChange("", () => this.render(), { attribute: "code" });
|
|
33
32
|
language = this.useChange("text", () => this.render(), {
|
|
34
33
|
attribute: "language",
|
|
35
34
|
parse: oneOf(CODE_LANGUAGES, "text")
|
|
36
35
|
});
|
|
36
|
+
code = this.useChange("", () => this.render(), { attribute: "code" });
|
|
37
37
|
/** A file name or a title over the code. */
|
|
38
|
-
heading = this.useChange("", () =>
|
|
39
|
-
|
|
38
|
+
heading = this.useChange("", (value) => {
|
|
39
|
+
this._refs.heading.textContent = value;
|
|
40
|
+
this.reflect("has-header", value !== "");
|
|
41
|
+
}, { attribute: "heading" });
|
|
42
|
+
lineNumbers = this.useChange(false, (value) => this.reflect("line-numbers", value), { attribute: "line-numbers" });
|
|
40
43
|
hideCopy = this.useChange(false, (value) => {
|
|
41
44
|
this._refs.copy.hidden = value;
|
|
42
45
|
}, { attribute: "hide-copy" });
|
|
@@ -44,27 +47,27 @@ var JlCodeBlock = class extends JlElement {
|
|
|
44
47
|
wrap = this.useChange(false, (value) => this.reflect("wrap", value), { attribute: "wrap" });
|
|
45
48
|
/** A CSS height past which the code scrolls under its header: `320px`, `50vh`; a number is pixels. */
|
|
46
49
|
maxHeight = this.useChange("", (value) => this.style.setProperty("--max-height", value.trim() === "" ? "none" : cssLength(value)), { attribute: "max-height" });
|
|
50
|
+
/** What the code was coloured from: the inputs call back with what they hold as the block connects. */
|
|
51
|
+
_drawn = {
|
|
52
|
+
language: "",
|
|
53
|
+
source: ""
|
|
54
|
+
};
|
|
47
55
|
_refs = this.useRefs((ref) => ({
|
|
48
56
|
code: ref("code"),
|
|
49
57
|
copy: ref(JlCopyButton),
|
|
50
58
|
gutter: ref(".gutter"),
|
|
51
|
-
header: ref("header"),
|
|
52
59
|
heading: ref(".heading"),
|
|
53
60
|
language: ref(".language")
|
|
54
61
|
}));
|
|
55
62
|
templateHtml() {
|
|
56
63
|
return /* @__PURE__ */ jsxs("figure", {
|
|
57
64
|
attrs: { part: "base" },
|
|
58
|
-
children: [/* @__PURE__ */ jsxs("header", {
|
|
59
|
-
hidden: true,
|
|
60
|
-
children: [/* @__PURE__ */ jsx("span", { class: "heading" }), /* @__PURE__ */ jsx("span", { class: "language" })]
|
|
61
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
65
|
+
children: [/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("span", { class: "heading" }), /* @__PURE__ */ jsx("span", { class: "language" })] }), /* @__PURE__ */ jsxs("div", {
|
|
62
66
|
class: "body",
|
|
63
67
|
children: [
|
|
64
68
|
/* @__PURE__ */ jsx("div", {
|
|
65
69
|
class: "gutter",
|
|
66
|
-
"aria-hidden": "true"
|
|
67
|
-
hidden: true
|
|
70
|
+
"aria-hidden": "true"
|
|
68
71
|
}),
|
|
69
72
|
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", {}) }),
|
|
70
73
|
/* @__PURE__ */ jsx(JlCopyButton, { class: "copy" })
|
|
@@ -85,24 +88,18 @@ var JlCodeBlock = class extends JlElement {
|
|
|
85
88
|
render() {
|
|
86
89
|
const source = this.source();
|
|
87
90
|
const language = this.language.get();
|
|
91
|
+
if (source === this._drawn.source && language === this._drawn.language) return;
|
|
92
|
+
this._drawn.source = source;
|
|
93
|
+
this._drawn.language = language;
|
|
88
94
|
this._refs.code.replaceChildren(...highlightedNodes(source, language));
|
|
89
95
|
this._refs.copy.value.set(source);
|
|
96
|
+
this._refs.language.textContent = LANGUAGE_LABELS[language];
|
|
90
97
|
this.renderGutter(source);
|
|
91
|
-
this.renderHeader();
|
|
92
98
|
}
|
|
99
|
+
/** The line numbers, which the CSS shows with `line-numbers`. */
|
|
93
100
|
renderGutter(source) {
|
|
94
|
-
const gutter = this._refs.gutter;
|
|
95
|
-
gutter.hidden = !this.lineNumbers.get();
|
|
96
101
|
const count = source.split("\n").length;
|
|
97
|
-
gutter.textContent = Array.from({ length: count }, (_, index) => String(index + 1)).join("\n");
|
|
98
|
-
}
|
|
99
|
-
renderHeader() {
|
|
100
|
-
const heading = this.heading.get();
|
|
101
|
-
const label = LANGUAGE_LABELS[this.language.get()];
|
|
102
|
-
this._refs.heading.textContent = heading;
|
|
103
|
-
this._refs.language.textContent = label;
|
|
104
|
-
this._refs.header.hidden = heading === "";
|
|
105
|
-
this.reflect("has-header", heading !== "");
|
|
102
|
+
this._refs.gutter.textContent = Array.from({ length: count }, (_, index) => String(index + 1)).join("\n");
|
|
106
103
|
}
|
|
107
104
|
};
|
|
108
105
|
JlCodeBlock.register();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-combobox.css?inline
|
|
2
|
-
var jl_combobox_default = ":host{min-width:0;display:block}.toggle jl-icon{transition:transform var(--jl-fast) var(--jl-ease)}:host([open]) .toggle jl-icon{transform:rotate(180deg)}.toggle:disabled{cursor:not-allowed}.popup{padding:4px}.listbox{max-height:264px;margin:0;padding:0;list-style:none;position:relative;overflow-y:auto}.option{border-radius:var(--jl-radius-xs);min-height:34px;color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:10px;padding:6px 10px;line-height:1.35;display:flex}.option
|
|
2
|
+
var jl_combobox_default = ":host{min-width:0;display:block}.toggle jl-icon{transition:transform var(--jl-fast) var(--jl-ease)}:host([open]) .toggle jl-icon{transform:rotate(180deg)}.toggle:disabled{cursor:not-allowed}.popup{padding:4px}.listbox{max-height:264px;margin:0;padding:0;list-style:none;position:relative;overflow-y:auto}.option{border-radius:var(--jl-radius-xs);min-height:34px;color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:10px;padding:6px 10px;line-height:1.35;display:flex}.option[aria-selected=true]{background:var(--jl-surface-3)}.option-label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.option.chosen .option-label{font-weight:600}.option[aria-disabled=true]{color:var(--jl-faint);cursor:not-allowed}.text{flex:1;gap:1px;min-width:0;display:grid}.description{color:var(--jl-muted);font-size:var(--jl-font-xs)}.check{color:var(--jl-accent);visibility:hidden}.option.chosen .check{visibility:visible}mark{color:var(--jl-accent);background:0 0;font-weight:700}.empty{color:var(--jl-muted);font-size:var(--jl-font-sm);padding:8px 10px}";
|
|
3
3
|
export { jl_combobox_default as default };
|