-
Notifications
You must be signed in to change notification settings - Fork 16
feat: add chat-input #948
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
feat: add chat-input #948
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
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-chat-input-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-chat-input-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-chat-input.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 @@ | ||
| - group: | ||
| - text: project-spec.pdf | ||
| - button "Remove attachment project-spec.pdf" | ||
| - group: | ||
| - text: mockup.png | ||
| - button "Remove attachment mockup.png" | ||
| - textbox "Chat message input": | ||
| - /placeholder: Enter a command, question or topic... | ||
| - button "Attach files" | ||
| - button "Take photo" | ||
| - button "Text formatting" | ||
| - button "More actions" | ||
| - button "Insert emoji" | ||
| - button "Send Message" | ||
| - text: The content is AI generated. Always verify the information for accuracy. |
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
23 changes: 23 additions & 0 deletions
23
projects/element-ng/chat-messages/si-chat-input-disclaimer.directive.ts
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,23 @@ | ||
| /** | ||
| * Copyright (c) Siemens 2016 - 2025 | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
| import { Directive } from '@angular/core'; | ||
|
|
||
| /** | ||
| * Directive to mark content as chat input disclaimer. | ||
| * Apply this directive to content that should be slotted into the disclaimer area. | ||
| * | ||
| * @example | ||
| * ```html | ||
| * <si-chat-input> | ||
| * <div siChatInputDisclaimer> | ||
| * Custom disclaimer content | ||
| * </div> | ||
| * </si-chat-input> | ||
| * ``` | ||
| */ | ||
| @Directive({ | ||
| selector: '[siChatInputDisclaimer]' | ||
| }) | ||
| export class SiChatInputDisclaimerDirective {} |
108 changes: 108 additions & 0 deletions
108
projects/element-ng/chat-messages/si-chat-input.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,108 @@ | ||
| <div class="input-wrapper border rounded-3 bg-body" (click)="onContainerClick($event)"> | ||
| @if (hasAttachments()) { | ||
| <div class="p-4 pb-0"> | ||
| <si-attachment-list | ||
| [attachments]="attachmentList" | ||
| [removeLabel]="removeAttachmentLabel()" | ||
| [removable]="true" | ||
| (remove)="removeAttachment($event)" | ||
| /> | ||
| </div> | ||
| } | ||
|
|
||
| <div class="p-4 pe-2 pb-0 si-body-2"> | ||
| <label class="form-label d-none" [for]="id">{{ label() | translate }}</label> | ||
| <textarea | ||
| #textInput | ||
| class="chat-textarea w-100 border-0 p-2" | ||
| rows="1" | ||
| [id]="id" | ||
| [placeholder]="placeholder() | translate" | ||
| [disabled]="disabled()" | ||
| [maxlength]="maxLength() || null" | ||
| [(ngModel)]="value" | ||
| (keydown)="onKeyDown($event)" | ||
| (input)="adjustTextareaHeight($event)" | ||
| ></textarea> | ||
| </div> | ||
|
|
||
| <div class="d-flex align-items-center justify-content-between px-4 ps-5 pb-2"> | ||
| <div class="d-flex align-items-center gap-4"> | ||
| @if (allowAttachments()) { | ||
| <input | ||
| #fileInput | ||
| type="file" | ||
| class="d-none" | ||
| siFileUpload | ||
| [accept]="accept()" | ||
| [maxFileSize]="maxFileSize()" | ||
| [multiple]="true" | ||
| (validFiles)="onFilesAdded($event)" | ||
| (fileError)="onFileError($event)" | ||
| /> | ||
|
|
||
| <button | ||
| type="button" | ||
| class="btn btn-ghost btn-circle btn-sm" | ||
| [attr.aria-label]="attachFileLabel() | translate" | ||
| [disabled]="disabled()" | ||
| (click)="fileInput.click()" | ||
| > | ||
| <si-icon icon="element-attachment" /> | ||
| </button> | ||
| } | ||
|
|
||
| @if (hasActions() || hasSecondaryActions()) { | ||
| <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> | ||
| } | ||
| <div #projected class="d-flex flex-wrap align-items-start gap-4"> | ||
| <ng-content /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <button | ||
| type="button" | ||
| class="btn btn-ghost btn-circle btn-sm" | ||
| [disabled]="buttonDisabled()" | ||
| [attr.aria-label]="buttonLabel() | translate" | ||
| (click)="onButtonClick()" | ||
| > | ||
| <si-icon class="text-primary" [icon]="buttonIcon()" /> | ||
| </button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="disclaimer-wrapper text-center mt-4 px-3"> | ||
| @if (disclaimer()) { | ||
| <span class="si-caption text-secondary d-block">{{ disclaimer() | translate }}</span> | ||
| } | ||
| <ng-content select="[siChatInputDisclaimer]" /> | ||
| </div> |
45 changes: 45 additions & 0 deletions
45
projects/element-ng/chat-messages/si-chat-input.component.scss
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,45 @@ | ||
| @use 'sass:map'; | ||
| @use '@siemens/element-theme/src/styles/variables'; | ||
|
|
||
| :host { | ||
| max-inline-size: 720px; | ||
| } | ||
|
|
||
| .input-wrapper { | ||
| border-color: variables.$element-ui-4; | ||
| background-color: variables.$element-base-input-experimental; | ||
| } | ||
|
|
||
| .chat-textarea { | ||
| // Prevent layout shift on first input | ||
| min-block-size: calc(1.5em * variables.$si-line-height-body); | ||
| font-family: inherit; | ||
| outline: none; | ||
| resize: none; | ||
| // stylelint-disable-next-line declaration-no-important | ||
| background-color: transparent !important; | ||
|
|
||
| &::placeholder { | ||
| color: variables.$element-text-secondary; | ||
| } | ||
|
|
||
| &:disabled { | ||
| // stylelint-disable-next-line declaration-no-important | ||
| background-color: transparent !important; | ||
| color: variables.$element-text-disabled; | ||
| cursor: not-allowed; | ||
|
|
||
| &::placeholder { | ||
| color: variables.$element-text-disabled; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .input-wrapper:has(.chat-textarea:focus-visible) { | ||
| @include variables.make-outline-focus(); | ||
| border-color: variables.$element-ui-1; | ||
| } | ||
|
|
||
| .disclaimer-wrapper:empty { | ||
| display: none; | ||
| } | ||
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.