@telia-ace/widget-site 1.1.120-rc.0 → 1.1.120-rc.10
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/environment.d.ts +17 -0
- package/icon.component.d.ts +11 -0
- package/icons/question.d.ts +5 -0
- package/index.d.ts +2 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/index.umd.js +1 -1
- package/package.json +1 -1
- package/site-api.d.ts +13 -0
- package/site.component.d.ts +40 -0
- package/trigger.component.d.ts +27 -0
- package/types/trigger.d.ts +21 -0
- package/types/widget.d.ts +8 -0
- package/types.d.ts +4 -0
- package/utils/create-svg.d.ts +11 -0
- package/utils/map-branding.d.ts +1 -0
- package/utils/metadata.d.ts +2 -0
- package/utils/storage-parser.d.ts +1 -0
- package/widget-api.d.ts +9 -0
- package/widget.component.d.ts +41 -0
package/environment.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SiteAPI } from './site-api';
|
|
2
|
+
import { SiteConfigurationHandler, WidgetAPIHandler } from './types';
|
|
3
|
+
export declare class Environment {
|
|
4
|
+
private _api;
|
|
5
|
+
private _bootstrapped;
|
|
6
|
+
private _widgetAPIHandlers;
|
|
7
|
+
constructor(_api: SiteAPI);
|
|
8
|
+
bootstrap(): void;
|
|
9
|
+
private _bootstrap;
|
|
10
|
+
executePreloadedHandlers(widgetName: string): void;
|
|
11
|
+
configure(delegate: SiteConfigurationHandler): void;
|
|
12
|
+
version(): {
|
|
13
|
+
sites: string;
|
|
14
|
+
widgets: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
widget(name: string, delegate: WidgetAPIHandler): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class IconComponent extends HTMLElement {
|
|
2
|
+
get svg(): string;
|
|
3
|
+
set svg(value: string);
|
|
4
|
+
get size(): string;
|
|
5
|
+
set size(value: string);
|
|
6
|
+
static get observedAttributes(): string[];
|
|
7
|
+
shadow: ShadowRoot;
|
|
8
|
+
constructor();
|
|
9
|
+
attributeChangedCallback(_name: string, _oldVal: string, _newVal: string): void;
|
|
10
|
+
render(): void;
|
|
11
|
+
}
|
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class T{constructor(t){this._api=t,this._bootstrapped=!1,this._widgetAPIHandlers=new Map,window.ace=window.ace||{_c:[],_w:[],widget:function(e,i){window.ace._w.push([e,i])},configure:function(e){window.ace._c.push(e)}}}bootstrap(){this._bootstrap()}_bootstrap(){const t=globalThis.ace;globalThis.ace=this,this._bootstrapped=!0,((t==null?void 0:t._w)||[]).forEach(([e,i])=>{this.widget(e,i)}),((t==null?void 0:t._c)||[]).forEach(e=>{this.configure(e)})}executePreloadedHandlers(t){(this._widgetAPIHandlers.get(t)||[]).forEach(i=>{i()}),this._widgetAPIHandlers.set(t,[])}configure(t){if(!this._bootstrapped)throw new Error("ace environment not bootstrapped");t(this._api)}version(){return this._api.version()}widget(t,e){const i=Object.values(this._api.getWidgets()).find(s=>{var n;return((n=s.widget)==null?void 0:n.name)===t});if(!i){const s=this._widgetAPIHandlers.get(t)||[];s.push(()=>{const n=Object.values(this._api.getWidgets()).find(a=>{var d;return((d=a.widget)==null?void 0:d.name)===t});e(n==null?void 0:n.api)}),this._widgetAPIHandlers.set(t,s);return}e(i.api)}}const $="
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class T{constructor(t){this._api=t,this._bootstrapped=!1,this._widgetAPIHandlers=new Map,window.ace=window.ace||{_c:[],_w:[],widget:function(e,i){window.ace._w.push([e,i])},configure:function(e){window.ace._c.push(e)}}}bootstrap(){this._bootstrap()}_bootstrap(){const t=globalThis.ace;globalThis.ace=this,this._bootstrapped=!0,((t==null?void 0:t._w)||[]).forEach(([e,i])=>{this.widget(e,i)}),((t==null?void 0:t._c)||[]).forEach(e=>{this.configure(e)})}executePreloadedHandlers(t){(this._widgetAPIHandlers.get(t)||[]).forEach(i=>{i()}),this._widgetAPIHandlers.set(t,[])}configure(t){if(!this._bootstrapped)throw new Error("ace environment not bootstrapped");t(this._api)}version(){return this._api.version()}widget(t,e){const i=Object.values(this._api.getWidgets()).find(s=>{var n;return((n=s.widget)==null?void 0:n.name)===t});if(!i){const s=this._widgetAPIHandlers.get(t)||[];s.push(()=>{const n=Object.values(this._api.getWidgets()).find(a=>{var d;return((d=a.widget)==null?void 0:d.name)===t});e(n==null?void 0:n.api)}),this._widgetAPIHandlers.set(t,s);return}e(i.api)}}const $="1.1.120-rc.10";class z{constructor(t){this._site=t}storagePolicy(t){Object.entries(this._site._widgets).forEach(([e,i])=>{i.dispatch("set-storage-policies",{policies:t})})}disallowStorageKey(t){Object.entries(this._site._widgets).forEach(([e,i])=>{i.dispatch("disallow-storage-key",{storageKey:t})})}getWidgets(){return this._site._widgets}version(){const t=$;return{widgets:this._site.getWidgetsVersions(),sites:t}}}class M{constructor(t,e){this.triggerType=t,this.condition=e,this.triggerType=t,this.condition=e}shouldActivate(t){if(this.triggerType!=="visit"||this.condition.type!=="url")return[];const e=[];return this.condition.outputs.filter(i=>i.action.type==="render_widget"&&B(i.value,t)).forEach(i=>{let s={widgetId:""};try{s=JSON.parse(i.action.data)}catch{s={widgetId:""}}e.push(s.widgetId)}),e}}const B=(r,t)=>{if(r==="*"||r==="/*"||r===t)return!0;if(r.endsWith("/*")){const s=r.slice(0,-2);return t.startsWith(s)}return!1},U=(r,t)=>{const e=s=>`ace_${r.substring(0,7)}-${s}`;return Object.entries(t).reduce((s,[n,a])=>{const[d,c]=n.split("-");if(e(c)!=n)return s;try{const o=JSON.parse(a);s[c]=o.value}catch{return s}return s},{})},u="https://widgets.ace.teliacompany.net",H="https://embed.webprovisions.io",W=()=>{if(typeof window<"u"){const r=history.pushState,t=history.replaceState;history.pushState=function(...e){r.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class y extends HTMLElement{constructor(){var t;super(),this._site=null,this._widgets={},this._loadedVersions={},this._path=((t=window==null?void 0:window.location)==null?void 0:t.pathname)||"",this._api=new z(this),this._environment=new T(this._api),this.routeChangeListener=()=>{this._path=window.location.pathname,this.render()},this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["siteid","apiurl","embedurl"]}get siteId(){return this.getAttribute("siteid")||""}set siteId(t){this.setAttribute("siteid",t)}get apiUrl(){return this.getAttribute("apiurl")||u}set apiUrl(t){this.setAttribute("apiurl",t)}get embedUrl(){return this.getAttribute("embedurl")||H}set embedUrl(t){this.setAttribute("embedurl",t)}async connectedCallback(){W(),await this._loadSite(),this.render(),this._environment.bootstrap(),window.addEventListener("locationchange",this.routeChangeListener),window.addEventListener("message",t=>{var s;const{type:e,data:i}=t.data;if(e==="widget-minimize")this._widgets[i.widgetId].toggleExpand();else if(e==="widget-activated"){this._widgets[i.widgetId].executeMessageQueue();const n=this._widgets[i.widgetId];n&&(this._loadedVersions[i.widgetId]=i.version,this._environment.executePreloadedHandlers(((s=n.widget)==null?void 0:s.name)||""));try{const a=JSON.parse(i.storage),d=U(i.widgetId,a);typeof d.open=="boolean"&&(n.disableAnimations(),n.toggleExpand(d.open),setTimeout(()=>{n.enableAnimations()},600))}catch{console.warn("unable to parse widget storage")}}})}disconnectedCallback(){window.removeEventListener("locationchange",this.routeChangeListener)}attributeChangedCallback(t,e,i){this.render()}async _loadSite(){var s;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json(),i=location.hostname;if(!((e==null?void 0:e.hosts)||[]).includes(i)){console.warn(`the host "${i}" needs to be configured as an allowed host in order to install widgets.`);return}this._site=e,this._site&&(this._site.triggers=this._site.triggers.map(n=>new M(n.triggerType,n.condition))),(((s=this._site)==null?void 0:s.widgets)||[]).forEach(async n=>{this.addWidgetEl(n.id)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget"),i.id=e,i.widgetId=t,this.apiUrl!==u&&(i.apiUrl=this.apiUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i}}getWidgetsVersions(){return this._loadedVersions}render(){if(!this._site){this.shadow.innerHTML="";return}const t=O(this._site);for(const[e,i]of Object.entries(this._widgets)){const s=t.find(n=>n.id===e);s&&!i.isActivated()?i.activate():!s&&i.isActivated()&&i.deactivate()}this.shadow.innerHTML=""}}window.customElements.get("ace-site")||window.customElements.define("ace-site",y);const O=r=>{const t=window.location.pathname;return r.triggers.reduce((i,s)=>(s.shouldActivate(t).forEach(a=>{const d=i.find(o=>o.id===a),c=((r==null?void 0:r.widgets)||[]).find(o=>o.id===a);!d&&c&&i.push({id:a})}),i),[])},g=(r,t,e)=>{r&&e.style.setProperty(t,r)},P=(r,t)=>{var e,i,s,n,a,d,c,o,l;g((e=r.colors)==null?void 0:e.primaryBackground,"--primary-background",t),g((i=r.colors)==null?void 0:i.textOnPrimaryBackground,"--text-on-primary-background",t),g((s=r.colors)==null?void 0:s.secondaryBackground,"--secondary-background",t),g((n=r.colors)==null?void 0:n.textOnSecondaryBackground,"--text-on-secondary-background",t),g((a=r.colors)==null?void 0:a.interactiveDestructiveBackground,"--destructive-color",t),g((d=r.colors)==null?void 0:d.interactiveTextOnDestructiveBackground,"--text-on-destructive-color",t),g((c=r.colors)==null?void 0:c.interactivePrimaryBackground,"--interactive-primary-background",t),g((o=r.colors)==null?void 0:o.interactiveTextOnPrimaryBackground,"--interactive-text-on-primary-background",t),g((l=r.colors)==null?void 0:l.focusColor,"--focus-color",t)},j=(r={})=>{const{content:t="",title:e,attributes:i=[]}=r;let s="";const n=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},...i];return e&&(s=`<title>${e}</title>`),`<svg ${n.map(d=>`${d.name}="${d.value}"`).join(" ")}>${s}${t}</svg>`},_=document.createElement("template");_.innerHTML=`<span
|
|
2
2
|
class="ace-icon__container"
|
|
3
3
|
></span>`;const x=document.createElement("template");var f;const p=(f=document.querySelector("script[nonce]"))==null?void 0:f.getAttribute("nonce");x.innerHTML=`<style ${p?`nonce="${p}"`:""}>
|
|
4
4
|
:host {
|
package/index.mjs
CHANGED
package/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(h,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(h=typeof globalThis<"u"?globalThis:h||self,u(h["@telia-ace/widget-site"]={}))})(this,function(h){"use strict";var I,S,T;class u{constructor(t){this._api=t,this._bootstrapped=!1,this._widgetAPIHandlers=new Map,window.ace=window.ace||{_c:[],_w:[],widget:function(e,i){window.ace._w.push([e,i])},configure:function(e){window.ace._c.push(e)}}}bootstrap(){this._bootstrap()}_bootstrap(){const t=globalThis.ace;globalThis.ace=this,this._bootstrapped=!0,((t==null?void 0:t._w)||[]).forEach(([e,i])=>{this.widget(e,i)}),((t==null?void 0:t._c)||[]).forEach(e=>{this.configure(e)})}executePreloadedHandlers(t){(this._widgetAPIHandlers.get(t)||[]).forEach(i=>{i()}),this._widgetAPIHandlers.set(t,[])}configure(t){if(!this._bootstrapped)throw new Error("ace environment not bootstrapped");t(this._api)}version(){return this._api.version()}widget(t,e){const i=Object.values(this._api.getWidgets()).find(s=>{var n;return((n=s.widget)==null?void 0:n.name)===t});if(!i){const s=this._widgetAPIHandlers.get(t)||[];s.push(()=>{const n=Object.values(this._api.getWidgets()).find(a=>{var d;return((d=a.widget)==null?void 0:d.name)===t});e(n==null?void 0:n.api)}),this._widgetAPIHandlers.set(t,s);return}e(i.api)}}const z="
|
|
1
|
+
(function(h,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(h=typeof globalThis<"u"?globalThis:h||self,u(h["@telia-ace/widget-site"]={}))})(this,function(h){"use strict";var I,S,T;class u{constructor(t){this._api=t,this._bootstrapped=!1,this._widgetAPIHandlers=new Map,window.ace=window.ace||{_c:[],_w:[],widget:function(e,i){window.ace._w.push([e,i])},configure:function(e){window.ace._c.push(e)}}}bootstrap(){this._bootstrap()}_bootstrap(){const t=globalThis.ace;globalThis.ace=this,this._bootstrapped=!0,((t==null?void 0:t._w)||[]).forEach(([e,i])=>{this.widget(e,i)}),((t==null?void 0:t._c)||[]).forEach(e=>{this.configure(e)})}executePreloadedHandlers(t){(this._widgetAPIHandlers.get(t)||[]).forEach(i=>{i()}),this._widgetAPIHandlers.set(t,[])}configure(t){if(!this._bootstrapped)throw new Error("ace environment not bootstrapped");t(this._api)}version(){return this._api.version()}widget(t,e){const i=Object.values(this._api.getWidgets()).find(s=>{var n;return((n=s.widget)==null?void 0:n.name)===t});if(!i){const s=this._widgetAPIHandlers.get(t)||[];s.push(()=>{const n=Object.values(this._api.getWidgets()).find(a=>{var d;return((d=a.widget)==null?void 0:d.name)===t});e(n==null?void 0:n.api)}),this._widgetAPIHandlers.set(t,s);return}e(i.api)}}const z="1.1.120-rc.10";class M{constructor(t){this._site=t}storagePolicy(t){Object.entries(this._site._widgets).forEach(([e,i])=>{i.dispatch("set-storage-policies",{policies:t})})}disallowStorageKey(t){Object.entries(this._site._widgets).forEach(([e,i])=>{i.dispatch("disallow-storage-key",{storageKey:t})})}getWidgets(){return this._site._widgets}version(){const t=z;return{widgets:this._site.getWidgetsVersions(),sites:t}}}class B{constructor(t,e){this.triggerType=t,this.condition=e,this.triggerType=t,this.condition=e}shouldActivate(t){if(this.triggerType!=="visit"||this.condition.type!=="url")return[];const e=[];return this.condition.outputs.filter(i=>i.action.type==="render_widget"&&U(i.value,t)).forEach(i=>{let s={widgetId:""};try{s=JSON.parse(i.action.data)}catch{s={widgetId:""}}e.push(s.widgetId)}),e}}const U=(r,t)=>{if(r==="*"||r==="/*"||r===t)return!0;if(r.endsWith("/*")){const s=r.slice(0,-2);return t.startsWith(s)}return!1},H=(r,t)=>{const e=s=>`ace_${r.substring(0,7)}-${s}`;return Object.entries(t).reduce((s,[n,a])=>{const[d,c]=n.split("-");if(e(c)!=n)return s;try{const o=JSON.parse(a);s[c]=o.value}catch{return s}return s},{})},p="https://widgets.ace.teliacompany.net",W="https://embed.webprovisions.io",O=()=>{if(typeof window<"u"){const r=history.pushState,t=history.replaceState;history.pushState=function(...e){r.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class m extends HTMLElement{constructor(){var t;super(),this._site=null,this._widgets={},this._loadedVersions={},this._path=((t=window==null?void 0:window.location)==null?void 0:t.pathname)||"",this._api=new M(this),this._environment=new u(this._api),this.routeChangeListener=()=>{this._path=window.location.pathname,this.render()},this.shadow=this.attachShadow({mode:"open"})}static get observedAttributes(){return["siteid","apiurl","embedurl"]}get siteId(){return this.getAttribute("siteid")||""}set siteId(t){this.setAttribute("siteid",t)}get apiUrl(){return this.getAttribute("apiurl")||p}set apiUrl(t){this.setAttribute("apiurl",t)}get embedUrl(){return this.getAttribute("embedurl")||W}set embedUrl(t){this.setAttribute("embedurl",t)}async connectedCallback(){O(),await this._loadSite(),this.render(),this._environment.bootstrap(),window.addEventListener("locationchange",this.routeChangeListener),window.addEventListener("message",t=>{var s;const{type:e,data:i}=t.data;if(e==="widget-minimize")this._widgets[i.widgetId].toggleExpand();else if(e==="widget-activated"){this._widgets[i.widgetId].executeMessageQueue();const n=this._widgets[i.widgetId];n&&(this._loadedVersions[i.widgetId]=i.version,this._environment.executePreloadedHandlers(((s=n.widget)==null?void 0:s.name)||""));try{const a=JSON.parse(i.storage),d=H(i.widgetId,a);typeof d.open=="boolean"&&(n.disableAnimations(),n.toggleExpand(d.open),setTimeout(()=>{n.enableAnimations()},600))}catch{console.warn("unable to parse widget storage")}}})}disconnectedCallback(){window.removeEventListener("locationchange",this.routeChangeListener)}attributeChangedCallback(t,e,i){this.render()}async _loadSite(){var s;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json(),i=location.hostname;if(!((e==null?void 0:e.hosts)||[]).includes(i)){console.warn(`the host "${i}" needs to be configured as an allowed host in order to install widgets.`);return}this._site=e,this._site&&(this._site.triggers=this._site.triggers.map(n=>new B(n.triggerType,n.condition))),(((s=this._site)==null?void 0:s.widgets)||[]).forEach(async n=>{this.addWidgetEl(n.id)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget"),i.id=e,i.widgetId=t,this.apiUrl!==p&&(i.apiUrl=this.apiUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i}}getWidgetsVersions(){return this._loadedVersions}render(){if(!this._site){this.shadow.innerHTML="";return}const t=P(this._site);for(const[e,i]of Object.entries(this._widgets)){const s=t.find(n=>n.id===e);s&&!i.isActivated()?i.activate():!s&&i.isActivated()&&i.deactivate()}this.shadow.innerHTML=""}}window.customElements.get("ace-site")||window.customElements.define("ace-site",m);const P=r=>{const t=window.location.pathname;return r.triggers.reduce((i,s)=>(s.shouldActivate(t).forEach(a=>{const d=i.find(o=>o.id===a),c=((r==null?void 0:r.widgets)||[]).find(o=>o.id===a);!d&&c&&i.push({id:a})}),i),[])},g=(r,t,e)=>{r&&e.style.setProperty(t,r)},j=(r,t)=>{var e,i,s,n,a,d,c,o,l;g((e=r.colors)==null?void 0:e.primaryBackground,"--primary-background",t),g((i=r.colors)==null?void 0:i.textOnPrimaryBackground,"--text-on-primary-background",t),g((s=r.colors)==null?void 0:s.secondaryBackground,"--secondary-background",t),g((n=r.colors)==null?void 0:n.textOnSecondaryBackground,"--text-on-secondary-background",t),g((a=r.colors)==null?void 0:a.interactiveDestructiveBackground,"--destructive-color",t),g((d=r.colors)==null?void 0:d.interactiveTextOnDestructiveBackground,"--text-on-destructive-color",t),g((c=r.colors)==null?void 0:c.interactivePrimaryBackground,"--interactive-primary-background",t),g((o=r.colors)==null?void 0:o.interactiveTextOnPrimaryBackground,"--interactive-text-on-primary-background",t),g((l=r.colors)==null?void 0:l.focusColor,"--focus-color",t)},V=(r={})=>{const{content:t="",title:e,attributes:i=[]}=r;let s="";const n=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},...i];return e&&(s=`<title>${e}</title>`),`<svg ${n.map(d=>`${d.name}="${d.value}"`).join(" ")}>${s}${t}</svg>`},w=document.createElement("template");w.innerHTML=`<span
|
|
2
2
|
class="ace-icon__container"
|
|
3
3
|
></span>`;const f=document.createElement("template"),b=(I=document.querySelector("script[nonce]"))==null?void 0:I.getAttribute("nonce");f.innerHTML=`<style ${b?`nonce="${b}"`:""}>
|
|
4
4
|
:host {
|
package/package.json
CHANGED
package/site-api.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SiteComponent } from './site.component';
|
|
2
|
+
import { WidgetComponent } from './widget.component';
|
|
3
|
+
export declare class SiteAPI {
|
|
4
|
+
private _site;
|
|
5
|
+
constructor(_site: SiteComponent);
|
|
6
|
+
storagePolicy(policies: string[]): void;
|
|
7
|
+
disallowStorageKey(key: string): void;
|
|
8
|
+
getWidgets(): Record<string, WidgetComponent>;
|
|
9
|
+
version(): {
|
|
10
|
+
sites: string;
|
|
11
|
+
widgets: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Environment } from './environment';
|
|
2
|
+
import { SiteAPI } from './site-api';
|
|
3
|
+
import { Trigger } from './types/trigger';
|
|
4
|
+
import { WidgetComponent } from './widget.component';
|
|
5
|
+
type Site = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
triggers: Trigger[];
|
|
9
|
+
hosts: string[];
|
|
10
|
+
widgets: WidgetDefinition[];
|
|
11
|
+
};
|
|
12
|
+
type WidgetDefinition = {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
export declare class SiteComponent extends HTMLElement {
|
|
16
|
+
static get observedAttributes(): string[];
|
|
17
|
+
get siteId(): string;
|
|
18
|
+
set siteId(value: string);
|
|
19
|
+
get apiUrl(): string;
|
|
20
|
+
set apiUrl(value: string);
|
|
21
|
+
get embedUrl(): string;
|
|
22
|
+
set embedUrl(value: string);
|
|
23
|
+
_site: Site | null;
|
|
24
|
+
_widgets: Record<string, WidgetComponent>;
|
|
25
|
+
_loadedVersions: Record<string, string>;
|
|
26
|
+
_path: string;
|
|
27
|
+
_api: SiteAPI;
|
|
28
|
+
_environment: Environment;
|
|
29
|
+
shadow: ShadowRoot;
|
|
30
|
+
constructor();
|
|
31
|
+
connectedCallback(): Promise<void>;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
attributeChangedCallback(_name: string, _oldVal: string, _newVal: string): void;
|
|
34
|
+
routeChangeListener: () => void;
|
|
35
|
+
_loadSite(): Promise<void>;
|
|
36
|
+
addWidgetEl(widgetId: string): void;
|
|
37
|
+
getWidgetsVersions(): Record<string, string>;
|
|
38
|
+
render(): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Widget } from './types/widget';
|
|
2
|
+
import { IconComponent } from './icon.component';
|
|
3
|
+
export declare class TriggerComponent extends HTMLElement {
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
get widgetId(): string;
|
|
6
|
+
set widgetId(value: string);
|
|
7
|
+
get apiUrl(): string;
|
|
8
|
+
set apiUrl(value: string);
|
|
9
|
+
widget: Widget | null;
|
|
10
|
+
loaded: boolean;
|
|
11
|
+
active: boolean;
|
|
12
|
+
icon: any;
|
|
13
|
+
shadow: ShadowRoot;
|
|
14
|
+
constructor();
|
|
15
|
+
connectedCallback(): Promise<void>;
|
|
16
|
+
attributeChangedCallback(_name: string, _oldVal: string, _newVal: string): void;
|
|
17
|
+
_onClicked: () => void;
|
|
18
|
+
setActive(active: boolean): void;
|
|
19
|
+
_applyBranding(): void;
|
|
20
|
+
private _loadWidget;
|
|
21
|
+
_renderSymbol(): Promise<IconComponent | HTMLImageElement | null>;
|
|
22
|
+
toggle(): void;
|
|
23
|
+
hide(): void;
|
|
24
|
+
show(): void;
|
|
25
|
+
private _renderButtonLabel;
|
|
26
|
+
render(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class Trigger {
|
|
2
|
+
triggerType: string;
|
|
3
|
+
condition: TriggerType['condition'];
|
|
4
|
+
constructor(triggerType: string, condition: TriggerType['condition']);
|
|
5
|
+
shouldActivate(currentLocation: string): string[];
|
|
6
|
+
}
|
|
7
|
+
type TriggerType = {
|
|
8
|
+
triggerType: string;
|
|
9
|
+
condition: {
|
|
10
|
+
type: 'url' | string;
|
|
11
|
+
outputs: {
|
|
12
|
+
value: string;
|
|
13
|
+
action: {
|
|
14
|
+
type: 'render_widget' | string;
|
|
15
|
+
data: string;
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const pathMatches: (path: string, currentLocation: string) => boolean;
|
|
21
|
+
export {};
|
package/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mapBranding: (context: Record<string, any>, el: HTMLElement) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseStorage: (widgetId: string, storage: Record<string, string>) => Record<string, any>;
|
package/widget-api.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WidgetComponent } from './widget.component';
|
|
2
|
+
export declare class WidgetAPI {
|
|
3
|
+
widgetEl: WidgetComponent;
|
|
4
|
+
constructor(widgetEl: WidgetComponent);
|
|
5
|
+
open(): void;
|
|
6
|
+
close(): void;
|
|
7
|
+
setZIndex(zIndex: number): void;
|
|
8
|
+
setFullscreenMode(value: boolean): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TriggerComponent } from './trigger.component';
|
|
2
|
+
import { Widget } from './types/widget';
|
|
3
|
+
import { WidgetAPI } from './widget-api';
|
|
4
|
+
export declare class WidgetComponent extends HTMLElement {
|
|
5
|
+
static get observedAttributes(): string[];
|
|
6
|
+
shadow: ShadowRoot;
|
|
7
|
+
widget: Widget | null;
|
|
8
|
+
activated: boolean;
|
|
9
|
+
active: boolean;
|
|
10
|
+
iframeEl: HTMLIFrameElement | null;
|
|
11
|
+
trigger: TriggerComponent | null;
|
|
12
|
+
_messageQueue: {
|
|
13
|
+
type: string;
|
|
14
|
+
data: Record<string, any>;
|
|
15
|
+
}[];
|
|
16
|
+
api: WidgetAPI;
|
|
17
|
+
zIndex: number;
|
|
18
|
+
get expanded(): string;
|
|
19
|
+
set expanded(value: string);
|
|
20
|
+
get widgetId(): string;
|
|
21
|
+
set widgetId(value: string);
|
|
22
|
+
get apiUrl(): string;
|
|
23
|
+
set apiUrl(value: string);
|
|
24
|
+
constructor();
|
|
25
|
+
attributeChangedCallback(_name: string, _oldVal: string, _newVal: string): void;
|
|
26
|
+
connectedCallback(): Promise<void>;
|
|
27
|
+
isActivated(): boolean;
|
|
28
|
+
disableAnimations(): void;
|
|
29
|
+
enableAnimations(): void;
|
|
30
|
+
private _getContainerEl;
|
|
31
|
+
activate(): Promise<void>;
|
|
32
|
+
private _loadWidget;
|
|
33
|
+
dispatch(type: string, data?: Record<string, any>): void;
|
|
34
|
+
deactivate(): Promise<void>;
|
|
35
|
+
private _createIFrame;
|
|
36
|
+
executeMessageQueue(): void;
|
|
37
|
+
isExpanded(): boolean;
|
|
38
|
+
toggleExpand(value?: boolean): void;
|
|
39
|
+
setZIndex(value: number): void;
|
|
40
|
+
render(): void;
|
|
41
|
+
}
|