dropdown.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone, AfterContentInit, OnDestroy, QueryList, Renderer2, SimpleChanges } from '@angular/core';
  2. import { Placement, PlacementArray } from '../util/positioning';
  3. import { NgbDropdownConfig } from './dropdown-config';
  4. export declare class NgbNavbar {
  5. }
  6. /**
  7. * A directive you should put on a dropdown item to enable keyboard navigation.
  8. * Arrow keys will move focus between items marked with this directive.
  9. *
  10. * @since 4.1.0
  11. */
  12. export declare class NgbDropdownItem {
  13. elementRef: ElementRef<HTMLElement>;
  14. private _disabled;
  15. disabled: boolean;
  16. constructor(elementRef: ElementRef<HTMLElement>);
  17. }
  18. /**
  19. * A directive that wraps dropdown menu content and dropdown items.
  20. */
  21. export declare class NgbDropdownMenu {
  22. dropdown: any;
  23. placement: Placement;
  24. isOpen: boolean;
  25. menuItems: QueryList<NgbDropdownItem>;
  26. constructor(dropdown: any);
  27. }
  28. /**
  29. * A directive to mark an element to which dropdown menu will be anchored.
  30. *
  31. * This is a simple version of the `NgbDropdownToggle` directive.
  32. * It plays the same role, but doesn't listen to click events to toggle dropdown menu thus enabling support
  33. * for events other than click.
  34. *
  35. * @since 1.1.0
  36. */
  37. export declare class NgbDropdownAnchor {
  38. dropdown: any;
  39. private _elementRef;
  40. anchorEl: any;
  41. constructor(dropdown: any, _elementRef: ElementRef<HTMLElement>);
  42. getNativeElement(): HTMLElement;
  43. }
  44. /**
  45. * A directive to mark an element that will toggle dropdown via the `click` event.
  46. *
  47. * You can also use `NgbDropdownAnchor` as an alternative.
  48. */
  49. export declare class NgbDropdownToggle extends NgbDropdownAnchor {
  50. constructor(dropdown: any, elementRef: ElementRef<HTMLElement>);
  51. }
  52. /**
  53. * A directive that provides contextual overlays for displaying lists of links and more.
  54. */
  55. export declare class NgbDropdown implements AfterContentInit, OnDestroy {
  56. private _changeDetector;
  57. private _document;
  58. private _ngZone;
  59. private _elementRef;
  60. private _renderer;
  61. private _closed$;
  62. private _zoneSubscription;
  63. private _bodyContainer;
  64. private _menu;
  65. private _menuElement;
  66. private _anchor;
  67. /**
  68. * Indicates whether the dropdown should be closed when clicking one of dropdown items or pressing ESC.
  69. *
  70. * * `true` - the dropdown will close on both outside and inside (menu) clicks.
  71. * * `false` - the dropdown can only be closed manually via `close()` or `toggle()` methods.
  72. * * `"inside"` - the dropdown will close on inside menu clicks, but not outside clicks.
  73. * * `"outside"` - the dropdown will close only on the outside clicks and not on menu clicks.
  74. */
  75. autoClose: boolean | 'outside' | 'inside';
  76. /**
  77. * Defines whether or not the dropdown menu is opened initially.
  78. */
  79. _open: boolean;
  80. /**
  81. * The preferred placement of the dropdown.
  82. *
  83. * Possible values are `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`,
  84. * `"bottom-right"`, `"left"`, `"left-top"`, `"left-bottom"`, `"right"`, `"right-top"`,
  85. * `"right-bottom"`
  86. *
  87. * Accepts an array of strings or a string with space separated possible values.
  88. *
  89. * The default order of preference is `"bottom-left bottom-right top-left top-right"`
  90. *
  91. * Please see the [positioning overview](#/positioning) for more details.
  92. */
  93. placement: PlacementArray;
  94. /**
  95. * A selector specifying the element the dropdown should be appended to.
  96. * Currently only supports "body".
  97. *
  98. * @since 4.1.0
  99. */
  100. container: null | 'body';
  101. /**
  102. * Enable or disable the dynamic positioning. The default value is dynamic unless the dropdown is used
  103. * inside a Bootstrap navbar. If you need custom placement for a dropdown in a navbar, set it to
  104. * dynamic explicitly. See the [positioning of dropdown](#/positioning#dropdown)
  105. * and the [navbar demo](/#/components/dropdown/examples#navbar) for more details.
  106. *
  107. * @since 4.2.0
  108. */
  109. display: 'dynamic' | 'static';
  110. /**
  111. * An event fired when the dropdown is opened or closed.
  112. *
  113. * The event payload is a `boolean`:
  114. * * `true` - the dropdown was opened
  115. * * `false` - the dropdown was closed
  116. */
  117. openChange: EventEmitter<boolean>;
  118. constructor(_changeDetector: ChangeDetectorRef, config: NgbDropdownConfig, _document: any, _ngZone: NgZone, _elementRef: ElementRef<HTMLElement>, _renderer: Renderer2, ngbNavbar: NgbNavbar);
  119. ngAfterContentInit(): void;
  120. ngOnChanges(changes: SimpleChanges): void;
  121. /**
  122. * Checks if the dropdown menu is open.
  123. */
  124. isOpen(): boolean;
  125. /**
  126. * Opens the dropdown menu.
  127. */
  128. open(): void;
  129. private _setCloseHandlers;
  130. /**
  131. * Closes the dropdown menu.
  132. */
  133. close(): void;
  134. /**
  135. * Toggles the dropdown menu.
  136. */
  137. toggle(): void;
  138. ngOnDestroy(): void;
  139. onKeyDown(event: KeyboardEvent): void;
  140. private _isDropup;
  141. private _isEventFromToggle;
  142. private _getMenuElements;
  143. private _positionMenu;
  144. private _getFirstPlacement;
  145. private _resetContainer;
  146. private _applyContainer;
  147. private _applyPlacementClasses;
  148. }