declarations
Version:
[](https://www.npmjs.com/package/declarations)
903 lines (751 loc) • 469 kB
TypeScript
// Type definitions for WinJS
// Project: http://try.buildwinjs.com/
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>, Jeff Fisher <https://github.com/xirzec>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/**
* Defines an Element object.
**/
interface Element {
winControl: any;
}
/**
* Utility class for easy access to operations on application folders
**/
interface IOHelper {
/**
* Determines whether the specified file exists in the folder.
* @param filename The name of the file.
* @returns A promise that completes with a value of either true (if the file exists) or false.
**/
exists(filename: string): WinJS.Promise<boolean>;
/**
* Reads the specified file. If the file doesn't exist, the specified default value is returned.
* @param fileName The file to read from.
* @param def The default value to be returned if the file failed to open.
* @returns A promise that completes with a value that is either the contents of the file, or the specified default value.
**/
readText(fileName: string, def?: string): WinJS.Promise<string>;
/**
* Deletes a file from the folder.
* @param fileName The file to be deleted.
* @returns A promise that is fulfilled when the file has been deleted.
**/
remove(fileName: string): WinJS.Promise<void>;
/**
* Writes the specified text to the specified file.
* @param fileName The name of the file.
* @param text The content to be written to the file.
* @returns A promise that is completed when the file has been written.
**/
writeText(fileName: string, text: string): WinJS.Promise<number>;
/**
* This API supports the WinJS infrastructure and is not intended to be used directly from your code.
**/
storage: any;
}
/**
* Provides application-level functionality, for example activation, storage, and application events.
**/
declare namespace WinJS.Application {
//#region Objects
/**
* The local storage of the application.
**/
var local: IOHelper;
/**
* The roaming storage of the application.
**/
var roaming: IOHelper;
/**
* The temp storage of the application.
**/
var temp: IOHelper;
/**
* An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content.
**/
var sessionState: any;
//#endregion Objects
//#region Functions
/**
* Adds an event listener for application-level events: activated, checkpoint, error, loaded, ready, settings, and unload.
* @param type The type (name) of the event. You can use any of the following:"activated", "checkpoint", "error", "loaded", "ready", "settings", and" unload".
* @param listener The listener to invoke when the event is raised.
* @param capture true to initiate capture, otherwise false.
**/
function addEventListener(type: string, listener: Function, capture?: boolean): void;
/**
* Queues a checkpoint event.
**/
function checkpoint(): void;
/**
* Queues an event to be processed by the WinJS.Application event queue.
* @param eventRecord The event object is expected to have a type property that is used as the event name when dispatching on the WinJS.Application event queue. The entire object is provided to event listeners in the detail property of the event.
**/
function queueEvent(eventRecord: any): void;
/**
* Removes an event listener from the control.
* @param type The type (name) of the event.
* @param listener The listener to remove.
* @param useCapture Specifies whether or not to initiate capture.
**/
function removeEventListener(type: string, listener: Function, useCapture?: any): void;
/**
* Starts dispatching application events (the activated, checkpoint, error, loaded, ready, settings, and unload events).
**/
function start(): void;
/**
* Stops application event processing and resets WinJS.Application to its initial state. All WinJS.Application event listeners (for the activated, checkpoint, error, loaded, ready, settings, and unload events) are removed.
**/
function stop(): void;
//#endregion Functions
//#region Events
interface IPromiseEvent extends CustomEvent {
/**
* Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload.
* @param promise The promise that should complete before processing is complete.
**/
setPromise(promise: IPromise<any>): void;
}
/**
* Occurs when WinRT activation has occurred. The name of this event is "activated" (and also "mainwindowactivated"). This event occurs after the loaded event and before the ready event.
* @param eventInfo An object that contains information about the event. For more information about event arguments, see the WinRT event argument classes: WebUICachedFileUpdaterActivatedEventArgs, WebUICameraSettingsActivatedEventArgs, WebUIContactPickerActivatedEventArgs, WebUIDeviceActivatedEventArgs, WebUIFileActivatedEventArgs, WebUIFileOpenPickerActivatedEventArgs, WebUIFileSavePickerActivatedEventArgs, WebUILaunchActivatedEventArgs, WebUIPrintTaskSettingsActivatedEventArgs, WebUIProtocolActivatedEventArgs, WebUISearchActivatedEventArgs, WebUIShareTargetActivatedEventArgs.
**/
function onactivated(eventInfo: IPromiseEvent): void;
/**
* Occurs when receiving PLM notification or when the checkpoint function is called.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise.
**/
function oncheckpoint(eventInfo: IPromiseEvent): void;
/**
* Occurs when an unhandled error has been raised.
* @param eventInfo An object that contains information about the event.
**/
function onerror(eventInfo: IPromiseEvent): void;
/**
* Occurs after the DOMContentLoaded event, which fires after the page has been parsed but before all the resources are loaded. This event occurs before the activated event and the ready event.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise.
**/
function onloaded(eventInfo: IPromiseEvent): void;
/**
* Occurs when the application is ready. This event occurs after the loaded event and the activated event.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise.
**/
function onready(eventInfo: IPromiseEvent): void;
/**
* Occurs when the settings charm is invoked.
* @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: type, applicationcommands.
**/
function onsettings(eventInfo: IPromiseEvent): void;
/**
* Occurs when the application is about to be unloaded.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise.
**/
function onunload(eventInfo: IPromiseEvent): void;
/**
* Occurs whenever a user clicks the hardware backbutton.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type
**/
function onbackclick(eventInfo: IPromiseEvent): void;
//#endregion Events
}
/**
* Provides functionality for data and template binding.
**/
declare namespace WinJS.Binding {
//#region Properties
//#endregion Properties
//#region Objects
/**
* Allows you to add bindable properties dynamically.
**/
var dynamicObservableMixin: {
//#region Methods
/**
* Adds a property with change notification to this object, including a ECMAScript5 property definition.
* @param name The name of the property to add.
* @param value This object is returned.
**/
addProperty(name: string, value: any): void;
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns This object is returned.
**/
bind(name: string, action: any): Function;
/**
* Gets a property value by name.
* @param name The name of the property to get.
* @returns The value of the property as an observable object.
**/
getProperty(name: string): any;
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: string, oldValue: string): Promise<any>;
/**
* Removes a property value.
* @param name The name of the property to remove.
* @returns This object is returned.
**/
removeProperty(name: string): any;
/**
* Updates a property value and notifies any listeners.
* @param name The name of the property to update.
* @param value The new value of the property.
* @returns This object is returned.
**/
setProperty(name: string, value: any): any;
/**
* Removes one or more listeners from the notification list for a given property.
* @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.
* @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.
* @returns This object is returned.
**/
unbind(name: string, action: Function): any;
/**
* Updates a property value and notifies any listeners.
* @param name The name of the property to update.
* @param value The new value of the property.
* @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed.
**/
updateProperty(name: string, value: any): Promise<any>;
//#endregion Methods
};
/**
* Do not instantiate. A list returned by the createFiltered method.
**/
interface FilteredListProjection<T> extends ListProjection<T> {
//#region Methods
/**
* Returns a key/data pair for the specified index.
* @param index The index of the value to retrieve.
* @returns An object that has two properties: key and data.
**/
getItem(index: number): IKeyDataPair<T>;
/**
* Returns the index of the first occurrence of a key in a list.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
/**
* Forces the list to send a itemmutated notification to any listeners for the value at the specified index.
* @param index The index of the value that was mutated.
**/
notifyMutated(index: number): void;
/**
* Replaces the value at the specified index with a new value.
* @param index The index of the value that was replaced.
* @param newValue The new value.
**/
setAt(index: number, newValue: T): void;
//#endregion Methods
//#region Properties
/**
* The length of the list. Returns an integer value one higher than the highest element defined in an list.
**/
length: number;
//#endregion Properties
}
/**
* A list of groups.
**/
interface GroupsListProjection<T> extends ListBase<T> {
//#region Methods
/**
* Gets a key/data pair for the specified index.
* @param index The index of the value to retrieve.
* @returns An object that has two properties: key and data.
**/
getItem(index: number): IKeyDataPair<T>;
/**
* Gets a key/data pair for the specified key.
* @param key The key of the value to retrieve.
* @returns An object with two properties: key and data.
**/
getItemFromKey(key: string): IKeyDataPair<T>;
/**
* Returns the index of the first occurrence of a key in a list.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
//#endregion Methods
//#region Properties
/**
* The length of the list. Returns an integer value one higher than the highest element defined in an list.
**/
length: number;
//#endregion Properties
}
/**
* Do not instantiate. Sorts the underlying list by group key and within a group respects the position of the item in the underlying list. Returned by createGrouped.
**/
interface GroupedSortedListProjection<T, G> extends SortedListProjection<T> {
//#region Properties
/**
* Gets a List, which is a projection of the groups that were identified in this list.
**/
groups: GroupsListProjection<G>;
//#endregion Properties
/**
* Returns a key/data pair for the specified index.
* @param index The index of the value to retrieve.
* @returns An object that has two properties: key and data.
**/
getItem(index: number): IGroupKeyDataPair<T>;
}
/**
* Represents a list of objects that can be accessed by index or by a string key. Provides methods to search, sort, filter, and manipulate the data.
**/
class List<T> implements ListBaseWithMutators<T> {
//#region Constructors
/**
* Creates a List object.
* @constructor
* @param list The array containing the elements to initalize the list.
* @param options You can set two Boolean options: binding and proxy. If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors.
**/
constructor(list?: T[], options?: any);
//#endregion Constructors
//#region Events
/**
* An item in the list has changed its value.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue.
**/
onitemchanged(eventInfo: CustomEvent): void;
/**
* A new item has been inserted into the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
oniteminserted(eventInfo: CustomEvent): void;
/**
* An item has been changed locations in the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemmoved(eventInfo: CustomEvent): void;
/**
* An item has been mutated. This event occurs as a result of calling the notifyMutated method.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemmutated(eventInfo: CustomEvent): void;
/**
* An item has been removed from the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemremoved(eventInfo: CustomEvent): void;
/**
* The list has been refreshed. Any references to items in the list may be incorrect.
* @param eventInfo An object that contains information about the event. The detail property of this object is null.
**/
onreload(eventInfo: CustomEvent): void;
//#endregion Events
//#region Methods
/**
* Adds an event listener to the control.
* @param type The type (name) of the event.
* @param listener The listener to invoke when the event gets raised.
* @param useCapture If true, initiates capture, otherwise false.
**/
addEventListener(type: string, listener: Function, useCapture?: boolean): void;
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns A reference to this observableMixin object.
**/
bind(name: string, action: Function): any;
/**
* Returns a new list consisting of a combination of two arrays.
* @param item Additional items to add to the end of the list.
* @returns An array containing the concatenation of the list and any other supplied items.
**/
concat(...item: T[]): T[];
/**
* Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change.
* @param predicate A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @returns A filtered projection over the list.
**/
createFiltered(predicate: (x: T) => boolean): FilteredListProjection<T>;
/**
* Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list.
* @param groupKey A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @param groupData A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group.
* @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after).
* @returns A grouped projection over the list.
**/
createGrouped<G>(groupKey: (x: T) => string, groupData: (x: T) => G, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection<T, G>;
/**
* Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.
* @param sorter A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @returns A sorted projection over the list.
**/
createSorted(sorter: (left: T, right: T) => number): SortedListProjection<T>;
/**
* Raises an event of the specified type and with the specified additional properties.
* @param type The type (name) of the event.
* @param eventProperties The set of additional properties to be attached to the event object when the event is raised.
* @returns true if preventDefault was called on the event.
**/
dispatchEvent(type: string, eventProperties: any): boolean;
/**
* Checks whether the specified callback function returns true for all elements in a list.
* @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns true if the callback returns true for all elements in the list.
**/
every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Returns the elements of a list that meet the condition specified in a callback function.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns An array containing the elements that meet the condition specified in the callback function.
**/
filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): T[];
/**
* Calls the specified callback function for each element in a list.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
**/
forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
/**
* Gets the value at the specified index.
* @param index The index of the value to get.
* @returns The value at the specified index.
**/
getAt(index: number): T;
/**
* Gets a key/data pair for the specified list index.
* @param index The index of value to retrieve.
* @returns An object with .key and .data properties.
**/
getItem(index: number): IKeyDataPair<T>;
/**
* Gets a key/data pair for the list item key specified.
* @param key The key of the value to retrieve.
* @returns An object with .key and .data properties.
**/
getItemFromKey(key: string): IKeyDataPair<T>;
/**
* Gets the index of the first occurrence of the specified value in a list.
* @param searchElement The value to locate in the list.
* @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
* @returns The index of the first occurrence of a value in a list or -1 if not found.
**/
indexOf(searchElement: T, fromIndex?: number): number;
/**
* Gets the index of the first occurrence of a key in a list.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
/**
* Returns a string consisting of all the elements of a list separated by the specified separator string.
* @param separator A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma.
* @returns The elements of a list separated by the specified separator string.
**/
join(separator?: string): string;
/**
* Gets the index of the last occurrence of the specified value in a list.
* @param searchElement The value to locate in the list.
* @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list.
* @returns The index of the last occurrence of a value in a list, or -1 if not found.
**/
lastIndexOf(searchElement: T, fromIndex?: number): number;
/**
* Calls the specified callback function on each element of a list, and returns an array that contains the results.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list.
* @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns An array containing the result of calling the callback function on each element in the list.
**/
map<G>(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[];
/**
* Moves the value at index to the specified position.
* @param index The original index of the value.
* @param newIndex The index of the value after the move.
**/
move(index: number, newIndex: number): void;
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: any, oldValue: any): Promise<any>;
/**
* Forces the list to send a itemmutated notification to any listeners for the value at the specified index.
* @param index The index of the value that was mutated.
**/
notifyMutated(index: number): void;
/**
* Forces the list to send a reload notification to any listeners.
**/
notifyReload(): void;
/**
* Removes the last element from a list and returns it.
* @returns The last element from the list.
**/
pop(): T;
/**
* Appends new element(s) to a list, and returns the new length of the list.
* @param value The element to insert at the end of the list.
* @returns The new length of the list.
**/
push(value: T): number;
push(...values: T[]): number;
/**
* Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.
* @param initiallValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value.
* @returns The return value from the last call to the callback function.
**/
reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T): T;
/**
* Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.
* @param initialValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.
* @returns The return value from the last call to callback function.
**/
reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T): T;
/**
* Removes an event listener from the control.
* @param type The type (name) of the event.
* @param listener The listener to remove.
* @param useCapture true if capture is to be initiated, otherwise false.
**/
removeEventListener(type: string, listener: Function, useCapture?: boolean): void;
/**
* Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution.
**/
reverse(): void;
/**
* Replaces the value at the specified index with a new value.
* @param index The index of the value that was replaced.
* @param newValue The new value.
**/
setAt(index: number, newValue: T): void;
/**
* Removes the first element from a list and returns it.
* @returns The first element from the list.
**/
shift(): T;
/**
* Extracts a section of a list and returns a new list.
* @param begin The index that specifies the beginning of the section.
* @param end The index that specifies the end of the section.
* @returns Returns a section of list.
**/
slice(begin: number, end?: number): T[];
/**
* Checks whether the specified callback function returns true for any element of a list.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns true if callback returns true for any element in the list.
**/
some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution.
* @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
**/
sort(sortFunction?: (left: T, right: T) => number): void;
/**
* Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the list from which to start removing elements.
* @param howMany The number of elements to remove.
* @param item The elements to insert into the list in place of the deleted elements.
* @returns The deleted elements.
**/
splice(start: number, howMany?: number, ...item: T[]): T[];
/**
* Removes one or more listeners from the notification list for a given property.
* @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.
* @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.
* @returns This object is returned.
**/
unbind(name: string, action: Function): any;
/**
* Appends new element(s) to a list, and returns the new length of the list.
* @param value The element to insert at the start of the list.
* @returns The new length of the list.
**/
unshift(value: T): number;
unshift(...values: T[]): number;
//#endregion Methods
//#region Properties
/**
* Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView.
**/
dataSource: WinJS.UI.IListDataSource<T>;
/**
* Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list.
**/
length: number;
/**
* Indicates that the object is compatibile with declarative processing.
**/
static supportedForProcessing: boolean;
//#endregion Properties
}
/**
* Represents a base class for lists.
**/
interface ListBase<T> {
//#region Events
/**
* An item in the list has changed its value.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue.
**/
onitemchanged(eventInfo: CustomEvent): void;
/**
* A new item has been inserted into the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
oniteminserted(eventInfo: CustomEvent): void;
/**
* An item has been changed locations in the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemmoved(eventInfo: CustomEvent): void;
/**
* An item has been mutated. This event occurs as a result of calling the notifyMutated method.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemmutated(eventInfo: CustomEvent): void;
/**
* An item has been removed from the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemremoved(eventInfo: CustomEvent): void;
/**
* The list has been refreshed. Any references to items in the list may be incorrect.
* @param eventInfo An object that contains information about the event. The detail property of this object is null.
**/
onreload(eventInfo: CustomEvent): void;
//#endregion Events
//#region Methods
/**
* Adds an event listener to the control.
* @param type The type (name) of the event.
* @param listener The listener to invoke when the event gets raised.
* @param useCapture If true, initiates capture, otherwise false.
**/
addEventListener(type: string, listener: Function, useCapture?: boolean): void;
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns A reference to this observableMixin object.
**/
bind(name: string, action: Function): any;
/**
* Returns a new list consisting of a combination of two arrays.
* @param item Additional items to add to the end of the list.
* @returns An array containing the concatenation of the list and any other supplied items.
**/
concat(...item: T[]): T[];
/**
* Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change.
* @param predicate A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @returns A filtered projection over the list.
**/
createFiltered(predicate: (x: T) => boolean): FilteredListProjection<T>;
/**
* Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list.
* @param groupKey A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @param groupData A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group.
* @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after).
* @returns A grouped projection over the list.
**/
createGrouped<G>(groupKey: (x: T) => string, groupData: (x: T) => G, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection<T, G>;
/**
* Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.
* @param sorter A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @returns A sorted projection over the list.
**/
createSorted(sorter: (left: T, right: T) => number): SortedListProjection<T>;
/**
* Raises an event of the specified type and with the specified additional properties.
* @param type The type (name) of the event.
* @param eventProperties The set of additional properties to be attached to the event object when the event is raised.
* @returns true if preventDefault was called on the event.
**/
dispatchEvent(type: string, eventProperties: any): boolean;
/**
* Checks whether the specified callback function returns true for all elements in a list.
* @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns true if the callback returns true for all elements in the list.
**/
every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Returns the elements of a list that meet the condition specified in a callback function.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns An array containing the elements that meet the condition specified in the callback function.
**/
filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): T[];
/**
* Calls the specified callback function for each element in a list.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
**/
forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
/**
* Gets the value at the specified index.
* @param index The index of the value to get.
* @returns The value at the specified index.
**/
getAt(index: number): T;
/**
* Gets the index of the first occurrence of the specified value in a list.
* @param searchElement The value to locate in the list.
* @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
* @returns The index of the first occurrence of a value in a list or -1 if not found.
**/
indexOf(searchElement: T, fromIndex?: number): number;
/**
* Returns a string consisting of all the elements of a list separated by the specified separator string.
* @param separator A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma.
* @returns The elements of a list separated by the specified separator string.
**/
join(separator?: string): string;
/**
* Gets the index of the last occurrence of the specified value in a list.
* @param searchElement The value to locate in the list.
* @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list.
* @returns The index of the last occurrence of a value in a list, or -1 if not found.
**/
lastIndexOf(searchElement: T, fromIndex?: number): number;
/**
* Calls the specified callback function on each element of a list, and returns an array that contains the results.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list.
* @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns An array containing the result of calling the callback function on each element in the list.
**/
map<G>(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[];
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: any, oldValue: any): Promise<any>;
/**
* Forces the list to send a reload notification to any listeners.
**/
notifyReload(): void;
/**
* Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback functi