dropdown.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. "use strict";
  2. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7. };
  8. var __metadata = (this && this.__metadata) || function (k, v) {
  9. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var scrolling_1 = require("@angular/cdk/scrolling");
  13. var core_1 = require("@angular/core");
  14. var animations_1 = require("@angular/animations");
  15. var common_1 = require("@angular/common");
  16. var shared_1 = require("../common/shared");
  17. var domhandler_1 = require("../dom/domhandler");
  18. var objectutils_1 = require("../utils/objectutils");
  19. var forms_1 = require("@angular/forms");
  20. var filterutils_1 = require("../utils/filterutils");
  21. var tooltip_1 = require("../tooltip/tooltip");
  22. exports.DROPDOWN_VALUE_ACCESSOR = {
  23. provide: forms_1.NG_VALUE_ACCESSOR,
  24. useExisting: core_1.forwardRef(function () { return Dropdown; }),
  25. multi: true
  26. };
  27. var DropdownItem = /** @class */ (function () {
  28. function DropdownItem() {
  29. this.onClick = new core_1.EventEmitter();
  30. }
  31. DropdownItem.prototype.onOptionClick = function (event) {
  32. this.onClick.emit({
  33. originalEvent: event,
  34. option: this.option
  35. });
  36. };
  37. __decorate([
  38. core_1.Input(),
  39. __metadata("design:type", Object)
  40. ], DropdownItem.prototype, "option", void 0);
  41. __decorate([
  42. core_1.Input(),
  43. __metadata("design:type", Boolean)
  44. ], DropdownItem.prototype, "selected", void 0);
  45. __decorate([
  46. core_1.Input(),
  47. __metadata("design:type", Boolean)
  48. ], DropdownItem.prototype, "disabled", void 0);
  49. __decorate([
  50. core_1.Input(),
  51. __metadata("design:type", Boolean)
  52. ], DropdownItem.prototype, "visible", void 0);
  53. __decorate([
  54. core_1.Input(),
  55. __metadata("design:type", Number)
  56. ], DropdownItem.prototype, "itemSize", void 0);
  57. __decorate([
  58. core_1.Input(),
  59. __metadata("design:type", core_1.TemplateRef)
  60. ], DropdownItem.prototype, "template", void 0);
  61. __decorate([
  62. core_1.Output(),
  63. __metadata("design:type", core_1.EventEmitter)
  64. ], DropdownItem.prototype, "onClick", void 0);
  65. DropdownItem = __decorate([
  66. core_1.Component({
  67. selector: 'p-dropdownItem',
  68. template: "\n <li (click)=\"onOptionClick($event)\" role=\"option\"\n [attr.aria-label]=\"option.label\"\n [ngStyle]=\"{'height': itemSize + 'px'}\"\n [ngClass]=\"{'ui-dropdown-item ui-corner-all':true,\n 'ui-state-highlight': selected,\n 'ui-state-disabled':(option.disabled),\n 'ui-dropdown-item-empty': !option.label||option.label.length === 0}\">\n <span *ngIf=\"!template\">{{option.label||'empty'}}</span>\n <ng-container *ngTemplateOutlet=\"template; context: {$implicit: option}\"></ng-container>\n </li>\n "
  69. })
  70. ], DropdownItem);
  71. return DropdownItem;
  72. }());
  73. exports.DropdownItem = DropdownItem;
  74. var Dropdown = /** @class */ (function () {
  75. function Dropdown(el, renderer, cd, zone) {
  76. this.el = el;
  77. this.renderer = renderer;
  78. this.cd = cd;
  79. this.zone = zone;
  80. this.scrollHeight = '200px';
  81. this.filterBy = 'label';
  82. this.resetFilterOnHide = false;
  83. this.dropdownIcon = 'pi pi-chevron-down';
  84. this.autoDisplayFirst = true;
  85. this.emptyFilterMessage = 'No results found';
  86. this.autoZIndex = true;
  87. this.baseZIndex = 0;
  88. this.showTransitionOptions = '225ms ease-out';
  89. this.hideTransitionOptions = '195ms ease-in';
  90. this.filterMatchMode = "contains";
  91. this.tooltip = '';
  92. this.tooltipPosition = 'right';
  93. this.tooltipPositionStyle = 'absolute';
  94. this.onChange = new core_1.EventEmitter();
  95. this.onFocus = new core_1.EventEmitter();
  96. this.onBlur = new core_1.EventEmitter();
  97. this.onClick = new core_1.EventEmitter();
  98. this.onShow = new core_1.EventEmitter();
  99. this.onHide = new core_1.EventEmitter();
  100. this.onModelChange = function () { };
  101. this.onModelTouched = function () { };
  102. this.viewPortOffsetTop = 0;
  103. }
  104. Object.defineProperty(Dropdown.prototype, "autoWidth", {
  105. get: function () {
  106. return this._autoWidth;
  107. },
  108. set: function (_autoWidth) {
  109. this._autoWidth = _autoWidth;
  110. console.log("Setting autoWidth has no effect as automatic width calculation is removed for better perfomance.");
  111. },
  112. enumerable: true,
  113. configurable: true
  114. });
  115. Object.defineProperty(Dropdown.prototype, "disabled", {
  116. get: function () {
  117. return this._disabled;
  118. },
  119. set: function (_disabled) {
  120. if (_disabled)
  121. this.focused = false;
  122. this._disabled = _disabled;
  123. if (!this.cd.destroyed) {
  124. this.cd.detectChanges();
  125. }
  126. },
  127. enumerable: true,
  128. configurable: true
  129. });
  130. ;
  131. Dropdown.prototype.ngAfterContentInit = function () {
  132. var _this = this;
  133. this.templates.forEach(function (item) {
  134. switch (item.getType()) {
  135. case 'item':
  136. _this.itemTemplate = item.template;
  137. break;
  138. case 'selectedItem':
  139. _this.selectedItemTemplate = item.template;
  140. break;
  141. case 'group':
  142. _this.groupTemplate = item.template;
  143. break;
  144. default:
  145. _this.itemTemplate = item.template;
  146. break;
  147. }
  148. });
  149. };
  150. Dropdown.prototype.ngOnInit = function () {
  151. this.optionsToDisplay = this.options;
  152. this.updateSelectedOption(null);
  153. };
  154. Object.defineProperty(Dropdown.prototype, "options", {
  155. get: function () {
  156. return this._options;
  157. },
  158. set: function (val) {
  159. var opts = this.optionLabel ? objectutils_1.ObjectUtils.generateSelectItems(val, this.optionLabel) : val;
  160. this._options = opts;
  161. this.optionsToDisplay = this._options;
  162. this.updateSelectedOption(this.value);
  163. this.optionsChanged = true;
  164. if (this.filterValue && this.filterValue.length) {
  165. this.activateFilter();
  166. }
  167. },
  168. enumerable: true,
  169. configurable: true
  170. });
  171. Dropdown.prototype.ngAfterViewInit = function () {
  172. if (this.editable) {
  173. this.updateEditableLabel();
  174. }
  175. };
  176. Object.defineProperty(Dropdown.prototype, "label", {
  177. get: function () {
  178. return (this.selectedOption ? this.selectedOption.label : null);
  179. },
  180. enumerable: true,
  181. configurable: true
  182. });
  183. Dropdown.prototype.updateEditableLabel = function () {
  184. if (this.editableInputViewChild && this.editableInputViewChild.nativeElement) {
  185. this.editableInputViewChild.nativeElement.value = (this.selectedOption ? this.selectedOption.label : this.value || '');
  186. }
  187. };
  188. Dropdown.prototype.onItemClick = function (event) {
  189. var _this = this;
  190. var option = event.option;
  191. this.itemClick = true;
  192. if (!option.disabled) {
  193. this.selectItem(event, option);
  194. this.focusViewChild.nativeElement.focus();
  195. }
  196. setTimeout(function () {
  197. _this.hide(event);
  198. }, 150);
  199. };
  200. Dropdown.prototype.selectItem = function (event, option) {
  201. var _this = this;
  202. if (this.selectedOption != option) {
  203. this.selectedOption = option;
  204. this.value = option.value;
  205. this.filled = true;
  206. this.onModelChange(this.value);
  207. this.updateEditableLabel();
  208. this.onChange.emit({
  209. originalEvent: event.originalEvent,
  210. value: this.value
  211. });
  212. if (this.virtualScroll) {
  213. setTimeout(function () {
  214. _this.viewPortOffsetTop = _this.viewPort.measureScrollOffset();
  215. }, 1);
  216. }
  217. }
  218. };
  219. Dropdown.prototype.ngAfterViewChecked = function () {
  220. var _this = this;
  221. if (this.optionsChanged && this.overlayVisible) {
  222. this.optionsChanged = false;
  223. if (this.virtualScroll) {
  224. this.updateVirtualScrollSelectedIndex(true);
  225. }
  226. this.zone.runOutsideAngular(function () {
  227. setTimeout(function () {
  228. _this.alignOverlay();
  229. }, 1);
  230. });
  231. }
  232. if (this.selectedOptionUpdated && this.itemsWrapper) {
  233. if (this.virtualScroll && this.viewPort) {
  234. var range = this.viewPort.getRenderedRange();
  235. this.updateVirtualScrollSelectedIndex(false);
  236. if (range.start > this.virtualScrollSelectedIndex || range.end < this.virtualScrollSelectedIndex) {
  237. this.viewPort.scrollToIndex(this.virtualScrollSelectedIndex);
  238. }
  239. }
  240. var selectedItem = domhandler_1.DomHandler.findSingle(this.overlay, 'li.ui-state-highlight');
  241. if (selectedItem) {
  242. domhandler_1.DomHandler.scrollInView(this.itemsWrapper, domhandler_1.DomHandler.findSingle(this.overlay, 'li.ui-state-highlight'));
  243. }
  244. this.selectedOptionUpdated = false;
  245. }
  246. };
  247. Dropdown.prototype.writeValue = function (value) {
  248. if (this.filter) {
  249. this.resetFilter();
  250. }
  251. this.value = value;
  252. this.updateSelectedOption(value);
  253. this.updateEditableLabel();
  254. this.updateFilledState();
  255. this.cd.markForCheck();
  256. };
  257. Dropdown.prototype.resetFilter = function () {
  258. if (this.filterViewChild && this.filterViewChild.nativeElement) {
  259. this.filterValue = null;
  260. this.filterViewChild.nativeElement.value = '';
  261. }
  262. this.optionsToDisplay = this.options;
  263. };
  264. Dropdown.prototype.updateSelectedOption = function (val) {
  265. this.selectedOption = this.findOption(val, this.optionsToDisplay);
  266. if (this.autoDisplayFirst && !this.placeholder && !this.selectedOption && this.optionsToDisplay && this.optionsToDisplay.length && !this.editable) {
  267. this.selectedOption = this.optionsToDisplay[0];
  268. }
  269. this.selectedOptionUpdated = true;
  270. };
  271. Dropdown.prototype.registerOnChange = function (fn) {
  272. this.onModelChange = fn;
  273. };
  274. Dropdown.prototype.registerOnTouched = function (fn) {
  275. this.onModelTouched = fn;
  276. };
  277. Dropdown.prototype.setDisabledState = function (val) {
  278. this.disabled = val;
  279. };
  280. Dropdown.prototype.onMouseclick = function (event) {
  281. if (this.disabled || this.readonly) {
  282. return;
  283. }
  284. this.onClick.emit(event);
  285. this.selfClick = true;
  286. this.clearClick = domhandler_1.DomHandler.hasClass(event.target, 'ui-dropdown-clear-icon');
  287. if (!this.itemClick && !this.clearClick) {
  288. this.focusViewChild.nativeElement.focus();
  289. if (this.overlayVisible)
  290. this.hide(event);
  291. else
  292. this.show();
  293. this.cd.detectChanges();
  294. }
  295. };
  296. Dropdown.prototype.onEditableInputClick = function (event) {
  297. this.itemClick = true;
  298. this.bindDocumentClickListener();
  299. };
  300. Dropdown.prototype.onEditableInputFocus = function (event) {
  301. this.focused = true;
  302. this.hide(event);
  303. this.onFocus.emit(event);
  304. };
  305. Dropdown.prototype.onEditableInputChange = function (event) {
  306. this.value = event.target.value;
  307. this.updateSelectedOption(this.value);
  308. this.onModelChange(this.value);
  309. this.onChange.emit({
  310. originalEvent: event,
  311. value: this.value
  312. });
  313. };
  314. Dropdown.prototype.show = function () {
  315. this.overlayVisible = true;
  316. };
  317. Dropdown.prototype.onOverlayAnimationStart = function (event) {
  318. switch (event.toState) {
  319. case 'visible':
  320. this.overlay = event.element;
  321. var itemsWrapperSelector = this.virtualScroll ? '.cdk-virtual-scroll-viewport' : '.ui-dropdown-items-wrapper';
  322. this.itemsWrapper = domhandler_1.DomHandler.findSingle(this.overlay, itemsWrapperSelector);
  323. this.appendOverlay();
  324. if (this.autoZIndex) {
  325. this.overlay.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex));
  326. }
  327. this.alignOverlay();
  328. this.bindDocumentClickListener();
  329. this.bindDocumentResizeListener();
  330. if (this.options && this.options.length) {
  331. if (!this.virtualScroll) {
  332. var selectedListItem = domhandler_1.DomHandler.findSingle(this.itemsWrapper, '.ui-dropdown-item.ui-state-highlight');
  333. if (selectedListItem) {
  334. domhandler_1.DomHandler.scrollInView(this.itemsWrapper, selectedListItem);
  335. }
  336. }
  337. }
  338. if (this.filterViewChild && this.filterViewChild.nativeElement) {
  339. this.filterViewChild.nativeElement.focus();
  340. }
  341. this.onShow.emit(event);
  342. break;
  343. case 'void':
  344. this.onOverlayHide();
  345. break;
  346. }
  347. };
  348. Dropdown.prototype.scrollToSelectedVirtualScrollElement = function () {
  349. if (!this.virtualAutoScrolled) {
  350. if (this.viewPortOffsetTop) {
  351. this.viewPort.scrollToOffset(this.viewPortOffsetTop);
  352. }
  353. else if (this.virtualScrollSelectedIndex > -1) {
  354. this.viewPort.scrollToIndex(this.virtualScrollSelectedIndex);
  355. }
  356. }
  357. this.virtualAutoScrolled = true;
  358. };
  359. Dropdown.prototype.updateVirtualScrollSelectedIndex = function (resetOffset) {
  360. if (this.selectedOption && this.optionsToDisplay && this.optionsToDisplay.length) {
  361. if (resetOffset) {
  362. this.viewPortOffsetTop = 0;
  363. }
  364. this.virtualScrollSelectedIndex = this.findOptionIndex(this.selectedOption.value, this.optionsToDisplay);
  365. }
  366. };
  367. Dropdown.prototype.appendOverlay = function () {
  368. if (this.appendTo) {
  369. if (this.appendTo === 'body')
  370. document.body.appendChild(this.overlay);
  371. else
  372. domhandler_1.DomHandler.appendChild(this.overlay, this.appendTo);
  373. this.overlay.style.minWidth = domhandler_1.DomHandler.getWidth(this.containerViewChild.nativeElement) + 'px';
  374. }
  375. };
  376. Dropdown.prototype.restoreOverlayAppend = function () {
  377. if (this.overlay && this.appendTo) {
  378. this.el.nativeElement.appendChild(this.overlay);
  379. }
  380. };
  381. Dropdown.prototype.hide = function (event) {
  382. this.overlayVisible = false;
  383. if (this.filter && this.resetFilterOnHide) {
  384. this.resetFilter();
  385. }
  386. if (this.virtualScroll) {
  387. this.virtualAutoScrolled = false;
  388. }
  389. this.cd.markForCheck();
  390. this.onHide.emit(event);
  391. };
  392. Dropdown.prototype.alignOverlay = function () {
  393. if (this.overlay) {
  394. if (this.appendTo)
  395. domhandler_1.DomHandler.absolutePosition(this.overlay, this.containerViewChild.nativeElement);
  396. else
  397. domhandler_1.DomHandler.relativePosition(this.overlay, this.containerViewChild.nativeElement);
  398. }
  399. };
  400. Dropdown.prototype.onInputFocus = function (event) {
  401. this.focused = true;
  402. this.onFocus.emit(event);
  403. };
  404. Dropdown.prototype.onInputBlur = function (event) {
  405. this.focused = false;
  406. this.onModelTouched();
  407. this.onBlur.emit(event);
  408. };
  409. Dropdown.prototype.findPrevEnabledOption = function (index) {
  410. var prevEnabledOption;
  411. if (this.optionsToDisplay && this.optionsToDisplay.length) {
  412. for (var i = (index - 1); 0 <= i; i--) {
  413. var option = this.optionsToDisplay[i];
  414. if (option.disabled) {
  415. continue;
  416. }
  417. else {
  418. prevEnabledOption = option;
  419. break;
  420. }
  421. }
  422. if (!prevEnabledOption) {
  423. for (var i = this.optionsToDisplay.length - 1; i >= index; i--) {
  424. var option = this.optionsToDisplay[i];
  425. if (option.disabled) {
  426. continue;
  427. }
  428. else {
  429. prevEnabledOption = option;
  430. break;
  431. }
  432. }
  433. }
  434. }
  435. return prevEnabledOption;
  436. };
  437. Dropdown.prototype.findNextEnabledOption = function (index) {
  438. var nextEnabledOption;
  439. if (this.optionsToDisplay && this.optionsToDisplay.length) {
  440. for (var i = (index + 1); index < (this.optionsToDisplay.length - 1); i++) {
  441. var option = this.optionsToDisplay[i];
  442. if (option.disabled) {
  443. continue;
  444. }
  445. else {
  446. nextEnabledOption = option;
  447. break;
  448. }
  449. }
  450. if (!nextEnabledOption) {
  451. for (var i = 0; i < index; i++) {
  452. var option = this.optionsToDisplay[i];
  453. if (option.disabled) {
  454. continue;
  455. }
  456. else {
  457. nextEnabledOption = option;
  458. break;
  459. }
  460. }
  461. }
  462. }
  463. return nextEnabledOption;
  464. };
  465. Dropdown.prototype.onKeydown = function (event, search) {
  466. if (this.readonly || !this.optionsToDisplay || this.optionsToDisplay.length === null) {
  467. return;
  468. }
  469. switch (event.which) {
  470. //down
  471. case 40:
  472. if (!this.overlayVisible && event.altKey) {
  473. this.show();
  474. }
  475. else {
  476. if (this.group) {
  477. var selectedItemIndex = this.selectedOption ? this.findOptionGroupIndex(this.selectedOption.value, this.optionsToDisplay) : -1;
  478. if (selectedItemIndex !== -1) {
  479. var nextItemIndex = selectedItemIndex.itemIndex + 1;
  480. if (nextItemIndex < (this.optionsToDisplay[selectedItemIndex.groupIndex].items.length)) {
  481. this.selectItem(event, this.optionsToDisplay[selectedItemIndex.groupIndex].items[nextItemIndex]);
  482. this.selectedOptionUpdated = true;
  483. }
  484. else if (this.optionsToDisplay[selectedItemIndex.groupIndex + 1]) {
  485. this.selectItem(event, this.optionsToDisplay[selectedItemIndex.groupIndex + 1].items[0]);
  486. this.selectedOptionUpdated = true;
  487. }
  488. }
  489. else {
  490. this.selectItem(event, this.optionsToDisplay[0].items[0]);
  491. }
  492. }
  493. else {
  494. var selectedItemIndex = this.selectedOption ? this.findOptionIndex(this.selectedOption.value, this.optionsToDisplay) : -1;
  495. var nextEnabledOption = this.findNextEnabledOption(selectedItemIndex);
  496. if (nextEnabledOption) {
  497. this.selectItem(event, nextEnabledOption);
  498. this.selectedOptionUpdated = true;
  499. }
  500. }
  501. }
  502. event.preventDefault();
  503. break;
  504. //up
  505. case 38:
  506. if (this.group) {
  507. var selectedItemIndex = this.selectedOption ? this.findOptionGroupIndex(this.selectedOption.value, this.optionsToDisplay) : -1;
  508. if (selectedItemIndex !== -1) {
  509. var prevItemIndex = selectedItemIndex.itemIndex - 1;
  510. if (prevItemIndex >= 0) {
  511. this.selectItem(event, this.optionsToDisplay[selectedItemIndex.groupIndex].items[prevItemIndex]);
  512. this.selectedOptionUpdated = true;
  513. }
  514. else if (prevItemIndex < 0) {
  515. var prevGroup = this.optionsToDisplay[selectedItemIndex.groupIndex - 1];
  516. if (prevGroup) {
  517. this.selectItem(event, prevGroup.items[prevGroup.items.length - 1]);
  518. this.selectedOptionUpdated = true;
  519. }
  520. }
  521. }
  522. }
  523. else {
  524. var selectedItemIndex = this.selectedOption ? this.findOptionIndex(this.selectedOption.value, this.optionsToDisplay) : -1;
  525. var prevEnabledOption = this.findPrevEnabledOption(selectedItemIndex);
  526. if (prevEnabledOption) {
  527. this.selectItem(event, prevEnabledOption);
  528. this.selectedOptionUpdated = true;
  529. }
  530. }
  531. event.preventDefault();
  532. break;
  533. //space
  534. case 32:
  535. case 32:
  536. if (!this.overlayVisible) {
  537. this.show();
  538. event.preventDefault();
  539. }
  540. break;
  541. //enter
  542. case 13:
  543. if (!this.filter || (this.optionsToDisplay && this.optionsToDisplay.length > 0)) {
  544. this.hide(event);
  545. }
  546. event.preventDefault();
  547. break;
  548. //escape and tab
  549. case 27:
  550. case 9:
  551. this.hide(event);
  552. break;
  553. //search item based on keyboard input
  554. default:
  555. if (search) {
  556. this.search(event);
  557. }
  558. break;
  559. }
  560. };
  561. Dropdown.prototype.search = function (event) {
  562. var _this = this;
  563. if (this.searchTimeout) {
  564. clearTimeout(this.searchTimeout);
  565. }
  566. var char = event.key;
  567. this.previousSearchChar = this.currentSearchChar;
  568. this.currentSearchChar = char;
  569. if (this.previousSearchChar === this.currentSearchChar)
  570. this.searchValue = this.currentSearchChar;
  571. else
  572. this.searchValue = this.searchValue ? this.searchValue + char : char;
  573. var newOption;
  574. if (this.group) {
  575. var searchIndex = this.selectedOption ? this.findOptionGroupIndex(this.selectedOption.value, this.optionsToDisplay) : { groupIndex: 0, itemIndex: 0 };
  576. newOption = this.searchOptionWithinGroup(searchIndex);
  577. }
  578. else {
  579. var searchIndex = this.selectedOption ? this.findOptionIndex(this.selectedOption.value, this.optionsToDisplay) : -1;
  580. newOption = this.searchOption(++searchIndex);
  581. }
  582. if (newOption) {
  583. this.selectItem(event, newOption);
  584. this.selectedOptionUpdated = true;
  585. }
  586. this.searchTimeout = setTimeout(function () {
  587. _this.searchValue = null;
  588. }, 250);
  589. };
  590. Dropdown.prototype.searchOption = function (index) {
  591. var option;
  592. if (this.searchValue) {
  593. option = this.searchOptionInRange(index, this.optionsToDisplay.length);
  594. if (!option) {
  595. option = this.searchOptionInRange(0, index);
  596. }
  597. }
  598. return option;
  599. };
  600. Dropdown.prototype.searchOptionInRange = function (start, end) {
  601. for (var i = start; i < end; i++) {
  602. var opt = this.optionsToDisplay[i];
  603. if (opt.label.toLowerCase().startsWith(this.searchValue.toLowerCase())) {
  604. return opt;
  605. }
  606. }
  607. return null;
  608. };
  609. Dropdown.prototype.searchOptionWithinGroup = function (index) {
  610. var option;
  611. if (this.searchValue) {
  612. for (var i = index.groupIndex; i < this.optionsToDisplay.length; i++) {
  613. for (var j = (index.groupIndex === i) ? (index.itemIndex + 1) : 0; j < this.optionsToDisplay[i].items.length; j++) {
  614. var opt = this.optionsToDisplay[i].items[j];
  615. if (opt.label.toLowerCase().startsWith(this.searchValue.toLowerCase())) {
  616. return opt;
  617. }
  618. }
  619. }
  620. if (!option) {
  621. for (var i = 0; i <= index.groupIndex; i++) {
  622. for (var j = 0; j < ((index.groupIndex === i) ? index.itemIndex : this.optionsToDisplay[i].items.length); j++) {
  623. var opt = this.optionsToDisplay[i].items[j];
  624. if (opt.label.toLowerCase().startsWith(this.searchValue.toLowerCase())) {
  625. return opt;
  626. }
  627. }
  628. }
  629. }
  630. }
  631. return null;
  632. };
  633. Dropdown.prototype.findOptionIndex = function (val, opts) {
  634. var index = -1;
  635. if (opts) {
  636. for (var i = 0; i < opts.length; i++) {
  637. if ((val == null && opts[i].value == null) || objectutils_1.ObjectUtils.equals(val, opts[i].value, this.dataKey)) {
  638. index = i;
  639. break;
  640. }
  641. }
  642. }
  643. return index;
  644. };
  645. Dropdown.prototype.findOptionGroupIndex = function (val, opts) {
  646. var groupIndex, itemIndex;
  647. if (opts) {
  648. for (var i = 0; i < opts.length; i++) {
  649. groupIndex = i;
  650. itemIndex = this.findOptionIndex(val, opts[i].items);
  651. if (itemIndex !== -1) {
  652. break;
  653. }
  654. }
  655. }
  656. if (itemIndex !== -1) {
  657. return { groupIndex: groupIndex, itemIndex: itemIndex };
  658. }
  659. else {
  660. return -1;
  661. }
  662. };
  663. Dropdown.prototype.findOption = function (val, opts, inGroup) {
  664. if (this.group && !inGroup) {
  665. var opt = void 0;
  666. if (opts && opts.length) {
  667. for (var _i = 0, opts_1 = opts; _i < opts_1.length; _i++) {
  668. var optgroup = opts_1[_i];
  669. opt = this.findOption(val, optgroup.items, true);
  670. if (opt) {
  671. break;
  672. }
  673. }
  674. }
  675. return opt;
  676. }
  677. else {
  678. var index = this.findOptionIndex(val, opts);
  679. return (index != -1) ? opts[index] : null;
  680. }
  681. };
  682. Dropdown.prototype.onFilter = function (event) {
  683. var inputValue = event.target.value;
  684. if (inputValue && inputValue.length) {
  685. this.filterValue = inputValue;
  686. this.activateFilter();
  687. }
  688. else {
  689. this.filterValue = null;
  690. this.optionsToDisplay = this.options;
  691. }
  692. this.optionsChanged = true;
  693. };
  694. Dropdown.prototype.activateFilter = function () {
  695. var searchFields = this.filterBy.split(',');
  696. if (this.options && this.options.length) {
  697. if (this.group) {
  698. var filteredGroups = [];
  699. for (var _i = 0, _a = this.options; _i < _a.length; _i++) {
  700. var optgroup = _a[_i];
  701. var filteredSubOptions = filterutils_1.FilterUtils.filter(optgroup.items, searchFields, this.filterValue, this.filterMatchMode);
  702. if (filteredSubOptions && filteredSubOptions.length) {
  703. filteredGroups.push({
  704. label: optgroup.label,
  705. value: optgroup.value,
  706. items: filteredSubOptions
  707. });
  708. }
  709. }
  710. this.optionsToDisplay = filteredGroups;
  711. }
  712. else {
  713. this.optionsToDisplay = filterutils_1.FilterUtils.filter(this.options, searchFields, this.filterValue, this.filterMatchMode);
  714. }
  715. this.optionsChanged = true;
  716. }
  717. };
  718. Dropdown.prototype.applyFocus = function () {
  719. if (this.editable)
  720. domhandler_1.DomHandler.findSingle(this.el.nativeElement, '.ui-dropdown-label.ui-inputtext').focus();
  721. else
  722. domhandler_1.DomHandler.findSingle(this.el.nativeElement, 'input[readonly]').focus();
  723. };
  724. Dropdown.prototype.focus = function () {
  725. this.applyFocus();
  726. };
  727. Dropdown.prototype.bindDocumentClickListener = function () {
  728. var _this = this;
  729. if (!this.documentClickListener) {
  730. this.documentClickListener = this.renderer.listen('document', 'click', function (event) {
  731. if (!_this.selfClick && !_this.itemClick) {
  732. _this.hide(event);
  733. _this.unbindDocumentClickListener();
  734. }
  735. _this.clearClickState();
  736. _this.cd.markForCheck();
  737. });
  738. }
  739. };
  740. Dropdown.prototype.clearClickState = function () {
  741. this.selfClick = false;
  742. this.itemClick = false;
  743. };
  744. Dropdown.prototype.unbindDocumentClickListener = function () {
  745. if (this.documentClickListener) {
  746. this.documentClickListener();
  747. this.documentClickListener = null;
  748. }
  749. };
  750. Dropdown.prototype.bindDocumentResizeListener = function () {
  751. this.documentResizeListener = this.onWindowResize.bind(this);
  752. window.addEventListener('resize', this.documentResizeListener);
  753. };
  754. Dropdown.prototype.unbindDocumentResizeListener = function () {
  755. if (this.documentResizeListener) {
  756. window.removeEventListener('resize', this.documentResizeListener);
  757. this.documentResizeListener = null;
  758. }
  759. };
  760. Dropdown.prototype.onWindowResize = function () {
  761. if (!domhandler_1.DomHandler.isAndroid()) {
  762. this.hide(event);
  763. }
  764. };
  765. Dropdown.prototype.updateFilledState = function () {
  766. this.filled = (this.selectedOption != null);
  767. };
  768. Dropdown.prototype.clear = function (event) {
  769. this.clearClick = true;
  770. this.value = null;
  771. this.onModelChange(this.value);
  772. this.onChange.emit({
  773. originalEvent: event,
  774. value: this.value
  775. });
  776. this.updateSelectedOption(this.value);
  777. this.updateEditableLabel();
  778. this.updateFilledState();
  779. };
  780. Dropdown.prototype.onOverlayHide = function () {
  781. this.unbindDocumentClickListener();
  782. this.unbindDocumentResizeListener();
  783. this.overlay = null;
  784. this.itemsWrapper = null;
  785. };
  786. Dropdown.prototype.ngOnDestroy = function () {
  787. this.restoreOverlayAppend();
  788. this.onOverlayHide();
  789. };
  790. __decorate([
  791. core_1.Input(),
  792. __metadata("design:type", String)
  793. ], Dropdown.prototype, "scrollHeight", void 0);
  794. __decorate([
  795. core_1.Input(),
  796. __metadata("design:type", Boolean)
  797. ], Dropdown.prototype, "filter", void 0);
  798. __decorate([
  799. core_1.Input(),
  800. __metadata("design:type", String)
  801. ], Dropdown.prototype, "name", void 0);
  802. __decorate([
  803. core_1.Input(),
  804. __metadata("design:type", Object)
  805. ], Dropdown.prototype, "style", void 0);
  806. __decorate([
  807. core_1.Input(),
  808. __metadata("design:type", Object)
  809. ], Dropdown.prototype, "panelStyle", void 0);
  810. __decorate([
  811. core_1.Input(),
  812. __metadata("design:type", String)
  813. ], Dropdown.prototype, "styleClass", void 0);
  814. __decorate([
  815. core_1.Input(),
  816. __metadata("design:type", String)
  817. ], Dropdown.prototype, "panelStyleClass", void 0);
  818. __decorate([
  819. core_1.Input(),
  820. __metadata("design:type", Boolean)
  821. ], Dropdown.prototype, "readonly", void 0);
  822. __decorate([
  823. core_1.Input(),
  824. __metadata("design:type", Boolean)
  825. ], Dropdown.prototype, "required", void 0);
  826. __decorate([
  827. core_1.Input(),
  828. __metadata("design:type", Boolean)
  829. ], Dropdown.prototype, "editable", void 0);
  830. __decorate([
  831. core_1.Input(),
  832. __metadata("design:type", Object)
  833. ], Dropdown.prototype, "appendTo", void 0);
  834. __decorate([
  835. core_1.Input(),
  836. __metadata("design:type", Number)
  837. ], Dropdown.prototype, "tabindex", void 0);
  838. __decorate([
  839. core_1.Input(),
  840. __metadata("design:type", String)
  841. ], Dropdown.prototype, "placeholder", void 0);
  842. __decorate([
  843. core_1.Input(),
  844. __metadata("design:type", String)
  845. ], Dropdown.prototype, "filterPlaceholder", void 0);
  846. __decorate([
  847. core_1.Input(),
  848. __metadata("design:type", String)
  849. ], Dropdown.prototype, "inputId", void 0);
  850. __decorate([
  851. core_1.Input(),
  852. __metadata("design:type", String)
  853. ], Dropdown.prototype, "selectId", void 0);
  854. __decorate([
  855. core_1.Input(),
  856. __metadata("design:type", String)
  857. ], Dropdown.prototype, "dataKey", void 0);
  858. __decorate([
  859. core_1.Input(),
  860. __metadata("design:type", String)
  861. ], Dropdown.prototype, "filterBy", void 0);
  862. __decorate([
  863. core_1.Input(),
  864. __metadata("design:type", Boolean)
  865. ], Dropdown.prototype, "autofocus", void 0);
  866. __decorate([
  867. core_1.Input(),
  868. __metadata("design:type", Boolean)
  869. ], Dropdown.prototype, "resetFilterOnHide", void 0);
  870. __decorate([
  871. core_1.Input(),
  872. __metadata("design:type", String)
  873. ], Dropdown.prototype, "dropdownIcon", void 0);
  874. __decorate([
  875. core_1.Input(),
  876. __metadata("design:type", String)
  877. ], Dropdown.prototype, "optionLabel", void 0);
  878. __decorate([
  879. core_1.Input(),
  880. __metadata("design:type", Boolean)
  881. ], Dropdown.prototype, "autoDisplayFirst", void 0);
  882. __decorate([
  883. core_1.Input(),
  884. __metadata("design:type", Boolean)
  885. ], Dropdown.prototype, "group", void 0);
  886. __decorate([
  887. core_1.Input(),
  888. __metadata("design:type", Boolean)
  889. ], Dropdown.prototype, "showClear", void 0);
  890. __decorate([
  891. core_1.Input(),
  892. __metadata("design:type", String)
  893. ], Dropdown.prototype, "emptyFilterMessage", void 0);
  894. __decorate([
  895. core_1.Input(),
  896. __metadata("design:type", Boolean)
  897. ], Dropdown.prototype, "virtualScroll", void 0);
  898. __decorate([
  899. core_1.Input(),
  900. __metadata("design:type", Number)
  901. ], Dropdown.prototype, "itemSize", void 0);
  902. __decorate([
  903. core_1.Input(),
  904. __metadata("design:type", Boolean)
  905. ], Dropdown.prototype, "autoZIndex", void 0);
  906. __decorate([
  907. core_1.Input(),
  908. __metadata("design:type", Number)
  909. ], Dropdown.prototype, "baseZIndex", void 0);
  910. __decorate([
  911. core_1.Input(),
  912. __metadata("design:type", String)
  913. ], Dropdown.prototype, "showTransitionOptions", void 0);
  914. __decorate([
  915. core_1.Input(),
  916. __metadata("design:type", String)
  917. ], Dropdown.prototype, "hideTransitionOptions", void 0);
  918. __decorate([
  919. core_1.Input(),
  920. __metadata("design:type", String)
  921. ], Dropdown.prototype, "ariaFilterLabel", void 0);
  922. __decorate([
  923. core_1.Input(),
  924. __metadata("design:type", String)
  925. ], Dropdown.prototype, "filterMatchMode", void 0);
  926. __decorate([
  927. core_1.Input(),
  928. __metadata("design:type", Number)
  929. ], Dropdown.prototype, "maxlength", void 0);
  930. __decorate([
  931. core_1.Input(),
  932. __metadata("design:type", String)
  933. ], Dropdown.prototype, "tooltip", void 0);
  934. __decorate([
  935. core_1.Input(),
  936. __metadata("design:type", String)
  937. ], Dropdown.prototype, "tooltipPosition", void 0);
  938. __decorate([
  939. core_1.Input(),
  940. __metadata("design:type", String)
  941. ], Dropdown.prototype, "tooltipPositionStyle", void 0);
  942. __decorate([
  943. core_1.Input(),
  944. __metadata("design:type", String)
  945. ], Dropdown.prototype, "tooltipStyleClass", void 0);
  946. __decorate([
  947. core_1.Output(),
  948. __metadata("design:type", core_1.EventEmitter)
  949. ], Dropdown.prototype, "onChange", void 0);
  950. __decorate([
  951. core_1.Output(),
  952. __metadata("design:type", core_1.EventEmitter)
  953. ], Dropdown.prototype, "onFocus", void 0);
  954. __decorate([
  955. core_1.Output(),
  956. __metadata("design:type", core_1.EventEmitter)
  957. ], Dropdown.prototype, "onBlur", void 0);
  958. __decorate([
  959. core_1.Output(),
  960. __metadata("design:type", core_1.EventEmitter)
  961. ], Dropdown.prototype, "onClick", void 0);
  962. __decorate([
  963. core_1.Output(),
  964. __metadata("design:type", core_1.EventEmitter)
  965. ], Dropdown.prototype, "onShow", void 0);
  966. __decorate([
  967. core_1.Output(),
  968. __metadata("design:type", core_1.EventEmitter)
  969. ], Dropdown.prototype, "onHide", void 0);
  970. __decorate([
  971. core_1.ViewChild('container', { static: false }),
  972. __metadata("design:type", core_1.ElementRef)
  973. ], Dropdown.prototype, "containerViewChild", void 0);
  974. __decorate([
  975. core_1.ViewChild('filter', { static: false }),
  976. __metadata("design:type", core_1.ElementRef)
  977. ], Dropdown.prototype, "filterViewChild", void 0);
  978. __decorate([
  979. core_1.ViewChild('in', { static: false }),
  980. __metadata("design:type", core_1.ElementRef)
  981. ], Dropdown.prototype, "focusViewChild", void 0);
  982. __decorate([
  983. core_1.ViewChild(scrolling_1.CdkVirtualScrollViewport, { static: false }),
  984. __metadata("design:type", scrolling_1.CdkVirtualScrollViewport)
  985. ], Dropdown.prototype, "viewPort", void 0);
  986. __decorate([
  987. core_1.ViewChild('editableInput', { static: false }),
  988. __metadata("design:type", core_1.ElementRef)
  989. ], Dropdown.prototype, "editableInputViewChild", void 0);
  990. __decorate([
  991. core_1.ContentChildren(shared_1.PrimeTemplate),
  992. __metadata("design:type", core_1.QueryList)
  993. ], Dropdown.prototype, "templates", void 0);
  994. __decorate([
  995. core_1.Input(),
  996. __metadata("design:type", Boolean),
  997. __metadata("design:paramtypes", [Boolean])
  998. ], Dropdown.prototype, "autoWidth", null);
  999. __decorate([
  1000. core_1.Input(),
  1001. __metadata("design:type", Boolean),
  1002. __metadata("design:paramtypes", [Boolean])
  1003. ], Dropdown.prototype, "disabled", null);
  1004. __decorate([
  1005. core_1.Input(),
  1006. __metadata("design:type", Array),
  1007. __metadata("design:paramtypes", [Array])
  1008. ], Dropdown.prototype, "options", null);
  1009. Dropdown = __decorate([
  1010. core_1.Component({
  1011. selector: 'p-dropdown',
  1012. template: "\n <div #container [ngClass]=\"{'ui-dropdown ui-widget ui-state-default ui-corner-all ui-helper-clearfix':true,\n 'ui-state-disabled':disabled, 'ui-dropdown-open':overlayVisible, 'ui-state-focus':focused, 'ui-dropdown-clearable': showClear && !disabled}\"\n (click)=\"onMouseclick($event)\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <div class=\"ui-helper-hidden-accessible\">\n <input #in [attr.id]=\"inputId\" type=\"text\" [attr.aria-label]=\"selectedOption ? selectedOption.label : ' '\" readonly (focus)=\"onInputFocus($event)\" aria-haspopup=\"listbox\"\n (blur)=\"onInputBlur($event)\" (keydown)=\"onKeydown($event, true)\" [disabled]=\"disabled\" [attr.tabindex]=\"tabindex\" [attr.autofocus]=\"autofocus\">\n </div>\n <div class=\"ui-helper-hidden-accessible ui-dropdown-hidden-select\">\n <select [attr.required]=\"required\" [attr.name]=\"name\" tabindex=\"-1\" aria-hidden=\"true\">\n <option *ngIf=\"placeholder\" value=\"\">{{placeholder}}</option>\n <option *ngIf=\"selectedOption\" [value]=\"selectedOption.value\" [selected]=\"true\">{{selectedOption.label}}</option>\n </select>\n </div>\n <div class=\"ui-dropdown-label-container\" [pTooltip]=\"tooltip\" [tooltipPosition]=\"tooltipPosition\" [positionStyle]=\"tooltipPositionStyle\" [tooltipStyleClass]=\"tooltipStyleClass\">\n <label [ngClass]=\"{'ui-dropdown-label ui-inputtext ui-corner-all':true,'ui-dropdown-label-empty':(label == null || label.length === 0)}\" *ngIf=\"!editable && (label != null)\">\n <ng-container *ngIf=\"!selectedItemTemplate\">{{label||'empty'}}</ng-container>\n <ng-container *ngTemplateOutlet=\"selectedItemTemplate; context: {$implicit: selectedOption}\"></ng-container>\n </label>\n <label [ngClass]=\"{'ui-dropdown-label ui-inputtext ui-corner-all ui-placeholder':true,'ui-dropdown-label-empty': (placeholder == null || placeholder.length === 0)}\" *ngIf=\"!editable && (label == null)\">{{placeholder||'empty'}}</label>\n <input #editableInput type=\"text\" [attr.maxlength]=\"maxlength\" [attr.aria-label]=\"selectedOption ? selectedOption.label : ' '\" class=\"ui-dropdown-label ui-inputtext ui-corner-all\" *ngIf=\"editable\" [disabled]=\"disabled\" [attr.placeholder]=\"placeholder\"\n (click)=\"onEditableInputClick($event)\" (input)=\"onEditableInputChange($event)\" (focus)=\"onEditableInputFocus($event)\" (blur)=\"onInputBlur($event)\">\n <i class=\"ui-dropdown-clear-icon pi pi-times\" (click)=\"clear($event)\" *ngIf=\"value != null && showClear && !disabled\"></i>\n </div>\n <div class=\"ui-dropdown-trigger ui-state-default ui-corner-right\">\n <span class=\"ui-dropdown-trigger-icon ui-clickable\" [ngClass]=\"dropdownIcon\"></span>\n </div>\n <div *ngIf=\"overlayVisible\" [ngClass]=\"'ui-dropdown-panel ui-widget ui-widget-content ui-corner-all ui-shadow'\" [@overlayAnimation]=\"{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}\" (@overlayAnimation.start)=\"onOverlayAnimationStart($event)\" [ngStyle]=\"panelStyle\" [class]=\"panelStyleClass\">\n <div *ngIf=\"filter\" class=\"ui-dropdown-filter-container\" (click)=\"$event.stopPropagation()\">\n <input #filter type=\"text\" autocomplete=\"off\" [value]=\"filterValue||''\" class=\"ui-dropdown-filter ui-inputtext ui-widget ui-state-default ui-corner-all\" [attr.placeholder]=\"filterPlaceholder\"\n (keydown.enter)=\"$event.preventDefault()\" (keydown)=\"onKeydown($event, false)\" (input)=\"onFilter($event)\" [attr.aria-label]=\"ariaFilterLabel\">\n <span class=\"ui-dropdown-filter-icon pi pi-search\"></span>\n </div>\n <div class=\"ui-dropdown-items-wrapper\" [style.max-height]=\"virtualScroll ? 'auto' : (scrollHeight||'auto')\">\n <ul class=\"ui-dropdown-items ui-dropdown-list ui-widget-content ui-widget ui-corner-all ui-helper-reset\" role=\"listbox\">\n <ng-container *ngIf=\"group\">\n <ng-template ngFor let-optgroup [ngForOf]=\"optionsToDisplay\">\n <li class=\"ui-dropdown-item-group\">\n <span *ngIf=\"!groupTemplate\">{{optgroup.label||'empty'}}</span>\n <ng-container *ngTemplateOutlet=\"groupTemplate; context: {$implicit: optgroup}\"></ng-container>\n </li>\n <ng-container *ngTemplateOutlet=\"itemslist; context: {$implicit: optgroup.items, selectedOption: selectedOption}\"></ng-container>\n </ng-template>\n </ng-container>\n <ng-container *ngIf=\"!group\">\n <ng-container *ngTemplateOutlet=\"itemslist; context: {$implicit: optionsToDisplay, selectedOption: selectedOption}\"></ng-container>\n </ng-container>\n <ng-template #itemslist let-options let-selectedOption=\"selectedOption\">\n\n <ng-container *ngIf=\"!virtualScroll; else virtualScrollList\">\n <ng-template ngFor let-option let-i=\"index\" [ngForOf]=\"options\">\n <p-dropdownItem [option]=\"option\" [selected]=\"selectedOption == option\" \n (onClick)=\"onItemClick($event)\"\n [template]=\"itemTemplate\"></p-dropdownItem>\n </ng-template>\n </ng-container>\n <ng-template #virtualScrollList>\n <cdk-virtual-scroll-viewport (scrolledIndexChange)=\"scrollToSelectedVirtualScrollElement()\" #viewport [ngStyle]=\"{'height': scrollHeight}\" [itemSize]=\"itemSize\" *ngIf=\"virtualScroll && optionsToDisplay && optionsToDisplay.length\">\n <ng-container *cdkVirtualFor=\"let option of options; let i = index; let c = count; let f = first; let l = last; let e = even; let o = odd\"> \n <p-dropdownItem [option]=\"option\" [selected]=\"selectedOption == option\"\n (onClick)=\"onItemClick($event)\"\n [template]=\"itemTemplate\"></p-dropdownItem>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n </ng-template>\n </ng-template>\n <li *ngIf=\"filter && optionsToDisplay && optionsToDisplay.length === 0\" class=\"ui-dropdown-empty-message\">{{emptyFilterMessage}}</li>\n </ul>\n </div>\n </div>\n </div>\n ",
  1013. animations: [
  1014. animations_1.trigger('overlayAnimation', [
  1015. animations_1.state('void', animations_1.style({
  1016. transform: 'translateY(5%)',
  1017. opacity: 0
  1018. })),
  1019. animations_1.state('visible', animations_1.style({
  1020. transform: 'translateY(0)',
  1021. opacity: 1
  1022. })),
  1023. animations_1.transition('void => visible', animations_1.animate('{{showTransitionParams}}')),
  1024. animations_1.transition('visible => void', animations_1.animate('{{hideTransitionParams}}'))
  1025. ])
  1026. ],
  1027. host: {
  1028. '[class.ui-inputwrapper-filled]': 'filled',
  1029. '[class.ui-inputwrapper-focus]': 'focused'
  1030. },
  1031. providers: [exports.DROPDOWN_VALUE_ACCESSOR]
  1032. }),
  1033. __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2, core_1.ChangeDetectorRef, core_1.NgZone])
  1034. ], Dropdown);
  1035. return Dropdown;
  1036. }());
  1037. exports.Dropdown = Dropdown;
  1038. var DropdownModule = /** @class */ (function () {
  1039. function DropdownModule() {
  1040. }
  1041. DropdownModule = __decorate([
  1042. core_1.NgModule({
  1043. imports: [common_1.CommonModule, shared_1.SharedModule, scrolling_1.ScrollingModule, tooltip_1.TooltipModule],
  1044. exports: [Dropdown, shared_1.SharedModule, scrolling_1.ScrollingModule],
  1045. declarations: [Dropdown, DropdownItem]
  1046. })
  1047. ], DropdownModule);
  1048. return DropdownModule;
  1049. }());
  1050. exports.DropdownModule = DropdownModule;
  1051. //# sourceMappingURL=dropdown.js.map