@luigi-project/client 2.14.3-dev.202408140027 → 2.14.3-dev.202408140659
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 +51 -54
- package/luigi-client.js +1 -1
- package/luigi-client.js.map +1 -1
- package/luigi-element.d.ts +83 -67
- package/luigi-element.js +2 -158
- package/luigi-element.js.map +1 -0
- package/package.json +1 -1
package/luigi-element.d.ts
CHANGED
|
@@ -1,60 +1,55 @@
|
|
|
1
1
|
// Type definitions for Luigi Client web components
|
|
2
2
|
|
|
3
3
|
export declare interface ConfirmationModalSettings {
|
|
4
|
-
type?: string;
|
|
5
|
-
header?: string;
|
|
6
4
|
body?: string;
|
|
7
5
|
buttonConfirm?: string | boolean;
|
|
8
6
|
buttonDismiss?: string;
|
|
7
|
+
header?: string;
|
|
8
|
+
type?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export declare interface ModalSettings {
|
|
12
|
-
|
|
13
|
-
size?: 'fullscreen' | 'l' | 'm' | 's';
|
|
14
|
-
width?: string;
|
|
12
|
+
closebtn_data_testid?: string;
|
|
15
13
|
height?: string;
|
|
16
14
|
keepPrevious?: boolean;
|
|
17
|
-
|
|
15
|
+
size?: 'fullscreen' | 'l' | 'm' | 's';
|
|
16
|
+
title?: string;
|
|
17
|
+
width?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export declare interface SplitViewSettings {
|
|
21
|
-
title?: string;
|
|
22
|
-
size?: number;
|
|
23
21
|
collapsed?: boolean;
|
|
22
|
+
size?: number;
|
|
23
|
+
title?: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export
|
|
27
|
-
'expand',
|
|
28
|
-
'collapse',
|
|
29
|
-
'resize',
|
|
30
|
-
'close'
|
|
31
|
-
}
|
|
26
|
+
export type SplitViewEvents = 'close' | 'collapse' | 'expand' | 'resize';
|
|
32
27
|
|
|
33
28
|
export declare interface SplitViewInstance {
|
|
34
29
|
collapse: () => void;
|
|
35
|
-
expand: () => void;
|
|
36
|
-
setSize: (value: number) => void;
|
|
37
|
-
on: (key: SplitViewEvents, callback: () => void) => string;
|
|
38
30
|
exists: () => boolean;
|
|
31
|
+
expand: () => void;
|
|
39
32
|
getSize: () => number;
|
|
40
33
|
isCollapsed: () => boolean;
|
|
41
34
|
isExpanded: () => boolean;
|
|
35
|
+
on: (key: SplitViewEvents, callback: () => void) => string;
|
|
36
|
+
setSize: (value: number) => void;
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
export declare interface DrawerSettings {
|
|
45
|
-
header?: any;
|
|
46
|
-
size?: 'l' | 'm' | 's' | 'xs';
|
|
47
40
|
backdrop?: boolean;
|
|
41
|
+
header?: any;
|
|
48
42
|
overlap?: boolean;
|
|
43
|
+
size?: 'l' | 'm' | 's' | 'xs';
|
|
49
44
|
}
|
|
50
45
|
|
|
51
46
|
export declare interface AlertSettings {
|
|
52
|
-
|
|
53
|
-
type: 'info' | 'success' | 'warning' | 'error';
|
|
47
|
+
closeAfter?: number;
|
|
54
48
|
links?: {
|
|
55
49
|
[key: string]: { text: string; url?: string; dismissKey?: string };
|
|
56
50
|
};
|
|
57
|
-
|
|
51
|
+
text?: string;
|
|
52
|
+
type: 'info' | 'success' | 'warning' | 'error';
|
|
58
53
|
}
|
|
59
54
|
|
|
60
55
|
export declare interface NodeParams {
|
|
@@ -338,51 +333,6 @@ export declare interface LinkManager {
|
|
|
338
333
|
hasBack: () => boolean;
|
|
339
334
|
}
|
|
340
335
|
|
|
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
|
-
|
|
386
336
|
export declare interface Options {
|
|
387
337
|
/**
|
|
388
338
|
*
|
|
@@ -466,3 +416,69 @@ export interface LuigiClient {
|
|
|
466
416
|
*/
|
|
467
417
|
getClientPermissions(): () => Object;
|
|
468
418
|
}
|
|
419
|
+
|
|
420
|
+
export 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
|
+
}
|
package/luigi-element.js
CHANGED
|
@@ -1,158 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
}
|
|
1
|
+
var t={d:function(e,i){for(var o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e={};t.d(e,{q:function(){return o},z:function(){return i}});class i extends HTMLElement{constructor(t){super();const e=t.openShadow||!1;this._shadowRoot=this.attachShadow({mode:e?"open":"closed",delegatesFocus:!1}),this.__initialized=!1,this.deferLuigiClientWCInit=t.deferLuigiClientWCInit||!1}__postProcess(t,e,i){var o,n;this.LuigiClient=e,this.context=t;const s=document.createElement("template");s.innerHTML=this.render(t);const r=()=>{if(this.__initialized)return;this._shadowRoot.appendChild(s.content.cloneNode(!0)),Reflect.ownKeys(Reflect.getPrototypeOf(this)).forEach((t=>{"string"==typeof t&&t.startsWith("$_")&&(this._shadowRoot[t]=this[t].bind(this))}));const e=this._shadowRoot.querySelectorAll("[id]");e&&e.forEach((t=>{this["$"+t.getAttribute("id")]=t})),this.afterInit(t),this.__initialized=!0};if(this.luigiConfig&&(null===(o=this.luigiConfig.styleSources)||void 0===o?void 0:o.length)){let t=this.luigiConfig.styleSources.length;const e=this.luigiConfig.loadStylesSync,o=()=>{t--,t<1&&r()};null===(n=this.luigiConfig.styleSources)||void 0===n||n.forEach((t=>{const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",i+t),e&&(n.addEventListener("load",o),n.addEventListener("error",o)),this._shadowRoot.appendChild(n)})),e||r()}else r()}afterInit(t){}render(t){return""}update(){}onContextUpdate(t){}querySelector(t){return this._shadowRoot.querySelector(t)}set context(t){this.__lui_ctx=t,this.__initialized&&(this.onContextUpdate(t),this.attributeChangedCallback())}get context(){return this.__lui_ctx}attributeChangedCallback(t,e,i){this.update()}}function o(t,...e){let i="";return null==t||t.forEach(((t,o)=>{i+=t,o<e.length&&void 0!==e[o]&&null!==e[o]&&(i+=e[o])})),i.replace(/\$\_/gi,"this.getRootNode().$_")}var n=e.z,s=e.q;export{n as LuigiElement,s as html};
|
|
2
|
+
//# sourceMappingURL=luigi-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"luigi-element.js","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,SAASC,EAASC,GACzC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAG3E,ECPAH,EAAwB,SAASS,EAAKC,GAAQ,OAAOL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,EAAO,G,4DCK/F,MAAMI,UAAqBC,YAQhC,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,EAUK,SAASS,EAAKC,KAAkCC,GACrD,IAAIF,EAAe,GAUnB,OARAC,SAAAA,EAAS3B,SAAQ,CAACC,EAAY4B,KAC5BH,GAAQzB,EAEJ4B,EAAQD,EAAKnB,aAA0BqB,IAAhBF,EAAKC,IAAwC,OAAhBD,EAAKC,KAC3DH,GAAQE,EAAKC,GACf,IAGKH,EAAKK,QAAQ,SAAU,wBAChC,C","sources":["webpack://LuigiElement/webpack/bootstrap","webpack://LuigiElement/webpack/runtime/define property getters","webpack://LuigiElement/webpack/runtime/hasOwnProperty shorthand","webpack://LuigiElement/./src/luigi-element.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","import { Options } from '../luigi-element';\n\n/**\n * Base class for Luigi web component micro frontends.\n */\nexport class 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/**\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 */\nexport function 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"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","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":""}
|
package/package.json
CHANGED