igniteui-webcomponents 6.2.0 → 6.3.0-alpha.0
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.
- package/components/chat/chat-input.d.ts +70 -0
- package/components/chat/chat-input.js +266 -0
- package/components/chat/chat-input.js.map +1 -0
- package/components/chat/chat-message-list.d.ts +111 -0
- package/components/chat/chat-message-list.js +178 -0
- package/components/chat/chat-message-list.js.map +1 -0
- package/components/chat/chat-message.d.ts +57 -0
- package/components/chat/chat-message.js +59 -0
- package/components/chat/chat-message.js.map +1 -0
- package/components/chat/chat-state.d.ts +155 -0
- package/components/chat/chat-state.js +167 -0
- package/components/chat/chat-state.js.map +1 -0
- package/components/chat/chat.d.ts +164 -0
- package/components/chat/chat.js +168 -0
- package/components/chat/chat.js.map +1 -0
- package/components/chat/markdown-util.d.ts +2 -0
- package/components/chat/markdown-util.js +22 -0
- package/components/chat/markdown-util.js.map +1 -0
- package/components/chat/message-attachments.d.ts +45 -0
- package/components/chat/message-attachments.js +127 -0
- package/components/chat/message-attachments.js.map +1 -0
- package/components/chat/themes/chat.base.css.d.ts +1 -0
- package/components/chat/themes/chat.base.css.js +3 -0
- package/components/chat/themes/chat.base.css.js.map +1 -0
- package/components/chat/themes/dark/chat.bootstrap.css.d.ts +1 -0
- package/components/chat/themes/dark/chat.bootstrap.css.js +3 -0
- package/components/chat/themes/dark/chat.bootstrap.css.js.map +1 -0
- package/components/chat/themes/dark/chat.fluent.css.d.ts +1 -0
- package/components/chat/themes/dark/chat.fluent.css.js +3 -0
- package/components/chat/themes/dark/chat.fluent.css.js.map +1 -0
- package/components/chat/themes/dark/chat.indigo.css.d.ts +1 -0
- package/components/chat/themes/dark/chat.indigo.css.js +3 -0
- package/components/chat/themes/dark/chat.indigo.css.js.map +1 -0
- package/components/chat/themes/dark/chat.material.css.d.ts +1 -0
- package/components/chat/themes/dark/chat.material.css.js +3 -0
- package/components/chat/themes/dark/chat.material.css.js.map +1 -0
- package/components/chat/themes/input.base.css.d.ts +1 -0
- package/components/chat/themes/input.base.css.js +3 -0
- package/components/chat/themes/input.base.css.js.map +1 -0
- package/components/chat/themes/input.d.ts +2 -0
- package/components/chat/themes/input.js +35 -0
- package/components/chat/themes/input.js.map +1 -0
- package/components/chat/themes/light/chat.bootstrap.css.d.ts +1 -0
- package/components/chat/themes/light/chat.bootstrap.css.js +3 -0
- package/components/chat/themes/light/chat.bootstrap.css.js.map +1 -0
- package/components/chat/themes/light/chat.fluent.css.d.ts +1 -0
- package/components/chat/themes/light/chat.fluent.css.js +3 -0
- package/components/chat/themes/light/chat.fluent.css.js.map +1 -0
- package/components/chat/themes/light/chat.indigo.css.d.ts +1 -0
- package/components/chat/themes/light/chat.indigo.css.js +3 -0
- package/components/chat/themes/light/chat.indigo.css.js.map +1 -0
- package/components/chat/themes/light/chat.material.css.d.ts +1 -0
- package/components/chat/themes/light/chat.material.css.js +3 -0
- package/components/chat/themes/light/chat.material.css.js.map +1 -0
- package/components/chat/themes/light/chat.shared.css.d.ts +1 -0
- package/components/chat/themes/light/chat.shared.css.js +3 -0
- package/components/chat/themes/light/chat.shared.css.js.map +1 -0
- package/components/chat/themes/message-attachments.base.css.d.ts +1 -0
- package/components/chat/themes/message-attachments.base.css.js +3 -0
- package/components/chat/themes/message-attachments.base.css.js.map +1 -0
- package/components/chat/themes/message-list.base.css.d.ts +1 -0
- package/components/chat/themes/message-list.base.css.js +3 -0
- package/components/chat/themes/message-list.base.css.js.map +1 -0
- package/components/chat/themes/message.base.css.d.ts +1 -0
- package/components/chat/themes/message.base.css.js +3 -0
- package/components/chat/themes/message.base.css.js.map +1 -0
- package/components/chat/themes/shared/chat-message.common.css.d.ts +1 -0
- package/components/chat/themes/shared/chat-message.common.css.js +3 -0
- package/components/chat/themes/shared/chat-message.common.css.js.map +1 -0
- package/components/chat/themes/shared/chat.common.css.d.ts +1 -0
- package/components/chat/themes/shared/chat.common.css.js +3 -0
- package/components/chat/themes/shared/chat.common.css.js.map +1 -0
- package/components/chat/themes/shared/input/input.bootstrap.css.d.ts +1 -0
- package/components/chat/themes/shared/input/input.bootstrap.css.js +3 -0
- package/components/chat/themes/shared/input/input.bootstrap.css.js.map +1 -0
- package/components/chat/themes/shared/input/input.common.css.d.ts +1 -0
- package/components/chat/themes/shared/input/input.common.css.js +3 -0
- package/components/chat/themes/shared/input/input.common.css.js.map +1 -0
- package/components/chat/themes/shared/input/input.fluent.css.d.ts +1 -0
- package/components/chat/themes/shared/input/input.fluent.css.js +3 -0
- package/components/chat/themes/shared/input/input.fluent.css.js.map +1 -0
- package/components/chat/themes/shared/input/input.indigo.css.d.ts +1 -0
- package/components/chat/themes/shared/input/input.indigo.css.js +3 -0
- package/components/chat/themes/shared/input/input.indigo.css.js.map +1 -0
- package/components/chat/themes/shared/input/input.material.css.d.ts +1 -0
- package/components/chat/themes/shared/input/input.material.css.js +3 -0
- package/components/chat/themes/shared/input/input.material.css.js.map +1 -0
- package/components/chat/themes/shared/message-attachments.common.css.d.ts +1 -0
- package/components/chat/themes/shared/message-attachments.common.css.js +3 -0
- package/components/chat/themes/shared/message-attachments.common.css.js.map +1 -0
- package/components/chat/themes/shared/message-list.common.css.d.ts +1 -0
- package/components/chat/themes/shared/message-list.common.css.js +3 -0
- package/components/chat/themes/shared/message-list.common.css.js.map +1 -0
- package/components/chat/themes/themes.d.ts +2 -0
- package/components/chat/themes/themes.js +46 -0
- package/components/chat/themes/themes.js.map +1 -0
- package/components/chat/types.d.ts +190 -0
- package/components/chat/types.js +8 -0
- package/components/chat/types.js.map +1 -0
- package/components/checkbox/themes/dark/switch/switch.bootstrap.css.js +1 -1
- package/components/checkbox/themes/dark/switch/switch.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/dark/switch/switch.fluent.css.js +1 -1
- package/components/checkbox/themes/dark/switch/switch.fluent.css.js.map +1 -1
- package/components/checkbox/themes/dark/switch/switch.indigo.css.js +1 -1
- package/components/checkbox/themes/dark/switch/switch.indigo.css.js.map +1 -1
- package/components/checkbox/themes/dark/switch/switch.material.css.js +1 -1
- package/components/checkbox/themes/dark/switch/switch.material.css.js.map +1 -1
- package/components/checkbox/themes/light/switch/switch.bootstrap.css.js +1 -1
- package/components/checkbox/themes/light/switch/switch.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/light/switch/switch.fluent.css.js +1 -1
- package/components/checkbox/themes/light/switch/switch.fluent.css.js.map +1 -1
- package/components/checkbox/themes/light/switch/switch.indigo.css.js +1 -1
- package/components/checkbox/themes/light/switch/switch.indigo.css.js.map +1 -1
- package/components/checkbox/themes/light/switch/switch.material.css.js +1 -1
- package/components/checkbox/themes/light/switch/switch.material.css.js.map +1 -1
- package/components/common/context.d.ts +5 -1
- package/components/common/context.js +2 -1
- package/components/common/context.js.map +1 -1
- package/components/common/definitions/defineAllComponents.js +2 -0
- package/components/common/definitions/defineAllComponents.js.map +1 -1
- package/custom-elements.json +15692 -13967
- package/igniteui-webcomponents.css-data.json +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/web-types.json +2 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { LitElement, type TemplateResult } from 'lit';
|
|
2
|
+
import type { Constructor } from '../common/mixins/constructor.js';
|
|
3
|
+
import type { IgcChatOptions, IgcMessage, IgcMessageAttachment } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Defines the custom events dispatched by the `<igc-chat>` component.
|
|
6
|
+
*/
|
|
7
|
+
export interface IgcChatComponentEventMap {
|
|
8
|
+
/**
|
|
9
|
+
* Dispatched when a new chat message is created (sent).
|
|
10
|
+
*
|
|
11
|
+
* @event igcMessageCreated
|
|
12
|
+
* @type {CustomEvent<IgcMessage>}
|
|
13
|
+
* @detail The message that was created.
|
|
14
|
+
*/
|
|
15
|
+
igcMessageCreated: CustomEvent<IgcMessage>;
|
|
16
|
+
/**
|
|
17
|
+
* Dispatched when a chat message attachment is clicked.
|
|
18
|
+
*
|
|
19
|
+
* @event igcAttachmentClick
|
|
20
|
+
* @type {CustomEvent<IgcMessageAttachment>}
|
|
21
|
+
* @detail The attachment that was clicked.
|
|
22
|
+
*/
|
|
23
|
+
igcAttachmentClick: CustomEvent<IgcMessageAttachment>;
|
|
24
|
+
/**
|
|
25
|
+
* Dispatched when an attachment is changed (e.g., updated or removed).
|
|
26
|
+
*
|
|
27
|
+
* @event igcAttachmentChange
|
|
28
|
+
* @type {CustomEvent<IgcMessageAttachment>}
|
|
29
|
+
* @detail The attachment that was changed.
|
|
30
|
+
*/
|
|
31
|
+
igcAttachmentChange: CustomEvent<IgcMessageAttachment>;
|
|
32
|
+
/**
|
|
33
|
+
* Dispatched during an attachment drag operation.
|
|
34
|
+
*
|
|
35
|
+
* @event igcAttachmentDrag
|
|
36
|
+
* @type {CustomEvent<any>}
|
|
37
|
+
* @detail The drag event payload.
|
|
38
|
+
*/
|
|
39
|
+
igcAttachmentDrag: CustomEvent<any>;
|
|
40
|
+
/**
|
|
41
|
+
* Dispatched when an attachment is dropped (e.g., in a drag-and-drop operation).
|
|
42
|
+
*
|
|
43
|
+
* @event igcAttachmentDrop
|
|
44
|
+
* @type {CustomEvent<any>}
|
|
45
|
+
* @detail The drop event payload.
|
|
46
|
+
*/
|
|
47
|
+
igcAttachmentDrop: CustomEvent<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Dispatched when the typing status changes (e.g., user starts or stops typing).
|
|
50
|
+
*
|
|
51
|
+
* @event igcTypingChange
|
|
52
|
+
* @type {CustomEvent<boolean>}
|
|
53
|
+
* @detail `true` if typing started, `false` if stopped.
|
|
54
|
+
*/
|
|
55
|
+
igcTypingChange: CustomEvent<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Dispatched when the chat input field gains focus.
|
|
58
|
+
*
|
|
59
|
+
* @event igcInputFocus
|
|
60
|
+
* @type {CustomEvent<any>}
|
|
61
|
+
* @detail Focus event payload.
|
|
62
|
+
*/
|
|
63
|
+
igcInputFocus: CustomEvent<any>;
|
|
64
|
+
/**
|
|
65
|
+
* Dispatched when the chat input field loses focus.
|
|
66
|
+
*
|
|
67
|
+
* @event igcInputBlur
|
|
68
|
+
* @type {CustomEvent<any>}
|
|
69
|
+
* @detail Blur event payload.
|
|
70
|
+
*/
|
|
71
|
+
igcInputBlur: CustomEvent<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Dispatched when the content of the chat input changes.
|
|
74
|
+
*
|
|
75
|
+
* @event igcInputChange
|
|
76
|
+
* @type {CustomEvent<string>}
|
|
77
|
+
* @detail The current text value of the input.
|
|
78
|
+
*/
|
|
79
|
+
igcInputChange: CustomEvent<string>;
|
|
80
|
+
}
|
|
81
|
+
declare const IgcChatComponent_base: Constructor<import("../common/mixins/event-emitter.js").EventEmitterInterface<IgcChatComponentEventMap>> & Constructor<LitElement>;
|
|
82
|
+
/**
|
|
83
|
+
* A chat UI component for displaying messages, attachments, and input interaction.
|
|
84
|
+
*
|
|
85
|
+
* This component is part of the Ignite UI Web Components suite.
|
|
86
|
+
*
|
|
87
|
+
* @element igc-chat
|
|
88
|
+
* @slot prefix - Slot for injecting content (e.g., avatar or icon) before the chat title.
|
|
89
|
+
* @slot title - Slot for overriding the chat title content.
|
|
90
|
+
* @slot actions - Slot for injecting header actions (e.g., buttons, menus).
|
|
91
|
+
* @slot suggestions-header - Slot for rendering a custom header for the suggestions list.
|
|
92
|
+
* @slot suggestions - Slot for rendering a custom list of quick reply suggestions.
|
|
93
|
+
* @slot suggestions-actions - Slot for rendering additional actions.
|
|
94
|
+
* @slot suggestion - Slot for rendering a single suggestion item.
|
|
95
|
+
* @slot empty-state - Slot shown when there are no messages.
|
|
96
|
+
*
|
|
97
|
+
* @csspart header - Styles the header container.
|
|
98
|
+
* @csspart prefix - Styles the element before the title (e.g., avatar).
|
|
99
|
+
* @csspart title - Styles the chat header title.
|
|
100
|
+
* @csspart suggestions - Styles the suggestion container.
|
|
101
|
+
* @csspart suggestion - Styles each suggestion item.
|
|
102
|
+
*/
|
|
103
|
+
export default class IgcChatComponent extends IgcChatComponent_base {
|
|
104
|
+
static readonly tagName = "igc-chat";
|
|
105
|
+
static styles: import("lit").CSSResult[];
|
|
106
|
+
/**
|
|
107
|
+
* Registers the chat component and its child components.
|
|
108
|
+
* Should be called once before using the component.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* IgcChatComponent.register();
|
|
112
|
+
*/
|
|
113
|
+
static register(): void;
|
|
114
|
+
private readonly _chatState;
|
|
115
|
+
private _context;
|
|
116
|
+
private _hasContent;
|
|
117
|
+
private _chatInput;
|
|
118
|
+
constructor();
|
|
119
|
+
/**
|
|
120
|
+
* The list of chat messages currently displayed.
|
|
121
|
+
* Use this property to set or update the message history.
|
|
122
|
+
*/
|
|
123
|
+
set messages(value: IgcMessage[]);
|
|
124
|
+
get messages(): IgcMessage[];
|
|
125
|
+
/**
|
|
126
|
+
* The chat message currently being composed but not yet sent.
|
|
127
|
+
* Includes the draft text and any attachments.
|
|
128
|
+
*/
|
|
129
|
+
set draftMessage(value: {
|
|
130
|
+
text: string;
|
|
131
|
+
attachments?: IgcMessageAttachment[];
|
|
132
|
+
});
|
|
133
|
+
get draftMessage(): {
|
|
134
|
+
text: string;
|
|
135
|
+
attachments?: IgcMessageAttachment[];
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Controls the chat behavior and appearance through a configuration object.
|
|
139
|
+
* Use this to toggle UI options, provide suggestions, templates, etc.
|
|
140
|
+
*/
|
|
141
|
+
set options(value: IgcChatOptions);
|
|
142
|
+
get options(): IgcChatOptions | undefined;
|
|
143
|
+
/** Returns the default attachments element. */
|
|
144
|
+
get defaultAttachments(): TemplateResult;
|
|
145
|
+
/** Returns the default textarea element. */
|
|
146
|
+
get defaultTextArea(): TemplateResult;
|
|
147
|
+
/** Returns the default file upload button element. */
|
|
148
|
+
get defaultFileUploadButton(): TemplateResult;
|
|
149
|
+
/** Returns the default send message button element. */
|
|
150
|
+
get defaultSendButton(): TemplateResult;
|
|
151
|
+
protected contextChanged(): void;
|
|
152
|
+
private renderHeader;
|
|
153
|
+
private renderSuggestions;
|
|
154
|
+
protected firstUpdated(): void;
|
|
155
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
156
|
+
protected render(): TemplateResult<1>;
|
|
157
|
+
}
|
|
158
|
+
declare global {
|
|
159
|
+
interface HTMLElementTagNameMap {
|
|
160
|
+
/** The `<igc-chat>` custom element. */
|
|
161
|
+
'igc-chat': IgcChatComponent;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { ContextProvider } from '@lit/context';
|
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
|
9
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
10
|
+
import { addThemingController } from '../../theming/theming-controller.js';
|
|
11
|
+
import IgcButtonComponent from '../button/button.js';
|
|
12
|
+
import { chatContext } from '../common/context.js';
|
|
13
|
+
import { watch } from '../common/decorators/watch.js';
|
|
14
|
+
import { registerComponent } from '../common/definitions/register.js';
|
|
15
|
+
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
|
|
16
|
+
import IgcChatInputComponent from './chat-input.js';
|
|
17
|
+
import IgcChatMessageListComponent from './chat-message-list.js';
|
|
18
|
+
import { createChatState } from './chat-state.js';
|
|
19
|
+
import { styles } from './themes/chat.base.css.js';
|
|
20
|
+
import { styles as shared } from './themes/shared/chat.common.css.js';
|
|
21
|
+
import { all } from './themes/themes.js';
|
|
22
|
+
class IgcChatComponent extends EventEmitterMixin(LitElement) {
|
|
23
|
+
static register() {
|
|
24
|
+
registerComponent(IgcChatComponent, IgcChatInputComponent, IgcChatMessageListComponent, IgcButtonComponent);
|
|
25
|
+
}
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this._chatState = createChatState(this);
|
|
29
|
+
this._context = new ContextProvider(this, {
|
|
30
|
+
context: chatContext,
|
|
31
|
+
initialValue: this._chatState,
|
|
32
|
+
});
|
|
33
|
+
this._hasContent = false;
|
|
34
|
+
addThemingController(this, all);
|
|
35
|
+
}
|
|
36
|
+
set messages(value) {
|
|
37
|
+
this._chatState.messages = value;
|
|
38
|
+
}
|
|
39
|
+
get messages() {
|
|
40
|
+
return this._chatState.messages;
|
|
41
|
+
}
|
|
42
|
+
set draftMessage(value) {
|
|
43
|
+
if (this._chatState) {
|
|
44
|
+
this._chatState.inputValue = value.text;
|
|
45
|
+
this._chatState.inputAttachments = value.attachments || [];
|
|
46
|
+
this.requestUpdate();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
get draftMessage() {
|
|
50
|
+
return {
|
|
51
|
+
text: this._chatState?.inputValue,
|
|
52
|
+
attachments: this._chatState?.inputAttachments,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
set options(value) {
|
|
56
|
+
this._chatState.options = value;
|
|
57
|
+
}
|
|
58
|
+
get options() {
|
|
59
|
+
return this._chatState.options;
|
|
60
|
+
}
|
|
61
|
+
get defaultAttachments() {
|
|
62
|
+
return this._chatInput.defaultAttachmentsArea;
|
|
63
|
+
}
|
|
64
|
+
get defaultTextArea() {
|
|
65
|
+
return this._chatInput.defaultTextArea;
|
|
66
|
+
}
|
|
67
|
+
get defaultFileUploadButton() {
|
|
68
|
+
return this._chatInput.defaultFileUploadButton;
|
|
69
|
+
}
|
|
70
|
+
get defaultSendButton() {
|
|
71
|
+
return this._chatInput.defaultSendButton;
|
|
72
|
+
}
|
|
73
|
+
contextChanged() {
|
|
74
|
+
this._context.setValue(this._chatState, true);
|
|
75
|
+
}
|
|
76
|
+
renderHeader() {
|
|
77
|
+
return html ` <div part="header">
|
|
78
|
+
<slot name="prefix" part="prefix"></slot>
|
|
79
|
+
<slot name="title" part="title"
|
|
80
|
+
>${this._chatState.options?.headerText}</slot
|
|
81
|
+
>
|
|
82
|
+
<slot name="actions" part="actions"></slot>
|
|
83
|
+
</div>`;
|
|
84
|
+
}
|
|
85
|
+
renderSuggestions() {
|
|
86
|
+
return html ` <div
|
|
87
|
+
part="suggestions-container"
|
|
88
|
+
role="list"
|
|
89
|
+
aria-label="Suggestions"
|
|
90
|
+
>
|
|
91
|
+
<slot name="suggestions-header" part="suggestions-header"></slot>
|
|
92
|
+
<slot name="suggestions" part="suggestions">
|
|
93
|
+
${this._chatState.options?.suggestions?.map((suggestion) => html `
|
|
94
|
+
<slot name="suggestion" part="suggestion" role="listitem">
|
|
95
|
+
<igc-chip
|
|
96
|
+
@click=${() => this._chatState?.handleSuggestionClick(suggestion)}
|
|
97
|
+
>
|
|
98
|
+
<span>${suggestion}</span>
|
|
99
|
+
</igc-chip>
|
|
100
|
+
</slot>
|
|
101
|
+
`)}
|
|
102
|
+
</slot>
|
|
103
|
+
<slot name="suggestions-actions" part="suggestions-actions"></slot>
|
|
104
|
+
</div>`;
|
|
105
|
+
}
|
|
106
|
+
firstUpdated() {
|
|
107
|
+
this._context.setValue(this._chatState, true);
|
|
108
|
+
}
|
|
109
|
+
createRenderRoot() {
|
|
110
|
+
const root = super.createRenderRoot();
|
|
111
|
+
root.addEventListener('slotchange', () => {
|
|
112
|
+
this._hasContent =
|
|
113
|
+
this._chatState?.hasSlotContent('prefix') ||
|
|
114
|
+
this._chatState?.hasSlotContent('title') ||
|
|
115
|
+
this._chatState?.hasSlotContent('actions');
|
|
116
|
+
});
|
|
117
|
+
return root;
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
const hasSuggestions = this._chatState.options?.suggestions &&
|
|
121
|
+
this._chatState.options.suggestions.length > 0;
|
|
122
|
+
return html `
|
|
123
|
+
<div part="chat-container">
|
|
124
|
+
${this._hasContent || this._chatState.options?.headerText
|
|
125
|
+
? this.renderHeader()
|
|
126
|
+
: nothing}
|
|
127
|
+
${this.messages.length === 0
|
|
128
|
+
? html `<div part="empty-state">
|
|
129
|
+
<slot name="empty-state"> </slot>
|
|
130
|
+
</div>`
|
|
131
|
+
: html `<igc-chat-message-list> </igc-chat-message-list>`}
|
|
132
|
+
${hasSuggestions &&
|
|
133
|
+
this._chatState.suggestionsPosition === 'below-messages'
|
|
134
|
+
? this.renderSuggestions()
|
|
135
|
+
: nothing}
|
|
136
|
+
<igc-chat-input> </igc-chat-input>
|
|
137
|
+
${hasSuggestions &&
|
|
138
|
+
this._chatState.suggestionsPosition === 'below-input'
|
|
139
|
+
? this.renderSuggestions()
|
|
140
|
+
: nothing}
|
|
141
|
+
</div>
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
IgcChatComponent.tagName = 'igc-chat';
|
|
146
|
+
IgcChatComponent.styles = [styles, shared];
|
|
147
|
+
export default IgcChatComponent;
|
|
148
|
+
__decorate([
|
|
149
|
+
state()
|
|
150
|
+
], IgcChatComponent.prototype, "_hasContent", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
query(IgcChatInputComponent.tagName)
|
|
153
|
+
], IgcChatComponent.prototype, "_chatInput", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
property({ reflect: true, attribute: false })
|
|
156
|
+
], IgcChatComponent.prototype, "messages", null);
|
|
157
|
+
__decorate([
|
|
158
|
+
property({ reflect: true, attribute: false })
|
|
159
|
+
], IgcChatComponent.prototype, "draftMessage", null);
|
|
160
|
+
__decorate([
|
|
161
|
+
property({ attribute: false })
|
|
162
|
+
], IgcChatComponent.prototype, "options", null);
|
|
163
|
+
__decorate([
|
|
164
|
+
watch('messages'),
|
|
165
|
+
watch('draftMessage'),
|
|
166
|
+
watch('options')
|
|
167
|
+
], IgcChatComponent.prototype, "contextChanged", null);
|
|
168
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../src/components/chat/chat.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,qBAAqB,MAAM,iBAAiB,CAAC;AACpD,OAAO,2BAA2B,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAkHzC,MAAqB,gBAAiB,SAAQ,iBAAiB,CAG7D,UAAU,CAAC;IAaJ,MAAM,CAAC,QAAQ;QACpB,iBAAiB,CACf,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,k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CAAC;IACjB,KAAK,CAAC,cAAc,CAAC;IACrB,KAAK,CAAC,SAAS,CAAC;sDAGhB","sourcesContent":["import { ContextProvider } from '@lit/context';\nimport { html, LitElement, nothing, type TemplateResult } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcButtonComponent from '../button/button.js';\nimport { chatContext } from '../common/context.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport type { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport IgcChatInputComponent from './chat-input.js';\nimport IgcChatMessageListComponent from './chat-message-list.js';\nimport { createChatState } from './chat-state.js';\nimport { styles } from './themes/chat.base.css.js';\nimport { styles as shared } from './themes/shared/chat.common.css.js';\nimport { all } from './themes/themes.js';\nimport type {\n IgcChatOptions,\n IgcMessage,\n IgcMessageAttachment,\n} from './types.js';\n\n/**\n * Defines the custom events dispatched by the `<igc-chat>` component.\n */\nexport interface IgcChatComponentEventMap {\n /**\n * Dispatched when a new chat message is created (sent).\n *\n * @event igcMessageCreated\n * @type {CustomEvent<IgcMessage>}\n * @detail The message that was created.\n */\n igcMessageCreated: CustomEvent<IgcMessage>;\n\n /**\n * Dispatched when a chat message attachment is clicked.\n *\n * @event igcAttachmentClick\n * @type {CustomEvent<IgcMessageAttachment>}\n * @detail The attachment that was clicked.\n */\n igcAttachmentClick: CustomEvent<IgcMessageAttachment>;\n\n /**\n * Dispatched when an attachment is changed (e.g., updated or removed).\n *\n * @event igcAttachmentChange\n * @type {CustomEvent<IgcMessageAttachment>}\n * @detail The attachment that was changed.\n */\n igcAttachmentChange: CustomEvent<IgcMessageAttachment>;\n\n /**\n * Dispatched during an attachment drag operation.\n *\n * @event igcAttachmentDrag\n * @type {CustomEvent<any>}\n * @detail The drag event payload.\n */\n igcAttachmentDrag: CustomEvent<any>;\n\n /**\n * Dispatched when an attachment is dropped (e.g., in a drag-and-drop operation).\n *\n * @event igcAttachmentDrop\n * @type {CustomEvent<any>}\n * @detail The drop event payload.\n */\n igcAttachmentDrop: CustomEvent<any>;\n\n /**\n * Dispatched when the typing status changes (e.g., user starts or stops typing).\n *\n * @event igcTypingChange\n * @type {CustomEvent<boolean>}\n * @detail `true` if typing started, `false` if stopped.\n */\n igcTypingChange: CustomEvent<boolean>;\n\n /**\n * Dispatched when the chat input field gains focus.\n *\n * @event igcInputFocus\n * @type {CustomEvent<any>}\n * @detail Focus event payload.\n */\n igcInputFocus: CustomEvent<any>;\n\n /**\n * Dispatched when the chat input field loses focus.\n *\n * @event igcInputBlur\n * @type {CustomEvent<any>}\n * @detail Blur event payload.\n */\n igcInputBlur: CustomEvent<any>;\n\n /**\n * Dispatched when the content of the chat input changes.\n *\n * @event igcInputChange\n * @type {CustomEvent<string>}\n * @detail The current text value of the input.\n */\n igcInputChange: CustomEvent<string>;\n}\n\n/**\n * A chat UI component for displaying messages, attachments, and input interaction.\n *\n * This component is part of the Ignite UI Web Components suite.\n *\n * @element igc-chat\n * @slot prefix - Slot for injecting content (e.g., avatar or icon) before the chat title.\n * @slot title - Slot for overriding the chat title content.\n * @slot actions - Slot for injecting header actions (e.g., buttons, menus).\n * @slot suggestions-header - Slot for rendering a custom header for the suggestions list.\n * @slot suggestions - Slot for rendering a custom list of quick reply suggestions.\n * @slot suggestions-actions - Slot for rendering additional actions.\n * @slot suggestion - Slot for rendering a single suggestion item.\n * @slot empty-state - Slot shown when there are no messages.\n *\n * @csspart header - Styles the header container.\n * @csspart prefix - Styles the element before the title (e.g., avatar).\n * @csspart title - Styles the chat header title.\n * @csspart suggestions - Styles the suggestion container.\n * @csspart suggestion - Styles each suggestion item.\n */\nexport default class IgcChatComponent extends EventEmitterMixin<\n IgcChatComponentEventMap,\n Constructor<LitElement>\n>(LitElement) {\n public static readonly tagName = 'igc-chat';\n\n public static styles = [styles, shared];\n\n /* blazorSuppress */\n /**\n * Registers the chat component and its child components.\n * Should be called once before using the component.\n *\n * @example\n * IgcChatComponent.register();\n */\n public static register() {\n registerComponent(\n IgcChatComponent,\n IgcChatInputComponent,\n IgcChatMessageListComponent,\n IgcButtonComponent\n );\n }\n\n private readonly _chatState = createChatState(this);\n\n private _context = new ContextProvider(this, {\n context: chatContext,\n initialValue: this._chatState,\n });\n\n @state()\n private _hasContent = false;\n\n @query(IgcChatInputComponent.tagName)\n private _chatInput!: IgcChatInputComponent;\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n /**\n * The list of chat messages currently displayed.\n * Use this property to set or update the message history.\n */\n @property({ reflect: true, attribute: false })\n public set messages(value: IgcMessage[]) {\n this._chatState.messages = value;\n }\n\n public get messages(): IgcMessage[] {\n return this._chatState.messages;\n }\n\n /**\n * The chat message currently being composed but not yet sent.\n * Includes the draft text and any attachments.\n */\n @property({ reflect: true, attribute: false })\n public set draftMessage(value: {\n text: string;\n attachments?: IgcMessageAttachment[];\n }) {\n if (this._chatState) {\n this._chatState.inputValue = value.text;\n this._chatState.inputAttachments = value.attachments || [];\n this.requestUpdate();\n }\n }\n\n public get draftMessage(): {\n text: string;\n attachments?: IgcMessageAttachment[];\n } {\n return {\n text: this._chatState?.inputValue,\n attachments: this._chatState?.inputAttachments,\n };\n }\n\n /**\n * Controls the chat behavior and appearance through a configuration object.\n * Use this to toggle UI options, provide suggestions, templates, etc.\n */\n @property({ attribute: false })\n public set options(value: IgcChatOptions) {\n this._chatState.options = value;\n }\n\n public get options(): IgcChatOptions | undefined {\n return this._chatState.options;\n }\n\n /** Returns the default attachments element. */\n public get defaultAttachments(): TemplateResult {\n return this._chatInput.defaultAttachmentsArea;\n }\n\n /** Returns the default textarea element. */\n public get defaultTextArea(): TemplateResult {\n return this._chatInput.defaultTextArea;\n }\n\n /** Returns the default file upload button element. */\n public get defaultFileUploadButton(): TemplateResult {\n return this._chatInput.defaultFileUploadButton;\n }\n\n /** Returns the default send message button element. */\n public get defaultSendButton(): TemplateResult {\n return this._chatInput.defaultSendButton;\n }\n\n @watch('messages')\n @watch('draftMessage')\n @watch('options')\n protected contextChanged() {\n this._context.setValue(this._chatState, true);\n }\n\n private renderHeader() {\n return html` <div part=\"header\">\n <slot name=\"prefix\" part=\"prefix\"></slot>\n <slot name=\"title\" part=\"title\"\n >${this._chatState.options?.headerText}</slot\n >\n <slot name=\"actions\" part=\"actions\"></slot>\n </div>`;\n }\n\n private renderSuggestions() {\n return html` <div\n part=\"suggestions-container\"\n role=\"list\"\n aria-label=\"Suggestions\"\n >\n <slot name=\"suggestions-header\" part=\"suggestions-header\"></slot>\n <slot name=\"suggestions\" part=\"suggestions\">\n ${this._chatState.options?.suggestions?.map(\n (suggestion) => html`\n <slot name=\"suggestion\" part=\"suggestion\" role=\"listitem\">\n <igc-chip\n @click=${() =>\n this._chatState?.handleSuggestionClick(suggestion)}\n >\n <span>${suggestion}</span>\n </igc-chip>\n </slot>\n `\n )}\n </slot>\n <slot name=\"suggestions-actions\" part=\"suggestions-actions\"></slot>\n </div>`;\n }\n\n protected override firstUpdated() {\n this._context.setValue(this._chatState, true);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n root.addEventListener('slotchange', () => {\n this._hasContent =\n this._chatState?.hasSlotContent('prefix') ||\n this._chatState?.hasSlotContent('title') ||\n this._chatState?.hasSlotContent('actions');\n });\n return root;\n }\n\n protected override render() {\n const hasSuggestions =\n this._chatState.options?.suggestions &&\n this._chatState.options.suggestions.length > 0;\n return html`\n <div part=\"chat-container\">\n ${this._hasContent || this._chatState.options?.headerText\n ? this.renderHeader()\n : nothing}\n ${this.messages.length === 0\n ? html`<div part=\"empty-state\">\n <slot name=\"empty-state\"> </slot>\n </div>`\n : html`<igc-chat-message-list> </igc-chat-message-list>`}\n ${hasSuggestions &&\n this._chatState.suggestionsPosition === 'below-messages'\n ? this.renderSuggestions()\n : nothing}\n <igc-chat-input> </igc-chat-input>\n ${hasSuggestions &&\n this._chatState.suggestionsPosition === 'below-input'\n ? this.renderSuggestions()\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** The `<igc-chat>` custom element. */\n 'igc-chat': IgcChatComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { marked } from 'marked';
|
|
3
|
+
marked.setOptions({
|
|
4
|
+
gfm: true,
|
|
5
|
+
breaks: true,
|
|
6
|
+
});
|
|
7
|
+
const renderer = new marked.Renderer();
|
|
8
|
+
renderer.code = (code, language) => {
|
|
9
|
+
return `<pre><code class="language-${language}">${code}</code></pre>`;
|
|
10
|
+
};
|
|
11
|
+
renderer.link = (href, title, text) => {
|
|
12
|
+
return `<a href="${href}" target="_blank" rel="noopener noreferrer" ${title ? `title="${title}"` : ''}>${text}</a>`;
|
|
13
|
+
};
|
|
14
|
+
export function renderMarkdown(text) {
|
|
15
|
+
if (!text)
|
|
16
|
+
return html ``;
|
|
17
|
+
const rendered = marked(text, { renderer }).toString();
|
|
18
|
+
const template = document.createElement('template');
|
|
19
|
+
template.innerHTML = rendered;
|
|
20
|
+
return html `${template.content}`;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=markdown-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-util.js","sourceRoot":"","sources":["../../../src/components/chat/markdown-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,IAAI;IACT,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;AAGvC,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;IACjC,OAAO,8BAA8B,QAAQ,KAAK,IAAI,eAAe,CAAC;AACxE,CAAC,CAAC;AAGF,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IACpC,OAAO,YAAY,IAAI,+CAA+C,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,MAAM,CAAC;AACtH,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA,EAAE,CAAC;IAEzB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC;IAE9B,OAAO,IAAI,CAAA,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { html, type TemplateResult } from 'lit';\nimport { marked } from 'marked';\n\nmarked.setOptions({\n gfm: true,\n breaks: true,\n});\n\nconst renderer = new marked.Renderer();\n\n// Customize code rendering\nrenderer.code = (code, language) => {\n return `<pre><code class=\"language-${language}\">${code}</code></pre>`;\n};\n\n// Customize link rendering\nrenderer.link = (href, title, text) => {\n return `<a href=\"${href}\" target=\"_blank\" rel=\"noopener noreferrer\" ${title ? `title=\"${title}\"` : ''}>${text}</a>`;\n};\n\nexport function renderMarkdown(text: string): TemplateResult {\n if (!text) return html``;\n\n const rendered = marked(text, { renderer }).toString();\n const template = document.createElement('template');\n template.innerHTML = rendered;\n\n return html`${template.content}`;\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { type IgcMessage } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A component that renders message attachments within a chat.
|
|
5
|
+
*
|
|
6
|
+
* Displays attachments such as images or files, supporting custom templates
|
|
7
|
+
* and default rendering using expansion panels.
|
|
8
|
+
*
|
|
9
|
+
* @element igc-message-attachments
|
|
10
|
+
*
|
|
11
|
+
* @csspart attachments-container - Container wrapping all attachments.
|
|
12
|
+
* @csspart attachment - Wrapper for a single attachment.
|
|
13
|
+
* @csspart attachment-header - Wrapper for a single attachment header.
|
|
14
|
+
* @csspart attachments-content - Part representing the attachment preview.
|
|
15
|
+
* @csspart attachment-icon - Icon part representing the attachment type.
|
|
16
|
+
* @csspart file-name - Part representing the attachment's file name.
|
|
17
|
+
* @csspart actions - Container for header action buttons.
|
|
18
|
+
* @csspart image-attachment - Part for the image element inside an image attachment.
|
|
19
|
+
*
|
|
20
|
+
* @fires igcAttachmentClick - Fired when an attachment header is toggled (clicked).
|
|
21
|
+
*/
|
|
22
|
+
export default class IgcMessageAttachmentsComponent extends LitElement {
|
|
23
|
+
static readonly tagName = "igc-message-attachments";
|
|
24
|
+
static styles: import("lit").CSSResult[];
|
|
25
|
+
private _chatState?;
|
|
26
|
+
static register(): void;
|
|
27
|
+
/**
|
|
28
|
+
* The array of attachments to render.
|
|
29
|
+
*/
|
|
30
|
+
message: IgcMessage | undefined;
|
|
31
|
+
constructor();
|
|
32
|
+
private handleHeaderClick;
|
|
33
|
+
private getURL;
|
|
34
|
+
private defaulAttachmentContent;
|
|
35
|
+
private renderAttachmentHeaderText;
|
|
36
|
+
private renderAttachmentHeaderActions;
|
|
37
|
+
private renderAttachmentContent;
|
|
38
|
+
private renderDefaultAttachmentsTemplate;
|
|
39
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface HTMLElementTagNameMap {
|
|
43
|
+
'igc-message-attachments': IgcMessageAttachmentsComponent;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { consume } from '@lit/context';
|
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
|
9
|
+
import { property } from 'lit/decorators.js';
|
|
10
|
+
import IgcIconButtonComponent from '../button/icon-button.js';
|
|
11
|
+
import { chatContext } from '../common/context.js';
|
|
12
|
+
import { registerComponent } from '../common/definitions/register.js';
|
|
13
|
+
import IgcExpansionPanelComponent from '../expansion-panel/expansion-panel.js';
|
|
14
|
+
import IgcIconComponent from '../icon/icon.js';
|
|
15
|
+
import { registerIconFromText } from '../icon/icon.registry.js';
|
|
16
|
+
import { styles } from './themes/message-attachments.base.css.js';
|
|
17
|
+
import { styles as shared } from './themes/shared/message-attachments.common.css.js';
|
|
18
|
+
import { closeIcon, fileIcon, imageIcon, moreIcon, previewIcon, } from './types.js';
|
|
19
|
+
class IgcMessageAttachmentsComponent extends LitElement {
|
|
20
|
+
static register() {
|
|
21
|
+
registerComponent(IgcMessageAttachmentsComponent, IgcIconComponent, IgcIconButtonComponent, IgcExpansionPanelComponent);
|
|
22
|
+
}
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
registerIconFromText('close', closeIcon, 'material');
|
|
26
|
+
registerIconFromText('file', fileIcon, 'material');
|
|
27
|
+
registerIconFromText('image', imageIcon, 'material');
|
|
28
|
+
registerIconFromText('preview', previewIcon, 'material');
|
|
29
|
+
registerIconFromText('more', moreIcon, 'material');
|
|
30
|
+
}
|
|
31
|
+
handleHeaderClick(attachment) {
|
|
32
|
+
this._chatState?.emitEvent('igcAttachmentClick', { detail: attachment });
|
|
33
|
+
}
|
|
34
|
+
getURL(attachment) {
|
|
35
|
+
if (attachment.url) {
|
|
36
|
+
return attachment.url;
|
|
37
|
+
}
|
|
38
|
+
if (attachment.file) {
|
|
39
|
+
return URL.createObjectURL(attachment.file);
|
|
40
|
+
}
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
defaulAttachmentContent(attachment) {
|
|
44
|
+
return html `${attachment.type === 'image' ||
|
|
45
|
+
attachment.file?.type.startsWith('image/')
|
|
46
|
+
? html `<img
|
|
47
|
+
part="image-attachment"
|
|
48
|
+
src=${this.getURL(attachment)}
|
|
49
|
+
alt=${attachment.name}
|
|
50
|
+
/>`
|
|
51
|
+
: nothing}`;
|
|
52
|
+
}
|
|
53
|
+
renderAttachmentHeaderText(attachment) {
|
|
54
|
+
return html `<div part="details">
|
|
55
|
+
${this._chatState?.options?.templates?.attachmentHeaderTemplate &&
|
|
56
|
+
this.message
|
|
57
|
+
? this._chatState.options.templates.attachmentHeaderTemplate(this.message)
|
|
58
|
+
: html `${attachment.type === 'image' ||
|
|
59
|
+
attachment.file?.type.startsWith('image/')
|
|
60
|
+
? html `<igc-icon
|
|
61
|
+
name="image"
|
|
62
|
+
collection="material"
|
|
63
|
+
part="attachment-icon"
|
|
64
|
+
></igc-icon>`
|
|
65
|
+
: html `<igc-icon
|
|
66
|
+
name="file"
|
|
67
|
+
collection="material"
|
|
68
|
+
part="attachment-icon"
|
|
69
|
+
></igc-icon>`}
|
|
70
|
+
<span part="file-name">${attachment.name}</span> `}
|
|
71
|
+
</div>`;
|
|
72
|
+
}
|
|
73
|
+
renderAttachmentHeaderActions() {
|
|
74
|
+
return html `<div part="actions">
|
|
75
|
+
${this._chatState?.options?.templates?.attachmentActionsTemplate &&
|
|
76
|
+
this.message
|
|
77
|
+
? this._chatState.options.templates.attachmentActionsTemplate(this.message)
|
|
78
|
+
: nothing}
|
|
79
|
+
</div>`;
|
|
80
|
+
}
|
|
81
|
+
renderAttachmentContent(attachment) {
|
|
82
|
+
return html `<div part="attachment-content">
|
|
83
|
+
${this._chatState?.options?.templates?.attachmentContentTemplate &&
|
|
84
|
+
this.message
|
|
85
|
+
? this._chatState.options.templates.attachmentContentTemplate(this.message)
|
|
86
|
+
: this.defaulAttachmentContent(attachment)}
|
|
87
|
+
</div>`;
|
|
88
|
+
}
|
|
89
|
+
renderDefaultAttachmentsTemplate() {
|
|
90
|
+
return html `${this.message?.attachments?.map((attachment) => html `<div part="attachment">
|
|
91
|
+
<div
|
|
92
|
+
part="attachment-header"
|
|
93
|
+
role="button"
|
|
94
|
+
@click=${() => this.handleHeaderClick(attachment)}
|
|
95
|
+
>
|
|
96
|
+
${this.renderAttachmentHeaderText(attachment)}
|
|
97
|
+
${this.renderAttachmentHeaderActions()}
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
${attachment.type === 'image' ||
|
|
101
|
+
attachment.file?.type.startsWith('image/') ||
|
|
102
|
+
this._chatState?.options?.templates?.attachmentContentTemplate
|
|
103
|
+
? this.renderAttachmentContent(attachment)
|
|
104
|
+
: nothing}
|
|
105
|
+
</div>`)}`;
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
return html `
|
|
109
|
+
<div part="attachments-container">
|
|
110
|
+
${this._chatState?.options?.templates?.attachmentTemplate &&
|
|
111
|
+
this.message
|
|
112
|
+
? this._chatState.options.templates.attachmentTemplate(this.message)
|
|
113
|
+
: this.renderDefaultAttachmentsTemplate()}
|
|
114
|
+
</div>
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
IgcMessageAttachmentsComponent.tagName = 'igc-message-attachments';
|
|
119
|
+
IgcMessageAttachmentsComponent.styles = [styles, shared];
|
|
120
|
+
export default IgcMessageAttachmentsComponent;
|
|
121
|
+
__decorate([
|
|
122
|
+
consume({ context: chatContext, subscribe: true })
|
|
123
|
+
], IgcMessageAttachmentsComponent.prototype, "_chatState", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ attribute: false })
|
|
126
|
+
], IgcMessageAttachmentsComponent.prototype, "message", void 0);
|
|
127
|
+
//# sourceMappingURL=message-attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-attachments.js","sourceRoot":"","sources":["../../../src/components/chat/message-attachments.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,0BAA0B,MAAM,uCAAuC,CAAC;AAC/E,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EACL,SAAS,EACT,QAAQ,EAGR,SAAS,EACT,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AAqBpB,MAAqB,8BAA+B,SAAQ,UAAU;IAS7D,MAAM,CAAC,QAAQ;QACpB,iBAAiB,CACf,8BAA8B,EAC9B,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,CAC3B,CAAC;IACJ,CAAC;IAQD;QACE,KAAK,EAAE,CAAC;QACR,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACrD,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnD,o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AAyB;YAC5D,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC;YAC1C,CAAC,CAAC,OAAO;eACN,CACV,EAAE,CAAC;IACN,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB;YACzD,IAAI,CAAC,OAAO;YACV,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC;YACpE,CAAC,CAAC,IAAI,CAAC,gCAAgC,EAAE;;KAE9C,CAAC;IACJ,CAAC;;AArIsB,sCAAO,GAAG,yBAAyB,CAAC;AAEpC,qCAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;eAH9B,8BAA8B;AAMzC;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kEACpB;AAgB/B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+DACC","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport IgcIconButtonComponent from '../button/icon-button.js';\nimport { chatContext } from '../common/context.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport IgcExpansionPanelComponent from '../expansion-panel/expansion-panel.js';\nimport IgcIconComponent from '../icon/icon.js';\nimport { registerIconFromText } from '../icon/icon.registry.js';\nimport type { ChatState } from './chat-state.js';\nimport { styles } from './themes/message-attachments.base.css.js';\nimport { styles as shared } from './themes/shared/message-attachments.common.css.js';\nimport {\n closeIcon,\n fileIcon,\n type IgcMessage,\n type IgcMessageAttachment,\n imageIcon,\n moreIcon,\n previewIcon,\n} from './types.js';\n\n/**\n * A component that renders message attachments within a chat.\n *\n * Displays attachments such as images or files, supporting custom templates\n * and default rendering using expansion panels.\n *\n * @element igc-message-attachments\n *\n * @csspart attachments-container - Container wrapping all attachments.\n * @csspart attachment - Wrapper for a single attachment.\n * @csspart attachment-header - Wrapper for a single attachment header.\n * @csspart attachments-content - Part representing the attachment preview.\n * @csspart attachment-icon - Icon part representing the attachment type.\n * @csspart file-name - Part representing the attachment's file name.\n * @csspart actions - Container for header action buttons.\n * @csspart image-attachment - Part for the image element inside an image attachment.\n *\n * @fires igcAttachmentClick - Fired when an attachment header is toggled (clicked).\n */\nexport default class IgcMessageAttachmentsComponent extends LitElement {\n public static readonly tagName = 'igc-message-attachments';\n\n public static override styles = [styles, shared];\n\n @consume({ context: chatContext, subscribe: true })\n private _chatState?: ChatState;\n\n /* blazorSuppress */\n public static register() {\n registerComponent(\n IgcMessageAttachmentsComponent,\n IgcIconComponent,\n IgcIconButtonComponent,\n IgcExpansionPanelComponent\n );\n }\n\n /**\n * The array of attachments to render.\n */\n @property({ attribute: false })\n message: IgcMessage | undefined;\n\n constructor() {\n super();\n registerIconFromText('close', closeIcon, 'material');\n registerIconFromText('file', fileIcon, 'material');\n registerIconFromText('image', imageIcon, 'material');\n registerIconFromText('preview', previewIcon, 'material');\n registerIconFromText('more', moreIcon, 'material');\n }\n\n private handleHeaderClick(attachment: IgcMessageAttachment) {\n this._chatState?.emitEvent('igcAttachmentClick', { detail: attachment });\n }\n\n private getURL(attachment: IgcMessageAttachment): string {\n if (attachment.url) {\n return attachment.url;\n }\n if (attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n return '';\n }\n\n private defaulAttachmentContent(attachment: IgcMessageAttachment) {\n return html`${attachment.type === 'image' ||\n attachment.file?.type.startsWith('image/')\n ? html`<img\n part=\"image-attachment\"\n src=${this.getURL(attachment)}\n alt=${attachment.name}\n />`\n : nothing}`;\n }\n\n private renderAttachmentHeaderText(attachment: IgcMessageAttachment) {\n return html`<div part=\"details\">\n ${this._chatState?.options?.templates?.attachmentHeaderTemplate &&\n this.message\n ? this._chatState.options.templates.attachmentHeaderTemplate(\n this.message\n )\n : html`${attachment.type === 'image' ||\n attachment.file?.type.startsWith('image/')\n ? html`<igc-icon\n name=\"image\"\n collection=\"material\"\n part=\"attachment-icon\"\n ></igc-icon>`\n : html`<igc-icon\n name=\"file\"\n collection=\"material\"\n part=\"attachment-icon\"\n ></igc-icon>`}\n <span part=\"file-name\">${attachment.name}</span> `}\n </div>`;\n }\n\n private renderAttachmentHeaderActions() {\n return html`<div part=\"actions\">\n ${this._chatState?.options?.templates?.attachmentActionsTemplate &&\n this.message\n ? this._chatState.options.templates.attachmentActionsTemplate(\n this.message\n )\n : nothing}\n </div>`;\n }\n\n private renderAttachmentContent(attachment: IgcMessageAttachment) {\n return html`<div part=\"attachment-content\">\n ${this._chatState?.options?.templates?.attachmentContentTemplate &&\n this.message\n ? this._chatState.options.templates.attachmentContentTemplate(\n this.message\n )\n : this.defaulAttachmentContent(attachment)}\n </div>`;\n }\n\n private renderDefaultAttachmentsTemplate() {\n return html`${this.message?.attachments?.map(\n (attachment) =>\n html`<div part=\"attachment\">\n <div\n part=\"attachment-header\"\n role=\"button\"\n @click=${() => this.handleHeaderClick(attachment)}\n >\n ${this.renderAttachmentHeaderText(attachment)}\n ${this.renderAttachmentHeaderActions()}\n </div>\n\n ${attachment.type === 'image' ||\n attachment.file?.type.startsWith('image/') ||\n this._chatState?.options?.templates?.attachmentContentTemplate\n ? this.renderAttachmentContent(attachment)\n : nothing}\n </div>`\n )}`;\n }\n\n protected override render() {\n return html`\n <div part=\"attachments-container\">\n ${this._chatState?.options?.templates?.attachmentTemplate &&\n this.message\n ? this._chatState.options.templates.attachmentTemplate(this.message)\n : this.renderDefaultAttachmentsTemplate()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-message-attachments': IgcMessageAttachmentsComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `:host{--is-large: clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-large, 3), 1);--is-medium: min( clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-medium, 2), 1), clamp(0, var(--ig-size-large, 3) - var(--component-size, 1), 1) );--is-small: clamp(0, var(--ig-size-medium) - var(--component-size, 1), 1);position:relative;box-sizing:border-box;scrollbar-width:var(--ig-scrollbar-size, var(--sb-size));scrollbar-color:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color)) var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar{width:var(--ig-scrollbar-size, var(--sb-size));height:var(--ig-scrollbar-size, var(--sb-size));background:var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar-thumb{background:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color))}:host *,:host *::before,:host *::after{box-sizing:border-box}:host([hidden]),[hidden]{display:none !important}:host{width:100%;height:600px;overflow:hidden;box-shadow:var(--ig-elevation-4);display:flex;flex-direction:column}[part=chat-container]{display:flex;flex-direction:column;align-items:center;height:100%;gap:2.5rem}igc-chat-message-list,[part=empty-state],[part=suggestions-container]{max-width:47.5rem;width:100%}[part=suggestions-header]{font-family:var(--ig-subtitle-2-font-family, var(--ig-font-family));font-size:var(--ig-subtitle-2-font-size);font-weight:var(--ig-subtitle-2-font-weight);font-style:var(--ig-subtitle-2-font-style);line-height:var(--ig-subtitle-2-line-height);letter-spacing:var(--ig-subtitle-2-letter-spacing);text-transform:var(--ig-subtitle-2-text-transform);margin-top:var(--ig-subtitle-2-margin-top);margin-bottom:var(--ig-subtitle-2-margin-bottom);margin:0}[part=empty-state]{height:100%}[part=header]{display:flex;align-items:center;justify-content:space-between;padding:1rem .8125rem;gap:1rem;box-shadow:var(--ig-elevation-4);width:100%}[part=title]{font-family:var(--ig-h6-font-family, var(--ig-font-family));font-size:var(--ig-h6-font-size);font-weight:var(--ig-h6-font-weight);font-style:var(--ig-h6-font-style);line-height:var(--ig-h6-line-height);letter-spacing:var(--ig-h6-letter-spacing);text-transform:var(--ig-h6-text-transform);margin-top:var(--ig-h6-margin-top);margin-bottom:var(--ig-h6-margin-bottom);margin:0}[part=suggestions-container]{display:flex;flex-direction:column;gap:.75rem}[part=suggestions-container] igc-chip{--ig-size: 3;width:-moz-fit-content;width:fit-content}`;
|
|
3
|
+
//# sourceMappingURL=chat.base.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.base.css.js","sourceRoot":"","sources":["../../../../src/components/chat/themes/chat.base.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,w7EAAw7E,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{--is-large: clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-large, 3), 1);--is-medium: min( clamp(0, (var(--component-size, 1) + 1) - var(--ig-size-medium, 2), 1), clamp(0, var(--ig-size-large, 3) - var(--component-size, 1), 1) );--is-small: clamp(0, var(--ig-size-medium) - var(--component-size, 1), 1);position:relative;box-sizing:border-box;scrollbar-width:var(--ig-scrollbar-size, var(--sb-size));scrollbar-color:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color)) var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar{width:var(--ig-scrollbar-size, var(--sb-size));height:var(--ig-scrollbar-size, var(--sb-size));background:var(--ig-scrollbar-track-background, var(--sb-track-bg-color))}:host ::-webkit-scrollbar-thumb{background:var(--ig-scrollbar-thumb-background, var(--sb-thumb-bg-color))}:host *,:host *::before,:host *::after{box-sizing:border-box}:host([hidden]),[hidden]{display:none !important}:host{width:100%;height:600px;overflow:hidden;box-shadow:var(--ig-elevation-4);display:flex;flex-direction:column}[part=chat-container]{display:flex;flex-direction:column;align-items:center;height:100%;gap:2.5rem}igc-chat-message-list,[part=empty-state],[part=suggestions-container]{max-width:47.5rem;width:100%}[part=suggestions-header]{font-family:var(--ig-subtitle-2-font-family, var(--ig-font-family));font-size:var(--ig-subtitle-2-font-size);font-weight:var(--ig-subtitle-2-font-weight);font-style:var(--ig-subtitle-2-font-style);line-height:var(--ig-subtitle-2-line-height);letter-spacing:var(--ig-subtitle-2-letter-spacing);text-transform:var(--ig-subtitle-2-text-transform);margin-top:var(--ig-subtitle-2-margin-top);margin-bottom:var(--ig-subtitle-2-margin-bottom);margin:0}[part=empty-state]{height:100%}[part=header]{display:flex;align-items:center;justify-content:space-between;padding:1rem .8125rem;gap:1rem;box-shadow:var(--ig-elevation-4);width:100%}[part=title]{font-family:var(--ig-h6-font-family, var(--ig-font-family));font-size:var(--ig-h6-font-size);font-weight:var(--ig-h6-font-weight);font-style:var(--ig-h6-font-style);line-height:var(--ig-h6-line-height);letter-spacing:var(--ig-h6-letter-spacing);text-transform:var(--ig-h6-text-transform);margin-top:var(--ig-h6-margin-top);margin-bottom:var(--ig-h6-margin-bottom);margin:0}[part=suggestions-container]{display:flex;flex-direction:column;gap:.75rem}[part=suggestions-container] igc-chip{--ig-size: 3;width:-moz-fit-content;width:fit-content}`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.bootstrap.css.js","sourceRoot":"","sources":["../../../../../src/components/chat/themes/dark/chat.bootstrap.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,8BAA8B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{--ig-theme: bootstrap}`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.fluent.css.js","sourceRoot":"","sources":["../../../../../src/components/chat/themes/dark/chat.fluent.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,2BAA2B,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{--ig-theme: fluent}`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|