cmat 0.0.87 → 0.0.88
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.
- package/fesm2022/cmat-components-adapter.mjs +9 -9
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +98 -80
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +26 -34
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +467 -556
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +270 -259
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +200 -116
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +85 -38
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +841 -0
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-custom-formly.mjs +1395 -838
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +996 -0
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-date-range.mjs +310 -264
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +16 -20
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +120 -137
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +17 -24
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +18 -24
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +30 -39
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +12 -12
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +10 -10
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +48 -41
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +104 -107
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +12 -15
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +118 -75
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +196 -178
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +26 -41
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +81 -80
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +1212 -1287
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +467 -450
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +143 -132
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +68 -83
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +18 -24
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +220 -136
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +262 -215
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +227 -195
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +15 -34
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +95 -88
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +70 -67
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +23 -26
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +190 -159
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +276 -213
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +178 -128
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +44 -28
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +107 -163
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +29 -36
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +14 -18
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +111 -118
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +65 -66
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +130 -160
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +32 -39
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +186 -176
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +25 -28
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +85 -92
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +3 -3
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +49 -50
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +16 -19
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +60 -69
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +31 -30
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +6 -6
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +3 -3
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +3 -3
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +3 -3
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +3 -3
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +3 -3
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +7 -13
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-services-alert.mjs +26 -27
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +14 -23
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +8 -8
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +6 -10
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +3 -3
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +30 -47
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +3 -3
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +43 -34
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +3 -3
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +3 -3
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +11 -11
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +3 -3
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat.mjs +9228 -7507
- package/fesm2022/cmat.mjs.map +1 -1
- package/icons/material-icons/heroicons-outline.svg +3 -0
- package/icons/material-icons/heroicons-solid.svg +3 -0
- package/package.json +10 -1
- package/styles/components/bundle.scss +21 -0
- package/styles/overrides/angular-material.scss +22 -1
- package/tailwind/plugins/theming.js +183 -183
- package/types/cmat-components-breadcrumb.d.ts +40 -37
- package/types/cmat-components-card.d.ts +11 -13
- package/types/cmat-components-carousel.d.ts +87 -113
- package/types/cmat-components-cascade.d.ts +84 -65
- package/types/cmat-components-chip-input.d.ts +29 -24
- package/types/cmat-components-code-editor.d.ts +28 -12
- package/types/cmat-components-color-picker.d.ts +236 -0
- package/types/cmat-components-custom-formly.d.ts +316 -184
- package/types/cmat-components-data-picker.d.ts +372 -0
- package/types/cmat-components-date-range.d.ts +31 -36
- package/types/cmat-components-date-time-display.d.ts +8 -8
- package/types/cmat-components-drawer.d.ts +30 -32
- package/types/cmat-components-empty-state.d.ts +9 -10
- package/types/cmat-components-file-preview.d.ts +9 -9
- package/types/cmat-components-filter-toolbar.d.ts +15 -15
- package/types/cmat-components-form-actions.d.ts +5 -5
- package/types/cmat-components-fullscreen.d.ts +5 -5
- package/types/cmat-components-highlight.d.ts +13 -14
- package/types/cmat-components-image-viewer.d.ts +29 -33
- package/types/cmat-components-inline-loading.d.ts +6 -6
- package/types/cmat-components-json-editor.d.ts +15 -17
- package/types/cmat-components-knob-input.d.ts +58 -55
- package/types/cmat-components-masonry.d.ts +9 -12
- package/types/cmat-components-material-color-picker.d.ts +16 -21
- package/types/cmat-components-material-datetimepicker.d.ts +174 -216
- package/types/cmat-components-navigation.d.ts +34 -39
- package/types/cmat-components-opt-input.d.ts +35 -33
- package/types/cmat-components-org-chart.d.ts +8 -9
- package/types/cmat-components-page-header.d.ts +9 -9
- package/types/cmat-components-pagination.d.ts +36 -40
- package/types/cmat-components-password-strength.d.ts +58 -64
- package/types/cmat-components-popover.d.ts +22 -32
- package/types/cmat-components-progress-bar.d.ts +7 -10
- package/types/cmat-components-qrcode.d.ts +22 -22
- package/types/cmat-components-rating.d.ts +17 -19
- package/types/cmat-components-rich-text-editor.d.ts +11 -12
- package/types/cmat-components-select-search.d.ts +48 -36
- package/types/cmat-components-select-table.d.ts +38 -34
- package/types/cmat-components-select-tree.d.ts +17 -15
- package/types/cmat-components-skeleton.d.ts +27 -10
- package/types/cmat-components-speed-dial.d.ts +24 -33
- package/types/cmat-components-status-tag.d.ts +19 -9
- package/types/cmat-components-table-toolbar.d.ts +7 -7
- package/types/cmat-components-timeline.d.ts +33 -34
- package/types/cmat-components-toast.d.ts +26 -30
- package/types/cmat-components-transfer-picker.d.ts +51 -56
- package/types/cmat-components-treetable.d.ts +12 -13
- package/types/cmat-components-upload.d.ts +33 -38
- package/types/cmat-components-x6-angular-shape.d.ts +1 -1
- package/types/cmat-directives-animate-on-scroll.d.ts +7 -7
- package/types/cmat-directives-arrow-cursor.d.ts +18 -20
- package/types/cmat-directives-data-exporter.d.ts +10 -10
- package/types/cmat-directives-debounce.d.ts +5 -5
- package/types/cmat-directives-digit-only.d.ts +13 -13
- package/types/cmat-directives-seamless-auto-scroll.d.ts +7 -7
- package/types/cmat-pipes-secure.d.ts +1 -3
- package/types/cmat-services-alert.d.ts +11 -12
- package/types/cmat-services-config.d.ts +2 -7
- package/types/cmat-services-confirmation.d.ts +2 -2
- package/types/cmat-services-data.d.ts +0 -1
- package/types/cmat-services-loading.d.ts +14 -22
- package/types/cmat-services-media-watcher.d.ts +5 -5
- package/types/cmat-services-translation.d.ts +4 -5
- package/types/cmat.d.ts +2167 -1746
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { NgStyle, DecimalPipe } from '@angular/common';
|
|
1
|
+
import { NgStyle, NgClass, DecimalPipe } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Injectable,
|
|
4
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { signal, untracked, Injectable, input, output, inject, Injector, effect, afterNextRender, Directive, ElementRef, DestroyRef, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, Pipe } from '@angular/core';
|
|
5
4
|
import * as i5 from '@angular/material/button';
|
|
6
5
|
import { MatButtonModule } from '@angular/material/button';
|
|
7
6
|
import * as i2 from '@angular/material/form-field';
|
|
@@ -13,90 +12,153 @@ import { MatInputModule } from '@angular/material/input';
|
|
|
13
12
|
import * as i4 from '@angular/material/select';
|
|
14
13
|
import { MatSelectModule } from '@angular/material/select';
|
|
15
14
|
import { CmatDigitOnlyDirective } from 'cmat/directives/digit-only';
|
|
16
|
-
import { CmatMediaWatcherService } from 'cmat/services/media-watcher';
|
|
17
|
-
import { Subject } from 'rxjs';
|
|
18
15
|
|
|
19
16
|
class CmatPaginationService {
|
|
20
17
|
constructor() {
|
|
21
|
-
this.
|
|
22
|
-
|
|
18
|
+
this._instances = signal({}, /* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [{ debugName: "_instances" }] : /* istanbul ignore next */ []));
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
21
|
+
this.instances = this._instances.asReadonly();
|
|
23
22
|
this._defaultPaginationId = 'DEFAULT_PAGINATION_ID';
|
|
24
23
|
}
|
|
25
|
-
get change$() {
|
|
26
|
-
return this._change.asObservable();
|
|
27
|
-
}
|
|
28
24
|
defaultId() { return this._defaultPaginationId; }
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
notifyChange(_id) {
|
|
27
|
+
// 使用 requestAnimationFrame 延迟 Signal 更新,避免在模板渲染周期中写入
|
|
28
|
+
requestAnimationFrame(() => {
|
|
29
|
+
this._instances.update(current => ({ ...current }));
|
|
30
|
+
});
|
|
31
31
|
}
|
|
32
|
-
register(instance) {
|
|
32
|
+
register(instance, fromPipe = false) {
|
|
33
33
|
const normalizedInstance = {
|
|
34
34
|
...structuredClone(instance),
|
|
35
35
|
id: instance.id ?? this._defaultPaginationId
|
|
36
36
|
};
|
|
37
37
|
const id = normalizedInstance.id;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
let changed = false;
|
|
39
|
+
const currentInstances = untracked(() => this._instances());
|
|
40
|
+
if (!currentInstances[id]) {
|
|
41
|
+
changed = true;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const needsUpdate = this._needsUpdate(currentInstances[id], normalizedInstance);
|
|
45
|
+
if (needsUpdate) {
|
|
46
|
+
changed = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (changed) {
|
|
50
|
+
if (fromPipe) {
|
|
51
|
+
requestAnimationFrame(() => {
|
|
52
|
+
this._instances.update((current) => {
|
|
53
|
+
if (!current[id]) {
|
|
54
|
+
return { ...current, [id]: normalizedInstance };
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this._updateInstance(current[id], normalizedInstance);
|
|
58
|
+
return { ...current };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this._instances.update((current) => {
|
|
65
|
+
if (!current[id]) {
|
|
66
|
+
return { ...current, [id]: normalizedInstance };
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this._updateInstance(current[id], normalizedInstance);
|
|
70
|
+
return { ...current };
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
41
74
|
}
|
|
42
|
-
return
|
|
75
|
+
return changed;
|
|
43
76
|
}
|
|
44
77
|
getCurrentPage(id) {
|
|
45
|
-
return this._instances[id]?.currentPage;
|
|
78
|
+
return this._instances()[id]?.currentPage;
|
|
46
79
|
}
|
|
47
80
|
getItemsPerPage(id) {
|
|
48
|
-
return this._instances[id]?.itemsPerPage;
|
|
81
|
+
return this._instances()[id]?.itemsPerPage;
|
|
49
82
|
}
|
|
50
83
|
setCurrentPage(id, page) {
|
|
51
|
-
|
|
52
|
-
const instance =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
84
|
+
this._instances.update((current) => {
|
|
85
|
+
const instance = current[id];
|
|
86
|
+
if (instance) {
|
|
87
|
+
const maxPage = Math.ceil(instance.totalItems / instance.itemsPerPage);
|
|
88
|
+
if (page <= maxPage && 1 <= page) {
|
|
89
|
+
// 创建新引用以确保 Signal 检测到变化
|
|
90
|
+
current[id] = { ...instance, currentPage: page };
|
|
91
|
+
return { ...current };
|
|
92
|
+
}
|
|
57
93
|
}
|
|
58
|
-
|
|
94
|
+
return current;
|
|
95
|
+
});
|
|
96
|
+
// 通知分页器更新显示
|
|
97
|
+
this.notifyChange(id);
|
|
59
98
|
}
|
|
60
99
|
setTotalItems(id, totalItems) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
100
|
+
this._instances.update((current) => {
|
|
101
|
+
const instance = current[id];
|
|
102
|
+
if (instance && 0 <= totalItems) {
|
|
103
|
+
current[id] = { ...instance, totalItems };
|
|
104
|
+
return { ...current };
|
|
105
|
+
}
|
|
106
|
+
return current;
|
|
107
|
+
});
|
|
108
|
+
// 通知分页器更新显示
|
|
109
|
+
this.notifyChange(id);
|
|
65
110
|
}
|
|
66
111
|
setItemsPerPage(id, itemsPerPage) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
112
|
+
this._instances.update((current) => {
|
|
113
|
+
const instance = current[id];
|
|
114
|
+
if (instance) {
|
|
115
|
+
current[id] = { ...instance, itemsPerPage };
|
|
116
|
+
return { ...current };
|
|
117
|
+
}
|
|
118
|
+
return current;
|
|
119
|
+
});
|
|
120
|
+
// 通知分页器更新显示
|
|
121
|
+
this.notifyChange(id);
|
|
71
122
|
}
|
|
72
123
|
getInstance(id = this._defaultPaginationId) {
|
|
73
|
-
|
|
74
|
-
|
|
124
|
+
const instance = this._instances()[id];
|
|
125
|
+
if (instance) {
|
|
126
|
+
return this._clone(instance);
|
|
75
127
|
}
|
|
76
128
|
return undefined;
|
|
77
129
|
}
|
|
78
|
-
_updateInstance(
|
|
130
|
+
_updateInstance(current, incoming) {
|
|
79
131
|
let changed = false;
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
const keys = new Set([...Object.keys(currentInstance), ...Object.keys(instance)]);
|
|
132
|
+
if (incoming.id) {
|
|
133
|
+
const keys = new Set([...Object.keys(current), ...Object.keys(incoming)]);
|
|
83
134
|
for (const prop of keys) {
|
|
84
135
|
const key = prop;
|
|
85
|
-
if (
|
|
86
|
-
|
|
136
|
+
if (incoming[key] !== current[key]) {
|
|
137
|
+
current[key] = incoming[key];
|
|
87
138
|
changed = true;
|
|
88
139
|
}
|
|
89
140
|
}
|
|
90
141
|
}
|
|
91
142
|
return changed;
|
|
92
143
|
}
|
|
144
|
+
_needsUpdate(current, incoming) {
|
|
145
|
+
// 检查是否有任何属性发生变化
|
|
146
|
+
const keys = new Set([...Object.keys(current), ...Object.keys(incoming)]);
|
|
147
|
+
for (const prop of keys) {
|
|
148
|
+
const key = prop;
|
|
149
|
+
if (incoming[key] !== current[key]) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
93
155
|
_clone(obj) {
|
|
94
156
|
return structuredClone(obj);
|
|
95
157
|
}
|
|
96
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
97
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
158
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
159
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationService, providedIn: 'root' }); }
|
|
98
160
|
}
|
|
99
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationService, decorators: [{
|
|
100
162
|
type: Injectable,
|
|
101
163
|
args: [{
|
|
102
164
|
providedIn: 'root'
|
|
@@ -105,27 +167,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
|
|
|
105
167
|
|
|
106
168
|
class CmatPaginationDirective {
|
|
107
169
|
constructor() {
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
this.
|
|
170
|
+
this.id = input(/* @ts-ignore */
|
|
171
|
+
...(ngDevMode ? [undefined, { debugName: "id" }] : /* istanbul ignore next */ []));
|
|
172
|
+
this.maxSize = input(7, /* @ts-ignore */
|
|
173
|
+
...(ngDevMode ? [{ debugName: "maxSize" }] : /* istanbul ignore next */ []));
|
|
174
|
+
this.pageChange = output();
|
|
175
|
+
this.pageBoundsCorrection = output();
|
|
176
|
+
this.perPageCountChange = output();
|
|
177
|
+
this.pages = signal([], /* @ts-ignore */
|
|
178
|
+
...(ngDevMode ? [{ debugName: "pages" }] : /* istanbul ignore next */ []));
|
|
113
179
|
this.service = inject(CmatPaginationService);
|
|
114
180
|
this._injector = inject(Injector);
|
|
115
|
-
this._destroyRef = inject(DestroyRef);
|
|
116
181
|
this._pageLinksUpdateQueued = false;
|
|
117
|
-
|
|
118
|
-
.
|
|
119
|
-
if (this.
|
|
120
|
-
|
|
182
|
+
effect(() => {
|
|
183
|
+
const instances = this.service.instances();
|
|
184
|
+
if (this._getId() === instances[this._getId()]?.id) {
|
|
185
|
+
untracked(() => {
|
|
186
|
+
this._schedulePageLinksUpdate();
|
|
187
|
+
});
|
|
121
188
|
}
|
|
122
189
|
});
|
|
123
|
-
}
|
|
124
|
-
ngOnInit() {
|
|
125
|
-
this.id ??= this.service.defaultId();
|
|
126
|
-
this._schedulePageLinksUpdate();
|
|
127
|
-
}
|
|
128
|
-
ngOnChanges() {
|
|
129
190
|
this._schedulePageLinksUpdate();
|
|
130
191
|
}
|
|
131
192
|
previous() {
|
|
@@ -171,10 +232,10 @@ class CmatPaginationDirective {
|
|
|
171
232
|
}
|
|
172
233
|
}
|
|
173
234
|
getCurrent() {
|
|
174
|
-
return this.service.getCurrentPage(this.
|
|
235
|
+
return this.service.getCurrentPage(this._getId());
|
|
175
236
|
}
|
|
176
237
|
getLastPage() {
|
|
177
|
-
const inst = this.service.getInstance(this.
|
|
238
|
+
const inst = this.service.getInstance(this._getId());
|
|
178
239
|
if (!inst) {
|
|
179
240
|
return;
|
|
180
241
|
}
|
|
@@ -184,32 +245,39 @@ class CmatPaginationDirective {
|
|
|
184
245
|
return Math.ceil(inst.totalItems / inst.itemsPerPage);
|
|
185
246
|
}
|
|
186
247
|
getTotalItems() {
|
|
187
|
-
return this.service.getInstance(this.
|
|
248
|
+
return this.service.getInstance(this._getId())?.totalItems;
|
|
188
249
|
}
|
|
189
250
|
setItemsPerPage(count) {
|
|
190
|
-
this.
|
|
251
|
+
const id = this._getId();
|
|
252
|
+
this.service.setItemsPerPage(id, count);
|
|
191
253
|
this.perPageCountChange.emit(count);
|
|
192
|
-
const inst = this.service.getInstance(
|
|
254
|
+
const inst = this.service.getInstance(id);
|
|
193
255
|
if (!inst) {
|
|
194
256
|
return;
|
|
195
257
|
}
|
|
196
258
|
this.setCurrent(this._outOfBoundCorrection(inst));
|
|
197
259
|
}
|
|
260
|
+
_getId() {
|
|
261
|
+
return this.id() ?? this.service.defaultId();
|
|
262
|
+
}
|
|
198
263
|
_checkValidId() {
|
|
199
|
-
|
|
200
|
-
|
|
264
|
+
const id = this._getId();
|
|
265
|
+
if (this.service.getInstance(id)?.id == null) {
|
|
266
|
+
console.warn(`PaginationControlsDirective: the specified id "${id}" does not match any registered PaginationInstance`);
|
|
201
267
|
}
|
|
202
268
|
}
|
|
203
269
|
_updatePageLinks() {
|
|
204
|
-
const inst = this.service.getInstance(this.
|
|
270
|
+
const inst = this.service.getInstance(this._getId());
|
|
205
271
|
if (!inst) {
|
|
206
|
-
this.pages
|
|
272
|
+
this.pages.set([]);
|
|
207
273
|
return;
|
|
208
274
|
}
|
|
209
275
|
const correctedCurrentPage = this._outOfBoundCorrection(inst);
|
|
210
|
-
const pageForRender = correctedCurrentPage !== inst.currentPage
|
|
276
|
+
const pageForRender = correctedCurrentPage !== inst.currentPage
|
|
277
|
+
? correctedCurrentPage
|
|
278
|
+
: inst.currentPage;
|
|
211
279
|
this.pageBoundsCorrection.emit(correctedCurrentPage);
|
|
212
|
-
this.pages
|
|
280
|
+
this.pages.set(this._createPageArray(pageForRender, inst.itemsPerPage, inst.totalItems, this.maxSize()));
|
|
213
281
|
}
|
|
214
282
|
_schedulePageLinksUpdate() {
|
|
215
283
|
if (this._pageLinksUpdateQueued) {
|
|
@@ -244,8 +312,8 @@ class CmatPaginationDirective {
|
|
|
244
312
|
while (i <= totalPages && i <= paginationRange) {
|
|
245
313
|
let label;
|
|
246
314
|
const pageNumber = this._calculatePageNumber(i, currentPage, paginationRange, totalPages);
|
|
247
|
-
const openingEllipsesNeeded =
|
|
248
|
-
const closingEllipsesNeeded =
|
|
315
|
+
const openingEllipsesNeeded = i === 2 && (isMiddle || isEnd);
|
|
316
|
+
const closingEllipsesNeeded = i === paginationRange - 1 && (isMiddle || isStart);
|
|
249
317
|
if (ellipsesNeeded && (openingEllipsesNeeded || closingEllipsesNeeded)) {
|
|
250
318
|
label = '...';
|
|
251
319
|
}
|
|
@@ -254,7 +322,7 @@ class CmatPaginationDirective {
|
|
|
254
322
|
}
|
|
255
323
|
pages.push({
|
|
256
324
|
label: label,
|
|
257
|
-
value: pageNumber
|
|
325
|
+
value: pageNumber,
|
|
258
326
|
});
|
|
259
327
|
i++;
|
|
260
328
|
}
|
|
@@ -283,77 +351,93 @@ class CmatPaginationDirective {
|
|
|
283
351
|
return i;
|
|
284
352
|
}
|
|
285
353
|
}
|
|
286
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
287
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
354
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
355
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", type: CmatPaginationDirective, isStandalone: true, selector: "pagination-template,[pagination-template]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, maxSize: { classPropertyName: "maxSize", publicName: "maxSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageChange: "pageChange", pageBoundsCorrection: "pageBoundsCorrection", perPageCountChange: "perPageCountChange" }, exportAs: ["paginationApi"], ngImport: i0 }); }
|
|
288
356
|
}
|
|
289
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
357
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationDirective, decorators: [{
|
|
290
358
|
type: Directive,
|
|
291
359
|
args: [{
|
|
292
360
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
293
361
|
selector: 'pagination-template,[pagination-template]',
|
|
294
|
-
exportAs: 'paginationApi'
|
|
362
|
+
exportAs: 'paginationApi',
|
|
295
363
|
}]
|
|
296
|
-
}], ctorParameters: () => [], propDecorators: { id: [{
|
|
297
|
-
type: Input
|
|
298
|
-
}], maxSize: [{
|
|
299
|
-
type: Input
|
|
300
|
-
}], pageChange: [{
|
|
301
|
-
type: Output
|
|
302
|
-
}], pageBoundsCorrection: [{
|
|
303
|
-
type: Output
|
|
304
|
-
}], perPageCountChange: [{
|
|
305
|
-
type: Output
|
|
306
|
-
}] } });
|
|
364
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], maxSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSize", required: false }] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], pageBoundsCorrection: [{ type: i0.Output, args: ["pageBoundsCorrection"] }], perPageCountChange: [{ type: i0.Output, args: ["perPageCountChange"] }] } });
|
|
307
365
|
|
|
308
366
|
class CmatPaginationComponent {
|
|
309
367
|
constructor() {
|
|
310
|
-
this.
|
|
311
|
-
|
|
312
|
-
this.
|
|
313
|
-
|
|
314
|
-
this.itemsPerPages = [10, 20, 30]
|
|
315
|
-
|
|
316
|
-
this.
|
|
317
|
-
|
|
368
|
+
this.id = input(/* @ts-ignore */
|
|
369
|
+
...(ngDevMode ? [undefined, { debugName: "id" }] : /* istanbul ignore next */ []));
|
|
370
|
+
this.maxSize = input(7, /* @ts-ignore */
|
|
371
|
+
...(ngDevMode ? [{ debugName: "maxSize" }] : /* istanbul ignore next */ []));
|
|
372
|
+
this.itemsPerPages = input([10, 20, 30], /* @ts-ignore */
|
|
373
|
+
...(ngDevMode ? [{ debugName: "itemsPerPages" }] : /* istanbul ignore next */ []));
|
|
374
|
+
this.initPerPage = input(10, /* @ts-ignore */
|
|
375
|
+
...(ngDevMode ? [{ debugName: "initPerPage" }] : /* istanbul ignore next */ []));
|
|
376
|
+
this.autoHide = input(false, /* @ts-ignore */
|
|
377
|
+
...(ngDevMode ? [{ debugName: "autoHide" }] : /* istanbul ignore next */ []));
|
|
378
|
+
this.pageChange = output();
|
|
379
|
+
this.pageBoundsCorrection = output();
|
|
380
|
+
this.perPageCountChange = output();
|
|
381
|
+
this._elementRef = inject(ElementRef);
|
|
318
382
|
this._destroyRef = inject(DestroyRef);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
383
|
+
// 组件宽度信号,初始化为一个合理默认值
|
|
384
|
+
this._componentWidth = signal(1024, /* @ts-ignore */
|
|
385
|
+
...(ngDevMode ? [{ debugName: "_componentWidth" }] : /* istanbul ignore next */ []));
|
|
386
|
+
// 根据组件自身宽度判断是否使用移动端样式(阈值:768px)
|
|
387
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
388
|
+
this.isScreenSmall = computed(() => {
|
|
389
|
+
return this._componentWidth() < 768;
|
|
390
|
+
}, /* @ts-ignore */
|
|
391
|
+
...(ngDevMode ? [{ debugName: "isScreenSmall" }] : /* istanbul ignore next */ []));
|
|
392
|
+
// 使用 ResizeObserver 监听组件自身宽度变化
|
|
393
|
+
afterNextRender(() => {
|
|
394
|
+
const element = this._elementRef.nativeElement;
|
|
395
|
+
// 确保元素是块级或行内块级,可以正确测量宽度
|
|
396
|
+
if (getComputedStyle(element).display === 'inline') {
|
|
397
|
+
element.style.display = 'inline-block';
|
|
398
|
+
element.style.width = '100%';
|
|
399
|
+
}
|
|
400
|
+
// 立即获取一次初始宽度
|
|
401
|
+
const initialWidth = element.getBoundingClientRect().width;
|
|
402
|
+
if (initialWidth > 0) {
|
|
403
|
+
this._componentWidth.set(initialWidth);
|
|
404
|
+
}
|
|
405
|
+
// 创建 ResizeObserver
|
|
406
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
407
|
+
for (const entry of entries) {
|
|
408
|
+
const width = entry.contentRect.width;
|
|
409
|
+
// 只有当宽度大于0时才更新,避免无效值
|
|
410
|
+
if (width > 0) {
|
|
411
|
+
this._componentWidth.set(width);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
// 开始观察
|
|
416
|
+
resizeObserver.observe(element);
|
|
417
|
+
// 组件销毁时清理观察者
|
|
418
|
+
this._destroyRef.onDestroy(() => {
|
|
419
|
+
resizeObserver.disconnect();
|
|
420
|
+
});
|
|
332
421
|
});
|
|
333
422
|
}
|
|
334
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
335
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
423
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
424
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: CmatPaginationComponent, isStandalone: true, selector: "cmat-pagination", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, maxSize: { classPropertyName: "maxSize", publicName: "maxSize", isSignal: true, isRequired: false, transformFunction: null }, itemsPerPages: { classPropertyName: "itemsPerPages", publicName: "itemsPerPages", isSignal: true, isRequired: false, transformFunction: null }, initPerPage: { classPropertyName: "initPerPage", publicName: "initPerPage", isSignal: true, isRequired: false, transformFunction: null }, autoHide: { classPropertyName: "autoHide", publicName: "autoHide", isSignal: true, isRequired: false, transformFunction: null } }, 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=\"flex-auto items-center\" [ngClass]=\"{'hidden':isScreenSmall(),'flex':!isScreenSmall()}\">\r\n <span>\u603B\u8BA1:{{ p.getTotalItems() }}</span>\r\n </div>\r\n <nav role=\"navigation\" class=\"flex min-h-12\" [ngClass]=\"{'w-full':isScreenSmall(),'w-0':!isScreenSmall()}\">\r\n @if (!(autoHide() && p.pages().length <= 1)) { \r\n <ul class=\"flex flex-row items-center w-full\"\r\n [ngClass]=\"{'justify-center':isScreenSmall(),'justify-end':!isScreenSmall()}\">\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\" class=\"cursor-pointer text-gray-400 hover:text-current\"\r\n (click)=\"p.setCurrent(page.value)\">\r\n <span>{{\r\n page.label === \"...\"\r\n ? page.label\r\n : (page.label | number: \"\")\r\n }}</span>\r\n </a>\r\n }\r\n @if (p.getCurrent() === page.value) {\r\n <span class=\"text-current\">\r\n <span>{{\r\n page.label === \"...\"\r\n ? page.label\r\n : (page.label | number: \"\")\r\n }}</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=\"px-2\" [ngClass]=\"{'hidden':isScreenSmall(),'block':!isScreenSmall()}\">\r\n <mat-form-field appearance=\"fill\" [ngStyle]=\"{\r\n width: (p.getLastPage()?.toString()?.length || 0) * 8 + 64 + 'px',\r\n }\">\r\n <input #current matInput type=\"text\" cmatDigitOnly class=\"text-end\" [value]=\"p.getCurrent()\"\r\n [autocomplete]=\"'off'\" [min]=\"0\" [max]=\"p.getLastPage() || 0\" (keyup.enter)=\"p.setCurrent(current.value)\" />\r\n <span matSuffix>/\r\n <div class=\"pl-1\">{{ p.getLastPage() }}</div>\r\n </span>\r\n </mat-form-field>\r\n </li>\r\n <li [ngClass]=\"{'hidden':isScreenSmall(),'block':!isScreenSmall()}\" >\r\n <mat-form-field class=\"w-24\" appearance=\"fill\">\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: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: DecimalPipe, name: "number" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
336
425
|
}
|
|
337
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
426
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginationComponent, decorators: [{
|
|
338
427
|
type: Component,
|
|
339
|
-
args: [{ selector: 'cmat-pagination', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cmatPagination', imports: [
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}],
|
|
351
|
-
|
|
352
|
-
}], initPerPage: [{
|
|
353
|
-
type: Input
|
|
354
|
-
}], autoHide: [{
|
|
355
|
-
type: Input
|
|
356
|
-
}] } });
|
|
428
|
+
args: [{ selector: 'cmat-pagination', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cmatPagination', imports: [
|
|
429
|
+
CmatPaginationDirective,
|
|
430
|
+
MatIconModule,
|
|
431
|
+
NgStyle,
|
|
432
|
+
MatFormFieldModule,
|
|
433
|
+
MatInputModule,
|
|
434
|
+
CmatDigitOnlyDirective,
|
|
435
|
+
MatSelectModule,
|
|
436
|
+
DecimalPipe,
|
|
437
|
+
MatButtonModule,
|
|
438
|
+
NgClass
|
|
439
|
+
], 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=\"flex-auto items-center\" [ngClass]=\"{'hidden':isScreenSmall(),'flex':!isScreenSmall()}\">\r\n <span>\u603B\u8BA1:{{ p.getTotalItems() }}</span>\r\n </div>\r\n <nav role=\"navigation\" class=\"flex min-h-12\" [ngClass]=\"{'w-full':isScreenSmall(),'w-0':!isScreenSmall()}\">\r\n @if (!(autoHide() && p.pages().length <= 1)) { \r\n <ul class=\"flex flex-row items-center w-full\"\r\n [ngClass]=\"{'justify-center':isScreenSmall(),'justify-end':!isScreenSmall()}\">\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\" class=\"cursor-pointer text-gray-400 hover:text-current\"\r\n (click)=\"p.setCurrent(page.value)\">\r\n <span>{{\r\n page.label === \"...\"\r\n ? page.label\r\n : (page.label | number: \"\")\r\n }}</span>\r\n </a>\r\n }\r\n @if (p.getCurrent() === page.value) {\r\n <span class=\"text-current\">\r\n <span>{{\r\n page.label === \"...\"\r\n ? page.label\r\n : (page.label | number: \"\")\r\n }}</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=\"px-2\" [ngClass]=\"{'hidden':isScreenSmall(),'block':!isScreenSmall()}\">\r\n <mat-form-field appearance=\"fill\" [ngStyle]=\"{\r\n width: (p.getLastPage()?.toString()?.length || 0) * 8 + 64 + 'px',\r\n }\">\r\n <input #current matInput type=\"text\" cmatDigitOnly class=\"text-end\" [value]=\"p.getCurrent()\"\r\n [autocomplete]=\"'off'\" [min]=\"0\" [max]=\"p.getLastPage() || 0\" (keyup.enter)=\"p.setCurrent(current.value)\" />\r\n <span matSuffix>/\r\n <div class=\"pl-1\">{{ p.getLastPage() }}</div>\r\n </span>\r\n </mat-form-field>\r\n </li>\r\n <li [ngClass]=\"{'hidden':isScreenSmall(),'block':!isScreenSmall()}\" >\r\n <mat-form-field class=\"w-24\" appearance=\"fill\">\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>" }]
|
|
440
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], maxSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSize", required: false }] }], itemsPerPages: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsPerPages", required: false }] }], initPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "initPerPage", required: false }] }], autoHide: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoHide", required: false }] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], pageBoundsCorrection: [{ type: i0.Output, args: ["pageBoundsCorrection"] }], perPageCountChange: [{ type: i0.Output, args: ["perPageCountChange"] }] } });
|
|
357
441
|
|
|
358
442
|
const LARGE_NUMBER = Number.MAX_SAFE_INTEGER;
|
|
359
443
|
class CmatPaginatePipe {
|
|
@@ -374,7 +458,7 @@ class CmatPaginatePipe {
|
|
|
374
458
|
let start;
|
|
375
459
|
let end;
|
|
376
460
|
const perPage = this._toNumber(args.itemsPerPage);
|
|
377
|
-
const emitChange = this.service.register(instance);
|
|
461
|
+
const emitChange = this.service.register(instance, true);
|
|
378
462
|
if (!serverSideMode) {
|
|
379
463
|
const pageSize = perPage || LARGE_NUMBER;
|
|
380
464
|
start = (instance.currentPage - 1) * pageSize;
|
|
@@ -433,10 +517,10 @@ class CmatPaginatePipe {
|
|
|
433
517
|
_toNumber(value) {
|
|
434
518
|
return Number(value);
|
|
435
519
|
}
|
|
436
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
437
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "
|
|
520
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
521
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginatePipe, isStandalone: true, name: "paginate" }); }
|
|
438
522
|
}
|
|
439
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
523
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatPaginatePipe, decorators: [{
|
|
440
524
|
type: Pipe,
|
|
441
525
|
args: [{
|
|
442
526
|
name: 'paginate',
|