@telia-ace/widget-types-grid 1.0.30-experimental.2 → 1.0.30-experimental.21

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.
@@ -0,0 +1,154 @@
1
+ var h = (r, e, o) => new Promise((i, t) => {
2
+ var n = (s) => {
3
+ try {
4
+ l(o.next(s));
5
+ } catch (d) {
6
+ t(d);
7
+ }
8
+ }, a = (s) => {
9
+ try {
10
+ l(o.throw(s));
11
+ } catch (d) {
12
+ t(d);
13
+ }
14
+ }, l = (s) => s.done ? i(s.value) : Promise.resolve(s.value).then(n, a);
15
+ l((o = o.apply(r, e)).next());
16
+ });
17
+ import { ComponentPlatform as u } from "@telia-ace/widget-core";
18
+ import { nothing as g, css as w, LitElement as y } from "lit";
19
+ import { state as m, property as _ } from "lit/decorators.js";
20
+ import { html as v, unsafeStatic as b } from "lit/static-html.js";
21
+ import { resolveComponent as x } from "./index.js";
22
+ import "@telia-ace/widget-ui";
23
+ import "react";
24
+ import "@emotion/react";
25
+ import "@emotion/styled";
26
+ import "@telia-ace/widget-utilities";
27
+ import "react-transition-group";
28
+ import "react-router";
29
+ import "@open-wc/lit-helpers";
30
+ import "@telia-ace/widget-routing";
31
+ import "@telia-ace/widget-services";
32
+ import "@webprovisions/bootstrapping";
33
+ import "@webprovisions/platform";
34
+ const f = (r) => {
35
+ const e = r.getRootNode();
36
+ if (r.getAttribute("widgetname"))
37
+ return window.humany.widgets.find(
38
+ r.getAttribute("widgetname")
39
+ );
40
+ if (r.classList.contains("humany-widget")) {
41
+ const o = Array.from(r.classList).reduce(
42
+ (t, n) => (n.indexOf("humany_") === 0 && (t = n.replace("humany_", "")), t),
43
+ void 0
44
+ );
45
+ return window.humany.widgets.find(o);
46
+ }
47
+ return e.host ? f(e.host) : null;
48
+ };
49
+ class C {
50
+ constructor(e) {
51
+ (this.host = e).addController(this);
52
+ }
53
+ hostConnected() {
54
+ this.widget = f(this.host);
55
+ }
56
+ }
57
+ const P = (r) => {
58
+ class e extends r {
59
+ constructor(...i) {
60
+ super(), this._instances = /* @__PURE__ */ new Map(), this.addEventListener("request-instance", (t) => {
61
+ const n = t.detail.key;
62
+ this._instances.has(n) && (t.detail.instance = this._instances.get(n), t.stopPropagation());
63
+ });
64
+ }
65
+ provideInstance(i, t) {
66
+ this._instances.set(i, t);
67
+ }
68
+ }
69
+ return e;
70
+ };
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
+ };
76
+ class c extends P(y) {
77
+ constructor() {
78
+ super(), this.controller = new C(this), this._child = null, this._entry = null;
79
+ }
80
+ connectedCallback() {
81
+ super.connectedCallback(), this.controller.widget && (this.provideInstance("container", this.controller.widget.container), Promise.all([
82
+ u.getInstance(this.controller.widget.container),
83
+ this.controller.widget.container.getAsync("componentResolver")
84
+ ]).then((e) => h(this, null, function* () {
85
+ this.platform = e[0];
86
+ const o = e[1];
87
+ if (this.unsubscribe = this.platform.events.subscribe(
88
+ "components:root-children-changed",
89
+ (i, { node: t }) => {
90
+ t.parent && t.parent.type === "root" && (this._entry = t.parent.children.default[0].id);
91
+ }
92
+ ), this._entry = this.platform.nodes.root.children.default[0].id || null, !this._entry) {
93
+ console.warn("Could not get node ID for entry node on the ComponentPlatform.");
94
+ return;
95
+ }
96
+ this._child = (yield x(this._entry, o, this.platform)) || null;
97
+ })));
98
+ }
99
+ render() {
100
+ return this._child ? v` <${b(this._child.tag)} nodeId=${this._child.nodeId} /> ` : g;
101
+ }
102
+ }
103
+ c.styles = [
104
+ w`
105
+ :host {
106
+ --gap: 0;
107
+ --fonts-type: 'Lato';
108
+ --fonts-small: 0.9em;
109
+ --fonts-normal: 1em;
110
+ --fonts-medium: 1.1em;
111
+ --fonts-huge: 1.4em;
112
+ --fonts-large: 1.1em;
113
+ --colors-accent: #fafafa;
114
+ --colors-link: #990ae3;
115
+ --colors-primary: #990ae3;
116
+ --colors-text: #333333;
117
+ --colors-textLight: #767676;
118
+ --colors-warning: #cc0000;
119
+ --accessibility-border: 2px dashed #990ae3;
120
+ --accessibility-colors-inactiveText: #990ae3;
121
+ --accessibility-colors-activeText: #ffffff;
122
+ --inputBorder: 1px solid #000000;
123
+ --border: 1px solid #000000;
124
+ --borderRadius: 5px;
125
+ --boxShadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
126
+ --cardinal: 3px;
127
+ --size-small: var(--cardinal);
128
+ --size-normal: calc(var(--cardinal) * 3);
129
+ --size-medium: calc(var(--cardinal) * 5);
130
+ --size-large: calc(var(--cardinal) * 8);
131
+ --size-huge: calc(var(--cardinal) * 12);
132
+
133
+ --typography-h1: h2;
134
+ }
135
+ `
136
+ ];
137
+ p([
138
+ m()
139
+ ], c.prototype, "_entry", 2);
140
+ p([
141
+ _()
142
+ ], c.prototype, "widgetName", 2);
143
+ p([
144
+ m()
145
+ ], c.prototype, "_child", 2);
146
+ customElements.define("widget-root", c);
147
+ const H = (r, e, o) => {
148
+ const i = document.createElement("widget-root");
149
+ i.setAttribute("widgetName", r), o.appendChild(i);
150
+ };
151
+ export {
152
+ H as default
153
+ };
154
+ //# sourceMappingURL=render.3f019371.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.3f019371.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,QA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;AAAA,EADPC,EAAM;AAAA,GA7CEb,EA8CD,WAAA,UAAA,CAAA;AChEZ,eAAe,OAAO,eAAeA,CAAU;AAE/C,MAAAe,IAAe,CAAC3B,GAAoB4B,GAAsBC,MAAyB;AACzE,QAAA9B,IAAO,SAAS,cAAc,aAAa;AAC5C,EAAAA,EAAA,aAAa,cAAcC,CAAU,GAC1C6B,EAAQ,YAAY9B,CAAI;AAC5B;"}
@@ -1,6 +1,6 @@
1
1
  import { ComponentPlatform } from '@telia-ace/widget-core';
