@luigi-project/client 2.32.1-dev.202610210048 → 2.32.1-dev.202610230050
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-element.d.ts +22 -1
- package/luigi-element.js +26 -0
- package/package.json +1 -1
package/luigi-element.d.ts
CHANGED
|
@@ -300,10 +300,11 @@ export declare interface LinkManager {
|
|
|
300
300
|
* @param {boolean} modalSettings.keepPrevious Lets you open multiple modals. Keeps the previously opened modal and allows to open another modal on top of the previous one. By default the previous modals are discarded.
|
|
301
301
|
* @param {string} modalSettings.closebtn_data_testid lets you specify a `data_testid` for the close button. Default value is `lui-modal-index-0`. If multiple modals are opened the index will be increased per modal.
|
|
302
302
|
* @param {Function} onCloseCallback callback function called upon closing the opened modal
|
|
303
|
+
* @returns {promise} which is resolved when closing the modal. By using LuigiClient.linkManager().goBack({ foo: 'bar' }) to close the modal you have access to the `goBackContext` when the promise will be resolved.
|
|
303
304
|
* @example
|
|
304
305
|
* LuigiClient.linkManager().openAsModal('projects/pr1/users', {title:'Users', size:'m'});
|
|
305
306
|
*/
|
|
306
|
-
openAsModal: (nodepath: string, modalSettings?: ModalSettings, onCloseCallback?: Function) =>
|
|
307
|
+
openAsModal: <T = unknown>(nodepath: string, modalSettings?: ModalSettings, onCloseCallback?: Function) => Promise<T>;
|
|
307
308
|
|
|
308
309
|
/**
|
|
309
310
|
* Opens a view in a split view. You can specify the split view's title and size. If you don't specify the title, it is the node label. If there is no node label, the title remains empty. The default size of the split view is 40, which means 40% height of the split view.
|
|
@@ -499,6 +500,26 @@ export declare interface Options {
|
|
|
499
500
|
*/
|
|
500
501
|
export declare const html: (strings: TemplateStringsArray, ...keys: unknown[]) => string;
|
|
501
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Registers a web component that the micro frontend bundle defines itself, making it
|
|
505
|
+
* available to Luigi as a web component micro frontend. Use this when your bundle builds
|
|
506
|
+
* and owns its own custom element class (for example Angular Elements) instead of relying
|
|
507
|
+
* on Luigi to define the element for you.
|
|
508
|
+
*
|
|
509
|
+
* The Luigi Core application must be present on the page. If it is not, an error is logged
|
|
510
|
+
* and the call is a no-op.
|
|
511
|
+
* @param {string} srcString the URL of the web component bundle, which must resolve to the same URL Luigi uses for the node (the node's `viewUrl`). Luigi hex-encodes the resolved absolute URL to derive the custom element id (`luigi-wc-<encoded-url>`) the component is registered under; if `srcString` resolves to a different URL, Luigi registers and looks the element up under different ids and the component never renders. From the bundle registering itself, pass `import.meta.url` (ES module) or `document.currentScript?.src` (classic script), depending on how the bundle is loaded.
|
|
512
|
+
* @param {HTMLElement} element the web component class (custom element constructor) to register
|
|
513
|
+
* @since NEXTRELEASE
|
|
514
|
+
* @example
|
|
515
|
+
* import { registerWebComponent } from '@luigi-project/client/luigi-element.js';
|
|
516
|
+
*
|
|
517
|
+
* export class MyComponent extends LuigiElement { \/* ... *\/ }
|
|
518
|
+
*
|
|
519
|
+
* registerWebComponent(import.meta.url, MyComponent);
|
|
520
|
+
*/
|
|
521
|
+
export declare function registerWebComponent(srcString: string, element: HTMLElement): void;
|
|
522
|
+
|
|
502
523
|
export interface LuigiClient {
|
|
503
524
|
/**
|
|
504
525
|
* @returns {Object} node parameters, where the object property name is the node parameter name without the prefix, and its value is the value of the node parameter. For example `{sort: 'asc', page: 3}`
|
package/luigi-element.js
CHANGED
|
@@ -156,3 +156,29 @@ export function html(literal, ...keys) {
|
|
|
156
156
|
});
|
|
157
157
|
return html.replace(/\$\_/gi, 'this.getRootNode().$_');
|
|
158
158
|
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Registers a web component that the micro frontend bundle defines itself, making it
|
|
162
|
+
* available to Luigi as a web component micro frontend. Use this when your bundle builds
|
|
163
|
+
* and owns its own custom element class (for example Angular Elements) instead of relying
|
|
164
|
+
* on Luigi to define the element for you.
|
|
165
|
+
*
|
|
166
|
+
* The Luigi Core application must be present on the page. If it is not, an error is logged
|
|
167
|
+
* and the call is a no-op.
|
|
168
|
+
* @param {string} srcString the URL of the web component bundle, which must resolve to the same URL Luigi uses for the node (the node's `viewUrl`). Luigi hex-encodes the resolved absolute URL to derive the custom element id (`luigi-wc-<encoded-url>`) the component is registered under; if `srcString` resolves to a different URL, Luigi registers and looks the element up under different ids and the component never renders. From the bundle registering itself, pass `import.meta.url` (ES module) or `document.currentScript?.src` (classic script), depending on how the bundle is loaded.
|
|
169
|
+
* @param {HTMLElement} element the web component class (custom element constructor) to register
|
|
170
|
+
* @since NEXTRELEASE
|
|
171
|
+
* @example
|
|
172
|
+
* import { registerWebComponent } from '@luigi-project/client/luigi-element.js';
|
|
173
|
+
*
|
|
174
|
+
* export class MyComponent extends LuigiElement { \/* ... *\/ }
|
|
175
|
+
*
|
|
176
|
+
* registerWebComponent(import.meta.url, MyComponent);
|
|
177
|
+
*/
|
|
178
|
+
export function registerWebComponent(srcString, element) {
|
|
179
|
+
if (!window.Luigi) {
|
|
180
|
+
console.error('Error registering web component, Luigi core app not present.');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
window.Luigi._registerWebcomponent(srcString, element);
|
|
184
|
+
}
|
package/package.json
CHANGED