ngx-bootstrap-dropdown.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, ChangeDetectorRef, Renderer2, ElementRef, Directive, ViewContainerRef, Input, Output, TemplateRef, HostBinding, HostListener, NgModule } from '@angular/core';
  2. import { filter } from 'rxjs/operators';
  3. import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
  4. import { isBs3 } from 'ngx-bootstrap/utils';
  5. import { style, animate, AnimationBuilder } from '@angular/animations';
  6. import { PositioningService } from 'ngx-bootstrap/positioning';
  7. /**
  8. * @fileoverview added by tsickle
  9. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10. */
  11. /**
  12. * Default dropdown configuration
  13. */
  14. class BsDropdownConfig {
  15. constructor() {
  16. /**
  17. * default dropdown auto closing behavior
  18. */
  19. this.autoClose = true;
  20. /**
  21. * default dropdown auto closing behavior
  22. */
  23. this.insideClick = false;
  24. /**
  25. * turn on/off animation
  26. */
  27. this.isAnimated = false;
  28. }
  29. }
  30. BsDropdownConfig.decorators = [
  31. { type: Injectable }
  32. ];
  33. /**
  34. * @fileoverview added by tsickle
  35. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  36. */
  37. class BsDropdownState {
  38. constructor() {
  39. this.direction = 'down';
  40. this.isOpenChange = new EventEmitter();
  41. this.isDisabledChange = new EventEmitter();
  42. this.toggleClick = new EventEmitter();
  43. this.dropdownMenu = new Promise((/**
  44. * @param {?} resolve
  45. * @return {?}
  46. */
  47. resolve => {
  48. this.resolveDropdownMenu = resolve;
  49. }));
  50. }
  51. }
  52. BsDropdownState.decorators = [
  53. { type: Injectable }
  54. ];
  55. /** @nocollapse */
  56. BsDropdownState.ctorParameters = () => [];
  57. /**
  58. * @fileoverview added by tsickle
  59. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  60. */
  61. /** @type {?} */
  62. const DROPDOWN_ANIMATION_TIMING = '220ms cubic-bezier(0, 0, 0.2, 1)';
  63. /** @type {?} */
  64. const dropdownAnimation = [
  65. style({ height: 0, overflow: 'hidden' }),
  66. animate(DROPDOWN_ANIMATION_TIMING, style({ height: '*', overflow: 'hidden' }))
  67. ];
  68. /**
  69. * @fileoverview added by tsickle
  70. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  71. */
  72. class BsDropdownContainerComponent {
  73. /**
  74. * @param {?} _state
  75. * @param {?} cd
  76. * @param {?} _renderer
  77. * @param {?} _element
  78. * @param {?} _builder
  79. */
  80. constructor(_state, cd, _renderer, _element, _builder) {
  81. this._state = _state;
  82. this.cd = cd;
  83. this._renderer = _renderer;
  84. this._element = _element;
  85. this.isOpen = false;
  86. this._factoryDropDownAnimation = _builder.build(dropdownAnimation);
  87. this._subscription = _state.isOpenChange.subscribe((/**
  88. * @param {?} value
  89. * @return {?}
  90. */
  91. (value) => {
  92. this.isOpen = value;
  93. /** @type {?} */
  94. const dropdown = this._element.nativeElement.querySelector('.dropdown-menu');
  95. this._renderer.addClass(this._element.nativeElement.querySelector('div'), 'open');
  96. if (dropdown && !isBs3()) {
  97. this._renderer.addClass(dropdown, 'show');
  98. if (dropdown.classList.contains('dropdown-menu-right')) {
  99. this._renderer.setStyle(dropdown, 'left', 'auto');
  100. this._renderer.setStyle(dropdown, 'right', '0');
  101. }
  102. if (this.direction === 'up') {
  103. this._renderer.setStyle(dropdown, 'top', 'auto');
  104. this._renderer.setStyle(dropdown, 'transform', 'translateY(-101%)');
  105. }
  106. }
  107. if (dropdown && this._state.isAnimated) {
  108. this._factoryDropDownAnimation.create(dropdown)
  109. .play();
  110. }
  111. this.cd.markForCheck();
  112. this.cd.detectChanges();
  113. }));
  114. }
  115. /**
  116. * @return {?}
  117. */
  118. get direction() {
  119. return this._state.direction;
  120. }
  121. /**
  122. * \@internal
  123. * @param {?} el
  124. * @return {?}
  125. */
  126. _contains(el) {
  127. return this._element.nativeElement.contains(el);
  128. }
  129. /**
  130. * @return {?}
  131. */
  132. ngOnDestroy() {
  133. this._subscription.unsubscribe();
  134. }
  135. }
  136. BsDropdownContainerComponent.decorators = [
  137. { type: Component, args: [{
  138. selector: 'bs-dropdown-container',
  139. changeDetection: ChangeDetectionStrategy.OnPush,
  140. host: {
  141. style: 'display:block;position: absolute;'
  142. },
  143. template: `
  144. <div [class.dropup]="direction === 'up'"
  145. [class.dropdown]="direction === 'down'"
  146. [class.show]="isOpen"
  147. [class.open]="isOpen"><ng-content></ng-content>
  148. </div>
  149. `
  150. }] }
  151. ];
  152. /** @nocollapse */
  153. BsDropdownContainerComponent.ctorParameters = () => [
  154. { type: BsDropdownState },
  155. { type: ChangeDetectorRef },
  156. { type: Renderer2 },
  157. { type: ElementRef },
  158. { type: AnimationBuilder }
  159. ];
  160. /**
  161. * @fileoverview added by tsickle
  162. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  163. */
  164. class BsDropdownDirective {
  165. /**
  166. * @param {?} _elementRef
  167. * @param {?} _renderer
  168. * @param {?} _viewContainerRef
  169. * @param {?} _cis
  170. * @param {?} _state
  171. * @param {?} _config
  172. * @param {?} _builder
  173. */
  174. constructor(_elementRef, _renderer, _viewContainerRef, _cis, _state, _config, _builder) {
  175. this._elementRef = _elementRef;
  176. this._renderer = _renderer;
  177. this._viewContainerRef = _viewContainerRef;
  178. this._cis = _cis;
  179. this._state = _state;
  180. this._config = _config;
  181. // todo: move to component loader
  182. this._isInlineOpen = false;
  183. this._subscriptions = [];
  184. this._isInited = false;
  185. // set initial dropdown state from config
  186. this._state.autoClose = this._config.autoClose;
  187. this._state.insideClick = this._config.insideClick;
  188. this._state.isAnimated = this._config.isAnimated;
  189. this._factoryDropDownAnimation = _builder.build(dropdownAnimation);
  190. // create dropdown component loader
  191. this._dropdown = this._cis
  192. .createLoader(this._elementRef, this._viewContainerRef, this._renderer)
  193. .provide({ provide: BsDropdownState, useValue: this._state });
  194. this.onShown = this._dropdown.onShown;
  195. this.onHidden = this._dropdown.onHidden;
  196. this.isOpenChange = this._state.isOpenChange;
  197. }
  198. /**
  199. * Indicates that dropdown will be closed on item or document click,
  200. * and after pressing ESC
  201. * @param {?} value
  202. * @return {?}
  203. */
  204. set autoClose(value) {
  205. this._state.autoClose = value;
  206. }
  207. /**
  208. * @return {?}
  209. */
  210. get autoClose() {
  211. return this._state.autoClose;
  212. }
  213. /**
  214. * Indicates that dropdown will be animated
  215. * @param {?} value
  216. * @return {?}
  217. */
  218. set isAnimated(value) {
  219. this._state.isAnimated = value;
  220. }
  221. /**
  222. * @return {?}
  223. */
  224. get isAnimated() {
  225. return this._state.isAnimated;
  226. }
  227. /**
  228. * This attribute indicates that the dropdown shouldn't close on inside click when autoClose is set to true
  229. * @param {?} value
  230. * @return {?}
  231. */
  232. set insideClick(value) {
  233. this._state.insideClick = value;
  234. }
  235. /**
  236. * @return {?}
  237. */
  238. get insideClick() {
  239. return this._state.insideClick;
  240. }
  241. /**
  242. * Disables dropdown toggle and hides dropdown menu if opened
  243. * @param {?} value
  244. * @return {?}
  245. */
  246. set isDisabled(value) {
  247. this._isDisabled = value;
  248. this._state.isDisabledChange.emit(value);
  249. if (value) {
  250. this.hide();
  251. }
  252. }
  253. /**
  254. * @return {?}
  255. */
  256. get isDisabled() {
  257. return this._isDisabled;
  258. }
  259. /**
  260. * Returns whether or not the popover is currently being shown
  261. * @return {?}
  262. */
  263. get isOpen() {
  264. if (this._showInline) {
  265. return this._isInlineOpen;
  266. }
  267. return this._dropdown.isShown;
  268. }
  269. /**
  270. * @param {?} value
  271. * @return {?}
  272. */
  273. set isOpen(value) {
  274. if (value) {
  275. this.show();
  276. }
  277. else {
  278. this.hide();
  279. }
  280. }
  281. /**
  282. * @return {?}
  283. */
  284. get isBs4() {
  285. return !isBs3();
  286. }
  287. /**
  288. * @private
  289. * @return {?}
  290. */
  291. get _showInline() {
  292. return !this.container;
  293. }
  294. /**
  295. * @return {?}
  296. */
  297. ngOnInit() {
  298. // fix: seems there are an issue with `routerLinkActive`
  299. // which result in duplicated call ngOnInit without call to ngOnDestroy
  300. // read more: https://github.com/valor-software/ngx-bootstrap/issues/1885
  301. if (this._isInited) {
  302. return;
  303. }
  304. this._isInited = true;
  305. // attach DOM listeners
  306. this._dropdown.listen({
  307. // because of dropdown inline mode
  308. outsideClick: false,
  309. triggers: this.triggers,
  310. show: (/**
  311. * @return {?}
  312. */
  313. () => this.show())
  314. });
  315. // toggle visibility on toggle element click
  316. this._subscriptions.push(this._state.toggleClick.subscribe((/**
  317. * @param {?} value
  318. * @return {?}
  319. */
  320. (value) => this.toggle(value))));
  321. // hide dropdown if set disabled while opened
  322. this._subscriptions.push(this._state.isDisabledChange
  323. .pipe(filter((/**
  324. * @param {?} value
  325. * @return {?}
  326. */
  327. (value) => value)))
  328. .subscribe((/**
  329. * @param {?} value
  330. * @return {?}
  331. */
  332. (value) => this.hide())));
  333. }
  334. /**
  335. * Opens an element’s popover. This is considered a “manual” triggering of
  336. * the popover.
  337. * @return {?}
  338. */
  339. show() {
  340. if (this.isOpen || this.isDisabled) {
  341. return;
  342. }
  343. if (this._showInline) {
  344. if (!this._inlinedMenu) {
  345. this._state.dropdownMenu.then((/**
  346. * @param {?} dropdownMenu
  347. * @return {?}
  348. */
  349. (dropdownMenu) => {
  350. this._dropdown.attachInline(dropdownMenu.viewContainer, dropdownMenu.templateRef);
  351. this._inlinedMenu = this._dropdown._inlineViewRef;
  352. this.addBs4Polyfills();
  353. this._renderer.addClass(this._inlinedMenu.rootNodes[0].parentNode, 'open');
  354. this.playAnimation();
  355. }))
  356. // swallow errors
  357. .catch();
  358. }
  359. this.addBs4Polyfills();
  360. this._isInlineOpen = true;
  361. this.onShown.emit(true);
  362. this._state.isOpenChange.emit(true);
  363. this.playAnimation();
  364. return;
  365. }
  366. this._state.dropdownMenu.then((/**
  367. * @param {?} dropdownMenu
  368. * @return {?}
  369. */
  370. dropdownMenu => {
  371. // check direction in which dropdown should be opened
  372. /** @type {?} */
  373. const _dropup = this.dropup ||
  374. (typeof this.dropup !== 'undefined' && this.dropup);
  375. this._state.direction = _dropup ? 'up' : 'down';
  376. /** @type {?} */
  377. const _placement = this.placement || (_dropup ? 'top start' : 'bottom start');
  378. // show dropdown
  379. this._dropdown
  380. .attach(BsDropdownContainerComponent)
  381. .to(this.container)
  382. .position({ attachment: _placement })
  383. .show({
  384. content: dropdownMenu.templateRef,
  385. placement: _placement
  386. });
  387. this._state.isOpenChange.emit(true);
  388. }))
  389. // swallow error
  390. .catch();
  391. }
  392. /**
  393. * Closes an element’s popover. This is considered a “manual” triggering of
  394. * the popover.
  395. * @return {?}
  396. */
  397. hide() {
  398. if (!this.isOpen) {
  399. return;
  400. }
  401. if (this._showInline) {
  402. this.removeShowClass();
  403. this.removeDropupStyles();
  404. this._isInlineOpen = false;
  405. this.onHidden.emit(true);
  406. }
  407. else {
  408. this._dropdown.hide();
  409. }
  410. this._state.isOpenChange.emit(false);
  411. }
  412. /**
  413. * Toggles an element’s popover. This is considered a “manual” triggering of
  414. * the popover. With parameter <code>true</code> allows toggling, with parameter <code>false</code>
  415. * only hides opened dropdown. Parameter usage will be removed in ngx-bootstrap v3
  416. * @param {?=} value
  417. * @return {?}
  418. */
  419. toggle(value) {
  420. if (this.isOpen || !value) {
  421. return this.hide();
  422. }
  423. return this.show();
  424. }
  425. /**
  426. * \@internal
  427. * @param {?} event
  428. * @return {?}
  429. */
  430. _contains(event) {
  431. return this._elementRef.nativeElement.contains(event.target) ||
  432. (this._dropdown.instance && this._dropdown.instance._contains(event.target));
  433. }
  434. /**
  435. * @return {?}
  436. */
  437. ngOnDestroy() {
  438. // clean up subscriptions and destroy dropdown
  439. for (const sub of this._subscriptions) {
  440. sub.unsubscribe();
  441. }
  442. this._dropdown.dispose();
  443. }
  444. /**
  445. * @private
  446. * @return {?}
  447. */
  448. addBs4Polyfills() {
  449. if (!isBs3()) {
  450. this.addShowClass();
  451. this.checkRightAlignment();
  452. this.addDropupStyles();
  453. }
  454. }
  455. /**
  456. * @private
  457. * @return {?}
  458. */
  459. playAnimation() {
  460. if (this._state.isAnimated && this._inlinedMenu) {
  461. this._factoryDropDownAnimation.create(this._inlinedMenu.rootNodes[0])
  462. .play();
  463. }
  464. }
  465. /**
  466. * @private
  467. * @return {?}
  468. */
  469. addShowClass() {
  470. if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
  471. this._renderer.addClass(this._inlinedMenu.rootNodes[0], 'show');
  472. }
  473. }
  474. /**
  475. * @private
  476. * @return {?}
  477. */
  478. removeShowClass() {
  479. if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
  480. this._renderer.removeClass(this._inlinedMenu.rootNodes[0], 'show');
  481. }
  482. }
  483. /**
  484. * @private
  485. * @return {?}
  486. */
  487. checkRightAlignment() {
  488. if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
  489. /** @type {?} */
  490. const isRightAligned = this._inlinedMenu.rootNodes[0].classList.contains('dropdown-menu-right');
  491. this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'left', isRightAligned ? 'auto' : '0');
  492. this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'right', isRightAligned ? '0' : 'auto');
  493. }
  494. }
  495. /**
  496. * @private
  497. * @return {?}
  498. */
  499. addDropupStyles() {
  500. if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
  501. // a little hack to not break support of bootstrap 4 beta
  502. this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'top', this.dropup ? 'auto' : '100%');
  503. this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'transform', this.dropup ? 'translateY(-101%)' : 'translateY(0)');
  504. this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'bottom', 'auto');
  505. }
  506. }
  507. /**
  508. * @private
  509. * @return {?}
  510. */
  511. removeDropupStyles() {
  512. if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
  513. this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'top');
  514. this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'transform');
  515. this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'bottom');
  516. }
  517. }
  518. }
  519. BsDropdownDirective.decorators = [
  520. { type: Directive, args: [{
  521. selector: '[bsDropdown],[dropdown]',
  522. exportAs: 'bs-dropdown',
  523. providers: [BsDropdownState],
  524. host: {
  525. '[class.dropup]': 'dropup',
  526. '[class.open]': 'isOpen',
  527. '[class.show]': 'isOpen && isBs4'
  528. }
  529. },] }
  530. ];
  531. /** @nocollapse */
  532. BsDropdownDirective.ctorParameters = () => [
  533. { type: ElementRef },
  534. { type: Renderer2 },
  535. { type: ViewContainerRef },
  536. { type: ComponentLoaderFactory },
  537. { type: BsDropdownState },
  538. { type: BsDropdownConfig },
  539. { type: AnimationBuilder }
  540. ];
  541. BsDropdownDirective.propDecorators = {
  542. placement: [{ type: Input }],
  543. triggers: [{ type: Input }],
  544. container: [{ type: Input }],
  545. dropup: [{ type: Input }],
  546. autoClose: [{ type: Input }],
  547. isAnimated: [{ type: Input }],
  548. insideClick: [{ type: Input }],
  549. isDisabled: [{ type: Input }],
  550. isOpen: [{ type: Input }],
  551. isOpenChange: [{ type: Output }],
  552. onShown: [{ type: Output }],
  553. onHidden: [{ type: Output }]
  554. };
  555. /**
  556. * @fileoverview added by tsickle
  557. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  558. */
  559. class BsDropdownMenuDirective {
  560. // tslint:disable:no-any
  561. /**
  562. * @param {?} _state
  563. * @param {?} _viewContainer
  564. * @param {?} _templateRef
  565. */
  566. constructor(_state, _viewContainer, _templateRef) {
  567. _state.resolveDropdownMenu({
  568. templateRef: _templateRef,
  569. viewContainer: _viewContainer
  570. });
  571. }
  572. }
  573. BsDropdownMenuDirective.decorators = [
  574. { type: Directive, args: [{
  575. selector: '[bsDropdownMenu],[dropdownMenu]',
  576. exportAs: 'bs-dropdown-menu'
  577. },] }
  578. ];
  579. /** @nocollapse */
  580. BsDropdownMenuDirective.ctorParameters = () => [
  581. { type: BsDropdownState },
  582. { type: ViewContainerRef },
  583. { type: TemplateRef }
  584. ];
  585. /**
  586. * @fileoverview added by tsickle
  587. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  588. */
  589. class BsDropdownToggleDirective {
  590. /**
  591. * @param {?} _changeDetectorRef
  592. * @param {?} _dropdown
  593. * @param {?} _element
  594. * @param {?} _renderer
  595. * @param {?} _state
  596. */
  597. constructor(_changeDetectorRef, _dropdown, _element, _renderer, _state) {
  598. this._changeDetectorRef = _changeDetectorRef;
  599. this._dropdown = _dropdown;
  600. this._element = _element;
  601. this._renderer = _renderer;
  602. this._state = _state;
  603. this.isDisabled = null;
  604. this._subscriptions = [];
  605. // sync is open value with state
  606. this._subscriptions.push(this._state.isOpenChange.subscribe((/**
  607. * @param {?} value
  608. * @return {?}
  609. */
  610. (value) => {
  611. this.isOpen = value;
  612. if (value) {
  613. this._documentClickListener = this._renderer.listen('document', 'click', (/**
  614. * @param {?} event
  615. * @return {?}
  616. */
  617. (event) => {
  618. if (this._state.autoClose && event.button !== 2 &&
  619. !this._element.nativeElement.contains(event.target) &&
  620. !(this._state.insideClick && this._dropdown._contains(event))) {
  621. this._state.toggleClick.emit(false);
  622. this._changeDetectorRef.detectChanges();
  623. }
  624. }));
  625. this._escKeyUpListener = this._renderer.listen(this._element.nativeElement, 'keyup.esc', (/**
  626. * @return {?}
  627. */
  628. () => {
  629. if (this._state.autoClose) {
  630. this._state.toggleClick.emit(false);
  631. this._changeDetectorRef.detectChanges();
  632. }
  633. }));
  634. }
  635. else {
  636. this._documentClickListener();
  637. this._escKeyUpListener();
  638. }
  639. })));
  640. // populate disabled state
  641. this._subscriptions.push(this._state.isDisabledChange.subscribe((/**
  642. * @param {?} value
  643. * @return {?}
  644. */
  645. (value) => (this.isDisabled = value || null))));
  646. }
  647. /**
  648. * @return {?}
  649. */
  650. onClick() {
  651. if (this.isDisabled) {
  652. return;
  653. }
  654. this._state.toggleClick.emit(true);
  655. }
  656. /**
  657. * @return {?}
  658. */
  659. ngOnDestroy() {
  660. if (this._documentClickListener) {
  661. this._documentClickListener();
  662. }
  663. if (this._escKeyUpListener) {
  664. this._escKeyUpListener();
  665. }
  666. for (const sub of this._subscriptions) {
  667. sub.unsubscribe();
  668. }
  669. }
  670. }
  671. BsDropdownToggleDirective.decorators = [
  672. { type: Directive, args: [{
  673. selector: '[bsDropdownToggle],[dropdownToggle]',
  674. exportAs: 'bs-dropdown-toggle',
  675. host: {
  676. '[attr.aria-haspopup]': 'true'
  677. }
  678. },] }
  679. ];
  680. /** @nocollapse */
  681. BsDropdownToggleDirective.ctorParameters = () => [
  682. { type: ChangeDetectorRef },
  683. { type: BsDropdownDirective },
  684. { type: ElementRef },
  685. { type: Renderer2 },
  686. { type: BsDropdownState }
  687. ];
  688. BsDropdownToggleDirective.propDecorators = {
  689. isDisabled: [{ type: HostBinding, args: ['attr.disabled',] }],
  690. isOpen: [{ type: HostBinding, args: ['attr.aria-expanded',] }],
  691. onClick: [{ type: HostListener, args: ['click', [],] }]
  692. };
  693. /**
  694. * @fileoverview added by tsickle
  695. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  696. */
  697. class BsDropdownModule {
  698. // tslint:disable-next-line:no-any
  699. /**
  700. * @param {?=} config
  701. * @return {?}
  702. */
  703. static forRoot(config) {
  704. return {
  705. ngModule: BsDropdownModule,
  706. providers: [
  707. ComponentLoaderFactory,
  708. PositioningService,
  709. BsDropdownState,
  710. {
  711. provide: BsDropdownConfig,
  712. useValue: config ? config : { autoClose: true, insideClick: false }
  713. }
  714. ]
  715. };
  716. }
  717. }
  718. BsDropdownModule.decorators = [
  719. { type: NgModule, args: [{
  720. declarations: [
  721. BsDropdownMenuDirective,
  722. BsDropdownToggleDirective,
  723. BsDropdownContainerComponent,
  724. BsDropdownDirective
  725. ],
  726. exports: [
  727. BsDropdownMenuDirective,
  728. BsDropdownToggleDirective,
  729. BsDropdownDirective
  730. ],
  731. entryComponents: [BsDropdownContainerComponent]
  732. },] }
  733. ];
  734. export { BsDropdownConfig, BsDropdownContainerComponent, BsDropdownDirective, BsDropdownMenuDirective, BsDropdownModule, BsDropdownState, BsDropdownToggleDirective };
  735. //# sourceMappingURL=ngx-bootstrap-dropdown.js.map