import type { CacheOptions, ComponentState } from './types'; /** * @description * Exposes APIs to maintain the state of UI components */ declare class NavigationUtils { #private; userSettings: any; componentCache: { [key: string]: ComponentState; }; contextMapToClearOnCancel: { [context: string]: Set; }; constructor(); /** * This function returns the normalized form for the key * @private * @param key string to normalize * @returns normalized string */ getNormalizedKey(key: string): string; /** * This API updates the state of a specified UI component. The updated state is stored in a browser session. * @description This will save the state in browser session * @param key -- The ID of the UI component whose state must be updated * @param state -- The data that must be set as the state of the UI component * @function * @example In this example, the API updates the state of a UI component whose key is on8ttl-c11n-work-d-2001-caseview. * PCore.getNavigationUtils().setComponentState(key, object) * PCore.getNavigationUtils().setComponentState("on8ttl-c11n-work-d-2001-caseview", { * active: 0 * }); */ setComponentState: (key: string, state: any) => void; /** * This API obtains the state of a specified UI component * @description This API returns the state of the UI component as a Java Script object * @param key -- The ID of the UI component whose state must be retrieved * @returns -- the saved state with the corresponding key
Eg : {active:0} * @function * @example In this example, the API obtains the state of the UI component whose key is on8ttl-c11n-work-d-2001-caseview * PCore.getNavigationUtils().getComponentState(key) * PCore.getNavigationUtils().getComponentState("on8ttl-c11n-work-d-2001-caseview"); */ getComponentState: (key: string) => string | true | object | null; /** * This API remove the state of a specified UI component * @param key -- The ID of the UI component whose state must be removed * @function * @example In this example, the API remove the state of the UI component whose key is on8ttl-c11n-work-d-2001-caseview * PCore.getNavigationUtils().removeComponentState(key) * PCore.getNavigationUtils().removeComponentState("on8ttl-c11n-work-d-2001-caseview") */ removeComponentState: (key: string) => void; /** * This API makes get request to obtain the saved state of the userSettings * @private * @function * @example In this example, the API obtains saved state of the userSettings and saves them in class reference * PCore.getNavigationUtils().fetchUserSettings() */ fetchUserSettings: () => Promise; /** * Initializes the userSettings attribute of the NavigationUtils class. * @function * @example In this example, the API initializes the userSettings attribute of the NavigationUtils class. * PCore.getNavigationUtils().init(); */ init: () => void; /** * This Api obtains the value of a specified property in the userSettings attribute. * @param path -- The location of the property whose value must be obtained. * @returns -- The value of the property from userSettings attribute
Eg : {Case:{summaryPanelExpanded:true}} * @function * @example In this example, the API returns the value of the 'prop1' property in the userSettings attribute. * PCore.getNavigationUtils().getUserSettings('prop1'); */ getUserSettings: (path: string) => any; /** * This API specifies or updates values of properties in the userSettings attribute. * @param path -- The path of the UI component whose state must be updated * @param value -- The value that must be assigned to the property. * @returns -- A promise that resolves to the updated user settings as an object
Eg : new Promise().then((res) => console.log(res)}) * @function * @example In this example, the API sets the value of the 'prop1' property to true in the userSettings attribute. * PCore.getNavigationUtils().setUserSettings('prop1', true); */ setUserSettings: (path: string, value: string) => Promise; /** * This API updates the state of a specified key. The updated state is stored in a cache. * @param key - The key whose state must be updated. The key should be unique across the application. * @param value - The data that must be set as the value for the specified key. * @param options - optional arguments * options.clearOnCancelForContext - context for which the key is associated. * @function * @example In this example, the API updates the value whose key is uniquekeyacrosstheapp' . * PCore.getNavigationUtils().setComponentState(key, object) * PCore.getNavigationUtils().setComponentState("uniquekeyacrosstheapp", { * search: { * filter1: 'name' * }, * { * clearOnCancelForContext: 'app/primary_1/workarea_1 * } * }); */ setComponentCache(key: string, value: ComponentState, options?: CacheOptions): void; /** * This API returns the value of a specified key. * @param key - The key whose value must be returned. * @returns - The value which associated with the key. ComponentState can be string | number | boolean | object | null */ getComponentCache(key: string): ComponentState | void; /** * This API returns the value value of the query param in the URL. * @returns - The the query params of the page URL. */ getURLParam(key: string, decode: boolean): string | null; /** * This API sets the specified query param in the page URL. * @param key - The key whose state must be updated. The key should be unique across the application. * @param value - The data that must be set as the value for the specified key. * @param encode - (optional) If true, the value will be encoded before setting the parameter, otherwise it will be set as is. * @function * @example In this example, the API sets the query param whose key is activeTab' . * PCore.getNavigationUtils().setURLParam(key, object) * PCore.getNavigationUtils().setURLParam("activeTab", "Epics"); */ setURLParam(key: string, value: string, encode?: boolean): void; /** * This API removes the value of the corresponding key from the cache. * @param key The key value state must be removed. * @returns - it returns true if the key is removed from the cache successfully. */ resetComponentCache(key: string): boolean; } declare const _default: NavigationUtils; export default _default;