@nyaruka/temba-components 0.100.0 → 0.101.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
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.101.0](https://github.com/nyaruka/temba-components/compare/v0.100.0...v0.101.0)
|
|
8
|
+
|
|
9
|
+
- Switch template field initialization to updated() [`9701746`](https://github.com/nyaruka/temba-components/commit/97017460746df49432b630c803aa14d120da9004)
|
|
10
|
+
|
|
7
11
|
#### [v0.100.0](https://github.com/nyaruka/temba-components/compare/v0.99.0...v0.100.0)
|
|
8
12
|
|
|
13
|
+
> 17 July 2024
|
|
14
|
+
|
|
9
15
|
- Template attachment variables [`#444`](https://github.com/nyaruka/temba-components/pull/444)
|
|
10
16
|
- Allow text urls for template attachments [`7df73ad`](https://github.com/nyaruka/temba-components/commit/7df73ade272825fbd93a178d4b85a904c8cab359)
|
|
11
17
|
- Show thumbnail based on the attachment type [`a5ee94e`](https://github.com/nyaruka/temba-components/commit/a5ee94e0a0bcc0c06a4edffc625aeaf41e718174)
|
package/dist/temba-components.js
CHANGED
|
@@ -7477,7 +7477,7 @@ background: #ccc;
|
|
|
7477
7477
|
color: #777;
|
|
7478
7478
|
margin-left: 0.25em;
|
|
7479
7479
|
}
|
|
7480
|
-
`}
|
|
7480
|
+
`}updated(t){super.updated(t),t.has("template")&&(this.textInputAttachments={},this.currentVariables=this.variables,this.currentVariables.length>0&&this.currentVariables.forEach(((t,e)=>{const i=t.split(":");i.length>1&&-1===i[0].indexOf("/")&&(this.textInputAttachments[e]=!0)})))}handleTemplateChanged(t){const e=this.selectedTemplate;this.selectedTemplate=t.target.values[0],e&&(this.currentVariables=[],this.textInputAttachments={}),this.selectedTemplate?(this.translation=this.selectedTemplate.base_translation,this.translation?this.variables=new Array((this.translation.variables||[]).length).fill(""):this.variables=[]):(this.translation=null,this.variables=[]),this.fireCustomEvent(Le.ContextChanged,{template:this.selectedTemplate,translation:this.translation,variables:this.currentVariables})}handleAttachmentLoading(t){const e=t.target,i=parseInt(e.getAttribute("index"));this.pickersLoading[i]=t.detail.loading,this.requestUpdate()}handleAttachmentsChanged(t){const e=t.target,i=parseInt(e.getAttribute("index"));if(0===e.attachments.length)this.currentVariables[i]="";else{const t=e.attachments[0];t.url&&t.content_type?this.currentVariables[i]=`${t.content_type}:${t.url}`:this.currentVariables[i]=""}this.fireContentChange(),this.requestUpdate("currentVariables")}handleVariableChanged(t){const e=t.target,i=parseInt(e.getAttribute("index")),o=e.getAttribute("prefix")||"";let n=e.value;n&&(n=o+n),this.currentVariables[i]=n,this.fireContentChange()}fireContentChange(){this.fireCustomEvent(Le.ContentChanged,{template:this.selectedTemplate,translation:this.translation,variables:this.currentVariables})}renderVariables(t){var e;const i=new RegExp(`{{(${Object.keys(t.variables||[]).join("|")})}}`,"g");let o=null,n=[];t.content&&t.content.trim().length>0&&(n=(null===(e=t.content)||void 0===e?void 0:e.split(i))||[]);const s=this.currentVariables||[];return o=n.length>0?n.map(((e,i)=>{if(i%2==0)return j`<span class="text">${e}</span>`;const o=t.variables[e];return j`<temba-completion
|
|
7481
7481
|
class="variable"
|
|
7482
7482
|
type="text"
|
|
7483
7483
|
value=${o<s.length?s[o]:null}
|