Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync LuigiClient API on LuigiElement Typescript declaration with actu… #4055

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 56 additions & 8 deletions client/luigi-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,30 +346,33 @@ export declare interface LinkManager {
*/
getCurrentRoute: () => Promise<string>;
}

export declare class LuigiElement extends HTMLElement {
constructor(options?: Options);

/**
* Override to return the html template string defining the web component view.
*
* @param {*} ctx The context object passed by luigi core
* @param {*} ctx The context object passed by Luigi Core
*/
render(ctx?: Object): string;

/**
* Override to execute logic after an attribute of this web component has changed.
*/
update(): void;

/**
* Override to execute logic when a new context object is set.
*
* @param {*} ctx The new context object passed by luigi core
* @param {*} ctx The new context object passed by Luigi Core
*/
onContextUpdate(ctx: Object): void;

/**
* Override to execute logic after initialization of the web component, i.e.
* after internal rendering and all context data set.
*
* @param {*} ctx The context object passed by luigi core
* @param {*} ctx The context object passed by Luigi Core
*/
afterInit(ctx: Object): void;

Expand All @@ -394,19 +397,18 @@ export declare class LuigiElement extends HTMLElement {

export declare interface Options {
/**
*
*if `true` shadowRoot mode is "open" otherwise shadowRoot mode is "closed".
* if `true` shadowRoot mode is "open" otherwise shadowRoot mode is "closed".
*/
openShadow: boolean;

/**
* if `true` LuigiClient initialization will be defered, until `LuigiClient.luigiClientInit()` will be called.
* if `true` LuigiClient initialization will be deferred, until `LuigiClient.luigiClientInit()` is called.
*/
deferLuigiClientWCInit: boolean;
}

/**
* Html string processing according to luigi functionality.
* Html string processing according to Luigi functionality.
* Also useful in combination with LitElement VS Code plugins.
*
* @param {String} literal The literal to process.
Expand All @@ -420,22 +422,28 @@ export interface LuigiClient {
* @memberof LuigiClient
*/
getActiveFeatureToggles: () => Array<String>;

/**
* Gets the current locale.
* @returns {string} current locale
* @memberof LuigiClient
*/
getCurrentLocale: () => string;

linkManager: () => LinkManager;

uxManager: () => UxManager;

publishEvent: (event: Event) => void;

/**
* Sets node parameters in Luigi Core. The parameters will be added to the URL.
* @param {Object} params
* @param {boolean} keepBrowserHistory
* @memberof LuigiClient
*/
addNodeParams: (params: Object, keepBrowserHistory: boolean) => void;

/**
* Returns the node parameters of the active URL.
* Node parameters are defined like URL query parameters but with a specific prefix allowing Luigi to pass them to the micro frontend view. The default prefix is **~** and you can use it in the following way: `https://my.luigi.app/home/products?~sort=asc&~page=3`.
Expand All @@ -446,18 +454,21 @@ export interface LuigiClient {
* @memberof LuigiClient
*/
getNodeParams: (shouldDesanitise: boolean) => Object;

/**
* Sends anchor to Luigi Core. The anchor will be added to the URL.
* @param {string} anchor
* @memberof LuigiClient
*/
setAnchor: (anchor: string) => void;

/**
* Retrieves the search params from the active URL
* @returns {Object} containing the search params
* @memberof LuigiClient
*/
getCoreSearchParams: () => Object;

/**
* Returns the dynamic path parameters of the active URL.
* Path parameters are defined by navigation nodes with a dynamic **pathSegment** value starting with **:**, such as **productId**.
Expand All @@ -468,10 +479,47 @@ export interface LuigiClient {
* @memberof LuigiClient
*/
getPathParams: () => Object;

/**
* Returns the current client permissions as specified in the navigation node or an empty object. For details, see [Node parameters](navigation-parameters-reference.md).
* @returns {Object} client permissions as specified in the navigation node
* @memberof LuigiClient
*/
getClientPermissions(): () => Object;

/**
* Post-processing actions or data after they've been loaded or updated.
* @memberof LuigiClient
*/
__postProcess: () => void;

/**
* Returns the count of certain attributes or elements, such as number of items.
* @returns {number} attribute count
* @memberof LuigiClient
*/
attCnt: () => number;

/**
* Callback function called after loading or if an error occurs while loading.
* @param {boolean} isError indicates if there was an error
* @memberof LuigiClient
*/
afterLoadOrError: (isError: boolean) => void;

/**
* Callback function that is called when an attribute changes.
* @param {string} name The name of the attribute that changed
* @param {string} oldValue The old value of the attribute
* @param {string} newValue The new value of the attribute
* @memberof LuigiClient
*/
attributeChangedCallback: (name: string, oldValue: string, newValue: string) => void;

/**
* Returns the HTML content or template for rendering.
* @returns {string} HTML content
* @memberof LuigiClient
*/
html: () => string;
}
Loading