igniteui-webcomponents 6.4.0-alpha.1 → 6.4.0-alpha.2
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 +7 -4
- package/components/chat/chat-input.js +21 -13
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat-message.d.ts +5 -2
- package/components/chat/chat-message.js +18 -10
- package/components/chat/chat-message.js.map +1 -1
- package/components/chat/utils.d.ts +13 -2
- package/components/chat/utils.js +36 -14
- package/components/chat/utils.js.map +1 -1
- package/components/combo/themes/shared/combo.bootstrap.css.js +1 -1
- package/components/combo/themes/shared/combo.bootstrap.css.js.map +1 -1
- package/components/combo/themes/shared/combo.common.css.js +1 -1
- package/components/combo/themes/shared/combo.common.css.js.map +1 -1
- package/components/combo/themes/shared/combo.fluent.css.js +1 -1
- package/components/combo/themes/shared/combo.fluent.css.js.map +1 -1
- package/components/combo/themes/shared/combo.indigo.css.js +1 -1
- package/components/combo/themes/shared/combo.indigo.css.js.map +1 -1
- package/components/combo/themes/shared/combo.material.css.js +1 -1
- package/components/combo/themes/shared/combo.material.css.js.map +1 -1
- package/components/dialog/themes/dialog.base.css.js +1 -1
- package/components/dialog/themes/dialog.base.css.js.map +1 -1
- package/components/input/themes/input.base.css.js +1 -1
- package/components/input/themes/input.base.css.js.map +1 -1
- package/components/mask-input/mask-input-base.js +5 -0
- package/components/mask-input/mask-input-base.js.map +1 -1
- package/components/select/themes/shared/select.common.css.js +1 -1
- package/components/select/themes/shared/select.common.css.js.map +1 -1
- package/components/select/themes/shared/select.fluent.css.js +1 -1
- package/components/select/themes/shared/select.fluent.css.js.map +1 -1
- package/components/select/themes/shared/select.material.css.js +1 -1
- package/components/select/themes/shared/select.material.css.js.map +1 -1
- package/custom-elements.json +144 -12
- package/package.json +1 -1
|
@@ -36,16 +36,19 @@ export default class IgcChatInputComponent extends LitElement {
|
|
|
36
36
|
private _userIsTyping;
|
|
37
37
|
private _userLastTypeTime;
|
|
38
38
|
private _typingTimeout;
|
|
39
|
-
private readonly
|
|
39
|
+
private readonly _adoptedStyles;
|
|
40
|
+
private readonly _stateChanged;
|
|
41
|
+
private readonly _stateConsumer;
|
|
40
42
|
private readonly _userInputState;
|
|
41
|
-
private readonly _textInputElement
|
|
42
|
-
protected readonly _fileInput
|
|
43
|
+
private readonly _textInputElement?;
|
|
44
|
+
protected readonly _fileInput?: HTMLInputElement;
|
|
43
45
|
private _parts;
|
|
46
|
+
private get _state();
|
|
44
47
|
private get _acceptedTypes();
|
|
45
48
|
constructor();
|
|
46
|
-
protected firstUpdated(): void;
|
|
47
49
|
/** @internal */
|
|
48
50
|
focusInput(): void;
|
|
51
|
+
private _adoptPageStyles;
|
|
49
52
|
private _getRenderer;
|
|
50
53
|
private _sendMessage;
|
|
51
54
|
private _setTypingStateAndEmit;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { consume } from '@lit/context';
|
|
7
|
+
import { ContextConsumer, consume } from '@lit/context';
|
|
8
8
|
import { html, LitElement, nothing } from 'lit';
|
|
9
9
|
import { query, state } from 'lit/decorators.js';
|
|
10
10
|
import { cache } from 'lit/directives/cache.js';
|
|
@@ -23,13 +23,16 @@ import IgcTextareaComponent from '../textarea/textarea.js';
|
|
|
23
23
|
import { styles } from './themes/input.base.css.js';
|
|
24
24
|
import { all } from './themes/input.js';
|
|
25
25
|
import { styles as shared } from './themes/shared/input/input.common.css.js';
|
|
26
|
-
import {
|
|
26
|
+
import { addAdoptedStylesController, getChatAcceptedFiles, getIconName, } from './utils.js';
|
|
27
27
|
export default class IgcChatInputComponent extends LitElement {
|
|
28
28
|
static { this.tagName = 'igc-chat-input'; }
|
|
29
29
|
static { this.styles = [styles, shared]; }
|
|
30
30
|
static register() {
|
|
31
31
|
registerComponent(IgcChatInputComponent, IgcTextareaComponent, IgcIconButtonComponent, IgcChipComponent, IgcIconComponent);
|
|
32
32
|
}
|
|
33
|
+
get _state() {
|
|
34
|
+
return this._stateConsumer.value;
|
|
35
|
+
}
|
|
33
36
|
get _acceptedTypes() {
|
|
34
37
|
return this._state.acceptedFileTypes;
|
|
35
38
|
}
|
|
@@ -47,16 +50,24 @@ export default class IgcChatInputComponent extends LitElement {
|
|
|
47
50
|
this._userIsTyping = false;
|
|
48
51
|
this._userLastTypeTime = Date.now();
|
|
49
52
|
this._typingTimeout = 0;
|
|
53
|
+
this._adoptedStyles = addAdoptedStylesController(this);
|
|
54
|
+
this._stateChanged = () => {
|
|
55
|
+
this._adoptedStyles.shouldAdoptStyles(!!this._state.options?.adoptRootStyles &&
|
|
56
|
+
!this._adoptedStyles.hasAdoptedStyles);
|
|
57
|
+
};
|
|
58
|
+
this._stateConsumer = new ContextConsumer(this, {
|
|
59
|
+
context: chatContext,
|
|
60
|
+
callback: this._stateChanged,
|
|
61
|
+
subscribe: true,
|
|
62
|
+
});
|
|
50
63
|
this._parts = { 'input-container': true, dragging: false };
|
|
51
|
-
addThemingController(this, all);
|
|
52
|
-
}
|
|
53
|
-
firstUpdated() {
|
|
54
|
-
if (this._state.options?.adoptRootStyles) {
|
|
55
|
-
adoptPageStyles(this);
|
|
56
|
-
}
|
|
64
|
+
addThemingController(this, all, { themeChange: this._adoptPageStyles });
|
|
57
65
|
}
|
|
58
66
|
focusInput() {
|
|
59
|
-
this._textInputElement
|
|
67
|
+
this._textInputElement?.focus();
|
|
68
|
+
}
|
|
69
|
+
_adoptPageStyles() {
|
|
70
|
+
this._adoptedStyles.shouldAdoptStyles(this._adoptedStyles.hasAdoptedStyles);
|
|
60
71
|
}
|
|
61
72
|
_getRenderer(name) {
|
|
62
73
|
return this._state.options?.renderers
|
|
@@ -115,7 +126,7 @@ export default class IgcChatInputComponent extends LitElement {
|
|
|
115
126
|
}, delay);
|
|
116
127
|
}
|
|
117
128
|
_handleFileInputClick() {
|
|
118
|
-
this._fileInput
|
|
129
|
+
this._fileInput?.showPicker();
|
|
119
130
|
}
|
|
120
131
|
_handleFocusState(event) {
|
|
121
132
|
this._state.emitEvent(event.type === 'focus' ? 'igcInputFocus' : 'igcInputBlur');
|
|
@@ -284,9 +295,6 @@ export default class IgcChatInputComponent extends LitElement {
|
|
|
284
295
|
`;
|
|
285
296
|
}
|
|
286
297
|
}
|
|
287
|
-
__decorate([
|
|
288
|
-
consume({ context: chatContext, subscribe: true })
|
|
289
|
-
], IgcChatInputComponent.prototype, "_state", void 0);
|
|
290
298
|
__decorate([
|
|
291
299
|
consume({ context: chatUserInputContext, subscribe: true })
|
|
292
300
|
], IgcChatInputComponent.prototype, "_userInputState", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input.js","sourceRoot":"","sources":["../../../src/components/chat/chat-input.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,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAA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I,CAAC,WAAW;;UAEtB,IAAI,CAAC,MAAM,CAAC,mBAAmB;YAC/B,CAAC,CAAC,IAAI,CAAA;;kBAEE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;;aAE3D;YACH,CAAC,CAAC,OAAO;;;YAGP,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;YAI3C,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;;;KAGpD,CAAC;IACJ,CAAC;;AApUgB;IADhB,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;qDACf;AAGnB;IADhB,OAAO,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;8DACf;AAG5B;IADhB,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC;gEACsB;AAGvC;IADlB,KAAK,CAAC,oBAAoB,CAAC;yDACqB;AAGzC;IADP,KAAK,EAAE;qDACsD","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { query, state } from 'lit/decorators.js';\nimport { cache } from 'lit/directives/cache.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { until } from 'lit/directives/until.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcIconButtonComponent from '../button/icon-button.js';\nimport IgcChipComponent from '../chip/chip.js';\nimport { chatContext, chatUserInputContext } from '../common/context.js';\nimport { enterKey, tabKey } from '../common/controllers/key-bindings.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, hasFiles, isEmpty, trimmedHtml } from '../common/util.js';\nimport IgcIconComponent from '../icon/icon.js';\nimport IgcTextareaComponent from '../textarea/textarea.js';\nimport type { ChatState } from './chat-state.js';\nimport { styles } from './themes/input.base.css.js';\nimport { all } from './themes/input.js';\nimport { styles as shared } from './themes/shared/input/input.common.css.js';\nimport type {\n ChatInputRenderContext,\n ChatRenderContext,\n ChatTemplateRenderer,\n IgcChatMessageAttachment,\n} from './types.js';\nimport { adoptPageStyles, getChatAcceptedFiles, getIconName } from './utils.js';\n\ntype DefaultInputRenderers = {\n input: ChatTemplateRenderer<ChatInputRenderContext>;\n inputActions: ChatTemplateRenderer<ChatRenderContext>;\n inputActionsEnd: ChatTemplateRenderer<ChatRenderContext>;\n inputActionsStart: ChatTemplateRenderer<ChatRenderContext>;\n inputAttachments: ChatTemplateRenderer<ChatInputRenderContext>;\n fileUploadButton: ChatTemplateRenderer<ChatRenderContext>;\n sendButton: ChatTemplateRenderer<ChatRenderContext>;\n};\n\n/* blazorSuppress */\n/**\n * A web component that provides the input area for the `igc-chat` interface.\n *\n * It supports:\n * - Text input with automatic resizing\n * - Sending messages on Enter key (with Shift+Enter for newlines)\n * - File attachments via file picker or drag-and-drop\n * - Customizable templates for send button, attachments, and text input\n * - Emits various chat-related events (typing, input focus/blur, attachment drop, etc.)\n *\n * @element igc-chat-input\n *\n * @slot - Default unnamed slot for rendering inside the component\n * @fires igcTypingChange - Fired when the user starts/stops typing\n * @fires igcInputFocus - Fired when the input area receives focus\n * @fires igcInputBlur - Fired when the input area loses focus\n * @fires igcAttachmentDrag - Fired when dragging a file over the input\n * @fires igcAttachmentDrop - Fired when a file is dropped into the input\n * @fires igcChange - Fired when file input changes (delegated from `<igc-file-input>`)\n *\n * @csspart input-container - Container for the input section\n * @csspart input-wrapper - Wrapper around the text input\n * @csspart text-input - The `<igc-textarea>` component\n * @csspart actions-container - Container for file upload/send buttons\n * @csspart send-button - The send icon button\n * @csspart attachments - Container for rendering attachments\n * @csspart attachment-wrapper - Wrapper for individual attachment\n * @csspart attachment-name - Display name of an attachment\n */\nexport default class IgcChatInputComponent extends LitElement {\n public static readonly tagName = 'igc-chat-input';\n public static override styles = [styles, shared];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(\n IgcChatInputComponent,\n IgcTextareaComponent,\n IgcIconButtonComponent,\n IgcChipComponent,\n IgcIconComponent\n );\n }\n\n private readonly _defaults: Readonly<DefaultInputRenderers> = Object.freeze({\n fileUploadButton: () => this._renderFileUploadButton(),\n input: () => this._renderTextArea(),\n inputActions: () => this._renderActionsArea(),\n inputActionsEnd: () => nothing,\n inputActionsStart: () => nothing,\n inputAttachments: (ctx) => this._renderAttachmentsArea(ctx.attachments),\n sendButton: () => this._renderSendButton(),\n });\n\n private _userIsTyping = false;\n private _userLastTypeTime = Date.now();\n private _typingTimeout = 0;\n\n @consume({ context: chatContext, subscribe: true })\n private readonly _state!: ChatState;\n\n @consume({ context: chatUserInputContext, subscribe: true })\n private readonly _userInputState!: ChatState;\n\n @query(IgcTextareaComponent.tagName)\n private readonly _textInputElement!: IgcTextareaComponent;\n\n @query('#input_attachments')\n protected readonly _fileInput!: HTMLInputElement;\n\n @state()\n private _parts = { 'input-container': true, dragging: false };\n\n private get _acceptedTypes() {\n return this._state.acceptedFileTypes;\n }\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected override firstUpdated(): void {\n if (this._state.options?.adoptRootStyles) {\n adoptPageStyles(this);\n }\n }\n\n /** @internal */\n public focusInput(): void {\n this._textInputElement.focus();\n }\n\n private _getRenderer<U extends keyof DefaultInputRenderers>(\n name: U\n ): DefaultInputRenderers[U] {\n return this._state.options?.renderers\n ? ((this._state.options.renderers[name] ??\n this._defaults[name]) as DefaultInputRenderers[U])\n : this._defaults[name];\n }\n\n private async _sendMessage(): Promise<void> {\n if (\n !this._userInputState.hasInputValue &&\n !this._userInputState.hasInputAttachments\n ) {\n return;\n }\n\n this._userInputState.addMessageWithEvent({\n text: this._userInputState.inputValue,\n attachments: this._userInputState.inputAttachments,\n });\n\n this.style.height = 'auto';\n\n await this._userInputState.host.updateComplete;\n this.focusInput();\n }\n\n private _setTypingStateAndEmit(state: boolean): void {\n this._userIsTyping = state;\n this._userInputState.emitUserTypingState(state);\n }\n\n private _handleAttachmentRemoved(attachment: IgcChatMessageAttachment): void {\n const current = this._userInputState.inputAttachments;\n\n if (this._state.emitAttachmentRemoved(attachment)) {\n this._state.inputAttachments = current.toSpliced(\n current.indexOf(attachment),\n 1\n );\n }\n }\n\n private _handleKeydown(event: KeyboardEvent): void {\n this._userLastTypeTime = Date.now();\n const isEnterKey = event.key.toLowerCase() === enterKey.toLowerCase();\n const isTab = event.key.toLocaleLowerCase() === tabKey.toLowerCase();\n\n if (isTab && !this._userIsTyping) {\n return;\n }\n\n if (isEnterKey && !event.shiftKey) {\n event.preventDefault();\n this._sendMessage();\n\n if (this._userIsTyping) {\n clearTimeout(this._typingTimeout);\n this._setTypingStateAndEmit(false);\n }\n\n return;\n }\n\n clearTimeout(this._typingTimeout);\n const delay = this._state.stopTypingDelay;\n\n if (!this._userIsTyping) {\n this._setTypingStateAndEmit(true);\n }\n\n this._typingTimeout = setTimeout(() => {\n if (this._userIsTyping && this._userLastTypeTime + delay <= Date.now()) {\n this._setTypingStateAndEmit(false);\n }\n }, delay);\n }\n\n private _handleFileInputClick(): void {\n this._fileInput.showPicker();\n }\n\n private _handleFocusState(event: FocusEvent): void {\n this._state.emitEvent(\n event.type === 'focus' ? 'igcInputFocus' : 'igcInputBlur'\n );\n }\n\n private _handleDragEnter(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n\n const validFiles = getChatAcceptedFiles(event, this._acceptedTypes);\n this._parts = { 'input-container': true, dragging: !isEmpty(validFiles) };\n this._state.emitEvent('igcAttachmentDrag');\n }\n\n private _handleDragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n }\n\n private _handleDragLeave(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n\n // Check if we're actually leaving the container\n const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();\n const x = event.clientX;\n const y = event.clientY;\n\n if (\n x <= rect.left ||\n x >= rect.right ||\n y <= rect.top ||\n y >= rect.bottom\n ) {\n this._parts = { 'input-container': true, dragging: false };\n }\n }\n\n private _handleDrop(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this._parts = { 'input-container': true, dragging: false };\n\n const validFiles = getChatAcceptedFiles(event, this._acceptedTypes);\n this._state.emitEvent('igcAttachmentDrop');\n this._state.attachFilesWithEvent(validFiles);\n this.requestUpdate();\n }\n\n private _handleInput({ detail }: CustomEvent<string>): void {\n this._state.inputValue = detail;\n this._state.emitEvent('igcInputChange', { detail: { value: detail } });\n }\n\n private _handleFileUpload(event: Event): void {\n const input = event.target as HTMLInputElement;\n\n if (hasFiles(input)) {\n this._state.attachFilesWithEvent(Array.from(input.files!));\n }\n }\n\n /**\n * Default attachments area template used when no custom template is provided.\n * Renders the list of input attachments as chips.\n * @returns TemplateResult containing the attachments area\n */\n private _renderAttachmentsArea(attachments: IgcChatMessageAttachment[]) {\n return html`${attachments?.map(\n (attachment) => html`\n <div part=\"attachment-wrapper\" role=\"listitem\">\n <igc-chip\n removable\n @igcRemove=${() => this._handleAttachmentRemoved(attachment)}\n >\n <igc-icon\n part=\"attachment-icon\"\n slot=\"prefix\"\n name=${getIconName(attachment.file?.type ?? attachment.type)}\n ></igc-icon>\n <span part=\"attachment-name\">${attachment.name}</span>\n </igc-chip>\n </div>\n `\n )} `;\n }\n\n /**\n * Default text area template used when no custom template is provided.\n * Renders a text area for user input.\n * @returns TemplateResult containing the text area\n */\n private _renderTextArea() {\n return html`\n <igc-textarea\n part=\"text-input\"\n aria-label=\"Chat text input\"\n placeholder=${ifDefined(this._state.options?.inputPlaceholder)}\n resize=\"auto\"\n rows=\"1\"\n .value=${this._userInputState?.inputValue}\n @igcInput=${this._handleInput}\n @keydown=${this._handleKeydown}\n @focus=${this._handleFocusState}\n @blur=${this._handleFocusState}\n ></igc-textarea>\n `;\n }\n\n private _renderFileUploadButton() {\n const accepted = this._state.options?.acceptedFiles;\n const attachmentsDisabled = this._state.options?.disableInputAttachments;\n\n return html`${cache(\n attachmentsDisabled\n ? nothing\n : html`\n <label for=\"input_attachments\" part=\"file-upload\">\n <igc-icon-button\n aria-label=\"Attach files\"\n variant=\"flat\"\n name=\"attach_file\"\n @click=${this._handleFileInputClick}\n ></igc-icon-button>\n <input\n type=\"file\"\n id=\"input_attachments\"\n tabindex=\"-1\"\n name=\"input_attachments\"\n aria-label=\"Upload button\"\n multiple\n accept=${bindIf(accepted, accepted)}\n @change=${this._handleFileUpload}\n />\n </label>\n `\n )}`;\n }\n\n private _renderSendButton() {\n const enabled =\n this._state.hasInputValue || this._state.hasInputAttachments;\n\n return html`\n <igc-icon-button\n aria-label=\"Send message\"\n name=\"send_message\"\n variant=\"contained\"\n part=\"send-button\"\n ?disabled=${!enabled}\n @click=${this._sendMessage}\n ></igc-icon-button>\n `;\n }\n\n private _renderActionsArea() {\n const ctx: ChatRenderContext = { instance: this._state.host };\n\n return trimmedHtml`\n <div part=\"file-upload-container\">\n ${this._getRenderer('fileUploadButton')(ctx)}\n </div>\n <div part=\"input-actions-start\">\n ${this._getRenderer('inputActionsStart')(ctx)}\n </div>\n <div part=\"send-button-container\">${this._getRenderer('sendButton')(ctx)}</div>\n <div part=\"input-actions-end\">\n ${this._getRenderer('inputActionsEnd')(ctx)}\n </div>\n `;\n }\n\n protected override render() {\n const ctx: ChatRenderContext = { instance: this._state.host };\n\n const inputCtx: ChatInputRenderContext = {\n ...ctx,\n attachments: this._state.inputAttachments,\n value: this._state.inputValue,\n };\n\n return html`\n <div\n part=${partMap(this._parts)}\n @dragenter=${this._handleDragEnter}\n @dragover=${this._handleDragOver}\n @dragleave=${this._handleDragLeave}\n @drop=${this._handleDrop}\n >\n ${this._state.hasInputAttachments\n ? html`\n <div part=\"attachments\" role=\"list\" aria-label=\"Attachments\">\n ${until(this._getRenderer('inputAttachments')(inputCtx))}\n </div>\n `\n : nothing}\n\n <div part=\"input-wrapper\">\n ${until(this._getRenderer('input')(inputCtx))}\n </div>\n\n <div part=\"actions-container\">\n ${until(this._getRenderer('inputActions')(ctx))}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-chat-input': IgcChatInputComponent;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat-input.js","sourceRoot":"","sources":["../../../src/components/chat/chat-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAC/C,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,IAAI,MAA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AAC,gBAAgB;oBACtB,IAAI,CAAC,eAAe;qBACnB,IAAI,CAAC,gBAAgB;gBAC1B,IAAI,CAAC,WAAW;;UAEtB,IAAI,CAAC,MAAM,CAAC,mBAAmB;YAC/B,CAAC,CAAC,IAAI,CAAA;;kBAEE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;;aAE3D;YACH,CAAC,CAAC,OAAO;;;YAGP,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;YAI3C,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;;;KAGpD,CAAC;IACJ,CAAC;;AAnUgB;IADhB,OAAO,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;8DACf;AAG5B;IADhB,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC;gEACsB;AAGvC;IADlB,KAAK,CAAC,oBAAoB,CAAC;yDACqB;AAGzC;IADP,KAAK,EAAE;qDACsD","sourcesContent":["import { ContextConsumer, consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { query, state } from 'lit/decorators.js';\nimport { cache } from 'lit/directives/cache.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { until } from 'lit/directives/until.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcIconButtonComponent from '../button/icon-button.js';\nimport IgcChipComponent from '../chip/chip.js';\nimport { chatContext, chatUserInputContext } from '../common/context.js';\nimport { enterKey, tabKey } from '../common/controllers/key-bindings.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, hasFiles, isEmpty, trimmedHtml } from '../common/util.js';\nimport IgcIconComponent from '../icon/icon.js';\nimport IgcTextareaComponent from '../textarea/textarea.js';\nimport type { ChatState } from './chat-state.js';\nimport { styles } from './themes/input.base.css.js';\nimport { all } from './themes/input.js';\nimport { styles as shared } from './themes/shared/input/input.common.css.js';\nimport type {\n ChatInputRenderContext,\n ChatRenderContext,\n ChatTemplateRenderer,\n IgcChatMessageAttachment,\n} from './types.js';\nimport {\n addAdoptedStylesController,\n type ChatAcceptedFileTypes,\n getChatAcceptedFiles,\n getIconName,\n} from './utils.js';\n\ntype DefaultInputRenderers = {\n input: ChatTemplateRenderer<ChatInputRenderContext>;\n inputActions: ChatTemplateRenderer<ChatRenderContext>;\n inputActionsEnd: ChatTemplateRenderer<ChatRenderContext>;\n inputActionsStart: ChatTemplateRenderer<ChatRenderContext>;\n inputAttachments: ChatTemplateRenderer<ChatInputRenderContext>;\n fileUploadButton: ChatTemplateRenderer<ChatRenderContext>;\n sendButton: ChatTemplateRenderer<ChatRenderContext>;\n};\n\n/* blazorSuppress */\n/**\n * A web component that provides the input area for the `igc-chat` interface.\n *\n * It supports:\n * - Text input with automatic resizing\n * - Sending messages on Enter key (with Shift+Enter for newlines)\n * - File attachments via file picker or drag-and-drop\n * - Customizable templates for send button, attachments, and text input\n * - Emits various chat-related events (typing, input focus/blur, attachment drop, etc.)\n *\n * @element igc-chat-input\n *\n * @slot - Default unnamed slot for rendering inside the component\n * @fires igcTypingChange - Fired when the user starts/stops typing\n * @fires igcInputFocus - Fired when the input area receives focus\n * @fires igcInputBlur - Fired when the input area loses focus\n * @fires igcAttachmentDrag - Fired when dragging a file over the input\n * @fires igcAttachmentDrop - Fired when a file is dropped into the input\n * @fires igcChange - Fired when file input changes (delegated from `<igc-file-input>`)\n *\n * @csspart input-container - Container for the input section\n * @csspart input-wrapper - Wrapper around the text input\n * @csspart text-input - The `<igc-textarea>` component\n * @csspart actions-container - Container for file upload/send buttons\n * @csspart send-button - The send icon button\n * @csspart attachments - Container for rendering attachments\n * @csspart attachment-wrapper - Wrapper for individual attachment\n * @csspart attachment-name - Display name of an attachment\n */\nexport default class IgcChatInputComponent extends LitElement {\n public static readonly tagName = 'igc-chat-input';\n public static override styles = [styles, shared];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(\n IgcChatInputComponent,\n IgcTextareaComponent,\n IgcIconButtonComponent,\n IgcChipComponent,\n IgcIconComponent\n );\n }\n\n private readonly _defaults: Readonly<DefaultInputRenderers> = Object.freeze({\n fileUploadButton: () => this._renderFileUploadButton(),\n input: () => this._renderTextArea(),\n inputActions: () => this._renderActionsArea(),\n inputActionsEnd: () => nothing,\n inputActionsStart: () => nothing,\n inputAttachments: (ctx) => this._renderAttachmentsArea(ctx.attachments),\n sendButton: () => this._renderSendButton(),\n });\n\n private _userIsTyping = false;\n private _userLastTypeTime = Date.now();\n private _typingTimeout = 0;\n\n private readonly _adoptedStyles = addAdoptedStylesController(this);\n\n private readonly _stateChanged = () => {\n this._adoptedStyles.shouldAdoptStyles(\n !!this._state.options?.adoptRootStyles &&\n !this._adoptedStyles.hasAdoptedStyles\n );\n };\n\n private readonly _stateConsumer = new ContextConsumer(this, {\n context: chatContext,\n callback: this._stateChanged,\n subscribe: true,\n });\n\n @consume({ context: chatUserInputContext, subscribe: true })\n private readonly _userInputState!: ChatState;\n\n @query(IgcTextareaComponent.tagName)\n private readonly _textInputElement?: IgcTextareaComponent;\n\n @query('#input_attachments')\n protected readonly _fileInput?: HTMLInputElement;\n\n @state()\n private _parts = { 'input-container': true, dragging: false };\n\n private get _state(): ChatState {\n return this._stateConsumer.value!;\n }\n\n private get _acceptedTypes(): ChatAcceptedFileTypes | null {\n return this._state.acceptedFileTypes;\n }\n\n constructor() {\n super();\n addThemingController(this, all, { themeChange: this._adoptPageStyles });\n }\n\n /** @internal */\n public focusInput(): void {\n this._textInputElement?.focus();\n }\n\n private _adoptPageStyles(): void {\n this._adoptedStyles.shouldAdoptStyles(this._adoptedStyles.hasAdoptedStyles);\n }\n\n private _getRenderer<U extends keyof DefaultInputRenderers>(\n name: U\n ): DefaultInputRenderers[U] {\n return this._state.options?.renderers\n ? ((this._state.options.renderers[name] ??\n this._defaults[name]) as DefaultInputRenderers[U])\n : this._defaults[name];\n }\n\n private async _sendMessage(): Promise<void> {\n if (\n !this._userInputState.hasInputValue &&\n !this._userInputState.hasInputAttachments\n ) {\n return;\n }\n\n this._userInputState.addMessageWithEvent({\n text: this._userInputState.inputValue,\n attachments: this._userInputState.inputAttachments,\n });\n\n this.style.height = 'auto';\n\n await this._userInputState.host.updateComplete;\n this.focusInput();\n }\n\n private _setTypingStateAndEmit(state: boolean): void {\n this._userIsTyping = state;\n this._userInputState.emitUserTypingState(state);\n }\n\n private _handleAttachmentRemoved(attachment: IgcChatMessageAttachment): void {\n const current = this._userInputState.inputAttachments;\n\n if (this._state.emitAttachmentRemoved(attachment)) {\n this._state.inputAttachments = current.toSpliced(\n current.indexOf(attachment),\n 1\n );\n }\n }\n\n private _handleKeydown(event: KeyboardEvent): void {\n this._userLastTypeTime = Date.now();\n const isEnterKey = event.key.toLowerCase() === enterKey.toLowerCase();\n const isTab = event.key.toLocaleLowerCase() === tabKey.toLowerCase();\n\n if (isTab && !this._userIsTyping) {\n return;\n }\n\n if (isEnterKey && !event.shiftKey) {\n event.preventDefault();\n this._sendMessage();\n\n if (this._userIsTyping) {\n clearTimeout(this._typingTimeout);\n this._setTypingStateAndEmit(false);\n }\n\n return;\n }\n\n clearTimeout(this._typingTimeout);\n const delay = this._state.stopTypingDelay;\n\n if (!this._userIsTyping) {\n this._setTypingStateAndEmit(true);\n }\n\n this._typingTimeout = setTimeout(() => {\n if (this._userIsTyping && this._userLastTypeTime + delay <= Date.now()) {\n this._setTypingStateAndEmit(false);\n }\n }, delay);\n }\n\n private _handleFileInputClick(): void {\n this._fileInput?.showPicker();\n }\n\n private _handleFocusState(event: FocusEvent): void {\n this._state.emitEvent(\n event.type === 'focus' ? 'igcInputFocus' : 'igcInputBlur'\n );\n }\n\n private _handleDragEnter(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n\n const validFiles = getChatAcceptedFiles(event, this._acceptedTypes);\n this._parts = { 'input-container': true, dragging: !isEmpty(validFiles) };\n this._state.emitEvent('igcAttachmentDrag');\n }\n\n private _handleDragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n }\n\n private _handleDragLeave(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n\n // Check if we're actually leaving the container\n const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();\n const x = event.clientX;\n const y = event.clientY;\n\n if (\n x <= rect.left ||\n x >= rect.right ||\n y <= rect.top ||\n y >= rect.bottom\n ) {\n this._parts = { 'input-container': true, dragging: false };\n }\n }\n\n private _handleDrop(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n this._parts = { 'input-container': true, dragging: false };\n\n const validFiles = getChatAcceptedFiles(event, this._acceptedTypes);\n this._state.emitEvent('igcAttachmentDrop');\n this._state.attachFilesWithEvent(validFiles);\n this.requestUpdate();\n }\n\n private _handleInput({ detail }: CustomEvent<string>): void {\n this._state.inputValue = detail;\n this._state.emitEvent('igcInputChange', { detail: { value: detail } });\n }\n\n private _handleFileUpload(event: Event): void {\n const input = event.target as HTMLInputElement;\n\n if (hasFiles(input)) {\n this._state.attachFilesWithEvent(Array.from(input.files!));\n }\n }\n\n /**\n * Default attachments area template used when no custom template is provided.\n * Renders the list of input attachments as chips.\n * @returns TemplateResult containing the attachments area\n */\n private _renderAttachmentsArea(attachments: IgcChatMessageAttachment[]) {\n return html`${attachments?.map(\n (attachment) => html`\n <div part=\"attachment-wrapper\" role=\"listitem\">\n <igc-chip\n removable\n @igcRemove=${() => this._handleAttachmentRemoved(attachment)}\n >\n <igc-icon\n part=\"attachment-icon\"\n slot=\"prefix\"\n name=${getIconName(attachment.file?.type ?? attachment.type)}\n ></igc-icon>\n <span part=\"attachment-name\">${attachment.name}</span>\n </igc-chip>\n </div>\n `\n )} `;\n }\n\n /**\n * Default text area template used when no custom template is provided.\n * Renders a text area for user input.\n * @returns TemplateResult containing the text area\n */\n private _renderTextArea() {\n return html`\n <igc-textarea\n part=\"text-input\"\n aria-label=\"Chat text input\"\n placeholder=${ifDefined(this._state.options?.inputPlaceholder)}\n resize=\"auto\"\n rows=\"1\"\n .value=${this._userInputState?.inputValue}\n @igcInput=${this._handleInput}\n @keydown=${this._handleKeydown}\n @focus=${this._handleFocusState}\n @blur=${this._handleFocusState}\n ></igc-textarea>\n `;\n }\n\n private _renderFileUploadButton() {\n const accepted = this._state.options?.acceptedFiles;\n const attachmentsDisabled = this._state.options?.disableInputAttachments;\n\n return html`${cache(\n attachmentsDisabled\n ? nothing\n : html`\n <label for=\"input_attachments\" part=\"file-upload\">\n <igc-icon-button\n aria-label=\"Attach files\"\n variant=\"flat\"\n name=\"attach_file\"\n @click=${this._handleFileInputClick}\n ></igc-icon-button>\n <input\n type=\"file\"\n id=\"input_attachments\"\n tabindex=\"-1\"\n name=\"input_attachments\"\n aria-label=\"Upload button\"\n multiple\n accept=${bindIf(accepted, accepted)}\n @change=${this._handleFileUpload}\n />\n </label>\n `\n )}`;\n }\n\n private _renderSendButton() {\n const enabled =\n this._state.hasInputValue || this._state.hasInputAttachments;\n\n return html`\n <igc-icon-button\n aria-label=\"Send message\"\n name=\"send_message\"\n variant=\"contained\"\n part=\"send-button\"\n ?disabled=${!enabled}\n @click=${this._sendMessage}\n ></igc-icon-button>\n `;\n }\n\n private _renderActionsArea() {\n const ctx: ChatRenderContext = { instance: this._state.host };\n\n return trimmedHtml`\n <div part=\"file-upload-container\">\n ${this._getRenderer('fileUploadButton')(ctx)}\n </div>\n <div part=\"input-actions-start\">\n ${this._getRenderer('inputActionsStart')(ctx)}\n </div>\n <div part=\"send-button-container\">${this._getRenderer('sendButton')(ctx)}</div>\n <div part=\"input-actions-end\">\n ${this._getRenderer('inputActionsEnd')(ctx)}\n </div>\n `;\n }\n\n protected override render() {\n const ctx: ChatRenderContext = { instance: this._state.host };\n\n const inputCtx: ChatInputRenderContext = {\n ...ctx,\n attachments: this._state.inputAttachments,\n value: this._state.inputValue,\n };\n\n return html`\n <div\n part=${partMap(this._parts)}\n @dragenter=${this._handleDragEnter}\n @dragover=${this._handleDragOver}\n @dragleave=${this._handleDragLeave}\n @drop=${this._handleDrop}\n >\n ${this._state.hasInputAttachments\n ? html`\n <div part=\"attachments\" role=\"list\" aria-label=\"Attachments\">\n ${until(this._getRenderer('inputAttachments')(inputCtx))}\n </div>\n `\n : nothing}\n\n <div part=\"input-wrapper\">\n ${until(this._getRenderer('input')(inputCtx))}\n </div>\n\n <div part=\"actions-container\">\n ${until(this._getRenderer('inputActions')(ctx))}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-chat-input': IgcChatInputComponent;\n }\n}\n"]}
|
|
@@ -21,14 +21,17 @@ export default class IgcChatMessageComponent extends LitElement {
|
|
|
21
21
|
static readonly tagName = "igc-chat-message";
|
|
22
22
|
static styles: import("lit").CSSResult[];
|
|
23
23
|
static register(): void;
|
|
24
|
+
private readonly _adoptedStyles;
|
|
24
25
|
private readonly _defaults;
|
|
25
|
-
private readonly
|
|
26
|
+
private readonly _stateChanged;
|
|
27
|
+
private readonly _stateConsumer;
|
|
28
|
+
private get _state();
|
|
26
29
|
/**
|
|
27
30
|
* The chat message to render.
|
|
28
31
|
*/
|
|
29
32
|
message: IgcChatMessage;
|
|
30
33
|
constructor();
|
|
31
|
-
|
|
34
|
+
private _adoptPageStyles;
|
|
32
35
|
private _getRenderer;
|
|
33
36
|
private _handleCopy;
|
|
34
37
|
private _handleMessageActionClick;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { ContextConsumer } from '@lit/context';
|
|
8
8
|
import { html, LitElement, nothing } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
import { cache } from 'lit/directives/cache.js';
|
|
@@ -19,7 +19,7 @@ import IgcMessageAttachmentsComponent from './message-attachments.js';
|
|
|
19
19
|
import { styles } from './themes/message.base.css.js';
|
|
20
20
|
import { all } from './themes/message.js';
|
|
21
21
|
import { styles as shared } from './themes/shared/chat-message/chat-message.common.css.js';
|
|
22
|
-
import {
|
|
22
|
+
import { addAdoptedStylesController } from './utils.js';
|
|
23
23
|
const LIKE_INACTIVE = 'thumb_up_inactive';
|
|
24
24
|
const LIKE_ACTIVE = 'thumb_up_active';
|
|
25
25
|
const DISLIKE_INACTIVE = 'thumb_down_inactive';
|
|
@@ -32,20 +32,31 @@ export default class IgcChatMessageComponent extends LitElement {
|
|
|
32
32
|
static register() {
|
|
33
33
|
registerComponent(IgcChatMessageComponent, IgcMessageAttachmentsComponent, IgcIconButtonComponent);
|
|
34
34
|
}
|
|
35
|
+
get _state() {
|
|
36
|
+
return this._stateConsumer.value;
|
|
37
|
+
}
|
|
35
38
|
constructor() {
|
|
36
39
|
super();
|
|
40
|
+
this._adoptedStyles = addAdoptedStylesController(this);
|
|
37
41
|
this._defaults = Object.freeze({
|
|
38
42
|
messageHeader: () => this._renderHeader(),
|
|
39
43
|
messageContent: () => this._renderContent(),
|
|
40
44
|
messageAttachments: () => this._renderAttachments(),
|
|
41
45
|
messageActions: () => this._renderActions(),
|
|
42
46
|
});
|
|
43
|
-
|
|
47
|
+
this._stateChanged = () => {
|
|
48
|
+
this._adoptedStyles.shouldAdoptStyles(!!this._state.options?.adoptRootStyles &&
|
|
49
|
+
!this._adoptedStyles.hasAdoptedStyles);
|
|
50
|
+
};
|
|
51
|
+
this._stateConsumer = new ContextConsumer(this, {
|
|
52
|
+
context: chatContext,
|
|
53
|
+
callback: this._stateChanged,
|
|
54
|
+
subscribe: true,
|
|
55
|
+
});
|
|
56
|
+
addThemingController(this, all, { themeChange: this._adoptPageStyles });
|
|
44
57
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
adoptPageStyles(this);
|
|
48
|
-
}
|
|
58
|
+
_adoptPageStyles() {
|
|
59
|
+
this._adoptedStyles.shouldAdoptStyles(this._adoptedStyles.hasAdoptedStyles);
|
|
49
60
|
}
|
|
50
61
|
_getRenderer(name) {
|
|
51
62
|
return this._state.options?.renderers
|
|
@@ -203,9 +214,6 @@ export default class IgcChatMessageComponent extends LitElement {
|
|
|
203
214
|
`;
|
|
204
215
|
}
|
|
205
216
|
}
|
|
206
|
-
__decorate([
|
|
207
|
-
consume({ context: chatContext, subscribe: true })
|
|
208
|
-
], IgcChatMessageComponent.prototype, "_state", void 0);
|
|
209
217
|
__decorate([
|
|
210
218
|
property({ attribute: false })
|
|
211
219
|
], IgcChatMessageComponent.prototype, "message", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message.js","sourceRoot":"","sources":["../../../src/components/chat/chat-message.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,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,8BAA8B,MAAM,0BAA0B,CAAC;AACtE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C,CAAC;;KAEpD,CAAC;IACJ,CAAC;IAEkB,MAAM;QACvB,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;QAChE,MAAM,GAAG,GAA6B;YACpC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SAC3B,CAAC;QAEF,MAAM,KAAK,GAAG;YACZ,mBAAmB,EAAE,IAAI;YACzB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC;SACrD,CAAC;QAEF,OAAO,IAAI,CAAA;QACP,KAAK,CACL,IAAI,CAAC,OAAO;YACV,CAAC,CAAC,IAAI,CAAA;0BACU,OAAO,CAAC,KAAK,CAAC;kBACtB,KAAK,CACL,eAAe;gBACb,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;gBAC7B,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAC1B;;aAEJ;YACH,CAAC,CAAC,OAAO,CACZ;KACF,CAAC;IACJ,CAAC;;AAjNgB;IADhB,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDACf;AAM7B;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;wDACC","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { cache } from 'lit/directives/cache.js';\nimport { until } from 'lit/directives/until.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcIconButtonComponent from '../button/icon-button.js';\nimport { chatContext } from '../common/context.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { partMap } from '../common/part-map.js';\nimport { isEmpty, trimmedHtml } from '../common/util.js';\nimport type { ChatState } from './chat-state.js';\nimport IgcMessageAttachmentsComponent from './message-attachments.js';\nimport { styles } from './themes/message.base.css.js';\nimport { all } from './themes/message.js';\nimport { styles as shared } from './themes/shared/chat-message/chat-message.common.css.js';\nimport type {\n ChatMessageRenderContext,\n ChatTemplateRenderer,\n IgcChatMessage,\n} from './types.js';\nimport { adoptPageStyles } from './utils.js';\n\nconst LIKE_INACTIVE = 'thumb_up_inactive';\nconst LIKE_ACTIVE = 'thumb_up_active';\nconst DISLIKE_INACTIVE = 'thumb_down_inactive';\nconst DISLIKE_ACTIVE = 'thumb_down_active';\nconst COPY_CONTENT = 'copy_content';\nconst REGENERATE = 'regenerate';\n\ntype DefaultMessageRenderers = {\n messageHeader: ChatTemplateRenderer<ChatMessageRenderContext>;\n messageContent: ChatTemplateRenderer<ChatMessageRenderContext>;\n messageAttachments: ChatTemplateRenderer<ChatMessageRenderContext>;\n messageActions: ChatTemplateRenderer<ChatMessageRenderContext>;\n};\n\n/* blazorSuppress */\n/**\n * A chat message component for displaying individual messages in `<igc-chat>`.\n *\n * @element igc-chat-message\n *\n *\n * This component renders a single chat message including:\n * - Message text (sanitized)\n * - Attachments (if any)\n * - Custom templates for message content and actions (if provided via chat options)\n *\n * It distinguishes sent messages from received messages by comparing\n * the message sender with the current user ID from chat state.\n *\n * The message text is sanitized with DOMPurify before rendering,\n * and can be rendered with a markdown renderer if provided.\n */\nexport default class IgcChatMessageComponent extends LitElement {\n public static readonly tagName = 'igc-chat-message';\n public static override styles = [styles, shared];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(\n IgcChatMessageComponent,\n IgcMessageAttachmentsComponent,\n IgcIconButtonComponent\n );\n }\n\n private readonly _defaults = Object.freeze<DefaultMessageRenderers>({\n messageHeader: () => this._renderHeader(),\n messageContent: () => this._renderContent(),\n messageAttachments: () => this._renderAttachments(),\n messageActions: () => this._renderActions(),\n });\n\n @consume({ context: chatContext, subscribe: true })\n private readonly _state!: ChatState;\n\n /**\n * The chat message to render.\n */\n @property({ attribute: false })\n public message!: IgcChatMessage;\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected override firstUpdated(): void {\n if (this._state.options?.adoptRootStyles) {\n adoptPageStyles(this);\n }\n }\n\n private _getRenderer(name: keyof DefaultMessageRenderers) {\n return this._state.options?.renderers\n ? (this._state.options.renderers[name] ?? this._defaults[name])\n : this._defaults[name];\n }\n\n private async _handleCopy(): Promise<void> {\n const text = this.message.text;\n const separator = text ? '\\n\\n' : '';\n const attachments = this.message.attachments ?? [];\n const { attachmentLabel, attachmentsListLabel, messageCopied } =\n this._state.resourceStrings!;\n\n const attachmentsText = isEmpty(attachments)\n ? ''\n : attachments\n .map(({ name, url }) => `${name ?? attachmentLabel}: ${url ?? ''}`)\n .join('\\n');\n\n const payload = attachmentsText\n ? `${text}${separator}${attachmentsListLabel}:\\n${attachmentsText}`\n : text;\n\n try {\n await navigator.clipboard.writeText(payload);\n this._state.showActionToast(messageCopied);\n } catch (err) {\n throw new Error(`Failed to copy message: ${err}`);\n }\n }\n\n private _handleMessageActionClick(event: PointerEvent): void {\n const targetButton = event.target as HTMLElement;\n const button = targetButton.closest(IgcIconButtonComponent.tagName);\n\n if (!button) {\n return;\n }\n\n let reaction = button.name;\n\n switch (reaction) {\n case LIKE_INACTIVE:\n case LIKE_ACTIVE:\n reaction = this.message.reactions?.includes(LIKE_ACTIVE)\n ? LIKE_INACTIVE\n : LIKE_ACTIVE;\n break;\n case DISLIKE_INACTIVE:\n case DISLIKE_ACTIVE:\n reaction = this.message.reactions?.includes(DISLIKE_ACTIVE)\n ? DISLIKE_INACTIVE\n : DISLIKE_ACTIVE;\n break;\n case COPY_CONTENT:\n reaction = COPY_CONTENT;\n this._handleCopy();\n break;\n case REGENERATE:\n reaction = REGENERATE;\n break;\n default:\n reaction = '';\n }\n\n this.message.reactions = reaction ? [reaction] : [];\n this._state.emitMessageReaction({ message: this.message, reaction });\n this.requestUpdate();\n }\n\n private _renderHeader() {\n return nothing;\n }\n\n private _renderContent() {\n return html`${this.message.text}`;\n }\n\n private _renderActions() {\n const isSent = this.message.sender === this._state.currentUserId;\n const hasText = this.message.text.trim();\n const hasAttachments = !isEmpty(this.message.attachments ?? []);\n const isTyping = this._state.options?.isTyping;\n const isLastMessage = this.message === this._state.messages.at(-1);\n const resourceStrings = this._state.resourceStrings!;\n\n if (isSent || !(hasText || hasAttachments) || (isLastMessage && isTyping)) {\n return nothing;\n }\n\n return html`\n ${this._renderActionButton(COPY_CONTENT, resourceStrings.reactionCopy)}\n ${this._renderActionButton(\n this.message.reactions?.includes(LIKE_ACTIVE)\n ? LIKE_ACTIVE\n : LIKE_INACTIVE,\n resourceStrings.reactionLike\n )}\n ${this._renderActionButton(\n this.message.reactions?.includes(DISLIKE_ACTIVE)\n ? DISLIKE_ACTIVE\n : DISLIKE_INACTIVE,\n resourceStrings.reactionDislike\n )}\n ${this._renderActionButton(\n REGENERATE,\n resourceStrings.reactionRegenerate\n )}\n `;\n }\n\n private _renderActionButton(name: string, tooltipMessage: string) {\n return html`\n <igc-icon-button\n id=${`${name}-button`}\n name=${name}\n variant=\"flat\"\n @pointerenter=${({ target }: PointerEvent) =>\n this._state.showActionsTooltip(target as Element, tooltipMessage)}\n @focus=${({ target }: FocusEvent) =>\n this._state.showActionsTooltip(target as Element, tooltipMessage)}\n ></igc-icon-button>\n `;\n }\n\n private _renderAttachments() {\n return isEmpty(this.message.attachments ?? [])\n ? nothing\n : html`\n <igc-message-attachments\n .message=${this.message}\n exportparts=\"\n attachment,\n attachment-header,\n attachment-icon,\n file-name,\n attachment-content\"\n ></igc-message-attachments>\n `;\n }\n\n private _renderMessage() {\n const ctx: ChatMessageRenderContext = {\n message: this.message,\n instance: this._state.host,\n };\n\n return trimmedHtml`\n <div part=\"message-header\">\n ${until(this._getRenderer('messageHeader')(ctx))}\n </div>\n <div part=\"plain-text\">\n ${until(this._getRenderer('messageContent')(ctx))}\n </div>\n <div part=\"message-attachments\">\n ${until(this._getRenderer('messageAttachments')(ctx))}\n </div>\n <div part=\"message-actions\" @click=${this._handleMessageActionClick}>\n ${until(this._getRenderer('messageActions')(ctx))}\n </div>\n `;\n }\n\n protected override render() {\n const messageRenderer = this._state.options?.renderers?.message;\n const ctx: ChatMessageRenderContext = {\n message: this.message,\n instance: this._state.host,\n };\n\n const parts = {\n 'message-container': true,\n sent: this._state.isCurrentUserMessage(this.message),\n };\n\n return html`\n ${cache(\n this.message\n ? html`\n <div part=${partMap(parts)}>\n ${cache(\n messageRenderer\n ? until(messageRenderer(ctx))\n : this._renderMessage()\n )}\n </div>\n `\n : nothing\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-chat-message': IgcChatMessageComponent;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat-message.js","sourceRoot":"","sources":["../../../src/components/chat/chat-message.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,8BAA8B,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OA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{ html, LitElement, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { cache } from 'lit/directives/cache.js';\nimport { until } from 'lit/directives/until.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcIconButtonComponent from '../button/icon-button.js';\nimport { chatContext } from '../common/context.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { partMap } from '../common/part-map.js';\nimport { isEmpty, trimmedHtml } from '../common/util.js';\nimport type { ChatState } from './chat-state.js';\nimport IgcMessageAttachmentsComponent from './message-attachments.js';\nimport { styles } from './themes/message.base.css.js';\nimport { all } from './themes/message.js';\nimport { styles as shared } from './themes/shared/chat-message/chat-message.common.css.js';\nimport type {\n ChatMessageRenderContext,\n ChatTemplateRenderer,\n IgcChatMessage,\n} from './types.js';\nimport { addAdoptedStylesController } from './utils.js';\n\nconst LIKE_INACTIVE = 'thumb_up_inactive';\nconst LIKE_ACTIVE = 'thumb_up_active';\nconst DISLIKE_INACTIVE = 'thumb_down_inactive';\nconst DISLIKE_ACTIVE = 'thumb_down_active';\nconst COPY_CONTENT = 'copy_content';\nconst REGENERATE = 'regenerate';\n\ntype DefaultMessageRenderers = {\n messageHeader: ChatTemplateRenderer<ChatMessageRenderContext>;\n messageContent: ChatTemplateRenderer<ChatMessageRenderContext>;\n messageAttachments: ChatTemplateRenderer<ChatMessageRenderContext>;\n messageActions: ChatTemplateRenderer<ChatMessageRenderContext>;\n};\n\n/* blazorSuppress */\n/**\n * A chat message component for displaying individual messages in `<igc-chat>`.\n *\n * @element igc-chat-message\n *\n *\n * This component renders a single chat message including:\n * - Message text (sanitized)\n * - Attachments (if any)\n * - Custom templates for message content and actions (if provided via chat options)\n *\n * It distinguishes sent messages from received messages by comparing\n * the message sender with the current user ID from chat state.\n *\n * The message text is sanitized with DOMPurify before rendering,\n * and can be rendered with a markdown renderer if provided.\n */\nexport default class IgcChatMessageComponent extends LitElement {\n public static readonly tagName = 'igc-chat-message';\n public static override styles = [styles, shared];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(\n IgcChatMessageComponent,\n IgcMessageAttachmentsComponent,\n IgcIconButtonComponent\n );\n }\n\n private readonly _adoptedStyles = addAdoptedStylesController(this);\n\n private readonly _defaults = Object.freeze<DefaultMessageRenderers>({\n messageHeader: () => this._renderHeader(),\n messageContent: () => this._renderContent(),\n messageAttachments: () => this._renderAttachments(),\n messageActions: () => this._renderActions(),\n });\n\n private readonly _stateChanged = () => {\n this._adoptedStyles.shouldAdoptStyles(\n !!this._state.options?.adoptRootStyles &&\n !this._adoptedStyles.hasAdoptedStyles\n );\n };\n\n private readonly _stateConsumer = new ContextConsumer(this, {\n context: chatContext,\n callback: this._stateChanged,\n subscribe: true,\n });\n\n private get _state(): ChatState {\n return this._stateConsumer.value!;\n }\n\n /**\n * The chat message to render.\n */\n @property({ attribute: false })\n public message!: IgcChatMessage;\n\n constructor() {\n super();\n addThemingController(this, all, { themeChange: this._adoptPageStyles });\n }\n\n private _adoptPageStyles(): void {\n this._adoptedStyles.shouldAdoptStyles(this._adoptedStyles.hasAdoptedStyles);\n }\n\n private _getRenderer(name: keyof DefaultMessageRenderers) {\n return this._state.options?.renderers\n ? (this._state.options.renderers[name] ?? this._defaults[name])\n : this._defaults[name];\n }\n\n private async _handleCopy(): Promise<void> {\n const text = this.message.text;\n const separator = text ? '\\n\\n' : '';\n const attachments = this.message.attachments ?? [];\n const { attachmentLabel, attachmentsListLabel, messageCopied } =\n this._state.resourceStrings!;\n\n const attachmentsText = isEmpty(attachments)\n ? ''\n : attachments\n .map(({ name, url }) => `${name ?? attachmentLabel}: ${url ?? ''}`)\n .join('\\n');\n\n const payload = attachmentsText\n ? `${text}${separator}${attachmentsListLabel}:\\n${attachmentsText}`\n : text;\n\n try {\n await navigator.clipboard.writeText(payload);\n this._state.showActionToast(messageCopied);\n } catch (err) {\n throw new Error(`Failed to copy message: ${err}`);\n }\n }\n\n private _handleMessageActionClick(event: PointerEvent): void {\n const targetButton = event.target as HTMLElement;\n const button = targetButton.closest(IgcIconButtonComponent.tagName);\n\n if (!button) {\n return;\n }\n\n let reaction = button.name;\n\n switch (reaction) {\n case LIKE_INACTIVE:\n case LIKE_ACTIVE:\n reaction = this.message.reactions?.includes(LIKE_ACTIVE)\n ? LIKE_INACTIVE\n : LIKE_ACTIVE;\n break;\n case DISLIKE_INACTIVE:\n case DISLIKE_ACTIVE:\n reaction = this.message.reactions?.includes(DISLIKE_ACTIVE)\n ? DISLIKE_INACTIVE\n : DISLIKE_ACTIVE;\n break;\n case COPY_CONTENT:\n reaction = COPY_CONTENT;\n this._handleCopy();\n break;\n case REGENERATE:\n reaction = REGENERATE;\n break;\n default:\n reaction = '';\n }\n\n this.message.reactions = reaction ? [reaction] : [];\n this._state.emitMessageReaction({ message: this.message, reaction });\n this.requestUpdate();\n }\n\n private _renderHeader() {\n return nothing;\n }\n\n private _renderContent() {\n return html`${this.message.text}`;\n }\n\n private _renderActions() {\n const isSent = this.message.sender === this._state.currentUserId;\n const hasText = this.message.text.trim();\n const hasAttachments = !isEmpty(this.message.attachments ?? []);\n const isTyping = this._state.options?.isTyping;\n const isLastMessage = this.message === this._state.messages.at(-1);\n const resourceStrings = this._state.resourceStrings!;\n\n if (isSent || !(hasText || hasAttachments) || (isLastMessage && isTyping)) {\n return nothing;\n }\n\n return html`\n ${this._renderActionButton(COPY_CONTENT, resourceStrings.reactionCopy)}\n ${this._renderActionButton(\n this.message.reactions?.includes(LIKE_ACTIVE)\n ? LIKE_ACTIVE\n : LIKE_INACTIVE,\n resourceStrings.reactionLike\n )}\n ${this._renderActionButton(\n this.message.reactions?.includes(DISLIKE_ACTIVE)\n ? DISLIKE_ACTIVE\n : DISLIKE_INACTIVE,\n resourceStrings.reactionDislike\n )}\n ${this._renderActionButton(\n REGENERATE,\n resourceStrings.reactionRegenerate\n )}\n `;\n }\n\n private _renderActionButton(name: string, tooltipMessage: string) {\n return html`\n <igc-icon-button\n id=${`${name}-button`}\n name=${name}\n variant=\"flat\"\n @pointerenter=${({ target }: PointerEvent) =>\n this._state.showActionsTooltip(target as Element, tooltipMessage)}\n @focus=${({ target }: FocusEvent) =>\n this._state.showActionsTooltip(target as Element, tooltipMessage)}\n ></igc-icon-button>\n `;\n }\n\n private _renderAttachments() {\n return isEmpty(this.message.attachments ?? [])\n ? nothing\n : html`\n <igc-message-attachments\n .message=${this.message}\n exportparts=\"\n attachment,\n attachment-header,\n attachment-icon,\n file-name,\n attachment-content\"\n ></igc-message-attachments>\n `;\n }\n\n private _renderMessage() {\n const ctx: ChatMessageRenderContext = {\n message: this.message,\n instance: this._state.host,\n };\n\n return trimmedHtml`\n <div part=\"message-header\">\n ${until(this._getRenderer('messageHeader')(ctx))}\n </div>\n <div part=\"plain-text\">\n ${until(this._getRenderer('messageContent')(ctx))}\n </div>\n <div part=\"message-attachments\">\n ${until(this._getRenderer('messageAttachments')(ctx))}\n </div>\n <div part=\"message-actions\" @click=${this._handleMessageActionClick}>\n ${until(this._getRenderer('messageActions')(ctx))}\n </div>\n `;\n }\n\n protected override render() {\n const messageRenderer = this._state.options?.renderers?.message;\n const ctx: ChatMessageRenderContext = {\n message: this.message,\n instance: this._state.host,\n };\n\n const parts = {\n 'message-container': true,\n sent: this._state.isCurrentUserMessage(this.message),\n };\n\n return html`\n ${cache(\n this.message\n ? html`\n <div part=${partMap(parts)}>\n ${cache(\n messageRenderer\n ? until(messageRenderer(ctx))\n : this._renderMessage()\n )}\n </div>\n `\n : nothing\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-chat-message': IgcChatMessageComponent;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LitElement } from 'lit';
|
|
1
|
+
import { type LitElement, type ReactiveController, type ReactiveControllerHost } from 'lit';
|
|
2
2
|
import type { IgcChatMessageAttachment } from './types.js';
|
|
3
3
|
export type ChatAcceptedFileTypes = {
|
|
4
4
|
extensions: Set<string>;
|
|
@@ -13,4 +13,15 @@ export declare function getIconName(fileType?: string): "attach_document" | "att
|
|
|
13
13
|
export declare function createAttachmentURL(attachment: IgcChatMessageAttachment): string;
|
|
14
14
|
export declare function getFileExtension(name: string): string;
|
|
15
15
|
export declare function isImageAttachment(attachment: IgcChatMessageAttachment | File): boolean;
|
|
16
|
-
|
|
16
|
+
declare class AdoptedStylesController implements ReactiveController {
|
|
17
|
+
private readonly _host;
|
|
18
|
+
private _hasAdoptedStyles;
|
|
19
|
+
get hasAdoptedStyles(): boolean;
|
|
20
|
+
private _adoptRootStyles;
|
|
21
|
+
constructor(host: ReactiveControllerHost & LitElement);
|
|
22
|
+
shouldAdoptStyles(condition: boolean): void;
|
|
23
|
+
/** @internal */
|
|
24
|
+
hostDisconnected(): void;
|
|
25
|
+
}
|
|
26
|
+
export declare function addAdoptedStylesController(host: ReactiveControllerHost & LitElement): AdoptedStylesController;
|
|
27
|
+
export type { AdoptedStylesController };
|
package/components/chat/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { adoptStyles } from 'lit';
|
|
1
|
+
import { adoptStyles, } from 'lit';
|
|
2
2
|
import { last } from '../common/util.js';
|
|
3
3
|
export const ChatFileTypeIcons = new Map(Object.entries({
|
|
4
4
|
css: 'file_css',
|
|
@@ -64,22 +64,44 @@ export function isImageAttachment(attachment) {
|
|
|
64
64
|
}
|
|
65
65
|
return Boolean(attachment.type === 'image' || attachment.file?.type.startsWith('image/'));
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
class AdoptedStylesController {
|
|
68
|
+
get hasAdoptedStyles() {
|
|
69
|
+
return this._hasAdoptedStyles;
|
|
70
|
+
}
|
|
71
|
+
_adoptRootStyles() {
|
|
72
|
+
const sheets = [];
|
|
73
|
+
for (const sheet of document.styleSheets) {
|
|
74
|
+
try {
|
|
75
|
+
const constructed = new CSSStyleSheet();
|
|
76
|
+
for (const rule of sheet.cssRules) {
|
|
77
|
+
if (rule.cssText.startsWith('@import')) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
constructed.insertRule(rule.cssText);
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
sheets.push(constructed);
|
|
77
83
|
}
|
|
78
|
-
|
|
84
|
+
catch { }
|
|
85
|
+
}
|
|
86
|
+
const ctor = this._host.constructor;
|
|
87
|
+
adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, ...sheets]);
|
|
88
|
+
}
|
|
89
|
+
constructor(host) {
|
|
90
|
+
this._hasAdoptedStyles = false;
|
|
91
|
+
this._host = host;
|
|
92
|
+
host.addController(this);
|
|
93
|
+
}
|
|
94
|
+
shouldAdoptStyles(condition) {
|
|
95
|
+
if (condition) {
|
|
96
|
+
this._adoptRootStyles();
|
|
97
|
+
this._hasAdoptedStyles = true;
|
|
79
98
|
}
|
|
80
|
-
catch { }
|
|
81
99
|
}
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
hostDisconnected() {
|
|
101
|
+
this._hasAdoptedStyles = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function addAdoptedStylesController(host) {
|
|
105
|
+
return new AdoptedStylesController(host);
|
|
84
106
|
}
|
|
85
107
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/chat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/chat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAIZ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AASzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CACtC,MAAM,CAAC,OAAO,CAAC;IACb,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,GAAG,E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C,WAAW,CAAC,CAAC;YAC3B,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAgC,CAAC;QACzD,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAW,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,YAAY,IAAyC;QA3B7C,sBAAiB,GAAG,KAAK,CAAC;QA4BhC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEM,iBAAiB,CAAC,SAAkB;QACzC,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAChC,CAAC;IACH,CAAC;IAGM,gBAAgB;QACrB,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACjC,CAAC;CACF;AAED,MAAM,UAAU,0BAA0B,CACxC,IAAyC;IAEzC,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import {\n adoptStyles,\n type LitElement,\n type ReactiveController,\n type ReactiveControllerHost,\n} from 'lit';\nimport { last } from '../common/util.js';\nimport type { IgcChatMessageAttachment } from './types.js';\n\nexport type ChatAcceptedFileTypes = {\n extensions: Set<string>;\n mimeTypes: Set<string>;\n wildcardTypes: Set<string>;\n};\n\nexport const ChatFileTypeIcons = new Map(\n Object.entries({\n css: 'file_css',\n csv: 'file_csv',\n doc: 'file_doc',\n docx: 'file_doc',\n htm: 'file_htm',\n html: 'file_html',\n js: 'file_js',\n json: 'file_json',\n pdf: 'file_pdf',\n rtf: 'file_rtf',\n svg: 'file_svg',\n txt: 'file_txt',\n url: 'file_link',\n xls: 'file_xls',\n xlsx: 'file_xls',\n xml: 'file_xml',\n zip: 'file_zip',\n default: 'file_generic',\n })\n);\n\nexport function parseAcceptedFileTypes(\n fileTypes: string\n): ChatAcceptedFileTypes {\n const types = fileTypes.split(',').map((each) => each.trim().toLowerCase());\n return {\n extensions: new Set(types.filter((t) => t.startsWith('.'))),\n mimeTypes: new Set(\n types.filter((t) => !t.startsWith('.') && !t.endsWith('/*'))\n ),\n wildcardTypes: new Set(\n types.filter((t) => t.endsWith('/*')).map((t) => t.slice(0, -2))\n ),\n };\n}\n\nexport function isAcceptedFileType(\n file: File,\n accepted: ChatAcceptedFileTypes | null\n): boolean {\n if (!(accepted && file)) {\n return true;\n }\n\n const { extensions, mimeTypes, wildcardTypes } = accepted;\n const fileType = file.type.toLowerCase();\n const fileExtension = `.${last(file.name.split('.'))?.toLowerCase()}`;\n const [fileBaseType] = fileType.split('/');\n\n return (\n extensions.has(fileExtension) ||\n mimeTypes.has(fileType) ||\n wildcardTypes.has(fileBaseType)\n );\n}\n\nexport function getChatAcceptedFiles(\n event: DragEvent,\n accepted: ChatAcceptedFileTypes | null\n): File[] {\n return Array.from(event.dataTransfer?.items ?? [])\n .filter(\n (item) =>\n item.kind === 'file' && isAcceptedFileType(item.getAsFile()!, accepted)\n )\n .map((item) => item.getAsFile()!);\n}\n\nexport function getIconName(fileType?: string) {\n return fileType?.startsWith('image') ? 'attach_image' : 'attach_document';\n}\n\nexport function createAttachmentURL(\n attachment: IgcChatMessageAttachment\n): string {\n if (attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n\n return attachment.url || '';\n}\n\nexport function getFileExtension(name: string): string {\n const parts = name.split('.');\n return parts.length > 1 ? last(parts) : '';\n}\n\nexport function isImageAttachment(\n attachment: IgcChatMessageAttachment | File\n): boolean {\n if (attachment instanceof File) {\n return attachment.type.startsWith('image/');\n }\n\n return Boolean(\n attachment.type === 'image' || attachment.file?.type.startsWith('image/')\n );\n}\n\nclass AdoptedStylesController implements ReactiveController {\n private readonly _host: ReactiveControllerHost & LitElement;\n private _hasAdoptedStyles = false;\n\n public get hasAdoptedStyles(): boolean {\n return this._hasAdoptedStyles;\n }\n\n private _adoptRootStyles(): void {\n const sheets: CSSStyleSheet[] = [];\n\n for (const sheet of document.styleSheets) {\n try {\n const constructed = new CSSStyleSheet();\n for (const rule of sheet.cssRules) {\n // https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule:~:text=If%20parsed%20rule%20is%20an%20%40import%20rule\n if (rule.cssText.startsWith('@import')) {\n continue;\n }\n constructed.insertRule(rule.cssText);\n }\n sheets.push(constructed);\n } catch {}\n }\n\n const ctor = this._host.constructor as typeof LitElement;\n adoptStyles(this._host.shadowRoot!, [...ctor.elementStyles, ...sheets]);\n }\n\n constructor(host: ReactiveControllerHost & LitElement) {\n this._host = host;\n host.addController(this);\n }\n\n public shouldAdoptStyles(condition: boolean): void {\n if (condition) {\n this._adoptRootStyles();\n this._hasAdoptedStyles = true;\n }\n }\n\n /** @internal */\n public hostDisconnected(): void {\n this._hasAdoptedStyles = false;\n }\n}\n\nexport function addAdoptedStylesController(\n host: ReactiveControllerHost & LitElement\n): AdoptedStylesController {\n return new AdoptedStylesController(host);\n}\n\nexport type { AdoptedStylesController };\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const styles = css `:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){font-family:var(--ig-body-2-font-family, var(--ig-font-family));font-size:var(--ig-body-2-font-size);font-weight:var(--ig-body-2-font-weight);font-style:var(--ig-body-2-font-style);line-height:var(--ig-body-2-line-height);letter-spacing:var(--ig-body-2-letter-spacing);text-transform:var(--ig-body-2-text-transform);margin-top:var(--ig-body-2-margin-top);margin-bottom:var(--ig-body-2-margin-bottom);grid-auto-rows:minmax(1.25rem, auto);margin-block-start:max(var(--is-large, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))))}:host ::slotted([slot=suffix]),:host ::slotted([slot=prefix]){height:100%;display:flex;align-items:center}[part=list-wrapper]{border:var(--border-width) solid var(--border-color);background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input,[part=list-wrapper] igc-input::part(container),[part=list-wrapper] igc-input::part(input){height:1.75rem}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;border-radius:0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-end:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(suffix){background:rgba(0,0,0,0);border:none;border-radius:0}[part=list-wrapper] [part=search-input] [part~=case-icon]{border-block-end:.0625rem solid var(--ig-gray-400);border-inline:none;transition:border .15s ease-out}[part=list-wrapper] [part=search-input]:focus,[part=list-wrapper] [part=search-input]:focus-within{border-block-end:.125rem solid var(--ig-primary-500)}[part=list-wrapper] [part=search-input]:focus [part~=case-icon],[part=list-wrapper] [part=search-input]:focus-within [part~=case-icon]{border:none}[part=clear-icon]{border-inline-end:.0625rem solid var(--border-color)}[part="case-icon active"]{color:var(--ig-primary-500)}:host(:
|
|
2
|
+
export const styles = css `:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){font-family:var(--ig-body-2-font-family, var(--ig-font-family));font-size:var(--ig-body-2-font-size);font-weight:var(--ig-body-2-font-weight);font-style:var(--ig-body-2-font-style);line-height:var(--ig-body-2-line-height);letter-spacing:var(--ig-body-2-letter-spacing);text-transform:var(--ig-body-2-text-transform);margin-top:var(--ig-body-2-margin-top);margin-bottom:var(--ig-body-2-margin-bottom);grid-auto-rows:minmax(1.25rem, auto);margin-block-start:max(var(--is-large, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))))}:host ::slotted([slot=suffix]),:host ::slotted([slot=prefix]){height:100%;display:flex;align-items:center}[part=list-wrapper]{border:var(--border-width) solid var(--border-color);background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input,[part=list-wrapper] igc-input::part(container),[part=list-wrapper] igc-input::part(input){height:1.75rem}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;border-radius:0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-end:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(suffix){background:rgba(0,0,0,0);border:none;border-radius:0}[part=list-wrapper] [part=search-input] [part~=case-icon]{border-block-end:.0625rem solid var(--ig-gray-400);border-inline:none;transition:border .15s ease-out}[part=list-wrapper] [part=search-input]:focus,[part=list-wrapper] [part=search-input]:focus-within{border-block-end:.125rem solid var(--ig-primary-500)}[part=list-wrapper] [part=search-input]:focus [part~=case-icon],[part=list-wrapper] [part=search-input]:focus-within [part~=case-icon]{border:none}[part=clear-icon]{border-inline-end:.0625rem solid var(--border-color)}[part="case-icon active"]{color:var(--ig-primary-500)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{border-inline-end:.0625rem solid var(--disabled-border-color)}:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) [part|=toggle],:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) [part|=toggle]{border-inline-end:.0625rem solid var(--disabled-border-color)}:host(:disabled) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=prefix]){border-inline-start:.0625rem solid var(--disabled-border-color)}:host(:not([disabled])) ::slotted([slot=suffix]),:host(:not([disabled])) [part|=toggle],:host(:not(:disabled)) ::slotted([slot=suffix]),:host(:not(:disabled)) [part|=toggle]{border-inline-end:.0625rem solid var(--border-color)}:host(:not([disabled])) ::slotted([slot=prefix]),:host(:not(:disabled)) ::slotted([slot=prefix]){border-inline-start:.0625rem solid var(--border-color)}`;
|
|
3
3
|
//# sourceMappingURL=combo.bootstrap.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo.bootstrap.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.bootstrap.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"combo.bootstrap.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.bootstrap.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,q5GAAq5G,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){font-family:var(--ig-body-2-font-family, var(--ig-font-family));font-size:var(--ig-body-2-font-size);font-weight:var(--ig-body-2-font-weight);font-style:var(--ig-body-2-font-style);line-height:var(--ig-body-2-line-height);letter-spacing:var(--ig-body-2-letter-spacing);text-transform:var(--ig-body-2-text-transform);margin-top:var(--ig-body-2-margin-top);margin-bottom:var(--ig-body-2-margin-bottom);grid-auto-rows:minmax(1.25rem, auto);margin-block-start:max(var(--is-large, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))))}:host ::slotted([slot=suffix]),:host ::slotted([slot=prefix]){height:100%;display:flex;align-items:center}[part=list-wrapper]{border:var(--border-width) solid var(--border-color);background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input,[part=list-wrapper] igc-input::part(container),[part=list-wrapper] igc-input::part(input){height:1.75rem}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;border-radius:0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-end:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(suffix){background:rgba(0,0,0,0);border:none;border-radius:0}[part=list-wrapper] [part=search-input] [part~=case-icon]{border-block-end:.0625rem solid var(--ig-gray-400);border-inline:none;transition:border .15s ease-out}[part=list-wrapper] [part=search-input]:focus,[part=list-wrapper] [part=search-input]:focus-within{border-block-end:.125rem solid var(--ig-primary-500)}[part=list-wrapper] [part=search-input]:focus [part~=case-icon],[part=list-wrapper] [part=search-input]:focus-within [part~=case-icon]{border:none}[part=clear-icon]{border-inline-end:.0625rem solid var(--border-color)}[part=\"case-icon active\"]{color:var(--ig-primary-500)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{border-inline-end:.0625rem solid var(--disabled-border-color)}:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) [part|=toggle],:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) [part|=toggle]{border-inline-end:.0625rem solid var(--disabled-border-color)}:host(:disabled) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=prefix]){border-inline-start:.0625rem solid var(--disabled-border-color)}:host(:not([disabled])) ::slotted([slot=suffix]),:host(:not([disabled])) [part|=toggle],:host(:not(:disabled)) ::slotted([slot=suffix]),:host(:not(:disabled)) [part|=toggle]{border-inline-end:.0625rem solid var(--border-color)}:host(:not([disabled])) ::slotted([slot=prefix]),:host(:not(:disabled)) ::slotted([slot=prefix]){border-inline-start:.0625rem solid var(--border-color)}`;\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const styles = css `:host ::part(helper-text){color:var(--helper-text-color)}:host igc-popover::part(container){border-radius:var(--border-radius)}[part=empty]{color:var(--empty-list-placeholder-color)}[part~=toggle-icon]{background:var(--toggle-button-background);color:var(--toggle-button-foreground)}[part~=toggle-icon] igc-icon{color:inherit}[part~=clear-icon]{background:var(--clear-button-background);color:var(--clear-button-foreground)}[part~=clear-icon] igc-icon{color:inherit}:host(:focus-within) [part~=toggle-icon]{background:var(--toggle-button-background-focus
|
|
2
|
+
export const styles = css `:host ::part(helper-text){color:var(--helper-text-color)}:host igc-popover::part(container){border-radius:var(--border-radius)}[part=filter-input]{border-bottom:.0625rem dashed var(--search-separator-border-color)}[part=empty]{color:var(--empty-list-placeholder-color);background:var(--empty-list-background)}[part~=toggle-icon]{background:var(--toggle-button-background);color:var(--toggle-button-foreground)}[part~=toggle-icon] igc-icon{color:inherit}[part="toggle-icon filled"]{color:var(--toggle-button-foreground-filled)}[part~=clear-icon]{background:var(--clear-button-background);color:var(--clear-button-foreground)}[part~=clear-icon] igc-icon{color:inherit}:host(:focus-within) [part~=toggle-icon]{background:var(--toggle-button-background-focus);color:var(--toggle-button-foreground-focus)}:host(:focus-within) [part~=toggle-icon] igc-icon{color:inherit}:host(:focus-within) [part~=clear-icon]{background:var(--clear-button-background-focus);color:var(--clear-button-foreground-focus)}:host(:focus-within) [part~=clear-icon] igc-icon{color:inherit}:host(:not([disabled]):state(ig-invalid)) ::part(helper-text),:host(:not(:disabled):state(ig-invalid)) ::part(helper-text){color:var(--error-secondary-color)}:host(:disabled) igc-input::part(input)::-moz-placeholder, :host([disabled]) igc-input::part(input)::-moz-placeholder{color:var(--disabled-text-color)}:host(:disabled) ::slotted([slot=prefix]),:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) igc-input::part(label),:host(:disabled) igc-input::part(input)::placeholder,:host(:disabled) ::part(helper-text),:host([disabled]) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) igc-input::part(label),:host([disabled]) igc-input::part(input)::placeholder,:host([disabled]) ::part(helper-text){color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{background:inherit;color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon] igc-icon,:host([disabled]) [part~=clear-icon] igc-icon{color:inherit}:host(:disabled) [part~=toggle-icon],:host([disabled]) [part~=toggle-icon]{background:var(--toggle-button-background-disabled);color:var(--toggle-button-foreground-disabled)}:host(:disabled) [part~=toggle-icon] igc-icon,:host([disabled]) [part~=toggle-icon] igc-icon{color:inherit}::slotted([slot=suffix]),::slotted([slot=prefix]){padding-inline:var(--affix-padding)}`;
|
|
3
3
|
//# sourceMappingURL=combo.common.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo.common.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.common.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"combo.common.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.common.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,g4EAAg4E,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host ::part(helper-text){color:var(--helper-text-color)}:host igc-popover::part(container){border-radius:var(--border-radius)}[part=filter-input]{border-bottom:.0625rem dashed var(--search-separator-border-color)}[part=empty]{color:var(--empty-list-placeholder-color);background:var(--empty-list-background)}[part~=toggle-icon]{background:var(--toggle-button-background);color:var(--toggle-button-foreground)}[part~=toggle-icon] igc-icon{color:inherit}[part=\"toggle-icon filled\"]{color:var(--toggle-button-foreground-filled)}[part~=clear-icon]{background:var(--clear-button-background);color:var(--clear-button-foreground)}[part~=clear-icon] igc-icon{color:inherit}:host(:focus-within) [part~=toggle-icon]{background:var(--toggle-button-background-focus);color:var(--toggle-button-foreground-focus)}:host(:focus-within) [part~=toggle-icon] igc-icon{color:inherit}:host(:focus-within) [part~=clear-icon]{background:var(--clear-button-background-focus);color:var(--clear-button-foreground-focus)}:host(:focus-within) [part~=clear-icon] igc-icon{color:inherit}:host(:not([disabled]):state(ig-invalid)) ::part(helper-text),:host(:not(:disabled):state(ig-invalid)) ::part(helper-text){color:var(--error-secondary-color)}:host(:disabled) igc-input::part(input)::-moz-placeholder, :host([disabled]) igc-input::part(input)::-moz-placeholder{color:var(--disabled-text-color)}:host(:disabled) ::slotted([slot=prefix]),:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) igc-input::part(label),:host(:disabled) igc-input::part(input)::placeholder,:host(:disabled) ::part(helper-text),:host([disabled]) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) igc-input::part(label),:host([disabled]) igc-input::part(input)::placeholder,:host([disabled]) ::part(helper-text){color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{background:inherit;color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon] igc-icon,:host([disabled]) [part~=clear-icon] igc-icon{color:inherit}:host(:disabled) [part~=toggle-icon],:host([disabled]) [part~=toggle-icon]{background:var(--toggle-button-background-disabled);color:var(--toggle-button-foreground-disabled)}:host(:disabled) [part~=toggle-icon] igc-icon,:host([disabled]) [part~=toggle-icon] igc-icon{color:inherit}::slotted([slot=suffix]),::slotted([slot=prefix]){padding-inline:var(--affix-padding)}`;\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const styles = css `:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){margin-block-start:max(var(--is-large, 1)*max(0.3125rem, -1 * 0.3125rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.3125rem, -1 * 0.3125rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.3125rem, -1 * 0.3125rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))));grid-auto-rows:minmax(1.125rem, auto)}[part=filter-input]{padding:max(var(--is-large, 1)*max(0.5rem, -1 * 0.5rem)*var(--ig-spacing-large, var(--ig-spacing, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-medium, var(--ig-spacing, var(--ig-spacing))),var(--is-small, 1)*max(0.125rem, -1 * 0.125rem)*var(--ig-spacing-small, var(--ig-spacing, var(--ig-spacing))))}[part=list-wrapper]{background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-radius:0;border-inline:0;border-block-start:0}[part=list-wrapper] igc-input::part(container)::before{inset-inline-start:0;width:calc(100% - var(--input-border-size));box-shadow:inset 0 calc(var(--input-border-size)*-1) 0 0;border-radius:0}[part=list-wrapper] igc-input:focus-within::part(container)::before{box-shadow:inset 0 calc((var(--input-border-size) + 0.0625rem)*-1) 0 0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none;height:var(--size)}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(suffix){background:rgba(0,0,0,0)}
|
|
2
|
+
export const styles = css `:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){margin-block-start:max(var(--is-large, 1)*max(0.3125rem, -1 * 0.3125rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.3125rem, -1 * 0.3125rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.3125rem, -1 * 0.3125rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))));grid-auto-rows:minmax(1.125rem, auto)}[part=filter-input]{padding:max(var(--is-large, 1)*max(0.5rem, -1 * 0.5rem)*var(--ig-spacing-large, var(--ig-spacing, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-medium, var(--ig-spacing, var(--ig-spacing))),var(--is-small, 1)*max(0.125rem, -1 * 0.125rem)*var(--ig-spacing-small, var(--ig-spacing, var(--ig-spacing))))}[part=list-wrapper]{background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-radius:0;border-inline:0;border-block-start:0}[part=list-wrapper] igc-input::part(container)::before{inset-inline-start:0;width:calc(100% - var(--input-border-size));box-shadow:inset 0 calc(var(--input-border-size)*-1) 0 0;border-radius:0}[part=list-wrapper] igc-input:focus-within::part(container)::before{box-shadow:inset 0 calc((var(--input-border-size) + 0.0625rem)*-1) 0 0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none;height:var(--size)}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(suffix){background:rgba(0,0,0,0)}`;
|
|
3
3
|
//# sourceMappingURL=combo.fluent.css.js.map
|