@syware/jlib 0.6.0 → 0.8.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/dist/all.js +10 -5
- package/dist/atoms/jl-app-icon.d.ts +5 -0
- package/dist/atoms/jl-app-icon.js +26 -4
- package/dist/atoms/jl-badge.js +1 -1
- package/dist/atoms/jl-button.d.ts +5 -0
- package/dist/atoms/jl-button.js +4 -1
- package/dist/atoms/jl-chip.js +3 -2
- package/dist/atoms/jl-input.js +4 -3
- package/dist/atoms/jl-link.js +1 -1
- package/dist/atoms/jl-rating.js +4 -5
- package/dist/atoms/jl-select.css_raw.js +1 -1
- package/dist/atoms/jl-select.d.ts +10 -8
- package/dist/atoms/jl-select.js +15 -9
- package/dist/atoms/jl-spinner.js +2 -2
- package/dist/base/jl-form-control.js +2 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -4
- package/dist/lib/app-icon.d.ts +8 -0
- package/dist/lib/app-icon.js +37 -0
- package/dist/lib/attributes.d.ts +9 -0
- package/dist/lib/attributes.js +10 -1
- package/dist/lib/dom.d.ts +2 -0
- package/dist/lib/dom.js +3 -1
- package/dist/lib/download.d.ts +10 -0
- package/dist/lib/download.js +62 -0
- package/dist/lib/icons.d.ts +4 -0
- package/dist/lib/icons.js +7 -4
- package/dist/lib/input-list.d.ts +12 -0
- package/dist/lib/input-list.js +14 -0
- package/dist/lib/internals.d.ts +5 -0
- package/dist/lib/internals.js +18 -0
- package/dist/lib/nav-tree.d.ts +2 -2
- package/dist/lib/palette.d.ts +2 -2
- package/dist/lib/palette.js +6 -0
- package/dist/lib/resize.d.ts +2 -0
- package/dist/lib/resize.js +10 -0
- package/dist/lib/table.d.ts +22 -4
- package/dist/lib/table.js +55 -5
- package/dist/lib/text.d.ts +2 -0
- package/dist/lib/text.js +4 -1
- package/dist/lib/texts.d.ts +99 -0
- package/dist/lib/texts.js +104 -0
- package/dist/lib/tree.d.ts +10 -1
- package/dist/lib/tree.js +37 -3
- package/dist/molecules/jl-account-button.js +1 -1
- package/dist/molecules/jl-alert.js +2 -1
- package/dist/molecules/jl-breadcrumb.js +3 -3
- package/dist/molecules/jl-calendar.js +4 -4
- package/dist/molecules/jl-chip-group.d.ts +7 -6
- package/dist/molecules/jl-chip-group.js +8 -6
- package/dist/molecules/jl-code-block.css_raw.js +1 -1
- package/dist/molecules/jl-code-block.d.ts +5 -0
- package/dist/molecules/jl-code-block.js +5 -2
- package/dist/molecules/jl-combobox.js +5 -6
- package/dist/molecules/jl-copy-button.js +5 -4
- package/dist/molecules/jl-date-picker.js +6 -7
- package/dist/molecules/jl-empty.js +1 -1
- package/dist/molecules/jl-facts.css_raw.js +3 -0
- package/dist/molecules/jl-facts.d.ts +35 -0
- package/dist/molecules/jl-facts.js +64 -0
- package/dist/molecules/jl-file-drop.d.ts +5 -0
- package/dist/molecules/jl-file-drop.js +17 -14
- package/dist/molecules/jl-input-list.css_raw.js +3 -0
- package/dist/molecules/jl-input-list.d.ts +79 -0
- package/dist/molecules/jl-input-list.js +177 -0
- package/dist/molecules/jl-load-more.css_raw.js +3 -0
- package/dist/molecules/jl-load-more.d.ts +41 -0
- package/dist/molecules/jl-load-more.js +62 -0
- package/dist/molecules/jl-load-state.js +6 -7
- package/dist/molecules/jl-menu.d.ts +8 -4
- package/dist/molecules/jl-menu.js +8 -1
- package/dist/molecules/jl-number-input.js +4 -4
- package/dist/molecules/jl-pagination.js +5 -5
- package/dist/molecules/jl-radio-group.d.ts +8 -7
- package/dist/molecules/jl-radio-group.js +12 -8
- package/dist/molecules/jl-search-button.js +4 -4
- package/dist/molecules/jl-search.js +4 -4
- package/dist/molecules/jl-segmented.d.ts +8 -7
- package/dist/molecules/jl-segmented.js +12 -6
- package/dist/molecules/jl-steps.css_raw.js +1 -1
- package/dist/molecules/jl-steps.d.ts +2 -0
- package/dist/molecules/jl-steps.js +30 -14
- package/dist/molecules/jl-tabs.js +2 -1
- package/dist/molecules/jl-tag-input.js +2 -2
- package/dist/molecules/jl-toast.css_raw.js +1 -1
- package/dist/molecules/jl-toast.d.ts +13 -1
- package/dist/molecules/jl-toast.js +23 -3
- package/dist/organisms/jl-command-palette.css_raw.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +20 -4
- package/dist/organisms/jl-command-palette.js +41 -9
- package/dist/organisms/jl-confirm.js +5 -7
- package/dist/organisms/jl-dialog.js +2 -1
- package/dist/organisms/jl-drawer.js +2 -1
- package/dist/organisms/jl-flow.js +12 -12
- package/dist/organisms/jl-navbar.js +6 -6
- package/dist/organisms/jl-side-nav.css_raw.js +1 -1
- package/dist/organisms/jl-side-nav.d.ts +40 -7
- package/dist/organisms/jl-side-nav.js +78 -16
- package/dist/organisms/jl-tab-bar.d.ts +8 -7
- package/dist/organisms/jl-tab-bar.js +12 -6
- package/dist/organisms/jl-table.css_raw.js +1 -1
- package/dist/organisms/jl-table.d.ts +62 -15
- package/dist/organisms/jl-table.js +246 -35
- package/dist/organisms/jl-toaster.d.ts +9 -1
- package/dist/organisms/jl-toaster.js +148 -7
- package/dist/organisms/jl-tree.css_raw.js +1 -1
- package/dist/organisms/jl-tree.d.ts +71 -4
- package/dist/organisms/jl-tree.js +303 -40
- package/dist/templates/jl-app-shell.css_raw.js +1 -1
- package/dist/templates/jl-app-shell.d.ts +10 -0
- package/dist/templates/jl-app-shell.js +16 -2
- package/dist/templates/jl-auth-layout.js +1 -1
- package/dist/templates/jl-page.js +3 -3
- package/dist/templates/jl-split-view.js +5 -4
- package/dist/types/jl-app-icon.types.d.ts +5 -0
- package/dist/types/jl-chip-group.types.d.ts +3 -3
- package/dist/types/jl-command-palette.types.d.ts +17 -6
- package/dist/types/jl-facts.types.d.ts +17 -0
- package/dist/types/jl-menu.types.d.ts +4 -4
- package/dist/types/jl-radio-group.types.d.ts +6 -3
- package/dist/types/jl-segmented.types.d.ts +6 -3
- package/dist/types/jl-select.types.d.ts +6 -3
- package/dist/types/jl-side-nav.types.d.ts +11 -6
- package/dist/types/jl-steps.types.d.ts +2 -0
- package/dist/types/jl-tab-bar.types.d.ts +6 -3
- package/dist/types/jl-table.types.d.ts +42 -9
- package/dist/types/jl-toaster.types.d.ts +42 -1
- package/dist/types/jl-tree.types.d.ts +26 -0
- package/dist/types/texts.types.d.ts +5 -0
- package/package.json +3 -3
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
2
|
import { JlElement } from "../base/jl-element.js";
|
|
3
|
-
import { jsonOf, oneOf } from "../lib/attributes.js";
|
|
3
|
+
import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
|
|
4
4
|
import { registerIcons } from "../lib/icons.js";
|
|
5
|
+
import { columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, sortRows, toggleAll, toggleKey, withRowOpen } from "../lib/table.js";
|
|
6
|
+
import { jlText } from "../lib/texts.js";
|
|
5
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
6
8
|
import { setOrRemove } from "../lib/dom.js";
|
|
7
9
|
import { JlBadge } from "../atoms/jl-badge.js";
|
|
8
|
-
import {
|
|
10
|
+
import { startedOnControl } from "../lib/surface.js";
|
|
9
11
|
import jl_table_default from "./jl-table.css_raw.js";
|
|
10
12
|
import { css } from "@jadis/core";
|
|
11
|
-
import { ArrowDown, ArrowUp, ChevronsUpDown, Inbox } from "lucide";
|
|
12
|
-
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
13
|
+
import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown, Inbox } from "lucide";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
13
15
|
// src/organisms/jl-table.tsx
|
|
14
16
|
registerIcons({
|
|
15
17
|
"arrow-down": ArrowDown,
|
|
16
18
|
"arrow-up": ArrowUp,
|
|
19
|
+
"chevron-right": ChevronRight,
|
|
17
20
|
"chevrons-up-down": ChevronsUpDown,
|
|
18
21
|
inbox: Inbox
|
|
19
22
|
});
|
|
@@ -22,12 +25,22 @@ var TABLE_SORT_DIRECTIONS = [
|
|
|
22
25
|
"asc",
|
|
23
26
|
"desc"
|
|
24
27
|
];
|
|
28
|
+
var TABLE_EXPANSIONS = [
|
|
29
|
+
"none",
|
|
30
|
+
"single",
|
|
31
|
+
"multiple"
|
|
32
|
+
];
|
|
33
|
+
var MARKED_ATTRIBUTE = "data-marked";
|
|
34
|
+
var EXPANDED_ATTRIBUTE = "data-expanded";
|
|
35
|
+
var DETAIL_ID_PREFIX = "detail-";
|
|
25
36
|
var DEFAULT_ROW_KEY = "id";
|
|
26
|
-
var
|
|
37
|
+
var NO_SORT_KEY = "";
|
|
27
38
|
var SKELETON_ROWS = 5;
|
|
28
39
|
var SORT_ICON_SIZE = 14;
|
|
29
40
|
var EMPTY_ICON_SIZE = 18;
|
|
41
|
+
var CHEVRON_SIZE = 16;
|
|
30
42
|
var NO_SORT = "none";
|
|
43
|
+
var NO_EXPANSION = "none";
|
|
31
44
|
var ARIA_SORT = {
|
|
32
45
|
asc: "ascending",
|
|
33
46
|
desc: "descending",
|
|
@@ -45,6 +58,7 @@ var CELL_MAKERS = {
|
|
|
45
58
|
}),
|
|
46
59
|
code: (text) => text === "" ? "" : /* @__PURE__ */ jsx("code", { children: text }),
|
|
47
60
|
date: (text) => text,
|
|
61
|
+
datetime: (text) => text,
|
|
48
62
|
number: (text) => text,
|
|
49
63
|
text: (text) => text
|
|
50
64
|
};
|
|
@@ -63,12 +77,25 @@ function checkbox(label, index) {
|
|
|
63
77
|
})]
|
|
64
78
|
});
|
|
65
79
|
}
|
|
80
|
+
/** One of the table's own checkboxes, not an input a renderer drew. */
|
|
81
|
+
var isTableCheckbox = (target) => target instanceof HTMLInputElement && target.matches(".select-cell > .check > .checkbox");
|
|
82
|
+
/** The detail drawn under a row while it is open. */
|
|
83
|
+
function detailOf(row) {
|
|
84
|
+
const next = row.nextElementSibling;
|
|
85
|
+
return next?.classList.contains("detail") ? next : null;
|
|
86
|
+
}
|
|
87
|
+
/** Whether a press ends a drag that selected text, which leaves the row as it was. */
|
|
88
|
+
var isSelectingText = () => (document.getSelection()?.toString() ?? "") !== "";
|
|
66
89
|
/**
|
|
67
90
|
* Rows of data under column headings. `columns` say what each column shows and how (`format`: text, number, date,
|
|
68
91
|
* badge, code); `rows` are plain objects. Sortable headings cycle ascending, descending and unsorted, and sort the
|
|
69
92
|
* rows in place; `selectable` adds a checkbox column. The header stays on top while the rows scroll within
|
|
70
93
|
* `max-height`, and the table scrolls sideways on narrow screens. Cells of a column can be drawn by code with
|
|
71
|
-
* `renderers`.
|
|
94
|
+
* `renderers`. `expandable` rows open on a press to show their `detail` under them, the row staying as it is: one at
|
|
95
|
+
* a time (`single`) or any number (`multiple`).
|
|
96
|
+
*
|
|
97
|
+
* Typed by its rows, `JlTable<Order>` checks and completes the fields its columns name, and hands its renderers and
|
|
98
|
+
* `detail` an order; `JlTable<Order, 'actions'>` adds a column that is not a field, which a renderer draws.
|
|
72
99
|
*/
|
|
73
100
|
var JlTable = class extends JlElement {
|
|
74
101
|
static selector = "jl-table";
|
|
@@ -82,9 +109,15 @@ var JlTable = class extends JlElement {
|
|
|
82
109
|
parse: jsonOf([])
|
|
83
110
|
});
|
|
84
111
|
/** The field that tells rows apart, for the selection. */
|
|
85
|
-
rowKey = this.useChange(DEFAULT_ROW_KEY, () => this.schedule("body"), {
|
|
112
|
+
rowKey = this.useChange(DEFAULT_ROW_KEY, () => this.schedule("body"), {
|
|
113
|
+
attribute: "row-key",
|
|
114
|
+
parse: textOf(DEFAULT_ROW_KEY)
|
|
115
|
+
});
|
|
86
116
|
/** The column the rows are sorted by. */
|
|
87
|
-
sortKey = this.useChange(
|
|
117
|
+
sortKey = this.useChange(NO_SORT_KEY, () => this.schedule("body"), {
|
|
118
|
+
attribute: "sort-key",
|
|
119
|
+
parse: textOf(NO_SORT_KEY)
|
|
120
|
+
});
|
|
88
121
|
sortDirection = this.useChange(NO_SORT, () => this.schedule("body"), {
|
|
89
122
|
attribute: "sort-direction",
|
|
90
123
|
parse: oneOf(TABLE_SORT_DIRECTIONS, NO_SORT)
|
|
@@ -99,6 +132,24 @@ var JlTable = class extends JlElement {
|
|
|
99
132
|
attribute: "selected",
|
|
100
133
|
parse: jsonOf([])
|
|
101
134
|
});
|
|
135
|
+
/** Rows open on a press to show their `detail` under them: one at a time (`single`), any number (`multiple`). */
|
|
136
|
+
expandable = this.useChange(NO_EXPANSION, (value) => {
|
|
137
|
+
this.reflect("expandable", value === NO_EXPANSION ? false : value);
|
|
138
|
+
this.schedule("head", "body");
|
|
139
|
+
}, {
|
|
140
|
+
attribute: "expandable",
|
|
141
|
+
parse: oneOf(TABLE_EXPANSIONS, NO_EXPANSION)
|
|
142
|
+
});
|
|
143
|
+
/** The keys of the open rows. */
|
|
144
|
+
expanded = this.useChange([], () => this.renderExpansion(), {
|
|
145
|
+
attribute: "expanded",
|
|
146
|
+
parse: jsonOf([])
|
|
147
|
+
});
|
|
148
|
+
/** The keys of rows to draw attention to, such as a search's matches: a mark, not a selection. */
|
|
149
|
+
marked = this.useChange([], () => this.renderMarks(), {
|
|
150
|
+
attribute: "marked",
|
|
151
|
+
parse: jsonOf([])
|
|
152
|
+
});
|
|
102
153
|
/** Shorter rows, for long lists. */
|
|
103
154
|
dense = this.useChange(false, (value) => this.reflect("dense", value), { attribute: "dense" });
|
|
104
155
|
/** Shades every other row. */
|
|
@@ -106,7 +157,7 @@ var JlTable = class extends JlElement {
|
|
|
106
157
|
/** A CSS height past which the rows scroll under the header: `320px`, `50vh`; a number is pixels. */
|
|
107
158
|
maxHeight = this.useChange("", (value) => this.renderMaxHeight(value), { attribute: "max-height" });
|
|
108
159
|
/** What the table says when it has no rows. */
|
|
109
|
-
emptyText = this.useChange(
|
|
160
|
+
emptyText = this.useChange(jlText("noData"), () => this.schedule("body"), { attribute: "empty-text" });
|
|
110
161
|
/** Shows placeholder rows while the data loads. */
|
|
111
162
|
loading = this.useChange(false, (value) => {
|
|
112
163
|
this.reflect("loading", value);
|
|
@@ -117,18 +168,39 @@ var JlTable = class extends JlElement {
|
|
|
117
168
|
label = this.useChange("", (value) => setOrRemove(this._refs.table, "aria-label", value), { attribute: "label" });
|
|
118
169
|
/** Draws the cells of some columns by code, by column key: `{ name: (row) => <strong>{row.name}</strong> }`. */
|
|
119
170
|
renderers = this.useChange({}, () => this.schedule("body"));
|
|
171
|
+
_source = { detail: null };
|
|
120
172
|
_pending = {
|
|
121
173
|
body: false,
|
|
122
174
|
head: false,
|
|
123
175
|
queued: false
|
|
124
176
|
};
|
|
125
|
-
/** The
|
|
126
|
-
_view = {
|
|
177
|
+
/** The rows as drawn and their keys, by their place: the rows and their checkboxes carry the place. */
|
|
178
|
+
_view = {
|
|
179
|
+
keys: [],
|
|
180
|
+
rows: []
|
|
181
|
+
};
|
|
127
182
|
_refs = this.useRefs((ref) => ({
|
|
128
183
|
body: ref("tbody"),
|
|
129
184
|
head: ref("thead"),
|
|
130
185
|
table: ref("table")
|
|
131
186
|
}));
|
|
187
|
+
/** Draws what an open row shows under it, from the row: `(row) => <JlFacts items={…} />`. */
|
|
188
|
+
get detail() {
|
|
189
|
+
return this._source.detail;
|
|
190
|
+
}
|
|
191
|
+
set detail(draw) {
|
|
192
|
+
this._source.detail = draw;
|
|
193
|
+
this.whenRendered(() => this.schedule("body"));
|
|
194
|
+
}
|
|
195
|
+
/** Opens or closes a row, as a press on it would; one at a time, opening a row closes the one that was open. */
|
|
196
|
+
toggle(key, open) {
|
|
197
|
+
const expansion = this.expandable.get();
|
|
198
|
+
if (expansion === NO_EXPANSION) return;
|
|
199
|
+
const before = openRows(this.expanded.get(), expansion);
|
|
200
|
+
const expanded = withRowOpen(this.expanded.get(), key, open, expansion);
|
|
201
|
+
this.expanded.set(expanded);
|
|
202
|
+
for (const change of rowToggles(before, openRows(expanded, expansion))) this.events.emit("toggle", change);
|
|
203
|
+
}
|
|
132
204
|
templateHtml() {
|
|
133
205
|
return /* @__PURE__ */ jsx("div", {
|
|
134
206
|
class: "scroll",
|
|
@@ -145,9 +217,9 @@ var JlTable = class extends JlElement {
|
|
|
145
217
|
if (key !== void 0) this.sortBy(key);
|
|
146
218
|
});
|
|
147
219
|
this.on(this._refs.table, "change", (event) => {
|
|
148
|
-
|
|
149
|
-
if (input instanceof HTMLInputElement && input.classList.contains("checkbox")) this.changeSelection(input);
|
|
220
|
+
if (isTableCheckbox(event.target)) this.changeSelection(event.target);
|
|
150
221
|
});
|
|
222
|
+
this.on(this._refs.body, "click", (event) => this.pressRow(event));
|
|
151
223
|
}
|
|
152
224
|
/** Draws on the next microtask: the inputs set while connecting give one drawing, not one each. */
|
|
153
225
|
schedule(...parts) {
|
|
@@ -165,8 +237,11 @@ var JlTable = class extends JlElement {
|
|
|
165
237
|
this.renderSortState();
|
|
166
238
|
if (body) this.renderBody();
|
|
167
239
|
this.renderSelection();
|
|
240
|
+
this.renderExpansion();
|
|
168
241
|
}
|
|
169
|
-
sortBy(
|
|
242
|
+
sortBy(name) {
|
|
243
|
+
const key = this.columns.get().find((column) => column.key === name)?.key;
|
|
244
|
+
if (key === void 0) return;
|
|
170
245
|
const current = key === this.sortKey.get() ? this.sortDirection.get() : NO_SORT;
|
|
171
246
|
const direction = nextSortDirection(current);
|
|
172
247
|
this.sortKey.set(key);
|
|
@@ -183,18 +258,57 @@ var JlTable = class extends JlElement {
|
|
|
183
258
|
this.selected.set(keys);
|
|
184
259
|
this.events.emit("selection", keys);
|
|
185
260
|
}
|
|
261
|
+
/** A press on a row's chevron, or on the row anywhere but its controls and its checkbox, opens or closes it. */
|
|
262
|
+
pressRow(event) {
|
|
263
|
+
const row = this.dataRowOf(event);
|
|
264
|
+
const key = row === void 0 ? void 0 : this.keyOf(row);
|
|
265
|
+
if (row === void 0 || key === void 0 || !this.opensOnPress(event, row)) return;
|
|
266
|
+
this.toggle(key, !row.hasAttribute(EXPANDED_ATTRIBUTE));
|
|
267
|
+
}
|
|
268
|
+
/** The row of data a press is on: one of the table's, not a row in the content of a detail. */
|
|
269
|
+
dataRowOf(event) {
|
|
270
|
+
const body = this._refs.body;
|
|
271
|
+
return event.composedPath().find((target) => target instanceof HTMLTableRowElement && target.parentElement === body && target.dataset.index !== void 0);
|
|
272
|
+
}
|
|
273
|
+
opensOnPress(event, row) {
|
|
274
|
+
const path = event.composedPath();
|
|
275
|
+
const chevron = row.querySelector("button.expand");
|
|
276
|
+
if (chevron === null) return false;
|
|
277
|
+
const select = row.querySelector(".select-cell");
|
|
278
|
+
const elsewhere = startedOnControl(event, row) || select !== null && path.includes(select) || isSelectingText();
|
|
279
|
+
return path.includes(chevron) || !elsewhere;
|
|
280
|
+
}
|
|
186
281
|
renderMaxHeight(value) {
|
|
187
282
|
const height = /^\d+(\.\d+)?$/.test(value.trim()) ? `${value.trim()}px` : value;
|
|
188
283
|
this.style.setProperty("--max-height", height === "" ? "none" : height);
|
|
189
284
|
this.reflect("scrolls", height !== "");
|
|
190
285
|
}
|
|
286
|
+
isExpandable() {
|
|
287
|
+
return this.expandable.get() !== NO_EXPANSION;
|
|
288
|
+
}
|
|
289
|
+
/** The number of cells in a row: the columns, after the checkbox and the chevron when there are. */
|
|
290
|
+
span(columns) {
|
|
291
|
+
return columns.length + Number(this.selectable.get()) + Number(this.isExpandable());
|
|
292
|
+
}
|
|
191
293
|
renderHead() {
|
|
192
294
|
const selectAll = this.selectable.get() ? /* @__PURE__ */ jsx("th", {
|
|
193
295
|
class: "select-cell",
|
|
194
296
|
scope: "col",
|
|
195
297
|
children: checkbox("Select all rows", null)
|
|
196
298
|
}) : null;
|
|
197
|
-
this.
|
|
299
|
+
const details = this.isExpandable() ? /* @__PURE__ */ jsx("th", {
|
|
300
|
+
class: "expand-cell",
|
|
301
|
+
scope: "col",
|
|
302
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
303
|
+
class: "sr-only",
|
|
304
|
+
children: jlText("details")
|
|
305
|
+
})
|
|
306
|
+
}) : null;
|
|
307
|
+
this._refs.head.replaceChildren(/* @__PURE__ */ jsxs("tr", { children: [
|
|
308
|
+
selectAll,
|
|
309
|
+
details,
|
|
310
|
+
this.columns.get().map((column) => this.headerCell(column))
|
|
311
|
+
] }));
|
|
198
312
|
}
|
|
199
313
|
headerCell(column) {
|
|
200
314
|
const content = column.sortable ? /* @__PURE__ */ jsxs("button", {
|
|
@@ -233,53 +347,96 @@ var JlTable = class extends JlElement {
|
|
|
233
347
|
}
|
|
234
348
|
renderBody() {
|
|
235
349
|
const columns = this.columns.get();
|
|
236
|
-
const span = columns.length + Number(this.selectable.get());
|
|
237
350
|
if (this.loading.get()) {
|
|
238
|
-
this.
|
|
351
|
+
this.setView([], []);
|
|
239
352
|
this._refs.body.replaceChildren(...this.skeletonRows(columns));
|
|
240
353
|
return;
|
|
241
354
|
}
|
|
242
355
|
const rows = this.rows.get();
|
|
243
356
|
if (rows.length === 0) {
|
|
244
|
-
this.
|
|
245
|
-
this._refs.body.replaceChildren(this.emptyRow(span));
|
|
357
|
+
this.setView([], []);
|
|
358
|
+
this._refs.body.replaceChildren(this.emptyRow(this.span(columns)));
|
|
246
359
|
return;
|
|
247
360
|
}
|
|
248
361
|
const keyField = this.rowKey.get();
|
|
249
362
|
const keys = new Map(rows.map((row, index) => [row, rowKeyOf(row, keyField, index)]));
|
|
250
363
|
const sorted = this.sortedRows();
|
|
251
|
-
this.
|
|
364
|
+
this.setView(sorted, sorted.map((row, index) => keys.get(row) ?? index));
|
|
252
365
|
this._refs.body.replaceChildren(...sorted.map((row, index) => this.bodyRow(row, index, columns)));
|
|
366
|
+
this.renderMarks();
|
|
367
|
+
}
|
|
368
|
+
setView(rows, keys) {
|
|
369
|
+
this._view.rows = rows;
|
|
370
|
+
this._view.keys = keys;
|
|
253
371
|
}
|
|
254
372
|
bodyRow(row, index, columns) {
|
|
255
373
|
const first = columns[0];
|
|
256
|
-
const name = first === void 0 ? String(index + 1) : formatCell(row
|
|
374
|
+
const name = first === void 0 ? String(index + 1) : formatCell(fieldOf(row, first.key), first.format);
|
|
257
375
|
const select = this.selectable.get() ? /* @__PURE__ */ jsx("td", {
|
|
258
376
|
class: "select-cell",
|
|
259
377
|
children: checkbox(`Select ${name}`, index)
|
|
260
378
|
}) : null;
|
|
261
|
-
|
|
262
|
-
class:
|
|
263
|
-
children:
|
|
264
|
-
|
|
379
|
+
const chevron = this.isExpandable() ? /* @__PURE__ */ jsx("td", {
|
|
380
|
+
class: "expand-cell",
|
|
381
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
382
|
+
type: "button",
|
|
383
|
+
class: "expand",
|
|
384
|
+
"aria-expanded": "false",
|
|
385
|
+
"aria-label": jlText("detailsOf", { name }),
|
|
386
|
+
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
387
|
+
class: "chevron",
|
|
388
|
+
name: "chevron-right",
|
|
389
|
+
size: CHEVRON_SIZE
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
}) : null;
|
|
393
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
394
|
+
"data-index": index,
|
|
395
|
+
children: [
|
|
396
|
+
select,
|
|
397
|
+
chevron,
|
|
398
|
+
columns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
399
|
+
class: `align-${columnAlign(column)} format-${column.format ?? "text"}${column.wrap ? " wrap" : ""}`,
|
|
400
|
+
children: this.cell(row, column)
|
|
401
|
+
}))
|
|
402
|
+
]
|
|
403
|
+
});
|
|
265
404
|
}
|
|
405
|
+
/** A cell's value, drawn by its renderer or in its format, with the row's description under it when it has one. */
|
|
266
406
|
cell(row, column) {
|
|
407
|
+
const value = this.cellValue(row, column);
|
|
408
|
+
const description = column.description === void 0 ? "" : formatCell(fieldOf(row, column.description));
|
|
409
|
+
if (description === "") return value;
|
|
410
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
411
|
+
class: "cell-value",
|
|
412
|
+
children: value
|
|
413
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
414
|
+
class: "cell-description",
|
|
415
|
+
children: description
|
|
416
|
+
})] });
|
|
417
|
+
}
|
|
418
|
+
cellValue(row, column) {
|
|
267
419
|
const renderer = this.renderers.get()[column.key];
|
|
268
420
|
if (renderer !== void 0) return renderer(row);
|
|
269
421
|
const format = column.format ?? "text";
|
|
270
|
-
return CELL_MAKERS[format](formatCell(row
|
|
422
|
+
return CELL_MAKERS[format](formatCell(fieldOf(row, column.key), format), column);
|
|
271
423
|
}
|
|
272
424
|
skeletonRows(columns) {
|
|
273
425
|
const select = this.selectable.get();
|
|
426
|
+
const expand = this.isExpandable();
|
|
274
427
|
return Array.from({ length: SKELETON_ROWS }, () => /* @__PURE__ */ jsxs("tr", {
|
|
275
428
|
class: "skeleton",
|
|
276
|
-
children: [
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
429
|
+
children: [
|
|
430
|
+
select ? /* @__PURE__ */ jsx("td", {
|
|
431
|
+
class: "select-cell",
|
|
432
|
+
children: /* @__PURE__ */ jsx("span", { class: "bone box" })
|
|
433
|
+
}) : null,
|
|
434
|
+
expand ? /* @__PURE__ */ jsx("td", { class: "expand-cell" }) : null,
|
|
435
|
+
columns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
436
|
+
class: `align-${columnAlign(column)}`,
|
|
437
|
+
children: /* @__PURE__ */ jsx("span", { class: "bone" })
|
|
438
|
+
}))
|
|
439
|
+
]
|
|
283
440
|
}));
|
|
284
441
|
}
|
|
285
442
|
emptyRow(span) {
|
|
@@ -297,10 +454,64 @@ var JlTable = class extends JlElement {
|
|
|
297
454
|
})
|
|
298
455
|
});
|
|
299
456
|
}
|
|
457
|
+
/** The rows of data, without the details under the open ones. */
|
|
458
|
+
dataRows() {
|
|
459
|
+
return [...this._refs.body.querySelectorAll(":scope > tr[data-index]")];
|
|
460
|
+
}
|
|
461
|
+
keyOf(row) {
|
|
462
|
+
return this._view.keys[Number(row.dataset.index)];
|
|
463
|
+
}
|
|
464
|
+
/** The bar and the shade of marked rows, changed in place. */
|
|
465
|
+
renderMarks() {
|
|
466
|
+
const marked = new Set(this.marked.get());
|
|
467
|
+
for (const row of this.dataRows()) {
|
|
468
|
+
const key = this.keyOf(row);
|
|
469
|
+
row.toggleAttribute(MARKED_ATTRIBUTE, key !== void 0 && marked.has(key));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/** The details of the open rows, added under them and taken away in place: one that stays open keeps its content. */
|
|
473
|
+
renderExpansion() {
|
|
474
|
+
const open = new Set(openRows(this.expanded.get(), this.expandable.get()));
|
|
475
|
+
for (const row of this.dataRows()) {
|
|
476
|
+
const key = this.keyOf(row);
|
|
477
|
+
this.renderRowOpen(row, key !== void 0 && open.has(key));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
renderRowOpen(row, open) {
|
|
481
|
+
const chevron = row.querySelector("button.expand");
|
|
482
|
+
if (chevron === null) return;
|
|
483
|
+
row.toggleAttribute(EXPANDED_ATTRIBUTE, open);
|
|
484
|
+
chevron.setAttribute("aria-expanded", String(open));
|
|
485
|
+
const detail = detailOf(row);
|
|
486
|
+
if (!open) {
|
|
487
|
+
detail?.remove();
|
|
488
|
+
chevron.removeAttribute("aria-controls");
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (detail !== null) return;
|
|
492
|
+
const id = `${DETAIL_ID_PREFIX}${row.dataset.index}`;
|
|
493
|
+
row.after(this.detailRow(row, id));
|
|
494
|
+
chevron.setAttribute("aria-controls", id);
|
|
495
|
+
}
|
|
496
|
+
detailRow(row, id) {
|
|
497
|
+
const data = this._view.rows[Number(row.dataset.index)];
|
|
498
|
+
const draw = this._source.detail;
|
|
499
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
500
|
+
class: "detail",
|
|
501
|
+
id,
|
|
502
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
503
|
+
colSpan: this.span(this.columns.get()),
|
|
504
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
505
|
+
class: "detail-body",
|
|
506
|
+
children: data === void 0 || draw === null ? "" : draw(data)
|
|
507
|
+
})
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
|
+
}
|
|
300
511
|
/** The checkboxes and the shading of selected rows, changed in place. */
|
|
301
512
|
renderSelection() {
|
|
302
513
|
const selected = new Set(this.selected.get());
|
|
303
|
-
for (const input of this._refs.body.querySelectorAll("
|
|
514
|
+
for (const input of this._refs.body.querySelectorAll(":scope > tr > .select-cell .checkbox")) {
|
|
304
515
|
const key = this._view.keys[Number(input.dataset.index)];
|
|
305
516
|
const on = key !== void 0 && selected.has(key);
|
|
306
517
|
input.checked = on;
|
|
@@ -315,4 +526,4 @@ var JlTable = class extends JlElement {
|
|
|
315
526
|
}
|
|
316
527
|
};
|
|
317
528
|
JlTable.register();
|
|
318
|
-
export { JlTable, TABLE_SORT_DIRECTIONS };
|
|
529
|
+
export { JlTable, TABLE_EXPANSIONS, TABLE_SORT_DIRECTIONS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JlElement } from '../base/jl-element';
|
|
2
|
-
import type { ToasterPlacement, ToastHandle, ToastOptions } from '../types/jl-toaster.types';
|
|
2
|
+
import type { DownloadOptions, DownloadResult, DownloadTexts, ToasterPlacement, ToastHandle, ToastOptions } from '../types/jl-toaster.types';
|
|
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
|
|
@@ -49,3 +49,11 @@ export declare class JlToaster extends JlElement {
|
|
|
49
49
|
* Returns a handle to close it early.
|
|
50
50
|
*/
|
|
51
51
|
export declare function toast(options: ToastOptions): ToastHandle;
|
|
52
|
+
/** A download's texts, in the language the page set (`setTexts`): what `download()` says unless told otherwise. */
|
|
53
|
+
export declare const downloadTexts: () => DownloadTexts;
|
|
54
|
+
/**
|
|
55
|
+
* Downloads a file with its progress in a toast of the page's toaster: the time the server takes to prepare it,
|
|
56
|
+
* the bytes received (a bar when it says the size), then the name it was saved under, or why it failed. Its
|
|
57
|
+
* Cancel stops it. Call it from a download link's click, leaving a modified click (a new tab) to the browser.
|
|
58
|
+
*/
|
|
59
|
+
export declare function download(url: string, options?: DownloadOptions): Promise<DownloadResult>;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
2
|
import { JlElement } from "../base/jl-element.js";
|
|
3
3
|
import { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
4
|
+
import { registerIcons } from "../lib/icons.js";
|
|
5
|
+
import { formatDuration } from "../lib/time.js";
|
|
6
|
+
import { fillText } from "../lib/text.js";
|
|
7
|
+
import { jlText } from "../lib/texts.js";
|
|
8
|
+
import { formatFileSize } from "../lib/files.js";
|
|
4
9
|
import { JlToast } from "../molecules/jl-toast.js";
|
|
10
|
+
import { answerError, dispositionFileName, readWithProgress, saveBlob, urlFileName } from "../lib/download.js";
|
|
5
11
|
import jl_toaster_default from "./jl-toaster.css_raw.js";
|
|
6
12
|
import { css } from "@jadis/core";
|
|
13
|
+
import { Download } from "lucide";
|
|
7
14
|
import { jsx } from "@jadis/core/jsx-runtime";
|
|
8
15
|
// src/organisms/jl-toaster.tsx
|
|
16
|
+
registerIcons({ download: Download });
|
|
9
17
|
var TOASTER_PLACEMENTS = [
|
|
10
18
|
"bottom-right",
|
|
11
19
|
"bottom-center",
|
|
@@ -18,11 +26,26 @@ var MAX_LIMIT = 20;
|
|
|
18
26
|
var DEFAULT_DURATION = 5e3;
|
|
19
27
|
var LONG_DURATION = 8e3;
|
|
20
28
|
var LONG_TONE = "danger";
|
|
21
|
-
var DEFAULT_LABEL = "Notifications";
|
|
22
29
|
var STACKED = "data-stacked";
|
|
23
30
|
/** How long a toast stays when its options do not say: longer for an error, or to give time to press its action. */
|
|
24
31
|
var defaultDuration = (options) => options.tone === LONG_TONE || (options.actionLabel ?? "") !== "" ? LONG_DURATION : DEFAULT_DURATION;
|
|
25
32
|
var OPEN = ":popover-open";
|
|
33
|
+
/** The inputs of a toast that an update may change, each set when the update gives it. */
|
|
34
|
+
var TOAST_SETTERS = {
|
|
35
|
+
actionLabel: (toast, value) => toast.actionLabel.set(value ?? ""),
|
|
36
|
+
closable: (toast, value) => toast.closable.set(value ?? false),
|
|
37
|
+
duration: (toast, value) => toast.duration.set(value ?? 0),
|
|
38
|
+
heading: (toast, value) => toast.heading.set(value ?? ""),
|
|
39
|
+
icon: (toast, value) => toast.icon.set(value ?? ""),
|
|
40
|
+
onAction: () => void 0,
|
|
41
|
+
progress: (toast, value) => toast.progress.set(value ?? null),
|
|
42
|
+
text: (toast, value) => toast.text.set(value ?? ""),
|
|
43
|
+
tone: (toast, value) => toast.tone.set(value ?? "neutral"),
|
|
44
|
+
working: (toast, value) => toast.working.set(value ?? false)
|
|
45
|
+
};
|
|
46
|
+
function updateToast(toast, changes) {
|
|
47
|
+
for (const key of Object.keys(changes)) TOAST_SETTERS[key](toast, changes[key]);
|
|
48
|
+
}
|
|
26
49
|
/**
|
|
27
50
|
* The corner of the window where notifications stack, newest nearest the edge, at most `max` at a time. It lives in
|
|
28
51
|
* the top layer, so it shows over open dialogs, and its live region reads new toasts to screen readers. Pages
|
|
@@ -40,7 +63,7 @@ var JlToaster = class extends JlElement {
|
|
|
40
63
|
parse: clampedNumber(DEFAULT_MAX, 1, MAX_LIMIT)
|
|
41
64
|
});
|
|
42
65
|
/** The region's name for screen readers. */
|
|
43
|
-
label = this.useChange(
|
|
66
|
+
label = this.useChange(jlText("notifications"), (value) => this._refs.region.setAttribute("aria-label", value), { attribute: "label" });
|
|
44
67
|
_watched = /* @__PURE__ */ new WeakSet();
|
|
45
68
|
_refs = this.useRefs((ref) => ({
|
|
46
69
|
region: ref(".region"),
|
|
@@ -58,13 +81,21 @@ var JlToaster = class extends JlElement {
|
|
|
58
81
|
icon: options.icon,
|
|
59
82
|
duration: options.duration ?? defaultDuration(options),
|
|
60
83
|
closable: options.closable ?? true,
|
|
61
|
-
actionLabel: options.actionLabel
|
|
84
|
+
actionLabel: options.actionLabel,
|
|
85
|
+
working: options.working,
|
|
86
|
+
progress: options.progress
|
|
62
87
|
});
|
|
63
|
-
const
|
|
64
|
-
|
|
88
|
+
const actions = { onAction: options.onAction };
|
|
89
|
+
toast.addEventListener("action", () => actions.onAction?.());
|
|
65
90
|
this.append(toast);
|
|
66
91
|
this.whenRendered(() => this.raise());
|
|
67
|
-
return {
|
|
92
|
+
return {
|
|
93
|
+
dismiss: () => toast.dismiss(),
|
|
94
|
+
update: (changes) => {
|
|
95
|
+
if ("onAction" in changes) actions.onAction = changes.onAction;
|
|
96
|
+
updateToast(toast, changes);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
68
99
|
}
|
|
69
100
|
templateHtml() {
|
|
70
101
|
return /* @__PURE__ */ jsx("section", {
|
|
@@ -146,4 +177,114 @@ function pageToaster() {
|
|
|
146
177
|
function toast(options) {
|
|
147
178
|
return pageToaster().notify(options);
|
|
148
179
|
}
|
|
149
|
-
|
|
180
|
+
var DOWNLOAD_ICON = "download";
|
|
181
|
+
var SAVED_VISIBLE_MS = 6e3;
|
|
182
|
+
var PREPARING_TICK_MS = 1e3;
|
|
183
|
+
var PROGRESS_INTERVAL_MS = 250;
|
|
184
|
+
var PERCENT = 100;
|
|
185
|
+
var FALLBACK_NAME = "download";
|
|
186
|
+
var CONTENT_LENGTH = "content-length";
|
|
187
|
+
var CONTENT_DISPOSITION = "content-disposition";
|
|
188
|
+
/** A download's texts, in the language the page set (`setTexts`): what `download()` says unless told otherwise. */
|
|
189
|
+
var downloadTexts = () => ({
|
|
190
|
+
cancel: jlText("downloadCancel"),
|
|
191
|
+
failed: jlText("downloadFailed"),
|
|
192
|
+
preparing: jlText("downloadPreparing"),
|
|
193
|
+
received: jlText("downloadReceived"),
|
|
194
|
+
receivedOf: jlText("downloadReceivedOf"),
|
|
195
|
+
saved: jlText("downloadSaved")
|
|
196
|
+
});
|
|
197
|
+
/** The toast's text and bar for the bytes received: a share of the size when the server said it. */
|
|
198
|
+
function receiving(received, total, texts) {
|
|
199
|
+
const size = formatFileSize(received);
|
|
200
|
+
if (total <= 0) return {
|
|
201
|
+
progress: null,
|
|
202
|
+
text: fillText(texts.received, { received: size })
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
progress: Math.min(PERCENT, received / total * PERCENT),
|
|
206
|
+
text: fillText(texts.receivedOf, {
|
|
207
|
+
received: size,
|
|
208
|
+
total: formatFileSize(total)
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
async function failureOf(response) {
|
|
213
|
+
const body = await response.json().catch(() => null);
|
|
214
|
+
return new Error(answerError(body, response.status));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Downloads a file with its progress in a toast of the page's toaster: the time the server takes to prepare it,
|
|
218
|
+
* the bytes received (a bar when it says the size), then the name it was saved under, or why it failed. Its
|
|
219
|
+
* Cancel stops it. Call it from a download link's click, leaving a modified click (a new tab) to the browser.
|
|
220
|
+
*/
|
|
221
|
+
async function download(url, options = {}) {
|
|
222
|
+
const texts = {
|
|
223
|
+
...downloadTexts(),
|
|
224
|
+
...options.texts
|
|
225
|
+
};
|
|
226
|
+
const controller = new AbortController();
|
|
227
|
+
const started = performance.now();
|
|
228
|
+
const preparingText = () => fillText(texts.preparing, { time: formatDuration(performance.now() - started) });
|
|
229
|
+
const handle = toast({
|
|
230
|
+
actionLabel: texts.cancel,
|
|
231
|
+
closable: false,
|
|
232
|
+
duration: 0,
|
|
233
|
+
heading: options.title ?? urlFileName(url, FALLBACK_NAME),
|
|
234
|
+
icon: DOWNLOAD_ICON,
|
|
235
|
+
onAction: () => controller.abort(),
|
|
236
|
+
progress: null,
|
|
237
|
+
text: preparingText(),
|
|
238
|
+
working: true
|
|
239
|
+
});
|
|
240
|
+
const preparing = window.setInterval(() => handle.update({ text: preparingText() }), PREPARING_TICK_MS);
|
|
241
|
+
try {
|
|
242
|
+
const response = await fetch(url, {
|
|
243
|
+
...options.init,
|
|
244
|
+
signal: controller.signal
|
|
245
|
+
});
|
|
246
|
+
window.clearInterval(preparing);
|
|
247
|
+
if (!response.ok) throw await failureOf(response);
|
|
248
|
+
const total = Number(response.headers.get(CONTENT_LENGTH)) || 0;
|
|
249
|
+
const blob = await readWithProgress(response, (received) => handle.update(receiving(received, total, texts)), PROGRESS_INTERVAL_MS);
|
|
250
|
+
const name = dispositionFileName(response.headers.get(CONTENT_DISPOSITION)) ?? options.fileName ?? urlFileName(url, FALLBACK_NAME);
|
|
251
|
+
saveBlob(blob, name);
|
|
252
|
+
handle.update({
|
|
253
|
+
actionLabel: "",
|
|
254
|
+
closable: true,
|
|
255
|
+
duration: SAVED_VISIBLE_MS,
|
|
256
|
+
icon: "",
|
|
257
|
+
text: fillText(texts.saved, {
|
|
258
|
+
name,
|
|
259
|
+
size: formatFileSize(blob.size)
|
|
260
|
+
}),
|
|
261
|
+
tone: "ok",
|
|
262
|
+
working: false
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
name,
|
|
266
|
+
outcome: "saved",
|
|
267
|
+
size: blob.size
|
|
268
|
+
};
|
|
269
|
+
} catch (error) {
|
|
270
|
+
window.clearInterval(preparing);
|
|
271
|
+
if (controller.signal.aborted) {
|
|
272
|
+
handle.dismiss();
|
|
273
|
+
return { outcome: "canceled" };
|
|
274
|
+
}
|
|
275
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
276
|
+
handle.update({
|
|
277
|
+
actionLabel: "",
|
|
278
|
+
closable: true,
|
|
279
|
+
icon: "",
|
|
280
|
+
text: fillText(texts.failed, { error: message }),
|
|
281
|
+
tone: "danger",
|
|
282
|
+
working: false
|
|
283
|
+
});
|
|
284
|
+
return {
|
|
285
|
+
error: message,
|
|
286
|
+
outcome: "failed"
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
export { JlToaster, TOASTER_PLACEMENTS, download, downloadTexts, toast };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-tree.css?raw
|
|
2
|
-
var jl_tree_default = ":host {\n display: block;\n --indent: 16px;\n --row-height: 30px;\n}\n\n.tree {\n color: var(--jl-text-2);\n font-size: var(--jl-font-md);\n}\n\n.group {\n position: relative;\n}\n\n/* A quiet line under each open folder, from its chevron down along its children. */\n.group::before {\n position: absolute;\n top: 0;\n bottom: 4px;\n left: calc(8px + var(--level) * var(--indent) + 6.5px);\n width: 1px;\n background: var(--jl-line);\n content: \"\";\n}\n\n.item:focus-visible {\n box-shadow: none;\n}\n\n.row {\n display: flex;\n align-items: center;\n gap: 6px;\n height: var(--row-height);\n padding: 0 8px 0 calc(8px + var(--level) * var(--indent));\n border-radius: var(--jl-radius-sm);\n cursor: pointer;\n user-select: none;\n}\n\n.row:hover {\n background: var(--jl-surface-2);\n color: var(--jl-text);\n}\n\n.item:focus-visible > .row {\n box-shadow: var(--jl-focus-ring);\n}\n\n.item[aria-selected=\"true\"] > .row {\n background: var(--jl-accent-soft);\n color: var(--jl-text);\n font-weight: 600;\n}\n\n.chevron {\n display: inline-flex;\n flex: none;\n justify-content: center;\n width: 14px;\n color: var(--jl-faint);\n transition: rotate var(--jl-fast) var(--jl-ease);\n}\n\n.item[aria-expanded=\"true\"] > .row > .chevron {\n rotate: 90deg;\n}\n\n.icon {\n color: var(--jl-muted);\n}\n\n.item[aria-selected=\"true\"] > .row > .icon {\n color: var(--jl-accent);\n}\n\n.label {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n";
|
|
2
|
+
var jl_tree_default = ":host {\n display: block;\n --indent: 16px;\n --row-height: 30px;\n}\n\n.tree {\n color: var(--jl-text-2);\n font-size: var(--jl-font-md);\n}\n\n.group {\n position: relative;\n}\n\n/* A quiet line under each open folder, from its chevron down along its children. */\n.group::before {\n position: absolute;\n top: 0;\n bottom: 4px;\n left: calc(8px + var(--level) * var(--indent) + 6.5px);\n width: 1px;\n background: var(--jl-line);\n content: \"\";\n}\n\n.item:focus-visible {\n box-shadow: none;\n}\n\n.row {\n display: flex;\n align-items: center;\n gap: 6px;\n height: var(--row-height);\n padding: 0 8px 0 calc(8px + var(--level) * var(--indent));\n border-radius: var(--jl-radius-sm);\n cursor: pointer;\n user-select: none;\n}\n\n.row:hover {\n background: var(--jl-surface-2);\n color: var(--jl-text);\n}\n\n.item:focus-visible > .row {\n box-shadow: var(--jl-focus-ring);\n}\n\n.item[aria-selected=\"true\"] > .row {\n background: var(--jl-accent-soft);\n color: var(--jl-text);\n font-weight: 600;\n}\n\n.chevron {\n display: inline-flex;\n flex: none;\n justify-content: center;\n width: 14px;\n color: var(--jl-faint);\n transition: rotate var(--jl-fast) var(--jl-ease);\n}\n\n.item[aria-expanded=\"true\"] > .row > .chevron {\n rotate: 90deg;\n}\n\n.icon {\n color: var(--jl-muted);\n}\n\n.item[aria-selected=\"true\"] > .row > .icon {\n color: var(--jl-accent);\n}\n\n.label {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* A link's row looks like any row: the address shows in the status bar, and a middle click opens a tab. */\na.row {\n color: inherit;\n text-decoration: none;\n}\n\n/* What ends a level: its page on the way, the button for its next page, an error to load again. */\n.item.level-end > .row {\n color: var(--jl-muted);\n}\n\n.level-end[aria-disabled=\"true\"] > .row {\n cursor: default;\n}\n\n.level-end[aria-disabled=\"true\"] > .row:hover {\n background: none;\n}\n\n.spinner {\n flex: none;\n color: var(--jl-muted);\n}\n\n.more,\n.retry {\n flex: none;\n color: var(--jl-accent);\n font-weight: 500;\n}\n\n.level-end > .row:hover .more,\n.level-end > .row:hover .retry {\n color: var(--jl-accent-strong);\n}\n\n.icon.error {\n color: var(--jl-danger);\n}\n\n.note {\n display: flex;\n align-items: center;\n gap: 6px;\n min-height: var(--row-height);\n padding: 0 8px 0 calc(8px + var(--level) * var(--indent));\n color: var(--jl-muted);\n}\n\n/* A folder's count, or a short word, after its label. */\n.badge {\n flex: none;\n margin-left: auto;\n color: var(--jl-faint);\n font-size: var(--jl-font-xs);\n font-variant-numeric: tabular-nums;\n}\n";
|
|
3
3
|
export { jl_tree_default as default };
|