forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopilot-chat-view-input-container.ts
More file actions
80 lines (73 loc) · 2.25 KB
/
Copy pathcopilot-chat-view-input-container.ts
File metadata and controls
80 lines (73 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import {
Component,
input,
ChangeDetectionStrategy,
ViewEncapsulation,
forwardRef,
ElementRef,
} from "@angular/core";
import { CommonModule } from "@angular/common";
import { CopilotSlot } from "../../slots/copilot-slot";
import { CopilotChatInput } from "./copilot-chat-input";
import { CopilotChatViewDisclaimer } from "./copilot-chat-view-disclaimer";
import { cn } from "../../utils";
/**
* InputContainer component for CopilotChatView
* Container for input and disclaimer components
* Uses ForwardRef for DOM access
*/
@Component({
standalone: true,
selector: "copilot-chat-view-input-container",
imports: [CommonModule, CopilotSlot],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
providers: [
{
provide: ElementRef,
useExisting: forwardRef(() => CopilotChatViewInputContainer),
},
],
template: `
<div [class]="computedClass">
<!-- Input component -->
<div class="max-w-3xl mx-auto py-0 px-4 sm:px-0">
<copilot-slot
[slot]="input()"
[context]="{ inputClass: inputClass() }"
[defaultComponent]="defaultInputComponent"
>
</copilot-slot>
</div>
<!-- Disclaimer - always rendered like in React -->
<copilot-slot
[slot]="disclaimer()"
[context]="{ text: disclaimerText(), inputClass: disclaimerClass() }"
[defaultComponent]="defaultDisclaimerComponent"
>
</copilot-slot>
</div>
`,
})
export class CopilotChatViewInputContainer extends ElementRef {
inputContainerClass = input<string | undefined>();
// Input slot configuration
input = input<any | undefined>();
inputClass = input<string | undefined>();
// Disclaimer slot configuration
disclaimer = input<any | undefined>();
disclaimerText = input<string | undefined>();
disclaimerClass = input<string | undefined>();
// Default components
protected readonly defaultInputComponent = CopilotChatInput;
protected readonly defaultDisclaimerComponent = CopilotChatViewDisclaimer;
constructor(elementRef: ElementRef) {
super(elementRef.nativeElement);
}
get computedClass(): string {
return cn(
"absolute bottom-0 left-0 right-0 z-20",
this.inputContainerClass(),
);
}
}