From 1b718961940d46754115ef6015607fe29a30b521 Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Tue, 3 Mar 2015 16:35:24 -0500 Subject: [PATCH 001/397] Updated with new definitions for Foundation 5.2 -- patches from https://github.com/georgemarshall --- foundation/foundation.d.ts | 303 ++++++++++++++++++++++++++++--------- 1 file changed, 235 insertions(+), 68 deletions(-) diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index d74e954e6..326574ff4 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Foundation 3.2 +// Type definitions for Foundation 5.2.1 // Project: http://foundation.zurb.com/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -6,83 +6,250 @@ /// -interface OrbitOptions { - animation?: string; - animationSpeed?: number; - timer?: boolean; - resetTimerOnClick?: boolean; - advanceSpeed?: number; - pauseOnHover?: boolean; - startClockOnMouseOut?: boolean; - startClockOnMouseOutAfter?: number; - directionalNav?: number; - captions?: number; - captionAnimation?: string; - captionAnimationSpeed?: number; - bullets?: boolean; - bulletThumbs?: boolean; - bulletThumbLocation?: string; - afterSlideChange?: () => void; - fluid?: boolean; +interface AbideOptions { + live_validate?: boolean; + focus_on_invalid?: boolean; + error_labels?: boolean; + timeout?: number; + patterns?: Object; + validators?: { + equalTo?: () => boolean; + }; } -interface RevealOptions { - animation?: string; - animationSpeed?: number; - closeOnBackgroundClick?: boolean; - dismissModalClass?: string; - /** - * The class of the modals background. - */ - bgClass?: string; - open?: () => void; +interface AccordionOptions { + active_class?: string; + multi_expand?: boolean; + toggleable?: boolean; +} + +interface AlertOptions { + callback?: () => void; +} + +interface ClearingOptions { + templates?: { + viewing?: string; + }; +} + +interface DropdownOptions { + active_class?: string; + align?: string; + is_hover?: boolean; opened?: () => void; - close?: () => void; closed?: () => void; - /** - * The modals background object. - */ - bg: JQuery; - /** - * The css property for when the modal is opened and closed. - */ - css: { - open: { - opacity?: number; - visibility?: string; - display: string; - }; - close: { - opacity: number; - visibility: string; - display: string; - }; +} + +interface EqualizerOptions { + use_tallest?: boolean; + before_height_change?: () => void; + after_height_change?: () => void; +} + +interface InterchangeOptions { + load_attr?: string; + named_queries?: Object; + directives?: { + replace?: (el: HTMLElement, path: string, trigger: (...args: any[]) => any) => any; }; } interface JoyrideOptions { - tipLocation?: string; - nubPosition?: string; - scrollSpeed?: number; + expose?: boolean; + modal?: boolean; + tip_location?: string; + nub_position?: string; + scroll_speed?: number; timer?: number; - startTimerOnClick?: boolean; - nextButton?: boolean; - tipAnimation?: string; - pauseAfter?: number[]; - tipAnimationFadeSpeed?: number; - cookieMonster?: boolean; - cookieName?: string; - cookieDomain?: boolean; - tipContainer?: string; - postRideCallback?: () => void; - postStepCallback?: () => void; + start_timer_on_click?: boolean; + start_offset?: number; + next_button?: boolean; + tip_animation?: string; + pause_after?: number[]; + exposed?: HTMLElement[]; + tip_animation_fade_speed?: number; + cookie_monster?: boolean; + cookie_name?: string; + cookie_domain?: boolean; + cookie_expires?: number; + tip_container?: string; + abort_on_close?: boolean; + tip_location_patterns?: { + top?: string[]; + bottom?: string[]; + left?: string[]; + right?: string[]; + }; + post_ride_callback?: () => void; + post_step_callback?: () => void; + pre_step_callback?: () => void; + pre_ride_callback?: () => void; + post_expose_callback?: () => void; + template?: { + link?: string; + timer?: string; + tip?: string; + wrapper?: string; + button?: string; + modal?: string; + expose?: string; + expose_cover?: string; + }; + expose_add_class?: string; +} + +interface MagellanOptions { + active_class?: string; + threshold?: number; + destination_threshold?: number; + throttle_delay?: number; +} + +interface OffCanvasOptions {} + +interface OrbitOptions { + animation?: string; + timer_speed?: number; + pause_on_hover?: boolean; + resume_on_mouseout?: boolean; + next_on_click?: boolean; + animation_speed?: number; + stack_on_small?: boolean; + navigation_arrows?: boolean; + slide_number?: boolean; + slide_number_text?: string; + container_class?: string; + stack_on_small_class?: string; + next_class?: string; + prev_class?: string; + timer_container_class?: string; + timer_paused_class?: string; + timer_progress_class?: string; + slides_container_class?: string; + preloader_class?: string; + slide_selector?: string; + bullets_container_class?: string; + bullets_active_class?: string; + slide_number_class?: string; + caption_class?: string; + active_slide_class?: string; + orbit_transition_class?: string; + bullets?: boolean; + circular?: boolean; + timer?: boolean; + variable_height?: boolean; + swipe?: boolean; + before_slide_change?: () => void; + after_slide_change?: () => void; +} + +interface RevealOptions { + animation?: string; + animation_speed?: number; + close_on_background_click?: boolean; + close_on_esc?: boolean; + dismiss_modal_class?: string; + bg_class?: string; + open?: () => void; + opened?: () => void; + close?: () => void; + closed?: () => void; + bg?: JQuery; + css?: { + open?: Object; + close?: Object; + }; +} + +interface SliderOptions { + start?: number; + end?: number; + step?: number; + initial?: number; + display_selector?: string; + on_change?: () => void; +} + +interface TabOptions { + active_class?: string; + callback?: () => void; + deep_linking?: boolean; + scroll_to_content?: boolean; +} + +interface TooltipOptions { + additional_inheritable_classes?: string[]; + tooltip_class?: string; + append_to?: string; + touch_close_text?: string; + disable_for_touch?: boolean; + hover_delay?: number; + tip_template?: (selector: string, content: string) => string; +} + +interface TopbarOptions{ + index?: number; + sticky_class?: string; + custom_back_text?: boolean; + back_text?: string; + is_hover?: boolean; + mobile_show_parent_link?: boolean; + scrolltop?: boolean; + sticky_on?: string; +} + +interface FoundationOptions { + abide?: AbideOptions; + accordion?: AccordionOptions; + alert?: AlertOptions; + clearing?: ClearingOptions; + dropdown?: DropdownOptions; + interchange?: InterchangeOptions; + joyride?: JoyrideOptions; + magellan?: MagellanOptions; + offcanvas: OffCanvasOptions; + orbit?: OrbitOptions; + reveal?: RevealOptions; + tab?: TabOptions; + tooltip?: TooltipOptions; + topbar?: TopbarOptions; +} + +interface FoundationStatic { + name: string; + version: string; + media_queries: Object; + stylesheet: CSSStyleSheet; + global: { + namespace: string; + }; + init(scope: JQuery): JQuery; + init(scope: JQuery, libraries: FoundationOptions): JQuery; + init(scope: JQuery, libraries: string, method: FoundationOptions): JQuery; + init(scope: JQuery, libraries: string, method: string, options: Object): JQuery; + init_lib(lib: any, args: any): (...args: any[]) => any; + patch(lib: any): void; + inherit(scope: JQuery, methods: string): void; + set_namespace(): void; + libs: Object; + utils: { + S(selector: any, context: any): JQuery; + throttle(func: (...args: any[]) => any, delay: number): (...args: any[]) => any; + debounce(func: (...args: any[]) => any, delay: number, immediate: boolean): (...args: any[]) => any; + data_options(el: JQuery): Object; + register_media(media: string, media_class: string): void; + add_custom_rule(rule: string, media: string): void; + image_loaded(images: JQuery, callback: (...args: any[]) => any): void; + random_str(length?: number): string; + }; } interface JQuery { - orbit(): JQuery; - orbit(OrbitOptions): JQuery; - reveal(): JQuery; - reveal(RevealOptions): JQuery; - joyride(): JQuery; - joyride(JoyrideOptions): JQuery; + foundation(): JQuery; + foundation(libraries: FoundationOptions): JQuery; + foundation(libraries: string, method: FoundationOptions): JQuery; + foundation(libraries: string, method: string, options: Object): JQuery; } + +declare var Foundation: FoundationStatic; From 1bcc72555ee6fa70353326ca3baf2d3b4b7be796 Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Wed, 4 Mar 2015 09:23:34 -0500 Subject: [PATCH 002/397] Updated definitions for Foundation 5.5.1. --- CONTRIBUTORS.md | 2 +- foundation/foundation-tests.ts | 379 ++++++++++++++++++++-- foundation/foundation.d.ts | 570 ++++++++++++++++++--------------- 3 files changed, 662 insertions(+), 289 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 88905c88a..da416132c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -220,7 +220,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](ion.rangeSlider/ion.rangeSlider.d.ts) [for Ion.RangeSlider](https://github.com/IonDen/ion.rangeSlider) by [Sixin Li](https://github.com/sixinli) * [:link:](form-data/form-data.d.ts) [form-data](https://github.com/felixge/node-form-data) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](formidable/formidable.d.ts) [Formidable](https://github.com/felixge/node-formidable) by [Wim Looman](https://github.com/Nemo157) -* [:link:](foundation/foundation.d.ts) [Foundation](http://foundation.zurb.com) by [Boris Yankov](https://github.com/borisyankov) +* [:link:](foundation/foundation.d.ts) [Foundation](http://foundation.zurb.com) by [Boris Yankov](https://github.com/borisyankov), [George Marshall](https://github.com/georgemarshall), [Boltmade](https://github.com/Boltmade) * [:link:](fpsmeter/FPSMeter.d.ts) [FPSmeter](http://darsa.in/fpsmeter) by [Aaron Lampros](http://github.com/alampros) * [:link:](from/from.d.ts) [from](https://github.com/dominictarr/from) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](fs-extra/fs-extra.d.ts) [fs-extra](https://github.com/jprichardson/node-fs-extra) by [midknight41](https://github.com/midknight41) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index f64c83483..c95b54a5b 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -1,33 +1,346 @@ -/// -/// - -function test_orbit() { - $("#featured").orbit(); - $('#featured').orbit({ - animation: 'fade', - animationSpeed: 800, - timer: true, - resetTimerOnClick: false, - advanceSpeed: 4000, - pauseOnHover: false, - startClockOnMouseOut: false, - startClockOnMouseOutAfter: 1000, - directionalNav: true, - captions: true, - captionAnimation: 'fade', - captionAnimationSpeed: 800, - bullets: false, - bulletThumbs: false, - bulletThumbLocation: '', - afterSlideChange: function () { }, - fluid: true - }); -} - -function test_fluid() { - $("#myModal").reveal(); -} - -function test_joyride() { - $("#chooseID").joyride(); -} \ No newline at end of file +/// +/// + +function empty_callback() : void {} + +function plugin_list() { + return [ + "abide", + "accordion", + "alert", + "clearing", + "dropdown", + "interchange", + "joyride", + "magellan", + "offcanvas", + "orbit", + "reveal", + "slider", + "tab", + "tooltip", + "topbar" + ]; +} + +function abide_patterns() { + var patterns : AbidePatterns; + patterns.alpha = /^[a-zA-Z]+$/; + patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; + patterns.integer = /^[-+]?\d+$/; + patterns.number = /^[-+]?[1-9]\d*$/; + patterns.card = /^[0-9]{8}$/; + patterns.cvv = /^([0-9]){3,4}$/; + patterns.email = /^test@example\.org$/; + patterns.url = /http:\/\/www\.google\.com\//; + patterns.domain = /definitelytyped\.org/; + patterns.datetime = /([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))/; + patterns.date = /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/; + patterns.time = /(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}/; + patterns.dateISO = /\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/; + patterns.month_day_year = /(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d/; + patterns.color = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/; + return patterns; +} + +function abide_options() { + var opts : AbideOptions = {}; + opts.live_validate = false; + opts.validate_on_blur = true; + opts.focus_on_invalid = true; + opts.error_labels = true; + opts.timeout = 500; + opts.patterns = abide_patterns(); + opts.validators = { + diceRoll: function(el : HTMLInputElement, required : boolean, parent : HTMLElement) { + var possibilities = [true, false]; + return possibilities[Math.round(Math.random())]; + }, + isAllowed: function(el : HTMLInputElement, required : boolean, parent : HTMLElement) { + var possibilities = ["a@zurb.com", "b.zurb.com"]; + return possibilities.indexOf(el.value) > -1; + } + } + return opts; +} + +function accordion_options() { + var opts : AccordionOptions = {}; + opts.content_class = "content"; + opts.active_class = "class-name"; + opts.multi_expand = false; + opts.toggleable = true; + opts.callback = empty_callback; + return opts; +} + +function alert_options() { + var opts : AlertOptions = {}; + opts.callback = empty_callback; + return opts; +} + +function clearing_options() { + var opts : ClearingOptions = {}; + opts.templates = { + viewing : '
Some HTML
' + }; + opts.close_selectors = "#id-value, .class-name"; + opts.open_selectors = "li#id-value"; + opts.skip_selector = ".skip-class"; + opts.touch_label = "Display string"; + opts.init = true; + opts.locked = false; + return opts; +} + +function dropdown_options() { + var opts : DropdownOptions = {}; + opts.active_class = "class-name"; + opts.disabled_class = "disabled-class"; + opts.mega_class = "big"; + opts.align = "top"; + opts.is_hover = false; + opts.hover_timeout = 250; + opts.opened = empty_callback; + opts.closed = empty_callback; + return opts; +} + +function equalizer_options() { + var opts : EqualizerOptions = {}; + opts.use_tallest = true; + opts.equalize_on_stack = false; + return opts; +} + +function interchange_options() { + var opts : InterchangeOptions = {}; + opts.load_attr = "interchange"; + opts.named_queries = { + my_custom_query: "only screen and (max-width: 200px)" + }; + opts.directives = { + replace: empty_callback + }; + return opts; +} + +function joyride_options() { + var opts : JoyrideOptions = {}; + opts.expose = false; + opts.modal = true; + opts.keyboard = true; + opts.tip_location = "bottom"; + opts.nub_position = "left"; + opts.scroll_speed = 2500; + opts.scroll_animation = "lineaer"; + opts.timer = 100; + opts.start_timer_on_click = true; + opts.start_offset = 3; + opts.next_button = false; + opts.prev_button = false; + opts.tip_animation = "pulse"; + opts.pause_after = [4, 7, 10, 14]; + opts.exposed = ["#elm-id-one", "#elm-id-two"]; + opts.tip_animation_fade_speed = 100; + opts.cookie_monster = true; + opts.cookie_name = "ts_joyride"; + opts.cookie_domain = false; + opts.cookie_expires = 7; + opts.tip_container = '#header'; + opts.tip_location_patterns = { + top: ['botom'], + bottom: [], + left: ['right', 'top', 'bottom'], + right: ['left', 'top', 'bottom'] + }; + opts.post_ride_callback = empty_callback; + opts.post_step_callback = empty_callback; + opts.pre_step_callback = empty_callback; + opts.pre_ride_callback = empty_callback; + opts.post_expose_callback = empty_callback; + opts.template = { + link: '×', + timer: '
', + tip: '
', + wrapper: '
', + button: '', + prev_button: '', + modal: '
', + expose: '
', + expose_cover: '
' + }; + opts.expose_add_class = ".expose .class-name"; + return opts; +} + +function magellan_options() { + var opts : MagellanOptions = {}; + opts.active_class = ".active-element"; + opts.threshold = 20; + opts.destination_threshold = 30; + opts.throttle_delay = 24; + opts.fixed_top = 0; + opts.offset_by_height = false; + opts.duration = 1000; + opts.easing = "linear"; + return opts; +} + +function offcanvas_options() { + var opts : OffCanvasOptions = {}; + opts.open_method = "overlap_single"; + opts.close_on_click = true; + return opts; +} + +function orbit_options() { + var opts : OrbitOptions = {}; + opts.animation = 'slide'; + opts.timer_speed = 10000; + opts.pause_on_hover = true; + opts.resume_on_mouseout = false; + opts.next_on_click = true; + opts.animation_speed = 500; + opts.stack_on_small = false; + opts.navigation_arrows = true; + opts.slide_number = true; + opts.slide_number_text = 'of'; + opts.container_class = 'orbit-container'; + opts.stack_on_small_class = 'orbit-stack-on-small'; + opts.next_class = 'orbit-next'; + opts.prev_class = 'orbit-prev'; + opts.timer_container_class = 'orbit-timer'; + opts.timer_paused_class = 'paused'; + opts.timer_progress_class = 'orbit-progress'; + opts.slides_container_class = 'orbit-slides-container'; + opts.preloader_class = 'preloader'; + opts.slide_selector = 'li'; + opts.bullets_container_class = 'orbit-bullets'; + opts.bullets_active_class = 'active'; + opts.slide_number_class = 'orbit-slide-number'; + opts.caption_class = 'orbit-caption'; + opts.active_slide_class = 'active'; + opts.orbit_transition_class = 'orbit-transitioning'; + opts.bullets = true; + opts.circular = true; + opts.timer = true; + opts.variable_height = false; + opts.swipe = true; + opts.before_slide_change = empty_callback; + opts.after_slide_change = empty_callback; + return opts; +} + +function reveal_css_options() { + var opts : RevealCSSOptions = {}; + opts.opacity = 0; + opts.visibility = 'hidden'; + opts.display = "inline-block"; + return opts; +} + +function reveal_options() { + var opts : RevealOptions = {}; + opts.animation = "linear"; + opts.animation_speed = 500; + opts.close_on_background_click = false; + opts.dismiss_modal_class = ".modal-bye-bye"; + opts.multiple_opened = true; + opts.bg_class = ".modal-background"; + opts.root_element = "#element-id.element-class"; + opts.on_ajax_error = empty_callback; + opts.open = empty_callback; + opts.opened = empty_callback; + opts.close = empty_callback; + opts.close = empty_callback; + opts.bg = $("#my-modal-id .background"); + opts.css = { + open: reveal_css_options(), + close: reveal_css_options() + }; + return opts; +} + +function slider_options() { + var opts : SliderOptions; + opts.start = -1000; + opts.end = 1000; + opts.step = 50; + opts.precision = 4; + opts.initial = 0; + opts.vertical = false; + opts.trigger_input_change = true; + opts.on_change = empty_callback; + return opts; +} + +function tab_options() { + var opts : TabOptions = {}; + opts.active_class = "class-name"; + opts.callback = empty_callback; + opts.deep_linking = false; + opts.scroll_to_content = true; + opts.is_hover = false; + return opts; +} + +function tooltip_options() { + var opts : TooltipOptions = {}; + opts.additional_inheritable_classes = ["class1", "class2"]; + opts.tooltip_class = "tooltip"; + opts.append_to = "append-class"; + opts.touch_close_text = "Close"; + opts.disable_for_touch = true; + opts.hover_delay = 100; + opts.show_on = "all"; + opts.tip_template = function (selector, content) { + return '' + content + ''; + }; + return opts; +} + +function topbar_options() { + var opts : TopbarOptions = {}; + opts.index = 1; + opts.sticky_class = "top-bar"; + opts.custom_back_text = true; + opts.back_text = "Return"; + opts.is_hover = false; + opts.mobile_show_parent_link = true; + opts.scrolltop = true; + opts.sticky_on = "all"; + return opts; +} + +function foundation_options() : FoundationOptions { + var opts : FoundationOptions = {}; + opts.abide = abide_options(); + opts.accordion = accordion_options(); + opts.alert = alert_options(); + opts.clearing = clearing_options(); + opts.dropdown = dropdown_options(); + opts.equalizer = equalizer_options(); + opts.joyride = joyride_options(); + opts.magellan = magellan_options(); + opts.offcanvas = offcanvas_options(); + opts.orbit = orbit_options(); + opts.reveal = reveal_options(); + opts.slider = slider_options(); + opts.tab = tab_options(); + opts.tooltip = tooltip_options(); + opts.topbar = topbar_options(); + return opts; +} + +$(document).foundation(); + +$(document).foundation(foundation_options()); + +$(document).foundation("reflow"); +plugin_list().forEach((plugin) => $(document).foundation(plugin, "reflow")); + +$(document).foundation("slider", "set_value", 100); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index 326574ff4..a531a051e 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,255 +1,315 @@ -// Type definitions for Foundation 5.2.1 -// Project: http://foundation.zurb.com/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -/// - -interface AbideOptions { - live_validate?: boolean; - focus_on_invalid?: boolean; - error_labels?: boolean; - timeout?: number; - patterns?: Object; - validators?: { - equalTo?: () => boolean; - }; -} - -interface AccordionOptions { - active_class?: string; - multi_expand?: boolean; - toggleable?: boolean; -} - -interface AlertOptions { - callback?: () => void; -} - -interface ClearingOptions { - templates?: { - viewing?: string; - }; -} - -interface DropdownOptions { - active_class?: string; - align?: string; - is_hover?: boolean; - opened?: () => void; - closed?: () => void; -} - -interface EqualizerOptions { - use_tallest?: boolean; - before_height_change?: () => void; - after_height_change?: () => void; -} - -interface InterchangeOptions { - load_attr?: string; - named_queries?: Object; - directives?: { - replace?: (el: HTMLElement, path: string, trigger: (...args: any[]) => any) => any; - }; -} - -interface JoyrideOptions { - expose?: boolean; - modal?: boolean; - tip_location?: string; - nub_position?: string; - scroll_speed?: number; - timer?: number; - start_timer_on_click?: boolean; - start_offset?: number; - next_button?: boolean; - tip_animation?: string; - pause_after?: number[]; - exposed?: HTMLElement[]; - tip_animation_fade_speed?: number; - cookie_monster?: boolean; - cookie_name?: string; - cookie_domain?: boolean; - cookie_expires?: number; - tip_container?: string; - abort_on_close?: boolean; - tip_location_patterns?: { - top?: string[]; - bottom?: string[]; - left?: string[]; - right?: string[]; - }; - post_ride_callback?: () => void; - post_step_callback?: () => void; - pre_step_callback?: () => void; - pre_ride_callback?: () => void; - post_expose_callback?: () => void; - template?: { - link?: string; - timer?: string; - tip?: string; - wrapper?: string; - button?: string; - modal?: string; - expose?: string; - expose_cover?: string; - }; - expose_add_class?: string; -} - -interface MagellanOptions { - active_class?: string; - threshold?: number; - destination_threshold?: number; - throttle_delay?: number; -} - -interface OffCanvasOptions {} - -interface OrbitOptions { - animation?: string; - timer_speed?: number; - pause_on_hover?: boolean; - resume_on_mouseout?: boolean; - next_on_click?: boolean; - animation_speed?: number; - stack_on_small?: boolean; - navigation_arrows?: boolean; - slide_number?: boolean; - slide_number_text?: string; - container_class?: string; - stack_on_small_class?: string; - next_class?: string; - prev_class?: string; - timer_container_class?: string; - timer_paused_class?: string; - timer_progress_class?: string; - slides_container_class?: string; - preloader_class?: string; - slide_selector?: string; - bullets_container_class?: string; - bullets_active_class?: string; - slide_number_class?: string; - caption_class?: string; - active_slide_class?: string; - orbit_transition_class?: string; - bullets?: boolean; - circular?: boolean; - timer?: boolean; - variable_height?: boolean; - swipe?: boolean; - before_slide_change?: () => void; - after_slide_change?: () => void; -} - -interface RevealOptions { - animation?: string; - animation_speed?: number; - close_on_background_click?: boolean; - close_on_esc?: boolean; - dismiss_modal_class?: string; - bg_class?: string; - open?: () => void; - opened?: () => void; - close?: () => void; - closed?: () => void; - bg?: JQuery; - css?: { - open?: Object; - close?: Object; - }; -} - -interface SliderOptions { - start?: number; - end?: number; - step?: number; - initial?: number; - display_selector?: string; - on_change?: () => void; -} - -interface TabOptions { - active_class?: string; - callback?: () => void; - deep_linking?: boolean; - scroll_to_content?: boolean; -} - -interface TooltipOptions { - additional_inheritable_classes?: string[]; - tooltip_class?: string; - append_to?: string; - touch_close_text?: string; - disable_for_touch?: boolean; - hover_delay?: number; - tip_template?: (selector: string, content: string) => string; -} - -interface TopbarOptions{ - index?: number; - sticky_class?: string; - custom_back_text?: boolean; - back_text?: string; - is_hover?: boolean; - mobile_show_parent_link?: boolean; - scrolltop?: boolean; - sticky_on?: string; -} - -interface FoundationOptions { - abide?: AbideOptions; - accordion?: AccordionOptions; - alert?: AlertOptions; - clearing?: ClearingOptions; - dropdown?: DropdownOptions; - interchange?: InterchangeOptions; - joyride?: JoyrideOptions; - magellan?: MagellanOptions; - offcanvas: OffCanvasOptions; - orbit?: OrbitOptions; - reveal?: RevealOptions; - tab?: TabOptions; - tooltip?: TooltipOptions; - topbar?: TopbarOptions; -} - -interface FoundationStatic { - name: string; - version: string; - media_queries: Object; - stylesheet: CSSStyleSheet; - global: { - namespace: string; - }; - init(scope: JQuery): JQuery; - init(scope: JQuery, libraries: FoundationOptions): JQuery; - init(scope: JQuery, libraries: string, method: FoundationOptions): JQuery; - init(scope: JQuery, libraries: string, method: string, options: Object): JQuery; - init_lib(lib: any, args: any): (...args: any[]) => any; - patch(lib: any): void; - inherit(scope: JQuery, methods: string): void; - set_namespace(): void; - libs: Object; - utils: { - S(selector: any, context: any): JQuery; - throttle(func: (...args: any[]) => any, delay: number): (...args: any[]) => any; - debounce(func: (...args: any[]) => any, delay: number, immediate: boolean): (...args: any[]) => any; - data_options(el: JQuery): Object; - register_media(media: string, media_class: string): void; - add_custom_rule(rule: string, media: string): void; - image_loaded(images: JQuery, callback: (...args: any[]) => any): void; - random_str(length?: number): string; - }; -} - -interface JQuery { - foundation(): JQuery; - foundation(libraries: FoundationOptions): JQuery; - foundation(libraries: string, method: FoundationOptions): JQuery; - foundation(libraries: string, method: string, options: Object): JQuery; -} - -declare var Foundation: FoundationStatic; +// Type definitions for Foundation 5.5.1 +// Project : http://foundation.zurb.com/ +// Definitions by : Boris Yankov +// Definitions : https://github.com/borisyankov/DefinitelyTyped + + +/// + +// http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration +interface AbidePatterns { + alpha? : RegExp; + alpha_numeric? : RegExp; + integer? : RegExp; + number? : RegExp; + card? : RegExp; + cvv? : RegExp; + email? : RegExp; + url? : RegExp; + domain? : RegExp; + datetime? : RegExp; + date? : RegExp; + time? : RegExp; + dateISO? : RegExp; + month_day_year? : RegExp; + color? : RegExp; +} + +interface AbideOptions { + live_validate? : boolean; + validate_on_blur? : boolean; + focus_on_invalid? : boolean; + error_labels? : boolean; + timeout? : number; + patterns? : AbidePatterns; + validators? : Object; +} + +// http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration +interface AccordionOptions { + content_class? : string; + active_class? : string; + multi_expand? : boolean; + toggleable? : boolean; + callback? : () => any; +} + +// http://foundation.zurb.com/docs/components/alert_boxes.html +interface AlertOptions { + callback? : () => any; +} + +// http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration +interface ClearingOptions { + templates? : Object; + close_selectors? : string; + open_selectors? : string; + skip_selector? : string; + touch_label? : string; + init? : boolean; + locked? : boolean; +} + +// http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration +interface DropdownOptions { + active_class? : string; + disabled_class? : string; + mega_class? : string; + align? : string; + is_hover? : boolean; + hover_timeout? : number; + opened? : () => any; + closed? : () => any; +} + +// http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration +interface EqualizerOptions { + use_tallest? : boolean; + equalize_on_stack? : boolean; +} + +// http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries +interface InterchangeOptions { + load_attr? : string; + named_queries? : Object; + directives? : Object; +} + +// http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration +interface JoyrideOptions { + expose? : boolean; + modal? : boolean; + keyboard? : boolean; + tip_location? : string; + nub_position? : string; + scroll_speed? : number; + scroll_animation? : string; + timer? : number; + start_timer_on_click? : boolean; + start_offset? : number; + next_button? : boolean; + prev_button? : boolean; + tip_animation? : string; + pause_after? : number[]; + exposed? : string[]; + tip_animation_fade_speed? : number; + cookie_monster? : boolean; + cookie_name? : string; + cookie_domain? : boolean; + cookie_expires? : number; + tip_container? : string; + tip_location_patterns? : { + top? : string[]; + bottom? : string[]; + left? : string[]; + right? : string[]; + }; + post_ride_callback? : () => void; + post_step_callback? : () => void; + pre_step_callback? : () => void; + pre_ride_callback? : () => void; + post_expose_callback? : () => void; + template? : { + link? : string; + timer? : string; + tip? : string; + wrapper? : string; + button? : string; + modal? : string; + expose? : string; + expose_cover? : string; + }; + expose_add_class? : string; +} + +// http://foundation.zurb.com/docs/components/magellan.html#js +interface MagellanOptions { + active_class? : string; + threshold? : number; + destination_threshold? : number; + throttle_delay? : number; + fixed_top? : number; + offset_by_height? : boolean; + duration? : number; + easing? : string; +} + +// http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration +interface OffCanvasOptions { + open_method? : string; + close_on_click? : boolean; +} + +// http://foundation.zurb.com/docs/components/orbit.html#advanced +interface OrbitOptions { + animation? : string; + timer_speed? : number; + pause_on_hover? : boolean; + resume_on_mouseout? : boolean; + next_on_click? : boolean; + animation_speed? : number; + stack_on_small? : boolean; + navigation_arrows? : boolean; + slide_number? : boolean; + slide_number_text? : string; + container_class? : string; + stack_on_small_class? : string; + next_class? : string; + prev_class? : string; + timer_container_class? : string; + timer_paused_class? : string; + timer_progress_class? : string; + slides_container_class? : string; + preloader_class? : string; + slide_selector? : string; + bullets_container_class? : string; + bullets_active_class? : string; + slide_number_class? : string; + caption_class? : string; + active_slide_class? : string; + orbit_transition_class? : string; + bullets? : boolean; + circular? : boolean; + timer? : boolean; + variable_height? : boolean; + swipe? : boolean; + before_slide_change? : () => any; + after_slide_change? : () => any; +} + +// http://foundation.zurb.com/docs/components/reveal.html +interface RevealCSSOptions { + opacity? : number; + visibility? : string; + display? : string; +} + +interface RevealOptions { + animation? : string; + animation_speed? : number; + close_on_background_click? : boolean; + dismiss_modal_class? : string; + multiple_opened? : boolean; + bg_class? : string; + root_element? : string; + on_ajax_error? : () => any; + open? : () => any; + opened? : () => any; + close? : () => any; + closed? : () => any; + bg? : JQuery; + css? : { + open? : RevealCSSOptions; + close? : RevealCSSOptions; + }; +} + +// http://foundation.zurb.com/docs/components/range_slider.html +interface SliderOptions { + start? : number; + end? : number; + step? : number; + precision? : number; + initial? : number; + vertical? : boolean; + trigger_input_change? : boolean; + on_change? : () => any; +} + +// http://foundation.zurb.com/docs/components/tabs.html +interface TabOptions { + active_class? : string; + callback? : () => any; + deep_linking? : boolean; + scroll_to_content? : boolean; + is_hover? : boolean; +} + +interface TooltipOptions { + additional_inheritable_classes? : string[]; + tooltip_class? : string; + append_to? : string; + touch_close_text? : string; + disable_for_touch? : boolean; + hover_delay? : number; + show_on? : string; + tip_template? : (selector : string, content : string) => string; +} + +interface TopbarOptions { + index? : number; + sticky_class? : string; + custom_back_text? : boolean; + back_text? : string; + is_hover? : boolean; + mobile_show_parent_link? : boolean; + scrolltop? : boolean; + sticky_on? : string; +} + +interface FoundationOptions { + abide? : AbideOptions; + accordion? : AccordionOptions; + alert? : AlertOptions; + clearing? : ClearingOptions; + dropdown? : DropdownOptions; + equalizer? : EqualizerOptions; + interchange? : InterchangeOptions; + joyride? : JoyrideOptions; + magellan? : MagellanOptions; + offcanvas? : OffCanvasOptions; + orbit? : OrbitOptions; + reveal? : RevealOptions; + slider? : SliderOptions; + tab? : TabOptions; + tooltip? : TooltipOptions; + topbar? : TopbarOptions; +} + +interface FoundationStatic { + name : string; + version : string; + media_queries : Object; + stylesheet : CSSStyleSheet; + global : { + namespace : string; + }; + init(scope : JQuery) : JQuery; + init(scope : JQuery, libraries : FoundationOptions) : JQuery; + init(scope : JQuery, libraries : string, method : FoundationOptions) : JQuery; + init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; + init_lib(lib : any, args : any) : (...args : any[]) => any; + patch(lib : any) : void; + inherit(scope : JQuery, methods : string) : void; + set_namespace() : void; + libs : any; + utils : { + S(selector : any, context : any) : JQuery; + throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; + debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; + data_options(el : JQuery) : Object; + register_media(media : string, media_class : string) : void; + add_custom_rule(rule : string, media : string) : void; + image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; + random_str(length? : number) : string; + }; +} + +interface JQuery { + foundation() : JQuery; + foundation(libraries : FoundationOptions | string) : JQuery; + foundation(libraries : string, method : FoundationOptions | string) : JQuery; + foundation(libraries : string, method : string, options : Object) : JQuery; +} + +declare var Foundation : FoundationStatic; From 25cad4036620470b17be460cdf823319b345634a Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Sun, 8 Mar 2015 13:47:14 -0400 Subject: [PATCH 003/397] Fixed up header to meet spec requirements. --- foundation/foundation.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index a531a051e..0f4ef3be1 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,7 +1,7 @@ -// Type definitions for Foundation 5.5.1 -// Project : http://foundation.zurb.com/ -// Definitions by : Boris Yankov -// Definitions : https://github.com/borisyankov/DefinitelyTyped +// Type definitions for Foundation v5.5.1 +// Project: http://foundation.zurb.com/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 9e24a051107337c96c1d47b15b540d5e6b75610e Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Sun, 8 Mar 2015 13:54:16 -0400 Subject: [PATCH 004/397] Namespace the various Foundation option interfaces to prevent conflicts. --- foundation/foundation-tests.ts | 38 ++++++++--------- foundation/foundation.d.ts | 74 +++++++++++++++++----------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index c95b54a5b..062fcc04b 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -24,7 +24,7 @@ function plugin_list() { } function abide_patterns() { - var patterns : AbidePatterns; + var patterns : FoundationAbidePatterns; patterns.alpha = /^[a-zA-Z]+$/; patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; patterns.integer = /^[-+]?\d+$/; @@ -44,7 +44,7 @@ function abide_patterns() { } function abide_options() { - var opts : AbideOptions = {}; + var opts : FoundationAbideOptions = {}; opts.live_validate = false; opts.validate_on_blur = true; opts.focus_on_invalid = true; @@ -65,7 +65,7 @@ function abide_options() { } function accordion_options() { - var opts : AccordionOptions = {}; + var opts : FoundationAccordionOptions = {}; opts.content_class = "content"; opts.active_class = "class-name"; opts.multi_expand = false; @@ -75,13 +75,13 @@ function accordion_options() { } function alert_options() { - var opts : AlertOptions = {}; + var opts : FoundationAlertOptions = {}; opts.callback = empty_callback; return opts; } function clearing_options() { - var opts : ClearingOptions = {}; + var opts : FoundationClearingOptions = {}; opts.templates = { viewing : '
Some HTML
' }; @@ -95,7 +95,7 @@ function clearing_options() { } function dropdown_options() { - var opts : DropdownOptions = {}; + var opts : FoundationDropdownOptions = {}; opts.active_class = "class-name"; opts.disabled_class = "disabled-class"; opts.mega_class = "big"; @@ -108,14 +108,14 @@ function dropdown_options() { } function equalizer_options() { - var opts : EqualizerOptions = {}; + var opts : FoundationEqualizerOptions = {}; opts.use_tallest = true; opts.equalize_on_stack = false; return opts; } function interchange_options() { - var opts : InterchangeOptions = {}; + var opts : FoundationInterchangeOptions = {}; opts.load_attr = "interchange"; opts.named_queries = { my_custom_query: "only screen and (max-width: 200px)" @@ -127,7 +127,7 @@ function interchange_options() { } function joyride_options() { - var opts : JoyrideOptions = {}; + var opts : FoundationJoyrideOptions = {}; opts.expose = false; opts.modal = true; opts.keyboard = true; @@ -176,7 +176,7 @@ function joyride_options() { } function magellan_options() { - var opts : MagellanOptions = {}; + var opts : FoundationMagellanOptions = {}; opts.active_class = ".active-element"; opts.threshold = 20; opts.destination_threshold = 30; @@ -189,14 +189,14 @@ function magellan_options() { } function offcanvas_options() { - var opts : OffCanvasOptions = {}; + var opts : FoundationOffCanvasOptions = {}; opts.open_method = "overlap_single"; opts.close_on_click = true; return opts; } function orbit_options() { - var opts : OrbitOptions = {}; + var opts : FoundationOrbitOptions = {}; opts.animation = 'slide'; opts.timer_speed = 10000; opts.pause_on_hover = true; @@ -234,7 +234,7 @@ function orbit_options() { } function reveal_css_options() { - var opts : RevealCSSOptions = {}; + var opts : FoundationRevealCSSOptions = {}; opts.opacity = 0; opts.visibility = 'hidden'; opts.display = "inline-block"; @@ -242,7 +242,7 @@ function reveal_css_options() { } function reveal_options() { - var opts : RevealOptions = {}; + var opts : FoundationRevealOptions = {}; opts.animation = "linear"; opts.animation_speed = 500; opts.close_on_background_click = false; @@ -264,7 +264,7 @@ function reveal_options() { } function slider_options() { - var opts : SliderOptions; + var opts : FoundationSliderOptions; opts.start = -1000; opts.end = 1000; opts.step = 50; @@ -277,7 +277,7 @@ function slider_options() { } function tab_options() { - var opts : TabOptions = {}; + var opts : FoundationTabOptions = {}; opts.active_class = "class-name"; opts.callback = empty_callback; opts.deep_linking = false; @@ -287,7 +287,7 @@ function tab_options() { } function tooltip_options() { - var opts : TooltipOptions = {}; + var opts : FoundationTooltipOptions = {}; opts.additional_inheritable_classes = ["class1", "class2"]; opts.tooltip_class = "tooltip"; opts.append_to = "append-class"; @@ -304,7 +304,7 @@ function tooltip_options() { } function topbar_options() { - var opts : TopbarOptions = {}; + var opts : FoundationTopbarOptions = {}; opts.index = 1; opts.sticky_class = "top-bar"; opts.custom_back_text = true; @@ -316,7 +316,7 @@ function topbar_options() { return opts; } -function foundation_options() : FoundationOptions { +function foundation_options() { var opts : FoundationOptions = {}; opts.abide = abide_options(); opts.accordion = accordion_options(); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index 0f4ef3be1..ad3696f01 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -7,7 +7,7 @@ /// // http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration -interface AbidePatterns { +interface FoundationAbidePatterns { alpha? : RegExp; alpha_numeric? : RegExp; integer? : RegExp; @@ -25,18 +25,18 @@ interface AbidePatterns { color? : RegExp; } -interface AbideOptions { +interface FoundationAbideOptions { live_validate? : boolean; validate_on_blur? : boolean; focus_on_invalid? : boolean; error_labels? : boolean; timeout? : number; - patterns? : AbidePatterns; + patterns? : FoundationAbidePatterns; validators? : Object; } // http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration -interface AccordionOptions { +interface FoundationAccordionOptions { content_class? : string; active_class? : string; multi_expand? : boolean; @@ -45,12 +45,12 @@ interface AccordionOptions { } // http://foundation.zurb.com/docs/components/alert_boxes.html -interface AlertOptions { +interface FoundationAlertOptions { callback? : () => any; } // http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration -interface ClearingOptions { +interface FoundationClearingOptions { templates? : Object; close_selectors? : string; open_selectors? : string; @@ -61,7 +61,7 @@ interface ClearingOptions { } // http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration -interface DropdownOptions { +interface FoundationDropdownOptions { active_class? : string; disabled_class? : string; mega_class? : string; @@ -73,20 +73,20 @@ interface DropdownOptions { } // http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration -interface EqualizerOptions { +interface FoundationEqualizerOptions { use_tallest? : boolean; equalize_on_stack? : boolean; } // http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries -interface InterchangeOptions { +interface FoundationInterchangeOptions { load_attr? : string; named_queries? : Object; directives? : Object; } // http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration -interface JoyrideOptions { +interface FoundationJoyrideOptions { expose? : boolean; modal? : boolean; keyboard? : boolean; @@ -133,7 +133,7 @@ interface JoyrideOptions { } // http://foundation.zurb.com/docs/components/magellan.html#js -interface MagellanOptions { +interface FoundationMagellanOptions { active_class? : string; threshold? : number; destination_threshold? : number; @@ -145,13 +145,13 @@ interface MagellanOptions { } // http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration -interface OffCanvasOptions { +interface FoundationOffCanvasOptions { open_method? : string; close_on_click? : boolean; } // http://foundation.zurb.com/docs/components/orbit.html#advanced -interface OrbitOptions { +interface FoundationOrbitOptions { animation? : string; timer_speed? : number; pause_on_hover? : boolean; @@ -188,13 +188,13 @@ interface OrbitOptions { } // http://foundation.zurb.com/docs/components/reveal.html -interface RevealCSSOptions { +interface FoundationRevealCSSOptions { opacity? : number; visibility? : string; display? : string; } -interface RevealOptions { +interface FoundationRevealOptions { animation? : string; animation_speed? : number; close_on_background_click? : boolean; @@ -209,13 +209,13 @@ interface RevealOptions { closed? : () => any; bg? : JQuery; css? : { - open? : RevealCSSOptions; - close? : RevealCSSOptions; + open? : FoundationRevealCSSOptions; + close? : FoundationRevealCSSOptions; }; } // http://foundation.zurb.com/docs/components/range_slider.html -interface SliderOptions { +interface FoundationSliderOptions { start? : number; end? : number; step? : number; @@ -227,7 +227,7 @@ interface SliderOptions { } // http://foundation.zurb.com/docs/components/tabs.html -interface TabOptions { +interface FoundationTabOptions { active_class? : string; callback? : () => any; deep_linking? : boolean; @@ -235,7 +235,7 @@ interface TabOptions { is_hover? : boolean; } -interface TooltipOptions { +interface FoundationTooltipOptions { additional_inheritable_classes? : string[]; tooltip_class? : string; append_to? : string; @@ -246,7 +246,7 @@ interface TooltipOptions { tip_template? : (selector : string, content : string) => string; } -interface TopbarOptions { +interface FoundationTopbarOptions { index? : number; sticky_class? : string; custom_back_text? : boolean; @@ -258,22 +258,22 @@ interface TopbarOptions { } interface FoundationOptions { - abide? : AbideOptions; - accordion? : AccordionOptions; - alert? : AlertOptions; - clearing? : ClearingOptions; - dropdown? : DropdownOptions; - equalizer? : EqualizerOptions; - interchange? : InterchangeOptions; - joyride? : JoyrideOptions; - magellan? : MagellanOptions; - offcanvas? : OffCanvasOptions; - orbit? : OrbitOptions; - reveal? : RevealOptions; - slider? : SliderOptions; - tab? : TabOptions; - tooltip? : TooltipOptions; - topbar? : TopbarOptions; + abide? : FoundationAbideOptions; + accordion? : FoundationAccordionOptions; + alert? : FoundationAlertOptions; + clearing? : FoundationClearingOptions; + dropdown? : FoundationDropdownOptions; + equalizer? : FoundationEqualizerOptions; + interchange? : FoundationInterchangeOptions; + joyride? : FoundationJoyrideOptions; + magellan? : FoundationMagellanOptions; + offcanvas? : FoundationOffCanvasOptions; + orbit? : FoundationOrbitOptions; + reveal? : FoundationRevealOptions; + slider? : FoundationSliderOptions; + tab? : FoundationTabOptions; + tooltip? : FoundationTooltipOptions; + topbar? : FoundationTopbarOptions; } interface FoundationStatic { From 7dd9a59ab0c37c19178735dfa02b2ad69dde7d82 Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Sun, 15 Mar 2015 14:16:25 -0400 Subject: [PATCH 005/397] Don't pollute the global namespace with interfaces used for Foundation. --- foundation/foundation-tests.ts | 38 +-- foundation/foundation.d.ts | 564 +++++++++++++++++---------------- 2 files changed, 302 insertions(+), 300 deletions(-) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index 062fcc04b..9706fbf97 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -24,7 +24,7 @@ function plugin_list() { } function abide_patterns() { - var patterns : FoundationAbidePatterns; + var patterns : Foundation.AbidePatterns = {}; patterns.alpha = /^[a-zA-Z]+$/; patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; patterns.integer = /^[-+]?\d+$/; @@ -44,7 +44,7 @@ function abide_patterns() { } function abide_options() { - var opts : FoundationAbideOptions = {}; + var opts : Foundation.AbideOptions = {}; opts.live_validate = false; opts.validate_on_blur = true; opts.focus_on_invalid = true; @@ -65,7 +65,7 @@ function abide_options() { } function accordion_options() { - var opts : FoundationAccordionOptions = {}; + var opts : Foundation.AccordionOptions = {}; opts.content_class = "content"; opts.active_class = "class-name"; opts.multi_expand = false; @@ -75,13 +75,13 @@ function accordion_options() { } function alert_options() { - var opts : FoundationAlertOptions = {}; + var opts : Foundation.AlertOptions = {}; opts.callback = empty_callback; return opts; } function clearing_options() { - var opts : FoundationClearingOptions = {}; + var opts : Foundation.ClearingOptions = {}; opts.templates = { viewing : '
Some HTML
' }; @@ -95,7 +95,7 @@ function clearing_options() { } function dropdown_options() { - var opts : FoundationDropdownOptions = {}; + var opts : Foundation.DropdownOptions = {}; opts.active_class = "class-name"; opts.disabled_class = "disabled-class"; opts.mega_class = "big"; @@ -108,14 +108,14 @@ function dropdown_options() { } function equalizer_options() { - var opts : FoundationEqualizerOptions = {}; + var opts : Foundation.EqualizerOptions = {}; opts.use_tallest = true; opts.equalize_on_stack = false; return opts; } function interchange_options() { - var opts : FoundationInterchangeOptions = {}; + var opts : Foundation.InterchangeOptions = {}; opts.load_attr = "interchange"; opts.named_queries = { my_custom_query: "only screen and (max-width: 200px)" @@ -127,7 +127,7 @@ function interchange_options() { } function joyride_options() { - var opts : FoundationJoyrideOptions = {}; + var opts : Foundation.JoyrideOptions = {}; opts.expose = false; opts.modal = true; opts.keyboard = true; @@ -176,7 +176,7 @@ function joyride_options() { } function magellan_options() { - var opts : FoundationMagellanOptions = {}; + var opts : Foundation.MagellanOptions = {}; opts.active_class = ".active-element"; opts.threshold = 20; opts.destination_threshold = 30; @@ -189,14 +189,14 @@ function magellan_options() { } function offcanvas_options() { - var opts : FoundationOffCanvasOptions = {}; + var opts : Foundation.OffCanvasOptions = {}; opts.open_method = "overlap_single"; opts.close_on_click = true; return opts; } function orbit_options() { - var opts : FoundationOrbitOptions = {}; + var opts : Foundation.OrbitOptions = {}; opts.animation = 'slide'; opts.timer_speed = 10000; opts.pause_on_hover = true; @@ -234,7 +234,7 @@ function orbit_options() { } function reveal_css_options() { - var opts : FoundationRevealCSSOptions = {}; + var opts : Foundation.RevealCSSOptions = {}; opts.opacity = 0; opts.visibility = 'hidden'; opts.display = "inline-block"; @@ -242,7 +242,7 @@ function reveal_css_options() { } function reveal_options() { - var opts : FoundationRevealOptions = {}; + var opts : Foundation.RevealOptions = {}; opts.animation = "linear"; opts.animation_speed = 500; opts.close_on_background_click = false; @@ -264,7 +264,7 @@ function reveal_options() { } function slider_options() { - var opts : FoundationSliderOptions; + var opts : Foundation.SliderOptions = {}; opts.start = -1000; opts.end = 1000; opts.step = 50; @@ -277,7 +277,7 @@ function slider_options() { } function tab_options() { - var opts : FoundationTabOptions = {}; + var opts : Foundation.TabOptions = {}; opts.active_class = "class-name"; opts.callback = empty_callback; opts.deep_linking = false; @@ -287,7 +287,7 @@ function tab_options() { } function tooltip_options() { - var opts : FoundationTooltipOptions = {}; + var opts : Foundation.TooltipOptions = {}; opts.additional_inheritable_classes = ["class1", "class2"]; opts.tooltip_class = "tooltip"; opts.append_to = "append-class"; @@ -304,7 +304,7 @@ function tooltip_options() { } function topbar_options() { - var opts : FoundationTopbarOptions = {}; + var opts : Foundation.TopbarOptions = {}; opts.index = 1; opts.sticky_class = "top-bar"; opts.custom_back_text = true; @@ -317,7 +317,7 @@ function topbar_options() { } function foundation_options() { - var opts : FoundationOptions = {}; + var opts : Foundation.Options = {}; opts.abide = abide_options(); opts.accordion = accordion_options(); opts.alert = alert_options(); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index ad3696f01..c2dc4fc24 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -6,310 +6,312 @@ /// -// http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration -interface FoundationAbidePatterns { - alpha? : RegExp; - alpha_numeric? : RegExp; - integer? : RegExp; - number? : RegExp; - card? : RegExp; - cvv? : RegExp; - email? : RegExp; - url? : RegExp; - domain? : RegExp; - datetime? : RegExp; - date? : RegExp; - time? : RegExp; - dateISO? : RegExp; - month_day_year? : RegExp; - color? : RegExp; -} +declare module Foundation { + // http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration + interface AbidePatterns { + alpha? : RegExp; + alpha_numeric? : RegExp; + integer? : RegExp; + number? : RegExp; + card? : RegExp; + cvv? : RegExp; + email? : RegExp; + url? : RegExp; + domain? : RegExp; + datetime? : RegExp; + date? : RegExp; + time? : RegExp; + dateISO? : RegExp; + month_day_year? : RegExp; + color? : RegExp; + } -interface FoundationAbideOptions { - live_validate? : boolean; - validate_on_blur? : boolean; - focus_on_invalid? : boolean; - error_labels? : boolean; - timeout? : number; - patterns? : FoundationAbidePatterns; - validators? : Object; -} + interface AbideOptions { + live_validate? : boolean; + validate_on_blur? : boolean; + focus_on_invalid? : boolean; + error_labels? : boolean; + timeout? : number; + patterns? : AbidePatterns; + validators? : Object; + } -// http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration -interface FoundationAccordionOptions { - content_class? : string; - active_class? : string; - multi_expand? : boolean; - toggleable? : boolean; - callback? : () => any; -} + // http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration + interface AccordionOptions { + content_class? : string; + active_class? : string; + multi_expand? : boolean; + toggleable? : boolean; + callback? : () => any; + } -// http://foundation.zurb.com/docs/components/alert_boxes.html -interface FoundationAlertOptions { - callback? : () => any; -} + // http://foundation.zurb.com/docs/components/alert_boxes.html + interface AlertOptions { + callback? : () => any; + } -// http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration -interface FoundationClearingOptions { - templates? : Object; - close_selectors? : string; - open_selectors? : string; - skip_selector? : string; - touch_label? : string; - init? : boolean; - locked? : boolean; -} + // http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration + interface ClearingOptions { + templates? : Object; + close_selectors? : string; + open_selectors? : string; + skip_selector? : string; + touch_label? : string; + init? : boolean; + locked? : boolean; + } -// http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration -interface FoundationDropdownOptions { - active_class? : string; - disabled_class? : string; - mega_class? : string; - align? : string; - is_hover? : boolean; - hover_timeout? : number; - opened? : () => any; - closed? : () => any; -} + // http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration + interface DropdownOptions { + active_class? : string; + disabled_class? : string; + mega_class? : string; + align? : string; + is_hover? : boolean; + hover_timeout? : number; + opened? : () => any; + closed? : () => any; + } -// http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration -interface FoundationEqualizerOptions { - use_tallest? : boolean; - equalize_on_stack? : boolean; -} + // http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration + interface EqualizerOptions { + use_tallest? : boolean; + equalize_on_stack? : boolean; + } -// http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries -interface FoundationInterchangeOptions { - load_attr? : string; - named_queries? : Object; - directives? : Object; -} + // http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries + interface InterchangeOptions { + load_attr? : string; + named_queries? : Object; + directives? : Object; + } -// http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration -interface FoundationJoyrideOptions { - expose? : boolean; - modal? : boolean; - keyboard? : boolean; - tip_location? : string; - nub_position? : string; - scroll_speed? : number; - scroll_animation? : string; - timer? : number; - start_timer_on_click? : boolean; - start_offset? : number; - next_button? : boolean; - prev_button? : boolean; - tip_animation? : string; - pause_after? : number[]; - exposed? : string[]; - tip_animation_fade_speed? : number; - cookie_monster? : boolean; - cookie_name? : string; - cookie_domain? : boolean; - cookie_expires? : number; - tip_container? : string; - tip_location_patterns? : { - top? : string[]; - bottom? : string[]; - left? : string[]; - right? : string[]; - }; - post_ride_callback? : () => void; - post_step_callback? : () => void; - pre_step_callback? : () => void; - pre_ride_callback? : () => void; - post_expose_callback? : () => void; - template? : { - link? : string; - timer? : string; - tip? : string; - wrapper? : string; - button? : string; - modal? : string; - expose? : string; - expose_cover? : string; - }; - expose_add_class? : string; -} + // http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration + interface JoyrideOptions { + expose? : boolean; + modal? : boolean; + keyboard? : boolean; + tip_location? : string; + nub_position? : string; + scroll_speed? : number; + scroll_animation? : string; + timer? : number; + start_timer_on_click? : boolean; + start_offset? : number; + next_button? : boolean; + prev_button? : boolean; + tip_animation? : string; + pause_after? : number[]; + exposed? : string[]; + tip_animation_fade_speed? : number; + cookie_monster? : boolean; + cookie_name? : string; + cookie_domain? : boolean; + cookie_expires? : number; + tip_container? : string; + tip_location_patterns? : { + top? : string[]; + bottom? : string[]; + left? : string[]; + right? : string[]; + }; + post_ride_callback? : () => void; + post_step_callback? : () => void; + pre_step_callback? : () => void; + pre_ride_callback? : () => void; + post_expose_callback? : () => void; + template? : { + link? : string; + timer? : string; + tip? : string; + wrapper? : string; + button? : string; + modal? : string; + expose? : string; + expose_cover? : string; + }; + expose_add_class? : string; + } -// http://foundation.zurb.com/docs/components/magellan.html#js -interface FoundationMagellanOptions { - active_class? : string; - threshold? : number; - destination_threshold? : number; - throttle_delay? : number; - fixed_top? : number; - offset_by_height? : boolean; - duration? : number; - easing? : string; -} + // http://foundation.zurb.com/docs/components/magellan.html#js + interface MagellanOptions { + active_class? : string; + threshold? : number; + destination_threshold? : number; + throttle_delay? : number; + fixed_top? : number; + offset_by_height? : boolean; + duration? : number; + easing? : string; + } -// http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration -interface FoundationOffCanvasOptions { - open_method? : string; - close_on_click? : boolean; -} + // http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration + interface OffCanvasOptions { + open_method? : string; + close_on_click? : boolean; + } -// http://foundation.zurb.com/docs/components/orbit.html#advanced -interface FoundationOrbitOptions { - animation? : string; - timer_speed? : number; - pause_on_hover? : boolean; - resume_on_mouseout? : boolean; - next_on_click? : boolean; - animation_speed? : number; - stack_on_small? : boolean; - navigation_arrows? : boolean; - slide_number? : boolean; - slide_number_text? : string; - container_class? : string; - stack_on_small_class? : string; - next_class? : string; - prev_class? : string; - timer_container_class? : string; - timer_paused_class? : string; - timer_progress_class? : string; - slides_container_class? : string; - preloader_class? : string; - slide_selector? : string; - bullets_container_class? : string; - bullets_active_class? : string; - slide_number_class? : string; - caption_class? : string; - active_slide_class? : string; - orbit_transition_class? : string; - bullets? : boolean; - circular? : boolean; - timer? : boolean; - variable_height? : boolean; - swipe? : boolean; - before_slide_change? : () => any; - after_slide_change? : () => any; -} + // http://foundation.zurb.com/docs/components/orbit.html#advanced + interface OrbitOptions { + animation? : string; + timer_speed? : number; + pause_on_hover? : boolean; + resume_on_mouseout? : boolean; + next_on_click? : boolean; + animation_speed? : number; + stack_on_small? : boolean; + navigation_arrows? : boolean; + slide_number? : boolean; + slide_number_text? : string; + container_class? : string; + stack_on_small_class? : string; + next_class? : string; + prev_class? : string; + timer_container_class? : string; + timer_paused_class? : string; + timer_progress_class? : string; + slides_container_class? : string; + preloader_class? : string; + slide_selector? : string; + bullets_container_class? : string; + bullets_active_class? : string; + slide_number_class? : string; + caption_class? : string; + active_slide_class? : string; + orbit_transition_class? : string; + bullets? : boolean; + circular? : boolean; + timer? : boolean; + variable_height? : boolean; + swipe? : boolean; + before_slide_change? : () => any; + after_slide_change? : () => any; + } -// http://foundation.zurb.com/docs/components/reveal.html -interface FoundationRevealCSSOptions { - opacity? : number; - visibility? : string; - display? : string; -} + // http://foundation.zurb.com/docs/components/reveal.html + interface RevealCSSOptions { + opacity? : number; + visibility? : string; + display? : string; + } -interface FoundationRevealOptions { - animation? : string; - animation_speed? : number; - close_on_background_click? : boolean; - dismiss_modal_class? : string; - multiple_opened? : boolean; - bg_class? : string; - root_element? : string; - on_ajax_error? : () => any; - open? : () => any; - opened? : () => any; - close? : () => any; - closed? : () => any; - bg? : JQuery; - css? : { - open? : FoundationRevealCSSOptions; - close? : FoundationRevealCSSOptions; - }; -} + interface RevealOptions { + animation? : string; + animation_speed? : number; + close_on_background_click? : boolean; + dismiss_modal_class? : string; + multiple_opened? : boolean; + bg_class? : string; + root_element? : string; + on_ajax_error? : () => any; + open? : () => any; + opened? : () => any; + close? : () => any; + closed? : () => any; + bg? : JQuery; + css? : { + open? : RevealCSSOptions; + close? : RevealCSSOptions; + }; + } -// http://foundation.zurb.com/docs/components/range_slider.html -interface FoundationSliderOptions { - start? : number; - end? : number; - step? : number; - precision? : number; - initial? : number; - vertical? : boolean; - trigger_input_change? : boolean; - on_change? : () => any; -} + // http://foundation.zurb.com/docs/components/range_slider.html + interface SliderOptions { + start? : number; + end? : number; + step? : number; + precision? : number; + initial? : number; + vertical? : boolean; + trigger_input_change? : boolean; + on_change? : () => any; + } -// http://foundation.zurb.com/docs/components/tabs.html -interface FoundationTabOptions { - active_class? : string; - callback? : () => any; - deep_linking? : boolean; - scroll_to_content? : boolean; - is_hover? : boolean; -} + // http://foundation.zurb.com/docs/components/tabs.html + interface TabOptions { + active_class? : string; + callback? : () => any; + deep_linking? : boolean; + scroll_to_content? : boolean; + is_hover? : boolean; + } -interface FoundationTooltipOptions { - additional_inheritable_classes? : string[]; - tooltip_class? : string; - append_to? : string; - touch_close_text? : string; - disable_for_touch? : boolean; - hover_delay? : number; - show_on? : string; - tip_template? : (selector : string, content : string) => string; -} + interface TooltipOptions { + additional_inheritable_classes? : string[]; + tooltip_class? : string; + append_to? : string; + touch_close_text? : string; + disable_for_touch? : boolean; + hover_delay? : number; + show_on? : string; + tip_template? : (selector : string, content : string) => string; + } -interface FoundationTopbarOptions { - index? : number; - sticky_class? : string; - custom_back_text? : boolean; - back_text? : string; - is_hover? : boolean; - mobile_show_parent_link? : boolean; - scrolltop? : boolean; - sticky_on? : string; -} + interface TopbarOptions { + index? : number; + sticky_class? : string; + custom_back_text? : boolean; + back_text? : string; + is_hover? : boolean; + mobile_show_parent_link? : boolean; + scrolltop? : boolean; + sticky_on? : string; + } -interface FoundationOptions { - abide? : FoundationAbideOptions; - accordion? : FoundationAccordionOptions; - alert? : FoundationAlertOptions; - clearing? : FoundationClearingOptions; - dropdown? : FoundationDropdownOptions; - equalizer? : FoundationEqualizerOptions; - interchange? : FoundationInterchangeOptions; - joyride? : FoundationJoyrideOptions; - magellan? : FoundationMagellanOptions; - offcanvas? : FoundationOffCanvasOptions; - orbit? : FoundationOrbitOptions; - reveal? : FoundationRevealOptions; - slider? : FoundationSliderOptions; - tab? : FoundationTabOptions; - tooltip? : FoundationTooltipOptions; - topbar? : FoundationTopbarOptions; -} + interface Options { + abide? : AbideOptions; + accordion? : AccordionOptions; + alert? : AlertOptions; + clearing? : ClearingOptions; + dropdown? : DropdownOptions; + equalizer? : EqualizerOptions; + interchange? : InterchangeOptions; + joyride? : JoyrideOptions; + magellan? : MagellanOptions; + offcanvas? : OffCanvasOptions; + orbit? : OrbitOptions; + reveal? : RevealOptions; + slider? : SliderOptions; + tab? : TabOptions; + tooltip? : TooltipOptions; + topbar? : TopbarOptions; + } -interface FoundationStatic { - name : string; - version : string; - media_queries : Object; - stylesheet : CSSStyleSheet; - global : { - namespace : string; - }; - init(scope : JQuery) : JQuery; - init(scope : JQuery, libraries : FoundationOptions) : JQuery; - init(scope : JQuery, libraries : string, method : FoundationOptions) : JQuery; - init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; - init_lib(lib : any, args : any) : (...args : any[]) => any; - patch(lib : any) : void; - inherit(scope : JQuery, methods : string) : void; - set_namespace() : void; - libs : any; - utils : { - S(selector : any, context : any) : JQuery; - throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; - debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; - data_options(el : JQuery) : Object; - register_media(media : string, media_class : string) : void; - add_custom_rule(rule : string, media : string) : void; - image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; - random_str(length? : number) : string; - }; + interface FoundationStatic { + name : string; + version : string; + media_queries : Object; + stylesheet : CSSStyleSheet; + global : { + namespace : string; + }; + init(scope : JQuery) : JQuery; + init(scope : JQuery, libraries : Options) : JQuery; + init(scope : JQuery, libraries : string, method : Options) : JQuery; + init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; + init_lib(lib : any, args : any) : (...args : any[]) => any; + patch(lib : any) : void; + inherit(scope : JQuery, methods : string) : void; + set_namespace() : void; + libs : any; + utils : { + S(selector : any, context : any) : JQuery; + throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; + debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; + data_options(el : JQuery) : Object; + register_media(media : string, media_class : string) : void; + add_custom_rule(rule : string, media : string) : void; + image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; + random_str(length? : number) : string; + }; + } } interface JQuery { foundation() : JQuery; - foundation(libraries : FoundationOptions | string) : JQuery; - foundation(libraries : string, method : FoundationOptions | string) : JQuery; + foundation(libraries : Foundation.Options | string) : JQuery; + foundation(libraries : string, method : Foundation.Options | string) : JQuery; foundation(libraries : string, method : string, options : Object) : JQuery; } -declare var Foundation : FoundationStatic; +declare var Foundation : Foundation.FoundationStatic; From 7600257d34baa6305ee1da58245242926960d5a8 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Mon, 30 Mar 2015 14:55:16 -0400 Subject: [PATCH 006/397] Update d3.d.ts --- d3.cloud.layout/d3.cloud.layout.d.ts | 102 +- d3/d3-tests.ts | 575 +-- d3/d3.d.ts | 6729 +++++++++++++------------- d3/plugins/d3.superformula-tests.ts | 4 +- d3/plugins/d3.superformula.d.ts | 57 +- 5 files changed, 3665 insertions(+), 3802 deletions(-) diff --git a/d3.cloud.layout/d3.cloud.layout.d.ts b/d3.cloud.layout/d3.cloud.layout.d.ts index 5ac3aced8..1e41ecbc2 100644 --- a/d3.cloud.layout/d3.cloud.layout.d.ts +++ b/d3.cloud.layout/d3.cloud.layout.d.ts @@ -5,41 +5,77 @@ /// -declare module D3 { - export module Layout { - export interface IRotate { - (number:number) : CloudLayout; - (number:()=>number) : CloudLayout; +declare module d3 { + module layout { + export function cloud(): Cloud; + export function cloud(): Cloud; + + module cloud { + interface Word { + text?: string; + font?: string; + style?: string; + weight?: string | number; + rotate?: number; + size?: number; + padding?: number; + x?: number; + y?: number; + } } + interface Cloud { + start(): Cloud; + stop(): Cloud; + timeInterval(): number; + timeInterval(interval: number): Cloud; - export interface CloudLayout { - (layers: any[], index?: number): any[]; - values(accessor?: (d: any) => any): CloudLayout; - offset(offset: string): CloudLayout; - size: { - /** - * Gets the available layout size - */ - (): Array; - /** - * Sets the available layout size - */ - (size: Array): CloudLayout; - }; - words: (inputArray: Array) => CloudLayout; - rotate:IRotate; - padding: (number:number) => CloudLayout; - font: (string:string) => CloudLayout; - fontSize(fctn: (d: any) => number): CloudLayout; - on: (eventname: string, callee: (words: any[]) => void) => CloudLayout; - start: () => CloudLayout; + words(): T[]; + words(words: T[]): Cloud; + + size(): [number, number]; + size(size: [number, number]): Cloud; + + font(): (datum: T, index: number) => string; + font(font: string): Cloud; + font(font: (datum: T, index: number) => string): Cloud; + + fontStyle(): (datum: T, index: number) => string; + fontStyle(style: string): Cloud; + fontStyle(style: (datum: T, index: number) => string): Cloud; + + fontWeight(): (datum: T, index: number) => string | number; + fontWeight(weight: string | number): Cloud; + fontWeight(weight: (datum: T, index: number) => string | number): Cloud; + + rotate(): (datum: T, index: number) => number; + rotate(rotate: number): Cloud; + rotate(rotate: (datum: T, index: number) => number): Cloud; + + text(): (datum: T, index: number) => string; + text(text: string): Cloud; + text(text: (datum: T, index: number) => string): Cloud; + + spiral(): (size: number) => (t: number) => [number, number]; + spiral(name: string): Cloud; + spiral(spiral: (size: number) => (t: number) => [number, number]): Cloud; + + fontSize(): (datum: T, index: number) => number; + fontSize(size: number): Cloud; + fontSize(size: (datum: T, index: number) => number): Cloud; + + padding(): (datum: T, index: number) => number; + padding(padding: number): Cloud; + padding(padding: (datum: T, index: number) => number): Cloud; + + on(type: "word", listener: (word: T) => void): Cloud; + on(type: "end", listener: (tags: T[], bounds: { x: number; y: number }[]) => void): Cloud; + on(type: string, listener: (...args: any[]) => void): Cloud; + + on(type: "word"): (word: T) => void; + on(type: "end"): (tags: T[], bounds: { x: number; y: number }[]) => void; + on(type: string): (...args: any[]) => void; + } } - - - export interface Layout { - cloud(): CloudLayout; - } - } -} \ No newline at end of file +} diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 51c51f608..70e4036dd 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -1,19 +1,23 @@ /// //Example from http://bl.ocks.org/3887235 +interface TestPieChartData { + population: number; + age: string; +} function testPieChart() { var width = 960, height = 500, radius = Math.min(width, height) / 2; - var color = d3.scale.ordinal() + var color = d3.scale.ordinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); - var arc = d3.svg.arc() + var arc = d3.svg.arc>() .outerRadius(radius - 10) .innerRadius(0); - var pie = d3.layout.pie() + var pie = d3.layout.pie() .sort(null) .value(function (d) { return d.population; }); @@ -23,12 +27,7 @@ function testPieChart() { .append("g") .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); - d3.csv("data.csv", function (error, data) { - - data.forEach(function (d) { - d.population = +d.population; - }); - + d3.csv("data.csv", d => ({ population: +d['population'], age: d['age'] }), function (error, data) { var g = svg.selectAll(".arc") .data(pie(data)) .enter().append("g") @@ -91,12 +90,12 @@ function groupedBarChart() { var x0 = d3.scale.ordinal() .rangeRoundBands([0, width], .1); - var x1 = d3.scale.ordinal(); + var x1 = d3.scale.ordinal(); var y = d3.scale.linear() .range([height, 0]); - var color = d3.scale.ordinal() + var color = d3.scale.ordinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); var xAxis = d3.svg.axis() @@ -114,7 +113,7 @@ function groupedBarChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.csv("data.csv", function (error, data: Array) { + d3.csv("data.csv", function (error, data: Array) { var ageNames = d3.keys(data[0]).filter(function (key) { return key !== "State"; }); data.forEach(function (d) { @@ -146,7 +145,7 @@ function groupedBarChart() { .attr("class", "g") .attr("transform", function (d) { return "translate(" + x0(d.State) + ",0)"; }); - state.selectAll("rect") + state.selectAll("rect") .data(function (d) { return d.ages; }) .enter().append("rect") .attr("width", x1.rangeBand()) @@ -189,7 +188,7 @@ function stackedBarChart() { var y = d3.scale.linear() .rangeRound([height, 0]); - var color = d3.scale.ordinal() + var color = d3.scale.ordinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); var xAxis = d3.svg.axis() @@ -207,7 +206,7 @@ function stackedBarChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.csv("data.csv", function (error, data) { + d3.csv("data.csv", function (error, data: any) { color.domain(d3.keys(data[0]).filter(function (key) { return key !== "State"; })); data.forEach(function (d) { @@ -219,7 +218,7 @@ function stackedBarChart() { data.sort(function (a, b) { return b.total - a.total; }); x.domain(data.map(function (d) { return d.State; })); - y.domain([0, d3.max(data, function (d) { return d.total; })]); + y.domain([0, d3.max(data, function (d: { total: number }) { return d.total; })]); svg.append("g") .attr("class", "x axis") @@ -240,15 +239,15 @@ function stackedBarChart() { .data(data) .enter().append("g") .attr("class", "g") - .attr("transform", function (d) { return "translate(" + x(d.State) + ",0)"; }); + .attr("transform", function (d: any) { return "translate(" + x(d.State) + ",0)"; }); state.selectAll("rect") - .data(function (d) { return d.ages; }) + .data(function (d: any) { return d.ages; }) .enter().append("rect") .attr("width", x.rangeBand()) - .attr("y", function (d) { return y(d.y1); }) - .attr("height", function (d) { return y(d.y0) - y(d.y1); }) - .style("fill", function (d) { return color(d.name); }); + .attr("y", function (d: any) { return y(d.y1); }) + .attr("height", function (d: any) { return y(d.y0) - y(d.y1); }) + .style("fill", function (d: any) { return color(d.name); }); var legend = svg.selectAll(".legend") .data(color.domain().reverse()) @@ -284,7 +283,7 @@ function normalizedBarChart() { var y = d3.scale.linear() .rangeRound([height, 0]); - var color = d3.scale.ordinal() + var color = d3.scale.ordinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); var xAxis = d3.svg.axis() @@ -328,21 +327,21 @@ function normalizedBarChart() { .data(data) .enter().append("g") .attr("class", "state") - .attr("transform", function (d) { return "translate(" + x(d.State) + ",0)"; }); + .attr("transform", function (d: any) { return "translate(" + x(d.State) + ",0)"; }); state.selectAll("rect") .data(function (d) { return d.ages; }) .enter().append("rect") .attr("width", x.rangeBand()) - .attr("y", function (d) { return y(d.y1); }) - .attr("height", function (d) { return y(d.y0) - y(d.y1); }) - .style("fill", function (d) { return color(d.name); }); + .attr("y", function (d: any) { return y(d.y1); }) + .attr("height", function (d: any) { return y(d.y0) - y(d.y1); }) + .style("fill", function (d: any) { return color(d.name); }); var legend = svg.select(".state:last-child").selectAll(".legend") - .data(function (d) { return d.ages; }) + .data(function (d: any) { return d.ages; }) .enter().append("g") .attr("class", "legend") - .attr("transform", function (d) { return "translate(" + x.rangeBand() / 2 + "," + y((d.y0 + d.y1) / 2) + ")"; }); + .attr("transform", function (d: any) { return "translate(" + x.rangeBand() / 2 + "," + y((d.y0 + d.y1) / 2) + ")"; }); legend.append("line") .attr("x2", 10); @@ -350,7 +349,7 @@ function normalizedBarChart() { legend.append("text") .attr("x", 13) .attr("dy", ".35em") - .text(function (d) { return d.name; }); + .text(function (d: any) { return d.name; }); }); } @@ -384,14 +383,14 @@ function sortablebarChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.tsv("data.tsv", function (error, data) { + d3.tsv("data.tsv", function (error, data: any) { data.forEach(function (d) { d.frequency = +d.frequency; }); x.domain(data.map(function (d) { return d.letter; })); - y.domain([0, d3.max(data, function (d) { return d.frequency; })]); + y.domain([0, d3.max(data, function (d: any) { return d.frequency; })]); svg.append("g") .attr("class", "x axis") @@ -412,10 +411,10 @@ function sortablebarChart() { .data(data) .enter().append("rect") .attr("class", "bar") - .attr("x", function (d) { return x(d.letter); }) + .attr("x", function (d: any) { return x(d.letter); }) .attr("width", x.rangeBand()) - .attr("y", function (d) { return y(d.frequency); }) - .attr("height", function (d) { return height - y(d.frequency); }); + .attr("y", function (d: any) { return y(d.frequency); }) + .attr("height", function (d: any) { return height - y(d.frequency); }); d3.select("input").on("change", change); @@ -497,8 +496,8 @@ function callenderView() { d3.csv("dji.csv", function (error, csv) { var data = d3.nest() - .key(function (d) { return d.Date; }) - .rollup(function (d) { return (d[0].Close - d[0].Open) / d[0].Open; }) + .key(function (d: any) { return d.Date; }) + .rollup(function (d: any) { return (d[0].Close - d[0].Open) / d[0].Open; }) .map(csv); rect.filter(function (d) { return d in data; }) @@ -529,7 +528,7 @@ function lineChart() { var parseDate = d3.time.format("%d-%b-%y").parse; - var x = d3.time.scale() + var x = d3.time.scale() .range([0, width]); var y = d3.scale.linear() @@ -543,7 +542,7 @@ function lineChart() { .scale(y) .orient("left"); - var line = d3.svg.line() + var line = d3.svg.line<{ date: Date; close: number }>() .x(function (d) { return x(d.date); }) .y(function (d) { return y(d.close); }); @@ -559,8 +558,8 @@ function lineChart() { d.close = +d.close; }); - x.domain(d3.extent(data, function (d) { return d.date; })); - y.domain(d3.extent(data, function (d) { return d.close; })); + x.domain(d3.extent(data, function (d: any) { return d.date; })); + y.domain(d3.extent(data, function (d: any) { return d.close; })); svg.append("g") .attr("class", "x axis") @@ -606,7 +605,7 @@ function bivariateAreaChart() { .scale(y) .orient("left"); - var area = d3.svg.area() + var area = d3.svg.area<{ date: Date; low: number; high: number }>() .x(function (d) { return x(d.date); }) .y0(function (d) { return y(d.low); }) .y1(function (d) { return y(d.high); }); @@ -617,15 +616,15 @@ function bivariateAreaChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.tsv("data.tsv", function (error, data) { + d3.tsv("data.tsv", function (error, data: any) { data.forEach(function (d) { d.date = parseDate(d.date); d.low = +d.low; d.high = +d.high; }); - x.domain(d3.extent(data, function (d) { return d.date; })); - y.domain([d3.min(data, function (d) { return d.low; }), d3.max(data, function (d) { return d.high; })]); + x.domain(d3.extent(data, function (d: any) { return d.date; })); + y.domain([d3.min(data, function (d: any) { return d.low; }), d3.max(data, function (d: any) { return d.high; })]); svg.append("path") .datum(data) @@ -673,8 +672,8 @@ function dragMultiples() { function dragmove(d) { d3.select(this) - .attr("cx", d.x = Math.max(radius, Math.min(width - radius, d3.event.x))) - .attr("cy", d.y = Math.max(radius, Math.min(height - radius, d3.event.y))); + .attr("cx", d.x = Math.max(radius, Math.min(width - radius, ( d3.event).x))) + .attr("cy", d.y = Math.max(radius, Math.min(height - radius, ( d3.event).y))); } } @@ -806,31 +805,31 @@ function populationPyramid() { .attr("dy", ".71em") .text(2000); - d3.csv("population.csv", function (error, data: Array) { + d3.csv("population.csv", function (error, rows: Array) { // Convert strings to numbers. - data.forEach(function (d) { + rows.forEach(function (d) { d.people = +d.people; d.year = +d.year; d.age = +d.age; } ); // Compute the extent of the data set in age and years. - var age1 = d3.max(data, function (d) { return d.age; } ), - year0 = d3.min(data, function (d) { return d.year; } ), - year1 = d3.max(data, function (d) { return d.year; } ), + var age1 = d3.max(rows, function (d) { return d.age; } ), + year0 = d3.min(rows, function (d) { return d.year; } ), + year1 = d3.max(rows, function (d) { return d.year; } ), year = year1; // Update the scale domains. x.domain([year1 - age1, year1]); - y.domain([0, d3.max(data, function (d) { return d.people; } )]); + y.domain([0, d3.max(rows, function (d) { return d.people; } )]); // Produce a map from year and birthyear to [male, female]. - data = d3.nest() - .key(function (d) { return d.year; } ) + var data = d3.nest() + .key(function (d) { return '' + d.year; } ) .key(function (d) { return '' + (d.year - d.age); } ) .rollup(function (v) { return v.map(function (d) { return d.people; } ); } ) - .map(data); + .map(rows); // Add an axis to show the population values. svg.append("g") @@ -849,7 +848,7 @@ function populationPyramid() { .attr("transform", function (birthyear) { return "translate(" + x(birthyear) + ",0)"; } ); birthyear.selectAll("rect") - .data(function (birthyear) { return data[year][birthyear] || [0, 0]; } ) + .data(function (birthyear): number[] { return data[year][birthyear] || [0, 0]; } ) .enter().append("rect") .attr("x", -barWidth / 2) .attr("width", barWidth) @@ -874,7 +873,7 @@ function populationPyramid() { // Allow the arrow keys to change the displayed year. window.focus(); d3.select(window).on("keydown", function () { - switch (d3.event.keyCode) { + switch (( d3.event).keyCode) { case 37: year = Math.max(year0, year - 10); break; case 39: year = Math.min(year1, year + 10); break; } @@ -890,7 +889,7 @@ function populationPyramid() { .attr("transform", "translate(" + (x(year1) - x(year)) + ",0)"); birthyear.selectAll("rect") - .data(function (birthyear) { return data[year][birthyear] || [0, 0]; } ) + .data(function (birthyear): number[] { return data[year][birthyear] || [0, 0]; } ) .transition() .duration(750) .attr("y", y) @@ -900,17 +899,31 @@ function populationPyramid() { } //Example from http://bl.ocks.org/MoritzStefaner/1377729 -function forcedBasedLabelPlacemant() { +module forcedBasedLabelPlacemant { + interface Node extends d3.layout.force.Node { + label: string; + } + + interface LabelAnchor extends d3.layout.force.Node { + node: Node; + } + + interface LabelAnchorLink extends d3.layout.force.Link { + source: Node; + target: Node; + weight: number; + } + var w = 960, h = 500; var labelDistance = 0; var vis = d3.select("body").append("svg:svg").attr("width", w).attr("height", h); - var nodes = []; - var labelAnchors = []; - var labelAnchorLinks = []; - var links = []; + var nodes: Node[] = []; + var labelAnchors: LabelAnchor[] = []; + var labelAnchorLinks: { source: number; target: number }[] = []; + var links: typeof labelAnchorLinks = []; for (var i = 0; i < 30; i++) { var nodeLabel = { @@ -941,14 +954,14 @@ function forcedBasedLabelPlacemant() { }); }; - var force = d3.layout.force().size([w, h]).nodes(nodes).links(links).gravity(1).linkDistance(50).charge(-3000).linkStrength(function (x) { + var force = d3.layout.force().size([w, h]).nodes(nodes).links(links).gravity(1).linkDistance(50).charge(-3000).linkStrength(function (x) { return x.weight * 10 } ); force.start(); - var force2 = d3.layout.force().nodes(labelAnchors).links(labelAnchorLinks).gravity(0).linkDistance(0).linkStrength(8).charge(-100).size([w, h]); + var force2 = d3.layout.force().nodes(labelAnchors).links(labelAnchorLinks).gravity(0).linkDistance(0).linkStrength(8).charge(-100).size([w, h]); force2.start(); var link = vis.selectAll("line.link").data(links).enter().append("svg:line").attr("class", "link").style("stroke", "#CCC"); @@ -1021,14 +1034,21 @@ function forcedBasedLabelPlacemant() { } //Example from http://bl.ocks.org/mbostock/1125997 -function forceCollapsable() { +module forceCollapsable { + interface Node extends d3.layout.force.Node { + id: string; + _children: Node[]; + children?: Node[]; + size: number; + } + var w = 1280, h = 800, node, link, root; - var force = d3.layout.force() + var force = d3.layout.force() .on("tick", tick) .charge(function (d) { return d._children ? -d.size / 100 : -30; } ) .linkDistance(function (d) { return d.target._children ? 80 : 30; } ) @@ -1048,7 +1068,7 @@ function forceCollapsable() { function update() { var nodes = flatten(root), - links = d3.layout.tree().links(nodes); + links = d3.layout.tree().links(nodes); // Restart the force layout. force @@ -1195,7 +1215,7 @@ function voronoiTesselation() { var width = 960, height = 500; - var vertices = >d3.range(100).map(function (d) { + var vertices = d3.range(100).map(function (d): [number, number] { return [Math.random() * width, Math.random() * height]; } ); @@ -1208,7 +1228,7 @@ function voronoiTesselation() { .attr("class", "PiYG") .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } ); - var path = svg.append("g").selectAll("path"); + var path = >svg.append("g").selectAll("path"); svg.selectAll("circle") .data(vertices.slice(1)) @@ -1234,50 +1254,50 @@ function forceDirectedVoronoi() { links = [], simulate = true, zoomToAdd = true, - color = d3.scale.quantize().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]) + color = d3.scale.quantize().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]) var numVertices = (w*h) / 3000; var vertices = d3.range(numVertices).map(function(i) { var angle = radius * (i+10); - return {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; + return {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; }); - var d3_geom_voronoi = d3.geom.voronoi() + var d3_geom_voronoi = d3.geom.voronoi<{ x: number; y: number }>() .x(function(d) { return d.x; }) .y(function(d) { return d.y; }) var prevEventScale = 1; var zoom = d3.behavior.zoom().on("zoom", function(d,i) { if (zoomToAdd){ - if (d3.event.scale > prevEventScale) { + if (( d3.event).scale > prevEventScale) { var angle = radius * vertices.length; - vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) - } else if (vertices.length > 2 && d3.event.scale != prevEventScale) { + vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) + } else if (vertices.length > 2 && ( d3.event).scale != prevEventScale) { vertices.pop(); } force.nodes(vertices).start() } else { - if (d3.event.scale > prevEventScale) { + if (( d3.event).scale > prevEventScale) { radius+= .01 } else { radius -= .01 } vertices.forEach(function(d, i) { var angle = radius * (i+10); - vertices[i] = {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; + vertices[i] = {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; }); force.nodes(vertices).start() } - prevEventScale = d3.event.scale; + prevEventScale = ( d3.event).scale; }); d3.select(window) .on("keydown", function() { // shift - if(d3.event.keyCode == 16) { + if(( d3.event).keyCode == 16) { zoomToAdd = false } // s - if(d3.event.keyCode == 83) { + if(( d3.event).keyCode == 83) { simulate = !simulate if(simulate) { force.start() @@ -1303,9 +1323,9 @@ function forceDirectedVoronoi() { force.nodes(vertices).start(); - var circle = svg.selectAll("circle"); - var path = svg.selectAll("path"); - var link = svg.selectAll("line"); + var circle = > svg.selectAll("circle"); + var path = > svg.selectAll("path"); + var link = > svg.selectAll("line"); function update() { path = path.data(d3_geom_voronoi(vertices)); @@ -1313,7 +1333,7 @@ function forceDirectedVoronoi() { // drag node by dragging cell .call(d3.behavior.drag() .on("drag", function(d, i) { - vertices[i] = {x: vertices[i].x + d3.event.dx, y: vertices[i].y + d3.event.dy} + vertices[i] = {x: vertices[i].x + ( d3.event).dx, y: vertices[i].y + ( d3.event).dy} }) ) .style("fill", function(d, i) { return color(0) }) @@ -1347,7 +1367,7 @@ function delaunayTesselation() { var width = 960, height = 500; - var vertices = >d3.range(100).map(function (d) { + var vertices = d3.range(100).map(function (d): [number, number] { return [Math.random() * width, Math.random() * height]; } ); @@ -1357,7 +1377,7 @@ function delaunayTesselation() { .attr("class", "PiYG") .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } ); - var path = svg.append("g").selectAll("path"); + var path = >svg.append("g").selectAll("path"); svg.selectAll("circle") .data(vertices.slice(1)) @@ -1379,11 +1399,13 @@ function quadtree() { var width = 960, height = 500; - var data = d3.range(5000).map(function () { - return { x: Math.random() * width, y: Math.random() * width }; - } ); + var data = d3.range(5000).map(function(): [number, number] { + return [Math.random() * width, Math.random() * width]; + }); - var quadtree = d3.geom.quadtree(data, -1, -1, width + 1, height + 1); + var quadtree = d3.geom.quadtree() + .extent([[-1, -1], [width + 1, height + 1]]) + (data); var brush = d3.svg.brush() .x(d3.scale.identity().domain([0, width])) @@ -1405,11 +1427,11 @@ function quadtree() { .attr("height", function (d) { return d.height; } ); var point = svg.selectAll(".point") - .data(data) + .data(<{ scanned?: boolean; selected?: boolean; 0: number; 1: number }[]> data) .enter().append("circle") .attr("class", "point") - .attr("cx", function (d) { return d.x; } ) - .attr("cy", function (d) { return d.y; } ) + .attr("cx", function (d) { return d[0]; } ) + .attr("cy", function (d) { return d[1]; } ) .attr("r", 4); svg.append("g") @@ -1455,7 +1477,7 @@ function convexHull() { var randomX = d3.random.normal(width / 2, 60), randomY = d3.random.normal(height / 2, 60), - vertices = d3.range(100).map(function () { return [randomX(), randomY()]; } ); + vertices = d3.range(100).map(function (): [number, number] { return [randomX(), randomY()]; } ); var svg = d3.select("body").append("svg") .attr("width", width) @@ -1470,7 +1492,7 @@ function convexHull() { var hull = svg.append("path") .attr("class", "hull"); - var circle = svg.selectAll("circle"); + var circle = > svg.selectAll("circle"); redraw(); @@ -1483,19 +1505,25 @@ function convexHull() { } // example from http://bl.ocks.org/mbostock/1044242 -function hierarchicalEdgeBundling() { +module hierarchicalEdgeBundling { + interface Result extends d3.layout.cluster.Result { + parent: Result; + size: number; + key: string; + } + var diameter = 960, radius = diameter / 2, innerRadius = radius - 120; - var cluster = d3.layout.cluster() + var cluster = d3.layout.cluster() .size([360, innerRadius]) .sort(null) .value(function (d) { return d.size; } ); - var bundle = d3.layout.bundle(); + var bundle = d3.layout.bundle(); - var line = d3.svg.line.radial() + var line = d3.svg.line.radial() .interpolate("bundle") .tension(.85) .radius(function (d) { return d.y; } ) @@ -1604,7 +1632,7 @@ function roundedRectangles() { .attr("transform", function (d, i) { return "scale(" + (1 - d / 25) * 20 + ")"; } ) .style("fill", d3.scale.category20c()); - g.map(function (d) { + var g0 = g.datum(function (d) { return { center: [0, 0], angle: 0 }; } ); @@ -1614,7 +1642,7 @@ function roundedRectangles() { d3.timer(function () { count++; - g.attr("transform", function (d, i) { + g0.attr("transform", function (d, i) { d.center[0] += (mouse[0] - d.center[0]) / (i + 5); d.center[1] += (mouse[1] - d.center[1]) / (i + 5); d.angle += Math.sin((count + i) / 10) * 7; @@ -1643,10 +1671,10 @@ function streamGraph() { .domain([0, d3.max(layers0.concat(layers1), function (layer) { return d3.max(layer, function (d) { return d.y0 + d.y; }); })]) .range([height, 0]); - var color = d3.scale.linear() + var color = d3.scale.linear() .range(["#aad", "#556"]); - var area = d3.svg.area() + var area = d3.svg.area<{ x: number; y: number; y0: number }>() .x(function (d) { return x(d.x); }) .y0(function (d) { return y(d.y0); }) .y1(function (d) { return y(d.y0 + d.y); }); @@ -1694,14 +1722,20 @@ function streamGraph() { } // example from http://mbostock.github.io/d3/talk/20111116/force-collapsible.html -function forceCollapsable2() { +module forceCollapsable2 { + interface Node extends d3.layout.force.Node { + _children: Node[]; + size: number; + id: string; + } + var w = 1280, h = 800, node, link, root; - var force = d3.layout.force() + var force = d3.layout.force() .on("tick", tick) .charge(function (d) { return d._children ? -d.size / 100 : -30; } ) .linkDistance(function (d) { return d.target._children ? 80 : 30; } ) @@ -1721,7 +1755,7 @@ function forceCollapsable2() { function update() { var nodes = flatten(root), - links = d3.layout.tree().links(nodes); + links = d3.layout.tree().links(nodes); // Restart the force layout. force @@ -1828,7 +1862,7 @@ function chordDiagram() { innerRadius = Math.min(width, height) * .41, outerRadius = innerRadius * 1.1; - var fill = d3.scale.ordinal() + var fill = d3.scale.ordinal() .domain(d3.range(4)) .range(["#000000", "#FFDD89", "#957244", "#F26223"]); @@ -1843,7 +1877,7 @@ function chordDiagram() { .enter().append("path") .style("fill", function (d) { return fill(d.index); } ) .style("stroke", function (d) { return fill(d.index); } ) - .attr("d", d3.svg.arc().innerRadius(innerRadius).outerRadius(outerRadius)) + .attr("d", d3.svg.arc().innerRadius(innerRadius).outerRadius(outerRadius)) .on("mouseover", fade(.1)) .on("mouseout", fade(1)); @@ -1876,7 +1910,7 @@ function chordDiagram() { .selectAll("path") .data(chord.chords) .enter().append("path") - .attr("d", d3.svg.chord().radius(innerRadius)) + .attr("d", d3.svg.chord().radius(innerRadius)) .style("fill", function (d) { return fill(d.target.index); } ) .style("opacity", 1); @@ -1925,14 +1959,12 @@ function irisParallel() { .attr("transform", "translate(" + m[3] + "," + m[0] + ")"); d3.csv("iris.csv", function (flowers) { + var i: number; // Create a scale and brush for each trait. traits.forEach(function (d) { - // Coerce values to numbers. - flowers.forEach(function (p) { p[d] = +p[d]; } ); - - y[d] = d3.scale.linear() - .domain(d3.extent(flowers, function (p) { return p[d]; } )) + y[d] = d3.scale.linear() + .domain(d3.extent(flowers, function (p) { return +p[d]; } )) .range([h, 0]); y[d].brush = d3.svg.brush() @@ -1963,7 +1995,7 @@ function irisParallel() { .data(flowers) .enter().append("svg:path") .attr("d", path) - .attr("class", function (d) { return d.species; } ); + .attr("class", function (d) { return d['species']; } ); // Add a group element for each trait. var g = svg.selectAll(".trait") @@ -1971,8 +2003,8 @@ function irisParallel() { .enter().append("svg:g") .attr("class", "trait") .attr("transform", function (d) { return "translate(" + x(d) + ")"; } ) - .call(d3.behavior.drag() - .origin(function (d) { return { x: x(d) }; } ) + .call(d3.behavior.drag() + .origin(function (d) { return { x: x(d), y: undefined }; } ) .on("dragstart", dragstart) .on("drag", drag) .on("dragend", dragend)); @@ -1994,12 +2026,12 @@ function irisParallel() { .attr("x", -8) .attr("width", 16); - function dragstart(d, i?) { + function dragstart(d) { i = traits.indexOf(d); } - function drag(d, i?) { - x.range()[i] = d3.event.x; + function drag(d) { + x.range()[i] = ( d3.event).x; traits.sort(function (a, b) { return x(a) - x(b); } ); g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); foreground.attr("d", path); @@ -2015,7 +2047,7 @@ function irisParallel() { // Returns the path for a given data point. function path(d) { - return line(traits.map(function (p) { return [x(p), y[p](d[p])]; } )); + return line(traits.map(function (p): [number, number] { return [x(p), y[p](d[p])]; } )); } // Handles a brush event, toggling the display of foreground lines. @@ -2098,7 +2130,7 @@ function healthAndWealth() { .text(1800); // Load the data. - d3.json("nations.json", function (nations) { + d3.json("nations.json", function (nations: any[]) { // A bisector since many nation's data is sparsely-defined. var bisect = d3.bisector(function (d) { return d[0]; } ); @@ -2219,7 +2251,7 @@ function healthAndWealth() { // Test for d3.functor function functorTest () { - var f = d3.functor(10); + var f: (n: number) => number = d3.functor(10); var g = d3.functor(function (v) { return v; }); return f(10) === g(10); @@ -2243,68 +2275,68 @@ function nestTest () { } ]; - var n1 = d3.nest() - .key(function (d) { return d.a; }) + var n1 = d3.nest<{a: number; b: number[] }>() + .key(function (d) { return String(d.a); }) .sortKeys(d3.descending) .rollup(function (vals) { - return d3.sum(vals); + return d3.sum(vals[0].b); }); n1.map(data); n1.entries(data); - var n2 = d3.nest() - .key(function (d) { return d.a; }) + var n2 = d3.nest<{ a: number; b: number[] }>() + .key(function (d) { return String(d.a); }) .sortValues(function (x1, x2) { return x1[0] < x1[1] ? -1 : (x1[0] > x1[0] ? 1 : 0); }); n2.map(data); n2.entries(data); // Tests adopted from d3's tests. - var keys = d3.nest() - .key(function(d) { return d.foo; }) + var keys = d3.nest<{ foo: number; }>() + .key(function(d) { return String(d.foo); }) .entries([{foo: 1}, {foo: 1}, {foo: 2}]) .map(function(d) { return d.key; }) .sort(d3.ascending); - var entries = d3.nest() - .key(function(d) { return d.foo; }) + var entries = d3.nest<{foo: number; bar?: number}>() + .key(function(d) { return String(d.foo); }) .entries([{foo: 1, bar: 0}, {foo: 2}, {foo: 1, bar: 1}]); - keys = d3.nest() - .key(function(d) { return d.foo; }).sortKeys(d3.descending) + keys = d3.nest<{foo: number}>() + .key(function(d) { return String(d.foo); }).sortKeys(d3.descending) .entries([{foo: 1}, {foo: 1}, {foo: 2}]) .map(function(d) { return d.key; }); - entries = d3.nest() - .key(function(d) { return d.foo; }) + entries = d3.nest<{ foo: number; bar?: number }>() + .key(function(d) { return String(d.foo); }) .sortValues(function(a, b) { return a.bar - b.bar; }) .entries([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]); - entries = d3.nest() - .key(function(d) { return d.foo; }) + entries = d3.nest<{ foo: number; bar?: number }>() + .key(function(d) { return String(d.foo); }) .rollup(function(values) { return d3.sum(values, function(d) { return d.bar; }); }) .entries([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]); - entries = d3.nest() - .key(function(d) { return d[0]; }).sortKeys(d3.ascending) - .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + entries = d3.nest<[number, number]>() + .key(function(d) { return String(d[0]); }).sortKeys(d3.ascending) + .key(function(d) { return String(d[1]); }).sortKeys(d3.ascending) .entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]); - entries = d3.nest() - .key(function(d) { return d[0]; }).sortKeys(d3.ascending) - .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + entries = d3.nest<[number, number]>() + .key(function(d) { return String(d[0]); }).sortKeys(d3.ascending) + .key(function(d) { return String(d[1]); }).sortKeys(d3.ascending) .rollup(function(values) { return values.length; }) .entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]); - entries = d3.nest() - .key(function(d) { return d[0]; }).sortKeys(d3.ascending) - .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + entries = d3.nest<{ 0: number; 1: number; 2?: number }>() + .key(function(d) { return String(d[0]); }).sortKeys(d3.ascending) + .key(function(d) { return String(d[1]); }).sortKeys(d3.ascending) .sortValues(function(a, b) { return a[2] - b[2]; }) .entries([[0, 1], [0, 2, 1], [1, 1], [1, 2], [0, 2, 0]]); - var map = d3.nest() - .key(function(d) { return d[0]; }).sortKeys(d3.ascending) - .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + var map = d3.nest<{ 0: number; 1: number; 2?: number }>() + .key(function(d) { return String(d[0]); }).sortKeys(d3.ascending) + .key(function(d) { return String(d[1]); }).sortKeys(d3.ascending) .sortValues(function(a, b) { return a[2] - b[2]; }) .map([[0, 1], [0, 2, 1], [1, 1], [1, 2], [0, 2, 0]]); } @@ -2344,7 +2376,7 @@ function brushTest() { var brush1 = d3.svg.brush() .x(xScale) .on('brush', function () { - var extent = brush1.extent(); + var extent = <[number, number]> brush1.extent(); xMin = Math.max(extent[0], 0); xMax = Math.min(extent[1], 1); brush1.extent([xMin, xMax]); @@ -2373,186 +2405,155 @@ function brushTest() { // Tests for area // Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/area-test.js function svgAreaTest () { - var a = d3.svg.area(); + var a = d3.svg.area(), + f: () => number, + n: number; - a.x()([0, 1]); - a.x()([0, 1], 1); + a.x(f).x() === f; + a.x(n).x() === n; a.x(0); - a.x(function (d) { return d.x * 10; }); + a.x(function (d) { return d[0] * 10; }); a.x(function (d, i) { return i * 10; }); - a.x0()([0, 1]); - a.x0()([0, 1], 1); + a.x(f).x0() === f; + a.x(n).x0() === n; a.x0(0); - a.x0(function (d) { return d.x * 10; }); + a.x0(function (d) { return d[0] * 10; }); a.x0(function (d, i) { return i * 10; }); - a.x1()([0, 1]); - a.x1()([0, 1], 1); + a.x(f).x1() === f; + a.x(n).x1() === n; a.x1(0); - a.x1(function (d) { return d.x * 10; }); + a.x1(function (d) { return d[0] * 10; }); a.x1(function (d, i) { return i * 10; }); - a.y()([0, 1]); - a.y()([0, 1], 1); + a.y(f).y() === f; + a.y(n).y() === n; a.y(0); - a.y(function (d) { return d.x * 10; }); + a.y(function (d) { return d[0] * 10; }); a.y(function (d, i) { return i * 10; }); - a.y0()([0, 1]); - a.y0()([0, 1], 1); + a.y(f).y0() === f; + a.y(n).y0() === n; a.y0(0); - a.y0(function (d) { return d.x * 10; }); + a.y0(function (d) { return d[0] * 10; }); a.y0(function (d, i) { return i * 10; }); - a.y1()([0, 1]); - a.y1()([0, 1], 1); + a.y(f).y1() === f; + a.y(n).y1() === n; a.y1(0); - a.y1(function (d) { return d.x * 10; }); + a.y1(function (d) { return d[0] * 10; }); a.y1(function (d, i) { return i * 10; }); } // Tests for areaRadial // Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/area-radial-test.js function svgAreaRadialTest () { - var a = d3.svg.area.radial(); + var a = d3.svg.area.radial(), + f: () => number, + n: number; - a.x()([0, 1]); - a.x()([0, 1], 1); - a.x(0); - a.x(function (d) { return d.x * 10; }); - a.x(function (d, i) { return i * 10; }); - - a.x0()([0, 1]); - a.x0()([0, 1], 1); - a.x0(0); - a.x0(function (d) { return d.x * 10; }); - a.x0(function (d, i) { return i * 10; }); - - a.x1()([0, 1]); - a.x1()([0, 1], 1); - a.x1(0); - a.x1(function (d) { return d.x * 10; }); - a.x1(function (d, i) { return i * 10; }); - - a.y()([0, 1]); - a.y()([0, 1], 1); - a.y(0); - a.y(function (d) { return d.x * 10; }); - a.y(function (d, i) { return i * 10; }); - - a.y0()([0, 1]); - a.y0()([0, 1], 1); - a.y0(0); - a.y0(function (d) { return d.x * 10; }); - a.y0(function (d, i) { return i * 10; }); - - a.y1()([0, 1]); - a.y1()([0, 1], 1); - a.y1(0); - a.y1(function (d) { return d.x * 10; }); - a.y1(function (d, i) { return i * 10; }); - - a.radius(function () { return 10; }); - a.radius(function (d) { return d.x * 10; }); + a.radius(f).radius() === f; + a.radius(n).radius() === n; + a.radius(0); + a.radius(function (d) { return d[0] * 10; }); a.radius(function (d, i) { return i * 10; }); - a.innerRadius(function () { return 10; }); - a.innerRadius(function (d) { return d.x * 10; }); + a.radius(f).innerRadius() === f; + a.radius(n).innerRadius() === n; + a.innerRadius(0); + a.innerRadius(function (d) { return d[0] * 10; }); a.innerRadius(function (d, i) { return i * 10; }); - a.outerRadius(function () { return 10; }); - a.outerRadius(function (d) { return d.x * 10; }); + a.radius(f).outerRadius() === f; + a.radius(n).outerRadius() === n; + a.outerRadius(0); + a.outerRadius(function (d) { return d[1] * 10; }); a.outerRadius(function (d, i) { return i * 10; }); - a.angle(function () { return 10; }); - a.angle(function (d) { return d.x * 10; }); + a.angle(f).angle() === f; + a.angle(n).angle() === n; + a.angle(0); + a.angle(function (d) { return d[0] * 10; }); a.angle(function (d, i) { return i * 10; }); - a.startAngle(function () { return 10; }); - a.startAngle(function (d) { return d.x * 10; }); + a.angle(f).startAngle() === f; + a.angle(n).startAngle() === n; + a.startAngle(0); + a.startAngle(function (d) { return d[0] * 10; }); a.startAngle(function (d, i) { return i * 10; }); - a.endAngle(function () { return 10; }); - a.endAngle(function (d) { return d.x * 10; }); + a.angle(f).endAngle() === f; + a.angle(n).endAngle() === n; + a.endAngle(0); + a.endAngle(function (d) { return d[1] * 10; }); a.endAngle(function (d, i) { return i * 10; }); } // Tests for d3.svg.line // Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/line-test.js function svgLineTest () { - var l = d3.svg.line(); + var l = d3.svg.line(), + f: () => number, + n: number; - l.x()([0, 1]); - l.x()([0, 1], 0); + l.x(f).x() === f; + l.x(n).x() === n; l.x(0); - l.x(function (d) { return d.x; }); + l.x(function (d) { return d[0]; }); l.x(function (d, i) { return i; }); - l.y()([0, 1]); - l.y()([0, 1], 0); + l.y(f).y() === f; + l.y(n).y() === n; l.y(0); - l.y(function (d) { return d.y; }); + l.y(function (d) { return d[1]; }); l.y(function (d, i) { return i; }); } // Tests for d3.svg.line.radial // Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/line-radial-test.js function svgLineRadialTest () { - var l = d3.svg.line.radial(); + var l = d3.svg.line.radial(), + f: () => number, + n: number; - l.x()([0, 1]); - l.x()([0, 1], 0); - l.x(0); - l.x(function (d) { return d.x; }); - l.x(function (d, i) { return i; }); - - l.y()([0, 1]); - l.y()([0, 1], 0); - l.y(0); - l.y(function (d) { return d.y; }); - l.y(function (d, i) { return i; }); - - l.radius()([0, 1]); - l.radius()([0, 1], 0); + l.radius(f).radius() === f; + l.radius(n).radius() === n; l.radius(0); - l.radius(function (d) { return d.x; }); + l.radius(function (d) { return d[0]; }); l.radius(function (d, i) { return i; }); - l.angle()([0, 1]); - l.angle()([0, 1], 0); + l.angle(f).angle() === f; + l.angle(n).angle() === n; l.angle(0); - l.angle(function (d) { return d.y; }); + l.angle(function (d) { return d[1]; }); l.angle(function (d, i) { return i; }); } // Tests for d3.svg.arc // Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/arc-test.js function svgArcTest () { - var l = d3.svg.arc(); + var l = d3.svg.arc(), + f: () => number; - l.innerRadius()([0, 1]); - l.innerRadius()([0, 1], 0); + l.innerRadius(f).innerRadius() === f; l.innerRadius(0); - l.innerRadius(function (d) { return d.x; }); + l.innerRadius(function (d) { return d[0]; }); l.innerRadius(function (d, i) { return i; }); - l.outerRadius()([0, 1]); - l.outerRadius()([0, 1], 0); + l.outerRadius(f).outerRadius() === f; l.outerRadius(0); - l.outerRadius(function (d) { return d.x; }); + l.outerRadius(function (d) { return d[1]; }); l.outerRadius(function (d, i) { return i; }); - l.startAngle()([0, 1]); - l.startAngle()([0, 1], 0); + l.startAngle(f).startAngle() === f; l.startAngle(0); - l.startAngle(function (d) { return d.x; }); + l.startAngle(function (d) { return d[0]; }); l.startAngle(function (d, i) { return i; }); - l.endAngle()([0, 1]); - l.endAngle()([0, 1], 0); + l.endAngle(f).endAngle() === f; l.endAngle(0); - l.endAngle(function (d) { return d.x; }); + l.endAngle(function (d) { return d[1]; }); l.endAngle(function (d, i) { return i; }); } @@ -2561,28 +2562,28 @@ function svgArcTest () { function svgDiagonalTest () { var d = d3.svg.diagonal(); - d.projection()({ x: 0, y: 1}); d.projection()({ x: 0, y: 1}, 0); d.projection(function (d) { return [d.x, d.y]; }); d.projection(function (d, i) { return [i, i + 1]; }); - d.source()({x: 0, y: 1}); - d.source()({x: 0, y: 1}, 0); + d.source()({ source: {x: 0, y: 1}, target: null }, 0); d.source({x: 0, y: 1}); - d.source(function (d) { return {x: d.x, y: d.y}; }); - d.source(function (d, i) { return {x: d.x * i, y: d.y * i}; }); + d.source(function (d) { return {x: d.source.x, y: d.source.y}; }); + d.source(function (d, i) { return {x: d.source.x * i, y: d.source.y * i}; }); - d.target()({x: 0, y: 1}); - d.target()({x: 0, y: 1}, 0); + d.target()({ target: {x: 0, y: 1}, source: null }, 0); d.target({x: 0, y: 1}); - d.target(function (d) { return {x: d.x, y: d.y}; }); - d.target(function (d, i) { return {x: d.x * i, y: d.y * i}; }); + d.target(function (d) { return {x: d.target.x, y: d.target.y}; }); + d.target(function (d, i) { return {x: d.target.x * i, y: d.target.y * i}; }); } // Tests for d3.extent // Adopted from: https://github.com/mbostock/d3/blob/master/test/arrays/extent-test.js function extentTest() { + // usages of `o' suppressed as well as mixed-type comparisons + // see https://github.com/Microsoft/TypeScript/commit/c0db7ffe8f55b6ec335880482ca43b93b066689d var o = { valueOf: function () { return NaN; } }; + d3.extent([1]); d3.extent([5, 1, 2, 3, 4]); d3.extent([20, 3]); @@ -2591,15 +2592,15 @@ function extentTest() { d3.extent(["20", "3"]); d3.extent(["3", "20"]); d3.extent([NaN, 1, 2, 3, 4, 5]); - d3.extent([o, 1, 2, 3, 4, 5]); + // d3.extent([o, 1, 2, 3, 4, 5]); d3.extent([1, 2, 3, 4, 5, NaN]); - d3.extent([1, 2, 3, 4, 5, o]); + // d3.extent([1, 2, 3, 4, 5, o]); d3.extent([10, null, 3, undefined, 5, NaN]); d3.extent([-1, null, -3, undefined, -5, NaN]); - d3.extent([20, "3"]); - d3.extent(["20", 3]); - d3.extent([3, "20"]); - d3.extent(["3", 20]); + // d3.extent([20, "3"]); + // d3.extent(["20", 3]); + // d3.extent([3, "20"]); + // d3.extent(["3", 20]); d3.extent([1], (d) => { return d; }); d3.extent([5, 1, 2, 3, 4], (d) => { return d; }); @@ -2609,28 +2610,28 @@ function extentTest() { d3.extent(["20", "3"], (d) => { return d; }); d3.extent(["3", "20"], (d) => { return d; }); d3.extent([NaN, 1, 2, 3, 4, 5], (d) => { return d; }); - d3.extent([o, 1, 2, 3, 4, 5], (d) => { return d; }); + // d3.extent([o, 1, 2, 3, 4, 5], (d) => { return d; }); d3.extent([1, 2, 3, 4, 5, NaN], (d) => { return d; }); - d3.extent([1, 2, 3, 4, 5, o], (d) => { return d; }); + // d3.extent([1, 2, 3, 4, 5, o], (d) => { return d; }); d3.extent([10, null, 3, undefined, 5, NaN], (d) => { return d; }); d3.extent([-1, null, -3, undefined, -5, NaN], (d) => { return d; }); - d3.extent([20, "3"], (d) => { return d; }); - d3.extent(["20", 3], (d) => { return d; }); - d3.extent([3, "20"], (d) => { return d; }); - d3.extent(["3", 20], (d) => { return d; }); + // d3.extent([20, "3"], (d) => { return d; }); + // d3.extent(["20", 3], (d) => { return d; }); + // d3.extent([3, "20"], (d) => { return d; }); + // d3.extent(["3", 20], (d) => { return d; }); } // Tests for d3.time.format.multi // Adopted from http://bl.ocks.org/mbostock/4149176 function multiTest() { var customTimeFormat = d3.time.format.multi([ - [".%L", function(d) { return d.getMilliseconds(); }], - [":%S", function(d) { return d.getSeconds(); }], - ["%I:%M", function(d) { return d.getMinutes(); }], - ["%I %p", function(d) { return d.getHours(); }], - ["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }], + [".%L", function(d) { return !!d.getMilliseconds(); }], + [":%S", function(d) { return !!d.getSeconds(); }], + ["%I:%M", function(d) { return !!d.getMinutes(); }], + ["%I %p", function(d) { return !!d.getHours(); }], + ["%a %d", function(d) { return !!d.getDay() && d.getDate() != 1; }], ["%b %d", function(d) { return d.getDate() != 1; }], - ["%B", function(d) { return d.getMonth(); }], + ["%B", function(d) { return !!d.getMonth(); }], ["%Y", function() { return true; }] ]); @@ -2656,4 +2657,4 @@ function multiTest() { .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); -} \ No newline at end of file +} diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 57e817818..dddef751b 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1,3451 +1,3278 @@ -// Type definitions for d3JS -// Project: http://d3js.org/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module D3 { - export interface Selectors { - /** - * Select an element from the current document - */ - select: { - /** - * Returns the empty selection - */ - (): Selection; - /** - * Selects the first element that matches the specified selector string - * - * @param selector Selection String to match - */ - (selector: string): Selection; - /** - * Selects the specified node - * - * @param element Node element to select - */ - (element: EventTarget): Selection; - }; - - /** - * Select multiple elements from the current document - */ - selectAll: { - /** - * Selects all elements that match the specified selector - * - * @param selector Selection String to match - */ - (selector: string): Selection; - /** - * Selects the specified array of elements - * - * @param elements Array of node elements to select - */ - (elements: EventTarget[]): Selection; - }; - } - - export interface D3Event extends Event{ - dx: number; - dy: number; - clientX: number; - clientY: number; - translate: number[]; - scale: number; - sourceEvent: D3Event; - x: number; - y: number; - keyCode: number; - altKey: any; - type: string; - } - - export interface Base extends Selectors { - /** - * Create a behavior - */ - behavior: Behavior.Behavior; - /** - * Access the current user event for interaction - */ - event: D3Event; - - /** - * Compare two values for sorting. - * Returns -1 if a is less than b, or 1 if a is greater than b, or 0 - * - * @param a First value - * @param b Second value - */ - ascending(a: T, b: T): number; - /** - * Compare two values for sorting. - * Returns -1 if a is greater than b, or 1 if a is less than b, or 0 - * - * @param a First value - * @param b Second value - */ - descending(a: T, b: T): number; - /** - * Find the minimum value in an array - * - * @param arr Array to search - * @param map Accsessor function - */ - min(arr: T[], map: (v?: T, i?: number) => U): U; - /** - * Find the minimum value in an array - * - * @param arr Array to search - */ - min(arr: T[]): T; - /** - * Find the maximum value in an array - * - * @param arr Array to search - * @param map Accsessor function - */ - max(arr: T[], map: (v?: T, i?: number) => U): U; - /** - * Find the maximum value in an array - * - * @param arr Array to search - */ - max(arr: T[]): T; - /** - * Find the minimum and maximum value in an array - * - * @param arr Array to search - * @param map Accsessor function - */ - extent(arr: T[], map: (v: T) => U): U[]; - /** - * Find the minimum and maximum value in an array - * - * @param arr Array to search - */ - extent(arr: T[]): T[]; - /** - * Compute the sum of an array of numbers - * - * @param arr Array to search - * @param map Accsessor function - */ - sum(arr: T[], map: (v: T) => number): number; - /** - * Compute the sum of an array of numbers - * - * @param arr Array to search - */ - sum(arr: number[]): number; - /** - * Compute the arithmetic mean of an array of numbers - * - * @param arr Array to search - * @param map Accsessor function - */ - mean(arr: T[], map: (v: T) => number): number; - /** - * Compute the arithmetic mean of an array of numbers - * - * @param arr Array to search - */ - mean(arr: number[]): number; - /** - * Compute the median of an array of numbers (the 0.5-quantile). - * - * @param arr Array to search - * @param map Accsessor function - */ - median(arr: T[], map: (v: T) => number): number; - /** - * Compute the median of an array of numbers (the 0.5-quantile). - * - * @param arr Array to search - */ - median(arr: number[]): number; - /** - * Compute a quantile for a sorted array of numbers. - * - * @param arr Array to search - * @param p The quantile to return - */ - quantile: (arr: number[], p: number) => number; - /** - * Locate the insertion point for x in array to maintain sorted order - * - * @param arr Array to search - * @param x Value to search for insertion point - * @param low Minimum value of array subset - * @param hihg Maximum value of array subset - */ - bisect(arr: T[], x: T, low?: number, high?: number): number; - /** - * Locate the insertion point for x in array to maintain sorted order - * - * @param arr Array to search - * @param x Value to serch for insertion point - * @param low Minimum value of array subset - * @param high Maximum value of array subset - */ - bisectLeft(arr: T[], x: T, low?: number, high?: number): number; - /** - * Locate the insertion point for x in array to maintain sorted order - * - * @param arr Array to search - * @param x Value to serch for insertion point - * @param low Minimum value of array subset - * @param high Maximum value of array subset - */ - bisectRight(arr: T[], x: T, low?: number, high?: number): number; - /** - * Bisect using an accessor. - * - * @param accessor Accessor function - */ - bisector(accessor: (data: any, index: number) => any): any; - /** - * Randomize the order of an array. - * - * @param arr Array to randomize - */ - shuffle(arr: T[]): T[]; - /** - * Reorder an array of elements according to an array of indexes - * - * @param arr Array to reorder - * @param indexes Array containing the order the elements should be returned in - */ - permute(arr: any[], indexes: any[]): any[]; - /** - * Transpose a variable number of arrays. - * - * @param arrs Arrays to transpose - */ - zip(...arrs: any[]): any[]; - /** - * Parse the given 2D affine transform string, as defined by SVG's transform attribute. - * - * @param definition 2D affine transform string - */ - transform(definition: string): any; - /** - * Transpose an array of arrays. - * - * @param matrix Two dimensional array to transpose - */ - transpose(matrix: any[]): any[]; - /** - * Creates an array containing tuples of adjacent pairs - * - * @param arr An array containing entries to pair - * @returns any[][] An array of 2-element tuples for each pair - */ - pairs(arr: any[]): any[][]; - /** - * List the keys of an associative array. - * - * @param map Array of objects to get the key values from - */ - keys(map: any): string[]; - /** - * List the values of an associative array. - * - * @param map Array of objects to get the values from - */ - values(map: any): any[]; - /** - * List the key-value entries of an associative array. - * - * @param map Array of objects to get the key-value pairs from - */ - entries(map: any): any[]; - /** - * merge multiple arrays into one array - * - * @param map Arrays to merge - */ - merge(...map: any[]): any[]; - /** - * Generate a range of numeric values. - */ - range: { - /** - * Generate a range of numeric values from 0. - * - * @param stop Value to generate the range to - * @param step Step between each value - */ - (stop: number, step?: number): number[]; - /** - * Generate a range of numeric values. - * - * @param start Value to start - * @param stop Value to generate the range to - * @param step Step between each value - */ - (start: number, stop?: number, step?: number): number[]; - }; - /** - * Create new nest operator - */ - nest(): Nest; - /** - * Request a resource using XMLHttpRequest. - */ - xhr: { - /** - * Creates an asynchronous request for specified url - * - * @param url Url to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr; - /** - * Creates an asynchronous request for specified url - * - * @param url Url to request - * @param mime MIME type to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, mime: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr; - }; - /** - * Request a text file - */ - text: { - /** - * Request a text file - * - * @param url Url to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, callback?: (response: string) => void ): Xhr; - /** - * Request a text file - * - * @param url Url to request - * @param mime MIME type to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, mime: string, callback?: (response: string) => void ): Xhr; - }; - /** - * Request a JSON blob - * - * @param url Url to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - json: (url: string, callback?: (error: any, data: any) => void ) => Xhr; - /** - * Request an HTML document fragment. - */ - xml: { - /** - * Request an HTML document fragment. - * - * @param url Url to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, callback?: (response: Document) => void ): Xhr; - /** - * Request an HTML document fragment. - * - * @param url Url to request - * @param mime MIME type to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, mime: string, callback?: (response: Document) => void ): Xhr; - }; - /** - * Request an XML document fragment. - * - * @param url Url to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - html: (url: string, callback?: (response: DocumentFragment) => void ) => Xhr; - /** - * Request a comma-separated values (CSV) file. - */ - csv: Dsv; - /** - * Request a tab-separated values (TSV) file - */ - tsv: Dsv; - /** - * Time Functions - */ - time: Time.Time; - /** - * Scales - */ - scale: Scale.ScaleBase; - /* - * Interpolate two values - */ - interpolate: Transition.BaseInterpolate; - /* - * Interpolate two numbers - */ - interpolateNumber: Transition.BaseInterpolate; - /* - * Interpolate two integers - */ - interpolateRound: Transition.BaseInterpolate; - /* - * Interpolate two strings - */ - interpolateString: Transition.BaseInterpolate; - /* - * Interpolate two RGB colors - */ - interpolateRgb: Transition.BaseInterpolate; - /* - * Interpolate two HSL colors - */ - interpolateHsl: Transition.BaseInterpolate; - /* - * Interpolate two HCL colors - */ - interpolateHcl: Transition.BaseInterpolate; - /* - * Interpolate two L*a*b* colors - */ - interpolateLab: Transition.BaseInterpolate; - /* - * Interpolate two arrays of values - */ - interpolateArray: Transition.BaseInterpolate; - /* - * Interpolate two arbitary objects - */ - interpolateObject: Transition.BaseInterpolate; - /* - * Interpolate two 2D matrix transforms - */ - interpolateTransform: Transition.BaseInterpolate; - /* - * The array of built-in interpolator factories - */ - interpolators: Transition.InterpolateFactory[]; - /** - * Layouts - */ - layout: Layout.Layout; - /** - * Svg's - */ - svg: Svg.Svg; - /** - * Random number generators - */ - random: Random; - /** - * Create a function to format a number as a string - * - * @param specifier The format specifier to use - */ - format(specifier: string): (value: number) => string; - /** - * Returns the SI prefix for the specified value at the specified precision - */ - formatPrefix(value: number, precision?: number): MetricPrefix; - /** - * The version of the d3 library - */ - version: string; - /** - * Returns the root selection - */ - selection(): Selection; - ns: { - /** - * The map of registered namespace prefixes - */ - prefix: { - svg: string; - xhtml: string; - xlink: string; - xml: string; - xmlns: string; - }; - /** - * Qualifies the specified name - */ - qualify(name: string): { space: string; local: string; }; - }; - /** - * Returns a built-in easing function of the specified type - */ - ease: (type: string, ...arrs: any[]) => D3.Transition.Transition; - /** - * Constructs a new RGB color. - */ - rgb: { - /** - * Constructs a new RGB color with the specified r, g and b channel values - */ - (r: number, g: number, b: number): D3.Color.RGBColor; - /** - * Constructs a new RGB color by parsing the specified color string - */ - (color: string): D3.Color.RGBColor; - }; - /** - * Constructs a new HCL color. - */ - hcl: { - /** - * Constructs a new HCL color. - */ - (h: number, c: number, l: number): Color.HCLColor; - /** - * Constructs a new HCL color by parsing the specified color string - */ - (color: string): Color.HCLColor; - }; - /** - * Constructs a new HSL color. - */ - hsl: { - /** - * Constructs a new HSL color with the specified hue h, saturation s and lightness l - */ - (h: number, s: number, l: number): Color.HSLColor; - /** - * Constructs a new HSL color by parsing the specified color string - */ - (color: string): Color.HSLColor; - }; - /** - * Constructs a new RGB color. - */ - lab: { - /** - * Constructs a new LAB color. - */ - (l: number, a: number, b: number): Color.LABColor; - /** - * Constructs a new LAB color by parsing the specified color string - */ - (color: string): Color.LABColor; - }; - geo: Geo.Geo; - geom: Geom.Geom; - /** - * gets the mouse position relative to a specified container. - */ - mouse(container: any): number[]; - /** - * gets the touch positions relative to a specified container. - */ - touches(container: any): number[][]; - - /** - * If the specified value is a function, returns the specified value. - * Otherwise, returns a function that returns the specified value. - */ - functor(value: (p : R) => T): (p : R) => T; - functor(value: T): (p : any) => T; - - map: { - (): Map; - (object: {[key: string]: T; }): Map; - (map: Map): Map; - (array: T[]): Map; - (array: T[], keyFn: (object: T, index?: number) => string): Map; - }; - set: { - (): Set; - (array: T[]): Set; - }; - dispatch(...types: string[]): Dispatch; - rebind(target: any, source: any, ...names: any[]): any; - requote(str: string): string; - timer: { - (funct: () => boolean, delay?: number, mark?: number): void; - flush(): void; - } - transition(): Transition.Transition; - - round(x: number, n: number): number; - } - - export interface Dispatch { - [event: string]: any; - on: { - (type: string): any; - (type: string, listener: any): any; - } - } - - export interface MetricPrefix { - /** - * the scale function, for converting numbers to the appropriate prefixed scale. - */ - scale: (d: number) => number; - /** - * the prefix symbol - */ - symbol: string; - } - - export interface Xhr { - /** - * Get or set request header - */ - header: { - /** - * Get the value of specified request header - * - * @param name Name of header to get the value for - */ - (name: string): string; - /** - * Set the value of specified request header - * - * @param name Name of header to set the value for - * @param value Value to set the header to - */ - (name: string, value: string): Xhr; - }; - /** - * Get or set MIME Type - */ - mimeType: { - /** - * Get the current MIME Type - */ - (): string; - /** - * Set the MIME Type for the request - * - * @param type The MIME type for the request - */ - (type: string): Xhr; - }; - /* - * Get or Set the function used to map the response to the associated data value - */ - response: { - /** - * Get function used to map the response to the associated data value - */ - (): (xhr: XMLHttpRequest) => any; - /** - * Set function used to map the response to the associated data value - * - * @param value The function used to map the response to a data value - */ - (value: (xhr: XMLHttpRequest) => any): Xhr; - }; - /** - * Issue the request using the GET method - * - * @param callback Function to invoke on completion of request - */ - get(callback?: (xhr: XMLHttpRequest) => void ): Xhr; - /** - * Issue the request using the POST method - */ - post: { - /** - * Issue the request using the POST method - * - * @param callback Function to invoke on completion of request - */ - (callback?: (xhr: XMLHttpRequest) => void ): Xhr; - /** - * Issue the request using the POST method - * - * @param data Data to post back in the request - * @param callback Function to invoke on completion of request - */ - (data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr; - }; - /** - * Issues this request using the specified method - */ - send: { - /** - * Issues this request using the specified method - * - * @param method Method to use to make the request - * @param callback Function to invoke on completion of request - */ - (method: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr; - /** - * Issues this request using the specified method - * - * @param method Method to use to make the request - * @param data Data to post back in the request - * @param callback Function to invoke on completion of request - */ - (method: string, data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr; - }; - /** - * Aborts this request, if it is currently in-flight - */ - abort(): Xhr; - /** - * Registers a listener to receive events - * - * @param type Enent name to attach the listener to - * @param listener Function to attach to event - */ - on: (type: string, listener: (data: any, index?: number) => any) => Xhr; - } - - export interface Dsv { - /** - * Request a delimited values file - * - * @param url Url to request - * @param callback Function to invoke when resource is loaded or the request fails - */ - (url: string, callback?: (error: any, response: any[]) => void ): Xhr; - /** - * Parse a delimited string into objects using the header row. - * - * @param string delimited formatted string to parse - * @param accessor to modify properties of each row - */ - parse(string: string, accessor?: (row: any, index?: number) => any): any[]; - /** - * Parse a delimited string into tuples, ignoring the header row. - * - * @param string delimited formatted string to parse - */ - parseRows(string: string, accessor: (row: any[], index: number) => any): any; - /** - * Format an array of tuples into a delimited string. - * - * @param rows Array to convert to a delimited string - */ - format(rows: any[]): string; - } - - export interface Selection extends Selectors, Array { - attr: { - (name: string): string; - (name: string, value: any): Selection; - (name: string, valueFunction: (data: any, index: number) => any): Selection; - (attrValueMap : Object): Selection; - }; - - classed: { - (name: string): boolean; - (name: string, value: any): Selection; - (name: string, valueFunction: (data: any, index: number) => any): Selection; - (classValueMap: Object): Selection; - }; - - style: { - (name: string): string; - (name: string, value: any, priority?: string): Selection; - (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection; - (styleValueMap : Object): Selection; - }; - - property: { - (name: string): void; - (name: string, value: any): Selection; - (name: string, valueFunction: (data: any, index: number) => any): Selection; - (propertyValueMap : Object): Selection; - }; - - text: { - (): string; - (value: any): Selection; - (valueFunction: (data: any, index: number) => any): Selection; - }; - - html: { - (): string; - (value: any): Selection; - (valueFunction: (data: any, index: number) => any): Selection; - }; - - append: (name: string) => Selection; - insert: (name: string, before: string) => Selection; - remove: () => Selection; - empty: () => boolean; - - data: { - (values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => any): UpdateSelection; - (values: any[], key?: (data: any, index?: number) => any): UpdateSelection; - (): any[]; - }; - - datum: { - /** - * Sets the element's bound data to the return value of the specified function evaluated - * for each selected element. - * Unlike the D3.Selection.data method, this method does not compute a join (and thus - * does not compute enter and exit selections). - * @param values The function to be evaluated for each selected element, being passed the - * previous datum d and the current index i, with the this context as the current DOM - * element. The function is then used to set each element's data. A null value will - * delete the bound data. This operator has no effect on the index. - */ - (values: (data: any, index: number) => any): UpdateSelection; - /** - * Sets the element's bound data to the specified value on all selected elements. - * Unlike the D3.Selection.data method, this method does not compute a join (and thus - * does not compute enter and exit selections). - * @param values The same data to be given to all elements. - */ - (values: any): UpdateSelection; - /** - * Returns the bound datum for the first non-null element in the selection. - * This is generally useful only if you know the selection contains exactly one element. - */ - (): any; - /** - * Returns the bound datum for the first non-null element in the selection. - * This is generally useful only if you know the selection contains exactly one element. - */ - (): T; - }; - - filter: { - (filter: (data: any, index: number) => boolean, thisArg?: any): UpdateSelection; - (filter: string): UpdateSelection; - }; - - call(callback: (selection: Selection, ...args: any[]) => void, ...args: any[]): Selection; - each(eachFunction: (data: any, index: number) => any): Selection; - on: { - (type: string): (data: any, index: number) => any; - (type: string, listener: (data: any, index: number) => any, capture?: boolean): Selection; - }; - - /** - * Returns the total number of elements in the current selection. - */ - size(): number; - - /** - * Starts a transition for the current selection. Transitions behave much like selections, - * except operators animate smoothly over time rather than applying instantaneously. - */ - transition(): Transition.Transition; - - /** - * Sorts the elements in the current selection according to the specified comparator - * function. - * - * @param comparator a comparison function, which will be passed two data elements a and b - * to compare, and should return either a negative, positive, or zero value to indicate - * their relative order. - */ - sort(comparator?: (a: T, b: T) => number): Selection; - - /** - * Re-inserts elements into the document such that the document order matches the selection - * order. This is equivalent to calling sort() if the data is already sorted, but much - * faster. - */ - order: () => Selection; - - /** - * Returns the first non-null element in the current selection. If the selection is empty, - * returns null. - */ - node: () => T; - } - - export interface EnterSelection { - append: (name: string) => Selection; - insert: (name: string, before?: string) => Selection; - select: (selector: string) => Selection; - empty: () => boolean; - node: () => Element; - call: (callback: (selection: EnterSelection) => void) => EnterSelection; - size: () => number; - } - - export interface UpdateSelection extends Selection { - enter: () => EnterSelection; - update: () => Selection; - exit: () => Selection; - } - - export interface NestKeyValue { - key: string; - values: any; - } - - export interface Nest { - key(keyFunction: (data: any, index: number) => string): Nest; - sortKeys(comparator: (d1: any, d2: any) => number): Nest; - sortValues(comparator: (d1: any, d2: any) => number): Nest; - rollup(rollupFunction: (data: any, index: number) => any): Nest; - map(values: any[], mapType?: any): any; - entries(values: any[]): NestKeyValue[]; - } - - export interface MapKeyValue { - key: string; - value: T; - } - - export interface Map { - has(key: string): boolean; - get(key: string): T; - set(key: string, value: T): T; - remove(key: string): boolean; - keys(): string[]; - values(): T[]; - entries(): MapKeyValue[]; - forEach(func: (key: string, value: T) => void ): void; - empty(): boolean; - size(): number; - } - - export interface Set { - has(value: T): boolean; - add(value: T): T; - remove(value: T): boolean; - values(): string[]; - forEach(func: (value: string) => void ): void; - empty(): boolean; - size(): number; - } - - export interface Random { - /** - * Returns a function for generating random numbers with a normal distribution - * - * @param mean The expected value of the generated pseudorandom numbers - * @param deviation The given standard deviation - */ - normal(mean?: number, deviation?: number): () => number; - /** - * Returns a function for generating random numbers with a log-normal distribution - * - * @param mean The expected value of the generated pseudorandom numbers - * @param deviation The given standard deviation - */ - logNormal(mean?: number, deviation?: number): () => number; - /** - * Returns a function for generating random numbers with an Irwin-Hall distribution - * - * @param count The number of independent variables - */ - irwinHall(count: number): () => number; - } - - // Transitions - export module Transition { - export interface Transition { - duration: { - (duration: number): Transition; - (duration: (data: any, index: number) => any): Transition; - }; - delay: { - (delay: number): Transition; - (delay: (data: any, index: number) => any): Transition; - }; - attr: { - (name: string): string; - (name: string, value: any): Transition; - (name: string, valueFunction: (data: any, index: number) => any): Transition; - (attrValueMap : any): Transition; - }; - style: { - (name: string): string; - (name: string, value: any, priority?: string): Transition; - (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Transition; - }; - call(callback: (transition: Transition, ...args: any[]) => void, ...args: any[]): Transition; - /** - * Select an element from the current document - */ - select: { - /** - * Selects the first element that matches the specified selector string - * - * @param selector Selection String to match - */ - (selector: string): Transition; - /** - * Selects the specified node - * - * @param element Node element to select - */ - (element: EventTarget): Transition; - }; - - /** - * Select multiple elements from the current document - */ - selectAll: { - /** - * Selects all elements that match the specified selector - * - * @param selector Selection String to match - */ - (selector: string): Transition; - /** - * Selects the specified array of elements - * - * @param elements Array of node elements to select - */ - (elements: EventTarget[]): Transition; - } - each: { - /** - * Immediately invokes the specified function for each element in the current - * transition, passing in the current datum and index, with the this context - * of the current DOM element. Similar to D3.Selection.each. - * - * @param eachFunction The function to be invoked for each element in the - * current transition, passing in the current datum and index, with the this - * context of the current DOM element. - */ - (eachFunction: (data: any, index: number) => any): Transition; - /** - * Adds a listener for transition events, supporting "start", "end" and - * "interrupt" events. The listener will be invoked for each individual - * element in the transition. - * - * @param type Type of transition event. Supported values are "start", "end" - * and "interrupt". - * @param listener The listener to be invoked for each individual element in - * the transition. - */ - (type: string, listener: (data: any, index: number) => any): Transition; - } - transition: () => Transition; - ease: (value: string, ...arrs: any[]) => Transition; - attrTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate): Transition; - styleTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate, priority?: string): Transition; - text: { - (text: string): Transition; - (text: (d: any, i: number) => string): Transition; - } - tween(name: string, factory: InterpolateFactory): Transition; - filter: { - (selector: string): Transition; - (selector: (data: any, index: number) => boolean): Transition; - }; - remove(): Transition; - } - - export interface InterpolateFactory { - (a?: any, b?: any): BaseInterpolate; - } - - export interface BaseInterpolate { - (a: any, b?: any): any; - } - - export interface Interpolate { - (t: any): any; - } - } - - //Time - export module Time { - export interface Time { - second: Interval; - minute: Interval; - hour: Interval; - day: Interval; - week: Interval; - sunday: Interval; - monday: Interval; - tuesday: Interval; - wednesday: Interval; - thursday: Interval; - friday: Interval; - saturday: Interval; - month: Interval; - year: Interval; - - seconds: Range; - minutes: Range; - hours: Range; - days: Range; - weeks: Range; - months: Range; - years: Range; - - sundays: Range; - mondays: Range; - tuesdays: Range; - wednesdays: Range; - thursdays: Range; - fridays: Range; - saturdays: Range; - format: { - /** - * Constructs a new local time formatter using the given specifier. - */ - (specifier: string): TimeFormat; - /** - * Returns a new multi-resolution time format given the specified array of predicated formats. - */ - multi: (formats: any[][]) => TimeFormat; - - utc: { - /** - * Constructs a new local time formatter using the given specifier. - */ - (specifier: string): TimeFormat; - /** - * Returns a new multi-resolution UTC time format given the specified array of predicated formats. - */ - multi: (formats: any[][]) => TimeFormat; - }; - - /** - * The full ISO 8601 UTC time format: "%Y-%m-%dT%H:%M:%S.%LZ". - */ - iso: TimeFormat; - }; - - scale: { - /** - * Constructs a new time scale with the default domain and range; - * the ticks and tick format are configured for local time. - */ - (): Scale.TimeScale; - /** - * Constructs a new time scale with the default domain and range; - * the ticks and tick format are configured for UTC time. - */ - utc(): Scale.TimeScale; - }; - } - - export interface Range { - (start: Date, end: Date, step?: number): Date[]; - } - - export interface Interval { - (date: Date): Date; - floor: (date: Date) => Date; - round: (date: Date) => Date; - ceil: (date: Date) => Date; - range: Range; - offset: (date: Date, step: number) => Date; - utc?: Interval; - } - - export interface TimeFormat { - (date: Date): string; - parse: (string: string) => Date; - } - } - - // Layout - export module Layout { - export interface Layout { - /** - * Creates a new Stack layout - */ - stack(): StackLayout; - /** - * Creates a new pie layout - */ - pie(): PieLayout; - /** - * Creates a new force layout - */ - force(): ForceLayout; - /** - * Creates a new tree layout - */ - tree(): TreeLayout; - bundle(): BundleLayout; - chord(): ChordLayout; - cluster(): ClusterLayout; - hierarchy(): HierarchyLayout; - histogram(): HistogramLayout; - pack(): PackLayout; - partition(): PartitionLayout; - treemap(): TreeMapLayout; - } - - export interface StackLayout { - (layers: T[], index?: number): T[]; - values(accessor?: (d: any) => any): StackLayout; - offset(offset: string): StackLayout; - x(accessor: (d: any, i: number) => any): StackLayout; - y(accessor: (d: any, i: number) => any): StackLayout; - out(setter: (d: any, y0: number, y: number) => void): StackLayout; - } - - export interface TreeLayout { - /** - * Gets or sets the sort order of sibling nodes for the layout using the specified comparator function - */ - sort: { - /** - * Gets the sort order function of sibling nodes for the layout - */ - (): (d1: any, d2: any) => number; - /** - * Sets the sort order of sibling nodes for the layout using the specified comparator function - */ - (comparator: (d1: any, d2: any) => number): TreeLayout; - }; - /** - * Gets or sets the specified children accessor function - */ - children: { - /** - * Gets the children accessor function - */ - (): (d: any) => any; - /** - * Sets the specified children accessor function - */ - (children: (d: any) => any): TreeLayout; - }; - /** - * Runs the tree layout - */ - nodes(root: GraphNode): GraphNode[]; - /** - * Given the specified array of nodes, such as those returned by nodes, returns an array of objects representing the links from parent to child for each node - */ - links(nodes: GraphNode[]): GraphLink[]; - /** - * If separation is specified, uses the specified function to compute separation between neighboring nodes. If separation is not specified, returns the current separation function - */ - separation: { - /** - * Gets the current separation function - */ - (): (a: GraphNode, b: GraphNode) => number; - /** - * Sets the specified function to compute separation between neighboring nodes - */ - (separation: (a: GraphNode, b: GraphNode) => number): TreeLayout; - }; - /** - * Gets or sets the available layout size - */ - size: { - /** - * Gets the available layout size - */ - (): number[]; - /** - * Sets the available layout size - */ - (size: number[]): TreeLayout; - }; - /** - * Gets or sets the available node size - */ - nodeSize: { - /** - * Gets the available node size - */ - (): number[]; - /** - * Sets the available node size - */ - (size: number[]): TreeLayout; - }; - } - - export interface PieLayout { - (values: any[], index?: number): ArcDescriptor[]; - value: { - (): (d: any, index: number) => number; - (accessor: (d: any, index: number) => number): PieLayout; - }; - sort: { - (): (d1: any, d2: any) => number; - (comparator: (d1: any, d2: any) => number): PieLayout; - }; - startAngle: { - (): number; - (angle: number): PieLayout; - (angle: () => number): PieLayout; - (angle: (d : any) => number): PieLayout; - (angle: (d : any, i: number) => number): PieLayout; - }; - endAngle: { - (): number; - (angle: number): PieLayout; - (angle: () => number): PieLayout; - (angle: (d : any) => number): PieLayout - (angle: (d : any, i: number) => number): PieLayout; - }; - } - - export interface ArcDescriptor { - value: any; - data: any; - startAngle: number; - endAngle: number; - index: number; - } - - export interface GraphNode { - id?: number; - index?: number; - name?: string; - px?: number; - py?: number; - size?: number; - weight?: number; - x?: number; - y?: number; - subindex?: number; - startAngle?: number; - endAngle?: number; - value?: number; - fixed?: boolean; - children?: GraphNode[]; - _children?: GraphNode[]; - parent?: GraphNode; - depth?: number; - } - - export interface GraphLink { - source: GraphNode; - target: GraphNode; - } - - export interface GraphNodeForce { - index?: number; - x?: number; - y?: number; - px?: number; - py?: number; - fixed?: boolean; - weight?: number; - } - - export interface GraphLinkForce { - source: GraphNodeForce; - target: GraphNodeForce; - } - - export interface ForceLayout { - (): ForceLayout; - size: { - (): number[]; - (mysize: number[]): ForceLayout; - }; - linkDistance: { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - linkStrength: - { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - friction: - { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - alpha: { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - charge: { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - - theta: { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - - gravity: { - (): number; - (number:number): ForceLayout; - (accessor: (d: any, index: number) => number): ForceLayout; - }; - - links: { - (): GraphLinkForce[]; - (arLinks: GraphLinkForce[]): ForceLayout; - - }; - nodes: - { - (): GraphNodeForce[]; - (arNodes: GraphNodeForce[]): ForceLayout; - - }; - start(): ForceLayout; - resume(): ForceLayout; - stop(): ForceLayout; - tick(): ForceLayout; - on(type: string, listener: () => void ): ForceLayout; - drag(): ForceLayout; - } - - export interface BundleLayout{ - (links: GraphLink[]): GraphNode[][]; - } - - export interface ChordLayout { - matrix: { - (): number[][]; - (matrix: number[][]): ChordLayout; - } - padding: { - (): number; - (padding: number): ChordLayout; - } - sortGroups: { - (): (a: number, b: number) => number; - (comparator: (a: number, b: number) => number): ChordLayout; - } - sortSubgroups: { - (): (a: number, b: number) => number; - (comparator: (a: number, b: number) => number): ChordLayout; - } - sortChords: { - (): (a: number, b: number) => number; - (comparator: (a: number, b: number) => number): ChordLayout; - } - chords(): GraphLink[]; - groups(): ArcDescriptor[]; - } - - export interface ClusterLayout{ - sort: { - (): (a: GraphNode, b: GraphNode) => number; - (comparator: (a: GraphNode, b: GraphNode) => number): ClusterLayout; - } - children: { - (): (d: any, i?: number) => GraphNode[]; - (children: (d: any, i?: number) => GraphNode[]): ClusterLayout; - } - nodes(root: GraphNode): GraphNode[]; - links(nodes: GraphNode[]): GraphLink[]; - separation: { - (): (a: GraphNode, b: GraphNode) => number; - (separation: (a: GraphNode, b: GraphNode) => number): ClusterLayout; - } - size: { - (): number[]; - (size: number[]): ClusterLayout; - } - value: { - (): (node: GraphNode) => number; - (value: (node: GraphNode) => number): ClusterLayout; - } - } - - export interface HierarchyLayout { - sort: { - (): (a: GraphNode, b: GraphNode) => number; - (comparator: (a: GraphNode, b: GraphNode) => number): HierarchyLayout; - } - children: { - (): (d: any, i?: number) => GraphNode[]; - (children: (d: any, i?: number) => GraphNode[]): HierarchyLayout; - } - nodes(root: GraphNode): GraphNode[]; - links(nodes: GraphNode[]): GraphLink[]; - value: { - (): (node: GraphNode) => number; - (value: (node: GraphNode) => number): HierarchyLayout; - } - reValue(root: GraphNode): HierarchyLayout; - } - - export interface Bin extends Array { - x: number; - dx: number; - y: number; - } - - export interface HistogramLayout { - (values: any[], index?: number): Bin[]; - value: { - (): (value: any) => any; - (accessor: (value: any) => any): HistogramLayout - } - range: { - (): (value: any, index: number) => number[]; - (range: (value: any, index: number) => number[]): HistogramLayout; - (range: number[]): HistogramLayout; - } - bins: { - (): (range: any[], index: number) => number[]; - (bins: (range: any[], index: number) => number[]): HistogramLayout; - (bins: number): HistogramLayout; - (bins: number[]): HistogramLayout; - } - frequency: { - (): boolean; - (frequency: boolean): HistogramLayout; - } - } - - export interface PackLayout { - sort: { - (): (a: GraphNode, b: GraphNode) => number; - (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout; - } - children: { - (): (d: any, i?: number) => GraphNode[]; - (children: (d: any, i?: number) => GraphNode[]): PackLayout; - } - nodes(root: GraphNode): GraphNode[]; - links(nodes: GraphNode[]): GraphLink[]; - value: { - (): (node: GraphNode) => number; - (value: (node: GraphNode) => number): PackLayout; - } - size: { - (): number[]; - (size: number[]): PackLayout; - } - padding: { - (): number; - (padding: number): PackLayout; - } - } - - export interface PartitionLayout { - sort: { - (): (a: GraphNode, b: GraphNode) => number; - (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout; - } - children: { - (): (d: any, i?: number) => GraphNode[]; - (children: (d: any, i?: number) => GraphNode[]): PackLayout; - } - nodes(root: GraphNode): GraphNode[]; - links(nodes: GraphNode[]): GraphLink[]; - value: { - (): (node: GraphNode) => number; - (value: (node: GraphNode) => number): PackLayout; - } - size: { - (): number[]; - (size: number[]): PackLayout; - } - } - - export interface TreeMapLayout { - sort: { - (): (a: GraphNode, b: GraphNode) => number; - (comparator: (a: GraphNode, b: GraphNode) => number): TreeMapLayout; - } - children: { - (): (d: any, i?: number) => GraphNode[]; - (children: (d: any, i?: number) => GraphNode[]): TreeMapLayout; - } - nodes(root: GraphNode): GraphNode[]; - links(nodes: GraphNode[]): GraphLink[]; - value: { - (): (node: GraphNode) => number; - (value: (node: GraphNode) => number): TreeMapLayout; - } - size: { - (): number[]; - (size: number[]): TreeMapLayout; - } - padding: { - (): number; - (padding: number): TreeMapLayout; - } - round: { - (): boolean; - (round: boolean): TreeMapLayout; - } - sticky: { - (): boolean; - (sticky: boolean): TreeMapLayout; - } - mode: { - (): string; - (mode: string): TreeMapLayout; - } - } - } - - // Color - export module Color { - export interface Color { - /** - * increase lightness by some exponential factor (gamma) - */ - brighter(k?: number): Color; - /** - * decrease lightness by some exponential factor (gamma) - */ - darker(k?: number): Color; - /** - * convert the color to a string. - */ - toString(): string; - } - - export interface RGBColor extends Color{ - /** - * the red color channel. - */ - r: number; - /** - * the green color channel. - */ - g: number; - /** - * the blue color channel. - */ - b: number; - /** - * convert from RGB to HSL. - */ - hsl(): HSLColor; - } - - export interface HSLColor extends Color{ - /** - * hue - */ - h: number; - /** - * saturation - */ - s: number; - /** - * lightness - */ - l: number; - /** - * convert from HSL to RGB. - */ - rgb(): RGBColor; - } - - export interface LABColor extends Color{ - /** - * lightness - */ - l: number; - /** - * a-dimension - */ - a: number; - /** - * b-dimension - */ - b: number; - /** - * convert from LAB to RGB. - */ - rgb(): RGBColor; - } - - export interface HCLColor extends Color{ - /** - * hue - */ - h: number; - /** - * chroma - */ - c: number; - /** - * luminance - */ - l: number; - /** - * convert from HCL to RGB. - */ - rgb(): RGBColor; - } - } - - // SVG - export module Svg { - export interface Svg { - /** - * Create a new symbol generator - */ - symbol(): Symbol; - /** - * Create a new axis generator - */ - axis(): Axis; - /** - * Create a new arc generator - */ - arc(): Arc; - /** - * Create a new line generator - */ - line: { - (): Line; - radial(): LineRadial; - } - /** - * Create a new area generator - */ - area: { - (): Area; - radial(): AreaRadial; - } - /** - * Create a new brush generator - */ - brush(): Brush; - /** - * Create a new chord generator - */ - chord(): Chord; - /** - * Create a new diagonal generator - */ - diagonal: { - (): Diagonal; - radial(): Diagonal; - } - /** - * The array of supported symbol types. - */ - symbolTypes: string[]; - } - - export interface Symbol { - type: (symbolType: string | ((datum: any, index: number) => string)) => Symbol; - size: (size: number | ((datum: any, index: number) => number)) => Symbol; - (datum:any, index:number): string; - } - - export interface Brush { - /** - * Draws or redraws this brush into the specified selection of elements - */ - (selection: Selection): void; - /** - * Gets or sets the x-scale associated with the brush - */ - x: { - /** - * Gets the x-scale associated with the brush - */ - (): D3.Scale.Scale; - /** - * Sets the x-scale associated with the brush - * - * @param accessor The new Scale - */ - (scale: D3.Scale.Scale): Brush; - }; - /** - * Gets or sets the x-scale associated with the brush - */ - y: { - /** - * Gets the x-scale associated with the brush - */ - (): D3.Scale.Scale; - /** - * Sets the x-scale associated with the brush - * - * @param accessor The new Scale - */ - (scale: D3.Scale.Scale): Brush; - }; - /** - * Gets or sets the current brush extent - */ - extent: { - /** - * Gets the current brush extent - */ - (): any[]; - /** - * Sets the current brush extent - */ - (values: any[]): Brush; - }; - /** - * Clears the extent, making the brush extent empty. - */ - clear(): Brush; - /** - * Returns true if and only if the brush extent is empty - */ - empty(): boolean; - /** - * Gets or sets the listener for the specified event type - */ - on: { - /** - * Gets the listener for the specified event type - */ - (type: string): (data: any, index: number) => any; - /** - * Sets the listener for the specified event type - */ - (type: string, listener: (data: any, index: number) => any, capture?: boolean): Brush; - }; - } - - export interface Axis { - (selection: Selection): void; - (transition: Transition.Transition): void; - - scale: { - (): any; - (scale: any): Axis; - }; - - orient: { - (): string; - (orientation: string): Axis; - }; - - ticks: { - (): any[]; - (...arguments: any[]): Axis; - }; - - tickPadding: { - (): number; - (padding: number): Axis; - }; - - tickValues: { - (): any[]; - (values: any[]): Axis; - }; - tickSubdivide(count: number): Axis; - tickSize: { - (): number; - (inner: number, outer?: number): Axis; - } - innerTickSize: { - (): number; - (value: number): Axis; - } - outerTickSize: { - (): number; - (value: number): Axis; - } - tickFormat(formatter: (value: any, index?: number) => string): Axis; - nice(count?: number): Axis; - } - - export interface Arc { - /** - * Returns the path data string - * - * @param data Array of data elements - * @param index Optional index - */ - (data: any, index?: number): string; - innerRadius: { - (): (data: any, index?: number) => number; - (radius: number): Arc; - (radius: () => number): Arc; - (radius: (data: any) => number): Arc; - (radius: (data: any, index: number) => number): Arc; - }; - outerRadius: { - (): (data: any, index?: number) => number; - (radius: number): Arc; - (radius: () => number): Arc; - (radius: (data: any) => number): Arc; - (radius: (data: any, index: number) => number): Arc; - }; - startAngle: { - (): (data: any, index?: number) => number; - (angle: number): Arc; - (angle: () => number): Arc; - (angle: (data: any) => number): Arc; - (angle: (data: any, index: number) => number): Arc; - }; - endAngle: { - (): (data: any, index?: number) => number; - (angle: number): Arc; - (angle: () => number): Arc; - (angle: (data: any) => number): Arc; - (angle: (data: any, index: number) => number): Arc; - }; - centroid(data: any, index?: number): number[]; - } - - export interface Line { - /** - * Returns the path data string - * - * @param data Array of data elements - * @param index Optional index - */ - (data: any[], index?: number): string; - /** - * Get or set the x-coordinate accessor. - */ - x: { - /** - * Get the x-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Line; - (accessor: (data: any, index: number) => number): Line; - /** - * Set the x-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): Line; - }; - /** - * Get or set the y-coordinate accessor. - */ - y: { - /** - * Get the y-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Line; - (accessor: (data: any, index: number) => number): Line; - /** - * Set the y-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): Line; - }; - /** - * Get or set the interpolation mode. - */ - interpolate: { - /** - * Get the interpolation accessor. - */ - (): string; - /** - * Set the interpolation accessor. - * - * @param interpolate The interpolation mode - */ - (interpolate: string): Line; - }; - /** - * Get or set the cardinal spline tension. - */ - tension: { - /** - * Get the cardinal spline accessor. - */ - (): number; - /** - * Set the cardinal spline accessor. - * - * @param tension The Cardinal spline interpolation tension - */ - (tension: number): Line; - }; - /** - * Control whether the line is defined at a given point. - */ - defined: { - /** - * Get the accessor function that controls where the line is defined. - */ - (): (data: any, index?: number) => boolean; - /** - * Set the accessor function that controls where the area is defined. - * - * @param defined The new accessor function - */ - (defined: (data: any, index?: number) => boolean): Line; - }; - } - - export interface LineRadial { - /** - * Returns the path data string - * - * @param data Array of data elements - * @param index Optional index - */ - (data: any[], index?: number): string; - /** - * Get or set the x-coordinate accessor. - */ - x: { - /** - * Get the x-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): LineRadial; - (accessor: (data: any, index: number) => number): LineRadial; - - /** - * Set the x-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): LineRadial; - }; - /** - * Get or set the y-coordinate accessor. - */ - y: { - /** - * Get the y-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): LineRadial; - (accessor: (data: any, index: number) => number): LineRadial; - /** - * Set the y-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): LineRadial; - }; - /** - * Get or set the interpolation mode. - */ - interpolate: { - /** - * Get the interpolation accessor. - */ - (): string; - /** - * Set the interpolation accessor. - * - * @param interpolate The interpolation mode - */ - (interpolate: string): LineRadial; - }; - /** - * Get or set the cardinal spline tension. - */ - tension: { - /** - * Get the cardinal spline accessor. - */ - (): number; - /** - * Set the cardinal spline accessor. - * - * @param tension The Cardinal spline interpolation tension - */ - (tension: number): LineRadial; - }; - /** - * Control whether the line is defined at a given point. - */ - defined: { - /** - * Get the accessor function that controls where the line is defined. - */ - (): (data: any) => any; - /** - * Set the accessor function that controls where the area is defined. - * - * @param defined The new accessor function - */ - (defined: (data: any) => any): LineRadial; - }; - radius: { - (): (d: any, i?: number) => number; - (radius: number): LineRadial; - (radius: (d: any) => number): LineRadial; - (radius: (d: any, i: number) => number): LineRadial; - } - angle: { - (): (d: any, i?: any) => number; - (angle: number): LineRadial; - (angle: (d: any) => number): LineRadial; - (angle: (d: any, i: any) => number): LineRadial; - } - } - - export interface Area { - /** - * Generate a piecewise linear area, as in an area chart. - */ - (data: any[], index?: number): string; - /** - * Get or set the x-coordinate accessor. - */ - x: { - /** - * Get the x-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Area; - (accessor: (data: any, index: number) => number): Area; - /** - * Set the x-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): Area; - }; - /** - * Get or set the x0-coordinate (baseline) accessor. - */ - x0: { - /** - * Get the x0-coordinate (baseline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x0-coordinate (baseline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Area; - (accessor: (data: any, index: number) => number): Area; - /** - * Set the x0-coordinate (baseline) to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): Area; - }; - /** - * Get or set the x1-coordinate (topline) accessor. - */ - x1: { - /** - * Get the x1-coordinate (topline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x1-coordinate (topline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Area; - (accessor: (data: any, index: number) => number): Area; - /** - * Set the x1-coordinate (topline) to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): Area; - }; - /** - * Get or set the y-coordinate accessor. - */ - y: { - /** - * Get the y-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Area; - (accessor: (data: any, index: number) => number): Area; - /** - * Set the y-coordinate to a constant. - * - * @param cnst The constant value - */ - (cnst: number): Area; - }; - /** - * Get or set the y0-coordinate (baseline) accessor. - */ - y0: { - /** - * Get the y0-coordinate (baseline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y0-coordinate (baseline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Area; - (accessor: (data: any, index: number) => number): Area; - /** - * Set the y0-coordinate (baseline) to a constant. - * - * @param cnst The constant value - */ - (cnst: number): Area; - }; - /** - * Get or set the y1-coordinate (topline) accessor. - */ - y1: { - /** - * Get the y1-coordinate (topline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y1-coordinate (topline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): Area; - (accessor: (data: any, index: number) => number): Area; - /** - * Set the y1-coordinate (baseline) to a constant. - * - * @param cnst The constant value - */ - (cnst: number): Area; - }; - /** - * Get or set the interpolation mode. - */ - interpolate: { - /** - * Get the interpolation accessor. - */ - (): string; - /** - * Set the interpolation accessor. - * - * @param interpolate The interpolation mode - */ - (interpolate: string): Area; - }; - /** - * Get or set the cardinal spline tension. - */ - tension: { - /** - * Get the cardinal spline accessor. - */ - (): number; - /** - * Set the cardinal spline accessor. - * - * @param tension The Cardinal spline interpolation tension - */ - (tension: number): Area; - }; - /** - * Control whether the area is defined at a given point. - */ - defined: { - /** - * Get the accessor function that controls where the area is defined. - */ - (): (data: any, index?: number) => any; - /** - * Set the accessor function that controls where the area is defined. - * - * @param defined The new accessor function - */ - (defined: (data: any, index?: number) => any): Area; - }; - } - - export interface AreaRadial { - /** - * Generate a piecewise linear area, as in an area chart. - */ - (data: any[], index?: number): string; - /** - * Get or set the x-coordinate accessor. - */ - x: { - /** - * Get the x-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): AreaRadial; - (accessor: (data: any, index: number) => number): AreaRadial; - /** - * Set the x-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): AreaRadial; - }; - /** - * Get or set the x0-coordinate (baseline) accessor. - */ - x0: { - /** - * Get the x0-coordinate (baseline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x0-coordinate (baseline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): AreaRadial; - (accessor: (data: any, index: number) => number): AreaRadial; - /** - * Set the x0-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): AreaRadial; - }; - /** - * Get or set the x1-coordinate (topline) accessor. - */ - x1: { - /** - * Get the x1-coordinate (topline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the x1-coordinate (topline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): AreaRadial; - (accessor: (data: any, index: number) => number): AreaRadial; - /** - * Set the x1-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): AreaRadial; - }; - /** - * Get or set the y-coordinate accessor. - */ - y: { - /** - * Get the y-coordinate accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): AreaRadial; - (accessor: (data: any, index: number) => number): AreaRadial; - /** - * Set the y-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): AreaRadial; - }; - /** - * Get or set the y0-coordinate (baseline) accessor. - */ - y0: { - /** - * Get the y0-coordinate (baseline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y0-coordinate (baseline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): AreaRadial; - (accessor: (data: any, index: number) => number): AreaRadial; - /** - * Set the y0-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): AreaRadial; - }; - /** - * Get or set the y1-coordinate (topline) accessor. - */ - y1: { - /** - * Get the y1-coordinate (topline) accessor. - */ - (): (data: any, index ?: number) => number; - /** - * Set the y1-coordinate (topline) accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: any) => number): AreaRadial; - (accessor: (data: any, index: number) => number): AreaRadial; - /** - * Set the y1-coordinate to a constant. - * - * @param cnst The new constant value. - */ - (cnst: number): AreaRadial; - }; - /** - * Get or set the interpolation mode. - */ - interpolate: { - /** - * Get the interpolation accessor. - */ - (): string; - /** - * Set the interpolation accessor. - * - * @param interpolate The interpolation mode - */ - (interpolate: string): AreaRadial; - }; - /** - * Get or set the cardinal spline tension. - */ - tension: { - /** - * Get the cardinal spline accessor. - */ - (): number; - /** - * Set the cardinal spline accessor. - * - * @param tension The Cardinal spline interpolation tension - */ - (tension: number): AreaRadial; - }; - /** - * Control whether the area is defined at a given point. - */ - defined: { - /** - * Get the accessor function that controls where the area is defined. - */ - (): (data: any) => any; - /** - * Set the accessor function that controls where the area is defined. - * - * @param defined The new accessor function - */ - (defined: (data: any) => any): AreaRadial; - }; - radius: { - (): number; - (radius: number): AreaRadial; - (radius: () => number): AreaRadial; - (radius: (data: any) => number): AreaRadial; - (radius: (data: any, index: number) => number): AreaRadial; - }; - innerRadius: { - (): number; - (radius: number): AreaRadial; - (radius: () => number): AreaRadial; - (radius: (data: any) => number): AreaRadial; - (radius: (data: any, index: number) => number): AreaRadial; - }; - outerRadius: { - (): number; - (radius: number): AreaRadial; - (radius: () => number): AreaRadial; - (radius: (data: any) => number): AreaRadial; - (radius: (data: any, index: number) => number): AreaRadial; - }; - angle: { - (): number; - (angle: number): AreaRadial; - (angle: () => number): AreaRadial; - (angle: (data: any) => number): AreaRadial; - (angle: (data: any, index: number) => number): AreaRadial; - }; - startAngle: { - (): number; - (angle: number): AreaRadial; - (angle: () => number): AreaRadial; - (angle: (data: any) => number): AreaRadial; - (angle: (data: any, index: number) => number): AreaRadial; - }; - endAngle: { - (): number; - (angle: number): AreaRadial; - (angle: () => number): AreaRadial; - (angle: (data: any) => number): AreaRadial; - (angle: (data: any, index: number) => number): AreaRadial; - }; - } - - export interface Chord { - (datum: any, index?: number): string; - radius: { - (): number; - (radius: number): Chord; - (radius: () => number): Chord; - }; - startAngle: { - (): number; - (angle: number): Chord; - (angle: () => number): Chord; - }; - endAngle: { - (): number; - (angle: number): Chord; - (angle: () => number): Chord; - }; - source: { - (): any; - (angle: any): Chord; - (angle: (d: any, i?: number) => any): Chord; - }; - target: { - (): any; - (angle: any): Chord; - (angle: (d: any, i?: number) => any): Chord; - }; - } - - export interface Diagonal { - (datum: any, index?: number): string; - projection: { - (): (datum: any, index?: number) => number[]; - (proj: (datum: any) => number[]): Diagonal; - (proj: (datum: any, index: number) => number[]): Diagonal; - }; - source: { - (): (datum: any, index?: number) => any; - (src: (datum: any) => any): Diagonal; - (src: (datum: any, index: number) => any): Diagonal; - (src: any): Diagonal; - }; - target: { - (): (datum: any, index?: number) => any; - (target: (d: any) => any): Diagonal; - (target: (d: any, i: number) => any): Diagonal; - (target: any): Diagonal; - }; - } - } - - // Scales - export module Scale { - export interface ScaleBase { - /** - * Construct a linear quantitative scale. - */ - linear(): LinearScale; - /* - * Construct an ordinal scale. - */ - ordinal(): OrdinalScale; - /** - * Construct a linear quantitative scale with a discrete output range. - */ - quantize(): QuantizeScale; - /* - * Construct an ordinal scale with ten categorical colors. - */ - category10(): OrdinalScale; - /* - * Construct an ordinal scale with twenty categorical colors - */ - category20(): OrdinalScale; - /* - * Construct an ordinal scale with twenty categorical colors - */ - category20b(): OrdinalScale; - /* - * Construct an ordinal scale with twenty categorical colors - */ - category20c(): OrdinalScale; - /* - * Construct a linear identity scale. - */ - identity(): IdentityScale; - /* - * Construct a quantitative scale with an logarithmic transform. - */ - log(): LogScale; - /* - * Construct a quantitative scale with an exponential transform. - */ - pow(): PowScale; - /* - * Construct a quantitative scale mapping to quantiles. - */ - quantile(): QuantileScale; - /* - * Construct a quantitative scale with a square root transform. - */ - sqrt(): SqrtScale; - /* - * Construct a threshold scale with a discrete output range. - */ - threshold(): ThresholdScale; - } - - export interface GenericScale { - (value: any): any; - domain: { - (values: any[]): S; - (): any[]; - }; - range: { - (values: any[]): S; - (): any[]; - }; - invertExtent?(y: any): any[]; - copy(): S; - } - - export interface Scale extends GenericScale { } - - export interface GenericQuantitativeScale extends GenericScale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: number): number; - /** - * Get the domain value corresponding to a given range value. - * - * @param value Range Value - */ - invert(value: number): number; - /** - * Set the scale's output range, and enable rounding. - * - * @param value The output range. - */ - rangeRound: (values: any[]) => S; - /** - * get or set the scale's output interpolator. - */ - interpolate: { - (): D3.Transition.Interpolate; - (factory: D3.Transition.Interpolate): S; - }; - /** - * enable or disable clamping of the output range. - * - * @param clamp Enable or disable - */ - clamp: { - (): boolean; - (clamp: boolean): S; - } - /** - * extend the scale domain to nice round numbers. - * - * @param count Optional number of ticks to exactly fit the domain - */ - nice(count?: number): S; - /** - * get representative values from the input domain. - * - * @param count Aproximate representative values to return. - */ - ticks(count: number): any[]; - /** - * get a formatter for displaying tick values - * - * @param count Aproximate representative values to return - */ - tickFormat(count: number, format?: string): (n: number) => string; - } - - export interface QuantitativeScale extends GenericQuantitativeScale { } - - export interface LinearScale extends GenericQuantitativeScale { } - - export interface IdentityScale extends GenericScale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: number): number; - /** - * Get the domain value corresponding to a given range value. - * - * @param value Range Value - */ - invert(value: number): number; - /** - * get representative values from the input domain. - * - * @param count Aproximate representative values to return. - */ - ticks(count: number): any[]; - /** - * get a formatter for displaying tick values - * - * @param count Aproximate representative values to return - */ - tickFormat(count: number): (n: number) => string; - } - - export interface SqrtScale extends GenericQuantitativeScale { } - - export interface PowScale extends GenericQuantitativeScale { } - - export interface LogScale extends GenericQuantitativeScale { } - - export interface OrdinalScale extends GenericScale { - rangePoints(interval: any[], padding?: number): OrdinalScale; - rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; - rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; - rangeBand(): number; - rangeExtent(): any[]; - } - - export interface QuantizeScale extends GenericScale { } - - export interface ThresholdScale extends GenericScale { } - - export interface QuantileScale extends GenericScale { - quantiles(): any[]; - } - - export interface TimeScale extends GenericScale { - (value: Date): number; - invert(value: number): Date; - rangeRound: (values: any[]) => TimeScale; - interpolate: { - (): D3.Transition.Interpolate; - (factory: D3.Transition.InterpolateFactory): TimeScale; - }; - clamp(clamp: boolean): TimeScale; - ticks: { - (count: number): any[]; - (range: D3.Time.Range, count: number): any[]; - }; - tickFormat(count: number): (n: number) => string; - nice(count?: number): TimeScale; - } - } - - // Behaviour - export module Behavior { - export interface Behavior{ - /** - * Constructs a new drag behaviour - */ - drag(): Drag; - /** - * Constructs a new zoom behaviour - */ - zoom(): Zoom; - } - - export interface Zoom { - /** - * Applies the zoom behavior to the specified selection, - * registering the necessary event listeners to support - * panning and zooming. - */ - (selection: Selection): void; - - /** - * Registers a listener to receive events - * - * @param type Enent name to attach the listener to - * @param listener Function to attach to event - */ - on: (type: string, listener: (data: any, index?: number) => any) => Zoom; - - /** - * Gets or set the current zoom scale - */ - scale: { - /** - * Get the current current zoom scale - */ - (): number; - /** - * Set the current current zoom scale - * - * @param origin Zoom scale - */ - (scale: number): Zoom; - }; - - /** - * Gets or set the current zoom translation vector - */ - translate: { - /** - * Get the current zoom translation vector - */ - (): number[]; - /** - * Set the current zoom translation vector - * - * @param translate Tranlation vector - */ - (translate: number[]): Zoom; - }; - - /** - * Gets or set the allowed scale range - */ - scaleExtent: { - /** - * Get the current allowed zoom range - */ - (): number[]; - /** - * Set the allowable zoom range - * - * @param extent Allowed zoom range - */ - (extent: number[]): Zoom; - }; - - /** - * Gets or set the X-Scale that should be adjusted when zooming - */ - x: { - /** - * Get the X-Scale - */ - (): D3.Scale.Scale; - /** - * Set the X-Scale to be adjusted - * - * @param x The X Scale - */ - (x: D3.Scale.Scale): Zoom; - - }; - - /** - * Gets or set the Y-Scale that should be adjusted when zooming - */ - y: { - /** - * Get the Y-Scale - */ - (): D3.Scale.Scale; - /** - * Set the Y-Scale to be adjusted - * - * @param y The Y Scale - */ - (y: D3.Scale.Scale): Zoom; - }; - } - - export interface Drag { - /** - * Execute drag method - */ - (): any; - - /** - * Registers a listener to receive events - * - * @param type Enent name to attach the listener to - * @param listener Function to attach to event - */ - on: (type: string, listener: (data: any, index?: number) => any) => Drag; - - /** - * Gets or set the current origin accessor function - */ - origin: { - /** - * Get the current origin accessor function - */ - (): any; - /** - * Set the origin accessor function - * - * @param origin Accessor function - */ - (origin?: any): Drag; - }; - } - } - - // Geography - export module Geo { - export interface Geo { - /** - * create a new geographic path generator - */ - path(): Path; - /** - * create a circle generator. - */ - circle(): Circle; - /** - * compute the spherical area of a given feature. - */ - area(feature: any): number; - /** - * compute the latitude-longitude bounding box for a given feature. - */ - bounds(feature: any): number[][]; - /** - * compute the spherical centroid of a given feature. - */ - centroid(feature: any): number[]; - /** - * compute the great-arc distance between two points. - */ - distance(a: number[], b: number[]): number; - /** - * interpolate between two points along a great arc. - */ - interpolate(a: number[], b: number[]): (t: number) => number[]; - /** - * compute the length of a line string or the circumference of a polygon. - */ - length(feature: any): number; - /** - * create a standard projection from a raw projection. - */ - projection(raw: RawProjection): Projection; - /** - * create a standard projection from a mutable raw projection. - */ - projectionMutator(rawFactory: RawProjection): ProjectionMutator; - /** - * the Albers equal-area conic projection. - */ - albers(): Projection; - /** - * a composite Albers projection for the United States. - */ - albersUsa(): Projection; - /** - * the azimuthal equal-area projection. - */ - azimuthalEqualArea: { - (): Projection; - raw: RawProjection; - } - /** - * the azimuthal equidistant projection. - */ - azimuthalEquidistant: { - (): Projection; - raw: RawProjection; - } - /** - * the conic conformal projection. - */ - conicConformal: { - (): Projection; - raw(phi1:number, phi2:number): RawProjection; - } - /** - * the conic equidistant projection. - */ - conicEquidistant: { - (): Projection; - raw(phi1:number, phi2:number): RawProjection; - } - /** - * the conic equal-area (a.k.a. Albers) projection. - */ - conicEqualArea: { - (): Projection; - raw(phi1:number, phi2:number): RawProjection; - } - /** - * the equirectangular (plate carreé) projection. - */ - equirectangular: { - (): Projection; - raw: RawProjection; - } - /** - * the gnomonic projection. - */ - gnomonic: { - (): Projection; - raw: RawProjection; - } - /** - * the spherical Mercator projection. - */ - mercator: { - (): Projection; - raw: RawProjection; - } - /** - * the azimuthal orthographic projection. - */ - orthographic: { - (): Projection; - raw: RawProjection; - } - /** - * the azimuthal stereographic projection. - */ - stereographic: { - (): Projection; - raw: RawProjection; - } - /** - * the transverse Mercator projection. - */ - transverseMercator: { - (): Projection; - raw: RawProjection; - } - /** - * convert a GeoJSON object to a geometry stream. - */ - stream(object: GeoJSON, listener: Stream): void; - /** - * - */ - graticule(): Graticule; - /** - * - */ - greatArc(): GreatArc; - /** - * - */ - rotation(rotation: number[]): Rotation; - } - - export interface Path { - /** - * Returns the path data string for the given feature - */ - (feature: any, index?: any): string; - /** - * get or set the geographic projection. - */ - projection: { - /** - * get the geographic projection. - */ - (): Projection; - /** - * set the geographic projection. - */ - (projection: Projection): Path; - } - /** - * get or set the render context. - */ - context: { - /** - * return an SVG path string invoked on the given feature. - */ - (): string; - /** - * sets the render context and returns the path generator - */ - (context: Context): Path; - } - /** - * Computes the projected area - */ - area(feature: any): any; - /** - * Computes the projected centroid - */ - centroid(feature: any): any; - /** - * Computes the projected bounding box - */ - bounds(feature: any): any; - /** - * get or set the radius to display point features. - */ - pointRadius: { - /** - * returns the current radius - */ - (): number; - /** - * sets the radius used to display Point and MultiPoint features to the specified number - */ - (radius: number): Path; - /** - * sets the radius used to display Point and MultiPoint features to the specified number - */ - (radius: (feature: any, index: number) => number): Path; - } - } - - export interface Context { - beginPath(): any; - moveTo(x: number, y: number): any; - lineTo(x: number, y: number): any; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): any; - closePath(): any; - } - - export interface Circle { - (...args: any[]): GeoJSON; - origin: { - (): number[]; - (origin: number[]): Circle; - (origin: (...args: any[]) => number[]): Circle; - } - angle: { - (): number; - (angle: number): Circle; - } - precision: { - (): number; - (precision: number): Circle; - } - } - - export interface Graticule{ - (): GeoJSON; - lines(): GeoJSON[]; - outline(): GeoJSON; - extent: { - (): number[][]; - (extent: number[][]): Graticule; - } - minorExtent: { - (): number[][]; - (extent: number[][]): Graticule; - } - majorExtent: { - (): number[][]; - (extent: number[][]): Graticule; - } - step: { - (): number[][]; - (extent: number[][]): Graticule; - } - minorStep: { - (): number[][]; - (extent: number[][]): Graticule; - } - majorStep: { - (): number[][]; - (extent: number[][]): Graticule; - } - precision: { - (): number; - (precision: number): Graticule; - } - } - - export interface GreatArc { - (): GeoJSON; - distance(): number; - source: { - (): any; - (source: any): GreatArc; - } - target: { - (): any; - (target: any): GreatArc; - } - precision: { - (): number; - (precision: number): GreatArc; - } - } - - export interface GeoJSON { - coordinates: number[][]; - type: string; - } - - export interface RawProjection { - (lambda: number, phi: number): number[]; - invert?(x: number, y: number): number[]; - } - - export interface Projection { - (coordinates: number[]): number[]; - invert?(point: number[]): number[]; - rotate: { - (): number[]; - (rotation: number[]): Projection; - }; - center: { - (): number[]; - (location: number[]): Projection; - }; - parallels: { - (): number[]; - (location: number[]): Projection; - }; - translate: { - (): number[]; - (point: number[]): Projection; - }; - scale: { - (): number; - (scale: number): Projection; - }; - clipAngle: { - (): number; - (angle: number): Projection; - }; - clipExtent: { - (): number[][]; - (extent: number[][]): Projection; - }; - precision: { - (): number; - (precision: number): Projection; - }; - stream(listener?: Stream): Stream; - } - - export interface Stream { - point(x: number, y: number, z?: number): void; - lineStart(): void; - lineEnd(): void; - polygonStart(): void; - polygonEnd(): void; - sphere(): void; - } - - export interface Rotation extends Array { - (location: number[]): Rotation; - invert(location: number[]): Rotation; - } - - export interface ProjectionMutator { - (lambda: number, phi: number): Projection; - } - } - - // Geometry - export module Geom { - export interface Geom { - voronoi(): Voronoi; - /** - * compute the Voronoi diagram for the specified points. - */ - voronoi(vertices: Vertice[]): Polygon[]; - /** - * compute the Delaunay triangulation for the specified points. - */ - delaunay(vertices?: Vertice[]): Polygon[]; - /** - * constructs a quadtree for an array of points. - */ - quadtree(): QuadtreeFactory; - /** - * Constructs a new quadtree for the specified array of points. - */ - quadtree(points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree; - /** - * Constructs a new quadtree for the specified array of points. - */ - quadtree(points: Point[], width: number, height: number): Quadtree; - /** - * Returns the input array of vertices with additional methods attached - */ - polygon(vertices:Vertice[]): Polygon; - /** - * creates a new hull layout with the default settings. - */ - hull(): Hull; - - hull(vertices:Vertice[]): Vertice[]; - } - - export interface Vertice extends Array { - /** - * Returns the angle of the vertice - */ - angle?: number; - } - - export interface Polygon extends Array { - /** - * Returns the signed area of this polygon - */ - area(): number; - /** - * Returns a two-element array representing the centroid of this polygon. - */ - centroid(): number[]; - /** - * Clips the subject polygon against this polygon - */ - clip(subject: Polygon): Polygon; - } - - export interface QuadtreeFactory { - /** - * Constructs a new quadtree for the specified array of points. - */ - (): Quadtree; - /** - * Constructs a new quadtree for the specified array of points. - */ - (points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree; - /** - * Constructs a new quadtree for the specified array of points. - */ - (points: Point[], width: number, height: number): Quadtree; - - x: { - (): (d: any) => any; - (accesor: (d: any) => any): QuadtreeFactory; - - } - y: { - (): (d: any) => any; - (accesor: (d: any) => any): QuadtreeFactory; - - } - size(): number[]; - size(size: number[]): QuadtreeFactory; - extent(): number[][]; - extent(points: number[][]): QuadtreeFactory; - } - - export interface Quadtree { - /** - * Adds a new point to the quadtree. - */ - add(point: Point): void; - visit(callback: any): void; - } - - export interface Point { - x: number; - y: number; - } - - export interface Voronoi { - /** - * Compute the Voronoi diagram for the specified data. - */ - (data: T[]): Polygon[]; - /** - * Compute the graph links for the Voronoi diagram for the specified data. - */ - links(data: T[]): Layout.GraphLink[]; - /** - * Compute the triangles for the Voronoi diagram for the specified data. - */ - triangles(data: T[]): number[][]; - x: { - /** - * Get the x-coordinate accessor. - */ - (): (data: T, index ?: number) => number; - - /** - * Set the x-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: T, index: number) => number): Voronoi; - - /** - * Set the x-coordinate to a constant. - * - * @param constant The new constant value. - */ - (constant: number): Voronoi; - } - y: { - /** - * Get the y-coordinate accessor. - */ - (): (data: T, index ?: number) => number; - - /** - * Set the y-coordinate accessor. - * - * @param accessor The new accessor function - */ - (accessor: (data: T, index: number) => number): Voronoi; - - /** - * Set the y-coordinate to a constant. - * - * @param constant The new constant value. - */ - (constant: number): Voronoi; - } - clipExtent: { - /** - * Get the clip extent. - */ - (): number[][]; - /** - * Set the clip extent. - * - * @param extent The new clip extent. - */ - (extent: number[][]): Voronoi; - } - size: { - /** - * Get the size. - */ - (): number[]; - /** - * Set the size, equivalent to a clip extent starting from (0,0). - * - * @param size The new size. - */ - (size: number[]): Voronoi; - } - } - - export interface Hull { - (vertices: Vertice[]): Vertice[]; - x: { - (): (d: any) => any; - (accesor: (d: any) => any): any; - } - y: { - (): (d: any) => any; - (accesor: (d: any) => any): any; - } - } - } -} - -declare var d3: D3.Base; - -declare module "d3" { - export = d3; -} +// Type definitions for d3JS +// Project: http://d3js.org/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module d3 { + /** + * The current version of D3.js. + */ + export var version: string; + + /** + * Find the first element that matches the given selector string. + */ + export function select(selector: string): Selection; + + /** + * Create a selection from the given node reference. + */ + export function select(node: EventTarget): Selection; + + /** + * Find all elements that match the given selector string. + */ + export function selectAll(selector: string): Selection; + + /** + * Create a selection from the given list of nodes. + */ + export function selectAll(nodes: EventTarget[]): Selection; + + /** + * Returns the root selection (as if by d3.select(document.documentElement)). This function may be used for 'instanceof' tests, and extending its prototype will add properties to all selections. + */ + export function selection(): Selection; + + module selection { + export var prototype: Selection; + + /** + * Selections are grouped into arrays of nodes, with the parent tracked in the 'parentNode' property. + */ + interface Group extends Array { + parentNode: EventTarget; + } + + interface Update { + /** + * Retrieve a grouped selection. + */ + [index: number]: Group; + + /** + * The number of groups in this selection. + */ + length: number; + + /** + * Retrieve the value of the given attribute for the first node in the selection. + * + * @param name The attribute name to query. May be prefixed (see d3.ns.prefix). + */ + attr(name: string): string; + + /** + * For all nodes, set the attribute to the specified constant value. Use null to remove. + * + * @param name The attribute name, optionally prefixed. + * @param value The attribute value to use. Note that this is coerced to a string automatically. + */ + attr(name: string, value: Primitive): Update; + + /** + * Derive an attribute value for each node in the selection based on bound data. + * + * @param name The attribute name, optionally prefixed. + * @param value The function of the datum (the bound data item) and index (the position in the subgrouping) which computes the attribute value. If the function returns null, the attribute is removed. + */ + attr(name: string, value: (datum: Datum, index: number) => Primitive): Update; + + /** + * Set multiple properties at once using an Object. D3 iterates over all enumerable properties and either sets or computes the attribute's value based on the corresponding entry in the Object. + * + * @param obj A key-value mapping corresponding to attributes and values. If the value is a simple string or number, it is taken as a constant. Otherwise, it is a function that derives the attribute value. + */ + attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Update; + + /** + * Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match. + * + * @param name The class list to query. + */ + classed(name: string): boolean; + + /** + * Adds (or removes) the given class list. + * + * @param name The class list to toggle. Spaces separate class names: "foo bar" is a list of two classes. + * @param value If true, add the classes. If false, remove them. + */ + classed(name: string, value: boolean): Update; + + /** + * Determine if the given class list should be toggled for each node in the selection. + * + * @param name The class list. Spaces separate multiple class names. + * @param value The function to run for each node. Should return true to add the class to the node, or false to remove it. + */ + classed(name: string, value: (datum: Datum, index: number) => boolean): Update; + + /** + * Set or derive classes for multiple class lists at once. + * + * @param obj An Object mapping class lists to values that are either plain booleans or functions that return booleans. + */ + classed(obj: { [key: string]: boolean | ((datum: Datum, index: number) => boolean) }): Update; + + /** + * Retrieve the computed style value for the first node in the selection. + * @param name The CSS property name to query + */ + style(name: string): string; + + /** + * Set a style property for all nodes in the selection. + * @param name the CSS property name + * @param value the property value + * @param priority if specified, either null or the string "important" (no exclamation mark) + */ + style(name: string, value: Primitive, priority?: string): Update; + + /** + * Derive a property value for each node in the selection. + * @param name the CSS property name + * @param value the function to derive the value + * @param priority if specified, either null or the string "important" (no exclamation mark) + */ + style(name: string, value: (datum: Datum, index: number) => Primitive, priority?: string): Update; + + /** + * Set a large number of CSS properties from an object. + * + * @param obj an Object whose keys correspond to CSS property names and values are either constants or functions that derive property values + * @param priority if specified, either null or the string "important" (no exclamation mark) + */ + style(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }, priority?: string): Update; + + /** + * Retrieve an arbitrary node property such as the 'checked' property of checkboxes, or the 'value' of text boxes. + * + * @param name the node's property to retrieve + */ + property(name: string): any; + + /** + * For each node, set the property value. Internally, this sets the node property directly (e.g., node[name] = value), so take care not to mutate special properties like __proto__. + * + * @param name the property name + * @param value the property value + */ + property(name: string, value: any): Update; + + /** + * For each node, derive the property value. Internally, this sets the node property directly (e.g., node[name] = value), so take care not to mutate special properties like __proto__. + * + * @param name the property name + * @param value the function used to derive the property's value + */ + property(name: string, value: (datum: Datum, index: number) => any): Update; + + /** + * Set multiple node properties. Caveats apply: take care not to mutate special properties like __proto__. + * + * @param obj an Object whose keys correspond to node properties and values are either constants or functions that will compute a value. + */ + property(obj: { [key: string]: any | ((datum: Datum, index: number) => any) }): Update; + + /** + * Retrieve the textContent of the first node in the selection. + */ + text(): string; + + /** + * Set the textContent of each node in the selection. + * @param value the text to use for all nodes + */ + text(value: Primitive): Update; + + /** + * Compute the textContent of each node in the selection. + * @param value the function which will compute the text + */ + text(value: (datum: Datum, index: number) => Primitive): Update; + + /** + * Retrieve the HTML content of the first node in the selection. Uses 'innerHTML' internally and will not work with SVG or other elements without a polyfill. + */ + html(): string; + + /** + * Set the HTML content of every node in the selection. Uses 'innerHTML' internally and thus will not work with SVG or other elements without a polyfill. + * @param value the HTML content to use. + */ + html(value: string): Selection; + + /** + * Compute the HTML content for each node in the selection. Uses 'innerHTML' internally and thus will not work with SVG or other elements without a polyfill. + * @param value the function to compute HTML content + */ + html(value: (datum: Datum, index: number) => string): Selection; + + /** + * Appends a new child to each node in the selection. This child will inherit the parent's data (if available). Returns a fresh selection consisting of the newly-appended children. + * + * @param name the element name to append. May be prefixed (see d3.ns.prefix). + */ + append(name: string): Selection; + + /** + * Appends a new child to each node in the selection by computing a new node. This child will inherit the parent's data (if available). Returns a fresh selection consisting of the newly-appended children. + * + * @param name the function to compute a new element + */ + append(name: (datum: Datum, index: number) => EventTarget): Update; + + /** + * Inserts a new child to each node in the selection. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the element name to append. May be prefixed (see d3.ns.prefix). + * @param before the selector to determine position (e.g., ":first-child") + */ + insert(name: string, before: string): Update; + + /** + * Inserts a new child to each node in the selection. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the element name to append. May be prefixed (see d3.ns.prefix). + * @param before a function to determine the node to use as the next sibling + */ + insert(name: string, before: (datum: Datum, index: number) => EventTarget): Update; + + /** + * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the function to compute a new child + * @param before the selector to determine position (e.g., ":first-child") + */ + insert(name: (datum: Datum, index: number) => EventTarget, before: string): Update; + + /** + * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the function to compute a new child + * @param before a function to determine the node to use as the next sibling + */ + insert(name: (datum: Datum, index: number) => EventTarget, before: (datum: Datum, index: number) => EventTarget): Update; + + /** + * Removes the elements from the DOM. They are in a detached state and may be re-added (though there is currently no dedicated API for doing so). + */ + remove(): Update; + + /** + * Retrieves the data bound to the first group in this selection. + */ + data(): Datum[]; + + /** + * Binds data to this selection. + * @param data the array of data to bind to this selection + * @param key the optional function to determine the unique key for each piece of data. When unspecified, uses the index of the element. + */ + data(data: NewDatum[], key?: (datum: NewDatum, index: number) => string): Update; + + /** + * Derives data to bind to this selection. + * @param data the function to derive data. Must return an array. + * @param key the optional function to determine the unique key for each data item. When unspecified, uses the index of the element. + */ + data(data: (datum: Datum, index: number) => NewDatum[], key?: (datum: NewDatum, index: number) => string): Update; + + /** + * Filters the selection, returning only those nodes that match the given CSS selector. + * @param selector the CSS selector + */ + filter(selector: string): Update; + + /** + * Filters the selection, returning only those nodes for which the given function returned true. + * @param selector the filter function + */ + filter(selector: (datum: Datum, index: number) => boolean): Update; + + /** + * Return the data item bound to the first element in the selection. + */ + datum(): Datum; + + /** + * Set the data item for each node in the selection. + * @param value the constant element to use for each node + */ + datum(value: NewDatum): Update; + + /** + * Derive the data item for each node in the selection. Useful for situations such as the HTML5 'dataset' attribute. + * @param value the function to compute data for each node + */ + datum(value: (datum: Datum, index: number) => NewDatum): Update; + + /** + * Reorders nodes in the selection based on the given comparator. Nodes are re-inserted into the document once sorted. + * @param comparator the comparison function, which defaults to d3.ascending + */ + sort(comparator?: (a: Datum, b: Datum) => number): Update; + + /** + * Reorders nodes in the document to match the selection order. More efficient than calling sort() if the selection is already ordered. + */ + order(): Update; + + /** + * Returns the listener (if any) for the given event. + * @param type the type of event to load the listener for. May have a namespace (e.g., ".foo") at the end. + */ + on(type: string): (datum: Datum, index: number) => any; + + /** + * Adds a listener for the specified event. If one was already registered, it is removed before the new listener is added. The return value of the listener function is ignored. + * @param type the of event to listen to. May have a namespace (e.g., ".foo") at the end. + * @param listener an event listener function, or null to unregister + * @param capture sets the DOM useCapture flag + */ + on(type: string, listener: (datum: Datum, index: number) => any, capture?: boolean): Update; + + /** + * Begins a new transition. Interrupts any active transitions of the same name. + * @param name the transition name (defaults to "") + */ + transition(name?: string): Transition; + + /** + * Interrupts the active transition of the provided name. Does not cancel scheduled transitions. + * @param name the transition name (defaults to "") + */ + interrupt(name?: string): Update; + + /** + * Creates a subselection by finding the first descendent matching the selector string. Bound data is inherited. + * @param selector the CSS selector to match against + */ + select(selector: string): Update; + + /** + * Creates a subselection by using a function to find descendent elements. Bound data is inherited. + * @param selector the function to find matching descendants + */ + select(selector: (datum: Datum, index: number) => EventTarget): Update; + + /** + * Creates a subselection by finding all descendents that match the given selector. Bound data is not inherited. + * @param selector the CSS selector to match against + */ + selectAll(selector: string): Update; + + /** + * Creates a subselection by using a function to find descendent elements. Bound data is not inherited. + * @param selector the function to find matching descendents + */ + selectAll(selector: (datum: Datum, index: number) => Array | NodeList): Update; + + /** + * Invoke the given function for each element in the selection. The return value of the function is ignored. + * @param func the function to invoke + */ + each(func: (datum: Datum, index: number) => any): Update; + + /** + * Call a function on the selection. sel.call(foo) is equivalent to foo(sel). + * @param func the function to call on the selection + * @param args any optional args + */ + call(func: (sel: Update, ...args: any[]) => any, ...args: any[]): Update; + + /** + * Returns true if the current selection is empty. + */ + empty(): boolean; + + /** + * Returns the first non-null element in the selection, or null otherwise. + */ + node(): EventTarget; + + /** + * Returns the total number of elements in the selection. + */ + size(): number; + + /** + * Returns the placeholder nodes for each data element for which no corresponding DOM element was found. + */ + enter(): Enter; + + /** + * Returns a selection for those DOM nodes for which no new data element was found. + */ + exit(): Selection; + } + + interface Enter { + append(name: string): Selection; + append(name: (datum: Datum, index: number) => EventTarget): Selection; + + insert(name: string, before?: string): Selection; + insert(name: string, before: (datum: Datum, index: number) => EventTarget): Selection; + insert(name: (datum: Datum, index: number) => EventTarget, before?: string): Selection; + insert(name: (datum: Datum, index: number) => EventTarget, before: (datum: Datum, index: number) => EventTarget): Selection; + + select(name: (datum: Datum, index: number) => EventTarget): Selection; + call(func: (selection: Enter, ...args: any[]) => any, ...args: any[]): Enter; + } + } + + /** + * Administrivia: JavaScript primitive types, or "things that toString() predictably". + */ + export type Primitive = number | string | boolean; + + /** + * Administrivia: anything with a valueOf(): number method is comparable, so we allow it in numeric operations + */ + interface Numeric { + valueOf(): number; + } + + /** + * A grouped array of nodes. + * @param Datum the data bound to this selection. + */ + interface Selection { + /** + * Retrieve a grouped selection. + */ + [index: number]: selection.Group; + + /** + * The number of groups in this selection. + */ + length: number; + + /** + * Retrieve the value of the given attribute for the first node in the selection. + * + * @param name The attribute name to query. May be prefixed (see d3.ns.prefix). + */ + attr(name: string): string; + + /** + * For all nodes, set the attribute to the specified constant value. Use null to remove. + * + * @param name The attribute name, optionally prefixed. + * @param value The attribute value to use. Note that this is coerced to a string automatically. + */ + attr(name: string, value: Primitive): Selection; + + /** + * Derive an attribute value for each node in the selection based on bound data. + * + * @param name The attribute name, optionally prefixed. + * @param value The function of the datum (the bound data item) and index (the position in the subgrouping) which computes the attribute value. If the function returns null, the attribute is removed. + */ + attr(name: string, value: (datum: Datum, index: number) => Primitive): Selection; + + /** + * Set multiple properties at once using an Object. D3 iterates over all enumerable properties and either sets or computes the attribute's value based on the corresponding entry in the Object. + * + * @param obj A key-value mapping corresponding to attributes and values. If the value is a simple string or number, it is taken as a constant. Otherwise, it is a function that derives the attribute value. + */ + attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Selection; + + /** + * Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match. + * + * @param name The class list to query. + */ + classed(name: string): boolean; + + /** + * Adds (or removes) the given class list. + * + * @param name The class list to toggle. Spaces separate class names: "foo bar" is a list of two classes. + * @param value If true, add the classes. If false, remove them. + */ + classed(name: string, value: boolean): Selection; + + /** + * Determine if the given class list should be toggled for each node in the selection. + * + * @param name The class list. Spaces separate multiple class names. + * @param value The function to run for each node. Should return true to add the class to the node, or false to remove it. + */ + classed(name: string, value: (datum: Datum, index: number) => boolean): Selection; + + /** + * Set or derive classes for multiple class lists at once. + * + * @param obj An Object mapping class lists to values that are either plain booleans or functions that return booleans. + */ + classed(obj: { [key: string]: boolean | ((datum: Datum, index: number) => boolean) }): Selection; + + /** + * Retrieve the computed style value for the first node in the selection. + * @param name The CSS property name to query + */ + style(name: string): string; + + /** + * Set a style property for all nodes in the selection. + * @param name the CSS property name + * @param value the property value + * @param priority if specified, either null or the string "important" (no exclamation mark) + */ + style(name: string, value: Primitive, priority?: string): Selection; + + /** + * Derive a property value for each node in the selection. + * @param name the CSS property name + * @param value the function to derive the value + * @param priority if specified, either null or the string "important" (no exclamation mark) + */ + style(name: string, value: (datum: Datum, index: number) => Primitive, priority?: string): Selection; + + /** + * Set a large number of CSS properties from an object. + * + * @param obj an Object whose keys correspond to CSS property names and values are either constants or functions that derive property values + * @param priority if specified, either null or the string "important" (no exclamation mark) + */ + style(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }, priority?: string): Selection; + + /** + * Retrieve an arbitrary node property such as the 'checked' property of checkboxes, or the 'value' of text boxes. + * + * @param name the node's property to retrieve + */ + property(name: string): any; + + /** + * For each node, set the property value. Internally, this sets the node property directly (e.g., node[name] = value), so take care not to mutate special properties like __proto__. + * + * @param name the property name + * @param value the property value + */ + property(name: string, value: any): Selection; + + /** + * For each node, derive the property value. Internally, this sets the node property directly (e.g., node[name] = value), so take care not to mutate special properties like __proto__. + * + * @param name the property name + * @param value the function used to derive the property's value + */ + property(name: string, value: (datum: Datum, index: number) => any): Selection; + + /** + * Set multiple node properties. Caveats apply: take care not to mutate special properties like __proto__. + * + * @param obj an Object whose keys correspond to node properties and values are either constants or functions that will compute a value. + */ + property(obj: { [key: string]: any | ((datum: Datum, index: number) => any) }): Selection; + + /** + * Retrieve the textContent of the first node in the selection. + */ + text(): string; + + /** + * Set the textContent of each node in the selection. + * @param value the text to use for all nodes + */ + text(value: Primitive): Selection; + + /** + * Compute the textContent of each node in the selection. + * @param value the function which will compute the text + */ + text(value: (datum: Datum, index: number) => Primitive): Selection; + + /** + * Retrieve the HTML content of the first node in the selection. Uses 'innerHTML' internally and will not work with SVG or other elements without a polyfill. + */ + html(): string; + + /** + * Set the HTML content of every node in the selection. Uses 'innerHTML' internally and thus will not work with SVG or other elements without a polyfill. + * @param value the HTML content to use. + */ + html(value: string): Selection; + + /** + * Compute the HTML content for each node in the selection. Uses 'innerHTML' internally and thus will not work with SVG or other elements without a polyfill. + * @param value the function to compute HTML content + */ + html(value: (datum: Datum, index: number) => string): Selection; + + /** + * Appends a new child to each node in the selection. This child will inherit the parent's data (if available). Returns a fresh selection consisting of the newly-appended children. + * + * @param name the element name to append. May be prefixed (see d3.ns.prefix). + */ + append(name: string): Selection; + + /** + * Appends a new child to each node in the selection by computing a new node. This child will inherit the parent's data (if available). Returns a fresh selection consisting of the newly-appended children. + * + * @param name the function to compute a new element + */ + append(name: (datum: Datum, index: number) => EventTarget): Selection; + + /** + * Inserts a new child to each node in the selection. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the element name to append. May be prefixed (see d3.ns.prefix). + * @param before the selector to determine position (e.g., ":first-child") + */ + insert(name: string, before: string): Selection; + + /** + * Inserts a new child to each node in the selection. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the element name to append. May be prefixed (see d3.ns.prefix). + * @param before a function to determine the node to use as the next sibling + */ + insert(name: string, before: (datum: Datum, index: number) => EventTarget): Selection; + + /** + * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the function to compute a new child + * @param before the selector to determine position (e.g., ":first-child") + */ + insert(name: (datum: Datum, index: number) => EventTarget, before: string): Selection; + + /** + * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. + * @param name the function to compute a new child + * @param before a function to determine the node to use as the next sibling + */ + insert(name: (datum: Datum, index: number) => EventTarget, before: (datum: Datum, index: number) => EventTarget): Selection; + + /** + * Removes the elements from the DOM. They are in a detached state and may be re-added (though there is currently no dedicated API for doing so). + */ + remove(): Selection; + + /** + * Retrieves the data bound to the first group in this selection. + */ + data(): Datum[]; + + /** + * Binds data to this selection. + * @param data the array of data to bind to this selection + * @param key the optional function to determine the unique key for each piece of data. When unspecified, uses the index of the element. + */ + data(data: NewDatum[], key?: (datum: NewDatum, index: number) => string): selection.Update; + + /** + * Derives data to bind to this selection. + * @param data the function to derive data. Must return an array. + * @param key the optional function to determine the unique key for each data item. When unspecified, uses the index of the element. + */ + data(data: (datum: Datum, index: number) => NewDatum[], key?: (datum: NewDatum, index: number) => string): selection.Update; + + /** + * Filters the selection, returning only those nodes that match the given CSS selector. + * @param selector the CSS selector + */ + filter(selector: string): Selection; + + /** + * Filters the selection, returning only those nodes for which the given function returned true. + * @param selector the filter function + */ + filter(selector: (datum: Datum, index: number) => boolean): Selection; + + /** + * Return the data item bound to the first element in the selection. + */ + datum(): Datum; + + /** + * Derive the data item for each node in the selection. Useful for situations such as the HTML5 'dataset' attribute. + * @param value the function to compute data for each node + */ + datum(value: (datum: Datum, index: number) => NewDatum): Selection; + + /** + * Set the data item for each node in the selection. + * @param value the constant element to use for each node + */ + datum(value: NewDatum): Selection; + + /** + * Reorders nodes in the selection based on the given comparator. Nodes are re-inserted into the document once sorted. + * @param comparator the comparison function, which defaults to d3.ascending + */ + sort(comparator?: (a: Datum, b: Datum) => number): Selection; + + /** + * Reorders nodes in the document to match the selection order. More efficient than calling sort() if the selection is already ordered. + */ + order(): Selection; + + /** + * Returns the listener (if any) for the given event. + * @param type the type of event to load the listener for. May have a namespace (e.g., ".foo") at the end. + */ + on(type: string): (datum: Datum, index: number) => any; + + /** + * Adds a listener for the specified event. If one was already registered, it is removed before the new listener is added. The return value of the listener function is ignored. + * @param type the of event to listen to. May have a namespace (e.g., ".foo") at the end. + * @param listener an event listener function, or null to unregister + * @param capture sets the DOM useCapture flag + */ + on(type: string, listener: (datum: Datum, index: number) => any, capture?: boolean): Selection; + + /** + * Begins a new transition. Interrupts any active transitions of the same name. + * @param name the transition name (defaults to "") + */ + transition(name?: string): Transition; + + /** + * Interrupts the active transition of the provided name. Does not cancel scheduled transitions. + * @param name the transition name (defaults to "") + */ + interrupt(name?: string): Selection; + + /** + * Creates a subselection by finding the first descendent matching the selector string. Bound data is inherited. + * @param selector the CSS selector to match against + */ + select(selector: string): Selection; + + /** + * Creates a subselection by using a function to find descendent elements. Bound data is inherited. + * @param selector the function to find matching descendants + */ + select(selector: (datum: Datum, index: number) => EventTarget): Selection; + + /** + * Creates a subselection by finding all descendents that match the given selector. Bound data is not inherited. + * @param selector the CSS selector to match against + */ + selectAll(selector: string): Selection; + + /** + * Creates a subselection by finding all descendants that match the given selector. Bound data is not inherited. + * + * Use this overload when data-binding a subselection (that is, sel.selectAll('.foo').data(d => ...)). The type will carry over. + */ + selectAll(selector: string): Selection; + + /** + * Creates a subselection by using a function to find descendent elements. Bound data is not inherited. + * @param selector the function to find matching descendents + */ + selectAll(selector: (datum: Datum, index: number) => Array | NodeList): Selection; + + /** + * Creates a subselection by using a function to find descendent elements. Bound data is not inherited. + * + * Use this overload when data-binding a subselection (that is, sel.selectAll('.foo').data(d => ...)). The type will carry over. + * @param selector the function to find matching descendents + */ + selectAll(selector: (datum: Datum, index: number) => Array | NodeList): Selection; + + /** + * Invoke the given function for each element in the selection. The return value of the function is ignored. + * @param func the function to invoke + */ + each(func: (datum: Datum, index: number) => any): Selection; + + /** + * Call a function on the selection. sel.call(foo) is equivalent to foo(sel). + * @param func the function to call on the selection + * @param args any optional args + */ + call(func: (sel: Selection, ...args: any[]) => any, ...args: any[]): Selection; + + /** + * Returns true if the current selection is empty. + */ + empty(): boolean; + + /** + * Returns the first non-null element in the selection, or null otherwise. + */ + node(): EventTarget; + + /** + * Returns the total number of elements in the selection. + */ + size(): number; + } + + export function transition(): Transition; + module transition { + export var prototype: Transition; + } + + interface Transition { + delay(): number; + delay(delay: number): Transition; + delay(delay: (datum: Datum, index: number) => number): Transition; + + duration(): number; + duration(duration: number): Transition; + duration(duration: (datum: Datum, index: number) => number): Transition; + + ease(): (t: number) => number; + ease(value: string, ...args: any[]): Transition; + ease(value: (t: number) => number): Transition; + + attr(name: string, value: Primitive): Transition; + attr(name: string, value: (datum: Datum, index: number) => Primitive): Transition; + attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Transition; + + attrTween(name: string, tween: (datum: Datum, index: number, attr: string) => Primitive): Transition; + + style(name: string, value: Primitive, priority?: string): Transition; + style(name: string, value: (datum: Datum, index: number) => Primitive, priority?: string): Transition; + style(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }, priority?: string): Transition; + + styleTween(name: string, tween: (datum: Datum, index: number, attr: string) => Primitive, priority?: string): Transition; + + text(value: Primitive): Transition; + text(value: (datum: Datum, index: number) => Primitive): Transition; + + tween(name: string, factory: () => (t: number) => any): Transition; + + remove(): Transition; + + select(selector: string): Transition; + select(selector: (d: Datum, i: number) => EventTarget): Transition; + + selectAll(selector: string): Transition; + selectAll(selector: (d: Datum, i: number) => EventTarget[]): Transition; + + filter(selector: string): Transition; + filter(selector: (d: Datum, i: number) => boolean): Transition; + + each(type: string, listener: (d: Datum, i: number) => any): Transition; + each(listener: (d: Datum, i: number) => any): Transition; + + call(func: (transition: Transition, ...args: any[]) => any, ...args: any[]): Transition; + + empty(): boolean; + node(): EventTarget; + size(): number; + } + + export function ease(type: 'linear'): (t: number) => number; + export function ease(type: 'linear-in'): (t: number) => number; + export function ease(type: 'linear-out'): (t: number) => number; + export function ease(type: 'linear-in-out'): (t: number) => number; + export function ease(type: 'linear-out-in'): (t: number) => number; + + export function ease(type: 'poly', k: number): (t: number) => number; + export function ease(type: 'poly-in', k: number): (t: number) => number; + export function ease(type: 'poly-out', k: number): (t: number) => number; + export function ease(type: 'poly-in-out', k: number): (t: number) => number; + export function ease(type: 'poly-out-in', k: number): (t: number) => number; + + export function ease(type: 'quad'): (t: number) => number; + export function ease(type: 'quad-in'): (t: number) => number; + export function ease(type: 'quad-out'): (t: number) => number; + export function ease(type: 'quad-in-out'): (t: number) => number; + export function ease(type: 'quad-out-in'): (t: number) => number; + + export function ease(type: 'cubic'): (t: number) => number; + export function ease(type: 'cubic-in'): (t: number) => number; + export function ease(type: 'cubic-out'): (t: number) => number; + export function ease(type: 'cubic-in-out'): (t: number) => number; + export function ease(type: 'cubic-out-in'): (t: number) => number; + + export function ease(type: 'sin'): (t: number) => number; + export function ease(type: 'sin-in'): (t: number) => number; + export function ease(type: 'sin-out'): (t: number) => number; + export function ease(type: 'sin-in-out'): (t: number) => number; + export function ease(type: 'sin-out-in'): (t: number) => number; + + export function ease(type: 'circle'): (t: number) => number; + export function ease(type: 'circle-in'): (t: number) => number; + export function ease(type: 'circle-out'): (t: number) => number; + export function ease(type: 'circle-in-out'): (t: number) => number; + export function ease(type: 'circle-out-in'): (t: number) => number; + + export function ease(type: 'elastic', a?: number, b?: number): (t: number) => number; + export function ease(type: 'elastic-in', a?: number, b?: number): (t: number) => number; + export function ease(type: 'elastic-out', a?: number, b?: number): (t: number) => number; + export function ease(type: 'elastic-in-out', a?: number, b?: number): (t: number) => number; + export function ease(type: 'elastic-out-in', a?: number, b?: number): (t: number) => number; + + export function ease(type: 'back', s: number): (t: number) => number; + export function ease(type: 'back-in', s: number): (t: number) => number; + export function ease(type: 'back-out', s: number): (t: number) => number; + export function ease(type: 'back-in-out', s: number): (t: number) => number; + export function ease(type: 'back-out-in', s: number): (t: number) => number; + + export function ease(type: 'bounce'): (t: number) => number; + export function ease(type: 'bounce-in'): (t: number) => number; + export function ease(type: 'bounce-out'): (t: number) => number; + export function ease(type: 'bounce-in-out'): (t: number) => number; + export function ease(type: 'bounce-out-in'): (t: number) => number; + + export function ease(type: string, ...args: any[]): (t: number) => number; + + export function timer(func: () => any, delay?: number, time?: number): void; + + module timer { + export function flush(): void; + } + + /** + * The current event's value. Use this variable in a handler registered with selection.on. + */ + export var event: Event; + + /** + * Returns the x and y coordinates of the mouse relative to the provided container element, using d3.event for the mouse's position on the page. + * @param container the container element (e.g. an SVG element) + */ + export function mouse(container: EventTarget): [number, number]; + + /** + * Given a container element and a touch identifier, determine the x and y coordinates of the touch. + * @param container the container element (e.g., an SVG element) + * @param identifier the given touch identifier + */ + export function touch(container: EventTarget, identifer: number): [number, number]; + + /** + * Given a container element, a list of touches, and a touch identifier, determine the x and y coordinates of the touch. + * @param container the container element (e.g., an SVG element) + * @param identifier the given touch identifier + */ + export function touch(container: EventTarget, touches: TouchList, identifer: number): [number, number]; + + /** + * Given a container element and an optional list of touches, return the position of every touch relative to the container. + * @param container the container element + * @param touches an optional list of touches (defaults to d3.event.touches) + */ + export function touches(container: EventTarget, touches?: TouchList): Array<[number, number]>; + + // NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances. + /** + * Compares two primitive values for sorting (in ascending order). + */ + export function ascending(a: Primitive, b: Primitive): number; + + /** + * Compares two primitive values for sorting (in ascending order). + */ + export function descending(a: Primitive, b: Primitive): number; + + /** + * Return the minimum value in the array using natural order. + */ + export function min(array: number[]): number; + + /** + * Return the minimum value in the array using natural order. + */ + export function min(array: string[]): string; + + /** + * Return the minimum value in the array using natural order. + */ + export function min(array: T[]): T; + + /** + * Return the minimum value in the array using natural order. + */ + export function min(array: T[], accessor: (datum: T, index: number) => number): number; + + /** + * Return the minimum value in the array using natural order. + */ + export function min(array: T[], accessor: (datum: T, index: number) => string): string; + + /** + * Return the minimum value in the array using natural order. + */ + export function min(array: T[], accessor: (datum: T, index: number) => U): U; + + /** + * Return the maximum value in the array of numbers using natural order. + */ + export function max(array: number[]): number; + + /** + * Return the maximum value in the array of strings using natural order. + */ + export function max(array: string[]): string; + + /** + * Return the maximum value in the array of numbers using natural order. + */ + export function max(array: T[]): T; + + /** + * Return the maximum value in the array using natural order and a projection function to map values to numbers. + */ + export function max(array: T[], accessor: (datum: T, index: number) => number): number; + + /** + * Return the maximum value in the array using natural order and a projection function to map values to strings. + */ + export function max(array: T[], accessor: (datum: T, index: number) => string): string; + + /** + * Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values. + */ + export function max(array: T[], accessor: (datum: T, index: number) => U): U; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: number[]): [number, number]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: string[]): [string, string]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: T[]): [T, T]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: Array): [T | Primitive, T | Primitive]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: T[], accessor: (datum: T, index: number) => number): [number, number]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: T[], accessor: (datum: T, index: number) => string): [string, string]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: U[], accessor: (datum: T, index: number) => U): [U | Primitive, U | Primitive]; + + /** + * Compute the sum of an array of numbers. + */ + export function sum(array: number[]): number; + + /** + * Compute the sum of an array, using the given accessor to convert values to numbers. + */ + export function sum(array: T[], accessor: (datum: T, index: number) => number): number; + + export function mean(array: number[]): number; + export function mean(array: T[], accessor: (datum: T, index: number) => number): number; + + export function quantile(array: number[], p: number): number; + + export function variance(array: number[]): number; + export function variance(array: T[], accessor: (datum: T, index: number) => number): number; + + export function deviation(array: number[]): number; + export function deviation(array: T[], accessor: (datum: T, index: number) => number): number; + + export function bisectLeft(array: number[], x: number, lo?: number, hi?: number): number; + export function bisectLeft(array: string[], x: string, lo?: number, hi?: number): number; + + export var bisect: typeof bisectRight; + + export function bisectRight(array: T[], x: T, lo?: number, hi?: number): number; + + export function bisector(accessor: (x: T) => U): { + left: (array: T[], x: T, lo?: number, hi?: number) => number; + right: (array: T[], x: T, lo?: number, hi?: number) => number; + } + + export function bisector(comparator: (a: T, b: U) => number): { + left: (array: T[], x: U, lo?: number, hi?: number) => number; + right: (array: T[], x: U, lo?: number, hi?: number) => number; + } + + export function shuffle(array: T[], lo?: number, hi?: number): T[]; + + /** + * Returns the enumerable property names of the specified object. + * @param object a JavaScript object + */ + export function keys(object: Object): string[]; + + /** + * Returns an array containing the property values of the specified object. + */ + export function values(object: { [key: string]: T }): T[]; + /** + * Returns an array containing the property values of the specified object. + */ + export function values(object: { [key: number]: T }): T[]; + /** + * Returns an array containing the property values of the specified object. + */ + export function values(object: Object): any[]; + + /** + * Returns an array of key-value pairs containing the property values of the specified object. + */ + export function entries(object: { [key: string]: T }): { key: string; value: T }[]; + + /** + * Returns an array of key-value pairs containing the property values of the specified object. + */ + export function entries(object: { [key: number]: T }): { key: string; value: T }[]; + + /** + * Returns an array of key-value pairs containing the property values of the specified object. + */ + export function entries(object: Object): { key: string; value: any }[]; + + /** + * A shim for ES6 maps. The implementation uses a JavaScript object internally, and thus keys are limited to strings. + */ + interface Map { + /** + * Does the map contain the given key? + */ + has(key: string): boolean; + + /** + * Retrieve the value for the given key. Returns undefined if there is no value stored. + */ + get(key: string): T; + + /** + * Set the value for the given key. Returns the new value. + */ + set(key: string, value: T): T; + + /** + * Remove the value for the given key. Returns true if there was a value and false otherwise. + */ + remove(key: string): boolean; + + /** + * Returns an array of all keys in arbitrary order. + */ + keys(): string[]; + + /** + * Returns an array of all values in arbitrary order. + */ + values(): T[]; + + /** + * Returns an array of key-value objects in arbitrary order. + */ + entries(): { key: string; value: T }[]; + + /** + * Calls the function for each key and value pair in the map. The 'this' context is the map itself. + */ + forEach(func: (key: string, value: T) => any): void; + + /** + * Is this map empty? + */ + empty(): boolean; + + /** + * Returns the number of elements stored in the map. + */ + size(): number; + } + + /** + * Constructs an initially empty map. + */ + export function map(): Map; + + /** + * Construct a new map by copying keys and values from the given one. + */ + export function map(object: Map): Map; + + /** + * Construct a new map by copying enumerable properties and values from the given object. + */ + export function map(object: { [key: string]: T }): Map; + + /** + * Construct a new map by copying enumerable properties and values from the given object. + */ + export function map(object: { [key: number]: T }): Map; + + /** + * Construct a new map by copying elements from the array. The key function is used to identify each object. + */ + export function map(array: T[], key: (datum: T, index: number) => string): Map; + + /** + * Construct a new map by copying enumerable properties and values from the given object. + */ + export function map(object: Object): Map; + + /** + * A shim for ES6 sets. Is only able to store strings. + */ + interface Set { + /** + * Is the given string stored in this set? + */ + has(value: string): boolean; + + /** + * Add the string to this set. Returns the value. + */ + add(value: string): string; + + /** + * Remove the given value from the set. Returns true if it was stored, and false otherwise. + */ + remove(value: string): boolean; + + /** + * Returns an array of the strings stored in this set. + */ + values(): string[]; + + /** + * Calls a given function for each value in the set. The return value of the function is ignored. The this context of the function is the set itself. + */ + forEach(func: (value: string) => any): void; + + /** + * Is this set empty? + */ + empty(): boolean; + + /** + * Returns the number of values stored in this set. + */ + size(): number; + } + + /** + * Creates an initially-empty set. + */ + export function set(): Set; + + /** + * Initializes a set from the given array of strings. + */ + export function set(array: string[]): Set; + + /** + * Merges the specified arrays into a single array. + */ + export function merge(arrays: T[][]): T[]; + + /** + * Generates a 0-based numeric sequence. The output range does not include 'stop'. + */ + export function range(stop: number): number[]; + + /** + * Generates a numeric sequence starting from the given start and stop values. 'step' defaults to 1. The output range does not include 'stop'. + */ + export function range(start: number, stop: number, step?: number): number[]; + + /** + * Given the specified array, return an array corresponding to the list of indices in 'keys'. + */ + export function permute(array: { [key: number]: T }, keys: number[]): T[]; + + /** + * Given the specified object, return an array corresponding to the list of property names in 'keys'. + */ + export function permute(object: { [key: string]: T }, keys: string[]): T[]; + + // TODO construct n-tuples from n input arrays + export function zip(...arrays: T[][]): T[][]; + + export function transpose(matrix: T[][]): T[][]; + + /** + * For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1. + * Returns the empty array if the input array has fewer than two elements. + */ + export function pairs(array: T[]): Array<[T, T]>; + + interface Nest { + key(func: (datum: T) => string): Nest; + sortKeys(comparator: (a: string, b: string) => number): Nest; + sortValues(comparator: (a: T, b: T) => number): Nest; + rollup(func: (values: T[]) => U): Nest; + map(array: T[]): { [key: string]: any }; + map(array: T[], mapType: typeof d3.map): Map; + entries(array: T[]): { key: string; values: any }[]; + } + + export function nest(): Nest; + + export module random { + export function normal(mean?: number, deviation?: number): () => number; + export function logNormal(mean?: number, deviation?: number): () => number; + export function bates(count: number): () => number; + export function irwinHall(count: number): () => number; + } + + interface Transform { + rotate: number; + translate: [number, number]; + skew: number; + scale: [number, number]; + toString(): string; + } + + export function transform(transform: string): Transform; + + export function format(specifier: string): (n: number) => string; + + interface FormatPrefix { + symbol: string; + scale(n: number): number; + } + + export function formatPrefix(value: number, precision?: number): FormatPrefix; + + export function round(x: number, n?: number): number; + + export function requote(string: string): string; + + export var rgb: { + new (r: number, g: number, b: number): Rgb; + new (color: string): Rgb; + + (r: number, g: number, b: number): Rgb; + (color: string): Rgb; + }; + + interface Rgb extends Color { + r: number; + g: number; + b: number; + + brighter(k?: number): Rgb; + darker(k?: number): Rgb; + + hsl(): Hsl; + + toString(): string; + } + + export var hsl: { + new (h: number, s: number, l: number): Hsl; + new (color: string): Hsl; + + (h: number, s: number, l: number): Hsl; + (color: string): Hsl; + }; + + interface Hsl extends Color { + h: number; + s: number; + l: number; + + brighter(k?: number): Hsl; + darker(k?: number): Hsl; + + rgb(): Rgb; + + toString(): string; + } + + export var hcl: { + new (h: number, c: number, l: number): Hcl; + new (color: string): Hcl; + + (h: number, c: number, l: number): Hcl; + (color: string): Hcl; + }; + + interface Hcl extends Color { + h: number; + c: number; + l: number; + + brighter(k?: number): Hcl; + darker(k?: number): Hcl; + } + + export var lab: { + new (l: number, a: number, b: number): Lab; + new (color: string): Lab; + + (l: number, a: number, b: number): Lab; + (color: string): Lab; + } + + interface Lab extends Color { + l: number; + a: number; + b: number; + + brighter(k?: number): Lab; + darker(k?: number): Lab; + + rgb(): Rgb; + toString(): string; + } + + export var color: { + (): Color; + new (): Color; + }; + + interface Color { + rgb(): Rgb; + } + + export module ns { + interface Qualified { + space: string; + local: string; + } + + export var prefix: { [key: string]: string }; + export function qualify(name: string): Qualified | string; + } + + export function functor(value: T): T; + export function functor(value: T): () => T; + + export function rebind(target: {}, source: {}, ...names: string[]): any; + + export function dispatch(...names: string[]): Dispatch; + + interface Dispatch { + on(type: string): (...args: any[]) => void; + on(type: string, listener: (...args: any[]) => any): Dispatch; + [event: string]: (...args: any[]) => void; + } + + export module scale { + export function identity(): Identity; + + interface Identity { + (n: number): number; + invert(n: number): number; + + domain(): number[]; + domain(numbers: number[]): Identity; + + range(): number[]; + range(numbers: number[]): Identity; + + ticks(count?: number): number[]; + + tickFormat(count?: number, format?: string): (n: number) => string; + + copy(): Identity; + } + + export function linear(): Linear; + export function linear(): Linear; + export function linear(): Linear; + + interface Linear { + (x: number): Output; + invert(y: number): number; + + domain(): number[]; + domain(numbers: number[]): Linear; + + range(): Range[]; + range(values: Range[]): Linear; + + rangeRound(values: number[]): Linear; + + interpolate(): (a: Range, b: Range) => (t: number) => Output; + interpolate(factory: (a: Range, b: Range) => (t: number) => Output): Linear; + + clamp(): boolean; + clamp(clamp: boolean): Linear; + + ticks(count?: number): number[]; + + tickFormat(count?: number, format?: string): (n: number) => string; + + copy(): Linear; + } + + export function sqrt(): Pow; + export function sqrt(): Pow; + export function pow(): Pow; + export function pow(): Pow; + + interface Pow { + (x: number): Output; + + invert(y: number): number; + + domain(): number[]; + domain(numbers: number[]): Pow; + + range(): Range[]; + range(values: Range[]): Pow; + + rangeRound(values: number[]): Pow; + + exponent(): number; + exponent(k: number): Pow; + + interpolate(): (a: Range, b: Range) => (t: number) => Output; + interpolate(factory: (a: Range, b: Range) => (t: number) => Output): Pow; + + clamp(): boolean; + clamp(clamp: boolean): Pow; + + nice(m?: number): Pow; + + ticks(count?: number): number[]; + + tickFormat(count?: number, format?: string): (n: number) => string; + + copy(): Pow; + } + + export function log(): Log; + export function log(): Log; + + interface Log { + (x: number): Output; + + invert(y: number): number; + + domain(): number[]; + domain(numbers: number[]): Log; + + range(): Range[]; + range(values: Range[]): Log; + + rangeRound(values: number[]): Log; + + base(): number; + base(base: number): Log; + + interpolate(): (a: Range, b: Range) => (t: number) => Output; + interpolate(factory: (a: Range, b: Range) => (t: number) => Output): Log; + + clamp(): boolean; + clamp(clamp: boolean): Log; + + nice(): Log; + + ticks(): number[]; + + tickFormat(count?: number, format?: string): (t: number) => string; + + copy(): Log; + } + + export function quantize(): Quantize; + + interface Quantize { + (x: number): T; + + invertExtent(y: T): [number, number]; + + domain(): number[]; + domain(numbers: number[]): Quantize; + + range(): T[]; + range(values: T[]): Quantize; + + copy(): Quantize; + } + + export function quantile(): Quantile; + + interface Quantile { + (x: number): T; + + invertExtent(y: T): [number, number]; + + domain(): number[]; + domain(numbers: number[]): Quantile; + + range(): T[]; + range(values: T[]): Quantile; + + quantiles(): number[]; + + copy(): Quantile; + } + + export function threshold(): Threshold; + export function threshold(): Threshold; + + interface Threshold { + (x: number): Range; + + invertExtent(y: Range): [Domain, Domain]; + + domain(): Domain[]; + domain(domain: Domain[]): Threshold; + + range(): Range[]; + range(values: Range[]): Threshold; + + copy(): Threshold; + } + + export function ordinal(): Ordinal; + export function category10(): Ordinal; + export function category20(): Ordinal; + export function category20b(): Ordinal; + export function category20c(): Ordinal; + + interface Ordinal { + (x: Primitive): T; + + domain(): string[]; + domain(values: Primitive[]): Ordinal; + + range(): T[]; + range(values: T[]): Ordinal; + + rangePoints(interval: [number, number], padding?: number): Ordinal; + rangeRoundPoints(interval: [number, number], padding?: number): Ordinal; + + rangeBands(interval: [number, number], padding?: number, outerPadding?: number): Ordinal; + rangeRoundBands(interval: [number, number], padding?: number, outerPadding?: number): Ordinal; + + rangeBand(): number; + rangeExtent(): [number, number]; + + copy(): Ordinal; + } + } + + export function interpolate(a: number, b: number): (t: number) => number; + export function interpolate(a: string, b: string): (t: number) => string; + export function interpolate(a: string | Color, b: Color): (t: number) => string; + export function interpolate(a: Array, b: Color[]): (t: number) => string; + export function interpolate(a: Range[], b: Output[]): (t: number) => Output[]; + export function interpolate(a: Range[], b: Range[]): (t: number) => Output[]; + export function interpolate(a: { [key: string]: string | Color }, b: { [key: string]: Color }): (t: number) => { [key: string]: string }; + export function interpolate(a: { [key: string]: Range }, b: { [key: string]: Output }): (t: number) => { [key: string]: Output }; + export function interpolate(a: { [key: string]: Range }, b: { [key: string]: Range }): (t: number) => { [key: string]: Output }; + + export function interpolateNumber(a: number, b: number): (t: number) => number; + + export function interpolateRound(a: number, b: number): (t: number) => number; + + export function interpolateString(a: string, b: string): (t: number) => string; + + export function interpolateRgb(a: string | Color, b: string | Color): (t: number) => string; + + export function interpolateHsl(a: string | Color, b: string | Color): (t: number) => string; + + export function interpolateLab(a: string | Color, b: string | Color): (t: number) => string; + + export function interpolateHcl(a: string | Color, b: string | Color): (t: number) => string; + + export function interpolateArray(a: Array, b: Color[]): (t: number) => string[]; + export function interpolateArray(a: Range[], b: Range[]): (t: number) => Output[]; + export function interpolateArray(a: Range[], b: Output[]): (t: number) => Output[]; + + export function interpolateObject(a: { [key: string]: string | Color }, b: { [key: string]: Color }): (t: number) => { [key: string]: string }; + export function interpolateObject(a: { [key: string]: Range }, b: { [key: string]: Output }): (t: number) => { [key: string]: Output }; + export function interpolateObject(a: { [key: string]: Range }, b: { [key: string]: Range }): (t: number) => { [key: string]: Output }; + + export function interpolateTransform(a: string | Transform, b: string | Transform): (t: number) => string; + + export function interpolateZoom(a: [number, number, number], b: [number, number, number]): { + (t: number): [number, number, number]; + duration: number; + }; + + export var interpolators: Array<(a: any, b: any) => (t: number) => any>; + + export module time { + export var second: Interval; + export var minute: Interval; + export var hour: Interval; + export var day: Interval; + export var week: Interval; + export var sunday: Interval; + export var monday: Interval; + export var tuesday: Interval; + export var wednesday: Interval; + export var thursday: Interval; + export var friday: Interval; + export var saturday: Interval; + export var month: Interval; + export var year: Interval; + + interface Interval { + (d: Date): Date; + + floor(d: Date): Date; + + round(d: Date): Date; + + ceil(d: Date): Date; + + range(start: Date, stop: Date, step?: number): Date[]; + + offset(date: Date, step: Date): Date; + + utc: { + (d: Date): Date; + + floor(d: Date): Date; + + round(d: Date): Date; + + ceil(d: Date): Date; + + range(start: Date, stop: Date, step?: number): Date[]; + + offset(date: Date, step: Date): Date; + } + } + + export function seconds(start: Date, stop: Date, step?: number): Date[]; + export function minutes(start: Date, stop: Date, step?: number): Date[]; + export function hours(start: Date, stop: Date, step?: number): Date[]; + export function days(start: Date, stop: Date, step?: number): Date[]; + export function weeks(start: Date, stop: Date, step?: number): Date[]; + export function sundays(start: Date, stop: Date, step?: number): Date[]; + export function mondays(start: Date, stop: Date, step?: number): Date[]; + export function tuesdays(start: Date, stop: Date, step?: number): Date[]; + export function wednesdays(start: Date, stop: Date, step?: number): Date[]; + export function thursdays(start: Date, stop: Date, step?: number): Date[]; + export function fridays(start: Date, stop: Date, step?: number): Date[]; + export function saturdays(start: Date, stop: Date, step?: number): Date[]; + export function months(start: Date, stop: Date, step?: number): Date[]; + export function years(start: Date, stop: Date, step?: number): Date[]; + + export function dayOfYear(d: Date): number; + export function weekOfYear(d: Date): number; + export function sundayOfYear(d: Date): number; + export function mondayOfYear(d: Date): number; + export function tuesdayOfYear(d: Date): number; + export function wednesdayOfYear(d: Date): number; + export function fridayOfYear(d: Date): number; + export function saturdayOfYear(d: Date): number; + + export function format(specifier: string): Format; + + export module format { + export function multi(formats: Array<[string, (d: Date) => boolean]>): Format; + export function utc(specifier: string): Format; + export var iso: Format; + } + + interface Format { + (d: Date): string; + parse(input: string): Date; + } + + export function scale(): Scale; + export function scale(): Scale; + export function scale(): Scale; + + export module scale { + export function utc(): Scale; + export function utc(): Scale; + export function utc(): Scale; + } + + + interface Scale { + (x: Date): Output; + + invert(y: number): Date; + + domain(): Date[]; + domain(dates: number[]): Scale; + domain(dates: Date[]): Scale; + + nice(): Scale; + nice(interval: Interval, step?: number): Scale; + + range(): Range[]; + range(values: Range[]): Scale; + + rangeRound(values: number[]): Scale; + + interpolate(): (a: Range, b: Range) => (t: number) => Output; + interpolate(factory: (a: Range, b: Range) => (t: number) => Output): Scale; + + clamp(): boolean; + clamp(clamp: boolean): Scale; + + ticks(): Date[]; + ticks(interval: Interval, step?: number): Date[]; + ticks(count: number): Date[]; + + tickFormat(count: number): (d: Date) => string; + + copy(): Scale; + } + } + + export module behavior { + export function drag(): Drag; + + interface Drag { + (selection: Selection): void; + + on(type: string): (d: Datum, i: number) => any; + on(type: string, listener: (d: Datum, i: number) => any): Drag; + + origin(): (d: Datum, i: number) => { x: number; y: number }; + origin(accessor: (d: Datum, i: number) => { x: number; y: number }): Drag; + } + + export function zoom(): Zoom; + + module zoom { + interface Scale { + domain(): number[]; + domain(values: number[]): Scale; + + invert(y: number): number; + + range(values: number[]): Scale; + range(): number[]; + } + } + + interface Zoom { + (selection: Selection): void; + + translate(): [number, number]; + translate(translate: [number, number]): Zoom; + + scale(): number; + scale(scale: number): Zoom; + + scaleExtent(): [number, number]; + scaleExtent(extent: [number, number]): Zoom; + + center(): [number, number]; + center(center: [number, number]): Zoom; + + size(): [number, number]; + size(size: [number, number]): Zoom; + + x(): zoom.Scale; + x(x: zoom.Scale): Zoom; + + y(): zoom.Scale; + y(y: zoom.Scale): Zoom; + + on(type: string): (d: Datum, i: number) => any; + on(type: string, listener: (d: Datum, i: number) => any): Zoom; + + event(selection: Selection): void; + event(transition: Transition): void; + } + } + + export module geo { + export function path(): Path; + + interface Path { + (feature: any, index?: number): string; + + area(feature: any): number; + + centroid(feature: any): [number, number]; + + bounds(feature: any): [[number, number], [number, number]]; + + projection(): Transform | ((coordinates: [number, number]) => [number, number]); + projection(stream: Transform): Path; + projection(projection: (coordinates: [number, number]) => [number, number]): Path; + + pointRadius(): number | ((datum: any, index: number) => number); + pointRadius(radius: number): Path; + pointRadius(radius: (datum: any, index: number) => number): Path; + + context(): CanvasRenderingContext2D; + context(context: CanvasRenderingContext2D): Path; + } + + export function graticule(): Graticule; + + interface Graticule { + (): any; + + lines(): any[]; + + outline(): any; + + extent(): [[number, number], [number, number]]; + extent(extent: [[number, number], [number, number]]): Graticule; + + majorExtent(): [[number, number], [number, number]]; + majorExtent(extent: [[number, number], [number, number]]): Graticule; + + minorExtent(): [[number, number], [number, number]]; + minorExtent(extent: [[number, number], [number, number]]): Graticule; + + step(): [number, number]; + step(step: [number, number]): Graticule; + + majorStep(): [number, number]; + majorStep(step: [number, number]): Graticule; + + minorStep(): [number, number]; + minorStep(step: [number, number]): Graticule; + + precision(): number; + precision(precision: number): Graticule; + } + + export function circle(): Circle; + + interface Circle { + (...args: any[]): any; + + origin(): [number, number] | ((...args: any[]) => [number, number]); + origin(origin: [number, number]): Circle; + origin(origin: (...args: any[]) => [number, number]): Circle; + + angle(): number; + angle(angle: number): Circle; + + precision(): number; + precision(precision: number): Circle; + } + + export function area(feature: any): number; + export function centroid(feature: any): [number, number]; + export function bounds(feature: any): [[number, number], [number, number]]; + export function distance(a: [number, number], b: [number, number]): number; + export function length(feature: any): number; + export function interpolate(a: [number, number], b: [number, number]): (t: number) => [number, number]; + + export function rotation(rotate: [number, number] | [number, number, number]): Rotation; + + interface Rotation { + (location: [number, number]): [number, number]; + invert(location: [number, number]): [number, number]; + } + + export function stream(object: any, listener: Listener): void; + + interface Listener { + point(x: number, y: number, z: number): void; + lineStart(): void; + lineEnd(): void; + polygonStart(): void; + polygonEnd(): void; + sphere(): void; + } + + export function transform(methods: TransformMethods): Transform; + + interface TransformMethods { + point?(x: number, y: number, z: number): void; + lineStart?(): void; + lineEnd?(): void; + polygonStart?(): void; + polygonEnd?(): void; + sphere?(): void; + } + + interface Transform { + stream(stream: Listener): Listener; + } + + export function clipExtent(): ClipExtent; + + interface ClipExtent extends Transform { + extent(): [[number, number], [number, number]]; + extent(extent: [[number, number], [number, number]]): ClipExtent; + } + + export function projection(raw: RawInvertibleProjection): InvertibleProjection; + export function projection(raw: RawProjection): Projection; + + export function projectionMutator(factory: (...args: any[]) => RawInvertibleProjection): (...args: any[]) => InvertibleProjection; + export function projectionMutator(factory: (...args: any[]) => RawProjection): (...args: any[]) => Projection; + + export function albers(): ConicProjection; + export function albersUsa(): ConicProjection; + export function azimuthalEqualArea(): InvertibleProjection; + module azimuthalEqualArea { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function azimuthalEquidistant(): InvertibleProjection; + module azimuthalEquidistant { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function conicConformal(): ConicProjection; + module conicConformal { + export function raw(phi0: number, phi1: number): RawInvertibleProjection; + } + + export function conicEqualArea(): ConicProjection; + module conicEqualArea { + export function raw(phi0: number, phi1: number): RawInvertibleProjection; + } + + export function conicEquidistant(): ConicProjection; + module conicEquidistant { + export function raw(phi0: number, phi1: number): RawInvertibleProjection; + } + + export function equirectangular(): InvertibleProjection; + module equirectangular { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function gnomonic(): InvertibleProjection; + module gnomonic { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function mercator(): InvertibleProjection; + module mercator { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function orthographic(): InvertibleProjection; + module orthographic { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function stereographic(): InvertibleProjection; + module stereographic { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + export function transverseMercator(): InvertibleProjection; + module transverseMercator { + export function raw(lambda: number, phi: number): [number, number]; + module raw { + export function invert(x: number, y: number): [number, number]; + } + } + + interface Projection { + (location: [number, number]): [number, number]; + + rotate(): [number, number, number]; + rotate(rotation: [number, number, number]): Projection; + + center(): [number, number]; + center(location: [number, number]): Projection; + + translate(): [number, number]; + translate(point: [number, number]): Projection; + + scale(): number; + scale(scale: number): Projection; + + clipAngle(): number; + clipAngle(angle: number): Projection; + + clipExtent(): [[number, number], [number, number]]; + clipExtent(extent: [[number, number], [number, number]]): Projection; + + precision(): number; + precision(precision: number): Projection; + + stream(listener: Listener): Listener; + } + + interface InvertibleProjection extends Projection { + invert(point: [number, number]): [number, number]; + } + + interface ConicProjection extends InvertibleProjection { + parallels(): [number, number]; + parallels(parallels: [number, number]): ConicProjection; + + rotate(): [number, number, number]; + rotate(rotation: [number, number, number]): ConicProjection; + + center(): [number, number]; + center(location: [number, number]): ConicProjection; + + translate(): [number, number]; + translate(point: [number, number]): ConicProjection; + + scale(): number; + scale(scale: number): ConicProjection; + + clipAngle(): number; + clipAngle(angle: number): ConicProjection; + + clipExtent(): [[number, number], [number, number]]; + clipExtent(extent: [[number, number], [number, number]]): ConicProjection; + + precision(): number; + precision(precision: number): ConicProjection; + } + + interface RawProjection { + (lambda: number, phi: number): [number, number]; + } + + interface RawInvertibleProjection extends RawProjection { + invert(x: number, y: number): [number, number]; + } + } + + module svg { + export function line(): Line<[number, number]>; + export function line(): Line; + + interface Line { + (data: T[]): string; + + x(): number | ((d: T, i: number) => number); + x(x: number): Line; + x(x: (d: T, i: number) => number): Line; + + y(): number | ((d: T, i: number) => number); + y(x: number): Line; + y(y: (d: T, i: number) => number): Line; + + interpolate(): string | ((points: Array<[number, number]>) => string); + interpolate(interpolate: "linear"): Line; + interpolate(interpolate: "linear-closed"): Line; + interpolate(interpolate: "step"): Line; + interpolate(interpolate: "step-before"): Line; + interpolate(interpolate: "step-after"): Line; + interpolate(interpolate: "basis"): Line; + interpolate(interpolate: "basis-open"): Line; + interpolate(interpolate: "basis-closed"): Line; + interpolate(interpolate: "bundle"): Line; + interpolate(interpolate: "cardinal"): Line; + interpolate(interpolate: "cardinal-open"): Line; + interpolate(interpolate: "cardinal-closed"): Line; + interpolate(interpolate: "monotone"): Line; + interpolate(interpolate: string): Line; + interpolate(interpolate: (points: Array<[number, number]>) => string): Line; + + tension(): number; + tension(tension: number): Line; + + defined(): (d: T, i: number) => boolean; + defined(defined: (d: T, i: number) => boolean): Line; + } + + module line { + export function radial(): Radial<[number, number]>; + export function radial(): Radial; + + interface Radial { + (data: T[]): string; + + radius(): number | ((d: T, i: number) => number); + radius(radius: number): Radial; + radius(radius: (d: T, i: number) => number): Radial; + + angle(): number | ((d: T, i: number) => number); + angle(angle: number): Radial; + angle(angle: (d: T, i: number) => number): Radial; + + interpolate(): string | ((points: Array<[number, number]>) => string); + interpolate(interpolate: "linear"): Radial; + interpolate(interpolate: "linear-closed"): Radial; + interpolate(interpolate: "step"): Radial; + interpolate(interpolate: "step-before"): Radial; + interpolate(interpolate: "step-after"): Radial; + interpolate(interpolate: "basis"): Radial; + interpolate(interpolate: "basis-open"): Radial; + interpolate(interpolate: "basis-closed"): Radial; + interpolate(interpolate: "bundle"): Radial; + interpolate(interpolate: "cardinal"): Radial; + interpolate(interpolate: "cardinal-open"): Radial; + interpolate(interpolate: "cardinal-closed"): Radial; + interpolate(interpolate: "monotone"): Radial; + interpolate(interpolate: string): Radial; + interpolate(interpolate: (points: Array<[number, number]>) => string): Radial; + + tension(): number; + tension(tension: number): Radial; + + defined(): (d: T, i: number) => boolean; + defined(defined: (d: T, i: number) => boolean): Radial; + } + } + + export function area(): Area<[number, number]>; + export function area(): Area; + + interface Area { + (data: T[]): string; + + x(): number | ((d: T, i: number) => number); + x(x: number): Area; + x(x: (d: T, i: number) => number): Area; + + x0(): number | ((d: T, i: number) => number); + x0(x0: number): Area; + x0(x0: (d: T, i: number) => number): Area; + + x1(): number | ((d: T, i: number) => number); + x1(x1: number): Area; + x1(x1: (d: T, i: number) => number): Area; + + y(): number | ((d: T, i: number) => number); + y(y: number): Area; + y(y: (d: T, i: number) => number): Area; + + y0(): number | ((d: T, i: number) => number); + y0(y0: number): Area; + y0(y0: (d: T, i: number) => number): Area; + + y1(): number | ((d: T, i: number) => number); + y1(y1: number): Area; + y1(y1: (d: T, i: number) => number): Area; + + interpolate(): string | ((points: Array<[number, number]>) => string); + interpolate(interpolate: "linear"): Area; + interpolate(interpolate: "step"): Area; + interpolate(interpolate: "step-before"): Area; + interpolate(interpolate: "step-after"): Area; + interpolate(interpolate: "basis"): Area; + interpolate(interpolate: "basis-open"): Area; + interpolate(interpolate: "cardinal"): Area; + interpolate(interpolate: "cardinal-open"): Area; + interpolate(interpolate: "monotone"): Area; + interpolate(interpolate: string): Area; + + tension(): number; + tension(tension: number): Area; + + defined(): (d: T, i: number) => boolean; + defined(): (d: T, i: number) => boolean; + } + + module area { + export function radial(): Radial<[number, number]>; + export function radial(): Radial; + + interface Radial { + (data: T[]): string; + + radius(): number | ((d: T, i: number) => number); + radius(radius: number): Radial; + radius(radius: (d: T, i: number) => number): Radial; + + innerRadius(): number | ((d: T, i: number) => number); + innerRadius(innerRadius: number): Radial; + innerRadius(innerRadius: (d: T, i: number) => number): Radial; + + outerRadius(): number | ((d: T, i: number) => number); + outerRadius(outerRadius: number): Radial; + outerRadius(outerRadius: (d: T, i: number) => number): Radial; + + angle(): number | ((d: T, i: number) => number); + angle(angle: number): Radial; + angle(angle: (d: T, i: number) => number): Radial; + + startAngle(): number | ((d: T, i: number) => number); + startAngle(startAngle: number): Radial; + startAngle(startAngle: (d: T, i: number) => number): Radial; + + endAngle(): number | ((d: T, i: number) => number); + endAngle(endAngle: number): Radial; + endAngle(endAngle: (d: T, i: number) => number): Radial; + + interpolate(): string | ((points: Array<[number, number]>) => string); + interpolate(interpolate: "linear"): Radial; + interpolate(interpolate: "step"): Radial; + interpolate(interpolate: "step-before"): Radial; + interpolate(interpolate: "step-after"): Radial; + interpolate(interpolate: "basis"): Radial; + interpolate(interpolate: "basis-open"): Radial; + interpolate(interpolate: "cardinal"): Radial; + interpolate(interpolate: "cardinal-open"): Radial; + interpolate(interpolate: "monotone"): Radial; + interpolate(interpolate: string): Radial; + interpolate(interpolate: (points: Array<[number, number]>) => string): Radial; + + tension(): number; + tension(tension: number): Radial; + + defined(): (d: T, i: number) => boolean; + defined(): (d: T, i: number) => boolean; + } + } + + export function arc(): Arc; + export function arc(): Arc; + + module arc { + interface Arc { + innerRadius: number; + outerRadius: number; + startAngle: number; + endAngle: number; + padAngle: number + } + } + + interface Arc { + (d: T, i: number): string; + + innerRadius(): (d: T, i: number) => number; + innerRadius(radius: number): Arc; + innerRadius(radius: (d: T, i: number) => number): Arc; + + outerRadius(): (d: T, i: number) => number; + outerRadius(radius: number): Arc; + outerRadius(radius: (d: T, i: number) => number): Arc; + + cornerRadius(): (d: T, i: number) => number; + cornerRadius(radius: number): Arc; + cornerRadius(radius: (d: T, i: number) => number): Arc; + + padRadius(): string | ((d: T, i: number) => number); + padRadius(radius: "auto"): Arc; + padRadius(radius: string): Arc; + padRadius(radius: (d: T, i: number) => number): Arc; + + startAngle(): (d: T, i: number) => number; + startAngle(angle: number): Arc; + startAngle(angle: (d: T, i: number) => number): Arc; + + endAngle(): (d: T, i: number) => number; + endAngle(angle: number): Arc; + endAngle(angle: (d: T, i: number) => number): Arc; + + padAngle(): (d: T, i: number) => number; + padAngle(angle: number): Arc; + padAngle(angle: (d: T, i: number) => number): Arc; + + centroid(d: T, i?: number): [number, number]; + } + + export function symbol(): Symbol<{}>; + export function symbol(): Symbol; + + interface Symbol { + (d: T, i: number): string; + + type(): (d: T, i: number) => string; + type(type: string): Symbol; + type(type: (d: T, i: number) => string): Symbol; + + size(): (d: T, i: string) => number; + size(size: number): Symbol; + size(size: (d: T, i: number) => number): Symbol; + } + + export var symbolTypes: string[]; + + export function chord(): Chord, chord.Node>; + export function chord(): Chord, Node>; + export function chord(): Chord; + + module chord { + interface Link { + source: Node; + target: Node; + } + + interface Node { + radius: number; + startAngle: number; + endAngle: number + } + } + + interface Chord { + (d: Link, i: number): string; + + source(): (d: Link, i: number) => Node; + source(source: Node): Chord; + source(source: (d: Link, i: number) => Node): Chord; + + target(): (d: Link, i: number) => Node; + target(target: Node): Chord; + target(target: (d: Link, i: number) => Node): Chord; + + radius(): (d: Node, i: number) => number; + radius(radius: number): Chord; + radius(radius: (d: Node, i: number) => number): Chord; + + startAngle(): (d: Node, i: number) => number; + startAngle(angle: number): Chord; + startAngle(angle: (d: Node, i: number) => number): Chord; + + endAngle(): (d: Node, i: number) => number; + endAngle(angle: number): Chord; + endAngle(angle: (d: Node, i: number) => number): Chord; + } + + export function diagonal(): Diagonal, diagonal.Node>; + export function diagonal(): Diagonal, Node>; + export function diagonal(): Diagonal; + + module diagonal { + interface Link { + source: Node; + target: Node; + } + + interface Node { + x: number; + y: number; + } + } + + interface Diagonal { + (d: Link, i: number): string; + + source(): (d: Link, i: number) => Node; + source(source: Node): Diagonal; + source(source: (d: Link, i: number) => Node): Diagonal; + + target(): (d: Link, i: number) => Node; + target(target: Node): Diagonal; + target(target: (d: Link, i: number) => Node): Diagonal; + + projection(): (d: Node, i: number) => [number, number]; + projection(projection: (d: Node, i: number) => [number, number]): Diagonal; + } + + module diagonal { + export function radial(): Radial, Node>; + export function radial(): Radial, Node>; + export function radial(): Radial; + + interface Radial { + (d: Link, i: number): string; + + source(): (d: Link, i: number) => Node; + source(source: Node): Radial; + source(source: (d: Link, i: number) => Node): Radial; + + target(): (d: Link, i: number) => Node; + target(target: Node): Radial; + target(target: (d: Link, i: number) => Node): Radial; + + projection(): (d: Node, i: number) => [number, number]; + projection(projection: (d: Node, i: number) => [number, number]): Radial; + } + } + + export function axis(): Axis; + + interface Axis { + (selection: Selection): void; + (selection: Transition): void; + + scale(): any; + scale(scale: any): Axis; + + orient(): string; + orient(orientation: string): Axis; + + ticks(): any[]; + ticks(...args: any[]): Axis; + + tickValues(): any[]; + tickValues(values: any[]): Axis; + + tickSize(): number; + tickSize(size: number): Axis; + tickSize(inner: number, outer: number): Axis; + + innerTickSize(): number; + innerTickSize(size: number): Axis; + + outerTickSize(): number; + outerTickSize(size: number): Axis; + + tickPadding(): number; + tickPadding(padding: number): Axis; + + tickFormat(): (t: any) => string; + tickFormat(format: (t: any) => string): Axis; + } + + export function brush(): Brush; + export function brush(): Brush; + + module brush { + interface Scale { + domain(): number[]; + domain(domain: number[]): Scale; + + range(): number[]; + range(range: number[]): Scale; + + invert?(y: number): number; + } + } + + interface Brush { + (selection: Selection): void; + (selection: Transition): void; + + event(selection: Selection): void; + event(selection: Transition): void; + + x(): brush.Scale; + x(x: brush.Scale): Brush; + + y(): brush.Scale; + y(y: brush.Scale): Brush; + + extent(): [number, number] | [[number, number], [number, number]]; + extent(extent: [number, number] | [[number, number], [number, number]]): Brush; + + clamp(): boolean | [boolean, boolean]; + clamp(clamp: boolean | [boolean, boolean]): Brush; + + clear(): void; + + empty(): boolean; + + on(type: 'brushstart'): (datum: T, index: number) => void; + on(type: 'brush'): (datum: T, index: number) => void; + on(type: 'brushend'): (datum: T, index: number) => void; + on(type: string): (datum: T, index: number) => void; + + on(type: 'brushstart', listener: (datum: T, index: number) => void): Brush; + on(type: 'brush', listener: (datum: T, index: number) => void): Brush; + on(type: 'brushend', listener: (datum: T, index: number) => void): Brush; + on(type: string, listener: (datum: T, index: number) => void): Brush; + } + } + + export function xhr(url: string, mimeType?: string, callback?: (err: any, data: any) => void): Xhr; + export function xhr(url: string, callback: (err: any, data: any) => void): Xhr; + + interface Xhr { + header(name: string): string; + header(name: string, value: string): Xhr; + + mimeType(): string; + mimeType(type: string): Xhr; + + responseType(): string; + responseType(type: string): Xhr; + + response(): (request: XMLHttpRequest) => any; + response(value: (request: XMLHttpRequest) => any): Xhr; + + get(callback?: (err: any, data: any) => void): Xhr; + + post(data?: any, callback?: (err: any, data: any) => void): Xhr; + post(callback: (err: any, data: any) => void): Xhr; + + send(method: string, data?: any, callback?: (err: any, data: any) => void): Xhr; + send(method: string, callback: (err: any, data: any) => void): Xhr; + + abort(): Xhr; + + on(type: "beforesend"): (request: XMLHttpRequest) => void; + on(type: "progress"): (request: XMLHttpRequest) => void; + on(type: "load"): (response: any) => void; + on(type: "error"): (err: any) => void; + on(type: string): (...args: any[]) => void; + + on(type: "beforesend", listener: (request: XMLHttpRequest) => void): Xhr; + on(type: "progress", listener: (request: XMLHttpRequest) => void): Xhr; + on(type: "load", listener: (response: any) => void): Xhr; + on(type: "error", listener: (err: any) => void): Xhr; + on(type: string, listener: (...args: any[]) => void): Xhr; + } + + export function text(url: string, mimeType?: string, callback?: (err: any, data: string) => void): Xhr; + export function text(url: string, callback: (err: any, data: string) => void): Xhr; + + export function json(url: string, callback?: (err: any, data: any) => void): Xhr; + + export function xml(url: string, mimeType?: string, callback?: (err: any, data: any) => void): Xhr; + export function xml(url: string, callback: (err: any, data: any) => void): Xhr; + + export function html(url: string, callback?: (err: any, data: DocumentFragment) => void): Xhr; + + export var csv: Dsv; + export var tsv: Dsv; + export function dsv(delimiter: string, mimeType: string): Dsv; + + interface Dsv { + (url: string, callback: (rows: { [key: string]: string }[]) => void): DsvXhr<{ [key: string]: string }>; + (url: string, callback: (error: any, rows: { [key: string]: string }[]) => void): DsvXhr<{ [key: string]: string }>; + (url: string): DsvXhr<{ [key: string]: string }>; + (url: string, accessor: (row: { [key: string]: string }) => T, callback: (rows: T[]) => void): DsvXhr; + (url: string, accessor: (row: { [key: string]: string }) => T, callback: (error: any, rows: T[]) => void): DsvXhr; + (url: string, accessor: (row: { [key: string]: string }) => T): DsvXhr; + + parse(string: string): { [key: string]: string }[]; + parse(string: string, accessor: (row: { [key: string]: string }, index: number) => T): T[]; + + parseRows(string: string): string[][]; + parseRows(string: string, accessor: (row: string[], index: number) => T): T[]; + + format(rows: Object[]): string; + + formatRows(rows: string[][]): string; + } + + interface DsvXhr extends Xhr { + row(): (row: { [key: string]: string }) => T; + row(accessor: (row: { [key: string]: string }) => U): DsvXhr; + + header(name: string): string; + header(name: string, value: string): DsvXhr; + + mimeType(): string; + mimeType(type: string): DsvXhr; + + responseType(): string; + responseType(type: string): DsvXhr; + + response(): (request: XMLHttpRequest) => any; + response(value: (request: XMLHttpRequest) => any): DsvXhr; + + get(callback?: (err: any, data: T) => void): DsvXhr; + post(data?: any, callback?: (err: any, data: T) => void): DsvXhr; + post(callback: (err: any, data: T) => void): DsvXhr; + + send(method: string, data?: any, callback?: (err: any, data: T) => void): DsvXhr; + send(method: string, callback: (err: any, data: T) => void): DsvXhr; + + abort(): DsvXhr; + + on(type: "beforesend"): (request: XMLHttpRequest) => void; + on(type: "progress"): (request: XMLHttpRequest) => void; + on(type: "load"): (response: T) => void; + on(type: "error"): (err: any) => void; + on(type: string): (...args: any[]) => void; + + on(type: "beforesend", listener: (request: XMLHttpRequest) => void): DsvXhr; + on(type: "progress", listener: (request: XMLHttpRequest) => void): DsvXhr; + on(type: "load", listener: (response: T) => void): DsvXhr; + on(type: "error", listener: (err: any) => void): DsvXhr; + on(type: string, listener: (...args: any[]) => void): DsvXhr; + } + + export function locale(definition: LocaleDefinition): Locale; + + interface LocaleDefinition { + decimal: string; + thousands: string; + grouping: number[]; + currency: [string, string]; + dateTime: string; + date: string; + time: string; + periods: [string, string]; + days: [string, string, string, string, string, string, string]; + shortDays: [string, string, string, string, string, string, string]; + months: [string, string, string, string, string, string, string, string, string, string, string, string]; + shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string]; + } + + interface Locale { + numberFormat(specifier: string): (n: number) => string; + timeFormat: { + (specifier: string): time.Format; + utc(specifier: string): time.Format; + } + } + + module layout { + export function bundle(): Bundle; + export function bundle(): Bundle + + module bundle { + interface Node { + parent: Node; + } + + interface Link { + source: T; + target: T; + } + } + + interface Bundle { + (links: bundle.Link[]): T[][]; + } + + export function chord(): Chord; + + module chord { + interface Link { + source: Node; + target: Node; + } + + interface Node { + index: number; + subindex: number; + startAngle: number; + endAngle: number; + value: number; + } + + interface Group { + index: number; + startAngle: number; + endAngle: number; + value: number; + } + } + + interface Chord { + matrix(): number[][]; + matrix(matrix: number[][]): Chord; + + padding(): number; + padding(padding: number): Chord; + + sortGroups(): (a: number, b: number) => number; + sortGroups(comparator: (a: number, b: number) => number): Chord; + + sortSubgroups(): (a: number, b: number) => number; + sortSubgroups(comparator: (a: number, b: number) => number): Chord; + + sortChords(): (a: number, b: number) => number; + sortChords(comparator: (a: number, b: number) => number): Chord; + + chords(): chord.Link[]; + groups(): chord.Group[]; + } + + export function cluster(): Cluster; + export function cluster(): Cluster; + + module cluster { + interface Result { + parent?: Result; + children?: Result[]; + depth?: number; + x?: number; + y?: number; + } + + interface Link { + source: T; + target: T; + } + } + + interface Cluster { + (root: T): T[]; + + nodes(root: T): T[]; + + links(nodes: T[]): cluster.Link; + + children(): (node: T) => T[]; + children(accessor: (node: T) => T[]): Cluster; + + sort(): (a: T, b: T) => number; + sort(comparator: (a: T, b: T) => number): Cluster; + + separation(): (a: T, b: T) => number; + separation(separation: (a: T, b: T) => number): Cluster; + + size(): [number, number]; + size(size: [number, number]): Cluster; + + nodeSize(): [number, number]; + nodeSize(nodeSize: [number, number]): Cluster; + + value(): (a: T) => number; + value(value: (a: T) => number): Cluster; + } + + export function force(): Force, force.Node>; + export function force(): Force, Node>; + export function force, Node extends force.Node>(): Force; + + module force { + interface Link { + source: T; + target: T; + } + + interface Node { + index?: number; + x?: number; + y?: number; + px?: number; + py?: number; + fixed?: boolean; + weight?: number; + } + + interface Event { + type: string; + alpha: number; + } + } + + interface Force, Node extends force.Node> { + size(): [number, number]; + size(size: [number, number]): Force; + + linkDistance(): number | ((link: Link, index: number) => number); + linkDistance(distance: number): Force; + linkDistance(distance: (link: Link, index: number) => number): Force; + + linkStrength(): number | ((link: Link, index: number) => number); + linkStrength(strength: number): Force; + linkStrength(strength: (link: Link, index: number) => number): Force; + + friction(): number; + friction(friction: number): Force; + + charge(): number | ((node: Node, index: number) => number); + charge(charge: number): Force; + charge(charge: (node: Node, index: number) => number): Force; + + chargeDistance(): number; + chargeDistance(distance: number): Force; + + theta(): number; + theta(theta: number): Force; + + gravity(): number; + gravity(gravity: number): Force; + + nodes(): Node[]; + nodes(nodes: Node[]): Force; + + links(): Link[]; + links(links: { source: number; target: number }[]): Force; + links(links: Link[]): Force; + + start(): Force; + + alpha(): number; + alpha(value: number): Force; + + resume(): Force; + + stop(): Force; + + on(type: string): (event: force.Event) => void; + on(type: string, listener: (event: force.Event) => void): Force; + + drag(): behavior.Drag; + drag(selection: Selection): void; + } + + export function hierarchy(): Hierarchy; + export function hierarchy(): Hierarchy; + + module hierarchy { + interface Result { + parent?: Result; + children?: Result[]; + value?: number; + depth?: number; + } + } + + interface Hierarchy { + (root: T): T[]; + + children(): (node: T) => T[]; + children(accessor: (node: T) => T[]): Hierarchy; + + sort(): (a: T, b: T) => number; + sort(comparator: (a: T, b: T) => number): Hierarchy; + + value(): (node: T) => number; + value(accessor: (node: T) => number): Hierarchy; + + revalue(root: T): T[]; + } + + export function histogram(): Histogram; + export function histogram(): Histogram; + + module histogram { + interface Bin extends Array { + x: number; + dx: number; + y: number; + } + } + + interface Histogram { + (values: T[], index?: number): histogram.Bin[]; + + value(): (datum: T, index: number) => number; + value(value: (datum: T, index: number) => number): Histogram; + + range(): (values: T[], index: number) => [number, number]; + range(range: (values: T[], index: number) => [number, number]): Histogram; + + bins(): (range: [number, number], values: T[], index: number) => number[]; + bins(count: number): Histogram; + bins(thresholds: number[]): Histogram; + bins(func: (range: [number, number], values: T[], index: number) => number[]): Histogram; + + frequency(): boolean; + frequency(frequency: boolean): Histogram; + } + + export function pack(): Pack; + export function pack(): Pack; + + module pack { + interface Node { + parent?: Node; + children?: Node[]; + value?: number; + depth?: number; + x?: number; + y?: number; + r?: number; + } + + interface Link { + source: Node; + target: Node; + } + } + + interface Pack { + (root: T): T[]; + + nodes(root: T): T[]; + + links(nodes: T[]): pack.Link[]; + + children(): (node: T, depth: number) => T[]; + children(children: (node: T, depth: number) => T[]): Pack; + + sort(): (a: T, b: T) => number; + sort(comparator: (a: T, b: T) => number): Pack; + + value(): (node: T) => number; + value(value: (node: T) => number): Pack; + + size(): [number, number]; + size(size: [number, number]): Pack; + + radius(): number | ((node: T) => number); + radius(radius: number): Pack; + radius(radius: (node: T) => number): Pack; + + padding(): number; + padding(padding: number): Pack; + } + + export function pie(): Pie; + export function pie(): Pie; + + module pie { + interface Arc { + value: number; + startAngle: number; + endAngle: number; + padAngle: number; + data: T; + } + } + + interface Pie { + (data: T[], index?: number): pie.Arc[]; + + value(): (datum: T, index: number) => number; + value(accessor: (datum: T, index: number) => number): Pie; + + sort(): (a: T, b: T) => number; + sort(comparator: (a: T, b: T) => number): Pie; + + startAngle(): number | ((data: T[], index: number) => number); + startAngle(angle: number): Pie; + startAngle(angle: (data: T[], index: number) => number): Pie; + + endAngle(): number | ((data: T[], index: number) => number); + endAngle(angle: number): Pie; + endAngle(angle: (data: T[], index: number) => number): Pie; + + padAngle(): number | ((data: T[], index: number) => number); + padAngle(angle: number): Pie; + padAngle(angle: (data: T[], index: number) => number): Pie; + } + + export function stack(): Stack; + export function stack(): Stack; + export function stack(): Stack; + module stack { + interface Value { + x: number; + y: number; + y0?: number; + } + } + + interface Stack { + (layers: Series[], index?: number): Series[]; + + values(): (layer: Series, index: number) => Value[]; + values(accessor: (layer: Series, index: number) => Value[]): Stack; + + offset(): (data: Array<[number, number]>) => number[]; + offset(offset: "silhouette"): Stack; + offset(offset: "wiggle"): Stack; + offset(offset: "expand"): Stack; + offset(offset: "zero"): Stack; + offset(offset: string): Stack; + offset(offset: (data: Array<[number, number]>) => number[]): Stack; + + order(): (data: Array<[number, number]>) => number[]; + order(order: "inside-out"): Stack; + order(order: "reverse"): Stack; + order(order: "default"): Stack; + order(order: string): Stack; + order(order: (data: Array<[number, number]>) => number[]): Stack; + + x(): (value: Value, index: number) => number; + x(accessor: (value: Value, index: number) => number): Stack; + + y(): (value: Value, index: number) => number; + y(accesor: (value: Value, index: number) => number): Stack; + + out(): (value: Value, y0: number, y: number) => void; + out(setter: (value: Value, y0: number, y: number) => void): Stack; + } + + export function tree(): Tree; + export function tree(): Tree; + + module tree { + interface Link { + source: T; + target: T; + } + + interface Node { + parent?: Node; + children?: Node[]; + depth?: number; + x?: number; + y?: number; + } + } + + interface Tree { + (root: T, index?: number): T[]; + + nodes(root: T, index?: number): T[]; + + links(nodes: T[]): tree.Link[]; + + children(): (datum: T, index: number) => T[]; + children(children: (datum: T, index: number) => T[]): Tree; + + separation(): (a: T, b: T) => number; + separation(separation: (a: T, b: T) => number): Tree; + + size(): [number, number]; + size(size: [number, number]): Tree; + + nodeSize(): [number, number]; + nodeSize(size: [number, number]): Tree; + + sort(): (a: T, b: T) => number; + sort(comparator: (a: T, b: T) => number): Tree; + + value(): (datum: T, index: number) => number; + value(value: (datum: T, index: number) => number): Tree; + } + + export function treemap(): Treemap; + export function treemap(): Treemap; + + module treemap { + interface Node { + parent?: Node; + children?: Node[]; + value?: number; + depth?: number; + x?: number; + y?: number; + dx?: number; + dy?: number; + } + + interface Link { + source: T; + target: T; + } + + type Padding = number | [number, number, number, number]; + } + + interface Treemap { + (root: T, index?: number): T[]; + + nodes(root: T, index?: number): T[]; + + links(nodes: T[]): treemap.Link[]; + + children(): (node: T, depth: number) => T[]; + children(children: (node: T, depth: number) => T[]): Treemap; + + sort(): (a: T, b: T) => number; + sort(comparator: (a: T, b: T) => number): Treemap; + + value(): (node: T, index: number) => number; + value(value: (node: T, index: number) => number): Treemap; + + size(): [number, number]; + size(size: [number, number]): Treemap; + + padding(): (node: T, depth: number) => treemap.Padding; + padding(padding: treemap.Padding): Treemap; + padding(padding: (node: T, depth: number) => treemap.Padding): Treemap; + + round(): boolean; + round(round: boolean): Treemap; + + sticky(): boolean; + sticky(sticky: boolean): boolean; + + mode(): string; + mode(mode: "squarify"): Treemap; + mode(mode: "slice"): Treemap; + mode(mode: "dice"): Treemap; + mode(mode: "slice-dice"): Treemap; + mode(mode: string): Treemap; + + ratio(): number; + ratio(ratio: number): Treemap; + } + } + + module geom { + export function voronoi(): Voronoi<[number, number]>; + export function voronoi(): Voronoi; + + module voronoi { + interface Link { + source: T; + target: T; + } + } + + interface Voronoi { + (data: T[]): Array<[number, number]>; + + x(): (vertex: T) => number; + x(x: (vertex: T) => number): Voronoi; + + y(): (vertex: T) => number; + y(y: (vertex: T) => number): Voronoi; + + clipExtent(): [[number, number], [number, number]]; + clipExtent(extent: [[number, number], [number, number]]): Voronoi; + + links(data: T[]): voronoi.Link[]; + + triangles(data: T[]): Array<[T, T, T]>; + } + + /** + * @deprecated use d3.geom.voronoi().triangles() instead + */ + export function delaunay(vertices: Array<[number, number]>): Array<[[number, number], [number, number], [number, number]]>; + + export function quadtree(): Quadtree<[number, number]>; + export function quadtree(): Quadtree; + + module quadtree { + interface Node { + nodes: [Node, Node, Node, Node]; + leaf: boolean; + point: T; + x: number; + y: number; + } + + interface Quadtree extends Node { + add(point: T): void; + visit(callback: (node: Node, x1: number, y1: number, x2: number, y2: number) => boolean | void): void; + find(point: [number, number]): T; + } + } + + interface Quadtree { + (points: T[]): quadtree.Quadtree; + + x(): (datum: T, index: number) => number; + x(x: number): Quadtree; + x(x: (datum: T, index: number) => number): Quadtree; + + y(): (datum: T, index: number) => number; + y(y: number): Quadtree; + y(y: (datum: T, index: number) => number): Quadtree; + + extent(): [[number, number], [number, number]]; + extent(extent: [[number, number], [number, number]]): Quadtree; + } + + export function hull(vertices: Array<[number, number]>): Array<[number, number]>; + export function hull(): Hull<[number, number]>; + export function hull(): Hull; + + interface Hull { + (vertices: T[]): Array<[number, number]>; + + x(): (datum: T) => number; + x(x: (datum: T) => number): Hull; + + y(): (datum: T) => number; + y(y: (datum: T) => number): Hull; + } + + export function polygon(vertices: Array<[number, number]>): Polygon; + + interface Polygon { + area(): number; + + centroid(): [number, number]; + + clip(subject: Array<[number, number]>): Array<[number, number]>; + } + } +} + +// we need this to exist +interface TouchList { } + +declare module 'd3' { + export = d3; +} diff --git a/d3/plugins/d3.superformula-tests.ts b/d3/plugins/d3.superformula-tests.ts index 3e7dd4d58..432ea214c 100644 --- a/d3/plugins/d3.superformula-tests.ts +++ b/d3/plugins/d3.superformula-tests.ts @@ -12,7 +12,7 @@ function superformula() { .attr("width", 960) .attr("height", 500); - var small = d3.superformula() + var small = d3.superformula() .type(function (d) { return d; } ) .size(size); @@ -37,4 +37,4 @@ function superformula() { .attr("class", "big") .attr("transform", "translate(450,250)") .attr("d", big); -} \ No newline at end of file +} diff --git a/d3/plugins/d3.superformula.d.ts b/d3/plugins/d3.superformula.d.ts index 6f5c59b07..d9252a45d 100644 --- a/d3/plugins/d3.superformula.d.ts +++ b/d3/plugins/d3.superformula.d.ts @@ -1,38 +1,37 @@ /// +declare module d3 { + export function superformula(): Superformula; -declare module D3 { - interface SuperformulaPath - { - superformulaPath(params: number[], n: number, diameter: number): Superformula; + module superformula { + interface Type { + m: number; + n1: number; + n2: number; + n3: number; + a: number; + b: number; + } } + interface Superformula { + (datum: T, index: number): string; - interface SuperformulaType - { - (any: any): any;//hans - m: number; - n1: number; - n2: number; - n3: number; - a: number; - b: number; + type(): (datum: T, index: number) => string; + type(type: string): Superformula; + type(type: (datum: T, index: number) => string): Superformula; + + size(): (datum: T, index: number) => number; + size(size: number): Superformula; + size(size: (datum: T, index: number) => number): Superformula; + + segments(): (datum: T, index: number) => number; + segments(segments: number): Superformula; + segments(segments: (datum: T, index: number) => number): Superformula; + + param(name: string): number; + param(name: string, value: number): Superformula; } - interface Superformula - { - (): any; - type(any: any): any; - param(name: string, value: number): Superformula; - size(x: number): Superformula; - segments(x: number): Superformula; - } - - - interface Base extends Selectors - { - superformula: Superformula; - superformulaPath: SuperformulaPath; - superformulaTypes: SuperformulaType[]; - } + export var superformulaTypes: string[]; } From 39debc285e0827afc57b78c4f3d4fe1a345287f8 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Mon, 30 Mar 2015 15:26:22 -0400 Subject: [PATCH 007/397] Fix tests and broken references --- d3/d3-tests.ts | 12 ++++++------ dagre-d3/dagre-d3.d.ts | 2 +- dcjs/dc-1.6.0.d.ts | 8 ++++---- dcjs/dc.d.ts | 44 +++++++++++++++++++++--------------------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 70e4036dd..4750c2309 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -48,33 +48,33 @@ function testPieChart() { function testMapConstructor() { //No arg constructor - var emptyMap: D3.Map = d3.map(); + var emptyMap: d3.Map = d3.map(); //Object constructor var object:{[key: string]: number } = {a: 1, b: 2, c: 3}; - var objectMap: D3.Map = d3.map(object); + var objectMap: d3.Map = d3.map(object); //Array constructor var numberArray: number[] = [1, 2, 3] - var numberArrayMap: D3.Map = d3.map(numberArray); + var numberArrayMap: d3.Map = d3.map(numberArray); //Array with keyFn constructor var objectArray: {key: string}[] = [{key: "v1"}, {key: "v2"}, {key: "v3"}]; var indexes: number[] = []; //keyFn with index - var objectArrayMap1: D3.Map<{key: string}> + var objectArrayMap1: d3.Map<{key: string}> = d3.map<{key: string}>(objectArray, (o: {key: string}, index: number) => { indexes.push(index); return o.key; }); //keyFn without index - var objectArrayMap2: D3.Map<{key: string}> + var objectArrayMap2: d3.Map<{key: string}> = d3.map<{key: string}>(objectArray, (o: {key: string}) => { return o.key; }); //Map constructor - var duplicateMap: D3.Map = d3.map(numberArrayMap); + var duplicateMap: d3.Map = d3.map(numberArrayMap); } //Example from http://bl.ocks.org/3887051 diff --git a/dagre-d3/dagre-d3.d.ts b/dagre-d3/dagre-d3.d.ts index d088d1d82..d654fa0b4 100644 --- a/dagre-d3/dagre-d3.d.ts +++ b/dagre-d3/dagre-d3.d.ts @@ -24,7 +24,7 @@ declare module Dagre { interface Render { new (): Render; - (selection: D3.Selection, g: Dagre.Graph): void; + (selection: d3.Selection, g: Dagre.Graph): void; } } diff --git a/dcjs/dc-1.6.0.d.ts b/dcjs/dc-1.6.0.d.ts index 2b06c34dd..2feed9a8c 100644 --- a/dcjs/dc-1.6.0.d.ts +++ b/dcjs/dc-1.6.0.d.ts @@ -47,8 +47,8 @@ export interface ILegendwidget { legend: (l:ILegendwidget) => T; chartID: () => number; options: (o:Object)=>void ; - select: (selector: D3.Selection) => D3.Selection; - selectAll: (selector: D3.Selection) => D3.Selection; + select: (selector: d3.Selection) => d3.Selection; + selectAll: (selector: d3.Selection) => d3.Selection; } export interface IEvents { @@ -85,8 +85,8 @@ export interface ILegendwidget { x: IGetSet; y: IGetSet; elasticY: IGetSet; - xAxis: IGetSet; - yAxis: IGetSet; + xAxis: IGetSet; + yAxis: IGetSet; yAxisPadding: IGetSet; xAxisPadding: IGetSet; renderHorizontalGridLines: IGetSet; diff --git a/dcjs/dc.d.ts b/dcjs/dc.d.ts index 5a83b5c7c..5382c9b76 100644 --- a/dcjs/dc.d.ts +++ b/dcjs/dc.d.ts @@ -86,7 +86,7 @@ declare module DC { clamp(n: number, min: number, max: number): number; uniqueId(): number; nameToId(name: string): string; - appendOrSelect(parent: D3.Selection, selector: string, tag: any): D3.Selection; + appendOrSelect(parent: d3.Selection, selector: string, tag: any): d3.Selection; safeNumber(n: any): number; } @@ -112,11 +112,11 @@ declare module DC { group: IGetSet; ordering: IGetSet, T>; filterAll(): void; - select(selector: D3.Selection|string): D3.Selection; - selectAll(selector: D3.Selection|string): D3.Selection; - anchor(anchor: BaseMixin|D3.Selection|string, chartGroup?: string): D3.Selection; + select(selector: d3.Selection|string): d3.Selection; + selectAll(selector: d3.Selection|string): d3.Selection; + anchor(anchor: BaseMixin|d3.Selection|string, chartGroup?: string): d3.Selection; anchorName(): string; - svg: IGetSet; + svg: IGetSet, d3.Selection>; resetSvg(): void; filterPrinter: IGetSet<(filters: Array) => string, T>; turnOnControls(): void; @@ -160,7 +160,7 @@ declare module DC { } export interface ColorMixin { - colors: IGetSet|Array, T>; + colors: IGetSet | { (n: number): string; domain(colors: any[]): any }, T>; ordinalColors(r: Array): void; linearColors(r: Array): void; colorAccessor: IGetSet, T>; @@ -174,12 +174,12 @@ declare module DC { rangeChart: IGetSet, T>; zoomScale: IGetSet, T>; zoomOutRestrict: IGetSet; - g: IGetSet; + g: IGetSet, T>; mouseZoomable: IGetSet; - chartBodyG(): D3.Selection; - x: IGetSet, T>; + chartBodyG(): d3.Selection; + x: IGetSet<(n: any) => any, T>; xUnits: IGetSet; - xAxis: IGetSet; + xAxis: IGetSet; elasticX: IGetSet; xAxisPadding: IGetSet; xUnitCount(): number; @@ -187,8 +187,8 @@ declare module DC { isOrdinal(): boolean; xAxisLabel: IBiGetSet; yAxisLabel: IBiGetSet; - y: IGetSet, T>; - yAxis: IGetSet; + y: IGetSet<(n: any) => any, T>; + yAxis: IGetSet; elasticY: IGetSet; renderHorizontalGridLines: IGetSet; renderVerticalGridLines: IGetSet; @@ -209,7 +209,7 @@ declare module DC { hideStack(name: string): void; showStack(name: string): void; // title(stackName: string, titleFn: Accessor); - stackLayout: IGetSet; + stackLayout: IGetSet, T>; } export interface CapMixin { @@ -219,7 +219,7 @@ declare module DC { } export interface BubbleMixin extends ColorMixin { - r: IGetSet, T>; + r: IGetSet<(n: any) => any, T>; radiusValueAccessor: IGetSet, T>; minRadiusWithLabel: IGetSet; maxBubbleRelativeSize: IGetSet; @@ -295,8 +295,8 @@ declare module DC { children(): Array>; shareColors: IGetSet; shareTitle: IGetSet; - rightY: IGetSet, CompositeChart>; - rightYAxis: IGetSet; + rightY: IGetSet<(n: any) => any, CompositeChart>; + rightYAxis: IGetSet; } export interface SeriesChart extends CompositeChart { @@ -314,9 +314,9 @@ declare module DC { export interface GeoChoroplethChart extends ColorMixin, BaseMixin { overlayGeoJson(json: any, name: string, keyAccessor: Accessor): void; - projection: IGetSet; + projection: IGetSet; geoJsons(): Array; - geoPath(): D3.Geo.Path; + geoPath(): d3.geo.Path; removeGeoJson(name: string): void; } @@ -325,9 +325,9 @@ declare module DC { } export interface RowChart extends CapMixin, MarginMixin, ColorMixin, BaseMixin { - x: IGetSet, RowChart>; + x: IGetSet<(n: any) => any, RowChart>; renderTitleLabel: IGetSet; - xAxis: IGetSet; + xAxis: IGetSet; fixedBarHeight: IGetSet; gap: IGetSet; elasticX: IGetSet; @@ -338,7 +338,7 @@ declare module DC { export interface ScatterPlot extends CoordinateGridMixin { existenceAccessor: IGetSet, ScatterPlot>; - symbol: IGetSet; + symbol: IGetSet, ScatterPlot>; symbolSize: IGetSet; highlightedSize: IGetSet; hiddenSize: IGetSet; @@ -392,7 +392,7 @@ declare module DC { renderAll(group?: string): void; redrawAll(group?: string): void; disableTransitions: boolean; - transition(selections: D3.Selection, duration: number, callback: (s: D3.Selection) => void): void; + transition(selections: d3.Selection, duration: number, callback: (s: d3.Selection) => void): void; units: Units; events: Events; From 6f60566a5e6cedc17778624d1a231be4f0745031 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Mon, 30 Mar 2015 15:28:48 -0400 Subject: [PATCH 008/397] add self to contributor header --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index dddef751b..e5b9c86c6 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1,6 +1,6 @@ // Type definitions for d3JS // Project: http://d3js.org/ -// Definitions by: Boris Yankov +// Definitions by: Alex Ford , Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module d3 { From 16d084b052cbbae8826835c2ab5fe1109bc1f9dd Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Tue, 31 Mar 2015 10:51:43 -0400 Subject: [PATCH 009/397] Add more default types for D3 scales --- d3/d3.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index e5b9c86c6..9aa91a874 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1502,8 +1502,11 @@ declare module d3 { copy(): Linear; } + export function sqrt(): Pow; export function sqrt(): Pow; export function sqrt(): Pow; + + export function pow(): Pow; export function pow(): Pow; export function pow(): Pow; @@ -1538,6 +1541,7 @@ declare module d3 { copy(): Pow; } + export function log(): Log; export function log(): Log; export function log(): Log; From b9546998e3f65e39b944164846396d13cd195986 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Tue, 31 Mar 2015 10:51:58 -0400 Subject: [PATCH 010/397] noImplicitAny compliance --- d3/d3-tests.ts | 193 +++++++++++++++++++++++++------------------------ 1 file changed, 100 insertions(+), 93 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 4750c2309..2bae83e43 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -113,11 +113,11 @@ function groupedBarChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.csv("data.csv", function (error, data: Array) { + d3.csv("data.csv", function (error: any, data: Array) { var ageNames = d3.keys(data[0]).filter(function (key) { return key !== "State"; }); data.forEach(function (d) { - d.ages = ageNames.map(function (name) { return { name: name, value: +d[name] }; }); + d.ages = ageNames.map(function (name) { return { name: name, value: +( d)[name] }; }); }); x0.domain(data.map(function (d) { return d.State; })); @@ -206,18 +206,18 @@ function stackedBarChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.csv("data.csv", function (error, data: any) { + d3.csv("data.csv", function (error: any, data: any) { color.domain(d3.keys(data[0]).filter(function (key) { return key !== "State"; })); - data.forEach(function (d) { + data.forEach(function (d: any) { var y0 = 0; d.ages = color.domain().map(function (name) { return { name: name, y0: y0, y1: y0 += +d[name] }; }); d.total = d.ages[d.ages.length - 1].y1; }); - data.sort(function (a, b) { return b.total - a.total; }); + data.sort(function (a: any, b: any) { return b.total - a.total; }); - x.domain(data.map(function (d) { return d.State; })); + x.domain(data.map(function (d: any) { return d.State; })); y.domain([0, d3.max(data, function (d: { total: number }) { return d.total; })]); svg.append("g") @@ -304,15 +304,15 @@ function normalizedBarChart() { d3.csv("data.csv", function (error, data) { color.domain(d3.keys(data[0]).filter(function (key) { return key !== "State"; })); - data.forEach(function (d) { + data.forEach(function (d: any) { var y0 = 0; d.ages = color.domain().map(function (name) { return { name: name, y0: y0, y1: y0 += +d[name] }; }); - d.ages.forEach(function (d) { d.y0 /= y0; d.y1 /= y0; }); + d.ages.forEach(function (d: any) { d.y0 /= y0; d.y1 /= y0; }); }); - data.sort(function (a, b) { return b.ages[0].y1 - a.ages[0].y1; }); + data.sort(function (a: any, b: any) { return b.ages[0].y1 - a.ages[0].y1; }); - x.domain(data.map(function (d) { return d.State; })); + x.domain(data.map(function (d: any) { return d.State; })); svg.append("g") .attr("class", "x axis") @@ -383,13 +383,13 @@ function sortablebarChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.tsv("data.tsv", function (error, data: any) { + d3.tsv("data.tsv", function (error: any, data: any) { - data.forEach(function (d) { + data.forEach(function (d: any) { d.frequency = +d.frequency; }); - x.domain(data.map(function (d) { return d.letter; })); + x.domain(data.map(function (d: any) { return d.letter; })); y.domain([0, d3.max(data, function (d: any) { return d.frequency; })]); svg.append("g") @@ -426,17 +426,17 @@ function sortablebarChart() { clearTimeout(sortTimeout); var x0 = x.domain(data.sort(this.checked - ? function (a, b) { return b.frequency - a.frequency; } - : function (a, b) { return d3.ascending(a.letter, b.letter); }) - .map(function (d) { return d.letter; })) + ? function (a: any, b: any) { return b.frequency - a.frequency; } + : function (a: any, b: any) { return d3.ascending(a.letter, b.letter); }) + .map(function (d: any) { return d.letter; })) .copy(); var transition = svg.transition().duration(750), - delay = function (d, i) { return i * 50; }; + delay = function (d: any, i: number) { return i * 50; }; transition.selectAll(".bar") .delay(delay) - .attr("x", function (d) { return x0(d.letter); }); + .attr("x", function (d: any) { return x0(d.letter); }); transition.select(".x.axis") .call(xAxis) @@ -506,7 +506,7 @@ function callenderView() { .text(function (d) { return d + ": " + percent(data[d]); }); }); - function monthPath(t0) { + function monthPath(t0: Date) { var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0), d0 = +day(t0), w0 = +week(t0), d1 = +day(t1), w1 = +week(t1); @@ -552,8 +552,8 @@ function lineChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.tsv("data.tsv", function (error, data) { - data.forEach(function (d) { + d3.tsv("data.tsv", function (error: any, data: any) { + data.forEach(function (d: any) { d.date = parseDate(d.date); d.close = +d.close; }); @@ -616,8 +616,8 @@ function bivariateAreaChart() { .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - d3.tsv("data.tsv", function (error, data: any) { - data.forEach(function (d) { + d3.tsv("data.tsv", function (error: any, data: any) { + data.forEach(function (d: any) { d.date = parseDate(d.date); d.low = +d.low; d.high = +d.high; @@ -670,7 +670,7 @@ function dragMultiples() { .attr("cy", function (d) { return d.y; }) .call(drag); - function dragmove(d) { + function dragmove(d: { x: number; y: number }) { d3.select(this) .attr("cx", d.x = Math.max(radius, Math.min(width - radius, ( d3.event).x))) .attr("cy", d.y = Math.max(radius, Math.min(height - radius, ( d3.event).y))); @@ -753,7 +753,7 @@ function chainedTransitions() { .attr("cy", y) .each(slide(20, w - 20)); - function slide(x0, x1) { + function slide(x0: number, x1: number) { t += 50; return function() { d3.select(this).transition() @@ -805,7 +805,7 @@ function populationPyramid() { .attr("dy", ".71em") .text(2000); - d3.csv("population.csv", function (error, rows: Array) { + d3.csv("population.csv", function (error: any, rows: Array) { // Convert strings to numbers. rows.forEach(function (d) { @@ -980,7 +980,7 @@ module forcedBasedLabelPlacemant { } ).style("fill", "#555").style("font-family", "Arial").style("font-size", 12); var updateLink = function () { - this.attr("x1", function (d) { + (> this).attr("x1", function (d) { return d.source.x; } ).attr("y1", function (d) { return d.source.y; @@ -993,7 +993,7 @@ module forcedBasedLabelPlacemant { } var updateNode = function () { - this.attr("transform", function (d) { + (> this).attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")"; } ); @@ -1044,9 +1044,9 @@ module forceCollapsable { var w = 1280, h = 800, - node, - link, - root; + node: d3.selection.Update, + link: d3.selection.Update>, + root: any; var force = d3.layout.force() .on("tick", tick) @@ -1124,12 +1124,12 @@ module forceCollapsable { } // Color leaf nodes orange, and packages white or blue. - function color(d) { + function color(d: Node) { return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c"; } // Toggle children on click. - function click(d) { + function click(d: Node) { if (d.children) { d._children = d.children; d.children = null; @@ -1141,12 +1141,12 @@ module forceCollapsable { } // Returns a list of all nodes under the root. - function flatten(root) { - var nodes = [], i = 0; + function flatten(root: Node) { + var nodes: Node[] = [], i = 0; - function recurse(node) { + function recurse(node: Node) { if (node.children) node.size = node.children.reduce(function (p, v) { return p + recurse(v); } , 0); - if (!node.id) node.id = ++i; + if (!node.id) node.id = String(++i); nodes.push(node); return node.size; } @@ -1202,7 +1202,7 @@ function azimuthalEquidistant() { .attr("d", path); svg.insert("path", ".graticule") - .datum(topojson.mesh(world, world.objects.countries, function (a, b) { return a !== b; } )) + .datum(topojson.mesh(world, world.objects.countries, function (a: any, b: any) { return a !== b; } )) .attr("class", "boundary") .attr("d", path); } ); @@ -1251,7 +1251,6 @@ function forceDirectedVoronoi() { var w = window.innerWidth > 960 ? 960 : (window.innerWidth || 960), h = window.innerHeight > 500 ? 500 : (window.innerHeight || 500), radius = 5.25, - links = [], simulate = true, zoomToAdd = true, color = d3.scale.quantize().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]) @@ -1441,7 +1440,7 @@ function quadtree() { brushed(); function brushed() { - var extent = brush.extent(); + var extent = <[[number, number], [number, number]]> brush.extent(); point.each(function (d) { d.scanned = d.selected = false; } ); search(quadtree, extent[0][0], extent[0][1], extent[1][0], extent[1][1]); point.classed("scanned", function (d) { return d.scanned; } ); @@ -1449,8 +1448,8 @@ function quadtree() { } // Collapse the quadtree into an array of rectangles. - function nodes(quadtree) { - var nodes = []; + function nodes(quadtree: d3.geom.quadtree.Quadtree<[number, number]>) { + var nodes: Array<{x: number; y: number; width: number; height: number}> = []; quadtree.visit(function (node, x1, y1, x2, y2) { nodes.push({ x: x1, y: y1, width: x2 - x1, height: y2 - y1 }); } ); @@ -1458,12 +1457,12 @@ function quadtree() { } // Find the nodes within the specified rectangle. - function search(quadtree, x0, y0, x3, y3) { + function search(quadtree: d3.geom.quadtree.Quadtree<{ scanned?: boolean; selected?: boolean; 0: number; 1: number }>, x0: number, y0: number, x3: number, y3: number) { quadtree.visit(function (node, x1, y1, x2, y2) { var p = node.point; if (p) { p.scanned = true; - p.selected = (p.x >= x0) && (p.x < x3) && (p.y >= y0) && (p.y < y3); + p.selected = (p[0] >= x0) && (p[0] < x3) && (p[1] >= y0) && (p[1] < y3); } return x1 >= x3 || y1 >= y3 || x2 < x0 || y2 < y0; } ); @@ -1563,11 +1562,11 @@ module hierarchicalEdgeBundling { var packages = { // Lazily construct the package hierarchy from class names. - root: function (classes) { - var map = {}; + root: function (classes: any[]) { + var map: {[key: string]: Result} = {}; - function find(name, data?) { - var node = map[name], i; + function find(name: string, data?: any) { + var node: Result = map[name], i: number; if (!node) { node = map[name] = data || { name: name, children: [] }; if (name.length) { @@ -1587,9 +1586,9 @@ module hierarchicalEdgeBundling { } , // Return a list of imports for the given array of nodes. - imports: function (nodes) { - var map = {}, - imports = []; + imports: function (nodes: any[]) { + var map: {[key: string]: Result} = {}, + imports: d3.layout.cluster.Link[] = []; // Compute a map from name to node. nodes.forEach(function (d) { @@ -1598,7 +1597,7 @@ module hierarchicalEdgeBundling { // For each import, construct a link from the source to target node. nodes.forEach(function (d) { - if (d.imports) d.imports.forEach(function (i) { + if (d.imports) d.imports.forEach(function (i: string) { imports.push({ source: map[d.name], target: map[i] }); } ); } ); @@ -1702,9 +1701,9 @@ function streamGraph() { } // Inspired by Lee Byron's test data generator. - function bumpLayer(n): Array<{x: number; y: number;y0?:number;}> { + function bumpLayer(n: number): Array<{x: number; y: number;y0?:number;}> { - function bump(a) { + function bump(a: number[]) { var x = 1 / (.1 + Math.random()), y = 2 * Math.random() - .5, z = 10 / (.1 + Math.random()); @@ -1714,7 +1713,7 @@ function streamGraph() { } } - var a = [], i; + var a: number[] = [], i: number; for (i = 0; i < n; ++i) a[i] = 0; for (i = 0; i < 5; ++i) bump(a); return a.map(function (d, i) { return { x: i, y: Math.max(0, d) }; } ); @@ -1724,6 +1723,7 @@ function streamGraph() { // example from http://mbostock.github.io/d3/talk/20111116/force-collapsible.html module forceCollapsable2 { interface Node extends d3.layout.force.Node { + children: Node[]; _children: Node[]; size: number; id: string; @@ -1731,9 +1731,9 @@ module forceCollapsable2 { var w = 1280, h = 800, - node, - link, - root; + node: d3.selection.Update, + link: d3.selection.Update>, + root: Node; var force = d3.layout.force() .on("tick", tick) @@ -1811,12 +1811,12 @@ module forceCollapsable2 { } // Color leaf nodes orange, and packages white or blue. - function color(d) { + function color(d: Node) { return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c"; } // Toggle children on click. - function click(d) { + function click(d: Node) { if (d.children) { d._children = d.children; d.children = null; @@ -1828,12 +1828,12 @@ module forceCollapsable2 { } // Returns a list of all nodes under the root. - function flatten(root) { - var nodes = [], i = 0; + function flatten(root: Node) { + var nodes: Node[] = [], i = 0; - function recurse(node) { + function recurse(node: Node) { if (node.children) node.size = node.children.reduce(function (p, v) { return p + recurse(v); } , 0); - if (!node.id) node.id = ++i; + if (!node.id) node.id = String(++i); nodes.push(node); return node.size; } @@ -1915,7 +1915,7 @@ function chordDiagram() { .style("opacity", 1); // Returns an array of tick angles and labels, given a group. - function groupTicks(d) { + function groupTicks(d: d3.layout.chord.Node) { var k = (d.endAngle - d.startAngle) / d.value; return d3.range(0, d.value, 1000).map(function (v, i) { return { @@ -1926,8 +1926,8 @@ function chordDiagram() { } // Returns an event handler for fading a given chord group. - function fade(opacity) { - return function (g, i) { + function fade(opacity: number) { + return function (g: {}, i: number) { svg.selectAll(".chord path") .filter(function (d) { return d.source.index != i && d.target.index != i; } ) .transition() @@ -1946,11 +1946,11 @@ function irisParallel() { h = 800 - m[0] - m[2]; var x = d3.scale.ordinal().domain(traits).rangePoints([0, w]), - y = {}; + y: {[key: string]: any} = {}; var line = d3.svg.line(), axis = d3.svg.axis().orient("left"), - foreground; + foreground: d3.Selection<{ [key: string]: string}>; var svg = d3.select("body").append("svg:svg") .attr("width", w + m[1] + m[3]) @@ -2004,7 +2004,7 @@ function irisParallel() { .attr("class", "trait") .attr("transform", function (d) { return "translate(" + x(d) + ")"; } ) .call(d3.behavior.drag() - .origin(function (d) { return { x: x(d), y: undefined }; } ) + .origin(function (d) { return { x: x(d), y: NaN }; } ) .on("dragstart", dragstart) .on("drag", drag) .on("dragend", dragend)); @@ -2026,18 +2026,18 @@ function irisParallel() { .attr("x", -8) .attr("width", 16); - function dragstart(d) { + function dragstart(d: string) { i = traits.indexOf(d); } - function drag(d) { + function drag(d: string) { x.range()[i] = ( d3.event).x; traits.sort(function (a, b) { return x(a) - x(b); } ); g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); foreground.attr("d", path); } - function dragend(d) { + function dragend(d: string) { x.domain(traits).rangePoints([0, w]); var t = d3.transition().duration(500); t.selectAll(".trait").attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); @@ -2046,7 +2046,7 @@ function irisParallel() { } ); // Returns the path for a given data point. - function path(d) { + function path(d: any): string { return line(traits.map(function (p): [number, number] { return [x(p), y[p](d[p])]; } )); } @@ -2065,11 +2065,11 @@ function irisParallel() { //example from function healthAndWealth() { // Various accessors that specify the four dimensions of data to visualize. - function x(d) { return d.income; } - function y(d) { return d.lifeExpectancy; } - function radius(d) { return d.population; } - function color(d) { return d.region; } - function key(d) { return d.name; } + function x(d: any) { return d.income; } + function y(d: any) { return d.lifeExpectancy; } + function radius(d: any) { return d.population; } + function color(d: any) { return d.region; } + function key(d: any) { return d.name; } // Chart dimensions. var margin = { top: 19.5, right: 19.5, bottom: 19.5, left: 39.5 }, @@ -2133,7 +2133,7 @@ function healthAndWealth() { d3.json("nations.json", function (nations: any[]) { // A bisector since many nation's data is sparsely-defined. - var bisect = d3.bisector(function (d) { return d[0]; } ); + var bisect = d3.bisector(function (d: any) { return d[0]; } ); // Add a dot per nation. Initialize the data at 1800, and set the colors. var dot = svg.append("g") @@ -2169,14 +2169,14 @@ function healthAndWealth() { .each("end", enableInteraction); // Positions the dots based on data. - function position(dot) { + function position(dot: d3.Selection) { dot.attr("cx", function (d) { return xScale(x(d)); } ) .attr("cy", function (d) { return yScale(y(d)); } ) .attr("r", function (d) { return radiusScale(radius(d)); } ); } // Defines a sort order so that the smallest dots are drawn on top. - function order(a, b) { + function order(a: any, b: any) { return radius(b) - radius(a); } @@ -2213,17 +2213,17 @@ function healthAndWealth() { // For the interpolated data, the dots and label are redrawn. function tweenYear() { var year = d3.interpolateNumber(1800, 2009); - return function (t) { displayYear(year(t)); }; + return function (t: number) { displayYear(year(t)); }; } // Updates the display to show the specified year. - function displayYear(year) { + function displayYear(year: number) { dot.data(interpolateData(year), key).call(position).sort(order); label.text(Math.round(year)); } // Interpolates the dataset for the given (fractional) year. - function interpolateData(year) { + function interpolateData(year: number) { return nations.map(function (d) { return { name: d.name, @@ -2236,7 +2236,7 @@ function healthAndWealth() { } // Finds (and possibly interpolates) the value for the specified year. - function interpolateValues(values, year) { + function interpolateValues(values: any[], year: number) { var i = bisect.left(values, year, 0, values.length - 1), a = values[i]; if (i > 0) { @@ -2252,7 +2252,7 @@ function healthAndWealth() { // Test for d3.functor function functorTest () { var f: (n: number) => number = d3.functor(10); - var g = d3.functor(function (v) { return v; }); + var g = d3.functor(function (v: number) { return v; }); return f(10) === g(10); } @@ -2287,7 +2287,7 @@ function nestTest () { var n2 = d3.nest<{ a: number; b: number[] }>() .key(function (d) { return String(d.a); }) .sortValues(function (x1, x2) { - return x1[0] < x1[1] ? -1 : (x1[0] > x1[0] ? 1 : 0); }); + return x1.b[0] < x1.b[1] ? -1 : (x1.b[0] > x1.b[0] ? 1 : 0); }); n2.map(data); n2.entries(data); @@ -2387,7 +2387,7 @@ function brushTest() { .x(xScale) .y(yScale) .on('brush', function () { - var extent = brush2.extent(); + var extent = <[[number, number], [number, number]]> brush2.extent(); var xExtent = extent[0], yExtent = extent[1]; @@ -2538,25 +2538,32 @@ function svgArcTest () { l.innerRadius(f).innerRadius() === f; l.innerRadius(0); - l.innerRadius(function (d) { return d[0]; }); + l.innerRadius(function (d) { return d.innerRadius; }); l.innerRadius(function (d, i) { return i; }); l.outerRadius(f).outerRadius() === f; l.outerRadius(0); - l.outerRadius(function (d) { return d[1]; }); + l.outerRadius(function (d) { return d.outerRadius; }); l.outerRadius(function (d, i) { return i; }); l.startAngle(f).startAngle() === f; l.startAngle(0); - l.startAngle(function (d) { return d[0]; }); + l.startAngle(function (d) { return d.innerRadius; }); l.startAngle(function (d, i) { return i; }); l.endAngle(f).endAngle() === f; l.endAngle(0); - l.endAngle(function (d) { return d[1]; }); + l.endAngle(function (d) { return d.outerRadius; }); l.endAngle(function (d, i) { return i; }); } +function svgArcTest2 () { + var l = d3.svg.arc<[number, number]>(); + + l.innerRadius(d => d[0]); + l.outerRadius(d => d[1]); +} + // Tests for d3.svg.diagonal // Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/diagonal-test.js function svgDiagonalTest () { From 663240f96936f0aa16f9e175241e3890f3c461dc Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Tue, 31 Mar 2015 11:03:02 -0400 Subject: [PATCH 011/397] ordinal scales use any string-coercible type --- d3/d3-tests.ts | 6 +++--- d3/d3.d.ts | 39 ++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 2bae83e43..5db3528f5 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -738,7 +738,7 @@ function panAndZoom() { function chainedTransitions() { var w = 960, h = 500, - y = d3.scale.ordinal().domain(d3.range(50)).rangePoints([20, h - 20]), + y = d3.scale.ordinal().domain(d3.range(50)).rangePoints([20, h - 20]), t = Date.now(); var svg = d3.select("body").append("svg:svg") @@ -1629,7 +1629,7 @@ function roundedRectangles() { .attr("width", 25) .attr("height", 25) .attr("transform", function (d, i) { return "scale(" + (1 - d / 25) * 20 + ")"; } ) - .style("fill", d3.scale.category20c()); + .style("fill", d3.scale.category20c()); var g0 = g.datum(function (d) { return { center: [0, 0], angle: 0 }; @@ -1862,7 +1862,7 @@ function chordDiagram() { innerRadius = Math.min(width, height) * .41, outerRadius = innerRadius * 1.1; - var fill = d3.scale.ordinal() + var fill = d3.scale.ordinal() .domain(d3.range(4)) .range(["#000000", "#FFDD89", "#957244", "#F26223"]); diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 9aa91a874..18a27790b 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1627,31 +1627,36 @@ declare module d3 { copy(): Threshold; } - export function ordinal(): Ordinal; - export function category10(): Ordinal; - export function category20(): Ordinal; - export function category20b(): Ordinal; - export function category20c(): Ordinal; + export function ordinal(): Ordinal; + export function ordinal(): Ordinal; + export function category10(): Ordinal; + export function category10(): Ordinal; + export function category20(): Ordinal; + export function category20(): Ordinal; + export function category20b(): Ordinal; + export function category20b(): Ordinal; + export function category20c(): Ordinal; + export function category20c(): Ordinal; + + interface Ordinal { + (x: Domain): Range; - interface Ordinal { - (x: Primitive): T; + domain(): Domain[]; + domain(values: Domain[]): Ordinal; - domain(): string[]; - domain(values: Primitive[]): Ordinal; + range(): Range[]; + range(values: Range[]): Ordinal; - range(): T[]; - range(values: T[]): Ordinal; + rangePoints(interval: [number, number], padding?: number): Ordinal; + rangeRoundPoints(interval: [number, number], padding?: number): Ordinal; - rangePoints(interval: [number, number], padding?: number): Ordinal; - rangeRoundPoints(interval: [number, number], padding?: number): Ordinal; - - rangeBands(interval: [number, number], padding?: number, outerPadding?: number): Ordinal; - rangeRoundBands(interval: [number, number], padding?: number, outerPadding?: number): Ordinal; + rangeBands(interval: [number, number], padding?: number, outerPadding?: number): Ordinal; + rangeRoundBands(interval: [number, number], padding?: number, outerPadding?: number): Ordinal; rangeBand(): number; rangeExtent(): [number, number]; - copy(): Ordinal; + copy(): Ordinal; } } From c390cc036fa7b9336ba8be9784c0e18c459dacc3 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Tue, 31 Mar 2015 11:06:14 -0400 Subject: [PATCH 012/397] Correct failing build. --- d3.cloud.layout/d3.cloud.layout-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/d3.cloud.layout/d3.cloud.layout-tests.ts b/d3.cloud.layout/d3.cloud.layout-tests.ts index c22d76b36..9d5ed7b71 100644 --- a/d3.cloud.layout/d3.cloud.layout-tests.ts +++ b/d3.cloud.layout/d3.cloud.layout-tests.ts @@ -10,7 +10,7 @@ } - var fill = d3.scale.category20(); + var fill = d3.scale.category20(); d3.layout.cloud().size([300, 300]) .words([ "Hello", "world", "normally", "you", "want", "more", "words", @@ -40,4 +40,4 @@ return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")"; }) .text(function(d:ICompTextSize) { return d.text; }); - } \ No newline at end of file + } From 5532887980800ceef4d93f7a6b43188662d709f9 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Tue, 31 Mar 2015 19:44:31 -0400 Subject: [PATCH 013/397] require scale-like behavior of dc.js scales --- dcjs/dc.d.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dcjs/dc.d.ts b/dcjs/dc.d.ts index 5382c9b76..62739e16a 100644 --- a/dcjs/dc.d.ts +++ b/dcjs/dc.d.ts @@ -20,6 +20,16 @@ declare module DC { (t: T, r?: R): V; } + export interface Scale { + (x: any): T; + + domain(values: any[]): Scale; + domain(): any[]; + + range(values: T[]): Scale; + range(): T[]; + } + export interface Accessor { (datum: T, index?: number): V; } @@ -160,9 +170,9 @@ declare module DC { } export interface ColorMixin { - colors: IGetSet | { (n: number): string; domain(colors: any[]): any }, T>; + colors: IGetSet | Scale, T>; ordinalColors(r: Array): void; - linearColors(r: Array): void; + linearColors(r: Array): void; colorAccessor: IGetSet, T>; colorDomain: IGetSet, T>; calculateColorDomain(): void; @@ -187,7 +197,7 @@ declare module DC { isOrdinal(): boolean; xAxisLabel: IBiGetSet; yAxisLabel: IBiGetSet; - y: IGetSet<(n: any) => any, T>; + y: IGetSet, T>; yAxis: IGetSet; elasticY: IGetSet; renderHorizontalGridLines: IGetSet; @@ -219,7 +229,7 @@ declare module DC { } export interface BubbleMixin extends ColorMixin { - r: IGetSet<(n: any) => any, T>; + r: IGetSet, T>; radiusValueAccessor: IGetSet, T>; minRadiusWithLabel: IGetSet; maxBubbleRelativeSize: IGetSet; @@ -325,7 +335,7 @@ declare module DC { } export interface RowChart extends CapMixin, MarginMixin, ColorMixin, BaseMixin { - x: IGetSet<(n: any) => any, RowChart>; + x: IGetSet, RowChart>; renderTitleLabel: IGetSet; xAxis: IGetSet; fixedBarHeight: IGetSet; From 23515939b9df8c4525dad8ac3d063810700ec9cf Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Fri, 3 Apr 2015 15:36:58 -0400 Subject: [PATCH 014/397] remove refs to non-existent "D3" --- d3/d3-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 15be39839..5db3528f5 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -475,7 +475,7 @@ function callenderView() { .style("text-anchor", "middle") .text(function (d) { return d; }); - var rect: D3.UpdateSelection = svg.selectAll(".day") + var rect = svg.selectAll(".day") .data(function (d) { return d3.time.days(new Date(d, 0, 1), new Date(d + 1, 0, 1)); }) .enter().append("rect") .attr("class", "day") @@ -973,7 +973,7 @@ module forcedBasedLabelPlacemant { var anchorLink = vis.selectAll("line.anchorLink").data(labelAnchorLinks)//.enter().append("svg:line").attr("class", "anchorLink").style("stroke", "#999"); - var anchorNode: D3.Selection = vis.selectAll("g.anchorNode").data(force2.nodes()).enter().append("svg:g").attr("class", "anchorNode"); + var anchorNode = vis.selectAll("g.anchorNode").data(force2.nodes()).enter().append("svg:g").attr("class", "anchorNode"); anchorNode.append("svg:circle").attr("r", 0).style("fill", "#FFF"); anchorNode.append("svg:text").text(function (d, i) { return i % 2 == 0 ? "" : d.node.label From 5ea1c5b513fee483cd2ee02e3c93d4d1b62cad2d Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Mon, 4 May 2015 15:11:12 -0500 Subject: [PATCH 015/397] Add type declarations for unorm: both importable module and ambient var --- unorm/unorm.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 unorm/unorm.d.ts diff --git a/unorm/unorm.d.ts b/unorm/unorm.d.ts new file mode 100644 index 000000000..9f96fcef0 --- /dev/null +++ b/unorm/unorm.d.ts @@ -0,0 +1,14 @@ +declare module unorm { + interface Static { + nfd(str: string): string; + nfkd(str: string): string; + nfc(str: string): string; + nfkc(str: string): string; + } +} + +declare var unorm: unorm.Static; + +declare module "unorm" { + export = unorm; +} From dde696d52e8a992a060db9e7fca64652984aa803 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Mon, 4 May 2015 13:55:19 -0500 Subject: [PATCH 016/397] Add virtual-dom type declarations, based on virtual-dom's docs.jsig --- virtual-dom/virtual-dom.d.ts | 121 +++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 virtual-dom/virtual-dom.d.ts diff --git a/virtual-dom/virtual-dom.d.ts b/virtual-dom/virtual-dom.d.ts new file mode 100644 index 000000000..70166515f --- /dev/null +++ b/virtual-dom/virtual-dom.d.ts @@ -0,0 +1,121 @@ +declare module VirtualDOM { + interface VHook { + hook(node: Element, propertyName: string): void; + unhook(node: Element, propertyName: string): void; + } + + type EventHandler = (...args: any[]) => void; + + interface VProperties { + attributes?: {[index: string]: string}; + /** + I would like to use {[index: string]: string}, but then we couldn't use an + object literal when setting the styles, since TypeScript doesn't seem to + infer that {'fontSize': string; 'fontWeight': string;} is actually quite + assignable to the type { [index: string]: string; } + */ + style?: any; + /** + The relaxation on `style` above is the reason why we need `any` as an option + on the indexer type. + */ + [index: string]: any | string | boolean | number | VHook | EventHandler | {[index: string]: string | boolean | number}; + } + + interface VNode { + tagName: string; + properties: VProperties; + children: VTree[]; + key?: string; + namespace?: string; + count: number; + hasWidgets: boolean; + hasThunks: boolean; + hooks: any[]; + descendantHooks: any[]; + version: string; + type: string; // 'VirtualNode' + } + + interface VText { + text: string; + new (text: any); + version: string; + type: string; // 'VirtualText' + } + + interface Widget { + type: string; // 'Widget' + init(): Element; + update(previous: Widget, domNode: Element): void; + destroy(node: Element): void; + } + + interface Thunk { + type: string; // 'Thunk' + vnode: VTree; + render(previous: VTree): VTree; + } + + type VTree = VText | VNode | Widget | Thunk; + + // enum VPatch { + // NONE = 0, + // VTEXT = 1, + // VNODE = 2, + // WIDGET = 3, + // PROPS = 4, + // ORDER = 5, + // INSERT = 6, + // REMOVE = 7, + // THUNK = 8 + // } + interface VPatch { + vNode: VNode, + patch: any; + new(type: number, vNode: VNode, patch: any): VPatch; + version: string; + /** + type is set to 'VirtualPatch' on the prototype, but overridden in the + constructor with a number. + */ + type: number; + } + + interface createProperties extends VProperties { + key?: string; + namespace?: string; + } + type createChildren = Array; + + /** + create() calls either document.createElement() or document.createElementNS(), + for which the common denominator is Element (not HTMLElement). + */ + function create(vnode: VText, opts?: {document?: Document, warn?: boolean}): Text; + function create(vnode: VNode | Widget | Thunk, opts?: {document?: Document, warn?: boolean}): Element; + function h(tagName: string, properties: createProperties, ...children: createChildren): VNode; + function h(tagName: string, ...children: createChildren): VNode; + function diff(left: VTree, right: VTree): VPatch[]; + /** + patch() usually just returns rootNode after doing stuff to it, so we want + to preserve that type (though it will usually be just Element). + */ + function patch(rootNode: T, patches: VPatch[], renderOptions?: any): T; +} + +declare module "virtual-dom/h" { + export = VirtualDOM.h; +} +declare module "virtual-dom/create-element" { + export = VirtualDOM.create; +} +declare module "virtual-dom/diff" { + export = VirtualDOM.diff; +} +declare module "virtual-dom/patch" { + export = VirtualDOM.patch; +} +declare module "virtual-dom" { + export = VirtualDOM; +} From 0faae8ebf7f8e4c3cab38ef35ffd4a814b811c7b Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Fri, 15 May 2015 13:00:47 -0500 Subject: [PATCH 017/397] Collapse createChildren and rename as 'VChild' --- virtual-dom/virtual-dom.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/virtual-dom/virtual-dom.d.ts b/virtual-dom/virtual-dom.d.ts index 70166515f..7023d38fd 100644 --- a/virtual-dom/virtual-dom.d.ts +++ b/virtual-dom/virtual-dom.d.ts @@ -86,7 +86,8 @@ declare module VirtualDOM { key?: string; namespace?: string; } - type createChildren = Array; + + type VChild = VTree[] | VTree | string[] | string; /** create() calls either document.createElement() or document.createElementNS(), @@ -94,8 +95,8 @@ declare module VirtualDOM { */ function create(vnode: VText, opts?: {document?: Document, warn?: boolean}): Text; function create(vnode: VNode | Widget | Thunk, opts?: {document?: Document, warn?: boolean}): Element; - function h(tagName: string, properties: createProperties, ...children: createChildren): VNode; - function h(tagName: string, ...children: createChildren): VNode; + function h(tagName: string, properties: createProperties, ...children: VChild[]): VNode; + function h(tagName: string, ...children: VChild[]): VNode; function diff(left: VTree, right: VTree): VPatch[]; /** patch() usually just returns rootNode after doing stuff to it, so we want From 1e2a1e22e5c44adb10667dc5bd91a2367f3af288 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Fri, 15 May 2015 13:07:19 -0500 Subject: [PATCH 018/397] Fix h() signatures to reflect virtual-hyperscript readme (I must have misread the jsig file) --- virtual-dom/virtual-dom.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtual-dom/virtual-dom.d.ts b/virtual-dom/virtual-dom.d.ts index 7023d38fd..10575e8ca 100644 --- a/virtual-dom/virtual-dom.d.ts +++ b/virtual-dom/virtual-dom.d.ts @@ -95,8 +95,8 @@ declare module VirtualDOM { */ function create(vnode: VText, opts?: {document?: Document, warn?: boolean}): Text; function create(vnode: VNode | Widget | Thunk, opts?: {document?: Document, warn?: boolean}): Element; - function h(tagName: string, properties: createProperties, ...children: VChild[]): VNode; - function h(tagName: string, ...children: VChild[]): VNode; + function h(tagName: string, properties: createProperties, children: string | VChild[]): VNode; + function h(tagName: string, children: string | VChild[]): VNode; function diff(left: VTree, right: VTree): VPatch[]; /** patch() usually just returns rootNode after doing stuff to it, so we want From e1210e53158790023ab52a15207762f2e7b2e917 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 May 2015 19:26:58 +0200 Subject: [PATCH 019/397] jasmine ajax defs --- jasmine-ajax/jasmine-ajax-tests.ts | 1818 ++++++++++++++++++ jasmine-ajax/jasmine-ajax-tests.ts.tscparams | 1 + jasmine-ajax/jasmine-ajax.d.ts | 77 + 3 files changed, 1896 insertions(+) create mode 100644 jasmine-ajax/jasmine-ajax-tests.ts create mode 100644 jasmine-ajax/jasmine-ajax-tests.ts.tscparams create mode 100644 jasmine-ajax/jasmine-ajax.d.ts diff --git a/jasmine-ajax/jasmine-ajax-tests.ts b/jasmine-ajax/jasmine-ajax-tests.ts new file mode 100644 index 000000000..b5134d2cf --- /dev/null +++ b/jasmine-ajax/jasmine-ajax-tests.ts @@ -0,0 +1,1818 @@ +/** + * Tests adapted from: https://github.com/jasmine/jasmine-ajax + * By Louis Grignon + */ + +/// +/// + +describe('StubTracker', function() { + beforeEach(function() { + var Constructor = getJasmineRequireObj().AjaxStubTracker(); + this.tracker = new Constructor(); + }); + + it('finds nothing if no stubs are added', function() { + expect(this.tracker.findStub()).toBeUndefined(); + }); + + it('finds an added stub', function() { + var stub = { matches: function() { return true; } }; + this.tracker.addStub(stub); + + expect(this.tracker.findStub()).toBe(stub); + }); + + it('skips an added stub that does not match', function() { + var stub = { matches: function() { return false; } }; + this.tracker.addStub(stub); + + expect(this.tracker.findStub()).toBeUndefined(); + }); + + it('passes url, data, and method to the stub', function() { + var stub = { matches: jasmine.createSpy('matches') }; + this.tracker.addStub(stub); + + this.tracker.findStub('url', 'data', 'method'); + + expect(stub.matches).toHaveBeenCalledWith('url', 'data', 'method'); + }); + + it('can clear out all stubs', function() { + var stub = { matches: jasmine.createSpy('matches') }; + this.tracker.addStub(stub); + + this.tracker.findStub(); + + expect(stub.matches).toHaveBeenCalled(); + + this.tracker.reset(); + stub.matches.calls.reset(); + + this.tracker.findStub(); + + expect(stub.matches).not.toHaveBeenCalled(); + }); + + it('uses the most recently added stub that matches', function() { + var stub1 = { matches: function() { return true; } }; + var stub2 = { matches: function() { return true; } }; + var stub3 = { matches: function() { return false; } }; + + this.tracker.addStub(stub1); + this.tracker.addStub(stub2); + this.tracker.addStub(stub3); + + expect(this.tracker.findStub()).toBe(stub2); + }); +}); + +describe('FakeRequest', function() { + beforeEach(function() { + this.requestTracker = { track: jasmine.createSpy('trackRequest') }; + this.stubTracker = { findStub: function() {} }; + var parserInstance = this.parserInstance = jasmine.createSpy('parse'); + this.paramParser = { findParser: function() { return { parse: parserInstance }; } }; + var eventBus = this.fakeEventBus = { + addEventListener: jasmine.createSpy('addEventListener'), + trigger: jasmine.createSpy('trigger'), + removeEventListener: jasmine.createSpy('removeEventListener') + }; + this.eventBusFactory = function() { + return eventBus; + }; + this.fakeGlobal = { + XMLHttpRequest: function() { + this.extraAttribute = 'my cool attribute'; + }, + DOMParser: window['DOMParser'], + ActiveXObject: window['ActiveXObject'] + }; + this.FakeRequest = getJasmineRequireObj().AjaxFakeRequest(this.eventBusFactory)(this.fakeGlobal, this.requestTracker, this.stubTracker, this.paramParser); + }); + + it('extends from the global XMLHttpRequest', function() { + var request = new this.FakeRequest(); + + expect(request.extraAttribute).toEqual('my cool attribute'); + }); + + it('skips XMLHttpRequest attributes that IE does not want copied', function() { + // use real window here so it will correctly go red on IE if it breaks + var FakeRequest = getJasmineRequireObj().AjaxFakeRequest(this.eventBusFactory)(window, this.requestTracker, this.stubTracker, this.paramParser); + var request = new FakeRequest(); + + expect(request.responseBody).toBeUndefined(); + expect(request.responseXML).toBeUndefined(); + expect(request.statusText).toBeUndefined(); + }); + + it('tracks the request', function() { + var request = new this.FakeRequest(); + + expect(this.requestTracker.track).toHaveBeenCalledWith(request); + }); + + it('has default request headers and override mime type', function() { + var request = new this.FakeRequest(); + + expect(request.requestHeaders).toEqual({}); + expect(request.overriddenMimeType).toBeNull(); + }); + + it('saves request information when opened', function() { + var request = new this.FakeRequest(); + request.open('METHOD', 'URL', 'ignore_async', 'USERNAME', 'PASSWORD'); + + expect(request.method).toEqual('METHOD'); + expect(request.url).toEqual('URL'); + expect(request.username).toEqual('USERNAME'); + expect(request.password).toEqual('PASSWORD'); + }); + + it('saves an override mime type', function() { + var request = new this.FakeRequest(); + + request.overrideMimeType('application/text; charset: utf-8'); + + expect(request.overriddenMimeType).toBe('application/text; charset: utf-8'); + }); + + it('saves request headers', function() { + var request = new this.FakeRequest(); + + request.setRequestHeader('X-Header-1', 'value1'); + request.setRequestHeader('X-Header-2', 'value2'); + + expect(request.requestHeaders).toEqual({ + 'X-Header-1': 'value1', + 'X-Header-2': 'value2' + }); + }); + + it('combines request headers with the same header name', function() { + var request = new this.FakeRequest(); + + request.setRequestHeader('X-Header', 'value1'); + request.setRequestHeader('X-Header', 'value2'); + + expect(request.requestHeaders['X-Header']).toEqual('value1, value2'); + }); + + it('finds the content-type request header', function() { + var request = new this.FakeRequest(); + + request.setRequestHeader('ContEnt-tYPe', 'application/text+xml'); + + expect(request.contentType()).toEqual('application/text+xml'); + }); + + describe('managing readyState', function() { + beforeEach(function() { + this.request = new this.FakeRequest(); + }); + + it('has an initial ready state of 0 (uninitialized)', function() { + expect(this.request.readyState).toBe(0); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalled(); + }); + + it('has a ready state of 1 (open) when opened', function() { + this.request.open(); + + expect(this.request.readyState).toBe(1); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 0 (uninitialized) when aborted', function() { + this.request.open(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.abort(); + + expect(this.request.readyState).toBe(0); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 1 (sent) when sent', function() { + this.request.open(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.send(); + + expect(this.request.readyState).toBe(1); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 4 (loaded) when timed out', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + jasmine.clock().install(); + this.request.responseTimeout(); + jasmine.clock().uninstall(); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange', 'timeout'); + }); + + it('has a ready state of 4 (loaded) when network erroring', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.responseError(); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 4 (loaded) when responding', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.respondWith({}); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 2, then 4 (loaded) when responding', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + var request = this.request; + var events = []; + var headers = [ + { name: 'X-Header', value: 'foo' } + ]; + + this.fakeEventBus.trigger.and.callFake(function(event) { + if (event === 'readystatechange') { + events.push({ + readyState: request.readyState, + status: request.status, + statusText: request.statusText, + responseHeaders: request.responseHeaders + }); + } + }); + + this.request.respondWith({ + status: 200, + statusText: 'OK', + responseHeaders: headers + }); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(events.length).toBe(2); + expect(events).toEqual([ + { readyState: 2, status: 200, statusText: 'OK', responseHeaders: headers }, + { readyState: 4, status: 200, statusText: 'OK', responseHeaders: headers } + ]); + }); + + it('throws an error when timing out a request that has completed', function() { + this.request.open(); + this.request.send(); + this.request.respondWith({}); + var request = this.request; + + expect(function() { + request.responseTimeout(); + }).toThrowError('FakeXMLHttpRequest already completed'); + }); + + it('throws an error when responding to a request that has completed', function() { + this.request.open(); + this.request.send(); + this.request.respondWith({}); + var request = this.request; + + expect(function() { + request.respondWith({}); + }).toThrowError('FakeXMLHttpRequest already completed'); + }); + + it('throws an error when erroring a request that has completed', function() { + this.request.open(); + this.request.send(); + this.request.respondWith({}); + var request = this.request; + + expect(function() { + request.responseError({}); + }).toThrowError('FakeXMLHttpRequest already completed'); + }); + }); + + it('registers on-style callback with the event bus', function() { + this.request = new this.FakeRequest(); + + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('readystatechange', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('loadstart', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('progress', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('abort', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('error', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('load', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('timeout', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('loadend', jasmine.any(Function)); + + this.request.onreadystatechange = jasmine.createSpy('readystatechange'); + this.request.onloadstart = jasmine.createSpy('loadstart'); + this.request.onprogress = jasmine.createSpy('progress'); + this.request.onabort = jasmine.createSpy('abort'); + this.request.onerror = jasmine.createSpy('error'); + this.request.onload = jasmine.createSpy('load'); + this.request.ontimeout = jasmine.createSpy('timeout'); + this.request.onloadend = jasmine.createSpy('loadend'); + + var args = this.fakeEventBus.addEventListener.calls.allArgs(); + for (var i = 0; i < args.length; i++) { + var eventName = args[i][0], + busCallback = args[i][1]; + + busCallback(); + expect(this.request['on' + eventName]).toHaveBeenCalled(); + } + }); + + it('delegates addEventListener to the eventBus', function() { + this.request = new this.FakeRequest(); + + this.request.addEventListener('foo', 'bar'); + + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('foo', 'bar'); + }); + + it('delegates removeEventListener to the eventBus', function() { + this.request = new this.FakeRequest(); + + this.request.removeEventListener('foo', 'bar'); + + expect(this.fakeEventBus.removeEventListener).toHaveBeenCalledWith('foo', 'bar'); + }); + + describe('triggering progress events', function() { + beforeEach(function() { + this.request = new this.FakeRequest(); + }); + + it('should not trigger any events to start', function() { + this.request.open(); + + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('should trigger loadstart when sent', function() { + this.request.open(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.send(); + + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadend'); + }); + + it('should trigger abort, progress, loadend when aborted', function() { + this.request.open(); + this.request.send(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.abort(); + + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); + + it('should trigger error, progress, loadend when network error', function() { + this.request.open(); + this.request.send(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.responseError(); + + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); + + it('should trigger timeout, progress, loadend when timing out', function() { + this.request.open(); + this.request.send(); + + this.fakeEventBus.trigger.calls.reset(); + + jasmine.clock().install(); + this.request.responseTimeout(); + jasmine.clock().uninstall(); + + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange', 'timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); + + it('should trigger load, progress, loadend when responding', function() { + this.request.open(); + this.request.send(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.respondWith({ status: 200 }); + + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); + }); + + it('ticks the jasmine clock on timeout', function() { + var clock = { tick: jasmine.createSpy('tick') }; + spyOn(jasmine, 'clock').and.returnValue(clock); + + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.responseTimeout(); + + expect(clock.tick).toHaveBeenCalledWith(30000); + }); + + it('has an initial status of null', function() { + var request = new this.FakeRequest(); + + expect(request.status).toBeNull(); + }); + + it('has an aborted status', function() { + var request = new this.FakeRequest(); + + request.abort(); + + expect(request.status).toBe(0); + expect(request.statusText).toBe('abort'); + }); + + it('has a status from the response', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.status).toBe(200); + expect(request.statusText).toBe(''); + }); + + it('has a statusText from the response', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, statusText: 'OK' }); + + expect(request.status).toBe(200); + expect(request.statusText).toBe('OK'); + }); + + it('saves off any data sent to the server', function() { + var request = new this.FakeRequest(); + request.open(); + request.send('foo=bar&baz=quux'); + + expect(request.params).toBe('foo=bar&baz=quux'); + }); + + it('parses data sent to the server', function() { + var request = new this.FakeRequest(); + request.open(); + request.send('foo=bar&baz=quux'); + + this.parserInstance.and.returnValue('parsed'); + + expect(request.data()).toBe('parsed'); + }); + + it('skips parsing if no data was sent', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + expect(request.data()).toEqual({}); + expect(this.parserInstance).not.toHaveBeenCalled(); + }); + + it('saves responseText', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foobar' }); + + expect(request.responseText).toBe('foobar'); + }); + + it('defaults responseText if none is given', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.responseText).toBe(''); + }); + + it('retrieves individual response headers', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ + status: 200, + responseHeaders: { + 'X-Header': 'foo' + } + }); + + expect(request.getResponseHeader('X-Header')).toBe('foo'); + }); + + it('retrieves individual response headers case-insensitively', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ + status: 200, + responseHeaders: { + 'X-Header': 'foo' + } + }); + + expect(request.getResponseHeader('x-header')).toBe('foo'); + }); + + it('retrieves a combined response header', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ + status: 200, + responseHeaders: [ + { name: 'X-Header', value: 'foo' }, + { name: 'X-Header', value: 'bar' } + ] + }); + + expect(request.getResponseHeader('x-header')).toBe('foo, bar'); + }); + + it("doesn't pollute the response headers of other XHRs", function() { + var request1 = new this.FakeRequest(); + request1.open(); + request1.send(); + + var request2 = new this.FakeRequest(); + request2.open(); + request2.send(); + + request1.respondWith({ status: 200, responseHeaders: { 'X-Foo': 'bar' } }); + request2.respondWith({ status: 200, responseHeaders: { 'X-Baz': 'quux' } }); + + expect(request1.getAllResponseHeaders()).toBe("X-Foo: bar\r\n"); + expect(request2.getAllResponseHeaders()).toBe("X-Baz: quux\r\n"); + }); + + it('retrieves all response headers', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ + status: 200, + responseHeaders: [ + { name: 'X-Header-1', value: 'foo' }, + { name: 'X-Header-2', value: 'bar' }, + { name: 'X-Header-1', value: 'baz' } + ] + }); + + expect(request.getAllResponseHeaders()).toBe("X-Header-1: foo\r\nX-Header-2: bar\r\nX-Header-1: baz\r\n"); + }); + + it('sets the content-type header to the specified contentType when no other headers are supplied', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'text/plain' }); + + expect(request.getResponseHeader('content-type')).toBe('text/plain'); + expect(request.getAllResponseHeaders()).toBe("Content-Type: text/plain\r\n"); + }); + + it('sets a default content-type header if no contentType and headers are supplied', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.getResponseHeader('content-type')).toBe('application/json'); + expect(request.getAllResponseHeaders()).toBe("Content-Type: application/json\r\n"); + }); + + it('has no responseXML by default', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.responseXML).toBeNull(); + }); + + it('parses a text/xml document into responseXML', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'text/xml', responseText: '' }); + + if (typeof window['Document'] !== 'undefined') { + expect(request.responseXML instanceof window['Document']).toBe(true); + expect(request.response instanceof window['Document']).toBe(true); + } else { + // IE 8 + expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); + expect(request.response instanceof window['ActiveXObject']).toBe(true); + } + }); + + it('parses an application/xml document into responseXML', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'application/xml', responseText: '' }); + + if (typeof window['Document'] !== 'undefined') { + expect(request.responseXML instanceof window['Document']).toBe(true); + expect(request.response instanceof window['Document']).toBe(true); + } else { + // IE 8 + expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); + expect(request.response instanceof window['ActiveXObject']).toBe(true); + } + }); + + it('parses a custom blah+xml document into responseXML', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'application/text+xml', responseText: '' }); + + if (typeof window['Document'] !== 'undefined') { + expect(request.responseXML instanceof window['Document']).toBe(true); + expect(request.response instanceof window['Document']).toBe(true); + } else { + // IE 8 + expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); + expect(request.response instanceof window['ActiveXObject']).toBe(true); + } + }); + + it('defaults the response attribute to the responseText', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foo' }); + + expect(request.response).toEqual('foo'); + }); + + it('has a text response when the responseType is blank', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foo', responseType: '' }); + + expect(request.response).toEqual('foo'); + }); + + it('has a text response when the responseType is text', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foo', responseType: 'text' }); + + expect(request.response).toEqual('foo'); + }); +}); + + +describe("Jasmine Mock Ajax (for toplevel)", function() { + var request, anotherRequest, response; + var success, error, complete; + var client, onreadystatechange; + var sharedContext: any = {}; + var fakeGlobal, mockAjax; + + beforeEach(function() { + var fakeXMLHttpRequest = jasmine.createSpy('realFakeXMLHttpRequest'); + fakeGlobal = { + XMLHttpRequest: fakeXMLHttpRequest, + DOMParser: window['DOMParser'], + ActiveXObject: window['ActiveXObject'] + }; + mockAjax = new MockAjax(fakeGlobal); + mockAjax.install(); + + success = jasmine.createSpy("onSuccess"); + error = jasmine.createSpy("onFailure"); + complete = jasmine.createSpy("onComplete"); + + onreadystatechange = function() { + if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE + if (this.status === 200) { + success(this.responseText, this.textStatus, this); + } else { + error(this, this.textStatus, ''); + } + + complete(this, this.textStatus); + } + }; + }); + + describe("when making a request", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.send(); + request = mockAjax.requests.mostRecent(); + }); + + it("should store URL and transport", function() { + expect(request.url).toEqual("example.com/someApi"); + }); + + it("should queue the request", function() { + expect(mockAjax.requests.count()).toEqual(1); + }); + + it("should allow access to the queued request", function() { + expect(mockAjax.requests.first()).toEqual(request); + }); + + it("should allow access to the queued request via index", function() { + expect(mockAjax.requests.at(0)).toEqual(request); + }); + + describe("and then another request", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.send(); + + anotherRequest = mockAjax.requests.mostRecent(); + }); + + it("should queue the next request", function() { + expect(mockAjax.requests.count()).toEqual(2); + }); + + it("should allow access to the other queued request", function() { + expect(mockAjax.requests.first()).toEqual(request); + expect(mockAjax.requests.mostRecent()).toEqual(anotherRequest); + }); + }); + + describe("mockAjax.requests.mostRecent()", function () { + + describe("when there is one request queued", function () { + it("should return the request", function() { + expect(mockAjax.requests.mostRecent()).toEqual(request); + }); + }); + + describe("when there is more than one request", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.send(); + anotherRequest = mockAjax.requests.mostRecent(); + }); + + it("should return the most recent request", function() { + expect(mockAjax.requests.mostRecent()).toEqual(anotherRequest); + }); + }); + + describe("when there are no requests", function () { + beforeEach(function() { + mockAjax.requests.reset(); + }); + + it("should return null", function() { + expect(mockAjax.requests.mostRecent()).toBeUndefined(); + }); + }); + }); + + describe("clearAjaxRequests()", function () { + beforeEach(function() { + mockAjax.requests.reset(); + }); + + it("should remove all requests", function() { + expect(mockAjax.requests.count()).toEqual(0); + expect(mockAjax.requests.mostRecent()).toBeUndefined(); + }); + }); + }); + + describe("when simulating a response with request.response", function () { + describe("and the response is Success", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = {status: 200, statusText: "OK", contentType: "text/html", responseText: "OK!"}; + request.respondWith(response); + + sharedContext.responseCallback = success; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = response.contentType; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + it("should call the success handler", function() { + expect(success).toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).not.toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("and the response is Success, but with JSON", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "application/json"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = {status: 200, statusText: "OK", contentType: "application/json", responseText: '{"foo":"bar"}', responseType: "json"}; + + request.respondWith(responseObject); + + sharedContext.responseCallback = success; + sharedContext.status = responseObject.status; + sharedContext.statusText = responseObject.statusText; + sharedContext.contentType = responseObject.contentType; + sharedContext.responseText = responseObject.responseText; + sharedContext.responseType = responseObject.responseType; + + response = success.calls.mostRecent().args[2]; + }); + + it("should call the success handler", function() { + expect(success).toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).not.toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + it("should return a JavaScript object for XHR2 response", function() { + var responseText = sharedContext.responseText; + expect(success.calls.mostRecent().args[0]).toEqual(responseText); + + expect(response.responseText).toEqual(responseText); + expect(response.response).toEqual({foo: "bar"}); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("and the response is Success, and response is overriden", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "application/json"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = {status: 200, statusText: "OK", contentType: "application/json", responseText: '{"foo":"bar"}', responseType: 'json'}; + + request.respondWith(responseObject); + + sharedContext.responseCallback = success; + sharedContext.status = responseObject.status; + sharedContext.statusText = responseObject.statusText; + sharedContext.contentType = responseObject.contentType; + sharedContext.responseText = responseObject.responseText; + sharedContext.responseType = responseObject.responseType; + + response = success.calls.mostRecent().args[2]; + }); + + it("should return the provided override for the XHR2 response", function() { + var responseText = sharedContext.responseText; + + expect(response.responseText).toEqual(responseText); + expect(response.response).toEqual({foo: "bar"}); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("response with unique header names using an object", function () { + beforeEach(function () { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = {status: 200, statusText: "OK", responseText: '["foo"]', responseHeaders: { + 'X-Header1': 'header 1 value', + 'X-Header2': 'header 2 value', + 'X-Header3': 'header 3 value' + }}; + request.respondWith(responseObject); + response = success.calls.mostRecent().args[2]; + }); + + it("getResponseHeader should return the each value", function () { + expect(response.getResponseHeader('X-Header1')).toBe('header 1 value'); + expect(response.getResponseHeader('X-Header2')).toBe('header 2 value'); + expect(response.getResponseHeader('X-Header3')).toBe('header 3 value'); + }); + + it("getAllResponseHeaders should return all values", function () { + expect(response.getAllResponseHeaders()).toBe([ + "X-Header1: header 1 value", + "X-Header2: header 2 value", + "X-Header3: header 3 value" + ].join("\r\n") + "\r\n"); + }); + }); + + describe("response with multiple headers of the same name using an array of objects", function () { + beforeEach(function () { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = {status: 200, statusText: "OK", responseText: '["foo"]', responseHeaders: [ + { name: 'X-Header', value: 'header value 1' }, + { name: 'X-Header', value: 'header value 2' } + ]}; + request.respondWith(responseObject); + response = success.calls.mostRecent().args[2]; + }); + + it("getResponseHeader should return all values comma separated", function () { + expect(response.getResponseHeader('X-Header')).toBe('header value 1, header value 2'); + }); + + it("getAllResponseHeaders should return all values", function () { + expect(response.getAllResponseHeaders()).toBe([ + "X-Header: header value 1", + "X-Header: header value 2" + ].join("\r\n") + "\r\n"); + }); + }); + + describe("the content type defaults to application/json", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "application/json"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = {status: 200, statusText: "OK", responseText: '{"foo": "valid JSON, dammit."}', responseType: 'json'}; + request.respondWith(response); + + sharedContext.responseCallback = success; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = "application/json"; + sharedContext.responseType = response.responseType; + sharedContext.responseText = response.responseText; + }); + + it("should call the success handler", function() { + expect(success).toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).not.toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("and the status/response code is 0", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = {status: 0, statusText: "ABORT", responseText: '{"foo": "whoops!"}'}; + request.respondWith(response); + + sharedContext.responseCallback = error; + sharedContext.status = 0; + sharedContext.statusText = response.statusText; + sharedContext.contentType = 'application/json'; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + it("should call the success handler", function() { + expect(success).not.toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Failure(sharedContext); + }); + }); + + describe("and the response is error", function () { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = {status: 500, statusText: "SERVER ERROR", contentType: "text/html", responseText: "(._){"}; + request.respondWith(response); + + sharedContext.responseCallback = error; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = response.contentType; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + it("should not call the success handler", function() { + expect(success).not.toHaveBeenCalled(); + }); + + it("should call the failure handler", function() { + expect(error).toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Failure(sharedContext); + }); + + describe('when simulating a response with request.responseTimeout', function() { + beforeEach(function() { + jasmine.clock().install(); + + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = {contentType: "text/html", response: "(._){response", responseText: "(._){", responseType: "text"}; + request.responseTimeout(response); + + sharedContext.responseCallback = error; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = response.contentType; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + afterEach(function() { + jasmine.clock().uninstall(); + }); + + it("should not call the success handler", function() { + expect(success).not.toHaveBeenCalled(); + }); + + it("should call the failure handler", function() { + expect(error).toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + }); +}); + + +function sharedAjaxResponseBehaviorForZepto_Success(context) { + describe("the success response", function () { + var xhr; + beforeEach(function() { + xhr = context.responseCallback.calls.mostRecent().args[2]; + }); + + it("should have the expected status code", function() { + expect(xhr.status).toEqual(context.status); + }); + + it("should have the expected content type", function() { + expect(xhr.getResponseHeader('Content-Type')).toEqual(context.contentType); + }); + + it("should have the expected xhr2 response", function() { + var expected = context.response || context.responseType === 'json' ? JSON.parse(context.responseText) : context.responseText; + expect(xhr.response).toEqual(expected); + }); + + it("should have the expected response text", function() { + expect(xhr.responseText).toEqual(context.responseText); + }); + + it("should have the expected status text", function() { + expect(xhr.statusText).toEqual(context.statusText); + }); + }); +} + +function sharedAjaxResponseBehaviorForZepto_Failure(context) { + describe("the failure response", function () { + var xhr; + beforeEach(function() { + xhr = context.responseCallback.calls.mostRecent().args[0]; + }); + + it("should have the expected status code", function() { + expect(xhr.status).toEqual(context.status); + }); + + it("should have the expected content type", function() { + expect(xhr.getResponseHeader('Content-Type')).toEqual(context.contentType); + }); + + it("should have the expected xhr2 response", function() { + var expected = context.response || xhr.responseType === 'json' ? JSON.parse(xhr.responseText) : xhr.responseText; + expect(xhr.response).toEqual(expected); + }); + + it("should have the expected response text", function() { + expect(xhr.responseText).toEqual(context.responseText); + }); + + it("should have the expected status text", function() { + expect(xhr.statusText).toEqual(context.statusText); + }); + }); +} + +describe('ParamParser', function() { + beforeEach(function() { + var Constructor = getJasmineRequireObj().AjaxParamParser(); + expect(Constructor).toEqual(jasmine.any(Function)); + this.parser = new Constructor(); + }); + + it('has a default parser', function() { + var parser = this.parser.findParser({ contentType: function() {} }), + parsed = parser.parse('3+stooges=shemp&3+stooges=larry%20%26%20moe%20%26%20curly&some%3Dthing=else+entirely'); + + expect(parsed).toEqual({ + '3 stooges': ['shemp', 'larry & moe & curly'], + 'some=thing': ['else entirely'] + }); + }); + + it('should detect and parse json', function() { + var data = { + foo: 'bar', + baz: ['q', 'u', 'u', 'x'], + nested: { + object: { + containing: 'stuff' + } + } + }, + parser = this.parser.findParser({ contentType: function() { return 'application/json'; } }), + parsed = parser.parse(JSON.stringify(data)); + + expect(parsed).toEqual(data); + }); + + it('should parse json with further qualifiers on content-type', function() { + var data = { + foo: 'bar', + baz: ['q', 'u', 'u', 'x'], + nested: { + object: { + containing: 'stuff' + } + } + }, + parser = this.parser.findParser({ contentType: function() { return 'application/json; charset=utf-8'; } }), + parsed = parser.parse(JSON.stringify(data)); + + expect(parsed).toEqual(data); + }); + + it('should have custom parsers take precedence', function() { + var custom = { + test: jasmine.createSpy('test').and.returnValue(true), + parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') + }; + + this.parser.add(custom); + + var parser = this.parser.findParser({ contentType: function() {} }), + parsed = parser.parse('custom_format'); + + expect(parsed).toEqual('parsedFormat'); + expect(custom.test).toHaveBeenCalled(); + expect(custom.parse).toHaveBeenCalledWith('custom_format'); + }); + + it('should skip custom parsers that do not match', function() { + var custom = { + test: jasmine.createSpy('test').and.returnValue(false), + parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') + }; + + this.parser.add(custom); + + var parser = this.parser.findParser({ contentType: function() {} }), + parsed = parser.parse('custom_format'); + + expect(parsed).toEqual({ custom_format: [ 'undefined' ] }); + expect(custom.test).toHaveBeenCalled(); + expect(custom.parse).not.toHaveBeenCalled(); + }); + + it('removes custom parsers when reset', function() { + var custom = { + test: jasmine.createSpy('test').and.returnValue(true), + parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') + }; + + this.parser.add(custom); + + var parser = this.parser.findParser({ contentType: function() {} }), + parsed = parser.parse('custom_format'); + + expect(parsed).toEqual('parsedFormat'); + + custom.test['calls'].reset(); + custom.parse['calls'].reset(); + + this.parser.reset(); + + parser = this.parser.findParser({ contentType: function() {} }); + parsed = parser.parse('custom_format'); + + expect(parsed).toEqual({ custom_format: [ 'undefined' ] }); + expect(custom.test).not.toHaveBeenCalled(); + expect(custom.parse).not.toHaveBeenCalled(); + }); +}); + +describe('RequestStub', function() { + beforeEach(function() { + this.RequestStub = getJasmineRequireObj().AjaxRequestStub(); + + jasmine.addMatchers({ + toMatchRequest: function() { + return { + compare: function(actual) { + return { + pass: actual.matches.apply(actual, Array.prototype.slice.call(arguments, 1)) + }; + } + }; + } + }); + }); + + it('matches just by exact url', function() { + var stub = new this.RequestStub('www.example.com/foo'); + + expect(stub)['toMatchRequest']('www.example.com/foo'); + }); + + it('does not match if the url differs', function() { + var stub = new this.RequestStub('www.example.com/foo'); + + expect(stub).not['toMatchRequest']('www.example.com/bar'); + }); + + it('matches unordered query params', function() { + var stub = new this.RequestStub('www.example.com?foo=bar&baz=quux'); + + expect(stub)['toMatchRequest']('www.example.com?baz=quux&foo=bar'); + }); + + it('requires all specified query params to be there', function() { + var stub = new this.RequestStub('www.example.com?foo=bar&baz=quux'); + + expect(stub).not['toMatchRequest']('www.example.com?foo=bar'); + }); + + it('can match the url with a RegExp', function() { + var stub = new this.RequestStub(/ba[rz]/); + + expect(stub)['toMatchRequest']('bar'); + expect(stub)['toMatchRequest']('baz'); + expect(stub).not['toMatchRequest']('foo'); + }); + + it('requires the method to match if supplied', function() { + var stub = new this.RequestStub('www.example.com/foo', null, 'POST'); + + expect(stub).not['toMatchRequest']('www.example.com/foo'); + expect(stub).not['toMatchRequest']('www.example.com/foo', null, 'GET'); + expect(stub)['toMatchRequest']('www.example.com/foo', null, 'POST'); + }); + + it('requires the data submitted to match if supplied', function() { + var stub = new this.RequestStub('/foo', 'foo=bar&baz=quux'); + + expect(stub)['toMatchRequest']('/foo', 'baz=quux&foo=bar'); + expect(stub).not['toMatchRequest']('/foo', 'foo=bar'); + }); +}); + +describe('RequestTracker', function() { + beforeEach(function() { + var Constructor = getJasmineRequireObj().AjaxRequestTracker(); + this.tracker = new Constructor(); + }); + + it('tracks the number of times ajax requests are made', function() { + expect(this.tracker.count()).toBe(0); + + this.tracker.track(); + + expect(this.tracker.count()).toBe(1); + }); + + it('simplifies access to the last (most recent) request', function() { + this.tracker.track(); + this.tracker.track('request'); + + expect(this.tracker.mostRecent()).toEqual('request'); + }); + + it('returns a useful falsy value when there is no last (most recent) request', function() { + expect(this.tracker.mostRecent()).toBeFalsy(); + }); + + it('simplifies access to the first (oldest) request', function() { + this.tracker.track('request'); + this.tracker.track(); + + expect(this.tracker.first()).toEqual('request'); + }); + + it('returns a useful falsy value when there is no first (oldest) request', function() { + expect(this.tracker.first()).toBeFalsy(); + }); + + it('allows the requests list to be reset', function() { + this.tracker.track(); + this.tracker.track(); + + expect(this.tracker.count()).toBe(2); + + this.tracker.reset(); + + expect(this.tracker.count()).toBe(0); + }); + + it('allows retrieval of an arbitrary request by index', function() { + this.tracker.track('1'); + this.tracker.track('2'); + this.tracker.track('3'); + + expect(this.tracker.at(1)).toEqual('2'); + }); + + it('allows retrieval of all requests that are for a given url', function() { + this.tracker.track({ url: 'foo' }); + this.tracker.track({ url: 'bar' }); + + expect(this.tracker.filter('bar')).toEqual([{ url: 'bar' }]); + }); + + it('allows retrieval of all requests that match a given RegExp', function() { + this.tracker.track({ url: 'foo' }); + this.tracker.track({ url: 'bar' }); + this.tracker.track({ url: 'baz' }); + + expect(this.tracker.filter(/ba[rz]/)).toEqual([{ url: 'bar' }, { url: 'baz' }]); + }); + + it('allows retrieval of all requests that match based on a function', function() { + this.tracker.track({ url: 'foo' }); + this.tracker.track({ url: 'bar' }); + this.tracker.track({ url: 'baz' }); + + var func = function(request) { + return request.url === 'bar'; + }; + + expect(this.tracker.filter(func)).toEqual([{ url: 'bar' }]); + }); + + it('filters to nothing if no requests have been tracked', function() { + expect(this.tracker.filter('foo')).toEqual([]); + }); +}); + +describe('EventBus', function() { + beforeEach(function() { + this.bus = getJasmineRequireObj().AjaxEventBus()(); + }); + + it('calls an event listener', function() { + var callback = jasmine.createSpy('callback'); + + this.bus.addEventListener('foo', callback); + this.bus.trigger('foo'); + + expect(callback).toHaveBeenCalled(); + }); + + it('calls an event listener with additional arguments', function() { + var callback = jasmine.createSpy('callback'); + + this.bus.addEventListener('foo', callback); + this.bus.trigger('foo', 'bar'); + + expect(callback).toHaveBeenCalledWith('bar'); + }); + + it('only triggers callbacks for the specified event', function() { + var fooCallback = jasmine.createSpy('foo'), + barCallback = jasmine.createSpy('bar'); + + this.bus.addEventListener('foo', fooCallback); + this.bus.addEventListener('bar', barCallback); + + this.bus.trigger('foo'); + + expect(fooCallback).toHaveBeenCalled(); + expect(barCallback).not.toHaveBeenCalled(); + }); + + it('calls all the callbacks for the specified event', function() { + var callback1 = jasmine.createSpy('callback'); + var callback2 = jasmine.createSpy('otherCallback'); + + this.bus.addEventListener('foo', callback1); + this.bus.addEventListener('foo', callback2); + + this.bus.trigger('foo'); + + expect(callback1).toHaveBeenCalled(); + expect(callback2).toHaveBeenCalled(); + }); + + it('works if there are no callbacks for the event', function() { + var bus = this.bus; + expect(function() { + bus.trigger('notActuallyThere'); + }).not.toThrow(); + }); + + it('does not call listeners that have been removed', function() { + var callback = jasmine.createSpy('callback'); + + this.bus.addEventListener('foo', callback); + this.bus.removeEventListener('foo', callback); + this.bus.trigger('foo'); + + expect(callback).not.toHaveBeenCalled(); + }); + + it('only removes the specified callback', function() { + var callback1 = jasmine.createSpy('callback'); + var callback2 = jasmine.createSpy('otherCallback'); + + this.bus.addEventListener('foo', callback1); + this.bus.addEventListener('foo', callback2); + this.bus.removeEventListener('foo', callback2); + + this.bus.trigger('foo'); + + expect(callback1).toHaveBeenCalled(); + expect(callback2).not.toHaveBeenCalled(); + }); +}); + +describe("Webmock style mocking", function() { + var successSpy, errorSpy, response, fakeGlobal, mockAjax; + + var sendRequest = function(fakeGlobal, url?, method?) { + url = url || "http://example.com/someApi"; + method = method || 'GET'; + var xhr = new fakeGlobal.XMLHttpRequest(); + xhr.onreadystatechange = function(args) { + if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE + response = this; + successSpy(); + } + }; + + xhr.open(method, url); + xhr.send(); + }; + + beforeEach(function() { + successSpy = jasmine.createSpy('success'); + fakeGlobal = {XMLHttpRequest: jasmine.createSpy('realXMLHttpRequest')}; + mockAjax = new MockAjax(fakeGlobal); + mockAjax.install(); + + mockAjax.stubRequest("http://example.com/someApi").andReturn({responseText: "hi!"}); + }); + + it("allows a url to be setup as a stub", function() { + sendRequest(fakeGlobal); + expect(successSpy).toHaveBeenCalled(); + }); + + it("should allow you to clear all the ajax stubs", function() { + mockAjax.stubs.reset(); + sendRequest(fakeGlobal); + expect(successSpy).not.toHaveBeenCalled(); + }); + + it("should set the contentType", function() { + sendRequest(fakeGlobal); + expect(response.getResponseHeader('Content-Type')).toEqual('application/json'); + }); + + it("should set the responseText", function() { + sendRequest(fakeGlobal); + expect(response.responseText).toEqual('hi!'); + }); + + it("should default the status to 200", function() { + sendRequest(fakeGlobal); + expect(response.status).toEqual(200); + }); + + it("should set the responseHeaders", function() { + mockAjax.stubRequest("http://example.com/someApi").andReturn({ + responseText: "hi!", + responseHeaders: [{name: "X-Custom", value: "header value"}] + }); + sendRequest(fakeGlobal); + expect(response.getResponseHeader('X-Custom')).toEqual('header value'); + }); + + describe("with another stub for the same url", function() { + beforeEach(function() { + mockAjax.stubRequest("http://example.com/someApi").andReturn({responseText: "no", status: 403}); + sendRequest(fakeGlobal); + }); + + it("should set the status", function() { + expect(response.status).toEqual(403); + }); + + it("should allow the latest stub to win", function() { + expect(response.responseText).toEqual('no'); + }); + }); +}); + +describe("withMock", function() { + var sendRequest = function(fakeGlobal) { + var xhr = new fakeGlobal.XMLHttpRequest(); + + xhr.open("GET", "http://example.com/someApi"); + xhr.send(); + }; + + it("installs the mock for passed in function, and uninstalls when complete", function() { + var xmlHttpRequest = jasmine.createSpyObj('XMLHttpRequest', ['open', 'send']), + xmlHttpRequestCtor = spyOn(window, 'XMLHttpRequest').and.returnValue(xmlHttpRequest), + fakeGlobal = {XMLHttpRequest: xmlHttpRequestCtor}, + mockAjax = new MockAjax(fakeGlobal); + + mockAjax.withMock(function() { + sendRequest(fakeGlobal); + expect(xmlHttpRequest.open).not.toHaveBeenCalled(); + }); + + sendRequest(fakeGlobal); + expect(xmlHttpRequest.open).toHaveBeenCalled(); + }); + + it("properly uninstalls when the passed in function throws", function() { + var xmlHttpRequest = jasmine.createSpyObj('XMLHttpRequest', ['open', 'send']), + xmlHttpRequestCtor = spyOn(window, 'XMLHttpRequest').and.returnValue(xmlHttpRequest), + fakeGlobal = {XMLHttpRequest: xmlHttpRequestCtor}, + mockAjax = new MockAjax(fakeGlobal); + + expect(function() { + mockAjax.withMock(function() { + throw "error"; + }); + }).toThrow("error"); + + sendRequest(fakeGlobal); + expect(xmlHttpRequest.open).toHaveBeenCalled(); + }); +}); + +describe("mockAjax", function() { + it("throws an error if installed multiple times", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + function doubleInstall() { + mockAjax.install(); + mockAjax.install(); + } + + expect(doubleInstall).toThrow(); + }); + + it("does not throw an error if uninstalled between installs", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + function sequentialInstalls() { + mockAjax.install(); + mockAjax.uninstall(); + mockAjax.install(); + } + + expect(sequentialInstalls).not.toThrow(); + }); + + it("does not replace XMLHttpRequest until it is installed", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + fakeGlobal.XMLHttpRequest('foo'); + expect(fakeXmlHttpRequest).toHaveBeenCalledWith('foo'); + fakeXmlHttpRequest.calls.reset(); + + mockAjax.install(); + fakeGlobal.XMLHttpRequest('foo'); + expect(fakeXmlHttpRequest).not.toHaveBeenCalled(); + }); + + it("replaces the global XMLHttpRequest on uninstall", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + mockAjax.install(); + mockAjax.uninstall(); + + fakeGlobal.XMLHttpRequest('foo'); + expect(fakeXmlHttpRequest).toHaveBeenCalledWith('foo'); + }); + + it("clears requests and stubs upon uninstall", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + mockAjax.install(); + + mockAjax.requests.track({url: '/testurl'}); + mockAjax.stubRequest('/bobcat'); + + expect(mockAjax.requests.count()).toEqual(1); + expect(mockAjax.stubs.findStub('/bobcat')).toBeDefined(); + + mockAjax.uninstall(); + + expect(mockAjax.requests.count()).toEqual(0); + expect(mockAjax.stubs.findStub('/bobcat')).not.toBeDefined(); + }); + + it("allows the httpRequest to be retrieved", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + mockAjax.install(); + var request = new (fakeGlobal.XMLHttpRequest)(); + + expect(mockAjax.requests.count()).toBe(1); + expect(mockAjax.requests.mostRecent()).toBe(request); + }); + + it("allows the httpRequests to be cleared", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); + + mockAjax.install(); + var request = new (fakeGlobal.XMLHttpRequest)(); + + expect(mockAjax.requests.mostRecent()).toBe(request); + mockAjax.requests.reset(); + expect(mockAjax.requests.count()).toBe(0); + }); +}); diff --git a/jasmine-ajax/jasmine-ajax-tests.ts.tscparams b/jasmine-ajax/jasmine-ajax-tests.ts.tscparams new file mode 100644 index 000000000..d3f5a12fa --- /dev/null +++ b/jasmine-ajax/jasmine-ajax-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/jasmine-ajax/jasmine-ajax.d.ts b/jasmine-ajax/jasmine-ajax.d.ts new file mode 100644 index 000000000..70ca2f57c --- /dev/null +++ b/jasmine-ajax/jasmine-ajax.d.ts @@ -0,0 +1,77 @@ +// Type definitions for jasmine-ajax 3.1.1 +// Project: https://github.com/jasmine/jasmine-ajax +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface JasmineAjaxResponse { + status?: string; + statusText?: string; + responseText?: string; + response?: string; + responseType?: string; + contentType?: string; + responseHeaders?: { [key: string]: string }; +} + +interface JasmineAjaxRequest { + url: string; + respondWith(response: JasmineAjaxResponse): void; +} + +interface JasmineAjaxRequestTracker { + track(request: JasmineAjaxRequest): void; + first(): JasmineAjaxRequest; + count(): number; + reset(): void; + mostRecent(): JasmineAjaxRequest; + at(index: number): JasmineAjaxRequest; + filter(urlToMatch: RegExp): JasmineAjaxRequest[]; + filter(urlToMatch: Function): JasmineAjaxRequest[]; + filter(urlToMatch: string): JasmineAjaxRequest[]; +} + +interface JasmineAjaxRequestStubReturnOptions { + status?: number; + contentType?: string; + response?: string; + responseText?: string; + responseHeaders?: { [key: string]: string }; +} + +interface JasmineAjaxRequestStub { + data?: string; + method?: string; + andReturn(options: JasmineAjaxRequestStubReturnOptions): void; + matches(fullUrl: string, data: string, method: string): boolean; +} + +interface JasmineAjaxStubTracker { + addStub(stub: JasmineAjaxRequestStub): void; + reset(): void; + findStub(url: string, data?: string, method?: string): JasmineAjaxRequestStub; +} + +interface JasmineAjaxParamParser { + test(xhr: XMLHttpRequest): boolean; + parse(paramString: string): any; +} + +declare class MockAjax { + constructor(globals); + + install(): void; + uninstall(): void; + + withMock(closure: () => void): void; + addCustomParamParser(parser: JasmineAjaxParamParser): void; + + stubRequest(url: RegExp, data?: string, method?: string): JasmineAjaxRequestStub; + stubRequest(url: string, data?: string, method?: string): JasmineAjaxRequestStub; + + requests: JasmineAjaxRequestTracker; + stubs: JasmineAjaxStubTracker; +} + +declare module jasmine { + export var Ajax: MockAjax; +} From c0bb2b179811977f9a4d71285071989acf5a75b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 May 2015 21:15:47 +0200 Subject: [PATCH 020/397] fixed dependencies and errors --- jasmine-ajax/jasmine-ajax-tests.ts | 3197 ++++++++++++++-------------- jasmine-ajax/jasmine-ajax.d.ts | 11 +- 2 files changed, 1610 insertions(+), 1598 deletions(-) diff --git a/jasmine-ajax/jasmine-ajax-tests.ts b/jasmine-ajax/jasmine-ajax-tests.ts index b5134d2cf..6b5c50b1b 100644 --- a/jasmine-ajax/jasmine-ajax-tests.ts +++ b/jasmine-ajax/jasmine-ajax-tests.ts @@ -6,1813 +6,1820 @@ /// /// +declare function getJasmineRequireObj(); + describe('StubTracker', function() { - beforeEach(function() { - var Constructor = getJasmineRequireObj().AjaxStubTracker(); - this.tracker = new Constructor(); - }); + beforeEach(function() { + var Constructor = getJasmineRequireObj().AjaxStubTracker(); + this.tracker = new Constructor(); + }); - it('finds nothing if no stubs are added', function() { - expect(this.tracker.findStub()).toBeUndefined(); - }); + it('finds nothing if no stubs are added', function() { + expect(this.tracker.findStub()).toBeUndefined(); + }); - it('finds an added stub', function() { - var stub = { matches: function() { return true; } }; - this.tracker.addStub(stub); + it('finds an added stub', function() { + var stub = { matches: function() { return true; } }; + this.tracker.addStub(stub); - expect(this.tracker.findStub()).toBe(stub); - }); + expect(this.tracker.findStub()).toBe(stub); + }); - it('skips an added stub that does not match', function() { - var stub = { matches: function() { return false; } }; - this.tracker.addStub(stub); + it('skips an added stub that does not match', function() { + var stub = { matches: function() { return false; } }; + this.tracker.addStub(stub); - expect(this.tracker.findStub()).toBeUndefined(); - }); + expect(this.tracker.findStub()).toBeUndefined(); + }); - it('passes url, data, and method to the stub', function() { - var stub = { matches: jasmine.createSpy('matches') }; - this.tracker.addStub(stub); + it('passes url, data, and method to the stub', function() { + var stub = { matches: jasmine.createSpy('matches') }; + this.tracker.addStub(stub); - this.tracker.findStub('url', 'data', 'method'); + this.tracker.findStub('url', 'data', 'method'); - expect(stub.matches).toHaveBeenCalledWith('url', 'data', 'method'); - }); + expect(stub.matches).toHaveBeenCalledWith('url', 'data', 'method'); + }); - it('can clear out all stubs', function() { - var stub = { matches: jasmine.createSpy('matches') }; - this.tracker.addStub(stub); + it('can clear out all stubs', function() { + var stub = { matches: jasmine.createSpy('matches') }; + this.tracker.addStub(stub); - this.tracker.findStub(); + this.tracker.findStub(); - expect(stub.matches).toHaveBeenCalled(); + expect(stub.matches).toHaveBeenCalled(); - this.tracker.reset(); - stub.matches.calls.reset(); + this.tracker.reset(); + stub.matches.calls.reset(); - this.tracker.findStub(); + this.tracker.findStub(); - expect(stub.matches).not.toHaveBeenCalled(); - }); + expect(stub.matches).not.toHaveBeenCalled(); + }); - it('uses the most recently added stub that matches', function() { - var stub1 = { matches: function() { return true; } }; - var stub2 = { matches: function() { return true; } }; - var stub3 = { matches: function() { return false; } }; + it('uses the most recently added stub that matches', function() { + var stub1 = { matches: function() { return true; } }; + var stub2 = { matches: function() { return true; } }; + var stub3 = { matches: function() { return false; } }; - this.tracker.addStub(stub1); - this.tracker.addStub(stub2); - this.tracker.addStub(stub3); + this.tracker.addStub(stub1); + this.tracker.addStub(stub2); + this.tracker.addStub(stub3); - expect(this.tracker.findStub()).toBe(stub2); - }); + expect(this.tracker.findStub()).toBe(stub2); + }); }); describe('FakeRequest', function() { - beforeEach(function() { - this.requestTracker = { track: jasmine.createSpy('trackRequest') }; - this.stubTracker = { findStub: function() {} }; - var parserInstance = this.parserInstance = jasmine.createSpy('parse'); - this.paramParser = { findParser: function() { return { parse: parserInstance }; } }; - var eventBus = this.fakeEventBus = { - addEventListener: jasmine.createSpy('addEventListener'), - trigger: jasmine.createSpy('trigger'), - removeEventListener: jasmine.createSpy('removeEventListener') - }; - this.eventBusFactory = function() { - return eventBus; - }; - this.fakeGlobal = { - XMLHttpRequest: function() { - this.extraAttribute = 'my cool attribute'; - }, - DOMParser: window['DOMParser'], - ActiveXObject: window['ActiveXObject'] - }; - this.FakeRequest = getJasmineRequireObj().AjaxFakeRequest(this.eventBusFactory)(this.fakeGlobal, this.requestTracker, this.stubTracker, this.paramParser); - }); - - it('extends from the global XMLHttpRequest', function() { - var request = new this.FakeRequest(); - - expect(request.extraAttribute).toEqual('my cool attribute'); - }); - - it('skips XMLHttpRequest attributes that IE does not want copied', function() { - // use real window here so it will correctly go red on IE if it breaks - var FakeRequest = getJasmineRequireObj().AjaxFakeRequest(this.eventBusFactory)(window, this.requestTracker, this.stubTracker, this.paramParser); - var request = new FakeRequest(); - - expect(request.responseBody).toBeUndefined(); - expect(request.responseXML).toBeUndefined(); - expect(request.statusText).toBeUndefined(); - }); - - it('tracks the request', function() { - var request = new this.FakeRequest(); - - expect(this.requestTracker.track).toHaveBeenCalledWith(request); - }); - - it('has default request headers and override mime type', function() { - var request = new this.FakeRequest(); - - expect(request.requestHeaders).toEqual({}); - expect(request.overriddenMimeType).toBeNull(); - }); - - it('saves request information when opened', function() { - var request = new this.FakeRequest(); - request.open('METHOD', 'URL', 'ignore_async', 'USERNAME', 'PASSWORD'); - - expect(request.method).toEqual('METHOD'); - expect(request.url).toEqual('URL'); - expect(request.username).toEqual('USERNAME'); - expect(request.password).toEqual('PASSWORD'); - }); - - it('saves an override mime type', function() { - var request = new this.FakeRequest(); - - request.overrideMimeType('application/text; charset: utf-8'); - - expect(request.overriddenMimeType).toBe('application/text; charset: utf-8'); - }); - - it('saves request headers', function() { - var request = new this.FakeRequest(); - - request.setRequestHeader('X-Header-1', 'value1'); - request.setRequestHeader('X-Header-2', 'value2'); - - expect(request.requestHeaders).toEqual({ - 'X-Header-1': 'value1', - 'X-Header-2': 'value2' - }); - }); - - it('combines request headers with the same header name', function() { - var request = new this.FakeRequest(); - - request.setRequestHeader('X-Header', 'value1'); - request.setRequestHeader('X-Header', 'value2'); - - expect(request.requestHeaders['X-Header']).toEqual('value1, value2'); - }); - - it('finds the content-type request header', function() { - var request = new this.FakeRequest(); - - request.setRequestHeader('ContEnt-tYPe', 'application/text+xml'); - - expect(request.contentType()).toEqual('application/text+xml'); - }); - - describe('managing readyState', function() { - beforeEach(function() { - this.request = new this.FakeRequest(); - }); - - it('has an initial ready state of 0 (uninitialized)', function() { - expect(this.request.readyState).toBe(0); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalled(); - }); - - it('has a ready state of 1 (open) when opened', function() { - this.request.open(); - - expect(this.request.readyState).toBe(1); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - }); - - it('has a ready state of 0 (uninitialized) when aborted', function() { - this.request.open(); - this.fakeEventBus.trigger.calls.reset(); - - this.request.abort(); - - expect(this.request.readyState).toBe(0); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - }); - - it('has a ready state of 1 (sent) when sent', function() { - this.request.open(); - this.fakeEventBus.trigger.calls.reset(); - - this.request.send(); - - expect(this.request.readyState).toBe(1); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadstart'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('readystatechange'); - }); - - it('has a ready state of 4 (loaded) when timed out', function() { - this.request.open(); - this.request.send(); - this.fakeEventBus.trigger.calls.reset(); - - jasmine.clock().install(); - this.request.responseTimeout(); - jasmine.clock().uninstall(); - - expect(this.request.readyState).toBe(4); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange', 'timeout'); - }); - - it('has a ready state of 4 (loaded) when network erroring', function() { - this.request.open(); - this.request.send(); - this.fakeEventBus.trigger.calls.reset(); - - this.request.responseError(); - - expect(this.request.readyState).toBe(4); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - }); - - it('has a ready state of 4 (loaded) when responding', function() { - this.request.open(); - this.request.send(); - this.fakeEventBus.trigger.calls.reset(); - - this.request.respondWith({}); - - expect(this.request.readyState).toBe(4); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - }); - - it('has a ready state of 2, then 4 (loaded) when responding', function() { - this.request.open(); - this.request.send(); - this.fakeEventBus.trigger.calls.reset(); - - var request = this.request; - var events = []; - var headers = [ - { name: 'X-Header', value: 'foo' } - ]; - - this.fakeEventBus.trigger.and.callFake(function(event) { - if (event === 'readystatechange') { - events.push({ - readyState: request.readyState, - status: request.status, - statusText: request.statusText, - responseHeaders: request.responseHeaders - }); - } - }); - - this.request.respondWith({ - status: 200, - statusText: 'OK', - responseHeaders: headers - }); - - expect(this.request.readyState).toBe(4); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - expect(events.length).toBe(2); - expect(events).toEqual([ - { readyState: 2, status: 200, statusText: 'OK', responseHeaders: headers }, - { readyState: 4, status: 200, statusText: 'OK', responseHeaders: headers } - ]); - }); - - it('throws an error when timing out a request that has completed', function() { - this.request.open(); - this.request.send(); - this.request.respondWith({}); - var request = this.request; - - expect(function() { - request.responseTimeout(); - }).toThrowError('FakeXMLHttpRequest already completed'); - }); - - it('throws an error when responding to a request that has completed', function() { - this.request.open(); - this.request.send(); - this.request.respondWith({}); - var request = this.request; - - expect(function() { - request.respondWith({}); - }).toThrowError('FakeXMLHttpRequest already completed'); - }); - - it('throws an error when erroring a request that has completed', function() { - this.request.open(); - this.request.send(); - this.request.respondWith({}); - var request = this.request; - - expect(function() { - request.responseError({}); - }).toThrowError('FakeXMLHttpRequest already completed'); - }); - }); - - it('registers on-style callback with the event bus', function() { - this.request = new this.FakeRequest(); - - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('readystatechange', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('loadstart', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('progress', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('abort', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('error', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('load', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('timeout', jasmine.any(Function)); - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('loadend', jasmine.any(Function)); - - this.request.onreadystatechange = jasmine.createSpy('readystatechange'); - this.request.onloadstart = jasmine.createSpy('loadstart'); - this.request.onprogress = jasmine.createSpy('progress'); - this.request.onabort = jasmine.createSpy('abort'); - this.request.onerror = jasmine.createSpy('error'); - this.request.onload = jasmine.createSpy('load'); - this.request.ontimeout = jasmine.createSpy('timeout'); - this.request.onloadend = jasmine.createSpy('loadend'); - - var args = this.fakeEventBus.addEventListener.calls.allArgs(); - for (var i = 0; i < args.length; i++) { - var eventName = args[i][0], - busCallback = args[i][1]; - - busCallback(); - expect(this.request['on' + eventName]).toHaveBeenCalled(); - } - }); - - it('delegates addEventListener to the eventBus', function() { - this.request = new this.FakeRequest(); - - this.request.addEventListener('foo', 'bar'); - - expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('foo', 'bar'); - }); - - it('delegates removeEventListener to the eventBus', function() { - this.request = new this.FakeRequest(); - - this.request.removeEventListener('foo', 'bar'); - - expect(this.fakeEventBus.removeEventListener).toHaveBeenCalledWith('foo', 'bar'); - }); - - describe('triggering progress events', function() { - beforeEach(function() { - this.request = new this.FakeRequest(); - }); - - it('should not trigger any events to start', function() { - this.request.open(); - - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - }); - - it('should trigger loadstart when sent', function() { - this.request.open(); - - this.fakeEventBus.trigger.calls.reset(); - - this.request.send(); - - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadstart'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('readystatechange'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('progress'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadend'); - }); - - it('should trigger abort, progress, loadend when aborted', function() { - this.request.open(); - this.request.send(); - - this.fakeEventBus.trigger.calls.reset(); - - this.request.abort(); - - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('abort'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); - }); - - it('should trigger error, progress, loadend when network error', function() { - this.request.open(); - this.request.send(); - - this.fakeEventBus.trigger.calls.reset(); - - this.request.responseError(); - - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('error'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); - }); + beforeEach(function() { + this.requestTracker = { track: jasmine.createSpy('trackRequest') }; + this.stubTracker = { findStub: function() { } }; + var parserInstance = this.parserInstance = jasmine.createSpy('parse'); + this.paramParser = { findParser: function() { return { parse: parserInstance }; } }; + var eventBus = this.fakeEventBus = { + addEventListener: jasmine.createSpy('addEventListener'), + trigger: jasmine.createSpy('trigger'), + removeEventListener: jasmine.createSpy('removeEventListener') + }; + this.eventBusFactory = function() { + return eventBus; + }; + this.fakeGlobal = { + XMLHttpRequest: function() { + this.extraAttribute = 'my cool attribute'; + }, + DOMParser: window['DOMParser'], + ActiveXObject: window['ActiveXObject'] + }; + this.FakeRequest = getJasmineRequireObj().AjaxFakeRequest(this.eventBusFactory)(this.fakeGlobal, this.requestTracker, this.stubTracker, this.paramParser); + }); + + it('extends from the global XMLHttpRequest', function() { + var request = new this.FakeRequest(); + + expect(request.extraAttribute).toEqual('my cool attribute'); + }); + + it('skips XMLHttpRequest attributes that IE does not want copied', function() { + // use real window here so it will correctly go red on IE if it breaks + var FakeRequest = getJasmineRequireObj().AjaxFakeRequest(this.eventBusFactory)(window, this.requestTracker, this.stubTracker, this.paramParser); + var request = new FakeRequest(); + + expect(request.responseBody).toBeUndefined(); + expect(request.responseXML).toBeUndefined(); + expect(request.statusText).toBeUndefined(); + }); + + it('tracks the request', function() { + var request = new this.FakeRequest(); + + expect(this.requestTracker.track).toHaveBeenCalledWith(request); + }); + + it('has default request headers and override mime type', function() { + var request = new this.FakeRequest(); + + expect(request.requestHeaders).toEqual({}); + expect(request.overriddenMimeType).toBeNull(); + }); + + it('saves request information when opened', function() { + var request = new this.FakeRequest(); + request.open('METHOD', 'URL', 'ignore_async', 'USERNAME', 'PASSWORD'); + + expect(request.method).toEqual('METHOD'); + expect(request.url).toEqual('URL'); + expect(request.username).toEqual('USERNAME'); + expect(request.password).toEqual('PASSWORD'); + }); + + it('saves an override mime type', function() { + var request = new this.FakeRequest(); + + request.overrideMimeType('application/text; charset: utf-8'); + + expect(request.overriddenMimeType).toBe('application/text; charset: utf-8'); + }); + + it('saves request headers', function() { + var request = new this.FakeRequest(); + + request.setRequestHeader('X-Header-1', 'value1'); + request.setRequestHeader('X-Header-2', 'value2'); + + expect(request.requestHeaders).toEqual({ + 'X-Header-1': 'value1', + 'X-Header-2': 'value2' + }); + }); + + it('combines request headers with the same header name', function() { + var request = new this.FakeRequest(); + + request.setRequestHeader('X-Header', 'value1'); + request.setRequestHeader('X-Header', 'value2'); + + expect(request.requestHeaders['X-Header']).toEqual('value1, value2'); + }); + + it('finds the content-type request header', function() { + var request = new this.FakeRequest(); + + request.setRequestHeader('ContEnt-tYPe', 'application/text+xml'); + + expect(request.contentType()).toEqual('application/text+xml'); + }); + + describe('managing readyState', function() { + beforeEach(function() { + this.request = new this.FakeRequest(); + }); + + it('has an initial ready state of 0 (uninitialized)', function() { + expect(this.request.readyState).toBe(0); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalled(); + }); + + it('has a ready state of 1 (open) when opened', function() { + this.request.open(); + + expect(this.request.readyState).toBe(1); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 0 (uninitialized) when aborted', function() { + this.request.open(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.abort(); + + expect(this.request.readyState).toBe(0); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 1 (sent) when sent', function() { + this.request.open(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.send(); + + expect(this.request.readyState).toBe(1); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 4 (loaded) when timed out', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + jasmine.clock().install(); + this.request.responseTimeout(); + jasmine.clock().uninstall(); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange', 'timeout'); + }); + + it('has a ready state of 4 (loaded) when network erroring', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.responseError(); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 4 (loaded) when responding', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + this.request.respondWith({}); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('has a ready state of 2, then 4 (loaded) when responding', function() { + this.request.open(); + this.request.send(); + this.fakeEventBus.trigger.calls.reset(); + + var request = this.request; + var events = []; + var headers = [ + { name: 'X-Header', value: 'foo' } + ]; + + this.fakeEventBus.trigger.and.callFake(function(event) { + if (event === 'readystatechange') { + events.push({ + readyState: request.readyState, + status: request.status, + statusText: request.statusText, + responseHeaders: request.responseHeaders + }); + } + }); + + this.request.respondWith({ + status: 200, + statusText: 'OK', + responseHeaders: headers + }); + + expect(this.request.readyState).toBe(4); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(events.length).toBe(2); + expect(events).toEqual([ + { readyState: 2, status: 200, statusText: 'OK', responseHeaders: headers }, + { readyState: 4, status: 200, statusText: 'OK', responseHeaders: headers } + ]); + }); + + it('throws an error when timing out a request that has completed', function() { + this.request.open(); + this.request.send(); + this.request.respondWith({}); + var request = this.request; + + expect(function() { + request.responseTimeout(); + }).toThrowError('FakeXMLHttpRequest already completed'); + }); + + it('throws an error when responding to a request that has completed', function() { + this.request.open(); + this.request.send(); + this.request.respondWith({}); + var request = this.request; + + expect(function() { + request.respondWith({}); + }).toThrowError('FakeXMLHttpRequest already completed'); + }); + + it('throws an error when erroring a request that has completed', function() { + this.request.open(); + this.request.send(); + this.request.respondWith({}); + var request = this.request; + + expect(function() { + request.responseError({}); + }).toThrowError('FakeXMLHttpRequest already completed'); + }); + }); + + it('registers on-style callback with the event bus', function() { + this.request = new this.FakeRequest(); + + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('readystatechange', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('loadstart', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('progress', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('abort', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('error', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('load', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('timeout', jasmine.any(Function)); + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('loadend', jasmine.any(Function)); + + this.request.onreadystatechange = jasmine.createSpy('readystatechange'); + this.request.onloadstart = jasmine.createSpy('loadstart'); + this.request.onprogress = jasmine.createSpy('progress'); + this.request.onabort = jasmine.createSpy('abort'); + this.request.onerror = jasmine.createSpy('error'); + this.request.onload = jasmine.createSpy('load'); + this.request.ontimeout = jasmine.createSpy('timeout'); + this.request.onloadend = jasmine.createSpy('loadend'); + + var args = this.fakeEventBus.addEventListener.calls.allArgs(); + for (var i = 0; i < args.length; i++) { + var eventName = args[i][0], + busCallback = args[i][1]; + + busCallback(); + expect(this.request['on' + eventName]).toHaveBeenCalled(); + } + }); + + it('delegates addEventListener to the eventBus', function() { + this.request = new this.FakeRequest(); + + this.request.addEventListener('foo', 'bar'); + + expect(this.fakeEventBus.addEventListener).toHaveBeenCalledWith('foo', 'bar'); + }); + + it('delegates removeEventListener to the eventBus', function() { + this.request = new this.FakeRequest(); + + this.request.removeEventListener('foo', 'bar'); + + expect(this.fakeEventBus.removeEventListener).toHaveBeenCalledWith('foo', 'bar'); + }); + + describe('triggering progress events', function() { + beforeEach(function() { + this.request = new this.FakeRequest(); + }); + + it('should not trigger any events to start', function() { + this.request.open(); + + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + }); + + it('should trigger loadstart when sent', function() { + this.request.open(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.send(); + + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadend'); + }); + + it('should trigger abort, progress, loadend when aborted', function() { + this.request.open(); + this.request.send(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.abort(); + + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); + + it('should trigger error, progress, loadend when network error', function() { + this.request.open(); + this.request.send(); + + this.fakeEventBus.trigger.calls.reset(); + + this.request.responseError(); + + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); - it('should trigger timeout, progress, loadend when timing out', function() { - this.request.open(); - this.request.send(); + it('should trigger timeout, progress, loadend when timing out', function() { + this.request.open(); + this.request.send(); - this.fakeEventBus.trigger.calls.reset(); + this.fakeEventBus.trigger.calls.reset(); - jasmine.clock().install(); - this.request.responseTimeout(); - jasmine.clock().uninstall(); + jasmine.clock().install(); + this.request.responseTimeout(); + jasmine.clock().uninstall(); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange', 'timeout'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('timeout'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); - }); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange', 'timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); - it('should trigger load, progress, loadend when responding', function() { - this.request.open(); - this.request.send(); + it('should trigger load, progress, loadend when responding', function() { + this.request.open(); + this.request.send(); - this.fakeEventBus.trigger.calls.reset(); + this.fakeEventBus.trigger.calls.reset(); - this.request.respondWith({ status: 200 }); + this.request.respondWith({ status: 200 }); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('load'); - expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); - expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); - }); - }); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('loadstart'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('readystatechange'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('progress'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('abort'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('error'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('load'); + expect(this.fakeEventBus.trigger).not.toHaveBeenCalledWith('timeout'); + expect(this.fakeEventBus.trigger).toHaveBeenCalledWith('loadend'); + }); + }); - it('ticks the jasmine clock on timeout', function() { - var clock = { tick: jasmine.createSpy('tick') }; - spyOn(jasmine, 'clock').and.returnValue(clock); + it('ticks the jasmine clock on timeout', function() { + var clock = { tick: jasmine.createSpy('tick') }; + spyOn(jasmine, 'clock').and.returnValue(clock); - var request = new this.FakeRequest(); - request.open(); - request.send(); + var request = new this.FakeRequest(); + request.open(); + request.send(); - request.responseTimeout(); + request.responseTimeout(); - expect(clock.tick).toHaveBeenCalledWith(30000); - }); + expect(clock.tick).toHaveBeenCalledWith(30000); + }); - it('has an initial status of null', function() { - var request = new this.FakeRequest(); - - expect(request.status).toBeNull(); - }); - - it('has an aborted status', function() { - var request = new this.FakeRequest(); - - request.abort(); + it('has an initial status of null', function() { + var request = new this.FakeRequest(); + + expect(request.status).toBeNull(); + }); + + it('has an aborted status', function() { + var request = new this.FakeRequest(); + + request.abort(); - expect(request.status).toBe(0); - expect(request.statusText).toBe('abort'); - }); + expect(request.status).toBe(0); + expect(request.statusText).toBe('abort'); + }); - it('has a status from the response', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200 }); - - expect(request.status).toBe(200); - expect(request.statusText).toBe(''); - }); - - it('has a statusText from the response', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, statusText: 'OK' }); - - expect(request.status).toBe(200); - expect(request.statusText).toBe('OK'); - }); - - it('saves off any data sent to the server', function() { - var request = new this.FakeRequest(); - request.open(); - request.send('foo=bar&baz=quux'); - - expect(request.params).toBe('foo=bar&baz=quux'); - }); - - it('parses data sent to the server', function() { - var request = new this.FakeRequest(); - request.open(); - request.send('foo=bar&baz=quux'); - - this.parserInstance.and.returnValue('parsed'); + it('has a status from the response', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.status).toBe(200); + expect(request.statusText).toBe(''); + }); + + it('has a statusText from the response', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, statusText: 'OK' }); + + expect(request.status).toBe(200); + expect(request.statusText).toBe('OK'); + }); + + it('saves off any data sent to the server', function() { + var request = new this.FakeRequest(); + request.open(); + request.send('foo=bar&baz=quux'); + + expect(request.params).toBe('foo=bar&baz=quux'); + }); + + it('parses data sent to the server', function() { + var request = new this.FakeRequest(); + request.open(); + request.send('foo=bar&baz=quux'); + + this.parserInstance.and.returnValue('parsed'); - expect(request.data()).toBe('parsed'); - }); - - it('skips parsing if no data was sent', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - expect(request.data()).toEqual({}); - expect(this.parserInstance).not.toHaveBeenCalled(); - }); - - it('saves responseText', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, responseText: 'foobar' }); + expect(request.data()).toBe('parsed'); + }); + + it('skips parsing if no data was sent', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + expect(request.data()).toEqual({}); + expect(this.parserInstance).not.toHaveBeenCalled(); + }); + + it('saves responseText', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foobar' }); - expect(request.responseText).toBe('foobar'); - }); + expect(request.responseText).toBe('foobar'); + }); - it('defaults responseText if none is given', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200 }); + it('defaults responseText if none is given', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); - expect(request.responseText).toBe(''); - }); + expect(request.responseText).toBe(''); + }); - it('retrieves individual response headers', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); + it('retrieves individual response headers', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); - request.respondWith({ - status: 200, - responseHeaders: { - 'X-Header': 'foo' - } - }); + request.respondWith({ + status: 200, + responseHeaders: { + 'X-Header': 'foo' + } + }); - expect(request.getResponseHeader('X-Header')).toBe('foo'); - }); + expect(request.getResponseHeader('X-Header')).toBe('foo'); + }); - it('retrieves individual response headers case-insensitively', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); + it('retrieves individual response headers case-insensitively', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); - request.respondWith({ - status: 200, - responseHeaders: { - 'X-Header': 'foo' - } - }); - - expect(request.getResponseHeader('x-header')).toBe('foo'); - }); - - it('retrieves a combined response header', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ - status: 200, - responseHeaders: [ - { name: 'X-Header', value: 'foo' }, - { name: 'X-Header', value: 'bar' } - ] - }); - - expect(request.getResponseHeader('x-header')).toBe('foo, bar'); - }); - - it("doesn't pollute the response headers of other XHRs", function() { - var request1 = new this.FakeRequest(); - request1.open(); - request1.send(); - - var request2 = new this.FakeRequest(); - request2.open(); - request2.send(); - - request1.respondWith({ status: 200, responseHeaders: { 'X-Foo': 'bar' } }); - request2.respondWith({ status: 200, responseHeaders: { 'X-Baz': 'quux' } }); - - expect(request1.getAllResponseHeaders()).toBe("X-Foo: bar\r\n"); - expect(request2.getAllResponseHeaders()).toBe("X-Baz: quux\r\n"); - }); - - it('retrieves all response headers', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ - status: 200, - responseHeaders: [ - { name: 'X-Header-1', value: 'foo' }, - { name: 'X-Header-2', value: 'bar' }, - { name: 'X-Header-1', value: 'baz' } - ] - }); - - expect(request.getAllResponseHeaders()).toBe("X-Header-1: foo\r\nX-Header-2: bar\r\nX-Header-1: baz\r\n"); - }); - - it('sets the content-type header to the specified contentType when no other headers are supplied', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, contentType: 'text/plain' }); - - expect(request.getResponseHeader('content-type')).toBe('text/plain'); - expect(request.getAllResponseHeaders()).toBe("Content-Type: text/plain\r\n"); - }); - - it('sets a default content-type header if no contentType and headers are supplied', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200 }); - - expect(request.getResponseHeader('content-type')).toBe('application/json'); - expect(request.getAllResponseHeaders()).toBe("Content-Type: application/json\r\n"); - }); - - it('has no responseXML by default', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200 }); - - expect(request.responseXML).toBeNull(); - }); - - it('parses a text/xml document into responseXML', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, contentType: 'text/xml', responseText: '' }); - - if (typeof window['Document'] !== 'undefined') { - expect(request.responseXML instanceof window['Document']).toBe(true); - expect(request.response instanceof window['Document']).toBe(true); - } else { - // IE 8 - expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); - expect(request.response instanceof window['ActiveXObject']).toBe(true); - } - }); - - it('parses an application/xml document into responseXML', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, contentType: 'application/xml', responseText: '' }); - - if (typeof window['Document'] !== 'undefined') { - expect(request.responseXML instanceof window['Document']).toBe(true); - expect(request.response instanceof window['Document']).toBe(true); - } else { - // IE 8 - expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); - expect(request.response instanceof window['ActiveXObject']).toBe(true); - } - }); - - it('parses a custom blah+xml document into responseXML', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, contentType: 'application/text+xml', responseText: '' }); - - if (typeof window['Document'] !== 'undefined') { - expect(request.responseXML instanceof window['Document']).toBe(true); - expect(request.response instanceof window['Document']).toBe(true); - } else { - // IE 8 - expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); - expect(request.response instanceof window['ActiveXObject']).toBe(true); - } - }); - - it('defaults the response attribute to the responseText', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, responseText: 'foo' }); - - expect(request.response).toEqual('foo'); - }); - - it('has a text response when the responseType is blank', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, responseText: 'foo', responseType: '' }); - - expect(request.response).toEqual('foo'); - }); - - it('has a text response when the responseType is text', function() { - var request = new this.FakeRequest(); - request.open(); - request.send(); - - request.respondWith({ status: 200, responseText: 'foo', responseType: 'text' }); - - expect(request.response).toEqual('foo'); - }); + request.respondWith({ + status: 200, + responseHeaders: { + 'X-Header': 'foo' + } + }); + + expect(request.getResponseHeader('x-header')).toBe('foo'); + }); + + it('retrieves a combined response header', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ + status: 200, + responseHeaders: [ + { name: 'X-Header', value: 'foo' }, + { name: 'X-Header', value: 'bar' } + ] + }); + + expect(request.getResponseHeader('x-header')).toBe('foo, bar'); + }); + + it("doesn't pollute the response headers of other XHRs", function() { + var request1 = new this.FakeRequest(); + request1.open(); + request1.send(); + + var request2 = new this.FakeRequest(); + request2.open(); + request2.send(); + + request1.respondWith({ status: 200, responseHeaders: { 'X-Foo': 'bar' } }); + request2.respondWith({ status: 200, responseHeaders: { 'X-Baz': 'quux' } }); + + expect(request1.getAllResponseHeaders()).toBe("X-Foo: bar\r\n"); + expect(request2.getAllResponseHeaders()).toBe("X-Baz: quux\r\n"); + }); + + it('retrieves all response headers', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ + status: 200, + responseHeaders: [ + { name: 'X-Header-1', value: 'foo' }, + { name: 'X-Header-2', value: 'bar' }, + { name: 'X-Header-1', value: 'baz' } + ] + }); + + expect(request.getAllResponseHeaders()).toBe("X-Header-1: foo\r\nX-Header-2: bar\r\nX-Header-1: baz\r\n"); + }); + + it('sets the content-type header to the specified contentType when no other headers are supplied', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'text/plain' }); + + expect(request.getResponseHeader('content-type')).toBe('text/plain'); + expect(request.getAllResponseHeaders()).toBe("Content-Type: text/plain\r\n"); + }); + + it('sets a default content-type header if no contentType and headers are supplied', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.getResponseHeader('content-type')).toBe('application/json'); + expect(request.getAllResponseHeaders()).toBe("Content-Type: application/json\r\n"); + }); + + it('has no responseXML by default', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200 }); + + expect(request.responseXML).toBeNull(); + }); + + it('parses a text/xml document into responseXML', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'text/xml', responseText: '' }); + + if (typeof window['Document'] !== 'undefined') { + expect(request.responseXML instanceof window['Document']).toBe(true); + expect(request.response instanceof window['Document']).toBe(true); + } else { + // IE 8 + expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); + expect(request.response instanceof window['ActiveXObject']).toBe(true); + } + }); + + it('parses an application/xml document into responseXML', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'application/xml', responseText: '' }); + + if (typeof window['Document'] !== 'undefined') { + expect(request.responseXML instanceof window['Document']).toBe(true); + expect(request.response instanceof window['Document']).toBe(true); + } else { + // IE 8 + expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); + expect(request.response instanceof window['ActiveXObject']).toBe(true); + } + }); + + it('parses a custom blah+xml document into responseXML', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, contentType: 'application/text+xml', responseText: '' }); + + if (typeof window['Document'] !== 'undefined') { + expect(request.responseXML instanceof window['Document']).toBe(true); + expect(request.response instanceof window['Document']).toBe(true); + } else { + // IE 8 + expect(request.responseXML instanceof window['ActiveXObject']).toBe(true); + expect(request.response instanceof window['ActiveXObject']).toBe(true); + } + }); + + it('defaults the response attribute to the responseText', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foo' }); + + expect(request.response).toEqual('foo'); + }); + + it('has a text response when the responseType is blank', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foo', responseType: '' }); + + expect(request.response).toEqual('foo'); + }); + + it('has a text response when the responseType is text', function() { + var request = new this.FakeRequest(); + request.open(); + request.send(); + + request.respondWith({ status: 200, responseText: 'foo', responseType: 'text' }); + + expect(request.response).toEqual('foo'); + }); }); describe("Jasmine Mock Ajax (for toplevel)", function() { - var request, anotherRequest, response; - var success, error, complete; - var client, onreadystatechange; - var sharedContext: any = {}; - var fakeGlobal, mockAjax; - - beforeEach(function() { - var fakeXMLHttpRequest = jasmine.createSpy('realFakeXMLHttpRequest'); - fakeGlobal = { - XMLHttpRequest: fakeXMLHttpRequest, - DOMParser: window['DOMParser'], - ActiveXObject: window['ActiveXObject'] - }; - mockAjax = new MockAjax(fakeGlobal); - mockAjax.install(); - - success = jasmine.createSpy("onSuccess"); - error = jasmine.createSpy("onFailure"); - complete = jasmine.createSpy("onComplete"); - - onreadystatechange = function() { - if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE - if (this.status === 200) { - success(this.responseText, this.textStatus, this); - } else { - error(this, this.textStatus, ''); - } - - complete(this, this.textStatus); - } - }; - }); - - describe("when making a request", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.send(); - request = mockAjax.requests.mostRecent(); - }); - - it("should store URL and transport", function() { - expect(request.url).toEqual("example.com/someApi"); - }); - - it("should queue the request", function() { - expect(mockAjax.requests.count()).toEqual(1); - }); - - it("should allow access to the queued request", function() { - expect(mockAjax.requests.first()).toEqual(request); - }); - - it("should allow access to the queued request via index", function() { - expect(mockAjax.requests.at(0)).toEqual(request); - }); - - describe("and then another request", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.send(); - - anotherRequest = mockAjax.requests.mostRecent(); - }); - - it("should queue the next request", function() { - expect(mockAjax.requests.count()).toEqual(2); - }); - - it("should allow access to the other queued request", function() { - expect(mockAjax.requests.first()).toEqual(request); - expect(mockAjax.requests.mostRecent()).toEqual(anotherRequest); - }); - }); - - describe("mockAjax.requests.mostRecent()", function () { - - describe("when there is one request queued", function () { - it("should return the request", function() { - expect(mockAjax.requests.mostRecent()).toEqual(request); - }); - }); - - describe("when there is more than one request", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.send(); - anotherRequest = mockAjax.requests.mostRecent(); - }); - - it("should return the most recent request", function() { - expect(mockAjax.requests.mostRecent()).toEqual(anotherRequest); - }); - }); - - describe("when there are no requests", function () { - beforeEach(function() { - mockAjax.requests.reset(); - }); - - it("should return null", function() { - expect(mockAjax.requests.mostRecent()).toBeUndefined(); - }); - }); - }); - - describe("clearAjaxRequests()", function () { - beforeEach(function() { - mockAjax.requests.reset(); - }); - - it("should remove all requests", function() { - expect(mockAjax.requests.count()).toEqual(0); - expect(mockAjax.requests.mostRecent()).toBeUndefined(); - }); - }); - }); - - describe("when simulating a response with request.response", function () { - describe("and the response is Success", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "text/plain"); - client.send(); - - request = mockAjax.requests.mostRecent(); - response = {status: 200, statusText: "OK", contentType: "text/html", responseText: "OK!"}; - request.respondWith(response); - - sharedContext.responseCallback = success; - sharedContext.status = response.status; - sharedContext.statusText = response.statusText; - sharedContext.contentType = response.contentType; - sharedContext.responseText = response.responseText; - sharedContext.responseType = response.responseType; - }); - - it("should call the success handler", function() { - expect(success).toHaveBeenCalled(); - }); - - it("should not call the failure handler", function() { - expect(error).not.toHaveBeenCalled(); - }); - - it("should call the complete handler", function() { - expect(complete).toHaveBeenCalled(); - }); - - sharedAjaxResponseBehaviorForZepto_Success(sharedContext); - }); - - describe("and the response is Success, but with JSON", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "application/json"); - client.send(); - - request = mockAjax.requests.mostRecent(); - var responseObject = {status: 200, statusText: "OK", contentType: "application/json", responseText: '{"foo":"bar"}', responseType: "json"}; - - request.respondWith(responseObject); - - sharedContext.responseCallback = success; - sharedContext.status = responseObject.status; - sharedContext.statusText = responseObject.statusText; - sharedContext.contentType = responseObject.contentType; - sharedContext.responseText = responseObject.responseText; - sharedContext.responseType = responseObject.responseType; - - response = success.calls.mostRecent().args[2]; - }); - - it("should call the success handler", function() { - expect(success).toHaveBeenCalled(); - }); - - it("should not call the failure handler", function() { - expect(error).not.toHaveBeenCalled(); - }); - - it("should call the complete handler", function() { - expect(complete).toHaveBeenCalled(); - }); - - it("should return a JavaScript object for XHR2 response", function() { - var responseText = sharedContext.responseText; - expect(success.calls.mostRecent().args[0]).toEqual(responseText); - - expect(response.responseText).toEqual(responseText); - expect(response.response).toEqual({foo: "bar"}); - }); - - sharedAjaxResponseBehaviorForZepto_Success(sharedContext); - }); - - describe("and the response is Success, and response is overriden", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "application/json"); - client.send(); - - request = mockAjax.requests.mostRecent(); - var responseObject = {status: 200, statusText: "OK", contentType: "application/json", responseText: '{"foo":"bar"}', responseType: 'json'}; - - request.respondWith(responseObject); - - sharedContext.responseCallback = success; - sharedContext.status = responseObject.status; - sharedContext.statusText = responseObject.statusText; - sharedContext.contentType = responseObject.contentType; - sharedContext.responseText = responseObject.responseText; - sharedContext.responseType = responseObject.responseType; - - response = success.calls.mostRecent().args[2]; - }); - - it("should return the provided override for the XHR2 response", function() { - var responseText = sharedContext.responseText; - - expect(response.responseText).toEqual(responseText); - expect(response.response).toEqual({foo: "bar"}); - }); - - sharedAjaxResponseBehaviorForZepto_Success(sharedContext); - }); - - describe("response with unique header names using an object", function () { - beforeEach(function () { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com"); - client.send(); - - request = mockAjax.requests.mostRecent(); - var responseObject = {status: 200, statusText: "OK", responseText: '["foo"]', responseHeaders: { - 'X-Header1': 'header 1 value', - 'X-Header2': 'header 2 value', - 'X-Header3': 'header 3 value' - }}; - request.respondWith(responseObject); - response = success.calls.mostRecent().args[2]; - }); - - it("getResponseHeader should return the each value", function () { - expect(response.getResponseHeader('X-Header1')).toBe('header 1 value'); - expect(response.getResponseHeader('X-Header2')).toBe('header 2 value'); - expect(response.getResponseHeader('X-Header3')).toBe('header 3 value'); - }); - - it("getAllResponseHeaders should return all values", function () { - expect(response.getAllResponseHeaders()).toBe([ - "X-Header1: header 1 value", - "X-Header2: header 2 value", - "X-Header3: header 3 value" - ].join("\r\n") + "\r\n"); - }); - }); - - describe("response with multiple headers of the same name using an array of objects", function () { - beforeEach(function () { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com"); - client.send(); - - request = mockAjax.requests.mostRecent(); - var responseObject = {status: 200, statusText: "OK", responseText: '["foo"]', responseHeaders: [ - { name: 'X-Header', value: 'header value 1' }, - { name: 'X-Header', value: 'header value 2' } - ]}; - request.respondWith(responseObject); - response = success.calls.mostRecent().args[2]; - }); - - it("getResponseHeader should return all values comma separated", function () { - expect(response.getResponseHeader('X-Header')).toBe('header value 1, header value 2'); - }); - - it("getAllResponseHeaders should return all values", function () { - expect(response.getAllResponseHeaders()).toBe([ - "X-Header: header value 1", - "X-Header: header value 2" - ].join("\r\n") + "\r\n"); - }); - }); - - describe("the content type defaults to application/json", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "application/json"); - client.send(); - - request = mockAjax.requests.mostRecent(); - response = {status: 200, statusText: "OK", responseText: '{"foo": "valid JSON, dammit."}', responseType: 'json'}; - request.respondWith(response); - - sharedContext.responseCallback = success; - sharedContext.status = response.status; - sharedContext.statusText = response.statusText; - sharedContext.contentType = "application/json"; - sharedContext.responseType = response.responseType; - sharedContext.responseText = response.responseText; - }); - - it("should call the success handler", function() { - expect(success).toHaveBeenCalled(); - }); - - it("should not call the failure handler", function() { - expect(error).not.toHaveBeenCalled(); - }); - - it("should call the complete handler", function() { - expect(complete).toHaveBeenCalled(); - }); - - sharedAjaxResponseBehaviorForZepto_Success(sharedContext); - }); - - describe("and the status/response code is 0", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "text/plain"); - client.send(); - - request = mockAjax.requests.mostRecent(); - response = {status: 0, statusText: "ABORT", responseText: '{"foo": "whoops!"}'}; - request.respondWith(response); - - sharedContext.responseCallback = error; - sharedContext.status = 0; - sharedContext.statusText = response.statusText; - sharedContext.contentType = 'application/json'; - sharedContext.responseText = response.responseText; - sharedContext.responseType = response.responseType; - }); - - it("should call the success handler", function() { - expect(success).not.toHaveBeenCalled(); - }); - - it("should not call the failure handler", function() { - expect(error).toHaveBeenCalled(); - }); - - it("should call the complete handler", function() { - expect(complete).toHaveBeenCalled(); - }); - - sharedAjaxResponseBehaviorForZepto_Failure(sharedContext); - }); - }); - - describe("and the response is error", function () { - beforeEach(function() { - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "text/plain"); - client.send(); - - request = mockAjax.requests.mostRecent(); - response = {status: 500, statusText: "SERVER ERROR", contentType: "text/html", responseText: "(._){"}; - request.respondWith(response); - - sharedContext.responseCallback = error; - sharedContext.status = response.status; - sharedContext.statusText = response.statusText; - sharedContext.contentType = response.contentType; - sharedContext.responseText = response.responseText; - sharedContext.responseType = response.responseType; - }); - - it("should not call the success handler", function() { - expect(success).not.toHaveBeenCalled(); - }); - - it("should call the failure handler", function() { - expect(error).toHaveBeenCalled(); - }); - - it("should call the complete handler", function() { - expect(complete).toHaveBeenCalled(); - }); - - sharedAjaxResponseBehaviorForZepto_Failure(sharedContext); - }); - - describe('when simulating a response with request.responseTimeout', function() { - beforeEach(function() { - jasmine.clock().install(); - - client = new fakeGlobal.XMLHttpRequest(); - client.onreadystatechange = onreadystatechange; - client.open("GET", "example.com/someApi"); - client.setRequestHeader("Content-Type", "text/plain"); - client.send(); - - request = mockAjax.requests.mostRecent(); - response = {contentType: "text/html", response: "(._){response", responseText: "(._){", responseType: "text"}; - request.responseTimeout(response); - - sharedContext.responseCallback = error; - sharedContext.status = response.status; - sharedContext.statusText = response.statusText; - sharedContext.contentType = response.contentType; - sharedContext.responseText = response.responseText; - sharedContext.responseType = response.responseType; - }); - - afterEach(function() { - jasmine.clock().uninstall(); - }); - - it("should not call the success handler", function() { - expect(success).not.toHaveBeenCalled(); - }); - - it("should call the failure handler", function() { - expect(error).toHaveBeenCalled(); - }); - - it("should call the complete handler", function() { - expect(complete).toHaveBeenCalled(); - }); - }); + var request, anotherRequest, response; + var success, error, complete; + var client, onreadystatechange; + var sharedContext: any = {}; + var fakeGlobal, mockAjax; + + beforeEach(function() { + var fakeXMLHttpRequest = jasmine.createSpy('realFakeXMLHttpRequest'); + fakeGlobal = { + XMLHttpRequest: fakeXMLHttpRequest, + DOMParser: window['DOMParser'], + ActiveXObject: window['ActiveXObject'] + }; + mockAjax = new MockAjax(fakeGlobal); + mockAjax.install(); + + success = jasmine.createSpy("onSuccess"); + error = jasmine.createSpy("onFailure"); + complete = jasmine.createSpy("onComplete"); + + onreadystatechange = function() { + if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE + if (this.status === 200) { + success(this.responseText, this.textStatus, this); + } else { + error(this, this.textStatus, ''); + } + + complete(this, this.textStatus); + } + }; + }); + + describe("when making a request", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.send(); + request = mockAjax.requests.mostRecent(); + }); + + it("should store URL and transport", function() { + expect(request.url).toEqual("example.com/someApi"); + }); + + it("should queue the request", function() { + expect(mockAjax.requests.count()).toEqual(1); + }); + + it("should allow access to the queued request", function() { + expect(mockAjax.requests.first()).toEqual(request); + }); + + it("should allow access to the queued request via index", function() { + expect(mockAjax.requests.at(0)).toEqual(request); + }); + + describe("and then another request", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.send(); + + anotherRequest = mockAjax.requests.mostRecent(); + }); + + it("should queue the next request", function() { + expect(mockAjax.requests.count()).toEqual(2); + }); + + it("should allow access to the other queued request", function() { + expect(mockAjax.requests.first()).toEqual(request); + expect(mockAjax.requests.mostRecent()).toEqual(anotherRequest); + }); + }); + + describe("mockAjax.requests.mostRecent()", function() { + + describe("when there is one request queued", function() { + it("should return the request", function() { + expect(mockAjax.requests.mostRecent()).toEqual(request); + }); + }); + + describe("when there is more than one request", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.send(); + anotherRequest = mockAjax.requests.mostRecent(); + }); + + it("should return the most recent request", function() { + expect(mockAjax.requests.mostRecent()).toEqual(anotherRequest); + }); + }); + + describe("when there are no requests", function() { + beforeEach(function() { + mockAjax.requests.reset(); + }); + + it("should return null", function() { + expect(mockAjax.requests.mostRecent()).toBeUndefined(); + }); + }); + }); + + describe("clearAjaxRequests()", function() { + beforeEach(function() { + mockAjax.requests.reset(); + }); + + it("should remove all requests", function() { + expect(mockAjax.requests.count()).toEqual(0); + expect(mockAjax.requests.mostRecent()).toBeUndefined(); + }); + }); + }); + + describe("when simulating a response with request.response", function() { + describe("and the response is Success", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = { status: 200, statusText: "OK", contentType: "text/html", responseText: "OK!" }; + request.respondWith(response); + + sharedContext.responseCallback = success; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = response.contentType; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + it("should call the success handler", function() { + expect(success).toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).not.toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("and the response is Success, but with JSON", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "application/json"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = { status: 200, statusText: "OK", contentType: "application/json", responseText: '{"foo":"bar"}', responseType: "json" }; + + request.respondWith(responseObject); + + sharedContext.responseCallback = success; + sharedContext.status = responseObject.status; + sharedContext.statusText = responseObject.statusText; + sharedContext.contentType = responseObject.contentType; + sharedContext.responseText = responseObject.responseText; + sharedContext.responseType = responseObject.responseType; + + response = success.calls.mostRecent().args[2]; + }); + + it("should call the success handler", function() { + expect(success).toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).not.toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + it("should return a JavaScript object for XHR2 response", function() { + var responseText = sharedContext.responseText; + expect(success.calls.mostRecent().args[0]).toEqual(responseText); + + expect(response.responseText).toEqual(responseText); + expect(response.response).toEqual({ foo: "bar" }); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("and the response is Success, and response is overriden", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "application/json"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = { status: 200, statusText: "OK", contentType: "application/json", responseText: '{"foo":"bar"}', responseType: 'json' }; + + request.respondWith(responseObject); + + sharedContext.responseCallback = success; + sharedContext.status = responseObject.status; + sharedContext.statusText = responseObject.statusText; + sharedContext.contentType = responseObject.contentType; + sharedContext.responseText = responseObject.responseText; + sharedContext.responseType = responseObject.responseType; + + response = success.calls.mostRecent().args[2]; + }); + + it("should return the provided override for the XHR2 response", function() { + var responseText = sharedContext.responseText; + + expect(response.responseText).toEqual(responseText); + expect(response.response).toEqual({ foo: "bar" }); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("response with unique header names using an object", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = { + status: 200, statusText: "OK", responseText: '["foo"]', responseHeaders: { + 'X-Header1': 'header 1 value', + 'X-Header2': 'header 2 value', + 'X-Header3': 'header 3 value' + } + }; + request.respondWith(responseObject); + response = success.calls.mostRecent().args[2]; + }); + + it("getResponseHeader should return the each value", function() { + expect(response.getResponseHeader('X-Header1')).toBe('header 1 value'); + expect(response.getResponseHeader('X-Header2')).toBe('header 2 value'); + expect(response.getResponseHeader('X-Header3')).toBe('header 3 value'); + }); + + it("getAllResponseHeaders should return all values", function() { + expect(response.getAllResponseHeaders()).toBe([ + "X-Header1: header 1 value", + "X-Header2: header 2 value", + "X-Header3: header 3 value" + ].join("\r\n") + "\r\n"); + }); + }); + + describe("response with multiple headers of the same name using an array of objects", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com"); + client.send(); + + request = mockAjax.requests.mostRecent(); + var responseObject = { + status: 200, statusText: "OK", responseText: '["foo"]', responseHeaders: [ + { name: 'X-Header', value: 'header value 1' }, + { name: 'X-Header', value: 'header value 2' } + ] + }; + request.respondWith(responseObject); + response = success.calls.mostRecent().args[2]; + }); + + it("getResponseHeader should return all values comma separated", function() { + expect(response.getResponseHeader('X-Header')).toBe('header value 1, header value 2'); + }); + + it("getAllResponseHeaders should return all values", function() { + expect(response.getAllResponseHeaders()).toBe([ + "X-Header: header value 1", + "X-Header: header value 2" + ].join("\r\n") + "\r\n"); + }); + }); + + describe("the content type defaults to application/json", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "application/json"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = { status: 200, statusText: "OK", responseText: '{"foo": "valid JSON, dammit."}', responseType: 'json' }; + request.respondWith(response); + + sharedContext.responseCallback = success; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = "application/json"; + sharedContext.responseType = response.responseType; + sharedContext.responseText = response.responseText; + }); + + it("should call the success handler", function() { + expect(success).toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).not.toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Success(sharedContext); + }); + + describe("and the status/response code is 0", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = { status: 0, statusText: "ABORT", responseText: '{"foo": "whoops!"}' }; + request.respondWith(response); + + sharedContext.responseCallback = error; + sharedContext.status = 0; + sharedContext.statusText = response.statusText; + sharedContext.contentType = 'application/json'; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + it("should call the success handler", function() { + expect(success).not.toHaveBeenCalled(); + }); + + it("should not call the failure handler", function() { + expect(error).toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Failure(sharedContext); + }); + }); + + describe("and the response is error", function() { + beforeEach(function() { + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = { status: 500, statusText: "SERVER ERROR", contentType: "text/html", responseText: "(._){" }; + request.respondWith(response); + + sharedContext.responseCallback = error; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = response.contentType; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + it("should not call the success handler", function() { + expect(success).not.toHaveBeenCalled(); + }); + + it("should call the failure handler", function() { + expect(error).toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + + sharedAjaxResponseBehaviorForZepto_Failure(sharedContext); + }); + + describe('when simulating a response with request.responseTimeout', function() { + beforeEach(function() { + jasmine.clock().install(); + + client = new fakeGlobal.XMLHttpRequest(); + client.onreadystatechange = onreadystatechange; + client.open("GET", "example.com/someApi"); + client.setRequestHeader("Content-Type", "text/plain"); + client.send(); + + request = mockAjax.requests.mostRecent(); + response = { contentType: "text/html", response: "(._){response", responseText: "(._){", responseType: "text" }; + request.responseTimeout(response); + + sharedContext.responseCallback = error; + sharedContext.status = response.status; + sharedContext.statusText = response.statusText; + sharedContext.contentType = response.contentType; + sharedContext.responseText = response.responseText; + sharedContext.responseType = response.responseType; + }); + + afterEach(function() { + jasmine.clock().uninstall(); + }); + + it("should not call the success handler", function() { + expect(success).not.toHaveBeenCalled(); + }); + + it("should call the failure handler", function() { + expect(error).toHaveBeenCalled(); + }); + + it("should call the complete handler", function() { + expect(complete).toHaveBeenCalled(); + }); + }); }); function sharedAjaxResponseBehaviorForZepto_Success(context) { - describe("the success response", function () { - var xhr; - beforeEach(function() { - xhr = context.responseCallback.calls.mostRecent().args[2]; - }); + describe("the success response", function() { + var xhr; + beforeEach(function() { + xhr = context.responseCallback.calls.mostRecent().args[2]; + }); - it("should have the expected status code", function() { - expect(xhr.status).toEqual(context.status); - }); + it("should have the expected status code", function() { + expect(xhr.status).toEqual(context.status); + }); - it("should have the expected content type", function() { - expect(xhr.getResponseHeader('Content-Type')).toEqual(context.contentType); - }); + it("should have the expected content type", function() { + expect(xhr.getResponseHeader('Content-Type')).toEqual(context.contentType); + }); - it("should have the expected xhr2 response", function() { - var expected = context.response || context.responseType === 'json' ? JSON.parse(context.responseText) : context.responseText; - expect(xhr.response).toEqual(expected); - }); + it("should have the expected xhr2 response", function() { + var expected = context.response || context.responseType === 'json' ? JSON.parse(context.responseText) : context.responseText; + expect(xhr.response).toEqual(expected); + }); - it("should have the expected response text", function() { - expect(xhr.responseText).toEqual(context.responseText); - }); + it("should have the expected response text", function() { + expect(xhr.responseText).toEqual(context.responseText); + }); - it("should have the expected status text", function() { - expect(xhr.statusText).toEqual(context.statusText); - }); - }); + it("should have the expected status text", function() { + expect(xhr.statusText).toEqual(context.statusText); + }); + }); } function sharedAjaxResponseBehaviorForZepto_Failure(context) { - describe("the failure response", function () { - var xhr; - beforeEach(function() { - xhr = context.responseCallback.calls.mostRecent().args[0]; - }); + describe("the failure response", function() { + var xhr; + beforeEach(function() { + xhr = context.responseCallback.calls.mostRecent().args[0]; + }); - it("should have the expected status code", function() { - expect(xhr.status).toEqual(context.status); - }); + it("should have the expected status code", function() { + expect(xhr.status).toEqual(context.status); + }); - it("should have the expected content type", function() { - expect(xhr.getResponseHeader('Content-Type')).toEqual(context.contentType); - }); + it("should have the expected content type", function() { + expect(xhr.getResponseHeader('Content-Type')).toEqual(context.contentType); + }); - it("should have the expected xhr2 response", function() { - var expected = context.response || xhr.responseType === 'json' ? JSON.parse(xhr.responseText) : xhr.responseText; - expect(xhr.response).toEqual(expected); - }); + it("should have the expected xhr2 response", function() { + var expected = context.response || xhr.responseType === 'json' ? JSON.parse(xhr.responseText) : xhr.responseText; + expect(xhr.response).toEqual(expected); + }); - it("should have the expected response text", function() { - expect(xhr.responseText).toEqual(context.responseText); - }); + it("should have the expected response text", function() { + expect(xhr.responseText).toEqual(context.responseText); + }); - it("should have the expected status text", function() { - expect(xhr.statusText).toEqual(context.statusText); - }); - }); + it("should have the expected status text", function() { + expect(xhr.statusText).toEqual(context.statusText); + }); + }); } describe('ParamParser', function() { - beforeEach(function() { - var Constructor = getJasmineRequireObj().AjaxParamParser(); - expect(Constructor).toEqual(jasmine.any(Function)); - this.parser = new Constructor(); - }); + beforeEach(function() { + var Constructor = getJasmineRequireObj().AjaxParamParser(); + expect(Constructor).toEqual(jasmine.any(Function)); + this.parser = new Constructor(); + }); - it('has a default parser', function() { - var parser = this.parser.findParser({ contentType: function() {} }), - parsed = parser.parse('3+stooges=shemp&3+stooges=larry%20%26%20moe%20%26%20curly&some%3Dthing=else+entirely'); + it('has a default parser', function() { + var parser = this.parser.findParser({ contentType: function() { } }), + parsed = parser.parse('3+stooges=shemp&3+stooges=larry%20%26%20moe%20%26%20curly&some%3Dthing=else+entirely'); - expect(parsed).toEqual({ - '3 stooges': ['shemp', 'larry & moe & curly'], - 'some=thing': ['else entirely'] - }); - }); + expect(parsed).toEqual({ + '3 stooges': ['shemp', 'larry & moe & curly'], + 'some=thing': ['else entirely'] + }); + }); - it('should detect and parse json', function() { - var data = { - foo: 'bar', - baz: ['q', 'u', 'u', 'x'], - nested: { - object: { - containing: 'stuff' - } - } + it('should detect and parse json', function() { + var data = { + foo: 'bar', + baz: ['q', 'u', 'u', 'x'], + nested: { + object: { + containing: 'stuff' + } + } }, - parser = this.parser.findParser({ contentType: function() { return 'application/json'; } }), - parsed = parser.parse(JSON.stringify(data)); + parser = this.parser.findParser({ contentType: function() { return 'application/json'; } }), + parsed = parser.parse(JSON.stringify(data)); - expect(parsed).toEqual(data); - }); + expect(parsed).toEqual(data); + }); - it('should parse json with further qualifiers on content-type', function() { - var data = { - foo: 'bar', - baz: ['q', 'u', 'u', 'x'], - nested: { - object: { - containing: 'stuff' - } - } + it('should parse json with further qualifiers on content-type', function() { + var data = { + foo: 'bar', + baz: ['q', 'u', 'u', 'x'], + nested: { + object: { + containing: 'stuff' + } + } }, - parser = this.parser.findParser({ contentType: function() { return 'application/json; charset=utf-8'; } }), - parsed = parser.parse(JSON.stringify(data)); + parser = this.parser.findParser({ contentType: function() { return 'application/json; charset=utf-8'; } }), + parsed = parser.parse(JSON.stringify(data)); - expect(parsed).toEqual(data); - }); + expect(parsed).toEqual(data); + }); - it('should have custom parsers take precedence', function() { - var custom = { - test: jasmine.createSpy('test').and.returnValue(true), - parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') - }; + it('should have custom parsers take precedence', function() { + var custom = { + test: jasmine.createSpy('test').and.returnValue(true), + parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') + }; - this.parser.add(custom); + this.parser.add(custom); - var parser = this.parser.findParser({ contentType: function() {} }), - parsed = parser.parse('custom_format'); + var parser = this.parser.findParser({ contentType: function() { } }), + parsed = parser.parse('custom_format'); - expect(parsed).toEqual('parsedFormat'); - expect(custom.test).toHaveBeenCalled(); - expect(custom.parse).toHaveBeenCalledWith('custom_format'); - }); + expect(parsed).toEqual('parsedFormat'); + expect(custom.test).toHaveBeenCalled(); + expect(custom.parse).toHaveBeenCalledWith('custom_format'); + }); - it('should skip custom parsers that do not match', function() { - var custom = { - test: jasmine.createSpy('test').and.returnValue(false), - parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') - }; + it('should skip custom parsers that do not match', function() { + var custom = { + test: jasmine.createSpy('test').and.returnValue(false), + parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') + }; - this.parser.add(custom); + this.parser.add(custom); - var parser = this.parser.findParser({ contentType: function() {} }), - parsed = parser.parse('custom_format'); + var parser = this.parser.findParser({ contentType: function() { } }), + parsed = parser.parse('custom_format'); - expect(parsed).toEqual({ custom_format: [ 'undefined' ] }); - expect(custom.test).toHaveBeenCalled(); - expect(custom.parse).not.toHaveBeenCalled(); - }); + expect(parsed).toEqual({ custom_format: ['undefined'] }); + expect(custom.test).toHaveBeenCalled(); + expect(custom.parse).not.toHaveBeenCalled(); + }); - it('removes custom parsers when reset', function() { - var custom = { - test: jasmine.createSpy('test').and.returnValue(true), - parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') - }; + it('removes custom parsers when reset', function() { + var custom = { + test: jasmine.createSpy('test').and.returnValue(true), + parse: jasmine.createSpy('parse').and.returnValue('parsedFormat') + }; - this.parser.add(custom); + this.parser.add(custom); - var parser = this.parser.findParser({ contentType: function() {} }), - parsed = parser.parse('custom_format'); + var parser = this.parser.findParser({ contentType: function() { } }), + parsed = parser.parse('custom_format'); - expect(parsed).toEqual('parsedFormat'); + expect(parsed).toEqual('parsedFormat'); - custom.test['calls'].reset(); - custom.parse['calls'].reset(); + custom.test['calls'].reset(); + custom.parse['calls'].reset(); - this.parser.reset(); + this.parser.reset(); - parser = this.parser.findParser({ contentType: function() {} }); - parsed = parser.parse('custom_format'); + parser = this.parser.findParser({ contentType: function() { } }); + parsed = parser.parse('custom_format'); - expect(parsed).toEqual({ custom_format: [ 'undefined' ] }); - expect(custom.test).not.toHaveBeenCalled(); - expect(custom.parse).not.toHaveBeenCalled(); - }); + expect(parsed).toEqual({ custom_format: ['undefined'] }); + expect(custom.test).not.toHaveBeenCalled(); + expect(custom.parse).not.toHaveBeenCalled(); + }); }); describe('RequestStub', function() { - beforeEach(function() { - this.RequestStub = getJasmineRequireObj().AjaxRequestStub(); + beforeEach(function() { + this.RequestStub = getJasmineRequireObj().AjaxRequestStub(); - jasmine.addMatchers({ - toMatchRequest: function() { - return { - compare: function(actual) { - return { - pass: actual.matches.apply(actual, Array.prototype.slice.call(arguments, 1)) - }; - } - }; - } - }); - }); + jasmine.addMatchers({ + toMatchRequest: function(a, b) { + return { + compare: function(actual): jasmine.CustomMatcherResult { + return { + message: '', + pass: actual.matches.apply(actual, Array.prototype.slice.call(arguments, 1)) + }; + } + }; + } + }); + }); - it('matches just by exact url', function() { - var stub = new this.RequestStub('www.example.com/foo'); + it('matches just by exact url', function() { + var stub = new this.RequestStub('www.example.com/foo'); - expect(stub)['toMatchRequest']('www.example.com/foo'); - }); + expect(stub)['toMatchRequest']('www.example.com/foo'); + }); - it('does not match if the url differs', function() { - var stub = new this.RequestStub('www.example.com/foo'); + it('does not match if the url differs', function() { + var stub = new this.RequestStub('www.example.com/foo'); - expect(stub).not['toMatchRequest']('www.example.com/bar'); - }); + expect(stub).not['toMatchRequest']('www.example.com/bar'); + }); - it('matches unordered query params', function() { - var stub = new this.RequestStub('www.example.com?foo=bar&baz=quux'); + it('matches unordered query params', function() { + var stub = new this.RequestStub('www.example.com?foo=bar&baz=quux'); - expect(stub)['toMatchRequest']('www.example.com?baz=quux&foo=bar'); - }); + expect(stub)['toMatchRequest']('www.example.com?baz=quux&foo=bar'); + }); - it('requires all specified query params to be there', function() { - var stub = new this.RequestStub('www.example.com?foo=bar&baz=quux'); + it('requires all specified query params to be there', function() { + var stub = new this.RequestStub('www.example.com?foo=bar&baz=quux'); - expect(stub).not['toMatchRequest']('www.example.com?foo=bar'); - }); + expect(stub).not['toMatchRequest']('www.example.com?foo=bar'); + }); - it('can match the url with a RegExp', function() { - var stub = new this.RequestStub(/ba[rz]/); + it('can match the url with a RegExp', function() { + var stub = new this.RequestStub(/ba[rz]/); - expect(stub)['toMatchRequest']('bar'); - expect(stub)['toMatchRequest']('baz'); - expect(stub).not['toMatchRequest']('foo'); - }); + expect(stub)['toMatchRequest']('bar'); + expect(stub)['toMatchRequest']('baz'); + expect(stub).not['toMatchRequest']('foo'); + }); - it('requires the method to match if supplied', function() { - var stub = new this.RequestStub('www.example.com/foo', null, 'POST'); + it('requires the method to match if supplied', function() { + var stub = new this.RequestStub('www.example.com/foo', null, 'POST'); - expect(stub).not['toMatchRequest']('www.example.com/foo'); - expect(stub).not['toMatchRequest']('www.example.com/foo', null, 'GET'); - expect(stub)['toMatchRequest']('www.example.com/foo', null, 'POST'); - }); + expect(stub).not['toMatchRequest']('www.example.com/foo'); + expect(stub).not['toMatchRequest']('www.example.com/foo', null, 'GET'); + expect(stub)['toMatchRequest']('www.example.com/foo', null, 'POST'); + }); - it('requires the data submitted to match if supplied', function() { - var stub = new this.RequestStub('/foo', 'foo=bar&baz=quux'); + it('requires the data submitted to match if supplied', function() { + var stub = new this.RequestStub('/foo', 'foo=bar&baz=quux'); - expect(stub)['toMatchRequest']('/foo', 'baz=quux&foo=bar'); - expect(stub).not['toMatchRequest']('/foo', 'foo=bar'); - }); + expect(stub)['toMatchRequest']('/foo', 'baz=quux&foo=bar'); + expect(stub).not['toMatchRequest']('/foo', 'foo=bar'); + }); }); describe('RequestTracker', function() { - beforeEach(function() { - var Constructor = getJasmineRequireObj().AjaxRequestTracker(); - this.tracker = new Constructor(); - }); + beforeEach(function() { + var Constructor = getJasmineRequireObj().AjaxRequestTracker(); + this.tracker = new Constructor(); + }); - it('tracks the number of times ajax requests are made', function() { - expect(this.tracker.count()).toBe(0); + it('tracks the number of times ajax requests are made', function() { + expect(this.tracker.count()).toBe(0); - this.tracker.track(); + this.tracker.track(); - expect(this.tracker.count()).toBe(1); - }); + expect(this.tracker.count()).toBe(1); + }); - it('simplifies access to the last (most recent) request', function() { - this.tracker.track(); - this.tracker.track('request'); + it('simplifies access to the last (most recent) request', function() { + this.tracker.track(); + this.tracker.track('request'); - expect(this.tracker.mostRecent()).toEqual('request'); - }); + expect(this.tracker.mostRecent()).toEqual('request'); + }); - it('returns a useful falsy value when there is no last (most recent) request', function() { - expect(this.tracker.mostRecent()).toBeFalsy(); - }); + it('returns a useful falsy value when there is no last (most recent) request', function() { + expect(this.tracker.mostRecent()).toBeFalsy(); + }); - it('simplifies access to the first (oldest) request', function() { - this.tracker.track('request'); - this.tracker.track(); + it('simplifies access to the first (oldest) request', function() { + this.tracker.track('request'); + this.tracker.track(); - expect(this.tracker.first()).toEqual('request'); - }); + expect(this.tracker.first()).toEqual('request'); + }); - it('returns a useful falsy value when there is no first (oldest) request', function() { - expect(this.tracker.first()).toBeFalsy(); - }); + it('returns a useful falsy value when there is no first (oldest) request', function() { + expect(this.tracker.first()).toBeFalsy(); + }); - it('allows the requests list to be reset', function() { - this.tracker.track(); - this.tracker.track(); + it('allows the requests list to be reset', function() { + this.tracker.track(); + this.tracker.track(); - expect(this.tracker.count()).toBe(2); + expect(this.tracker.count()).toBe(2); - this.tracker.reset(); + this.tracker.reset(); - expect(this.tracker.count()).toBe(0); - }); + expect(this.tracker.count()).toBe(0); + }); - it('allows retrieval of an arbitrary request by index', function() { - this.tracker.track('1'); - this.tracker.track('2'); - this.tracker.track('3'); + it('allows retrieval of an arbitrary request by index', function() { + this.tracker.track('1'); + this.tracker.track('2'); + this.tracker.track('3'); - expect(this.tracker.at(1)).toEqual('2'); - }); + expect(this.tracker.at(1)).toEqual('2'); + }); - it('allows retrieval of all requests that are for a given url', function() { - this.tracker.track({ url: 'foo' }); - this.tracker.track({ url: 'bar' }); + it('allows retrieval of all requests that are for a given url', function() { + this.tracker.track({ url: 'foo' }); + this.tracker.track({ url: 'bar' }); - expect(this.tracker.filter('bar')).toEqual([{ url: 'bar' }]); - }); + expect(this.tracker.filter('bar')).toEqual([{ url: 'bar' }]); + }); - it('allows retrieval of all requests that match a given RegExp', function() { - this.tracker.track({ url: 'foo' }); - this.tracker.track({ url: 'bar' }); - this.tracker.track({ url: 'baz' }); + it('allows retrieval of all requests that match a given RegExp', function() { + this.tracker.track({ url: 'foo' }); + this.tracker.track({ url: 'bar' }); + this.tracker.track({ url: 'baz' }); - expect(this.tracker.filter(/ba[rz]/)).toEqual([{ url: 'bar' }, { url: 'baz' }]); - }); + expect(this.tracker.filter(/ba[rz]/)).toEqual([{ url: 'bar' }, { url: 'baz' }]); + }); - it('allows retrieval of all requests that match based on a function', function() { - this.tracker.track({ url: 'foo' }); - this.tracker.track({ url: 'bar' }); - this.tracker.track({ url: 'baz' }); + it('allows retrieval of all requests that match based on a function', function() { + this.tracker.track({ url: 'foo' }); + this.tracker.track({ url: 'bar' }); + this.tracker.track({ url: 'baz' }); - var func = function(request) { - return request.url === 'bar'; - }; + var func = function(request) { + return request.url === 'bar'; + }; - expect(this.tracker.filter(func)).toEqual([{ url: 'bar' }]); - }); + expect(this.tracker.filter(func)).toEqual([{ url: 'bar' }]); + }); - it('filters to nothing if no requests have been tracked', function() { - expect(this.tracker.filter('foo')).toEqual([]); - }); + it('filters to nothing if no requests have been tracked', function() { + expect(this.tracker.filter('foo')).toEqual([]); + }); }); describe('EventBus', function() { - beforeEach(function() { - this.bus = getJasmineRequireObj().AjaxEventBus()(); - }); + beforeEach(function() { + this.bus = getJasmineRequireObj().AjaxEventBus()(); + }); - it('calls an event listener', function() { - var callback = jasmine.createSpy('callback'); + it('calls an event listener', function() { + var callback = jasmine.createSpy('callback'); - this.bus.addEventListener('foo', callback); - this.bus.trigger('foo'); + this.bus.addEventListener('foo', callback); + this.bus.trigger('foo'); - expect(callback).toHaveBeenCalled(); - }); + expect(callback).toHaveBeenCalled(); + }); - it('calls an event listener with additional arguments', function() { - var callback = jasmine.createSpy('callback'); + it('calls an event listener with additional arguments', function() { + var callback = jasmine.createSpy('callback'); - this.bus.addEventListener('foo', callback); - this.bus.trigger('foo', 'bar'); + this.bus.addEventListener('foo', callback); + this.bus.trigger('foo', 'bar'); - expect(callback).toHaveBeenCalledWith('bar'); - }); + expect(callback).toHaveBeenCalledWith('bar'); + }); - it('only triggers callbacks for the specified event', function() { - var fooCallback = jasmine.createSpy('foo'), - barCallback = jasmine.createSpy('bar'); + it('only triggers callbacks for the specified event', function() { + var fooCallback = jasmine.createSpy('foo'), + barCallback = jasmine.createSpy('bar'); - this.bus.addEventListener('foo', fooCallback); - this.bus.addEventListener('bar', barCallback); + this.bus.addEventListener('foo', fooCallback); + this.bus.addEventListener('bar', barCallback); - this.bus.trigger('foo'); + this.bus.trigger('foo'); - expect(fooCallback).toHaveBeenCalled(); - expect(barCallback).not.toHaveBeenCalled(); - }); + expect(fooCallback).toHaveBeenCalled(); + expect(barCallback).not.toHaveBeenCalled(); + }); - it('calls all the callbacks for the specified event', function() { - var callback1 = jasmine.createSpy('callback'); - var callback2 = jasmine.createSpy('otherCallback'); + it('calls all the callbacks for the specified event', function() { + var callback1 = jasmine.createSpy('callback'); + var callback2 = jasmine.createSpy('otherCallback'); - this.bus.addEventListener('foo', callback1); - this.bus.addEventListener('foo', callback2); + this.bus.addEventListener('foo', callback1); + this.bus.addEventListener('foo', callback2); - this.bus.trigger('foo'); + this.bus.trigger('foo'); - expect(callback1).toHaveBeenCalled(); - expect(callback2).toHaveBeenCalled(); - }); + expect(callback1).toHaveBeenCalled(); + expect(callback2).toHaveBeenCalled(); + }); - it('works if there are no callbacks for the event', function() { - var bus = this.bus; - expect(function() { - bus.trigger('notActuallyThere'); - }).not.toThrow(); - }); + it('works if there are no callbacks for the event', function() { + var bus = this.bus; + expect(function() { + bus.trigger('notActuallyThere'); + }).not.toThrow(); + }); - it('does not call listeners that have been removed', function() { - var callback = jasmine.createSpy('callback'); + it('does not call listeners that have been removed', function() { + var callback = jasmine.createSpy('callback'); - this.bus.addEventListener('foo', callback); - this.bus.removeEventListener('foo', callback); - this.bus.trigger('foo'); + this.bus.addEventListener('foo', callback); + this.bus.removeEventListener('foo', callback); + this.bus.trigger('foo'); - expect(callback).not.toHaveBeenCalled(); - }); + expect(callback).not.toHaveBeenCalled(); + }); - it('only removes the specified callback', function() { - var callback1 = jasmine.createSpy('callback'); - var callback2 = jasmine.createSpy('otherCallback'); + it('only removes the specified callback', function() { + var callback1 = jasmine.createSpy('callback'); + var callback2 = jasmine.createSpy('otherCallback'); - this.bus.addEventListener('foo', callback1); - this.bus.addEventListener('foo', callback2); - this.bus.removeEventListener('foo', callback2); + this.bus.addEventListener('foo', callback1); + this.bus.addEventListener('foo', callback2); + this.bus.removeEventListener('foo', callback2); - this.bus.trigger('foo'); + this.bus.trigger('foo'); - expect(callback1).toHaveBeenCalled(); - expect(callback2).not.toHaveBeenCalled(); - }); + expect(callback1).toHaveBeenCalled(); + expect(callback2).not.toHaveBeenCalled(); + }); }); describe("Webmock style mocking", function() { - var successSpy, errorSpy, response, fakeGlobal, mockAjax; + var successSpy, errorSpy, response, fakeGlobal, mockAjax; - var sendRequest = function(fakeGlobal, url?, method?) { - url = url || "http://example.com/someApi"; - method = method || 'GET'; - var xhr = new fakeGlobal.XMLHttpRequest(); - xhr.onreadystatechange = function(args) { - if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE - response = this; - successSpy(); - } - }; + var sendRequest = function(fakeGlobal, url?, method?) { + url = url || "http://example.com/someApi"; + method = method || 'GET'; + var xhr = new fakeGlobal.XMLHttpRequest(); + xhr.onreadystatechange = function(args) { + if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE + response = this; + successSpy(); + } + }; - xhr.open(method, url); - xhr.send(); - }; + xhr.open(method, url); + xhr.send(); + }; - beforeEach(function() { - successSpy = jasmine.createSpy('success'); - fakeGlobal = {XMLHttpRequest: jasmine.createSpy('realXMLHttpRequest')}; - mockAjax = new MockAjax(fakeGlobal); - mockAjax.install(); + beforeEach(function() { + successSpy = jasmine.createSpy('success'); + fakeGlobal = { XMLHttpRequest: jasmine.createSpy('realXMLHttpRequest') }; + mockAjax = new MockAjax(fakeGlobal); + mockAjax.install(); - mockAjax.stubRequest("http://example.com/someApi").andReturn({responseText: "hi!"}); - }); + mockAjax.stubRequest("http://example.com/someApi").andReturn({ responseText: "hi!" }); + }); - it("allows a url to be setup as a stub", function() { - sendRequest(fakeGlobal); - expect(successSpy).toHaveBeenCalled(); - }); + it("allows a url to be setup as a stub", function() { + sendRequest(fakeGlobal); + expect(successSpy).toHaveBeenCalled(); + }); - it("should allow you to clear all the ajax stubs", function() { - mockAjax.stubs.reset(); - sendRequest(fakeGlobal); - expect(successSpy).not.toHaveBeenCalled(); - }); + it("should allow you to clear all the ajax stubs", function() { + mockAjax.stubs.reset(); + sendRequest(fakeGlobal); + expect(successSpy).not.toHaveBeenCalled(); + }); - it("should set the contentType", function() { - sendRequest(fakeGlobal); - expect(response.getResponseHeader('Content-Type')).toEqual('application/json'); - }); + it("should set the contentType", function() { + sendRequest(fakeGlobal); + expect(response.getResponseHeader('Content-Type')).toEqual('application/json'); + }); - it("should set the responseText", function() { - sendRequest(fakeGlobal); - expect(response.responseText).toEqual('hi!'); - }); + it("should set the responseText", function() { + sendRequest(fakeGlobal); + expect(response.responseText).toEqual('hi!'); + }); - it("should default the status to 200", function() { - sendRequest(fakeGlobal); - expect(response.status).toEqual(200); - }); + it("should default the status to 200", function() { + sendRequest(fakeGlobal); + expect(response.status).toEqual(200); + }); - it("should set the responseHeaders", function() { - mockAjax.stubRequest("http://example.com/someApi").andReturn({ - responseText: "hi!", - responseHeaders: [{name: "X-Custom", value: "header value"}] - }); - sendRequest(fakeGlobal); - expect(response.getResponseHeader('X-Custom')).toEqual('header value'); - }); + it("should set the responseHeaders", function() { + mockAjax.stubRequest("http://example.com/someApi").andReturn({ + responseText: "hi!", + responseHeaders: [{ name: "X-Custom", value: "header value" }] + }); + sendRequest(fakeGlobal); + expect(response.getResponseHeader('X-Custom')).toEqual('header value'); + }); - describe("with another stub for the same url", function() { - beforeEach(function() { - mockAjax.stubRequest("http://example.com/someApi").andReturn({responseText: "no", status: 403}); - sendRequest(fakeGlobal); - }); + describe("with another stub for the same url", function() { + beforeEach(function() { + mockAjax.stubRequest("http://example.com/someApi").andReturn({ responseText: "no", status: 403 }); + sendRequest(fakeGlobal); + }); - it("should set the status", function() { - expect(response.status).toEqual(403); - }); + it("should set the status", function() { + expect(response.status).toEqual(403); + }); - it("should allow the latest stub to win", function() { - expect(response.responseText).toEqual('no'); - }); - }); + it("should allow the latest stub to win", function() { + expect(response.responseText).toEqual('no'); + }); + }); }); describe("withMock", function() { - var sendRequest = function(fakeGlobal) { - var xhr = new fakeGlobal.XMLHttpRequest(); + var sendRequest = function(fakeGlobal) { + var xhr = new fakeGlobal.XMLHttpRequest(); - xhr.open("GET", "http://example.com/someApi"); - xhr.send(); - }; + xhr.open("GET", "http://example.com/someApi"); + xhr.send(); + }; - it("installs the mock for passed in function, and uninstalls when complete", function() { - var xmlHttpRequest = jasmine.createSpyObj('XMLHttpRequest', ['open', 'send']), - xmlHttpRequestCtor = spyOn(window, 'XMLHttpRequest').and.returnValue(xmlHttpRequest), - fakeGlobal = {XMLHttpRequest: xmlHttpRequestCtor}, - mockAjax = new MockAjax(fakeGlobal); + it("installs the mock for passed in function, and uninstalls when complete", function() { + var xmlHttpRequest = jasmine.createSpyObj('XMLHttpRequest', ['open', 'send']), + xmlHttpRequestCtor = spyOn(window, 'XMLHttpRequest').and.returnValue(xmlHttpRequest), + fakeGlobal = { XMLHttpRequest: xmlHttpRequestCtor }, + mockAjax = new MockAjax(fakeGlobal); - mockAjax.withMock(function() { - sendRequest(fakeGlobal); - expect(xmlHttpRequest.open).not.toHaveBeenCalled(); - }); + mockAjax.withMock(function() { + sendRequest(fakeGlobal); + expect(xmlHttpRequest.open).not.toHaveBeenCalled(); + }); - sendRequest(fakeGlobal); - expect(xmlHttpRequest.open).toHaveBeenCalled(); - }); + sendRequest(fakeGlobal); + expect(xmlHttpRequest.open).toHaveBeenCalled(); + }); - it("properly uninstalls when the passed in function throws", function() { - var xmlHttpRequest = jasmine.createSpyObj('XMLHttpRequest', ['open', 'send']), - xmlHttpRequestCtor = spyOn(window, 'XMLHttpRequest').and.returnValue(xmlHttpRequest), - fakeGlobal = {XMLHttpRequest: xmlHttpRequestCtor}, - mockAjax = new MockAjax(fakeGlobal); + it("properly uninstalls when the passed in function throws", function() { + var xmlHttpRequest = jasmine.createSpyObj('XMLHttpRequest', ['open', 'send']), + xmlHttpRequestCtor = spyOn(window, 'XMLHttpRequest').and.returnValue(xmlHttpRequest), + fakeGlobal = { XMLHttpRequest: xmlHttpRequestCtor }, + mockAjax = new MockAjax(fakeGlobal); - expect(function() { - mockAjax.withMock(function() { - throw "error"; - }); - }).toThrow("error"); + expect(function() { + mockAjax.withMock(function() { + throw "error"; + }); + }).toThrow("error"); - sendRequest(fakeGlobal); - expect(xmlHttpRequest.open).toHaveBeenCalled(); - }); + sendRequest(fakeGlobal); + expect(xmlHttpRequest.open).toHaveBeenCalled(); + }); }); describe("mockAjax", function() { - it("throws an error if installed multiple times", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("throws an error if installed multiple times", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - function doubleInstall() { - mockAjax.install(); - mockAjax.install(); - } + function doubleInstall() { + mockAjax.install(); + mockAjax.install(); + } - expect(doubleInstall).toThrow(); - }); + expect(doubleInstall).toThrow(); + }); - it("does not throw an error if uninstalled between installs", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("does not throw an error if uninstalled between installs", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - function sequentialInstalls() { - mockAjax.install(); - mockAjax.uninstall(); - mockAjax.install(); - } + function sequentialInstalls() { + mockAjax.install(); + mockAjax.uninstall(); + mockAjax.install(); + } - expect(sequentialInstalls).not.toThrow(); - }); + expect(sequentialInstalls).not.toThrow(); + }); - it("does not replace XMLHttpRequest until it is installed", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("does not replace XMLHttpRequest until it is installed", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - fakeGlobal.XMLHttpRequest('foo'); - expect(fakeXmlHttpRequest).toHaveBeenCalledWith('foo'); - fakeXmlHttpRequest.calls.reset(); + fakeGlobal.XMLHttpRequest('foo'); + expect(fakeXmlHttpRequest).toHaveBeenCalledWith('foo'); + fakeXmlHttpRequest.calls.reset(); - mockAjax.install(); - fakeGlobal.XMLHttpRequest('foo'); - expect(fakeXmlHttpRequest).not.toHaveBeenCalled(); - }); + mockAjax.install(); + fakeGlobal.XMLHttpRequest('foo'); + expect(fakeXmlHttpRequest).not.toHaveBeenCalled(); + }); - it("replaces the global XMLHttpRequest on uninstall", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("replaces the global XMLHttpRequest on uninstall", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - mockAjax.install(); - mockAjax.uninstall(); + mockAjax.install(); + mockAjax.uninstall(); - fakeGlobal.XMLHttpRequest('foo'); - expect(fakeXmlHttpRequest).toHaveBeenCalledWith('foo'); - }); + fakeGlobal.XMLHttpRequest('foo'); + expect(fakeXmlHttpRequest).toHaveBeenCalledWith('foo'); + }); - it("clears requests and stubs upon uninstall", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("clears requests and stubs upon uninstall", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - mockAjax.install(); + mockAjax.install(); - mockAjax.requests.track({url: '/testurl'}); - mockAjax.stubRequest('/bobcat'); + mockAjax.requests.track({ url: '/testurl' }); + mockAjax.stubRequest('/bobcat'); - expect(mockAjax.requests.count()).toEqual(1); - expect(mockAjax.stubs.findStub('/bobcat')).toBeDefined(); + expect(mockAjax.requests.count()).toEqual(1); + expect(mockAjax.stubs.findStub('/bobcat')).toBeDefined(); - mockAjax.uninstall(); + mockAjax.uninstall(); - expect(mockAjax.requests.count()).toEqual(0); - expect(mockAjax.stubs.findStub('/bobcat')).not.toBeDefined(); - }); + expect(mockAjax.requests.count()).toEqual(0); + expect(mockAjax.stubs.findStub('/bobcat')).not.toBeDefined(); + }); - it("allows the httpRequest to be retrieved", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("allows the httpRequest to be retrieved", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - mockAjax.install(); - var request = new (fakeGlobal.XMLHttpRequest)(); + mockAjax.install(); + var request = new (fakeGlobal.XMLHttpRequest)(); - expect(mockAjax.requests.count()).toBe(1); - expect(mockAjax.requests.mostRecent()).toBe(request); - }); + expect(mockAjax.requests.count()).toBe(1); + expect(mockAjax.requests.mostRecent()).toBe(request); + }); - it("allows the httpRequests to be cleared", function() { - var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), - fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, - mockAjax = new MockAjax(fakeGlobal); + it("allows the httpRequests to be cleared", function() { + var fakeXmlHttpRequest = jasmine.createSpy('fakeXmlHttpRequest'), + fakeGlobal = { XMLHttpRequest: fakeXmlHttpRequest }, + mockAjax = new MockAjax(fakeGlobal); - mockAjax.install(); - var request = new (fakeGlobal.XMLHttpRequest)(); + mockAjax.install(); + var request = new (fakeGlobal.XMLHttpRequest)(); - expect(mockAjax.requests.mostRecent()).toBe(request); - mockAjax.requests.reset(); - expect(mockAjax.requests.count()).toBe(0); - }); + expect(mockAjax.requests.mostRecent()).toBe(request); + mockAjax.requests.reset(); + expect(mockAjax.requests.count()).toBe(0); + }); }); diff --git a/jasmine-ajax/jasmine-ajax.d.ts b/jasmine-ajax/jasmine-ajax.d.ts index 70ca2f57c..657ec3374 100644 --- a/jasmine-ajax/jasmine-ajax.d.ts +++ b/jasmine-ajax/jasmine-ajax.d.ts @@ -4,17 +4,22 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface JasmineAjaxResponse { - status?: string; + status?: number; statusText?: string; responseText?: string; response?: string; - responseType?: string; contentType?: string; responseHeaders?: { [key: string]: string }; } -interface JasmineAjaxRequest { +interface JasmineAjaxRequest extends XMLHttpRequest { url: string; + method: string; + username: string; + password: string; + requestHeaders: { [key: string]: string }; + overriddenMimeType: string; + respondWith(response: JasmineAjaxResponse): void; } From 16c5267ec4c4611949ce77e381a9b416cb5a3f36 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 May 2015 11:18:08 +0200 Subject: [PATCH 021/397] fixed implicit any --- jasmine-ajax/jasmine-ajax.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jasmine-ajax/jasmine-ajax.d.ts b/jasmine-ajax/jasmine-ajax.d.ts index 657ec3374..d10f67ad4 100644 --- a/jasmine-ajax/jasmine-ajax.d.ts +++ b/jasmine-ajax/jasmine-ajax.d.ts @@ -62,7 +62,7 @@ interface JasmineAjaxParamParser { } declare class MockAjax { - constructor(globals); + constructor(globals: any); install(): void; uninstall(): void; From fcec5c68577433516aaf6ea2dd95bf9264928ada Mon Sep 17 00:00:00 2001 From: jandic Date: Fri, 22 May 2015 15:25:46 +0200 Subject: [PATCH 022/397] Fixed - Parameters made optional Some parameters were mandatory while they were supposed to be optional --- dojo/dojo.d.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index 7b95efdfa..e39db0583 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -4873,7 +4873,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - every(arr: any[], callback: Function, thisObject: Object): boolean; + every(arr: any[], callback: Function, thisObject?: Object): boolean; /** * Determines whether or not every item in arr satisfies the * condition implemented by callback. @@ -4887,7 +4887,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - every(arr: String, callback: Function, thisObject: Object): boolean; + every(arr: String, callback: Function, thisObject?: Object): boolean; /** * Determines whether or not every item in arr satisfies the * condition implemented by callback. @@ -4901,7 +4901,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - every(arr: any[], callback: String, thisObject: Object): boolean; + every(arr: any[], callback: String, thisObject?: Object): boolean; /** * Determines whether or not every item in arr satisfies the * condition implemented by callback. @@ -4915,7 +4915,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - every(arr: String, callback: String, thisObject: Object): boolean; + every(arr: String, callback: String, thisObject?: Object): boolean; /** * Returns a new Array with those items from arr that match the * condition implemented by callback. @@ -4929,7 +4929,7 @@ declare module dojo { * @param callback a function that is invoked with three arguments (item,index, array). The return of this function is expected tobe a boolean which determines whether the passed-in itemwill be included in the returned array. * @param thisObject Optionalmay be used to scope the call to callback */ - filter(arr: any[], callback: Function, thisObject: Object): any[]; + filter(arr: any[], callback: Function, thisObject?: Object): any[]; /** * Returns a new Array with those items from arr that match the * condition implemented by callback. @@ -4943,7 +4943,7 @@ declare module dojo { * @param callback a function that is invoked with three arguments (item,index, array). The return of this function is expected tobe a boolean which determines whether the passed-in itemwill be included in the returned array. * @param thisObject Optionalmay be used to scope the call to callback */ - filter(arr: any[], callback: String, thisObject: Object): any[]; + filter(arr: any[], callback: String, thisObject?: Object): any[]; /** * for every item in arr, callback is invoked. Return values are ignored. * If you want to break out of the loop, consider using array.every() or array.some(). @@ -5020,7 +5020,7 @@ declare module dojo { * @param fromIndex Optional * @param findLast OptionalMakes indexOf() work like lastIndexOf(). Used internally; not meant for external usage. */ - indexOf(arr: any[], value: Object, fromIndex: number, findLast: boolean): number; + indexOf(arr: any[], value: Object, fromIndex?: number, findLast?: boolean): number; /** * locates the last index of the provided value in the passed * array. If the value is not found, -1 is returned. @@ -5036,7 +5036,7 @@ declare module dojo { * @param value * @param fromIndex Optional */ - lastIndexOf(arr: any, value: any, fromIndex: number): number; + lastIndexOf(arr: any, value: any, fromIndex?: number): number; /** * applies callback to each element of arr and returns * an Array with the results @@ -5051,7 +5051,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: any[], callback: Function, thisObject: Object, Ctr: any): any[]; + map(arr: any[], callback: Function, thisObject?: Object, Ctr: any): any[]; /** * applies callback to each element of arr and returns * an Array with the results @@ -5066,7 +5066,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: String, callback: Function, thisObject: Object, Ctr: any): any[]; + map(arr: String, callback: Function, thisObject?: Object, Ctr: any): any[]; /** * applies callback to each element of arr and returns * an Array with the results @@ -5081,7 +5081,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: any[], callback: String, thisObject: Object, Ctr: any): any[]; + map(arr: any[], callback: String, thisObject?: Object, Ctr: any): any[]; /** * applies callback to each element of arr and returns * an Array with the results @@ -5096,7 +5096,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: String, callback: String, thisObject: Object, Ctr: any): any[]; + map(arr: String, callback: String, thisObject?: Object, Ctr: any): any[]; /** * Determines whether or not any item in arr satisfies the * condition implemented by callback. @@ -5110,7 +5110,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - some(arr: any[], callback: Function, thisObject: Object): boolean; + some(arr: any[], callback: Function, thisObject?: Object): boolean; /** * Determines whether or not any item in arr satisfies the * condition implemented by callback. @@ -5124,7 +5124,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - some(arr: String, callback: Function, thisObject: Object): boolean; + some(arr: String, callback: Function, thisObject?: Object): boolean; /** * Determines whether or not any item in arr satisfies the * condition implemented by callback. @@ -5138,7 +5138,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - some(arr: any[], callback: String, thisObject: Object): boolean; + some(arr: any[], callback: String, thisObject?: Object): boolean; /** * Determines whether or not any item in arr satisfies the * condition implemented by callback. @@ -5152,7 +5152,7 @@ declare module dojo { * @param callback a function is invoked with three arguments: item, index,and array and returns true if the condition is met. * @param thisObject Optionalmay be used to scope the call to callback */ - some(arr: String, callback: String, thisObject: Object): boolean; + some(arr: String, callback: String, thisObject?: Object): boolean; } /** * Permalink: http://dojotoolkit.org/api/1.9/dojo/_base/connect.html From 95eac2d4ed66828e43fe10e0bd09515d5f5a62fe Mon Sep 17 00:00:00 2001 From: jandic Date: Fri, 22 May 2015 15:46:23 +0200 Subject: [PATCH 023/397] Fixed compilation issue --- dojo/dojo.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index e39db0583..8ec115654 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -5051,7 +5051,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: any[], callback: Function, thisObject?: Object, Ctr: any): any[]; + map(arr: any[], callback: Function, thisObject: Object, Ctr: any): any[]; /** * applies callback to each element of arr and returns * an Array with the results @@ -5066,7 +5066,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: String, callback: Function, thisObject?: Object, Ctr: any): any[]; + map(arr: String, callback: Function, thisObject: Object, Ctr: any): any[]; /** * applies callback to each element of arr and returns * an Array with the results @@ -5081,7 +5081,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: any[], callback: String, thisObject?: Object, Ctr: any): any[]; + map(arr: any[], callback: String, thisObject: Object, Ctr: any): any[]; /** * applies callback to each element of arr and returns * an Array with the results @@ -5096,7 +5096,7 @@ declare module dojo { * @param thisObject Optionalmay be used to scope the call to callback * @param Ctr */ - map(arr: String, callback: String, thisObject?: Object, Ctr: any): any[]; + map(arr: String, callback: String, thisObject: Object, Ctr: any): any[]; /** * Determines whether or not any item in arr satisfies the * condition implemented by callback. From 0242bb8147de010b2d847175cec9edd9191fa570 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Sun, 24 May 2015 19:39:37 -0300 Subject: [PATCH 024/397] defs + tests from examples --- hashids/hashids-test.ts | 19 +++++++++++++++++++ hashids/hashids.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 hashids/hashids-test.ts create mode 100644 hashids/hashids.d.ts diff --git a/hashids/hashids-test.ts b/hashids/hashids-test.ts new file mode 100644 index 000000000..9e51c8b8a --- /dev/null +++ b/hashids/hashids-test.ts @@ -0,0 +1,19 @@ +/// + +/* require hashids */ +import Hashids = require("hashids"); + +/* creating class object */ +var hashids = new Hashids("this is my salt"); + +/* encoding several numbers into one id */ +var id = hashids.encode(1337, 5, 77, 12345678); +id = hashids.encode(1337); +id = hashids.encode(45, 434, 1313, 99); + +/* decoding that id */ +var numbers = hashids.decode(id); +numbers.length > 0 ? true : false; + +hashids = new Hashids("this is my salt", 0, "abcdefgh123456789"); +hashids = new Hashids("this is my salt", 8); diff --git a/hashids/hashids.d.ts b/hashids/hashids.d.ts new file mode 100644 index 000000000..9a98259b0 --- /dev/null +++ b/hashids/hashids.d.ts @@ -0,0 +1,36 @@ +// Type definitions for Hashids.js 1.x +// Project: https://github.com/ivanakimov/hashids.node.js +// Definitions by: Paulo Cesar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Hashids { + + export interface IHashids { + new(salt: string, minHashLength?: number, alphabet?: string): IHashids; + version: string; + minAlphabetLength: number; + sepDiv: number; + guardDiv: number; + errorAlphabetLength: string; + errorAlphabetSpace: string; + alphabet: string[]; + seps: string; + minHashLength: number; + salt: string; + decode(hash: string): number[]; + encode(arg: number): string; + encode(arg: number[]): string; + encode(...args: number[]): string; + encodeHex(str: string): string; + decodeHex(hash: string): string; + hash(input: number, alphabet: string): string; + unhash(input: string[], alphabet: string): number; + } +} + +declare module 'hashids' { + var hashids: Hashids.IHashids; + export = hashids; +} \ No newline at end of file From f68c7d8664642406b9f79bb182dca39e22da6acc Mon Sep 17 00:00:00 2001 From: Tysonzero Date: Mon, 25 May 2015 00:17:20 -0600 Subject: [PATCH 025/397] Rename inputmask function to mask --- maskedinput/maskedinput-tests.ts | 6 +++--- maskedinput/maskedinput.d.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/maskedinput/maskedinput-tests.ts b/maskedinput/maskedinput-tests.ts index ba9ff33e6..c50387104 100644 --- a/maskedinput/maskedinput-tests.ts +++ b/maskedinput/maskedinput-tests.ts @@ -6,7 +6,7 @@ /// /// -$("#test").inputmask("9:000"); -$("#test").inputmask("9:000", { numeric: true }); +$("#test").mask("9:000"); +$("#test").mask("9:000", { numeric: true }); -var alies = $.inputmask.defaults.aliases; \ No newline at end of file +var alies = $.mask.defaults.aliases; \ No newline at end of file diff --git a/maskedinput/maskedinput.d.ts b/maskedinput/maskedinput.d.ts index 2e918ed66..b099ba326 100644 --- a/maskedinput/maskedinput.d.ts +++ b/maskedinput/maskedinput.d.ts @@ -47,9 +47,9 @@ interface MaskedInputDefaults { } interface JQueryStatic { - inputmask: MaskedInputStatic; + mask: MaskedInputStatic; } interface JQuery { - inputmask(mask: string, options?: JQueryMaskedInputOptions): JQuery; + mask(mask: string, options?: JQueryMaskedInputOptions): JQuery; } \ No newline at end of file From 6a38eeb4bff7b88145b92b188b24a4fa41caeca3 Mon Sep 17 00:00:00 2001 From: Tysonzero Date: Mon, 25 May 2015 00:17:49 -0600 Subject: [PATCH 026/397] Add newlines at end of maskedinput files --- maskedinput/maskedinput-tests.ts | 2 +- maskedinput/maskedinput.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maskedinput/maskedinput-tests.ts b/maskedinput/maskedinput-tests.ts index c50387104..52d01db21 100644 --- a/maskedinput/maskedinput-tests.ts +++ b/maskedinput/maskedinput-tests.ts @@ -9,4 +9,4 @@ $("#test").mask("9:000"); $("#test").mask("9:000", { numeric: true }); -var alies = $.mask.defaults.aliases; \ No newline at end of file +var alies = $.mask.defaults.aliases; diff --git a/maskedinput/maskedinput.d.ts b/maskedinput/maskedinput.d.ts index b099ba326..cf30fe023 100644 --- a/maskedinput/maskedinput.d.ts +++ b/maskedinput/maskedinput.d.ts @@ -52,4 +52,4 @@ interface JQueryStatic { interface JQuery { mask(mask: string, options?: JQueryMaskedInputOptions): JQuery; -} \ No newline at end of file +} From 9f902efd3550bb53e9072ca843881eac2a604e51 Mon Sep 17 00:00:00 2001 From: Sam Albert Date: Tue, 26 May 2015 13:31:01 -0400 Subject: [PATCH 027/397] Added _.get definition to lodash with updated test file. --- lodash/lodash-tests.ts | 2 ++ lodash/lodash.d.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 6a48e20c1..a96b0b6f3 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -922,6 +922,8 @@ result = _.methods(_); result = <_.LoDashArrayWrapper>_(_).functions(); result = <_.LoDashArrayWrapper>_(_).methods(); +result = _.get({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); + result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); interface FirstSecond { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 602b05d31..4b96e01e5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5836,6 +5836,22 @@ declare module _ { methods(): _.LoDashArrayWrapper; } + //_.get + interface LoDashStatic { + /** + * Gets the property value at path of object. If the resolved + * value is undefined the defaultValue is used in its place. + * @param object The object to query. + * @param path The path of the property to get. + * @param defaultValue The value returned if the resolved value is undefined. + * @return Returns the resolved value. + **/ + get(object : Object, + path:string|string[], + defaultValue?:T + ): T; + } + //_.has interface LoDashStatic { /** From 3724099e05645107f2680428d6e0d237790051e8 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Tue, 26 May 2015 16:44:06 -0300 Subject: [PATCH 028/397] test > tests --- hashids/{hashids-test.ts => hashids-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename hashids/{hashids-test.ts => hashids-tests.ts} (100%) diff --git a/hashids/hashids-test.ts b/hashids/hashids-tests.ts similarity index 100% rename from hashids/hashids-test.ts rename to hashids/hashids-tests.ts From e96b92628f8ec90da6aebc58f44445f10e2cb655 Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Tue, 26 May 2015 21:42:24 -0300 Subject: [PATCH 029/397] Initial Commit --- magicsuggest/magicsuggest.d.ts | 463 +++++++++++++++++++++++++++++++++ 1 file changed, 463 insertions(+) create mode 100644 magicsuggest/magicsuggest.d.ts diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts new file mode 100644 index 000000000..4d031c39f --- /dev/null +++ b/magicsuggest/magicsuggest.d.ts @@ -0,0 +1,463 @@ +// Type definitions for MagicSuggest 2.1.4 +// Project: http://nicolasbize.com/magicsuggest +// Definitions by: Leonardo Chaia +// Definitions: http://github.com/leonardochaia + +/// +interface JQuery { + magicSuggest: (configurationObject: MagicSuggest.Configuration) => MagicSuggest.Instance; +} + +declare module MagicSuggest { + interface Configuration { + /********** CONFIGURATION PROPERTIES ************/ + /** + * Restricts or allows the user to validate typed entries. + * Defaults to true. + */ + allowFreeEntries?: boolean; + + /** + * Restricts or allows the user to add the same entry more than once + * Defaults to false. + */ + allowDuplicates?: boolean; + + /** + * Additional config object passed to each $.ajax call + */ + ajaxConfig?: JQueryAjaxSettings; + + /** + * If a single suggestion comes out, it is preselected. + */ + autoSelect?: boolean; + + /** + * Auto select the first matching item with multiple items shown + */ + selectFirst?: boolean; + + /** + * Allow customization of query parameter + */ + queryParam?: string; + + /** + * A function triggered just before the ajax request is sent, similar to jQuery + */ + beforeSend?: () => void; + + /** + * A custom CSS class to apply to the field's underlying element. + */ + cls?: string; + + /** + * JSON Data source used to populate the combo box. 3 options are available here: + * No Data Source (default) + * When left null, the combo box will not suggest anything. It can still enable the user to enter + * multiple entries if allowFreeEntries is * set to true (default). + * Static Source + * You can pass an array of JSON objects, an array of strings or even a single CSV string as the + * data source.For ex. data: [* {id:0,name:"Paris"}, {id: 1, name: "New York"}] + * You can also pass any json object with the results property containing the json array. + * Url + * You can pass the url from which the component will fetch its JSON data.Data will be fetched + * using a POST ajax request that will * include the entered text as 'query' parameter. The results + * fetched from the server can be: + * - an array of JSON objects (ex: [{id:...,name:...},{...}]) + * - a string containing an array of JSON objects ready to be parsed (ex: "[{id:...,name:...},{...}]") + * - a JSON object whose data will be contained in the results property + * (ex: {results: [{id:...,name:...},{...}] + * Function + * You can pass a function which returns an array of JSON objects (ex: [{id:...,name:...},{...}]) + * The function can return the JSON data or it can use the first argument as function to handle the data. + * Only one (callback function or return value) is needed for the function to succeed. + * See the following example: + * function (response) { var myjson = [{name: 'test', id: 1}]; response(myjson); return myjson; } + */ + data?: any; + + /** + * Additional parameters to the ajax call + */ + dataUrlParams?: Object; + + /** + * Start the component in a disabled state. + */ + disabled?: boolean; + + /** + * Name of JSON object property that defines the disabled behaviour + */ + disabledField?: string; + + /** + * Name of JSON object property displayed in the combo list + */ + displayField?: string; + + /** + * Set to false if you only want mouse interaction. In that case the combo will + * automatically expand on focus. + */ + editable?: boolean; + + /** + * Set starting state for combo. + */ + expanded?: boolean; + + /** + * Automatically expands combo on focus. + */ + expandOnFocus?: boolean; + + /** + * JSON property by which the list should be grouped + */ + groupBy?: string; + + /** + * Set to true to hide the trigger on the right + */ + hideTrigger?: boolean; + + /** + * Set to true to highlight search input within displayed suggestions + */ + highlight?: boolean; + + /** + * A custom ID for this component + */ + id?: string; + + /** + * A class that is added to the info message appearing on the top-right part of the component + */ + infoMsgCls?: string; + + /** + * Additional parameters passed out to the INPUT tag. Enables usage of AngularJS's custom tags for ex. + */ + inputCfg?: any; + + /** + * The class that is applied to show that the field is invalid + */ + invalidCls?: string; + + /** + * Set to true to filter data results according to case. Useless if the data is fetched remotely + */ + matchCase?: boolean; + + /** + * Once expanded, the combo's height will take as much room as the # of available results. + * In case there are too many results displayed, this will fix the drop down height. + */ + maxDropHeight?: number; + + /** + * Defines how long the user free entry can be. Set to null for no limit. + */ + maxEntryLength?: number; + + /** + * A function that defines the helper text when the max entry length has been surpassed. + */ + maxEntryRenderer?: (v?: number) => void; + + /** + * The maximum number of results displayed in the combo drop down at once. + */ + maxSuggestions?: number; + + /** + * The maximum number of items the user can select if multiple selection is allowed. + * Set to null to remove the limit. + */ + maxSelection?: number; + + /** + * A function that defines the helper text when the max selection amount has been reached. The function has a single + * parameter which is the number of selected elements. + */ + maxSelectionRenderer?: (v: number) => void; + + /** + * The method used by the ajax request. + */ + method?: string; + + /** + * The minimum number of characters the user must type before the combo expands and offers suggestions. + */ + minChars?: number; + + /** + * A function that defines the helper text when not enough letters are set. The function has a single + * parameter which is the difference between the required amount of letters and the current one. + */ + minCharsRenderer?: (v: number) => void; + + /** + * Whether or not sorting / filtering should be done remotely or locally. + * Use either 'local' or 'remote' + */ + mode?: string; + + /** + * The name used as a form element. + */ + name?: string; + + /** + * The text displayed when there are no suggestions. + */ + noSuggestionText?: string; + + /** + * The default placeholder text when nothing has been entered + */ + placeholder?: string; + + /** + * A function used to define how the items will be presented in the combo + */ + renderer?: (item: any) => void; + + /** + * Whether or not this field should be required + */ + required?: boolean; + + /** + * Set to true to render selection as a delimited string + */ + resultAsString?: boolean; + + /** + * Text delimiter to use in a delimited string. + */ + resultAsStringDelimiter?: string; + + /** + * Name of JSON object property that represents the list of suggested objects + */ + resultsField?: string; + + /** + * A custom CSS class to add to a selected item + */ + selectionCls?: string; + + /** + * An optional element replacement in which the selection is rendered + */ + selectionContainer?: JQuery; + + /** + * Where the selected items will be displayed. Only 'right', 'bottom' and 'inner' are valid values + */ + selectionPosition?: string; + + /** + * A function used to define how the items will be presented in the tag list + */ + selectionRenderer?: (item: any) => void; + + /** + * Set to true to stack the selectioned items when positioned on the bottom + * Requires the selectionPosition to be set to 'bottom' + */ + selectionStacked?: boolean; + + /** + * Direction used for sorting. Only 'asc' and 'desc' are valid values + */ + sortDir?: string; + + /** + * name of JSON object property for local result sorting. + * Leave null if you do not wish the results to be ordered or if they are already ordered remotely. + */ + sortOrder?: string; + + /** + * If set to boolean; suggestions will have to start by user input (and not simply contain it as a substring) + */ + strictSuggest?: boolean; + + /** + * Custom style added to the component container. + */ + style?: string; + + /** + * If set to boolean; the combo will expand / collapse when clicked upon + */ + toggleOnClick?: boolean; + + + /** + * Amount (in ms) between keyboard registers. + */ + typeDelay?: number; + + /** + * If set to boolean; tab won't blur the component but will be registered as the ENTER key + */ + useTabKey?: boolean; + + /** + * If set to boolean; using comma will validate the user's choice + */ + useCommaKey?: boolean; + + + /** + * Determines whether or not the results will be displayed with a zebra table style + */ + useZebraStyle?: boolean; + + /** + * initial value for the field + */ + value?: any; + + /** + * name of JSON object property that represents its underlying value + */ + valueField?: string; + + /** + * regular expression to validate the values against + */ + vregex?: any; + + /** + * type to validate against + */ + vtype?: any; + } + + interface Instance { + /** + * Add one or multiple json items to the current selection + * @param items - json object or array of json objects + * @param isSilent - (optional) set to true to suppress 'selectionchange' event from being triggered + */ + addToSelection(objs: Array, isSilent?: boolean): void; + + /** + * Clears the current selection + * @param isSilent - (optional) set to true to suppress 'selectionchange' event from being triggered + */ + clear(isSilent?: boolean): void; + + /** + * Collapse the drop down part of the combo + */ + collapse(): void; + + /** + * Set the component in a disabled state. + */ + disable(): void; + + /** + * Empties out the combo user text + */ + empty(): void; + + /** + * Set the component in a enable state. + */ + enable(): void; + + /** + * Retrieve component enabled status + * @return {boolean} + */ + isDisabled(): boolean; + + /** + * Checks whether the field is valid or not + * @return {boolean} + */ + isValid(): boolean; + + /** + * Gets the data params for current ajax request + */ + getDataUrlParams(): Object; + + /** + * Gets the name given to the form input + */ + getName(): string; + + /** + * Retrieve an array of selected json objects + * @return {Array} + */ + getSelection(): Array; + + /** + * Retrieve the current text entered by the user + */ + getRawValue(): string; + + /** + * Retrieve an array of selected values + */ + getValue(): Array; + + /** + * Remove one or multiples json items from the current selection + * @param items - json object or array of json objects + * @param isSilent - (optional) set to true to suppress 'selectionchange' event from being triggered + */ + removeFromSelection(items: any, isSilent: boolean): void; + + /** + * Set up some combo data after it has been rendered + * @param data + */ + setData(data: any): void; + + /** + * Get current data + */ + getData(): any; + + /** + * Sets the name for the input field so it can be fetched in the form + * @param name + */ + setName(name: string): void; + + /** + * Sets the current selection with the JSON items provided + * @param items + */ + setSelection(items: Array): void; + + /** + * Sets a value for the combo box. Value must be an array of values with data type matching valueField one. + * @param data + */ + setValue(values: Array): void; + + /** + * Sets data params for subsequent ajax requests + * @param params + */ + setDataUrlParams(params: any): void; + + } +} \ No newline at end of file From 2f6e9b996c5c5005f187d1f0991d7a96b6c84d2b Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Tue, 26 May 2015 21:44:01 -0300 Subject: [PATCH 030/397] Changed definitios url --- magicsuggest/magicsuggest.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts index 4d031c39f..9cb09e3e8 100644 --- a/magicsuggest/magicsuggest.d.ts +++ b/magicsuggest/magicsuggest.d.ts @@ -1,7 +1,7 @@ // Type definitions for MagicSuggest 2.1.4 // Project: http://nicolasbize.com/magicsuggest // Definitions by: Leonardo Chaia -// Definitions: http://github.com/leonardochaia +// Definitions: http://github.com/leonardochaia/DefinitelyTyped /// interface JQuery { @@ -460,4 +460,4 @@ declare module MagicSuggest { setDataUrlParams(params: any): void; } -} \ No newline at end of file +} From 21de100cfeacc11fe002874d6ed824c81ce1c26f Mon Sep 17 00:00:00 2001 From: Sam Albert Date: Tue, 26 May 2015 22:14:56 -0400 Subject: [PATCH 031/397] Updated callback to support indefinite number of buffer params --- node_zeromq/zmq-tests.ts | 2 +- node_zeromq/zmq.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node_zeromq/zmq-tests.ts b/node_zeromq/zmq-tests.ts index 696a98c13..a62d97a6c 100644 --- a/node_zeromq/zmq-tests.ts +++ b/node_zeromq/zmq-tests.ts @@ -19,7 +19,7 @@ function test3() { var sock = zmq.socket('push'); sock.bindSync('tcp://127.0.0.1:3000'); sock.send(['hello', 'world']); - sock.on('message', function (buffer: Buffer) { + sock.on('message', function (buffer1: Buffer, buffer2: Buffer) { // }); } diff --git a/node_zeromq/zmq.d.ts b/node_zeromq/zmq.d.ts index 8d29e0569..3ab2d1f25 100644 --- a/node_zeromq/zmq.d.ts +++ b/node_zeromq/zmq.d.ts @@ -182,7 +182,7 @@ declare module 'zmq' { * @param eventName {string} * @param callback {Function} */ - on(eventName: string, callback: (buffer: Buffer) => void): void; + on(eventName: string, callback: (...buffer: Buffer[]) => void): void; // Socket Options _fd: any; From 7094689c1f419280d40305c6fa9a8474c36ecdba Mon Sep 17 00:00:00 2001 From: Seulgi Kim Date: Wed, 27 May 2015 20:29:52 +0900 Subject: [PATCH 032/397] gulp-istanbul 0.9.0 adds enforceThresholds function. --- gulp-istanbul/gulp-istanbul-0.8.1.d.ts | 51 ++++++++++++++++++++++++++ gulp-istanbul/gulp-istanbul-tests.ts | 13 +++++++ gulp-istanbul/gulp-istanbul.d.ts | 17 ++++++++- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 gulp-istanbul/gulp-istanbul-0.8.1.d.ts diff --git a/gulp-istanbul/gulp-istanbul-0.8.1.d.ts b/gulp-istanbul/gulp-istanbul-0.8.1.d.ts new file mode 100644 index 000000000..3a10dfdba --- /dev/null +++ b/gulp-istanbul/gulp-istanbul-0.8.1.d.ts @@ -0,0 +1,51 @@ +// Type definitions for gulp-istanbul v0.8.1 +// Project: https://github.com/SBoudrias/gulp-istanbul +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-istanbul" { + function GulpIstanbul(opts?: GulpIstanbul.Options): NodeJS.ReadWriteStream; + + module GulpIstanbul { + export function hookRequire(): NodeJS.ReadWriteStream; + export function summarizeCoverage(opts?: {coverageVariable?: string}): Coverage; + export function writeReports(opts?: ReportOptions): NodeJS.ReadWriteStream; + + interface Options { + coverageVariable?: string; + includeUntested?: boolean; + embedSource?: boolean; + preserveComments?: boolean; + noCompact?: boolean; + noAutoWrap?: boolean; + codeGenerationOptions?: Object; + debug?: boolean; + walkDebug?: boolean; + } + + interface Coverage { + lines: CoverageStats; + statements: CoverageStats; + functions: CoverageStats; + branches: CoverageStats; + } + + interface CoverageStats { + total: number; + covered: number; + skipped: number; + pct: number; + } + + interface ReportOptions { + dir?: string; + reporters?: string[]; + reportOpts?: {dir?: string}; + coverageVariable?: string; + } + } + + export = GulpIstanbul; +} diff --git a/gulp-istanbul/gulp-istanbul-tests.ts b/gulp-istanbul/gulp-istanbul-tests.ts index 7f2327d07..0d64b53d0 100644 --- a/gulp-istanbul/gulp-istanbul-tests.ts +++ b/gulp-istanbul/gulp-istanbul-tests.ts @@ -29,4 +29,17 @@ gulp.task('test', function (cb) { .pipe(istanbul.writeReports({reporters: ['text']})) // Creating the reports after tests runned .on('end', cb); }); +}); + +gulp.task('test', function (cb) { + gulp.src(['lib/**/*.js', 'main.js']) + .pipe(istanbul({includeUntested: true})) // Covering files + .pipe(istanbul.hookRequire()) + .on('finish', function () { + gulp.src(['test/*.html']) + .pipe(testFramework()) + .pipe(istanbul.writeReports({reporters: ['text']})) // Creating the reports after tests runned + .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) // + .on('end', cb); + }); }); \ No newline at end of file diff --git a/gulp-istanbul/gulp-istanbul.d.ts b/gulp-istanbul/gulp-istanbul.d.ts index bf7a13bb0..d917d64b1 100644 --- a/gulp-istanbul/gulp-istanbul.d.ts +++ b/gulp-istanbul/gulp-istanbul.d.ts @@ -1,4 +1,4 @@ -// Type definitions for gulp-istanbul +// Type definitions for gulp-istanbul v0.9.0 // Project: https://github.com/SBoudrias/gulp-istanbul // Definitions by: Asana // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,6 +12,7 @@ declare module "gulp-istanbul" { export function hookRequire(): NodeJS.ReadWriteStream; export function summarizeCoverage(opts?: {coverageVariable?: string}): Coverage; export function writeReports(opts?: ReportOptions): NodeJS.ReadWriteStream; + export function enforceThresholds(opts?: ThresholdOptions): NodeJS.ReadWriteStream; interface Options { coverageVariable?: string; @@ -45,7 +46,19 @@ declare module "gulp-istanbul" { reportOpts?: {dir?: string}; coverageVariable?: string; } + + interface ThresholdOptions { + coverageVariable?: string; + thresholds?: { global?: Coverage|number; each?: Coverage|number }; + } + + interface CoverageOptions { + lines?: number; + statements?: number; + functions?: number; + branches?: number; + } } export = GulpIstanbul; -} \ No newline at end of file +} From a5efba8589f59949da9d7f0367cd4bfc53a8269c Mon Sep 17 00:00:00 2001 From: Seulgi Kim Date: Wed, 27 May 2015 20:55:26 +0900 Subject: [PATCH 033/397] Fix username --- mpromise/mpromise.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpromise/mpromise.d.ts b/mpromise/mpromise.d.ts index ba6961362..2a99964c2 100644 --- a/mpromise/mpromise.d.ts +++ b/mpromise/mpromise.d.ts @@ -1,6 +1,6 @@ // Type definitions for mpromise 0.5.4 // Project: https://github.com/aheckmann/mpromise -// Definitions by: Seulgi Kim +// Definitions by: Seulgi Kim // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "mpromise" { From f2603afffaabe8c70b95d77961745c29036fe858 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:00:54 +0100 Subject: [PATCH 034/397] Added static method and wrapped in module. Updated to include static Routie methods. Wrapped types up into a module definition. --- routie/routie.d.ts | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index 9317904d4..d6e4cd281 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -3,15 +3,33 @@ // Definitions by: Adilson // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface Route { - constructor(path: string, name: string): Route; - addHandler(fn: Function): void; - removeHandler(fn: Function): void; - run(params: any): void; - match(path: string, params: any): boolean; - toURL(params: any): string; +declare module routie { + interface Route { + constructor(path: string, name: string): Route; + addHandler(fn: Function): void; + removeHandler(fn: Function): void; + run(params: any): void; + match(path: string, params: any): boolean; + toURL(params: any): string; + } + + interface Routie extends RoutieStatic { + (path: string): void; + (path: string, fn: Function): void; + (routes: { [key: string]: Function }): void; + } + + interface RoutieStatic { + lookup(name: string, fn: Function): string; + remove(path: string, fn: Function): void; + removeAll(): void; + navigate(path: string, options: RouteOptions): void; + noConflict(): Routie; + } + + interface RouteOptions { + silent?: boolean; + } } -declare function routie(path: string): void; -declare function routie(path: string, fn: Function): void; -declare function routie(routes: { [key: string]: Function }): void; \ No newline at end of file +declare var routie: routie.Routie; From 34ef6f1dd3ce8c4ead9c1234ca96f2e582f08160 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:02:08 +0100 Subject: [PATCH 035/397] Added to change log. --- routie/routie.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index d6e4cd281..cd3bb09dc 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -1,6 +1,7 @@ // Type definitions for routie 0.3.2 // Project: https://github.com/jgallen23/routie // Definitions by: Adilson +// Definitions by: kwilson // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module routie { From e2e6bdb50df936afdcfd91e2e1bdcdb28f392a11 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:13:48 +0100 Subject: [PATCH 036/397] Added tests for static functions. --- routie/routie-tests.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/routie/routie-tests.ts b/routie/routie-tests.ts index 323142c7e..12ee397c4 100644 --- a/routie/routie-tests.ts +++ b/routie/routie-tests.ts @@ -54,4 +54,24 @@ routie("users/12312312"); routie("*", function () { }); -routie("anything"); \ No newline at end of file +routie("anything"); + +// STATIC + +// Lookup +var existing = routie.lookup("users/bob", () => { +}); + +// Remove +routie.remove("users/bob", () => { +}); + +// RemoveAll +routie.removeAll(); + +// Navigate +routie.navigate("users/bob"); +routie.navigate("users/bob", { silent: true }); + +// NoConflict +var myRoutie = routie.noConflict(); From 45d69d19cbc7beae195cfeb5d4d6c085b9073545 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:14:21 +0100 Subject: [PATCH 037/397] Fixed missing optional flag for navigate options. --- routie/routie.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index cd3bb09dc..8f32c3d78 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -24,7 +24,7 @@ declare module routie { lookup(name: string, fn: Function): string; remove(path: string, fn: Function): void; removeAll(): void; - navigate(path: string, options: RouteOptions): void; + navigate(path: string, options?: RouteOptions): void; noConflict(): Routie; } From fa7330d6fe18c795891fc8465445662ba5cd9675 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:16:53 +0100 Subject: [PATCH 038/397] Fixed heading error. --- routie/routie.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index 8f32c3d78..79ab2dc8a 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -1,7 +1,6 @@ // Type definitions for routie 0.3.2 // Project: https://github.com/jgallen23/routie // Definitions by: Adilson -// Definitions by: kwilson // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module routie { From 8f7a306a4875d0fb1124e67a84c7ab3eea3f8d09 Mon Sep 17 00:00:00 2001 From: Reto Rezzonico Date: Wed, 27 May 2015 16:28:51 +0200 Subject: [PATCH 039/397] Add definitions for angular-jwt --- angular-jwt/angular-jwt-tests.ts | 17 +++++++++++++++++ angular-jwt/angular-jwt.d.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 angular-jwt/angular-jwt-tests.ts create mode 100644 angular-jwt/angular-jwt.d.ts diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts new file mode 100644 index 000000000..2e7ccbc08 --- /dev/null +++ b/angular-jwt/angular-jwt-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +var app = angular.module("angular-jwt-tests", ["angular-jwt"]); + +var $jwtHelper: angular.jwt.IJwtHelper; + +var expToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8'; +var tokenPayload = $jwtHelper.decodeToken(expToken); +var date = $jwtHelper.getTokenExpirationDate(expToken); +var bool = $jwtHelper.isTokenExpired(expToken); + +var $jwtInterceptor: angular.jwt.IJwtInterceptor; + +$jwtInterceptor.tokenGetter = () => { + return expToken; +} \ No newline at end of file diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts new file mode 100644 index 000000000..ec0e03e16 --- /dev/null +++ b/angular-jwt/angular-jwt.d.ts @@ -0,0 +1,30 @@ +// Type definitions for angular-jwt 0.0.8 +// Project: https://github.com/auth0/angular-jwt +// Definitions by: Reto Rezzonico +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.jwt { + + interface JwtToken { + iss: string; + sub: string; + aud: string; + exp: number; + nbf: number; + iat: number; + jti: string; + unique_name: string; + } + + interface IJwtHelper { + decodeToken(token: string): JwtToken; + getTokenExpirationDate(token: any): Date; + isTokenExpired(token: any, offsetSeconds?: number): boolean; + } + + interface IJwtInterceptor { + tokenGetter(): string; + } +} \ No newline at end of file From 989b586b954819ef65a894634ffb0fa0ca0bb84d Mon Sep 17 00:00:00 2001 From: Reto Rezzonico Date: Wed, 27 May 2015 16:32:52 +0200 Subject: [PATCH 040/397] Linebreaks --- angular-jwt/angular-jwt-tests.ts | 2 +- angular-jwt/angular-jwt.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts index 2e7ccbc08..7f66f2611 100644 --- a/angular-jwt/angular-jwt-tests.ts +++ b/angular-jwt/angular-jwt-tests.ts @@ -14,4 +14,4 @@ var $jwtInterceptor: angular.jwt.IJwtInterceptor; $jwtInterceptor.tokenGetter = () => { return expToken; -} \ No newline at end of file +} diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts index ec0e03e16..55bb3e4f6 100644 --- a/angular-jwt/angular-jwt.d.ts +++ b/angular-jwt/angular-jwt.d.ts @@ -27,4 +27,4 @@ declare module angular.jwt { interface IJwtInterceptor { tokenGetter(): string; } -} \ No newline at end of file +} From 4c024ccc5b6d4258dfec002bc41b8c68de648c01 Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Wed, 27 May 2015 17:57:12 -0300 Subject: [PATCH 041/397] Added tests file. Bugfixes on definitions --- magicsuggest/magicsuggest-tests.ts | 24 ++++++++++++++++++++++++ magicsuggest/magicsuggest.d.ts | 7 +++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 magicsuggest/magicsuggest-tests.ts diff --git a/magicsuggest/magicsuggest-tests.ts b/magicsuggest/magicsuggest-tests.ts new file mode 100644 index 000000000..993f6cde3 --- /dev/null +++ b/magicsuggest/magicsuggest-tests.ts @@ -0,0 +1,24 @@ + +function basicTest() { + $('#magicSuggest').magicSuggest(); +} + +function testWithConfigurationOptions() { + $('#magicSuggest').magicSuggest({ + data: [ + { id: 1, name: "Buenos Aires" }, + { id: 2, name: "New York" }, + { id: 3, name: "Madrid" }, + ], + maxDropHeight: 500, + maxSelection: 2, + expandOnFocus: true, + }); +} + +function testSomeMethods() { + var ms = $('#magicSuggest').magicSuggest(); + ms.addToSelection([{ id: 1, name: "Mexico" }]); + console.info(ms.getSelection()); + ms.disable() +} \ No newline at end of file diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts index 9cb09e3e8..f1ac71a2e 100644 --- a/magicsuggest/magicsuggest.d.ts +++ b/magicsuggest/magicsuggest.d.ts @@ -5,7 +5,10 @@ /// interface JQuery { - magicSuggest: (configurationObject: MagicSuggest.Configuration) => MagicSuggest.Instance; + /** + * Initialize MagicSuggest on this selector + */ + magicSuggest(configurationObject?: MagicSuggest.Configuration): MagicSuggest.Instance; } declare module MagicSuggest { @@ -460,4 +463,4 @@ declare module MagicSuggest { setDataUrlParams(params: any): void; } -} +} \ No newline at end of file From 220ded7238f0cd09b1f456ffb562aa61190335be Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Wed, 27 May 2015 18:02:55 -0300 Subject: [PATCH 042/397] Forgot to add the reference to typings on test file --- magicsuggest/magicsuggest-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/magicsuggest/magicsuggest-tests.ts b/magicsuggest/magicsuggest-tests.ts index 993f6cde3..b41cf9f71 100644 --- a/magicsuggest/magicsuggest-tests.ts +++ b/magicsuggest/magicsuggest-tests.ts @@ -1,4 +1,6 @@ - +/// +/// + function basicTest() { $('#magicSuggest').magicSuggest(); } From dc9c8d2d5f4822cec81f7c4184f6103e3c340eee Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Tue, 26 May 2015 21:42:24 -0300 Subject: [PATCH 043/397] Initial Commit --- magicsuggest/magicsuggest.d.ts | 463 +++++++++++++++++++++++++++++++++ 1 file changed, 463 insertions(+) create mode 100644 magicsuggest/magicsuggest.d.ts diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts new file mode 100644 index 000000000..4d031c39f --- /dev/null +++ b/magicsuggest/magicsuggest.d.ts @@ -0,0 +1,463 @@ +// Type definitions for MagicSuggest 2.1.4 +// Project: http://nicolasbize.com/magicsuggest +// Definitions by: Leonardo Chaia +// Definitions: http://github.com/leonardochaia + +/// +interface JQuery { + magicSuggest: (configurationObject: MagicSuggest.Configuration) => MagicSuggest.Instance; +} + +declare module MagicSuggest { + interface Configuration { + /********** CONFIGURATION PROPERTIES ************/ + /** + * Restricts or allows the user to validate typed entries. + * Defaults to true. + */ + allowFreeEntries?: boolean; + + /** + * Restricts or allows the user to add the same entry more than once + * Defaults to false. + */ + allowDuplicates?: boolean; + + /** + * Additional config object passed to each $.ajax call + */ + ajaxConfig?: JQueryAjaxSettings; + + /** + * If a single suggestion comes out, it is preselected. + */ + autoSelect?: boolean; + + /** + * Auto select the first matching item with multiple items shown + */ + selectFirst?: boolean; + + /** + * Allow customization of query parameter + */ + queryParam?: string; + + /** + * A function triggered just before the ajax request is sent, similar to jQuery + */ + beforeSend?: () => void; + + /** + * A custom CSS class to apply to the field's underlying element. + */ + cls?: string; + + /** + * JSON Data source used to populate the combo box. 3 options are available here: + * No Data Source (default) + * When left null, the combo box will not suggest anything. It can still enable the user to enter + * multiple entries if allowFreeEntries is * set to true (default). + * Static Source + * You can pass an array of JSON objects, an array of strings or even a single CSV string as the + * data source.For ex. data: [* {id:0,name:"Paris"}, {id: 1, name: "New York"}] + * You can also pass any json object with the results property containing the json array. + * Url + * You can pass the url from which the component will fetch its JSON data.Data will be fetched + * using a POST ajax request that will * include the entered text as 'query' parameter. The results + * fetched from the server can be: + * - an array of JSON objects (ex: [{id:...,name:...},{...}]) + * - a string containing an array of JSON objects ready to be parsed (ex: "[{id:...,name:...},{...}]") + * - a JSON object whose data will be contained in the results property + * (ex: {results: [{id:...,name:...},{...}] + * Function + * You can pass a function which returns an array of JSON objects (ex: [{id:...,name:...},{...}]) + * The function can return the JSON data or it can use the first argument as function to handle the data. + * Only one (callback function or return value) is needed for the function to succeed. + * See the following example: + * function (response) { var myjson = [{name: 'test', id: 1}]; response(myjson); return myjson; } + */ + data?: any; + + /** + * Additional parameters to the ajax call + */ + dataUrlParams?: Object; + + /** + * Start the component in a disabled state. + */ + disabled?: boolean; + + /** + * Name of JSON object property that defines the disabled behaviour + */ + disabledField?: string; + + /** + * Name of JSON object property displayed in the combo list + */ + displayField?: string; + + /** + * Set to false if you only want mouse interaction. In that case the combo will + * automatically expand on focus. + */ + editable?: boolean; + + /** + * Set starting state for combo. + */ + expanded?: boolean; + + /** + * Automatically expands combo on focus. + */ + expandOnFocus?: boolean; + + /** + * JSON property by which the list should be grouped + */ + groupBy?: string; + + /** + * Set to true to hide the trigger on the right + */ + hideTrigger?: boolean; + + /** + * Set to true to highlight search input within displayed suggestions + */ + highlight?: boolean; + + /** + * A custom ID for this component + */ + id?: string; + + /** + * A class that is added to the info message appearing on the top-right part of the component + */ + infoMsgCls?: string; + + /** + * Additional parameters passed out to the INPUT tag. Enables usage of AngularJS's custom tags for ex. + */ + inputCfg?: any; + + /** + * The class that is applied to show that the field is invalid + */ + invalidCls?: string; + + /** + * Set to true to filter data results according to case. Useless if the data is fetched remotely + */ + matchCase?: boolean; + + /** + * Once expanded, the combo's height will take as much room as the # of available results. + * In case there are too many results displayed, this will fix the drop down height. + */ + maxDropHeight?: number; + + /** + * Defines how long the user free entry can be. Set to null for no limit. + */ + maxEntryLength?: number; + + /** + * A function that defines the helper text when the max entry length has been surpassed. + */ + maxEntryRenderer?: (v?: number) => void; + + /** + * The maximum number of results displayed in the combo drop down at once. + */ + maxSuggestions?: number; + + /** + * The maximum number of items the user can select if multiple selection is allowed. + * Set to null to remove the limit. + */ + maxSelection?: number; + + /** + * A function that defines the helper text when the max selection amount has been reached. The function has a single + * parameter which is the number of selected elements. + */ + maxSelectionRenderer?: (v: number) => void; + + /** + * The method used by the ajax request. + */ + method?: string; + + /** + * The minimum number of characters the user must type before the combo expands and offers suggestions. + */ + minChars?: number; + + /** + * A function that defines the helper text when not enough letters are set. The function has a single + * parameter which is the difference between the required amount of letters and the current one. + */ + minCharsRenderer?: (v: number) => void; + + /** + * Whether or not sorting / filtering should be done remotely or locally. + * Use either 'local' or 'remote' + */ + mode?: string; + + /** + * The name used as a form element. + */ + name?: string; + + /** + * The text displayed when there are no suggestions. + */ + noSuggestionText?: string; + + /** + * The default placeholder text when nothing has been entered + */ + placeholder?: string; + + /** + * A function used to define how the items will be presented in the combo + */ + renderer?: (item: any) => void; + + /** + * Whether or not this field should be required + */ + required?: boolean; + + /** + * Set to true to render selection as a delimited string + */ + resultAsString?: boolean; + + /** + * Text delimiter to use in a delimited string. + */ + resultAsStringDelimiter?: string; + + /** + * Name of JSON object property that represents the list of suggested objects + */ + resultsField?: string; + + /** + * A custom CSS class to add to a selected item + */ + selectionCls?: string; + + /** + * An optional element replacement in which the selection is rendered + */ + selectionContainer?: JQuery; + + /** + * Where the selected items will be displayed. Only 'right', 'bottom' and 'inner' are valid values + */ + selectionPosition?: string; + + /** + * A function used to define how the items will be presented in the tag list + */ + selectionRenderer?: (item: any) => void; + + /** + * Set to true to stack the selectioned items when positioned on the bottom + * Requires the selectionPosition to be set to 'bottom' + */ + selectionStacked?: boolean; + + /** + * Direction used for sorting. Only 'asc' and 'desc' are valid values + */ + sortDir?: string; + + /** + * name of JSON object property for local result sorting. + * Leave null if you do not wish the results to be ordered or if they are already ordered remotely. + */ + sortOrder?: string; + + /** + * If set to boolean; suggestions will have to start by user input (and not simply contain it as a substring) + */ + strictSuggest?: boolean; + + /** + * Custom style added to the component container. + */ + style?: string; + + /** + * If set to boolean; the combo will expand / collapse when clicked upon + */ + toggleOnClick?: boolean; + + + /** + * Amount (in ms) between keyboard registers. + */ + typeDelay?: number; + + /** + * If set to boolean; tab won't blur the component but will be registered as the ENTER key + */ + useTabKey?: boolean; + + /** + * If set to boolean; using comma will validate the user's choice + */ + useCommaKey?: boolean; + + + /** + * Determines whether or not the results will be displayed with a zebra table style + */ + useZebraStyle?: boolean; + + /** + * initial value for the field + */ + value?: any; + + /** + * name of JSON object property that represents its underlying value + */ + valueField?: string; + + /** + * regular expression to validate the values against + */ + vregex?: any; + + /** + * type to validate against + */ + vtype?: any; + } + + interface Instance { + /** + * Add one or multiple json items to the current selection + * @param items - json object or array of json objects + * @param isSilent - (optional) set to true to suppress 'selectionchange' event from being triggered + */ + addToSelection(objs: Array, isSilent?: boolean): void; + + /** + * Clears the current selection + * @param isSilent - (optional) set to true to suppress 'selectionchange' event from being triggered + */ + clear(isSilent?: boolean): void; + + /** + * Collapse the drop down part of the combo + */ + collapse(): void; + + /** + * Set the component in a disabled state. + */ + disable(): void; + + /** + * Empties out the combo user text + */ + empty(): void; + + /** + * Set the component in a enable state. + */ + enable(): void; + + /** + * Retrieve component enabled status + * @return {boolean} + */ + isDisabled(): boolean; + + /** + * Checks whether the field is valid or not + * @return {boolean} + */ + isValid(): boolean; + + /** + * Gets the data params for current ajax request + */ + getDataUrlParams(): Object; + + /** + * Gets the name given to the form input + */ + getName(): string; + + /** + * Retrieve an array of selected json objects + * @return {Array} + */ + getSelection(): Array; + + /** + * Retrieve the current text entered by the user + */ + getRawValue(): string; + + /** + * Retrieve an array of selected values + */ + getValue(): Array; + + /** + * Remove one or multiples json items from the current selection + * @param items - json object or array of json objects + * @param isSilent - (optional) set to true to suppress 'selectionchange' event from being triggered + */ + removeFromSelection(items: any, isSilent: boolean): void; + + /** + * Set up some combo data after it has been rendered + * @param data + */ + setData(data: any): void; + + /** + * Get current data + */ + getData(): any; + + /** + * Sets the name for the input field so it can be fetched in the form + * @param name + */ + setName(name: string): void; + + /** + * Sets the current selection with the JSON items provided + * @param items + */ + setSelection(items: Array): void; + + /** + * Sets a value for the combo box. Value must be an array of values with data type matching valueField one. + * @param data + */ + setValue(values: Array): void; + + /** + * Sets data params for subsequent ajax requests + * @param params + */ + setDataUrlParams(params: any): void; + + } +} \ No newline at end of file From 68dd8244f14677b3bf8f17dbb50090721c65175d Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Tue, 26 May 2015 21:44:01 -0300 Subject: [PATCH 044/397] Changed definitios url --- magicsuggest/magicsuggest.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts index 4d031c39f..9cb09e3e8 100644 --- a/magicsuggest/magicsuggest.d.ts +++ b/magicsuggest/magicsuggest.d.ts @@ -1,7 +1,7 @@ // Type definitions for MagicSuggest 2.1.4 // Project: http://nicolasbize.com/magicsuggest // Definitions by: Leonardo Chaia -// Definitions: http://github.com/leonardochaia +// Definitions: http://github.com/leonardochaia/DefinitelyTyped /// interface JQuery { @@ -460,4 +460,4 @@ declare module MagicSuggest { setDataUrlParams(params: any): void; } -} \ No newline at end of file +} From 69750463b614f599f4f95496daed88ce8a489610 Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Wed, 27 May 2015 17:57:12 -0300 Subject: [PATCH 045/397] Added tests file. Bugfixes on definitions --- magicsuggest/magicsuggest-tests.ts | 24 ++++++++++++++++++++++++ magicsuggest/magicsuggest.d.ts | 7 +++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 magicsuggest/magicsuggest-tests.ts diff --git a/magicsuggest/magicsuggest-tests.ts b/magicsuggest/magicsuggest-tests.ts new file mode 100644 index 000000000..993f6cde3 --- /dev/null +++ b/magicsuggest/magicsuggest-tests.ts @@ -0,0 +1,24 @@ + +function basicTest() { + $('#magicSuggest').magicSuggest(); +} + +function testWithConfigurationOptions() { + $('#magicSuggest').magicSuggest({ + data: [ + { id: 1, name: "Buenos Aires" }, + { id: 2, name: "New York" }, + { id: 3, name: "Madrid" }, + ], + maxDropHeight: 500, + maxSelection: 2, + expandOnFocus: true, + }); +} + +function testSomeMethods() { + var ms = $('#magicSuggest').magicSuggest(); + ms.addToSelection([{ id: 1, name: "Mexico" }]); + console.info(ms.getSelection()); + ms.disable() +} \ No newline at end of file diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts index 9cb09e3e8..f1ac71a2e 100644 --- a/magicsuggest/magicsuggest.d.ts +++ b/magicsuggest/magicsuggest.d.ts @@ -5,7 +5,10 @@ /// interface JQuery { - magicSuggest: (configurationObject: MagicSuggest.Configuration) => MagicSuggest.Instance; + /** + * Initialize MagicSuggest on this selector + */ + magicSuggest(configurationObject?: MagicSuggest.Configuration): MagicSuggest.Instance; } declare module MagicSuggest { @@ -460,4 +463,4 @@ declare module MagicSuggest { setDataUrlParams(params: any): void; } -} +} \ No newline at end of file From 99d72aacf41a3b2bc6c48a3da50940989a3c5563 Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Wed, 27 May 2015 18:02:55 -0300 Subject: [PATCH 046/397] Forgot to add the reference to typings on test file --- magicsuggest/magicsuggest-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/magicsuggest/magicsuggest-tests.ts b/magicsuggest/magicsuggest-tests.ts index 993f6cde3..b41cf9f71 100644 --- a/magicsuggest/magicsuggest-tests.ts +++ b/magicsuggest/magicsuggest-tests.ts @@ -1,4 +1,6 @@ - +/// +/// + function basicTest() { $('#magicSuggest').magicSuggest(); } From 0f894228dfd3ad45b843dbf2fd445e4da04e8e55 Mon Sep 17 00:00:00 2001 From: Dmitry Radkovskiy Date: Thu, 28 May 2015 00:43:38 +0300 Subject: [PATCH 047/397] Moved declarations to moment-node.d.ts --- moment/moment-node.d.ts | 482 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 482 insertions(+) create mode 100644 moment/moment-node.d.ts diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts new file mode 100644 index 000000000..13f1b9362 --- /dev/null +++ b/moment/moment-node.d.ts @@ -0,0 +1,482 @@ +// Type definitions for Moment.js 2.8.0 +// Project: https://github.com/timrwood/moment +// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module moment { + + interface MomentInput { + + years?: number; + y?: number; + + months?: number; + M?: number; + + weeks?: number; + w?: number; + + days?: number; + d?: number; + + hours?: number; + h?: number; + + minutes?: number; + m?: number; + + seconds?: number; + s?: number; + + milliseconds?: number; + ms?: number; + + } + + interface Duration { + + humanize(withSuffix?: boolean): string; + + as(units: string): number; + + milliseconds(): number; + asMilliseconds(): number; + + seconds(): number; + asSeconds(): number; + + minutes(): number; + asMinutes(): number; + + hours(): number; + asHours(): number; + + days(): number; + asDays(): number; + + months(): number; + asMonths(): number; + + years(): number; + asYears(): number; + + add(n: number, p: string): Duration; + add(n: number): Duration; + add(d: Duration): Duration; + + subtract(n: number, p: string): Duration; + subtract(n: number): Duration; + subtract(d: Duration): Duration; + + toISOString(): string; + + } + + interface Moment { + + format(format: string): string; + format(): string; + + fromNow(withoutSuffix?: boolean): string; + + startOf(unitOfTime: string): Moment; + endOf(unitOfTime: string): Moment; + + /** + * Mutates the original moment by adding time. (deprecated in 2.8.0) + * + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + * @param amount the amount you want to add + */ + add(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by adding time. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + */ + add(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. Note that the order of arguments can be flipped. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + */ + add(amount: string, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. + * + * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} + */ + add(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by adding time. + * + * @param duration a length of time + */ + add(duration: Duration): Moment; + + /** + * Mutates the original moment by subtracting time. (deprecated in 2.8.0) + * + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + * @param amount the amount you want to subtract + */ + subtract(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + * @param amount the amount you want to subtract + */ + subtract(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + */ + subtract(amount: string, unitOfTime: string): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} + */ + subtract(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param duration a length of time + */ + subtract(duration: Duration): Moment; + + calendar(): string; + calendar(start: Moment): string; + + clone(): Moment; + + /** + * @return Unix timestamp, or milliseconds since the epoch. + */ + valueOf(): number; + + local(): Moment; // current date/time in local mode + + utc(): Moment; // current date/time in UTC mode + + isValid(): boolean; + + year(y: number): Moment; + year(): number; + quarter(): number; + quarter(q: number): Moment; + month(M: number): Moment; + month(M: string): Moment; + month(): number; + day(d: number): Moment; + day(d: string): Moment; + day(): number; + date(d: number): Moment; + date(): number; + hour(h: number): Moment; + hour(): number; + hours(h: number): Moment; + hours(): number; + minute(m: number): Moment; + minute(): number; + minutes(m: number): Moment; + minutes(): number; + second(s: number): Moment; + second(): number; + seconds(s: number): Moment; + seconds(): number; + millisecond(ms: number): Moment; + millisecond(): number; + milliseconds(ms: number): Moment; + milliseconds(): number; + weekday(): number; + weekday(d: number): Moment; + isoWeekday(): number; + isoWeekday(d: number): Moment; + weekYear(): number; + weekYear(d: number): Moment; + isoWeekYear(): number; + isoWeekYear(d: number): Moment; + week(): number; + week(d: number): Moment; + weeks(): number; + weeks(d: number): Moment; + isoWeek(): number; + isoWeek(d: number): Moment; + isoWeeks(): number; + isoWeeks(d: number): Moment; + weeksInYear(): number; + isoWeeksInYear(): number; + dayOfYear(): number; + dayOfYear(d: number): Moment; + + from(f: Moment): string; + from(f: Moment, suffix: boolean): string; + from(d: Date): string; + from(s: string): string; + from(date: number[]): string; + + diff(b: Moment): number; + diff(b: Moment, unitOfTime: string): number; + diff(b: Moment, unitOfTime: string, round: boolean): number; + + toArray(): number[]; + toDate(): Date; + toISOString(): string; + toJSON(): string; + unix(): number; + + isLeapYear(): boolean; + zone(): number; + zone(b: number): Moment; + zone(b: string): Moment; + utcOffset(): number; + utcOffset(b: number): Moment; + utcOffset(b: string): Moment; + daysInMonth(): number; + isDST(): boolean; + + isBefore(): boolean; + isBefore(b: Moment): boolean; + isBefore(b: string): boolean; + isBefore(b: Number): boolean; + isBefore(b: Date): boolean; + isBefore(b: number[]): boolean; + isBefore(b: Moment, granularity: string): boolean; + isBefore(b: String, granularity: string): boolean; + isBefore(b: Number, granularity: string): boolean; + isBefore(b: Date, granularity: string): boolean; + isBefore(b: number[], granularity: string): boolean; + + isAfter(): boolean; + isAfter(b: Moment): boolean; + isAfter(b: string): boolean; + isAfter(b: Number): boolean; + isAfter(b: Date): boolean; + isAfter(b: number[]): boolean; + isAfter(b: Moment, granularity: string): boolean; + isAfter(b: String, granularity: string): boolean; + isAfter(b: Number, granularity: string): boolean; + isAfter(b: Date, granularity: string): boolean; + isAfter(b: number[], granularity: string): boolean; + + isSame(b: Moment): boolean; + isSame(b: string): boolean; + isSame(b: Number): boolean; + isSame(b: Date): boolean; + isSame(b: number[]): boolean; + isSame(b: Moment, granularity: string): boolean; + isSame(b: String, granularity: string): boolean; + isSame(b: Number, granularity: string): boolean; + isSame(b: Date, granularity: string): boolean; + isSame(b: number[], granularity: string): boolean; + + // Deprecated as of 2.8.0. + lang(language: string): Moment; + lang(reset: boolean): Moment; + lang(): MomentLanguage; + + locale(language: string): Moment; + locale(reset: boolean): Moment; + locale(): string; + + localeData(language: string): Moment; + localeData(reset: boolean): Moment; + localeData(): MomentLanguage; + + // Deprecated as of 2.7.0. + max(date: Date): Moment; + max(date: number): Moment; + max(date: any[]): Moment; + max(date: string): Moment; + max(date: string, format: string): Moment; + max(clone: Moment): Moment; + + // Deprecated as of 2.7.0. + min(date: Date): Moment; + min(date: number): Moment; + min(date: any[]): Moment; + min(date: string): Moment; + min(date: string, format: string): Moment; + min(clone: Moment): Moment; + + get(unit: string): number; + set(unit: string, value: number): Moment; + + } + + interface MomentCalendar { + + lastDay: any; + sameDay: any; + nextDay: any; + lastWeek: any; + nextWeek: any; + sameElse: any; + + } + + interface BaseMomentLanguage { + months ?: any; + monthsShort ?: any; + weekdays ?: any; + weekdaysShort ?: any; + weekdaysMin ?: any; + relativeTime ?: MomentRelativeTime; + meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; + calendar ?: MomentCalendar; + ordinal ?: (num: number) => string; + } + + interface MomentLanguage extends BaseMomentLanguage { + longDateFormat?: MomentLongDateFormat; + } + + interface MomentLanguageData extends BaseMomentLanguage { + /** + * @param formatType should be L, LL, LLL, LLLL. + */ + longDateFormat(formatType: string): string; + } + + interface MomentLongDateFormat { + + L: string; + LL: string; + LLL: string; + LLLL: string; + LT: string; + l?: string; + ll?: string; + lll?: string; + llll?: string; + lt?: string; + + } + + interface MomentRelativeTime { + + future: any; + past: any; + s: any; + m: any; + mm: any; + h: any; + hh: any; + d: any; + dd: any; + M: any; + MM: any; + y: any; + yy: any; + + } + + interface MomentStatic { + + version: string; + + (): Moment; + (date: number): Moment; + (date: number[]): Moment; + (date: string, format?: string, strict?: boolean): Moment; + (date: string, format?: string, language?: string, strict?: boolean): Moment; + (date: string, formats: string[], strict?: boolean): Moment; + (date: string, formats: string[], language?: string, strict?: boolean): Moment; + (date: string, specialFormat: () => void, strict?: boolean): Moment; + (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; + (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; + (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; + (date: Date): Moment; + (date: Moment): Moment; + (date: Object): Moment; + + utc(): Moment; + utc(date: number): Moment; + utc(date: number[]): Moment; + utc(date: string, format?: string, strict?: boolean): Moment; + utc(date: string, format?: string, language?: string, strict?: boolean): Moment; + utc(date: string, formats: string[], strict?: boolean): Moment; + utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; + utc(date: Date): Moment; + utc(date: Moment): Moment; + utc(date: Object): Moment; + + unix(timestamp: number): Moment; + + invalid(parsingFlags?: Object): Moment; + isMoment(): boolean; + isMoment(m: any): boolean; + isDuration(): boolean; + isDuration(d: any): boolean; + + // Deprecated in 2.8.0. + lang(language?: string): string; + lang(language?: string, definition?: MomentLanguage): string; + + locale(language?: string): string; + locale(language?: string[]): string; + locale(language?: string, definition?: MomentLanguage): string; + + localeData(language?: string): MomentLanguageData; + + longDateFormat: any; + relativeTime: any; + meridiem: (hour: number, minute: number, isLowercase: boolean) => string; + calendar: any; + ordinal: (num: number) => string; + + duration(milliseconds: Number): Duration; + duration(num: Number, unitOfTime: string): Duration; + duration(input: MomentInput): Duration; + duration(object: any): Duration; + duration(): Duration; + + parseZone(date: string): Moment; + + months(): string[]; + months(index: number): string; + months(format: string): string[]; + months(format: string, index: number): string; + monthsShort(): string[]; + monthsShort(index: number): string; + monthsShort(format: string): string[]; + monthsShort(format: string, index: number): string; + + weekdays(): string[]; + weekdays(index: number): string; + weekdays(format: string): string[]; + weekdays(format: string, index: number): string; + weekdaysShort(): string[]; + weekdaysShort(index: number): string; + weekdaysShort(format: string): string[]; + weekdaysShort(format: string, index: number): string; + weekdaysMin(): string[]; + weekdaysMin(index: number): string; + weekdaysMin(format: string): string[]; + weekdaysMin(format: string, index: number): string; + + min(moments: Moment[]): Moment; + max(moments: Moment[]): Moment; + + normalizeUnits(unit: string): string; + relativeTimeThreshold(threshold: string, limit: number): void; + + /** + * Constant used to enable explicit ISO_8601 format parsing. + */ + ISO_8601(): void; + + } + +} + +declare module 'moment' { + var moment: moment.MomentStatic; + export = moment; +} From a1575b96ec38e916750629839d2110cb96210f89 Mon Sep 17 00:00:00 2001 From: Dmitry Radkovskiy Date: Thu, 28 May 2015 00:46:21 +0300 Subject: [PATCH 048/397] Modified moment.d.ts to use moment-node.d.ts --- moment/moment.d.ts | 477 +-------------------------------------------- 1 file changed, 1 insertion(+), 476 deletions(-) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index e09aab1d5..736956e5d 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -3,481 +3,6 @@ // Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module moment { - - interface MomentInput { - - years?: number; - y?: number; - - months?: number; - M?: number; - - weeks?: number; - w?: number; - - days?: number; - d?: number; - - hours?: number; - h?: number; - - minutes?: number; - m?: number; - - seconds?: number; - s?: number; - - milliseconds?: number; - ms?: number; - - } - - interface Duration { - - humanize(withSuffix?: boolean): string; - - as(units: string): number; - - milliseconds(): number; - asMilliseconds(): number; - - seconds(): number; - asSeconds(): number; - - minutes(): number; - asMinutes(): number; - - hours(): number; - asHours(): number; - - days(): number; - asDays(): number; - - months(): number; - asMonths(): number; - - years(): number; - asYears(): number; - - add(n: number, p: string): Duration; - add(n: number): Duration; - add(d: Duration): Duration; - - subtract(n: number, p: string): Duration; - subtract(n: number): Duration; - subtract(d: Duration): Duration; - - toISOString(): string; - - } - - interface Moment { - - format(format: string): string; - format(): string; - - fromNow(withoutSuffix?: boolean): string; - - startOf(unitOfTime: string): Moment; - endOf(unitOfTime: string): Moment; - - /** - * Mutates the original moment by adding time. (deprecated in 2.8.0) - * - * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) - * @param amount the amount you want to add - */ - add(unitOfTime: string, amount: number): Moment; - /** - * Mutates the original moment by adding time. - * - * @param amount the amount you want to add - * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) - */ - add(amount: number, unitOfTime: string): Moment; - /** - * Mutates the original moment by adding time. Note that the order of arguments can be flipped. - * - * @param amount the amount you want to add - * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) - */ - add(amount: string, unitOfTime: string): Moment; - /** - * Mutates the original moment by adding time. - * - * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} - */ - add(objectLiteral: MomentInput): Moment; - /** - * Mutates the original moment by adding time. - * - * @param duration a length of time - */ - add(duration: Duration): Moment; - - /** - * Mutates the original moment by subtracting time. (deprecated in 2.8.0) - * - * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) - * @param amount the amount you want to subtract - */ - subtract(unitOfTime: string, amount: number): Moment; - /** - * Mutates the original moment by subtracting time. - * - * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) - * @param amount the amount you want to subtract - */ - subtract(amount: number, unitOfTime: string): Moment; - /** - * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. - * - * @param amount the amount you want to add - * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) - */ - subtract(amount: string, unitOfTime: string): Moment; - /** - * Mutates the original moment by subtracting time. - * - * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} - */ - subtract(objectLiteral: MomentInput): Moment; - /** - * Mutates the original moment by subtracting time. - * - * @param duration a length of time - */ - subtract(duration: Duration): Moment; - - calendar(): string; - calendar(start: Moment): string; - - clone(): Moment; - - /** - * @return Unix timestamp, or milliseconds since the epoch. - */ - valueOf(): number; - - local(): Moment; // current date/time in local mode - - utc(): Moment; // current date/time in UTC mode - - isValid(): boolean; - - year(y: number): Moment; - year(): number; - quarter(): number; - quarter(q: number): Moment; - month(M: number): Moment; - month(M: string): Moment; - month(): number; - day(d: number): Moment; - day(d: string): Moment; - day(): number; - date(d: number): Moment; - date(): number; - hour(h: number): Moment; - hour(): number; - hours(h: number): Moment; - hours(): number; - minute(m: number): Moment; - minute(): number; - minutes(m: number): Moment; - minutes(): number; - second(s: number): Moment; - second(): number; - seconds(s: number): Moment; - seconds(): number; - millisecond(ms: number): Moment; - millisecond(): number; - milliseconds(ms: number): Moment; - milliseconds(): number; - weekday(): number; - weekday(d: number): Moment; - isoWeekday(): number; - isoWeekday(d: number): Moment; - weekYear(): number; - weekYear(d: number): Moment; - isoWeekYear(): number; - isoWeekYear(d: number): Moment; - week(): number; - week(d: number): Moment; - weeks(): number; - weeks(d: number): Moment; - isoWeek(): number; - isoWeek(d: number): Moment; - isoWeeks(): number; - isoWeeks(d: number): Moment; - weeksInYear(): number; - isoWeeksInYear(): number; - dayOfYear(): number; - dayOfYear(d: number): Moment; - - from(f: Moment): string; - from(f: Moment, suffix: boolean): string; - from(d: Date): string; - from(s: string): string; - from(date: number[]): string; - - diff(b: Moment): number; - diff(b: Moment, unitOfTime: string): number; - diff(b: Moment, unitOfTime: string, round: boolean): number; - - toArray(): number[]; - toDate(): Date; - toISOString(): string; - toJSON(): string; - unix(): number; - - isLeapYear(): boolean; - zone(): number; - zone(b: number): Moment; - zone(b: string): Moment; - utcOffset(): number; - utcOffset(b: number): Moment; - utcOffset(b: string): Moment; - daysInMonth(): number; - isDST(): boolean; - - isBefore(): boolean; - isBefore(b: Moment): boolean; - isBefore(b: string): boolean; - isBefore(b: Number): boolean; - isBefore(b: Date): boolean; - isBefore(b: number[]): boolean; - isBefore(b: Moment, granularity: string): boolean; - isBefore(b: String, granularity: string): boolean; - isBefore(b: Number, granularity: string): boolean; - isBefore(b: Date, granularity: string): boolean; - isBefore(b: number[], granularity: string): boolean; - - isAfter(): boolean; - isAfter(b: Moment): boolean; - isAfter(b: string): boolean; - isAfter(b: Number): boolean; - isAfter(b: Date): boolean; - isAfter(b: number[]): boolean; - isAfter(b: Moment, granularity: string): boolean; - isAfter(b: String, granularity: string): boolean; - isAfter(b: Number, granularity: string): boolean; - isAfter(b: Date, granularity: string): boolean; - isAfter(b: number[], granularity: string): boolean; - - isSame(b: Moment): boolean; - isSame(b: string): boolean; - isSame(b: Number): boolean; - isSame(b: Date): boolean; - isSame(b: number[]): boolean; - isSame(b: Moment, granularity: string): boolean; - isSame(b: String, granularity: string): boolean; - isSame(b: Number, granularity: string): boolean; - isSame(b: Date, granularity: string): boolean; - isSame(b: number[], granularity: string): boolean; - - // Deprecated as of 2.8.0. - lang(language: string): Moment; - lang(reset: boolean): Moment; - lang(): MomentLanguage; - - locale(language: string): Moment; - locale(reset: boolean): Moment; - locale(): string; - - localeData(language: string): Moment; - localeData(reset: boolean): Moment; - localeData(): MomentLanguage; - - // Deprecated as of 2.7.0. - max(date: Date): Moment; - max(date: number): Moment; - max(date: any[]): Moment; - max(date: string): Moment; - max(date: string, format: string): Moment; - max(clone: Moment): Moment; - - // Deprecated as of 2.7.0. - min(date: Date): Moment; - min(date: number): Moment; - min(date: any[]): Moment; - min(date: string): Moment; - min(date: string, format: string): Moment; - min(clone: Moment): Moment; - - get(unit: string): number; - set(unit: string, value: number): Moment; - - } - - interface MomentCalendar { - - lastDay: any; - sameDay: any; - nextDay: any; - lastWeek: any; - nextWeek: any; - sameElse: any; - - } - - interface BaseMomentLanguage { - months ?: any; - monthsShort ?: any; - weekdays ?: any; - weekdaysShort ?: any; - weekdaysMin ?: any; - relativeTime ?: MomentRelativeTime; - meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; - calendar ?: MomentCalendar; - ordinal ?: (num: number) => string; - } - - interface MomentLanguage extends BaseMomentLanguage { - longDateFormat?: MomentLongDateFormat; - } - - interface MomentLanguageData extends BaseMomentLanguage { - /** - * @param formatType should be L, LL, LLL, LLLL. - */ - longDateFormat(formatType: string): string; - } - - interface MomentLongDateFormat { - - L: string; - LL: string; - LLL: string; - LLLL: string; - LT: string; - l?: string; - ll?: string; - lll?: string; - llll?: string; - lt?: string; - - } - - interface MomentRelativeTime { - - future: any; - past: any; - s: any; - m: any; - mm: any; - h: any; - hh: any; - d: any; - dd: any; - M: any; - MM: any; - y: any; - yy: any; - - } - - interface MomentStatic { - - version: string; - - (): Moment; - (date: number): Moment; - (date: number[]): Moment; - (date: string, format?: string, strict?: boolean): Moment; - (date: string, format?: string, language?: string, strict?: boolean): Moment; - (date: string, formats: string[], strict?: boolean): Moment; - (date: string, formats: string[], language?: string, strict?: boolean): Moment; - (date: string, specialFormat: () => void, strict?: boolean): Moment; - (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; - (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; - (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; - (date: Date): Moment; - (date: Moment): Moment; - (date: Object): Moment; - - utc(): Moment; - utc(date: number): Moment; - utc(date: number[]): Moment; - utc(date: string, format?: string, strict?: boolean): Moment; - utc(date: string, format?: string, language?: string, strict?: boolean): Moment; - utc(date: string, formats: string[], strict?: boolean): Moment; - utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; - utc(date: Date): Moment; - utc(date: Moment): Moment; - utc(date: Object): Moment; - - unix(timestamp: number): Moment; - - invalid(parsingFlags?: Object): Moment; - isMoment(): boolean; - isMoment(m: any): boolean; - isDuration(): boolean; - isDuration(d: any): boolean; - - // Deprecated in 2.8.0. - lang(language?: string): string; - lang(language?: string, definition?: MomentLanguage): string; - - locale(language?: string): string; - locale(language?: string[]): string; - locale(language?: string, definition?: MomentLanguage): string; - - localeData(language?: string): MomentLanguageData; - - longDateFormat: any; - relativeTime: any; - meridiem: (hour: number, minute: number, isLowercase: boolean) => string; - calendar: any; - ordinal: (num: number) => string; - - duration(milliseconds: Number): Duration; - duration(num: Number, unitOfTime: string): Duration; - duration(input: MomentInput): Duration; - duration(object: any): Duration; - duration(): Duration; - - parseZone(date: string): Moment; - - months(): string[]; - months(index: number): string; - months(format: string): string[]; - months(format: string, index: number): string; - monthsShort(): string[]; - monthsShort(index: number): string; - monthsShort(format: string): string[]; - monthsShort(format: string, index: number): string; - - weekdays(): string[]; - weekdays(index: number): string; - weekdays(format: string): string[]; - weekdays(format: string, index: number): string; - weekdaysShort(): string[]; - weekdaysShort(index: number): string; - weekdaysShort(format: string): string[]; - weekdaysShort(format: string, index: number): string; - weekdaysMin(): string[]; - weekdaysMin(index: number): string; - weekdaysMin(format: string): string[]; - weekdaysMin(format: string, index: number): string; - - min(moments: Moment[]): Moment; - max(moments: Moment[]): Moment; - - normalizeUnits(unit: string): string; - relativeTimeThreshold(threshold: string, limit: number): void; - - /** - * Constant used to enable explicit ISO_8601 format parsing. - */ - ISO_8601(): void; - - } - -} +/// declare var moment: moment.MomentStatic; - -declare module 'moment' { - export = moment; -} From 4e99d96891661b1d8885e2748b812b7d1ea19dbb Mon Sep 17 00:00:00 2001 From: LCHProducciones Date: Wed, 27 May 2015 19:43:27 -0300 Subject: [PATCH 049/397] Bugfixes on definitions --- magicsuggest/magicsuggest.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/magicsuggest/magicsuggest.d.ts b/magicsuggest/magicsuggest.d.ts index f1ac71a2e..660a58c5c 100644 --- a/magicsuggest/magicsuggest.d.ts +++ b/magicsuggest/magicsuggest.d.ts @@ -447,8 +447,9 @@ declare module MagicSuggest { /** * Sets the current selection with the JSON items provided * @param items + * @param isSilent - (optional) */ - setSelection(items: Array): void; + setSelection(items: Array, isSilet?: boolean): void; /** * Sets a value for the combo box. Value must be an array of values with data type matching valueField one. From 3ca8ceb795a971e425d8a9873de74a509aec9d43 Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Wed, 27 May 2015 18:28:29 -0700 Subject: [PATCH 050/397] [react] Make var addons into a module This lets you do import aliasing (eg. `import TestUtils = React.addons.TestUtils;`) --- react/react-addons-global.d.ts | 172 +++++++++++++++++---------------- react/react-addons-tests.ts | 10 +- react/react-addons.d.ts | 172 +++++++++++++++++---------------- 3 files changed, 188 insertions(+), 166 deletions(-) diff --git a/react/react-addons-global.d.ts b/react/react-addons-global.d.ts index bccd3f427..cda3edcc8 100644 --- a/react/react-addons-global.d.ts +++ b/react/react-addons-global.d.ts @@ -9,33 +9,39 @@ declare module React { // React.addons // ---------------------------------------------------------------------- - export var addons: { - CSSTransitionGroup: CSSTransitionGroup; - LinkedStateMixin: LinkedStateMixin; - PureRenderMixin: PureRenderMixin; - TransitionGroup: TransitionGroup; + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; - batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; - batchedUpdates(callback: (a: A) => any, a: A): void; - batchedUpdates(callback: () => any): void; + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; // deprecated: use petehunt/react-classset or JedWatson/classnames - classSet(cx: { [key: string]: boolean }): string; - classSet(...classList: string[]): string; + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; - cloneWithProps

(element: DOMElement

, props: P): DOMElement

; - cloneWithProps

(element: ClassicElement

, props: P): ClassicElement

; - cloneWithProps

(element: ReactElement

, props: P): ReactElement

; + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; - createFragment(object: { [key: string]: ReactNode }): ReactFragment; + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; - update(value: any[], spec: UpdateArraySpec): any[]; - update(value: {}, spec: UpdateSpec): any; + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; // Development tools - Perf: ReactPerf; - TestUtils: ReactTestUtils; - }; + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } // // React.addons (Transitions) @@ -114,14 +120,14 @@ declare module React { totalTime: number; } - interface ReactPerf { - start(): void; - stop(): void; - printInclusive(measurements: Measurements[]): void; - printExclusive(measurements: Measurements[]): void; - printWasted(measurements: Measurements[]): void; - printDOM(measurements: Measurements[]): void; - getLastMeasurements(): Measurements[]; + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; } // @@ -132,55 +138,59 @@ declare module React { new(): any; } - interface ReactTestUtils { - Simulate: Simulate; + module ReactTestUtils { + export import Simulate = ReactSimulate; - renderIntoDocument

(element: ReactElement

): Component; - renderIntoDocument>(element: ReactElement): C; + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; - mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - isElementOfType(element: ReactElement, type: ReactType): boolean; - isTextComponent(instance: Component): boolean; - isDOMComponent(instance: Component): boolean; - isCompositeComponent(instance: Component): boolean; - isCompositeComponentWithType( + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( instance: Component, type: ComponentClass): boolean; - findAllInRenderedTree( + export function findAllInRenderedTree( tree: Component, fn: (i: Component) => boolean): Component; - scryRenderedDOMComponentsWithClass( + export function scryRenderedDOMComponentsWithClass( tree: Component, className: string): DOMComponent[]; - findRenderedDOMComponentWithClass( + export function findRenderedDOMComponentWithClass( tree: Component, className: string): DOMComponent; - scryRenderedDOMComponentsWithTag( + export function scryRenderedDOMComponentsWithTag( tree: Component, tagName: string): DOMComponent[]; - findRenderedDOMComponentWithTag( + export function findRenderedDOMComponentWithTag( tree: Component, tagName: string): DOMComponent; - scryRenderedComponentsWithType

( + export function scryRenderedComponentsWithType

( tree: Component, type: ComponentClass

): Component[]; - scryRenderedComponentsWithType>( + export function scryRenderedComponentsWithType>( tree: Component, type: ComponentClass): C[]; - findRenderedComponentWithType

( + export function findRenderedComponentWithType

( tree: Component, type: ComponentClass

): Component; - findRenderedComponentWithType>( + export function findRenderedComponentWithType>( tree: Component, type: ComponentClass): C; - createRenderer(): ShallowRenderer; + export function createRenderer(): ShallowRenderer; } interface SyntheticEventData { @@ -222,40 +232,40 @@ declare module React { (component: Component, eventData?: SyntheticEventData): void; } - interface Simulate { - blur: EventSimulator; - change: EventSimulator; - click: EventSimulator; - cut: EventSimulator; - doubleClick: EventSimulator; - drag: EventSimulator; - dragEnd: EventSimulator; - dragEnter: EventSimulator; - dragExit: EventSimulator; - dragLeave: EventSimulator; - dragOver: EventSimulator; - dragStart: EventSimulator; - drop: EventSimulator; - focus: EventSimulator; - input: EventSimulator; - keyDown: EventSimulator; - keyPress: EventSimulator; - keyUp: EventSimulator; - mouseDown: EventSimulator; - mouseEnter: EventSimulator; - mouseLeave: EventSimulator; - mouseMove: EventSimulator; - mouseOut: EventSimulator; - mouseOver: EventSimulator; - mouseUp: EventSimulator; - paste: EventSimulator; - scroll: EventSimulator; - submit: EventSimulator; - touchCancel: EventSimulator; - touchEnd: EventSimulator; - touchMove: EventSimulator; - touchStart: EventSimulator; - wheel: EventSimulator; + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; } class ShallowRenderer { diff --git a/react/react-addons-tests.ts b/react/react-addons-tests.ts index 72d6db486..f67072c5f 100644 --- a/react/react-addons-tests.ts +++ b/react/react-addons-tests.ts @@ -1,6 +1,8 @@ /// import React = require("react/addons"); +import TestUtils = React.addons.TestUtils; + interface Props extends React.Props { hello: string; world?: string; @@ -397,12 +399,12 @@ React.createFactory(React.addons.CSSTransitionGroup)({ // -------------------------------------------------------------------------- var node: Element; -React.addons.TestUtils.Simulate.click(node); -React.addons.TestUtils.Simulate.change(node); -React.addons.TestUtils.Simulate.keyDown(node, { key: "Enter" }); +TestUtils.Simulate.click(node); +TestUtils.Simulate.change(node); +TestUtils.Simulate.keyDown(node, { key: "Enter" }); var renderer: React.ShallowRenderer = - React.addons.TestUtils.createRenderer(); + TestUtils.createRenderer(); renderer.render(React.createElement(Timer)); var output: Timer = renderer.getRenderOutput(); diff --git a/react/react-addons.d.ts b/react/react-addons.d.ts index c4e768f27..4ddf17152 100644 --- a/react/react-addons.d.ts +++ b/react/react-addons.d.ts @@ -744,33 +744,39 @@ declare module "react/addons" { // React.addons // ---------------------------------------------------------------------- - export var addons: { - CSSTransitionGroup: CSSTransitionGroup; - LinkedStateMixin: LinkedStateMixin; - PureRenderMixin: PureRenderMixin; - TransitionGroup: TransitionGroup; + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; - batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; - batchedUpdates(callback: (a: A) => any, a: A): void; - batchedUpdates(callback: () => any): void; + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; // deprecated: use petehunt/react-classset or JedWatson/classnames - classSet(cx: { [key: string]: boolean }): string; - classSet(...classList: string[]): string; + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; - cloneWithProps

(element: DOMElement

, props: P): DOMElement

; - cloneWithProps

(element: ClassicElement

, props: P): ClassicElement

; - cloneWithProps

(element: ReactElement

, props: P): ReactElement

; + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; - createFragment(object: { [key: string]: ReactNode }): ReactFragment; + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; - update(value: any[], spec: UpdateArraySpec): any[]; - update(value: {}, spec: UpdateSpec): any; + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; // Development tools - Perf: ReactPerf; - TestUtils: ReactTestUtils; - }; + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } // // React.addons (Transitions) @@ -849,14 +855,14 @@ declare module "react/addons" { totalTime: number; } - interface ReactPerf { - start(): void; - stop(): void; - printInclusive(measurements: Measurements[]): void; - printExclusive(measurements: Measurements[]): void; - printWasted(measurements: Measurements[]): void; - printDOM(measurements: Measurements[]): void; - getLastMeasurements(): Measurements[]; + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; } // @@ -867,55 +873,59 @@ declare module "react/addons" { new(): any; } - interface ReactTestUtils { - Simulate: Simulate; + module ReactTestUtils { + export import Simulate = ReactSimulate; - renderIntoDocument

(element: ReactElement

): Component; - renderIntoDocument>(element: ReactElement): C; + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; - mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - isElementOfType(element: ReactElement, type: ReactType): boolean; - isTextComponent(instance: Component): boolean; - isDOMComponent(instance: Component): boolean; - isCompositeComponent(instance: Component): boolean; - isCompositeComponentWithType( + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( instance: Component, type: ComponentClass): boolean; - findAllInRenderedTree( + export function findAllInRenderedTree( tree: Component, fn: (i: Component) => boolean): Component; - scryRenderedDOMComponentsWithClass( + export function scryRenderedDOMComponentsWithClass( tree: Component, className: string): DOMComponent[]; - findRenderedDOMComponentWithClass( + export function findRenderedDOMComponentWithClass( tree: Component, className: string): DOMComponent; - scryRenderedDOMComponentsWithTag( + export function scryRenderedDOMComponentsWithTag( tree: Component, tagName: string): DOMComponent[]; - findRenderedDOMComponentWithTag( + export function findRenderedDOMComponentWithTag( tree: Component, tagName: string): DOMComponent; - scryRenderedComponentsWithType

( + export function scryRenderedComponentsWithType

( tree: Component, type: ComponentClass

): Component[]; - scryRenderedComponentsWithType>( + export function scryRenderedComponentsWithType>( tree: Component, type: ComponentClass): C[]; - findRenderedComponentWithType

( + export function findRenderedComponentWithType

( tree: Component, type: ComponentClass

): Component; - findRenderedComponentWithType>( + export function findRenderedComponentWithType>( tree: Component, type: ComponentClass): C; - createRenderer(): ShallowRenderer; + export function createRenderer(): ShallowRenderer; } interface SyntheticEventData { @@ -957,40 +967,40 @@ declare module "react/addons" { (component: Component, eventData?: SyntheticEventData): void; } - interface Simulate { - blur: EventSimulator; - change: EventSimulator; - click: EventSimulator; - cut: EventSimulator; - doubleClick: EventSimulator; - drag: EventSimulator; - dragEnd: EventSimulator; - dragEnter: EventSimulator; - dragExit: EventSimulator; - dragLeave: EventSimulator; - dragOver: EventSimulator; - dragStart: EventSimulator; - drop: EventSimulator; - focus: EventSimulator; - input: EventSimulator; - keyDown: EventSimulator; - keyPress: EventSimulator; - keyUp: EventSimulator; - mouseDown: EventSimulator; - mouseEnter: EventSimulator; - mouseLeave: EventSimulator; - mouseMove: EventSimulator; - mouseOut: EventSimulator; - mouseOver: EventSimulator; - mouseUp: EventSimulator; - paste: EventSimulator; - scroll: EventSimulator; - submit: EventSimulator; - touchCancel: EventSimulator; - touchEnd: EventSimulator; - touchMove: EventSimulator; - touchStart: EventSimulator; - wheel: EventSimulator; + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; } class ShallowRenderer { From 23b92b854f13406ad47da99ecdcc4855f7e2cc28 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 28 May 2015 15:36:30 +0200 Subject: [PATCH 051/397] Type definitions for urlsafe-base64 v1.0.0 --- urlsafe-base64/urlsafe-base64-tests.ts | 9 +++++ urlsafe-base64/urlsafe-base64.d.ts | 50 ++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 urlsafe-base64/urlsafe-base64-tests.ts create mode 100644 urlsafe-base64/urlsafe-base64.d.ts diff --git a/urlsafe-base64/urlsafe-base64-tests.ts b/urlsafe-base64/urlsafe-base64-tests.ts new file mode 100644 index 000000000..2c7d4722f --- /dev/null +++ b/urlsafe-base64/urlsafe-base64-tests.ts @@ -0,0 +1,9 @@ +/// + +import URLSafeBase64 = require('urlsafe-base64'); + +var base64 = URLSafeBase64.encode(new Buffer('3Rpbmd1aXNoZWQ', 'base64')); + +var buf = URLSafeBase64.decode('3Rpbmd1aXNoZWQ'); + +var isValid = URLSafeBase64.validate('3Rpbmd1aXNoZWQ'); diff --git a/urlsafe-base64/urlsafe-base64.d.ts b/urlsafe-base64/urlsafe-base64.d.ts new file mode 100644 index 000000000..c9c6ed0b9 --- /dev/null +++ b/urlsafe-base64/urlsafe-base64.d.ts @@ -0,0 +1,50 @@ +// Type definitions for urlsafe-base64 v1.0.0 +// Project: https://github.com/RGBboy/urlsafe-base64 +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'urlsafe-base64' { + /** + * Library version. + */ + export var version: string; + + /** + * .encode + * + * return an encoded Buffer as URL Safe Base64 + * + * Note: This function encodes to the RFC 4648 Spec where '+' is encoded + * as '-' and '/' is encoded as '_'. The padding character '=' is + * removed. + * + * @param {Buffer} buffer + * @return {String} + * @api public + */ + export function encode(buffer: Buffer): string; + + /** + * .decode + * + * return an decoded URL Safe Base64 as Buffer + * + * @param {String} + * @return {Buffer} + * @api public + */ + export function decode(base64: string): Buffer; + + /** + * .validate + * + * Validates a string if it is URL Safe Base64 encoded. + * + * @param {String} + * @return {Boolean} + * @api public + */ + export function validate(base64: string): boolean; +} From f7ceda504602664f36d5a7bf303068dc45d5e824 Mon Sep 17 00:00:00 2001 From: Vadim Macagon Date: Thu, 28 May 2015 22:37:24 +0700 Subject: [PATCH 052/397] Add PrettyStream constructor with options, and some doc comments --- bunyan-prettystream/bunyan-prettystream.d.ts | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bunyan-prettystream/bunyan-prettystream.d.ts b/bunyan-prettystream/bunyan-prettystream.d.ts index 9f9fa4f57..12e399ea3 100644 --- a/bunyan-prettystream/bunyan-prettystream.d.ts +++ b/bunyan-prettystream/bunyan-prettystream.d.ts @@ -1,6 +1,6 @@ -// Type definitions for bunyan-prettystream +// Type definitions for bunyan-prettystream 0.1.3 // Project: https://www.npmjs.com/package/bunyan-prettystream -// Definitions by: Jason Swearingen +// Definitions by: Jason Swearingen , Vadim Macagon // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -8,7 +8,23 @@ declare module "bunyan-prettystream" { import stream = require("stream"); class PrettyStream extends stream.Writable { - public pipe(destination: T, options?: { end?: boolean; }): T; + /** + * @param options.mode Output format, can be either `long`, `short`, or `dev`, + * defaults to `long`. + * @param options.useColor Indicates whether or not output should be colored, + * defaults to `true`. + */ + constructor(options?: { mode?: string; useColor?: boolean }); + + /** + * Pipes data from this stream to another. + * + * @param destination Stream to write data to. + * @param options.end Indicates whether `end()` should be called on the `destination` + * stream when this stream emits `end`, defaults to `true`. + * @return The `destination` stream. + */ + pipe(destination: T, options?: { end?: boolean; }): T; } export = PrettyStream; } \ No newline at end of file From 9920fd383c8a426d91eaae34ed33ab23046d8ae5 Mon Sep 17 00:00:00 2001 From: LeandroDG Date: Thu, 28 May 2015 13:25:04 -0300 Subject: [PATCH 053/397] Adding basic authentication support Added property "auth" to options class and method "request.auth" to provide basic authentication --- request/request.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/request/request.d.ts b/request/request.d.ts index eff35ada6..e94a04ad1 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -62,6 +62,7 @@ declare module 'request' { callback?: (error: any, response: any, body: any) => void; jar?: any; // CookieJar form?: any; // Object or string + auth?: AuthOptions; oauth?: OAuthOptions; aws?: AWSOptions; hawk ?: HawkOptions; @@ -107,6 +108,7 @@ declare module 'request' { multipart(multipart: RequestPart[]): Request; json(val: any): Request; aws(opts: AWSOptions, now?: boolean): Request; + auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; oauth(oauth: OAuthOptions): Request; jar(jar: CookieJar): Request; From 292104d982d25965eefa0411ce0e1118323b4dc7 Mon Sep 17 00:00:00 2001 From: LeandroDG Date: Thu, 28 May 2015 18:13:44 -0300 Subject: [PATCH 054/397] Changed response type to http.IncomingMessage --- request/request.d.ts | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/request/request.d.ts b/request/request.d.ts index e94a04ad1..e16eafadb 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -15,40 +15,40 @@ declare module 'request' { export = RequestAPI; - function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: any, body: any) => void): RequestAPI.Request; - function RequestAPI(uri: string, callback?: (error: any, response: any, body: any) => void): RequestAPI.Request; - function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: any, body: any) => void): RequestAPI.Request; + function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; + function RequestAPI(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; + function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; module RequestAPI { export function defaults(options: Options): typeof RequestAPI; - export function request(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function request(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function request(options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function request(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function request(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function request(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function get(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function get(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function post(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function post(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function put(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function put(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function head(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function head(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function patch(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function patch(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; - export function del(uri: string, callback?: (error: any, response: any, body: any) => void): Request; - export function del(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + export function del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; export function forever(agentOptions: any, optionsArg: any): Request; export function jar(): CookieJar; @@ -59,7 +59,7 @@ declare module 'request' { export interface Options { url?: string; uri?: string; - callback?: (error: any, response: any, body: any) => void; + callback?: (error: any, response: http.IncomingMessage, body: any) => void; jar?: any; // CookieJar form?: any; // Object or string auth?: AuthOptions; From bb793321c6797c8b94da0da2517b8bb5a4af09c3 Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Thu, 28 May 2015 14:18:58 -0700 Subject: [PATCH 055/397] [React] change ShallowRenderer output to ReactElement --- react/react-addons-global.d.ts | 3 ++- react/react-addons-tests.ts | 4 ++-- react/react-addons.d.ts | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/react/react-addons-global.d.ts b/react/react-addons-global.d.ts index cda3edcc8..508ae0522 100644 --- a/react/react-addons-global.d.ts +++ b/react/react-addons-global.d.ts @@ -269,7 +269,8 @@ declare module React { } class ShallowRenderer { - getRenderOutput>(): C; + getRenderOutput>(): E; + getRenderOutput(): ReactElement; render(element: ReactElement, context?: any): void; unmount(): void; } diff --git a/react/react-addons-tests.ts b/react/react-addons-tests.ts index f67072c5f..b07b7fd58 100644 --- a/react/react-addons-tests.ts +++ b/react/react-addons-tests.ts @@ -406,5 +406,5 @@ TestUtils.Simulate.keyDown(node, { key: "Enter" }); var renderer: React.ShallowRenderer = TestUtils.createRenderer(); renderer.render(React.createElement(Timer)); -var output: Timer = renderer.getRenderOutput(); - +var output: React.ReactElement> = + renderer.getRenderOutput(); diff --git a/react/react-addons.d.ts b/react/react-addons.d.ts index 4ddf17152..40693cb80 100644 --- a/react/react-addons.d.ts +++ b/react/react-addons.d.ts @@ -1004,7 +1004,8 @@ declare module "react/addons" { } class ShallowRenderer { - getRenderOutput>(): C; + getRenderOutput>(): E; + getRenderOutput(): ReactElement; render(element: ReactElement, context?: any): void; unmount(): void; } From 4c7693c94dcb63654c8e1fe643f232300767eff7 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Thu, 28 May 2015 14:50:38 -0700 Subject: [PATCH 056/397] Fixed MDPalette definition. --- angular-material/angular-material.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 06c1ecf25..1517c295f 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -150,8 +150,8 @@ declare module angular.material { A400?: string; A700?: string; contrastDefaultColor?: string; - contrastDarkColors?: string; - contrastStrongLightColors?: string; + contrastDarkColors?: string[]; + contrastLightColors?: string[]; } interface MDThemeHues { From 1cc5ea01d8986ba5793072de8c63822947298ce2 Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Thu, 28 May 2015 15:30:16 -0700 Subject: [PATCH 057/397] [React] Update HTMLAttributes interface removes `scrollLeft`, `scrollTop` (0.12.0) adds `formAction`, `formEncType`, `formMethod`, `formTarget`, `marginHeight`, `marginWidth` (0.12.2) adds `scoped`, `high`, `low`, `optimum`, `unselectable` (0.13.2) --- react/react-addons.d.ts | 14 ++++++++++++-- react/react-global.d.ts | 14 ++++++++++++-- react/react.d.ts | 14 ++++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/react/react-addons.d.ts b/react/react-addons.d.ts index 40693cb80..37cde636d 100644 --- a/react/react-addons.d.ts +++ b/react/react-addons.d.ts @@ -435,10 +435,16 @@ declare module "react/addons" { draggable?: boolean; encType?: string; form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; formNoValidate?: boolean; + formTarget?: string; frameBorder?: number | string; + headers?: string; height?: number | string; hidden?: boolean; + high?: number; href?: string; hrefLang?: string; htmlFor?: string; @@ -449,7 +455,10 @@ declare module "react/addons" { lang?: string; list?: string; loop?: boolean; + low?: number; manifest?: string; + marginHeight?: number; + marginWidth?: number; max?: number | string; maxLength?: number; media?: string; @@ -461,6 +470,7 @@ declare module "react/addons" { name?: string; noValidate?: boolean; open?: boolean; + optimum?: number; pattern?: string; placeholder?: string; poster?: string; @@ -474,9 +484,8 @@ declare module "react/addons" { rowSpan?: number; sandbox?: string; scope?: string; - scrollLeft?: number; + scoped?: boolean; scrolling?: string; - scrollTop?: number; seamless?: boolean; selected?: boolean; shape?: string; @@ -506,6 +515,7 @@ declare module "react/addons" { itemProp?: string; itemScope?: boolean; itemType?: string; + unselectable?: boolean; } interface SVGAttributes extends DOMAttributes { diff --git a/react/react-global.d.ts b/react/react-global.d.ts index c3fa9fc7c..5a4893862 100644 --- a/react/react-global.d.ts +++ b/react/react-global.d.ts @@ -435,10 +435,16 @@ declare module React { draggable?: boolean; encType?: string; form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; formNoValidate?: boolean; + formTarget?: string; frameBorder?: number | string; + headers?: string; height?: number | string; hidden?: boolean; + high?: number; href?: string; hrefLang?: string; htmlFor?: string; @@ -449,7 +455,10 @@ declare module React { lang?: string; list?: string; loop?: boolean; + low?: number; manifest?: string; + marginHeight?: number; + marginWidth?: number; max?: number | string; maxLength?: number; media?: string; @@ -461,6 +470,7 @@ declare module React { name?: string; noValidate?: boolean; open?: boolean; + optimum?: number; pattern?: string; placeholder?: string; poster?: string; @@ -474,9 +484,8 @@ declare module React { rowSpan?: number; sandbox?: string; scope?: string; - scrollLeft?: number; + scoped?: boolean; scrolling?: string; - scrollTop?: number; seamless?: boolean; selected?: boolean; shape?: string; @@ -506,6 +515,7 @@ declare module React { itemProp?: string; itemScope?: boolean; itemType?: string; + unselectable?: boolean; } interface SVGAttributes extends DOMAttributes { diff --git a/react/react.d.ts b/react/react.d.ts index d92279305..0b202f20e 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -435,10 +435,16 @@ declare module "react" { draggable?: boolean; encType?: string; form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; formNoValidate?: boolean; + formTarget?: string; frameBorder?: number | string; + headers?: string; height?: number | string; hidden?: boolean; + high?: number; href?: string; hrefLang?: string; htmlFor?: string; @@ -449,7 +455,10 @@ declare module "react" { lang?: string; list?: string; loop?: boolean; + low?: number; manifest?: string; + marginHeight?: number; + marginWidth?: number; max?: number | string; maxLength?: number; media?: string; @@ -461,6 +470,7 @@ declare module "react" { name?: string; noValidate?: boolean; open?: boolean; + optimum?: number; pattern?: string; placeholder?: string; poster?: string; @@ -474,9 +484,8 @@ declare module "react" { rowSpan?: number; sandbox?: string; scope?: string; - scrollLeft?: number; + scoped?: boolean; scrolling?: string; - scrollTop?: number; seamless?: boolean; selected?: boolean; shape?: string; @@ -506,6 +515,7 @@ declare module "react" { itemProp?: string; itemScope?: boolean; itemType?: string; + unselectable?: boolean; } interface SVGAttributes extends DOMAttributes { From 7b47d0c9776b0dc18ce2b0d6f5e406692309019a Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Thu, 28 May 2015 15:33:04 -0700 Subject: [PATCH 058/397] [React] Update README (0.13.3) --- react/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/react/README.md b/react/README.md index 0c773fd38..1f4cb7f03 100644 --- a/react/README.md +++ b/react/README.md @@ -1,10 +1,11 @@ -# React v0.13.0 Type Definitions +# React v0.13.3 Type Definitions This folder contains the following `.d.ts` files: -* `react-0.13.0.d.ts` declares the external module `"react"` -* `react-addons-0.13.0.d.ts` declares the external module `"react/addons"` -* `react-global-0.13.0.d.ts` declares the internal module `React` in the global namespace -* `react-addons-global-0.13.0.d.ts` extends the global `React` module with `addons` +* `react.d.ts` declares the external module `"react"` +* `react-addons.d.ts` declares the external module `"react/addons"` +* `react-global.d.ts` declares the internal module `React` in the global namespace +* `react-addons-global.d.ts` extends the global `React` module with `addons` -Interfaces are duplicated between these files; please take care to keep them in sync when making changes. See [#3615](https://github.com/borisyankov/DefinitelyTyped/pull/3615) for relevant discussion. +Interfaces are duplicated between these files; please take care to keep them in sync when making changes. +See [#3615](https://github.com/borisyankov/DefinitelyTyped/pull/3615) for relevant discussion. From 3afd16a3691da4a9be175374f127730fbf87dc7a Mon Sep 17 00:00:00 2001 From: Fabian Raetz Date: Fri, 29 May 2015 00:33:31 +0200 Subject: [PATCH 059/397] add test case for fulfilled --- chai-as-promised/chai-as-promised-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chai-as-promised/chai-as-promised-tests.ts b/chai-as-promised/chai-as-promised-tests.ts index a2dcb72ed..95a433517 100644 --- a/chai-as-promised/chai-as-promised-tests.ts +++ b/chai-as-promised/chai-as-promised-tests.ts @@ -9,6 +9,7 @@ chai.use(chaiAsPromised); var promise: any; chai.expect(promise).to.eventually.equal(3); chai.expect(promise).to.become(3); +chai.expect(promise).to.be.fulfilled; chai.expect(promise).to.be.rejected; chai.expect(promise).to.be.rejectedWith(Error); chai.expect(promise).to.notify(() => console.log('done')); From 5b0830b61e0cd5ba8dfe37bca50e47af2d3d1575 Mon Sep 17 00:00:00 2001 From: Fabian Raetz Date: Fri, 29 May 2015 00:34:31 +0200 Subject: [PATCH 060/397] add fulfilled to Assertion --- chai-as-promised/chai-as-promised.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chai-as-promised/chai-as-promised.d.ts b/chai-as-promised/chai-as-promised.d.ts index 6ff150eb4..106bbf41e 100644 --- a/chai-as-promised/chai-as-promised.d.ts +++ b/chai-as-promised/chai-as-promised.d.ts @@ -14,6 +14,7 @@ declare module Chai { interface Assertion { become(expected: any): Assertion; + fulfilled: Assertion; rejected: Assertion; rejectedWith(expected: any): Assertion; notify(fn: Function): Assertion; From 5294692073a4dc3c04ae971809d8bba93452ba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?= Date: Fri, 29 May 2015 09:59:37 +0200 Subject: [PATCH 061/397] AngularJS 1.4 - `bindToController` object definition This commit supports using `bindToController` as an object (see: https://github.com/angular/angular.js/blob/master/CHANGELOG.md#features-9). --- angularjs/angular.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 719e84139..29dd32c68 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.3+ +// Type definitions for Angular JS 1.4+ // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -1550,7 +1550,7 @@ declare module angular { compile?: IDirectiveCompileFn; controller?: any; controllerAs?: string; - bindToController?: boolean; + bindToController?: any; link?: IDirectiveLinkFn | IDirectivePrePost; name?: string; priority?: number; From 58d0e244a7a608835ada3382f70732b23d6f9b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?= Date: Fri, 29 May 2015 10:06:25 +0200 Subject: [PATCH 062/397] union type for `bindToController` --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 29dd32c68..bdb804ff2 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1550,7 +1550,7 @@ declare module angular { compile?: IDirectiveCompileFn; controller?: any; controllerAs?: string; - bindToController?: any; + bindToController?: boolean|Object; link?: IDirectiveLinkFn | IDirectivePrePost; name?: string; priority?: number; From 4b7a72361277c3c5daf95bc2f9e7e69b5f51a9ab Mon Sep 17 00:00:00 2001 From: Vadim Macagon Date: Fri, 29 May 2015 13:40:07 +0700 Subject: [PATCH 063/397] Add type definitions for pty.js --- pty.js/pty.js-tests.ts | 21 +++++++ pty.js/pty.js.d.ts | 133 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 pty.js/pty.js-tests.ts create mode 100644 pty.js/pty.js.d.ts diff --git a/pty.js/pty.js-tests.ts b/pty.js/pty.js-tests.ts new file mode 100644 index 000000000..cf73af384 --- /dev/null +++ b/pty.js/pty.js-tests.ts @@ -0,0 +1,21 @@ +/// + +import pty = require('pty.js'); + +var term: pty.Terminal = pty.spawn('bash', [], { + name: 'xterm-color', + cols: 80, + rows: 30, + cwd: process.env.HOME, + env: process.env +}); + +term.on('data', function(data: any) { + console.log(data); +}); + +term.write('ls\r'); +term.resize(100, 40); +term.write('ls /\r'); + +console.log(term.process); diff --git a/pty.js/pty.js.d.ts b/pty.js/pty.js.d.ts new file mode 100644 index 000000000..937dff0c0 --- /dev/null +++ b/pty.js/pty.js.d.ts @@ -0,0 +1,133 @@ +// Type definitions for pty.js 0.2.7-1 +// Project: https://github.com/chjj/pty.js +// Definitions by: Vadim Macagon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'pty.js' { + /** Options that can be used when creating a new pseudo-terminal. */ + interface TerminalOptions { + name?: string; + cols?: number; + rows?: number; + cwd?: string; + env?: any; + uid?: number; + gid?: number; + } + + import stream = require('stream'); + import net = require('net'); + + export class Terminal implements stream.Stream { + /** Read-only name of the terminal. */ + name: string; + /** Read-only number of columns in the terminal. */ + cols: number; + /** Read-only number of rows in the terminal. */ + rows: number; + /** + * Read-only identifier of the spawned process associated with the slave end of the + * pseudo-terminal. This will be null if the terminal was created via [[Terminal.open]]. + */ + pid: number; + /** Read-only file descriptor of the master end of the pseudo-terminal. */ + fd: number; + /** Read-only name of the slave end of the pseudo-terminal. */ + pty: string; + /** Read-only filename of the executable associated with the slave end of the pseudo-terminal. */ + file: string; + /** Read-only name of the process associated with the slave end of the pseudo-terminal. */ + process: string; + stdout: Terminal; + /** Note that an exception will be thrown if an attempt is made to access this property. */ + stderr: Terminal; + stdin: Terminal; + socket: net.Socket; + + /** + * Creates a new pseudo-terminal, spawns a child process, and associates it with the slave + * end of the pseudo-terminal. + */ + constructor(file?: string, args?: string[], opt?: TerminalOptions); + + resize(cols?: number, rows?: number): void; + /** + * Sends a signal to the spawned process associated with the slave end of the + * pseudo-terminal (this only works if [[pid]] is not null). + */ + kill(signal?: string): void; + redraw(): void; + + // NodeJS Socket-like interface (wrappers for this.socket) + + write(data: any): boolean; + end(data: any): void; + pause(): void; + resume(): void; + setEncoding(encoding: string): void; + /** + * Closes the master end of the pseudo-terminal, and attempts to kill the spawned process + * associated with the slave end of the pseudo-terminal (but only if [[pid]] is not null). + */ + destroy(): void; + + // NodeJS Stream interface + + pipe(destination: T, options?: { end?: boolean; }): T; + + // NodeJS EventEmitter interface + + addListener(event: string, listener: Function): NodeJS.EventEmitter; + on(event: string, listener: Function): NodeJS.EventEmitter; + once(event: string, listener: Function): NodeJS.EventEmitter; + removeListener(event: string, listener: Function): NodeJS.EventEmitter; + removeAllListeners(event?: string): NodeJS.EventEmitter; + // NOTE: this method is not actually defined in pty.js + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } + + /** + * Creates a new pseudo-terminal, spawns a child process, and associates it with the slave + * end of the pseudo-terminal. + */ + export function createTerminal(file?: string, args?: string[], opt?: TerminalOptions): Terminal; + /** Alias for [[createTerminal]]. */ + export function fork(file?: string, args?: string[], opt?: TerminalOptions): Terminal; + /** Alias for [[createTerminal]]. */ + export function spawn(file?: string, args?: string[], opt?: TerminalOptions): Terminal; + /** + * Creates a new pseudo-terminal. + * This function is not available on Windows, use [[fork]] there instead. + */ + export function open(opt?: { cols?: number; rows?: number }): Terminal; + + // Internal stuff that probably isn't very useful but is exported by pty.js + export module native { + /** Unix-only. */ + export function fork( + file: string, args: string[], env: any, cwd: string, cols: number, rows: number, + uid?: number, gid?: number + ): { fd: number; pid: number; pty: string }; + /** Unix-only. */ + export function open( + cols: number, rows: number + ): { master: number; slave: number; pty: string }; + /** Unix-only. */ + export function process(fd: number, tty: string): string; + /** Windows-only. */ + export function open( + dataPipe: string, cols: number, rows: number, debug: boolean + ): { pid: number; pty: number; fd: number }; + /** Windows-only. */ + export function startProcess( + pid: number, file: string, cmdline: string, env: string[], cwd: string + ): void; + /** Windows-only. */ + export function kill(pid: number): void; + export function resize(fd: number, cols: number, rows: number): void; + } +} From 08f4725531229e124af715130d0ead425f999ee7 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Fri, 29 May 2015 11:45:53 +0100 Subject: [PATCH 064/397] Add mobile-detect type definitions --- mobile-detect/mobile-detect-tests.ts | 14 ++++++++++++++ mobile-detect/mobile-detect.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 mobile-detect/mobile-detect-tests.ts create mode 100644 mobile-detect/mobile-detect.d.ts diff --git a/mobile-detect/mobile-detect-tests.ts b/mobile-detect/mobile-detect-tests.ts new file mode 100644 index 000000000..694d3cd89 --- /dev/null +++ b/mobile-detect/mobile-detect-tests.ts @@ -0,0 +1,14 @@ +/// + +var md: MobileDetect; + +var mobie: string = md.mobile() +var phone: string = md.phone() +var tablet: string = md.tablet() +var userAgent: string = md.userAgent() +var os: string = md.os() +var isPhone: boolean = md.is('iPhone') +var bot: boolean = md.is('bot') +var version: number = md.version('Webkit') +var versionStr: string = md.versionStr('Build') +var match: boolean = md.match('playstation|xbox') \ No newline at end of file diff --git a/mobile-detect/mobile-detect.d.ts b/mobile-detect/mobile-detect.d.ts new file mode 100644 index 000000000..e6149848d --- /dev/null +++ b/mobile-detect/mobile-detect.d.ts @@ -0,0 +1,22 @@ +// Type definitions for mobile-detect v1.2.0 +// Project: http://hgoebl.github.io/mobile-detect.js/ +// Definitions by: Martin McWhorter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + + +declare class MobileDetect { + + contructor(userAgent: string, maxPhoneWidth?: number); + + is(key: string): boolean; + match(pattern: string|RegExp): boolean + mobile(): string; + mobileGrade(): string; + os(): string; + phone(): string; + tablet(): string; + userAgent(): string; + version(value: string): number; + versionStr(value: string): string; +} From f6ce2b2a27c5aa64432700c16b87938a3fd540f0 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Fri, 29 May 2015 11:48:18 +0100 Subject: [PATCH 065/397] fix vertical whitespace --- mobile-detect/mobile-detect.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/mobile-detect/mobile-detect.d.ts b/mobile-detect/mobile-detect.d.ts index e6149848d..f37793ced 100644 --- a/mobile-detect/mobile-detect.d.ts +++ b/mobile-detect/mobile-detect.d.ts @@ -3,8 +3,6 @@ // Definitions by: Martin McWhorter // Definitions: https://github.com/borisyankov/DefinitelyTyped - - declare class MobileDetect { contructor(userAgent: string, maxPhoneWidth?: number); From 9fffdcf779c2fa49e0b6b0b1e332004d5a5026c5 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Fri, 29 May 2015 12:16:47 +0100 Subject: [PATCH 066/397] Fix tests --- mobile-detect/mobile-detect.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile-detect/mobile-detect.d.ts b/mobile-detect/mobile-detect.d.ts index f37793ced..c24b2ea67 100644 --- a/mobile-detect/mobile-detect.d.ts +++ b/mobile-detect/mobile-detect.d.ts @@ -5,7 +5,7 @@ declare class MobileDetect { - contructor(userAgent: string, maxPhoneWidth?: number); + contructor(userAgent: string, maxPhoneWidth?: number): MobileDetect; is(key: string): boolean; match(pattern: string|RegExp): boolean From 3aee09a07cbd608a23a17c6c28ae26dc51499dc9 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Fri, 29 May 2015 13:10:45 +0100 Subject: [PATCH 067/397] Fix contructor --- mobile-detect/mobile-detect-tests.ts | 2 +- mobile-detect/mobile-detect.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile-detect/mobile-detect-tests.ts b/mobile-detect/mobile-detect-tests.ts index 694d3cd89..64dbddc1a 100644 --- a/mobile-detect/mobile-detect-tests.ts +++ b/mobile-detect/mobile-detect-tests.ts @@ -1,6 +1,6 @@ /// -var md: MobileDetect; +var md: MobileDetect = new MobileDetect(window.navigator.userAgent); var mobie: string = md.mobile() var phone: string = md.phone() diff --git a/mobile-detect/mobile-detect.d.ts b/mobile-detect/mobile-detect.d.ts index c24b2ea67..180fd0664 100644 --- a/mobile-detect/mobile-detect.d.ts +++ b/mobile-detect/mobile-detect.d.ts @@ -5,7 +5,7 @@ declare class MobileDetect { - contructor(userAgent: string, maxPhoneWidth?: number): MobileDetect; + constructor(userAgent: string, maxPhoneWidth?: number); is(key: string): boolean; match(pattern: string|RegExp): boolean From dfc08933163f1e36ba0bad0390bcc2a1a4636bd3 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 29 May 2015 13:24:40 +0100 Subject: [PATCH 068/397] Update angular.d.ts - JSDoc-ed $filter --- angularjs/angular.d.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 92784af38..1b12c2026 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -736,17 +736,37 @@ declare module angular { eventFn(element: Node, doneFn: () => void): Function; } - /////////////////////////////////////////////////////////////////////////// - // FilterService - // see http://docs.angularjs.org/api/ng.$filter - // see http://docs.angularjs.org/api/ng.$filterProvider - /////////////////////////////////////////////////////////////////////////// + /** + * $filter - $filterProvider - service in module ng + * + * Filters are used for formatting data displayed to the user. + * + * see https://docs.angularjs.org/api/ng/service/$filter + */ interface IFilterService { + /** + * Usage: + * $filter(name); + * + * @param name Name of the filter function to retrieve + */ (name: string): Function; } + /** + * $filterProvider - $filter - provider in module ng + * + * Filters are just functions which transform input to an output. However filters need to be Dependency Injected. To achieve this a filter definition consists of a factory function which is annotated with dependencies and is responsible for creating a filter function. + * + * see https://docs.angularjs.org/api/ng/provider/$filterProvider + */ interface IFilterProvider extends IServiceProvider { - register(name: string, filterFactory: Function): IServiceProvider; + /** + * register(name); + * + * @param name Name of the filter function, or an object map of filters where the keys are the filter names and the values are the filter factories. Note: Filter names must be valid angular Expressions identifiers, such as uppercase or orderBy. Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace your filters, then you can use capitalization (myappSubsectionFilterx) or underscores (myapp_subsection_filterx). + */ + register(name: string | {}): IServiceProvider; } /////////////////////////////////////////////////////////////////////////// From cec0beaa1c72b9a0178541a82b74af384708bf98 Mon Sep 17 00:00:00 2001 From: Adam Kalman Date: Fri, 29 May 2015 14:17:17 -0700 Subject: [PATCH 069/397] 90296 add in map values definitions add in definitions for map values when used within a chain generated via _.chain or _(). --- lodash/lodash.d.ts | 569 ++++++++++++++++++++++++--------------------- 1 file changed, 302 insertions(+), 267 deletions(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 84db97b2d..cf7ab8851 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -13,27 +13,27 @@ declare module _ { * In addition to Lo-Dash methods, wrappers also have the following Array methods: * concat, join, pop, push, reverse, shift, slice, sort, splice, and unshift * - * Chaining is supported in custom builds as long as the value method is implicitly or + * Chaining is supported in custom builds as long as the value method is implicitly or * explicitly included in the build. * * The chainable wrapper functions are: - * after, assign, bind, bindAll, bindKey, chain, chunk, compact, compose, concat, countBy, - * createCallback, curry, debounce, defaults, defer, delay, difference, filter, flatten, - * forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy, - * indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, - * object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject, - * remove, rest, reverse, shuffle, slice, sort, sortBy, splice, tap, throttle, times, + * after, assign, bind, bindAll, bindKey, chain, chunk, compact, compose, concat, countBy, + * createCallback, curry, debounce, defaults, defer, delay, difference, filter, flatten, + * forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy, + * indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, + * object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject, + * remove, rest, reverse, shuffle, slice, sort, sortBy, splice, tap, throttle, times, * toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip * * The non-chainable wrapper functions are: - * clone, cloneDeep, contains, escape, every, find, findIndex, findKey, findLast, - * findLastIndex, findLastKey, has, identity, indexOf, isArguments, isArray, isBoolean, - * isDate, isElement, isEmpty, isEqual, isFinite, isFunction, isNaN, isNull, isNumber, - * isObject, isPlainObject, isRegExp, isString, isUndefined, join, lastIndexOf, mixin, - * noConflict, parseInt, pop, random, reduce, reduceRight, result, shift, size, some, + * clone, cloneDeep, contains, escape, every, find, findIndex, findKey, findLast, + * findLastIndex, findLastKey, has, identity, indexOf, isArguments, isArray, isBoolean, + * isDate, isElement, isEmpty, isEqual, isFinite, isFunction, isNaN, isNull, isNumber, + * isObject, isPlainObject, isRegExp, isString, isUndefined, join, lastIndexOf, mixin, + * noConflict, parseInt, pop, random, reduce, reduceRight, result, shift, size, some, * sortedIndex, runInContext, template, unescape, uniqueId, and value * - * The wrapper functions first and last return wrapped values when n is provided, otherwise + * The wrapper functions first and last return wrapped values when n is provided, otherwise * they return unwrapped values. * * Explicit chaining can be enabled by using the _.chain method. @@ -56,14 +56,14 @@ declare module _ { support: Support; /** - * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby + * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby * (ERB). Change the following template settings to use alternative delimiters. **/ templateSettings: TemplateSettings; } /** - * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby + * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby * (ERB). Change the following template settings to use alternative delimiters. **/ interface TemplateSettings { @@ -108,7 +108,7 @@ declare module _ { argsObject: boolean; /** - * Detect if name or message properties of Error.prototype are enumerable by default. + * Detect if name or message properties of Error.prototype are enumerable by default. * (IE < 9, Safari < 5.1) **/ enumErrorProps: boolean; @@ -119,7 +119,7 @@ declare module _ { fastBind: boolean; /** - * Detect if functions can be decompiled by Function#toString (all but PS3 and older Opera + * Detect if functions can be decompiled by Function#toString (all but PS3 and older Opera * mobile browsers & avoided in Windows 8 apps). **/ funcDecomp: boolean; @@ -130,7 +130,7 @@ declare module _ { funcNames: boolean; /** - * Detect if arguments object indexes are non-enumerable (Firefox < 4, IE < 9, PhantomJS, + * Detect if arguments object indexes are non-enumerable (Firefox < 4, IE < 9, PhantomJS, * Safari < 5.1). **/ nonEnumArgs: boolean; @@ -138,7 +138,7 @@ declare module _ { /** * Detect if properties shadowing those on Object.prototype are non-enumerable. * - * In IE < 9 an objects own properties, shadowing non-enumerable ones, are made + * In IE < 9 an objects own properties, shadowing non-enumerable ones, are made * non-enumerable as well (a.k.a the JScript [[DontEnum]] bug). **/ nonEnumShadows: boolean; @@ -151,9 +151,9 @@ declare module _ { /** * Detect if Array#shift and Array#splice augment array-like objects correctly. * - * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array shift() and splice() - * functions that fail to remove the last element, value[0], of array-like objects even - * though the length property is set to 0. The shift() method is buggy in IE 8 compatibility + * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array shift() and splice() + * functions that fail to remove the last element, value[0], of array-like objects even + * though the length property is set to 0. The shift() method is buggy in IE 8 compatibility * mode, while splice() is buggy regardless of mode in IE < 9 and buggy in compatibility mode * in IE 9. **/ @@ -162,7 +162,7 @@ declare module _ { /** * Detect lack of support for accessing string characters by index. * - * IE < 8 can't access characters by index and IE 8 can only access characters by index on + * IE < 8 can't access characters by index and IE 8 can only access characters by index on * string literals. **/ unindexedChars: boolean; @@ -232,8 +232,8 @@ declare module _ { //_.tap interface LoDashStatic { /** - * Invokes interceptor with the value as the first argument and then returns value. The - * purpose of this method is to "tap into" a method chain in order to perform operations on + * Invokes interceptor with the value as the first argument and then returns value. The + * purpose of this method is to "tap into" a method chain in order to perform operations on * intermediate results within the chain. * @param value The value to provide to interceptor * @param interceptor The function to invoke. @@ -254,7 +254,7 @@ declare module _ { /********* * Arrays * **********/ - + //_.chunk interface LoDashStatic { /** @@ -271,7 +271,7 @@ declare module _ { **/ chunk(array: List, size?: number): T[][]; } - + interface LoDashArrayWrapper { /** * @see _.chunk @@ -338,10 +338,10 @@ declare module _ { //_.findIndex interface LoDashStatic { /** - * This method is like _.find except that it returns the index of the first element that passes + * This method is like _.find except that it returns the index of the first element that passes * the callback check, instead of the element itself. * @param array The array to search. - * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be + * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be * used to create a ".pluck" or ".where" style callback, respectively. * @param thisArg The this binding of callback. * @return Returns the index of the found element, else -1. @@ -393,7 +393,7 @@ declare module _ { /** * This method is like _.findIndex except that it iterates over elements of a collection from right to left. * @param array The array to search. - * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be + * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be * used to create a ".pluck" or ".where" style callback, respectively. * @param thisArg The this binding of callback. * @return Returns the index of the found element, else -1. @@ -443,12 +443,12 @@ declare module _ { //_.first interface LoDashStatic { /** - * Gets the first element or first n elements of an array. If a callback is provided - * elements at the beginning of the array are returned as long as the callback returns - * truey. The callback is bound to thisArg and invoked with three arguments; (value, + * Gets the first element or first n elements of an array. If a callback is provided + * elements at the beginning of the array are returned as long as the callback returns + * truey. The callback is bound to thisArg and invoked with three arguments; (value, * index, array). * - * If a property name is provided for callback the created "_.pluck" style callback + * If a property name is provided for callback the created "_.pluck" style callback * will return the property value of the given element. * * If an object is provided for callback the created "_.where" style callback will return ] @@ -769,15 +769,15 @@ declare module _ { //_.flatten interface LoDashStatic { /** - * Flattens a nested array (the nesting can be to any depth). If isShallow is truey, the - * array will only be flattened a single level. If a callback is provided each element of - * the array is passed through the callback before flattening. The callback is bound to + * Flattens a nested array (the nesting can be to any depth). If isShallow is truey, the + * array will only be flattened a single level. If a callback is provided each element of + * the array is passed through the callback before flattening. The callback is bound to * thisArg and invoked with three arguments; (value, index, array). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param array The array to flatten. * @param shallow If true then only flatten one level, optional, default = false. @@ -936,8 +936,8 @@ declare module _ { //_.indexOf interface LoDashStatic { /** - * Gets the index at which the first occurrence of value is found using strict equality - * for comparisons, i.e. ===. If the array is already sorted providing true for fromIndex + * Gets the index at which the first occurrence of value is found using strict equality + * for comparisons, i.e. ===. If the array is already sorted providing true for fromIndex * will run a faster binary search. * @param array The array to search. * @param value The value to search for. @@ -995,15 +995,15 @@ declare module _ { //_.initial interface LoDashStatic { /** - * Gets all but the last element or last n elements of an array. If a callback is provided - * elements at the end of the array are excluded from the result as long as the callback - * returns truey. The callback is bound to thisArg and invoked with three arguments; + * Gets all but the last element or last n elements of an array. If a callback is provided + * elements at the end of the array are excluded from the result as long as the callback + * returns truey. The callback is bound to thisArg and invoked with three arguments; * (value, index, array). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param array The array to query. * @param n Leaves this many elements behind, optional. @@ -1086,7 +1086,7 @@ declare module _ { //_.intersection interface LoDashStatic { /** - * Creates an array of unique values present in all provided arrays using strict + * Creates an array of unique values present in all provided arrays using strict * equality for comparisons, i.e. ===. * @param arrays The arrays to inspect. * @return Returns an array of composite values. @@ -1102,14 +1102,14 @@ declare module _ { //_.last interface LoDashStatic { /** - * Gets the last element or last n elements of an array. If a callback is provided - * elements at the end of the array are returned as long as the callback returns truey. + * Gets the last element or last n elements of an array. If a callback is provided + * elements at the end of the array are returned as long as the callback returns truey. * The callback is bound to thisArg and invoked with three arguments; (value, index, array). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param array The array to query. * @return Returns the last element(s) of array. @@ -1191,8 +1191,8 @@ declare module _ { //_.lastIndexOf interface LoDashStatic { /** - * Gets the index at which the last occurrence of value is found using strict equality - * for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the + * Gets the index at which the last occurrence of value is found using strict equality + * for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the * end of the collection. * @param array The array to search. * @param value The value to search for. @@ -1216,7 +1216,7 @@ declare module _ { //_.pull interface LoDashStatic { /** - * Removes all provided values from the given array using strict equality for comparisons, + * Removes all provided values from the given array using strict equality for comparisons, * i.e. ===. * @param array The array to modify. * @param values The values to remove. @@ -1237,8 +1237,8 @@ declare module _ { //_.range interface LoDashStatic { /** - * Creates an array of numbers (positive and/or negative) progressing from start up - * to but not including end. If start is less than stop a zero-length range is created + * Creates an array of numbers (positive and/or negative) progressing from start up + * to but not including end. If start is less than stop a zero-length range is created * unless a negative step is specified. * @param start The start of the range. * @param end The end of the range. @@ -1262,14 +1262,14 @@ declare module _ { //_.remove interface LoDashStatic { /** - * Removes all elements from an array that the callback returns truey for and returns - * an array of removed elements. The callback is bound to thisArg and invoked with three + * Removes all elements from an array that the callback returns truey for and returns + * an array of removed elements. The callback is bound to thisArg and invoked with three * arguments; (value, index, array). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param array The array to modify. * @param callback The function called per iteration. @@ -1325,19 +1325,19 @@ declare module _ { //_.rest interface LoDashStatic { /** - * The opposite of _.initial this method gets all but the first element or first n elements of - * an array. If a callback function is provided elements at the beginning of the array are excluded - * from the result as long as the callback returns truey. The callback is bound to thisArg and + * The opposite of _.initial this method gets all but the first element or first n elements of + * an array. If a callback function is provided elements at the beginning of the array are excluded + * from the result as long as the callback returns truey. The callback is bound to thisArg and * invoked with three arguments; (value, index, array). * - * If a property name is provided for callback the created "_.pluck" style callback will return + * If a property name is provided for callback the created "_.pluck" style callback will return * the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return true + * + * If an object is provided for callback the created "_.where" style callback will return true * for elements that have the properties of the given object, else false. * @param array The array to query. - * @param {(Function|Object|number|string)} [callback=1] The function called per element or the number - * of elements to exclude. If a property name or object is provided it will be used to create a + * @param {(Function|Object|number|string)} [callback=1] The function called per element or the number + * of elements to exclude. If a property name or object is provided it will be used to create a * ".pluck" or ".where" style callback, respectively. * @param {*} [thisArg] The this binding of callback. * @return Returns a slice of array. @@ -1547,15 +1547,15 @@ declare module _ { //_.sortedIndex interface LoDashStatic { /** - * Uses a binary search to determine the smallest index at which a value should be inserted - * into a given sorted array in order to maintain the sort order of the array. If a callback - * is provided it will be executed for value and each element of array to compute their sort + * Uses a binary search to determine the smallest index at which a value should be inserted + * into a given sorted array in order to maintain the sort order of the array. If a callback + * is provided it will be executed for value and each element of array to compute their sort * ranking. The callback is bound to thisArg and invoked with one argument; (value). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param array The sorted list. * @param value The value to determine its index within `list`. @@ -1617,7 +1617,7 @@ declare module _ { //_.union interface LoDashStatic { /** - * Creates an array of unique values, in order, of the provided arrays using strict + * Creates an array of unique values, in order, of the provided arrays using strict * equality for comparisons, i.e. ===. * @param arrays The arrays to inspect. * @return Returns an array of composite values. @@ -1633,16 +1633,16 @@ declare module _ { //_.uniq interface LoDashStatic { /** - * Creates a duplicate-value-free version of an array using strict equality for comparisons, - * i.e. ===. If the array is sorted, providing true for isSorted will use a faster algorithm. - * If a callback is provided each element of array is passed through the callback before - * uniqueness is computed. The callback is bound to thisArg and invoked with three arguments; + * Creates a duplicate-value-free version of an array using strict equality for comparisons, + * i.e. ===. If the array is sorted, providing true for isSorted will use a faster algorithm. + * If a callback is provided each element of array is passed through the callback before + * uniqueness is computed. The callback is bound to thisArg and invoked with three arguments; * (value, index, array). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param array Array to remove duplicates from. * @param isSorted True if `array` is already sorted, optiona, default = false. @@ -1969,7 +1969,7 @@ declare module _ { * @param whereValue _.where style callback **/ unique( - whereValue: W): LoDashArrayWrapper; + whereValue: W): LoDashArrayWrapper; } //_.without @@ -2023,12 +2023,12 @@ declare module _ { xor( ...others: List[]): LoDashArrayWrapper; } - + //_.zip interface LoDashStatic { /** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second elements + * Creates an array of grouped elements, the first of which contains the first + * elements of the given arrays, the second of which contains the second elements * of the given arrays, and so on. * @param arrays Arrays to process. * @return A new array of grouped elements. @@ -2066,8 +2066,8 @@ declare module _ { //_.zipObject interface LoDashStatic { /** - * Creates an object composed from arrays of keys and values. Provide either a single - * two dimensional array, i.e. [[key1, value1], [key2, value2]] or two arrays, one of + * Creates an object composed from arrays of keys and values. Provide either a single + * two dimensional array, i.e. [[key1, value1], [key2, value2]] or two arrays, one of * keys and one of corresponding values. * @param keys The array of keys. * @param values The array of values. @@ -2092,10 +2092,10 @@ declare module _ { //_.at interface LoDashStatic { /** - * Creates an array of elements from the specified indexes, or keys, of the collection. + * Creates an array of elements from the specified indexes, or keys, of the collection. * Indexes may be specified as individual arguments or as arrays of indexes. * @param collection The collection to iterate over. - * @param indexes The indexes of collection to retrieve, specified as individual indexes or + * @param indexes The indexes of collection to retrieve, specified as individual indexes or * arrays of indexes. * @return A new array of elements corresponding to the provided indexes. **/ @@ -2142,7 +2142,7 @@ declare module _ { //_.contains interface LoDashStatic { /** - * Checks if a given value is present in a collection using strict equality for comparisons, + * Checks if a given value is present in a collection using strict equality for comparisons, * i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection. * @param collection The collection to iterate over. * @param target The value to check for. @@ -2218,15 +2218,15 @@ declare module _ { //_.countBy interface LoDashStatic { /** - * Creates an object composed of keys generated from the results of running each element - * of collection through the callback. The corresponding value of each key is the number - * of times the key was returned by the callback. The callback is bound to thisArg and + * Creates an object composed of keys generated from the results of running each element + * of collection through the callback. The corresponding value of each key is the number + * of times the key was returned by the callback. The callback is bound to thisArg and * invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -2304,14 +2304,14 @@ declare module _ { //_.every interface LoDashStatic { /** - * Checks if the given callback returns truey value for all elements of a collection. - * The callback is bound to thisArg and invoked with three arguments; (value, index|key, + * Checks if the given callback returns truey value for all elements of a collection. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, * collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -2465,14 +2465,14 @@ declare module _ { //_.filter interface LoDashStatic { /** - * Iterates over elements of a collection, returning an array of all elements the - * callback returns truey for. The callback is bound to thisArg and invoked with three + * Iterates over elements of a collection, returning an array of all elements the + * callback returns truey for. The callback is bound to thisArg and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -2677,17 +2677,17 @@ declare module _ { //_.find interface LoDashStatic { /** - * Iterates over elements of a collection, returning the first element that the callback - * returns truey for. The callback is bound to thisArg and invoked with three arguments; + * Iterates over elements of a collection, returning the first element that the callback + * returns truey for. The callback is bound to thisArg and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param collection Searches for a value in this list. - * @param callback The function called per iteration. + * @param callback The function called per iteration. * @param thisArg The this binding of callback. * @return The found element, else undefined. **/ @@ -2930,10 +2930,10 @@ declare module _ { //_.findLast interface LoDashStatic { /** - * This method is like _.find except that it iterates over elements of a collection from + * This method is like _.find except that it iterates over elements of a collection from * right to left. * @param collection Searches for a value in this list. - * @param callback The function called per iteration. + * @param callback The function called per iteration. * @param thisArg The this binding of callback. * @return The found element, else undefined. **/ @@ -3032,8 +3032,8 @@ declare module _ { //_.forEach interface LoDashStatic { /** - * Iterates over elements of a collection, executing the callback for each element. - * The callback is bound to thisArg and invoked with three arguments; (value, index|key, + * Iterates over elements of a collection, executing the callback for each element. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, * collection). Callbacks may exit iteration early by explicitly returning false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3139,7 +3139,7 @@ declare module _ { //_.forEachRight interface LoDashStatic { /** - * This method is like _.forEach except that it iterates over elements of a + * This method is like _.forEach except that it iterates over elements of a * collection from right to left. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3232,14 +3232,14 @@ declare module _ { //_.groupBy interface LoDashStatic { /** - * Creates an object composed of keys generated from the results of running each element - * of a collection through the callback. The corresponding value of each key is an array - * of the elements responsible for generating the key. The callback is bound to thisArg + * Creates an object composed of keys generated from the results of running each element + * of a collection through the callback. The corresponding value of each key is an array + * of the elements responsible for generating the key. The callback is bound to thisArg * and invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3361,15 +3361,15 @@ declare module _ { //_.indexBy interface LoDashStatic { /** - * Creates an object composed of keys generated from the results of running each element - * of the collection through the given callback. The corresponding value of each key is - * the last element responsible for generating the key. The callback is bound to thisArg + * Creates an object composed of keys generated from the results of running each element + * of the collection through the given callback. The corresponding value of each key is + * the last element responsible for generating the key. The callback is bound to thisArg * and invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3425,9 +3425,9 @@ declare module _ { //_.invoke interface LoDashStatic { /** - * Invokes the method named by methodName on each element in the collection returning - * an array of the results of each invoked method. Additional arguments will be provided - * to each invoked method. If methodName is a function it will be invoked for, and this + * Invokes the method named by methodName on each element in the collection returning + * an array of the results of each invoked method. Additional arguments will be provided + * to each invoked method. If methodName is a function it will be invoked for, and this * bound to, each element in the collection. * @param collection The collection to iterate over. * @param methodName The name of the method to invoke. @@ -3482,14 +3482,14 @@ declare module _ { //_.map interface LoDashStatic { /** - * Creates an array of values by running each element in the collection through the callback. - * The callback is bound to thisArg and invoked with three arguments; (value, index|key, + * Creates an array of values by running each element in the collection through the callback. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, * collection). * - * If a property name is provided for callback the created "_.pluck" style callback will return + * If a property name is provided for callback the created "_.pluck" style callback will return * the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return true + * If an object is provided for callback the created "_.where" style callback will return true * for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3624,15 +3624,15 @@ declare module _ { //_.max interface LoDashStatic { /** - * Retrieves the maximum value of a collection. If the collection is empty or falsey -Infinity is - * returned. If a callback is provided it will be executed for each value in the collection to - * generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked + * Retrieves the maximum value of a collection. If the collection is empty or falsey -Infinity is + * returned. If a callback is provided it will be executed for each value in the collection to + * generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked * with three arguments; (value, index, collection). - * - * If a property name is provided for callback the created "_.pluck" style callback will return the + * + * If a property name is provided for callback the created "_.pluck" style callback will return the * property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return true for + * If an object is provided for callback the created "_.where" style callback will return true for * elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3735,15 +3735,15 @@ declare module _ { //_.min interface LoDashStatic { /** - * Retrieves the minimum value of a collection. If the collection is empty or falsey - * Infinity is returned. If a callback is provided it will be executed for each value - * in the collection to generate the criterion by which the value is ranked. The callback + * Retrieves the minimum value of a collection. If the collection is empty or falsey + * Infinity is returned. If a callback is provided it will be executed for each value + * in the collection to generate the criterion by which the value is ranked. The callback * is bound to thisArg and invoked with three arguments; (value, index, collection). * - * If a property name is provided for callback the created "_.pluck" style callback + * If a property name is provided for callback the created "_.pluck" style callback * will return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will + * If an object is provided for callback the created "_.where" style callback will * return true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -3889,10 +3889,10 @@ declare module _ { //_.reduce interface LoDashStatic { /** - * Reduces a collection to a value which is the accumulated result of running each - * element in the collection through the callback, where each successive callback execution - * consumes the return value of the previous execution. If accumulator is not provided the - * first element of the collection will be used as the initial accumulator value. The callback + * Reduces a collection to a value which is the accumulated result of running each + * element in the collection through the callback, where each successive callback execution + * consumes the return value of the previous execution. If accumulator is not provided the + * first element of the collection will be used as the initial accumulator value. The callback * is bound to thisArg and invoked with four arguments; (accumulator, value, index|key, collection). * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -4148,7 +4148,7 @@ declare module _ { //_.reduceRight interface LoDashStatic { /** - * This method is like _.reduce except that it iterates over elements of a collection from + * This method is like _.reduce except that it iterates over elements of a collection from * right to left. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -4259,13 +4259,13 @@ declare module _ { //_.reject interface LoDashStatic { /** - * The opposite of _.filter this method returns the elements of a collection that + * The opposite of _.filter this method returns the elements of a collection that * the callback does not return truey for. * - * If a property name is provided for callback the created "_.pluck" style callback + * If a property name is provided for callback the created "_.pluck" style callback * will return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will + * If an object is provided for callback the created "_.where" style callback will * return true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -4404,7 +4404,7 @@ declare module _ { //_.shuffle interface LoDashStatic { /** - * Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. + * Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. * See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. * @param collection The collection to shuffle. * @return Returns a new shuffled collection. @@ -4439,7 +4439,7 @@ declare module _ { //_.size interface LoDashStatic { /** - * Gets the size of the collection by returning collection.length for arrays and array-like + * Gets the size of the collection by returning collection.length for arrays and array-like * objects or the number of own enumerable properties for objects. * @param collection The collection to inspect. * @return collection.length @@ -4469,14 +4469,14 @@ declare module _ { //_.some interface LoDashStatic { /** - * Checks if the callback returns a truey value for any element of a collection. The function - * returns as soon as it finds a passing value and does not iterate over the entire collection. + * Checks if the callback returns a truey value for any element of a collection. The function + * returns as soon as it finds a passing value and does not iterate over the entire collection. * The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will return + * If a property name is provided for callback the created "_.pluck" style callback will return * the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return true for + * If an object is provided for callback the created "_.where" style callback will return true for * elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -4644,15 +4644,15 @@ declare module _ { //_.sortBy interface LoDashStatic { /** - * Creates an array of elements, sorted in ascending order by the results of running each - * element in a collection through the callback. This method performs a stable sort, that - * is, it will preserve the original sort order of equal elements. The callback is bound + * Creates an array of elements, sorted in ascending order by the results of running each + * element in a collection through the callback. This method performs a stable sort, that + * is, it will preserve the original sort order of equal elements. The callback is bound * to thisArg and invoked with three arguments; (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will + * If a property name is provided for callback the created "_.pluck" style callback will * return the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * If an object is provided for callback the created "_.where" style callback will return * true for elements that have the properties of the given object, else false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -4763,7 +4763,7 @@ declare module _ { //_.where interface LoDashStatic { /** - * Performs a deep comparison of each element in a collection to the given properties + * Performs a deep comparison of each element in a collection to the given properties * object, returning an array of all elements that have equivalent property values. * @param collection The collection to iterate over. * @param properties The object of property values to filter by. @@ -4802,7 +4802,7 @@ declare module _ { //_.after interface LoDashStatic { /** - * Creates a function that executes func, with the this binding and arguments of the + * Creates a function that executes func, with the this binding and arguments of the * created function, only after being called n times. * @param n The number of times the function must be called before func is executed. * @param func The function to restrict. @@ -4823,7 +4823,7 @@ declare module _ { //_.bind interface LoDashStatic { /** - * Creates a function that, when called, invokes func with the this binding of thisArg + * Creates a function that, when called, invokes func with the this binding of thisArg * and prepends any additional bind arguments to those provided to the bound function. * @param func The function to bind. * @param thisArg The this binding of func. @@ -4848,11 +4848,11 @@ declare module _ { //_.bindAll interface LoDashStatic { /** - * Binds methods of an object to the object itself, overwriting the existing method. Method - * names may be specified as individual arguments or as arrays of method names. If no method + * Binds methods of an object to the object itself, overwriting the existing method. Method + * names may be specified as individual arguments or as arrays of method names. If no method * names are provided all the function properties of object will be bound. * @param object The object to bind and assign the bound methods to. - * @param methodNames The object method names to bind, specified as individual method names + * @param methodNames The object method names to bind, specified as individual method names * or arrays of method names. * @return object **/ @@ -4871,9 +4871,9 @@ declare module _ { //_.bindKey interface LoDashStatic { /** - * Creates a function that, when called, invokes the method at object[key] and prepends any - * additional bindKey arguments to those provided to the bound function. This method differs - * from _.bind by allowing bound functions to reference methods that will be redefined or don't + * Creates a function that, when called, invokes the method at object[key] and prepends any + * additional bindKey arguments to those provided to the bound function. This method differs + * from _.bind by allowing bound functions to reference methods that will be redefined or don't * yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. * @param object The object the method belongs to. * @param key The key of the method. @@ -4898,9 +4898,9 @@ declare module _ { //_.compose interface LoDashStatic { /** - * Creates a function that is the composition of the provided functions, where each function - * consumes the return value of the function that follows. For example, composing the functions - * f(), g(), and h() produces f(g(h())). Each function is executed with the this binding of the + * Creates a function that is the composition of the provided functions, where each function + * consumes the return value of the function that follows. For example, composing the functions + * f(), g(), and h() produces f(g(h())). Each function is executed with the this binding of the * composed function. * @param funcs Functions to compose. * @return The new composed function. @@ -4918,9 +4918,9 @@ declare module _ { //_.createCallback interface LoDashStatic { /** - * Produces a callback bound to an optional thisArg. If func is a property name the created - * callback will return the property value for a given element. If func is an object the created - * callback will return true for elements that contain the equivalent object properties, + * Produces a callback bound to an optional thisArg. If func is a property name the created + * callback will return the property value for a given element. If func is an object the created + * callback will return true for elements that contain the equivalent object properties, * otherwise it will return false. * @param func The value to convert to a callback. * @param thisArg The this binding of the created callback. @@ -4962,9 +4962,9 @@ declare module _ { //_.curry interface LoDashStatic { /** - * Creates a function which accepts one or more arguments of func that when invoked either - * executes func returning its result, if all func arguments have been provided, or returns - * a function that accepts one or more of the remaining func arguments, and so on. The arity + * Creates a function which accepts one or more arguments of func that when invoked either + * executes func returning its result, if all func arguments have been provided, or returns + * a function that accepts one or more of the remaining func arguments, and so on. The arity * of func can be specified if func.length is not sufficient. * @param func The function to curry. * @param arity The arity of func. @@ -4985,13 +4985,13 @@ declare module _ { //_.debounce interface LoDashStatic { /** - * Creates a function that will delay the execution of func until after wait milliseconds have - * elapsed since the last time it was invoked. Provide an options object to indicate that func - * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls + * Creates a function that will delay the execution of func until after wait milliseconds have + * elapsed since the last time it was invoked. Provide an options object to indicate that func + * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls * to the debounced function will return the result of the last func call. * - * Note: If leading and trailing options are true func will be called on the trailing edge of - * the timeout only if the the debounced function is invoked more than once during the wait + * Note: If leading and trailing options are true func will be called on the trailing edge of + * the timeout only if the the debounced function is invoked more than once during the wait * timeout. * @param func The function to debounce. * @param wait The number of milliseconds to delay. @@ -5036,7 +5036,7 @@ declare module _ { //_.defer interface LoDashStatic { /** - * Defers executing the func function until the current call stack has cleared. Additional + * Defers executing the func function until the current call stack has cleared. Additional * arguments will be provided to func when it is invoked. * @param func The function to defer. * @param args Arguments to invoke the function with. @@ -5057,7 +5057,7 @@ declare module _ { //_.delay interface LoDashStatic { /** - * Executes the func function after wait milliseconds. Additional arguments will be provided + * Executes the func function after wait milliseconds. Additional arguments will be provided * to func when it is invoked. * @param func The function to delay. * @param wait The number of milliseconds to delay execution. @@ -5082,10 +5082,10 @@ declare module _ { //_.memoize interface LoDashStatic { /** - * Creates a function that memoizes the result of func. If resolver is provided it will be - * used to determine the cache key for storing the result based on the arguments provided to - * the memoized function. By default, the first argument provided to the memoized function is - * used as the cache key. The func is executed with the this binding of the memoized function. + * Creates a function that memoizes the result of func. If resolver is provided it will be + * used to determine the cache key for storing the result based on the arguments provided to + * the memoized function. By default, the first argument provided to the memoized function is + * used as the cache key. The func is executed with the this binding of the memoized function. * The result cache is exposed as the cache property on the memoized function. * @param func Computationally expensive function that will now memoized results. * @param resolver Hash function for storing the result of `fn`. @@ -5099,8 +5099,8 @@ declare module _ { //_.once interface LoDashStatic { /** - * Creates a function that is restricted to execute func once. Repeat calls to the function - * will return the value of the first call. The func is executed with the this binding of the + * Creates a function that is restricted to execute func once. Repeat calls to the function + * will return the value of the first call. The func is executed with the this binding of the * created function. * @param func Function to only execute once. * @return The new restricted function. @@ -5111,8 +5111,8 @@ declare module _ { //_.partial interface LoDashStatic { /** - * Creates a function that, when called, invokes func with any additional partial arguments - * prepended to those provided to the new function. This method is similar to _.bind except + * Creates a function that, when called, invokes func with any additional partial arguments + * prepended to those provided to the new function. This method is similar to _.bind except * it does not alter the this binding. * @param func The function to partially apply arguments to. * @param args Arguments to be partially applied. @@ -5126,7 +5126,7 @@ declare module _ { //_.partialRight interface LoDashStatic { /** - * This method is like _.partial except that partial arguments are appended to those provided + * This method is like _.partial except that partial arguments are appended to those provided * to the new function. * @param func The function to partially apply arguments to. * @param args Arguments to be partially applied. @@ -5140,12 +5140,12 @@ declare module _ { //_.throttle interface LoDashStatic { /** - * Creates a function that, when executed, will only call the func function at most once per - * every wait milliseconds. Provide an options object to indicate that func should be invoked - * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled + * Creates a function that, when executed, will only call the func function at most once per + * every wait milliseconds. Provide an options object to indicate that func should be invoked + * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled * function will return the result of the last func call. * - * Note: If leading and trailing options are true func will be called on the trailing edge of + * Note: If leading and trailing options are true func will be called on the trailing edge of * the timeout only if the the throttled function is invoked more than once during the wait timeout. * @param func The function to throttle. * @param wait The number of milliseconds to throttle executions to. @@ -5176,8 +5176,8 @@ declare module _ { //_.wrap interface LoDashStatic { /** - * Creates a function that provides value to the wrapper function as its first argument. - * Additional arguments provided to the function are appended to those provided to the + * Creates a function that provides value to the wrapper function as its first argument. + * Additional arguments provided to the function are appended to those provided to the * wrapper function. The wrapper is executed with the this binding of the created function. * @param value The value to wrap. * @param wrapper The wrapper function. @@ -5195,9 +5195,9 @@ declare module _ { //_.assign interface LoDashStatic { /** - * Assigns own enumerable properties of source object(s) to the destination object. Subsequent - * sources will overwrite property assignments of previous sources. If a callback is provided - * it will be executed to produce the assigned values. The callback is bound to thisArg and + * Assigns own enumerable properties of source object(s) to the destination object. Subsequent + * sources will overwrite property assignments of previous sources. If a callback is provided + * it will be executed to produce the assigned values. The callback is bound to thisArg and * invoked with two arguments; (objectValue, sourceValue). * @param object The destination object. * @param s1-8 The source object(s) @@ -5387,9 +5387,9 @@ declare module _ { //_.clone interface LoDashStatic { /** - * Creates a clone of value. If deep is true nested objects will also be cloned, otherwise - * they will be assigned by reference. If a callback is provided it will be executed to produce - * the cloned values. If the callback returns undefined cloning will be handled by the method + * Creates a clone of value. If deep is true nested objects will also be cloned, otherwise + * they will be assigned by reference. If a callback is provided it will be executed to produce + * the cloned values. If the callback returns undefined cloning will be handled by the method * instead. The callback is bound to thisArg and invoked with one argument; (value). * @param value The value to clone. * @param deep Specify a deep clone. @@ -5407,13 +5407,13 @@ declare module _ { //_.cloneDeep interface LoDashStatic { /** - * Creates a deep clone of value. If a callback is provided it will be executed to produce the - * cloned values. If the callback returns undefined cloning will be handled by the method instead. + * Creates a deep clone of value. If a callback is provided it will be executed to produce the + * cloned values. If the callback returns undefined cloning will be handled by the method instead. * The callback is bound to thisArg and invoked with one argument; (value). * - * Note: This method is loosely based on the structured clone algorithm. Functions and DOM nodes - * are not cloned. The enumerable properties of arguments objects and objects created by constructors - * other than Object are cloned to plain Object objects. + * Note: This method is loosely based on the structured clone algorithm. Functions and DOM nodes + * are not cloned. The enumerable properties of arguments objects and objects created by constructors + * other than Object are cloned to plain Object objects. * See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm. * @param value The value to clone. * @param callback The function to customize cloning values. @@ -5429,8 +5429,8 @@ declare module _ { //_.defaults interface LoDashStatic { /** - * Assigns own enumerable properties of source object(s) to the destination object for all - * destination properties that resolve to undefined. Once a property is set, additional defaults + * Assigns own enumerable properties of source object(s) to the destination object for all + * destination properties that resolve to undefined. Once a property is set, additional defaults * of the same property will be ignored. * @param object The destination object. * @param sources The source objects. @@ -5451,7 +5451,7 @@ declare module _ { //_.findKey interface LoDashStatic { /** - * This method is like _.findIndex except that it returns the key of the first element that + * This method is like _.findIndex except that it returns the key of the first element that * passes the callback check, instead of the element itself. * @param object The object to search. * @param callback The function called per iteration. @@ -5514,8 +5514,8 @@ declare module _ { //_.forIn interface LoDashStatic { /** - * Iterates over own and inherited enumerable properties of an object, executing the callback for - * each property. The callback is bound to thisArg and invoked with three arguments; (value, key, + * Iterates over own and inherited enumerable properties of an object, executing the callback for + * each property. The callback is bound to thisArg and invoked with three arguments; (value, key, * object). Callbacks may exit iteration early by explicitly returning false. * @param object The object to iterate over. * @param callback The function called per iteration. @@ -5548,7 +5548,7 @@ declare module _ { //_.forInRight interface LoDashStatic { /** - * This method is like _.forIn except that it iterates over elements of a collection in the + * This method is like _.forIn except that it iterates over elements of a collection in the * opposite order. * @param object The object to iterate over. * @param callback The function called per iteration. @@ -5581,8 +5581,8 @@ declare module _ { //_.forOwn interface LoDashStatic { /** - * Iterates over own enumerable properties of an object, executing the callback for each - * property. The callback is bound to thisArg and invoked with three arguments; (value, key, + * Iterates over own enumerable properties of an object, executing the callback for each + * property. The callback is bound to thisArg and invoked with three arguments; (value, key, * object). Callbacks may exit iteration early by explicitly returning false. * @param object The object to iterate over. * @param callback The function called per iteration. @@ -5615,7 +5615,7 @@ declare module _ { //_.forOwnRight interface LoDashStatic { /** - * This method is like _.forOwn except that it iterates over elements of a collection in the + * This method is like _.forOwn except that it iterates over elements of a collection in the * opposite order. * @param object The object to iterate over. * @param callback The function called per iteration. @@ -5647,7 +5647,7 @@ declare module _ { //_.functions interface LoDashStatic { /** - * Creates a sorted array of property names of all enumerable properties, own and inherited, of + * Creates a sorted array of property names of all enumerable properties, own and inherited, of * object that have function values. * @param object The object to inspect. * @return An array of property names that have function values. @@ -5675,7 +5675,7 @@ declare module _ { //_.has interface LoDashStatic { /** - * Checks if the specified object property exists and is a direct property, instead of an + * Checks if the specified object property exists and is a direct property, instead of an * inherited property. * @param object The object to check. * @param property The property to check for. @@ -5747,14 +5747,14 @@ declare module _ { //_.isEmpty interface LoDashStatic { /** - * Checks if value is empty. Arrays, strings, or arguments objects with a length of 0 and objects + * Checks if value is empty. Arrays, strings, or arguments objects with a length of 0 and objects * with no own enumerable properties are considered "empty". * @param value The value to inspect. * @return True if the value is empty, else false. **/ isEmpty(value?: any[]|Dictionary|string|any): boolean; } - + //_.isError interface LoDashStatic { /** @@ -5770,9 +5770,9 @@ declare module _ { //_.isEqual interface LoDashStatic { /** - * Performs a deep comparison between two values to determine if they are equivalent to each - * other. If a callback is provided it will be executed to compare values. If the callback - * returns undefined comparisons will be handled by the method instead. The callback is bound to + * Performs a deep comparison between two values to determine if they are equivalent to each + * other. If a callback is provided it will be executed to compare values. If the callback + * returns undefined comparisons will be handled by the method instead. The callback is bound to * thisArg and invoked with two arguments; (a, b). * @param a The value to compare. * @param b The other value to compare. @@ -5792,7 +5792,7 @@ declare module _ { /** * Checks if value is, or can be coerced to, a finite number. * - * Note: This is not the same as native isFinite which will return true for booleans and empty + * Note: This is not the same as native isFinite which will return true for booleans and empty * strings. See http://es5.github.io/#x15.1.2.5. * @param value The value to check. * @return True if the value is finite, else false. @@ -5815,7 +5815,7 @@ declare module _ { /** * Checks if value is NaN. * - * Note: This is not the same as native isNaN which will return true for undefined and other + * Note: This is not the same as native isNaN which will return true for undefined and other * non-numeric values. See http://es5.github.io/#x15.1.2.4. * @param value The value to check. * @return True if the value is NaN, else false. @@ -5848,7 +5848,7 @@ declare module _ { //_.isObject interface LoDashStatic { /** - * Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, + * Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, * new Number(0), and new String('')) * @param value The value to check. * @return True if the value is an object, else false. @@ -5917,19 +5917,22 @@ declare module _ { interface LoDashStatic { /** * Creates an object with the same keys as object and values generated by running each own - * enumerable property of object through the callback. The callback is bound to thisArg and - * invoked with three arguments; (value, key, object). + * enumerable property of object through iteratee. The iteratee function is bound to thisArg + * and invoked with three arguments: (value, key, object). * - * If a property name is provided for callback the created "_.pluck" style callback will return + * If a property name is provided iteratee the created "_.property" style callback returns * the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return true + * If a value is also provided for thisArg the creted "_.matchesProperty" style callback returns + * true for elements that have a matching property value, else false;. + * + * If an object is provided for iteratee the created "_.matches" style callback returns true * for elements that have the properties of the given object, else false. * - * @param object The object to iterate over. - * @param callback The function called per iteration. - * @param thisArg `this` object in `iterator`, optional. - * @return Returns a new object with values of the results of each callback execution. + * @param {Object} object The object to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Object} [thisArg] The `this` binding of `iteratee`. + * @return {Object} Returns the new mapped object. */ mapValues(obj: Dictionary, callback: ObjectIterator, thisArg?: any): Dictionary; mapValues(obj: Dictionary, where: Dictionary): Dictionary; @@ -5937,14 +5940,46 @@ declare module _ { mapValues(obj: T, callback: ObjectIterator, thisArg?: any): T; } + interface LoDashObjectWrapper { + /** + * @see _.mapValues + * TValue is the type of the property values of T. + * TResult is the type output by the ObjectIterator function + */ + mapValues(callback: ObjectIterator, thisArg?: any): LoDashObjectWrapper>; + + /** + * @see _.mapValues + * TResult is the type of the property specified by pluck. + * T should be a Dictionary> + */ + mapValues(pluck: string): LoDashObjectWrapper>; + + /** + * @see _.mapValues + * TResult is the type of the property specified by pluck. + * TResult has to extend Dictionary<> for this to return true. + * TResultValueType is the type of the properties on TResult. + * T should be a Dictionary> + */ + mapValues>(pluck: string, where: TResult): LoDashArrayWrapper>; + + /** + * @see _.mapValues + * TResult is the type of the properties of each object in the values of T + * T should be a Dictionary> + */ + mapValues(where: Dictionary): LoDashArrayWrapper; + } + //_.merge interface LoDashStatic { /** - * Recursively merges own enumerable properties of the source object(s), that don't resolve - * to undefined into the destination object. Subsequent sources will overwrite property - * assignments of previous sources. If a callback is provided it will be executed to produce - * the merged values of the destination and source properties. If the callback returns undefined - * merging will be handled by the method instead. The callback is bound to thisArg and invoked + * Recursively merges own enumerable properties of the source object(s), that don't resolve + * to undefined into the destination object. Subsequent sources will overwrite property + * assignments of previous sources. If a callback is provided it will be executed to produce + * the merged values of the destination and source properties. If the callback returns undefined + * merging will be handled by the method instead. The callback is bound to thisArg and invoked * with two arguments; (objectValue, sourceValue). * @param object The destination object. * @param s1-8 The source object(s) @@ -5995,10 +6030,10 @@ declare module _ { //_.omit interface LoDashStatic { /** - * Creates a shallow clone of object excluding the specified properties. Property names may be - * specified as individual arguments or as arrays of property names. If a callback is provided - * it will be executed for each property of object omitting the properties the callback returns - * truey for. The callback is bound to thisArg and invoked with three arguments; (value, key, + * Creates a shallow clone of object excluding the specified properties. Property names may be + * specified as individual arguments or as arrays of property names. If a callback is provided + * it will be executed for each property of object omitting the properties the callback returns + * truey for. The callback is bound to thisArg and invoked with three arguments; (value, key, * object). * @param object The source object. * @param keys The properties to omit. @@ -6048,7 +6083,7 @@ declare module _ { //_.pairs interface LoDashStatic { /** - * Creates a two dimensional array of an object's key-value pairs, + * Creates a two dimensional array of an object's key-value pairs, * i.e. [[key1, value1], [key2, value2]]. * @param object The object to inspect. * @return Aew array of key-value pairs. @@ -6066,10 +6101,10 @@ declare module _ { //_.picks interface LoDashStatic { /** - * Creates a shallow clone of object composed of the specified properties. Property names may be - * specified as individual arguments or as arrays of property names. If a callback is provided - * it will be executed for each property of object picking the properties the callback returns - * truey for. The callback is bound to thisArg and invoked with three arguments; (value, key, + * Creates a shallow clone of object composed of the specified properties. Property names may be + * specified as individual arguments or as arrays of property names. If a callback is provided + * it will be executed for each property of object picking the properties the callback returns + * truey for. The callback is bound to thisArg and invoked with three arguments; (value, key, * object). * @param object Object to strip unwanted key/value pairs. * @param keys Property names to pick @@ -6098,10 +6133,10 @@ declare module _ { //_.transform interface LoDashStatic { /** - * An alternative to _.reduce this method transforms object to a new accumulator object which is - * the result of running each of its elements through a callback, with each callback execution - * potentially mutating the accumulator object. The callback is bound to thisArg and invoked with - * four arguments; (accumulator, value, key, object). Callbacks may exit iteration early by + * An alternative to _.reduce this method transforms object to a new accumulator object which is + * the result of running each of its elements through a callback, with each callback execution + * potentially mutating the accumulator object. The callback is bound to thisArg and invoked with + * four arguments; (accumulator, value, key, object). Callbacks may exit iteration early by * explicitly returning false. * @param collection The collection to iterate over. * @param callback The function called per iteration. @@ -6198,10 +6233,10 @@ declare module _ { //_.parseInt interface LoDashStatic { /** - * Converts the given value into an integer of the specified radix. If radix is undefined or 0 a + * Converts the given value into an integer of the specified radix. If radix is undefined or 0 a * radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used. * - * Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See + * Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See * http://es5.github.io/#E. * @param value The value to parse. * @param radix The radix used to interpret the value to parse. @@ -6265,8 +6300,8 @@ declare module _ { //_.random interface LoDashStatic { /** - * Produces a random number between min and max (inclusive). If only one argument is provided a - * number between 0 and the given number will be returned. If floating is truey or either min or + * Produces a random number between min and max (inclusive). If only one argument is provided a + * number between 0 and the given number will be returned. If floating is truey or either min or * max are floats a floating-point number will be returned instead of an integer. * @param max The maximum possible value. * @param floating Specify returning a floating-point number. @@ -6285,8 +6320,8 @@ declare module _ { //_.result interface LoDashStatic { /** - * Resolves the value of property on object. If property is a function it will be invoked with - * the this binding of object and its result returned, else the property value is returned. If + * Resolves the value of property on object. If property is a function it will be invoked with + * the this binding of object and its result returned, else the property value is returned. If * object is falsey then undefined is returned. * @param object The object to inspect. * @param property The property to get the value of. @@ -6308,10 +6343,10 @@ declare module _ { //_.template interface LoDashStatic { /** - * A micro-templating method that handles arbitrary delimiters, preserves whitespace, and + * A micro-templating method that handles arbitrary delimiters, preserves whitespace, and * correctly escapes quotes within interpolated code. * - * Note: In the development build, _.template utilizes sourceURLs for easier debugging. See + * Note: In the development build, _.template utilizes sourceURLs for easier debugging. See * http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl * * For more information on precompiling templates see: @@ -6352,7 +6387,7 @@ declare module _ { //_.times interface LoDashStatic { /** - * Executes the callback n times, returning an array of the results of each callback execution. + * Executes the callback n times, returning an array of the results of each callback execution. * The callback is bound to thisArg and invoked with one argument; (index). * @param n The number of times to execute the callback. * @param callback The function called per iteration. @@ -6367,7 +6402,7 @@ declare module _ { //_.unescape interface LoDashStatic { /** - * The inverse of _.escape this method converts the HTML entities &, <, >, ", and + * The inverse of _.escape this method converts the HTML entities &, <, >, ", and * ' in string to their corresponding characters. * @param string The string to unescape. * @return The unescaped string. @@ -6385,7 +6420,7 @@ declare module _ { **/ uniqueId(prefix?: string): string; } - + //_.noop interface LoDashStatic { /** @@ -6411,7 +6446,7 @@ declare module _ { */ create(prototype: Object, properties?: Object): Object; } - + interface ListIterator { (value: T, index: number, collection: T[]): TResult; } From fa52db59121913b35e9641a0f73ccc3ffba58840 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Fri, 29 May 2015 17:42:46 -0400 Subject: [PATCH 070/397] Allow optional fs-extra#mkdirs options object --- fs-extra/fs-extra-tests.ts | 4 ++++ fs-extra/fs-extra.d.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs-extra/fs-extra-tests.ts b/fs-extra/fs-extra-tests.ts index 939821b6d..0919ef1b0 100644 --- a/fs-extra/fs-extra-tests.ts +++ b/fs-extra/fs-extra-tests.ts @@ -58,9 +58,13 @@ fs.createFile(file, errorCallback); fs.createFileSync(file); fs.mkdirs(dir, errorCallback); +fs.mkdirs(dir, {}, errorCallback); fs.mkdirsSync(dir); +fs.mkdirsSync(dir, {}); fs.mkdirp(dir, errorCallback); +fs.mkdirp(dir, {}, errorCallback); fs.mkdirpSync(dir); +fs.mkdirpSync(dir, {}); fs.outputFile(file, data, errorCallback); fs.outputFileSync(file, data); diff --git a/fs-extra/fs-extra.d.ts b/fs-extra/fs-extra.d.ts index 5b1ecf0b9..852956a71 100644 --- a/fs-extra/fs-extra.d.ts +++ b/fs-extra/fs-extra.d.ts @@ -52,8 +52,10 @@ declare module "fs-extra" { export function mkdirs(dir: string, callback?: (err: Error) => void): void; export function mkdirp(dir: string, callback?: (err: Error) => void): void; - export function mkdirsSync(dir: string): void; - export function mkdirpSync(dir: string): void; + export function mkdirs(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void; + export function mkdirp(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void; + export function mkdirsSync(dir: string, options?: MkdirOptions): void; + export function mkdirpSync(dir: string, options?: MkdirOptions): void; export function outputFile(file: string, data: any, callback?: (err: Error) => void): void; export function outputFileSync(file: string, data: any): void; @@ -171,6 +173,11 @@ declare module "fs-extra" { flag?: string; } + export interface MkdirOptions { + fs?: any; + mode?: number; + } + export interface ReadStreamOptions { flags?: string; encoding?: string; From 18fdbd98c7343f8c9fb54199adb40f60ace91484 Mon Sep 17 00:00:00 2001 From: Adam Kalman Date: Fri, 29 May 2015 14:52:58 -0700 Subject: [PATCH 071/397] 90296 add and fix tests add in a test for the new code, and make all the tests pass. --- lodash/lodash-tests.ts | 2 ++ lodash/lodash.d.ts | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 6a48e20c1..a265eda3b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -143,6 +143,8 @@ result = _('test').value(); result = _([1, 2, 3]).value(); result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value(); +result = <_.Dictionary>_({ a: 1, b: 2}).mapValues(function(num: number) { return num * 2; }).value(); + // /************* // * Arrays * // *************/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d06a993f9..81fd2c661 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6121,12 +6121,10 @@ declare module _ { /** * @see _.mapValues - * TResult is the type of the property specified by pluck. - * TResult has to extend Dictionary<> for this to return true. - * TResultValueType is the type of the properties on TResult. - * T should be a Dictionary> + * TResult is the type of the properties on the object specified by pluck. + * T should be a Dictionary>> */ - mapValues>(pluck: string, where: TResult): LoDashArrayWrapper>; + mapValues(pluck: string, where: Dictionary): LoDashArrayWrapper>; /** * @see _.mapValues From 4f11e3facf42c7691ae89a55fd35bb10b8ecfc0f Mon Sep 17 00:00:00 2001 From: Arvitaly Date: Sat, 30 May 2015 23:49:38 +0300 Subject: [PATCH 072/397] Fixed ur to url for RequestResource in phantomjs --- phantomjs/phantomjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phantomjs/phantomjs.d.ts b/phantomjs/phantomjs.d.ts index 3682024b6..0bb6af7b8 100644 --- a/phantomjs/phantomjs.d.ts +++ b/phantomjs/phantomjs.d.ts @@ -173,7 +173,7 @@ interface ResourceResponse { interface ResourceRequest { id: number; method: string; - ur: string; + url: string; time: Date; headers: { [name: string]: string; }; } From 33c089e9c0a19a94f50aaf4e2fe64fccdb4fce36 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sun, 31 May 2015 11:05:24 +1000 Subject: [PATCH 073/397] Update toastr.d.ts --- toastr/toastr.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toastr/toastr.d.ts b/toastr/toastr.d.ts index 2fcdc3840..321177ec2 100644 --- a/toastr/toastr.d.ts +++ b/toastr/toastr.d.ts @@ -197,3 +197,6 @@ interface Toastr { } declare var toastr: Toastr; +declare module "toastr" { + export = toastr; +} From e6057412964979bebb5ca85665b2b39a37b0ccdb Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Sun, 31 May 2015 10:30:59 +0300 Subject: [PATCH 074/397] ICurrent route can sometimes have a 5108route param --- angularjs/angular-route.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index 4ddf87cab..3ac22c096 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -108,6 +108,8 @@ declare module angular.route { // see http://docs.angularjs.org/api/ng.$route#current interface ICurrentRoute extends IRoute { + $$route?: IRoute; + locals: { $scope: IScope; $template: string; From c32e1df7c5ed02a36a7e911db68440d3daf1e649 Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Sun, 31 May 2015 10:32:28 +0300 Subject: [PATCH 075/397] IActionDescriptor can have a url override also --- angularjs/angular-resource.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 057cc1b56..ec8430cb8 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -45,6 +45,7 @@ declare module angular.resource { // Just a reference to facilitate describing new actions interface IActionDescriptor { + url?: string; method: string; isArray?: boolean; params?: any; From 3e6f6339a537c569cb99bc54746d189545345485 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Abuzyarov" Date: Sun, 31 May 2015 13:48:30 +0300 Subject: [PATCH 076/397] Add Decorator definition to IModule --- angularjs/angular-tests.ts | 3 +++ angularjs/angular.d.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 628b6d1d2..7511f3627 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -201,6 +201,9 @@ mod.constant(My.Namespace); mod.value('name', 23); mod.value('name', "23"); mod.value(My.Namespace); +mod.decorator('name', function($scope:ng.IScope){ }); +mod.decorator('name', ['$scope', function($scope: ng.IScope){ }]); + class TestProvider implements ng.IServiceProvider { constructor(private $scope: ng.IScope) { diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 457a1df35..621f0b3e5 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -384,6 +384,14 @@ declare module angular { value(name: string, value: any): IModule; value(object: Object): IModule; + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * @param name The name of the service to decorate + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name:string, decoratorConstructor: Function): IModule; + decorator(name:string, inlineAnnotatedConstructor: any[]): IModule; + // Properties name: string; requires: string[]; From 47ccfe38b576bc6602ac4286f9a5f7bbe46879fc Mon Sep 17 00:00:00 2001 From: Viktor Sidochenko Date: Sun, 31 May 2015 19:37:57 +0500 Subject: [PATCH 077/397] Add chrome.browser type --- chrome/chrome.d.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 23eb24bef..19d5c4d0b 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -43,6 +43,37 @@ declare module chrome.alarms { var onAlarm: AlarmEvent; } +/** + * Use the chrome.browser API to interact with the Chrome browser associated with + * the current application and Chrome profile. + */ +declare module chrome.browser { + interface Options { + /** + * The URL to navigate to when the new tab is initially opened. + */ + url:string; + } + + /** + * Opens a new tab in a browser window associated with the current application + * and Chrome profile. If no browser window for the Chrome profile is opened, + * a new one is opened prior to creating the new tab. + * @param options Configures how the tab should be opened. + * @param callback Called when the tab was successfully + * created, or failed to be created. If failed, runtime.lastError will be set. + */ + export function openTab (options: Options, callback: () => void): void; + + /** + * Opens a new tab in a browser window associated with the current application + * and Chrome profile. If no browser window for the Chrome profile is opened, + * a new one is opened prior to creating the new tab. Since Chrome 42 only. + * @param options Configures how the tab should be opened. + */ + export function openTab (options: Options): void; +} + //////////////////// // Bookmarks //////////////////// From beac5c03fee9705314cdf6162a19d8edc7288849 Mon Sep 17 00:00:00 2001 From: FalloutPL Date: Mon, 1 Jun 2015 01:58:49 +0200 Subject: [PATCH 078/397] Missing id for Client interface It`s exposed in: https://github.com/Automattic/socket.io/blob/master/lib/client.js#L28 --- socket.io/socket.io.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index ac5381f09..3f3c042fe 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -91,5 +91,6 @@ declare module SocketIO { interface Client { conn: any; request: any; + id: string; } } From 83ea26f60b059a307c09cb0b827499a246e1fab2 Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Mon, 1 Jun 2015 12:39:06 +0900 Subject: [PATCH 079/397] Updated a test code for dat-gui. --- dat-gui/dat-gui-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dat-gui/dat-gui-tests.ts b/dat-gui/dat-gui-tests.ts index cd71e2471..19b34dd43 100644 --- a/dat-gui/dat-gui-tests.ts +++ b/dat-gui/dat-gui-tests.ts @@ -157,3 +157,19 @@ var FizzyText = function () { update(); } +// ------------ 11. Object Literal Tests +() => { + var obj = {a:1,b:1}; + var gui = new dat.GUI(); + var controller = gui.add(obj, 'maxSize', 0, 10); + + controller.onChange(function (value) { + // Fires on every change, drag, keypress, etc. + }); + + controller.onFinishChange(function (value) { + // Fires when a controller loses focus. + alert("The new value is " + value); + }); +} + From d9b2f58d6864a8a7e1792a54307a2d5c6dbec9ab Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Mon, 1 Jun 2015 09:27:43 +0300 Subject: [PATCH 080/397] IResourceServiceProvider --- angularjs/angular-resource.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index ec8430cb8..7f02a533e 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -21,6 +21,7 @@ declare module angular.resource { stripTrailingSlashes?: boolean; } + /////////////////////////////////////////////////////////////////////////// // ResourceService // see http://docs.angularjs.org/api/ngResource.$resource @@ -144,6 +145,13 @@ declare module angular.resource { ($resource: angular.resource.IResourceService): IResourceClass; >($resource: angular.resource.IResourceService): U; } + + // IResourceServiceProvider used to configure global settings + interface IResourceServiceProvider extends ng.IServiceProvider { + + defaults: IResourceOptions; + } + } /** extensions to base ng based on using angular-resource */ From 480df8744d1c300751cf7225789da0f45cee3497 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 1 Jun 2015 16:33:43 +0900 Subject: [PATCH 081/397] add `imagemagick-native`s type definition file --- .../imagemagick-native-tests.ts | 128 ++++++++++++++++++ imagemagick-native/imagemagick-native.d.ts | 96 +++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 imagemagick-native/imagemagick-native-tests.ts create mode 100644 imagemagick-native/imagemagick-native.d.ts diff --git a/imagemagick-native/imagemagick-native-tests.ts b/imagemagick-native/imagemagick-native-tests.ts new file mode 100644 index 000000000..a1e42c6a9 --- /dev/null +++ b/imagemagick-native/imagemagick-native-tests.ts @@ -0,0 +1,128 @@ +/// +/// + +import imagemagick = require('imagemagick-native'); +import fs = require('fs'); + + +// Examples + +// * Convert formats +// Convert from one format to another with quality control: +fs.writeFileSync('after.png', imagemagick.convert({ + srcData: fs.readFileSync('before.jpg'), + format: 'PNG', + quality: 100 // (best) to 1 (worst) +})); + +// * Blur +// Blur image: +fs.writeFileSync('after.jpg', imagemagick.convert({ + srcData: fs.readFileSync('before.jpg'), + blur: 5 +})); + +// * Resize +// Resized images by specifying width and height. There are three resizing styles: +// - aspectfill: Default. The resulting image will be exactly the specified size, and may be cropped. +// - aspectfit: Scales the image so that it will not have to be cropped. +// - fill: Squishes or stretches the image so that it fills exactly the specified size. +fs.writeFileSync('after_resize.jpg', imagemagick.convert({ + srcData: fs.readFileSync('before_resize.jpg'), + width: 100, + height: 100, + resizeStyle: 'aspectfill', // is the default, or 'aspectfit' or 'fill' + gravity: 'Center' // optional: position crop area when using 'aspectfill' +})); + +// * Rotate, flip, and mirror +// Rotate and flip images, and combine the two to mirror: +fs.writeFileSync('after_rotateflip.jpg', imagemagick.convert({ + srcData: fs.readFileSync('before_rotateflip.jpg'), + rotate: 180, + flip: true +})); + + +// API Reference + +// * convert(options, [callback]) +// Convert a buffer provided as options.srcData and return a Buffer. +var options = { + srcData: fs.readFileSync('source.jpg'), + srcFormat: 'jpeg', + quality: 90, + trim: true, + trimFuzz: 0.25, + width: 100, + height: 100, + density: 96, + resizeStyle: 'aspectfill', + gravity: 'NorthWest', + format: 'png', + filter: 'Lnaczos', + blur: 3, + strip: true, + rotate: 30, + flip: true, + debug: true, + ignoreWarnings: false +}; + +imagemagick.convert(options, (err: any, buffer: Buffer) => { + // check err, use buffer +}); +fs.createReadStream('input.png') + .pipe(imagemagick.streams.convert(options)) + .pipe(fs.createWriteStream('output.png')); + + +// * identify(options, [callback]) +// Identify a buffer provided as srcData and return an object. +imagemagick.identify({ + srcData: fs.readFileSync('target.jpg'), + debug: true, + ignoreWarnings: false +}, (err: any, result: imagemagick.IIdentifyResult) => { + // check err, use result +}); + +// * quantizeColors(options) +// Quantize the image to a specified amount of colors from a buffer provided as srcData and return an array. +var colors = imagemagick.quantizeColors({ + srcData: fs.readFileSync('target.jpg'), + colors: 3, + debug: true, + ignoreWarnings: false +}); + +// * composite(options, [callback]) +// Composite a buffer provided as options.compositeData on a buffer provided as options.srcData with gravity specified by options.gravity and return a Buffer +imagemagick.composite({ + srcData: fs.readFileSync('target.jpg'), + compositeData: fs.readFileSync('composite.jpg'), + gravity: 'NorthWestGravity', + debug: true, + ignoreWarnings: false +}, (err: any, buffer: Buffer) => { + // check err, use buffer +}); + +// * getConstPixels(options) +// Get pixels of provided rectangular region. +var pixels = imagemagick.getConstPixels({ + srcData: fs.readFileSync('target.jpg'), + x: 0, + y: 0, + columns: 1, + rows: 1 +}); + +// * quantumDepth +// Return ImageMagick's QuantumDepth, which is defined in compile time. +var depth: number = imagemagick.quantumDepth(); + +// * version +// Return ImageMagick's version as string. +var version: string = imagemagick.version(); + diff --git a/imagemagick-native/imagemagick-native.d.ts b/imagemagick-native/imagemagick-native.d.ts new file mode 100644 index 000000000..c69cd6d8d --- /dev/null +++ b/imagemagick-native/imagemagick-native.d.ts @@ -0,0 +1,96 @@ +// Type definitions for imagemagick-native 1.7.0 +// Project: https://www.npmjs.org/package/imagemagick-native +// Definitions by: Hiroki Horiuchi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "imagemagick-native" { + + import stream = require('stream'); + export module streams { + export function convert(options: IConvertOptions): stream.Transform; + } + + function convert(options: IConvertOptions): Buffer; + function convert(options: IConvertOptions, callback: (err: any, result: Buffer) => void): void; + function identify(options: IIdentifyOptions): IIdentifyResult; + function identify(options: IIdentifyOptions, callback: (err: any, result: IIdentifyResult) => void): void; + function quantizeColors(options: IQuantizeColorsOptions): IQuantizeColorsItem[]; + function composite(options: ICompositeOptions): Buffer; + function composite(options: ICompositeOptions, callback: (err: any, result: Buffer) => void): void; + function getConstPixels(options: IConstPixelsOptions): IConstPixelsItem[]; + function quantumDepth(): number; + function version(): string; + + export interface IConvertOptions { + srcData: Buffer; + srcFormat?: string; + quality?: number; + trim?: boolean; + trimFuzz?: number; + width?: number; + height?: number; + density?: number; + resizeStyle?: string; + gravity?: string; + format?: string; + filter?: string; + blur?: number; + strip?: boolean; + rotate?: number; + flip?: boolean; + debug?: boolean; + ignoreWarnings?: boolean; + } + export interface IIdentifyOptions { + srcData: Buffer; + debug?: boolean; + ignoreWarnings?: boolean; + } + export interface IIdentifyResult { + format: string; + width: number; + height: number; + depth: number; + density : { + width : number; + height : number; + }; + exif: { + orientation: number; // 0 if none exists or e.g. 3 (portrait iPad pictures) + }; + } + export interface IQuantizeColorsOptions { + srcData: Buffer; + colors: number; + debug?: boolean; + ignoreWarnings?: boolean; + } + export interface IQuantizeColorsItem { + r: number; + g: number; + b: number; + hex: string; + } + export interface ICompositeOptions { + srcData: Buffer; + compositeData: Buffer; + gravity?: string; + debug?: boolean; + ignoreWarnings?: boolean; + } + export interface IConstPixelsOptions { + srcData: Buffer; + x: number; + y: number; + columns: number; + rows: number; + } + export interface IConstPixelsItem { + red: number; + green: number; + blue: number; + opacity: number; + } + +} + From a5db8a65cad22c7b4c9025aa56d93aa0f14eb5fb Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 1 Jun 2015 16:40:50 +0900 Subject: [PATCH 082/397] add reference to `node.d.ts` --- imagemagick-native/imagemagick-native.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imagemagick-native/imagemagick-native.d.ts b/imagemagick-native/imagemagick-native.d.ts index c69cd6d8d..e848fa32a 100644 --- a/imagemagick-native/imagemagick-native.d.ts +++ b/imagemagick-native/imagemagick-native.d.ts @@ -3,6 +3,8 @@ // Definitions by: Hiroki Horiuchi // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module "imagemagick-native" { import stream = require('stream'); From eb24f0b44e302d0a40e0b9eeac89b16346001e37 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 1 Jun 2015 17:33:27 +0900 Subject: [PATCH 083/397] fix `convert` options on stream version --- .../imagemagick-native-tests.ts | 6 +++++- imagemagick-native/imagemagick-native.d.ts | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/imagemagick-native/imagemagick-native-tests.ts b/imagemagick-native/imagemagick-native-tests.ts index a1e42c6a9..efefba8ee 100644 --- a/imagemagick-native/imagemagick-native-tests.ts +++ b/imagemagick-native/imagemagick-native-tests.ts @@ -73,7 +73,11 @@ imagemagick.convert(options, (err: any, buffer: Buffer) => { // check err, use buffer }); fs.createReadStream('input.png') - .pipe(imagemagick.streams.convert(options)) + .pipe(imagemagick.streams.convert({ + quality: 75, + width: 160, + height: 160 + })) .pipe(fs.createWriteStream('output.png')); diff --git a/imagemagick-native/imagemagick-native.d.ts b/imagemagick-native/imagemagick-native.d.ts index e848fa32a..fbf213f68 100644 --- a/imagemagick-native/imagemagick-native.d.ts +++ b/imagemagick-native/imagemagick-native.d.ts @@ -9,7 +9,7 @@ declare module "imagemagick-native" { import stream = require('stream'); export module streams { - export function convert(options: IConvertOptions): stream.Transform; + export function convert(options: IStreamConvertOptions): stream.Transform; } function convert(options: IConvertOptions): Buffer; @@ -23,6 +23,25 @@ declare module "imagemagick-native" { function quantumDepth(): number; function version(): string; + export interface IStreamConvertOptions { + srcFormat?: string; + quality?: number; + trim?: boolean; + trimFuzz?: number; + width?: number; + height?: number; + density?: number; + resizeStyle?: string; + gravity?: string; + format?: string; + filter?: string; + blur?: number; + strip?: boolean; + rotate?: number; + flip?: boolean; + debug?: boolean; + ignoreWarnings?: boolean; + } export interface IConvertOptions { srcData: Buffer; srcFormat?: string; From adab66e6a9f99b9f55c33dd0e4a96fd065dafe0e Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Mon, 1 Jun 2015 17:08:15 +0300 Subject: [PATCH 084/397] Remove incorrect ICurrentRoute api --- angularjs/angular-route.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index 3ac22c096..4ddf87cab 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -108,8 +108,6 @@ declare module angular.route { // see http://docs.angularjs.org/api/ng.$route#current interface ICurrentRoute extends IRoute { - $$route?: IRoute; - locals: { $scope: IScope; $template: string; From e6360b8507bb68489c17e0a4eeee79276b955612 Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Mon, 1 Jun 2015 17:08:46 +0300 Subject: [PATCH 085/397] Add IResourceServiceProvider interface --- angularjs/angular-resource-tests.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index 148d40901..189eec3c5 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -135,4 +135,11 @@ mod = mod.factory('factory name', resourceServiceFactoryFunction); /////////////////////////////////////// // IResource -/////////////////////////////////////// \ No newline at end of file +/////////////////////////////////////// + + +/////////////////////////////////////// +// IResourceServiceProvider +/////////////////////////////////////// +var resourceServiceProvider: angular.resource.IResourceServiceProvider; +resourceServiceProvider.defaults.stripTrailingSlashes = false; From 64d5b5286f6c15426ce4d4e0e535b85ddfc33629 Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Mon, 1 Jun 2015 17:14:39 +0300 Subject: [PATCH 086/397] AngularJS: IActionDescriptor test new url parameter --- angularjs/angular-resource-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index 189eec3c5..f7f248ea8 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -8,6 +8,7 @@ interface IMyResourceClass extends angular.resource.IResourceClass /////////////////////////////////////// var actionDescriptor: angular.resource.IActionDescriptor; +actionDescriptor.url = '/api/test-url/' actionDescriptor.headers = { header: 'value' }; actionDescriptor.isArray = true; actionDescriptor.method = 'method action'; From 0af334e2c9e088838c33ee3b09172c986fe8d54a Mon Sep 17 00:00:00 2001 From: "Bogdan I. Bursuc" Date: Mon, 1 Jun 2015 17:28:16 +0300 Subject: [PATCH 087/397] ICurrentRoute.locals will also contain any resolved values --- angularjs/angular-route.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index 4ddf87cab..662b2c11d 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -109,6 +109,7 @@ declare module angular.route { // see http://docs.angularjs.org/api/ng.$route#current interface ICurrentRoute extends IRoute { locals: { + [index: string]: any; $scope: IScope; $template: string; }; From a6e165ec11d827fe22550c9af868b29e67b9e5b7 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Mon, 1 Jun 2015 11:53:49 -0400 Subject: [PATCH 088/397] Add _.mapObject --- underscore/underscore-tests.ts | 4 ++++ underscore/underscore.d.ts | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 60c1708d0..d530a4334 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -182,6 +182,10 @@ _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name'); _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age'); _.omit({ name: 'moe', age: 50, userid: 'moe1' }, ['name', 'age']); +_.mapObject({ a: 1, b: 2 }, val => val * 2) === _.mapObject({ a: 2, b: 4 }, _.identity); +_.mapObject({ a: 1, b: 2 }, (val, key, o) => o[key] * 2) === _.mapObject({ a: 2, b: 4}, _.identity); +_.mapObject({ x: "string 1", y: "string 2" }, 'length') === _.mapObject({ x: "string 1", y: "string 2"}, _.property('length')); + var iceCream = { flavor: "chocolate" }; _.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" }); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 03088bffd..653d3ea07 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1170,6 +1170,31 @@ interface UnderscoreStatic { * @return List of all the values on `object`. **/ values(object: any): any[]; + + /** + * Like map, but for objects. Transform the value of each property in turn. + * @param object The object to transform + * @param iteratee The function that transforms property values + * @param context The optional context (value of `this`) to bind to + * @return a new _.Dictionary of property values + */ + mapObject(object: _.Dictionary, iteratee: (val: T, key: string, object: _.Dictionary) => U, context?: any): _.Dictionary; + + /** + * Like map, but for objects. Transform the value of each property in turn. + * @param object The object to transform + * @param iteratee The function that tranforms property values + * @param context The optional context (value of `this`) to bind to + */ + mapObject(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary; + + /** + * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property + * @param object The object to transform + * @param iteratee The property name to retrieve + * @param context The optional context (value of `this`) to bind to + */ + mapObject(object: any, iteratee: string, context?: any): _.Dictionary; /** * Convert an object into a list of [key, value] pairs. From b0371ddc3fdb94af90655e55f5f26d0bd3c3c039 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Mon, 1 Jun 2015 14:41:33 -0700 Subject: [PATCH 089/397] Changed the MDPalette definition to use a union. --- angular-material/angular-material.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 1517c295f..1383b0beb 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -150,8 +150,8 @@ declare module angular.material { A400?: string; A700?: string; contrastDefaultColor?: string; - contrastDarkColors?: string[]; - contrastLightColors?: string[]; + contrastDarkColors?: string|string[]; + contrastLightColors?: string|string[]; } interface MDThemeHues { From 499811255bde78f457a50f1595746b90ca17131b Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Tue, 2 Jun 2015 01:34:08 -0400 Subject: [PATCH 090/397] initial commit --- node-calendar/.gitignore | 4 + node-calendar/node-calendar-tests.ts | 126 +++++++++++++ node-calendar/node-calendar.d.ts | 271 +++++++++++++++++++++++++++ node-calendar/package.json | 14 ++ 4 files changed, 415 insertions(+) create mode 100644 node-calendar/.gitignore create mode 100644 node-calendar/node-calendar-tests.ts create mode 100755 node-calendar/node-calendar.d.ts create mode 100755 node-calendar/package.json diff --git a/node-calendar/.gitignore b/node-calendar/.gitignore new file mode 100644 index 000000000..76136c9e9 --- /dev/null +++ b/node-calendar/.gitignore @@ -0,0 +1,4 @@ +*.js +tsconfig.json +node_modules +.settings \ No newline at end of file diff --git a/node-calendar/node-calendar-tests.ts b/node-calendar/node-calendar-tests.ts new file mode 100644 index 000000000..5a4a40a46 --- /dev/null +++ b/node-calendar/node-calendar-tests.ts @@ -0,0 +1,126 @@ +/// +/// + +import node_calendar = require('node-calendar'); + +var cal = new node_calendar.Calendar(node_calendar.SUNDAY); + +assert(cal.getfirstweekday() == node_calendar.SUNDAY); + +cal.setfirstweekday(node_calendar.MONDAY); + +assert(cal.getfirstweekday() == node_calendar.MONDAY); + +assert(node_calendar.MONDAY == 0); +assert(node_calendar.TUESDAY == 1); +assert(node_calendar.WEDNESDAY == 2); +assert(node_calendar.THURSDAY == 3); +assert(node_calendar.FRIDAY == 4); +assert(node_calendar.SATURDAY == 5); +assert(node_calendar.SUNDAY == 6); + +assert(node_calendar.day_name[node_calendar.MONDAY] == 'Monday'); +assert(node_calendar.day_name[node_calendar.TUESDAY] == 'Tuesday'); +assert(node_calendar.day_name[node_calendar.WEDNESDAY] == 'Wednesday'); +assert(node_calendar.day_name[node_calendar.THURSDAY] == 'Thursday'); +assert(node_calendar.day_name[node_calendar.FRIDAY] == 'Friday'); +assert(node_calendar.day_name[node_calendar.SATURDAY] == 'Saturday'); +assert(node_calendar.day_name[node_calendar.SUNDAY] == 'Sunday'); + +assert(node_calendar.day_abbr[node_calendar.MONDAY] == 'Mon'); +assert(node_calendar.day_abbr[node_calendar.TUESDAY] == 'Tue'); +assert(node_calendar.day_abbr[node_calendar.WEDNESDAY] == 'Wed'); +assert(node_calendar.day_abbr[node_calendar.THURSDAY] == 'Thu'); +assert(node_calendar.day_abbr[node_calendar.FRIDAY] == 'Fri'); +assert(node_calendar.day_abbr[node_calendar.SATURDAY] == 'Sat'); +assert(node_calendar.day_abbr[node_calendar.SUNDAY] == 'Sun'); + +assert(node_calendar.JANUARY == 1); +assert(node_calendar.FEBRUARY == 2); +assert(node_calendar.MARCH == 3); +assert(node_calendar.APRIL == 4); +assert(node_calendar.MAY == 5); +assert(node_calendar.JUNE == 6); +assert(node_calendar.JULY == 7); +assert(node_calendar.AUGUST == 8); +assert(node_calendar.SEPTEMBER == 9); +assert(node_calendar.OCTOBER == 10); +assert(node_calendar.NOVEMBER == 11); +assert(node_calendar.DECEMBER == 12); + +assert(node_calendar.month_name[0] == ''); +assert(node_calendar.month_name[node_calendar.JANUARY] == 'January'); +assert(node_calendar.month_name[node_calendar.FEBRUARY] == 'February'); +assert(node_calendar.month_name[node_calendar.MARCH] == 'March'); +assert(node_calendar.month_name[node_calendar.APRIL] == 'April'); +assert(node_calendar.month_name[node_calendar.MAY] == 'May'); +assert(node_calendar.month_name[node_calendar.JUNE] == 'June'); +assert(node_calendar.month_name[node_calendar.JULY] == 'July'); +assert(node_calendar.month_name[node_calendar.AUGUST] == 'August'); +assert(node_calendar.month_name[node_calendar.SEPTEMBER] == 'September'); +assert(node_calendar.month_name[node_calendar.OCTOBER] == 'October'); +assert(node_calendar.month_name[node_calendar.NOVEMBER] == 'November'); +assert(node_calendar.month_name[node_calendar.DECEMBER] == 'December'); + +assert(node_calendar.month_abbr[0] == ''); +assert(node_calendar.month_abbr[node_calendar.JANUARY] == 'Jan'); +assert(node_calendar.month_abbr[node_calendar.FEBRUARY] == 'Feb'); +assert(node_calendar.month_abbr[node_calendar.MARCH] == 'Mar'); +assert(node_calendar.month_abbr[node_calendar.APRIL] == 'Apr'); +assert(node_calendar.month_abbr[node_calendar.MAY] == 'May'); +assert(node_calendar.month_abbr[node_calendar.JUNE] == 'Jun'); +assert(node_calendar.month_abbr[node_calendar.JULY] == 'Jul'); +assert(node_calendar.month_abbr[node_calendar.AUGUST] == 'Aug'); +assert(node_calendar.month_abbr[node_calendar.SEPTEMBER] == 'Sep'); +assert(node_calendar.month_abbr[node_calendar.OCTOBER] == 'Oct'); +assert(node_calendar.month_abbr[node_calendar.NOVEMBER] == 'Nov'); +assert(node_calendar.month_abbr[node_calendar.DECEMBER] == 'Dec'); + +cal.itermonthdates(2015, node_calendar.JANUARY).forEach(assertIsDate); +cal.itermonthdays(2014, node_calendar.FEBRUARY).forEach(assertIsNumber); +cal.itermonthdays2(2013, node_calendar.MARCH).forEach(assertDayOfWeekMonth); +cal.iterweekdays().forEach(assertIsNumber); + +assertMonthGrid(cal.monthdatescalendar(2012, node_calendar.APRIL), assertIsDate); +assertMonthGrid(cal.monthdays2calendar(2011, node_calendar.MAY), assertDayOfWeekMonth); +assertMonthGrid(cal.monthdayscalendar(2010, node_calendar.JUNE), assertIsNumber); + +assertYearGrid(cal.yeardatescalendar(2009, 3), assertIsDate); +assertYearGrid(cal.yeardays2calendar(2008, 2), assertDayOfWeekMonth); +assertYearGrid(cal.yeardayscalendar(2007, 4), assertIsNumber); + +function assertIsDate(d: Date) { + assert(d instanceof Date, 'Should be a date'); +} + +function assertIsNumber(n: number) { + assert(typeof n == 'number', 'Should be a number'); +} + +function assertDayOfWeekMonth(d: IDayOfWeekMonth) { + assert(d instanceof Array, 'Day of weak/month should be an array'); + assert(d.length == 2, 'Day of weak/month array should contain 2 items'); + assert(typeof d[0] == 'number', 'Day of month should be a number'); + assert(typeof d[1] == 'number', 'Day of week should be a number'); +} + +function assertWeekRow(row: IWeekRow, assertItemType: (item: T) => void) { + row.forEach(assertItemType); +} + +function assertMonthGrid(grid: IMonthGrid, assertItemType: (item: T) => void) { + grid.forEach(wr => assertWeekRow(wr, assertItemType)); +} + +function assertMonthRow(row: IMonthRow, assertItemType: (item: T) => void) { + row.forEach(mg => assertMonthGrid(mg, assertItemType)); +} + +function assertYearGrid(grid: IYearGrid, assertItemType: (item: T) => void) { + grid.forEach(mr => assertMonthRow(mr, assertItemType)); +} + +function assert(condition: boolean, msg?: string): void { + if (condition) return; + throw new Error(msg); +} \ No newline at end of file diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts new file mode 100755 index 000000000..a1c3f0500 --- /dev/null +++ b/node-calendar/node-calendar.d.ts @@ -0,0 +1,271 @@ +// Type definitions for node-calendar v0.1.4 +// Project: https://www.npmjs.com/package/node-calendar +// Definitions by: Luzian Zagadinow +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface IDayOfWeekMonth extends Array { + /** dayOfMonth */ + 0: number; + + /** dayOfWeek */ + 1: number; +} + +interface IWeekRow extends Array { + [dayIndex: number]: T; +} + +interface IMonthGrid extends Array> { + [weekRowIndex: number]: IWeekRow; +} + +interface IMonthRow extends Array> { + [monthColumnIndex: number]: IMonthGrid; +} + +interface IYearGrid extends Array>{ + [monthRowIndex: number]: IMonthRow; +} + +/** + * This module allows you to output calendars like the Unix cal program, and provides + * additional useful functions related to the calendar. By default, these calendars + * have Monday as the first day of the week, and Sunday as the last (the European + * convention). Use setfirstweekday() to set the first day of the week to Sunday + * (6) or to any other weekday. Parameters that specify dates are given as integers. + */ +declare module 'node-calendar' { + /** 0 */ + export var MONDAY: number; + + /** 1 */ + export var TUESDAY: number; + + /** 2 */ + export var WEDNESDAY: number; + + /** 3 */ + export var THURSDAY: number; + + /** 4 */ + export var FRIDAY: number; + + /** 5 */ + export var SATURDAY: number; + + /** 6 */ + export var SUNDAY: number; + + + /** 1 */ + export var JANUARY: number; + + /** 2 */ + export var FEBRUARY: number; + + /** 3 */ + export var MARCH: number; + + /** 4 */ + export var APRIL:number; + + /** 5 */ + export var MAY: number; + + /** 6 */ + export var JUNE: number; + + /** 7 */ + export var JULY: number; + + /** 8 */ + export var AUGUST: number; + + /** 9 */ + export var SEPTEMBER: number; + + /** 10 */ + export var OCTOBER: number; + + /** 11 */ + export var NOVEMBER: number; + + /** 12 */ + export var DECEMBER: number; + + /** + * [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] + */ + export var day_name: string[]; + + /** + * [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ] + */ + export var day_abbr: string[]; + + /** + * [ '', 'January', 'February', 'March', + * 'April', 'May', 'June', 'July', 'August', + * 'September', 'October', 'November', 'December' ] + */ + export var month_name: string[]; + + /** + * [ '', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + * 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] + */ + export var month_abbr: string[]; + + /** + * Base calendar class. This class doesn't do any formatting. It simply provides + * data to subclasses. + */ + export class Calendar { + /** + * @param {number} firstweekday + * Numerical day of the week the calendar weeks should start. + * (0=MON, 1=TUE, ...) Default: 0 + */ + constructor(firstweekday?: number); + + /** + * Numerical day of the week the calendar weeks should start. + * (0=MON, 1=TUE, ...) + * + * @method getfirstweekday + */ + getfirstweekday(): number; + + /** + * Numerical day of the week the calendar weeks should start. + * (0=MON, 1=TUE, ...) + * + * @param {number} firstweekday + * Numerical day of the week the calendar weeks should start. + * (0=MON, 1=TUE, ...) Default: 0 + */ + setfirstweekday(firstweekday: number): void; + + /** + * One week of weekday numbers starting with the configured first one. + */ + iterweekdays(): number[]; + + /** + * Dates for one month. The array will contain Date values and will always + * iterate through complete weeks, so it will yield dates outside the + * specified month. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} month + * Month for which the calendar should be generated. + */ + itermonthdates(year: number, month: number): Date[]; + + /** + * Like itermonthdates(), but will yield day numbers. For days outside + * the specified month the day number is 0. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} month + * Month for which the calendar should be generated. + */ + itermonthdays(year: number, month: number): number[]; + + /** + * Like itermonthdates(), but will yield [day number, weekday number] + * arrays. For days outside the specified month the day number is 0. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} month + * Month for which the calendar should be generated. + */ + itermonthdays2(year: number, month: number): IDayOfWeekMonth[]; + + /** + * A matrix (array of array) representing a month's calendar. + * Each row represents a week; week entries are Date values. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} month + * Month for which the calendar should be generated. + */ + monthdatescalendar(year: number, month: number): IMonthGrid; + + /** + * A matrix representing a month's calendar. Each row represents a week; + * days outside this month are zero. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} month + * Month for which the calendar should be generated. + */ + monthdayscalendar(year: number, month: number): IMonthGrid; + + /** + * Return a matrix representing a month's calendar. Each row represents + * a week; week entries are [day number, weekday number] arrays. Day numbers + * outside this month are zero. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} month + * Month for which the calendar should be generated. + */ + monthdays2calendar(year: number, month: number): IMonthGrid; + + /** + * The specified year ready for formatting. The return value is an array + * of month rows. Each month row contains up to width months. Each month + * contains between 4 and 6 weeks and each week contains 1-7 days. Days + * are Date objects. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} width + * The number of months to include in each row. Default: 3 + */ + yeardatescalendar(year: number, width?: number): IYearGrid; + + /** + * the specified year ready for formatting (similar to yeardatescalendar()). + * Entries in the week arrays are day numbers. Day numbers outside this + * month are zero. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} width + * The number of months to include in each row. Default: 3 + */ + yeardayscalendar(year: number, width?: number): IYearGrid; + + /** + * The specified year ready for formatting (similar to yeardatescalendar()). + * Entries in the week arrays are [day number, weekday number] arrays. + * Day numbers outside this month are zero. + * + * @param {number} year + * Year for which the calendar should be generated. + * @param {number} width + * The number of months to include in each row. Default: 3 + */ + yeardays2calendar(year: number, width?: number): IYearGrid; + } + + // Undocumented + //export function isleap(year: number): boolean; + //export function leapdays(beginYear: number, endYear: number): number; + //export function monthrange(year: number, month: number): number[]; + //export function weekday(year: number, month: number, day: number): number; + //export function timegm(dateParams: number[]): number; + //export function IllegalLocaleError(): Error; + //export function IllegalDayError(): Error; + //export function IllegalMonthError(): Error; + //export function IllegalTimeError(): Error; + //export function IllegalWeekdayError(): Error; +} \ No newline at end of file diff --git a/node-calendar/package.json b/node-calendar/package.json new file mode 100755 index 000000000..8cc162a95 --- /dev/null +++ b/node-calendar/package.json @@ -0,0 +1,14 @@ +{ + "name": "node-calendar.d.ts", + "version": "0.0.1", + "description": "Type definitions for node-calendar v0.1.4", + "main": "node-calendar-tests", + "scripts": { + "test": "node node-calendar-tests" + }, + "author": "Luzian Zagadinow (https://github.com/luzianz)", + "license": "MIT", + "dependencies": { + "node-calendar": "^0.1.4" + } +} \ No newline at end of file From 78deea6ba8f69456d58dcc14099136f73bc7b715 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Tue, 2 Jun 2015 17:28:20 +1000 Subject: [PATCH 091/397] Syntax for modernComponent Is this test valid @pspeter3? Regarding : https://github.com/Asana/typed-react/commit/9008be2f41c56bdd975213a08c97f1847333b15d --- react/react-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/react/react-tests.ts b/react/react-tests.ts index 2802a34cd..64b59e195 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -150,6 +150,8 @@ var classicComponent: React.ClassicComponent = React.render(classicElement, container); var domComponent: React.DOMComponent = React.render(domElement, container); +var modernComponent = + React.render(React.createElement(ModernComponent, props), container); // Other Top-Level API var unmounted: boolean = React.unmountComponentAtNode(container); From 7026f99eebbca5fe5d35741538a54e089b83f97b Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Tue, 2 Jun 2015 11:03:45 +0200 Subject: [PATCH 092/397] Add UNSTARTED to PlayerState See docs: https://developers.google.com/youtube/iframe_api_reference --- youtube/youtube.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index d7e52ae17..0add84b79 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -150,10 +150,11 @@ declare module YT { } export enum PlayerState { + UNSTARTED, BUFFERING, CUED, ENDED, PAUSED, PLAYING } -} \ No newline at end of file +} From 93a0bd7d5083d63eb5ac702ee9081fa5032f018e Mon Sep 17 00:00:00 2001 From: Graham Mendick Date: Tue, 2 Jun 2015 10:21:55 +0100 Subject: [PATCH 093/397] Added Navigation typings and tests --- navigation/navigation-tests.ts | 117 +++++ navigation/navigation.d.ts | 847 +++++++++++++++++++++++++++++++++ 2 files changed, 964 insertions(+) create mode 100644 navigation/navigation-tests.ts create mode 100644 navigation/navigation.d.ts diff --git a/navigation/navigation-tests.ts b/navigation/navigation-tests.ts new file mode 100644 index 000000000..e0871a267 --- /dev/null +++ b/navigation/navigation-tests.ts @@ -0,0 +1,117 @@ +/// + +// History Manager +class LogHistoryManager extends Navigation.HashHistoryManager { + addHistory(state: Navigation.State, url: string) { + console.log('add history'); + super.addHistory(state, url); + } +} + +// State Router +class LogStateRouter extends Navigation.StateRouter { + getData(route: string): { state: Navigation.State; data: any } { + console.log('get data'); + return super.getData(route); + } +} + +// Settings +Navigation.settings.router = new LogStateRouter(); +Navigation.settings.historyManager = new LogHistoryManager(); +Navigation.settings.stateIdKey = 'state'; + +// Configuration +Navigation.StateInfoConfig.build([ + { key: 'home', initial: 'page', states: [ + { key: 'page', route: '' } + ]}, + { key: 'person', initial: 'list', states: [ + { key: 'list', route: 'people/{page}', transitions: [ + { key: 'select', to: 'details' } + ], defaults: { page: 1 }, trackCrumbTrail: false }, + { key: 'details', route: 'person/{id}', defaultTypes: { id: 'number' } } + ]} +]); + +// StateInfo +var dialogs = Navigation.StateInfoConfig.dialogs; +var home = dialogs['home']; +var homePage = home.states['page']; +var homeKey = home.key; +var homePageKey = homePage.key; +homePage = home.initial; +var person = dialogs['person']; +var personList = person.states['list']; +var personDetails = person.states['details']; +var personListSelect = personList.transitions['select']; +personList = personListSelect.parent; +personDetails = personListSelect.to; +var pageDefault = personList.defaults.page; +var idDefaultType = personDetails.defaultTypes.id; + +// StateNavigator +personList.dispose = () => {}; +personList.navigating = (data, url, navigate) => { + navigate(); +}; +personList.navigated = (data) => {}; + +// State Handler +class LogStateHandler extends Navigation.StateHandler { + getNavigationData(state: Navigation.State, url: string): any { + console.log('get navigation data'); + super.getNavigationData(state, url); + } +} +homePage.stateHandler = new LogStateHandler(); +personList.stateHandler = new LogStateHandler(); +personDetails.stateHandler = new LogStateHandler(); + +// Navigation Event +var navigationListener = +(oldState: Navigation.State, state: Navigation.State, data: any) => { + Navigation.StateController.offNavigate(navigationListener); +}; +Navigation.StateController.onNavigate(navigationListener); + +// Navigation +Navigation.start('home'); +Navigation.StateController.navigate('person'); +Navigation.StateController.refresh(); +Navigation.StateController.refresh({ page: 2 }); +Navigation.StateController.navigate('select', { id: 10 }); +var canGoBack: boolean = Navigation.StateController.canNavigateBack(1); +Navigation.StateController.navigateBack(1); + +// Navigation Link +var link = Navigation.StateController.getNavigationLink('person'); +link = Navigation.StateController.getRefreshLink(); +link = Navigation.StateController.getRefreshLink({ page: 2 }); +link = Navigation.StateController.getNavigationLink('select', { id: 10 }); +var nextDialog = Navigation.StateController.getNextState('select').parent; +person = nextDialog; +Navigation.StateController.navigateLink(link); +link = Navigation.StateController.getNavigationBackLink(1); +var crumb = Navigation.StateController.crumbs[0]; +link = crumb.navigationLink; + +// StateContext +Navigation.StateController.navigate('home'); +Navigation.StateController.navigate('person'); +home = Navigation.StateContext.previousDialog; +homePage = Navigation.StateContext.previousState; +person === Navigation.StateContext.dialog; +personList === Navigation.StateContext.state; +var url: string = Navigation.StateContext.url; +var page: number = Navigation.StateContext.data.page; + +// Navigation Data +Navigation.StateController.refresh({ page: 2 }); +var data = Navigation.StateContext.includeCurrentData({ sort: 'name' }, ['page']); +Navigation.StateController.refresh(data); +Navigation.StateContext.clear('sort'); +var data = Navigation.StateContext.includeCurrentData({ pageSize: 10 }); +Navigation.StateController.refresh(data); +Navigation.StateContext.clear(); +Navigation.StateController.refresh(); diff --git a/navigation/navigation.d.ts b/navigation/navigation.d.ts new file mode 100644 index 000000000..7cb830897 --- /dev/null +++ b/navigation/navigation.d.ts @@ -0,0 +1,847 @@ +// Type definitions for Navigation 1.0 +// Project: http://grahammendick.github.io/navigation/ +// Definitions by: Graham Mendick +// Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module 'navigation' { + export = Navigation; +} + +declare module Navigation { + /** + * Defines a contract a class must implement in order to represent a + * logical grouping of child State elements. Navigating across different + * dialogs will initialise the crumb trail + */ + interface IDialog { + /** + * Gets the State children + */ + states: TStates; + /** + * Gets the state to navigate to if the Key is passed as an action + * parameter to the StateController + */ + initial: TState; + /** + * Gets the key, unique across dialogs, which is passed as the action + * parameter to the StateController when navigating + */ + key: string; + /** + * Gets the textual description of the dialog + */ + title?: string; + } + + /** + * Defines a contract a class must implement in order to configure state + * information. A child of a Dialog element, it represents the endpoint of + * a navigation + */ + interface IState { + /** + * Gets the Transition children + */ + transitions?: TTransitions; + /** + * Gets the key, unique within a Parent, used by Dialog and Transition + * elements to specify navigation configuration + */ + key: string; + /** + * Gets the default NavigationData for this State + */ + defaults?: any; + /** + * Gets the default NavigationData Types for this State + */ + defaultTypes?: any; + /** + * Gets the textual description of the state + */ + title?: string; + /** + * Gets the route Url pattern + */ + route: string; + /** + * Gets a value that indicates whether to maintain crumb trail + * information e.g PreviousState. This can be used together with Route + * to produce user friendly Urls + */ + trackCrumbTrail?: boolean; + } + + /** + * Defines a contract a class must implement in order to configure + * transition information. A child of a State element it represents a + * possible navigation from its Parent to a sibling State + */ + interface ITransition { + /** + * Gets the state to navigate to if the Key is passed as an action + * parameter to the StateController + */ + to: TState; + /** + * Gets the key, unique within a Parent, which is passed as the action + * parameter to the StateController when navigating + */ + key: string; + } + + /** + * Configures dialog information. Represents a logical grouping of child + * State elements. Navigating across different dialogs will initialise the + * crumb trail + */ + class Dialog implements IDialog { + /** + * Gets the State children by index + */ + _states: State[]; + /** + * Gets the State children + */ + states: { + [index: string]: State; + }; + /** + * Gets the number of the dialog + */ + index: number; + /** + * Gets the state to navigate to if the Key is passed as an action + * parameter to the StateController + */ + initial: State; + /** + * Gets the key, unique across dialogs, which is passed as the action + * parameter to the StateController when navigating + */ + key: string; + /** + * Gets the textual description of the dialog + */ + title: string; + } + + /** + * Configures state information. A child of a Dialog element, it + * represents the endpoint of a navigation + */ + class State implements IState<{ [index: string]: Transition; }> { + /** + * Gets the Transition children by index + */ + _transitions: Transition[]; + /** + * Gets the Transition children + */ + transitions: { + [index: string]: Transition; + }; + /** + * Gets the parent Dialog configuration item + */ + parent: Dialog; + /** + * Gets the number of the state within its Parent + */ + index: number; + /** + * Gets the unique identifier for this State + */ + id: string; + /** + * Gets the key, unique within a Parent, used by Dialog and Transition + * elements to specify navigation configuration + */ + key: string; + /** + * Gets the default NavigationData for this State + */ + defaults: any; + /** + * Gets the default NavigationData Types for this State + */ + defaultTypes: any; + /** + * Gets the formatted default NavigationData for this State + */ + formattedDefaults: any; + /** + * Gets the textual description of the state + */ + title: string; + /** + * Gets the route Url pattern + */ + route: string; + /** + * Gets a value that indicates whether to maintain crumb trail + * information e.g PreviousState. This can be used together with Route + * to produce user friendly Urls + */ + trackCrumbTrail: boolean; + /** + * Gets or sets the IStateHandler responsible for building and parsing + * avigation links to this State + */ + stateHandler: IStateHandler; + /** + * Called on the old State (this is not the same as the previous + * State) after navigating to a different State + */ + dispose: () => void; + /** + * Called on the current State after navigating to it + * @param data The current NavigationData + */ + navigated: (data: any) => void; + /** + * Called on the new State before navigating to it + * @param data The new NavigationData + * @param url The new target location + * @param navigate The function to call to continue to navigate + */ + navigating: (data: any, url: string, navigate: () => void) => void; + } + + /** + * Configures transition information. A child of a State element it + * represents a possible navigation from its Parent to a sibling State + */ + class Transition implements ITransition { + /** + * Gets the state to navigate to if the Key is passed as an action + * parameter to the StateController + */ + to: State; + /** + * Gets the parent State configuration item + */ + parent: State; + /** + * Gets the number of the transition within its Parent + */ + index: number; + /** + * Gets the key, unique within a Parent, which is passed as the action + * parameter to the StateController when navigating + */ + key: string; + } + + /** + * Provides static access to the Dialog, State and Transition configuration + */ + class StateInfoConfig { + /** + * Gets a collection of Dialog information, by index, with their child + * State information and grandchild Transition information + */ + static _dialogs: Dialog[]; + /** + * Gets a collection of Dialog information with their child State + * information and grandchild Transition information + */ + static dialogs: { + [index: string]: Dialog; + }; + /** + * Builds the Dialog, State and Transition configuration + * @param dialogs A collection of Dialog information with their child + * State information and grandchild Transition information + */ + static build(dialogs: IDialog[]>[]>[]): void; + } + + /** + * Defines a contract a class must implement in order to manage the browser + * Url + */ + interface IHistoryManager { + /** + * Gets or sets a value indicating whether to disable browser history + */ + disabled: boolean; + /** + * Registers browser history event listeners + */ + init(): any; + /** + * Adds browser history + * @param state The State navigated to + * @param url The current url + */ + addHistory(state: State, url: string): void; + /** + * Gets the current location + */ + getCurrentUrl(): string; + /** + * Gets an Href from the url + */ + getHref(url: string): string; + /** + * Gets a Url from the anchor + */ + getUrl(anchor: HTMLAnchorElement): string; + } + + /** + * Manages history using the browser Url's hash. If used in a browser + * without the hashchange event or outside of a browser environment, then + * history is disabled + */ + class HashHistoryManager implements IHistoryManager { + /** + * Gets or sets a value indicating whether to disable browser history. + * Set to true if used in a browser without the hashchange event or + * outside of a browser environment + */ + disabled: boolean; + /** + * Gets or sets a value indicating whether to use '#' in place of '?' + * in Urls. Set to true for Internet explorer 6 and 7 support + */ + replaceQueryIdentifier: boolean; + /** + * Registers a listener for the hashchange event + */ + init(): void; + /** + * Sets the browser Url's hash to the url + * @param state The State navigated to + * @param url The current url + */ + addHistory(state: State, url: string): void; + /** + * Gets the current location + */ + getCurrentUrl(): string; + /** + * Gets an Href from the url + */ + getHref(url: string): string; + /** + * Gets a Url from the anchor + */ + getUrl(anchor: HTMLAnchorElement): string; + } + + /** + * Manages history using the HTML5 history api. If used in a browser + * without the HTML5 history api or outside of a browser environment, then + * history is disabled + */ + class HTML5HistoryManager implements IHistoryManager { + /** + * Gets or sets a value indicating whether to disable browser history. + * Set to true if used in a browser without the HTML5 history api or + * outside of a browser environment + */ + disabled: boolean; + /** + * Registers a listener for the popstate event + */ + init(): void; + /** + * Sets the browser Url to the url using pushState + * @param state The State navigated to + * @param url The current url + */ + addHistory(state: State, url: string): void; + /** + * Gets the current location + */ + getCurrentUrl(): string; + /** + * Gets an Href from the url + */ + getHref(url: string): string; + /** + * Gets a Url from the anchor + */ + getUrl(anchor: HTMLAnchorElement): string; + } + + /** + * Defines a contract a class must implement in order to build and parse + * navigation links + */ + interface IStateHandler { + /** + * Gets a link that navigates to the state passing the data + * @param state The State to navigate to + * @param data The data to pass when navigating + * @returns The navigation link + */ + getNavigationLink(state: State, data: any): string; + /** + * Navigates to the url + * @param oldState The current State + * @param state The State to navigate to + * @param url The target location + */ + navigateLink(oldState: State, state: State, url: string): void; + /** + * Gets the data parsed from the url + * @param state The State navigated to + * @param url The current url + * @returns The navigation data + */ + getNavigationData(state: State, url: string): any; + /** + * Truncates the crumb trail + * @param The State navigated to + * @param The Crumb collection representing the crumb trail + * @returns Truncated crumb trail + */ + truncateCrumbTrail(state: State, crumbs: Crumb[]): Crumb[]; + } + + /** + * Represents one piece of the crumb trail and holds the information need + * to return to and recreate the State as previously visited. In a single + * crumb trail no two crumbs can have the same State but all must have the + * same Dialog + */ + class Crumb { + /** + * Gets the Context Data held at the time of navigating away from this + * State + */ + data: any; + /** + * Gets the configuration information associated with this navigation + */ + state: State; + /** + * Gets a value indicating whether the Crumb is the last in the crumb + * trail + */ + last: boolean; + /** + * Gets the State Title + */ + title: string; + /** + * Gets the hyperlink navigation to return to the State and pass the + * associated Data + */ + navigationLink: string; + /** + * Initializes a new instance of the Crumb class + */ + constructor(data: any, state: State, link: string, last: boolean); + } + + /** + * Provides access to the Navigation Settings configuration + */ + class NavigationSettings { + router: IRouter; + historyManager: IHistoryManager; + /** + * Gets or sets the key that identifies the StateId + */ + stateIdKey: string; + /** + * Gets or sets the key that identifies the PreviousStateId + */ + previousStateIdKey: string; + /** + * Gets or sets the key that identifies the ReturnData + */ + returnDataKey: string; + /** + * Gets or sets the key that identifies the CrumbTrail + */ + crumbTrailKey: string; + /** + * Gets or sets the application path + */ + applicationPath: string; + } + + /** + * Provides static properties for accessing context sensitive navigation + * information. Holds the current State and NavigationData. Also holds the + * previous State (this is not the same as the previous Crumb) + */ + class StateContext { + /** + * Gets the State navigated away from to reach the current State + */ + static previousState: State; + /** + * Gets the parent of the PreviousState property + */ + static previousDialog: Dialog; + /** + * Gets the current State + */ + static state: State; + /** + * Gets the parent of the State property + */ + static dialog: Dialog; + /** + * Gets the NavigationData for the current State. It can be accessed. + * Will become the data stored in a Crumb when part of a crumb trail + */ + static data: any; + /** + * Gets the current Url + */ + static url: string; + /** + * Combines the data with all the current NavigationData + * @param The data to add to the current NavigationData + * @returns The combined data + */ + static includeCurrentData(data: any): any; + /** + * Combines the data with a subset of the current NavigationData + * @param The data to add to the current NavigationData + * @returns The combined data + */ + static includeCurrentData(data: any, keys: string[]): any; + /** + * Removes all items from the NavigationData + */ + static clear(): void; + /** + * Removes a single item from the NavigationData + * @param The key of the item to remove + */ + static clear(key: string): void; + } + + /** + * Manages all navigation. These can be forward using an action parameter; + * backward via a Crumb; or refreshing the current State + */ + class StateController { + /** + * Gets a Crumb collection representing the crumb trail, ordered oldest + * Crumb first + */ + static crumbs: Crumb[]; + /** + * Sets the Context Data with the data returned from the current + * State's IStateHandler + * @param state The current State + * @param url The current Url + */ + static setStateContext(state: State, url: string): void; + /** + * Registers a navigate event listener + * @param handler The navigate event listener + */ + static onNavigate(handler: (oldState: State, state: State, data: any) => void): void; + /** + * Unregisters a navigate event listener + * @param handler The navigate event listener + */ + static offNavigate(handler: (oldState: State, state: State, data: any) => void): void; + /** + * Navigates to a State. Depending on the action will either navigate + * to the 'to' State of a Transition or the 'initial' State of a + * Dialog. It passes no NavigationData + * @param action The key of a child Transition or the key of a Dialog + * @throws action does not match the key of a child Transition or the + * key of a Dialog; or there is NavigationData that cannot be converted + * to a String + * @throws A mandatory route parameter has not been supplied a value + */ + static navigate(action: string): void; + /** + * Navigates to a State. Depending on the action will either navigate + * to the 'to' State of a Transition or the 'initial' State of a + * Dialog + * @param action The key of a child Transition or the key of a Dialog + * @param toData The NavigationData to be passed to the next State and + * stored in the StateContext + * @throws action does not match the key of a child Transition or the + * key of a Dialog; or there is NavigationData that cannot be converted + * to a String + * @throws A mandatory route parameter has not been supplied a value + */ + static navigate(action: string, toData: any): void; + /** + * Gets a Url to navigate to a State. Depending on the action will + * either navigate to the 'to' State of a Transition or the 'initial' + * State of a Dialog. It passes no NavigationData + * @param action The key of a child Transition or the key of a Dialog + * @returns Url that will navigate to State specified in the action + * @throws action does not match the key of a child Transition or the + * key of a Dialog; or there is NavigationData that cannot be converted + * to a String + */ + static getNavigationLink(action: string): string; + /** + * Gets a Url to navigate to a State. Depending on the action will + * either navigate to the 'to' State of a Transition or the 'initial' + * State of a Dialog + * @param action The key of a child Transition or the key of a Dialog + * @param toData The NavigationData to be passed to the next State and + * stored in the StateContext + * @returns Url that will navigate to State specified in the action + * @throws action does not match the key of a child Transition or the + * key of a Dialog; or there is NavigationData that cannot be converted + * to a String + */ + static getNavigationLink(action: string, toData: any): string; + /** + * Determines if the distance specified is within the bounds of the + * crumb trail represented by the Crumbs collection + */ + static canNavigateBack(distance: number): boolean; + /** + * Navigates back to the Crumb contained in the crumb trail, + * represented by the Crumbs collection, as specified by the distance. + * In the crumb trail no two crumbs can have the same State but all + * must have the same Dialog + * @param distance Starting at 1, the number of Crumb steps to go back + * @throws canNavigateBack returns false for this distance + * @throws A mandatory route parameter has not been supplied a value + */ + static navigateBack(distance: number): void; + /** + * Gets a Url to navigate to a Crumb contained in the crumb trail, + * represented by the Crumbs collection, as specified by the distance. + * In the crumb trail no two crumbs can have the same State but all + * must have the same Dialog + * @param distance Starting at 1, the number of Crumb steps to go back + * @throws canNavigateBack returns false for this distance + */ + static getNavigationBackLink(distance: number): string; + /** + * Navigates to the current State passing no NavigationData + * @throws A mandatory route parameter has not been supplied a value + */ + static refresh(): void; + /** + * Navigates to the current State + * @param toData The NavigationData to be passed to the current State + * and stored in the StateContext + * @throws There is NavigationData that cannot be converted to a String + * @throws A mandatory route parameter has not been supplied a value + */ + static refresh(toData: any): void; + /** + * Gets a Url to navigate to the current State passing no + * NavigationData + */ + static getRefreshLink(): string; + /** + * Gets a Url to navigate to the current State + * @param toData The NavigationData to be passed to the current State + * and stored in the StateContext + * @returns Url that will navigate to the current State + * @throws There is NavigationData that cannot be converted to a String + */ + static getRefreshLink(toData: any): string; + /** + * Navigates to the url + * @param url The target location + */ + static navigateLink(url: string): void; + /** + * Gets the next State. Depending on the action will either return the + * 'to' State of a Transition or the 'initial' State of a Dialog + * @param action The key of a child Transition or the key of a Dialog + * @throws action does not match the key of a child Transition or the + * key of a Dialog + */ + static getNextState(action: string): State; + } + + /** + * Implementation of IStateHandler that builds and parses navigation links + */ + class StateHandler implements IStateHandler { + /** + * Gets a link that navigates to the state passing the data + * @param state The State to navigate to + * @param data The data to pass when navigating + * @returns The navigation link + */ + getNavigationLink(state: State, data: any): string; + /** + * Navigates to the url + * @param oldState The current State + * @param state The State to navigate to + * @param url The target location + */ + navigateLink(oldState: State, state: State, url: string): void; + /** + * Gets the data parsed from the url + * @param state The State navigated to + * @param url The current url + * @returns The navigation data + */ + getNavigationData(state: State, url: string): any; + /** + * Truncates the crumb trail whenever a repeated or initial State is + * encountered + * @param The State navigated to + * @param The Crumb collection representing the crumb trail + * @returns Truncated crumb trail + */ + truncateCrumbTrail(state: State, crumbs: Crumb[]): Crumb[]; + } + + /** + * Defines a contract a class must implement in order build and parse + * State routes + */ + interface IRouter { + /** + * Gets the matching State and data for the route + * @param route The route to match + * @returns The matched State and data + */ + getData(route: string): { state: State; data: any; }; + /** + * Gets the matching route and data for the state and data + * @param The state to match + * @param The data to match + * @returns The matched route and data + */ + getRoute(state: State, data: any): { route: string; data: any; }; + /** + * Gets or sets a value indicating whether the route matching supports + * default parameter values + */ + supportsDefaults: boolean; + /** + * Registers all route configuration information + * @param dialogs Collection of Dialogs with their child State route + * information + */ + addRoutes(dialogs: Dialog[]): void; + } + + /** + * Implementation of IRouter that builds and parses State routes using the + * Navigation Router + */ + class StateRouter implements IRouter { + /** + * Gets the underlying Navigation Router + */ + router: Router; + /** + * Gets true, indicating the underlying Navigation Router supports + * defaults + */ + supportsDefaults: boolean; + /** + * Gets the matching State and data for the route + * @param route The route to match + * @returns The matched State and data + */ + getData(route: string): { state: State; data: any; }; + /** + * Gets the matching route and data for the state and data + * @param The state to match + * @param The data to match + * @returns The matched route and data + */ + getRoute(state: State, data: any): { route: string; data: any; }; + /** + * Registers all route configuration information with the underlying + * Navigation Router + * @param dialogs Collection of Dialogs with their child State route + * information + */ + addRoutes(dialogs: Dialog[]): void; + } + + /** + * Holds information about a route + */ + class Route { + /** + * Gets the path pattern of a route + */ + path: string; + /** + * Gets the default parameter values + */ + defaults: any; + /** + * Gets the list of parameters + */ + params: { name: string; optional: boolean; }[]; + /** + * Initializes a new instance of the Route class + * @param path The route pattern + */ + constructor(path: string); + /** + * Initializes a new instance of the Route class + * @param path The route pattern + * @param defaults The default parameter values + */ + constructor(path: string, defaults: any); + /** + * Gets the matching data for the path + * @param path The path to match + * @returns The matched data or null if there's no match + */ + match(path: string): any; + /** + * Gets the route populated with default values + * @returns The built route + */ + build(): string; + /** + * Gets the route populated with data and default values + * @param The data for the route parameters + * @returns The built route + */ + build(data: any): string; + } + + /** + * The default Navigation router implementation + */ + class Router { + /** + * Registers a route + * @param path The route path + * @returns The parsed Route + */ + addRoute(path: string): Route; + /** + * Registers a route with default parameters + * @param path The route path + * @param defaults The route parameter defaults + * @returns The parsed Route + */ + addRoute(path: string, defaults: any): Route; + /** + * Gets the matching route and data for the path + * @param route The path to match + * @returns The matched route and data + */ + match(path: string): { route: Route; data: any; }; + } + + /** + * Gets the Navigation settings + */ + export var settings: NavigationSettings; + + /** + * Initializes the history manager and navigates to the current location. + * If used outside of a browser environment, pass in the Url to navigate to + * @param url If used outside of a browser, the url to navigate to + */ + export var start: (url?: string) => void; +} \ No newline at end of file From 9a8c66d5ac920c19a21fb70cb100eaf3e560d1b0 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Tue, 2 Jun 2015 11:24:36 +0200 Subject: [PATCH 094/397] Fix indentation --- youtube/youtube.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index 0add84b79..30580053f 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -150,7 +150,7 @@ declare module YT { } export enum PlayerState { - UNSTARTED, + UNSTARTED, BUFFERING, CUED, ENDED, From d4873ce3f5a4f19a5d88dbca32b8a0daea8385a4 Mon Sep 17 00:00:00 2001 From: Dave Keen Date: Tue, 2 Jun 2015 15:45:34 +0200 Subject: [PATCH 095/397] rx: added missing 'pairs' definition --- rx/rx-lite.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rx/rx-lite.d.ts b/rx/rx-lite.d.ts index 82221d633..c5034c3b7 100644 --- a/rx/rx-lite.d.ts +++ b/rx/rx-lite.d.ts @@ -589,6 +589,8 @@ declare module Rx { merge(scheduler: IScheduler, sources: Observable[]): Observable; merge(scheduler: IScheduler, sources: IPromise[]): Observable; + pairs(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>; + zip(first: Observable, sources: Observable[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; zip(first: Observable, sources: IPromise[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; zip(source1: Observable, source2: Observable, resultSelector: (item1: T1, item2: T2) => TResult): Observable; From 36bc838e4f30c1ccdd5a9530db5ba03f8f331b5d Mon Sep 17 00:00:00 2001 From: jpsfs Date: Tue, 2 Jun 2015 15:03:30 +0100 Subject: [PATCH 096/397] Add missing jasmine-jquery matchers and comments. --- jasmine-jquery/jasmine-jquery-tests.ts | 4 + jasmine-jquery/jasmine-jquery.d.ts | 248 ++++++++++++++++++++++++- 2 files changed, 250 insertions(+), 2 deletions(-) diff --git a/jasmine-jquery/jasmine-jquery-tests.ts b/jasmine-jquery/jasmine-jquery-tests.ts index ef6d8cc79..f6542c216 100644 --- a/jasmine-jquery/jasmine-jquery-tests.ts +++ b/jasmine-jquery/jasmine-jquery-tests.ts @@ -39,6 +39,10 @@ describe("Jasmine jQuery extension", () => { expect($('').focus()).toBeFocused(); //expect($form).toHandle("submit") //expect($form).toHandleWith("submit", yourSubmitCallback) + expect($('

')).toBeInDOM(); + expect($('
')).toContainElement('span.some-class'); + expect($('

    header

    ')).toContainHtml('
      '); + expect($('

        header

        ')).toContainText('header') }); it("Handles HTML Fixtures", () => { diff --git a/jasmine-jquery/jasmine-jquery.d.ts b/jasmine-jquery/jasmine-jquery.d.ts index e1ed6c3c0..dcff2d12c 100644 --- a/jasmine-jquery/jasmine-jquery.d.ts +++ b/jasmine-jquery/jasmine-jquery.d.ts @@ -81,39 +81,283 @@ declare module jasmine { } interface Matchers { + /** + * Check if DOM element has class. + * + * @param className Name of the class to check. + * + * @example + * // returns true + * expect($('
        ')).toHaveClass("some-class") + */ toHaveClass(className: string): boolean; - toHaveCss(css): boolean; + + /** + * Check if DOM element has the given CSS properties. + * + * @param css Object containing the properties (and values) to check. + * + * @example + * // returns true + * expect($('
        ')).toHaveCss({display: "none", margin: "10px"}) + * + * @example + * // returns true + * expect($('
        ')).toHaveCss({margin: "10px"}) + */ + toHaveCss(css: Object): boolean; + + /** + * Checks if DOM element is visible. + * Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero. + */ toBeVisible(): boolean; + /** + * Check if DOM element is hidden. + * Elements can be hidden for several reasons: + * - They have a CSS display value of none ; + * - They are form elements with type equal to hidden. + * - Their width and height are explicitly set to 0. + * - An ancestor element is hidden, so the element is not shown on the page. + */ toBeHidden(): boolean; + + /** + * Only for tags that have checked attribute + * + * @example + * // returns true + * expect($('')).toBeSelected() + */ toBeSelected(): boolean; + + /** + * Only for tags that have checked attribute + * @example + * // returns true + * expect($('')).toBeChecked() + */ toBeChecked(): boolean; + + /** + * Checks for child DOM elements or text + */ toBeEmpty(): boolean; + + /** + * Checks if element exists in or out the DOM. + */ toExist(): boolean; + + /** + * Checks if array has the given length. + * + * @param length Expected length + */ toHaveLength(length: number): boolean; + + /** + * Check if DOM element contains an attribute and, optionally, if the value of the attribute is equal to the expected one. + * + * @param attributeName Name of the attribute to check + * @param expectedAttributeValue Expected attribute value + */ toHaveAttr(attributeName: string, expectedAttributeValue?): boolean; + + /** + * Check if DOM element contains a property and, optionally, if the value of the property is equal to the expected one. + * + * @param propertyName Property name to check + * @param expectedPropertyValue Expected property value + */ toHaveProp(propertyName: string, expectedPropertyValue?): boolean; + + /** + * Check if DOM element has the given Id + * + * @param Id Expected identifier + */ toHaveId(id: string): boolean; + + /** + * Check if DOM element has the specified HTML. + * + * @example + * // returns true + * expect($('
        ')).toHaveHtml('') + */ toHaveHtml(html: string): boolean; + + /** + * Check if DOM element contains the specified HTML. + * + * @example + * // returns true + * expect($('

          header

          ')).toContainHtml('
            ') + */ //toContainHtml(html: string): boolean; + + /** + * Check if DOM element has the given Text. + * @param text Accepts a string or regular expression + * + * @example + * // returns true + * expect($('
            some text
            ')).toHaveText('some text') + */ toHaveText(text: string): boolean; + /** + * Check if DOM element contains the specified text. + * + * @example + * // returns true + * expect($('

              header

              ')).toContainText('header') + */ //toContainText(text: string): boolean; + + /** + * Check if DOM element has the given value. + * This can only be applied for element on with jQuery val() can be called. + * + * @example + * // returns true + * expect($('')).toHaveValue('some text') + */ toHaveValue(value): boolean; + + /** + * Check if DOM element has the given data. + * This can only be applied for element on with jQuery data(key) can be called. + * + */ toHaveData(key, expectedValue): boolean; toBe(selector: JQuery): boolean; + + /** + * Check if DOM element is matched by the given selector. + * + * @example + * // returns true + * expect($('
              ')).toContain('some-class') + */ toContain(selector: JQuery): boolean; + + /** + * Check if DOM element exists inside the given parent element. + * + * @example + * // returns true + * expect($('
              ')).toContainElement('span.some-class') + */ + toContainElement(selector: string): boolean; + + /** + * Check to see if the set of matched elements matches the given selector + * + * @example + * expect($('').addClass('js-something')).toBeMatchedBy('.js-something') + * + * @returns {Boolean} true if DOM contains the element + */ toBeMatchedBy(selector: string): boolean; + + /** + * Only for tags that have disabled attribute + * @example + * // returns true + * expect('').toBeDisabled() + */ toBeDisabled(): boolean; + + /** + * Check if DOM element is focused + * @example + * // returns true + * expect($('').focus()).toBeFocused() + */ toBeFocused(): boolean; - toHandle(event): boolean; + + /** + * Checks if DOM element handles event. + * + * @example + * // returns true + * expect($form).toHandle("submit") + */ + toHandle(eventName: string): boolean; + + /** + * Assigns a callback to an event of the DOM element. + * + * @param eventName Name of the event to assign the callback to. + * @param eventHandler Callback function to be assigned. + * + * @example + * expect($form).toHandleWith("submit", yourSubmitCallback) + */ toHandleWith(eventName: string, eventHandler): boolean; + /** + * Checks if event was triggered. + */ toHaveBeenTriggered(): boolean; + + /** + * Checks if the event has been triggered on selector. + * @param selector Selector that should have triggered the event. + */ toHaveBeenTriggeredOn(selector: string): boolean; + + /** + * Checks if the event has been triggered on selector. + * @param selector Selector that should have triggered the event. + * @param args Extra arguments to be passed to jQuery events functions. + */ toHaveBeenTriggeredOnAndWith(selector: string, ...args: any[]): boolean; + + /** + * Checks if event propagation has been prevented. + */ toHaveBeenPrevented(): boolean; + + /** + * Checks if event propagation has been prevented on element with selector. + * + * @param selector Selector that should have prevented the event. + */ toHaveBeenPreventedOn(selector: string): boolean; + + /** + * Checks if event propagation has been stopped. + * + * @example + * // returns true + * var spyEvent = spyOnEvent('#some_element', 'click') + * $('#some_element').click(function (event){event.stopPropagation();}) + * $('#some_element').click() + * expect(spyEvent).toHaveBeenStopped() + */ toHaveBeenStopped(): boolean; + + /** + * Checks if event propagation has been stopped by an element with the given selector. + * @param selector Selector of the element that should have stopped the event propagation. + * + * @example + * // returns true + * $('#some_element').click(function (event){event.stopPropagation();}) + * $('#some_element').click() + * expect('click').toHaveBeenStoppedOn('#some_element') + */ toHaveBeenStoppedOn(selector: string): boolean; + + /** + * Checks to see if the matched element is attached to the DOM. + * @example + * expect($('#id-name')[0]).toBeInDOM() + */ + toBeInDOM(): boolean; + } interface JQueryEventSpy { From e8ac76dbcf18f24ae50b8ac05aa8375952aabf6f Mon Sep 17 00:00:00 2001 From: Sobit Akhmedov Date: Tue, 2 Jun 2015 19:03:21 +0200 Subject: [PATCH 097/397] add optional() method to Validator interface --- express-validator/express-validator.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index 7fc04f70e..428c90afd 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -150,6 +150,10 @@ declare module ExpressValidator { * Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats */ isCreditCard(): Validator; + /** + * Check an input only when the input exists + */ + optional(): Validator; } interface Sanitizer { From bf1d9d8b44bd7d0ad2b2a5e57f188916798c17db Mon Sep 17 00:00:00 2001 From: tomtheisen Date: Tue, 2 Jun 2015 10:35:36 -0700 Subject: [PATCH 098/397] Update select2 events Update select2 events based on documentation at http://select2.github.io/select2/ --- select2/select2.d.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/select2/select2.d.ts b/select2/select2.d.ts index b1f21f664..0b4543596 100644 --- a/select2/select2.d.ts +++ b/select2/select2.d.ts @@ -76,6 +76,10 @@ interface Select2JQueryEventObject extends JQueryEventObject { val: any; added: any; removed: any; + choice: { + id: any; + text: string; + }; } interface JQuery { @@ -84,6 +88,26 @@ interface JQuery { on(events: "change", selector?: string, data?: any, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; on(events: "change", selector?: string, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; on(events: "change", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-opening", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-open", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-close", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-highlight", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-selecting", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-removing", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-removed", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-loaded", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-focus", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-blur", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-opening", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-open", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-close", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-highlight", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-selecting", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-removing", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-removed", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-loaded", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-focus", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "select2-blur", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; select2(): JQuery; select2(it: IdTextPair): JQuery; @@ -141,9 +165,9 @@ interface JQuery { /** * Notifies Select2 that a drag and drop sorting operation has finished */ - select2(method: 'onSortEnd'): JQuery; + select2(method: 'onSortEnd'): JQuery; select2(method: string): any; select2(method: string, value: any, trigger?: boolean): any; select2(options: Select2Options): JQuery; -} +} From a89eb5c302cd3faa50844a0ed677941e510b9623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20H=C3=A4berle?= Date: Tue, 2 Jun 2015 20:12:44 +0200 Subject: [PATCH 099/397] Fixed typing issu --- wolfy87-eventemitter/wolfy87-eventemitter-test.ts | 2 +- wolfy87-eventemitter/wolfy87-eventemitter.d.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wolfy87-eventemitter/wolfy87-eventemitter-test.ts b/wolfy87-eventemitter/wolfy87-eventemitter-test.ts index adef23a39..d2d4e6f0c 100644 --- a/wolfy87-eventemitter/wolfy87-eventemitter-test.ts +++ b/wolfy87-eventemitter/wolfy87-eventemitter-test.ts @@ -1,6 +1,6 @@ /// -//import EventEmitter = require("wolfy87-eventemitter"); +import EventEmitter = require("wolfy87-eventemitter"); var emitter = new EventEmitter(); diff --git a/wolfy87-eventemitter/wolfy87-eventemitter.d.ts b/wolfy87-eventemitter/wolfy87-eventemitter.d.ts index 59c17284a..95cf32ea7 100644 --- a/wolfy87-eventemitter/wolfy87-eventemitter.d.ts +++ b/wolfy87-eventemitter/wolfy87-eventemitter.d.ts @@ -505,8 +505,9 @@ declare module Wolfy87EventEmitter { } declare module "wolfy87-eventemitter" { + class EventEmitter extends Wolfy87EventEmitter.EventEmitter {} export = EventEmitter; } -declare var EventEmitter: typeof Wolfy87EventEmitter.EventEmitter; +//declare var EventEmitter: typeof Wolfy87EventEmitter.EventEmitter; From 5dcc9e204702eaaa40e6f09d99e74c74fb026a56 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Tue, 2 Jun 2015 13:22:40 -0700 Subject: [PATCH 100/397] Add `angular.merge` function This is new API in Angular 1.4: https://docs.angularjs.org/api/ng/function/angular.merge --- angularjs/angular.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 009af202a..0e54c2aea 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -249,6 +249,16 @@ declare module angular { isString(value: any): boolean; isUndefined(value: any): boolean; lowercase(str: string): string; + + /** + * Deeply extends the destination object dst by copying own enumerable properties from the src object(s) to dst. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target: var object = angular.merge({}, object1, object2). + * + * Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy. + * + * @param dst Destination object. + * @param src Source object(s). + */ + merge(dst: any, ...src: any[]): any; /** * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. From eb7a5d41278dfee57bb8bb4ddb325b39c0e745d1 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Wed, 3 Jun 2015 10:31:30 +0900 Subject: [PATCH 101/397] add `delete` method --- superagent/superagent-tests.ts | 4 ++++ superagent/superagent.d.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/superagent/superagent-tests.ts b/superagent/superagent-tests.ts index 436874aaf..eaefbf473 100644 --- a/superagent/superagent-tests.ts +++ b/superagent/superagent-tests.ts @@ -52,6 +52,10 @@ request .del('/user/1') .end(callback); +request + .delete('/user/1') + .end(callback); + request('/search') .end(callback); diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index ef477e16a..6944fcceb 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -26,6 +26,7 @@ declare module "superagent" { put(url: string, callback?: CallbackHandler): Req; head(url: string, callback?: CallbackHandler): Req; del(url: string, callback?: CallbackHandler): Req; + delete(url: string, callback?: CallbackHandler): Req; options(url: string, callback?: CallbackHandler): Req; trace(url: string, callback?: CallbackHandler): Req; copy(url: string, callback?: CallbackHandler): Req; From 8ab53b38cfdf61e7dc75cf960f427a68bd996664 Mon Sep 17 00:00:00 2001 From: Justin Lan Date: Tue, 2 Jun 2015 21:15:02 -0700 Subject: [PATCH 102/397] Fix some errors in the d3 definitions == Interval.offset() == Should take a number not a Date as the second parameter (https://github.com/mbostock/d3/wiki/Time-Intervals#interval_offset) == svg.line.defined() and svg.area.defined() == In two places setter signature for defined() wasn't listed. == svg.symbol()'s index parameter is optional == https://github.com/mbostock/d3/wiki/SVG-Shapes#_symbol --- d3/d3.d.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 495999bb8..2fa1493b7 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -13,7 +13,7 @@ declare module d3 { * Find the first element that matches the given selector string. */ export function select(selector: string): Selection; - + /** * Create a selection from the given node reference. */ @@ -86,7 +86,7 @@ declare module d3 { attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Update; /** - * Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match. + * Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match. * * @param name The class list to query. */ @@ -476,7 +476,7 @@ declare module d3 { attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Selection; /** - * Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match. + * Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match. * * @param name The class list to query. */ @@ -928,20 +928,20 @@ declare module d3 { */ export function mouse(container: EventTarget): [number, number]; - /** + /** * Given a container element and a touch identifier, determine the x and y coordinates of the touch. * @param container the container element (e.g., an SVG element) * @param identifier the given touch identifier */ export function touch(container: EventTarget, identifer: number): [number, number]; - /** + /** * Given a container element, a list of touches, and a touch identifier, determine the x and y coordinates of the touch. * @param container the container element (e.g., an SVG element) * @param identifier the given touch identifier */ export function touch(container: EventTarget, touches: TouchList, identifer: number): [number, number]; - + /** * Given a container element and an optional list of touches, return the position of every touch relative to the container. * @param container the container element @@ -1024,7 +1024,7 @@ declare module d3 { * Return the min and max simultaneously. */ export function extent(array: number[]): [number, number]; - + /** * Return the min and max simultaneously. */ @@ -1172,7 +1172,7 @@ declare module d3 { * Calls the function for each key and value pair in the map. The 'this' context is the map itself. */ forEach(func: (key: string, value: T) => any): void; - + /** * Is this map empty? */ @@ -1495,6 +1495,8 @@ declare module d3 { clamp(): boolean; clamp(clamp: boolean): Linear; + nice(count?: number): Linear; + ticks(count?: number): number[]; tickFormat(count?: number, format?: string): (n: number) => string; @@ -1637,7 +1639,7 @@ declare module d3 { export function category20b(): Ordinal; export function category20c(): Ordinal; export function category20c(): Ordinal; - + interface Ordinal { (x: Domain): Range; @@ -1728,7 +1730,7 @@ declare module d3 { range(start: Date, stop: Date, step?: number): Date[]; - offset(date: Date, step: Date): Date; + offset(date: Date, step: number): Date; utc: { (d: Date): Date; @@ -1741,7 +1743,7 @@ declare module d3 { range(start: Date, stop: Date, step?: number): Date[]; - offset(date: Date, step: Date): Date; + offset(date: Date, step: number): Date; } } @@ -1768,7 +1770,7 @@ declare module d3 { export function wednesdayOfYear(d: Date): number; export function fridayOfYear(d: Date): number; export function saturdayOfYear(d: Date): number; - + export function format(specifier: string): Format; export module format { @@ -1935,7 +1937,7 @@ declare module d3 { minorStep(): [number, number]; minorStep(step: [number, number]): Graticule; - + precision(): number; precision(precision: number): Graticule; } @@ -2281,7 +2283,7 @@ declare module d3 { tension(tension: number): Area; defined(): (d: T, i: number) => boolean; - defined(): (d: T, i: number) => boolean; + defined(defined: (d: T, i: number) => boolean): Area; } module area { @@ -2332,7 +2334,7 @@ declare module d3 { tension(tension: number): Radial; defined(): (d: T, i: number) => boolean; - defined(): (d: T, i: number) => boolean; + defined(defined: (d: T, i: number) => boolean): Radial; } } @@ -2388,7 +2390,7 @@ declare module d3 { export function symbol(): Symbol; interface Symbol { - (d: T, i: number): string; + (d: T, i?: number): string; type(): (d: T, i: number) => string; type(type: string): Symbol; @@ -2647,7 +2649,7 @@ declare module d3 { parseRows(string: string, accessor: (row: string[], index: number) => T): T[]; format(rows: Object[]): string; - + formatRows(rows: string[][]): string; } @@ -3284,4 +3286,4 @@ interface TouchList { } declare module 'd3' { export = d3; -} \ No newline at end of file +} From fb0ecf0c33fb167532c5351eb97ae6b7268d2311 Mon Sep 17 00:00:00 2001 From: Igor Kriklivets Date: Wed, 3 Jun 2015 11:34:16 +0300 Subject: [PATCH 103/397] Update to 14.2.7 version --- devextreme/dx.devextreme.d.ts | 804 ++++++++++++++++++++-------------- 1 file changed, 473 insertions(+), 331 deletions(-) diff --git a/devextreme/dx.devextreme.d.ts b/devextreme/dx.devextreme.d.ts index 36e3bb615..f2b6a9048 100644 --- a/devextreme/dx.devextreme.d.ts +++ b/devextreme/dx.devextreme.d.ts @@ -1,4 +1,4 @@ -// Type definitions for DevExtreme 14.2+ +// Type definitions for DevExtreme 14.2.7 // Project: http://js.devexpress.com/ // Definitions by: DevExpress Inc. // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -21,6 +21,7 @@ declare module DevExpress { export module validationEngine { export interface IValidator { validate(): ValidatorValidationResult; + reset(): void; } export interface ValidatorValidationResult { isValid: boolean; @@ -38,6 +39,7 @@ declare module DevExpress { group: any; validators: IValidator[]; validate(): ValidationGroupValidationResult; + reset(): void; } /** Provides access to the object that represents the specified validation group. */ export function getGroupConfig(group: any): GroupConfig @@ -47,6 +49,10 @@ declare module DevExpress { export function validateGroup(group: any): ValidationGroupValidationResult; /** Validates rules of the validators that belong to the default validation group. */ export function validateGroup(): ValidationGroupValidationResult; + /** Resets the values and validation result of the editors that belong to the specified validation group. */ + export function resetGroup(group: any): void; + /** Resets the values and validation result of the editors that belong to the default validation group. */ + export function resetGroup(): void; /** Validates the rules that are defined within the dxValidator objects that are registered for the specified ViewModel. */ export function validateModel(model: Object): ValidationGroupValidationResult; /** Registers all the dxValidator objects by which the fields of the specified ViewModel are extended. */ @@ -245,6 +251,7 @@ declare module DevExpress { filter?: Object; sort?: Object; select?: Object; + expand?: Object; group?: Object; skip?: number; take?: number; @@ -265,7 +272,7 @@ declare module DevExpress { updating: JQueryCallback; constructor(options?: StoreOptions); /** Returns the data item specified by the key. */ - byKey(key: any, extraOptions?: Object): JQueryPromise; + byKey(key: any): JQueryPromise; /** Adds an item to the data associated with this Store. */ insert(values: Object): JQueryPromise; /** Returns the key expression specified via the key configuration option. */ @@ -340,7 +347,7 @@ declare module DevExpress { byKey?: (key: any) => Promise; /** * User implementation of the byKey(key, extraOptions) method. - * @deprecated Use "byKey" instead + * @deprecated byKey.md */ lookup?: (key: any) => Promise; /** The user implementation of the insert(values) method. */ @@ -379,6 +386,8 @@ declare module DevExpress { searchValue?: Object; /** Specifies the initial select option value. */ select?: Object; + /** An array of the strings that represent the names of the navigation properties to be loaded simultaneously with the OData store's entity. */ + expand?: Object; /** Specifies the initial sort option value. */ sort?: Object; /** Specifies the underlying Store instance used to access data. */ @@ -535,6 +544,8 @@ declare module DevExpress { constructor(options?: ODataStoreOptions); /** Creates the Query object for the OData endpoint. */ createQuery(loadOptions: Object): Object; + /** Returns the data item specified by the key. */ + byKey(key: any, extraOptions?: { expand?: Object }): JQueryPromise; } /** An universal chainable data query interface object. */ export interface Query { @@ -657,7 +668,7 @@ declare module DevExpress { items?: Array; /** * A function performed when a widget item is selected. - * @deprecated Use the 'onSelectionChanged' option instead + * @deprecated onSelectionChanged.md */ itemSelectAction?: Function; /** The template to be used for rendering items. */ @@ -713,11 +724,11 @@ declare module DevExpress { /** The template to be used for rendering items. */ itemTemplate?: any; /** The currently selected value in the widget. */ - value?: any; + value?: Object; } export interface EditorOptions extends WidgetOptions { /** The currently specified value. */ - value?: any; + value?: Object; /** A handler for the valueChanged event. */ onValueChanged?: Function; valueChangeAction?: Function; @@ -729,6 +740,8 @@ declare module DevExpress { isValid?: boolean; /** Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed. */ validationMessageMode?: string; + /** Resets the editor's value to undefined. */ + reset(): void; } /** A base class for editors. */ export class Editor extends Widget { } @@ -817,6 +830,24 @@ declare module DevExpress.framework { /** Formats an object to a URI. */ format(obj: Object): string; } + export interface StateManagerOptions { + /** A storage to which the state manager saves the application state. */ + storage?: Object; + } + /** An object used to store the current application state. */ + export class StateManager { + constructor(options?: StateManagerOptions); + /** Adds an object that implements an interface of a state source to the state manager's collection of state sources. */ + addStateSource(stateSource: Object): void; + /** Removes a specified state source from the state manager's collection of state sources. */ + removeStateSource(stateSource: Object): void; + /** Saves the current application state. */ + saveState(): void; + /** Restores the application state that has been saved by the saveState() method to the state storage. */ + restoreState(): void; + /** Removes the application state that has been saved by the saveState() method to the state storage. */ + clearState(): void; + } export module html { export var layoutSets: Array; export interface HtmlApplicationOptions { @@ -824,7 +855,7 @@ declare module DevExpress.framework { commandMapping?: Object; /** * The name of the default layout used by the application. - * @deprecated Use the "navigationType" option instead. + * @deprecated navigationType.md */ defaultLayout?: string; /** Specifies whether or not view caching is disabled. */ @@ -839,14 +870,18 @@ declare module DevExpress.framework { navigateToRootViewMode?: string; /** An array of dxCommand configuration objects used to define commands available from the application's global navigation. */ navigation?: Array; + /** A state manager to be used in the application. */ + stateManager?: StateManager; + /** Specifies the storage to be used by the application's state manager to store the application state. */ + stateStorage?: Object; /** * Specifies a strategy for choosing layouts for views in your application. - * @deprecated Use the "layoutSet" option instead. + * @deprecated layoutSet.md */ navigationType?: string; /** * Specifies the object that represents the root namespace of the application. - * @deprecated Use the "namespace" option instead. + * @deprecated namespace.md */ ns?: Object; /** Indicates whether on not to use the title of the previously displayed view as text on the Back button. */ @@ -879,13 +914,15 @@ declare module DevExpress.framework { viewCache: ViewCache; /** An array of dxCommand components that are created based on the application's navigation option value. */ navigation: Array; + /** Provides access to the StateManager object. */ + stateManager: StateManager; /** Provides access to the Router object. */ router: Router; /** Navigates to the URI preceding the current one in the navigation history. */ back(): void; /** Returns a Boolean value indicating whether or not backwards navigation is currently possible. */ canBack(): boolean; - /** Removes the application state that has been saved by the saveState() method to the state storage. */ + /** Calls the clearState() method of the application's StateManager object. */ clearState(): void; /** Creates global navigation commands. */ createNavigation(navigationConfig: Array): void; @@ -899,9 +936,9 @@ declare module DevExpress.framework { navigate(uri?: any, options?: Object): void; /** Renders navigation commands to the navigation command containers that are located in the layouts used in the application. */ renderNavigation(): void; - /** Restores the application state that has been saved by the saveState() method to the state storage, and applies it to the application. */ + /** Calls the restoreState() method of the application's StateManager object. */ restoreState(): void; - /** Saves the current application state. */ + /** Calls the saveState method of the application's StateManager object. */ saveState(): void; /** Provides access to the object that defines the current context to be considered when choosing an appropriate template for a view. */ templateContext(): Object; @@ -1039,6 +1076,8 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxValidatorOptions); /** Validates the value of the editor that is controlled by the current dxValidator object against the list of the specified validation rules. */ validate(): validationEngine.ValidatorValidationResult; + /** Resets the value and validation result of the editor associated with the current dxValidator object. */ + reset(): void; } /** The widget that is used in the Knockout and Angular approaches to combine the editors to be validated. */ export class dxValidationGroup extends DOMComponent { @@ -1046,6 +1085,8 @@ declare module DevExpress.ui { constructor(element: Element); /** Validates rules of the validators that belong to the current validation group. */ validate(): validationEngine.ValidationGroupValidationResult; + /** Resets the value and validation result of the editors that are included to the current validation group. */ + reset(): void; } export interface dxValidationSummaryOptions extends CollectionWidgetOptions { /** Specifies the validation group for which summary should be generated. */ @@ -1082,6 +1123,15 @@ declare module DevExpress.ui { searchEnabled?: boolean; /** Specifies whether or not the widget displays items by pages. */ pagingEnabled?: boolean; + /** The text or HTML markup displayed by the widget if the item collection is empty. */ + noDataText?: string; + /** A handler for the selectionChanged event. */ + onSelectionChanged?: Function; + /** A handler for the itemClick event. */ + onItemClick?: Function; + onContentReady?: Function; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; } /** A base class for drop-down list widgets. */ export class dxDropDownList extends dxDropDownEditor { @@ -1160,12 +1210,19 @@ declare module DevExpress.ui { /** Specifies the current value displayed by the widget. */ value?: any; valueUpdateAction?: Function; - valueChangeAction?: Function; /** Specifies DOM event names that update a widget's value. */ valueChangeEvent?: string; valueUpdateEvent?: string; /** Specifies whether or not the widget checks the inner text for spelling mistakes. */ spellcheck?: boolean; + /** Specifies HTML attributes applied to the inner input element of the widget. */ + attr?: Object; + /** The read-only option that holds the text displayed by the widget input element. */ + text?: string; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; } /** A base class for text editing widgets. */ export class dxTextEditor extends Editor { @@ -1197,6 +1254,8 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxTextAreaOptions); } export interface dxTabsOptions extends CollectionWidgetOptions { + /** Specifies whether the widget enables an end-user to select only a single item or multiple items. */ + selectionMode?: string; /** Specifies whether or not an end-user can scroll tabs by swiping. */ scrollByContent?: boolean; /** Specifies whether or not an end-user can scroll tabs. */ @@ -1216,8 +1275,9 @@ declare module DevExpress.ui { onTitleHold?: Function; /** A handler for the titleRendered event. */ onTitleRendered?: Function; - /** A template to be used for rendering the widget title. */ titleTemplate?: any; + /** The template to be used for rendering an item title. */ + itemTitleTemplate?: any; } /** A widget used to display a view and to switch between several views by clicking the appropriate tabs. */ export class dxTabPanel extends dxMultiView { @@ -1230,32 +1290,16 @@ declare module DevExpress.ui { /** The text that is provided as a hint in the select box editor. */ placeholder?: string; /** Specifies whether or not the widget allows an end-user to enter a custom value. */ - editEnabled?: boolean; + fieldEditEnabled?: boolean; } /** A widget that allows you to select an item in a dropdown list. */ export class dxSelectBox extends dxDropDownList { constructor(element: JQuery, options?: dxSelectBoxOptions); constructor(element: Element, options?: dxSelectBoxOptions); - /** Closes the drop-down editor. */ - close(): void; - /** Opens the drop-down editor. */ - open(): void; } export interface dxTagBoxOptions extends dxSelectBoxOptions { /** Holds the list of selected values. */ values?: Array; - /** Holds the last selected value. */ - value?: any; - /** A handler for the valueChanged event. */ - onValueChanged?: (e: { - component: dxTagBox; - element: JQuery; - model: Object; - value: Object; - values: Object; - itemData: Object; - jQueryEvent: JQueryEventObject; - }) => void; } /** A widget that allows you to select multiple items from a dropdown list. */ export class dxTagBox extends dxSelectBox { @@ -1310,6 +1354,12 @@ declare module DevExpress.ui { updateAction?: Function; /** Indicates whether to use native or simulated scrolling. */ useNative?: boolean; + /** A Boolean value specifying whether to enable or disable the bounce-back effect. */ + bounceEnabled?: boolean; + /** A Boolean value specifying whether or not an end-user can scroll the widget content swiping it up or down. */ + scrollByContent?: boolean; + /** A Boolean value specifying whether or not an end-user can scroll the widget content using the scrollbar. */ + scrollByThumb?: boolean; } /** A widget used to display scrollable content. */ export class dxScrollable extends DOMComponent { @@ -1369,6 +1419,8 @@ declare module DevExpress.ui { width?: any; /** Specifies items displayed on the top or bottom toolbar of the popup window. */ buttons?: Array; + /** Specifies whether or not the widget displays the Close button. */ + showCloseButton?: boolean; /** A handler for the titleRendered event. */ onTitleRendered?: Function; } @@ -1396,6 +1448,8 @@ declare module DevExpress.ui { export class dxPopover extends dxPopup { constructor(element: JQuery, options?: dxPopoverOptions); constructor(element: Element, options?: dxPopoverOptions); + /** Displays the widget for the specified target element. */ + show(target?: any): JQueryPromise; } export interface dxOverlayOptions extends WidgetOptions { /** An object that defines the animation options of the widget. */ @@ -1449,13 +1503,15 @@ declare module DevExpress.ui { show(): JQueryPromise; /** Toggles the visibility of the widget. */ toggle(showing: boolean): JQueryPromise; + /** A static method that specifies the default z-index for all overlay widgets. */ + static baseZIndex(zIndex: number): void; } export interface dxNumberBoxOptions extends dxTextEditorOptions { /** The maximum value accepted by the number box. */ max?: number; /** The minimum value accepted by the number box. */ min?: number; - /** Specifies whether to show spin buttons. */ + /** Specifies whether or not to show spin buttons. */ showSpinButtons?: boolean; useTouchSpinButtons?: boolean; /** Specifies by which value the widget value changes when a spin button is clicked. */ @@ -1468,7 +1524,9 @@ declare module DevExpress.ui { constructor(element: JQuery, options?: dxNumberBoxOptions); constructor(element: Element, options?: dxNumberBoxOptions); } - export interface dxNavBarOptions extends dxTabsOptions { } + export interface dxNavBarOptions extends dxTabsOptions { + scrollingEnabled?: boolean; + } /** A widget that contains items used to navigate through application views. */ export class dxNavBar extends dxTabs { constructor(element: JQuery, options?: dxNavBarOptions); @@ -1526,7 +1584,7 @@ declare module DevExpress.ui { } /** * An object, a string, or an array specifying the location displayed at the center of the widget. - * @deprecated Use the 'center' option instead + * @deprecated center.md */ location?: { lat?: number; @@ -1586,8 +1644,8 @@ declare module DevExpress.ui { clearButtonText?: string; /** A Boolean value specifying whether or not the widget is closed if a user clicks outside of the overlaying window. */ closeOnOutsideClick?: any; - /** The text displayed on the Done button. */ - doneButtonText?: string; + /** The text displayed on the Apply button. */ + applyButtonText?: string; /** A Boolean value specifying whether or not to display the lookup in full-screen mode. */ fullScreen?: boolean; /** A Boolean value specifying whether or not to group widget items. */ @@ -1597,8 +1655,6 @@ declare module DevExpress.ui { groupTemplate?: any; /** The text displayed on the button used to load the next page from the data source. */ nextButtonText?: string; - /** The text or HTML markup displayed by the widget if there are no items satisfying the specified search condition. */ - noDataText?: string; /** A handler for the pageLoading event. */ onPageLoading?: Function; pageLoadingAction?: Function; @@ -1634,8 +1690,6 @@ declare module DevExpress.ui { shading?: boolean; /** Specifies whether to display the Cancel button in the lookup window. */ showCancelButton?: boolean; - /** Specifies whether to display the Done button in the lookup window. */ - showDoneButton?: boolean; /** A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. */ showNextButton?: boolean; /** The title of the lookup window. */ @@ -1649,10 +1703,11 @@ declare module DevExpress.ui { /** A handler for the valueChanged event. */ onValueChanged?: Function; contentReadyAction?: Function; - onContentReady?: Function; titleRender?: any; /** A handler for the titleRendered event. */ onTitleRendered?: Function; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; } /** A widget that allows a user to select predefined values from a lookup window. */ export class dxLookup extends dxDropDownList { @@ -1703,7 +1758,7 @@ declare module DevExpress.ui { deleteEnabled?: boolean; /** * A mode specifying how to delete a list item. - * @deprecated Use the "deleteType" option instead. + * @deprecated deleteType.md */ deleteMode?: string; /** Specifies the way a user can delete items from the list. */ @@ -1721,14 +1776,14 @@ declare module DevExpress.ui { selectionEnabled?: boolean; /** * A mode specifying how to select a list item. - * @deprecated Use the "selectionType" option instead. + * @deprecated selectionType.md */ selectionMode?: string; /** A type specifying how to select a list item. */ selectionType?: string; /** Specifies whether the item list represented by this widget is editable. */ editEnabled?: boolean; - /** Specifies whether or not to show the load panel during data loading. */ + /** Specifies whether or not to show the loading panel when the DataSource bound to the widget is loading data. */ indicateLoading?: boolean; }; /** A Boolean value specifying whether or not to display a grouped list. */ @@ -1736,6 +1791,7 @@ declare module DevExpress.ui { groupRender?: any; /** The name of the template used to display a group header. */ groupTemplate?: any; + onItemDeleting?: Function; /** A handler for the itemDeleted event. */ onItemDeleted?: Function; itemDeleteAction?: Function; @@ -1774,8 +1830,8 @@ declare module DevExpress.ui { selectionMode?: string; /** A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. */ showNextButton?: boolean; - /** A Boolean value specifying if the widget scrollbar is visible. */ - showScrollbar?: boolean; + /** Specifies when the widget shows the scrollbar. */ + showScrollbar?: string; /** Specifies whether or not the widget uses native scrolling. */ useNativeScrolling?: boolean; itemUnselectAction?: Function; @@ -1831,7 +1887,7 @@ declare module DevExpress.ui { unselectItem(itemIndex: any): void; /** * Updates the widget scrollbar according to widget content size. - * @deprecated Use the "updateDimensions" method instead. + * @deprecated updateDimensions.md */ update(): JQueryPromise; /** Updates the widget scrollbar according to widget content size. */ @@ -1844,6 +1900,8 @@ declare module DevExpress.ui { export interface dxGalleryOptions extends CollectionWidgetOptions { /** The time, in milliseconds, spent on slide animation. */ animationDuration?: number; + /** Specifies whether or not to animate the displayed item change. */ + animationEnabled?: boolean; /** A Boolean value specifying whether or not to allow users to switch between items by clicking an indicator. */ indicatorEnabled?: boolean; /** A Boolean value specifying whether or not to scroll back to the first item after the last item is swiped. */ @@ -1871,16 +1929,25 @@ declare module DevExpress.ui { prevItem(animation: boolean): JQueryPromise; } export interface dxDropDownEditorOptions extends dxTextBoxOptions { + /** Specifies the current value displayed by the widget. */ + value?: Object; /** A handler for the closed event. */ onClosed?: Function; /** A handler for the opened event. */ onOpened?: Function; - /** Specifies whether or not the drop-down window is displayed. */ + /** Specifies whether or not the drop-down editor is displayed. */ opened?: boolean; closeAction?: Function; openAction?: Function; shownAction?: Function; hiddenAction?: Function; + /** Specifies whether or not the widget allows an end-user to enter a custom value. */ + fieldEditEnabled?: boolean; + editEnabled?: boolean; + /** Specifies the way an end-user applies the selected value. */ + applyValueMode?: string; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; } /** A drop-down editor widget. */ export class dxDropDownEditor extends dxTextBox { @@ -1890,12 +1957,10 @@ declare module DevExpress.ui { close(): void; /** Opens the drop-down editor. */ open(): void; + /** Resets the widget's value to null. */ + reset(): void; } export interface dxDateBoxOptions extends dxTextEditorOptions { - /** A dxCalendar configuration object used to initialize the drop-down calendar. */ - calendarOptions?: dxCalendarOptions; - /** Specifies whether or not to close the drop-down calendar when widget value has been changed. */ - closeOnValueChange?: boolean; /** A format used to display date/time information. */ format?: string; /** A Globalize format string specifying the date display format. */ @@ -1906,7 +1971,7 @@ declare module DevExpress.ui { min?: Date; /** The text displayed by the widget when the widget value is not yet specified. This text is also used as a title of the date picker. */ placeholder?: string; - /** Specifies whether or not a user can pick out a date via the drop-down calendar. */ + /** Specifies whether or not a user can pick out a date using the drop-down calendar. */ useCalendar?: boolean; /** A Date object specifying the date and time currently selected using the date box. */ value?: Date; @@ -1916,7 +1981,7 @@ declare module DevExpress.ui { interval?: number; } /** A date box widget. */ - export class dxDateBox extends dxTextEditor { + export class dxDateBox extends dxDropDownEditor { constructor(element: JQuery, options?: dxDateBoxOptions); constructor(element: Element, options?: dxDateBoxOptions); } @@ -1990,12 +2055,14 @@ declare module DevExpress.ui { /** Specifies the screen factor with which all elements are located in a single column. */ singleColumnScreen?: string; } - /** A widget used to build an adaptive markup dependent on screen resolution. */ + /** A widget used to build an adaptive markup that is dependent on screen resolution. */ export class dxResponsiveBox extends CollectionWidget { constructor(element: JQuery, options?: dxBoxOptions); constructor(element: Element, options?: dxBoxOptions); } export interface dxAutocompleteOptions extends dxDropDownListOptions { + /** Specifies the current value displayed by the widget. */ + value?: string; /** The minimum number of characters that must be entered into the text box to begin a search. */ minSearchLength?: number; /** Specifies the maximum count of items displayed by the widget. */ @@ -2041,21 +2108,11 @@ declare module DevExpress.ui { /** Expands the specified item. */ expandItem(index: number): JQueryPromise; } - export interface dxFileUploaderFile { - /** Specifies the selected file name. */ - name?: string; - /** Specifies the selected file size in bytes. */ - size?: number; - /** Specifies the MIME type of the selected file. */ - type?: string; - /** Specifies the date and time of the last selected file modification. */ - lastModifiedDate?: Date; - } export interface dxFileUploaderOptions extends EditorOptions { - /** An object that holds the selected file data. */ - value?: dxFileUploaderFile; - /** Holds data of the files selected in the widget. */ - values?: Array; + /** A read-only option that holds a File instance representing the selected file. */ + value?: File; + /** Holds the File instances representing files selected in the widget. */ + values?: Array; /** Specifies the text displayed on the button opening the file selection dialog. */ buttonText?: string; /** Specifies the text displayed on the area to which an end-user can drop a file. */ @@ -2093,7 +2150,7 @@ declare module DevExpress.ui { /** A handler for the complete event. */ onComplete?: Function; } - /** A widget used to indicate a progress. */ + /** A widget used to indicate progress. */ export class dxProgressBar extends dxTrackBar { constructor(element: JQuery, options?: dxProgressBarOptions); constructor(element: Element, options?: dxProgressBarOptions); @@ -2175,7 +2232,7 @@ declare module DevExpress.ui { constructor(element: JQuery, options?: dxSwitchOptions); constructor(element: Element, options?: dxSwitchOptions); } - export interface dxSlideoutOptions extends CollectionWidgetOptions { + export interface dxSlideOutOptions extends CollectionWidgetOptions { /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ activeStateEnabled?: boolean; /** A Boolean value specifying whether or not to display a grouped menu. */ @@ -2190,11 +2247,13 @@ declare module DevExpress.ui { menuVisible?: boolean; /** Indicates whether the menu can be shown/hidden by swiping the widget's main panel. */ swipeEnabled?: boolean; + /** A template to be used for rendering widget content. */ + contentTemplate?: any; } - /** The dxSlideOut widget allows you to slide-out the current view to reveal an item list. */ + /** The widget that allows you to slide-out the current view to reveal an item list. */ export class dxSlideOut extends CollectionWidget { - constructor(element: JQuery, options?: dxSlideoutOptions); - constructor(element: Element, options?: dxSlideoutOptions); + constructor(element: JQuery, options?: dxSlideOutOptions); + constructor(element: Element, options?: dxSlideOutOptions); /** Hides the widget's slide-out menu. */ hideMenu(): JQueryPromise; /** Displays the widget's slide-out menu. */ @@ -2205,6 +2264,8 @@ declare module DevExpress.ui { export interface dxPivotOptions extends CollectionWidgetOptions { /** The index of the currently active pivot item. */ selectedIndex?: number; + /** A template to be used for rendering widget content. */ + contentTemplate?: any; } /** A widget that is similar to a traditional tab control, but optimized for the phone with simplified end-user interaction. */ export class dxPivot extends CollectionWidget { @@ -2257,12 +2318,20 @@ declare module DevExpress.ui { popupWidth?: any; /** The height of the menu popup in pixels. */ popupHeight?: any; + /** Specifies whether or not the drop-down menu is displayed. */ + opened?: boolean; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; } /** A drop-down menu widget. */ export class dxDropDownMenu extends Widget { constructor(element: JQuery, options?: dxDropDownEditorOptions); constructor(element: Element, options?: dxDropDownEditorOptions); /** This section lists the data source fields that are used in a default template for drop-down menu items. */ + /** Opens the drop-down menu. */ + open(): void; + /** Closes the drop-down menu. */ + close(): void; } export interface dxActionSheetOptions extends CollectionWidgetOptions { cancelClickAction?: any; @@ -2270,7 +2339,7 @@ declare module DevExpress.ui { onCancelClick?: any; /** The text displayed in the button that closes the action sheet. */ cancelText?: string; - /** Specifies whether to display the Cancel button in action sheet. */ + /** Specifies whether or not to display the Cancel button in action sheet. */ showCancelButton?: boolean; /** A Boolean value specifying whether or not the title of the action sheet is visible. */ showTitle?: boolean; @@ -2297,14 +2366,11 @@ declare module DevExpress.ui { export interface dxColorBoxOptions extends dxDropDownEditorOptions { /** Specifies the text displayed on the button that applies changes and closes the drop-down editor. */ applyButtonText?: string; - /** Specifies whether the widget value is updated after the Apply button is clicked or immediately after a color is selected in the palette. */ applyValueMode?: string; /** Specifies the text displayed on the button that cancels changes and closes the drop-down editor. */ cancelButtonText?: string; /** Specifies whether or not the widget value includes the alpha channel component. */ editAlphaChannel?: boolean; - /** The color currently selected by the widget. */ - value?: string; } /** A widget used to specify a color value. */ export class dxColorBox extends dxDropDownEditor { @@ -2323,7 +2389,12 @@ declare module DevExpress.ui { export interface dxTreeViewOptions extends CollectionWidgetOptions { /** Specifies whether a nested or plain array is used as a data source. */ dataStructure?: string; - /** An array of currently expanded item objects. */ + /** Specifies whether or not a user can expand all tree view items by the "*" hot key. */ + expandAllEnabled?: boolean; + /** + * An array of currently expanded item objects. + * @deprecated Use item.expanded field instead + */ expandedItems?: Array; /** Specifies whether or not a check box is displayed at each tree view item. */ showCheckBoxes?: boolean; @@ -2345,6 +2416,7 @@ declare module DevExpress.ui { itemsExpr?: any; /** Specifies the name of the data source item field that holds the key of the parent item. */ parentIdExpr?: any; + disabledExpr?: any; /** A string value specifying available scrolling directions. */ scrollDirection?: string; /** A handler for the itemSelected event. */ @@ -2370,6 +2442,10 @@ declare module DevExpress.ui { collapseItem(itemElement: any): void; /** Returns all nodes of the tree view. */ getNodes(): Array; + /** Selects all widget items. */ + selectAll(): void; + /** Unselects all widget items. */ + unselectAll(): void; } export interface dxMenuBaseOptions extends CollectionWidgetOptions { /** An object that defines the animation options of the widget. */ @@ -2386,6 +2462,8 @@ declare module DevExpress.ui { selectionMode?: string; /** Specifies the user interaction by which submenus are shown. */ showSubmenuMode?: string; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; } export class dxMenuBase extends CollectionWidget { constructor(element: JQuery, options?: dxMenuBaseOptions); @@ -2402,8 +2480,6 @@ declare module DevExpress.ui { /** Specifies by which user interaction the first-level submenu is shown. */ showFirstSubmenuMode?: string; showPopupMode?: string; - /** Specifies by which user interaction secondary-level submenus are shown. */ - showSubmenuMode?: string; /** Specifies the direction at which the submenus are displayed. */ submenuDirection?: string; /** A handler for the submenuHidden event. */ @@ -2445,8 +2521,6 @@ declare module DevExpress.ui { positioningAction?: Function; showingAction?: Function; shownAction?: Function; - /** Specifies by which user interaction the context menu is shown. */ - showSubmenuMode?: string; /** Specifies the direction at which submenus are displayed. */ submenuDirection?: string; /** The target element associated with a popover. */ @@ -2458,6 +2532,12 @@ declare module DevExpress.ui { export class dxContextMenu extends dxMenuBase { constructor(element: JQuery, options?: dxContextMenuOptions); constructor(element: Element, options?: dxContextMenuOptions); + /** Toggles the visibility of the widget. */ + toggle(showing: boolean): JQueryPromise; + /** Shows the widget. */ + show(): JQueryPromise; + /** Hides the widget. */ + hide(): JQueryPromise; } export interface dxRemoteOperations { /** Specifies whether or not filtering must be performed on the server side. */ @@ -2973,9 +3053,7 @@ Specifies the message displayed in a group row when the corresponding group cont /** Specifies whether text that does not fit into a column should be wrapped. */ wordWrapEnabled?: boolean; } - /** -A data grid widget. - */ + /** A data grid widget. */ export class dxDataGrid extends Widget { constructor(element: JQuery, options?: dxDataGridOptions); constructor(element: Element, options?: dxDataGridOptions); @@ -3070,6 +3148,7 @@ Searches grid records by a search string. searchByText(text: string): void; /** Selects all grid records. */ selectAll(): void; + deselectAll(): void; /** Selects specific grid records. */ selectRows(keys: Array, preserve: boolean): void; /** Deselects specific grid records. */ @@ -3100,8 +3179,13 @@ declare module DevExpress.viz.charts { type: string; /** Unselects all the selected points of the series. The points are displayed in an initial style. */ clearSelection(): void; - /** Gets a point from the series point collection based on the specified argument. */ + /** + * Gets a point from the series point collection based on the specified argument. + * @deprecated getPointsByArg(pointArg).md + */ getPointByArg(pointArg: any): Object; + /** Gets points from the series point collection based on the specified argument. */ + getPointsByArg(pointArg: any): Array; /** Gets a point from the series point collection based on the specified point position. */ getPointByPos(positionIndex: number): Object; /** Selects the series. The series is displayed in a 'selected' style until another series is selected or the current series is deselected programmatically. */ @@ -3239,8 +3323,6 @@ declare module DevExpress.viz.charts { } /** This section describes the methods that can be used in code to manipulate the Point object. */ export interface PolarPoint extends BasePoint { - /** Gets the parameters of the point's minimum bounding rectangle (MBR). */ - getBoundingRect(): Object; series: PolarSeries; } export interface Strip { @@ -3624,8 +3706,6 @@ declare module DevExpress.viz.charts { tagField?: string; /** Specifies the data source field that provides values for series points. */ valueField?: string; - /** Specifies the required type for series values. */ - valueType?: string; } export interface PieSeriesConfig extends CommonPieSeriesConfig { /** Sets the series type. */ @@ -3648,8 +3728,12 @@ declare module DevExpress.viz.charts { font?: viz.core.Font; /** Specifies the position of the constant line label relative to the chart plot. */ position?: string; + /** Indicates whether or not to display labels for the axis constant lines. */ + visible?: boolean; } export interface PolarCommonConstantLineLabel { + /** Indicates whether or not to display labels for the axis constant lines. */ + visible?: boolean; /** Specifies font options for a constant line label. */ font?: viz.core.Font; } @@ -3865,6 +3949,8 @@ declare module DevExpress.viz.charts { minorTickCount?: number; /** Specifies the required type of the value axis. */ type?: string; + /** Specifies the pane on which the current value axis will be displayed. */ + pane?: string; /** Specifies options for value axis strips. */ strips?: Array; } @@ -4285,6 +4371,10 @@ declare module DevExpress.viz.charts { export interface PieLegend extends core.BaseLegend { /** Specifies what chart elements to highlight when a corresponding item in the legend is hovered over. */ hoverMode?: string; + /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a legend item. */ + customizeHint?: (pointInfo: { pointName: string; pointIndex: number; pointColor: string; }) => string; + /** Specifies a callback function that returns the text to be displayed by a legend item. */ + customizeText?: (pointInfo: { pointName: string; pointIndex: number; pointColor: string; }) => string; } export interface dxPieChartOptions extends BaseChartOptions { /** Specifies adaptive layout options. */ @@ -4375,7 +4465,7 @@ declare module DevExpress.viz.core { /** Specifies a color for the tooltip. */ color?: string; customizeText?: Function; - /** Allows you to change the appearance of particular tooltips. */ + /** Specifies text and appearance of a particular set of tooltips. */ customizeTooltip?: (arg: Object) => { color?: string; text?: string }; /** Specifies whether or not the tooltip is enabled. */ enabled?: boolean; @@ -4575,52 +4665,49 @@ declare module DevExpress.viz.gauges { /** Specifies the start value for the scale of the gauge. */ startValue?: number; } - export interface BaseSubvalueIndicator { - /** Specifies the length of an arrow for the subvalue indicator of the textCloud type in pixels. */ - arrowLength?: number; - /** Specifies the color of a subvalue indicator. */ - color?: string; - /** Specifies the length for a subvalue indicator of the triangleMarker type in pixels. */ - length?: number; - /** Sets the array of colors to be used for coloring the subvalue indicators. */ - palette?: Array; - /** Specifies the appearance of the text displayed in a subvalue indicator of the textCloud type. */ - text?: Object; - /** Specifies a callback function that returns the text to be displayed in a subvalue indicator of the textCloud type. */ - customizeText?: (indicatedSubvalue: { value: number; valueText: string }) => string; - /** Specifies font options for the text displayed by a subvalue indicator of the textCloud type. */ - font?: viz.core.Font; - /** Specifies a format for the text displayed in a subvalue indicator of the textCloud type. */ - format?: string; - /** Specifies a precision for the formatted value displayed in a subvalue indicator of the textCloud type. */ - precision?: number; - /** Overriden by descriptions for specific widgets. */ - type?: string; - /** Specifies the width for a subvalue indicator of the triangleMarker type in pixels. */ - width?: number; - } export interface BaseValueIndicator { - /** Specifies the background color for the value indicator of the rangeBar type. */ + /** Specifies the type of subvalue indicators. */ + type?: string; + /** Specifies the background color for the indicator of the rangeBar type. */ backgroundColor?: string; - /** Specifies the base value for the value indicator of the rangeBar type. */ + /** Specifies the base value for the indicator of the rangeBar type. */ baseValue?: number; - /** Specifies the color of the value indicator. */ + /** Specifies a color of the indicator. */ color?: string; - /** Specifies the range bar size for a value indicator of the rangeBar type. */ + /** Specifies the range bar size for an indicator of the rangeBar type. */ size?: number; - /** Specifies the appearance of the text displayed in a value indicator of the rangeBar type. */ text?: { - /** Specifies a callback function that returns the text to be displayed in a value indicator of the rangeBar type. */ + /** Specifies a callback function that returns the text to be displayed in an indicator. */ customizeText?: (indicatedValue: { value: number; valueText: string }) => string; - /** Specifies font options for the text displayed by a value indicator of the rangeBar type. */ font?: viz.core.Font; - /** Specifies a format for the text displayed in a value indicator of the rangeBar type. */ + /** Specifies a format for the text displayed in an indicator. */ format?: string; /** Specifies the range bar's label indent in pixels. */ indent?: number; - /** Specifies a precision for the formatted value displayed by a value indicator of the rangeBar type. */ + /** Specifies a precision for the formatted value displayed by an indicator. */ precision?: number; }; + offset?: number; + length?: number; + width?: number; + /** Specifies the length of an arrow for the indicator of the textCloud type in pixels. */ + arrowLength?: number; + /** Sets the array of colors to be used for coloring subvalue indicators. */ + palette?: Array; + /** Specifies the distance between the needle and the center of a gauge for the indicator of a needle-like type. */ + indentFromCenter?: number; + /** Specifies the second color for the indicator of the twoColorNeedle type. */ + secondColor?: string; + /** Specifies the length of a twoNeedleColor type indicator tip as a percentage. */ + secondFraction?: number; + /** Specifies the spindle's diameter in pixels for the indicator of a needle-like type. */ + spindleSize?: number; + /** Specifies the inner diameter in pixels, so that the spindle has the shape of a ring. */ + spindleGapSize?: number; + /** Specifies the orientation of the rangeBar indicator on a vertically oriented dxLinearGauge widget. */ + horizontalOrientation?: string; + /** Specifies the orientation of the rangeBar indicator on a horizontally oriented dxLinearGauge widget. */ + verticalOrientation?: string; } export interface SharedGaugeOptions { /** Specifies animation options. */ @@ -4662,7 +4749,7 @@ declare module DevExpress.viz.gauges { /** Specifies a gauge's scale options. */ scale?: BaseScale; /** Specifies the appearance options of subvalue indicators. */ - subvalueIndicator?: BaseSubvalueIndicator; + subvalueIndicator?: BaseValueIndicator; /** Specifies a set of subvalues to be designated by the subvalue indicators. */ subvalues?: Array; /** Specifies the main value on a gauge. */ @@ -4710,28 +4797,6 @@ declare module DevExpress.viz.gauges { /** Specifies the orientation of scale ticks on a horizontally oriented dxLinearGauge widget. */ verticalOrientation?: string; } - export interface LinearSubvalueIndicator extends BaseSubvalueIndicator { - /** Specifies the orientation of the subvalue indicators on a vertically oriented dxLinearGauge widget. */ - horizontalOrientation?: string; - /** Specifies the distance between a subvalue indicator and an invisible scale line in pixels. */ - offset?: number; - /** Specifies the orientation of the subvalue indicators on a horizontally oriented dxLinearGauge widget. */ - verticalOrientation?: string; - } - export interface LinearValueIndicator extends BaseValueIndicator { - /** Specifies the orientation of the rangeBar value indicator on a vertically oriented dxLinearGauge widget. */ - horizontalOrientation?: string; - /** Specifies the length of a value indicator in pixels. */ - length?: number; - /** Specifies the distance between a value indicator and an invisible scale line. */ - offset?: number; - /** Specifies the type of the value indicator. */ - type?: string; - /** Specifies the orientation of the rangeBar value indicator on a horizontally oriented dxLinearGauge widget. */ - verticalOrientation?: string; - /** Specifies the width of a value indicator in pixels. */ - width?: number; - } export interface dxLinearGaugeOptions extends BaseGaugeOptions { /** Specifies the options required to set the geometry of the dxLinearGauge widget. */ geometry?: { @@ -4741,8 +4806,6 @@ declare module DevExpress.viz.gauges { /** Specifies gauge range container options. */ rangeContainer?: LinearRangeContainer; scale?: LinearScale; - subvalueIndicator?: LinearSubvalueIndicator; - valueIndicator?: LinearValueIndicator; } /** A widget that represents a gauge with a linear scale. */ export class dxLinearGauge extends dxBaseGauge { @@ -4764,28 +4827,6 @@ declare module DevExpress.viz.gauges { /** Specifies the orientation of scale ticks. */ orientation?: string; } - export interface CircularSubvalueIndicator extends BaseSubvalueIndicator { - /** Specifies the distance between a subvalue indicator and an invisible scale line in pixels. */ - offset?: number; - } - export interface CircularValueIndicator extends BaseValueIndicator { - /** Specifies the distance between the needle and the center of a gauge for the value indicator of needle-like types. */ - indentFromCenter?: number; - /** Specifies the distance between the value indicator and the invisible scale line. */ - offset?: number; - /** Specifies the second color for the value indicator of the twoColorNeedle type. */ - secondColor?: string; - /** Specifies the length of a twoNeedleColor type value indicator tip as a percentage. */ - secondFraction?: number; - /** Specifies the inner diameter in pixels, so that the spindle has the shape of a ring. */ - spindleGapSize?: number; - /** Specifies the spindle's diameter in pixels for the value indicator of a needle-like type. */ - spindleSize?: number; - /** Specifies the value indicator type. */ - type?: string; - /** Specifies, in pixels, the width for a value indicator of a needle-like type. */ - width?: number; - } export interface dxCircularGaugeOptions extends BaseGaugeOptions { /** Specifies the options required to set the geometry of the dxCircularGauge widget. */ geometry?: { @@ -4797,8 +4838,6 @@ declare module DevExpress.viz.gauges { /** Specifies gauge range container options. */ rangeContainer?: CircularRangeContainer; scale?: CircularScale; - subvalueIndicator?: CircularSubvalueIndicator; - valueIndicator?: CircularValueIndicator; } /** A widget that represents a gauge with a circular scale. */ export class dxCircularGauge extends dxBaseGauge { @@ -5478,165 +5517,268 @@ declare module DevExpress.viz.sparklines { } } interface JQuery { - dxProgressBar(options?: DevExpress.ui.dxProgressBarOptions): JQuery; - dxProgressBar(methodName: string, ...params: any[]): any; - dxProgressBar(methodName: "instance"): DevExpress.ui.dxProgressBar; - dxSlider(options?: DevExpress.ui.dxSliderOptions): JQuery; - dxSlider(methodName: string, ...params: any[]): any; - dxSlider(methodName: "instance"): DevExpress.ui.dxSlider; - dxRangeSlider(options?: DevExpress.ui.dxRangeSliderOptions): JQuery; - dxRangeSlider(methodName: string, ...params: any[]): any; - dxRangeSlider(methodName: "instance"): DevExpress.ui.dxRangeSlider; - dxFileUploader(options?: DevExpress.ui.dxFileUploaderOptions): JQuery; - dxFileUploader(methodName: string, ...params: any[]): any; - dxFileUploader(methodName: "instance"): DevExpress.ui.dxFileUploader; + dxProgressBar(): JQuery; + dxProgressBar(options: "instance"): DevExpress.ui.dxProgressBar; + dxProgressBar(options: string): any; + dxProgressBar(options: string, ...params: any[]): any; + dxProgressBar(options: DevExpress.ui.dxProgressBarOptions): JQuery; + dxSlider(): JQuery; + dxSlider(options: "instance"): DevExpress.ui.dxSlider; + dxSlider(options: string): any; + dxSlider(options: string, ...params: any[]): any; + dxSlider(options: DevExpress.ui.dxSliderOptions): JQuery; + dxRangeSlider(): JQuery; + dxRangeSlider(options: "instance"): DevExpress.ui.dxRangeSlider; + dxRangeSlider(options: string): any; + dxRangeSlider(options: string, ...params: any[]): any; + dxRangeSlider(options: DevExpress.ui.dxRangeSliderOptions): JQuery; + dxFileUploader(): JQuery; + dxFileUploader(options: "instance"): DevExpress.ui.dxFileUploader; + dxFileUploader(options: string): any; + dxFileUploader(options: string, ...params: any[]): any; + dxFileUploader(options: DevExpress.ui.dxFileUploaderOptions): JQuery; dxValidator(): JQuery; - dxValidator(methodName: string, ...params: any[]): any; - dxValidator(methodName: "instance"): DevExpress.ui.dxValidator; - dxValidatonGroup(): JQuery; - dxValidatonGroup(methodName: string, ...params: any[]): any; - dxValidatonGroup(methodName: "instance"): DevExpress.ui.dxValidationGroup; + dxValidator(options: "instance"): DevExpress.ui.dxValidator; + dxValidator(options: string): any; + dxValidator(options: string, ...params: any[]): any; + dxValidationGroup(): JQuery; + dxValidationGroup(options: "instance"): DevExpress.ui.dxValidationGroup; + dxValidationGroup(options: string): any; + dxValidationGroup(options: string, ...params: any[]): any; dxValidationSummary(): JQuery; - dxValidationSummary(methodName: string, ...params: any[]): any; - dxValidationSummary(methodName: "instance"): DevExpress.ui.dxValidationSummary; - dxTooltip(options?: DevExpress.ui.dxTooltipOptions): JQuery; - dxTooltip(methodName: string, ...params: any[]): any; - dxTooltip(methodName: "instance"): DevExpress.ui.dxTooltip; - dxDropDownList(options?: DevExpress.ui.dxDropDownListOptions): JQuery; - dxDropDownList(methodName: string, ...params: any[]): any; - dxDropDownList(methodName: "instance"): DevExpress.ui.dxDropDownList; - dxToolbar(options?: DevExpress.ui.dxToolbarOptions): JQuery; - dxToolbar(methodName: string, ...params: any[]): any; - dxToolbar(methodName: "instance"): DevExpress.ui.dxToolbar; - dxToast(options?: DevExpress.ui.dxToastOptions): JQuery; - dxToast(methodName: string, ...params: any[]): any; - dxToast(methodName: "instance"): DevExpress.ui.dxToast; - dxTextEditor(options?: DevExpress.ui.dxTextEditorOptions): JQuery; - dxTextEditor(methodName: string, ...params: any[]): any; - dxTextEditor(methodName: "instance"): DevExpress.ui.dxTextEditor; - dxTextBox(options?: DevExpress.ui.dxTextBoxOptions): JQuery; - dxTextBox(methodName: string, ...params: any[]): any; - dxTextBox(methodName: "instance"): DevExpress.ui.dxTextBox; - dxTextArea(options?: DevExpress.ui.dxTextAreaOptions): JQuery; - dxTextArea(methodName: string, ...params: any[]): any; - dxTextArea(methodName: "instance"): DevExpress.ui.dxTextArea; - dxTabs(options?: DevExpress.ui.dxTabsOptions): JQuery; - dxTabs(methodName: string, ...params: any[]): any; - dxTabs(methodName: "instance"): DevExpress.ui.dxTabs; - dxTabPanel(options?: DevExpress.ui.dxTabPanelOptions): JQuery; - dxTabPanel(methodName: string, ...params: any[]): any; - dxTabPanel(methodName: "instance"): DevExpress.ui.dxTabPanel; - dxSelectBox(options?: DevExpress.ui.dxSelectBoxOptions): JQuery; - dxSelectBox(methodName: string, ...params: any[]): any; - dxSelectBox(methodName: "instance"): DevExpress.ui.dxSelectBox; - dxScrollView(options?: DevExpress.ui.dxScrollViewOptions): JQuery; - dxScrollView(methodName: string, ...params: any[]): any; - dxScrollView(methodName: "instance"): DevExpress.ui.dxScrollView; - dxScrollable(options?: DevExpress.ui.dxScrollableOptions): JQuery; - dxScrollable(methodName: string, ...params: any[]): any; - dxScrollable(methodName: "instance"): DevExpress.ui.dxScrollable; - dxRadioGroup(options?: DevExpress.ui.dxRadioGroupOptions): JQuery; - dxRadioGroup(methodName: string, ...params: any[]): any; - dxRadioGroup(methodName: "instance"): DevExpress.ui.dxRadioGroup; - dxPopup(options?: DevExpress.ui.dxPopupOptions): JQuery; - dxPopup(methodName: string, ...params: any[]): any; - dxPopup(methodName: "instance"): DevExpress.ui.dxPopup; - dxPopover(options?: DevExpress.ui.dxPopoverOptions): JQuery; - dxPopover(methodName: string, ...params: any[]): any; - dxPopover(methodName: "instance"): DevExpress.ui.dxPopover; - dxOverlay(options?: DevExpress.ui.dxOverlayOptions): JQuery; - dxOverlay(methodName: string, ...params: any[]): any; - dxOverlay(methodName: "instance"): DevExpress.ui.dxOverlay; - dxNumberBox(options?: DevExpress.ui.dxNumberBoxOptions): JQuery; - dxNumberBox(methodName: string, ...params: any[]): any; - dxNumberBox(methodName: "instance"): DevExpress.ui.dxNumberBox; - dxNavBar(options?: DevExpress.ui.dxNavBarOptions): JQuery; - dxNavBar(methodName: string, ...params: any[]): any; - dxNavBar(methodName: "instance"): DevExpress.ui.dxNavBar; - dxMultiView(options?: DevExpress.ui.dxMultiViewOptions): JQuery; - dxMultiView(methodName: string, ...params: any[]): any; - dxMultiView(methodName: "instance"): DevExpress.ui.dxMultiView; - dxMap(options?: DevExpress.ui.dxMapOptions): JQuery; - dxMap(methodName: string, ...params: any[]): any; - dxMap(methodName: "instance"): DevExpress.ui.dxMap; - dxLookup(options?: DevExpress.ui.dxLookupOptions): JQuery; - dxLookup(methodName: string, ...params: any[]): any; - dxLookup(methodName: "instance"): DevExpress.ui.dxLookup; - dxLoadPanel(options?: DevExpress.ui.dxLoadPanelOptions): JQuery; - dxLoadPanel(methodName: string, ...params: any[]): any; - dxLoadPanel(methodName: "instance"): DevExpress.ui.dxLoadPanel; - dxLoadIndicator(options?: DevExpress.ui.dxLoadIndicatorOptions): JQuery; - dxLoadIndicator(methodName: string, ...params: any[]): any; - dxLoadIndicator(methodName: "instance"): DevExpress.ui.dxLoadIndicator; - dxList(options?: DevExpress.ui.dxListOptions): JQuery; - dxList(methodName: string, ...params: any[]): any; - dxList(methodName: "instance"): DevExpress.ui.dxList; - dxGallery(options?: DevExpress.ui.dxGalleryOptions): JQuery; - dxGallery(methodName: string, ...params: any[]): any; - dxGallery(methodName: "instance"): DevExpress.ui.dxGallery; - dxDropDownEditor(options?: DevExpress.ui.dxDropDownEditorOptions): JQuery; - dxDropDownEditor(methodName: string, ...params: any[]): any; - dxDropDownEditor(methodName: "instance"): DevExpress.ui.dxDropDownEditor; - dxDateBox(options?: DevExpress.ui.dxDateBoxOptions): JQuery; - dxDateBox(methodName: string, ...params: any[]): any; - dxDateBox(methodName: "instance"): DevExpress.ui.dxDateBox; - dxCheckBox(options?: DevExpress.ui.dxCheckBoxOptions): JQuery; - dxCheckBox(methodName: string, ...params: any[]): any; - dxCheckBox(methodName: "instance"): DevExpress.ui.dxCheckBox; - dxBox(options?: DevExpress.ui.dxBoxOptions): JQuery; - dxBox(methodName: string, ...params: any[]): any; - dxBox(methodName: "instance"): DevExpress.ui.dxBox; - dxButton(options?: DevExpress.ui.dxButtonOptions): JQuery; - dxButton(methodName: string, ...params: any[]): any; - dxButton(methodName: "instance"): DevExpress.ui.dxButton; - dxCalendar(options?: DevExpress.ui.dxCalendarOptions): JQuery; - dxCalendar(methodName: string, ...params: any[]): any; - dxCalendar(methodName: "instance"): DevExpress.ui.dxCalendar; - dxAccordion(options?: DevExpress.ui.dxAccordionOptions): JQuery; - dxAccordion(methodName: string, ...params: any[]): any; - dxAccordion(methodName: "instance"): DevExpress.ui.dxAccordion; - dxAutocomplete(options?: DevExpress.ui.dxAutocompleteOptions): JQuery; - dxAutocomplete(methodName: string, ...params: any[]): any; - dxAutocomplete(methodName: "instance"): DevExpress.ui.dxAutocomplete; - dxTileView(options?: DevExpress.ui.dxTileViewOptions): JQuery; - dxTileView(methodName: string, ...params: any[]): any; - dxTileView(methodName: "instance"): DevExpress.ui.dxTileView; - dxSwitch(options?: DevExpress.ui.dxSwitchOptions): JQuery; - dxSwitch(methodName: string, ...params: any[]): any; - dxSwitch(methodName: "instance"): DevExpress.ui.dxSwitch; - dxSlideOut(options?: DevExpress.ui.dxSlideoutOptions): JQuery; - dxSlideOut(methodName: string, ...params: any[]): any; - dxSlideOut(methodName: "instance"): DevExpress.ui.dxSlideOut; - dxPivot(options?: DevExpress.ui.dxPivotOptions): JQuery; - dxPivot(methodName: string, ...params: any[]): any; - dxPivot(methodName: "instance"): DevExpress.ui.dxPivot; - dxPanorama(options?: DevExpress.ui.dxPanoramaOptions): JQuery; - dxPanorama(methodName: string, ...params: any[]): any; - dxPanorama(methodName: "instance"): DevExpress.ui.dxPanorama; - dxActionSheet(options?: DevExpress.ui.dxActionSheetOptions): JQuery; - dxActionSheet(methodName: string, ...params: any[]): any; - dxActionSheet(methodName: "instance"): DevExpress.ui.dxActionSheet; - dxDropDownMenu(options?: DevExpress.ui.dxDropDownMenuOptions): JQuery; - dxDropDownMenu(methodName: string, ...params: any[]): any; - dxDropDownMenu(methodName: "instance"): DevExpress.ui.dxDropDownMenu; - dxTreeView(options?: DevExpress.ui.dxTreeViewOptions): JQuery; - dxTreeView(methodName: string, ...params: any[]): any; - dxTreeView(methodName: "instance"): DevExpress.ui.dxTreeView; - dxMenuBase(options?: DevExpress.ui.dxMenuBaseOptions): JQuery; - dxMenuBase(methodName: string, ...params: any[]): any; - dxMenuBase(methodName: "instance"): DevExpress.ui.dxMenuBase; - dxMenu(options?: DevExpress.ui.dxMenuOptions): JQuery; - dxMenu(methodName: string, ...params: any[]): any; - dxMenu(methodName: "instance"): DevExpress.ui.dxMenu; - dxContextMenu(options?: DevExpress.ui.dxContextMenuOptions): JQuery; - dxContextMenu(methodName: string, ...params: any[]): any; - dxContextMenu(methodName: "instance"): DevExpress.ui.dxContextMenu; - dxColorBox(options?: DevExpress.ui.dxColorBoxOptions): JQuery; - dxColorBox(methodName: string, ...params: any[]): any; - dxColorBox(methodName: "instance"): DevExpress.ui.dxColorBox; - dxDataGrid(options?: DevExpress.ui.dxDataGridOptions): JQuery; - dxDataGrid(methodName: string, ...params: any[]): any; - dxDataGrid(methodName: "instance"): DevExpress.ui.dxDataGrid; + dxValidationSummary(options: "instance"): DevExpress.ui.dxValidationSummary; + dxValidationSummary(options: string): any; + dxValidationSummary(options: string, ...params: any[]): any; + dxTooltip(): JQuery; + dxTooltip(options: "instance"): DevExpress.ui.dxTooltip; + dxTooltip(options: string): any; + dxTooltip(options: string, ...params: any[]): any; + dxTooltip(options: DevExpress.ui.dxTooltipOptions): JQuery; + dxDropDownList(): JQuery; + dxDropDownList(options: "instance"): DevExpress.ui.dxDropDownList; + dxDropDownList(options: string): any; + dxDropDownList(options: string, ...params: any[]): any; + dxDropDownList(options: DevExpress.ui.dxDropDownListOptions): JQuery; + dxToolbar(): JQuery; + dxToolbar(options: "instance"): DevExpress.ui.dxToolbar; + dxToolbar(options: string): any; + dxToolbar(options: string, ...params: any[]): any; + dxToolbar(options: DevExpress.ui.dxToolbarOptions): JQuery; + dxToast(): JQuery; + dxToast(options: "instance"): DevExpress.ui.dxToast; + dxToast(options: string): any; + dxToast(options: string, ...params: any[]): any; + dxToast(options: DevExpress.ui.dxToastOptions): JQuery; + dxTextEditor(): JQuery; + dxTextEditor(options: "instance"): DevExpress.ui.dxTextEditor; + dxTextEditor(options: string): any; + dxTextEditor(options: string, ...params: any[]): any; + dxTextEditor(options: DevExpress.ui.dxTextEditorOptions): JQuery; + dxTextBox(): JQuery; + dxTextBox(options: "instance"): DevExpress.ui.dxTextBox; + dxTextBox(options: string): any; + dxTextBox(options: string, ...params: any[]): any; + dxTextBox(options: DevExpress.ui.dxTextBoxOptions): JQuery; + dxTextArea(): JQuery; + dxTextArea(options: "instance"): DevExpress.ui.dxTextArea; + dxTextArea(options: string): any; + dxTextArea(options: string, ...params: any[]): any; + dxTextArea(options: DevExpress.ui.dxTextAreaOptions): JQuery; + dxTabs(): JQuery; + dxTabs(options: "instance"): DevExpress.ui.dxTabs; + dxTabs(options: string): any; + dxTabs(options: string, ...params: any[]): any; + dxTabs(options: DevExpress.ui.dxTabsOptions): JQuery; + dxTabPanel(): JQuery; + dxTabPanel(options: "instance"): DevExpress.ui.dxTabPanel; + dxTabPanel(options: string): any; + dxTabPanel(options: string, ...params: any[]): any; + dxTabPanel(options: DevExpress.ui.dxTabPanelOptions): JQuery; + dxSelectBox(): JQuery; + dxSelectBox(options: "instance"): DevExpress.ui.dxSelectBox; + dxSelectBox(options: string): any; + dxSelectBox(options: string, ...params: any[]): any; + dxSelectBox(options: DevExpress.ui.dxSelectBoxOptions): JQuery; + dxScrollView(): JQuery; + dxScrollView(options: "instance"): DevExpress.ui.dxScrollView; + dxScrollView(options: string): any; + dxScrollView(options: string, ...params: any[]): any; + dxScrollView(options: DevExpress.ui.dxScrollViewOptions): JQuery; + dxScrollable(): JQuery; + dxScrollable(options: "instance"): DevExpress.ui.dxScrollable; + dxScrollable(options: string): any; + dxScrollable(options: string, ...params: any[]): any; + dxScrollable(options: DevExpress.ui.dxScrollableOptions): JQuery; + dxRadioGroup(): JQuery; + dxRadioGroup(options: "instance"): DevExpress.ui.dxRadioGroup; + dxRadioGroup(options: string): any; + dxRadioGroup(options: string, ...params: any[]): any; + dxRadioGroup(options: DevExpress.ui.dxRadioGroupOptions): JQuery; + dxPopup(): JQuery; + dxPopup(options: "instance"): DevExpress.ui.dxPopup; + dxPopup(options: string): any; + dxPopup(options: string, ...params: any[]): any; + dxPopup(options: DevExpress.ui.dxPopupOptions): JQuery; + dxPopover(): JQuery; + dxPopover(options: "instance"): DevExpress.ui.dxPopover; + dxPopover(options: string): any; + dxPopover(options: string, ...params: any[]): any; + dxPopover(options: DevExpress.ui.dxPopoverOptions): JQuery; + dxOverlay(): JQuery; + dxOverlay(options: "instance"): DevExpress.ui.dxOverlay; + dxOverlay(options: string): any; + dxOverlay(options: string, ...params: any[]): any; + dxOverlay(options: DevExpress.ui.dxOverlayOptions): JQuery; + dxNumberBox(): JQuery; + dxNumberBox(options: "instance"): DevExpress.ui.dxNumberBox; + dxNumberBox(options: string): any; + dxNumberBox(options: string, ...params: any[]): any; + dxNumberBox(options: DevExpress.ui.dxNumberBoxOptions): JQuery; + dxNavBar(): JQuery; + dxNavBar(options: "instance"): DevExpress.ui.dxNavBar; + dxNavBar(options: string): any; + dxNavBar(options: string, ...params: any[]): any; + dxNavBar(options: DevExpress.ui.dxNavBarOptions): JQuery; + dxMultiView(): JQuery; + dxMultiView(options: "instance"): DevExpress.ui.dxMultiView; + dxMultiView(options: string): any; + dxMultiView(options: string, ...params: any[]): any; + dxMultiView(options: DevExpress.ui.dxMultiViewOptions): JQuery; + dxMap(): JQuery; + dxMap(options: "instance"): DevExpress.ui.dxMap; + dxMap(options: string): any; + dxMap(options: string, ...params: any[]): any; + dxMap(options: DevExpress.ui.dxMapOptions): JQuery; + dxLookup(): JQuery; + dxLookup(options: "instance"): DevExpress.ui.dxLookup; + dxLookup(options: string): any; + dxLookup(options: string, ...params: any[]): any; + dxLookup(options: DevExpress.ui.dxLookupOptions): JQuery; + dxLoadPanel(): JQuery; + dxLoadPanel(options: "instance"): DevExpress.ui.dxLoadPanel; + dxLoadPanel(options: string): any; + dxLoadPanel(options: string, ...params: any[]): any; + dxLoadPanel(options: DevExpress.ui.dxLoadPanelOptions): JQuery; + dxLoadIndicator(): JQuery; + dxLoadIndicator(options: "instance"): DevExpress.ui.dxLoadIndicator; + dxLoadIndicator(options: string): any; + dxLoadIndicator(options: string, ...params: any[]): any; + dxLoadIndicator(options: DevExpress.ui.dxLoadIndicatorOptions): JQuery; + dxList(): JQuery; + dxList(options: "instance"): DevExpress.ui.dxList; + dxList(options: string): any; + dxList(options: string, ...params: any[]): any; + dxList(options: DevExpress.ui.dxListOptions): JQuery; + dxGallery(): JQuery; + dxGallery(options: "instance"): DevExpress.ui.dxGallery; + dxGallery(options: string): any; + dxGallery(options: string, ...params: any[]): any; + dxGallery(options: DevExpress.ui.dxGalleryOptions): JQuery; + dxDropDownEditor(): JQuery; + dxDropDownEditor(options: "instance"): DevExpress.ui.dxDropDownEditor; + dxDropDownEditor(options: string): any; + dxDropDownEditor(options: string, ...params: any[]): any; + dxDropDownEditor(options: DevExpress.ui.dxDropDownEditorOptions): JQuery; + dxDateBox(): JQuery; + dxDateBox(options: "instance"): DevExpress.ui.dxDateBox; + dxDateBox(options: string): any; + dxDateBox(options: string, ...params: any[]): any; + dxDateBox(options: DevExpress.ui.dxDateBoxOptions): JQuery; + dxCheckBox(): JQuery; + dxCheckBox(options: "instance"): DevExpress.ui.dxCheckBox; + dxCheckBox(options: string): any; + dxCheckBox(options: string, ...params: any[]): any; + dxCheckBox(options: DevExpress.ui.dxCheckBoxOptions): JQuery; + dxBox(): JQuery; + dxBox(options: "instance"): DevExpress.ui.dxBox; + dxBox(options: string): any; + dxBox(options: string, ...params: any[]): any; + dxBox(options: DevExpress.ui.dxBoxOptions): JQuery; + dxButton(): JQuery; + dxButton(options: "instance"): DevExpress.ui.dxButton; + dxButton(options: string): any; + dxButton(options: string, ...params: any[]): any; + dxButton(options: DevExpress.ui.dxButtonOptions): JQuery; + dxCalendar(): JQuery; + dxCalendar(options: "instance"): DevExpress.ui.dxCalendar; + dxCalendar(options: string): any; + dxCalendar(options: string, ...params: any[]): any; + dxCalendar(options: DevExpress.ui.dxCalendarOptions): JQuery; + dxAccordion(): JQuery; + dxAccordion(options: "instance"): DevExpress.ui.dxAccordion; + dxAccordion(options: string): any; + dxAccordion(options: string, ...params: any[]): any; + dxAccordion(options: DevExpress.ui.dxAccordionOptions): JQuery; + dxAutocomplete(): JQuery; + dxAutocomplete(options: "instance"): DevExpress.ui.dxAutocomplete; + dxAutocomplete(options: string): any; + dxAutocomplete(options: string, ...params: any[]): any; + dxAutocomplete(options: DevExpress.ui.dxAutocompleteOptions): JQuery; + dxTileView(): JQuery; + dxTileView(options: "instance"): DevExpress.ui.dxTileView; + dxTileView(options: string): any; + dxTileView(options: string, ...params: any[]): any; + dxTileView(options: DevExpress.ui.dxTileViewOptions): JQuery; + dxSwitch(): JQuery; + dxSwitch(options: "instance"): DevExpress.ui.dxSwitch; + dxSwitch(options: string): any; + dxSwitch(options: string, ...params: any[]): any; + dxSwitch(options: DevExpress.ui.dxSwitchOptions): JQuery; + dxSlideOut(): JQuery; + dxSlideOut(options: "instance"): DevExpress.ui.dxSlideOut; + dxSlideOut(options: string): any; + dxSlideOut(options: string, ...params: any[]): any; + dxSlideOut(options: DevExpress.ui.dxSlideOutOptions): JQuery; + dxPivot(): JQuery; + dxPivot(options: "instance"): DevExpress.ui.dxPivot; + dxPivot(options: string): any; + dxPivot(options: string, ...params: any[]): any; + dxPivot(options: DevExpress.ui.dxPivotOptions): JQuery; + dxPanorama(): JQuery; + dxPanorama(options: "instance"): DevExpress.ui.dxPanorama; + dxPanorama(options: string): any; + dxPanorama(options: string, ...params: any[]): any; + dxPanorama(options: DevExpress.ui.dxPanoramaOptions): JQuery; + dxActionSheet(): JQuery; + dxActionSheet(options: "instance"): DevExpress.ui.dxActionSheet; + dxActionSheet(options: string): any; + dxActionSheet(options: string, ...params: any[]): any; + dxActionSheet(options: DevExpress.ui.dxActionSheetOptions): JQuery; + dxDropDownMenu(): JQuery; + dxDropDownMenu(options: "instance"): DevExpress.ui.dxDropDownMenu; + dxDropDownMenu(options: string): any; + dxDropDownMenu(options: string, ...params: any[]): any; + dxDropDownMenu(options: DevExpress.ui.dxDropDownMenuOptions): JQuery; + dxTreeView(): JQuery; + dxTreeView(options: "instance"): DevExpress.ui.dxTreeView; + dxTreeView(options: string): any; + dxTreeView(options: string, ...params: any[]): any; + dxTreeView(options: DevExpress.ui.dxTreeViewOptions): JQuery; + dxMenuBase(): JQuery; + dxMenuBase(options: "instance"): DevExpress.ui.dxMenuBase; + dxMenuBase(options: string): any; + dxMenuBase(options: string, ...params: any[]): any; + dxMenuBase(options: DevExpress.ui.dxMenuBaseOptions): JQuery; + dxMenu(): JQuery; + dxMenu(options: "instance"): DevExpress.ui.dxMenu; + dxMenu(options: string): any; + dxMenu(options: string, ...params: any[]): any; + dxMenu(options: DevExpress.ui.dxMenuOptions): JQuery; + dxContextMenu(): JQuery; + dxContextMenu(options: "instance"): DevExpress.ui.dxContextMenu; + dxContextMenu(options: string): any; + dxContextMenu(options: string, ...params: any[]): any; + dxContextMenu(options: DevExpress.ui.dxContextMenuOptions): JQuery; + dxColorBox(): JQuery; + dxColorBox(options: "instance"): DevExpress.ui.dxColorBox; + dxColorBox(options: string): any; + dxColorBox(options: string, ...params: any[]): any; + dxColorBox(options: DevExpress.ui.dxColorBoxOptions): JQuery; + dxDataGrid(): JQuery; + dxDataGrid(options: "instance"): DevExpress.ui.dxDataGrid; + dxDataGrid(options: string): any; + dxDataGrid(options: string, ...params: any[]): any; + dxDataGrid(options: DevExpress.ui.dxDataGridOptions): JQuery; dxChart(options?: DevExpress.viz.charts.dxChartOptions): JQuery; dxChart(methodName: string, ...params: any[]): any; dxChart(methodName: "instance"): DevExpress.viz.charts.dxChart; From 8636f410705b4dc1a68ac9a9526a5256db872f2d Mon Sep 17 00:00:00 2001 From: Igor Kriklivets Date: Wed, 3 Jun 2015 12:19:16 +0300 Subject: [PATCH 104/397] Fix for previous commit --- devextreme/dx.devextreme.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devextreme/dx.devextreme.d.ts b/devextreme/dx.devextreme.d.ts index f2b6a9048..a1d361f54 100644 --- a/devextreme/dx.devextreme.d.ts +++ b/devextreme/dx.devextreme.d.ts @@ -740,11 +740,12 @@ declare module DevExpress { isValid?: boolean; /** Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed. */ validationMessageMode?: string; - /** Resets the editor's value to undefined. */ - reset(): void; } /** A base class for editors. */ - export class Editor extends Widget { } + export class Editor extends Widget { + /** Resets the editor's value to undefined. */ + reset(): void; + } /** An object that serves as a namespace for methods displaying a message in an application/site. */ export var dialog: { /** Creates an alert dialog message containing a single "OK" button. */ From 45c923a5f8426b93b07dfab456004879001a3cf7 Mon Sep 17 00:00:00 2001 From: Eik Date: Wed, 3 Jun 2015 14:11:42 +0200 Subject: [PATCH 105/397] Corrected an issue that didn't allow me to use an extended PageableCollection in a Marionette.compositeView. --- backbone.paginator/backbone.paginator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backbone.paginator/backbone.paginator.d.ts b/backbone.paginator/backbone.paginator.d.ts index 6eb560cc8..eb0a71962 100644 --- a/backbone.paginator/backbone.paginator.d.ts +++ b/backbone.paginator/backbone.paginator.d.ts @@ -52,7 +52,7 @@ declare module Backbone { type PageableGetPageOptions = CollectionFetchOptions|Silenceable; - class PageableCollection extends Collection{ + class PageableCollection extends Collection{ fullCollection: Collection; mode: string; From 5fdac5f3478e1691eca2f33a8db19454bb7d9f0c Mon Sep 17 00:00:00 2001 From: Josh Petersen Date: Wed, 3 Jun 2015 09:34:42 -0400 Subject: [PATCH 106/397] added definitions and tests for project xlsx https://github.com/SheetJS/js-xlsx --- xlsx/xlsx-tests.ts | 26 +++++++++ xlsx/xlsx.d.ts | 136 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 xlsx/xlsx-tests.ts create mode 100644 xlsx/xlsx.d.ts diff --git a/xlsx/xlsx-tests.ts b/xlsx/xlsx-tests.ts new file mode 100644 index 000000000..7a4054626 --- /dev/null +++ b/xlsx/xlsx-tests.ts @@ -0,0 +1,26 @@ +/// +import xlsx = require('xlsx'); + +var options:xlsx.IParsingOptions = { + cellDates:true +}; + +var workbook = xlsx.readFile('test.xlsx', options); +var otherworkbook = xlsx.readFile('test.xlsx', {type: 'file'}); + +console.log(workbook.Props.Author); + +var firstsheet:string = workbook.SheetNames[0]; + +var firstworksheet = workbook.Sheets[firstsheet]; + +console.log(firstworksheet["A1"]); + +interface tester { + name:string; + age: number; +} + +var jsonvalues:tester[] = xlsx.utils.sheet_to_json(firstworksheet); +var csv = xlsx.utils.sheet_to_csv(firstworksheet); +var formulae = xlsx.utils.sheet_to_formulae(firstworksheet); diff --git a/xlsx/xlsx.d.ts b/xlsx/xlsx.d.ts new file mode 100644 index 000000000..16df800dd --- /dev/null +++ b/xlsx/xlsx.d.ts @@ -0,0 +1,136 @@ +// Type definitions for xlsx +// Project: https://github.com/SheetJS/js-xlsx +// Definitions by: themauveavenger +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'xlsx' { + + export function readFile(filename:string, opts?:IParsingOptions):IWorkBook; + export function read(data:any, opts?:IParsingOptions):IWorkBook; + export var utils:IUtils; + + export interface IProperties { + LastAuthor?:string + Author?:string; + CreatedDate?:Date; + ModifiedDate?:Date + Application?:string; + AppVersion?:string; + Company?:string; + DocSecurity?:string; + Manager?:string; + HyperlinksChanged?: boolean; + SharedDoc?:boolean; + LinksUpToDate?:boolean; + ScaleCrop?:boolean; + Worksheets?:number; + SheetNames?:string[]; + } + + export interface IParsingOptions { + cellFormula?:boolean; + cellHTML?:boolean; + cellNF?:boolean; + cellStyles?:boolean; + cellDates?:boolean; + sheetStubs?:boolean; + sheetRows?:number; + bookDeps?:boolean; + bookFiles?:boolean; + bookProps?:boolean; + bookSheets?:boolean; + bookVBA?:boolean; + password?:string; + + /** + * Possible options: 'binary', 'base64', 'buffer', 'file' + */ + type?:string; + } + + export interface IWorkBook { + /** + * A dictionary of the worksheets in the workbook. + * Use SheetNames to reference these. + */ + Sheets:{[sheet:string]:IWorkSheet}; + + /** + * ordered list of the sheet names in the workbook + */ + SheetNames:string[]; + + /** + * an object storing the standard properties. wb.Custprops stores custom properties. + * Since the XLS standard properties deviate from the XLSX standard, XLS parsing stores core properties in both places. + */ + Props:IProperties; + } + + /** + * object representing the worksheet + */ + export interface IWorkSheet { + [cell:string]:IWorkSheetCell; + } + + export interface IWorkSheetCell { + /** + * The Excel Data Type of the cell. + * b Boolean, n Number, e error, s String, d Date + */ + t: string; + + /** + * The raw value of the cell. + */ + v: string; + + /** + * rich text encoding (if applicable) + */ + r?: string; + + /** + * HTML rendering of the rich text (if applicable) + */ + h?: string; + + /** + * formatted text (if applicable) + */ + w?: string; + + /** + * cell formula (if applicable) + */ + f?: string; + + /** + * comments associated with the cell ** + */ + c?: string; + + /** + * number format string associated with the cell (if requested) + */ + z?: string; + + /** + * cell hyperlink object (.Target holds link, .tooltip is tooltip) + */ + l?: string; + + /** + * the style/theme of the cell (if applicable) + */ + s?: string; + } + + export interface IUtils { + sheet_to_json(worksheet:IWorkSheet|IWorkBook):T[]; + sheet_to_csv(worksheet:IWorkSheet):any; + sheet_to_formulae(worksheet:IWorkSheet):any; + } + +} From c8436fbe1eb00d52f7ed123311a64d5bded7ee87 Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Wed, 3 Jun 2015 10:29:07 -0400 Subject: [PATCH 107/397] removed extraneous files --- node-calendar/.gitignore | 4 ---- node-calendar/package.json | 14 -------------- 2 files changed, 18 deletions(-) delete mode 100644 node-calendar/.gitignore delete mode 100755 node-calendar/package.json diff --git a/node-calendar/.gitignore b/node-calendar/.gitignore deleted file mode 100644 index 76136c9e9..000000000 --- a/node-calendar/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.js -tsconfig.json -node_modules -.settings \ No newline at end of file diff --git a/node-calendar/package.json b/node-calendar/package.json deleted file mode 100755 index 8cc162a95..000000000 --- a/node-calendar/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "node-calendar.d.ts", - "version": "0.0.1", - "description": "Type definitions for node-calendar v0.1.4", - "main": "node-calendar-tests", - "scripts": { - "test": "node node-calendar-tests" - }, - "author": "Luzian Zagadinow (https://github.com/luzianz)", - "license": "MIT", - "dependencies": { - "node-calendar": "^0.1.4" - } -} \ No newline at end of file From 265b807686458b8a3adeab00ecba82b99927ca53 Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 11:56:52 -0500 Subject: [PATCH 108/397] added username to facebook profile --- passport-facebook/passport-facebook.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts index 855b033f5..26479cc29 100644 --- a/passport-facebook/passport-facebook.d.ts +++ b/passport-facebook/passport-facebook.d.ts @@ -13,6 +13,7 @@ declare module 'passport-facebook' { interface Profile extends passport.Profile { gender: string; profileUrl: string; + username: string; } interface IStrategyOption { From 4ad9034a401094b53bb01ae1ed113b401f128e43 Mon Sep 17 00:00:00 2001 From: Olivier Foissac Date: Wed, 3 Jun 2015 18:57:03 +0200 Subject: [PATCH 109/397] * Add comments from https://developers.google.com/maps/documentation/javascript/3.19/reference on MarkerOptions, Symbol, SymbolPath, InfoWindow, InfoWindowOptions, LatLng, Point. * Add missing interface google.maps.Icon. --- googlemaps/google.maps-tests.ts | 13 +- googlemaps/google.maps.d.ts | 212 ++++++++++++++++++++++++++++++-- 2 files changed, 214 insertions(+), 11 deletions(-) diff --git a/googlemaps/google.maps-tests.ts b/googlemaps/google.maps-tests.ts index 1079f78b2..23931850d 100644 --- a/googlemaps/google.maps-tests.ts +++ b/googlemaps/google.maps-tests.ts @@ -104,4 +104,15 @@ var removePropertyEvent: google.maps.Data.RemovePropertyEvent = { feature: feature, name: "test", oldValue: {} -}; \ No newline at end of file +}; + + +/***** Overlays *****/ + +var icon: google.maps.Icon = { + anchor: new google.maps.Point(16, 16), + origin: new google.maps.Point(0, 0), + scaledSize: new google.maps.Size(32, 32), + size: new google.maps.Size(32, 32), + url: "dummy" +} \ No newline at end of file diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index fe4e7459c..ecf319c83 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -397,23 +397,86 @@ declare module google.maps { } export interface MarkerOptions { + /** Which animation to play when marker is added to a map. */ animation?: Animation; + /** + * If true, the marker receives mouse and touch events. + * @default true + */ clickable?: boolean; + /** Mouse cursor to show on hover. */ cursor?: string; + /** + * If true, the marker can be dragged. + * @default false + */ draggable?: boolean; flat?: boolean; + /** + * Icon for the foreground. + * If a string is provided, it is treated as though it were an Icon with the string as url. + * @type {(string|Icon|Symbol)} + */ icon?: any; + /** + * Map on which to display Marker. + * @type {(Map|StreetViewPanorama)} + */ map?: any; + /** + * Optimization renders many markers as a single static element. + * Optimized rendering is enabled by default. + * Disable optimized rendering for animated GIFs or PNGs, or when each marker must be rendered + * as a separate DOM element (advanced usage only). + */ optimized?: boolean; + /** + * Marker position. Required. + */ position?: LatLng; raiseOnDrag?: boolean; shadow?: any; + /** Image map region definition used for drag/click. */ shape?: MarkerShape; + /** Rollover text. */ title?: string; + /** If true, the marker is visible. */ visible?: boolean; + /** + * All markers are displayed on the map in order of their zIndex, + * with higher values displaying in front of markers with lower values. + * By default, markers are displayed according to their vertical position on screen, + * with lower markers appearing in front of markers further up the screen. + */ zIndex?: number; } + export interface Icon { + /** + * The position at which to anchor an image in correspondence to the location of the marker on the map. + * By default, the anchor is located along the center point of the bottom of the image. + */ + anchor?: Point; + /** + * The position of the image within a sprite, if any. + * By default, the origin is located at the top left corner of the image (0, 0). + */ + origin?: Point; + /** + * The size of the entire image after scaling, if any. + * Use this property to stretch/ shrink an image or a sprite. + */ + scaledSize?: Size; + /** + * The display size of the sprite or image. + * When using sprites, you must specify the sprite size. + * If the size is not provided, it will be set when the image loads. + */ + size?: Size; + /** The URL of the image or sprite sheet. */ + url?: string; + } + export class MarkerImage { constructor (url: string, size?: Size, origin?: Point, anchor?: Point, scaledSize?: Size); anchor: Point; @@ -429,22 +492,68 @@ declare module google.maps { } export interface Symbol { + /** + * The position of the symbol relative to the marker or polyline. + * The coordinates of the symbol's path are translated left and up by the anchor's x and y coordinates respectively. + * By default, a symbol is anchored at (0, 0). + * The position is expressed in the same coordinate system as the symbol's path. + */ anchor?: Point; + /** + * The symbol's fill color. + * All CSS3 colors are supported except for extended named colors. For symbol markers, this defaults to 'black'. + * For symbols on polylines, this defaults to the stroke color of the corresponding polyline. + */ fillColor?: string; + /** + * The symbol's fill opacity. + * @default 0 + */ fillOpacity?: number; + /** + * The symbol's path, which is a built-in symbol path, or a custom path expressed using SVG path notation. Required. + * @type {(SymbolPath|string)} + */ path?: any; + /** + * The angle by which to rotate the symbol, expressed clockwise in degrees. + * Defaults to 0. + * A symbol in an IconSequence where fixedRotation is false is rotated relative to the angle of the edge on which it lies. + */ rotation?: number; + /** + * The amount by which the symbol is scaled in size. + * For symbol markers, this defaults to 1; after scaling, the symbol may be of any size. + * For symbols on a polyline, this defaults to the stroke weight of the polyline; + * after scaling, the symbol must lie inside a square 22 pixels in size centered at the symbol's anchor. + */ scale?: number; + /** + * The symbol's stroke color. All CSS3 colors are supported except for extended named colors. + * For symbol markers, this defaults to 'black'. + * For symbols on a polyline, this defaults to the stroke color of the polyline. + */ strokeColor?: string; + /** + * The symbol's stroke opacity. For symbol markers, this defaults to 1. + * For symbols on a polyline, this defaults to the stroke opacity of the polyline. + */ strokeOpacity?: number; + /** The symbol's stroke weight. Defaults to the scale of the symbol.v*/ strokeWeight?: number; } + /** Built-in symbol paths. */ export enum SymbolPath { + /** A backward-pointing closed arrow. */ BACKWARD_CLOSED_ARROW, + /** A backward-pointing open arrow. */ BACKWARD_OPEN_ARROW, + /** A circle. */ CIRCLE, + /** A forward-pointing closed arrow. */ FORWARD_CLOSED_ARROW, + /** A forward-pointing open arrow. */ FORWARD_OPEN_ARROW } @@ -453,13 +562,33 @@ declare module google.maps { DROP } + /** + * An overlay that looks like a bubble and is often connected to a marker. + * This class extends MVCObject. + */ export class InfoWindow extends MVCObject { - constructor (opts?: InfoWindowOptions); + /** + * Creates an info window with the given options. + * An InfoWindow can be placed on a map at a particular position or above a marker, + * depending on what is specified in the options. + * Unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened. + * After constructing an InfoWindow, you must call open to display it on the map. + * The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect. + */ + constructor(opts?: InfoWindowOptions); + /** Closes this InfoWindow by removing it from the DOM structure. */ close(): void; getContent(): any; // string or Element getPosition(): LatLng; getZIndex(): number; open(map?: Map, anchor?: MVCObject): void; + /** + * Opens this InfoWindow on the given map. Optionally, an InfoWindow can be associated with an anchor. + * In the core API, the only anchor is the Marker class. + * However, an anchor can be any MVCObject that exposes a LatLng position property and optionally + * a Point anchorPoint property for calculating the pixelOffset (see InfoWindowOptions). + * The anchorPoint is the offset from the anchor's position to the tip of the InfoWindow. + */ open(map?: StreetViewPanorama, anchor?: MVCObject): void; setContent(content: Node): void; setContent(content: string): void; @@ -469,11 +598,40 @@ declare module google.maps { } export interface InfoWindowOptions { + /** + * Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. + * The InfoWindow will be sized according to the content. + * To set an explicit size for the content, set content to be a HTML element with that size. + * @type {(string|Node)} + */ content?: any; + /** + * Disable auto-pan on open. By default, the info window will pan the map so that it is fully visible when it opens. + */ disableAutoPan?: boolean; + /** + * Maximum width of the infowindow, regardless of content's width. + * This value is only considered if it is set before a call to open. + * To change the maximum width when changing content, call close, setOptions, and then open. + */ maxWidth?: number; + /** + * The offset, in pixels, of the tip of the info window from the point on the map + * at whose geographical coordinates the info window is anchored. + * If an InfoWindow is opened with an anchor, the pixelOffset will be calculated from the anchor's anchorPoint property. + */ pixelOffset?: Size; + /** + * The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead. + */ position?: LatLng; + /** + * All InfoWindows are displayed on the map in order of their zIndex, + * with higher values displaying in front of InfoWindows with lower values. + * By default, InfoWindows are displayed according to their latitude, + * with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes. + * InfoWindows are always displayed in front of markers. + */ zIndex?: number; } @@ -1356,15 +1514,43 @@ declare module google.maps { latLng: LatLng; } - /***** Base *****/ - export class LatLng { - constructor (lat: number, lng: number, noWrap?: boolean); - equals(other: LatLng): boolean; - lat(): number; - lng(): number; - toString(): string; - toUrlValue(precision?: number): string; + /* **** Base **** */ + /** + * A LatLng is a point in geographical coordinates: latitude and longitude. + * + * * Latitude ranges between -90 and 90 degrees, inclusive. + * Values above or below this range will be clamped to the range [-90, 90]. + * This means that if the value specified is less than -90, it will be set to -90. + * And if the value is greater than 90, it will be set to 90. + * * Longitude ranges between -180 and 180 degrees, inclusive. + * Values above or below this range will be wrapped so that they fall within the range. + * For example, a value of -190 will be converted to 170. A value of 190 will be converted to -170. + * This reflects the fact that longitudes wrap around the globe. + * + * Although the default map projection associates longitude with the x-coordinate of the map, and latitude with the y-coordinate, + * the latitude coordinate is always written first, followed by the longitude. + * Notice that you cannot modify the coordinates of a LatLng. If you want to compute another point, you have to create a new one. + */ + export class LatLng { + /** + * Creates a LatLng object representing a geographic point. + * Note the ordering of latitude and longitude. + * @param lat Latitude is specified in degrees within the range [-90, 90]. + * @param lng Longitude is specified in degrees within the range [-180, 180]. + * @param noWrap Set noWrap to true to enable values outside of this range. + */ + constructor(lat: number, lng: number, noWrap?: boolean); + /** Comparison function. */ + equals(other: LatLng): boolean; + /** Returns the latitude in degrees. */ + lat(): number; + /** Returns the longitude in degrees. */ + lng(): number; + /** Converts to string representation. */ + toString(): string; + /** Returns a string of the form "lat,lng". We round the lat/lng values to 6 decimal places by default. */ + toUrlValue(precision?: number): string; } export class LatLngBounds { @@ -1383,11 +1569,17 @@ declare module google.maps { union(other: LatLngBounds): LatLngBounds; } + export class Point { - constructor (x: number, y: number); + /** A point on a two-dimensional plane. */ + constructor(x: number, y: number); + /** The X coordinate */ x: number; + /** The Y coordinate */ y: number; + /** Compares two Points */ equals(other: Point): boolean; + /** Returns a string representation of this Point. */ toString(): string; } From 3bf10e44d143f27b549986d617f37def4c7530ba Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 11:57:24 -0500 Subject: [PATCH 110/397] added passport-google-oauth definitions --- .../passport-google-oauth-tests.ts | 38 ++++++++++++ .../passport-google-oauth.d.ts | 60 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 passport-google-oauth/passport-google-oauth-tests.ts create mode 100644 passport-google-oauth/passport-google-oauth.d.ts diff --git a/passport-google-oauth/passport-google-oauth-tests.ts b/passport-google-oauth/passport-google-oauth-tests.ts new file mode 100644 index 000000000..60fad97b4 --- /dev/null +++ b/passport-google-oauth/passport-google-oauth-tests.ts @@ -0,0 +1,38 @@ +/** + * Created by jcabresos on 4/19/2014. + */ +import passport = require('passport'); +import google = require('passport-google-oauth'); + +// just some test model +var User = { + findOrCreate(id:string, provider:string, callback:(err:any, user:any) => void): void { + callback(null, {username:'james'}); + } +} + +passport.use(new google.OAuthStrategy({ + consumerKey: process.env.GOOGLE_CONSUMER_KEY, + consumerSecret: process.env.GOOGLE_CONSUMER_SECRET, + callbackURL: process.env.PASSPORT_GOOGLE_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); + +passport.use(new google.OAuth2Strategy({ + clientID: process.env.GOOGLE_CLIENT_ID, + clientSecret: process.env.GOOGLE_CLIENT_SECRET, + callbackURL: process.env.PASSPORT_GOOGLE_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); diff --git a/passport-google-oauth/passport-google-oauth.d.ts b/passport-google-oauth/passport-google-oauth.d.ts new file mode 100644 index 000000000..ea6c1e91a --- /dev/null +++ b/passport-google-oauth/passport-google-oauth.d.ts @@ -0,0 +1,60 @@ +// Type definitions for passport-facebook 1.0.3 +// Project: https://github.com/jaredhanson/passport-facebook +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'passport-google-oauth' { + + import passport = require('passport'); + import express = require('express'); + + interface Profile extends passport.Profile { + gender: string; + } + + interface IOAuthStrategyOption { + consumerKey: string; + consumerSecret: string; + callbackURL: string; + + reguestTokenURL?: string; + accessTokenURL?: string; + userAuthorizationURL?: string; + sessionKey?: string; + } + + class OAuthStrategy implements passport.Strategy { + constructor(options: IOAuthStrategyOption, + verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; + authenticate: (req: express.Request, options?: Object) => void; + } + + interface IOAuth2StrategyOption { + clientID: string; + clientSecret: string; + callbackURL: string; + + authorizationURL?: string; + tokenURL?: string; + + accessType?: string; + approval_prompt?: string; + prompt?: string; + loginHint?: string; + userID?: string; + hostedDomain?: string; + display?: string; + requestVisibleActions?: string; + openIDRealm?: string; + } + + class OAuth2Strategy implements passport.Strategy { + constructor(options: IOAuth2StrategyOption, + verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; + authenticate: (req: express.Request, options?: Object) => void; + } +} From ca327372d6e390c5406cbab28b90934eaf883093 Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 11:58:03 -0500 Subject: [PATCH 111/397] added passport-twitter definitions --- passport-twitter/passport-twitter-tests.ts | 25 +++++++++++++++ passport-twitter/passport-twitter.d.ts | 37 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 passport-twitter/passport-twitter-tests.ts create mode 100644 passport-twitter/passport-twitter.d.ts diff --git a/passport-twitter/passport-twitter-tests.ts b/passport-twitter/passport-twitter-tests.ts new file mode 100644 index 000000000..3abead1b2 --- /dev/null +++ b/passport-twitter/passport-twitter-tests.ts @@ -0,0 +1,25 @@ +/** + * Created by jcabresos on 4/19/2014. + */ +import passport = require('passport'); +import twitter = require('passport-twitter'); + +// just some test model +var User = { + findOrCreate(id:string, provider:string, callback:(err:any, user:any) => void): void { + callback(null, {username:'james'}); + } +} + +passport.use(new twitter.Strategy({ + clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID, + clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET, + callbackURL: process.env.PASSPORT_FACEBOOK_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); diff --git a/passport-twitter/passport-twitter.d.ts b/passport-twitter/passport-twitter.d.ts new file mode 100644 index 000000000..22e292acf --- /dev/null +++ b/passport-twitter/passport-twitter.d.ts @@ -0,0 +1,37 @@ +// Type definitions for passport-facebook 1.0.3 +// Project: https://github.com/jaredhanson/passport-facebook +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'passport-twitter' { + + import passport = require('passport'); + import express = require('express'); + + interface Profile extends passport.Profile { + gender: string; + } + + interface IStrategyOption { + consumerKey: string; + consumerSecret: string; + callbackURL: string; + + reguestTokenURL?: string; + accessTokenURL?: string; + userAuthorizationURL?: string; + sessionKey?: string; + + userProfileURL?: string; + skipExtendedUserProfile?: boolean; + } + + class Strategy implements passport.Strategy { + constructor(options: IStrategyOption, + verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; + authenticate: (req: express.Request, options?: Object) => void; + } +} From a1915bad2e932a2be44a718818c3b5286793f26c Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 12:35:10 -0500 Subject: [PATCH 112/397] fixed twitter tests, added _raw and _json properties --- passport-facebook/passport-facebook.d.ts | 3 +++ passport-google-oauth/passport-google-oauth.d.ts | 3 +++ passport-twitter/passport-twitter-tests.ts | 6 +++--- passport-twitter/passport-twitter.d.ts | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts index 26479cc29..b3adaf860 100644 --- a/passport-facebook/passport-facebook.d.ts +++ b/passport-facebook/passport-facebook.d.ts @@ -14,6 +14,9 @@ declare module 'passport-facebook' { gender: string; profileUrl: string; username: string; + + _raw: string; + _json: any; } interface IStrategyOption { diff --git a/passport-google-oauth/passport-google-oauth.d.ts b/passport-google-oauth/passport-google-oauth.d.ts index ea6c1e91a..27744021f 100644 --- a/passport-google-oauth/passport-google-oauth.d.ts +++ b/passport-google-oauth/passport-google-oauth.d.ts @@ -12,6 +12,9 @@ declare module 'passport-google-oauth' { interface Profile extends passport.Profile { gender: string; + + _raw: string; + _json: any; } interface IOAuthStrategyOption { diff --git a/passport-twitter/passport-twitter-tests.ts b/passport-twitter/passport-twitter-tests.ts index 3abead1b2..ae644dfa2 100644 --- a/passport-twitter/passport-twitter-tests.ts +++ b/passport-twitter/passport-twitter-tests.ts @@ -12,9 +12,9 @@ var User = { } passport.use(new twitter.Strategy({ - clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID, - clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET, - callbackURL: process.env.PASSPORT_FACEBOOK_CALLBACK_URL + consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY, + consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET, + callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL }, function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) { User.findOrCreate(profile.id, profile.provider, function(err, user) { diff --git a/passport-twitter/passport-twitter.d.ts b/passport-twitter/passport-twitter.d.ts index 22e292acf..cb43aad26 100644 --- a/passport-twitter/passport-twitter.d.ts +++ b/passport-twitter/passport-twitter.d.ts @@ -12,6 +12,11 @@ declare module 'passport-twitter' { interface Profile extends passport.Profile { gender: string; + username: string; + + _raw: string; + _json: any; + _accessLevel: string; } interface IStrategyOption { From 923432817762816801e7312f2813529ef9731020 Mon Sep 17 00:00:00 2001 From: Josh Petersen Date: Wed, 3 Jun 2015 14:25:05 -0400 Subject: [PATCH 113/397] minor fix. sheet_to_json only accepts worksheet as a parameter. --- xlsx/xlsx.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xlsx/xlsx.d.ts b/xlsx/xlsx.d.ts index 16df800dd..cdc75349b 100644 --- a/xlsx/xlsx.d.ts +++ b/xlsx/xlsx.d.ts @@ -128,7 +128,7 @@ declare module 'xlsx' { } export interface IUtils { - sheet_to_json(worksheet:IWorkSheet|IWorkBook):T[]; + sheet_to_json(worksheet:IWorkSheet):T[]; sheet_to_csv(worksheet:IWorkSheet):any; sheet_to_formulae(worksheet:IWorkSheet):any; } From bf09efb39f0ec78dec18134bae3546239ff07328 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Wed, 3 Jun 2015 16:51:31 -0700 Subject: [PATCH 114/397] Added Numbro typedefs (taken from NumeralJS and renamed). Numbro is a maintained fork of the now unmaintained numeraljs. --- numbro/numbro-commonjs-tests.ts | 44 ++++++++++++++++++++++++++++++ numbro/numbro-tests.ts | 43 +++++++++++++++++++++++++++++ numbro/numbro.d.ts | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 numbro/numbro-commonjs-tests.ts create mode 100644 numbro/numbro-tests.ts create mode 100644 numbro/numbro.d.ts diff --git a/numbro/numbro-commonjs-tests.ts b/numbro/numbro-commonjs-tests.ts new file mode 100644 index 000000000..c428a475e --- /dev/null +++ b/numbro/numbro-commonjs-tests.ts @@ -0,0 +1,44 @@ +/// +import numbro = require("numbro"); + +var valueFormat: string = numbro(1000).format('0,0'); +// '1,000' + +var valueUnformat: number = numbro().unformat('($10,000.00)'); +// '-10000' + +var value3: Numbro = numbro(1000); +var added: Numbro = value3.add(10); +// 1010 + +var value4: Numbro = numbro(1000); +var formatValue4a: string = value4.format('0,0'); +// '1,000' +var formatValue4b: number = value4.value(); +// 1000 + +var value5: Numbro = numbro(); +value5.set(1000); +var value5Num: number = value5.value(); +// 1000 + +var value6: Numbro = numbro(1000); +var value: number = 100; +var difference = value6.difference(value); +// 900 + +var value7: Numbro = numbro(0); +numbro.zeroFormat('N/A'); +var zeroString: string = value7.format('0.0'); +// 'N/A' + +var a: Numbro = numbro(1000); +var b: Numbro = numbro(a); +var c: Numbro = a.clone(); + +var aVal: number = a.set(2000).value(); +// 2000 +var bVal: number = b.value(); +// 1000 +var cVal: number = c.add(10).value(); +// 1010 diff --git a/numbro/numbro-tests.ts b/numbro/numbro-tests.ts new file mode 100644 index 000000000..0b18e898d --- /dev/null +++ b/numbro/numbro-tests.ts @@ -0,0 +1,43 @@ +/// + +var valueFormat: string = numbro(1000).format('0,0'); +// '1,000' + +var valueUnformat: number = numbro().unformat('($10,000.00)'); +// '-10000' + +var value3: Numbro = numbro(1000); +var added: Numbro = value3.add(10); +// 1010 + +var value4: Numbro = numbro(1000); +var formatValue4a: string = value4.format('0,0'); +// '1,000' +var formatValue4b: number = value4.value(); +// 1000 + +var value5: Numbro = numbro(); +value5.set(1000); +var value5Num: number = value5.value(); +// 1000 + +var value6: Numbro = numbro(1000); +var value: number = 100; +var difference = value6.difference(value); +// 900 + +var value7: Numbro = numbro(0); +numbro.zeroFormat('N/A'); +var zeroString: string = value7.format('0.0'); +// 'N/A' + +var a: Numbro = numbro(1000); +var b: Numbro = numbro(a); +var c: Numbro = a.clone(); + +var aVal: number = a.set(2000).value(); +// 2000 +var bVal: number = b.value(); +// 1000 +var cVal: number = c.add(10).value(); +// 1010 diff --git a/numbro/numbro.d.ts b/numbro/numbro.d.ts new file mode 100644 index 000000000..a2c1f8d7a --- /dev/null +++ b/numbro/numbro.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Numbro.js +// Project: https://github.com/foretagsplatsen/numbro +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface NumbroLanguage { + delimiters: { + thousands: string; + decimal: string; + }; + abbreviations: { + thousand: string; + million: string; + billion: string; + trillion: string; + }; + ordinal(num: number): string; + currency: { + symbol: string; + }; +} + +interface Numbro { + (value?: any): Numbro; + version: string; + isNumbro: boolean; + language(key: string, values?: NumbroLanguage): Numbro; + zeroFormat(format: string): string; + clone(): Numbro; + format(inputString: string): string; + unformat(inputString: string): number; + value(): number; + valueOf(): number; + set (value: any): Numbro; + add(value: any): Numbro; + subtract(value: any): Numbro; + multiply(value: any): Numbro; + divide(value: any): Numbro; + difference(value: any): number; +} + +declare var numbro: Numbro; + +declare module "numbro" { + + export = numbro; + +} From 5a7baf8191c735673ed3c4db783379ecd98af0be Mon Sep 17 00:00:00 2001 From: Sam Herrmann Date: Wed, 3 Jun 2015 22:06:25 -0400 Subject: [PATCH 115/397] Add missing "parent" property to angular-ui-router state configuration object As documented here: http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$stateProvider --- angular-ui-router/angular-ui-router-tests.ts | 11 ++++++++++- angular-ui-router/angular-ui-router.d.ts | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index c31bb1688..a43f9e9bc 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -64,7 +64,16 @@ myApp.config(( controller: function ($scope: MyAppScope) { $scope.things = ["A", "Set", "Of", "Things"]; } - }).state('index', { + }) + .state('list', { + parent: 'state3', + url: "/list", + templateUrl: "partials/state3.list.html", + controller: function ($scope: MyAppScope) { + $scope.things = ["A", "Set", "Of", "Things"]; + } + }) + .state('index', { url: "", views: { "viewA": { template: "index.viewA" }, diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index bfec95156..acc9342d9 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -30,6 +30,13 @@ declare module angular.ui { * Function (injectable), returns the actual controller function or string. */ controllerProvider?: Function; + + /** + * Specifies the parent state of this state + */ + parent?: string | IState + + resolve?: {}; /** * A url with optional parameters. When a state is navigated or transitioned to, the $stateParams service will be populated with any parameters that were passed. From 08fee9265fb493ba6a308f009677696ee063a5d0 Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 00:18:28 -0400 Subject: [PATCH 116/397] remove IDayOfWeekMonth in favor of a tuple of [number, number] with refactor --- node-calendar/node-calendar-tests.ts | 3 +-- node-calendar/node-calendar.d.ts | 14 +++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/node-calendar/node-calendar-tests.ts b/node-calendar/node-calendar-tests.ts index 5a4a40a46..6de5d6cc4 100644 --- a/node-calendar/node-calendar-tests.ts +++ b/node-calendar/node-calendar-tests.ts @@ -1,5 +1,4 @@ /// -/// import node_calendar = require('node-calendar'); @@ -97,7 +96,7 @@ function assertIsNumber(n: number) { assert(typeof n == 'number', 'Should be a number'); } -function assertDayOfWeekMonth(d: IDayOfWeekMonth) { +function assertDayOfWeekMonth(d: [number, number]) { assert(d instanceof Array, 'Day of weak/month should be an array'); assert(d.length == 2, 'Day of weak/month array should contain 2 items'); assert(typeof d[0] == 'number', 'Day of month should be a number'); diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts index a1c3f0500..3839d6541 100755 --- a/node-calendar/node-calendar.d.ts +++ b/node-calendar/node-calendar.d.ts @@ -3,14 +3,6 @@ // Definitions by: Luzian Zagadinow // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface IDayOfWeekMonth extends Array { - /** dayOfMonth */ - 0: number; - - /** dayOfWeek */ - 1: number; -} - interface IWeekRow extends Array { [dayIndex: number]: T; } @@ -183,7 +175,7 @@ declare module 'node-calendar' { * @param {number} month * Month for which the calendar should be generated. */ - itermonthdays2(year: number, month: number): IDayOfWeekMonth[]; + itermonthdays2(year: number, month: number): [number, number][]; /** * A matrix (array of array) representing a month's calendar. @@ -217,7 +209,7 @@ declare module 'node-calendar' { * @param {number} month * Month for which the calendar should be generated. */ - monthdays2calendar(year: number, month: number): IMonthGrid; + monthdays2calendar(year: number, month: number): IMonthGrid<[number, number]>; /** * The specified year ready for formatting. The return value is an array @@ -254,7 +246,7 @@ declare module 'node-calendar' { * @param {number} width * The number of months to include in each row. Default: 3 */ - yeardays2calendar(year: number, width?: number): IYearGrid; + yeardays2calendar(year: number, width?: number): IYearGrid<[number, number]>; } // Undocumented From 66feb94be0a3c2f60cd2a64744f271c8fb3748a6 Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 01:38:15 -0400 Subject: [PATCH 117/397] add missing definitions for module functions add line breaks in documentation to make readable --- node-calendar/node-calendar.d.ts | 169 ++++++++++++++++++++++++++++--- 1 file changed, 154 insertions(+), 15 deletions(-) diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts index 3839d6541..ae4b16cad 100755 --- a/node-calendar/node-calendar.d.ts +++ b/node-calendar/node-calendar.d.ts @@ -15,7 +15,7 @@ interface IMonthRow extends Array> { [monthColumnIndex: number]: IMonthGrid; } -interface IYearGrid extends Array>{ +interface IYearGrid extends Array> { [monthRowIndex: number]: IMonthRow; } @@ -59,7 +59,7 @@ declare module 'node-calendar' { export var MARCH: number; /** 4 */ - export var APRIL:number; + export var APRIL: number; /** 5 */ export var MAY: number; @@ -150,6 +150,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} month * Month for which the calendar should be generated. */ @@ -161,6 +162,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} month * Month for which the calendar should be generated. */ @@ -172,6 +174,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} month * Month for which the calendar should be generated. */ @@ -183,6 +186,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} month * Month for which the calendar should be generated. */ @@ -194,6 +198,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} month * Month for which the calendar should be generated. */ @@ -206,6 +211,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} month * Month for which the calendar should be generated. */ @@ -219,6 +225,7 @@ declare module 'node-calendar' { * * @param {number} year * Year for which the calendar should be generated. + * * @param {number} width * The number of months to include in each row. Default: 3 */ @@ -230,7 +237,8 @@ declare module 'node-calendar' { * month are zero. * * @param {number} year - * Year for which the calendar should be generated. + * Year for which the calendar should be generated + * * @param {number} width * The number of months to include in each row. Default: 3 */ @@ -242,22 +250,153 @@ declare module 'node-calendar' { * Day numbers outside this month are zero. * * @param {number} year - * Year for which the calendar should be generated. + * Year for which the calendar should be generated + * * @param {number} width * The number of months to include in each row. Default: 3 */ yeardays2calendar(year: number, width?: number): IYearGrid<[number, number]>; } - // Undocumented - //export function isleap(year: number): boolean; - //export function leapdays(beginYear: number, endYear: number): number; - //export function monthrange(year: number, month: number): number[]; - //export function weekday(year: number, month: number, day: number): number; - //export function timegm(dateParams: number[]): number; - //export function IllegalLocaleError(): Error; - //export function IllegalDayError(): Error; - //export function IllegalMonthError(): Error; - //export function IllegalTimeError(): Error; - //export function IllegalWeekdayError(): Error; + /** + * @param {number} year + * Year to test. + * + * @return {boolean} + * true for leap years, false for non-leap years. + */ + export function isleap(year: number): boolean; + + /** + * @param {number} y1 + * Beginning year in the range to test. + * + * @param {number} y2 + * Ending year in the range to test. + * + * @return {number} + * Number of leap years in range (y1...y2). Assumes y1 <= y2. + */ + export function leapdays(y1: number, y2: number): number; + + /** + * @param {number} year + * Year for which the range should be calculated. + * + * @param {number} month + * Month for which the range should be calculated. + * + * @throws {IllegalMonthError} if the provided month is invalid. + * + * @return {number[]} + * starting weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month. + */ + export function monthrange(year: number, month: number): number[]; + + /** + * Sets the locale for use in extracting month and weekday names. + * + * @param {string} locale + * Locale to set on the calendar object. Default: en_US + * + * @throws {IllegalLocaleError} if the provided locale is invalid. + */ + export function setlocale(locale?: string); + + /** + * Unrelated but handy function to calculate Unix timestamp from GMT. + * + * @param timegmt {[number, number, number, number, number, number]} + * An array containing the elements from a time structure dataset. + * Format: [tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec] + * + * @throws {IllegalMonthError} if the provided month element is invalid. + * + * @throws {IllegalDayError} if the provided day element is invalid. + * + * @throws {IllegalTimeError} if any of the the provided time elements are invalid. + * + * @return {number} + * Unix timestamp from GMT. + */ + export function timegm(timegmt: [number, number, number, number, number, number]): number; + + /** + * @param {number} year + * Year for which the weekday should be calculated. + * + * @param {number} month + * Month for which the weekday should be calculated. + * + * @param {number} day + * Day for which the weekday should be calculated. + * + * @throws {IllegalMonthError} if the provided month element is invalid. + * + * @throws {IllegalDayError} if the provided day element is invalid. + * + * @return {number} + * weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31). + */ + export function weekday(year: number, month: number, day: number): number; + + /** + * Error indicating a nonexistent or unsupported locale specified. + * + * @param {string} message + * Optional custom error message. + */ + export class IllegalLocaleError implements Error { + public name: string; + public message: string; + constructor(message?: string) + } + + /** + * Error indicating a day index specified outside of the valid range. + * + * @param {string} message + * Optional custom error message. + */ + export class IllegalDayError implements Error { + public name: string; + public message: string; + constructor(message?: string) + } + + /** + * Error indicating a month index specified outside of the expected range (1-12 ~ Jan-Dec). + * + * @param {string} message + * Optional custom error message. + */ + export class IllegalMonthError implements Error { + public name: string; + public message: string; + constructor(message?: string) + } + + /** + * Error indicating a time element is outside of the valid range. + * + * @param {string} message + * Optional custom error message. + */ + export class IllegalTimeError implements Error { + public name: string; + public message: string; + constructor(message?: string) + } + + /** + * Error indicating a weekday index specified outside of the expected range (0-6 ~ Mon-Sun). + * + * @param {string} message + * Optional custom error message. + */ + export class IllegalWeekdayError implements Error { + public name: string; + public message: string; + constructor(message?: string) + } } \ No newline at end of file From cc6e98cc6be9849851c2d8879ec5c9134145b988 Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 01:46:31 -0400 Subject: [PATCH 118/397] add tests to reflect new definitions --- node-calendar/node-calendar-tests.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/node-calendar/node-calendar-tests.ts b/node-calendar/node-calendar-tests.ts index 6de5d6cc4..b57cd9f84 100644 --- a/node-calendar/node-calendar-tests.ts +++ b/node-calendar/node-calendar-tests.ts @@ -88,6 +88,25 @@ assertYearGrid(cal.yeardatescalendar(2009, 3), assertIsDate); assertYearGrid(cal.yeardays2calendar(2008, 2), assertDayOfWeekMonth); assertYearGrid(cal.yeardayscalendar(2007, 4), assertIsNumber); +node_calendar.setlocale('en_US'); + +assertIsError(new node_calendar.IllegalDayError()); +assertIsError(new node_calendar.IllegalLocaleError()); +assertIsError(new node_calendar.IllegalMonthError()); +assertIsError(new node_calendar.IllegalTimeError); +assertIsError(new node_calendar.IllegalWeekdayError()); + +assertIsBoolean(node_calendar.isleap(2000)); +assertIsNumber(node_calendar.weekday(2015, node_calendar.JULY, 7)); +assertIsNumber(node_calendar.leapdays(2000, 2010)); + +node_calendar.monthrange(2015, node_calendar.JANUARY).forEach(assertIsNumber); + +var timegmt:[number,number,number,number,number,number] = [2014, node_calendar.JULY, 7, 12, 41, 59]; +assertIsNumber(node_calendar.timegm(timegmt)); + + +// FUNCTIONS ------------------------------------------------------------------ function assertIsDate(d: Date) { assert(d instanceof Date, 'Should be a date'); } @@ -96,6 +115,10 @@ function assertIsNumber(n: number) { assert(typeof n == 'number', 'Should be a number'); } +function assertIsBoolean(b: boolean) { + assert(typeof b == 'boolean', 'Should be a boolean'); +} + function assertDayOfWeekMonth(d: [number, number]) { assert(d instanceof Array, 'Day of weak/month should be an array'); assert(d.length == 2, 'Day of weak/month array should contain 2 items'); @@ -122,4 +145,9 @@ function assertYearGrid(grid: IYearGrid, assertItemType: (item: T) => void function assert(condition: boolean, msg?: string): void { if (condition) return; throw new Error(msg); +} + +function assertIsError(error: Error) { + assert(typeof error.name == 'string', 'Error name should exist and be a string'); + assert(typeof error.message == 'string', 'Error message should exist and be a string'); } \ No newline at end of file From 7c4b699df0acd2108fccf00e7fed3e8933eb2327 Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 01:49:16 -0400 Subject: [PATCH 119/397] specify return type of setlocal() --- node-calendar/node-calendar.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts index ae4b16cad..6f2b7814b 100755 --- a/node-calendar/node-calendar.d.ts +++ b/node-calendar/node-calendar.d.ts @@ -301,7 +301,7 @@ declare module 'node-calendar' { * * @throws {IllegalLocaleError} if the provided locale is invalid. */ - export function setlocale(locale?: string); + export function setlocale(locale?: string): void; /** * Unrelated but handy function to calculate Unix timestamp from GMT. From 0d8680a11b1d592d10784b94e9a23dd652b5ec65 Mon Sep 17 00:00:00 2001 From: bls Date: Thu, 4 Jun 2015 17:46:55 +1000 Subject: [PATCH 120/397] Add tls.createSecureContext to node.js typing. --- node/node-tests.ts | 11 +++++++++++ node/node.d.ts | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/node/node-tests.ts b/node/node-tests.ts index 8c381bc0e..7c05c3a21 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -7,6 +7,7 @@ import zlib = require("zlib"); import url = require('url'); import util = require("util"); import crypto = require("crypto"); +import tls = require("tls"); import http = require("http"); import net = require("net"); import dgram = require("dgram"); @@ -143,6 +144,16 @@ function crypto_cipher_decipher_buffer_test() { assert.deepEqual(clearText2, clearText); } +//////////////////////////////////////////////////// +/// TLS tests : http://nodejs.org/api/tls.html +//////////////////////////////////////////////////// + +var ctx: tls.SecureContext = tls.createSecureContext({ + key: "NOT REALLY A KEY", + cert: "SOME CERTIFICATE", +}); +var blah = ctx.context; + //////////////////////////////////////////////////// // Make sure .listen() and .close() retuern a Server instance diff --git a/node/node.d.ts b/node/node.d.ts index 2543ccaca..f9b3a68a8 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1236,11 +1236,27 @@ declare module "tls" { cleartext: any; } + export interface SecureContextOptions { + pfx?: any; //string | buffer + key?: any; //string | buffer + passphrase?: string; + cert?: any; // string | buffer + ca?: any; // string | buffer + crl?: any; // string | string[] + ciphers?: string; + honorCipherOrder?: boolean; + } + + export interface SecureContext { + context: any; + } + export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; + export function createSecureContext(details: SecureContextOptions): SecureContext; } declare module "crypto" { From 60d204c382a6a5126f9708b3848cf783cd535717 Mon Sep 17 00:00:00 2001 From: Vadim Macagon Date: Thu, 4 Jun 2015 16:49:28 +0700 Subject: [PATCH 121/397] Extend Mocha typings to allow writing of custom reporters --- mocha/mocha-tests.ts | 34 +++++++ mocha/mocha.d.ts | 230 ++++++++++++++++++++++++++----------------- 2 files changed, 173 insertions(+), 91 deletions(-) diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index f90fefaf9..a2e2b0796 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -249,3 +249,37 @@ function test_run_withOnComplete() { console.log(failures); }); } + +class CustomSpecReporter extends MochaDef.reporters.Spec { + constructor(runner: Mocha.IRunner) { + super(runner); + + runner.on('test', (test: Mocha.ITest) => { + console.log(test.parent.title + '/' + test.title); + }); + } +} + +class MyReporter extends MochaDef.reporters.Base { + passes: number = 0; + failures: number = 0; + + constructor(runner: Mocha.IRunner) { + super(runner); + + runner.on('pass', (test: Mocha.ITest) => { + this.passes++; + console.log('pass: %s', test.fullTitle()); + }); + + runner.on('fail', (test: Mocha.ITest, err: Error) => { + this.failures++; + console.log('fail: %s -- error: %s', test.fullTitle(), err.message); + }); + + runner.on('end', () => { + console.log('end: %d/%d', this.passes, this.passes + this.failures); + process.exit(this.failures); + }); + } +} diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index 63ad66014..fefd91946 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -1,24 +1,9 @@ -// Type definitions for mocha 2.0.1 +// Type definitions for mocha 2.2.5 // Project: http://mochajs.org/ -// Definitions by: Kazi Manzur Rashid , otiai10 , jt000 +// Definitions by: Kazi Manzur Rashid , otiai10 , jt000 , Vadim Macagon // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface Mocha { - // Setup mocha with the given setting options. - setup(options: MochaSetupOptions): Mocha; - - //Run tests and invoke `fn()` when complete. - run(callback?: () => void): void; - - // Set reporter as function - reporter(reporter: () => void): Mocha; - - // Set reporter, defaults to "dot" - reporter(reporter: string): Mocha; - - // Enable growl support. - growl(): Mocha -} +/// interface MochaSetupOptions { //milliseconds to wait before considering a test slow @@ -33,7 +18,7 @@ interface MochaSetupOptions { //array of accepted globals globals?: any[]; - // reporter instance (function or string), defaults to `mocha.reporters.Dot` + // reporter instance (function or string), defaults to `mocha.reporters.Spec` reporter?: any; // bail on the first test failure @@ -45,56 +30,20 @@ interface MochaSetupOptions { // grep string or regexp to filter tests with grep?: any; } - + interface MochaDone { (error?: Error): void; } declare var mocha: Mocha; - -declare var describe: { - (description: string, spec: () => void): void; - only(description: string, spec: () => void): void; - skip(description: string, spec: () => void): void; - timeout(ms: number): void; -} - +declare var describe: Mocha.IContextDefinition; // alias for `describe` -declare var context: { - (contextTitle: string, spec: () => void): void; - only(contextTitle: string, spec: () => void): void; - skip(contextTitle: string, spec: () => void): void; - timeout(ms: number): void; -}; - +declare var context: Mocha.IContextDefinition; // alias for `describe` -declare var suite: { - (suiteTitle: string, spec: () => void): void; - only(suiteTitle: string, spec: () => void): void; - skip(suiteTitle: string, spec: () => void): void; - timeout(ms: number): void; -}; - -declare var it: { - (expectation: string, assertion?: () => void): void; - (expectation: string, assertion?: (done: MochaDone) => void): void; - only(expectation: string, assertion?: () => void): void; - only(expectation: string, assertion?: (done: MochaDone) => void): void; - skip(expectation: string, assertion?: () => void): void; - skip(expectation: string, assertion?: (done: MochaDone) => void): void; - timeout(ms: number): void; -}; - +declare var suite: Mocha.IContextDefinition; +declare var it: Mocha.ITestDefinition; // alias for `it` -declare var test: { - (expectation: string, assertion?: () => void): void; - (expectation: string, assertion?: (done: MochaDone) => void): void; - only(expectation: string, assertion?: () => void): void; - only(expectation: string, assertion?: (done: MochaDone) => void): void; - skip(expectation: string, assertion?: () => void): void; - skip(expectation: string, assertion?: (done: MochaDone) => void): void; - timeout(ms: number): void; -}; +declare var test: Mocha.ITestDefinition; declare function before(action: () => void): void; @@ -128,39 +77,138 @@ declare function suiteTeardown(action: () => void): void; declare function suiteTeardown(action: (done: MochaDone) => void): void; -declare module "mocha" { +declare class Mocha { + constructor(options?: { + grep?: RegExp; + ui?: string; + reporter?: string; + timeout?: number; + bail?: boolean; + }); - class Mocha { - constructor(options?: { - grep?: RegExp; - ui?: string; - reporter?: string; - timeout?: number; - bail?: boolean; - }); + /** Setup mocha with the given options. */ + setup(options: MochaSetupOptions): Mocha; + bail(value?: boolean): Mocha; + addFile(file: string): Mocha; + /** Sets reporter by name, defaults to "spec". */ + reporter(name: string): Mocha; + /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ + reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; + ui(value: string): Mocha; + grep(value: string): Mocha; + grep(value: RegExp): Mocha; + invert(): Mocha; + ignoreLeaks(value: boolean): Mocha; + checkLeaks(): Mocha; + /** Enables growl support. */ + growl(): Mocha; + globals(value: string): Mocha; + globals(values: string[]): Mocha; + useColors(value: boolean): Mocha; + useInlineDiffs(value: boolean): Mocha; + timeout(value: number): Mocha; + slow(value: number): Mocha; + enableTimeouts(value: boolean): Mocha; + asyncOnly(value: boolean): Mocha; + noHighlighting(value: boolean): Mocha; + /** Runs tests and invokes `onComplete()` when finished. */ + run(onComplete?: (failures: number) => void): Mocha.IRunner; +} - bail(value?: boolean): Mocha; - addFile(file: string): Mocha; - reporter(value: string): Mocha; - ui(value: string): Mocha; - grep(value: string): Mocha; - grep(value: RegExp): Mocha; - invert(): Mocha; - ignoreLeaks(value: boolean): Mocha; - checkLeaks(): Mocha; - growl(): Mocha; - globals(value: string): Mocha; - globals(values: string[]): Mocha; - useColors(value: boolean): Mocha; - useInlineDiffs(value: boolean): Mocha; - timeout(value: number): Mocha; - slow(value: number): Mocha; - enableTimeouts(value: boolean): Mocha; - asyncOnly(value: boolean): Mocha; - noHighlighting(value: boolean): Mocha; - - run(onComplete?: (failures: number) => void): void; +// merge the Mocha class declaration with a module +declare module Mocha { + /** Partial interface for Mocha's `Runnable` class. */ + interface IRunnable extends NodeJS.EventEmitter { + title: string; + fn: Function; + async: boolean; + sync: boolean; + timedOut: boolean; } + /** Partial interface for Mocha's `Suite` class. */ + interface ISuite extends NodeJS.EventEmitter { + parent: ISuite; + title: string; + + fullTitle(): string; + } + + /** Partial interface for Mocha's `Test` class. */ + interface ITest extends IRunnable { + parent: ISuite; + pending: boolean; + + fullTitle(): string; + } + + /** Partial interface for Mocha's `Runner` class. */ + interface IRunner extends NodeJS.EventEmitter {} + + interface IContextDefinition { + (description: string, spec: () => void): ISuite; + only(description: string, spec: () => void): ISuite; + skip(description: string, spec: () => void): void; + timeout(ms: number): void; + } + + interface ITestDefinition { + (expectation: string, assertion?: () => void): ITest; + (expectation: string, assertion?: (done: MochaDone) => void): ITest; + only(expectation: string, assertion?: () => void): ITest; + only(expectation: string, assertion?: (done: MochaDone) => void): ITest; + skip(expectation: string, assertion?: () => void): void; + skip(expectation: string, assertion?: (done: MochaDone) => void): void; + timeout(ms: number): void; + } + + export module reporters { + export class Base { + stats: { + suites: number; + tests: number; + passes: number; + pending: number; + failures: number; + }; + + constructor(runner: IRunner); + } + + export class Doc extends Base {} + export class Dot extends Base {} + export class HTML extends Base {} + export class HTMLCov extends Base {} + export class JSON extends Base {} + export class JSONCov extends Base {} + export class JSONStream extends Base {} + export class Landing extends Base {} + export class List extends Base {} + export class Markdown extends Base {} + export class Min extends Base {} + export class Nyan extends Base {} + export class Progress extends Base { + /** + * @param options.open String used to indicate the start of the progress bar. + * @param options.complete String used to indicate a complete test on the progress bar. + * @param options.incomplete String used to indicate an incomplete test on the progress bar. + * @param options.close String used to indicate the end of the progress bar. + */ + constructor(runner: IRunner, options?: { + open?: string; + complete?: string; + incomplete?: string; + close?: string; + }); + } + export class Spec extends Base {} + export class TAP extends Base {} + export class XUnit extends Base { + constructor(runner: IRunner, options?: any); + } + } +} + +declare module "mocha" { export = Mocha; } From f844c0947a137399b8fb0e7135613b9e68797e16 Mon Sep 17 00:00:00 2001 From: Aurelien Souchet Date: Thu, 4 Jun 2015 16:35:13 +0200 Subject: [PATCH 122/397] added new pickers interface / methods to WinRT --- winrt/winrt.d.ts | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index ed4f33e77..8671e62e0 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -44,6 +44,17 @@ declare module Windows { clear(): void; first(): Windows.Foundation.Collections.IIterator>; } + export class ValueSet implements Windows.Foundation.Collections.IPropertySet, Windows.Foundation.Collections.IObservableMap, Windows.Foundation.Collections.IMap, Windows.Foundation.Collections.IIterable> { + size: number; + onmapchanged: any/* TODO */; + lookup(key: string): any; + hasKey(key: string): boolean; + getView(): Windows.Foundation.Collections.IMapView; + insert(key: string, value: any): boolean; + remove(key: string): void; + clear(): void; + first(): Windows.Foundation.Collections.IIterator>; + } export interface IIterable { first(): Windows.Foundation.Collections.IIterator; } @@ -7940,7 +7951,7 @@ declare module Windows { control: Windows.Networking.Sockets.MessageWebSocketControl; information: Windows.Networking.Sockets.MessageWebSocketInformation; onmessagereceived: any/* TODO */; - close(): void; + close(): void; close(code: number, reason: string): void; } export class MessageWebSocketControl implements Windows.Networking.Sockets.IMessageWebSocketControl, Windows.Networking.Sockets.IWebSocketControl { @@ -7980,7 +7991,7 @@ declare module Windows { control: Windows.Networking.Sockets.StreamWebSocketControl; information: Windows.Networking.Sockets.StreamWebSocketInformation; inputStream: Windows.Storage.Streams.IInputStream; - close(): void; + close(): void; close(code: number, reason: string): void; } export class StreamWebSocketControl implements Windows.Networking.Sockets.IStreamWebSocketControl, Windows.Networking.Sockets.IWebSocketControl { @@ -10986,6 +10997,11 @@ declare module Windows { pickSingleFileAsync(): Windows.Foundation.IAsyncOperation; pickMultipleFilesAsync(): Windows.Foundation.IAsyncOperation>; } + export interface IFileOpenPicker2 { + continuationData: Windows.Foundation.Collections.ValueSet; + pickMultipleFilesAndContinue(): void; + pickSingleFileAndContinue(): void; + } export interface IFileSavePicker { commitButtonText: string; defaultFileExtension: string; @@ -10996,6 +11012,10 @@ declare module Windows { suggestedStartLocation: Windows.Storage.Pickers.PickerLocationId; pickSaveFileAsync(): Windows.Foundation.IAsyncOperation; } + export interface IFileSavePicker2 { + continuationData: Windows.Foundation.Collections.ValueSet; + pickSaveFileAndContinue(): void; + } export interface IFolderPicker { commitButtonText: string; fileTypeFilter: Windows.Foundation.Collections.IVector; @@ -11004,16 +11024,23 @@ declare module Windows { viewMode: Windows.Storage.Pickers.PickerViewMode; pickSingleFolderAsync(): Windows.Foundation.IAsyncOperation; } - export class FileOpenPicker implements Windows.Storage.Pickers.IFileOpenPicker { + export interface IFolderPicker2 { + continuationData: Windows.Foundation.Collections.ValueSet; + pickFolderAndContinue(): void; + } + export class FileOpenPicker implements Windows.Storage.Pickers.IFileOpenPicker, Windows.Storage.Pickers.IFileOpenPicker2 { commitButtonText: string; fileTypeFilter: Windows.Foundation.Collections.IVector; settingsIdentifier: string; suggestedStartLocation: Windows.Storage.Pickers.PickerLocationId; viewMode: Windows.Storage.Pickers.PickerViewMode; + continuationData: Windows.Foundation.Collections.ValueSet; + pickSingleFileAndContinue(): void; pickSingleFileAsync(): Windows.Foundation.IAsyncOperation; + pickMultipleFilesAndContinue(): void; pickMultipleFilesAsync(): Windows.Foundation.IAsyncOperation>; } - export class FileSavePicker implements Windows.Storage.Pickers.IFileSavePicker { + export class FileSavePicker implements Windows.Storage.Pickers.IFileSavePicker, Windows.Storage.Pickers.IFileSavePicker2 { commitButtonText: string; defaultFileExtension: string; fileTypeChoices: Windows.Foundation.Collections.IMap>; @@ -11021,14 +11048,18 @@ declare module Windows { suggestedFileName: string; suggestedSaveFile: Windows.Storage.StorageFile; suggestedStartLocation: Windows.Storage.Pickers.PickerLocationId; + continuationData: Windows.Foundation.Collections.ValueSet; + pickSaveFileAndContinue(): void; pickSaveFileAsync(): Windows.Foundation.IAsyncOperation; } - export class FolderPicker implements Windows.Storage.Pickers.IFolderPicker { + export class FolderPicker implements Windows.Storage.Pickers.IFolderPicker, Windows.Storage.Pickers.IFolderPicker2 { commitButtonText: string; fileTypeFilter: Windows.Foundation.Collections.IVector; settingsIdentifier: string; suggestedStartLocation: Windows.Storage.Pickers.PickerLocationId; viewMode: Windows.Storage.Pickers.PickerViewMode; + continuationData: Windows.Foundation.Collections.ValueSet; + pickFolderAndContinue(): void; pickSingleFolderAsync(): Windows.Foundation.IAsyncOperation; } } @@ -14750,4 +14781,4 @@ declare module Windows.Foundation { dispatchEvent?(type: string, details: any): boolean; removeEventListener?(eventType: string, listener: Function, capture?: boolean): void; } -} +} \ No newline at end of file From 034379ca892327cb722466975d5baa71981a61cf Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 14:18:34 -0400 Subject: [PATCH 123/397] change return type of monthrange to a tuple --- node-calendar/node-calendar.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts index 6f2b7814b..e37f438fb 100755 --- a/node-calendar/node-calendar.d.ts +++ b/node-calendar/node-calendar.d.ts @@ -288,10 +288,10 @@ declare module 'node-calendar' { * * @throws {IllegalMonthError} if the provided month is invalid. * - * @return {number[]} + * @return {[number, number]} * starting weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month. */ - export function monthrange(year: number, month: number): number[]; + export function monthrange(year: number, month: number): [number, number]; /** * Sets the locale for use in extracting month and weekday names. From e118e97028b155ef13e755bcee92afbf9425cc1a Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 14:29:53 -0400 Subject: [PATCH 124/397] formatting: correct whitespace inconsistencies --- node-calendar/node-calendar.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts index e37f438fb..6d5c12eec 100755 --- a/node-calendar/node-calendar.d.ts +++ b/node-calendar/node-calendar.d.ts @@ -348,7 +348,7 @@ declare module 'node-calendar' { */ export class IllegalLocaleError implements Error { public name: string; - public message: string; + public message: string; constructor(message?: string) } @@ -360,7 +360,7 @@ declare module 'node-calendar' { */ export class IllegalDayError implements Error { public name: string; - public message: string; + public message: string; constructor(message?: string) } @@ -372,7 +372,7 @@ declare module 'node-calendar' { */ export class IllegalMonthError implements Error { public name: string; - public message: string; + public message: string; constructor(message?: string) } @@ -384,7 +384,7 @@ declare module 'node-calendar' { */ export class IllegalTimeError implements Error { public name: string; - public message: string; + public message: string; constructor(message?: string) } @@ -396,7 +396,7 @@ declare module 'node-calendar' { */ export class IllegalWeekdayError implements Error { public name: string; - public message: string; + public message: string; constructor(message?: string) } } \ No newline at end of file From 42cb5d2749a91f518edc39cf77464149fb6d055e Mon Sep 17 00:00:00 2001 From: Luzian Zagadinow Date: Thu, 4 Jun 2015 15:07:31 -0400 Subject: [PATCH 125/397] move @param documentation from Error classes at their class level to the constructor where they belong. --- node-calendar/node-calendar.d.ts | 60 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/node-calendar/node-calendar.d.ts b/node-calendar/node-calendar.d.ts index 6d5c12eec..204ec6921 100755 --- a/node-calendar/node-calendar.d.ts +++ b/node-calendar/node-calendar.d.ts @@ -340,63 +340,63 @@ declare module 'node-calendar' { */ export function weekday(year: number, month: number, day: number): number; - /** - * Error indicating a nonexistent or unsupported locale specified. - * - * @param {string} message - * Optional custom error message. - */ + /** Error indicating a nonexistent or unsupported locale specified. */ export class IllegalLocaleError implements Error { public name: string; public message: string; + + /** + * @param {string} message + * Optional custom error message. + */ constructor(message?: string) } - /** - * Error indicating a day index specified outside of the valid range. - * - * @param {string} message - * Optional custom error message. - */ + /** Error indicating a day index specified outside of the valid range. */ export class IllegalDayError implements Error { public name: string; public message: string; + + /** + * @param {string} message + * Optional custom error message. + */ constructor(message?: string) } - /** - * Error indicating a month index specified outside of the expected range (1-12 ~ Jan-Dec). - * - * @param {string} message - * Optional custom error message. - */ + /** Error indicating a month index specified outside of the expected range (1-12 ~ Jan-Dec). */ export class IllegalMonthError implements Error { public name: string; public message: string; + + /** + * @param {string} message + * Optional custom error message. + */ constructor(message?: string) } - /** - * Error indicating a time element is outside of the valid range. - * - * @param {string} message - * Optional custom error message. - */ + /** Error indicating a time element is outside of the valid range. */ export class IllegalTimeError implements Error { public name: string; public message: string; + + /** + * @param {string} message + * Optional custom error message. + */ constructor(message?: string) } - /** - * Error indicating a weekday index specified outside of the expected range (0-6 ~ Mon-Sun). - * - * @param {string} message - * Optional custom error message. - */ + /** Error indicating a weekday index specified outside of the expected range (0-6 ~ Mon-Sun). */ export class IllegalWeekdayError implements Error { public name: string; public message: string; + + /** + * @param {string} message + * Optional custom error message. + */ constructor(message?: string) } } \ No newline at end of file From 4e5a848013335eecb13276eaa5c793c02eab3e72 Mon Sep 17 00:00:00 2001 From: Ryan McNamara Date: Thu, 4 Jun 2015 13:42:34 -0700 Subject: [PATCH 126/397] Created type definitions and tests for heap: https://www.npmjs.com/package/heap --- heap/heap-tests.ts | 96 ++++++++++++++++++++++++++++++++++++++++++++++ heap/heap.d.ts | 84 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 heap/heap-tests.ts create mode 100644 heap/heap.d.ts diff --git a/heap/heap-tests.ts b/heap/heap-tests.ts new file mode 100644 index 000000000..605425893 --- /dev/null +++ b/heap/heap-tests.ts @@ -0,0 +1,96 @@ +/// + +var numberComparator = (a: number, b: number) => { return a.toString().length - b.toString().length; }; +var stringComparator = (a: string, b: string) => { return a.length - b.length; }; + +// Test constructor +var numberHeap: Heap = new Heap(); +numberHeap = new Heap(numberComparator); + +var stringHeap: Heap = new Heap(); +stringHeap = new Heap(stringComparator); + +// Test instance methods +numberHeap.push(0); +stringHeap.push("foo"); +numberHeap.insert(0); +stringHeap.insert("foo"); + +var numberIdentifier: number = numberHeap.pop(); +var stringIdentifier: string = stringHeap.pop(); + +numberIdentifier = numberHeap.replace(1); +stringIdentifier = stringHeap.replace("bar"); + +numberIdentifier = numberHeap.pushpop(2); +stringIdentifier = stringHeap.pushpop("bar"); + +numberHeap.heapify(); +stringHeap.heapify(); + +numberHeap.updateItem(2); +stringHeap.updateItem("bar"); + +var booleanIdentifier: boolean = numberHeap.empty(); +booleanIdentifier = stringHeap.empty(); + +numberIdentifier = numberHeap.size(); +numberIdentifier = stringHeap.size(); + +var numberArray: number[] = numberHeap.toArray(); +var stringArray: string[] = stringHeap.toArray(); + +numberHeap = numberHeap.clone(); +numberHeap = numberHeap.copy(); + +stringHeap = stringHeap.clone(); +stringHeap = stringHeap.copy(); + +// Test static methods +Heap.push(numberArray, 3); +Heap.push(numberArray, 3, numberComparator); + +Heap.push(stringArray, "foo"); +Heap.push(stringArray, "foo", stringComparator); + +numberIdentifier = Heap.pop(numberArray); +numberIdentifier = Heap.pop(numberArray, numberComparator); + +stringIdentifier = Heap.pop(stringArray); +stringIdentifier = Heap.pop(stringArray, stringComparator); + +numberIdentifier = Heap.replace(numberArray, 1); +numberIdentifier = Heap.replace(numberArray, 1, numberComparator); + +stringIdentifier = Heap.replace(stringArray, "foo"); +stringIdentifier = Heap.replace(stringArray, "foo", stringComparator); + +numberIdentifier = Heap.pushpop(numberArray, 1); +numberIdentifier = Heap.pushpop(numberArray, 1, numberComparator); + +stringIdentifier = Heap.pushpop(stringArray, "foo"); +stringIdentifier = Heap.pushpop(stringArray, "foo", stringComparator); + +Heap.heapify(numberArray); +Heap.heapify(numberArray, numberComparator); + +Heap.heapify(stringArray); +Heap.heapify(stringArray, stringComparator); + +Heap.updateItem(numberArray, 1); +Heap.updateItem(numberArray, 1, numberComparator); + +Heap.updateItem(stringArray, "foo"); +Heap.updateItem(stringArray, "foo", stringComparator); + +Heap.nlargest(numberArray, 1); +Heap.nlargest(numberArray, 1, numberComparator); + +Heap.nlargest(stringArray, 1); +Heap.nlargest(stringArray, 1, stringComparator); + +Heap.nsmallest(numberArray, 1); +Heap.nsmallest(numberArray, 1, numberComparator); + +Heap.nsmallest(stringArray, 1); +Heap.nsmallest(stringArray, 1, stringComparator); diff --git a/heap/heap.d.ts b/heap/heap.d.ts new file mode 100644 index 000000000..3ec573d1c --- /dev/null +++ b/heap/heap.d.ts @@ -0,0 +1,84 @@ +// Type definitions for heap 0.2.6 +// Project: https://github.com/qiao/heap.js +// Definitions by: Ryan McNamara +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class Heap { + + // Constructor + + constructor(cmp?: (a: T, b: T) => number); + + // Instance Methods + + // Push item onto heap. + push(item: T): void; + insert(item: T): void; + + // Pop the smallest item off the heap and return it. + pop(): T; + + // Return the smallest item of the heap. + peek(): T; + top(): T; + front(): T; + + // Pop and return the current smallest value, and add the new item. + // This is more efficient than pop() followed by push(), and can be more appropriate when using a fixed size heap. + // Note that the value returned may be larger than item! + replace(item: T): T; + + // Fast version of a push followed by a pop. + pushpop(item: T): T; + + // Rebuild the heap. This method may come handy when the priority of the internal data is being modified. + heapify(): void; + + // Update the position of the given item in the heap. This function should be called every time the item is being modified. + updateItem(item: T): void; + + // Determine whether the heap is empty. + empty(): boolean; + + // Get the number of elements stored in the heap. + size(): number; + + // Return the array representation of the heap. (note: the array is a shallow copy of the heap's internal nodes) + toArray(): T[]; + + // Return a clone of the heap. (note: the internal data is a shallow copy of the original one) + clone(): Heap + copy(): Heap + + // Static Methods + + // Push item onto array, maintaining the heap invariant. + static push(array: T[], item: T, cmp?: (a: T, b: T) => number): void; + + // Pop the smallest item off the array, maintaining the heap invariant. + static pop(array: T[], cmp?: (a: T, b: T) => number): T; + + // Pop and return the current smallest value, and add the new item. + // This is more efficient than heappop() followed by heappush(), and can be more appropriate when using a fixed size heap. Note that the value returned may be larger than item! + static replace(array: T[], item: T, cmp?: (a: T, b: T) => number): T; + + // Fast version of a heappush followed by a heappop. + static pushpop(array: T[], item: T, cmp?: (a: T, b: T) => number): T; + + // Build the heap. + static heapify(array: T[], cmp?: (a: T, b: T) => number): Heap; + + // Update the position of the given item in the heap. This function should be called every time the item is being modified. + static updateItem(array: T[], item: T, cmp?: (a: T, b: T) => number): void; + + // Find the n largest elements in a dataset. + static nlargest(array: T[], n: number, cmp?: (a: T, b: T) => number): T[]; + + // Find the n smallest elements in a dataset. + static nsmallest(array: T[], n: number, cmp?: (a: T, b: T) => number): T[]; + +} + +declare module 'heap' { + export = Heap; +} From 18e1d3ad8c7b38e86ec6531c3f7308172a302072 Mon Sep 17 00:00:00 2001 From: Yaron Librach Date: Fri, 5 Jun 2015 01:06:34 -0400 Subject: [PATCH 127/397] Update definitions and tests to 1.0.1 spec. --- oclazyload/oclazyload-tests.ts | 106 +++++++++++++++++++---- oclazyload/oclazyload.d.ts | 153 +++++++++++++++++++++++++++++---- 2 files changed, 223 insertions(+), 36 deletions(-) diff --git a/oclazyload/oclazyload-tests.ts b/oclazyload/oclazyload-tests.ts index 3879a564b..d3d3d6b11 100644 --- a/oclazyload/oclazyload-tests.ts +++ b/oclazyload/oclazyload-tests.ts @@ -1,23 +1,95 @@ /// -var lazyloader:Function = ()=>{}; +angular.module('app', ['oc.lazyLoad']).config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider: oc.ILazyLoadProvider) { + $ocLazyLoadProvider.config({ + debug: true, + events: true, + modules: [{ + name: 'TestModule', + files: ['js/TestModule.js'] + }] + }) +}]); -var config1: oc.ILazyLoadConfig = { - asyncLoader: lazyloader -}; +angular.module('app').controller(['$ocLazyLoadProvider', function ($ocLazyLoad: oc.ILazyLoad) { + $ocLazyLoad.load('testModule.js'); -var config2:oc.ILazyLoadConfig = { - asyncLoader: lazyloader, - loadedModules: ['module1', 'module2'] -}; + $ocLazyLoad.load(['testModule.js', 'testModuleCtrl.js', 'testModuleService.js']); -var moduleConfig:oc.ILazyLoadModuleConfig = { - name:'testmodule', - files:['testmodule'] -} + $ocLazyLoad.load([ + 'testModule.js', + { + type: 'css', + path: 'testModuleCtrl' + }, + { + type: 'html', + path: 'testModuleCtrl.html' + }, + { + type: 'js', + path: 'testModuleCtrl' + }, + 'js!testModuleService', + 'less!testModuleLessFile' + ]); -var config2:oc.ILazyLoadConfig = { - asyncLoader: lazyloader, - loadedModules: ['module1', 'module2'], - modules: [moduleConfig] -}; + $ocLazyLoad.load([ + { + files: [ + 'testModule.js', + 'bower_components/bootstrap/dist/js/bootstrap.js' + ], + cache: false, + kjdf: false + }, + { + files: ['anotherModule.js'], + cache: true + } + ]); + + $ocLazyLoad.load( + [ + 'testModule.js', + 'bower_components/bootstrap/dist/js/bootstrap.js', + 'anotherModule.js' + ], + { + cache: false + }); + + $ocLazyLoad.load( + [ + 'partials/template1.html', + 'partials/template2.html' + ], + { + cache: false, + reconfig: true, + rerun: true, + serie: true, + insertBefore: '#load_css_before', + timeout: 5000 + }); + + $ocLazyLoad.setModuleConfig({ + files: [ + 'testModule.js' + ], + cache: true + }); + + var getConfig: oc.IModuleConfig = $ocLazyLoad.getModuleConfig('testModule'); + + var getModules: string[] = $ocLazyLoad.getModules(); + + var isLoaded: boolean = $ocLazyLoad.isLoaded([ + 'testModule1.js', + 'testModule2.js' + ]); + + $ocLazyLoad.inject('testModule'); + + $ocLazyLoad.toggleWatch(true); +}]); \ No newline at end of file diff --git a/oclazyload/oclazyload.d.ts b/oclazyload/oclazyload.d.ts index 22ac45f9d..1acf7e781 100644 --- a/oclazyload/oclazyload.d.ts +++ b/oclazyload/oclazyload.d.ts @@ -7,28 +7,143 @@ declare module oc { - interface ILazyLoadConfig { - asyncLoader:any; - loadedModules?:string[]; - modules?:ILazyLoadModuleConfig[]; - } - - interface ILazyLoadModuleConfig { - name:string; - files:string[]; - } - interface ILazyLoad { - load(module:any):ng.IPromise; - loadTemplateFile(url:string, config:ILazyLoadModuleConfig):ng.IPromise; - loadTemplateFile(urls:string[], config:ILazyLoadModuleConfig):ng.IPromise; - getModuleName(moduleName:string):string; - getModules():string[]; - getModuleConfig(name:string):ILazyLoadModuleConfig; - setModuleConfig(config:ILazyLoadModuleConfig):void; + /** + * Loads a module or a list of modules into Angular. + * + * @param module The name of a predefined module config object, or a module config object, or an array of either + * @param config Options to be used when loading the modules + */ + load(module: string|ITypedModuleConfig|IModuleConfig|(string|ITypedModuleConfig|IModuleConfig)[], config?: IOptionsConfig): ng.IPromise; + + /** + * Defines a module config object. + * @param config The module config object + * @returns The module config object that was passed in + */ + setModuleConfig(config: IModuleConfig): IModuleConfig; + + /** + * Gets the specified module config object. + * @param name The name of the module config object to get + */ + getModuleConfig(name: string): IModuleConfig; + + /** + * Gets the list of loaded module names. + */ + getModules(): string[]; + + /** + * Checks if a module name, or list of modules names, has been previously loaded into Angular. + */ + isLoaded(moduleName: string|string[]): boolean; + + /** + * Injects a module with the associated name into Angular. Useful for manual injection when loading through RequireJS, SystemJS, etc. Useful in + * conjunction with the toggleWatch() method. + */ + inject(moduleName: string|string[]): boolean; + + /** + * Enables or disables watching Angular for new modules. Useful in conjunction with the inject() method. Make sure to not keep the watch enabled + * indefinitely, or unexpected results may occur. + */ + toggleWatch(watch: boolean): void; + } + + interface ITypedModuleConfig extends IOptionsConfig { + /** + * The file extension, without the period. For example, 'html'. + */ + type: string; + + /** + * The file path, including file name. + */ + path: string; + } + + interface IModuleConfig extends IOptionsConfig { + /** + * The name of the module for easy retrieval later. + */ + name?: string; + + /** + * The list of files to be loaded for this module. + */ + files: string[]; + } + + interface IOptionsConfig extends ng.IRequestShortcutConfig { + /** + * If true, bypasses browser cache by appending a timestamp to URLs. Defaults to true. + */ + cache?: boolean; + + /** + * If true, a module config will be invoked each time the module is reloaded. Use with caution, as re-invoking configs can lead to unexpected results. + * Defaults to false. + */ + reconfig?: boolean; + + /** + * If true, a module run block will be invoked each time the module is reloaded. Use with caution, as re-invoking run blocks can lead to unexpected results. + * Defaults to false. + */ + rerun?: boolean; + + /** + * If true, will load files in a series, instead of in parallel. Defaults to false. + */ + serie?: boolean; + + /** + * If set, will insert files immediately before the provided CSS selector, instead of the default behavior of inserting files immediately before the + * last child of the element. Defaults to undefined. + */ + insertBefore?: string; } interface ILazyLoadProvider { - config(config:ILazyLoadConfig):void; + /** + * Configures the main service provider. + * @param config The configuration settings to use + */ + config(config: IProviderConfig): void; + } + + interface IProviderConfig { + /** + * If true, all errors will be logged to the console, in addition to rejecting a promise. Defaults to false. + */ + debug?: boolean; + + /** + * If true, an event will be broadcast whenever a module, component or file is loaded. Events that can be broadcast are: ocLazyLoad.moduleLoaded, + * ocLazyLoad.moduleReloaded, ocLazyLoad.componentLoaded, ocLazyLoad.fileLoaded. Defaults to false. + */ + events?: boolean; + + /** + * Predefines a set of module configurations for later use. A name must be provided for each module so that it can be retrieved later. + */ + modules?: IModuleConfig[]; + } +} + +declare module angular { + interface IAngularStatic { + /** + * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. + * + * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved. + * + * @param name The name of the module to create or retrieve. + * @param requires The names of modules this module depends on, and/or ocLazyLoad module configurations. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration. + * @param configFn Optional configuration function for the module. + */ + module(name: string, requires?: (string|oc.IModuleConfig)[], configFn?: Function): IModule; } } \ No newline at end of file From 85d9af51b40179a0e494a04e115afed54b13cc39 Mon Sep 17 00:00:00 2001 From: Igor Kriklivets Date: Fri, 5 Jun 2015 18:54:04 +0300 Subject: [PATCH 128/397] Update to 15.1.3 --- devextreme/14.2/dx.devextreme-14.2.7.d.ts | 5813 +++++++++++++++++++++ devextreme/dx.devextreme.d.ts | 1096 +++- 2 files changed, 6656 insertions(+), 253 deletions(-) create mode 100644 devextreme/14.2/dx.devextreme-14.2.7.d.ts diff --git a/devextreme/14.2/dx.devextreme-14.2.7.d.ts b/devextreme/14.2/dx.devextreme-14.2.7.d.ts new file mode 100644 index 000000000..a1d361f54 --- /dev/null +++ b/devextreme/14.2/dx.devextreme-14.2.7.d.ts @@ -0,0 +1,5813 @@ +// Type definitions for DevExtreme 14.2.7 +// Project: http://js.devexpress.com/ +// Definitions by: DevExpress Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module DevExpress { + /** A mixin that provides a capability to fire and subscribe to events. */ + export interface EventsMixin { + /** Subscribes to a specified event. */ + on(eventName: string, eventHandler: Function): T; + /** Subscribes to the specified events. */ + on(events: { [eventName: string]: Function; }): T; + /** Detaches all event handlers from the specified event. */ + off(eventName: string): Object; + /** Detaches a particular event handler from the specified event. */ + off(eventName: string, eventHandler: Function): T; + } + /** An object that serves as a namespace for the methods required to perform validation. */ + export module validationEngine { + export interface IValidator { + validate(): ValidatorValidationResult; + reset(): void; + } + export interface ValidatorValidationResult { + isValid: boolean; + name?: string; + value: any; + brokenRule: any; + validationRules: any[]; + } + export interface ValidationGroupValidationResult { + isValid: boolean; + brokenRules: any[]; + validators: IValidator[]; + } + export interface GroupConfig extends EventsMixin { + group: any; + validators: IValidator[]; + validate(): ValidationGroupValidationResult; + reset(): void; + } + /** Provides access to the object that represents the specified validation group. */ + export function getGroupConfig(group: any): GroupConfig + /** Provides access to the object that represents the default validation group. */ + export function getGroupConfig(): GroupConfig + /** Validates rules of the validators that belong to the specified validation group. */ + export function validateGroup(group: any): ValidationGroupValidationResult; + /** Validates rules of the validators that belong to the default validation group. */ + export function validateGroup(): ValidationGroupValidationResult; + /** Resets the values and validation result of the editors that belong to the specified validation group. */ + export function resetGroup(group: any): void; + /** Resets the values and validation result of the editors that belong to the default validation group. */ + export function resetGroup(): void; + /** Validates the rules that are defined within the dxValidator objects that are registered for the specified ViewModel. */ + export function validateModel(model: Object): ValidationGroupValidationResult; + /** Registers all the dxValidator objects by which the fields of the specified ViewModel are extended. */ + export function registerModelForValidation(model: Object): void; + } + export var hardwareBackButton: JQueryCallback; + /** Processes the hardware back button click. */ + export function processHardwareBackButton(): void; + /** Specifies whether or not the entire application/site supports right-to-left representation. */ + export var rtlEnabled: boolean; + /** Registers a new component in the DevExpress.ui namespace, and a jQuery plugin and Knockout binding for the required component. */ + export function registerComponent(name: string, componentClass: Object): void; + /** Registers a new component in the specified namespace as a jQuery plugin, Angular directive and Knockout binding. */ + export function registerComponent(name: string, namespace: Object, componentClass: Object): void; + /** Requests that the browser call a specified function to update animation before the next repaint. */ + export function requestAnimationFrame(callback: Function): number; + /** Cancels an animation frame request scheduled with the requestAnimationFrame method. */ + export function cancelAnimationFrame(requestID: number): void; + /** Custom Knockout binding that links an HTML element with a specific action. */ + export class Action { } + /** Used to get URLs that vary in a locally running application and the application running on production. */ + export class EndpointSelector { + constructor(options: { + [key: string]: { + local?: string; + production?: string; + } + }); + /** Returns a local or a productional URL depending on how the application is currently running. */ + urlFor(key: string): string; + } + /** An object that serves as a namespace for the methods that are used to animate UI elements. */ + export module fx { + /** The animation object specifies the widget animation options. */ + export interface AnimationOptions { + /** A function called after animation is completed. */ + complete?: (element: JQuery, config: AnimationOptions) => void; + /** A number specifying wait time before animation execution. */ + delay?: number; + /** A number specifying the time in milliseconds spent on animation. */ + duration?: number; + /** A string specifying the type of an easing function used for animation. */ + easing?: string; + /** Specifies the initial widget animation state. */ + from?: any; + /** A function called before animation is started. */ + start?: (element: JQuery, config: AnimationOptions) => void; + /** Specifies the initial widget animation state. */ + to?: any; + /** A string value specifying the animation type. */ + type?: string; + /** Specifies the animation direction for the "slideIn" and "slideOut" animation types. */ + direction?: string; + } + /** Animates the specified element. */ + export function animate(element: HTMLElement, config: Object): Object; + /** Returns a value indicating whether the specified element is being animated. */ + export function isAnimating(element: HTMLElement): boolean; + /** Stops the animation. */ + export function stop(element: HTMLElement, jumpToEnd: boolean): void; + } + /** An object that serves as a namespace for the methods and events specifying information on the current device. */ + export module devices { + /** The device object defines the device on which the application is running. */ + export interface Device { + /** Indicates whether or not the device platform is Android. */ + android?: boolean; + /** Specifies the type of the device on which the application is running. */ + deviceType?: string; + /** Indicates whether or not the device platform is generic, which means that the application will look and behave according to a generic "light" or "dark" theme. */ + generic?: boolean; + /** Indicates whether or not the device platform is iOS. */ + ios?: boolean; + /** Indicates whether or not the device type is 'phone'. */ + phone?: boolean; + /** Specifies the platform of the device on which the application is running. */ + platform?: string; + /** Indicates whether or not the device type is 'tablet'. */ + tablet?: boolean; + /** Indicates whether or not the device platform is Tizen. */ + tizen?: boolean; + /** Specifies an array with the major and minor versions of the device platform. */ + version?: Array; + /** Indicates whether or not the device platform is Windows8. */ + win8?: boolean; + } + export var orientationChanged: JQueryCallback; + /** Overrides actual device information to force the application to operate as if it was running on the specified device. */ + export function current(deviceName: any): void; + /** Returns information about the current device. */ + export function current(): Device; + /** Returns the current device orientation. */ + export function orientation(): string; + /** Returns real information about the current device regardless of the value passed to the devices.current(deviceName) method. */ + export function real(): Device; + } + /** The position object specifies the widget positioning options. */ + export interface PositionOptions { + /** The target element position that the widget is positioned against. */ + at?: string; + /** The element within which the widget is positioned. */ + boundary?: Element; + /** A string value holding horizontal and vertical offset from the window's boundaries. */ + boundaryOffset?: string; + /** Specifies how to move the widget if it overflows the screen. */ + collision?: any; + /** The position of the widget to align against the target element. */ + my?: string; + /** The target element that the widget is positioned against. */ + of?: HTMLElement; + /** A string value holding horizontal and vertical offset in pixels, separated by a space (e.g., "5 -10"). */ + offset?: string; + } + export interface ComponentOptions { + /** A handler for the optionChanged event. */ + onOptionChanged?: Function; + /** A handler for the disposing event. */ + onDisposing?: Function; + } + /** A base class for all components and widgets. */ + export class Component { + constructor(options?: ComponentOptions) + /** Prevents the component from refreshing until the endUpdate method is called. */ + beginUpdate(): void; + /** Enables the component to refresh after the beginUpdate method call. */ + endUpdate(): void; + /** Returns an instance of this component class. */ + instance(): Component; + /** Sets one or more options of this component. */ + option(options: Object): void; + /** Returns the configuration options of this component. */ + option(): Object; + /** Gets the value of the specified configuration option of this component. */ + option(optionName: string): any; + /** Sets a value to the specified configuration option of this component. */ + option(optionName: string, optionValue: any): void; + } + export interface DOMComponentOptions extends ComponentOptions { + /** Specifies whether or not the current component supports a right-to-left representation. */ + rtlEnabled?: boolean; + } + /** A base class for all components. */ + export class DOMComponent extends Component { + constructor(element: JQuery, options?: DOMComponentOptions); + constructor(element: HTMLElement, options?: DOMComponentOptions); + /** Returns the root HTML element of the widget. */ + element(): JQuery; + /** Specifies the device-dependent default configuration options for this component. */ + static defaultOptions(rule: { + device?: any; + options?: any; + }): void; + } + export module data { + export interface ODataError extends Error { + httpStatus?: number; + errorDetails?: any; + } + export interface StoreOptions { + inserted?: (values: Object, key: any) => void; + inserting?: (values: Object) => void; + loaded?: (result: Array) => void; + loading?: (loadOptions: LoadOptions) => void; + modified?: () => void; + modifying?: () => void; + removed?: (key: any) => void; + removing?: (key: any) => void; + updated?: (key: any, values: Object) => void; + updating?: (key: any, values: Object) => void; + /** A handler for the modified event. */ + onModified?: () => void; + /** A handler for the modifying event. */ + onModifying?: () => void; + /** A handler for the removed event. */ + onRemoved?: (key: any) => void; + /** A handler for the removing event. */ + onRemoving?: (key: any) => void; + /** A handler for the updated event. */ + onUpdated?: (key: any, values: Object) => void; + /** A handler for the updating event. */ + onUpdating?: (key: any, values: Object) => void; + /** A handler for the loaded event. */ + onLoaded?: (result: Array) => void; + /** A handler for the loading event. */ + onLoading?: (loadOptions: LoadOptions) => void; + /** A handler for the inserted event. */ + onInserted?: (values: Object, key: any) => void; + /** A handler for the inserting event. */ + onInserting?: (values: Object) => void; + /** Specifies the function called when the Store causes an error. */ + errorHandler?: (e: Error) => void; + /** Specifies the key properties within the data associated with the Store. */ + key?: any; + } + export interface LoadOptions { + filter?: Object; + sort?: Object; + select?: Object; + expand?: Object; + group?: Object; + skip?: number; + take?: number; + userData?: Object; + requireTotalCount?: boolean; + } + /** The base class for all Stores. */ + export class Store implements EventsMixin { + inserted: JQueryCallback; + inserting: JQueryCallback; + loaded: JQueryCallback; + loading: JQueryCallback; + modified: JQueryCallback; + modifying: JQueryCallback; + removed: JQueryCallback; + removing: JQueryCallback; + updated: JQueryCallback; + updating: JQueryCallback; + constructor(options?: StoreOptions); + /** Returns the data item specified by the key. */ + byKey(key: any): JQueryPromise; + /** Adds an item to the data associated with this Store. */ + insert(values: Object): JQueryPromise; + /** Returns the key expression specified via the key configuration option. */ + key(): any; + /** Returns the key of the Store item that matches the specified object. */ + keyOf(obj: Object): any; + /** Starts loading the data. */ + load(obj?: LoadOptions): JQueryPromise; + /** Removes the data item specified by the key. */ + remove(key: any): JQueryPromise; + /** Obtains the total count of items that will be returned by the load() function. */ + totalCount(obj?: { + filter?: Object; + select?: Object; + group?: Object; + sort?: Object; + }): JQueryPromise; + /** Updates the data item specified by the key. */ + update(key: any, values: Object): JQueryPromise; + on(eventName: "removing", eventHandler: (key: any) => void): Store; + on(eventName: "removed", eventHandler: (key: any) => void): Store; + on(eventName: "updating", eventHandler: (key: any, values: Object) => void): Store; + on(eventName: "updated", eventHandler: (key: any, values: Object) => void): Store; + on(eventName: "inserting", eventHandler: (values: Object) => void): Store; + on(eventName: "inserted", eventHandler: (values: Object, key: any) => void): Store; + on(eventName: "modifying", eventHandler: () => void): Store; + on(eventName: "modified", eventHandler: () => void): Store; + on(eventName: "loading", eventHandler: (loadOptions: LoadOptions) => void): Store; + on(eventName: "loaded", eventHandler: (result: Array) => void): Store; + on(eventName: string, eventHandler: Function): Store; + on(events: { [eventName: string]: Function; }): Store; + off(eventName: "removing"): Store; + off(eventName: "removed"): Store; + off(eventName: "updating"): Store; + off(eventName: "updated"): Store; + off(eventName: "inserting"): Store; + off(eventName: "inserted"): Store; + off(eventName: "modifying"): Store; + off(eventName: "modified"): Store; + off(eventName: "loading"): Store; + off(eventName: "loaded"): Store; + off(eventName: string): Store; + off(eventName: "removing", eventHandler: (key: any) => void): Store; + off(eventName: "removed", eventHandler: (key: any) => void): Store; + off(eventName: "updating", eventHandler: (key: any, values: Object) => void): Store; + off(eventName: "updated", eventHandler: (key: any, values: Object) => void): Store; + off(eventName: "inserting", eventHandler: (values: Object) => void): Store; + off(eventName: "inserted", eventHandler: (values: Object, key: any) => void): Store; + off(eventName: "modifying", eventHandler: () => void): Store; + off(eventName: "modified", eventHandler: () => void): Store; + off(eventName: "loading", eventHandler: (loadOptions: LoadOptions) => void): Store; + off(eventName: "loaded", eventHandler: (result: Array) => void): Store; + off(eventName: string, eventHandler: Function): Store; + } + export interface ArrayStoreOptions extends StoreOptions { + /** Specifies the array associated with this Store. */ + data?: Array; + } + /** A Store accessing an in-memory array. */ + export class ArrayStore extends Store { + constructor(options?: ArrayStoreOptions); + /** Clears all data associated with the current ArrayStore. */ + clear(): void; + /** Creates the Query object for the underlying array. */ + createQuery(): Query; + } + interface Promise { + then(doneFn?: Function, failFn?: Function, progressFn?: Function): Promise; + } + export interface CustomStoreOptions extends StoreOptions { + /** The user implementation of the byKey(key, extraOptions) method. */ + byKey?: (key: any) => Promise; + /** + * User implementation of the byKey(key, extraOptions) method. + * @deprecated byKey.md + */ + lookup?: (key: any) => Promise; + /** The user implementation of the insert(values) method. */ + insert?: (values: Object) => Promise; + /** The user implementation of the load(options) method. */ + load?: (options?: LoadOptions) => Promise; + /** The user implementation of the remove(key) method. */ + remove?: (key: any) => Promise; + /** The user implementation of the totalCount(options) method. */ + totalCount?: () => Promise; + /** The user implementation of the update(key, values) method. */ + update?: (key: any, values: Object) => Promise; + } + /** A Store object that enables you to implement your own data access logic. */ + export class CustomStore extends Store { + constructor(options: CustomStoreOptions); + } + export interface DataSourceOptions { + /** Specifies data filtering conditions. */ + filter?: Object; + /** Specifies data grouping conditions. */ + group?: Object; + /** The item mapping function. */ + map?: (record: any) => any; + /** Specifies the maximum number of items the page can contain. */ + pageSize?: number; + /** Specifies whether a DataSource loads data by pages, or all items at once. */ + paginate?: boolean; + /** The data post processing function. */ + postProcess?: (data: any[]) => any[]; + /** Specifies a value by which the required items are searched. */ + searchExpr?: Object; + /** Specifies the comparison operation used to search for the required items. */ + searchOperation?: string; + /** Specifies the value to which the search expression is compared. */ + searchValue?: Object; + /** Specifies the initial select option value. */ + select?: Object; + /** An array of the strings that represent the names of the navigation properties to be loaded simultaneously with the OData store's entity. */ + expand?: Object; + /** Specifies the initial sort option value. */ + sort?: Object; + /** Specifies the underlying Store instance used to access data. */ + store?: any; + /** A handler for the changed event. */ + onChanged?: () => void; + /** A handler for the loadingChanged event. */ + onLoadingChanged?: (isLoading: boolean) => void; + /** A handler for the loadError event. */ + onLoadError?: (e?: Error) => void; + } + /** An object that provides access to a data web service or local data storage for collection container widgets. */ + export class DataSource implements EventsMixin { + constructor(options?: DataSourceOptions); + changed: JQueryCallback; + loadError: JQueryCallback; + loadingChanged: JQueryCallback; + /** Disposes all resources associated with this DataSource. */ + dispose(): void; + /** Returns the current filter option value. */ + filter(): Object; + /** Sets the filter option value. */ + filter(filterExpr: Object): void; + /** Returns the current group option value. */ + group(): Object; + /** Sets the group option value. */ + group(groupExpr: Object): void; + /** Indicates whether or not the current page contains fewer items than the number of items specified by the pageSize configuration option. */ + isLastPage(): boolean; + /** Indicates whether or not at least one load() method execution has successfully finished. */ + isLoaded(): boolean; + /** Indicates whether or not the DataSource is currently being loaded. */ + isLoading(): boolean; + /** Returns the array of items currently operated by the DataSource. */ + items(): Array; + /** Returns the key expression. */ + key(): any; + /** Starts loading data. */ + load(): JQueryPromise>; + /** Returns an object that would be passed to the load() method of the underlying Store according to the current data shaping option values of the current DataSource instance. */ + loadOptions(): Object; + /** Returns the current pageSize option value. */ + pageSize(): number; + /** Sets the pageSize option value. */ + pageSize(value: number): void; + /** Specifies the index of the currently loaded page. */ + pageIndex(): number; + /** Specifies the index of the page to be loaded during the next load() method execution. */ + pageIndex(newIndex: number): void; + /** Returns the current paginate option value. */ + paginate(): boolean; + /** Sets the paginate option value. */ + paginate(value: boolean): void; + /** Returns the searchExpr option value. */ + searchExpr(): Object; + /** Sets the searchExpr option value. */ + searchExpr(expr: Object): void; + /** Returns the currently specified search operation. */ + searchOperation(): string; + /** Sets the current search operation. */ + searchOperation(op: string): void; + /** Returns the searchValue option value. */ + searchValue(): Object; + /** Sets the searchValue option value. */ + searchValue(value: Object): void; + /** Returns the current select option value. */ + select(): Object; + /** Sets the select option value. */ + select(expr: Object): void; + /** Returns the current sort option value. */ + sort(): Object; + /** Sets the sort option value. */ + sort(sortExpr: Object): void; + /** Returns the underlying Store instance. */ + store(): Store; + /** Returns the number of data items available in an underlying Store after the last load() operation without paging. */ + totalCount(): number; + on(eventName: "loadingChanged", eventHandler: (isLoading: boolean) => void): DataSource; + on(eventName: "loadError", eventHandler: (e?: Error) => void): DataSource; + on(eventName: "changed", eventHandler: () => void): DataSource; + on(eventName: string, eventHandler: Function): DataSource; + on(events: { [eventName: string]: Function; }): DataSource; + off(eventName: "loadingChanged"): DataSource; + off(eventName: "loadError"): DataSource; + off(eventName: "changed"): DataSource; + off(eventName: string): DataSource; + off(eventName: "loadingChanged", eventHandler: (isLoading: boolean) => void): DataSource; + off(eventName: "loadError", eventHandler: (e?: Error) => void): DataSource; + off(eventName: "changed", eventHandler: () => void): DataSource; + off(eventName: string, eventHandler: Function): DataSource; + } + /** An object used to work with primitive data types not supported by JavaScript when accessing an OData web service. */ + export class EdmLiteral { + /** Returns a string representation of the value associated with this EdmLiteral object. */ + valueOf(): string; + } + /** An object used to generate and hold the GUID. */ + export class Guid { + /** Creates a new Guid instance that holds the specified GUID. */ + constructor(value: string); + /** Creates a new Guid instance holding the generated GUID. */ + constructor(); + /** Returns a string representation of the Guid instance. */ + toString(): string; + /** Returns a string representation of the Guid instance. */ + valueOf(): string; + } + export interface LocalStoreOptions extends ArrayStoreOptions { + /** Specifies the time (in miliseconds) after the change operation, before the data is flushed. */ + flushInterval?: number; + /** Specifies whether the data is flushed immediatelly after each change operation, or after the delay specified via the flushInterval option. */ + immediate?: boolean; + /** The unique identifier used to distinguish the data within the HTML5 Web Storage. */ + name?: string; + } + /** A Store providing access to the HTML5 Web Storage. */ + export class LocalStore extends ArrayStore { + constructor(options?: LocalStoreOptions); + /** Removes all data associated with this Store. */ + clear(): void; + } + export interface ODataContextOptions extends ODataStoreOptions { + /** Specifies the list of entities to be accessed via the ODataContext. */ + entities?: Object; + /** Specifies the function called if the ODataContext causes an error. */ + errorHandler?: (e: Error) => void; + } + /** Provides access to the entire OData service. */ + export class ODataContext { + constructor(options?: ODataContextOptions); + /** Initiates the specified WebGet service operation that returns a value. For the information on service operations, refer to the OData documentation. */ + get(operationName: string, params: Object): JQueryPromise; + /** Initiates the specified WebGet service operation that returns nothing. For the information on service operations, refer to the OData documentation. */ + invoke(operationName: string, params: Object, httpMethod: Object): JQueryPromise; + /** Return a special proxy object to describe the entity link. */ + objectLink(entityAlias: string, key: any): Object; + } + export interface ODataStoreOptions extends StoreOptions { + /** A function used to customize a web request before it is sent. */ + beforeSend?: (request: Object) => void; + /** Specifies whether the ODataStore uses the JSONP approach to access non-CORS-compatible remote services. */ + jsonp?: boolean; + /** Specifies the type of the ODataStore key property. The following key types are supported out of the box: String, Int32, Int64, and Guid. */ + keyType?: any; + /** Specifies the URL of the data service being accessed via the current ODataContext. */ + url?: string; + /** Specifies the version of the OData protocol used to interact with the data service. */ + version?: number; + /** Specifies the value of the withCredentials field of the underlying jqXHR object. */ + withCredentials?: boolean; + } + /** A Store providing access to a separate OData web service entity. */ + export class ODataStore extends Store { + constructor(options?: ODataStoreOptions); + /** Creates the Query object for the OData endpoint. */ + createQuery(loadOptions: Object): Object; + /** Returns the data item specified by the key. */ + byKey(key: any, extraOptions?: { expand?: Object }): JQueryPromise; + } + /** An universal chainable data query interface object. */ + export interface Query { + /** Calculates a custom summary for the items in the current Query. */ + aggregate(step: (accumulator: any, value: any) => any): JQueryPromise; + /** Calculates a custom summary for the items in the current Query. */ + aggregate(seed: any, step: (accumulator: any, value: any) => any, finalize: (result: any) => any): JQueryPromise; + /** Calculates the average item value for the current Query. */ + avg(getter: Object): JQueryPromise; + /** Finds the item with the maximum getter value. */ + max(getter: Object): JQueryPromise; + /** Finds the item with the maximum value in the Query. */ + max(): JQueryPromise; + /** Finds the item with the minimum value in the Query. */ + min(): JQueryPromise; + /** Finds the item with the minimum getter value. */ + min(getter: Object): JQueryPromise; + /** Calculates the average item value for the current Query, if each Query item has a numeric type. */ + avg(): JQueryPromise; + /** Returns the total count of items in the current Query. */ + count(): JQueryPromise; + /** Executes the Query. */ + enumerate(): JQueryPromise; + /** Filters the current Query data. */ + filter(criteria: Array): Query; + /** Groups the current Query data. */ + groupBy(getter: Object): Query; + /** Applies the specified transformation to each item. */ + select(getter: Object): Query; + /** Limits the data item count. */ + slice(skip: number, take?: number): Query; + /** Sorts current Query data. */ + sortBy(getter: Object, desc: boolean): Query; + /** Sorts current Query data. */ + sortBy(getter: Object): Query; + /** Calculates the sum of item getter values in the current Query. */ + sum(getter: Object): JQueryPromise; + /** Calculates the sum of item values in the current Query. */ + sum(): JQueryPromise; + /** Adds one more sorting condition to the current Query. */ + thenBy(getter: Object): Query; + /** Adds one more sorting condition to the current Query. */ + thenBy(getter: Object, desc: boolean): Query; + /** Returns the array of current Query items. */ + toArray(): Array; + } + /** The global data layer error handler. */ + export var errorHandler: (e: Error) => void; + /** Encodes the specified string or array of bytes to base64 encoding. */ + export function base64_encode(input: any): string; + /** Creates a Query instance. */ + export function query(array: Array): Query; + /** Creates a Query instance for accessing the remote service specified by a URL. */ + export function query(url: string, queryOptions: Object): Query; + /** This section describes the utility objects provided by the DevExtreme data layer. */ + export var utils: { + /** Compiles a getter function from the getter expression. */ + compileGetter(expr: any): Function; + /** Compiles a setter function from the setter expression. */ + compileSetter(expr: any): Function; + odata: { + /** Holds key value converters for OData. */ + keyConverters: { + String(value: any): string; + Int32(value: any): number; + Int64(value: any): EdmLiteral; + Guid(value: any): Guid; + Boolean(value: any): boolean; + Single(value: any): EdmLiteral; + Decimal(value: any): EdmLiteral; + }; + } + } + } + /** An object that serves as a namespace for DevExtreme UI widgets as well as for methods implementing UI logic in DevExtreme sites/applications. */ + export module ui { + /** + * Sets parameters for the viewport meta tag. + * @deprecated Use the "DevExpress.utils.initMobileViewport" option instead. + */ + export function initViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void; + export interface WidgetOptions extends DOMComponentOptions { + /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ + activeStateEnabled?: boolean; + /** A Boolean value specifying whether or not the widget can respond to user interaction. */ + disabled?: boolean; + /** Specifies the height of the widget. */ + height?: any; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; + /** Specifies whether or not the widget can be focused. */ + focusStateEnabled?: boolean; + /** A Boolean value specifying whether or not the widget is visible. */ + visible?: boolean; + /** Specifies the width of the widget. */ + width?: any; + /** Specifies the widget tab index. */ + tabIndex?: number; + /** Specifies the text of the hint displayed for the widget. */ + hint?: string; + } + /** The base class for widgets. */ + export class Widget extends DOMComponent { + constructor(options?: WidgetOptions); + /** Redraws the widget. */ + repaint(): void; + /** Sets focus on the widget. */ + focus(): void; + } + export interface CollectionWidgetOptions extends WidgetOptions { + /** A data source used to fetch data to be displayed by the widget. */ + dataSource?: any; + itemClickAction?: any; + itemHoldAction?: Function; + /** The time period in milliseconds before the onItemHold event is raised. */ + itemHoldTimeout?: number; + itemRender?: any; + itemRenderedAction?: Function; + /** An array of items displayed by the widget. */ + items?: Array; + /** + * A function performed when a widget item is selected. + * @deprecated onSelectionChanged.md + */ + itemSelectAction?: Function; + /** The template to be used for rendering items. */ + itemTemplate?: any; + loopItemFocus?: boolean; + /** The text or HTML markup displayed by the widget if the item collection is empty. */ + noDataText?: string; + onContentReady?: any; + contentReadyAction?: any; + /** A handler for the itemClick event. */ + onItemClick?: any; + /** A handler for the itemContextMenu event. */ + onItemContextMenu?: Function; + /** A handler for the itemHold event. */ + onItemHold?: Function; + /** A handler for the itemRendered event. */ + onItemRendered?: Function; + /** A handler for the selectionChanged event. */ + onSelectionChanged?: Function; + /** The index of the currently selected widget item. */ + selectedIndex?: number; + /** The selected item object. */ + selectedItem?: Object; + /** An array of currently selected item objects. */ + selectedItems?: Array; + /** A handler for the itemDeleting event. */ + onItemDeleting?: Function; + /** A handler for the itemDeleted event. */ + onItemDeleted?: Function; + /** A handler for the itemReordered event. */ + onItemReordered?: Function; + } + /** The base class for widgets containing an item collection. */ + export class CollectionWidget extends Widget { + constructor(element: JQuery, options?: CollectionWidgetOptions); + constructor(element: HTMLElement, options?: CollectionWidgetOptions); + selectItem(itemElement: any): void; + unselectItem(itemElement: any): void; + deleteItem(itemElement: any): JQueryPromise; + isItemSelected(itemElement: any): boolean; + reorderItem(itemElement: any, toItemElement: any): JQueryPromise; + } + export interface DataExpressionMixinOptions { + /** A data source used to fetch data to be displayed by the widget. */ + dataSource?: any; + /** Specifies the name of the data source item field whose value is displayed by the widget. */ + displayExpr?: any; + /** Specifies the name of a data source item field whose value is held in the value configuration option. */ + valueExpr?: any; + itemRender?: any; + /** An array of items displayed by the widget. */ + items?: Array; + /** The template to be used for rendering items. */ + itemTemplate?: any; + /** The currently selected value in the widget. */ + value?: Object; + } + export interface EditorOptions extends WidgetOptions { + /** The currently specified value. */ + value?: Object; + /** A handler for the valueChanged event. */ + onValueChanged?: Function; + valueChangeAction?: Function; + /** A Boolean value specifying whether or not the widget is read-only. */ + readOnly?: boolean; + /** Holds the object that defines the error that occurred during validation. */ + validationError?: Object; + /** Specifies whether the editor's value is valid. */ + isValid?: boolean; + /** Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed. */ + validationMessageMode?: string; + } + /** A base class for editors. */ + export class Editor extends Widget { + /** Resets the editor's value to undefined. */ + reset(): void; + } + /** An object that serves as a namespace for methods displaying a message in an application/site. */ + export var dialog: { + /** Creates an alert dialog message containing a single "OK" button. */ + alert(message: string, title: string): JQueryPromise; + /** Creates a confirm dialog that contains "Yes" and "No" buttons. */ + confirm(message: string, title: string): JQueryPromise; + /** Creates a custom dialog using the options specified by the passed configuration object. */ + custom(options: { title?: string; message?: string; buttons?: Array; }): { + show(): JQueryPromise; + hide(): void; + hide(value: any): void; + }; + }; + /** Creates a toast message. */ + export function notify(message: any, type: string, displayTime: number): void; + /** Creates a toast message. */ + export function notify(options: Object): void; + /** An object that serves as a namespace for the methods that work with DevExtreme CSS Themes. */ + export var themes: { + /** Returns the name of the currently applied theme. */ + current(): string; + /** Changes the current theme to the specified one. */ + current(themeName: string): void; + }; + /** Sets a specified template engine. */ + export function setTemplateEngine(name: string): void; + /** Sets a custom template engine defined via custom compile and render functions. */ + export function setTemplateEngine(options: Object): void; + /** An object that serves as a namespace for utility methods that can be helpful when working with the DevExtreme framework and UI widgets. */ + export var utils: { + /** Sets parameters for the viewport meta tag. */ + initMobileViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void; + }; + } +} +declare module DevExpress.framework { + /** An object used to store information on the views displayed in an application. */ + export class ViewCache { + viewRemoved: JQueryCallback; + /** Removes all the viewInfo objects from the cache. */ + clear(): void; + /** Obtains a viewInfo object from the cache by the specified key. */ + getView(key: string): Object; + /** Checks whether or not a viewInfo object is contained in the view cache under the specified key. */ + hasView(key: string): boolean; + /** Removes a viewInfo object from the cache by the specified key. */ + removeView(key: string): Object; + /** Adds the specified viewInfo object to the cache under the specified key. */ + setView(key: string, viewInfo: Object): void; + } + export interface dxCommandOptions extends DOMComponentOptions { + action?: any; + /** Specifies an action performed when the execute() method of the command is called. */ + onExecute?: any; + /** Indicates whether or not the widget that displays this command is disabled. */ + disabled?: boolean; + /** Specifies the name of the icon shown inside the widget associated with this command. */ + icon?: string; + /** A URL pointing to the icon shown inside the widget associated with this command. */ + iconSrc?: string; + /** The identifier of the command. */ + id?: string; + /** Specifies the title of the widget associated with this command. */ + title?: string; + /** Specifies the type of the button, if the command is rendered as a dxButton widget. */ + type?: string; + /** A Boolean value specifying whether or not the widget associated with this command is visible. */ + visible?: boolean; + } + /** A markup component used to define markup options for a command. */ + export class dxCommand extends DOMComponent { + constructor(element: JQuery, options: dxCommandOptions); + constructor(options: dxCommandOptions); + /** Executes the action associated with this command. */ + execute(): void; + } + /** An object responsible for routing. */ + export class Router { + /** Adds a routing rule to the list of registered rules. */ + register(pattern: string, defaults?: Object, constraints?: Object): void; + /** Decodes the specified URI to an object using the registered routing rules. */ + parse(uri: string): Object; + /** Formats an object to a URI. */ + format(obj: Object): string; + } + export interface StateManagerOptions { + /** A storage to which the state manager saves the application state. */ + storage?: Object; + } + /** An object used to store the current application state. */ + export class StateManager { + constructor(options?: StateManagerOptions); + /** Adds an object that implements an interface of a state source to the state manager's collection of state sources. */ + addStateSource(stateSource: Object): void; + /** Removes a specified state source from the state manager's collection of state sources. */ + removeStateSource(stateSource: Object): void; + /** Saves the current application state. */ + saveState(): void; + /** Restores the application state that has been saved by the saveState() method to the state storage. */ + restoreState(): void; + /** Removes the application state that has been saved by the saveState() method to the state storage. */ + clearState(): void; + } + export module html { + export var layoutSets: Array; + export interface HtmlApplicationOptions { + /** Specifies where the commands that are defined in the application's views must be displayed. */ + commandMapping?: Object; + /** + * The name of the default layout used by the application. + * @deprecated navigationType.md + */ + defaultLayout?: string; + /** Specifies whether or not view caching is disabled. */ + disableViewCache?: boolean; + /** An array of layout controllers that should be used to show application views in the current navigation context. */ + layoutSet?: any; + /** Specifies whether the current application must behave as a mobile or web application. */ + mode?: string; + /** Specifies the object that represents a root namespace of the application. */ + namespace?: Object; + /** Specifies application behavior when the user navigates to a root view. */ + navigateToRootViewMode?: string; + /** An array of dxCommand configuration objects used to define commands available from the application's global navigation. */ + navigation?: Array; + /** A state manager to be used in the application. */ + stateManager?: StateManager; + /** Specifies the storage to be used by the application's state manager to store the application state. */ + stateStorage?: Object; + /** + * Specifies a strategy for choosing layouts for views in your application. + * @deprecated layoutSet.md + */ + navigationType?: string; + /** + * Specifies the object that represents the root namespace of the application. + * @deprecated namespace.md + */ + ns?: Object; + /** Indicates whether on not to use the title of the previously displayed view as text on the Back button. */ + useViewTitleAsBackText?: boolean; + /** A custom view cache to be used in the application. */ + viewCache?: Object; + /** Specifies a limit for the views that can be cached. */ + viewCacheSize?: number; + /** Specifies options for the viewport meta tag of a mobile browser. */ + viewPort?: JQuery; + /** A custom router to be used in the application. */ + router?: Router; + } + /** An object used to manage views, as well as control the application life cycle. */ + export class HtmlApplication implements EventsMixin { + constructor(options: HtmlApplicationOptions); + afterViewSetup: JQueryCallback; + beforeViewSetup: JQueryCallback; + initialized: JQueryCallback; + navigating: JQueryCallback; + navigatingBack: JQueryCallback; + resolveLayoutController: JQueryCallback; + viewDisposed: JQueryCallback; + viewDisposing: JQueryCallback; + viewHidden: JQueryCallback; + viewRendered: JQueryCallback; + viewShowing: JQueryCallback; + viewShown: JQueryCallback; + /** Provides access to the ViewCache object. */ + viewCache: ViewCache; + /** An array of dxCommand components that are created based on the application's navigation option value. */ + navigation: Array; + /** Provides access to the StateManager object. */ + stateManager: StateManager; + /** Provides access to the Router object. */ + router: Router; + /** Navigates to the URI preceding the current one in the navigation history. */ + back(): void; + /** Returns a Boolean value indicating whether or not backwards navigation is currently possible. */ + canBack(): boolean; + /** Calls the clearState() method of the application's StateManager object. */ + clearState(): void; + /** Creates global navigation commands. */ + createNavigation(navigationConfig: Array): void; + /** Returns an HTML template of the specified view. */ + getViewTemplate(viewName: string): JQuery; + /** Returns a configuration object used to create a dxView component for a specified view. */ + getViewTemplateInfo(viewName: string): Object; + /** Adds a specified HTML template to a collection of view or layout templates. */ + loadTemplates(source: any): JQueryPromise; + /** Navigates to the specified URI. */ + navigate(uri?: any, options?: Object): void; + /** Renders navigation commands to the navigation command containers that are located in the layouts used in the application. */ + renderNavigation(): void; + /** Calls the restoreState() method of the application's StateManager object. */ + restoreState(): void; + /** Calls the saveState method of the application's StateManager object. */ + saveState(): void; + /** Provides access to the object that defines the current context to be considered when choosing an appropriate template for a view. */ + templateContext(): Object; + on(eventName: "initialized", eventHandler: () => void): HtmlApplication; + on(eventName: "afterViewSetup", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + on(eventName: "beforeViewSetup", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + on(eventName: "navigating", eventHandler: (e: { + currentUri: string; + uri: string; + cancel: boolean; + options: { + root: boolean; + target: string; + direction: string; + rootInDetailPane: boolean; + modal: boolean; + }; + }) => void): HtmlApplication; + on(eventName: "navigatingBack", eventHandler: (e: { + cancel: boolean; + isHardwareButton: boolean; + }) => void): HtmlApplication; + on(eventName: "resolveLayoutController", eventHandler: (e: { + viewInfo: Object; + layoutController: Object; + availableLayoutControllers: Array; + }) => void): HtmlApplication; + on(eventName: "viewDisposed", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + on(eventName: "viewDisposing", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + on(eventName: "viewHidden", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + on(eventName: "viewRendered", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + on(eventName: "viewShowing", eventHandler: (e: { + viewInfo: Object; + direction: string; + }) => void): HtmlApplication; + on(eventName: "viewShown", eventHandler: (e: { + viewInfo: Object; + direction: string; + }) => void): HtmlApplication; + on(eventName: string, eventHandler: Function): HtmlApplication; + on(events: { [eventName: string]: Function; }): HtmlApplication; + off(eventName: "initialized"): HtmlApplication; + off(eventName: "afterViewSetup"): HtmlApplication; + off(eventName: "beforeViewSetup"): HtmlApplication; + off(eventName: "navigating"): HtmlApplication; + off(eventName: "navigatingBack"): HtmlApplication; + off(eventName: "resolveLayoutController"): HtmlApplication; + off(eventName: "viewDisposed"): HtmlApplication; + off(eventName: "viewDisposing"): HtmlApplication; + off(eventName: "viewHidden"): HtmlApplication; + off(eventName: "viewRendered"): HtmlApplication; + off(eventName: "viewShowing"): HtmlApplication; + off(eventName: "viewShown"): HtmlApplication; + off(eventName: string): HtmlApplication; + off(eventName: "initialized", eventHandler: () => void): HtmlApplication; + off(eventName: "afterViewSetup", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + off(eventName: "beforeViewSetup", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + off(eventName: "navigating", eventHandler: (e: { + currentUri: string; + uri: string; + cancel: boolean; + options: { + root: boolean; + target: string; + direction: string; + rootInDetailPane: boolean; + modal: boolean; + }; + }) => void): HtmlApplication; + off(eventName: "navigatingBack", eventHandler: (e: { + cancel: boolean; + isHardwareButton: boolean; + }) => void): HtmlApplication; + off(eventName: "resolveLayoutController", eventHandler: (e: { + viewInfo: Object; + layoutController: Object; + availableLayoutControllers: Array; + }) => void): HtmlApplication; + off(eventName: "viewDisposed", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + off(eventName: "viewDisposing", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + off(eventName: "viewHidden", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + off(eventName: "viewRendered", eventHandler: (e: { + viewInfo: Object; + }) => void): HtmlApplication; + off(eventName: "viewShowing", eventHandler: (e: { + viewInfo: Object; + direction: string; + }) => void): HtmlApplication; + off(eventName: "viewShown", eventHandler: (e: { + viewInfo: Object; + direction: string; + }) => void): HtmlApplication; + off(eventName: string, eventHandler: Function): HtmlApplication; + } + } +} +declare module DevExpress.ui { + export interface dxValidatorOptions extends DOMComponentOptions { + /** An array of validation rules to be checked for the editor with which the dxValidator object is associated. */ + validationRules?: Array; + /** Specifies the editor name to be used in the validation default messages. */ + name?: string; + /** An object that specifies what and when to validate and how to apply the validation result. */ + adapter?: Object; + /** Specifies the validation group the editor will be related to. */ + validationGroup?: string; + /** A handler for the validated event. */ + onValidated?: (params: validationEngine.ValidatorValidationResult) => void; + } + /** A widget that is used to validate the associated DevExtreme editors against the defined validation rules. */ + export class dxValidator extends DOMComponent implements validationEngine.IValidator { + constructor(element: JQuery, options?: dxValidatorOptions); + constructor(element: Element, options?: dxValidatorOptions); + /** Validates the value of the editor that is controlled by the current dxValidator object against the list of the specified validation rules. */ + validate(): validationEngine.ValidatorValidationResult; + /** Resets the value and validation result of the editor associated with the current dxValidator object. */ + reset(): void; + } + /** The widget that is used in the Knockout and Angular approaches to combine the editors to be validated. */ + export class dxValidationGroup extends DOMComponent { + constructor(element: JQuery); + constructor(element: Element); + /** Validates rules of the validators that belong to the current validation group. */ + validate(): validationEngine.ValidationGroupValidationResult; + /** Resets the value and validation result of the editors that are included to the current validation group. */ + reset(): void; + } + export interface dxValidationSummaryOptions extends CollectionWidgetOptions { + /** Specifies the validation group for which summary should be generated. */ + validationGroup?: string; + } + /** A widget for displaying the result of checking validation rules for editors. */ + export class dxValidationSummary extends CollectionWidget { + constructor(element: JQuery, options?: dxValidationSummaryOptions); + constructor(element: Element, options?: dxValidationSummaryOptions); + } + export interface dxTooltipOptions extends dxPopoverOptions { + } + /** A tooltip widget. */ + export class dxTooltip extends dxPopover { + constructor(element: JQuery, options?: dxTooltipOptions); + constructor(element: Element, options?: dxTooltipOptions); + } + export interface dxDropDownListOptions extends dxDropDownEditorOptions { + /** Returns the value currently displayed by the widget. */ + displayValue?: string; + /** The minimum number of characters that must be entered into the text box to begin a search. */ + minSearchLength?: number; + /** Specifies the name of a data source item field or an expression whose value is compared to the search criterion. */ + searchExpr?: Object; + /** Specifies the binary operation used to filter data. */ + searchMode?: string; + /** Specifies the time delay, in milliseconds, after the last character has been typed in, before a search is executed. */ + searchTimeout?: number; + /** A handler for the valueChanged event. */ + onValueChanged?: Function; + /** Specifies DOM event names that update a widget's value. */ + valueChangeEvent?: string; + /** Specifies whether or not the widget supports searching. */ + searchEnabled?: boolean; + /** Specifies whether or not the widget displays items by pages. */ + pagingEnabled?: boolean; + /** The text or HTML markup displayed by the widget if the item collection is empty. */ + noDataText?: string; + /** A handler for the selectionChanged event. */ + onSelectionChanged?: Function; + /** A handler for the itemClick event. */ + onItemClick?: Function; + onContentReady?: Function; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; + } + /** A base class for drop-down list widgets. */ + export class dxDropDownList extends dxDropDownEditor { + constructor(element: JQuery, options?: dxDropDownListOptions); + constructor(element: Element, options?: dxDropDownListOptions); + } + export interface dxToolbarOptions extends CollectionWidgetOptions { + menuItemRender?: any; + /** The template used to render menu items. */ + menuItemTemplate?: any; + /** Informs the widget about its location in a view HTML markup. */ + renderAs?: string; + } + /** A toolbar widget. */ + export class dxToolbar extends CollectionWidget { + constructor(element: JQuery, options?: dxToolbarOptions); + constructor(element: Element, options?: dxToolbarOptions); + } + export interface dxToastOptions extends dxOverlayOptions { + animation?: fx.AnimationOptions; + /** The time span in milliseconds during which the dxToast widget is visible. */ + displayTime?: number; + height?: any; + /** The dxToast message text. */ + message?: string; + position?: PositionOptions; + shading?: boolean; + /** Specifies the dxToast widget type. */ + type?: string; + width?: any; + closeOnBackButton?: boolean; + } + /** The toast message widget. */ + export class dxToast extends dxOverlay { + constructor(element: JQuery, options?: dxToastOptions); + constructor(element: Element, options?: dxToastOptions); + } + export interface dxTextEditorOptions extends EditorOptions { + /** A handler for the change event. */ + onChange?: Function; + changeAction?: Function; + /** A handler for the copy event. */ + onCopy?: Function; + copyAction?: Function; + /** A handler for the cut event. */ + onCut?: Function; + cutAction?: Function; + /** A handler for the enterKey event. */ + onEnterKey?: Function; + enterKeyAction?: Function; + /** A handler for the focusIn event. */ + onFocusIn?: Function; + focusInAction?: Function; + /** A handler for the focusOut event. */ + onFocusOut?: Function; + focusOutAction?: Function; + /** A handler for the input event. */ + onInput?: Function; + inputAction?: Function; + /** A handler for the keyDown event. */ + onKeyDown?: Function; + keyDownAction?: Function; + /** A handler for the keyPress event. */ + onKeyPress?: Function; + keyPressAction?: Function; + /** A handler for the keyUp event. */ + onKeyUp?: Function; + keyUpAction?: Function; + /** A handler for the paste event. */ + onPaste?: Function; + pasteAction?: Function; + /** The text displayed by the widget when the widget value is empty. */ + placeholder?: string; + /** Specifies whether to display the Clear button in the widget. */ + showClearButton?: boolean; + /** Specifies the current value displayed by the widget. */ + value?: any; + valueUpdateAction?: Function; + /** Specifies DOM event names that update a widget's value. */ + valueChangeEvent?: string; + valueUpdateEvent?: string; + /** Specifies whether or not the widget checks the inner text for spelling mistakes. */ + spellcheck?: boolean; + /** Specifies HTML attributes applied to the inner input element of the widget. */ + attr?: Object; + /** The read-only option that holds the text displayed by the widget input element. */ + text?: string; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; + } + /** A base class for text editing widgets. */ + export class dxTextEditor extends Editor { + constructor(element: JQuery, options?: dxTextEditorOptions); + constructor(element: Element, options?: dxTextEditorOptions); + /** Removes focus from the input element. */ + blur(): void; + /** Sets focus to the input element representing the widget. */ + focus(): void; + } + export interface dxTextBoxOptions extends dxTextEditorOptions { + /** Specifies the maximum number of characters you can enter into the textbox. */ + maxLength?: any; + /** The "mode" attribute value of the actual HTML input element representing the text box. */ + mode?: string; + } + /** A single-line text box widget. */ + export class dxTextBox extends dxTextEditor { + constructor(element: JQuery, options?: dxTextBoxOptions); + constructor(element: Element, options?: dxTextBoxOptions); + } + export interface dxTextAreaOptions extends dxTextBoxOptions { + /** Specifies whether or not the widget checks the inner text for spelling mistakes. */ + spellcheck?: boolean; + } + /** A widget used to display and edit multi-line text. */ + export class dxTextArea extends dxTextBox { + constructor(element: JQuery, options?: dxTextAreaOptions); + constructor(element: Element, options?: dxTextAreaOptions); + } + export interface dxTabsOptions extends CollectionWidgetOptions { + /** Specifies whether the widget enables an end-user to select only a single item or multiple items. */ + selectionMode?: string; + /** Specifies whether or not an end-user can scroll tabs by swiping. */ + scrollByContent?: boolean; + /** Specifies whether or not an end-user can scroll tabs. */ + scrollingEnabled?: boolean; + /** A Boolean value that specifies the availability of navigation buttons. */ + showNavButtons?: boolean; + } + /** A tab strip used to switch between pages. */ + export class dxTabs extends CollectionWidget { + constructor(element: JQuery, options?: dxTabsOptions); + constructor(element: Element, options?: dxTabsOptions); + } + export interface dxTabPanelOptions extends dxMultiViewOptions { + /** A handler for the titleClick event. */ + onTitleClick?: any; + /** A handler for the titleHold event. */ + onTitleHold?: Function; + /** A handler for the titleRendered event. */ + onTitleRendered?: Function; + titleTemplate?: any; + /** The template to be used for rendering an item title. */ + itemTitleTemplate?: any; + } + /** A widget used to display a view and to switch between several views by clicking the appropriate tabs. */ + export class dxTabPanel extends dxMultiView { + constructor(element: JQuery, options?: dxTabPanelOptions); + constructor(element: Element, options?: dxTabPanelOptions); + } + export interface dxSelectBoxOptions extends dxDropDownListOptions { + /** The template to be used for rendering the widget text field. */ + fieldTemplate?: any; + /** The text that is provided as a hint in the select box editor. */ + placeholder?: string; + /** Specifies whether or not the widget allows an end-user to enter a custom value. */ + fieldEditEnabled?: boolean; + } + /** A widget that allows you to select an item in a dropdown list. */ + export class dxSelectBox extends dxDropDownList { + constructor(element: JQuery, options?: dxSelectBoxOptions); + constructor(element: Element, options?: dxSelectBoxOptions); + } + export interface dxTagBoxOptions extends dxSelectBoxOptions { + /** Holds the list of selected values. */ + values?: Array; + } + /** A widget that allows you to select multiple items from a dropdown list. */ + export class dxTagBox extends dxSelectBox { + constructor(element: JQuery, options?: dxTagBoxOptions); + constructor(element: Element, options?: dxTagBoxOptions); + } + export interface dxScrollViewOptions extends dxScrollableOptions { + /** A handler for the pullDown event. */ + onPullDown?: Function; + pullDownAction?: Function; + /** Specifies the text shown in the pullDown panel when pulling the content down lowers the refresh threshold. */ + pulledDownText?: string; + /** Specifies the text shown in the pullDown panel while pulling the content down to the refresh threshold. */ + pullingDownText?: string; + /** A handler for the reachBottom event. */ + onReachBottom?: Function; + reachBottomAction?: Function; + /** Specifies the text shown in the pullDown panel displayed when content is scrolled to the bottom. */ + reachBottomText?: string; + /** Specifies the text shown in the pullDown panel displayed when the content is being refreshed. */ + refreshingText?: string; + /** Returns a value indicating if the scrollView content is larger then the widget container. */ + isFull(): boolean; + /** Locks the widget until the release(preventScrollBottom) method is called and executes the function passed to the onPullDown option and the handler assigned to the pullDown event. */ + refresh(): void; + /** Notifies the scroll view that data loading is finished. */ + release(preventScrollBottom: boolean): JQueryPromise; + /** Toggles the loading state of the widget. */ + toggleLoading(showOrHide: boolean): void; + } + /** A widget used to display scrollable content. */ + export class dxScrollView extends dxScrollable { + constructor(element: JQuery, options?: dxScrollViewOptions); + constructor(element: Element, options?: dxScrollViewOptions); + } + export interface dxScrollableLocation { + top?: number; + left?: number; + } + export interface dxScrollableOptions extends DOMComponentOptions { + /** A string value specifying the available scrolling directions. */ + direction?: string; + /** A Boolean value specifying whether or not the widget can respond to user interaction. */ + disabled?: boolean; + /** A handler for the scroll event. */ + onScroll?: Function; + scrollAction?: Function; + /** Specifies when the widget shows the scrollbar. */ + showScrollbar?: string; + /** A handler for the update event. */ + onUpdated?: Function; + updateAction?: Function; + /** Indicates whether to use native or simulated scrolling. */ + useNative?: boolean; + /** A Boolean value specifying whether to enable or disable the bounce-back effect. */ + bounceEnabled?: boolean; + /** A Boolean value specifying whether or not an end-user can scroll the widget content swiping it up or down. */ + scrollByContent?: boolean; + /** A Boolean value specifying whether or not an end-user can scroll the widget content using the scrollbar. */ + scrollByThumb?: boolean; + } + /** A widget used to display scrollable content. */ + export class dxScrollable extends DOMComponent { + constructor(element: JQuery, options?: dxScrollableOptions); + constructor(element: Element, options?: dxScrollableOptions); + /** Returns the height of the scrollable widget in pixels. */ + clientHeight(): number; + /** Returns the width of the scrollable widget in pixels. */ + clientWidth(): number; + /** An HTML element of the widget. */ + content(): JQuery; + /** Scrolls the widget content by the specified number of pixels. */ + scrollBy(distance: number): void; + /** Scrolls widget content by the specified number of pixels in horizontal and vertical directions. */ + scrollBy(distanceObject: dxScrollableLocation): void; + /** Returns the height of the scrollable content in pixels. */ + scrollHeight(): number; + /** Returns the current scroll position against the leftmost position. */ + scrollLeft(): number; + /** Returns how far the scrollable content is scrolled from the top and from the left. */ + scrollOffset(): dxScrollableLocation; + /** Scrolls widget content to the specified position. */ + scrollTo(targetLocation: number): void; + /** Scrolls widget content to a specified position. */ + scrollTo(targetLocation: dxScrollableLocation): void; + /** Scrolls widget content to the specified element. */ + scrollToElement(element: Element): void; + /** Returns the current scroll position against the topmost position. */ + scrollTop(): number; + /** Returns the width of the scrollable content in pixels. */ + scrollWidth(): number; + /** Updates the dimensions of the scrollable contents. */ + update(): void; + } + export interface dxRadioGroupOptions extends CollectionWidgetOptions { + /** Specifies the radio group layout. */ + layout?: string; + } + /** A widget that enables a user to select one item within a list of items represented by radio buttons. */ + export class dxRadioGroup extends CollectionWidget { + constructor(element: JQuery, options?: dxRadioGroupOptions); + constructor(element: Element, options?: dxRadioGroupOptions); + } + export interface dxPopupOptions extends dxOverlayOptions { + animation?: fx.AnimationOptions; + /** Specifies whether or not to allow a user to drag the popup window. */ + dragEnabled?: boolean; + /** A Boolean value specifying whether or not to display the widget in full-screen mode. */ + fullScreen?: boolean; + position?: PositionOptions; + /** A Boolean value specifying whether or not to display the title in the overlay window. */ + showTitle?: boolean; + /** The title in the overlay window. */ + title?: string; + /** A template to be used for rendering the widget title. */ + titleTemplate?: any; + width?: any; + /** Specifies items displayed on the top or bottom toolbar of the popup window. */ + buttons?: Array; + /** Specifies whether or not the widget displays the Close button. */ + showCloseButton?: boolean; + /** A handler for the titleRendered event. */ + onTitleRendered?: Function; + } + /** A widget that displays required content in a popup window. */ + export class dxPopup extends dxOverlay { + constructor(element: JQuery, options?: dxPopupOptions); + constructor(element: Element, options?: dxPopupOptions); + } + export interface dxPopoverOptions extends dxPopupOptions { + /** An object defining animation options of the widget. */ + animation?: fx.AnimationOptions; + /** Specifies the height of the widget. */ + height?: any; + /** An object defining widget positioning options. */ + position?: PositionOptions; + shading?: boolean; + /** A Boolean value specifying whether or not to display the title in the overlay window. */ + showTitle?: boolean; + /** The target element associated with a popover. */ + target?: any; + /** Specifies the width of the widget. */ + width?: any; + } + /** A widget that displays the required content in a popup window. */ + export class dxPopover extends dxPopup { + constructor(element: JQuery, options?: dxPopoverOptions); + constructor(element: Element, options?: dxPopoverOptions); + /** Displays the widget for the specified target element. */ + show(target?: any): JQueryPromise; + } + export interface dxOverlayOptions extends WidgetOptions { + /** An object that defines the animation options of the widget. */ + animation?: fx.AnimationOptions; + /** A Boolean value specifying whether or not the widget is closed if a user presses the Back hardware button. */ + closeOnBackButton?: boolean; + /** A Boolean value specifying whether or not the widget is closed if a user clicks outside of the overlapping window. */ + closeOnOutsideClick?: any; + /** A template to be used for rendering widget content. */ + contentTemplate?: any; + /** Specifies whether widget content is rendered when the widget is shown or when rendering the widget. */ + deferRendering?: boolean; + /** Specifies whether or not an end-user can drag the widget. */ + dragEnabled?: boolean; + /** The height of the widget in pixels. */ + height?: any; + /** A handler for the hidden event. */ + onHidden?: Function; + hiddenAction?: Function; + /** A handler for the hiding event. */ + onHiding?: Function; + hidingAction?: Function; + /** An object defining widget positioning options. */ + position?: PositionOptions; + /** A Boolean value specifying whether or not the main screen is inactive while the widget is active. */ + shading?: boolean; + /** Specifies the shading color. */ + shadingColor?: string; + /** A handler for the showing event. */ + onShowing?: Function; + showingAction?: Function; + /** A handler for the shown event. */ + onShown?: Function; + shownAction?: Function; + /** A Boolean value specifying whether or not the widget is visible. */ + visible?: boolean; + /** The widget width in pixels. */ + width?: any; + } + /** A widget displaying the required content in an overlay window. */ + export class dxOverlay extends Widget { + constructor(element: JQuery, options?: dxOverlayOptions); + constructor(element: Element, options?: dxOverlayOptions); + /** An HTML element of the widget. */ + content(): JQuery; + /** Hides the widget. */ + hide(): JQueryPromise; + /** Recalculates the overlay's size and position. */ + repaint(): void; + /** Shows the widget. */ + show(): JQueryPromise; + /** Toggles the visibility of the widget. */ + toggle(showing: boolean): JQueryPromise; + /** A static method that specifies the default z-index for all overlay widgets. */ + static baseZIndex(zIndex: number): void; + } + export interface dxNumberBoxOptions extends dxTextEditorOptions { + /** The maximum value accepted by the number box. */ + max?: number; + /** The minimum value accepted by the number box. */ + min?: number; + /** Specifies whether or not to show spin buttons. */ + showSpinButtons?: boolean; + useTouchSpinButtons?: boolean; + /** Specifies by which value the widget value changes when a spin button is clicked. */ + step?: number; + /** The current number box value. */ + value?: number; + } + /** A textbox widget that enables a user to enter numeric values. */ + export class dxNumberBox extends dxTextEditor { + constructor(element: JQuery, options?: dxNumberBoxOptions); + constructor(element: Element, options?: dxNumberBoxOptions); + } + export interface dxNavBarOptions extends dxTabsOptions { + scrollingEnabled?: boolean; + } + /** A widget that contains items used to navigate through application views. */ + export class dxNavBar extends dxTabs { + constructor(element: JQuery, options?: dxNavBarOptions); + constructor(element: Element, options?: dxNavBarOptions); + } + export interface dxMultiViewOptions extends CollectionWidgetOptions { + /** Specifies whether or not to animate the displayed item change. */ + animationEnabled?: boolean; + /** A Boolean value specifying whether or not to scroll back to the first item after the last item is swiped. */ + loop?: boolean; + /** The index of the currently displayed item. */ + selectedIndex?: number; + /** A Boolean value specifying whether or not to allow users to change the selected index by swiping. */ + swipeEnabled?: boolean; + } + /** A widget used to display a view and to switch between several views. */ + export class dxMultiView extends CollectionWidget { + constructor(element: JQuery, options?: dxMultiViewOptions); + constructor(element: Element, options?: dxMultiViewOptions); + } + export interface dxMapOptions extends WidgetOptions { + /** Specifies whether or not the widget automatically adjusts center and zoom option values when adding a new marker or route. */ + autoAdjust?: boolean; + bounds?: { + northEast?: { + lat?: number; + lng?: number; + }; + southWest?: { + lat?: number; + lng?: number; + }; + /** An object, a string, or an array specifying the location displayed at the center of the widget. */ + center?: { + /** The latitude location displayed in the center of the widget. */ + lat?: number; + /** The longitude location displayed in the center of the widget. */ + lng?: number; + }; + /** A handler for the click event. */ + onClick?: any; + clickAction?: any; + /** Specifies whether or not map widget controls are available. */ + controls?: boolean; + /** Specifies the height of the widget. */ + height?: number; + /** A key used to authenticate the application within the required map provider. */ + key?: { + /** A key used to authenticate the application within the "Bing" map provider. */ + bing?: string; + /** A key used to authenticate the application within the "Google" map provider. */ + google?: string; + /** A key used to authenticate the application within the "Google Static" map provider. */ + googleStatic?: string; + } + /** + * An object, a string, or an array specifying the location displayed at the center of the widget. + * @deprecated center.md + */ + location?: { + lat?: number; + lng?: number; + }; + /** A handler for the markerAdded event. */ + onMarkerAdded?: Function; + markerAddedAction?: Function; + /** A URL pointing to the custom icon to be used for map markers. */ + markerIconSrc?: string; + /** A handler for the markerRemoved event. */ + onMarkerRemoved?: Function; + markerRemovedAction?: Function; + /** An array of markers displayed on a map. */ + markers?: Array; + /** The name of the current map data provider. */ + provider?: string; + /** A handler for the ready event. */ + onReady?: Function; + readyAction?: Function; + /** A handler for the routeAdded event. */ + onRouteAdded?: Function; + routeAddedAction?: Function; + /** A handler for the routeRemoved event. */ + onRouteRemoved?: Function; + routeRemovedAction?: Function; + /** An array of routes shown on the map. */ + routes?: Array; + /** The type of a map to display. */ + type?: string; + /** Specifies the width of the widget. */ + width?: number; + /** The zoom level of the map. */ + zoom?: number; + /** Adds a marker to the map. */ + addMarker(markerOptions: Object): JQueryPromise; + /** Adds a route to the map. */ + addRoute(options: Object): JQueryPromise; + /** Removes a marker from the map. */ + removeMarker(marker: Object): JQueryPromise; + /** Removes a route from the map. */ + removeRoute(route: any): JQueryPromise; + }; + } + /** An interactive map widget. */ + export class dxMap extends Widget { + constructor(element: JQuery, options?: dxMapOptions); + constructor(element: Element, options?: dxMapOptions); + } + export interface dxLookupOptions extends dxDropDownListOptions { + /** An object defining widget animation options. */ + animation?: fx.AnimationOptions; + autoPagingEnabled?: boolean; + /** The text displayed on the Cancel button. */ + cancelButtonText?: string; + /** The text displayed on the Clear button. */ + clearButtonText?: string; + /** A Boolean value specifying whether or not the widget is closed if a user clicks outside of the overlaying window. */ + closeOnOutsideClick?: any; + /** The text displayed on the Apply button. */ + applyButtonText?: string; + /** A Boolean value specifying whether or not to display the lookup in full-screen mode. */ + fullScreen?: boolean; + /** A Boolean value specifying whether or not to group widget items. */ + grouped?: boolean; + groupRender?: any; + /** The name of the template used to display a group header. */ + groupTemplate?: any; + /** The text displayed on the button used to load the next page from the data source. */ + nextButtonText?: string; + /** A handler for the pageLoading event. */ + onPageLoading?: Function; + pageLoadingAction?: Function; + /** Specifies the text shown in the pullDown panel, which is displayed when the widget is scrolled to the bottom. */ + pageLoadingText?: string; + /** The text displayed by the widget when nothing is selected. */ + placeholder?: string; + /** The height of the widget popup element. */ + popupHeight?: any; + /** The width of the widget popup element. */ + popupWidth?: any; + /** An object defining widget positioning options. */ + position?: PositionOptions; + /** Specifies the text displayed in the pullDown panel when the widget is pulled below the refresh threshold. */ + pulledDownText?: string; + /** Specifies the text shown in the pullDown panel while the list is being pulled down to the refresh threshold. */ + pullingDownText?: string; + /** A handler for the pullRefresh event. */ + onPullRefresh?: Function; + pullRefreshAction?: Function; + /** A Boolean value specifying whether or not the widget supports the "pull down to refresh" gesture. */ + pullRefreshEnabled?: boolean; + /** Specifies the text displayed in the pullDown panel while the widget is being refreshed. */ + refreshingText?: string; + /** A handler for the scroll event. */ + onScroll?: Function; + scrollAction?: Function; + /** A Boolean value specifying whether or not the search bar is visible. */ + searchEnabled?: boolean; + /** The text that is provided as a hint in the lookup's search bar. */ + searchPlaceholder?: string; + /** A Boolean value specifying whether or not the main screen is inactive while the lookup is active. */ + shading?: boolean; + /** Specifies whether to display the Cancel button in the lookup window. */ + showCancelButton?: boolean; + /** A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. */ + showNextButton?: boolean; + /** The title of the lookup window. */ + title?: string; + /** A template to be used for rendering the widget title. */ + titleTemplate?: any; + /** Specifies whether or not the widget uses native scrolling. */ + useNativeScrolling?: boolean; + /** Specifies whether or not to show lookup contents in a dxPopover widget. */ + usePopover?: boolean; + /** A handler for the valueChanged event. */ + onValueChanged?: Function; + contentReadyAction?: Function; + titleRender?: any; + /** A handler for the titleRendered event. */ + onTitleRendered?: Function; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; + } + /** A widget that allows a user to select predefined values from a lookup window. */ + export class dxLookup extends dxDropDownList { + constructor(element: JQuery, options?: dxLookupOptions); + constructor(element: Element, options?: dxLookupOptions); + /** This section lists the data source fields that are used in a default template for lookup drop-down items. */ + } + export interface dxLoadPanelOptions extends dxOverlayOptions { + /** An object defining the animation options of the widget. */ + animation?: fx.AnimationOptions; + /** The delay in milliseconds after which the load panel is displayed. */ + delay?: number; + /** The height of the widget. */ + height?: number; + /** A URL pointing to an image to be used as a load indicator. */ + indicatorSrc?: string; + /** The text displayed in the load panel. */ + message?: string; + /** A Boolean value specifying whether or not to show a load indicator. */ + showIndicator?: boolean; + /** A Boolean value specifying whether or not to show the pane behind the load indicator. */ + showPane?: boolean; + /** The width of the widget. */ + width?: number; + } + /** A widget used to indicate whether or not an element is loading. */ + export class dxLoadPanel extends dxOverlay { + constructor(element: JQuery, options?: dxLoadPanelOptions); + constructor(element: Element, options?: dxLoadPanelOptions); + } + export interface dxLoadIndicatorOptions extends WidgetOptions { + /** Specifies the path to an image used as the indicator. */ + indicatorSrc?: string; + } + /** The widget used to indicate the loading process. */ + export class dxLoadIndicator extends Widget { + constructor(element: JQuery, options?: dxLoadIndicatorOptions); + constructor(element: Element, options?: dxLoadIndicatorOptions); + } + export interface dxListOptions extends CollectionWidgetOptions { + /** A Boolean value specifying whether or not to load the next page from the data source when the list is scrolled to the bottom. */ + autoPagingEnabled?: boolean; + /** Specifies whether or not the widget displays items by pages. */ + pagingEnabled?: boolean; + /** An object used to set configuration options for the dxList's edit mode. */ + editConfig?: { + /** Specifies whether the list items can be deleted. */ + deleteEnabled?: boolean; + /** + * A mode specifying how to delete a list item. + * @deprecated deleteType.md + */ + deleteMode?: string; + /** Specifies the way a user can delete items from the list. */ + deleteType?: string; + itemRender?: any; + /** The template used to render list items in edit mode. */ + itemTemplate?: any; + /** Specifies the array of items for a context menu called for a list item. */ + menuItems?: Array; + /** Specifies whether an item context menu is shown when a user swipes or holds an item. */ + menuType?: string; + /** Specifies whether or not a user can reorder items. */ + reorderEnabled?: boolean; + /** Specifies whether the list items can be selected. */ + selectionEnabled?: boolean; + /** + * A mode specifying how to select a list item. + * @deprecated selectionType.md + */ + selectionMode?: string; + /** A type specifying how to select a list item. */ + selectionType?: string; + /** Specifies whether the item list represented by this widget is editable. */ + editEnabled?: boolean; + /** Specifies whether or not to show the loading panel when the DataSource bound to the widget is loading data. */ + indicateLoading?: boolean; + }; + /** A Boolean value specifying whether or not to display a grouped list. */ + grouped?: boolean; + groupRender?: any; + /** The name of the template used to display a group header. */ + groupTemplate?: any; + onItemDeleting?: Function; + /** A handler for the itemDeleted event. */ + onItemDeleted?: Function; + itemDeleteAction?: Function; + /** A handler for the itemReordered event. */ + onItemReordered?: Function; + itemReorderAction?: Function; + /** A handler for the itemClick event. */ + onItemClick?: any; + /** A handler for the itemSwipe event. */ + onItemSwipe?: Function; + itemSwipeAction?: Function; + /** The text displayed on the button used to load the next page from the data source. */ + nextButtonText?: string; + /** A handler for the pageLoading event. */ + onPageLoading?: Function; + pageLoadingAction?: Function; + /** Specifies the text shown in the pullDown panel, which is displayed when the list is scrolled to the bottom. */ + pageLoadingText?: string; + /** Specifies the text displayed in the pullDown panel when the list is pulled below the refresh threshold. */ + pulledDownText?: string; + /** Specifies the text shown in the pullDown panel while the list is being pulled down to the refresh threshold. */ + pullingDownText?: string; + /** A handler for the pullRefresh event. */ + onPullRefresh?: Function; + pullRefreshAction?: Function; + /** A Boolean value specifying whether or not the widget supports the "pull down to refresh" gesture. */ + pullRefreshEnabled?: boolean; + /** Specifies the text displayed in the pullDown panel while the list is being refreshed. */ + refreshingText?: string; + /** A handler for the scroll event. */ + onScroll?: Function; + scrollAction?: Function; + /** A Boolean value specifying whether to enable or disable list scrolling. */ + scrollingEnabled?: boolean; + /** Specifies whether the list supports single item selection or multi-selection. */ + selectionMode?: string; + /** A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. */ + showNextButton?: boolean; + /** Specifies when the widget shows the scrollbar. */ + showScrollbar?: string; + /** Specifies whether or not the widget uses native scrolling. */ + useNativeScrolling?: boolean; + itemUnselectAction?: Function; + onItemContextMenu?: Function; + onItemHold?: Function; + /** Specifies whether or not an end-user can collapse groups. */ + collapsibleGroups?: boolean; + } + /** A list widget. */ + export class dxList extends CollectionWidget { + constructor(element: JQuery, options?: dxListOptions); + constructor(element: Element, options?: dxListOptions); + /** Returns the height of the widget in pixels. */ + clientHeight(): number; + /** Removes the specified item from the list. */ + deleteItem(itemIndex: any): JQueryPromise; + /** Removes the specified item from the list. */ + deleteItem(itemElement: Element): JQueryPromise; + /** Returns a Boolean value that indicates whether or not the specified item is selected. */ + isItemSelected(itemIndex: any): boolean; + /** Returns a Boolean value that indicates whether or not the specified item is selected. */ + isItemSelected(itemElement: Element): boolean; + /** + * Reloads list data. + * @deprecated Use the "reload" method instead. + */ + refresh(): void; + /** Reloads list data. */ + reload(): void; + /** Moves the specified item to the specified position in the list. */ + reorderItem(itemElement: Element, toItemElement: Element): JQueryPromise; + /** Moves the specified item to the specified position in the list. */ + reorderItem(itemIndex: any, toItemIndex: any): JQueryPromise; + /** Scrolls the list content by the specified number of pixels. */ + scrollBy(distance: number): void; + /** Returns the height of the list content in pixels. */ + scrollHeight(): number; + /** Scrolls list content to the specified position. */ + scrollTo(location: number): void; + /** Scrolls the list to the specified item. */ + scrollToItem(itemElement: Element): void; + /** Scrolls the list to the specified item. */ + scrollToItem(itemIndex: any): void; + /** Returns how far the list content is scrolled from the top. */ + scrollTop(): number; + /** Selects the specified item from the list. */ + selectItem(itemElement: Element): void; + /** Selects the specified item from the list. */ + selectItem(itemIndex: any): void; + /** Deselects the specified item from the list. */ + unselectItem(itemElement: Element): void; + /** Unselects the specified item from the list. */ + unselectItem(itemIndex: any): void; + /** + * Updates the widget scrollbar according to widget content size. + * @deprecated updateDimensions.md + */ + update(): JQueryPromise; + /** Updates the widget scrollbar according to widget content size. */ + updateDimensions(): JQueryPromise; + /** Expands the specified group. */ + expandGroup(groupIndex: number): JQueryPromise; + /** Collapses the specified group. */ + collapseGroup(groupIndex: number): JQueryPromise; + } + export interface dxGalleryOptions extends CollectionWidgetOptions { + /** The time, in milliseconds, spent on slide animation. */ + animationDuration?: number; + /** Specifies whether or not to animate the displayed item change. */ + animationEnabled?: boolean; + /** A Boolean value specifying whether or not to allow users to switch between items by clicking an indicator. */ + indicatorEnabled?: boolean; + /** A Boolean value specifying whether or not to scroll back to the first item after the last item is swiped. */ + loop?: boolean; + /** The index of the currently active gallery item. */ + selectedIndex?: number; + /** A Boolean value specifying whether or not to display an indicator that points to the selected gallery item. */ + showIndicator?: boolean; + /** A Boolean value that specifies the availability of the "Forward" and "Back" navigation buttons. */ + showNavButtons?: boolean; + /** The time interval in milliseconds, after which the gallery switches to the next item. */ + slideshowDelay?: number; + /** A Boolean value specifying whether or not to allow users to switch between items by swiping. */ + swipeEnabled?: boolean; + } + /** An image gallery widget. */ + export class dxGallery extends CollectionWidget { + constructor(element: JQuery, options?: dxGalleryOptions); + constructor(element: Element, options?: dxGalleryOptions); + /** Shows the specified gallery item. */ + goToItem(itemIndex: number, animation: boolean): JQueryPromise; + /** Shows the next gallery item. */ + nextItem(animation: boolean): JQueryPromise; + /** Shows the previous gallery item. */ + prevItem(animation: boolean): JQueryPromise; + } + export interface dxDropDownEditorOptions extends dxTextBoxOptions { + /** Specifies the current value displayed by the widget. */ + value?: Object; + /** A handler for the closed event. */ + onClosed?: Function; + /** A handler for the opened event. */ + onOpened?: Function; + /** Specifies whether or not the drop-down editor is displayed. */ + opened?: boolean; + closeAction?: Function; + openAction?: Function; + shownAction?: Function; + hiddenAction?: Function; + /** Specifies whether or not the widget allows an end-user to enter a custom value. */ + fieldEditEnabled?: boolean; + editEnabled?: boolean; + /** Specifies the way an end-user applies the selected value. */ + applyValueMode?: string; + /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ + focusStateEnabled?: boolean; + } + /** A drop-down editor widget. */ + export class dxDropDownEditor extends dxTextBox { + constructor(element: JQuery, options?: dxDropDownEditorOptions); + constructor(element: Element, options?: dxDropDownEditorOptions); + /** Closes the drop-down editor. */ + close(): void; + /** Opens the drop-down editor. */ + open(): void; + /** Resets the widget's value to null. */ + reset(): void; + } + export interface dxDateBoxOptions extends dxTextEditorOptions { + /** A format used to display date/time information. */ + format?: string; + /** A Globalize format string specifying the date display format. */ + formatString?: string; + /** The last date that can be selected within the widget. */ + max?: Date; + /** The minimum date that can be selected within the widget. */ + min?: Date; + /** The text displayed by the widget when the widget value is not yet specified. This text is also used as a title of the date picker. */ + placeholder?: string; + /** Specifies whether or not a user can pick out a date using the drop-down calendar. */ + useCalendar?: boolean; + /** A Date object specifying the date and time currently selected using the date box. */ + value?: Date; + /** Specifies whether or not the widget uses the native HTML input element. */ + useNative?: boolean; + /** Specifies the interval between neighboring values in the popup list in minutes. */ + interval?: number; + } + /** A date box widget. */ + export class dxDateBox extends dxDropDownEditor { + constructor(element: JQuery, options?: dxDateBoxOptions); + constructor(element: Element, options?: dxDateBoxOptions); + } + export interface dxCheckBoxOptions extends EditorOptions { + checked?: boolean; + /** Specifies the widget state. */ + value?: boolean; + /** Specifies the text displayed by the check box. */ + text?: string; + } + /** A check box widget. */ + export class dxCheckBox extends Editor { + constructor(element: JQuery, options?: dxCheckBoxOptions); + constructor(element: Element, options?: dxCheckBoxOptions); + } + export interface dxCalendarOptions extends EditorOptions { + /** Specifies a date displayed on the current calendar page. */ + currentDate?: Date; + /** Specifies the first day of a week. */ + firstDayOfWeek?: number; + /** The latest date the widget allows to select. */ + max?: Date; + /** The earliest date the widget allows to select. */ + min?: Date; + } + /** A calendar widget. */ + export class dxCalendar extends Editor { + constructor(element: JQuery, options?: dxCalendarOptions); + constructor(element: Element, options?: dxCalendarOptions); + } + export interface dxButtonOptions extends WidgetOptions { + /** A handler for the click event. */ + onClick?: any; + clickAction?: any; + /** The name of an icon to be displayed on the button. */ + icon?: string; + /** A URL pointing to the image to be displayed on the button. */ + iconSrc?: string; + /** The text displayed on the button. */ + text?: string; + /** Specifies the button type. */ + type?: string; + /** Specifies the name of the validation group to be accessed in the click event handler. */ + validationGroup?: string; + } + /** A button widget. */ + export class dxButton extends Widget { + constructor(element: JQuery, options?: dxButtonOptions); + constructor(element: Element, options?: dxButtonOptions); + } + export interface dxBoxOptions extends CollectionWidget { + /** Specifies how widget items are aligned along the main direction. */ + align?: string; + /** Specifies the direction of item positioning in the widget. */ + direction?: string; + /** Specifies how widget items are aligned cross-wise. */ + crossAlign?: string; + } + /** A container widget used to arrange inner elements. */ + export class dxBox extends CollectionWidget { + constructor(element: JQuery, options?: dxBoxOptions); + constructor(element: Element, options?: dxBoxOptions); + } + export interface dxResponsiveBoxOptions extends CollectionWidgetOptions { + /** Specifies the collection of rows for the grid used to position layout elements. */ + rows?: Array; + /** Specifies the collection of columns for the grid used to position layout elements. */ + cols?: Array; + /** Specifies the function returning the screen factor depending on the screen width. */ + screenByWidth?: (width: number) => string; + /** Specifies the screen factor with which all elements are located in a single column. */ + singleColumnScreen?: string; + } + /** A widget used to build an adaptive markup that is dependent on screen resolution. */ + export class dxResponsiveBox extends CollectionWidget { + constructor(element: JQuery, options?: dxBoxOptions); + constructor(element: Element, options?: dxBoxOptions); + } + export interface dxAutocompleteOptions extends dxDropDownListOptions { + /** Specifies the current value displayed by the widget. */ + value?: string; + /** The minimum number of characters that must be entered into the text box to begin a search. */ + minSearchLength?: number; + /** Specifies the maximum count of items displayed by the widget. */ + maxItemCount?: number; + /** Specifies the currently selected item. */ + selectedItem?: Object; + } + /** A textbox widget that supports autocompletion. */ + export class dxAutocomplete extends dxDropDownList { + constructor(element: JQuery, options?: dxAutocompleteOptions); + constructor(element: Element, options?: dxAutocompleteOptions); + /** Opens the drop-down editor. */ + open(): void; + /** Closes the drop-down editor. */ + close(): void; + } + export interface dxAccordionOptions extends CollectionWidgetOptions { + /** A number specifying the time in milliseconds spent on the animation of the expanding or collapsing of a panel. */ + animationDuration?: number; + /** Specifies the height of the widget. */ + height?: any; + /** Specifies whether all items can be collapsed or whether at least one item must always be expanded. */ + collapsible?: boolean; + /** Specifies whether the widget can expand several items or only a single item at once. */ + multiple?: boolean; + /** The template to be used for rendering dxAccordion items. */ + itemTemplate?: any; + /** A handler for the itemTitleClick event. */ + onItemTitleClick?: any; + /** A handler for the itemTitleHold event. */ + onItemTitleHold?: Function; + /** The template to be used for rendering an item title. */ + itemTitleTemplate?: any; + /** The index number of the currently selected item. */ + selectedIndex?: number; + } + /** A widget that displays data source items on collapsible panels. */ + export class dxAccordion extends CollectionWidget { + constructor(element: JQuery, options?: dxAccordionOptions); + constructor(element: Element, options?: dxAccordionOptions); + /** Collapses the specified item. */ + collapseItem(index: number): JQueryPromise; + /** Expands the specified item. */ + expandItem(index: number): JQueryPromise; + } + export interface dxFileUploaderOptions extends EditorOptions { + /** A read-only option that holds a File instance representing the selected file. */ + value?: File; + /** Holds the File instances representing files selected in the widget. */ + values?: Array; + /** Specifies the text displayed on the button opening the file selection dialog. */ + buttonText?: string; + /** Specifies the text displayed on the area to which an end-user can drop a file. */ + labelText?: string; + /** Specifies the value passed to the name attribute of the underlying input element. */ + name?: string; + /** Specifies whether the widget enables an end-user to select a single file or multiple files. */ + multiple?: boolean; + /** Specifies a file type or several types accepted by the widget. */ + accept?: string; + } + /** A widget used to select and upload a file or multiple files. */ + export class dxFileUploader extends Editor { + constructor(element: JQuery, options?: dxFileUploaderOptions); + constructor(element: Element, options?: dxFileUploaderOptions); + } + export interface dxTrackBarOptions extends EditorOptions { + /** The minimum value the widget can accept. */ + min?: number; + /** The maximum value the widget can accept. */ + max?: number; + /** The current widget value. */ + value?: number; + } + /** A base class for track bar widgets. */ + export class dxTrackBar extends Editor { + constructor(element: JQuery, options?: dxTrackBarOptions); + constructor(element: Element, options?: dxTrackBarOptions); + } + export interface dxProgressBarOptions extends dxTrackBarOptions { + /** Specifies a format for the progress status. */ + statusFormat?: any; + /** Specifies whether or not the widget displays a progress status. */ + showStatus?: boolean; + /** A handler for the complete event. */ + onComplete?: Function; + } + /** A widget used to indicate progress. */ + export class dxProgressBar extends dxTrackBar { + constructor(element: JQuery, options?: dxProgressBarOptions); + constructor(element: Element, options?: dxProgressBarOptions); + } + export interface dxSliderOptions extends dxTrackBarOptions { + /** The slider step size. */ + step?: number; + /** The current slider value. */ + value?: number; + /** Specifies whether or not to highlight a range selected within the widget. */ + showRange?: boolean; + /** Specifies options for the slider tooltip. */ + tooltip?: { + /** Specifies whether or not the tooltip is enabled. */ + enabled?: boolean; + /** Specifies format for the tooltip. */ + format?: any; + /** Specifies whether the tooltip is located over or under the slider. */ + position?: string; + /** Specifies whether the widget always shows a tooltip or only when a pointer is over the slider. */ + showMode?: string; + }; + /** Specifies options for labels displayed at the min and max values. */ + label?: { + /** Specifies whether or not slider labels are visible. */ + visible?: boolean; + /** Specifies whether labels are located over or under the scale. */ + position?: string; + /** Specifies a format for labels. */ + format?: any; + }; + } + /** A widget that allows a user to select a numeric value within a given range. */ + export class dxSlider extends dxTrackBar { + constructor(element: JQuery, options?: dxSliderOptions); + constructor(element: Element, options?: dxSliderOptions); + } + export interface dxRangeSliderOptions extends dxSliderOptions { + /** The left edge of the interval currently selected using the range slider. */ + start?: number; + /** The right edge of the interval currently selected using the range slider. */ + end?: number; + } + /** A widget that enables a user to select a range of numeric values. */ + export class dxRangeSlider extends dxSlider { + constructor(element: JQuery, options?: dxRangeSliderOptions); + constructor(element: Element, options?: dxRangeSliderOptions); + } + export interface dxTileViewOptions extends CollectionWidgetOptions { + /** Specifies the height of the base tile view item. */ + baseItemHeight?: number; + /** Specifies the width of the base tile view item. */ + baseItemWidth?: number; + /** Specifies the height of the widget. */ + height?: any; + /** Specifies the distance in pixels between adjacent tiles. */ + itemMargin?: number; + listHeight?: any; + /** A Boolean value specifying whether or not to display a scrollbar. */ + showScrollbar?: boolean; + } + /** A widget displaying several blocks of data as tiles. */ + export class dxTileView extends CollectionWidget { + constructor(element: JQuery, options?: dxTileViewOptions); + constructor(element: Element, options?: dxTileViewOptions); + /** Returns the current scroll position of the widget content. */ + scrollPosition(): number; + } + export interface dxSwitchOptions extends EditorOptions { + /** Text displayed when the widget is in a disabled state. */ + offText?: string; + /** Text displayed when the widget is in an enabled state. */ + onText?: string; + /** A Boolean value specifying whether the current switch state is "On" or "Off". */ + value?: boolean; + } + /** A switch widget. */ + export class dxSwitch extends Editor { + constructor(element: JQuery, options?: dxSwitchOptions); + constructor(element: Element, options?: dxSwitchOptions); + } + export interface dxSlideOutOptions extends CollectionWidgetOptions { + /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ + activeStateEnabled?: boolean; + /** A Boolean value specifying whether or not to display a grouped menu. */ + menuGrouped?: boolean; + menuGroupRender?: any; + /** The name of the template used to display a group header. */ + menuGroupTemplate?: any; + menuItemRender?: any; + /** The template used to render menu items. */ + menuItemTemplate?: any; + /** Specifies whether or not the slide-out menu is displayed. */ + menuVisible?: boolean; + /** Indicates whether the menu can be shown/hidden by swiping the widget's main panel. */ + swipeEnabled?: boolean; + /** A template to be used for rendering widget content. */ + contentTemplate?: any; + } + /** The widget that allows you to slide-out the current view to reveal an item list. */ + export class dxSlideOut extends CollectionWidget { + constructor(element: JQuery, options?: dxSlideOutOptions); + constructor(element: Element, options?: dxSlideOutOptions); + /** Hides the widget's slide-out menu. */ + hideMenu(): JQueryPromise; + /** Displays the widget's slide-out menu. */ + showMenu(): JQueryPromise; + /** Toggles the visibility of the widget's slide-out menu. */ + toggleMenuVisibility(showing: boolean): JQueryPromise; + } + export interface dxPivotOptions extends CollectionWidgetOptions { + /** The index of the currently active pivot item. */ + selectedIndex?: number; + /** A template to be used for rendering widget content. */ + contentTemplate?: any; + } + /** A widget that is similar to a traditional tab control, but optimized for the phone with simplified end-user interaction. */ + export class dxPivot extends CollectionWidget { + constructor(element: JQuery, options?: dxPivotOptions); + constructor(element: Element, options?: dxPivotOptions); + } + export interface dxPanoramaOptions extends CollectionWidgetOptions { + /** An object exposing options for setting a background image for the panorama. */ + backgroundImage?: { + /** Specifies the height of the panorama's background image. */ + height?: number; + /** Specifies the URL of the image that is used as the panorama's background image. */ + url?: string; + /** Specifies the width of the panorama's background image. */ + width?: number; + }; + /** The index of the currently active panorama item. */ + selectedIndex?: number; + /** Specifies the widget content title. */ + title?: string; + } + /** A widget displaying the required content in a long horizontal canvas that extends beyond the frames of the screen. */ + export class dxPanorama extends CollectionWidget { + constructor(element: JQuery, options?: dxDropDownEditorOptions); + constructor(element: Element, options?: dxDropDownEditorOptions); + } + export interface dxDropDownMenuOptions extends WidgetOptions { + /** A handler for the buttonClick event. */ + onButtonClick?: any; + buttonClickAction?: any; + /** The name of the icon to be displayed by the DropDownMenu button. */ + buttonIcon?: string; + /** A URL pointing to the image to be displayed by the DropDownMenu button. */ + buttonIconSrc?: string; + /** The text displayed in the DropDownMenu button. */ + buttonText?: string; + /** A data source used to fetch data to be displayed by the widget. */ + dataSource?: any; + /** A handler for the itemClick event. */ + onItemClick?: any; + itemClickAction?: any; + itemRender?: any; + /** An array of items displayed by the widget. */ + items?: Array; + /** The template to be used for rendering items. */ + itemTemplate?: any; + /** Specifies whether or not to show the drop down menu within a dxPopover widget. */ + usePopover?: boolean; + /** The width of the menu popup in pixels. */ + popupWidth?: any; + /** The height of the menu popup in pixels. */ + popupHeight?: any; + /** Specifies whether or not the drop-down menu is displayed. */ + opened?: boolean; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; + } + /** A drop-down menu widget. */ + export class dxDropDownMenu extends Widget { + constructor(element: JQuery, options?: dxDropDownEditorOptions); + constructor(element: Element, options?: dxDropDownEditorOptions); + /** This section lists the data source fields that are used in a default template for drop-down menu items. */ + /** Opens the drop-down menu. */ + open(): void; + /** Closes the drop-down menu. */ + close(): void; + } + export interface dxActionSheetOptions extends CollectionWidgetOptions { + cancelClickAction?: any; + /** A handler for the cancelClick event. */ + onCancelClick?: any; + /** The text displayed in the button that closes the action sheet. */ + cancelText?: string; + /** Specifies whether or not to display the Cancel button in action sheet. */ + showCancelButton?: boolean; + /** A Boolean value specifying whether or not the title of the action sheet is visible. */ + showTitle?: boolean; + /** Specifies the element the action sheet popover points at. */ + target?: any; + /** The title of the action sheet. */ + title?: string; + /** Specifies whether or not to show the action sheet within a dxPopover widget. */ + usePopover?: boolean; + /** A Boolean value specifying whether or not the dxActionSheet widget is visible. */ + visible?: boolean; + } + /** A widget consisting of a set of choices related to a certain task. */ + export class dxActionSheet extends CollectionWidget { + constructor(element: JQuery, options?: dxActionSheetOptions); + constructor(element: Element, options?: dxActionSheetOptions); + /** Hides the widget. */ + hide(): JQueryPromise; + /** Shows the widget. */ + show(): JQueryPromise; + /** Shows or hides the widget depending on the Boolean value passed as the parameter. */ + toggle(showing: boolean): JQueryPromise; + } + export interface dxColorBoxOptions extends dxDropDownEditorOptions { + /** Specifies the text displayed on the button that applies changes and closes the drop-down editor. */ + applyButtonText?: string; + applyValueMode?: string; + /** Specifies the text displayed on the button that cancels changes and closes the drop-down editor. */ + cancelButtonText?: string; + /** Specifies whether or not the widget value includes the alpha channel component. */ + editAlphaChannel?: boolean; + } + /** A widget used to specify a color value. */ + export class dxColorBox extends dxDropDownEditor { + constructor(element: JQuery, options?: dxColorBoxOptions); + constructor(element: Element, options?: dxColorBoxOptions); + } + export interface dxColorPickerOptions extends dxColorBoxOptions { } + /** + * A widget used to specify a color value. + * @deprecated Use the dxColorBox widget instead + */ + export class dxColorPicker extends dxColorBox { + constructor(element: JQuery, options?: dxColorPickerOptions); + constructor(element: Element, options?: dxColorPickerOptions); + } + export interface dxTreeViewOptions extends CollectionWidgetOptions { + /** Specifies whether a nested or plain array is used as a data source. */ + dataStructure?: string; + /** Specifies whether or not a user can expand all tree view items by the "*" hot key. */ + expandAllEnabled?: boolean; + /** + * An array of currently expanded item objects. + * @deprecated Use item.expanded field instead + */ + expandedItems?: Array; + /** Specifies whether or not a check box is displayed at each tree view item. */ + showCheckBoxes?: boolean; + /** Specifies whether or not to select nodes recursively. */ + selectNodesRecursive?: boolean; + /** Specifies whether the "Select All" check box is displayed over the tree view. */ + selectAllEnabled?: boolean; + /** Specifies the text displayed at the "Select All" check box. */ + selectAllText?: string; + /** Specifies the name of the data source item field used as a key. */ + keyExpr?: any; + /** Specifies the name of the data source item field whose value is displayed by the widget. */ + displayExpr?: any; + /** Specifies the name of the data source item field whose value defines whether or not the corresponding node is selected. */ + selectedExpr?: any; + /** Specifies the name of the data source item field whose value defines whether or not the corresponding node is expanded. */ + expandedExpr?: any; + /** Specifies the name of the data source item field that contains an array of nested items. */ + itemsExpr?: any; + /** Specifies the name of the data source item field that holds the key of the parent item. */ + parentIdExpr?: any; + disabledExpr?: any; + /** A string value specifying available scrolling directions. */ + scrollDirection?: string; + /** A handler for the itemSelected event. */ + onItemSelected?: Function; + /** A handler for the itemExpanded event. */ + onItemExpanded?: Function; + /** A handler for the itemCollapsed event. */ + onItemCollapsed?: Function; + } + /** A widget displaying specified data items as a tree. */ + export class dxTreeView extends CollectionWidget { + constructor(element: JQuery, options?: dxTreeViewOptions); + constructor(element: Element, options?: dxTreeViewOptions); + /** Updates the tree view scrollbars according to the current size of the widget content. */ + updateDimensions(): JQueryPromise; + /** Selects the specified item. */ + selectItem(itemElement: any): void; + /** Unselects the specified item. */ + unselectItem(itemElement: any): void; + /** Expands the specified item. */ + expandItem(itemElement: any): void; + /** Collapses the specified item. */ + collapseItem(itemElement: any): void; + /** Returns all nodes of the tree view. */ + getNodes(): Array; + /** Selects all widget items. */ + selectAll(): void; + /** Unselects all widget items. */ + unselectAll(): void; + } + export interface dxMenuBaseOptions extends CollectionWidgetOptions { + /** An object that defines the animation options of the widget. */ + animation?: fx.AnimationOptions; + /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ + activeStateEnabled?: boolean; + /** Specifies the name of the CSS class associated with the menu. */ + cssClass?: string; + /** Holds an array of menu items. */ + items?: Array; + /** Specifies whether or not an item becomes selected if an end-user clicks it. */ + selectionByClick?: boolean; + /** Specifies the selection mode supported by the menu. */ + selectionMode?: string; + /** Specifies the user interaction by which submenus are shown. */ + showSubmenuMode?: string; + /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ + hoverStateEnabled?: boolean; + } + export class dxMenuBase extends CollectionWidget { + constructor(element: JQuery, options?: dxMenuBaseOptions); + constructor(element: Element, options?: dxMenuBaseOptions); + /** Selects the specified item. */ + selectItem(itemElement: any): void; + /** Unselects the specified item. */ + unselectItem(itemElement: any): void; + } + export interface dxMenuOptions extends dxMenuBaseOptions { + firstSubMenuDirection?: string; + /** Specifies whether the menu has horizontal or vertical orientation. */ + orientation?: string; + /** Specifies by which user interaction the first-level submenu is shown. */ + showFirstSubmenuMode?: string; + showPopupMode?: string; + /** Specifies the direction at which the submenus are displayed. */ + submenuDirection?: string; + /** A handler for the submenuHidden event. */ + onSubmenuHidden?: Function; + submenuHiddenAction?: Function; + /** A handler for the submenuHiding event. */ + onSubmenuHiding?: Function; + submenuHidingAction?: Function; + /** A handler for the submenuShowing event. */ + onSubmenuShowing?: Function; + submenuShowingAction?: Function; + /** A handler for the submenuShown event. */ + onSubmenuShown?: Function; + submenuShownAction?: Function; + } + /** A menu widget. */ + export class dxMenu extends dxMenuBase { + constructor(element: JQuery, options?: dxMenuOptions); + constructor(element: Element, options?: dxMenuOptions); + } + export interface dxContextMenuOptions extends dxMenuBaseOptions { + direction?: string; + hiddenAction?: Function; + hidingAction?: Function; + /** Specifies whether the context menu can be called only from code or by user interaction as well. */ + invokeOnlyFromCode?: boolean; + /** A handler for the hidden event. */ + onHidden?: Function; + /** A handler for the hiding event. */ + onHiding?: Function; + /** A handler for the positioning event. */ + onPositioning?: Function; + /** A handler for the showing event. */ + onShowing?: Function; + /** A handler for the shown event. */ + onShown?: Function; + /** An object defining widget positioning options. */ + position?: PositionOptions; + positioningAction?: Function; + showingAction?: Function; + shownAction?: Function; + /** Specifies the direction at which submenus are displayed. */ + submenuDirection?: string; + /** The target element associated with a popover. */ + target?: any; + /** A Boolean value specifying whether or not the widget is visible. */ + visible?: boolean; + } + /** A context menu widget. */ + export class dxContextMenu extends dxMenuBase { + constructor(element: JQuery, options?: dxContextMenuOptions); + constructor(element: Element, options?: dxContextMenuOptions); + /** Toggles the visibility of the widget. */ + toggle(showing: boolean): JQueryPromise; + /** Shows the widget. */ + show(): JQueryPromise; + /** Hides the widget. */ + hide(): JQueryPromise; + } + export interface dxRemoteOperations { + /** Specifies whether or not filtering must be performed on the server side. */ + filtering?: boolean; + /** Specifies whether or not paging must be performed on the server side. */ + paging?: boolean; + /** Specifies whether or not sorting must be performed on the server side. */ + sorting?: boolean; + } + export interface dxDataGridColumn { + /** Specifies the content alignment within column cells. */ + alignment?: string; + /** Specifies whether the values in a column can be edited at runtime. Setting this option makes sense only when editing is enabled for a grid. */ + allowEditing?: boolean; + /** Specifies whether or not a column can be used for filtering grid records. Setting this option makes sense only when the filter row or search panel is visible. */ + allowFiltering?: boolean; + /** Specifies whether a column can be used for grouping grid records at runtime. Setting this option makes sense only when the group panel is visible. */ + allowGrouping?: boolean; + /** Specifies whether or not a column can be hidden by a user. Setting this option makes sense only when the column chooser is visible. */ + allowHiding?: boolean; + /** Specifies whether or not a particular column can be used in column reordering. Setting this option makes sense only when the allowColumnReordering option is set to true. */ + allowReordering?: boolean; + /** Specifies whether or not a particular column can be resized by a user. Setting this option makes sense only when the allowColumnResizing option is true. */ + allowResizing?: boolean; + /** Specifies whether grid records can be sorted by a specific column at runtime. Setting this option makes sense only when the sorting mode differs from none. */ + allowSorting?: boolean; + /** Specifies whether groups appear expanded or not when records are grouped by a specific column. Setting this option makes sense only when grouping is allowed for this column. */ + autoExpandGroup?: boolean; + /** Specifies a callback function that returns a value to be displayed in a column cell. */ + calculateCellValue?: (rowData: Object) => string; + /** Specifies a callback function that defines filters for customary calculated grid cells. */ + calculateFilterExpression?: (filterValue: any, selectedFilterOperation: string) => Array; + /** Specifies a caption for a column. */ + caption?: string; + /** Specifies a custom template for grid column cells. */ + cellTemplate?: any; + /** Specifies a CSS class to be applied to a column. */ + cssClass?: string; + /** Specifies a callback function that determines grouping values. */ + calculateGroupValue?: (rowData: Object) => string; + /** Specifies a callback function that returns the text to be displayed in the cells of a column. */ + customizeText?: (cellInfo: { value: any; valueText: string }) => string; + /** Specifies the field of a data source that provides data for a column. */ + dataField?: string; + /** Specifies the required type of column values. */ + dataType?: string; + /** Specifies a custom template for the cell of a grid column when it is in an editing state. */ + editCellTemplate?: any; + /** Specifies whether HTML tags are displayed as plain text or applied to the values of the column. */ + encodeHtml?: boolean; + /** In a boolean column, replaces all false items with a specified text. */ + falseText?: string; + /** Specifies the set of available filter operations. */ + filterOperations?: Array; + /** Specifies a filter value for a column. */ + filterValue?: any; + /** Specifies a format for the values displayed in a column. */ + format?: string; + /** Specifies a custom template for the group cell of a grid column. */ + groupCellTemplate?: any; + /** Specifies the index of a column when grid records are grouped by the values of this column. */ + groupIndex?: number; + /** Specifies a custom template for the header of a grid column. */ + headerCellTemplate?: any; + /** Specifies options of a lookup column. */ + lookup?: { + /** Specifies whether or not a user can nullify values of a lookup column. */ + allowClearing?: boolean; + /** +Specifies the data source providing data for a lookup column. + */ + dataSource?: any; + /** Specifies the expression defining the data source field whose values must be displayed. */ + displayExpr?: any; + /** Specifies the expression defining the data source field whose values must be replaced. */ + valueExpr?: string; + }; + /** Specifies a precision for formatted values displayed in a column. */ + precision?: number; + /** Specifies a filter operation applied to a column. */ + selectedFilterOperation?: string; + /** Specifies whether or not the column displays its values by using editors. */ + showEditorAlways?: boolean; + /** Specifies whether or not to display the column when grid records are grouped by it. */ + showWhenGrouped?: boolean; + /** Specifies the index of a column when grid records are sorted by the values of this column. */ + sortIndex?: number; + /** Specifies the initial sort order of column values. */ + sortOrder?: string; + /** In a boolean column, replaces all true items with a specified text. */ + trueText?: string; + /** Specifies whether a column is visible or not. */ + visible?: boolean; + /** Specifies the sequence number of the column in the grid. */ + visibleIndex?: number; + /** Specifies a column width in pixels or percentages. */ + width?: any; + /** Specifies an array of validation rules to be checked when updating column cell values. */ + validationRules?: Array; + /** Specifies whether or not to display the header of a hidden column in the column chooser. */ + showInColumnChooser?: boolean; + /** Specifies the identifier of the column. */ + name?: string; + } + export interface dxDataGridOptions extends WidgetOptions { + /** Specifies whether the outer borders of the grid are visible or not. */ + showBorders?: boolean; + /** Indicates whether to show the error row for the grid. */ + errorRowEnabled?: boolean; + /** A handler for the rowValidating event. */ + onRowValidating?: (e: Object) => void; + initNewRow?: (e: { data: Object }) => void; + /** A handler for the initNewRow event. */ + onInitNewRow?: (e: { data: Object }) => void; + rowInserted?: (e: { data: Object; key: any }) => void; + /** A handler for the rowInserted event. */ + onRowInserted?: (e: { data: Object; key: any }) => void; + rowInserting?: (e: { data: Object; cancel: boolean }) => void; + /** A handler for the rowInserting event. */ + onRowInserting?: (e: { data: Object; cancel: boolean }) => void; + rowRemoved?: (e: { data: Object; key: any }) => void; + /** A handler for the rowRemoved event. */ + onRowRemoved?: (e: { data: Object; key: any }) => void; + rowRemoving?: (e: { data: Object; key: any; cancel: boolean }) => void; + /** A handler for the rowRemoving event. */ + onRowRemoving?: (e: { data: Object; key: any; cancel: boolean }) => void; + rowUpdated?: (e: { data: Object; key: any }) => void; + /** A handler for the rowUpdated event. */ + onRowUpdated?: (e: { data: Object; key: any }) => void; + rowUpdating?: (e: { oldData: Object; newData: Object; key: any; cancel: boolean }) => void; + /** A handler for the rowUpdating event. */ + onRowUpdating?: (e: { oldData: Object; newData: Object; key: any; cancel: boolean }) => void; + /** Enables a hint that appears when a user hovers the mouse pointer over a cell with truncated content. */ + cellHintEnabled?: boolean; + /** Specifies whether or not grid columns can be reordered by a user. */ + allowColumnReordering?: boolean; + /** Specifies whether or not grid columns can be resized by a user. */ + allowColumnResizing?: boolean; + cellClick?: any; + /** A handler for the cellClick event. */ + onCellClick?: any; + cellHoverChanged?: (e: Object) => void; + /** A handler for the cellHoverChanged event. */ + onCellHoverChanged?: (e: Object) => void; + cellPrepared?: (e: Object) => void; + /** A handler for the cellPrepared event. */ + onCellPrepared?: (e: Object) => void; + /** Specifies whether or not the width of grid columns depends on column content. */ + columnAutoWidth?: boolean; + /** Specifies the options of a column chooser. */ + columnChooser?: { + /** Specifies text displayed by the column chooser panel when it does not contain any columns. */ + emptyPanelText?: string; + /** Specifies whether a user can invoke the column chooser or not. */ + enabled?: boolean; + /** Specifies the height of the column chooser panel. */ + height?: number; + /** Specifies text displayed in the title of the column chooser panel. */ + title?: string; + /** Specifies the width of the column chooser panel. */ + width?: number; + }; + /** +An array of grid columns. + */ + columns?: Array; + onContentReady?: Function; + contentReadyAction?: Function; + /** Specifies a function that customizes grid columns after they are created. */ + customizeColumns?: (columns: Array) => void; + dataErrorOccurred?: (errorObject: Error) => void; + /** Specifies a data source for the grid. */ + dataSource?: any; + editingStart?: (e: { + data: Object; + key: any; + cancel: boolean; + column: dxDataGridColumn + }) => void; + /** A handler for the editingStart event. */ + onEditingStart?: (e: { + data: Object; + key: any; + cancel: boolean; + column: dxDataGridColumn + }) => void; + editorPrepared?: (e: Object) => void; + /** A handler for the editorPrepared event. */ + onEditorPrepared?: (e: Object) => void; + editorPreparing?: (e: Object) => void; + /** A handler for the editorPreparing event. */ + onEditorPreparing?: (e: Object) => void; + /** Contains options that specify how grid content can be changed. */ + editing?: { + /** Specifies whether or not grid records can be edited at runtime. */ + editEnabled?: boolean; + /** Specifies how grid values can be edited manually. */ + editMode?: string; + /** Specifies whether or not new records can be inserted into a grid. */ + insertEnabled?: boolean; + /** Specifies whether or not records can be deleted from a grid. */ + removeEnabled?: boolean; + /** Contains options that specify texts for editing-related grid controls. */ + texts?: { + /** Specifies text for a hint that appears when a user hovers the mouse pointer over the "Save" button. Setting this option makes sense only when the editMode option is set to batch. */ + saveAllChanges?: string; + /** Specifies text for a cancel button displayed when a row is in the editing state. Setting this option makes sense only when the editEnabled option is set to true. */ + cancelRowChanges?: string; + /** Specifies text for a hint that appears when a user hovers the mouse pointer over the "Revert" button. Setting this option makes sense only when the editMode option is set to batch. */ + cancelAllChanges?: string; + /** Specifies a message to be displayed by a confirmation window. Setting this option makes sense only when the edit mode is "row". */ + confirmDeleteMessage?: string; + /** Specifies text to be displayed in the title of a confirmation window. Setting this option makes sense only when the edit mode is "row". */ + confirmDeleteTitle?: string; + /** Specifies text for a button that deletes a row from a grid. Setting this option makes sense only when the removeEnabled option is set to true. */ + deleteRow?: string; + /** Specifies text for a hint that appears when a user hovers the mouse pointer over the "Add" button. Setting this option makes sense only when the insertEnabled option is true. */ + addRow?: string; + /** Specifies text for a button that turns a row into the editing state. Setting this option makes sense only when the editEnabled option is set to true. */ + editRow?: string; + /** + * Specifies text for a button that recovers a deleted row. Setting this option makes sense only if the grid uses the batch edit mode and the removeEnabled option is set to true. + * @deprecated Use the "undeleteRow" option instead. + */ + recoverRow?: string; + /** Specifies text for a save button displayed when a row is in the editing state. Setting this option makes sense only when the editEnabled option is set to true. */ + saveRowChanges?: string; + /** Specifies text for a button that recovers a deleted row. Setting this option makes sense only if the grid uses the batch edit mode and the removeEnabled option is set to true. */ + undeleteRow?: string; + }; + }; + /** Specifies filter row options. */ + filterRow?: { + /** Specifies when to apply a filter. */ + applyFilter?: string; + /** Specifies text for the hint that pops up when a user hovers the mouse pointer over the "Apply Filter" button. */ + applyFilterText?: string; + /** Specifies descriptions for filter operations. */ + operationDescriptions?: { + "=": string; + "<>": string; + "<": string; + "<=": string; + ">": string; + ">=": string; + "startswith": string; + "contains": string; + "notcontains": string; + "endswith": string; + }; + /** Specifies text for the reset operation in a filter list. */ + resetOperationText?: string; + /** Specifies text for the operation of clearing the applied filter when a select box is used. */ + showAllText?: string; + /** Specifies whether or not an icon that allows the user to choose a filter operation is visible. */ + showOperationChooser?: boolean; + /** Specifies whether the filter row is visible or not. */ + visible?: boolean; + }; + /** Specifies the behavior of grouped grid records. */ + grouping?: { + /** Specifies whether the user can collapse grouped records in a grid or not. */ + allowCollapsing?: boolean; + /** Specifies whether groups appear expanded or not. */ + autoExpandAll?: boolean; + /** Specifies the message displayed in a group row when the corresponding group is continued from the previous page. */ + groupContinuedMessage?: string; + /** +Specifies the message displayed in a group row when the corresponding group continues on the next page. + */ + groupContinuesMessage?: string; + }; + /** Specifies options that configure the group panel. */ + groupPanel?: { + /** Specifies whether columns can be dragged onto or from the group panel. */ + allowColumnDragging?: boolean; + /** Specifies text displayed by the group panel when it does not contain any columns. */ + emptyPanelText?: string; + /** Specifies whether the group panel is visible or not. */ + visible?: boolean; + }; + /** Specifies options configuring the load panel. */ + loadPanel?: { + /** Specifies whether to show the load panel or not. */ + enabled?: boolean; + /** Specifies the height of the load panel in pixels. */ + height?: number; + /** Specifies a URL pointing to an image to be used as a loading indicator. */ + indicatorSrc?: string; + /** Specifies whether or not a loading indicator must be displayed on the load panel. */ + showIndicator?: boolean; + /** Specifies whether or not the pane of the load panel must be displayed. */ + showPane?: boolean; + /** Specifies text displayed by the load panel. */ + text?: string; + /** Specifies the width of the load panel in pixels. */ + width?: number; + }; + /** Specifies text displayed when a grid does not contain any records. */ + noDataText?: string; + /** Specifies the options of a grid pager. */ + pager?: { + /** Specifies the page sizes that can be selected at runtime. */ + allowedPageSizes?: any; + /** Specifies whether to show the page size selector or not. */ + showPageSizeSelector?: boolean; + /** Specifies whether to show the pager or not. */ + visible?: any; + /** Specifies the text accompanying the page navigator. */ + infoText?: string; + /** Specifies whether or not to display the text accompanying the page navigator. This text is specified by the infoText option. */ + showInfo?: boolean; + /** Specifies whether or not to display buttons that switch the grid to the previous or next page. */ + showNavigationButtons?: boolean; + }; + /** Specifies paging options. */ + paging?: { + /** Specifies whether dxDataGrid loads data page by page or all at once. */ + enabled?: boolean; + /** Specifies the grid page that should be displayed by default. */ + pageIndex?: number; + /** Specifies the size of grid pages. */ + pageSize?: number; + }; + /** Specifies whether or not grid rows must be shaded in a different way. */ + rowAlternationEnabled?: boolean; + rowClick?: any; + /** A handler for the rowClick event. */ + onRowClick?: any; + rowPrepared?: (e: Object) => void; + /** A handler for the rowPrepared event. */ + onRowPrepared?: (e: Object) => void; + /** Specifies a custom template for grid rows. */ + rowTemplate?: any; + /** A configuration object specifying scrolling options. */ + scrolling?: { + /** Specifies the scrolling mode. */ + mode?: string; + /** Specifies whether or not a grid must preload pages adjacent to the current page when using virtual scrolling. */ + preloadEnabled?: boolean; + }; + /** Specifies options of the search panel. */ + searchPanel?: { + /** Specifies whether or not search strings in the located grid records should be highlighted. */ + highlightSearchText?: boolean; + /** Specifies text displayed by the search panel when no search string was typed. */ + placeholder?: string; + /** Specifies whether the search panel is visible or not. */ + visible?: boolean; + /** Specifies the width of the search panel in pixels. */ + width?: number; + /** Sets a search string for the search panel. */ + text?: string; + }; + /** Specifies the operations that must be performed on the server side. */ + remoteOperations?: any; + /** Allows you to sort groups according to the values of group summary items. */ + sortByGroupSummaryInfo?: Array<{ + /** Specifies the group summary item whose values must be used to sort groups. */ + summaryItem?: string; + /** Specifies the identifier of the column that must be used in grouping so that sorting by group summary item values be applied. */ + groupColumn?: string; + /** Specifies the sort order of group summary item values. */ + sortOrder?: string; + }>; + /** Allows you to build a master-detail interface in the grid. */ + masterDetail?: { + /** Enables an end-user to expand/collapse detail sections. */ + enabled?: boolean; + /** Specifies whether detail sections appear expanded or collapsed. */ + autoExpandAll?: boolean; + /** Specifies the template for detail sections. */ + template?: any; + }; + /** Specifies the keys of the records that must appear selected initially. */ + selectedRowKeys?: Array; + /** Specifies options of runtime selection. */ + selection?: { + /** Specifies whether the user can select all grid records at once. */ + allowSelectAll?: boolean; + /** Specifies the selection mode. */ + mode?: string; + }; + selectionChanged?: (e: { + currentSelectedRowKeys: Array; + currentDeselectedRowKeys: Array; + selectedRowKeys: Array; + selectedRowsData: Array; + }) => void; + /** A handler for the dataErrorOccured event. */ + onDataErrorOccurred?: (e: { error: Error }) => void; + /** A handler for the selectionChanged event. */ + onSelectionChanged?: (e: { + currentSelectedRowKeys: Array; + currentDeselectedRowKeys: Array; + selectedRowKeys: Array; + selectedRowsData: Array; + }) => void; + /** Specifies whether column headers are visible or not. */ + showColumnHeaders?: boolean; + /** Specifies whether or not vertical lines separating one grid column from another are visible. */ + showColumnLines?: boolean; + /** Specifies whether or not horizontal lines separating one grid row from another are visible. */ + showRowLines?: boolean; + /** Specifies options of runtime sorting. */ + sorting?: { + /** Specifies text for the context menu item that sets an ascending sort order in a column. */ + ascendingText?: string; + /** Specifies text for the context menu item that resets sorting settings for a column. */ + clearText?: string; + /** Specifies text for the context menu item that sets a descending sort order in a column. */ + descendingText?: string; + /** Specifies the runtime sorting mode. */ + mode?: string; + }; + /** Specifies options of state storing. */ + stateStoring?: { + /** Specifies a callback function that performs specific actions on state loading. */ + customLoad?: () => JQueryPromise; + /** Specifies a callback function that performs specific actions on state saving. */ + customSave?: (gridState: Object) => void; + /** Specifies whether or not a grid saves its state. */ + enabled?: boolean; + /** Specifies the delay between the last change of a grid state and the operation of saving this state in milliseconds. */ + savingTimeout?: number; + /** Specifies a unique key to be used for storing the grid state. */ + storageKey?: string; + /** Specifies the type of storage to be used for state storing. */ + type?: string; + }; + /** Specifies the options of the grid summary. */ + summary?: { + /** Contains options that specify text patterns for summary items. */ + texts?: { + /** Specifies a pattern for the 'sum' summary items when they are displayed in the parent column. */ + sum?: string; + /** Specifies a pattern for the 'sum' summary items displayed in a group row or in any other column rather than the parent one. */ + sumOtherColumn?: string; + /** Specifies a pattern for the 'min' summary items when they are displayed in the parent column. */ + min?: string; + /** Specifies a pattern for the 'min' summary items displayed in a group row or in any other column rather than the parent one. */ + minOtherColumn?: string; + /** Specifies a pattern for the 'max' summary items when they are displayed in the parent column. */ + max?: string; + /** Specifies a pattern for the 'max' summary items displayed in a group row or in any other column rather than the parent one. */ + maxOtherColumn?: string; + /** Specifies a pattern for the 'avg' summary items when they are displayed in the parent column. */ + avg?: string; + /** Specifies a pattern for the 'avg' summary items displayed in a group row or in any other column rather than the parent one. */ + avgOtherColumn?: string; + /** Specifies a pattern for the 'count' summary items. */ + count?: string; + }; + /** Specifies items of the group summary. */ + groupItems?: Array<{ + /** Specifies the identifier of a summary item. */ + name?: string; + /** Specifies the column that provides data for a group summary item. */ + column?: string; + /** Customizes the text to be displayed in the summary item. */ + customizeText?: (itemInfo: { + value: any; + valueText: string; + }) => string; + /** Specifies a pattern for the summary item text. */ + displayFormat?: string; + /** Specifies a precision for the summary item value of a numeric format. */ + precision?: number; + /** Specifies whether or not a summary item must be displayed in the group footer. */ + showInGroupFooter?: boolean; + /** Specifies the column that must hold the summary item when this item is displayed in the group footer. */ + showInColumn?: string; + /** Specifies how to aggregate data for a summary item. */ + summaryType?: string; + /** Specifies a format for the summary item value. */ + valueFormat?: string; + }>; + /** Specifies items of the total summary. */ + totalItems?: Array<{ + /** Specifies the identifier of a summary item. */ + name?: string; + /** Specifies the alignment of a summary item. */ + alignment?: string; + /** Specifies the column that provides data for a summary item. */ + column?: string; + /** Specifies a CSS class to be applied to a summary item. */ + cssClass?: string; + /** Customizes the text to be displayed in the summary item. */ + customizeText?: (itemInfo: { + value: any; + valueText: string; + }) => string; + /** Specifies a pattern for the summary item text. */ + displayFormat?: string; + /** Specifies a precision for the summary item value of a numeric format. */ + precision?: number; + /** Specifies the column that must hold the summary item. */ + showInColumn?: string; + /** Specifies how to aggregate data for a summary item. */ + summaryType?: string; + /** Specifies a format for the summary item value. */ + valueFormat?: string; + }>; + /** Allows you to use a custom aggregate function to calculate the value of a summary item. */ + calculateCustomSummary?: (options: { + component: dxDataGrid; + name?: string; + value: any; + totalValue: any; + summaryProcess: string + }) => void; + }; + /** Specifies whether text that does not fit into a column should be wrapped. */ + wordWrapEnabled?: boolean; + } + /** A data grid widget. */ + export class dxDataGrid extends Widget { + constructor(element: JQuery, options?: dxDataGridOptions); + constructor(element: Element, options?: dxDataGridOptions); + /** Ungroups grid records. */ + clearGrouping(): void; + /** Clears sorting settings of all grid columns at once. */ + clearSorting(): void; + /** Allows you to obtain a cell by its row index and the data field of its column. */ + getCellElement(rowIndex: number, dataField: string): any; + /** Allows you to obtain a cell by its row index and the visible index of its column. */ + getCellElement(rowIndex: number, visibleColumnIndex: number): any; + /** Returns the current state of the grid. */ + state(): Object; + /** Sets the grid state. */ + state(state: Object): void; + /** Allows you to obtain the row index by a data key. */ + getRowIndexByKey(key: any): number; + /** Allows you to obtain the data key by a row index. */ + getKeyByRowIndex(rowIndex: number): any; + /** Adds a new column to a grid. */ + addColumn(columnOptions: dxDataGridColumn): void; + /** Displays the load panel. */ + beginCustomLoading(messageText: string): void; + /** Discards changes made in a grid. */ + cancelEditData(): void; + /** Clears the filter applied to grid records from code. */ + clearFilter(): void; + /** Deselects all grid records. */ + clearSelection(): void; + /** Draws the cell being edited from the editing state. Use this method when the edit mode is batch. */ + closeEditCell(): void; + /** Collapses groups or master rows in a grid. */ + collapseAll(groupIndex?: number): void; + /** Returns the number of data columns in a grid. */ + columnCount(): number; + /** Returns the value of a specific column option. */ + columnOption(id: number, optionName: string): any; + /** Sets an option of a specific column. */ + columnOption(id: number, optionName: string, optionValue: any): void; + /** Returns the options of a column by an identifier. */ + columnOption(id: any): Object; + /** Sets several options of a column at once. */ + columnOption(id: any, options: Object): void; + /** Sets a specific cell into the editing state. */ + editCell(rowIndex: number, columnIndex: number): void; + /** Sets a specific row into the editing state. */ + editRow(rowIndex: number): void; + /** Hides the load panel. */ + endCustomLoading(): void; + /** Expands groups or master rows in a grid. */ + expandAll(groupIndex: number): void; + /** Allows you to find out whether a specific group or master row is expanded or collapsed. */ + isRowExpanded(key: any): boolean; + /** Allows you to expand a specific group or master row by its key. */ + expandRow(key: any): void; + /** Allows you to collapse a specific group or master row by its key. */ + collapseRow(key: any): void; + /** Applies a filter to grid records. */ + filter(filterExpr: Array): void; + /** Gets the keys of currently selected grid records. */ + getSelectedRowKeys(): Array; + /** Gets the data objects of currently selected grid records. */ + getSelectedRowsData(): Array; + /** Hides the column chooser panel. */ + hideColumnChooser(): void; + /** Adds a new data row to a grid. */ + insertRow(): void; + /** Returns the key corresponding to the passed data object. */ + keyOf(obj: Object): any; + /** Switches a grid to a specified page. */ + pageIndex(newIndex: number): void; + /** Gets the index of the current page. */ + pageIndex(): number; + /** Sets the page size. */ + pageSize(value: number): void; + /** Gets the current page size. */ + pageSize(): number; + /** + * Recovers a row deleted in the batch edit mode. + * @deprecated Use the "undeleteRow" method instead. + */ + recoverRow(rowIndex: number): void; + /** Refreshes grid data. */ + refresh(): void; + /** Removes a specific row from a grid. */ + removeRow(rowIndex: number): void; + /** Saves changes made in a grid. */ + saveEditData(): void; + /** +Searches grid records by a search string. + */ + searchByText(text: string): void; + /** Selects all grid records. */ + selectAll(): void; + deselectAll(): void; + /** Selects specific grid records. */ + selectRows(keys: Array, preserve: boolean): void; + /** Deselects specific grid records. */ + deselectRows(keys: Array): void; + /** Selects grid rows by indexes. */ + selectRowsByIndexes(indexes: Array): void; + /** Allows you to find out whether a row is selected or not. */ + isRowSelected(key: any): boolean; + /** Invokes the column chooser panel. */ + showColumnChooser(): void; + startSelectionWithCheckboxes(): boolean; + /** Returns the number of records currently held by a grid. */ + totalCount(): number; + /** Recovers a row deleted in the batch edit mode. */ + undeleteRow(rowIndex: number): void; + /** Allows you to obtain a data object by its key. */ + byKey(key: any): JQueryPromise; + /** Gets the value of a total summary item. */ + getTotalSummaryValue(summaryItemName: string): any; + } +} +declare module DevExpress.viz.charts { + /** This section describes the fields and methods that can be used in code to manipulate the Series object. */ + export interface BaseSeries { + /** Provides information about the state of the series object. */ + fullState: number; + /** Returns the type of the series. */ + type: string; + /** Unselects all the selected points of the series. The points are displayed in an initial style. */ + clearSelection(): void; + /** + * Gets a point from the series point collection based on the specified argument. + * @deprecated getPointsByArg(pointArg).md + */ + getPointByArg(pointArg: any): Object; + /** Gets points from the series point collection based on the specified argument. */ + getPointsByArg(pointArg: any): Array; + /** Gets a point from the series point collection based on the specified point position. */ + getPointByPos(positionIndex: number): Object; + /** Selects the series. The series is displayed in a 'selected' style until another series is selected or the current series is deselected programmatically. */ + select(): void; + /** Selects the specified point. The point is displayed in a 'selected' style. */ + selectPoint(point: BasePoint): void; + /** Deselects the specified point. The point is displayed in an initial style. */ + deselectPoint(point: BasePoint): void; + /** Returns an array of all points in the series. */ + getAllPoints(): Array; + /** Returns visible series points. */ + getVisiblePoints(): Array; + } + /** This section describes the methods that can be used in code to manipulate the Point object. */ + export interface BasePoint { + /** Provides information about the state of the point object. */ + fullState: number; + /** Returns the point's argument value that was set in the data source. */ + originalArgument: any; + /** Returns the point's value that was set in the data source. */ + originalValue: any; + /** Returns the tag of the point. */ + tag: string; + /** Deselects the point. */ + clearSelection(): void; + /** Gets the color of a particular point. */ + getColor(): string; + /** Hides the tooltip of the point. */ + hideTooltip(): void; + /** Provides information about the hover state of a point. */ + isHovered(): any; + /** Provides information about the selection state of a point. */ + isSelected(): any; + /** Selects the point. The point is displayed in a 'selected' style until another point is selected or the current point is deselected programmatically. */ + select(): void; + /** Shows the tooltip of the point. */ + showTooltip(): void; + /** Allows you to obtain the label of a series point. */ + getLabel(): any; + /** Returns the series object to which the point belongs. */ + series: BaseSeries; + } + /** This section describes the fields and methods that can be used in code to manipulate the Series object. */ + export interface ChartSeries extends BaseSeries { + /** Returns the name of the series pane. */ + pane: string; + /** Returns the name of the value axis of the series. */ + axis: string; + /** Returns the name of the series. */ + name: string; + /** Returns the tag of the series. */ + tag: string; + /** Hides a particular series. */ + hide(): void; + /** Provides information about the hover state of a series. */ + isHovered(): any; + /** Provides information about the selection state of a series. */ + isSelected(): any; + /** Provides information about the visibility state of a series. */ + isVisible(): boolean; + /** Makes a particular series visible. */ + show(): void; + selectPoint(point: ChartPoint): void; + deselectPoint(point: ChartPoint): void; + getAllPoints(): Array; + getVisiblePoints(): Array; + } + /** This section describes the methods that can be used in code to manipulate the Point object. */ + export interface ChartPoint extends BasePoint { + /** Contains the close value of the point. This field is useful for points belonging to a series of the candle stick or stock type only. */ + originalCloseValue: any; + /** Contains the high value of the point. This field is useful for points belonging to a series of the candle stick or stock type only. */ + originalHighValue: any; + /** Contains the low value of the point. This field is useful for points belonging to a series of the candle stick or stock type only. */ + originalLowValue: any; + /** Contains the first value of the point. This field is useful for points belonging to a series of the range area or range bar type only. */ + originalMinValue: any; + /** Contains the open value of the point. This field is useful for points belonging to a series of the candle stick or stock type only. */ + originalOpenValue: any; + /** Contains the size of the bubble as it was set in the data source. This field is useful for points belonging to a series of the bubble type only. */ + size: any; + /** Gets the parameters of the point's minimum bounding rectangle (MBR). */ + getBoundingRect(): { x: number; y: number; width: number; height: number; }; + series: ChartSeries; + } + /** This section describes the methods that can be used in code to manipulate the Label object. */ + export interface Label { + /** Gets the parameters of the label's minimum bounding rectangle (MBR). */ + getBoundingRect(): { x: number; y: number; width: number; height: number; }; + /** Hides the point label. */ + hide(): void; + /** Shows the point label. */ + show(): void; + } + export interface PieSeries extends BaseSeries { + selectPoint(point: PiePoint): void; + deselectPoint(point: PiePoint): void; + getAllPoints(): Array; + getVisiblePoints(): Array; + } + /** This section describes the methods that can be used in code to manipulate the Point object. */ + export interface PiePoint extends BasePoint { + /** Gets the percentage value of the specific point. */ + percent: any; + /** Provides information about the visibility state of a point. */ + isVisible(): boolean; + /** Makes a specific point visible. */ + show(): void; + /** Hides a specific point. */ + hide(): void; + series: PieSeries; + } + /** This section describes the fields and methods that can be used in code to manipulate the Series object. */ + export interface PolarSeries extends BaseSeries { + /** Returns the name of the value axis of the series. */ + axis: string; + /** Returns the name of the series. */ + name: string; + /** Returns the tag of the series. */ + tag: string; + /** Hides a particular series. */ + hide(): void; + /** Provides information about the hover state of a series. */ + isHovered(): any; + /** Provides information about the selection state of a series. */ + isSelected(): any; + /** Provides information about the visibility state of a series. */ + isVisible(): boolean; + /** Makes a particular series visible. */ + show(): void; + selectPoint(point: PolarPoint): void; + deselectPoint(point: PolarPoint): void; + getAllPoints(): Array; + getVisiblePoints(): Array; + } + /** This section describes the methods that can be used in code to manipulate the Point object. */ + export interface PolarPoint extends BasePoint { + series: PolarSeries; + } + export interface Strip { + /** Specifies a color for a strip. */ + color?: string; + /** An object that defines the label configuration options of a strip. */ + label?: { + /** Specifies the text displayed in a strip. */ + text?: string; + }; + /** Specifies a start value for a strip. */ + startValue?: any; + /** Specifies an end value for a strip. */ + endValue?: any; + } + export interface BaseSeriesConfigLabel { + /** Specifies a format for arguments displayed by point labels. */ + argumentFormat?: string; + /** Specifies a precision for formatted point arguments displayed in point labels. */ + argumentPrecision?: number; + /** Specifies a background color for point labels. */ + backgroundColor?: string; + /** Specifies border options for point labels. */ + border?: viz.core.DashedBorder; + /** Specifies connector options for series point labels. */ + connector?: { + /** Specifies the color of label connectors. */ + color?: string; + /** Indicates whether or not label connectors are visible. */ + visible?: boolean; + /** Specifies the width of label connectors. */ + width?: number; + }; + /** Specifies a callback function that returns the text to be displayed by point labels. */ + customizeText?: (pointInfo: Object) => string; + /** Specifies font options for the text displayed in point labels. */ + font?: viz.core.Font; + /** Specifies a format for the text displayed by point labels. */ + format?: string; + position?: string; + /** Specifies a precision for formatted point values displayed in point labels. */ + precision?: number; + /** Specifies the angle used to rotate point labels from their initial position. */ + rotationAngle?: number; + /** Specifies the visibility of point labels. */ + visible?: boolean; + } + export interface SeriesConfigLabel extends BaseSeriesConfigLabel { + /** Specifies whether or not to show a label when the point has a zero value. */ + showForZeroValues?: boolean; + } + export interface ChartSeriesConfigLabel extends SeriesConfigLabel { + /** Specifies how to align point labels relative to the corresponding data points that they represent. */ + alignment?: string; + /** Specifies how to shift point labels horizontally from their initial positions. */ + horizontalOffset?: number; + /** Specifies how to shift point labels vertically from their initial positions. */ + verticalOffset?: number; + /** Specifies a precision for the percentage values displayed in the labels of a full-stacked-like series. */ + percentPrecision?: number; + } + export interface BaseCommonSeriesConfig { + /** Specifies the data source field that provides arguments for series points. */ + argumentField?: string; + axis?: string; + /** An object defining the label configuration options for a series in the dxChart widget. */ + label?: ChartSeriesConfigLabel; + /** Specifies border options for point labels. */ + border?: viz.core.DashedBorder; + /** Specifies a series color. */ + color?: string; + /** Specifies the dash style of the series' line. */ + dashStyle?: string; + hoverMode?: string; + /** An object defining configuration options for a hovered series. */ + hoverStyle?: { + /** An object defining the border options for a hovered series. */ + border?: viz.core.DashedBorder; + /**

              Sets a color for a series when it is hovered over.

              */ + color?: string; + /** Specifies the dash style for the line in a hovered series. */ + dashStyle?: string; + /** Specifies the hatching options to be applied when a series is hovered over. */ + hatching?: viz.core.Hatching; + /** Specifies the width of a line in a hovered series. */ + width?: number; + }; + /** Specifies whether a chart ignores null data points or not. */ + ignoreEmptyPoints?: boolean; + /** Specifies how many points are acceptable to be in a series to display all labels for these points. Otherwise, the labels will not be displayed. */ + maxLabelCount?: number; + /** Specifies the minimal length of a displayed bar in pixels. */ + minBarSize?: number; + /** Specifies opacity for a series. */ + opacity?: number; + /** Specifies the series elements to highlight when the series is selected. */ + selectionMode?: string; + /** An object defining configuration options for a selected series. */ + selectionStyle?: { + /** An object defining the border options for a selected series. */ + border?: viz.core.DashedBorder; + /** Sets a color for a series when it is selected. */ + color?: string; + /** Specifies the dash style for the line in a selected series. */ + dashStyle?: string; + /** Specifies the hatching options to be applied when a series is selected. */ + hatching?: viz.core.Hatching; + /** Specifies the width of a line in a selected series. */ + width?: number; + }; + /** Specifies whether or not to show the series in the chart's legend. */ + showInLegend?: boolean; + /** Specifies the name of the stack where the values of the _stackedBar_ series must be located. */ + stack?: string; + /** Specifies the name of the data source field that provides data about a point. */ + tagField?: string; + /** Specifies the data source field that provides values for series points. */ + valueField?: string; + /** Specifies the visibility of a series. */ + visible?: boolean; + /** Specifies a line width. */ + width?: number; + /** Configures error bars. */ + valueErrorBar?: { + /** Specifies whether error bars must be displayed in full or partially. */ + displayMode?: string; + /** Specifies the data field that provides data for low error values. */ + lowValueField?: string; + /** Specifies the data field that provides data for high error values. */ + highValueField?: string; + /** Specifies how error bar values must be calculated. */ + type?: string; + /** Specifies the value to be used for generating error bars. */ + value?: number; + /** Specifies the color of error bars. */ + color?: string; + /** Specifies the opacity of error bars. */ + opacity?: number; + /** Specifies the length of the lines that indicate the error bar edges. */ + edgeLength?: number; + /** Specifies the width of the error bar line. */ + lineWidth?: number; + }; + } + export interface CommonPointOptions { + /** Specifies border options for points in the line and area series. */ + border?: viz.core.Border; + /** Specifies the points color. */ + color?: string; + /** Specifies what series points to highlight when a point is hovered over. */ + hoverMode?: string; + /** An object defining configuration options for a hovered point. */ + hoverStyle?: { + /** An object defining the border options for a hovered point. */ + border?: viz.core.Border; + /** Sets a color for a point when it is hovered over. */ + color?: string; + /** Specifies the diameter of a hovered point in the series that represents data points as symbols (not as bars for instance). */ + size?: number; + }; + /** Specifies what series points to highlight when a point is selected. */ + selectionMode?: string; + /** An object defining configuration options for a selected point. */ + selectionStyle?: { + /** An object defining the border options for a selected point. */ + border?: viz.core.Border; + /**

              Sets a color for a point when it is selected.

              */ + color?: string; + /** Specifies the diameter of a selected point in the series that represents data points as symbols (not as bars for instance). */ + size?: number; + }; + /** Specifies the point diameter in pixels for those series that represent data points as symbols (not as bars for instance). */ + size?: number; + /** Specifies a symbol for presenting points of the line and area series. */ + symbol?: string; + visible?: boolean; + } + export interface ChartCommonPointOptions extends CommonPointOptions { + /** An object specifying the parameters of an image that is used as a point marker. */ + image?: { + /** Specifies the height of an image that is used as a point marker. */ + height?: any; + /** Specifies a URL leading to the image to be used as a point marker. */ + url?: any; + /** Specifies the width of an image that is used as a point marker. */ + width?: any; + }; + } + export interface PolarCommonPointOptions extends CommonPointOptions { + /** An object specifying the parameters of an image that is used as a point marker. */ + image?: { + /** Specifies the height of an image that is used as a point marker. */ + height?: number; + /** Specifies a URL leading to the image to be used as a point marker. */ + url?: string; + /** Specifies the width of an image that is used as a point marker. */ + width?: number; + }; + } + /** An object that defines configuration options for chart series. */ + export interface CommonSeriesConfig extends BaseCommonSeriesConfig { + /** Specifies the data source field that provides a 'close' value for a _candleStick_ or _stock_ series. */ + closeValueField?: string; + /** Specifies a radius for bar corners. */ + cornerRadius?: number; + /** Specifies the data source field that provides a 'high' value for a _candleStick_ or _stock_ series. */ + highValueField?: string; + /** Specifies the color for the body (rectangle) of a _candleStick_ series. */ + innerColor?: string; + /** Specifies the data source field that provides a 'low' value for a _candleStick_ or _stock_ series. */ + lowValueField?: string; + /** Specifies the data source field that provides an 'open' value for a _candleStick_ or _stock_ series. */ + openValueField?: string; + /** Specifies the pane that will be used to display a series. */ + pane?: string; + /** An object defining configuration options for points in line-, scatter- and area-like series. */ + point?: ChartCommonPointOptions; + /** Specifies the data source field that provides values for one end of a range series. To set the data source field for the other end of the range series, use the rangeValue2Field property. */ + rangeValue1Field?: string; + /** Specifies the data source field that provides values for the second end of a range series. To set the data source field for the other end of the range series, use the rangeValue1Field property. */ + rangeValue2Field?: string; + /** Specifies reduction options for the stock or candleStick series. */ + reduction?: { + /** Specifies a color for the points whose reduction level price is lower in comparison to the value in the previous point. */ + color?: string; + /** Specifies for which price level (open, high, low or close) to enable reduction options in the series. */ + level?: string; + }; + /** Specifies the data source field that defines the size of bubbles. */ + sizeField?: string; + } + export interface CommonSeriesSettings extends CommonSeriesConfig { + /**

              An object that specifies configuration options for all series of the area type in the chart.

              */ + area?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _bar_ type in the chart. */ + bar?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the bubble type in the chart. */ + bubble?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _candleStick_ type in the chart. */ + candlestick?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _fullStackedArea_ type in the chart. */ + fullstackedarea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the Full-Stacked Spline Area type in the chart. */ + fullstackedsplinearea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _fullStackedBar_ type in the chart. */ + fullstackedbar?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _fullStackedLine_ type in the chart. */ + fullstackedline?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the Full-Stacked Spline type in the chart. */ + fullstackedspline?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _line_ type in the chart. */ + line?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _rangeArea_ type in the chart. */ + rangearea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _rangeBar_ type in the chart. */ + rangebar?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _scatter_ type in the chart. */ + scatter?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _spline_ type in the chart. */ + spline?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _splineArea_ type in the chart. */ + splinearea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _stackedArea_ type in the chart. */ + stackedarea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the Stacked Spline Area type in the chart. */ + stackedsplinearea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _stackedBar_ type in the chart. */ + stackedbar?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _stackedLine_ type in the chart. */ + stackedline?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the Stacked Spline type in the chart. */ + stackedspline?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _stepArea_ type in the chart. */ + steparea?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _stepLine_ type in the chart. */ + stepline?: CommonSeriesConfig; + /** An object that specifies configuration options for all series of the _stock_ type in the chart. */ + stock?: CommonSeriesConfig; + /** Sets a series type. */ + type?: string; + } + export interface SeriesConfig extends CommonSeriesConfig { + /** Specifies the name that identifies the series. */ + name?: string; + /** Specifies data about a series. */ + tag?: any; + /** Sets the series type. */ + type?: string; + } + /** An object that defines configuration options for polar chart series. */ + export interface CommonPolarSeriesConfig extends BaseCommonSeriesConfig { + /** Specifies whether or not to close the chart by joining the end point with the first point. */ + closed?: boolean; + label?: SeriesConfigLabel; + point?: PolarCommonPointOptions; + } + export interface CommonPolarSeriesSettings extends CommonPolarSeriesConfig { + /** An object that specifies configuration options for all series of the area type in the chart. */ + area?: CommonPolarSeriesConfig; + /** An object that specifies configuration options for all series of the _bar_ type in the chart. */ + bar?: CommonPolarSeriesConfig; + /** An object that specifies configuration options for all series of the _line_ type in the chart. */ + line?: CommonPolarSeriesConfig; + /** An object that specifies configuration options for all series of the _scatter_ type in the chart. */ + scatter?: CommonPolarSeriesConfig; + /** An object that specifies configuration options for all series of the _stackedBar_ type in the chart. */ + stackedbar?: CommonPolarSeriesConfig; + /** Sets a series type. */ + type?: string; + } + export interface PolarSeriesConfig extends CommonPolarSeriesConfig { + /** Specifies the name that identifies the series. */ + name?: string; + /** Specifies data about a series. */ + tag?: any; + /** Sets the series type. */ + type?: string; + } + export interface PieSeriesConfigLabel extends BaseSeriesConfigLabel { + /** Specifies how to shift labels from their initial position in a radial direction in pixels. */ + radialOffset?: number; + /** Specifies a precision for the percentage values displayed in labels. */ + percentPrecision?: number; + } + /** An object that defines configuration options for chart series. */ + export interface CommonPieSeriesConfig { + /** Specifies the data source field that provides arguments for series points. */ + argumentField?: string; + /** Specifies the required type for series arguments. */ + argumentType?: string; + /** An object defining the series border configuration options. */ + border?: viz.core.DashedBorder; + /** Specifies a series color. */ + color?: string; + /** Specifies the chart elements to highlight when a series is hovered over. */ + hoverMode?: string; + /** An object defining configuration options for a hovered series. */ + hoverStyle?: { + /** An object defining the border options for a hovered series. */ + border?: viz.core.DashedBorder; + /** Sets a color for the series when it is hovered over. */ + color?: string; + /** Specifies the hatching options to be applied when a point is hovered over. */ + hatching?: viz.core.Hatching; + }; + /** Specifies the fraction of the inner radius relative to the total radius in the series of the 'doughnut' type. */ + innerRadius?: number; + /** An object defining the label configuration options. */ + label?: PieSeriesConfigLabel; + /** Specifies how many points are acceptable to be in a series to display all labels for these points. Otherwise, the labels will not be displayed. */ + maxLabelCount?: number; + /** Specifies a minimal size of a displayed pie segment. */ + minSegmentSize?: number; + /** Specifies the direction in which the dxPieChart's series points are located. */ + segmentsDirection?: string; + /**

              Specifies the chart elements to highlight when the series is selected.

              */ + selectionMode?: string; + /** An object defining configuration options for the series when it is selected. */ + selectionStyle?: { + /** An object defining the border options for a selected series. */ + border?: viz.core.DashedBorder; + /** Sets a color for a series when it is selected. */ + color?: string; + /** Specifies the hatching options to be applied when a point is selected. */ + hatching?: viz.core.Hatching; + }; + /** Specifies chart segment grouping options. */ + smallValuesGrouping?: { + /** Specifies the name of the grouped chart segment. This name represents the segment in the chart legend. */ + groupName?: string; + /** Specifies the segment grouping mode. */ + mode?: string; + /** Specifies a threshold for segment values. */ + threshold?: number; + /** Specifies how many segments must not be grouped. */ + topCount?: number; + }; + /** Specifies a start angle for a pie chart in arc degrees. */ + startAngle?: number; + /**

              Specifies the name of the data source field that provides data about a point.

              */ + tagField?: string; + /** Specifies the data source field that provides values for series points. */ + valueField?: string; + } + export interface PieSeriesConfig extends CommonPieSeriesConfig { + /** Sets the series type. */ + type?: string; + } + export interface SeriesTemplate { + /** Specifies a callback function that returns a series object with individual series settings. */ + customizeSeries?: (seriesName: string) => SeriesConfig; + /** Specifies a data source field that represents the series name. */ + nameField?: string; + } + export interface PolarSeriesTemplate { + /** Specifies a callback function that returns a series object with individual series settings. */ + customizeSeries?: (seriesName: string) => PolarSeriesConfig; + /** Specifies a data source field that represents the series name. */ + nameField?: string; + } + export interface ChartCommonConstantLineLabel { + /** Specifies font options for a constant line label. */ + font?: viz.core.Font; + /** Specifies the position of the constant line label relative to the chart plot. */ + position?: string; + /** Indicates whether or not to display labels for the axis constant lines. */ + visible?: boolean; + } + export interface PolarCommonConstantLineLabel { + /** Indicates whether or not to display labels for the axis constant lines. */ + visible?: boolean; + /** Specifies font options for a constant line label. */ + font?: viz.core.Font; + } + export interface ConstantLineStyle { + /** Specifies a color for a constant line. */ + color?: string; + /** Specifies a dash style for a constant line. */ + dashStyle?: string; + /** Specifies a constant line width in pixels. */ + width?: number; + } + export interface ChartCommonConstantLineStyle extends ConstantLineStyle { + /** An object defining constant line label options. */ + label?: ChartCommonConstantLineLabel; + /** Specifies the space between the constant line label and the left/right side of the constant line. */ + paddingLeftRight?: number; + /** Specifies the space between the constant line label and the top/bottom side of the constant line. */ + paddingTopBottom?: number; + } + export interface PolarCommonConstantLineStyle extends ConstantLineStyle { + /** An object defining constant line label options. */ + label?: PolarCommonConstantLineLabel; + } + export interface CommonAxisLabel { + /** Specifies font options for axis labels. */ + font?: viz.core.Font; + /** Specifies the spacing between an axis and its labels in pixels. */ + indentFromAxis?: number; + /** Indicates whether or not axis labels are visible. */ + visible?: boolean; + } + export interface ChartCommonAxisLabel extends CommonAxisLabel { + /** Specifies the label's position relative to the tick (grid line). */ + alignment?: string; + /** Specifies the overlap resolving algorithm to be applied to axis labels. */ + overlappingBehavior?: { + /** Specifies how to arrange axis labels. */ + mode?: string; + /** Specifies the angle used to rotate axis labels. */ + rotationAngle?: number; + /** Specifies the spacing that must be set between staggered rows when the 'stagger' algorithm is applied. */ + staggeringSpacing?: number; + }; + } + export interface PolarCommonAxisLabel extends CommonAxisLabel { + /** Specifies the overlap resolving algorithm to be applied to axis labels. */ + overlappingBehavior?: string; + } + export interface CommonAxisTitle { + /** Specifies font options for an axis title. */ + font?: viz.core.Font; + /** Specifies a margin for an axis title in pixels. */ + margin?: number; + } + export interface BaseCommonAxisSettings { + /** Specifies the color of the line that represents an axis. */ + color?: string; + /** Specifies whether ticks/grid lines of a discrete axis are located between labels or cross the labels. */ + discreteAxisDivisionMode?: string; + /** An object defining the configuration options for the grid lines of an axis in the dxPolarChart widget. */ + grid?: { + /** Specifies a color for grid lines. */ + color?: string; + /** Specifies an opacity for grid lines. */ + opacity?: number; + /** Indicates whether or not the grid lines of an axis are visible. */ + visible?: boolean; + /** Specifies the width of grid lines. */ + width?: number; + }; + /** Specifies the options of the minor grid. */ + minorGrid?: { + /** Specifies a color for the lines of the minor grid. */ + color?: string; + /** Specifies an opacity for the lines of the minor grid. */ + opacity?: number; + /** Indicates whether the minor grid is visible or not. */ + visible?: boolean; + /** Specifies a width for the lines of the minor grid. */ + width?: number; + }; + /** Indicates whether or not an axis is inverted. */ + inverted?: boolean; + /** Specifies the opacity of the line that represents an axis. */ + opacity?: number; + /** Indicates whether or not to set ticks/grid lines of a continuous axis of the 'date-time' type at the beginning of each date-time interval. */ + setTicksAtUnitBeginning?: boolean; + /** An object defining the configuration options for axis ticks. */ + tick?: { + /** Specifies ticks color. */ + color?: string; + /** Specifies tick opacity. */ + opacity?: number; + /** Indicates whether or not ticks are visible on an axis. */ + visible?: boolean; + }; + /** Specifies the options of the minor ticks. */ + minorTick?: { + /** Specifies a color for the minor ticks. */ + color?: string; + /** Specifies an opacity for the minor ticks. */ + opacity?: number; + /** Indicates whether or not the minor ticks are displayed on an axis. */ + visible?: boolean; + }; + /** Indicates whether or not the line that represents an axis in a chart is visible. */ + visible?: boolean; + /** Specifies the width of the line that represents an axis in the chart. */ + width?: number; + } + export interface ChartCommonAxisSettings extends BaseCommonAxisSettings { + /** Specifies the appearance of all the widget's constant lines. */ + constantLineStyle?: ChartCommonConstantLineStyle; + /** An object defining the label configuration options that are common for all axes in the dxChart widget. */ + label?: ChartCommonAxisLabel; + /** Specifies a coefficient that determines the spacing between the maximum series point and the axis. */ + maxValueMargin?: number; + /** Specifies a coefficient that determines the spacing between the minimum series point and the axis. */ + minValueMargin?: number; + /** Specifies, in pixels, the space reserved for an axis. */ + placeholderSize?: number; + /** An object defining configuration options for strip style. */ + stripStyle?: { + /** An object defining the configuration options for a strip label style. */ + label?: { + /** Specifies font options for a strip label. */ + font?: viz.core.Font; + /** Specifies the label's position on a strip. */ + horizontalAlignment?: string; + /** Specifies a label's position on a strip. */ + verticalAlignment?: string; + }; + /** Specifies the spacing, in pixels, between the left/right strip border and the strip label. */ + paddingLeftRight?: number; + /** Specifies the spacing, in pixels, between the top/bottom strip borders and the strip label. */ + paddingTopBottom?: number; + }; + /** An object defining the title configuration options that are common for all axes in the dxChart widget. */ + title?: CommonAxisTitle; + /** Indicates whether or not to display series with indents from axis boundaries. */ + valueMarginsEnabled?: boolean; + } + export interface PolarCommonAxisSettings extends BaseCommonAxisSettings { + /** Specifies the appearance of all the widget's constant lines. */ + constantLineStyle?: PolarCommonConstantLineStyle; + /** An object defining the label configuration options that are common for all axes in the dxPolarChart widget. */ + label?: PolarCommonAxisLabel; + /** An object defining configuration options for strip style. */ + stripStyle?: { + /** An object defining the configuration options for a strip label style. */ + label?: { + /** Specifies font options for a strip label. */ + font?: viz.core.Font; + }; + }; + } + export interface ChartConstantLineLabel extends ChartCommonConstantLineLabel { + /** Specifies the horizontal alignment of a constant line label. */ + horizontalAlignment?: string; + /** Specifies the vertical alignment of a constant line label. */ + verticalAlignment?: string; + /** Specifies the text to be displayed in a constant line label. */ + text?: string; + } + export interface PolarConstantLineLabel extends PolarCommonConstantLineLabel { + /** Specifies the text to be displayed in a constant line label. */ + text?: string; + } + export interface AxisLabel { + /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a label on the value axis. */ + customizeHint?: (argument: { value: any; valueText: string }) => string; + /** Specifies a callback function that returns the text to be displayed in value axis labels. */ + customizeText?: (argument: { value: any; valueText: string }) => string; + /** Specifies a format for the text displayed by axis labels. */ + format?: string; + /** Specifies a precision for the formatted value displayed in the axis labels. */ + precision?: number; + } + export interface ChartAxisLabel extends ChartCommonAxisLabel, AxisLabel { } + export interface PolarAxisLabel extends PolarCommonAxisLabel, AxisLabel { } + export interface AxisTitle extends CommonAxisTitle { + /** Specifies the text for the value axis title. */ + text?: string; + } + export interface ChartConstantLineStyle extends ChartCommonConstantLineStyle { + /** An object defining constant line label options. */ + label?: ChartConstantLineLabel; + } + export interface ChartConstantLine extends ChartConstantLineStyle { + /** An object defining constant line label options. */ + label?: ChartConstantLineLabel; + /** Specifies a value to be displayed by a constant line. */ + value?: any; + } + export interface PolarConstantLine extends PolarCommonConstantLineStyle { + /** An object defining constant line label options. */ + label?: PolarConstantLineLabel; + /** Specifies a value to be displayed by a constant line. */ + value?: any; + } + export interface Axis { + /** Specifies a coefficient for dividing the value axis. */ + axisDivisionFactor?: number; + /** Specifies the order in which discrete values are arranged on the value axis. */ + categories?: Array; + /** Specifies the value to be raised to a power when generating ticks for a logarithmic axis. */ + logarithmBase?: number; + /** Specifies an interval between axis ticks/grid lines. */ + tickInterval?: any; + /** Specifies the interval between minor ticks. */ + minorTickInterval?: any; + /** Specifies the number of minor ticks between two neighboring major ticks. */ + minorTickCount?: number; + /** Specifies the required type of the value axis. */ + type?: string; + /** Specifies the pane on which the current value axis will be displayed. */ + pane?: string; + /** Specifies options for value axis strips. */ + strips?: Array; + } + export interface ChartAxis extends ChartCommonAxisSettings, Axis { + /** Defines an array of the value axis constant lines. */ + constantLines?: Array; + /** Specifies the appearance options for the constant lines of the value axis. */ + constantLineStyle?: ChartCommonConstantLineStyle; + /** Specifies options for value axis labels. */ + label?: ChartAxisLabel; + /** Specifies the maximum value on the value axis. */ + max?: any; + /** Specifies the minimum value on the value axis. */ + min?: any; + /** Specifies the position of the value axis on a chart. */ + position?: string; + /** Specifies the title for a value axis. */ + title?: AxisTitle; + } + export interface PolarAxis extends PolarCommonAxisSettings, Axis { + /** Defines an array of the value axis constant lines. */ + constantLines?: Array; + /** Specifies options for value axis labels. */ + label?: PolarAxisLabel; + } + export interface ArgumentAxis { + /** Specifies the desired type of axis values. */ + argumentType?: string; + /** Specifies the elements that will be highlighted when the argument axis is hovered over. */ + hoverMode?: string; + } + export interface ChartArgumentAxis extends ChartAxis, ArgumentAxis { } + export interface PolarArgumentAxis extends PolarAxis, ArgumentAxis { + /** Specifies a start angle for the argument axis in degrees. */ + startAngle?: number; + /** Specifies whether or not to display the first point at the angle specified by the startAngle option. */ + firstPointOnStartAngle?: boolean; + /** Specifies the period of the argument values in the data source. */ + period?: number; + } + export interface ValueAxis { + /** Specifies the name of the value axis. */ + name?: string; + /** Specifies whether or not to indicate a zero value on the value axis. */ + showZero?: boolean; + /** Specifies the desired type of axis values. */ + valueType?: string; + } + export interface ChartValueAxis extends ChartAxis, ValueAxis { + /** Specifies the spacing, in pixels, between multiple value axes in a chart. */ + multipleAxesSpacing?: number; + /** Specifies the value by which the chart's value axes are synchronized. */ + synchronizedValue?: number; + } + export interface PolarValueAxis extends PolarAxis, ValueAxis { + /** Indicates whether to display series with indents from axis boundaries. */ + valueMarginsEnabled?: boolean; + /** Specifies a coefficient that determines the spacing between the maximum series point and the axis. */ + maxValueMargin?: number; + /** Specifies a coefficient that determines the spacing between the minimum series point and the axis. */ + minValueMargin?: number; + tick?: { + visible?: boolean; + } + } + export interface CommonPane { + /** Specifies a background color in a pane. */ + backgroundColor?: string; + /** Specifies the border options of a chart's pane. */ + border?: PaneBorder; + } + export interface Pane extends CommonPane { + /** Specifies the name of a pane. */ + name?: string; + } + export interface PaneBorder extends viz.core.DashedBorderWithOpacity { + /** Specifies the bottom border's visibility state in a pane. */ + bottom?: boolean; + /** Specifies the left border's visibility state in a pane. */ + left?: boolean; + /** Specifies the right border's visibility state in a pane. */ + right?: boolean; + /** Specifies the top border's visibility state in a pane. */ + top?: boolean; + } + export interface ChartAnimation extends viz.core.Animation { + /** Specifies the maximum series point count in the chart that the animation supports. */ + maxPointCountSupported?: number; + } + export interface BaseChartTooltip extends viz.core.Tooltip { + /** Specifies a format for arguments of the chart's series points. */ + argumentFormat?: string; + /** Specifies a precision for formatted arguments displayed in tooltips. */ + argumentPrecision?: number; + /** Specifies a precision for a percent value displayed in tooltips for stacked series and dxPieChart series. */ + percentPrecision?: number; + } + export interface BaseChartOptions extends viz.core.BaseWidgetOptions { + /** Specifies adaptive layout options. */ + adaptiveLayout?: { + /** Specifies the width of the widget container that is small enough for the layout to begin adapting. */ + width?: number; + /** Specifies the height of the widget container that is small enough for the layout to begin adapting. */ + height?: number; + /** Specifies whether or not point labels can be hidden when the layout is adapting. */ + keepLabels?: boolean; + }; + /** Specifies animation options. */ + animation?: ChartAnimation; + /** Specifies a callback function that returns an object with options for a specific point label. */ + customizeLabel?: (labelInfo: Object) => Object; + /** Specifies a callback function that returns an object with options for a specific point. */ + customizePoint?: (pointInfo: Object) => Object; + /** Specifies a data source for the chart. */ + dataSource?: any; + done?: Function; + /** Specifies the appearance of the loading indicator. */ + loadingIndicator?: viz.core.LoadingIndicator; + /** Specifies options of a dxChart's (dxPieChart's) legend. */ + legend?: core.BaseLegend; + /** Specifies the blank space between the chart's extreme elements and the boundaries of the area provided for the widget (see size) in pixels. */ + margin?: viz.core.Margins; + /** Sets the name of the palette to be used in the chart. Alternatively, an array of colors can be set as a custom palette to be used within this chart. */ + palette?: any; + /** A handler for the done event. */ + onDone?: (e: { + component: BaseChart; + element: Element; + }) => void; + /** A handler for the pointClick event. */ + onPointClick?: any; + pointClick?: any; + /** A handler for the pointHoverChanged event. */ + onPointHoverChanged?: (e: { + component: BaseChart; + element: Element; + target: TPoint; + }) => void; + pointHoverChanged?: (point: TPoint) => void; + /** A handler for the pointSelectionChanged event. */ + onPointSelectionChanged?: (e: { + component: BaseChart; + element: Element; + target: TPoint; + }) => void; + pointSelectionChanged?: (point: TPoint) => void; + /** Specifies whether a single point or multiple points can be selected in the chart. */ + pointSelectionMode?: string; + /** Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates. */ + redrawOnResize?: boolean; + /** Specifies options for the dxChart and dxPieChart widget series. */ + series?: any; + /** Specifies the size of the widget in pixels. */ + size?: viz.core.Size; + /** Sets the name of the theme to be used in the chart. */ + theme?: string; + /** Specifies a title for the chart. */ + title?: { + /** Specifies font options for the title. */ + font?: viz.core.Font; + /** Specifies the title's horizontal position in the chart. */ + horizontalAlignment?: string; + /** Specifies a title's position on the chart in the vertical direction. */ + verticalAlignment?: string; + /** Specifies the distance between the title and surrounding chart elements in pixels. */ + margin?: viz.core.Margins; + /** Specifies the height of the space reserved for the title. */ + placeholderSize?: number; + /** Specifies a text for the chart's title. */ + text?: string; + }; + /** Specifies tooltip options. */ + tooltip?: BaseChartTooltip; + /** A handler for the tooltipShown event. */ + onTooltipShown?: (e: { + component: BaseChart; + element: Element; + }) => void; + /** A handler for the tooltipHidden event. */ + onTooltipHidden?: (e: { + component: BaseChart; + element: Element; + }) => void; + tooltipHidden?: (point: TPoint) => void; + tooltipShown?: (point: TPoint) => void; + } + /** A base class for all chart widgets included in the ChartJS library. */ + export class BaseChart extends viz.core.BaseWidget { + /** Deselects the chart's selected series. The series is displayed in an initial style. */ + clearSelection(): void; + /** Gets the current size of the widget. */ + getSize(): { width: number; height: number }; + /** Displays the loading indicator. */ + showLoadingIndicator(): void; + /** Conceals the loading indicator. */ + hideLoadingIndicator(): void; + /** Hides all widget tooltips. */ + hideTooltip(): void; + /** Redraws a widget. */ + render(renderOptions?: { + force?: boolean; + animate?: boolean; + asyncSeriesRendering?: boolean; + }): void; + } + export interface AdvancedLegend extends core.BaseLegend { + /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a legend item. */ + customizeHint?: (seriesInfo: { seriesName: string; seriesIndex: number; seriesColor: string; }) => string; + /**

              Specifies a callback function that returns the text to be displayed by legend items.

              */ + customizeText?: (seriesInfo: { seriesName: string; seriesIndex: number; seriesColor: string; }) => string; + /** Specifies what series elements to highlight when a corresponding item in the legend is hovered over. */ + hoverMode?: string; + } + export interface AdvancedOptions extends BaseChartOptions { + /** A handler for the argumentAxisClick event. */ + onArgumentAxisClick?: any; + /** Specifies the color of the parent page element. */ + containerBackgroundColor?: string; + /** An object providing options for managing data from a data source. */ + dataPrepareSettings?: { + /** Specifies whether or not to validate the values from a data source. */ + checkTypeForAllData?: boolean; + /** Specifies whether or not to convert the values from a data source into the data type of an axis. */ + convertToAxisDataType?: boolean; + /** Specifies how to sort the series points. */ + sortingMethod?: any; + }; + /** A handler for the legendClick event. */ + onLegendClick?: any; + /** A handler for the seriesClick event. */ + onSeriesClick?: any; + /** A handler for the seriesHoverChanged event. */ + onSeriesHoverChanged?: (e: { + component: BaseChart; + element: Element; + target: TSeries; + }) => void; + /** A handler for the seriesSelectionChanged event. */ + onSeriesSelectionChanged?: (e: { + component: BaseChart; + element: Element; + target: TSeries; + }) => void; + /** Specifies whether a single series or multiple series can be selected in the chart. */ + seriesSelectionMode?: string; + /** Specifies how the chart must behave when series point labels overlap. */ + resolveLabelOverlapping?: string; + } + export interface Legend extends AdvancedLegend { + /** Specifies whether the legend is located outside or inside the chart's plot. */ + position?: string; + } + export interface ChartTooltip extends BaseChartTooltip { + /** Specifies whether the tooltip must be located in the center of a bar or on its edge. Applies only to the Bar series. */ + location?: string; + /** Specifies the kind of information to display in a tooltip. */ + shared?: boolean; + } + export interface dxChartOptions extends AdvancedOptions { + /** Specifies a value indicating whether all bars in a series must have the same width, or may have different widths if any points in other series are missing. */ + equalBarWidth?: any; + adaptiveLayout?: { + keepLabels?: boolean; + }; + /** Indicates whether or not to synchronize value axes when they are displayed on a single pane. */ + synchronizeMultiAxes?: boolean; + /** Specifies whether or not to filter the series points depending on their quantity. */ + useAggregation?: boolean; + /** Indicates whether or not to adjust a value axis to the current minimum and maximum values of a zoomed chart. */ + adjustOnZoom?: boolean; + /** Specifies argument axis options for the dxChart widget. */ + argumentAxis?: ChartArgumentAxis; + argumentAxisClick?: any; + /** An object defining the configuration options that are common for all axes of the dxChart widget. */ + commonAxisSettings?: ChartCommonAxisSettings; + /** An object defining the configuration options that are common for all panes in the dxChart widget. */ + commonPaneSettings?: CommonPane; + /** An object defining the configuration options that are common for all series of the dxChart widget. */ + commonSeriesSettings?: CommonSeriesSettings; + /** An object that specifies the appearance options of the chart crosshair. */ + crosshair?: { + /** Specifies a color for the crosshair lines. */ + color?: string; + /** Specifies a dash style for the crosshair lines. */ + dashStyle?: string; + /** Specifies whether to enable the crosshair or not. */ + enabled?: boolean; + /** Specifies the opacity of the crosshair lines. */ + opacity?: number; + /** Specifies the width of the crosshair lines. */ + width?: number; + /** Specifies the appearance of the horizontal crosshair line. */ + horizontalLine?: CrosshaierWithLabel; + /** Specifies the appearance of the vertical crosshair line. */ + verticalLine?: CrosshaierWithLabel; + /** Specifies the options of the crosshair labels. */ + label?: { + /** Specifies a color for the background of the crosshair labels. */ + backgroundColor?: string; + /** Specifies whether the crosshair labels are visible or not. */ + visible?: boolean; + /** Specifies font options for the text of the crosshair labels. */ + font?: viz.core.Font; + } + }; + /** Specifies a default pane for the chart's series. */ + defaultPane?: string; + /** Specifies a coefficient determining the diameter of the largest bubble. */ + maxBubbleSize?: number; + /** Specifies the diameter of the smallest bubble measured in pixels. */ + minBubbleSize?: number; + /** Defines the dxChart widget's pane(s). */ + panes?: Array; + /** Swaps the axes round so that the value axis becomes horizontal and the argument axes becomes vertical. */ + rotated?: boolean; + /** Specifies the options of a chart's legend. */ + legend?: Legend; + /** Specifies options for dxChart widget series. */ + series?: Array; + legendClick?: any; + seriesClick?: any; + seriesHoverChanged?: (series: ChartSeries) => void; + seriesSelectionChanged?: (series: ChartSeries) => void; + /** Defines options for the series template. */ + seriesTemplate?: SeriesTemplate; + /** Specifies tooltip options. */ + tooltip?: ChartTooltip; + /** Specifies value axis options for the dxChart widget. */ + valueAxis?: Array; + /** Enables scrolling in your chart. */ + scrollingMode?: string; + /** Enables zooming in your chart. */ + zoomingMode?: string; + /** Specifies the settings of the scroll bar. */ + scrollBar?: { + /** Specifies whether the scroll bar is visible or not. */ + visible?: boolean; + /** Specifies the spacing between the scroll bar and the chart's plot in pixels. */ + offset?: number; + /** Specifies the color of the scroll bar. */ + color?: string; + /** Specifies the width of the scroll bar in pixels. */ + width?: number; + /** Specifies the opacity of the scroll bar. */ + opacity?: number; + /** Specifies the position of the scroll bar in the chart. */ + position?: string; + }; + } + /** A widget used to embed charts into HTML JS applications. */ + export class dxChart extends BaseChart { + constructor(element: JQuery, options?: dxChartOptions); + constructor(element: Element, options?: dxChartOptions); + /** Returns an array of all series in the chart. */ + getAllSeries(): Array; + /** Gets a series within the chart's series collection by the specified name (see the name option). */ + getSeriesByName(seriesName: string): ChartSeries; + /** Gets a series within the chart's series collection by its position number. */ + getSeriesByPos(seriesIndex: number): ChartSeries; + /** Sets the specified start and end values for the chart's argument axis. */ + zoomArgument(startValue: any, endValue: any): void; + } + interface CrosshaierWithLabel extends viz.core.DashedBorderWithOpacity { + /** Configures the label that belongs to the horizontal crosshair line. */ + label?: { + /** Specifies a color for the background of the label that belongs to the horizontal crosshair line. */ + backgroundColor?: string; + /** Specifies whether the label of the horizontal crosshair line is visible or not. */ + visible?: boolean; + /** Specifies font options for the text of the label that belongs to the horizontal crosshair line. */ + font?: viz.core.Font; + } + } + export interface PolarChartTooltip extends BaseChartTooltip { + /** Specifies the kind of information to display in a tooltip. */ + shared?: boolean; + } + export interface dxPolarChartOptions extends AdvancedOptions { + /** Specifies a value indicating whether all bars in a series must have the same angle, or may have different angles if any points in other series are missing. */ + equalBarWidth?: boolean; + /** Specifies adaptive layout options. */ + adaptiveLayout?: { + width?: number; + height?: number; + /** Specifies whether or not point labels can be hidden when the layout is adapting. */ + keepLabels?: boolean; + }; + /** Indicates whether or not to display a "spider web". */ + useSpiderWeb?: boolean; + /** Specifies argument axis options for the dxPolarChart widget. */ + argumentAxis?: PolarArgumentAxis; + /** An object defining the configuration options that are common for all axes of the dxPolarChart widget. */ + commonAxisSettings?: PolarCommonAxisSettings; + /** An object defining the configuration options that are common for all series of the dxPolarChart widget. */ + commonSeriesSettings?: CommonPolarSeriesSettings; + /** Specifies the options of a chart's legend. */ + legend?: AdvancedLegend; + /** Specifies options for dxPolarChart widget series. */ + series?: Array; + /** Defines options for the series template. */ + seriesTemplate?: PolarSeriesTemplate; + /** Specifies tooltip options. */ + tooltip?: PolarChartTooltip; + /** Specifies value axis options for the dxPolarChart widget. */ + valueAxis?: PolarValueAxis; + } + /** A chart widget displaying data in a polar coordinate system. */ + export class dxPolarChart extends BaseChart { + constructor(element: JQuery, options?: dxPolarChartOptions); + constructor(element: Element, options?: dxPolarChartOptions); + /** Returns an array of all series in the chart. */ + getAllSeries(): Array; + /** Gets a series within the chart's series collection by the specified name (see the name option). */ + getSeriesByName(seriesName: string): PolarSeries; + /** Gets a series within the chart's series collection by its position number. */ + getSeriesByPos(seriesIndex: number): PolarSeries; + } + export interface PieLegend extends core.BaseLegend { + /** Specifies what chart elements to highlight when a corresponding item in the legend is hovered over. */ + hoverMode?: string; + /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a legend item. */ + customizeHint?: (pointInfo: { pointName: string; pointIndex: number; pointColor: string; }) => string; + /** Specifies a callback function that returns the text to be displayed by a legend item. */ + customizeText?: (pointInfo: { pointName: string; pointIndex: number; pointColor: string; }) => string; + } + export interface dxPieChartOptions extends BaseChartOptions { + /** Specifies adaptive layout options. */ + adaptiveLayout?: { + /** Specifies whether or not point labels can be hidden when the layout is adapting. */ + keepLabels?: boolean; + }; + /** Specifies dxPieChart legend options. */ + legend?: PieLegend; + /** Specifies options for the series of the dxPieChart widget. */ + series?: Array; + /** Specifies the diameter of the pie. */ + diameter?: number; + /** A handler for the legendClick event. */ + onLegendClick?: any; + legendClick?: any; + /** Specifies how the chart must behave when series point labels overlap. */ + resolveLabelOverlapping?: string; + } + /** A circular chart widget for HTML JS applications. */ + export class dxPieChart extends BaseChart { + constructor(element: JQuery, options?: dxPieChartOptions); + constructor(element: Element, options?: dxPieChartOptions); + /** Provides access to the dxPieChart series. */ + getSeries(): PieSeries; + } +} +declare module DevExpress.viz.core { + export interface Border { + /** Sets a border color for a selected series. */ + color?: string; + /** Sets border visibility for a selected series. */ + visible?: boolean; + /** Sets a border width for a selected series. */ + width?: number; + } + export interface DashedBorder extends Border { + /** Specifies a dash style for the border of a selected series point. */ + dashStyle?: string; + } + export interface DashedBorderWithOpacity extends DashedBorder { + /** Specifies the opacity of the tooltip's border. */ + opacity?: number; + } + export interface Font { + /** Specifies the font color for a strip label. */ + color?: string; + /** Specifies the font family for a strip label. */ + family?: string; + /** Specifies the font opacity for a strip label. */ + opacity?: number; + /** Specifies the font size for a strip label. */ + size?: any; + /** Specifies the font weight for the text displayed in strips. */ + weight?: number; + } + export interface Hatching { + /** Specifies how to apply hatching to highlight a selected series. */ + direction?: string; + /** Specifies the opacity of hatching lines. */ + opacity?: number; + /** Specifies the distance between hatching lines in pixels. */ + step?: number; + /** Specifies the width of hatching lines in pixels. */ + width?: number; + } + export interface Margins { + /** Specifies the legend's bottom margin in pixels. */ + bottom?: number; + /** Specifies the legend's left margin in pixels. */ + left?: number; + /** Specifies the legend's right margin in pixels. */ + right?: number; + /** Specifies the legend's bottom margin in pixels. */ + top?: number; + } + export interface Size { + /** Specifies the width of the widget. */ + width?: number; + /** Specifies the height of the widget. */ + height?: number; + } + export interface Tooltip { + /** Specifies the length of the tooltip's arrow in pixels. */ + arrowLength?: number; + /** Specifies the appearance of the tooltip's border. */ + border?: viz.core.DashedBorderWithOpacity; + /** Specifies a color for the tooltip. */ + color?: string; + customizeText?: Function; + /** Specifies text and appearance of a particular set of tooltips. */ + customizeTooltip?: (arg: Object) => { color?: string; text?: string }; + /** Specifies whether or not the tooltip is enabled. */ + enabled?: boolean; + /** Specifies font options for the text displayed by the tooltip. */ + font?: Font; + /** Specifies a format for the text displayed by the tooltip. */ + format?: string; + /** Specifies the opacity of a tooltip. */ + opacity?: number; + /** Specifies a distance from the tooltip's left/right boundaries to the inner text in pixels. */ + paddingLeftRight?: number; + /** Specifies a distance from the tooltip's top/bottom boundaries to the inner text in pixels. */ + paddingTopBottom?: number; + /** Specifies a precision for formatted values displayed by the tooltip. */ + precision?: number; + /** Specifies options of the tooltip's shadow. */ + shadow?: { + /** Specifies the blur distance of the tooltip's shadow. */ + blur?: number; + /** Specifies the color of the tooltip's shadow. */ + color?: string; + /** Specifies the horizontal offset of the tooltip's shadow relative to the tooltip in pixels. */ + offsetX?: number; + /** Specifies the vertical offset of the tooltip's shadow relative to the tooltip in pixels. */ + offsetY?: number; + /** Specifies the opacity of the tooltip's shadow. */ + opacity?: number; + }; + } + export interface Animation { + /** Determines how long animation runs. */ + duration?: number; + /** Specifies the animation easing mode. */ + easing?: string; + /** Indicates whether or not animation is enabled. */ + enabled?: boolean; + } + export interface LoadingIndicator { + /** Specifies a color for the loading indicator background. */ + backgroundColor?: string; + /** Specifies font options for the loading indicator text. */ + font?: viz.core.Font; + /** Specifies whether to show the loading indicator or not. */ + show?: boolean; + /** Specifies a text to be displayed by the loading indicator. */ + text?: string; + } + export interface LegendBorder extends viz.core.DashedBorderWithOpacity { + /** Specifies a radius for the corners of the legend border. */ + cornerRadius?: number; + } + export interface BaseLegend { + /** Specifies the color of the legend's background. */ + backgroundColor?: string; + /** Specifies legend border settings. */ + border?: viz.core.LegendBorder; + /** Specifies how many columns must be taken to arrange legend items. */ + columnCount?: number; + /** Specifies the spacing between a pair of neighboring legend columns in pixels. */ + columnItemSpacing?: number; + /** Specifies whether or not item columns in the legend have an equal width. */ + equalColumnWidth?: boolean; + /** Specifies font options for legend items. */ + font?: viz.core.Font; + /** Specifies the legend's position on the map. */ + horizontalAlignment?: string; + /** Specifies the alignment of legend items. */ + itemsAlignment?: string; + /** Specifies the position of text relative to the item marker. */ + itemTextPosition?: string; + /** Specifies the distance between the legend and the container borders in pixels. */ + margin?: viz.core.Margins; + /** Specifies the size of item markers in the legend in pixels. */ + markerSize?: number; + /** Specifies whether to arrange legend items horizontally or vertically. */ + orientation?: string; + /** Specifies the spacing between the legend left/right border and legend items in pixels. */ + paddingLeftRight?: number; + /** Specifies the spacing between the legend top/bottom border and legend items in pixels. */ + paddingTopBottom?: number; + /** Specifies how many rows must be taken to arrange legend items. */ + rowCount?: number; + /** Specifies the spacing between a pair of neighboring legend rows in pixels. */ + rowItemSpacing?: number; + /** Specifies the legend's position on the map. */ + verticalAlignment?: string; + /** Specifies whether or not the legend is visible on the map. */ + visible?: boolean; + } + export interface BaseWidgetOptions { + drawn?: (widget: Object) => void; + /** A handler for the drawn event. */ + onDrawn?: (e: { + component: BaseWidget; + element: Element; + }) => void; + incidentOccured?: (incidentInfo: { + id: string; + type: string; + args: any; + text: string; + widget: string; + version: string; + }) => void; + /** A handler for the incidentOccurred event. */ + onIncidentOccurred?: ( + component: BaseWidget, + element: Element, + target: { + id: string; + type: string; + args: any; + text: string; + widget: string; + version: string; + } + ) => void; + /** Notifies a widget that it is embedded into an HTML page that uses a path modifier. */ + pathModified?: boolean; + /** Specifies whether or not the widget supports right-to-left representation. */ + rtlEnabled?: boolean; + } + /** This section describes options and methods that are common to all widgets. */ + export class BaseWidget extends DOMComponent { + /** Returns the widget's SVG markup. */ + svg(): string; + } +} +declare module DevExpress.viz.gauges { + export interface BaseRangeContainer { + /** Specifies a range container's background color. */ + backgroundColor?: string; + /** Specifies the offset of the range container from an invisible scale line in pixels. */ + offset?: number; + /** Sets the name of the palette or an array of colors to be used for coloring the gauge range container. */ + palette?: any; + /** An array of objects representing ranges contained in the range container. */ + ranges?: Array<{ startValue: number; endValue: number; color: string }>; + /** Specifies a color of a range. */ + color?: string; + /** Specifies an end value of a range. */ + endValue?: number; + /** Specifies a start value of a range. */ + startValue?: number; + } + export interface ScaleTick { + /** Specifies the color of the scale's minor ticks. */ + color?: string; + /** Specifies an array of custom minor ticks. */ + customTickValues?: Array; + /** Specifies the length of the scale's minor ticks. */ + length?: number; + /** Indicates whether automatically calculated minor ticks are visible or not. */ + showCalculatedTicks?: boolean; + /** Specifies an interval between minor ticks. */ + tickInterval?: number; + /** Indicates whether scale minor ticks are visible or not. */ + visible?: boolean; + /** Specifies the width of the scale's minor ticks. */ + width?: number; + } + export interface ScaleMajorTick extends ScaleTick { + /** Specifies whether or not to expand the current major tick interval if labels overlap each other. */ + useTicksAutoArrangement?: boolean; + } + export interface BaseScaleLabel { + /** Specifies whether or not scale labels should be colored similarly to their corresponding ranges in the range container. */ + useRangeColors?: boolean; + /** Specifies a callback function that returns the text to be displayed in scale labels. */ + customizeText?: (scaleValue: { value: number; valueText: string }) => string; + /** Specifies font options for the text displayed in the scale labels of the gauge. */ + font?: viz.core.Font; + /** Specifies a format for the text displayed in scale labels. */ + format?: string; + /** Specifies a precision for the formatted value displayed in the scale labels. */ + precision?: number; + /** Specifies whether or not scale labels are visible on the gauge. */ + visible?: boolean; + } + export interface BaseScale { + /** Specifies the end value for the scale of the gauge. */ + endValue?: number; + /** Specifies whether or not to hide the first scale label. */ + hideFirstLabel?: boolean; + /** Specifies whether or not to hide the first major tick on the scale. */ + hideFirstTick?: boolean; + /** Specifies whether or not to hide the last scale label. */ + hideLastLabel?: boolean; + /** Specifies whether or not to hide the last major tick on the scale. */ + hideLastTick?: boolean; + /** Specifies common options for scale labels. */ + label?: BaseScaleLabel; + /** Specifies options of the gauge's major ticks. */ + majorTick?: ScaleMajorTick; + /** Specifies options of the gauge's minor ticks. */ + minorTick?: ScaleTick; + /** Specifies the start value for the scale of the gauge. */ + startValue?: number; + } + export interface BaseValueIndicator { + /** Specifies the type of subvalue indicators. */ + type?: string; + /** Specifies the background color for the indicator of the rangeBar type. */ + backgroundColor?: string; + /** Specifies the base value for the indicator of the rangeBar type. */ + baseValue?: number; + /** Specifies a color of the indicator. */ + color?: string; + /** Specifies the range bar size for an indicator of the rangeBar type. */ + size?: number; + text?: { + /** Specifies a callback function that returns the text to be displayed in an indicator. */ + customizeText?: (indicatedValue: { value: number; valueText: string }) => string; + font?: viz.core.Font; + /** Specifies a format for the text displayed in an indicator. */ + format?: string; + /** Specifies the range bar's label indent in pixels. */ + indent?: number; + /** Specifies a precision for the formatted value displayed by an indicator. */ + precision?: number; + }; + offset?: number; + length?: number; + width?: number; + /** Specifies the length of an arrow for the indicator of the textCloud type in pixels. */ + arrowLength?: number; + /** Sets the array of colors to be used for coloring subvalue indicators. */ + palette?: Array; + /** Specifies the distance between the needle and the center of a gauge for the indicator of a needle-like type. */ + indentFromCenter?: number; + /** Specifies the second color for the indicator of the twoColorNeedle type. */ + secondColor?: string; + /** Specifies the length of a twoNeedleColor type indicator tip as a percentage. */ + secondFraction?: number; + /** Specifies the spindle's diameter in pixels for the indicator of a needle-like type. */ + spindleSize?: number; + /** Specifies the inner diameter in pixels, so that the spindle has the shape of a ring. */ + spindleGapSize?: number; + /** Specifies the orientation of the rangeBar indicator on a vertically oriented dxLinearGauge widget. */ + horizontalOrientation?: string; + /** Specifies the orientation of the rangeBar indicator on a horizontally oriented dxLinearGauge widget. */ + verticalOrientation?: string; + } + export interface SharedGaugeOptions { + /** Specifies animation options. */ + animation?: viz.core.Animation; + /** Specifies the appearance of the loading indicator. */ + loadingIndicator?: viz.core.LoadingIndicator; + /** Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates. */ + redrawOnResize?: boolean; + /** Specifies the size of the widget in pixels. */ + size?: viz.core.Size; + /** Specifies a subtitle for a gauge. */ + subtitle?: { + /** Specifies font options for the subtitle. */ + font?: viz.core.Font; + /** Specifies a text for the subtitle. */ + text?: string; + }; + /** Specifies the name of the theme to be applied. */ + theme?: string; + /** Specifies a title for a gauge. */ + title?: { + /** Specifies font options for the title. */ + font?: viz.core.Font; + /** Specifies a title's position on the gauge. */ + position?: string; + /** Specifies a text for the title. */ + text?: string; + }; + /** Specifies options for gauge tooltips. */ + tooltip?: viz.core.Tooltip; + } + export interface BaseGaugeOptions extends viz.core.BaseWidgetOptions, SharedGaugeOptions { + /** Specifies the color of the parent page element. */ + containerBackgroundColor?: string; + /** Specifies the blank space in pixels between the widget's extreme elements and the boundaries of the area provided for the widget (see the size option). */ + margin?: viz.core.Margins; + /** Specifies options of the gauge's range container. */ + rangeContainer?: BaseRangeContainer; + /** Specifies a gauge's scale options. */ + scale?: BaseScale; + /** Specifies the appearance options of subvalue indicators. */ + subvalueIndicator?: BaseValueIndicator; + /** Specifies a set of subvalues to be designated by the subvalue indicators. */ + subvalues?: Array; + /** Specifies the main value on a gauge. */ + value?: number; + /** Specifies the appearance options of the value indicator. */ + valueIndicator?: BaseValueIndicator; + } + /** A gauge widget. */ + export class dxBaseGauge extends viz.core.BaseWidget { + /** Displays the loading indicator. */ + showLoadingIndicator(): void; + /** Conceals the loading indicator. */ + hideLoadingIndicator(): void; + /** Redraws a widget. */ + render(): void; + /** Returns the main gauge value. */ + value(): number; + /** Updates a gauge value. */ + value(value: number): void; + /** Returns an array of gauge subvalues. */ + subvalues(): Array; + /** Updates gauge subvalues. */ + subvalues(subvalues: Array): void; + } + export interface LinearRangeContainer extends BaseRangeContainer { + /** Specifies the orientation of the range container on a vertically oriented dxLinearGauge widget. */ + horizontalOrientation?: string; + /** Specifies the orientation of a range container on a horizontally oriented dxLinearGauge widget. */ + verticalOrientation?: string; + /** Specifies the width of the range container's start and end boundaries in the dxLinearGauge widget. */ + width?: any; + /** Specifies an end width of a range container. */ + end?: number; + /** Specifies a start width of a range container. */ + start?: number; + } + export interface LinearScaleLabel extends BaseScaleLabel { + /** Specifies the spacing between scale labels and ticks. */ + indentFromTick?: number; + } + export interface LinearScale extends BaseScale { + /** Specifies the orientation of scale ticks on a vertically oriented dxLinearGauge widget. */ + horizontalOrientation?: string; + label?: LinearScaleLabel; + /** Specifies the orientation of scale ticks on a horizontally oriented dxLinearGauge widget. */ + verticalOrientation?: string; + } + export interface dxLinearGaugeOptions extends BaseGaugeOptions { + /** Specifies the options required to set the geometry of the dxLinearGauge widget. */ + geometry?: { + /** Indicates whether to display the dxLinearGauge widget vertically or horizontally. */ + orientation?: string; + }; + /** Specifies gauge range container options. */ + rangeContainer?: LinearRangeContainer; + scale?: LinearScale; + } + /** A widget that represents a gauge with a linear scale. */ + export class dxLinearGauge extends dxBaseGauge { + constructor(element: JQuery, options?: dxLinearGaugeOptions); + constructor(element: Element, options?: dxLinearGaugeOptions); + } + export interface CircularRangeContainer extends BaseRangeContainer { + /** Specifies the orientation of the range container in the dxCircularGauge widget. */ + orientation?: string; + /** Specifies the range container's width in pixels. */ + width?: number; + } + export interface CircularScaleLabel extends BaseScaleLabel { + /** Specifies the spacing between scale labels and ticks. */ + indentFromTick?: number; + } + export interface CircularScale extends BaseScale { + label?: CircularScaleLabel; + /** Specifies the orientation of scale ticks. */ + orientation?: string; + } + export interface dxCircularGaugeOptions extends BaseGaugeOptions { + /** Specifies the options required to set the geometry of the dxCircularGauge widget. */ + geometry?: { + /** Specifies the end angle of the circular gauge's arc. */ + endAngle?: number; + /** Specifies the start angle of the circular gauge's arc. */ + startAngle?: number; + }; + /** Specifies gauge range container options. */ + rangeContainer?: CircularRangeContainer; + scale?: CircularScale; + } + /** A widget that represents a gauge with a circular scale. */ + export class dxCircularGauge extends dxBaseGauge { + constructor(element: JQuery, options?: dxCircularGaugeOptions); + constructor(element: Element, options?: dxCircularGaugeOptions); + } + export interface dxBarGaugeOptions extends viz.core.BaseWidgetOptions, SharedGaugeOptions { + /** Specifies a color for the remaining segment of the bar's track. */ + backgroundColor?: string; + /** Specifies a distance between bars in pixels. */ + barSpacing?: number; + /** Specifies a base value for bars. */ + baseValue?: number; + /** Specifies an end value for the gauge's invisible scale. */ + endValue?: number; + /** Defines the shape of the gauge's arc. */ + geometry?: { + /** Specifies the end angle of the bar gauge's arc. */ + endAngle?: number; + /** Specifies the start angle of the bar gauge's arc. */ + startAngle?: number; + }; + /** Specifies the options of the labels that accompany gauge bars. */ + label?: { + /** Specifies a color for the label connector text. */ + connectorColor?: string; + /** Specifies the width of the label connector in pixels. */ + connectorWidth?: number; + /** Specifies a callback function that returns a text for labels. */ + customizeText?: (barValue: { value: number; valueText: string }) => string; + /** Specifies font options for bar labels. */ + font?: viz.core.Font; + /** Specifies a format for bar labels. */ + format?: string; + /** Specifies the distance between the upper bar and bar labels in pixels. */ + indent?: number; + /** Specifies a precision for the formatted value displayed by labels. */ + precision?: number; + /** Specifies whether bar labels appear on a gauge or not. */ + visible?: boolean; + }; + /** Sets the name of the palette or an array of colors to be used for coloring the gauge range container. */ + palette?: string; + /** Defines the radius of the bar that is closest to the center relatively to the radius of the topmost bar. */ + relativeInnerRadius?: number; + /** Specifies a start value for the gauge's invisible scale. */ + startValue?: number; + /** Specifies the array of values to be indicated on a bar gauge. */ + values?: Array; + } + /** A circular bar widget. */ + export class dxBarGauge extends viz.core.BaseWidget { + constructor(element: JQuery, options?: dxBarGaugeOptions); + constructor(element: Element, options?: dxBarGaugeOptions); + /** Displays the loading indicator. */ + showLoadingIndicator(): void; + /** Conceals the loading indicator. */ + hideLoadingIndicator(): void; + /** Redraws the widget. */ + render(): void; + /** Returns an array of gauge values. */ + values(): Array; + /** Updates the values displayed by a gauge. */ + values(values: Array): void; + } +} +declare module DevExpress.viz.map { + /** This section describes the fields and methods that can be used in code to manipulate the Area object. */ + export interface Area { + /** Contains the element type. */ + type: string; + /** Return the value of an attribute. */ + attribute(name: string): any; + /** Provides information about the selection state of an area. */ + selected(): boolean; + /** Sets a new selection state for an area. */ + selected(state: boolean): void; + } + /** This section describes the fields and methods that can be used in code to manipulate the Markers object. */ + export interface Marker { + /** Contains the descriptive text accompanying the map marker. */ + text: string; + /** Contains the type of the element. */ + type: string; + /** Contains the URL of an image map marker. */ + url: string; + /** Contains the value of a bubble map marker. */ + value: number; + /** Contains the values of a pie map marker. */ + values: Array; + /** Returns the value of an attribute. */ + attribute(name: string): any; + /** Returns the coordinates of a specific marker. */ + coordinates(): Array; + /** Provides information about the selection state of a marker. */ + selected(): boolean; + /** Sets a new selection state for a marker. */ + selected(state: boolean): void; + } + export interface AreaSettings { + /** Specifies the width of the area border in pixels. */ + borderWidth?: number; + /** Specifies a color for the area border. */ + borderColor?: string; + click?: any; + /** Specifies a color for an area. */ + color?: string; + /** Specifies the function that customizes each area individually. */ + customize?: (areaInfo: Area) => AreaSettings; + /** Specifies a color for the area border when the area is hovered over. */ + hoveredBorderColor?: string; + /** Specifies the pixel-measured width of the area border when the area is hovered over. */ + hoveredBorderWidth?: number; + /** Specifies a color for an area when this area is hovered over. */ + hoveredColor?: string; + /** Specifies whether or not to change the appearance of an area when it is hovered over. */ + hoverEnabled?: boolean; + /** Configures area labels. */ + label?: { + /** Specifies the data field that provides data for area labels. */ + dataField?: string; + /** Enables area labels. */ + enabled?: boolean; + /** Specifies font options for area labels. */ + font?: viz.core.Font; + }; + /** Specifies the name of the palette or a custom range of colors to be used for coloring a map. */ + palette?: any; + /** Specifies the number of colors in a palette. */ + paletteSize?: number; + /** Allows you to paint areas with similar attributes in the same color. */ + colorGroups?: Array; + /** Specifies the field that provides data to be used for coloring areas. */ + colorGroupingField?: string; + /** Specifies a color for the area border when the area is selected. */ + selectedBorderColor?: string; + /** Specifies a color for an area when this area is selected. */ + selectedColor?: string; + /** Specifies the pixel-measured width of the area border when the area is selected. */ + selectedBorderWidth?: number; + selectionChanged?: (area: Area) => void; + /** Specifies whether single or multiple areas can be selected on a vector map. */ + selectionMode?: string; + } + export interface MarkerSettings { + /** Specifies a color for the marker border. */ + borderColor?: string; + /** Specifies the width of the marker border in pixels. */ + borderWidth?: number; + click?: any; + /** Specifies a color for a marker of the dot or bubble type. */ + color?: string; + /** Specifies the function that customizes each marker individually. */ + customize?: (markerInfo: Marker) => MarkerSettings; + font?: Object; + /** Specifies the pixel-measured width of the marker border when the marker is hovered over. */ + hoveredBorderWidth?: number; + /** Specifies a color for the marker border when the marker is hovered over. */ + hoveredBorderColor?: string; + /** Specifies a color for a marker of the dot or bubble type when this marker is hovered over. */ + hoveredColor?: string; + /** Specifies whether or not to change the appearance of a marker when it is hovered over. */ + hoverEnabled?: boolean; + /** Specifies marker label options. */ + label?: { + /** Enables marker labels. */ + enabled?: boolean; + /** Specifies font options for marker labels. */ + font?: viz.core.Font; + }; + /** Specifies the pixel-measured diameter of the marker that represents the biggest value. Setting this option makes sense only if you use markers of the bubble type. */ + maxSize?: number; + /** Specifies the pixel-measured diameter of the marker that represents the smallest value. Setting this option makes sense only if you use markers of the bubble type. */ + minSize?: number; + /** Specifies the opacity of markers. Setting this option makes sense only if you use markers of the bubble type. */ + opacity?: number; + /** Specifies the pixel-measured width of the marker border when the marker is selected. */ + selectedBorderWidth?: number; + /** Specifies a color for the marker border when the marker is selected. */ + selectedBorderColor?: string; + /** Specifies a color for a marker of the dot or bubble type when this marker is selected. */ + selectedColor?: string; + selectionChanged?: (marker: Marker) => void; + /** Specifies whether a single or multiple markers can be selected on a vector map. */ + selectionMode?: string; + /** Specifies the size of markers. Setting this option makes sense for any type of marker except bubble. */ + size?: number; + /** Specifies the type of markers to be used on the map. */ + type?: string; + /** Specifies the name of a palette or a custom set of colors to be used for coloring markers of the pie type. */ + palette?: any; + /** Allows you to paint markers with similar attributes in the same color. */ + colorGroups?: Array; + /** Specifies the field that provides data to be used for coloring markers. */ + colorGroupingField?: string; + /** Allows you to display bubbles with similar attributes in the same size. */ + sizeGroups?: Array; + /** Specifies the field that provides data to be used for sizing bubble markers. */ + sizeGroupingField?: string; + } + export interface dxVectorMapOptions extends viz.core.BaseWidgetOptions { + /** An object specifying options for the map areas. */ + areaSettings?: AreaSettings; + /** Specifies the options for the map background. */ + background?: { + /** Specifies a color for the background border. */ + borderColor?: string; + /** Specifies a color for the background. */ + color?: string; + }; + /** Specifies the positioning of a map in geographical coordinates. */ + bounds?: Array; + /** Specifies the options of the control bar. */ + controlBar?: { + /** Specifies a color for the outline of the control bar elements. */ + borderColor?: string; + /** Specifies a color for the inner area of the control bar elements. */ + color?: string; + /** Specifies whether or not to display the control bar. */ + enabled?: boolean; + /** Specifies the margin of the control bar in pixels. */ + margin?: number; + /** Specifies the position of the control bar. */ + horizontalAlignment?: string; + /** Specifies the position of the control bar. */ + verticalAlignment?: string; + }; + /** Specifies the appearance of the loading indicator. */ + loadingIndicator?: viz.core.LoadingIndicator; + /** Specifies a data source for the map area. */ + mapData?: any; + /** Specifies a data source for the map markers. */ + markers?: any; + /** An object specifying options for the map markers. */ + markerSettings?: MarkerSettings; + /** Specifies the size of the dxVectorMap widget. */ + size?: viz.core.Size; + /** Specifies the name of the theme to be applied. */ + theme?: Object; + /** Specifies tooltip options. */ + tooltip?: viz.core.Tooltip; + /** Configures map legends. */ + legends?: Array; + /** Specifies whether or not the map should respond when a user rolls the mouse wheel. */ + wheelEnabled?: boolean; + /** Specifies whether the map should respond to touch gestures. */ + touchEnabled?: boolean; + /** Disables the zooming capability. */ + zoomingEnabled?: boolean; + /** Specifies the geographical coordinates of the center for a map. */ + center?: Array; + centerChanged?: (center: Array) => void; + /** A handler for the centerChanged event. */ + onCenterChanged?: (e: { + center: Array; + component: dxVectorMap; + element: Element; + }) => void; + /** Specifies a number that is used to zoom a map initially. */ + zoomFactor?: number; + zoomFactorChanged?: (zoomFactor: number) => void; + /** A handler for the zoomFactorChanged event. */ + onZoomFactorChanged?: (e: { + zoomFactor: number; + component: dxVectorMap; + element: Element; + }) => void; + click?: any; + /** A handler for the click event. */ + onClick?: any; + /** A handler for the areaClick event. */ + onAreaClick?: any; + /** A handler for the areaSelectionChanged event. */ + onAreaSelectionChanged?: (e: { + target: Area; + component: dxVectorMap; + element: Element; + }) => void; + /** A handler for the markerClick event. */ + onMarkerClick?: any; + /** A handler for the markerSelectionChanged event. */ + onMarkerSelectionChanged?: (e: { + target: Marker; + component: dxVectorMap; + element: Element; + }) => void; + /** Disables the panning capability. */ + panningEnabled?: boolean; + } + export interface Legend extends viz.core.BaseLegend { + /** Specifies text for legend items. */ + customizeText?: (itemInfo: { start: number; end: number; index: number; color: string; size: number; }) => string; + /** Specifies text for a hint that appears when a user hovers the mouse pointer over the text of a legend item. */ + customizeHint?: (itemInfo: { start: number; end: number; index: number; color: string; size: number }) => string; + /** Specifies the source of data for the legend. */ + source?: string; + } + /** A vector map widget. */ + export class dxVectorMap extends viz.core.BaseWidget { + constructor(element: JQuery, options?: dxVectorMapOptions); + constructor(element: Element, options?: dxVectorMapOptions); + /** Displays the loading indicator. */ + showLoadingIndicator(): void; + /** Conceals the loading indicator. */ + hideLoadingIndicator(): void; + /** Redraws a widget. */ + render(): void; + /** Gets the current coordinates of the map center. */ + center(): Array; + /** Sets the coordinates of the map center. */ + center(centerCoordinates: Array): void; + /** Deselects all the selected areas on a map. The areas are displayed in their initial style after. */ + clearAreaSelection(): void; + /** Deselects all the selected markers on a map. The markers are displayed in their initial style after. */ + clearMarkerSelection(): void; + /** Deselects all the selected area and markers on a map at once. The areas and markers are displayed in their initial style after. */ + clearSelection(): void; + /** Converts client area coordinates into map coordinates. */ + convertCoordinates(x: number, y: number): Array; + /** Returns an array with all the map areas. */ + getAreas(): Array; + /** Returns an array with all the map markers. */ + getMarkers(): Array; + /** Gets the current coordinates of the map viewport. */ + viewport(): Array; + /** Sets the coordinates of the map viewport. */ + viewport(viewportCoordinates: Array): void; + /** Gets the current value of the map zoom factor. */ + zoomFactor(): number; + /** Sets the value of the map zoom factor. */ + zoomFactor(zoomFactor: number): void; + } +} +declare module DevExpress.viz.rangeSelector { + export interface dxRangeSelectorOptions extends viz.core.BaseWidgetOptions { + /** Specifies the options for the range selector's background. */ + background?: { + /** Specifies the background color for the dxRangeSelector. */ + color?: string; + /** Specifies image options. */ + image?: { + /** Specifies a location for the image in the background of a range selector. */ + location?: string; + /** Specifies the image's URL. */ + url?: string; + }; + /** Indicates whether or not the background (background color and/or image) is visible. */ + visible?: boolean; + }; + /** Specifies the dxRangeSelector's behavior options. */ + behavior?: { + /** Indicates whether or not you can swap sliders. */ + allowSlidersSwap?: boolean; + /** +Indicates whether or not animation is enabled. + */ + animationEnabled?: boolean; + /** Specifies when to call the onSelectedRangeChanged function. */ + callSelectedRangeChanged?: string; + /** Indicates whether or not an end user can specify the range using a mouse, without the use of sliders. */ + manualRangeSelectionEnabled?: boolean; + /** Indicates whether or not an end user can shift the selected range to the required location on a scale by clicking. */ + moveSelectedRangeByClick?: boolean; + /** Indicates whether to snap a slider to ticks. */ + snapToTicks?: boolean; + }; + /** Specifies the options required to display a chart as the range selector's background. */ + chart?: { + /** Specifies a coefficient for determining an indent from the bottom background boundary to the lowest chart point. */ + bottomIndent?: number; + /** An object defining the common configuration options for the chart’s series. */ + commonSeriesSettings?: viz.charts.CommonSeriesSettings; + /** An object providing options for managing data from a data source. */ + dataPrepareSettings?: { + /** Specifies whether or not to validate values from a data source. */ + checkTypeForAllData?: boolean; + /** Specifies whether or not to convert the values from a data source into the data type of an axis. */ + convertToAxisDataType?: boolean; + /** Specifies how to sort series points. */ + sortingMethod?: any; + }; + /** Specifies a value indicating whether all bars in a series must have the same width, or may have different widths if any points in other series are missing. */ + equalBarWidth?: any; + /** An object defining the chart’s series. */ + series?: Array; + /** Defines options for the series template. */ + seriesTemplate?: viz.charts.SeriesTemplate; + /** Specifies a coefficient for determining an indent from the background's top boundary to the topmost chart point. */ + topIndent?: number; + /** Specifies whether or not to filter the series points depending on their quantity. */ + useAggregation?: boolean; + /** Specifies options for the chart's value axis. */ + valueAxis?: { + /** Indicates whether or not the chart's value axis must be inverted. */ + inverted?: boolean; + /** Specifies the value to be raised to a power when generating ticks for a logarithmic value axis. */ + logarithmBase?: number; + /** Specifies the maximum value of the chart's value axis. */ + max?: number; + /** Specifies the minimum value of the chart's value axis. */ + min?: number; + /** Specifies the type of the value axis. */ + type?: string; + /** Specifies the desired type of axis values. */ + valueType?: string; + }; + }; + /** Specifies the color of the parent page element. */ + containerBackgroundColor?: string; + /** Specifies a data source for the scale values and for the chart at the background. */ + dataSource?: any; + /** Specifies the data source field that provides data for the scale. */ + dataSourceField?: string; + /** Specifies the appearance of the loading indicator. */ + loadingIndicator?: viz.core.LoadingIndicator; + /** Specifies the blank space in pixels between the dxRangeSelector widget's extreme elements and the boundaries of the area provided for the widget (see size). */ + margin?: viz.core.Margins; + /** Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates. */ + redrawOnResize?: boolean; + /** Specifies options of the range selector's scale. */ + scale?: { + /** Specifies the scale's end value. */ + endValue?: any; + /** Specifies common options for scale labels. */ + label?: { + /** Specifies a callback function that returns the text to be displayed in scale labels. */ + customizeText?: (scaleValue: { value: any; valueText: string; }) => string; + /** Specifies font options for the text displayed in the range selector's scale labels. */ + font?: viz.core.Font; + /** Specifies a format for the text displayed in scale labels. */ + format?: string; + /** Specifies a precision for the formatted value displayed in the scale labels. */ + precision?: number; + /** Specifies a spacing between scale labels and the background bottom edge. */ + topIndent?: number; + /** Specifies whether or not the scale's labels are visible. */ + visible?: boolean; + }; + /** Specifies the value to be raised to a power when generating ticks for a logarithmic scale. */ + logarithmBase?: number; + /** Specifies an interval between major ticks. */ + majorTickInterval?: any; + /** Specifies options for the date-time scale's markers. */ + marker?: { + /** Defines the options that can be set for the text that is displayed by the scale markers. */ + label?: { + /** Specifies a callback function that returns the text to be displayed in scale markers. */ + customizeText?: (markerValue: { value: any; valueText: string }) => string; + /** Specifies a format for the text displayed in scale markers. */ + format?: string; + }; + /** Specifies the height of the marker's separator. */ + separatorHeight?: number; + /** Specifies the space between the marker label and the marker separator. */ + textLeftIndent?: number; + /** Specifies the space between the marker's label and the top edge of the marker's separator. */ + textTopIndent?: number; + /** Specified the indent between the marker and the scale lables. */ + topIndent?: number; + /** Indicates whether scale markers are visible. */ + visible?: boolean; + }; + /** Specifies the maximum range that can be selected. */ + maxRange?: any; + /** Specifies the number of minor ticks between neighboring major ticks. */ + minorTickCount?: number; + /** +Specifies an interval between minor ticks. + */ + minorTickInterval?: any; + /** Specifies the minimum range that can be selected. */ + minRange?: any; + /** Specifies the height of the space reserved for the scale in pixels. */ + placeholderHeight?: number; + /** Indicates whether or not to set ticks of a date-time scale at the beginning of each date-time interval. */ + setTicksAtUnitBeginning?: boolean; + /** Specifies whether or not to show ticks for the boundary scale values, when neither major ticks nor minor ticks are created for these values. */ + showCustomBoundaryTicks?: boolean; + /** Indicates whether or not to show minor ticks on the scale. */ + showMinorTicks?: boolean; + /** Specifies the scale's start value. */ + startValue?: any; + /** Specifies options defining the appearance of scale ticks. */ + tick?: { + /** Specifies the color of scale ticks (both major and minor ticks). */ + color?: string; + /** Specifies the opacity of scale ticks (both major and minor ticks). */ + opacity?: number; + /** Specifies the width of the scale's ticks (both major and minor ticks). */ + width?: number; + }; + /** Specifies the type of the scale. */ + type?: string; + /** Specifies whether or not to expand the current tick interval if labels overlap each other. */ + useTicksAutoArrangement?: boolean; + /** Specifies the type of values on the scale. */ + valueType?: string; + /** Specifies the order of arguments on a discrete scale. */ + categories?: Array; + }; + /** Specifies the range to be selected when displaying the dxRangeSelector. */ + selectedRange?: { + /** Specifies the start value of the range to be selected when displaying the dxRangeSelector widget on a page. */ + startValue?: any; + /** Specifies the end value of the range to be selected when displaying the dxRangeSelector widget on a page. */ + endValue?: any; + }; + selectedRangeChanged?: (selectedRange: { startValue: any; endValue: any; }) => void; + /** A handler for the selectedRangeChanged event. */ + onSelectedRangeChanged?: (e: { + startValue: any; + endValue: any; + component: dxRangeSelector; + element: Element; + }) => void; + /** Specifies the options of the range selector's shutters. */ + shutter?: { + /** Specifies shutter color. */ + color?: string; + /** Specifies the opacity of the color of shutters. */ + opacity?: number; + }; + /** Specifies in pixels the size of the dxRangeSelector widget. */ + size?: viz.core.Size; + /** Specifies the appearance of the range selector's slider handles. */ + sliderHandle?: { + /** Specifies the color of the slider handles. */ + color?: string; + /** Specifies the opacity of the slider handles. */ + opacity?: number; + /** Specifies the width of the slider handles. */ + width?: number; + }; + /** Defines the options of the range selector slider markers. */ + sliderMarker?: { + /** Specifies the color of the slider markers. */ + color?: string; + /** Specifies a callback function that returns the text to be displayed by slider markers. */ + customizeText?: (scaleValue: { value: any; valueText: any; }) => string; + /** Specifies font options for the text displayed by the range selector slider markers. */ + font?: viz.core.Font; + /** Specifies a format for the text displayed in slider markers. */ + format?: string; + /** Specifies the color used for the slider marker text when the currently selected range does not match the minRange and maxRange values. */ + invalidRangeColor?: string; + /** Specifies the empty space between the marker's border and the marker’s text. */ + padding?: number; + /** Specifies in pixels the height and width of the space reserved for the range selector slider markers. */ + placeholderSize?: { + /** Specifies the height of the placeholder for the left and right slider markers. */ + height?: number; + /** Specifies the width of the placeholder for the left and right slider markers. */ + width?: { + /** Specifies the width of the left slider marker's placeholder. */ + left?: number; + /** Specifies the width of the right slider marker's placeholder. */ + right?: number; + }; + }; + /** Specifies a precision for the formatted value displayed in slider markers. */ + precision?: number; + /** Indicates whether or not the slider markers are visible. */ + visible?: boolean; + }; + /** Sets the name of the theme to be used by the range selector. */ + theme?: string; + } + /** A widget that allows end users to select a range of values on a scale. */ + export class dxRangeSelector extends viz.core.BaseWidget { + constructor(element: JQuery, options?: dxRangeSelectorOptions); + constructor(element: Element, options?: dxRangeSelectorOptions); + /** Displays the loading indicator. */ + showLoadingIndicator(): void; + /** Conceals the loading indicator. */ + hideLoadingIndicator(): void; + /** Redraws a widget. */ + render(skipChartAnimation?: boolean): void; + /** Returns the currently selected range. */ + getSelectedRange(): { startValue: any; endValue: any; }; + /** Sets a specified range. */ + setSelectedRange(selectedRange: { startValue: any; endValue: any; }): void; + } +} +declare module DevExpress.viz.sparklines { + export interface SparklineTooltip extends viz.core.Tooltip { + /** Specifies how a tooltip is horizontally aligned relative to the graph. */ + horizontalAlignment?: string; + /** Specifies how a tooltip is vertically aligned relative to the graph. */ + verticalAlignment?: string; + } + export interface BaseSparklineOptions extends viz.core.BaseWidgetOptions { + /** Specifies the blank space between the widget's extreme elements and the boundaries of the area provided for the widget in pixels. */ + margin?: viz.core.Margins; + /** Specifies the size of the widget. */ + size?: viz.core.Size; + /** Specifies the name of the theme to be applied. */ + theme?: string; + /** Specifies tooltip options. */ + tooltip?: SparklineTooltip; + } + /** Overridden by descriptions for particular widgets. */ + export class BaseSparkline extends viz.core.BaseWidget { + /** Redraws a widget. */ + render(): void; + } + export interface dxBulletOptions extends BaseSparkline { + /** Specifies a color for the bullet bar. */ + color?: string; + /** Specifies an end value for the invisible scale. */ + endScaleValue?: number; + /** Specifies whether or not to show the target line. */ + showTarget?: boolean; + /** Specifies whether or not to show the line indicating zero on the invisible scale. */ + showZeroLevel?: boolean; + /** Specifies a start value for the invisible scale. */ + startScaleValue?: number; + /** Specifies the value indicated by the target line. */ + target?: number; + /** Specifies a color for both the target and zero level lines. */ + targetColor?: string; + /** Specifies the width of the target line. */ + targetWidth?: number; + /** Specifies the primary value indicated by the bullet bar. */ + value?: number; + } + /** A bullet graph widget. */ + export class dxBullet extends BaseSparkline { + constructor(element: JQuery, options?: dxBulletOptions); + constructor(element: Element, options?: dxBulletOptions); + } + export interface dxSparklineOptions extends BaseSparklineOptions { + /** Specifies the data source field that provides arguments for a sparkline. */ + argumentField?: string; + /** Sets a color for the bars indicating negative values. Available for a sparkline of the bar type only. */ + barNegativeColor?: string; + /** Sets a color for the bars indicating positive values. Available for a sparkline of the bar type only. */ + barPositiveColor?: string; + /** Specifies a data source for the sparkline. */ + dataSource?: Array; + /** Sets a color for the boundary of both the first and last points on a sparkline. */ + firstLastColor?: string; + /** Specifies whether a sparkline ignores null data points or not. */ + ignoreEmptyPoints?: boolean; + /** Sets a color for a line on a sparkline. Available for the sparklines of the line- and area-like types. */ + lineColor?: string; + /** Specifies a width for a line on a sparkline. Available for the sparklines of the line- and area-like types. */ + lineWidth?: number; + /** Sets a color for the bars indicating the values that are less than the winloss threshold. Available for a sparkline of the winloss type only. */ + lossColor?: string; + /** Sets a color for the boundary of the maximum point on a sparkline. */ + maxColor?: string; + /** Sets a color for the boundary of the minimum point on a sparkline. */ + minColor?: string; + /** Sets a color for points on a sparkline. Available for the sparklines of the line- and area-like types. */ + pointColor?: string; + /** Specifies the diameter of sparkline points in pixels. Available for the sparklines of line- and area-like types. */ + pointSize?: number; + /** Specifies a symbol to use as a point marker on a sparkline. Available for the sparklines of the line- and area-like types. */ + pointSymbol?: string; + /** Specifies whether or not to indicate both the first and last values on a sparkline. */ + showFirstLast?: boolean; + /** Specifies whether or not to indicate both the minimum and maximum values on a sparkline. */ + showMinMax?: boolean; + /** Determines the type of a sparkline. */ + type?: string; + /** Specifies the data source field that provides values for a sparkline. */ + valueField?: string; + /** Sets a color for the bars indicating the values greater than a winloss threshold. Available for a sparkline of the winloss type only. */ + winColor?: string; + /** Specifies a value that serves as a threshold for the sparkline of the winloss type. */ + winlossThreshold?: number; + } + /** A sparkline widget. */ + export class dxSparkline extends BaseSparkline { + constructor(element: JQuery, options?: dxSparklineOptions); + constructor(element: Element, options?: dxSparklineOptions); + } +} +interface JQuery { + dxProgressBar(): JQuery; + dxProgressBar(options: "instance"): DevExpress.ui.dxProgressBar; + dxProgressBar(options: string): any; + dxProgressBar(options: string, ...params: any[]): any; + dxProgressBar(options: DevExpress.ui.dxProgressBarOptions): JQuery; + dxSlider(): JQuery; + dxSlider(options: "instance"): DevExpress.ui.dxSlider; + dxSlider(options: string): any; + dxSlider(options: string, ...params: any[]): any; + dxSlider(options: DevExpress.ui.dxSliderOptions): JQuery; + dxRangeSlider(): JQuery; + dxRangeSlider(options: "instance"): DevExpress.ui.dxRangeSlider; + dxRangeSlider(options: string): any; + dxRangeSlider(options: string, ...params: any[]): any; + dxRangeSlider(options: DevExpress.ui.dxRangeSliderOptions): JQuery; + dxFileUploader(): JQuery; + dxFileUploader(options: "instance"): DevExpress.ui.dxFileUploader; + dxFileUploader(options: string): any; + dxFileUploader(options: string, ...params: any[]): any; + dxFileUploader(options: DevExpress.ui.dxFileUploaderOptions): JQuery; + dxValidator(): JQuery; + dxValidator(options: "instance"): DevExpress.ui.dxValidator; + dxValidator(options: string): any; + dxValidator(options: string, ...params: any[]): any; + dxValidationGroup(): JQuery; + dxValidationGroup(options: "instance"): DevExpress.ui.dxValidationGroup; + dxValidationGroup(options: string): any; + dxValidationGroup(options: string, ...params: any[]): any; + dxValidationSummary(): JQuery; + dxValidationSummary(options: "instance"): DevExpress.ui.dxValidationSummary; + dxValidationSummary(options: string): any; + dxValidationSummary(options: string, ...params: any[]): any; + dxTooltip(): JQuery; + dxTooltip(options: "instance"): DevExpress.ui.dxTooltip; + dxTooltip(options: string): any; + dxTooltip(options: string, ...params: any[]): any; + dxTooltip(options: DevExpress.ui.dxTooltipOptions): JQuery; + dxDropDownList(): JQuery; + dxDropDownList(options: "instance"): DevExpress.ui.dxDropDownList; + dxDropDownList(options: string): any; + dxDropDownList(options: string, ...params: any[]): any; + dxDropDownList(options: DevExpress.ui.dxDropDownListOptions): JQuery; + dxToolbar(): JQuery; + dxToolbar(options: "instance"): DevExpress.ui.dxToolbar; + dxToolbar(options: string): any; + dxToolbar(options: string, ...params: any[]): any; + dxToolbar(options: DevExpress.ui.dxToolbarOptions): JQuery; + dxToast(): JQuery; + dxToast(options: "instance"): DevExpress.ui.dxToast; + dxToast(options: string): any; + dxToast(options: string, ...params: any[]): any; + dxToast(options: DevExpress.ui.dxToastOptions): JQuery; + dxTextEditor(): JQuery; + dxTextEditor(options: "instance"): DevExpress.ui.dxTextEditor; + dxTextEditor(options: string): any; + dxTextEditor(options: string, ...params: any[]): any; + dxTextEditor(options: DevExpress.ui.dxTextEditorOptions): JQuery; + dxTextBox(): JQuery; + dxTextBox(options: "instance"): DevExpress.ui.dxTextBox; + dxTextBox(options: string): any; + dxTextBox(options: string, ...params: any[]): any; + dxTextBox(options: DevExpress.ui.dxTextBoxOptions): JQuery; + dxTextArea(): JQuery; + dxTextArea(options: "instance"): DevExpress.ui.dxTextArea; + dxTextArea(options: string): any; + dxTextArea(options: string, ...params: any[]): any; + dxTextArea(options: DevExpress.ui.dxTextAreaOptions): JQuery; + dxTabs(): JQuery; + dxTabs(options: "instance"): DevExpress.ui.dxTabs; + dxTabs(options: string): any; + dxTabs(options: string, ...params: any[]): any; + dxTabs(options: DevExpress.ui.dxTabsOptions): JQuery; + dxTabPanel(): JQuery; + dxTabPanel(options: "instance"): DevExpress.ui.dxTabPanel; + dxTabPanel(options: string): any; + dxTabPanel(options: string, ...params: any[]): any; + dxTabPanel(options: DevExpress.ui.dxTabPanelOptions): JQuery; + dxSelectBox(): JQuery; + dxSelectBox(options: "instance"): DevExpress.ui.dxSelectBox; + dxSelectBox(options: string): any; + dxSelectBox(options: string, ...params: any[]): any; + dxSelectBox(options: DevExpress.ui.dxSelectBoxOptions): JQuery; + dxScrollView(): JQuery; + dxScrollView(options: "instance"): DevExpress.ui.dxScrollView; + dxScrollView(options: string): any; + dxScrollView(options: string, ...params: any[]): any; + dxScrollView(options: DevExpress.ui.dxScrollViewOptions): JQuery; + dxScrollable(): JQuery; + dxScrollable(options: "instance"): DevExpress.ui.dxScrollable; + dxScrollable(options: string): any; + dxScrollable(options: string, ...params: any[]): any; + dxScrollable(options: DevExpress.ui.dxScrollableOptions): JQuery; + dxRadioGroup(): JQuery; + dxRadioGroup(options: "instance"): DevExpress.ui.dxRadioGroup; + dxRadioGroup(options: string): any; + dxRadioGroup(options: string, ...params: any[]): any; + dxRadioGroup(options: DevExpress.ui.dxRadioGroupOptions): JQuery; + dxPopup(): JQuery; + dxPopup(options: "instance"): DevExpress.ui.dxPopup; + dxPopup(options: string): any; + dxPopup(options: string, ...params: any[]): any; + dxPopup(options: DevExpress.ui.dxPopupOptions): JQuery; + dxPopover(): JQuery; + dxPopover(options: "instance"): DevExpress.ui.dxPopover; + dxPopover(options: string): any; + dxPopover(options: string, ...params: any[]): any; + dxPopover(options: DevExpress.ui.dxPopoverOptions): JQuery; + dxOverlay(): JQuery; + dxOverlay(options: "instance"): DevExpress.ui.dxOverlay; + dxOverlay(options: string): any; + dxOverlay(options: string, ...params: any[]): any; + dxOverlay(options: DevExpress.ui.dxOverlayOptions): JQuery; + dxNumberBox(): JQuery; + dxNumberBox(options: "instance"): DevExpress.ui.dxNumberBox; + dxNumberBox(options: string): any; + dxNumberBox(options: string, ...params: any[]): any; + dxNumberBox(options: DevExpress.ui.dxNumberBoxOptions): JQuery; + dxNavBar(): JQuery; + dxNavBar(options: "instance"): DevExpress.ui.dxNavBar; + dxNavBar(options: string): any; + dxNavBar(options: string, ...params: any[]): any; + dxNavBar(options: DevExpress.ui.dxNavBarOptions): JQuery; + dxMultiView(): JQuery; + dxMultiView(options: "instance"): DevExpress.ui.dxMultiView; + dxMultiView(options: string): any; + dxMultiView(options: string, ...params: any[]): any; + dxMultiView(options: DevExpress.ui.dxMultiViewOptions): JQuery; + dxMap(): JQuery; + dxMap(options: "instance"): DevExpress.ui.dxMap; + dxMap(options: string): any; + dxMap(options: string, ...params: any[]): any; + dxMap(options: DevExpress.ui.dxMapOptions): JQuery; + dxLookup(): JQuery; + dxLookup(options: "instance"): DevExpress.ui.dxLookup; + dxLookup(options: string): any; + dxLookup(options: string, ...params: any[]): any; + dxLookup(options: DevExpress.ui.dxLookupOptions): JQuery; + dxLoadPanel(): JQuery; + dxLoadPanel(options: "instance"): DevExpress.ui.dxLoadPanel; + dxLoadPanel(options: string): any; + dxLoadPanel(options: string, ...params: any[]): any; + dxLoadPanel(options: DevExpress.ui.dxLoadPanelOptions): JQuery; + dxLoadIndicator(): JQuery; + dxLoadIndicator(options: "instance"): DevExpress.ui.dxLoadIndicator; + dxLoadIndicator(options: string): any; + dxLoadIndicator(options: string, ...params: any[]): any; + dxLoadIndicator(options: DevExpress.ui.dxLoadIndicatorOptions): JQuery; + dxList(): JQuery; + dxList(options: "instance"): DevExpress.ui.dxList; + dxList(options: string): any; + dxList(options: string, ...params: any[]): any; + dxList(options: DevExpress.ui.dxListOptions): JQuery; + dxGallery(): JQuery; + dxGallery(options: "instance"): DevExpress.ui.dxGallery; + dxGallery(options: string): any; + dxGallery(options: string, ...params: any[]): any; + dxGallery(options: DevExpress.ui.dxGalleryOptions): JQuery; + dxDropDownEditor(): JQuery; + dxDropDownEditor(options: "instance"): DevExpress.ui.dxDropDownEditor; + dxDropDownEditor(options: string): any; + dxDropDownEditor(options: string, ...params: any[]): any; + dxDropDownEditor(options: DevExpress.ui.dxDropDownEditorOptions): JQuery; + dxDateBox(): JQuery; + dxDateBox(options: "instance"): DevExpress.ui.dxDateBox; + dxDateBox(options: string): any; + dxDateBox(options: string, ...params: any[]): any; + dxDateBox(options: DevExpress.ui.dxDateBoxOptions): JQuery; + dxCheckBox(): JQuery; + dxCheckBox(options: "instance"): DevExpress.ui.dxCheckBox; + dxCheckBox(options: string): any; + dxCheckBox(options: string, ...params: any[]): any; + dxCheckBox(options: DevExpress.ui.dxCheckBoxOptions): JQuery; + dxBox(): JQuery; + dxBox(options: "instance"): DevExpress.ui.dxBox; + dxBox(options: string): any; + dxBox(options: string, ...params: any[]): any; + dxBox(options: DevExpress.ui.dxBoxOptions): JQuery; + dxButton(): JQuery; + dxButton(options: "instance"): DevExpress.ui.dxButton; + dxButton(options: string): any; + dxButton(options: string, ...params: any[]): any; + dxButton(options: DevExpress.ui.dxButtonOptions): JQuery; + dxCalendar(): JQuery; + dxCalendar(options: "instance"): DevExpress.ui.dxCalendar; + dxCalendar(options: string): any; + dxCalendar(options: string, ...params: any[]): any; + dxCalendar(options: DevExpress.ui.dxCalendarOptions): JQuery; + dxAccordion(): JQuery; + dxAccordion(options: "instance"): DevExpress.ui.dxAccordion; + dxAccordion(options: string): any; + dxAccordion(options: string, ...params: any[]): any; + dxAccordion(options: DevExpress.ui.dxAccordionOptions): JQuery; + dxAutocomplete(): JQuery; + dxAutocomplete(options: "instance"): DevExpress.ui.dxAutocomplete; + dxAutocomplete(options: string): any; + dxAutocomplete(options: string, ...params: any[]): any; + dxAutocomplete(options: DevExpress.ui.dxAutocompleteOptions): JQuery; + dxTileView(): JQuery; + dxTileView(options: "instance"): DevExpress.ui.dxTileView; + dxTileView(options: string): any; + dxTileView(options: string, ...params: any[]): any; + dxTileView(options: DevExpress.ui.dxTileViewOptions): JQuery; + dxSwitch(): JQuery; + dxSwitch(options: "instance"): DevExpress.ui.dxSwitch; + dxSwitch(options: string): any; + dxSwitch(options: string, ...params: any[]): any; + dxSwitch(options: DevExpress.ui.dxSwitchOptions): JQuery; + dxSlideOut(): JQuery; + dxSlideOut(options: "instance"): DevExpress.ui.dxSlideOut; + dxSlideOut(options: string): any; + dxSlideOut(options: string, ...params: any[]): any; + dxSlideOut(options: DevExpress.ui.dxSlideOutOptions): JQuery; + dxPivot(): JQuery; + dxPivot(options: "instance"): DevExpress.ui.dxPivot; + dxPivot(options: string): any; + dxPivot(options: string, ...params: any[]): any; + dxPivot(options: DevExpress.ui.dxPivotOptions): JQuery; + dxPanorama(): JQuery; + dxPanorama(options: "instance"): DevExpress.ui.dxPanorama; + dxPanorama(options: string): any; + dxPanorama(options: string, ...params: any[]): any; + dxPanorama(options: DevExpress.ui.dxPanoramaOptions): JQuery; + dxActionSheet(): JQuery; + dxActionSheet(options: "instance"): DevExpress.ui.dxActionSheet; + dxActionSheet(options: string): any; + dxActionSheet(options: string, ...params: any[]): any; + dxActionSheet(options: DevExpress.ui.dxActionSheetOptions): JQuery; + dxDropDownMenu(): JQuery; + dxDropDownMenu(options: "instance"): DevExpress.ui.dxDropDownMenu; + dxDropDownMenu(options: string): any; + dxDropDownMenu(options: string, ...params: any[]): any; + dxDropDownMenu(options: DevExpress.ui.dxDropDownMenuOptions): JQuery; + dxTreeView(): JQuery; + dxTreeView(options: "instance"): DevExpress.ui.dxTreeView; + dxTreeView(options: string): any; + dxTreeView(options: string, ...params: any[]): any; + dxTreeView(options: DevExpress.ui.dxTreeViewOptions): JQuery; + dxMenuBase(): JQuery; + dxMenuBase(options: "instance"): DevExpress.ui.dxMenuBase; + dxMenuBase(options: string): any; + dxMenuBase(options: string, ...params: any[]): any; + dxMenuBase(options: DevExpress.ui.dxMenuBaseOptions): JQuery; + dxMenu(): JQuery; + dxMenu(options: "instance"): DevExpress.ui.dxMenu; + dxMenu(options: string): any; + dxMenu(options: string, ...params: any[]): any; + dxMenu(options: DevExpress.ui.dxMenuOptions): JQuery; + dxContextMenu(): JQuery; + dxContextMenu(options: "instance"): DevExpress.ui.dxContextMenu; + dxContextMenu(options: string): any; + dxContextMenu(options: string, ...params: any[]): any; + dxContextMenu(options: DevExpress.ui.dxContextMenuOptions): JQuery; + dxColorBox(): JQuery; + dxColorBox(options: "instance"): DevExpress.ui.dxColorBox; + dxColorBox(options: string): any; + dxColorBox(options: string, ...params: any[]): any; + dxColorBox(options: DevExpress.ui.dxColorBoxOptions): JQuery; + dxDataGrid(): JQuery; + dxDataGrid(options: "instance"): DevExpress.ui.dxDataGrid; + dxDataGrid(options: string): any; + dxDataGrid(options: string, ...params: any[]): any; + dxDataGrid(options: DevExpress.ui.dxDataGridOptions): JQuery; + dxChart(options?: DevExpress.viz.charts.dxChartOptions): JQuery; + dxChart(methodName: string, ...params: any[]): any; + dxChart(methodName: "instance"): DevExpress.viz.charts.dxChart; + dxPieChart(options?: DevExpress.viz.charts.dxPieChartOptions): JQuery; + dxPieChart(methodName: string, ...params: any[]): any; + dxPieChart(methodName: "instance"): DevExpress.viz.charts.dxPieChart; + dxPolarChart(options?: DevExpress.viz.charts.dxPolarChartOptions): JQuery; + dxPolarChart(methodName: string, ...params: any[]): any; + dxPolarChart(methodName: "instance"): DevExpress.viz.charts.dxPolarChart; + dxLinearGauge(options?: DevExpress.viz.gauges.dxLinearGaugeOptions): JQuery; + dxLinearGauge(methodName: string, ...params: any[]): any; + dxLinearGauge(methodName: "instance"): DevExpress.viz.gauges.dxLinearGauge; + dxCircularGauge(options?: DevExpress.viz.gauges.dxCircularGaugeOptions): JQuery; + dxCircularGauge(methodName: string, ...params: any[]): any; + dxCircularGauge(methodName: "instance"): DevExpress.viz.gauges.dxCircularGauge; + dxBarGauge(options?: DevExpress.viz.gauges.dxBarGaugeOptions): JQuery; + dxBarGauge(methodName: string, ...params: any[]): any; + dxBarGauge(methodName: "instance"): DevExpress.viz.gauges.dxBarGauge; + dxRangeSelector(options?: DevExpress.viz.rangeSelector.dxRangeSelectorOptions): JQuery; + dxRangeSelector(methodName: string, ...params: any[]): any; + dxRangeSelector(methodName: "instance"): DevExpress.viz.rangeSelector.dxRangeSelector; + dxVectorMap(options?: DevExpress.viz.map.dxVectorMapOptions): JQuery; + dxVectorMap(methodName: string, ...params: any[]): any; + dxVectorMap(methodName: "instance"): DevExpress.viz.map.dxVectorMap; + dxBullet(options?: DevExpress.viz.sparklines.dxBulletOptions): JQuery; + dxBullet(methodName: string, ...params: any[]): any; + dxBullet(methodName: "instance"): DevExpress.viz.sparklines.dxBullet; + dxSparkline(options?: DevExpress.viz.sparklines.dxSparklineOptions): JQuery; + dxSparkline(methodName: string, ...params: any[]): any; + dxSparkline(methodName: "instance"): DevExpress.viz.sparklines.dxSparkline; +} \ No newline at end of file diff --git a/devextreme/dx.devextreme.d.ts b/devextreme/dx.devextreme.d.ts index a1d361f54..4825e80b2 100644 --- a/devextreme/dx.devextreme.d.ts +++ b/devextreme/dx.devextreme.d.ts @@ -1,11 +1,11 @@ -// Type definitions for DevExtreme 14.2.7 +// Type definitions for DevExtreme 15.1.3 // Project: http://js.devexpress.com/ // Definitions by: DevExpress Inc. // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// -declare module DevExpress { +declare module DevExpress { /** A mixin that provides a capability to fire and subscribe to events. */ export interface EventsMixin { /** Subscribes to a specified event. */ @@ -35,7 +35,7 @@ declare module DevExpress { brokenRules: any[]; validators: IValidator[]; } - export interface GroupConfig extends EventsMixin { + export interface GroupConfig extends EventsMixin { group: any; validators: IValidator[]; validate(): ValidationGroupValidationResult; @@ -56,7 +56,7 @@ declare module DevExpress { /** Validates the rules that are defined within the dxValidator objects that are registered for the specified ViewModel. */ export function validateModel(model: Object): ValidationGroupValidationResult; /** Registers all the dxValidator objects by which the fields of the specified ViewModel are extended. */ - export function registerModelForValidation(model: Object): void; + export function registerModelForValidation(model: Object) : void; } export var hardwareBackButton: JQueryCallback; /** Processes the hardware back button click. */ @@ -86,21 +86,23 @@ declare module DevExpress { } /** An object that serves as a namespace for the methods that are used to animate UI elements. */ export module fx { - /** The animation object specifies the widget animation options. */ + /** Defines animation options. */ export interface AnimationOptions { /** A function called after animation is completed. */ complete?: (element: JQuery, config: AnimationOptions) => void; /** A number specifying wait time before animation execution. */ delay?: number; + /** A number specifying the time period to wait before the animation of the next stagger item starts. */ + staggerDelay?: number; /** A number specifying the time in milliseconds spent on animation. */ duration?: number; /** A string specifying the type of an easing function used for animation. */ easing?: string; - /** Specifies the initial widget animation state. */ + /** Specifies the initial animation state. */ from?: any; /** A function called before animation is started. */ start?: (element: JQuery, config: AnimationOptions) => void; - /** Specifies the initial widget animation state. */ + /** Specifies a final animation state. */ to?: any; /** A string value specifying the animation type. */ type?: string; @@ -108,12 +110,39 @@ declare module DevExpress { direction?: string; } /** Animates the specified element. */ - export function animate(element: HTMLElement, config: Object): Object; + export function animate(element: HTMLElement, config: AnimationOptions): Object; /** Returns a value indicating whether the specified element is being animated. */ export function isAnimating(element: HTMLElement): boolean; /** Stops the animation. */ export function stop(element: HTMLElement, jumpToEnd: boolean): void; } + /** The manager that performs several specified animations at a time. */ + export class TransitionExecutor { + /** Deletes all the animations registered in the Transition Executor by using the enter(elements, animation) and leave(elements, animation) methods. */ + reset(): void; + /** Registers a set of elements that should be animated as "entering" using the specified animation configuration. */ + enter(elements: JQuery, animation: any): void; + /** Registers a set of elements that should be animated as "leaving" using the specified animation configuration. */ + leave(elements: JQuery, animation: any): void; + /** Starts all the animations registered using the enter(elements, animation) and leave(elements, animation) methods beforehand. */ + start(config: Object): JQueryPromise; + } + export class AnimationPresetCollection { + /** Resets all the changes made in the animation repository. */ + resetToDefaults(): void; + /** Deletes the specified animation or clears all the animation repository, if an animation name is not passed. */ + clear(name: string): void; + /** Adds the specified animation preset to the animation repository by the specified name. */ + registerPreset(name: string, config: any): void; + /** Applies the changes made in the animation repository. */ + applyChanges(): void; + /** Returns the configuration of the animation found in the animation repository by the specified name for the current device. */ + getPreset(name: string): void; + /** Registers predefined animations in the animation repository. */ + registerDefaultPresets(): void; + } + /** A repository of animations. */ + export var animationPresets: AnimationPresetCollection; /** An object that serves as a namespace for the methods and events specifying information on the current device. */ export module devices { /** The device object defines the device on which the application is running. */ @@ -132,12 +161,12 @@ declare module DevExpress { platform?: string; /** Indicates whether or not the device type is 'tablet'. */ tablet?: boolean; - /** Indicates whether or not the device platform is Tizen. */ - tizen?: boolean; /** Specifies an array with the major and minor versions of the device platform. */ version?: Array; /** Indicates whether or not the device platform is Windows8. */ win8?: boolean; + /** Specifies a performance grade of the current device. */ + grade?: string; } export var orientationChanged: JQueryCallback; /** Overrides actual device information to force the application to operate as if it was running on the specified device. */ @@ -167,6 +196,8 @@ declare module DevExpress { offset?: string; } export interface ComponentOptions { + /** A handler for the initialized event. */ + onInitialized?: Function; /** A handler for the optionChanged event. */ onOptionChanged?: Function; /** A handler for the disposing event. */ @@ -193,6 +224,10 @@ declare module DevExpress { export interface DOMComponentOptions extends ComponentOptions { /** Specifies whether or not the current component supports a right-to-left representation. */ rtlEnabled?: boolean; + /** Specifies the height of the widget. */ + height?: any; + /** Specifies the width of the widget. */ + width?: any; } /** A base class for all components. */ export class DOMComponent extends Component { @@ -339,17 +374,12 @@ declare module DevExpress { /** Creates the Query object for the underlying array. */ createQuery(): Query; } - interface Promise { + interface Promise { then(doneFn?: Function, failFn?: Function, progressFn?: Function): Promise; } export interface CustomStoreOptions extends StoreOptions { /** The user implementation of the byKey(key, extraOptions) method. */ byKey?: (key: any) => Promise; - /** - * User implementation of the byKey(key, extraOptions) method. - * @deprecated byKey.md - */ - lookup?: (key: any) => Promise; /** The user implementation of the insert(values) method. */ insert?: (values: Object) => Promise; /** The user implementation of the load(options) method. */ @@ -622,26 +652,19 @@ declare module DevExpress { } /** An object that serves as a namespace for DevExtreme UI widgets as well as for methods implementing UI logic in DevExtreme sites/applications. */ export module ui { - /** - * Sets parameters for the viewport meta tag. - * @deprecated Use the "DevExpress.utils.initMobileViewport" option instead. - */ - export function initViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void; export interface WidgetOptions extends DOMComponentOptions { /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ activeStateEnabled?: boolean; /** A Boolean value specifying whether or not the widget can respond to user interaction. */ disabled?: boolean; - /** Specifies the height of the widget. */ - height?: any; /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ hoverStateEnabled?: boolean; /** Specifies whether or not the widget can be focused. */ focusStateEnabled?: boolean; + /** Specifies a shortcut key that sets focus on the widget element. */ + accessKey?: string; /** A Boolean value specifying whether or not the widget is visible. */ visible?: boolean; - /** Specifies the width of the widget. */ - width?: any; /** Specifies the widget tab index. */ tabIndex?: number; /** Specifies the text of the hint displayed for the widget. */ @@ -654,6 +677,8 @@ declare module DevExpress { repaint(): void; /** Sets focus on the widget. */ focus(): void; + /** Registers a handler for pressing of the specified key. */ + registerKeyHandler(key: string, handler: Function): void; } export interface CollectionWidgetOptions extends WidgetOptions { /** A data source used to fetch data to be displayed by the widget. */ @@ -741,10 +766,10 @@ declare module DevExpress { /** Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed. */ validationMessageMode?: string; } - /** A base class for editors. */ - export class Editor extends Widget { - /** Resets the editor's value to undefined. */ - reset(): void; + /** @docid Editor */ + export class Editor extends Widget { + /** @docid EditorMethods_reset */ + reset(): void; } /** An object that serves as a namespace for methods displaying a message in an application/site. */ export var dialog: { @@ -781,7 +806,138 @@ declare module DevExpress { }; } } -declare module DevExpress.framework { +declare module DevExpress.data { + export interface XmlaStoreOptions { + /** The HTTP address to an XMLA OLAP server. */ + url?: string; + /** The name of the database associated with the Store. */ + catalog?: string; + /** The cube name. */ + cube?: string; + } + /** A Store that provides access to an OLAP cube using the XMLA standard. */ + export class XmlaStore { + constructor(options: XmlaStoreOptions); + } + export interface PivotGridField { + index?: number; + /** A boolean value specifying whether or not the field is visible in the pivot grid and the Field Chooser. */ + visible?: boolean; + /** Name of the data source field containing data for the pivot grid field. */ + dataField?: string; + /** A caption that will be displayed in the pivot grid's field chooser to identify the field. */ + caption?: string; + /** Specifies a type of field values. */ + dataType?: string; + /** Specifies how the values of the current field are combined into groups. Cannot be used for the XmlaStore store type. */ + groupInterval?: any; + /** Specifies how to aggregate field data. Cannot be used for th XmlaStore store type. */ + summaryType?: string; + /** Allows you to use a custom aggregate function to calculate the summary values. Cannot be used for the XmlaStore store type. */ + calculateCustomSummary?: (options: { + summaryProcess?: string; + value?: any; + totalValue?: any; + }) => void; + /** Specifies the function that determines how to split data from the data source into ranges for header items. Cannot be used for the XmlaStore store type. */ + selector?: (data: Object) => any; + /** Type of the area where the field is located. */ + area?: string; + /** Index among the other fields displayed within the same area. */ + areaIndex?: number; + /** The name of the folder in which the field is located. */ + displayFolder?: string; + /** The name of the group to which the field belongs. */ + groupName?: string; + /** The index of the field within a group. */ + groupIndex?: number; + /** Specifies the initial sort order of field values. */ + sortOrder?: string; + /** Specifies how field data should be sorted. Can be used for the XmlaStore store type only. */ + sortBy?: string; + /** Specifies the data field against which the header items of this field should be sorted. */ + sortBySummaryField?: string; + /** The array of field names that specify a path to column/row whose summary field is used for sorting of this field's header items. */ + sortBySummaryPath?: Array; + /** The filter values for the current field. */ + filterValues?: Array; + /** The filter type for the current field. */ + filterType?: string; + /** Indicates whether all header items of the field's header level are expanded. */ + expanded?: boolean; + /** Specifies whether the field should be treated as a Data Field. */ + isMeasure?: boolean; + /** Specifies a display format for field values. */ + format?: string; + /** Specifies a callback function that returns the text to be displayed in the cells of a field. */ + customizeText?: (cellInfo: { value: any; valueText: string }) => string; + /** Specifies a precision for formatted field values. */ + precision?: number; + /** Specifies how to sort the header items. */ + sortingMethod?: (a: Object, b: Object) => number; + /** Allows an end-user to change sorting options. */ + allowSorting?: boolean; + /** Allows an end-user to sort columns by summary values. */ + allowSortingBySummary?: boolean; + /** Allows an end-user to change filtering options. */ + allowFiltering?: boolean; + /** Allows an end-user to expand/collapse all header items within a header level. */ + allowExpandAll?: boolean; + /** Specifies the absolute width of the field in the pivot grid. */ + width?: number; + } + export interface PivotGridDataSourceOptions { + /** Specifies the underlying Store instance used to access data. */ + store?: any; + /** Indicates whether or not the automatic field generation from data in the Store is enabled. */ + retrieveFields?: boolean; + /** Specifies data filtering conditions. */ + filter?: Object; + /** An array of pivot grid fields. */ + fields?: Array; + /** Indicates whether or not the local sorting of the XMLA data should be performed. */ + localSorting?: boolean; + /** A handler for the changed event. */ + onChanged?: () => void; + /** A handler for the loadingChanged event. */ + onLoadingChanged?: (isLoading: boolean) => void; + /** A handler for the loadError event. */ + onLoadError?: (e?: Object) => void; + /** A handler for the fieldsPrepared event. */ + onFieldsPrepared?: (e?: Array) => void; + } + /** An object that provides access to data for the dxPivotGrid widget. */ + export class PivotGridDataSource implements EventsMixin { + constructor(options?: PivotGridDataSource); + /** Starts loading data. */ + load(): JQueryPromise; + /** Indicates whether or not the PivotGridDataSource is currently being loaded. */ + isLoading(): boolean; + /** Gets data displayed in a PivotGrid. */ + getData(): Object; + /** Gets all fields within a specified area. */ + getAreaFields(area: string, collectGroups: boolean): Array; + /** Gets all fields from the data source. */ + fields(): Array; + /** Sets the fields option. */ + fields(fields: Array): void; + /** Gets current options of a specified field. */ + field(id: number): PivotGridField; + /** Sets one or more options of a specified field. */ + field(id: number, field: PivotGridField): void; + /** Collapses a specified header item. */ + collapseHeaderItem(area: string, path: Array): void; + /** Expands a specified header item. */ + expandHeaderItem(area: string, path: Array): void; + /** Disposes of all resources associated with this PivotGridDataSource. */ + dispose(): void; + on(eventName: string, eventHandler: Function): PivotGridDataSource; + on(events: { [eventName: string]: Function; }): PivotGridDataSource; + off(eventName: string): PivotGridDataSource; + off(eventName: string, eventHandler: Function): PivotGridDataSource; + } +} +declare module DevExpress.framework { /** An object used to store information on the views displayed in an application. */ export class ViewCache { viewRemoved: JQueryCallback; @@ -804,7 +960,6 @@ declare module DevExpress.framework { disabled?: boolean; /** Specifies the name of the icon shown inside the widget associated with this command. */ icon?: string; - /** A URL pointing to the icon shown inside the widget associated with this command. */ iconSrc?: string; /** The identifier of the command. */ id?: string; @@ -851,18 +1006,19 @@ declare module DevExpress.framework { } export module html { export var layoutSets: Array; + export var animationSets: { [animationSetName: string]: AnimationSet }; + export interface AnimationSet { + [animationName: string]: any + } export interface HtmlApplicationOptions { /** Specifies where the commands that are defined in the application's views must be displayed. */ commandMapping?: Object; - /** - * The name of the default layout used by the application. - * @deprecated navigationType.md - */ - defaultLayout?: string; /** Specifies whether or not view caching is disabled. */ disableViewCache?: boolean; /** An array of layout controllers that should be used to show application views in the current navigation context. */ layoutSet?: any; + /** Specifies the animation presets that are used to animate different UI elements in the current application. */ + animationSet?: AnimationSet; /** Specifies whether the current application must behave as a mobile or web application. */ mode?: string; /** Specifies the object that represents a root namespace of the application. */ @@ -875,16 +1031,6 @@ declare module DevExpress.framework { stateManager?: StateManager; /** Specifies the storage to be used by the application's state manager to store the application state. */ stateStorage?: Object; - /** - * Specifies a strategy for choosing layouts for views in your application. - * @deprecated layoutSet.md - */ - navigationType?: string; - /** - * Specifies the object that represents the root namespace of the application. - * @deprecated namespace.md - */ - ns?: Object; /** Indicates whether on not to use the title of the previously displayed view as text on the Back button. */ useViewTitleAsBackText?: boolean; /** A custom view cache to be used in the application. */ @@ -1058,7 +1204,7 @@ declare module DevExpress.framework { } } } -declare module DevExpress.ui { +declare module DevExpress.ui { export interface dxValidatorOptions extends DOMComponentOptions { /** An array of validation rules to be checked for the editor with which the dxValidator object is associated. */ validationRules?: Array; @@ -1098,6 +1244,25 @@ declare module DevExpress.ui { constructor(element: JQuery, options?: dxValidationSummaryOptions); constructor(element: Element, options?: dxValidationSummaryOptions); } + /** A widget that displays required content in a resizable element. */ + export interface dxResizableOptions extends DOMComponentOptions { + /** Specifies which borders of the widget element are used as a handle. */ + handles?: string; + /** Specifies the lower width boundary for resizing. */ + minWidth?: number; + /** Specifies the upper width boundary for resizing. */ + maxWidth?: number; + /** Specifies the lower height boundary for resizing. */ + minHeight?: number; + /** Specifies the upper height boundary for resizing. */ + maxHeight?: number; + /** A handler for the resizeStart event. */ + onResizeStart?: Function; + /** A handler for the resize event. */ + onResize?: Function; + /** A handler for the resizeEnd event. */ + onResizeEnd?: Function; + } export interface dxTooltipOptions extends dxPopoverOptions { } /** A tooltip widget. */ @@ -1122,7 +1287,10 @@ declare module DevExpress.ui { valueChangeEvent?: string; /** Specifies whether or not the widget supports searching. */ searchEnabled?: boolean; - /** Specifies whether or not the widget displays items by pages. */ + /** + * Specifies whether or not the widget displays items by pages. + * @deprecated dataSource.paginate.md + */ pagingEnabled?: boolean; /** The text or HTML markup displayed by the widget if the item collection is empty. */ noDataText?: string; @@ -1210,10 +1378,8 @@ declare module DevExpress.ui { showClearButton?: boolean; /** Specifies the current value displayed by the widget. */ value?: any; - valueUpdateAction?: Function; /** Specifies DOM event names that update a widget's value. */ valueChangeEvent?: string; - valueUpdateEvent?: string; /** Specifies whether or not the widget checks the inner text for spelling mistakes. */ spellcheck?: boolean; /** Specifies HTML attributes applied to the inner input element of the widget. */ @@ -1224,6 +1390,14 @@ declare module DevExpress.ui { focusStateEnabled?: boolean; /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ hoverStateEnabled?: boolean; + /** The editor mask, which specifies the format of the entered string. */ + mask?: string; + /** Specifies a mask placeholder character. */ + maskChar?: string; + /** Specifies custom mask rules. */ + maskRules?: Object; + /** A message displayed when the entered text does not match the specified pattern. */ + maskInvalidMessage?: string; } /** A base class for text editing widgets. */ export class dxTextEditor extends Editor { @@ -1370,7 +1544,7 @@ declare module DevExpress.ui { clientHeight(): number; /** Returns the width of the scrollable widget in pixels. */ clientWidth(): number; - /** An HTML element of the widget. */ + /** Returns an HTML element of the widget. */ content(): JQuery; /** Scrolls the widget content by the specified number of pixels. */ scrollBy(distance: number): void; @@ -1411,7 +1585,7 @@ declare module DevExpress.ui { /** A Boolean value specifying whether or not to display the widget in full-screen mode. */ fullScreen?: boolean; position?: PositionOptions; - /** A Boolean value specifying whether or not to display the title in the overlay window. */ + /** A Boolean value specifying whether or not to display the title in the popup window. */ showTitle?: boolean; /** The title in the overlay window. */ title?: string; @@ -1465,6 +1639,8 @@ declare module DevExpress.ui { deferRendering?: boolean; /** Specifies whether or not an end-user can drag the widget. */ dragEnabled?: boolean; + /** Specifies whether or not an end user can resize the widget. */ + resizeEnabled?: boolean; /** The height of the widget in pixels. */ height?: any; /** A handler for the hidden event. */ @@ -1583,14 +1759,6 @@ declare module DevExpress.ui { /** A key used to authenticate the application within the "Google Static" map provider. */ googleStatic?: string; } - /** - * An object, a string, or an array specifying the location displayed at the center of the widget. - * @deprecated center.md - */ - location?: { - lat?: number; - lng?: number; - }; /** A handler for the markerAdded event. */ onMarkerAdded?: Function; markerAddedAction?: Function; @@ -1638,11 +1806,12 @@ declare module DevExpress.ui { export interface dxLookupOptions extends dxDropDownListOptions { /** An object defining widget animation options. */ animation?: fx.AnimationOptions; - autoPagingEnabled?: boolean; /** The text displayed on the Cancel button. */ cancelButtonText?: string; /** The text displayed on the Clear button. */ clearButtonText?: string; + /** Specifies whether or not the widget cleans the search box when the popup window is displayed. */ + cleanSearchOnOpening?: boolean; /** A Boolean value specifying whether or not the widget is closed if a user clicks outside of the overlaying window. */ closeOnOutsideClick?: any; /** The text displayed on the Apply button. */ @@ -1658,6 +1827,8 @@ declare module DevExpress.ui { nextButtonText?: string; /** A handler for the pageLoading event. */ onPageLoading?: Function; + /** Specifies whether the next page is loaded when a user scrolls the widget to the bottom or when the "next" button is clicked. */ + pageLoadMode?: string; pageLoadingAction?: Function; /** Specifies the text shown in the pullDown panel, which is displayed when the widget is scrolled to the bottom. */ pageLoadingText?: string; @@ -1691,7 +1862,10 @@ declare module DevExpress.ui { shading?: boolean; /** Specifies whether to display the Cancel button in the lookup window. */ showCancelButton?: boolean; - /** A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. */ + /** + * A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. + * @deprecated pageLoadMode.md + */ showNextButton?: boolean; /** The title of the lookup window. */ title?: string; @@ -1709,6 +1883,8 @@ declare module DevExpress.ui { onTitleRendered?: Function; /** Specifies whether or not the widget supports the focused state and keyboard navigation. */ focusStateEnabled?: boolean; + /** A Boolean value specifying whether or not to display the title in the popup window. */ + showPopupTitle?: boolean; } /** A widget that allows a user to select predefined values from a lookup window. */ export class dxLookup extends dxDropDownList { @@ -1749,52 +1925,16 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxLoadIndicatorOptions); } export interface dxListOptions extends CollectionWidgetOptions { - /** A Boolean value specifying whether or not to load the next page from the data source when the list is scrolled to the bottom. */ - autoPagingEnabled?: boolean; - /** Specifies whether or not the widget displays items by pages. */ - pagingEnabled?: boolean; - /** An object used to set configuration options for the dxList's edit mode. */ - editConfig?: { - /** Specifies whether the list items can be deleted. */ - deleteEnabled?: boolean; - /** - * A mode specifying how to delete a list item. - * @deprecated deleteType.md - */ - deleteMode?: string; - /** Specifies the way a user can delete items from the list. */ - deleteType?: string; - itemRender?: any; - /** The template used to render list items in edit mode. */ - itemTemplate?: any; - /** Specifies the array of items for a context menu called for a list item. */ - menuItems?: Array; - /** Specifies whether an item context menu is shown when a user swipes or holds an item. */ - menuType?: string; - /** Specifies whether or not a user can reorder items. */ - reorderEnabled?: boolean; - /** Specifies whether the list items can be selected. */ - selectionEnabled?: boolean; - /** - * A mode specifying how to select a list item. - * @deprecated selectionType.md - */ - selectionMode?: string; - /** A type specifying how to select a list item. */ - selectionType?: string; - /** Specifies whether the item list represented by this widget is editable. */ - editEnabled?: boolean; - /** Specifies whether or not to show the loading panel when the DataSource bound to the widget is loading data. */ - indicateLoading?: boolean; - }; /** A Boolean value specifying whether or not to display a grouped list. */ grouped?: boolean; groupRender?: any; - /** The name of the template used to display a group header. */ + /** The template to be used for rendering item groups. */ groupTemplate?: any; onItemDeleting?: Function; /** A handler for the itemDeleted event. */ onItemDeleted?: Function; + /** A handler for the groupRendered event. */ + onGroupRendered?: Function; itemDeleteAction?: Function; /** A handler for the itemReordered event. */ onItemReordered?: Function; @@ -1827,19 +1967,40 @@ declare module DevExpress.ui { scrollAction?: Function; /** A Boolean value specifying whether to enable or disable list scrolling. */ scrollingEnabled?: boolean; - /** Specifies whether the list supports single item selection or multi-selection. */ - selectionMode?: string; - /** A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. */ - showNextButton?: boolean; /** Specifies when the widget shows the scrollbar. */ showScrollbar?: string; /** Specifies whether or not the widget uses native scrolling. */ useNativeScrolling?: boolean; + /** A Boolean value specifying whether to enable or disable the bounce-back effect. */ + bounceEnabled?: boolean; + /** A Boolean value specifying if the list is scrolled by content. */ + scrollByContent?: boolean; + /** A Boolean value specifying if the list is scrolled using the scrollbar. */ + scrollByThumb?: boolean; itemUnselectAction?: Function; onItemContextMenu?: Function; onItemHold?: Function; /** Specifies whether or not an end-user can collapse groups. */ collapsibleGroups?: boolean; + /** Specifies whether the next page is loaded when a user scrolls the widget to the bottom or when the "next" button is clicked. */ + pageLoadMode?: string; + /** Specifies whether or not to display controls used to select list items. */ + showSelectionControls?: boolean; + /** Specifies whether the list supports single item selection or multi-selection. */ + selectionMode?: string; + selectAllText?: string; + /** Specifies the array of items for a context menu called for a list item. */ + menuItems?: Array; + /** Specifies whether an item context menu is shown when a user holds or swipes an item. */ + menuMode?: string; + /** Specifies whether or not an end user can delete list items. */ + allowItemDeleting?: boolean; + /** Specifies the way a user can delete items from the list. */ + itemDeleteMode?: string; + /** Specifies whether or not an end user can reorder list items. */ + allowItemReordering?: boolean; + /** Specifies whether or not to show the loading panel when the DataSource bound to the widget is loading data. */ + indicateLoading?: boolean; } /** A list widget. */ export class dxList extends CollectionWidget { @@ -1855,11 +2016,6 @@ declare module DevExpress.ui { isItemSelected(itemIndex: any): boolean; /** Returns a Boolean value that indicates whether or not the specified item is selected. */ isItemSelected(itemElement: Element): boolean; - /** - * Reloads list data. - * @deprecated Use the "reload" method instead. - */ - refresh(): void; /** Reloads list data. */ reload(): void; /** Moves the specified item to the specified position in the list. */ @@ -1886,11 +2042,6 @@ declare module DevExpress.ui { unselectItem(itemElement: Element): void; /** Unselects the specified item from the list. */ unselectItem(itemIndex: any): void; - /** - * Updates the widget scrollbar according to widget content size. - * @deprecated updateDimensions.md - */ - update(): JQueryPromise; /** Updates the widget scrollbar according to widget content size. */ updateDimensions(): JQueryPromise; /** Expands the specified group. */ @@ -1917,6 +2068,12 @@ declare module DevExpress.ui { slideshowDelay?: number; /** A Boolean value specifying whether or not to allow users to switch between items by swiping. */ swipeEnabled?: boolean; + /** Specifies whether or not to display parts of previous and next images along the sides of the current image. */ + wrapAround?: boolean; + /** Specifies if the widget stretches images to fit the total gallery width. */ + stretchImages?: boolean; + /** Specifies the width of an area used to display a single image. */ + initialItemWidth?: number; } /** An image gallery widget. */ export class dxGallery extends CollectionWidget { @@ -1960,6 +2117,10 @@ declare module DevExpress.ui { open(): void; /** Resets the widget's value to null. */ reset(): void; + /** Returns an <input> element of the widget. */ + field(): JQuery; + /** Returns an HTML element of the popup window content. */ + content(): JQuery; } export interface dxDateBoxOptions extends dxTextEditorOptions { /** A format used to display date/time information. */ @@ -1972,14 +2133,24 @@ declare module DevExpress.ui { min?: Date; /** The text displayed by the widget when the widget value is not yet specified. This text is also used as a title of the date picker. */ placeholder?: string; - /** Specifies whether or not a user can pick out a date using the drop-down calendar. */ + /** + * Specifies whether or not a user can pick out a date using the drop-down calendar. + * @deprecated Use 'pickerType' option instead. + */ useCalendar?: boolean; /** A Date object specifying the date and time currently selected using the date box. */ value?: Date; - /** Specifies whether or not the widget uses the native HTML input element. */ + /** + * Specifies whether or not the widget uses the native HTML input element. + * @deprecated Use 'pickerType' option instead. + */ useNative?: boolean; /** Specifies the interval between neighboring values in the popup list in minutes. */ interval?: number; + /** Specifies the maximum zoom level of a calendar, which is used to pick the date. */ + maxZoomLevel?: string; + /** Specifies the type of date/time picker. */ + pickerType?: string; } /** A date box widget. */ export class dxDateBox extends dxDropDownEditor { @@ -1987,7 +2158,6 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxDateBoxOptions); } export interface dxCheckBoxOptions extends EditorOptions { - checked?: boolean; /** Specifies the widget state. */ value?: boolean; /** Specifies the text displayed by the check box. */ @@ -2007,6 +2177,16 @@ declare module DevExpress.ui { max?: Date; /** The earliest date the widget allows to select. */ min?: Date; + /** Specifies whether or not the widget displays a button that selects the current date. */ + showTodayButton?: boolean; + /** Specifies the current calendar zoom level. */ + zoomLevel?: string; + /** Specifies the maximum zoom level of the calendar. */ + maxZoomLevel?: string; + /** Specifies the minimum zoom level of the calendar. */ + minZoomLevel?: string; + /** The template to be used for rendering calendar cells. */ + cellTemplate?: any; } /** A calendar widget. */ export class dxCalendar extends Editor { @@ -2014,12 +2194,13 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxCalendarOptions); } export interface dxButtonOptions extends WidgetOptions { + /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ + activeStateEnabled?: boolean; /** A handler for the click event. */ onClick?: any; clickAction?: any; /** The name of an icon to be displayed on the button. */ icon?: string; - /** A URL pointing to the image to be displayed on the button. */ iconSrc?: string; /** The text displayed on the button. */ text?: string; @@ -2044,7 +2225,7 @@ declare module DevExpress.ui { /** A container widget used to arrange inner elements. */ export class dxBox extends CollectionWidget { constructor(element: JQuery, options?: dxBoxOptions); - constructor(element: Element, options?: dxBoxOptions); + constructor(element: Element, options?: dxBoxOptions); } export interface dxResponsiveBoxOptions extends CollectionWidgetOptions { /** Specifies the collection of rows for the grid used to position layout elements. */ @@ -2114,8 +2295,11 @@ declare module DevExpress.ui { value?: File; /** Holds the File instances representing files selected in the widget. */ values?: Array; - /** Specifies the text displayed on the button opening the file selection dialog. */ buttonText?: string; + /** The text displayed on the button that opens the file browser. */ + selectButtonText?: string; + /** The text displayed on the button that starts uploading. */ + uploadButtonText?: string; /** Specifies the text displayed on the area to which an end-user can drop a file. */ labelText?: string; /** Specifies the value passed to the name attribute of the underlying input element. */ @@ -2124,6 +2308,22 @@ declare module DevExpress.ui { multiple?: boolean; /** Specifies a file type or several types accepted by the widget. */ accept?: string; + /** Specifies a target Url for the upload request. */ + uploadUrl?: string; + /** Specifies if an end user can remove a just uploaded file. */ + allowCanceling?: boolean; + /** Specifies whether or not the widget displays the list of selected files. */ + showFileList?: boolean; + /** Gets the current progress in percentages. */ + progress?: number; + /** The message displayed by the widget when it is ready to upload the specified files. */ + readyToUploadMessage?: string; + /** The message displayed by the widget when uploading is finished. */ + uploadedMessage?: string; + /** The message displayed by the widget on uploading failure. */ + uploadFailedMessage?: string; + /** Specifies how the widget uploads files. */ + uploadMode?: string; } /** A widget used to select and upload a file or multiple files. */ export class dxFileUploader extends Editor { @@ -2163,6 +2363,8 @@ declare module DevExpress.ui { value?: number; /** Specifies whether or not to highlight a range selected within the widget. */ showRange?: boolean; + /** Specifies the size of a step by which a slider handle is moved when a user uses the Page up or Page down keyboard shortcuts. */ + keyStep?: number; /** Specifies options for the slider tooltip. */ tooltip?: { /** Specifies whether or not the tooltip is enabled. */ @@ -2201,6 +2403,8 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxRangeSliderOptions); } export interface dxTileViewOptions extends CollectionWidgetOptions { + /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ + activeStateEnabled?: boolean; /** Specifies the height of the base tile view item. */ baseItemHeight?: number; /** Specifies the width of the base tile view item. */ @@ -2209,7 +2413,6 @@ declare module DevExpress.ui { height?: any; /** Specifies the distance in pixels between adjacent tiles. */ itemMargin?: number; - listHeight?: any; /** A Boolean value specifying whether or not to display a scrollbar. */ showScrollbar?: boolean; } @@ -2233,6 +2436,31 @@ declare module DevExpress.ui { constructor(element: JQuery, options?: dxSwitchOptions); constructor(element: Element, options?: dxSwitchOptions); } + export interface dxSlideOutViewOptions extends WidgetOptions { + /** Specifies whether or not the menu panel is visible. */ + menuVisible?: boolean; + /** Specifies whether or not the menu is shown when a user swipes the widget content. */ + swipeEnabled?: boolean; + /** A template to be used for rendering menu panel content. */ + menuTemplate?: any; + /** A template to be used for rendering widget content. */ + contentTemplate?: any; + } + /** The widget that allows you to slide-out the current view to reveal a custom menu. */ + export class dxSlideOutView extends Widget { + constructor(element: JQuery, options?: dxSlideOutViewOptions); + constructor(element: Element, options?: dxSlideOutViewOptions); + /** Returns an HTML element of the widget menu block. */ + menuContent(): JQuery; + /** Returns an HTML element of the widget content block. */ + content(): JQuery; + /** Displays the widget's menu block. */ + showMenu(): JQueryPromise; + /** Hides the widget's menu block. */ + hideMenu(): JQueryPromise; + /** Toggles the visibility of the widget's menu block. */ + toggleMenuVisibility(): JQueryPromise; + } export interface dxSlideOutOptions extends CollectionWidgetOptions { /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ activeStateEnabled?: boolean; @@ -2244,6 +2472,10 @@ declare module DevExpress.ui { menuItemRender?: any; /** The template used to render menu items. */ menuItemTemplate?: any; + /** A handler for the menuGroupRendered event. */ + onMenuGroupRendered?: Function; + /** A handler for the menuItemRendered event. */ + onMenuItemRendered?: Function; /** Specifies whether or not the slide-out menu is displayed. */ menuVisible?: boolean; /** Indicates whether the menu can be shown/hidden by swiping the widget's main panel. */ @@ -2265,6 +2497,8 @@ declare module DevExpress.ui { export interface dxPivotOptions extends CollectionWidgetOptions { /** The index of the currently active pivot item. */ selectedIndex?: number; + /** A Boolean value specifying whether or not to allow users to switch between items by swiping. */ + swipeEnabled?: boolean; /** A template to be used for rendering widget content. */ contentTemplate?: any; } @@ -2299,7 +2533,6 @@ declare module DevExpress.ui { buttonClickAction?: any; /** The name of the icon to be displayed by the DropDownMenu button. */ buttonIcon?: string; - /** A URL pointing to the image to be displayed by the DropDownMenu button. */ buttonIconSrc?: string; /** The text displayed in the DropDownMenu button. */ buttonText?: string; @@ -2364,6 +2597,68 @@ declare module DevExpress.ui { /** Shows or hides the widget depending on the Boolean value passed as the parameter. */ toggle(showing: boolean): JQueryPromise; } + export interface dxSchedulerOptions extends WidgetOptions { + /** Specifies a date displayed on the current scheduler view by default. */ + currentDate?: Date; + /** Specifies the view used in the scheduler by default. */ + currentView?: string; + /** A data source used to fetch data to be displayed by the widget. */ + dataSource?: any; + /** Specifies the first day of a week. */ + firstDayOfWeek?: number; + /** The template to be used for rendering appointments. */ + appointmentTemplate?: any; + /** Lists the views to be available within the scheduler's View Selector. */ + views?: Array; + /** Specifies the resource kinds by which the scheduler's appointments are grouped in a timetable. */ + groups?: Array; + /** Specifies a start hour in the scheduler view's time interval. */ + startDayHour?: number; + /** Specifies an end hour in the scheduler view's time interval. */ + endDayHour?: number; + /** Specifies an array of resources available in the scheduler. */ + resources?: Array<{ + /** Indicates whether or not several resources of this kind can be assigned to an appointment. */ + allowMultiple?: boolean; + /** Indicates whether or not resources of this kind have priority in the color identification of the appointments that have resources of different kinds assigned. */ + mainColor?: boolean; + /** A data source used to fetch resources to be available in the scheduler. */ + dataSource?: any; + /** Specifies the resource object field whose value is displayed by the Resource editor in the Appointment popup window. */ + displayExpr?: any; + /** Specifies the resource object field that is used as a value of the Resource editor in the Appointment popup window. */ + valueExpr?: any; + /** The name of the appointment object field that specifies a resource of this kind. */ + field?: string; + /** Specifies the label of the Appointment popup window field that allows end users to assign a resource of this kind. */ + label?: string; + }>; + /** A handler for the AppoinmentAdding event. */ + onAppointmentAdding?: Function; + /** A handler for the appointmentAdded event. */ + onAppointmentAdded?: Function; + /** A handler for the AppoinmentUpdating event. */ + onAppointmentUpdating?: Function; + /** A handler for the appointmentUpdated event. */ + onAppointmentUpdated?: Function; + /** A handler for the AppoinmentDeleting event. */ + onAppointmentDeleting?: Function; + /** A handler for the appointmentDeleted event. */ + onAppointmentDeleted?: Function; + /** A handler for the appointmentRendered event. */ + onAppointmentRendered?: Function; + } + /** A widget that displays scheduled data using different views and provides the capability to load, add and edit appointments. */ + export class dxScheduler extends Widget { + constructor(element: JQuery, options?: dxSchedulerOptions); + constructor(element: Element, options?: dxSchedulerOptions); + /** Add the appointment defined by the object passed as a parameter to the data associated with the widget. */ + addAppointment(appointment: Object): void; + /** Updates the appointment specified by the first method parameter by the appointment object specified by the second method parameter in the the data associated with the widget. */ + updateAppointment(target: Object, appointment: Object): void; + /** Deletes the appointment defined by the parameter from the the data associated with the widget. */ + deleteAppointment(appointment: Object): void; + } export interface dxColorBoxOptions extends dxDropDownEditorOptions { /** Specifies the text displayed on the button that applies changes and closes the drop-down editor. */ applyButtonText?: string; @@ -2372,6 +2667,8 @@ declare module DevExpress.ui { cancelButtonText?: string; /** Specifies whether or not the widget value includes the alpha channel component. */ editAlphaChannel?: boolean; + /** Specifies the size of a step by which a handle is moved using a keyboard shortcut. */ + keyStep?: number; } /** A widget used to specify a color value. */ export class dxColorBox extends dxDropDownEditor { @@ -2388,6 +2685,8 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxColorPickerOptions); } export interface dxTreeViewOptions extends CollectionWidgetOptions { + /** Specifies whether or not to animate item collapsing and expanding. */ + animationEnabled?: boolean; /** Specifies whether a nested or plain array is used as a data source. */ dataStructure?: string; /** Specifies whether or not a user can expand all tree view items by the "*" hot key. */ @@ -2417,7 +2716,14 @@ declare module DevExpress.ui { itemsExpr?: any; /** Specifies the name of the data source item field that holds the key of the parent item. */ parentIdExpr?: any; + /** Specifies the name of the data source item field whose value defines whether or not the corresponding node is disabled. */ disabledExpr?: any; + /** Specifies the name of the data source item field whose value defines whether or not the corresponding node includes child nodes. */ + hasItemsExpr?: any; + /** Specifies if the virtual mode is enabled. */ + virtualModeEnabled?: boolean; + /** Specifies the parent ID value of the root item. */ + rootValue?: any; /** A string value specifying available scrolling directions. */ scrollDirection?: string; /** A handler for the itemSelected event. */ @@ -2461,8 +2767,18 @@ declare module DevExpress.ui { selectionByClick?: boolean; /** Specifies the selection mode supported by the menu. */ selectionMode?: string; - /** Specifies the user interaction by which submenus are shown. */ - showSubmenuMode?: string; + /** Specifies options of submenu showing and hiding. */ + showSubmenuMode?: { + /** Specifies the mode name. */ + name?: string; + /** Specifies the delay of submenu show and hiding. */ + delay?: { + /** The time span after which the submenu is shown. */ + show?: number; + /** The time span after which the submenu is hidden. */ + hide?: number; + }; + }; /** A Boolean value specifying whether or not the widget changes its state when being hovered by an end user. */ hoverStateEnabled?: boolean; } @@ -2475,12 +2791,22 @@ declare module DevExpress.ui { unselectItem(itemElement: any): void; } export interface dxMenuOptions extends dxMenuBaseOptions { - firstSubMenuDirection?: string; + /** Specifies whether or not the submenu is hidden when the mouse pointer leaves it. */ + hideSubmenuOnMouseLeave?: boolean; /** Specifies whether the menu has horizontal or vertical orientation. */ orientation?: string; - /** Specifies by which user interaction the first-level submenu is shown. */ - showFirstSubmenuMode?: string; - showPopupMode?: string; + /** Specifies options for showing and hiding the first level submenu. */ + showFirstSubmenuMode?: { + /** Specifies the mode name. */ + name?: string; + /** Specifies the delay of submenu showing and hiding. */ + delay?: { + /** The time span after which the submenu is shown. */ + show?: number; + /** The time span after which the submenu is hidden. */ + hide?: number; + }; + }; /** Specifies the direction at which the submenus are displayed. */ submenuDirection?: string; /** A handler for the submenuHidden event. */ @@ -2502,11 +2828,13 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxMenuOptions); } export interface dxContextMenuOptions extends dxMenuBaseOptions { - direction?: string; - hiddenAction?: Function; - hidingAction?: Function; - /** Specifies whether the context menu can be called only from code or by user interaction as well. */ - invokeOnlyFromCode?: boolean; + /** Holds an object that specifies options of alternative menu invocation. */ + alternativeInvocationMode?: { + /** Specifies whether or not the standard context menu invocation (on a right mouse click or on a long tap) is disabled. */ + enabled?: Boolean; + /** Specifies the element used to invoke the context menu. */ + invokingElement?: any; + }; /** A handler for the hidden event. */ onHidden?: Function; /** A handler for the hiding event. */ @@ -2519,9 +2847,6 @@ declare module DevExpress.ui { onShown?: Function; /** An object defining widget positioning options. */ position?: PositionOptions; - positioningAction?: Function; - showingAction?: Function; - shownAction?: Function; /** Specifies the direction at which submenus are displayed. */ submenuDirection?: string; /** The target element associated with a popover. */ @@ -2553,8 +2878,12 @@ declare module DevExpress.ui { alignment?: string; /** Specifies whether the values in a column can be edited at runtime. Setting this option makes sense only when editing is enabled for a grid. */ allowEditing?: boolean; - /** Specifies whether or not a column can be used for filtering grid records. Setting this option makes sense only when the filter row or search panel is visible. */ + /** Specifies whether or not a column can be used for filtering grid records. Setting this option makes sense only when the filter row and column header filtering are visible. */ allowFiltering?: boolean; + /** Specifies whether or not the column can be anchored to a grid edge by end users. Setting this option makes sense only when the columnFixing | enabled option is set to true. */ + allowFixing?: boolean; + /** Specifies if a column can be used for searching grid records. Setting this option makes sense only when the search panel is visible. */ + allowSearch?: boolean; /** Specifies whether a column can be used for grouping grid records at runtime. Setting this option makes sense only when the group panel is visible. */ allowGrouping?: boolean; /** Specifies whether or not a column can be hidden by a user. Setting this option makes sense only when the column chooser is visible. */ @@ -2577,8 +2906,10 @@ declare module DevExpress.ui { cellTemplate?: any; /** Specifies a CSS class to be applied to a column. */ cssClass?: string; - /** Specifies a callback function that determines grouping values. */ - calculateGroupValue?: (rowData: Object) => string; + /** Specifies a callback function that determines values for column cells to be used for grouping. */ + calculateGroupValue?: any; + /** Specifies a callback function that returns a value or the name of the field to be used for sorting column cells. */ + calculateSortValue?: any; /** Specifies a callback function that returns the text to be displayed in the cells of a column. */ customizeText?: (cellInfo: { value: any; valueText: string }) => string; /** Specifies the field of a data source that provides data for a column. */ @@ -2595,6 +2926,14 @@ declare module DevExpress.ui { filterOperations?: Array; /** Specifies a filter value for a column. */ filterValue?: any; + /** Specifies initial filter values for the column's header filter. */ + filterValues?: Array; + /** Specifies whether to include or exclude the records with the values selected in the column's header filter. */ + filterType?: string; + /** Indicates whether the column takes part in horizontal grid scrolling or is anchored to a grid edge. */ + fixed?: boolean; + /** Specifies the grid edge to which the column is anchored. */ + fixedPosition?: string; /** Specifies a format for the values displayed in a column. */ format?: string; /** Specifies a custom template for the group cell of a grid column. */ @@ -2650,6 +2989,8 @@ Specifies the data source providing data for a lookup column. errorRowEnabled?: boolean; /** A handler for the rowValidating event. */ onRowValidating?: (e: Object) => void; + /** A handler for the contextMenuPreparing event. */ + onContextMenuPreparing?: (e: Object) => void; initNewRow?: (e: { data: Object }) => void; /** A handler for the initNewRow event. */ onInitNewRow?: (e: { data: Object }) => void; @@ -2701,6 +3042,40 @@ Specifies the data source providing data for a lookup column. /** Specifies the width of the column chooser panel. */ width?: number; }; + /** Specifies options for column fixing. */ + columnFixing?: { + /** Indicates if column fixing is enabled. */ + enabled?: boolean; + /** Contains options that specify texts for column-fixing related commands in the column header's context menu. */ + texts?: { + /** Specifies text for a context menu item that fixes the column for which the context menu is invoked. */ + fix?: string; + /** Specifies text for a context menu item that unfixes the column for which the context menu is invoked. */ + unfix?: string; + /** Specifies text for a context menu subitem that fixes a column, for which the context menu is invoked, to the left grid edge. */ + leftPosition?: string; + /** Specifies text for a context menu subitem that fixes a column, for which the context menu is invoked, to the right grid edge. */ + rightPosition?: string; + }; + }; + /** Specifies options for filtering using a column header filter. */ + headerFilter?: { + /** Indicates whether or not the column header filter button is visible. */ + visible?: boolean; + /** Specifies the height of the dropdown menu invoked when using a column header filter. */ + height?: number; + /** Specifies the width of the dropdown menu invoked when using a column header filter. */ + width?: number; + /** Contains options that specify texts for the dropdown menu invoked when you use a column header filter. */ + texts?: { + /** Specifies text for the item specifying an empty value in the column header filter's dropdown menu. */ + emptyValue?: string; + /** Specifies text for a button that closes the column header filter's dropdown menu and applies specified filtering. */ + ok?: string; + /** Specifies text for a button that closes the column header filter's dropdown menu without applying performed selection. */ + cancel?: string; + } + }; /** An array of grid columns. */ @@ -2759,11 +3134,6 @@ An array of grid columns. addRow?: string; /** Specifies text for a button that turns a row into the editing state. Setting this option makes sense only when the editEnabled option is set to true. */ editRow?: string; - /** - * Specifies text for a button that recovers a deleted row. Setting this option makes sense only if the grid uses the batch edit mode and the removeEnabled option is set to true. - * @deprecated Use the "undeleteRow" option instead. - */ - recoverRow?: string; /** Specifies text for a save button displayed when a row is in the editing state. Setting this option makes sense only when the editEnabled option is set to true. */ saveRowChanges?: string; /** Specifies text for a button that recovers a deleted row. Setting this option makes sense only if the grid uses the batch edit mode and the removeEnabled option is set to true. */ @@ -2913,6 +3283,32 @@ Specifies the message displayed in a group row when the corresponding group cont /** Specifies the template for detail sections. */ template?: any; }; + /** Specifies options for exporting grid data. */ + export?: { + /** Indicates if the export feature is enabled in the grid. */ + enabled?: boolean; + /** Specifies a default name for the file to which grid data is exported. */ + fileName?: string; + /** Specifies whether to enable Excel filtering for the exported data in the resulting XLSX file. */ + excelFilterEnabled?: boolean; + /** Specifies whether to enable word wrapping for the exported data in the resulting XLSX file. */ + excelWrapTextEnabled?: boolean; + /** Specifies the URL of the server-side proxy that streams the resulting file to the end user to enable export in IE8, IE9 and Safari browsers. */ + proxyUrl?: string; + /** Indicates whether to allow end users to export not only the data displayed in the grid, but the selected rows only. */ + allowExportSelectedData?: boolean; + /** Contains options that specify texts for the export-related commands and hints. */ + texts?: { + /** Specifies text for the Export button when this button invokes a dropdown menu so you can choose the required export format. */ + exportTo?: string; + /** Specifies text for the Export button when this button exports to the XSLX format. */ + exportToExcel?: string; + /** Specifies text for the item in the Export dropdown menu that exports grid data to Excel. */ + excelFormat?: string; + /** Specifies text for the option in the Export dropdown menu that allows you to choose whether to export all the grid data or the selected rows only. */ + selectedRows?: string; + } + }; /** Specifies the keys of the records that must appear selected initially. */ selectedRowKeys?: Array; /** Specifies options of runtime selection. */ @@ -2937,6 +3333,22 @@ Specifies the message displayed in a group row when the corresponding group cont selectedRowKeys: Array; selectedRowsData: Array; }) => void; + /** A handler for the exporting event. */ + onExporting?: (e: { + fileName: string; + format: string; + cancel: boolean; + }) => void; + /** A handler for the exported event. */ + onExported?: (e: Object) => void; + /** A handler for the rowExpanding event. */ + onRowExpanding?: (e: Object) => void; + /** A handler for the rowExpanded event. */ + onRowExpanded?: (e: Object) => void; + /** A handler for the rowCollapsing event. */ + onRowCollapsing?: (e: Object) => void; + /** A handler for the rowCollapsed event. */ + onRowCollapsed?: (e: Object) => void; /** Specifies whether column headers are visible or not. */ showColumnHeaders?: boolean; /** Specifies whether or not vertical lines separating one grid column from another are visible. */ @@ -3009,7 +3421,9 @@ Specifies the message displayed in a group row when the corresponding group cont precision?: number; /** Specifies whether or not a summary item must be displayed in the group footer. */ showInGroupFooter?: boolean; - /** Specifies the column that must hold the summary item when this item is displayed in the group footer. */ + /** Indicates whether to display group summary items in brackets of the group row header or to align them by the corresponding columns within the group row. */ + alignByColumn?: boolean; + /** Specifies the column that must hold the summary item when this item is displayed in the group footer or aligned by a column in the group row. */ showInColumn?: string; /** Specifies how to aggregate data for a summary item. */ summaryType?: string; @@ -3080,7 +3494,7 @@ Specifies the message displayed in a group row when the corresponding group cont beginCustomLoading(messageText: string): void; /** Discards changes made in a grid. */ cancelEditData(): void; - /** Clears the filter applied to grid records from code. */ + /** Clears all the filters applied to grid records. */ clearFilter(): void; /** Deselects all grid records. */ clearSelection(): void; @@ -3112,8 +3526,12 @@ Specifies the message displayed in a group row when the corresponding group cont expandRow(key: any): void; /** Allows you to collapse a specific group or master row by its key. */ collapseRow(key: any): void; - /** Applies a filter to grid records. */ - filter(filterExpr: Array): void; + /** Applies a filter to the grid's data source. */ + filter(filterExpr?: any): void; + /** Returns a filter expression applied to the grid's data source using the filter(filterExpr) method. */ + filter(): any; + /** Returns a filter expression applied to the grid using all possible scenarious. */ + getCombinedFilter(): any; /** Gets the keys of currently selected grid records. */ getSelectedRowKeys(): Array; /** Gets the data objects of currently selected grid records. */ @@ -3132,11 +3550,6 @@ Specifies the message displayed in a group row when the corresponding group cont pageSize(value: number): void; /** Gets the current page size. */ pageSize(): number; - /** - * Recovers a row deleted in the batch edit mode. - * @deprecated Use the "undeleteRow" method instead. - */ - recoverRow(rowIndex: number): void; /** Refreshes grid data. */ refresh(): void; /** Removes a specific row from a grid. */ @@ -3149,6 +3562,7 @@ Searches grid records by a search string. searchByText(text: string): void; /** Selects all grid records. */ selectAll(): void; + /** Deselects the rows that are currently selected within the applied filter. */ deselectAll(): void; /** Selects specific grid records. */ selectRows(keys: Array, preserve: boolean): void; @@ -3169,9 +3583,140 @@ Searches grid records by a search string. byKey(key: any): JQueryPromise; /** Gets the value of a total summary item. */ getTotalSummaryValue(summaryItemName: string): any; + /** Exports grid data to Excel. */ + exportToExcel(selectionOnly: boolean): void; + /** Updates the grid to the size of its content. */ + updateDimensions(): void; + /** Focuses the specified cell element in the grid. */ + focus(element?: JQuery): void; + } + export interface dxPivotGridOptions extends WidgetOptions { + /** Specifies a data source for the pivot grid. */ + dataSource?: any; + useNativeScrolling?: any; + /** Allows an end-user to change sorting options. */ + allowSorting?: boolean; + /** Allows an end-user to sort columns by summary values. */ + allowSortingBySummary?: boolean; + /** Allows an end-user to change filtering options. */ + allowFiltering?: boolean; + /** Allows an end-user to expand/collapse all header items within a header level. */ + allowExpandAll?: boolean; + /** Specifies whether to display the Total rows. */ + showRowTotals?: boolean; + /** Specifies whether to display the Grand Total row. */ + showRowGrandTotals?: boolean; + /** Specifies whether to display the Total columns. */ + showColumnTotals?: boolean; + /** Specifies whether to display the Grand Total column. */ + showColumnGrandTotals?: boolean; + /** The Field Chooser configuration options. */ + fieldChooser?: { + /** Enables or disables the field chooser. */ + enabled?: boolean; + /** Specifies the field chooser layout. */ + layout?: number; + /** Specifies the text to display as a title of the field chooser popup window. */ + title?: string; + /** Specifies the field chooser width. */ + width?: number; + /** Specifies the field chooser height. */ + height?: number; + /** Strings that can be changed or localized in the pivot grid's integrated Field Chooser. */ + texts?: { + /** The string to display instead of Row Fields. */ + rowFields?: string; + /** The string to display instead of Column Fields. */ + columnFields?: string; + /** The string to display instead of Data Fields. */ + dataFields?: string; + /** The string to display instead of Filter Fields. */ + filterFields?: string; + /** The string to display instead of All Fields. */ + allFields?: string; + }; + } + /** Strings that can be changed or localized in the dxPivotGrid widget. */ + texts?: { + /** The string to display as a header of the Grand Total row and column. */ + grandTotal?: string; + /** The string to display as a header of the Total row and column. */ + total?: string; + /** Specifies the text displayed when a pivot grid does not contain any fields. */ + noData?: string; + /** The string to display as a Show Field Chooser context menu item. */ + showFieldChooser?: string; + /** The string to display as an Expand All context menu item. */ + expandAll?: string; + /** The string to display as a Collapse All context menu item. */ + collapseAll?: string; + /** The string to display as a Sort Column by Summary Value context menu item. */ + sortColumnBySummary?: string; + /** The string to display as a Sort Row by Summary Value context menu item. */ + sortRowBySummary?: string; + /** The string to display as a Remove All Sorting context menu item. */ + removeAllSorting?: string; + }; + /** The Load panel configuration options. */ + loadPanel?: { + /** Enables or disables the load panel. */ + enabled?: boolean; + /** Specifies the height of the load panel. */ + height?: number; + /** Specifies the URL pointing to an image that will be used as a load indicator. */ + indicatorSrc?: string; + /** Specifies whether or not to show a load indicator. */ + showIndicator?: boolean; + /** Specifies whether or not to show load panel background. */ + showPane?: boolean; + /** Specifies the text to display inside a load panel. */ + text?: string; + /** Specifies the width of the load panel. */ + width?: number; + }; + /** A handler for the cellClick event. */ + onCellClick?: (e: any) => void; + /** A handler for the cellPrepared event. */ + onCellPrepared?: (e: any) => void; + } + /** A data summarization widget for multi-dimensional data analysis and data mining. */ + export class dxPivotGrid extends Widget { + constructor(element: JQuery, options?: dxPivotGridOptions); + constructor(element: Element, options?: dxPivotGridOptions); + /** Gets the PivotGridDataSource instance. */ + getDataSource(): DevExpress.data.PivotGridDataSource; + /** Updates the widget to the size of its content. */ + updateDimensions(): void; + } + export interface dxPivotGridFieldChooserOptions extends WidgetOptions { + /** Specifies the field chooser layout. */ + layout?: number; + /** The data source of a dxPivotGrid widget. */ + dataSource?: DevExpress.data.PivotGridDataSource; + onContentReady?: Function; + /** Strings that can be changed or localized in the dxPivotGridFieldChooser widget. */ + texts?: { + /** The string to display instead of Row Fields. */ + rowFields?: string; + /** The string to display instead of Column Fields. */ + columnFields?: string; + /** The string to display instead of Data Fields. */ + dataFields?: string; + /** The string to display instead of Filter Fields. */ + filterFields?: string; + /** The string to display instead of All Fields. */ + allFields?: string; + }; + } + /** A complementary widget for dxPivotGrid that allows you to manage data displayed in the dxPivotGrid. */ + export class dxPivotGridFieldChooser extends Widget { + constructor(element: JQuery, options?: dxPivotGridFieldChooserOptions); + constructor(element: Element, options?: dxPivotGridFieldChooserOptions); + /** Updates the widget to the size of its content. */ + updateDimensions(): void; } } -declare module DevExpress.viz.charts { +declare module DevExpress.viz.charts { /** This section describes the fields and methods that can be used in code to manipulate the Series object. */ export interface BaseSeries { /** Provides information about the state of the series object. */ @@ -3180,7 +3725,9 @@ declare module DevExpress.viz.charts { type: string; /** Unselects all the selected points of the series. The points are displayed in an initial style. */ clearSelection(): void; - /** + /** Gets the color of a particular series. */ + getColor(): string; + /** * Gets a point from the series point collection based on the specified argument. * @deprecated getPointsByArg(pointArg).md */ @@ -3239,7 +3786,7 @@ declare module DevExpress.viz.charts { name: string; /** Returns the tag of the series. */ tag: string; - /** Hides a particular series. */ + /** Hides a series. */ hide(): void; /** Provides information about the hover state of a series. */ isHovered(): any; @@ -3307,7 +3854,7 @@ declare module DevExpress.viz.charts { name: string; /** Returns the tag of the series. */ tag: string; - /** Hides a particular series. */ + /** Hides a series. */ hide(): void; /** Provides information about the hover state of a series. */ isHovered(): any; @@ -3469,59 +4016,59 @@ declare module DevExpress.viz.charts { }; } export interface CommonPointOptions { - /** Specifies border options for points in the line and area series. */ - border?: viz.core.Border; - /** Specifies the points color. */ - color?: string; - /** Specifies what series points to highlight when a point is hovered over. */ - hoverMode?: string; - /** An object defining configuration options for a hovered point. */ - hoverStyle?: { - /** An object defining the border options for a hovered point. */ + /** Specifies border options for points in the line and area series. */ border?: viz.core.Border; - /** Sets a color for a point when it is hovered over. */ + /** Specifies the points color. */ color?: string; - /** Specifies the diameter of a hovered point in the series that represents data points as symbols (not as bars for instance). */ + /** Specifies what series points to highlight when a point is hovered over. */ + hoverMode?: string; + /** An object defining configuration options for a hovered point. */ + hoverStyle?: { + /** An object defining the border options for a hovered point. */ + border?: viz.core.Border; + /** Sets a color for a point when it is hovered over. */ + color?: string; + /** Specifies the diameter of a hovered point in the series that represents data points as symbols (not as bars for instance). */ + size?: number; + }; + /** Specifies what series points to highlight when a point is selected. */ + selectionMode?: string; + /** An object defining configuration options for a selected point. */ + selectionStyle?: { + /** An object defining the border options for a selected point. */ + border?: viz.core.Border; + /**

              Sets a color for a point when it is selected.

              */ + color?: string; + /** Specifies the diameter of a selected point in the series that represents data points as symbols (not as bars for instance). */ + size?: number; + }; + /** Specifies the point diameter in pixels for those series that represent data points as symbols (not as bars for instance). */ size?: number; - }; - /** Specifies what series points to highlight when a point is selected. */ - selectionMode?: string; - /** An object defining configuration options for a selected point. */ - selectionStyle?: { - /** An object defining the border options for a selected point. */ - border?: viz.core.Border; - /**

              Sets a color for a point when it is selected.

              */ - color?: string; - /** Specifies the diameter of a selected point in the series that represents data points as symbols (not as bars for instance). */ - size?: number; - }; - /** Specifies the point diameter in pixels for those series that represent data points as symbols (not as bars for instance). */ - size?: number; - /** Specifies a symbol for presenting points of the line and area series. */ - symbol?: string; - visible?: boolean; + /** Specifies a symbol for presenting points of the line and area series. */ + symbol?: string; + visible?: boolean; } export interface ChartCommonPointOptions extends CommonPointOptions { - /** An object specifying the parameters of an image that is used as a point marker. */ - image?: { - /** Specifies the height of an image that is used as a point marker. */ - height?: any; - /** Specifies a URL leading to the image to be used as a point marker. */ - url?: any; - /** Specifies the width of an image that is used as a point marker. */ - width?: any; - }; + /** An object specifying the parameters of an image that is used as a point marker. */ + image?: { + /** Specifies the height of an image that is used as a point marker. */ + height?: any; + /** Specifies a URL leading to the image to be used as a point marker. */ + url?: any; + /** Specifies the width of an image that is used as a point marker. */ + width?: any; + }; } export interface PolarCommonPointOptions extends CommonPointOptions { - /** An object specifying the parameters of an image that is used as a point marker. */ - image?: { - /** Specifies the height of an image that is used as a point marker. */ - height?: number; - /** Specifies a URL leading to the image to be used as a point marker. */ - url?: string; - /** Specifies the width of an image that is used as a point marker. */ - width?: number; - }; + /** An object specifying the parameters of an image that is used as a point marker. */ + image?: { + /** Specifies the height of an image that is used as a point marker. */ + height?: number; + /** Specifies a URL leading to the image to be used as a point marker. */ + url?: string; + /** Specifies the width of an image that is used as a point marker. */ + width?: number; + }; } /** An object that defines configuration options for chart series. */ export interface CommonSeriesConfig extends BaseCommonSeriesConfig { @@ -3904,17 +4451,17 @@ declare module DevExpress.viz.charts { text?: string; } export interface AxisLabel { - /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a label on the value axis. */ + /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a label on the value axis. */ customizeHint?: (argument: { value: any; valueText: string }) => string; - /** Specifies a callback function that returns the text to be displayed in value axis labels. */ + /** Specifies a callback function that returns the text to be displayed in value axis labels. */ customizeText?: (argument: { value: any; valueText: string }) => string; - /** Specifies a format for the text displayed by axis labels. */ + /** Specifies a format for the text displayed by axis labels. */ format?: string; - /** Specifies a precision for the formatted value displayed in the axis labels. */ + /** Specifies a precision for the formatted value displayed in the axis labels. */ precision?: number; } - export interface ChartAxisLabel extends ChartCommonAxisLabel, AxisLabel { } - export interface PolarAxisLabel extends PolarCommonAxisLabel, AxisLabel { } + export interface ChartAxisLabel extends ChartCommonAxisLabel, AxisLabel {} + export interface PolarAxisLabel extends PolarCommonAxisLabel, AxisLabel {} export interface AxisTitle extends CommonAxisTitle { /** Specifies the text for the value axis title. */ text?: string; @@ -3930,7 +4477,7 @@ declare module DevExpress.viz.charts { value?: any; } export interface PolarConstantLine extends PolarCommonConstantLineStyle { - /** An object defining constant line label options. */ + /** An object defining constant line label options. */ label?: PolarConstantLineLabel; /** Specifies a value to be displayed by a constant line. */ value?: any; @@ -3983,7 +4530,7 @@ declare module DevExpress.viz.charts { /** Specifies the elements that will be highlighted when the argument axis is hovered over. */ hoverMode?: string; } - export interface ChartArgumentAxis extends ChartAxis, ArgumentAxis { } + export interface ChartArgumentAxis extends ChartAxis, ArgumentAxis {} export interface PolarArgumentAxis extends PolarAxis, ArgumentAxis { /** Specifies a start angle for the argument axis in degrees. */ startAngle?: number; @@ -3999,7 +4546,7 @@ declare module DevExpress.viz.charts { showZero?: boolean; /** Specifies the desired type of axis values. */ valueType?: string; - } + } export interface ChartValueAxis extends ChartAxis, ValueAxis { /** Specifies the spacing, in pixels, between multiple value axes in a chart. */ multipleAxesSpacing?: number; @@ -4106,8 +4653,6 @@ declare module DevExpress.viz.charts { series?: any; /** Specifies the size of the widget in pixels. */ size?: viz.core.Size; - /** Sets the name of the theme to be used in the chart. */ - theme?: string; /** Specifies a title for the chart. */ title?: { /** Specifies font options for the title. */ @@ -4157,7 +4702,7 @@ declare module DevExpress.viz.charts { asyncSeriesRendering?: boolean; }): void; } - export interface AdvancedLegend extends core.BaseLegend { + export interface AdvancedLegend extends core.BaseLegend { /** Specifies the text for a hint that appears when a user hovers the mouse pointer over a legend item. */ customizeHint?: (seriesInfo: { seriesName: string; seriesIndex: number; seriesColor: string; }) => string; /**

              Specifies a callback function that returns the text to be displayed by legend items.

              */ @@ -4198,7 +4743,7 @@ declare module DevExpress.viz.charts { /** Specifies whether a single series or multiple series can be selected in the chart. */ seriesSelectionMode?: string; /** Specifies how the chart must behave when series point labels overlap. */ - resolveLabelOverlapping?: string; + resolveLabelOverlapping?: string; } export interface Legend extends AdvancedLegend { /** Specifies whether the legend is located outside or inside the chart's plot. */ @@ -4263,7 +4808,7 @@ declare module DevExpress.viz.charts { maxBubbleSize?: number; /** Specifies the diameter of the smallest bubble measured in pixels. */ minBubbleSize?: number; - /** Defines the dxChart widget's pane(s). */ + /** Defines the dxChart widget's pane(s). */ panes?: Array; /** Swaps the axes round so that the value axis becomes horizontal and the argument axes becomes vertical. */ rotated?: boolean; @@ -4393,7 +4938,7 @@ declare module DevExpress.viz.charts { onLegendClick?: any; legendClick?: any; /** Specifies how the chart must behave when series point labels overlap. */ - resolveLabelOverlapping?: string; + resolveLabelOverlapping?: string; } /** A circular chart widget for HTML JS applications. */ export class dxPieChart extends BaseChart { @@ -4403,7 +4948,7 @@ declare module DevExpress.viz.charts { getSeries(): PieSeries; } } -declare module DevExpress.viz.core { +declare module DevExpress.viz.core { export interface Border { /** Sets a border color for a selected series. */ color?: string; @@ -4465,8 +5010,7 @@ declare module DevExpress.viz.core { border?: viz.core.DashedBorderWithOpacity; /** Specifies a color for the tooltip. */ color?: string; - customizeText?: Function; - /** Specifies text and appearance of a particular set of tooltips. */ + /** Specifies text and appearance of a set of tooltips. */ customizeTooltip?: (arg: Object) => { color?: string; text?: string }; /** Specifies whether or not the tooltip is enabled. */ enabled?: boolean; @@ -4527,8 +5071,6 @@ declare module DevExpress.viz.core { columnCount?: number; /** Specifies the spacing between a pair of neighboring legend columns in pixels. */ columnItemSpacing?: number; - /** Specifies whether or not item columns in the legend have an equal width. */ - equalColumnWidth?: boolean; /** Specifies font options for legend items. */ font?: viz.core.Font; /** Specifies the legend's position on the map. */ @@ -4573,21 +5115,23 @@ declare module DevExpress.viz.core { }) => void; /** A handler for the incidentOccurred event. */ onIncidentOccurred?: ( - component: BaseWidget, - element: Element, - target: { - id: string; - type: string; - args: any; - text: string; - widget: string; - version: string; - } + component: BaseWidget, + element: Element, + target: { + id: string; + type: string; + args: any; + text: string; + widget: string; + version: string; + } ) => void; /** Notifies a widget that it is embedded into an HTML page that uses a path modifier. */ pathModified?: boolean; /** Specifies whether or not the widget supports right-to-left representation. */ rtlEnabled?: boolean; + /** Sets the name of the theme to be used in the widget. */ + theme?: string; } /** This section describes options and methods that are common to all widgets. */ export class BaseWidget extends DOMComponent { @@ -4595,7 +5139,7 @@ declare module DevExpress.viz.core { svg(): string; } } -declare module DevExpress.viz.gauges { +declare module DevExpress.viz.gauges { export interface BaseRangeContainer { /** Specifies a range container's background color. */ backgroundColor?: string; @@ -4726,8 +5270,6 @@ declare module DevExpress.viz.gauges { /** Specifies a text for the subtitle. */ text?: string; }; - /** Specifies the name of the theme to be applied. */ - theme?: string; /** Specifies a title for a gauge. */ title?: { /** Specifies font options for the title. */ @@ -4905,7 +5447,7 @@ declare module DevExpress.viz.gauges { values(values: Array): void; } } -declare module DevExpress.viz.map { +declare module DevExpress.viz.map { /** This section describes the fields and methods that can be used in code to manipulate the Area object. */ export interface Area { /** Contains the element type. */ @@ -4916,6 +5458,8 @@ declare module DevExpress.viz.map { selected(): boolean; /** Sets a new selection state for an area. */ selected(state: boolean): void; + /** Applies the area settings specified as a parameter and updates the area appearance. */ + applySettings(settings: any): void; } /** This section describes the fields and methods that can be used in code to manipulate the Markers object. */ export interface Marker { @@ -4937,6 +5481,8 @@ declare module DevExpress.viz.map { selected(): boolean; /** Sets a new selection state for a marker. */ selected(state: boolean): void; + /** Applies the marker settings specified as a parameter and updates the marker appearance. */ + applySettings(settings: any): void; } export interface AreaSettings { /** Specifies the width of the area border in pixels. */ @@ -5065,6 +5611,8 @@ declare module DevExpress.viz.map { horizontalAlignment?: string; /** Specifies the position of the control bar. */ verticalAlignment?: string; + /** Specifies the opacity of the Control_Bar. */ + opacity?: number; }; /** Specifies the appearance of the loading indicator. */ loadingIndicator?: viz.core.LoadingIndicator; @@ -5076,8 +5624,6 @@ declare module DevExpress.viz.map { markerSettings?: MarkerSettings; /** Specifies the size of the dxVectorMap widget. */ size?: viz.core.Size; - /** Specifies the name of the theme to be applied. */ - theme?: Object; /** Specifies tooltip options. */ tooltip?: viz.core.Tooltip; /** Configures map legends. */ @@ -5099,6 +5645,8 @@ declare module DevExpress.viz.map { }) => void; /** Specifies a number that is used to zoom a map initially. */ zoomFactor?: number; + /** Specifies a map's maximum zoom factor. */ + maxZoomFactor?: number; zoomFactorChanged?: (zoomFactor: number) => void; /** A handler for the zoomFactorChanged event. */ onZoomFactorChanged?: (e: { @@ -5172,7 +5720,7 @@ declare module DevExpress.viz.map { zoomFactor(zoomFactor: number): void; } } -declare module DevExpress.viz.rangeSelector { +declare module DevExpress.viz.rangeSelector { export interface dxRangeSelectorOptions extends viz.core.BaseWidgetOptions { /** Specifies the options for the range selector's background. */ background?: { @@ -5346,6 +5894,15 @@ Specifies an interval between minor ticks. /** Specifies the end value of the range to be selected when displaying the dxRangeSelector widget on a page. */ endValue?: any; }; + /** Specifies the color of the selected range. */ + selectedRangeColor?: string; + /** Range selector's indent options. */ + indent?: { + /** Specifies range selector's left indent. */ + left?: number; + /** Specifies range selector's right indent. */ + right?: number; + }; selectedRangeChanged?: (selectedRange: { startValue: any; endValue: any; }) => void; /** A handler for the selectedRangeChanged event. */ onSelectedRangeChanged?: (e: { @@ -5354,7 +5911,7 @@ Specifies an interval between minor ticks. component: dxRangeSelector; element: Element; }) => void; - /** Specifies the options of the range selector's shutters. */ + /** Specifies range selector shutter options. */ shutter?: { /** Specifies shutter color. */ color?: string; @@ -5384,9 +5941,21 @@ Specifies an interval between minor ticks. format?: string; /** Specifies the color used for the slider marker text when the currently selected range does not match the minRange and maxRange values. */ invalidRangeColor?: string; - /** Specifies the empty space between the marker's border and the marker’s text. */ + /** + * Specifies the empty space between the marker's border and the marker’s text. + * @deprecated Use the 'paddingTopBottom' and 'paddingLeftRight' options instead + */ padding?: number; - /** Specifies in pixels the height and width of the space reserved for the range selector slider markers. */ + /** Specifies the empty space between the marker's top and bottom borders and the marker's text. */ + paddingTopBottom?: number; + /** Specifies the empty space between the marker's left and right borders and the marker's text. */ + paddingLeftRight?: number; + /** Specifies the placeholder height of the slider marker. */ + placeholderHeight?: number; + /** + * Specifies in pixels the height and width of the space reserved for the range selector slider markers. + * @deprecated Use the 'placeholderHeight' and 'indent' options instead + */ placeholderSize?: { /** Specifies the height of the placeholder for the left and right slider markers. */ height?: number; @@ -5403,8 +5972,6 @@ Specifies an interval between minor ticks. /** Indicates whether or not the slider markers are visible. */ visible?: boolean; }; - /** Sets the name of the theme to be used by the range selector. */ - theme?: string; } /** A widget that allows end users to select a range of values on a scale. */ export class dxRangeSelector extends viz.core.BaseWidget { @@ -5422,11 +5989,17 @@ Specifies an interval between minor ticks. setSelectedRange(selectedRange: { startValue: any; endValue: any; }): void; } } -declare module DevExpress.viz.sparklines { +declare module DevExpress.viz.sparklines { export interface SparklineTooltip extends viz.core.Tooltip { - /** Specifies how a tooltip is horizontally aligned relative to the graph. */ + /** + * Specifies how a tooltip is horizontally aligned relative to the graph. + * @deprecated Tooltip alignment is no more available. + */ horizontalAlignment?: string; - /** Specifies how a tooltip is vertically aligned relative to the graph. */ + /** + * Specifies how a tooltip is vertically aligned relative to the graph. + * @deprecated Tooltip alignment is no more available. + */ verticalAlignment?: string; } export interface BaseSparklineOptions extends viz.core.BaseWidgetOptions { @@ -5434,8 +6007,6 @@ declare module DevExpress.viz.sparklines { margin?: viz.core.Margins; /** Specifies the size of the widget. */ size?: viz.core.Size; - /** Specifies the name of the theme to be applied. */ - theme?: string; /** Specifies tooltip options. */ tooltip?: SparklineTooltip; } @@ -5510,6 +6081,10 @@ declare module DevExpress.viz.sparklines { winColor?: string; /** Specifies a value that serves as a threshold for the sparkline of the winloss type. */ winlossThreshold?: number; + /** Specifies the minimum value of the sparkline value axis. */ + minValue?: number; + /** Specifies the maximum value of the sparkline's value axis. */ + maxValue?: number; } /** A sparkline widget. */ export class dxSparkline extends BaseSparkline { @@ -5517,7 +6092,7 @@ declare module DevExpress.viz.sparklines { constructor(element: Element, options?: dxSparklineOptions); } } -interface JQuery { +interface JQuery { dxProgressBar(): JQuery; dxProgressBar(options: "instance"): DevExpress.ui.dxProgressBar; dxProgressBar(options: string): any; @@ -5780,6 +6355,21 @@ interface JQuery { dxDataGrid(options: string): any; dxDataGrid(options: string, ...params: any[]): any; dxDataGrid(options: DevExpress.ui.dxDataGridOptions): JQuery; + dxPivotGrid(): JQuery; + dxPivotGrid(options: "instance"): DevExpress.ui.dxPivotGrid; + dxPivotGrid(options: string): any; + dxPivotGrid(options: string, ...params: any[]): any; + dxPivotGrid(options: DevExpress.ui.dxPivotGridOptions): JQuery; + dxPivotGridFieldChooser(): JQuery; + dxPivotGridFieldChooser(options: "instance"): DevExpress.ui.dxPivotGridFieldChooser; + dxPivotGridFieldChooser(options: string): any; + dxPivotGridFieldChooser(options: string, ...params: any[]): any; + dxPivotGridFieldChooser(options: DevExpress.ui.dxPivotGridFieldChooserOptions): JQuery; + dxScheduler(): JQuery; + dxScheduler(options: "instance"): DevExpress.ui.dxScheduler; + dxScheduler(options: string): any; + dxScheduler(options: string, ...params: any[]): any; + dxScheduler(options: DevExpress.ui.dxSchedulerOptions): JQuery; dxChart(options?: DevExpress.viz.charts.dxChartOptions): JQuery; dxChart(methodName: string, ...params: any[]): any; dxChart(methodName: "instance"): DevExpress.viz.charts.dxChart; From 48df6f8dd4ebd0a09bb980a5bcd2acbc41217c31 Mon Sep 17 00:00:00 2001 From: Igor Kriklivets Date: Fri, 5 Jun 2015 18:57:28 +0300 Subject: [PATCH 129/397] Path to jQuery.d.ts changed --- devextreme/14.2/dx.devextreme-14.2.7.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devextreme/14.2/dx.devextreme-14.2.7.d.ts b/devextreme/14.2/dx.devextreme-14.2.7.d.ts index a1d361f54..c8827de9c 100644 --- a/devextreme/14.2/dx.devextreme-14.2.7.d.ts +++ b/devextreme/14.2/dx.devextreme-14.2.7.d.ts @@ -1,9 +1,9 @@ -// Type definitions for DevExtreme 14.2.7 +// Type definitions for DevExtreme 14.2.7 // Project: http://js.devexpress.com/ // Definitions by: DevExpress Inc. // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// declare module DevExpress { /** A mixin that provides a capability to fire and subscribe to events. */ From 279425d25fbe4e7a3a3ae5ff429c0c0124c23473 Mon Sep 17 00:00:00 2001 From: Lucy He Date: Fri, 5 Jun 2015 18:04:26 -0400 Subject: [PATCH 130/397] Add typing for addResources. Export i18next-client module. --- i18next/i18next-tests.ts | 18 ++++++++++++++++++ i18next/i18next.d.ts | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/i18next/i18next-tests.ts b/i18next/i18next-tests.ts index b1732de11..741f12982 100644 --- a/i18next/i18next-tests.ts +++ b/i18next/i18next-tests.ts @@ -665,6 +665,24 @@ describe('i18next', function () { }); + describe('adding resources after initialisation', function () { + + var frResource = { 'simple_fr': 'ok_from_fr' }; + var enResource = { 'simple_en': 'ok_from_en' }; + + beforeEach(function (done) { + i18n.init({ resStore: {} }, + function (t) { done(); }); + }); + + it('it should use resources for translation added after initialisation', function () { + i18n.addResources('fr', 'translation', frResource); + i18n.addResources('en', 'translation', enResource); + expect(i18n.t('simple_fr', { lng: 'fr' })).to.be('ok_from_fr'); + expect(i18n.t('simple_en', { lng: 'en' })).to.be('ok_from_en'); + }); + + }); }); describe('translation functionality', function () { diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 3463f2426..4d7d5945b 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -66,6 +66,7 @@ interface I18nextOptions { interface I18nextStatic { + addResources(language: string, namespace: string, resources: IResourceStoreKey): void; addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void; detectLanguage(): string; functions: { @@ -130,4 +131,8 @@ declare var i18n: I18nextStatic; declare module 'i18next' { export = i18n; +} + +declare module 'i18next-client' { + export = i18n; } \ No newline at end of file From f3797dc8504128fba6810be381c2983e7cfc05e8 Mon Sep 17 00:00:00 2001 From: Lucy He Date: Fri, 5 Jun 2015 18:10:15 -0400 Subject: [PATCH 131/397] Move function so typings are alphabetical. --- i18next/i18next.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 4d7d5945b..f39095459 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -66,8 +66,8 @@ interface I18nextOptions { interface I18nextStatic { - addResources(language: string, namespace: string, resources: IResourceStoreKey): void; addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void; + addResources(language: string, namespace: string, resources: IResourceStoreKey): void; detectLanguage(): string; functions: { extend(target: any, ...objs: any[]): Object; From ed5be30e622dbfd9a302a310e5322dbee759cfc9 Mon Sep 17 00:00:00 2001 From: Kenneth Kolstad Date: Fri, 5 Jun 2015 15:48:45 -0700 Subject: [PATCH 132/397] lodash: add generic _.remove --- lodash/lodash-tests.ts | 1 + lodash/lodash.d.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2017252ff..f45f2fb04 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -270,6 +270,7 @@ result = _.range(0); result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); result = _.remove(foodsOrganic, 'organic'); result = _.remove(foodsType, { 'type': 'vegetable' }); +var typedResult: IFoodType[] = _.remove([ { name: 'apple' }, { name: 'orange' }], { name: 'orange' }); result = _.sortedIndex([20, 30, 50], 40); result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index dfa5e2e6a..a3523fe9f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1296,6 +1296,14 @@ declare module _ { remove( array: List, wherealue?: Dictionary): any[]; + + /** + * @see _.remove + * @param item The item to remove + **/ + remove( + array:Array, + item:T): T[]; } //_.rest From 40b0c2661875cf6fcb3765f9a4325395b903b105 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 5 Jun 2015 15:58:51 -0700 Subject: [PATCH 133/397] Update angular2.d.ts for alpha.26 --- angular2/angular2-tests.ts | 5 +- angular2/angular2.d.ts | 5556 +++++++++++++++++++++++++++++++++--- 2 files changed, 5144 insertions(+), 417 deletions(-) diff --git a/angular2/angular2-tests.ts b/angular2/angular2-tests.ts index bdd2628e5..80c7e3cd9 100644 --- a/angular2/angular2-tests.ts +++ b/angular2/angular2-tests.ts @@ -2,7 +2,6 @@ // Use Typescript 1.4 style imports import ng = require("angular2/angular2"); -import di = require("angular2/di"); class Service { @@ -17,11 +16,11 @@ class Cmp { Cmp.annotations = [ ng.Component({ selector: 'cmp', - injectables: [Service, di.bind(Service2).toValue(null)] + injectables: [Service, ng.bind(Service2).toValue(null)] }), ng.View({ template: '{{greeting}} world!', - directives: [ng.For, ng.If] + directives: [ng.NgFor, ng.NgIf] }) ]; diff --git a/angular2/angular2.d.ts b/angular2/angular2.d.ts index fa3cc7788..b70c4577d 100644 --- a/angular2/angular2.d.ts +++ b/angular2/angular2.d.ts @@ -1,299 +1,1839 @@ -// Type definitions for Angular v2.0.0-alpha.22 +// Type definitions for Angular v2.0.0-alpha.26 // Project: http://angular.io/ // Definitions by: angular team // Definitions: https://github.com/borisyankov/DefinitelyTyped -/****************** - * This is a minimal type definition for the Angular2 quickstart. - * We plan to publish a complete definition soon. - ******************/ +// *********************************************************** +// This file is generated by the Angular build process. +// Please do not create manual edits or send pull requests +// modifying this file. +// *********************************************************** + +// Angular depends transitively on these libraries. +// If you don't have them installed you can run +// $ tsd query es6-promise rx rx-lite --action install --save +/// +/// interface List extends Array {} +interface Map {} +interface StringMap extends Map {} interface Type {} -interface _ComponentArg { - /** - * The CSS selector that triggers the instantiation of a directive. - * - * Angular only allows directives to trigger on CSS selectors that do not cross element boundaries. - * - * `selector` may be declared as one of the following: - * - * - `element-name`: select by element name. - * - `.class`: select by class name. - * - `[attribute]`: select by attribute name. - * - `[attribute=value]`: select by attribute name and value. - * - `:not(sub_selector)`: select only if the element does not match the `sub_selector`. - * - `selector1, selector2`: select if either `selector1` or `selector2` matches. - * - * - * ## Example - * - * Suppose we have a directive with an `input[type=text]` selector. - * - * And the following HTML: - * - * ```html - *
              - * - * - * - * ``` - * - * The directive would only be instantiated on the `` element. - * - */ - selector: string; +declare module "angular2/angular2" { + type SetterFn = typeof Function; + type int = number; + + // See https://github.com/Microsoft/TypeScript/issues/1168 + class BaseException /* extends Error */ { + message: any; + stack: any; + toString(): string; + } +} + + +declare module "angular2/angular2" { + class AbstractChangeDetector extends ChangeDetector { + addChild(cd: ChangeDetector): any; + addShadowDomChild(cd: ChangeDetector): any; + callOnAllChangesDone(): any; + checkNoChanges(): any; + detectChanges(): any; + detectChangesInRecords(throwOnChange: boolean): any; + lightDomChildren: List; + markAsCheckOnce(): any; + markPathToRootAsCheckOnce(): any; + mode: string; + parent: ChangeDetector; + ref: ChangeDetectorRef; + remove(): any; + removeChild(cd: ChangeDetector): any; + removeShadowDomChild(cd: ChangeDetector): any; + shadowDomChildren: List; + } + class ProtoRecord { + args: List; + bindingRecord: BindingRecord; + contextIndex: number; + directiveIndex: DirectiveIndex; + expressionAsString: string; + fixedArgs: List; + funcOrValue: any; + isLifeCycleRecord(): boolean; + isPipeRecord(): boolean; + isPureFunction(): boolean; + lastInBinding: boolean; + lastInDirective: boolean; + mode: number; + name: string; + selfIndex: number; + } + + /** - * Enumerates the set of properties that accept data binding for a directive. - * - * The `properties` property defines a set of `directiveProperty` to `bindingProperty` - * key-value pairs: - * - * - `directiveProperty` specifies the component property where the value is written. - * - `bindingProperty` specifies the DOM property where the value is read from. - * - * You can include a {@link Pipe} when specifying a `bindingProperty` to allow for data transformation and structural - * change detection of the value. These pipes will be evaluated in the context of this component. - * - * - * ## Syntax - * + * Directives allow you to attach behavior to elements in the DOM. + * + * Directives with an embedded view are called Components. + * + * A directive consists of a single directive annotation and a controller class. When the + * directive's `selector` matches + * elements in the DOM, the following steps occur: + * + * 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor + * arguments. + * 2. Angular instantiates directives for each matched element using `ElementInjector` in a + * depth-first order, + * as declared in the HTML. + * + * ## Understanding How Injection Works + * + * There are three stages of injection resolution. + * - *Pre-existing Injectors*: + * - The terminal Injector cannot resolve dependencies. It either throws an error or, if + * the dependency was + * specified as `@Optional`, returns `null`. + * - The platform injector resolves browser singleton resources, such as: cookies, title, + * location, and others. + * - *Component Injectors*: Each component instance has its own Injector, and they follow + * the same parent-child hierarchy + * as the component instances in the DOM. + * - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each + * element has an `ElementInjector` + * which follow the same parent-child hierarchy as the DOM elements themselves. + * + * When a template is instantiated, it also must instantiate the corresponding directives in a + * depth-first order. The + * current `ElementInjector` resolves the constructor dependencies for each directive. + * + * Angular then resolves dependencies as follows, according to the order in which they appear in the + * View: + * + * 1. Dependencies on the current element + * 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary + * 3. Dependencies on component injectors and their parents until it encounters the root component + * 4. Dependencies on pre-existing injectors + * + * + * The `ElementInjector` can inject other directives, element-specific special objects, or it can + * delegate to the parent + * injector. + * + * To inject other directives, declare the constructor parameter as: + * - `directive:DirectiveType`: a directive on the current element only + * - `@Ancestor() directive:DirectiveType`: any directive that matches the type between the current + * element and the + * Shadow DOM root. Current element is not included in the resolution, therefore even if it could + * resolve it, it will + * be ignored. + * - `@Parent() directive:DirectiveType`: any directive that matches the type on a direct parent + * element only. + * - `@Query(DirectiveType) query:QueryList`: A live collection of direct child + * directives. + * - `@QueryDescendants(DirectiveType) query:QueryList`: A live collection of any + * child directives. + * + * To inject element-specific special objects, declare the constructor parameter as: + * - `element: ElementRef` to obtain a reference to logical element in the view. + * - `viewContainer: ViewContainerRef` to control child template instantiation, for + * Directive directives only + * - `bindingPropagation: BindingPropagation` to control change detection in a more granular way. + * + * ## Example + * + * The following example demonstrates how dependency injection resolves constructor arguments in + * practice. + * + * + * Assume this HTML template: + * * ``` + *
              + *
              + *
              + *
              + *
              + *
              + *
              + *
              + *
              + *
              + * ``` + * + * With the following `dependency` decorator and `SomeService` injectable class. + * + * ``` + * @Injectable() + * class SomeService { + * } + * * @Directive({ - * properties: { - * 'directiveProperty1': 'bindingProperty1', - * 'directiveProperty2': 'bindingProperty2 | pipe1 | ...', - * ... + * selector: '[dependency]', + * properties: [ + * 'id: dependency' + * ] + * }) + * class Dependency { + * id:string; + * } + * ``` + * + * Let's step through the different ways in which `MyDirective` could be declared... + * + * + * ### No injection + * + * Here the constructor is declared with no arguments, therefore nothing is injected into + * `MyDirective`. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor() { * } * } * ``` - * - * - * ## Basic Property Binding - * - * We can easily build a simple `Tooltip` directive that exposes a `tooltip` property, which can be used in templates - * with standard Angular syntax. For example: - * + * + * This directive would be instantiated with no dependencies. + * + * + * ### Component-level injection + * + * Directives can inject any injectable instance from the closest component injector or any of its + * parents. + * + * Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type + * from the parent + * component's injector. + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(someService: SomeService) { + * } + * } + * ``` + * + * This directive would be instantiated with a dependency on `SomeService`. + * + * + * ### Injecting a directive from the current element + * + * Directives can inject other directives declared on the current element. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(dependency: Dependency) { + * expect(dependency.id).toEqual(3); + * } + * } + * ``` + * This directive would be instantiated with `Dependency` declared at the same element, in this case + * `dependency="3"`. + * + * + * ### Injecting a directive from a direct parent element + * + * Directives can inject other directives declared on a direct parent element. By definition, a + * directive with a + * `@Parent` annotation does not attempt to resolve dependencies for the current element, even if + * this would satisfy + * the dependency. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Parent() dependency: Dependency) { + * expect(dependency.id).toEqual(2); + * } + * } + * ``` + * This directive would be instantiated with `Dependency` declared at the parent element, in this + * case `dependency="2"`. + * + * + * ### Injecting a directive from any ancestor elements + * + * Directives can inject other directives declared on any ancestor element (in the current Shadow + * DOM), i.e. on the + * parent element and its parents. By definition, a directive with an `@Ancestor` annotation does + * not attempt to + * resolve dependencies for the current element, even if this would satisfy the dependency. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Ancestor() dependency: Dependency) { + * expect(dependency.id).toEqual(2); + * } + * } + * ``` + * + * Unlike the `@Parent` which only checks the parent, `@Ancestor` checks the parent, as well as its + * parents recursively. If `dependency="2"` didn't exist on the direct parent, this injection would + * have returned + * `dependency="1"`. + * + * + * ### Injecting a live collection of direct child directives + * + * + * A directive can also query for other child directives. Since parent directives are instantiated + * before child directives, a directive can't simply inject the list of child directives. Instead, + * the directive injects a QueryList, which updates its contents as children are added, + * removed, or moved by a directive that uses a ViewContainerRef such as a `ng-for`, an + * `ng-if`, or an `ng-switch`. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Query(Dependency) dependencies:QueryList) { + * } + * } + * ``` + * + * This directive would be instantiated with a QueryList which contains `Dependency` 4 and + * 6. Here, `Dependency` 5 would not be included, because it is not a direct child. + * + * ### Injecting a live collection of descendant directives + * + * Note: This is will be implemented in later release. () + * + * Similar to `@Query` above, but also includes the children of the child elements. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@QueryDescendents(Dependency) dependencies:QueryList) { + * } + * } + * ``` + * + * This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6. + * + * ### Optional injection + * + * The normal behavior of directives is to return an error when a specified dependency cannot be + * resolved. If you + * would like to inject `null` on unresolved dependency instead, you can annotate that dependency + * with `@Optional()`. + * This explicitly permits the author of a template to treat some of the surrounding directives as + * optional. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Optional() dependency:Dependency) { + * } + * } + * ``` + * + * This directive would be instantiated with a `Dependency` directive found on the current element. + * If none can be + * found, the injector supplies `null` instead of throwing an error. + * + * ## Example + * + * Here we use a decorator directive to simply define basic tool-tip behavior. + * * ``` * @Directive({ * selector: '[tooltip]', - * properties: { - * 'text': 'tooltip' - * } - * }) - * class Tooltip { - * set text(text) { - * // This will get called every time the 'tooltip' binding changes with the new value. - * } - * } - * ``` - * - * We can then bind to the `tooltip' property as either an expression (`someExpression`) or as a string literal, as - * shown in the HTML template below: - * - * ```html - *
              ...
              - *
              ...
              - * ``` - * - * Whenever the `someExpression` expression changes, the `properties` declaration instructs - * Angular to update the `Tooltip`'s `text` property. - * - * - * - * ## Bindings With Pipes - * - * You can also use pipes when writing binding definitions for a directive. - * - * For example, we could write a binding that updates the directive on structural changes, rather than on reference - * changes, as normally occurs in change detection. - * - * See {@link Pipe} and {@link keyValDiff} documentation for more details. - * - * ``` - * @Directive({ - * selector: '[class-set]', - * properties: { - * 'classChanges': 'classSet | keyValDiff' - * } - * }) - * class ClassSet { - * set classChanges(changes:KeyValueChanges) { - * // This will get called every time the `class-set` expressions changes its structure. - * } - * } - * ``` - * - * The template that this directive is used in may also contain its own pipes. For example: - * - * ```html - *
              - * ``` - * - * In this case, the two pipes compose as if they were inlined: `someExpression | somePipe | keyValDiff`. - * - */ - properties?: Object; - - /** - * Specifies which DOM hostListeners a directive listens to. - * - * The `hostListeners` property defines a set of `event` to `method` key-value pairs: - * - * - `event1`: the DOM event that the directive listens to. - * - `statement`: the statement to execute when the event occurs. - * If the evalutation of the statement returns `false`, then `preventDefault`is applied on the DOM event. - * - * To listen to global events, a target must be added to the event name. - * The target can be `window`, `document` or `body`. - * - * When writing a directive event binding, you can also refer to the following local variables: - * - `$event`: Current event object which triggered the event. - * - `$target`: The source of the event. This will be either a DOM element or an Angular directive. - * (will be implemented in later release) - * - * - * ## Syntax - * - * ``` - * @Directive({ + * properties: [ + * 'text: tooltip' + * ], * hostListeners: { - * 'event1': 'onMethod1(arguments)', - * 'target:event2': 'onMethod2(arguments)', - * ... - * } - * } - * ``` - * - * ## Basic Event Binding: - * - * Suppose you want to write a directive that triggers on `change` events in the DOM and on `resize` events in window. - * You would define the event binding as follows: - * - * ``` - * @Directive({ - * selector: 'input', - * hostListeners: { - * 'change': 'onChange($event)', - * 'window:resize': 'onResize($event)' + * 'onmouseenter': 'onMouseEnter()', + * 'onmouseleave': 'onMouseLeave()' * } * }) - * class InputDirective { - * onChange(event:Event) { + * class Tooltip{ + * text:string; + * overlay:Overlay; // NOT YET IMPLEMENTED + * overlayManager:OverlayManager; // NOT YET IMPLEMENTED + * + * constructor(overlayManager:OverlayManager) { + * this.overlay = overlay; * } - * onResize(event:Event) { + * + * onMouseEnter() { + * // exact signature to be determined + * this.overlay = this.overlayManager.open(text, ...); + * } + * + * onMouseLeave() { + * this.overlay.close(); + * this.overlay = null; * } * } * ``` - * - * Here the `onChange` method of `InputDirective` is invoked whenever the DOM element fires the 'change' event. - * + * In our HTML template, we can then add this behavior to a `
              ` or any other element with the + * `tooltip` selector, + * like so: + * + * ``` + *
              + * ``` + * + * Directives can also control the instantiation, destruction, and positioning of inline template + * elements: + * + * A directive uses a ViewContainerRef to instantiate, insert, move, and destroy views at + * runtime. + * The ViewContainerRef is created as a result of `