@nyaruka/temba-components 0.114.0 → 0.114.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.114.1](https://github.com/nyaruka/temba-components/compare/v0.114.0...v0.114.1)
|
|
8
|
+
|
|
9
|
+
- Encode email addresses on resolveUsers [`b3ce6de`](https://github.com/nyaruka/temba-components/commit/b3ce6dec167eddadbec8447b0b0a5380fb85dd72)
|
|
10
|
+
|
|
7
11
|
#### [v0.114.0](https://github.com/nyaruka/temba-components/compare/v0.113.0...v0.114.0)
|
|
8
12
|
|
|
13
|
+
> 7 January 2025
|
|
14
|
+
|
|
9
15
|
- Assignment bar [`#470`](https://github.com/nyaruka/temba-components/pull/470)
|
|
10
16
|
- Add assignment bar [`10d2666`](https://github.com/nyaruka/temba-components/commit/10d2666af7ee61cc89dca8472748fdf9d5520e9e)
|
|
11
17
|
- Remove cruft [`8bfb1e7`](https://github.com/nyaruka/temba-components/commit/8bfb1e795a885afa2893b0e6921f663c4487db73)
|
package/dist/temba-components.js
CHANGED
|
@@ -392,7 +392,7 @@ let fr=Ys,vr=!1;const br=["es","fr","pt"],yr="data:image/png;base64,iVBORw0KGgoA
|
|
|
392
392
|
width: 100%;
|
|
393
393
|
top: 0.5em;
|
|
394
394
|
}
|
|
395
|
-
`}markDirty(t){this.dirtyElements.includes(t)||this.dirtyElements.push(t)}cleanAll(){this.dirtyElements.forEach((t=>t.markClean())),this.dirtyElements=[]}markClean(t){this.dirtyElements=this.dirtyElements.filter((e=>e!==t))}getDirtyMessage(){if(this.dirtyElements.length>0)return this.dirtyElements[0].dirtyMessage||"You have unsaved changes, are you sure you want to continue?"}getLocale(){return this.locale[0]}clearCache(){this.cache=Le(this.max,this.ttl)}reset(){this.ready=!1,this.clearCache(),this.settings=JSON.parse(oe("settings")||"{}");const t=[];this.completionEndpoint&&t.push(jt(this.completionEndpoint).then((t=>{this.schema=t.json.context,this.fnOptions=t.json.functions}))),this.fieldsEndpoint&&t.push(this.refreshFields()),this.globalsEndpoint&&t.push(Yt(this.globalsEndpoint).then((t=>{this.keyedAssets.globals=t.map((t=>t.key))}))),this.languagesEndpoint&&t.push(Yt(this.languagesEndpoint).then((t=>{this.languages=t.reduce((function(t,e){return t[e.value]=e.name,t}),{})}))),this.groupsEndpoint&&t.push(Yt(this.groupsEndpoint).then((t=>{t.forEach((t=>{this.groups[t.uuid]=t}))}))),this.workspaceEndpoint&&t.push(jt(this.workspaceEndpoint).then((t=>{this.workspace=t.json;const e=t.headers.get("content-language");e&&(this.locale=[e,...this.locale])}))),this.shortcutsEndpoint&&t.push(this.refreshShortcuts()),this.initialHttpComplete=Promise.all(t),this.initialHttpComplete.then((()=>{this.ready=!0}))}getShortcuts(){return this.shortcuts||[]}firstUpdated(){this.reset()}getLanguageCode(){return this.locale.length>0?this.locale[0].split("-")[0]:"en"}async refreshGlobals(){return Yt(this.globalsEndpoint).then((t=>{this.keyedAssets.globals=t.map((t=>t.key))}))}async refreshShortcuts(){return Yt(this.shortcutsEndpoint).then((t=>{this.shortcuts=t}))}async refreshFields(){return Yt(this.fieldsEndpoint).then((t=>{this.keyedAssets.fields=[],this.featuredFields=[],t.forEach((t=>{this.keyedAssets.fields.push(t.key),this.fields[t.key]=t,t.featured&&this.featuredFields.push(t)})),this.featuredFields.sort(((t,e)=>e.priority-t.priority)),this.keyedAssets.fields.sort(),this.fireCustomEvent($e.StoreUpdated,{url:this.fieldsEndpoint,data:this.keyedAssets.fields})}))}shiftAndRound(t,e,i){const o=Math.round(t.shiftTo(e).get(e));return 1==o?`1 ${i}`:`${o} ${e}`}getCountdown(t){const e=t.diff(Hs.now()).rescale();return e.months>0?"> 1 month":e.days>1?`~ ${this.shiftAndRound(e,"days","day")}`:e.hours>0?`~ ${this.shiftAndRound(e,"hours","hour")}`:`~ ${this.shiftAndRound(e,"minutes","minute")}`}getShortDuration(t,e=null){const i=e||Hs.now();return t.setLocale(this.locale[0]).toRelative({base:i,style:"long"})}getShortDurationFromIso(t,e=null){const i=Hs.fromISO(t),o=e?Hs.fromISO(e):Hs.now();return this.getShortDuration(i,o)}setKeyedAssets(t,e){this.keyedAssets[t]=e}updated(t){if(super.updated(t),t.has("ready")&&this.ready){const t=this.getLanguageCode(),e=br.find((e=>e===t));e&&wr(e)}}getCompletionSchema(){return this.schema}getFunctions(){return this.fnOptions}getKeyedAssets(){return this.keyedAssets}getFieldKeys(){return this.keyedAssets.fields||[]}getContactField(t){return this.fields[t]}getFeaturedFields(){return this.featuredFields}getLanguageName(t){return this.languages[t]}isDynamicGroup(t){const e=this.groups[t];return!(e&&!e.query)}getWorkspace(){return this.workspace}formatDate(t){return Hs.fromISO(t).setLocale(this.getLocale()).toLocaleString(Hs.DATETIME_SHORT)}postJSON(t,e=""){return Qt(t,e)}postForm(t,e,i={}){return((t,e,i={})=>{const o=new FormData;return Object.keys(e).forEach((t=>{o.append(t,e[t])})),Jt(t,o,i)})(t,e,i)}postUrl(t,e="",i={},o=null){return Kt(t,e,i,o)}getUrl(t,e){return!(e=e||{}).force&&this.cache.has(t)?new Promise((e=>{e(this.cache.get(t))})):jt(t,e.controller,e.headers||{}).then((e=>new Promise(((i,o)=>{e.status>=200&&e.status<=300?(this.cache.set(t,e),i(e)):o("Status: "+e.status)}))))}getResults(t,e){e=e||{};const i="results_"+t,o=this.cache.get(i);return!e.force&&o?new Promise((t=>{t(o)})):new Promise((e=>{const o=this.pendingResolves[t]||[];o.push(e),this.pendingResolves[t]=o,o.length<=1&&Wt(t).then((e=>{this.cache.set(i,e);const o=this.pendingResolves[t]||[];for(;o.length>0;){o.pop()(e)}}))}))}updateCache(t,e){this.cache.set(t,e),this.fireCustomEvent($e.StoreUpdated,{url:t,data:e})}removeFromCache(t){this.cache.delete(t)}resolveUsers(t,e){return new Promise((i=>{const o=new Set;t.forEach((t=>{e.forEach((e=>{const i=e.split(".");let n=t;for(let t=0;t<i.length&&(n=n[i[t]],n);t++);n&&n.email&&o.add(n.email)}))}));const n=[];o.forEach((t=>{n.push(this.getUrl(`/api/v2/users.json?email=${t}`))})),Promise.all(n).then((o=>{o.forEach((i=>{if(i&&i.json){const o=i.json.results;if(o&&1===o.length){const i=o[0];t.forEach((t=>{e.forEach((e=>{const o=e.split(".");let n=t,s=n;for(let t=0;t<o.length&&(s=n,n=n[o[t]],n);t++);if(n&&n.email===i.email){const t=s[o[o.length-1]];t.avatar=i.avatar,t.name=_r(i),s[o[o.length-1]].avatar=i.avatar}}))}))}}})),i()}))}))}makeRequest(t,e){const i=this.fetching[t],o=(new Date).getTime();if(i)return void setTimeout((()=>{this.makeRequest(t,e)}),500);let n=this.cache.get(t);n&&!e.force?(n=e.prepareData?e.prepareData(n):n,this.fireCustomEvent($e.StoreUpdated,{url:t,data:n})):(e=e||{},this.fetching[t]=o,Wt(t).then((i=>{i?(this.cache.set(t,i),delete this.fetching[t],i=e.prepareData?e.prepareData(i):i,this.fireCustomEvent($e.StoreUpdated,{url:t,data:i})):delete this.fetching[t]})))}get(t,e=null){return this.settings[t]||e}set(t,e){this.settings[t]=e}render(){if(!this.ready&&this.loader)return j`<temba-loading size="10" units="8"></temba-loading>`}}t([ce({type:Number})],kr.prototype,"ttl",void 0),t([ce({type:Number})],kr.prototype,"max",void 0),t([ce({type:Boolean})],kr.prototype,"ready",void 0),t([ce({type:Boolean})],kr.prototype,"loader",void 0),t([ce({type:String,attribute:"completion"})],kr.prototype,"completionEndpoint",void 0),t([ce({type:String,attribute:"fields"})],kr.prototype,"fieldsEndpoint",void 0),t([ce({type:String,attribute:"groups"})],kr.prototype,"groupsEndpoint",void 0),t([ce({type:String,attribute:"globals"})],kr.prototype,"globalsEndpoint",void 0),t([ce({type:String,attribute:"languages"})],kr.prototype,"languagesEndpoint",void 0),t([ce({type:String,attribute:"workspace"})],kr.prototype,"workspaceEndpoint",void 0),t([ce({type:String,attribute:"shortcuts"})],kr.prototype,"shortcutsEndpoint",void 0),t([ce({type:Object,attribute:!1})],kr.prototype,"schema",void 0),t([ce({type:Object,attribute:!1})],kr.prototype,"fnOptions",void 0),t([ce({type:Object,attribute:!1})],kr.prototype,"keyedAssets",void 0);class Ar extends pe{constructor(){super(...arguments),this.marginHorizontal=0,this.marginVertical=7,this.scrollPct=75,this.cursorIndex=-1,this.internalFocusDisabled=!1,this.nameKey="name",this.loading=!1,this.hideShadow=!1,this.getName=function(t){return t[this.nameKey||"name"]},this.renderInputOption=function(){return null},this.scrollHeight=0,this.triggerScroll=!1,this.scrollParent=null,this.setCursor=ee((function(t){this.internalFocusDisabled||t!==this.cursorIndex&&(this.cursorIndex=t)}),50)}static get styles(){return r`
|
|
395
|
+
`}markDirty(t){this.dirtyElements.includes(t)||this.dirtyElements.push(t)}cleanAll(){this.dirtyElements.forEach((t=>t.markClean())),this.dirtyElements=[]}markClean(t){this.dirtyElements=this.dirtyElements.filter((e=>e!==t))}getDirtyMessage(){if(this.dirtyElements.length>0)return this.dirtyElements[0].dirtyMessage||"You have unsaved changes, are you sure you want to continue?"}getLocale(){return this.locale[0]}clearCache(){this.cache=Le(this.max,this.ttl)}reset(){this.ready=!1,this.clearCache(),this.settings=JSON.parse(oe("settings")||"{}");const t=[];this.completionEndpoint&&t.push(jt(this.completionEndpoint).then((t=>{this.schema=t.json.context,this.fnOptions=t.json.functions}))),this.fieldsEndpoint&&t.push(this.refreshFields()),this.globalsEndpoint&&t.push(Yt(this.globalsEndpoint).then((t=>{this.keyedAssets.globals=t.map((t=>t.key))}))),this.languagesEndpoint&&t.push(Yt(this.languagesEndpoint).then((t=>{this.languages=t.reduce((function(t,e){return t[e.value]=e.name,t}),{})}))),this.groupsEndpoint&&t.push(Yt(this.groupsEndpoint).then((t=>{t.forEach((t=>{this.groups[t.uuid]=t}))}))),this.workspaceEndpoint&&t.push(jt(this.workspaceEndpoint).then((t=>{this.workspace=t.json;const e=t.headers.get("content-language");e&&(this.locale=[e,...this.locale])}))),this.shortcutsEndpoint&&t.push(this.refreshShortcuts()),this.initialHttpComplete=Promise.all(t),this.initialHttpComplete.then((()=>{this.ready=!0}))}getShortcuts(){return this.shortcuts||[]}firstUpdated(){this.reset()}getLanguageCode(){return this.locale.length>0?this.locale[0].split("-")[0]:"en"}async refreshGlobals(){return Yt(this.globalsEndpoint).then((t=>{this.keyedAssets.globals=t.map((t=>t.key))}))}async refreshShortcuts(){return Yt(this.shortcutsEndpoint).then((t=>{this.shortcuts=t}))}async refreshFields(){return Yt(this.fieldsEndpoint).then((t=>{this.keyedAssets.fields=[],this.featuredFields=[],t.forEach((t=>{this.keyedAssets.fields.push(t.key),this.fields[t.key]=t,t.featured&&this.featuredFields.push(t)})),this.featuredFields.sort(((t,e)=>e.priority-t.priority)),this.keyedAssets.fields.sort(),this.fireCustomEvent($e.StoreUpdated,{url:this.fieldsEndpoint,data:this.keyedAssets.fields})}))}shiftAndRound(t,e,i){const o=Math.round(t.shiftTo(e).get(e));return 1==o?`1 ${i}`:`${o} ${e}`}getCountdown(t){const e=t.diff(Hs.now()).rescale();return e.months>0?"> 1 month":e.days>1?`~ ${this.shiftAndRound(e,"days","day")}`:e.hours>0?`~ ${this.shiftAndRound(e,"hours","hour")}`:`~ ${this.shiftAndRound(e,"minutes","minute")}`}getShortDuration(t,e=null){const i=e||Hs.now();return t.setLocale(this.locale[0]).toRelative({base:i,style:"long"})}getShortDurationFromIso(t,e=null){const i=Hs.fromISO(t),o=e?Hs.fromISO(e):Hs.now();return this.getShortDuration(i,o)}setKeyedAssets(t,e){this.keyedAssets[t]=e}updated(t){if(super.updated(t),t.has("ready")&&this.ready){const t=this.getLanguageCode(),e=br.find((e=>e===t));e&&wr(e)}}getCompletionSchema(){return this.schema}getFunctions(){return this.fnOptions}getKeyedAssets(){return this.keyedAssets}getFieldKeys(){return this.keyedAssets.fields||[]}getContactField(t){return this.fields[t]}getFeaturedFields(){return this.featuredFields}getLanguageName(t){return this.languages[t]}isDynamicGroup(t){const e=this.groups[t];return!(e&&!e.query)}getWorkspace(){return this.workspace}formatDate(t){return Hs.fromISO(t).setLocale(this.getLocale()).toLocaleString(Hs.DATETIME_SHORT)}postJSON(t,e=""){return Qt(t,e)}postForm(t,e,i={}){return((t,e,i={})=>{const o=new FormData;return Object.keys(e).forEach((t=>{o.append(t,e[t])})),Jt(t,o,i)})(t,e,i)}postUrl(t,e="",i={},o=null){return Kt(t,e,i,o)}getUrl(t,e){return!(e=e||{}).force&&this.cache.has(t)?new Promise((e=>{e(this.cache.get(t))})):jt(t,e.controller,e.headers||{}).then((e=>new Promise(((i,o)=>{e.status>=200&&e.status<=300?(this.cache.set(t,e),i(e)):o("Status: "+e.status)}))))}getResults(t,e){e=e||{};const i="results_"+t,o=this.cache.get(i);return!e.force&&o?new Promise((t=>{t(o)})):new Promise((e=>{const o=this.pendingResolves[t]||[];o.push(e),this.pendingResolves[t]=o,o.length<=1&&Wt(t).then((e=>{this.cache.set(i,e);const o=this.pendingResolves[t]||[];for(;o.length>0;){o.pop()(e)}}))}))}updateCache(t,e){this.cache.set(t,e),this.fireCustomEvent($e.StoreUpdated,{url:t,data:e})}removeFromCache(t){this.cache.delete(t)}resolveUsers(t,e){return new Promise((i=>{const o=new Set;t.forEach((t=>{e.forEach((e=>{const i=e.split(".");let n=t;for(let t=0;t<i.length&&(n=n[i[t]],n);t++);n&&n.email&&o.add(n.email)}))}));const n=[];o.forEach((t=>{n.push(this.getUrl(`/api/v2/users.json?email=${encodeURIComponent(t)}`))})),Promise.all(n).then((o=>{o.forEach((i=>{if(i&&i.json){const o=i.json.results;if(o&&1===o.length){const i=o[0];t.forEach((t=>{e.forEach((e=>{const o=e.split(".");let n=t,s=n;for(let t=0;t<o.length&&(s=n,n=n[o[t]],n);t++);if(n&&n.email===i.email){const t=s[o[o.length-1]];t.avatar=i.avatar,t.name=_r(i),s[o[o.length-1]].avatar=i.avatar}}))}))}}})),i()}))}))}makeRequest(t,e){const i=this.fetching[t],o=(new Date).getTime();if(i)return void setTimeout((()=>{this.makeRequest(t,e)}),500);let n=this.cache.get(t);n&&!e.force?(n=e.prepareData?e.prepareData(n):n,this.fireCustomEvent($e.StoreUpdated,{url:t,data:n})):(e=e||{},this.fetching[t]=o,Wt(t).then((i=>{i?(this.cache.set(t,i),delete this.fetching[t],i=e.prepareData?e.prepareData(i):i,this.fireCustomEvent($e.StoreUpdated,{url:t,data:i})):delete this.fetching[t]})))}get(t,e=null){return this.settings[t]||e}set(t,e){this.settings[t]=e}render(){if(!this.ready&&this.loader)return j`<temba-loading size="10" units="8"></temba-loading>`}}t([ce({type:Number})],kr.prototype,"ttl",void 0),t([ce({type:Number})],kr.prototype,"max",void 0),t([ce({type:Boolean})],kr.prototype,"ready",void 0),t([ce({type:Boolean})],kr.prototype,"loader",void 0),t([ce({type:String,attribute:"completion"})],kr.prototype,"completionEndpoint",void 0),t([ce({type:String,attribute:"fields"})],kr.prototype,"fieldsEndpoint",void 0),t([ce({type:String,attribute:"groups"})],kr.prototype,"groupsEndpoint",void 0),t([ce({type:String,attribute:"globals"})],kr.prototype,"globalsEndpoint",void 0),t([ce({type:String,attribute:"languages"})],kr.prototype,"languagesEndpoint",void 0),t([ce({type:String,attribute:"workspace"})],kr.prototype,"workspaceEndpoint",void 0),t([ce({type:String,attribute:"shortcuts"})],kr.prototype,"shortcutsEndpoint",void 0),t([ce({type:Object,attribute:!1})],kr.prototype,"schema",void 0),t([ce({type:Object,attribute:!1})],kr.prototype,"fnOptions",void 0),t([ce({type:Object,attribute:!1})],kr.prototype,"keyedAssets",void 0);class Ar extends pe{constructor(){super(...arguments),this.marginHorizontal=0,this.marginVertical=7,this.scrollPct=75,this.cursorIndex=-1,this.internalFocusDisabled=!1,this.nameKey="name",this.loading=!1,this.hideShadow=!1,this.getName=function(t){return t[this.nameKey||"name"]},this.renderInputOption=function(){return null},this.scrollHeight=0,this.triggerScroll=!1,this.scrollParent=null,this.setCursor=ee((function(t){this.internalFocusDisabled||t!==this.cursorIndex&&(this.cursorIndex=t)}),50)}static get styles(){return r`
|
|
396
396
|
:host {
|
|
397
397
|
--transition-speed: 0;
|
|
398
398
|
}
|