ng-primitives 0.120.4 → 0.121.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.
Files changed (147) hide show
  1. package/example-theme/index.css +9 -0
  2. package/fesm2022/ng-primitives-a11y.mjs +5 -5
  3. package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
  4. package/fesm2022/ng-primitives-accordion.mjs +34 -51
  5. package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
  6. package/fesm2022/ng-primitives-ai.mjs +39 -52
  7. package/fesm2022/ng-primitives-ai.mjs.map +1 -1
  8. package/fesm2022/ng-primitives-autofill.mjs +4 -4
  9. package/fesm2022/ng-primitives-autofill.mjs.map +1 -1
  10. package/fesm2022/ng-primitives-avatar.mjs +14 -17
  11. package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
  12. package/fesm2022/ng-primitives-breadcrumbs.mjs +21 -21
  13. package/fesm2022/ng-primitives-breadcrumbs.mjs.map +1 -1
  14. package/fesm2022/ng-primitives-button.mjs +7 -9
  15. package/fesm2022/ng-primitives-button.mjs.map +1 -1
  16. package/fesm2022/ng-primitives-checkbox.mjs +15 -30
  17. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  18. package/fesm2022/ng-primitives-combobox.mjs +60 -92
  19. package/fesm2022/ng-primitives-combobox.mjs.map +1 -1
  20. package/fesm2022/ng-primitives-common.mjs +4 -4
  21. package/fesm2022/ng-primitives-common.mjs.map +1 -1
  22. package/fesm2022/ng-primitives-context-menu.mjs +68 -121
  23. package/fesm2022/ng-primitives-context-menu.mjs.map +1 -1
  24. package/fesm2022/ng-primitives-date-picker.mjs +91 -115
  25. package/fesm2022/ng-primitives-date-picker.mjs.map +1 -1
  26. package/fesm2022/ng-primitives-dialog.mjs +35 -51
  27. package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
  28. package/fesm2022/ng-primitives-file-upload.mjs +26 -53
  29. package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
  30. package/fesm2022/ng-primitives-focus-trap.mjs +5 -8
  31. package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
  32. package/fesm2022/ng-primitives-form-field.mjs +39 -44
  33. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  34. package/fesm2022/ng-primitives-input-otp.mjs +30 -43
  35. package/fesm2022/ng-primitives-input-otp.mjs.map +1 -1
  36. package/fesm2022/ng-primitives-input.mjs +6 -8
  37. package/fesm2022/ng-primitives-input.mjs.map +1 -1
  38. package/fesm2022/ng-primitives-interactions.mjs +31 -48
  39. package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
  40. package/fesm2022/ng-primitives-internal.mjs +39 -35
  41. package/fesm2022/ng-primitives-internal.mjs.map +1 -1
  42. package/fesm2022/ng-primitives-listbox.mjs +34 -48
  43. package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
  44. package/fesm2022/ng-primitives-menu.mjs +85 -151
  45. package/fesm2022/ng-primitives-menu.mjs.map +1 -1
  46. package/fesm2022/ng-primitives-meter.mjs +25 -36
  47. package/fesm2022/ng-primitives-meter.mjs.map +1 -1
  48. package/fesm2022/ng-primitives-navigation-menu.mjs +60 -108
  49. package/fesm2022/ng-primitives-navigation-menu.mjs.map +1 -1
  50. package/fesm2022/ng-primitives-number-field.mjs +35 -59
  51. package/fesm2022/ng-primitives-number-field.mjs.map +1 -1
  52. package/fesm2022/ng-primitives-pagination.mjs +270 -297
  53. package/fesm2022/ng-primitives-pagination.mjs.map +1 -1
  54. package/fesm2022/ng-primitives-popover.mjs +209 -223
  55. package/fesm2022/ng-primitives-popover.mjs.map +1 -1
  56. package/fesm2022/ng-primitives-portal.mjs +88 -59
  57. package/fesm2022/ng-primitives-portal.mjs.map +1 -1
  58. package/fesm2022/ng-primitives-progress.mjs +30 -41
  59. package/fesm2022/ng-primitives-progress.mjs.map +1 -1
  60. package/fesm2022/ng-primitives-radio.mjs +20 -30
  61. package/fesm2022/ng-primitives-radio.mjs.map +1 -1
  62. package/fesm2022/ng-primitives-resize.mjs +3 -3
  63. package/fesm2022/ng-primitives-resize.mjs.map +1 -1
  64. package/fesm2022/ng-primitives-roving-focus.mjs +20 -34
  65. package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
  66. package/fesm2022/ng-primitives-search.mjs +9 -9
  67. package/fesm2022/ng-primitives-search.mjs.map +1 -1
  68. package/fesm2022/ng-primitives-select.mjs +720 -620
  69. package/fesm2022/ng-primitives-select.mjs.map +1 -1
  70. package/fesm2022/ng-primitives-separator.mjs +4 -6
  71. package/fesm2022/ng-primitives-separator.mjs.map +1 -1
  72. package/fesm2022/ng-primitives-slider.mjs +63 -100
  73. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  74. package/fesm2022/ng-primitives-state.mjs +3 -3
  75. package/fesm2022/ng-primitives-state.mjs.map +1 -1
  76. package/fesm2022/ng-primitives-switch.mjs +15 -21
  77. package/fesm2022/ng-primitives-switch.mjs.map +1 -1
  78. package/fesm2022/ng-primitives-tabs.mjs +31 -41
  79. package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
  80. package/fesm2022/ng-primitives-textarea.mjs +5 -7
  81. package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
  82. package/fesm2022/ng-primitives-toast.mjs +30 -23
  83. package/fesm2022/ng-primitives-toast.mjs.map +1 -1
  84. package/fesm2022/ng-primitives-toggle-group.mjs +20 -36
  85. package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
  86. package/fesm2022/ng-primitives-toggle.mjs +10 -19
  87. package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
  88. package/fesm2022/ng-primitives-toolbar.mjs +4 -6
  89. package/fesm2022/ng-primitives-toolbar.mjs.map +1 -1
  90. package/fesm2022/ng-primitives-tooltip.mjs +401 -402
  91. package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
  92. package/fesm2022/ng-primitives-utils.mjs +5 -4
  93. package/fesm2022/ng-primitives-utils.mjs.map +1 -1
  94. package/package.json +56 -55
  95. package/schematics/ng-generate/templates/select/select.__fileSuffix@dasherize__.ts.template +48 -48
  96. package/{a11y/index.d.ts → types/ng-primitives-a11y.d.ts} +18 -24
  97. package/{accordion/index.d.ts → types/ng-primitives-accordion.d.ts} +85 -98
  98. package/{autofill/index.d.ts → types/ng-primitives-autofill.d.ts} +3 -10
  99. package/{avatar/index.d.ts → types/ng-primitives-avatar.d.ts} +7 -30
  100. package/{breadcrumbs/index.d.ts → types/ng-primitives-breadcrumbs.d.ts} +15 -70
  101. package/{button/index.d.ts → types/ng-primitives-button.d.ts} +23 -29
  102. package/{checkbox/index.d.ts → types/ng-primitives-checkbox.d.ts} +68 -74
  103. package/{combobox/index.d.ts → types/ng-primitives-combobox.d.ts} +35 -35
  104. package/{context-menu/index.d.ts → types/ng-primitives-context-menu.d.ts} +2 -1
  105. package/{date-picker/index.d.ts → types/ng-primitives-date-picker.d.ts} +2 -2
  106. package/{dialog/index.d.ts → types/ng-primitives-dialog.d.ts} +7 -2
  107. package/{file-upload/index.d.ts → types/ng-primitives-file-upload.d.ts} +5 -20
  108. package/{focus-trap/index.d.ts → types/ng-primitives-focus-trap.d.ts} +3 -10
  109. package/{form-field/index.d.ts → types/ng-primitives-form-field.d.ts} +9 -40
  110. package/{input/index.d.ts → types/ng-primitives-input.d.ts} +3 -10
  111. package/{menu/index.d.ts → types/ng-primitives-menu.d.ts} +17 -63
  112. package/{navigation-menu/index.d.ts → types/ng-primitives-navigation-menu.d.ts} +15 -70
  113. package/{number-field/index.d.ts → types/ng-primitives-number-field.d.ts} +80 -110
  114. package/types/ng-primitives-pagination.d.ts +502 -0
  115. package/{popover/index.d.ts → types/ng-primitives-popover.d.ts} +244 -57
  116. package/{portal/index.d.ts → types/ng-primitives-portal.d.ts} +22 -13
  117. package/{progress/index.d.ts → types/ng-primitives-progress.d.ts} +3 -10
  118. package/{roving-focus/index.d.ts → types/ng-primitives-roving-focus.d.ts} +65 -79
  119. package/types/ng-primitives-select.d.ts +687 -0
  120. package/{separator/index.d.ts → types/ng-primitives-separator.d.ts} +3 -10
  121. package/{slider/index.d.ts → types/ng-primitives-slider.d.ts} +76 -138
  122. package/{state/index.d.ts → types/ng-primitives-state.d.ts} +26 -21
  123. package/{switch/index.d.ts → types/ng-primitives-switch.d.ts} +50 -64
  124. package/{tabs/index.d.ts → types/ng-primitives-tabs.d.ts} +9 -40
  125. package/{textarea/index.d.ts → types/ng-primitives-textarea.d.ts} +3 -10
  126. package/{toast/index.d.ts → types/ng-primitives-toast.d.ts} +13 -1
  127. package/{toggle-group/index.d.ts → types/ng-primitives-toggle-group.d.ts} +75 -89
  128. package/{toggle/index.d.ts → types/ng-primitives-toggle.d.ts} +50 -56
  129. package/{toolbar/index.d.ts → types/ng-primitives-toolbar.d.ts} +3 -10
  130. package/types/ng-primitives-tooltip.d.ts +691 -0
  131. package/pagination/index.d.ts +0 -211
  132. package/select/index.d.ts +0 -396
  133. package/tooltip/index.d.ts +0 -384
  134. /package/{ai/index.d.ts → types/ng-primitives-ai.d.ts} +0 -0
  135. /package/{common/index.d.ts → types/ng-primitives-common.d.ts} +0 -0
  136. /package/{date-time-luxon/index.d.ts → types/ng-primitives-date-time-luxon.d.ts} +0 -0
  137. /package/{date-time/index.d.ts → types/ng-primitives-date-time.d.ts} +0 -0
  138. /package/{input-otp/index.d.ts → types/ng-primitives-input-otp.d.ts} +0 -0
  139. /package/{interactions/index.d.ts → types/ng-primitives-interactions.d.ts} +0 -0
  140. /package/{internal/index.d.ts → types/ng-primitives-internal.d.ts} +0 -0
  141. /package/{listbox/index.d.ts → types/ng-primitives-listbox.d.ts} +0 -0
  142. /package/{meter/index.d.ts → types/ng-primitives-meter.d.ts} +0 -0
  143. /package/{radio/index.d.ts → types/ng-primitives-radio.d.ts} +0 -0
  144. /package/{resize/index.d.ts → types/ng-primitives-resize.d.ts} +0 -0
  145. /package/{search/index.d.ts → types/ng-primitives-search.d.ts} +0 -0
  146. /package/{utils/index.d.ts → types/ng-primitives-utils.d.ts} +0 -0
  147. /package/{index.d.ts → types/ng-primitives.d.ts} +0 -0
