-
Notifications
You must be signed in to change notification settings - Fork 16
feat: add base chat messages #877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| ## Public API Report File for "@siemens/element-ng_chat-messages" | ||
|
|
||
| > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
|
||
| ```ts | ||
|
|
||
| import * as _angular_core from '@angular/core'; | ||
| import { ElementRef } from '@angular/core'; | ||
| import * as i1 from '@siemens/element-ng/resize-observer'; | ||
| import { MenuItem } from '@siemens/element-ng/menu'; | ||
| import * as _siemens_element_translate_ng_translate_types from '@siemens/element-translate-ng/translate-types'; | ||
| import { SiModalService } from '@siemens/element-ng/modal'; | ||
| import { TemplateRef } from '@angular/core'; | ||
| import { TranslatableString } from '@siemens/element-translate-ng/translate-types'; | ||
|
|
||
| // @public | ||
| export interface Attachment { | ||
| name: string; | ||
| previewTemplate?: TemplateRef<any> | (() => TemplateRef<any>); | ||
| } | ||
|
|
||
| // @public | ||
| export interface MessageAction { | ||
| action: (actionParam: any, source: this) => void; | ||
| disabled?: boolean; | ||
| icon: string; | ||
| label: TranslatableString; | ||
| } | ||
|
|
||
| // @public | ||
| export class SiAiMessageComponent { | ||
| constructor(); | ||
| readonly actionParam: _angular_core.InputSignal<unknown>; | ||
| readonly actions: _angular_core.InputSignal<MessageAction[]>; | ||
| readonly content: _angular_core.InputSignal<string>; | ||
| readonly contentFormatter: _angular_core.InputSignal<((text: string) => string | Node) | undefined>; | ||
| // (undocumented) | ||
| protected readonly formattedContent: _angular_core.Signal<ElementRef<HTMLDivElement> | undefined>; | ||
| readonly loading: _angular_core.InputSignalWithTransform<boolean, unknown>; | ||
| readonly secondaryActions: _angular_core.InputSignal<MenuItem[]>; | ||
| readonly secondaryActionsLabel: _angular_core.InputSignal<_siemens_element_translate_ng_translate_types.TranslatableString>; | ||
| // (undocumented) | ||
| protected readonly textContent: _angular_core.WritableSignal<string | undefined>; | ||
| // (undocumented) | ||
| static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiAiMessageComponent, "si-ai-message", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "contentFormatter": { "alias": "contentFormatter"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "actions": { "alias": "actions"; "required": false; "isSignal": true; }; "secondaryActions": { "alias": "secondaryActions"; "required": false; "isSignal": true; }; "actionParam": { "alias": "actionParam"; "required": false; "isSignal": true; }; "secondaryActionsLabel": { "alias": "secondaryActionsLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; | ||
| // (undocumented) | ||
| static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiAiMessageComponent, never>; | ||
| } | ||
|
|
||
| // @public | ||
| export class SiAttachmentListComponent { | ||
| readonly alignment: _angular_core.InputSignal<"start" | "end">; | ||
| readonly attachments: _angular_core.InputSignal<Attachment[]>; | ||
| // (undocumented) | ||
| protected getFileIcon(name: string): string; | ||
| // (undocumented) | ||
| protected modalService: SiModalService; | ||
| // (undocumented) | ||
| protected openPreview(event: Event, attachment: Attachment): void; | ||
| readonly removable: _angular_core.InputSignalWithTransform<boolean, unknown>; | ||
| readonly remove: _angular_core.OutputEmitterRef<Attachment>; | ||
| readonly removeLabel: _angular_core.InputSignal<_siemens_element_translate_ng_translate_types.TranslatableString>; | ||
| // (undocumented) | ||
| static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiAttachmentListComponent, "si-attachment-list", never, { "attachments": { "alias": "attachments"; "required": false; "isSignal": true; }; "alignment": { "alias": "alignment"; "required": false; "isSignal": true; }; "removable": { "alias": "removable"; "required": false; "isSignal": true; }; "removeLabel": { "alias": "removeLabel"; "required": false; "isSignal": true; }; }, { "remove": "remove"; }, never, never, true, never>; | ||
| // (undocumented) | ||
| static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiAttachmentListComponent, never>; | ||
| } | ||
|
|
||
| // @public | ||
| export class SiChatMessageActionDirective { | ||
| // (undocumented) | ||
| static ɵdir: _angular_core.ɵɵDirectiveDeclaration<SiChatMessageActionDirective, "[siChatMessageAction]", never, {}, {}, never, never, true, never>; | ||
| // (undocumented) | ||
| static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiChatMessageActionDirective, never>; | ||
| } | ||
|
|
||
| // @public | ||
| export class SiChatMessageComponent { | ||
| readonly actionsPosition: _angular_core.InputSignal<"bottom" | "side">; | ||
| readonly alignment: _angular_core.InputSignal<"start" | "end">; | ||
| readonly loading: _angular_core.InputSignal<boolean>; | ||
| // (undocumented) | ||
| static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiChatMessageComponent, "si-chat-message", never, { "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "alignment": { "alias": "alignment"; "required": false; "isSignal": true; }; "actionsPosition": { "alias": "actionsPosition"; "required": false; "isSignal": true; }; }, {}, never, ["si-icon,si-avatar,img", "si-attachment-list,si-badge", "*", "[siChatMessageAction]"], true, [{ directive: typeof i1.SiResponsiveContainerDirective; inputs: {}; outputs: {}; }]>; | ||
| // (undocumented) | ||
| static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiChatMessageComponent, never>; | ||
| } | ||
|
|
||
| // @public | ||
| export class SiUserMessageComponent { | ||
| constructor(); | ||
| readonly actionParam: _angular_core.InputSignal<any>; | ||
| readonly actions: _angular_core.InputSignal<MessageAction[]>; | ||
| readonly attachments: _angular_core.InputSignal<Attachment[]>; | ||
| readonly content: _angular_core.InputSignal<string>; | ||
| readonly contentFormatter: _angular_core.InputSignal<((text: string) => string | Node) | undefined>; | ||
| // (undocumented) | ||
| protected readonly formattedContent: _angular_core.Signal<ElementRef<HTMLDivElement> | undefined>; | ||
| // (undocumented) | ||
| protected readonly hasAttachments: _angular_core.Signal<boolean>; | ||
| readonly secondaryActions: _angular_core.InputSignal<MenuItem[]>; | ||
| readonly secondaryActionsLabel: _angular_core.InputSignal<_siemens_element_translate_ng_translate_types.TranslatableString>; | ||
| // (undocumented) | ||
| protected readonly textContent: _angular_core.WritableSignal<string | undefined>; | ||
| // (undocumented) | ||
| static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiUserMessageComponent, "si-user-message", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "contentFormatter": { "alias": "contentFormatter"; "required": false; "isSignal": true; }; "actions": { "alias": "actions"; "required": false; "isSignal": true; }; "secondaryActions": { "alias": "secondaryActions"; "required": false; "isSignal": true; }; "attachments": { "alias": "attachments"; "required": false; "isSignal": true; }; "actionParam": { "alias": "actionParam"; "required": false; "isSignal": true; }; "secondaryActionsLabel": { "alias": "secondaryActionsLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; | ||
| // (undocumented) | ||
| static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiUserMessageComponent, never>; | ||
| } | ||
|
|
||
| // (No @packageDocumentation comment for this package) | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...pshots/si-chat-messages--si-ai-message-element-examples-chromium-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...shots/si-chat-messages--si-ai-message-element-examples-chromium-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-ai-message.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| - paragraph: | ||
| - text: Here's a | ||
| - strong: simple response | ||
| - text: with basic formatting. | ||
| - paragraph: | ||
| - text: You can use | ||
| - code: inline code | ||
| - text: "and create lists:" | ||
| - list: | ||
| - listitem: First item | ||
| - listitem: Second item | ||
| - button "Good response" | ||
| - button "Copy response" | ||
| - button "Retry response" | ||
| - button "More actions" |
3 changes: 3 additions & 0 deletions
3
...s/si-chat-messages--si-attachment-list-element-examples-chromium-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
.../si-chat-messages--si-attachment-list-element-examples-chromium-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-attachment-list.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| - group: | ||
| - button "quarterly-report.xlsx" | ||
| - button "Remove attachment quarterly-report.xlsx" | ||
| - group: | ||
| - button "screenshot.png" | ||
| - button "Remove attachment screenshot.png" | ||
| - group: | ||
| - button "very-long-filename-that-demonstrates-text-truncation-behavior.pdf" | ||
| - button "Remove attachment very-long-filename-that-demonstrates-text-truncation-behavior.pdf" | ||
| - group: | ||
| - button "data.csv" | ||
| - button "Remove attachment data.csv" | ||
| - group: | ||
| - button "audio.mp3" | ||
| - button "Remove attachment audio.mp3" | ||
| - group: | ||
| - button "final-report.docx" | ||
| - group: | ||
| - button "diagram.jpg" | ||
| - group: | ||
| - button "config.json" |
3 changes: 3 additions & 0 deletions
3
...hots/si-chat-messages--si-chat-message-element-examples-chromium-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/si-chat-messages--si-chat-message-element-examples-chromium-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-chat-message.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| - group: error-log.txt | ||
| - group: screenshot.png | ||
| - paragraph: | ||
| - text: Can you help me with this | ||
| - strong: code snippet | ||
| - text: "? I'm getting an error when I run it." | ||
| - button "Copy" | ||
| - button "Edit" | ||
| - button "More actions" | ||
| - text: JD Thanks for the help! That worked perfectly. | ||
| - button "Copy" | ||
| - button "Edit" | ||
| - group: error-log.txt | ||
| - group: screenshot.png |
3 changes: 3 additions & 0 deletions
3
...hots/si-chat-messages--si-user-message-element-examples-chromium-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/si-chat-messages--si-user-message-element-examples-chromium-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
playwright/snapshots/static.spec.ts-snapshots/si-chat-messages--si-user-message.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| - group: error-log.txt | ||
| - group: screenshot.png | ||
| - paragraph: | ||
| - text: Can you help me with this | ||
| - strong: code snippet | ||
| - text: "?" | ||
| - paragraph: | ||
| - code: console.log('Hello World') | ||
| - paragraph: I'm getting an error when I run it. | ||
| - button "Edit message" | ||
| - button "Copy message" | ||
| - button "Delete message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /** | ||
| * Copyright (c) Siemens 2016 - 2025 | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
| export * from './si-ai-message.component'; | ||
| export * from './si-attachment-list.component'; | ||
| export * from './si-chat-message-action.directive'; | ||
| export * from './si-chat-message.component'; | ||
| export * from './si-user-message.component'; | ||
| export * from './message-action.model'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * Copyright (c) Siemens 2016 - 2025 | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
| import type { TranslatableString } from '@siemens/element-translate-ng/translate-types'; | ||
|
|
||
| /** | ||
| * Actions for messages representing an action with icon, label (for accessibility), and handler. | ||
| * Only the icon will be displayed. | ||
| * @experimental | ||
| */ | ||
| export interface MessageAction { | ||
| /** Label that is shown to the user. */ | ||
| label: TranslatableString; | ||
| /** | ||
| * Icon used to represent the action | ||
| */ | ||
| icon: string; | ||
| /** | ||
| * Action that is called when the item is triggered. | ||
| */ | ||
| action: (actionParam: any, source: this) => void; | ||
| /** Whether the menu item is disabled. */ | ||
| disabled?: boolean; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", | ||
| "lib": { | ||
| "entryFile": "index.ts" | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
projects/element-ng/chat-messages/si-ai-message.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <si-chat-message alignment="start" actionsPosition="bottom" [loading]="loading()"> | ||
| @if (content()) { | ||
| @let content = textContent(); | ||
| @if (content) { | ||
| <span class="text-pre-wrap">{{ content }}</span> | ||
| } @else { | ||
| <div #formattedContent> </div> | ||
| } | ||
| } | ||
|
|
||
| @if (actions().length > 0 || secondaryActions().length > 0) { | ||
| <div class="d-flex gap-4 ai-message-actions" siChatMessageAction> | ||
| @for (action of actions(); track $index) { | ||
| <button | ||
| type="button" | ||
| class="btn btn-ghost btn-circle btn-sm" | ||
| [disabled]="action.disabled" | ||
| [attr.aria-label]="action.label | translate" | ||
| (click)="action.action(actionParam(), action)" | ||
| > | ||
| <si-icon [icon]="action.icon" /> | ||
| </button> | ||
| } | ||
|
|
||
| @if (secondaryActions().length > 0) { | ||
| <button | ||
| type="button" | ||
| class="btn btn-ghost btn-circle btn-sm" | ||
| [cdkMenuTriggerFor]="secondaryActionsMenu" | ||
| [attr.aria-label]="secondaryActionsLabel() | translate" | ||
| [attr.title]="secondaryActionsLabel() | translate" | ||
| > | ||
| <si-icon icon="element-optionsVertical" /> | ||
| </button> | ||
|
|
||
| <ng-template #secondaryActionsMenu> | ||
| <si-menu-factory [items]="secondaryActions()" [actionParam]="actionParam()" /> | ||
| </ng-template> | ||
| } | ||
| </div> | ||
| } | ||
| </si-chat-message> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.