@luigi-project/client 2.14.3-dev.20240850849 → 2.14.3-dev.20240870027
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/luigi-client.d.ts +54 -51
- package/luigi-client.js +1 -2
- package/luigi-client.js.map +1 -1
- package/luigi-element.d.ts +67 -94
- package/luigi-element.js +158 -2
- package/package.json +1 -1
- package/luigi-client.js.LICENSE.txt +0 -14
- package/luigi-element.js.map +0 -1
package/luigi-element.d.ts
CHANGED
|
@@ -1,55 +1,60 @@
|
|
|
1
1
|
// Type definitions for Luigi Client web components
|
|
2
2
|
|
|
3
3
|
export declare interface ConfirmationModalSettings {
|
|
4
|
+
type?: string;
|
|
5
|
+
header?: string;
|
|
4
6
|
body?: string;
|
|
5
7
|
buttonConfirm?: string | boolean;
|
|
6
8
|
buttonDismiss?: string;
|
|
7
|
-
header?: string;
|
|
8
|
-
type?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export declare interface ModalSettings {
|
|
12
|
-
closebtn_data_testid?: string;
|
|
13
|
-
height?: string;
|
|
14
|
-
keepPrevious?: boolean;
|
|
15
|
-
size?: 'fullscreen' | 'l' | 'm' | 's';
|
|
16
12
|
title?: string;
|
|
13
|
+
size?: 'fullscreen' | 'l' | 'm' | 's';
|
|
17
14
|
width?: string;
|
|
15
|
+
height?: string;
|
|
16
|
+
keepPrevious?: boolean;
|
|
17
|
+
closebtn_data_testid?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export declare interface SplitViewSettings {
|
|
21
|
-
collapsed?: boolean;
|
|
22
|
-
size?: number;
|
|
23
21
|
title?: string;
|
|
22
|
+
size?: number;
|
|
23
|
+
collapsed?: boolean;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export declare enum SplitViewEvents {
|
|
27
|
+
'expand',
|
|
28
|
+
'collapse',
|
|
29
|
+
'resize',
|
|
30
|
+
'close'
|
|
31
|
+
}
|
|
27
32
|
|
|
28
33
|
export declare interface SplitViewInstance {
|
|
29
34
|
collapse: () => void;
|
|
30
|
-
exists: () => boolean;
|
|
31
35
|
expand: () => void;
|
|
36
|
+
setSize: (value: number) => void;
|
|
37
|
+
on: (key: SplitViewEvents, callback: () => void) => string;
|
|
38
|
+
exists: () => boolean;
|
|
32
39
|
getSize: () => number;
|
|
33
40
|
isCollapsed: () => boolean;
|
|
34
41
|
isExpanded: () => boolean;
|
|
35
|
-
on: (key: SplitViewEvents, callback: () => void) => string;
|
|
36
|
-
setSize: (value: number) => void;
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export declare interface DrawerSettings {
|
|
40
|
-
backdrop?: boolean;
|
|
41
45
|
header?: any;
|
|
42
|
-
overlap?: boolean;
|
|
43
46
|
size?: 'l' | 'm' | 's' | 'xs';
|
|
47
|
+
backdrop?: boolean;
|
|
48
|
+
overlap?: boolean;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export declare interface AlertSettings {
|
|
47
|
-
|
|
52
|
+
text?: string;
|
|
53
|
+
type: 'info' | 'success' | 'warning' | 'error';
|
|
48
54
|
links?: {
|
|
49
55
|
[key: string]: { text: string; url?: string; dismissKey?: string };
|
|
50
56
|
};
|
|
51
|
-
|
|
52
|
-
type: 'info' | 'success' | 'warning' | 'error';
|
|
57
|
+
closeAfter?: number;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
export declare interface NodeParams {
|
|
@@ -333,6 +338,51 @@ export declare interface LinkManager {
|
|
|
333
338
|
hasBack: () => boolean;
|
|
334
339
|
}
|
|
335
340
|
|
|
341
|
+
export declare class LuigiElement extends HTMLElement {
|
|
342
|
+
constructor(options?: Options);
|
|
343
|
+
/**
|
|
344
|
+
* Override to return the html template string defining the web component view.
|
|
345
|
+
*
|
|
346
|
+
* @param {*} ctx The context object passed by luigi core
|
|
347
|
+
*/
|
|
348
|
+
render(ctx?: Object): string;
|
|
349
|
+
/**
|
|
350
|
+
* Override to execute logic after an attribute of this web component has changed.
|
|
351
|
+
*/
|
|
352
|
+
update(): void;
|
|
353
|
+
/**
|
|
354
|
+
* Override to execute logic when a new context object is set.
|
|
355
|
+
*
|
|
356
|
+
* @param {*} ctx The new context object passed by luigi core
|
|
357
|
+
*/
|
|
358
|
+
onContextUpdate(ctx: Object): void;
|
|
359
|
+
/**
|
|
360
|
+
* Override to execute logic after initialization of the web component, i.e.
|
|
361
|
+
* after internal rendering and all context data set.
|
|
362
|
+
*
|
|
363
|
+
* @param {*} ctx The context object passed by luigi core
|
|
364
|
+
*/
|
|
365
|
+
afterInit(ctx: Object): void;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Query selector operating on shadow root.
|
|
369
|
+
*
|
|
370
|
+
* @see ParentNode.querySelector
|
|
371
|
+
*/
|
|
372
|
+
querySelector(selector: string): any;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* LuigiClient instance
|
|
376
|
+
*/
|
|
377
|
+
LuigiClient: LuigiClient;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Context object
|
|
381
|
+
* @returns {Object} context object
|
|
382
|
+
*/
|
|
383
|
+
get context(): Object;
|
|
384
|
+
}
|
|
385
|
+
|
|
336
386
|
export declare interface Options {
|
|
337
387
|
/**
|
|
338
388
|
*
|
|
@@ -416,80 +466,3 @@ export interface LuigiClient {
|
|
|
416
466
|
*/
|
|
417
467
|
getClientPermissions(): () => Object;
|
|
418
468
|
}
|
|
419
|
-
|
|
420
|
-
declare class LuigiElement extends HTMLElement {
|
|
421
|
-
private deferLuigiClientWCInit;
|
|
422
|
-
private LuigiClient;
|
|
423
|
-
private luigiConfig;
|
|
424
|
-
private _shadowRoot;
|
|
425
|
-
private __initialized;
|
|
426
|
-
private __lui_ctx;
|
|
427
|
-
|
|
428
|
-
constructor(options?: Options);
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Invoked by luigi core if present, internal, don't override.
|
|
432
|
-
* @private
|
|
433
|
-
*/
|
|
434
|
-
__postProcess(ctx: Record<string, any>, luigiClient: any, module_location_path: string): void;
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Override to execute logic after initialization of the web component, i.e.
|
|
438
|
-
* after internal rendering and all context data set.
|
|
439
|
-
*
|
|
440
|
-
* @param {*} ctx The context object passed by luigi core
|
|
441
|
-
*/
|
|
442
|
-
afterInit(ctx: Record<string, any>): void;
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Override to return the html template string defining the web component view.
|
|
446
|
-
*
|
|
447
|
-
* @param {*} ctx The context object passed by luigi core
|
|
448
|
-
*/
|
|
449
|
-
render(ctx: Record<string, any>): string;
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Override to execute logic after an attribute of this web component has changed.
|
|
453
|
-
*/
|
|
454
|
-
update(): void;
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Override to execute logic when a new context object is set.
|
|
458
|
-
*
|
|
459
|
-
* @param {*} ctx The new context object passed by luigi core
|
|
460
|
-
*/
|
|
461
|
-
onContextUpdate(ctx: Record<string, any>): void;
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Query selector operating on shadow root.
|
|
465
|
-
*
|
|
466
|
-
* @see ParentNode.querySelector
|
|
467
|
-
*/
|
|
468
|
-
querySelector(selector: string): HTMLElement | null;
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Handles changes on the context property.
|
|
472
|
-
*
|
|
473
|
-
* @private
|
|
474
|
-
*/
|
|
475
|
-
set context(ctx: Record<string, any>);
|
|
476
|
-
get context(): Record<string, any>;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Handles changes on attributes.
|
|
480
|
-
*
|
|
481
|
-
* @private
|
|
482
|
-
*/
|
|
483
|
-
attributeChangedCallback(name?: string, oldVal?: any, newVal?: any): void;
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Html string processing according to luigi functionality.
|
|
487
|
-
* Also useful in combination with LitElement VS Code plugins.
|
|
488
|
-
*
|
|
489
|
-
* @param {String} literal The literal to process.
|
|
490
|
-
* @returns {String} Returns the processed literal.
|
|
491
|
-
*/
|
|
492
|
-
html(literal: TemplateStringsArray, ...keys: unknown[]): string;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
export default LuigiElement;
|
package/luigi-element.js
CHANGED
|
@@ -1,2 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Base class for Luigi web component micro frontends.
|
|
3
|
+
*/
|
|
4
|
+
export class LuigiElement extends HTMLElement {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super();
|
|
7
|
+
const openShadow = options ? options.openShadow : false;
|
|
8
|
+
this._shadowRoot = this.attachShadow({
|
|
9
|
+
mode: openShadow ? 'open' : 'closed',
|
|
10
|
+
delegatesFocus: false
|
|
11
|
+
});
|
|
12
|
+
this.__initialized = false;
|
|
13
|
+
this.deferLuigiClientWCInit = options ? options.deferLuigiClientWCInit : false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Invoked by luigi core if present, internal, don't override.
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
__postProcess(ctx, luigiClient, module_location_path) {
|
|
21
|
+
this.LuigiClient = luigiClient;
|
|
22
|
+
this.context = ctx;
|
|
23
|
+
const template = document.createElement('template');
|
|
24
|
+
template.innerHTML = this.render(ctx);
|
|
25
|
+
const attCnt = () => {
|
|
26
|
+
if (!this.__initialized) {
|
|
27
|
+
this._shadowRoot.appendChild(template.content.cloneNode(true));
|
|
28
|
+
Reflect.ownKeys(Reflect.getPrototypeOf(this)).forEach(el => {
|
|
29
|
+
if (el.startsWith('$_')) {
|
|
30
|
+
this._shadowRoot[el] = this[el].bind(this);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const elementsWithIds = this._shadowRoot.querySelectorAll('[id]');
|
|
34
|
+
if (elementsWithIds) {
|
|
35
|
+
elementsWithIds.forEach(el => {
|
|
36
|
+
this['$' + el.getAttribute('id')] = el;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
this.afterInit(ctx);
|
|
40
|
+
this.__initialized = true;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (this.luigiConfig && this.luigiConfig.styleSources && this.luigiConfig.styleSources.length > 0) {
|
|
44
|
+
let nr_styles = this.luigiConfig.styleSources.length;
|
|
45
|
+
const loadStylesSync = this.luigiConfig.loadStylesSync;
|
|
46
|
+
const afterLoadOrError = () => {
|
|
47
|
+
nr_styles--;
|
|
48
|
+
if (nr_styles < 1) {
|
|
49
|
+
attCnt();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
this.luigiConfig.styleSources.forEach((element, index) => {
|
|
54
|
+
const link = document.createElement('link');
|
|
55
|
+
link.setAttribute('rel', 'stylesheet');
|
|
56
|
+
link.setAttribute('href', module_location_path + element);
|
|
57
|
+
if (loadStylesSync) {
|
|
58
|
+
link.addEventListener('load', afterLoadOrError);
|
|
59
|
+
link.addEventListener('error', afterLoadOrError);
|
|
60
|
+
}
|
|
61
|
+
this._shadowRoot.appendChild(link);
|
|
62
|
+
});
|
|
63
|
+
if (!loadStylesSync) {
|
|
64
|
+
attCnt();
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
attCnt();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Override to execute logic after initialization of the web component, i.e.
|
|
73
|
+
* after internal rendering and all context data set.
|
|
74
|
+
*
|
|
75
|
+
* @param {*} ctx The context object passed by luigi core
|
|
76
|
+
*/
|
|
77
|
+
afterInit(ctx) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Override to return the html template string defining the web component view.
|
|
83
|
+
*
|
|
84
|
+
* @param {*} ctx The context object passed by luigi core
|
|
85
|
+
*/
|
|
86
|
+
render(ctx) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Override to execute logic after an attribute of this web component has changed.
|
|
92
|
+
*/
|
|
93
|
+
update() {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Override to execute logic when a new context object is set.
|
|
99
|
+
*
|
|
100
|
+
* @param {*} ctx The new context object passed by luigi core
|
|
101
|
+
*/
|
|
102
|
+
onContextUpdate(ctx) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Query selector operating on shadow root.
|
|
108
|
+
*
|
|
109
|
+
* @see ParentNode.querySelector
|
|
110
|
+
*/
|
|
111
|
+
querySelector(selector) {
|
|
112
|
+
return this._shadowRoot.querySelector(selector);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Handles changes on the context property.
|
|
117
|
+
*
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
set context(ctx) {
|
|
121
|
+
this.__lui_ctx = ctx;
|
|
122
|
+
if (this.__initialized) {
|
|
123
|
+
this.onContextUpdate(ctx);
|
|
124
|
+
this.attributeChangedCallback();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
get context() {
|
|
129
|
+
return this.__lui_ctx;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Handles changes on attributes.
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
138
|
+
this.update();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Html string processing according to luigi functionality.
|
|
144
|
+
* Also useful in combination with LitElement VS Code plugins.
|
|
145
|
+
*
|
|
146
|
+
* @param {String} literal The literal to process.
|
|
147
|
+
* @returns {String} Returns the processed literal.
|
|
148
|
+
*/
|
|
149
|
+
export function html(literal, ...keys) {
|
|
150
|
+
let html = '';
|
|
151
|
+
literal.forEach((el, index) => {
|
|
152
|
+
html += el;
|
|
153
|
+
if (index < keys.length && keys[index] !== undefined && keys[index] !== null) {
|
|
154
|
+
html += keys[index];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return html.replace(/\$\_/gi, 'this.getRootNode().$_');
|
|
158
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
package/luigi-element.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"luigi-element.js","mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,MAAM,WACT,O,2DCLA,MAAMC,UAAqBC,YAQzB,WAAAC,CAAYC,GACVC,QAEA,MAAMC,EAAsBF,EAAQE,aAAc,EAElDC,KAAKC,YAAcD,KAAKE,aAAa,CACnCC,KAAMJ,EAAa,OAAS,SAC5BK,gBAAgB,IAElBJ,KAAKK,eAAgB,EACrBL,KAAKM,uBAAyBT,EAAQS,yBAA0B,CAClE,CAMA,aAAAC,CAAcC,EAA0BC,EAAkBC,G,QACxDV,KAAKW,YAAcF,EACnBT,KAAKY,QAAUJ,EAEf,MAAMK,EAAgCC,SAASC,cAAc,YAE7DF,EAASG,UAAYhB,KAAKiB,OAAOT,GAEjC,MAAMU,EAAS,KACb,GAAIlB,KAAKK,cACP,OAGFL,KAAKC,YAAYkB,YAAYN,EAASO,QAAQC,WAAU,IACxDC,QAAQC,QAAQD,QAAQE,eAAexB,OAAcyB,SAASC,IAC1C,iBAAPA,GAAmBA,EAAGC,WAAW,QAE1C3B,KAAKC,YAAYyB,GAAM1B,KAAK0B,GAAIE,KAAK5B,MACvC,IAGF,MAAM6B,EAAuC7B,KAAKC,YAAY6B,iBAAiB,QAE3ED,GACFA,EAAgBJ,SAASC,IAEvB1B,KAAK,IAAM0B,EAAGK,aAAa,OAASL,CAAE,IAG1C1B,KAAKgC,UAAUxB,GACfR,KAAKK,eAAgB,CAAI,EAG3B,GAAIL,KAAKiC,cAA+C,QAAhC,EAAAjC,KAAKiC,YAA0B,oBAAC,eAAEC,QAAQ,CAChE,IAAIC,EAAoBnC,KAAKiC,YAA0B,aAAEC,OACzD,MAAME,EAA0BpC,KAAKiC,YAA4B,eAC3DI,EAAmB,KACvBF,IAEIA,EAAY,GACdjB,GACF,EAG8B,QAAhC,EAAAlB,KAAKiC,YAA0B,oBAAC,SAAER,SAASa,IACzC,MAAMC,EAAwBzB,SAASC,cAAc,QAErDwB,EAAKC,aAAa,MAAO,cACzBD,EAAKC,aAAa,OAAQ9B,EAAuB4B,GAE7CF,IACFG,EAAKE,iBAAiB,OAAQJ,GAC9BE,EAAKE,iBAAiB,QAASJ,IAGjCrC,KAAKC,YAAYkB,YAAYoB,EAAK,IAG/BH,GACHlB,GAEJ,MACEA,GAEJ,CAQA,SAAAc,CAAUxB,GAEV,CAOA,MAAAS,CAAOT,GACL,MAAO,EACT,CAKA,MAAAkC,GAEA,CAOA,eAAAC,CAAgBnC,GAEhB,CAQS,aAAAoC,CAAcC,GACrB,OAAO7C,KAAKC,YAAY2C,cAAcC,EACxC,CAOA,WAAIjC,CAAQJ,GACVR,KAAK8C,UAAYtC,EAEbR,KAAKK,gBACPL,KAAK2C,gBAAgBnC,GACrBR,KAAK+C,2BAET,CAEA,WAAInC,GACF,OAAOZ,KAAK8C,SACd,CAOA,wBAAAC,CAAyBC,EAAeC,EAAcC,GACpDlD,KAAK0C,QACP,CASA,IAAAS,CAAKC,KAAkCC,GACrC,IAAIF,EAAe,GAUnB,OARAC,EAAQ3B,SAAQ,CAACC,EAAY4B,KAC3BH,GAAQzB,EAEJ4B,EAAQD,EAAKnB,aAA0BqB,IAAhBF,EAAKC,IAAwC,OAAhBD,EAAKC,KAC3DH,GAAQE,EAAKC,GACf,IAGKH,EAAKK,QAAQ,SAAU,wBAChC,EAGF,UAAe9D,C","sources":["webpack://luigi-client-private/webpack/universalModuleDefinition","webpack://luigi-client-private/./src/luigi-element.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(self, function() {\nreturn ","import { Options } from '../luigi-element';\n\n/**\n * Base class for Luigi web component micro frontends.\n */\nclass LuigiElement extends HTMLElement {\n private deferLuigiClientWCInit: boolean;\n private LuigiClient!: any;\n private luigiConfig!: Record<string, any>;\n private _shadowRoot: ShadowRoot;\n private __initialized: boolean;\n private __lui_ctx!: Record<string, any>;\n\n constructor(options: Options) {\n super();\n\n const openShadow: boolean = options.openShadow || false;\n\n this._shadowRoot = this.attachShadow({\n mode: openShadow ? 'open' : 'closed',\n delegatesFocus: false\n });\n this.__initialized = false;\n this.deferLuigiClientWCInit = options.deferLuigiClientWCInit || false;\n }\n\n /**\n * Invoked by luigi core if present, internal, don't override.\n * @private\n */\n __postProcess(ctx: Record<string, any>, luigiClient: any, module_location_path: string): void {\n this.LuigiClient = luigiClient;\n this.context = ctx;\n\n const template: HTMLTemplateElement = document.createElement('template');\n\n template.innerHTML = this.render(ctx);\n\n const attCnt = (): void => {\n if (this.__initialized) {\n return;\n }\n\n this._shadowRoot.appendChild(template.content.cloneNode(true));\n Reflect.ownKeys(Reflect.getPrototypeOf(this) as any).forEach((el: string | symbol) => {\n if (typeof el === 'string' && el.startsWith('$_')) {\n // @ts-ignore\n this._shadowRoot[el] = this[el].bind(this);\n }\n });\n\n const elementsWithIds: NodeListOf<Element> = this._shadowRoot.querySelectorAll('[id]');\n\n if (elementsWithIds) {\n elementsWithIds.forEach((el: Element) => {\n // @ts-ignore\n this['$' + el.getAttribute('id')] = el;\n });\n }\n this.afterInit(ctx);\n this.__initialized = true;\n };\n\n if (this.luigiConfig && this.luigiConfig['styleSources']?.length) {\n let nr_styles: number = this.luigiConfig['styleSources'].length;\n const loadStylesSync: boolean = this.luigiConfig['loadStylesSync'];\n const afterLoadOrError = (): void => {\n nr_styles--;\n\n if (nr_styles < 1) {\n attCnt();\n }\n };\n\n this.luigiConfig['styleSources']?.forEach((element: string) => {\n const link: HTMLLinkElement = document.createElement('link');\n\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', module_location_path + element);\n\n if (loadStylesSync) {\n link.addEventListener('load', afterLoadOrError);\n link.addEventListener('error', afterLoadOrError);\n }\n\n this._shadowRoot.appendChild(link);\n });\n\n if (!loadStylesSync) {\n attCnt();\n }\n } else {\n attCnt();\n }\n }\n\n /**\n * Override to execute logic after initialization of the web component, i.e.\n * after internal rendering and all context data set.\n *\n * @param {*} ctx The context object passed by luigi core\n */\n afterInit(ctx: Record<string, any>): void {\n return;\n }\n\n /**\n * Override to return the html template string defining the web component view.\n *\n * @param {*} ctx The context object passed by luigi core\n */\n render(ctx: Record<string, any>): string {\n return '';\n }\n\n /**\n * Override to execute logic after an attribute of this web component has changed.\n */\n update(): void {\n return;\n }\n\n /**\n * Override to execute logic when a new context object is set.\n *\n * @param {*} ctx The new context object passed by luigi core\n */\n onContextUpdate(ctx: Record<string, any>): void {\n return;\n }\n\n /**\n * Query selector operating on shadow root.\n *\n * @see ParentNode.querySelector\n */\n // prettier-ignore\n override querySelector(selector: string): HTMLElement | null {\n return this._shadowRoot.querySelector(selector);\n }\n\n /**\n * Handles changes on the context property.\n *\n * @private\n */\n set context(ctx: Record<string, any>) {\n this.__lui_ctx = ctx;\n\n if (this.__initialized) {\n this.onContextUpdate(ctx);\n this.attributeChangedCallback();\n }\n }\n\n get context(): Record<string, any> {\n return this.__lui_ctx;\n }\n\n /**\n * Handles changes on attributes.\n *\n * @private\n */\n attributeChangedCallback(name?: string, oldVal?: any, newVal?: any): void {\n this.update();\n }\n\n /**\n * Html string processing according to luigi functionality.\n * Also useful in combination with LitElement VS Code plugins.\n *\n * @param {String} literal The literal to process.\n * @returns {String} Returns the processed literal.\n */\n html(literal: TemplateStringsArray, ...keys: unknown[]): string {\n let html: string = '';\n\n literal.forEach((el: string, index: number) => {\n html += el;\n\n if (index < keys.length && keys[index] !== undefined && keys[index] !== null) {\n html += keys[index];\n }\n });\n\n return html.replace(/\\$\\_/gi, 'this.getRootNode().$_');\n }\n}\n\nexport default LuigiElement;\n"],"names":["root","factory","exports","module","define","amd","a","i","self","LuigiElement","HTMLElement","constructor","options","super","openShadow","this","_shadowRoot","attachShadow","mode","delegatesFocus","__initialized","deferLuigiClientWCInit","__postProcess","ctx","luigiClient","module_location_path","LuigiClient","context","template","document","createElement","innerHTML","render","attCnt","appendChild","content","cloneNode","Reflect","ownKeys","getPrototypeOf","forEach","el","startsWith","bind","elementsWithIds","querySelectorAll","getAttribute","afterInit","luigiConfig","length","nr_styles","loadStylesSync","afterLoadOrError","element","link","setAttribute","addEventListener","update","onContextUpdate","querySelector","selector","__lui_ctx","attributeChangedCallback","name","oldVal","newVal","html","literal","keys","index","undefined","replace"],"sourceRoot":""}
|