@nyaruka/temba-components 0.134.4 → 0.134.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,16 +4,46 @@ 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.134.4](https://github.com/nyaruka/temba-components/compare/v0.134.0...v0.134.4)
7
+ #### [v0.134.6](https://github.com/nyaruka/temba-components/compare/v0.134.5...v0.134.6)
8
+
9
+ - Deleted message treatment [`#775`](https://github.com/nyaruka/temba-components/pull/775)
10
+ - Add screenshot tests for deleted messages [`db32633`](https://github.com/nyaruka/temba-components/commit/db32633ab3153d658e7d8f77cf77e8ce84186bdc)
11
+ - MsgEVent._deleted.user is optional [`b8135d9`](https://github.com/nyaruka/temba-components/commit/b8135d944cb260b0594a0b40c7c4764d420045c3)
12
+
13
+ #### [v0.134.5](https://github.com/nyaruka/temba-components/compare/v0.134.4...v0.134.5)
14
+
15
+ > 2 December 2025
16
+
17
+ - Fix message log links [`6bfb571`](https://github.com/nyaruka/temba-components/commit/6bfb571d6e09dba4d5b9ef9fea3d50718d98dbed)
18
+
19
+ #### [v0.134.4](https://github.com/nyaruka/temba-components/compare/v0.134.3...v0.134.4)
20
+
21
+ > 2 December 2025
8
22
 
9
23
  - Nicer popups for chat messages [`#773`](https://github.com/nyaruka/temba-components/pull/773)
10
24
  - Fix groupings, dates, new lines in messages [`#772`](https://github.com/nyaruka/temba-components/pull/772)
25
+ - Revert unintended change [`4615b1d`](https://github.com/nyaruka/temba-components/commit/4615b1d68cb89060dac219c3ecab18488cee73d5)
26
+
27
+ #### [v0.134.3](https://github.com/nyaruka/temba-components/compare/v0.134.2...v0.134.3)
28
+
29
+ > 1 December 2025
30
+
11
31
  - Fix handling of showMessageLogsAfter property in ContactChat component [`#771`](https://github.com/nyaruka/temba-components/pull/771)
32
+
33
+ #### [v0.134.2](https://github.com/nyaruka/temba-components/compare/v0.134.1...v0.134.2)
34
+
35
+ > 1 December 2025
36
+
12
37
  - Generate message log URLs for messages [`#770`](https://github.com/nyaruka/temba-components/pull/770)
13
- - Fix rendering of note added events when no user [`#769`](https://github.com/nyaruka/temba-components/pull/769)
14
38
  - Generate message log URLs for messages created within a specified number of days. [`1e6433d`](https://github.com/nyaruka/temba-components/commit/1e6433dcaccf3a8cf1e07f5865eda16db7f16e70)
15
39
  - Use Date type property on Chat component [`cf244e1`](https://github.com/nyaruka/temba-components/commit/cf244e102fbb2aaa22eb688eeda9172270ddfb70)
16
- - Revert unintended change [`4615b1d`](https://github.com/nyaruka/temba-components/commit/4615b1d68cb89060dac219c3ecab18488cee73d5)
40
+ - Apply suggestions from code review [`9ceae6a`](https://github.com/nyaruka/temba-components/commit/9ceae6a95aed669824d771c8cefeb7745f7628af)
41
+
42
+ #### [v0.134.1](https://github.com/nyaruka/temba-components/compare/v0.134.0...v0.134.1)
43
+
44
+ > 27 November 2025
45
+
46
+ - Fix rendering of note added events when no user [`#769`](https://github.com/nyaruka/temba-components/pull/769)
17
47
 
18
48
  #### [v0.134.0](https://github.com/nyaruka/temba-components/compare/v0.133.0...v0.134.0)
19
49
 
@@ -2415,6 +2415,16 @@ const{I:th}=at,eh=()=>document.createComment(""),ih=(t,e,i)=>{const n=t._$AA.par
2415
2415
  color: #ad47479a;
2416
2416
  }
2417
2417
 
2418
+ .deleted .bubble {
2419
+ background: #fff;
2420
+ color: #999;
2421
+ border: 1px solid #e0e0e0;
2422
+ }
2423
+
2424
+ .deleted .bubble .name {
2425
+ color: #aaa;
2426
+ }
2427
+
2418
2428
  .message-text {
2419
2429
  white-space: pre-wrap;
2420
2430
  margin-bottom: 0.5em;
@@ -2422,6 +2432,12 @@ const{I:th}=at,eh=()=>document.createComment(""),ih=(t,e,i)=>{const n=t._$AA.par
2422
2432
  word-break: break-word;
2423
2433
  }
2424
2434
 
2435
+ .message-deleted {
2436
+ font-style: italic;
2437
+ margin-bottom: 0.5em;
2438
+ line-height: 1.2em;
2439
+ }
2440
+
2425
2441
  .chat {
2426
2442
  width: 28rem;
2427
2443
  border-radius: var(--curvature);
@@ -2713,8 +2729,8 @@ const{I:th}=at,eh=()=>document.createComment(""),ih=(t,e,i)=>{const n=t._$AA.par
2713
2729
  </div>`}const x=V`
2714
2730
  <div class="block ${d?"incoming":"outgoing"}">
2715
2731
  <div class="group-messages" style="flex-grow:1">
2716
- ${ah(l,(t=>t),((t,e)=>{var i,n;const o=this.msgMap.get(t),s=o,r=o._status?o._status.status:"",a=(null===(i=s.msg)||void 0===i?void 0:i.unsendable_reason)||(null===(n=s._status)||void 0===n?void 0:n.reason)&&("failed"===r||"errored"===r);return V`<div
2717
- class="row message ${r} ${a?"error":""}"
2732
+ ${ah(l,(t=>t),((t,e)=>{var i,n;const o=this.msgMap.get(t),s=o,r=o._status?o._status.status:"",a=(null===(i=s.msg)||void 0===i?void 0:i.unsendable_reason)||(null===(n=s._status)||void 0===n?void 0:n.reason)&&("failed"===r||"errored"===r)?"error":"",l=s._deleted?"deleted":"";return V`<div
2733
+ class="row message ${r} ${a} ${l}"
2718
2734
  >
2719
2735
  ${this.renderMessage(o,0==e?u:null)}
2720
2736
  </div>`}))}
@@ -2731,19 +2747,19 @@ const{I:th}=at,eh=()=>document.createComment(""),ih=(t,e,i)=>{const n=t._$AA.par
2731
2747
  </div>
2732
2748
  ${null}
2733
2749
  ${b}
2734
- `;return{html:x,timestamp:y}}renderMessage(t,e=null){var i,n;if(t._rendered)return V`<div class="event">${t._rendered.html}</div>`;const o=t,s=null===(i=o.msg)||void 0===i?void 0:i.unsendable_reason,r=null===(n=o._status)||void 0===n?void 0:n.reason,a=s?(t=>{switch(t){case"no_route":return"No channel available to send message";case"contact_blocked":return"Contact has been blocked";case"contact_stopped":return"Contact has been stopped";case"contact_archived":return"Contact is archived";case"org_suspended":return"Workspace is suspended";case"looping":return"Message loop detected";default:return"Unable to send message"}})(s):r?(t=>{switch(t){case"error_limit":return"Error limit reached";case"too_old":return"Message is too old to send";case"channel_removed":return"Channel was removed";default:return"Message failed to send"}})(r):null,l=this.showMessageLogsAfter&&o.created_on>=this.showMessageLogsAfter&&o.msg.channel?`/channels/channel/logs/${o.msg.channel}/msg/${t.uuid}/`:null;return V`
2750
+ `;return{html:x,timestamp:y}}renderMessage(t,e=null){var i,n,o;if(t._rendered)return V`<div class="event">${t._rendered.html}</div>`;const s=t,r=null===(i=s.msg)||void 0===i?void 0:i.unsendable_reason,a=null===(n=s._status)||void 0===n?void 0:n.reason,l=r?(t=>{switch(t){case"no_route":return"No channel available to send message";case"contact_blocked":return"Contact has been blocked";case"contact_stopped":return"Contact has been stopped";case"contact_archived":return"Contact is archived";case"org_suspended":return"Workspace is suspended";case"looping":return"Message loop detected";default:return"Unable to send message"}})(r):a?(t=>{switch(t){case"error_limit":return"Error limit reached";case"too_old":return"Message is too old to send";case"channel_removed":return"Channel was removed";default:return"Message failed to send"}})(a):null,c=this.showMessageLogsAfter&&s.created_on>=this.showMessageLogsAfter&&s.msg.channel?`/channels/channel/logs/${s.msg.channel.uuid}/msg/${t.uuid}/`:null,h=s._deleted,d=h?s._deleted.by_contact?"contact":(null===(o=s._deleted.user)||void 0===o?void 0:o.name)||"user":null;return V`
2735
2751
  <div class="bubble-wrap">
2736
2752
  <div class="popup" style="white-space: nowrap;">
2737
- ${a?V`<div style="color: var(--color-error); margin-right: 1em;">
2738
- ${a}
2753
+ ${l?V`<div style="color: var(--color-error); margin-right: 1em;">
2754
+ ${l}
2739
2755
  </div>`:null}
2740
2756
  <temba-date
2741
- value="${o.created_on.toISOString()}"
2757
+ value="${s.created_on.toISOString()}"
2742
2758
  display="relative"
2743
2759
  ></temba-date>
2744
- ${l?V`<a
2760
+ ${c?V`<a
2745
2761
  style="margin-left: 1em; color: var(--color-primary-dark);"
2746
- href="${l}"
2762
+ href="${c}"
2747
2763
  target="_blank"
2748
2764
  rel="noopener noreferrer"
2749
2765
  ><temba-icon name="log"></temba-icon
@@ -2751,13 +2767,18 @@ const{I:th}=at,eh=()=>document.createComment(""),ih=(t,e,i)=>{const n=t._$AA.par
2751
2767
 
2752
2768
  <div class="arrow">▼</div>
2753
2769
  </div>
2754
- ${o.msg.text?V`<div class="bubble">
2770
+ ${h?V`<div class="bubble">
2771
+ ${e?V`<div class="name">${e}</div>`:null}
2772
+ <div class="message-deleted">
2773
+ Message deleted by ${d}
2774
+ </div>
2775
+ </div>`:s.msg.text?V`<div class="bubble">
2755
2776
  ${e?V`<div class="name">${e}</div>`:null}
2756
- <div class="message-text">${o.msg.text}</div>
2777
+ <div class="message-text">${s.msg.text}</div>
2757
2778
  </div>`:null}
2758
2779
 
2759
2780
  <div class="attachments">
2760
- ${(o.msg.attachments||[]).map((t=>V`<temba-thumbnail
2781
+ ${(s.msg.attachments||[]).map((t=>V`<temba-thumbnail
2761
2782
  attachment="${t}"
2762
2783
  ></temba-thumbnail>`))}
2763
2784
  </div>
@@ -3039,7 +3060,7 @@ const{I:th}=at,eh=()=>document.createComment(""),ih=(t,e,i)=>{const n=t._$AA.par
3039
3060
  `}set showMessageLogsAfter(t){const e=this._showMessageLogsAfter;this._showMessageLogsAfter=t?new Date(t):null,this.requestUpdate("showMessageLogsAfter",e)}get showMessageLogsAfter(){return this._showMessageLogsAfter}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=yl,this._showMessageLogsAfter=null,this.ticket=null,this.beforeUUID=null,this.afterUUID=null,this.refreshId=null,this.polling=!1,this.pollingInterval=2e3,this.lastFetchTime=null}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){var e;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.currentContact&&(this.chat=this.shadowRoot.querySelector("temba-chat"),this.currentContact.uuid!==(null===(e=t.get("currentContact"))||void 0===e?void 0:e.uuid)?this.reset():setTimeout((()=>this.checkForNewMessages()),500),this.fetchPreviousMessages())}reset(){this.chat&&this.chat.reset(),this.blockFetching=!1,this.ticket=null,this.beforeUUID=null,this.afterUUID=null,this.refreshId=null,this.polling=!1,this.pollingInterval=2e3,this.lastFetchTime=null,this.errorMessage=null;const t=this.shadowRoot.querySelector("temba-compose");t&&t.reset()}handleInterrupt(){this.fireCustomEvent(Dn.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.";pe(`/contact/chat/${this.currentContact.uuid}/`,n).then((t=>{if(t.status<400){const i=t.json.event;i.created_on=new Date(i.created_on),this.chat.addMessages([i],null,!0),this.pollingInterval=2e3,this.checkForNewMessages(),e.reset(),this.fireCustomEvent(Dn.MessageSent,{msg:n,response:t})}else this.errorMessage=r})).catch((()=>{this.errorMessage=r}))}getEndpoint(){return this.contact?`/contact/chat/${this.contact}/`:null}scheduleRefresh(t=!1){this.refreshId&&(clearTimeout(this.refreshId),this.refreshId=null),this.pollingInterval=t?2e3:Math.min(this.pollingInterval+1e3,15e3),this.refreshId=setTimeout((()=>{this.checkForNewMessages()}),this.pollingInterval)}prerender(t){switch(t.type){case mh.AIRTIME_TRANSFERRED:t._rendered={html:Ch(t),type:ch.Inline};break;case mh.CALL_CREATED:case mh.CALL_MISSED:case mh.CALL_RECEIVED:t._rendered={html:Ah(t),type:ch.Inline};break;case mh.CHAT_STARTED:t._rendered={html:vh(t),type:ch.Inline};break;case mh.CONTACT_FIELD_CHANGED:t._rendered={html:yh(t),type:ch.Inline};break;case mh.CONTACT_GROUPS_CHANGED:t._rendered={html:kh(t),type:ch.Inline};break;case mh.CONTACT_LANGUAGE_CHANGED:t._rendered={html:Sh(t),type:ch.Inline};break;case mh.CONTACT_NAME_CHANGED:t._rendered={html:bh(t),type:ch.Inline};break;case mh.CONTACT_STATUS_CHANGED:t._rendered={html:Eh(t),type:ch.Inline};break;case mh.CONTACT_URNS_CHANGED:t._rendered={html:xh(t),type:ch.Inline};break;case mh.OPTIN_REQUESTED:case mh.OPTIN_STARTED:case mh.OPTIN_STOPPED:t._rendered={html:Th(t),type:ch.Inline};break;case mh.RUN_STARTED:case mh.RUN_ENDED:t._rendered={html:fh(t),type:ch.Inline};break;case mh.TICKET_ASSIGNEE_CHANGED:t._rendered={html:wh(t),type:ch.Inline};break;case mh.TICKET_CLOSED:t._rendered={html:_h(t,"closed"),type:ch.Inline};break;case mh.TICKET_OPENED:t._rendered={html:_h(t,"opened"),type:ch.Inline};break;case mh.TICKET_NOTE_ADDED:t._rendered={html:_h(t,"noted"),type:ch.Inline};break;case mh.TICKET_REOPENED:t._rendered={html:_h(t,"reopened"),type:ch.Inline};break;case mh.TICKET_TOPIC_CHANGED:t._rendered={html:V`<div>
3040
3061
  Topic changed to
3041
3062
  <strong>${t.topic.name}</strong>
3042
- </div>`,type:ch.Inline};break;default:console.error("Unknown event type",t)}}createMessages(t){if(t.events){const e=[];return t.events.forEach((t=>{(!this.afterUUID||t.uuid.toLowerCase()>this.afterUUID.toLowerCase())&&(this.afterUUID=t.uuid),t.created_on=new Date(t.created_on),"msg_created"===t.type||"msg_received"===t.type||"ivr_created"===t.type?e.push(t):(this.prerender(t),t._rendered&&e.push(t))})),e.filter((t=>!!t))}return[]}checkForNewMessages(){var t;if(this.polling)return;const e=this.chat;if(this.currentContact&&this.afterUUID){this.polling=!0,this.lastFetchTime=Date.now();const i=this.getEndpoint();if(!i)return;const n=this.currentContact.uuid;Mh(i,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,null,this.afterUUID).then((t=>{const i=this.createMessages(t);if(i.reverse(),n===this.currentContact.uuid){const t=i.length>0;e.addMessages(i,null,!0),this.polling=!1,this.scheduleRefresh(t)}else this.polling=!1}))}}fetchPreviousMessages(){var t;const e=this.chat,i=this;if(e&&!e.fetching&&!i.blockFetching&&(e.fetching=!0,this.currentContact)){const n=this.getEndpoint();if(!n)return;if(!this.beforeUUID&&!this.afterUUID){const t=Jt();this.beforeUUID=t,this.afterUUID=t}Mh(n,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,this.beforeUUID,null).then((t=>{const n=this.createMessages(t);if(n.reverse(),0===n.length)i.blockFetching=!0;else if(t.next)this.beforeUUID=t.next;else if(i.blockFetching=!0,t.events&&t.events.length>0){const i=t.events[t.events.length-1];e.setEndOfHistory(new Date(i.created_on))}e.addMessages(n),this.scheduleRefresh()}))}}fetchComplete(){this.chat&&(this.chat.fetching=!1)}getTembaCompose(){return this.currentTicket?this.currentContact&&"active"!==this.currentContact.status||this.currentTicket.closed_on?null:this.getCompose():this.currentContact&&"active"!==this.currentContact.status?null:this.getCompose()}getCompose(){return V`<div class="border"></div>
3063
+ </div>`,type:ch.Inline}}}createMessages(t){if(t.events){const e=[];return t.events.forEach((t=>{(!this.afterUUID||t.uuid.toLowerCase()>this.afterUUID.toLowerCase())&&(this.afterUUID=t.uuid),t.created_on=new Date(t.created_on),"msg_created"===t.type||"msg_received"===t.type||"ivr_created"===t.type?e.push(t):(this.prerender(t),t._rendered&&e.push(t))})),e.filter((t=>!!t))}return[]}checkForNewMessages(){var t;if(this.polling)return;const e=this.chat;if(this.currentContact&&this.afterUUID){this.polling=!0,this.lastFetchTime=Date.now();const i=this.getEndpoint();if(!i)return;const n=this.currentContact.uuid;Mh(i,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,null,this.afterUUID).then((t=>{const i=this.createMessages(t);if(i.reverse(),n===this.currentContact.uuid){const t=i.length>0;e.addMessages(i,null,!0),this.polling=!1,this.scheduleRefresh(t)}else this.polling=!1}))}}fetchPreviousMessages(){var t;const e=this.chat,i=this;if(e&&!e.fetching&&!i.blockFetching&&(e.fetching=!0,this.currentContact)){const n=this.getEndpoint();if(!n)return;if(!this.beforeUUID&&!this.afterUUID){const t=Jt();this.beforeUUID=t,this.afterUUID=t}Mh(n,null===(t=this.currentTicket)||void 0===t?void 0:t.uuid,this.beforeUUID,null).then((t=>{const n=this.createMessages(t);if(n.reverse(),0===n.length)i.blockFetching=!0;else if(t.next)this.beforeUUID=t.next;else if(i.blockFetching=!0,t.events&&t.events.length>0){const i=t.events[t.events.length-1];e.setEndOfHistory(new Date(i.created_on))}e.addMessages(n),this.scheduleRefresh()}))}}fetchComplete(){this.chat&&(this.chat.fetching=!1)}getTembaCompose(){return this.currentTicket?this.currentContact&&"active"!==this.currentContact.status||this.currentTicket.closed_on?null:this.getCompose():this.currentContact&&"active"!==this.currentContact.status?null:this.getCompose()}getCompose(){return V`<div class="border"></div>
3043
3064
  <div class="compose">
3044
3065
  <temba-compose
3045
3066
  attachments