@@ -1,365 +1,357 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, numberAttribute, booleanAttribute, computed, HostListener, Directive, output } from '@angular/core';
2
+ import { signal, computed, input, numberAttribute, booleanAttribute, Directive, output } from '@angular/core';
3
3
  import { ngpButton } from 'ng-primitives/button';
4
- import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
4
+ import { injectElementRef } from 'ng-primitives/internal';
5
+ import { createPrimitive, controlledState, attrBinding, dataBinding, deprecatedSetter, listener } from 'ng-primitives/state';
5
6
 
6
- /**
7
- * The state token for the Pagination primitive.
8
- */
9
- const NgpPaginationStateToken = createStateToken('Pagination');
10
- /**
11
- * Provides the Pagination state.
12
- */
13
- const providePaginationState = createStateProvider(NgpPaginationStateToken);
14
- /**
15
- * Injects the Pagination state.
16
- */
17
- const injectPaginationState = createStateInjector(NgpPaginationStateToken);
18
- /**
19
- * The Pagination state registration function.
20
- */
21
- const paginationState = createState(NgpPaginationStateToken);
7
+ const [NgpPaginationStateToken, ngpPagination, injectPaginationState, providePaginationState,] = createPrimitive('NgpPagination', ({ page: _page = signal(undefined), defaultPage: _defaultPage = signal(1), pageCount: _pageCount = signal(0), disabled: _disabled = signal(false), onPageChange, }) => {
8
+ const elementRef = injectElementRef();
9
+ const [page, setPage, pageChange] = controlledState({
10
+ value: _page,
11
+ defaultValue: _defaultPage,
12
+ onChange: onPageChange,
13
+ });
14
+ const firstPage = computed(() => page() === 1, ...(ngDevMode ? [{ debugName: "firstPage" }] : /* istanbul ignore next */ []));
15
+ const lastPage = computed(() => page() === _pageCount(), ...(ngDevMode ? [{ debugName: "lastPage" }] : /* istanbul ignore next */ []));
16
+ // Host bindings
17
+ attrBinding(elementRef, 'role', 'navigation');
18
+ dataBinding(elementRef, 'data-page', () => page().toString());
19
+ dataBinding(elementRef, 'data-page-count', () => _pageCount().toString());
20
+ dataBinding(elementRef, 'data-first-page', () => (firstPage() ? '' : null));
21
+ dataBinding(elementRef, 'data-last-page', () => (lastPage() ? '' : null));
22
+ dataBinding(elementRef, 'data-disabled', () => (_disabled() ? '' : null));
23
+ function goToPage(page) {
24
+ // check if the page is within the bounds of the pagination
25
+ if (page < 1 || page > _pageCount()) {
26
+ return;
27
+ }
28
+ setPage(page);
29
+ }
30
+ return {
31
+ page: deprecatedSetter(page, 'setPage', setPage),
32
+ pageCount: _pageCount,
33
+ pageChange,
34
+ disabled: _disabled,
35
+ firstPage,
36
+ lastPage,
37
+ goToPage,
38
+ };
39
+ });
40
+
41
+ const [NgpPaginationButtonStateToken, ngpPaginationButton, injectPaginationButtonState, providePaginationButtonState,] = createPrimitive('NgpPaginationButton', ({ page = signal(-1), disabled: _disabled = signal(false), }) => {
42
+ const elementRef = injectElementRef();
43
+ const paginationState = injectPaginationState();
44
+ const selected = computed(() => page() === paginationState().page(), ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
45
+ const disabled = computed(() => _disabled() || paginationState().disabled(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
46
+ // Setup interactions
47
+ ngpButton({ disabled: disabled });
48
+ // Host binding
49
+ attrBinding(elementRef, 'tabindex', () => (disabled() ? -1 : 0));
50
+ attrBinding(elementRef, 'aria-current', selected);
51
+ dataBinding(elementRef, 'data-page', () => page().toString());
52
+ dataBinding(elementRef, 'data-selected', () => (selected() ? '' : null));
53
+ // Listeners
54
+ listener(elementRef, 'click', goToPage);
55
+ listener(elementRef, 'keydown.space', handleOnEnter);
56
+ listener(elementRef, 'keydown.enter', handleOnEnter);
57
+ function goToPage() {
58
+ if (disabled()) {
59
+ return;
60
+ }
61
+ paginationState().goToPage(page());
62
+ }
63
+ function handleOnEnter(event) {
64
+ event.preventDefault();
65
+ event.stopPropagation();
66
+ goToPage();
67
+ }
68
+ return {
69
+ page,
70
+ disabled,
71
+ goToPage,
72
+ };
73
+ });
22
74
 
23
75
  /**
24
76
  * The `NgpPaginationButton` directive is used to create a pagination button.
25
77
  */
26
78
  class NgpPaginationButton {
27
79
  constructor() {
28
- /**
29
- * Access the pagination state.
30
- */
31
- this.paginationState = injectPaginationState();
32
80
  /**
33
81
  * Define the page this button represents.
34
82
  */
35
- this.page = input.required(...(ngDevMode ? [{ debugName: "page", alias: 'ngpPaginationButtonPage',
36
- transform: numberAttribute }] : [{
37
- alias: 'ngpPaginationButtonPage',
38
- transform: numberAttribute,
39
- }]));
83
+ this.page = input.required({ ...(ngDevMode ? { debugName: "page" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationButtonPage',
84
+ transform: numberAttribute });
40
85
  /**
41
86
  * Whether the button is disabled.
42
87
  */
43
- this.buttonDisabled = input(false, ...(ngDevMode ? [{ debugName: "buttonDisabled", alias: 'ngpPaginationButtonDisabled',
44
- transform: booleanAttribute }] : [{
45
- alias: 'ngpPaginationButtonDisabled',
46
- transform: booleanAttribute,
47
- }]));
48
- /**
49
- * Whether the button is disabled.
50
- */
51
- this.disabled = computed(() => this.buttonDisabled() || this.paginationState().disabled(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
52
- /**
53
- * Whether this page is the currently selected page.
54
- */
55
- this.selected = computed(() => this.page() === this.paginationState().page(), ...(ngDevMode ? [{ debugName: "selected" }] : []));
56
- ngpButton({ disabled: this.disabled });
88
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationButtonDisabled',
89
+ transform: booleanAttribute });
90
+ this.state = ngpPaginationButton({
91
+ page: this.page,
92
+ disabled: this.disabled,
93
+ });
57
94
  }
58
95
  /**
59
96
  * Go to the page this button represents.
60
97
  */
61
98
  goToPage() {
62
- if (this.disabled()) {
63
- return;
64
- }
65
- this.paginationState().goToPage(this.page());
66
- }
67
- /**
68
- * A click event may not be fired if this is on an anchor tag and the href is empty.
69
- * This is a workaround to ensure the click event is fired.
70
- */
71
- onEnter(event) {
72
- event.preventDefault();
73
- event.stopPropagation();
74
- this.goToPage();
99
+ return this.state.goToPage();
75
100
  }
76
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationButton, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
77
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpPaginationButton, isStandalone: true, selector: "[ngpPaginationButton]", inputs: { page: { classPropertyName: "page", publicName: "ngpPaginationButtonPage", isSignal: true, isRequired: true, transformFunction: null }, buttonDisabled: { classPropertyName: "buttonDisabled", publicName: "ngpPaginationButtonDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "goToPage()", "keydown.enter": "onEnter($event)", "keydown.space": "onEnter($event)" }, properties: { "tabindex": "disabled() ? -1 : 0", "attr.data-page": "page()", "attr.data-selected": "selected() ? \"\" : null", "attr.aria-current": "selected()" } }, exportAs: ["ngpPaginationButton"], ngImport: i0 }); }
101
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationButton, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
102
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPaginationButton, isStandalone: true, selector: "[ngpPaginationButton]", inputs: { page: { classPropertyName: "page", publicName: "ngpPaginationButtonPage", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpPaginationButtonDisabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ngpPaginationButton"], ngImport: i0 }); }
78
103
  }
79
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationButton, decorators: [{
104
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationButton, decorators: [{
80
105
  type: Directive,
81
106
  args: [{
82
107
  selector: '[ngpPaginationButton]',
83
108
  exportAs: 'ngpPaginationButton',
84
- host: {
85
- '[tabindex]': 'disabled() ? -1 : 0',
86
- '[attr.data-page]': 'page()',
87
- '[attr.data-selected]': 'selected() ? "" : null',
88
- '[attr.aria-current]': 'selected()',
89
- },
90
109
  }]
91
- }], ctorParameters: () => [], propDecorators: { page: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationButtonPage", required: true }] }], buttonDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationButtonDisabled", required: false }] }], goToPage: [{
92
- type: HostListener,
93
- args: ['click']
94
- }], onEnter: [{
95
- type: HostListener,
96
- args: ['keydown.enter', ['$event']]
97
- }, {
98
- type: HostListener,
99
- args: ['keydown.space', ['$event']]
100
- }] } });
110
+ }], propDecorators: { page: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationButtonPage", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationButtonDisabled", required: false }] }] } });
111
+
112
+ const [NgpPaginationFirstStateToken, ngpPaginationFirst, injectPaginationFirstState, providePaginationFirstState,] = createPrimitive('NgpPaginationFirst', ({ disabled: _disabled = signal(false) }) => {
113
+ const elementRef = injectElementRef();
114
+ const paginationState = injectPaginationState();
115
+ const disabled = computed(() => _disabled() || paginationState().disabled() || paginationState().firstPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
116
+ // Setup interactions
117
+ ngpButton({ disabled: disabled });
118
+ // Host binding
119
+ attrBinding(elementRef, 'tabindex', () => (disabled() ? -1 : 0));
120
+ dataBinding(elementRef, 'data-first-page', () => (paginationState().firstPage() ? '' : null));
121
+ // Listener
122
+ listener(elementRef, 'click', goToFirstPage);
123
+ listener(elementRef, 'keydown.enter', handleOnEnter);
124
+ listener(elementRef, 'keydown.space', handleOnEnter);
125
+ function goToFirstPage() {
126
+ if (disabled()) {
127
+ return;
128
+ }
129
+ paginationState().goToPage(1);
130
+ }
131
+ function handleOnEnter(event) {
132
+ event.preventDefault();
133
+ event.stopPropagation();
134
+ goToFirstPage();
135
+ }
136
+ return {
137
+ disabled,
138
+ goToFirstPage,
139
+ };
140
+ });
101
141
 
102
142
  /**
103
143
  * The `NgpPaginationFirst` directive is used to create a pagination button that navigates to the first page.
104
144
  */
105
145
  class NgpPaginationFirst {
106
146
  constructor() {
107
- /**
108
- * Access the pagination state.
109
- */
110
- this.paginationState = injectPaginationState();
111
147
  /**
112
148
  * Whether the button is disabled.
113
149
  */
114
- this.buttonDisabled = input(false, ...(ngDevMode ? [{ debugName: "buttonDisabled", alias: 'ngpPaginationFirstDisabled',
115
- transform: booleanAttribute }] : [{
116
- alias: 'ngpPaginationFirstDisabled',
117
- transform: booleanAttribute,
118
- }]));
119
- this.disabled = computed(() => this.buttonDisabled() ||
120
- this.paginationState().disabled() ||
121
- this.paginationState().firstPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
122
- ngpButton({ disabled: this.disabled });
150
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationFirstDisabled',
151
+ transform: booleanAttribute });
152
+ this.state = ngpPaginationFirst({
153
+ disabled: this.disabled,
154
+ });
123
155
  }
124
156
  /**
125
157
  * Go to the first page.
126
158
  */
127
159
  goToFirstPage() {
128
- if (this.disabled()) {
129
- return;
130
- }
131
- this.paginationState().goToPage(1);
132
- }
133
- /**
134
- * A click event may not be fired if this is on an anchor tag and the href is empty.
135
- * This is a workaround to ensure the click event is fired.
136
- */
137
- onEnter(event) {
138
- event.preventDefault();
139
- event.stopPropagation();
140
- this.goToFirstPage();
160
+ return this.state.goToFirstPage();
141
161
  }
142
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationFirst, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
143
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpPaginationFirst, isStandalone: true, selector: "[ngpPaginationFirst]", inputs: { buttonDisabled: { classPropertyName: "buttonDisabled", publicName: "ngpPaginationFirstDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "goToFirstPage()", "keydown.enter": "onEnter($event)", "keydown.space": "onEnter($event)" }, properties: { "tabindex": "disabled() ? -1 : 0", "attr.data-first-page": "paginationState().firstPage() ? \"\" : null" } }, exportAs: ["ngpPaginationFirst"], ngImport: i0 }); }
162
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationFirst, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
163
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPaginationFirst, isStandalone: true, selector: "[ngpPaginationFirst]", inputs: { disabled: { classPropertyName: "disabled", publicName: "ngpPaginationFirstDisabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ngpPaginationFirst"], ngImport: i0 }); }
144
164
  }
