@copilotkitnext/angular 0.0.2 → 0.0.4

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.
Files changed (168) hide show
  1. package/README.md +3 -3
  2. package/dist/README.md +3 -3
  3. package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +10 -10
  4. package/dist/components/chat/copilot-chat-message-view.component.d.ts +42 -42
  5. package/dist/components/chat/copilot-chat-view.component.d.ts +14 -14
  6. package/dist/esm2022/components/chat/copilot-chat-assistant-message-buttons.component.mjs +384 -0
  7. package/dist/esm2022/components/chat/copilot-chat-assistant-message-renderer.component.mjs +286 -0
  8. package/dist/esm2022/components/chat/copilot-chat-assistant-message-toolbar.component.mjs +27 -0
  9. package/dist/esm2022/components/chat/copilot-chat-assistant-message.component.mjs +433 -0
  10. package/dist/esm2022/components/chat/copilot-chat-assistant-message.types.mjs +2 -0
  11. package/dist/esm2022/components/chat/copilot-chat-audio-recorder.component.mjs +202 -0
  12. package/dist/esm2022/components/chat/copilot-chat-buttons.component.mjs +321 -0
  13. package/dist/esm2022/components/chat/copilot-chat-input-defaults.mjs +38 -0
  14. package/dist/esm2022/components/chat/copilot-chat-input.component.mjs +666 -0
  15. package/dist/esm2022/components/chat/copilot-chat-input.types.mjs +10 -0
  16. package/dist/esm2022/components/chat/copilot-chat-message-view-cursor.component.mjs +45 -0
  17. package/dist/esm2022/components/chat/copilot-chat-message-view.component.mjs +296 -0
  18. package/dist/esm2022/components/chat/copilot-chat-message-view.types.mjs +2 -0
  19. package/dist/esm2022/components/chat/copilot-chat-textarea.component.mjs +188 -0
  20. package/dist/esm2022/components/chat/copilot-chat-tool-calls-view.component.mjs +216 -0
  21. package/dist/esm2022/components/chat/copilot-chat-toolbar.component.mjs +25 -0
  22. package/dist/esm2022/components/chat/copilot-chat-tools-menu.component.mjs +199 -0
  23. package/dist/esm2022/components/chat/copilot-chat-user-message-branch-navigation.component.mjs +137 -0
  24. package/dist/esm2022/components/chat/copilot-chat-user-message-buttons.component.mjs +207 -0
  25. package/dist/esm2022/components/chat/copilot-chat-user-message-renderer.component.mjs +35 -0
  26. package/dist/esm2022/components/chat/copilot-chat-user-message-toolbar.component.mjs +34 -0
  27. package/dist/esm2022/components/chat/copilot-chat-user-message.component.mjs +341 -0
  28. package/dist/esm2022/components/chat/copilot-chat-user-message.types.mjs +2 -0
  29. package/dist/esm2022/components/chat/copilot-chat-view-disclaimer.component.mjs +52 -0
  30. package/dist/esm2022/components/chat/copilot-chat-view-feather.component.mjs +55 -0
  31. package/dist/esm2022/components/chat/copilot-chat-view-handlers.service.mjs +19 -0
  32. package/dist/esm2022/components/chat/copilot-chat-view-input-container.component.mjs +110 -0
  33. package/dist/esm2022/components/chat/copilot-chat-view-scroll-to-bottom-button.component.mjs +93 -0
  34. package/dist/esm2022/components/chat/copilot-chat-view-scroll-view.component.mjs +443 -0
  35. package/dist/esm2022/components/chat/copilot-chat-view.component.mjs +479 -0
  36. package/dist/esm2022/components/chat/copilot-chat-view.types.mjs +2 -0
  37. package/dist/esm2022/components/chat/copilot-chat.component.mjs +214 -0
  38. package/dist/esm2022/components/copilotkit-tool-render.component.mjs +153 -0
  39. package/dist/esm2022/copilotkitnext-angular.mjs +5 -0
  40. package/dist/esm2022/core/chat-configuration/chat-configuration.providers.mjs +65 -0
  41. package/dist/esm2022/core/chat-configuration/chat-configuration.service.mjs +145 -0
  42. package/dist/esm2022/core/chat-configuration/chat-configuration.types.mjs +26 -0
  43. package/dist/esm2022/core/copilotkit.providers.mjs +34 -0
  44. package/dist/esm2022/core/copilotkit.service.mjs +430 -0
  45. package/dist/esm2022/core/copilotkit.types.mjs +12 -0
  46. package/dist/esm2022/directives/copilotkit-agent-context.directive.mjs +130 -0
  47. package/dist/esm2022/directives/copilotkit-agent.directive.mjs +217 -0
  48. package/dist/esm2022/directives/copilotkit-chat-config.directive.mjs +218 -0
  49. package/dist/esm2022/directives/copilotkit-config.directive.mjs +94 -0
  50. package/dist/esm2022/directives/copilotkit-frontend-tool.directive.mjs +130 -0
  51. package/dist/esm2022/directives/copilotkit-human-in-the-loop.directive.mjs +266 -0
  52. package/dist/esm2022/directives/stick-to-bottom.directive.mjs +181 -0
  53. package/dist/esm2022/index.mjs +70 -0
  54. package/dist/esm2022/lib/directives/tooltip.directive.mjs +211 -0
  55. package/dist/esm2022/lib/slots/copilot-slot.component.mjs +144 -0
  56. package/dist/esm2022/lib/slots/slot.types.mjs +6 -0
  57. package/dist/esm2022/lib/slots/slot.utils.mjs +222 -0
  58. package/dist/esm2022/lib/utils.mjs +10 -0
  59. package/dist/esm2022/services/resize-observer.service.mjs +152 -0
  60. package/dist/esm2022/services/scroll-position.service.mjs +124 -0
  61. package/dist/esm2022/types/frontend-tool.mjs +2 -0
  62. package/dist/esm2022/types/human-in-the-loop.mjs +2 -0
  63. package/dist/esm2022/utils/agent-context.utils.mjs +114 -0
  64. package/dist/esm2022/utils/agent.utils.mjs +204 -0
  65. package/dist/esm2022/utils/chat-config.utils.mjs +186 -0
  66. package/dist/esm2022/utils/copilotkit.utils.mjs +20 -0
  67. package/dist/esm2022/utils/frontend-tool.utils.mjs +228 -0
  68. package/dist/esm2022/utils/human-in-the-loop.utils.mjs +296 -0
  69. package/dist/fesm2022/copilotkitnext-angular.mjs +163 -164
  70. package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -1
  71. package/package.json +21 -18
  72. package/vitest.config.mts +32 -21
  73. package/.turbo/turbo-build.log +0 -38
  74. package/.turbo/turbo-check-types.log +0 -0
  75. package/.turbo/turbo-test.log +0 -71
  76. package/ng-package.json +0 -19
  77. package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +0 -282
  78. package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +0 -419
  79. package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +0 -372
  80. package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +0 -249
  81. package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +0 -292
  82. package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +0 -472
  83. package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +0 -29
  84. package/src/components/chat/copilot-chat-assistant-message.component.ts +0 -463
  85. package/src/components/chat/copilot-chat-assistant-message.types.ts +0 -50
  86. package/src/components/chat/copilot-chat-audio-recorder.component.ts +0 -241
  87. package/src/components/chat/copilot-chat-buttons.component.ts +0 -308
  88. package/src/components/chat/copilot-chat-buttons.component.ts.bak +0 -471
  89. package/src/components/chat/copilot-chat-input-defaults.ts +0 -47
  90. package/src/components/chat/copilot-chat-input.component.ts +0 -512
  91. package/src/components/chat/copilot-chat-input.types.ts +0 -148
  92. package/src/components/chat/copilot-chat-message-view-cursor.component.ts +0 -51
  93. package/src/components/chat/copilot-chat-message-view.component.ts +0 -233
  94. package/src/components/chat/copilot-chat-message-view.types.ts +0 -39
  95. package/src/components/chat/copilot-chat-textarea.component.ts +0 -220
  96. package/src/components/chat/copilot-chat-tool-calls-view.component.ts +0 -261
  97. package/src/components/chat/copilot-chat-toolbar.component.ts +0 -35
  98. package/src/components/chat/copilot-chat-tools-menu.component.ts +0 -185
  99. package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +0 -121
  100. package/src/components/chat/copilot-chat-user-message-buttons.component.ts +0 -170
  101. package/src/components/chat/copilot-chat-user-message-renderer.component.ts +0 -37
  102. package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +0 -37
  103. package/src/components/chat/copilot-chat-user-message.component.ts +0 -247
  104. package/src/components/chat/copilot-chat-user-message.types.ts +0 -42
  105. package/src/components/chat/copilot-chat-view-disclaimer.component.ts +0 -51
  106. package/src/components/chat/copilot-chat-view-feather.component.ts +0 -47
  107. package/src/components/chat/copilot-chat-view-handlers.service.ts +0 -14
  108. package/src/components/chat/copilot-chat-view-input-container.component.ts +0 -87
  109. package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +0 -79
  110. package/src/components/chat/copilot-chat-view-scroll-view.component.ts +0 -322
  111. package/src/components/chat/copilot-chat-view.component.ts +0 -420
  112. package/src/components/chat/copilot-chat-view.types.ts +0 -52
  113. package/src/components/chat/copilot-chat.component.ts +0 -232
  114. package/src/components/copilotkit-tool-render.component.ts +0 -169
  115. package/src/core/__tests__/copilotkit.service.spec.ts +0 -1051
  116. package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +0 -316
  117. package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +0 -287
  118. package/src/core/chat-configuration/chat-configuration.providers.ts +0 -71
  119. package/src/core/chat-configuration/chat-configuration.service.ts +0 -162
  120. package/src/core/chat-configuration/chat-configuration.types.ts +0 -57
  121. package/src/core/copilotkit.providers.ts +0 -59
  122. package/src/core/copilotkit.service.ts +0 -542
  123. package/src/core/copilotkit.types.ts +0 -132
  124. package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +0 -384
  125. package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +0 -253
  126. package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +0 -385
  127. package/src/directives/__tests__/copilotkit-config.directive.spec.ts +0 -69
  128. package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +0 -60
  129. package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +0 -108
  130. package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +0 -452
  131. package/src/directives/copilotkit-agent-context.directive.ts +0 -138
  132. package/src/directives/copilotkit-agent.directive.ts +0 -225
  133. package/src/directives/copilotkit-chat-config.directive.ts +0 -241
  134. package/src/directives/copilotkit-config.directive.ts +0 -81
  135. package/src/directives/copilotkit-frontend-tool.directive.ts +0 -145
  136. package/src/directives/copilotkit-human-in-the-loop.directive.ts +0 -281
  137. package/src/directives/stick-to-bottom.directive.ts +0 -204
  138. package/src/index.ts +0 -105
  139. package/src/lib/directives/tooltip.directive.ts +0 -292
  140. package/src/lib/slots/__tests__/slot.utils.spec.ts +0 -377
  141. package/src/lib/slots/copilot-slot.component.ts +0 -135
  142. package/src/lib/slots/index.ts +0 -3
  143. package/src/lib/slots/slot.types.ts +0 -64
  144. package/src/lib/slots/slot.utils.ts +0 -289
  145. package/src/lib/utils.ts +0 -10
  146. package/src/public-api.ts +0 -1
  147. package/src/services/resize-observer.service.ts +0 -181
  148. package/src/services/scroll-position.service.ts +0 -169
  149. package/src/styles/globals.css +0 -266
  150. package/src/styles/index.css +0 -3
  151. package/src/test-setup.ts +0 -15
  152. package/src/testing/index.ts +0 -3
  153. package/src/testing/testing.utils.ts +0 -248
  154. package/src/types/frontend-tool.ts +0 -44
  155. package/src/types/human-in-the-loop.ts +0 -52
  156. package/src/utils/__tests__/agent.utils.spec.ts +0 -234
  157. package/src/utils/__tests__/chat-config.utils.spec.ts +0 -306
  158. package/src/utils/__tests__/frontend-tool-inject.spec.ts +0 -350
  159. package/src/utils/__tests__/frontend-tool-integration.spec.ts +0 -199
  160. package/src/utils/__tests__/frontend-tool.utils.spec.ts +0 -272
  161. package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +0 -365
  162. package/src/utils/agent-context.utils.ts +0 -133
  163. package/src/utils/agent.utils.ts +0 -239
  164. package/src/utils/chat-config.utils.ts +0 -221
  165. package/src/utils/copilotkit.utils.ts +0 -20
  166. package/src/utils/frontend-tool.utils.ts +0 -266
  167. package/src/utils/human-in-the-loop.utils.ts +0 -359
  168. package/tsconfig.spec.json +0 -12
