@telia-ace/widget-core-flamingo 1.1.36-rc.0 → 1.1.36-rc.1

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -333,7 +333,7 @@
333
333
  opacity: 0;
334
334
  animation: slideDown 0.3s linear;
335
335
  }
336
- `;wi([m({attribute:!1})],st.prototype,"application",2);class Ai{constructor(){this.root=this.createRoot()}createComponentModel(t,e){this.root.application=e;const i=a=>{if(Array.isArray(a)){const[c,...l]=a;return{definitionId:c,overrides:l}}return{definitionId:a,overrides:[]}},s=(a,c,l,h)=>{l.forEach(p=>{const u=i(p),f=h[u.definitionId];if(!f){console.error(`No definition found for component type '${u.definitionId}'.`);return}const g=a.createNode(f.type,f.type);g&&(g.name=u.definitionId,g.application=e,f.properties&&g.writeProperties(f.properties),f.context&&g.writeContext(f.context),f.layout&&g.writeLayout(f.layout),c.addChild(g),f.children&&s(a,g,f.children,h))})},{entry:n,components:o}=t;return s(this,this.root,[n],o),this.root}createRoot(){return new st}createNode(t,e){const i=this.resolveComponent(e);if(!i)return console.warn(`Unable to resolve component: ${e}`),new xt;const s=new i;return s.type=e,s.name=t,s}resolveComponent(t){return customElements.get(`ace-${t}`)}getRoot(){return this.root}}const ge=class{constructor(){this.components=new Map}getComponent(r){const t=this.components.get(r);return t||console.warn(`Unable to resolve component: ${r}. You most likely forgot to register the required plugin.`),t}registerComponent(r,t){this.components.set(r,t)}async loadComponents(){const r=[...this.components.entries()].map(([t,e])=>e.then(i=>{this.defineAsWebComponent(t,i.default)}));await Promise.all(r)}defineAsWebComponent(r,t){const e=ge.ResolveWebComponentName(r);customElements.get(e)||customElements.define(e,t)}};let me=ge;me.ResolveWebComponentName=r=>`ace-${r}`;class Si{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}}class ve{constructor(t,e,i,s){this.name=t,this.container=e,this.settings=i,this.options=s,this.platform=new Ai,this.texts=new Si,this.renderStrategy=y.Inline,this.anchor="BottomRight",this.autoActivate=!1,this.plugins=[],this.componentResolver=new me,this.components=[],this.renderStrategy=this.options.renderStrategy||y.Inline,this.triggerIcon=this.options.triggerIcon,typeof s.autoActivate=="boolean"&&(this.autoActivate=s.autoActivate),s.anchor&&(this.anchor=s.anchor),this.container.register("$settings",i),this.texts.loadTexts(i.texts||{})}async activate(){if(await this.loadPlugins(),await this.componentResolver.loadComponents(),this.root=this.platform.createComponentModel(this.settings,this),this.container.setState(ee.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))}hide(){this.root&&(this.root.classList.add("hidden"),this.root.classList.remove("expanded"))}mute(){this.settings.branding.other.disableSound=!0}unmute(){this.settings.branding.other.disableSound=!1}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,t}return this.root}}const ye=class{async getSite(r){const e=await(await fetch(r)).json();return e?{id:e.id,apps:e.widgets.map(i=>{let s=y.Inline;return i.renderStrategy==="Trigger"&&(s=y.Trigger),{id:i.id,widgetId:i.widgetId,renderStrategy:s,autoActivate:i.autoActivate,anchor:i.anchor,triggerIcon:{type:"Telia",content:i.triggerIcon}}})}:null}async getWidget(r){const e=await(await fetch(`${ye.endpoint}/widget/${r}`)).json();return e?{name:e.name,config:JSON.parse(e.configuration)}:null}};let Q=ye;Q.endpoint="https://widgets.ace.teliacompany.net/api";class be{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(s=>s.name===e.name);i&&e.dispatchEvent(new CustomEvent("environment-created",{detail:{widget:i}}))})}registerApp(t,e,i){const s=new bt(t,this),n=new ve(t,s,e,i);this.applications.push(n)}plugin(t){return this.applications.forEach(e=>{e.plugin(t)}),this}}class $e{constructor(t){this.configurations=[],this.httpClient=new Q,this.httpClient=new Q,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 be,this.addGlobal(this.environment);for await(const i of this.configurations){const s=await this.httpClient.getWidget(i.widgetId);s&&((e=this.environment)==null||e.registerApp(s.name,s.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 xi=Object.defineProperty,Ci=Object.getOwnPropertyDescriptor,Ct=(r,t,e,i)=>{for(var s=i>1?void 0:i?Ci(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&xi(t,e,s),s};class k 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()}}k.styles=[U`
336
+ `;wi([m({attribute:!1})],st.prototype,"application",2);class Ai{constructor(){this.root=this.createRoot()}createComponentModel(t,e){this.root.application=e;const i=a=>{if(Array.isArray(a)){const[c,...l]=a;return{definitionId:c,overrides:l}}return{definitionId:a,overrides:[]}},s=(a,c,l,h)=>{l.forEach(p=>{const u=i(p),f=h[u.definitionId];if(!f){console.error(`No definition found for component type '${u.definitionId}'.`);return}const g=a.createNode(f.type,f.type);g&&(g.name=u.definitionId,g.application=e,f.properties&&g.writeProperties(f.properties),f.context&&g.writeContext(f.context),f.layout&&g.writeLayout(f.layout),c.addChild(g),f.children&&s(a,g,f.children,h))})},{entry:n,components:o}=t;return s(this,this.root,[n],o),this.root}createRoot(){return new st}createNode(t,e){const i=this.resolveComponent(e);if(!i)return console.warn(`Unable to resolve component: ${e}`),new xt;const s=new i;return s.type=e,s.name=t,s}resolveComponent(t){return customElements.get(`ace-${t}`)}getRoot(){return this.root}}const ge=class{constructor(){this.components=new Map}getComponent(r){const t=this.components.get(r);return t||console.warn(`Unable to resolve component: ${r}. You most likely forgot to register the required plugin.`),t}registerComponent(r,t){this.components.set(r,t)}async loadComponents(){const r=[...this.components.entries()].map(([t,e])=>e.then(i=>{this.defineAsWebComponent(t,i.default)}));await Promise.all(r)}defineAsWebComponent(r,t){const e=ge.ResolveWebComponentName(r);customElements.get(e)||customElements.define(e,t)}};let me=ge;me.ResolveWebComponentName=r=>`ace-${r}`;class Si{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 ve{constructor(t,e,i,s){this.name=t,this.container=e,this.settings=i,this.options=s,this.platform=new Ai,this.texts=new Si,this.renderStrategy=y.Inline,this.anchor="BottomRight",this.autoActivate=!1,this.plugins=[],this.componentResolver=new me,this.components=[],this.renderStrategy=this.options.renderStrategy||y.Inline,this.triggerIcon=this.options.triggerIcon,typeof s.autoActivate=="boolean"&&(this.autoActivate=s.autoActivate),s.anchor&&(this.anchor=s.anchor),this.container.register("$settings",i),this.texts.loadTexts(i.texts||{})}async activate(){if(await this.loadPlugins(),await this.componentResolver.loadComponents(),this.root=this.platform.createComponentModel(this.settings,this),this.container.setState(ee.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))}hide(){this.root&&(this.root.classList.add("hidden"),this.root.classList.remove("expanded"))}mute(){this.settings.branding.other.disableSound=!0}unmute(){this.settings.branding.other.disableSound=!1}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,t}return this.root}}const ye=class{async getSite(r){const e=await(await fetch(r)).json();return e?{id:e.id,apps:e.widgets.map(i=>{let s=y.Inline;return i.renderStrategy==="Trigger"&&(s=y.Trigger),{id:i.id,widgetId:i.widgetId,renderStrategy:s,autoActivate:i.autoActivate,anchor:i.anchor,triggerIcon:{type:"Telia",content:i.triggerIcon}}})}:null}async getWidget(r){const e=await(await fetch(`${ye.endpoint}/widget/${r}`)).json();return e?{name:e.name,config:JSON.parse(e.configuration)}:null}};let Q=ye;Q.endpoint="https://widgets.ace.teliacompany.net/api";class be{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(s=>s.name===e.name);i&&e.dispatchEvent(new CustomEvent("environment-created",{detail:{widget:i}}))})}registerApp(t,e,i){const s=new bt(t,this),n=new ve(t,s,e,i);this.applications.push(n)}plugin(t){return this.applications.forEach(e=>{e.plugin(t)}),this}}class $e{constructor(t){this.configurations=[],this.httpClient=new Q,this.httpClient=new Q,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 be,this.addGlobal(this.environment);for await(const i of this.configurations){const s=await this.httpClient.getWidget(i.widgetId);s&&((e=this.environment)==null||e.registerApp(s.name,s.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 xi=Object.defineProperty,Ci=Object.getOwnPropertyDescriptor,Ct=(r,t,e,i)=>{for(var s=i>1?void 0:i?Ci(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&xi(t,e,s),s};class k 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()}}k.styles=[U`
337
337
  :host {
338
338
  display: block;
339
339
  }
