forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
winjs.d.ts
8969 lines (7419 loc) · 387 KB
/
winjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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/borisyankov/DefinitelyTyped
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* 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>;
}
/**
* Provides application-level functionality, for example activation, storage, and application events.
**/
declare module 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 Methods
/**
* 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.
**/
function setPromise(promise: Promise<any>): void;
//#endregion Methods
//#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
/**
* 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: CustomEvent): 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: CustomEvent): void;
/**
* Occurs when an unhandled error has been raised.
* @param eventInfo An object that contains information about the event.
**/
function onerror(eventInfo: CustomEvent): 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: CustomEvent): 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: CustomEvent): 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: CustomEvent): 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: CustomEvent): void;
//#endregion Events
}
/**
* Provides functionality for data and template binding.
**/
declare module WinJS.Binding {
//#region Properties
/**
* Determines whether or not binding should automatically set the ID of an element. This property should be set to true in apps that use WinJS (WinJS) binding.
**/
var optimizeBindingReferences: boolean;
//#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.
**/
class 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
}
/**
* Do not instantiate. A list of groups.
**/
class 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.
**/
class GroupedSortedListProjection<T> extends SortedListProjection<T> {
//#region Properties
/**
* Gets a List, which is a projection of the groups that were identified in this list.
**/
groups: GroupsListProjection<T>;
//#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> extends 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 Methods
/**
* 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 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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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[];
//#endregion Methods
//#region Properties
/**
* 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;
//#endregion Properties
}
/**
* Represents a base class for lists.
**/
class 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(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection<T>;
/**
* 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 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;
/**
* 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;
/**
* 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;
//#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>;
/**
* Indicates that the object is compatibile with declarative processing.
**/
static supportedForProcessing: boolean;
//#endregion Properties
}
/**
* Represents a base class for normal list modifying operations.
**/
class ListBaseWithMutators<T> extends ListBase<T> {
//#region Methods
/**
* 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;
/**
* Removes the first element from a list and returns it.
* @returns The first element from the list.
**/
shift(): T;
/**
* 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
}
/**
* Represents a base class for list projections.
**/
class ListProjection<T> extends ListBaseWithMutators<T> {
//#region Methods
/**
* Disconnects a WinJS.Binding.List projection from its underlying WinJS.Binding.List. It's only important to call this method when the WinJS.Binding.List projection and the WinJS.Binding.List have different lifetimes. (Call this method on the WinJS.Binding.List projection, not the underlying WinJS.Binding.List.)
**/
dispose(): void;
/**
* 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>;
/**
* Moves the value at index to position newIndex.
* @param index The original index of the value.
* @param newIndex The index of the value after the move.
**/
move(index: number, newIndex: 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[];
//#endregion Methods
}
/**
* Provides a standard implementation of the bindable contract, as well as a basic storage mechanism that participates in change notification and an asynchronous notification implementation.
**/
var mixin: {
//#region Methods
/**
* Adds a property to the object. The property includes change notification and an ECMAScript 5 property definition .
* @param name The name of the property to add.
* @param value The value of the property.
* @returns This object is returned.
**/
addProperty(name: string, value: any): any;
/**
* 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
};
/**
* Provides functions that can make an object observable.
**/
var observableMixin: {
//#region Methods
/**
* 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;
/**
* 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>;
/**
* 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;
//#endregion Methods
};
/**
* Do not instantiate. Returned by the createSorted method.
**/
class SortedListProjection<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.
* @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 to be replaced.
* @param newValue The new value.
**/
setAt(index: number, newValue: T): void;
//#endregion Methods
//#region Properties
/**
* Gets or sets the length of the list. Returns an integer value one higher than the highest element defined in a list.
**/
length: number;
//#endregion Properties
}
/**
* Provides a reusable declarative binding element.
**/
class Template {
//#region Constructors
/**
* Creates a template that provides a reusable declarative binding element.
* @constructor
* @param element The DOM element to convert to a template.
* @param options If this parameter is supplied, the template is loaded from the URI and the content of the element parameter is ignored. You can add the following options: href.
**/
constructor(element: HTMLElement, options?:any);
//#endregion Constructors
//#region Methods
/**
* Binds values from the specified data context to elements that are descendants of the specified root element that have the declarative binding attributes specified (data-win-bind).
* @param dataContext The object to use for default data binding.
* @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created.
* @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished.
**/
render(dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
/**
* Renders a template based on the specified URI (static method).
* @param href The URI from which to load the template.
* @param dataContext The object to use for default data binding.
* @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created.
* @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV.
**/
static render(href: string, dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
//#endregion Methods
//#region Properties
/**
* Gets or sets the default binding initializer for the template.
**/
bindingInitializer: any;
/**
* Gets or sets a value that specifies whether a debug break is inserted into the first rendering of each template. This property only has an effect when the app is in debug mode.
**/
debugBreakOnRender: boolean;
/**
* This property is deprecated and might not be available in future versions of the WinJS. Gets or sets a value that specifies whether optimized template processing has been disabled.
**/
disableOptimizedProcessing: boolean;
/**
* Gets the DOM element that is used as the template.
**/
element: HTMLElement;