11import type { Meta , StoryObj } from "@storybook/angular" ;
22import { moduleMetadata } from "@storybook/angular" ;
33import { CommonModule } from "@angular/common" ;
4- import {
5- CopilotChatUserMessage ,
6- provideCopilotChatLabels ,
7- type UserMessage ,
8- } from "@copilotkitnext/angular" ;
4+ import { CopilotChatUserMessage , provideCopilotChatLabels } from "@copilotkitnext/angular" ;
5+ import { UserMessage } from "@ag-ui/client" ;
96
107// Simple default message
118const simpleMessage : UserMessage = {
129 id : "simple-user-message" ,
1310 content : "Hello! Can you help me build an Angular component?" ,
1411 role : "user" ,
15- timestamp : new Date ( ) ,
1612} ;
1713
1814// Longer user message
@@ -29,7 +25,6 @@ const longMessage: UserMessage = {
2925
3026Can you help me implement this step by step? I'm particularly struggling with the form validation and state management parts.` ,
3127 role : "user" ,
32- timestamp : new Date ( ) ,
3328} ;
3429
3530// Code-related user message
@@ -55,15 +50,13 @@ export class UserListComponent {
5550
5651How can I fix this?` ,
5752 role : "user" ,
58- timestamp : new Date ( ) ,
5953} ;
6054
6155// Short question
6256const shortMessage : UserMessage = {
6357 id : "short-user-message" ,
6458 content : "What's the difference between signals and observables in Angular?" ,
6559 role : "user" ,
66- timestamp : new Date ( ) ,
6760} ;
6861
6962const meta : Meta < CopilotChatUserMessage > = {
@@ -130,7 +123,7 @@ export class ChatComponent {
130123 role: 'user',
131124 timestamp: new Date(),
132125 };
133-
126+
134127 onEditMessage(event: any): void {
135128 console.log('Edit message:', event);
136129 }
@@ -179,7 +172,7 @@ Can you help me implement this step by step? I'm particularly struggling with th
179172 role: 'user',
180173 timestamp: new Date(),
181174 };
182-
175+
183176 onEditMessage(event: any): void {
184177 console.log('Edit message:', event);
185178 }
@@ -220,7 +213,7 @@ export class ChatComponent {
220213 role: 'user',
221214 timestamp: new Date(),
222215 };
223-
216+
224217 onEditMessage(event: any): void {
225218 alert('Edit message clicked!');
226219 console.log('Edit message:', event);
@@ -261,7 +254,7 @@ export class ChatComponent {
261254 role: 'user',
262255 timestamp: new Date(),
263256 };
264-
257+
265258 // No edit handler - edit button won't appear
266259}` ,
267260 language : "typescript" ,
@@ -318,7 +311,7 @@ How can I fix this?\`,
318311 role: 'user',
319312 timestamp: new Date(),
320313 };
321-
314+
322315 onEditMessage(event: any): void {
323316 alert('Edit code message clicked!');
324317 }
@@ -359,7 +352,7 @@ export class ChatComponent {
359352 role: 'user',
360353 timestamp: new Date(),
361354 };
362-
355+
363356 onEditMessage(event: any): void {
364357 console.log('Edit short message clicked!');
365358 }
@@ -391,7 +384,7 @@ export const WithAdditionalToolbarItems: Story = {
391384 🔄
392385 </button>
393386 </ng-template>
394-
387+
395388 <div style="display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 16px;">
396389 <div style="width: 100%; max-width: 640px;">
397390 <copilot-chat-user-message
@@ -429,7 +422,7 @@ import { CopilotChatUserMessage, UserMessage } from '@copilotkitnext/angular';
429422 🔄
430423 </button>
431424 </ng-template>
432-
425+
433426 <copilot-chat-user-message
434427 [message]="message"
435428 [additionalToolbarItems]="additionalItems"
@@ -439,22 +432,22 @@ import { CopilotChatUserMessage, UserMessage } from '@copilotkitnext/angular';
439432})
440433export class ChatComponent {
441434 @ViewChild('additionalItems') additionalItems!: TemplateRef<any>;
442-
435+
443436 message: UserMessage = {
444437 id: 'simple-user-message',
445438 content: 'Hello! Can you help me build an Angular component?',
446439 role: 'user',
447440 timestamp: new Date(),
448441 };
449-
442+
450443 onEditMessage(event: any): void {
451444 console.log('Edit clicked!');
452445 }
453-
446+
454447 onCustomAction1(): void {
455448 alert('Custom button 1 clicked!');
456449 }
457-
450+
458451 onCustomAction2(): void {
459452 alert('Custom button 2 clicked!');
460453 }
@@ -482,7 +475,7 @@ export const CustomAppearance: Story = {
482475 {{ content }}
483476 </div>
484477 </ng-template>
485-
478+
486479 <ng-template #toolbar>
487480 <div class="w-full bg-transparent flex items-center justify-end -mr-[5px] mt-[8px] invisible group-hover:visible">
488481 <div class="flex items-center gap-1 justify-end">
@@ -499,7 +492,7 @@ export const CustomAppearance: Story = {
499492 </div>
500493 </div>
501494 </ng-template>
502-
495+
503496 <div style="display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 16px;">
504497 <div style="width: 100%; max-width: 640px;">
505498 <copilot-chat-user-message
@@ -522,8 +515,7 @@ export const CustomComponents: Story = {
522515 args : {
523516 message : simpleMessage ,
524517 editMessage : ( ) => console . log ( "Edit clicked!" ) ,
525- inputClass :
526- "bg-gradient-to-r from-purple-100 to-pink-100 rounded-xl p-4 shadow-sm" ,
518+ inputClass : "bg-gradient-to-r from-purple-100 to-pink-100 rounded-xl p-4 shadow-sm" ,
527519 } ,
528520 render : ( ) => ( {
529521 props : {
@@ -536,7 +528,7 @@ export const CustomComponents: Story = {
536528 💬 {{ content }}
537529 </div>
538530 </ng-template>
539-
531+
540532 <div style="display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 16px;">
541533 <div style="width: 100%; max-width: 640px;">
542534 <copilot-chat-user-message
@@ -559,30 +551,26 @@ export const WithBranchNavigation: Story = {
559551 args : {
560552 message : {
561553 id : "branch-message" ,
562- content :
563- "This message has multiple branches. You can navigate between them using the branch controls." ,
554+ content : "This message has multiple branches. You can navigate between them using the branch controls." ,
564555 role : "user" ,
565556 } ,
566557 editMessage : ( ) => console . log ( "Edit clicked!" ) ,
567558 branchIndex : 2 ,
568559 numberOfBranches : 3 ,
569- switchToBranch : ( { branchIndex } ) =>
570- console . log ( `Switching to branch ${ branchIndex + 1 } ` ) ,
560+ switchToBranch : ( { branchIndex } ) => console . log ( `Switching to branch ${ branchIndex + 1 } ` ) ,
571561 } ,
572562} ;
573563
574564export const WithManyBranches : Story = {
575565 args : {
576566 message : {
577567 id : "many-branches-message" ,
578- content :
579- "This is branch 5 of 10. Use the navigation arrows to explore different variations of this message." ,
568+ content : "This is branch 5 of 10. Use the navigation arrows to explore different variations of this message." ,
580569 role : "user" ,
581570 } ,
582571 editMessage : ( ) => console . log ( "Edit clicked!" ) ,
583572 branchIndex : 4 ,
584573 numberOfBranches : 10 ,
585- switchToBranch : ( { branchIndex } ) =>
586- alert ( `Would switch to branch ${ branchIndex + 1 } of 10` ) ,
574+ switchToBranch : ( { branchIndex } ) => alert ( `Would switch to branch ${ branchIndex + 1 } of 10` ) ,
587575 } ,
588576} ;
0 commit comments