cmat 0.0.78 → 0.0.80

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 (211) hide show
  1. package/fesm2022/cmat-components-adapter.mjs +9 -46
  2. package/fesm2022/cmat-components-adapter.mjs.map +1 -1
  3. package/fesm2022/cmat-components-breadcrumb.mjs +104 -205
  4. package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
  5. package/fesm2022/cmat-components-card.mjs +4 -8
  6. package/fesm2022/cmat-components-card.mjs.map +1 -1
  7. package/fesm2022/cmat-components-carousel.mjs +21 -21
  8. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  9. package/fesm2022/cmat-components-cascade.mjs +18 -24
  10. package/fesm2022/cmat-components-cascade.mjs.map +1 -1
  11. package/fesm2022/cmat-components-chip-input.mjs +21 -21
  12. package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
  13. package/fesm2022/cmat-components-code-editor.mjs +4 -22
  14. package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
  15. package/fesm2022/cmat-components-custom-formly.mjs +181 -245
  16. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  17. package/fesm2022/cmat-components-date-range.mjs +12 -184
  18. package/fesm2022/cmat-components-date-range.mjs.map +1 -1
  19. package/fesm2022/cmat-components-date-time-display.mjs +3 -15
  20. package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
  21. package/fesm2022/cmat-components-drawer.mjs +10 -100
  22. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  23. package/fesm2022/cmat-components-empty-state.mjs +4 -25
  24. package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
  25. package/fesm2022/cmat-components-file-preview.mjs +3 -21
  26. package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
  27. package/fesm2022/cmat-components-filter-toolbar.mjs +7 -50
  28. package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
  29. package/fesm2022/cmat-components-form-actions.mjs +3 -9
  30. package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
  31. package/fesm2022/cmat-components-fullscreen.mjs +4 -4
  32. package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
  33. package/fesm2022/cmat-components-highlight.mjs +6 -32
  34. package/fesm2022/cmat-components-highlight.mjs.map +1 -1
  35. package/fesm2022/cmat-components-image-viewer.mjs +12 -24
  36. package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
  37. package/fesm2022/cmat-components-inline-loading.mjs +3 -12
  38. package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
  39. package/fesm2022/cmat-components-json-editor.mjs +11 -16
  40. package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
  41. package/fesm2022/cmat-components-knob-input.mjs +24 -18
  42. package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
  43. package/fesm2022/cmat-components-masonry.mjs +8 -17
  44. package/fesm2022/cmat-components-masonry.mjs.map +1 -1
  45. package/fesm2022/cmat-components-material-color-picker.mjs +13 -34
  46. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  47. package/fesm2022/cmat-components-material-datetimepicker.mjs +80 -436
  48. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  49. package/fesm2022/cmat-components-navigation.mjs +266 -816
  50. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  51. package/fesm2022/cmat-components-opt-input.mjs +7 -10
  52. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  53. package/fesm2022/cmat-components-org-chart.mjs +11 -11
  54. package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
  55. package/fesm2022/cmat-components-page-header.mjs +8 -19
  56. package/fesm2022/cmat-components-page-header.mjs.map +1 -1
  57. package/fesm2022/cmat-components-pagination.mjs +113 -108
  58. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  59. package/fesm2022/cmat-components-password-strength.mjs +13 -16
  60. package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
  61. package/fesm2022/cmat-components-popover.mjs +15 -151
  62. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  63. package/fesm2022/cmat-components-progress-bar.mjs +16 -26
  64. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  65. package/fesm2022/cmat-components-qrcode.mjs +5 -11
  66. package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
  67. package/fesm2022/cmat-components-rating.mjs +14 -14
  68. package/fesm2022/cmat-components-rating.mjs.map +1 -1
  69. package/fesm2022/cmat-components-rich-text-editor.mjs +4 -25
  70. package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
  71. package/fesm2022/cmat-components-select-search.mjs +51 -79
  72. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  73. package/fesm2022/cmat-components-select-table.mjs +204 -162
  74. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  75. package/fesm2022/cmat-components-select-tree.mjs +142 -97
  76. package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
  77. package/fesm2022/cmat-components-skeleton.mjs +4 -22
  78. package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
  79. package/fesm2022/cmat-components-speed-dial.mjs +14 -19
  80. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  81. package/fesm2022/cmat-components-status-tag.mjs +3 -18
  82. package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
  83. package/fesm2022/cmat-components-table-toolbar.mjs +3 -15
  84. package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
  85. package/fesm2022/cmat-components-timeline.mjs +18 -21
  86. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  87. package/fesm2022/cmat-components-toast.mjs +20 -20
  88. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  89. package/fesm2022/cmat-components-transfer-picker.mjs +159 -123
  90. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  91. package/fesm2022/cmat-components-treetable.mjs +17 -19
  92. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  93. package/fesm2022/cmat-components-upload.mjs +35 -57
  94. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  95. package/fesm2022/cmat-components-x6-angular-shape.mjs +0 -4
  96. package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
  97. package/fesm2022/cmat-directives-animate-on-scroll.mjs +6 -27
  98. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  99. package/fesm2022/cmat-directives-arrow-cursor.mjs +7 -9
  100. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  101. package/fesm2022/cmat-directives-autofocus.mjs +3 -3
  102. package/fesm2022/cmat-directives-data-exporter.mjs +24 -33
  103. package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
  104. package/fesm2022/cmat-directives-debounce.mjs +14 -17
  105. package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
  106. package/fesm2022/cmat-directives-digit-only.mjs +6 -23
  107. package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
  108. package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
  109. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +4 -11
  110. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
  111. package/fesm2022/cmat-lib-mock-api.mjs +6 -43
  112. package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
  113. package/fesm2022/cmat-pipes-bytes.mjs +3 -3
  114. package/fesm2022/cmat-pipes-date-format.mjs +3 -3
  115. package/fesm2022/cmat-pipes-find-by-key.mjs +3 -5
  116. package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
  117. package/fesm2022/cmat-pipes-group-by.mjs +3 -3
  118. package/fesm2022/cmat-pipes-keys.mjs +3 -3
  119. package/fesm2022/cmat-pipes-secure.mjs +8 -12
  120. package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
  121. package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
  122. package/fesm2022/cmat-services-alert.mjs +3 -3
  123. package/fesm2022/cmat-services-config.mjs +50 -26
  124. package/fesm2022/cmat-services-config.mjs.map +1 -1
  125. package/fesm2022/cmat-services-confirmation.mjs +9 -11
  126. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  127. package/fesm2022/cmat-services-data.mjs +56 -101
  128. package/fesm2022/cmat-services-data.mjs.map +1 -1
  129. package/fesm2022/cmat-services-export-as.mjs +4 -32
  130. package/fesm2022/cmat-services-export-as.mjs.map +1 -1
  131. package/fesm2022/cmat-services-loading.mjs +49 -40
  132. package/fesm2022/cmat-services-loading.mjs.map +1 -1
  133. package/fesm2022/cmat-services-local-storage.mjs +3 -3
  134. package/fesm2022/cmat-services-media-watcher.mjs +19 -25
  135. package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
  136. package/fesm2022/cmat-services-platform.mjs +3 -10
  137. package/fesm2022/cmat-services-platform.mjs.map +1 -1
  138. package/fesm2022/cmat-services-splash-screen.mjs +8 -13
  139. package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
  140. package/fesm2022/cmat-services-title.mjs +8 -12
  141. package/fesm2022/cmat-services-title.mjs.map +1 -1
  142. package/fesm2022/cmat-services-translation.mjs +3 -3
  143. package/fesm2022/cmat-services-utils.mjs +5 -27
  144. package/fesm2022/cmat-services-utils.mjs.map +1 -1
  145. package/fesm2022/cmat-validators.mjs +0 -8
  146. package/fesm2022/cmat-validators.mjs.map +1 -1
  147. package/fesm2022/cmat.mjs +3477 -3795
  148. package/fesm2022/cmat.mjs.map +1 -1
  149. package/package.json +1 -1
  150. package/tailwind/plugins/helpers.js +1 -10
  151. package/tailwind/plugins/scrollbar/index.js +0 -1
  152. package/tailwind/plugins/scrollbar/typedefs.js +1 -7
  153. package/tailwind/plugins/scrollbar/utilities.js +9 -58
  154. package/tailwind/plugins/scrollbar/variants.js +2 -17
  155. package/tailwind/plugins/theming.js +1 -57
  156. package/tailwind/utils/generate-contrasts.js +1 -12
  157. package/tailwind/utils/generate-palette.js +1 -32
  158. package/types/cmat-components-adapter.d.ts +0 -25
  159. package/types/cmat-components-breadcrumb.d.ts +25 -175
  160. package/types/cmat-components-carousel.d.ts +2 -20
  161. package/types/cmat-components-cascade.d.ts +4 -4
  162. package/types/cmat-components-chip-input.d.ts +4 -3
  163. package/types/cmat-components-code-editor.d.ts +0 -18
  164. package/types/cmat-components-custom-formly.d.ts +30 -37
  165. package/types/cmat-components-date-range.d.ts +1 -72
  166. package/types/cmat-components-date-time-display.d.ts +0 -15
  167. package/types/cmat-components-drawer.d.ts +2 -44
  168. package/types/cmat-components-empty-state.d.ts +0 -21
  169. package/types/cmat-components-file-preview.d.ts +0 -18
  170. package/types/cmat-components-filter-toolbar.d.ts +3 -43
  171. package/types/cmat-components-form-actions.d.ts +0 -6
  172. package/types/cmat-components-image-viewer.d.ts +5 -18
  173. package/types/cmat-components-inline-loading.d.ts +0 -9
  174. package/types/cmat-components-json-editor.d.ts +0 -1
  175. package/types/cmat-components-knob-input.d.ts +3 -3
  176. package/types/cmat-components-masonry.d.ts +1 -2
  177. package/types/cmat-components-material-color-picker.d.ts +1 -2
  178. package/types/cmat-components-material-datetimepicker.d.ts +6 -272
  179. package/types/cmat-components-navigation.d.ts +34 -171
  180. package/types/cmat-components-opt-input.d.ts +1 -1
  181. package/types/cmat-components-page-header.d.ts +2 -16
  182. package/types/cmat-components-pagination.d.ts +26 -27
  183. package/types/cmat-components-password-strength.d.ts +1 -2
  184. package/types/cmat-components-popover.d.ts +1 -110
  185. package/types/cmat-components-progress-bar.d.ts +9 -11
  186. package/types/cmat-components-rating.d.ts +6 -7
  187. package/types/cmat-components-rich-text-editor.d.ts +0 -21
  188. package/types/cmat-components-select-search.d.ts +4 -20
  189. package/types/cmat-components-select-table.d.ts +24 -12
  190. package/types/cmat-components-select-tree.d.ts +29 -29
  191. package/types/cmat-components-skeleton.d.ts +0 -18
  192. package/types/cmat-components-speed-dial.d.ts +1 -2
  193. package/types/cmat-components-status-tag.d.ts +0 -15
  194. package/types/cmat-components-table-toolbar.d.ts +0 -12
  195. package/types/cmat-components-timeline.d.ts +3 -4
  196. package/types/cmat-components-toast.d.ts +2 -2
  197. package/types/cmat-components-transfer-picker.d.ts +42 -36
  198. package/types/cmat-components-treetable.d.ts +3 -4
  199. package/types/cmat-components-upload.d.ts +12 -17
  200. package/types/cmat-components-x6-angular-shape.d.ts +0 -1
  201. package/types/cmat-directives-arrow-cursor.d.ts +1 -1
  202. package/types/cmat-directives-debounce.d.ts +3 -4
  203. package/types/cmat-pipes-secure.d.ts +3 -4
  204. package/types/cmat-services-config.d.ts +35 -13
  205. package/types/cmat-services-data.d.ts +13 -12
  206. package/types/cmat-services-export-as.d.ts +0 -22
  207. package/types/cmat-services-loading.d.ts +15 -10
  208. package/types/cmat-services-media-watcher.d.ts +10 -13
  209. package/types/cmat-services-splash-screen.d.ts +2 -4
  210. package/types/cmat-services-title.d.ts +3 -5
  211. package/types/cmat.d.ts +733 -1391
