##// END OF EJS Templates
Corrected typings dijit/_WidgetBase, dojo/store
cin -
r16:f6ff0b17b520 v1.0.5 default
parent child
Show More
@@ -1,2368 +1,2368
1 1 /// <reference path="../dojo/index.d.ts" />
2 2 /// <reference path="form.d.ts" />
3 3 /// <reference path="layout.d.ts" />
4 4
5 5 declare namespace dijit {
6 6 /* Global Dijit Interface */
7 7 interface Dijit { }
8 8
9 9 /* dijit/_AttachMixin */
10 10
11 11 /* tslint:disable:class-name */
12 12
13 13 interface _WidgetBase {
14 14 dojoAttachEvent: string;
15 15 dojoAttachPoint: string;
16 16 }
17 17
18 18 interface _AttachMixin {
19 19 /**
20 20 * List of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"]
21 21 */
22 22 _attachPoints: string[];
23 23
24 24 /**
25 25 * List of connections associated with data-dojo-attach-event=... in the template
26 26 */
27 27 _attachEvents: dojo.Handle[];
28 28
29 29 /**
30 30 * Object to which attach points and events will be scoped. Defaults to 'this'.
31 31 */
32 32 attachScope: any;
33 33
34 34 /**
35 35 * Search descendants of this.containerNode for data-dojo-attach-point and data-dojo-attach-event.
36 36 *
37 37 * Should generally be left false (the default value) both for performance and to avoid failures when this.containerNode holds other _AttachMixin instances with their own attach points and events.
38 38 */
39 39 searchContainerNode: boolean;
40 40
41 41 /**
42 42 * Attach to DOM nodes marked with special attributes.
43 43 */
44 44 buildRendering(): void;
45 45
46 46 /**
47 47 * hook for _WidgetsInTemplateMixin
48 48 */
49 49 _beforeFillContent(): void;
50 50
51 51 /**
52 52 * Iterate through the dom nodes and attach functions and nodes accordingly.
53 53 *
54 54 * Map widget properties and functions to the handlers specified in the dom node and it's descendants. This function iterates over all nodes and looks for these properties:
55 55 * - dojoAttachPoint/data-dojo-attach-point
56 56 * - dojoAttachEvent/data-dojo-attach-event
57 57 */
58 58 _attachTemplateNodes(rootNode: Element | Node): void;
59 59
60 60 /**
61 61 * Process data-dojo-attach-point and data-dojo-attach-event for given node or widget.
62 62 *
63 63 * Returns true if caller should process baseNode's children too.
64 64 */
65 65 _processTemplateNode<T extends (Element | Node | _WidgetBase)>(
66 66 baseNode: T,
67 67 getAttrFunc: (baseNode: T, attr: string) => string,
68 68 attachFunc: (node: T, type: string, func?: Function) => dojo.Handle
69 69 ): boolean;
70 70
71 71 /**
72 72 * Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event. Meant to attach to DOMNodes, not to widgets.
73 73 */
74 74 _attach(node: Element | Node, type: string, func?: Function): dojo.Handle;
75 75
76 76 /**
77 77 * Detach and clean up the attachments made in _attachtempalteNodes.
78 78 */
79 79 _detachTemplateNodes(): void;
80 80
81 81 destroyRendering(preserveDom?: boolean): void;
82 82 }
83 83
84 84 interface _AttachMixinConstructor extends dojo._base.DeclareConstructor<_AttachMixin> { }
85 85
86 86 /* dijit/_BidiMixin */
87 87
88 88 interface _WidgetBase {
89 89
90 90 /**
91 91 * Gets the right direction of text.
92 92 */
93 93 getTextDir(text: string): string;
94 94
95 95 /**
96 96 * Set element.dir according to this.textDir, assuming this.textDir has a value.
97 97 */
98 98 applyTextDir(element: HTMLElement, text?: string): void;
99 99
100 100 /**
101 101 * Wraps by UCC (Unicode control characters) option's text according to this.textDir
102 102 */
103 103 enforceTextDirWithUcc(option: HTMLOptionElement, text: string): string;
104 104
105 105 /**
106 106 * Restores the text of origObj, if needed, after enforceTextDirWithUcc, e.g. set("textDir", textDir).
107 107 */
108 108 restoreOriginalText(origObj: HTMLOptionElement): HTMLOptionElement;
109 109 }
110 110
111 111 /* dijit/_ConfirmDialogMixin */
112 112
113 113 interface _ConfirmDialogMixin extends _WidgetsInTemplateMixin {
114 114 /**
115 115 * HTML snippet for action bar, overrides _DialogMixin.actionBarTemplate
116 116 */
117 117 actionBarTemplate: string;
118 118
119 119 /**
120 120 * Label of OK button.
121 121 */
122 122 buttonOk: string;
123 123
124 124 /**
125 125 * Label of cancel button.
126 126 */
127 127 buttonCancel: string;
128 128 }
129 129
130 130 /* dijit/_Contained */
131 131
132 132 interface _Contained {
133 133 /**
134 134 * Returns the previous child of the parent or null if this is the
135 135 * first child of the parent.
136 136 */
137 137 getPreviousSibling<T extends _WidgetBase>(): T;
138 138
139 139 /**
140 140 * Returns the next child of the parent or null if this is the last
141 141 * child of the parent.
142 142 */
143 143 getNextSibling<T extends _WidgetBase>(): T;
144 144
145 145 /**
146 146 * Returns the index of this widget within its container parent.
147 147 * It returns -1 if the parent does not exist or if the parent is
148 148 * not a dijit/_Container.
149 149 */
150 150 getIndexInParent(): number;
151 151 }
152 152
153 153 interface _ContainedConstructor extends dojo._base.DeclareConstructor<_Contained> { }
154 154
155 155 /* dijit/_Container */
156 156
157 157 interface _Container {
158 158 buildRendering(): void;
159 159
160 160 /**
161 161 * Makes the given widget a child of this widget.
162 162 */
163 163 addChild<T extends _WidgetBase>(widget: T, insertIndex?: number): void;
164 164
165 165 /**
166 166 * Removes the passed widget instance from this widget but does
167 167 * not destroy it. You can also pass in an integer indicating
168 168 * the index within the container to remove (ie, removeChild(5) removes the sixth widget)
169 169 */
170 170 removeChild<T extends _WidgetBase>(widget: T): void;
171 171 removeChild<T extends number>(widget: number): void;
172 172
173 173 /**
174 174 * Returns true if widget has child widgets, i.e. if this.containerNode contains widgets.
175 175 */
176 176 hasChildren(): boolean;
177 177
178 178 /**
179 179 * Gets the index of the child in this container or -1 if not found
180 180 */
181 181 getIndexOfChild<T extends _WidgetBase>(widget: T): number;
182 182 }
183 183
184 184 interface _ContainerConstructor extends dojo._base.DeclareConstructor<_Container> { }
185 185
186 186 /* dijit/_CssStateMixin */
187 187
188 188 interface CSSStateNodes {
189 189 [node: string]: string;
190 190 }
191 191
192 192 interface _CssStateMixin {
193 193 /**
194 194 * True if cursor is over this widget
195 195 */
196 196 hovering: boolean;
197 197
198 198 /**
199 199 * True if mouse was pressed while over this widget, and hasn't been released yet
200 200 */
201 201 active: boolean;
202 202 }
203 203
204 204 interface _CssStateMixinConstructor extends dojo._base.DeclareConstructor<_CssStateMixin> { }
205 205
206 206 /* dijit/_DialogMixin */
207 207
208 208 interface _DialogMixin {
209 209 /**
210 210 * HTML snippet to show the action bar (gray bar with OK/cancel buttons).
211 211 * Blank by default, but used by ConfirmDialog/ConfirmTooltipDialog subclasses.
212 212 */
213 213 actionBarTemplate: string;
214 214
215 215 /**
216 216 * Callback when the user hits the submit button.
217 217 * Override this method to handle Dialog execution.
218 218 */
219 219 execute(formContents?: any): void;
220 220
221 221 /**
222 222 * Called when user has pressed the Dialog's cancel button, to notify container.
223 223 */
224 224 onCancel(): void;
225 225
226 226 /**
227 227 * Called when user has pressed the dialog's OK button, to notify container.
228 228 */
229 229 onExecute(): void;
230 230 }
231 231
232 232 /* dijit/_FocusMixin */
233 233 interface _FocusMixin { }
234 234
235 235 interface _WidgetBase {
236 236 /**
237 237 * Called when the widget becomes "active" because
238 238 * it or a widget inside of it either has focus, or has recently
239 239 * been clicked.
240 240 */
241 241 onFocus(): void;
242 242
243 243 /**
244 244 * Called when the widget stops being "active" because
245 245 * focus moved to something outside of it, or the user
246 246 * clicked somewhere outside of it, or the widget was
247 247 * hidden.
248 248 */
249 249 onBlur(): void;
250 250 }
251 251
252 252 /* dijit/_HasDropDown */
253 253
254 254 interface _HasDropDown<T extends _WidgetBase> extends _FocusMixin {
255 255 /**
256 256 * The button/icon/node to click to display the drop down.
257 257 * Can be set via a data-dojo-attach-point assignment.
258 258 * If missing, then either focusNode or domNode (if focusNode is also missing) will be used.
259 259 */
260 260 _buttonNode: HTMLElement;
261 261
262 262 /**
263 263 * Will set CSS class dijitUpArrow, dijitDownArrow, dijitRightArrow etc. on this node depending
264 264 * on where the drop down is set to be positioned.
265 265 * Can be set via a data-dojo-attach-point assignment.
266 266 * If missing, then _buttonNode will be used.
267 267 */
268 268 _arrowWrapperNode: HTMLElement;
269 269
270 270 /**
271 271 * The node to set the aria-expanded class on.
272 272 * Also sets popupActive class but that will be removed in 2.0.
273 273 * Can be set via a data-dojo-attach-point assignment.
274 274 * If missing, then focusNode or _buttonNode (if focusNode is missing) will be used.
275 275 */
276 276 _popupStateNode: HTMLElement;
277 277
278 278 /**
279 279 * The node to display the popup around.
280 280 * Can be set via a data-dojo-attach-point assignment.
281 281 * If missing, then domNode will be used.
282 282 */
283 283 _aroundNode: HTMLElement;
284 284
285 285 /**
286 286 * The widget to display as a popup. This widget *must* be
287 287 * defined before the startup function is called.
288 288 */
289 289 dropDown: T;
290 290
291 291 /**
292 292 * Set to true to make the drop down at least as wide as this
293 293 * widget. Set to false if the drop down should just be its
294 294 * default width.
295 295 */
296 296 autoWidth: boolean;
297 297
298 298 /**
299 299 * Set to true to make the drop down exactly as wide as this
300 300 * widget. Overrides autoWidth.
301 301 */
302 302 forceWidth: boolean;
303 303
304 304 /**
305 305 * The max height for our dropdown.
306 306 * Any dropdown taller than this will have scrollbars.
307 307 * Set to 0 for no max height, or -1 to limit height to available space in viewport
308 308 */
309 309 maxHeight: number;
310 310
311 311 /**
312 312 * This variable controls the position of the drop down.
313 313 * It's an array of strings
314 314 */
315 315 dropDownPosition: string[];
316 316 /* TODO remove for TS 1.8 */
317 317 /* dropDownPosition: ('before' | 'after' | 'above' | 'below')[]; */
318 318
319 319 /**
320 320 * When set to false, the click events will not be stopped, in
321 321 * case you want to use them in your subclass
322 322 */
323 323 _stopClickEvents: boolean;
324 324
325 325 /**
326 326 * Callback when the user mousedown/touchstart on the arrow icon.
327 327 */
328 328 _onDropDownMouseDown(e: MouseEvent): void;
329 329
330 330 /**
331 331 * Callback on mouseup/touchend after mousedown/touchstart on the arrow icon.
332 332 * Note that this function is called regardless of what node the event occurred on (but only after
333 333 * a mousedown/touchstart on the arrow).
334 334 */
335 335 _onDropDownMouseUp(e?: MouseEvent): void;
336 336
337 337 /**
338 338 * The drop down was already opened on mousedown/keydown; just need to stop the event
339 339 */
340 340 _onDropDownClick(e: MouseEvent): void;
341 341
342 342 buildRendering(): void;
343 343 postCreate(): void;
344 344 destroy(preserveDom?: boolean): void;
345 345
346 346 /**
347 347 * Returns true if the dropdown exists and it's data is loaded. This can
348 348 * be overridden in order to force a call to loadDropDown().
349 349 */
350 350 isLoaded(): boolean;
351 351
352 352 /**
353 353 * Creates the drop down if it doesn't exist, loads the data
354 354 * if there's an href and it hasn't been loaded yet, and then calls
355 355 * the given callback.
356 356 */
357 357 loadDropDown(loadCallback: () => void): void;
358 358
359 359 /**
360 360 * Creates the drop down if it doesn't exist, loads the data
361 361 * if there's an href and it hasn't been loaded yet, and
362 362 * then opens the drop down. This is basically a callback when the
363 363 * user presses the down arrow button to open the drop down.
364 364 */
365 365 loadAndOpenDropDown(): dojo.Deferred<T>;
366 366
367 367 /**
368 368 * Callback when the user presses the down arrow button or presses
369 369 * the down arrow key to open/close the drop down.
370 370 * Toggle the drop-down widget; if it is up, close it, if not, open it
371 371 */
372 372 toggleDropDown(): void;
373 373
374 374 /**
375 375 * Opens the dropdown for this widget. To be called only when this.dropDown
376 376 * has been created and is ready to display (ie, it's data is loaded).
377 377 */
378 378 openDropDown(): PlaceLocation;
379 379
380 380 /**
381 381 * Closes the drop down on this widget
382 382 */
383 383 closeDropDown(focus?: boolean): void;
384 384 }
385 385
386 386 /* dijit/_OnDijitClickMixin */
387 387
388 388 interface _OnDijitClickMixin {
389 389 /**
390 390 * override _WidgetBase.connect() to make this.connect(node, "ondijitclick", ...) work
391 391 */
392 392 connect(obj: any, event: string | dojo.ExtensionEvent, method: string | dojo.EventListener): dojo.WatchHandle;
393 393 }
394 394
395 395 interface _OnDijitClickMixinConstructor {
396 396 /**
397 397 * Deprecated. New code should access the dijit/a11yclick event directly, ex:
398 398 * | this.own(on(node, a11yclick, function(){ ... }));
399 399 *
400 400 * Mixing in this class will make _WidgetBase.connect(node, "ondijitclick", ...) work.
401 401 * It also used to be necessary to make templates with ondijitclick work, but now you can just require
402 402 * dijit/a11yclick.
403 403 */
404 404 new(): _OnDijitClickMixin;
405 405 a11yclick: A11yClick;
406 406 }
407 407
408 408 /* dijit/_TemplatedMixin */
409 409
410 410 interface _TemplatedMixin extends _AttachMixin {
411 411
412 412 /**
413 413 * A string that represents the widget template.
414 414 * Use in conjunction with dojo.cache() to load from a file.
415 415 */
416 416 templateString: string;
417 417
418 418 /**
419 419 * Path to template (HTML file) for this widget relative to dojo.baseUrl.
420 420 * Deprecated: use templateString with require([... "dojo/text!..."], ...) instead
421 421 */
422 422 templatePath: string;
423 423
424 424 /**
425 425 * Set _AttachMixin.searchContainerNode to true for back-compat for widgets that have data-dojo-attach-point's
426 426 * and events inside this.containerNode. Remove for 2.0.
427 427 */
428 428 searchContainerNode: boolean;
429 429
430 430 /**
431 431 * Construct the UI for this widget from a template, setting this.domNode.
432 432 */
433 433 buildRendering(): void;
434 434 }
435 435
436 436 interface _TemplatedMixinConstructor extends _WidgetBaseConstructor<_TemplatedMixin> {
437 437 /**
438 438 * Static method to get a template based on the templatePath or
439 439 * templateString key
440 440 */
441 441 getCachedTemplate(templateString: string, alwaysUseString: string, doc?: Document): string | HTMLElement;
442 442 }
443 443
444 444 /* dijit/_Widget */
445 445 interface _Widget extends _WidgetBase, _OnDijitClickMixin, _FocusMixin {
446 446 /**
447 447 * Connect to this function to receive notifications of mouse click events.
448 448 */
449 449 onClick(event: MouseEvent): void;
450 450
451 451 /**
452 452 * Connect to this function to receive notifications of mouse double click events.
453 453 */
454 454 onDblClick(event: MouseEvent): void;
455 455
456 456 /**
457 457 * Connect to this function to receive notifications of keys being pressed down.
458 458 */
459 459 onKeyDown(event: KeyboardEvent): void;
460 460
461 461 /**
462 462 * Connect to this function to receive notifications of printable keys being typed.
463 463 */
464 464 onKeyPress(event: KeyboardEvent): void;
465 465
466 466 /**
467 467 * Connect to this function to receive notifications of keys being released.
468 468 */
469 469 onKeyUp(event: KeyboardEvent): void;
470 470
471 471 /**
472 472 * Connect to this function to receive notifications of when the mouse button is pressed down.
473 473 */
474 474 onMouseDown(event: MouseEvent): void;
475 475
476 476 /**
477 477 * Connect to this function to receive notifications of when the mouse moves over nodes contained within this widget.
478 478 */
479 479 onMouseMove(event: MouseEvent): void;
480 480
481 481 /**
482 482 * Connect to this function to receive notifications of when the mouse moves off of nodes contained within this widget.
483 483 */
484 484 onMouseOut(event: MouseEvent): void;
485 485
486 486 /**
487 487 * Connect to this function to receive notifications of when the mouse moves onto nodes contained within this widget.
488 488 */
489 489 onMouseOver(event: MouseEvent): void;
490 490
491 491 /**
492 492 * Connect to this function to receive notifications of when the mouse moves off of this widget.
493 493 */
494 494 onMouseLeave(event: MouseEvent): void;
495 495
496 496 /**
497 497 * Connect to this function to receive notifications of when the mouse moves onto this widget.
498 498 */
499 499 onMouseEnter(event: MouseEvent): void;
500 500
501 501 /**
502 502 * Connect to this function to receive notifications of when the mouse button is released.
503 503 */
504 504 onMouseUp(event: MouseEvent): void;
505 505
506 506 postCreate(): void;
507 507
508 508 /**
509 509 * Deprecated. Use set() instead.
510 510 */
511 511 setAttribute(attr: string, value: any): void;
512 512
513 513 /**
514 514 * This method is deprecated, use get() or set() directly.
515 515 */
516 516 attr(name: string | { [attr: string]: any }, value?: any): any;
517 517
518 518 /**
519 519 * Returns all the widgets contained by this, i.e., all widgets underneath this.containerNode.
520 520 */
521 521 getDescendants(): _Widget[];
522 522
523 523 /**
524 524 * Called when this widget becomes the selected pane in a
525 525 * `dijit/layout/TabContainer`, `dijit/layout/StackContainer`,
526 526 * `dijit/layout/AccordionContainer`, etc.
527 527 *
528 528 * Also called to indicate display of a `dijit.Dialog`, `dijit.TooltipDialog`, or `dijit.TitlePane`.
529 529 */
530 530 onShow(): void;
531 531
532 532 /**
533 533 * Called when another widget becomes the selected pane in a
534 534 * `dijit/layout/TabContainer`, `dijit/layout/StackContainer`,
535 535 * `dijit/layout/AccordionContainer`, etc.
536 536 *
537 537 * Also called to indicate hide of a `dijit.Dialog`, `dijit.TooltipDialog`, or `dijit.TitlePane`.
538 538 */
539 539 onHide(): void;
540 540
541 541 /**
542 542 * Called when this widget is being displayed as a popup (ex: a Calendar popped
543 543 * up from a DateTextBox), and it is hidden.
544 544 * This is called from the dijit.popup code, and should not be called directly.
545 545 *
546 546 * Also used as a parameter for children of `dijit/layout/StackContainer` or subclasses.
547 547 * Callback if a user tries to close the child. Child will be closed if this function returns true.
548 548 */
549 549 onClose(): boolean;
550 550 }
551 551
552 552 interface _WidgetBase {
553 553 /**
554 554 * Used across all instances a hash to cache attribute names and their getter
555 555 * and setter names.
556 556 */
557 557 _attrPairNames: { [attr: string]: string };
558 558
559 559 /**
560 560 * Helper function for get() and set().
561 561 * Caches attribute name values so we don't do the string ops every time.
562 562 */
563 563 _getAttrNames(name: string): string;
564 564
565 565 /**
566 566 * Internal helper for directly changing an attribute value.
567 567 * This method id derived from Stateful and must not be used!
568 568 * @deprecated use `_set(name, value)` instead.
569 569 */
570 570 _changeAttrValue(name: string, value: any): this;
571 571
572 572 get<K extends keyof this>(name: K): this[K];
573 573
574 574 /**
575 575 * Helper function to set new value for specified property, and call handlers
576 576 * registered with watch() if the value has changed.
577 577 * @param name
578 578 * @param value
579 579 */
580 580 _set<K extends keyof this>(name: K, value: this[K]): void;
581 581
582 582 /**
583 583 * Helper function to get value for specified property stored by this._set(),
584 584 * i.e. for properties with custom setters. Used mainly by custom getters.
585 585 *
586 586 * For example, CheckBox._getValueAttr() calls this._get("value").
587 587 * @param name
588 588 */
589 589 _get<K extends keyof this>(name: K): this[K];
590 590
591 591 /**
592 592 * Set a property on a Stateful instance
593 593 */
594 594 set<K extends keyof this>(name: K, value: this[K], ...opts: unknown[]): this;
595 set(values: Partial<this>): this;
595 set<K extends keyof this>(values: {[k in K]?: this[k]}): this;
596 596
597 597 /**
598 598 * Watches a property for changes
599 599 */
600 600 watch(callback: <K extends keyof any>(prop: K, oldValue: any, newValue: any) => void): dojo.WatchHandle;
601 601 watch<K extends keyof this>(name: K, callback: (prop: K, oldValue: this[K], newValue: this[K]) => void): dojo.WatchHandle;
602 602 }
603 603
604 604 type EventInitArgs<T extends Event> = {
605 605 [p in keyof T]?: T[p] extends (...args: any) => any ? never : T[p];
606 606 };
607 607
608 608 /* dijit/_WidgetBase */
609 609 interface _WidgetBase<Events extends { [name in keyof Events]: Event } = GlobalEventHandlersEventMap> extends Destroyable {
610 610
611 611 /**
612 612 * A unique, opaque ID string that can be assigned by users or by the
613 613 * system. If the developer passes an ID which is known not to be
614 614 * unique, the specified ID is ignored and the system-generated ID is
615 615 * used instead.
616 616 */
617 617 id: string;
618 618
619 619 /**
620 620 * Rarely used. Overrides the default Dojo locale used to render this widget,
621 621 * as defined by the [HTML LANG](http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute.
622 622 * Value must be among the list of locales specified during by the Dojo bootstrap,
623 623 * formatted according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt) (like en-us).
624 624 */
625 625 lang: string;
626 626
627 627 /**
628 628 * Bi-directional support, as defined by the [HTML DIR](http://www.w3.org/TR/html401/struct/dirlang.html#adef-dir)
629 629 * attribute. Either left-to-right "ltr" or right-to-left "rtl". If undefined, widgets renders in page's
630 630 * default direction.
631 631 */
632 632 dir: string;
633 633
634 634 /**
635 635 * HTML class attribute
636 636 */
637 637 class: string;
638 638
639 639 /**
640 640 * HTML style attributes as cssText string or name/value hash
641 641 */
642 642 style: string;
643 643
644 644 /**
645 645 * HTML title attribute.
646 646 *
647 647 * For form widgets this specifies a tooltip to display when hovering over
648 648 * the widget (just like the native HTML title attribute).
649 649 *
650 650 * For TitlePane or for when this widget is a child of a TabContainer, AccordionContainer,
651 651 * etc., it's used to specify the tab label, accordion pane title, etc. In this case it's
652 652 * interpreted as HTML.
653 653 */
654 654 title: string;
655 655
656 656 /**
657 657 * When this widget's title attribute is used to for a tab label, accordion pane title, etc.,
658 658 * this specifies the tooltip to appear when the mouse is hovered over that text.
659 659 */
660 660 tooltip: string;
661 661
662 662 /**
663 663 * Root CSS class of the widget (ex: dijitTextBox), used to construct CSS classes to indicate
664 664 * widget state.
665 665 */
666 666 baseClass: string;
667 667
668 668 /**
669 669 * pointer to original DOM node
670 670 */
671 671 srcNodeRef: HTMLElement;
672 672
673 673 /**
674 674 * This is our visible representation of the widget! Other DOM
675 675 * Nodes may by assigned to other properties, usually through the
676 676 * template system's data-dojo-attach-point syntax, but the domNode
677 677 * property is the canonical "top level" node in widget UI.
678 678 */
679 679 domNode: HTMLElement;
680 680
681 681 /**
682 682 * Designates where children of the source DOM node will be placed.
683 683 * "Children" in this case refers to both DOM nodes and widgets.
684 684 */
685 685 containerNode: HTMLElement;
686 686
687 687 /**
688 688 * The document this widget belongs to. If not specified to constructor, will default to
689 689 * srcNodeRef.ownerDocument, or if no sourceRef specified, then to the document global
690 690 */
691 691 ownerDocument: HTMLElement;
692 692
693 693 /**
694 694 * Deprecated. Instead of attributeMap, widget should have a _setXXXAttr attribute
695 695 * for each XXX attribute to be mapped to the DOM.
696 696 */
697 697 attributeMap: { [attribute: string]: any };
698 698
699 699 /**
700 700 * Bi-directional support, the main variable which is responsible for the direction of the text.
701 701 * The text direction can be different than the GUI direction by using this parameter in creation
702 702 * of a widget.
703 703 */
704 704 textDir: string;
705 705
706 706 _started?: boolean;
707 707
708 708 /**
709 709 * Kicks off widget instantiation. See create() for details.
710 710 */
711 711 postscript(params?: any, srcNodeRef?: HTMLElement): void;
712 712
713 713 /**
714 714 * Kick off the life-cycle of a widget
715 715 */
716 716 create(params?: any, srcNodeRef?: HTMLElement): void;
717 717
718 718 /**
719 719 * Called after the parameters to the widget have been read-in,
720 720 * but before the widget template is instantiated. Especially
721 721 * useful to set properties that are referenced in the widget
722 722 * template.
723 723 */
724 724 postMixInProperties(): void;
725 725
726 726 /**
727 727 * Construct the UI for this widget, setting this.domNode.
728 728 * Most widgets will mixin `dijit._TemplatedMixin`, which implements this method.
729 729 */
730 730 buildRendering(): void;
731 731
732 732 /**
733 733 * Processing after the DOM fragment is created
734 734 */
735 735 postCreate(): void;
736 736
737 737 /**
738 738 * Processing after the DOM fragment is added to the document
739 739 */
740 740 startup(): void;
741 741
742 742 /**
743 743 * Destroy this widget and its descendants
744 744 */
745 745 destroyRecursive(preserveDom?: boolean): void;
746 746
747 747 /**
748 748 * Destroys the DOM nodes associated with this widget.
749 749 */
750 750 destroyRendering(preserveDom?: boolean): void;
751 751
752 752 /**
753 753 * Recursively destroy the children of this widget and their
754 754 * descendants.
755 755 */
756 756 destroyDescendants(preserveDom?: boolean): void;
757 757
758 758 /**
759 759 * Deprecated. Override destroy() instead to implement custom widget tear-down
760 760 * behavior.
761 761 * @deprecated
762 762 */
763 763 uninitialize(): boolean;
764 764
765 765 /**
766 766 * Used by widgets to signal that a synthetic event occurred, ex:
767 767 * | myWidget.emit("attrmodified-selectedChildWidget", {}).
768 768 */
769 769 emit<K extends keyof Events>(eventName: K, evt: EventInitArgs<Events[K]>, callbackArgs?: any[]): any;
770 770
771 771 /**
772 772 * Call specified function when event occurs, ex: myWidget.on("click", function(){ ... }).
773 773 */
774 774 on<K extends keyof Events>(eventName: K, cb: (evt: Events[K]) => void): dojo.WatchHandle;
775 775
776 776 on(type: dojo.ExtensionEvent, func: dojo.EventListener): dojo.WatchHandle;
777 777
778 778 /**
779 779 * Returns a string that represents the widget.
780 780 */
781 781 toString(): string;
782 782
783 783 /**
784 784 * Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent
785 785 * is this widget. Note that it does not return all descendants, but rather just direct children.
786 786 */
787 787 getChildren<T extends _WidgetBase>(): T[];
788 788
789 789 /**
790 790 * Returns the parent widget of this widget.
791 791 */
792 792 getParent<T extends _WidgetBase>(): T;
793 793
794 794 /**
795 795 * Deprecated, will be removed in 2.0, use this.own(on(...)) or this.own(aspect.after(...)) instead.
796 796 * @deprecated
797 797 */
798 798 connect(obj: any, event: string | dojo.ExtensionEvent, method: string | dojo.EventListener): dojo.WatchHandle;
799 799
800 800 /**
801 801 * Deprecated, will be removed in 2.0, use handle.remove() instead.
802 802 * @deprecated
803 803 */
804 804 disconnect(handle: dojo.WatchHandle): void;
805 805
806 806 /**
807 807 * Deprecated, will be removed in 2.0, use this.own(topic.subscribe()) instead.
808 808 * @deprecated
809 809 */
810 810 subscribe(t: string, method: dojo.EventListener): dojo.WatchHandle;
811 811
812 812 /**
813 813 * Deprecated, will be removed in 2.0, use handle.remove() instead.
814 814 * @deprecated
815 815 */
816 816 unsubscribe(handle: dojo.WatchHandle): void;
817 817
818 818 /**
819 819 * Return this widget's explicit or implicit orientation (true for LTR, false for RTL)
820 820 */
821 821 isLeftToRight(): boolean;
822 822
823 823 /**
824 824 * Return true if this widget can currently be focused
825 825 * and false if not
826 826 */
827 827 isFocusable(): boolean;
828 828
829 829 /**
830 830 * Place this widget somewhere in the DOM based
831 831 * on standard domConstruct.place() conventions.
832 832 */
833 833 placeAt<T extends _WidgetBase>(reference: dojo.NodeFragmentOrString | T, position?: string | number): this;
834 834
835 835 /**
836 836 * Wrapper to setTimeout to avoid deferred functions executing
837 837 * after the originating widget has been destroyed.
838 838 * Returns an object handle with a remove method (that returns null) (replaces clearTimeout).
839 839 */
840 840 defer(fcn: Function, delay?: number): dojo.Handle;
841 841 }
842 842
843 843 interface _WidgetBaseConstructor<W> extends Pick<dojo._base.DeclareConstructor<W>, Exclude<keyof dojo._base.DeclareConstructor<W>, 'new'>> {
844 844 new(params?: Partial<W> & ThisType<W>, srcNodeRef?: dojo.NodeOrString): W & dojo._base.DeclareCreatedObject;
845 845 }
846 846
847 847 /* dijit/_WidgetsInTemplateMixin */
848 848
849 849 interface _WidgetsInTemplateMixin {
850 850 /**
851 851 * Used to provide a context require to dojo/parser in order to be
852 852 * able to use relative MIDs (e.g. `./Widget`) in the widget's template.
853 853 */
854 854 contextRequire: Function;
855 855
856 856 startup(): void;
857 857 }
858 858
859 859 interface _WidgetsInTemplateMixinConstructor extends dojo._base.DeclareConstructor<_WidgetsInTemplateMixin> {
860 860 new(params: Object, srcNodeRef: dojo.NodeOrString): _WidgetsInTemplateMixin;
861 861 }
862 862
863 863 /* dijit/a11yclick */
864 864
865 865 interface A11yClick {
866 866
867 867 /**
868 868 * Custom press, release, and click synthetic events
869 869 * which trigger on a left mouse click, touch, or space/enter keyup.
870 870 */
871 871 (node: HTMLElement, listener: Function): dojo.Handle;
872 872
873 873 /**
874 874 * Mousedown (left button), touchstart, or keydown (space or enter) corresponding to logical click operation.
875 875 */
876 876 press: dojo.ExtensionEvent;
877 877
878 878 /**
879 879 * Mouseup (left button), touchend, or keyup (space or enter) corresponding to logical click operation.
880 880 */
881 881 release: dojo.ExtensionEvent;
882 882
883 883 /**
884 884 * Mouse cursor or a finger is dragged over the given node.
885 885 */
886 886 move: dojo.ExtensionEvent;
887 887 }
888 888
889 889 /* dijit/Calendar */
890 890
891 891 interface _MonthDropDownButton extends form.DropDownButton<_MonthDropDown> {
892 892 onMonthSelect(): void;
893 893 postCreate(): void;
894 894
895 895 //set(name: 'month', value: number): this;
896 896 //set(name: string, value: any): this;
897 897 //set(values: Object): this;
898 898 }
899 899
900 900 interface _MonthDropDownButtonConstructor extends _WidgetBaseConstructor<_MonthDropDownButton> { }
901 901
902 902 interface _MonthDropDown extends _Widget, _TemplatedMixin, _CssStateMixin {
903 903 months: string[];
904 904 baseClass: string;
905 905 templateString: string;
906 906
907 907 /**
908 908 * Callback when month is selected from drop down
909 909 */
910 910 onChange(month: number): void;
911 911
912 912 //set(name: 'months', value: string[]): this;
913 913 //set(name: string, value: any): this;
914 914 //set(values: Object): this;
915 915 }
916 916
917 917 interface _MonthDropDownConstructor extends _WidgetBaseConstructor<_MonthDropDown> { }
918 918
919 919 interface Calendar extends CalendarLite, _Widget, _CssStateMixin {
920 920
921 921 baseClass: string;
922 922
923 923 /**
924 924 * Set node classes for various mouse events, see dijit._CssStateMixin for more details
925 925 */
926 926 cssStateNodes: CSSStateNodes;
927 927
928 928 /**
929 929 * Creates the drop down button that displays the current month and lets user pick a new one
930 930 */
931 931 _createMonthWidget(): _MonthDropDownButton;
932 932
933 933 postCreate(): void;
934 934
935 935 /**
936 936 * Handler for when user selects a month from the drop down list
937 937 */
938 938 _onMonthSelect(newMonth: number): void;
939 939
940 940 /**
941 941 * Handler for mouse over events on days, sets hovered style
942 942 */
943 943 _onDayMouseOver(evt: MouseEvent): void;
944 944
945 945 /**
946 946 * Handler for mouse out events on days, clears hovered style
947 947 */
948 948 _onDayMouseOut(evt: MouseEvent): void;
949 949 _onDayMouseDown(evt: MouseEvent): void;
950 950 _onDayMouseUp(evt: MouseEvent): void;
951 951
952 952 /**
953 953 * Provides keyboard navigation of calendar.
954 954 */
955 955 handleKey(evt: KeyboardEvent): void;
956 956
957 957 /**
958 958 * For handling keydown events on a stand alone calendar
959 959 */
960 960 _onKeyDown(evt: KeyboardEvent): void;
961 961
962 962 /**
963 963 * Deprecated. Notification that a date cell was selected. It may be the same as the previous value.
964 964 */
965 965 onValueSelected(date: Date): void;
966 966
967 967 onChange(date: Date): void;
968 968
969 969 /**
970 970 * May be overridden to return CSS classes to associate with the date entry for the given dateObject
971 971 * for example to indicate a holiday in specified locale.
972 972 */
973 973 getClassForDate(dateObject: Date, locale?: string): string;
974 974
975 975 // get(name: 'value'): Date;
976 976 // get(name: string): any;
977 977
978 978 // set(name: 'value', value: number | Date): this;
979 979 // set(name: string, value: any): this;
980 980 // set(values: Object): this;
981 981 }
982 982
983 983 interface CalendarConstructor extends _WidgetBaseConstructor<Calendar> {
984 984 _MonthWidget: _MonthWidgetConstructor;
985 985 _MonthDropDown: _MonthDropDownButtonConstructor;
986 986 _MonthDropDownButton: _MonthDropDownButtonConstructor;
987 987 }
988 988
989 989 /* dijit/CalendarLite */
990 990
991 991 interface _MonthWidget extends _WidgetBase {
992 992 // set(name: 'month', value: Date): this;
993 993 // set(name: string, value: any): this;
994 994 // set(values: Object): this;
995 995 }
996 996
997 997 interface _MonthWidgetConstructor extends _WidgetBaseConstructor<_MonthWidget> { }
998 998
999 999 interface CalendarLite extends _WidgetBase, _TemplatedMixin {
1000 1000 /**
1001 1001 * Template for main calendar
1002 1002 */
1003 1003 templateString: string;
1004 1004
1005 1005 /**
1006 1006 * Template for cell for a day of the week (ex: M)
1007 1007 */
1008 1008 dowTemplateString: string;
1009 1009
1010 1010 dateTemplateString: string;
1011 1011 weekTemplateString: string;
1012 1012
1013 1013 /**
1014 1014 * The currently selected Date, initially set to invalid date to indicate no selection.
1015 1015 */
1016 1016 value: Date;
1017 1017
1018 1018 /**
1019 1019 * JavaScript namespace to find calendar routines. If unspecified, uses Gregorian calendar routines
1020 1020 * at dojo/date and dojo/date/locale.
1021 1021 */
1022 1022 datePackage: string;
1023 1023
1024 1024 /**
1025 1025 * How to represent the days of the week in the calendar header. See locale
1026 1026 */
1027 1027 dayWidth: string;
1028 1028
1029 1029 /**
1030 1030 * Order fields are traversed when user hits the tab key
1031 1031 */
1032 1032 tabIndex: string;
1033 1033
1034 1034 /**
1035 1035 * (Optional) The first day of week override. By default the first day of week is determined
1036 1036 * for the current locale (extracted from the CLDR).
1037 1037 * Special value -1 (default value), means use locale dependent value.
1038 1038 */
1039 1039 dayOffset: number;
1040 1040
1041 1041 /**
1042 1042 * Date object containing the currently focused date, or the date which would be focused
1043 1043 * if the calendar itself was focused. Also indicates which year and month to display,
1044 1044 * i.e. the current "page" the calendar is on.
1045 1045 */
1046 1046 currentFocus: Date;
1047 1047
1048 1048 /**
1049 1049 * Put the summary to the node with role=grid
1050 1050 */
1051 1051 _setSummaryAttr: string;
1052 1052
1053 1053 baseClass: string;
1054 1054
1055 1055 /**
1056 1056 * Runs various tests on the value, checking that it's a valid date, rather
1057 1057 * than blank or NaN.
1058 1058 */
1059 1059 _isValidDate(value: Date): boolean;
1060 1060
1061 1061 /**
1062 1062 * Convert Number into Date, or copy Date object. Then, round to nearest day,
1063 1063 * setting to 1am to avoid issues when DST shift occurs at midnight, see #8521, #9366)
1064 1064 */
1065 1065 _patchDate(value: number | Date): Date;
1066 1066
1067 1067 /**
1068 1068 * This just sets the content of node to the specified text.
1069 1069 * Can't do "node.innerHTML=text" because of an IE bug w/tables, see #3434.
1070 1070 */
1071 1071 _setText(node: HTMLElement, text?: string): void;
1072 1072
1073 1073 /**
1074 1074 * Fills in the calendar grid with each day (1-31).
1075 1075 * Call this on creation, when moving to a new month.
1076 1076 */
1077 1077 _populateGrid(): void;
1078 1078
1079 1079 /**
1080 1080 * Fill in localized month, and prev/current/next years
1081 1081 */
1082 1082 _populateControls(): void;
1083 1083
1084 1084 /**
1085 1085 * Sets calendar's value to today's date
1086 1086 */
1087 1087 goToToday(): void;
1088 1088
1089 1089 /**
1090 1090 * Creates the drop down button that displays the current month and lets user pick a new one
1091 1091 */
1092 1092 _createMonthWidget(): void;
1093 1093
1094 1094 buildRendering(): void;
1095 1095 postCreate(): void;
1096 1096
1097 1097 /**
1098 1098 * Set up connects for increment/decrement of months/years
1099 1099 */
1100 1100 _connectControls(): void;
1101 1101
1102 1102 /**
1103 1103 * If the calendar currently has focus, then focuses specified date,
1104 1104 * changing the currently displayed month/year if necessary.
1105 1105 * If the calendar doesn't have focus, updates currently
1106 1106 * displayed month/year, and sets the cell that will get focus
1107 1107 * when Calendar is focused.
1108 1108 */
1109 1109 _setCurrentFocusAttr(date: Date, forceFocus?: boolean): void;
1110 1110
1111 1111 /**
1112 1112 * Focus the calendar by focusing one of the calendar cells
1113 1113 */
1114 1114 focus(): void;
1115 1115
1116 1116 /**
1117 1117 * Handler for day clicks, selects the date if appropriate
1118 1118 */
1119 1119 _onDayClick(evt: MouseEvent): void;
1120 1120
1121 1121 /**
1122 1122 * Returns the cell corresponding to the date, or null if the date is not within the currently
1123 1123 * displayed month.
1124 1124 */
1125 1125 _getNodeByDate(value: Date): HTMLElement;
1126 1126
1127 1127 /**
1128 1128 * Marks the specified cells as selected, and clears cells previously marked as selected.
1129 1129 * For CalendarLite at most one cell is selected at any point, but this allows an array
1130 1130 * for easy subclassing.
1131 1131 */
1132 1132 _markSelectedDates(dates: Date[]): void;
1133 1133
1134 1134 /**
1135 1135 * Called only when the selected date has changed
1136 1136 */
1137 1137 onChange(date: Date): void;
1138 1138
1139 1139 /**
1140 1140 * May be overridden to disable certain dates in the calendar e.g. `isDisabledDate=dojo.date.locale.isWeekend`
1141 1141 */
1142 1142 isDisabledDate(dateObject: Date, locale?: string): boolean;
1143 1143
1144 1144 /**
1145 1145 * May be overridden to return CSS classes to associate with the date entry for the given dateObject,
1146 1146 * for example to indicate a holiday in specified locale.
1147 1147 */
1148 1148 getClassForDate(dateObject: Date, locale?: string): string;
1149 1149
1150 1150 // get(name: 'value'): Date;
1151 1151 // get(name: string): any;
1152 1152
1153 1153 // set(name: 'value', value: number | Date): this;
1154 1154 // set(name: string, value: any): this;
1155 1155 // set(values: Object): this;
1156 1156 }
1157 1157
1158 1158 interface CalendarLiteConstructor extends _WidgetBaseConstructor<CalendarLite> {
1159 1159 _MonthWidget: _MonthWidgetConstructor;
1160 1160 }
1161 1161
1162 1162 /* dijit/Destroyable */
1163 1163
1164 1164 interface Destroyable {
1165 1165 _destroyed?: true;
1166 1166
1167 1167 /**
1168 1168 * Destroy this class, releasing any resources registered via own().
1169 1169 */
1170 1170 destroy(preserveDom?: boolean): void;
1171 1171
1172 1172 /**
1173 1173 * Track specified handles and remove/destroy them when this instance is destroyed, unless they were
1174 1174 * already removed/destroyed manually.
1175 1175 */
1176 1176 own(...args: any[]): any[];
1177 1177 }
1178 1178
1179 1179 /**
1180 1180 * Mixin to track handles and release them when instance is destroyed.
1181 1181 */
1182 1182 interface DestroyableConstructor extends dojo._base.DeclareConstructor<Destroyable> { }
1183 1183
1184 1184 /** dijit/_KeyNavMixin */
1185 1185
1186 1186 /**
1187 1187 * A mixin to allow arrow key and letter key navigation of child or descendant widgets.
1188 1188 * It can be used by dijit/_Container based widgets with a flat list of children, or more complex widgets like dijit/Tree.
1189 1189 *
1190 1190 * To use this mixin, the subclass must:
1191 1191 *
1192 1192 * - Implement _getNext(), _getFirst(), _getLast(), _onLeftArrow(), _onRightArrow() _onDownArrow(), _onUpArrow() methods to handle home/end/left/right/up/down keystrokes. Next and previous in this context refer to a linear ordering of the descendants used by letter key search.
1193 1193 * - Set all descendants' initial tabIndex to "-1"; both initial descendants and any descendants added later, by for example addChild()
1194 1194 * - Define childSelector to a function or string that identifies focusable descendant widgets
1195 1195 *
1196 1196 * Also, child widgets must implement a focus() method.
1197 1197 */
1198 1198 interface _KeyNavMixin extends _FocusMixin {
1199 1199 /**
1200 1200 * Tab index of the container; same as HTML tabIndex attribute.
1201 1201 * Note then when user tabs into the container, focus is immediately moved to the first item in the container.
1202 1202 */
1203 1203 tabIndex: string;
1204 1204
1205 1205 /**
1206 1206 * Selector (passed to on.selector()) used to identify what to treat as a child widget. Used to monitor focus events and set this.focusedChild. Must be set by implementing class. If this is a string (ex: "> *") then the implementing class must require dojo/query.
1207 1207 */
1208 1208 childSelector: string | Function | null;
1209 1209
1210 1210 /**
1211 1211 * Called on left arrow key, or right arrow key if widget is in RTL mode.
1212 1212 * Should go back to the previous child in horizontal container widgets like Toolbar.
1213 1213 */
1214 1214 _onLeftArrow(evt?: KeyboardEvent): void;
1215 1215
1216 1216 /**
1217 1217 * Called on right arrow key, or left arrow key if widget is in RTL mode.
1218 1218 * Should go to the next child in horizontal container widgets like Toolbar.
1219 1219 */
1220 1220 _onRightArrow(evt?: KeyboardEvent): void;
1221 1221
1222 1222 /**
1223 1223 * Called on up arrow key. Should go to the previous child in vertical container widgets like Menu.
1224 1224 */
1225 1225 _onUpArrow(evt?: KeyboardEvent): void;
1226 1226
1227 1227 /**
1228 1228 * Called on down arrow key. Should go to the next child in vertical container widgets like Menu.
1229 1229 */
1230 1230 _onDownArrow(evt?: KeyboardEvent): void;
1231 1231
1232 1232 /**
1233 1233 * Default focus() implementation: focus the first child.
1234 1234 */
1235 1235 focus(): void;
1236 1236
1237 1237 /**
1238 1238 * Returns first child that can be focused.
1239 1239 */
1240 1240 _getFirstFocusableChild(): _WidgetBase;
1241 1241
1242 1242 /**
1243 1243 * Returns last child that can be focused.
1244 1244 */
1245 1245 _getLastFocusableChild(): _WidgetBase;
1246 1246
1247 1247 /**
1248 1248 * Focus the first focusable child in the container.
1249 1249 */
1250 1250 focusFirstChild(): void;
1251 1251
1252 1252 /**
1253 1253 * Focus the last focusable child in the container.
1254 1254 */
1255 1255 focusLastChild(): void;
1256 1256
1257 1257 /**
1258 1258 * Focus specified child widget.
1259 1259 *
1260 1260 * @param widget Reference to container's child widget
1261 1261 * @param last If true and if widget has multiple focusable nodes, focus the last one instead of the first one
1262 1262 */
1263 1263 focusChild(widget: _WidgetBase, last?: boolean): void;
1264 1264
1265 1265 /**
1266 1266 * Handler for when the container itself gets focus.
1267 1267 *
1268 1268 * Initially the container itself has a tabIndex, but when it gets focus, switch focus to first child.
1269 1269 */
1270 1270 _onContainerFocus(evt: Event): void;
1271 1271
1272 1272 /**
1273 1273 * Called when a child widget gets focus, either by user clicking it, or programatically by arrow key handling code.
1274 1274 *
1275 1275 * It marks that the current node is the selected one, and the previously selected node no longer is.
1276 1276 */
1277 1277 _onChildFocus(child?: _WidgetBase): void;
1278 1278
1279 1279 _searchString: string;
1280 1280
1281 1281 multiCharSearchDuration: number;
1282 1282
1283 1283 /**
1284 1284 * When a key is pressed that matches a child item, this method is called so that a widget can take appropriate action is necessary.
1285 1285 */
1286 1286 onKeyboardSearch(tem: _WidgetBase, evt: Event, searchString: string, numMatches: number): void;
1287 1287
1288 1288 /**
1289 1289 * Compares the searchString to the widget's text label, returning:
1290 1290 *
1291 1291 * * -1: a high priority match and stop searching
1292 1292 * * 0: not a match
1293 1293 * * 1: a match but keep looking for a higher priority match
1294 1294 */
1295 1295 _keyboardSearchCompare(item: _WidgetBase, searchString: string): -1 | 0 | 1;
1296 1296
1297 1297 /**
1298 1298 * When a key is pressed, if it's an arrow key etc. then it's handled here.
1299 1299 */
1300 1300 _onContainerKeydown(evt: Event): void;
1301 1301
1302 1302 /**
1303 1303 * When a printable key is pressed, it's handled here, searching by letter.
1304 1304 */
1305 1305 _onContainerKeypress(evt: Event): void;
1306 1306
1307 1307 /**
1308 1308 * Perform a search of the widget's options based on the user's keyboard activity
1309 1309 *
1310 1310 * Called on keypress (and sometimes keydown), searches through this widget's children looking for items that match the user's typed search string. Multiple characters typed within 1 sec of each other are combined for multicharacter searching.
1311 1311 */
1312 1312 _keyboardSearch(evt: Event, keyChar: string): void;
1313 1313
1314 1314 /**
1315 1315 * Called when focus leaves a child widget to go to a sibling widget.
1316 1316 */
1317 1317 _onChildBlur(widget: _WidgetBase): void;
1318 1318
1319 1319 /**
1320 1320 * Returns the next or previous focusable descendant, compared to "child".
1321 1321 * Implements and extends _KeyNavMixin._getNextFocusableChild() for a _Container.
1322 1322 */
1323 1323 _getNextFocusableChild(child: _WidgetBase, dir: 1 | -1): _WidgetBase | null;
1324 1324
1325 1325 /**
1326 1326 * Returns the first child.
1327 1327 */
1328 1328 _getFirst(): _WidgetBase | null;
1329 1329
1330 1330 /**
1331 1331 * Returns the last descendant.
1332 1332 */
1333 1333 _getLast(): _WidgetBase | null;
1334 1334
1335 1335 /**
1336 1336 * Returns the next descendant, compared to "child".
1337 1337 */
1338 1338 _getNext(child: _WidgetBase, dir: 1 | -1): _WidgetBase | null;
1339 1339 }
1340 1340
1341 1341 interface _KeyNavMixinConstructor extends dojo._base.DeclareConstructor<_KeyNavMixin> { }
1342 1342
1343 1343 /* dijit/_KeyNavContainer */
1344 1344
1345 1345 /**
1346 1346 * A _Container with keyboard navigation of its children.
1347 1347 *
1348 1348 * Provides normalized keyboard and focusing code for Container widgets.
1349 1349 * To use this mixin, call connectKeyNavHandlers() in postCreate().
1350 1350 * Also, child widgets must implement a focus() method.
1351 1351 */
1352 1352 interface _KeyNavContainer extends _FocusMixin, _KeyNavMixin, _Container {
1353 1353 /**
1354 1354 * Deprecated. You can call this in postCreate() to attach the keyboard handlers to the container, but the preferred method is to override _onLeftArrow() and _onRightArrow(), or _onUpArrow() and _onDownArrow(), to call focusPrev() and focusNext().
1355 1355 *
1356 1356 * @param prevKeyCodes Key codes for navigating to the previous child.
1357 1357 * @param nextKeyCodes Key codes for navigating to the next child.
1358 1358 */
1359 1359 connectKeyNavHandlers(prevKeyCodes: number[], nextKeyCodes: number[]): void;
1360 1360
1361 1361 /**
1362 1362 * @deprecated
1363 1363 */
1364 1364 startupKeyNavChildren(): void;
1365 1365
1366 1366 /**
1367 1367 * Setup for each child widget.
1368 1368 *
1369 1369 * Sets tabIndex=-1 on each child, so that the tab key will leave the container rather than visiting each child.
1370 1370 *
1371 1371 * Note: if you add children by a different method than addChild(), then need to call this manually or at least make sure the child's tabIndex is -1.
1372 1372 *
1373 1373 * Note: see also _LayoutWidget.setupChild(), which is also called for each child widget.
1374 1374 */
1375 1375 _startupChild(widget: _WidgetBase): void;
1376 1376
1377 1377 /**
1378 1378 * Returns the first child.
1379 1379 */
1380 1380 _getFirst(): _Widget | null;
1381 1381
1382 1382 /**
1383 1383 * Returns the last descendant.
1384 1384 */
1385 1385 _getLast(): _Widget | null;
1386 1386
1387 1387 /**
1388 1388 * Focus the next widget
1389 1389 */
1390 1390 focusNext(): void;
1391 1391
1392 1392 /**
1393 1393 * Focus the last focusable node in the previous widget
1394 1394 *
1395 1395 * (ex: go to the ComboButton icon section rather than button section)
1396 1396 */
1397 1397 focusPrev(): void;
1398 1398
1399 1399 /**
1400 1400 * Implement _KeyNavMixin.childSelector, to identify focusable child nodes.
1401 1401 *
1402 1402 * If we allowed a dojo/query dependency from this module this could more simply be a string "> *" instead of this function.
1403 1403 */
1404 1404 childSelector(node: Element | Node): boolean | void | any;
1405 1405 }
1406 1406
1407 1407 interface _KeyNavContainerConstructor extends dojo._base.DeclareConstructor<_KeyNavContainer> { }
1408 1408
1409 1409 /* dijit/_MenuBase */
1410 1410
1411 1411 /**
1412 1412 * Abstract base class for Menu and MenuBar.
1413 1413 * Subclass should implement _onUpArrow(), _onDownArrow(), _onLeftArrow(), and _onRightArrow().
1414 1414 */
1415 1415 interface _MenuBase extends _Widget, _TemplatedMixin, _KeyNavContainer, _CssStateMixin {
1416 1416 selected: MenuItem | null;
1417 1417
1418 1418 _setSelectedAttr(item?: MenuItem | null): void;
1419 1419
1420 1420 /**
1421 1421 * This Menu has been clicked (mouse or via space/arrow key) or opened as a submenu, so mere mouseover will open submenus. Focusing a menu via TAB does NOT automatically make it active since TAB is a navigation operation and not a selection one.
1422 1422 *
1423 1423 * For Windows apps, pressing the ALT key focuses the menubar menus (similar to TAB navigation) but the menu is not active (ie no dropdown) until an item is clicked.
1424 1424 */
1425 1425 activated: boolean;
1426 1426
1427 1427 _setActivatedAttr(val: boolean): void;
1428 1428
1429 1429 /**
1430 1430 * pointer to menu that displayed me
1431 1431 */
1432 1432 parentMenu: _Widget | null;
1433 1433
1434 1434 /**
1435 1435 * After a menu has been activated (by clicking on it etc.), number of milliseconds before hovering (without clicking) another MenuItem causes that MenuItem's popup to automatically open.
1436 1436 */
1437 1437 popupDelay: number;
1438 1438
1439 1439 /**
1440 1440 * For a passive (unclicked) Menu, number of milliseconds before hovering (without clicking) will cause the popup to open. Default is Infinity, meaning you need to click the menu to open it.
1441 1441 */
1442 1442 passivePopupDelay: number;
1443 1443
1444 1444 /**
1445 1445 * A toggle to control whether or not a Menu gets focused when opened as a drop down from a MenuBar or DropDownButton/ComboButton. Note though that it always get focused when opened via the keyboard.
1446 1446 */
1447 1447 autoFocus: boolean;
1448 1448
1449 1449 /**
1450 1450 * Selector (passed to on.selector()) used to identify MenuItem child widgets, but exclude inert children like MenuSeparator. If subclass overrides to a string (ex: "> *"), the subclass must require dojo/query.
1451 1451 */
1452 1452 childSelector(node: Element | Node): boolean | void | Function;
1453 1453
1454 1454 /**
1455 1455 * Attach point for notification about when a menu item has been executed. This is an internal mechanism used for Menus to signal to their parent to close them, because they are about to execute the onClick handler. In general developers should not attach to or override this method.
1456 1456 */
1457 1457 onExecute(): void;
1458 1458
1459 1459 /**
1460 1460 * Attach point for notification about when the user cancels the current menu
1461 1461 * This is an internal mechanism used for Menus to signal to their parent to close them. In general developers should not attach to or override this method.
1462 1462 */
1463 1463 onCancel(): void;
1464 1464
1465 1465 /**
1466 1466 * This handles the right arrow key (left arrow key on RTL systems), which will either open a submenu, or move to the next item in the ancestor MenuBar
1467 1467 */
1468 1468 _moveToPopup(evt: Event): void;
1469 1469
1470 1470 /**
1471 1471 * This handler is called when the mouse moves over the popup.
1472 1472 */
1473 1473 _onPopupHover(evt?: MouseEvent): void;
1474 1474
1475 1475 /**
1476 1476 * Called when cursor is over a MenuItem.
1477 1477 */
1478 1478 onItemHover(item: MenuItem): void;
1479 1479
1480 1480 /**
1481 1481 * Called when a child MenuItem becomes deselected. Setup timer to close its popup.
1482 1482 */
1483 1483 _onChildDeselect(item: MenuItem): void;
1484 1484
1485 1485 /**
1486 1486 * Callback fires when mouse exits a MenuItem
1487 1487 */
1488 1488 onItemUnhover(item: MenuItem): void;
1489 1489
1490 1490 /**
1491 1491 * Cancels the popup timer because the user has stop hovering on the MenuItem, etc.
1492 1492 */
1493 1493 _stopPopupTimer(): void;
1494 1494
1495 1495 /**
1496 1496 * Cancels the pending-close timer because the close has been preempted
1497 1497 */
1498 1498 _stopPendingCloseTimer(): void;
1499 1499
1500 1500 /**
1501 1501 * Returns the top menu in this chain of Menus
1502 1502 */
1503 1503 _getTopMenu(): void;
1504 1504
1505 1505 /**
1506 1506 * Handle clicks on an item.
1507 1507 */
1508 1508 onItemClick(item: _WidgetBase, evt: Event): void;
1509 1509
1510 1510 /**
1511 1511 * Open the popup to the side of/underneath the current menu item, and optionally focus first item
1512 1512 */
1513 1513 _openItemPopup(fromItem: MenuItem, focus: boolean): void;
1514 1514
1515 1515 /**
1516 1516 * Callback when this menu is opened.
1517 1517 * This is called by the popup manager as notification that the menu was opened.
1518 1518 */
1519 1519 onOpen(evt?: Event): void;
1520 1520
1521 1521 /**
1522 1522 * Callback when this menu is closed.
1523 1523 * This is called by the popup manager as notification that the menu was closed.
1524 1524 */
1525 1525 onClose(): boolean;
1526 1526
1527 1527 /**
1528 1528 * Called when submenu is clicked or focus is lost. Close hierarchy of menus.
1529 1529 */
1530 1530 _closeChild(): void;
1531 1531 /**
1532 1532 * Called when child of this Menu gets focus from:
1533 1533 *
1534 1534 * 1. clicking it
1535 1535 * 2. tabbing into it
1536 1536 * 3. being opened by a parent menu.
1537 1537 *
1538 1538 * This is not called just from mouse hover.
1539 1539 */
1540 1540 _onItemFocus(item: MenuItem): void;
1541 1541
1542 1542 /**
1543 1543 * Called when focus is moved away from this Menu and it's submenus.
1544 1544 */
1545 1545 _onBlur(): void;
1546 1546
1547 1547 /**
1548 1548 * Called when the user is done with this menu. Closes hierarchy of menus.
1549 1549 */
1550 1550 _cleanUp(clearSelectedItem?: boolean): void;
1551 1551 }
1552 1552
1553 1553 interface _MenuBaseConstructor extends _WidgetBaseConstructor<_MenuBase> { }
1554 1554
1555 1555 /* dijit/Dialog */
1556 1556
1557 1557 interface _DialogBase extends _TemplatedMixin, form._FormMixin, _DialogMixin, _CssStateMixin {
1558 1558 templateString: string;
1559 1559 baseClass: string;
1560 1560 cssStateNodes: CSSStateNodes;
1561 1561
1562 1562 /**
1563 1563 * True if Dialog is currently displayed on screen.
1564 1564 */
1565 1565 open: boolean;
1566 1566
1567 1567 /**
1568 1568 * The time in milliseconds it takes the dialog to fade in and out
1569 1569 */
1570 1570 duration: number;
1571 1571
1572 1572 /**
1573 1573 * A Toggle to modify the default focus behavior of a Dialog, which
1574 1574 * is to re-focus the element which had focus before being opened.
1575 1575 * False will disable refocusing. Default: true
1576 1576 */
1577 1577 refocus: boolean;
1578 1578
1579 1579 /**
1580 1580 * A Toggle to modify the default focus behavior of a Dialog, which
1581 1581 * is to focus on the first dialog element after opening the dialog.
1582 1582 * False will disable autofocusing. Default: true
1583 1583 */
1584 1584 autofocus: boolean;
1585 1585
1586 1586 /**
1587 1587 * Toggles the movable aspect of the Dialog. If true, Dialog
1588 1588 * can be dragged by it's title. If false it will remain centered
1589 1589 * in the viewport.
1590 1590 */
1591 1591 draggable: boolean;
1592 1592
1593 1593 /**
1594 1594 * Maximum size to allow the dialog to expand to, relative to viewport size
1595 1595 */
1596 1596 maxRatio: number;
1597 1597
1598 1598 /**
1599 1599 * Dialog show [x] icon to close itself, and ESC key will close the dialog.
1600 1600 */
1601 1601 closable: boolean;
1602 1602 postMixInProperties(): void;
1603 1603 postCreate(): void;
1604 1604
1605 1605 /**
1606 1606 * Called when data has been loaded from an href.
1607 1607 * Unlike most other callbacks, this function can be connected to (via `dojo.connect`)
1608 1608 * but should *not* be overridden.
1609 1609 */
1610 1610 onLoad(data?: any): void;
1611 1611
1612 1612 focus(): void;
1613 1613
1614 1614 /* Not entirely sure of the resolution type of these promises */
1615 1615
1616 1616 /**
1617 1617 * Display the dialog
1618 1618 */
1619 1619 show(): dojo.promise.Promise<any>;
1620 1620
1621 1621 /**
1622 1622 * Hide the dialog
1623 1623 */
1624 1624 hide(): dojo.promise.Promise<any>;
1625 1625
1626 1626 /**
1627 1627 * Called with no argument when viewport scrolled or viewport size changed. Adjusts Dialog as
1628 1628 * necessary to keep it visible.
1629 1629 *
1630 1630 * Can also be called with an argument (by dojox/layout/ResizeHandle etc.) to explicitly set the
1631 1631 * size of the dialog.
1632 1632 */
1633 1633 resize(dim?: dojo.DomGeometryWidthHeight): void;
1634 1634
1635 1635 destroy(preserveDom?: boolean): void;
1636 1636 }
1637 1637
1638 1638 interface _DialogBaseConstructor extends _WidgetBaseConstructor<_DialogBase> { }
1639 1639
1640 1640 interface Dialog extends layout.ContentPane, _DialogBase {
1641 1641 /* overrides conflicting methods */
1642 1642 resize(dim?: dojo.DomGeometryWidthHeight): void;
1643 1643 }
1644 1644
1645 1645 interface DialogLevelManager {
1646 1646 _beginZIndex: number;
1647 1647
1648 1648 /**
1649 1649 * Call right before fade-in animation for new dialog.
1650 1650 *
1651 1651 * Saves current focus, displays/adjusts underlay for new dialog,
1652 1652 * and sets the z-index of the dialog itself.
1653 1653 *
1654 1654 * New dialog will be displayed on top of all currently displayed dialogs.
1655 1655 * Caller is responsible for setting focus in new dialog after the fade-in
1656 1656 * animation completes.
1657 1657 */
1658 1658 show(dialog: _WidgetBase, underlayAttrs: Object): void;
1659 1659
1660 1660 /**
1661 1661 * Called when the specified dialog is hidden/destroyed, after the fade-out
1662 1662 * animation ends, in order to reset page focus, fix the underlay, etc.
1663 1663 * If the specified dialog isn't open then does nothing.
1664 1664 *
1665 1665 * Caller is responsible for either setting display:none on the dialog domNode,
1666 1666 * or calling dijit/popup.hide(), or removing it from the page DOM.
1667 1667 */
1668 1668 hide(dialog: _WidgetBase): void;
1669 1669
1670 1670 /**
1671 1671 * Returns true if specified Dialog is the top in the task
1672 1672 */
1673 1673 isTop(dialog: _WidgetBase): boolean;
1674 1674 }
1675 1675
1676 1676 interface DialogConstructor extends _WidgetBaseConstructor<Dialog> {
1677 1677 /**
1678 1678 * for monkey patching and dojox/widget/DialogSimple
1679 1679 */
1680 1680 _DialogBase: _DialogBaseConstructor;
1681 1681 _DialogLevelManager: DialogLevelManager;
1682 1682 _dialogStack: {
1683 1683 dialog: _WidgetBase,
1684 1684 focus: any,
1685 1685 underlayAttrs: any
1686 1686 }[];
1687 1687 }
1688 1688
1689 1689 /* dijit/ConfirmDialog */
1690 1690
1691 1691 interface ConfirmDialog extends _ConfirmDialogMixin { }
1692 1692
1693 1693 interface ConfirmDialogConstructor extends DialogConstructor { }
1694 1694
1695 1695 /* dijit/DropDownMenu */
1696 1696
1697 1697 /**
1698 1698 * A menu, without features for context menu (Meaning, drop down menu)
1699 1699 */
1700 1700 interface DropDownMenu extends _MenuBase { }
1701 1701
1702 1702 interface DropDownMenuConstructor extends _WidgetBaseConstructor<DropDownMenu> { }
1703 1703
1704 1704 /* dijit/Fieldset */
1705 1705
1706 1706 /**
1707 1707 * An accessible fieldset that can be expanded or collapsed via
1708 1708 * its legend. Fieldset extends `dijit.TitlePane`.
1709 1709 */
1710 1710 interface Fieldset extends TitlePane {
1711 1711 open: boolean;
1712 1712 }
1713 1713
1714 1714 interface FieldsetConstructor extends _WidgetBaseConstructor<Fieldset> { }
1715 1715
1716 1716 /* dijit/Menu */
1717 1717
1718 1718 /**
1719 1719 * A context menu you can assign to multiple elements
1720 1720 */
1721 1721 interface Menu extends dijit.DropDownMenu {
1722 1722 /**
1723 1723 * Array of dom node ids of nodes to attach to.
1724 1724 * Fill this with nodeIds upon widget creation and it becomes context menu for those nodes.
1725 1725 */
1726 1726 targetNodeIds: string[];
1727 1727
1728 1728 /**
1729 1729 * CSS expression to apply this Menu to descendants of targetNodeIds, rather than to
1730 1730 * the nodes specified by targetNodeIds themselves. Useful for applying a Menu to
1731 1731 * a range of rows in a table, tree, etc.
1732 1732 *
1733 1733 * The application must require() an appropriate level of dojo/query to handle the selector.
1734 1734 */
1735 1735 selector: string;
1736 1736
1737 1737 /**
1738 1738 * If true, right clicking anywhere on the window will cause this context menu to open.
1739 1739 * If false, must specify targetNodeIds.
1740 1740 */
1741 1741 contextMenuForWindow: boolean;
1742 1742
1743 1743 /**
1744 1744 * If true, menu will open on left click instead of right click, similar to a file menu.
1745 1745 */
1746 1746 leftClickToOpen: boolean;
1747 1747
1748 1748 /**
1749 1749 * When this menu closes, re-focus the element which had focus before it was opened.
1750 1750 */
1751 1751 refocus: boolean;
1752 1752
1753 1753 /**
1754 1754 * Attach menu to given node
1755 1755 */
1756 1756 bindDomNode(node: string | Node): void;
1757 1757
1758 1758 /**
1759 1759 * Detach menu from given node
1760 1760 */
1761 1761 unBindDomNode(nodeName: string | Node): void;
1762 1762 }
1763 1763
1764 1764 interface MenuConstructor extends _WidgetBaseConstructor<Menu> { }
1765 1765
1766 1766 /* dijit/MenuBar */
1767 1767 interface MenuBar extends _MenuBase {
1768 1768 baseClass: 'dijitMenuBar';
1769 1769 popupDelay: number;
1770 1770 _isMenuBar: true;
1771 1771 _orient: string[];
1772 1772 _moveToPopup(evt: Event): void;
1773 1773 focusChild(item: _WidgetBase): void;
1774 1774 _onChildDeselect(item: _WidgetBase): void;
1775 1775 _onLeftArrow(): void;
1776 1776 _onRightArrow(): void;
1777 1777 _onDownArrow(): void;
1778 1778 _onUpArrow(): void;
1779 1779 onItemClick(item: _WidgetBase, evt: Event): void;
1780 1780 }
1781 1781
1782 1782 interface MenuBarConstructor extends _WidgetBaseConstructor<MenuBar> { }
1783 1783
1784 1784 /* dijit/MenuBarItem */
1785 1785 interface MenuBarItem extends MenuItem { }
1786 1786
1787 1787 interface MenuBarItemConstructor extends _WidgetBaseConstructor<MenuBarItem> { }
1788 1788
1789 1789 /* dijit/MenuItem */
1790 1790 interface MenuItem extends _Widget, _TemplatedMixin, _Contained, _CssStateMixin {
1791 1791 /**
1792 1792 * Text for the accelerator (shortcut) key combination, a control, alt, etc. modified keystroke meant to execute the menu item regardless of where the focus is on the page.
1793 1793 *
1794 1794 * Note that although Menu can display accelerator keys, there is no infrastructure to actually catch and execute those accelerators.
1795 1795 */
1796 1796 accelKey: string;
1797 1797
1798 1798 /**
1799 1799 * If true, the menu item is disabled.
1800 1800 * If false, the menu item is enabled.
1801 1801 */
1802 1802 disabled: boolean;
1803 1803
1804 1804 /** Menu text as HTML */
1805 1805 label: string;
1806 1806
1807 1807 /**
1808 1808 * Class to apply to DOMNode to make it display an icon.
1809 1809 */
1810 1810 iconClass: string;
1811 1811
1812 1812 /**
1813 1813 * Hook for attr('accelKey', ...) to work.
1814 1814 * Set accelKey on this menu item.
1815 1815 */
1816 1816 _setAccelKeyAttr(value: string): void;
1817 1817
1818 1818 /**
1819 1819 * Hook for attr('disabled', ...) to work.
1820 1820 * Enable or disable this menu item.
1821 1821 */
1822 1822 _setDisabledAttr(value: boolean): void;
1823 1823
1824 1824 _setLabelAttr(val: string): void;
1825 1825 _setIconClassAttr(val: string): void;
1826 1826
1827 1827 _fillContent(source: Element): void;
1828 1828
1829 1829 /**
1830 1830 * Indicate that this node is the currently selected one
1831 1831 */
1832 1832 _setSelected(selected: boolean): void;
1833 1833
1834 1834 focus(): void;
1835 1835
1836 1836 /**
1837 1837 * Deprecated.
1838 1838 * Use set('disabled', bool) instead.
1839 1839 */
1840 1840 setDisabled(disabled: boolean): void;
1841 1841
1842 1842 /**
1843 1843 * Deprecated.
1844 1844 * Use set('label', ...) instead.
1845 1845 */
1846 1846 setLabel(content: string): void;
1847 1847 }
1848 1848
1849 1849 interface MenuItemConstructor extends _WidgetBaseConstructor<MenuItem> { }
1850 1850
1851 1851 /* dijit/MenuSeparator */
1852 1852 interface MenuSeparator extends _WidgetBase, _TemplatedMixin, _Contained { }
1853 1853
1854 1854 interface MenuSeparatorConstructor extends _WidgetBaseConstructor<MenuSeparator> { }
1855 1855
1856 1856 /* dijit/place */
1857 1857
1858 1858 interface PlacePosition {
1859 1859 x: number;
1860 1860 y: number;
1861 1861 }
1862 1862
1863 1863 interface PlaceWidthHeight {
1864 1864 w: number;
1865 1865 h: number;
1866 1866 }
1867 1867
1868 1868 interface PlaceRectangle extends PlacePosition, PlaceWidthHeight { }
1869 1869
1870 1870 type PlaceCorner = 'BL' | 'TR' | 'BR' | 'TL';
1871 1871
1872 1872 type PlacePositions = 'before' | 'after' | 'before-centered' | 'after-centered' | 'above-centered' | 'above' | 'above-alt' | 'below-centered' | 'below' | 'below-alt';
1873 1873
1874 1874 interface PlaceChoice {
1875 1875 corner: PlaceCorner;
1876 1876 pos: PlacePosition;
1877 1877 aroundCorner?: PlaceCorner;
1878 1878 }
1879 1879
1880 1880 interface PlaceLocation extends PlaceRectangle {
1881 1881 corner: PlaceCorner;
1882 1882 aroundCorner: PlaceCorner;
1883 1883 overflow: number;
1884 1884 spaceAvailable: PlaceWidthHeight;
1885 1885 }
1886 1886
1887 1887 interface LayoutNodeFunction {
1888 1888 (node: HTMLElement, aroundCorner: string, corner: string, spaceAvailable: PlaceWidthHeight, aroundNodeCoords: PlaceWidthHeight): number;
1889 1889 }
1890 1890
1891 1891 interface Place {
1892 1892 /**
1893 1893 * Positions node kitty-corner to the rectangle centered at (pos.x, pos.y) with width and height of
1894 1894 * padding.x * 2 and padding.y * 2, or zero if padding not specified. Picks first corner in corners[]
1895 1895 * where node is fully visible, or the corner where it's most visible.
1896 1896 *
1897 1897 * Node is assumed to be absolutely or relatively positioned.
1898 1898 */
1899 1899 at(node: Element, pos?: PlacePosition, corners?: PlaceCorner[], padding?: PlacePosition, layoutNode?: LayoutNodeFunction): PlaceLocation;
1900 1900
1901 1901 /**
1902 1902 * Position node adjacent or kitty-corner to anchor
1903 1903 * such that it's fully visible in viewport.
1904 1904 */
1905 1905 around(node: Element, anchor: Element | PlaceRectangle, positions: PlacePositions[], leftToRight?: boolean, layoutNode?: LayoutNodeFunction): PlaceLocation;
1906 1906 }
1907 1907
1908 1908 /* dijit/popup */
1909 1909
1910 1910 interface PopupOpenArgs {
1911 1911 /**
1912 1912 * widget to display
1913 1913 */
1914 1914 popup?: _WidgetBase;
1915 1915
1916 1916 /**
1917 1917 * the button etc. that is displaying this popup
1918 1918 */
1919 1919 parent?: _WidgetBase;
1920 1920
1921 1921 /**
1922 1922 * DOM node (typically a button); place popup relative to this node. (Specify this *or* "x" and "y" parameters.)
1923 1923 */
1924 1924 around?: HTMLElement;
1925 1925
1926 1926 /**
1927 1927 * Absolute horizontal position (in pixels) to place node at. (Specify this *or* "around" parameter.)
1928 1928 */
1929 1929 x?: number;
1930 1930
1931 1931 /**
1932 1932 * Absolute vertical position (in pixels) to place node at. (Specify this *or* "around" parameter.)
1933 1933 */
1934 1934 y?: number;
1935 1935
1936 1936 /**
1937 1937 * When the around parameter is specified, orient should be a list of positions to try
1938 1938 */
1939 1939 orient?: string | string[] | { BL?: string; TR?: string; TL?: string; BR?: string; };
1940 1940
1941 1941 /**
1942 1942 * callback when user has canceled the popup by:
1943 1943 *
1944 1944 * 1. hitting ESC or
1945 1945 * 2. by using the popup widget's proprietary cancel mechanism (like a cancel button in a dialog);
1946 1946 * i.e. whenever popupWidget.onCancel() is called, args.onCancel is called
1947 1947 */
1948 1948 onCancel?: () => void;
1949 1949
1950 1950 /**
1951 1951 * callback whenever this popup is closed
1952 1952 */
1953 1953 onClose?: () => void;
1954 1954
1955 1955 /**
1956 1956 * callback when user "executed" on the popup/sub-popup by selecting a menu choice, etc. (top menu only)
1957 1957 */
1958 1958 onExecute?: () => void;
1959 1959
1960 1960 /**
1961 1961 * adding a buffer around the opening position. This is only useful when around is not set.
1962 1962 */
1963 1963 padding?: PlacePosition;
1964 1964
1965 1965 /**
1966 1966 * The max height for the popup. Any popup taller than this will have scrollbars.
1967 1967 * Set to Infinity for no max height. Default is to limit height to available space in viewport,
1968 1968 * above or below the aroundNode or specified x/y position.
1969 1969 */
1970 1970 maxHeight?: number;
1971 1971 }
1972 1972
1973 1973 interface PopupManager {
1974 1974 /**
1975 1975 * Stack of currently popped up widgets.
1976 1976 * (someone opened _stack[0], and then it opened _stack[1], etc.)
1977 1977 */
1978 1978 _stack: _WidgetBase[];
1979 1979
1980 1980 /**
1981 1981 * Z-index of the first popup. (If first popup opens other
1982 1982 * popups they get a higher z-index.)
1983 1983 */
1984 1984 _beginZIndex: number;
1985 1985
1986 1986 _idGen: number;
1987 1987
1988 1988 /**
1989 1989 * If screen has been scrolled, reposition all the popups in the stack.
1990 1990 * Then set timer to check again later.
1991 1991 */
1992 1992 _repositionAll(): void;
1993 1993
1994 1994 /**
1995 1995 * Initialization for widgets that will be used as popups.
1996 1996 * Puts widget inside a wrapper DIV (if not already in one),
1997 1997 * and returns pointer to that wrapper DIV.
1998 1998 */
1999 1999 _createWrapper(widget: _WidgetBase): HTMLDivElement;
2000 2000
2001 2001 /**
2002 2002 * Moves the popup widget off-screen.
2003 2003 * Do not use this method to hide popups when not in use, because
2004 2004 * that will create an accessibility issue: the offscreen popup is
2005 2005 * still in the tabbing order.
2006 2006 */
2007 2007 moveOffScreen(widget: _WidgetBase): HTMLDivElement;
2008 2008
2009 2009 /**
2010 2010 * Hide this popup widget (until it is ready to be shown).
2011 2011 * Initialization for widgets that will be used as popups
2012 2012 *
2013 2013 * Also puts widget inside a wrapper DIV (if not already in one)
2014 2014 *
2015 2015 * If popup widget needs to layout it should
2016 2016 * do so when it is made visible, and popup._onShow() is called.
2017 2017 */
2018 2018 hide(widget: _WidgetBase): void;
2019 2019
2020 2020 /**
2021 2021 * Compute the closest ancestor popup that's *not* a child of another popup.
2022 2022 * Ex: For a TooltipDialog with a button that spawns a tree of menus, find the popup of the button.
2023 2023 */
2024 2024 getTopPopup(): _WidgetBase;
2025 2025
2026 2026 /**
2027 2027 * Popup the widget at the specified position
2028 2028 */
2029 2029 open(args: PopupOpenArgs): PlaceLocation;
2030 2030
2031 2031 /**
2032 2032 * Close specified popup and any popups that it parented.
2033 2033 * If no popup is specified, closes all popups.
2034 2034 */
2035 2035 close(popup?: _WidgetBase): void;
2036 2036 }
2037 2037
2038 2038 /* dijit/PopupMenuBarItem */
2039 2039
2040 2040 interface PopupMenuBarItem extends PopupMenuItem { }
2041 2041
2042 2042 interface PopupMenuBarItemConstructor extends _WidgetBaseConstructor<PopupMenuBarItem> { }
2043 2043
2044 2044 /** dijit/PopupMenuItem */
2045 2045
2046 2046 /**
2047 2047 * An item in a Menu that spawn a drop down (usually a drop down menu)
2048 2048 */
2049 2049 interface PopupMenuItem extends MenuItem {
2050 2050 /**
2051 2051 * When Menu is declared in markup, this code gets the menu label and the popup widget from the srcNodeRef.
2052 2052 *
2053 2053 * srcNodeRef.innerHTML contains both the menu item text and a popup widget
2054 2054 * The first part holds the menu item text and the second part is the popup
2055 2055 */
2056 2056 _fillContent(source: Element): void;
2057 2057
2058 2058 /**
2059 2059 * Open the popup to the side of/underneath this MenuItem, and optionally focus first item
2060 2060 */
2061 2061 _openPopup(params: { around?: Element; popup?: Function }, focus?: boolean): void;
2062 2062
2063 2063 _closePopup(): void;
2064 2064 }
2065 2065
2066 2066 interface PopupMenuItemConstructor extends _WidgetBaseConstructor<PopupMenuItem> { }
2067 2067
2068 2068 /* dijit/registry */
2069 2069
2070 2070 interface Registry {
2071 2071 /**
2072 2072 * Number of registered widgets
2073 2073 */
2074 2074 length: number;
2075 2075
2076 2076 /**
2077 2077 * Add a widget to the registry. If a duplicate ID is detected, a error is thrown.
2078 2078 */
2079 2079 add(widget: _WidgetBase): void;
2080 2080
2081 2081 /**
2082 2082 * Remove a widget from the registry. Does not destroy the widget; simply
2083 2083 * removes the reference.
2084 2084 */
2085 2085 remove(id: string): void;
2086 2086
2087 2087 /**
2088 2088 * Find a widget by it's id.
2089 2089 * If passed a widget then just returns the widget.
2090 2090 */
2091 2091 byId(id: string | _WidgetBase): _WidgetBase;
2092 2092
2093 2093 /**
2094 2094 * Returns the widget corresponding to the given DOMNode
2095 2095 */
2096 2096 byNode(node: Element | Node): _WidgetBase;
2097 2097
2098 2098 /**
2099 2099 * Convert registry into a true Array
2100 2100 */
2101 2101 toArray(): _WidgetBase[];
2102 2102
2103 2103 /**
2104 2104 * Generates a unique id for a given widgetType
2105 2105 */
2106 2106 getUniqueId(widgetType: string): string;
2107 2107
2108 2108 /**
2109 2109 * Search subtree under root returning widgets found.
2110 2110 * Doesn't search for nested widgets (ie, widgets inside other widgets).
2111 2111 */
2112 2112 findWidgets(root: Node, skipNode?: Node): _WidgetBase[];
2113 2113
2114 2114 /**
2115 2115 * Returns the widget whose DOM tree contains the specified DOMNode, or null if
2116 2116 * the node is not contained within the DOM tree of any widget
2117 2117 */
2118 2118 getEnclosingWidget(node: Element | Node): _WidgetBase;
2119 2119 }
2120 2120
2121 2121 /* dijit/TitlePane */
2122 2122
2123 2123 interface TitlePane extends dijit.layout.ContentPane, _TemplatedMixin, _CssStateMixin {
2124 2124 /**
2125 2125 * Whether pane can be opened or closed by clicking the title bar.
2126 2126 */
2127 2127 toggleable: boolean;
2128 2128
2129 2129 /**
2130 2130 * Tabindex setting for the title (so users can tab to the title then use space/enter to open/close the title pane)
2131 2131 */
2132 2132 tabIndex: string;
2133 2133
2134 2134 /**
2135 2135 * Time in milliseconds to fade in/fade out
2136 2136 */
2137 2137 duration: number;
2138 2138
2139 2139 /**
2140 2140 * Don't change this parameter from the default value.
2141 2141 *
2142 2142 * This ContentPane parameter doesn't make sense for TitlePane, since TitlePane is never a child of a layout container, nor should TitlePane try to control the size of an inner widget.
2143 2143 */
2144 2144 doLayout: boolean;
2145 2145
2146 2146 /**
2147 2147 * Switches between opened and closed state
2148 2148 */
2149 2149 toggle(): void;
2150 2150
2151 2151 /**
2152 2152 * Set the open/close css state for the TitlePane
2153 2153 */
2154 2154 _setCss(): void;
2155 2155
2156 2156 /**
2157 2157 * Handler for when user hits a key
2158 2158 */
2159 2159 _onTitleKey(e: Event): void;
2160 2160
2161 2161 /**
2162 2162 * Handler when user clicks the title bar
2163 2163 */
2164 2164 _onTitleClick(): void;
2165 2165
2166 2166 /**
2167 2167 * Deprecated. Use set('title', ...) instead.
2168 2168 */
2169 2169 setTitle(): void;
2170 2170 }
2171 2171
2172 2172 interface TitlePaneConstructor extends _WidgetBaseConstructor<TitlePane> { }
2173 2173
2174 2174 /* dijit/Toolbar */
2175 2175
2176 2176 interface Toolbar extends dijit._Widget, dijit._TemplatedMixin, dijit._KeyNavContainer { }
2177 2177
2178 2178 interface ToolbarConstructor extends _WidgetBaseConstructor<Toolbar> { }
2179 2179
2180 2180 /* dijit/ToolbarSeparator */
2181 2181
2182 2182 interface ToolbarSeparator extends dijit._Widget, dijit._TemplatedMixin { }
2183 2183
2184 2184 interface ToolbarSeparatorConstructor extends _WidgetBaseConstructor<ToolbarSeparator> { }
2185 2185
2186 2186 /* dijit/Tooltip */
2187 2187
2188 2188 interface Tooltip extends _Widget {
2189 2189 /**
2190 2190 * HTML to display in the tooltip.
2191 2191 * Specified as innerHTML when creating the widget from markup.
2192 2192 */
2193 2193 label: string;
2194 2194
2195 2195 /**
2196 2196 * Number of milliseconds to wait after hovering over/focusing on the object, before
2197 2197 * the tooltip is displayed.
2198 2198 */
2199 2199 showDelay: number;
2200 2200
2201 2201 /**
2202 2202 * Number of milliseconds to wait after unhovering the object, before
2203 2203 * the tooltip is hidden. Note that blurring an object hides the tooltip immediately.
2204 2204 */
2205 2205 hideDelay: number;
2206 2206
2207 2207 /**
2208 2208 * Id of domNode(s) to attach the tooltip to.
2209 2209 * When user hovers over specified dom node(s), the tooltip will appear.
2210 2210 */
2211 2211 connectId: dojo.NodeOrString | dojo.NodeOrString[];
2212 2212
2213 2213 /**
2214 2214 * See description of `dijit/Tooltip.defaultPosition` for details on position parameter.
2215 2215 */
2216 2216 position: string;
2217 2217
2218 2218 /**
2219 2219 * CSS expression to apply this Tooltip to descendants of connectIds, rather than to
2220 2220 * the nodes specified by connectIds themselves. Useful for applying a Tooltip to
2221 2221 * a range of rows in a table, tree, etc. Use in conjunction with getContent() parameter.
2222 2222 * Ex: connectId: myTable, selector: "tr", getContent: function(node){ return ...; }
2223 2223 *
2224 2224 * The application must require() an appropriate level of dojo/query to handle the selector.
2225 2225 */
2226 2226 selector: string;
2227 2227
2228 2228 /**
2229 2229 * Attach tooltip to specified node if it's not already connected
2230 2230 */
2231 2231 addTarget(node: dojo.NodeOrString): void;
2232 2232
2233 2233 /**
2234 2234 * Detach tooltip from specified node
2235 2235 */
2236 2236 removeTarget(node: dojo.NodeOrString): void;
2237 2237
2238 2238 /**
2239 2239 * User overridable function that return the text to display in the tooltip.
2240 2240 */
2241 2241 getContent(node: Node): Node;
2242 2242
2243 2243 /**
2244 2244 * Display the tooltip; usually not called directly.
2245 2245 */
2246 2246 open(target: Node): void;
2247 2247
2248 2248 /**
2249 2249 * Hide the tooltip or cancel timer for show of tooltip
2250 2250 */
2251 2251 close(): void;
2252 2252
2253 2253 /**
2254 2254 * Called when the tooltip is shown
2255 2255 */
2256 2256 onShow(): void;
2257 2257
2258 2258 /**
2259 2259 * Called when the tooltip is hidden
2260 2260 */
2261 2261 onHide(): void;
2262 2262 }
2263 2263
2264 2264 interface TooltipConstructor extends _WidgetBaseConstructor<Tooltip> {
2265 2265 /**
2266 2266 * This variable controls the position of tooltips, if the position is not specified to
2267 2267 * the Tooltip widget or *TextBox widget itself. It's an array of strings with the values
2268 2268 * possible for `dijit/place.around()`. The recommended values are:
2269 2269 *
2270 2270 * - before-centered: centers tooltip to the left of the anchor node/widget, or to the right
2271 2271 * in the case of RTL scripts like Hebrew and Arabic
2272 2272 * - after-centered: centers tooltip to the right of the anchor node/widget, or to the left
2273 2273 * in the case of RTL scripts like Hebrew and Arabic
2274 2274 * - above-centered: tooltip is centered above anchor node
2275 2275 * - below-centered: tooltip is centered above anchor node
2276 2276 *
2277 2277 * The list is positions is tried, in order, until a position is found where the tooltip fits
2278 2278 * within the viewport.
2279 2279 *
2280 2280 * Be careful setting this parameter. A value of "above-centered" may work fine until the user scrolls
2281 2281 * the screen so that there's no room above the target node. Nodes with drop downs, like
2282 2282 * DropDownButton or FilteringSelect, are especially problematic, in that you need to be sure
2283 2283 * that the drop down and tooltip don't overlap, even when the viewport is scrolled so that there
2284 2284 * is only room below (or above) the target node, but not both.
2285 2285 */
2286 2286 defaultPosition: [string];
2287 2287
2288 2288 /**
2289 2289 * Static method to display tooltip w/specified contents in specified position.
2290 2290 * See description of dijit/Tooltip.defaultPosition for details on position parameter.
2291 2291 * If position is not specified then dijit/Tooltip.defaultPosition is used.
2292 2292 */
2293 2293 show(innerHTML: string, aroundNode: PlaceRectangle, position?: [string], rtl?: boolean, textDir?: string, onMouseEnter?: Function, onMouseLeave?: Function): void;
2294 2294
2295 2295 /**
2296 2296 * Hide the tooltip
2297 2297 */
2298 2298 hide(aroundNode: PlaceRectangle): void;
2299 2299 }
2300 2300
2301 2301 /* dijit/TooltipDialog */
2302 2302
2303 2303 interface TooltipDialog extends layout.ContentPane, _TemplatedMixin, form._FormMixin, _DialogMixin {
2304 2304 /**
2305 2305 * Description of tooltip dialog (required for a11y)
2306 2306 */
2307 2307 title: string;
2308 2308
2309 2309 /**
2310 2310 * Don't change this parameter from the default value.
2311 2311 * This ContentPane parameter doesn't make sense for TooltipDialog, since TooltipDialog
2312 2312 * is never a child of a layout container, nor can you specify the size of
2313 2313 * TooltipDialog in order to control the size of an inner widget.
2314 2314 */
2315 2315 doLayout: boolean;
2316 2316
2317 2317 /**
2318 2318 * A Toggle to modify the default focus behavior of a Dialog, which
2319 2319 * is to focus on the first dialog element after opening the dialog.
2320 2320 * False will disable autofocusing. Default: true.
2321 2321 */
2322 2322 autofocus: boolean;
2323 2323
2324 2324 /**
2325 2325 * The pointer to the first focusable node in the dialog.
2326 2326 */
2327 2327 _firstFocusItem: any;
2328 2328
2329 2329 /**
2330 2330 * The pointer to which node has focus prior to our dialog.
2331 2331 */
2332 2332 _lastFocusItem: any;
2333 2333
2334 2334 /**
2335 2335 * Configure widget to be displayed in given position relative to the button.
2336 2336 *
2337 2337 * This is called from the dijit.popup code, and should not be called directly.
2338 2338 */
2339 2339 orient(node: Node | HTMLElement, aroundCorner: PlaceCorner, tooltipCorner: PlaceCorner): void;
2340 2340
2341 2341 /**
2342 2342 * Focus on first field
2343 2343 */
2344 2344 focus(): void;
2345 2345
2346 2346 /**
2347 2347 * Called when dialog is displayed.
2348 2348 *
2349 2349 * This is called from the dijit.popup code, and should not be called directly.
2350 2350 */
2351 2351 onOpen(pos: {
2352 2352 aroundCorner: PlaceCorner
2353 2353 aroundNodePos: PlacePosition
2354 2354 corner: PlaceCorner
2355 2355 x: number
2356 2356 y: number
2357 2357 }): void;
2358 2358
2359 2359 /**
2360 2360 * Handler for keydown events
2361 2361 *
2362 2362 * Keep keyboard focus in dialog; close dialog on escape key
2363 2363 */
2364 2364 _onKey(evt: KeyboardEvent): void;
2365 2365 }
2366 2366
2367 2367 interface TooltipDialogConstructor extends _WidgetBaseConstructor<TooltipDialog> { }
2368 2368 }
@@ -1,590 +1,590
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 12 interface SortInformation {
13 13
14 14 /**
15 15 * The name of the attribute to sort on.
16 16 */
17 17 attribute: string;
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 25 interface QueryOptions {
26 26 /**
27 27 * A list of attributes to sort on, as well as direction
28 28 * For example:
29 29 * | [{attribute:"price", descending: true}].
30 30 * If the sort parameter is omitted, then the natural order of the store may be
31 31 * applied if there is a natural order.
32 32 */
33 33 sort?: SortInformation[];
34 34
35 35 /**
36 36 * The first result to begin iteration on
37 37 */
38 38 start?: number;
39 39
40 40 /**
41 41 * The number of how many results should be returned.
42 42 */
43 43 count?: number;
44 44 }
45 45
46 46 interface QueryEngineFunction<T extends object> {
47 47 (array: T[]): T[];
48 48 matches(object: T): boolean;
49 49 }
50 50
51 type BaseQueryType = string | object | ((...params: any[]) => any);
51 type BaseQueryType = string | object | ((...params: unknown[]) => unknown);
52 52
53 53 interface QueryEngine<T extends object, Q extends BaseQueryType> {
54 54 <O extends QueryOptions>(query: Q, options?: O): QueryEngineFunction<T>;
55 55 }
56 56
57 57 interface PutDirectives<T extends object> {
58 58
59 59 /**
60 60 * Indicates the identity of the object if a new object is created
61 61 */
62 62 id?: Identity;
63 63
64 64 /**
65 65 * If the collection of objects in the store has a natural ordering,
66 66 * this indicates that the created or updated object should be placed before the
67 67 * object specified by the value of this property. A value of null indicates that the
68 68 * object should be last.
69 69 */
70 70 before?: T;
71 71
72 72 /**
73 73 * If the store is hierarchical (with single parenting) this property indicates the
74 74 * new parent of the created or updated object.
75 75 */
76 76 parent?: T;
77 77
78 78 /**
79 79 * If this is provided as a boolean it indicates that the object should or should not
80 80 * overwrite an existing object. A value of true indicates that a new object
81 81 * should not be created, the operation should update an existing object. A
82 82 * value of false indicates that an existing object should not be updated, a new
83 83 * object should be created (which is the same as an add() operation). When
84 84 * this property is not provided, either an update or creation is acceptable.
85 85 */
86 86 overwrite?: boolean;
87 87 }
88 88
89 89 interface SyncQueryResults<T extends object> extends Array<T> {
90 90 total?: number;
91 91 }
92 92
93 93 interface AsyncQueryResults<T extends object> extends PromiseLike<Array<T>> {
94 94 /**
95 95 * Iterates over the query results, based on
96 96 * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/objects/Array/forEach.
97 97 * Note that this may executed asynchronously. The callback may be called
98 98 * after this function returns.
99 99 */
100 100 forEach(callback: (item: T, index: number, results: Array<T>) => void, thisObject?: object): PromiseLike<void>;
101 101
102 102 /**
103 103 * Filters the query results, based on
104 104 * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter.
105 105 * Note that this may executed asynchronously. The callback may be called
106 106 * after this function returns.
107 107 */
108 108 filter(callback: (item: T, index: number, results: Array<T>) => boolean, thisObject?: object): PromiseLike<Array<T>>;
109 109
110 110 /**
111 111 * Maps the query results, based on
112 112 * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map.
113 113 * Note that this may executed asynchronously. The callback may be called
114 114 * after this function returns.
115 115 */
116 116 map<U>(callback: (item: T, index: number, results: Array<T>) => U, thisObject?: object): PromiseLike<Array<U>>;
117 117
118 118 /** Cancells the current query */
119 119 cancel(reason?: any): void;
120 120
121 121 total?: PromiseLike<number>;
122 122 }
123 123
124 124 type QueryResults<T extends object> = SyncQueryResults<T> | AsyncQueryResults<T>;
125 125
126 126 interface Transaction {
127 127 /**
128 128 * Commits the transaction. This may throw an error if it fails. Of if the operation
129 129 * is asynchronous, it may return a promise that represents the eventual success
130 130 * or failure of the commit.
131 131 */
132 132 commit(): void;
133 133
134 134 /**
135 135 * Aborts the transaction. This may throw an error if it fails. Of if the operation
136 136 * is asynchronous, it may return a promise that represents the eventual success
137 137 * or failure of the abort.
138 138 */
139 139 abort(): void;
140 140 }
141 141
142 142 interface Transacted {
143 143 /**
144 144 * Starts a new transaction.
145 145 * Note that a store user might not call transaction() prior to using put,
146 146 * delete, etc. in which case these operations effectively could be thought of
147 147 * as "auto-commit" style actions.
148 148 */
149 149 transaction(): Transaction;
150 150 }
151 151
152 152 interface MetadataProvider<T extends object> {
153 153 /**
154 154 * Returns any metadata about the object. This may include attribution,
155 155 * cache directives, history, or version information.
156 156 */
157 157 getMetadata(object: T): object;
158 158 }
159 159
160 160 interface IdentityProvider<T extends object> {
161 161 /**
162 162 * If the store has a single primary key, this indicates the property to use as the
163 163 * identity property. The values of this property should be unique.
164 164 */
165 165 idProperty: keyof T;
166 166
167 167 /**
168 168 * Returns an object's identity
169 169 */
170 170 getIdentity(object: T): Identity;
171 171 }
172 172
173 173 interface Queryable<
174 174 T extends object,
175 175 Q extends BaseQueryType,
176 176 O extends QueryOptions,
177 177 R extends QueryResults<T> = QueryResults<T>> {
178 178
179 179 /**
180 180 * Queries the store for objects. This does not alter the store, but returns a
181 181 * set of data from the store.
182 182 */
183 183 query(query?: Q, options?: O): R;
184 184 }
185 185
186 186 interface SyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
187 187 extends IdentityProvider<T>, Queryable<T, Q, O, SyncQueryResults<T>> {
188 188
189 189 /**
190 190 * If the store can be queried locally (on the client side in JS), this defines
191 191 * the query engine to use for querying the data store.
192 192 * This takes a query and query options and returns a function that can execute
193 193 * the provided query on a JavaScript array. The queryEngine may be replace to
194 194 * provide more sophisticated querying capabilities. For example:
195 195 * | var query = store.queryEngine({foo:"bar"}, {count:10});
196 196 * | query(someArray) -> filtered array
197 197 * The returned query function may have a "matches" property that can be
198 198 * used to determine if an object matches the query. For example:
199 199 * | query.matches({id:"some-object", foo:"bar"}) -> true
200 200 * | query.matches({id:"some-object", foo:"something else"}) -> false
201 201 */
202 202 queryEngine?: QueryEngine<T, Q>;
203 203
204 204 /**
205 205 * Retrieves an object by its identity
206 206 */
207 207 get(id: Identity): T;
208 208
209 209 /**
210 210 * Stores an object
211 211 */
212 put(object: T, directives?: PutDirectives<T>): any;
212 put(object: T, directives?: PutDirectives<T>): unknown;
213 213
214 214 /**
215 215 * Creates an object, throws an error if the object already exists
216 216 */
217 add(object: T, directives?: PutDirectives<T>): any;
217 add(object: T, directives?: PutDirectives<T>): unknown;
218 218
219 219 /**
220 220 * Deletes an object by its identity
221 221 */
222 222 remove(id: Identity): void;
223 223
224 224 }
225 225
226 226 interface AsyncStore<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
227 227 extends IdentityProvider<T>, Queryable<T, Q, O, AsyncQueryResults<T>> {
228 228
229 229 /**
230 230 * If the store can be queried locally (on the client side in JS), this defines
231 231 * the query engine to use for querying the data store.
232 232 * This takes a query and query options and returns a function that can execute
233 233 * the provided query on a JavaScript array. The queryEngine may be replace to
234 234 * provide more sophisticated querying capabilities. For example:
235 235 * | var query = store.queryEngine({foo:"bar"}, {count:10});
236 236 * | query(someArray) -> filtered array
237 237 * The returned query function may have a "matches" property that can be
238 238 * used to determine if an object matches the query. For example:
239 239 * | query.matches({id:"some-object", foo:"bar"}) -> true
240 240 * | query.matches({id:"some-object", foo:"something else"}) -> false
241 241 */
242 242 queryEngine?: QueryEngine<T, Q>;
243 243
244 244 /**
245 245 * Retrieves an object by its identity
246 246 */
247 247 get(id: Identity): PromiseLike<T>;
248 248
249 249 /**
250 250 * Stores an object
251 251 */
252 put(object: T, directives?: PutDirectives<T>): PromiseLike<any>;
252 put(object: T, directives?: PutDirectives<T>): PromiseLike<unknown>;
253 253
254 254 /**
255 255 * Creates an object, throws an error if the object already exists
256 256 */
257 add(object: T, directives?: PutDirectives<T>): PromiseLike<any>;
257 add(object: T, directives?: PutDirectives<T>): PromiseLike<unknown>;
258 258
259 259 /**
260 260 * Deletes an object by its identity
261 261 */
262 262 remove(id: string | number): PromiseLike<void>;
263 263
264 264 }
265 265
266 266 interface HierarchicalStore<T extends object, O extends QueryOptions = QueryOptions, R extends QueryResults<T> = QueryResults<T>> {
267 267
268 268 /**
269 269 * Retrieves the children of an object.
270 270 */
271 271 getChildren(parent: T, options?: O): R;
272 272 }
273 273
274 274 interface Store<T extends object, Q extends BaseQueryType = Partial<T> | ((item: T) => boolean) | string, O extends QueryOptions = QueryOptions>
275 275 extends IdentityProvider<T>, Queryable<T, Q, O> {
276 276
277 277 /**
278 278 * If the store can be queried locally (on the client side in JS), this defines
279 279 * the query engine to use for querying the data store.
280 280 * This takes a query and query options and returns a function that can execute
281 281 * the provided query on a JavaScript array. The queryEngine may be replace to
282 282 * provide more sophisticated querying capabilities. For example:
283 283 * | var query = store.queryEngine({foo:"bar"}, {count:10});
284 284 * | query(someArray) -> filtered array
285 285 * The returned query function may have a "matches" property that can be
286 286 * used to determine if an object matches the query. For example:
287 287 * | query.matches({id:"some-object", foo:"bar"}) -> true
288 288 * | query.matches({id:"some-object", foo:"something else"}) -> false
289 289 */
290 290 queryEngine?: QueryEngine<T, Q>;
291 291
292 292 /**
293 293 * Retrieves an object by its identity
294 294 */
295 295 get(id: Identity): T | PromiseLike<T>;
296 296
297 297 /**
298 298 * Stores an object
299 299 */
300 put(object: T, directives?: PutDirectives<T>): any;
300 put(object: T, directives?: PutDirectives<T>): unknown;
301 301
302 302 /**
303 303 * Creates an object, throws an error if the object already exists
304 304 */
305 add(object: T, directives?: PutDirectives<T>): any;
305 add(object: T, directives?: PutDirectives<T>): unknown;
306 306
307 307 /**
308 308 * Deletes an object by its identity
309 309 */
310 310 remove(id: Identity): void | PromiseLike<void>;
311 311
312 312 }
313 313
314 314 interface StoreConstructor {
315 315 new <T extends object, Q extends BaseQueryType, O extends QueryOptions>(): Store<T, Q, O>;
316 316 }
317 317 }
318 318
319 319 namespace util {
320 320
321 321 /* dojo/store/util/QueryResults */
322 322
323 323 interface QueryResultsFunction {
324 324 /**
325 325 * A function that wraps the results of a store query with additional
326 326 * methods.
327 327 */
328 328 <T extends object>(results: T[]): api.SyncQueryResults<T>;
329 329 <T extends object>(results: PromiseLike<T[]>): api.AsyncQueryResults<T>;
330 330 }
331 331
332 332 /* dojo/store/util/SimpleQueryEngine */
333 333 interface SimpleQueryEngine extends api.QueryEngine<object, api.BaseQueryType> { }
334 334 }
335 335
336 336 /* dojo/store/Cache */
337 337
338 338 interface CacheOptions<T extends object = any> {
339 339 /**
340 340 * This is a function that will be called for each item in a query response to determine
341 341 * if it is cacheable. If isLoaded returns true, the item will be cached, otherwise it
342 342 * will not be cached. If isLoaded is not provided, all items will be cached.
343 343 */
344 344 isLoaded?: (item: T) => boolean;
345 345 }
346 346
347 347 interface CacheMixin {
348 348 /**
349 349 * Remove the object with the specific id.
350 350 */
351 351 remove(id: api.Identity): PromiseLike<void>;
352 352
353 353 /**
354 354 * Remove the object with the given id from the underlying caching store.
355 355 */
356 356 evict(id: api.Identity): PromiseLike<void>;
357 357 }
358 358
359 359 interface Cache {
360 360 /**
361 361 * The Cache store wrapper takes a master store and a caching store,
362 362 * caches data from the master into the caching store for faster
363 363 * lookup. Normally one would use a memory store for the caching
364 364 * store and a server store like JsonRest for the master store.
365 365 */
366 366 <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 367 }
368 368
369 369 /* dojo/store/DataStore */
370 370
371 371 interface DataStoreOptions<T extends object> {
372 372 idProperty?: keyof T;
373 373 queryEngine?: api.QueryEngine<T, api.QueryOptions>;
374 374 store?: data.api.Read<T> | data.api.Write<T> | data.api.Identity<T>;
375 375 }
376 376
377 377 interface DataStore<T extends object> extends api.Store<T, api.BaseQueryType, api.QueryOptions> {
378 378 /**
379 379 * The object store to convert to a data store
380 380 */
381 381 store: data.api.Read<T> | data.api.Write<T> | data.api.Identity<T>;
382 382
383 383 /**
384 384 * Defines the query engine to use for querying the data store
385 385 */
386 386 queryEngine: api.QueryEngine<T, api.BaseQueryType>;
387 387
388 388 _objectConverter(callback: (item: T) => any): (item: T) => any;
389 389 }
390 390
391 391 interface DataStoreConstructor extends _base.DeclareConstructor<DataStore<object>> {
392 392 new <T extends object>(options?: DataStoreOptions<T>): DataStore<T>;
393 393 }
394 394
395 395 /* dojo/store/JsonRest */
396 396
397 397 interface Headers {
398 398 [header: string]: string;
399 399 }
400 400
401 401 interface JsonRestPutDirectives<T extends object> extends api.PutDirectives<T> {
402 402 headers?: Headers;
403 403
404 404 incremental?: boolean;
405 405
406 406 timeout?: number
407 407 }
408 408
409 409 interface JsonRestQueryOptions extends api.QueryOptions {
410 410 headers?: Headers;
411 411
412 412 timeout?: number;
413 413 }
414 414
415 415 interface JsonRestOptions<T extends object> {
416 416 idProperty?: keyof T;
417 417 queryEngine?: api.QueryEngine<T, JsonRestQueryOptions>;
418 418 headers?: Headers;
419 419 target?: string;
420 420 rangeParam?: string;
421 421 sortParam?: string;
422 422 ascendingPrefix?: string;
423 423 descendingPrefix?: string;
424 424 accepts?: string;
425 425 }
426 426
427 427 interface JsonRest<
428 428 T extends object,
429 429 Q extends api.BaseQueryType = (Partial<T> | string) & api.BaseQueryType,
430 430 O extends JsonRestQueryOptions = JsonRestQueryOptions>
431 431 extends api.AsyncStore<T, Q, O> {
432 432 /**
433 433 * Additional headers to pass in all requests to the server. These can be overridden
434 434 * by passing additional headers to calls to the store.
435 435 */
436 436 headers: Headers;
437 437
438 438 /**
439 439 * The target base URL to use for all requests to the server. This string will be
440 440 * prepended to the id to generate the URL (relative or absolute) for requests
441 441 * sent to the server
442 442 */
443 443 target: string;
444 444
445 445 /**
446 446 * Use a query parameter for the requested range. If this is omitted, than the
447 447 * Range header will be used. Independent of this, the X-Range header is always set.
448 448 */
449 449 rangeParam?: string;
450 450
451 451 /**
452 452 * The query parameter to used for holding sort information. If this is omitted, than
453 453 * the sort information is included in a functional query token to avoid colliding
454 454 * with the set of name/value pairs.
455 455 */
456 456 sortParam?: string;
457 457
458 458 /**
459 459 * The prefix to apply to sort attribute names that are ascending
460 460 */
461 461 ascendingPrefix: string;
462 462
463 463 /**
464 464 * The prefix to apply to sort attribute names that are descending
465 465 */
466 466 descendingPrefix: string;
467 467
468 468 /**
469 469 * If the target has no trailing '/', then append it.
470 470 */
471 471 _getTarget(id: api.Identity): string;
472 472
473 473 /**
474 474 * Retrieves an object by its identity. This will trigger a GET request to the server using
475 475 * the url `this.target + id`.
476 476 */
477 477 get(id: api.Identity, options?: { headers: Headers } | Headers): PromiseLike<T>;
478 478
479 479 /**
480 480 * Defines the Accept header to use on HTTP requests
481 481 */
482 482 accepts: string;
483 483
484 484 /**
485 485 * Stores an object. This will trigger a PUT request to the server
486 486 * if the object has an id, otherwise it will trigger a POST request.
487 487 */
488 put(object: T, options?: JsonRestPutDirectives<T>): PromiseLike<any>;
488 put(object: T, options?: JsonRestPutDirectives<T>): PromiseLike<unknown>;
489 489
490 490 /**
491 491 * Adds an object. This will trigger a PUT request to the server
492 492 * if the object has an id, otherwise it will trigger a POST request.
493 493 */
494 add(object: T, options?: JsonRestPutDirectives<T>): PromiseLike<any>;
494 add(object: T, options?: JsonRestPutDirectives<T>): PromiseLike<unknown>;
495 495
496 496 /**
497 497 * Deletes an object by its identity. This will trigger a DELETE request to the server.
498 498 */
499 499 remove(id: api.Identity, options?: { headers?: Headers }): PromiseLike<void>;
500 500
501 501 }
502 502
503 503 interface JsonRestConstructor extends _base.DeclareConstructor<JsonRest<object, api.BaseQueryType, JsonRestQueryOptions>> {
504 504 new <T extends object, Q extends api.BaseQueryType, O extends JsonRestQueryOptions>(options?: JsonRestOptions<T>): JsonRest<T, Q, O>;
505 505 }
506 506
507 507 /* dojo/store/Memory */
508 508
509 509 interface MemoryOptions<T extends object> {
510 510 data?: T[];
511 511 idProperty?: keyof T;
512 512 queryEngine?: api.QueryEngine<T, api.QueryOptions>;
513 513 setData?: (data: T[]) => void;
514 514 }
515 515
516 516 interface Memory<T extends object> extends api.SyncStore<T> {
517 517 /**
518 518 * The array of all the objects in the memory store
519 519 */
520 520 data: T[];
521 521
522 522 /**
523 523 * An index of data indices into the data array by id
524 524 */
525 525 index: { [id: string]: number };
526 526
527 527 /**
528 528 * Sets the given data as the source for this store, and indexes it
529 529 */
530 530 setData(data: T[]): void;
531 531 }
532 532
533 533 interface MemoryConstructor extends _base.DeclareConstructor<Memory<any>> {
534 534 /**
535 535 * This is a basic in-memory object store. It implements dojo/store/api/Store.
536 536 */
537 537 new <T extends object>(options?: MemoryOptions<T>): Memory<T>;
538 538 }
539 539
540 540 /* dojo/store/Observable */
541 541
542 542 interface ObservableQueryResultsMixin<T extends object> {
543 543 /**
544 544 * Allows observation of results
545 545 */
546 546 observe(listener: (object: T, previousIndex: number, newIndex: number) => void, includeUpdates?: boolean): {
547 547 remove(): void;
548 548 cancel(): void;
549 549 };
550 550 }
551 551
552 552 type ObservableQueryResults<T extends object> = ObservableQueryResultsMixin<T> & api.QueryResults<T>;
553 553
554 554 interface ObservableMixin<T extends object, Q extends api.BaseQueryType, O extends api.QueryOptions, R extends api.QueryResults<T> = api.QueryResults<T> > {
555 555 notify(object: T, existingId?: api.Identity): void;
556 556
557 557 /**
558 558 * Queries the store for objects. This does not alter the store, but returns a
559 559 * set of data from the store.
560 560 */
561 561 query(query: Q, options?: O): ObservableQueryResultsMixin<T> & R;
562 562 }
563 563
564 564 interface ResultsObserveMixin<T extends object> {
565 565 /**
566 566 * Allows observation of results
567 567 */
568 568 observe(listener: (object: T, previousIndex: number, newIndex: number) => void, includeUpdates?: boolean): {
569 569 remove(): void;
570 570 cancel(): void;
571 571 };
572 572 }
573 573
574 574 interface Notifiable<T> {
575 575 notify(object: T, existingId?: api.Identity): void;
576 576 }
577 577
578 578 type ResultItem<R> = R extends ArrayLike<infer I1> ? I1 :
579 579 R extends PromiseLike<ArrayLike<infer I2>> ? I2 : never;
580 580
581 581 type ObservableStore<S extends { query: (...params: any) => any }> =
582 582 S extends { query: (...params: infer P) => api.QueryResults<infer R> } ? {
583 583 [K in keyof S]: K extends "query" ? (...params: P) => ReturnType<S[K]> & ResultsObserveMixin<R> : S[K];
584 584 } & Notifiable<R> : S;
585 585
586 586 interface Observable {
587 587 new <S extends api.Store<any, any, any>>(store: S): ObservableStore<S>;
588 588 }
589 589 }
590 590 }
General Comments 0
You need to be logged in to leave comments. Login now