145
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationFirst, decorators: [{
165
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationFirst, decorators: [{
146
166
  type: Directive,
147
167
  args: [{
148
168
  selector: '[ngpPaginationFirst]',
149
169
  exportAs: 'ngpPaginationFirst',
150
- host: {
151
- '[tabindex]': 'disabled() ? -1 : 0',
152
- '[attr.data-first-page]': 'paginationState().firstPage() ? "" : null',
153
- },
154
170
  }]
155
- }], ctorParameters: () => [], propDecorators: { buttonDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationFirstDisabled", required: false }] }], goToFirstPage: [{
156
- type: HostListener,
157
- args: ['click']
158
- }], onEnter: [{
159
- type: HostListener,
160
- args: ['keydown.enter', ['$event']]
161
- }, {
162
- type: HostListener,
163
- args: ['keydown.space', ['$event']]
164
- }] } });
171
+ }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationFirstDisabled", required: false }] }] } });
172
+
173
+ const [NgpPaginationLastStateToken, ngpPaginationLast, injectPaginationLastState, providePaginationLastState,] = createPrimitive('NgpPaginationLast', ({ disabled: _disabled = signal(false) }) => {
174
+ const elementRef = injectElementRef();
175
+ const paginationState = injectPaginationState();
176
+ const disabled = computed(() => _disabled() || paginationState().disabled() || paginationState().lastPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
177
+ // Setup interactions
178
+ ngpButton({ disabled: disabled });
179
+ // Host binding
180
+ attrBinding(elementRef, 'tabindex', () => (disabled() ? -1 : 0));
181
+ dataBinding(elementRef, 'data-last-page', () => (paginationState().lastPage() ? '' : null));
182
+ // Listener
183
+ listener(elementRef, 'click', goToLastPage);
184
+ listener(elementRef, 'keydown.enter', handleOnEnter);
185
+ listener(elementRef, 'keydown.space', handleOnEnter);
186
+ function goToLastPage() {
187
+ if (disabled()) {
188
+ return;
189
+ }
190
+ paginationState().goToPage(paginationState().pageCount());
191
+ }
192
+ function handleOnEnter(event) {
193
+ event.preventDefault();
194
+ event.stopPropagation();
195
+ goToLastPage();
196
+ }
197
+ return {
198
+ disabled,
199
+ goToLastPage,
200
+ };
201
+ });
165
202
 
166
203
  /**
167
204
  * The `NgpPaginationLast` directive is used to create a pagination button that navigates to the last page.
168
205
  */
169
206
  class NgpPaginationLast {
170
207
  constructor() {
171
- /**
172
- * Access the pagination state.
173
- */
174
- this.paginationState = injectPaginationState();
175
208
  /**
176
209
  * Whether the button is disabled.
177
210
  */
178
- this.buttonDisabled = input(false, ...(ngDevMode ? [{ debugName: "buttonDisabled", alias: 'ngpPaginationLastDisabled',
179
- transform: booleanAttribute }] : [{
180
- alias: 'ngpPaginationLastDisabled',
181
- transform: booleanAttribute,
182
- }]));
183
- this.disabled = computed(() => this.buttonDisabled() ||
184
- this.paginationState().disabled() ||
185
- this.paginationState().lastPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
186
- ngpButton({ disabled: this.disabled });
211
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationLastDisabled',
212
+ transform: booleanAttribute });
213
+ this.state = ngpPaginationLast({
214
+ disabled: this.disabled,
215
+ });
187
216
  }
188
217
  /**
189
218
  * Go to the last page.
190
219
  */
191
220
  goToLastPage() {
192
- if (this.disabled()) {
193
- return;
194
- }
195
- this.paginationState().goToPage(this.paginationState().pageCount());
196
- }
197
- /**
198
- * A click event may not be fired if this is on an anchor tag and the href is empty.
199
- * This is a workaround to ensure the click event is fired.
200
- */
201
- onEnter(event) {
202
- event.preventDefault();
203
- event.stopPropagation();
204
- this.goToLastPage();
221
+ this.state.goToLastPage();
205
222
  }
206
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationLast, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
207
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpPaginationLast, isStandalone: true, selector: "[ngpPaginationLast]", inputs: { buttonDisabled: { classPropertyName: "buttonDisabled", publicName: "ngpPaginationLastDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "goToLastPage()", "keydown.enter": "onEnter($event)", "keydown.space": "onEnter($event)" }, properties: { "tabindex": "disabled() ? -1 : 0", "attr.data-last-page": "paginationState().lastPage() ? \"\" : null" } }, exportAs: ["ngpPaginationLast"], ngImport: i0 }); }
223
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationLast, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
224
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPaginationLast, isStandalone: true, selector: "[ngpPaginationLast]", inputs: { disabled: { classPropertyName: "disabled", publicName: "ngpPaginationLastDisabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ngpPaginationLast"], ngImport: i0 }); }
208
225
  }