package/index.mjs CHANGED
@@ -248,7 +248,7 @@ var be = function() {
248
248
  try {
249
249
  e.next(t);
250
250
  } catch (i) {
251
- F(i);
251
+ W(i);
252
252
  }
253
253
  }, r.prototype.error = function(t) {
254
254
  var e = this.partialObserver;
@@ -256,17 +256,17 @@ var be = function() {
256
256
  try {
257
257
  e.error(t);
258
258
  } catch (i) {
259
- F(i);
259
+ W(i);
260
260
  }
261
261
  else
262
- F(t);
262
+ W(t);
263
263
  }, r.prototype.complete = function() {
264
264
  var t = this.partialObserver;
265
265
  if (t.complete)
266
266
  try {
267
267
  t.complete();
268
268
  } catch (e) {
269
- F(e);
269
+ W(e);
270
270
  }
271
271
  }, r;
272
272
  }(), vt = function(r) {
@@ -293,7 +293,7 @@ var be = function() {
293
293
  }
294
294
  return t;
295
295
  }(Qt);
296
- function F(r) {
296
+ function W(r) {
297
297
  ve(r);
298
298
  }
299
299
  function $e(r) {
@@ -871,7 +871,7 @@ class H {
871
871
  for (const p of s.getAttributeNames())
872
872
  if (p.endsWith(re)) {
873
873
  const u = h[o++], f = s.getAttribute(p).split(_), g = /([.?@])?(.*)/.exec(u);
874
- c.push({ type: 1, index: n, name: g[2], strings: f, ctor: g[1] === "." ? We : g[1] === "?" ? Fe : g[1] === "@" ? Ge : tt }), s.removeAttribute(p);
874
+ c.push({ type: 1, index: n, name: g[2], strings: f, ctor: g[1] === "." ? Fe : g[1] === "?" ? We : g[1] === "@" ? Ge : tt }), s.removeAttribute(p);
875
875
  } else
876
876
  p.startsWith(_) && (c.push({ type: 6, index: n }), s.removeAttribute(p));
877
877
  if (oe.test(s.tagName)) {
@@ -1028,7 +1028,7 @@ class tt {
1028
1028
  t === d ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
1029
1029
  }
1030
1030
  }
1031
- class We extends tt {
1031
+ class Fe extends tt {
1032
1032
  constructor() {
1033
1033
  super(...arguments), this.type = 3;
1034
1034
  }
@@ -1036,7 +1036,7 @@ class We extends tt {
1036
1036
  this.element[this.name] = t === d ? void 0 : t;
1037
1037
  }
1038
1038
  }
1039
- class Fe extends tt {
1039
+ class We extends tt {
1040
1040
  constructor() {
1041
1041
  super(...arguments), this.type = 4;
1042
1042
  }
@@ -1297,7 +1297,7 @@ class he extends ce {
1297
1297
  }
1298
1298
  const ri = /* @__PURE__ */ new WeakMap();
1299
1299
  let zt = 0;
1300
- const ht = /* @__PURE__ */ new Map(), Wt = /* @__PURE__ */ new WeakSet(), Ft = () => new Promise((r) => requestAnimationFrame(r)), si = [{ transform: "translateX(100%) scale(0)", opacity: 0 }], Gt = (r, t) => {
1300
+ const ht = /* @__PURE__ */ new Map(), Ft = /* @__PURE__ */ new WeakSet(), Wt = () => new Promise((r) => requestAnimationFrame(r)), si = [{ transform: "translateX(100%) scale(0)", opacity: 0 }], Gt = (r, t) => {
1301
1301
  const e = r - t;
1302
1302
  return e === 0 ? void 0 : e;
1303
1303
  }, Vt = (r, t) => {
@@ -1381,7 +1381,7 @@ class ai extends he {
1381
1381
  if (!this.o || !this.element.isConnected || this.options.skipInitial && !this.isHostRendered)
1382
1382
  return;
1383
1383
  let t;
1384
- this.prepare(), await Ft;
1384
+ this.prepare(), await Wt;
1385
1385
  const e = this._(), i = this.A(this.options.keyframeOptions, e), s = this.p();
1386
1386
  if (this.g !== void 0) {
1387
1387
  const { from: n, to: o } = this.O(this.g, s, e);
@@ -1410,7 +1410,7 @@ class ai extends he {
1410
1410
  var e;
1411
1411
  if (!this.o || (this.options.id !== void 0 && ht.set(this.options.id, this.g), this.options.out === void 0))
1412
1412
  return;
1413
- if (this.prepare(), await Ft(), (e = this.t) == null ? void 0 : e.isConnected) {
1413
+ if (this.prepare(), await Wt(), (e = this.t) == null ? void 0 : e.isConnected) {
1414
1414
  const i = this.i && this.i.parentNode === this.t ? this.i : null;
1415
1415
  if (this.t.insertBefore(this.element, i), this.options.stabilizeOut) {
1416
1416
  const s = this.p();
@@ -1442,9 +1442,9 @@ class ai extends he {
1442
1442
  return t;
1443
1443
  }
1444
1444
  get isHostRendered() {
1445
- const t = Wt.has(this.l);
1445
+ const t = Ft.has(this.l);
1446
1446
  return t || this.l.updateComplete.then(() => {
1447
- Wt.add(this.l);
1447
+ Ft.add(this.l);
1448
1448
  }), t;
1449
1449
  }
1450
1450
  A(t, e = this._()) {
@@ -2125,6 +2125,9 @@ class _i {
2125
2125
  const i = this.texts.get(t);
2126
2126
  return i || e || null;
2127
2127
  }
2128
+ getOrFallback(t, e) {
2129
+ return this.texts.get(t) || e;
2130
+ }
2128
2131
  }
2129
2132
  class wi {
2130
2133
  constructor(t, e, i, s) {
@@ -2309,7 +2312,7 @@ var xi = Object.defineProperty, Ci = Object.getOwnPropertyDescriptor, xt = (r, t
2309
2312
  (o = r[n]) && (s = (i ? o(t, e, s) : o(s)) || s);
2310
2313
  return i && s && xi(t, e, s), s;
2311
2314
  };
2312
- class W extends $ {
2315
+ class F extends $ {
2313
2316
  constructor() {
2314
2317
  super(), this.status = "deactivated", this.addEventListener("environment-created", this.onEnvironmentCreated);
2315
2318
  }
@@ -2341,7 +2344,7 @@ class W extends $ {
2341
2344
  return this.widget.render();
2342
2345
  }
2343
2346
  }
2344
- W.styles = [
2347
+ F.styles = [
2345
2348
  U`
2346
2349
  :host {
2347
2350
  display: block;
@@ -2350,23 +2353,23 @@ W.styles = [
2350
2353
  ];
2351
2354
  xt([
2352
2355
  m({ attribute: !0 })
2353
- ], W.prototype, "name", 2);
2356
+ ], F.prototype, "name", 2);
2354
2357
  xt([
2355
2358
  z()
2356
- ], W.prototype, "widget", 2);
2359
+ ], F.prototype, "widget", 2);
2357
2360
  xt([
2358
2361
  z()
2359
- ], W.prototype, "status", 2);
2362
+ ], F.prototype, "status", 2);
2360
2363
  customElements.get("ace-trigger-slot") || customElements.define("ace-trigger-slot", et);
2361
2364
  customElements.get("ace-trigger") || customElements.define("ace-trigger", A);
2362
2365
  customElements.get("ace-unresolved-component") || customElements.define("ace-unresolved-component", St);
2363
2366
  customElements.get("ace-wrapper") || customElements.define("ace-wrapper", rt);
2364
- customElements.get("ace-widget") || customElements.define("ace-widget", W);
2367
+ customElements.get("ace-widget") || customElements.define("ace-widget", F);
2365
2368
  const Ri = async (r, t) => {
2366
2369
  await new Si(r).bootstrap(t);
2367
2370
  };
2368
2371
  export {
2369
- W as AceWidget,
2372
+ F as AceWidget,
2370
2373
  wi as Application,
2371
2374
  Rt as Container,
2372
2375
  Ai as Environment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-core-flamingo",
3
- "version": "1.1.36-rc.0",
3
+ "version": "1.1.36-rc.1",
4
4
  "dependencies": {
5
5
  "lit": "^3.0.2",
6
6
  "@teliads/icons": "^8.4.0",
@@ -6,4 +6,5 @@ export declare class TextsService implements ITextsService {
6
6
  private texts;
7
7
  loadTexts(texts: Record<string, string>): void;
8
8
  get(key: string, fallback?: string): string | null;
9
+ getOrFallback(key: string, fallback: string): string;
9
10
  }