@nyaruka/temba-components 0.90.0 → 0.91.2
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/.github/workflows/build.yml +4 -4
- package/.github/workflows/publish.yml +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/temba-components.js +11 -6
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/templates/TemplateEditor.js +22 -15
- package/out-tsc/src/templates/TemplateEditor.js.map +1 -1
- package/package.json +1 -1
- package/src/templates/TemplateEditor.ts +24 -16
|
@@ -7,11 +7,11 @@ jobs:
|
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
9
|
- name: Set Timezone
|
|
10
|
-
uses: szenius/set-timezone@
|
|
10
|
+
uses: szenius/set-timezone@v2.0
|
|
11
11
|
with:
|
|
12
12
|
timezoneLinux: "UTC"
|
|
13
13
|
- name: Checkout (GitHub)
|
|
14
|
-
uses: actions/checkout@
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
15
|
- run: docker network create --driver bridge textit_default
|
|
16
16
|
- name: Build and run dev container task
|
|
17
17
|
uses: devcontainers/ci@v0.3
|
|
@@ -23,13 +23,13 @@ jobs:
|
|
|
23
23
|
|
|
24
24
|
- name: Upload artifacts
|
|
25
25
|
if: failure()
|
|
26
|
-
uses: actions/upload-artifact@
|
|
26
|
+
uses: actions/upload-artifact@v4
|
|
27
27
|
with:
|
|
28
28
|
name: screenshots
|
|
29
29
|
path: screenshots/
|
|
30
30
|
|
|
31
31
|
- name: Upload coverage to Codecov
|
|
32
|
-
uses: codecov/codecov-action@
|
|
32
|
+
uses: codecov/codecov-action@v4
|
|
33
33
|
with:
|
|
34
34
|
token: ${{secrets.CODECOV_TOKEN}}
|
|
35
35
|
files: coverage/lcov.info
|
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,25 @@ 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.91.2](https://github.com/nyaruka/temba-components/compare/v0.91.1...v0.91.2)
|
|
8
|
+
|
|
9
|
+
- Fix for empty content [`#433`](https://github.com/nyaruka/temba-components/pull/433)
|
|
10
|
+
- Bump github actions versions [`#432`](https://github.com/nyaruka/temba-components/pull/432)
|
|
11
|
+
|
|
12
|
+
#### [v0.91.1](https://github.com/nyaruka/temba-components/compare/v0.91.0...v0.91.1)
|
|
13
|
+
|
|
14
|
+
> 7 June 2024
|
|
15
|
+
|
|
16
|
+
#### [v0.91.0](https://github.com/nyaruka/temba-components/compare/v0.90.0...v0.91.0)
|
|
17
|
+
|
|
18
|
+
> 7 June 2024
|
|
19
|
+
|
|
20
|
+
- Remove params from component spec [`#431`](https://github.com/nyaruka/temba-components/pull/431)
|
|
21
|
+
|
|
7
22
|
#### [v0.90.0](https://github.com/nyaruka/temba-components/compare/v0.89.0...v0.90.0)
|
|
8
23
|
|
|
24
|
+
> 7 June 2024
|
|
25
|
+
|
|
9
26
|
- Add media picker, use for compose and templates [`#430`](https://github.com/nyaruka/temba-components/pull/430)
|
|
10
27
|
- Fix drop acceptance [`f520af6`](https://github.com/nyaruka/temba-components/commit/f520af64ceaa2630833d36d36eac4e42c97204f1)
|
|
11
28
|
- Make templates work for different content types [`58b7ed8`](https://github.com/nyaruka/temba-components/commit/58b7ed8a49d537055f946f3ed404aecd592d6db3)
|
package/dist/temba-components.js
CHANGED
|
@@ -7701,6 +7701,10 @@ background: #ccc;
|
|
|
7701
7701
|
align-items: center;
|
|
7702
7702
|
}
|
|
7703
7703
|
|
|
7704
|
+
.button .content {
|
|
7705
|
+
margin-bottom: 0;
|
|
7706
|
+
}
|
|
7707
|
+
|
|
7704
7708
|
.button .display {
|
|
7705
7709
|
margin-right: 0.5em;
|
|
7706
7710
|
background: #f9f9f9;
|
|
@@ -7724,8 +7728,9 @@ background: #ccc;
|
|
|
7724
7728
|
max-height: 50vh;
|
|
7725
7729
|
overflow-y: auto;
|
|
7726
7730
|
overflow-x: hidden;
|
|
7731
|
+
padding-bottom: 0;
|
|
7727
7732
|
}
|
|
7728
|
-
`}firstUpdated(t){super.firstUpdated(t)}updated(t){super.updated(t)}handleTemplateChanged(t){const e=this.selectedTemplate;this.selectedTemplate=t.target.values[0];const[i,o]=this.lang.split("-");this.selectedTemplate?this.selectedTemplate.translations.forEach((t=>{if(t.locale===this.lang||!o&&t.locale.split("-")[0]===i){this.translation=t;const i=new Array((t.variables||[]).length).fill("");e||this.variables&&this.variables.forEach(((t,e)=>{i[e]=t})),this.variables=i}})):this.translation=null,this.fireCustomEvent(Me.ContextChanged,{template:this.selectedTemplate,translation:this.translation,variables:this.variables})}handleAttachmentsChanged(t){const e=t.target,i=parseInt(e.getAttribute("index"));if(0===e.attachments.length)this.variables[i]="";else{const t=e.attachments[0];t.url&&t.content_type?this.variables[i]=`${t.content_type}:${t.url}`:this.variables[i]=""}this.fireContentChange()}handleVariableChanged(t){const e=t.target,i=parseInt(e.getAttribute("index"));this.variables[i]=e.value,this.fireContentChange()}fireContentChange(){this.fireCustomEvent(Me.ContentChanged,{template:this.selectedTemplate,translation:this.translation,variables:this.variables})}renderVariables(t){var e;const i=new RegExp(`{{(${Object.keys(t.variables||[]).join("|")})}}`,"g");let o=null;
|
|
7733
|
+
`}firstUpdated(t){super.firstUpdated(t)}updated(t){super.updated(t)}handleTemplateChanged(t){const e=this.selectedTemplate;this.selectedTemplate=t.target.values[0];const[i,o]=this.lang.split("-");this.selectedTemplate?this.selectedTemplate.translations.forEach((t=>{if(t.locale===this.lang||!o&&t.locale.split("-")[0]===i){this.translation=t;const i=new Array((t.variables||[]).length).fill("");e||this.variables&&this.variables.forEach(((t,e)=>{i[e]=t})),this.variables=i}})):this.translation=null,this.fireCustomEvent(Me.ContextChanged,{template:this.selectedTemplate,translation:this.translation,variables:this.variables})}handleAttachmentsChanged(t){const e=t.target,i=parseInt(e.getAttribute("index"));if(0===e.attachments.length)this.variables[i]="";else{const t=e.attachments[0];t.url&&t.content_type?this.variables[i]=`${t.content_type}:${t.url}`:this.variables[i]=""}this.fireContentChange()}handleVariableChanged(t){const e=t.target,i=parseInt(e.getAttribute("index"));this.variables[i]=e.value,this.fireContentChange()}fireContentChange(){this.fireCustomEvent(Me.ContentChanged,{template:this.selectedTemplate,translation:this.translation,variables:this.variables})}renderVariables(t){var e;const i=new RegExp(`{{(${Object.keys(t.variables||[]).join("|")})}}`,"g");let o=null,n=[];return t.content&&t.content.trim().length>0&&(n=(null===(e=t.content)||void 0===e?void 0:e.split(i))||[]),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
|
|
7729
7734
|
class="variable"
|
|
7730
7735
|
type="text"
|
|
7731
7736
|
value=${o<this.variables.length?this.variables[o]:null}
|
|
@@ -7733,24 +7738,24 @@ background: #ccc;
|
|
|
7733
7738
|
name="${t.name}"
|
|
7734
7739
|
index="${o}"
|
|
7735
7740
|
placeholder="{{${e}}}"
|
|
7736
|
-
></temba-completion>`})):t.
|
|
7741
|
+
></temba-completion>`})):Object.values(t.variables).map((t=>{const e=this.translation.variables[t];if("image"===e.type||"document"===e.type||"audio"===e.type||"video"===e.type){let i=[];if(this.variables[t]){const e=this.variables[t].split(":");i=[{url:e[1],content_type:e[0]}]}return j`<div
|
|
7737
7742
|
style="
|
|
7738
7743
|
display: flex;
|
|
7739
7744
|
align-items: center;
|
|
7740
7745
|
border-radius: var(--curvature);
|
|
7741
|
-
${0===
|
|
7746
|
+
${0===i.length?"background-color:rgba(255,0,0,.07);":""}
|
|
7742
7747
|
"
|
|
7743
7748
|
>
|
|
7744
7749
|
<temba-media-picker
|
|
7745
7750
|
accept="${"document"===e.type?"application/pdf":e.type+"/*"}"
|
|
7746
7751
|
max="1"
|
|
7747
|
-
index=${
|
|
7752
|
+
index=${t}
|
|
7748
7753
|
icon="attachment_${e.type}"
|
|
7749
|
-
attachments=${JSON.stringify(
|
|
7754
|
+
attachments=${JSON.stringify(i)}
|
|
7750
7755
|
@change=${this.handleAttachmentsChanged.bind(this)}
|
|
7751
7756
|
></temba-media-picker>
|
|
7752
7757
|
<div>
|
|
7753
|
-
${0==
|
|
7758
|
+
${0==i.length?j`Attach ${e.type} to continue`:""}
|
|
7754
7759
|
</div>
|
|
7755
7760
|
</div>`}})),j`<div class="content">${o}</div> `}renderComponents(t){const e=t.filter((t=>!t.type.startsWith("button/"))).map((t=>j`<div class="${t.name}">
|
|
7756
7761
|
${this.renderVariables(t)}
|