@copilotkitnext/angular 0.0.1

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 (169) hide show
  1. package/.turbo/turbo-build.log +39 -0
  2. package/.turbo/turbo-check-types.log +0 -0
  3. package/.turbo/turbo-test.log +71 -0
  4. package/LICENSE +10 -0
  5. package/README-agent-context.md +310 -0
  6. package/dist/LICENSE +10 -0
  7. package/dist/components/chat/copilot-chat-assistant-message-buttons.component.d.ts +75 -0
  8. package/dist/components/chat/copilot-chat-assistant-message-renderer.component.d.ts +31 -0
  9. package/dist/components/chat/copilot-chat-assistant-message-toolbar.component.d.ts +8 -0
  10. package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +131 -0
  11. package/dist/components/chat/copilot-chat-assistant-message.types.d.ts +31 -0
  12. package/dist/components/chat/copilot-chat-audio-recorder.component.d.ts +40 -0
  13. package/dist/components/chat/copilot-chat-buttons.component.d.ts +66 -0
  14. package/dist/components/chat/copilot-chat-input-defaults.d.ts +37 -0
  15. package/dist/components/chat/copilot-chat-input.component.d.ts +133 -0
  16. package/dist/components/chat/copilot-chat-input.types.d.ts +129 -0
  17. package/dist/components/chat/copilot-chat-message-view-cursor.component.d.ts +15 -0
  18. package/dist/components/chat/copilot-chat-message-view.component.d.ts +293 -0
  19. package/dist/components/chat/copilot-chat-message-view.types.d.ts +24 -0
  20. package/dist/components/chat/copilot-chat-textarea.component.d.ts +45 -0
  21. package/dist/components/chat/copilot-chat-tool-calls-view.component.d.ts +35 -0
  22. package/dist/components/chat/copilot-chat-toolbar.component.d.ts +8 -0
  23. package/dist/components/chat/copilot-chat-tools-menu.component.d.ts +20 -0
  24. package/dist/components/chat/copilot-chat-user-message-branch-navigation.component.d.ts +23 -0
  25. package/dist/components/chat/copilot-chat-user-message-buttons.component.d.ts +39 -0
  26. package/dist/components/chat/copilot-chat-user-message-renderer.component.d.ts +9 -0
  27. package/dist/components/chat/copilot-chat-user-message-toolbar.component.d.ts +8 -0
  28. package/dist/components/chat/copilot-chat-user-message.component.d.ts +55 -0
  29. package/dist/components/chat/copilot-chat-user-message.types.d.ts +33 -0
  30. package/dist/components/chat/copilot-chat-view-disclaimer.component.d.ts +15 -0
  31. package/dist/components/chat/copilot-chat-view-feather.component.d.ts +15 -0
  32. package/dist/components/chat/copilot-chat-view-handlers.service.d.ts +11 -0
  33. package/dist/components/chat/copilot-chat-view-input-container.component.d.ts +23 -0
  34. package/dist/components/chat/copilot-chat-view-scroll-to-bottom-button.component.d.ts +17 -0
  35. package/dist/components/chat/copilot-chat-view-scroll-view.component.d.ts +84 -0
  36. package/dist/components/chat/copilot-chat-view.component.d.ts +205 -0
  37. package/dist/components/chat/copilot-chat-view.types.d.ts +42 -0
  38. package/dist/components/chat/copilot-chat.component.d.ts +37 -0
  39. package/dist/components/copilotkit-tool-render.component.d.ts +25 -0
  40. package/dist/core/chat-configuration/chat-configuration.providers.d.ts +54 -0
  41. package/dist/core/chat-configuration/chat-configuration.service.d.ts +75 -0
  42. package/dist/core/chat-configuration/chat-configuration.types.d.ts +27 -0
  43. package/dist/core/copilotkit.providers.d.ts +13 -0
  44. package/dist/core/copilotkit.service.d.ts +119 -0
  45. package/dist/core/copilotkit.types.d.ts +83 -0
  46. package/dist/directives/copilotkit-agent-context.directive.d.ts +68 -0
  47. package/dist/directives/copilotkit-agent.directive.d.ts +106 -0
  48. package/dist/directives/copilotkit-chat-config.directive.d.ts +84 -0
  49. package/dist/directives/copilotkit-config.directive.d.ts +44 -0
  50. package/dist/directives/copilotkit-frontend-tool.directive.d.ts +25 -0
  51. package/dist/directives/copilotkit-human-in-the-loop.directive.d.ts +124 -0
  52. package/dist/directives/stick-to-bottom.directive.d.ts +62 -0
  53. package/dist/fesm2022/copilotkitnext-angular.mjs +9314 -0
  54. package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -0
  55. package/dist/index.d.ts +55 -0
  56. package/dist/lib/directives/tooltip.directive.d.ts +33 -0
  57. package/dist/lib/slots/copilot-slot.component.d.ts +34 -0
  58. package/dist/lib/slots/slot.types.d.ts +55 -0
  59. package/dist/lib/slots/slot.utils.d.ts +108 -0
  60. package/dist/lib/utils.d.ts +6 -0
  61. package/dist/services/resize-observer.service.d.ts +44 -0
  62. package/dist/services/scroll-position.service.d.ts +50 -0
  63. package/dist/styles.css +1963 -0
  64. package/dist/types/frontend-tool.d.ts +37 -0
  65. package/dist/types/human-in-the-loop.d.ts +44 -0
  66. package/dist/utils/agent-context.utils.d.ts +75 -0
  67. package/dist/utils/agent.utils.d.ts +99 -0
  68. package/dist/utils/chat-config.utils.d.ts +166 -0
  69. package/dist/utils/copilotkit.utils.d.ts +16 -0
  70. package/dist/utils/frontend-tool.utils.d.ts +119 -0
  71. package/dist/utils/human-in-the-loop.utils.d.ts +92 -0
  72. package/eslint.config.mjs +20 -0
  73. package/ng-package.json +19 -0
  74. package/package.json +96 -0
  75. package/slots.md +331 -0
  76. package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +282 -0
  77. package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +419 -0
  78. package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +372 -0
  79. package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +249 -0
  80. package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +292 -0
  81. package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +472 -0
  82. package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +29 -0
  83. package/src/components/chat/copilot-chat-assistant-message.component.ts +463 -0
  84. package/src/components/chat/copilot-chat-assistant-message.types.ts +50 -0
  85. package/src/components/chat/copilot-chat-audio-recorder.component.ts +241 -0
  86. package/src/components/chat/copilot-chat-buttons.component.ts +308 -0
  87. package/src/components/chat/copilot-chat-buttons.component.ts.bak +471 -0
  88. package/src/components/chat/copilot-chat-input-defaults.ts +47 -0
  89. package/src/components/chat/copilot-chat-input.component.ts +512 -0
  90. package/src/components/chat/copilot-chat-input.types.ts +148 -0
  91. package/src/components/chat/copilot-chat-message-view-cursor.component.ts +51 -0
  92. package/src/components/chat/copilot-chat-message-view.component.ts +233 -0
  93. package/src/components/chat/copilot-chat-message-view.types.ts +39 -0
  94. package/src/components/chat/copilot-chat-textarea.component.ts +220 -0
  95. package/src/components/chat/copilot-chat-tool-calls-view.component.ts +261 -0
  96. package/src/components/chat/copilot-chat-toolbar.component.ts +35 -0
  97. package/src/components/chat/copilot-chat-tools-menu.component.ts +185 -0
  98. package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +121 -0
  99. package/src/components/chat/copilot-chat-user-message-buttons.component.ts +170 -0
  100. package/src/components/chat/copilot-chat-user-message-renderer.component.ts +37 -0
  101. package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +37 -0
  102. package/src/components/chat/copilot-chat-user-message.component.ts +247 -0
  103. package/src/components/chat/copilot-chat-user-message.types.ts +42 -0
  104. package/src/components/chat/copilot-chat-view-disclaimer.component.ts +51 -0
  105. package/src/components/chat/copilot-chat-view-feather.component.ts +47 -0
  106. package/src/components/chat/copilot-chat-view-handlers.service.ts +14 -0
  107. package/src/components/chat/copilot-chat-view-input-container.component.ts +87 -0
  108. package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +79 -0
  109. package/src/components/chat/copilot-chat-view-scroll-view.component.ts +322 -0
  110. package/src/components/chat/copilot-chat-view.component.ts +420 -0
  111. package/src/components/chat/copilot-chat-view.types.ts +52 -0
  112. package/src/components/chat/copilot-chat.component.ts +232 -0
  113. package/src/components/copilotkit-tool-render.component.ts +169 -0
  114. package/src/core/__tests__/copilotkit.service.spec.ts +1051 -0
  115. package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +316 -0
  116. package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +287 -0
  117. package/src/core/chat-configuration/chat-configuration.providers.ts +71 -0
  118. package/src/core/chat-configuration/chat-configuration.service.ts +162 -0
  119. package/src/core/chat-configuration/chat-configuration.types.ts +57 -0
  120. package/src/core/copilotkit.providers.ts +59 -0
  121. package/src/core/copilotkit.service.ts +542 -0
  122. package/src/core/copilotkit.types.ts +132 -0
  123. package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +384 -0
  124. package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +253 -0
  125. package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +385 -0
  126. package/src/directives/__tests__/copilotkit-config.directive.spec.ts +69 -0
  127. package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +60 -0
  128. package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +108 -0
  129. package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +452 -0
  130. package/src/directives/copilotkit-agent-context.directive.ts +138 -0
  131. package/src/directives/copilotkit-agent.directive.ts +225 -0
  132. package/src/directives/copilotkit-chat-config.directive.ts +241 -0
  133. package/src/directives/copilotkit-config.directive.ts +81 -0
  134. package/src/directives/copilotkit-frontend-tool.directive.ts +145 -0
  135. package/src/directives/copilotkit-human-in-the-loop.directive.ts +281 -0
  136. package/src/directives/stick-to-bottom.directive.ts +204 -0
  137. package/src/index.ts +105 -0
  138. package/src/lib/directives/tooltip.directive.ts +292 -0
  139. package/src/lib/slots/__tests__/slot.utils.spec.ts +377 -0
  140. package/src/lib/slots/copilot-slot.component.ts +135 -0
  141. package/src/lib/slots/index.ts +3 -0
  142. package/src/lib/slots/slot.types.ts +64 -0
  143. package/src/lib/slots/slot.utils.ts +289 -0
  144. package/src/lib/utils.ts +10 -0
  145. package/src/public-api.ts +1 -0
  146. package/src/services/resize-observer.service.ts +181 -0
  147. package/src/services/scroll-position.service.ts +169 -0
  148. package/src/styles/globals.css +266 -0
  149. package/src/styles/index.css +3 -0
  150. package/src/test-setup.ts +15 -0
  151. package/src/testing/index.ts +3 -0
  152. package/src/testing/testing.utils.ts +248 -0
  153. package/src/types/frontend-tool.ts +44 -0
  154. package/src/types/human-in-the-loop.ts +52 -0
  155. package/src/utils/__tests__/agent.utils.spec.ts +234 -0
  156. package/src/utils/__tests__/chat-config.utils.spec.ts +306 -0
  157. package/src/utils/__tests__/frontend-tool-inject.spec.ts +350 -0
  158. package/src/utils/__tests__/frontend-tool-integration.spec.ts +199 -0
  159. package/src/utils/__tests__/frontend-tool.utils.spec.ts +272 -0
  160. package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +365 -0
  161. package/src/utils/agent-context.utils.ts +133 -0
  162. package/src/utils/agent.utils.ts +239 -0
  163. package/src/utils/chat-config.utils.ts +221 -0
  164. package/src/utils/copilotkit.utils.ts +20 -0
  165. package/src/utils/frontend-tool.utils.ts +266 -0
  166. package/src/utils/human-in-the-loop.utils.ts +359 -0
  167. package/tsconfig.json +33 -0
  168. package/tsconfig.spec.json +12 -0
  169. package/vitest.config.mts +34 -0