209
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationLast, decorators: [{
226
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationLast, decorators: [{
210
227
  type: Directive,
211
228
  args: [{
212
229
  selector: '[ngpPaginationLast]',
213
230
  exportAs: 'ngpPaginationLast',
214
- host: {
215
- '[tabindex]': 'disabled() ? -1 : 0',
216
- '[attr.data-last-page]': 'paginationState().lastPage() ? "" : null',
217
- },
218
231
  }]
219
- }], ctorParameters: () => [], propDecorators: { buttonDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationLastDisabled", required: false }] }], goToLastPage: [{
220
- type: HostListener,
221
- args: ['click']
222
- }], onEnter: [{
223
- type: HostListener,
224
- args: ['keydown.enter', ['$event']]
225
- }, {
226
- type: HostListener,
227
- args: ['keydown.space', ['$event']]
228
- }] } });
232
+ }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationLastDisabled", required: false }] }] } });
233
+
234
+ const [NgpPaginationNextStateToken, ngpPaginationNext, injectPaginationNextState, providePaginationNextState,] = createPrimitive('NgpPaginationNext', ({ disabled: _disabled = signal(false) }) => {
235
+ const elementRef = injectElementRef();
236
+ const paginationState = injectPaginationState();
237
+ const disabled = computed(() => _disabled() || paginationState().disabled() || paginationState().lastPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
238
+ // Setup interactions
239
+ ngpButton({ disabled: disabled });
240
+ // Host binding
241
+ attrBinding(elementRef, 'tabindex', () => (disabled() ? -1 : 0));
242
+ dataBinding(elementRef, 'data-last-page', () => (paginationState().lastPage() ? '' : null));
243
+ // Listener
244
+ listener(elementRef, 'click', goToNextPage);
245
+ listener(elementRef, 'keydown.enter', handleOnEnter);
246
+ listener(elementRef, 'keydown.space', handleOnEnter);
247
+ function goToNextPage() {
248
+ if (disabled()) {
249
+ return;
250
+ }
251
+ paginationState().goToPage(paginationState().page() + 1);
252
+ }
253
+ function handleOnEnter(event) {
254
+ event.preventDefault();
255
+ event.stopPropagation();
256
+ goToNextPage();
257
+ }
258
+ return {
259
+ disabled,
260
+ goToNextPage,
261
+ };
262
+ });
229
263
 
230
264
  /**
231
265
  * The `NgpPaginationNext` directive is used to create a pagination button that navigates to the next page.
232
266
  */
233
267
  class NgpPaginationNext {
234
268
  constructor() {
235
- /**
236
- * Access the pagination state.
237
- */
238
- this.paginationState = injectPaginationState();
239
- /**
240
- * Whether the button is disabled.
241
- */
242
- this.buttonDisabled = input(false, ...(ngDevMode ? [{ debugName: "buttonDisabled", alias: 'ngpPaginationNextDisabled',
243
- transform: booleanAttribute }] : [{
244
- alias: 'ngpPaginationNextDisabled',
245
- transform: booleanAttribute,
246
- }]));
247
269
  /**
248
270
  * Whether the button is disabled.
249
271
  */
250
- this.disabled = computed(() => this.buttonDisabled() ||
251
- this.paginationState().disabled() ||
252
- this.paginationState().lastPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
253
- ngpButton({ disabled: this.disabled });
272
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationNextDisabled',
273
+ transform: booleanAttribute });
274
+ this.state = ngpPaginationNext({
275
+ disabled: this.disabled,
276
+ });
254
277
  }
255
278
  /**
256
279
  * Go to the next page.
257
280
  */
258
281
  goToNextPage() {
259
- if (this.disabled()) {
260
- return;
261
- }
262
- this.paginationState().goToPage(this.paginationState().page() + 1);
282
+ return this.state.goToNextPage();
263
283
  }
264
- /**
265
- * A click event may not be fired if this is on an anchor tag and the href is empty.
266
- * This is a workaround to ensure the click event is fired.
267
- */
268
- onEnter(event) {
269
- event.preventDefault();
270
- event.stopPropagation();
271
- this.goToNextPage();
272
- }
273
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationNext, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
274
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpPaginationNext, isStandalone: true, selector: "[ngpPaginationNext]", inputs: { buttonDisabled: { classPropertyName: "buttonDisabled", publicName: "ngpPaginationNextDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "goToNextPage()", "keydown.enter": "onEnter($event)", "keydown.space": "onEnter($event)" }, properties: { "tabindex": "disabled() ? -1 : 0", "attr.data-last-page": "paginationState().lastPage() ? \"\" : null" } }, exportAs: ["ngpPaginationNext"], ngImport: i0 }); }
284
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationNext, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
285
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPaginationNext, isStandalone: true, selector: "[ngpPaginationNext]", inputs: { disabled: { classPropertyName: "disabled", publicName: "ngpPaginationNextDisabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ngpPaginationNext"], ngImport: i0 }); }
275
286
  }
