Skip to content

Commit 377982d

Browse files
committed
refactor(button): readonly signals
1 parent f59bf08 commit 377982d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

projects/coreui-angular/src/lib/button/button.directive.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,47 @@ export class ButtonDirective {
2121
* Toggle the active state for the component. [docs]
2222
* @type InputSignalWithTransform<boolean, unknown>
2323
*/
24-
active: InputSignalWithTransform<boolean, unknown> = input(false, { transform: booleanAttribute });
24+
readonly active: InputSignalWithTransform<boolean, unknown> = input(false, { transform: booleanAttribute });
2525

2626
/**
2727
* Sets the color context of the component to one of CoreUI’s themed colors. [docs]
2828
* @type InputSignal<Colors>
2929
*/
30-
color: InputSignal<Colors> = input<Colors>('primary');
30+
readonly color: InputSignal<Colors> = input<Colors>('primary');
3131

3232
/**
3333
* Toggle the disabled state for the component.
3434
* @type InputSignalWithTransform<boolean, unknown>
3535
*/
36-
disabled: InputSignalWithTransform<boolean, unknown> = input(false, { transform: booleanAttribute });
36+
readonly disabled: InputSignalWithTransform<boolean, unknown> = input(false, { transform: booleanAttribute });
3737

3838
/**
3939
* Select the shape of the component.
4040
* @type InputSignal<Shapes>
4141
*/
42-
shape: InputSignal<Shapes | undefined> = input<Shapes>();
42+
readonly shape: InputSignal<Shapes | undefined> = input<Shapes>();
4343

4444
/**
4545
* Size the component small or large.
4646
* @type InputSignal<'sm' | 'lg' | ''>
4747
*/
48-
size: InputSignal<'' | 'sm' | 'lg'> = input<'' | 'sm' | 'lg'>('');
48+
readonly size: InputSignal<'' | 'sm' | 'lg'> = input<'' | 'sm' | 'lg'>('');
4949

5050
/**
5151
* Specifies the type of button. Always specify the type attribute for the `<button>` element.
5252
* Different browsers may use different default types for the `<button>` element.
5353
* @type InputSignal<ButtonType>
5454
* @default 'button'
5555
*/
56-
type: InputSignal<ButtonType> = input<ButtonType>('button');
56+
readonly type: InputSignal<ButtonType> = input<ButtonType>('button');
5757

5858
/**
5959
* Set the button variant to an outlined button or a ghost button.
6060
* @type InputSignal<'ghost' | 'outline' | undefined>
6161
*/
62-
variant: InputSignal<'ghost' | 'outline' | undefined> = input<'ghost' | 'outline'>();
62+
readonly variant: InputSignal<'ghost' | 'outline' | undefined> = input<'ghost' | 'outline'>();
6363

64-
hostClasses = computed(() => {
64+
readonly hostClasses = computed(() => {
6565
return {
6666
btn: true,
6767
[`btn-${this.color()}`]: !!this.color() && !this.variant(),
@@ -74,21 +74,21 @@ export class ButtonDirective {
7474
} as Record<string, boolean>;
7575
});
7676

77-
_disabled = computed(() => this.disabled());
77+
readonly _disabled = computed(() => this.disabled());
7878

79-
ariaDisabled = computed(() => {
79+
readonly ariaDisabled = computed(() => {
8080
return this._disabled() ? true : null;
8181
});
8282

83-
attrDisabled = computed(() => {
83+
readonly attrDisabled = computed(() => {
8484
return this._disabled() ? '' : null;
8585
});
8686

87-
tabIndex = computed(() => {
87+
readonly tabIndex = computed(() => {
8888
return this._disabled() ? '-1' : null;
8989
});
9090

91-
isActive = computed(() => {
91+
readonly isActive = computed(() => {
9292
return <boolean>this.active() || null;
9393
});
9494
}

0 commit comments

Comments
 (0)