@telia-ace/widget-core-flamingo 1.1.70-rc.16 → 1.1.70-rc.18
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +6 -0
- package/index.mjs +6 -0
- package/package.json +1 -1
package/index.js
CHANGED
@@ -305,6 +305,7 @@
|
|
305
305
|
@media screen and (max-width: 800px) {
|
306
306
|
:host(.floating) {
|
307
307
|
inset: 0 0 95px 0;
|
308
|
+
height: 100vh;
|
308
309
|
}
|
309
310
|
}
|
310
311
|
@media screen and (min-width: 801px) {
|
@@ -325,6 +326,10 @@
|
|
325
326
|
:host(.floating) .widget-container {
|
326
327
|
box-shadow: rgba(0, 0, 0, 0.16) 0px 5px 40px;
|
327
328
|
border-radius: 0.7rem;
|
329
|
+
|
330
|
+
@media screen and (max-width: 800px) {
|
331
|
+
border-radius: 0;
|
332
|
+
}
|
328
333
|
}
|
329
334
|
|
330
335
|
* {
|
@@ -363,6 +368,7 @@
|
|
363
368
|
:host(.hidden) {
|
364
369
|
opacity: 0;
|
365
370
|
animation: slideDown 0.3s linear;
|
371
|
+
pointer-events: none;
|
366
372
|
}
|
367
373
|
`;Ti([m({attribute:!1}),Ei({context:ve})],rt.prototype,"application",2);class Ri{constructor(){this.root=this.createRoot()}createComponentModel(t,e){this.root.application=e;const i=a=>{if(Array.isArray(a)){const[c,...h]=a;return{definitionId:c,overrides:h}}return{definitionId:a,overrides:[]}},r=(a,c,h,l)=>{h.forEach(p=>{const f=i(p),u=l[f.definitionId];if(!u){console.error(`No definition found for component type '${f.definitionId}'.`);return}const g=a.createNode(u.type,u.type);g&&(g.name=f.definitionId,g.application=e,u.properties&&g.writeProperties(u.properties),u.context&&g.writeContext(u.context),u.layout&&g.writeLayout(u.layout),c.addChild(g),u.children&&r(a,g,u.children,l))})},{entry:n,components:o}=t;return r(this,this.root,[n],o),this.root}createRoot(){return new rt}createNode(t,e){const i=this.resolveComponent(e);if(!i)return console.warn(`Unable to resolve component: ${e}`),new St;const r=new i;return r.type=e,r.name=t,r}resolveComponent(t){return customElements.get(`ace-${t}`)}getRoot(){return this.root}}const ye=class{constructor(){this.components=new Map}getComponent(s){const t=this.components.get(s);return t||console.warn(`Unable to resolve component: ${s}. You most likely forgot to register the required plugin.`),t}registerComponent(s,t){this.components.set(s,t)}async loadComponents(){const s=[...this.components.entries()].map(([t,e])=>e.then(i=>{this.defineAsWebComponent(t,i.default)}));await Promise.all(s)}defineAsWebComponent(s,t){const e=ye.ResolveWebComponentName(s);customElements.get(e)||customElements.define(e,t)}};let be=ye;be.ResolveWebComponentName=s=>`ace-${s}`;class $e{constructor(t){this.widgetId=t}_prefixKey(t){return`ace_${this.widgetId.substring(0,7)}-${t}`}set(t,e){sessionStorage.setItem(this._prefixKey(t),e)}get(t){const e=sessionStorage.getItem(this._prefixKey(t));if(!e)return null;try{return JSON.parse(e)}catch{return e}}}class Ii{constructor(){this.texts=new Map}loadTexts(t){this.texts=new Map(Object.entries(t))}get(t,e){const i=this.texts.get(t);return i||e||null}getOrFallback(t,e){return this.texts.get(t)||e}}class _e{constructor(t,e,i,r,n){this.id=t,this.name=e,this.container=i,this.settings=r,this.options=n,this.platform=new Ri,this.texts=new Ii,this.renderStrategy=y.Inline,this.anchor="BottomRight",this.autoActivate=!1,this.plugins=[],this.componentResolver=new be,this.components=[],this.trigger=null,this.renderStrategy=this.options.renderStrategy||y.Inline,this.triggerIcon=this.options.triggerIcon,this.storage=new $e(this.id),typeof n.autoActivate=="boolean"&&(this.autoActivate=n.autoActivate),n.anchor&&(this.anchor=n.anchor),this.container.register("$settings",r),this.texts.loadTexts(r.texts||{})}async activate(){if(await this.loadPlugins(),await this.componentResolver.loadComponents(),this.root=this.platform.createComponentModel(this.settings,this),this.container.setState(se.Ready),this.autoActivate){const t=this.render();t&&this._getTargetElement().appendChild(t)}}async loadPlugins(){for await(const t of this.plugins)await t(this)}styles(){return this.settings.styles||{}}branding(){return this.settings.branding||{}}plugin(t){return this.plugins.push(t),this}appendToDOM(){this.root&&(this.root.classList.add("expanded"),this.root.classList.remove("hidden"),document.body.appendChild(this.root)),this.storage.set("open","true")}hide(){this.root&&(this.root.classList.add("hidden"),this.root.classList.remove("expanded")),this.storage.set("open","false")}mute(){this.storage.set("muteAudioNotifications","true")}unmute(){this.storage.set("muteAudioNotifications","false")}registerComponent(t,e){this.componentResolver.registerComponent(t,e)}resolveComponent(t){return this.componentResolver.getComponent(t)}mountComponent(t){this.components.push(t)}getComponent(t){const e=this.components.find(i=>i.type===t);return e||null}_getTargetElement(){let t="bottom-right";if(this.anchor==="BottomRight"?t="bottom-right":this.anchor==="BottomLeft"&&(t="bottom-left"),this.renderStrategy===y.Trigger){let e=document.querySelector(`ace-trigger-slot.${t}`);return e||(e=new it,e.anchor=this.anchor,document.body.appendChild(e)),e}return document.body}render(){if(this.renderStrategy===y.Trigger){const t=new _;return t.application=this,this.trigger=t,this.storage.get("open")&&this.trigger.toggleActive(),t}return this.root}}const Ui=s=>new B(s),we=class{constructor(s=we.endpoint){this._endpoint=s}async getSite(s){const e=await(await fetch(s)).json();return e?{id:e.id,apps:e.widgets.map(i=>{let r=y.Inline;return i.renderStrategy==="Trigger"&&(r=y.Trigger),{id:i.id,widgetId:i.widgetId,renderStrategy:r,autoActivate:i.autoActivate,anchor:i.anchor,triggerIcon:{type:"Telia",content:i.triggerIcon}}})}:null}async getWidget(s){const e=await(await fetch(`${this._endpoint}/widget/${s}`)).json();return e?{name:e.name,config:JSON.parse(e.configuration)}:null}};let B=we;B.endpoint="https://widgets.ace.teliacompany.net/api";class Ae{constructor(){this.applications=[],this.container=new bt("environment",this),setTimeout(()=>{this.notifyWidgetsOfCreation()},1e3)}async bootstrap(){await this.activate()}async activate(){const t=this.applications.filter(e=>e.autoActivate);for await(const e of t)await e.activate()}notifyWidgetsOfCreation(){document.querySelectorAll("ace-widget").forEach(e=>{const i=this.applications.find(r=>r.name===e.name);i&&e.dispatchEvent(new CustomEvent("environment-created",{detail:{widget:i}}))})}registerApp(t,e,i,r){const n=new bt(e,this),o=new _e(t,e,n,i,r);this.applications.push(o)}plugin(t){return this.applications.forEach(e=>{e.plugin(t)}),this}}class xe{constructor(t){this.configurations=[],this.httpClient=new B,this.httpClient=new B,typeof t=="string"?this.url=t:(t.httpClient&&(this.httpClient=t.httpClient),this.loadFromConfig(t))}async load(t){const e=await this.httpClient.getSite(t);if(!e){console.warn(`Unable to load site from the url provided: ${t}`);return}this.configurations=e.apps}loadFromConfig(t){this.configurations=t.apps.map(e=>({id:"",renderStrategy:e.renderStrategy,widgetId:e.widgetId,autoActivate:e.autoActivate,anchor:e.anchor,triggerIcon:{type:"Telia",content:e.triggerIcon||"question"}}))}async bootstrap(t){var e;this.url&&await this.load(this.url),this.environment=new Ae,this.addGlobal(this.environment);for await(const i of this.configurations){const r=await this.httpClient.getWidget(i.widgetId);r&&((e=this.environment)==null||e.registerApp(i.widgetId,r.name,r.config,{renderStrategy:i.renderStrategy,triggerIcon:i.triggerIcon,autoActivate:i.autoActivate,anchor:i.anchor}))}t(this.environment),await this.environment.bootstrap()}addGlobal(t){globalThis.widgets=t}}var ki=Object.defineProperty,ji=Object.getOwnPropertyDescriptor,Et=(s,t,e,i)=>{for(var r=i>1?void 0:i?ji(t,e):t,n=s.length-1,o;n>=0;n--)(o=s[n])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&ki(t,e,r),r};class U extends ${constructor(){super(),this.status="deactivated",this.addEventListener("environment-created",this.onEnvironmentCreated)}async connectedCallback(){super.connectedCallback(),await this.getGlobalEnvironment()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("environment-created",this.onEnvironmentCreated)}async onEnvironmentCreated(t){this.widget=t.detail.widget,await this.activate(),this.requestUpdate()}async activate(){this.widget&&(await this.widget.activate(),this.status="activated")}async getGlobalEnvironment(){const t=globalThis.widgets;t&&(this.widget=t.applications.find(e=>e.name===this.name),await this.activate())}render(){if(!this.widget||this.status!=="activated")return d;if(this.widget.renderStrategy===y.Trigger){const t=new _;return t.application=this.widget,t}return this.widget.render()}}U.styles=[I`
|
368
374
|
:host {
|
package/index.mjs
CHANGED
@@ -2109,6 +2109,7 @@ rt.styles = I`
|
|
2109
2109
|
@media screen and (max-width: 800px) {
|
2110
2110
|
:host(.floating) {
|
2111
2111
|
inset: 0 0 95px 0;
|
2112
|
+
height: 100vh;
|
2112
2113
|
}
|
2113
2114
|
}
|
2114
2115
|
@media screen and (min-width: 801px) {
|
@@ -2129,6 +2130,10 @@ rt.styles = I`
|
|
2129
2130
|
:host(.floating) .widget-container {
|
2130
2131
|
box-shadow: rgba(0, 0, 0, 0.16) 0px 5px 40px;
|
2131
2132
|
border-radius: 0.7rem;
|
2133
|
+
|
2134
|
+
@media screen and (max-width: 800px) {
|
2135
|
+
border-radius: 0;
|
2136
|
+
}
|
2132
2137
|
}
|
2133
2138
|
|
2134
2139
|
* {
|
@@ -2167,6 +2172,7 @@ rt.styles = I`
|
|
2167
2172
|
:host(.hidden) {
|
2168
2173
|
opacity: 0;
|
2169
2174
|
animation: slideDown 0.3s linear;
|
2175
|
+
pointer-events: none;
|
2170
2176
|
}
|
2171
2177
|
`;
|
2172
2178
|
Ci([
|