@tacdaed/fragments 1.0.0-beta.3 → 1.0.0-beta.4
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/README.md +14 -0
- package/ng-package.json +20 -0
- package/package.json +22 -29
- package/src/lib/components/accordion/accordion.component.html +103 -0
- package/src/lib/components/accordion/accordion.component.scss +382 -0
- package/src/lib/components/accordion/accordion.component.spec.ts +147 -0
- package/src/lib/components/accordion/accordion.component.ts +211 -0
- package/src/lib/components/accordion/accordion.type.ts +82 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.html +43 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.scss +112 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +33 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +103 -0
- package/src/lib/components/breadcrumb/breadcrumb.interface.ts +7 -0
- package/src/lib/components/button/button.component.html +57 -0
- package/src/lib/components/button/button.component.scss +445 -0
- package/src/lib/components/button/button.component.spec.ts +99 -0
- package/src/lib/components/button/button.component.ts +143 -0
- package/src/lib/components/button/button.type.ts +7 -0
- package/src/lib/components/card/card.component.html +44 -0
- package/src/lib/components/card/card.component.scss +114 -0
- package/src/lib/components/card/card.component.spec.ts +65 -0
- package/src/lib/components/card/card.component.ts +21 -0
- package/src/lib/components/card/card.type.ts +3 -0
- package/src/lib/components/code-block/code-block.component.html +55 -0
- package/src/lib/components/code-block/code-block.component.scss +122 -0
- package/src/lib/components/code-block/code-block.component.spec.ts +81 -0
- package/src/lib/components/code-block/code-block.component.ts +302 -0
- package/src/lib/components/code-block/code-block.interface.ts +28 -0
- package/src/lib/components/code-block/code-block.type.ts +73 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.html +14 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.scss +20 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.spec.ts +38 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.ts +181 -0
- package/src/lib/components/input/input-base.ts +187 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.html +76 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.scss +179 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.spec.ts +44 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.ts +299 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.html +37 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.scss +128 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.spec.ts +43 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.ts +112 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.html +43 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.scss +140 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.spec.ts +62 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.ts +136 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.html +81 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.scss +228 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.spec.ts +62 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.ts +178 -0
- package/src/lib/components/input/input-consts.ts +132 -0
- package/src/lib/components/input/input-date/input-date-validators.ts +41 -0
- package/src/lib/components/input/input-date/input-date.component.html +41 -0
- package/src/lib/components/input/input-date/input-date.component.scss +95 -0
- package/src/lib/components/input/input-date/input-date.component.spec.ts +43 -0
- package/src/lib/components/input/input-date/input-date.component.ts +359 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.html +70 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.scss +133 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.spec.ts +36 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.ts +387 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.html +89 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.scss +171 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.spec.ts +43 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.ts +351 -0
- package/src/lib/components/input/input-interface.ts +8 -0
- package/src/lib/components/input/input-number/input-number-validators.ts +0 -0
- package/src/lib/components/input/input-number/input-number.component.html +51 -0
- package/src/lib/components/input/input-number/input-number.component.scss +140 -0
- package/src/lib/components/input/input-number/input-number.component.spec.ts +44 -0
- package/src/lib/components/input/input-number/input-number.component.ts +343 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.html +44 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.scss +139 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.spec.ts +58 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.ts +132 -0
- package/src/lib/components/input/input-slider/input-slider.component.html +111 -0
- package/src/lib/components/input/input-slider/input-slider.component.scss +203 -0
- package/src/lib/components/input/input-slider/input-slider.component.spec.ts +46 -0
- package/src/lib/components/input/input-slider/input-slider.component.ts +410 -0
- package/src/lib/components/input/input-text/input-text-validators.ts +67 -0
- package/src/lib/components/input/input-text/input-text.component.html +71 -0
- package/src/lib/components/input/input-text/input-text.component.scss +118 -0
- package/src/lib/components/input/input-text/input-text.component.spec.ts +55 -0
- package/src/lib/components/input/input-text/input-text.component.ts +215 -0
- package/src/lib/components/input/input-time/input-time-validators.ts +42 -0
- package/src/lib/components/input/input-time/input-time.component.html +92 -0
- package/src/lib/components/input/input-time/input-time.component.scss +191 -0
- package/src/lib/components/input/input-time/input-time.component.spec.ts +39 -0
- package/src/lib/components/input/input-time/input-time.component.ts +691 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.html +36 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.scss +121 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.spec.ts +54 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.ts +117 -0
- package/src/lib/components/input/input-type.ts +18 -0
- package/src/lib/components/input/input-validation/input-validation.component.html +19 -0
- package/src/lib/components/input/input-validation/input-validation.component.scss +39 -0
- package/src/lib/components/input/input-validation/input-validation.component.spec.ts +45 -0
- package/src/lib/components/input/input-validation/input-validation.component.ts +13 -0
- package/src/lib/components/input/input.pipe.ts +14 -0
- package/src/lib/components/layout/container/container.component.html +1 -0
- package/src/lib/components/layout/container/container.component.scss +33 -0
- package/src/lib/components/layout/container/container.component.ts +32 -0
- package/src/lib/components/layout/container/container.type.ts +1 -0
- package/src/lib/components/layout/divider/divider.component.html +1 -0
- package/src/lib/components/layout/divider/divider.component.scss +60 -0
- package/src/lib/components/layout/divider/divider.component.ts +38 -0
- package/src/lib/components/layout/divider/divider.type.ts +2 -0
- package/src/lib/components/layout/section/section.component.html +21 -0
- package/src/lib/components/layout/section/section.component.scss +43 -0
- package/src/lib/components/layout/section/section.component.ts +33 -0
- package/src/lib/components/layout/section/section.type.ts +2 -0
- package/src/lib/components/layout/separator/separator.component.html +9 -0
- package/src/lib/components/layout/separator/separator.component.scss +52 -0
- package/src/lib/components/layout/separator/separator.component.ts +25 -0
- package/src/lib/components/layout/separator/separator.type.ts +1 -0
- package/src/lib/components/loader/content-blur/content-blur.component.html +13 -0
- package/src/lib/components/loader/content-blur/content-blur.component.scss +43 -0
- package/src/lib/components/loader/content-blur/content-blur.component.spec.ts +42 -0
- package/src/lib/components/loader/content-blur/content-blur.component.ts +34 -0
- package/src/lib/components/loader/loader.type.ts +2 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.html +26 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.scss +151 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.spec.ts +47 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.ts +28 -0
- package/src/lib/components/loader/progress-bar/progress-bar.type.ts +8 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.html +12 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.scss +202 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.spec.ts +55 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.ts +73 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.type.ts +6 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.html +13 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.scss +113 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.spec.ts +37 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.ts +51 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.type.ts +6 -0
- package/src/lib/components/loader/spinner/spinner.component.html +20 -0
- package/src/lib/components/loader/spinner/spinner.component.scss +137 -0
- package/src/lib/components/loader/spinner/spinner.component.spec.ts +43 -0
- package/src/lib/components/loader/spinner/spinner.component.ts +32 -0
- package/src/lib/components/loader/spinner/spinner.type.ts +6 -0
- package/src/lib/components/modal/modal.component.html +47 -0
- package/src/lib/components/modal/modal.component.scss +139 -0
- package/src/lib/components/modal/modal.component.spec.ts +60 -0
- package/src/lib/components/modal/modal.component.ts +83 -0
- package/src/lib/components/modal/modal.type.ts +9 -0
- package/src/lib/components/morph/blob-moph/blob-moprh.component.spec.ts +79 -0
- package/src/lib/components/morph/blob-moph/blob-moprh.component.ts +96 -0
- package/src/lib/components/morph/blob-moph/blob-morph.component.html +34 -0
- package/src/lib/components/morph/blob-moph/blob-morph.component.scss +7 -0
- package/src/lib/components/morph/morph.abstract.ts +13 -0
- package/src/lib/components/pagination/pagination.interface.ts +4 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.html +61 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.scss +187 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.spec.ts +88 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.ts +177 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.html +170 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.scss +312 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.spec.ts +61 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.ts +372 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.html +125 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.scss +267 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.spec.ts +66 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.ts +315 -0
- package/src/lib/components/selection-lists/selection-lists-base.ts +35 -0
- package/src/lib/components/selection-lists/selection-lists-const.ts +17 -0
- package/src/lib/components/selection-lists/selection-lists-interface.ts +7 -0
- package/src/lib/components/selection-lists/selection-lists.type.ts +1 -0
- package/src/lib/components/side-nav/side-nav.component.html +101 -0
- package/src/lib/components/side-nav/side-nav.component.scss +295 -0
- package/src/lib/components/side-nav/side-nav.component.spec.ts +0 -0
- package/src/lib/components/side-nav/side-nav.component.ts +18 -0
- package/src/lib/components/side-nav/side-nav.type.ts +28 -0
- package/src/lib/components/snackbar/snackbar.component.html +33 -0
- package/src/lib/components/snackbar/snackbar.component.scss +195 -0
- package/src/lib/components/snackbar/snackbar.component.ts +112 -0
- package/src/lib/components/snackbar/snackbar.type.ts +27 -0
- package/src/lib/components/status/chip/chip.component.html +51 -0
- package/src/lib/components/status/chip/chip.component.scss +149 -0
- package/src/lib/components/status/chip/chip.component.spec.ts +62 -0
- package/src/lib/components/status/chip/chip.component.ts +83 -0
- package/src/lib/components/status/chip/chip.type.ts +42 -0
- package/src/lib/components/status/directives/badge/badge.directive.spec.ts +60 -0
- package/src/lib/components/status/directives/badge/badge.directive.ts +190 -0
- package/src/lib/components/status/directives/badge/badge.interface.ts +19 -0
- package/src/lib/components/status/pill/pill.component.html +40 -0
- package/src/lib/components/status/pill/pill.component.scss +113 -0
- package/src/lib/components/status/pill/pill.component.spec.ts +47 -0
- package/src/lib/components/status/pill/pill.component.ts +83 -0
- package/src/lib/components/status/pill/pill.type.ts +42 -0
- package/src/lib/components/status/status.interface.ts +57 -0
- package/src/lib/components/status/status.type.ts +62 -0
- package/src/lib/components/status/tag/tag.component.html +39 -0
- package/src/lib/components/status/tag/tag.component.scss +140 -0
- package/src/lib/components/status/tag/tag.component.spec.ts +47 -0
- package/src/lib/components/status/tag/tag.component.ts +83 -0
- package/src/lib/components/status/tag/tag.type.ts +42 -0
- package/src/lib/components/stepper/stepper.component.html +83 -0
- package/src/lib/components/stepper/stepper.component.scss +196 -0
- package/src/lib/components/stepper/stepper.component.ts +482 -0
- package/src/lib/components/stepper/stepper.type.ts +60 -0
- package/src/lib/components/table/table.component.html +438 -0
- package/src/lib/components/table/table.component.scss +259 -0
- package/src/lib/components/table/table.component.spec.ts +117 -0
- package/src/lib/components/table/table.component.ts +215 -0
- package/src/lib/components/table/table.enum.ts +4 -0
- package/src/lib/components/table/table.function.ts +47 -0
- package/src/lib/components/table/table.interface.ts +143 -0
- package/src/lib/components/table/table.pipe.ts +62 -0
- package/src/lib/components/table/table.type.ts +15 -0
- package/src/lib/components/tabs/tabs.component.html +88 -0
- package/src/lib/components/tabs/tabs.component.scss +305 -0
- package/src/lib/components/tabs/tabs.component.spec.ts +94 -0
- package/src/lib/components/tabs/tabs.component.ts +282 -0
- package/src/lib/components/tabs/tabs.type.ts +81 -0
- package/src/lib/components/title-bar/title-bar.component.html +21 -0
- package/src/lib/components/title-bar/title-bar.component.scss +139 -0
- package/src/lib/components/title-bar/title-bar.component.spec.ts +44 -0
- package/src/lib/components/title-bar/title-bar.component.ts +13 -0
- package/src/lib/components/toast/toast.component.html +36 -0
- package/src/lib/components/toast/toast.component.scss +241 -0
- package/src/lib/components/toast/toast.component.ts +165 -0
- package/src/lib/components/toast/toast.type.ts +37 -0
- package/src/lib/components/toast-stack/toast-stack.component.html +30 -0
- package/src/lib/components/toast-stack/toast-stack.component.scss +35 -0
- package/src/lib/components/toast-stack/toast-stack.component.ts +51 -0
- package/src/lib/consts/country-prefix.ts +244 -0
- package/src/lib/directives/tooltip/popover.directive.ts +274 -0
- package/src/lib/directives/tooltip/tooltip.directive.spec.ts +86 -0
- package/src/lib/directives/tooltip/tooltip.directive.ts +234 -0
- package/src/lib/directives/tooltip/tooltip.interface.ts +29 -0
- package/src/lib/directives/tooltip/tooltip.type.ts +9 -0
- package/src/lib/interfaces/common.interfaces.ts +4 -0
- package/src/lib/pipes/chunk.pipe.ts +16 -0
- package/src/lib/pipes/safe-html.pipe.ts +14 -0
- package/src/lib/pipes/sanitize-html.pipe.ts +23 -0
- package/src/lib/types/base.types.ts +23 -0
- package/src/lib/types/common.types.ts +98 -0
- package/src/lib/types/form.types.ts +5 -0
- package/src/lib/utils/common.utils.ts +53 -0
- package/src/lib/utils/date.utils.ts +474 -0
- package/src/lib/utils/number.utils.ts +16 -0
- package/src/lib/utils/uuid.utils.ts +39 -0
- package/src/public-api.ts +114 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +9 -0
- package/fesm2022/tacdaed-fragments.mjs +0 -8928
- package/fesm2022/tacdaed-fragments.mjs.map +0 -1
- package/index.d.ts +0 -3929
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterViewInit,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
Input,
|
|
7
|
+
Output,
|
|
8
|
+
ViewChild,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { animate, svg } from 'animejs';
|
|
11
|
+
import { MorphBase } from '../morph.abstract';
|
|
12
|
+
import { SpinnerComponent } from '../../loader/spinner/spinner.component';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'app-blob-morph',
|
|
16
|
+
templateUrl: './blob-morph.component.html',
|
|
17
|
+
imports: [SpinnerComponent],
|
|
18
|
+
styleUrls: ['./blob-morph.component.scss'],
|
|
19
|
+
})
|
|
20
|
+
export class BlobMorphComponent extends MorphBase implements AfterViewInit {
|
|
21
|
+
@Input() override imageUrl: string | null = null;
|
|
22
|
+
@Input() override fillColor: string | null = null;
|
|
23
|
+
@Input() override pathStart: string = this.generateRandomPath();
|
|
24
|
+
@Input() override pathEnd: string = this.generateRandomPath();
|
|
25
|
+
@Input() override duration: number = 4000;
|
|
26
|
+
|
|
27
|
+
@Output() loadEvent: EventEmitter<void> = new EventEmitter<void>();
|
|
28
|
+
|
|
29
|
+
@ViewChild('morphPath', { static: false })
|
|
30
|
+
morphPathRef!: ElementRef<SVGPathElement>;
|
|
31
|
+
clipId = `clip-${Math.random().toString(36).substring(2, 10)}`;
|
|
32
|
+
|
|
33
|
+
protected isLoaded: boolean = false;
|
|
34
|
+
|
|
35
|
+
ngAfterViewInit(): void {
|
|
36
|
+
const startPath = this.morphPathRef.nativeElement;
|
|
37
|
+
const endPath = document.getElementById(
|
|
38
|
+
`morph-path-end-${this.clipId}`
|
|
39
|
+
) as SVGPathElement | null;
|
|
40
|
+
|
|
41
|
+
if (startPath && endPath) {
|
|
42
|
+
animate(startPath, {
|
|
43
|
+
d: svg.morphTo(endPath),
|
|
44
|
+
direction: 'alternate-reverse',
|
|
45
|
+
duration: this.duration,
|
|
46
|
+
ease: 'inOut',
|
|
47
|
+
loop: true,
|
|
48
|
+
alternate: true,
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
console.error('Path elements not found');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected override generateRandomPath(
|
|
56
|
+
points = 8,
|
|
57
|
+
radius = 60,
|
|
58
|
+
variability = 20
|
|
59
|
+
): string {
|
|
60
|
+
const angleStep = (Math.PI * 2) / points;
|
|
61
|
+
const coords: { x: number; y: number }[] = [];
|
|
62
|
+
|
|
63
|
+
for (let i = 0; i < points; i++) {
|
|
64
|
+
const angle = i * angleStep;
|
|
65
|
+
const randRadius = radius + (Math.random() - 0.5) * 2 * variability;
|
|
66
|
+
const x = Math.cos(angle) * randRadius;
|
|
67
|
+
const y = Math.sin(angle) * randRadius;
|
|
68
|
+
coords.push({ x, y });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let path = `M${coords[0].x.toFixed(1)},${coords[0].y.toFixed(1)}`;
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < coords.length; i++) {
|
|
74
|
+
const p0 = coords[i];
|
|
75
|
+
const p1 = coords[(i + 1) % coords.length];
|
|
76
|
+
const pPrev = coords[(i - 1 + coords.length) % coords.length];
|
|
77
|
+
const pNext = coords[(i + 2) % coords.length];
|
|
78
|
+
|
|
79
|
+
const control1X = p0.x + (p1.x - pPrev.x) * 0.2;
|
|
80
|
+
const control1Y = p0.y + (p1.y - pPrev.y) * 0.2;
|
|
81
|
+
|
|
82
|
+
const control2X = p1.x - (pNext.x - p0.x) * 0.2;
|
|
83
|
+
const control2Y = p1.y - (pNext.y - p0.y) * 0.2;
|
|
84
|
+
|
|
85
|
+
path += ` C${control1X.toFixed(1)},${control1Y.toFixed(1)} ${control2X.toFixed(1)},${control2Y.toFixed(1)} ${p1.x.toFixed(1)},${p1.y.toFixed(1)}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
path += ' Z';
|
|
89
|
+
return path;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onLoadEvent(): void {
|
|
93
|
+
this.isLoaded = true;
|
|
94
|
+
this.loadEvent.emit();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<div class="blob-container">
|
|
2
|
+
<svg
|
|
3
|
+
viewBox="0 0 200 200"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
class="blob-svg"
|
|
6
|
+
[class.hidden]="!isLoaded"
|
|
7
|
+
>
|
|
8
|
+
<defs>
|
|
9
|
+
<clipPath [attr.id]="clipId" transform="translate(100 100)">
|
|
10
|
+
<path #morphPath [attr.d]="pathStart" />
|
|
11
|
+
</clipPath>
|
|
12
|
+
<path [attr.id]="'morph-path-end-' + clipId" [attr.d]="pathEnd" />
|
|
13
|
+
</defs>
|
|
14
|
+
|
|
15
|
+
@if (imageUrl) {
|
|
16
|
+
<image
|
|
17
|
+
[attr.href]="imageUrl"
|
|
18
|
+
width="100%"
|
|
19
|
+
height="100%"
|
|
20
|
+
preserveAspectRatio="xMidYMid slice"
|
|
21
|
+
[attr.clip-path]="'url(#' + clipId + ')'"
|
|
22
|
+
(load)="onLoadEvent()"
|
|
23
|
+
/>
|
|
24
|
+
} @else {
|
|
25
|
+
<g [attr.clip-path]="'url(#' + clipId + ')'">
|
|
26
|
+
<rect width="100%" height="100%" [attr.fill]="fillColor || '#ccc'" />
|
|
27
|
+
</g>
|
|
28
|
+
}
|
|
29
|
+
</svg>
|
|
30
|
+
|
|
31
|
+
@if (!isLoaded) {
|
|
32
|
+
<frg-spinner [isOverlayItem]="true"></frg-spinner>
|
|
33
|
+
}
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export abstract class MorphBase {
|
|
2
|
+
protected imageUrl: string | null = null;
|
|
3
|
+
protected fillColor: string | null = null;
|
|
4
|
+
protected pathStart: string = '';
|
|
5
|
+
protected pathEnd: string = '';
|
|
6
|
+
protected duration: number = 4000;
|
|
7
|
+
|
|
8
|
+
protected abstract generateRandomPath(
|
|
9
|
+
points: number,
|
|
10
|
+
radius: number,
|
|
11
|
+
variability: number
|
|
12
|
+
): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@if (totalItems > pageSize) {
|
|
2
|
+
<nav
|
|
3
|
+
class="frg-pagination-small"
|
|
4
|
+
aria-label="Paginazione nome lista"
|
|
5
|
+
[ngClass]="{
|
|
6
|
+
'frg-pagination-small__primary': styleType === 'primary',
|
|
7
|
+
'frg-pagination-small__secondary': styleType === 'secondary',
|
|
8
|
+
'frg-pagination-small__tertiary': styleType === 'tertiary',
|
|
9
|
+
'frg-pagination-small__dark': styleType === 'dark',
|
|
10
|
+
'frg-pagination-small__light': styleType === 'light'
|
|
11
|
+
}"
|
|
12
|
+
>
|
|
13
|
+
<ul class="frg-pagination-small__list">
|
|
14
|
+
<li class="frg-pagination-small__paging frg-pagination-small__prev">
|
|
15
|
+
<a
|
|
16
|
+
href="javascript:void(0);"
|
|
17
|
+
[class.disabled]="page === 1"
|
|
18
|
+
(click)="changePage(page - 1)"
|
|
19
|
+
>
|
|
20
|
+
<span class="visually-hidden">Pagina precedente</span>
|
|
21
|
+
<span class="fas fa-angle-left" aria-hidden="true"></span>
|
|
22
|
+
</a>
|
|
23
|
+
</li>
|
|
24
|
+
@for (pageNum of pagesArray; track pageNum; let i = $index) {
|
|
25
|
+
@if (showStartEllipsis && i === 1) {
|
|
26
|
+
<li class="frg-pagination-small__paging frg-pagination-small__ellipsis">
|
|
27
|
+
<span class="ellipsis">...</span>
|
|
28
|
+
</li>
|
|
29
|
+
}
|
|
30
|
+
<li
|
|
31
|
+
class="frg-pagination-small__paging frg-pagination-small__page-number"
|
|
32
|
+
>
|
|
33
|
+
<a
|
|
34
|
+
href="javascript:void(0);"
|
|
35
|
+
[attr.aria-current]="page === pageNum ? 'page' : null"
|
|
36
|
+
(click)="changePage(pageNum)"
|
|
37
|
+
>
|
|
38
|
+
<span class="visually-hidden">Pagina</span>
|
|
39
|
+
{{ pageNum }}
|
|
40
|
+
</a>
|
|
41
|
+
</li>
|
|
42
|
+
@if (showEndEllipsis && i === pagesArray.length - 2) {
|
|
43
|
+
<li class="frg-pagination-small__paging frg-pagination-small__ellipsis">
|
|
44
|
+
<span class="ellipsis">...</span>
|
|
45
|
+
</li>
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
<li class="frg-pagination-small__paging frg-pagination-small__next">
|
|
50
|
+
<a
|
|
51
|
+
href="javascript:void(0);"
|
|
52
|
+
[class.disabled]="page === totalPages"
|
|
53
|
+
(click)="changePage(page + 1)"
|
|
54
|
+
>
|
|
55
|
+
<span class="visually-hidden">Pagina successiva</span>
|
|
56
|
+
<span class="fas fa-angle-right" aria-hidden="true"></span>
|
|
57
|
+
</a>
|
|
58
|
+
</li>
|
|
59
|
+
</ul>
|
|
60
|
+
</nav>
|
|
61
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@use './../../../../../assets/styles/scss/variables' as *;
|
|
3
|
+
|
|
4
|
+
.frg-pagination-small {
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
margin: 12px 0;
|
|
9
|
+
gap: 0.2rem;
|
|
10
|
+
|
|
11
|
+
&__list {
|
|
12
|
+
list-style: none;
|
|
13
|
+
padding: 0;
|
|
14
|
+
margin: 0;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
|
|
19
|
+
li:first-child {
|
|
20
|
+
margin-right: 0.5rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
li:last-child {
|
|
24
|
+
margin-left: 0.5rem;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
& a {
|
|
29
|
+
display: flex;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
align-items: center;
|
|
32
|
+
border-radius: 999px;
|
|
33
|
+
min-width: 1.9rem;
|
|
34
|
+
height: 1.9rem;
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
border: 1px solid transparent;
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
text-align: center;
|
|
39
|
+
transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
background-color: transparent;
|
|
42
|
+
color: $color-dark-soft;
|
|
43
|
+
|
|
44
|
+
&.disabled {
|
|
45
|
+
cursor: default;
|
|
46
|
+
color: $color-disabled;
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:focus-visible {
|
|
51
|
+
outline: 2px solid color.scale($color-primary, $lightness: 35%);
|
|
52
|
+
outline-offset: 2px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&__primary {
|
|
57
|
+
a {
|
|
58
|
+
margin: 0 2px;
|
|
59
|
+
|
|
60
|
+
&[aria-current='page'] {
|
|
61
|
+
background-color: $color-primary;
|
|
62
|
+
color: $color-light;
|
|
63
|
+
border-color: transparent;
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:hover:not([aria-current='page']) {
|
|
68
|
+
background-color: color.scale($color-primary, $lightness: 40%);
|
|
69
|
+
color: $color-light;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&.disabled {
|
|
73
|
+
&:hover {
|
|
74
|
+
background-color: #f1f2f5;
|
|
75
|
+
color: $color-disabled;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&__secondary {
|
|
82
|
+
a {
|
|
83
|
+
margin: 0 2px;
|
|
84
|
+
|
|
85
|
+
&[aria-current='page'] {
|
|
86
|
+
background-color: $color-secondary;
|
|
87
|
+
color: $color-light;
|
|
88
|
+
border-color: transparent;
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&:hover:not([aria-current='page']) {
|
|
93
|
+
background-color: color.scale($color-secondary, $lightness: 40%);
|
|
94
|
+
color: $color-light;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&.disabled {
|
|
98
|
+
&:hover {
|
|
99
|
+
background-color: #f1f2f5;
|
|
100
|
+
color: $color-disabled;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&__tertiary {
|
|
107
|
+
a {
|
|
108
|
+
margin: 0 2px;
|
|
109
|
+
|
|
110
|
+
&[aria-current='page'] {
|
|
111
|
+
background-color: $color-tertiary;
|
|
112
|
+
color: $color-light;
|
|
113
|
+
border-color: transparent;
|
|
114
|
+
pointer-events: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&:hover:not([aria-current='page']) {
|
|
118
|
+
background-color: color.scale($color-tertiary, $lightness: 40%);
|
|
119
|
+
color: $color-light;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.disabled {
|
|
123
|
+
&:hover {
|
|
124
|
+
background-color: #f1f2f5;
|
|
125
|
+
color: $color-disabled;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&__dark {
|
|
132
|
+
a {
|
|
133
|
+
margin: 0 2px;
|
|
134
|
+
background-color: $color-light;
|
|
135
|
+
border: 1px solid rgba($color-light, 0.12);
|
|
136
|
+
color: $color-dark-soft;
|
|
137
|
+
|
|
138
|
+
&[aria-current='page'] {
|
|
139
|
+
background-color: rgba($color-dark, 0.9);
|
|
140
|
+
border-color: rgba($color-dark, 0.85);
|
|
141
|
+
color: $color-light-soft;
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&:hover:not([aria-current='page']) {
|
|
146
|
+
background-color: color.scale($color-dark-neutral, $lightness: 45%);
|
|
147
|
+
color: $color-light;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&.disabled {
|
|
151
|
+
border-color: rgba($color-light, 0.08);
|
|
152
|
+
color: $color-disabled;
|
|
153
|
+
|
|
154
|
+
&:hover {
|
|
155
|
+
background-color: $color-dark-neutral;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&__light {
|
|
162
|
+
a {
|
|
163
|
+
margin: 0 2px;
|
|
164
|
+
color: $color-light-neutral;
|
|
165
|
+
|
|
166
|
+
&[aria-current='page'] {
|
|
167
|
+
background-color: $color-light;
|
|
168
|
+
color: $color-dark-neutral;
|
|
169
|
+
pointer-events: none;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&:hover:not([aria-current='page']) {
|
|
173
|
+
background-color: $color-light-soft;
|
|
174
|
+
color: $color-dark-neutral;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&.disabled {
|
|
178
|
+
color: $color-dark-soft;
|
|
179
|
+
&:hover {
|
|
180
|
+
background-color: transparent;
|
|
181
|
+
color: $color-dark-soft;
|
|
182
|
+
pointer-events: none;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { By } from '@angular/platform-browser';
|
|
3
|
+
import { SmallPaginationComponent } from './small-pagination.component';
|
|
4
|
+
import { IPaginationOutput } from '../pagination.interface';
|
|
5
|
+
|
|
6
|
+
type DemoItem = { id: number };
|
|
7
|
+
|
|
8
|
+
describe('SmallPaginationComponent', () => {
|
|
9
|
+
let fixture: ComponentFixture<SmallPaginationComponent<DemoItem>>;
|
|
10
|
+
let component: SmallPaginationComponent<DemoItem>;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
imports: [SmallPaginationComponent]
|
|
15
|
+
}).compileComponents();
|
|
16
|
+
|
|
17
|
+
fixture = TestBed.createComponent(SmallPaginationComponent<DemoItem>);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('builds simple pages when ellipsis disabled', () => {
|
|
22
|
+
component.totalItems = 20;
|
|
23
|
+
component.pageSize = 5;
|
|
24
|
+
component.fullData = Array.from({ length: 20 }, (_, i) => ({ id: i + 1 }));
|
|
25
|
+
component.hasElipsisPages = false;
|
|
26
|
+
|
|
27
|
+
fixture.detectChanges();
|
|
28
|
+
|
|
29
|
+
expect(component.pagesArray).toEqual([1, 2, 3, 4]);
|
|
30
|
+
expect(component.showStartEllipsis).toBeFalse();
|
|
31
|
+
expect(component.showEndEllipsis).toBeFalse();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('builds ellipsis pages for large datasets', () => {
|
|
35
|
+
component.totalItems = 48;
|
|
36
|
+
component.pageSize = 4;
|
|
37
|
+
component.fullData = Array.from({ length: 48 }, (_, i) => ({ id: i + 1 }));
|
|
38
|
+
component.page = 3;
|
|
39
|
+
component.hasElipsisPages = true;
|
|
40
|
+
|
|
41
|
+
fixture.detectChanges();
|
|
42
|
+
|
|
43
|
+
expect(component.pagesArray).toEqual([1, 2, 3, 4, 12]);
|
|
44
|
+
expect(component.showStartEllipsis).toBeFalse();
|
|
45
|
+
expect(component.showEndEllipsis).toBeTrue();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('emits pageChange with paged data', () => {
|
|
49
|
+
const emitSpy = spyOn(component.pageChange, 'emit');
|
|
50
|
+
|
|
51
|
+
component.totalItems = 10;
|
|
52
|
+
component.pageSize = 2;
|
|
53
|
+
component.fullData = Array.from({ length: 10 }, (_, i) => ({ id: i + 1 }));
|
|
54
|
+
|
|
55
|
+
fixture.detectChanges();
|
|
56
|
+
|
|
57
|
+
component.changePage(2);
|
|
58
|
+
|
|
59
|
+
const expected: IPaginationOutput<DemoItem> = {
|
|
60
|
+
page: 2,
|
|
61
|
+
pagedData: [{ id: 3 }, { id: 4 }]
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
expect(emitSpy).toHaveBeenCalledWith(expected);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('clamps page to 1 on init', () => {
|
|
68
|
+
component.totalItems = 5;
|
|
69
|
+
component.pageSize = 5;
|
|
70
|
+
component.fullData = [{ id: 1 }];
|
|
71
|
+
component.page = 0;
|
|
72
|
+
|
|
73
|
+
fixture.detectChanges();
|
|
74
|
+
|
|
75
|
+
expect(component.page).toBe(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('does not render pagination when only one page', () => {
|
|
79
|
+
component.totalItems = 4;
|
|
80
|
+
component.pageSize = 4;
|
|
81
|
+
component.fullData = Array.from({ length: 4 }, (_, i) => ({ id: i + 1 }));
|
|
82
|
+
|
|
83
|
+
fixture.detectChanges();
|
|
84
|
+
|
|
85
|
+
const nav = fixture.debugElement.query(By.css('nav'));
|
|
86
|
+
expect(nav).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Input,
|
|
6
|
+
OnChanges,
|
|
7
|
+
OnInit,
|
|
8
|
+
Output,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { TBaseStyle } from '../../../types/base.types';
|
|
11
|
+
import { IPaginationOutput } from '../pagination.interface';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'frg-small-pagination',
|
|
15
|
+
imports: [CommonModule],
|
|
16
|
+
templateUrl: './small-pagination.component.html',
|
|
17
|
+
styleUrls: ['./small-pagination.component.scss']
|
|
18
|
+
})
|
|
19
|
+
export class SmallPaginationComponent<T> implements OnInit, OnChanges {
|
|
20
|
+
@Input() totalItems = 0;
|
|
21
|
+
@Input() fullData = [] as T[];
|
|
22
|
+
@Input() page = 0;
|
|
23
|
+
@Input() pageSize = 0;
|
|
24
|
+
@Input() hasElipsisPages = false;
|
|
25
|
+
@Input() styleType: TBaseStyle = 'primary';
|
|
26
|
+
|
|
27
|
+
@Output() pageChange = new EventEmitter<IPaginationOutput<T>>();
|
|
28
|
+
|
|
29
|
+
pagesArray: number[] = [];
|
|
30
|
+
pagedData: T[] = [];
|
|
31
|
+
totalPages = 0;
|
|
32
|
+
showStartEllipsis = false;
|
|
33
|
+
showEndEllipsis = false;
|
|
34
|
+
maxVisiblePages = 4;
|
|
35
|
+
|
|
36
|
+
ngOnInit() {
|
|
37
|
+
this.calculateTotalPages();
|
|
38
|
+
this.setCurrentPage();
|
|
39
|
+
this.generatePagesArray();
|
|
40
|
+
this.changePage(this.page);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ngOnChanges() {
|
|
44
|
+
this.calculateTotalPages();
|
|
45
|
+
this.setCurrentPage();
|
|
46
|
+
this.generatePagesArray();
|
|
47
|
+
this.changePage(this.page);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private calculateTotalPages() {
|
|
51
|
+
this.totalPages = Math.ceil(this.totalItems / this.pageSize);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private generatePagesArray() {
|
|
55
|
+
this.pagesArray = [];
|
|
56
|
+
|
|
57
|
+
if (this.totalPages <= 0) {
|
|
58
|
+
this.resetEllipsis();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const currentPage = this.clampPage(this.page);
|
|
63
|
+
|
|
64
|
+
if (!this.hasElipsisPages || this.isSimplePagination()) {
|
|
65
|
+
this.buildSimplePages();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.buildEllipsisPages(currentPage);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private buildSimplePages() {
|
|
73
|
+
this.pagesArray = this.range(1, this.totalPages);
|
|
74
|
+
this.resetEllipsis();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private buildEllipsisPages(currentPage: number) {
|
|
78
|
+
const startPage = 1;
|
|
79
|
+
const endPage = this.totalPages;
|
|
80
|
+
const visibleMiddle = this.getVisibleMiddleCount();
|
|
81
|
+
|
|
82
|
+
if (visibleMiddle === 0) {
|
|
83
|
+
this.pagesArray = endPage === 1 ? [startPage] : [startPage, endPage];
|
|
84
|
+
this.showStartEllipsis = currentPage > startPage + 1;
|
|
85
|
+
this.showEndEllipsis = currentPage < endPage - 1;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const { middleStart, middleEnd } = this.getMiddleRange(
|
|
90
|
+
currentPage,
|
|
91
|
+
visibleMiddle,
|
|
92
|
+
startPage,
|
|
93
|
+
endPage
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const pagesToAdd = [
|
|
97
|
+
startPage,
|
|
98
|
+
...this.range(middleStart, middleEnd),
|
|
99
|
+
endPage,
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
this.pagesArray = this.uniquePages(pagesToAdd);
|
|
103
|
+
this.showStartEllipsis = middleStart > startPage + 1;
|
|
104
|
+
this.showEndEllipsis = middleEnd < endPage - 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private getVisibleMiddleCount(): number {
|
|
108
|
+
return Math.max(this.maxVisiblePages - 1, 0);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private getMiddleRange(
|
|
112
|
+
currentPage: number,
|
|
113
|
+
visibleMiddle: number,
|
|
114
|
+
startPage: number,
|
|
115
|
+
endPage: number
|
|
116
|
+
): { middleStart: number; middleEnd: number } {
|
|
117
|
+
let middleStart = currentPage - Math.floor(visibleMiddle / 2);
|
|
118
|
+
let middleEnd = middleStart + visibleMiddle - 1;
|
|
119
|
+
|
|
120
|
+
if (middleStart < startPage + 1) {
|
|
121
|
+
middleStart = startPage + 1;
|
|
122
|
+
middleEnd = middleStart + visibleMiddle - 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (middleEnd > endPage - 1) {
|
|
126
|
+
middleEnd = endPage - 1;
|
|
127
|
+
middleStart = Math.max(startPage + 1, middleEnd - visibleMiddle + 1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { middleStart, middleEnd };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private uniquePages(pages: number[]): number[] {
|
|
134
|
+
return pages.filter((value, index, array) => array.indexOf(value) === index);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private resetEllipsis() {
|
|
138
|
+
this.showStartEllipsis = false;
|
|
139
|
+
this.showEndEllipsis = false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private clampPage(page: number): number {
|
|
143
|
+
return Math.min(Math.max(page, 1), this.totalPages);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
changePage(newPage: number) {
|
|
147
|
+
if (newPage >= 1 && newPage <= this.totalPages) {
|
|
148
|
+
this.page = newPage;
|
|
149
|
+
const startIndex = (this.page - 1) * this.pageSize;
|
|
150
|
+
const endIndex = startIndex + this.pageSize;
|
|
151
|
+
const pagedData = this.fullData.slice(startIndex, endIndex);
|
|
152
|
+
this.pagedData = pagedData;
|
|
153
|
+
this.pageChange.emit({
|
|
154
|
+
page: this.page,
|
|
155
|
+
pagedData: this.pagedData,
|
|
156
|
+
});
|
|
157
|
+
this.generatePagesArray();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
setCurrentPage() {
|
|
162
|
+
this.page = Math.max(this.page, 1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private isSimplePagination(): boolean {
|
|
166
|
+
return (
|
|
167
|
+
!!this.maxVisiblePages &&
|
|
168
|
+
(this.totalPages <= this.maxVisiblePages || this.maxVisiblePages <= 2)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private range(start: number, end: number): number[] {
|
|
173
|
+
const result = [];
|
|
174
|
+
for (let i = start; i <= end; i++) result.push(i);
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
}
|