@omnia/fx
Version:
Provide Omnia Fx typings and tooling for clientside Omnia development.
172 lines (171 loc) • 7.09 kB
TypeScript
import { FirstDayOfWeeks, GuidValue, IIcon, TenantRegionalSettings, TimePeriodSettings } from "../../models";
export declare module Utils {
function isNativeClass(value: any): boolean;
function asyncForEach<T>(array: Array<T>, callback: (item: T, index?: number, items?: Array<T>) => Promise<void>): Promise<void>;
function isPromise(val: any): boolean;
function isString(target: any): boolean;
function isNumber(target: any): boolean;
/**
* Check if object is null or undefined
*/
function isNull(obj: any): boolean;
/**
* Check if object is null or undefined or empty
*/
function isNullOrEmpty(obj: any): boolean;
/**
* Check if array is null or undefined or empty
*/
function isArrayNullOrEmpty(obj: any): boolean;
/**
* Determine whether the argument is an array.
*
* @param obj Object to test whether or not it is an array.
*/
function isArray(obj: any): boolean;
/**
* Check if is type of a function
* @param obj Object to test whether or not it is an function.
*/
function isFunction(obj: any): boolean;
/**
* Check if is type of a Object
* @param obj Object to test whether or not it is an function.
*/
function isObject(obj: any): boolean;
/**
* Check if is type of a boolean
* @param obj Object to test whether or not it is an function.
*/
function isBoolean(obj: any): boolean;
/**
* Generate a new guid
*/
function generateGuid(): string;
/**
* Validate guid value
*/
function isValidGuid(value: string): boolean;
/**
* Scheck a guid whether or not it is a empty guid
*/
function isEmptyGuid(guid: string): boolean;
/**@deprecated This will be removed in Omnia 7.0. Use @prop {OmniaEnvironmentContext.isBackendSharePointServer}*/
function isOnPrem(backendRuntime: string): boolean;
/**@deprecated This will be removed in Omnia 7.0. Use @prop {OmniaEnvironmentContext.isBackendM365} */
function isOnline(backendRuntime: string): boolean;
function groupBy<T>(collection: Array<T>, propName: string): Array<{
key: any;
items: Array<T>;
}>;
/**
* Find first element in array [items] with property [prop] with value equal to [value]
*/
function getElementWith<T>(items: Array<T>, prop: string, value: any): T;
/**
* Set a timer with an ID. Reset the timer if timewatch is called again with the same ID before the timer has triggered.
*/
function timewatch(id: string, callback: () => any, ms: number): any;
function clearTimewatch(id: number): void;
/**
* Set a timer with an ID. If timebox is called again with the same ID before the timer has triggered, don't do anything. Otherwise, set a new timer with that ID.
*/
function timebox(id: string, callback: () => any, ms: number): void;
/**
* convert a string to a friendly url string
*/
function makeFriendlyUrl(str: string, collapseAndTrimDashes?: boolean, whiteSpaceChar?: string): string;
function getSocialDate(utcDate: Date | string, locale?: string): string;
function getDayjsLocale(locale?: string): string;
function clone<T extends I, I>(obj: I): T;
function castToBoolean(obj: any): boolean;
function fixUrl(url: string): string;
function castToInt(obj: any): number;
function getUrlParts(url: any): {
href: string;
host: string;
hostname: string;
port: string;
pathname: string;
protocol: string;
hash: string;
search: string;
};
function trimStart(str: string, chr: string): string;
function trimEnd(str: string, chr: string): string;
function after(timePeriodSettings: TimePeriodSettings, date?: Date): Date;
function before(timePeriodSettings: TimePeriodSettings, date?: Date): Date;
function getScrollParent(node: any): any;
function throttle(func: any, wait: any, options: any): () => any;
/**
* Convert object keys/ string to camle cases
*/
function toCamelCase(object: any): any;
function waitForElementAvailable(el: Element, elementId: string, callBack: () => void): void;
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are **not** supported.
*
* @category Lang
* @param value The value to compare.
* @param other The other value to compare.
* @returns Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'user': 'fred' };
* var other = { 'user': 'fred' };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
function isEqual(value: any, other: any): any;
function safeStringify(value: any): string;
function getFileType(fileName: string): string;
function isImageFormatSupportForMediaPicker(fileName: string): boolean;
function ensureDateTimeFormat(regionalSettings: TenantRegionalSettings): {
dateFormat: string;
timeFormat: string;
};
function formatDateTime(regionalSettings: TenantRegionalSettings, date?: Date | string): string;
function getVuetifyFirstDayOfWeek(value: FirstDayOfWeeks): 0 | 1;
function removeClaimPrefixFromLoginName(loginName: string): string;
function getManifestIdByElementName(elementName: string): GuidValue;
/**
* Get profile url for online and other environment like sharepoint server
* online : https://delve.office.com/?u=${id}
* onprem : mysiteurl + /Person.aspx?accountname=accountName
* */
function getProfileUrl(uid: string): string;
function getOfficeAppURI(fileUrl: string, extension: string): string;
function getFileExtensionByFileUrl(url: string): string;
function trapFocus(kevent: KeyboardEvent, anchors: {
start: HTMLElement;
end: HTMLElement;
}, container: HTMLElement): void;
function truncate(str: string, n: number, useWordBoundary: boolean): string;
/**
* Check if icon is null or undefined or empty
*/
function hasIcon(icon: IIcon): boolean;
function isUriScheme(url: string): boolean;
function convertDateToGMT(val: Date): Date;
function covertDateToLocalTimeZone(val: Date): Date;
function convertStringToArray(object: any): any;
/**
* Support accessibility alert after search completion: Replace message after search
*/
function supportSearchCompletedAlert(hiddenSearchAlertId: string, message: string): void;
/**
* Support accessibility alert after search completion: Get hidden alert id based on componentId
*/
function getHiddenSearchAlertId(componentId: string): string;
}