@telia-ace/widget-types-grid 1.0.30-experimental.17 → 1.0.30-experimental.19
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/dist/index.js
CHANGED
|
@@ -684,7 +684,7 @@ class Ue {
|
|
|
684
684
|
}
|
|
685
685
|
render() {
|
|
686
686
|
const { widgetDOMElement: t, triggerDOMElement: n } = this.options, s = this.container.get("$widget");
|
|
687
|
-
return t.getAttribute("data-rendered") === "true" ? Promise.resolve() : (n && this.options.triggerType === _.Badge && Ge(n), import("./render.
|
|
687
|
+
return t.getAttribute("data-rendered") === "true" ? Promise.resolve() : (n && this.options.triggerType === _.Badge && Ge(n), import("./render.5e8a0971.js").then((o) => o.default(s.name, this.container, t)).then(() => {
|
|
688
688
|
if (t.setAttribute("data-rendered", "true"), n && this.options.triggerType === _.Badge) {
|
|
689
689
|
const i = this.options.triggerOptions.openTooltip;
|
|
690
690
|
xt(n, i);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var h = (
|
|
1
|
+
var h = (r, e, o) => new Promise((i, t) => {
|
|
2
2
|
var n = (s) => {
|
|
3
3
|
try {
|
|
4
|
-
l(
|
|
4
|
+
l(o.next(s));
|
|
5
5
|
} catch (d) {
|
|
6
6
|
t(d);
|
|
7
7
|
}
|
|
8
8
|
}, a = (s) => {
|
|
9
9
|
try {
|
|
10
|
-
l(
|
|
10
|
+
l(o.throw(s));
|
|
11
11
|
} catch (d) {
|
|
12
12
|
t(d);
|
|
13
13
|
}
|
|
14
14
|
}, l = (s) => s.done ? i(s.value) : Promise.resolve(s.value).then(n, a);
|
|
15
|
-
l((
|
|
15
|
+
l((o = o.apply(r, e)).next());
|
|
16
16
|
});
|
|
17
|
-
import { ComponentPlatform as
|
|
18
|
-
import { nothing as
|
|
17
|
+
import { ComponentPlatform as u } from "@telia-ace/widget-core";
|
|
18
|
+
import { nothing as g, css as w, LitElement as y } from "lit";
|
|
19
19
|
import { state as m, property as _ } from "lit/decorators.js";
|
|
20
20
|
import { html as v, unsafeStatic as b } from "lit/static-html.js";
|
|
21
21
|
import { resolveComponent as x } from "./index.js";
|
|
@@ -31,18 +31,18 @@ import "@telia-ace/widget-routing";
|
|
|
31
31
|
import "@telia-ace/widget-services";
|
|
32
32
|
import "@webprovisions/bootstrapping";
|
|
33
33
|
import "@webprovisions/platform";
|
|
34
|
-
const f = (
|
|
35
|
-
const e =
|
|
36
|
-
if (
|
|
34
|
+
const f = (r) => {
|
|
35
|
+
const e = r.getRootNode();
|
|
36
|
+
if (r.getAttribute("widgetname"))
|
|
37
37
|
return window.humany.widgets.find(
|
|
38
|
-
|
|
38
|
+
r.getAttribute("widgetname")
|
|
39
39
|
);
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
40
|
+
if (r.classList.contains("humany-widget")) {
|
|
41
|
+
const o = Array.from(r.classList).reduce(
|
|
42
42
|
(t, n) => (n.indexOf("humany_") === 0 && (t = n.replace("humany_", "")), t),
|
|
43
43
|
void 0
|
|
44
44
|
);
|
|
45
|
-
return window.humany.widgets.find(
|
|
45
|
+
return window.humany.widgets.find(o);
|
|
46
46
|
}
|
|
47
47
|
return e.host ? f(e.host) : null;
|
|
48
48
|
};
|
|
@@ -54,24 +54,24 @@ class C {
|
|
|
54
54
|
this.widget = f(this.host);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const P = (
|
|
58
|
-
class e extends
|
|
57
|
+
const P = (r) => {
|
|
58
|
+
class e extends r {
|
|
59
59
|
constructor(...i) {
|
|
60
60
|
super(), this._instances = /* @__PURE__ */ new Map(), this.addEventListener("request-instance", (t) => {
|
|
61
61
|
const n = t.detail.key;
|
|
62
|
-
|
|
62
|
+
this._instances.has(n) && (t.detail.instance = this._instances.get(n), t.stopPropagation());
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
provideInstance(i, t) {
|
|
66
|
-
|
|
66
|
+
this._instances.set(i, t);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
return e;
|
|
70
70
|
};
|
|
71
|
-
var I = Object.defineProperty, L = Object.getOwnPropertyDescriptor, p = (
|
|
72
|
-
for (var t = i > 1 ? void 0 : i ? L(e,
|
|
73
|
-
(a =
|
|
74
|
-
return i && t && I(e,
|
|
71
|
+
var I = Object.defineProperty, L = Object.getOwnPropertyDescriptor, p = (r, e, o, i) => {
|
|
72
|
+
for (var t = i > 1 ? void 0 : i ? L(e, o) : e, n = r.length - 1, a; n >= 0; n--)
|
|
73
|
+
(a = r[n]) && (t = (i ? a(e, o, t) : a(t)) || t);
|
|
74
|
+
return i && t && I(e, o, t), t;
|
|
75
75
|
};
|
|
76
76
|
class c extends P(y) {
|
|
77
77
|
constructor() {
|
|
@@ -79,11 +79,11 @@ class c extends P(y) {
|
|
|
79
79
|
}
|
|
80
80
|
connectedCallback() {
|
|
81
81
|
super.connectedCallback(), this.controller.widget && (this.provideInstance("container", this.controller.widget.container), Promise.all([
|
|
82
|
-
|
|
82
|
+
u.getInstance(this.controller.widget.container),
|
|
83
83
|
this.controller.widget.container.getAsync("componentResolver")
|
|
84
84
|
]).then((e) => h(this, null, function* () {
|
|
85
85
|
this.platform = e[0];
|
|
86
|
-
const
|
|
86
|
+
const o = e[1];
|
|
87
87
|
if (this.unsubscribe = this.platform.events.subscribe(
|
|
88
88
|
"components:root-children-changed",
|
|
89
89
|
(i, { node: t }) => {
|
|
@@ -93,11 +93,11 @@ class c extends P(y) {
|
|
|
93
93
|
console.warn("Could not get node ID for entry node on the ComponentPlatform.");
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
this._child = (yield x(this._entry,
|
|
96
|
+
this._child = (yield x(this._entry, o, this.platform)) || null;
|
|
97
97
|
})));
|
|
98
98
|
}
|
|
99
99
|
render() {
|
|
100
|
-
return this._child ? v` <${b(this._child.tag)} nodeId=${this._child.nodeId} /> ` :
|
|
100
|
+
return this._child ? v` <${b(this._child.tag)} nodeId=${this._child.nodeId} /> ` : g;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
c.styles = [
|
|
@@ -144,11 +144,11 @@ p([
|
|
|
144
144
|
m()
|
|
145
145
|
], c.prototype, "_child", 2);
|
|
146
146
|
customElements.define("widget-root", c);
|
|
147
|
-
const
|
|
147
|
+
const H = (r, e, o) => {
|
|
148
148
|
const i = document.createElement("widget-root");
|
|
149
|
-
i.setAttribute("widgetName",
|
|
149
|
+
i.setAttribute("widgetName", r), o.appendChild(i);
|
|
150
150
|
};
|
|
151
151
|
export {
|
|
152
|
-
|
|
152
|
+
H as default
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=render.
|
|
154
|
+
//# sourceMappingURL=render.5e8a0971.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.5e8a0971.js","sources":["../src/utils/get-widget.ts","../src/controllers/widget-controller.ts","../src/mixins/provider.ts","../src/ui/widget-root.ts","../src/ui/render.ts"],"sourcesContent":["// export const getWidget = (elem: HTMLElement) => {\n// const widgetEl = elem.closest('.humany-widget');\n// console.log('elem', widgetEl);\n\n// if (!widgetEl) {\n// return;\n// }\n\n// const widgetName = Array.from(widgetEl.classList).reduce<string | undefined>(\n// (acc, className) => {\n// if (className.indexOf('humany_') === 0) {\n// acc = className.replace('humany_', '');\n// }\n// return acc;\n// },\n// undefined\n// );\n\n// if (!widgetName) {\n// return;\n// }\n\n// const widget = (window as any).humany.widgets.find(widgetName);\n// return widget;\n// };\n\nexport const getWidget = (elem: HTMLElement): any => {\n const root = elem.getRootNode() as any;\n\n if (elem.getAttribute('widgetname')) {\n const widget = (window as any).humany.widgets.find(\n elem.getAttribute('widgetname')\n );\n\n return widget;\n } else if (elem.classList.contains('humany-widget')) {\n const widgetName = Array.from(elem.classList).reduce<string | undefined>(\n (acc, className) => {\n if (className.indexOf('humany_') === 0) {\n acc = className.replace('humany_', '');\n }\n return acc;\n },\n undefined\n );\n const widget = (window as any).humany.widgets.find(widgetName);\n\n return widget;\n }\n\n if (!root.host) {\n return null;\n }\n\n return getWidget(root.host);\n\n // const widgetEl = elem.closest('.humany-widget');\n // console.log('elem', widgetEl);\n\n // if (!widgetEl) {\n // return;\n // }\n\n // const widgetName = Array.from(widgetEl.classList).reduce<string | undefined>(\n // (acc, className) => {\n // if (className.indexOf('humany_') === 0) {\n // acc = className.replace('humany_', '');\n // }\n // return acc;\n // },\n // undefined\n // );\n\n // if (!widgetName) {\n // return;\n // }\n\n // const widget = (window as any).humany.widgets.find(widgetName);\n // return widget;\n};\n","import { Widget } from '@webprovisions/platform';\nimport { getWidget } from '../utils/get-widget';\n\nexport class WidgetController {\n host: any;\n widget: Widget | undefined;\n\n constructor(host: any) {\n (this.host = host).addController(this);\n }\n\n hostConnected() {\n this.widget = getWidget(this.host);\n }\n}\n","import { LitElement } from 'lit';\n\nexport declare class ProviderInterface {\n provideInstance(key: string, instance: any): void;\n}\n\ntype Constructor<T = {}> = new (...args: any[]) => T;\n\nexport const Provider = <T extends Constructor<LitElement>>(Base: T) => {\n class ProviderClass extends Base {\n _instances = new Map();\n\n constructor(...args: any[]) {\n super();\n\n this.addEventListener('request-instance', (event: any) => {\n const key = event.detail.key;\n\n if (this._instances.has(key)) {\n event.detail.instance = this._instances.get(key);\n event.stopPropagation();\n }\n });\n }\n\n provideInstance(key: string, instance: any) {\n this._instances.set(key, instance);\n }\n }\n\n return ProviderClass as Constructor<ProviderInterface> & T;\n};\n","import { ComponentPlatform, ComponentResolver } from '@telia-ace/widget-core';\nimport { EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { css, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { html, unsafeStatic } from 'lit/static-html.js';\nimport { WidgetController } from '../controllers/widget-controller';\nimport { Provider } from '../mixins/provider';\nimport { resolveComponent } from '../utils/resolve-component';\n// import {\n// GuideList,\n// Paragraph,\n// ItemList,\n// List,\n// SymbolBadge,\n// Text,\n// Html,\n// Button,\n// Typography,\n// TextLink,\n// } from 'ui'; // TODO: this is not how we want to register the ui elements\n\n// @customElement('widget-root')\nexport class WidgetRoot extends Provider(LitElement) {\n controller = new WidgetController(this);\n platform: ComponentPlatform | undefined;\n unsubscribe: EventSubscriptionCancellation | undefined;\n\n static styles = [\n css`\n :host {\n --gap: 0;\n --fonts-type: 'Lato';\n --fonts-small: 0.9em;\n --fonts-normal: 1em;\n --fonts-medium: 1.1em;\n --fonts-huge: 1.4em;\n --fonts-large: 1.1em;\n --colors-accent: #fafafa;\n --colors-link: #990ae3;\n --colors-primary: #990ae3;\n --colors-text: #333333;\n --colors-textLight: #767676;\n --colors-warning: #cc0000;\n --accessibility-border: 2px dashed #990ae3;\n --accessibility-colors-inactiveText: #990ae3;\n --accessibility-colors-activeText: #ffffff;\n --inputBorder: 1px solid #000000;\n --border: 1px solid #000000;\n --borderRadius: 5px;\n --boxShadow: 0px 0px 10px rgba(0, 0, 0, 0.1);\n --cardinal: 3px;\n --size-small: var(--cardinal);\n --size-normal: calc(var(--cardinal) * 3);\n --size-medium: calc(var(--cardinal) * 5);\n --size-large: calc(var(--cardinal) * 8);\n --size-huge: calc(var(--cardinal) * 12);\n\n --typography-h1: h2;\n }\n `,\n ];\n\n @state()\n declare _entry: string | null;\n @property()\n declare widgetName: string;\n\n @state()\n declare _child: { tag: string; nodeId: string } | null;\n\n constructor() {\n super();\n this._child = null;\n this._entry = null;\n // this._installRoutes();\n }\n\n // _installRoutes() {\n // page('/browse', this._browseRoute);\n // page('*', this._notFoundRoute);\n // page();\n // }\n\n // _browseRoute() {\n // console.log('browse route');\n // }\n\n // _notFoundRoute() {\n // console.log('not found route');\n // }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.controller.widget) {\n this.provideInstance('container', this.controller.widget.container);\n\n Promise.all([\n ComponentPlatform.getInstance(this.controller.widget.container),\n this.controller.widget.container.getAsync('componentResolver'),\n ]).then(async (values) => {\n this.platform = values[0];\n const resolver: ComponentResolver = values[1];\n\n this.unsubscribe = this.platform.events.subscribe(\n 'components:root-children-changed',\n (event: any, { node }: any) => {\n if (node.parent && node.parent.type === 'root') {\n this._entry = node.parent.children.default[0].id;\n }\n }\n );\n\n this._entry = this.platform.nodes.root.children.default[0].id || null;\n\n if (!this._entry) {\n console.warn('Could not get node ID for entry node on the ComponentPlatform.');\n return;\n }\n\n this._child =\n (await resolveComponent(this._entry, resolver, this.platform)) || null;\n });\n }\n }\n\n render() {\n if (!this._child) {\n return nothing;\n }\n\n return html` <${unsafeStatic(this._child.tag)} nodeId=${this._child.nodeId} /> `;\n }\n}\n","import { Container } from '@webprovisions/platform';\nimport './widget-component';\nimport { WidgetRoot } from './widget-root';\n\ncustomElements.define('widget-root', WidgetRoot);\n\nexport default (widgetName: string, container: Container, element: HTMLElement) => {\n const root = document.createElement('widget-root');\n root.setAttribute('widgetName', widgetName);\n element.appendChild(root);\n};\n"],"names":["getWidget","elem","root","widgetName","acc","className","WidgetController","host","Provider","Base","ProviderClass","args","event","key","instance","WidgetRoot","LitElement","ComponentPlatform","values","__async","resolver","node","resolveComponent","html","unsafeStatic","nothing","css","__decorateClass","state","property","render","container","element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Ba,MAAAA,IAAY,CAACC,MAA2B;AAC7C,QAAAC,IAAOD,EAAK;AAEd,MAAAA,EAAK,aAAa,YAAY;AAKzB,WAJS,OAAe,OAAO,QAAQ;AAAA,MAC5CA,EAAK,aAAa,YAAY;AAAA,IAAA;AAIvB,MAAAA,EAAK,UAAU,SAAS,eAAe,GAAG;AACnD,UAAME,IAAa,MAAM,KAAKF,EAAK,SAAS,EAAE;AAAA,MAC5C,CAACG,GAAKC,OACAA,EAAU,QAAQ,SAAS,MAAM,MAC7BD,IAAAC,EAAU,QAAQ,WAAW,EAAE,IAEhCD;AAAA,MAET;AAAA,IAAA;AAIK,WAFS,OAAe,OAAO,QAAQ,KAAKD,CAAU;AAAA,EAG/D;AAEI,SAACD,EAAK,OAIHF,EAAUE,EAAK,IAAI,IAHjB;AA4BX;AC5EO,MAA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version": "1.0.30-experimental.19",
|
|
4
4
|
"description": "Type definition for Grid widget.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@open-wc/dedupe-mixin": "^1.3.1",
|
|
25
25
|
"@open-wc/lit-helpers": "^0.5.1",
|
|
26
|
-
"@telia-ace/widget-core": "1.0.21-experimental.
|
|
27
|
-
"@telia-ace/widget-forms": "1.0.28-experimental.
|
|
28
|
-
"@telia-ace/widget-routing": "1.0.22-experimental.
|
|
29
|
-
"@telia-ace/widget-services": "1.0.21-experimental.
|
|
30
|
-
"@telia-ace/widget-ui": "1.0.28-experimental.
|
|
31
|
-
"@telia-ace/widget-utilities": "1.0.10-experimental.
|
|
26
|
+
"@telia-ace/widget-core": "1.0.21-experimental.19",
|
|
27
|
+
"@telia-ace/widget-forms": "1.0.28-experimental.19",
|
|
28
|
+
"@telia-ace/widget-routing": "1.0.22-experimental.19",
|
|
29
|
+
"@telia-ace/widget-services": "1.0.21-experimental.19",
|
|
30
|
+
"@telia-ace/widget-ui": "1.0.28-experimental.19",
|
|
31
|
+
"@telia-ace/widget-utilities": "1.0.10-experimental.19",
|
|
32
32
|
"@webprovisions/bootstrapping": "^1.0.12",
|
|
33
33
|
"@webprovisions/platform": "^1.1.2",
|
|
34
34
|
"lit": "^2.6.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@emotion/cache": "^11.10.5",
|
|
49
49
|
"@emotion/react": "^11.10.5",
|
|
50
50
|
"@emotion/styled": "^11.10.5",
|
|
51
|
-
"@telia-ace/widget-developer-tools": "1.0.16-experimental.
|
|
51
|
+
"@telia-ace/widget-developer-tools": "1.0.16-experimental.19",
|
|
52
52
|
"@types/react": "^18.0.26",
|
|
53
53
|
"@types/react-dom": "^18.0.10",
|
|
54
54
|
"@types/react-router": "^5.1.20",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render.4f979aa1.js","sources":["../src/utils/get-widget.ts","../src/controllers/widget-controller.ts","../src/mixins/provider.ts","../src/ui/widget-root.ts","../src/ui/render.ts"],"sourcesContent":["// export const getWidget = (elem: HTMLElement) => {\n// const widgetEl = elem.closest('.humany-widget');\n// console.log('elem', widgetEl);\n\n// if (!widgetEl) {\n// return;\n// }\n\n// const widgetName = Array.from(widgetEl.classList).reduce<string | undefined>(\n// (acc, className) => {\n// if (className.indexOf('humany_') === 0) {\n// acc = className.replace('humany_', '');\n// }\n// return acc;\n// },\n// undefined\n// );\n\n// if (!widgetName) {\n// return;\n// }\n\n// const widget = (window as any).humany.widgets.find(widgetName);\n// return widget;\n// };\n\nexport const getWidget = (elem: HTMLElement): any => {\n const root = elem.getRootNode() as any;\n\n if (elem.getAttribute('widgetname')) {\n const widget = (window as any).humany.widgets.find(\n elem.getAttribute('widgetname')\n );\n\n return widget;\n } else if (elem.classList.contains('humany-widget')) {\n const widgetName = Array.from(elem.classList).reduce<string | undefined>(\n (acc, className) => {\n if (className.indexOf('humany_') === 0) {\n acc = className.replace('humany_', '');\n }\n return acc;\n },\n undefined\n );\n const widget = (window as any).humany.widgets.find(widgetName);\n\n return widget;\n }\n\n if (!root.host) {\n return null;\n }\n\n return getWidget(root.host);\n\n // const widgetEl = elem.closest('.humany-widget');\n // console.log('elem', widgetEl);\n\n // if (!widgetEl) {\n // return;\n // }\n\n // const widgetName = Array.from(widgetEl.classList).reduce<string | undefined>(\n // (acc, className) => {\n // if (className.indexOf('humany_') === 0) {\n // acc = className.replace('humany_', '');\n // }\n // return acc;\n // },\n // undefined\n // );\n\n // if (!widgetName) {\n // return;\n // }\n\n // const widget = (window as any).humany.widgets.find(widgetName);\n // return widget;\n};\n","import { Widget } from '@webprovisions/platform';\nimport { getWidget } from '../utils/get-widget';\n\nexport class WidgetController {\n host: any;\n widget: Widget | undefined;\n\n constructor(host: any) {\n (this.host = host).addController(this);\n }\n\n hostConnected() {\n this.widget = getWidget(this.host);\n }\n}\n","import { LitElement } from 'lit';\n\nexport declare class ProviderInterface {\n provideInstance(key: string, instance: any): void;\n}\n\ntype Constructor<T = {}> = new (...args: any[]) => T;\n\nexport const Provider = <T extends Constructor<LitElement>>(Base: T) => {\n class ProviderClass extends Base {\n _instances = new Map();\n\n constructor(...args: any[]) {\n super();\n\n this.addEventListener('request-instance', (event: any) => {\n const key = event.detail.key;\n console.log('listener fired');\n\n if (this._instances.has(key)) {\n event.detail.instance = this._instances.get(key);\n event.stopPropagation();\n }\n });\n }\n\n provideInstance(key: string, instance: any) {\n console.log('providing instance', key, instance);\n this._instances.set(key, instance);\n }\n }\n\n return ProviderClass as Constructor<ProviderInterface> & T;\n};\n","import { ComponentPlatform, ComponentResolver } from '@telia-ace/widget-core';\nimport { EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { css, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { html, unsafeStatic } from 'lit/static-html.js';\nimport { WidgetController } from '../controllers/widget-controller';\nimport { Provider } from '../mixins/provider';\nimport { resolveComponent } from '../utils/resolve-component';\n// import {\n// GuideList,\n// Paragraph,\n// ItemList,\n// List,\n// SymbolBadge,\n// Text,\n// Html,\n// Button,\n// Typography,\n// TextLink,\n// } from 'ui'; // TODO: this is not how we want to register the ui elements\n\n// @customElement('widget-root')\nexport class WidgetRoot extends Provider(LitElement) {\n controller = new WidgetController(this);\n platform: ComponentPlatform | undefined;\n unsubscribe: EventSubscriptionCancellation | undefined;\n\n static styles = [\n css`\n :host {\n --gap: 0;\n --fonts-type: 'Lato';\n --fonts-small: 0.9em;\n --fonts-normal: 1em;\n --fonts-medium: 1.1em;\n --fonts-huge: 1.4em;\n --fonts-large: 1.1em;\n --colors-accent: #fafafa;\n --colors-link: #990ae3;\n --colors-primary: #990ae3;\n --colors-text: #333333;\n --colors-textLight: #767676;\n --colors-warning: #cc0000;\n --accessibility-border: 2px dashed #990ae3;\n --accessibility-colors-inactiveText: #990ae3;\n --accessibility-colors-activeText: #ffffff;\n --inputBorder: 1px solid #000000;\n --border: 1px solid #000000;\n --borderRadius: 5px;\n --boxShadow: 0px 0px 10px rgba(0, 0, 0, 0.1);\n --cardinal: 3px;\n --size-small: var(--cardinal);\n --size-normal: calc(var(--cardinal) * 3);\n --size-medium: calc(var(--cardinal) * 5);\n --size-large: calc(var(--cardinal) * 8);\n --size-huge: calc(var(--cardinal) * 12);\n\n --typography-h1: h2;\n }\n `,\n ];\n\n @state()\n declare _entry: string | null;\n @property()\n declare widgetName: string;\n\n @state()\n declare _child: { tag: string; nodeId: string } | null;\n\n constructor() {\n super();\n this._child = null;\n this._entry = null;\n // this._installRoutes();\n }\n\n // _installRoutes() {\n // page('/browse', this._browseRoute);\n // page('*', this._notFoundRoute);\n // page();\n // }\n\n // _browseRoute() {\n // console.log('browse route');\n // }\n\n // _notFoundRoute() {\n // console.log('not found route');\n // }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.controller.widget) {\n this.provideInstance('container', this.controller.widget.container);\n\n Promise.all([\n ComponentPlatform.getInstance(this.controller.widget.container),\n this.controller.widget.container.getAsync('componentResolver'),\n ]).then(async (values) => {\n this.platform = values[0];\n const resolver: ComponentResolver = values[1];\n\n this.unsubscribe = this.platform.events.subscribe(\n 'components:root-children-changed',\n (event: any, { node }: any) => {\n if (node.parent && node.parent.type === 'root') {\n this._entry = node.parent.children.default[0].id;\n }\n }\n );\n\n this._entry = this.platform.nodes.root.children.default[0].id || null;\n\n if (!this._entry) {\n console.warn('Could not get node ID for entry node on the ComponentPlatform.');\n return;\n }\n\n this._child =\n (await resolveComponent(this._entry, resolver, this.platform)) || null;\n });\n }\n }\n\n render() {\n if (!this._child) {\n return nothing;\n }\n\n return html` <${unsafeStatic(this._child.tag)} nodeId=${this._child.nodeId} /> `;\n }\n}\n","import { Container } from '@webprovisions/platform';\nimport './widget-component';\nimport { WidgetRoot } from './widget-root';\n\ncustomElements.define('widget-root', WidgetRoot);\n\nexport default (widgetName: string, container: Container, element: HTMLElement) => {\n const root = document.createElement('widget-root');\n root.setAttribute('widgetName', widgetName);\n element.appendChild(root);\n};\n"],"names":["getWidget","elem","root","widgetName","acc","className","WidgetController","host","Provider","Base","ProviderClass","args","event","key","instance","WidgetRoot","LitElement","ComponentPlatform","values","__async","resolver","node","resolveComponent","html","unsafeStatic","nothing","css","__decorateClass","state","property","render","container","element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Ba,MAAAA,IAAY,CAACC,MAA2B;AAC7C,QAAAC,IAAOD,EAAK;AAEd,MAAAA,EAAK,aAAa,YAAY;AAKzB,WAJS,OAAe,OAAO,QAAQ;AAAA,MAC5CA,EAAK,aAAa,YAAY;AAAA,IAAA;AAIvB,MAAAA,EAAK,UAAU,SAAS,eAAe,GAAG;AACnD,UAAME,IAAa,MAAM,KAAKF,EAAK,SAAS,EAAE;AAAA,MAC5C,CAACG,GAAKC,OACAA,EAAU,QAAQ,SAAS,MAAM,MAC7BD,IAAAC,EAAU,QAAQ,WAAW,EAAE,IAEhCD;AAAA,MAET;AAAA,IAAA;AAIK,WAFS,OAAe,OAAO,QAAQ,KAAKD,CAAU;AAAA,EAG/D;AAEI,SAACD,EAAK,OAIHF,EAAUE,EAAK,IAAI,IAHjB;AA4BX;AC5EO,MAAMI,EAAiB;AAAA,EAI5B,YAAYC,GAAW;AACrB,KAAC,KAAK,OAAOA,GAAM,cAAc,IAAI;AAAA,EACvC;AAAA,EAEA,gBAAgB;AACT,SAAA,SAASP,EAAU,KAAK,IAAI;AAAA,EACnC;AACF;ACNa,MAAAQ,IAAW,CAAoCC,MAAY;AACtE,QAAMC,UAAsBD,EAAK;AAAA,IAG/B,eAAeE,GAAa;AACpB,eAHR,KAAA,iCAAiB,OAKV,KAAA,iBAAiB,oBAAoB,CAACC,MAAe;AAClD,cAAAC,IAAMD,EAAM,OAAO;AACzB,gBAAQ,IAAI,gBAAgB,GAExB,KAAK,WAAW,IAAIC,CAAG,MACzBD,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