@nyaruka/temba-components 0.129.5 → 0.129.6
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
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.129.6](https://github.com/nyaruka/temba-components/compare/v0.129.5...v0.129.6)
|
|
8
|
+
|
|
9
|
+
- Fix message event to use ID for chatevent [`#650`](https://github.com/nyaruka/temba-components/pull/650)
|
|
10
|
+
|
|
7
11
|
#### [v0.129.5](https://github.com/nyaruka/temba-components/compare/v0.129.3...v0.129.5)
|
|
8
12
|
|
|
13
|
+
> 12 August 2025
|
|
14
|
+
|
|
9
15
|
- Don't trigger ref change on internal values change for Select [`#648`](https://github.com/nyaruka/temba-components/pull/648)
|
|
10
16
|
- Cleanup unused chat event types and remove some unused properties on other types [`#647`](https://github.com/nyaruka/temba-components/pull/647)
|
|
11
17
|
- Nestable form layouts [`#644`](https://github.com/nyaruka/temba-components/pull/644)
|
package/dist/temba-components.js
CHANGED
|
@@ -2924,7 +2924,7 @@ let Ar=rr,Mr=!1;const Tr=["es","fr","pt"],Pr="data:image/png;base64,iVBORw0KGgoA
|
|
|
2924
2924
|
temba-button {
|
|
2925
2925
|
--button-border: 1px solid #ddd;
|
|
2926
2926
|
}
|
|
2927
|
-
`}constructor(){super(),this.contactsEndpoint="/api/v2/contacts.json",this.currentNote="",this.showDetails=!0,this.currentTicket=null,this.currentContact=null,this.agent="",this.blockFetching=!1,this.showInterrupt=!1,this.avatar=Pr,this.ticket=null,this.lastEventTime=null,this.newestEventTime=null,this.refreshId=null,this.polling=!1}firstUpdated(t){super.firstUpdated(t)}connectedCallback(){super.connectedCallback(),this.chat=this.shadowRoot.querySelector("temba-chat")}disconnectedCallback(){super.disconnectedCallback(),this.refreshId&&clearInterval(this.refreshId)}updated(t){super.updated(t),(t.has("data")||t.has("currentContact"))&&(this.refreshId&&(clearTimeout(this.refreshId),this.refreshId=null),this.currentContact=this.data),t.has("currentContact")&&(this.chat=this.shadowRoot.querySelector("temba-chat"),this.reset(),this.fetchPreviousMessages())}reset(){this.chat&&this.chat.reset(),this.blockFetching=!1,this.ticket=null,this.lastEventTime=null,this.newestEventTime=null,this.refreshId=null,this.polling=!1,this.errorMessage=null;const t=this.shadowRoot.querySelector("temba-compose");t&&t.reset()}handleInterrupt(){this.fireCustomEvent(je.Interrupt,{contact:this.currentContact})}handleRetry(){this.shadowRoot.querySelector("temba-compose").triggerSend()}handleSend(t){this.errorMessage=null;const e=t.currentTarget,i=t.detail.langValues.und,n={contact:this.currentContact.uuid},o=i.text;o&&o.length>0&&(n.text=o);const s=i.attachments;if(s&&s.length>0){const t=s.map((t=>t.uuid));n.attachments=t}this.currentTicket&&(n.ticket=this.currentTicket.uuid);const r="Send failed, please try again.";ne("/api/v2/messages.json",n).then((t=>{t.status<400?(this.checkForNewMessages(),e.reset(),this.fireCustomEvent(je.MessageSent,{msg:n})):this.errorMessage=r})).catch((()=>{this.errorMessage=r}))}getEndpoint(){return this.contact?`/contact/history/${this.contact}/?_format=json`:null}scheduleRefresh(){let t=(new Date).getTime()-this.newestEventTime/1e3-5e3;this.refreshId&&(clearTimeout(this.refreshId),this.refreshId=null),t=Math.min(t,15e3),t=Math.max(t,2e3),this.refreshId=setTimeout((()=>{this.checkForNewMessages()}),t)}getEventMessage(t){let e=null;switch(t.type){case Zc.TICKET_OPENED:e={type:Vc.Inline,text:eh(t,"opened")};break;case Zc.TICKET_ASSIGNED:e={type:Vc.Inline,text:ih(t)};break;case Zc.TICKET_REOPENED:e={type:Vc.Inline,text:eh(t,"reopened")};break;case Zc.TICKET_CLOSED:e={type:Vc.Inline,text:eh(t,"closed")};break;case Zc.TICKET_TOPIC_CHANGED:e={type:Vc.Inline,text:`Topic changed to **${t.topic.name}**`};break;case Zc.FLOW_ENTERED:case Zc.FLOW_EXITED:e={type:Vc.Inline,text:Kc(t)};break;case Zc.CONTACT_FIELD_CHANGED:e={type:Vc.Inline,text:Qc(t)};break;case Zc.CONTACT_NAME_CHANGED:e={type:Vc.Inline,text:Jc(t)};break;case Zc.CONTACT_URNS_CHANGED:e={type:Vc.Inline,text:th(t)};break;case Zc.CONTACT_GROUPS_CHANGED:e={type:Vc.Inline,text:nh(t)};break;case Zc.AIRTIME_TRANSFERRED:e={type:Vc.Inline,text:oh(t)};break;case Zc.CALL_STARTED:e={type:Vc.Inline,text:"Call Started"};break;case Zc.CHANNEL_EVENT:e={type:Vc.Inline,text:Xc(t)};break;case Zc.CONTACT_LANGUAGE_CHANGED:e={type:Vc.Inline,text:sh(t)};break;case Zc.OPTIN_REQUESTED:e={type:Vc.Inline,text:rh(t)}}return e&&t.created_on?e.date=new Date(t.created_on):console.error("Unknown event type",t),e}getUserForEvent(t){let e=null;return"msg_received"===t.type?e={name:this.currentContact.name}:t.created_by&&(e={email:t.created_by.email,name:`${t.created_by.first_name} ${t.created_by.last_name}`.trim(),avatar:t.created_by.avatar}),e}createMessages(t){if(t.events){let e=[];return t.events.forEach((t=>{const i=1e3*new Date(t.created_on).getTime();if(i>this.newestEventTime&&(this.newestEventTime=i),"ticket_note_added"===t.type){const i=t;e.push({type:Vc.Note,id:t.created_on+t.type,user:this.getUserForEvent(i),date:new Date(i.created_on),text:i.note})}else if("ticket_opened"===t.type){const i=t;e.push({type:Vc.Note,id:t.created_on+t.type+"_note",user:this.getUserForEvent(i),date:new Date(i.created_on),text:i.note}),e.push(this.getEventMessage(t))}else if("msg_created"===t.type||"msg_received"===t.type||"broadcast_created"===t.type){const i=t;e.push({
|
|
2927
|
+
`}constructor(){super(),this.contactsEndpoint="/api/v2/contacts.json",this.currentNote="",this.showDetails=!0,this.currentTicket=null,this.currentContact=null,this.agent="",this.blockFetching=!1,this.showInterrupt=!1,this.avatar=Pr,this.ticket=null,this.lastEventTime=null,this.newestEventTime=null,this.refreshId=null,this.polling=!1}firstUpdated(t){super.firstUpdated(t)}connectedCallback(){super.connectedCallback(),this.chat=this.shadowRoot.querySelector("temba-chat")}disconnectedCallback(){super.disconnectedCallback(),this.refreshId&&clearInterval(this.refreshId)}updated(t){super.updated(t),(t.has("data")||t.has("currentContact"))&&(this.refreshId&&(clearTimeout(this.refreshId),this.refreshId=null),this.currentContact=this.data),t.has("currentContact")&&(this.chat=this.shadowRoot.querySelector("temba-chat"),this.reset(),this.fetchPreviousMessages())}reset(){this.chat&&this.chat.reset(),this.blockFetching=!1,this.ticket=null,this.lastEventTime=null,this.newestEventTime=null,this.refreshId=null,this.polling=!1,this.errorMessage=null;const t=this.shadowRoot.querySelector("temba-compose");t&&t.reset()}handleInterrupt(){this.fireCustomEvent(je.Interrupt,{contact:this.currentContact})}handleRetry(){this.shadowRoot.querySelector("temba-compose").triggerSend()}handleSend(t){this.errorMessage=null;const e=t.currentTarget,i=t.detail.langValues.und,n={contact:this.currentContact.uuid},o=i.text;o&&o.length>0&&(n.text=o);const s=i.attachments;if(s&&s.length>0){const t=s.map((t=>t.uuid));n.attachments=t}this.currentTicket&&(n.ticket=this.currentTicket.uuid);const r="Send failed, please try again.";ne("/api/v2/messages.json",n).then((t=>{t.status<400?(this.checkForNewMessages(),e.reset(),this.fireCustomEvent(je.MessageSent,{msg:n})):this.errorMessage=r})).catch((()=>{this.errorMessage=r}))}getEndpoint(){return this.contact?`/contact/history/${this.contact}/?_format=json`:null}scheduleRefresh(){let t=(new Date).getTime()-this.newestEventTime/1e3-5e3;this.refreshId&&(clearTimeout(this.refreshId),this.refreshId=null),t=Math.min(t,15e3),t=Math.max(t,2e3),this.refreshId=setTimeout((()=>{this.checkForNewMessages()}),t)}getEventMessage(t){let e=null;switch(t.type){case Zc.TICKET_OPENED:e={type:Vc.Inline,text:eh(t,"opened")};break;case Zc.TICKET_ASSIGNED:e={type:Vc.Inline,text:ih(t)};break;case Zc.TICKET_REOPENED:e={type:Vc.Inline,text:eh(t,"reopened")};break;case Zc.TICKET_CLOSED:e={type:Vc.Inline,text:eh(t,"closed")};break;case Zc.TICKET_TOPIC_CHANGED:e={type:Vc.Inline,text:`Topic changed to **${t.topic.name}**`};break;case Zc.FLOW_ENTERED:case Zc.FLOW_EXITED:e={type:Vc.Inline,text:Kc(t)};break;case Zc.CONTACT_FIELD_CHANGED:e={type:Vc.Inline,text:Qc(t)};break;case Zc.CONTACT_NAME_CHANGED:e={type:Vc.Inline,text:Jc(t)};break;case Zc.CONTACT_URNS_CHANGED:e={type:Vc.Inline,text:th(t)};break;case Zc.CONTACT_GROUPS_CHANGED:e={type:Vc.Inline,text:nh(t)};break;case Zc.AIRTIME_TRANSFERRED:e={type:Vc.Inline,text:oh(t)};break;case Zc.CALL_STARTED:e={type:Vc.Inline,text:"Call Started"};break;case Zc.CHANNEL_EVENT:e={type:Vc.Inline,text:Xc(t)};break;case Zc.CONTACT_LANGUAGE_CHANGED:e={type:Vc.Inline,text:sh(t)};break;case Zc.OPTIN_REQUESTED:e={type:Vc.Inline,text:rh(t)}}return e&&t.created_on?e.date=new Date(t.created_on):console.error("Unknown event type",t),e}getUserForEvent(t){let e=null;return"msg_received"===t.type?e={name:this.currentContact.name}:t.created_by&&(e={email:t.created_by.email,name:`${t.created_by.first_name} ${t.created_by.last_name}`.trim(),avatar:t.created_by.avatar}),e}createMessages(t){if(t.events){let e=[];return t.events.forEach((t=>{const i=1e3*new Date(t.created_on).getTime();if(i>this.newestEventTime&&(this.newestEventTime=i),"ticket_note_added"===t.type){const i=t;e.push({type:Vc.Note,id:t.created_on+t.type,user:this.getUserForEvent(i),date:new Date(i.created_on),text:i.note})}else if("ticket_opened"===t.type){const i=t;e.push({type:Vc.Note,id:t.created_on+t.type+"_note",user:this.getUserForEvent(i),date:new Date(i.created_on),text:i.note}),e.push(this.getEventMessage(t))}else if("msg_created"===t.type||"msg_received"===t.type||"broadcast_created"===t.type){const i=t;e.push({id:t.uuid,type:"msg_received"===i.type?"msg_in":"msg_out",user:this.getUserForEvent(i),date:new Date(i.created_on),attachments:i.msg.attachments,text:i.msg.text,sendError:"E"===i.status||"F"===i.status,popup:H`<div
|
|
2928
2928
|
style="display: flex; flex-direction: row; align-items:center; justify-content: space-between;font-size:0.9em;line-height:1em;min-width:10em"
|
|
2929
2929
|
>
|
|
2930
2930
|
<div style="justify-content:left;text-align:left">
|