Skip to content

Commit 66ac009

Browse files
committed
refactor(pagination): input transform for disabled prop, cleanups
1 parent f4c29f8 commit 66ac009

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
---
44

5+
#### `5.5.22` next
6+
7+
- refactor(pagination): input transform for disabled prop, cleanups
8+
9+
---
10+
511
#### `5.5.21`
612

713
- chore(dependencies): update to `Angular 20.3.10`

projects/coreui-angular/src/lib/pagination/page-item/page-item.directive.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import { computed, contentChild, Directive, effect, ElementRef, inject, input, Renderer2 } from '@angular/core';
1+
import {
2+
booleanAttribute,
3+
computed,
4+
contentChild,
5+
Directive,
6+
effect,
7+
ElementRef,
8+
inject,
9+
input,
10+
Renderer2
11+
} from '@angular/core';
12+
import { BooleanInput } from '@angular/cdk/coercion';
213

314
import { PageLinkDirective } from '../page-link/page-link.directive';
415

@@ -11,6 +22,8 @@ import { PageLinkDirective } from '../page-link/page-link.directive';
1122
}
1223
})
1324
export class PageItemDirective {
25+
static ngAcceptInputType_disabled: BooleanInput;
26+
1427
readonly #renderer = inject(Renderer2);
1528

1629
/**
@@ -23,7 +36,7 @@ export class PageItemDirective {
2336
* Toggle the disabled state for the component.
2437
* @return boolean
2538
*/
26-
readonly disabled = input<boolean>();
39+
readonly disabled = input(false, { transform: booleanAttribute });
2740

2841
readonly ariaCurrent = computed(() => {
2942
return this.active() ? 'page' : null;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { TestBed } from '@angular/core/testing';
12
import { PageLinkDirective } from './page-link.directive';
23

34
describe('PageLinkDirective', () => {
45
it('should create an instance', () => {
5-
const directive = new PageLinkDirective();
6-
expect(directive).toBeTruthy();
6+
TestBed.runInInjectionContext(() => {
7+
const directive = new PageLinkDirective();
8+
expect(directive).toBeTruthy();
9+
});
710
});
811
});
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
import { Directive } from '@angular/core';
1+
import { booleanAttribute, computed, Directive, input } from '@angular/core';
2+
import { BooleanInput } from '@angular/cdk/coercion';
23

34
@Directive({
45
selector: '[cPageLink]',
5-
host: { class: 'page-link' }
6+
host: { class: 'page-link', '[class]': 'hostClasses()' }
67
})
7-
export class PageLinkDirective {}
8+
export class PageLinkDirective {
9+
static ngAcceptInputType_disabled: BooleanInput;
10+
11+
readonly disabled = input(false, { transform: booleanAttribute });
12+
13+
readonly hostClasses = computed(() => {
14+
return {
15+
'page-link': true,
16+
disabled: this.disabled()
17+
} as Record<string, boolean>;
18+
});
19+
}

0 commit comments

Comments
 (0)