@nanahoshi/mona-ui 0.1.0
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 +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Directive, inject, TemplateRef, input, ElementRef, signal, linkedSignal, contentChildren, computed, contentChild, viewChild, output, effect, untracked, afterRenderEffect, DestroyRef, Component } from '@angular/core';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { FormsModule } from '@angular/forms';
|
|
6
|
+
import { LucideEllipsis, LucideChevronsLeft, LucideChevronLeft, LucideChevronRight, LucideChevronsRight } from '@lucide/angular';
|
|
7
|
+
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
8
|
+
import { PreventableEvent, SlicePipe } from '@nanahoshi/mona-ui/common';
|
|
9
|
+
import { DropdownListComponent, DropdownListValueTemplateDirective } from '@nanahoshi/mona-ui/dropdown-list';
|
|
10
|
+
import { DropdownVirtualScrollDirective } from '@nanahoshi/mona-ui/dropdowns';
|
|
11
|
+
import { NavigationKeys } from '@nanahoshi/mona-ui/internal';
|
|
12
|
+
import { NumericTextBoxComponent } from '@nanahoshi/mona-ui/numeric-text-box';
|
|
13
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
14
|
+
import { range } from '@mirei/ts-collections';
|
|
15
|
+
import { twMerge } from 'tailwind-merge';
|
|
16
|
+
import { cva } from 'class-variance-authority';
|
|
17
|
+
|
|
18
|
+
class PagerFocusableDirective {
|
|
19
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerFocusableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
20
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PagerFocusableDirective, isStandalone: true, selector: "[monaPagerFocusable]", host: { properties: { "attr.data-mona-pager-focusable": "'true'" } }, ngImport: i0 }); }
|
|
21
|
+
}
|
|
22
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerFocusableDirective, decorators: [{
|
|
23
|
+
type: Directive,
|
|
24
|
+
args: [{
|
|
25
|
+
selector: "[monaPagerFocusable]",
|
|
26
|
+
host: {
|
|
27
|
+
"[attr.data-mona-pager-focusable]": "'true'"
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
}] });
|
|
31
|
+
|
|
32
|
+
class PagerInfoTemplateDirective {
|
|
33
|
+
constructor() {
|
|
34
|
+
this.templateRef = inject(TemplateRef);
|
|
35
|
+
}
|
|
36
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerInfoTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
37
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PagerInfoTemplateDirective, isStandalone: true, selector: "ng-template[monaPagerInfoTemplate]", ngImport: i0 }); }
|
|
38
|
+
}
|
|
39
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerInfoTemplateDirective, decorators: [{
|
|
40
|
+
type: Directive,
|
|
41
|
+
args: [{
|
|
42
|
+
selector: "ng-template[monaPagerInfoTemplate]"
|
|
43
|
+
}]
|
|
44
|
+
}] });
|
|
45
|
+
|
|
46
|
+
class PagerNavigationButtonsTemplateDirective {
|
|
47
|
+
constructor() {
|
|
48
|
+
this.templateRef = inject(TemplateRef);
|
|
49
|
+
this.type = input.required(/* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
51
|
+
}
|
|
52
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerNavigationButtonsTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
53
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: PagerNavigationButtonsTemplateDirective, isStandalone: true, selector: "ng-template[monaPagerNavigationButtonsTemplate]", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
54
|
+
}
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerNavigationButtonsTemplateDirective, decorators: [{
|
|
56
|
+
type: Directive,
|
|
57
|
+
args: [{
|
|
58
|
+
selector: "ng-template[monaPagerNavigationButtonsTemplate]"
|
|
59
|
+
}]
|
|
60
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }] } });
|
|
61
|
+
|
|
62
|
+
class PagerNumericButtonsTemplateDirective {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.templateRef = inject(TemplateRef);
|
|
65
|
+
}
|
|
66
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerNumericButtonsTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
67
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PagerNumericButtonsTemplateDirective, isStandalone: true, selector: "ng-template[monaPagerNumericButtonsTemplate]", ngImport: i0 }); }
|
|
68
|
+
}
|
|
69
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerNumericButtonsTemplateDirective, decorators: [{
|
|
70
|
+
type: Directive,
|
|
71
|
+
args: [{
|
|
72
|
+
selector: "ng-template[monaPagerNumericButtonsTemplate]"
|
|
73
|
+
}]
|
|
74
|
+
}] });
|
|
75
|
+
|
|
76
|
+
class PagerPageSizeTemplateDirective {
|
|
77
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerPageSizeTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
78
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PagerPageSizeTemplateDirective, isStandalone: true, selector: "ng-template[monaPagerPageSizeTemplate]", ngImport: i0 }); }
|
|
79
|
+
}
|
|
80
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerPageSizeTemplateDirective, decorators: [{
|
|
81
|
+
type: Directive,
|
|
82
|
+
args: [{
|
|
83
|
+
selector: "ng-template[monaPagerPageSizeTemplate]"
|
|
84
|
+
}]
|
|
85
|
+
}] });
|
|
86
|
+
|
|
87
|
+
class PageSizeChangeEvent extends PreventableEvent {
|
|
88
|
+
constructor(newPageSize, oldPageSize) {
|
|
89
|
+
super("pageSizeChange");
|
|
90
|
+
this.newPageSize = newPageSize;
|
|
91
|
+
this.oldPageSize = oldPageSize;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const pagerBaseVariants = cva(`
|
|
96
|
+
flex py-1 px-2
|
|
97
|
+
bg-background text-foreground
|
|
98
|
+
border border-border
|
|
99
|
+
text-sm
|
|
100
|
+
[&_mona-numeric-text-box]:ml-4
|
|
101
|
+
[&_mona-numeric-text-box]:w-12
|
|
102
|
+
[&_mona-numeric-text-box_input]:text-center
|
|
103
|
+
[&_mona-numeric-text-box_input]:bg-input-background
|
|
104
|
+
|
|
105
|
+
[&_mona-dropdown-list]:mx-1
|
|
106
|
+
[&_mona-dropdown-list]:my-0
|
|
107
|
+
`, {
|
|
108
|
+
variants: {
|
|
109
|
+
rounded: {
|
|
110
|
+
none: "rounded-none",
|
|
111
|
+
small: "rounded-sm",
|
|
112
|
+
medium: "rounded-md",
|
|
113
|
+
large: "rounded-lg",
|
|
114
|
+
full: "rounded-full"
|
|
115
|
+
},
|
|
116
|
+
size: {
|
|
117
|
+
small: "text-xs",
|
|
118
|
+
medium: "text-sm",
|
|
119
|
+
large: "text-base"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const pagerInfoVariants = cva(`
|
|
124
|
+
flex items-center justify-end
|
|
125
|
+
flex-1 pl-2 whitespace-nowrap
|
|
126
|
+
`);
|
|
127
|
+
const pagerInputVariants = cva(`
|
|
128
|
+
flex items-center
|
|
129
|
+
[&_mona-numeric-text-box]:w-12
|
|
130
|
+
[&_mona-numeric-text-box]:mx-1
|
|
131
|
+
|
|
132
|
+
`);
|
|
133
|
+
const pagerListVariants = cva(`
|
|
134
|
+
flex flex-wrap
|
|
135
|
+
[&_li]:list-none
|
|
136
|
+
[&_li]:flex
|
|
137
|
+
[&_li]:items-center
|
|
138
|
+
[&_li]:justify-center
|
|
139
|
+
`);
|
|
140
|
+
const pagerListItemVariants = cva("", {
|
|
141
|
+
variants: {
|
|
142
|
+
active: {
|
|
143
|
+
true: "font-semibold",
|
|
144
|
+
false: ""
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
defaultVariants: {
|
|
148
|
+
active: false
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const pagerBaseThemeVariants = (theme) => {
|
|
153
|
+
switch (theme) {
|
|
154
|
+
case "mona":
|
|
155
|
+
return pagerBaseVariants;
|
|
156
|
+
default:
|
|
157
|
+
return pagerBaseVariants;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const pagerInfoThemeVariants = (theme) => {
|
|
161
|
+
switch (theme) {
|
|
162
|
+
case "mona":
|
|
163
|
+
return pagerInfoVariants;
|
|
164
|
+
default:
|
|
165
|
+
return pagerInfoVariants;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const pagerInputThemeVariants = (theme) => {
|
|
169
|
+
switch (theme) {
|
|
170
|
+
case "mona":
|
|
171
|
+
return pagerInputVariants;
|
|
172
|
+
default:
|
|
173
|
+
return pagerInputVariants;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const pagerListThemeVariants = (theme) => {
|
|
177
|
+
switch (theme) {
|
|
178
|
+
case "mona":
|
|
179
|
+
return pagerListVariants;
|
|
180
|
+
default:
|
|
181
|
+
return pagerListVariants;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const pagerListItemThemeVariants = (theme) => {
|
|
185
|
+
switch (theme) {
|
|
186
|
+
case "mona":
|
|
187
|
+
return pagerListItemVariants;
|
|
188
|
+
default:
|
|
189
|
+
return pagerListItemVariants;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const PAGER_FOCUSABLE_ATTRIBUTE = "data-mona-pager-focusable";
|
|
194
|
+
const FOCUSABLE_TARGET_SELECTOR = "button, input, select, textarea, a[href], [tabindex]";
|
|
195
|
+
class PagerComponent {
|
|
196
|
+
#document;
|
|
197
|
+
#hostElementRef;
|
|
198
|
+
#infoVisible;
|
|
199
|
+
#innerNavigationActive;
|
|
200
|
+
#managedFocusTargets;
|
|
201
|
+
#originalTabIndices;
|
|
202
|
+
#skip;
|
|
203
|
+
#themeService;
|
|
204
|
+
#widthObserver;
|
|
205
|
+
#previousPageSize;
|
|
206
|
+
constructor() {
|
|
207
|
+
this.#document = inject(DOCUMENT);
|
|
208
|
+
this.#hostElementRef = inject(ElementRef);
|
|
209
|
+
this.#infoVisible = signal(true, /* @ts-ignore */
|
|
210
|
+
...(ngDevMode ? [{ debugName: "#infoVisible" }] : /* istanbul ignore next */ []));
|
|
211
|
+
this.#innerNavigationActive = signal(false, /* @ts-ignore */
|
|
212
|
+
...(ngDevMode ? [{ debugName: "#innerNavigationActive" }] : /* istanbul ignore next */ []));
|
|
213
|
+
this.#managedFocusTargets = new Set();
|
|
214
|
+
this.#originalTabIndices = new WeakMap();
|
|
215
|
+
this.#skip = linkedSignal(() => this.skip(), /* @ts-ignore */
|
|
216
|
+
...(ngDevMode ? [{ debugName: "#skip" }] : /* istanbul ignore next */ []));
|
|
217
|
+
this.#themeService = inject(ThemeService);
|
|
218
|
+
this.#widthObserver = null;
|
|
219
|
+
this.#previousPageSize = 10;
|
|
220
|
+
this.navigationButtonsTemplateList = contentChildren(PagerNavigationButtonsTemplateDirective, /* @ts-ignore */
|
|
221
|
+
...(ngDevMode ? [{ debugName: "navigationButtonsTemplateList" }] : /* istanbul ignore next */ []));
|
|
222
|
+
this.baseClasses = computed(() => {
|
|
223
|
+
const theme = this.#themeService.theme();
|
|
224
|
+
const rounded = this.rounded();
|
|
225
|
+
const userClasses = this.userClasses();
|
|
226
|
+
const classes = pagerBaseThemeVariants(theme)({ rounded });
|
|
227
|
+
return twMerge(classes, userClasses);
|
|
228
|
+
}, /* @ts-ignore */
|
|
229
|
+
...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
|
|
230
|
+
this.firstPageLabel = "First page";
|
|
231
|
+
this.firstPageNavigationTemplate = computed(() => {
|
|
232
|
+
const navigationTemplates = this.navigationButtonsTemplateList();
|
|
233
|
+
return navigationTemplates.find(t => t.type() === "first");
|
|
234
|
+
}, /* @ts-ignore */
|
|
235
|
+
...(ngDevMode ? [{ debugName: "firstPageNavigationTemplate" }] : /* istanbul ignore next */ []));
|
|
236
|
+
this.iconSize = computed(() => {
|
|
237
|
+
const size = this.size();
|
|
238
|
+
switch (size) {
|
|
239
|
+
case "small":
|
|
240
|
+
return 18;
|
|
241
|
+
case "medium":
|
|
242
|
+
return 20;
|
|
243
|
+
case "large":
|
|
244
|
+
return 22;
|
|
245
|
+
default:
|
|
246
|
+
return 20;
|
|
247
|
+
}
|
|
248
|
+
}, /* @ts-ignore */
|
|
249
|
+
...(ngDevMode ? [{ debugName: "iconSize" }] : /* istanbul ignore next */ []));
|
|
250
|
+
this.infoClasses = computed(() => {
|
|
251
|
+
const theme = this.#themeService.theme();
|
|
252
|
+
return pagerInfoThemeVariants(theme)();
|
|
253
|
+
}, /* @ts-ignore */
|
|
254
|
+
...(ngDevMode ? [{ debugName: "infoClasses" }] : /* istanbul ignore next */ []));
|
|
255
|
+
this.infoVisible = computed(() => {
|
|
256
|
+
const showInfo = this.showInfo();
|
|
257
|
+
const visible = this.#infoVisible();
|
|
258
|
+
return showInfo && visible;
|
|
259
|
+
}, /* @ts-ignore */
|
|
260
|
+
...(ngDevMode ? [{ debugName: "infoVisible" }] : /* istanbul ignore next */ []));
|
|
261
|
+
this.inputClasses = computed(() => {
|
|
262
|
+
const theme = this.#themeService.theme();
|
|
263
|
+
return pagerInputThemeVariants(theme)();
|
|
264
|
+
}, /* @ts-ignore */
|
|
265
|
+
...(ngDevMode ? [{ debugName: "inputClasses" }] : /* istanbul ignore next */ []));
|
|
266
|
+
this.inputValue = linkedSignal(() => this.page(), /* @ts-ignore */
|
|
267
|
+
...(ngDevMode ? [{ debugName: "inputValue" }] : /* istanbul ignore next */ []));
|
|
268
|
+
this.jumpNextLabel = computed(() => `Jump forward ${this.visiblePages()} pages`, /* @ts-ignore */
|
|
269
|
+
...(ngDevMode ? [{ debugName: "jumpNextLabel" }] : /* istanbul ignore next */ []));
|
|
270
|
+
this.jumpPreviousLabel = computed(() => `Jump back ${this.visiblePages()} pages`, /* @ts-ignore */
|
|
271
|
+
...(ngDevMode ? [{ debugName: "jumpPreviousLabel" }] : /* istanbul ignore next */ []));
|
|
272
|
+
this.lastPageLabel = "Last page";
|
|
273
|
+
this.lastPageNavigationTemplate = computed(() => {
|
|
274
|
+
const navigationTemplates = this.navigationButtonsTemplateList();
|
|
275
|
+
return navigationTemplates.find(t => t.type() === "last");
|
|
276
|
+
}, /* @ts-ignore */
|
|
277
|
+
...(ngDevMode ? [{ debugName: "lastPageNavigationTemplate" }] : /* istanbul ignore next */ []));
|
|
278
|
+
this.listClasses = computed(() => {
|
|
279
|
+
const theme = this.#themeService.theme();
|
|
280
|
+
return pagerListThemeVariants(theme)();
|
|
281
|
+
}, /* @ts-ignore */
|
|
282
|
+
...(ngDevMode ? [{ debugName: "listClasses" }] : /* istanbul ignore next */ []));
|
|
283
|
+
this.nextJumperVisible = computed(() => {
|
|
284
|
+
const pages = this.pages();
|
|
285
|
+
const visiblePages = this.visiblePages();
|
|
286
|
+
return pages.length > visiblePages && pages[pages.length - 1].page - pages[pages.length - 2].page > 1;
|
|
287
|
+
}, /* @ts-ignore */
|
|
288
|
+
...(ngDevMode ? [{ debugName: "nextJumperVisible" }] : /* istanbul ignore next */ []));
|
|
289
|
+
this.nextPageLabel = "Next page";
|
|
290
|
+
this.nextPageNavigationTemplate = computed(() => {
|
|
291
|
+
const navigationTemplates = this.navigationButtonsTemplateList();
|
|
292
|
+
return navigationTemplates.find(t => t.type() === "next");
|
|
293
|
+
}, /* @ts-ignore */
|
|
294
|
+
...(ngDevMode ? [{ debugName: "nextPageNavigationTemplate" }] : /* istanbul ignore next */ []));
|
|
295
|
+
this.numericButtonsTemplate = contentChild(PagerNumericButtonsTemplateDirective, /* @ts-ignore */
|
|
296
|
+
...(ngDevMode ? [{ debugName: "numericButtonsTemplate" }] : /* istanbul ignore next */ []));
|
|
297
|
+
this.page = computed(() => Math.floor(this.#skip() / this.pagerPageSize()) + 1, /* @ts-ignore */
|
|
298
|
+
...(ngDevMode ? [{ debugName: "page" }] : /* istanbul ignore next */ []));
|
|
299
|
+
this.pageCount = computed(() => Math.ceil(this.total() / this.pagerPageSize()), /* @ts-ignore */
|
|
300
|
+
...(ngDevMode ? [{ debugName: "pageCount" }] : /* istanbul ignore next */ []));
|
|
301
|
+
this.pageInputVisible = signal(true, /* @ts-ignore */
|
|
302
|
+
...(ngDevMode ? [{ debugName: "pageInputVisible" }] : /* istanbul ignore next */ []));
|
|
303
|
+
this.pageList = computed(() => {
|
|
304
|
+
return range(1, this.pageCount()).toArray();
|
|
305
|
+
}, /* @ts-ignore */
|
|
306
|
+
...(ngDevMode ? [{ debugName: "pageList" }] : /* istanbul ignore next */ []));
|
|
307
|
+
this.pageListVisible = signal(true, /* @ts-ignore */
|
|
308
|
+
...(ngDevMode ? [{ debugName: "pageListVisible" }] : /* istanbul ignore next */ []));
|
|
309
|
+
this.pageSizeDropdownList = viewChild("pageSizeDropdownList", /* @ts-ignore */
|
|
310
|
+
...(ngDevMode ? [{ debugName: "pageSizeDropdownList" }] : /* istanbul ignore next */ []));
|
|
311
|
+
this.pageSizeDropdownData = computed(() => {
|
|
312
|
+
const values = this.pageSizeValues();
|
|
313
|
+
if (values === false || (Array.isArray(values) && values.length === 0)) {
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
if (Array.isArray(values)) {
|
|
317
|
+
return values;
|
|
318
|
+
}
|
|
319
|
+
return [5, 10, 20, 50, 100];
|
|
320
|
+
}, /* @ts-ignore */
|
|
321
|
+
...(ngDevMode ? [{ debugName: "pageSizeDropdownData" }] : /* istanbul ignore next */ []));
|
|
322
|
+
this.pageSizeTemplate = contentChild(PagerPageSizeTemplateDirective, { ...(ngDevMode ? { debugName: "pageSizeTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
323
|
+
this.pagerInfo = computed(() => {
|
|
324
|
+
const start = (this.page() - 1) * this.pagerPageSize() + 1;
|
|
325
|
+
const end = Math.min(this.page() * this.pagerPageSize(), this.total());
|
|
326
|
+
return `${start} - ${end} of ${this.total()} items`;
|
|
327
|
+
}, /* @ts-ignore */
|
|
328
|
+
...(ngDevMode ? [{ debugName: "pagerInfo" }] : /* istanbul ignore next */ []));
|
|
329
|
+
this.pagerInfoTemplate = contentChild(PagerInfoTemplateDirective, /* @ts-ignore */
|
|
330
|
+
...(ngDevMode ? [{ debugName: "pagerInfoTemplate" }] : /* istanbul ignore next */ []));
|
|
331
|
+
this.pagerInfoTemplateContext = computed(() => {
|
|
332
|
+
return {
|
|
333
|
+
currentPage: this.page(),
|
|
334
|
+
pageSize: this.pagerPageSize(),
|
|
335
|
+
skip: this.#skip(),
|
|
336
|
+
total: this.total(),
|
|
337
|
+
totalPages: this.pageCount()
|
|
338
|
+
};
|
|
339
|
+
}, /* @ts-ignore */
|
|
340
|
+
...(ngDevMode ? [{ debugName: "pagerInfoTemplateContext" }] : /* istanbul ignore next */ []));
|
|
341
|
+
this.pagerPageSize = linkedSignal(() => this.pageSize(), /* @ts-ignore */
|
|
342
|
+
...(ngDevMode ? [{ debugName: "pagerPageSize" }] : /* istanbul ignore next */ []));
|
|
343
|
+
this.pages = computed(() => {
|
|
344
|
+
return this.preparePages(this.page(), this.visiblePages(), this.pageCount());
|
|
345
|
+
}, /* @ts-ignore */
|
|
346
|
+
...(ngDevMode ? [{ debugName: "pages" }] : /* istanbul ignore next */ []));
|
|
347
|
+
this.previousJumperVisible = computed(() => this.pages().length > this.visiblePages() && this.pages()[1].page - 1 > 1, /* @ts-ignore */
|
|
348
|
+
...(ngDevMode ? [{ debugName: "previousJumperVisible" }] : /* istanbul ignore next */ []));
|
|
349
|
+
this.previousPageLabel = "Previous page";
|
|
350
|
+
this.previousPageNavigationTemplate = computed(() => {
|
|
351
|
+
const navigationTemplates = this.navigationButtonsTemplateList();
|
|
352
|
+
return navigationTemplates.find(t => t.type() === "previous");
|
|
353
|
+
}, /* @ts-ignore */
|
|
354
|
+
...(ngDevMode ? [{ debugName: "previousPageNavigationTemplate" }] : /* istanbul ignore next */ []));
|
|
355
|
+
/**
|
|
356
|
+
* @description Shows the first and last page navigation buttons.
|
|
357
|
+
* @default true
|
|
358
|
+
*/
|
|
359
|
+
this.firstLast = input(true, /* @ts-ignore */
|
|
360
|
+
...(ngDevMode ? [{ debugName: "firstLast" }] : /* istanbul ignore next */ []));
|
|
361
|
+
/**
|
|
362
|
+
* @description Enables keyboard navigation on the pager wrapper and its inner controls.
|
|
363
|
+
* @default true
|
|
364
|
+
*/
|
|
365
|
+
this.navigable = input(true, /* @ts-ignore */
|
|
366
|
+
...(ngDevMode ? [{ debugName: "navigable" }] : /* istanbul ignore next */ []));
|
|
367
|
+
/**
|
|
368
|
+
* @description Emitted when the current page changes.
|
|
369
|
+
*/
|
|
370
|
+
this.pageChange = output();
|
|
371
|
+
/**
|
|
372
|
+
* @description Shows a numeric input for jumping directly to a page.
|
|
373
|
+
* @default false
|
|
374
|
+
*/
|
|
375
|
+
this.pageInput = input(false, /* @ts-ignore */
|
|
376
|
+
...(ngDevMode ? [{ debugName: "pageInput" }] : /* istanbul ignore next */ []));
|
|
377
|
+
/**
|
|
378
|
+
* @description Number of items displayed per page.
|
|
379
|
+
* @default 5
|
|
380
|
+
*/
|
|
381
|
+
this.pageSize = input(5, /* @ts-ignore */
|
|
382
|
+
...(ngDevMode ? [{ debugName: "pageSize" }] : /* istanbul ignore next */ []));
|
|
383
|
+
/**
|
|
384
|
+
* @description Emitted when the page size changes. Cancelable via `preventDefault()` on the event.
|
|
385
|
+
*/
|
|
386
|
+
this.pageSizeChange = output();
|
|
387
|
+
/**
|
|
388
|
+
* @description Page-size options shown in the page-size dropdown. Set to `false` or an empty array to hide the dropdown.
|
|
389
|
+
* @default [5, 10, 20, 50, 100]
|
|
390
|
+
*/
|
|
391
|
+
this.pageSizeValues = input([5, 10, 20, 50, 100], /* @ts-ignore */
|
|
392
|
+
...(ngDevMode ? [{ debugName: "pageSizeValues" }] : /* istanbul ignore next */ []));
|
|
393
|
+
/**
|
|
394
|
+
* @description Shows the previous and next page navigation buttons.
|
|
395
|
+
* @default true
|
|
396
|
+
*/
|
|
397
|
+
this.previousNext = input(true, /* @ts-ignore */
|
|
398
|
+
...(ngDevMode ? [{ debugName: "previousNext" }] : /* istanbul ignore next */ []));
|
|
399
|
+
/**
|
|
400
|
+
* @description Collapses sections of the pager as the host element narrows.
|
|
401
|
+
* @default true
|
|
402
|
+
*/
|
|
403
|
+
this.responsive = input(true, /* @ts-ignore */
|
|
404
|
+
...(ngDevMode ? [{ debugName: "responsive" }] : /* istanbul ignore next */ []));
|
|
405
|
+
/**
|
|
406
|
+
* @description Border-radius preset applied to the component.
|
|
407
|
+
* @default "medium"
|
|
408
|
+
*/
|
|
409
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
410
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
411
|
+
/**
|
|
412
|
+
* @description Displays the summary of the current page range and total item count.
|
|
413
|
+
* @default true
|
|
414
|
+
*/
|
|
415
|
+
this.showInfo = input(true, /* @ts-ignore */
|
|
416
|
+
...(ngDevMode ? [{ debugName: "showInfo" }] : /* istanbul ignore next */ []));
|
|
417
|
+
/**
|
|
418
|
+
* @description Size preset controlling the component's dimensions.
|
|
419
|
+
* @default "medium"
|
|
420
|
+
*/
|
|
421
|
+
this.size = input("medium", /* @ts-ignore */
|
|
422
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
423
|
+
/**
|
|
424
|
+
* @description Number of items to skip before the current page. Determines the current page together with `pageSize`.
|
|
425
|
+
* @default 0
|
|
426
|
+
*/
|
|
427
|
+
this.skip = input(0, /* @ts-ignore */
|
|
428
|
+
...(ngDevMode ? [{ debugName: "skip" }] : /* istanbul ignore next */ []));
|
|
429
|
+
/**
|
|
430
|
+
* @description Total number of items in the paged collection.
|
|
431
|
+
* @default 0
|
|
432
|
+
*/
|
|
433
|
+
this.total = input(0, /* @ts-ignore */
|
|
434
|
+
...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
435
|
+
/**
|
|
436
|
+
* @description Visual mode of the pager: numeric page buttons, or a page-jump input.
|
|
437
|
+
* @default "numeric"
|
|
438
|
+
*/
|
|
439
|
+
this.type = input("numeric", /* @ts-ignore */
|
|
440
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
441
|
+
/**
|
|
442
|
+
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
443
|
+
* @default ""
|
|
444
|
+
*/
|
|
445
|
+
this.userClasses = input("", { ...(ngDevMode ? { debugName: "userClasses" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
446
|
+
/**
|
|
447
|
+
* @description Number of numeric page buttons shown at once before collapsing into jump controls.
|
|
448
|
+
* @default 5
|
|
449
|
+
*/
|
|
450
|
+
this.visiblePages = input(5, /* @ts-ignore */
|
|
451
|
+
...(ngDevMode ? [{ debugName: "visiblePages" }] : /* istanbul ignore next */ []));
|
|
452
|
+
effect(() => {
|
|
453
|
+
const pageSize = this.pageSize();
|
|
454
|
+
untracked(() => (this.#previousPageSize = pageSize));
|
|
455
|
+
});
|
|
456
|
+
effect(() => {
|
|
457
|
+
const navigable = this.navigable();
|
|
458
|
+
if (!navigable) {
|
|
459
|
+
untracked(() => {
|
|
460
|
+
this.#innerNavigationActive.set(false);
|
|
461
|
+
this.restoreManagedFocusTargets();
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
effect(() => {
|
|
466
|
+
const page = this.page();
|
|
467
|
+
untracked(() => this.pageChange.emit({ page, skip: this.#skip(), take: this.pagerPageSize() }));
|
|
468
|
+
});
|
|
469
|
+
afterRenderEffect(() => {
|
|
470
|
+
if (this.responsive()) {
|
|
471
|
+
this.#widthObserver = new ResizeObserver(() => {
|
|
472
|
+
untracked(() => {
|
|
473
|
+
this.#infoVisible.set(this.#hostElementRef.nativeElement.clientWidth >= 790);
|
|
474
|
+
this.pageInputVisible.set(this.#hostElementRef.nativeElement.clientWidth >= 640);
|
|
475
|
+
this.pageListVisible.set(this.#hostElementRef.nativeElement.clientWidth >= 480);
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
this.#widthObserver.observe(this.#hostElementRef.nativeElement);
|
|
479
|
+
}
|
|
480
|
+
else if (this.#widthObserver) {
|
|
481
|
+
untracked(() => {
|
|
482
|
+
this.#infoVisible.set(true);
|
|
483
|
+
this.pageInputVisible.set(true);
|
|
484
|
+
this.pageListVisible.set(true);
|
|
485
|
+
});
|
|
486
|
+
this.#widthObserver.disconnect();
|
|
487
|
+
this.#widthObserver = null;
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
afterRenderEffect(() => {
|
|
491
|
+
this.navigable();
|
|
492
|
+
this.#innerNavigationActive();
|
|
493
|
+
this.firstLast();
|
|
494
|
+
this.page();
|
|
495
|
+
this.pageCount();
|
|
496
|
+
this.pageInput();
|
|
497
|
+
this.pageInputVisible();
|
|
498
|
+
this.pageListVisible();
|
|
499
|
+
this.pageSizeDropdownData();
|
|
500
|
+
this.pages();
|
|
501
|
+
this.previousNext();
|
|
502
|
+
this.type();
|
|
503
|
+
untracked(() => this.syncFocusableTabIndexes());
|
|
504
|
+
});
|
|
505
|
+
inject(DestroyRef).onDestroy(() => this.#widthObserver?.disconnect());
|
|
506
|
+
}
|
|
507
|
+
onJumpNextClick() {
|
|
508
|
+
const page = Math.min(this.page() + this.visiblePages(), this.pageCount());
|
|
509
|
+
this.setPage(page);
|
|
510
|
+
}
|
|
511
|
+
onJumpPreviousClick() {
|
|
512
|
+
const page = Math.max(this.page() - this.visiblePages(), 1);
|
|
513
|
+
this.setPage(page);
|
|
514
|
+
}
|
|
515
|
+
onKeydown(event) {
|
|
516
|
+
if (!this.navigable()) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (event.key === NavigationKeys.Home) {
|
|
520
|
+
event.preventDefault();
|
|
521
|
+
this.setKeyboardPage(1);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (event.key === NavigationKeys.End) {
|
|
525
|
+
event.preventDefault();
|
|
526
|
+
this.setKeyboardPage(this.pageCount());
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (this.#innerNavigationActive()) {
|
|
530
|
+
this.handleInnerNavigationKeydown(event);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
if (event.target !== this.#hostElementRef.nativeElement) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
switch (event.key) {
|
|
537
|
+
case NavigationKeys.Enter:
|
|
538
|
+
event.preventDefault();
|
|
539
|
+
this.activateInnerNavigation();
|
|
540
|
+
break;
|
|
541
|
+
case NavigationKeys.ArrowLeft:
|
|
542
|
+
case NavigationKeys.PageUp:
|
|
543
|
+
event.preventDefault();
|
|
544
|
+
this.setKeyboardPage(this.page() - 1);
|
|
545
|
+
break;
|
|
546
|
+
case NavigationKeys.ArrowRight:
|
|
547
|
+
case NavigationKeys.PageDown:
|
|
548
|
+
event.preventDefault();
|
|
549
|
+
this.setKeyboardPage(this.page() + 1);
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
onNextPageClick() {
|
|
554
|
+
const page = Math.min(this.page() + 1, this.pageCount());
|
|
555
|
+
this.setPage(page);
|
|
556
|
+
}
|
|
557
|
+
onPageClick(page) {
|
|
558
|
+
if (page === this.page()) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
this.setPage(page);
|
|
562
|
+
}
|
|
563
|
+
onPageInputBlur() {
|
|
564
|
+
if (this.inputValue() === null || this.inputValue() === this.page()) {
|
|
565
|
+
this.inputValue.set(this.page());
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (this.inputValue() < 1) {
|
|
569
|
+
this.inputValue.set(1);
|
|
570
|
+
}
|
|
571
|
+
else if (this.inputValue() > this.pageCount()) {
|
|
572
|
+
this.inputValue.set(this.pageCount());
|
|
573
|
+
}
|
|
574
|
+
this.setPage(this.inputValue());
|
|
575
|
+
}
|
|
576
|
+
onPageSizeValueChange(value) {
|
|
577
|
+
if (value === this.pagerPageSize()) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const event = new PageSizeChangeEvent(value, this.pagerPageSize());
|
|
581
|
+
const pageSizeDropdownList = this.pageSizeDropdownList();
|
|
582
|
+
this.pageSizeChange.emit(event);
|
|
583
|
+
if (event.isDefaultPrevented()) {
|
|
584
|
+
this.pagerPageSize.set(this.#previousPageSize);
|
|
585
|
+
if (pageSizeDropdownList) {
|
|
586
|
+
pageSizeDropdownList.setValue(this.#previousPageSize);
|
|
587
|
+
}
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
this.#previousPageSize = value;
|
|
591
|
+
this.pagerPageSize.set(value);
|
|
592
|
+
if (pageSizeDropdownList) {
|
|
593
|
+
pageSizeDropdownList.setValue(value);
|
|
594
|
+
}
|
|
595
|
+
this.setPage(1);
|
|
596
|
+
}
|
|
597
|
+
onPreviousPageClick() {
|
|
598
|
+
const page = Math.max(this.page() - 1, 1);
|
|
599
|
+
this.setPage(page);
|
|
600
|
+
}
|
|
601
|
+
pageItemClasses(active) {
|
|
602
|
+
return pagerListItemThemeVariants(this.#themeService.theme())({ active });
|
|
603
|
+
}
|
|
604
|
+
activateInnerNavigation() {
|
|
605
|
+
const targets = this.getFocusableTargets();
|
|
606
|
+
if (targets.length === 0) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
this.#innerNavigationActive.set(true);
|
|
610
|
+
targets[0].focus();
|
|
611
|
+
}
|
|
612
|
+
focusNextTarget(backwards) {
|
|
613
|
+
const targets = this.getFocusableTargets();
|
|
614
|
+
if (targets.length === 0) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const activeElement = this.#document.activeElement;
|
|
618
|
+
const currentIndex = activeElement
|
|
619
|
+
? targets.findIndex(target => target === activeElement || target.contains(activeElement))
|
|
620
|
+
: -1;
|
|
621
|
+
const nextIndex = currentIndex === -1 ? 0 : (currentIndex + (backwards ? -1 : 1) + targets.length) % targets.length;
|
|
622
|
+
targets[nextIndex].focus();
|
|
623
|
+
}
|
|
624
|
+
getFocusableTargets() {
|
|
625
|
+
const host = this.#hostElementRef.nativeElement;
|
|
626
|
+
const markedElements = Array.from(host.querySelectorAll(`[${PAGER_FOCUSABLE_ATTRIBUTE}="true"]`));
|
|
627
|
+
const targets = [];
|
|
628
|
+
const seen = new Set();
|
|
629
|
+
for (const element of markedElements) {
|
|
630
|
+
const target = this.resolveFocusableTarget(element);
|
|
631
|
+
if (!target || seen.has(target) || this.isElementDisabled(target) || this.isElementHidden(target)) {
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
seen.add(target);
|
|
635
|
+
targets.push(target);
|
|
636
|
+
}
|
|
637
|
+
return targets;
|
|
638
|
+
}
|
|
639
|
+
handleInnerNavigationKeydown(event) {
|
|
640
|
+
if (event.key === NavigationKeys.Escape) {
|
|
641
|
+
event.preventDefault();
|
|
642
|
+
this.#innerNavigationActive.set(false);
|
|
643
|
+
this.#hostElementRef.nativeElement.focus();
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (event.key === "Tab") {
|
|
647
|
+
event.preventDefault();
|
|
648
|
+
this.focusNextTarget(event.shiftKey);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
isElementDisabled(element) {
|
|
652
|
+
if ((element instanceof HTMLButtonElement ||
|
|
653
|
+
element instanceof HTMLInputElement ||
|
|
654
|
+
element instanceof HTMLSelectElement ||
|
|
655
|
+
element instanceof HTMLTextAreaElement) &&
|
|
656
|
+
element.disabled) {
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
return element.getAttribute("aria-disabled") === "true" || element.hasAttribute("disabled");
|
|
660
|
+
}
|
|
661
|
+
isElementHidden(element) {
|
|
662
|
+
if (element.closest("[hidden]") || element.getAttribute("aria-hidden") === "true") {
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
const style = this.#document.defaultView?.getComputedStyle(element);
|
|
666
|
+
return style?.display === "none" || style?.visibility === "hidden";
|
|
667
|
+
}
|
|
668
|
+
overrideTabIndex(element) {
|
|
669
|
+
if (!this.#originalTabIndices.has(element)) {
|
|
670
|
+
this.#originalTabIndices.set(element, element.getAttribute("tabindex"));
|
|
671
|
+
}
|
|
672
|
+
element.setAttribute("tabindex", "-1");
|
|
673
|
+
this.#managedFocusTargets.add(element);
|
|
674
|
+
}
|
|
675
|
+
preparePages(currentPage, visiblePages, maxPages) {
|
|
676
|
+
const half = Math.floor(visiblePages / 2);
|
|
677
|
+
let first = 1;
|
|
678
|
+
let index = 0;
|
|
679
|
+
const pages = [];
|
|
680
|
+
if (maxPages <= 5) {
|
|
681
|
+
for (index = 1; index <= maxPages; index++) {
|
|
682
|
+
pages.push({ page: index, text: index.toString() });
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
else if (currentPage < visiblePages) {
|
|
686
|
+
pages.push({ page: first, text: first.toString() });
|
|
687
|
+
for (index = 2; index < (maxPages < visiblePages ? maxPages : visiblePages) + 1; index++) {
|
|
688
|
+
pages.push({ page: index, text: index.toString() });
|
|
689
|
+
}
|
|
690
|
+
pages.push({ page: maxPages, text: maxPages.toString() });
|
|
691
|
+
}
|
|
692
|
+
else if (currentPage >= visiblePages && currentPage <= maxPages - visiblePages) {
|
|
693
|
+
pages.push({ page: first, text: first.toString() });
|
|
694
|
+
for (index = currentPage - half; index < currentPage + visiblePages - half; index++) {
|
|
695
|
+
pages.push({ page: index, text: index.toString() });
|
|
696
|
+
}
|
|
697
|
+
pages.push({ page: maxPages, text: maxPages.toString() });
|
|
698
|
+
}
|
|
699
|
+
else if (currentPage >= maxPages - visiblePages) {
|
|
700
|
+
pages.push({ page: first, text: first.toString() });
|
|
701
|
+
index = maxPages - visiblePages < currentPage ? maxPages - visiblePages : currentPage;
|
|
702
|
+
for (; index <= maxPages; index++) {
|
|
703
|
+
pages.push({ page: index, text: index.toString() });
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return pages;
|
|
707
|
+
}
|
|
708
|
+
resolveFocusableTarget(element) {
|
|
709
|
+
if (element.matches(FOCUSABLE_TARGET_SELECTOR)) {
|
|
710
|
+
return element;
|
|
711
|
+
}
|
|
712
|
+
return (Array.from(element.querySelectorAll(FOCUSABLE_TARGET_SELECTOR)).find(target => !this.isElementDisabled(target) && !this.isElementHidden(target)) ?? null);
|
|
713
|
+
}
|
|
714
|
+
restoreManagedFocusTarget(element) {
|
|
715
|
+
const originalTabIndex = this.#originalTabIndices.get(element);
|
|
716
|
+
if (originalTabIndex == null) {
|
|
717
|
+
element.removeAttribute("tabindex");
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
element.setAttribute("tabindex", originalTabIndex);
|
|
721
|
+
}
|
|
722
|
+
this.#managedFocusTargets.delete(element);
|
|
723
|
+
}
|
|
724
|
+
restoreManagedFocusTargets() {
|
|
725
|
+
for (const element of Array.from(this.#managedFocusTargets)) {
|
|
726
|
+
this.restoreManagedFocusTarget(element);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
setKeyboardPage(page) {
|
|
730
|
+
const pageCount = this.pageCount();
|
|
731
|
+
if (pageCount < 1) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
this.setPage(Math.min(Math.max(page, 1), pageCount));
|
|
735
|
+
}
|
|
736
|
+
setPage(page) {
|
|
737
|
+
this.#skip.set((page - 1) * this.pagerPageSize());
|
|
738
|
+
}
|
|
739
|
+
syncFocusableTabIndexes() {
|
|
740
|
+
const focusableTargets = this.getFocusableTargets();
|
|
741
|
+
const currentTargets = new Set(focusableTargets);
|
|
742
|
+
for (const element of Array.from(this.#managedFocusTargets)) {
|
|
743
|
+
if (!this.navigable() || !currentTargets.has(element)) {
|
|
744
|
+
this.restoreManagedFocusTarget(element);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (!this.navigable()) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
for (const target of focusableTargets) {
|
|
751
|
+
this.overrideTabIndex(target);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
755
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PagerComponent, isStandalone: true, selector: "mona-pager", inputs: { firstLast: { classPropertyName: "firstLast", publicName: "firstLast", isSignal: true, isRequired: false, transformFunction: null }, navigable: { classPropertyName: "navigable", publicName: "navigable", isSignal: true, isRequired: false, transformFunction: null }, pageInput: { classPropertyName: "pageInput", publicName: "pageInput", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, pageSizeValues: { classPropertyName: "pageSizeValues", publicName: "pageSizeValues", isSignal: true, isRequired: false, transformFunction: null }, previousNext: { classPropertyName: "previousNext", publicName: "previousNext", isSignal: true, isRequired: false, transformFunction: null }, responsive: { classPropertyName: "responsive", publicName: "responsive", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, showInfo: { classPropertyName: "showInfo", publicName: "showInfo", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, skip: { classPropertyName: "skip", publicName: "skip", isSignal: true, isRequired: false, transformFunction: null }, total: { classPropertyName: "total", publicName: "total", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, userClasses: { classPropertyName: "userClasses", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, visiblePages: { classPropertyName: "visiblePages", publicName: "visiblePages", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageChange: "pageChange", pageSizeChange: "pageSizeChange" }, host: { listeners: { "keydown": "onKeydown($event)" }, properties: { "attr.tabindex": "navigable() ? 0 : null", "class": "baseClasses()" } }, queries: [{ propertyName: "navigationButtonsTemplateList", predicate: PagerNavigationButtonsTemplateDirective, isSignal: true }, { propertyName: "numericButtonsTemplate", first: true, predicate: PagerNumericButtonsTemplateDirective, descendants: true, isSignal: true }, { propertyName: "pageSizeTemplate", first: true, predicate: PagerPageSizeTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "pagerInfoTemplate", first: true, predicate: PagerInfoTemplateDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "pageSizeDropdownList", first: true, predicate: ["pageSizeDropdownList"], descendants: true, isSignal: true }], ngImport: i0, template: "@let numericButtonsTemplateRef = numericButtonsTemplate()?.templateRef;\r\n@let pageSizeTemplateRef = pageSizeTemplate();\r\n@let pagerInfoTemplateRef = pagerInfoTemplate()?.templateRef;\r\n\r\n@if (type() === \"numeric\") {\r\n @if (pageListVisible()) {\r\n <ol [class]=\"listClasses()\">\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"firstPageButton\"></ng-container>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"previousPageButton\"></ng-container>\r\n }\r\n\r\n @if (numericButtonsTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"numericButtonsTemplateRef\"\r\n [ngTemplateOutletContext]=\"{ totalPages: pageCount() }\"></ng-container>\r\n } @else {\r\n @if (pages().length !== 0) {\r\n <li [class]=\"pageItemClasses(page() === 1)\">\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [selected]=\"page() === 1\"\r\n [attr.aria-label]=\"'Page 1'\"\r\n [attr.aria-current]=\"page() === 1 ? 'page' : null\"\r\n (click)=\"onPageClick(1)\">\r\n 1\r\n </button>\r\n </li>\r\n }\r\n @if (previousJumperVisible()) {\r\n <li>\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"jumpPreviousLabel()\"\r\n (click)=\"onJumpPreviousClick()\">\r\n <svg lucideEllipsis [size]=\"iconSize()\"></svg>\r\n </button>\r\n </li>\r\n }\r\n\r\n @for (pageItem of pages() | monaSlice: 1 : pages().length - 1; track $index) {\r\n <li [attr.data-page]=\"pageItem.page\" [class]=\"pageItemClasses(page() === pageItem.page)\">\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [selected]=\"page() === pageItem.page\"\r\n [attr.aria-label]=\"'Page ' + pageItem.text\"\r\n [attr.aria-current]=\"page() === pageItem.page ? 'page' : null\"\r\n (click)=\"onPageClick(pageItem.page)\">\r\n {{ pageItem.text }}\r\n </button>\r\n </li>\r\n }\r\n\r\n @if (nextJumperVisible()) {\r\n <li>\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"jumpNextLabel()\"\r\n (click)=\"onJumpNextClick()\">\r\n <svg lucideEllipsis [size]=\"iconSize()\"></svg>\r\n </button>\r\n </li>\r\n }\r\n\r\n @if (pages().length > 1) {\r\n <li [class]=\"pageItemClasses(page() === pageCount())\">\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [selected]=\"page() === pageCount()\"\r\n [attr.aria-label]=\"'Page ' + pageCount()\"\r\n [attr.aria-current]=\"page() === pageCount() ? 'page' : null\"\r\n (click)=\"onPageClick(pageCount())\">\r\n {{ pageCount() }}\r\n </button>\r\n </li>\r\n }\r\n }\r\n\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"nextPageButton\"></ng-container>\r\n }\r\n\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"lastPageButton\"></ng-container>\r\n }\r\n\r\n @if (pageInputVisible() && pageInput()) {\r\n <li>\r\n <mona-numeric-text-box\r\n monaPagerFocusable\r\n [spinners]=\"false\"\r\n [minValue]=\"1\"\r\n [maxValue]=\"pageCount()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [ngModel]=\"inputValue()\"\r\n (ngModelChange)=\"inputValue.set($event)\"\r\n (inputBlur)=\"onPageInputBlur()\"></mona-numeric-text-box>\r\n </li>\r\n }\r\n\r\n @if (pageInputVisible() && pageSizeDropdownData().length > 0) {\r\n <li>\r\n @if (pageSizeTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"pageSizeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{ $implicit: pageSizeDropdownData() }\">\r\n </ng-container>\r\n } @else {\r\n <mona-dropdown-list\r\n monaPagerFocusable\r\n [data]=\"pageSizeDropdownData()\"\r\n [ngModel]=\"pageSize()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n (ngModelChange)=\"onPageSizeValueChange($event)\"\r\n #pageSizeDropdownList>\r\n <ng-template monaDropDownListValueTemplate let-item>\r\n <span>{{ item }} / page</span>\r\n </ng-template>\r\n </mona-dropdown-list>\r\n }\r\n </li>\r\n }\r\n </ol>\r\n }\r\n @if (infoVisible()) {\r\n @if (pagerInfoTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"pagerInfoTemplateRef\"\r\n [ngTemplateOutletContext]=\"pagerInfoTemplateContext()\"></ng-container>\r\n } @else {\r\n <span [class]=\"infoClasses()\">{{ pagerInfo() }}</span>\r\n }\r\n }\r\n}\r\n@if (type() === \"input\") {\r\n <div [class]=\"inputClasses()\">\r\n @if (pageListVisible()) {\r\n <ol [class]=\"listClasses()\">\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"firstPageButton\"></ng-container>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"previousPageButton\"></ng-container>\r\n }\r\n <li class=\"flex items-center gap-2 mx-2\">\r\n <span>Page</span>\r\n <mona-numeric-text-box\r\n monaPagerFocusable\r\n [spinners]=\"false\"\r\n [minValue]=\"1\"\r\n [maxValue]=\"pageCount()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [ngModel]=\"inputValue()\"\r\n (ngModelChange)=\"inputValue.set($event)\"\r\n (inputBlur)=\"onPageInputBlur()\"></mona-numeric-text-box>\r\n <span>of</span>\r\n <span>{{ pageCount() }}</span>\r\n </li>\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"nextPageButton\"></ng-container>\r\n }\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"lastPageButton\"></ng-container>\r\n }\r\n </ol>\r\n }\r\n </div>\r\n @if (infoVisible()) {\r\n @if (pagerInfoTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"pagerInfoTemplateRef\"\r\n [ngTemplateOutletContext]=\"pagerInfoTemplateContext()\"></ng-container>\r\n } @else {\r\n <span [class]=\"infoClasses()\">{{ pagerInfo() }}</span>\r\n }\r\n }\r\n}\r\n@if (!pageListVisible()) {\r\n <ol [class]=\"listClasses()\">\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"firstPageButton\"></ng-container>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"previousPageButton\"></ng-container>\r\n }\r\n @if (pageCount() !== 0) {\r\n <li>\r\n <mona-dropdown-list\r\n monaPagerFocusable\r\n [data]=\"pageList()\"\r\n [ngModel]=\"page()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n monaDropDownVirtualScroll\r\n (ngModelChange)=\"onPageClick($event)\"\r\n style=\"width: 75px\"></mona-dropdown-list>\r\n </li>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"nextPageButton\"></ng-container>\r\n }\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"lastPageButton\"></ng-container>\r\n }\r\n </ol>\r\n}\r\n\r\n<ng-template #firstPageButton>\r\n <li>\r\n @let firstPageTemplate = firstPageNavigationTemplate();\r\n @if (firstPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"firstPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() === 1\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"firstPageLabel\"\r\n (click)=\"onPageClick(1)\"\r\n [disabled]=\"page() === 1\">\r\n <svg lucideChevronsLeft [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n\r\n<ng-template #previousPageButton>\r\n <li>\r\n @let previousPageTemplate = previousPageNavigationTemplate();\r\n @if (previousPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"previousPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() <= 1\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [disabled]=\"page() <= 1\"\r\n [attr.aria-label]=\"previousPageLabel\"\r\n (click)=\"onPreviousPageClick()\">\r\n <svg lucideChevronLeft [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n\r\n<ng-template #nextPageButton>\r\n <li>\r\n @let nextPageTemplate = nextPageNavigationTemplate();\r\n @if (nextPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"nextPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() < 1 || page() === pageCount()\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [disabled]=\"page() < 1 || page() === pageCount()\"\r\n [attr.aria-label]=\"nextPageLabel\"\r\n (click)=\"onNextPageClick()\">\r\n <svg lucideChevronRight [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n\r\n<ng-template #lastPageButton>\r\n <li>\r\n @let lastPageTemplate = lastPageNavigationTemplate();\r\n @if (lastPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"lastPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() === pageCount()\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"lastPageLabel\"\r\n (click)=\"onPageClick(pageCount())\"\r\n [disabled]=\"page() === pageCount()\">\r\n <svg lucideChevronsRight [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "class"], outputs: ["disabledChange", "loadingChange", "lookChange", "selectedChange"] }, { kind: "component", type: NumericTextBoxComponent, selector: "mona-numeric-text-box", inputs: ["aria-label", "decimals", "disabled", "formatter", "maxValue", "minValue", "nullable", "readonly", "required", "invalid", "rounded", "size", "spinners", "step", "tabindex", "touched", "class", "value"], outputs: ["inputBlur", "inputFocus", "inputFocusOut", "touch", "valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: DropdownListComponent, selector: "mona-dropdown-list", inputs: ["aria-label", "aria-labelledby", "data", "disabled", "itemDisabled", "invalid", "loading", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "required", "rounded", "showClearButton", "size", "textField", "touched", "class", "valueField", "value"], outputs: ["close", "closed", "disabledChange", "open", "opened", "touch", "valueChange"] }, { kind: "directive", type: PagerFocusableDirective, selector: "[monaPagerFocusable]" }, { kind: "directive", type: DropdownVirtualScrollDirective, selector: " mona-auto-complete[monaDropDownVirtualScroll], mona-dropdown-list[monaDropDownVirtualScroll], mona-combo-box[monaDropDownVirtualScroll], mona-multi-select[monaDropDownVirtualScroll] ", inputs: ["monaDropDownVirtualScroll"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: DropdownListValueTemplateDirective, selector: "ng-template[monaDropDownListValueTemplate]" }, { kind: "component", type: LucideEllipsis, selector: "svg[lucideEllipsis], svg[lucideMoreHorizontal]" }, { kind: "component", type: LucideChevronsLeft, selector: "svg[lucideChevronsLeft]" }, { kind: "component", type: LucideChevronLeft, selector: "svg[lucideChevronLeft]" }, { kind: "component", type: LucideChevronRight, selector: "svg[lucideChevronRight]" }, { kind: "component", type: LucideChevronsRight, selector: "svg[lucideChevronsRight]" }, { kind: "pipe", type: SlicePipe, name: "monaSlice" }] }); }
|
|
756
|
+
}
|
|
757
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PagerComponent, decorators: [{
|
|
758
|
+
type: Component,
|
|
759
|
+
args: [{ selector: "mona-pager", imports: [
|
|
760
|
+
ButtonDirective,
|
|
761
|
+
NumericTextBoxComponent,
|
|
762
|
+
FormsModule,
|
|
763
|
+
DropdownListComponent,
|
|
764
|
+
PagerFocusableDirective,
|
|
765
|
+
SlicePipe,
|
|
766
|
+
DropdownVirtualScrollDirective,
|
|
767
|
+
NgTemplateOutlet,
|
|
768
|
+
DropdownListValueTemplateDirective,
|
|
769
|
+
LucideEllipsis,
|
|
770
|
+
LucideChevronsLeft,
|
|
771
|
+
LucideChevronLeft,
|
|
772
|
+
LucideChevronRight,
|
|
773
|
+
LucideChevronsRight
|
|
774
|
+
], host: {
|
|
775
|
+
"[attr.tabindex]": "navigable() ? 0 : null",
|
|
776
|
+
"[class]": "baseClasses()",
|
|
777
|
+
"(keydown)": "onKeydown($event)"
|
|
778
|
+
}, template: "@let numericButtonsTemplateRef = numericButtonsTemplate()?.templateRef;\r\n@let pageSizeTemplateRef = pageSizeTemplate();\r\n@let pagerInfoTemplateRef = pagerInfoTemplate()?.templateRef;\r\n\r\n@if (type() === \"numeric\") {\r\n @if (pageListVisible()) {\r\n <ol [class]=\"listClasses()\">\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"firstPageButton\"></ng-container>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"previousPageButton\"></ng-container>\r\n }\r\n\r\n @if (numericButtonsTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"numericButtonsTemplateRef\"\r\n [ngTemplateOutletContext]=\"{ totalPages: pageCount() }\"></ng-container>\r\n } @else {\r\n @if (pages().length !== 0) {\r\n <li [class]=\"pageItemClasses(page() === 1)\">\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [selected]=\"page() === 1\"\r\n [attr.aria-label]=\"'Page 1'\"\r\n [attr.aria-current]=\"page() === 1 ? 'page' : null\"\r\n (click)=\"onPageClick(1)\">\r\n 1\r\n </button>\r\n </li>\r\n }\r\n @if (previousJumperVisible()) {\r\n <li>\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"jumpPreviousLabel()\"\r\n (click)=\"onJumpPreviousClick()\">\r\n <svg lucideEllipsis [size]=\"iconSize()\"></svg>\r\n </button>\r\n </li>\r\n }\r\n\r\n @for (pageItem of pages() | monaSlice: 1 : pages().length - 1; track $index) {\r\n <li [attr.data-page]=\"pageItem.page\" [class]=\"pageItemClasses(page() === pageItem.page)\">\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [selected]=\"page() === pageItem.page\"\r\n [attr.aria-label]=\"'Page ' + pageItem.text\"\r\n [attr.aria-current]=\"page() === pageItem.page ? 'page' : null\"\r\n (click)=\"onPageClick(pageItem.page)\">\r\n {{ pageItem.text }}\r\n </button>\r\n </li>\r\n }\r\n\r\n @if (nextJumperVisible()) {\r\n <li>\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"jumpNextLabel()\"\r\n (click)=\"onJumpNextClick()\">\r\n <svg lucideEllipsis [size]=\"iconSize()\"></svg>\r\n </button>\r\n </li>\r\n }\r\n\r\n @if (pages().length > 1) {\r\n <li [class]=\"pageItemClasses(page() === pageCount())\">\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [selected]=\"page() === pageCount()\"\r\n [attr.aria-label]=\"'Page ' + pageCount()\"\r\n [attr.aria-current]=\"page() === pageCount() ? 'page' : null\"\r\n (click)=\"onPageClick(pageCount())\">\r\n {{ pageCount() }}\r\n </button>\r\n </li>\r\n }\r\n }\r\n\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"nextPageButton\"></ng-container>\r\n }\r\n\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"lastPageButton\"></ng-container>\r\n }\r\n\r\n @if (pageInputVisible() && pageInput()) {\r\n <li>\r\n <mona-numeric-text-box\r\n monaPagerFocusable\r\n [spinners]=\"false\"\r\n [minValue]=\"1\"\r\n [maxValue]=\"pageCount()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [ngModel]=\"inputValue()\"\r\n (ngModelChange)=\"inputValue.set($event)\"\r\n (inputBlur)=\"onPageInputBlur()\"></mona-numeric-text-box>\r\n </li>\r\n }\r\n\r\n @if (pageInputVisible() && pageSizeDropdownData().length > 0) {\r\n <li>\r\n @if (pageSizeTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"pageSizeTemplateRef\"\r\n [ngTemplateOutletContext]=\"{ $implicit: pageSizeDropdownData() }\">\r\n </ng-container>\r\n } @else {\r\n <mona-dropdown-list\r\n monaPagerFocusable\r\n [data]=\"pageSizeDropdownData()\"\r\n [ngModel]=\"pageSize()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n (ngModelChange)=\"onPageSizeValueChange($event)\"\r\n #pageSizeDropdownList>\r\n <ng-template monaDropDownListValueTemplate let-item>\r\n <span>{{ item }} / page</span>\r\n </ng-template>\r\n </mona-dropdown-list>\r\n }\r\n </li>\r\n }\r\n </ol>\r\n }\r\n @if (infoVisible()) {\r\n @if (pagerInfoTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"pagerInfoTemplateRef\"\r\n [ngTemplateOutletContext]=\"pagerInfoTemplateContext()\"></ng-container>\r\n } @else {\r\n <span [class]=\"infoClasses()\">{{ pagerInfo() }}</span>\r\n }\r\n }\r\n}\r\n@if (type() === \"input\") {\r\n <div [class]=\"inputClasses()\">\r\n @if (pageListVisible()) {\r\n <ol [class]=\"listClasses()\">\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"firstPageButton\"></ng-container>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"previousPageButton\"></ng-container>\r\n }\r\n <li class=\"flex items-center gap-2 mx-2\">\r\n <span>Page</span>\r\n <mona-numeric-text-box\r\n monaPagerFocusable\r\n [spinners]=\"false\"\r\n [minValue]=\"1\"\r\n [maxValue]=\"pageCount()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [ngModel]=\"inputValue()\"\r\n (ngModelChange)=\"inputValue.set($event)\"\r\n (inputBlur)=\"onPageInputBlur()\"></mona-numeric-text-box>\r\n <span>of</span>\r\n <span>{{ pageCount() }}</span>\r\n </li>\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"nextPageButton\"></ng-container>\r\n }\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"lastPageButton\"></ng-container>\r\n }\r\n </ol>\r\n }\r\n </div>\r\n @if (infoVisible()) {\r\n @if (pagerInfoTemplateRef) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"pagerInfoTemplateRef\"\r\n [ngTemplateOutletContext]=\"pagerInfoTemplateContext()\"></ng-container>\r\n } @else {\r\n <span [class]=\"infoClasses()\">{{ pagerInfo() }}</span>\r\n }\r\n }\r\n}\r\n@if (!pageListVisible()) {\r\n <ol [class]=\"listClasses()\">\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"firstPageButton\"></ng-container>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"previousPageButton\"></ng-container>\r\n }\r\n @if (pageCount() !== 0) {\r\n <li>\r\n <mona-dropdown-list\r\n monaPagerFocusable\r\n [data]=\"pageList()\"\r\n [ngModel]=\"page()\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n monaDropDownVirtualScroll\r\n (ngModelChange)=\"onPageClick($event)\"\r\n style=\"width: 75px\"></mona-dropdown-list>\r\n </li>\r\n }\r\n @if (previousNext()) {\r\n <ng-container [ngTemplateOutlet]=\"nextPageButton\"></ng-container>\r\n }\r\n @if (firstLast()) {\r\n <ng-container [ngTemplateOutlet]=\"lastPageButton\"></ng-container>\r\n }\r\n </ol>\r\n}\r\n\r\n<ng-template #firstPageButton>\r\n <li>\r\n @let firstPageTemplate = firstPageNavigationTemplate();\r\n @if (firstPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"firstPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() === 1\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"firstPageLabel\"\r\n (click)=\"onPageClick(1)\"\r\n [disabled]=\"page() === 1\">\r\n <svg lucideChevronsLeft [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n\r\n<ng-template #previousPageButton>\r\n <li>\r\n @let previousPageTemplate = previousPageNavigationTemplate();\r\n @if (previousPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"previousPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() <= 1\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [disabled]=\"page() <= 1\"\r\n [attr.aria-label]=\"previousPageLabel\"\r\n (click)=\"onPreviousPageClick()\">\r\n <svg lucideChevronLeft [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n\r\n<ng-template #nextPageButton>\r\n <li>\r\n @let nextPageTemplate = nextPageNavigationTemplate();\r\n @if (nextPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"nextPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() < 1 || page() === pageCount()\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [disabled]=\"page() < 1 || page() === pageCount()\"\r\n [attr.aria-label]=\"nextPageLabel\"\r\n (click)=\"onNextPageClick()\">\r\n <svg lucideChevronRight [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n\r\n<ng-template #lastPageButton>\r\n <li>\r\n @let lastPageTemplate = lastPageNavigationTemplate();\r\n @if (lastPageTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"lastPageTemplate.templateRef\"\r\n [ngTemplateOutletContext]=\"{\r\n totalPages: pageCount(),\r\n pageSize: pagerPageSize(),\r\n disabled: page() === pageCount()\r\n }\">\r\n </ng-container>\r\n } @else {\r\n <button\r\n monaPagerFocusable\r\n monaButton\r\n look=\"ghost\"\r\n [rounded]=\"rounded()\"\r\n [size]=\"size()\"\r\n [attr.aria-label]=\"lastPageLabel\"\r\n (click)=\"onPageClick(pageCount())\"\r\n [disabled]=\"page() === pageCount()\">\r\n <svg lucideChevronsRight [size]=\"iconSize()\"></svg>\r\n </button>\r\n }\r\n </li>\r\n</ng-template>\r\n" }]
|
|
779
|
+
}], ctorParameters: () => [], propDecorators: { navigationButtonsTemplateList: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => PagerNavigationButtonsTemplateDirective), { isSignal: true }] }], numericButtonsTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PagerNumericButtonsTemplateDirective), { isSignal: true }] }], pageSizeDropdownList: [{ type: i0.ViewChild, args: ["pageSizeDropdownList", { isSignal: true }] }], pageSizeTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PagerPageSizeTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], pagerInfoTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PagerInfoTemplateDirective), { isSignal: true }] }], firstLast: [{ type: i0.Input, args: [{ isSignal: true, alias: "firstLast", required: false }] }], navigable: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigable", required: false }] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], pageInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageInput", required: false }] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }], pageSizeChange: [{ type: i0.Output, args: ["pageSizeChange"] }], pageSizeValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSizeValues", required: false }] }], previousNext: [{ type: i0.Input, args: [{ isSignal: true, alias: "previousNext", required: false }] }], responsive: [{ type: i0.Input, args: [{ isSignal: true, alias: "responsive", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], showInfo: [{ type: i0.Input, args: [{ isSignal: true, alias: "showInfo", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], skip: [{ type: i0.Input, args: [{ isSignal: true, alias: "skip", required: false }] }], total: [{ type: i0.Input, args: [{ isSignal: true, alias: "total", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], userClasses: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], visiblePages: [{ type: i0.Input, args: [{ isSignal: true, alias: "visiblePages", required: false }] }] } });
|
|
780
|
+
|
|
781
|
+
/*
|
|
782
|
+
* Public API Surface of @nanahoshi/mona-ui/pager
|
|
783
|
+
*/
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Generated bundle index. Do not edit.
|
|
787
|
+
*/
|
|
788
|
+
|
|
789
|
+
export { PageSizeChangeEvent, PagerComponent, PagerInfoTemplateDirective, PagerNavigationButtonsTemplateDirective, PagerNumericButtonsTemplateDirective, PagerPageSizeTemplateDirective };
|
|
790
|
+
//# sourceMappingURL=nanahoshi-mona-ui-pager.mjs.map
|