@progress/kendo-react-conversational-ui 7.2.4-develop.3 → 7.3.0-develop.1
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/ViewItem.js +8 -0
- package/ViewItem.mjs +59 -0
- package/ai-prompt/AIPrompt.js +8 -0
- package/ai-prompt/AIPrompt.mjs +35 -0
- package/ai-prompt/AIPromptContent.js +8 -0
- package/ai-prompt/AIPromptContent.mjs +17 -0
- package/ai-prompt/AIPromptContext.js +8 -0
- package/ai-prompt/AIPromptContext.mjs +15 -0
- package/ai-prompt/AIPromptExpander.js +8 -0
- package/ai-prompt/AIPromptExpander.mjs +27 -0
- package/ai-prompt/AIPromptFooter.js +8 -0
- package/ai-prompt/AIPromptFooter.mjs +16 -0
- package/ai-prompt/AIPromptHeader.js +8 -0
- package/ai-prompt/AIPromptHeader.mjs +36 -0
- package/ai-prompt/views/AIPromptCommandsView.js +8 -0
- package/ai-prompt/views/AIPromptCommandsView.mjs +38 -0
- package/ai-prompt/views/AIPromptOutputView.js +8 -0
- package/ai-prompt/views/AIPromptOutputView.mjs +93 -0
- package/ai-prompt/views/AIPromptView.js +8 -0
- package/ai-prompt/views/AIPromptView.mjs +61 -0
- package/ai-prompt/views/AIPromptViewRender.js +8 -0
- package/ai-prompt/views/AIPromptViewRender.mjs +16 -0
- package/components/Action.js +8 -0
- package/components/Action.mjs +44 -0
- package/components/ActionGroup.js +8 -0
- package/components/ActionGroup.mjs +49 -0
- package/components/Attachment.js +8 -0
- package/components/Attachment.mjs +49 -0
- package/components/AttachmentGroup.js +8 -0
- package/components/AttachmentGroup.mjs +74 -0
- package/components/Chat.js +8 -0
- package/components/Chat.mjs +208 -0
- package/components/ChatMessage.js +8 -0
- package/components/ChatMessage.mjs +62 -0
- package/components/DateMarker.js +8 -0
- package/components/DateMarker.mjs +20 -0
- package/components/MessageGroup.js +8 -0
- package/components/MessageGroup.mjs +69 -0
- package/components/NewMessage.js +8 -0
- package/components/NewMessage.mjs +94 -0
- package/components/Toolbar.js +8 -0
- package/components/Toolbar.mjs +17 -0
- package/components/base/FocusableUponSelection.js +8 -0
- package/components/base/FocusableUponSelection.mjs +20 -0
- package/components/base/SelectableItemsContainer.js +8 -0
- package/components/base/SelectableItemsContainer.mjs +42 -0
- package/components/templates/HeroCard.js +8 -0
- package/components/templates/HeroCard.mjs +45 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +8 -5
- package/index.d.mts +811 -5
- package/index.d.ts +811 -23
- package/index.js +8 -5
- package/index.mjs +32 -876
- package/messages/index.js +8 -0
- package/messages/index.mjs +25 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +6 -6
- package/utils.js +8 -0
- package/utils.mjs +12 -0
- package/ChatPropsAndState.d.ts +0 -95
- package/Events.d.ts +0 -42
- package/ViewItem.d.ts +0 -61
- package/ai-prompt/AIPrompt.d.ts +0 -95
- package/ai-prompt/AIPromptContent.d.ts +0 -19
- package/ai-prompt/AIPromptContext.d.ts +0 -24
- package/ai-prompt/AIPromptExpander.d.ts +0 -10
- package/ai-prompt/AIPromptFooter.d.ts +0 -19
- package/ai-prompt/AIPromptHeader.d.ts +0 -36
- package/ai-prompt/views/AIPromptCommandsView.d.ts +0 -54
- package/ai-prompt/views/AIPromptOutputView.d.ts +0 -66
- package/ai-prompt/views/AIPromptView.d.ts +0 -26
- package/ai-prompt/views/AIPromptViewRender.d.ts +0 -23
- package/api/action.interface.d.ts +0 -35
- package/api/attachment.interface.d.ts +0 -36
- package/api/message.interface.d.ts +0 -60
- package/api/user.interface.d.ts +0 -27
- package/components/Action.d.ts +0 -23
- package/components/ActionGroup.d.ts +0 -27
- package/components/Attachment.d.ts +0 -28
- package/components/AttachmentGroup.d.ts +0 -27
- package/components/Chat.d.ts +0 -76
- package/components/ChatMessage.d.ts +0 -72
- package/components/DateMarker.d.ts +0 -18
- package/components/MessageGroup.d.ts +0 -29
- package/components/NewMessage.d.ts +0 -38
- package/components/Toolbar.d.ts +0 -13
- package/components/base/FocusableUponSelection.d.ts +0 -24
- package/components/base/SelectableItemsContainer.d.ts +0 -37
- package/components/templates/HeroCard.d.ts +0 -45
- package/messages/index.d.ts +0 -39
- package/package-metadata.d.ts +0 -9
- package/utils.d.ts +0 -9
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as s from "react";
|
|
10
|
+
import { classNames as r } from "@progress/kendo-react-common";
|
|
11
|
+
import n from "./Action.mjs";
|
|
12
|
+
import { SelectableItemsContainer as i } from "./base/SelectableItemsContainer.mjs";
|
|
13
|
+
class l extends i {
|
|
14
|
+
constructor(e) {
|
|
15
|
+
super(e);
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
const e = this.props.group.actions ? this.props.group.actions.length - 1 : 0;
|
|
19
|
+
return /* @__PURE__ */ s.createElement(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
className: this.getClassNames(),
|
|
23
|
+
onClick: this.onRequestContainerSelection,
|
|
24
|
+
onKeyDown: this.onKeyDown
|
|
25
|
+
},
|
|
26
|
+
this.props.group.actions && this.props.group.actions.map(
|
|
27
|
+
(o, t) => /* @__PURE__ */ s.createElement(
|
|
28
|
+
n,
|
|
29
|
+
{
|
|
30
|
+
item: o,
|
|
31
|
+
onActionExecute: this.props.onActionExecute,
|
|
32
|
+
selected: t === this.state.selectedItemIndex,
|
|
33
|
+
isFirstItemInGroup: t === 0,
|
|
34
|
+
isLastItemInGroup: t === e,
|
|
35
|
+
key: t
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
getClassNames() {
|
|
42
|
+
return r(
|
|
43
|
+
"k-quick-replies"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
l as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";const n=require("react"),a=require("@progress/kendo-react-common"),l=require("./base/FocusableUponSelection.js");function o(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(s,i,r.get?r:{enumerable:!0,get:()=>t[i]})}}return s.default=t,Object.freeze(s)}const e=o(n);class c extends l.FocusableUponSelection{render(){return e.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:s=>this.elementToFocus=s},this.props.template?e.createElement(this.props.template,{item:this.props.item}):e.createElement("div",{className:"k-card"},e.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView(),this.getContentView())))}getTabIndexValue(){if(this.props.tabbable!==void 0)return this.props.tabbable?0:-1}getClassNames(){return a.classNames({"k-selected":this.props.selected},{"k-focus":this.props.selected},{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup})}getTitleView(){return this.props.item.title?e.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?e.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return this.props.item.contentType.indexOf("image/")===0?e.createElement("img",{src:this.props.item.content}):this.props.item.content}}module.exports=c;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import { classNames as s } from "@progress/kendo-react-common";
|
|
11
|
+
import { FocusableUponSelection as i } from "./base/FocusableUponSelection.mjs";
|
|
12
|
+
class p extends i {
|
|
13
|
+
render() {
|
|
14
|
+
return /* @__PURE__ */ e.createElement(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: this.getClassNames(),
|
|
18
|
+
tabIndex: this.getTabIndexValue(),
|
|
19
|
+
onClick: this.props.onClick,
|
|
20
|
+
ref: (t) => this.elementToFocus = t
|
|
21
|
+
},
|
|
22
|
+
this.props.template ? /* @__PURE__ */ e.createElement(this.props.template, { item: this.props.item }) : /* @__PURE__ */ e.createElement("div", { className: "k-card" }, /* @__PURE__ */ e.createElement("div", { className: "k-card-body" }, this.getTitleView(), this.getSubtitleView(), this.getContentView()))
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
getTabIndexValue() {
|
|
26
|
+
if (this.props.tabbable !== void 0)
|
|
27
|
+
return this.props.tabbable ? 0 : -1;
|
|
28
|
+
}
|
|
29
|
+
getClassNames() {
|
|
30
|
+
return s(
|
|
31
|
+
{ "k-selected": this.props.selected },
|
|
32
|
+
{ "k-focus": this.props.selected },
|
|
33
|
+
{ "k-first": this.props.isFirstItemInGroup },
|
|
34
|
+
{ "k-last": this.props.isLastItemInGroup }
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
getTitleView() {
|
|
38
|
+
return this.props.item.title ? /* @__PURE__ */ e.createElement("h5", { className: "k-card-title" }, this.props.item.title) : null;
|
|
39
|
+
}
|
|
40
|
+
getSubtitleView() {
|
|
41
|
+
return this.props.item.subtitle ? /* @__PURE__ */ e.createElement("h6", { className: "k-card-subtitle" }, this.props.item.subtitle) : null;
|
|
42
|
+
}
|
|
43
|
+
getContentView() {
|
|
44
|
+
return this.props.item.contentType.indexOf("image/") === 0 ? /* @__PURE__ */ e.createElement("img", { src: this.props.item.content }) : this.props.item.content;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
p as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";const c=require("react"),l=require("@progress/kendo-react-common"),a=require("@progress/kendo-svg-icons"),u=require("./Attachment.js"),h=require("./base/SelectableItemsContainer.js"),i=require("@progress/kendo-react-buttons");function m(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>s[e]})}}return t.default=s,Object.freeze(t)}const o=m(c);class p extends h.SelectableItemsContainer{render(){const t=this.isCardDeckLayout(this.props),e=o.createElement("div",{className:this.getClassNames(),onKeyDown:t?void 0:this.onKeyDown},this.props.group.attachments.map((r,n)=>o.createElement(u,{item:r,template:this.props.itemTemplate,selected:n===this.state.selectedItemIndex,tabbable:this.props.isLastGroup&&n===this.state.selectedItemIndex,isFirstItemInGroup:n===0,isLastItemInGroup:n===this.getLastItemIndex(),onClick:()=>this.onAttachmentClick(n),key:n})));return t?o.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:this.onKeyDown},this.getLeftScrollBtn(),e,this.getRightScrollBtn()):e}get isKeyboardNavigationLeftRight(){return this.isCardDeckLayout(this.props)}getLastItemIndex(){return this.props.group.attachments.length-1}getLeftScrollBtn(){let t=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex&&(t=o.createElement(i.Button,{icon:"chevron-left",onClick:()=>this.onNavigateBtnClick(!1),svgIcon:a.chevronLeftIcon})),t}getRightScrollBtn(){let t=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex!==this.getLastItemIndex()&&(t=o.createElement(i.Button,{icon:"chevron-right",onClick:()=>this.onNavigateBtnClick(!0),svgIcon:a.chevronRightIcon})),t}onAttachmentClick(t){this.onRequestContainerSelection(),this.setState({selectedItemIndex:t})}onNavigateBtnClick(t){this.onRequestContainerSelection(),this.navigate(t,1)}isCardDeckLayout(t){return t.group.attachmentLayout!=="list"}getClassNames(){return l.classNames({"k-card-list":this.props.group.attachmentLayout,"k-card-deck":this.isCardDeckLayout(this.props)})}}module.exports=p;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as s from "react";
|
|
10
|
+
import { classNames as a } from "@progress/kendo-react-common";
|
|
11
|
+
import { chevronLeftIcon as n, chevronRightIcon as c } from "@progress/kendo-svg-icons";
|
|
12
|
+
import l from "./Attachment.mjs";
|
|
13
|
+
import { SelectableItemsContainer as h } from "./base/SelectableItemsContainer.mjs";
|
|
14
|
+
import { Button as i } from "@progress/kendo-react-buttons";
|
|
15
|
+
class k extends h {
|
|
16
|
+
render() {
|
|
17
|
+
const t = this.isCardDeckLayout(this.props), o = /* @__PURE__ */ s.createElement(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
className: this.getClassNames(),
|
|
21
|
+
onKeyDown: t ? void 0 : this.onKeyDown
|
|
22
|
+
},
|
|
23
|
+
this.props.group.attachments.map((r, e) => /* @__PURE__ */ s.createElement(
|
|
24
|
+
l,
|
|
25
|
+
{
|
|
26
|
+
item: r,
|
|
27
|
+
template: this.props.itemTemplate,
|
|
28
|
+
selected: e === this.state.selectedItemIndex,
|
|
29
|
+
tabbable: this.props.isLastGroup && e === this.state.selectedItemIndex,
|
|
30
|
+
isFirstItemInGroup: e === 0,
|
|
31
|
+
isLastItemInGroup: e === this.getLastItemIndex(),
|
|
32
|
+
onClick: () => this.onAttachmentClick(e),
|
|
33
|
+
key: e
|
|
34
|
+
}
|
|
35
|
+
))
|
|
36
|
+
);
|
|
37
|
+
return t ? /* @__PURE__ */ s.createElement("div", { className: "k-card-deck-scrollwrap", onKeyDown: this.onKeyDown }, this.getLeftScrollBtn(), o, this.getRightScrollBtn()) : o;
|
|
38
|
+
}
|
|
39
|
+
// Overriding the default navigation.
|
|
40
|
+
get isKeyboardNavigationLeftRight() {
|
|
41
|
+
return this.isCardDeckLayout(this.props);
|
|
42
|
+
}
|
|
43
|
+
getLastItemIndex() {
|
|
44
|
+
return this.props.group.attachments.length - 1;
|
|
45
|
+
}
|
|
46
|
+
getLeftScrollBtn() {
|
|
47
|
+
let t = null;
|
|
48
|
+
return this.isCardDeckLayout(this.props) && this.state.selectedItemIndex && (t = /* @__PURE__ */ s.createElement(i, { icon: "chevron-left", onClick: () => this.onNavigateBtnClick(!1), svgIcon: n })), t;
|
|
49
|
+
}
|
|
50
|
+
getRightScrollBtn() {
|
|
51
|
+
let t = null;
|
|
52
|
+
return this.isCardDeckLayout(this.props) && this.state.selectedItemIndex !== this.getLastItemIndex() && (t = /* @__PURE__ */ s.createElement(i, { icon: "chevron-right", onClick: () => this.onNavigateBtnClick(!0), svgIcon: c })), t;
|
|
53
|
+
}
|
|
54
|
+
onAttachmentClick(t) {
|
|
55
|
+
this.onRequestContainerSelection(), this.setState({ selectedItemIndex: t });
|
|
56
|
+
}
|
|
57
|
+
onNavigateBtnClick(t) {
|
|
58
|
+
this.onRequestContainerSelection(), this.navigate(t, 1);
|
|
59
|
+
}
|
|
60
|
+
isCardDeckLayout(t) {
|
|
61
|
+
return t.group.attachmentLayout !== "list";
|
|
62
|
+
}
|
|
63
|
+
getClassNames() {
|
|
64
|
+
return a(
|
|
65
|
+
{
|
|
66
|
+
"k-card-list": this.props.group.attachmentLayout,
|
|
67
|
+
"k-card-deck": this.isCardDeckLayout(this.props)
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
k as default
|
|
74
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@progress/kendo-react-common"),o=require("prop-types"),p=require("react"),u=require("../ViewItem.js"),m=require("./ActionGroup.js"),d=require("./AttachmentGroup.js"),g=require("./DateMarker.js"),I=require("./MessageGroup.js"),f=require("./NewMessage.js"),T=require("./ChatMessage.js"),w=require("../package-metadata.js"),c=require("../messages/index.js"),y=require("@progress/kendo-react-intl");function S(a){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>a[e]})}}return s.default=a,Object.freeze(s)}const i=S(p),l=class l extends i.Component{constructor(s){super(s),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.onFocus=()=>{clearTimeout(this.timeoutIdForChatLosingFocus)},this.onBlur=()=>{this.timeoutIdForChatLosingFocus=window.setTimeout(()=>{this.setState({selectedItemIndex:null})},0)},this.onSelectionRequested=e=>{this.setState({selectedItemIndex:e})},this.onKeyDown=e=>{let t=null,r=this.state.selectedItemIndex!==null?this.state.selectedItemIndex:this.viewItems.lastSelectionIndex;e.keyCode===n.Keys.up?r===null?t=0:r>0&&(t=r-1):e.keyCode===n.Keys.down&&(r===null?t=0:r<this.viewItems.lastSelectionIndex&&(t=r+1)),t!==null&&(this.setState({selectedItemIndex:t}),e.preventDefault())},this.onMessageSend=(e,t)=>{n.dispatchEvent(this.props.onMessageSend,t,this,{message:e})},this.onActionExecute=(e,t)=>{if(n.dispatchEvent(this.props.onActionExecute,t,this,{action:e}),!t.isDefaultPrevented()){switch(e.type){case"reply":this.onMessageSend({author:this.props.user,text:e.value,timestamp:new Date},t);break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value);break}this.newMsgComp.focusInput()}},n.validatePackage(w.packageMetadata),this.state={selectedItemIndex:null,isFirstRender:!0}}render(){this.viewItems=this.getViewItemsFromMsgs(this.props.messages),this.isDirectionRightToLeft=this.checkIsDirectionRightToLeft(this.props);const s=y.provideLocalizationService(this);return i.createElement("div",{style:{width:this.props.width},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>this.chatWrapperEl=e},i.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":s.toLanguageString(c.ariaLabelMessageList,c.messages[c.ariaLabelMessageList]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>this.viewItemsWrapperEl=e},i.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),i.createElement(f,{user:this.props.user,onMessageSend:this.onMessageSend,isDirectionRightToLeft:this.isDirectionRightToLeft,ref:e=>this.newMsgComp=e,placeholder:this.props.placeholder,MessageBox:this.props.messageBox,toolbar:this.props.toolbar,onToolbarActionButtonClick:this.props.onToolbarActionExecute,showToolbar:this.props.showToolbar}))}componentDidMount(){this.setState({isFirstRender:!1},()=>{this.nextTickId=window.setTimeout(()=>this.scrollViewItemsToBottom(),250)})}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidUpdate(s){s.messages.length!==this.props.messages.length&&this.scrollToBottomOnLoadingData&&this.scrollViewItemsToBottom()}getClassNames(){return n.classNames("k-chat",this.props.className,{"k-rtl":this.isDirectionRightToLeft})}checkIsDirectionRightToLeft(s){return!!(s.dir!==void 0?s.dir==="rtl":this.chatWrapperEl&&getComputedStyle(this.chatWrapperEl).direction==="rtl")}renderViewItems(){const s=this.viewItems.length-1;return this.viewItems.map((e,t)=>{if(e.type==="date-marker")return i.createElement(g,{item:e,key:t});if(e.type==="message-group")return i.createElement(I,{group:e,itemTemplate:this.props.messageTemplate,attachmentTemplate:this.props.attachmentTemplate,user:this.props.user,selectedItemIndex:this.state.selectedItemIndex,onRequestSelection:this.onSelectionRequested,isLastGroup:t===s,key:t,message:this.props.message||l.defaultProps.message});if(e.type==="attachment-group")return i.createElement(d,{group:e,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:e.selectionIndex===this.state.selectedItemIndex,isLastGroup:t===s,key:t});if(e.type==="action-group")return i.createElement(m,{group:e,onActionExecute:this.onActionExecute,onRequestSelection:this.onSelectionRequested,selected:e.selectionIndex===this.state.selectedItemIndex,isLastGroup:t===s,key:t})})}scrollViewItemsToBottom(){this.viewItemsWrapperEl&&(this.viewItemsWrapperEl.scrollTop=this.viewItemsWrapperEl.scrollHeight-this.viewItemsWrapperEl.clientHeight)}getViewItemsFromMsgs(s){return s.length>0?u.convertMsgsToViewItems(s):[]}};l.propTypes={messages:o.arrayOf(o.object),user:o.object,messageTemplate:o.any,attachmentTemplate:o.any,width:o.oneOfType([o.string,o.number]),onMessageSend:o.func,onActionExecute:o.func,dir:o.string,messageBox:o.any},l.defaultProps={messages:[],dateFormat:"g",message:T.ChatMessage};let h=l;exports.Chat=h;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { Keys as n, dispatchEvent as l, validatePackage as p, classNames as h } from "@progress/kendo-react-common";
|
|
10
|
+
import o from "prop-types";
|
|
11
|
+
import * as i from "react";
|
|
12
|
+
import { convertMsgsToViewItems as u } from "../ViewItem.mjs";
|
|
13
|
+
import d from "./ActionGroup.mjs";
|
|
14
|
+
import g from "./AttachmentGroup.mjs";
|
|
15
|
+
import f from "./DateMarker.mjs";
|
|
16
|
+
import I from "./MessageGroup.mjs";
|
|
17
|
+
import T from "./NewMessage.mjs";
|
|
18
|
+
import { ChatMessage as w } from "./ChatMessage.mjs";
|
|
19
|
+
import { packageMetadata as S } from "../package-metadata.mjs";
|
|
20
|
+
import { ariaLabelMessageList as c, messages as x } from "../messages/index.mjs";
|
|
21
|
+
import { provideLocalizationService as y } from "@progress/kendo-react-intl";
|
|
22
|
+
const a = class a extends i.Component {
|
|
23
|
+
constructor(s) {
|
|
24
|
+
super(s), this.viewItems = [], this.isDirectionRightToLeft = !1, this.scrollToBottomOnLoadingData = !0, this.onFocus = () => {
|
|
25
|
+
clearTimeout(this.timeoutIdForChatLosingFocus);
|
|
26
|
+
}, this.onBlur = () => {
|
|
27
|
+
this.timeoutIdForChatLosingFocus = window.setTimeout(() => {
|
|
28
|
+
this.setState({ selectedItemIndex: null });
|
|
29
|
+
}, 0);
|
|
30
|
+
}, this.onSelectionRequested = (e) => {
|
|
31
|
+
this.setState({ selectedItemIndex: e });
|
|
32
|
+
}, this.onKeyDown = (e) => {
|
|
33
|
+
let t = null, r = this.state.selectedItemIndex !== null ? this.state.selectedItemIndex : this.viewItems.lastSelectionIndex;
|
|
34
|
+
e.keyCode === n.up ? r === null ? t = 0 : r > 0 && (t = r - 1) : e.keyCode === n.down && (r === null ? t = 0 : r < this.viewItems.lastSelectionIndex && (t = r + 1)), t !== null && (this.setState({ selectedItemIndex: t }), e.preventDefault());
|
|
35
|
+
}, this.onMessageSend = (e, t) => {
|
|
36
|
+
l(this.props.onMessageSend, t, this, { message: e });
|
|
37
|
+
}, this.onActionExecute = (e, t) => {
|
|
38
|
+
if (l(this.props.onActionExecute, t, this, { action: e }), !t.isDefaultPrevented()) {
|
|
39
|
+
switch (e.type) {
|
|
40
|
+
case "reply":
|
|
41
|
+
this.onMessageSend(
|
|
42
|
+
{
|
|
43
|
+
author: this.props.user,
|
|
44
|
+
text: e.value,
|
|
45
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
46
|
+
},
|
|
47
|
+
t
|
|
48
|
+
);
|
|
49
|
+
break;
|
|
50
|
+
case "call":
|
|
51
|
+
window.open("tel:" + e.value);
|
|
52
|
+
break;
|
|
53
|
+
case "openUrl":
|
|
54
|
+
window.open(e.value);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
this.newMsgComp.focusInput();
|
|
58
|
+
}
|
|
59
|
+
}, p(S), this.state = { selectedItemIndex: null, isFirstRender: !0 };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @hidden
|
|
63
|
+
*/
|
|
64
|
+
render() {
|
|
65
|
+
this.viewItems = this.getViewItemsFromMsgs(this.props.messages), this.isDirectionRightToLeft = this.checkIsDirectionRightToLeft(this.props);
|
|
66
|
+
const s = y(this);
|
|
67
|
+
return /* @__PURE__ */ i.createElement(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
style: { width: this.props.width },
|
|
71
|
+
onKeyDown: this.onKeyDown,
|
|
72
|
+
className: this.getClassNames(),
|
|
73
|
+
ref: (e) => this.chatWrapperEl = e
|
|
74
|
+
},
|
|
75
|
+
/* @__PURE__ */ i.createElement(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: "k-message-list k-avatars",
|
|
79
|
+
onBlur: this.onBlur,
|
|
80
|
+
onFocus: this.onFocus,
|
|
81
|
+
role: "log",
|
|
82
|
+
"aria-label": s.toLanguageString(c, x[c]),
|
|
83
|
+
"aria-live": "polite",
|
|
84
|
+
onScroll: (e) => {
|
|
85
|
+
this.scrollToBottomOnLoadingData = e.currentTarget.scrollTop === e.currentTarget.scrollHeight - e.currentTarget.clientHeight;
|
|
86
|
+
},
|
|
87
|
+
ref: (e) => this.viewItemsWrapperEl = e
|
|
88
|
+
},
|
|
89
|
+
/* @__PURE__ */ i.createElement("div", { className: "k-message-list-content" }, this.renderViewItems())
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ i.createElement(
|
|
92
|
+
T,
|
|
93
|
+
{
|
|
94
|
+
user: this.props.user,
|
|
95
|
+
onMessageSend: this.onMessageSend,
|
|
96
|
+
isDirectionRightToLeft: this.isDirectionRightToLeft,
|
|
97
|
+
ref: (e) => this.newMsgComp = e,
|
|
98
|
+
placeholder: this.props.placeholder,
|
|
99
|
+
MessageBox: this.props.messageBox,
|
|
100
|
+
toolbar: this.props.toolbar,
|
|
101
|
+
onToolbarActionButtonClick: this.props.onToolbarActionExecute,
|
|
102
|
+
showToolbar: this.props.showToolbar
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @hidden
|
|
109
|
+
*/
|
|
110
|
+
componentDidMount() {
|
|
111
|
+
this.setState({ isFirstRender: !1 }, () => {
|
|
112
|
+
this.nextTickId = window.setTimeout(() => this.scrollViewItemsToBottom(), 250);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @hidden
|
|
117
|
+
*/
|
|
118
|
+
componentWillUnmount() {
|
|
119
|
+
clearTimeout(this.nextTickId);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @hidden
|
|
123
|
+
*/
|
|
124
|
+
componentDidUpdate(s) {
|
|
125
|
+
s.messages.length !== this.props.messages.length && this.scrollToBottomOnLoadingData && this.scrollViewItemsToBottom();
|
|
126
|
+
}
|
|
127
|
+
getClassNames() {
|
|
128
|
+
return h(
|
|
129
|
+
"k-chat",
|
|
130
|
+
this.props.className,
|
|
131
|
+
{ "k-rtl": this.isDirectionRightToLeft }
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
checkIsDirectionRightToLeft(s) {
|
|
135
|
+
return !!(s.dir !== void 0 ? s.dir === "rtl" : this.chatWrapperEl && getComputedStyle(this.chatWrapperEl).direction === "rtl");
|
|
136
|
+
}
|
|
137
|
+
renderViewItems() {
|
|
138
|
+
const s = this.viewItems.length - 1;
|
|
139
|
+
return this.viewItems.map((e, t) => {
|
|
140
|
+
if (e.type === "date-marker")
|
|
141
|
+
return /* @__PURE__ */ i.createElement(f, { item: e, key: t });
|
|
142
|
+
if (e.type === "message-group")
|
|
143
|
+
return /* @__PURE__ */ i.createElement(
|
|
144
|
+
I,
|
|
145
|
+
{
|
|
146
|
+
group: e,
|
|
147
|
+
itemTemplate: this.props.messageTemplate,
|
|
148
|
+
attachmentTemplate: this.props.attachmentTemplate,
|
|
149
|
+
user: this.props.user,
|
|
150
|
+
selectedItemIndex: this.state.selectedItemIndex,
|
|
151
|
+
onRequestSelection: this.onSelectionRequested,
|
|
152
|
+
isLastGroup: t === s,
|
|
153
|
+
key: t,
|
|
154
|
+
message: this.props.message || a.defaultProps.message
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
if (e.type === "attachment-group")
|
|
158
|
+
return /* @__PURE__ */ i.createElement(
|
|
159
|
+
g,
|
|
160
|
+
{
|
|
161
|
+
group: e,
|
|
162
|
+
itemTemplate: this.props.attachmentTemplate,
|
|
163
|
+
onRequestSelection: this.onSelectionRequested,
|
|
164
|
+
selected: e.selectionIndex === this.state.selectedItemIndex,
|
|
165
|
+
isLastGroup: t === s,
|
|
166
|
+
key: t
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
if (e.type === "action-group")
|
|
170
|
+
return /* @__PURE__ */ i.createElement(
|
|
171
|
+
d,
|
|
172
|
+
{
|
|
173
|
+
group: e,
|
|
174
|
+
onActionExecute: this.onActionExecute,
|
|
175
|
+
onRequestSelection: this.onSelectionRequested,
|
|
176
|
+
selected: e.selectionIndex === this.state.selectedItemIndex,
|
|
177
|
+
isLastGroup: t === s,
|
|
178
|
+
key: t
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
scrollViewItemsToBottom() {
|
|
184
|
+
this.viewItemsWrapperEl && (this.viewItemsWrapperEl.scrollTop = this.viewItemsWrapperEl.scrollHeight - this.viewItemsWrapperEl.clientHeight);
|
|
185
|
+
}
|
|
186
|
+
getViewItemsFromMsgs(s) {
|
|
187
|
+
return s.length > 0 ? u(s) : [];
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
a.propTypes = {
|
|
191
|
+
messages: o.arrayOf(o.object),
|
|
192
|
+
user: o.object,
|
|
193
|
+
messageTemplate: o.any,
|
|
194
|
+
attachmentTemplate: o.any,
|
|
195
|
+
width: o.oneOfType([o.string, o.number]),
|
|
196
|
+
onMessageSend: o.func,
|
|
197
|
+
onActionExecute: o.func,
|
|
198
|
+
dir: o.string,
|
|
199
|
+
messageBox: o.any
|
|
200
|
+
}, a.defaultProps = {
|
|
201
|
+
messages: [],
|
|
202
|
+
dateFormat: "g",
|
|
203
|
+
message: w
|
|
204
|
+
};
|
|
205
|
+
let m = a;
|
|
206
|
+
export {
|
|
207
|
+
m as Chat
|
|
208
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),p=require("@progress/kendo-react-common"),o=require("@progress/kendo-react-intl"),c=require("./base/FocusableUponSelection.js");function m(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const a=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>s[i]})}}return e.default=s,Object.freeze(e)}const t=m(l),n=class n extends c.FocusableUponSelection{render(){return t.createElement("div",{className:this.getClassNames(),tabIndex:this.props.tabIndex,onClick:()=>this.props.onRequestSelection(this.props.item.selectionIndex),onFocus:()=>this.props.onRequestSelection(this.props.item.selectionIndex),ref:e=>this.elementToFocus=e},this.getTimestampView(),this.getMainView(),this.getStatusView())}getMainView(){return this.props.item.typing?t.createElement("div",{className:"k-chat-bubble"},t.createElement("div",{className:"k-typing-indicator"},t.createElement("span",null),t.createElement("span",null),t.createElement("span",null))):this.props.template?t.createElement(this.props.template,{item:this.props.item}):this.props.item.text?t.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=t.createElement("time",{className:"k-message-time","aria-hidden":!this.props.selected},o.provideIntlService(this).formatDate(this.props.item.timestamp,this.props.dateFormat))),e}getStatusView(){let e=null;return this.props.item.status&&(e=t.createElement("span",{className:"k-message-status"},this.props.item.status)),e}getClassNames(){return p.classNames({"k-only":this.props.isOnlyItemInGroup},{"k-first":this.props.isFirstItemInGroup&&!this.props.isOnlyItemInGroup},{"k-last":this.props.isLastItemInGroup&&!this.props.isOnlyItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected},"k-message")}};n.defaultProps={dateFormat:"g",tabIndex:-1};let r=n;o.registerForIntl(r);exports.ChatMessage=r;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import { classNames as r } from "@progress/kendo-react-common";
|
|
11
|
+
import { provideIntlService as p, registerForIntl as a } from "@progress/kendo-react-intl";
|
|
12
|
+
import { FocusableUponSelection as l } from "./base/FocusableUponSelection.mjs";
|
|
13
|
+
const i = class i extends l {
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
render() {
|
|
18
|
+
return /* @__PURE__ */ e.createElement(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: this.getClassNames(),
|
|
22
|
+
tabIndex: this.props.tabIndex,
|
|
23
|
+
onClick: () => this.props.onRequestSelection(this.props.item.selectionIndex),
|
|
24
|
+
onFocus: () => this.props.onRequestSelection(this.props.item.selectionIndex),
|
|
25
|
+
ref: (t) => this.elementToFocus = t
|
|
26
|
+
},
|
|
27
|
+
this.getTimestampView(),
|
|
28
|
+
this.getMainView(),
|
|
29
|
+
this.getStatusView()
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
getMainView() {
|
|
33
|
+
return this.props.item.typing ? /* @__PURE__ */ e.createElement("div", { className: "k-chat-bubble" }, /* @__PURE__ */ e.createElement("div", { className: "k-typing-indicator" }, /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("span", null), /* @__PURE__ */ e.createElement("span", null))) : this.props.template ? /* @__PURE__ */ e.createElement(this.props.template, { item: this.props.item }) : this.props.item.text ? /* @__PURE__ */ e.createElement("div", { className: "k-chat-bubble" }, this.props.item.text) : null;
|
|
34
|
+
}
|
|
35
|
+
getTimestampView() {
|
|
36
|
+
let t = null;
|
|
37
|
+
return this.props.item.timestamp && (t = /* @__PURE__ */ e.createElement("time", { className: "k-message-time", "aria-hidden": !this.props.selected }, p(this).formatDate(this.props.item.timestamp, this.props.dateFormat))), t;
|
|
38
|
+
}
|
|
39
|
+
getStatusView() {
|
|
40
|
+
let t = null;
|
|
41
|
+
return this.props.item.status && (t = /* @__PURE__ */ e.createElement("span", { className: "k-message-status" }, this.props.item.status)), t;
|
|
42
|
+
}
|
|
43
|
+
getClassNames() {
|
|
44
|
+
return r(
|
|
45
|
+
{ "k-only": this.props.isOnlyItemInGroup },
|
|
46
|
+
{ "k-first": this.props.isFirstItemInGroup && !this.props.isOnlyItemInGroup },
|
|
47
|
+
{ "k-last": this.props.isLastItemInGroup && !this.props.isOnlyItemInGroup },
|
|
48
|
+
{ "k-selected": this.props.selected },
|
|
49
|
+
{ "k-focus": this.props.selected },
|
|
50
|
+
"k-message"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
i.defaultProps = {
|
|
55
|
+
dateFormat: "g",
|
|
56
|
+
tabIndex: -1
|
|
57
|
+
};
|
|
58
|
+
let s = i;
|
|
59
|
+
a(s);
|
|
60
|
+
export {
|
|
61
|
+
s as ChatMessage
|
|
62
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";const o=require("react"),s=require("@progress/kendo-react-intl");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=i(o);class a extends c.Component{render(){const t=this.props.item;return c.createElement("div",{className:"k-timestamp"},s.provideIntlService(this).formatDate(t.timestamp,"D"))}}s.registerForIntl(a);module.exports=a;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import { provideIntlService as r, registerForIntl as s } from "@progress/kendo-react-intl";
|
|
11
|
+
class a extends e.Component {
|
|
12
|
+
render() {
|
|
13
|
+
const t = this.props.item;
|
|
14
|
+
return /* @__PURE__ */ e.createElement("div", { className: "k-timestamp" }, r(this).formatDate(t.timestamp, "D"));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
s(a);
|
|
18
|
+
export {
|
|
19
|
+
a as default
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";const c=require("react"),i=require("@progress/kendo-react-common"),p=require("@progress/kendo-react-layout"),l=require("./Attachment.js"),u=require("../utils.js"),m=require("@progress/kendo-react-intl"),n=require("../messages/index.js");function g(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>r[e]})}}return s.default=r,Object.freeze(s)}const a=g(c);class h extends a.Component{render(){const{avatarUrl:s,avatarAltText:e,name:t}=this.props.group.author,o=m.provideLocalizationService(this);return a.createElement("div",{className:this.getMsgGroupClassNames()},t&&a.createElement("p",{className:"k-author"},t),s&&a.createElement(p.Avatar,{type:"image"},a.createElement("img",{src:s,alt:e!==void 0?e:o.toLanguageString(n.avatarAlt,n.messages[n.avatarAlt])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return i.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":u.isAuthor(this.props.user,this.props.group.messages[0])})}getGroupMessagesView(){const s=this.props.group.messages.length-1;return this.props.group.messages.map((e,t)=>{const o=[a.createElement(this.props.message,{item:e,template:this.props.itemTemplate,selected:e.selectionIndex===this.props.selectedItemIndex,onRequestSelection:this.props.onRequestSelection,tabIndex:t===s&&this.props.isLastGroup?0:-1,isFirstItemInGroup:t===0,isLastItemInGroup:t===s,isOnlyItemInGroup:s===0,key:t})];return e.attachments&&e.attachments.length===1&&o.push(a.createElement(l,{item:e.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${t}`})),o})}}module.exports=h;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as s from "react";
|
|
10
|
+
import { classNames as p } from "@progress/kendo-react-common";
|
|
11
|
+
import { Avatar as m } from "@progress/kendo-react-layout";
|
|
12
|
+
import i from "./Attachment.mjs";
|
|
13
|
+
import { isAuthor as n } from "../utils.mjs";
|
|
14
|
+
import { provideLocalizationService as l } from "@progress/kendo-react-intl";
|
|
15
|
+
import { avatarAlt as o, messages as c } from "../messages/index.mjs";
|
|
16
|
+
class G extends s.Component {
|
|
17
|
+
render() {
|
|
18
|
+
const { avatarUrl: a, avatarAltText: e, name: t } = this.props.group.author, r = l(this);
|
|
19
|
+
return /* @__PURE__ */ s.createElement("div", { className: this.getMsgGroupClassNames() }, t && /* @__PURE__ */ s.createElement("p", { className: "k-author" }, t), a && /* @__PURE__ */ s.createElement(m, { type: "image" }, /* @__PURE__ */ s.createElement(
|
|
20
|
+
"img",
|
|
21
|
+
{
|
|
22
|
+
src: a,
|
|
23
|
+
alt: e !== void 0 ? e : r.toLanguageString(o, c[o])
|
|
24
|
+
}
|
|
25
|
+
)), this.getGroupMessagesView());
|
|
26
|
+
}
|
|
27
|
+
getMsgGroupClassNames() {
|
|
28
|
+
return p(
|
|
29
|
+
"k-message-group",
|
|
30
|
+
{
|
|
31
|
+
"k-no-avatar": !this.props.group.author.avatarUrl,
|
|
32
|
+
"k-alt": n(this.props.user, this.props.group.messages[0])
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
getGroupMessagesView() {
|
|
37
|
+
const a = this.props.group.messages.length - 1;
|
|
38
|
+
return this.props.group.messages.map((e, t) => {
|
|
39
|
+
const r = [/* @__PURE__ */ s.createElement(
|
|
40
|
+
this.props.message,
|
|
41
|
+
{
|
|
42
|
+
item: e,
|
|
43
|
+
template: this.props.itemTemplate,
|
|
44
|
+
selected: e.selectionIndex === this.props.selectedItemIndex,
|
|
45
|
+
onRequestSelection: this.props.onRequestSelection,
|
|
46
|
+
tabIndex: t === a && this.props.isLastGroup ? 0 : -1,
|
|
47
|
+
isFirstItemInGroup: t === 0,
|
|
48
|
+
isLastItemInGroup: t === a,
|
|
49
|
+
isOnlyItemInGroup: a === 0,
|
|
50
|
+
key: t
|
|
51
|
+
}
|
|
52
|
+
)];
|
|
53
|
+
return e.attachments && e.attachments.length === 1 && r.push(
|
|
54
|
+
/* @__PURE__ */ s.createElement(
|
|
55
|
+
i,
|
|
56
|
+
{
|
|
57
|
+
item: e.attachments[0],
|
|
58
|
+
template: this.props.attachmentTemplate,
|
|
59
|
+
selected: !1,
|
|
60
|
+
key: `att-${t}`
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
), r;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
G as default
|
|
69
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";const l=require("@progress/kendo-react-common"),p=require("react"),g=require("./Toolbar.js"),u=require("@progress/kendo-react-buttons"),c=require("@progress/kendo-svg-icons"),m=require("@progress/kendo-react-intl"),n=require("../messages/index.js");function h(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const s in a)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>a[s]})}}return e.default=a,Object.freeze(e)}const t=h(p);class d extends t.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.onInputKeyDown=e=>{e.keyCode===l.Keys.enter&&this.sendMessage(e)},this.sendMessage=e=>{if(this.props.onMessageSend&&this.inputEl!==null){const s=this.inputEl.value;if(s){const o={author:this.props.user,text:s,timestamp:new Date};this.props.onMessageSend(o,e)}}this.inputEl!==null&&(this.inputEl.value=null)}}render(){const e=m.provideLocalizationService(this),s=t.createElement("input",{type:"text",className:this.getClassNames(),placeholder:this.props.placeholder,onKeyDown:this.onInputKeyDown,onFocus:()=>this.setState({focused:!0}),onBlur:()=>this.setState({focused:!1}),ref:i=>this.inputEl=i,"aria-label":e.toLanguageString(n.newMessageMessageInput,n.messages[n.newMessageMessageInput])}),o=t.createElement(u.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:c.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(n.newMessageSendButton,n.messages[n.newMessageSendButton]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),r=t.createElement(u.Button,{fillMode:"flat",themeColor:"base",rounded:null,className:"k-button-toggle",icon:"more-horizontal",svgIcon:c.moreHorizontalIcon,onClick:i=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,i),"aria-label":e.toLanguageString(n.newMessageOptionsButton,n.messages[n.newMessageOptionsButton])});return t.createElement(t.Fragment,null,t.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?t.createElement(this.props.MessageBox,{messageInput:s,sendButton:o,toolbarButton:r}):t.createElement(t.Fragment,null,s,t.createElement("span",{className:"k-input-suffix"},this.props.toolbar&&r,o))),this.props.showToolbar&&t.createElement(g,null,this.props.toolbar))}focusInput(){this.inputEl!==null&&this.inputEl.focus()}getClassNames(){return l.classNames("k-input-inner",{"k-focus":this.state.focused})}}module.exports=d;
|