276
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationNext, decorators: [{
287
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationNext, decorators: [{
277
288
  type: Directive,
278
289
  args: [{
279
290
  selector: '[ngpPaginationNext]',
280
291
  exportAs: 'ngpPaginationNext',
281
- host: {
282
- '[tabindex]': 'disabled() ? -1 : 0',
283
- '[attr.data-last-page]': 'paginationState().lastPage() ? "" : null',
284
- },
285
292
  }]
286
- }], ctorParameters: () => [], propDecorators: { buttonDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationNextDisabled", required: false }] }], goToNextPage: [{
287
- type: HostListener,
288
- args: ['click']
289
- }], onEnter: [{
290
- type: HostListener,
291
- args: ['keydown.enter', ['$event']]
292
- }, {
293
- type: HostListener,
294
- args: ['keydown.space', ['$event']]
295
- }] } });
293
+ }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationNextDisabled", required: false }] }] } });
294
+
295
+ const [NgpPaginationPreviousStateToken, ngpPaginationPrevious, injectPaginationPreviousState, providePaginationPreviousState,] = createPrimitive('NgpPaginationPrevious', ({ disabled: _disabled = signal(false) }) => {
296
+ const elementRef = injectElementRef();
297
+ const paginationState = injectPaginationState();
298
+ const disabled = computed(() => _disabled() || paginationState().disabled() || paginationState().firstPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
299
+ // Setup interactions
300
+ ngpButton({ disabled: disabled });
301
+ // Host binding
302
+ attrBinding(elementRef, 'tabindex', () => (disabled() ? -1 : 0));
303
+ dataBinding(elementRef, 'data-first-page', () => (paginationState().firstPage() ? '' : null));
304
+ // Listener
305
+ listener(elementRef, 'click', goToPreviousPage);
306
+ listener(elementRef, 'keydown.enter', handleOnEnter);
307
+ listener(elementRef, 'keydown.space', handleOnEnter);
308
+ function goToPreviousPage() {
309
+ if (disabled()) {
310
+ return;
311
+ }
312
+ paginationState().goToPage(paginationState().page() - 1);
313
+ }
314
+ function handleOnEnter(event) {
315
+ event.preventDefault();
316
+ event.stopPropagation();
317
+ goToPreviousPage();
318
+ }
319
+ return {
320
+ disabled,
321
+ goToPreviousPage,
322
+ };
323
+ });
296
324
 
297
325
  /**
298
326
  * The `NgpPaginationPrevious` directive is used to create a pagination button that navigates to the previous page.
299
327
  */
300
328
  class NgpPaginationPrevious {
301
329
  constructor() {
302
- /**
303
- * Access the pagination state.
304
- */
305
- this.paginationState = injectPaginationState();
306
330
  /**
307
331
  * Whether the button is disabled.
308
332
  */
309
- this.buttonDisabled = input(false, ...(ngDevMode ? [{ debugName: "buttonDisabled", alias: 'ngpPaginationPreviousDisabled',
310
- transform: booleanAttribute }] : [{
311
- alias: 'ngpPaginationPreviousDisabled',
312
- transform: booleanAttribute,
313
- }]));
314
- /**
315
- * Whether the button is disabled.
316
- */
317
- this.disabled = computed(() => this.buttonDisabled() ||
318
- this.paginationState().disabled() ||
319
- this.paginationState().firstPage(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
320
- ngpButton({ disabled: this.disabled });
333
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationPreviousDisabled',
334
+ transform: booleanAttribute });
335
+ this.state = ngpPaginationPrevious({
336
+ disabled: this.disabled,
337
+ });
321
338
  }
322
339
  /**
323
340
  * Go to the previous page.
324
341
  */
325
342
  goToPreviousPage() {
326
- if (this.disabled()) {
327
- return;
328
- }
329
- this.paginationState().goToPage(this.paginationState().page() - 1);
330
- }
331
- /**
332
- * A click event may not be fired if this is on an anchor tag and the href is empty.
333
- * This is a workaround to ensure the click event is fired.
334
- */
335
- onEnter(event) {
336
- event.preventDefault();
337
- event.stopPropagation();
338
- this.goToPreviousPage();
343
+ return this.state.goToPreviousPage();
339
344
  }
340
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationPrevious, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
341
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpPaginationPrevious, isStandalone: true, selector: "[ngpPaginationPrevious]", inputs: { buttonDisabled: { classPropertyName: "buttonDisabled", publicName: "ngpPaginationPreviousDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "goToPreviousPage()", "keydown.enter": "onEnter($event)", "keydown.space": "onEnter($event)" }, properties: { "tabindex": "disabled() ? -1 : 0", "attr.data-first-page": "paginationState().firstPage() ? \"\" : null" } }, exportAs: ["ngpPaginationPrevious"], ngImport: i0 }); }
345
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationPrevious, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
346
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPaginationPrevious, isStandalone: true, selector: "[ngpPaginationPrevious]", inputs: { disabled: { classPropertyName: "disabled", publicName: "ngpPaginationPreviousDisabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ngpPaginationPrevious"], ngImport: i0 }); }
342
347
  }
