@nyaruka/temba-components 0.63.2 → 0.64.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 +19 -1
- package/dist/{f03ff82f.js → b023e673.js} +185 -167
- package/dist/index.js +185 -167
- package/dist/static/svg/index.svg +1 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/dist/templates/components-body.html +1 -1
- package/dist/templates/components-head.html +1 -1
- package/out-tsc/src/compose/Compose.js +48 -5
- package/out-tsc/src/compose/Compose.js.map +1 -1
- package/out-tsc/src/contacts/ContactChat.js +3 -8
- package/out-tsc/src/contacts/ContactChat.js.map +1 -1
- package/out-tsc/src/contacts/events.js +3 -2
- package/out-tsc/src/contacts/events.js.map +1 -1
- package/out-tsc/src/select/Select.js +6 -1
- package/out-tsc/src/select/Select.js.map +1 -1
- package/out-tsc/src/tabpane/Tab.js +4 -0
- package/out-tsc/src/tabpane/Tab.js.map +1 -1
- package/out-tsc/src/tabpane/TabPane.js +7 -2
- package/out-tsc/src/tabpane/TabPane.js.map +1 -1
- package/out-tsc/src/vectoricon/index.js +2 -2
- package/out-tsc/src/vectoricon/index.js.map +1 -1
- package/out-tsc/test/temba-compose.test.js +1 -0
- package/out-tsc/test/temba-compose.test.js.map +1 -1
- package/package.json +1 -1
- package/src/compose/Compose.ts +53 -7
- package/src/contacts/ContactChat.ts +2 -7
- package/src/contacts/events.ts +2 -2
- package/src/select/Select.ts +8 -1
- package/src/tabpane/Tab.ts +3 -0
- package/src/tabpane/TabPane.ts +7 -2
- package/src/vectoricon/index.ts +2 -2
- package/static/svg/index.svg +1 -1
- package/static/svg/work/traced/message-chat-square.svg +1 -0
- package/static/svg/work/used/message-chat-square.svg +3 -0
- package/test/temba-compose.test.ts +1 -0
package/dist/sw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
if(!self.define){let e,t={};const o=(o,n)=>(o=new URL(o+".js",n).href,t[o]||new Promise((t=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=t,document.head.appendChild(e)}else e=o,importScripts(o),t()})).then((()=>{let e=t[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e})));self.define=(n,s)=>{const
|
|
1
|
+
if(!self.define){let e,t={};const o=(o,n)=>(o=new URL(o+".js",n).href,t[o]||new Promise((t=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=t,document.head.appendChild(e)}else e=o,importScripts(o),t()})).then((()=>{let e=t[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e})));self.define=(n,s)=>{const d=e||("document"in self?document.currentScript.src:"")||location.href;if(t[d])return;let i={};const r=e=>o(e,d),c={module:{uri:d},exports:i,require:r};t[d]=Promise.all(n.map((e=>c[e]||r(e)))).then((e=>(s(...e),i)))}}define(["./workbox-919adfb7"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"b023e673.js",revision:"ab3e92c97bd74c2dddaa17dfebaad2c5"},{url:"templates/components-body.html",revision:"d3ae5671dc13804bc4f00730042d4058"},{url:"templates/components-head.html",revision:"e3dcaa05421135bf5de93d1cdc7bf52d"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute("polyfills/*.js",new e.CacheFirst,"GET")}));
|
|
2
2
|
//# sourceMappingURL=sw.js.map
|
package/dist/sw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw.js","sources":["../../tmp/
|
|
1
|
+
{"version":3,"file":"sw.js","sources":["../../tmp/2cc19c3c8a5231edcec78f263bb1c780/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/workspaces/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/workspaces/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/workspaces/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/workspaces/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/workspaces/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/workspaces/temba-components/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"b023e673.js\",\n \"revision\": \"ab3e92c97bd74c2dddaa17dfebaad2c5\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"d3ae5671dc13804bc4f00730042d4058\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"e3dcaa05421135bf5de93d1cdc7bf52d\"\n }\n], {});\n\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"/index.html\")));\n\n\nworkbox_routing_registerRoute(\"polyfills/*.js\", new workbox_strategies_CacheFirst(), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","url","revision","workbox","registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","workbox_strategies_CacheFirst"],"mappings":"0nBAwBAA,KAAKC,cAELC,EAAAA,eAQAC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,cACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,qCAEb,CAAE,GAEwBC,EAAAC,cAAC,IAAIC,EAAAA,gBAAgCC,EAAAA,wBAA2C,iBAGhFH,EAAAC,cAAC,iBAAkB,IAAIG,aAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/
|
|
1
|
+
<script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/b023e673.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.64.0"</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/
|
|
1
|
+
<link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/b023e673.js" crossorigin="anonymous">
|
|
@@ -26,7 +26,6 @@ export class Compose extends FormElement {
|
|
|
26
26
|
opacity: 0;
|
|
27
27
|
pointer-events: none;
|
|
28
28
|
position: absolute;
|
|
29
|
-
z-index: 2;
|
|
30
29
|
height: 100%;
|
|
31
30
|
width: 100%;
|
|
32
31
|
bottom: 0;
|
|
@@ -159,7 +158,6 @@ export class Compose extends FormElement {
|
|
|
159
158
|
.language {
|
|
160
159
|
margin-bottom: 0.6em;
|
|
161
160
|
display: block;
|
|
162
|
-
z-index: 2;
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
.top-right {
|
|
@@ -195,6 +193,10 @@ export class Compose extends FormElement {
|
|
|
195
193
|
temba-loading {
|
|
196
194
|
margin: auto 1em;
|
|
197
195
|
}
|
|
196
|
+
|
|
197
|
+
.optins {
|
|
198
|
+
padding: 1em;
|
|
199
|
+
}
|
|
198
200
|
`;
|
|
199
201
|
}
|
|
200
202
|
constructor() {
|
|
@@ -209,6 +211,8 @@ export class Compose extends FormElement {
|
|
|
209
211
|
this.languages = [];
|
|
210
212
|
this.currentAttachments = [];
|
|
211
213
|
this.currentQuickReplies = [];
|
|
214
|
+
this.currentOptin = [];
|
|
215
|
+
this.optinEndpoint = '/api/v2/optins.json';
|
|
212
216
|
this.failedAttachments = [];
|
|
213
217
|
this.buttonName = 'Send';
|
|
214
218
|
this.buttonDisabled = true;
|
|
@@ -216,6 +220,10 @@ export class Compose extends FormElement {
|
|
|
216
220
|
this.langValues = {};
|
|
217
221
|
this.currentLanguage = 'und';
|
|
218
222
|
}
|
|
223
|
+
isBaseLanguage() {
|
|
224
|
+
return (this.currentLanguage == 'und' ||
|
|
225
|
+
this.currentLanguage == this.languages[0].iso);
|
|
226
|
+
}
|
|
219
227
|
handleTabChanged() {
|
|
220
228
|
const tabs = this.shadowRoot.querySelector('temba-tabs');
|
|
221
229
|
const tab = tabs.getCurrentTab();
|
|
@@ -260,6 +268,7 @@ export class Compose extends FormElement {
|
|
|
260
268
|
this.currentQuickReplies = (langValue.quick_replies || []).map(value => {
|
|
261
269
|
return { name: value, value };
|
|
262
270
|
});
|
|
271
|
+
this.currentOptin = langValue['optin'] ? [langValue['optin']] : [];
|
|
263
272
|
this.setFocusOnChatbox();
|
|
264
273
|
// TODO: this feels like it shouldn't be needed
|
|
265
274
|
const chatbox = this.shadowRoot.querySelector('.chatbox');
|
|
@@ -269,10 +278,11 @@ export class Compose extends FormElement {
|
|
|
269
278
|
this.resetTabs();
|
|
270
279
|
this.requestUpdate('currentAttachments');
|
|
271
280
|
}
|
|
272
|
-
if (this.langValues &&
|
|
281
|
+
if ((this.langValues &&
|
|
273
282
|
(changes.has('currentText') ||
|
|
274
283
|
changes.has('currentAttachments') ||
|
|
275
|
-
changes.has('currentQuickReplies')))
|
|
284
|
+
changes.has('currentQuickReplies'))) ||
|
|
285
|
+
changes.has('currentOptin')) {
|
|
276
286
|
this.toggleButton();
|
|
277
287
|
const trimmed = this.currentText ? this.currentText.trim() : '';
|
|
278
288
|
if (trimmed ||
|
|
@@ -282,6 +292,7 @@ export class Compose extends FormElement {
|
|
|
282
292
|
text: trimmed,
|
|
283
293
|
attachments: this.currentAttachments,
|
|
284
294
|
quick_replies: this.currentQuickReplies.map(option => option.value),
|
|
295
|
+
optin: this.currentOptin.length > 0 ? this.currentOptin[0] : null,
|
|
285
296
|
};
|
|
286
297
|
}
|
|
287
298
|
else {
|
|
@@ -315,6 +326,11 @@ export class Compose extends FormElement {
|
|
|
315
326
|
handleQuickReplyChange(event) {
|
|
316
327
|
this.requestUpdate('currentQuickReplies');
|
|
317
328
|
}
|
|
329
|
+
handleOptInChange(event) {
|
|
330
|
+
console.log('changed', this.currentOptin, event.target.values);
|
|
331
|
+
this.currentOptin = event.target.values;
|
|
332
|
+
this.requestUpdate('optIn');
|
|
333
|
+
}
|
|
318
334
|
handleChatboxChange(evt) {
|
|
319
335
|
const chatbox = evt.target;
|
|
320
336
|
this.currentText = chatbox.value;
|
|
@@ -616,13 +632,14 @@ export class Compose extends FormElement {
|
|
|
616
632
|
`;
|
|
617
633
|
}
|
|
618
634
|
getActions() {
|
|
635
|
+
const showOptins = this.optIns && this.isBaseLanguage();
|
|
619
636
|
return html `
|
|
620
637
|
<temba-tabs
|
|
621
638
|
embedded
|
|
622
639
|
focusedname
|
|
623
640
|
bottom
|
|
624
641
|
refresh="${this.currentAttachments.length}|${this.index}|${this
|
|
625
|
-
.currentQuickReplies.length}"
|
|
642
|
+
.currentQuickReplies.length}|${showOptins}|${this.currentOptin}"
|
|
626
643
|
>
|
|
627
644
|
${this.attachments
|
|
628
645
|
? html `<temba-tab
|
|
@@ -651,6 +668,23 @@ export class Compose extends FormElement {
|
|
|
651
668
|
></temba-select>
|
|
652
669
|
</temba-tab>`
|
|
653
670
|
: null}
|
|
671
|
+
<temba-tab
|
|
672
|
+
name="Opt-in"
|
|
673
|
+
icon="channel_fba"
|
|
674
|
+
?hidden=${!showOptins}
|
|
675
|
+
?checked=${this.currentOptin.length > 0}
|
|
676
|
+
>
|
|
677
|
+
<temba-select
|
|
678
|
+
@change=${this.handleOptInChange}
|
|
679
|
+
.values=${this.currentOptin}
|
|
680
|
+
endpoint="${this.optinEndpoint}"
|
|
681
|
+
class="optins"
|
|
682
|
+
searchable
|
|
683
|
+
clearable
|
|
684
|
+
placeholder="Select an opt-in to use for Facebook (optional)"
|
|
685
|
+
></temba-select>
|
|
686
|
+
</temba-tab>
|
|
687
|
+
|
|
654
688
|
<div slot="tab-right" class="top-right">
|
|
655
689
|
${this.buttonError
|
|
656
690
|
? html `<div class="send-error">${this.buttonError}</div>`
|
|
@@ -724,6 +758,9 @@ __decorate([
|
|
|
724
758
|
__decorate([
|
|
725
759
|
property({ type: Boolean })
|
|
726
760
|
], Compose.prototype, "quickReplies", void 0);
|
|
761
|
+
__decorate([
|
|
762
|
+
property({ type: Boolean })
|
|
763
|
+
], Compose.prototype, "optIns", void 0);
|
|
727
764
|
__decorate([
|
|
728
765
|
property({ type: Boolean })
|
|
729
766
|
], Compose.prototype, "counter", void 0);
|
|
@@ -757,6 +794,12 @@ __decorate([
|
|
|
757
794
|
__decorate([
|
|
758
795
|
property({ type: Array })
|
|
759
796
|
], Compose.prototype, "currentQuickReplies", void 0);
|
|
797
|
+
__decorate([
|
|
798
|
+
property({ type: Array })
|
|
799
|
+
], Compose.prototype, "currentOptin", void 0);
|
|
800
|
+
__decorate([
|
|
801
|
+
property({ type: String })
|
|
802
|
+
], Compose.prototype, "optinEndpoint", void 0);
|
|
760
803
|
__decorate([
|
|
761
804
|
property({ type: Array, attribute: false })
|
|
762
805
|
], Compose.prototype, "failedAttachments", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compose.js","sourceRoot":"","sources":["../../../src/compose/Compose.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAc,eAAe,EAAY,MAAM,eAAe,CAAC;AACtE,O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f;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;yCACX;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;0CAC3B;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0CACC;AAG3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDACY;AAGtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDACkC;AAG5D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDACP;AAGrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CACxB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAC5B;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;2CAClC;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCACT;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAOpB;AAGP;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACH","sourcesContent":["import { TemplateResult, html, css } from 'lit';\nimport { FormElement } from '../FormElement';\nimport { property } from 'lit/decorators.js';\nimport { Icon } from '../vectoricon';\nimport { Attachment, CustomEventType, Language } from '../interfaces';\nimport {\n formatFileSize,\n getClasses,\n postFormData,\n truncate,\n DEFAULT_MEDIA_ENDPOINT,\n WebResponse,\n isImageAttachment,\n} from '../utils';\nimport { Completion } from '../completion/Completion';\nimport { Select } from '../select/Select';\nimport { TabPane } from '../tabpane/TabPane';\nimport { EventHandler } from '../RapidElement';\n\nexport class Compose extends FormElement {\n static get styles() {\n return css`\n .container {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n position: relative;\n\n border-radius: var(--curvature-widget);\n background: var(--color-widget-bg);\n border: 1px solid var(--color-widget-border);\n transition: all ease-in-out var(--transition-speed);\n box-shadow: var(--widget-box-shadow);\n caret-color: var(--input-caret);\n }\n\n .drop-mask {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n z-index: 2;\n height: 100%;\n width: 100%;\n bottom: 0;\n right: 0;\n background: rgba(210, 243, 184, 0.8);\n border-radius: var(--curvature-widget);\n margin: -0.5em;\n padding: 0.5em;\n transition: opacity ease-in-out var(--transition-speed);\n display: flex;\n align-items: center;\n text-align: center;\n }\n\n .highlight .drop-mask {\n opacity: 1;\n }\n\n .drop-mask > div {\n margin: auto;\n border-radius: var(--curvature-widget);\n font-weight: 400;\n color: rgba(0, 0, 0, 0.5);\n }\n\n .items {\n }\n\n .chatbox {\n --color-widget-border: none;\n --curvature-widget: var(--curvature) var(--curvature) 0px 0px;\n --textarea-min-height: 4em;\n }\n\n .attachments {\n }\n .attachments-list {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n padding: 0.2em;\n }\n .attachment-item {\n padding: 0.4em;\n }\n .attachment-item.error {\n background: #fff;\n color: rgba(250, 0, 0, 0.75);\n padding: 0.2em;\n margin: 0.3em 0.5em;\n border-radius: var(--curvature);\n display: block;\n }\n\n .remove-item {\n position: absolute;\n --icon-color: #ccc;\n background: #fff;\n border-radius: 99%;\n transform: scale(0);\n transition: transform 200ms linear;\n }\n\n .attachment-item:hover .remove-item {\n transform: scale(1);\n }\n\n .remove-item:hover {\n --icon-color: #333;\n cursor: pointer;\n }\n\n .remove-item.error:hover {\n background: rgba(250, 0, 0, 0.1);\n }\n\n .remove-item.error {\n background: rgba(250, 0, 0, 0.05);\n color: rgba(250, 0, 0, 0.75);\n }\n .attachment-name {\n align-self: center;\n font-size: 12px;\n padding: 2px 8px;\n }\n\n .actions {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0em;\n background: #f9f9f9;\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n border-top: solid 1px var(--color-widget-border);\n }\n\n #upload-input {\n display: none;\n }\n .upload-label {\n display: flex;\n align-items: center;\n }\n .upload-icon {\n color: rgb(102, 102, 102);\n }\n .actions-right {\n display: flex;\n align-items: center;\n }\n temba-charcount {\n margin-right: 5px;\n overflow: hidden;\n --temba-charcount-counts-margin-top: 0px;\n --temba-charcount-summary-margin-top: 0px;\n --temba-charcount-summary-position: fixed;\n --temba-charcount-summary-right: 105px;\n --temba-charcount-summary-bottom: 105px;\n }\n temba-button {\n --button-y: 1px;\n --button-x: 12px;\n }\n .send-error {\n color: rgba(250, 0, 0, 0.75);\n font-size: var(--help-text-size);\n }\n\n .language {\n margin-bottom: 0.6em;\n display: block;\n z-index: 2;\n }\n\n .top-right {\n align-items: center;\n display: flex;\n }\n\n #send-button {\n margin: 0.3em;\n }\n\n temba-tabs {\n --focused-tab-color: #f4f4f4;\n }\n\n .quick-replies {\n margin: 0.8em;\n }\n\n .add-attachment {\n padding: 1em;\n background: #eee;\n border-radius: var(--curvature);\n color: #aaa;\n margin: 0.5em;\n }\n\n .add-attachment:hover {\n background: #e9e9e9;\n cursor: pointer;\n }\n\n temba-loading {\n margin: auto 1em;\n }\n `;\n }\n\n @property({ type: Number })\n index = 1;\n\n @property({ type: Number })\n maxAttachments = 3;\n\n @property({ type: Number })\n maxLength = 640;\n\n @property({ type: Boolean })\n completion: boolean;\n\n @property({ type: Boolean })\n chatbox: boolean;\n\n @property({ type: Boolean })\n attachments: boolean;\n\n @property({ type: Boolean })\n quickReplies: boolean;\n\n @property({ type: Boolean })\n counter: boolean;\n\n @property({ type: Boolean })\n pendingDrop: boolean;\n\n @property({ type: Boolean })\n button: boolean;\n\n @property({ type: String })\n currentText = '';\n\n @property({ type: String })\n initialText = '';\n\n @property({ type: String })\n accept = ''; //e.g. \".xls,.xlsx\"\n\n @property({ type: String, attribute: false })\n endpoint = DEFAULT_MEDIA_ENDPOINT;\n\n @property({ type: Boolean, attribute: false })\n uploading: boolean;\n\n @property({ type: Array })\n languages: Language[] = [];\n\n @property({ type: Array })\n currentAttachments: Attachment[] = [];\n\n @property({ type: Array })\n currentQuickReplies: { name: string; value: string }[] = [];\n\n @property({ type: Array, attribute: false })\n failedAttachments: Attachment[] = [];\n\n @property({ type: String })\n buttonName = 'Send';\n\n @property({ type: Boolean, attribute: false })\n buttonDisabled = true;\n\n @property({ type: String, attribute: false })\n buttonError = '';\n\n @property({ type: Boolean, attribute: 'widget_only' })\n widgetOnly: boolean;\n\n @property({ type: Array })\n errors: string[];\n\n @property({ type: Object })\n langValues: {\n [lang: string]: {\n text: string;\n attachments: Attachment[];\n quick_replies: string[];\n };\n } = {};\n\n @property({ type: String })\n currentLanguage = 'und';\n\n public constructor() {\n super();\n }\n\n private handleTabChanged() {\n const tabs = this.shadowRoot.querySelector('temba-tabs') as TabPane;\n const tab = tabs.getCurrentTab();\n if (tab) {\n // check we are going for the first attachment\n if (tab.icon == 'attachment') {\n if (this.currentAttachments.length == 0) {\n this.handleUploadFileIconClicked();\n }\n }\n }\n }\n\n public getEventHandlers(): EventHandler[] {\n return [\n { event: CustomEventType.ContextChanged, method: this.handleTabChanged },\n ];\n }\n\n public firstUpdated(changes: Map<string, any>): void {\n super.firstUpdated(changes);\n\n if (changes.has('languages') && this.languages.length > 0) {\n this.currentLanguage = this.languages[0].iso;\n }\n\n if (changes.has('value')) {\n this.langValues = this.getDeserializedValue() || {};\n }\n this.setFocusOnChatbox();\n }\n\n public updated(changes: Map<string, any>): void {\n super.updated(changes);\n\n if (changes.has('currentLanguage') && this.langValues) {\n let langValue = {\n text: '',\n attachments: [],\n quick_replies: [],\n };\n\n if (this.currentLanguage in this.langValues) {\n langValue = this.langValues[this.currentLanguage];\n }\n\n this.currentText = langValue.text;\n this.initialText = langValue.text;\n this.currentAttachments = langValue.attachments;\n this.currentQuickReplies = (langValue.quick_replies || []).map(value => {\n return { name: value, value };\n });\n this.setFocusOnChatbox();\n\n // TODO: this feels like it shouldn't be needed\n const chatbox = this.shadowRoot.querySelector('.chatbox') as any;\n if (chatbox) {\n chatbox.value = this.initialText;\n }\n this.resetTabs();\n this.requestUpdate('currentAttachments');\n }\n\n if (\n this.langValues &&\n (changes.has('currentText') ||\n changes.has('currentAttachments') ||\n changes.has('currentQuickReplies'))\n ) {\n this.toggleButton();\n\n const trimmed = this.currentText ? this.currentText.trim() : '';\n if (\n trimmed ||\n this.currentAttachments.length > 0 ||\n this.currentQuickReplies.length > 0\n ) {\n this.langValues[this.currentLanguage] = {\n text: trimmed,\n attachments: this.currentAttachments,\n quick_replies: this.currentQuickReplies.map(option => option.value),\n };\n } else {\n delete this.langValues[this.currentLanguage];\n }\n this.fireCustomEvent(CustomEventType.ContentChanged, this.langValues);\n this.requestUpdate('langValues');\n this.setValue(this.langValues);\n }\n }\n\n private setFocusOnChatbox(): void {\n if (this.chatbox) {\n const completion = this.shadowRoot.querySelector(\n '.chatbox'\n ) as Completion;\n if (completion) {\n window.setTimeout(() => {\n completion.focus();\n // this.resetTabs();\n }, 0);\n }\n }\n }\n\n public reset(): void {\n (this.shadowRoot.querySelector('.chatbox') as HTMLInputElement).value = '';\n this.initialText = '';\n this.currentText = '';\n this.currentQuickReplies = [];\n this.currentAttachments = [];\n this.failedAttachments = [];\n this.buttonError = '';\n }\n\n private handleQuickReplyChange(event: InputEvent) {\n this.requestUpdate('currentQuickReplies');\n }\n\n private handleChatboxChange(evt: Event) {\n const chatbox = evt.target as HTMLInputElement;\n this.currentText = chatbox.value;\n }\n\n private handleDragEnter(evt: DragEvent): void {\n this.highlight(evt);\n }\n\n private handleDragOver(evt: DragEvent): void {\n this.highlight(evt);\n }\n\n private handleDragLeave(evt: DragEvent): void {\n this.unhighlight(evt);\n }\n\n private handleDrop(evt: DragEvent): void {\n if (this.canAcceptAttachments()) {\n this.unhighlight(evt);\n const dt = evt.dataTransfer;\n if (dt) {\n const files = dt.files;\n this.uploadFiles(files);\n }\n }\n }\n\n private preventDefaults(evt: Event): void {\n evt.preventDefault();\n evt.stopPropagation();\n }\n\n private highlight(evt: DragEvent): void {\n if (this.canAcceptAttachments()) {\n this.pendingDrop = true;\n this.preventDefaults(evt);\n }\n }\n\n private unhighlight(evt: DragEvent): void {\n if (this.canAcceptAttachments()) {\n this.pendingDrop = false;\n this.preventDefaults(evt);\n }\n }\n\n private handleUploadFileIconClicked(): void {\n this.dispatchEvent(new Event('change'));\n }\n\n private handleUploadFileInputChanged(evt: Event): void {\n const target = evt.target as HTMLInputElement;\n const files = target.files;\n this.uploadFiles(files);\n }\n\n public canAcceptAttachments() {\n return (\n this.attachments && this.currentAttachments.length < this.maxAttachments\n );\n }\n\n public uploadFiles(files: FileList): void {\n let filesToUpload = [];\n if (this.currentAttachments && this.currentAttachments.length > 0) {\n //remove duplicate files that have already been uploaded\n filesToUpload = [...files].filter(file => {\n const index = this.currentAttachments.findIndex(\n value => value.filename === file.name && value.size === file.size\n );\n if (index === -1) {\n return file;\n }\n });\n } else {\n filesToUpload = [...files];\n }\n filesToUpload.map(fileToUpload => {\n this.uploadFile(fileToUpload);\n });\n }\n\n private uploadFile(file: File): void {\n this.uploading = true;\n\n const url = this.endpoint;\n const payload = new FormData();\n payload.append('file', file);\n postFormData(url, payload)\n .then((response: WebResponse) => {\n if (this.currentAttachments.length >= this.maxAttachments) {\n this.addFailedAttachment(file, 'Too many attachments');\n } else {\n const attachment = response.json as Attachment;\n if (attachment) {\n this.addCurrentAttachment(attachment);\n }\n }\n })\n .catch((error: WebResponse) => {\n let uploadError = '';\n if (error.status === 400) {\n uploadError = error.json.file[0];\n } else {\n uploadError = 'Server failure';\n }\n console.error(uploadError);\n this.addFailedAttachment(file, uploadError);\n })\n .finally(() => {\n this.uploading = false;\n });\n }\n\n private addCurrentAttachment(attachmentToAdd: any) {\n this.currentAttachments.push(attachmentToAdd);\n this.requestUpdate('currentAttachments');\n }\n private removeCurrentAttachment(attachmentToRemove: any) {\n this.currentAttachments = this.currentAttachments.filter(\n currentAttachment => currentAttachment !== attachmentToRemove\n );\n this.requestUpdate('currentAttachments');\n }\n\n private addFailedAttachment(file: File, error: string) {\n const failedAttachment = {\n uuid: Math.random().toString(36).slice(2, 6),\n content_type: file.type,\n filename: file.name,\n url: file.name,\n size: file.size,\n error: error,\n } as Attachment;\n this.failedAttachments.push(failedAttachment);\n this.requestUpdate('failedAttachments');\n }\n private removeFailedAttachment(attachmentToRemove: any) {\n this.failedAttachments = this.failedAttachments.filter(\n (failedAttachment: any) => failedAttachment !== attachmentToRemove\n );\n this.requestUpdate('failedAttachments');\n }\n\n private handleRemoveFileClicked(evt: Event): void {\n const target = evt.target as HTMLDivElement;\n\n const currentAttachmentToRemove = this.currentAttachments.find(\n ({ uuid }) => uuid === target.id\n );\n if (currentAttachmentToRemove) {\n this.removeCurrentAttachment(currentAttachmentToRemove);\n }\n\n const failedAttachmentToRemove = this.failedAttachments.find(\n ({ uuid }) => uuid === target.id\n );\n if (failedAttachmentToRemove) {\n this.removeFailedAttachment(failedAttachmentToRemove);\n }\n }\n\n public toggleButton() {\n if (this.button) {\n this.buttonError = '';\n const chatboxEmpty = this.currentText.trim().length === 0;\n const attachmentsEmpty = this.currentAttachments.length === 0;\n if (this.chatbox && this.attachments) {\n this.buttonDisabled = chatboxEmpty && attachmentsEmpty;\n } else if (this.chatbox) {\n this.buttonDisabled = chatboxEmpty;\n } else if (this.attachments) {\n this.buttonDisabled = attachmentsEmpty;\n } else {\n this.buttonDisabled = true;\n }\n }\n }\n\n private handleSendClick(evt: Event) {\n evt.stopPropagation();\n this.handleSend();\n }\n\n private handleSendEnter(evt: KeyboardEvent) {\n if (this.button) {\n if (evt.key === 'Enter' && !evt.shiftKey) {\n if (this.completion) {\n const chat = evt.target as Completion;\n if (!chat.hasVisibleOptions()) {\n this.handleSend();\n this.preventDefaults(evt);\n }\n } else {\n this.handleSend();\n this.preventDefaults(evt);\n }\n }\n }\n }\n\n private handleSend() {\n if (!this.buttonDisabled) {\n this.buttonDisabled = true;\n const name = this.buttonName;\n this.fireCustomEvent(CustomEventType.ButtonClicked, { name });\n }\n }\n\n private handleLanguageChange(evt: Event) {\n const select = evt.target as Select;\n this.currentLanguage = select.values[0].iso;\n }\n\n public resetTabs() {\n (this.shadowRoot.querySelector('temba-tabs') as TabPane).index = -1;\n }\n\n public render(): TemplateResult {\n return html`\n <temba-field\n name=${this.name}\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n .value=${this.value}\n >\n ${this.languages.length > 1\n ? html`<temba-select\n @change=${this.handleLanguageChange}\n class=\"language\"\n name=\"language\"\n .staticOptions=${this.languages}\n valueKey=\"iso\"\n >\n </temba-select>`\n : null}\n\n <div\n class=${getClasses({ container: true, highlight: this.pendingDrop })}\n @dragenter=\"${this.handleDragEnter}\"\n @dragover=\"${this.handleDragOver}\"\n @dragleave=\"${this.handleDragLeave}\"\n @drop=\"${this.handleDrop}\"\n >\n <div class=\"drop-mask\"><div>Upload Attachment</div></div>\n\n ${this.chatbox ? html`${this.getChatbox()}` : null}\n\n <div class=\"items actions\">${this.getActions()}</div>\n </div>\n </temba-field>\n `;\n }\n\n private getChatbox(): TemplateResult {\n if (this.completion) {\n return html`<temba-completion\n class=\"chatbox\"\n .value=${this.initialText}\n gsm\n textarea\n autogrow\n maxlength=${this.maxLength}\n @change=${this.handleChatboxChange}\n @keydown=${this.handleSendEnter}\n placeholder=\"Write something here\"\n >\n </temba-completion>`;\n } else {\n return html`<temba-textinput\n class=\"chatbox\"\n gsm\n textarea\n autogrow\n maxlength=${this.maxLength}\n .value=${this.initialText}\n @change=${this.handleChatboxChange}\n @keydown=${this.handleSendEnter}\n placeholder=\"Write something here\"\n >\n </temba-textinput>`;\n }\n }\n\n private getAttachments(): TemplateResult {\n return html`\n ${this.attachments\n ? html` <div class=\"attachments-list\">\n ${this.currentAttachments.map(validAttachment => {\n return html` <div class=\"attachment-item\">\n <temba-icon\n class=\"remove-item\"\n @click=\"${this.handleRemoveFileClicked}\"\n id=\"${validAttachment.uuid}\"\n name=\"${Icon.delete_small}\"\n ></temba-icon>\n ${isImageAttachment(validAttachment)\n ? html`<temba-thumbnail\n url=\"${validAttachment.url}\"\n ></temba-thumbnail>`\n : html`<temba-thumbnail\n label=\"${validAttachment.content_type.split('/')[1]}\"\n ></temba-thumbnail>`}\n </div>`;\n })}\n ${this.getUploader()}\n </div>\n ${this.failedAttachments.map(invalidAttachment => {\n return html` <div class=\"attachment-item error\">\n <div\n class=\"remove-item error\"\n @click=\"${this.handleRemoveFileClicked}\"\n >\n <temba-icon\n id=\"${invalidAttachment.uuid}\"\n name=\"${Icon.delete_small}\"\n ></temba-icon>\n </div>\n <div class=\"attachment-name\">\n <span\n title=\"${invalidAttachment.filename} (${formatFileSize(\n 0,\n 0\n )}) - Attachment failed - ${invalidAttachment.error}\"\n >${truncate(invalidAttachment.filename, 25)}\n (${formatFileSize(0, 0)}) - Attachment failed</span\n >\n </div>\n </div>`;\n })}`\n : null}\n `;\n }\n\n private getActions(): TemplateResult {\n return html`\n <temba-tabs\n embedded\n focusedname\n bottom\n refresh=\"${this.currentAttachments.length}|${this.index}|${this\n .currentQuickReplies.length}\"\n >\n ${this.attachments\n ? html`<temba-tab\n name=\"Attachments\"\n icon=\"attachment\"\n .count=${this.currentAttachments.length}\n >\n <div class=\"items attachments\">${this.getAttachments()}</div>\n </temba-tab>`\n : null}\n ${this.quickReplies\n ? html`<temba-tab\n name=\"Quick Replies\"\n icon=\"quick_replies\"\n .count=${this.currentQuickReplies.length}\n >\n <temba-select\n @change=${this.handleQuickReplyChange}\n .values=${this.currentQuickReplies}\n class=\"quick-replies\"\n tags\n multi\n searchable\n expressions\n placeholder=\"Add Quick Reply\"\n ></temba-select>\n </temba-tab>`\n : null}\n <div slot=\"tab-right\" class=\"top-right\">\n ${this.buttonError\n ? html`<div class=\"send-error\">${this.buttonError}</div>`\n : null}\n ${this.counter ? this.getCounter() : null}\n ${this.button ? this.getButton() : null}\n </div>\n </temba-tabs>\n `;\n }\n\n private getUploader(): TemplateResult {\n if (this.uploading) {\n return html`<temba-loading units=\"3\" size=\"12\"></temba-loading>`;\n } else {\n return this.currentAttachments.length < this.maxAttachments\n ? html`<input\n type=\"file\"\n id=\"upload-input\"\n multiple\n accept=\"${this.accept}\"\n @change=\"${this.handleUploadFileInputChanged}\"\n />\n <label\n id=\"upload-label\"\n class=\"actions-left upload-label\"\n for=\"upload-input\"\n >\n <div\n class=\"add-attachment\"\n @click=\"${this.handleUploadFileIconClicked}\"\n >\n <temba-icon name=\"add\" size=\"1.5\"></temba-icon>\n </div>\n </label>`\n : null;\n }\n }\n\n private getCounter(): TemplateResult {\n return html`<temba-charcount\n .text=\"${this.currentText}\"\n ></temba-charcount>`;\n }\n\n private getButton(): TemplateResult {\n return html` <temba-button\n id=\"send-button\"\n name=${this.buttonName}\n @click=${this.handleSendClick}\n ?disabled=${this.buttonDisabled}\n ></temba-button>`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Compose.js","sourceRoot":"","sources":["../../../src/compose/Compose.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAc,eAAe,EAAY,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,cAAc,EACd,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,sBAAsB,EAEtB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAMlB,MAAM,OAAO,OAAQ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AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0CACC;AAG3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDACY;AAGtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDACkC;AAG5D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6CAC0B;AAGpD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACW;AAGtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDACP;AAGrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CACxB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAC5B;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;2CAClC;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCACT;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAQpB;AAGP;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACH","sourcesContent":["import { TemplateResult, html, css } from 'lit';\nimport { FormElement } from '../FormElement';\nimport { property } from 'lit/decorators.js';\nimport { Icon } from '../vectoricon';\nimport { Attachment, CustomEventType, Language } from '../interfaces';\nimport {\n formatFileSize,\n getClasses,\n postFormData,\n truncate,\n DEFAULT_MEDIA_ENDPOINT,\n WebResponse,\n isImageAttachment,\n} from '../utils';\nimport { Completion } from '../completion/Completion';\nimport { Select } from '../select/Select';\nimport { TabPane } from '../tabpane/TabPane';\nimport { EventHandler } from '../RapidElement';\n\nexport class Compose extends FormElement {\n static get styles() {\n return css`\n .container {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n position: relative;\n\n border-radius: var(--curvature-widget);\n background: var(--color-widget-bg);\n border: 1px solid var(--color-widget-border);\n transition: all ease-in-out var(--transition-speed);\n box-shadow: var(--widget-box-shadow);\n caret-color: var(--input-caret);\n }\n\n .drop-mask {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n height: 100%;\n width: 100%;\n bottom: 0;\n right: 0;\n background: rgba(210, 243, 184, 0.8);\n border-radius: var(--curvature-widget);\n margin: -0.5em;\n padding: 0.5em;\n transition: opacity ease-in-out var(--transition-speed);\n display: flex;\n align-items: center;\n text-align: center;\n }\n\n .highlight .drop-mask {\n opacity: 1;\n }\n\n .drop-mask > div {\n margin: auto;\n border-radius: var(--curvature-widget);\n font-weight: 400;\n color: rgba(0, 0, 0, 0.5);\n }\n\n .items {\n }\n\n .chatbox {\n --color-widget-border: none;\n --curvature-widget: var(--curvature) var(--curvature) 0px 0px;\n --textarea-min-height: 4em;\n }\n\n .attachments {\n }\n .attachments-list {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n padding: 0.2em;\n }\n .attachment-item {\n padding: 0.4em;\n }\n .attachment-item.error {\n background: #fff;\n color: rgba(250, 0, 0, 0.75);\n padding: 0.2em;\n margin: 0.3em 0.5em;\n border-radius: var(--curvature);\n display: block;\n }\n\n .remove-item {\n position: absolute;\n --icon-color: #ccc;\n background: #fff;\n border-radius: 99%;\n transform: scale(0);\n transition: transform 200ms linear;\n }\n\n .attachment-item:hover .remove-item {\n transform: scale(1);\n }\n\n .remove-item:hover {\n --icon-color: #333;\n cursor: pointer;\n }\n\n .remove-item.error:hover {\n background: rgba(250, 0, 0, 0.1);\n }\n\n .remove-item.error {\n background: rgba(250, 0, 0, 0.05);\n color: rgba(250, 0, 0, 0.75);\n }\n .attachment-name {\n align-self: center;\n font-size: 12px;\n padding: 2px 8px;\n }\n\n .actions {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0em;\n background: #f9f9f9;\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n border-top: solid 1px var(--color-widget-border);\n }\n\n #upload-input {\n display: none;\n }\n .upload-label {\n display: flex;\n align-items: center;\n }\n .upload-icon {\n color: rgb(102, 102, 102);\n }\n .actions-right {\n display: flex;\n align-items: center;\n }\n temba-charcount {\n margin-right: 5px;\n overflow: hidden;\n --temba-charcount-counts-margin-top: 0px;\n --temba-charcount-summary-margin-top: 0px;\n --temba-charcount-summary-position: fixed;\n --temba-charcount-summary-right: 105px;\n --temba-charcount-summary-bottom: 105px;\n }\n temba-button {\n --button-y: 1px;\n --button-x: 12px;\n }\n .send-error {\n color: rgba(250, 0, 0, 0.75);\n font-size: var(--help-text-size);\n }\n\n .language {\n margin-bottom: 0.6em;\n display: block;\n }\n\n .top-right {\n align-items: center;\n display: flex;\n }\n\n #send-button {\n margin: 0.3em;\n }\n\n temba-tabs {\n --focused-tab-color: #f4f4f4;\n }\n\n .quick-replies {\n margin: 0.8em;\n }\n\n .add-attachment {\n padding: 1em;\n background: #eee;\n border-radius: var(--curvature);\n color: #aaa;\n margin: 0.5em;\n }\n\n .add-attachment:hover {\n background: #e9e9e9;\n cursor: pointer;\n }\n\n temba-loading {\n margin: auto 1em;\n }\n\n .optins {\n padding: 1em;\n }\n `;\n }\n\n @property({ type: Number })\n index = 1;\n\n @property({ type: Number })\n maxAttachments = 3;\n\n @property({ type: Number })\n maxLength = 640;\n\n @property({ type: Boolean })\n completion: boolean;\n\n @property({ type: Boolean })\n chatbox: boolean;\n\n @property({ type: Boolean })\n attachments: boolean;\n\n @property({ type: Boolean })\n quickReplies: boolean;\n\n @property({ type: Boolean })\n optIns: boolean;\n\n @property({ type: Boolean })\n counter: boolean;\n\n @property({ type: Boolean })\n pendingDrop: boolean;\n\n @property({ type: Boolean })\n button: boolean;\n\n @property({ type: String })\n currentText = '';\n\n @property({ type: String })\n initialText = '';\n\n @property({ type: String })\n accept = ''; //e.g. \".xls,.xlsx\"\n\n @property({ type: String, attribute: false })\n endpoint = DEFAULT_MEDIA_ENDPOINT;\n\n @property({ type: Boolean, attribute: false })\n uploading: boolean;\n\n @property({ type: Array })\n languages: Language[] = [];\n\n @property({ type: Array })\n currentAttachments: Attachment[] = [];\n\n @property({ type: Array })\n currentQuickReplies: { name: string; value: string }[] = [];\n\n @property({ type: Array })\n currentOptin: { name: string; uuid: string }[] = [];\n\n @property({ type: String })\n optinEndpoint = '/api/v2/optins.json';\n\n @property({ type: Array, attribute: false })\n failedAttachments: Attachment[] = [];\n\n @property({ type: String })\n buttonName = 'Send';\n\n @property({ type: Boolean, attribute: false })\n buttonDisabled = true;\n\n @property({ type: String, attribute: false })\n buttonError = '';\n\n @property({ type: Boolean, attribute: 'widget_only' })\n widgetOnly: boolean;\n\n @property({ type: Array })\n errors: string[];\n\n @property({ type: Object })\n langValues: {\n [lang: string]: {\n text: string;\n attachments: Attachment[];\n quick_replies: string[];\n optin?: { name: string; uuid: string };\n };\n } = {};\n\n @property({ type: String })\n currentLanguage = 'und';\n\n public constructor() {\n super();\n }\n\n private isBaseLanguage(): boolean {\n return (\n this.currentLanguage == 'und' ||\n this.currentLanguage == this.languages[0].iso\n );\n }\n\n private handleTabChanged() {\n const tabs = this.shadowRoot.querySelector('temba-tabs') as TabPane;\n const tab = tabs.getCurrentTab();\n if (tab) {\n // check we are going for the first attachment\n if (tab.icon == 'attachment') {\n if (this.currentAttachments.length == 0) {\n this.handleUploadFileIconClicked();\n }\n }\n }\n }\n\n public getEventHandlers(): EventHandler[] {\n return [\n { event: CustomEventType.ContextChanged, method: this.handleTabChanged },\n ];\n }\n\n public firstUpdated(changes: Map<string, any>): void {\n super.firstUpdated(changes);\n\n if (changes.has('languages') && this.languages.length > 0) {\n this.currentLanguage = this.languages[0].iso;\n }\n\n if (changes.has('value')) {\n this.langValues = this.getDeserializedValue() || {};\n }\n this.setFocusOnChatbox();\n }\n\n public updated(changes: Map<string, any>): void {\n super.updated(changes);\n\n if (changes.has('currentLanguage') && this.langValues) {\n let langValue = {\n text: '',\n attachments: [],\n quick_replies: [],\n };\n\n if (this.currentLanguage in this.langValues) {\n langValue = this.langValues[this.currentLanguage];\n }\n\n this.currentText = langValue.text;\n this.initialText = langValue.text;\n this.currentAttachments = langValue.attachments;\n this.currentQuickReplies = (langValue.quick_replies || []).map(value => {\n return { name: value, value };\n });\n this.currentOptin = langValue['optin'] ? [langValue['optin']] : [];\n this.setFocusOnChatbox();\n\n // TODO: this feels like it shouldn't be needed\n const chatbox = this.shadowRoot.querySelector('.chatbox') as any;\n if (chatbox) {\n chatbox.value = this.initialText;\n }\n this.resetTabs();\n this.requestUpdate('currentAttachments');\n }\n\n if (\n (this.langValues &&\n (changes.has('currentText') ||\n changes.has('currentAttachments') ||\n changes.has('currentQuickReplies'))) ||\n changes.has('currentOptin')\n ) {\n this.toggleButton();\n\n const trimmed = this.currentText ? this.currentText.trim() : '';\n if (\n trimmed ||\n this.currentAttachments.length > 0 ||\n this.currentQuickReplies.length > 0\n ) {\n this.langValues[this.currentLanguage] = {\n text: trimmed,\n attachments: this.currentAttachments,\n quick_replies: this.currentQuickReplies.map(option => option.value),\n optin: this.currentOptin.length > 0 ? this.currentOptin[0] : null,\n };\n } else {\n delete this.langValues[this.currentLanguage];\n }\n this.fireCustomEvent(CustomEventType.ContentChanged, this.langValues);\n this.requestUpdate('langValues');\n this.setValue(this.langValues);\n }\n }\n\n private setFocusOnChatbox(): void {\n if (this.chatbox) {\n const completion = this.shadowRoot.querySelector(\n '.chatbox'\n ) as Completion;\n if (completion) {\n window.setTimeout(() => {\n completion.focus();\n // this.resetTabs();\n }, 0);\n }\n }\n }\n\n public reset(): void {\n (this.shadowRoot.querySelector('.chatbox') as HTMLInputElement).value = '';\n this.initialText = '';\n this.currentText = '';\n this.currentQuickReplies = [];\n this.currentAttachments = [];\n this.failedAttachments = [];\n this.buttonError = '';\n }\n\n private handleQuickReplyChange(event: InputEvent) {\n this.requestUpdate('currentQuickReplies');\n }\n\n private handleOptInChange(event: InputEvent) {\n console.log('changed', this.currentOptin, (event.target as any).values);\n this.currentOptin = (event.target as any).values;\n this.requestUpdate('optIn');\n }\n\n private handleChatboxChange(evt: Event) {\n const chatbox = evt.target as HTMLInputElement;\n this.currentText = chatbox.value;\n }\n\n private handleDragEnter(evt: DragEvent): void {\n this.highlight(evt);\n }\n\n private handleDragOver(evt: DragEvent): void {\n this.highlight(evt);\n }\n\n private handleDragLeave(evt: DragEvent): void {\n this.unhighlight(evt);\n }\n\n private handleDrop(evt: DragEvent): void {\n if (this.canAcceptAttachments()) {\n this.unhighlight(evt);\n const dt = evt.dataTransfer;\n if (dt) {\n const files = dt.files;\n this.uploadFiles(files);\n }\n }\n }\n\n private preventDefaults(evt: Event): void {\n evt.preventDefault();\n evt.stopPropagation();\n }\n\n private highlight(evt: DragEvent): void {\n if (this.canAcceptAttachments()) {\n this.pendingDrop = true;\n this.preventDefaults(evt);\n }\n }\n\n private unhighlight(evt: DragEvent): void {\n if (this.canAcceptAttachments()) {\n this.pendingDrop = false;\n this.preventDefaults(evt);\n }\n }\n\n private handleUploadFileIconClicked(): void {\n this.dispatchEvent(new Event('change'));\n }\n\n private handleUploadFileInputChanged(evt: Event): void {\n const target = evt.target as HTMLInputElement;\n const files = target.files;\n this.uploadFiles(files);\n }\n\n public canAcceptAttachments() {\n return (\n this.attachments && this.currentAttachments.length < this.maxAttachments\n );\n }\n\n public uploadFiles(files: FileList): void {\n let filesToUpload = [];\n if (this.currentAttachments && this.currentAttachments.length > 0) {\n //remove duplicate files that have already been uploaded\n filesToUpload = [...files].filter(file => {\n const index = this.currentAttachments.findIndex(\n value => value.filename === file.name && value.size === file.size\n );\n if (index === -1) {\n return file;\n }\n });\n } else {\n filesToUpload = [...files];\n }\n filesToUpload.map(fileToUpload => {\n this.uploadFile(fileToUpload);\n });\n }\n\n private uploadFile(file: File): void {\n this.uploading = true;\n\n const url = this.endpoint;\n const payload = new FormData();\n payload.append('file', file);\n postFormData(url, payload)\n .then((response: WebResponse) => {\n if (this.currentAttachments.length >= this.maxAttachments) {\n this.addFailedAttachment(file, 'Too many attachments');\n } else {\n const attachment = response.json as Attachment;\n if (attachment) {\n this.addCurrentAttachment(attachment);\n }\n }\n })\n .catch((error: WebResponse) => {\n let uploadError = '';\n if (error.status === 400) {\n uploadError = error.json.file[0];\n } else {\n uploadError = 'Server failure';\n }\n console.error(uploadError);\n this.addFailedAttachment(file, uploadError);\n })\n .finally(() => {\n this.uploading = false;\n });\n }\n\n private addCurrentAttachment(attachmentToAdd: any) {\n this.currentAttachments.push(attachmentToAdd);\n this.requestUpdate('currentAttachments');\n }\n private removeCurrentAttachment(attachmentToRemove: any) {\n this.currentAttachments = this.currentAttachments.filter(\n currentAttachment => currentAttachment !== attachmentToRemove\n );\n this.requestUpdate('currentAttachments');\n }\n\n private addFailedAttachment(file: File, error: string) {\n const failedAttachment = {\n uuid: Math.random().toString(36).slice(2, 6),\n content_type: file.type,\n filename: file.name,\n url: file.name,\n size: file.size,\n error: error,\n } as Attachment;\n this.failedAttachments.push(failedAttachment);\n this.requestUpdate('failedAttachments');\n }\n private removeFailedAttachment(attachmentToRemove: any) {\n this.failedAttachments = this.failedAttachments.filter(\n (failedAttachment: any) => failedAttachment !== attachmentToRemove\n );\n this.requestUpdate('failedAttachments');\n }\n\n private handleRemoveFileClicked(evt: Event): void {\n const target = evt.target as HTMLDivElement;\n\n const currentAttachmentToRemove = this.currentAttachments.find(\n ({ uuid }) => uuid === target.id\n );\n if (currentAttachmentToRemove) {\n this.removeCurrentAttachment(currentAttachmentToRemove);\n }\n\n const failedAttachmentToRemove = this.failedAttachments.find(\n ({ uuid }) => uuid === target.id\n );\n if (failedAttachmentToRemove) {\n this.removeFailedAttachment(failedAttachmentToRemove);\n }\n }\n\n public toggleButton() {\n if (this.button) {\n this.buttonError = '';\n const chatboxEmpty = this.currentText.trim().length === 0;\n const attachmentsEmpty = this.currentAttachments.length === 0;\n if (this.chatbox && this.attachments) {\n this.buttonDisabled = chatboxEmpty && attachmentsEmpty;\n } else if (this.chatbox) {\n this.buttonDisabled = chatboxEmpty;\n } else if (this.attachments) {\n this.buttonDisabled = attachmentsEmpty;\n } else {\n this.buttonDisabled = true;\n }\n }\n }\n\n private handleSendClick(evt: Event) {\n evt.stopPropagation();\n this.handleSend();\n }\n\n private handleSendEnter(evt: KeyboardEvent) {\n if (this.button) {\n if (evt.key === 'Enter' && !evt.shiftKey) {\n if (this.completion) {\n const chat = evt.target as Completion;\n if (!chat.hasVisibleOptions()) {\n this.handleSend();\n this.preventDefaults(evt);\n }\n } else {\n this.handleSend();\n this.preventDefaults(evt);\n }\n }\n }\n }\n\n private handleSend() {\n if (!this.buttonDisabled) {\n this.buttonDisabled = true;\n const name = this.buttonName;\n this.fireCustomEvent(CustomEventType.ButtonClicked, { name });\n }\n }\n\n private handleLanguageChange(evt: Event) {\n const select = evt.target as Select;\n this.currentLanguage = select.values[0].iso;\n }\n\n public resetTabs() {\n (this.shadowRoot.querySelector('temba-tabs') as TabPane).index = -1;\n }\n\n public render(): TemplateResult {\n return html`\n <temba-field\n name=${this.name}\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n .value=${this.value}\n >\n ${this.languages.length > 1\n ? html`<temba-select\n @change=${this.handleLanguageChange}\n class=\"language\"\n name=\"language\"\n .staticOptions=${this.languages}\n valueKey=\"iso\"\n >\n </temba-select>`\n : null}\n\n <div\n class=${getClasses({ container: true, highlight: this.pendingDrop })}\n @dragenter=\"${this.handleDragEnter}\"\n @dragover=\"${this.handleDragOver}\"\n @dragleave=\"${this.handleDragLeave}\"\n @drop=\"${this.handleDrop}\"\n >\n <div class=\"drop-mask\"><div>Upload Attachment</div></div>\n\n ${this.chatbox ? html`${this.getChatbox()}` : null}\n\n <div class=\"items actions\">${this.getActions()}</div>\n </div>\n </temba-field>\n `;\n }\n\n private getChatbox(): TemplateResult {\n if (this.completion) {\n return html`<temba-completion\n class=\"chatbox\"\n .value=${this.initialText}\n gsm\n textarea\n autogrow\n maxlength=${this.maxLength}\n @change=${this.handleChatboxChange}\n @keydown=${this.handleSendEnter}\n placeholder=\"Write something here\"\n >\n </temba-completion>`;\n } else {\n return html`<temba-textinput\n class=\"chatbox\"\n gsm\n textarea\n autogrow\n maxlength=${this.maxLength}\n .value=${this.initialText}\n @change=${this.handleChatboxChange}\n @keydown=${this.handleSendEnter}\n placeholder=\"Write something here\"\n >\n </temba-textinput>`;\n }\n }\n\n private getAttachments(): TemplateResult {\n return html`\n ${this.attachments\n ? html` <div class=\"attachments-list\">\n ${this.currentAttachments.map(validAttachment => {\n return html` <div class=\"attachment-item\">\n <temba-icon\n class=\"remove-item\"\n @click=\"${this.handleRemoveFileClicked}\"\n id=\"${validAttachment.uuid}\"\n name=\"${Icon.delete_small}\"\n ></temba-icon>\n ${isImageAttachment(validAttachment)\n ? html`<temba-thumbnail\n url=\"${validAttachment.url}\"\n ></temba-thumbnail>`\n : html`<temba-thumbnail\n label=\"${validAttachment.content_type.split('/')[1]}\"\n ></temba-thumbnail>`}\n </div>`;\n })}\n ${this.getUploader()}\n </div>\n ${this.failedAttachments.map(invalidAttachment => {\n return html` <div class=\"attachment-item error\">\n <div\n class=\"remove-item error\"\n @click=\"${this.handleRemoveFileClicked}\"\n >\n <temba-icon\n id=\"${invalidAttachment.uuid}\"\n name=\"${Icon.delete_small}\"\n ></temba-icon>\n </div>\n <div class=\"attachment-name\">\n <span\n title=\"${invalidAttachment.filename} (${formatFileSize(\n 0,\n 0\n )}) - Attachment failed - ${invalidAttachment.error}\"\n >${truncate(invalidAttachment.filename, 25)}\n (${formatFileSize(0, 0)}) - Attachment failed</span\n >\n </div>\n </div>`;\n })}`\n : null}\n `;\n }\n\n private getActions(): TemplateResult {\n const showOptins = this.optIns && this.isBaseLanguage();\n return html`\n <temba-tabs\n embedded\n focusedname\n bottom\n refresh=\"${this.currentAttachments.length}|${this.index}|${this\n .currentQuickReplies.length}|${showOptins}|${this.currentOptin}\"\n >\n ${this.attachments\n ? html`<temba-tab\n name=\"Attachments\"\n icon=\"attachment\"\n .count=${this.currentAttachments.length}\n >\n <div class=\"items attachments\">${this.getAttachments()}</div>\n </temba-tab>`\n : null}\n ${this.quickReplies\n ? html`<temba-tab\n name=\"Quick Replies\"\n icon=\"quick_replies\"\n .count=${this.currentQuickReplies.length}\n >\n <temba-select\n @change=${this.handleQuickReplyChange}\n .values=${this.currentQuickReplies}\n class=\"quick-replies\"\n tags\n multi\n searchable\n expressions\n placeholder=\"Add Quick Reply\"\n ></temba-select>\n </temba-tab>`\n : null}\n <temba-tab\n name=\"Opt-in\"\n icon=\"channel_fba\"\n ?hidden=${!showOptins}\n ?checked=${this.currentOptin.length > 0}\n >\n <temba-select\n @change=${this.handleOptInChange}\n .values=${this.currentOptin}\n endpoint=\"${this.optinEndpoint}\"\n class=\"optins\"\n searchable\n clearable\n placeholder=\"Select an opt-in to use for Facebook (optional)\"\n ></temba-select>\n </temba-tab>\n\n <div slot=\"tab-right\" class=\"top-right\">\n ${this.buttonError\n ? html`<div class=\"send-error\">${this.buttonError}</div>`\n : null}\n ${this.counter ? this.getCounter() : null}\n ${this.button ? this.getButton() : null}\n </div>\n </temba-tabs>\n `;\n }\n\n private getUploader(): TemplateResult {\n if (this.uploading) {\n return html`<temba-loading units=\"3\" size=\"12\"></temba-loading>`;\n } else {\n return this.currentAttachments.length < this.maxAttachments\n ? html`<input\n type=\"file\"\n id=\"upload-input\"\n multiple\n accept=\"${this.accept}\"\n @change=\"${this.handleUploadFileInputChanged}\"\n />\n <label\n id=\"upload-label\"\n class=\"actions-left upload-label\"\n for=\"upload-input\"\n >\n <div\n class=\"add-attachment\"\n @click=\"${this.handleUploadFileIconClicked}\"\n >\n <temba-icon name=\"add\" size=\"1.5\"></temba-icon>\n </div>\n </label>`\n : null;\n }\n }\n\n private getCounter(): TemplateResult {\n return html`<temba-charcount\n .text=\"${this.currentText}\"\n ></temba-charcount>`;\n }\n\n private getButton(): TemplateResult {\n return html` <temba-button\n id=\"send-button\"\n name=${this.buttonName}\n @click=${this.handleSendClick}\n ?disabled=${this.buttonDisabled}\n ></temba-button>`;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { CustomEventType } from '../interfaces';
|
|
5
|
-
import {
|
|
5
|
+
import { postJSON } from '../utils';
|
|
6
6
|
import { ContactStoreElement } from './ContactStoreElement';
|
|
7
7
|
const DEFAULT_REFRESH = 10000;
|
|
8
8
|
export class ContactChat extends ContactStoreElement {
|
|
@@ -46,7 +46,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
46
46
|
padding: 0.8em;
|
|
47
47
|
display: flex;
|
|
48
48
|
flex-direction: column;
|
|
49
|
-
z-index: 3;
|
|
50
49
|
border-bottom-left-radius: var(--curvature);
|
|
51
50
|
border-bottom-right-radius: var(--curvature);
|
|
52
51
|
}
|
|
@@ -97,7 +96,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
97
96
|
this.currentContact = null;
|
|
98
97
|
this.agent = '';
|
|
99
98
|
this.refreshInterval = null;
|
|
100
|
-
this.showDetails = getCookieBoolean(COOKIE_KEYS.TICKET_SHOW_DETAILS);
|
|
101
99
|
}
|
|
102
100
|
connectedCallback() {
|
|
103
101
|
super.connectedCallback();
|
|
@@ -201,12 +199,9 @@ export class ContactChat extends ContactStoreElement {
|
|
|
201
199
|
? this.getTembaContactHistory()
|
|
202
200
|
: null;
|
|
203
201
|
const chatbox = this.currentContact ? this.getTembaChatbox() : null;
|
|
204
|
-
const contactHistoryAndChatbox = html
|
|
205
|
-
style="flex-grow: 1; margin-right: 0em; display:flex; flex-direction:row; min-height: 0;"
|
|
206
|
-
class="left-pane ${this.showDetails ? 'open' : ''}"
|
|
207
|
-
>
|
|
202
|
+
const contactHistoryAndChatbox = html `
|
|
208
203
|
<div class="chat-wrapper">${contactHistory} ${chatbox}</div>
|
|
209
|
-
|
|
204
|
+
`;
|
|
210
205
|
return html `${contactHistoryAndChatbox}`;
|
|
211
206
|
}
|
|
212
207
|
getTembaContactHistory() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactChat.js","sourceRoot":"","sources":["../../../src/contacts/ContactChat.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAW,eAAe,EAAU,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,WAAY,SAAQ,mBAAmB;IAC3C,MAAM,KAAK,MAAM;QACtB,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8ET,CAAC;IACJ,CAAC;IA6BD;QACE,KAAK,EAAE,CAAC;QAxBV,qBAAgB,GAAG,uBAAuB,CAAC;QAG3C,gBAAW,GAAG,EAAE,CAAC;QAGjB,gBAAW,GAAG,IAAI,CAAC;QAGnB,YAAO,GAAG,KAAK,CAAC;QAGhB,kBAAa,GAAW,IAAI,CAAC;QAG7B,mBAAc,GAAY,IAAI,CAAC;QAG/B,UAAK,GAAG,EAAE,CAAC;QAUX,oBAAe,GAAG,IAAI,CAAC;QAHrB,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACvE,CAAC;IAIM,iBAAiB;Q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;WAG/C,CAAC;IACV,CAAC;CACF;AArNC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;+CAC7B;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACgB;AAG3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACE;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAChB","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { Contact, CustomEventType, Ticket } from '../interfaces';\nimport { COOKIE_KEYS, getCookieBoolean, postJSON } from '../utils';\nimport { ContactHistory } from './ContactHistory';\nimport { ContactStoreElement } from './ContactStoreElement';\nimport { Compose } from '../compose/Compose';\n\nconst DEFAULT_REFRESH = 10000;\n\nexport class ContactChat extends ContactStoreElement {\n public static get styles() {\n return css`\n .left-pane {\n box-shadow: -13px 10px 7px 14px rgba(0, 0, 0, 0);\n transition: box-shadow 600ms linear;\n }\n\n .left-pane.open {\n z-index: 1000;\n }\n\n :host {\n flex-grow: 1;\n display: flex;\n flex-direction: row;\n min-height: 0;\n border-radius: var(--curvature);\n }\n\n .chat-wrapper {\n display: flex;\n flex-grow: 1;\n flex-direction: column;\n background: #e9e9e9;\n\n min-height: 0;\n }\n\n temba-contact-history {\n border-bottom: 0px solid #f4f4f4;\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n\n .chatbox {\n padding: 0.8em;\n display: flex;\n flex-direction: column;\n z-index: 3;\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n }\n\n .chatbox.full {\n border-bottom-right-radius: 0 !important;\n }\n\n .closed-footer {\n padding: 1em;\n background: #f2f2f2;\n border-top: 3px solid #e1e1e1;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n a {\n color: var(--color-link-primary);\n }\n\n a:hover {\n text-decoration: underline;\n color: var(--color-link-primary-hover);\n }\n\n temba-button#reopen-button {\n --button-y: 1px;\n --button-x: 12px;\n }\n\n temba-completion {\n --widget-box-shadow: none;\n --color-widget-border: transparent;\n --widget-box-shadow-focused: none;\n --color-focus: transparent;\n --color-widget-bg-focused: transparent;\n }\n `;\n }\n\n @property({ type: String, attribute: 'ticket' })\n ticketUUID: string;\n\n @property({ type: String })\n contactsEndpoint = '/api/v2/contacts.json';\n\n @property({ type: String })\n currentNote = '';\n\n @property({ type: Boolean })\n showDetails = true;\n\n @property({ type: Boolean })\n monitor = false;\n\n @property({ type: Object })\n currentTicket: Ticket = null;\n\n @property({ type: Object })\n currentContact: Contact = null;\n\n @property({ type: String })\n agent = '';\n\n // http promise to monitor for completeness\n public httpComplete: Promise<void>;\n\n constructor() {\n super();\n this.showDetails = getCookieBoolean(COOKIE_KEYS.TICKET_SHOW_DETAILS);\n }\n\n refreshInterval = null;\n\n public connectedCallback() {\n super.connectedCallback();\n if (this.monitor) {\n this.refreshInterval = setInterval(() => {\n if (this.currentTicket && this.currentTicket.closed_on) {\n return;\n }\n this.refresh();\n }, DEFAULT_REFRESH);\n }\n }\n\n public disconnectedCallback() {\n if (this.refreshInterval) {\n clearInterval(this.refreshInterval);\n }\n }\n\n public getContactHistory(): ContactHistory {\n return this.shadowRoot.querySelector(\n 'temba-contact-history'\n ) as ContactHistory;\n }\n\n public refresh(scrollToBottom = false): void {\n const contactHistory = this.getContactHistory();\n if (contactHistory) {\n if (scrollToBottom) {\n contactHistory.scrollToBottom();\n }\n contactHistory.refresh();\n // super.refresh();\n }\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if we don't have an endpoint infer one\n if (\n changedProperties.has('data') ||\n changedProperties.has('currentContact')\n ) {\n this.currentContact = this.data;\n }\n }\n\n private handleSend(evt: CustomEvent) {\n const buttonName = evt.detail.name;\n if (buttonName === 'Send') {\n const payload = {\n contact: this.currentContact.uuid,\n };\n const compose = evt.currentTarget as Compose;\n if (compose) {\n const text = compose.currentText;\n if (text && text.length > 0) {\n payload['text'] = text;\n }\n const attachments = compose.currentAttachments;\n if (attachments && attachments.length > 0) {\n const attachment_uuids = attachments.map(\n attachment => attachment.uuid\n );\n payload['attachments'] = attachment_uuids;\n }\n }\n if (this.currentTicket) {\n payload['ticket'] = this.currentTicket.uuid;\n }\n\n const genericError = buttonName + ' failed, please try again.';\n\n postJSON(`/api/v2/messages.json`, payload)\n .then(response => {\n if (response.status < 400) {\n compose.reset();\n this.refresh(true);\n this.fireCustomEvent(CustomEventType.MessageSent, { msg: payload });\n } else if (response.status < 500) {\n if (\n response.json.text &&\n response.json.text.length > 0 &&\n response.json.text[0].length > 0\n ) {\n let textError = response.json.text[0];\n textError = textError.replace(\n 'Ensure this field has no more than',\n 'Maximum allowed text is'\n );\n compose.buttonError = textError;\n } else if (\n response.json.attachments &&\n response.json.attachments.length > 0 &&\n response.json.attachments[0].length > 0\n ) {\n let attachmentError = response.json.attachments[0];\n attachmentError = attachmentError\n .replace(\n 'Ensure this field has no more than',\n 'Maximum allowed attachments is'\n )\n .replace('elements', 'files');\n compose.buttonError = attachmentError;\n } else {\n compose.buttonError = genericError;\n }\n } else {\n compose.buttonError = genericError;\n }\n })\n .catch(error => {\n console.error(error);\n compose.buttonError = genericError;\n });\n }\n }\n\n public render(): TemplateResult {\n const contactHistory = this.currentContact\n ? this.getTembaContactHistory()\n : null;\n const chatbox = this.currentContact ? this.getTembaChatbox() : null;\n\n const contactHistoryAndChatbox = html`<div\n style=\"flex-grow: 1; margin-right: 0em; display:flex; flex-direction:row; min-height: 0;\"\n class=\"left-pane ${this.showDetails ? 'open' : ''}\"\n >\n <div class=\"chat-wrapper\">${contactHistory} ${chatbox}</div>\n </div>`;\n return html`${contactHistoryAndChatbox}`;\n }\n\n private getTembaContactHistory(): TemplateResult {\n return html` <temba-contact-history\n .uuid=${this.currentContact.uuid}\n .contact=${this.currentContact}\n .ticket=${this.currentTicket ? this.currentTicket.uuid : null}\n .endDate=${this.currentTicket ? this.currentTicket.closed_on : null}\n .agent=${this.agent}\n >\n </temba-contact-history>`;\n }\n\n private getTembaChatbox(): TemplateResult {\n if (this.currentTicket) {\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n if (!this.currentTicket.closed_on) {\n //chatbox for active contacts with an open ticket\n return this.getChatbox();\n } else {\n return null;\n }\n }\n }\n\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n //chatbox for active contacts\n return this.getChatbox();\n }\n }\n\n private getChatbox(): TemplateResult {\n return html`<div class=\"chatbox\">\n <temba-compose\n chatbox\n attachments\n counter\n button\n @temba-button-clicked=${this.handleSend.bind(this)}\n >\n </temba-compose>\n </div>`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContactChat.js","sourceRoot":"","sources":["../../../src/contacts/ContactChat.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAW,eAAe,EAAU,MAAM,eAAe,CAAC;AACjE,OAAO,EAAiC,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,WAAY,SAAQ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iDAAiD;oBACjD,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;iBAC1B;qBAAM;oBACL,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,QAAQ,EAAE;YAClE,uDAAuD;YACvD,OAAO,IAAI,CAAC;SACb;aAAM;YACL,6BAA6B;YAC7B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;SAC1B;IACH,CAAC;IAEO,UAAU;QAChB,OAAO,IAAI,CAAA;;;;;;gCAMiB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;;WAG/C,CAAC;IACV,CAAC;CACF;AAjNC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;+CAC7B;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACgB;AAG3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACE;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAChB","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { Contact, CustomEventType, Ticket } from '../interfaces';\nimport { COOKIE_KEYS, getCookieBoolean, postJSON } from '../utils';\nimport { ContactHistory } from './ContactHistory';\nimport { ContactStoreElement } from './ContactStoreElement';\nimport { Compose } from '../compose/Compose';\n\nconst DEFAULT_REFRESH = 10000;\n\nexport class ContactChat extends ContactStoreElement {\n public static get styles() {\n return css`\n .left-pane {\n box-shadow: -13px 10px 7px 14px rgba(0, 0, 0, 0);\n transition: box-shadow 600ms linear;\n }\n\n .left-pane.open {\n z-index: 1000;\n }\n\n :host {\n flex-grow: 1;\n display: flex;\n flex-direction: row;\n min-height: 0;\n border-radius: var(--curvature);\n }\n\n .chat-wrapper {\n display: flex;\n flex-grow: 1;\n flex-direction: column;\n background: #e9e9e9;\n\n min-height: 0;\n }\n\n temba-contact-history {\n border-bottom: 0px solid #f4f4f4;\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n\n .chatbox {\n padding: 0.8em;\n display: flex;\n flex-direction: column;\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n }\n\n .chatbox.full {\n border-bottom-right-radius: 0 !important;\n }\n\n .closed-footer {\n padding: 1em;\n background: #f2f2f2;\n border-top: 3px solid #e1e1e1;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n a {\n color: var(--color-link-primary);\n }\n\n a:hover {\n text-decoration: underline;\n color: var(--color-link-primary-hover);\n }\n\n temba-button#reopen-button {\n --button-y: 1px;\n --button-x: 12px;\n }\n\n temba-completion {\n --widget-box-shadow: none;\n --color-widget-border: transparent;\n --widget-box-shadow-focused: none;\n --color-focus: transparent;\n --color-widget-bg-focused: transparent;\n }\n `;\n }\n\n @property({ type: String, attribute: 'ticket' })\n ticketUUID: string;\n\n @property({ type: String })\n contactsEndpoint = '/api/v2/contacts.json';\n\n @property({ type: String })\n currentNote = '';\n\n @property({ type: Boolean })\n showDetails = true;\n\n @property({ type: Boolean })\n monitor = false;\n\n @property({ type: Object })\n currentTicket: Ticket = null;\n\n @property({ type: Object })\n currentContact: Contact = null;\n\n @property({ type: String })\n agent = '';\n\n // http promise to monitor for completeness\n public httpComplete: Promise<void>;\n\n constructor() {\n super();\n }\n\n refreshInterval = null;\n\n public connectedCallback() {\n super.connectedCallback();\n if (this.monitor) {\n this.refreshInterval = setInterval(() => {\n if (this.currentTicket && this.currentTicket.closed_on) {\n return;\n }\n this.refresh();\n }, DEFAULT_REFRESH);\n }\n }\n\n public disconnectedCallback() {\n if (this.refreshInterval) {\n clearInterval(this.refreshInterval);\n }\n }\n\n public getContactHistory(): ContactHistory {\n return this.shadowRoot.querySelector(\n 'temba-contact-history'\n ) as ContactHistory;\n }\n\n public refresh(scrollToBottom = false): void {\n const contactHistory = this.getContactHistory();\n if (contactHistory) {\n if (scrollToBottom) {\n contactHistory.scrollToBottom();\n }\n contactHistory.refresh();\n // super.refresh();\n }\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if we don't have an endpoint infer one\n if (\n changedProperties.has('data') ||\n changedProperties.has('currentContact')\n ) {\n this.currentContact = this.data;\n }\n }\n\n private handleSend(evt: CustomEvent) {\n const buttonName = evt.detail.name;\n if (buttonName === 'Send') {\n const payload = {\n contact: this.currentContact.uuid,\n };\n const compose = evt.currentTarget as Compose;\n if (compose) {\n const text = compose.currentText;\n if (text && text.length > 0) {\n payload['text'] = text;\n }\n const attachments = compose.currentAttachments;\n if (attachments && attachments.length > 0) {\n const attachment_uuids = attachments.map(\n attachment => attachment.uuid\n );\n payload['attachments'] = attachment_uuids;\n }\n }\n if (this.currentTicket) {\n payload['ticket'] = this.currentTicket.uuid;\n }\n\n const genericError = buttonName + ' failed, please try again.';\n\n postJSON(`/api/v2/messages.json`, payload)\n .then(response => {\n if (response.status < 400) {\n compose.reset();\n this.refresh(true);\n this.fireCustomEvent(CustomEventType.MessageSent, { msg: payload });\n } else if (response.status < 500) {\n if (\n response.json.text &&\n response.json.text.length > 0 &&\n response.json.text[0].length > 0\n ) {\n let textError = response.json.text[0];\n textError = textError.replace(\n 'Ensure this field has no more than',\n 'Maximum allowed text is'\n );\n compose.buttonError = textError;\n } else if (\n response.json.attachments &&\n response.json.attachments.length > 0 &&\n response.json.attachments[0].length > 0\n ) {\n let attachmentError = response.json.attachments[0];\n attachmentError = attachmentError\n .replace(\n 'Ensure this field has no more than',\n 'Maximum allowed attachments is'\n )\n .replace('elements', 'files');\n compose.buttonError = attachmentError;\n } else {\n compose.buttonError = genericError;\n }\n } else {\n compose.buttonError = genericError;\n }\n })\n .catch(error => {\n console.error(error);\n compose.buttonError = genericError;\n });\n }\n }\n\n public render(): TemplateResult {\n const contactHistory = this.currentContact\n ? this.getTembaContactHistory()\n : null;\n const chatbox = this.currentContact ? this.getTembaChatbox() : null;\n\n const contactHistoryAndChatbox = html`\n <div class=\"chat-wrapper\">${contactHistory} ${chatbox}</div>\n `;\n return html`${contactHistoryAndChatbox}`;\n }\n\n private getTembaContactHistory(): TemplateResult {\n return html` <temba-contact-history\n .uuid=${this.currentContact.uuid}\n .contact=${this.currentContact}\n .ticket=${this.currentTicket ? this.currentTicket.uuid : null}\n .endDate=${this.currentTicket ? this.currentTicket.closed_on : null}\n .agent=${this.agent}\n >\n </temba-contact-history>`;\n }\n\n private getTembaChatbox(): TemplateResult {\n if (this.currentTicket) {\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n if (!this.currentTicket.closed_on) {\n //chatbox for active contacts with an open ticket\n return this.getChatbox();\n } else {\n return null;\n }\n }\n }\n\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n //chatbox for active contacts\n return this.getChatbox();\n }\n }\n\n private getChatbox(): TemplateResult {\n return html`<div class=\"chatbox\">\n <temba-compose\n chatbox\n attachments\n counter\n button\n @temba-button-clicked=${this.handleSend.bind(this)}\n >\n </temba-compose>\n </div>`;\n }\n}\n"]}
|
|
@@ -973,6 +973,7 @@ export const renderOptinRequested = (event) => {
|
|
|
973
973
|
</div>`;
|
|
974
974
|
};
|
|
975
975
|
export const renderChannelEvent = (event) => {
|
|
976
|
+
var _a, _b;
|
|
976
977
|
let eventMessage = '';
|
|
977
978
|
let icon = Icon.call;
|
|
978
979
|
if (event.event.type === 'mt_miss') {
|
|
@@ -1011,12 +1012,12 @@ export const renderChannelEvent = (event) => {
|
|
|
1011
1012
|
}
|
|
1012
1013
|
else if (event.event.type == 'optin') {
|
|
1013
1014
|
eventMessage = html `Opted in to
|
|
1014
|
-
<span class="attn">${event.event.optin.name}</span>`;
|
|
1015
|
+
<span class="attn">${(_a = event.event.optin) === null || _a === void 0 ? void 0 : _a.name}</span>`;
|
|
1015
1016
|
icon = Icon.optin;
|
|
1016
1017
|
}
|
|
1017
1018
|
else if (event.event.type == 'optout') {
|
|
1018
1019
|
eventMessage = html `Opted out of
|
|
1019
|
-
<span class="attn">${event.event.optin.name}</span>`;
|
|
1020
|
+
<span class="attn">${(_b = event.event.optin) === null || _b === void 0 ? void 0 : _b.name}</span>`;
|
|
1020
1021
|
icon = Icon.optout;
|
|
1021
1022
|
}
|
|
1022
1023
|
return html `<temba-icon name="${icon}"></temba-icon>
|