UNPKG

@synebo/lightning-types

Version:
1,400 lines (1,364 loc) 54.9 kB
declare module Aura { type EventPhase = 'capture' | 'bubble' | 'default'; interface Component { addEventHandler: ( event: string, handler: ( ...args: any ) => void, phase: EventPhase, includeFacets?: boolean ) => void; addHandler: () => void; addValueHandler: ( config: { event: string; action: string } ) => void; addValueProvider: ( key: string, valueProvider: any ) => void; autoDestroy: ( destroy: boolean ) => void; clearReference: ( key: string ) => void; destroy: () => void; find: ( name: string | any ) => Component | Component[]; get: ( name: string ) => ComponentAction | any; getConcreteComponent: () => Component; getElement: () => HTMLElement; getElements: () => HTMLElement[]; getEvent: ( name: string ) => ComponentEvent; getGlobalId: () => string; getLocalId: () => string; getName: () => string; getReference: ( key: string ) => any; getSuper: () => Component; getType: () => string; getVersion: () => string; isConcrete: () => boolean; isInstanceOf: ( name: string ) => boolean; isRendered: () => boolean; isValid: () => boolean; removeEventHandler: ( event: string, handler: ( ...args ) => void, phase?: EventPhase ) => void; set: ( key: string, value: any ) => void; superAfterRender: () => void; superRender: () => any; superRerender: () => void; superUnrender: () => void; [ key: string ]: any; } interface PrechatField { name: string; value: any; label: string; className?: string; maxLength?: number; readOnly?: boolean; required?: boolean; type?: string; } interface PrechatApiComponent<C = Component> extends Component { startChat: ( fields: PrechatField[] ) => void; validateFields: ( fields: PrechatField[] ) => any; getPrechatFields: () => PrechatField[]; } type MinimizedApiEventReason = | 'agentEndedChat' | 'agentsUnavailable' | 'visitorEndedChat' | 'visitorConnectionError' | 'visitorTimeout' | 'visitorBlocked' | 'connectionError'; interface MinimizedApiEventData { label: string; queuePosition?: number; agentName?: string; agentType?: 'agent' | 'chatbot'; labelAssistiveText?: string; isAgentJoining?: boolean; agentsInChat?: string[]; timeoutSecondsRemaining?: number; reason?: MinimizedApiEventReason; unreadMessageCount?: number; } type MinimizedApiEventName = | 'offlineSupportState' | 'prechatState' | 'waitingState' | 'queueUpdate' | 'waitingEndedState' | 'chatState' | 'chatConferenceState' | 'chatTimeoutUpdate' | 'chatUnreadMessage' | 'chatTransferringState' | 'chatEndedState' | 'reconnectingState' | 'postchatState'; interface MinimizedApiComponent<C = Component> extends Component { registerEventHandler: ( eventHandlerFunction: ( cmp?: C, eventName?: MinimizedApiEventName, eventData?: MinimizedApiEventData ) => void ) => void; maximize: () => void; } interface FlowComponent extends Component { startFlow: ( flowName: string, inputVariables?: FlowInputVariable[] ) => void; resumeFlow: ( interviewId: string ) => void; } interface FlowOutputVariable { dataType: 'STRING' | 'SOBJECT' | any; flowName: string; isCollection: boolean; name: string; objectType: string; value: any; } interface FlowInputVariable { name: string; type: string; value: any; } interface FlowStatusChange { activeStages: any[]; currentStage: any; flowTitle: string; helpText: string; guid: string; outputVariables: FlowOutputVariable[]; status: 'STARTED' | 'PAUSED' | 'FINISHED' | 'FINISHED_SCREEN' | 'ERROR'; } interface ComponentRenderer<H = any> extends Component { render: ( cmp: Component, helper: H ) => any; rerender: ( cmp: Component, helper: H ) => void; afterRender: ( cmp: Component, helper: H ) => void; unrender: ( cmp: Component, helper: H ) => void; } interface ComponentEvent { fire: ( params?: any ) => void; getEventType: () => string; getName: () => string; getParam: ( name: string ) => any; getParams: () => any; getPhase: () => EventPhase; getSource: () => Component; getSourceEvent: () => any; getType: () => string; pause: () => void; preventDefault: () => void; resume: () => void; setParam: ( name: string, value: any ) => void; setParams: ( params: any ) => void; stopPropagation: () => void; } interface ComponentActionResult { getState: () => 'SUCCESS' | 'ERROR'; getReturnValue: () => any; getError: () => any; } interface ComponentAction { getCallback: () => void; getError: () => any[]; getName: () => string; getParam: ( name: string ) => any; getParams: () => any; getReturnValue: () => any; getState: () => string; isBackground: () => boolean; setAbortable: () => void; setBackground: () => void; setCallback: ( scope: any, callback: ( resutl: ComponentActionResult ) => any, name?: string ) => void; setParam: ( key: string, value: any ) => void; setParams: ( params: any ) => void; setStorable: ( config?: any ) => void; } interface WeekName { fullName: string; shortName: string; } interface MonthName { fullName: string; shortName: string; } interface $Locale { country: string; currency: string; currencyCode: string; currencyFormat: string; dateFormat: string; datetimeFormat: string; decimal: string; dir: string; firstDayOfWeek: number; grouping: string; isEasternNameStyle: boolean; labelForToday: string; lang: string; langLocale: string; language: string; longDateFormat: string; nameOfMonths: MonthName[]; nameOfWeekdays: WeekName[]; numberFormat: string; percentFormat: string; shortDateFormat: string; shortDatetimeFormat: string; timeFormat: string; timezone: string; userLocaleCountry: string; userLocaleLang: string; variant: string; zero: string; } interface OverlayModalParams { header?: any; body?: any; footer?: any; showCloseButton?: boolean; cssClass?: string; closeCallback?: () => void; } interface OverlayPopoverParams { body: any; referenceSelector: any; cssClass: string; } interface OverlayRef { close: () => void; show: () => void; hide: () => void; isVisible: () => boolean; } interface OverlayLib extends Component { /** * @description * Displays a modal with a message. * @param {OverlayModalParams} modalParams * @returns {Promise} */ showCustomModal: ( modalParams: OverlayModalParams ) => Promise<OverlayRef>; /** * @description * Displays a popover with a message. * @param {OverlayPopoverParams} popoverParams * @returns {Promise} */ showCustomPopover: ( popoverParams: OverlayPopoverParams ) => Promise<OverlayRef>; /** * @description * Dismisses and destroys the modal or popover. */ notifyClose: () => void; } /** * @description * Util methods provide utility functions for browsers in addition to * functions for retrieving, manipulating, or checking DOM elements. * @constructor * @platform * @export */ class Util { /** * Adds a CSS class to a component. * * @example * //find a component with aura:id="myCmp" in markup * var myCmp = component.find("myCmp"); * $A.util.addClass(myCmp, "myClass"); * * @param {Object} element The component to apply the class on. * @param {String} newClass The CSS class to be applied. * @export * @platform */ addClass: ( element: Component, className: string ) => void; /** * Checks whether the component has the specified CSS class. * * @example * //find a component with aura:id="myCmp" in markup * var myCmp = component.find("myCmp"); * $A.util.hasClass(myCmp, "myClass"); * * @param {Object} element The component to check. * @param {String} className The CSS class name to check for. * @returns {Boolean} True if the specified class is found for the component, or false otherwise. * @export * @platform * */ hasClass: ( element: Component, className: string ) => boolean; /** * Removes a CSS class from a component. * * @example * //find a component with aura:id="myCmp" in markup * var myCmp = component.find("myCmp"); * $A.util.removeClass(myCmp, "myClass"); * * @param {Object} element The component to remove the class from. * @param {String} newClass The CSS class to be removed from the element. * @export * @platform * */ removeClass: ( element: Component, className: string ) => void; /** * Toggles (adds or removes) a CSS class from a component. * * @example * //find a component with aura:id="toggleMe" in markup * var toggleText = component.find("toggleMe"); * $A.util.toggleClass(toggleText, "toggle"); * * @param {Object} element The component to add or remove the class from. * @param {String} className The CSS class to be added or removed. * @export * @platform * */ toggleClass: ( element: Component, className: string ) => void; /** * Swaps an element's class by removing the selected class and adding another in its place. * * @param {Object} element The element to be processed. * @param {String} oldClass The class to remove from the element. * @param {String} newClass The class to add to the element. * @export */ swapClass: ( element: Component, oldClass: string, newClass: string ) => void; /** * Builds the appropriate css class name for a flavor. * * @param {Object} cmp The DefDescriptor of the component being flavored. * @returns {String} flavor The flavor name. * @export */ buildFlavorClass: ( element: Component, flavor: string ) => string; /** * Coerces truthy and falsy values into native booleans * * @param {Object} val The object to check. * @returns {Boolean} True if the object is truthy, or false otherwise. * @platform * @function * @export */ getBooleanValue: ( val: any ) => boolean; /** * Checks whether the specified object is an array. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is an array, or false otherwise. * @function * @platform * @export */ isArray: ( obj: any ) => boolean; /** * Checks if the object is empty. * An empty object's value is undefined, null, an empty array, or empty string. An object with no native * properties is not considered empty. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is empty, or false otherwise. * @platform * @export */ isEmpty: ( obj: any ) => boolean; /** * Checks whether the specified object is a valid object. * A valid object: Is not a DOM element, is not a native browser class (XMLHttpRequest) * is not falsey, and is not an array, error, function string or number. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is a valid object, or false otherwise. * @function * @platform * @export */ isObject: ( obj: any ) => boolean; /** * Checks whether the specified value is a plain object. * Plain objects are created using "{}" or "new Object()". * * NOTE: This will work for non-object values since their toString output is (e.g.) "[object Null]", * but callers should ideally perform typeof/null checks first in order to avoid the performance * cost of calling Object.prototype.toString() on non-object values. * * @param {Any} o The value to check. * @returns {Boolean} True if the value is a plain object, or false otherwise. * @export */ isPlainObject: ( o: any ) => boolean; /** * Checks whether the specified object is a valid error. * A valid error: Is not a DOM element, native browser class (XMLHttpRequest), falsey, * array, function string or number. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is a valid error, or false otherwise. * @export */ isError: ( obj: any ) => boolean; /** * Checks whether the specified object is a valid function. * A valid function: Is not a DOM element, native browser class (XMLHttpRequest), falsey, * array, error, or number. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is a valid function, or false otherwise. * @export */ isFunction: ( obj: any ) => boolean; /** * Checks if the object is of type string. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is of type string, or false otherwise. * @export */ isString: ( obj: any ) => boolean; /** * Checks if the object is of type number. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is of type number, or false otherwise. * @export */ isNumber: ( obj: any ) => boolean; /** * Checks if the object is a finite number (not NaN or Infinity or -Infinity) * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is a finite number, or false otherwise. * @export */ isFiniteNumber: ( obj: any ) => boolean; /** * Checks if the object is of type boolean. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object is of type boolean, or false otherwise. * @export */ isBoolean: ( obj: any ) => boolean; /** * Checks if the object is undefined. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is undefined, or false otherwise. * @export * @platform */ isUndefined: ( obj: any ) => boolean; /** * Checks if the object is undefined or null. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is undefined or null, or return false otherwise. * @export * @platform */ isUndefinedOrNull: ( obj: any ) => boolean; /** * Creates and returns an HTML element of the specified tag name and map of attributes. * * @param {String} tagName Tag name of the html element to create (e.g. 'a', 'img', 'div'). * @param {Map} attributes A map of attributes that the element will have * (e.g. {src: 'foo.img', alt: 'Some text'} * @returns (HTMLElement) the newly created element */ createHtmlElement: ( tagName: string, attributes?: Object ) => HTMLElement; /** * Removes all children of a node, effectively clearing its body. * * @param {HTMLElement} node The node to be cleared. * @export */ clearNode: ( node: HTMLElement ) => void; /** * Generates dom nodes from string markup * * @param {String} markup The markup from which to generate dom nodes * @returns {Array} An array of the elements that were generated. */ createElementsFromMarkup: ( markup: string ) => NodeList; /** * Inserts element(s) as the first child of the parent element. * * @param {Object} newE1 The new element to insert. * @param {Object} referenceE1 The reference element * @returns {Object} The element that was inserted. */ insertFirst: ( newEl, referenceEl ) => void; /** * Inserts a new element, newEl, directly before the reference element, referenceEl. * If the reference element is a parent node, insert the new element directly before the parent node. * * @param {Object} newE1 The new element to insert. * @param {Object} referenceE1 The reference element * @returns {Object} The element that was inserted. */ insertBefore: ( newEl, referenceEl ) => void; /** * Inserts a new element, newEl, directly after the reference element, referenceEl. * If the reference element is a parent node, insert the new element directly after the parent node. * * @param {Object} newE1 The new element to insert. * @param {Object} referenceE1 The reference element * @returns {Object} The element that was inserted. */ insertAfter: ( newEl, referenceEl ) => void; /** * Adds a new element to the end of the reference element. Does not work if the canHaveChildren property on the reference element is false. * * @param {Object} newE1 The element to append as a child of the reference element. * @param {Object} referenceE1 The existing element * @returns {Object} The new element that was added */ appendChild: ( newE1, referenceE1 ) => void; /** * Removes the specified element from the DOM. * * Use this method with caution. Since we hijack the normal delete * functionality, we need to be careful of odd event processing. Specifically * we end up sending off some events that would not otherwise be sent. * * Also note that we currently remove nodes children first, which means we * deconstruct our tree from the bottom up. If we reverse this, we might be * able to add optimizations. * * @param {Object} element The element to be removed. */ removeElement: ( element ) => void; /** * Manipulate the properties of the querystring portion of a url. * @param {String} url Any url to manipulate, if it doesn't have a question mark in it. Any hash remains not affected. * @param {Object} params Map of key->value's to set in the url. Set key to null to remove it from the url. * @param {Boolean} encoded True if params are alredy encoded and prevent re-encoding. * @export */ generateUrl: ( url: string, params: any, encoded: boolean ) => string; /** * Trims a string by removing newlines, spaces, and tabs from the beginning and end of the string. * * @param {String} value The string to be trimmed. * @returns {String} * @export */ trim: ( value: string ) => string; /** * Formats an arbitrary number of arguments into a string by replacing {0}, {1}, ... {n} with the corresponding argument supplied after 'formatString'. * * @param {String} formatString The string to be formatted. * @param {String} arg1...argN The list of arguments to splice into formatString. * @returns {String} * @export */ format: ( formatString: string, ...args: string[] ) => string; /** * Truncates a string to the given length. * * @param {String} st The string to be truncated. * @param {Number} len The length of characters. Includes the ellipsis if ellipsis is set to true. * @param {Boolean} ellipsis If set to true, an ellipsis is added to the truncated string. * @param {Boolean} truncateByWord If set to true, checks that no truncation occurs in the middle of a word. * @returns {String} The truncated string. * @export */ truncate: ( st: string, len: number, ellipsis: boolean, truncateByWord: boolean ) => string; /** * Create a function that invokes the given callback after the tolerance period * has passed since the last invocation of the function. * * This is useful to defer responding to a stream of repetetive events until the * end of the stream. * * @param {Function} callback * The function to be run once the tolerance period has passed. * @param {Number} toleranceMillis * The tolerance duration in milliseconds. * @returns {Function} The function to invoke in order to trigger a start/reset * of the tolerance period. * @export */ createTimeoutCallback: ( callback: Function, toleranceMillis: number ) => Function; /** * Adds an event listener to a DOM element. * * @param {HTMLElement} element The DOM element to which to apply the listener. * @param {String} eventName The name of the DOM event, minus the "on" prefix (e.g. "click", "focus", "blur", etc.). * @param {Object} handler The JS handler to add. * @param {Boolean} useCapture Whether to use event capturing. * @param {Number} timeout Optional timeout (in milliseconds) that will delay the handler execution. * @returns {Object} Either a function (success) or null (fail) * @export */ on: ( element: HTMLElement, eventName: string, handler: any, useCapture: boolean, timeout: number ) => Function; /** * Removes an event listener from a DOM element. See also Util.on() a.k.a. $A.util.on() * * @param {HTMLElement} element The DOM element from which to remove the listener. * @param {String} eventName The name of the DOM event, minus the "on" prefix (e.g. "click", "focus", "blur", etc.). * @param {Function} listener The JS listener function to remove. * @param {Boolean} useCapture Whether to use event capturing. * @export */ removeOn: ( element: HTMLElement, eventName: string, listener: Function, useCapture: boolean ) => Function; /** * Stores the values of a form to a Map object. Values from a checkbox, radio, drop-down list, and textarea * are stored in the Map. * * @param {Object} form * @returns {Object} The map containing the values from the form input. * @export */ formToMap: ( form: any ) => any; /** * Gets the selected values from a list of options. * Returns a single value if only a single option is selected. * * @param {Object} select * @returns {Object} A list of selected options. * @export */ getSelectValue: ( select: HTMLSelectElement ) => string | string[]; /** * Adds a value to a map with a given key. If the key already exists, the values are turned into a list. * If the value has a dot in it - e.g. "properties.4" - it will be turned into an inner map, with * the second part as the inner key. * * @param {Object} inputMap The input map to be processed. * @param {String} key The data key whose value is to be added to the input map. * @param {Object} value The value of the data to add to the input map. * @export */ addValueToMap: ( inputMap: any, key: string, value: any ) => void; /** * Generates a map of values inside the main input map. This is used, for example, * When input fields have a "." operator, so * input name="def.def1" * input name="def.def2" * get put in the input map under "def", as a map with "def1" and "def2" mapped to their values. * * @param {Object} inputMap The input map to be processed. * @param {String} key The data key whose value is to be added to the input map. * @param {Object} value The value of the data to add to the input map. * @param {String} subMapKey * @export */ addMapValueToMap: ( inputMap: any, key: string, value: any, subMapKey: string ) => void; /** * Walks up a definition hierarchy to search for a sub definition by qualified name. * * @param {Object} def * The definition to search * @param {String} qname * The qualified name to search for * @returns {Boolean} true if qualified name is found in defs hierarchy * @export */ isSubDef: ( def: any, qname: string ) => boolean; /** * Copy properties & methods to one object from another, and return the object that was copied to. * This is useful for applying defaults to a specific configuration. * * @example * $A.util.apply(Child.prototype, Parent); // Returns a new object inheriting all the methods and properties from Parent. * * @example * $A.util.apply(Child.prototype, { isCool: true }); // Parent would then have a property of child. * * @example * $A.util.apply({ foo: 'bar', diameter: 10}, { diameter: 20, bat: 'man' }, true); //== {foo:'bar', diameter: 20, bat: 'man'} * * @example * $A.util.apply({ foo: 'bar', diameter: 10}, { diameter: 20, bat: 'man' }, false); //== {foo:'bar', diameter: 10, bat: 'man'} * * @param {Object} to The destination object that properties are copied to. * @param {Object} from The source object that properties are copied from. * @param {Boolean} [forceCopy] Whether to overwrite existing properties. (default: false) * @param {Boolean} [deepCopy] Whether to iterate over child objects. (default: false) * @param {Boolean} [ownOnly] Whether to skip prototype properties. (default: false) * @returns {Object} The object that properties were copied to. */ private apply: ( to: any, from: any, forceCopy?: boolean, deepCopy?: boolean, ownOnly?: boolean ) => any; /** * Deeply copies properties & methods to one object from another, and returns the object that was copied to. * * @param {Object} to The destination object that properties are copied to. * @param {Object} from The source object that properties are copied from. * @param {Boolean} [forceCopy] Whether to overwrite existing properties. (default: false) * @param {Boolean} [ownOnly] Whether to skip prototype properties. (default: false) * @returns {Object} The object that properties were copied to. */ private applyObject: ( to: any, from: any, forceCopy?: boolean, ownOnly?: boolean ) => any; /** * Deeply copies properties & methods to one array from another, and returns the array that was copied to. * * @param {Array} to The destination array that properties are copied to. * @param {Array} from The source array that properties are copied from. * @param {Boolean} [forceCopy] Whether to overwrite existing properties. (default: false) * @param {Boolean} [ownOnly] Whether to skip prototype properties. (default: false) * @returns {Array} The array that properties were copied to. */ private applyArray: ( to: any[], from: any[], forceCopy?: boolean, ownOnly?: boolean ) => any[]; /** * Gets a shallow copy of an Array or Object. * * @param {Object} value The value for which to return a comparable copy. * @returns {Object} The comparable copy of the value supplied. */ copy: ( value: any ) => any; /** * Deeply copies properties & methods from an object. * * @param {Object} object The object to deeply copy. * @param {Boolean} [ownOnly] Whether to skip prototype properties. (default: false) * @returns {Object} The object copy. */ private copyObject: ( object: any, ownOnly?: boolean ) => any; /** * Deeply copies properties & methods from an array. * * @param {Array} array The array to deeply copy. * @param {Boolean} [ownOnly] Whether to skip prototype properties. (default: false) * @returns {Array} The array copy. */ private copyArray: ( object: any[], ownOnly?: boolean ) => any[]; /** * Converts camelCase to hyphens. * * @param {String} str The string to be converted. * @returns {String} The string containing hyphens that replaces the camelCase. */ private camelCaseToHyphens: ( str: string ) => string; /** * Converts hyphens to camelCase. * * @param {String} str The string to be converted. * @returns {String} The string in camelCase. */ private hyphensToCamelCase: ( str: string ) => string; /** * Converts words to camelCase, strips non-alphanumeric characters * * */ private toCamelCase: ( str: string ) => string; /** * * @description Returns whether a given DOM element can accept custom data attributes. * * @param {HTMLElement} element The element to check for custom data attribute support. * @returns {Boolean} Whether element accepts custom data attributes. */ private acceptsData: ( element: HTMLElement ) => boolean; /** * Return attributeValue of an element * * @param {HTMLElement} element The element from which to retrieve data. * @param {String} attributeName The name of attribute to look up on element. * @export */ getElementAttributeValue: ( element: HTMLElement, attributeName: string ) => string; /** * @description Attempts to set focus on 'target'. * @param {HTMLElement|Component} target The DOM element or Component to which to send focus. * @export */ setFocus: ( element: HTMLElement | Component ) => void; /** * * @description Returns a custom data attribute value from a DOM element. * For more information on custom data attributes, see http://html5doctor.com/html5-custom-data-attributes/ * @param {HTMLElement} element The element from which to retrieve data. * @param {String} key The data key to look up on element. * @export */ getDataAttribute: ( element: HTMLElement, key: string ) => string; /** * * @description Sets a custom data attribute value from a DOM element. * For more information on custom data attributes, see http://html5doctor.com/html5-custom-data-attributes/ * @param {HTMLElement} element The element from which to retrieve data. * @param {String} key The data key to add to element. * @param {String} value The value of the data to add to an element. If value is undefined, the key data attribute will be removed from element. * @export */ setDataAttribute: ( element: HTMLElement, key: string, value: string ) => void; /** * @private */ private getDataAttributeName: ( key: string ) => void; /** * Checks whether a custom data attribute value already exists. * @param {HTMLElement} element The element from which to retrieve data. * @param {String} key The data key to look up on element. * @returns {Boolean} true if element has data attribute * @export */ hasDataAttribute: ( element: HTMLElement, key: string ) => boolean; /** * Checks if the object is an HTML element. * @param {Object} obj * @returns {Boolean} True if the object is an HTMLElement object, or false otherwise. */ private isHTMLElement: ( obj: any ) => boolean; /** * Checks if the object is a SVG element. * @param {Object} obj * @returns {Boolean} True if the object is an SVGElement object, or false otherwise. */ private isSVGElement: ( obj: any ) => boolean; /** * Attach the element to the HTML body * @param {DOMElement} element * @export */ attachToDocumentBody: ( element: HTMLElement ) => boolean; /** * Check for substrings at the end. * @param {String} fullstr The string to check against. * @param {String} substr The substring to look for at the end. * @returns {Boolean} True if fullstr ends with substr. * @export */ stringEndsWith: ( fullstr: string, substr: string ) => boolean; /** * Creates a new function whith bound arguments. * @param {Function} method to bind. * @param {Any} bound 'this' instance for the new function's scope. * @param {Any} var-args of bound parameters. * @returns {Function} a new function that invokes the provided function instance with bound arguments. */ bind: ( method: Function, ...args: any ) => Function; /** * Performs a series of 'safe' sequential lookup of nested properies. * * Example: a safe lookup for "VALUE" in: object: { * first: { * second: [ * "VALUE" * ] * } * } * * Can be done via: $A.util.lookup(object, "first", "second", 0); * Instead of: object && object.first && object.first.second && object.first.second[0] * * @param {Object} root object or array to sequentially lookup properties from. * @param {String} var-args of string property names. * @return {Any} the looked-up property or undefined if any properties along the way were not found. * @export */ lookup: ( root: any, ...args: string[] ) => any; /** * Does an in-place merge of any number of array into the first. * @param {Array} array to receive the elements of subsequent arrays. * @param {Array} var-args of arrays that will have their elements copied into the first. * @returns {Array} the first array (which has been modified in-place). * @export */ merge: ( array: any[], ...args: any[] ) => any[]; /** * Runs a function over each element in an array. * @param {Array} array to loop over. * @param {Function} method to call for each element. * @param {Any} the 'this' instance inside the scope of provided method. */ forEach: ( array: any[], method: ( item: any, index: number ) => void, context: any ) => void; /** * Returns an array containing the return value of the provided function over every element of the input array. * @param {Array} array to loop over. * @param {Function} tranforms an element from the input array to an element in the output array. * @param {Any} the 'this' instance inside the scope of provided transformation method. * @returns {Array} where every element is a result of the transformation function * applied to the element (at the same index) from the input array. */ map: ( array: any[], tranforms: ( item: any, index: number ) => any, context: any ) => any[]; /** * Loops over an array, calling a function that provides the returned result of calling the function on the * previous element. * @param {Array} array to loop over. * @param {Function} reduction method that takes the resturned result from the previous call, the current element from * the input array and index. * @param {Any} the initial object passed to the first element in the array's reduction method. * @returns {Any} the final value returned from calling the reduction method on the last element. */ reduce: ( array: any[], reduction: ( item: any, index: number ) => any, context: any ) => any; /** * Loops over an array, calling a function that returns some boolean. Returns true if all calls return a truthy result. * @param {Array} array to loop over. * @param {Function} predicate that returns a boolean result based on the current array element. * @param {Any} the 'this' instance inside the scope of provided transformation method. * @returns {Boolean} true if all elements of the array satisfy the predicate. */ every: ( array: any[], predicate: ( item: any, index: number ) => boolean, context: any ) => boolean; /** * Loops over an array, calling a function that returns some boolean. Returns true if any calls return a truthy result. * @param {Array} array to loop over. * @param {Function} predicate that returns a boolean result based on the current array element. * @param {Any} the 'this' instance inside the scope of provided transformation method. * @returns {Boolean} true if any of the elements of the array satisfy the predicate. */ some: ( array: any[], predicate: ( item: any, index: number ) => boolean, context: any ) => boolean; /** * Loops over an array, constructing a new array with the elements that pass the filter predicate. * @param {Array} array to loop over. * @param {Function} predicate that returns a boolean result based on the current array element the result of which * indicates whether the element will be returned in the filter result array. * @param {Any} the 'this' instance inside the scope of provided predicate. * @returns {Array} ordered array of elements that pass the predicate. */ filter: ( array: any[], predicate: ( item: any, index: number ) => boolean, context: any ) => any[]; /** * Schedules the specified component to be asynchronously destroyed. * @param {Component} cmp * The component to be destroyed. * @private */ private destroyAsync: ( cmp: Component ) => void; /** * Returns whether "instance" is, directly or indirectly, an instance of * "constructor." An object is indirectly an instance if derivePrototypeFrom was * used to make the child type derive from the parent type. * * JavaScript's instanceof operator is not used as it doesn't understand * type inheritance. Using this method would avoid the need for child.prototype to be * an instance of parent; we also avoid having "unbound" instances. * * @param instance The object to test * @param constructor The object to test against * @returns {Boolean} Returns true if instance is an instance of constructor. * @export */ instanceOf: ( instance: any, constructor: any ) => boolean; /** * Destroys any components currently in the trashcan. * @private */ private emptyComponentTrash: () => void; /** * Determines if an element is either a descendant of, or the same as, another element in the DOM tree. * Both arguments to this function must be of type HTMLElement or SVGElement. * * @param {(HTMLElement|SVGElement)} container The element you think is the outermost container. * @param {(HTMLElement|SVGElement)} element The element you think is buried inside the container. * @returns {Boolean} Returns true if 'element' is indeed inside 'container', false otherwise. * @export */ contains: ( container: HTMLElement | SVGElement, element: HTMLElement | SVGElement ) => boolean; /** * Simple event squasher. * * @param {UIEvent} event the DOM event to squash * @param {Boolean} preventDefault if preventDefault() should also be called * @export */ squash: ( event: any, preventDefault: boolean ) => void; /** * Strip off html tags from html codes. * * @param {String} input the input html codes * @param {Array} tags the html tag names to be removed * @return {String} an output string without those specified tags * @export */ stripTags: ( input: string, tags: string[] ) => string; /** * Simple function to get client viewport dimensions. If neither window.innerWidth * nor document.body.clientWidth is supported by the client, returns "0" for * both width and height. * * @return {Object} JS object with the fields "width" and "height" * @export */ getWindowSize: () => any; /** * Checks if the object is an Aura component. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is a component, or return false otherwise. * @export */ isComponent: ( obj: any ) => boolean; /** * Checks if the object is an Aura value expression. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is an expression, or false otherwise. * @export */ isExpression: ( obj: any ) => boolean; /** * Checks if the object is an Aura value object. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is an Aura value (PropertyReferenceValue, FunctionCallValue, PassthroughValue). * @export */ isValue: ( obj: any ) => boolean; /** * Checks if the object is an Aura action object. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is an Aura Action. * @export */ isAction: ( obj: any ) => boolean; /** * Checks if the object is an Aura Event object. * * @param {Object} obj The object to check for. * @returns {Boolean} True if the object type is an Aura Event. * @export */ isEvent: ( obj: any ) => boolean; /** * Checks if touch events are supported. Cache the result, it shouldn't change. * * @returns {Boolean} True if touch events are supported. * @export */ supportsTouchEvents: () => boolean; /** * Estimate the size of an object or primitive in bytes. * * @param {Object} item The object or primitive whose size to estimate. * @return {Number} The estimated size of the item in bytes. * @export */ estimateSize: ( item: any ) => number; /** * Convert collection to a true array. * When dealing with a NodeList, sometimes you'll need it to actually be an array to properly deal with it. * Cannot always use Array.prototype.slice.call(), since it doesn't work in IE6/7/8 on NodeLists. * @returns An empty array if you pass a null or undefined value to collection. */ private toArray: ( obj: any[] ) => any[]; /** @export */ setText: ( node: HTMLElement, text: string ) => void; /** * Posts message to the provided window. This was done to workaround an issue where browser sets * event.source to be safeEvalWorker window (see W-3443540). * NOTE: safeEvalWorker has been removed. * @param {Window} targetWindow The destination window for the message * @param {Array} argsArray list of arguments to be posted * @export */ postMessage: ( targetWindow: Window, argsArray: any[] ) => void; /** * Get a string representation of component hierarchy by calling getOwner and walk up the component tree. * @param {component} leaf component to walk up the hierarchy * @private */ private getComponentHierarchy: ( component: Component ) => any; /** * eval throwing an error to check whether sourceURL is supported. * @private */ private hasSourceURL: () => any; /** * Returns a hash for a passed in string. * Replicates Java's hashCode method (https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#hashCode()). * @param {String} value string to be hashed. * @returns {Number} a hashed representation of the passed in string. * @private */ private getHashCode: ( value: string ) => number; /** * Browser check for all supported versions of Internet Explorer, does the validation using the userAgent. * * @returns {Boolean} true if Internet Explorer detected * @export */ isIE: () => boolean; /** * Whether IOS7 UIWebView * @returns {boolean} true if IOS UIWebView * @export */ isIOSWebView: () => boolean; /** * Gets a DOM element by its id without any leading characters (e.g. #) unless the ID contains them. * * @param {String} id The corresponding id of the DOM element. * @returns {Object} The element with the matching id, or null if none is found. * @export */ getElement: ( id: string ) => any; /** * Compares value equality of two variables. Returns true if primitive values match, * or if Object or Array members contain the same values. Checks Objects and Arrays recursively. * Fails fast. Note that objects stop comparing after satisfying 'likeness' against 'expected' -- i.e., * 'actual' is allowed to exhibit members that 'expected' does not, as long as all members of 'expected' are matched. * * @param {Object} expected The baseline value to use in the comparison against 'actual'. * @param {Object} actual The value to compare against 'expected'. * @returns {Boolean} Returns true if the values match, and false if they do not. */ equals: ( expected: any, actual: any ) => boolean; /** * Sanitize * Public method providing core sanitation functionality * * @param {String} dirty string * @param {Object} configuration object * @return {String} sanitized string * @export */ sanitizeDOM: ( dirty: string, configuration: Object ) => string; /** * Encodes values for safe embedding in HTML tags and attributes. * * @param {*} val will be converted to a String prior to encoding * @return {string} the encoded string * @export */ sanitizeHtml: ( val: any ) => string; /** * Encodes values for safe embedding in JavaScript string contexts. * * @param {*} val will be converted to a String prior to encoding * @return {string} the encoded string * @export */ sanitizeJs: ( val: any ) => string; /** * Encodes values embedded in HTML scripting attributes. * * @param {*} val will be converted to a String prior to encoding * @return {string} the encoded string * @export */ sanitizeJsAttr: ( val: any ) => string; /** * Percent-encodes unsafe characters in URIs. * * @param {*} val will be converted to a String prior to encoding * @return {string} the percent-encoded string * @export */ sanitizeUri: ( val: any ) => string; /** * Encodes an object as JSON, but with unsafe characters in string literals * backslash-escaped. * * @param {any} val * @return {string} the JSON and backslash-encoded string * @export */ sanitizeJsObj: ( val: any ) => string; /** * Encodes values for safe embedding in CSS context. * * @param {any} val * @return {string} the backslash-encoded string * @export */ sanitizeCSS: ( val: any ) => string; /** * Encodes values for safe embedding in HTML style attribute context. * * @param {any} val * @return {string} the entity and backslash-encoded string * @export */ sanitizeStyle: ( val: any ) => string; /** * @private */ private setClass: ( element: Component, newClass: string, remove: string ) => void; /** * @private */ private buildClass: ( oldClass: string, newClass: string, remove: string ) => void; /** * Browser check for localStorage enablement. * @returns {Boolean} true if LocalStorage is available * @private * */ private isLocalStorageEnabled: () => boolean; /** * Browser check for sessionStorage enablement. * @returns {Boolean} true if SessionStorage is available * @private */ private isSessionStorageEnabled: () => boolean; /** * Sets a cookie. * @param {String} key The name of the cookie. * @param {String} value The value of the cookie. * @param {Number} duration The duration of the cookie (milliseconds) * @private */ private setCookie: ( key: string, value: string, duration: number ) => void; /** * Gets a cookie. * @param {String} key The name of the cookie. * @return {String} the value of the cookie if it exists, undefined otherwise. * @private * */ private getCookie: ( key: string ) => string; /** * Clears a cookie. * @param {String} key The name of the cookie. * @private */ private clearCookie: ( key: string ) => void; /** * evals code globally, without enclosing the current scope * * @private */ private globalEval: () => void; } interface ComponentAttrs { [ key: string ]: any; } type CreateComponentDef = [ string, ComponentAttrs ]; type CreateComponentStatus = 'SUCCESS' | 'INCOMPLETE' | 'ERROR'; type CreateComponentCallback = ( cmp?: Component, status?: CreateComponentStatus, errorMessage?: string ) => void; type CreateComponentsCallback = ( cmps?: Component[], status?: CreateComponentStatus, errorMessage?: string ) => void; interface Duration { asDays: () => number; asHours: () => number; asMilliseconds: () => number; asMinutes: () => number; asMonths: () => number; asSeconds: () => number; asWeeks: () => number; asYears: () => number; days: () => number; hours: () => number; humanize: () => number; milliseconds: () => number; minutes: () => number; months: () => number; seconds: () => number; weeks: () => number; years: () => number; } interface LocalizationService { /** * @description * Formats a date. * */ formatDate: ( value: string | number | Date, formatString: string, locale?: string ) => string; parseDateTime: ( dateTimeString: string, parseFormat?: string, locale?: string | boolean, strictParsing?: boolean ) => Date; isAfter: ( date1: string | number | Date, date2: string | number | Date, unit?: string ) => boolean; isBefore: ( date1: string | number | Da