@syware/jlib 0.14.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 +6 -2
- package/dist/atoms/jl-progress.d.ts +1 -0
- package/dist/atoms/jl-progress.js +5 -2
- 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 +1 -0
- 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/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/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 +3 -3
- 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 +3 -2
- 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 +8 -4
- 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 +9 -3
- 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 +14 -3
- package/dist/organisms/jl-table.js +34 -15
- 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 +6 -4
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-command-palette.css?inline
|
|
2
|
-
var jl_command_palette_default = ":host{display:contents}dialog{border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);background:var(--jl-surface);width:min(620px,100vw - 24px);max-width:none;max-height:min(520px,100dvh - 24vh);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);flex-direction:column;margin:12vh auto auto;padding:0;overflow:hidden}dialog[open]{animation:drop var(--jl-fast) var(--jl-ease);display:flex}dialog::backdrop{background:var(--jl-scrim);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.search{border-bottom:1px solid var(--jl-line);flex:none;align-items:center;gap:10px;height:52px;padding:0 14px 0 16px;display:flex}.search-icon,.search-spinner{color:var(--jl-faint);flex:none}input{min-width:0;height:100%;font-size:max(15px, var(--jl-control-font));background:0 0;border:none;outline:none;flex:1;padding:0}input::placeholder{color:var(--jl-
|
|
2
|
+
var jl_command_palette_default = ":host{display:contents}dialog{border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);background:var(--jl-surface);width:min(620px,100vw - 24px);max-width:none;max-height:min(520px,100dvh - 24vh);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);flex-direction:column;margin:12vh auto auto;padding:0;overflow:hidden}dialog[open]{animation:drop var(--jl-fast) var(--jl-ease);display:flex}dialog::backdrop{background:var(--jl-scrim);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.search{border-bottom:1px solid var(--jl-line);flex:none;align-items:center;gap:10px;height:52px;padding:0 14px 0 16px;display:flex}.search-icon,.search-spinner{color:var(--jl-faint);flex:none}input{min-width:0;height:100%;font-size:max(15px, var(--jl-control-font));background:0 0;border:none;outline:none;flex:1;padding:0}input::placeholder{color:var(--jl-muted)}input:focus-visible{box-shadow:none}kbd{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-xs);background:var(--jl-surface);min-width:20px;height:20px;color:var(--jl-muted);border-bottom-width:2px;justify-content:center;align-items:center;padding:0 5px;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.results{overscroll-behavior:contain;flex:1;min-height:0;padding:6px;scroll-padding:6px;overflow-y:auto}[role=group]+[role=group]{border-top:1px solid var(--jl-line-soft);margin-top:4px;padding-top:4px}.group-label{color:var(--jl-muted);font-size:var(--jl-font-xs);padding:8px 10px 4px;font-weight:600}.option{border-radius:var(--jl-radius-sm);min-height:38px;color:var(--jl-text-2);cursor:pointer;align-items:center;gap:10px;padding:0 10px;display:flex}.option[aria-selected=true]{background:var(--jl-accent-soft);color:var(--jl-text)}.option-icon{width:16px;color:var(--jl-muted);flex:none}.option[aria-selected=true] .option-icon{color:var(--jl-accent)}.option-label{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.option-description{max-width:40%;color:var(--jl-muted);font-size:var(--jl-font-xs);text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}mark{color:var(--jl-accent);background:0 0;font-weight:700}.keys{flex:none;gap:3px;display:inline-flex}.empty{color:var(--jl-muted);text-align:center;padding:36px 16px}.results:empty,.results:not(:empty)+.empty{display:none}footer{border-top:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);flex-wrap:wrap;flex:none;align-items:center;gap:6px 16px;padding:8px 16px;display:flex}.hint,.hotkey-keys{align-items:center;gap:4px;display:inline-flex}.hotkey-hint{margin-left:auto}@media (width<520px){dialog{max-height:calc(100dvh - 24px);margin-top:12px}.hotkey-hint{display:none}}@keyframes drop{0%{opacity:0;transform:translateY(-6px)scale(.98)}}";
|
|
3
3
|
export { jl_command_palette_default as default };
|
|
@@ -63,6 +63,8 @@ export declare class JlCommandPalette<Id extends string = string> extends JlElem
|
|
|
63
63
|
templateCss(): string;
|
|
64
64
|
protected drawTexts(): void;
|
|
65
65
|
onConnect(): void;
|
|
66
|
+
/** A palette taken out of the page while it shows is no longer the modal on top. */
|
|
67
|
+
onDisconnect(): void;
|
|
66
68
|
private toggleOnHotkey;
|
|
67
69
|
private navigate;
|
|
68
70
|
private indexOf;
|
|
@@ -8,6 +8,7 @@ import { setOrRemove } from "../lib/dom.js";
|
|
|
8
8
|
import { JlSpinner } from "../atoms/jl-spinner.js";
|
|
9
9
|
import { hotkeyLabels, isApplePlatform, matchesHotkey, parseHotkey } from "../lib/hotkey.js";
|
|
10
10
|
import { highlightSegments } from "../lib/fuzzy.js";
|
|
11
|
+
import { modalClosed, modalOpened, onBackdropPress } from "../lib/modal.js";
|
|
11
12
|
import { groupMatches, matchCommands } from "../lib/palette.js";
|
|
12
13
|
import jl_command_palette_default from "./jl-command-palette.css.js";
|
|
13
14
|
import { css } from "@jadis/core";
|
|
@@ -187,15 +188,18 @@ var JlCommandPalette = class extends JlElement {
|
|
|
187
188
|
if (index !== null) this.choose(index);
|
|
188
189
|
});
|
|
189
190
|
this.on(dialog, "close", () => {
|
|
191
|
+
modalClosed(dialog);
|
|
190
192
|
this.reflect("open", false);
|
|
191
193
|
this.open.set(false);
|
|
192
194
|
this.events.emit("close");
|
|
193
195
|
});
|
|
194
|
-
|
|
195
|
-
if (event.target === dialog) this.close();
|
|
196
|
-
});
|
|
196
|
+
onBackdropPress(dialog, () => this.close(), this.killSignal);
|
|
197
197
|
this.renderOpen(this.open.get());
|
|
198
198
|
}
|
|
199
|
+
/** A palette taken out of the page while it shows is no longer the modal on top. */
|
|
200
|
+
onDisconnect() {
|
|
201
|
+
modalClosed(this._refs.dialog);
|
|
202
|
+
}
|
|
199
203
|
toggleOnHotkey(event) {
|
|
200
204
|
const hotkey = this.hotkey.get();
|
|
201
205
|
if (hotkey === "" || hotkey === NO_HOTKEY || event.defaultPrevented) return;
|
|
@@ -237,12 +241,14 @@ var JlCommandPalette = class extends JlElement {
|
|
|
237
241
|
if (!open) {
|
|
238
242
|
this.reflect("open", false);
|
|
239
243
|
dialog.close();
|
|
244
|
+
modalClosed(dialog);
|
|
240
245
|
return;
|
|
241
246
|
}
|
|
242
247
|
this._refs.input.value = "";
|
|
243
248
|
this.renderResults();
|
|
244
249
|
this.search("");
|
|
245
250
|
dialog.showModal();
|
|
251
|
+
modalOpened(dialog);
|
|
246
252
|
this._refs.input.focus();
|
|
247
253
|
this.reflect("open", true);
|
|
248
254
|
this.events.emit("open");
|
|
@@ -39,6 +39,9 @@ export declare class JlDialog extends JlElement {
|
|
|
39
39
|
templateCss(): string;
|
|
40
40
|
protected drawTexts(): void;
|
|
41
41
|
onConnect(): void;
|
|
42
|
+
/** A dialog taken out of the page while it shows is no longer the modal on top. */
|
|
43
|
+
onDisconnect(): void;
|
|
44
|
+
private closeUnlessPersistent;
|
|
42
45
|
private renderFooter;
|
|
43
46
|
private renderOpen;
|
|
44
47
|
}
|
|
@@ -4,6 +4,7 @@ import { JlElement } from "../base/jl-element.js";
|
|
|
4
4
|
import { oneOf } from "../lib/attributes.js";
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { JlButton } from "../atoms/jl-button.js";
|
|
7
|
+
import { modalClosed, modalOpened, onBackdropPress, setPersistent } from "../lib/modal.js";
|
|
7
8
|
import jl_dialog_default from "./jl-dialog.css.js";
|
|
8
9
|
import { css } from "@jadis/core";
|
|
9
10
|
import { X } from "lucide";
|
|
@@ -37,6 +38,7 @@ var JlDialog = class extends JlElement {
|
|
|
37
38
|
/** Keeps the dialog open on Escape and on a click outside: only its own buttons close it. */
|
|
38
39
|
persistent = this.useChange(false, (value) => {
|
|
39
40
|
this._refs.close.hidden = value;
|
|
41
|
+
setPersistent(this._refs.dialog, value);
|
|
40
42
|
}, { attribute: "persistent" });
|
|
41
43
|
_refs = this.useRefs((ref) => ({
|
|
42
44
|
actions: ref("slot[name=\"actions\"]"),
|
|
@@ -87,18 +89,24 @@ var JlDialog = class extends JlElement {
|
|
|
87
89
|
const dialog = this._refs.dialog;
|
|
88
90
|
this._refs.close.events.register("press", () => this.close());
|
|
89
91
|
this.on(dialog, "close", () => {
|
|
92
|
+
modalClosed(dialog);
|
|
90
93
|
this.open.set(false);
|
|
91
94
|
this.events.emit("close");
|
|
92
95
|
});
|
|
93
96
|
this.on(dialog, "cancel", (event) => {
|
|
94
97
|
if (this.persistent.get()) event.preventDefault();
|
|
95
98
|
});
|
|
96
|
-
|
|
97
|
-
if (event.target === dialog && !this.persistent.get()) this.close();
|
|
98
|
-
});
|
|
99
|
+
onBackdropPress(dialog, () => this.closeUnlessPersistent(), this.killSignal);
|
|
99
100
|
this.renderFooter();
|
|
100
101
|
this.on(this._refs.actions, "slotchange", () => this.renderFooter());
|
|
101
102
|
}
|
|
103
|
+
/** A dialog taken out of the page while it shows is no longer the modal on top. */
|
|
104
|
+
onDisconnect() {
|
|
105
|
+
modalClosed(this._refs.dialog);
|
|
106
|
+
}
|
|
107
|
+
closeUnlessPersistent() {
|
|
108
|
+
if (!this.persistent.get()) this.close();
|
|
109
|
+
}
|
|
102
110
|
renderFooter() {
|
|
103
111
|
this._refs.footer.hidden = this._refs.actions.assignedElements().length === 0;
|
|
104
112
|
}
|
|
@@ -109,10 +117,12 @@ var JlDialog = class extends JlElement {
|
|
|
109
117
|
if (open) {
|
|
110
118
|
this.renderFooter();
|
|
111
119
|
dialog.showModal();
|
|
120
|
+
modalOpened(dialog);
|
|
112
121
|
this.events.emit("open");
|
|
113
122
|
return;
|
|
114
123
|
}
|
|
115
124
|
dialog.close();
|
|
125
|
+
modalClosed(dialog);
|
|
116
126
|
}
|
|
117
127
|
};
|
|
118
128
|
JlDialog.register();
|
|
@@ -46,6 +46,9 @@ export declare class JlDrawer extends JlElement {
|
|
|
46
46
|
templateCss(): string;
|
|
47
47
|
protected drawTexts(): void;
|
|
48
48
|
onConnect(): void;
|
|
49
|
+
/** A drawer taken out of the page while it shows is no longer the modal on top. */
|
|
50
|
+
onDisconnect(): void;
|
|
51
|
+
private closeUnlessPersistent;
|
|
49
52
|
private renderFooter;
|
|
50
53
|
private renderOpen;
|
|
51
54
|
}
|
|
@@ -4,6 +4,7 @@ import { JlElement } from "../base/jl-element.js";
|
|
|
4
4
|
import { oneOf } from "../lib/attributes.js";
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { JlButton } from "../atoms/jl-button.js";
|
|
7
|
+
import { modalClosed, modalOpened, onBackdropPress, setPersistent } from "../lib/modal.js";
|
|
7
8
|
import jl_drawer_default from "./jl-drawer.css.js";
|
|
8
9
|
import { css } from "@jadis/core";
|
|
9
10
|
import { X } from "lucide";
|
|
@@ -47,6 +48,7 @@ var JlDrawer = class extends JlElement {
|
|
|
47
48
|
/** Keeps the drawer open on Escape and on a click outside: only its own buttons close it. */
|
|
48
49
|
persistent = this.useChange(false, (value) => {
|
|
49
50
|
this._refs.close.hidden = value;
|
|
51
|
+
setPersistent(this._refs.dialog, value);
|
|
50
52
|
}, { attribute: "persistent" });
|
|
51
53
|
_refs = this.useRefs((ref) => ({
|
|
52
54
|
close: ref(".close"),
|
|
@@ -108,6 +110,7 @@ var JlDrawer = class extends JlElement {
|
|
|
108
110
|
const dialog = this._refs.dialog;
|
|
109
111
|
this._refs.close.events.register("press", () => this.close());
|
|
110
112
|
this.on(dialog, "close", () => {
|
|
113
|
+
modalClosed(dialog);
|
|
111
114
|
this.reflect("open", false);
|
|
112
115
|
this.open.set(false);
|
|
113
116
|
this.events.emit("close");
|
|
@@ -115,13 +118,18 @@ var JlDrawer = class extends JlElement {
|
|
|
115
118
|
this.on(dialog, "cancel", (event) => {
|
|
116
119
|
if (this.persistent.get()) event.preventDefault();
|
|
117
120
|
});
|
|
118
|
-
|
|
119
|
-
if (event.target === dialog && !this.persistent.get()) this.close();
|
|
120
|
-
});
|
|
121
|
+
onBackdropPress(dialog, () => this.closeUnlessPersistent(), this.killSignal);
|
|
121
122
|
this.renderFooter();
|
|
122
123
|
this.on(this._refs.footerSlot, "slotchange", () => this.renderFooter());
|
|
123
124
|
this.renderOpen(this.open.get());
|
|
124
125
|
}
|
|
126
|
+
/** A drawer taken out of the page while it shows is no longer the modal on top. */
|
|
127
|
+
onDisconnect() {
|
|
128
|
+
modalClosed(this._refs.dialog);
|
|
129
|
+
}
|
|
130
|
+
closeUnlessPersistent() {
|
|
131
|
+
if (!this.persistent.get()) this.close();
|
|
132
|
+
}
|
|
125
133
|
renderFooter() {
|
|
126
134
|
this._refs.footer.hidden = this._refs.footerSlot.assignedElements().length === 0;
|
|
127
135
|
}
|
|
@@ -130,12 +138,14 @@ var JlDrawer = class extends JlElement {
|
|
|
130
138
|
if (open === dialog.open || !this.isConnected) return;
|
|
131
139
|
if (open) {
|
|
132
140
|
dialog.showModal();
|
|
141
|
+
modalOpened(dialog);
|
|
133
142
|
this.reflect("open", true);
|
|
134
143
|
this.events.emit("open");
|
|
135
144
|
return;
|
|
136
145
|
}
|
|
137
146
|
this.reflect("open", false);
|
|
138
147
|
dialog.close();
|
|
148
|
+
modalClosed(dialog);
|
|
139
149
|
}
|
|
140
150
|
};
|
|
141
151
|
JlDrawer.register();
|
|
@@ -59,6 +59,8 @@ export declare class JlFlow extends JlElement {
|
|
|
59
59
|
templateHtml(): Node;
|
|
60
60
|
templateCss(): string;
|
|
61
61
|
protected drawTexts(): void;
|
|
62
|
+
/** What a drawn node says in jlib's language: how it did in the run, and what each of its + buttons adds after. */
|
|
63
|
+
private drawNodeTexts;
|
|
62
64
|
private renderLabel;
|
|
63
65
|
onConnect(): void;
|
|
64
66
|
private show;
|
|
@@ -64,14 +64,16 @@ var STATUS_ICONS = {
|
|
|
64
64
|
running: "loader-circle",
|
|
65
65
|
waiting: "hourglass"
|
|
66
66
|
};
|
|
67
|
-
var
|
|
68
|
-
done: "
|
|
69
|
-
failed: "
|
|
70
|
-
running: "
|
|
71
|
-
waiting: "
|
|
67
|
+
var STATUS_TEXTS = {
|
|
68
|
+
done: "flowDone",
|
|
69
|
+
failed: "flowFailed",
|
|
70
|
+
running: "flowRunning",
|
|
71
|
+
waiting: "flowWaiting"
|
|
72
72
|
};
|
|
73
|
+
/** How a node did in the run, in jlib's language. */
|
|
74
|
+
var statusText = (status) => jlText(STATUS_TEXTS[status]);
|
|
73
75
|
/** What screen readers hear after a node's label: how it did in the run, and what to fix. */
|
|
74
|
-
var noteOf = (node) => [node.status ?
|
|
76
|
+
var noteOf = (node) => [node.status ? statusText(node.status) : "", node.problem ?? ""].filter((part) => part !== "").join(". ");
|
|
75
77
|
var markOf = (element, name) => element?.closest(`[${name}]`)?.getAttribute(name) ?? void 0;
|
|
76
78
|
var isControl = (event) => event.composedPath().some((element) => element instanceof Element && element.hasAttribute("data-control"));
|
|
77
79
|
function targetOf(event) {
|
|
@@ -86,7 +88,10 @@ function targetOf(event) {
|
|
|
86
88
|
}
|
|
87
89
|
var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
88
90
|
var newId = (prefix) => `${prefix}_${crypto.randomUUID().replaceAll("-", "").slice(0, ID_LENGTH)}`;
|
|
89
|
-
var addLabel = (node, port) => port.label ?
|
|
91
|
+
var addLabel = (node, port) => port.label ? jlText("addAfterPort", {
|
|
92
|
+
name: node.label,
|
|
93
|
+
port: port.label
|
|
94
|
+
}) : jlText("addAfter", { name: node.label });
|
|
90
95
|
/** Whether a node's new version differs in its position alone, as a drag or the arrows leave it: it only moves. */
|
|
91
96
|
function movedOnly(before, after) {
|
|
92
97
|
return [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].every((key) => key === "position" || Reflect.get(before, key) === Reflect.get(after, key));
|
|
@@ -285,9 +290,24 @@ var JlFlow = class extends JlElement {
|
|
|
285
290
|
button.title = text;
|
|
286
291
|
button.setAttribute("aria-label", text);
|
|
287
292
|
}
|
|
288
|
-
for (const { element } of this._nodes.values())
|
|
293
|
+
for (const { element, node } of this._nodes.values()) {
|
|
294
|
+
element.setAttribute("aria-roledescription", jlText("node"));
|
|
295
|
+
this.drawNodeTexts(element, node);
|
|
296
|
+
}
|
|
289
297
|
for (const port of this._refs.nodes.querySelectorAll(".port")) port.title = jlText("dragToConnect");
|
|
290
298
|
}
|
|
299
|
+
/** What a drawn node says in jlib's language: how it did in the run, and what each of its + buttons adds after. */
|
|
300
|
+
drawNodeTexts(element, node) {
|
|
301
|
+
if (node === void 0) return;
|
|
302
|
+
setOrRemove(element, "aria-description", noteOf(node));
|
|
303
|
+
const status = element.querySelector(".status");
|
|
304
|
+
if (status !== null && node.status) status.title = statusText(node.status);
|
|
305
|
+
const ports = portsOf(node);
|
|
306
|
+
for (const add of element.querySelectorAll(".add")) {
|
|
307
|
+
const port = ports.find((candidate) => candidate.id === add.dataset.add);
|
|
308
|
+
add.setAttribute("aria-label", port === void 0 ? "" : addLabel(node, port));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
291
311
|
renderLabel() {
|
|
292
312
|
this._refs.viewport.setAttribute("aria-label", this.label.get() || jlText("flow"));
|
|
293
313
|
}
|
|
@@ -692,7 +712,7 @@ var JlFlow = class extends JlElement {
|
|
|
692
712
|
}) : null,
|
|
693
713
|
node.status ? /* @__PURE__ */ jsx("span", {
|
|
694
714
|
class: "status",
|
|
695
|
-
title:
|
|
715
|
+
title: statusText(node.status),
|
|
696
716
|
attrs: { part: "status" },
|
|
697
717
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
698
718
|
name: STATUS_ICONS[node.status],
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-table.css?inline
|
|
2
|
-
var jl_table_default = ":host{contain:inline-size;--max-height:none;--cell-y:10px;--cell-x:14px;--select-width:44px;--expand-width:36px;--lead:0px;display:block}:host([expandable]){--lead:var(--expand-width)}:host([expandable][selectable]){--expand-width:28px;--lead:calc(var(--select-width) + var(--expand-width))}:host([dense]){--cell-y:6px;--cell-x:12px}.scroll{max-height:var(--max-height);border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface);overscroll-behavior-x:contain;position:relative;overflow:auto}:host([expandable]) .scroll{container-type:inline-size}table{border-collapse:separate;border-spacing:0;width:100%;color:var(--jl-text);font-size:var(--jl-font-md);line-height:20px}th,td{padding:var(--cell-y) var(--cell-x);white-space:nowrap;vertical-align:middle}th{z-index:1;border-bottom:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);letter-spacing:.01em;text-align:left;font-weight:600;position:sticky;top:0}td{border-top:1px solid var(--jl-line-soft)}tbody tr:first-child td{border-top:none}tbody tr.empty td{padding:40px var(--cell-x);color:var(--jl-muted);text-align:center}tbody tr.detail td{padding:0 var(--cell-x) calc(var(--cell-y) + 6px) calc(var(--lead) + var(--cell-x));white-space:normal;cursor:auto;border-top:none}.detail-body{left:calc(var(--lead) + var(--cell-x));max-width:calc(100cqi - var(--lead) - 2 * var(--cell-x));position:sticky}.align-left{text-align:left}.align-center{text-align:center}.align-right{text-align:right}.sort{border-radius:var(--jl-radius-xs);color:inherit;font-weight:inherit;letter-spacing:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;margin:-2px -4px;padding:2px 4px;display:inline-flex}.sort:hover{color:var(--jl-text)}.sort-icon{color:var(--jl-faint)}th[aria-sort]{color:var(--jl-text)}th[aria-sort] .sort-icon{color:var(--jl-accent)}tbody tr[data-marked] td{background:var(--jl-accent-soft)}tbody tr[data-marked] td:first-child{box-shadow:inset 3px 0 0 var(--jl-accent)}tbody tr:has(>.select-cell .checkbox:checked) td{background:var(--jl-accent-soft)}tbody tr:not(.empty,.skeleton,.detail,:has(>.select-cell .checkbox:checked)):hover td,:host([striped]) tbody tr:nth-child(2n of :where(:not(.detail))):not(.empty,[data-marked],:has(>.select-cell .checkbox:checked)) td{background:var(--jl-surface-2)}:host([striped]) tbody tr:not(.empty,.skeleton,.detail,:has(>.select-cell .checkbox:checked)):hover td{background:var(--jl-surface-3)}:host([striped]) tbody tr:nth-child(2n of :where(:not(.detail))):not([data-marked],:has(>.select-cell .checkbox:checked))+.detail td{background:var(--jl-surface-2)}.format-number{font-variant-numeric:tabular-nums}td.wrap{white-space:normal;overflow-wrap:anywhere;min-width:160px}.format-date{color:var(--jl-text-2);font-variant-numeric:tabular-nums}code{border-radius:var(--jl-radius-xs);background:var(--jl-code-bg);font-size:var(--jl-font-xs);padding:2px 6px}.select-cell{width:var(--select-width);padding-right:0;line-height:0}.expand-cell{width:var(--expand-width);padding-right:0;padding-left:calc(var(--cell-x) - 4px);line-height:0}.select-cell+.expand-cell{padding-left:0}:host([expandable]) tbody tr[data-index]{cursor:pointer}.expand{border-radius:var(--jl-radius-xs);width:24px;height:24px;color:var(--jl-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin:-2px 0;padding:0;display:inline-flex}.expand:hover{color:var(--jl-text)}.chevron{transition:rotate var(--jl-fast) var(--jl-ease)}.expand[aria-expanded=true] .chevron{rotate:90deg}.check{display:inline-flex;position:relative}.checkbox{border:1.5px solid var(--jl-line-strong);background:var(--jl-surface);cursor:pointer;appearance:none;width:16px;height:16px;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease);border-radius:4px;margin:0}.checkbox:hover{border-color:var(--jl-muted)}.checkbox:checked,.checkbox:indeterminate{border-color:var(--jl-accent);background:var(--jl-accent)}.checkbox:disabled{cursor:not-allowed;opacity:.5}.mark{pointer-events:none;position:absolute;inset:0}.checkbox:checked+.mark:after{border:solid var(--jl-on-accent);content:\"\";border-width:0 2px 2px 0;width:5px;height:9px;position:absolute;top:2.5px;left:5.5px;rotate:45deg}.checkbox:indeterminate+.mark:after{background:var(--jl-on-accent);content:\"\";border-radius:1px;height:2px;position:absolute;top:7px;left:4px;right:4px}.empty-content{align-items:center;gap:8px;display:inline-flex}.empty jl-icon{color:var(--jl-faint)}.bone{border-radius:var(--jl-radius-pill);background:linear-gradient(90deg, var(--jl-surface-3) 30%, var(--jl-surface-2) 50%, var(--jl-surface-3) 70%) 0 0 / 300% 100%;vertical-align:middle;width:70%;max-width:160px;height:10px;animation:1.4s linear infinite shimmer;display:inline-block}.bone.box{border-radius:4px;width:16px;height:16px}tbody tr.skeleton:nth-child(3n+2) .bone:not(.box){width:50%}tbody tr.skeleton:nth-child(3n) .bone:not(.box){width:85%}@media (prefers-reduced-motion:reduce){.bone{animation:none}}@keyframes shimmer{0%{background-position:100% 0}to{background-position:0 0}}.cell-description{color:var(--jl-muted);font-size:var(--jl-font-xs);margin-top:2px}";
|
|
2
|
+
var jl_table_default = ":host{contain:inline-size;--max-height:none;--cell-y:10px;--cell-x:14px;--select-width:44px;--expand-width:36px;--lead:0px;display:block}:host([expandable]){--lead:var(--expand-width)}:host([expandable][selectable]){--expand-width:28px;--lead:calc(var(--select-width) + var(--expand-width))}:host([dense]){--cell-y:6px;--cell-x:12px}.scroll{max-height:var(--max-height);border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface);overscroll-behavior-x:contain;position:relative;overflow:auto}:host([expandable]) .scroll{container-type:inline-size}table{border-collapse:separate;border-spacing:0;width:100%;color:var(--jl-text);font-size:var(--jl-font-md);line-height:20px}th,td{padding:var(--cell-y) var(--cell-x);white-space:nowrap;vertical-align:middle}th{z-index:1;border-bottom:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);letter-spacing:.01em;text-align:left;font-weight:600;position:sticky;top:0}td{border-top:1px solid var(--jl-line-soft)}tbody tr:first-child td{border-top:none}tbody tr.empty td{padding:40px var(--cell-x);color:var(--jl-muted);text-align:center}tbody tr.detail td{padding:0 var(--cell-x) calc(var(--cell-y) + 6px) calc(var(--lead) + var(--cell-x));white-space:normal;cursor:auto;border-top:none}.detail-body{left:calc(var(--lead) + var(--cell-x));max-width:calc(100cqi - var(--lead) - 2 * var(--cell-x));position:sticky}.align-left{text-align:left}.align-center{text-align:center}.align-right{text-align:right}.sort{border-radius:var(--jl-radius-xs);color:inherit;font-weight:inherit;letter-spacing:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;margin:-2px -4px;padding:2px 4px;display:inline-flex}.sort:hover{color:var(--jl-text)}.sort-icon{color:var(--jl-faint)}th[aria-sort]{color:var(--jl-text)}th[aria-sort] .sort-icon{color:var(--jl-accent)}tbody tr[data-marked] td{background:var(--jl-accent-soft)}tbody tr[data-marked] td:first-child{box-shadow:inset 3px 0 0 var(--jl-accent)}tbody tr:has(>.select-cell .checkbox:checked) td{background:var(--jl-accent-soft)}tbody tr:not(.empty,.skeleton,.detail,:has(>.select-cell .checkbox:checked)):hover td,:host([striped]) tbody tr:nth-child(2n of :where(:not(.detail))):not(.empty,[data-marked],:has(>.select-cell .checkbox:checked)) td{background:var(--jl-surface-2)}:host([striped]) tbody tr:not(.empty,.skeleton,.detail,:has(>.select-cell .checkbox:checked)):hover td{background:var(--jl-surface-3)}:host([striped]) tbody tr:nth-child(2n of :where(:not(.detail))):not([data-marked],:has(>.select-cell .checkbox:checked))+.detail td{background:var(--jl-surface-2)}.format-number{font-variant-numeric:tabular-nums}td.wrap{white-space:normal;overflow-wrap:anywhere;min-width:160px}.format-date{color:var(--jl-text-2);font-variant-numeric:tabular-nums}code{border-radius:var(--jl-radius-xs);background:var(--jl-code-bg);font-size:var(--jl-font-xs);padding:2px 6px}.select-cell{width:var(--select-width);padding-right:0;line-height:0}.expand-cell{width:var(--expand-width);padding-right:0;padding-left:calc(var(--cell-x) - 4px);line-height:0}.select-cell+.expand-cell{padding-left:0}tbody tr[data-index]{cursor:var(--row-cursor,auto)}:host([expandable]) tbody tr[data-index]{cursor:pointer}.expand{border-radius:var(--jl-radius-xs);width:24px;height:24px;color:var(--jl-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin:-2px 0;padding:0;display:inline-flex}.expand:hover{color:var(--jl-text)}.chevron{transition:rotate var(--jl-fast) var(--jl-ease)}.expand[aria-expanded=true] .chevron{rotate:90deg}.check{display:inline-flex;position:relative}.checkbox{border:1.5px solid var(--jl-line-strong);background:var(--jl-surface);cursor:pointer;appearance:none;width:16px;height:16px;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease);border-radius:4px;margin:0}.checkbox:hover{border-color:var(--jl-muted)}.checkbox:checked,.checkbox:indeterminate{border-color:var(--jl-accent);background:var(--jl-accent)}.checkbox:disabled{cursor:not-allowed;opacity:.5}.mark{pointer-events:none;position:absolute;inset:0}.checkbox:checked+.mark:after{border:solid var(--jl-on-accent);content:\"\";border-width:0 2px 2px 0;width:5px;height:9px;position:absolute;top:2.5px;left:5.5px;rotate:45deg}.checkbox:indeterminate+.mark:after{background:var(--jl-on-accent);content:\"\";border-radius:1px;height:2px;position:absolute;top:7px;left:4px;right:4px}.empty-content{align-items:center;gap:8px;display:inline-flex}.empty jl-icon{color:var(--jl-faint)}.bone{border-radius:var(--jl-radius-pill);background:linear-gradient(90deg, var(--jl-surface-3) 30%, var(--jl-surface-2) 50%, var(--jl-surface-3) 70%) 0 0 / 300% 100%;vertical-align:middle;width:70%;max-width:160px;height:10px;animation:1.4s linear infinite shimmer;display:inline-block}.bone.box{border-radius:4px;width:16px;height:16px}tbody tr.skeleton:nth-child(3n+2) .bone:not(.box){width:50%}tbody tr.skeleton:nth-child(3n) .bone:not(.box){width:85%}@media (prefers-reduced-motion:reduce){.bone{animation:none}}@keyframes shimmer{0%{background-position:100% 0}to{background-position:0 0}}.cell-description{color:var(--jl-muted);font-size:var(--jl-font-xs);margin-top:2px}";
|
|
3
3
|
export { jl_table_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JlElement } from '../base/jl-element';
|
|
2
|
-
import type { TableColumn, TableColumnKey, TableDetailRenderer, TableExpansion, TableField, TableRenderers, TableRow, TableRowKey, TableSort, TableSortDirection, TableToggle } from '../types/jl-table.types';
|
|
2
|
+
import type { TableColumn, TableColumnKey, TableDetailRenderer, TableExpansion, TableField, TablePress, TableRenderers, TableRow, TableRowKey, TableSort, TableSortDirection, TableToggle } from '../types/jl-table.types';
|
|
3
3
|
export declare const TABLE_SORT_DIRECTIONS: readonly TableSortDirection[];
|
|
4
4
|
export declare const TABLE_EXPANSIONS: readonly TableExpansion[];
|
|
5
5
|
/**
|
|
@@ -8,7 +8,8 @@ export declare const TABLE_EXPANSIONS: readonly TableExpansion[];
|
|
|
8
8
|
* rows in place; `selectable` adds a checkbox column. The header stays on top while the rows scroll within
|
|
9
9
|
* `max-height`, and the table scrolls sideways on narrow screens. Cells of a column can be drawn by code with
|
|
10
10
|
* `renderers`. `expandable` rows open on a press to show their `detail` under them, the row staying as it is: one at
|
|
11
|
-
* a time (`single`) or any number (`multiple`).
|
|
11
|
+
* a time (`single`) or any number (`multiple`). A press on a row fires `press` with the row, the button and the
|
|
12
|
+
* browser's event, which a page cancels to refuse it: to open a record on a click, its own menu on a right click.
|
|
12
13
|
*
|
|
13
14
|
* Typed by its rows, `JlTable<Order>` checks and completes the fields its columns name, and hands its renderers and
|
|
14
15
|
* `detail` an order; `JlTable<Order, 'actions'>` adds a column that is not a field, which a renderer draws.
|
|
@@ -19,6 +20,7 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
19
20
|
sort: TableSort<Row, Extra>;
|
|
20
21
|
selection: TableRowKey[];
|
|
21
22
|
toggle: TableToggle;
|
|
23
|
+
press: TablePress<Row>;
|
|
22
24
|
}>>;
|
|
23
25
|
readonly columns: Readonly<Readonly<{
|
|
24
26
|
get(): TableColumn<Row, Extra>[];
|
|
@@ -125,9 +127,19 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
125
127
|
private sortBy;
|
|
126
128
|
private changeSelection;
|
|
127
129
|
/** A press on a row's chevron, or on the row anywhere but its controls and its checkbox, opens or closes it. */
|
|
130
|
+
/**
|
|
131
|
+
* A press on a row. The page hears of it first (`press`); then, for a click it did not refuse, an expandable row
|
|
132
|
+
* opens or closes.
|
|
133
|
+
*/
|
|
128
134
|
private pressRow;
|
|
129
135
|
/** The row of data a press is on: one of the table's, not a row in the content of a detail. */
|
|
130
136
|
private dataRowOf;
|
|
137
|
+
/**
|
|
138
|
+
* Whether a press is on the row itself: not on a control in it (a link, a button, its chevron), nor in its
|
|
139
|
+
* selection cell, nor the end of a drag that selected text. Those keep their press for themselves.
|
|
140
|
+
*/
|
|
141
|
+
private isOnRowItself;
|
|
142
|
+
/** An expandable row opens on a press on itself, and on its chevron. */
|
|
131
143
|
private opensOnPress;
|
|
132
144
|
private renderMaxHeight;
|
|
133
145
|
private isExpandable;
|
|
@@ -152,7 +164,6 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
152
164
|
private cellValue;
|
|
153
165
|
private skeletonRows;
|
|
154
166
|
private emptyRow;
|
|
155
|
-
private keyOf;
|
|
156
167
|
/**
|
|
157
168
|
* Draws a state on the rows whose keys came into it or left it since it was last drawn: checking or opening one
|
|
158
169
|
* row changes that row alone, whatever the number of rows.
|
|
@@ -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. */
|
|
@@ -503,9 +525,6 @@ var JlTable = class extends JlElement {
|
|
|
503
525
|
})
|
|
504
526
|
});
|
|
505
527
|
}
|
|
506
|
-
keyOf(row) {
|
|
507
|
-
return this._view.drawn[Number(row.dataset.index)]?.key;
|
|
508
|
-
}
|
|
509
528
|
/**
|
|
510
529
|
* Draws a state on the rows whose keys came into it or left it since it was last drawn: checking or opening one
|
|
511
530
|
* row changes that row alone, whatever the number of rows.
|
|
@@ -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 };
|