343
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPaginationPrevious, decorators: [{
348
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPaginationPrevious, decorators: [{
344
349
  type: Directive,
345
350
  args: [{
346
351
  selector: '[ngpPaginationPrevious]',
347
352
  exportAs: 'ngpPaginationPrevious',
348
- host: {
349
- '[tabindex]': 'disabled() ? -1 : 0',
350
- '[attr.data-first-page]': 'paginationState().firstPage() ? "" : null',
351
- },
352
353
  }]
353
- }], ctorParameters: () => [], propDecorators: { buttonDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationPreviousDisabled", required: false }] }], goToPreviousPage: [{
354
- type: HostListener,
355
- args: ['click']
356
- }], onEnter: [{
357
- type: HostListener,
358
- args: ['keydown.enter', ['$event']]
359
- }, {
360
- type: HostListener,
361
- args: ['keydown.space', ['$event']]
362
- }] } });
354
+ }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationPreviousDisabled", required: false }] }] } });
363
355
 
364
356
  /**
365
357
  * The `NgpPagination` directive is used to create a pagination control.
@@ -367,13 +359,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
367
359
  class NgpPagination {
368
360
  constructor() {
369
361
  /**
370
- * The currently selected page.
362
+ * The currently selected page. Leave unset for uncontrolled usage, where the
363
+ * internal state is seeded from `defaultPage`.
364
+ */
365
+ this.page = input(undefined, { ...(ngDevMode ? { debugName: "page" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationPage',
366
+ transform: numberAttribute });
367
+ /**
368
+ * The default page for uncontrolled usage.
369
+ * @default 1
371
370
  */
372
- this.page = input(1, ...(ngDevMode ? [{ debugName: "page", alias: 'ngpPaginationPage',
373
- transform: numberAttribute }] : [{
374
- alias: 'ngpPaginationPage',
375
- transform: numberAttribute,
376
- }]));
371
+ this.defaultPage = input(1, { ...(ngDevMode ? { debugName: "defaultPage" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationDefaultPage',
372
+ transform: numberAttribute });
377
373
  /**
378
374
  * The event that is fired when the page changes.
379
375
  */
@@ -383,70 +379,47 @@ class NgpPagination {
383
379
  /**
384
380
  * The total number of pages.
385
381
  */
386
- this.pageCount = input(0, ...(ngDevMode ? [{ debugName: "pageCount", alias: 'ngpPaginationPageCount',
387
- transform: numberAttribute }] : [{
388
- alias: 'ngpPaginationPageCount',
389
- transform: numberAttribute,
390
- }]));
382
+ this.pageCount = input(0, { ...(ngDevMode ? { debugName: "pageCount" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationPageCount',
383
+ transform: numberAttribute });
391
384
  /**
392
385
  * Whether the pagination is disabled.
393
386
  */
394
- this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", alias: 'ngpPaginationDisabled',
395
- transform: booleanAttribute }] : [{
396
- alias: 'ngpPaginationDisabled',
397
- transform: booleanAttribute,
398
- }]));
399
- /**
400
- * Determine if we are on the first page.
401
- * @internal
402
- */
403
- this.firstPage = computed(() => this.state.page() === 1, ...(ngDevMode ? [{ debugName: "firstPage" }] : []));
404
- /**
405
- * Determine if we are on the last page.
406
- * @internal
407
- */
408
- this.lastPage = computed(() => this.state.page() === this.state.pageCount(), ...(ngDevMode ? [{ debugName: "lastPage" }] : []));
387
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), alias: 'ngpPaginationDisabled',
388
+ transform: booleanAttribute });
409
389
  /**
410
390
  * The control state for the pagination.
411
391
  * @internal
412
392
  */