@@ -1,6 +1,7 @@
1
1
  import { NgStyle, DecimalPipe } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { EventEmitter, Injectable, inject, ChangeDetectorRef, Output, Input, Directive, ViewEncapsulation, ChangeDetectionStrategy, Component, Pipe } from '@angular/core';
3
+ import { Injectable, EventEmitter, signal, inject, Injector, DestroyRef, afterNextRender, Output, Input, Directive, ViewEncapsulation, ChangeDetectionStrategy, Component, Pipe } from '@angular/core';
4
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
5
  import * as i5 from '@angular/material/button';
5
6
  import { MatButtonModule } from '@angular/material/button';
6
7
  import * as i2 from '@angular/material/form-field';
@@ -13,35 +14,38 @@ import * as i4 from '@angular/material/select';
13
14
  import { MatSelectModule } from '@angular/material/select';
14
15
  import { CmatDigitOnlyDirective } from 'cmat/directives/digit-only';
15
16
  import { CmatMediaWatcherService } from 'cmat/services/media-watcher';
16
- import { Subject, takeUntil } from 'rxjs';
17
- import { isNil } from 'lodash-es';
17
+ import { Subject } from 'rxjs';
18
18
 
19
19
  class CmatPaginationService {
20
20
  constructor() {
21
- this.change = new EventEmitter();
21
+ this._change = new Subject();
22
22
  this._instances = {};
23
23
  this._defaultPaginationId = 'DEFAULT_PAGINATION_ID';
24
24
  }
25
+ get change$() {
26
+ return this._change.asObservable();
27
+ }
25
28
  defaultId() { return this._defaultPaginationId; }
29
+ notifyChange(id) {
30
+ this._change.next(id);
31
+ }
26
32
  register(instance) {
27
- instance.id ??= this._defaultPaginationId;
28
- if (!this._instances[instance.id]) {
29
- this._instances[instance.id] = instance;
33
+ const normalizedInstance = {
34
+ ...structuredClone(instance),
35
+ id: instance.id ?? this._defaultPaginationId
36
+ };
37
+ const id = normalizedInstance.id;
38
+ if (!this._instances[id]) {
39
+ this._instances[id] = normalizedInstance;
30
40
  return true;
31
41
  }
32
- else {
33
- return this._updateInstance(instance);
34
- }
42
+ return this._updateInstance(normalizedInstance);
35
43
  }
36
44
  getCurrentPage(id) {
37
- if (this._instances[id]) {
38
- return this._instances[id].currentPage;
39
- }
45
+ return this._instances[id]?.currentPage;
40
46
  }
41
47
  getItemsPerPage(id) {
42
- if (this._instances[id]) {
43
- return this._instances[id].itemsPerPage;
44
- }
48
+ return this._instances[id]?.itemsPerPage;
45
49
  }
46
50
  setCurrentPage(id, page) {
47
51
  if (this._instances[id]) {
@@ -49,34 +53,37 @@ class CmatPaginationService {
49
53
  const maxPage = Math.ceil(instance.totalItems / instance.itemsPerPage);
50
54
  if (page <= maxPage && 1 <= page) {
51
55
  this._instances[id].currentPage = page;
52
- this.change.emit(id);
56
+ this.notifyChange(id);
53
57
  }
54
58
  }
55
59
  }
56
60
  setTotalItems(id, totalItems) {
57
61
  if (this._instances[id] && 0 <= totalItems) {
58
62
  this._instances[id].totalItems = totalItems;
59
- this.change.emit(id);
63
+ this.notifyChange(id);
60
64
  }
61
65
  }
62
66
  setItemsPerPage(id, itemsPerPage) {
63
67
  if (this._instances[id]) {
64
68
  this._instances[id].itemsPerPage = itemsPerPage;
65
- this.change.emit(id);
69
+ this.notifyChange(id);
66
70
  }
67
71
  }
68
72
  getInstance(id = this._defaultPaginationId) {
69
73
  if (this._instances[id]) {
70
74
  return this._clone(this._instances[id]);
71
75
  }
72
- return {};
76
+ return undefined;
73
77
  }
74
78
  _updateInstance(instance) {
75
79
  let changed = false;
76
80
  if (instance.id) {
77
- for (const prop in this._instances[instance.id]) {
78
- if (instance[prop] !== this._instances[instance.id][prop]) {
79
- this._instances[instance.id][prop] = instance[prop];
81
+ const currentInstance = this._instances[instance.id];
82
+ const keys = new Set([...Object.keys(currentInstance), ...Object.keys(instance)]);
83
+ for (const prop of keys) {
84
+ const key = prop;
85
+ if (instance[key] !== currentInstance[key]) {
86
+ currentInstance[key] = instance[key];
80
87
  changed = true;
81
88
  }
82
89
  }
@@ -84,18 +91,12 @@ class CmatPaginationService {
84
91
  return changed;
85
92
  }
86
93
  _clone(obj) {
87
- const target = {};
88
- for (const i in obj) {
89
- if (Object.prototype.hasOwnProperty.call(obj, i)) {
90
- target[i] = obj[i];
91
- }
92
- }
93
- return target;
94
+ return structuredClone(obj);
94
95
  }
95
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
96
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationService, providedIn: 'root' }); }
96
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
97
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationService, providedIn: 'root' }); }
97
98
  }
