igniteui-webcomponents 6.3.0-beta.0 → 6.3.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/CHANGELOG.md +14 -0
- package/components/accordion/accordion.js +3 -4
- package/components/accordion/accordion.js.map +1 -1
- package/components/avatar/avatar.js +3 -4
- package/components/avatar/avatar.js.map +1 -1
- package/components/badge/badge.js +3 -4
- package/components/badge/badge.js.map +1 -1
- package/components/banner/banner.js +3 -4
- package/components/banner/banner.js.map +1 -1
- package/components/button/button-base.js +1 -1
- package/components/button/button-base.js.map +1 -1
- package/components/button/button.js +3 -4
- package/components/button/button.js.map +1 -1
- package/components/button/icon-button.js +3 -4
- package/components/button/icon-button.js.map +1 -1
- package/components/button-group/button-group.js +3 -4
- package/components/button-group/button-group.js.map +1 -1
- package/components/button-group/toggle-button.js +4 -3
- package/components/button-group/toggle-button.js.map +1 -1
- package/components/calendar/calendar.js +3 -4
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.js +4 -3
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/months-view/months-view.js +4 -3
- package/components/calendar/months-view/months-view.js.map +1 -1
- package/components/calendar/years-view/years-view.js +4 -3
- package/components/calendar/years-view/years-view.js.map +1 -1
- package/components/card/card.actions.js +3 -4
- package/components/card/card.actions.js.map +1 -1
- package/components/card/card.content.js +3 -4
- package/components/card/card.content.js.map +1 -1
- package/components/card/card.header.js +3 -4
- package/components/card/card.header.js.map +1 -1
- package/components/card/card.js +3 -4
- package/components/card/card.js.map +1 -1
- package/components/card/card.media.js +3 -4
- package/components/card/card.media.js.map +1 -1
- package/components/carousel/carousel-indicator-container.js +3 -4
- package/components/carousel/carousel-indicator-container.js.map +1 -1
- package/components/carousel/carousel-indicator.js +3 -4
- package/components/carousel/carousel-indicator.js.map +1 -1
- package/components/carousel/carousel-slide.js +3 -4
- package/components/carousel/carousel-slide.js.map +1 -1
- package/components/carousel/carousel.js +3 -4
- package/components/carousel/carousel.js.map +1 -1
- package/components/chat/chat-input.d.ts +8 -20
- package/components/chat/chat-input.js +78 -56
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat-message.d.ts +6 -21
- package/components/chat/chat-message.js +113 -71
- package/components/chat/chat-message.js.map +1 -1
- package/components/chat/chat-state.d.ts +45 -50
- package/components/chat/chat-state.js +82 -91
- package/components/chat/chat-state.js.map +1 -1
- package/components/chat/chat.d.ts +68 -24
- package/components/chat/chat.js +99 -96
- package/components/chat/chat.js.map +1 -1
- package/components/chat/extras/markdown-renderer.d.ts +6 -3
- package/components/chat/extras/markdown-renderer.js +19 -14
- package/components/chat/extras/markdown-renderer.js.map +1 -1
- package/components/chat/message-attachments.d.ts +5 -5
- package/components/chat/message-attachments.js +49 -43
- package/components/chat/message-attachments.js.map +1 -1
- package/components/chat/themes/chat.base.css.js +1 -1
- package/components/chat/themes/chat.base.css.js.map +1 -1
- package/components/chat/themes/dark/chat.bootstrap.css.js +1 -1
- package/components/chat/themes/dark/chat.bootstrap.css.js.map +1 -1
- package/components/chat/themes/dark/chat.fluent.css.js +1 -1
- package/components/chat/themes/dark/chat.fluent.css.js.map +1 -1
- package/components/chat/themes/dark/chat.indigo.css.js +1 -1
- package/components/chat/themes/dark/chat.indigo.css.js.map +1 -1
- package/components/chat/themes/dark/chat.material.css.js +1 -1
- package/components/chat/themes/dark/chat.material.css.js.map +1 -1
- package/components/chat/themes/input.base.css.js +1 -1
- package/components/chat/themes/input.base.css.js.map +1 -1
- package/components/chat/themes/light/chat.bootstrap.css.js +1 -1
- package/components/chat/themes/light/chat.bootstrap.css.js.map +1 -1
- package/components/chat/themes/light/chat.indigo.css.js +1 -1
- package/components/chat/themes/light/chat.indigo.css.js.map +1 -1
- package/components/chat/themes/light/chat.shared.css.js +1 -1
- package/components/chat/themes/light/chat.shared.css.js.map +1 -1
- package/components/chat/themes/message-attachments.base.css.js +1 -1
- package/components/chat/themes/message-attachments.base.css.js.map +1 -1
- package/components/chat/themes/message.base.css.js +1 -1
- package/components/chat/themes/message.base.css.js.map +1 -1
- package/components/chat/themes/shared/chat.bootstrap.css.js +1 -1
- package/components/chat/themes/shared/chat.bootstrap.css.js.map +1 -1
- package/components/chat/themes/shared/chat.fluent.css.js +1 -1
- package/components/chat/themes/shared/chat.fluent.css.js.map +1 -1
- package/components/chat/themes/shared/chat.indigo.css.js +1 -1
- package/components/chat/themes/shared/chat.indigo.css.js.map +1 -1
- package/components/chat/themes/shared/input/input.bootstrap.css.js +1 -1
- package/components/chat/themes/shared/input/input.bootstrap.css.js.map +1 -1
- package/components/chat/themes/shared/input/input.fluent.css.js +1 -1
- package/components/chat/themes/shared/input/input.fluent.css.js.map +1 -1
- package/components/chat/themes/shared/input/input.indigo.css.js +1 -1
- package/components/chat/themes/shared/input/input.indigo.css.js.map +1 -1
- package/components/chat/themes/shared/message-attachments/message-attachments.common.css.js +1 -1
- package/components/chat/themes/shared/message-attachments/message-attachments.common.css.js.map +1 -1
- package/components/chat/types.d.ts +173 -28
- package/components/chat/types.js.map +1 -1
- package/components/chat/utils.d.ts +3 -3
- package/components/chat/utils.js +7 -11
- package/components/chat/utils.js.map +1 -1
- package/components/checkbox/checkbox.js +3 -4
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/checkbox/switch.js +3 -4
- package/components/checkbox/switch.js.map +1 -1
- package/components/checkbox/themes/checkbox.base.css.js +1 -1
- package/components/checkbox/themes/checkbox.base.css.js.map +1 -1
- package/components/checkbox/themes/switch.base.css.js +1 -1
- package/components/checkbox/themes/switch.base.css.js.map +1 -1
- package/components/chip/chip.js +3 -4
- package/components/chip/chip.js.map +1 -1
- package/components/combo/combo-header.js +3 -4
- package/components/combo/combo-header.js.map +1 -1
- package/components/combo/combo-item.js +3 -4
- package/components/combo/combo-item.js.map +1 -1
- package/components/combo/combo-list.js +2 -3
- package/components/combo/combo-list.js.map +1 -1
- package/components/combo/combo.js +4 -3
- package/components/combo/combo.js.map +1 -1
- package/components/common/controllers/focus-ring.js +5 -5
- package/components/common/controllers/focus-ring.js.map +1 -1
- package/components/common/controllers/key-bindings.js +4 -4
- package/components/common/controllers/key-bindings.js.map +1 -1
- package/components/common/i18n/chat.resources.d.ts +3 -0
- package/components/common/i18n/chat.resources.js +3 -0
- package/components/common/i18n/chat.resources.js.map +1 -1
- package/components/common/mixins/forms/associated.js +1 -1
- package/components/common/mixins/forms/associated.js.map +1 -1
- package/components/common/mixins/forms/form-value.js +1 -1
- package/components/common/mixins/forms/form-value.js.map +1 -1
- package/components/common/part-map.d.ts +1 -1
- package/components/common/util.d.ts +3 -0
- package/components/common/util.js +9 -1
- package/components/common/util.js.map +1 -1
- package/components/date-picker/date-picker.js +5 -4
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-range-picker/date-range-picker.js +5 -4
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.js +3 -4
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-time-input/date-time-input.js +2 -3
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/date-time-input/date-util.js +11 -11
- package/components/date-time-input/date-util.js.map +1 -1
- package/components/dialog/dialog.js +3 -4
- package/components/dialog/dialog.js.map +1 -1
- package/components/divider/divider.js +3 -4
- package/components/divider/divider.js.map +1 -1
- package/components/dropdown/dropdown-group.js +3 -4
- package/components/dropdown/dropdown-group.js.map +1 -1
- package/components/dropdown/dropdown-header.js +3 -4
- package/components/dropdown/dropdown-header.js.map +1 -1
- package/components/dropdown/dropdown-item.js +3 -4
- package/components/dropdown/dropdown-item.js.map +1 -1
- package/components/dropdown/dropdown.js +4 -3
- package/components/dropdown/dropdown.js.map +1 -1
- package/components/expansion-panel/expansion-panel.js +3 -4
- package/components/expansion-panel/expansion-panel.js.map +1 -1
- package/components/file-input/file-input.js +3 -4
- package/components/file-input/file-input.js.map +1 -1
- package/components/focus-trap/focus-trap.js +7 -8
- package/components/focus-trap/focus-trap.js.map +1 -1
- package/components/icon/icon-references.js +78 -0
- package/components/icon/icon-references.js.map +1 -1
- package/components/icon/icon-state.broadcast.js +1 -1
- package/components/icon/icon-state.broadcast.js.map +1 -1
- package/components/icon/icon.js +3 -4
- package/components/icon/icon.js.map +1 -1
- package/components/icon/internal-icons-lib.js +39 -0
- package/components/icon/internal-icons-lib.js.map +1 -1
- package/components/input/input-base.js +4 -3
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.js +2 -3
- package/components/input/input.js.map +1 -1
- package/components/input/themes/shared/input.bootstrap.css.js +1 -1
- package/components/input/themes/shared/input.bootstrap.css.js.map +1 -1
- package/components/input/themes/shared/input.indigo.css.js +1 -1
- package/components/input/themes/shared/input.indigo.css.js.map +1 -1
- package/components/list/list-header.js +3 -4
- package/components/list/list-header.js.map +1 -1
- package/components/list/list-item.js +3 -4
- package/components/list/list-item.js.map +1 -1
- package/components/list/list.js +3 -4
- package/components/list/list.js.map +1 -1
- package/components/list/themes/header.js +2 -28
- package/components/list/themes/header.js.map +1 -1
- package/components/list/themes/item.js +6 -20
- package/components/list/themes/item.js.map +1 -1
- package/components/mask-input/mask-input.js +2 -3
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/nav-drawer/nav-drawer-header-item.js +3 -4
- package/components/nav-drawer/nav-drawer-header-item.js.map +1 -1
- package/components/nav-drawer/nav-drawer-item.js +3 -4
- package/components/nav-drawer/nav-drawer-item.js.map +1 -1
- package/components/nav-drawer/nav-drawer.js +3 -4
- package/components/nav-drawer/nav-drawer.js.map +1 -1
- package/components/navbar/navbar.js +3 -4
- package/components/navbar/navbar.js.map +1 -1
- package/components/popover/popover.js +9 -10
- package/components/popover/popover.js.map +1 -1
- package/components/progress/circular-gradient.js +2 -3
- package/components/progress/circular-gradient.js.map +1 -1
- package/components/progress/circular-progress.js +3 -4
- package/components/progress/circular-progress.js.map +1 -1
- package/components/progress/linear-progress.js +3 -4
- package/components/progress/linear-progress.js.map +1 -1
- package/components/radio/radio.js +3 -4
- package/components/radio/radio.js.map +1 -1
- package/components/radio-group/radio-group.js +3 -4
- package/components/radio-group/radio-group.js.map +1 -1
- package/components/rating/rating-symbol.js +3 -4
- package/components/rating/rating-symbol.js.map +1 -1
- package/components/rating/rating.js +3 -4
- package/components/rating/rating.js.map +1 -1
- package/components/resize-container/resize-container.js +3 -4
- package/components/resize-container/resize-container.js.map +1 -1
- package/components/ripple/ripple.js +3 -4
- package/components/ripple/ripple.js.map +1 -1
- package/components/select/select-group.js +3 -4
- package/components/select/select-group.js.map +1 -1
- package/components/select/select-header.js +3 -4
- package/components/select/select-header.js.map +1 -1
- package/components/select/select-item.js +3 -4
- package/components/select/select-item.js.map +1 -1
- package/components/select/select.js +4 -3
- package/components/select/select.js.map +1 -1
- package/components/slider/range-slider.js +2 -3
- package/components/slider/range-slider.js.map +1 -1
- package/components/slider/slider-base.js +1 -1
- package/components/slider/slider-base.js.map +1 -1
- package/components/slider/slider-label.js +7 -8
- package/components/slider/slider-label.js.map +1 -1
- package/components/slider/slider.js +2 -3
- package/components/slider/slider.js.map +1 -1
- package/components/snackbar/snackbar.js +3 -4
- package/components/snackbar/snackbar.js.map +1 -1
- package/components/stepper/step.js +3 -4
- package/components/stepper/step.js.map +1 -1
- package/components/stepper/stepper.js +3 -4
- package/components/stepper/stepper.js.map +1 -1
- package/components/tabs/tab-dom.js +1 -1
- package/components/tabs/tab-dom.js.map +1 -1
- package/components/tabs/tab.js +4 -5
- package/components/tabs/tab.js.map +1 -1
- package/components/tabs/tabs.js +3 -4
- package/components/tabs/tabs.js.map +1 -1
- package/components/textarea/textarea.js +4 -3
- package/components/textarea/textarea.js.map +1 -1
- package/components/textarea/themes/shared/textarea.bootstrap.css.js +1 -1
- package/components/textarea/themes/shared/textarea.bootstrap.css.js.map +1 -1
- package/components/tile-manager/themes/tile-manager.base.css.js +1 -1
- package/components/tile-manager/themes/tile-manager.base.css.js.map +1 -1
- package/components/tile-manager/tile-manager.js +4 -3
- package/components/tile-manager/tile-manager.js.map +1 -1
- package/components/tile-manager/tile.js +3 -4
- package/components/tile-manager/tile.js.map +1 -1
- package/components/toast/toast.js +3 -4
- package/components/toast/toast.js.map +1 -1
- package/components/tooltip/controller.js +4 -4
- package/components/tooltip/controller.js.map +1 -1
- package/components/tooltip/tooltip.js +3 -4
- package/components/tooltip/tooltip.js.map +1 -1
- package/components/tree/tree-item.js +3 -4
- package/components/tree/tree-item.js.map +1 -1
- package/components/tree/tree.js +4 -3
- package/components/tree/tree.js.map +1 -1
- package/components/validation-container/validation-container.js +3 -4
- package/components/validation-container/validation-container.js.map +1 -1
- package/custom-elements.json +2142 -2029
- package/igniteui-webcomponents.css-data.json +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/package.json +24 -2
- package/web-types.json +2 -2
- package/components/list/themes/dark/header/list-header.bootstrap.css.d.ts +0 -1
- package/components/list/themes/dark/header/list-header.bootstrap.css.js +0 -3
- package/components/list/themes/dark/header/list-header.bootstrap.css.js.map +0 -1
- package/components/list/themes/dark/header/list-header.fluent.css.d.ts +0 -1
- package/components/list/themes/dark/header/list-header.fluent.css.js +0 -3
- package/components/list/themes/dark/header/list-header.fluent.css.js.map +0 -1
- package/components/list/themes/dark/header/list-header.indigo.css.d.ts +0 -1
- package/components/list/themes/dark/header/list-header.indigo.css.js +0 -3
- package/components/list/themes/dark/header/list-header.indigo.css.js.map +0 -1
- package/components/list/themes/dark/header/list-header.material.css.d.ts +0 -1
- package/components/list/themes/dark/header/list-header.material.css.js +0 -3
- package/components/list/themes/dark/header/list-header.material.css.js.map +0 -1
- package/components/list/themes/dark/item/list-item.bootstrap.css.d.ts +0 -1
- package/components/list/themes/dark/item/list-item.bootstrap.css.js +0 -3
- package/components/list/themes/dark/item/list-item.bootstrap.css.js.map +0 -1
- package/components/list/themes/dark/item/list-item.fluent.css.d.ts +0 -1
- package/components/list/themes/dark/item/list-item.fluent.css.js +0 -3
- package/components/list/themes/dark/item/list-item.fluent.css.js.map +0 -1
- package/components/list/themes/dark/item/list-item.indigo.css.d.ts +0 -1
- package/components/list/themes/dark/item/list-item.indigo.css.js +0 -3
- package/components/list/themes/dark/item/list-item.indigo.css.js.map +0 -1
- package/components/list/themes/dark/item/list-item.material.css.d.ts +0 -1
- package/components/list/themes/dark/item/list-item.material.css.js +0 -3
- package/components/list/themes/dark/item/list-item.material.css.js.map +0 -1
- package/components/list/themes/light/header/list-header.bootstrap.css.d.ts +0 -1
- package/components/list/themes/light/header/list-header.bootstrap.css.js +0 -3
- package/components/list/themes/light/header/list-header.bootstrap.css.js.map +0 -1
- package/components/list/themes/light/header/list-header.fluent.css.d.ts +0 -1
- package/components/list/themes/light/header/list-header.fluent.css.js +0 -3
- package/components/list/themes/light/header/list-header.fluent.css.js.map +0 -1
- package/components/list/themes/light/header/list-header.indigo.css.d.ts +0 -1
- package/components/list/themes/light/header/list-header.indigo.css.js +0 -3
- package/components/list/themes/light/header/list-header.indigo.css.js.map +0 -1
- package/components/list/themes/light/header/list-header.material.css.d.ts +0 -1
- package/components/list/themes/light/header/list-header.material.css.js +0 -3
- package/components/list/themes/light/header/list-header.material.css.js.map +0 -1
- package/components/list/themes/light/item/list-item.bootstrap.css.d.ts +0 -1
- package/components/list/themes/light/item/list-item.bootstrap.css.js +0 -3
- package/components/list/themes/light/item/list-item.bootstrap.css.js.map +0 -1
- package/components/list/themes/light/item/list-item.fluent.css.d.ts +0 -1
- package/components/list/themes/light/item/list-item.fluent.css.js +0 -3
- package/components/list/themes/light/item/list-item.fluent.css.js.map +0 -1
- package/components/list/themes/light/item/list-item.indigo.css.d.ts +0 -1
- package/components/list/themes/light/item/list-item.indigo.css.js +0 -3
- package/components/list/themes/light/item/list-item.indigo.css.js.map +0 -1
- package/components/list/themes/light/item/list-item.material.css.d.ts +0 -1
- package/components/list/themes/light/item/list-item.material.css.js +0 -3
- package/components/list/themes/light/item/list-item.material.css.js.map +0 -1
|
@@ -17,14 +17,16 @@ import { chatContext, chatUserInputContext } from '../common/context.js';
|
|
|
17
17
|
import { enterKey } from '../common/controllers/key-bindings.js';
|
|
18
18
|
import { registerComponent } from '../common/definitions/register.js';
|
|
19
19
|
import { partMap } from '../common/part-map.js';
|
|
20
|
-
import { bindIf, hasFiles, isEmpty } from '../common/util.js';
|
|
20
|
+
import { bindIf, hasFiles, isEmpty, trimmedHtml } from '../common/util.js';
|
|
21
21
|
import IgcIconComponent from '../icon/icon.js';
|
|
22
22
|
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
26
|
import { getChatAcceptedFiles, getIconName } from './utils.js';
|
|
27
|
-
class IgcChatInputComponent extends LitElement {
|
|
27
|
+
export default class IgcChatInputComponent extends LitElement {
|
|
28
|
+
static { this.tagName = 'igc-chat-input'; }
|
|
29
|
+
static { this.styles = [styles, shared]; }
|
|
28
30
|
static register() {
|
|
29
31
|
registerComponent(IgcChatInputComponent, IgcTextareaComponent, IgcIconButtonComponent, IgcChipComponent, IgcIconComponent);
|
|
30
32
|
}
|
|
@@ -33,30 +35,51 @@ class IgcChatInputComponent extends LitElement {
|
|
|
33
35
|
}
|
|
34
36
|
constructor() {
|
|
35
37
|
super();
|
|
36
|
-
this._parts = { 'input-container': true, dragging: false };
|
|
37
38
|
this._defaults = Object.freeze({
|
|
38
|
-
input: () => this._renderTextArea(),
|
|
39
|
-
inputActions: () => this.renderActionsArea(),
|
|
40
|
-
inputAttachments: (ctx) => this.renderAttachmentsArea(ctx.param),
|
|
41
39
|
fileUploadButton: () => this._renderFileUploadButton(),
|
|
40
|
+
input: () => this._renderTextArea(),
|
|
41
|
+
inputActions: () => this._renderActionsArea(),
|
|
42
|
+
inputActionsEnd: () => nothing,
|
|
43
|
+
inputActionsStart: () => nothing,
|
|
44
|
+
inputAttachments: (ctx) => this._renderAttachmentsArea(ctx.attachments),
|
|
42
45
|
sendButton: () => this._renderSendButton(),
|
|
43
46
|
});
|
|
47
|
+
this._parts = { 'input-container': true, dragging: false };
|
|
44
48
|
addThemingController(this, all);
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
this._state.textArea = this._textInputElement;
|
|
50
|
+
focusInput() {
|
|
51
|
+
this._textInputElement.focus();
|
|
49
52
|
}
|
|
50
53
|
_getRenderer(name) {
|
|
51
54
|
return this._state.options?.renderers
|
|
52
|
-
? (this._state.options.renderers[name] ??
|
|
55
|
+
? (this._state.options.renderers[name] ??
|
|
56
|
+
this._defaults[name])
|
|
53
57
|
: this._defaults[name];
|
|
54
58
|
}
|
|
59
|
+
async _sendMessage() {
|
|
60
|
+
if (!this._userInputState.hasInputValue &&
|
|
61
|
+
!this._userInputState.hasInputAttachments) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._userInputState.addMessageWithEvent({
|
|
65
|
+
text: this._userInputState.inputValue,
|
|
66
|
+
attachments: this._userInputState.inputAttachments,
|
|
67
|
+
});
|
|
68
|
+
this.style.height = 'auto';
|
|
69
|
+
await this._userInputState.host.updateComplete;
|
|
70
|
+
this.focusInput();
|
|
71
|
+
}
|
|
72
|
+
_handleAttachmentRemoved(attachment) {
|
|
73
|
+
const current = this._userInputState.inputAttachments;
|
|
74
|
+
if (this._state.emitAttachmentRemoved(attachment)) {
|
|
75
|
+
this._state.inputAttachments = current.toSpliced(current.indexOf(attachment), 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
55
78
|
_handleKeydown(event) {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
79
|
+
const isSendRequest = event.key.toLowerCase() === enterKey.toLowerCase() && !event.shiftKey;
|
|
80
|
+
if (isSendRequest) {
|
|
58
81
|
event.preventDefault();
|
|
59
|
-
this.
|
|
82
|
+
this._sendMessage();
|
|
60
83
|
}
|
|
61
84
|
else {
|
|
62
85
|
this._state.handleKeyDown(event);
|
|
@@ -98,29 +121,28 @@ class IgcChatInputComponent extends LitElement {
|
|
|
98
121
|
this._parts = { 'input-container': true, dragging: false };
|
|
99
122
|
const validFiles = getChatAcceptedFiles(event, this._acceptedTypes);
|
|
100
123
|
this._state.emitEvent('igcAttachmentDrop');
|
|
101
|
-
this._state.
|
|
124
|
+
this._state.attachFilesWithEvent(validFiles);
|
|
102
125
|
this.requestUpdate();
|
|
103
126
|
}
|
|
104
127
|
_handleInput({ detail }) {
|
|
105
|
-
if (detail === this._state.inputValue)
|
|
106
|
-
return;
|
|
107
128
|
this._state.inputValue = detail;
|
|
108
129
|
this._state.emitEvent('igcInputChange', { detail: { value: detail } });
|
|
109
130
|
}
|
|
110
131
|
_handleFileUpload(event) {
|
|
111
132
|
const input = event.target;
|
|
112
133
|
if (hasFiles(input)) {
|
|
113
|
-
this._state.
|
|
134
|
+
this._state.attachFilesWithEvent(Array.from(input.files));
|
|
114
135
|
}
|
|
115
136
|
}
|
|
116
|
-
|
|
117
|
-
return html `${attachments?.map((attachment
|
|
137
|
+
_renderAttachmentsArea(attachments) {
|
|
138
|
+
return html `${attachments?.map((attachment) => html `
|
|
118
139
|
<div part="attachment-wrapper" role="listitem">
|
|
119
140
|
<igc-chip
|
|
120
141
|
removable
|
|
121
|
-
@igcRemove=${() => this.
|
|
142
|
+
@igcRemove=${() => this._handleAttachmentRemoved(attachment)}
|
|
122
143
|
>
|
|
123
144
|
<igc-icon
|
|
145
|
+
part="attachment-icon"
|
|
124
146
|
slot="prefix"
|
|
125
147
|
name=${getIconName(attachment.file?.type ?? attachment.type)}
|
|
126
148
|
></igc-icon>
|
|
@@ -133,6 +155,7 @@ class IgcChatInputComponent extends LitElement {
|
|
|
133
155
|
return html `
|
|
134
156
|
<igc-textarea
|
|
135
157
|
part="text-input"
|
|
158
|
+
aria-label="Chat text input"
|
|
136
159
|
placeholder=${ifDefined(this._state.options?.inputPlaceholder)}
|
|
137
160
|
resize="auto"
|
|
138
161
|
rows="1"
|
|
@@ -150,8 +173,9 @@ class IgcChatInputComponent extends LitElement {
|
|
|
150
173
|
return html `${cache(attachmentsDisabled
|
|
151
174
|
? nothing
|
|
152
175
|
: html `
|
|
153
|
-
<label for="input_attachments" part="upload
|
|
176
|
+
<label for="input_attachments" part="file-upload">
|
|
154
177
|
<igc-icon-button
|
|
178
|
+
aria-label="Attach files"
|
|
155
179
|
variant="flat"
|
|
156
180
|
name="attach_file"
|
|
157
181
|
@click=${this._handleFileInputClick}
|
|
@@ -159,7 +183,9 @@ class IgcChatInputComponent extends LitElement {
|
|
|
159
183
|
<input
|
|
160
184
|
type="file"
|
|
161
185
|
id="input_attachments"
|
|
186
|
+
tabindex="-1"
|
|
162
187
|
name="input_attachments"
|
|
188
|
+
aria-label="Upload button"
|
|
163
189
|
multiple
|
|
164
190
|
accept=${bindIf(accepted, accepted)}
|
|
165
191
|
@change=${this._handleFileUpload}
|
|
@@ -176,26 +202,31 @@ class IgcChatInputComponent extends LitElement {
|
|
|
176
202
|
variant="contained"
|
|
177
203
|
part="send-button"
|
|
178
204
|
?disabled=${!enabled}
|
|
179
|
-
@click=${this.
|
|
205
|
+
@click=${this._sendMessage}
|
|
180
206
|
></igc-icon-button>
|
|
181
207
|
`;
|
|
182
208
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
209
|
+
_renderActionsArea() {
|
|
210
|
+
const ctx = { instance: this._state.host };
|
|
211
|
+
return trimmedHtml `
|
|
212
|
+
<div part="file-upload-container">
|
|
213
|
+
${this._getRenderer('fileUploadButton')(ctx)}
|
|
214
|
+
</div>
|
|
215
|
+
<div part="input-actions-start">
|
|
216
|
+
${this._getRenderer('inputActionsStart')(ctx)}
|
|
217
|
+
</div>
|
|
218
|
+
<div part="send-button-container">${this._getRenderer('sendButton')(ctx)}</div>
|
|
219
|
+
<div part="input-actions-end">
|
|
220
|
+
${this._getRenderer('inputActionsEnd')(ctx)}
|
|
221
|
+
</div>
|
|
222
|
+
`;
|
|
194
223
|
}
|
|
195
224
|
render() {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
const ctx = { instance: this._state.host };
|
|
226
|
+
const inputCtx = {
|
|
227
|
+
...ctx,
|
|
228
|
+
attachments: this._state.inputAttachments,
|
|
229
|
+
value: this._state.inputValue,
|
|
199
230
|
};
|
|
200
231
|
return html `
|
|
201
232
|
<div
|
|
@@ -205,34 +236,25 @@ class IgcChatInputComponent extends LitElement {
|
|
|
205
236
|
@dragleave=${this._handleDragLeave}
|
|
206
237
|
@drop=${this._handleDrop}
|
|
207
238
|
>
|
|
208
|
-
${this._state.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}))}
|
|
215
|
-
</div>`
|
|
239
|
+
${this._state.hasInputAttachments
|
|
240
|
+
? html `
|
|
241
|
+
<div part="attachments" role="list" aria-label="Attachments">
|
|
242
|
+
${until(this._getRenderer('inputAttachments')(inputCtx))}
|
|
243
|
+
</div>
|
|
244
|
+
`
|
|
216
245
|
: nothing}
|
|
246
|
+
|
|
217
247
|
<div part="input-wrapper">
|
|
218
|
-
${until(this._getRenderer('input')(
|
|
219
|
-
...partialCtx,
|
|
220
|
-
param: this._state.inputValue,
|
|
221
|
-
}))}
|
|
248
|
+
${until(this._getRenderer('input')(inputCtx))}
|
|
222
249
|
</div>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
param: undefined,
|
|
227
|
-
}))}
|
|
250
|
+
|
|
251
|
+
<div part="actions-container">
|
|
252
|
+
${until(this._getRenderer('inputActions')(ctx))}
|
|
228
253
|
</div>
|
|
229
254
|
</div>
|
|
230
255
|
`;
|
|
231
256
|
}
|
|
232
257
|
}
|
|
233
|
-
IgcChatInputComponent.tagName = 'igc-chat-input';
|
|
234
|
-
IgcChatInputComponent.styles = [styles, shared];
|
|
235
|
-
export default IgcChatInputComponent;
|
|
236
258
|
__decorate([
|
|
237
259
|
consume({ context: chatContext, subscribe: true })
|
|
238
260
|
], IgcChatInputComponent.prototype, "_state", 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,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC9D,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,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,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E,IAAI,CAAC,MAAM,CAAC,gBAAgB;aACpC,CAAC,CACH;mBACI;YACT,CAAC,CAAC,OAAO;;YAEP,KAAK,CACL,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACzB,GAAG,UAAU;YACb,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;SAC9B,CAAC,CACH;;;YAGC,KAAK,CACL,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;YAChC,GAAG,UAAU;YACb,KAAK,EAAE,SAAS;SACjB,CAAC,CACH;;;KAGN,CAAC;IACJ,CAAC;;AA1SsB,6BAAO,GAAG,gBAAgB,AAAnB,CAAoB;AAC3B,4BAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,AAAnB,CAAoB;eAF9B,qBAAqB;AAgBvB;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 } from '../common/controllers/key-bindings.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, hasFiles, isEmpty } 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 { ChatTemplateRenderer, IgcMessageAttachment } from './types.js';\nimport { getChatAcceptedFiles, getIconName } from './utils.js';\n\ntype DefaultInputRenderers = {\n input: ChatTemplateRenderer<string>;\n inputActions: ChatTemplateRenderer<void>;\n inputAttachments: ChatTemplateRenderer<IgcMessageAttachment[]>;\n fileUploadButton: ChatTemplateRenderer<void>;\n sendButton: ChatTemplateRenderer<void>;\n};\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 buttons-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 @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 private readonly _defaults: Readonly<DefaultInputRenderers> = Object.freeze({\n input: () => this._renderTextArea(),\n inputActions: () => this.renderActionsArea(),\n inputAttachments: (ctx) => this.renderAttachmentsArea(ctx.param),\n fileUploadButton: () => this._renderFileUploadButton(),\n sendButton: () => this._renderSendButton(),\n });\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected override firstUpdated() {\n this._state.updateAcceptedTypesCache();\n this._state.textArea = this._textInputElement;\n }\n\n private _getRenderer(\n name: keyof DefaultInputRenderers\n ): ChatTemplateRenderer<any> {\n return this._state.options?.renderers\n ? (this._state.options.renderers[name] ?? this._defaults[name])\n : this._defaults[name];\n }\n\n private _handleKeydown(event: KeyboardEvent): void {\n const isSend = event.key === enterKey && !event.shiftKey;\n\n if (isSend) {\n event.preventDefault();\n this._state.sendMessage();\n } else {\n // TODO:\n this._state.handleKeyDown(event);\n }\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.attachFiles(validFiles);\n this.requestUpdate();\n }\n\n /**\n * Handles input text changes.\n * Updates internal inputValue and emits 'igcInputChange' event.\n * @param e Input event from the text area\n */\n private _handleInput({ detail }: CustomEvent<string>): void {\n if (detail === this._state.inputValue) return;\n\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.attachFiles(Array.from(input.files!));\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: IgcMessageAttachment[]) {\n return html`${attachments?.map(\n (attachment, index) => html`\n <div part=\"attachment-wrapper\" role=\"listitem\">\n <igc-chip\n removable\n @igcRemove=${() => this._state.removeAttachment(index)}\n >\n <igc-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 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 /**\n * Default file upload button template used when no custom template is provided.\n * Renders a file input for attaching files.\n * @returns TemplateResult containing the file upload button\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=\"upload-button\">\n <igc-icon-button\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 name=\"input_attachments\"\n multiple\n accept=${bindIf(accepted, accepted)}\n @change=${this._handleFileUpload}\n />\n </label>\n `\n )}`;\n }\n\n /**\n * Default send button template used when no custom template is provided.\n * Renders a send button that submits the current input value and attachments.\n * @returns TemplateResult containing the send button\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._state.sendMessage}\n ></igc-icon-button>\n `;\n }\n\n private renderActionsArea() {\n return html` ${this._getRenderer('fileUploadButton')({\n param: undefined,\n defaults: this._defaults,\n options: this._state.options,\n })}\n ${this._getRenderer('sendButton')({\n param: undefined,\n defaults: this._defaults,\n options: this._state.options,\n })}`;\n }\n\n protected override render() {\n const partialCtx = {\n defaults: this._defaults,\n options: this._state.options,\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.inputAttachments &&\n this._state.inputAttachments.length > 0\n ? html` <div part=\"attachments\" role=\"list\" aria-label=\"Attachments\">\n ${until(\n this._getRenderer('inputAttachments')({\n ...partialCtx,\n param: this._state.inputAttachments,\n })\n )}\n </div>`\n : nothing}\n <div part=\"input-wrapper\">\n ${until(\n this._getRenderer('input')({\n ...partialCtx,\n param: this._state.inputValue,\n })\n )}\n </div>\n <div part=\"buttons-container\">\n ${until(\n this._getRenderer('inputActions')({\n ...partialCtx,\n param: undefined,\n })\n )}\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,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,MAAM,uCAAuC,CAAC;AACjE,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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CAAC,CAAC,QAAQ,CAAC,CAAC;;;;YAI3C,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;;;KAGpD,CAAC;IACJ,CAAC;;AAlSgB;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 } 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 { 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 @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 /** @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 _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 const isSendRequest =\n event.key.toLowerCase() === enterKey.toLowerCase() && !event.shiftKey;\n\n if (isSendRequest) {\n event.preventDefault();\n this._sendMessage();\n } else {\n // TODO:\n this._state.handleKeyDown(event);\n }\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 * 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,11 +1,10 @@
|
|
|
1
|
-
import { LitElement
|
|
2
|
-
import type {
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { IgcChatMessage } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* A chat message component for displaying individual messages in `<igc-chat>`.
|
|
5
5
|
*
|
|
6
6
|
* @element igc-chat-message
|
|
7
7
|
*
|
|
8
|
-
* @fires igcMessageReact - Fired when a message is reacted to.
|
|
9
8
|
*
|
|
10
9
|
* This component renders a single chat message including:
|
|
11
10
|
* - Message text (sanitized)
|
|
@@ -22,38 +21,24 @@ export default class IgcChatMessageComponent extends LitElement {
|
|
|
22
21
|
static readonly tagName = "igc-chat-message";
|
|
23
22
|
static styles: import("lit").CSSResult[];
|
|
24
23
|
static register(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Injected chat state context. Provides message data, user info, and options.
|
|
27
|
-
*/
|
|
28
|
-
private readonly _state;
|
|
29
24
|
private readonly _defaults;
|
|
25
|
+
private readonly _state;
|
|
30
26
|
/**
|
|
31
27
|
* The chat message to render.
|
|
32
28
|
*/
|
|
33
|
-
message
|
|
29
|
+
message: IgcChatMessage;
|
|
34
30
|
constructor();
|
|
35
31
|
protected firstUpdated(): void;
|
|
36
32
|
private _getRenderer;
|
|
33
|
+
private _handleCopy;
|
|
37
34
|
private _handleMessageActionClick;
|
|
38
35
|
private _renderHeader;
|
|
39
36
|
private _renderContent;
|
|
40
37
|
private _renderActions;
|
|
41
38
|
private _renderActionButton;
|
|
42
39
|
private _renderAttachments;
|
|
43
|
-
/**
|
|
44
|
-
* Default message template used when no custom template is provided.
|
|
45
|
-
* Renders the message text, sanitized for security.
|
|
46
|
-
* @param message The chat message to render
|
|
47
|
-
* @returns TemplateResult containing the rendered message
|
|
48
|
-
*/
|
|
49
40
|
private _renderMessage;
|
|
50
|
-
|
|
51
|
-
* Renders the chat message template.
|
|
52
|
-
* - Applies 'sent' CSS class if the message sender matches current user.
|
|
53
|
-
* - Uses markdown rendering if configured.
|
|
54
|
-
* - Renders attachments and custom templates if provided.
|
|
55
|
-
*/
|
|
56
|
-
protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
41
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
57
42
|
}
|
|
58
43
|
declare global {
|
|
59
44
|
interface HTMLElementTagNameMap {
|