/BankTMBWeb/node_modules/@angular/material/esm5/paginator.es5.js

https://bitbucket.org/EknarongAphiphutthikul/banktmb_project · JavaScript · 522 lines · 275 code · 6 blank · 241 comment · 20 complexity · a61ce8fd68e5e39b60215baa12c587bf MD5 · raw file

  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { Injectable, Optional, SkipSelf, NgModule, ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewEncapsulation, defineInjectable } from '@angular/core';
  9. import { Subject } from 'rxjs';
  10. import { __extends } from 'tslib';
  11. import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
  12. import { mixinInitialized } from '@angular/material/core';
  13. import { CommonModule } from '@angular/common';
  14. import { MatButtonModule } from '@angular/material/button';
  15. import { MatSelectModule } from '@angular/material/select';
  16. import { MatTooltipModule } from '@angular/material/tooltip';
  17. /**
  18. * @fileoverview added by tsickle
  19. * @suppress {checkTypes} checked by tsc
  20. */
  21. /**
  22. * To modify the labels and text displayed, create a new instance of MatPaginatorIntl and
  23. * include it in a custom provider
  24. */
  25. var MatPaginatorIntl = /** @class */ (function () {
  26. function MatPaginatorIntl() {
  27. /**
  28. * Stream that emits whenever the labels here are changed. Use this to notify
  29. * components if the labels have changed after initialization.
  30. */
  31. this.changes = new Subject();
  32. /**
  33. * A label for the page size selector.
  34. */
  35. this.itemsPerPageLabel = 'Items per page:';
  36. /**
  37. * A label for the button that increments the current page.
  38. */
  39. this.nextPageLabel = 'Next page';
  40. /**
  41. * A label for the button that decrements the current page.
  42. */
  43. this.previousPageLabel = 'Previous page';
  44. /**
  45. * A label for the button that moves to the first page.
  46. */
  47. this.firstPageLabel = 'First page';
  48. /**
  49. * A label for the button that moves to the last page.
  50. */
  51. this.lastPageLabel = 'Last page';
  52. /**
  53. * A label for the range of items within the current page and the length of the whole list.
  54. */
  55. this.getRangeLabel = function (page, pageSize, length) {
  56. if (length == 0 || pageSize == 0) {
  57. return "0 of " + length;
  58. }
  59. length = Math.max(length, 0);
  60. var /** @type {?} */ startIndex = page * pageSize;
  61. // If the start index exceeds the list length, do not try and fix the end index to the end.
  62. var /** @type {?} */ endIndex = startIndex < length ?
  63. Math.min(startIndex + pageSize, length) :
  64. startIndex + pageSize;
  65. return startIndex + 1 + " - " + endIndex + " of " + length;
  66. };
  67. }
  68. MatPaginatorIntl.decorators = [
  69. { type: Injectable, args: [{ providedIn: 'root' },] },
  70. ];
  71. /** @nocollapse */ MatPaginatorIntl.ngInjectableDef = defineInjectable({ factory: function MatPaginatorIntl_Factory() { return new MatPaginatorIntl(); }, token: MatPaginatorIntl, providedIn: "root" });
  72. return MatPaginatorIntl;
  73. }());
  74. /**
  75. * \@docs-private
  76. * @param {?} parentIntl
  77. * @return {?}
  78. */
  79. function MAT_PAGINATOR_INTL_PROVIDER_FACTORY(parentIntl) {
  80. return parentIntl || new MatPaginatorIntl();
  81. }
  82. /**
  83. * \@docs-private
  84. */
  85. var /** @type {?} */ MAT_PAGINATOR_INTL_PROVIDER = {
  86. // If there is already an MatPaginatorIntl available, use that. Otherwise, provide a new one.
  87. provide: MatPaginatorIntl,
  88. deps: [[new Optional(), new SkipSelf(), MatPaginatorIntl]],
  89. useFactory: MAT_PAGINATOR_INTL_PROVIDER_FACTORY
  90. };
  91. /**
  92. * @fileoverview added by tsickle
  93. * @suppress {checkTypes} checked by tsc
  94. */
  95. /**
  96. * The default page size if there is no page size and there are no provided page size options.
  97. */
  98. var /** @type {?} */ DEFAULT_PAGE_SIZE = 50;
  99. /**
  100. * Change event object that is emitted when the user selects a
  101. * different page size or navigates to another page.
  102. */
  103. var /**
  104. * Change event object that is emitted when the user selects a
  105. * different page size or navigates to another page.
  106. */
  107. PageEvent = /** @class */ (function () {
  108. function PageEvent() {
  109. }
  110. return PageEvent;
  111. }());
  112. /**
  113. * \@docs-private
  114. */
  115. var /**
  116. * \@docs-private
  117. */
  118. MatPaginatorBase = /** @class */ (function () {
  119. function MatPaginatorBase() {
  120. }
  121. return MatPaginatorBase;
  122. }());
  123. var /** @type {?} */ _MatPaginatorBase = mixinInitialized(MatPaginatorBase);
  124. /**
  125. * Component to provide navigation between paged information. Displays the size of the current
  126. * page, user-selectable options to change that size, what items are being shown, and
  127. * navigational button to go to the previous or next page.
  128. */
  129. var MatPaginator = /** @class */ (function (_super) {
  130. __extends(MatPaginator, _super);
  131. function MatPaginator(_intl, _changeDetectorRef) {
  132. var _this = _super.call(this) || this;
  133. _this._intl = _intl;
  134. _this._changeDetectorRef = _changeDetectorRef;
  135. _this._pageIndex = 0;
  136. _this._length = 0;
  137. _this._pageSizeOptions = [];
  138. _this._hidePageSize = false;
  139. _this._showFirstLastButtons = false;
  140. /**
  141. * Event emitted when the paginator changes the page size or page index.
  142. */
  143. _this.page = new EventEmitter();
  144. _this._intlChanges = _intl.changes.subscribe(function () { return _this._changeDetectorRef.markForCheck(); });
  145. return _this;
  146. }
  147. Object.defineProperty(MatPaginator.prototype, "pageIndex", {
  148. get: /**
  149. * The zero-based page index of the displayed list of items. Defaulted to 0.
  150. * @return {?}
  151. */
  152. function () { return this._pageIndex; },
  153. set: /**
  154. * @param {?} value
  155. * @return {?}
  156. */
  157. function (value) {
  158. this._pageIndex = Math.max(coerceNumberProperty(value), 0);
  159. this._changeDetectorRef.markForCheck();
  160. },
  161. enumerable: true,
  162. configurable: true
  163. });
  164. Object.defineProperty(MatPaginator.prototype, "length", {
  165. get: /**
  166. * The length of the total number of items that are being paginated. Defaulted to 0.
  167. * @return {?}
  168. */
  169. function () { return this._length; },
  170. set: /**
  171. * @param {?} value
  172. * @return {?}
  173. */
  174. function (value) {
  175. this._length = coerceNumberProperty(value);
  176. this._changeDetectorRef.markForCheck();
  177. },
  178. enumerable: true,
  179. configurable: true
  180. });
  181. Object.defineProperty(MatPaginator.prototype, "pageSize", {
  182. get: /**
  183. * Number of items to display on a page. By default set to 50.
  184. * @return {?}
  185. */
  186. function () { return this._pageSize; },
  187. set: /**
  188. * @param {?} value
  189. * @return {?}
  190. */
  191. function (value) {
  192. this._pageSize = Math.max(coerceNumberProperty(value), 0);
  193. this._updateDisplayedPageSizeOptions();
  194. },
  195. enumerable: true,
  196. configurable: true
  197. });
  198. Object.defineProperty(MatPaginator.prototype, "pageSizeOptions", {
  199. get: /**
  200. * The set of provided page size options to display to the user.
  201. * @return {?}
  202. */
  203. function () { return this._pageSizeOptions; },
  204. set: /**
  205. * @param {?} value
  206. * @return {?}
  207. */
  208. function (value) {
  209. this._pageSizeOptions = (value || []).map(function (p) { return coerceNumberProperty(p); });
  210. this._updateDisplayedPageSizeOptions();
  211. },
  212. enumerable: true,
  213. configurable: true
  214. });
  215. Object.defineProperty(MatPaginator.prototype, "hidePageSize", {
  216. get: /**
  217. * Whether to hide the page size selection UI from the user.
  218. * @return {?}
  219. */
  220. function () { return this._hidePageSize; },
  221. set: /**
  222. * @param {?} value
  223. * @return {?}
  224. */
  225. function (value) {
  226. this._hidePageSize = coerceBooleanProperty(value);
  227. },
  228. enumerable: true,
  229. configurable: true
  230. });
  231. Object.defineProperty(MatPaginator.prototype, "showFirstLastButtons", {
  232. get: /**
  233. * Whether to show the first/last buttons UI to the user.
  234. * @return {?}
  235. */
  236. function () { return this._showFirstLastButtons; },
  237. set: /**
  238. * @param {?} value
  239. * @return {?}
  240. */
  241. function (value) {
  242. this._showFirstLastButtons = coerceBooleanProperty(value);
  243. },
  244. enumerable: true,
  245. configurable: true
  246. });
  247. /**
  248. * @return {?}
  249. */
  250. MatPaginator.prototype.ngOnInit = /**
  251. * @return {?}
  252. */
  253. function () {
  254. this._initialized = true;
  255. this._updateDisplayedPageSizeOptions();
  256. this._markInitialized();
  257. };
  258. /**
  259. * @return {?}
  260. */
  261. MatPaginator.prototype.ngOnDestroy = /**
  262. * @return {?}
  263. */
  264. function () {
  265. this._intlChanges.unsubscribe();
  266. };
  267. /** Advances to the next page if it exists. */
  268. /**
  269. * Advances to the next page if it exists.
  270. * @return {?}
  271. */
  272. MatPaginator.prototype.nextPage = /**
  273. * Advances to the next page if it exists.
  274. * @return {?}
  275. */
  276. function () {
  277. if (!this.hasNextPage()) {
  278. return;
  279. }
  280. var /** @type {?} */ previousPageIndex = this.pageIndex;
  281. this.pageIndex++;
  282. this._emitPageEvent(previousPageIndex);
  283. };
  284. /** Move back to the previous page if it exists. */
  285. /**
  286. * Move back to the previous page if it exists.
  287. * @return {?}
  288. */
  289. MatPaginator.prototype.previousPage = /**
  290. * Move back to the previous page if it exists.
  291. * @return {?}
  292. */
  293. function () {
  294. if (!this.hasPreviousPage()) {
  295. return;
  296. }
  297. var /** @type {?} */ previousPageIndex = this.pageIndex;
  298. this.pageIndex--;
  299. this._emitPageEvent(previousPageIndex);
  300. };
  301. /** Move to the first page if not already there. */
  302. /**
  303. * Move to the first page if not already there.
  304. * @return {?}
  305. */
  306. MatPaginator.prototype.firstPage = /**
  307. * Move to the first page if not already there.
  308. * @return {?}
  309. */
  310. function () {
  311. // hasPreviousPage being false implies at the start
  312. if (!this.hasPreviousPage()) {
  313. return;
  314. }
  315. var /** @type {?} */ previousPageIndex = this.pageIndex;
  316. this.pageIndex = 0;
  317. this._emitPageEvent(previousPageIndex);
  318. };
  319. /** Move to the last page if not already there. */
  320. /**
  321. * Move to the last page if not already there.
  322. * @return {?}
  323. */
  324. MatPaginator.prototype.lastPage = /**
  325. * Move to the last page if not already there.
  326. * @return {?}
  327. */
  328. function () {
  329. // hasNextPage being false implies at the end
  330. if (!this.hasNextPage()) {
  331. return;
  332. }
  333. var /** @type {?} */ previousPageIndex = this.pageIndex;
  334. this.pageIndex = this.getNumberOfPages();
  335. this._emitPageEvent(previousPageIndex);
  336. };
  337. /** Whether there is a previous page. */
  338. /**
  339. * Whether there is a previous page.
  340. * @return {?}
  341. */
  342. MatPaginator.prototype.hasPreviousPage = /**
  343. * Whether there is a previous page.
  344. * @return {?}
  345. */
  346. function () {
  347. return this.pageIndex >= 1 && this.pageSize != 0;
  348. };
  349. /** Whether there is a next page. */
  350. /**
  351. * Whether there is a next page.
  352. * @return {?}
  353. */
  354. MatPaginator.prototype.hasNextPage = /**
  355. * Whether there is a next page.
  356. * @return {?}
  357. */
  358. function () {
  359. var /** @type {?} */ numberOfPages = this.getNumberOfPages();
  360. return this.pageIndex < numberOfPages && this.pageSize != 0;
  361. };
  362. /** Calculate the number of pages */
  363. /**
  364. * Calculate the number of pages
  365. * @return {?}
  366. */
  367. MatPaginator.prototype.getNumberOfPages = /**
  368. * Calculate the number of pages
  369. * @return {?}
  370. */
  371. function () {
  372. return Math.ceil(this.length / this.pageSize) - 1;
  373. };
  374. /**
  375. * Changes the page size so that the first item displayed on the page will still be
  376. * displayed using the new page size.
  377. *
  378. * For example, if the page size is 10 and on the second page (items indexed 10-19) then
  379. * switching so that the page size is 5 will set the third page as the current page so
  380. * that the 10th item will still be displayed.
  381. */
  382. /**
  383. * Changes the page size so that the first item displayed on the page will still be
  384. * displayed using the new page size.
  385. *
  386. * For example, if the page size is 10 and on the second page (items indexed 10-19) then
  387. * switching so that the page size is 5 will set the third page as the current page so
  388. * that the 10th item will still be displayed.
  389. * @param {?} pageSize
  390. * @return {?}
  391. */
  392. MatPaginator.prototype._changePageSize = /**
  393. * Changes the page size so that the first item displayed on the page will still be
  394. * displayed using the new page size.
  395. *
  396. * For example, if the page size is 10 and on the second page (items indexed 10-19) then
  397. * switching so that the page size is 5 will set the third page as the current page so
  398. * that the 10th item will still be displayed.
  399. * @param {?} pageSize
  400. * @return {?}
  401. */
  402. function (pageSize) {
  403. // Current page needs to be updated to reflect the new page size. Navigate to the page
  404. // containing the previous page's first item.
  405. var /** @type {?} */ startIndex = this.pageIndex * this.pageSize;
  406. var /** @type {?} */ previousPageIndex = this.pageIndex;
  407. this.pageIndex = Math.floor(startIndex / pageSize) || 0;
  408. this.pageSize = pageSize;
  409. this._emitPageEvent(previousPageIndex);
  410. };
  411. /**
  412. * Updates the list of page size options to display to the user. Includes making sure that
  413. * the page size is an option and that the list is sorted.
  414. * @return {?}
  415. */
  416. MatPaginator.prototype._updateDisplayedPageSizeOptions = /**
  417. * Updates the list of page size options to display to the user. Includes making sure that
  418. * the page size is an option and that the list is sorted.
  419. * @return {?}
  420. */
  421. function () {
  422. if (!this._initialized) {
  423. return;
  424. }
  425. // If no page size is provided, use the first page size option or the default page size.
  426. if (!this.pageSize) {
  427. this._pageSize = this.pageSizeOptions.length != 0 ?
  428. this.pageSizeOptions[0] :
  429. DEFAULT_PAGE_SIZE;
  430. }
  431. this._displayedPageSizeOptions = this.pageSizeOptions.slice();
  432. if (this._displayedPageSizeOptions.indexOf(this.pageSize) === -1) {
  433. this._displayedPageSizeOptions.push(this.pageSize);
  434. }
  435. // Sort the numbers using a number-specific sort function.
  436. this._displayedPageSizeOptions.sort(function (a, b) { return a - b; });
  437. this._changeDetectorRef.markForCheck();
  438. };
  439. /**
  440. * Emits an event notifying that a change of the paginator's properties has been triggered.
  441. * @param {?} previousPageIndex
  442. * @return {?}
  443. */
  444. MatPaginator.prototype._emitPageEvent = /**
  445. * Emits an event notifying that a change of the paginator's properties has been triggered.
  446. * @param {?} previousPageIndex
  447. * @return {?}
  448. */
  449. function (previousPageIndex) {
  450. this.page.emit({
  451. previousPageIndex: previousPageIndex,
  452. pageIndex: this.pageIndex,
  453. pageSize: this.pageSize,
  454. length: this.length
  455. });
  456. };
  457. MatPaginator.decorators = [
  458. { type: Component, args: [{selector: 'mat-paginator',
  459. exportAs: 'matPaginator',
  460. template: "<div class=\"mat-paginator-container\"><div class=\"mat-paginator-page-size\" *ngIf=\"!hidePageSize\"><div class=\"mat-paginator-page-size-label\">{{_intl.itemsPerPageLabel}}</div><mat-form-field *ngIf=\"_displayedPageSizeOptions.length > 1\" class=\"mat-paginator-page-size-select\"><mat-select [value]=\"pageSize\" [aria-label]=\"_intl.itemsPerPageLabel\" (selectionChange)=\"_changePageSize($event.value)\"><mat-option *ngFor=\"let pageSizeOption of _displayedPageSizeOptions\" [value]=\"pageSizeOption\">{{pageSizeOption}}</mat-option></mat-select></mat-form-field><div *ngIf=\"_displayedPageSizeOptions.length <= 1\">{{pageSize}}</div></div><div class=\"mat-paginator-range-actions\"><div class=\"mat-paginator-range-label\">{{_intl.getRangeLabel(pageIndex, pageSize, length)}}</div><button mat-icon-button type=\"button\" class=\"mat-paginator-navigation-first\" (click)=\"firstPage()\" [attr.aria-label]=\"_intl.firstPageLabel\" [matTooltip]=\"_intl.firstPageLabel\" [matTooltipPosition]=\"'above'\" [disabled]=\"!hasPreviousPage()\" *ngIf=\"showFirstLastButtons\"><svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\"><path d=\"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z\"/></svg></button> <button mat-icon-button type=\"button\" class=\"mat-paginator-navigation-previous\" (click)=\"previousPage()\" [attr.aria-label]=\"_intl.previousPageLabel\" [matTooltip]=\"_intl.previousPageLabel\" [matTooltipPosition]=\"'above'\" [disabled]=\"!hasPreviousPage()\"><svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\"><path d=\"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z\"/></svg></button> <button mat-icon-button type=\"button\" class=\"mat-paginator-navigation-next\" (click)=\"nextPage()\" [attr.aria-label]=\"_intl.nextPageLabel\" [matTooltip]=\"_intl.nextPageLabel\" [matTooltipPosition]=\"'above'\" [disabled]=\"!hasNextPage()\"><svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\"><path d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\"/></svg></button> <button mat-icon-button type=\"button\" class=\"mat-paginator-navigation-last\" (click)=\"lastPage()\" [attr.aria-label]=\"_intl.lastPageLabel\" [matTooltip]=\"_intl.lastPageLabel\" [matTooltipPosition]=\"'above'\" [disabled]=\"!hasNextPage()\" *ngIf=\"showFirstLastButtons\"><svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\"><path d=\"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z\"/></svg></button></div></div>",
  461. styles: [".mat-paginator{display:block}.mat-paginator-container{display:flex;align-items:center;justify-content:flex-end;min-height:56px;padding:0 8px;flex-wrap:wrap-reverse}.mat-paginator-page-size{display:flex;align-items:baseline;margin-right:8px}[dir=rtl] .mat-paginator-page-size{margin-right:0;margin-left:8px}.mat-paginator-page-size-label{margin:0 4px}.mat-paginator-page-size-select{margin:6px 4px 0 4px;width:56px}.mat-paginator-range-label{margin:0 32px 0 24px}.mat-paginator-range-actions{display:flex;align-items:center;min-height:48px}.mat-paginator-icon{width:28px;fill:currentColor}[dir=rtl] .mat-paginator-icon{transform:rotate(180deg)}"],
  462. host: {
  463. 'class': 'mat-paginator',
  464. },
  465. changeDetection: ChangeDetectionStrategy.OnPush,
  466. encapsulation: ViewEncapsulation.None,
  467. },] },
  468. ];
  469. /** @nocollapse */
  470. MatPaginator.ctorParameters = function () { return [
  471. { type: MatPaginatorIntl, },
  472. { type: ChangeDetectorRef, },
  473. ]; };
  474. MatPaginator.propDecorators = {
  475. "pageIndex": [{ type: Input },],
  476. "length": [{ type: Input },],
  477. "pageSize": [{ type: Input },],
  478. "pageSizeOptions": [{ type: Input },],
  479. "hidePageSize": [{ type: Input },],
  480. "showFirstLastButtons": [{ type: Input },],
  481. "page": [{ type: Output },],
  482. };
  483. return MatPaginator;
  484. }(_MatPaginatorBase));
  485. /**
  486. * @fileoverview added by tsickle
  487. * @suppress {checkTypes} checked by tsc
  488. */
  489. var MatPaginatorModule = /** @class */ (function () {
  490. function MatPaginatorModule() {
  491. }
  492. MatPaginatorModule.decorators = [
  493. { type: NgModule, args: [{
  494. imports: [
  495. CommonModule,
  496. MatButtonModule,
  497. MatSelectModule,
  498. MatTooltipModule,
  499. ],
  500. exports: [MatPaginator],
  501. declarations: [MatPaginator],
  502. providers: [MAT_PAGINATOR_INTL_PROVIDER],
  503. },] },
  504. ];
  505. return MatPaginatorModule;
  506. }());
  507. /**
  508. * @fileoverview added by tsickle
  509. * @suppress {checkTypes} checked by tsc
  510. */
  511. /**
  512. * @fileoverview added by tsickle
  513. * @suppress {checkTypes} checked by tsc
  514. */
  515. export { MatPaginatorModule, PageEvent, MatPaginatorBase, _MatPaginatorBase, MatPaginator, MatPaginatorIntl, MAT_PAGINATOR_INTL_PROVIDER_FACTORY, MAT_PAGINATOR_INTL_PROVIDER };
  516. //# sourceMappingURL=paginator.es5.js.map