98
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationService, decorators: [{
99
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationService, decorators: [{
99
100
  type: Injectable,
100
101
  args: [{
101
102
  providedIn: 'root'
@@ -108,28 +109,24 @@ class CmatPaginationDirective {
108
109
  this.pageChange = new EventEmitter();
109
110
  this.pageBoundsCorrection = new EventEmitter();
110
111
  this.perPageCountChange = new EventEmitter();
111
- this.pages = [];
112
+ this.pages$ = signal([], ...(ngDevMode ? [{ debugName: "pages$" }] : /* istanbul ignore next */ []));
112
113
  this.service = inject(CmatPaginationService);
113
- this.changeDetectorRef = inject(ChangeDetectorRef);
114
- this._unsubscribeAll = new Subject();
115
- this.service.change.pipe(takeUntil(this._unsubscribeAll))
114
+ this._injector = inject(Injector);
115
+ this._destroyRef = inject(DestroyRef);
116
+ this._pageLinksUpdateQueued = false;
117
+ this.service.change$.pipe(takeUntilDestroyed(this._destroyRef))
116
118
  .subscribe((id) => {
117
119
  if (this.id === id) {
118
- this._updatePageLinks();
119
- this.changeDetectorRef.markForCheck();
120
+ this._schedulePageLinksUpdate();
120
121
  }
121
122
  });
122
123
  }
123
124
  ngOnInit() {
124
125
  this.id ??= this.service.defaultId();
125
- this._updatePageLinks();
126
+ this._schedulePageLinksUpdate();
126
127
  }
127
128
  ngOnChanges() {
128
- this._updatePageLinks();
129
- }
130
- ngOnDestroy() {
131
- this._unsubscribeAll.next(void 0);
132
- this._unsubscribeAll.complete();
129
+ this._schedulePageLinksUpdate();
133
130
  }
134
131
  previous() {
135
132
  if (!this.isFirstPage()) {
@@ -168,46 +165,61 @@ class CmatPaginationDirective {
168
165
  return this.getLastPage() === this.getCurrent();
169
166
  }
170
167
  setCurrent(page) {
171
- this.pageChange.emit(page);
168
+ const nextPage = Number(page);
169
+ if (!Number.isNaN(nextPage)) {
170
+ this.pageChange.emit(nextPage);
171
+ }
172
172
  }
173
173
  getCurrent() {
174
174
  return this.service.getCurrentPage(this.id);
175
175
  }
176
176
  getLastPage() {
177
177
  const inst = this.service.getInstance(this.id);
178
+ if (!inst) {
179
+ return;
180
+ }
178
181
  if (inst.totalItems < 1) {
179
- // when there are 0 or fewer (an error case) items, there are no "pages" as such,
180
- // but it makes sense to consider a single, empty page as the last page.
181
182
  return 1;
182
183
  }
183
184
  return Math.ceil(inst.totalItems / inst.itemsPerPage);
184
185
  }
185
186
  getTotalItems() {
186
- return this.service.getInstance(this.id).totalItems;
187
+ return this.service.getInstance(this.id)?.totalItems;
187
188
  }
188
189
  setItemsPerPage(count) {
189
190
  this.service.setItemsPerPage(this.id, count);
190
191
  this.perPageCountChange.emit(count);
191
192
  const inst = this.service.getInstance(this.id);
193
+ if (!inst) {
194
+ return;
195
+ }
192
196
  this.setCurrent(this._outOfBoundCorrection(inst));
193
197
  }
194
198
  _checkValidId() {
195
- if (this.service.getInstance(this.id).id == null) {
199
+ if (this.service.getInstance(this.id)?.id == null) {
196
200
  console.warn(`PaginationControlsDirective: the specified id "${this.id}" does not match any registered PaginationInstance`);
197
201
  }
198
202
  }
199
203
  _updatePageLinks() {
200
204
  const inst = this.service.getInstance(this.id);
201
- const correctedCurrentPage = this._outOfBoundCorrection(inst);
202
- if (correctedCurrentPage !== inst.currentPage) {
203
- setTimeout(() => {
204
- this.pageBoundsCorrection.emit(correctedCurrentPage);
205
- this.pages = this._createPageArray(inst.currentPage, inst.itemsPerPage, inst.totalItems, this.maxSize);
206
- });
205
+ if (!inst) {
206
+ this.pages$.set([]);
207
+ return;
207
208
  }
208
- else {
209
- this.pages = this._createPageArray(inst.currentPage, inst.itemsPerPage, inst.totalItems, this.maxSize);
209
+ const correctedCurrentPage = this._outOfBoundCorrection(inst);
210
+ const pageForRender = correctedCurrentPage !== inst.currentPage ? correctedCurrentPage : inst.currentPage;
211
+ this.pageBoundsCorrection.emit(correctedCurrentPage);
212
+ this.pages$.set(this._createPageArray(pageForRender, inst.itemsPerPage, inst.totalItems, this.maxSize));
213
+ }
214
+ _schedulePageLinksUpdate() {
215
+ if (this._pageLinksUpdateQueued) {
216
+ return;
210
217
  }
218
+ this._pageLinksUpdateQueued = true;
219
+ afterNextRender(() => {
220
+ this._pageLinksUpdateQueued = false;
221
+ this._updatePageLinks();
222
+ }, { injector: this._injector });
211
223
  }
212
224
  _outOfBoundCorrection(instance) {
213
225
  const totalPages = Math.ceil(instance.totalItems / instance.itemsPerPage);
@@ -271,10 +283,10 @@ class CmatPaginationDirective {
271
283
  return i;
272
284
  }
273
285
  }
274
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
275
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.7", type: CmatPaginationDirective, isStandalone: true, selector: "pagination-template,[pagination-template]", inputs: { id: "id", maxSize: "maxSize" }, outputs: { pageChange: "pageChange", pageBoundsCorrection: "pageBoundsCorrection", perPageCountChange: "perPageCountChange" }, exportAs: ["paginationApi"], usesOnChanges: true, ngImport: i0 }); }
286
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
287
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: CmatPaginationDirective, isStandalone: true, selector: "pagination-template,[pagination-template]", inputs: { id: "id", maxSize: "maxSize" }, outputs: { pageChange: "pageChange", pageBoundsCorrection: "pageBoundsCorrection", perPageCountChange: "perPageCountChange" }, exportAs: ["paginationApi"], usesOnChanges: true, ngImport: i0 }); }
276
288
  }
277
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationDirective, decorators: [{
289
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationDirective, decorators: [{
278
290
  type: Directive,
279
291
  args: [{
280
292
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -301,10 +313,10 @@ class CmatPaginationComponent {
301
313
  this.maxSize = 7;
302
314
  this.itemsPerPages = [10, 20, 30];
303
315
  this.initPerPage = 10;
316
+ this.isScreenSmall = signal(false, ...(ngDevMode ? [{ debugName: "isScreenSmall" }] : /* istanbul ignore next */ []));
304
317
  this._cmatMediaWatcherService = inject(CmatMediaWatcherService);
305
- this._changeDetectorRef = inject(ChangeDetectorRef);
318
+ this._destroyRef = inject(DestroyRef);
306
319
  this._autoHide = false;
307
- this._unsubscribeAll = new Subject();
308
320
  }
309
321
  get autoHide() {
310
322
  return this._autoHide;
@@ -314,18 +326,17 @@ class CmatPaginationComponent {
314
326
  }
315
327
  ngOnInit() {
316
328
  this._cmatMediaWatcherService.onMediaChange$
317
- .pipe(takeUntil(this._unsubscribeAll))
329
+ .pipe(takeUntilDestroyed(this._destroyRef))
318
330
  .subscribe(({ matchingAliases }) => {
319
- this.isScreenSmall = !matchingAliases.includes('md');
320
- this._changeDetectorRef.markForCheck();
331
+ this.isScreenSmall.set(!matchingAliases.includes('md'));
321
332
  });
322
333
  }
323
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
324
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.7", type: CmatPaginationComponent, isStandalone: true, selector: "cmat-pagination", inputs: { id: "id", maxSize: "maxSize", itemsPerPages: "itemsPerPages", initPerPage: "initPerPage", autoHide: "autoHide" }, outputs: { pageChange: "pageChange", pageBoundsCorrection: "pageBoundsCorrection", perPageCountChange: "perPageCountChange" }, exportAs: ["cmatPagination"], ngImport: i0, template: "<pagination-template #p=\"paginationApi\" class=\"w-full px-4 py-2 flex\" [id]=\"id\"\r\n [maxSize]=\"isScreenSmall&&maxSize>5?5:maxSize\" (pageChange)=\"pageChange.emit($event)\"\r\n (pageBoundsCorrection)=\"pageBoundsCorrection.emit($event)\" (perPageCountChange)=\"perPageCountChange.emit($event)\">\r\n <div class=\"hidden md:flex flex-auto items-center\">\r\n <span>\u603B\u8BA1:{{p.getTotalItems()}}</span>\r\n </div>\r\n <nav role=\"navigation\" class=\"flex min-h-12 w-full md:w-0\">\r\n @if (!(autoHide && p.pages.length <= 1)) {\r\n <ul\r\n class=\"flex flex-row items-center justify-center md:justify-end w-full\">\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.goFirstPage()\">\r\n <mat-icon svgIcon=\"mat_outline:first_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"pr-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.previous()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_before\"></mat-icon>\r\n </button>\r\n </li>\r\n <div class=\"flex flex-row gap-4\">\r\n @for (page of p.pages; track $index) {\r\n <li class=\"flex text-xl lg:text-2xl\">\r\n @if (p.getCurrent() !== page.value) {\r\n <a tabindex=\"0\" role=\"presentation\"\r\n class=\"cursor-pointer text-gray-400 hover:text-current\" (click)=\"p.setCurrent(page.value)\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </a>\r\n }\r\n @if (p.getCurrent() === page.value) {\r\n <span class=\"text-current\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </span>\r\n }\r\n </li>\r\n }\r\n </div> \r\n <li class=\"pl-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.next()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_next\"></mat-icon>\r\n </button>\r\n </li>\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.goLastPage()\">\r\n <mat-icon svgIcon=\"mat_outline:last_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"hidden md:block px-2\">\r\n <mat-form-field [ngStyle]=\"{'width':((p.getLastPage()?.toString()?.length||0)*8+64)+'px'}\">\r\n <input #current matInput type=\"text\" cmatDigitOnly class=\"text-end\"\r\n [value]=\"p.getCurrent()\" [autocomplete]=\"'off'\" [min]=\"0\" [max]=\"p.getLastPage()||0\"\r\n (keyup.enter)=\"p.setCurrent(current.value)\">\r\n <span matSuffix>/<div class=\"pl-1\">{{p.getLastPage()}}</div></span>\r\n </mat-form-field>\r\n </li>\r\n <li class=\"hidden md:block\">\r\n <mat-form-field class=\"w-24\">\r\n <mat-select #pageCount name=\"pageCount\" [value]=\"initPerPage\"\r\n (selectionChange)=\"p.setItemsPerPage(pageCount.value)\">\r\n @for (perPage of itemsPerPages; track perPage) {\r\n <mat-option [value]=\"perPage\">\r\n {{perPage}}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n </mat-form-field>\r\n </li>\r\n </ul>\r\n }\r\n </nav>\r\n </pagination-template>", dependencies: [{ kind: "directive", type: CmatPaginationDirective, selector: "pagination-template,[pagination-template]", inputs: ["id", "maxSize"], outputs: ["pageChange", "pageBoundsCorrection", "perPageCountChange"], exportAs: ["paginationApi"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: CmatDigitOnlyDirective, selector: "[cmatDigitOnly]", inputs: ["decimal", "decimalSeparator", "allowNegatives", "allowPaste", "negativeSign", "min", "max", "pattern"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
334
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
335
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: CmatPaginationComponent, isStandalone: true, selector: "cmat-pagination", inputs: { id: "id", maxSize: "maxSize", itemsPerPages: "itemsPerPages", initPerPage: "initPerPage", autoHide: "autoHide" }, outputs: { pageChange: "pageChange", pageBoundsCorrection: "pageBoundsCorrection", perPageCountChange: "perPageCountChange" }, exportAs: ["cmatPagination"], ngImport: i0, template: "<pagination-template #p=\"paginationApi\" class=\"w-full px-4 py-2 flex\" [id]=\"id\"\r\n [maxSize]=\"isScreenSmall()&&maxSize>5?5:maxSize\" (pageChange)=\"pageChange.emit($event)\"\r\n (pageBoundsCorrection)=\"pageBoundsCorrection.emit($event)\" (perPageCountChange)=\"perPageCountChange.emit($event)\">\r\n <div class=\"hidden md:flex flex-auto items-center\">\r\n <span>\u603B\u8BA1:{{p.getTotalItems()}}</span>\r\n </div>\r\n <nav role=\"navigation\" class=\"flex min-h-12 w-full md:w-0\">\r\n @if (!(autoHide && p.pages$().length <= 1)) {\r\n <ul\r\n class=\"flex flex-row items-center justify-center md:justify-end w-full\">\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.goFirstPage()\">\r\n <mat-icon svgIcon=\"mat_outline:first_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"pr-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.previous()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_before\"></mat-icon>\r\n </button>\r\n </li>\r\n <div class=\"flex flex-row gap-4\">\r\n @for (page of p.pages$(); track $index) {\r\n <li class=\"flex text-xl lg:text-2xl\">\r\n @if (p.getCurrent() !== page.value) {\r\n <a tabindex=\"0\" role=\"presentation\"\r\n class=\"cursor-pointer text-gray-400 hover:text-current\" (click)=\"p.setCurrent(page.value)\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </a>\r\n }\r\n @if (p.getCurrent() === page.value) {\r\n <span class=\"text-current\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </span>\r\n }\r\n </li>\r\n }\r\n </div> \r\n <li class=\"pl-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.next()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_next\"></mat-icon>\r\n </button>\r\n </li>\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.goLastPage()\">\r\n <mat-icon svgIcon=\"mat_outline:last_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"hidden md:block px-2\">\r\n <mat-form-field [ngStyle]=\"{'width':((p.getLastPage()?.toString()?.length||0)*8+64)+'px'}\">\r\n <input #current matInput type=\"text\" cmatDigitOnly class=\"text-end\"\r\n [value]=\"p.getCurrent()\" [autocomplete]=\"'off'\" [min]=\"0\" [max]=\"p.getLastPage()||0\"\r\n (keyup.enter)=\"p.setCurrent(current.value)\">\r\n <span matSuffix>/<div class=\"pl-1\">{{p.getLastPage()}}</div></span>\r\n </mat-form-field>\r\n </li>\r\n <li class=\"hidden md:block\">\r\n <mat-form-field class=\"w-24\">\r\n <mat-select #pageCount name=\"pageCount\" [value]=\"initPerPage\"\r\n (selectionChange)=\"p.setItemsPerPage(pageCount.value)\">\r\n @for (perPage of itemsPerPages; track perPage) {\r\n <mat-option [value]=\"perPage\">\r\n {{perPage}}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n </mat-form-field>\r\n </li>\r\n </ul>\r\n }\r\n </nav>\r\n </pagination-template>\r\n", dependencies: [{ kind: "directive", type: CmatPaginationDirective, selector: "pagination-template,[pagination-template]", inputs: ["id", "maxSize"], outputs: ["pageChange", "pageBoundsCorrection", "perPageCountChange"], exportAs: ["paginationApi"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: CmatDigitOnlyDirective, selector: "[cmatDigitOnly]", inputs: ["decimal", "decimalSeparator", "allowNegatives", "allowPaste", "negativeSign", "min", "max", "pattern"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
325
336
  }
326
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginationComponent, decorators: [{
337
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginationComponent, decorators: [{
327
338
  type: Component,
328
- args: [{ selector: 'cmat-pagination', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cmatPagination', imports: [CmatPaginationDirective, MatIconModule, NgStyle, MatFormFieldModule, MatInputModule, CmatDigitOnlyDirective, MatSelectModule, DecimalPipe, MatButtonModule], template: "<pagination-template #p=\"paginationApi\" class=\"w-full px-4 py-2 flex\" [id]=\"id\"\r\n [maxSize]=\"isScreenSmall&&maxSize>5?5:maxSize\" (pageChange)=\"pageChange.emit($event)\"\r\n (pageBoundsCorrection)=\"pageBoundsCorrection.emit($event)\" (perPageCountChange)=\"perPageCountChange.emit($event)\">\r\n <div class=\"hidden md:flex flex-auto items-center\">\r\n <span>\u603B\u8BA1:{{p.getTotalItems()}}</span>\r\n </div>\r\n <nav role=\"navigation\" class=\"flex min-h-12 w-full md:w-0\">\r\n @if (!(autoHide && p.pages.length <= 1)) {\r\n <ul\r\n class=\"flex flex-row items-center justify-center md:justify-end w-full\">\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.goFirstPage()\">\r\n <mat-icon svgIcon=\"mat_outline:first_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"pr-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.previous()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_before\"></mat-icon>\r\n </button>\r\n </li>\r\n <div class=\"flex flex-row gap-4\">\r\n @for (page of p.pages; track $index) {\r\n <li class=\"flex text-xl lg:text-2xl\">\r\n @if (p.getCurrent() !== page.value) {\r\n <a tabindex=\"0\" role=\"presentation\"\r\n class=\"cursor-pointer text-gray-400 hover:text-current\" (click)=\"p.setCurrent(page.value)\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </a>\r\n }\r\n @if (p.getCurrent() === page.value) {\r\n <span class=\"text-current\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </span>\r\n }\r\n </li>\r\n }\r\n </div> \r\n <li class=\"pl-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.next()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_next\"></mat-icon>\r\n </button>\r\n </li>\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.goLastPage()\">\r\n <mat-icon svgIcon=\"mat_outline:last_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"hidden md:block px-2\">\r\n <mat-form-field [ngStyle]=\"{'width':((p.getLastPage()?.toString()?.length||0)*8+64)+'px'}\">\r\n <input #current matInput type=\"text\" cmatDigitOnly class=\"text-end\"\r\n [value]=\"p.getCurrent()\" [autocomplete]=\"'off'\" [min]=\"0\" [max]=\"p.getLastPage()||0\"\r\n (keyup.enter)=\"p.setCurrent(current.value)\">\r\n <span matSuffix>/<div class=\"pl-1\">{{p.getLastPage()}}</div></span>\r\n </mat-form-field>\r\n </li>\r\n <li class=\"hidden md:block\">\r\n <mat-form-field class=\"w-24\">\r\n <mat-select #pageCount name=\"pageCount\" [value]=\"initPerPage\"\r\n (selectionChange)=\"p.setItemsPerPage(pageCount.value)\">\r\n @for (perPage of itemsPerPages; track perPage) {\r\n <mat-option [value]=\"perPage\">\r\n {{perPage}}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n </mat-form-field>\r\n </li>\r\n </ul>\r\n }\r\n </nav>\r\n </pagination-template>" }]
339
+ args: [{ selector: 'cmat-pagination', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cmatPagination', imports: [CmatPaginationDirective, MatIconModule, NgStyle, MatFormFieldModule, MatInputModule, CmatDigitOnlyDirective, MatSelectModule, DecimalPipe, MatButtonModule], template: "<pagination-template #p=\"paginationApi\" class=\"w-full px-4 py-2 flex\" [id]=\"id\"\r\n [maxSize]=\"isScreenSmall()&&maxSize>5?5:maxSize\" (pageChange)=\"pageChange.emit($event)\"\r\n (pageBoundsCorrection)=\"pageBoundsCorrection.emit($event)\" (perPageCountChange)=\"perPageCountChange.emit($event)\">\r\n <div class=\"hidden md:flex flex-auto items-center\">\r\n <span>\u603B\u8BA1:{{p.getTotalItems()}}</span>\r\n </div>\r\n <nav role=\"navigation\" class=\"flex min-h-12 w-full md:w-0\">\r\n @if (!(autoHide && p.pages$().length <= 1)) {\r\n <ul\r\n class=\"flex flex-row items-center justify-center md:justify-end w-full\">\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.goFirstPage()\">\r\n <mat-icon svgIcon=\"mat_outline:first_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"pr-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===1\"\r\n (click)=\"p.previous()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_before\"></mat-icon>\r\n </button>\r\n </li>\r\n <div class=\"flex flex-row gap-4\">\r\n @for (page of p.pages$(); track $index) {\r\n <li class=\"flex text-xl lg:text-2xl\">\r\n @if (p.getCurrent() !== page.value) {\r\n <a tabindex=\"0\" role=\"presentation\"\r\n class=\"cursor-pointer text-gray-400 hover:text-current\" (click)=\"p.setCurrent(page.value)\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </a>\r\n }\r\n @if (p.getCurrent() === page.value) {\r\n <span class=\"text-current\">\r\n <span>{{ (page.label === '...') ? page.label : (page.label | number:'') }}</span>\r\n </span>\r\n }\r\n </li>\r\n }\r\n </div> \r\n <li class=\"pl-4\">\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.next()\">\r\n <mat-icon svgIcon=\"mat_outline:navigate_next\"></mat-icon>\r\n </button>\r\n </li>\r\n <li>\r\n <button type=\"button\" class=\"flex items-center\" matIconButton [disabled]=\"p.getCurrent()===p.getLastPage()\"\r\n (click)=\"p.goLastPage()\">\r\n <mat-icon svgIcon=\"mat_outline:last_page\"></mat-icon>\r\n </button>\r\n </li>\r\n <li class=\"hidden md:block px-2\">\r\n <mat-form-field [ngStyle]=\"{'width':((p.getLastPage()?.toString()?.length||0)*8+64)+'px'}\">\r\n <input #current matInput type=\"text\" cmatDigitOnly class=\"text-end\"\r\n [value]=\"p.getCurrent()\" [autocomplete]=\"'off'\" [min]=\"0\" [max]=\"p.getLastPage()||0\"\r\n (keyup.enter)=\"p.setCurrent(current.value)\">\r\n <span matSuffix>/<div class=\"pl-1\">{{p.getLastPage()}}</div></span>\r\n </mat-form-field>\r\n </li>\r\n <li class=\"hidden md:block\">\r\n <mat-form-field class=\"w-24\">\r\n <mat-select #pageCount name=\"pageCount\" [value]=\"initPerPage\"\r\n (selectionChange)=\"p.setItemsPerPage(pageCount.value)\">\r\n @for (perPage of itemsPerPages; track perPage) {\r\n <mat-option [value]=\"perPage\">\r\n {{perPage}}\r\n </mat-option>\r\n }\r\n </mat-select>\r\n </mat-form-field>\r\n </li>\r\n </ul>\r\n }\r\n </nav>\r\n </pagination-template>\r\n" }]
329
340
  }], propDecorators: { pageChange: [{
330
341
  type: Output
331
342
  }], pageBoundsCorrection: [{
@@ -351,64 +362,55 @@ class CmatPaginatePipe {
351
362
  this.state = {};
352
363
  }
353
364
  transform(collection, args) {
354
- if (!(collection instanceof Array)) {
365
+ if (!Array.isArray(collection)) {
355
366
  const _id = args.id ?? this.service.defaultId();
356
- if (this.state[_id]) {
357
- return this.state[_id].slice;
358
- }
359
- else {
360
- return collection;
361
- }
367
+ const cachedSlice = this.state[_id]?.slice;
368
+ return cachedSlice ?? collection;
362
369
  }
363
- const serverSideMode = args.totalItems && args.totalItems !== collection.length;
364
- const instance = this.createInstance(collection, args);
365
- const id = instance.id;
370
+ const totalItems = this._toNumber(args.totalItems) || collection.length;
371
+ const serverSideMode = totalItems !== collection.length;
372
+ const instance = this.createInstance(collection, { ...args, totalItems });
373
+ const id = instance.id ?? this.service.defaultId();
366
374
  let start;
367
375
  let end;
368
- let perPage = args.itemsPerPage;
376
+ const perPage = this._toNumber(args.itemsPerPage);
369
377
  const emitChange = this.service.register(instance);
370
- if (!serverSideMode && collection instanceof Array) {
371
- perPage = +perPage || LARGE_NUMBER;
372
- start = (instance.currentPage - 1) * perPage;
373
- end = start + perPage;
378
+ if (!serverSideMode) {
379
+ const pageSize = perPage || LARGE_NUMBER;
380
+ start = (instance.currentPage - 1) * pageSize;
381
+ end = start + pageSize;
374
382
  const isIdentical = this._stateIsIdentical(id, collection, start, end);
375
383
  if (isIdentical) {
376
384
  return this.state[id].slice;
377
385
  }
378
- else {
379
- const slice = collection.slice(start, end);
380
- this._saveState(id, collection, slice, start, end);
381
- this.service.change.emit(id);
382
- return slice;
383
- }
386
+ const slice = collection.slice(start, end);
387
+ this._saveState(id, collection, slice, start, end);
388
+ this.service.notifyChange(id);
389
+ return slice;
384
390
  }
385
- else {
386
- if (emitChange) {
387
- this.service.change.emit(id);
388
- }
389
- this._saveState(id, collection, collection, start, end);
390
- return collection;
391
+ if (emitChange) {
392
+ this.service.notifyChange(id);
391
393
  }
394
+ this._saveState(id, collection, collection, start, end);
395
+ return collection;
392
396
  }
393
397
  createInstance(collection, config) {
394
398
  this.checkConfig(config);
395
399
  return {
396
- id: !isNil(config.id) ? config.id : this.service.defaultId(),
397
- itemsPerPage: +config.itemsPerPage || 10,
398
- currentPage: +config.currentPage || 1,
399
- totalItems: +config.totalItems || collection.length
400
+ id: config.id ?? this.service.defaultId(),
401
+ itemsPerPage: this._toNumber(config.itemsPerPage) || 10,
402
+ currentPage: this._toNumber(config.currentPage) || 1,
403
+ totalItems: this._toNumber(config.totalItems) || collection.length
400
404
  };
401
405
  }
402
406
  checkConfig(config) {
403
- const required = ['itemsPerPage', 'currentPage'];
404
- const missing = required.filter(prop => !(prop in config));
405
- if (0 < missing.length) {
407
+ const missing = ['itemsPerPage', 'currentPage'].filter(prop => !(prop in config));
408
+ if (missing.length > 0) {
406
409
  throw new Error(`PaginatePipe: Argument is missing the following required properties: ${missing.join(', ')}`);
407
410
  }
408
411
  }
409
412
  _saveState(id, collection, slice, start, end) {
410
413
  this.state[id] = {
411
- collection,
412
414
  size: collection.length,
413
415
  slice,
414
416
  start,
@@ -428,10 +430,13 @@ class CmatPaginatePipe {
428
430
  }
429
431
  return state.slice.every((element, index) => element === collection[start + index]);
430
432
  }
431
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
432
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginatePipe, isStandalone: true, name: "paginate" }); }
433
+ _toNumber(value) {
434
+ return Number(value);
435
+ }
436
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
437
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginatePipe, isStandalone: true, name: "paginate" }); }
433
438
  }
434
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImport: i0, type: CmatPaginatePipe, decorators: [{
439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: CmatPaginatePipe, decorators: [{
435
440
  type: Pipe,
436
441
  args: [{
437
442
  name: 'paginate',