@@ -1,241 +0,0 @@
1
- import {
2
- Component,
3
- Input,
4
- Output,
5
- EventEmitter,
6
- ViewChild,
7
- ElementRef,
8
- AfterViewInit,
9
- OnDestroy,
10
- signal,
11
- computed,
12
- ChangeDetectionStrategy,
13
- ViewEncapsulation
14
- } from '@angular/core';
15
- import { AudioRecorderState, AudioRecorderError } from './copilot-chat-input.types';
16
-
17
- @Component({
18
- selector: 'copilot-chat-audio-recorder',
19
- standalone: true,
20
- changeDetection: ChangeDetectionStrategy.OnPush,
21
- encapsulation: ViewEncapsulation.None,
22
- template: `
23
- <div [class]="computedClass()">
24
- <canvas
25
- #canvasRef
26
- class="w-full h-full"
27
- [style.imageRendering]="'pixelated'"
28
- ></canvas>
29
- </div>
30
- `,
31
- styles: [],
32
- host: {
33
- '[class.copilot-chat-audio-recorder]': 'true'
34
- }
35
- })
36
- export class CopilotChatAudioRecorderComponent implements AfterViewInit, OnDestroy {
37
- @ViewChild('canvasRef', { static: true }) canvasRef!: ElementRef<HTMLCanvasElement>;
38
-
39
- @Input() set inputClass(val: string | undefined) {
40
- this.customClass.set(val);
41
- }
42
-
43
- @Input() set inputShowControls(val: boolean | undefined) {
44
- this.showControls.set(val ?? false);
45
- }
46
-
47
- @Output() stateChange = new EventEmitter<AudioRecorderState>();
48
- @Output() error = new EventEmitter<AudioRecorderError>();
49
-
50
- // Signals for state management
51
- state = signal<AudioRecorderState>('idle');
52
- customClass = signal<string | undefined>(undefined);
53
- showControls = signal<boolean>(false);
54
-
55
- // Computed values
56
- computedClass = computed(() => {
57
- const baseClasses = 'h-11 w-full px-5';
58
- return `${baseClasses} ${this.customClass() || ''}`;
59
- });
60
-
61
- statusText = computed(() => {
62
- switch (this.state()) {
63
- case 'recording':
64
- return 'Recording...';
65
- case 'processing':
66
- return 'Processing...';
67
- default:
68
- return 'Ready';
69
- }
70
- });
71
-
72
- // Animation and canvas properties
73
- private animationFrameId?: number;
74
-
75
- ngAfterViewInit(): void {
76
- this.startAnimation();
77
- }
78
-
79
- ngOnDestroy(): void {
80
- this.dispose();
81
- }
82
-
83
- /**
84
- * Start recording audio
85
- */
86
- async start(): Promise<void> {
87
- try {
88
- if (this.state() === 'recording') {
89
- return;
90
- }
91
-
92
- this.setState('recording');
93
- this.startAnimation();
94
-
95
- // In a real implementation, this would start actual audio recording
96
- // For now, we just simulate the recording state
97
-
98
- } catch (err) {
99
- const error = new AudioRecorderError(
100
- err instanceof Error ? err.message : 'Failed to start recording'
101
- );
102
- this.error.emit(error);
103
- this.setState('idle');
104
- throw error;
105
- }
106
- }
107
-
108
- /**
109
- * Stop recording audio and return blob
110
- */
111
- async stop(): Promise<Blob> {
112
- try {
113
- this.setState('idle');
114
- // Return empty blob - stub implementation
115
- const emptyBlob = new Blob([], { type: 'audio/webm' });
116
- return emptyBlob;
117
- } catch (err) {
118
- const error = new AudioRecorderError(
119
- err instanceof Error ? err.message : 'Failed to stop recording'
120
- );
121
- this.error.emit(error);
122
- this.setState('idle');
123
- throw error;
124
- }
125
- }
126
-
127
- /**
128
- * Get current recorder state
129
- */
130
- getState(): AudioRecorderState {
131
- return this.state();
132
- }
133
-
134
- /**
135
- * Dispose of resources
136
- */
137
- dispose(): void {
138
- this.stopAnimation();
139
- }
140
-
141
- private setState(state: AudioRecorderState): void {
142
- this.state.set(state);
143
- this.stateChange.emit(state);
144
- }
145
-
146
- private startAnimation(): void {
147
- const canvas = this.canvasRef.nativeElement;
148
- if (!canvas) return;
149
-
150
- const ctx = canvas.getContext('2d');
151
- if (!ctx) return;
152
-
153
- const draw = () => {
154
- const rect = canvas.getBoundingClientRect();
155
- const dpr = window.devicePixelRatio || 1;
156
-
157
- // Update canvas dimensions if container resized
158
- if (
159
- canvas.width !== rect.width * dpr ||
160
- canvas.height !== rect.height * dpr
161
- ) {
162
- canvas.width = rect.width * dpr;
163
- canvas.height = rect.height * dpr;
164
- ctx.scale(dpr, dpr);
165
- ctx.imageSmoothingEnabled = false;
166
- }
167
-
168
- // Configuration
169
- const barWidth = 2;
170
- const minHeight = 2;
171
- const maxHeight = 20;
172
- const gap = 2;
173
- const numSamples = Math.ceil(rect.width / (barWidth + gap));
174
-
175
- // Get loudness data
176
- const loudnessData = this.getLoudness(numSamples);
177
-
178
- // Clear canvas
179
- ctx.clearRect(0, 0, rect.width, rect.height);
180
-
181
- // Get current foreground color
182
- const computedStyle = getComputedStyle(canvas);
183
- const currentForeground = computedStyle.color;
184
-
185
- // Draw bars
186
- ctx.fillStyle = currentForeground;
187
- const centerY = rect.height / 2;
188
-
189
- for (let i = 0; i < loudnessData.length; i++) {
190
- const sample = loudnessData[i] ?? 0;
191
- const barHeight = Math.round(
192
- sample * (maxHeight - minHeight) + minHeight
193
- );
194
- const x = Math.round(i * (barWidth + gap));
195
- const y = Math.round(centerY - barHeight / 2);
196
-
197
- ctx.fillRect(x, y, barWidth, barHeight);
198
- }
199
-
200
- this.animationFrameId = requestAnimationFrame(draw);
201
- };
202
-
203
- draw();
204
- }
205
-
206
- private stopAnimation(): void {
207
- if (this.animationFrameId) {
208
- cancelAnimationFrame(this.animationFrameId);
209
- this.animationFrameId = undefined;
210
- }
211
- }
212
-
213
- private getLoudness(n: number): number[] {
214
- const elapsed = Date.now() / 1000; // Use current timestamp directly
215
- const samples: number[] = [];
216
-
217
- for (let i = 0; i < n; i++) {
218
- // Create a position that moves from left to right over time
219
- const position = (i / n) * 10 + elapsed * 0.5; // Scroll speed (slower)
220
-
221
- // Generate waveform using multiple sine waves for realism
222
- const wave1 = Math.sin(position * 2) * 0.3;
223
- const wave2 = Math.sin(position * 5 + elapsed) * 0.2;
224
- const wave3 = Math.sin(position * 0.5 + elapsed * 0.3) * 0.4;
225
-
226
- // Add some randomness for natural variation
227
- const noise = (Math.random() - 0.5) * 0.1;
228
-
229
- // Combine waves and add envelope for realistic amplitude variation
230
- const envelope = Math.sin(elapsed * 0.7) * 0.5 + 0.5; // Slow amplitude modulation
231
- let amplitude = (wave1 + wave2 + wave3 + noise) * envelope;
232
-
233
- // Clamp to 0-1 range
234
- amplitude = Math.max(0, Math.min(1, amplitude * 0.5 + 0.3));
235
-
236
- samples.push(amplitude);
237
- }
238
-
239
- return samples;
240
- }
241
- }
@@ -1,308 +0,0 @@
1
- import {
2
- Component,
3
- Input,
4
- Output,
5
- EventEmitter,
6
- ChangeDetectionStrategy,
7
- inject,
8
- signal,
9
- computed,
10
- ViewEncapsulation
11
- } from '@angular/core';
12
- import { CommonModule } from '@angular/common';
13
- import {
14
- LucideAngularModule,
15
- ArrowUp,
16
- Mic,
17
- X,
18
- Check,
19
- Plus
20
- } from 'lucide-angular';
21
- import { CopilotChatConfigurationService } from '../../core/chat-configuration/chat-configuration.service';
22
- import { CopilotTooltipDirective } from '../../lib/directives/tooltip.directive';
23
- import { cn } from '../../lib/utils';
24
-
25
- // Base button classes matching React's button variants
26
- const buttonBase = cn(
27
- 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium',
28
- 'transition-all disabled:pointer-events-none disabled:opacity-50',
29
- 'shrink-0 outline-none',
30
- 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]'
31
- );
32
-
33
- const chatInputToolbarPrimary = cn(
34
- 'cursor-pointer',
35
- // Background and text
36
- 'bg-black text-white',
37
- // Dark mode
38
- 'dark:bg-white dark:text-black dark:focus-visible:outline-white',
39
- // Shape and sizing
40
- 'rounded-full h-9 w-9',
41
- // Interactions
42
- 'transition-colors',
43
- // Focus states
44
- 'focus:outline-none',
45
- // Hover states
46
- 'hover:opacity-70 disabled:hover:opacity-100',
47
- // Disabled states
48
- 'disabled:cursor-not-allowed disabled:bg-[#00000014] disabled:text-[rgb(13,13,13)]',
49
- 'dark:disabled:bg-[#454545] dark:disabled:text-white'
50
- );
51
-
52
- const chatInputToolbarSecondary = cn(
53
- 'cursor-pointer',
54
- // Background and text
55
- 'bg-transparent text-[#444444]',
56
- // Dark mode
57
- 'dark:text-white dark:border-[#404040]',
58
- // Shape and sizing
59
- 'rounded-full h-9 w-9',
60
- // Interactions
61
- 'transition-colors',
62
- // Focus states
63
- 'focus:outline-none',
64
- // Hover states
65
- 'hover:bg-[#f8f8f8] hover:text-[#333333]',
66
- 'dark:hover:bg-[#404040] dark:hover:text-[#FFFFFF]',
67
- // Disabled states
68
- 'disabled:cursor-not-allowed disabled:opacity-50',
69
- 'disabled:hover:bg-transparent disabled:hover:text-[#444444]',
70
- 'dark:disabled:hover:bg-transparent dark:disabled:hover:text-[#CCCCCC]'
71
- );
72
-
73
- @Component({
74
- selector: 'copilot-chat-send-button',
75
- standalone: true,
76
- imports: [CommonModule, LucideAngularModule],
77
- changeDetection: ChangeDetectionStrategy.OnPush,
78
- encapsulation: ViewEncapsulation.None,
79
- template: `
80
- <div class="mr-[10px]">
81
- <button
82
- type="button"
83
- [disabled]="disabled"
84
- [class]="buttonClass"
85
- (click)="onClick()"
86
- >
87
- <lucide-angular [img]="ArrowUpIcon" [size]="18"></lucide-angular>
88
- </button>
89
- </div>
90
- `,
91
- styles: [``]
92
- })
93
- export class CopilotChatSendButtonComponent {
94
- @Input() disabled = false;
95
- @Output() clicked = new EventEmitter<void>();
96
-
97
- readonly ArrowUpIcon = ArrowUp;
98
- buttonClass = cn(buttonBase, chatInputToolbarPrimary);
99
-
100
- onClick(): void {
101
- if (!this.disabled) {
102
- this.clicked.emit();
103
- }
104
- }
105
- }
106
-
107
- @Component({
108
- selector: 'copilot-chat-start-transcribe-button',
109
- standalone: true,
110
- imports: [CommonModule, LucideAngularModule, CopilotTooltipDirective],
111
- changeDetection: ChangeDetectionStrategy.OnPush,
112
- encapsulation: ViewEncapsulation.None,
113
- template: `
114
- <button
115
- type="button"
116
- [disabled]="disabled"
117
- [class]="buttonClass"
118
- [copilotTooltip]="label"
119
- tooltipPosition="below"
120
- (click)="onClick()"
121
- >
122
- <lucide-angular [img]="MicIcon" [size]="18"></lucide-angular>
123
- </button>
124
- `,
125
- styles: [``]
126
- })
127
- export class CopilotChatStartTranscribeButtonComponent {
128
- @Input() disabled = false;
129
- @Output() clicked = new EventEmitter<void>();
130
-
131
- private chatConfig = inject(CopilotChatConfigurationService);
132
-
133
- readonly MicIcon = Mic;
134
- buttonClass = cn(buttonBase, chatInputToolbarSecondary, 'mr-2');
135
-
136
- get label(): string {
137
- return this.chatConfig.labels().chatInputToolbarStartTranscribeButtonLabel;
138
- }
139
-
140
- onClick(): void {
141
- if (!this.disabled) {
142
- this.clicked.emit();
143
- }
144
- }
145
- }
146
-
147
- @Component({
148
- selector: 'copilot-chat-cancel-transcribe-button',
149
- standalone: true,
150
- imports: [CommonModule, LucideAngularModule, CopilotTooltipDirective],
151
- changeDetection: ChangeDetectionStrategy.OnPush,
152
- encapsulation: ViewEncapsulation.None,
153
- template: `
154
- <button
155
- type="button"
156
- [disabled]="disabled"
157
- [class]="buttonClass"
158
- [copilotTooltip]="label"
159
- tooltipPosition="below"
160
- (click)="onClick()"
161
- >
162
- <lucide-angular [img]="XIcon" [size]="18"></lucide-angular>
163
- </button>
164
- `,
165
- styles: [``]
166
- })
167
- export class CopilotChatCancelTranscribeButtonComponent {
168
- @Input() disabled = false;
169
- @Output() clicked = new EventEmitter<void>();
170
-
171
- private chatConfig = inject(CopilotChatConfigurationService);
172
-
173
- readonly XIcon = X;
174
- buttonClass = cn(buttonBase, chatInputToolbarSecondary, 'mr-2');
175
-
176
- get label(): string {
177
- return this.chatConfig.labels().chatInputToolbarCancelTranscribeButtonLabel;
178
- }
179
-
180
- onClick(): void {
181
- if (!this.disabled) {
182
- this.clicked.emit();
183
- }
184
- }
185
- }
186
-
187
- @Component({
188
- selector: 'copilot-chat-finish-transcribe-button',
189
- standalone: true,
190
- imports: [CommonModule, LucideAngularModule, CopilotTooltipDirective],
191
- changeDetection: ChangeDetectionStrategy.OnPush,
192
- encapsulation: ViewEncapsulation.None,
193
- template: `
194
- <button
195
- type="button"
196
- [disabled]="disabled"
197
- [class]="buttonClass"
198
- [copilotTooltip]="label"
199
- tooltipPosition="below"
200
- (click)="onClick()"
201
- >
202
- <lucide-angular [img]="CheckIcon" [size]="18"></lucide-angular>
203
- </button>
204
- `,
205
- styles: [``]
206
- })
207
- export class CopilotChatFinishTranscribeButtonComponent {
208
- @Input() disabled = false;
209
- @Output() clicked = new EventEmitter<void>();
210
-
211
- private chatConfig = inject(CopilotChatConfigurationService);
212
-
213
- readonly CheckIcon = Check;
214
- buttonClass = cn(buttonBase, chatInputToolbarSecondary, 'mr-[10px]');
215
-
216
- get label(): string {
217
- return this.chatConfig.labels().chatInputToolbarFinishTranscribeButtonLabel;
218
- }
219
-
220
- onClick(): void {
221
- if (!this.disabled) {
222
- this.clicked.emit();
223
- }
224
- }
225
- }
226
-
227
- @Component({
228
- selector: 'copilot-chat-add-file-button',
229
- standalone: true,
230
- imports: [CommonModule, LucideAngularModule, CopilotTooltipDirective],
231
- changeDetection: ChangeDetectionStrategy.OnPush,
232
- encapsulation: ViewEncapsulation.None,
233
- template: `
234
- <button
235
- type="button"
236
- [disabled]="disabled"
237
- [class]="buttonClass"
238
- [copilotTooltip]="label"
239
- tooltipPosition="below"
240
- (click)="onClick()"
241
- >
242
- <lucide-angular [img]="PlusIcon" [size]="20"></lucide-angular>
243
- </button>
244
- `,
245
- styles: [``]
246
- })
247
- export class CopilotChatAddFileButtonComponent {
248
- @Input() disabled = false;
249
- @Output() clicked = new EventEmitter<void>();
250
-
251
- private chatConfig = inject(CopilotChatConfigurationService);
252
-
253
- readonly PlusIcon = Plus;
254
- buttonClass = cn(buttonBase, chatInputToolbarSecondary, 'ml-2');
255
-
256
- get label(): string {
257
- return this.chatConfig.labels().chatInputToolbarAddButtonLabel;
258
- }
259
-
260
- onClick(): void {
261
- if (!this.disabled) {
262
- this.clicked.emit();
263
- }
264
- }
265
- }
266
-
267
- // Base toolbar button component that other buttons can use
268
- @Component({
269
- selector: 'copilot-chat-toolbar-button',
270
- standalone: true,
271
- imports: [CommonModule, CopilotTooltipDirective],
272
- changeDetection: ChangeDetectionStrategy.OnPush,
273
- encapsulation: ViewEncapsulation.None,
274
- template: `
275
- <button
276
- type="button"
277
- [disabled]="disabled()"
278
- [class]="computedClass()"
279
- [copilotTooltip]="title()"
280
- tooltipPosition="below"
281
- (click)="onClick()"
282
- >
283
- <ng-content></ng-content>
284
- </button>
285
- `,
286
- styles: [``]
287
- })
288
- export class CopilotChatToolbarButtonComponent {
289
- disabled = signal(false);
290
- variant = signal<'primary' | 'secondary'>('secondary');
291
- customClass = signal('');
292
- title = signal('');
293
-
294
- @Output() clicked = new EventEmitter<void>();
295
-
296
- computedClass = computed(() => {
297
- const variantClass = this.variant() === 'primary'
298
- ? chatInputToolbarPrimary
299
- : chatInputToolbarSecondary;
300
- return cn(buttonBase, variantClass, this.customClass());
301
- });
302
-
303
- onClick(): void {
304
- if (!this.disabled()) {
305
- this.clicked.emit();
306
- }
307
- }
308
- }