@copilotkitnext/angular 0.0.2 → 0.0.5
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 +3 -3
- package/dist/README.md +3 -3
- package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +10 -10
- package/dist/components/chat/copilot-chat-message-view.component.d.ts +42 -42
- package/dist/components/chat/copilot-chat-view.component.d.ts +14 -14
- package/dist/core/copilotkit.providers.d.ts +1 -1
- package/dist/core/copilotkit.service.d.ts +5 -5
- package/dist/core/copilotkit.types.d.ts +8 -10
- package/dist/directives/copilotkit-frontend-tool.directive.d.ts +1 -1
- package/dist/esm2022/components/chat/copilot-chat-assistant-message-buttons.component.mjs +384 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message-renderer.component.mjs +286 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message-toolbar.component.mjs +27 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message.component.mjs +433 -0
- package/dist/esm2022/components/chat/copilot-chat-assistant-message.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat-audio-recorder.component.mjs +202 -0
- package/dist/esm2022/components/chat/copilot-chat-buttons.component.mjs +321 -0
- package/dist/esm2022/components/chat/copilot-chat-input-defaults.mjs +38 -0
- package/dist/esm2022/components/chat/copilot-chat-input.component.mjs +666 -0
- package/dist/esm2022/components/chat/copilot-chat-input.types.mjs +10 -0
- package/dist/esm2022/components/chat/copilot-chat-message-view-cursor.component.mjs +45 -0
- package/dist/esm2022/components/chat/copilot-chat-message-view.component.mjs +296 -0
- package/dist/esm2022/components/chat/copilot-chat-message-view.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat-textarea.component.mjs +188 -0
- package/dist/esm2022/components/chat/copilot-chat-tool-calls-view.component.mjs +216 -0
- package/dist/esm2022/components/chat/copilot-chat-toolbar.component.mjs +25 -0
- package/dist/esm2022/components/chat/copilot-chat-tools-menu.component.mjs +199 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-branch-navigation.component.mjs +137 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-buttons.component.mjs +207 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-renderer.component.mjs +35 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message-toolbar.component.mjs +34 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message.component.mjs +341 -0
- package/dist/esm2022/components/chat/copilot-chat-user-message.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat-view-disclaimer.component.mjs +52 -0
- package/dist/esm2022/components/chat/copilot-chat-view-feather.component.mjs +55 -0
- package/dist/esm2022/components/chat/copilot-chat-view-handlers.service.mjs +19 -0
- package/dist/esm2022/components/chat/copilot-chat-view-input-container.component.mjs +110 -0
- package/dist/esm2022/components/chat/copilot-chat-view-scroll-to-bottom-button.component.mjs +93 -0
- package/dist/esm2022/components/chat/copilot-chat-view-scroll-view.component.mjs +443 -0
- package/dist/esm2022/components/chat/copilot-chat-view.component.mjs +479 -0
- package/dist/esm2022/components/chat/copilot-chat-view.types.mjs +2 -0
- package/dist/esm2022/components/chat/copilot-chat.component.mjs +214 -0
- package/dist/esm2022/components/copilotkit-tool-render.component.mjs +153 -0
- package/dist/esm2022/copilotkitnext-angular.mjs +5 -0
- package/dist/esm2022/core/chat-configuration/chat-configuration.providers.mjs +65 -0
- package/dist/esm2022/core/chat-configuration/chat-configuration.service.mjs +145 -0
- package/dist/esm2022/core/chat-configuration/chat-configuration.types.mjs +26 -0
- package/dist/esm2022/core/copilotkit.providers.mjs +34 -0
- package/dist/esm2022/core/copilotkit.service.mjs +426 -0
- package/dist/esm2022/core/copilotkit.types.mjs +13 -0
- package/dist/esm2022/directives/copilotkit-agent-context.directive.mjs +130 -0
- package/dist/esm2022/directives/copilotkit-agent.directive.mjs +217 -0
- package/dist/esm2022/directives/copilotkit-chat-config.directive.mjs +218 -0
- package/dist/esm2022/directives/copilotkit-config.directive.mjs +94 -0
- package/dist/esm2022/directives/copilotkit-frontend-tool.directive.mjs +128 -0
- package/dist/esm2022/directives/copilotkit-human-in-the-loop.directive.mjs +265 -0
- package/dist/esm2022/directives/stick-to-bottom.directive.mjs +181 -0
- package/dist/esm2022/index.mjs +70 -0
- package/dist/esm2022/lib/directives/tooltip.directive.mjs +211 -0
- package/dist/esm2022/lib/slots/copilot-slot.component.mjs +144 -0
- package/dist/esm2022/lib/slots/slot.types.mjs +6 -0
- package/dist/esm2022/lib/slots/slot.utils.mjs +222 -0
- package/dist/esm2022/lib/utils.mjs +10 -0
- package/dist/esm2022/services/resize-observer.service.mjs +152 -0
- package/dist/esm2022/services/scroll-position.service.mjs +124 -0
- package/dist/esm2022/types/frontend-tool.mjs +2 -0
- package/dist/esm2022/types/human-in-the-loop.mjs +2 -0
- package/dist/esm2022/utils/agent-context.utils.mjs +114 -0
- package/dist/esm2022/utils/agent.utils.mjs +204 -0
- package/dist/esm2022/utils/chat-config.utils.mjs +186 -0
- package/dist/esm2022/utils/copilotkit.utils.mjs +20 -0
- package/dist/esm2022/utils/frontend-tool.utils.mjs +224 -0
- package/dist/esm2022/utils/human-in-the-loop.utils.mjs +293 -0
- package/dist/fesm2022/copilotkitnext-angular.mjs +174 -187
- package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -1
- package/dist/utils/frontend-tool.utils.d.ts +1 -1
- package/package.json +23 -20
- package/vitest.config.mts +32 -21
- package/.turbo/turbo-build.log +0 -38
- package/.turbo/turbo-check-types.log +0 -0
- package/.turbo/turbo-test.log +0 -71
- package/ng-package.json +0 -19
- package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +0 -282
- package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +0 -419
- package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +0 -372
- package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +0 -249
- package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +0 -292
- package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +0 -472
- package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +0 -29
- package/src/components/chat/copilot-chat-assistant-message.component.ts +0 -463
- package/src/components/chat/copilot-chat-assistant-message.types.ts +0 -50
- package/src/components/chat/copilot-chat-audio-recorder.component.ts +0 -241
- package/src/components/chat/copilot-chat-buttons.component.ts +0 -308
- package/src/components/chat/copilot-chat-buttons.component.ts.bak +0 -471
- package/src/components/chat/copilot-chat-input-defaults.ts +0 -47
- package/src/components/chat/copilot-chat-input.component.ts +0 -512
- package/src/components/chat/copilot-chat-input.types.ts +0 -148
- package/src/components/chat/copilot-chat-message-view-cursor.component.ts +0 -51
- package/src/components/chat/copilot-chat-message-view.component.ts +0 -233
- package/src/components/chat/copilot-chat-message-view.types.ts +0 -39
- package/src/components/chat/copilot-chat-textarea.component.ts +0 -220
- package/src/components/chat/copilot-chat-tool-calls-view.component.ts +0 -261
- package/src/components/chat/copilot-chat-toolbar.component.ts +0 -35
- package/src/components/chat/copilot-chat-tools-menu.component.ts +0 -185
- package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +0 -121
- package/src/components/chat/copilot-chat-user-message-buttons.component.ts +0 -170
- package/src/components/chat/copilot-chat-user-message-renderer.component.ts +0 -37
- package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +0 -37
- package/src/components/chat/copilot-chat-user-message.component.ts +0 -247
- package/src/components/chat/copilot-chat-user-message.types.ts +0 -42
- package/src/components/chat/copilot-chat-view-disclaimer.component.ts +0 -51
- package/src/components/chat/copilot-chat-view-feather.component.ts +0 -47
- package/src/components/chat/copilot-chat-view-handlers.service.ts +0 -14
- package/src/components/chat/copilot-chat-view-input-container.component.ts +0 -87
- package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +0 -79
- package/src/components/chat/copilot-chat-view-scroll-view.component.ts +0 -322
- package/src/components/chat/copilot-chat-view.component.ts +0 -420
- package/src/components/chat/copilot-chat-view.types.ts +0 -52
- package/src/components/chat/copilot-chat.component.ts +0 -232
- package/src/components/copilotkit-tool-render.component.ts +0 -169
- package/src/core/__tests__/copilotkit.service.spec.ts +0 -1051
- package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +0 -316
- package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +0 -287
- package/src/core/chat-configuration/chat-configuration.providers.ts +0 -71
- package/src/core/chat-configuration/chat-configuration.service.ts +0 -162
- package/src/core/chat-configuration/chat-configuration.types.ts +0 -57
- package/src/core/copilotkit.providers.ts +0 -59
- package/src/core/copilotkit.service.ts +0 -542
- package/src/core/copilotkit.types.ts +0 -132
- package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +0 -384
- package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +0 -253
- package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +0 -385
- package/src/directives/__tests__/copilotkit-config.directive.spec.ts +0 -69
- package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +0 -60
- package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +0 -108
- package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +0 -452
- package/src/directives/copilotkit-agent-context.directive.ts +0 -138
- package/src/directives/copilotkit-agent.directive.ts +0 -225
- package/src/directives/copilotkit-chat-config.directive.ts +0 -241
- package/src/directives/copilotkit-config.directive.ts +0 -81
- package/src/directives/copilotkit-frontend-tool.directive.ts +0 -145
- package/src/directives/copilotkit-human-in-the-loop.directive.ts +0 -281
- package/src/directives/stick-to-bottom.directive.ts +0 -204
- package/src/index.ts +0 -105
- package/src/lib/directives/tooltip.directive.ts +0 -292
- package/src/lib/slots/__tests__/slot.utils.spec.ts +0 -377
- package/src/lib/slots/copilot-slot.component.ts +0 -135
- package/src/lib/slots/index.ts +0 -3
- package/src/lib/slots/slot.types.ts +0 -64
- package/src/lib/slots/slot.utils.ts +0 -289
- package/src/lib/utils.ts +0 -10
- package/src/public-api.ts +0 -1
- package/src/services/resize-observer.service.ts +0 -181
- package/src/services/scroll-position.service.ts +0 -169
- package/src/styles/globals.css +0 -266
- package/src/styles/index.css +0 -3
- package/src/test-setup.ts +0 -15
- package/src/testing/index.ts +0 -3
- package/src/testing/testing.utils.ts +0 -248
- package/src/types/frontend-tool.ts +0 -44
- package/src/types/human-in-the-loop.ts +0 -52
- package/src/utils/__tests__/agent.utils.spec.ts +0 -234
- package/src/utils/__tests__/chat-config.utils.spec.ts +0 -306
- package/src/utils/__tests__/frontend-tool-inject.spec.ts +0 -350
- package/src/utils/__tests__/frontend-tool-integration.spec.ts +0 -199
- package/src/utils/__tests__/frontend-tool.utils.spec.ts +0 -272
- package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +0 -365
- package/src/utils/agent-context.utils.ts +0 -133
- package/src/utils/agent.utils.ts +0 -239
- package/src/utils/chat-config.utils.ts +0 -221
- package/src/utils/copilotkit.utils.ts +0 -20
- package/src/utils/frontend-tool.utils.ts +0 -266
- package/src/utils/human-in-the-loop.utils.ts +0 -359
- package/tsconfig.spec.json +0 -12
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
Output,
|
|
5
|
-
EventEmitter,
|
|
6
|
-
signal,
|
|
7
|
-
computed,
|
|
8
|
-
ChangeDetectionStrategy,
|
|
9
|
-
ChangeDetectorRef,
|
|
10
|
-
ViewEncapsulation,
|
|
11
|
-
inject
|
|
12
|
-
} from '@angular/core';
|
|
13
|
-
import { CommonModule } from '@angular/common';
|
|
14
|
-
import { LucideAngularModule, Copy, Check, Edit } from 'lucide-angular';
|
|
15
|
-
import { CopilotTooltipDirective } from '../../lib/directives/tooltip.directive';
|
|
16
|
-
import { CopilotChatConfigurationService } from '../../core/chat-configuration/chat-configuration.service';
|
|
17
|
-
import { cn } from '../../lib/utils';
|
|
18
|
-
|
|
19
|
-
// Base toolbar button component
|
|
20
|
-
@Component({
|
|
21
|
-
selector: 'button[copilotChatUserMessageToolbarButton]',
|
|
22
|
-
standalone: true,
|
|
23
|
-
imports: [CommonModule],
|
|
24
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
25
|
-
encapsulation: ViewEncapsulation.None,
|
|
26
|
-
template: `
|
|
27
|
-
<ng-content></ng-content>
|
|
28
|
-
`,
|
|
29
|
-
host: {
|
|
30
|
-
'[class]': 'computedClass()',
|
|
31
|
-
'[attr.disabled]': 'disabled ? true : null',
|
|
32
|
-
'type': 'button',
|
|
33
|
-
'[attr.aria-label]': 'title'
|
|
34
|
-
},
|
|
35
|
-
hostDirectives: [
|
|
36
|
-
{
|
|
37
|
-
directive: CopilotTooltipDirective,
|
|
38
|
-
inputs: ['copilotTooltip: title', 'tooltipPosition', 'tooltipDelay']
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
})
|
|
42
|
-
export class CopilotChatUserMessageToolbarButtonComponent {
|
|
43
|
-
@Input() title = '';
|
|
44
|
-
@Input() disabled = false;
|
|
45
|
-
@Input() set inputClass(value: string | undefined) {
|
|
46
|
-
this.customClass.set(value);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private customClass = signal<string | undefined>(undefined);
|
|
50
|
-
|
|
51
|
-
computedClass = computed(() => {
|
|
52
|
-
return cn(
|
|
53
|
-
// Flex centering
|
|
54
|
-
'inline-flex items-center justify-center',
|
|
55
|
-
// Cursor
|
|
56
|
-
'cursor-pointer',
|
|
57
|
-
// Background and text
|
|
58
|
-
'p-0 text-[rgb(93,93,93)] hover:bg-[#E8E8E8]',
|
|
59
|
-
// Dark mode
|
|
60
|
-
'dark:text-[rgb(243,243,243)] dark:hover:bg-[#303030]',
|
|
61
|
-
// Shape and sizing
|
|
62
|
-
'h-8 w-8 rounded-md',
|
|
63
|
-
// Interactions
|
|
64
|
-
'transition-colors',
|
|
65
|
-
// Hover states
|
|
66
|
-
'hover:text-[rgb(93,93,93)]',
|
|
67
|
-
'dark:hover:text-[rgb(243,243,243)]',
|
|
68
|
-
// Focus states
|
|
69
|
-
'focus:outline-none focus:ring-2 focus:ring-offset-2',
|
|
70
|
-
// Disabled state
|
|
71
|
-
'disabled:opacity-50 disabled:cursor-not-allowed',
|
|
72
|
-
this.customClass()
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Copy button component
|
|
78
|
-
@Component({
|
|
79
|
-
selector: 'copilot-chat-user-message-copy-button',
|
|
80
|
-
standalone: true,
|
|
81
|
-
imports: [CommonModule, LucideAngularModule, CopilotChatUserMessageToolbarButtonComponent],
|
|
82
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
83
|
-
encapsulation: ViewEncapsulation.None,
|
|
84
|
-
template: `
|
|
85
|
-
<button
|
|
86
|
-
copilotChatUserMessageToolbarButton
|
|
87
|
-
[title]="title || labels.userMessageToolbarCopyMessageLabel"
|
|
88
|
-
[disabled]="disabled"
|
|
89
|
-
[inputClass]="inputClass"
|
|
90
|
-
(click)="handleCopy()">
|
|
91
|
-
@if (copied()) {
|
|
92
|
-
<lucide-angular [img]="CheckIcon" [size]="18"></lucide-angular>
|
|
93
|
-
} @else {
|
|
94
|
-
<lucide-angular [img]="CopyIcon" [size]="18"></lucide-angular>
|
|
95
|
-
}
|
|
96
|
-
</button>
|
|
97
|
-
`
|
|
98
|
-
})
|
|
99
|
-
export class CopilotChatUserMessageCopyButtonComponent {
|
|
100
|
-
@Input() title?: string;
|
|
101
|
-
@Input() disabled = false;
|
|
102
|
-
@Input() inputClass?: string;
|
|
103
|
-
@Input() content?: string;
|
|
104
|
-
@Output() clicked = new EventEmitter<void>();
|
|
105
|
-
|
|
106
|
-
readonly CopyIcon = Copy;
|
|
107
|
-
readonly CheckIcon = Check;
|
|
108
|
-
|
|
109
|
-
copied = signal(false);
|
|
110
|
-
private chatConfig = inject(CopilotChatConfigurationService);
|
|
111
|
-
|
|
112
|
-
get labels() {
|
|
113
|
-
return this.chatConfig.labels();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
handleCopy(): void {
|
|
117
|
-
if (!this.content) return;
|
|
118
|
-
|
|
119
|
-
// Set copied immediately for instant feedback
|
|
120
|
-
this.copied.set(true);
|
|
121
|
-
setTimeout(() => this.copied.set(false), 2000);
|
|
122
|
-
|
|
123
|
-
// Copy to clipboard (fire and forget)
|
|
124
|
-
navigator.clipboard.writeText(this.content).then(
|
|
125
|
-
() => this.clicked.emit(),
|
|
126
|
-
(err) => {
|
|
127
|
-
console.error('Failed to copy message:', err);
|
|
128
|
-
this.copied.set(false);
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Edit button component
|
|
135
|
-
@Component({
|
|
136
|
-
selector: 'copilot-chat-user-message-edit-button',
|
|
137
|
-
standalone: true,
|
|
138
|
-
imports: [CommonModule, LucideAngularModule, CopilotChatUserMessageToolbarButtonComponent],
|
|
139
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
140
|
-
encapsulation: ViewEncapsulation.None,
|
|
141
|
-
template: `
|
|
142
|
-
<button
|
|
143
|
-
copilotChatUserMessageToolbarButton
|
|
144
|
-
[title]="title || labels.userMessageToolbarEditMessageLabel"
|
|
145
|
-
[disabled]="disabled"
|
|
146
|
-
[inputClass]="inputClass"
|
|
147
|
-
(click)="handleEdit()">
|
|
148
|
-
<lucide-angular [img]="EditIcon" [size]="18"></lucide-angular>
|
|
149
|
-
</button>
|
|
150
|
-
`
|
|
151
|
-
})
|
|
152
|
-
export class CopilotChatUserMessageEditButtonComponent {
|
|
153
|
-
@Input() title?: string;
|
|
154
|
-
@Input() disabled = false;
|
|
155
|
-
@Input() inputClass?: string;
|
|
156
|
-
@Output() clicked = new EventEmitter<void>();
|
|
157
|
-
|
|
158
|
-
readonly EditIcon = Edit;
|
|
159
|
-
private chatConfig = inject(CopilotChatConfigurationService);
|
|
160
|
-
|
|
161
|
-
get labels() {
|
|
162
|
-
return this.chatConfig.labels();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
handleEdit(): void {
|
|
166
|
-
if (!this.disabled) {
|
|
167
|
-
this.clicked.emit();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
ChangeDetectionStrategy,
|
|
5
|
-
ViewEncapsulation,
|
|
6
|
-
computed,
|
|
7
|
-
signal
|
|
8
|
-
} from '@angular/core';
|
|
9
|
-
import { CommonModule } from '@angular/common';
|
|
10
|
-
import { cn } from '../../lib/utils';
|
|
11
|
-
|
|
12
|
-
@Component({
|
|
13
|
-
selector: 'copilot-chat-user-message-renderer',
|
|
14
|
-
standalone: true,
|
|
15
|
-
imports: [CommonModule],
|
|
16
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
17
|
-
encapsulation: ViewEncapsulation.None,
|
|
18
|
-
host: {
|
|
19
|
-
'[class]': 'computedClass()'
|
|
20
|
-
},
|
|
21
|
-
template: `{{ content }}`
|
|
22
|
-
})
|
|
23
|
-
export class CopilotChatUserMessageRendererComponent {
|
|
24
|
-
@Input() content = '';
|
|
25
|
-
@Input() set inputClass(value: string | undefined) {
|
|
26
|
-
this.customClass.set(value);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private customClass = signal<string | undefined>(undefined);
|
|
30
|
-
|
|
31
|
-
computedClass = computed(() => {
|
|
32
|
-
return cn(
|
|
33
|
-
"prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap",
|
|
34
|
-
this.customClass()
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
ChangeDetectionStrategy,
|
|
5
|
-
ViewEncapsulation,
|
|
6
|
-
signal
|
|
7
|
-
} from '@angular/core';
|
|
8
|
-
import { CommonModule } from '@angular/common';
|
|
9
|
-
import { cn } from '../../lib/utils';
|
|
10
|
-
|
|
11
|
-
@Component({
|
|
12
|
-
selector: 'div[copilotChatUserMessageToolbar]',
|
|
13
|
-
standalone: true,
|
|
14
|
-
imports: [CommonModule],
|
|
15
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
-
encapsulation: ViewEncapsulation.None,
|
|
17
|
-
template: `
|
|
18
|
-
<ng-content></ng-content>
|
|
19
|
-
`,
|
|
20
|
-
host: {
|
|
21
|
-
'[class]': 'computedClass()'
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
export class CopilotChatUserMessageToolbarComponent {
|
|
25
|
-
@Input() inputClass?: string;
|
|
26
|
-
|
|
27
|
-
computedClass = signal<string>('');
|
|
28
|
-
|
|
29
|
-
ngOnInit() {
|
|
30
|
-
this.computedClass.set(
|
|
31
|
-
cn(
|
|
32
|
-
"w-full bg-transparent flex items-center justify-end mt-[4px] invisible group-hover:visible",
|
|
33
|
-
this.inputClass
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
Output,
|
|
5
|
-
EventEmitter,
|
|
6
|
-
TemplateRef,
|
|
7
|
-
ContentChild,
|
|
8
|
-
signal,
|
|
9
|
-
computed,
|
|
10
|
-
Type,
|
|
11
|
-
ChangeDetectionStrategy,
|
|
12
|
-
ViewEncapsulation
|
|
13
|
-
} from '@angular/core';
|
|
14
|
-
import { CommonModule } from '@angular/common';
|
|
15
|
-
import { CopilotSlotComponent } from '../../lib/slots/copilot-slot.component';
|
|
16
|
-
import {
|
|
17
|
-
type UserMessage,
|
|
18
|
-
type CopilotChatUserMessageOnEditMessageProps,
|
|
19
|
-
type CopilotChatUserMessageOnSwitchToBranchProps,
|
|
20
|
-
type MessageRendererContext,
|
|
21
|
-
type CopyButtonContext,
|
|
22
|
-
type EditButtonContext,
|
|
23
|
-
type BranchNavigationContext,
|
|
24
|
-
type ToolbarContext
|
|
25
|
-
} from './copilot-chat-user-message.types';
|
|
26
|
-
import { CopilotChatUserMessageRendererComponent } from './copilot-chat-user-message-renderer.component';
|
|
27
|
-
import {
|
|
28
|
-
CopilotChatUserMessageCopyButtonComponent,
|
|
29
|
-
CopilotChatUserMessageEditButtonComponent
|
|
30
|
-
} from './copilot-chat-user-message-buttons.component';
|
|
31
|
-
import { CopilotChatUserMessageToolbarComponent } from './copilot-chat-user-message-toolbar.component';
|
|
32
|
-
import { CopilotChatUserMessageBranchNavigationComponent } from './copilot-chat-user-message-branch-navigation.component';
|
|
33
|
-
import { cn } from '../../lib/utils';
|
|
34
|
-
|
|
35
|
-
@Component({
|
|
36
|
-
selector: 'copilot-chat-user-message',
|
|
37
|
-
standalone: true,
|
|
38
|
-
imports: [
|
|
39
|
-
CommonModule,
|
|
40
|
-
CopilotSlotComponent,
|
|
41
|
-
CopilotChatUserMessageRendererComponent,
|
|
42
|
-
CopilotChatUserMessageCopyButtonComponent,
|
|
43
|
-
CopilotChatUserMessageEditButtonComponent,
|
|
44
|
-
CopilotChatUserMessageToolbarComponent,
|
|
45
|
-
CopilotChatUserMessageBranchNavigationComponent
|
|
46
|
-
],
|
|
47
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
48
|
-
encapsulation: ViewEncapsulation.None,
|
|
49
|
-
template: `
|
|
50
|
-
<div
|
|
51
|
-
[class]="computedClass()"
|
|
52
|
-
[attr.data-message-id]="message.id">
|
|
53
|
-
|
|
54
|
-
<!-- Message Renderer -->
|
|
55
|
-
@if (messageRendererTemplate || messageRendererComponent) {
|
|
56
|
-
<copilot-slot
|
|
57
|
-
[slot]="messageRendererTemplate || messageRendererComponent"
|
|
58
|
-
[context]="messageRendererContext()"
|
|
59
|
-
[defaultComponent]="CopilotChatUserMessageRendererComponent"
|
|
60
|
-
>
|
|
61
|
-
</copilot-slot>
|
|
62
|
-
} @else {
|
|
63
|
-
<copilot-chat-user-message-renderer
|
|
64
|
-
[content]="message.content || ''"
|
|
65
|
-
[inputClass]="messageRendererClass">
|
|
66
|
-
</copilot-chat-user-message-renderer>
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
<!-- Toolbar -->
|
|
70
|
-
@if (toolbarTemplate || toolbarComponent) {
|
|
71
|
-
<copilot-slot
|
|
72
|
-
[slot]="toolbarTemplate || toolbarComponent"
|
|
73
|
-
[context]="toolbarContext()"
|
|
74
|
-
[defaultComponent]="CopilotChatUserMessageToolbarComponent"
|
|
75
|
-
>
|
|
76
|
-
</copilot-slot>
|
|
77
|
-
} @else {
|
|
78
|
-
<div copilotChatUserMessageToolbar [inputClass]="toolbarClass">
|
|
79
|
-
<div class="flex items-center gap-1 justify-end">
|
|
80
|
-
<!-- Additional toolbar items -->
|
|
81
|
-
@if (additionalToolbarItems) {
|
|
82
|
-
<ng-container *ngTemplateOutlet="additionalToolbarItems"></ng-container>
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
<!-- Copy button -->
|
|
86
|
-
@if (copyButtonTemplate || copyButtonComponent) {
|
|
87
|
-
<copilot-slot
|
|
88
|
-
[slot]="copyButtonTemplate || copyButtonComponent"
|
|
89
|
-
[context]="{ content: message?.content || '' }"
|
|
90
|
-
[outputs]="copyButtonOutputs"
|
|
91
|
-
[defaultComponent]="CopilotChatUserMessageCopyButtonComponent"
|
|
92
|
-
>
|
|
93
|
-
</copilot-slot>
|
|
94
|
-
} @else {
|
|
95
|
-
<copilot-chat-user-message-copy-button
|
|
96
|
-
[content]="message.content"
|
|
97
|
-
[inputClass]="copyButtonClass"
|
|
98
|
-
(clicked)="handleCopy()">
|
|
99
|
-
</copilot-chat-user-message-copy-button>
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
<!-- Edit button -->
|
|
103
|
-
@if (editMessage.observed) {
|
|
104
|
-
@if (editButtonTemplate || editButtonComponent) {
|
|
105
|
-
<copilot-slot
|
|
106
|
-
[slot]="editButtonTemplate || editButtonComponent"
|
|
107
|
-
[context]="{}"
|
|
108
|
-
[outputs]="editButtonOutputs"
|
|
109
|
-
[defaultComponent]="CopilotChatUserMessageEditButtonComponent"
|
|
110
|
-
>
|
|
111
|
-
</copilot-slot>
|
|
112
|
-
} @else {
|
|
113
|
-
<copilot-chat-user-message-edit-button
|
|
114
|
-
[inputClass]="editButtonClass"
|
|
115
|
-
(clicked)="handleEdit()">
|
|
116
|
-
</copilot-chat-user-message-edit-button>
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
<!-- Branch navigation -->
|
|
121
|
-
@if (showBranchNavigation()) {
|
|
122
|
-
@if (branchNavigationTemplate || branchNavigationComponent) {
|
|
123
|
-
<copilot-slot
|
|
124
|
-
[slot]="branchNavigationTemplate || branchNavigationComponent"
|
|
125
|
-
[context]="branchNavigationContext()"
|
|
126
|
-
[defaultComponent]="CopilotChatUserMessageBranchNavigationComponent"
|
|
127
|
-
>
|
|
128
|
-
</copilot-slot>
|
|
129
|
-
} @else {
|
|
130
|
-
<copilot-chat-user-message-branch-navigation
|
|
131
|
-
[currentBranch]="branchIndexSignal()"
|
|
132
|
-
[numberOfBranches]="numberOfBranchesSignal()"
|
|
133
|
-
[message]="message"
|
|
134
|
-
[inputClass]="branchNavigationClass"
|
|
135
|
-
(switchToBranch)="handleSwitchToBranch($event)">
|
|
136
|
-
</copilot-chat-user-message-branch-navigation>
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
}
|
|
142
|
-
</div>
|
|
143
|
-
`,
|
|
144
|
-
styles: [`
|
|
145
|
-
:host {
|
|
146
|
-
display: block;
|
|
147
|
-
width: 100%;
|
|
148
|
-
}
|
|
149
|
-
`]
|
|
150
|
-
})
|
|
151
|
-
export class CopilotChatUserMessageComponent {
|
|
152
|
-
// Capture templates from content projection
|
|
153
|
-
@ContentChild('messageRenderer', { read: TemplateRef }) messageRendererTemplate?: TemplateRef<MessageRendererContext>;
|
|
154
|
-
@ContentChild('toolbar', { read: TemplateRef }) toolbarTemplate?: TemplateRef<ToolbarContext>;
|
|
155
|
-
@ContentChild('copyButton', { read: TemplateRef }) copyButtonTemplate?: TemplateRef<CopyButtonContext>;
|
|
156
|
-
@ContentChild('editButton', { read: TemplateRef }) editButtonTemplate?: TemplateRef<EditButtonContext>;
|
|
157
|
-
@ContentChild('branchNavigation', { read: TemplateRef }) branchNavigationTemplate?: TemplateRef<BranchNavigationContext>;
|
|
158
|
-
|
|
159
|
-
// Props for tweaking default components
|
|
160
|
-
@Input() messageRendererClass?: string;
|
|
161
|
-
@Input() toolbarClass?: string;
|
|
162
|
-
@Input() copyButtonClass?: string;
|
|
163
|
-
@Input() editButtonClass?: string;
|
|
164
|
-
@Input() branchNavigationClass?: string;
|
|
165
|
-
|
|
166
|
-
// Component inputs for overrides
|
|
167
|
-
@Input() messageRendererComponent?: Type<any>;
|
|
168
|
-
@Input() toolbarComponent?: Type<any>;
|
|
169
|
-
@Input() copyButtonComponent?: Type<any>;
|
|
170
|
-
@Input() editButtonComponent?: Type<any>;
|
|
171
|
-
@Input() branchNavigationComponent?: Type<any>;
|
|
172
|
-
|
|
173
|
-
// Regular inputs
|
|
174
|
-
@Input() message!: UserMessage;
|
|
175
|
-
@Input() set branchIndex(val: number | undefined) {
|
|
176
|
-
this.branchIndexSignal.set(val ?? 0);
|
|
177
|
-
}
|
|
178
|
-
@Input() set numberOfBranches(val: number | undefined) {
|
|
179
|
-
this.numberOfBranchesSignal.set(val ?? 1);
|
|
180
|
-
}
|
|
181
|
-
@Input() additionalToolbarItems?: TemplateRef<any>;
|
|
182
|
-
@Input() set inputClass(val: string | undefined) {
|
|
183
|
-
this.customClass.set(val);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Output events
|
|
187
|
-
@Output() editMessage = new EventEmitter<CopilotChatUserMessageOnEditMessageProps>();
|
|
188
|
-
@Output() switchToBranch = new EventEmitter<CopilotChatUserMessageOnSwitchToBranchProps>();
|
|
189
|
-
|
|
190
|
-
// Signals
|
|
191
|
-
branchIndexSignal = signal(0);
|
|
192
|
-
numberOfBranchesSignal = signal(1);
|
|
193
|
-
customClass = signal<string | undefined>(undefined);
|
|
194
|
-
|
|
195
|
-
// Default components
|
|
196
|
-
CopilotChatUserMessageRendererComponent = CopilotChatUserMessageRendererComponent;
|
|
197
|
-
CopilotChatUserMessageToolbarComponent = CopilotChatUserMessageToolbarComponent;
|
|
198
|
-
CopilotChatUserMessageCopyButtonComponent = CopilotChatUserMessageCopyButtonComponent;
|
|
199
|
-
CopilotChatUserMessageEditButtonComponent = CopilotChatUserMessageEditButtonComponent;
|
|
200
|
-
CopilotChatUserMessageBranchNavigationComponent = CopilotChatUserMessageBranchNavigationComponent;
|
|
201
|
-
|
|
202
|
-
// Computed values
|
|
203
|
-
showBranchNavigation = computed(() => {
|
|
204
|
-
const branches = this.numberOfBranchesSignal();
|
|
205
|
-
return branches > 1 && this.switchToBranch.observed;
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
computedClass = computed(() => {
|
|
209
|
-
return cn(
|
|
210
|
-
"flex flex-col items-end group pt-10",
|
|
211
|
-
this.customClass()
|
|
212
|
-
);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// Context for slots (reactive via signals)
|
|
216
|
-
messageRendererContext = computed<MessageRendererContext>(() => ({
|
|
217
|
-
content: this.message?.content || ''
|
|
218
|
-
}));
|
|
219
|
-
|
|
220
|
-
// Output maps for slots
|
|
221
|
-
copyButtonOutputs = { clicked: () => this.handleCopy() };
|
|
222
|
-
editButtonOutputs = { clicked: () => this.handleEdit() };
|
|
223
|
-
|
|
224
|
-
branchNavigationContext = computed<BranchNavigationContext>(() => ({
|
|
225
|
-
currentBranch: this.branchIndexSignal(),
|
|
226
|
-
numberOfBranches: this.numberOfBranchesSignal(),
|
|
227
|
-
onSwitchToBranch: (props) => this.handleSwitchToBranch(props),
|
|
228
|
-
message: this.message
|
|
229
|
-
}));
|
|
230
|
-
|
|
231
|
-
toolbarContext = computed<ToolbarContext>(() => ({
|
|
232
|
-
children: null // Will be populated by the toolbar content
|
|
233
|
-
}));
|
|
234
|
-
|
|
235
|
-
handleCopy(): void {
|
|
236
|
-
// Copy is handled by the button component itself
|
|
237
|
-
// This is just for any additional logic if needed
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
handleEdit(): void {
|
|
241
|
-
this.editMessage.emit({ message: this.message });
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
handleSwitchToBranch(props: CopilotChatUserMessageOnSwitchToBranchProps): void {
|
|
245
|
-
this.switchToBranch.emit(props);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export interface UserMessage {
|
|
2
|
-
id: string;
|
|
3
|
-
content?: string;
|
|
4
|
-
role: 'user';
|
|
5
|
-
timestamp?: Date;
|
|
6
|
-
[key: string]: any; // Allow additional properties
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface CopilotChatUserMessageOnEditMessageProps {
|
|
10
|
-
message: UserMessage;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface CopilotChatUserMessageOnSwitchToBranchProps {
|
|
14
|
-
message: UserMessage;
|
|
15
|
-
branchIndex: number;
|
|
16
|
-
numberOfBranches: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Context interfaces for slots
|
|
20
|
-
export interface MessageRendererContext {
|
|
21
|
-
content: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface CopyButtonContext {
|
|
25
|
-
content?: string;
|
|
26
|
-
copied?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface EditButtonContext {
|
|
30
|
-
// Empty context - click handled via outputs map
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface BranchNavigationContext {
|
|
34
|
-
currentBranch: number;
|
|
35
|
-
numberOfBranches: number;
|
|
36
|
-
onSwitchToBranch?: (props: CopilotChatUserMessageOnSwitchToBranchProps) => void;
|
|
37
|
-
message: UserMessage;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ToolbarContext {
|
|
41
|
-
children?: any;
|
|
42
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
ChangeDetectionStrategy,
|
|
5
|
-
ViewEncapsulation,
|
|
6
|
-
inject,
|
|
7
|
-
} from "@angular/core";
|
|
8
|
-
import { CommonModule } from "@angular/common";
|
|
9
|
-
import { CopilotChatConfigurationService } from "../../core/chat-configuration/chat-configuration.service";
|
|
10
|
-
import { cn } from "../../lib/utils";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Disclaimer component for CopilotChatView
|
|
14
|
-
* Shows configurable disclaimer text below the input
|
|
15
|
-
* Integrates with CopilotChatConfigurationService for labels
|
|
16
|
-
*/
|
|
17
|
-
@Component({
|
|
18
|
-
selector: "copilot-chat-view-disclaimer",
|
|
19
|
-
standalone: true,
|
|
20
|
-
imports: [CommonModule],
|
|
21
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
22
|
-
encapsulation: ViewEncapsulation.None,
|
|
23
|
-
template: `
|
|
24
|
-
<div [class]="computedClass">
|
|
25
|
-
{{ disclaimerText }}
|
|
26
|
-
</div>
|
|
27
|
-
`,
|
|
28
|
-
})
|
|
29
|
-
export class CopilotChatViewDisclaimerComponent {
|
|
30
|
-
@Input() inputClass?: string;
|
|
31
|
-
@Input() text?: string;
|
|
32
|
-
|
|
33
|
-
private configService = inject(CopilotChatConfigurationService);
|
|
34
|
-
|
|
35
|
-
// Get disclaimer text from input or configuration
|
|
36
|
-
get disclaimerText(): string {
|
|
37
|
-
if (this.text) {
|
|
38
|
-
return this.text;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return this.configService.labels().chatDisclaimerText;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Computed class matching React exactly
|
|
45
|
-
get computedClass(): string {
|
|
46
|
-
return cn(
|
|
47
|
-
"text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto",
|
|
48
|
-
this.inputClass
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
ChangeDetectionStrategy,
|
|
5
|
-
ViewEncapsulation
|
|
6
|
-
} from '@angular/core';
|
|
7
|
-
import { CommonModule } from '@angular/common';
|
|
8
|
-
import { cn } from '../../lib/utils';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Feather component for CopilotChatView
|
|
12
|
-
* Creates a gradient overlay effect between messages and input
|
|
13
|
-
* Matches React implementation exactly with same Tailwind classes
|
|
14
|
-
*/
|
|
15
|
-
@Component({
|
|
16
|
-
selector: 'copilot-chat-view-feather',
|
|
17
|
-
standalone: true,
|
|
18
|
-
imports: [CommonModule],
|
|
19
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
|
-
encapsulation: ViewEncapsulation.None,
|
|
21
|
-
template: `
|
|
22
|
-
<div
|
|
23
|
-
[class]="computedClass"
|
|
24
|
-
[style]="style">
|
|
25
|
-
</div>
|
|
26
|
-
`
|
|
27
|
-
})
|
|
28
|
-
export class CopilotChatViewFeatherComponent {
|
|
29
|
-
@Input() inputClass?: string;
|
|
30
|
-
@Input() style?: { [key: string]: any };
|
|
31
|
-
|
|
32
|
-
// Computed class matching React exactly
|
|
33
|
-
get computedClass(): string {
|
|
34
|
-
return cn(
|
|
35
|
-
// Positioning
|
|
36
|
-
'absolute bottom-0 left-0 right-4 h-24 pointer-events-none z-10',
|
|
37
|
-
// Gradient
|
|
38
|
-
'bg-gradient-to-t',
|
|
39
|
-
// Light mode colors
|
|
40
|
-
'from-white via-white to-transparent',
|
|
41
|
-
// Dark mode colors
|
|
42
|
-
'dark:from-[rgb(33,33,33)] dark:via-[rgb(33,33,33)]',
|
|
43
|
-
// Custom classes
|
|
44
|
-
this.inputClass
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Injectable, signal } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Injectable({ providedIn: 'root' })
|
|
4
|
-
export class CopilotChatViewHandlersService {
|
|
5
|
-
// Assistant message handler availability
|
|
6
|
-
hasAssistantThumbsUpHandler = signal(false);
|
|
7
|
-
hasAssistantThumbsDownHandler = signal(false);
|
|
8
|
-
hasAssistantReadAloudHandler = signal(false);
|
|
9
|
-
hasAssistantRegenerateHandler = signal(false);
|
|
10
|
-
|
|
11
|
-
// User message handler availability
|
|
12
|
-
hasUserCopyHandler = signal(false);
|
|
13
|
-
hasUserEditHandler = signal(false);
|
|
14
|
-
}
|