@syware/jlib 0.13.0 → 0.15.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 +12 -8
- package/dist/atoms/jl-avatar.d.ts +2 -0
- package/dist/atoms/jl-avatar.js +11 -6
- package/dist/atoms/jl-button.d.ts +6 -0
- package/dist/atoms/jl-button.js +22 -8
- package/dist/atoms/jl-chip.js +2 -1
- package/dist/atoms/jl-input.js +3 -3
- package/dist/atoms/jl-link.d.ts +1 -0
- package/dist/atoms/jl-link.js +5 -2
- package/dist/atoms/jl-progress-ring.d.ts +2 -0
- package/dist/atoms/jl-progress-ring.js +9 -4
- package/dist/atoms/jl-progress.d.ts +1 -0
- package/dist/atoms/jl-progress.js +8 -4
- package/dist/atoms/jl-rating.d.ts +2 -0
- package/dist/atoms/jl-rating.js +11 -6
- package/dist/atoms/jl-select.css.js +1 -1
- package/dist/atoms/jl-select.d.ts +4 -0
- package/dist/atoms/jl-select.js +18 -2
- package/dist/atoms/jl-switch.css.js +1 -1
- package/dist/atoms/jl-textarea.js +2 -2
- package/dist/base/jl-form-control.d.ts +3 -2
- package/dist/base/jl-form-control.js +14 -4
- package/dist/index.d.ts +2 -1
- package/dist/lib/dom.d.ts +5 -0
- package/dist/lib/dom.js +9 -1
- package/dist/lib/download.js +10 -2
- package/dist/lib/floating.d.ts +5 -0
- package/dist/lib/floating.js +21 -2
- package/dist/lib/fuzzy.d.ts +3 -2
- package/dist/lib/fuzzy.js +15 -4
- package/dist/lib/hotkey.d.ts +13 -0
- package/dist/lib/hotkey.js +2 -1
- package/dist/lib/key-shortcut.js +11 -29
- package/dist/lib/modal.d.ts +24 -0
- package/dist/lib/modal.js +52 -0
- package/dist/lib/numeric.d.ts +5 -0
- package/dist/lib/numeric.js +11 -1
- package/dist/lib/option-filter.d.ts +2 -0
- package/dist/lib/option-filter.js +1 -1
- package/dist/lib/press.d.ts +11 -0
- package/dist/lib/press.js +31 -0
- package/dist/lib/progress.d.ts +0 -5
- package/dist/lib/progress.js +1 -9
- package/dist/lib/roving.d.ts +6 -0
- package/dist/lib/roving.js +14 -1
- package/dist/lib/table.js +12 -4
- package/dist/lib/texts-de.d.ts +12 -0
- package/dist/lib/texts-de.js +12 -0
- package/dist/lib/texts-fr.d.ts +12 -0
- package/dist/lib/texts-fr.js +12 -0
- package/dist/lib/texts.d.ts +12 -0
- package/dist/lib/texts.js +12 -0
- package/dist/molecules/jl-accordion-item.js +2 -1
- package/dist/molecules/jl-calendar.d.ts +4 -0
- package/dist/molecules/jl-calendar.js +16 -5
- package/dist/molecules/jl-chip-group.css.js +1 -1
- package/dist/molecules/jl-chip-group.js +4 -4
- package/dist/molecules/jl-code-block.css.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +4 -0
- package/dist/molecules/jl-combobox.js +23 -11
- package/dist/molecules/jl-copy-button.css.js +1 -1
- package/dist/molecules/jl-copy-button.d.ts +11 -4
- package/dist/molecules/jl-copy-button.js +48 -22
- package/dist/molecules/jl-date-picker.d.ts +4 -0
- package/dist/molecules/jl-date-picker.js +18 -12
- package/dist/molecules/jl-field.d.ts +5 -1
- package/dist/molecules/jl-field.js +24 -5
- package/dist/molecules/jl-file-drop.css.js +1 -1
- package/dist/molecules/jl-file-drop.d.ts +4 -0
- package/dist/molecules/jl-file-drop.js +16 -8
- package/dist/molecules/jl-input-list.js +13 -6
- package/dist/molecules/jl-load-state.d.ts +8 -0
- package/dist/molecules/jl-load-state.js +33 -7
- package/dist/molecules/jl-menu.d.ts +21 -1
- package/dist/molecules/jl-menu.js +58 -6
- package/dist/molecules/jl-number-input.d.ts +2 -0
- package/dist/molecules/jl-number-input.js +12 -8
- package/dist/molecules/jl-radio-group.js +4 -3
- package/dist/molecules/jl-search.js +2 -2
- package/dist/molecules/jl-segmented.js +2 -2
- package/dist/molecules/jl-tabs.js +2 -2
- package/dist/molecules/jl-tag-input.css.js +1 -1
- package/dist/molecules/jl-tag-input.d.ts +4 -0
- package/dist/molecules/jl-tag-input.js +17 -9
- package/dist/molecules/jl-toast.js +10 -6
- package/dist/molecules/jl-tooltip.js +8 -2
- package/dist/organisms/jl-command-palette.css.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +2 -0
- package/dist/organisms/jl-command-palette.js +10 -4
- package/dist/organisms/jl-dialog.d.ts +3 -0
- package/dist/organisms/jl-dialog.js +13 -3
- package/dist/organisms/jl-drawer.d.ts +3 -0
- package/dist/organisms/jl-drawer.js +13 -3
- package/dist/organisms/jl-flow.d.ts +2 -0
- package/dist/organisms/jl-flow.js +29 -9
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +15 -4
- package/dist/organisms/jl-table.js +40 -17
- package/dist/organisms/jl-toaster.d.ts +13 -2
- package/dist/organisms/jl-toaster.js +47 -4
- package/dist/organisms/jl-tree.css.js +1 -1
- package/dist/organisms/jl-tree.d.ts +23 -4
- package/dist/organisms/jl-tree.js +74 -18
- package/dist/styles/base.css.js +1 -1
- package/dist/styles/control.css.js +1 -1
- package/dist/styles/tokens.css.js +1 -1
- package/dist/tokens.css +4 -3
- package/dist/types/jl-load-state.types.d.ts +7 -0
- package/dist/types/jl-table.types.d.ts +12 -0
- package/dist/types/jl-tree.types.d.ts +17 -0
- package/dist/types/press.types.d.ts +6 -0
- package/package.json +7 -3
- package/dist/lib/roving-index.d.ts +0 -10
- package/dist/lib/roving-index.js +0 -32
- /package/dist/types/{roving-index.types.d.ts → roving.types.d.ts} +0 -0
|
@@ -8,6 +8,7 @@ import { JlIcon } from "../atoms/jl-icon.js";
|
|
|
8
8
|
import { setOrRemove } from "../lib/dom.js";
|
|
9
9
|
import { JlBadge } from "../atoms/jl-badge.js";
|
|
10
10
|
import { startedOnControl } from "../lib/surface.js";
|
|
11
|
+
import { PRESS_EVENTS, pressButtonOf, tellPress } from "../lib/press.js";
|
|
11
12
|
import jl_table_default from "./jl-table.css.js";
|
|
12
13
|
import { css } from "@jadis/core";
|
|
13
14
|
import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown, Inbox } from "lucide";
|
|
@@ -103,7 +104,8 @@ var isOpen = (row) => row.querySelector(":scope > .expand-cell > .expand")?.getA
|
|
|
103
104
|
* rows in place; `selectable` adds a checkbox column. The header stays on top while the rows scroll within
|
|
104
105
|
* `max-height`, and the table scrolls sideways on narrow screens. Cells of a column can be drawn by code with
|
|
105
106
|
* `renderers`. `expandable` rows open on a press to show their `detail` under them, the row staying as it is: one at
|
|
106
|
-
* a time (`single`) or any number (`multiple`).
|
|
107
|
+
* a time (`single`) or any number (`multiple`). A press on a row fires `press` with the row, the button and the
|
|
108
|
+
* browser's event, which a page cancels to refuse it: to open a record on a click, its own menu on a right click.
|
|
107
109
|
*
|
|
108
110
|
* Typed by its rows, `JlTable<Order>` checks and completes the fields its columns name, and hands its renderers and
|
|
109
111
|
* `detail` an order; `JlTable<Order, 'actions'>` adds a column that is not a field, which a renderer draws.
|
|
@@ -236,7 +238,7 @@ var JlTable = class extends JlElement {
|
|
|
236
238
|
this.on(this._refs.table, "change", (event) => {
|
|
237
239
|
if (isTableCheckbox(event.target)) this.changeSelection(event.target);
|
|
238
240
|
});
|
|
239
|
-
this.on(this._refs.body,
|
|
241
|
+
for (const type of PRESS_EVENTS) this.on(this._refs.body, type, (event) => this.pressRow(event));
|
|
240
242
|
}
|
|
241
243
|
/** Draws on the next microtask: the inputs set while connecting give one drawing, not one each. */
|
|
242
244
|
drawTexts() {
|
|
@@ -284,24 +286,43 @@ var JlTable = class extends JlElement {
|
|
|
284
286
|
this.events.emit("selection", keys);
|
|
285
287
|
}
|
|
286
288
|
/** A press on a row's chevron, or on the row anywhere but its controls and its checkbox, opens or closes it. */
|
|
289
|
+
/**
|
|
290
|
+
* A press on a row. The page hears of it first (`press`); then, for a click it did not refuse, an expandable row
|
|
291
|
+
* opens or closes.
|
|
292
|
+
*/
|
|
287
293
|
pressRow(event) {
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
294
|
+
const element = this.dataRowOf(event);
|
|
295
|
+
const drawn = element === void 0 ? void 0 : this._view.drawn[Number(element.dataset.index)];
|
|
296
|
+
const button = pressButtonOf(event);
|
|
297
|
+
if (element === void 0 || drawn === void 0 || button === null) return;
|
|
298
|
+
const onRow = this.isOnRowItself(event, element);
|
|
299
|
+
const press = {
|
|
300
|
+
button,
|
|
301
|
+
event,
|
|
302
|
+
key: drawn.key,
|
|
303
|
+
row: drawn.row
|
|
304
|
+
};
|
|
305
|
+
if (onRow && tellPress(event, () => this.events.emit("press", press)) || button !== "main" || !this.opensOnPress(event, element, onRow)) return;
|
|
306
|
+
this.toggle(drawn.key, !isOpen(element));
|
|
292
307
|
}
|
|
293
308
|
/** The row of data a press is on: one of the table's, not a row in the content of a detail. */
|
|
294
309
|
dataRowOf(event) {
|
|
295
310
|
const body = this._refs.body;
|
|
296
311
|
return event.composedPath().find((target) => target instanceof HTMLTableRowElement && target.parentElement === body && target.dataset.index !== void 0);
|
|
297
312
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Whether a press is on the row itself: not on a control in it (a link, a button, its chevron), nor in its
|
|
315
|
+
* selection cell, nor the end of a drag that selected text. Those keep their press for themselves.
|
|
316
|
+
*/
|
|
317
|
+
isOnRowItself(event, row) {
|
|
302
318
|
const select = row.querySelector(".select-cell");
|
|
303
|
-
const
|
|
304
|
-
return
|
|
319
|
+
const onSelectCell = select !== null && event.composedPath().includes(select);
|
|
320
|
+
return !(startedOnControl(event, row) || onSelectCell || isSelectingText());
|
|
321
|
+
}
|
|
322
|
+
/** An expandable row opens on a press on itself, and on its chevron. */
|
|
323
|
+
opensOnPress(event, row, onRow) {
|
|
324
|
+
const chevron = row.querySelector("button.expand");
|
|
325
|
+
return chevron !== null && (onRow || event.composedPath().includes(chevron));
|
|
305
326
|
}
|
|
306
327
|
renderMaxHeight(value) {
|
|
307
328
|
const height = /^\d+(\.\d+)?$/.test(value.trim()) ? `${value.trim()}px` : value;
|
|
@@ -398,6 +419,7 @@ var JlTable = class extends JlElement {
|
|
|
398
419
|
setView(drawn) {
|
|
399
420
|
this._view.drawn = drawn;
|
|
400
421
|
this._view.byKey = Map.groupBy(drawn, ({ key }) => key);
|
|
422
|
+
this._view.keys = [];
|
|
401
423
|
this._view.shown = NO_ROW_STATES();
|
|
402
424
|
}
|
|
403
425
|
/** The rows in the order of the sort, whose keys the select-all box goes by from now on. */
|
|
@@ -474,6 +496,7 @@ var JlTable = class extends JlElement {
|
|
|
474
496
|
const expand = this.isExpandable();
|
|
475
497
|
return Array.from({ length: SKELETON_ROWS }, () => /* @__PURE__ */ jsxs("tr", {
|
|
476
498
|
class: "skeleton",
|
|
499
|
+
attrs: { "aria-hidden": "true" },
|
|
477
500
|
children: [
|
|
478
501
|
select ? /* @__PURE__ */ jsx("td", {
|
|
479
502
|
class: "select-cell",
|
|
@@ -502,9 +525,6 @@ var JlTable = class extends JlElement {
|
|
|
502
525
|
})
|
|
503
526
|
});
|
|
504
527
|
}
|
|
505
|
-
keyOf(row) {
|
|
506
|
-
return this._view.drawn[Number(row.dataset.index)]?.key;
|
|
507
|
-
}
|
|
508
528
|
/**
|
|
509
529
|
* Draws a state on the rows whose keys came into it or left it since it was last drawn: checking or opening one
|
|
510
530
|
* row changes that row alone, whatever the number of rows.
|
|
@@ -514,9 +534,12 @@ var JlTable = class extends JlElement {
|
|
|
514
534
|
this._view.shown[state] = keys;
|
|
515
535
|
for (const { key, open } of changes) for (const { element } of this._view.byKey.get(key) ?? []) draw(element, open);
|
|
516
536
|
}
|
|
517
|
-
/** The bar and the shade of marked rows, changed in place. */
|
|
537
|
+
/** The bar and the shade of marked rows, changed in place; `aria-selected` tells a screen reader the same. */
|
|
518
538
|
renderMarks() {
|
|
519
|
-
this.redraw("marked", this.marked.get(), (element, on) =>
|
|
539
|
+
this.redraw("marked", this.marked.get(), (element, on) => {
|
|
540
|
+
element.toggleAttribute(MARKED_ATTRIBUTE, on);
|
|
541
|
+
setOrRemove(element, "aria-selected", on ? "true" : "");
|
|
542
|
+
});
|
|
520
543
|
}
|
|
521
544
|
/** The details of the open rows, added under them and taken away in place: one that stays open keeps its content. */
|
|
522
545
|
renderExpansion() {
|
|
@@ -3,8 +3,9 @@ import type { DownloadOptions, DownloadResult, DownloadTexts, ToasterPlacement,
|
|
|
3
3
|
export declare const TOASTER_PLACEMENTS: readonly ToasterPlacement[];
|
|
4
4
|
/**
|
|
5
5
|
* The corner of the window where notifications stack, newest nearest the edge, at most `max` at a time. It lives in
|
|
6
|
-
* the top layer, so it shows over open dialogs, and its live region reads new toasts to screen readers.
|
|
7
|
-
*
|
|
6
|
+
* the top layer, so it shows over open dialogs, and its live region reads new toasts to screen readers. While one of
|
|
7
|
+
* jlib's modals shows, the toaster sits inside it, where its toasts can be pressed. Pages usually call
|
|
8
|
+
* `toast({ heading, text, tone })`, which finds or makes the page's toaster.
|
|
8
9
|
*/
|
|
9
10
|
export declare class JlToaster extends JlElement {
|
|
10
11
|
static readonly selector = "jl-toaster";
|
|
@@ -23,6 +24,8 @@ export declare class JlToaster extends JlElement {
|
|
|
23
24
|
set(setter: string | ((prevState: string) => string)): void;
|
|
24
25
|
}>>;
|
|
25
26
|
private readonly _watched;
|
|
27
|
+
/** Where the toaster stood before it moved into a modal: it goes back there. */
|
|
28
|
+
private readonly _home;
|
|
26
29
|
private readonly _refs;
|
|
27
30
|
/**
|
|
28
31
|
* Shows a notification. It stays 5 seconds unless `duration` says otherwise, 8 for an error or with an action;
|
|
@@ -34,6 +37,14 @@ export declare class JlToaster extends JlElement {
|
|
|
34
37
|
protected drawTexts(): void;
|
|
35
38
|
onConnect(): void;
|
|
36
39
|
onDisconnect(): void;
|
|
40
|
+
/**
|
|
41
|
+
* A modal makes everything outside it inert, the top layer included: a toast shown over one could not be pressed,
|
|
42
|
+
* and a click on it reached the modal's backdrop. While a modal shows, the toaster sits inside the one on top; it
|
|
43
|
+
* goes back to its place when the last one closes.
|
|
44
|
+
*/
|
|
45
|
+
private followModal;
|
|
46
|
+
private moveInto;
|
|
47
|
+
private moveHome;
|
|
37
48
|
private toasts;
|
|
38
49
|
/** The newest `max` toasts show; the older ones wait. A dismissed toast leaves the toaster. */
|
|
39
50
|
private renderStack;
|
|
@@ -7,6 +7,7 @@ import { registerIcons } from "../lib/icons.js";
|
|
|
7
7
|
import { formatDuration } from "../lib/time.js";
|
|
8
8
|
import { formatFileSize } from "../lib/files.js";
|
|
9
9
|
import { JlToast } from "../molecules/jl-toast.js";
|
|
10
|
+
import { modalBus, topModal } from "../lib/modal.js";
|
|
10
11
|
import { answerError, dispositionFileName, readWithProgress, saveBlob, urlFileName } from "../lib/download.js";
|
|
11
12
|
import jl_toaster_default from "./jl-toaster.css.js";
|
|
12
13
|
import { css } from "@jadis/core";
|
|
@@ -46,10 +47,12 @@ var TOAST_SETTERS = {
|
|
|
46
47
|
function updateToast(toast, changes) {
|
|
47
48
|
for (const key of Object.keys(changes)) TOAST_SETTERS[key](toast, changes[key]);
|
|
48
49
|
}
|
|
50
|
+
var connectedToasters = /* @__PURE__ */ new Set();
|
|
49
51
|
/**
|
|
50
52
|
* The corner of the window where notifications stack, newest nearest the edge, at most `max` at a time. It lives in
|
|
51
|
-
* the top layer, so it shows over open dialogs, and its live region reads new toasts to screen readers.
|
|
52
|
-
*
|
|
53
|
+
* the top layer, so it shows over open dialogs, and its live region reads new toasts to screen readers. While one of
|
|
54
|
+
* jlib's modals shows, the toaster sits inside it, where its toasts can be pressed. Pages usually call
|
|
55
|
+
* `toast({ heading, text, tone })`, which finds or makes the page's toaster.
|
|
53
56
|
*/
|
|
54
57
|
var JlToaster = class extends JlElement {
|
|
55
58
|
static selector = "jl-toaster";
|
|
@@ -65,6 +68,11 @@ var JlToaster = class extends JlElement {
|
|
|
65
68
|
/** The region's name for screen readers. */
|
|
66
69
|
label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
|
|
67
70
|
_watched = /* @__PURE__ */ new WeakSet();
|
|
71
|
+
/** Where the toaster stood before it moved into a modal: it goes back there. */
|
|
72
|
+
_home = {
|
|
73
|
+
next: null,
|
|
74
|
+
parent: null
|
|
75
|
+
};
|
|
68
76
|
_refs = this.useRefs((ref) => ({
|
|
69
77
|
region: ref(".region"),
|
|
70
78
|
slot: ref("slot")
|
|
@@ -116,11 +124,45 @@ var JlToaster = class extends JlElement {
|
|
|
116
124
|
onConnect() {
|
|
117
125
|
this.renderStack();
|
|
118
126
|
this.on(this._refs.slot, "slotchange", () => this.renderStack());
|
|
127
|
+
connectedToasters.add(this);
|
|
128
|
+
this.followModal();
|
|
129
|
+
this.onBus(modalBus, "change", () => this.followModal());
|
|
119
130
|
}
|
|
120
131
|
onDisconnect() {
|
|
132
|
+
connectedToasters.delete(this);
|
|
121
133
|
const region = this._refs.region;
|
|
122
134
|
if (region.matches(OPEN)) region.hidePopover();
|
|
123
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* A modal makes everything outside it inert, the top layer included: a toast shown over one could not be pressed,
|
|
138
|
+
* and a click on it reached the modal's backdrop. While a modal shows, the toaster sits inside the one on top; it
|
|
139
|
+
* goes back to its place when the last one closes.
|
|
140
|
+
*/
|
|
141
|
+
followModal() {
|
|
142
|
+
const modal = topModal();
|
|
143
|
+
if (modal === void 0) {
|
|
144
|
+
this.moveHome();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.moveInto(modal);
|
|
148
|
+
}
|
|
149
|
+
moveInto(modal) {
|
|
150
|
+
if (this.parentNode === modal) return;
|
|
151
|
+
if (this._home.parent === null) {
|
|
152
|
+
this._home.parent = this.parentNode;
|
|
153
|
+
this._home.next = this.nextSibling;
|
|
154
|
+
}
|
|
155
|
+
modal.append(this);
|
|
156
|
+
this.renderStack();
|
|
157
|
+
}
|
|
158
|
+
moveHome() {
|
|
159
|
+
const { next, parent } = this._home;
|
|
160
|
+
if (parent === null) return;
|
|
161
|
+
this._home.parent = null;
|
|
162
|
+
this._home.next = null;
|
|
163
|
+
parent.insertBefore(this, next?.parentNode === parent ? next : null);
|
|
164
|
+
this.renderStack();
|
|
165
|
+
}
|
|
124
166
|
toasts() {
|
|
125
167
|
return [...this.children].filter((child) => child instanceof JlToast && !child.hidden);
|
|
126
168
|
}
|
|
@@ -165,9 +207,10 @@ var JlToaster = class extends JlElement {
|
|
|
165
207
|
}
|
|
166
208
|
};
|
|
167
209
|
JlToaster.register();
|
|
168
|
-
/** The page's toaster: the first one in the document, or a new one at the end of the body. */
|
|
210
|
+
/** The page's toaster: the first one connected, or in the document, or a new one at the end of the body. */
|
|
169
211
|
function pageToaster() {
|
|
170
|
-
const
|
|
212
|
+
const [connected] = connectedToasters;
|
|
213
|
+
const found = connected ?? document.querySelector(JlToaster.selector);
|
|
171
214
|
if (found !== null) return found;
|
|
172
215
|
const toaster = new JlToaster();
|
|
173
216
|
document.body.append(toaster);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-tree.css?inline
|
|
2
|
-
var jl_tree_default = ":host{--indent:16px;--row-height:30px;display:block}.tree{--level:0;color:var(--jl-text-2);font-size:var(--jl-font-md)}.group{--group-level:var(--level);position:relative}.group>*{--level:calc(var(--group-level) + 1)}.item[aria-expanded=false]>.group{display:none}.group:before{top:0;bottom:4px;left:calc(8px + var(--level) * var(--indent) + 6.5px);background:var(--jl-line);content:\"\";width:1px;position:absolute}.item:focus-visible{box-shadow:none}.row{height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));border-radius:var(--jl-radius-sm);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:6px;display:flex}.row:hover{background:var(--jl-surface-2);color:var(--jl-text)}.item:focus-visible>.row{box-shadow:var(--jl-focus-ring)}.item[aria-selected=true]>.row{background:var(--jl-accent-soft);color:var(--jl-text);font-weight:600}.chevron{width:14px;color:var(--jl-faint);transition:rotate var(--jl-fast) var(--jl-ease);flex:none;justify-content:center;display:inline-flex}.item[aria-expanded=true]>.row>.chevron{rotate:90deg}.icon{color:var(--jl-muted)}.item[aria-selected=true]>.row>.icon{color:var(--jl-accent)}.label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}a.row{color:inherit;text-decoration:none}.item.level-end>.row{color:var(--jl-muted)}.level-end[aria-disabled=true]>.row{cursor:default}.level-end[aria-disabled=true]>.row:hover{background:0 0}.spinner{color:var(--jl-muted);flex:none}.more,.retry{color:var(--jl-accent);flex:none;font-weight:500}.level-end>.row:hover .more,.level-end>.row:hover .retry{color:var(--jl-accent-strong)}.icon.error{color:var(--jl-danger)}.note{min-height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));color:var(--jl-muted);align-items:center;gap:6px;display:flex}.badge{color:var(--jl-
|
|
2
|
+
var jl_tree_default = ":host{--indent:16px;--row-height:30px;display:block}.tree{--level:0;color:var(--jl-text-2);font-size:var(--jl-font-md)}.group{--group-level:var(--level);position:relative}.group>*{--level:calc(var(--group-level) + 1)}.item[aria-expanded=false]>.group{display:none}.group:before{top:0;bottom:4px;left:calc(8px + var(--level) * var(--indent) + 6.5px);background:var(--jl-line);content:\"\";width:1px;position:absolute}.item:focus-visible{box-shadow:none}.row{height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));border-radius:var(--jl-radius-sm);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:6px;display:flex}.row:hover{background:var(--jl-surface-2);color:var(--jl-text)}.item:focus-visible>.row{box-shadow:var(--jl-focus-ring)}.item[aria-selected=true]>.row{background:var(--jl-accent-soft);color:var(--jl-text);font-weight:600}.chevron{width:14px;color:var(--jl-faint);transition:rotate var(--jl-fast) var(--jl-ease);flex:none;justify-content:center;display:inline-flex}.item[aria-expanded=true]>.row>.chevron{rotate:90deg}.icon{color:var(--jl-muted)}.item[aria-selected=true]>.row>.icon{color:var(--jl-accent)}.label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}a.row{color:inherit;text-decoration:none}.item.level-end>.row{color:var(--jl-muted)}.level-end[aria-disabled=true]>.row{cursor:default}.level-end[aria-disabled=true]>.row:hover{background:0 0}.spinner{color:var(--jl-muted);flex:none}.more,.retry{color:var(--jl-accent);flex:none;font-weight:500}.level-end>.row:hover .more,.level-end>.row:hover .retry{color:var(--jl-accent-strong)}.icon.error{color:var(--jl-danger)}.note{min-height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));color:var(--jl-muted);align-items:center;gap:6px;display:flex}.badge{color:var(--jl-muted);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;flex:none;margin-left:auto}";
|
|
3
3
|
export { jl_tree_default as default };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { JlElement } from '../base/jl-element';
|
|
2
|
-
import type { TreeItem, TreeLoader } from '../types/jl-tree.types';
|
|
2
|
+
import type { TreeItem, TreeLoader, TreePress } from '../types/jl-tree.types';
|
|
3
3
|
/**
|
|
4
4
|
* Nested items that open and close, as files in folders: `items` holds them, `expanded` lists the open folders and
|
|
5
5
|
* `value` is the selected item. With a `loader`, the tree loads itself a level at a time and a page at a time, so a
|
|
6
6
|
* large archive opens without loading everything: the roots first, a `lazy` folder's children when it opens, and
|
|
7
7
|
* the next page of a level from the button that ends it. The keyboard follows the tree pattern: Up and Down move,
|
|
8
8
|
* Right opens or enters a folder, Left closes it or goes to the parent, Home and End jump, Enter selects. Emits
|
|
9
|
-
* `select` and `toggle`; an item with an `href` is a link instead.
|
|
9
|
+
* `select` and `toggle`; an item with an `href` is a link instead. A press on an item fires `press` first, with
|
|
10
|
+
* the item, the button and the browser's event, which a page cancels to refuse it: its own menu on a right click.
|
|
10
11
|
*/
|
|
11
12
|
export declare class JlTree extends JlElement {
|
|
12
13
|
static readonly selector = "jl-tree";
|
|
@@ -16,6 +17,7 @@ export declare class JlTree extends JlElement {
|
|
|
16
17
|
id: string;
|
|
17
18
|
open: boolean;
|
|
18
19
|
};
|
|
20
|
+
press: TreePress;
|
|
19
21
|
}>>;
|
|
20
22
|
readonly items: Readonly<Readonly<{
|
|
21
23
|
get(): TreeItem[];
|
|
@@ -84,10 +86,21 @@ export declare class JlTree extends JlElement {
|
|
|
84
86
|
onConnect(): void;
|
|
85
87
|
private idOf;
|
|
86
88
|
/**
|
|
87
|
-
* A press selects the item; on a folder it also opens or closes it, and the chevron
|
|
88
|
-
* leaves a modified click (a new tab) to the browser.
|
|
89
|
+
* A press on a row. The main button selects the item; on a folder it also opens or closes it, and the chevron
|
|
90
|
+
* only does that. A link's row leaves a modified click (a new tab) to the browser. The page hears of a press on
|
|
91
|
+
* an item first, whatever its button (`press`), and refuses it by cancelling the event.
|
|
89
92
|
*/
|
|
90
93
|
private press;
|
|
94
|
+
/** A press on what the tree handles alone, with the main button: the row that ends a level, a folder's chevron. */
|
|
95
|
+
private pressOwnControl;
|
|
96
|
+
private toggleFolder;
|
|
97
|
+
/**
|
|
98
|
+
* Tells the page of a press on an item.
|
|
99
|
+
* @returns Whether the page refused it, by cancelling the event
|
|
100
|
+
*/
|
|
101
|
+
private tellItemPress;
|
|
102
|
+
/** Enter or Space on an item is a press too, of the main button: the page hears of it, and may refuse it. */
|
|
103
|
+
private tellKeyPress;
|
|
91
104
|
private handleKey;
|
|
92
105
|
/** Enter on an item: the row that ends a level loads its page, a link is followed, an item is selected. */
|
|
93
106
|
private activate;
|
|
@@ -116,6 +129,12 @@ export declare class JlTree extends JlElement {
|
|
|
116
129
|
private levelEnd;
|
|
117
130
|
private hasLevelEndRow;
|
|
118
131
|
protected drawTexts(): void;
|
|
132
|
+
/**
|
|
133
|
+
* The tree's own texts show only in the rows that end a level (a note, a spinner, "show more", an error): those
|
|
134
|
+
* are drawn again, the items stay. Every input's callback runs as the tree appears: each one building every row,
|
|
135
|
+
* a tree built its rows seven times.
|
|
136
|
+
*/
|
|
137
|
+
private drawLevelEnds;
|
|
119
138
|
private errorLabel;
|
|
120
139
|
private renderItemsUnlessQuiet;
|
|
121
140
|
/** Sets `items` without drawing every row again, which its callback does on each set(), even of an equal value. */
|
|
@@ -7,6 +7,7 @@ import { registerIcons } from "../lib/icons.js";
|
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
8
|
import { isModifiedClick, setOrRemove, uniqueId } from "../lib/dom.js";
|
|
9
9
|
import { JlSpinner } from "../atoms/jl-spinner.js";
|
|
10
|
+
import { PRESS_EVENTS, pressButtonOf, tellPress } from "../lib/press.js";
|
|
10
11
|
import { allItems, childrenOf, isFolder, treeKeyAction, withExpanded, withExtraRows, withPage } from "../lib/tree.js";
|
|
11
12
|
import jl_tree_default from "./jl-tree.css.js";
|
|
12
13
|
import { css } from "@jadis/core";
|
|
@@ -41,7 +42,8 @@ var rowsIn = (nodes) => new Map(nodes.filter((node) => node instanceof HTMLEleme
|
|
|
41
42
|
* large archive opens without loading everything: the roots first, a `lazy` folder's children when it opens, and
|
|
42
43
|
* the next page of a level from the button that ends it. The keyboard follows the tree pattern: Up and Down move,
|
|
43
44
|
* Right opens or enters a folder, Left closes it or goes to the parent, Home and End jump, Enter selects. Emits
|
|
44
|
-
* `select` and `toggle`; an item with an `href` is a link instead.
|
|
45
|
+
* `select` and `toggle`; an item with an `href` is a link instead. A press on an item fires `press` first, with
|
|
46
|
+
* the item, the button and the browser's event, which a page cancels to refuse it: its own menu on a right click.
|
|
45
47
|
*/
|
|
46
48
|
var JlTree = class extends JlElement {
|
|
47
49
|
static selector = "jl-tree";
|
|
@@ -63,15 +65,15 @@ var JlTree = class extends JlElement {
|
|
|
63
65
|
/** The tree's name for screen readers. */
|
|
64
66
|
label = this.useChange("", (value) => setOrRemove(this._refs.tree, "aria-label", value), { attribute: "label" });
|
|
65
67
|
/** What an empty tree says, such as "No object yet"; none by default. */
|
|
66
|
-
emptyText = this.useChange("", () => this.
|
|
68
|
+
emptyText = this.useChange("", () => this.drawLevelEnds(), { attribute: "empty-text" });
|
|
67
69
|
/** Said while a page loads; jlib's own text when empty. */
|
|
68
|
-
loadingText = this.useChange("", () => this.
|
|
70
|
+
loadingText = this.useChange("", () => this.drawLevelEnds(), { attribute: "loading-text" });
|
|
69
71
|
/** The button that loads a level's next page, `{count}` being how many items are left; jlib's own when empty. */
|
|
70
|
-
moreText = this.useChange("", () => this.
|
|
72
|
+
moreText = this.useChange("", () => this.drawLevelEnds(), { attribute: "more-text" });
|
|
71
73
|
/** Said where a page could not be loaded; jlib's own text when empty. */
|
|
72
|
-
errorText = this.useChange("", () => this.
|
|
74
|
+
errorText = this.useChange("", () => this.drawLevelEnds(), { attribute: "error-text" });
|
|
73
75
|
/** The action that loads it again; jlib's own text when empty. */
|
|
74
|
-
retryLabel = this.useChange("", () => this.
|
|
76
|
+
retryLabel = this.useChange("", () => this.drawLevelEnds(), { attribute: "retry-label" });
|
|
75
77
|
_source = { loader: null };
|
|
76
78
|
_rows = /* @__PURE__ */ new Map();
|
|
77
79
|
_focus = { id: "" };
|
|
@@ -133,7 +135,7 @@ var JlTree = class extends JlElement {
|
|
|
133
135
|
}
|
|
134
136
|
onConnect() {
|
|
135
137
|
const tree = this._refs.tree;
|
|
136
|
-
this.on(tree,
|
|
138
|
+
for (const type of PRESS_EVENTS) this.on(tree, type, (event) => this.press(event));
|
|
137
139
|
this.on(tree, "keydown", (event) => this.handleKey(event));
|
|
138
140
|
this.on(tree, "focusin", (event) => {
|
|
139
141
|
const id = this.idOf(event.target);
|
|
@@ -144,30 +146,71 @@ var JlTree = class extends JlElement {
|
|
|
144
146
|
return (target instanceof Element ? target.closest("[role=\"treeitem\"]") : null)?.dataset.id ?? null;
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
|
-
* A press selects the item; on a folder it also opens or closes it, and the chevron
|
|
148
|
-
* leaves a modified click (a new tab) to the browser.
|
|
149
|
+
* A press on a row. The main button selects the item; on a folder it also opens or closes it, and the chevron
|
|
150
|
+
* only does that. A link's row leaves a modified click (a new tab) to the browser. The page hears of a press on
|
|
151
|
+
* an item first, whatever its button (`press`), and refuses it by cancelling the event.
|
|
149
152
|
*/
|
|
150
153
|
press(event) {
|
|
151
154
|
const id = this.idOf(event.target);
|
|
152
|
-
|
|
155
|
+
const button = pressButtonOf(event);
|
|
156
|
+
if (id === null || button === null) return;
|
|
157
|
+
const item = isLevelEnd(id) ? void 0 : this.findItem(id);
|
|
158
|
+
const onChevron = event.target instanceof Element && event.target.closest(".chevron") !== null;
|
|
159
|
+
if (item === void 0 || onChevron) {
|
|
160
|
+
this.pressOwnControl(event, id, button);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (item.href !== void 0 && button === "main" && isModifiedClick(event) || this.tellItemPress({
|
|
164
|
+
button,
|
|
165
|
+
event,
|
|
166
|
+
id,
|
|
167
|
+
item
|
|
168
|
+
}) || button !== "main") return;
|
|
169
|
+
this.toggleFolder(item);
|
|
170
|
+
this.select(item);
|
|
171
|
+
this.moveFocus(id, true);
|
|
172
|
+
}
|
|
173
|
+
/** A press on what the tree handles alone, with the main button: the row that ends a level, a folder's chevron. */
|
|
174
|
+
pressOwnControl(event, id, button) {
|
|
175
|
+
if (button !== "main") return;
|
|
176
|
+
if (isLevelEnd(id)) {
|
|
153
177
|
this.loadNextPage(parentOfLevelEnd(id));
|
|
154
178
|
return;
|
|
155
179
|
}
|
|
156
|
-
const item =
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (item.href !== void 0 && !onChevron && isModifiedClick(event)) return;
|
|
161
|
-
if (isFolder(item)) this.toggle(id, !this.expanded.get().includes(id));
|
|
162
|
-
if (!onChevron) this.select(item);
|
|
180
|
+
const item = this.findItem(id);
|
|
181
|
+
if (item === void 0) return;
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
this.toggleFolder(item);
|
|
163
184
|
this.moveFocus(id, true);
|
|
164
185
|
}
|
|
186
|
+
toggleFolder(item) {
|
|
187
|
+
if (isFolder(item)) this.toggle(item.id, !this.expanded.get().includes(item.id));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Tells the page of a press on an item.
|
|
191
|
+
* @returns Whether the page refused it, by cancelling the event
|
|
192
|
+
*/
|
|
193
|
+
tellItemPress(press) {
|
|
194
|
+
return tellPress(press.event, () => this.events.emit("press", press));
|
|
195
|
+
}
|
|
196
|
+
/** Enter or Space on an item is a press too, of the main button: the page hears of it, and may refuse it. */
|
|
197
|
+
tellKeyPress(id, event) {
|
|
198
|
+
const item = isLevelEnd(id) ? void 0 : this.findItem(id);
|
|
199
|
+
return item !== void 0 && this.tellItemPress({
|
|
200
|
+
button: "main",
|
|
201
|
+
event,
|
|
202
|
+
id,
|
|
203
|
+
item
|
|
204
|
+
});
|
|
205
|
+
}
|
|
165
206
|
handleKey(event) {
|
|
166
207
|
const focused = this._focus.id;
|
|
167
208
|
const keyboardItems = withExtraRows(this.items.get(), (parent) => this.hasLevelEndRow(parent) ? levelEndId(parent) : null);
|
|
168
209
|
const action = treeKeyAction(keyboardItems, new Set(this.expanded.get()), focused, event.key);
|
|
169
210
|
if (action === null) return;
|
|
211
|
+
const refused = action.kind === "select" && this.tellKeyPress(action.id, event);
|
|
170
212
|
event.preventDefault();
|
|
213
|
+
if (refused) return;
|
|
171
214
|
({
|
|
172
215
|
focus: () => this.moveFocus(action.id, true),
|
|
173
216
|
select: () => this.activate(action.id),
|
|
@@ -295,7 +338,20 @@ var JlTree = class extends JlElement {
|
|
|
295
338
|
return end !== "none" && end !== "empty";
|
|
296
339
|
}
|
|
297
340
|
drawTexts() {
|
|
298
|
-
this.
|
|
341
|
+
this.drawLevelEnds();
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The tree's own texts show only in the rows that end a level (a note, a spinner, "show more", an error): those
|
|
345
|
+
* are drawn again, the items stay. Every input's callback runs as the tree appears: each one building every row,
|
|
346
|
+
* a tree built its rows seven times.
|
|
347
|
+
*/
|
|
348
|
+
drawLevelEnds() {
|
|
349
|
+
if (this.items.get().length === 0) {
|
|
350
|
+
this.renderItems();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const drawnLevels = [...this._loading.levels.keys()].filter((parent) => this.levelContainer(parent) !== null);
|
|
354
|
+
for (const parent of drawnLevels) this.redrawLevelEnd(parent);
|
|
299
355
|
}
|
|
300
356
|
errorLabel() {
|
|
301
357
|
return this.errorText.get() || jlText("loadError");
|
package/dist/styles/base.css.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/styles/base.css?inline
|
|
2
|
-
var base_default = ":host{box-sizing:border-box;font-family:var(--jl-font-sans);-webkit-tap-highlight-color:transparent}:host([hidden]){display:none!important}*,:before,:after{box-sizing:inherit}[hidden]{display:none!important}button,input,select,textarea{font:inherit;color:inherit}:focus-visible{box-shadow:var(--jl-focus-ring);outline:none}h1,h2,h3,h4,p,ul,ol,figure{margin:0}code,kbd,pre{font-family:var(--jl-font-mono)}.sr-only{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:1ms!important;animation-duration:1ms!important;animation-iteration-count:1!important}}";
|
|
2
|
+
var base_default = ":host{box-sizing:border-box;font-family:var(--jl-font-sans);-webkit-tap-highlight-color:transparent}:host([hidden]){display:none!important}*,:before,:after{box-sizing:inherit}[hidden]{display:none!important}button,input,select,textarea{font:inherit;color:inherit}:focus-visible{box-shadow:var(--jl-focus-ring);outline:none}h1,h2,h3,h4,p,ul,ol,figure{margin:0}code,kbd,pre{font-family:var(--jl-font-mono)}.sr-only{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}@media (forced-colors:active){:focus-visible{outline-offset:2px!important;outline:2px solid highlight!important}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:1ms!important;animation-duration:1ms!important;animation-iteration-count:1!important}}";
|
|
3
3
|
export { base_default as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/styles/control.css?inline
|
|
2
|
-
var control_default = ".control{width:100%;min-height:var(--height,var(--jl-control-md));border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-sm);background:var(--jl-surface);color:var(--jl-text);font-size:var(--jl-control-font);transition:border-color var(--jl-fast) var(--jl-ease), box-shadow var(--jl-fast) var(--jl-ease);align-items:center;gap:8px;padding:0 12px;line-height:20px;display:flex}.control:hover{border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%)}.control:focus-within{border-color:var(--jl-accent);box-shadow:var(--jl-focus-ring)}:host([invalid]) .control{border-color:var(--jl-danger)}:host([invalid]) .control:focus-within{box-shadow:0 0 0 3px color-mix(in srgb, var(--jl-danger) 25%, transparent)}:host([disabled]) .control,:host(:disabled) .control{background:var(--jl-surface-2);color:var(--jl-muted);cursor:not-allowed}:host([size=sm]){--height:var(--jl-control-sm)}:host([size=lg]){--height:var(--jl-control-lg)}.native{min-width:0;height:calc(var(--height,var(--jl-control-md)) - 2px);color:inherit;font:inherit;background:0 0;border:none;outline:none;flex:1;padding:0}.native::placeholder{color:var(--jl-
|
|
2
|
+
var control_default = ".control{width:100%;min-height:var(--height,var(--jl-control-md));border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-sm);background:var(--jl-surface);color:var(--jl-text);font-size:var(--jl-control-font);transition:border-color var(--jl-fast) var(--jl-ease), box-shadow var(--jl-fast) var(--jl-ease);align-items:center;gap:8px;padding:0 12px;line-height:20px;display:flex}.control:hover{border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%)}.control:focus-within{border-color:var(--jl-accent);box-shadow:var(--jl-focus-ring)}:host([invalid]) .control{border-color:var(--jl-danger)}:host([invalid]) .control:focus-within{box-shadow:0 0 0 3px color-mix(in srgb, var(--jl-danger) 25%, transparent)}:host([disabled]) .control,:host(:disabled) .control{background:var(--jl-surface-2);color:var(--jl-muted);cursor:not-allowed}:host([size=sm]){--height:var(--jl-control-sm)}:host([size=lg]){--height:var(--jl-control-lg)}.native{min-width:0;height:calc(var(--height,var(--jl-control-md)) - 2px);color:inherit;font:inherit;background:0 0;border:none;outline:none;flex:1;padding:0}.native::placeholder{color:var(--jl-muted)}.native:focus-visible{box-shadow:none}.native:disabled{cursor:not-allowed}.adornment{color:var(--jl-faint);flex:none;align-items:center;display:inline-flex}.action{border-radius:var(--jl-radius-xs);width:24px;height:24px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;flex:none;justify-content:center;align-items:center;margin-right:-4px;padding:0;display:inline-flex}.action:hover{background:var(--jl-surface-3);color:var(--jl-text)}";
|
|
3
3
|
export { control_default as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/styles/tokens.css?inline
|
|
2
|
-
var tokens_default = "@layer jlib{:root,[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--jl-font-sans:\"Manrope Variable\", \"Manrope\", system-ui, -apple-system, \"Segoe UI\", sans-serif;--jl-font-mono:\"JetBrains Mono Variable\", \"JetBrains Mono\", ui-monospace, \"SF Mono\", Menlo, monospace;--jl-font-xs:12px;--jl-font-sm:13px;--jl-font-md:14px;--jl-font-lg:16px;--jl-font-xl:20px;--jl-font-2xl:28px;--jl-text:#0b0b0c;--jl-text-2:#3a3f47;--jl-muted:#5b616b;--jl-faint:#8a9099;--jl-bg:#fff;--jl-surface:#fff;--jl-surface-2:#f7f8f9;--jl-surface-3:#eef0f2;--jl-code-bg:#f0f2f4;--jl-line:#e6e8eb;--jl-line-soft:#eef0f2;--jl-line-strong:#d5d9de;--jl-brand:#0e88d3;--jl-accent:#0c72b0;--jl-accent-strong:#095a8b;--jl-accent-soft:#e9f4fb;--jl-accent-line:#b7dbf2;--jl-on-accent:#fff;--jl-on-brand:#fff;--jl-ok:#17784a;--jl-ok-soft:#ecf6f0;--jl-warn:#9a5b00;--jl-warn-soft:#fcf4e6;--jl-danger:#b42318;--jl-danger-soft:#fdf0ef;--jl-on-danger:#fff;--jl-info:#0c72b0;--jl-info-soft:#e9f4fb;--jl-code-keyword:#0c72b0;--jl-code-tag:#095a8b;--jl-code-attribute:#5b48c8;--jl-code-string:#17784a;--jl-code-number:#9a5b00;--jl-code-function:#3d5a80;--jl-code-property:#127a72;--jl-code-comment
|
|
2
|
+
var tokens_default = "@layer jlib{:root,[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--jl-font-sans:\"Manrope Variable\", \"Manrope\", system-ui, -apple-system, \"Segoe UI\", sans-serif;--jl-font-mono:\"JetBrains Mono Variable\", \"JetBrains Mono\", ui-monospace, \"SF Mono\", Menlo, monospace;--jl-font-xs:12px;--jl-font-sm:13px;--jl-font-md:14px;--jl-font-lg:16px;--jl-font-xl:20px;--jl-font-2xl:28px;--jl-text:#0b0b0c;--jl-text-2:#3a3f47;--jl-muted:#5b616b;--jl-faint:#8a9099;--jl-bg:#fff;--jl-surface:#fff;--jl-surface-2:#f7f8f9;--jl-surface-3:#eef0f2;--jl-code-bg:#f0f2f4;--jl-line:#e6e8eb;--jl-line-soft:#eef0f2;--jl-line-strong:#d5d9de;--jl-brand:#0e88d3;--jl-accent:#0c72b0;--jl-accent-strong:#095a8b;--jl-accent-soft:#e9f4fb;--jl-accent-line:#b7dbf2;--jl-on-accent:#fff;--jl-on-brand:#fff;--jl-ok:#17784a;--jl-ok-soft:#ecf6f0;--jl-warn:#9a5b00;--jl-warn-soft:#fcf4e6;--jl-danger:#b42318;--jl-danger-soft:#fdf0ef;--jl-on-danger:#fff;--jl-info:#0c72b0;--jl-info-soft:#e9f4fb;--jl-code-keyword:#0c72b0;--jl-code-tag:#095a8b;--jl-code-attribute:#5b48c8;--jl-code-string:#17784a;--jl-code-number:#9a5b00;--jl-code-function:#3d5a80;--jl-code-property:#127a72;--jl-code-comment:var(--jl-muted);--jl-radius-xs:6px;--jl-radius-sm:8px;--jl-radius:10px;--jl-radius-lg:12px;--jl-radius-xl:20px;--jl-radius-pill:999px;--jl-space-1:4px;--jl-space-2:8px;--jl-space-3:12px;--jl-space-4:16px;--jl-space-5:20px;--jl-space-6:24px;--jl-space-8:32px;--jl-space-10:40px;--jl-space-12:48px;--jl-space-16:64px;--jl-control-sm:30px;--jl-control-md:36px;--jl-control-lg:44px;--jl-control-font:var(--jl-font-md);--jl-page-form:720px;--jl-page-standard:1120px;--jl-page-wide:1400px;--jl-shadow-sm:0 1px 2px #0b0b0c0d;--jl-shadow:0 6px 16px -6px #0b0b0c1f;--jl-shadow-lg:0 18px 44px -14px #0b0b0c38;--jl-focus-ring:0 0 0 3px color-mix(in srgb, var(--jl-brand) 35%, transparent);--jl-scrim:#0b0b0c61;--jl-ease:cubic-bezier(.2, .7, .2, 1);--jl-fast:.12s;--jl-slow:.24s}@media (prefers-color-scheme:dark){:root:not([data-theme=light]){--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--jl-text:#eceef1;--jl-text-2:#c3c8cf;--jl-muted:#959ca6;--jl-faint:#6b727c;--jl-bg:#0f1113;--jl-surface:#0f1113;--jl-surface-2:#16191c;--jl-surface-3:#1d2125;--jl-code-bg:#1d2125;--jl-line:#262a2f;--jl-line-soft:#1f2327;--jl-line-strong:#343a41;--jl-brand:#1a9be0;--jl-accent:#3ea6e8;--jl-accent-strong:#6cc0f2;--jl-accent-soft:#0f2a3b;--jl-accent-line:#1e4a66;--jl-on-accent:#04131c;--jl-ok:#4cc38a;--jl-ok-soft:#10261c;--jl-warn:#e5a54b;--jl-warn-soft:#2a2012;--jl-danger:#f0786c;--jl-danger-soft:#3a1a17;--jl-on-danger:#1c0604;--jl-info:#3ea6e8;--jl-info-soft:#0f2a3b;--jl-code-keyword:#3ea6e8;--jl-code-tag:#6cc0f2;--jl-code-attribute:#a99bf0;--jl-code-string:#4cc38a;--jl-code-number:#e5a54b;--jl-code-function:#8fb0d6;--jl-code-property:#4fc1b5;--jl-code-comment:var(--jl-muted);--jl-shadow-sm:0 1px 2px #0006;--jl-shadow:0 6px 18px -6px #0009;--jl-shadow-lg:0 18px 44px -12px #000000b3;--jl-scrim:#0000008c}}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--jl-text:#eceef1;--jl-text-2:#c3c8cf;--jl-muted:#959ca6;--jl-faint:#6b727c;--jl-bg:#0f1113;--jl-surface:#0f1113;--jl-surface-2:#16191c;--jl-surface-3:#1d2125;--jl-code-bg:#1d2125;--jl-line:#262a2f;--jl-line-soft:#1f2327;--jl-line-strong:#343a41;--jl-brand:#1a9be0;--jl-accent:#3ea6e8;--jl-accent-strong:#6cc0f2;--jl-accent-soft:#0f2a3b;--jl-accent-line:#1e4a66;--jl-on-accent:#04131c;--jl-ok:#4cc38a;--jl-ok-soft:#10261c;--jl-warn:#e5a54b;--jl-warn-soft:#2a2012;--jl-danger:#f0786c;--jl-danger-soft:#3a1a17;--jl-on-danger:#1c0604;--jl-info:#3ea6e8;--jl-info-soft:#0f2a3b;--jl-code-keyword:#3ea6e8;--jl-code-tag:#6cc0f2;--jl-code-attribute:#a99bf0;--jl-code-string:#4cc38a;--jl-code-number:#e5a54b;--jl-code-function:#8fb0d6;--jl-code-property:#4fc1b5;--jl-code-comment:var(--jl-muted);--jl-shadow-sm:0 1px 2px #0006;--jl-shadow:0 6px 18px -6px #0009;--jl-shadow-lg:0 18px 44px -12px #000000b3;--jl-scrim:#0000008c}@media (pointer:coarse){:root,[data-theme=light],[data-theme=dark]{--jl-control-sm:36px;--jl-control-md:44px;--jl-control-lg:48px;--jl-control-font:16px}}}";
|
|
3
3
|
export { tokens_default as default };
|
package/dist/tokens.css
CHANGED
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
--jl-code-number: #9a5b00;
|
|
63
63
|
--jl-code-function: #3d5a80;
|
|
64
64
|
--jl-code-property: #127a72;
|
|
65
|
-
|
|
65
|
+
/* Comments are text: the lightest ink text may have, not the fainter one of icons. */
|
|
66
|
+
--jl-code-comment: var(--jl-muted);
|
|
66
67
|
|
|
67
68
|
--jl-radius-xs: 6px;
|
|
68
69
|
--jl-radius-sm: 8px;
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
--jl-code-number: #e5a54b;
|
|
144
145
|
--jl-code-function: #8fb0d6;
|
|
145
146
|
--jl-code-property: #4fc1b5;
|
|
146
|
-
--jl-code-comment:
|
|
147
|
+
--jl-code-comment: var(--jl-muted);
|
|
147
148
|
--jl-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
|
|
148
149
|
--jl-shadow: 0 6px 18px -6px rgb(0 0 0 / 0.6);
|
|
149
150
|
--jl-shadow-lg: 0 18px 44px -12px rgb(0 0 0 / 0.7);
|
|
@@ -188,7 +189,7 @@
|
|
|
188
189
|
--jl-code-number: #e5a54b;
|
|
189
190
|
--jl-code-function: #8fb0d6;
|
|
190
191
|
--jl-code-property: #4fc1b5;
|
|
191
|
-
--jl-code-comment:
|
|
192
|
+
--jl-code-comment: var(--jl-muted);
|
|
192
193
|
--jl-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
|
|
193
194
|
--jl-shadow: 0 6px 18px -6px rgb(0 0 0 / 0.6);
|
|
194
195
|
--jl-shadow-lg: 0 18px 44px -12px rgb(0 0 0 / 0.7);
|
|
@@ -8,3 +8,10 @@ export type LoadTask<Value> = {
|
|
|
8
8
|
draw: (value: Value) => void;
|
|
9
9
|
isEmpty?: (value: Value) => boolean;
|
|
10
10
|
};
|
|
11
|
+
/** What a load's fetch came to: its value, or that it failed. */
|
|
12
|
+
export type Fetched<Value> = {
|
|
13
|
+
failed: false;
|
|
14
|
+
value: Value;
|
|
15
|
+
} | {
|
|
16
|
+
failed: true;
|
|
17
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Tone } from './options.types';
|
|
2
|
+
import type { PressButton } from './press.types';
|
|
2
3
|
/** How a cell shows its value: as it is, a localised number, date or date and time, a badge, or code. */
|
|
3
4
|
export type TableCellFormat = 'text' | 'number' | 'date' | 'datetime' | 'badge' | 'code';
|
|
4
5
|
export type TableAlign = 'left' | 'center' | 'right';
|
|
@@ -61,3 +62,14 @@ export type TableToggle = {
|
|
|
61
62
|
key: TableRowKey;
|
|
62
63
|
open: boolean;
|
|
63
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* A press on a row: which row, with which button, and the browser's event. The event says where the pointer is
|
|
67
|
+
* (`clientX`, `clientY`); cancelling it (`event.preventDefault()`) refuses the press: the browser's menu does not
|
|
68
|
+
* show for the secondary button, and an expandable row stays as it is for the main one.
|
|
69
|
+
*/
|
|
70
|
+
export type TablePress<Row extends object = TableRow> = {
|
|
71
|
+
key: TableRowKey;
|
|
72
|
+
row: Row;
|
|
73
|
+
button: PressButton;
|
|
74
|
+
event: MouseEvent;
|
|
75
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PressButton } from './press.types';
|
|
1
2
|
export type TreeItem = {
|
|
2
3
|
id: string;
|
|
3
4
|
label: string;
|
|
@@ -14,6 +15,22 @@ export type TreeItem = {
|
|
|
14
15
|
/** A count or a short word after the label: how many items a folder holds. */
|
|
15
16
|
badge?: string | number;
|
|
16
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* A press on an item: which one, with which button, and the browser's event. The main button is a pointer's or the
|
|
20
|
+
* keyboard's (Enter, Space); the others are always a pointer's event, which says where it is (`clientX`,
|
|
21
|
+
* `clientY`). Cancelling the event (`event.preventDefault()`) refuses the press: the item is not selected, its
|
|
22
|
+
* folder stays as it is, a link is not followed, and the browser's menu does not show.
|
|
23
|
+
*/
|
|
24
|
+
export type TreePress = {
|
|
25
|
+
id: string;
|
|
26
|
+
item: TreeItem;
|
|
27
|
+
} & ({
|
|
28
|
+
button: Extract<PressButton, 'main'>;
|
|
29
|
+
event: MouseEvent | KeyboardEvent;
|
|
30
|
+
} | {
|
|
31
|
+
button: Exclude<PressButton, 'main'>;
|
|
32
|
+
event: MouseEvent;
|
|
33
|
+
});
|
|
17
34
|
/** One page of a level, as a loader answers it: some of its items, and how many the level has in all. */
|
|
18
35
|
export type TreePage = {
|
|
19
36
|
items: TreeItem[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The button of a press on a row or an item: the main one (a click, a tap, Enter), the auxiliary one (a middle
|
|
3
|
+
* click), or the secondary one, which asks for a menu (a right click, the keyboard's menu key, a long press on a
|
|
4
|
+
* touch screen).
|
|
5
|
+
*/
|
|
6
|
+
export type PressButton = 'main' | 'auxiliary' | 'secondary';
|