import { AsDictionary, Dictionary } from '../types/dictionaries'; import { Enum } from '../types/enums'; import { ValueNamePair } from '../types/valueNamePair'; /** * Reverse current string and returns new reverse string * @param str - String to be reversed * @returns string Reverse string */ export declare function reverseString(str: string): string; /** * Generates random string consisting from lowercase letters * @param length - Length of generated string * @returns number Generated string */ export declare function generateId(length: number): string; /** * Generates random string of specified length from possible characters * @param length - Length of generated string * @param possible - Possible characters used for generation of string */ export declare function generateRandomString(length: number, possible?: string): string; /** * Converts string in that way that first letter will be lowerCase * @param text - Text to be converted */ export declare function firstToLowerCase(text: string): string; /** * Gets indication whether is child descendand of parent * @param parent - Parent to be tested * @param child - Child to be looked for */ export declare function isDescendant(parent: HTMLElement, child: HTMLElement): boolean; /** * Computes offset of element against document * @param element - Html element which offset is counted * @param doc - Html document to be used for extracting scroll offset */ export declare function offset(element: HTMLElement, doc?: Document): { top: number; left: number; bottom: number; right: number; }; /** * Converts html string into html DOM * @param html - Html string to be converted to DOM * @param doc - Optional html document to be used */ export declare function htmlToElement(html: string, doc?: Document): HTMLElement; /** * Extract values from enum type * @param enumType - Enum type that will have extracted values */ export declare function getEnumValues(enumType: TEnum): ValueNamePair[]; /** * Safely returns value from object property using string expression * @param object - Object which property value will be obtained * @param expression - Expression for obtaining value */ export declare function getValue(object: Record, expression: string): TValue; /** * Sets value to objects property using string expression * @param object - Object which property value will be set * @param value - Value that will be set * @param expression - Expression for setting value */ export declare function setValue(object: Dictionary, value: unknown, expression: string): void; /** * Formats string using '%s', to print '%s' you have to use '%%s' * @param str - String containing substitution constants * @param args - Arguments that are used for replacement */ export declare function format(str: string, ...args: unknown[]): string; /** * Performs flatMap over provided array * @param array - Array to be reduced using flatMap */ export declare function flatMapArray(array: TItem[][]): TItem[]; /** * Serialize object to string that is usable as url query parameter * @param obj - Object to be serialized * @param replacer - Function that can be used for replacing provided values */ export declare function serializeToUrlQuery(obj: TObj, replacer?: (this: any, key: string, value: any) => any): string; /** * Deserialize value from url query string into object * @param queryParamValue - Query param string value * @param reviver - Function that can be used for correctly deserializing value */ export declare function deserializeFromUrlQuery(queryParamValue: string, reviver?: (this: any, key: string, value: any) => any): TObj; /** * Converts id to valid html id * @param id - Id that is going to be converted to valid html id */ export declare function validHtmlId(id: string): string; /** * Checks whether is element overflown either horizontal, or vertical * @param element - Element to be tested for overflow */ export declare function isOverflown(element: HTMLElement): boolean; /** * Normalizes string, removing accent * @param value - String to be normalized */ export declare function normalizeAccent(value: string): string; /** * Converts instance of Class to equivalent Record type * @param instance - Instance which type to be converted * @typeparam TType - Type of instance */ export declare function asDictionary(instance: TType): AsDictionary; /** * Maps all iterable property values of object to "this" bounded * @param this - Object which will be filled with new values * @param value - Object holding values that will be used for filling * @param all - Indication whether map only existing properties or everything */ export declare function mapValuesToThis(this: Dictionary, value: Dictionary | undefined | null, all?: boolean): void; /** * Briefly shows simple notification with simple text * @param show - Indication whether show notification * @param text - Text to be displayed, defaults to HMR finished text */ export declare function simpleNotification(show: boolean, text?: string): void; /** * Transforms any string to colour code * @param str - String to be changed to colour code */ export declare function stringToColour(str: string): string; /** * Renders element into body directly or into container element * @param document - Html document instance * @param element - Html element that will be rendered * @param containerElementSelector - Css selector for container element, if not specified renders into body, css selector must contain element name and optionally css classes */ export declare function renderToBody(document: Document, element: HTMLElement, containerElementSelector?: string | null): void; /** * Formats input string using no parameters, returns original input * @param input - Input that will be formatted */ export declare function formatString(input: string | undefined | null, parameter?: null): string; /** * Formats input string using object holding formatting parameters * @param input - Input that will be formatted * @param parameter - Parameter as object which properties will be used for formatting * * ``` * formatString('test {{val}}, {{test}} {{test.num}} {{@test}}, {{@(2)test}} {{@test.bool}}', {val: 3, test: {bool: true, num: 10}}); * ``` * * displays `{{val}}` as direct stringified value of '`val`' property * displays `{{test}}` as direct strinfigied value of '`test`' property * displays `{{test.num}}` as direct strinfigied value of '`test`' property and its subproperty '`num`' * displays `{{@test}}` as JSON strinfigied value of '`test`' property * displays `{{@(2)test}}` as JSON stringified value of '`test`' property with 2 spaces indentation (other supported spaces are 4 and 8) * displays `{{@test.bool}}` as JSON stringified value of '`test`' property and its subproperty '`bool`' */ export declare function formatString(input: string | undefined | null, parameter: Record): string; /** * Formats input string using array holding formatting parameters * @param input - Input that will be formatted * @param parameter - Parameter as array which items will be used for formatting * * ``` * formatString('test {{0}}, {{@1}}, {{@(2)1}}', [3, {bool: true, num: 10}]) * ``` * * displays `{{0}}` as direct stringified value of '`0`' index item * displays `{{@1}}` as JSON strinfigied value of '`0`' index item * displays `{{@(2)1}}` as JSON stringified value of '`0`' index item with 2 spaces indentation (other supported spaces are 4 and 8) */ export declare function formatString(input: string | undefined | null, ...parameters: unknown[]): string; /** * Tests whether is element input type checkbox * @param element - Element to be tested */ export declare function isCheckbox(element: EventTarget): element is HTMLInputElement; /** * Tests whether is element input type radio * @param element - Element to be tested */ export declare function isRadio(element: EventTarget): element is HTMLInputElement; /** * Tests whether is element input * @param element - Element to be tested */ export declare function isInput(element: EventTarget): element is HTMLInputElement; /** * Tests whether is element select * @param element - Element to be tested */ export declare function isSelect(element: EventTarget): element is HTMLSelectElement; /** * Tests whether is element button * @param element - Element to be tested */ export declare function isButton(element: EventTarget): element is HTMLButtonElement; /** * Tests whether is element anchor * @param element - Element to be tested */ export declare function isAnchor(element: EventTarget): element is HTMLAnchorElement; //# sourceMappingURL=common.d.ts.map