@f-ewald/components 1.40.3 → 1.42.2
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 +14 -4
- package/custom-elements.json +2017 -131
- package/dist/app-shell.js +1 -1
- package/dist/app-shell.js.map +1 -1
- package/dist/blink-cursor.d.ts +27 -0
- package/dist/blink-cursor.d.ts.map +1 -0
- package/dist/blink-cursor.js +78 -0
- package/dist/blink-cursor.js.map +1 -0
- package/dist/code-diff.d.ts +41 -0
- package/dist/code-diff.d.ts.map +1 -0
- package/dist/code-diff.js +161 -0
- package/dist/code-diff.js.map +1 -0
- package/dist/comment-label.d.ts +26 -0
- package/dist/comment-label.d.ts.map +1 -0
- package/dist/comment-label.js +81 -0
- package/dist/comment-label.js.map +1 -0
- package/dist/confirm-dialog.d.ts +12 -6
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +50 -88
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/dag-graph.d.ts +161 -0
- package/dist/dag-graph.d.ts.map +1 -0
- package/dist/dag-graph.js +724 -0
- package/dist/dag-graph.js.map +1 -0
- package/dist/icons.d.ts +16 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +16 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +1 -1
- package/dist/mcp-server.js.map +1 -1
- package/dist/modal-dialog.d.ts +16 -13
- package/dist/modal-dialog.d.ts.map +1 -1
- package/dist/modal-dialog.js +69 -104
- package/dist/modal-dialog.js.map +1 -1
- package/dist/photo-gallery.js +1 -1
- package/dist/photo-gallery.js.map +1 -1
- package/dist/price-history-chart.js +1 -1
- package/dist/price-history-chart.js.map +1 -1
- package/dist/progress-bar.d.ts.map +1 -1
- package/dist/progress-bar.js +23 -17
- package/dist/progress-bar.js.map +1 -1
- package/dist/slide-panel.d.ts +3 -3
- package/dist/slide-panel.d.ts.map +1 -1
- package/dist/slide-panel.js +38 -22
- package/dist/slide-panel.js.map +1 -1
- package/dist/stat-strip.d.ts +30 -0
- package/dist/stat-strip.d.ts.map +1 -0
- package/dist/stat-strip.js +111 -0
- package/dist/stat-strip.js.map +1 -0
- package/dist/step-ladder.d.ts +46 -0
- package/dist/step-ladder.d.ts.map +1 -0
- package/dist/step-ladder.js +175 -0
- package/dist/step-ladder.js.map +1 -0
- package/dist/terminal-block.d.ts +45 -0
- package/dist/terminal-block.d.ts.map +1 -0
- package/dist/terminal-block.js +113 -0
- package/dist/terminal-block.js.map +1 -0
- package/dist/toast-notification.d.ts +7 -0
- package/dist/toast-notification.d.ts.map +1 -1
- package/dist/toast-notification.js +34 -0
- package/dist/toast-notification.js.map +1 -1
- package/dist/tokens.css +64 -1
- package/dist/tokens.d.ts +58 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +145 -0
- package/dist/tokens.js.map +1 -1
- package/dist/ui-button.js +2 -2
- package/dist/ui-button.js.map +1 -1
- package/dist/utils/dag-layout.d.ts +60 -0
- package/dist/utils/dag-layout.d.ts.map +1 -0
- package/dist/utils/dag-layout.js +80 -0
- package/dist/utils/dag-layout.js.map +1 -0
- package/dist/window-chrome.d.ts +34 -0
- package/dist/window-chrome.d.ts.map +1 -0
- package/dist/window-chrome.js +141 -0
- package/dist/window-chrome.js.map +1 -0
- package/docs/app-shell.md +1 -1
- package/docs/blink-cursor.md +45 -0
- package/docs/code-diff.md +64 -0
- package/docs/comment-label.md +49 -0
- package/docs/confirm-dialog.md +4 -3
- package/docs/dag-graph.md +101 -0
- package/docs/design-language.md +43 -21
- package/docs/icons.md +8 -0
- package/docs/layouts/marketing-landing.md +102 -0
- package/docs/modal-dialog.md +9 -9
- package/docs/photo-gallery.md +1 -1
- package/docs/price-history-chart.md +1 -0
- package/docs/slide-panel.md +2 -2
- package/docs/stat-strip.md +57 -0
- package/docs/step-ladder.md +63 -0
- package/docs/terminal-block.md +69 -0
- package/docs/ui-button.md +2 -0
- package/docs/window-chrome.md +64 -0
- package/llms.txt +282 -18
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-dialog.d.ts","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAW1E
|
|
1
|
+
{"version":3,"file":"confirm-dialog.d.ts","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAW1E;;;;;;;;;;;;GAYG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,OAAgB,MAAM,4BA0LpB;IAEF,qCAAqC;IACR,IAAI,UAAS;IAC1C,oCAAoC;IACM,YAAY,SAAY;IAClE,mCAAmC;IACM,WAAW,SAAY;IAChE,wEAAwE;IAC3C,MAAM,UAAQ;IAC3C,8EAA8E;IACjD,IAAI,UAAS;IAC1C,gEAAgE;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxC,oGAAoG;IACvE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAErC,OAAO,CAAC,OAAO,CAAqB;IAErD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAIf,qGAAqG;IACrG,OAAO,CAAC,aAAa;IAMrB,wFAAwF;IACxF,OAAO,CAAC,gBAAgB,CAEtB;IAEF;;;OAGG;IACH,OAAO,CAAC,eAAe,CAGrB;IAEF,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAYxD;IAEQ,oBAAoB,IAAI,IAAI,CAKpC;IAEQ,MAAM,yCAwBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
package/dist/confirm-dialog.js
CHANGED
|
@@ -5,14 +5,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { LitElement, css, html, nothing } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
8
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
9
9
|
import { iconArrowPath } from "./icons.js";
|
|
10
10
|
import { tokens } from "./tokens.js";
|
|
11
11
|
import { activateLayer, claimEscape, deactivateLayer, isTopLayer, } from "./utils/layer-stack.js";
|
|
12
12
|
/**
|
|
13
|
-
* Reusable confirmation dialog:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Reusable confirmation dialog: a native modal `<dialog>` (top layer, inert
|
|
14
|
+
* page behind it, built-in focus containment) with a slotted body, an
|
|
15
|
+
* optional error line, and Cancel/Confirm actions. Instant open/close (no
|
|
16
|
+
* transitions). Fires `confirm`/`cancel`
|
|
16
17
|
* (bubbling, composed) instead of owning any deletion logic itself —
|
|
17
18
|
* callers stay in charge of the request. Set `size="sm"` for compact
|
|
18
19
|
* actions one step below the default, matching `ui-button`'s `sm` size.
|
|
@@ -38,57 +39,31 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
38
39
|
this.error = null;
|
|
39
40
|
/** Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. */
|
|
40
41
|
this.size = "md";
|
|
41
|
-
|
|
42
|
-
this._onDocumentFocusIn = (event) => {
|
|
43
|
-
if (!this.open || !isTopLayer(this) || event.composedPath().includes(this))
|
|
44
|
-
return;
|
|
45
|
-
this._focusInitial();
|
|
46
|
-
};
|
|
42
|
+
/** Escape goes to the topmost layer only; it's ignored while a request is in flight. */
|
|
47
43
|
this._onWindowKeydown = (event) => {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (this.open && claimEscape(this, event) && !this.busy)
|
|
45
|
+
this._cancel();
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Native close requests (e.g. a back gesture) are routed through `cancel`; the consumer owns `open`.
|
|
49
|
+
* Named `_onNativeCancel` because this component also fires its own bubbling `cancel` CustomEvent.
|
|
50
|
+
*/
|
|
51
|
+
this._onNativeCancel = (event) => {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
if (this.open && isTopLayer(this) && !this.busy)
|
|
51
54
|
this._cancel();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (event.key !== "Tab")
|
|
55
|
-
return;
|
|
56
|
-
const focusable = this._getFocusableElements();
|
|
57
|
-
if (focusable.length === 0) {
|
|
58
|
-
event.preventDefault();
|
|
59
|
-
this._focusInitial();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const active = (this.shadowRoot?.activeElement ?? document.activeElement);
|
|
63
|
-
const index = focusable.indexOf(active);
|
|
64
|
-
if (event.shiftKey && index <= 0) {
|
|
65
|
-
event.preventDefault();
|
|
66
|
-
focusable.at(-1)?.focus();
|
|
67
|
-
}
|
|
68
|
-
else if (!event.shiftKey && index === focusable.length - 1) {
|
|
69
|
-
event.preventDefault();
|
|
70
|
-
focusable[0]?.focus();
|
|
71
|
-
}
|
|
72
55
|
};
|
|
73
56
|
}
|
|
74
57
|
static { this.styles = [
|
|
75
58
|
tokens,
|
|
76
59
|
css `
|
|
77
|
-
.overlay {
|
|
78
|
-
position: fixed;
|
|
79
|
-
inset: 0;
|
|
80
|
-
background: var(--ui-overlay, rgb(15 23 42 / 0.45));
|
|
81
|
-
z-index: var(--component-layer-z, 50);
|
|
82
|
-
display: none;
|
|
83
|
-
align-items: flex-start;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
padding: 10vh 1.25rem 1.25rem;
|
|
86
|
-
box-sizing: border-box;
|
|
87
|
-
}
|
|
88
|
-
.overlay.open {
|
|
89
|
-
display: flex;
|
|
90
|
-
}
|
|
91
60
|
.dialog {
|
|
61
|
+
/* Native modal <dialog>: top layer, inert page behind it, built-in focus containment. */
|
|
62
|
+
position: fixed;
|
|
63
|
+
inset: 0 0 auto 0;
|
|
64
|
+
margin: 10vh auto 0;
|
|
65
|
+
border: 0;
|
|
66
|
+
color: inherit;
|
|
92
67
|
background: var(--ui-surface, #ffffff);
|
|
93
68
|
border-radius: var(--ui-radius, 0.5rem);
|
|
94
69
|
box-shadow: var(
|
|
@@ -102,6 +77,9 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
102
77
|
box-sizing: border-box;
|
|
103
78
|
outline: none;
|
|
104
79
|
}
|
|
80
|
+
.dialog::backdrop {
|
|
81
|
+
background: var(--ui-overlay, rgb(15 23 42 / 0.45));
|
|
82
|
+
}
|
|
105
83
|
.dialog-text {
|
|
106
84
|
margin: 0 0 1rem;
|
|
107
85
|
color: var(--ui-text, #0f172a);
|
|
@@ -256,11 +234,8 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
256
234
|
}
|
|
257
235
|
}
|
|
258
236
|
@media (max-width: 48rem) {
|
|
259
|
-
.overlay {
|
|
260
|
-
padding: 0.75rem;
|
|
261
|
-
overflow-y: auto;
|
|
262
|
-
}
|
|
263
237
|
.dialog {
|
|
238
|
+
margin-top: 0.75rem;
|
|
264
239
|
padding: 0.75rem;
|
|
265
240
|
}
|
|
266
241
|
}
|
|
@@ -272,73 +247,57 @@ let ConfirmDialog = class ConfirmDialog extends LitElement {
|
|
|
272
247
|
_cancel() {
|
|
273
248
|
this.dispatchEvent(new CustomEvent("cancel", { bubbles: true, composed: true }));
|
|
274
249
|
}
|
|
275
|
-
|
|
276
|
-
const selector = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
|
|
277
|
-
const slotted = Array.from(this.querySelectorAll(selector));
|
|
278
|
-
const internal = Array.from(this.shadowRoot?.querySelectorAll(selector) ?? []).filter((element) => element.closest(".dialog") !== null);
|
|
279
|
-
return [...slotted, ...internal].filter((element) => !element.hasAttribute("hidden"));
|
|
280
|
-
}
|
|
250
|
+
/** Native focus delegation doesn't reliably reach slotted light-DOM content, so focus explicitly. */
|
|
281
251
|
_focusInitial() {
|
|
282
252
|
const autofocus = this.querySelector("[autofocus]");
|
|
283
253
|
const cancel = this.shadowRoot?.querySelector(".btn-cancel:not(:disabled)");
|
|
284
|
-
|
|
285
|
-
(autofocus ?? cancel ?? this._getFocusableElements()[0] ?? dialog)?.focus();
|
|
254
|
+
(autofocus ?? cancel)?.focus();
|
|
286
255
|
}
|
|
287
256
|
updated(changed) {
|
|
288
257
|
if (!changed.has("open"))
|
|
289
258
|
return;
|
|
290
259
|
if (this.open) {
|
|
291
260
|
activateLayer(this);
|
|
292
|
-
this._previousFocus = document.activeElement;
|
|
293
|
-
document.addEventListener("focusin", this._onDocumentFocusIn, true);
|
|
294
261
|
window.addEventListener("keydown", this._onWindowKeydown, true);
|
|
262
|
+
if (!this._dialog.open)
|
|
263
|
+
this._dialog.showModal();
|
|
295
264
|
this._focusInitial();
|
|
296
265
|
return;
|
|
297
266
|
}
|
|
298
267
|
deactivateLayer(this);
|
|
299
|
-
document.removeEventListener("focusin", this._onDocumentFocusIn, true);
|
|
300
268
|
window.removeEventListener("keydown", this._onWindowKeydown, true);
|
|
301
|
-
if (this.
|
|
302
|
-
this.
|
|
303
|
-
this._previousFocus = null;
|
|
269
|
+
if (this._dialog.open)
|
|
270
|
+
this._dialog.close();
|
|
304
271
|
}
|
|
305
272
|
disconnectedCallback() {
|
|
306
273
|
super.disconnectedCallback();
|
|
307
|
-
document.removeEventListener("focusin", this._onDocumentFocusIn, true);
|
|
308
274
|
window.removeEventListener("keydown", this._onWindowKeydown, true);
|
|
309
275
|
deactivateLayer(this);
|
|
310
|
-
if (this._previousFocus?.isConnected)
|
|
311
|
-
this._previousFocus.focus();
|
|
312
|
-
this._previousFocus = null;
|
|
313
276
|
this.open = false;
|
|
314
277
|
}
|
|
315
278
|
render() {
|
|
316
279
|
const accessibleName = this.getAttribute("aria-label") ?? "Confirmation";
|
|
317
280
|
return html `
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
>
|
|
327
|
-
<p id="dialog-text" class="dialog-text"><slot></slot></p>
|
|
328
|
-
${this.error
|
|
281
|
+
<dialog
|
|
282
|
+
class="dialog"
|
|
283
|
+
aria-label=${accessibleName}
|
|
284
|
+
aria-describedby=${this.error ? "dialog-text dialog-error" : "dialog-text"}
|
|
285
|
+
@cancel=${this._onNativeCancel}
|
|
286
|
+
>
|
|
287
|
+
<p id="dialog-text" class="dialog-text"><slot></slot></p>
|
|
288
|
+
${this.error
|
|
329
289
|
? html `<p id="dialog-error" class="error-text" role="alert">${this.error}</p>`
|
|
330
290
|
: nothing}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
291
|
+
<div class="dialog-actions">
|
|
292
|
+
<button class="btn-cancel" ?disabled=${this.busy} @click=${this._cancel}>${this.cancelLabel}</button>
|
|
293
|
+
<button class=${this.danger ? "btn-danger" : "btn-primary"} ?disabled=${this.busy} @click=${this._confirm}>
|
|
294
|
+
${this.busy
|
|
335
295
|
? html `<span class="spin" aria-hidden="true">${iconArrowPath(14)}</span>`
|
|
336
296
|
: nothing}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
</div>
|
|
297
|
+
${this.confirmLabel}
|
|
298
|
+
</button>
|
|
340
299
|
</div>
|
|
341
|
-
</
|
|
300
|
+
</dialog>
|
|
342
301
|
`;
|
|
343
302
|
}
|
|
344
303
|
};
|
|
@@ -363,6 +322,9 @@ __decorate([
|
|
|
363
322
|
__decorate([
|
|
364
323
|
property({ reflect: true })
|
|
365
324
|
], ConfirmDialog.prototype, "size", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
query("dialog")
|
|
327
|
+
], ConfirmDialog.prototype, "_dialog", void 0);
|
|
366
328
|
ConfirmDialog = __decorate([
|
|
367
329
|
customElement("confirm-dialog")
|
|
368
330
|
], ConfirmDialog);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-dialog.js","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,aAAa,EACb,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QAqML,qCAAqC;QACR,SAAI,GAAG,KAAK,CAAC;QAC1C,oCAAoC;QACM,iBAAY,GAAG,QAAQ,CAAC;QAClE,mCAAmC;QACM,gBAAW,GAAG,QAAQ,CAAC;QAChE,wEAAwE;QAC3C,WAAM,GAAG,IAAI,CAAC;QAC3C,8EAA8E;QACjD,SAAI,GAAG,KAAK,CAAC;QAC1C,gEAAgE;QACpD,UAAK,GAAkB,IAAI,CAAC;QACxC,oGAAoG;QACvE,SAAI,GAAgB,IAAI,CAAC;QAE9C,mBAAc,GAAuB,IAAI,CAAC;QA2B1C,uBAAkB,GAAG,CAAC,KAAiB,EAAQ,EAAE;YACvD,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,OAAO;YACnF,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC,CAAC;QAEM,qBAAgB,GAAG,CA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c,EAAE,CAAC;kDAAwB;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAe;AAEd;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAc;AAE9B;IAAX,QAAQ,EAAE;4CAA6B;AAEX;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAA0B;AAlN3C,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAqUzB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n activateLayer,\n claimEscape,\n deactivateLayer,\n isTopLayer,\n} from \"./utils/layer-stack.js\";\n\n/**\n * Reusable confirmation dialog: overlay + centered card with a slotted body,\n * an optional error line, and Cancel/Confirm actions. Instant `display:none`\n * → `display:flex` toggle (no transitions). Fires `confirm`/`cancel`\n * (bubbling, composed) instead of owning any deletion logic itself —\n * callers stay in charge of the request. Set `size=\"sm\"` for compact\n * actions one step below the default, matching `ui-button`'s `sm` size.\n *\n * @element confirm-dialog\n * @fires confirm - User clicked the confirm button.\n * @fires cancel - User clicked the cancel button.\n */\n@customElement(\"confirm-dialog\")\nexport class ConfirmDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .overlay {\n position: fixed;\n inset: 0;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n z-index: var(--component-layer-z, 50);\n display: none;\n align-items: flex-start;\n justify-content: center;\n padding: 10vh 1.25rem 1.25rem;\n box-sizing: border-box;\n }\n .overlay.open {\n display: flex;\n }\n .dialog {\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n padding: 1rem;\n box-sizing: border-box;\n outline: none;\n }\n .dialog-text {\n margin: 0 0 1rem;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n }\n .dialog-actions {\n display: flex;\n justify-content: flex-end;\n gap: 0.5rem;\n }\n .btn-cancel,\n .btn-danger,\n .btn-primary {\n height: 2rem;\n box-sizing: border-box;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .btn-cancel {\n /* Opaque base under the transparent-by-default secondary token, the\n same as ui-button's secondary variant — see the comment there. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 1px) solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n color: var(--ui-text, #0f172a);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 1rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n cursor: pointer;\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .btn-cancel:hover:not(:disabled) {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface, #ffffff);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n .btn-cancel:active:not(:disabled) {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface, #ffffff);\n box-shadow: none;\n }\n .btn-danger,\n .btn-primary {\n border: var(--ui-border-width, 1px) solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n /* The border width is themeable, so it has to stay inside the fixed\n height the sm size sets below. */\n box-sizing: border-box;\n padding: 0.5rem 1rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n .btn-danger {\n background: var(--ui-button-danger-background, var(--ui-danger, #dc2626));\n border-color: var(--ui-button-danger-border, transparent);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .btn-danger:hover:not(:disabled) {\n background: var(--ui-button-danger-background-hover, var(--ui-danger-hover, #b91c1c));\n }\n .btn-danger:active:not(:disabled) {\n background: var(--ui-button-danger-background-active, var(--ui-button-danger-background, var(--ui-danger, #dc2626)));\n box-shadow: none;\n }\n .btn-primary {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border-color: var(--ui-button-border, transparent);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .btn-primary:hover:not(:disabled) {\n background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));\n }\n .btn-primary:active:not(:disabled) {\n background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));\n box-shadow: none;\n }\n button:disabled {\n opacity: 0.6;\n cursor: default;\n }\n button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .btn-primary:focus-visible:not(:active),\n .btn-danger:focus-visible:not(:active),\n .btn-cancel:focus-visible:not(:active) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n :host([size=\"sm\"]) .btn-cancel,\n :host([size=\"sm\"]) .btn-danger,\n :host([size=\"sm\"]) .btn-primary {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .error-text {\n color: var(--ui-danger, #dc2626);\n font-size: var(--ui-font-size-sm, 0.75rem);\n margin: 0.5rem 0 0.75rem;\n }\n .spin {\n display: inline-flex;\n animation: spin 0.8s linear infinite;\n }\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .spin {\n animation: none;\n }\n }\n @media (forced-colors: active) {\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .overlay {\n padding: 0.75rem;\n overflow-y: auto;\n }\n .dialog {\n padding: 0.75rem;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Label for the confirm button. */\n @property({ attribute: \"confirm-label\" }) confirmLabel = \"Delete\";\n /** Label for the cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Danger (red) vs. primary (indigo) styling for the confirm button. */\n @property({ type: Boolean }) danger = true;\n /** Shows a spinner and disables both buttons while a request is in flight. */\n @property({ type: Boolean }) busy = false;\n /** Inline error line shown below the body, or null for none. */\n @property() error: string | null = null;\n /** Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n private _previousFocus: HTMLElement | null = null;\n\n private _confirm() {\n this.dispatchEvent(new CustomEvent(\"confirm\", { bubbles: true, composed: true }));\n }\n\n private _cancel() {\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n private _getFocusableElements(): HTMLElement[] {\n const selector =\n \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n const slotted = Array.from(this.querySelectorAll<HTMLElement>(selector));\n const internal = Array.from(\n this.shadowRoot?.querySelectorAll<HTMLElement>(selector) ?? [],\n ).filter((element) => element.closest(\".dialog\") !== null);\n return [...slotted, ...internal].filter((element) => !element.hasAttribute(\"hidden\"));\n }\n\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const cancel = this.shadowRoot?.querySelector<HTMLElement>(\".btn-cancel:not(:disabled)\");\n const dialog = this.shadowRoot?.querySelector<HTMLElement>(\".dialog\");\n (autofocus ?? cancel ?? this._getFocusableElements()[0] ?? dialog)?.focus();\n }\n\n private _onDocumentFocusIn = (event: FocusEvent): void => {\n if (!this.open || !isTopLayer(this) || event.composedPath().includes(this)) return;\n this._focusInitial();\n };\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !isTopLayer(this)) return;\n if (claimEscape(this, event) && !this.busy) {\n this._cancel();\n return;\n }\n if (event.key !== \"Tab\") return;\n\n const focusable = this._getFocusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n this._focusInitial();\n return;\n }\n const active = (this.shadowRoot?.activeElement ?? document.activeElement) as HTMLElement | null;\n const index = focusable.indexOf(active as HTMLElement);\n if (event.shiftKey && index <= 0) {\n event.preventDefault();\n focusable.at(-1)?.focus();\n } else if (!event.shiftKey && index === focusable.length - 1) {\n event.preventDefault();\n focusable[0]?.focus();\n }\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n this._previousFocus = document.activeElement as HTMLElement | null;\n document.addEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n this.open = false;\n }\n\n override render() {\n const accessibleName = this.getAttribute(\"aria-label\") ?? \"Confirmation\";\n return html`\n <div class=\"overlay ${this.open ? \"open\" : \"\"}\">\n <div\n class=\"dialog\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${accessibleName}\n aria-describedby=${this.error ? \"dialog-text dialog-error\" : \"dialog-text\"}\n tabindex=\"-1\"\n >\n <p id=\"dialog-text\" class=\"dialog-text\"><slot></slot></p>\n ${this.error\n ? html`<p id=\"dialog-error\" class=\"error-text\" role=\"alert\">${this.error}</p>`\n : nothing}\n <div class=\"dialog-actions\">\n <button class=\"btn-cancel\" ?disabled=${this.busy} @click=${this._cancel}>${this.cancelLabel}</button>\n <button class=${this.danger ? \"btn-danger\" : \"btn-primary\"} ?disabled=${this.busy} @click=${this._confirm}>\n ${this.busy\n ? html`<span class=\"spin\" aria-hidden=\"true\">${iconArrowPath(14)}</span>`\n : nothing}\n ${this.confirmLabel}\n </button>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"confirm-dialog\": ConfirmDialog;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"confirm-dialog.js","sourceRoot":"","sources":["../src/confirm-dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,aAAa,EACb,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;GA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,EAAE;4CAA6B;AAEX;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAA0B;AAE7B;IAAxB,KAAK,CAAC,QAAQ,CAAC;8CAAqC;AA5M1C,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAyRzB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { iconArrowPath } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n activateLayer,\n claimEscape,\n deactivateLayer,\n isTopLayer,\n} from \"./utils/layer-stack.js\";\n\n/**\n * Reusable confirmation dialog: a native modal `<dialog>` (top layer, inert\n * page behind it, built-in focus containment) with a slotted body, an\n * optional error line, and Cancel/Confirm actions. Instant open/close (no\n * transitions). Fires `confirm`/`cancel`\n * (bubbling, composed) instead of owning any deletion logic itself —\n * callers stay in charge of the request. Set `size=\"sm\"` for compact\n * actions one step below the default, matching `ui-button`'s `sm` size.\n *\n * @element confirm-dialog\n * @fires confirm - User clicked the confirm button.\n * @fires cancel - User clicked the cancel button.\n */\n@customElement(\"confirm-dialog\")\nexport class ConfirmDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .dialog {\n /* Native modal <dialog>: top layer, inert page behind it, built-in focus containment. */\n position: fixed;\n inset: 0 0 auto 0;\n margin: 10vh auto 0;\n border: 0;\n color: inherit;\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n padding: 1rem;\n box-sizing: border-box;\n outline: none;\n }\n .dialog::backdrop {\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n }\n .dialog-text {\n margin: 0 0 1rem;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n }\n .dialog-actions {\n display: flex;\n justify-content: flex-end;\n gap: 0.5rem;\n }\n .btn-cancel,\n .btn-danger,\n .btn-primary {\n height: 2rem;\n box-sizing: border-box;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .btn-cancel {\n /* Opaque base under the transparent-by-default secondary token, the\n same as ui-button's secondary variant — see the comment there. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 1px) solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n color: var(--ui-text, #0f172a);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 1rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n cursor: pointer;\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .btn-cancel:hover:not(:disabled) {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface, #ffffff);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n .btn-cancel:active:not(:disabled) {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface, #ffffff);\n box-shadow: none;\n }\n .btn-danger,\n .btn-primary {\n border: var(--ui-border-width, 1px) solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n /* The border width is themeable, so it has to stay inside the fixed\n height the sm size sets below. */\n box-sizing: border-box;\n padding: 0.5rem 1rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n .btn-danger {\n background: var(--ui-button-danger-background, var(--ui-danger, #dc2626));\n border-color: var(--ui-button-danger-border, transparent);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .btn-danger:hover:not(:disabled) {\n background: var(--ui-button-danger-background-hover, var(--ui-danger-hover, #b91c1c));\n }\n .btn-danger:active:not(:disabled) {\n background: var(--ui-button-danger-background-active, var(--ui-button-danger-background, var(--ui-danger, #dc2626)));\n box-shadow: none;\n }\n .btn-primary {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border-color: var(--ui-button-border, transparent);\n color: var(--ui-on-accent, #ffffff);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .btn-primary:hover:not(:disabled) {\n background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));\n }\n .btn-primary:active:not(:disabled) {\n background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));\n box-shadow: none;\n }\n button:disabled {\n opacity: 0.6;\n cursor: default;\n }\n button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .btn-primary:focus-visible:not(:active),\n .btn-danger:focus-visible:not(:active),\n .btn-cancel:focus-visible:not(:active) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n :host([size=\"sm\"]) .btn-cancel,\n :host([size=\"sm\"]) .btn-danger,\n :host([size=\"sm\"]) .btn-primary {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .error-text {\n color: var(--ui-danger, #dc2626);\n font-size: var(--ui-font-size-sm, 0.75rem);\n margin: 0.5rem 0 0.75rem;\n }\n .spin {\n display: inline-flex;\n animation: spin 0.8s linear infinite;\n }\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .spin {\n animation: none;\n }\n }\n @media (forced-colors: active) {\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .dialog {\n margin-top: 0.75rem;\n padding: 0.75rem;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Label for the confirm button. */\n @property({ attribute: \"confirm-label\" }) confirmLabel = \"Delete\";\n /** Label for the cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Danger (red) vs. primary (indigo) styling for the confirm button. */\n @property({ type: Boolean }) danger = true;\n /** Shows a spinner and disables both buttons while a request is in flight. */\n @property({ type: Boolean }) busy = false;\n /** Inline error line shown below the body, or null for none. */\n @property() error: string | null = null;\n /** Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n @query(\"dialog\") private _dialog!: HTMLDialogElement;\n\n private _confirm() {\n this.dispatchEvent(new CustomEvent(\"confirm\", { bubbles: true, composed: true }));\n }\n\n private _cancel() {\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n /** Native focus delegation doesn't reliably reach slotted light-DOM content, so focus explicitly. */\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const cancel = this.shadowRoot?.querySelector<HTMLElement>(\".btn-cancel:not(:disabled)\");\n (autofocus ?? cancel)?.focus();\n }\n\n /** Escape goes to the topmost layer only; it's ignored while a request is in flight. */\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (this.open && claimEscape(this, event) && !this.busy) this._cancel();\n };\n\n /**\n * Native close requests (e.g. a back gesture) are routed through `cancel`; the consumer owns `open`.\n * Named `_onNativeCancel` because this component also fires its own bubbling `cancel` CustomEvent.\n */\n private _onNativeCancel = (event: Event): void => {\n event.preventDefault();\n if (this.open && isTopLayer(this) && !this.busy) this._cancel();\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n if (!this._dialog.open) this._dialog.showModal();\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._dialog.open) this._dialog.close();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n this.open = false;\n }\n\n override render() {\n const accessibleName = this.getAttribute(\"aria-label\") ?? \"Confirmation\";\n return html`\n <dialog\n class=\"dialog\"\n aria-label=${accessibleName}\n aria-describedby=${this.error ? \"dialog-text dialog-error\" : \"dialog-text\"}\n @cancel=${this._onNativeCancel}\n >\n <p id=\"dialog-text\" class=\"dialog-text\"><slot></slot></p>\n ${this.error\n ? html`<p id=\"dialog-error\" class=\"error-text\" role=\"alert\">${this.error}</p>`\n : nothing}\n <div class=\"dialog-actions\">\n <button class=\"btn-cancel\" ?disabled=${this.busy} @click=${this._cancel}>${this.cancelLabel}</button>\n <button class=${this.danger ? \"btn-danger\" : \"btn-primary\"} ?disabled=${this.busy} @click=${this._confirm}>\n ${this.busy\n ? html`<span class=\"spin\" aria-hidden=\"true\">${iconArrowPath(14)}</span>`\n : nothing}\n ${this.confirmLabel}\n </button>\n </div>\n </dialog>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"confirm-dialog\": ConfirmDialog;\n }\n}\n"]}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type SVGTemplateResult } from "lit";
|
|
2
|
+
import "./icon-button.js";
|
|
3
|
+
import { type DagDirection } from "./utils/dag-layout.js";
|
|
4
|
+
export type { DagDirection } from "./utils/dag-layout.js";
|
|
5
|
+
/** One node of a `dag-graph`. */
|
|
6
|
+
export interface DagNode {
|
|
7
|
+
/** Unique id, referenced by edges and by `selected`. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Text shown on the node; long labels are shortened with an ellipsis (the full text is the tooltip). */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Key into `kinds`, which supplies the node's icon, color, and border style. */
|
|
12
|
+
kind?: string;
|
|
13
|
+
/** Draws the node faded with a dotted border, e.g. for data that is incomplete or unavailable. */
|
|
14
|
+
muted?: boolean;
|
|
15
|
+
/** Emphasizes the node, e.g. as part of a highlighted path or cycle. */
|
|
16
|
+
highlighted?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** One directed edge of a `dag-graph`, pointing from `source` to `target`. */
|
|
19
|
+
export interface DagEdge {
|
|
20
|
+
source: string;
|
|
21
|
+
target: string;
|
|
22
|
+
/** Emphasizes the edge, e.g. as part of a highlighted path or cycle. */
|
|
23
|
+
highlighted?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Presentation of one node kind. */
|
|
26
|
+
export interface DagNodeKind {
|
|
27
|
+
/** Name shown in the legend and appended to the node tooltip. */
|
|
28
|
+
label?: string;
|
|
29
|
+
/** Accent color (any CSS color) for the icon and border; defaults to `--ui-primary`. */
|
|
30
|
+
color?: string;
|
|
31
|
+
/** Icon factory, called with the icon size in pixels — e.g. one of the package's `icon*` exports. */
|
|
32
|
+
icon?: (size: number) => SVGTemplateResult;
|
|
33
|
+
/** Draws the node with a dashed border. */
|
|
34
|
+
dashed?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** A built-in toolbar control: `zoom` (in and out), `fit`, `center` (on the selected node), or `direction`. */
|
|
37
|
+
export type DagControl = "zoom" | "fit" | "center" | "direction";
|
|
38
|
+
/** Detail of the `direction-change` event. */
|
|
39
|
+
export interface DagDirectionChangeDetail {
|
|
40
|
+
direction: DagDirection;
|
|
41
|
+
}
|
|
42
|
+
/** Detail of the `node-select` event. */
|
|
43
|
+
export interface DagNodeSelectDetail {
|
|
44
|
+
id: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Interactive layered drawing of a directed graph — dependencies, pipelines, or any node-link data.
|
|
48
|
+
*
|
|
49
|
+
* Nodes are placed in layers (via dagre) so edges flow left to right (or top to bottom with
|
|
50
|
+
* `direction="TB"`); cycles are allowed, and the edges closing them are drawn dashed and point backward.
|
|
51
|
+
* Each node is a compact card sized to its label, with an optional icon, color, and border style from
|
|
52
|
+
* `kinds`. The whole graph is shown when it fits at a readable zoom; otherwise the selected node is centered at
|
|
53
|
+
* 100%. Drag to pan; pinch or Ctrl/⌘ + wheel to zoom (a plain wheel scrolls the page). With keyboard
|
|
54
|
+
* focus on the graph, arrow keys pan, `+`/`-` zoom, and `0` fits the graph. Clicking a node, or pressing
|
|
55
|
+
* Enter/Space on it, selects it. A toolbar in the top-right corner offers the `controls` you enable.
|
|
56
|
+
*
|
|
57
|
+
* Set `static` to present a fixed picture: the graph is always fitted into view, panning and zooming
|
|
58
|
+
* are off, and the toolbar is hidden; nodes can still be selected.
|
|
59
|
+
*
|
|
60
|
+
* Colors can be changed with these custom properties: `--dag-node-background`, `--dag-node-text`,
|
|
61
|
+
* `--dag-edge-color`, `--dag-selected-color`, and `--dag-highlight-color`; `--dag-graph-height` sets the
|
|
62
|
+
* height (default `24rem`).
|
|
63
|
+
*
|
|
64
|
+
* @element dag-graph
|
|
65
|
+
* @fires node-select - A node was clicked or activated with the keyboard; `detail` is `{ id }`.
|
|
66
|
+
* @fires direction-change - The toolbar's direction control flipped `direction`; `detail` is `{ direction }`.
|
|
67
|
+
* @slot empty - Shown when there are no nodes.
|
|
68
|
+
*/
|
|
69
|
+
export declare class DagGraph extends LitElement {
|
|
70
|
+
/** Nodes to draw. */
|
|
71
|
+
nodes: DagNode[];
|
|
72
|
+
/** Directed edges between `nodes`; edges with an unknown endpoint or to the node itself are ignored. */
|
|
73
|
+
edges: DagEdge[];
|
|
74
|
+
/** Presentation per node `kind`: legend label, color, icon, and border style. */
|
|
75
|
+
kinds: Record<string, DagNodeKind>;
|
|
76
|
+
/**
|
|
77
|
+
* Id of the selected node. Selecting a node updates it; when it changes to a node outside the visible area,
|
|
78
|
+
* the view follows.
|
|
79
|
+
*/
|
|
80
|
+
selected: string | null;
|
|
81
|
+
/** Layer direction: `LR` (left to right) or `TB` (top to bottom). */
|
|
82
|
+
direction: DagDirection;
|
|
83
|
+
/** Accessible name of the graph; the node and edge counts are appended. */
|
|
84
|
+
label: string;
|
|
85
|
+
/** Shows a legend of `kinds` below the graph. */
|
|
86
|
+
legend: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Space-separated toolbar controls to show: any of `zoom`, `fit`, `center`, and `direction`, in that
|
|
89
|
+
* order. An empty value hides the toolbar.
|
|
90
|
+
*/
|
|
91
|
+
controls: string;
|
|
92
|
+
/** Presents a static picture: always fitted, with panning, zooming, and the toolbar turned off. */
|
|
93
|
+
isStatic: boolean;
|
|
94
|
+
private _view;
|
|
95
|
+
private _hovered;
|
|
96
|
+
private _panning;
|
|
97
|
+
private _svg;
|
|
98
|
+
private _layout;
|
|
99
|
+
private _positions;
|
|
100
|
+
private _size;
|
|
101
|
+
private _viewReady;
|
|
102
|
+
private _lastSelected;
|
|
103
|
+
private _lastDirection;
|
|
104
|
+
private _measure;
|
|
105
|
+
private _measureFont;
|
|
106
|
+
private _resizeObserver;
|
|
107
|
+
private _drag;
|
|
108
|
+
private _suppressClick;
|
|
109
|
+
static styles: import("lit").CSSResult[];
|
|
110
|
+
connectedCallback(): void;
|
|
111
|
+
disconnectedCallback(): void;
|
|
112
|
+
protected firstUpdated(): void;
|
|
113
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
114
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
115
|
+
/** Fits the whole graph into view, never enlarging it beyond 100%. */
|
|
116
|
+
fit(): void;
|
|
117
|
+
/** Centers the view on a node (the selected one by default) at 100% zoom. */
|
|
118
|
+
center(id?: string | null): void;
|
|
119
|
+
/** Zooms by `factor` (e.g. `1.25` or `0.8`) around the center of the view. */
|
|
120
|
+
zoomBy(factor: number): void;
|
|
121
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
122
|
+
/** The enabled `controls`, in their fixed order; none in static mode or without nodes. */
|
|
123
|
+
private get _controls();
|
|
124
|
+
private _renderToolbar;
|
|
125
|
+
private _toggleDirection;
|
|
126
|
+
private _renderEdges;
|
|
127
|
+
private _renderNode;
|
|
128
|
+
private _renderLegend;
|
|
129
|
+
private _edgeKey;
|
|
130
|
+
private _layoutChanged;
|
|
131
|
+
/** Lays the graph out again, keeping the selected node where it was on screen. */
|
|
132
|
+
private _relayout;
|
|
133
|
+
private _initView;
|
|
134
|
+
/**
|
|
135
|
+
* Shows the whole graph when it fits at a readable zoom (always, when static); otherwise centers the selected
|
|
136
|
+
* node at 100%.
|
|
137
|
+
*/
|
|
138
|
+
private _frame;
|
|
139
|
+
/** Brings the selected node into view if it is outside the visible area. */
|
|
140
|
+
private _revealSelected;
|
|
141
|
+
/** Measures labels with the host's actual font, so themes with other fonts still size cards correctly. */
|
|
142
|
+
private _updateMeasure;
|
|
143
|
+
private _resize;
|
|
144
|
+
private _clamp;
|
|
145
|
+
private _centerOn;
|
|
146
|
+
private _zoomAround;
|
|
147
|
+
private _activate;
|
|
148
|
+
private _onNodeKey;
|
|
149
|
+
private _onPointerDown;
|
|
150
|
+
private _onPointerMove;
|
|
151
|
+
private _onPointerUp;
|
|
152
|
+
/** Pinch gestures and Ctrl/⌘ + wheel zoom; a plain wheel is left to the page so it can scroll. */
|
|
153
|
+
private _onWheel;
|
|
154
|
+
private _onKeyDown;
|
|
155
|
+
}
|
|
156
|
+
declare global {
|
|
157
|
+
interface HTMLElementTagNameMap {
|
|
158
|
+
"dag-graph": DagGraph;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=dag-graph.d.ts.map
|
|
@@ -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