@copilotkit/web-components 1.62.2-canary.1783457132 → 1.62.3
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 +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.umd.js +779 -277
- package/dist/index.umd.js.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.cjs +422 -119
- package/dist/threads-drawer/copilotkit-threads-drawer.cjs.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.d.cts +127 -13
- package/dist/threads-drawer/copilotkit-threads-drawer.d.cts.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.d.mts +127 -13
- package/dist/threads-drawer/copilotkit-threads-drawer.d.mts.map +1 -1
- package/dist/threads-drawer/copilotkit-threads-drawer.mjs +422 -119
- package/dist/threads-drawer/copilotkit-threads-drawer.mjs.map +1 -1
- package/dist/threads-drawer/index.d.cts +2 -2
- package/dist/threads-drawer/index.d.mts +2 -2
- package/dist/threads-drawer/styles.cjs +357 -156
- package/dist/threads-drawer/styles.cjs.map +1 -1
- package/dist/threads-drawer/styles.d.cts.map +1 -1
- package/dist/threads-drawer/styles.d.mts.map +1 -1
- package/dist/threads-drawer/styles.mjs +357 -156
- package/dist/threads-drawer/styles.mjs.map +1 -1
- package/dist/threads-drawer/types.d.cts +6 -1
- package/dist/threads-drawer/types.d.cts.map +1 -1
- package/dist/threads-drawer/types.d.mts +6 -1
- package/dist/threads-drawer/types.d.mts.map +1 -1
- package/package.json +1 -1
|
@@ -89,9 +89,9 @@ const iconDelete = lit.html`
|
|
|
89
89
|
<line x1="14" x2="14" y1="11" y2="17" />
|
|
90
90
|
</svg>
|
|
91
91
|
`;
|
|
92
|
-
const
|
|
92
|
+
const iconSidebar = lit.html`
|
|
93
93
|
<svg
|
|
94
|
-
class="
|
|
94
|
+
class="icon"
|
|
95
95
|
viewBox="0 0 24 24"
|
|
96
96
|
fill="none"
|
|
97
97
|
stroke="currentColor"
|
|
@@ -102,7 +102,51 @@ const iconLauncher = lit.html`
|
|
|
102
102
|
>
|
|
103
103
|
<rect width="18" height="18" x="3" y="3" rx="2" />
|
|
104
104
|
<path d="M9 3v18" />
|
|
105
|
-
|
|
105
|
+
</svg>
|
|
106
|
+
`;
|
|
107
|
+
/**
|
|
108
|
+
* Header / control icons for the redesigned drawer chrome (ENT-1051). Inlined
|
|
109
|
+
* lucide glyphs (`square-plus`, `filter`, `ellipsis-vertical`) drawn with
|
|
110
|
+
* `currentColor` so they inherit the button's themed color — the element cannot
|
|
111
|
+
* depend on a React icon library.
|
|
112
|
+
*/
|
|
113
|
+
const iconPlusSquare = lit.html`
|
|
114
|
+
<svg
|
|
115
|
+
class="icon"
|
|
116
|
+
viewBox="0 0 24 24"
|
|
117
|
+
fill="none"
|
|
118
|
+
stroke="currentColor"
|
|
119
|
+
stroke-width="2"
|
|
120
|
+
stroke-linecap="round"
|
|
121
|
+
stroke-linejoin="round"
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
>
|
|
124
|
+
<rect width="18" height="18" x="3" y="3" rx="2" />
|
|
125
|
+
<path d="M8 12h8" />
|
|
126
|
+
<path d="M12 8v8" />
|
|
127
|
+
</svg>
|
|
128
|
+
`;
|
|
129
|
+
const iconFunnel = lit.html`
|
|
130
|
+
<svg
|
|
131
|
+
class="icon"
|
|
132
|
+
viewBox="0 0 24 24"
|
|
133
|
+
fill="none"
|
|
134
|
+
stroke="currentColor"
|
|
135
|
+
stroke-width="2"
|
|
136
|
+
stroke-linecap="round"
|
|
137
|
+
stroke-linejoin="round"
|
|
138
|
+
aria-hidden="true"
|
|
139
|
+
>
|
|
140
|
+
<line x1="3" y1="5" x2="21" y2="5" />
|
|
141
|
+
<line x1="6" y1="12" x2="18" y2="12" />
|
|
142
|
+
<line x1="10" y1="19" x2="14" y2="19" />
|
|
143
|
+
</svg>
|
|
144
|
+
`;
|
|
145
|
+
const iconKebab = lit.html`
|
|
146
|
+
<svg class="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
147
|
+
<circle cx="12" cy="5" r="1.6" />
|
|
148
|
+
<circle cx="12" cy="12" r="1.6" />
|
|
149
|
+
<circle cx="12" cy="19" r="1.6" />
|
|
106
150
|
</svg>
|
|
107
151
|
`;
|
|
108
152
|
/**
|
|
@@ -111,7 +155,7 @@ const iconLauncher = lit.html`
|
|
|
111
155
|
*
|
|
112
156
|
* Pure VIEW: domain data (threads/loading/error/etc.) comes IN as properties and
|
|
113
157
|
* user intent goes OUT as bubbling+composed DOM `CustomEvent`s. The element owns
|
|
114
|
-
* VIEW state (open
|
|
158
|
+
* VIEW state (open, Active/All filter, confirm-delete dialog, per-row
|
|
115
159
|
* animations) while the consumer owns DOMAIN state. `open` is additionally
|
|
116
160
|
* externally controllable via the `open` property + `open-change` event so a
|
|
117
161
|
* host can coordinate mobile open/close.
|
|
@@ -122,6 +166,7 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
122
166
|
constructor(..._args) {
|
|
123
167
|
super(..._args);
|
|
124
168
|
this.label = "Threads";
|
|
169
|
+
this.recentLabel = "Recent Conversations";
|
|
125
170
|
this.threads = [];
|
|
126
171
|
this.loading = false;
|
|
127
172
|
this.error = null;
|
|
@@ -131,21 +176,34 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
131
176
|
this.hasMore = false;
|
|
132
177
|
this.fetchingMore = false;
|
|
133
178
|
this.fetchMoreError = null;
|
|
134
|
-
this.open =
|
|
179
|
+
this.open = false;
|
|
135
180
|
this.collapsed = false;
|
|
181
|
+
this.collapsible = true;
|
|
136
182
|
this._filter = "active";
|
|
137
183
|
this._confirmingDeleteId = null;
|
|
138
184
|
this._viewportIsMobile = false;
|
|
185
|
+
this._hasHeader = false;
|
|
139
186
|
this._hasMemories = false;
|
|
140
187
|
this._hasFooter = false;
|
|
188
|
+
this._filterOpen = false;
|
|
189
|
+
this._openMenuId = null;
|
|
141
190
|
this._mediaQuery = null;
|
|
142
191
|
this._onMediaChange = (event) => {
|
|
143
192
|
this._viewportIsMobile = event.matches;
|
|
144
193
|
};
|
|
145
194
|
this._onKeyDown = (event) => {
|
|
146
195
|
if (event.key === "Escape") {
|
|
196
|
+
if (this._openMenuId !== null) {
|
|
197
|
+
this._openMenuId = null;
|
|
198
|
+
event.stopPropagation();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (this._filterOpen) {
|
|
202
|
+
this._filterOpen = false;
|
|
203
|
+
event.stopPropagation();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
147
206
|
if (this._confirmingDeleteId !== null) {
|
|
148
|
-
this._confirmingDeleteId = null;
|
|
149
207
|
event.stopPropagation();
|
|
150
208
|
return;
|
|
151
209
|
}
|
|
@@ -157,8 +215,23 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
157
215
|
}
|
|
158
216
|
if (event.key === "Tab") this._trapTab(event);
|
|
159
217
|
};
|
|
218
|
+
this._onDocumentPointerDown = (event) => {
|
|
219
|
+
if (!this._filterOpen && this._openMenuId === null) return;
|
|
220
|
+
const path = event.composedPath();
|
|
221
|
+
if (this._filterOpen) {
|
|
222
|
+
const popover = this.renderRoot.querySelector("[part=\"filters\"]");
|
|
223
|
+
const trigger = this.renderRoot.querySelector("[part=\"filter-toggle\"]");
|
|
224
|
+
if (!(popover && path.includes(popover) || trigger && path.includes(trigger))) this._filterOpen = false;
|
|
225
|
+
}
|
|
226
|
+
if (this._openMenuId !== null) {
|
|
227
|
+
const popover = this.renderRoot.querySelector("[part=\"row-menu-popover\"]");
|
|
228
|
+
const trigger = this.renderRoot.querySelector(".row.menu-open [part=\"row-menu\"]");
|
|
229
|
+
if (!(popover && path.includes(popover) || trigger && path.includes(trigger))) this._openMenuId = null;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
160
232
|
this._seenNamed = /* @__PURE__ */ new Set();
|
|
161
233
|
this._justRevealed = /* @__PURE__ */ new Set();
|
|
234
|
+
this._repositionConfirm = () => this._positionConfirmDialog();
|
|
162
235
|
this._scrollLocked = false;
|
|
163
236
|
this._prevBodyOverflow = "";
|
|
164
237
|
this._trapTab = (event) => {
|
|
@@ -207,6 +280,11 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
207
280
|
type: String
|
|
208
281
|
},
|
|
209
282
|
label: { type: String },
|
|
283
|
+
recentLabel: {
|
|
284
|
+
attribute: "recent-label",
|
|
285
|
+
type: String
|
|
286
|
+
},
|
|
287
|
+
collapsible: { type: Boolean },
|
|
210
288
|
open: {
|
|
211
289
|
type: Boolean,
|
|
212
290
|
reflect: true
|
|
@@ -218,8 +296,11 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
218
296
|
_filter: { state: true },
|
|
219
297
|
_confirmingDeleteId: { state: true },
|
|
220
298
|
_viewportIsMobile: { state: true },
|
|
299
|
+
_hasHeader: { state: true },
|
|
221
300
|
_hasMemories: { state: true },
|
|
222
|
-
_hasFooter: { state: true }
|
|
301
|
+
_hasFooter: { state: true },
|
|
302
|
+
_filterOpen: { state: true },
|
|
303
|
+
_openMenuId: { state: true }
|
|
223
304
|
};
|
|
224
305
|
}
|
|
225
306
|
connectedCallback() {
|
|
@@ -230,11 +311,18 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
230
311
|
this._mediaQuery.addEventListener("change", this._onMediaChange);
|
|
231
312
|
}
|
|
232
313
|
this.addEventListener("keydown", this._onKeyDown);
|
|
314
|
+
if (typeof document !== "undefined") document.addEventListener("pointerdown", this._onDocumentPointerDown);
|
|
233
315
|
}
|
|
234
316
|
disconnectedCallback() {
|
|
235
317
|
super.disconnectedCallback();
|
|
236
318
|
this._mediaQuery?.removeEventListener("change", this._onMediaChange);
|
|
237
319
|
this.removeEventListener("keydown", this._onKeyDown);
|
|
320
|
+
if (typeof document !== "undefined") document.removeEventListener("pointerdown", this._onDocumentPointerDown);
|
|
321
|
+
if (typeof window !== "undefined") {
|
|
322
|
+
window.removeEventListener("scroll", this._repositionConfirm, true);
|
|
323
|
+
window.removeEventListener("resize", this._repositionConfirm);
|
|
324
|
+
}
|
|
325
|
+
if (typeof document !== "undefined") document.documentElement.style.removeProperty("--cpk-drawer-reserved-width");
|
|
238
326
|
this._releaseScrollLock();
|
|
239
327
|
}
|
|
240
328
|
willUpdate(changed) {
|
|
@@ -252,6 +340,9 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
252
340
|
if (this._confirmingDeleteId !== null) {
|
|
253
341
|
if (!this._visibleThreads().some((t) => t.id === this._confirmingDeleteId)) this._confirmingDeleteId = null;
|
|
254
342
|
}
|
|
343
|
+
if (this._openMenuId !== null) {
|
|
344
|
+
if (!this._visibleThreads().some((t) => t.id === this._openMenuId)) this._openMenuId = null;
|
|
345
|
+
}
|
|
255
346
|
}
|
|
256
347
|
}
|
|
257
348
|
updated(changed) {
|
|
@@ -259,22 +350,22 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
259
350
|
this._applyScrollLock();
|
|
260
351
|
this._focusFirstFocusable();
|
|
261
352
|
} else this._releaseScrollLock();
|
|
353
|
+
if (changed.has("collapsed") || changed.has("collapsible") || changed.has("_viewportIsMobile")) this._syncReservedWidth();
|
|
354
|
+
const dialog = this.renderRoot.querySelector("dialog");
|
|
355
|
+
if (dialog) {
|
|
356
|
+
const id = this._confirmingDeleteId;
|
|
357
|
+
if (id !== null && !dialog.open) {
|
|
358
|
+
typeof dialog.showModal === "function" ? dialog.showModal() : dialog.setAttribute("open", "");
|
|
359
|
+
this._positionConfirmDialog();
|
|
360
|
+
window.addEventListener("scroll", this._repositionConfirm, true);
|
|
361
|
+
window.addEventListener("resize", this._repositionConfirm);
|
|
362
|
+
} else if (id === null && dialog.open) {
|
|
363
|
+
typeof dialog.close === "function" ? dialog.close() : dialog.removeAttribute("open");
|
|
364
|
+
window.removeEventListener("scroll", this._repositionConfirm, true);
|
|
365
|
+
window.removeEventListener("resize", this._repositionConfirm);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
262
368
|
if (this._justRevealed.size > 0) this._justRevealed = /* @__PURE__ */ new Set();
|
|
263
|
-
this._syncNameClipping();
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Marks each row whose name text is truncated with `name-clipped`, so the CSS
|
|
267
|
-
* shows the name tooltip ONLY when the full name isn't already visible (an
|
|
268
|
-
* always-on bubble over every row on hover would be noise). Measured after
|
|
269
|
-
* render because truncation depends on the laid-out width.
|
|
270
|
-
*/
|
|
271
|
-
_syncNameClipping() {
|
|
272
|
-
this.renderRoot.querySelectorAll(".row-name").forEach((name) => {
|
|
273
|
-
const text = name.querySelector(".row-name-text");
|
|
274
|
-
const clipped = !!text && text.scrollWidth > text.clientWidth;
|
|
275
|
-
name.classList.toggle("name-clipped", clipped);
|
|
276
|
-
name.closest(".row")?.classList.toggle("name-clipped", clipped);
|
|
277
|
-
});
|
|
278
369
|
}
|
|
279
370
|
_isMobileModalOpen() {
|
|
280
371
|
return this._viewportIsMobile && this.open;
|
|
@@ -284,6 +375,63 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
284
375
|
this.open = next;
|
|
285
376
|
this._emit("open-change", { open: next });
|
|
286
377
|
}
|
|
378
|
+
_setCollapsed(next) {
|
|
379
|
+
if (this.collapsed === next) return;
|
|
380
|
+
this.collapsed = next;
|
|
381
|
+
this._emit("collapse-change", { collapsed: next });
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Signal the drawer's reserved layout width to the host so a desktop collapse
|
|
385
|
+
* reclaims the column instead of leaving an empty gap. On desktop-collapse we
|
|
386
|
+
* set `--cpk-drawer-reserved-width: 0px` on the document root; a host whose
|
|
387
|
+
* grid reads `grid-template-columns: var(--cpk-drawer-reserved-width, 320px) …`
|
|
388
|
+
* inherits it and collapses the track (with its own transition). Expanded/mobile
|
|
389
|
+
* clears the override so the host's fallback width applies — which also means
|
|
390
|
+
* the default (expanded) render never sets it, so there is no hydration flicker.
|
|
391
|
+
*
|
|
392
|
+
* It is set on `document.documentElement` (not `parentElement`) BECAUSE the
|
|
393
|
+
* element is nested inside a framework wrapper host, so its parent is the
|
|
394
|
+
* wrapper — not the grid container, which is an ancestor a child's custom
|
|
395
|
+
* property can't reach. `:root` inheritance reaches the grid regardless of
|
|
396
|
+
* wrapper nesting. Best-effort + namespaced, single-drawer-per-document; a host
|
|
397
|
+
* with multiple drawers or a custom layout should instead react to the
|
|
398
|
+
* `collapse-change` event.
|
|
399
|
+
*/
|
|
400
|
+
_syncReservedWidth() {
|
|
401
|
+
if (typeof document === "undefined") return;
|
|
402
|
+
const desktopCollapsed = this.collapsible && this.collapsed && !this._viewportIsMobile;
|
|
403
|
+
const root = document.documentElement;
|
|
404
|
+
if (desktopCollapsed) root.style.setProperty("--cpk-drawer-reserved-width", "0px");
|
|
405
|
+
else root.style.removeProperty("--cpk-drawer-reserved-width");
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Center the confirm-delete <dialog> over the drawer PANEL's on-screen box
|
|
409
|
+
* (not the viewport). The dialog stays a top-layer `showModal()` element so it
|
|
410
|
+
* is never clipped, but we drive its center via `--confirm-cx/cy` measured
|
|
411
|
+
* from the visible `.root` rect — so it reads as "inside the drawer" per the
|
|
412
|
+
* ENT-1051 design while keeping the top-layer robustness. Falls back to
|
|
413
|
+
* viewport-center (the CSS default) when the panel isn't measurable
|
|
414
|
+
* (SSR/jsdom).
|
|
415
|
+
*/
|
|
416
|
+
_positionConfirmDialog() {
|
|
417
|
+
const dialog = this.renderRoot.querySelector("dialog");
|
|
418
|
+
const root = this.renderRoot.querySelector(".root");
|
|
419
|
+
if (!dialog) return;
|
|
420
|
+
const rect = root?.getBoundingClientRect();
|
|
421
|
+
if (!rect || rect.width === 0 && rect.height === 0) {
|
|
422
|
+
dialog.style.removeProperty("--confirm-cx");
|
|
423
|
+
dialog.style.removeProperty("--confirm-cy");
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const vw = window.innerWidth;
|
|
427
|
+
const vh = window.innerHeight;
|
|
428
|
+
const visLeft = Math.max(rect.left, 0);
|
|
429
|
+
const visRight = Math.min(rect.right, vw);
|
|
430
|
+
const visTop = Math.max(rect.top, 0);
|
|
431
|
+
const visBottom = Math.min(rect.bottom, vh);
|
|
432
|
+
dialog.style.setProperty("--confirm-cx", `${(visLeft + visRight) / 2}px`);
|
|
433
|
+
dialog.style.setProperty("--confirm-cy", `${(visTop + visBottom) / 2}px`);
|
|
434
|
+
}
|
|
287
435
|
_setFilter(next) {
|
|
288
436
|
if (this._filter === next) return;
|
|
289
437
|
this._filter = next;
|
|
@@ -362,22 +510,17 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
362
510
|
});
|
|
363
511
|
}
|
|
364
512
|
render() {
|
|
513
|
+
const desktopCollapsed = this.collapsible && this.collapsed && !this._viewportIsMobile;
|
|
514
|
+
const mobileClosed = this._viewportIsMobile && !this.open;
|
|
515
|
+
const showCluster = desktopCollapsed || mobileClosed;
|
|
365
516
|
const rootClasses = {
|
|
366
517
|
root: true,
|
|
367
|
-
collapsed: this.collapsed && !this._viewportIsMobile,
|
|
368
518
|
mobile: this._viewportIsMobile,
|
|
369
519
|
open: this.open,
|
|
370
|
-
|
|
520
|
+
collapsed: desktopCollapsed
|
|
371
521
|
};
|
|
372
522
|
return lit.html`
|
|
373
|
-
${
|
|
374
|
-
class="launcher"
|
|
375
|
-
part="launcher"
|
|
376
|
-
aria-label="Open threads"
|
|
377
|
-
@click=${() => this._setOpen(true)}
|
|
378
|
-
>
|
|
379
|
-
<slot name="launcher-icon">${iconLauncher}</slot>
|
|
380
|
-
</button>` : lit.nothing}
|
|
523
|
+
${showCluster ? this._renderCluster() : lit.nothing}
|
|
381
524
|
${this._isMobileModalOpen() ? lit.html`<button
|
|
382
525
|
class="backdrop"
|
|
383
526
|
part="backdrop"
|
|
@@ -389,46 +532,153 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
389
532
|
part="root"
|
|
390
533
|
role=${this._isMobileModalOpen() ? "dialog" : "region"}
|
|
391
534
|
aria-modal=${this._isMobileModalOpen() ? "true" : lit.nothing}
|
|
535
|
+
aria-hidden=${desktopCollapsed ? "true" : lit.nothing}
|
|
392
536
|
aria-label=${this.label}
|
|
393
537
|
>
|
|
394
|
-
${
|
|
395
|
-
|
|
538
|
+
${desktopCollapsed ? lit.nothing : lit.html`${this._renderHeader()} ${this._renderBody()}
|
|
539
|
+
${this._renderMemories()} ${this._renderFooter()}
|
|
540
|
+
${this._renderConfirmDialog()}`}
|
|
396
541
|
</div>
|
|
397
542
|
`;
|
|
398
543
|
}
|
|
399
|
-
|
|
544
|
+
/**
|
|
545
|
+
* Floating launcher cluster from the Figma "closed" mockup: a sidebar-glyph
|
|
546
|
+
* toggle + a "New Conversation" (+) icon button. Shown in TWO states — the
|
|
547
|
+
* mobile closed state (toggle opens the off-canvas modal) and the desktop
|
|
548
|
+
* collapsed state (toggle expands the sidebar). The primary toggle keeps
|
|
549
|
+
* `part="launcher"` for mobile-launcher theme compat; the new-thread button is
|
|
550
|
+
* suppressed in the locked/unlicensed view, mirroring the New Conversation row.
|
|
551
|
+
*/
|
|
552
|
+
_renderCluster() {
|
|
553
|
+
const onToggle = this._viewportIsMobile ? () => this._setOpen(true) : () => this._setCollapsed(false);
|
|
400
554
|
return lit.html`
|
|
401
|
-
<div class="
|
|
402
|
-
<slot name="header"><span>${this.label}</span></slot>
|
|
555
|
+
<div class="launcher-cluster" part="launcher-cluster">
|
|
403
556
|
<button
|
|
404
|
-
class="
|
|
405
|
-
part="
|
|
406
|
-
aria-label
|
|
407
|
-
@click=${
|
|
557
|
+
class="launcher"
|
|
558
|
+
part="launcher"
|
|
559
|
+
aria-label=${this._viewportIsMobile ? "Open threads" : "Expand threads"}
|
|
560
|
+
@click=${onToggle}
|
|
408
561
|
>
|
|
409
|
-
|
|
562
|
+
<slot name="launcher-icon">${iconSidebar}</slot>
|
|
410
563
|
</button>
|
|
564
|
+
${this.licensed ? lit.html`<button
|
|
565
|
+
class="launcher launcher-new-thread"
|
|
566
|
+
part="launcher-new-thread"
|
|
567
|
+
aria-label="New Conversation"
|
|
568
|
+
@click=${() => this._emit("new-thread", {})}
|
|
569
|
+
>
|
|
570
|
+
${iconPlusSquare}
|
|
571
|
+
</button>` : lit.nothing}
|
|
411
572
|
</div>
|
|
412
|
-
|
|
413
|
-
|
|
573
|
+
`;
|
|
574
|
+
}
|
|
575
|
+
_renderHeader() {
|
|
576
|
+
const showMobileClose = this._viewportIsMobile && this.open;
|
|
577
|
+
const showCollapseToggle = this.collapsible && !this._viewportIsMobile;
|
|
578
|
+
return lit.html`
|
|
579
|
+
<div
|
|
580
|
+
class="header"
|
|
581
|
+
part="header"
|
|
582
|
+
?hidden=${!this._hasHeader && !showMobileClose && !showCollapseToggle}
|
|
583
|
+
>
|
|
584
|
+
<slot
|
|
585
|
+
name="header"
|
|
586
|
+
@slotchange=${(e) => {
|
|
587
|
+
this._hasHeader = e.target.assignedElements().length > 0;
|
|
588
|
+
}}
|
|
589
|
+
></slot>
|
|
590
|
+
${showCollapseToggle ? lit.html`<button
|
|
591
|
+
class="icon-btn"
|
|
592
|
+
part="collapse-toggle"
|
|
593
|
+
aria-label="Collapse threads"
|
|
594
|
+
@click=${() => this._setCollapsed(true)}
|
|
595
|
+
>
|
|
596
|
+
${iconSidebar}
|
|
597
|
+
</button>` : lit.nothing}
|
|
598
|
+
${showMobileClose ? lit.html`<button
|
|
599
|
+
class="icon-btn"
|
|
600
|
+
part="close-toggle"
|
|
601
|
+
aria-label="Close threads"
|
|
602
|
+
@click=${() => this._setOpen(false)}
|
|
603
|
+
>
|
|
604
|
+
${iconSidebar}
|
|
605
|
+
</button>` : lit.nothing}
|
|
606
|
+
</div>
|
|
607
|
+
${this.licensed ? this._renderNewConversation() : lit.nothing}
|
|
608
|
+
${this._renderSectionHeading()}
|
|
609
|
+
`;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Dedicated full-width "New Conversation" row. Keeps `part="new-thread-button"`
|
|
613
|
+
* and fires the existing `new-thread` event, so wrappers/themes that hook the
|
|
614
|
+
* old header pill are unaffected.
|
|
615
|
+
*/
|
|
616
|
+
_renderNewConversation() {
|
|
617
|
+
return lit.html`
|
|
618
|
+
<button
|
|
619
|
+
class="new-conversation"
|
|
620
|
+
part="new-thread-button"
|
|
621
|
+
@click=${() => this._emit("new-thread", {})}
|
|
622
|
+
>
|
|
623
|
+
${iconPlusSquare}
|
|
624
|
+
<span>New Conversation</span>
|
|
625
|
+
</button>
|
|
626
|
+
`;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* "Recent Conversations" section heading with a funnel button that opens the
|
|
630
|
+
* Active/All filter popover. Only shown when the list region is shown
|
|
631
|
+
* (licensed, and not the full-panel error/empty-before-load) — mirrors the
|
|
632
|
+
* old filters gate. The popover options keep `part="filter-active"` /
|
|
633
|
+
* `part="filter-all"` and still emit `filter-change` via `_setFilter`.
|
|
634
|
+
*/
|
|
635
|
+
_renderSectionHeading() {
|
|
636
|
+
if (!this.licensed || hasErrorMessage(this.error) && this.threads.length === 0) return lit.nothing;
|
|
637
|
+
return lit.html`
|
|
638
|
+
<div class="section-heading" part="section-heading">
|
|
639
|
+
<span class="section-title">${this.recentLabel}</span>
|
|
640
|
+
<button
|
|
641
|
+
class="icon-btn small"
|
|
642
|
+
part="filter-toggle"
|
|
643
|
+
aria-label="Filter threads"
|
|
644
|
+
aria-expanded=${this._filterOpen}
|
|
645
|
+
@click=${() => this._filterOpen = !this._filterOpen}
|
|
646
|
+
>
|
|
647
|
+
${iconFunnel}
|
|
648
|
+
${this._filter !== "active" ? lit.html`
|
|
649
|
+
<span class="filter-dot" part="filter-indicator"></span>
|
|
650
|
+
` : lit.nothing}
|
|
651
|
+
</button>
|
|
652
|
+
${this._filterOpen ? lit.html`<div
|
|
653
|
+
class="filter-popover"
|
|
654
|
+
part="filters"
|
|
655
|
+
role="group"
|
|
656
|
+
aria-label="Filter threads"
|
|
657
|
+
>
|
|
414
658
|
<button
|
|
415
|
-
class="filter-
|
|
659
|
+
class="filter-opt"
|
|
416
660
|
part="filter-active"
|
|
417
661
|
aria-pressed=${this._filter === "active"}
|
|
418
|
-
@click=${() =>
|
|
662
|
+
@click=${() => {
|
|
663
|
+
this._setFilter("active");
|
|
664
|
+
this._filterOpen = false;
|
|
665
|
+
}}
|
|
419
666
|
>
|
|
420
667
|
Active
|
|
421
668
|
</button>
|
|
422
669
|
<button
|
|
423
|
-
class="filter-
|
|
670
|
+
class="filter-opt"
|
|
424
671
|
part="filter-all"
|
|
425
672
|
aria-pressed=${this._filter === "all"}
|
|
426
|
-
@click=${() =>
|
|
673
|
+
@click=${() => {
|
|
674
|
+
this._setFilter("all");
|
|
675
|
+
this._filterOpen = false;
|
|
676
|
+
}}
|
|
427
677
|
>
|
|
428
678
|
All
|
|
429
679
|
</button>
|
|
430
|
-
</div
|
|
431
|
-
|
|
680
|
+
</div>` : lit.nothing}
|
|
681
|
+
</div>
|
|
432
682
|
`;
|
|
433
683
|
}
|
|
434
684
|
_renderBody() {
|
|
@@ -469,7 +719,12 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
469
719
|
}
|
|
470
720
|
_renderError() {
|
|
471
721
|
return lit.html`
|
|
472
|
-
<div
|
|
722
|
+
<div
|
|
723
|
+
class="state error"
|
|
724
|
+
part="error"
|
|
725
|
+
role="alert"
|
|
726
|
+
data-testid="drawer-error"
|
|
727
|
+
>
|
|
473
728
|
<p>${this.error}</p>
|
|
474
729
|
<button
|
|
475
730
|
class="primary"
|
|
@@ -496,20 +751,30 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
496
751
|
</div>
|
|
497
752
|
`;
|
|
498
753
|
return lit.html`
|
|
499
|
-
<ul
|
|
500
|
-
|
|
754
|
+
<ul
|
|
755
|
+
class=${this._openMenuId !== null ? "list menu-open" : "list"}
|
|
756
|
+
part="list"
|
|
757
|
+
role="listbox"
|
|
758
|
+
aria-label=${this.label}
|
|
759
|
+
>
|
|
760
|
+
${(0, lit_directives_repeat_js.repeat)(visible, (thread) => thread.id, (thread, index) => this._renderRow(thread, index, visible.length))}
|
|
501
761
|
</ul>
|
|
502
762
|
${this._renderFetchMore()}
|
|
503
763
|
`;
|
|
504
764
|
}
|
|
505
|
-
_renderRow(thread) {
|
|
765
|
+
_renderRow(thread, index = 0, total = 1) {
|
|
506
766
|
const isActive = thread.id === this.activeThreadId;
|
|
507
767
|
const hasName = thread.name !== null && thread.name !== "";
|
|
768
|
+
const displayName = hasName ? thread.name : "New thread";
|
|
508
769
|
const justRevealed = this._justRevealed.has(thread.id);
|
|
770
|
+
const menuOpen = this._openMenuId === thread.id;
|
|
771
|
+
const menuUp = menuOpen && total > 1 && index >= total / 2;
|
|
509
772
|
const rowClasses = {
|
|
510
773
|
row: true,
|
|
511
774
|
active: isActive,
|
|
512
|
-
archived: thread.archived
|
|
775
|
+
archived: thread.archived,
|
|
776
|
+
"menu-open": menuOpen,
|
|
777
|
+
"menu-up": menuUp
|
|
513
778
|
};
|
|
514
779
|
const nameClasses = {
|
|
515
780
|
"row-name": true,
|
|
@@ -517,14 +782,8 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
517
782
|
revealed: justRevealed
|
|
518
783
|
};
|
|
519
784
|
const slotName = rowSlotName(thread.id);
|
|
520
|
-
const nameSpan = lit.html`<span
|
|
521
|
-
class
|
|
522
|
-
part="row-name"
|
|
523
|
-
data-tooltip=${hasName ? thread.name : lit.nothing}
|
|
524
|
-
>
|
|
525
|
-
<span class="row-name-text"
|
|
526
|
-
>${hasName ? thread.name : "New thread"}</span
|
|
527
|
-
>
|
|
785
|
+
const nameSpan = lit.html`<span class=${(0, lit_directives_class_map_js.classMap)(nameClasses)} part="row-name">
|
|
786
|
+
<span class="row-name-text">${displayName}</span>
|
|
528
787
|
</span>`;
|
|
529
788
|
return lit.html`
|
|
530
789
|
<li
|
|
@@ -534,50 +793,76 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
534
793
|
aria-selected=${isActive ? "true" : "false"}
|
|
535
794
|
tabindex="0"
|
|
536
795
|
data-thread-id=${thread.id}
|
|
537
|
-
@click=${() =>
|
|
796
|
+
@click=${() => {
|
|
797
|
+
this._openMenuId = null;
|
|
798
|
+
this._emit("thread-selected", { threadId: thread.id });
|
|
799
|
+
}}
|
|
538
800
|
@keydown=${(e) => {
|
|
539
801
|
if (e.key === "Enter" || e.key === " ") {
|
|
540
802
|
e.preventDefault();
|
|
803
|
+
this._openMenuId = null;
|
|
541
804
|
this._emit("thread-selected", { threadId: thread.id });
|
|
542
805
|
}
|
|
543
806
|
}}
|
|
544
807
|
>
|
|
545
808
|
${slotName !== null ? lit.html`<slot name=${slotName}>${nameSpan}</slot>` : nameSpan}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
809
|
+
<button
|
|
810
|
+
class="row-menu"
|
|
811
|
+
part="row-menu"
|
|
812
|
+
aria-label=${`Actions for ${displayName}`}
|
|
813
|
+
aria-haspopup="menu"
|
|
814
|
+
aria-expanded=${menuOpen}
|
|
815
|
+
@click=${(e) => {
|
|
552
816
|
e.stopPropagation();
|
|
553
|
-
this.
|
|
817
|
+
this._openMenuId = menuOpen ? null : thread.id;
|
|
554
818
|
}}
|
|
819
|
+
>
|
|
820
|
+
${iconKebab}
|
|
821
|
+
</button>
|
|
822
|
+
${menuOpen ? lit.html`<div
|
|
823
|
+
class="row-menu-popover"
|
|
824
|
+
part="row-menu-popover"
|
|
825
|
+
role="menu"
|
|
555
826
|
>
|
|
556
|
-
${
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
827
|
+
${thread.archived ? lit.html`<button
|
|
828
|
+
class="row-menu-item"
|
|
829
|
+
part="row-unarchive"
|
|
830
|
+
role="menuitem"
|
|
831
|
+
aria-label=${`Unarchive thread ${displayName}`}
|
|
832
|
+
@click=${(e) => {
|
|
833
|
+
e.stopPropagation();
|
|
834
|
+
this._openMenuId = null;
|
|
835
|
+
this._emit("unarchive", { threadId: thread.id });
|
|
836
|
+
}}
|
|
837
|
+
>
|
|
838
|
+
${iconUnarchive}<span>Unarchive</span>
|
|
839
|
+
</button>` : lit.html`<button
|
|
840
|
+
class="row-menu-item"
|
|
841
|
+
part="row-archive"
|
|
842
|
+
role="menuitem"
|
|
843
|
+
aria-label=${`Archive thread ${displayName}`}
|
|
844
|
+
@click=${(e) => {
|
|
563
845
|
e.stopPropagation();
|
|
846
|
+
this._openMenuId = null;
|
|
564
847
|
this._emit("archive", { threadId: thread.id });
|
|
565
848
|
}}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
849
|
+
>
|
|
850
|
+
${iconArchive}<span>Archive</span>
|
|
851
|
+
</button>`}
|
|
852
|
+
<button
|
|
853
|
+
class="row-menu-item danger"
|
|
854
|
+
part="row-delete"
|
|
855
|
+
role="menuitem"
|
|
856
|
+
aria-label=${`Delete thread ${displayName}`}
|
|
857
|
+
@click=${(e) => {
|
|
575
858
|
e.stopPropagation();
|
|
859
|
+
this._openMenuId = null;
|
|
576
860
|
this._confirmingDeleteId = thread.id;
|
|
577
861
|
}}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
862
|
+
>
|
|
863
|
+
${iconDelete}<span>Delete</span>
|
|
864
|
+
</button>
|
|
865
|
+
</div>` : lit.nothing}
|
|
581
866
|
</li>
|
|
582
867
|
`;
|
|
583
868
|
}
|
|
@@ -632,41 +917,59 @@ var CopilotKitThreadsDrawer = class extends lit.LitElement {
|
|
|
632
917
|
</div>
|
|
633
918
|
`;
|
|
634
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* Confirm-delete dialog, rendered as a native `<dialog>` that is ALWAYS
|
|
922
|
+
* present in the shadow DOM so `updated()` can drive `showModal()`/`close()`
|
|
923
|
+
* against it. Opening with `showModal()` puts it in the browser TOP LAYER, so
|
|
924
|
+
* it can never be painted under other UI — the previous CSS-positioned overlay
|
|
925
|
+
* was trapped in the drawer host's stacking context and appeared under the
|
|
926
|
+
* chat's welcome view (ENT-1051). The `::backdrop` pseudo-element (styled in
|
|
927
|
+
* styles.ts) provides the scrim natively.
|
|
928
|
+
*
|
|
929
|
+
* The actionable content (message + Cancel/Delete, bound to the captured id)
|
|
930
|
+
* renders only while confirming, so a closed dialog holds nothing stale.
|
|
931
|
+
* Native dismissal is wired via `@cancel` (Escape) and a backdrop-click check.
|
|
932
|
+
*/
|
|
635
933
|
_renderConfirmDialog() {
|
|
636
|
-
if (this._confirmingDeleteId === null) return lit.nothing;
|
|
637
934
|
const id = this._confirmingDeleteId;
|
|
638
935
|
return lit.html`
|
|
639
|
-
<
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
936
|
+
<dialog
|
|
937
|
+
class="dialog"
|
|
938
|
+
part="confirm-dialog"
|
|
939
|
+
role="alertdialog"
|
|
940
|
+
aria-label="Confirm delete"
|
|
941
|
+
data-testid="drawer-confirm-delete"
|
|
942
|
+
@cancel=${(event) => {
|
|
943
|
+
event.preventDefault();
|
|
944
|
+
this._confirmingDeleteId = null;
|
|
945
|
+
}}
|
|
946
|
+
@click=${(event) => {
|
|
947
|
+
if (event.target === event.currentTarget) this._confirmingDeleteId = null;
|
|
948
|
+
}}
|
|
949
|
+
>
|
|
950
|
+
${id !== null ? lit.html`
|
|
951
|
+
<p>Delete this thread? This cannot be undone.</p>
|
|
952
|
+
<div class="dialog-actions">
|
|
953
|
+
<button
|
|
954
|
+
class="row-action"
|
|
955
|
+
part="confirm-cancel"
|
|
956
|
+
@click=${() => this._confirmingDeleteId = null}
|
|
957
|
+
>
|
|
958
|
+
Cancel
|
|
959
|
+
</button>
|
|
960
|
+
<button
|
|
961
|
+
class="primary"
|
|
962
|
+
part="confirm-delete"
|
|
963
|
+
@click=${() => {
|
|
661
964
|
this._confirmingDeleteId = null;
|
|
662
965
|
this._emit("delete", { threadId: id });
|
|
663
966
|
}}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
</
|
|
967
|
+
>
|
|
968
|
+
Delete
|
|
969
|
+
</button>
|
|
970
|
+
</div>
|
|
971
|
+
` : lit.nothing}
|
|
972
|
+
</dialog>
|
|
670
973
|
`;
|
|
671
974
|
}
|
|
672
975
|
};
|