primeng 8.0.2 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/components/accordion/accordion.js +3 -1
  3. package/components/accordion/accordion.js.map +1 -1
  4. package/components/accordion/accordion.metadata.json +1 -1
  5. package/components/autocomplete/autocomplete.d.ts +3 -0
  6. package/components/autocomplete/autocomplete.js +18 -3
  7. package/components/autocomplete/autocomplete.js.map +1 -1
  8. package/components/autocomplete/autocomplete.metadata.json +1 -1
  9. package/components/breadcrumb/breadcrumb.js +1 -1
  10. package/components/breadcrumb/breadcrumb.js.map +1 -1
  11. package/components/breadcrumb/breadcrumb.metadata.json +1 -1
  12. package/components/button/button.js +1 -1
  13. package/components/button/button.js.map +1 -1
  14. package/components/button/button.metadata.json +1 -1
  15. package/components/calendar/calendar.d.ts +1 -0
  16. package/components/calendar/calendar.js +23 -5
  17. package/components/calendar/calendar.js.map +1 -1
  18. package/components/calendar/calendar.metadata.json +1 -1
  19. package/components/carousel/carousel.d.ts +66 -47
  20. package/components/carousel/carousel.js +406 -197
  21. package/components/carousel/carousel.js.map +1 -1
  22. package/components/carousel/carousel.metadata.json +1 -1
  23. package/components/checkbox/checkbox.d.ts +1 -0
  24. package/components/checkbox/checkbox.js +10 -4
  25. package/components/checkbox/checkbox.js.map +1 -1
  26. package/components/checkbox/checkbox.metadata.json +1 -1
  27. package/components/common/api.d.ts +1 -0
  28. package/components/common/api.js +2 -0
  29. package/components/common/api.js.map +1 -1
  30. package/components/common/api.metadata.json +1 -1
  31. package/components/common/menuitem.d.ts +1 -0
  32. package/components/confirmdialog/confirmdialog.d.ts +1 -0
  33. package/components/confirmdialog/confirmdialog.js +34 -3
  34. package/components/confirmdialog/confirmdialog.js.map +1 -1
  35. package/components/confirmdialog/confirmdialog.metadata.json +1 -1
  36. package/components/contextmenu/contextmenu.d.ts +3 -1
  37. package/components/contextmenu/contextmenu.js +22 -8
  38. package/components/contextmenu/contextmenu.js.map +1 -1
  39. package/components/contextmenu/contextmenu.metadata.json +1 -1
  40. package/components/dataview/dataview.d.ts +1 -1
  41. package/components/dataview/dataview.js +4 -2
  42. package/components/dataview/dataview.js.map +1 -1
  43. package/components/dataview/dataview.metadata.json +1 -1
  44. package/components/dialog/dialog.js +7 -3
  45. package/components/dialog/dialog.js.map +1 -1
  46. package/components/dialog/dialog.metadata.json +1 -1
  47. package/components/dragdrop/dragdrop.d.ts +2 -1
  48. package/components/dragdrop/dragdrop.js +23 -5
  49. package/components/dragdrop/dragdrop.js.map +1 -1
  50. package/components/dragdrop/dragdrop.metadata.json +1 -1
  51. package/components/dropdown/dropdown.d.ts +13 -5
  52. package/components/dropdown/dropdown.js +82 -33
  53. package/components/dropdown/dropdown.js.map +1 -1
  54. package/components/dropdown/dropdown.metadata.json +1 -1
  55. package/components/focustrap/focustrap.js +1 -1
  56. package/components/focustrap/focustrap.js.map +1 -1
  57. package/components/inplace/inplace.d.ts +2 -2
  58. package/components/inplace/inplace.js.map +1 -1
  59. package/components/inputmask/inputmask.js +1 -1
  60. package/components/inputmask/inputmask.js.map +1 -1
  61. package/components/inputmask/inputmask.metadata.json +1 -1
  62. package/components/inputtextarea/inputtextarea.js +1 -0
  63. package/components/inputtextarea/inputtextarea.js.map +1 -1
  64. package/components/inputtextarea/inputtextarea.metadata.json +1 -1
  65. package/components/listbox/listbox.d.ts +2 -0
  66. package/components/listbox/listbox.js +41 -13
  67. package/components/listbox/listbox.js.map +1 -1
  68. package/components/listbox/listbox.metadata.json +1 -1
  69. package/components/megamenu/megamenu.js +1 -1
  70. package/components/megamenu/megamenu.js.map +1 -1
  71. package/components/megamenu/megamenu.metadata.json +1 -1
  72. package/components/menu/menu.js +1 -1
  73. package/components/menu/menu.js.map +1 -1
  74. package/components/menu/menu.metadata.json +1 -1
  75. package/components/menubar/menubar.d.ts +5 -3
  76. package/components/menubar/menubar.js +56 -33
  77. package/components/menubar/menubar.js.map +1 -1
  78. package/components/menubar/menubar.metadata.json +1 -1
  79. package/components/multiselect/multiselect.d.ts +7 -2
  80. package/components/multiselect/multiselect.js +40 -19
  81. package/components/multiselect/multiselect.js.map +1 -1
  82. package/components/multiselect/multiselect.metadata.json +1 -1
  83. package/components/orderlist/orderlist.d.ts +1 -0
  84. package/components/orderlist/orderlist.js +7 -1
  85. package/components/orderlist/orderlist.js.map +1 -1
  86. package/components/orderlist/orderlist.metadata.json +1 -1
  87. package/components/panelmenu/panelmenu.js +2 -2
  88. package/components/panelmenu/panelmenu.js.map +1 -1
  89. package/components/panelmenu/panelmenu.metadata.json +1 -1
  90. package/components/picklist/picklist.d.ts +1 -0
  91. package/components/picklist/picklist.js +8 -2
  92. package/components/picklist/picklist.js.map +1 -1
  93. package/components/picklist/picklist.metadata.json +1 -1
  94. package/components/slidemenu/slidemenu.js +1 -1
  95. package/components/slidemenu/slidemenu.js.map +1 -1
  96. package/components/slidemenu/slidemenu.metadata.json +1 -1
  97. package/components/slider/slider.d.ts +7 -1
  98. package/components/slider/slider.js +43 -1
  99. package/components/slider/slider.js.map +1 -1
  100. package/components/slider/slider.metadata.json +1 -1
  101. package/components/spinner/spinner.js +6 -0
  102. package/components/spinner/spinner.js.map +1 -1
  103. package/components/spinner/spinner.metadata.json +1 -1
  104. package/components/steps/steps.js +1 -1
  105. package/components/steps/steps.js.map +1 -1
  106. package/components/steps/steps.metadata.json +1 -1
  107. package/components/table/table.d.ts +3 -15
  108. package/components/table/table.js +15 -133
  109. package/components/table/table.js.map +1 -1
  110. package/components/table/table.metadata.json +1 -1
  111. package/components/tabmenu/tabmenu.js +3 -3
  112. package/components/tabmenu/tabmenu.js.map +1 -1
  113. package/components/tabmenu/tabmenu.metadata.json +1 -1
  114. package/components/tabview/tabview.d.ts +3 -0
  115. package/components/tabview/tabview.js +15 -1
  116. package/components/tabview/tabview.js.map +1 -1
  117. package/components/tabview/tabview.metadata.json +1 -1
  118. package/components/tieredmenu/tieredmenu.d.ts +14 -8
  119. package/components/tieredmenu/tieredmenu.js +89 -43
  120. package/components/tieredmenu/tieredmenu.js.map +1 -1
  121. package/components/tieredmenu/tieredmenu.metadata.json +1 -1
  122. package/components/tree/tree.js +9 -4
  123. package/components/tree/tree.js.map +1 -1
  124. package/components/tree/tree.metadata.json +1 -1
  125. package/components/treetable/treetable.d.ts +0 -12
  126. package/components/treetable/treetable.js +5 -122
  127. package/components/treetable/treetable.js.map +1 -1
  128. package/components/treetable/treetable.metadata.json +1 -1
  129. package/components/tristatecheckbox/tristatecheckbox.d.ts +1 -0
  130. package/components/tristatecheckbox/tristatecheckbox.js +7 -3
  131. package/components/tristatecheckbox/tristatecheckbox.js.map +1 -1
  132. package/components/tristatecheckbox/tristatecheckbox.metadata.json +1 -1
  133. package/components/utils/filterutils.d.ts +13 -0
  134. package/components/utils/filterutils.js +147 -0
  135. package/components/utils/filterutils.js.map +1 -0
  136. package/components/utils/filterutils.metadata.json +1 -0
  137. package/components/utils/objectutils.d.ts +0 -1
  138. package/components/utils/objectutils.js +0 -18
  139. package/components/utils/objectutils.js.map +1 -1
  140. package/components/utils/uniquecomponentid.d.ts +2 -0
  141. package/components/utils/uniquecomponentid.js +10 -0
  142. package/components/utils/uniquecomponentid.js.map +1 -0
  143. package/components/utils/uniquecomponentid.metadata.json +1 -0
  144. package/package.json +9 -5
  145. package/resources/components/carousel/carousel.css +57 -58
  146. package/resources/components/checkbox/checkbox.css +4 -0
  147. package/resources/components/colorpicker/images/color.png +0 -0
  148. package/resources/components/colorpicker/images/hue.png +0 -0
  149. package/resources/components/lightbox/images/loading.gif +0 -0
  150. package/resources/components/password/images/password-meter.png +0 -0
  151. package/resources/components/sidebar/sidebar.css +5 -1
  152. package/resources/components/table/table.css +4 -0
  153. package/resources/components/tree/images/line.gif +0 -0
  154. package/resources/primeng.css +608 -596
  155. package/resources/primeng.min.css +1 -1
  156. package/resources/themes/luna-amber/theme.css +2261 -2977
  157. package/resources/themes/luna-blue/theme.css +2253 -2969
  158. package/resources/themes/luna-green/theme.css +2253 -2969
  159. package/resources/themes/luna-pink/theme.css +2253 -2969
  160. package/resources/themes/nova-colored/theme.css +2267 -2983
  161. package/resources/themes/nova-dark/theme.css +2267 -2983
  162. package/resources/themes/nova-light/theme.css +2282 -2998
  163. package/resources/themes/rhea/theme.css +2250 -2966
  164. package/.editorconfig +0 -13
  165. package/.travis.yml +0 -23
  166. package/.vscode/settings.json +0 -2
