@aparte/core 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/conversation-list/aparte-conversation-list.d.ts +11 -0
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
- package/dist/components/launcher/aparte-launcher.d.ts +2 -0
- package/dist/components/launcher/aparte-launcher.d.ts.map +1 -1
- package/dist/components/sidebar/aparte-sidebar.d.ts +42 -5
- package/dist/components/sidebar/aparte-sidebar.d.ts.map +1 -1
- package/dist/custom-elements.json +2894 -2813
- package/dist/generated/element-attributes.d.ts +4 -2
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +83 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7548,7 +7548,10 @@ class AparteConversationList extends HTMLElement {
|
|
|
7548
7548
|
*/
|
|
7549
7549
|
_manage(event, run) {
|
|
7550
7550
|
if (!this.hasAttribute("manage") || event.defaultPrevented) return;
|
|
7551
|
-
const
|
|
7551
|
+
const target = this.getAttribute("target");
|
|
7552
|
+
const root = this.getRootNode();
|
|
7553
|
+
const chat = target ? root.getElementById?.(target) ?? this.ownerDocument.getElementById(target) : null;
|
|
7554
|
+
const manager = resolveConfig(chat ?? this).getConversationManager();
|
|
7552
7555
|
if (!manager) {
|
|
7553
7556
|
if (this._warnedNoManager) return;
|
|
7554
7557
|
this._warnedNoManager = true;
|
|
@@ -7749,9 +7752,10 @@ class AparteConversationList extends HTMLElement {
|
|
|
7749
7752
|
const select = target.closest("[data-select-id]");
|
|
7750
7753
|
if (select) {
|
|
7751
7754
|
this._closeMenu();
|
|
7755
|
+
const targetId = this.getAttribute("target");
|
|
7752
7756
|
this.dispatchEvent(new CustomEvent(
|
|
7753
7757
|
"aparte-conversation-select",
|
|
7754
|
-
{ detail: { id: select.dataset["selectId"] }, bubbles: true, composed: true }
|
|
7758
|
+
{ detail: { id: select.dataset["selectId"], ...targetId ? { targetId } : {} }, bubbles: true, composed: true }
|
|
7755
7759
|
));
|
|
7756
7760
|
}
|
|
7757
7761
|
};
|
|
@@ -9427,6 +9431,9 @@ class AparteSidebar extends HTMLElement {
|
|
|
9427
9431
|
_hostIntentSeeded = false;
|
|
9428
9432
|
/** Raised around `_applyDrawer`'s own writes, so the breakpoint is never read as a host's intent. */
|
|
9429
9433
|
_auto = false;
|
|
9434
|
+
/** The floating chat this sidebar is in, if any: its size decides the drawer, not the window's. */
|
|
9435
|
+
_launcher = null;
|
|
9436
|
+
_launcherWatch = null;
|
|
9430
9437
|
/**
|
|
9431
9438
|
* The element wrote `inert`/`aria-hidden` and may take them back. A host that inerts
|
|
9432
9439
|
* the sidebar behind its own modal wrote them itself, and `_syncHidden` runs on every
|
|
@@ -9445,7 +9452,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9445
9452
|
set collapsed(value) {
|
|
9446
9453
|
this.toggleAttribute("collapsed", presenceOn(value));
|
|
9447
9454
|
}
|
|
9448
|
-
/** True while the window is under the breakpoint
|
|
9455
|
+
/** True while the sidebar is a drawer: the window is under the breakpoint, or it is in a floating chat's card. */
|
|
9449
9456
|
get drawer() {
|
|
9450
9457
|
return this.hasAttribute("data-drawer");
|
|
9451
9458
|
}
|
|
@@ -9467,6 +9474,11 @@ class AparteSidebar extends HTMLElement {
|
|
|
9467
9474
|
document.addEventListener("keydown", this._onKeydown);
|
|
9468
9475
|
document.addEventListener("click", this._onDocumentClick);
|
|
9469
9476
|
window.addEventListener("aparte-config-change", this._onConfigChange);
|
|
9477
|
+
this._launcher = this.closest("aparte-launcher");
|
|
9478
|
+
if (this._launcher && typeof MutationObserver === "function") {
|
|
9479
|
+
this._launcherWatch = new MutationObserver(() => this._followLauncher());
|
|
9480
|
+
this._launcherWatch.observe(this._launcher, { attributes: true, attributeFilter: ["open", "maximized", "maximizable"] });
|
|
9481
|
+
}
|
|
9470
9482
|
this._watchBreakpoint();
|
|
9471
9483
|
this._syncHidden();
|
|
9472
9484
|
this._lastCollapsed = this.collapsed;
|
|
@@ -9483,15 +9495,55 @@ class AparteSidebar extends HTMLElement {
|
|
|
9483
9495
|
this._media?.removeEventListener("change", this._onMediaChange);
|
|
9484
9496
|
this._media = null;
|
|
9485
9497
|
const attr = (this.getAttribute("breakpoint") ?? "").trim();
|
|
9486
|
-
if (attr
|
|
9487
|
-
|
|
9498
|
+
if (attr !== "none" && typeof matchMedia === "function") {
|
|
9499
|
+
const query = attr ? `(max-width: ${attr})` : DRAWER_QUERY;
|
|
9500
|
+
this._media = matchMedia(query);
|
|
9501
|
+
this._media.addEventListener("change", this._onMediaChange);
|
|
9502
|
+
} else if (attr !== "none" && !this._launcher) {
|
|
9488
9503
|
return;
|
|
9489
9504
|
}
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9505
|
+
this._applyDrawer(this._wantsDrawer());
|
|
9506
|
+
}
|
|
9507
|
+
/**
|
|
9508
|
+
* A drawer under the window's breakpoint, and in the card of a floating chat whatever
|
|
9509
|
+
* the window: the card is narrow in the widest one. `breakpoint="none"` is the host's
|
|
9510
|
+
* word for a column at any width, and it holds in a card too.
|
|
9511
|
+
*/
|
|
9512
|
+
_wantsDrawer() {
|
|
9513
|
+
if ((this.getAttribute("breakpoint") ?? "").trim() === "none") return false;
|
|
9514
|
+
return (this._media?.matches ?? false) || this._inCard();
|
|
9515
|
+
}
|
|
9516
|
+
/**
|
|
9517
|
+
* In a floating chat that does not fill the window: its card, or the panel
|
|
9518
|
+
* `maximizable="panel"` runs along the window's edge, which is as narrow. Only as the
|
|
9519
|
+
* child of the card's shell, which is what holds the drawer there: anywhere else in a
|
|
9520
|
+
* card a drawer is fixed to the window, and one forced on a wide window would open over
|
|
9521
|
+
* the page the chat floats on.
|
|
9522
|
+
*/
|
|
9523
|
+
_inCard() {
|
|
9524
|
+
const launcher = this._launcher;
|
|
9525
|
+
if (!launcher || !this._cardShell()) return false;
|
|
9526
|
+
return !(launcher.hasAttribute("maximized") && launcher.getAttribute("maximizable") !== "panel");
|
|
9527
|
+
}
|
|
9528
|
+
/**
|
|
9529
|
+
* The floating chat opened, closed or changed size. Its size decides the drawer, and a
|
|
9530
|
+
* drawer does not outlive the chat it is in: left open under a closed chat it would still
|
|
9531
|
+
* answer Escape for the whole page, and stand over the chat when it opens again.
|
|
9532
|
+
*/
|
|
9533
|
+
_followLauncher() {
|
|
9534
|
+
this._applyDrawer(this._wantsDrawer());
|
|
9535
|
+
if (this.drawer && !this.collapsed && !this._launcher?.hasAttribute("open")) {
|
|
9536
|
+
this._opener = null;
|
|
9537
|
+
this.close();
|
|
9538
|
+
}
|
|
9539
|
+
}
|
|
9540
|
+
/**
|
|
9541
|
+
* The shell the scrim covers in a floating chat, when the sidebar is that shell's own
|
|
9542
|
+
* child: the stylesheet positions the drawer against it there (`sidebar.css`).
|
|
9543
|
+
*/
|
|
9544
|
+
_cardShell() {
|
|
9545
|
+
const shell = this._launcher ? this.parentElement : null;
|
|
9546
|
+
return shell?.classList.contains("aparte-app-shell") ? shell : null;
|
|
9495
9547
|
}
|
|
9496
9548
|
disconnectedCallback() {
|
|
9497
9549
|
this.removeEventListener("input", this._onInput);
|
|
@@ -9502,6 +9554,11 @@ class AparteSidebar extends HTMLElement {
|
|
|
9502
9554
|
window.removeEventListener("aparte-config-change", this._onConfigChange);
|
|
9503
9555
|
this._media?.removeEventListener("change", this._onMediaChange);
|
|
9504
9556
|
this._media = null;
|
|
9557
|
+
this._launcherWatch?.disconnect();
|
|
9558
|
+
this._launcherWatch = null;
|
|
9559
|
+
this._launcher = null;
|
|
9560
|
+
this._scrim?.remove();
|
|
9561
|
+
this._scrim = null;
|
|
9505
9562
|
this._ready = false;
|
|
9506
9563
|
}
|
|
9507
9564
|
attributeChangedCallback(name) {
|
|
@@ -9544,7 +9601,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9544
9601
|
else this.close();
|
|
9545
9602
|
}
|
|
9546
9603
|
// ─── Drawer ───────────────────────────────────────────────────────────
|
|
9547
|
-
_onMediaChange = (
|
|
9604
|
+
_onMediaChange = () => this._applyDrawer(this._wantsDrawer());
|
|
9548
9605
|
/**
|
|
9549
9606
|
* Entering the drawer state closes the sidebar: a narrow window that opens on an
|
|
9550
9607
|
* overlay covering the chat is the wrong first screen. Leaving it reopens, since
|
|
@@ -9552,6 +9609,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9552
9609
|
*/
|
|
9553
9610
|
_applyDrawer(drawer) {
|
|
9554
9611
|
const was = this.drawer;
|
|
9612
|
+
if (drawer !== was) this._opener = null;
|
|
9555
9613
|
this.toggleAttribute("data-drawer", drawer);
|
|
9556
9614
|
this._auto = true;
|
|
9557
9615
|
try {
|
|
@@ -9630,7 +9688,13 @@ class AparteSidebar extends HTMLElement {
|
|
|
9630
9688
|
this._scrim.className = "aparte-sidebar__scrim";
|
|
9631
9689
|
this._scrim.setAttribute("aria-hidden", "true");
|
|
9632
9690
|
this._scrim.addEventListener("click", () => this.close());
|
|
9633
|
-
this.
|
|
9691
|
+
const shell = this._cardShell();
|
|
9692
|
+
if (shell) {
|
|
9693
|
+
this._scrim.classList.add("aparte-sidebar__scrim--contained");
|
|
9694
|
+
shell.appendChild(this._scrim);
|
|
9695
|
+
} else {
|
|
9696
|
+
this.appendChild(this._scrim);
|
|
9697
|
+
}
|
|
9634
9698
|
} else if (!wanted && this._scrim) {
|
|
9635
9699
|
this._scrim.remove();
|
|
9636
9700
|
this._scrim = null;
|
|
@@ -9639,6 +9703,7 @@ class AparteSidebar extends HTMLElement {
|
|
|
9639
9703
|
_onKeydown = (e) => {
|
|
9640
9704
|
if (!this.drawer || this.collapsed) return;
|
|
9641
9705
|
if (e.key === "Escape") {
|
|
9706
|
+
if (e.defaultPrevented) return;
|
|
9642
9707
|
e.preventDefault();
|
|
9643
9708
|
this.close();
|
|
9644
9709
|
return;
|
|
@@ -9735,7 +9800,7 @@ function visibleFocusable(root) {
|
|
|
9735
9800
|
return Array.from(root.querySelectorAll(FOCUSABLE$1)).filter((el2) => !el2.closest("[hidden]") && el2.checkVisibility?.() !== false);
|
|
9736
9801
|
}
|
|
9737
9802
|
function nearestSidebar(control) {
|
|
9738
|
-
return control.closest("aparte-sidebar") ?? rootOf(control).querySelector("aparte-sidebar") ?? document.querySelector("aparte-sidebar");
|
|
9803
|
+
return control.closest("aparte-sidebar") ?? control.closest(".aparte-app-shell")?.querySelector("aparte-sidebar") ?? rootOf(control).querySelector("aparte-sidebar") ?? document.querySelector("aparte-sidebar");
|
|
9739
9804
|
}
|
|
9740
9805
|
deferHydrationOf(AparteSidebar);
|
|
9741
9806
|
if (!customElements.get("aparte-sidebar")) {
|
|
@@ -11109,10 +11174,14 @@ class AparteLauncher extends HTMLElement {
|
|
|
11109
11174
|
return true;
|
|
11110
11175
|
}
|
|
11111
11176
|
}
|
|
11177
|
+
/** A sidebar open as a drawer inside the card: Escape closes it before it closes the chat. */
|
|
11178
|
+
_drawerOpen() {
|
|
11179
|
+
return this.querySelector("aparte-sidebar[data-drawer]:not([collapsed])") !== null;
|
|
11180
|
+
}
|
|
11112
11181
|
_onKeydown = (e) => {
|
|
11113
11182
|
if (!this.open) return;
|
|
11114
11183
|
if (e.key === "Escape") {
|
|
11115
|
-
if (e.defaultPrevented || e.isComposing || e.keyCode === 229 || this._inModalDialog(e)) return;
|
|
11184
|
+
if (e.defaultPrevented || e.isComposing || e.keyCode === 229 || this._inModalDialog(e) || this._drawerOpen()) return;
|
|
11116
11185
|
e.preventDefault();
|
|
11117
11186
|
if (this.maximized && !this.sheet) this.maximized = false;
|
|
11118
11187
|
else this.close();
|