From aa59cd6fd700ada7cca9babf784da01373d75236 Mon Sep 17 00:00:00 2001 From: Anna Milewska Date: Fri, 6 Dec 2024 08:33:02 +0100 Subject: [PATCH 1/2] Sync LuigiClient API on LuigiElement Typescript declaration with actual implementation --- client/luigi-element.d.ts | 64 ++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/client/luigi-element.d.ts b/client/luigi-element.d.ts index 31fefc3e89..0a25aba4dc 100644 --- a/client/luigi-element.d.ts +++ b/client/luigi-element.d.ts @@ -337,30 +337,33 @@ export declare interface LinkManager { */ hasBack: () => boolean; } - 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; @@ -385,19 +388,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. @@ -411,15 +413,20 @@ export interface LuigiClient { * @memberof LuigiClient */ getActiveFeatureToggles: () => Array; + /** * 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 @@ -427,6 +434,7 @@ export interface LuigiClient { * @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`. @@ -437,18 +445,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**. @@ -459,10 +470,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-processes actions or data after they have 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 method that is triggered after loading or when an error occurs. + * @param {boolean} isError indicates if there was an error + * @memberof LuigiClient + */ + afterLoadOrError: (isError: boolean) => void; + + /** + * Callback function that is triggered 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; } From e43532d0f234f0a2aff6537984f44192601fa768 Mon Sep 17 00:00:00 2001 From: Mahati Shankar Date: Thu, 19 Dec 2024 14:52:04 +0100 Subject: [PATCH 2/2] cosmetics --- client/luigi-element.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/luigi-element.d.ts b/client/luigi-element.d.ts index 0a25aba4dc..ab6344fcb7 100644 --- a/client/luigi-element.d.ts +++ b/client/luigi-element.d.ts @@ -479,7 +479,7 @@ export interface LuigiClient { getClientPermissions(): () => Object; /** - * Post-processes actions or data after they have been loaded or updated. + * Post-processing actions or data after they've been loaded or updated. * @memberof LuigiClient */ __postProcess: () => void; @@ -492,14 +492,14 @@ export interface LuigiClient { attCnt: () => number; /** - * Callback method that is triggered after loading or when an error occurs. + * 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 triggered when an attribute changes. + * 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