413
- this.state = paginationState(this);
393
+ this.state = ngpPagination({
394
+ page: this.page,
395
+ defaultPage: this.defaultPage,
396
+ pageCount: this.pageCount,
397
+ disabled: this.disabled,
398
+ onPageChange: (value) => this.pageChange.emit(value),
399
+ });
414
400
  }
415
401
  /**
416
402
  * Go to the specified page.
417
403
  * @param page The page to go to.
418
404
  */
419
405
  goToPage(page) {
420
- // check if the page is within the bounds of the pagination
421
- if (page < 1 || page > this.state.pageCount()) {
422
- return;
423
- }
424
- this.state.page.set(page);
425
- this.pageChange.emit(page);
406
+ return this.state.goToPage(page);
426
407
  }
427
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPagination, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
428
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpPagination, isStandalone: true, selector: "[ngpPagination]", inputs: { page: { classPropertyName: "page", publicName: "ngpPaginationPage", isSignal: true, isRequired: false, transformFunction: null }, pageCount: { classPropertyName: "pageCount", publicName: "ngpPaginationPageCount", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpPaginationDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageChange: "ngpPaginationPageChange" }, host: { attributes: { "role": "navigation" }, properties: { "attr.data-page": "state.page()", "attr.data-page-count": "state.pageCount()", "attr.data-first-page": "firstPage() ? \"\" : null", "attr.data-last-page": "lastPage() ? \"\" : null", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [providePaginationState()], exportAs: ["ngpPagination"], ngImport: i0 }); }
408
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPagination, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
409
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpPagination, isStandalone: true, selector: "[ngpPagination]", inputs: { page: { classPropertyName: "page", publicName: "ngpPaginationPage", isSignal: true, isRequired: false, transformFunction: null }, defaultPage: { classPropertyName: "defaultPage", publicName: "ngpPaginationDefaultPage", isSignal: true, isRequired: false, transformFunction: null }, pageCount: { classPropertyName: "pageCount", publicName: "ngpPaginationPageCount", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpPaginationDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageChange: "ngpPaginationPageChange" }, providers: [providePaginationState()], exportAs: ["ngpPagination"], ngImport: i0 }); }
429
410
  }
