Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
[attr.aria-label]="secondaryActionsLabel() | translate"
[attr.title]="secondaryActionsLabel() | translate"
>
<si-icon icon="element-optionsVertical" />
<si-icon [icon]="icons.elementOptionsVertical" />
</button>

<ng-template #secondaryActionsMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
ElementRef,
signal
} from '@angular/core';
import { SiIconComponent } from '@siemens/element-ng/icon';
import { elementOptionsVertical } from '@siemens/element-icons';
import { addIcons, SiIconComponent } from '@siemens/element-ng/icon';
import { MenuItem, SiMenuFactoryComponent } from '@siemens/element-ng/menu';
import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate';

Expand Down Expand Up @@ -56,6 +57,7 @@ import { SiChatMessageComponent } from './si-chat-message.component';
})
export class SiAiMessageComponent {
protected readonly formattedContent = viewChild<ElementRef<HTMLDivElement>>('formattedContent');
protected readonly icons = addIcons({ elementOptionsVertical });

/**
* The AI-generated message content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
[attr.aria-label]="(removeLabel() | translate) + ' ' + attachment.name"
(click)="remove.emit(attachment); $event.stopPropagation()"
>
<si-icon class="icon" icon="element-delete" />
<si-icon class="icon" [icon]="icons.elementDelete" />
</button>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* SPDX-License-Identifier: MIT
*/
import { booleanAttribute, Component, inject, input, output, TemplateRef } from '@angular/core';
import { SiIconComponent } from '@siemens/element-ng/icon';
import { elementDelete, elementDocument } from '@siemens/element-icons';
import { addIcons, SiIconComponent } from '@siemens/element-ng/icon';
import { SiModalService } from '@siemens/element-ng/modal';
import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate';

Expand Down Expand Up @@ -53,6 +54,7 @@ export interface Attachment {
})
export class SiAttachmentListComponent {
protected modalService = inject(SiModalService);
protected readonly icons = addIcons({ elementDelete, elementDocument });

/**
* List of attachments to display
Expand Down Expand Up @@ -110,6 +112,6 @@ export class SiAttachmentListComponent {

protected getFileIcon(name: string): string {
// TODO: Accept map and default it in file upload directive.
return 'element-document';
return this.icons.elementDocument;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
[disabled]="disabled()"
(click)="fileInput.click()"
>
<si-icon icon="element-attachment" />
<si-icon [icon]="icons.elementAttachment" />
</button>
}

Expand All @@ -81,7 +81,7 @@
[attr.aria-label]="secondaryActionsLabel() | translate"
[attr.title]="secondaryActionsLabel() | translate"
>
<si-icon icon="element-optionsVertical" />
<si-icon [icon]="icons.elementOptionsVertical" />
</button>

<ng-template #secondaryActionsMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { FileUploadError, UploadFile } from '@siemens/element-ng/file-uploader';

import { provideIconConfig } from '../icon';
import { MessageAction } from './message-action.model';
import {
ChatInputAttachment,
Expand All @@ -20,7 +21,8 @@ describe('SiChatInputComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TestComponent]
imports: [TestComponent],
providers: [provideIconConfig({ disableSvgIcons: false })]
}).compileComponents();

fixture = TestBed.createComponent(TestComponent);
Expand Down Expand Up @@ -369,8 +371,9 @@ describe('SiChatInputComponent', () => {
fixture.componentRef.setInput('interruptible', true);
fixture.detectChanges();

const icon = debugElement.query(By.css('button si-icon'));
expect(icon.componentInstance.icon()).toBe('element-stop-filled');
expect(
debugElement.query(By.css('button[aria-label="Interrupt"] [data-icon="elementStopFilled"]'))
).toBeTruthy();
});

it('should use interrupt button label when interruptible is true', () => {
Expand Down Expand Up @@ -481,16 +484,18 @@ describe('SiChatInputComponent', () => {
fixture.detectChanges();

expect((component as any).showInterruptButton()).toBe(false);
expect((component as any).buttonIcon()).toBe('element-send-filled');
expect((component as any).buttonLabel()).toContain('Send');
const sendButton = debugElement.query(By.css('button[aria-label="Send"]'));
expect(sendButton).toBeTruthy();
expect(sendButton.query(By.css('[data-icon="elementSendFilled"]'))).toBeTruthy();
});

it('should use interrupt mode when interruptible is true', () => {
fixture.componentRef.setInput('interruptible', true);
fixture.detectChanges();

expect((component as any).showInterruptButton()).toBe(true);
expect((component as any).buttonIcon()).toBe('element-stop-filled');
expect((component as any).buttonLabel()).toContain('Interrupt');
const interruptButton = debugElement.query(By.css('button[aria-label="Interrupt"]'));
expect(interruptButton).toBeTruthy();
expect(interruptButton.query(By.css('[data-icon="elementStopFilled"]'))).toBeTruthy();
});
});
20 changes: 16 additions & 4 deletions projects/element-ng/chat-messages/si-chat-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ import {
viewChild
} from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
elementAttachment,
elementOptionsVertical,
elementSendFilled,
elementStopFilled
} from '@siemens/element-icons';
import {
SiFileUploadDirective,
UploadFile,
FileUploadError
} from '@siemens/element-ng/file-uploader';
import { SiIconComponent } from '@siemens/element-ng/icon';
import { addIcons, SiIconComponent } from '@siemens/element-ng/icon';
import { MenuItem, SiMenuFactoryComponent } from '@siemens/element-ng/menu';
import { SiTranslatePipe, TranslatableString, t } from '@siemens/element-translate-ng/translate';

Expand Down Expand Up @@ -89,6 +95,12 @@ export class SiChatInputComponent implements AfterViewInit {
private readonly textInput = viewChild<ElementRef<HTMLTextAreaElement>>('textInput');
private readonly projectedContent = viewChild<ElementRef>('projected');
private readonly fileUploadDirective = viewChild(SiFileUploadDirective);
protected readonly icons = addIcons({
elementAttachment,
elementOptionsVertical,
elementSendFilled,
elementStopFilled
});

/**
* Current input value
Expand Down Expand Up @@ -205,9 +217,9 @@ export class SiChatInputComponent implements AfterViewInit {
/**
* Send button icon
*
* @defaultValue 'element-send-filled'
* @defaultValue this.icons.elementSendFilled
*/
readonly sendButtonIcon = input('element-send-filled');
readonly sendButtonIcon = input(this.icons.elementSendFilled);

/**
* Interrupt button label
Expand Down Expand Up @@ -298,7 +310,7 @@ export class SiChatInputComponent implements AfterViewInit {
return !this.canSend();
});
protected readonly buttonIcon = computed(() =>
this.showInterruptButton() ? 'element-stop-filled' : this.sendButtonIcon()
this.showInterruptButton() ? this.icons.elementStopFilled : this.sendButtonIcon()
);
protected readonly buttonLabel = computed(() =>
this.showInterruptButton() ? this.interruptButtonLabel() : this.sendButtonLabel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[attr.aria-label]="secondaryActionsLabel() | translate"
[attr.title]="secondaryActionsLabel() | translate"
>
<si-icon icon="element-optionsVertical" />
<si-icon [icon]="icons.elementOptionsVertical" />
</button>

<ng-template #secondaryActionsMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*/
import { CdkMenuTrigger } from '@angular/cdk/menu';
import { Component, effect, input, viewChild, ElementRef, computed, signal } from '@angular/core';
import { SiIconComponent } from '@siemens/element-ng/icon';
import { elementOptionsVertical } from '@siemens/element-icons';
import { addIcons, SiIconComponent } from '@siemens/element-ng/icon';
import { MenuItem, SiMenuFactoryComponent } from '@siemens/element-ng/menu';
import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate';

Expand Down Expand Up @@ -51,6 +52,7 @@ import { SiChatMessageComponent } from './si-chat-message.component';
})
export class SiUserMessageComponent {
protected readonly formattedContent = viewChild<ElementRef<HTMLDivElement>>('formattedContent');
protected readonly icons = addIcons({ elementOptionsVertical });

/**
* The user message content
Expand Down
Loading