treefmt: apply prettier
Pure `nix fmt` output from the commit before this one — no hand edits. 203 files: 52 md, 42 tsx, 32 js, 32 css, 21 ts, 13 html, 8 json, 3 mjs. Reproduce with `nix develop -c nix fmt` on the parent commit; the result should be byte-identical to this tree. None of the 13 `.prettierignore` entries appears here — verified by intersecting the changed-file list against the ignore file, with a control proving the intersection finds a match when one exists.
This commit is contained in:
parent
5d24bedd60
commit
39b95c2ede
203 changed files with 10090 additions and 6085 deletions
|
|
@ -19,9 +19,9 @@
|
|||
// Other `.btn` consumers across the app stay on the light-DOM `.btn`
|
||||
// class for now — migrating them is a separate follow-up.
|
||||
|
||||
import { el } from './dom.js';
|
||||
import './hive-dialog/hive-dialog.js'; // registers <hive-dialog> — side-effect import
|
||||
import './hive-toast/hive-toast.js'; // registers <hive-toast> — side-effect import
|
||||
import { el } from "./dom.js";
|
||||
import "./hive-dialog/hive-dialog.js"; // registers <hive-dialog> — side-effect import
|
||||
import "./hive-toast/hive-toast.js"; // registers <hive-toast> — side-effect import
|
||||
|
||||
// openDialog({ title, message, content, buttons, danger, dismissable })
|
||||
// → Promise resolving to the clicked button's `value`, or `null` when the
|
||||
|
|
@ -37,9 +37,11 @@ import './hive-toast/hive-toast.js'; // registers <hive-toast> — side-effect i
|
|||
// stray Enter can't fire the destructive path), else the last button.
|
||||
export function openDialog(opts = {}) {
|
||||
return new Promise((resolve) => {
|
||||
const dlg = document.createElement('hive-dialog');
|
||||
const dlg = document.createElement("hive-dialog");
|
||||
dlg._opts = opts;
|
||||
dlg.addEventListener('hive-dialog-close', (e) => resolve(e.detail), { once: true });
|
||||
dlg.addEventListener("hive-dialog-close", (e) => resolve(e.detail), {
|
||||
once: true,
|
||||
});
|
||||
document.body.append(dlg);
|
||||
});
|
||||
}
|
||||
|
|
@ -54,19 +56,31 @@ export function openDialog(opts = {}) {
|
|||
// doStop(r.graceful);
|
||||
export function themedConfirm(opts = {}) {
|
||||
const {
|
||||
title = '', message = '', danger = false,
|
||||
confirmLabel = 'confirm', cancelLabel = 'cancel', checkboxes = [],
|
||||
title = "",
|
||||
message = "",
|
||||
danger = false,
|
||||
confirmLabel = "confirm",
|
||||
cancelLabel = "cancel",
|
||||
checkboxes = [],
|
||||
} = opts;
|
||||
|
||||
const boxes = checkboxes.map((cb) => {
|
||||
const input = el('input', { type: 'checkbox', class: 'check', name: cb.name });
|
||||
const input = el("input", {
|
||||
type: "checkbox",
|
||||
class: "check",
|
||||
name: cb.name,
|
||||
});
|
||||
if (cb.checked) input.checked = true;
|
||||
const row = el('label', { class: 'checkrow' },
|
||||
input, el('span', {}, cb.label || cb.name));
|
||||
const row = el(
|
||||
"label",
|
||||
{ class: "checkrow" },
|
||||
input,
|
||||
el("span", {}, cb.label || cb.name),
|
||||
);
|
||||
return { input, row };
|
||||
});
|
||||
const content = boxes.length
|
||||
? el('div', { class: 'checks' }, ...boxes.map((b) => b.row))
|
||||
? el("div", { class: "checks" }, ...boxes.map((b) => b.row))
|
||||
: null;
|
||||
|
||||
return openDialog({
|
||||
|
|
@ -75,13 +89,20 @@ export function themedConfirm(opts = {}) {
|
|||
content,
|
||||
danger,
|
||||
buttons: [
|
||||
{ label: cancelLabel, value: null, class: 'cancel', autofocus: danger },
|
||||
{ label: confirmLabel, value: 'confirm', danger, class: 'confirm', autofocus: !danger },
|
||||
{ label: cancelLabel, value: null, class: "cancel", autofocus: danger },
|
||||
{
|
||||
label: confirmLabel,
|
||||
value: "confirm",
|
||||
danger,
|
||||
class: "confirm",
|
||||
autofocus: !danger,
|
||||
},
|
||||
],
|
||||
}).then((v) => {
|
||||
if (v !== 'confirm') return null;
|
||||
if (v !== "confirm") return null;
|
||||
const out = {};
|
||||
for (let i = 0; i < boxes.length; i++) out[checkboxes[i].name] = boxes[i].input.checked;
|
||||
for (let i = 0; i < boxes.length; i++)
|
||||
out[checkboxes[i].name] = boxes[i].input.checked;
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
|
@ -95,10 +116,19 @@ export function themedConfirm(opts = {}) {
|
|||
// (via openDialog).
|
||||
export function themedPrompt(opts = {}) {
|
||||
const {
|
||||
title = '', message = '', label = '', placeholder = '', value = '',
|
||||
confirmLabel = 'ok', cancelLabel = 'cancel',
|
||||
title = "",
|
||||
message = "",
|
||||
label = "",
|
||||
placeholder = "",
|
||||
value = "",
|
||||
confirmLabel = "ok",
|
||||
cancelLabel = "cancel",
|
||||
} = opts;
|
||||
const input = el('textarea', { class: 'input textarea', rows: '3', placeholder });
|
||||
const input = el("textarea", {
|
||||
class: "input textarea",
|
||||
rows: "3",
|
||||
placeholder,
|
||||
});
|
||||
if (value) input.value = value;
|
||||
// Enter submits (clicks the confirm button mounted by openDialog);
|
||||
// Shift+Enter falls through to the textarea's default newline insert.
|
||||
|
|
@ -106,24 +136,32 @@ export function themedPrompt(opts = {}) {
|
|||
// lives in, so this resolves to the dialog's own `.box`/confirm button
|
||||
// without leaking across instances. The confirm button is selected by
|
||||
// its `variant` attribute now (hive-btn.js), not a CSS class.
|
||||
input.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
input.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter" && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
input.closest('.box')?.querySelector('[variant="confirm"]')?.click();
|
||||
input.closest(".box")?.querySelector('[variant="confirm"]')?.click();
|
||||
}
|
||||
});
|
||||
const content = el('div', { class: 'promptfield' },
|
||||
label ? el('label', { class: 'promptlabel' }, label) : null,
|
||||
input);
|
||||
const content = el(
|
||||
"div",
|
||||
{ class: "promptfield" },
|
||||
label ? el("label", { class: "promptlabel" }, label) : null,
|
||||
input,
|
||||
);
|
||||
const result = openDialog({
|
||||
title,
|
||||
message,
|
||||
content,
|
||||
buttons: [
|
||||
{ label: cancelLabel, value: '__cancel__', class: 'cancel' },
|
||||
{ label: confirmLabel, value: '__ok__', class: 'confirm', autofocus: true },
|
||||
{ label: cancelLabel, value: "__cancel__", class: "cancel" },
|
||||
{
|
||||
label: confirmLabel,
|
||||
value: "__ok__",
|
||||
class: "confirm",
|
||||
autofocus: true,
|
||||
},
|
||||
],
|
||||
}).then((v) => (v === '__ok__' ? input.value : null));
|
||||
}).then((v) => (v === "__ok__" ? input.value : null));
|
||||
// Prefer focusing the field over the OK button once the dialog has mounted.
|
||||
setTimeout(() => input.focus(), 0);
|
||||
return result;
|
||||
|
|
@ -138,24 +176,24 @@ export function themedPrompt(opts = {}) {
|
|||
// component — no theming, no encapsulation need), so it's styled with a
|
||||
// one-off inline style rather than a stylesheet.
|
||||
export function themedToast(message, opts = {}) {
|
||||
let container = document.getElementById('tc-toasts');
|
||||
let container = document.getElementById("tc-toasts");
|
||||
if (!container) {
|
||||
container = document.createElement('div');
|
||||
container.id = 'tc-toasts';
|
||||
container = document.createElement("div");
|
||||
container.id = "tc-toasts";
|
||||
Object.assign(container.style, {
|
||||
position: 'fixed',
|
||||
top: '1em',
|
||||
right: '1em',
|
||||
zIndex: '1100',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '0.5em',
|
||||
maxWidth: 'min(28em, 92vw)',
|
||||
pointerEvents: 'none',
|
||||
position: "fixed",
|
||||
top: "1em",
|
||||
right: "1em",
|
||||
zIndex: "1100",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "0.5em",
|
||||
maxWidth: "min(28em, 92vw)",
|
||||
pointerEvents: "none",
|
||||
});
|
||||
document.body.append(container);
|
||||
}
|
||||
const toast = document.createElement('hive-toast');
|
||||
const toast = document.createElement("hive-toast");
|
||||
toast._message = message;
|
||||
toast._opts = opts;
|
||||
container.append(toast);
|
||||
|
|
|
|||
Loading…
Reference in a new issue