@@ -0,0 +1,471 @@
1
+ import {
2
+ Component,
3
+ Input,
4
+ Output,
5
+ EventEmitter,
6
+ signal,
7
+ computed,
8
+ inject,
9
+ ChangeDetectionStrategy,
10
+ TemplateRef
11
+ } from '@angular/core';
12
+ import { CommonModule } from '@angular/common';
13
+ import { CopilotChatConfigurationService } from '../../core/chat-configuration/chat-configuration.service';
14
+ import type { CopilotChatLabels } from '../../core/chat-configuration/chat-configuration.types';
15
+
16
+ /**
17
+ * Base button component with common styling
18
+ */
19
+ @Component({
20
+ selector: 'copilot-chat-button-base',
21
+ standalone: true,
22
+ imports: [CommonModule],
23
+ template: `
24
+ <button
25
+ [type]="type()"
26
+ [disabled]="disabled()"
27
+ [class]="computedClass()"
28
+ (click)="handleClick($event)"
29
+ >
30
+ <ng-content></ng-content>
31
+ </button>
32
+ `,
33
+ styles: [`
34
+ button {
35
+ display: inline-flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ gap: 0.5rem;
39
+ white-space: nowrap;
40
+ border-radius: 0.375rem;
41
+ font-size: 0.875rem;
42
+ font-weight: 500;
43
+ transition: all 150ms;
44
+ outline: none;
45
+ border: none;
46
+ cursor: pointer;
47
+ flex-shrink: 0;
48
+ }
49
+
50
+ button:disabled {
51
+ pointer-events: none;
52
+ opacity: 0.5;
53
+ }
54
+
55
+ button:focus-visible {
56
+ outline: 2px solid transparent;
57
+ outline-offset: 2px;
58
+ box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.5);
59
+ }
60
+ `]
61
+ })
62
+ class CopilotChatButtonBase {
63
+ @Input() set inputType(val: 'button' | 'submit' | 'reset' | undefined) {
64
+ this.type.set(val || 'button');
65
+ }
66
+ @Input() set inputDisabled(val: boolean | undefined) {
67
+ this.disabled.set(val || false);
68
+ }
69
+ @Input() set inputClass(val: string | undefined) {
70
+ this.customClass.set(val);
71
+ }
72
+
73
+ @Output() click = new EventEmitter<MouseEvent>();
74
+
75
+ type = signal<'button' | 'submit' | 'reset'>('button');
76
+ disabled = signal<boolean>(false);
77
+ customClass = signal<string | undefined>(undefined);
78
+
79
+ computedClass = computed(() => {
80
+ return this.customClass() || 'button-base';
81
+ });
82
+
83
+ handleClick(event: MouseEvent): void {
84
+ if (!this.disabled()) {
85
+ this.click.emit(event);
86
+ }
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Send button component
92
+ */
93
+ @Component({
94
+ selector: 'copilot-chat-send-button',
95
+ standalone: true,
96
+ imports: [CommonModule],
97
+ changeDetection: ChangeDetectionStrategy.OnPush,
98
+ template: `
99
+ <div class="send-button-container">
100
+ <button
101
+ type="button"
102
+ [disabled]="disabled()"
103
+ [class]="computedClass()"
104
+ (click)="handleClick()"
105
+ >
106
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
107
+ <line x1="12" y1="19" x2="12" y2="5"></line>
108
+ <polyline points="5 12 12 5 19 12"></polyline>
109
+ </svg>
110
+ </button>
111
+ </div>
112
+ `,
113
+ styles: [`
114
+ .send-button-container {
115
+ margin-right: 10px;
116
+ }
117
+
118
+ button {
119
+ width: 32px;
120
+ height: 32px;
121
+ border-radius: 50%;
122
+ background: black;
123
+ color: white;
124
+ border: none;
125
+ cursor: pointer;
126
+ display: flex;
127
+ align-items: center;
128
+ justify-content: center;
129
+ transition: opacity 150ms;
130
+ }
131
+
132
+ button:hover:not(:disabled) {
133
+ opacity: 0.7;
134
+ }
135
+
136
+ button:disabled {
137
+ opacity: 0.5;
138
+ cursor: not-allowed;
139
+ }
140
+
141
+ button:focus {
142
+ outline: none;
143
+ }
144
+
145
+ :host-context(.dark) button {
146
+ background: white;
147
+ color: black;
148
+ }
149
+ `]
150
+ })
151
+ export class CopilotChatSendButtonComponent {
152
+ @Input() set inputDisabled(val: boolean | undefined) {
153
+ this.disabled.set(val || false);
154
+ }
155
+ @Input() set inputClass(val: string | undefined) {
156
+ this.customClass.set(val);
157
+ }
158
+
159
+ @Output() click = new EventEmitter<void>();
160
+
161
+ disabled = signal<boolean>(false);
162
+ customClass = signal<string | undefined>(undefined);
163
+
164
+ computedClass = computed(() => {
165
+ const baseClasses = 'send-button';
166
+ return this.customClass() || baseClasses;
167
+ });
168
+
169
+ handleClick(): void {
170
+ if (!this.disabled()) {
171
+ this.click.emit();
172
+ }
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Toolbar button component with tooltip support
178
+ */
179
+ @Component({
180
+ selector: 'copilot-chat-toolbar-button',
181
+ standalone: true,
182
+ imports: [CommonModule],
183
+ changeDetection: ChangeDetectionStrategy.OnPush,
184
+ template: `
185
+ <div class="toolbar-button-wrapper" [title]="tooltip()">
186
+ <button
187
+ type="button"
188
+ [disabled]="disabled()"
189
+ [class]="computedClass()"
190
+ (click)="handleClick()"
191
+ >
192
+ <ng-content></ng-content>
193
+ </button>
194
+ </div>
195
+ `,
196
+ styles: [`
197
+ .toolbar-button-wrapper {
198
+ position: relative;
199
+ display: inline-block;
200
+ }
201
+
202
+ button {
203
+ width: 32px;
204
+ height: 32px;
205
+ padding: 0;
206
+ border-radius: 6px;
207
+ background: transparent;
208
+ color: rgb(93, 93, 93);
209
+ border: none;
210
+ cursor: pointer;
211
+ display: flex;
212
+ align-items: center;
213
+ justify-content: center;
214
+ transition: all 150ms;
215
+ }
216
+
217
+ button:hover:not(:disabled) {
218
+ background: #E8E8E8;
219
+ }
220
+
221
+ button:disabled {
222
+ opacity: 0.5;
223
+ cursor: not-allowed;
224
+ }
225
+
226
+ :host-context(.dark) button {
227
+ color: rgb(243, 243, 243);
228
+ }
229
+
230
+ :host-context(.dark) button:hover:not(:disabled) {
231
+ background: #303030;
232
+ }
233
+
234
+ button.primary {
235
+ background: black;
236
+ color: white;
237
+ border-radius: 50%;
238
+ }
239
+
240
+ button.primary:hover:not(:disabled) {
241
+ opacity: 0.7;
242
+ background: black;
243
+ }
244
+
245
+ :host-context(.dark) button.primary {
246
+ background: white;
247
+ color: black;
248
+ }
249
+ `]
250
+ })
251
+ export class CopilotChatToolbarButtonComponent {
252
+ @Input() set inputDisabled(val: boolean | undefined) {
253
+ this.disabled.set(val || false);
254
+ }
255
+ @Input() set inputClass(val: string | undefined) {
256
+ this.customClass.set(val);
257
+ }
258
+ @Input() set inputTooltip(val: string | undefined) {
259
+ this.tooltip.set(val || '');
260
+ }
261
+ @Input() set inputVariant(val: 'primary' | 'secondary' | undefined) {
262
+ this.variant.set(val || 'secondary');
263
+ }
264
+
265
+ @Output() click = new EventEmitter<void>();
266
+
267
+ disabled = signal<boolean>(false);
268
+ customClass = signal<string | undefined>(undefined);
269
+ tooltip = signal<string>('');
270
+ variant = signal<'primary' | 'secondary'>('secondary');
271
+
272
+ computedClass = computed(() => {
273
+ const variantClass = this.variant() === 'primary' ? 'primary' : 'secondary';
274
+ return this.customClass() || `toolbar-button ${variantClass}`;
275
+ });
276
+
277
+ handleClick(): void {
278
+ if (!this.disabled()) {
279
+ this.click.emit();
280
+ }
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Start transcribe button
286
+ */
287
+ @Component({
288
+ selector: 'copilot-chat-start-transcribe-button',
289
+ standalone: true,
290
+ imports: [CommonModule, CopilotChatToolbarButtonComponent],
291
+ changeDetection: ChangeDetectionStrategy.OnPush,
292
+ template: `
293
+ <copilot-chat-toolbar-button
294
+ [inputDisabled]="disabled()"
295
+ [inputClass]="customClass() || 'mr-2'"
296
+ [inputTooltip]="tooltip()"
297
+ (click)="handleClick()"
298
+ >
299
+ <!-- Microphone Icon -->
300
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
301
+ <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path>
302
+ <path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
303
+ <line x1="12" y1="19" x2="12" y2="23"></line>
304
+ <line x1="8" y1="23" x2="16" y2="23"></line>
305
+ </svg>
306
+ </copilot-chat-toolbar-button>
307
+ `
308
+ })
309
+ export class CopilotChatStartTranscribeButtonComponent {
310
+ @Input() set inputDisabled(val: boolean | undefined) {
311
+ this.disabled.set(val || false);
312
+ }
313
+ @Input() set inputClass(val: string | undefined) {
314
+ this.customClass.set(val);
315
+ }
316
+
317
+ @Output() click = new EventEmitter<void>();
318
+
319
+ private chatConfig = inject(CopilotChatConfigurationService, { optional: true });
320
+
321
+ disabled = signal<boolean>(false);
322
+ customClass = signal<string | undefined>(undefined);
323
+
324
+ tooltip = computed(() => {
325
+ return this.chatConfig?.labels().chatInputToolbarStartTranscribeButtonLabel || 'Start recording';
326
+ });
327
+
328
+ handleClick(): void {
329
+ this.click.emit();
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Cancel transcribe button
335
+ */
336
+ @Component({
337
+ selector: 'copilot-chat-cancel-transcribe-button',
338
+ standalone: true,
339
+ imports: [CommonModule, CopilotChatToolbarButtonComponent],
340
+ changeDetection: ChangeDetectionStrategy.OnPush,
341
+ template: `
342
+ <copilot-chat-toolbar-button
343
+ [inputDisabled]="disabled()"
344
+ [inputClass]="customClass() || 'mr-2'"
345
+ [inputTooltip]="tooltip()"
346
+ (click)="handleClick()"
347
+ >
348
+ <!-- X Icon -->
349
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
350
+ <line x1="18" y1="6" x2="6" y2="18"></line>
351
+ <line x1="6" y1="6" x2="18" y2="18"></line>
352
+ </svg>
353
+ </copilot-chat-toolbar-button>
354
+ `
355
+ })
356
+ export class CopilotChatCancelTranscribeButtonComponent {
357
+ @Input() set inputDisabled(val: boolean | undefined) {
358
+ this.disabled.set(val || false);
359
+ }
360
+ @Input() set inputClass(val: string | undefined) {
361
+ this.customClass.set(val);
362
+ }
363
+
364
+ @Output() click = new EventEmitter<void>();
365
+
366
+ private chatConfig = inject(CopilotChatConfigurationService, { optional: true });
367
+
368
+ disabled = signal<boolean>(false);
369
+ customClass = signal<string | undefined>(undefined);
370
+
371
+ tooltip = computed(() => {
372
+ return this.chatConfig?.labels().chatInputToolbarCancelTranscribeButtonLabel || 'Cancel recording';
373
+ });
374
+
375
+ handleClick(): void {
376
+ this.click.emit();
377
+ }
378
+ }
379
+
380
+ /**
381
+ * Finish transcribe button
382
+ */
383
+ @Component({
384
+ selector: 'copilot-chat-finish-transcribe-button',
385
+ standalone: true,
386
+ imports: [CommonModule, CopilotChatToolbarButtonComponent],
387
+ changeDetection: ChangeDetectionStrategy.OnPush,
388
+ template: `
389
+ <copilot-chat-toolbar-button
390
+ [inputDisabled]="disabled()"
391
+ [inputClass]="customClass() || 'mr-[10px]'"
392
+ [inputTooltip]="tooltip()"
393
+ (click)="handleClick()"
394
+ >
395
+ <!-- Check Icon -->
396
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
397
+ <polyline points="20 6 9 17 4 12"></polyline>
398
+ </svg>
399
+ </copilot-chat-toolbar-button>
400
+ `
401
+ })
402
+ export class CopilotChatFinishTranscribeButtonComponent {
403
+ @Input() set inputDisabled(val: boolean | undefined) {
404
+ this.disabled.set(val || false);
405
+ }
406
+ @Input() set inputClass(val: string | undefined) {
407
+ this.customClass.set(val);
408
+ }
409
+
410
+ @Output() click = new EventEmitter<void>();
411
+
412
+ private chatConfig = inject(CopilotChatConfigurationService, { optional: true });
413
+
414
+ disabled = signal<boolean>(false);
415
+ customClass = signal<string | undefined>(undefined);
416
+
417
+ tooltip = computed(() => {
418
+ return this.chatConfig?.labels().chatInputToolbarFinishTranscribeButtonLabel || 'Finish recording';
419
+ });
420
+
421
+ handleClick(): void {
422
+ this.click.emit();
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Add file button
428
+ */
429
+ @Component({
430
+ selector: 'copilot-chat-add-file-button',
431
+ standalone: true,
432
+ imports: [CommonModule, CopilotChatToolbarButtonComponent],
433
+ changeDetection: ChangeDetectionStrategy.OnPush,
434
+ template: `
435
+ <copilot-chat-toolbar-button
436
+ [inputDisabled]="disabled()"
437
+ [inputClass]="customClass() || 'ml-2'"
438
+ [inputTooltip]="tooltip()"
439
+ (click)="handleClick()"
440
+ >
441
+ <!-- Plus Icon -->
442
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
443
+ <line x1="12" y1="5" x2="12" y2="19"></line>
444
+ <line x1="5" y1="12" x2="19" y2="12"></line>
445
+ </svg>
446
+ </copilot-chat-toolbar-button>
447
+ `
448
+ })
449
+ export class CopilotChatAddFileButtonComponent {
450
+ @Input() set inputDisabled(val: boolean | undefined) {
451
+ this.disabled.set(val || false);
452
+ }
453
+ @Input() set inputClass(val: string | undefined) {
454
+ this.customClass.set(val);
455
+ }
456
+
457
+ @Output() click = new EventEmitter<void>();
458
+
459
+ private chatConfig = inject(CopilotChatConfigurationService, { optional: true });
460
+
461
+ disabled = signal<boolean>(false);
462
+ customClass = signal<string | undefined>(undefined);
463
+
464
+ tooltip = computed(() => {
465
+ return this.chatConfig?.labels().chatInputToolbarAddButtonLabel || 'Add file';
466
+ });
467
+
468
+ handleClick(): void {
469
+ this.click.emit();
470
+ }
471
+ }
@@ -0,0 +1,47 @@
1
+ import { CopilotChatTextareaComponent } from "./copilot-chat-textarea.component";
2
+ import { CopilotChatAudioRecorderComponent } from "./copilot-chat-audio-recorder.component";
3
+ import {
4
+ CopilotChatSendButtonComponent,
5
+ CopilotChatStartTranscribeButtonComponent,
6
+ CopilotChatCancelTranscribeButtonComponent,
7
+ CopilotChatFinishTranscribeButtonComponent,
8
+ CopilotChatAddFileButtonComponent,
9
+ } from "./copilot-chat-buttons.component";
10
+ import { CopilotChatToolbarComponent } from "./copilot-chat-toolbar.component";
11
+ import { CopilotChatToolsMenuComponent } from "./copilot-chat-tools-menu.component";
12
+
13
+ /**
14
+ * Default components used by CopilotChatInput.
15
+ * These can be imported and reused when creating custom slot implementations.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { CopilotChatInputDefaults } from '@copilotkitnext/angular';
20
+ *
21
+ * @Component({
22
+ * template: `
23
+ * <copilot-chat-input [sendButtonSlot]="CustomSendButton">
24
+ * </copilot-chat-input>
25
+ * `
26
+ * })
27
+ * export class MyComponent {
28
+ * CustomSendButton = class extends CopilotChatInputDefaults.SendButton {
29
+ * // Custom implementation
30
+ * };
31
+ * }
32
+ * ```
33
+ */
34
+ export class CopilotChatInputDefaults {
35
+ static readonly TextArea = CopilotChatTextareaComponent;
36
+ static readonly AudioRecorder = CopilotChatAudioRecorderComponent;
37
+ static readonly SendButton = CopilotChatSendButtonComponent;
38
+ static readonly StartTranscribeButton =
39
+ CopilotChatStartTranscribeButtonComponent;
40
+ static readonly CancelTranscribeButton =
41
+ CopilotChatCancelTranscribeButtonComponent;
42
+ static readonly FinishTranscribeButton =
43
+ CopilotChatFinishTranscribeButtonComponent;
44
+ static readonly AddFileButton = CopilotChatAddFileButtonComponent;
45
+ static readonly Toolbar = CopilotChatToolbarComponent;
46
+ static readonly ToolsMenu = CopilotChatToolsMenuComponent;
47
+ }