@nyaruka/temba-components 0.44.0 → 0.46.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 +15 -0
- package/dist/{70a627f4.js → 041a136a.js} +174 -316
- package/dist/index.js +174 -316
- 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/button/Button.js +10 -0
- package/out-tsc/src/button/Button.js.map +1 -1
- package/out-tsc/src/completion/Completion.js +3 -0
- package/out-tsc/src/completion/Completion.js.map +1 -1
- package/out-tsc/src/completion/helpers.js +3 -0
- package/out-tsc/src/completion/helpers.js.map +1 -1
- package/out-tsc/src/contacts/ContactChat.js +8 -201
- package/out-tsc/src/contacts/ContactChat.js.map +1 -1
- package/out-tsc/src/contacts/ContactFields.js +1 -1
- package/out-tsc/src/contacts/ContactFields.js.map +1 -1
- package/out-tsc/src/contacts/ContactHistory.js +5 -111
- package/out-tsc/src/contacts/ContactHistory.js.map +1 -1
- package/out-tsc/src/contacts/ContactNameFetch.js +2 -1
- package/out-tsc/src/contacts/ContactNameFetch.js.map +1 -1
- package/out-tsc/src/contacts/ContactTickets.js +99 -17
- package/out-tsc/src/contacts/ContactTickets.js.map +1 -1
- package/out-tsc/src/contacts/events.js +28 -46
- package/out-tsc/src/contacts/events.js.map +1 -1
- package/out-tsc/src/date/TembaDate.js +4 -1
- package/out-tsc/src/date/TembaDate.js.map +1 -1
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/list/TembaList.js +0 -1
- package/out-tsc/src/list/TembaList.js.map +1 -1
- package/out-tsc/src/list/TembaMenu.js +1 -6
- package/out-tsc/src/list/TembaMenu.js.map +1 -1
- package/out-tsc/src/options/Options.js +6 -2
- package/out-tsc/src/options/Options.js.map +1 -1
- package/out-tsc/src/store/Store.js +32 -1
- package/out-tsc/src/store/Store.js.map +1 -1
- package/out-tsc/src/store/StoreElement.js +26 -5
- package/out-tsc/src/store/StoreElement.js.map +1 -1
- package/out-tsc/src/utils/index.js +16 -6
- package/out-tsc/src/utils/index.js.map +1 -1
- package/out-tsc/src/vectoricon/index.js +1 -1
- package/out-tsc/src/vectoricon/index.js.map +1 -1
- package/out-tsc/test/temba-contact-chat.test.js +0 -105
- package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
- package/out-tsc/test/temba-store.test.js +1 -1
- package/out-tsc/test/temba-store.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +2 -2
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/contacts/badges.png +0 -0
- package/screenshots/truth/contacts/compose-attachments-no-text-failure.png +0 -0
- package/screenshots/truth/contacts/compose-attachments-no-text-success.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-attachments.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-generic.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-text.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-success.png +0 -0
- package/screenshots/truth/contacts/compose-text-no-attachments-failure.png +0 -0
- package/screenshots/truth/contacts/compose-text-no-attachments-success.png +0 -0
- package/screenshots/truth/contacts/contact-active-default.png +0 -0
- package/screenshots/truth/contacts/contact-active-show-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-archived-hide-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-blocked-hide-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-stopped-hide-chatbox.png +0 -0
- package/screenshots/truth/contacts/history.png +0 -0
- package/src/button/Button.ts +10 -0
- package/src/completion/Completion.ts +3 -0
- package/src/completion/helpers.ts +4 -0
- package/src/contacts/ContactChat.ts +8 -214
- package/src/contacts/ContactFields.ts +1 -1
- package/src/contacts/ContactHistory.ts +7 -129
- package/src/contacts/ContactNameFetch.ts +2 -1
- package/src/contacts/ContactTickets.ts +99 -19
- package/src/contacts/events.ts +28 -47
- package/src/date/TembaDate.ts +7 -1
- package/src/interfaces.ts +1 -1
- package/src/list/TembaList.ts +0 -2
- package/src/list/TembaMenu.ts +1 -6
- package/src/options/Options.ts +8 -2
- package/src/store/Store.ts +34 -2
- package/src/store/StoreElement.ts +22 -6
- package/src/utils/index.ts +14 -6
- package/src/vectoricon/index.ts +1 -1
- package/test/temba-contact-chat.test.ts +0 -141
- package/test/temba-store.test.ts +1 -1
- package/test/utils.test.ts +2 -2
- package/screenshots/truth/contacts/contact-active-ticket-closed-show-reopen-button.png +0 -0
- package/screenshots/truth/contacts/contact-active-ticket-open-show-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-archived-ticket-closed-hide-chatbox.png +0 -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 i=e||("document"in self?document.currentScript.src:"")||location.href;if(t[i])return;let r={};const l=e=>o(e,i),
|
|
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 i=e||("document"in self?document.currentScript.src:"")||location.href;if(t[i])return;let r={};const l=e=>o(e,i),f={module:{uri:i},exports:r,require:l};t[i]=Promise.all(n.map((e=>f[e]||l(e)))).then((e=>(s(...e),r)))}}define(["./workbox-919adfb7"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"041a136a.js",revision:"aff6ee4042394b36cd3b90fab4441403"},{url:"templates/components-body.html",revision:"1f8f52ccde63fce8eb1dd523e501ff57"},{url:"templates/components-head.html",revision:"88f90114b613458d968ac323b1d56af1"}],{}),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/4f3aa99fd9d4de0a533bbe20291f5b64/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/runner/work/temba-components/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\": \"041a136a.js\",\n \"revision\": \"aff6ee4042394b36cd3b90fab4441403\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"1f8f52ccde63fce8eb1dd523e501ff57\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"88f90114b613458d968ac323b1d56af1\"\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/041a136a.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.46.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/041a136a.js" crossorigin="anonymous">
|
|
@@ -15,6 +15,12 @@ export class Button extends LitElement {
|
|
|
15
15
|
font-weight: 400;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
.small {
|
|
19
|
+
font-size: 0.8em;
|
|
20
|
+
--button-y: 0px;
|
|
21
|
+
--button-x: 0.5em;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
.v-2.button-container {
|
|
19
25
|
background: var(--button-bg);
|
|
20
26
|
background-image: var(--button-bg-img);
|
|
@@ -193,6 +199,7 @@ export class Button extends LitElement {
|
|
|
193
199
|
'attention-button': this.attention,
|
|
194
200
|
'destructive-button': this.destructive,
|
|
195
201
|
'light-button': this.light,
|
|
202
|
+
small: this.small,
|
|
196
203
|
})}"
|
|
197
204
|
tabindex="0"
|
|
198
205
|
@mousedown=${this.handleMouseDown}
|
|
@@ -238,6 +245,9 @@ __decorate([
|
|
|
238
245
|
__decorate([
|
|
239
246
|
property({ type: Boolean })
|
|
240
247
|
], Button.prototype, "active", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
property({ type: Boolean })
|
|
250
|
+
], Button.prototype, "small", void 0);
|
|
241
251
|
__decorate([
|
|
242
252
|
property({ type: String })
|
|
243
253
|
], Button.prototype, "href", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/button/Button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,OAAO,MAAO,SAAQ,UAAU;IAAtC;;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/button/Button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,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C,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qCACb;AAGf;IADC,QAAQ,EAAE;oCACE;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACR;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qCACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACd","sourcesContent":["import { LitElement, TemplateResult, html, css } from 'lit';\nimport { getClasses } from '../utils';\n\nimport { property } from 'lit/decorators.js';\n\nexport class Button extends LitElement {\n static get styles() {\n return css`\n :host {\n display: inline-block;\n font-family: var(--font-family);\n font-weight: 400;\n }\n\n .small {\n font-size: 0.8em;\n --button-y: 0px;\n --button-x: 0.5em;\n }\n\n .v-2.button-container {\n background: var(--button-bg);\n background-image: var(--button-bg-img);\n color: var(--button-text);\n box-shadow: var(--button-shadow);\n transition: all calc(var(--transition-speed) / 2) ease-in;\n }\n\n .button-container {\n color: #fff;\n cursor: pointer;\n display: block;\n border-radius: var(--curvature);\n outline: none;\n transition: background ease-in var(--transition-speed);\n user-select: none;\n -webkit-user-select: none;\n text-align: center;\n }\n\n .button-name {\n white-space: nowrap;\n }\n\n .secondary-button:hover .button-mask {\n border: 1px solid var(--color-button-secondary);\n }\n\n .button-mask:hover {\n background: rgba(0, 0, 0, 0.05);\n }\n\n .button-container:focus {\n outline: none;\n margin: 0;\n }\n\n .button-container:focus {\n box-shadow: var(--widget-box-shadow-focused);\n }\n\n .button-container.secondary-button:focus .button-mask {\n background: transparent;\n }\n\n .button-mask {\n padding: var(--button-y) var(--button-x);\n border-radius: var(--curvature);\n border: 1px solid transparent;\n transition: var(--transition-speed);\n background: var(--button-mask);\n }\n\n .button-container.disabled-button {\n background: rgba(0, 0, 0, 0.05);\n color: rgba(255, 255, 255, 0.45);\n cursor: default;\n }\n\n .button-container.disabled-button .button-mask {\n box-shadow: 0 0 0px 1px var(--color-button-disabled);\n }\n\n .button-container.disabled-button:hover .button-mask {\n box-shadow: 0 0 0px 1px var(--color-button-disabled);\n background: rgba(0, 0, 0, 0.05);\n }\n\n .button-container.active-button .button-mask {\n }\n\n .secondary-button.active-button {\n background: transparent;\n color: var(--color-text);\n }\n\n .secondary-button.active-button .button-mask {\n border: none;\n }\n\n .button-container.secondary-button.active-button:focus .button-mask {\n background: transparent;\n box-shadow: none;\n }\n\n .primary-button {\n background: var(--color-button-primary);\n color: var(--color-button-primary-text);\n }\n\n .light-button {\n background: var(--color-button-light);\n color: var(--color-button-light-text);\n }\n\n .attention-button {\n background: var(--color-button-attention);\n color: var(--color-button-primary-text);\n }\n\n .secondary-button {\n background: transparent;\n color: var(--color-text);\n font-weight: 300;\n }\n\n .destructive-button {\n background: var(--color-button-destructive);\n color: var(--color-button-destructive-text);\n }\n\n .button-mask.disabled-button {\n background: rgba(0, 0, 0, 0.1);\n }\n\n .secondary-button .button-mask:hover {\n background: transparent;\n }\n\n .submit-animation {\n padding: 1px 4px;\n }\n\n .submit-animation temba-loading {\n margin-bottom: -3px;\n line-height: normal;\n }\n `;\n }\n\n @property({ type: Boolean })\n primary: boolean;\n\n @property({ type: Boolean })\n secondary: boolean;\n\n @property({ type: Boolean })\n attention: boolean;\n\n @property({ type: Number })\n v = 1;\n\n @property({ type: Boolean })\n destructive: boolean;\n\n @property({ type: Boolean })\n light: boolean;\n\n @property()\n name: string;\n\n @property({ type: Boolean })\n disabled: boolean;\n\n @property({ type: Boolean })\n submitting: boolean;\n\n @property({ type: Boolean })\n active: boolean;\n\n @property({ type: Boolean })\n small: boolean;\n\n @property({ type: String })\n href: string;\n\n private handleClick(evt: MouseEvent) {\n if (this.disabled) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n\n if (this.href && !this.disabled) {\n this.ownerDocument.location.href = this.href;\n evt.preventDefault();\n evt.stopPropagation();\n }\n }\n\n private handleKeyUp(event: KeyboardEvent): void {\n this.active = false;\n if (event.key === 'Enter') {\n this.click();\n }\n }\n\n private handleMouseDown(): void {\n if (!this.disabled && !this.submitting) {\n this.active = true;\n this.classList.add('active');\n }\n }\n\n private handleMouseUp(): void {\n this.active = false;\n this.classList.remove('active');\n }\n\n public render(): TemplateResult {\n const buttonName = this.submitting\n ? html`<div class=\"submit-animation\">\n <temba-loading units=\"3\" size=\"8\" color=\"#eee\"></temba-loading>\n </div>`\n : this.name;\n\n return html`\n <div\n class=\"button-container \n v-${this.v}\n ${getClasses({\n 'primary-button':\n this.primary ||\n (!this.primary &&\n !this.secondary &&\n !this.attention &&\n this.v == 1),\n 'secondary-button': this.secondary,\n 'disabled-button': this.disabled,\n 'active-button': this.active,\n 'attention-button': this.attention,\n 'destructive-button': this.destructive,\n 'light-button': this.light,\n small: this.small,\n })}\"\n tabindex=\"0\"\n @mousedown=${this.handleMouseDown}\n @mouseup=${this.handleMouseUp}\n @mouseleave=${this.handleMouseUp}\n @keyup=${this.handleKeyUp}\n @click=${this.handleClick}\n >\n <div class=\"button-mask\">\n <div class=\"button-name\">${buttonName}</div>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -114,6 +114,9 @@ export class Completion extends FormElement {
|
|
|
114
114
|
}
|
|
115
115
|
executeQuery(ele) {
|
|
116
116
|
const store = document.querySelector('temba-store');
|
|
117
|
+
if (!ele.inputElement) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
117
120
|
const result = executeCompletionQuery(ele.inputElement, store, this.session);
|
|
118
121
|
this.query = result.query;
|
|
119
122
|
this.options = result.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Completion.js","sourceRoot":"","sources":["../../../src/completion/Completion.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AA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it-html/directives/if-defined.js';\nimport { TextInput } from '../textinput/TextInput';\nimport {\n renderCompletionOption,\n updateInputElementWithCompletion,\n executeCompletionQuery,\n} from './helpers';\n\nimport { FormElement } from '../FormElement';\nimport { CompletionOption, Position } from '../interfaces';\nimport { Store } from '../store/Store';\nimport { styleMap } from 'lit-html/directives/style-map.js';\n\n/**\n * Completion is a text input that handles excellent completion options in a popup\n */\nexport class Completion extends FormElement {\n static get styles() {\n return css`\n :host {\n display: block;\n }\n\n temba-options {\n --widget-box-shadow-focused: 0 0 4px rgba(0, 0, 0, 0.15);\n --color-focus: #e6e6e6;\n }\n\n .comp-container {\n position: relative;\n height: 100%;\n }\n\n #anchor {\n /* background: rgba(132, 40, 158, .1); */\n position: absolute;\n visibility: hidden;\n width: 250px;\n height: 20px;\n }\n\n .fn-marker {\n font-weight: bold;\n font-size: 42px;\n }\n\n .option-slot {\n background: #fff;\n }\n\n .current-fn {\n padding: 10px;\n margin: 5px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n border-radius: var(--curvature-widget);\n font-size: 90%;\n }\n\n .footer {\n padding: 5px 10px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n font-size: 80%;\n border-bottom-left-radius: var(--curvature-widget);\n border-bottom-right-radius: var(--curvature-widget);\n }\n\n code {\n background: rgba(0, 0, 0, 0.1);\n padding: 1px 5px;\n border-radius: var(--curvature);\n }\n `;\n }\n\n @property({ type: Boolean })\n session: boolean;\n\n @property({ type: Boolean })\n submitOnEnter = false;\n\n @property({ type: Object })\n anchorPosition: Position = { left: 0, top: 0 };\n\n @property({ attribute: false })\n currentFunction: CompletionOption;\n\n @property({ type: String })\n placeholder = '';\n\n @property({ attribute: false })\n textInputElement: TextInput;\n\n @property({ attribute: false })\n anchorElement: HTMLDivElement;\n\n @property({ type: Array })\n options: any[] = [];\n\n @property({ type: String })\n name = '';\n\n @property({ type: String })\n value = '';\n\n @property({ type: Boolean })\n textarea: boolean;\n\n @property({ type: Boolean })\n gsm: boolean;\n\n @property({ type: String })\n counter: string;\n\n @property({ type: Boolean })\n autogrow = false;\n\n private hiddenElement: HTMLInputElement;\n private query: string;\n\n public firstUpdated() {\n this.textInputElement = this.shadowRoot.querySelector(\n 'temba-textinput'\n ) as TextInput;\n this.anchorElement = this.shadowRoot.querySelector('#anchor');\n\n // create our hidden container so it gets included in our host element's form\n this.hiddenElement = document.createElement('input');\n this.hiddenElement.setAttribute('type', 'hidden');\n this.hiddenElement.setAttribute('name', this.getAttribute('name'));\n this.hiddenElement.setAttribute('value', this.getAttribute('value') || '');\n this.appendChild(this.hiddenElement);\n }\n\n private handleKeyUp(evt: KeyboardEvent) {\n // if we have options, ignore keys that are meant for them\n if (this.options && this.options.length > 0) {\n if (evt.key === 'ArrowUp' || evt.key === 'ArrowDown') {\n return;\n }\n\n if (evt.ctrlKey) {\n if (evt.key === 'n' || evt.key === 'p') {\n return;\n }\n }\n\n if (\n evt.key === 'Enter' ||\n evt.key === 'Escape' ||\n evt.key === 'Tab' ||\n evt.key.startsWith('Control')\n ) {\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n\n this.executeQuery(evt.currentTarget as TextInput);\n }\n }\n\n public hasVisibleOptions() {\n return this.options.length > 0;\n }\n\n private executeQuery(ele: TextInput) {\n const store: Store = document.querySelector('temba-store');\n const result = executeCompletionQuery(\n ele.inputElement,\n store,\n this.session\n );\n\n this.query = result.query;\n this.options = result.options;\n this.anchorPosition = result.anchorPosition;\n }\n\n private handleClick(evt: MouseEvent) {\n this.executeQuery(evt.currentTarget as TextInput);\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if our cursor changed, lets make sure our scrollbox is showing it\n if (changedProperties.has('value')) {\n this.hiddenElement.setAttribute('value', this.value);\n }\n }\n\n private handleInput(evt: KeyboardEvent) {\n const ele = evt.currentTarget as TextInput;\n this.executeQuery(ele);\n this.value = ele.inputElement.value;\n this.fireEvent('change');\n }\n\n private handleOptionCanceled() {\n // delay in case we are actively selecting\n window.setTimeout(() => {\n this.options = [];\n this.query = '';\n }, 100);\n }\n\n private handleOptionSelection(evt: CustomEvent) {\n const option = evt.detail.selected as CompletionOption;\n const tabbed = evt.detail.tabbed;\n\n updateInputElementWithCompletion(\n this.query,\n this.textInputElement.inputElement,\n option\n );\n this.query = '';\n this.options = [];\n\n if (tabbed) {\n this.executeQuery(this.textInputElement);\n }\n }\n\n public click() {\n super.click();\n const input = this.shadowRoot.querySelector('temba-textinput') as TextInput;\n if (input) {\n input.click();\n }\n }\n\n public render(): TemplateResult {\n const anchorStyles = this.anchorPosition\n ? {\n top: `${this.anchorPosition.top}px`,\n left: `${this.anchorPosition.left}px`,\n }\n : {};\n\n return html`\n <temba-field\n name=${this.name}\n .label=${this.label}\n .helpText=${this.helpText}\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n >\n <div class=\"comp-container\">\n <div id=\"anchor\" style=${styleMap(anchorStyles)}></div>\n <temba-textinput\n name=${this.name}\n placeholder=${this.placeholder}\n gsm=${this.gsm}\n counter=${ifDefined(this.counter)}\n @keyup=${this.handleKeyUp}\n @click=${this.handleClick}\n @input=${this.handleInput}\n @blur=${this.handleOptionCanceled}\n .value=${this.value}\n ?autogrow=${this.autogrow}\n ?textarea=${this.textarea}\n ?submitOnEnter=${this.submitOnEnter}\n >\n </temba-textinput>\n <temba-options\n @temba-selection=${this.handleOptionSelection}\n @temba-canceled=${this.handleOptionCanceled}\n .renderOption=${renderCompletionOption}\n .anchorTo=${this.anchorElement}\n .options=${this.options}\n ?visible=${this.options && this.options.length > 0}\n >\n ${this.currentFunction\n ? html`\n <div class=\"current-fn\">\n ${renderCompletionOption(this.currentFunction, true)}\n </div>\n `\n : null}\n <div class=\"footer\">Tab to complete, enter to select</div>\n </temba-options>\n </div>\n </temba-field>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Completion.js","sourceRoot":"","sources":["../../../src/completion/Completion.ts"],"names":[],"mappings":";AAAA,OAA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,IAAI,EAAE,OAAO,EAAE,CAAC;4CACX","sourcesContent":["import { TemplateResult, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit-html/directives/if-defined.js';\nimport { TextInput } from '../textinput/TextInput';\nimport {\n renderCompletionOption,\n updateInputElementWithCompletion,\n executeCompletionQuery,\n} from './helpers';\n\nimport { FormElement } from '../FormElement';\nimport { CompletionOption, Position } from '../interfaces';\nimport { Store } from '../store/Store';\nimport { styleMap } from 'lit-html/directives/style-map.js';\n\n/**\n * Completion is a text input that handles excellent completion options in a popup\n */\nexport class Completion extends FormElement {\n static get styles() {\n return css`\n :host {\n display: block;\n }\n\n temba-options {\n --widget-box-shadow-focused: 0 0 4px rgba(0, 0, 0, 0.15);\n --color-focus: #e6e6e6;\n }\n\n .comp-container {\n position: relative;\n height: 100%;\n }\n\n #anchor {\n /* background: rgba(132, 40, 158, .1); */\n position: absolute;\n visibility: hidden;\n width: 250px;\n height: 20px;\n }\n\n .fn-marker {\n font-weight: bold;\n font-size: 42px;\n }\n\n .option-slot {\n background: #fff;\n }\n\n .current-fn {\n padding: 10px;\n margin: 5px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n border-radius: var(--curvature-widget);\n font-size: 90%;\n }\n\n .footer {\n padding: 5px 10px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n font-size: 80%;\n border-bottom-left-radius: var(--curvature-widget);\n border-bottom-right-radius: var(--curvature-widget);\n }\n\n code {\n background: rgba(0, 0, 0, 0.1);\n padding: 1px 5px;\n border-radius: var(--curvature);\n }\n `;\n }\n\n @property({ type: Boolean })\n session: boolean;\n\n @property({ type: Boolean })\n submitOnEnter = false;\n\n @property({ type: Object })\n anchorPosition: Position = { left: 0, top: 0 };\n\n @property({ attribute: false })\n currentFunction: CompletionOption;\n\n @property({ type: String })\n placeholder = '';\n\n @property({ attribute: false })\n textInputElement: TextInput;\n\n @property({ attribute: false })\n anchorElement: HTMLDivElement;\n\n @property({ type: Array })\n options: any[] = [];\n\n @property({ type: String })\n name = '';\n\n @property({ type: String })\n value = '';\n\n @property({ type: Boolean })\n textarea: boolean;\n\n @property({ type: Boolean })\n gsm: boolean;\n\n @property({ type: String })\n counter: string;\n\n @property({ type: Boolean })\n autogrow = false;\n\n private hiddenElement: HTMLInputElement;\n private query: string;\n\n public firstUpdated() {\n this.textInputElement = this.shadowRoot.querySelector(\n 'temba-textinput'\n ) as TextInput;\n this.anchorElement = this.shadowRoot.querySelector('#anchor');\n\n // create our hidden container so it gets included in our host element's form\n this.hiddenElement = document.createElement('input');\n this.hiddenElement.setAttribute('type', 'hidden');\n this.hiddenElement.setAttribute('name', this.getAttribute('name'));\n this.hiddenElement.setAttribute('value', this.getAttribute('value') || '');\n this.appendChild(this.hiddenElement);\n }\n\n private handleKeyUp(evt: KeyboardEvent) {\n // if we have options, ignore keys that are meant for them\n if (this.options && this.options.length > 0) {\n if (evt.key === 'ArrowUp' || evt.key === 'ArrowDown') {\n return;\n }\n\n if (evt.ctrlKey) {\n if (evt.key === 'n' || evt.key === 'p') {\n return;\n }\n }\n\n if (\n evt.key === 'Enter' ||\n evt.key === 'Escape' ||\n evt.key === 'Tab' ||\n evt.key.startsWith('Control')\n ) {\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n\n this.executeQuery(evt.currentTarget as TextInput);\n }\n }\n\n public hasVisibleOptions() {\n return this.options.length > 0;\n }\n\n private executeQuery(ele: TextInput) {\n const store: Store = document.querySelector('temba-store');\n if (!ele.inputElement) {\n return;\n }\n const result = executeCompletionQuery(\n ele.inputElement,\n store,\n this.session\n );\n\n this.query = result.query;\n this.options = result.options;\n this.anchorPosition = result.anchorPosition;\n }\n\n private handleClick(evt: MouseEvent) {\n this.executeQuery(evt.currentTarget as TextInput);\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if our cursor changed, lets make sure our scrollbox is showing it\n if (changedProperties.has('value')) {\n this.hiddenElement.setAttribute('value', this.value);\n }\n }\n\n private handleInput(evt: KeyboardEvent) {\n const ele = evt.currentTarget as TextInput;\n this.executeQuery(ele);\n this.value = ele.inputElement.value;\n this.fireEvent('change');\n }\n\n private handleOptionCanceled() {\n // delay in case we are actively selecting\n window.setTimeout(() => {\n this.options = [];\n this.query = '';\n }, 100);\n }\n\n private handleOptionSelection(evt: CustomEvent) {\n const option = evt.detail.selected as CompletionOption;\n const tabbed = evt.detail.tabbed;\n\n updateInputElementWithCompletion(\n this.query,\n this.textInputElement.inputElement,\n option\n );\n this.query = '';\n this.options = [];\n\n if (tabbed) {\n this.executeQuery(this.textInputElement);\n }\n }\n\n public click() {\n super.click();\n const input = this.shadowRoot.querySelector('temba-textinput') as TextInput;\n if (input) {\n input.click();\n }\n }\n\n public render(): TemplateResult {\n const anchorStyles = this.anchorPosition\n ? {\n top: `${this.anchorPosition.top}px`,\n left: `${this.anchorPosition.left}px`,\n }\n : {};\n\n return html`\n <temba-field\n name=${this.name}\n .label=${this.label}\n .helpText=${this.helpText}\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n >\n <div class=\"comp-container\">\n <div id=\"anchor\" style=${styleMap(anchorStyles)}></div>\n <temba-textinput\n name=${this.name}\n placeholder=${this.placeholder}\n gsm=${this.gsm}\n counter=${ifDefined(this.counter)}\n @keyup=${this.handleKeyUp}\n @click=${this.handleClick}\n @input=${this.handleInput}\n @blur=${this.handleOptionCanceled}\n .value=${this.value}\n ?autogrow=${this.autogrow}\n ?textarea=${this.textarea}\n ?submitOnEnter=${this.submitOnEnter}\n >\n </temba-textinput>\n <temba-options\n @temba-selection=${this.handleOptionSelection}\n @temba-canceled=${this.handleOptionCanceled}\n .renderOption=${renderCompletionOption}\n .anchorTo=${this.anchorElement}\n .options=${this.options}\n ?visible=${this.options && this.options.length > 0}\n >\n ${this.currentFunction\n ? html`\n <div class=\"current-fn\">\n ${renderCompletionOption(this.currentFunction, true)}\n </div>\n `\n : null}\n <div class=\"footer\">Tab to complete, enter to select</div>\n </temba-options>\n </div>\n </temba-field>\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/completion/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EACL,SAAS,EACT,SAAS,EAGT,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,eAA+B,MAAM,mBAAmB,CAAC;AAUhE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC;AAE5B,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,GAAG,EAAE;IAC7C,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,GAAG,EAAE;IAC7C,SAAS;IACT,QAAQ;IACR,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,QAAQ;IACR,SAAS;IACT,QAAQ;CACT,CAAC,CAAC;AAEH,4BAA4B;AAC5B,MAAM,OAAO,cAAe,SAAQ,SAAS;IAG3C,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,iEAAiE;QACjE,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;IACH,CAAC;IACD,mEAAmE;IACnE,4BAA4B;IAC5B,MAAM,CAAC,IAAU,EAAE,CAAC,YAAY,CAAM;QACpC,uDAAuD;QACvD,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IACD,oEAA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B,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,UAAU;oBACrC,GAAG,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,SAAS;iBAC/B,CAAC;gBAEF,MAAM,CAAC,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAC1C,CAAC,EACD,iBAAiB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAClC,CAAC;gBAEF,MAAM,CAAC,OAAO,GAAG;oBACf,GAAG,cAAc,CACf,KAAK,CAAC,mBAAmB,EAAE,EAC3B,MAAM,CAAC,KAAK,EACZ,KAAK,CAAC,cAAc,EAAE,EACtB,OAAO,CACR;oBACD,GAAG,CAAC,gBAAgB;wBAClB,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;wBAClD,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC;gBAEF,OAAO,MAAM,CAAC;aACf;SACF;KACF;SAAM;QACL,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;KACnB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { html, TemplateResult } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport {\n directive,\n Directive,\n Part,\n PartInfo,\n PartType,\n} from 'lit/directive.js';\nimport ExcellentParser, { Expression } from './ExcellentParser';\nimport {\n CompletionOption,\n CompletionProperty,\n CompletionResult,\n CompletionSchema,\n CompletionType,\n KeyedAssets,\n} from '../interfaces';\nimport { Store } from '../store/Store';\nimport { Remarkable } from 'remarkable';\n\nconst md = new Remarkable();\n\nconst messageParser = new ExcellentParser('@', [\n 'contact',\n 'fields',\n 'globals',\n 'urns',\n]);\n\nconst sessionParser = new ExcellentParser('@', [\n 'contact',\n 'fields',\n 'globals',\n 'urns',\n 'results',\n 'input',\n 'run',\n 'child',\n 'parent',\n 'node',\n 'webhook',\n 'ticket',\n 'trigger',\n 'resume',\n]);\n\n// Class-based directive API\nexport class RenderMarkdown extends Directive {\n // State stored in class field\n value: string | undefined;\n constructor(partInfo: PartInfo) {\n super(partInfo);\n // When necessary, validate part in constructor using `part.type`\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('renderMarkdown only supports child expressions');\n }\n }\n // Optional: override update to perform any direct DOM manipulation\n // DirectiveParameters<this>\n update(part: Part, [initialValue]: any) {\n /* Any imperative updates to DOM/parts would go here */\n return this.render(initialValue);\n }\n // Do SSR-compatible rendering (arguments are passed from call site)\n render(initialValue: string) {\n // Previous state available on class field\n if (this.value === undefined) {\n this.value = initialValue;\n }\n return html`${unsafeHTML(md.render(this.value))}`;\n }\n}\n\nexport const renderMarkdown = directive(RenderMarkdown);\n\nexport const renderCompletionOption = (\n option: CompletionOption,\n selected: boolean\n): TemplateResult => {\n if (option.signature) {\n const argStart = option.signature.indexOf('(');\n const name = option.signature.substr(0, argStart);\n const args = option.signature.substr(argStart);\n\n return html`\n <div style=\"${selected ? 'font-weight: 400' : ''}\">\n <div style=\"display:inline-block;margin-right: 5px\">ƒ</div>\n <div style=\"display:inline-block\">${name}</div>\n ${selected\n ? html`\n <div\n style=\"display:inline-block; font-weight: 300; font-size: 85%\"\n >\n ${args}\n </div>\n <div class=\"detail\">${renderMarkdown(option.summary)}</div>\n `\n : null}\n </div>\n `;\n }\n\n return html`\n <div>\n <div style=\"${selected ? 'font-weight: 400' : ''}\">${option.name}</div>\n ${selected\n ? html` <div style=\"font-size: 85%\">${option.summary}</div> `\n : null}\n </div>\n `;\n};\n\nexport const getFunctions = (\n functions: CompletionOption[],\n query: string\n): CompletionOption[] => {\n if (!query) {\n return functions;\n }\n return functions.filter((option: CompletionOption) => {\n if (option.signature) {\n return option.signature.indexOf((query || '').toLowerCase()) === 0;\n }\n return false;\n });\n};\n\n/**\n * Takes a dot query and returns the completions options at the current level\n * @param dotQuery query such as \"contact.first_n\"\n */\nexport const getCompletions = (\n schema: CompletionSchema,\n dotQuery: string,\n keyedAssets: KeyedAssets = {},\n session: boolean\n): CompletionOption[] => {\n const parts = (dotQuery || '').split('.');\n let currentProps: CompletionProperty[] = session\n ? schema.root\n : schema.root_no_session;\n\n if (!currentProps) {\n return [];\n }\n\n let prefix = '';\n let part = '';\n while (parts.length > 0) {\n part = parts.shift();\n if (part) {\n // eslint-disable-next-line\n const nextProp = currentProps.find(\n (prop: CompletionProperty) => prop.key === part\n );\n if (nextProp) {\n // eslint-disable-next-line\n const nextType = schema.types.find(\n (type: CompletionType) => type.name === nextProp.type\n );\n if (nextType && nextType.properties) {\n currentProps = nextType.properties;\n prefix += part + '.';\n } else if (nextType && nextType.property_template) {\n prefix += part + '.';\n const template = nextType.property_template;\n if (keyedAssets[nextType.name]) {\n currentProps = keyedAssets[nextType.name].map((key: string) => ({\n key: template.key.replace('{key}', key),\n help: template.help.replace('{key}', key),\n type: template.type,\n }));\n } else {\n currentProps = [];\n }\n } else {\n // eslint-disable-next-line\n currentProps = currentProps.filter((prop: CompletionProperty) =>\n prop.key.startsWith(part.toLowerCase())\n );\n break;\n }\n } else {\n // eslint-disable-next-line\n currentProps = currentProps.filter((prop: CompletionProperty) =>\n prop.key.startsWith(part.toLowerCase())\n );\n break;\n }\n }\n }\n\n return currentProps.map((prop: CompletionProperty) => {\n const name =\n prop.key === '__default__'\n ? prefix.substr(0, prefix.length - 1)\n : prefix + prop.key;\n return { name, summary: prop.help };\n });\n};\n\nexport const getOffset = (el: HTMLElement) => {\n const rect = el.getBoundingClientRect(),\n scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,\n scrollTop = window.pageYOffset || document.documentElement.scrollTop;\n return { top: rect.top + scrollTop, left: rect.left + scrollLeft };\n};\n\nexport const getVerticalScroll = (ele: Node) => {\n let current = ele;\n const verticalScroll = 0;\n while (current) {\n current = current.parentNode;\n }\n return verticalScroll;\n};\n\nexport const getCompletionName = (option: CompletionOption): string => {\n return (\n option.name || option.signature.substr(0, option.signature.indexOf('('))\n );\n};\n\nexport const getCompletionSignature = (option: CompletionOption): string => {\n return option.signature.substr(option.signature.indexOf('('));\n};\n\n/**\n * Determines the pixel position of position inside a textarea or input\n * TODO: Explore somethign like contenteditable to avoid this madness\n * see: https://jh3y.medium.com/how-to-where-s-the-caret-getting-the-xy-position-of-the-caret-a24ba372990a\n */\nconst getCursorXY = (input, selectionPoint) => {\n const { offsetLeft: inputX, offsetTop: inputY } = input;\n const div = document.createElement('div');\n const copyStyle = getComputedStyle(input);\n for (const prop of copyStyle) {\n div.style[prop] = copyStyle[prop];\n }\n div.style.position = 'relative';\n const swap = '.';\n const inputValue =\n input.tagName === 'INPUT' ? input.value.replace(/ /g, swap) : input.value;\n const textContent = inputValue.substr(0, selectionPoint);\n div.textContent = textContent;\n if (input.tagName === 'TEXTAREA') div.style.height = 'auto';\n if (input.tagName === 'INPUT') div.style.width = 'auto';\n const span = document.createElement('span');\n span.textContent = inputValue.substr(selectionPoint) || '.';\n div.appendChild(span);\n document.body.appendChild(div);\n const { offsetLeft: spanX, offsetTop: spanY } = span;\n document.body.removeChild(div);\n return {\n left: inputX + spanX,\n top: inputY + spanY,\n };\n};\n\nexport const updateInputElementWithCompletion = (\n currentQuery: string,\n ele: HTMLInputElement,\n option: CompletionOption\n) => {\n let insertText = '';\n\n if (option.signature) {\n // they selected a function\n insertText = option.signature.substr(0, option.signature.indexOf('(') + 1);\n } else {\n insertText = option.name;\n }\n\n const queryLength = currentQuery.length;\n\n if (ele) {\n const value = ele.value;\n const insertionPoint = ele.selectionStart - queryLength;\n\n // strip out our query\n // const insertionPoint = value.lastIndexOf(value.substring(0, this.inputElement.selectionStart));\n const leftSide = value.substr(0, insertionPoint);\n const remaining = value.substr(insertionPoint + queryLength);\n const caret = leftSide.length + insertText.length;\n\n // set our value and our new caret\n ele.value = leftSide + insertText + remaining;\n ele.setSelectionRange(caret, caret);\n\n // now scroll our text box if necessary\n const position = getCursorXY(ele, caret);\n if (position.left > ele.width) {\n ele.scrollLeft = position.left;\n }\n\n ele.dispatchEvent(new Event('input'));\n }\n};\n\nexport const executeCompletionQuery = (\n ele: HTMLInputElement,\n store: Store,\n session: boolean\n): CompletionResult => {\n const result: CompletionResult = {\n currentFunction: null,\n options: [],\n anchorPosition: null,\n query: null,\n };\n\n // we need a store to do anything useful\n if (!store) {\n return result;\n }\n\n const cursor = ele.selectionStart;\n const input = ele.value.substring(0, cursor);\n\n const parser = session ? sessionParser : messageParser;\n const expressions = parser.findExpressions(input);\n const currentExpression = expressions.find(\n (expr: Expression) =>\n expr.start <= cursor &&\n (expr.end > cursor || (expr.end === cursor && !expr.closed))\n );\n\n if (currentExpression) {\n const includeFunctions = currentExpression.text.indexOf('(') > -1;\n if (includeFunctions) {\n const functionQuery = parser.functionContext(currentExpression.text);\n if (functionQuery) {\n const fns = getFunctions(store.getFunctions(), functionQuery);\n if (fns.length > 0) {\n result.currentFunction = fns[0];\n }\n }\n }\n\n for (let i = currentExpression.text.length; i >= 0; i--) {\n const curr = currentExpression.text[i];\n if (\n curr === '@' ||\n curr === '(' ||\n curr === ' ' ||\n curr === ',' ||\n curr === ')' ||\n i === 0\n ) {\n // don't include non-expression chars\n if (\n curr === '(' ||\n curr === ' ' ||\n curr === ',' ||\n curr === ')' ||\n curr === '@'\n ) {\n i++;\n }\n\n const caret = getCursorXY(ele, currentExpression.start + i);\n\n result.anchorPosition = {\n left: caret.left - 2 - ele.scrollLeft,\n top: caret.top - ele.scrollTop,\n };\n\n result.query = currentExpression.text.substr(\n i,\n currentExpression.text.length - i\n );\n\n result.options = [\n ...getCompletions(\n store.getCompletionSchema(),\n result.query,\n store.getKeyedAssets(),\n session\n ),\n ...(includeFunctions\n ? getFunctions(store.getFunctions(), result.query)\n : []),\n ];\n\n return result;\n }\n }\n } else {\n result.options = [];\n result.query = '';\n }\n return result;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/completion/helpers.ts"],"names":[],"m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,GAAG,GAAG,GAAG,CAAC,SAAS;iBAC/B,CAAC;gBAEF,MAAM,CAAC,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAC1C,CAAC,EACD,iBAAiB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAClC,CAAC;gBAEF,MAAM,CAAC,OAAO,GAAG;oBACf,GAAG,cAAc,CACf,KAAK,CAAC,mBAAmB,EAAE,EAC3B,MAAM,CAAC,KAAK,EACZ,KAAK,CAAC,cAAc,EAAE,EACtB,OAAO,CACR;oBACD,GAAG,CAAC,gBAAgB;wBAClB,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;wBAClD,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC;gBAEF,OAAO,MAAM,CAAC;aACf;SACF;KACF;SAAM;QACL,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;KACnB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { html, TemplateResult } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport {\n directive,\n Directive,\n Part,\n PartInfo,\n PartType,\n} from 'lit/directive.js';\nimport ExcellentParser, { Expression } from './ExcellentParser';\nimport {\n CompletionOption,\n CompletionProperty,\n CompletionResult,\n CompletionSchema,\n CompletionType,\n KeyedAssets,\n} from '../interfaces';\nimport { Store } from '../store/Store';\nimport { Remarkable } from 'remarkable';\n\nconst md = new Remarkable();\n\nconst messageParser = new ExcellentParser('@', [\n 'contact',\n 'fields',\n 'globals',\n 'urns',\n]);\n\nconst sessionParser = new ExcellentParser('@', [\n 'contact',\n 'fields',\n 'globals',\n 'urns',\n 'results',\n 'input',\n 'run',\n 'child',\n 'parent',\n 'node',\n 'webhook',\n 'ticket',\n 'trigger',\n 'resume',\n]);\n\n// Class-based directive API\nexport class RenderMarkdown extends Directive {\n // State stored in class field\n value: string | undefined;\n constructor(partInfo: PartInfo) {\n super(partInfo);\n // When necessary, validate part in constructor using `part.type`\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('renderMarkdown only supports child expressions');\n }\n }\n // Optional: override update to perform any direct DOM manipulation\n // DirectiveParameters<this>\n update(part: Part, [initialValue]: any) {\n /* Any imperative updates to DOM/parts would go here */\n return this.render(initialValue);\n }\n // Do SSR-compatible rendering (arguments are passed from call site)\n render(initialValue: string) {\n // Previous state available on class field\n if (this.value === undefined) {\n this.value = initialValue;\n }\n return html`${unsafeHTML(md.render(this.value))}`;\n }\n}\n\nexport const renderMarkdown = directive(RenderMarkdown);\n\nexport const renderCompletionOption = (\n option: CompletionOption,\n selected: boolean\n): TemplateResult => {\n if (option.signature) {\n const argStart = option.signature.indexOf('(');\n const name = option.signature.substr(0, argStart);\n const args = option.signature.substr(argStart);\n\n return html`\n <div style=\"${selected ? 'font-weight: 400' : ''}\">\n <div style=\"display:inline-block;margin-right: 5px\">ƒ</div>\n <div style=\"display:inline-block\">${name}</div>\n ${selected\n ? html`\n <div\n style=\"display:inline-block; font-weight: 300; font-size: 85%\"\n >\n ${args}\n </div>\n <div class=\"detail\">${renderMarkdown(option.summary)}</div>\n `\n : null}\n </div>\n `;\n }\n\n return html`\n <div>\n <div style=\"${selected ? 'font-weight: 400' : ''}\">${option.name}</div>\n ${selected\n ? html` <div style=\"font-size: 85%\">${option.summary}</div> `\n : null}\n </div>\n `;\n};\n\nexport const getFunctions = (\n functions: CompletionOption[],\n query: string\n): CompletionOption[] => {\n if (!query) {\n return functions;\n }\n return functions.filter((option: CompletionOption) => {\n if (option.signature) {\n return option.signature.indexOf((query || '').toLowerCase()) === 0;\n }\n return false;\n });\n};\n\n/**\n * Takes a dot query and returns the completions options at the current level\n * @param dotQuery query such as \"contact.first_n\"\n */\nexport const getCompletions = (\n schema: CompletionSchema,\n dotQuery: string,\n keyedAssets: KeyedAssets = {},\n session: boolean\n): CompletionOption[] => {\n const parts = (dotQuery || '').split('.');\n let currentProps: CompletionProperty[] = session\n ? schema.root\n : schema.root_no_session;\n\n if (!currentProps) {\n return [];\n }\n\n let prefix = '';\n let part = '';\n while (parts.length > 0) {\n part = parts.shift();\n if (part) {\n // eslint-disable-next-line\n const nextProp = currentProps.find(\n (prop: CompletionProperty) => prop.key === part\n );\n if (nextProp) {\n // eslint-disable-next-line\n const nextType = schema.types.find(\n (type: CompletionType) => type.name === nextProp.type\n );\n if (nextType && nextType.properties) {\n currentProps = nextType.properties;\n prefix += part + '.';\n } else if (nextType && nextType.property_template) {\n prefix += part + '.';\n const template = nextType.property_template;\n if (keyedAssets[nextType.name]) {\n currentProps = keyedAssets[nextType.name].map((key: string) => ({\n key: template.key.replace('{key}', key),\n help: template.help.replace('{key}', key),\n type: template.type,\n }));\n } else {\n currentProps = [];\n }\n } else {\n // eslint-disable-next-line\n currentProps = currentProps.filter((prop: CompletionProperty) =>\n prop.key.startsWith(part.toLowerCase())\n );\n break;\n }\n } else {\n // eslint-disable-next-line\n currentProps = currentProps.filter((prop: CompletionProperty) =>\n prop.key.startsWith(part.toLowerCase())\n );\n break;\n }\n }\n }\n\n return currentProps.map((prop: CompletionProperty) => {\n const name =\n prop.key === '__default__'\n ? prefix.substr(0, prefix.length - 1)\n : prefix + prop.key;\n return { name, summary: prop.help };\n });\n};\n\nexport const getOffset = (el: HTMLElement) => {\n const rect = el.getBoundingClientRect(),\n scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,\n scrollTop = window.pageYOffset || document.documentElement.scrollTop;\n return { top: rect.top + scrollTop, left: rect.left + scrollLeft };\n};\n\nexport const getVerticalScroll = (ele: Node) => {\n let current = ele;\n const verticalScroll = 0;\n while (current) {\n current = current.parentNode;\n }\n return verticalScroll;\n};\n\nexport const getCompletionName = (option: CompletionOption): string => {\n return (\n option.name || option.signature.substr(0, option.signature.indexOf('('))\n );\n};\n\nexport const getCompletionSignature = (option: CompletionOption): string => {\n return option.signature.substr(option.signature.indexOf('('));\n};\n\n/**\n * Determines the pixel position of position inside a textarea or input\n * TODO: Explore somethign like contenteditable to avoid this madness\n * see: https://jh3y.medium.com/how-to-where-s-the-caret-getting-the-xy-position-of-the-caret-a24ba372990a\n */\nconst getCursorXY = (input, selectionPoint) => {\n const { offsetLeft: inputX, offsetTop: inputY } = input;\n const div = document.createElement('div');\n const copyStyle = getComputedStyle(input);\n for (const prop of copyStyle) {\n div.style[prop] = copyStyle[prop];\n }\n div.style.position = 'relative';\n const swap = '.';\n const inputValue =\n input.tagName === 'INPUT' ? input.value.replace(/ /g, swap) : input.value;\n const textContent = inputValue.substr(0, selectionPoint);\n div.textContent = textContent;\n if (input.tagName === 'TEXTAREA') div.style.height = 'auto';\n if (input.tagName === 'INPUT') div.style.width = 'auto';\n const span = document.createElement('span');\n span.textContent = inputValue.substr(selectionPoint) || '.';\n div.appendChild(span);\n document.body.appendChild(div);\n const { offsetLeft: spanX, offsetTop: spanY } = span;\n document.body.removeChild(div);\n return {\n left: inputX + spanX,\n top: inputY + spanY,\n };\n};\n\nexport const updateInputElementWithCompletion = (\n currentQuery: string,\n ele: HTMLInputElement,\n option: CompletionOption\n) => {\n let insertText = '';\n\n if (option.signature) {\n // they selected a function\n insertText = option.signature.substr(0, option.signature.indexOf('(') + 1);\n } else {\n insertText = option.name;\n }\n\n const queryLength = currentQuery.length;\n\n if (ele) {\n const value = ele.value;\n const insertionPoint = ele.selectionStart - queryLength;\n\n // strip out our query\n // const insertionPoint = value.lastIndexOf(value.substring(0, this.inputElement.selectionStart));\n const leftSide = value.substr(0, insertionPoint);\n const remaining = value.substr(insertionPoint + queryLength);\n const caret = leftSide.length + insertText.length;\n\n // set our value and our new caret\n ele.value = leftSide + insertText + remaining;\n ele.setSelectionRange(caret, caret);\n\n // now scroll our text box if necessary\n const position = getCursorXY(ele, caret);\n if (position.left > ele.width) {\n ele.scrollLeft = position.left;\n }\n\n ele.dispatchEvent(new Event('input'));\n }\n};\n\nexport const executeCompletionQuery = (\n ele: HTMLInputElement,\n store: Store,\n session: boolean\n): CompletionResult => {\n const result: CompletionResult = {\n currentFunction: null,\n options: [],\n anchorPosition: null,\n query: null,\n };\n\n if (!ele) {\n return;\n }\n\n // we need a store to do anything useful\n if (!store) {\n return result;\n }\n\n const cursor = ele.selectionStart;\n const input = ele.value.substring(0, cursor);\n\n const parser = session ? sessionParser : messageParser;\n const expressions = parser.findExpressions(input);\n const currentExpression = expressions.find(\n (expr: Expression) =>\n expr.start <= cursor &&\n (expr.end > cursor || (expr.end === cursor && !expr.closed))\n );\n\n if (currentExpression) {\n const includeFunctions = currentExpression.text.indexOf('(') > -1;\n if (includeFunctions) {\n const functionQuery = parser.functionContext(currentExpression.text);\n if (functionQuery) {\n const fns = getFunctions(store.getFunctions(), functionQuery);\n if (fns.length > 0) {\n result.currentFunction = fns[0];\n }\n }\n }\n\n for (let i = currentExpression.text.length; i >= 0; i--) {\n const curr = currentExpression.text[i];\n if (\n curr === '@' ||\n curr === '(' ||\n curr === ' ' ||\n curr === ',' ||\n curr === ')' ||\n i === 0\n ) {\n // don't include non-expression chars\n if (\n curr === '(' ||\n curr === ' ' ||\n curr === ',' ||\n curr === ')' ||\n curr === '@'\n ) {\n i++;\n }\n\n const caret = getCursorXY(ele, currentExpression.start + i);\n\n result.anchorPosition = {\n left: caret.left - 2 - ele.scrollLeft,\n top: caret.top - ele.scrollTop,\n };\n\n result.query = currentExpression.text.substr(\n i,\n currentExpression.text.length - i\n );\n\n result.options = [\n ...getCompletions(\n store.getCompletionSchema(),\n result.query,\n store.getKeyedAssets(),\n session\n ),\n ...(includeFunctions\n ? getFunctions(store.getFunctions(), result.query)\n : []),\n ];\n\n return result;\n }\n }\n } else {\n result.options = [];\n result.query = '';\n }\n return result;\n};\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
5
|
-
import { COOKIE_KEYS, getCookieBoolean, postJSON, setCookie } from '../utils';
|
|
4
|
+
import { COOKIE_KEYS, getCookieBoolean, postJSON } from '../utils';
|
|
6
5
|
import { ContactStoreElement } from './ContactStoreElement';
|
|
7
|
-
import { Icon } from '../vectoricon';
|
|
8
6
|
const DEFAULT_REFRESH = 10000;
|
|
9
7
|
export class ContactChat extends ContactStoreElement {
|
|
10
8
|
static get styles() {
|
|
@@ -32,6 +30,7 @@ export class ContactChat extends ContactStoreElement {
|
|
|
32
30
|
flex-direction: column;
|
|
33
31
|
overflow: hidden;
|
|
34
32
|
min-height: 0;
|
|
33
|
+
border-radius: var(--curvature);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
temba-contact-history {
|
|
@@ -79,73 +78,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
79
78
|
--button-x: 12px;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
.toolbar {
|
|
83
|
-
position: relative;
|
|
84
|
-
width: 2.5em;
|
|
85
|
-
background: #e6e6e6;
|
|
86
|
-
transition: all 600ms ease-in;
|
|
87
|
-
z-index: 10;
|
|
88
|
-
flex-shrink: 0;
|
|
89
|
-
border-top-right-radius: var(--curvature);
|
|
90
|
-
border-bottom-right-radius: var(--curvature);
|
|
91
|
-
padding: 0.5em 0;
|
|
92
|
-
display: flex;
|
|
93
|
-
flex-direction: column;
|
|
94
|
-
align-items: center;
|
|
95
|
-
overflow: hidden;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.toolbar temba-icon {
|
|
99
|
-
fill: rgb(60, 60, 60);
|
|
100
|
-
margin-bottom: 0.5em;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.toolbar.closed {
|
|
104
|
-
box-shadow: inset 10px 0px 10px -11px rgb(0 0 0 / 15%);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
temba-contact-details {
|
|
108
|
-
flex-basis: 16em;
|
|
109
|
-
flex-grow: 0;
|
|
110
|
-
flex-shrink: 0;
|
|
111
|
-
transition: margin 600ms cubic-bezier(0.68, -0.55, 0.265, 1.05),
|
|
112
|
-
opacity 600ms ease-in-out 200ms;
|
|
113
|
-
z-index: 5;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
temba-contact-details.hidden {
|
|
117
|
-
margin-right: -16em;
|
|
118
|
-
opacity: 0;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
@media only screen and (max-width: 768px) {
|
|
122
|
-
temba-contact-details {
|
|
123
|
-
flex-basis: 12em;
|
|
124
|
-
flex-shrink: 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
temba-contact-details.hidden {
|
|
128
|
-
margin-right: -12em;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
#close-button,
|
|
133
|
-
#open-button {
|
|
134
|
-
margin-top: 1em;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
#details-button {
|
|
138
|
-
margin-top: 0.25em;
|
|
139
|
-
transform: rotate(180deg);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
#note-dialog,
|
|
143
|
-
#assign-dialog {
|
|
144
|
-
--header-bg: rgb(255, 249, 194);
|
|
145
|
-
--header-text: #555;
|
|
146
|
-
--textarea-height: 5em;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
81
|
temba-completion {
|
|
150
82
|
--widget-box-shadow: none;
|
|
151
83
|
--color-widget-border: transparent;
|
|
@@ -160,7 +92,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
160
92
|
this.contactsEndpoint = '/api/v2/contacts.json';
|
|
161
93
|
this.currentNote = '';
|
|
162
94
|
this.showDetails = true;
|
|
163
|
-
this.toolbar = false;
|
|
164
95
|
this.monitor = false;
|
|
165
96
|
this.currentTicket = null;
|
|
166
97
|
this.currentContact = null;
|
|
@@ -194,6 +125,7 @@ export class ContactChat extends ContactStoreElement {
|
|
|
194
125
|
contactHistory.scrollToBottom();
|
|
195
126
|
}
|
|
196
127
|
contactHistory.refresh();
|
|
128
|
+
// super.refresh();
|
|
197
129
|
}
|
|
198
130
|
}
|
|
199
131
|
updated(changedProperties) {
|
|
@@ -204,22 +136,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
204
136
|
this.currentContact = this.data;
|
|
205
137
|
}
|
|
206
138
|
}
|
|
207
|
-
handleTicketReopen() {
|
|
208
|
-
const uuid = this.currentTicket.uuid;
|
|
209
|
-
postJSON(`/api/v2/ticket_actions.json`, {
|
|
210
|
-
tickets: [uuid],
|
|
211
|
-
action: 'reopen',
|
|
212
|
-
})
|
|
213
|
-
.then(() => {
|
|
214
|
-
this.refresh();
|
|
215
|
-
this.fireCustomEvent(CustomEventType.ContentChanged, {
|
|
216
|
-
ticket: { uuid, status: 'open' },
|
|
217
|
-
});
|
|
218
|
-
})
|
|
219
|
-
.catch((response) => {
|
|
220
|
-
console.error(response);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
139
|
handleSend(evt) {
|
|
224
140
|
const buttonName = evt.detail.name;
|
|
225
141
|
if (buttonName === 'Send') {
|
|
@@ -275,14 +191,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
275
191
|
});
|
|
276
192
|
}
|
|
277
193
|
}
|
|
278
|
-
handleTicketAssigned() {
|
|
279
|
-
this.refresh();
|
|
280
|
-
this.getContactHistory().checkForAgentAssignmentEvent(this.agent);
|
|
281
|
-
}
|
|
282
|
-
handleDetailSlider() {
|
|
283
|
-
this.showDetails = !this.showDetails;
|
|
284
|
-
setCookie(COOKIE_KEYS.TICKET_SHOW_DETAILS, this.showDetails);
|
|
285
|
-
}
|
|
286
194
|
render() {
|
|
287
195
|
const contactHistory = this.currentContact
|
|
288
196
|
? this.getTembaContactHistory()
|
|
@@ -294,26 +202,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
294
202
|
>
|
|
295
203
|
<div class="chat-wrapper">${contactHistory} ${chatbox}</div>
|
|
296
204
|
</div>`;
|
|
297
|
-
if (this.toolbar) {
|
|
298
|
-
const contactDetails = this.currentContact
|
|
299
|
-
? this.getTembaContactDetails()
|
|
300
|
-
: null;
|
|
301
|
-
const toggleContactDetails = this.currentContact
|
|
302
|
-
? this.getToggleDetailsTembaTip()
|
|
303
|
-
: null;
|
|
304
|
-
const addNoteAndAssignTicketTembaTips = this.currentContact && this.currentTicket
|
|
305
|
-
? this.getAddNoteAndAssignTicketTembaTips()
|
|
306
|
-
: null;
|
|
307
|
-
const addNoteAndAssignTicketTembaModaxes = this.currentTicket
|
|
308
|
-
? this.getAddNoteAndAssignTicketTembaModaxes()
|
|
309
|
-
: null;
|
|
310
|
-
const contactDetailsAndActions = html `${contactDetails}
|
|
311
|
-
<div class="toolbar ${this.showDetails ? '' : 'closed'}">
|
|
312
|
-
${toggleContactDetails} ${addNoteAndAssignTicketTembaTips}
|
|
313
|
-
</div>
|
|
314
|
-
${addNoteAndAssignTicketTembaModaxes}`;
|
|
315
|
-
return html `${contactHistoryAndChatbox} ${contactDetailsAndActions}`;
|
|
316
|
-
}
|
|
317
205
|
return html `${contactHistoryAndChatbox}`;
|
|
318
206
|
}
|
|
319
207
|
getTembaContactHistory() {
|
|
@@ -333,20 +221,13 @@ export class ContactChat extends ContactStoreElement {
|
|
|
333
221
|
return null;
|
|
334
222
|
}
|
|
335
223
|
else {
|
|
336
|
-
if (this.currentTicket.closed_on) {
|
|
337
|
-
//reopen button for active contacts with a closed ticket
|
|
338
|
-
return html ` <div class="closed-footer">
|
|
339
|
-
<temba-button
|
|
340
|
-
id="reopen-button"
|
|
341
|
-
name="Reopen"
|
|
342
|
-
@click=${this.handleTicketReopen}
|
|
343
|
-
></temba-button>
|
|
344
|
-
</div>`;
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
224
|
+
if (!this.currentTicket.closed_on) {
|
|
347
225
|
//chatbox for active contacts with an open ticket
|
|
348
226
|
return this.getChatbox();
|
|
349
227
|
}
|
|
228
|
+
else {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
350
231
|
}
|
|
351
232
|
}
|
|
352
233
|
if (this.currentContact && this.currentContact.status !== 'active') {
|
|
@@ -359,7 +240,7 @@ export class ContactChat extends ContactStoreElement {
|
|
|
359
240
|
}
|
|
360
241
|
}
|
|
361
242
|
getChatbox() {
|
|
362
|
-
return html
|
|
243
|
+
return html `<div class="chatbox">
|
|
363
244
|
<temba-compose
|
|
364
245
|
chatbox
|
|
365
246
|
attachments
|
|
@@ -370,77 +251,6 @@ export class ContactChat extends ContactStoreElement {
|
|
|
370
251
|
</temba-compose>
|
|
371
252
|
</div>`;
|
|
372
253
|
}
|
|
373
|
-
getTembaContactDetails() {
|
|
374
|
-
return html ` <temba-contact-details
|
|
375
|
-
style="z-index: 10"
|
|
376
|
-
class="${this.showDetails ? '' : 'hidden'}"
|
|
377
|
-
showGroups="true"
|
|
378
|
-
.visible=${this.showDetails}
|
|
379
|
-
.ticket=${this.currentTicket}
|
|
380
|
-
.contact=${this.currentContact}
|
|
381
|
-
>
|
|
382
|
-
</temba-contact-details>`;
|
|
383
|
-
}
|
|
384
|
-
getToggleDetailsTembaTip() {
|
|
385
|
-
return html ` <temba-tip
|
|
386
|
-
style="margin-top:5px"
|
|
387
|
-
text="${this.showDetails ? 'Hide Details' : 'Show Details'}"
|
|
388
|
-
position="left"
|
|
389
|
-
hideOnChange
|
|
390
|
-
>
|
|
391
|
-
<temba-icon
|
|
392
|
-
id="details-button"
|
|
393
|
-
name="${this.showDetails ? Icon.menu_collapse : 'layout-left'}"
|
|
394
|
-
@click="${this.handleDetailSlider}"
|
|
395
|
-
clickable
|
|
396
|
-
animatechange="spin"
|
|
397
|
-
></temba-icon>
|
|
398
|
-
</temba-tip>`;
|
|
399
|
-
}
|
|
400
|
-
getAddNoteAndAssignTicketTembaTips() {
|
|
401
|
-
return html ` <temba-tip
|
|
402
|
-
style="margin-top:5px"
|
|
403
|
-
text="Assign"
|
|
404
|
-
position="left"
|
|
405
|
-
>
|
|
406
|
-
<temba-icon
|
|
407
|
-
id="assign-button"
|
|
408
|
-
name="${Icon.users}"
|
|
409
|
-
@click="${() => {
|
|
410
|
-
const modax = this.shadowRoot.getElementById('assign-dialog');
|
|
411
|
-
modax.open = true;
|
|
412
|
-
}}"
|
|
413
|
-
clickable
|
|
414
|
-
></temba-icon>
|
|
415
|
-
</temba-tip>
|
|
416
|
-
<temba-tip style="margin-top:5px" text="Add Note" position="left">
|
|
417
|
-
<temba-icon
|
|
418
|
-
id="add-note-button"
|
|
419
|
-
name="${Icon.add_note}"
|
|
420
|
-
@click="${() => {
|
|
421
|
-
const note = this.shadowRoot.getElementById('note-dialog');
|
|
422
|
-
note.open = true;
|
|
423
|
-
}}"
|
|
424
|
-
clickable
|
|
425
|
-
></temba-icon>
|
|
426
|
-
</temba-tip>`;
|
|
427
|
-
}
|
|
428
|
-
getAddNoteAndAssignTicketTembaModaxes() {
|
|
429
|
-
return html ` <temba-modax
|
|
430
|
-
header="Add Note"
|
|
431
|
-
id="note-dialog"
|
|
432
|
-
@temba-submitted=${this.refresh}
|
|
433
|
-
endpoint="/ticket/note/${this.currentTicket.uuid}/"
|
|
434
|
-
>
|
|
435
|
-
</temba-modax>
|
|
436
|
-
<temba-modax
|
|
437
|
-
header="Assign Ticket"
|
|
438
|
-
id="assign-dialog"
|
|
439
|
-
@temba-submitted=${this.handleTicketAssigned}
|
|
440
|
-
endpoint="/ticket/assign/${this.currentTicket.uuid}/"
|
|
441
|
-
>
|
|
442
|
-
</temba-modax>`;
|
|
443
|
-
}
|
|
444
254
|
}
|
|
445
255
|
__decorate([
|
|
446
256
|
property({ type: String, attribute: 'ticket' })
|
|
@@ -454,9 +264,6 @@ __decorate([
|
|
|
454
264
|
__decorate([
|
|
455
265
|
property({ type: Boolean })
|
|
456
266
|
], ContactChat.prototype, "showDetails", void 0);
|
|
457
|
-
__decorate([
|
|
458
|
-
property({ type: Boolean })
|
|
459
|
-
], ContactChat.prototype, "toolbar", void 0);
|
|
460
267
|
__decorate([
|
|
461
268
|
property({ type: Boolean })
|
|
462
269
|
], ContactChat.prototype, "monitor", void 0);
|