mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
feat(angular): forward a label input to the drawer element
This commit is contained in:
@@ -471,3 +471,32 @@ test("copilotDrawerRow renders per-row slot content for each thread", () => {
|
||||
);
|
||||
expect(slotEl?.textContent?.trim()).toContain("ROW:Alpha");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// label input forwarding
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Host that passes a custom label to the drawer. */
|
||||
@Component({
|
||||
selector: "test-host-label",
|
||||
standalone: true,
|
||||
imports: [CopilotDrawer],
|
||||
template: `<copilot-drawer [label]="'Custom'" />`,
|
||||
})
|
||||
class HostWithLabelComponent {}
|
||||
|
||||
test("label input is forwarded to the <copilotkit-drawer> element label property", () => {
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HostWithLabelComponent],
|
||||
});
|
||||
|
||||
const fixture = TestBed.createComponent(HostWithLabelComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const drawerEl = (fixture.nativeElement as HTMLElement).querySelector(
|
||||
"copilotkit-drawer",
|
||||
) as HTMLElement & { label: string };
|
||||
|
||||
expect(drawerEl.label).toBe("Custom");
|
||||
});
|
||||
|
||||
@@ -140,6 +140,12 @@ export class CopilotDrawer {
|
||||
alias: "data-testid",
|
||||
});
|
||||
|
||||
/**
|
||||
* Optional accessible/region + default-header label forwarded to the element's
|
||||
* `label` property; defaults to the element's own `"Threads"` when unset.
|
||||
*/
|
||||
readonly label = input<string | undefined>();
|
||||
|
||||
/**
|
||||
* Optional host override for the thread-select action.
|
||||
*
|
||||
@@ -237,6 +243,7 @@ export class CopilotDrawer {
|
||||
el.activeThreadId = this.activeThreadId();
|
||||
el.hasMore = this.threads.hasMoreThreads();
|
||||
el.fetchingMore = this.threads.isFetchingMoreThreads();
|
||||
if (this.label() !== undefined) el.label = this.label() as string;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user