@@ -10,29 +10,107 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  var core_1 = require("@angular/core");
13
- var domhandler_1 = require("../dom/domhandler");
14
13
  var shared_1 = require("../common/shared");
15
14
  var common_1 = require("@angular/common");
15
+ var uniquecomponentid_1 = require("../utils/uniquecomponentid");
16
16
  var Carousel = /** @class */ (function () {
17
- function Carousel(el, renderer, cd) {
17
+ function Carousel(el, zone) {
18
18
  this.el = el;
19
- this.renderer = renderer;
20
- this.cd = cd;
21
- this.numVisible = 3;
22
- this.firstVisible = 0;
19
+ this.zone = zone;
20
+ this.orientation = "horizontal";
21
+ this.verticalViewPortHeight = "300px";
22
+ this.contentClass = "";
23
+ this.dotsContainerClass = "";
23
24
  this.circular = false;
24
- this.breakpoint = 560;
25
- this.responsive = true;
26
25
  this.autoplayInterval = 0;
27
- this.effectDuration = '1s';
28
- this.easing = 'ease-out';
29
- this.pageLinks = 3;
30
26
  this.onPage = new core_1.EventEmitter();
31
- this.left = 0;
32
- this.columns = 0;
27
+ this._numVisible = 1;
28
+ this._numScroll = 1;
29
+ this._oldNumScroll = 0;
30
+ this.prevState = {
31
+ numScroll: 0,
32
+ numVisible: 0,
33
+ value: []
34
+ };
35
+ this.defaultNumScroll = 1;
36
+ this.defaultNumVisible = 1;
37
+ this._page = 0;
38
+ this.isRemainingItemsAdded = false;
39
+ this.remainingItems = 0;
40
+ this.totalShiftedItems = this.page * this.numScroll * -1;
33
41
  }
42
+ Object.defineProperty(Carousel.prototype, "page", {
43
+ get: function () {
44
+ return this._page;
45
+ },
46
+ set: function (val) {
47
+ if (this.isCreated && val !== this._page) {
48
+ if (this.autoplayInterval) {
49
+ this.stopAutoplay();
50
+ this.allowAutoplay = false;
51
+ }
52
+ if (val > this._page && val < (this.totalDots() - 1)) {
53
+ this.step(-1, val);
54
+ }
55
+ else if (val < this._page && val !== 0) {
56
+ this.step(1, val);
57
+ }
58
+ }
59
+ this._page = val;
60
+ },
61
+ enumerable: true,
62
+ configurable: true
63
+ });
64
+ Object.defineProperty(Carousel.prototype, "numVisible", {
65
+ get: function () {
66
+ return this._numVisible;
67
+ },
68
+ set: function (val) {
69
+ this._numVisible = val;
70
+ },
71
+ enumerable: true,
72
+ configurable: true
73
+ });
74
+ Object.defineProperty(Carousel.prototype, "numScroll", {
75
+ get: function () {
76
+ return this._numVisible;
77
+ },
78
+ set: function (val) {
79
+ this._numScroll = val;
80
+ },
81
+ enumerable: true,
82
+ configurable: true
83
+ });
84
+ Object.defineProperty(Carousel.prototype, "value", {
85
+ get: function () {
86
+ return this._value;
87
+ },
88
+ set: function (val) {
89
+ this._value = val;
90
+ if (this.circular && this._value) {
91
+ this.setCloneItems();
92
+ }
93
+ },
94
+ enumerable: true,
95
+ configurable: true
96
+ });
97
+ ;
34
98
  Carousel.prototype.ngAfterContentInit = function () {
35
99
  var _this = this;
100
+ this.id = uniquecomponentid_1.UniqueComponentId();
101
+ this.allowAutoplay = !!this.autoplayInterval;
102
+ if (this.circular) {
103
+ this.setCloneItems();
104
+ }
105
+ if (this.responsiveOptions) {
106
+ this.defaultNumScroll = this._numScroll;
107
+ this.defaultNumVisible = this._numVisible;
108
+ }
109
+ this.createStyle();
110
+ this.calculatePosition();
111
+ if (this.responsiveOptions) {
112
+ this.bindDocumentListeners();
113
+ }
36
114
  this.templates.forEach(function (item) {
37
115
  switch (item.getType()) {
38
116
  case 'item':
@@ -44,189 +122,317 @@ var Carousel = /** @class */ (function () {
44
122
  }
45
123
  });
46
124
  };
47
- Object.defineProperty(Carousel.prototype, "value", {
48
- get: function () {
49
- return this._value;
50
- },
51
- set: function (val) {
52
- this._value = val;
53
- this.handleDataChange();
54
- },
55
- enumerable: true,
56
- configurable: true
57
- });
58
- Carousel.prototype.handleDataChange = function () {
59
- if (this.value && this.value.length) {
60
- if (this.value.length && this.firstVisible >= this.value.length) {
61
- this.setPage(this.totalPages - 1);
125
+ Carousel.prototype.ngAfterContentChecked = function () {
126
+ var isCircular = this.isCircular();
127
+ var totalShiftedItems = this.totalShiftedItems;
128
+ if (this.value && (this.prevState.numScroll !== this._numScroll || this.prevState.numVisible !== this._numVisible || this.prevState.value.length !== this.value.length)) {
129
+ if (this.autoplayInterval) {
130
+ this.stopAutoplay();
131
+ }
132
+ this.remainingItems = (this.value.length - this._numVisible) % this._numScroll;
133
+ var page = this._page;
134
+ if (this.totalDots() !== 0 && page >= this.totalDots()) {
135
+ page = this.totalDots() - 1;
136
+ this._page = page;
137
+ this.onPage.emit({
138
+ page: this.page
139
+ });
140
+ }
141
+ totalShiftedItems = (page * this._numScroll) * -1;
142
+ if (isCircular) {
143
+ totalShiftedItems -= this._numVisible;
144
+ }
145
+ if (page === (this.totalDots() - 1) && this.remainingItems > 0) {
146
+ totalShiftedItems += (-1 * this.remainingItems) + this._numScroll;
147
+ this.isRemainingItemsAdded = true;
148
+ }
149
+ else {
150
+ this.isRemainingItemsAdded = false;
151
+ }
152
+ if (totalShiftedItems !== this.totalShiftedItems) {
153
+ this.totalShiftedItems = totalShiftedItems;
154
+ }
155
+ this._oldNumScroll = this._numScroll;
156
+ this.prevState.numScroll = this._numScroll;
157
+ this.prevState.numVisible = this._numVisible;
158
+ this.prevState.value = this._value;
159
+ this.itemsContainer.nativeElement.style.transform = this.isVertical() ? "translate3d(0, " + totalShiftedItems * (100 / this._numVisible) + "%, 0)" : "translate3d(" + totalShiftedItems * (100 / this._numVisible) + "%, 0, 0)";
160
+ this.isCreated = true;
161
+ if (this.autoplayInterval && this.isAutoplay()) {
162
+ this.startAutoplay();
62
163
  }
63
164
  }
64
- else {
65
- this.setPage(0);
165
+ if (isCircular) {
166
+ if (this.page === 0) {
167
+ totalShiftedItems = -1 * this._numVisible;
168
+ }
169
+ else if (totalShiftedItems === 0) {
170
+ totalShiftedItems = -1 * this.value.length;
171
+ if (this.remainingItems > 0) {
172
+ this.isRemainingItemsAdded = true;
173
+ }
174
+ }
175
+ if (totalShiftedItems !== this.totalShiftedItems) {
176
+ this.totalShiftedItems = totalShiftedItems;
177
+ }
66
178
  }
67
- this.valuesChanged = true;
68
179
  };
69
- Carousel.prototype.ngAfterViewChecked = function () {
70
- if (this.valuesChanged && this.containerViewChild && this.containerViewChild.nativeElement.offsetParent) {
71
- this.render();
72
- this.valuesChanged = false;
180
+ Carousel.prototype.createStyle = function () {
181
+ if (!this.carouselStyle) {
182
+ this.carouselStyle = document.createElement('style');
183
+ this.carouselStyle.type = 'text/css';
184
+ document.body.appendChild(this.carouselStyle);
73
185
  }
74
- };
75
- Carousel.prototype.ngAfterViewInit = function () {
76
- var _this = this;
77
- if (this.responsive) {
78
- this.documentResponsiveListener = this.renderer.listen('window', 'resize', function (event) {
79
- _this.updateState();
186
+ var innerHTML = "\n #" + this.id + " .ui-carousel-item {\n\t\t\t\tflex: 1 0 " + (100 / this.numVisible) + "%\n\t\t\t}\n ";
187
+ if (this.responsiveOptions) {
188
+ this.responsiveOptions.sort(function (data1, data2) {
189
+ var value1 = data1.breakpoint;
190
+ var value2 = data2.breakpoint;
191
+ var result = null;
192
+ if (value1 == null && value2 != null)
193
+ result = -1;
194
+ else if (value1 != null && value2 == null)
195
+ result = 1;
196
+ else if (value1 == null && value2 == null)
197
+ result = 0;
198
+ else if (typeof value1 === 'string' && typeof value2 === 'string')
199
+ result = value1.localeCompare(value2, undefined, { numeric: true });
200
+ else
201
+ result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
202
+ return -1 * result;
80
203
  });
204
+ for (var i = 0; i < this.responsiveOptions.length; i++) {
205
+ var res = this.responsiveOptions[i];
206
+ innerHTML += "\n @media screen and (max-width: " + res.breakpoint + ") {\n #" + this.id + " .ui-carousel-item {\n flex: 1 0 " + (100 / res.numVisible) + "%\n }\n }\n ";
207
+ }
81
208
  }
209
+ this.carouselStyle.innerHTML = innerHTML;
82
210
  };
83
- Carousel.prototype.updateLinks = function () {
84
- this.anchorPageLinks = [];
85
- for (var i = 0; i < this.totalPages; i++) {
86
- this.anchorPageLinks.push(i);
211
+ Carousel.prototype.calculatePosition = function () {
212
+ if (this.itemsContainer && this.responsiveOptions) {
213
+ var windowWidth = window.innerWidth;
214
+ var matchedResponsiveData = {
215
+ numVisible: this.defaultNumVisible,
216
+ numScroll: this.defaultNumScroll
217
+ };
218
+ for (var i = 0; i < this.responsiveOptions.length; i++) {
219
+ var res = this.responsiveOptions[i];
220
+ if (parseInt(res.breakpoint, 10) >= windowWidth) {
221
+ matchedResponsiveData = res;
222
+ }
223
+ }
224
+ if (this._numScroll !== matchedResponsiveData.numScroll) {
225
+ var page = this._page;
226
+ page = Math.floor((page * this._numScroll) / matchedResponsiveData.numScroll);
227
+ var totalShiftedItems = (matchedResponsiveData.numScroll * this.page) * -1;
228
+ if (this.isCircular()) {
229
+ totalShiftedItems -= matchedResponsiveData.numVisible;
230
+ }
231
+ this.totalShiftedItems = totalShiftedItems;
232
+ this._numScroll = matchedResponsiveData.numScroll;
233
+ this._page = page;
234
+ this.onPage.emit({
235
+ page: this.page
236
+ });
237
+ }
238
+ if (this._numVisible !== matchedResponsiveData.numVisible) {
239
+ this._numVisible = matchedResponsiveData.numVisible;
240
+ this.setCloneItems();
241
+ }
87
242
  }
88
243
  };
89
- Carousel.prototype.updateDropdown = function () {
90
- this.selectDropdownOptions = [];
91
- for (var i = 0; i < this.totalPages; i++) {
92
- this.selectDropdownOptions.push(i);
244
+ Carousel.prototype.setCloneItems = function () {
245
+ var _a, _b;
246
+ this.clonedItemsForStarting = [];
247
+ this.clonedItemsForFinishing = [];
248
+ if (this.isCircular()) {
249
+ (_a = this.clonedItemsForStarting).push.apply(_a, this.value.slice(-1 * this._numVisible));
250
+ (_b = this.clonedItemsForFinishing).push.apply(_b, this.value.slice(0, this._numVisible));
93
251
  }
94
252
  };
95
- Carousel.prototype.updateMobileDropdown = function () {
96
- this.mobileDropdownOptions = [];
97
- if (this.value && this.value.length) {
98
- for (var i = 0; i < this.value.length; i++) {
99
- this.mobileDropdownOptions.push(i);
100
- }
101
- }
253
+ Carousel.prototype.firstIndex = function () {
254
+ return this.isCircular() ? (-1 * (this.totalShiftedItems + this.numVisible)) : (this.totalShiftedItems * -1);
255
+ };
256
+ Carousel.prototype.lastIndex = function () {
257
+ return this.firstIndex() + this.numVisible - 1;
258
+ };
259
+ Carousel.prototype.totalDots = function () {
260
+ return this.value ? Math.ceil((this.value.length - this._numVisible) / this._numScroll) + 1 : 0;
261
+ };
262
+ Carousel.prototype.totalDotsArray = function () {
263
+ return Array(this.value ? Math.ceil((this.value.length - this._numVisible) / this._numScroll) + 1 : 0).fill(0);
264
+ ;
265
+ };
266
+ Carousel.prototype.containerClass = function () {
267
+ return { 'ui-carousel ui-widget': true,
268
+ 'ui-carousel-vertical': this.isVertical(),
269
+ 'ui-carousel-horizontal': !this.isVertical()
270
+ };
271
+ };
272
+ Carousel.prototype.contentClasses = function () {
273
+ return 'ui-carousel-content ' + this.contentClass;
274
+ };
275
+ Carousel.prototype.dotsContentClasses = function () {
276
+ return 'ui-carousel-dots-container ui-helper-reset ' + this.dotsContainerClass;
277
+ };
278
+ Carousel.prototype.isVertical = function () {
279
+ return this.orientation === 'vertical';
280
+ };
281
+ Carousel.prototype.isCircular = function () {
282
+ return this.circular && this.value && this.value.length >= this.numVisible;
283
+ };
284
+ Carousel.prototype.isAutoplay = function () {
285
+ return this.autoplayInterval && this.allowAutoplay;
102
286
  };
103
- Carousel.prototype.render = function () {
287
+ Carousel.prototype.navForward = function (e, index) {
288
+ if (this.circular || this._page < (this.totalDots() - 1)) {
289
+ this.step(-1, index);
290
+ }
104
291
  if (this.autoplayInterval) {
105
292
  this.stopAutoplay();
293
+ this.allowAutoplay = false;
294
+ }
295
+ if (e && e.cancelable) {
296
+ e.preventDefault();
106
297
  }
107
- this.items = domhandler_1.DomHandler.find(this.itemsViewChild.nativeElement, 'li');
108
- this.calculateColumns();
109
- this.calculateItemWidths();
110
- this.setPage(Math.floor(this.firstVisible / this.columns), true);
111
- if (!this.responsive) {
112
- this.containerViewChild.nativeElement.style.width = (domhandler_1.DomHandler.width(this.containerViewChild.nativeElement)) + 'px';
298
+ };
299
+ Carousel.prototype.navBackward = function (e, index) {
300
+ if (this.circular || this._page !== 0) {
301
+ this.step(1, index);
113
302
  }
114
303
  if (this.autoplayInterval) {
115
- this.circular = true;
116
- this.startAutoplay();
304
+ this.stopAutoplay();
305
+ this.allowAutoplay = false;
306
+ }
307
+ if (e && e.cancelable) {
308
+ e.preventDefault();
117
309
  }
118
- this.updateMobileDropdown();
119
- this.updateLinks();
120
- this.updateDropdown();
121
- this.cd.detectChanges();
122
310
  };
123
- Carousel.prototype.calculateItemWidths = function () {
124
- var firstItem = (this.items && this.items.length) ? this.items[0] : null;
125
- if (firstItem) {
126
- for (var i = 0; i < this.items.length; i++) {
127
- this.items[i].style.width = ((domhandler_1.DomHandler.innerWidth(this.viewportViewChild.nativeElement) - (domhandler_1.DomHandler.getHorizontalMargin(firstItem) * this.columns)) / this.columns) + 'px';
128
- }
311
+ Carousel.prototype.onDotClick = function (e, index) {
312
+ var page = this._page;
313
+ if (this.autoplayInterval) {
314
+ this.stopAutoplay();
315
+ this.allowAutoplay = false;
316
+ }
317
+ if (index > page) {
318
+ this.navForward(e, index);
319
+ }
320
+ else if (index < page) {
321
+ this.navBackward(e, index);
129
322
  }
130
323
  };
131
- Carousel.prototype.calculateColumns = function () {
132
- if (window.innerWidth <= this.breakpoint) {
133
- this.shrinked = true;
134
- this.columns = 1;
324
+ Carousel.prototype.step = function (dir, page) {
325
+ var totalShiftedItems = this.totalShiftedItems;
326
+ var isCircular = this.isCircular();
327
+ if (page != null) {
328
+ totalShiftedItems = (this._numScroll * page) * -1;
329
+ if (isCircular) {
330
+ totalShiftedItems -= this._numVisible;
331
+ }
332
+ this.isRemainingItemsAdded = false;
135
333
  }
136
334
  else {
137
- this.shrinked = false;
138
- this.columns = this.numVisible;
335
+ totalShiftedItems += (this._numScroll * dir);
336
+ if (this.isRemainingItemsAdded) {
337
+ totalShiftedItems += this.remainingItems - (this._numScroll * dir);
338
+ this.isRemainingItemsAdded = false;
339
+ }
340
+ var originalShiftedItems = isCircular ? (totalShiftedItems + this._numVisible) : totalShiftedItems;
341
+ page = Math.abs(Math.floor((originalShiftedItems / this._numScroll)));
139
342
  }
140
- this.page = Math.floor(this.firstVisible / this.columns);
141
- };
142
- Carousel.prototype.onNextNav = function () {
143
- var lastPage = (this.page === (this.totalPages - 1));
144
- if (!lastPage)
145
- this.setPage(this.page + 1);
146
- else if (this.circular)
147
- this.setPage(0);
343
+ if (isCircular && this.page === (this.totalDots() - 1) && dir === -1) {
344
+ totalShiftedItems = -1 * (this.value.length + this._numVisible);
345
+ page = 0;
346
+ }
347
+ else if (isCircular && this.page === 0 && dir === 1) {
348
+ totalShiftedItems = 0;
349
+ page = (this.totalDots() - 1);
350
+ }
351
+ else if (page === (this.totalDots() - 1) && this.remainingItems > 0) {
352
+ totalShiftedItems += ((this.remainingItems * -1) - (this._numScroll * dir));
353
+ this.isRemainingItemsAdded = true;
354
+ }
355
+ if (this.itemsContainer) {
356
+ this.itemsContainer.nativeElement.style.transform = this.isVertical() ? "translate3d(0, " + totalShiftedItems * (100 / this._numVisible) + "%, 0)" : "translate3d(" + totalShiftedItems * (100 / this._numVisible) + "%, 0, 0)";
357
+ this.itemsContainer.nativeElement.style.transition = 'transform 500ms ease 0s';
358
+ }
359
+ this.totalShiftedItems = totalShiftedItems;
360
+ this._page = page;
361
+ this.onPage.emit({
362
+ page: this.page
363
+ });
148
364
  };
149
- Carousel.prototype.onPrevNav = function () {
150
- if (this.page !== 0)
151
- this.setPage(this.page - 1);
152
- else if (this.circular)
153
- this.setPage(this.totalPages - 1);
365
+ Carousel.prototype.startAutoplay = function () {
366
+ var _this = this;
367
+ this.interval = setInterval(function () {
368
+ if (_this.page === (_this.totalDots() - 1)) {
369
+ _this.step(-1, 0);
370
+ }
371
+ else {
372
+ _this.step(-1, _this.page + 1);
373
+ }
374
+ }, this.autoplayInterval);
154
375
  };
155
- Carousel.prototype.setPageWithLink = function (event, p) {
156
- this.setPage(p);
157
- event.preventDefault();
376
+ Carousel.prototype.stopAutoplay = function () {
377
+ if (this.interval) {
378
+ clearInterval(this.interval);
379
+ }
158
380
  };
159
- Carousel.prototype.setPage = function (p, enforce) {
160
- if (p !== this.page || enforce) {
161
- this.page = p;
162
- this.left = (-1 * (domhandler_1.DomHandler.innerWidth(this.viewportViewChild.nativeElement) * this.page));
163
- this.firstVisible = this.page * this.columns;
164
- this.onPage.emit({
165
- page: this.page
166
- });
381
+ Carousel.prototype.onTransitionEnd = function () {
382
+ if (this.itemsContainer) {
383
+ this.itemsContainer.nativeElement.style.transition = '';
384
+ if ((this.page === 0 || this.page === (this.totalDots() - 1)) && this.isCircular()) {
385
+ this.itemsContainer.nativeElement.style.transform = this.isVertical() ? "translate3d(0, " + this.totalShiftedItems * (100 / this._numVisible) + "%, 0)" : "translate3d(" + this.totalShiftedItems * (100 / this._numVisible) + "%, 0, 0)";
386
+ }
167
387
  }
168
388
  };
169
- Carousel.prototype.onDropdownChange = function (val) {
170
- this.setPage(parseInt(val));
389
+ Carousel.prototype.onTouchStart = function (e) {
390
+ var touchobj = e.changedTouches[0];
391
+ this.startPos = {
392
+ x: touchobj.pageX,
393
+ y: touchobj.pageY
394
+ };
171
395
  };
172
- Object.defineProperty(Carousel.prototype, "displayPageLinks", {
173
- get: function () {
174
- return (this.totalPages <= this.pageLinks && !this.shrinked);
175
- },
176
- enumerable: true,
177
- configurable: true
178
- });
179
- Object.defineProperty(Carousel.prototype, "displayPageDropdown", {
180
- get: function () {
181
- return (this.totalPages > this.pageLinks && !this.shrinked);
182
- },
183
- enumerable: true,
184
- configurable: true
185
- });
186
- Object.defineProperty(Carousel.prototype, "totalPages", {
187
- get: function () {
188
- return (this.value && this.value.length) ? Math.ceil(this.value.length / this.columns) : 0;
189
- },
190
- enumerable: true,
191
- configurable: true
192
- });
193
- Carousel.prototype.routerDisplay = function () {
194
- var win = window;
195
- if (win.innerWidth <= this.breakpoint)
196
- return true;
197
- else
198
- return false;
396
+ Carousel.prototype.onTouchMove = function (e) {
397
+ if (e.cancelable) {
398
+ e.preventDefault();
399
+ }
400
+ };
401
+ Carousel.prototype.onTouchEnd = function (e) {
402
+ var touchobj = e.changedTouches[0];
403
+ if (this.isVertical()) {
404
+ this.changePageOnTouch(e, (touchobj.pageY - this.startPos.y));
405
+ }
406
+ else {
407
+ this.changePageOnTouch(e, (touchobj.pageX - this.startPos.x));
408
+ }
199
409
  };
200
- Carousel.prototype.updateState = function () {
201
- var win = window;
202
- if (win.innerWidth <= this.breakpoint) {
203
- this.shrinked = true;
204
- this.columns = 1;
205
- }
206
- else if (this.shrinked) {
207
- this.shrinked = false;
208
- this.columns = this.numVisible;
209
- this.updateLinks();
210
- this.updateDropdown();
211
- }
212
- this.calculateItemWidths();
213
- this.setPage(Math.floor(this.firstVisible / this.columns), true);
410
+ Carousel.prototype.changePageOnTouch = function (e, diff) {
411
+ if (diff < 0) {
412
+ this.navForward(e);
413
+ }
414
+ else {
415
+ this.navBackward(e);
416
+ }
214
417
  };
215
- Carousel.prototype.startAutoplay = function () {
418
+ Carousel.prototype.bindDocumentListeners = function () {
216
419
  var _this = this;
217
- this.interval = setInterval(function () {
218
- if (_this.page === (_this.totalPages - 1))
219
- _this.setPage(0);
220
- else
221
- _this.setPage(_this.page + 1);
222
- }, this.autoplayInterval);
420
+ if (!this.documentResizeListener) {
421
+ this.documentResizeListener = function (e) {
422
+ _this.calculatePosition();
423
+ };
424
+ window.addEventListener('resize', this.documentResizeListener);
425
+ }
223
426
  };
224
- Carousel.prototype.stopAutoplay = function () {
225
- clearInterval(this.interval);
427
+ Carousel.prototype.unbindDocumentListeners = function () {
428
+ if (this.documentResizeListener) {
429
+ window.removeEventListener('resize', this.documentResizeListener);
430
+ this.documentResizeListener = null;
431
+ }
226
432
  };
227
433
  Carousel.prototype.ngOnDestroy = function () {
228
- if (this.documentResponsiveListener) {
229
- this.documentResponsiveListener();
434
+ if (this.responsiveOptions) {
435
+ this.unbindDocumentListeners();
230
436
  }
231
437
  if (this.autoplayInterval) {
232
438
  this.stopAutoplay();
@@ -234,44 +440,52 @@ var Carousel = /** @class */ (function () {
234
440
  };
235
441
  __decorate([
236
442
  core_1.Input(),
237
- __metadata("design:type", Number)
238
- ], Carousel.prototype, "numVisible", void 0);
443
+ __metadata("design:type", Number),
444
+ __metadata("design:paramtypes", [Number])
445
+ ], Carousel.prototype, "page", null);
239
446
  __decorate([
240
447
  core_1.Input(),
241
- __metadata("design:type", Number)
242
- ], Carousel.prototype, "firstVisible", void 0);
448
+ __metadata("design:type", Number),
449
+ __metadata("design:paramtypes", [Number])
450
+ ], Carousel.prototype, "numVisible", null);
243
451
  __decorate([
244
452
  core_1.Input(),
245
- __metadata("design:type", String)
246
- ], Carousel.prototype, "headerText", void 0);
453
+ __metadata("design:type", Number),
454
+ __metadata("design:paramtypes", [Number])
455
+ ], Carousel.prototype, "numScroll", null);
247
456
  __decorate([
248
457
  core_1.Input(),
249
- __metadata("design:type", Boolean)
250
- ], Carousel.prototype, "circular", void 0);
458
+ __metadata("design:type", Array)
459
+ ], Carousel.prototype, "responsiveOptions", void 0);
251
460
  __decorate([
252
461
  core_1.Input(),
253
- __metadata("design:type", Number)
254
- ], Carousel.prototype, "breakpoint", void 0);
462
+ __metadata("design:type", Object)
463
+ ], Carousel.prototype, "orientation", void 0);
255
464
  __decorate([
256
465
  core_1.Input(),
257
- __metadata("design:type", Boolean)
258
- ], Carousel.prototype, "responsive", void 0);
466
+ __metadata("design:type", Object)
467
+ ], Carousel.prototype, "verticalViewPortHeight", void 0);
259
468
  __decorate([
260
469
  core_1.Input(),
261
- __metadata("design:type", Number)
262
- ], Carousel.prototype, "autoplayInterval", void 0);
470
+ __metadata("design:type", String)
471
+ ], Carousel.prototype, "contentClass", void 0);
263
472
  __decorate([
264
473
  core_1.Input(),
265
- __metadata("design:type", Object)
266
- ], Carousel.prototype, "effectDuration", void 0);
474
+ __metadata("design:type", String)
475
+ ], Carousel.prototype, "dotsContainerClass", void 0);
267
476
  __decorate([
268
477
  core_1.Input(),
269
- __metadata("design:type", String)
270
- ], Carousel.prototype, "easing", void 0);
478
+ __metadata("design:type", Array),
479
+ __metadata("design:paramtypes", [Object])
480
+ ], Carousel.prototype, "value", null);
481
+ __decorate([
482
+ core_1.Input(),
483
+ __metadata("design:type", Boolean)
484
+ ], Carousel.prototype, "circular", void 0);
271
485
  __decorate([
272
486
  core_1.Input(),
273
487
  __metadata("design:type", Number)
274
- ], Carousel.prototype, "pageLinks", void 0);
488
+ ], Carousel.prototype, "autoplayInterval", void 0);
275
489
  __decorate([
276
490
  core_1.Input(),
277
491
  __metadata("design:type", Object)
@@ -285,32 +499,27 @@ var Carousel = /** @class */ (function () {
285
499
  __metadata("design:type", core_1.EventEmitter)
286
500
  ], Carousel.prototype, "onPage", void 0);
287
501
  __decorate([
288
- core_1.ContentChildren(shared_1.PrimeTemplate),
289
- __metadata("design:type", core_1.QueryList)
290
- ], Carousel.prototype, "templates", void 0);
291
- __decorate([
292
- core_1.ViewChild('container', { static: false }),
502
+ core_1.ViewChild('itemsContainer', { static: true }),
293
503
  __metadata("design:type", core_1.ElementRef)
294
- ], Carousel.prototype, "containerViewChild", void 0);
504
+ ], Carousel.prototype, "itemsContainer", void 0);
295
505
  __decorate([
296
- core_1.ViewChild('viewport', { static: false }),
297
- __metadata("design:type", core_1.ElementRef)
298
- ], Carousel.prototype, "viewportViewChild", void 0);
506
+ core_1.ContentChild(shared_1.Header, { static: false }),
507
+ __metadata("design:type", Object)
508
+ ], Carousel.prototype, "headerFacet", void 0);
299
509
  __decorate([
300
- core_1.ViewChild('items', { static: false }),
301
- __metadata("design:type", core_1.ElementRef)
302
- ], Carousel.prototype, "itemsViewChild", void 0);
510
+ core_1.ContentChild(shared_1.Footer, { static: false }),
511
+ __metadata("design:type", Object)
512
+ ], Carousel.prototype, "footerFacet", void 0);
303
513
  __decorate([
304
- core_1.Input(),
305
- __metadata("design:type", Array),
306
- __metadata("design:paramtypes", [Array])
307
- ], Carousel.prototype, "value", null);
514
+ core_1.ContentChildren(shared_1.PrimeTemplate),
515
+ __metadata("design:type", core_1.QueryList)
516
+ ], Carousel.prototype, "templates", void 0);
308
517
  Carousel = __decorate([
309
518
  core_1.Component({
310
519
  selector: 'p-carousel',
311
- template: "\n <div #container [ngClass]=\"{'ui-carousel ui-widget ui-widget-content ui-corner-all':true}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <div class=\"ui-carousel-header ui-widget-header ui-corner-all\">\n <span class=\"ui-carousel-header-title\">{{headerText}}</span>\n <span class=\"ui-carousel-button ui-carousel-next-button pi pi-arrow-circle-right\" (click)=\"onNextNav()\" \n [ngClass]=\"{'ui-state-disabled':(page === (totalPages-1)) && !circular}\" *ngIf=\"value&&value.length\"></span>\n <span class=\"ui-carousel-button ui-carousel-prev-button pi pi-arrow-circle-left\" (click)=\"onPrevNav()\" \n [ngClass]=\"{'ui-state-disabled':(page === 0 && !circular)}\" *ngIf=\"value&&value.length\"></span>\n <div *ngIf=\"displayPageLinks\" class=\"ui-carousel-page-links\">\n <a tabindex=\"0\" (click)=\"setPageWithLink($event,i)\" class=\"ui-carousel-page-link pi\" *ngFor=\"let links of anchorPageLinks;let i=index\" [ngClass]=\"{'pi-circle-on': page===i, 'pi-circle-off': page !== i}\"></a>\n </div>\n <select *ngIf=\"displayPageDropdown\" class=\"ui-carousel-dropdown ui-widget ui-state-default ui-corner-left\" [value]=\"page\" (change)=\"onDropdownChange($event.target.value)\">\n <option *ngFor=\"let option of selectDropdownOptions\" [value]=\"option\" [selected]=\"value == option\">{{option+1}}</option>\n </select>\n <select *ngIf=\"responsive&&value&&value.length\" class=\"ui-carousel-mobiledropdown ui-widget ui-state-default ui-corner-left\" [value]=\"page\" (change)=\"onDropdownChange($event.target.value)\"\n [style.display]=\"shrinked ? 'block' : 'none'\">\n <option *ngFor=\"let option of mobileDropdownOptions\" [value]=\"option\" [selected]=\"value == option\">{{option+1}}</option>\n </select>\n </div>\n <div #viewport class=\"ui-carousel-viewport\">\n <ul #items class=\"ui-carousel-items\" [style.left.px]=\"left\" [style.transitionProperty]=\"'left'\" \n [style.transitionDuration]=\"effectDuration\" [style.transitionTimingFunction]=\"easing\">\n <li *ngFor=\"let item of value\" class=\"ui-carousel-item ui-widget-content ui-corner-all\">\n <ng-container *ngTemplateOutlet=\"itemTemplate; context: {$implicit: item}\"></ng-container>\n </li>\n </ul>\n </div>\n </div>\n "
520
+ template: "\n\t\t<div [attr.id]=\"id\" [ngClass]=\"containerClass()\" [ngStyle]=\"style\" [class]=\"styleClass\">\n\t\t\t<div class=\"ui-carousel-header\" *ngIf=\"headerFacet\">\n\t\t\t\t<ng-content select=\"p-header\"></ng-content>\n\t\t\t</div>\n\t\t\t<div [class]=\"contentClasses()\">\n\t\t\t\t<div class=\"ui-carousel-container\">\n\t\t\t\t\t<button [ngClass]=\"{'ui-carousel-prev ui-button ui-widget ui-state-default ui-corner-all':true, 'ui-state-disabled': _page === 0 && !circular}\" [disabled]=\"_page === 0 && !circular\" (click)=\"navBackward($event)\">\n\t\t\t\t\t\t<span [ngClass]=\"{'ui-carousel-prev-icon pi': true, 'pi-chevron-left': !isVertical(), 'pi-chevron-up': isVertical()}\"></span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<div class=\"ui-carousel-items-content\" [ngStyle]=\"{'height': isVertical() ? verticalViewPortHeight : 'auto'}\">\n\t\t\t\t\t\t<div #itemsContainer class=\"ui-carousel-items-container\" (transitionend)=\"onTransitionEnd()\" (touchend)=\"onTouchEnd($event)\" (touchstart)=\"onTouchStart($event)\" (touchmove)=\"onTouchMove($event)\">\n\t\t\t\t\t\t\t<div *ngFor=\"let item of clonedItemsForStarting; let index = index\" [ngClass]= \"{'ui-carousel-item ui-carousel-item-cloned': true,'ui-carousel-item-active': (totalShiftedItems * -1) === (value.length),\n\t\t\t\t\t\t\t'ui-carousel-item-start': 0 === index,\n\t\t\t\t\t\t\t'ui-carousel-item-end': (clonedItemsForStarting.length - 1) === index}\">\n\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"itemTemplate; context: {$implicit: item}\"></ng-container>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div *ngFor=\"let item of value; let index = index\" [ngClass]= \"{'ui-carousel-item': true,'ui-carousel-item-active': (firstIndex() <= index && lastIndex() >= index),\n\t\t\t\t\t\t\t'ui-carousel-item-start': firstIndex() === index,\n\t\t\t\t\t\t\t'ui-carousel-item-end': lastIndex() === index}\">\n\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"itemTemplate; context: {$implicit: item}\"></ng-container>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div *ngFor=\"let item of clonedItemsForFinishing; let index = index\" [ngClass]= \"{'ui-carousel-item ui-carousel-item-cloned': true,'ui-carousel-item-active': ((totalShiftedItems *-1) === numVisible),\n\t\t\t\t\t\t\t'ui-carousel-item-start': 0 === index,\n\t\t\t\t\t\t\t'ui-carousel-item-end': (clonedItemsForFinishing.length - 1) === index}\">\n\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"itemTemplate; context: {$implicit: item}\"></ng-container>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<button [ngClass]=\"{'ui-carousel-next ui-button ui-widget ui-state-default ui-corner-all': true, 'ui-state-disabled': (_page === totalDots()-1 && !circular)}\" [disabled]=\"_page === totalDots()-1 && !circular\" (click)=\"navForward($event)\">\n\t\t\t\t\t\t<span [ngClass]=\"{'ui-carousel-next-icon pi': true, 'pi-chevron-right': !isVertical(), 'pi-chevron-down': isVertical()}\"></span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<ul [class]=\"dotsContentClasses()\">\n\t\t\t\t\t<li *ngFor=\"let totalDot of totalDotsArray(); let i = index\" [ngClass]=\"{'ui-carousel-dot-item':true,'ui-state-highlight': _page === i}\">\n\t\t\t\t\t\t<button class=\"ui-button ui-widget ui-state-default ui-corner-all\" (click)=\"onDotClick($event, i)\">\n\t\t\t\t\t\t\t<span [ngClass]=\"{'ui-carousel-dot-icon pi':true, 'pi-circle-on': _page === i, 'pi-circle-off': !(_page === i)}\"></span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t\t<div class=\"ui-carousel-footer\" *ngIf=\"footerFacet\">\n\t\t\t\t<ng-content select=\"p-footer\"></ng-content>\n\t\t\t</div>\n\t\t</div>\n\t"
312
521
  }),
313
- __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2, core_1.ChangeDetectorRef])
522
+ __metadata("design:paramtypes", [core_1.ElementRef, core_1.NgZone])
314
523
  ], Carousel);
315
524
  return Carousel;
316
525
  }());
@@ -321,7 +530,7 @@ var CarouselModule = /** @class */ (function () {
321
530
  CarouselModule = __decorate([
322
531
  core_1.NgModule({
323
532
  imports: [common_1.CommonModule, shared_1.SharedModule],
324
- exports: [Carousel, shared_1.SharedModule],
533
+ exports: [common_1.CommonModule, Carousel, shared_1.SharedModule],
325
534
  declarations: [Carousel]
326
535
  })
327
536
  ], CarouselModule);