@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
119 lines (118 loc) • 4.51 kB
TypeScript
import { Hole } from 'uhtml';
import ConfigManager from '../tools/configuration/configmanager';
import StateManager, { Callback } from '../tools/state/statemanager';
import ComponentManager from '../tools/state/componentManager';
import UserInteractionManager from '../tools/state/userInteractionManager';
import { GgUserInteractionEvent } from '../tools/state/userinteractionevent';
declare class GirafeHTMLElement extends HTMLElement {
templateUrl: string | null;
styleUrl: string | null;
template: Hole | (() => Hole);
name: string;
shadow: ShadowRoot;
displayStyle?: string;
timeoutId?: NodeJS.Timeout;
rendered: boolean;
callbacks: Callback[];
configManager: ConfigManager;
stateManager: StateManager;
componentManager: ComponentManager;
userInteractionManager: UserInteractionManager;
private readonly unsafeCache;
constructor(name: string);
get state(): import("../tools/main").State;
getById<T = HTMLElement>(id: string): T;
loadConfig(): Promise<void>;
girafeTranslate(): void;
userInfoChanged(): void;
/**
* NOTE REG: We cannot just use truthy here, because javascript comparaison table is really problematic.
* For example:
* 0 == false
* [] == false
* "" == false
* And there are cases where we want to check null or undefined, because 0 can be a right value.
* More here : https://dorey.github.io/JavaScript-Equality-Table/
* @param val
* @returns
*/
isNullOrUndefined(val: unknown): boolean;
isNullOrUndefinedOrBlank(val: unknown): boolean;
getParentOfType(parentNodeName: string, elem: Node | null, initialElem?: Node | null): Node | null;
/**
* Render the component's template.
*/
render(): void;
/**
* Re-Render the component.
* The method should be called when the component
* has already been rendered and needs to be updated.
*/
refreshRender(): void;
/**
* Renders a hidden span with the name of the component.
* Useful to render a placeholder for not visible component.
*/
renderEmpty(): void;
/**
* Convert the string in parameter with uHtml and return it.
* This allows to convert a string with html in a right html object.
* For example, htmlUnsafe('<div></div>') will return an html div object.
*/
htmlUnsafe(str: string): Hole;
/**
* Convert a string to TemplateStringsArray
* Manage a cache of all the created objects to limit memory usage
*/
private getUnsafeTemplate;
/**
* Remember the initial display configuration of the component
* To be able to restore it
*/
private defineDisplayStyle;
/**
* In the templates, sometimes for accessibility reasons, we have to support the KeyDown Event
* In those case, we often juste want to do the same as the click event when Enter or Space is pressed
* Then this method can be used : it just calls the click event on the same element
*/
simulateClick(e: KeyboardEvent): void;
/**
* Hide the component (display: none).
*/
hide(): void;
/**
* Show the component (display: block).
*/
show(): void;
/**
* Returns the serialization of the current element. This method should be
* overwritten by child classes
* @returns An object describing the current element serialized
*/
serialize(): {};
/**
* Deserialize an element and set the current element state to the deserialized one
* @param _serializedElement The element serialization as returned by the serialize method
*/
deserialize(_serializedElement: unknown): void;
/**
* Subscribes with <callback> to the state changes made on <path>
*/
subscribe(path: string, callback: Callback): Callback;
subscribe(path: RegExp, callback: Callback): Callback;
/**
*
* @param callback Unsubscribe all callbacks
*/
unsubscribe(callback: Callback): void;
unsubscribe(callbacks: Callback[]): void;
/**
* When the component is disconnected from the DOM
* all the callbacks will be unregistered
*/
disconnectedCallback(): void;
registerInteractionListener(eventName: GgUserInteractionEvent, isExclusive: boolean): boolean;
unregisterInteractionListeners(eventNames?: GgUserInteractionEvent | GgUserInteractionEvent[]): void;
canExecute(eventName: GgUserInteractionEvent): boolean;
}
export default GirafeHTMLElement;