@telia-ace/alliance-ui 1.0.16-next.0 → 1.0.16-next.1
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/CHANGELOG.md +8 -0
- package/components/alliance-link.js +2 -2
- package/components/alliance-modal.js +3 -3
- package/components/alliance-paginator.js +3 -3
- package/components/alliance-pop-over.d.ts +2 -0
- package/components/alliance-pop-over.js +5 -0
- package/components/alliance-pop-over.js.map +1 -0
- package/components/alliance-table.js +3 -3
- package/components/alliance-view.js +43 -99
- package/components/alliance-view.js.map +1 -1
- package/components/chunk-2PC6L5RK.js +115 -0
- package/components/chunk-2PC6L5RK.js.map +1 -0
- package/components/{chunk-ADFC4JKF.js → chunk-4546RD56.js} +162 -198
- package/components/chunk-4546RD56.js.map +1 -0
- package/components/{chunk-B6YHD7BN.js → chunk-5A2VXG2P.js} +1 -1
- package/components/chunk-5A2VXG2P.js.map +1 -0
- package/components/chunk-AW7BCYX5.js +22 -0
- package/components/chunk-AW7BCYX5.js.map +1 -0
- package/components/{chunk-LYU2K33W.js → chunk-CZPHL6EU.js} +109 -226
- package/components/chunk-CZPHL6EU.js.map +1 -0
- package/components/chunk-IFHLWFVT.js +133 -0
- package/components/chunk-IFHLWFVT.js.map +1 -0
- package/components/{chunk-XPHFAKEI.js → chunk-MA6NFT5S.js} +21 -64
- package/components/chunk-MA6NFT5S.js.map +1 -0
- package/components/index.js +7 -6
- package/package.json +4 -3
- package/voca/foundations/index.js +3 -4
- package/voca/foundations/index.js.map +1 -1
- package/components/chunk-ADFC4JKF.js.map +0 -1
- package/components/chunk-B6YHD7BN.js.map +0 -1
- package/components/chunk-LYU2K33W.js.map +0 -1
- package/components/chunk-NB6ODBZJ.js +0 -13
- package/components/chunk-NB6ODBZJ.js.map +0 -1
- package/components/chunk-WYQTL7R3.js +0 -167
- package/components/chunk-WYQTL7R3.js.map +0 -1
- package/components/chunk-XPHFAKEI.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @telia-ace/alliance-ui
|
|
2
2
|
|
|
3
|
+
## 1.0.16-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d8c3069: Ensure `href` attribute is properly reflected and use [`display: contents`](https://developer.mozilla.org/en-US/docs/Web/CSS/display#contents) on the `<alliance-link>` host element.
|
|
8
|
+
- d8c3069: Add `<alliance-pop-over>` component.
|
|
9
|
+
- @telia-ace/alliance-internal-client-utilities@1.0.5-next.0
|
|
10
|
+
|
|
3
11
|
## 1.0.16-next.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-4546RD56.js';
|
|
2
2
|
import './chunk-JQ76TOQT.js';
|
|
3
3
|
import './chunk-P2AWWJPH.js';
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-
|
|
4
|
+
import './chunk-5A2VXG2P.js';
|
|
5
|
+
import './chunk-AW7BCYX5.js';
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
7
7
|
//# sourceMappingURL=alliance-modal.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-CZPHL6EU.js';
|
|
2
2
|
import './chunk-JQ76TOQT.js';
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
import './chunk-5A2VXG2P.js';
|
|
4
|
+
import './chunk-AW7BCYX5.js';
|
|
5
5
|
//# sourceMappingURL=out.js.map
|
|
6
6
|
//# sourceMappingURL=alliance-paginator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import './chunk-
|
|
1
|
+
import './chunk-MA6NFT5S.js';
|
|
2
2
|
import './chunk-P2AWWJPH.js';
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
import './chunk-5A2VXG2P.js';
|
|
4
|
+
import './chunk-AW7BCYX5.js';
|
|
5
5
|
//# sourceMappingURL=out.js.map
|
|
6
6
|
//# sourceMappingURL=alliance-table.js.map
|
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorateClass, define } from './chunk-AW7BCYX5.js';
|
|
2
2
|
import { LitElement, css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
|
|
5
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
6
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
8
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
-
else
|
|
10
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
11
|
-
if (d = decorators[i])
|
|
12
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
-
}
|
|
15
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
16
|
-
function _ts_metadata(k, v) {
|
|
17
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
18
|
-
return Reflect.metadata(k, v);
|
|
19
|
-
}
|
|
20
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
21
5
|
var viewElementPrefix = "alliance-view-";
|
|
22
6
|
var viewElementSelector = "app-view";
|
|
23
|
-
var ViewElementType
|
|
24
|
-
(function(ViewElementType2) {
|
|
7
|
+
var ViewElementType = /* @__PURE__ */ ((ViewElementType2) => {
|
|
25
8
|
ViewElementType2["Main"] = "main";
|
|
26
9
|
ViewElementType2["Aside"] = "aside";
|
|
27
10
|
ViewElementType2["Body"] = "body";
|
|
28
|
-
|
|
11
|
+
return ViewElementType2;
|
|
12
|
+
})(ViewElementType || {});
|
|
29
13
|
function viewElementTag(appName) {
|
|
30
14
|
return `${viewElementPrefix}${appName}`;
|
|
31
15
|
}
|
|
32
|
-
__name(viewElementTag, "viewElementTag");
|
|
33
16
|
function registerViewElement(appName, onRender) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
class ViewElement extends LitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.appView = true;
|
|
21
|
+
this.loading = true;
|
|
22
|
+
this.mounted = false;
|
|
23
|
+
this.args = {};
|
|
24
|
+
this.app = appName;
|
|
25
|
+
this.capability = "launch";
|
|
26
|
+
this.complete = (result) => {
|
|
27
|
+
this.dispatchEvent(new CustomEvent("complete", { detail: result }));
|
|
28
|
+
};
|
|
37
29
|
}
|
|
38
|
-
static
|
|
30
|
+
static {
|
|
31
|
+
this.styles = css`
|
|
39
32
|
.loader {
|
|
40
33
|
background-color: rgba(255, 255, 255, 0.4);
|
|
41
34
|
z-index: var(--layer-modal);
|
|
@@ -133,19 +126,6 @@ function registerViewElement(appName, onRender) {
|
|
|
133
126
|
}
|
|
134
127
|
}
|
|
135
128
|
`;
|
|
136
|
-
constructor() {
|
|
137
|
-
super();
|
|
138
|
-
this.appView = true;
|
|
139
|
-
this.loading = true;
|
|
140
|
-
this.mounted = false;
|
|
141
|
-
this.args = {};
|
|
142
|
-
this.app = appName;
|
|
143
|
-
this.capability = "launch";
|
|
144
|
-
this.complete = (result) => {
|
|
145
|
-
this.dispatchEvent(new CustomEvent("complete", {
|
|
146
|
-
detail: result
|
|
147
|
-
}));
|
|
148
|
-
};
|
|
149
129
|
}
|
|
150
130
|
init(props) {
|
|
151
131
|
for (const [key, value] of Object.entries(props)) {
|
|
@@ -181,7 +161,7 @@ function registerViewElement(appName, onRender) {
|
|
|
181
161
|
}
|
|
182
162
|
renderTypeStyling() {
|
|
183
163
|
switch (this.type) {
|
|
184
|
-
case "body"
|
|
164
|
+
case "body" /* Body */:
|
|
185
165
|
return html`
|
|
186
166
|
<style>
|
|
187
167
|
:host .app-loader {
|
|
@@ -189,7 +169,7 @@ function registerViewElement(appName, onRender) {
|
|
|
189
169
|
}
|
|
190
170
|
</style>
|
|
191
171
|
`;
|
|
192
|
-
case "aside"
|
|
172
|
+
case "aside" /* Aside */:
|
|
193
173
|
return html`
|
|
194
174
|
<style>
|
|
195
175
|
:host {
|
|
@@ -206,7 +186,7 @@ function registerViewElement(appName, onRender) {
|
|
|
206
186
|
</style>
|
|
207
187
|
`;
|
|
208
188
|
default:
|
|
209
|
-
case "main"
|
|
189
|
+
case "main" /* Main */:
|
|
210
190
|
return html`
|
|
211
191
|
<style>
|
|
212
192
|
:host {
|
|
@@ -225,66 +205,30 @@ function registerViewElement(appName, onRender) {
|
|
|
225
205
|
<slot></slot>
|
|
226
206
|
`;
|
|
227
207
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
property({
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}),
|
|
251
|
-
_ts_metadata("design:type", Object)
|
|
252
|
-
], ViewElement.prototype, "loading", void 0);
|
|
253
|
-
_ts_decorate([
|
|
254
|
-
property({
|
|
255
|
-
type: String,
|
|
256
|
-
attribute: false,
|
|
257
|
-
reflect: true
|
|
258
|
-
}),
|
|
259
|
-
_ts_metadata("design:type", Object)
|
|
260
|
-
], ViewElement.prototype, "app", void 0);
|
|
261
|
-
_ts_decorate([
|
|
262
|
-
property({
|
|
263
|
-
type: String,
|
|
264
|
-
attribute: true,
|
|
265
|
-
reflect: true
|
|
266
|
-
}),
|
|
267
|
-
_ts_metadata("design:type", Object)
|
|
268
|
-
], ViewElement.prototype, "type", void 0);
|
|
269
|
-
_ts_decorate([
|
|
270
|
-
property({
|
|
271
|
-
type: String,
|
|
272
|
-
attribute: true,
|
|
273
|
-
reflect: true
|
|
274
|
-
}),
|
|
275
|
-
_ts_metadata("design:type", Object)
|
|
276
|
-
], ViewElement.prototype, "capability", void 0);
|
|
277
|
-
_ts_decorate([
|
|
278
|
-
property({
|
|
279
|
-
type: Object,
|
|
280
|
-
attribute: true,
|
|
281
|
-
reflect: true
|
|
282
|
-
}),
|
|
283
|
-
_ts_metadata("design:type", Object)
|
|
284
|
-
], ViewElement.prototype, "args", void 0);
|
|
208
|
+
}
|
|
209
|
+
__decorateClass([
|
|
210
|
+
property({ type: Boolean, attribute: viewElementSelector, reflect: true })
|
|
211
|
+
], ViewElement.prototype, "appView", 2);
|
|
212
|
+
__decorateClass([
|
|
213
|
+
property({ type: Boolean, attribute: true, reflect: true })
|
|
214
|
+
], ViewElement.prototype, "mounted", 2);
|
|
215
|
+
__decorateClass([
|
|
216
|
+
property({ type: Boolean, attribute: true, reflect: true })
|
|
217
|
+
], ViewElement.prototype, "loading", 2);
|
|
218
|
+
__decorateClass([
|
|
219
|
+
property({ type: String, attribute: false, reflect: true })
|
|
220
|
+
], ViewElement.prototype, "app", 2);
|
|
221
|
+
__decorateClass([
|
|
222
|
+
property({ type: String, attribute: true, reflect: true })
|
|
223
|
+
], ViewElement.prototype, "type", 2);
|
|
224
|
+
__decorateClass([
|
|
225
|
+
property({ type: String, attribute: true, reflect: true })
|
|
226
|
+
], ViewElement.prototype, "capability", 2);
|
|
227
|
+
__decorateClass([
|
|
228
|
+
property({ type: Object, attribute: true, reflect: true })
|
|
229
|
+
], ViewElement.prototype, "args", 2);
|
|
285
230
|
define(viewElementTag(appName), ViewElement);
|
|
286
231
|
}
|
|
287
|
-
__name(registerViewElement, "registerViewElement");
|
|
288
232
|
|
|
289
233
|
export { ViewElementType, registerViewElement, viewElementPrefix, viewElementSelector, viewElementTag };
|
|
290
234
|
//# sourceMappingURL=out.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/alliance-view/alliance-view.ts"],"names":["LitElement","css","html","property","viewElementPrefix","viewElementSelector","ViewElementType","viewElementTag","appName","registerViewElement","onRender","ViewElement","styles","constructor","appView","loading","mounted","args","app","capability","complete","result","dispatchEvent","CustomEvent","detail","init","props","key","value","Object","entries","connectedCallback","id","crypto","randomUUID","renderLoader","renderTypeStyling","type","render","Boolean","attribute","reflect","String","define"],"mappings":";;;;;;AAIA,SAASA,YAAYC,KAAKC,YAAY;AACtC,SAASC,gBAAgB;;;;;;;;;;;;;;;;;AAIlB,IAAMC,oBAAoB;AAE1B,IAAMC,sBAAsB;;UAEvBC,kBAAAA;;;;GAAAA,oBAAAA,kBAAAA,CAAAA,EAAAA;AAML,SAASC,eAAeC,SAAe;AAC1C,SAAO,GAAGJ,iBAAAA,GAAoBI,OAAAA;AAClC;AAFgBD;AAwBT,SAASE,oBACZD,SACAE,UAAqD;AAErD,MAAMC,cAAN,MAAMA,oBAAoBX,WAAAA;WAAAA;;;IACtB,OAAOY,SAASX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmGhBY,cAAc;AACV,YAAK;AACL,WAAKC,UAAU;AACf,WAAKC,UAAU;AACf,WAAKC,UAAU;AACf,WAAKC,OAAO,CAAC;AACb,WAAKC,MAAMV;AACX,WAAKW,aAAa;AAClB,WAAKC,WAAW,CAACC,WAAAA;AACb,aAAKC,cAAc,IAAIC,YAAY,YAAY;UAAEC,QAAQH;QAAO,CAAA,CAAA;MACpE;IACJ;IAEAI,KAAKC,OAAsB;AACvB,iBAAW,CAACC,KAAKC,KAAAA,KAAUC,OAAOC,QAAQJ,KAAAA,GAAQ;AAC9C,YAAIE,OAAO;AAEP,eAAKD,GAAAA,IAAOC;QAChB;MACJ;IACJ;IAyBA,MAAMG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AAK,CAAA;;KA5IvD9B,YAAAA,WAAAA,QAAAA,MAAAA;AA6NNgC,SAAOpC,eAAeC,OAAAA,GAAUG,WAAAA;AACpC;AAlOgBF","sourcesContent":["import type {\n Promisable,\n SerializeableObject,\n} from '@telia-ace/alliance-internal-client-utilities';\nimport { LitElement, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { define } from '@/utils';\n\nexport const viewElementPrefix = 'alliance-view-';\n\nexport const viewElementSelector = 'app-view';\n\nexport enum ViewElementType {\n Main = 'main',\n Aside = 'aside',\n Body = 'body',\n}\n\nexport function viewElementTag(appName: string) {\n return `${viewElementPrefix}${appName}`;\n}\n\nexport type ViewInitProps = {\n app?: IViewElement['app'];\n capability?: IViewElement['capability'];\n id?: IViewElement['id'];\n args?: IViewElement['args'];\n type?: IViewElement['type'];\n complete?: IViewElement['complete'];\n};\n\nexport interface IViewElement extends LitElement {\n init: (props: ViewInitProps) => void;\n complete: (result: SerializeableObject | null) => void;\n app: string;\n capability: string;\n args: SerializeableObject;\n mounted: boolean;\n loading: boolean;\n type?: ViewElementType;\n}\n\nexport function registerViewElement(\n appName: string,\n onRender: (element: IViewElement) => Promisable<void>,\n) {\n class ViewElement extends LitElement implements IViewElement {\n static styles = css`\n .loader {\n background-color: rgba(255, 255, 255, 0.4);\n z-index: var(--layer-modal);\n position: absolute;\n inset: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n\n > div {\n display: inline-block;\n position: relative;\n width: 80px;\n height: 80px;\n\n > div {\n animation: alliance-app-loader 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n transform-origin: 40px 40px;\n\n &:after {\n content: ' ';\n display: block;\n position: absolute;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: var(--purple-850);\n margin: -4px 0 0 -4px;\n }\n &:nth-child(1) {\n animation-delay: -0.036s;\n }\n &:nth-child(1):after {\n top: 63px;\n left: 63px;\n }\n &:nth-child(2) {\n animation-delay: -0.072s;\n }\n &:nth-child(2):after {\n top: 68px;\n left: 56px;\n }\n &:nth-child(3) {\n animation-delay: -0.108s;\n }\n &:nth-child(3):after {\n top: 71px;\n left: 48px;\n }\n &:nth-child(4) {\n animation-delay: -0.144s;\n }\n &:nth-child(4):after {\n top: 72px;\n left: 40px;\n }\n &:nth-child(5) {\n animation-delay: -0.18s;\n }\n &:nth-child(5):after {\n top: 71px;\n left: 32px;\n }\n &:nth-child(6) {\n animation-delay: -0.216s;\n }\n &:nth-child(6):after {\n top: 68px;\n left: 24px;\n }\n &:nth-child(7) {\n animation-delay: -0.252s;\n }\n &:nth-child(7):after {\n top: 63px;\n left: 17px;\n }\n &:nth-child(8) {\n animation-delay: -0.288s;\n }\n &:nth-child(8):after {\n top: 56px;\n left: 12px;\n }\n }\n }\n }\n @keyframes alliance-app-loader {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n `;\n\n constructor() {\n super();\n this.appView = true;\n this.loading = true;\n this.mounted = false;\n this.args = {};\n this.app = appName;\n this.capability = 'launch';\n this.complete = (result) => {\n this.dispatchEvent(new CustomEvent('complete', { detail: result }));\n };\n }\n\n init(props: ViewInitProps) {\n for (const [key, value] of Object.entries(props)) {\n if (value) {\n // @ts-ignore\n this[key] = value;\n }\n }\n }\n\n @property({ type: Boolean, attribute: viewElementSelector, reflect: true })\n private declare appView: boolean;\n\n @property({ type: Boolean, attribute: true, reflect: true })\n declare mounted: IViewElement['mounted'];\n\n @property({ type: Boolean, attribute: true, reflect: true })\n declare loading: IViewElement['loading'];\n\n @property({ type: String, attribute: false, reflect: true })\n declare app: IViewElement['app'];\n\n @property({ type: String, attribute: true, reflect: true })\n declare type: IViewElement['type'];\n\n @property({ type: String, attribute: true, reflect: true })\n declare capability: IViewElement['capability'];\n\n @property({ type: Object, attribute: true, reflect: true })\n declare args: IViewElement['args'];\n\n declare complete: IViewElement['complete'];\n\n async connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = crypto.randomUUID();\n }\n await onRender(this);\n this.loading = false;\n this.mounted = true;\n }\n\n private renderLoader() {\n return html`\n <div class=\"loader\">\n <div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n `;\n }\n\n private renderTypeStyling() {\n switch (this.type) {\n case ViewElementType.Body:\n return html`\n <style>\n :host .app-loader {\n display: none;\n }\n </style>\n `;\n case ViewElementType.Aside:\n return html`\n <style>\n :host {\n height: 100vh;\n width: auto;\n z-index: 3;\n position: fixed;\n top: 0;\n left: 0;\n }\n :host .app-loader {\n display: none;\n }\n </style>\n `;\n default:\n case ViewElementType.Main:\n return html`\n <style>\n :host {\n position: relative;\n display: block;\n height: 100%;\n width: 100%;\n }\n </style>\n `;\n }\n }\n\n protected render() {\n return html`\n ${this.renderTypeStyling()} ${this.loading ? this.renderLoader() : ''}\n <slot></slot>\n `;\n }\n }\n\n define(viewElementTag(appName), ViewElement);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/alliance-view/alliance-view.ts"],"names":["ViewElementType"],"mappings":";;;;;;AAIA,SAAS,YAAY,KAAK,YAAY;AACtC,SAAS,gBAAgB;AAIlB,IAAM,oBAAoB;AAE1B,IAAM,sBAAsB;AAE5B,IAAK,kBAAL,kBAAKA,qBAAL;AACH,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,UAAO;AAHC,SAAAA;AAAA,GAAA;AAML,SAAS,eAAe,SAAiB;AAC5C,SAAO,GAAG,iBAAiB,GAAG,OAAO;AACzC;AAsBO,SAAS,oBACZ,SACA,UACF;AAAA,EACE,MAAM,oBAAoB,WAAmC;AAAA,IAoGzD,cAAc;AACV,YAAM;AACN,WAAK,UAAU;AACf,WAAK,UAAU;AACf,WAAK,UAAU;AACf,WAAK,OAAO,CAAC;AACb,WAAK,MAAM;AACX,WAAK,aAAa;AAClB,WAAK,WAAW,CAAC,WAAW;AACxB,aAAK,cAAc,IAAI,Y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ACD,iBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOX,KAAK;AACD,iBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAeX;AAAA,QACA,KAAK;AACD,iBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAUf;AAAA,IACJ;AAAA,IAEU,SAAS;AACf,aAAO;AAAA,kBACD,KAAK,kBAAkB,CAAC,IAAI,KAAK,UAAU,KAAK,aAAa,IAAI,EAAE;AAAA;AAAA;AAAA,IAG7E;AAAA,EACJ;AAhGoB;AAAA,IADf,SAAS,EAAE,MAAM,SAAS,WAAW,qBAAqB,SAAS,KAAK,CAAC;AAAA,KA1HxE,YA2Hc;AAGR;AAAA,IADP,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,KA7HzD,YA8HM;AAGA;AAAA,IADP,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,KAhIzD,YAiIM;AAGA;AAAA,IADP,SAAS,EAAE,MAAM,QAAQ,WAAW,OAAO,SAAS,KAAK,CAAC;AAAA,KAnIzD,YAoIM;AAGA;AAAA,IADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,KAtIxD,YAuIM;AAGA;AAAA,IADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,KAzIxD,YA0IM;AAGA;AAAA,IADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,KA5IxD,YA6IM;AAgFZ,SAAO,eAAe,OAAO,GAAG,WAAW;AAC/C","sourcesContent":["import type {\n Promisable,\n SerializeableObject,\n} from '@telia-ace/alliance-internal-client-utilities';\nimport { LitElement, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { define } from '@/utils';\n\nexport const viewElementPrefix = 'alliance-view-';\n\nexport const viewElementSelector = 'app-view';\n\nexport enum ViewElementType {\n Main = 'main',\n Aside = 'aside',\n Body = 'body',\n}\n\nexport function viewElementTag(appName: string) {\n return `${viewElementPrefix}${appName}`;\n}\n\nexport type ViewInitProps = {\n app?: IViewElement['app'];\n capability?: IViewElement['capability'];\n id?: IViewElement['id'];\n args?: IViewElement['args'];\n type?: IViewElement['type'];\n complete?: IViewElement['complete'];\n};\n\nexport interface IViewElement extends LitElement {\n init: (props: ViewInitProps) => void;\n complete: (result: SerializeableObject | null) => void;\n app: string;\n capability: string;\n args: SerializeableObject;\n mounted: boolean;\n loading: boolean;\n type?: ViewElementType;\n}\n\nexport function registerViewElement(\n appName: string,\n onRender: (element: IViewElement) => Promisable<void>,\n) {\n class ViewElement extends LitElement implements IViewElement {\n static styles = css`\n .loader {\n background-color: rgba(255, 255, 255, 0.4);\n z-index: var(--layer-modal);\n position: absolute;\n inset: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n\n > div {\n display: inline-block;\n position: relative;\n width: 80px;\n height: 80px;\n\n > div {\n animation: alliance-app-loader 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n transform-origin: 40px 40px;\n\n &:after {\n content: ' ';\n display: block;\n position: absolute;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: var(--purple-850);\n margin: -4px 0 0 -4px;\n }\n &:nth-child(1) {\n animation-delay: -0.036s;\n }\n &:nth-child(1):after {\n top: 63px;\n left: 63px;\n }\n &:nth-child(2) {\n animation-delay: -0.072s;\n }\n &:nth-child(2):after {\n top: 68px;\n left: 56px;\n }\n &:nth-child(3) {\n animation-delay: -0.108s;\n }\n &:nth-child(3):after {\n top: 71px;\n left: 48px;\n }\n &:nth-child(4) {\n animation-delay: -0.144s;\n }\n &:nth-child(4):after {\n top: 72px;\n left: 40px;\n }\n &:nth-child(5) {\n animation-delay: -0.18s;\n }\n &:nth-child(5):after {\n top: 71px;\n left: 32px;\n }\n &:nth-child(6) {\n animation-delay: -0.216s;\n }\n &:nth-child(6):after {\n top: 68px;\n left: 24px;\n }\n &:nth-child(7) {\n animation-delay: -0.252s;\n }\n &:nth-child(7):after {\n top: 63px;\n left: 17px;\n }\n &:nth-child(8) {\n animation-delay: -0.288s;\n }\n &:nth-child(8):after {\n top: 56px;\n left: 12px;\n }\n }\n }\n }\n @keyframes alliance-app-loader {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n `;\n\n constructor() {\n super();\n this.appView = true;\n this.loading = true;\n this.mounted = false;\n this.args = {};\n this.app = appName;\n this.capability = 'launch';\n this.complete = (result) => {\n this.dispatchEvent(new CustomEvent('complete', { detail: result }));\n };\n }\n\n init(props: ViewInitProps) {\n for (const [key, value] of Object.entries(props)) {\n if (value) {\n // @ts-ignore\n this[key] = value;\n }\n }\n }\n\n @property({ type: Boolean, attribute: viewElementSelector, reflect: true })\n private declare appView: boolean;\n\n @property({ type: Boolean, attribute: true, reflect: true })\n declare mounted: IViewElement['mounted'];\n\n @property({ type: Boolean, attribute: true, reflect: true })\n declare loading: IViewElement['loading'];\n\n @property({ type: String, attribute: false, reflect: true })\n declare app: IViewElement['app'];\n\n @property({ type: String, attribute: true, reflect: true })\n declare type: IViewElement['type'];\n\n @property({ type: String, attribute: true, reflect: true })\n declare capability: IViewElement['capability'];\n\n @property({ type: Object, attribute: true, reflect: true })\n declare args: IViewElement['args'];\n\n declare complete: IViewElement['complete'];\n\n async connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = crypto.randomUUID();\n }\n await onRender(this);\n this.loading = false;\n this.mounted = true;\n }\n\n private renderLoader() {\n return html`\n <div class=\"loader\">\n <div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n `;\n }\n\n private renderTypeStyling() {\n switch (this.type) {\n case ViewElementType.Body:\n return html`\n <style>\n :host .app-loader {\n display: none;\n }\n </style>\n `;\n case ViewElementType.Aside:\n return html`\n <style>\n :host {\n height: 100vh;\n width: auto;\n z-index: 3;\n position: fixed;\n top: 0;\n left: 0;\n }\n :host .app-loader {\n display: none;\n }\n </style>\n `;\n default:\n case ViewElementType.Main:\n return html`\n <style>\n :host {\n position: relative;\n display: block;\n height: 100%;\n width: 100%;\n }\n </style>\n `;\n }\n }\n\n protected render() {\n return html`\n ${this.renderTypeStyling()} ${this.loading ? this.renderLoader() : ''}\n <slot></slot>\n `;\n }\n }\n\n define(viewElementTag(appName), ViewElement);\n}\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { __decorateClass, define } from './chunk-AW7BCYX5.js';
|
|
2
|
+
import { createCapabilityPath, onEnter } from '@telia-ace/alliance-internal-client-utilities';
|
|
3
|
+
import { LitElement, css, html } from 'lit';
|
|
4
|
+
import { property } from 'lit/decorators.js';
|
|
5
|
+
|
|
6
|
+
function isOnCurrentPath(path = "") {
|
|
7
|
+
const cleanedPath = location.href.replace(location.origin, "");
|
|
8
|
+
return cleanedPath.startsWith(path);
|
|
9
|
+
}
|
|
10
|
+
var Link = class extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.navigate = () => {
|
|
14
|
+
if (this.active) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
history.pushState({}, "", this._href);
|
|
18
|
+
window.dispatchEvent(new Event("popstate"));
|
|
19
|
+
};
|
|
20
|
+
this.clickHandler = (event) => {
|
|
21
|
+
if (!this.app || this.download) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
this.navigate();
|
|
26
|
+
};
|
|
27
|
+
this.updateActive = () => {
|
|
28
|
+
this.active = isOnCurrentPath(this._href);
|
|
29
|
+
};
|
|
30
|
+
this.computeHref = () => {
|
|
31
|
+
if (this.app) {
|
|
32
|
+
this._href = this.href = createCapabilityPath(this.app, this.capability, this.args);
|
|
33
|
+
this.updateActive();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.href) {
|
|
37
|
+
this.capability = "";
|
|
38
|
+
return this._href = this.href;
|
|
39
|
+
}
|
|
40
|
+
throw new Error(
|
|
41
|
+
"The <alliance-link> component requires either the 'app' property or 'href' property!"
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
this.args = {};
|
|
45
|
+
this.download = false;
|
|
46
|
+
this.target = "_self";
|
|
47
|
+
this.href = this._href = "";
|
|
48
|
+
this.capability = "launch";
|
|
49
|
+
this.active = false;
|
|
50
|
+
}
|
|
51
|
+
static {
|
|
52
|
+
this.styles = css`
|
|
53
|
+
:host {
|
|
54
|
+
display: contents;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
connectedCallback() {
|
|
59
|
+
super.connectedCallback();
|
|
60
|
+
window.addEventListener("popstate", this.updateActive);
|
|
61
|
+
this.computeHref();
|
|
62
|
+
}
|
|
63
|
+
disconnectedCallback() {
|
|
64
|
+
window.removeEventListener("popstate", this.updateActive);
|
|
65
|
+
super.disconnectedCallback();
|
|
66
|
+
}
|
|
67
|
+
attributeChangedCallback(_1, _2, _3) {
|
|
68
|
+
super.attributeChangedCallback(_1, _2, _3);
|
|
69
|
+
setTimeout(() => this.computeHref());
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
return html`<a
|
|
73
|
+
part="anchor"
|
|
74
|
+
rel=${this.rel}
|
|
75
|
+
.target=${this.target}
|
|
76
|
+
.href=${this._href}
|
|
77
|
+
?download=${this.download}
|
|
78
|
+
?active=${this.active}
|
|
79
|
+
@click=${this.clickHandler}
|
|
80
|
+
@keydown=${onEnter(this.clickHandler)}
|
|
81
|
+
>
|
|
82
|
+
<slot></slot>
|
|
83
|
+
</a>`;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
__decorateClass([
|
|
87
|
+
property({ type: String, attribute: true, reflect: true })
|
|
88
|
+
], Link.prototype, "capability", 2);
|
|
89
|
+
__decorateClass([
|
|
90
|
+
property({ type: String, attribute: true, reflect: true })
|
|
91
|
+
], Link.prototype, "app", 2);
|
|
92
|
+
__decorateClass([
|
|
93
|
+
property({ type: Object, attribute: true, reflect: true })
|
|
94
|
+
], Link.prototype, "args", 2);
|
|
95
|
+
__decorateClass([
|
|
96
|
+
property({ type: String, attribute: true, reflect: true })
|
|
97
|
+
], Link.prototype, "href", 2);
|
|
98
|
+
__decorateClass([
|
|
99
|
+
property({ type: String })
|
|
100
|
+
], Link.prototype, "target", 2);
|
|
101
|
+
__decorateClass([
|
|
102
|
+
property({ type: String, attribute: true, reflect: true })
|
|
103
|
+
], Link.prototype, "rel", 2);
|
|
104
|
+
__decorateClass([
|
|
105
|
+
property({ type: Boolean, attribute: true, reflect: true })
|
|
106
|
+
], Link.prototype, "download", 2);
|
|
107
|
+
__decorateClass([
|
|
108
|
+
property({ type: String, attribute: false, reflect: false })
|
|
109
|
+
], Link.prototype, "_href", 2);
|
|
110
|
+
__decorateClass([
|
|
111
|
+
property({ type: Boolean, attribute: true, reflect: true })
|
|
112
|
+
], Link.prototype, "active", 2);
|
|
113
|
+
define("alliance-link", Link);
|
|
114
|
+
//# sourceMappingURL=out.js.map
|
|
115
|
+
//# sourceMappingURL=chunk-2PC6L5RK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/alliance-link/alliance-link.ts"],"names":[],"mappings":";;;;;;AAAA;AAAA,EAEI;AAAA,EACA;AAAA,OACG;AACP,SAAS,YAAY,KAAK,YAAY;AACtC,SAAS,gBAAgB;AAIzB,SAAS,gBAAgB,OAAe,IAAI;AACxC,QAAM,cAAc,SAAS,KAAK,QAAQ,SAAS,QAAQ,EAAE;AAC7D,SAAO,YAAY,WAAW,IAAI;AACtC;AAEO,IAAM,OAAN,cAAmB,WAAW;AAAA,EACjC,cAAc;AACV,UAAM;AAuCV,oBAAW,MAAM;AACb,UAAI,KAA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AAAA,sBACJ,KAAK,MAAM;AAAA,oBACb,KAAK,KAAK;AAAA,wBACN,KAAK,QAAQ;AAAA,sBACf,KAAK,MAAM;AAAA,qBACZ,KAAK,YAAY;AAAA,uBACf,QAAQ,KAAK,YAAY,CAAC;AAAA;AAAA;AAAA;AAAA,EAI7C;AACJ;AAzGY;AAAA,EADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GAjBjD,KAkBD;AAGA;AAAA,EADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GApBjD,KAqBD;AAGA;AAAA,EADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GAvBjD,KAwBD;AAMA;AAAA,EADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GA7BjD,KA8BD;AAGA;AAAA,EADP,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAhCjB,KAiCD;AAGA;AAAA,EADP,SAAS,EAAE,MAAM,QAAQ,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GAnCjD,KAoCD;AAGA;AAAA,EADP,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GAtClD,KAuCD;AAgDQ;AAAA,EADf,SAAS,EAAE,MAAM,QAAQ,WAAW,OAAO,SAAS,MAAM,CAAC;AAAA,GAtFnD,KAuFO;AAGA;AAAA,EADf,SAAS,EAAE,MAAM,SAAS,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,GAzFlD,KA0FO;AAmCpB,OAAO,iBAAiB,IAAI","sourcesContent":["import {\n type SerializeableObject,\n createCapabilityPath,\n onEnter,\n} from '@telia-ace/alliance-internal-client-utilities';\nimport { LitElement, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { define } from '@/utils';\n\nfunction isOnCurrentPath(path: string = '') {\n const cleanedPath = location.href.replace(location.origin, '');\n return cleanedPath.startsWith(path);\n}\n\nexport class Link extends LitElement {\n constructor() {\n super();\n this.args = {};\n this.download = false;\n this.target = '_self';\n this.href = this._href = '';\n this.capability = 'launch';\n this.active = false;\n }\n\n static styles = css`\n :host {\n display: contents;\n }\n `;\n\n @property({ type: String, attribute: true, reflect: true })\n declare capability: string;\n\n @property({ type: String, attribute: true, reflect: true })\n declare app: string;\n\n @property({ type: Object, attribute: true, reflect: true })\n declare args: SerializeableObject;\n\n /**\n * Link properties\n */\n @property({ type: String, attribute: true, reflect: true })\n declare href?: string;\n\n @property({ type: String })\n declare target?: string;\n\n @property({ type: String, attribute: true, reflect: true })\n declare rel?: string;\n\n @property({ type: Boolean, attribute: true, reflect: true })\n declare download?: boolean;\n\n navigate = () => {\n if (this.active) {\n return;\n }\n\n history.pushState({}, '', this._href);\n window.dispatchEvent(new Event('popstate'));\n };\n\n clickHandler = (event: MouseEvent | KeyboardEvent) => {\n if (!this.app || this.download) {\n return;\n }\n\n event.preventDefault();\n\n this.navigate();\n };\n\n updateActive = () => {\n this.active = isOnCurrentPath(this._href);\n };\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener('popstate', this.updateActive);\n this.computeHref();\n }\n\n disconnectedCallback() {\n window.removeEventListener('popstate', this.updateActive);\n super.disconnectedCallback();\n }\n\n attributeChangedCallback(_1: string, _2: string | null, _3: string | null) {\n super.attributeChangedCallback(_1, _2, _3);\n\n // FUTURE TODO: Try to figure out this timeout is needed\n // Update seems to happen too early if this is not timed\n setTimeout(() => this.computeHref());\n }\n\n /**\n * Internal properties\n */\n @property({ type: String, attribute: false, reflect: false })\n private declare _href: string;\n\n @property({ type: Boolean, attribute: true, reflect: true })\n private declare active: boolean;\n\n private computeHref = () => {\n if (this.app) {\n this._href = this.href = createCapabilityPath(this.app, this.capability, this.args);\n this.updateActive();\n return;\n }\n\n if (this.href) {\n this.capability = '';\n return (this._href = this.href);\n }\n\n throw new Error(\n \"The <alliance-link> component requires either the 'app' property or 'href' property!\",\n );\n };\n\n render() {\n return html`<a\n part=\"anchor\"\n rel=${this.rel}\n .target=${this.target}\n .href=${this._href}\n ?download=${this.download}\n ?active=${this.active}\n @click=${this.clickHandler}\n @keydown=${onEnter(this.clickHandler)}\n >\n <slot></slot>\n </a>`;\n }\n}\n\ndefine('alliance-link', Link);\n"]}
|