igniteui-webcomponents 6.3.0-alpha.0 → 6.3.0-beta.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 +27 -0
- package/components/accordion/accordion.js +1 -4
- package/components/accordion/accordion.js.map +1 -1
- package/components/accordion/themes/accordion.base.css.js +1 -1
- package/components/accordion/themes/accordion.base.css.js.map +1 -1
- package/components/banner/themes/banner.base.css.js +1 -1
- package/components/banner/themes/banner.base.css.js.map +1 -1
- package/components/banner/themes/shared/banner.bootstrap.css.js +1 -1
- package/components/banner/themes/shared/banner.bootstrap.css.js.map +1 -1
- package/components/banner/themes/shared/banner.fluent.css.js +1 -1
- package/components/banner/themes/shared/banner.fluent.css.js.map +1 -1
- package/components/banner/themes/shared/banner.indigo.css.js +1 -1
- package/components/banner/themes/shared/banner.indigo.css.js.map +1 -1
- package/components/banner/themes/shared/banner.material.css.js +1 -1
- package/components/banner/themes/shared/banner.material.css.js.map +1 -1
- package/components/button/themes/button/button.base.css.js +1 -1
- package/components/button/themes/button/button.base.css.js.map +1 -1
- package/components/button/themes/button/shared/button.common.css.js +1 -1
- package/components/button/themes/button/shared/button.common.css.js.map +1 -1
- package/components/button/themes/button/shared/button.fluent.css.js +1 -1
- package/components/button/themes/button/shared/button.fluent.css.js.map +1 -1
- package/components/button/themes/button/shared/button.indigo.css.js +1 -1
- package/components/button/themes/button/shared/button.indigo.css.js.map +1 -1
- package/components/button/themes/icon-button/icon-button.base.css.js +1 -1
- package/components/button/themes/icon-button/icon-button.base.css.js.map +1 -1
- package/components/button/themes/icon-button/shared/icon-button.bootstrap.css.js +1 -1
- package/components/button/themes/icon-button/shared/icon-button.bootstrap.css.js.map +1 -1
- package/components/button/themes/icon-button/shared/icon-button.fluent.css.js +1 -1
- package/components/button/themes/icon-button/shared/icon-button.fluent.css.js.map +1 -1
- package/components/button/themes/icon-button/shared/icon-button.indigo.css.js +1 -1
- package/components/button/themes/icon-button/shared/icon-button.indigo.css.js.map +1 -1
- package/components/button/themes/icon-button/shared/icon-button.material.css.js +1 -1
- package/components/button/themes/icon-button/shared/icon-button.material.css.js.map +1 -1
- package/components/button-group/themes/shared/button/button.bootstrap.css.js +1 -1
- package/components/button-group/themes/shared/button/button.bootstrap.css.js.map +1 -1
- package/components/button-group/themes/shared/button/button.common.css.js +1 -1
- package/components/button-group/themes/shared/button/button.common.css.js.map +1 -1
- package/components/button-group/themes/shared/button/button.indigo.css.js +1 -1
- package/components/button-group/themes/shared/button/button.indigo.css.js.map +1 -1
- package/components/calendar/calendar.d.ts +1 -1
- package/components/calendar/days-view/days-view.js +1 -3
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/months-view/months-view.js +1 -3
- package/components/calendar/months-view/months-view.js.map +1 -1
- package/components/calendar/themes/calendar.base.css.js +1 -1
- package/components/calendar/themes/calendar.base.css.js.map +1 -1
- package/components/calendar/themes/days-view.base.css.js +1 -1
- package/components/calendar/themes/days-view.base.css.js.map +1 -1
- package/components/calendar/themes/shared/bootstrap/calendar.bootstrap.css.js +1 -1
- package/components/calendar/themes/shared/bootstrap/calendar.bootstrap.css.js.map +1 -1
- package/components/calendar/themes/shared/bootstrap/days-view.bootstrap.css.js +1 -1
- package/components/calendar/themes/shared/bootstrap/days-view.bootstrap.css.js.map +1 -1
- package/components/calendar/themes/shared/bootstrap/year-month-view.bootstrap.css.js +1 -1
- package/components/calendar/themes/shared/bootstrap/year-month-view.bootstrap.css.js.map +1 -1
- package/components/calendar/themes/shared/fluent/calendar.fluent.css.js +1 -1
- package/components/calendar/themes/shared/fluent/calendar.fluent.css.js.map +1 -1
- package/components/calendar/themes/shared/indigo/calendar.indigo.css.js +1 -1
- package/components/calendar/themes/shared/indigo/calendar.indigo.css.js.map +1 -1
- package/components/calendar/themes/shared/material/calendar.material.css.js +1 -1
- package/components/calendar/themes/shared/material/calendar.material.css.js.map +1 -1
- package/components/calendar/themes/year-month-view.base.css.js +1 -1
- package/components/calendar/themes/year-month-view.base.css.js.map +1 -1
- package/components/calendar/years-view/years-view.js +1 -3
- package/components/calendar/years-view/years-view.js.map +1 -1
- package/components/card/themes/card.actions.base.css.js +1 -1
- package/components/card/themes/card.actions.base.css.js.map +1 -1
- package/components/card/themes/card.content.base.css.js +1 -1
- package/components/card/themes/card.content.base.css.js.map +1 -1
- package/components/card/themes/card.header.base.css.js +1 -1
- package/components/card/themes/card.header.base.css.js.map +1 -1
- package/components/card/themes/shared/actions/card.actions.bootstrap.css.js +1 -1
- package/components/card/themes/shared/actions/card.actions.bootstrap.css.js.map +1 -1
- package/components/card/themes/shared/actions/card.actions.indigo.css.js +1 -1
- package/components/card/themes/shared/actions/card.actions.indigo.css.js.map +1 -1
- package/components/card/themes/shared/container/card.bootstrap.css.js +1 -1
- package/components/card/themes/shared/container/card.bootstrap.css.js.map +1 -1
- package/components/card/themes/shared/container/card.indigo.css.js +1 -1
- package/components/card/themes/shared/container/card.indigo.css.js.map +1 -1
- package/components/card/themes/shared/content/card.content.bootstrap.css.js +1 -1
- package/components/card/themes/shared/content/card.content.bootstrap.css.js.map +1 -1
- package/components/card/themes/shared/header/card.header.fluent.css.js +1 -1
- package/components/card/themes/shared/header/card.header.fluent.css.js.map +1 -1
- package/components/card/themes/shared/header/card.header.indigo.css.js +1 -1
- package/components/card/themes/shared/header/card.header.indigo.css.js.map +1 -1
- package/components/carousel/carousel.js +0 -3
- package/components/carousel/carousel.js.map +1 -1
- package/components/carousel/themes/carousel.base.css.js +1 -1
- package/components/carousel/themes/carousel.base.css.js.map +1 -1
- package/components/carousel/themes/shared/carousel.indigo.css.js +1 -1
- package/components/carousel/themes/shared/carousel.indigo.css.js.map +1 -1
- package/components/chat/chat-input.d.ts +48 -28
- package/components/chat/chat-input.js +184 -199
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat-message.d.ts +22 -17
- package/components/chat/chat-message.js +137 -26
- package/components/chat/chat-message.js.map +1 -1
- package/components/chat/chat-state.d.ts +25 -47
- package/components/chat/chat-state.js +106 -77
- package/components/chat/chat-state.js.map +1 -1
- package/components/chat/chat.d.ts +54 -69
- package/components/chat/chat.js +226 -100
- package/components/chat/chat.js.map +1 -1
- package/components/chat/extras/markdown-renderer.d.ts +23 -0
- package/components/chat/extras/markdown-renderer.js +44 -0
- package/components/chat/extras/markdown-renderer.js.map +1 -0
- package/components/chat/message-attachments.d.ts +23 -12
- package/components/chat/message-attachments.js +87 -83
- package/components/chat/message-attachments.js.map +1 -1
- package/components/chat/themes/attachments.d.ts +2 -0
- package/components/chat/themes/attachments.js +14 -0
- package/components/chat/themes/attachments.js.map +1 -0
- 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/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.fluent.css.js +1 -1
- package/components/chat/themes/light/chat.fluent.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/message.d.ts +2 -0
- package/components/chat/themes/message.js +28 -0
- package/components/chat/themes/message.js.map +1 -0
- package/components/chat/themes/shared/chat-message/chat-message.bootstrap.css.js +3 -0
- package/components/chat/themes/shared/chat-message/chat-message.bootstrap.css.js.map +1 -0
- package/components/chat/themes/shared/chat-message/chat-message.common.css.js +3 -0
- package/components/chat/themes/shared/chat-message/chat-message.common.css.js.map +1 -0
- package/components/chat/themes/shared/chat-message/chat-message.fluent.css.js +3 -0
- package/components/chat/themes/shared/chat-message/chat-message.fluent.css.js.map +1 -0
- package/components/chat/themes/shared/chat-message/chat-message.indigo.css.js +3 -0
- package/components/chat/themes/shared/chat-message/chat-message.indigo.css.js.map +1 -0
- package/components/chat/themes/shared/chat.bootstrap.css.d.ts +1 -0
- package/components/chat/themes/shared/chat.bootstrap.css.js +3 -0
- package/components/chat/themes/shared/chat.bootstrap.css.js.map +1 -0
- package/components/chat/themes/shared/chat.common.css.js +1 -1
- package/components/chat/themes/shared/chat.common.css.js.map +1 -1
- package/components/chat/themes/shared/chat.fluent.css.d.ts +1 -0
- package/components/chat/themes/shared/chat.fluent.css.js +3 -0
- package/components/chat/themes/shared/chat.fluent.css.js.map +1 -0
- package/components/chat/themes/shared/chat.indigo.css.d.ts +1 -0
- package/components/chat/themes/shared/chat.indigo.css.js +3 -0
- package/components/chat/themes/shared/chat.indigo.css.js.map +1 -0
- 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.common.css.js +1 -1
- package/components/chat/themes/shared/input/input.common.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/input/input.material.css.js +1 -1
- package/components/chat/themes/shared/input/input.material.css.js.map +1 -1
- package/components/chat/themes/shared/message-attachments/message-attachments.common.css.d.ts +1 -0
- package/components/chat/themes/shared/message-attachments/message-attachments.common.css.js +3 -0
- package/components/chat/themes/shared/message-attachments/message-attachments.common.css.js.map +1 -0
- package/components/chat/themes/shared/message-attachments/message-attachments.indigo.css.d.ts +1 -0
- package/components/chat/themes/shared/message-attachments/message-attachments.indigo.css.js +3 -0
- package/components/chat/themes/shared/message-attachments/message-attachments.indigo.css.js.map +1 -0
- package/components/chat/themes/themes.js +9 -6
- package/components/chat/themes/themes.js.map +1 -1
- package/components/chat/types.d.ts +32 -85
- package/components/chat/types.js +1 -7
- package/components/chat/types.js.map +1 -1
- package/components/chat/utils.d.ts +16 -0
- package/components/chat/utils.js +86 -0
- package/components/chat/utils.js.map +1 -0
- package/components/checkbox/checkbox-base.d.ts +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.fluent.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.fluent.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.indigo.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.indigo.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.material.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.material.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.bootstrap.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.common.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.common.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.fluent.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.fluent.css.js.map +1 -1
- package/components/checkbox/themes/shared/switch/switch.indigo.css.js +1 -1
- package/components/checkbox/themes/shared/switch/switch.indigo.css.js.map +1 -1
- package/components/chip/themes/chip.base.css.js +1 -1
- package/components/chip/themes/chip.base.css.js.map +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
- package/components/combo/controllers/navigation.js +1 -1
- package/components/combo/controllers/navigation.js.map +1 -1
- package/components/combo/themes/combo-item.base.css.js +1 -1
- package/components/combo/themes/combo-item.base.css.js.map +1 -1
- package/components/combo/themes/combo.base.css.js +1 -1
- package/components/combo/themes/combo.base.css.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/common/context.d.ts +4 -1
- package/components/common/context.js +2 -1
- package/components/common/context.js.map +1 -1
- package/components/common/controllers/key-bindings.js +4 -3
- package/components/common/controllers/key-bindings.js.map +1 -1
- package/components/common/i18n/chat.resources.d.ts +8 -0
- package/components/common/i18n/chat.resources.js +8 -0
- package/components/common/i18n/chat.resources.js.map +1 -0
- package/components/common/util.d.ts +22 -0
- package/components/common/util.js +84 -2
- package/components/common/util.js.map +1 -1
- package/components/date-picker/date-picker.js +2 -2
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-picker/themes/date-picker.base.css.js +1 -1
- package/components/date-picker/themes/date-picker.base.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.bootstrap.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.bootstrap.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.common.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.common.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.fluent.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.fluent.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.indigo.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.indigo.css.js.map +1 -1
- package/components/date-range-picker/date-range-picker.base.css.js +1 -1
- package/components/date-range-picker/date-range-picker.base.css.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +1 -1
- package/components/date-range-picker/date-range-picker.js +0 -1
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.base.css.js +1 -1
- package/components/date-range-picker/predefined-ranges-area.base.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.bootstrap.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.bootstrap.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.common.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.common.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.fluent.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.fluent.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.indigo.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.indigo.css.js.map +1 -1
- package/components/date-time-input/date-time-input.js +1 -1
- package/components/date-time-input/date-time-input.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/dialog/themes/shared/dialog.bootstrap.css.js +1 -1
- package/components/dialog/themes/shared/dialog.bootstrap.css.js.map +1 -1
- package/components/dialog/themes/shared/dialog.common.css.js +1 -1
- package/components/dialog/themes/shared/dialog.common.css.js.map +1 -1
- package/components/dialog/themes/shared/dialog.fluent.css.js +1 -1
- package/components/dialog/themes/shared/dialog.fluent.css.js.map +1 -1
- package/components/dialog/themes/shared/dialog.indigo.css.js +1 -1
- package/components/dialog/themes/shared/dialog.indigo.css.js.map +1 -1
- package/components/dropdown/themes/dropdown-group.base.css.js +1 -1
- package/components/dropdown/themes/dropdown-group.base.css.js.map +1 -1
- package/components/dropdown/themes/dropdown-item.base.css.js +1 -1
- package/components/dropdown/themes/dropdown-item.base.css.js.map +1 -1
- package/components/dropdown/themes/shared/dropdown.indigo.css.js +1 -1
- package/components/dropdown/themes/shared/dropdown.indigo.css.js.map +1 -1
- package/components/dropdown/themes/shared/group/dropdown-group.fluent.css.js +1 -1
- package/components/dropdown/themes/shared/group/dropdown-group.fluent.css.js.map +1 -1
- package/components/dropdown/themes/shared/header/dropdown-header.common.css.js +1 -1
- package/components/dropdown/themes/shared/header/dropdown-header.common.css.js.map +1 -1
- package/components/dropdown/themes/shared/header/dropdown-header.indigo.css.js +1 -1
- package/components/dropdown/themes/shared/header/dropdown-header.indigo.css.js.map +1 -1
- package/components/dropdown/themes/shared/item/dropdown-item.indigo.css.js +1 -1
- package/components/dropdown/themes/shared/item/dropdown-item.indigo.css.js.map +1 -1
- package/components/expansion-panel/expansion-panel.js +0 -1
- package/components/expansion-panel/expansion-panel.js.map +1 -1
- package/components/expansion-panel/themes/expansion-panel.base.css.js +1 -1
- package/components/expansion-panel/themes/expansion-panel.base.css.js.map +1 -1
- package/components/expansion-panel/themes/shared/expansion-panel.indigo.css.js +1 -1
- package/components/expansion-panel/themes/shared/expansion-panel.indigo.css.js.map +1 -1
- package/components/file-input/file-input.d.ts +0 -4
- package/components/file-input/file-input.js +12 -15
- package/components/file-input/file-input.js.map +1 -1
- package/components/file-input/themes/shared/file-input.bootstrap.css.js +1 -1
- package/components/file-input/themes/shared/file-input.bootstrap.css.js.map +1 -1
- package/components/file-input/themes/shared/file-input.material.css.js +1 -1
- package/components/file-input/themes/shared/file-input.material.css.js.map +1 -1
- package/components/icon/icon-references.js +130 -0
- package/components/icon/icon-references.js.map +1 -1
- package/components/icon/internal-icons-lib.js +66 -0
- package/components/icon/internal-icons-lib.js.map +1 -1
- package/components/input/input.d.ts +0 -4
- package/components/input/input.js +9 -11
- 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.common.css.js +1 -1
- package/components/input/themes/shared/input.common.css.js.map +1 -1
- package/components/input/themes/shared/input.fluent.css.js +1 -1
- package/components/input/themes/shared/input.fluent.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/input/themes/shared/input.material.css.js +1 -1
- package/components/input/themes/shared/input.material.css.js.map +1 -1
- package/components/list/themes/dark/container/list.indigo.css.js +1 -1
- package/components/list/themes/dark/container/list.indigo.css.js.map +1 -1
- package/components/list/themes/dark/header/list-header.indigo.css.js +1 -1
- package/components/list/themes/dark/header/list-header.indigo.css.js.map +1 -1
- package/components/list/themes/dark/item/list-item.indigo.css.js +1 -1
- package/components/list/themes/dark/item/list-item.indigo.css.js.map +1 -1
- package/components/list/themes/header.base.css.js +1 -1
- package/components/list/themes/header.base.css.js.map +1 -1
- package/components/list/themes/item.base.css.js +1 -1
- package/components/list/themes/item.base.css.js.map +1 -1
- package/components/list/themes/light/container/list.indigo.css.js +1 -1
- package/components/list/themes/light/container/list.indigo.css.js.map +1 -1
- package/components/list/themes/light/header/list-header.indigo.css.js +1 -1
- package/components/list/themes/light/header/list-header.indigo.css.js.map +1 -1
- package/components/list/themes/light/item/list-item.indigo.css.js +1 -1
- package/components/list/themes/light/item/list-item.indigo.css.js.map +1 -1
- package/components/list/themes/shared/header/list-header.indigo.css.js +1 -1
- package/components/list/themes/shared/header/list-header.indigo.css.js.map +1 -1
- package/components/list/themes/shared/item/list-item.indigo.css.js +1 -1
- package/components/list/themes/shared/item/list-item.indigo.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.bootstrap.css.js +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.bootstrap.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.indigo.css.js +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.indigo.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.material.css.js +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.material.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.bootstrap.css.js +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.bootstrap.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.fluent.css.js +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.fluent.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.indigo.css.js +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.indigo.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.material.css.js +1 -1
- package/components/nav-drawer/themes/shared/header-item/header-item.material.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/item/item.bootstrap.css.js +1 -1
- package/components/nav-drawer/themes/shared/item/item.bootstrap.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/item/item.fluent.css.js +1 -1
- package/components/nav-drawer/themes/shared/item/item.fluent.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/item/item.indigo.css.js +1 -1
- package/components/nav-drawer/themes/shared/item/item.indigo.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/item/item.material.css.js +1 -1
- package/components/nav-drawer/themes/shared/item/item.material.css.js.map +1 -1
- package/components/navbar/themes/navbar.base.css.js +1 -1
- package/components/navbar/themes/navbar.base.css.js.map +1 -1
- package/components/navbar/themes/shared/navbar.bootstrap.css.js +1 -1
- package/components/navbar/themes/shared/navbar.bootstrap.css.js.map +1 -1
- package/components/navbar/themes/shared/navbar.indigo.css.js +1 -1
- package/components/navbar/themes/shared/navbar.indigo.css.js.map +1 -1
- package/components/progress/themes/linear/shared/linear.progress.fluent.css.js +1 -1
- package/components/progress/themes/linear/shared/linear.progress.fluent.css.js.map +1 -1
- package/components/progress/themes/linear/shared/linear.progress.indigo.css.js +1 -1
- package/components/progress/themes/linear/shared/linear.progress.indigo.css.js.map +1 -1
- package/components/radio/themes/shared/radio.bootstrap.css.js +1 -1
- package/components/radio/themes/shared/radio.bootstrap.css.js.map +1 -1
- package/components/radio/themes/shared/radio.fluent.css.js +1 -1
- package/components/radio/themes/shared/radio.fluent.css.js.map +1 -1
- package/components/radio/themes/shared/radio.indigo.css.js +1 -1
- package/components/radio/themes/shared/radio.indigo.css.js.map +1 -1
- package/components/radio/themes/shared/radio.material.css.js +1 -1
- package/components/radio/themes/shared/radio.material.css.js.map +1 -1
- package/components/radio-group/themes/radio-group.base.css.js +1 -1
- package/components/radio-group/themes/radio-group.base.css.js.map +1 -1
- package/components/radio-group/themes/shared/radio-group.bootstrap.css.js +1 -1
- package/components/radio-group/themes/shared/radio-group.bootstrap.css.js.map +1 -1
- package/components/radio-group/themes/shared/radio-group.fluent.css.js +1 -1
- package/components/radio-group/themes/shared/radio-group.fluent.css.js.map +1 -1
- package/components/radio-group/themes/shared/radio-group.indigo.css.js +1 -1
- package/components/radio-group/themes/shared/radio-group.indigo.css.js.map +1 -1
- package/components/radio-group/themes/shared/radio-group.material.css.js +1 -1
- package/components/radio-group/themes/shared/radio-group.material.css.js.map +1 -1
- package/components/rating/rating.js +0 -1
- package/components/rating/rating.js.map +1 -1
- package/components/rating/themes/rating.base.css.js +1 -1
- package/components/rating/themes/rating.base.css.js.map +1 -1
- package/components/rating/themes/shared/rating.indigo.css.js +1 -1
- package/components/rating/themes/shared/rating.indigo.css.js.map +1 -1
- package/components/resize-container/resize-container.d.ts +1 -1
- package/components/select/select.js +0 -1
- package/components/select/select.js.map +1 -1
- package/components/select/themes/dark/select.bootstrap.css.js +1 -1
- package/components/select/themes/dark/select.bootstrap.css.js.map +1 -1
- package/components/select/themes/light/select.bootstrap.css.js +1 -1
- package/components/select/themes/light/select.bootstrap.css.js.map +1 -1
- package/components/select/themes/shared/select.bootstrap.css.js +1 -1
- package/components/select/themes/shared/select.bootstrap.css.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.indigo.css.js +1 -1
- package/components/select/themes/shared/select.indigo.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/components/slider/slider-base.js +0 -1
- package/components/slider/slider-base.js.map +1 -1
- package/components/slider/themes/shared/slider.common.css.js +1 -1
- package/components/slider/themes/shared/slider.common.css.js.map +1 -1
- package/components/slider/themes/slider.base.css.js +1 -1
- package/components/slider/themes/slider.base.css.js.map +1 -1
- package/components/snackbar/themes/shared/snackbar.indigo.css.js +1 -1
- package/components/snackbar/themes/shared/snackbar.indigo.css.js.map +1 -1
- package/components/snackbar/themes/snackbar.base.css.js +1 -1
- package/components/snackbar/themes/snackbar.base.css.js.map +1 -1
- package/components/stepper/step.d.ts +1 -1
- package/components/tabs/tabs.js +0 -1
- package/components/tabs/tabs.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.bootstrap.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.bootstrap.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.fluent.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.fluent.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.indigo.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.indigo.css.js.map +1 -1
- package/components/tabs/themes/shared/tab/tab.material.css.js +1 -1
- package/components/tabs/themes/shared/tab/tab.material.css.js.map +1 -1
- package/components/textarea/textarea.d.ts +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/textarea/themes/shared/textarea.common.css.js +1 -1
- package/components/textarea/themes/shared/textarea.common.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.fluent.css.js +1 -1
- package/components/textarea/themes/shared/textarea.fluent.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.indigo.css.js +1 -1
- package/components/textarea/themes/shared/textarea.indigo.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js.map +1 -1
- package/components/textarea/themes/textarea.base.css.js +1 -1
- package/components/textarea/themes/textarea.base.css.js.map +1 -1
- package/components/tile-manager/resize-state.js +1 -1
- package/components/tile-manager/resize-state.js.map +1 -1
- package/components/toast/themes/shared/toast.bootstrap.css.js +1 -1
- package/components/toast/themes/shared/toast.bootstrap.css.js.map +1 -1
- package/components/toast/themes/shared/toast.common.css.js +1 -1
- package/components/toast/themes/shared/toast.common.css.js.map +1 -1
- package/components/toast/themes/shared/toast.fluent.css.js +1 -1
- package/components/toast/themes/shared/toast.fluent.css.js.map +1 -1
- package/components/toast/themes/toast.base.css.js +1 -1
- package/components/toast/themes/toast.base.css.js.map +1 -1
- package/components/tooltip/themes/tooltip.base.css.js +1 -1
- package/components/tooltip/themes/tooltip.base.css.js.map +1 -1
- package/components/tree/themes/item.base.css.js +1 -1
- package/components/tree/themes/item.base.css.js.map +1 -1
- package/components/tree/themes/shared/item.common.css.js +1 -1
- package/components/tree/themes/shared/item.common.css.js.map +1 -1
- package/components/tree/themes/shared/item.indigo.css.js +1 -1
- package/components/tree/themes/shared/item.indigo.css.js.map +1 -1
- package/components/tree/themes/shared/item.material.css.js +1 -1
- package/components/tree/themes/shared/item.material.css.js.map +1 -1
- package/components/tree/tree.js +3 -1
- package/components/tree/tree.js.map +1 -1
- package/components/tree/tree.navigation.js +3 -3
- package/components/tree/tree.navigation.js.map +1 -1
- package/components/tree/tree.selection.js +6 -2
- package/components/tree/tree.selection.js.map +1 -1
- package/custom-elements.json +18515 -18333
- package/extras/index.d.ts +1 -0
- package/extras/index.js +2 -0
- package/extras/index.js.map +1 -0
- package/igniteui-webcomponents.css-data.json +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +2 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +6 -2
- package/themes/dark/bootstrap.css +1 -1
- package/themes/dark/fluent.css +1 -1
- package/themes/dark/indigo.css +1 -1
- package/themes/dark/material.css +1 -1
- package/themes/light/bootstrap.css +1 -1
- package/themes/light/fluent.css +1 -1
- package/themes/light/indigo.css +1 -1
- package/themes/light/material.css +1 -1
- package/web-types.json +2 -2
- package/components/chat/chat-message-list.d.ts +0 -111
- package/components/chat/chat-message-list.js +0 -178
- package/components/chat/chat-message-list.js.map +0 -1
- package/components/chat/markdown-util.d.ts +0 -2
- package/components/chat/markdown-util.js +0 -22
- package/components/chat/markdown-util.js.map +0 -1
- package/components/chat/themes/message-list.base.css.js +0 -3
- package/components/chat/themes/message-list.base.css.js.map +0 -1
- package/components/chat/themes/shared/chat-message.common.css.js +0 -3
- package/components/chat/themes/shared/chat-message.common.css.js.map +0 -1
- package/components/chat/themes/shared/message-attachments.common.css.js +0 -3
- package/components/chat/themes/shared/message-attachments.common.css.js.map +0 -1
- package/components/chat/themes/shared/message-list.common.css.js +0 -3
- package/components/chat/themes/shared/message-list.common.css.js.map +0 -1
- /package/components/chat/themes/{message-list.base.css.d.ts → shared/chat-message/chat-message.bootstrap.css.d.ts} +0 -0
- /package/components/chat/themes/shared/{chat-message.common.css.d.ts → chat-message/chat-message.common.css.d.ts} +0 -0
- /package/components/chat/themes/shared/{message-attachments.common.css.d.ts → chat-message/chat-message.fluent.css.d.ts} +0 -0
- /package/components/chat/themes/shared/{message-list.common.css.d.ts → chat-message/chat-message.indigo.css.d.ts} +0 -0
|
@@ -1,23 +1,26 @@
|
|
|
1
|
+
import { enterKey } from '../common/controllers/key-bindings.js';
|
|
2
|
+
import { IgcChatResourceStringEN } from '../common/i18n/chat.resources.js';
|
|
3
|
+
import { isEmpty, nanoid } from '../common/util.js';
|
|
4
|
+
import { parseAcceptedFileTypes } from './utils.js';
|
|
1
5
|
export class ChatState {
|
|
2
|
-
get
|
|
3
|
-
return this.
|
|
6
|
+
get acceptedFileTypes() {
|
|
7
|
+
return this._acceptedTypesCache;
|
|
8
|
+
}
|
|
9
|
+
get disableAutoScroll() {
|
|
10
|
+
return this._options?.disableAutoScroll ?? false;
|
|
4
11
|
}
|
|
5
12
|
get messages() {
|
|
6
13
|
return this._messages;
|
|
7
14
|
}
|
|
8
15
|
set messages(value) {
|
|
9
16
|
this._messages = value;
|
|
10
|
-
this._sortedMessages = value.slice().sort((a, b) => {
|
|
11
|
-
return a.timestamp.getTime() - b.timestamp.getTime();
|
|
12
|
-
});
|
|
13
|
-
this._host.requestUpdate();
|
|
14
17
|
}
|
|
15
18
|
get options() {
|
|
16
19
|
return this._options;
|
|
17
20
|
}
|
|
18
21
|
set options(value) {
|
|
19
22
|
this._options = value;
|
|
20
|
-
this.
|
|
23
|
+
this._contextUpdateFn.call(this._host);
|
|
21
24
|
}
|
|
22
25
|
get currentUserId() {
|
|
23
26
|
return this._options?.currentUserId ?? 'user';
|
|
@@ -25,6 +28,9 @@ export class ChatState {
|
|
|
25
28
|
get suggestionsPosition() {
|
|
26
29
|
return this._options?.suggestionsPosition ?? this._suggestionsPosition;
|
|
27
30
|
}
|
|
31
|
+
get stopTypingDelay() {
|
|
32
|
+
return this._options?.stopTypingDelay ?? this._stopTypingDelay;
|
|
33
|
+
}
|
|
28
34
|
get textArea() {
|
|
29
35
|
return this._textArea;
|
|
30
36
|
}
|
|
@@ -36,36 +42,102 @@ export class ChatState {
|
|
|
36
42
|
}
|
|
37
43
|
set inputAttachments(value) {
|
|
38
44
|
this._inputAttachments = value;
|
|
39
|
-
this.
|
|
45
|
+
this._userInputContextUpdateFn.call(this._host);
|
|
40
46
|
}
|
|
41
47
|
get inputValue() {
|
|
42
48
|
return this._inputValue;
|
|
43
49
|
}
|
|
44
50
|
set inputValue(value) {
|
|
45
51
|
this._inputValue = value;
|
|
46
|
-
this.
|
|
52
|
+
this._userInputContextUpdateFn.call(this._host);
|
|
53
|
+
}
|
|
54
|
+
get hasInputValue() {
|
|
55
|
+
return this._inputValue.trim() !== '';
|
|
56
|
+
}
|
|
57
|
+
get hasInputAttachments() {
|
|
58
|
+
return !isEmpty(this._inputAttachments);
|
|
47
59
|
}
|
|
48
|
-
constructor(chat) {
|
|
60
|
+
constructor(chat, contextUpdateFn, userInputContextUpdateFn) {
|
|
49
61
|
this._textArea = null;
|
|
50
62
|
this._messages = [];
|
|
51
|
-
this._sortedMessages = [];
|
|
52
63
|
this._inputAttachments = [];
|
|
53
64
|
this._inputValue = '';
|
|
54
65
|
this._acceptedTypesCache = null;
|
|
55
66
|
this._suggestionsPosition = 'below-messages';
|
|
67
|
+
this._stopTypingDelay = 3000;
|
|
68
|
+
this._isTyping = false;
|
|
69
|
+
this._lastTyped = Date.now();
|
|
70
|
+
this.resourceStrings = IgcChatResourceStringEN;
|
|
71
|
+
this.handleKeyDown = (e) => {
|
|
72
|
+
if (e.key.toLowerCase() === enterKey.toLowerCase() && !e.shiftKey) {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
this.sendMessage();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this._lastTyped = Date.now();
|
|
78
|
+
if (!this._isTyping) {
|
|
79
|
+
this.emitEvent('igcTypingChange', {
|
|
80
|
+
detail: { isTyping: true },
|
|
81
|
+
});
|
|
82
|
+
this._isTyping = true;
|
|
83
|
+
}
|
|
84
|
+
const stopTypingDelay = this.stopTypingDelay;
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
if (this._isTyping &&
|
|
87
|
+
stopTypingDelay &&
|
|
88
|
+
this._lastTyped + stopTypingDelay < Date.now()) {
|
|
89
|
+
this.emitEvent('igcTypingChange', {
|
|
90
|
+
detail: { isTyping: false },
|
|
91
|
+
});
|
|
92
|
+
this._isTyping = false;
|
|
93
|
+
}
|
|
94
|
+
}, stopTypingDelay);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
this.sendMessage = () => {
|
|
98
|
+
if (!this.inputValue.trim() && this.inputAttachments.length === 0)
|
|
99
|
+
return;
|
|
100
|
+
this.addMessage({
|
|
101
|
+
text: this.inputValue,
|
|
102
|
+
attachments: this.inputAttachments,
|
|
103
|
+
});
|
|
104
|
+
this.inputValue = '';
|
|
105
|
+
if (this._textArea) {
|
|
106
|
+
this._textArea.style.height = 'auto';
|
|
107
|
+
}
|
|
108
|
+
this._host.updateComplete.then(() => {
|
|
109
|
+
this._textArea?.focus();
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
this.removeAttachment = (index) => {
|
|
113
|
+
const allowed = this.emitEvent('igcAttachmentChange', {
|
|
114
|
+
detail: this.inputAttachments.filter((_, i) => i !== index),
|
|
115
|
+
cancelable: true,
|
|
116
|
+
});
|
|
117
|
+
if (allowed) {
|
|
118
|
+
this.inputAttachments = this.inputAttachments.filter((_, i) => i !== index);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
this.handleSuggestionClick = (suggestion) => {
|
|
122
|
+
this.addMessage({ text: suggestion });
|
|
123
|
+
if (this.textArea) {
|
|
124
|
+
this.textArea.focus();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
56
127
|
this._host = chat;
|
|
128
|
+
this._contextUpdateFn = contextUpdateFn;
|
|
129
|
+
this._userInputContextUpdateFn = userInputContextUpdateFn;
|
|
130
|
+
}
|
|
131
|
+
isCurrentUserMessage(message) {
|
|
132
|
+
return this.currentUserId === message?.sender;
|
|
57
133
|
}
|
|
58
134
|
emitEvent(name, args) {
|
|
59
135
|
return this._host.emitEvent(name, args);
|
|
60
136
|
}
|
|
61
|
-
handleInputChange(value) {
|
|
62
|
-
this.inputValue = value;
|
|
63
|
-
this.emitEvent('igcInputChange', { detail: { value: this.inputValue } });
|
|
64
|
-
}
|
|
65
137
|
addMessage(message) {
|
|
66
138
|
const newMessage = {
|
|
67
|
-
id: message.id ??
|
|
68
|
-
text: message.text,
|
|
139
|
+
id: message.id ?? nanoid(),
|
|
140
|
+
text: message.text ?? '',
|
|
69
141
|
sender: message.sender ?? this.currentUserId,
|
|
70
142
|
timestamp: message.timestamp ?? new Date(),
|
|
71
143
|
attachments: message.attachments || [],
|
|
@@ -78,26 +150,28 @@ export class ChatState {
|
|
|
78
150
|
if (!this.messages.some((msg) => msg.id === newMessage.id)) {
|
|
79
151
|
this.messages = [...this.messages, newMessage];
|
|
80
152
|
}
|
|
153
|
+
this._host.requestUpdate('messages');
|
|
81
154
|
this.inputValue = '';
|
|
82
155
|
this.inputAttachments = [];
|
|
83
156
|
}
|
|
84
157
|
}
|
|
85
158
|
attachFiles(files) {
|
|
86
159
|
const newAttachments = [];
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
160
|
+
const fileNames = new Set(this.inputAttachments.map((attachment) => attachment.file?.name ?? ''));
|
|
161
|
+
for (const file of files) {
|
|
162
|
+
if (fileNames.has(file.name)) {
|
|
163
|
+
continue;
|
|
91
164
|
}
|
|
92
165
|
const isImage = file.type.startsWith('image/');
|
|
166
|
+
const url = URL.createObjectURL(file);
|
|
93
167
|
newAttachments.push({
|
|
94
|
-
id:
|
|
95
|
-
url
|
|
168
|
+
id: nanoid(),
|
|
169
|
+
url,
|
|
96
170
|
name: file.name,
|
|
97
|
-
file
|
|
98
|
-
thumbnail: isImage ?
|
|
171
|
+
file,
|
|
172
|
+
thumbnail: isImage ? url : undefined,
|
|
99
173
|
});
|
|
100
|
-
}
|
|
174
|
+
}
|
|
101
175
|
const allowed = this.emitEvent('igcAttachmentChange', {
|
|
102
176
|
detail: [...this.inputAttachments, ...newAttachments],
|
|
103
177
|
cancelable: true,
|
|
@@ -106,62 +180,17 @@ export class ChatState {
|
|
|
106
180
|
this.inputAttachments = [...this.inputAttachments, ...newAttachments];
|
|
107
181
|
}
|
|
108
182
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
cancelable: true,
|
|
113
|
-
});
|
|
114
|
-
if (allowed) {
|
|
115
|
-
this.inputAttachments = this.inputAttachments.filter((_, i) => i !== index);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
handleSuggestionClick(suggestion) {
|
|
119
|
-
this.addMessage({ text: suggestion });
|
|
120
|
-
if (this.textArea) {
|
|
121
|
-
this.textArea.focus();
|
|
122
|
-
}
|
|
183
|
+
isImageAttachment(attachment) {
|
|
184
|
+
return (attachment.type === 'image' ||
|
|
185
|
+
!!attachment.file?.type.startsWith('image/'));
|
|
123
186
|
}
|
|
124
187
|
updateOptions(options) {
|
|
125
188
|
this.options = { ...this.options, ...options };
|
|
126
189
|
}
|
|
127
190
|
updateAcceptedTypesCache() {
|
|
128
|
-
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
const types = this.options?.acceptedFiles
|
|
133
|
-
.split(',')
|
|
134
|
-
.map((type) => type.trim().toLowerCase());
|
|
135
|
-
this._acceptedTypesCache = {
|
|
136
|
-
extensions: new Set(types.filter((t) => t.startsWith('.'))),
|
|
137
|
-
mimeTypes: new Set(types.filter((t) => !t.startsWith('.') && !t.endsWith('/*'))),
|
|
138
|
-
wildcardTypes: new Set(types.filter((t) => t.endsWith('/*')).map((t) => t.slice(0, -2))),
|
|
139
|
-
};
|
|
191
|
+
this._acceptedTypesCache = this.options?.acceptedFiles
|
|
192
|
+
? parseAcceptedFileTypes(this.options.acceptedFiles)
|
|
193
|
+
: null;
|
|
140
194
|
}
|
|
141
|
-
isFileTypeAccepted(file, type = '') {
|
|
142
|
-
if (!this._acceptedTypesCache)
|
|
143
|
-
return true;
|
|
144
|
-
if (file === null && type === '')
|
|
145
|
-
return false;
|
|
146
|
-
const fileType = file != null ? file.type.toLowerCase() : type.toLowerCase();
|
|
147
|
-
const fileExtension = file != null
|
|
148
|
-
? `.${file.name.split('.').pop()?.toLowerCase()}`
|
|
149
|
-
: `.${type.split('/').pop()?.toLowerCase()}`;
|
|
150
|
-
if (this._acceptedTypesCache.extensions.has(fileExtension)) {
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
if (this._acceptedTypesCache.mimeTypes.has(fileType)) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
const [fileBaseType] = fileType.split('/');
|
|
157
|
-
return this._acceptedTypesCache.wildcardTypes.has(fileBaseType);
|
|
158
|
-
}
|
|
159
|
-
hasSlotContent(name) {
|
|
160
|
-
return (this._host.renderRoot.querySelector(`slot[name=${name}]`)
|
|
161
|
-
?.childNodes.length !== 0);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
export function createChatState(host) {
|
|
165
|
-
return new ChatState(host);
|
|
166
195
|
}
|
|
167
196
|
//# sourceMappingURL=chat-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-state.js","sourceRoot":"","sources":["../../../src/components/chat/chat-state.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,SAAS;IAgCpB,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/C,CAAC;IAKD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAMD,IAAW,QAAQ,CAAC,KAAmB;QACrC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjD,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IAKD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAA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GD,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAOM,cAAc,CAAC,IAAY;QAChC,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAkB,aAAa,IAAI,GAAG,CAAC;YACxE,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC,CAC5B,CAAC;IACJ,CAAC;CAEF;AAED,MAAM,UAAU,eAAe,CAAC,IAAsB;IACpD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import type IgcTextareaComponent from '../textarea/textarea.js';\nimport type IgcChatComponent from './chat.js';\nimport type { IgcChatComponentEventMap } from './chat.js';\nimport type {\n IgcChatOptions,\n IgcMessage,\n IgcMessageAttachment,\n} from './types.js';\n\n/**\n * Internal state manager for the `<igc-chat>` component.\n *\n * Manages messages, input value, attachments, options, and event emissions.\n */\nexport class ChatState {\n //#region Internal properties and state /** The host `<igc-chat>` component instance */\n private readonly _host: IgcChatComponent;\n /** Reference to the text area input component */\n private _textArea: IgcTextareaComponent | null = null;\n /** The current list of messages */\n private _messages: IgcMessage[] = [];\n /** Sorted copy of messages by timestamp */\n private _sortedMessages: IgcMessage[] = [];\n /** Chat options/configuration */\n private _options?: IgcChatOptions;\n /** List of current input attachments */\n private _inputAttachments: IgcMessageAttachment[] = [];\n /** Current input text */\n private _inputValue = '';\n /**\n * Cache of accepted file types, organized into extensions, mimeTypes, and wildcardTypes\n */\n private _acceptedTypesCache: {\n extensions: Set<string>;\n mimeTypes: Set<string>;\n wildcardTypes: Set<string>;\n } | null = null;\n\n private _suggestionsPosition: 'below-input' | 'below-messages' =\n 'below-messages';\n //#endregion\n\n //#region Public properties\n /**\n * Array of message IDs sorted by timestamp ascending.\n */\n public get sortedMessagesIds(): string[] {\n return this._sortedMessages.map((m) => m.id);\n }\n\n /**\n * Gets the list of chat messages.\n */\n public get messages(): IgcMessage[] {\n return this._messages;\n }\n\n /**\n * Sets the list of chat messages.\n * Also sorts messages by timestamp and requests host update.\n */\n public set messages(value: IgcMessage[]) {\n this._messages = value;\n this._sortedMessages = value.slice().sort((a, b) => {\n return a.timestamp.getTime() - b.timestamp.getTime();\n });\n this._host.requestUpdate();\n }\n\n /**\n * Gets current chat options.\n */\n public get options(): IgcChatOptions | undefined {\n return this._options;\n }\n\n /**\n * Sets chat options and requests host update.\n */\n public set options(value: IgcChatOptions) {\n this._options = value;\n this._host.requestUpdate();\n }\n\n /**\n * Gets the current user ID from options or returns 'user' as fallback.\n */\n public get currentUserId(): string {\n return this._options?.currentUserId ?? 'user';\n }\n\n /**\n * Gets the current suggestionsPosition from options or returns the default value 'below-messages'.\n */\n public get suggestionsPosition(): string {\n return this._options?.suggestionsPosition ?? this._suggestionsPosition;\n }\n /**\n * Gets the text area component.\n */\n public get textArea(): IgcTextareaComponent | null {\n return this._textArea;\n }\n\n /**\n * Sets the text area component.\n */\n public set textArea(value: IgcTextareaComponent) {\n this._textArea = value;\n }\n\n /**\n * Gets the list of attachments currently attached to input.\n */\n public get inputAttachments(): IgcMessageAttachment[] {\n return this._inputAttachments;\n }\n\n /**\n * Sets the input attachments and requests host update.\n */\n public set inputAttachments(value: IgcMessageAttachment[]) {\n this._inputAttachments = value;\n this._host.requestUpdate(); // Notify the host component to re-render\n }\n\n /**\n * Gets the current input value.\n */\n public get inputValue(): string {\n return this._inputValue;\n }\n\n /**\n * Sets the current input value and requests host update.\n */\n public set inputValue(value: string) {\n this._inputValue = value;\n this._host.requestUpdate();\n }\n //#endregion\n\n /**\n * Creates an instance of ChatState.\n * @param chat The host `<igc-chat>` component.\n */\n constructor(chat: IgcChatComponent) {\n this._host = chat;\n }\n\n //#region Event handlers\n\n /**\n * Emits a custom event from the host component.\n * @param name Event name (key of IgcChatComponentEventMap)\n * @param args Event detail or options\n * @returns true if event was not canceled, false otherwise\n */\n public emitEvent(name: keyof IgcChatComponentEventMap, args?: any) {\n return this._host.emitEvent(name, args);\n }\n\n /**\n * Handles input text changes.\n * Updates internal inputValue and emits 'igcInputChange' event.\n * @param value New input value\n */\n public handleInputChange(value: string): void {\n this.inputValue = value;\n this.emitEvent('igcInputChange', { detail: { value: this.inputValue } });\n }\n\n //#endregion\n\n //#region Public API\n\n /**\n * Adds a new chat message.\n * Emits 'igcMessageCreated' event which can be canceled to prevent adding.\n * Clears input value and attachments on success.\n * @param message Partial message object with optional id, sender, timestamp\n */\n public addMessage(message: {\n id?: string;\n text: string;\n sender?: string;\n timestamp?: Date;\n attachments?: IgcMessageAttachment[];\n }): void {\n const newMessage: IgcMessage = {\n id: message.id ?? Date.now().toString(),\n text: message.text,\n sender: message.sender ?? this.currentUserId,\n timestamp: message.timestamp ?? new Date(),\n attachments: message.attachments || [],\n };\n\n const allowed = this.emitEvent('igcMessageCreated', {\n detail: newMessage,\n cancelable: true,\n });\n\n if (allowed) {\n if (!this.messages.some((msg) => msg.id === newMessage.id)) {\n this.messages = [...this.messages, newMessage];\n }\n this.inputValue = '';\n this.inputAttachments = [];\n }\n }\n\n /**\n * Adds files as attachments to the input.\n * Emits 'igcAttachmentChange' event which can be canceled to prevent adding.\n * @param files Array of File objects to attach\n */\n public attachFiles(files: File[]) {\n const newAttachments: IgcMessageAttachment[] = [];\n let count = this.inputAttachments.length;\n files.forEach((file) => {\n if (this.inputAttachments.find((a) => a.name === file.name)) {\n return;\n }\n\n const isImage = file.type.startsWith('image/');\n newAttachments.push({\n id: Date.now().toString() + count++,\n url: URL.createObjectURL(file),\n name: file.name,\n file: file,\n thumbnail: isImage ? URL.createObjectURL(file) : undefined,\n });\n });\n\n const allowed = this.emitEvent('igcAttachmentChange', {\n detail: [...this.inputAttachments, ...newAttachments],\n cancelable: true,\n });\n if (allowed) {\n this.inputAttachments = [...this.inputAttachments, ...newAttachments];\n }\n }\n\n /**\n * Removes an attachment by index.\n * Emits 'igcAttachmentChange' event which can be canceled to prevent removal.\n * @param index Index of the attachment to remove\n */\n public removeAttachment(index: number): void {\n const allowed = this.emitEvent('igcAttachmentChange', {\n detail: this.inputAttachments.filter((_, i) => i !== index),\n cancelable: true,\n });\n if (allowed) {\n this.inputAttachments = this.inputAttachments.filter(\n (_, i) => i !== index\n );\n }\n }\n\n /**\n * Handles when a suggestion is clicked.\n * Adds the suggestion as a new message and focuses the text area.\n * @param suggestion The suggestion string clicked\n */\n public handleSuggestionClick(suggestion: string): void {\n this.addMessage({ text: suggestion });\n if (this.textArea) {\n this.textArea.focus();\n }\n }\n\n /**\n * Updates the chat options partially.\n * @param options Partial options to merge with current options\n */\n public updateOptions(options: Partial<IgcChatOptions>): void {\n this.options = { ...this.options, ...options };\n }\n\n /**\n * Updates the internal cache for accepted file types.\n * Parses the acceptedFiles string option into extensions, mimeTypes, and wildcard types.\n */\n public updateAcceptedTypesCache() {\n if (!this.options?.acceptedFiles) {\n this._acceptedTypesCache = null;\n return;\n }\n\n const types = this.options?.acceptedFiles\n .split(',')\n .map((type) => type.trim().toLowerCase());\n this._acceptedTypesCache = {\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\n /**\n * Checks if a file's type or extension is accepted by the chat's acceptedFiles setting.\n * @param file File object to check\n * @param type Optional MIME type override if no file provided\n * @returns True if accepted, false otherwise\n */\n public isFileTypeAccepted(file: File, type = ''): boolean {\n if (!this._acceptedTypesCache) return true;\n\n if (file === null && type === '') return false;\n\n const fileType =\n file != null ? file.type.toLowerCase() : type.toLowerCase();\n const fileExtension =\n file != null\n ? `.${file.name.split('.').pop()?.toLowerCase()}`\n : `.${type.split('/').pop()?.toLowerCase()}`;\n\n // Check file extension\n if (this._acceptedTypesCache.extensions.has(fileExtension)) {\n return true;\n }\n\n // Check exact MIME type\n if (this._acceptedTypesCache.mimeTypes.has(fileType)) {\n return true;\n }\n\n // Check wildcard MIME types\n const [fileBaseType] = fileType.split('/');\n return this._acceptedTypesCache.wildcardTypes.has(fileBaseType);\n }\n\n /**\n * Checks if a slot is empty.\n * @param name Slot name to check\n * @returns True if the slot has content, false otherwise\n */\n public hasSlotContent(name: string): boolean {\n return (\n this._host.renderRoot.querySelector<HTMLSlotElement>(`slot[name=${name}]`)\n ?.childNodes.length !== 0\n );\n }\n //#endregion\n}\n\nexport function createChatState(host: IgcChatComponent): ChatState {\n return new ChatState(host);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat-state.js","sourceRoot":"","sources":["../../../src/components/chat/chat-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AASpD,OAAO,EAA8B,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAOhF,MAAM,OAAO,SAAS;IAqCpB,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,EAAE,iBAAiB,IAAI,KAAK,CAAC;IACnD,CAAC;IAKD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAKD,IAAW,QAAQ,CAAC,KAAmB;QACrC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAKD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAKD,IAAW,OAAO,CAAC,KAAqB;QACtC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,gBAAgB,CAAC,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AAC,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,cAAc,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAEM,iBAAiB,CAAC,UAAgC;QACvD,OAAO,CACL,UAAU,CAAC,IAAI,KAAK,OAAO;YAC3B,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAC7C,CAAC;IACJ,CAAC;IAkFM,aAAa,CAAC,OAAgC;QACnD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;IACjD,CAAC;IAMM,wBAAwB;QAC7B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa;YACpD,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;YACpD,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;CAGF","sourcesContent":["import { enterKey } from '../common/controllers/key-bindings.js';\nimport { IgcChatResourceStringEN } from '../common/i18n/chat.resources.js';\nimport { isEmpty, nanoid } from '../common/util.js';\nimport type IgcTextareaComponent from '../textarea/textarea.js';\nimport type IgcChatComponent from './chat.js';\nimport type { IgcChatComponentEventMap } from './chat.js';\nimport type {\n IgcChatOptions,\n IgcMessage,\n IgcMessageAttachment,\n} from './types.js';\nimport { type ChatAcceptedFileTypes, parseAcceptedFileTypes } from './utils.js';\n\n/**\n * Internal state manager for the `<igc-chat>` component.\n *\n * Manages messages, input value, attachments, options, and event emissions.\n */\nexport class ChatState {\n //#region Internal properties and state /** The host `<igc-chat>` component instance */\n private readonly _host: IgcChatComponent;\n\n private readonly _contextUpdateFn: () => unknown;\n private readonly _userInputContextUpdateFn: () => unknown;\n\n /** Reference to the text area input component */\n private _textArea: IgcTextareaComponent | null = null;\n /** The current list of messages */\n private _messages: IgcMessage[] = [];\n /** Chat options/configuration */\n private _options?: IgcChatOptions;\n\n /** List of current input attachments */\n private _inputAttachments: IgcMessageAttachment[] = [];\n /** Current input text */\n private _inputValue = '';\n /**\n * Cache of accepted file types, organized into extensions, mimeTypes, and wildcardTypes\n */\n private _acceptedTypesCache: ChatAcceptedFileTypes | null = null;\n /** Default position of the suggestions */\n private _suggestionsPosition: 'below-input' | 'below-messages' =\n 'below-messages';\n /** Default time in milliseconds before dispatching stop typing event */\n private _stopTypingDelay = 3000;\n\n public _isTyping = false;\n private _lastTyped = Date.now();\n\n public resourceStrings = IgcChatResourceStringEN;\n\n //#endregion\n\n //#region Public properties\n\n public get acceptedFileTypes() {\n return this._acceptedTypesCache;\n }\n\n public get disableAutoScroll(): boolean {\n return this._options?.disableAutoScroll ?? false;\n }\n\n /**\n * Gets the list of chat messages.\n */\n public get messages(): IgcMessage[] {\n return this._messages;\n }\n\n /**\n * Sets the list of chat messages.\n */\n public set messages(value: IgcMessage[]) {\n this._messages = value;\n }\n\n /**\n * Gets current chat options.\n */\n public get options(): IgcChatOptions | undefined {\n return this._options;\n }\n\n /**\n * Sets chat options and requests host update.\n */\n public set options(value: IgcChatOptions) {\n this._options = value;\n this._contextUpdateFn.call(this._host);\n }\n\n /**\n * Gets the current user ID from options or returns 'user' as fallback.\n */\n public get currentUserId(): string {\n return this._options?.currentUserId ?? 'user';\n }\n\n /**\n * Gets the current suggestionsPosition from options or returns the default value 'below-messages'.\n */\n public get suggestionsPosition(): string {\n return this._options?.suggestionsPosition ?? this._suggestionsPosition;\n }\n\n /**\n * Gets the current stopTypingDelay from options or returns the default value `3000`.\n */\n public get stopTypingDelay(): number {\n return this._options?.stopTypingDelay ?? this._stopTypingDelay;\n }\n\n /**\n * Gets the text area component.\n */\n public get textArea(): IgcTextareaComponent | null {\n return this._textArea;\n }\n\n /**\n * Sets the text area component.\n */\n public set textArea(value: IgcTextareaComponent) {\n this._textArea = value;\n }\n\n /**\n * Gets the list of attachments currently attached to input.\n */\n public get inputAttachments(): IgcMessageAttachment[] {\n return this._inputAttachments;\n }\n\n /**\n * Sets the input attachments and requests host update.\n */\n public set inputAttachments(value: IgcMessageAttachment[]) {\n this._inputAttachments = value;\n this._userInputContextUpdateFn.call(this._host);\n }\n\n /**\n * Gets the current input value.\n */\n public get inputValue(): string {\n return this._inputValue;\n }\n\n /**\n * Sets the current input value and requests host update.\n */\n public set inputValue(value: string) {\n this._inputValue = value;\n this._userInputContextUpdateFn.call(this._host);\n }\n\n public get hasInputValue(): boolean {\n return this._inputValue.trim() !== '';\n }\n\n public get hasInputAttachments(): boolean {\n return !isEmpty(this._inputAttachments);\n }\n\n //#endregion\n\n constructor(\n chat: IgcChatComponent,\n contextUpdateFn: () => unknown,\n userInputContextUpdateFn: () => unknown\n ) {\n this._host = chat;\n this._contextUpdateFn = contextUpdateFn;\n this._userInputContextUpdateFn = userInputContextUpdateFn;\n }\n\n public isCurrentUserMessage(message?: IgcMessage): boolean {\n return this.currentUserId === message?.sender;\n }\n\n //#region Event handlers\n\n public emitEvent(name: keyof IgcChatComponentEventMap, args?: any): boolean {\n return this._host.emitEvent(name, args);\n }\n\n //#endregion\n\n //#region Public API\n\n /**\n * Adds a new chat message.\n * Emits 'igcMessageCreated' event which can be canceled to prevent adding.\n * Clears input value and attachments on success.\n * @param message Partial message object with optional id, sender, timestamp\n */\n public addMessage(message: Partial<IgcMessage>): void {\n const newMessage: IgcMessage = {\n id: message.id ?? nanoid(),\n text: message.text ?? '',\n sender: message.sender ?? this.currentUserId,\n timestamp: message.timestamp ?? new Date(),\n attachments: message.attachments || [],\n };\n\n const allowed = this.emitEvent('igcMessageCreated', {\n detail: newMessage,\n cancelable: true,\n });\n\n if (allowed) {\n if (!this.messages.some((msg) => msg.id === newMessage.id)) {\n this.messages = [...this.messages, newMessage];\n }\n this._host.requestUpdate('messages');\n\n this.inputValue = '';\n this.inputAttachments = [];\n }\n }\n\n /**\n * Adds files as attachments to the input.\n * Emits 'igcAttachmentChange' event which can be canceled to prevent adding.\n * @param files Array of File objects to attach\n */\n public attachFiles(files: File[]) {\n const newAttachments: IgcMessageAttachment[] = [];\n const fileNames = new Set(\n this.inputAttachments.map((attachment) => attachment.file?.name ?? '')\n );\n\n for (const file of files) {\n if (fileNames.has(file.name)) {\n continue;\n }\n\n const isImage = file.type.startsWith('image/');\n const url = URL.createObjectURL(file);\n\n newAttachments.push({\n id: nanoid(),\n url,\n name: file.name,\n file,\n thumbnail: isImage ? url : undefined,\n });\n }\n\n const allowed = this.emitEvent('igcAttachmentChange', {\n detail: [...this.inputAttachments, ...newAttachments],\n cancelable: true,\n });\n if (allowed) {\n this.inputAttachments = [...this.inputAttachments, ...newAttachments];\n }\n }\n\n public isImageAttachment(attachment: IgcMessageAttachment): boolean {\n return (\n attachment.type === 'image' ||\n !!attachment.file?.type.startsWith('image/')\n );\n }\n\n public handleKeyDown = (e: KeyboardEvent) => {\n if (e.key.toLowerCase() === enterKey.toLowerCase() && !e.shiftKey) {\n e.preventDefault();\n this.sendMessage();\n } else {\n this._lastTyped = Date.now();\n if (!this._isTyping) {\n this.emitEvent('igcTypingChange', {\n detail: { isTyping: true },\n });\n this._isTyping = true;\n }\n\n const stopTypingDelay = this.stopTypingDelay;\n setTimeout(() => {\n if (\n this._isTyping &&\n stopTypingDelay &&\n this._lastTyped + stopTypingDelay < Date.now()\n ) {\n this.emitEvent('igcTypingChange', {\n detail: { isTyping: false },\n });\n this._isTyping = false;\n }\n }, stopTypingDelay);\n }\n };\n\n public sendMessage = () => {\n if (!this.inputValue.trim() && this.inputAttachments.length === 0) return;\n\n this.addMessage({\n text: this.inputValue,\n attachments: this.inputAttachments,\n });\n this.inputValue = '';\n\n if (this._textArea) {\n this._textArea.style.height = 'auto';\n }\n\n this._host.updateComplete.then(() => {\n this._textArea?.focus();\n });\n };\n\n /**\n * Removes an attachment by index.\n * Emits 'igcAttachmentChange' event which can be canceled to prevent removal.\n * @param index Index of the attachment to remove\n */\n public removeAttachment = (index: number): void => {\n const allowed = this.emitEvent('igcAttachmentChange', {\n detail: this.inputAttachments.filter((_, i) => i !== index),\n cancelable: true,\n });\n if (allowed) {\n this.inputAttachments = this.inputAttachments.filter(\n (_, i) => i !== index\n );\n }\n };\n\n /**\n * Handles when a suggestion is clicked.\n * Adds the suggestion as a new message and focuses the text area.\n * @param suggestion The suggestion string clicked\n */\n public handleSuggestionClick = (suggestion: string): void => {\n this.addMessage({ text: suggestion });\n if (this.textArea) {\n this.textArea.focus();\n }\n };\n\n /**\n * Updates the chat options partially.\n * @param options Partial options to merge with current options\n */\n public updateOptions(options: Partial<IgcChatOptions>): void {\n this.options = { ...this.options, ...options };\n }\n\n /**\n * Updates the internal cache for accepted file types.\n * Parses the acceptedFiles string option into extensions, mimeTypes, and wildcard types.\n */\n public updateAcceptedTypesCache(): void {\n this._acceptedTypesCache = this.options?.acceptedFiles\n ? parseAcceptedFileTypes(this.options.acceptedFiles)\n : null;\n }\n\n //#endregion\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement, type
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
2
|
import type { Constructor } from '../common/mixins/constructor.js';
|
|
3
3
|
import type { IgcChatOptions, IgcMessage, IgcMessageAttachment } from './types.js';
|
|
4
4
|
/**
|
|
@@ -7,74 +7,45 @@ import type { IgcChatOptions, IgcMessage, IgcMessageAttachment } from './types.j
|
|
|
7
7
|
export interface IgcChatComponentEventMap {
|
|
8
8
|
/**
|
|
9
9
|
* Dispatched when a new chat message is created (sent).
|
|
10
|
-
*
|
|
11
|
-
* @event igcMessageCreated
|
|
12
|
-
* @type {CustomEvent<IgcMessage>}
|
|
13
|
-
* @detail The message that was created.
|
|
14
10
|
*/
|
|
15
11
|
igcMessageCreated: CustomEvent<IgcMessage>;
|
|
12
|
+
/**
|
|
13
|
+
* Dispatched when a message is reacted to.
|
|
14
|
+
*/
|
|
15
|
+
igcMessageReact: CustomEvent<{
|
|
16
|
+
message: IgcMessage;
|
|
17
|
+
reaction: string;
|
|
18
|
+
}>;
|
|
16
19
|
/**
|
|
17
20
|
* Dispatched when a chat message attachment is clicked.
|
|
18
|
-
*
|
|
19
|
-
* @event igcAttachmentClick
|
|
20
|
-
* @type {CustomEvent<IgcMessageAttachment>}
|
|
21
|
-
* @detail The attachment that was clicked.
|
|
22
21
|
*/
|
|
23
22
|
igcAttachmentClick: CustomEvent<IgcMessageAttachment>;
|
|
24
23
|
/**
|
|
25
24
|
* Dispatched when an attachment is changed (e.g., updated or removed).
|
|
26
|
-
*
|
|
27
|
-
* @event igcAttachmentChange
|
|
28
|
-
* @type {CustomEvent<IgcMessageAttachment>}
|
|
29
|
-
* @detail The attachment that was changed.
|
|
30
25
|
*/
|
|
31
26
|
igcAttachmentChange: CustomEvent<IgcMessageAttachment>;
|
|
32
27
|
/**
|
|
33
28
|
* Dispatched during an attachment drag operation.
|
|
34
|
-
*
|
|
35
|
-
* @event igcAttachmentDrag
|
|
36
|
-
* @type {CustomEvent<any>}
|
|
37
|
-
* @detail The drag event payload.
|
|
38
29
|
*/
|
|
39
|
-
igcAttachmentDrag: CustomEvent<
|
|
30
|
+
igcAttachmentDrag: CustomEvent<void>;
|
|
40
31
|
/**
|
|
41
32
|
* Dispatched when an attachment is dropped (e.g., in a drag-and-drop operation).
|
|
42
|
-
*
|
|
43
|
-
* @event igcAttachmentDrop
|
|
44
|
-
* @type {CustomEvent<any>}
|
|
45
|
-
* @detail The drop event payload.
|
|
46
33
|
*/
|
|
47
|
-
igcAttachmentDrop: CustomEvent<
|
|
34
|
+
igcAttachmentDrop: CustomEvent<void>;
|
|
48
35
|
/**
|
|
49
36
|
* Dispatched when the typing status changes (e.g., user starts or stops typing).
|
|
50
|
-
*
|
|
51
|
-
* @event igcTypingChange
|
|
52
|
-
* @type {CustomEvent<boolean>}
|
|
53
|
-
* @detail `true` if typing started, `false` if stopped.
|
|
54
37
|
*/
|
|
55
38
|
igcTypingChange: CustomEvent<boolean>;
|
|
56
39
|
/**
|
|
57
40
|
* Dispatched when the chat input field gains focus.
|
|
58
|
-
*
|
|
59
|
-
* @event igcInputFocus
|
|
60
|
-
* @type {CustomEvent<any>}
|
|
61
|
-
* @detail Focus event payload.
|
|
62
41
|
*/
|
|
63
|
-
igcInputFocus: CustomEvent<
|
|
42
|
+
igcInputFocus: CustomEvent<void>;
|
|
64
43
|
/**
|
|
65
44
|
* Dispatched when the chat input field loses focus.
|
|
66
|
-
*
|
|
67
|
-
* @event igcInputBlur
|
|
68
|
-
* @type {CustomEvent<any>}
|
|
69
|
-
* @detail Blur event payload.
|
|
70
45
|
*/
|
|
71
|
-
igcInputBlur: CustomEvent<
|
|
46
|
+
igcInputBlur: CustomEvent<void>;
|
|
72
47
|
/**
|
|
73
48
|
* Dispatched when the content of the chat input changes.
|
|
74
|
-
*
|
|
75
|
-
* @event igcInputChange
|
|
76
|
-
* @type {CustomEvent<string>}
|
|
77
|
-
* @detail The current text value of the input.
|
|
78
49
|
*/
|
|
79
50
|
igcInputChange: CustomEvent<string>;
|
|
80
51
|
}
|
|
@@ -82,9 +53,19 @@ declare const IgcChatComponent_base: Constructor<import("../common/mixins/event-
|
|
|
82
53
|
/**
|
|
83
54
|
* A chat UI component for displaying messages, attachments, and input interaction.
|
|
84
55
|
*
|
|
85
|
-
* This component is part of the Ignite UI Web Components suite.
|
|
86
|
-
*
|
|
87
56
|
* @element igc-chat
|
|
57
|
+
*
|
|
58
|
+
* @fires igcMessageCreated - Dispatched when a new chat message is created (sent).
|
|
59
|
+
* @fires igcMessageReact - Dispatched when a message is reacted to.
|
|
60
|
+
* @fires igcAttachmentClick - Dispatched when a chat message attachment is clicked.
|
|
61
|
+
* @fires igcAttachmentChange - Dispatched when a message attachment is changed (e.g., updated or removed).
|
|
62
|
+
* @fires igcAttachmentDrag - Dispatched during an attachment drag operation.
|
|
63
|
+
* @fires igcAttachmentDrop - Dispatched when an attachment is dropped (e.g., in a drag-and-drop operation).
|
|
64
|
+
* @fires igcTypingChange - Dispatched when the typing status changes (e.g., user starts or stops typing).
|
|
65
|
+
* @fires igcInputFocus - Dispatched when the chat input field gains focus.
|
|
66
|
+
* @fires igcInputBlur - Dispatched when the chat input field loses focus.
|
|
67
|
+
* @fires igcInputChange - Dispatched when the content of the chat input changes.
|
|
68
|
+
*
|
|
88
69
|
* @slot prefix - Slot for injecting content (e.g., avatar or icon) before the chat title.
|
|
89
70
|
* @slot title - Slot for overriding the chat title content.
|
|
90
71
|
* @slot actions - Slot for injecting header actions (e.g., buttons, menus).
|
|
@@ -103,19 +84,13 @@ declare const IgcChatComponent_base: Constructor<import("../common/mixins/event-
|
|
|
103
84
|
export default class IgcChatComponent extends IgcChatComponent_base {
|
|
104
85
|
static readonly tagName = "igc-chat";
|
|
105
86
|
static styles: import("lit").CSSResult[];
|
|
106
|
-
/**
|
|
107
|
-
* Registers the chat component and its child components.
|
|
108
|
-
* Should be called once before using the component.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* IgcChatComponent.register();
|
|
112
|
-
*/
|
|
113
87
|
static register(): void;
|
|
114
|
-
private readonly
|
|
115
|
-
private
|
|
116
|
-
private
|
|
117
|
-
private
|
|
118
|
-
|
|
88
|
+
private readonly _state;
|
|
89
|
+
private readonly _slots;
|
|
90
|
+
private readonly _context;
|
|
91
|
+
private readonly _userInputContext;
|
|
92
|
+
private _updateContext;
|
|
93
|
+
private _updateUserInputContext;
|
|
119
94
|
/**
|
|
120
95
|
* The list of chat messages currently displayed.
|
|
121
96
|
* Use this property to set or update the message history.
|
|
@@ -140,24 +115,34 @@ export default class IgcChatComponent extends IgcChatComponent_base {
|
|
|
140
115
|
*/
|
|
141
116
|
set options(value: IgcChatOptions);
|
|
142
117
|
get options(): IgcChatOptions | undefined;
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
get defaultFileUploadButton(): TemplateResult;
|
|
149
|
-
/** Returns the default send message button element. */
|
|
150
|
-
get defaultSendButton(): TemplateResult;
|
|
118
|
+
/**
|
|
119
|
+
* The resource strings of the chat.
|
|
120
|
+
*/
|
|
121
|
+
resourceStrings: import("../common/i18n/chat.resources.js").IgcChatResourceStrings;
|
|
122
|
+
constructor();
|
|
151
123
|
protected contextChanged(): void;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Scrolls the view to a specific message by id.
|
|
126
|
+
* @param messageId - The id of the message to scroll to
|
|
127
|
+
*/
|
|
128
|
+
scrollToMessage(messageId: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Updates the context value to notify all consumers that the chat state has changed.
|
|
131
|
+
* This ensures that components consuming the chat context will re-render.
|
|
132
|
+
*/
|
|
133
|
+
updateContextValue(): void;
|
|
134
|
+
protected updated(properties: PropertyValues<this>): void;
|
|
135
|
+
private _scrollToBottom;
|
|
136
|
+
private _renderHeader;
|
|
137
|
+
private _renderMessages;
|
|
138
|
+
private _renderLoadingTemplate;
|
|
139
|
+
private _renderSuggestionPrefix;
|
|
140
|
+
private _renderSuggestions;
|
|
141
|
+
private _renderEmptyState;
|
|
142
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
157
143
|
}
|
|
158
144
|
declare global {
|
|
159
145
|
interface HTMLElementTagNameMap {
|
|
160
|
-
/** The `<igc-chat>` custom element. */
|
|
161
146
|
'igc-chat': IgcChatComponent;
|
|
162
147
|
}
|
|
163
148
|
}
|