@artooi/ag-ui-web-component 0.49.0 → 0.50.1
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/CHANGELOG.md +175 -1
- package/README.md +25 -14
- package/dist/ag-ui-web-component.bundle.js +168 -125
- package/dist/ag-ui-web-component.bundle.js.map +3 -3
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/index.js +530 -110
- package/dist/index.js.map +2 -2
- package/dist/tools/chat_surface_tools.d.ts +8 -5
- package/dist/tools/chat_surface_tools.d.ts.map +1 -1
- package/dist/ui/placement/collapse_styles.d.ts.map +1 -1
- package/dist/ui/placement/panel_placement.d.ts +15 -1
- package/dist/ui/placement/panel_placement.d.ts.map +1 -1
- package/dist/ui/placement/resize_styles.d.ts.map +1 -1
- package/dist/ui/shell/frame_styles.d.ts.map +1 -1
- package/dist/ui/shell/token_styles.d.ts.map +1 -1
- package/dist/ui/themes/classic_tokens.d.ts.map +1 -1
- package/dist/ui/themes/ledger_styles.d.ts.map +1 -1
- package/dist/ui/themes/ledger_tokens.d.ts.map +1 -1
- package/dist/ui/themes/quiet_styles.d.ts.map +1 -1
- package/dist/ui/themes/soft_styles.d.ts.map +1 -1
- package/dist/ui/themes/soft_tokens.d.ts.map +1 -1
- package/dist/ui/transcript/transcript_styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/ag_ui_chat.ts +73 -7
- package/src/tools/chat_surface_tools.ts +8 -5
- package/src/ui/placement/collapse_styles.ts +8 -0
- package/src/ui/placement/panel_placement.ts +512 -99
- package/src/ui/placement/resize_styles.ts +9 -0
- package/src/ui/shell/frame_styles.ts +22 -2
- package/src/ui/shell/token_styles.ts +7 -6
- package/src/ui/themes/classic_tokens.ts +1 -0
- package/src/ui/themes/ledger_styles.ts +4 -3
- package/src/ui/themes/ledger_tokens.ts +1 -0
- package/src/ui/themes/quiet_styles.ts +2 -15
- package/src/ui/themes/soft_styles.ts +4 -3
- package/src/ui/themes/soft_tokens.ts +1 -0
- package/src/ui/transcript/transcript_styles.ts +14 -1
- package/src/version.ts +1 -1
|
@@ -21,12 +21,15 @@ export interface ChatSurfaceReport {
|
|
|
21
21
|
/** Whether the panel can be moved, or the placement owns its position. */
|
|
22
22
|
readonly movable: boolean;
|
|
23
23
|
/**
|
|
24
|
-
* Whether this page allows the panel to be moved at all
|
|
24
|
+
* Whether this page allows the panel to be moved at all: true for every
|
|
25
|
+
* placement unless the host set `data-launcher-drag="false"`. It is the
|
|
26
|
+
* page's setting alone and does not vary with the placement or `collapse-to`;
|
|
27
|
+
* whether this panel moves is {@link ChatSurfaceReport.movable}.
|
|
25
28
|
*
|
|
26
|
-
* Reported apart from
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* Reported apart from `movable` only because the two reasons a move is
|
|
30
|
+
* refused call for different sentences: a host that turned dragging off is
|
|
31
|
+
* not the placement owning the position, and telling the user the second
|
|
32
|
+
* when the first is true is a plain falsehood.
|
|
30
33
|
*/
|
|
31
34
|
readonly draggable: boolean;
|
|
32
35
|
/** Whether the panel currently covers the whole viewport. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat_surface_tools.d.ts","sourceRoot":"","sources":["../../src/tools/chat_surface_tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,kFAAkF;AAClF,eAAO,MAAM,YAAY,YAAI,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;AAE9F,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,oEAAoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;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EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;IACF;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAE/D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,IAAI,iBAAiB,CAAC;IACrC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;IAC/E,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACnF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,EAAE,CA4GzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapse_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/placement/collapse_styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"collapse_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/placement/collapse_styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,EAAE,MAmY7B,CAAC"}
|
|
@@ -80,7 +80,9 @@ export declare class PanelPlacement {
|
|
|
80
80
|
*
|
|
81
81
|
* Read from the stamp the drag helpers already set, rather than tracked
|
|
82
82
|
* separately: one source of truth, and it clears on `pointercancel` as well
|
|
83
|
-
* as `pointerup`, which is the end a touch gesture usually gets.
|
|
83
|
+
* as `pointerup`, which is the end a touch gesture usually gets. The one
|
|
84
|
+
* gesture that stamps nothing is an arrow key on a grip, which applies a box
|
|
85
|
+
* per key and states it only when the key comes up, hence #resizing.
|
|
84
86
|
*/
|
|
85
87
|
dragging(): boolean;
|
|
86
88
|
/** The report behind `AgUiChat.describeSurface`, whose doc is the contract. */
|
|
@@ -129,8 +131,20 @@ export declare class PanelPlacement {
|
|
|
129
131
|
* whenever the window resizes, and before an expand. The viewport that
|
|
130
132
|
* stored a position may since have shrunk, and a launcher past the edge is
|
|
131
133
|
* unreachable -- it is the only way back to a collapsed conversation.
|
|
134
|
+
*
|
|
135
|
+
* The one gate on whether a stored position is this element's to honour: the
|
|
136
|
+
* gestures check their own before they ever reach the placing below.
|
|
132
137
|
*/
|
|
133
138
|
restoreLauncherPosition(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Re-apply it for a change in the panel's own layout, which needs no window or
|
|
141
|
+
* reopen to happen: a line typed in the composer is one. A position waiting to
|
|
142
|
+
* be handed back under data-launcher-drag="false" waits on, because a panel that leaves for the
|
|
143
|
+
* host's corner as the reader starts typing is a jump with no cause they can see.
|
|
144
|
+
* It waits no longer than the panel stays on the screen: a host's size can stand
|
|
145
|
+
* it off an edge, where its header is out of reach until something else happens.
|
|
146
|
+
*/
|
|
147
|
+
settleLauncherPosition(): void;
|
|
134
148
|
/**
|
|
135
149
|
* Give the position back to the host when the new placement owns it, the way
|
|
136
150
|
* releaseOwnedAxes gives back a size. Without this a dragged inset survives
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel_placement.d.ts","sourceRoot":"","sources":["../../../src/ui/placement/panel_placement.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,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,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"resize_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/placement/resize_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,EAAE,MAiM3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/shell/frame_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"frame_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/shell/frame_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,EAAE,MAyI1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/shell/token_styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"token_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/shell/token_styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,EAAE,MA6c1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classic_tokens.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/classic_tokens.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"classic_tokens.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/classic_tokens.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,EAAE,MAgD5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/ledger_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"ledger_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/ledger_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,EAAE,MAuK3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger_tokens.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/ledger_tokens.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"ledger_tokens.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/ledger_tokens.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,EAAE,MA+B3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quiet_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/quiet_styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"quiet_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/quiet_styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,EAAE,MAiH1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/soft_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"soft_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/soft_styles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,EAAE,MAmJzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft_tokens.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/soft_tokens.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"soft_tokens.d.ts","sourceRoot":"","sources":["../../../src/ui/themes/soft_tokens.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,EAAE,MA2BzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/transcript/transcript_styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"transcript_styles.d.ts","sourceRoot":"","sources":["../../../src/ui/transcript/transcript_styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,EAAE,MAsJ/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artooi/ag-ui-web-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.1",
|
|
4
4
|
"description": "Framework-free <ag-ui-chat> Web Component over the AG-UI protocol. Drop-in chat sidebar with a pluggable client-side tool registry, DOM driver primitives, animations, and destructive-action confirmation modal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/src/core/ag_ui_chat.ts
CHANGED
|
@@ -633,6 +633,24 @@ export class AgUiChat extends HTMLElement {
|
|
|
633
633
|
* a field so `removeEventListener` on disconnect gets the same reference.
|
|
634
634
|
*/
|
|
635
635
|
readonly #onViewportResize = (): void => {
|
|
636
|
+
if (this.#readyToPlace()) {
|
|
637
|
+
this.#placement.restoreLauncherPosition();
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* The same for a change only the panel's own layout shows: a host's size, a
|
|
643
|
+
* viewport inset token, a line typed in the composer. Not a moment to hand a
|
|
644
|
+
* position back, so a panel under data-launcher-drag="false" stays put.
|
|
645
|
+
*/
|
|
646
|
+
readonly #onLayoutChange = (): void => {
|
|
647
|
+
if (this.#readyToPlace()) {
|
|
648
|
+
this.#placement.settleLauncherPosition();
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
/** Bring the viewport's readings up to date, and say whether placing may follow. */
|
|
653
|
+
#readyToPlace(): boolean {
|
|
636
654
|
this.#placement.publishVisualViewport();
|
|
637
655
|
this.#syncDock();
|
|
638
656
|
// Not while a gesture owns the position. Restoring re-applies the *stored*
|
|
@@ -647,11 +665,28 @@ export class AgUiChat extends HTMLElement {
|
|
|
647
665
|
// sent me looking -- that was an inset measured from the wrong box -- so it
|
|
648
666
|
// is a guard against a fight that had not been observed rather than a fix
|
|
649
667
|
// for one that had.
|
|
650
|
-
|
|
651
|
-
|
|
668
|
+
//
|
|
669
|
+
// Nor while this element has no box, which is what hiding it reports to the
|
|
670
|
+
// transcript's observer: placing measures a rect of nothing and writes an inset
|
|
671
|
+
// from it. Showing it reports again, so nothing waits on this.
|
|
672
|
+
return !this.#placement.dragging() && this.#hasBox();
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Whether this element generates a box at all. Hidden on itself or on any ancestor
|
|
677
|
+
* it does not; a host collapsed to its launcher does, whatever its size, and that
|
|
678
|
+
* launcher still has to be placed, which is why this is not a test of the size.
|
|
679
|
+
*/
|
|
680
|
+
#hasBox(): boolean {
|
|
681
|
+
return this.getClientRects().length > 0;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** Restore for a moment that is not a viewport's, which showing this reports anyway. */
|
|
685
|
+
#restoreIfBoxed(): void {
|
|
686
|
+
if (this.#hasBox()) {
|
|
687
|
+
this.#placement.restoreLauncherPosition();
|
|
652
688
|
}
|
|
653
|
-
|
|
654
|
-
};
|
|
689
|
+
}
|
|
655
690
|
|
|
656
691
|
/** Mic button mount point (input row); the control mounts on connect when enabled. */
|
|
657
692
|
readonly #voiceSlot: HTMLSpanElement;
|
|
@@ -1552,7 +1587,7 @@ export class AgUiChat extends HTMLElement {
|
|
|
1552
1587
|
requestAnimationFrame(() => {
|
|
1553
1588
|
// Before the anchor, which the placement stamps itself once a dragged
|
|
1554
1589
|
// position exists.
|
|
1555
|
-
this.#
|
|
1590
|
+
this.#restoreIfBoxed();
|
|
1556
1591
|
this.#placement.syncResizeAnchor();
|
|
1557
1592
|
});
|
|
1558
1593
|
// Resolve the string table before rendering any chrome (defaults are the
|
|
@@ -1586,6 +1621,25 @@ export class AgUiChat extends HTMLElement {
|
|
|
1586
1621
|
const dockObserver = new ResizeObserver(() => this.#syncDock());
|
|
1587
1622
|
dockObserver.observe(this.#dockBar);
|
|
1588
1623
|
this.#connection.signal.addEventListener("abort", () => dockObserver.disconnect());
|
|
1624
|
+
// A host's own size arrives with no event: a token written or a class changed
|
|
1625
|
+
// moves nothing here until the next window resize or reopen, and a panel
|
|
1626
|
+
// re-placed under a size that has since gone stays held short of its spot. The
|
|
1627
|
+
// transcript is watched rather than this element, whose box it follows, because
|
|
1628
|
+
// a page publishing a token from an observer of its own, as the README's recipe
|
|
1629
|
+
// does, changes this box after that observer has run, and the browser reports
|
|
1630
|
+
// the answer to a target no deeper than that one as a loop on the window. One
|
|
1631
|
+
// of its own already watches the transcript, so this adds no report of its own.
|
|
1632
|
+
const layoutObserver = new ResizeObserver(this.#onLayoutChange);
|
|
1633
|
+
layoutObserver.observe(this.#messages);
|
|
1634
|
+
this.#connection.signal.addEventListener("abort", () => layoutObserver.disconnect());
|
|
1635
|
+
// The viewport insets arrive the same way, and a page's observer writes them after
|
|
1636
|
+
// the window's resize event, so that restore reads the bar as it was. The probe
|
|
1637
|
+
// carries them, and an observer on it would be a report on the window for the same
|
|
1638
|
+
// reason, so it takes them as a transition instead: heard the next frame, whichever
|
|
1639
|
+
// element wrote them and however late.
|
|
1640
|
+
this.#placement.probe.addEventListener("transitionrun", this.#onLayoutChange, {
|
|
1641
|
+
signal: this.#connection.signal,
|
|
1642
|
+
});
|
|
1589
1643
|
this.#syncDock();
|
|
1590
1644
|
// Under collapse-to="none" the host draws the collapsed state itself, so
|
|
1591
1645
|
// it has to learn the state the element mounted in -- restored from
|
|
@@ -1890,7 +1944,7 @@ export class AgUiChat extends HTMLElement {
|
|
|
1890
1944
|
// Re-decide which way to open before opening: the viewport may have
|
|
1891
1945
|
// changed since the launcher was dropped, and this corner is what the
|
|
1892
1946
|
// panel grows from.
|
|
1893
|
-
this.#
|
|
1947
|
+
this.#restoreIfBoxed();
|
|
1894
1948
|
}
|
|
1895
1949
|
if (collapsed) {
|
|
1896
1950
|
this.setAttribute("collapsed", "");
|
|
@@ -2002,7 +2056,12 @@ export class AgUiChat extends HTMLElement {
|
|
|
2002
2056
|
if (!this.isConnected) {
|
|
2003
2057
|
return;
|
|
2004
2058
|
}
|
|
2005
|
-
|
|
2059
|
+
// With no box there is no bar drawn, which the host still hears of, and nothing to
|
|
2060
|
+
// measure: syncing would place a dragged panel from a rect of nothing. Showing this
|
|
2061
|
+
// element resizes the bar or the transcript, and their observers sync it then.
|
|
2062
|
+
const height = this.#hasBox()
|
|
2063
|
+
? this.#placement.syncDock(this.#dockBar, this.#resolveAnchor())
|
|
2064
|
+
: 0;
|
|
2006
2065
|
if (height === this.#barHeight) {
|
|
2007
2066
|
return;
|
|
2008
2067
|
}
|
|
@@ -2795,6 +2854,13 @@ export class AgUiChat extends HTMLElement {
|
|
|
2795
2854
|
const probe = this.#placement.probe;
|
|
2796
2855
|
probe.className = "viewport-probe";
|
|
2797
2856
|
probe.setAttribute("aria-hidden", "true");
|
|
2857
|
+
// A transition, so a token changing is an event. On the corners of a box with no
|
|
2858
|
+
// size, which draw nothing: a margin would push it out by the token again, and that
|
|
2859
|
+
// is scroll on a page or a card holding the chat. Not on the padding, which the
|
|
2860
|
+
// viewport is read from and has to stay instant.
|
|
2861
|
+
probe.style.borderRadius =
|
|
2862
|
+
"var(--_viewport-inset-top) var(--_viewport-inset-right) var(--_viewport-inset-bottom) var(--_viewport-inset-left)";
|
|
2863
|
+
probe.style.transition = "border-radius 1ms";
|
|
2798
2864
|
this.#root.replaceChildren(probe, this.#announcer.region, this.#chat, this.#dockBar);
|
|
2799
2865
|
}
|
|
2800
2866
|
|
|
@@ -25,12 +25,15 @@ export interface ChatSurfaceReport {
|
|
|
25
25
|
/** Whether the panel can be moved, or the placement owns its position. */
|
|
26
26
|
readonly movable: boolean;
|
|
27
27
|
/**
|
|
28
|
-
* Whether this page allows the panel to be moved at all
|
|
28
|
+
* Whether this page allows the panel to be moved at all: true for every
|
|
29
|
+
* placement unless the host set `data-launcher-drag="false"`. It is the
|
|
30
|
+
* page's setting alone and does not vary with the placement or `collapse-to`;
|
|
31
|
+
* whether this panel moves is {@link ChatSurfaceReport.movable}.
|
|
29
32
|
*
|
|
30
|
-
* Reported apart from
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
33
|
+
* Reported apart from `movable` only because the two reasons a move is
|
|
34
|
+
* refused call for different sentences: a host that turned dragging off is
|
|
35
|
+
* not the placement owning the position, and telling the user the second
|
|
36
|
+
* when the first is true is a plain falsehood.
|
|
34
37
|
*/
|
|
35
38
|
readonly draggable: boolean;
|
|
36
39
|
/** Whether the panel currently covers the whole viewport. */
|
|
@@ -300,6 +300,14 @@ export const COLLAPSE_STYLES: string = `
|
|
|
300
300
|
display: none;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/* A panel a host sized to the whole window stands on the strip, whose fixed box would
|
|
304
|
+
draw over the composer's foot. So it goes as it does on a phone, by display, so the
|
|
305
|
+
bar measures 0 and the host's padding goes with it, and the header's minimise
|
|
306
|
+
control is the way back. Collapsed, the strip is the way back, so it stays. */
|
|
307
|
+
:host([data-collapsed-to="bar"][data-fills-window]:not([collapsed])) .dock-bar {
|
|
308
|
+
display: none;
|
|
309
|
+
}
|
|
310
|
+
|
|
303
311
|
/* History from the bar: the panel's own drawer, moved beside the bar while
|
|
304
312
|
the panel is away, drawn as a popover standing on the bar's end. There is
|
|
305
313
|
no backdrop; a press outside the bar closes it, as Escape does.
|