2
2
  import { EventSubscriptionCancellation } from '@webprovisions/platform';
3
- import { LitElement } from 'lit';
3
+ import { LitElement, nothing } from 'lit';
4
4
  import { WidgetController } from '../controllers/widget-controller';
5
5
  declare const WidgetRoot_base: (new (...args: any[]) => import("../mixins/provider").ProviderInterface) & typeof LitElement;
6
6
  export declare class WidgetRoot extends WidgetRoot_base {
@@ -8,14 +8,14 @@ export declare class WidgetRoot extends WidgetRoot_base {
8
8
  platform: ComponentPlatform | undefined;
9
9
  unsubscribe: EventSubscriptionCancellation | undefined;
10
10
  static styles: import("lit").CSSResult[];
11
- protected _entry: string | null;
11
+ _entry: string | null;
12
12
  widgetName: string;
13
- protected _child: {
13
+ _child: {
14
14
  tag: string;
15
15
  nodeId: string;
16
16
  } | null;
17
17
  constructor();
18
18
  connectedCallback(): void;
19
- render(): import("lit").TemplateResult<1 | 2>;
19
+ render(): typeof nothing | import("lit").TemplateResult<1 | 2>;
20
20
  }
21
21
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-types-grid",
3
- "version": "1.0.30-experimental.2",
3
+ "version": "1.0.30-experimental.21",
4
4
  "description": "Type definition for Grid widget.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -23,15 +23,15 @@
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.2",
27
- "@telia-ace/widget-forms": "1.0.28-experimental.2",
28
- "@telia-ace/widget-routing": "1.0.22-experimental.2",
29
- "@telia-ace/widget-services": "1.0.21-experimental.2",
30
- "@telia-ace/widget-ui": "1.0.28-experimental.2",
31
- "@telia-ace/widget-utilities": "1.0.10-experimental.2",
26
+ "@telia-ace/widget-core": "1.0.21-experimental.21",
27
+ "@telia-ace/widget-forms": "1.0.28-experimental.21",
28
+ "@telia-ace/widget-routing": "1.0.22-experimental.21",
29
+ "@telia-ace/widget-services": "1.0.21-experimental.21",
30
+ "@telia-ace/widget-ui": "1.0.28-experimental.21",
31
+ "@telia-ace/widget-utilities": "1.0.10-experimental.21",
32
32
  "@webprovisions/bootstrapping": "^1.0.12",
33
33
  "@webprovisions/platform": "^1.1.2",
34
- "lit": "^2.6.0",
34
+ "lit": "^2.6.1",
35
35
  "page": "^1.11.6"
36
36
  },
37
37
  "peerDependencies": {
@@ -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.2",
51
+ "@telia-ace/widget-developer-tools": "1.0.16-experimental.21",
52
52
  "@types/react": "^18.0.26",
53
53
  "@types/react-dom": "^18.0.10",
54
54
  "@types/react-router": "^5.1.20",