430
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpPagination, decorators: [{
411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpPagination, decorators: [{
431
412
  type: Directive,
432
413
  args: [{
433
414
  selector: '[ngpPagination]',
434
415
  exportAs: 'ngpPagination',
435
416
  providers: [providePaginationState()],
436
- host: {
437
- role: 'navigation',
438
- '[attr.data-page]': 'state.page()',
439
- '[attr.data-page-count]': 'state.pageCount()',
440
- '[attr.data-first-page]': 'firstPage() ? "" : null',
441
- '[attr.data-last-page]': 'lastPage() ? "" : null',
442
- '[attr.data-disabled]': 'state.disabled() ? "" : null',
443
- },
444
417
  }]
445
- }], propDecorators: { page: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationPage", required: false }] }], pageChange: [{ type: i0.Output, args: ["ngpPaginationPageChange"] }], pageCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationPageCount", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationDisabled", required: false }] }] } });
418
+ }], propDecorators: { page: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationPage", required: false }] }], defaultPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationDefaultPage", required: false }] }], pageChange: [{ type: i0.Output, args: ["ngpPaginationPageChange"] }], pageCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationPageCount", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpPaginationDisabled", required: false }] }] } });
446
419
 
447
420
  /**
448
421
  * Generated bundle index. Do not edit.
449
422
  */
450
423
 
451
- export { NgpPagination, NgpPaginationButton, NgpPaginationFirst, NgpPaginationLast, NgpPaginationNext, NgpPaginationPrevious, injectPaginationState, providePaginationState };
424
+ export { NgpPagination, NgpPaginationButton, NgpPaginationButtonStateToken, NgpPaginationFirst, NgpPaginationFirstStateToken, NgpPaginationLast, NgpPaginationLastStateToken, NgpPaginationNext, NgpPaginationNextStateToken, NgpPaginationPrevious, NgpPaginationPreviousStateToken, NgpPaginationStateToken, injectPaginationButtonState, injectPaginationFirstState, injectPaginationLastState, injectPaginationNextState, injectPaginationPreviousState, injectPaginationState, ngpPagination, ngpPaginationButton, ngpPaginationFirst, ngpPaginationLast, ngpPaginationNext, ngpPaginationPrevious, providePaginationButtonState, providePaginationFirstState, providePaginationLastState, providePaginationNextState, providePaginationPreviousState, providePaginationState };
452
425
  //# sourceMappingURL=ng-primitives-pagination.mjs.map