##// END OF EJS Templates
added type parameter to dojo.store.api.SortInformation,...
cin -
r20:1c7650c17856 v1.0.8 default
parent child
Show More
@@ -1,1870 +1,1870
1 1 declare namespace dijit {
2 2
3 3 namespace form {
4 4
5 5 /* implied */
6 6
7 7 interface Constraints {
8 8 [prop: string]: any;
9 9 }
10 10
11 11 interface ConstrainedValueFunction<V = any, C extends Constraints = Constraints, T = any> {
12 12 /**
13 13 * Returns a value that has been constrained by the constraints
14 14 * @param value The value to constrain
15 15 * @param constraints The constraints to use
16 16 * @returns The constrained value
17 17 */
18 18 (value: V, constraints: C): T;
19 19 }
20 20
21 21 interface ConstrainedValidFunction<C extends Constraints = Constraints> {
22 22 /**
23 23 * Returns true if the value is valid based on the constraints, otherwise
24 24 * returns false.
25 25 * @param value The value to check
26 26 * @param constraints The constraints to use
27 27 * @returns true if valid, otherwise false
28 28 */
29 29 (value: any, constraints: C): boolean;
30 30 }
31 31
32 32 interface ConstraintsToRegExpString<C extends Constraints = Constraints> {
33 33 /**
34 34 * Takes a set of constraints and returns a RegExpString that can be used
35 35 * to match values against
36 36 * @param constraints The constraints to use
37 37 * @returns The RegExpString that represents the constraints
38 38 */
39 39 (constraints: C): string;
40 40 }
41 41
42 42 interface SerializationFunction {
43 43 (val: any, options?: Object): string;
44 44 }
45 45
46 46 /* dijit/form/_AutoCompleterMixin */
47 47
48 48 /* tslint:disable:class-name */
49 interface _AutoCompleterMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> extends _SearchMixin<T, Q, O> {
49 interface _AutoCompleterMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> extends _SearchMixin<T, Q, O> {
50 50 /**
51 51 * This is the item returned by the dojo/store/api/Store implementation that
52 52 * provides the data for this ComboBox, it's the currently selected item.
53 53 */
54 54 item: T;
55 55
56 56 /**
57 57 * If user types in a partial string, and then tab out of the `<input>` box,
58 58 * automatically copy the first entry displayed in the drop down list to
59 59 * the `<input>` field
60 60 */
61 61 autoComplete: boolean;
62 62
63 63 /**
64 64 * One of: "first", "all" or "none".
65 65 */
66 66 highlightMatch: string;
67 67 /* TODO: Uncomment for TS 1.8 and remove above */
68 68 /* highlightMatch: 'fisrt' | 'all' | 'none'; */
69 69
70 70 /**
71 71 * The entries in the drop down list come from this attribute in the
72 72 * dojo.data items.
73 73 * If not specified, the searchAttr attribute is used instead.
74 74 */
75 75 labelAttr: string;
76 76
77 77 /**
78 78 * Specifies how to interpret the labelAttr in the data store items.
79 79 * Can be "html" or "text".
80 80 */
81 81 labelType: string;
82 82
83 83 /**
84 84 * Flags to _HasDropDown to limit height of drop down to make it fit in viewport
85 85 */
86 86 maxHeight: number;
87 87
88 88 /**
89 89 * For backwards compatibility let onClick events propagate, even clicks on the down arrow button
90 90 */
91 91 _stopClickEvents: boolean;
92 92
93 93 _getCaretPos(element: HTMLElement): number;
94 94 _setCaretPos(element: HTMLElement, location: number): void;
95 95
96 96 /**
97 97 * Overrides _HasDropDown.loadDropDown().
98 98 */
99 99 loadDropDown(loadCallback: () => void): void;
100 100
101 101 /**
102 102 * signal to _HasDropDown that it needs to call loadDropDown() to load the
103 103 * drop down asynchronously before displaying it
104 104 */
105 105 isLoaded(): boolean;
106 106
107 107 /**
108 108 * Overrides _HasDropDown.closeDropDown(). Closes the drop down (assuming that it's open).
109 109 * This method is the callback when the user types ESC or clicking
110 110 * the button icon while the drop down is open. It's also called by other code.
111 111 */
112 112 closeDropDown(focus?: boolean): void;
113 113
114 114 postMixInProperties(): void;
115 115 postCreate(): void;
116 116
117 117 /**
118 118 * Highlights the string entered by the user in the menu. By default this
119 119 * highlights the first occurrence found. Override this method
120 120 * to implement your custom highlighting.
121 121 */
122 122 doHighlight(label: string, find: string): string;
123 123 reset(): void;
124 124 labelFunc(item: T, store: dojo.store.api.Store<T, Q, O>): string;
125 125
126 126 // set(name: 'value', value: string): this;
127 127 // set(name: 'item', value: T): this;
128 128 // set(name: 'disabled', value: boolean): this;
129 129 // set(name: string, value: any): this;
130 130 // set(values: Object): this;
131 131 }
132 132
133 133 /* dijit/form/_ButtonMixin */
134 134
135 135 interface _ButtonMixin {
136 136 /**
137 137 * A mixin to add a thin standard API wrapper to a normal HTML button
138 138 */
139 139 label: string;
140 140
141 141 /**
142 142 * Type of button (submit, reset, button, checkbox, radio)
143 143 */
144 144 type: string;
145 145 postCreate(): void;
146 146
147 147 /**
148 148 * Callback for when button is clicked.
149 149 * If type="submit", return true to perform submit, or false to cancel it.
150 150 */
151 151 onClick(e: MouseEvent): boolean | void;
152 152 onSetLabel(e: Event): void;
153 153 }
154 154
155 155 /* dijit/form/_CheckBoxMixin */
156 156
157 157 interface _CheckBoxMixin {
158 158 /**
159 159 * type attribute on `<input>` node.
160 160 * Overrides `dijit/form/Button.type`. Users should not change this value.
161 161 */
162 162 type: string;
163 163
164 164 /**
165 165 * As an initialization parameter, equivalent to value field on normal checkbox
166 166 * (if checked, the value is passed as the value when form is submitted).
167 167 */
168 168 value: string;
169 169
170 170 /**
171 171 * Should this widget respond to user input?
172 172 * In markup, this is specified as "readOnly".
173 173 * Similar to disabled except readOnly form values are submitted.
174 174 */
175 175 readOnly: boolean;
176 176
177 177 reset: () => void;
178 178 }
179 179
180 180 /* dijit/form/_ComboBoxMenu */
181 181
182 182 interface _ComboBoxMenu<T = any> extends _WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin<T> {
183 183 templateString: string;
184 184 baseClass: string;
185 185
186 186 /**
187 187 * Add hover CSS
188 188 */
189 189 onHover(node: HTMLElement): void;
190 190
191 191 /**
192 192 * Remove hover CSS
193 193 */
194 194 onUnhover(node: HTMLElement): void;
195 195
196 196 /**
197 197 * Add selected CSS
198 198 */
199 199 onSelect(node: HTMLElement): void;
200 200
201 201 /**
202 202 * Remove selected CSS
203 203 */
204 204 onDeselect(node: HTMLElement): void;
205 205
206 206 /**
207 207 * Handles page-up and page-down keypresses
208 208 */
209 209 _page(up?: boolean): void;
210 210
211 211 /**
212 212 * Handle keystroke event forwarded from ComboBox, returning false if it's
213 213 * a keystroke I recognize and process, true otherwise.
214 214 */
215 215 handleKey(evt: KeyboardEvent): boolean;
216 216
217 217 // set(name: string, value: any): this;
218 218 // set(values: Object): this;
219 219 }
220 220
221 221 interface _ComboBoxMenuConstructor extends _WidgetBaseConstructor<_ComboBoxMenu<any>> {
222 222 new <T = any>(params: Object, srcNodeRef: dojo.NodeOrString): _ComboBoxMenu<T>;
223 223 }
224 224
225 225 /* dijit/form/_ComboBoxMenuMixin */
226 226
227 227 interface _ComboBoxMenuMixin<T = any> {
228 228 /**
229 229 * Holds "next" and "previous" text for paging buttons on drop down
230 230 */
231 231 _messages: { next: string; previous: string; };
232 232
233 233 onClick(node: HTMLElement): void;
234 234
235 235 /**
236 236 * Notifies ComboBox/FilteringSelect that user selected an option.
237 237 */
238 238 onChange(direction: number): void;
239 239
240 240 /**
241 241 * Notifies ComboBox/FilteringSelect that user clicked to advance to next/previous page.
242 242 */
243 243 onPage(direction: number): void;
244 244
245 245 /**
246 246 * Callback from dijit.popup code to this widget, notifying it that it closed
247 247 */
248 248 onClose(): void;
249 249
250 250 /**
251 251 * Fills in the items in the drop down list
252 252 */
253 createOptions(results: T[], options: dojo.store.api.QueryOptions, labelFunc: (item: T) => { html: boolean; label: string; }): void;
253 createOptions(results: T[], options: dojo.store.api.QueryOptions<T>, labelFunc: (item: T) => { html: boolean; label: string; }): void;
254 254
255 255 /**
256 256 * Clears the entries in the drop down list, but of course keeps the previous and next buttons.
257 257 */
258 258 clearResultList(): void;
259 259
260 260 /**
261 261 * Highlight the first real item in the list (not Previous Choices).
262 262 */
263 263 highlightFirstOption(): void;
264 264
265 265 /**
266 266 * Highlight the last real item in the list (not More Choices).
267 267 */
268 268 highlightLastOption(): void;
269 269
270 270 selectFirstNode(): void;
271 271 selectLastNode(): void;
272 272 getHighlightedOption(): HTMLElement;
273 273
274 274 // set(name: 'value', value: Object): this;
275 275 // set(name: string, value: any): this;
276 276 // set(values: Object): this;
277 277 }
278 278
279 279 /* dijit/form/_DateTimeTextBox */
280 280
281 281 interface DateTimeConstraints extends Constraints, dojo.date.DateLocaleFormatOptions { }
282 282
283 283 interface _DateTimeTextBox<T extends _WidgetBase> extends RangeBoundTextBox, _HasDropDown<T> {
284 284 templateString: string;
285 285
286 286 /**
287 287 * Set this textbox to display a down arrow button, to open the drop down list.
288 288 */
289 289 hasDownArrow: boolean;
290 290 cssStateNodes: CSSStateNodes;
291 291
292 292 /**
293 293 * Despite the name, this parameter specifies both constraints on the input
294 294 * (including starting/ending dates/times allowed) as well as
295 295 * formatting options like whether the date is displayed in long (ex: December 25, 2005)
296 296 * or short (ex: 12/25/2005) format. See `dijit/form/_DateTimeTextBox.__Constraints` for details.
297 297 */
298 298 constraints: DateTimeConstraints;
299 299
300 300 /**
301 301 * The constraints without the min/max properties. Used by the compare() method
302 302 */
303 303 _unboundedConstraints: DateTimeConstraints;
304 304
305 305 pattern: (options?: dojo.date.DateLocaleFormatOptions | RangeBoundTextBoxConstraints) => string;
306 306
307 307 /**
308 308 * JavaScript namespace to find calendar routines. If unspecified, uses Gregorian calendar routines
309 309 * at dojo/date and dojo/date/locale.
310 310 */
311 311 datePackage: string;
312 312
313 313 postMixInProperties(): void;
314 314 compare(val1: Date, val2: Date): number;
315 315 autoWidth: boolean;
316 316
317 317 /**
318 318 * Formats the value as a Date, according to specified locale (second argument)
319 319 */
320 320 format: ConstrainedValueFunction<Date, DateTimeConstraints, string>;
321 321
322 322 /**
323 323 * Parses as string as a Date, according to constraints
324 324 */
325 325 parse: ConstrainedValueFunction<string, DateTimeConstraints, Date>;
326 326
327 327 serialize(val: any, options?: dojo.date.StampFormatOptions): string;
328 328
329 329 /**
330 330 * The default value to focus in the popupClass widget when the textbox value is empty.
331 331 */
332 332 dropDownDefaultValue: Date;
333 333
334 334 /**
335 335 * The value of this widget as a JavaScript Date object. Use get("value") / set("value", val) to manipulate.
336 336 * When passed to the parser in markup, must be specified according to `dojo/date/stamp.fromISOString()`
337 337 */
338 338 value: Date;
339 339
340 340 _blankValue: string;
341 341
342 342 /**
343 343 * Name of the popup widget class used to select a date/time.
344 344 * Subclasses should specify this.
345 345 */
346 346 popupClass: string | _WidgetBaseConstructor<T>;
347 347
348 348 /**
349 349 * Specifies constraints.selector passed to dojo.date functions, should be either
350 350 * "date" or "time".
351 351 * Subclass must specify this.
352 352 */
353 353 _selector: string;
354 354 /* TODO: uncomment for TS 1.8 */
355 355 /* _selector: 'data' | 'time'; */
356 356
357 357 buildRendering(): void;
358 358
359 359 /**
360 360 * Runs various tests on the value, checking for invalid conditions
361 361 */
362 362 _isInvalidDate(value: Date): boolean;
363 363
364 364 // get(name: 'displayedValue'): string;
365 365 // get(name: string): any;
366 366
367 367 // set(name: 'displayedValue', value: string): this;
368 368 // set(name: 'dropDownDefaultValue', value: Date): this;
369 369 // set(name: 'value', value: Date | string): this;
370 370 // set(name: 'constraints', value: DateTimeConstraints): this;
371 371 // set(name: string, value: any): this;
372 372 // set(values: Object): this;
373 373 }
374 374
375 375 interface _DateTimeTextBoxConstructor<T extends _WidgetBase> extends _WidgetBaseConstructor<_DateTimeTextBox<T>> { }
376 376
377 377 /* dijit/form/_ExpandingTextAreaMixin */
378 378
379 379 interface _ExpandingTextAreaMixin {
380 380 postCreate(): void;
381 381 startup(): void;
382 382 resize(): void;
383 383 }
384 384
385 385 /* dijit/form/_FormMixin */
386 386
387 387 interface OnValidStateChange {
388 388 (isValid?: boolean): void;
389 389 }
390 390
391 391 interface _FormMixin {
392 392
393 393 /**
394 394 * Will be "Error" if one or more of the child widgets has an invalid value,
395 395 * "Incomplete" if not all of the required child widgets are filled in. Otherwise, "",
396 396 * which indicates that the form is ready to be submitted.
397 397 */
398 398 state: '' | 'Error' | 'Incomplete';
399 399
400 400 /**
401 401 * Returns all form widget descendants, searching through non-form child widgets like BorderContainer
402 402 */
403 403 _getDescendantFormWidgets(children?: _WidgetBase[]): _FormWidget[];
404 404
405 405 reset(): void;
406 406
407 407 /**
408 408 * returns if the form is valid - same as isValid - but
409 409 * provides a few additional (ui-specific) features:
410 410 *
411 411 * 1. it will highlight any sub-widgets that are not valid
412 412 * 2. it will call focus() on the first invalid sub-widget
413 413 */
414 414 validate(): boolean;
415 415
416 416 setValues(val: any): _FormMixin;
417 417 getValues(): any;
418 418
419 419 /**
420 420 * Returns true if all of the widgets are valid.
421 421 * Deprecated, will be removed in 2.0. Use get("state") instead.
422 422 */
423 423 isValid(): boolean;
424 424
425 425 /**
426 426 * Stub function to connect to if you want to do something
427 427 * (like disable/enable a submit button) when the valid
428 428 * state changes on the form as a whole.
429 429 *
430 430 * Deprecated. Will be removed in 2.0. Use watch("state", ...) instead.
431 431 */
432 432 onValidStateChange: OnValidStateChange;
433 433
434 434 /**
435 435 * Compute what this.state should be based on state of children
436 436 */
437 437 _getState(): '' | 'Error' | 'Incomplete';
438 438
439 439 /**
440 440 * Deprecated method. Applications no longer need to call this. Remove for 2.0.
441 441 */
442 442 disconnectChildren(): void;
443 443
444 444 /**
445 445 * You can call this function directly, ex. in the event that you
446 446 * programmatically add a widget to the form *after* the form has been
447 447 * initialized.
448 448 */
449 449 connectChildren(inStartup?: boolean): void;
450 450
451 451 /**
452 452 * Called when child's value or disabled state changes
453 453 */
454 454 _onChildChange(attr?: string): void;
455 455
456 456 startup(): void;
457 457 destroy(preserveDom?: boolean): void;
458 458
459 459 _setValueAttr(value: any): void;
460 460 }
461 461
462 462 interface _FormMixinConstructor extends dojo._base.DeclareConstructor<_FormMixin> { }
463 463
464 464 /* dijit/form/_FormSelectWidget */
465 465
466 466 interface SelectOption {
467 467 value?: string;
468 468 label: string;
469 469 selected?: boolean;
470 470 disabled?: boolean;
471 471 }
472 472
473 interface _FormSelectWidget<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> extends _FormValueWidget {
473 interface _FormSelectWidget<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> extends _FormValueWidget {
474 474 /**
475 475 * Whether or not we are multi-valued
476 476 */
477 477 multiple: boolean;
478 478
479 479 /**
480 480 * The set of options for our select item. Roughly corresponds to
481 481 * the html `<option>` tag.
482 482 */
483 483 options: SelectOption[];
484 484
485 485 /**
486 486 * A store to use for getting our list of options - rather than reading them
487 487 * from the `<option>` html tags. Should support getIdentity().
488 488 * For back-compat store can also be a dojo/data/api/Identity.
489 489 */
490 490 store: dojo.store.api.Store<T, Q, O>;
491 491
492 492 /**
493 493 * A query to use when fetching items from our store
494 494 */
495 495 query: Q;
496 496
497 497 /**
498 498 * Query options to use when fetching from the store
499 499 */
500 500 queryOptions: O;
501 501
502 502 /**
503 503 * The entries in the drop down list come from this attribute in the dojo.store items.
504 504 * If ``store`` is set, labelAttr must be set too, unless store is an old-style
505 505 * dojo.data store rather than a new dojo/store.
506 506 */
507 507 labelAttr: string;
508 508
509 509 /**
510 510 * A callback to do with an onFetch - but before any items are actually
511 511 * iterated over (i.e. to filter even further what you want to add)
512 512 */
513 513 onFetch: (items: T[]) => void;
514 514
515 515 /**
516 516 * Flag to sort the options returned from a store by the label of
517 517 * the store.
518 518 */
519 519 sortByLabel: boolean;
520 520
521 521 /**
522 522 * By default loadChildren is called when the items are fetched from the
523 523 * store. This property allows delaying loadChildren (and the creation
524 524 * of the options/menuitems) until the user clicks the button to open the
525 525 * dropdown.
526 526 */
527 527 loadChildrenOnOpen: boolean;
528 528
529 529 /**
530 530 * This is the `dojo.Deferred` returned by setStore().
531 531 * Calling onLoadDeferred.then() registers your
532 532 * callback to be called only once, when the prior setStore completes.
533 533 */
534 534 onLoadDeferred: dojo.Deferred<void>;
535 535
536 536 /**
537 537 * Returns a given option (or options).
538 538 */
539 539 getOptions(valueOrIdx: string): SelectOption;
540 540 getOptions(valueOrIdx: number): SelectOption;
541 541 getOptions(valueOrIdx: SelectOption): SelectOption;
542 542 getOptions(valueOrIdx: (string | number | SelectOption)[]): SelectOption[];
543 543 getOptions(): SelectOption[];
544 544
545 545 /**
546 546 * Adds an option or options to the end of the select. If value
547 547 * of the option is empty or missing, a separator is created instead.
548 548 * Passing in an array of options will yield slightly better performance
549 549 * since the children are only loaded once.
550 550 */
551 551 addOption(option: SelectOption | SelectOption[]): void;
552 552
553 553 /**
554 554 * Removes the given option or options. You can remove by string
555 555 * (in which case the value is removed), number (in which case the
556 556 * index in the options array is removed), or select option (in
557 557 * which case, the select option with a matching value is removed).
558 558 * You can also pass in an array of those values for a slightly
559 559 * better performance since the children are only loaded once.
560 560 * For numeric option values, specify {value: number} as the argument.
561 561 */
562 562 removeOption(option: string | number | SelectOption | (string | number | SelectOption)[]): void;
563 563
564 564 /**
565 565 * Updates the values of the given option. The option to update
566 566 * is matched based on the value of the entered option. Passing
567 567 * in an array of new options will yield better performance since
568 568 * the children will only be loaded once.
569 569 */
570 570 updateOption(newOption: SelectOption | SelectOption[]): void;
571 571
572 572 /**
573 573 * Deprecated!
574 574 */
575 575 setStore(store: dojo.store.api.Store<T, Q, O>, selectedValue?: T, fetchArgs?: {
576 576 query: Q;
577 577 queryOptions: O;
578 578 onFetch: (items: T[], fetchArgs?: any) => void;
579 579 }): dojo.store.api.Store<T, Q, O>;
580 580
581 581 /**
582 582 * Sets the store you would like to use with this select widget.
583 583 * The selected value is the value of the new store to set. This
584 584 * function returns the original store, in case you want to reuse
585 585 * it or something.
586 586 */
587 587 _deprecatedSetStore(store: dojo.store.api.Store<T, Q, O>, selectedValue?: T, fetchArgs?: {
588 588 query: Q;
589 589 queryOptions: O;
590 590 onFetch: (items: T[], fetchArgs?: any) => void;
591 591 }): dojo.store.api.Store<T, Q, O>;
592 592
593 593 /**
594 594 * Loads the children represented by this widget's options.
595 595 * reset the menu to make it populatable on the next click
596 596 */
597 597 _loadChildren(): void;
598 598
599 599 /**
600 600 * Sets the "selected" class on the item for styling purposes
601 601 */
602 602 _updateSelection(): void;
603 603
604 604 /**
605 605 * Returns the value of the widget by reading the options for
606 606 * the selected flag
607 607 */
608 608 _getValueFromOpts(): string;
609 609
610 610 buildRendering(): void;
611 611
612 612 /**
613 613 * Loads our options and sets up our dropdown correctly. We
614 614 * don't want any content, so we don't call any inherit chain
615 615 * function.
616 616 */
617 617 _fillContent(): void;
618 618
619 619 /**
620 620 * sets up our event handling that we need for functioning
621 621 * as a select
622 622 */
623 623 postCreate(): void;
624 624
625 625 startup(): void;
626 626
627 627 /**
628 628 * Clean up our connections
629 629 */
630 630 destroy(preserveDom?: boolean): void;
631 631
632 632 /**
633 633 * User-overridable function which, for the given option, adds an
634 634 * item to the select. If the option doesn't have a value, then a
635 635 * separator is added in that place. Make sure to store the option
636 636 * in the created option widget.
637 637 */
638 638 _addOptionItem(option: SelectOption): void;
639 639
640 640 /**
641 641 * User-overridable function which, for the given option, removes
642 642 * its item from the select.
643 643 */
644 644 _removeOptionItem(option: SelectOption): void;
645 645
646 646 /**
647 647 * Overridable function which will set the display for the
648 648 * widget. newDisplay is either a string (in the case of
649 649 * single selects) or array of strings (in the case of multi-selects)
650 650 */
651 651 _setDisplay(newDisplay: string | string[]): void;
652 652
653 653 /**
654 654 * Overridable function to return the children that this widget contains.
655 655 */
656 656 _getChildren(): any[];
657 657
658 658 /**
659 659 * hooks into this.attr to provide a mechanism for getting the
660 660 * option items for the current value of the widget.
661 661 */
662 662 _getSelectedOptionsAttr(): SelectOption[];
663 663
664 664 /**
665 665 * a function that will "fake" loading children, if needed, and
666 666 * if we have set to not load children until the widget opens.
667 667 */
668 668 _pseudoLoadChildren(items: T[]): void;
669 669
670 670 /**
671 671 * a function that can be connected to in order to receive a
672 672 * notification that the store has finished loading and all options
673 673 * from that store are available
674 674 */
675 675 onSetStore(): void;
676 676 }
677 677
678 678 /* dijit/form/_FormValueMixin */
679 679
680 680 interface _FormValueMixin extends _FormWidgetMixin {
681 681
682 682 /**
683 683 * Should this widget respond to user input?
684 684 * In markup, this is specified as "readOnly".
685 685 * Similar to disabled except readOnly form values are submitted.
686 686 */
687 687 readOnly: boolean;
688 688
689 689 postCreate(): void;
690 690
691 691 /**
692 692 * Restore the value to the last value passed to onChange
693 693 */
694 694 undo(): void;
695 695
696 696 /**
697 697 * Reset the widget's value to what it was at initialization time
698 698 */
699 699 reset(): void;
700 700
701 701 _hasBeenBlurred?: boolean;
702 702 }
703 703
704 704 /* dijit/form/_FormValueWidget */
705 705
706 706 interface _FormValueWidget extends _FormWidget, _FormValueMixin {
707 707 /**
708 708 * Work around table sizing bugs on IE7 by forcing redraw
709 709 */
710 710 _layoutHackIE7(): void;
711 711
712 712 // set(name: string, value: any): this;
713 713 // set(values: Object): this;
714 714 }
715 715
716 716 interface _FormValueWidgetConstructor extends _WidgetBaseConstructor<_FormValueWidget> { }
717 717
718 718 /* dijit/form/_FormWidget */
719 719
720 720 interface _FormWidget extends _Widget, _TemplatedMixin, _CssStateMixin, _FormWidgetMixin {
721 721 setDisabled(disabled: boolean): void;
722 722 setValue(value: string): void;
723 723 postMixInProperties(): void;
724 724
725 725 // set(name: 'value', value: string): this;
726 726 // set(name: string, value: any): this;
727 727 // set(values: Object): this;
728 728 }
729 729
730 730 interface _FormWidgetConstructor extends _WidgetBaseConstructor<_FormWidget> { }
731 731
732 732 /* dijit/form/_FormWidgetMixin */
733 733
734 734 /**
735 735 * Mixin for widgets corresponding to native HTML elements such as `<checkbox>` or `<button>`,
736 736 * which can be children of a `<form>` node or a `dijit/form/Form` widget.
737 737 *
738 738 * Represents a single HTML element.
739 739 * All these widgets should have these attributes just like native HTML input elements.
740 740 * You can set them during widget construction or afterwards, via `dijit/_WidgetBase.set()`.
741 741 *
742 742 * They also share some common methods.
743 743 */
744 744 interface _FormWidgetMixin {
745 745 /**
746 746 * Name used when submitting form; same as "name" attribute or plain HTML elements
747 747 */
748 748 name: string;
749 749
750 750
751 751 /** Corresponds to the native HTML `<input>` element's attribute. */
752 752 alt: string;
753 753
754 754 /** Corresponds to the native HTML `<input>` element's attribute. */
755 755 value: any;
756 756
757 757 /** Corresponds to the native HTML `<input>` element's attribute. */
758 758 type: string;
759 759
760 760 /** Apply aria-label in markup to the widget's focusNode */
761 761 "aria-label": "focusNode";
762 762
763 763 /** Order fields are traversed when user hits the tab key */
764 764 tabIndex: number;
765 765
766 766 /** Should this widget respond to user input?
767 767 * In markup, this is specified as "disabled='disabled'", or just "disabled".
768 768 */
769 769 disabled: boolean;
770 770
771 771 /** Fires onChange for each value change or only on demand */
772 772 intermediateChanges: boolean;
773 773
774 774 /** On focus, should this widget scroll into view? */
775 775 scrollOnFocus: boolean;
776 776
777 777 _setDisabledAttr(value: boolean): void;
778 778
779 779 _onFocus(by: string): void;
780 780
781 781 /** Tells if this widget is focusable or not. Used internally by dijit.
782 782 * @protected
783 783 */
784 784 isFocusable(): boolean;
785 785
786 786 /** Put focus on this widget */
787 787 focus(): void;
788 788
789 789 /** Compare 2 values (as returned by get('value') for this widget).
790 790 * @protected
791 791 */
792 792 compare(val1: any, val2: any): number;
793 793
794 794 onChange(newValue: any): void;
795 795
796 796 /**
797 797 * Hook so set('value', value) works.
798 798 *
799 799 * Sets the value of the widget.
800 800 * If the value has changed, then fire onChange event, unless priorityChange
801 801 * is specified as null (or false?)
802 802 *
803 803 * @param value
804 804 * @param priorityChange
805 805 */
806 806 _setValueAttr(value: any, priorityChange?: boolean);
807 807
808 808 /**
809 809 * Called when the value of the widget has changed. Saves the new value in this.value,
810 810 * and calls onChange() if appropriate. See _FormWidget._handleOnChange() for details.
811 811 *
812 812 * @param newValue
813 813 * @param priorityChange
814 814 */
815 815 _handleOnChange(newValue: any, priorityChange?: boolean);
816 816 }
817 817
818 818 /* dijit/form/_ListBase */
819 819
820 820 interface _ListBase {
821 821 /**
822 822 * currently selected node
823 823 */
824 824 selected: HTMLElement;
825 825
826 826 /**
827 827 * Select the first displayed item in the list.
828 828 */
829 829 selectFirstNode(): void;
830 830
831 831 /**
832 832 * Select the last displayed item in the list
833 833 */
834 834 selectLastNode(): void;
835 835
836 836 /**
837 837 * Select the item just below the current selection.
838 838 * If nothing selected, select first node.
839 839 */
840 840 selectNextNode(): void;
841 841
842 842 /**
843 843 * Select the item just above the current selection.
844 844 * If nothing selected, select last node (if
845 845 * you select Previous and try to keep scrolling up the list).
846 846 */
847 847 selectPreviousNode(): void;
848 848
849 849 // set(name: 'selected', value: HTMLElement): this;
850 850 // set(name: string, value: any): this;
851 851 // set(values: Object): this;
852 852 }
853 853
854 854 /* dijit/form/_ListMouseMixin */
855 855
856 856 interface _ListMouseMixin extends _ListBase {
857 857 postCreate(): void;
858 858 }
859 859
860 860 /* dijit/form/_RadioButtonMixin */
861 861
862 862 interface _RadioButtonMixin {
863 863 /**
864 864 * type attribute on `<input>` node.
865 865 * Users should not change this value.
866 866 */
867 867 type: string;
868 868 }
869 869
870 870 /* dijit/form/_SearchMixin */
871 871
872 interface _SearchMixin<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> {
872 interface _SearchMixin<T extends Object, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> {
873 873 /**
874 874 * Argument to data provider.
875 875 * Specifies maximum number of search results to return per query
876 876 */
877 877 pageSize: number;
878 878
879 879 /**
880 880 * Reference to data provider object used by this ComboBox.
881 881 * The store must accept an object hash of properties for its query. See `query` and `queryExpr` for details.
882 882 */
883 883 store: dojo.store.api.Store<T, Q, O>;
884 884
885 885 /**
886 886 * Mixin to the store's fetch.
887 887 * For example, to set the sort order of the ComboBox menu, pass:
888 888 * { sort: [{attribute:"name",descending: true}] }
889 889 * To override the default queryOptions so that deep=false, do:
890 890 * { queryOptions: {ignoreCase: true, deep: false} }
891 891 */
892 892 fetchProperties: { [property: string]: any };
893 893
894 894 /**
895 895 * A query that can be passed to `store` to initially filter the items.
896 896 * ComboBox overwrites any reference to the `searchAttr` and sets it to the `queryExpr` with the user's input substituted.
897 897 */
898 898 query: Q;
899 899
900 900 /**
901 901 * Alternate to specifying a store. Id of a dijit/form/DataList widget.
902 902 */
903 903 list: string;
904 904
905 905 /**
906 906 * Delay in milliseconds between when user types something and we start
907 907 * searching based on that value
908 908 */
909 909 searchDelay: number;
910 910
911 911 /**
912 912 * Search for items in the data store where this attribute (in the item)
913 913 * matches what the user typed
914 914 */
915 915 searchAttr: string;
916 916
917 917 /**
918 918 * This specifies what query is sent to the data store,
919 919 * based on what the user has typed. Changing this expression will modify
920 920 * whether the results are only exact matches, a "starting with" match,
921 921 * etc.
922 922 * `${0}` will be substituted for the user text.
923 923 * `*` is used for wildcards.
924 924 * `${0}*` means "starts with", `*${0}*` means "contains", `${0}` means "is"
925 925 */
926 926 queryExpr: string;
927 927
928 928 /**
929 929 * Set true if the query should ignore case when matching possible items
930 930 */
931 931 ignoreCase: boolean;
932 932
933 933 /**
934 934 * Helper function to convert a simple pattern to a regular expression for matching.
935 935 */
936 936 _patternToRegExp(pattern: string): RegExp;
937 937
938 938 _abortQuery(): void;
939 939
940 940 /**
941 941 * Handles input (keyboard/paste) events
942 942 */
943 943 _processInput(e: KeyboardEvent): void;
944 944
945 945 /**
946 946 * Callback when a search completes.
947 947 */
948 948 onSearch(results: T[], query: Q, options: O): void;
949 949
950 950 _startSearchFromInput(): void;
951 951
952 952 /**
953 953 * Starts a search for elements matching text (text=="" means to return all items
954 954 * and calls onSearch(...) when the search completes, to display the results.
955 955 */
956 956 _startSearch(text: string): void;
957 957
958 958 postMixInProperties(): void;
959 959
960 960 // set(name: 'list', value: string): this;
961 961 // set(name: string, value: any): this;
962 962 // set(values: Object): this;
963 963 }
964 964
965 965 /* dijit/form/_Spinner */
966 966
967 967 interface AdjustFunction {
968 968 (val: any, delta: number): any;
969 969 }
970 970
971 971 interface _Spinner extends RangeBoundTextBox {
972 972 /**
973 973 * Number of milliseconds before a held arrow key or up/down button becomes typematic
974 974 */
975 975 defaultTimeout: number;
976 976
977 977 /**
978 978 * minimum number of milliseconds that typematic event fires when held key or button is held
979 979 */
980 980 minimumTimeout: number;
981 981
982 982 /**
983 983 * Fraction of time used to change the typematic timer between events.
984 984 * 1.0 means that each typematic event fires at defaultTimeout intervals.
985 985 * Less than 1.0 means that each typematic event fires at an increasing faster rate.
986 986 */
987 987 timeoutChangeRate: number;
988 988
989 989 /**
990 990 * Adjust the value by this much when spinning using the arrow keys/buttons
991 991 */
992 992 smallDelta: number;
993 993
994 994 /**
995 995 * Adjust the value by this much when spinning using the PgUp/Dn keys
996 996 */
997 997 largeDelta: number;
998 998
999 999 templateString: string;
1000 1000 baseClass: string;
1001 1001 cssStateNodes: CSSStateNodes;
1002 1002
1003 1003 /**
1004 1004 * Overridable function used to adjust a primitive value(Number/Date/...) by the delta amount specified.
1005 1005 * The val is adjusted in a way that makes sense to the object type.
1006 1006 */
1007 1007 adjust: AdjustFunction;
1008 1008
1009 1009 postCreate(): void;
1010 1010 }
1011 1011
1012 1012 interface _SpinnerConstrctor extends _WidgetBaseConstructor<_Spinner> { }
1013 1013
1014 1014 /* dijit/form/_TextBoxMixin */
1015 1015
1016 1016 interface _TextBoxMixin<C extends Constraints = Constraints> {
1017 1017 /**
1018 1018 * Removes leading and trailing whitespace if true. Default is false.
1019 1019 */
1020 1020 trim: boolean;
1021 1021
1022 1022 /**
1023 1023 * Converts all characters to uppercase if true. Default is false.
1024 1024 */
1025 1025 uppercase: boolean;
1026 1026
1027 1027 /**
1028 1028 * Converts all characters to lowercase if true. Default is false.
1029 1029 */
1030 1030 lowercase: boolean;
1031 1031
1032 1032 /**
1033 1033 * Converts the first character of each word to uppercase if true.
1034 1034 */
1035 1035 propercase: boolean;
1036 1036
1037 1037 /**
1038 1038 * HTML INPUT tag maxLength declaration.
1039 1039 */
1040 1040 maxLength: string;
1041 1041
1042 1042 /**
1043 1043 * If true, all text will be selected when focused with mouse
1044 1044 */
1045 1045 selectOnClick: boolean;
1046 1046
1047 1047 /**
1048 1048 * Defines a hint to help users fill out the input field (as defined in HTML 5).
1049 1049 * This should only contain plain text (no html markup).
1050 1050 */
1051 1051 placeHolder: string;
1052 1052
1053 1053 /**
1054 1054 * For subclasses like ComboBox where the displayed value
1055 1055 * (ex: Kentucky) and the serialized value (ex: KY) are different,
1056 1056 * this represents the displayed value.
1057 1057 *
1058 1058 * Setting 'displayedValue' through set('displayedValue', ...)
1059 1059 * updates 'value', and vice-versa. Otherwise 'value' is updated
1060 1060 * from 'displayedValue' periodically, like onBlur etc.
1061 1061 */
1062 1062 displayedValue: string;
1063 1063
1064 1064 /**
1065 1065 * Replaceable function to convert a value to a properly formatted string.
1066 1066 */
1067 1067 format: ConstrainedValueFunction<any, C, any>;
1068 1068
1069 1069 /**
1070 1070 * Replaceable function to convert a formatted string to a value
1071 1071 */
1072 1072 parse: ConstrainedValueFunction<any, C, any>;
1073 1073
1074 1074 /**
1075 1075 * Connect to this function to receive notifications of various user data-input events.
1076 1076 * Return false to cancel the event and prevent it from being processed.
1077 1077 * Note that although for historical reasons this method is called `onInput()`, it doesn't
1078 1078 * correspond to the standard DOM "input" event, because it occurs before the input has been processed.
1079 1079 */
1080 1080 onInput(e: InputEvent): void;
1081 1081
1082 1082 postCreate(): void;
1083 1083
1084 1084 /**
1085 1085 * if the textbox is blank, what value should be reported
1086 1086 */
1087 1087 _blankValue: string;
1088 1088
1089 1089 /**
1090 1090 * Auto-corrections (such as trimming) that are applied to textbox
1091 1091 * value on blur or form submit.
1092 1092 */
1093 1093 filter<T>(val: T): T;
1094 1094 filter<T extends number>(value: T): T;
1095 1095
1096 1096 _setBlurValue(): void;
1097 1097
1098 1098 reset(): void;
1099 1099 }
1100 1100
1101 1101 /* dijit/form/_ToggleButtonMixin */
1102 1102
1103 1103 interface _ToggleButtonMixin {
1104 1104 /**
1105 1105 * Corresponds to the native HTML `<input>` element's attribute.
1106 1106 * In markup, specified as "checked='checked'" or just "checked".
1107 1107 * True if the button is depressed, or the checkbox is checked,
1108 1108 * or the radio button is selected, etc.
1109 1109 */
1110 1110 checked: boolean;
1111 1111
1112 1112 postCreate(): void;
1113 1113
1114 1114 /**
1115 1115 * Reset the widget's value to what it was at initialization time
1116 1116 */
1117 1117 reset(): void;
1118 1118
1119 1119 _hasBeenBlurred?: boolean;
1120 1120 }
1121 1121
1122 1122 /* dijit/form/Button */
1123 1123
1124 1124 interface Button extends _FormWidget, _ButtonMixin {
1125 1125 /**
1126 1126 * Set this to true to hide the label text and display only the icon.
1127 1127 * (If showLabel=false then iconClass must be specified.)
1128 1128 * Especially useful for toolbars.
1129 1129 * If showLabel=true, the label will become the title (a.k.a. tooltip/hint)
1130 1130 */
1131 1131 showLabel: boolean;
1132 1132
1133 1133 /**
1134 1134 * Class to apply to DOMNode in button to make it display an icon
1135 1135 */
1136 1136 iconClass: string;
1137 1137
1138 1138 baseClass: string;
1139 1139 templateString: string;
1140 1140 postCreate(): void;
1141 1141 setLabel(content: string): void;
1142 1142 onLabelSet(e: Event): void;
1143 1143
1144 1144 onClick(e: MouseEvent): boolean | void;
1145 1145
1146 1146 // set(name: 'showLabel', value: boolean): this;
1147 1147 // set(name: 'value', value: string): this;
1148 1148 // set(name: 'name', value: string): this;
1149 1149 // set(name: 'label', value: string): this;
1150 1150 // set(name: string, value: any): this;
1151 1151 // set(values: Object): this;
1152 1152 }
1153 1153
1154 1154 interface ButtonConstructor extends _WidgetBaseConstructor<Button> { }
1155 1155
1156 1156 /* dijit/form/CheckBox */
1157 1157
1158 1158 interface CheckBox extends ToggleButton, _CheckBoxMixin {
1159 1159 templateString: string;
1160 1160 baseClass: string;
1161 1161 postMixInProperties(): void;
1162 1162 value: string;
1163 1163
1164 1164 // set(name: 'value', value: string | boolean): this;
1165 1165 // set(name: string, value: any): this;
1166 1166 // set(values: Object): this;
1167 1167 }
1168 1168
1169 1169 interface CheckBoxConstructor extends _WidgetBaseConstructor<CheckBox> { }
1170 1170
1171 1171 /* dijit/form/ComboBox */
1172 1172
1173 interface ComboBox<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions, C extends Constraints = Constraints> extends ValidationTextBox<C>, ComboBoxMixin<T, Q, O> {
1173 interface ComboBox<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>, C extends Constraints = Constraints> extends ValidationTextBox<C>, ComboBoxMixin<T, Q, O> {
1174 1174 // set(name: string, value: any): this;
1175 1175 // set(values: Object): this;
1176 1176 }
1177 1177
1178 1178 interface ComboBoxConstructor extends _WidgetBaseConstructor<ComboBox<any>> {
1179 new <T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions, C extends Constraints = Constraints>(params: Object, srcNodeRef: dojo.NodeOrString): ComboBox<T, Q, O, C>;
1179 new <T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>, C extends Constraints = Constraints>(params: Object, srcNodeRef: dojo.NodeOrString): ComboBox<T, Q, O, C>;
1180 1180 }
1181 1181
1182 1182 /* dijit/form/ComboBoxMixin */
1183 1183
1184 interface ComboBoxMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> extends _HasDropDown<_ComboBoxMenu<T>>, _AutoCompleterMixin<T, Q, O> {
1184 interface ComboBoxMixin<T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> extends _HasDropDown<_ComboBoxMenu<T>>, _AutoCompleterMixin<T, Q, O> {
1185 1185
1186 1186 /**
1187 1187 * Dropdown widget class used to select a date/time.
1188 1188 * Subclasses should specify this.
1189 1189 */
1190 1190 dropDownClass: _ComboBoxMenu<T>;
1191 1191
1192 1192 /**
1193 1193 * Set this textbox to have a down arrow button, to display the drop down list.
1194 1194 * Defaults to true.
1195 1195 */
1196 1196 hasDownArrow: boolean;
1197 1197
1198 1198 templateString: string;
1199 1199 baseClass: string;
1200 1200
1201 1201 /**
1202 1202 * Reference to data provider object used by this ComboBox.
1203 1203 *
1204 1204 * Should be dojo/store/api/Store, but dojo/data/api/Read supported
1205 1205 * for backwards compatibility.
1206 1206 */
1207 1207 store: dojo.store.api.Store<T, Q, O>;
1208 1208
1209 1209 cssStateNodes: CSSStateNodes;
1210 1210 postMixInProperties(): void;
1211 1211 buildRendering(): void;
1212 1212 }
1213 1213
1214 1214 interface ComboBoxMixinConstructor<T = any, U extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, V = any> extends _WidgetBaseConstructor<ComboBoxMixin<T, U, V>> { }
1215 1215
1216 1216 /* dijit/form/CurrencyTextBox */
1217 1217
1218 1218 interface CurrencyTextBoxConstraints extends NumberTextBoxConstraints, dojo.CurrencyFormatOptions, dojo.CurrencyParseOptions {
1219 1219 }
1220 1220
1221 1221 interface CurrencyTextBox extends NumberTextBox {
1222 1222 /**
1223 1223 * the [ISO4217](http://en.wikipedia.org/wiki/ISO_4217) currency code, a three letter sequence like "USD"
1224 1224 */
1225 1225 currency: string;
1226 1226
1227 1227 /**
1228 1228 * Despite the name, this parameter specifies both constraints on the input
1229 1229 * (including minimum/maximum allowed values) as well as
1230 1230 * formatting options. See `dijit/form/CurrencyTextBox.__Constraints` for details.
1231 1231 */
1232 1232 constraints: CurrencyTextBoxConstraints;
1233 1233
1234 1234 baseClass: string;
1235 1235
1236 1236 _formatter: (value: number, options?: dojo.CurrencyFormatOptions) => string;
1237 1237 _parser: (expression: string, options?: dojo.CurrencyParseOptions) => number;
1238 1238 _regExpGenerator: (options?: dojo.NumberRegexpOptions) => string;
1239 1239
1240 1240 /**
1241 1241 * Parses string value as a Currency, according to the constraints object
1242 1242 */
1243 1243 parse(value: string, constraints: CurrencyTextBoxConstraints): string;
1244 1244 }
1245 1245
1246 1246 interface CurrencyTextBoxConstructor extends _WidgetBaseConstructor<CurrencyTextBox> { }
1247 1247
1248 1248 /* dijit/form/DataList */
1249 1249
1250 1250 interface DataList<T extends Object> extends dojo.store.Memory<T> {
1251 1251 /**
1252 1252 * Get the option marked as selected, like `<option selected>`.
1253 1253 * Not part of dojo.data API.
1254 1254 */
1255 1255 fetchSelectedItem(): T;
1256 1256 }
1257 1257
1258 1258 interface DataListConstructor {
1259 1259 new <T extends Object>(params: Object, srcNodeRef: dojo.NodeOrString): DataList<T>;
1260 1260 }
1261 1261
1262 1262 /* dijit/form/DateTextBox */
1263 1263
1264 1264 interface DateTextBox extends _DateTimeTextBox<Calendar> {
1265 1265 baseClass: string;
1266 1266 popupClass: CalendarConstructor;
1267 1267 _selector: string;
1268 1268 maxHeight: number;
1269 1269
1270 1270 /**
1271 1271 * The value of this widget as a JavaScript Date object, with only year/month/day specified.`
1272 1272 */
1273 1273 value: Date;
1274 1274 }
1275 1275
1276 1276 interface DateTextBoxConstructor extends _WidgetBaseConstructor<DateTextBox> { }
1277 1277
1278 1278 /* dijit/form/DropDownButton */
1279 1279
1280 1280 interface DropDownButton<T extends _WidgetBase> extends Button, _Container, _HasDropDown<T> {
1281 1281 baseClass: string;
1282 1282 templateString: string;
1283 1283
1284 1284 /**
1285 1285 * Overrides _TemplatedMixin#_fillContent().
1286 1286 * My inner HTML possibly contains both the button label and/or a drop down widget, like
1287 1287 * <DropDownButton> <span>push me</span> <Menu> ... </Menu> </DropDownButton>
1288 1288 */
1289 1289 _fillContent(): void;
1290 1290 startup(): void;
1291 1291
1292 1292 /**
1293 1293 * Returns whether or not we are loaded - if our dropdown has an href,
1294 1294 * then we want to check that.
1295 1295 */
1296 1296 isLoaded(): boolean;
1297 1297
1298 1298 /**
1299 1299 * Default implementation assumes that drop down already exists,
1300 1300 * but hasn't loaded it's data (ex: ContentPane w/href).
1301 1301 * App must override if the drop down is lazy-created.
1302 1302 */
1303 1303 loadDropDown(callback: () => void): void;
1304 1304
1305 1305 /**
1306 1306 * Overridden so that focus is handled by the _HasDropDown mixin, not by
1307 1307 * the _FormWidget mixin.
1308 1308 */
1309 1309 isFocusable(): boolean;
1310 1310 }
1311 1311
1312 1312 interface DropDownButtonConstructor extends _WidgetBaseConstructor<DropDownButton<any>> {
1313 1313 new <T extends _WidgetBase>(params: Object, srcNodeRef: dojo.NodeOrString): DropDownButton<T>;
1314 1314 }
1315 1315
1316 1316 /* dijit/form/FilteringSelect */
1317 1317
1318 interface FilteringSelect<C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions> extends MappedTextBox<C>, ComboBoxMixin<T, Q, O> {
1318 interface FilteringSelect<C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions<T>> extends MappedTextBox<C>, ComboBoxMixin<T, Q, O> {
1319 1319 /**
1320 1320 * True (default) if user is required to enter a value into this field.
1321 1321 */
1322 1322 required: boolean;
1323 1323
1324 1324 _lastDisplayedValue: string;
1325 1325 _isValidSubset(): boolean;
1326 1326 isValid(): boolean;
1327 1327 _refreshState(): void;
1328 1328
1329 1329 /**
1330 1330 * Callback from dojo.store after lookup of user entered value finishes
1331 1331 */
1332 1332 _callbackSetLabel(result: T[], query: Q, options: O, priorityChange?: boolean): void;
1333 1333
1334 1334 _openResultList(results: T[], query: Q, options: O): void;
1335 1335 undo(): void;
1336 1336
1337 1337 // set(name: 'displayedValue', value: string): this;
1338 1338 // set(name: 'item', value: T): this;
1339 1339 // set(name: string, value: any): this;
1340 1340 // set(values: Object): this;
1341 1341 }
1342 1342
1343 1343 interface FilteringSelectConstructor extends _WidgetBaseConstructor<FilteringSelect<any, any, any, any>> {
1344 new <C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions>(params: Object, srcNodeRef: dojo.NodeOrString): FilteringSelect<C, T, Q, O>;
1344 new <C extends Constraints, T extends Object, Q extends string | Object | Function, O extends dojo.store.api.QueryOptions<T>>(params: Object, srcNodeRef: dojo.NodeOrString): FilteringSelect<C, T, Q, O>;
1345 1345 }
1346 1346
1347 1347 /* dijit/form/Form */
1348 1348
1349 1349 interface Form extends _Widget, _TemplatedMixin, _FormMixin, layout._ContentPaneResizeMixin {
1350 1350 name?: string;
1351 1351 action?: string;
1352 1352 method?: string;
1353 1353 encType?: string;
1354 1354 'accept-charset'?: string;
1355 1355 accept?: string;
1356 1356 target?: string;
1357 1357 templateString: string;
1358 1358
1359 1359 /**
1360 1360 * Deprecated: use submit()
1361 1361 */
1362 1362 execute(formContents: Object): void;
1363 1363
1364 1364 /**
1365 1365 * Deprecated: use onSubmit()
1366 1366 */
1367 1367 onExecute(): void;
1368 1368
1369 1369 /**
1370 1370 * restores all widget values back to their init values,
1371 1371 * calls onReset() which can cancel the reset by returning false
1372 1372 */
1373 1373 reset(e?: Event): void;
1374 1374
1375 1375 /**
1376 1376 * Callback when user resets the form. This method is intended
1377 1377 * to be over-ridden. When the `reset` method is called
1378 1378 * programmatically, the return value from `onReset` is used
1379 1379 * to compute whether or not resetting should proceed
1380 1380 */
1381 1381 onReset(e?: Event): boolean;
1382 1382
1383 1383 /**
1384 1384 * Callback when user submits the form.
1385 1385 */
1386 1386 onSubmit(e?: Event): boolean;
1387 1387
1388 1388 /**
1389 1389 * programmatically submit form if and only if the `onSubmit` returns true
1390 1390 */
1391 1391 submit(): void;
1392 1392 }
1393 1393
1394 1394 interface FormConstructor extends _WidgetBaseConstructor<Form> { }
1395 1395
1396 1396 /* dijit/form/HorizontalRule */
1397 1397
1398 1398 /**
1399 1399 * Hash marks for `dijit/form/HorizontalSlider`
1400 1400 */
1401 1401 interface HorizontalRule extends _Widget, _TemplatedMixin {
1402 1402 /**
1403 1403 * Number of hash marks to generate
1404 1404 */
1405 1405 count: number;
1406 1406
1407 1407 /**
1408 1408 * For HorizontalSlider, this is either "topDecoration" or "bottomDecoration", and indicates whether this rule goes above or below the slider.
1409 1409 */
1410 1410 container: string;
1411 1411
1412 1412 /**
1413 1413 * CSS style to apply to individual hash marks
1414 1414 */
1415 1415 ruleStyle: string;
1416 1416
1417 1417 _positionPrefix: string;
1418 1418 _positionSuffix: string;
1419 1419 _suffix: string;
1420 1420
1421 1421 _genHTML(pos: number): string;
1422 1422
1423 1423 /**
1424 1424 * VerticalRule will override this...
1425 1425 */
1426 1426 _isHorizontal: boolean;
1427 1427 }
1428 1428
1429 1429 interface HorizontalRuleConstructor extends _WidgetBaseConstructor<HorizontalRule> { }
1430 1430
1431 1431 /* dijit/form/HorizontalRuleLabels */
1432 1432
1433 1433 /**
1434 1434 * Labels for `dijit/form/HorizontalSlider`
1435 1435 */
1436 1436 interface HorizontalRuleLabels extends HorizontalRule {
1437 1437 /**
1438 1438 * CSS style to apply to individual text labels
1439 1439 */
1440 1440 labelStyle: string;
1441 1441
1442 1442 /**
1443 1443 * Array of text labels to render - evenly spaced from left-to-right or bottom-to-top.
1444 1444 * Alternately, minimum and maximum can be specified, to get numeric labels.
1445 1445 */
1446 1446 labels: string[];
1447 1447
1448 1448 /**
1449 1449 * Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified
1450 1450 */
1451 1451 numericMargin: number;
1452 1452
1453 1453 /**
1454 1454 * Leftmost label value for generated numeric labels when labels[] are not specified
1455 1455 */
1456 1456 minimum: number;
1457 1457
1458 1458 /**
1459 1459 * Rightmost label value for generated numeric labels when labels[] are not specified
1460 1460 */
1461 1461 maximum: number;
1462 1462
1463 1463 /**
1464 1464 * pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified
1465 1465 */
1466 1466 constraints: { pattern: string };
1467 1467
1468 1468 /**
1469 1469 * Returns the value to be used in HTML for the label as part of the left: attribute
1470 1470 */
1471 1471 _calcPosition(pos: number): number;
1472 1472
1473 1473 _genHTML(pos: number, ndx?: number): string;
1474 1474
1475 1475 /**
1476 1476 * extension point for bidi code
1477 1477 */
1478 1478 _genDirectionHTML(label: string): string;
1479 1479
1480 1480 /**
1481 1481 * Overridable function to return array of labels to use for this slider.
1482 1482 * Can specify a getLabels() method instead of a labels[] array, or min/max attributes.
1483 1483 */
1484 1484 getLabels(): string[];
1485 1485 }
1486 1486
1487 1487 interface HorizontalRuleLabelsConstructor extends _WidgetBaseConstructor<HorizontalRuleLabels> { }
1488 1488
1489 1489 /* dijit/form/HorizontalSlider */
1490 1490
1491 1491 interface _SliderMover extends dojo.dnd.Mover { }
1492 1492
1493 1493 /**
1494 1494 * A form widget that allows one to select a value with a horizontally draggable handle
1495 1495 */
1496 1496 interface HorizontalSlider extends _FormValueWidget, _Container {
1497 1497 /**
1498 1498 * Show increment/decrement buttons at the ends of the slider?
1499 1499 */
1500 1500 showButtons: boolean;
1501 1501
1502 1502 /**
1503 1503 * The minimum value the slider can be set to.
1504 1504 */
1505 1505 minimum: number;
1506 1506
1507 1507 /**
1508 1508 * The maximum value the slider can be set to.
1509 1509 */
1510 1510 maximum: number;
1511 1511
1512 1512 /**
1513 1513 * If specified, indicates that the slider handle has only 'discreteValues' possible positions, and that after dragging the handle, it will snap to the nearest possible position.
1514 1514 * Thus, the slider has only 'discreteValues' possible values.
1515 1515 *
1516 1516 * For example, if minimum=10, maxiumum=30, and discreteValues=3, then the slider handle has three possible positions, representing values 10, 20, or 30.
1517 1517 *
1518 1518 * If discreteValues is not specified or if it's value is higher than the number of pixels in the slider bar, then the slider handle can be moved freely, and the slider's value will be computed/reported based on pixel position (in this case it will likely be fractional, such as 123.456789).
1519 1519 */
1520 1520 discreteValues: number;
1521 1521
1522 1522 /**
1523 1523 * If discreteValues is also specified, this indicates the amount of clicks (ie, snap positions) that the slider handle is moved via pageup/pagedown keys.
1524 1524 * If discreteValues is not specified, it indicates the number of pixels.
1525 1525 */
1526 1526 pageIncrement: number;
1527 1527
1528 1528 /**
1529 1529 * If clicking the slider bar changes the value or not
1530 1530 */
1531 1531 clickSelect: boolean;
1532 1532
1533 1533 /**
1534 1534 * The time in ms to take to animate the slider handle from 0% to 100%, when clicking the slider bar to make the handle move.
1535 1535 */
1536 1536 slideDuration: number;
1537 1537
1538 1538 _mousePixelCoord: string;
1539 1539 _pixelCount: string;
1540 1540 _startingPixelCoord: string;
1541 1541 _handleOffsetCoord: string;
1542 1542 _progressPixelSize: string;
1543 1543
1544 1544 _onKeyUp(e: Event): void;
1545 1545 _onKeyDown(e: Event): void;
1546 1546 _onHandleClick(e: Event): void;
1547 1547
1548 1548 /**
1549 1549 * Returns true if direction is from right to left
1550 1550 */
1551 1551 _isReversed(): boolean;
1552 1552
1553 1553 _onBarClick(e: Event): void;
1554 1554
1555 1555 _setPixelValue(pixelValue: number, maxPixels: number, priorityChange?: boolean): void;
1556 1556
1557 1557 _setValueAttr(value: number, priorityChange?: boolean): void;
1558 1558
1559 1559 _bumpValue(signedChange: number, priorityChange: boolean): void;
1560 1560
1561 1561 _onClkBumper(val: any): void;
1562 1562 _onClkIncBumper(): void;
1563 1563 _onClkDecBumper(): void;
1564 1564
1565 1565 decrement(e: Event): void;
1566 1566 increment(e: Event): void;
1567 1567
1568 1568 _mouseWheeled(evt: Event): void;
1569 1569
1570 1570 _typematicCallback(count: number, button: Element, e: Event): void;
1571 1571 }
1572 1572
1573 1573 interface HorizontalSliderConstructor extends _WidgetBaseConstructor<HorizontalSlider> {
1574 1574 /**
1575 1575 * for monkey patching
1576 1576 */
1577 1577 _Mover: _SliderMover;
1578 1578 }
1579 1579
1580 1580 /* dijit/form/MappedTextBox */
1581 1581
1582 1582 interface MappedTextBox<C extends Constraints> extends ValidationTextBox<C> {
1583 1583 postMixInProperties(): void;
1584 1584 serialize: SerializationFunction;
1585 1585 toString(): string;
1586 1586 validate(isFocused?: boolean): boolean;
1587 1587 buildRendering(): void;
1588 1588 reset(): void;
1589 1589 }
1590 1590
1591 1591 interface MappedTextBoxConstructor extends _WidgetBaseConstructor<MappedTextBox<Constraints>> {
1592 1592 new <C extends Constraints>(params: Object, srcNodeRef: dojo.NodeOrString): MappedTextBox<C>;
1593 1593 }
1594 1594
1595 1595 /* dijit/form/NumberSpinner */
1596 1596
1597 1597 interface NumberSpinner extends _Spinner, NumberTextBoxMixin {
1598 1598 constraints: NumberTextBoxConstraints;
1599 1599 baseClass: string;
1600 1600 adjust(val: any, delta: number): any;
1601 1601
1602 1602 /* overrides */
1603 1603 pattern: ConstraintsToRegExpString<NumberTextBoxConstraints>;
1604 1604 parse(value: string, constraints: NumberTextBoxConstraints): string;
1605 1605 format(value: number, constraints: NumberTextBoxConstraints): string;
1606 1606 filter(value: number): number;
1607 1607 value: number;
1608 1608 }
1609 1609
1610 1610 interface NumberSpinnerConstructor extends _WidgetBaseConstructor<NumberSpinner> { }
1611 1611
1612 1612 /* dijit/form/NumberTextBox */
1613 1613
1614 1614 interface NumberTextBoxConstraints extends RangeBoundTextBoxConstraints, dojo.NumberFormatOptions, dojo.NumberParseOptions { }
1615 1615
1616 1616 interface NumberTextBoxMixin {
1617 1617 pattern: ConstraintsToRegExpString<NumberTextBoxConstraints>;
1618 1618 constraints: NumberTextBoxConstraints;
1619 1619 value: number;
1620 1620 editOptions: { pattern: string };
1621 1621 _formatter: (value: number, options?: dojo.NumberFormatOptions) => string;
1622 1622 _regExpGenerator: (options?: dojo.NumberRegexpOptions) => string;
1623 1623 _decimalInfo: (constraints: Constraints) => { sep: string; places: number; };
1624 1624 postMixInProperties(): void;
1625 1625 format(value: number, constraints: NumberTextBoxConstraints): string;
1626 1626 _parser: (expression: string, options?: dojo.NumberParseOptions) => number;
1627 1627 parse(value: string, constraints: dojo.NumberParseOptions): string;
1628 1628 filter(value: number): number;
1629 1629 serialize: SerializationFunction;
1630 1630 isValid(isFocused: boolean): boolean;
1631 1631 }
1632 1632
1633 1633 interface NumberTextBoxMixinConstructor extends _WidgetBaseConstructor<NumberTextBoxMixin> { }
1634 1634
1635 1635 interface NumberTextBox extends RangeBoundTextBox, NumberTextBoxMixin {
1636 1636 constraints: NumberTextBoxConstraints;
1637 1637 pattern: ConstraintsToRegExpString<NumberTextBoxConstraints>;
1638 1638 parse(value: string, constraints: dojo.NumberParseOptions): string;
1639 1639 format(value: number, constraints: dojo.NumberFormatOptions): string;
1640 1640 value: number;
1641 1641 filter(value: number): number;
1642 1642 }
1643 1643
1644 1644 interface NumberTextBoxConstructor extends _WidgetBaseConstructor<NumberTextBox> {
1645 1645 Mixin: NumberTextBoxMixinConstructor;
1646 1646 }
1647 1647
1648 1648 /* dijit/form/RadioButton */
1649 1649
1650 1650 interface RadioButton extends CheckBox, _RadioButtonMixin {
1651 1651 baseClass: string;
1652 1652 }
1653 1653
1654 1654 interface RadioButtonConstructor extends _WidgetBaseConstructor<RadioButton> { }
1655 1655
1656 1656 /* dijit/form/RangeBoundTextBox */
1657 1657
1658 1658 interface RangeBoundTextBoxConstraints extends Constraints {
1659 1659 min?: number;
1660 1660 max?: number;
1661 1661 }
1662 1662
1663 1663 interface RangeBoundTextBox extends MappedTextBox<RangeBoundTextBoxConstraints> {
1664 1664 /**
1665 1665 * The message to display if value is out-of-range
1666 1666 */
1667 1667 rangeMessage: string;
1668 1668
1669 1669 /**
1670 1670 * Overridable function used to validate the range of the numeric input value.
1671 1671 */
1672 1672 rangeCheck(primative: number, constraints: RangeBoundTextBoxConstraints): boolean;
1673 1673
1674 1674 /**
1675 1675 * Tests if the value is in the min/max range specified in constraints
1676 1676 */
1677 1677 isInRange(isFocused: boolean): boolean;
1678 1678
1679 1679 /**
1680 1680 * Returns true if the value is out of range and will remain
1681 1681 * out of range even if the user types more characters
1682 1682 */
1683 1683 _isDefinitelyOutOfRange(): boolean;
1684 1684
1685 1685 isValid(isFocused: boolean): boolean;
1686 1686 getErrorMessage(isFocused: boolean): string;
1687 1687 postMixInProperties(): void;
1688 1688 }
1689 1689
1690 1690 interface RangeBoundTextBoxConstructor extends _WidgetBaseConstructor<RangeBoundTextBox> { }
1691 1691
1692 1692 /* dijit/form/Select */
1693 1693
1694 interface Select<T extends Object, Q extends dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions, U extends dijit._WidgetBase> extends _FormSelectWidget<T, Q, O>, _HasDropDown<U>, _KeyNavMixin {
1694 interface Select<T extends Object, Q extends dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T>, U extends dijit._WidgetBase> extends _FormSelectWidget<T, Q, O>, _HasDropDown<U>, _KeyNavMixin {
1695 1695 baseClass: string;
1696 1696
1697 1697 /**
1698 1698 * What to display in an "empty" drop down.
1699 1699 */
1700 1700 emptyLabel: string;
1701 1701
1702 1702 /**
1703 1703 * Specifies how to interpret the labelAttr in the data store items.
1704 1704 */
1705 1705 labelType: string;
1706 1706
1707 1707 /**
1708 1708 * Currently displayed error/prompt message
1709 1709 */
1710 1710 message: string;
1711 1711
1712 1712 /**
1713 1713 * Can be true or false, default is false.
1714 1714 */
1715 1715 required: boolean;
1716 1716
1717 1717 /**
1718 1718 * "Incomplete" if this select is required but unset (i.e. blank value), "" otherwise
1719 1719 */
1720 1720 state: string;
1721 1721
1722 1722 /**
1723 1723 * Order fields are traversed when user hits the tab key
1724 1724 */
1725 1725 tabIndex: any;
1726 1726 templateString: any;
1727 1727
1728 1728 /**
1729 1729 * See the description of dijit/Tooltip.defaultPosition for details on this parameter.
1730 1730 */
1731 1731 tooltipPosition: any;
1732 1732
1733 1733 childSelector(node: Element | Node): boolean;
1734 1734 destroy(preserveDom: boolean): void;
1735 1735 focus(): void;
1736 1736
1737 1737 /**
1738 1738 * Sets the value to the given option, used during search by letter.
1739 1739 * @param widget Reference to option's widget
1740 1740 */
1741 1741 focusChild(widget: dijit._WidgetBase): void;
1742 1742 isLoaded(): boolean;
1743 1743
1744 1744 /**
1745 1745 * Whether or not this is a valid value.
1746 1746 * @param isFocused
1747 1747 */
1748 1748 isValid(isFocused: boolean): boolean;
1749 1749
1750 1750 /**
1751 1751 * populates the menu
1752 1752 * @param loadCallback
1753 1753 */
1754 1754 loadDropDown(loadCallback: () => any): void;
1755 1755 postCreate(): void;
1756 1756
1757 1757 /**
1758 1758 * set the missing message
1759 1759 */
1760 1760 postMixInProperties(): void;
1761 1761
1762 1762 /**
1763 1763 * Overridden so that the state will be cleared.
1764 1764 */
1765 1765 reset(): void;
1766 1766 startup(): void;
1767 1767
1768 1768 /**
1769 1769 * Called by oninit, onblur, and onkeypress, and whenever required/disabled state changes
1770 1770 * @param isFocused
1771 1771 */
1772 1772 validate(isFocused: boolean): boolean;
1773 1773
1774 1774 /**
1775 1775 * When a key is pressed that matches a child item,
1776 1776 * this method is called so that a widget can take
1777 1777 * appropriate action is necessary.
1778 1778 * @param item
1779 1779 * @param evt
1780 1780 * @param searchString
1781 1781 * @param numMatches
1782 1782 */
1783 1783 onKeyboardSearch(item: dijit._WidgetBase, evt: Event, searchString: string, numMatches: number): void;
1784 1784 }
1785 1785
1786 1786 interface SelectConstructor extends _WidgetBaseConstructor<Select<any, any, any, any>> { }
1787 1787
1788 1788 /* dijit/form/SimpleTextarea */
1789 1789
1790 1790 interface SimpleTextarea extends TextBox {
1791 1791 baseClass: string;
1792 1792 rows: string;
1793 1793 cols: string;
1794 1794 templateString: string;
1795 1795 postMixInProperties(): void;
1796 1796 buildRendering(): void;
1797 1797 filter(value: string): string;
1798 1798 }
1799 1799
1800 1800 interface SimpleTextareaConstructor extends _WidgetBaseConstructor<SimpleTextarea> {
1801 1801 new(params: Object, srcNodeRef: dojo.NodeOrString): SimpleTextarea;
1802 1802 }
1803 1803
1804 1804 /* dijit/form/Textarea */
1805 1805
1806 1806 interface Textarea extends SimpleTextarea, _ExpandingTextAreaMixin {
1807 1807 baseClass: string;
1808 1808 cols: string;
1809 1809 buildRendering(): void;
1810 1810 }
1811 1811
1812 1812 interface TextareaConstructor extends _WidgetBaseConstructor<Textarea> { }
1813 1813
1814 1814 /* dijit/form/TextBox */
1815 1815
1816 1816 interface TextBox extends _FormValueWidget, _TextBoxMixin<Constraints> {
1817 1817
1818 1818 }
1819 1819
1820 1820 interface TextBoxConstructor extends _WidgetBaseConstructor<TextBox> { }
1821 1821
1822 1822 /* dijit/form/ToggleButton */
1823 1823
1824 1824 interface ToggleButton extends Button, _ToggleButtonMixin {
1825 1825 baseClass: string;
1826 1826
1827 1827 setChecked(checked: boolean): void;
1828 1828 }
1829 1829
1830 1830 interface ToggleButtonConstructor extends _WidgetBaseConstructor<ToggleButton> { }
1831 1831
1832 1832 /* dijit/form/ValidationTextBox */
1833 1833
1834 1834 interface IsValidFunction {
1835 1835 (isFocused?: boolean): boolean;
1836 1836 }
1837 1837
1838 1838 interface ValidationTextBox<C extends Constraints = Constraints> extends TextBox {
1839 1839 templateString: string;
1840 1840 required: boolean;
1841 1841 promptMessage: string;
1842 1842 invalidMessage: string;
1843 1843 missingMessage: string;
1844 1844 message: string;
1845 1845 constraints: C;
1846 1846 pattern: string | ConstraintsToRegExpString<C>;
1847 1847 regExp: string;
1848 1848 regExpGen(constraints: C): void;
1849 1849 state: string;
1850 1850 tooltipPosition: string[];
1851 1851 validator: ConstrainedValidFunction<C>;
1852 1852 isValid: IsValidFunction;
1853 1853 getErrorMessage(isFocused: boolean): string;
1854 1854 getPromptMessage(isFocused: boolean): string;
1855 1855 validate(isFocused: boolean): boolean;
1856 1856 displayMessage(message: string): void;
1857 1857
1858 1858 startup(): void;
1859 1859 postMixInProperties(): void;
1860 1860
1861 1861 reset(): void;
1862 1862
1863 1863 destroy(preserveDom?: boolean): void;
1864 1864 }
1865 1865
1866 1866 interface ValidationTextBoxConstructor extends _WidgetBaseConstructor<ValidationTextBox<Constraints>> {
1867 1867 new <C extends Constraints>(params: Object, srcNodeRef: dojo.NodeOrString): ValidationTextBox<C>;
1868 1868 }
1869 1869 }
1870 1870 }
@@ -1,506 +1,506
1 1 /// <reference path="index.d.ts" />
2 2
3 3 declare module 'dijit/_Widget' {
4 4 type _Widget = dijit._Widget;
5 5 const _Widget: dijit._WidgetBaseConstructor<_Widget>;
6 6 export = _Widget;
7 7 }
8 8
9 9 declare module 'dijit/_WidgetBase' {
10 10 type _WidgetBase<E extends { [k in keyof E]: Event } = {}> = dijit._WidgetBase<E & GlobalEventHandlersEventMap>;
11 11
12 12 // individual _WidgetBase constructor to keep type parameters
13 13 interface _WidgetBaseConstructor {
14 14 new <A = {}, E extends { [k in keyof E]: Event } = {}>(params?: Partial<_WidgetBase<E> & A>, srcNodeRef?: dojo.NodeOrString): _WidgetBase<E> & dojo._base.DeclareCreatedObject;
15 15 prototype: _WidgetBase<any>;
16 16 }
17 17 const _WidgetBase: _WidgetBaseConstructor;
18 18 export = _WidgetBase;
19 19 }
20 20
21 21 declare module 'dijit/_AttachMixin' {
22 22 type _AttachMixin = dijit._AttachMixin;
23 23 const _AttachMixin: dijit._AttachMixinConstructor;
24 24 export = _AttachMixin;
25 25 }
26 26
27 27 declare module 'dijit/_CssStateMixin' {
28 28 type _CssStateMixin = dijit._CssStateMixin;
29 29 const _CssStateMixin: dijit._CssStateMixinConstructor;
30 30 export = _CssStateMixin;
31 31 }
32 32
33 33 declare module 'dijit/_Contained' {
34 34 type _Contained = dijit._Contained;
35 35 const _Contained: dijit._ContainedConstructor;
36 36 export = _Contained;
37 37 }
38 38
39 39 declare module 'dijit/_Container' {
40 40 type _Container = dijit._Container;
41 41 const _Container: dijit._ContainerConstructor;
42 42 export = _Container;
43 43 }
44 44
45 45 declare module 'dijit/_KeyNavContainer' {
46 46 type _KeyNavContainer = dijit._KeyNavContainer;
47 47 const _KeyNavContainer: dijit._KeyNavContainerConstructor;
48 48 export = _KeyNavContainer;
49 49 }
50 50
51 51 declare module 'dijit/_KeyNavMixin' {
52 52 type _KeyNavMixin = dijit._KeyNavMixin;
53 53 const _KeyNavMixin: dijit._KeyNavMixinConstructor;
54 54 export = _KeyNavMixin;
55 55 }
56 56
57 57 declare module 'dijit/_MenuBase' {
58 58 type _MenuBase = dijit._MenuBase;
59 59 const _MenuBase: dijit._MenuBaseConstructor;
60 60 export = _MenuBase;
61 61 }
62 62
63 63 declare module 'dijit/_TemplatedMixin' {
64 64 type _TemplatedMixin = dijit._TemplatedMixin;
65 65 const _TemplatedMixin: dijit._TemplatedMixinConstructor;
66 66 export = _TemplatedMixin;
67 67 }
68 68
69 69 declare module 'dijit/_WidgetsInTemplateMixin' {
70 70 type _WidgetsInTemplateMixin = dijit._WidgetsInTemplateMixin;
71 71 const _WidgetsInTemplateMixin: dijit._WidgetsInTemplateMixinConstructor;
72 72 export = _WidgetsInTemplateMixin;
73 73 }
74 74
75 75 declare module 'dijit/ConfirmDialog' {
76 76 type ConfirmDialog = dijit.ConfirmDialog;
77 77 const ConfirmDialog: dijit.ConfirmDialogConstructor;
78 78 export = ConfirmDialog;
79 79 }
80 80
81 81 declare module 'dijit/Calendar' {
82 82 type Calendar = dijit.Calendar;
83 83 const Calendar: dijit.CalendarConstructor;
84 84 export = Calendar;
85 85 }
86 86
87 87 declare module 'dijit/CalendarLite' {
88 88 type CalendarLite = dijit.CalendarLite;
89 89 const CalendarLite: dijit.CalendarLiteConstructor;
90 90 export = CalendarLite;
91 91 }
92 92
93 93 declare module 'dijit/Destroyable' {
94 94 type Destroyable = dijit.Destroyable;
95 95 const Destroyable: dijit.DestroyableConstructor;
96 96 export = Destroyable;
97 97 }
98 98
99 99 declare module 'dijit/Dialog' {
100 100 type Dialog = dijit.Dialog;
101 101 const Dialog: dijit.DialogConstructor;
102 102 export = Dialog;
103 103 }
104 104
105 105 declare module "dijit/_HasDropDown" {
106 106 type _HasDropDown<T extends dijit._WidgetBase = dijit._WidgetBase> = dijit._HasDropDown<T>;
107 107 const _HasDropDown: dijit._WidgetBaseConstructor<_HasDropDown>;
108 108
109 109 export = _HasDropDown;
110 110 }
111 111
112 112 declare module 'dijit/DropDownMenu' {
113 113 type DropDownMenu = dijit.DropDownMenu;
114 114 const DropDownMenu: dijit.DropDownMenuConstructor;
115 115 export = DropDownMenu;
116 116 }
117 117
118 118 declare module 'dijit/Fieldset' {
119 119 type Fieldset = dijit.Fieldset;
120 120 const Fieldset: dijit.FieldsetConstructor;
121 121 export = Fieldset;
122 122 }
123 123
124 124 declare module 'dijit/Menu' {
125 125 type Menu = dijit.Menu;
126 126 const Menu: dijit.MenuConstructor;
127 127 export = Menu;
128 128 }
129 129
130 130 declare module 'dijit/MenuBar' {
131 131 type MenuBar = dijit.MenuBar;
132 132 const MenuBar: dijit.MenuBarConstructor;
133 133 export = MenuBar;
134 134 }
135 135
136 136 declare module 'dijit/MenuBarItem' {
137 137 type MenuBarItem = dijit.MenuBarItem;
138 138 const MenuBarItem: dijit.MenuBarItemConstructor;
139 139 export = MenuBarItem;
140 140 }
141 141
142 142 declare module 'dijit/MenuItem' {
143 143 type MenuItem = dijit.MenuItem;
144 144 const MenuItem: dijit.MenuItemConstructor;
145 145 export = MenuItem;
146 146 }
147 147
148 148 declare module 'dijit/MenuSeparator' {
149 149 type MenuSeparator = dijit.MenuSeparator;
150 150 const MenuSeparator: dijit.MenuSeparatorConstructor;
151 151 export = MenuSeparator;
152 152 }
153 153
154 154 declare module 'dijit/place' {
155 155 const place: dijit.Place;
156 156 export = place;
157 157 }
158 158
159 159 declare module 'dijit/popup' {
160 160 const popup: dijit.PopupManager;
161 161 export = popup;
162 162 }
163 163
164 164 declare module 'dijit/PopupMenuBarItem' {
165 165 type PopupMenuBarItem = dijit.PopupMenuBarItem;
166 166 const PopupMenuBarItem: dijit.PopupMenuBarItemConstructor;
167 167 export = PopupMenuBarItem;
168 168 }
169 169
170 170 declare module 'dijit/PopupMenuItem' {
171 171 type PopupMenuItem = dijit.PopupMenuItem;
172 172 const PopupMenuItem: dijit.PopupMenuItemConstructor;
173 173 export = PopupMenuItem;
174 174 }
175 175
176 176 declare module 'dijit/registry' {
177 177 const registry: dijit.Registry;
178 178 export = registry;
179 179 }
180 180
181 181 declare module 'dijit/TitlePane' {
182 182 type TitlePane = dijit.TitlePane;
183 183 const TitlePane: dijit.TitlePaneConstructor;
184 184 export = TitlePane;
185 185 }
186 186
187 187 declare module 'dijit/Toolbar' {
188 188 type Toolbar = dijit.Toolbar;
189 189 const Toolbar: dijit.ToolbarConstructor;
190 190 export = Toolbar;
191 191 }
192 192
193 193 declare module 'dijit/ToolbarSeparator' {
194 194 type ToolbarSeparator = dijit.ToolbarSeparator;
195 195 const ToolbarSeparator: dijit.ToolbarSeparatorConstructor;
196 196 export = ToolbarSeparator;
197 197 }
198 198
199 199 declare module 'dijit/Tooltip' {
200 200 type Tooltip = dijit.Tooltip;
201 201 const Tooltip: dijit.TooltipConstructor;
202 202 export = Tooltip;
203 203 }
204 204
205 205 declare module 'dijit/TooltipDialog' {
206 206 type TooltipDialog = dijit.TooltipDialog;
207 207 const TooltipDialog: dijit.TooltipDialogConstructor;
208 208 export = TooltipDialog;
209 209 }
210 210
211 211 declare module 'dijit/_base/focus' {
212 212 const focus: dijit._base.Focus;
213 213 export = focus;
214 214 }
215 215
216 216 declare module 'dijit/_base/manager' {
217 217 const manager: dijit._base.Manager;
218 218 export = manager;
219 219 }
220 220
221 221 declare module 'dijit/_base/place' {
222 222 const place: dijit._base.Place;
223 223 export = place;
224 224 }
225 225
226 226 declare module 'dijit/_base/popup' {
227 227 const popup: dijit._base.Popup;
228 228 export = popup;
229 229 }
230 230
231 231 declare module 'dijit/_base/scroll' {
232 232 const scroll: dijit._base.Scroll;
233 233 export = scroll;
234 234 }
235 235
236 236 declare module 'dijit/_base/sniff' {
237 237 const sniff: dijit._base.Sniff;
238 238 export = sniff;
239 239 }
240 240
241 241 declare module 'dijit/_base/typematic' {
242 242 const typematic: dijit._base.Typematic;
243 243 export = typematic;
244 244 }
245 245
246 246 declare module 'dijit/_base/wai' {
247 247 const wai: dijit._base.Wai;
248 248 export = wai;
249 249 }
250 250
251 251 declare module 'dijit/_base/window' {
252 252 const window: dijit._base.Window;
253 253 export = window;
254 254 }
255 255
256 256 declare module 'dijit/form/_FormMixin' {
257 257 type _FormMixin = dijit.form._FormMixin;
258 258 const _FormMixin: dijit.form._FormMixinConstructor;
259 259 export = _FormMixin;
260 260 }
261 261
262 262 declare module "dijit/form/_FormWidgetMixin" {
263 263 type _FormWidgetMixin = dijit.form._FormWidgetMixin;
264 264 const _FormWidgetMixin: dijit._WidgetBaseConstructor<_FormWidgetMixin>;
265 265 export = _FormWidgetMixin;
266 266 }
267 267
268 268 declare module "dijit/form/_FormValueMixin" {
269 269 type _FormValueMixin = dijit.form._FormValueMixin;
270 270 const _FormValueMixin: dijit._WidgetBaseConstructor<_FormValueMixin>;
271 271 export = _FormValueMixin;
272 272 }
273 273
274 274 declare module 'dijit/form/_FormValueWidget' {
275 275 type _FormValueWidget = dijit.form._FormValueWidget;
276 276 const _FormValueWidget: dijit.form._FormValueWidgetConstructor;
277 277 export = _FormValueWidget;
278 278 }
279 279
280 280 declare module 'dijit/form/_FormWidget' {
281 281 type _FormWidget = dijit.form._FormWidget;
282 282 const _FormWidget: dijit.form._FormWidgetConstructor;
283 283 export = _FormWidget;
284 284 }
285 285
286 286 declare module 'dijit/form/Button' {
287 287 type Button = dijit.form.Button;
288 288 const Button: dijit.form.ButtonConstructor;
289 289 export = Button;
290 290 }
291 291
292 292 declare module 'dijit/form/CheckBox' {
293 293 type CheckBox = dijit.form.CheckBox;
294 294 const CheckBox: dijit.form.CheckBoxConstructor;
295 295 export = CheckBox;
296 296 }
297 297
298 298 declare module 'dijit/form/ComboBox' {
299 299 type ComboBox = dijit.form.TextBox;
300 300 const ComboBox: dijit.form.ComboBoxConstructor;
301 301 export = ComboBox;
302 302 }
303 303
304 304 declare module 'dijit/form/ComboBoxMixin' {
305 305 type ComboBoxMixin<T = any, U extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, V = any> = dijit.form.ComboBoxMixin<T, U, V>;
306 306 const ComboBoxMixin: dijit.form.ComboBoxConstructor;
307 307 export = ComboBoxMixin;
308 308 }
309 309
310 310 declare module 'dijit/form/CurrencyTextBox' {
311 311 type CurrencyTextBox = dijit.form.CurrencyTextBox;
312 312 const CurrencyTextBox: dijit.form.CurrencyTextBoxConstructor;
313 313 export = CurrencyTextBox;
314 314 }
315 315
316 316 declare module 'dijit/form/DataList' {
317 317 type DataList<T> = dijit.form.DataList<T>;
318 318 const DataList: dijit.form.DataListConstructor;
319 319 export = DataList;
320 320 }
321 321
322 322 declare module 'dijit/form/DateTextBox' {
323 323 type DateTextBox = dijit.form.DateTextBox;
324 324 const DateTextBox: dijit.form.DateTextBoxConstructor;
325 325 export = DateTextBox;
326 326 }
327 327
328 328 declare module 'dijit/form/DropDownButton' {
329 329 type DropDownButton<T extends dijit._WidgetBase> = dijit.form.DropDownButton<T>;
330 330 const DropDownButton: dijit.form.DropDownButtonConstructor;
331 331 export = DropDownButton;
332 332 }
333 333
334 334 declare module 'dijit/form/FilteringSelect' {
335 type FilteringSelect<C extends dijit.form.Constraints = dijit.form.Constraints, T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions = dojo.store.api.QueryOptions> = dijit.form.FilteringSelect<C, T, Q, O>;
335 type FilteringSelect<C extends dijit.form.Constraints = dijit.form.Constraints, T extends Object = any, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O extends dojo.store.api.QueryOptions<T> = dojo.store.api.QueryOptions<T>> = dijit.form.FilteringSelect<C, T, Q, O>;
336 336 const FilteringSelect: dijit.form.FilteringSelectConstructor;
337 337 export = FilteringSelect;
338 338 }
339 339
340 340 declare module 'dijit/form/Form' {
341 341 type Form = dijit.form.Form;
342 342 const Form: dijit.form.FormConstructor;
343 343 export = Form;
344 344 }
345 345
346 346 declare module 'dijit/form/HorizontalRule' {
347 347 type HorizontalRule = dijit.form.HorizontalRule;
348 348 const HorizontalRule: dijit.form.HorizontalRuleConstructor;
349 349 export = HorizontalRule;
350 350 }
351 351
352 352 declare module 'dijit/form/HorizontalRuleLabels' {
353 353 type HorizontalRuleLabels = dijit.form.HorizontalRuleLabels;
354 354 const HorizontalRuleLabels: dijit.form.HorizontalRuleLabelsConstructor;
355 355 export = HorizontalRuleLabels;
356 356 }
357 357
358 358 declare module 'dijit/form/HorizontalSlider' {
359 359 type HorizontalSlider = dijit.form.HorizontalSlider;
360 360 const HorizontalSlider: dijit.form.HorizontalSliderConstructor;
361 361 export = HorizontalSlider;
362 362 }
363 363
364 364 declare module 'dijit/form/MappedTextBox' {
365 365 type MappedTextBox<C extends dijit.form.Constraints = dijit.form.Constraints> = dijit.form.MappedTextBox<C>;
366 366 const MappedTextBox: dijit.form.MappedTextBoxConstructor;
367 367 export = MappedTextBox;
368 368 }
369 369
370 370 declare module 'dijit/form/NumberSpinner' {
371 371 type NumberSpinner = dijit.form.NumberSpinner;
372 372 const NumberSpinner: dijit.form.NumberSpinnerConstructor;
373 373 export = NumberSpinner;
374 374 }
375 375
376 376 declare module 'dijit/form/NumberTextBox' {
377 377 type NumberTextBox = dijit.form.NumberTextBox;
378 378 const NumberTextBox: dijit.form.NumberTextBoxConstructor;
379 379 export = NumberTextBox;
380 380 }
381 381
382 382 declare module 'dijit/form/RadioButton' {
383 383 type RadioButton = dijit.form.RadioButton;
384 384 const RadioButton: dijit.form.RadioButtonConstructor;
385 385 export = RadioButton;
386 386 }
387 387
388 388 declare module 'dijit/form/RangeBoundTextBox' {
389 389 type RangeBoundTextBox = dijit.form.RangeBoundTextBox;
390 390 const RangeBoundTextBox: dijit.form.RangeBoundTextBoxConstructor;
391 391 export = RangeBoundTextBox;
392 392 }
393 393
394 394 declare module 'dijit/form/Select' {
395 395 type Select<T, Q extends dojo.store.api.BaseQueryType = dojo.store.api.BaseQueryType, O = any, U extends dijit._WidgetBase = dijit._WidgetBase> = dijit.form.Select<T, Q, O, U>;
396 396 const Select: dijit.form.SelectConstructor;
397 397 export = Select;
398 398 }
399 399
400 400 declare module 'dijit/form/SimpleTextarea' {
401 401 type SimpleTextarea = dijit.form.SimpleTextarea;
402 402 const SimpleTextarea: dijit.form.SimpleTextareaConstructor;
403 403 export = SimpleTextarea;
404 404 }
405 405
406 406 declare module 'dijit/form/Textarea' {
407 407 type Textarea = dijit.form.Textarea;
408 408 const Textarea: dijit.form.TextareaConstructor;
409 409 export = Textarea;
410 410 }
411 411
412 412 declare module 'dijit/form/TextBox' {
413 413 type TextBox = dijit.form.TextBox;
414 414 const TextBox: dijit.form.TextBoxConstructor;
415 415 export = TextBox;
416 416 }
417 417
418 418 declare module 'dijit/form/ToggleButton' {
419 419 type ToggleButton = dijit.form.ToggleButton;
420 420 const ToggleButton: dijit.form.ToggleButtonConstructor;
421 421 export = ToggleButton;
422 422 }
423 423
424 424 declare module 'dijit/form/ValidationTextBox' {
425 425 type ValidationTextBox<C extends dijit.form.Constraints = dijit.form.Constraints> = dijit.form.ValidationTextBox<C>;
426 426 const ValidationTextBox: dijit.form.ValidationTextBoxConstructor;
427 427 export = ValidationTextBox;
428 428 }
429 429
430 430 declare module 'dijit/layout/_LayoutWidget' {
431 431 type _LayoutWidget = dijit.layout._LayoutWidget;
432 432 const _LayoutWidget: dijit.layout._LayoutWidgetConstructor;
433 433 export = _LayoutWidget;
434 434 }
435 435
436 436 declare module 'dijit/layout/AccordionContainer' {
437 437 type AccordionContainer = dijit.layout.AccordionContainer;
438 438 const AccordionContainer: dijit.layout.AccordionContainerConstructor;
439 439 export = AccordionContainer;
440 440 }
441 441
442 442 declare module 'dijit/layout/AccordionPane' {
443 443 type AccordionPane = dijit.layout.AccordionPane;
444 444 const AccordionPane: dijit.layout.AccordionPaneConstructor;
445 445 export = AccordionPane;
446 446 }
447 447
448 448 declare module 'dijit/layout/ContentPane' {
449 449 type ContentPane = dijit.layout.ContentPane;
450 450 const ContentPane: dijit.layout.ContentPaneConstructor;
451 451 export = ContentPane;
452 452 }
453 453
454 454 declare module 'dijit/layout/_ContentPaneResizeMixin' {
455 455 type _ContentPaneResizeMixin = dijit.layout._ContentPaneResizeMixin;
456 456 const _ContentPaneResizeMixin: dijit.layout._ContentPaneResizeMixinConstructor;
457 457 export = _ContentPaneResizeMixin;
458 458 }
459 459
460 460 declare module 'dijit/layout/BorderContainer' {
461 461 type BorderContainer = dijit.layout.BorderContainer;
462 462 const BorderContainer: dijit.layout.BorderContainerConstructor;
463 463 export = BorderContainer;
464 464 }
465 465
466 466 declare module 'dijit/layout/LayoutContainer' {
467 467 type LayoutContainer = dijit.layout.LayoutContainer;
468 468 const LayoutContainer: dijit.layout.LayoutContainerConstructor;
469 469 export = LayoutContainer;
470 470 }
471 471
472 472 declare module 'dijit/layout/LinkPane' {
473 473 type LinkPane = dijit.layout.LinkPane;
474 474 const LinkPane: dijit.layout.LinkPaneConstructor;
475 475 export = LinkPane;
476 476 }
477 477
478 478 declare module 'dijit/layout/ScrollingTabController' {
479 479 type ScrollingTabController = dijit.layout.ScrollingTabController;
480 480 const ScrollingTabController: dijit.layout.ScrollingTabControllerConstructor;
481 481 export = ScrollingTabController;
482 482 }
483 483
484 484 declare module 'dijit/layout/StackContainer' {
485 485 type StackContainer = dijit.layout.StackContainer;
486 486 const StackContainer: dijit.layout.StackContainerConstructor;
487 487 export = StackContainer;
488 488 }
489 489
490 490 declare module 'dijit/layout/StackController' {
491 491 type StackController = dijit.layout.StackController;
492 492 const StackController: dijit.layout.StackControllerConstructor;
493 493 export = StackController;
494 494 }
495 495
496 496 declare module 'dijit/layout/TabContainer' {
497 497 type TabContainer = dijit.layout.TabContainer;
498 498 const TabContainer: dijit.layout.TabContainerConstructor;
499 499 export = TabContainer;
500 500 }
501 501
502 502 declare module 'dijit/layout/TabController' {
503 503 type TabController = dijit.layout.TabController;
504 504 const TabController: dijit.layout.TabControllerConstructor;
505 505 export = TabController;
506 506 }
@@ -1,590 +1,592
1 1 /// <reference path="data.d.ts" />
2 2
3 3
4 4 declare namespace dojo {
5 5 namespace store {
6 6 namespace api {
7 7
8 8 type Identity = number | string;
9 9
10 10 /* dojo/store/api/Store */
11 11
12 interface SortInformation {
12 interface SortInformation<K extends string | number | symbol = string> {
13 13
14 14 /**
15 15 * The name of the attribute to sort on.
16 16 */
17 attribute: string;
17 attribute: K;
18 18
19 19 /**
20 20 * The direction of the sort. Default is false.
21 21 */
22 22 descending?: boolean;
23 23 }
24 24
25 interface QueryOptions {
25 type SortFn<T> = (left: T, right: T) => number;
26
27 interface QueryOptions<T = unknown> {
26 28 /**
27 29 * A list of attributes to sort on, as well as direction
28 30 * For example:
29 31 * | [{attribute:"price", descending: true}].
30 32 * If the sort parameter is omitted, then the natural order of the store may be
31 33 * applied if there is a natural order.
32 34 */
33 sort?: SortInformation[];
35 sort?: SortFn<T> | SortInformation<keyof T>[];
34 36
35 37 /**
36 38 * The first result to begin iteration on
37 39 */
38 40 start?: number;
39 41
40 42 /**
41 43 * The number of how many results should be returned.
42 44 */
43 45 count?: number;
44 46 }
45 47
46 48 interface QueryEngineFunction<T extends object> {
47 49 (array: T[]): T[];
48 50 matches(object: T): boolean;
49 51 }
50 52
51 53 type BaseQueryType = string | object | ((...params: unknown[]) => boolean);
52 54
53 55 interface QueryEngine<T extends object, Q extends BaseQueryType> {
54 <O extends QueryOptions>(query: Q, options?: O): QueryEngineFunction<T>;
56 <O extends QueryOptions<T>>(query: Q, options?: O): QueryEngineFunction<T>;
55 57 }
56 58
57 59 interface PutDirectives<T extends object> {
58 60
59 61 /**
60 62 * Indicates the identity of the object if a new object is created
61 63 */
62 64 id?: Identity;
63 65
64 66 /**
65 67 * If the collection of objects in the store has a natural ordering,
66 68 * this indicates that the created or updated object should be placed before the
67 69 * object specified by the value of this property. A value of null indicates that the
68 70 * object should be last.
69 71 */
70 72 before?: T;
71 73
72 74 /**
73 75 * If the store is hierarchical (with single parenting) this property indicates the
74 76 * new parent of the created or updated object.
75 77 */
76 78 parent?: T;
77 79
78 80 /**
79 81 * If this is provided as a boolean it indicates that the object should or should not
80 82 * overwrite an existing object. A value of true indicates that a new object
81 83 * should not be created, the operation should update an existing object. A
82 84 * value of false indicates that an existing object should not be updated, a new
83 85 * object should be created (which is the same as an add() operation). When
84 86 * this property is not provided, either an update or creation is acceptable.
85 87 */
86 88 overwrite?: boolean;
87 89 }
88 90
89 91 interface SyncQueryResults<T extends object> extends Array<T> {
90 92 total?: number;
91 93 }
92 94
93 95 interface AsyncQueryResults<T extends object> extends PromiseLike<Array<T>> {
94 96 /**
95 97 * Iterates over the query results, based on
96 98 * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/objects/Array/forEach.
97 99 * Note that this may executed asynchronously. The callback may be called
98 100 * after this function returns.
99 101 */
100 102 forEach(callback: (item: T, index: number, results: Array<T>) => void, thisObject?: object): PromiseLike<void>;
101 103
102 104 /**
103 105 * Filters the query results, based on
104 106 * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter.
105 107 * Note that this may executed asynchronously. The callback may be called
106 108 * after this function returns.
107 109 */
108 110 filter(callback: (item: T, index: number, results: Array<T>) => boolean, thisObject?: object): PromiseLike<Array<T>>;
109 111
110 112 /**
111 113 * Maps the query results, based on
112 114 * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map.
113 115 * Note that this may executed asynchronously. The callback may be called
114 116 * after this function returns.
115 117 */
116 118 map<U>(callback: (item: T, index: number, results: Array<T>) => U, thisObject?: object): PromiseLike<Array<U>>;
117 119
118 120 /** Cancells the current query */
119 121 cancel(reason?: any): void;
120 122
121 123 total?: PromiseLike<number>;
122 124 }
123 125
124 126 type QueryResults<T extends object> = SyncQueryResults<T> | AsyncQueryResults<T>;
125 127
126 128 interface Transaction {
127 129 /**
128 130 * Commits the transaction. This may throw an error if it fails. Of if the operation
129 131 * is asynchronous, it may return a promise that represents the eventual success
130 132 * or failure of the commit.
131 133 */
132 134 commit(): void;
133 135
134 136 /**
135 137 * Aborts the transaction. This may throw an error if it fails. Of if the operation
136 138 * is asynchronous, it may return a promise that represents the eventual success
137 139 * or failure of the abort.
138 140 */
139 141 abort(): void;
140 142 }
141 143
142 144 interface Transacted {
143 145 /**
144 146 * Starts a new transaction.
145 147 * Note that a store user might not call transaction() prior to using put,
146 148 * delete, etc. in which case these operations effectively could be thought of
147 149 * as "auto-commit" style actions.
148 150 */
149 151 transaction(): Transaction;
150 152 }
151 153
152 154 interface MetadataProvider<T extends object> {
153 155 /**
154 156 * Returns any metadata about the object. This may include attribution,
155 157 * cache directives, history, or version information.
156 158 */
157 159 getMetadata(object: T): object;
158 160 }
159 161
160 162 interface IdentityProvider<T extends object> {
161 163 /**
162 164 * If the store has a single primary key, this indicates the property to use as the
163 165 * identity property. The values of this property should be unique.
164 166 */
165 167 idProperty: keyof T;
166 168
167 169 /**
168 170 * Returns an object's identity
169 171 */
170 172 getIdentity(object: T): Identity;
171 173 }
172 174
173 175 interface Queryable<
174 176 T extends object,
175 177 Q extends BaseQueryType,
176 O extends QueryOptions,
178 O extends QueryOptions<T>,
177 179 R extends QueryResults<T> = QueryResults<T>> {
178 180
179 181 /**
180 182 * Queries the store for objects. This does not alter the store, but returns a
181 183 * set of data from the store.
182 184 */
183 185 query(query?: Q, options?: O): R;
184 186 }
185 187
186 interface SyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
188 interface SyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions<T> = QueryOptions<T>>
187 189 extends IdentityProvider<T>, Queryable<T, Q, O, SyncQueryResults<T>> {
188 190
189 191 /**
190 192 * If the store can be queried locally (on the client side in JS), this defines
191 193 * the query engine to use for querying the data store.
192 194 * This takes a query and query options and returns a function that can execute
193 195 * the provided query on a JavaScript array. The queryEngine may be replace to
194 196 * provide more sophisticated querying capabilities. For example:
195 197 * | var query = store.queryEngine({foo:"bar"}, {count:10});
196 198 * | query(someArray) -> filtered array
197 199 * The returned query function may have a "matches" property that can be
198 200 * used to determine if an object matches the query. For example:
199 201 * | query.matches({id:"some-object", foo:"bar"}) -> true
200 202 * | query.matches({id:"some-object", foo:"something else"}) -> false
201 203 */
202 204 queryEngine?: QueryEngine<T, Q>;
203 205
204 206 /**
205 207 * Retrieves an object by its identity
206 208 */
207 209 get(id: Identity): T;
208 210
209 211 /**
210 212 * Stores an object
211 213 */
212 214 put(object: T, directives?: PutDirectives<T>): unknown;
213 215
214 216 /**
215 217 * Creates an object, throws an error if the object already exists
216 218 */
217 219 add(object: T, directives?: PutDirectives<T>): unknown;
218 220
219 221 /**
220 222 * Deletes an object by its identity
221 223 */
222 224 remove(id: Identity): void;
223 225
224 226 }
225 227
226 interface AsyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
228 interface AsyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions<T> = QueryOptions<T>>
227 229 extends IdentityProvider<T>, Queryable<T, Q, O, AsyncQueryResults<T>> {
228 230
229 231 /**
230 232 * If the store can be queried locally (on the client side in JS), this defines
231 233 * the query engine to use for querying the data store.
232 234 * This takes a query and query options and returns a function that can execute
233 235 * the provided query on a JavaScript array. The queryEngine may be replace to
234 236 * provide more sophisticated querying capabilities. For example:
235 237 * | var query = store.queryEngine({foo:"bar"}, {count:10});
236 238 * | query(someArray) -> filtered array
237 239 * The returned query function may have a "matches" property that can be
238 240 * used to determine if an object matches the query. For example:
239 241 * | query.matches({id:"some-object", foo:"bar"}) -> true
240 242 * | query.matches({id:"some-object", foo:"something else"}) -> false
241 243 */
242 244 queryEngine?: QueryEngine<T, Q>;
243 245
244 246 /**
245 247 * Retrieves an object by its identity
246 248 */
247 249 get(id: Identity): PromiseLike<T>;
248 250
249 251 /**
250 252 * Stores an object
251 253 */
252 254 put(object: T, directives?: PutDirectives<T>): PromiseLike<unknown>;
253 255
254 256 /**
255 257 * Creates an object, throws an error if the object already exists
256 258 */
257 259 add(object: T, directives?: PutDirectives<T>): PromiseLike<unknown>;
258 260
259 261 /**
260 262 * Deletes an object by its identity
261 263 */
262 264 remove(id: string | number): PromiseLike<void>;
263 265
264 266 }
265 267
266 interface HierarchicalStore<T extends object, O extends QueryOptions = QueryOptions, R extends QueryResults<T> = QueryResults<T>> {
268 interface HierarchicalStore<T extends object, O extends QueryOptions<T> = QueryOptions<T>, R extends QueryResults<T> = QueryResults<T>> {
267 269
268 270 /**
269 271 * Retrieves the children of an object.
270 272 */
271 273 getChildren(parent: T, options?: O): R;
272 274 }
273 275
274 interface Store<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
276 interface Store<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions<T> = QueryOptions<T>>
275 277 extends IdentityProvider<T>, Queryable<T, Q, O> {
276 278
277 279 /**
278 280 * If the store can be queried locally (on the client side in JS), this defines
279 281 * the query engine to use for querying the data store.
280 282 * This takes a query and query options and returns a function that can execute
281 283 * the provided query on a JavaScript array. The queryEngine may be replace to
282 284 * provide more sophisticated querying capabilities. For example:
283 285 * | var query = store.queryEngine({foo:"bar"}, {count:10});
284 286 * | query(someArray) -> filtered array
285 287 * The returned query function may have a "matches" property that can be
286 288 * used to determine if an object matches the query. For example:
287 289 * | query.matches({id:"some-object", foo:"bar"}) -> true
288 290 * | query.matches({id:"some-object", foo:"something else"}) -> false
289 291 */
290 292 queryEngine?: QueryEngine<T, Q>;
291 293
292 294 /**
293 295 * Retrieves an object by its identity
294 296 */
295 297 get(id: Identity): T | PromiseLike<T>;
296 298
297 299 /**
298 300 * Stores an object
299 301 */
300 302 put(object: T, directives?: PutDirectives<T>): unknown;
301 303
302 304 /**
303 305 * Creates an object, throws an error if the object already exists
304 306 */
305 307 add(object: T, directives?: PutDirectives<T>): unknown;
306 308
307 309 /**
308 310 * Deletes an object by its identity
309 311 */
310 312 remove(id: Identity): void | PromiseLike<void>;
311 313
312 314 }
313 315
314 316 interface StoreConstructor {
315 317 new <T extends object, Q extends BaseQueryType, O extends QueryOptions>(): Store<T, Q, O>;
316 318 }
317 319 }
318 320
319 321 namespace util {
320 322
321 323 /* dojo/store/util/QueryResults */
322 324
323 325 interface QueryResultsFunction {
324 326 /**
325 327 * A function that wraps the results of a store query with additional
326 328 * methods.
327 329 */
328 330 <T extends object>(results: T[]): api.SyncQueryResults<T>;
329 331 <T extends object>(results: PromiseLike<T[]>): api.AsyncQueryResults<T>;
330 332 }
331 333
332 334 /* dojo/store/util/SimpleQueryEngine */
333 335 interface SimpleQueryEngine extends api.QueryEngine<object, api.BaseQueryType> { }
334 336 }
335 337
336 338 /* dojo/store/Cache */
337 339
338 340 interface CacheOptions<T extends object = any> {
339 341 /**
340 342 * This is a function that will be called for each item in a query response to determine
341 343 * if it is cacheable. If isLoaded returns true, the item will be cached, otherwise it
342 344 * will not be cached. If isLoaded is not provided, all items will be cached.
343 345 */
344 346 isLoaded?: (item: T) => boolean;
345 347 }
346 348
347 349 interface CacheMixin {
348 350 /**
349 351 * Remove the object with the specific id.
350 352 */
351 353 remove(id: api.Identity): PromiseLike<void>;
352 354
353 355 /**
354 356 * Remove the object with the given id from the underlying caching store.
355 357 */
356 358 evict(id: api.Identity): PromiseLike<void>;
357 359 }
358 360
359 361 interface Cache {
360 362 /**
361 363 * The Cache store wrapper takes a master store and a caching store,
362 364 * caches data from the master into the caching store for faster
363 365 * lookup. Normally one would use a memory store for the caching
364 366 * store and a server store like JsonRest for the master store.
365 367 */
366 368 <T extends object, Q extends api.BaseQueryType, O extends api.QueryOptions, S extends api.Store<T, Q, O>>(masterStore: S, cacheStore: api.Store<T, Q, O>, options?: CacheOptions): CacheMixin & S;
367 369 }
368 370
369 371 /* dojo/store/DataStore */
370 372
371 373 interface DataStoreOptions<T extends object> {
372 374 idProperty?: keyof T;
373 queryEngine?: api.QueryEngine<T, api.QueryOptions>;
375 queryEngine?: api.QueryEngine<T, api.QueryOptions<T>>;
374 376 store?: data.api.Read<T> | data.api.Write<T> | data.api.Identity<T>;
375 377 }
376 378
377 interface DataStore<T extends object> extends api.Store<T, api.BaseQueryType, api.QueryOptions> {
379 interface DataStore<T extends object> extends api.Store<T, api.BaseQueryType, api.QueryOptions<T>> {
378 380 /**
379 381 * The object store to convert to a data store
380 382 */
381 383 store: data.api.Read<T> | data.api.Write<T> | data.api.Identity<T>;
382 384
383 385 /**
384 386 * Defines the query engine to use for querying the data store
385 387 */
386 388 queryEngine: api.QueryEngine<T, api.BaseQueryType>;
387 389
388 390 _objectConverter(callback: (item: T) => any): (item: T) => any;
389 391 }
390 392
391 393 interface DataStoreConstructor extends _base.DeclareConstructor<DataStore<object>> {
392 394 new <T extends object>(options?: DataStoreOptions<T>): DataStore<T>;
393 395 }
394 396
395 397 /* dojo/store/JsonRest */
396 398
397 399 interface Headers {
398 400 [header: string]: string;
399 401 }
400 402
401 403 interface JsonRestPutDirectives<T extends object> extends api.PutDirectives<T> {
402 404 headers?: Headers;
403 405
404 406 incremental?: boolean;
405 407
406 408 timeout?: number
407 409 }
408 410
409 interface JsonRestQueryOptions extends api.QueryOptions {
411 interface JsonRestQueryOptions<T = unknown> extends api.QueryOptions<T> {
410 412 headers?: Headers;
411 413
412 414 timeout?: number;
413 415 }
414 416
415 417 interface JsonRestOptions<T extends object> {
416 418 idProperty?: keyof T;
417 queryEngine?: api.QueryEngine<T, JsonRestQueryOptions>;
419 queryEngine?: api.QueryEngine<T, JsonRestQueryOptions<T>>;
418 420 headers?: Headers;
419 421 target?: string;
420 422 rangeParam?: string;
421 423 sortParam?: string;
422 424 ascendingPrefix?: string;
423 425 descendingPrefix?: string;
424 426 accepts?: string;
425 427 }
426 428
427 429 interface JsonRest<
428 430 T extends object,
429 431 Q extends api.BaseQueryType = (Partial<T> | string) & api.BaseQueryType,
430 O extends JsonRestQueryOptions = JsonRestQueryOptions>
432 O extends JsonRestQueryOptions<T> = JsonRestQueryOptions<T>>
431 433 extends api.AsyncStore<T, Q, O> {
432 434 /**
433 435 * Additional headers to pass in all requests to the server. These can be overridden
434 436 * by passing additional headers to calls to the store.
435 437 */
436 438 headers: Headers;
437 439
438 440 /**
439 441 * The target base URL to use for all requests to the server. This string will be
440 442 * prepended to the id to generate the URL (relative or absolute) for requests
441 443 * sent to the server
442 444 */
443 445 target: string;
444 446
445 447 /**
446 448 * Use a query parameter for the requested range. If this is omitted, than the
447 449 * Range header will be used. Independent of this, the X-Range header is always set.
448 450 */
449 451 rangeParam?: string;
450 452
451 453 /**
452 454 * The query parameter to used for holding sort information. If this is omitted, than
453 455 * the sort information is included in a functional query token to avoid colliding
454 456 * with the set of name/value pairs.
455 457 */
456 458 sortParam?: string;
457 459
458 460 /**
459 461 * The prefix to apply to sort attribute names that are ascending
460 462 */
461 463 ascendingPrefix: string;
462 464
463 465 /**
464 466 * The prefix to apply to sort attribute names that are descending
465 467 */
466 468 descendingPrefix: string;
467 469
468 470 /**
469 471 * If the target has no trailing '/', then append it.
470 472 */
471 473 _getTarget(id: api.Identity): string;
472 474
473 475 /**
474 476 * Retrieves an object by its identity. This will trigger a GET request to the server using
475 477 * the url `this.target + id`.
476 478 */
477 479 get(id: api.Identity, options?: { headers: Headers } | Headers): PromiseLike<T>;
478 480
479 481 /**
480 482 * Defines the Accept header to use on HTTP requests
481 483 */
482 484 accepts: string;
483 485
484 486 /**
485 487 * Stores an object. This will trigger a PUT request to the server
486 488 * if the object has an id, otherwise it will trigger a POST request.
487 489 */
488 490 put(object: T, options?: JsonRestPutDirectives<T>): PromiseLike<unknown>;
489 491
490 492 /**
491 493 * Adds an object. This will trigger a PUT request to the server
492 494 * if the object has an id, otherwise it will trigger a POST request.
493 495 */
494 496 add(object: T, options?: JsonRestPutDirectives<T>): PromiseLike<unknown>;
495 497
496 498 /**
497 499 * Deletes an object by its identity. This will trigger a DELETE request to the server.
498 500 */
499 501 remove(id: api.Identity, options?: { headers?: Headers }): PromiseLike<void>;
500 502
501 503 }
502 504
503 505 interface JsonRestConstructor extends _base.DeclareConstructor<JsonRest<object, api.BaseQueryType, JsonRestQueryOptions>> {
504 506 new <T extends object, Q extends api.BaseQueryType, O extends JsonRestQueryOptions>(options?: JsonRestOptions<T>): JsonRest<T, Q, O>;
505 507 }
506 508
507 509 /* dojo/store/Memory */
508 510
509 511 interface MemoryOptions<T extends object> {
510 512 data?: T[];
511 513 idProperty?: keyof T;
512 queryEngine?: api.QueryEngine<T, api.QueryOptions>;
514 queryEngine?: api.QueryEngine<T, api.QueryOptions<T>>;
513 515 setData?: (data: T[]) => void;
514 516 }
515 517
516 518 interface Memory<T extends object> extends api.SyncStore<T> {
517 519 /**
518 520 * The array of all the objects in the memory store
519 521 */
520 522 data: T[];
521 523
522 524 /**
523 525 * An index of data indices into the data array by id
524 526 */
525 527 index: { [id: string]: number };
526 528
527 529 /**
528 530 * Sets the given data as the source for this store, and indexes it
529 531 */
530 532 setData(data: T[]): void;
531 533 }
532 534
533 535 interface MemoryConstructor extends _base.DeclareConstructor<Memory<any>> {
534 536 /**
535 537 * This is a basic in-memory object store. It implements dojo/store/api/Store.
536 538 */
537 539 new <T extends object>(options?: MemoryOptions<T>): Memory<T>;
538 540 }
539 541
540 542 /* dojo/store/Observable */
541 543
542 544 interface ObservableQueryResultsMixin<T extends object> {
543 545 /**
544 546 * Allows observation of results
545 547 */
546 548 observe(listener: (object: T, previousIndex: number, newIndex: number) => void, includeUpdates?: boolean): {
547 549 remove(): void;
548 550 cancel(): void;
549 551 };
550 552 }
551 553
552 554 type ObservableQueryResults<T extends object> = ObservableQueryResultsMixin<T> & api.QueryResults<T>;
553 555
554 interface ObservableMixin<T extends object, Q extends api.BaseQueryType, O extends api.QueryOptions, R extends api.QueryResults<T> = api.QueryResults<T> > {
556 interface ObservableMixin<T extends object, Q extends api.BaseQueryType, O extends api.QueryOptions<T>, R extends api.QueryResults<T> = api.QueryResults<T> > {
555 557 notify(object: T, existingId?: api.Identity): void;
556 558
557 559 /**
558 560 * Queries the store for objects. This does not alter the store, but returns a
559 561 * set of data from the store.
560 562 */
561 563 query(query: Q, options?: O): ObservableQueryResultsMixin<T> & R;
562 564 }
563 565
564 566 interface ResultsObserveMixin<T extends object> {
565 567 /**
566 568 * Allows observation of results
567 569 */
568 570 observe(listener: (object: T, previousIndex: number, newIndex: number) => void, includeUpdates?: boolean): {
569 571 remove(): void;
570 572 cancel(): void;
571 573 };
572 574 }
573 575
574 576 interface Notifiable<T> {
575 577 notify(object: T, existingId?: api.Identity): void;
576 578 }
577 579
578 580 type ResultItem<R> = R extends ArrayLike<infer I1> ? I1 :
579 581 R extends PromiseLike<ArrayLike<infer I2>> ? I2 : never;
580 582
581 583 type ObservableStore<S extends { query: (...params: any) => any }> =
582 584 S extends { query: (...params: infer P) => api.QueryResults<infer R> } ? {
583 585 [K in keyof S]: K extends "query" ? (...params: P) => ReturnType<S[K]> & ResultsObserveMixin<R> : S[K];
584 586 } & Notifiable<R> : S;
585 587
586 588 interface Observable {
587 589 new <S extends api.Store<any, any, any>>(store: S): ObservableStore<S>;
588 590 }
589 591 }
590 592 }
@@ -1,26 +1,27
1 1 import * as Memory from "dojo/store/Memory";
2 2 import * as Observable from "dojo/store/Observable";
3 3
4 4 interface Schedule {
5 5
6 6 id?: string;
7 7
8 8 title: string;
9 9
10 10 duration: number;
11 11 }
12 12
13 13 declare const store: dojo.store.api.Store<Schedule>;
14 14
15 15 const observable = new Observable(store);
16 16
17 17 const mem = new Memory<Schedule>();
18 18
19 19 observable.query().observe(() => { });
20 20 store.query().forEach(() => { });
21 21 const total = await store.query().total;
22 const result = await store.query();
22 const res1 = await store.query(undefined, { sort: [{ attribute: "duration", descending: true }] });
23 const res2 = await store.query(undefined, { sort: ({ duration: a }, { duration: b }) => a - b });
23 24
24 25 mem.query();
25 26
26 27 mem.add({ duration: 10, title: "Test event" });
General Comments 0
You need to be logged in to leave comments. Login now