From c968e5f5dda4091045f471ec3255ed014405c086 Mon Sep 17 00:00:00 2001 From: Alexander Ciesielski Date: Mon, 6 May 2024 15:23:35 +0200 Subject: [PATCH 1/7] feat(button): make standalone --- src/app/components/api/shared.ts | 9 +++++---- src/app/components/autofocus/autofocus.ts | 7 +++---- src/app/components/button/button.ts | 15 +++++++++------ src/app/components/ripple/ripple.ts | 8 ++++---- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/app/components/api/shared.ts b/src/app/components/api/shared.ts index 88735641065..cb5ecbe7e84 100755 --- a/src/app/components/api/shared.ts +++ b/src/app/components/api/shared.ts @@ -1,20 +1,22 @@ -import { CommonModule } from '@angular/common'; import { Component, Directive, Input, NgModule, TemplateRef } from '@angular/core'; @Component({ selector: 'p-header', + standalone: true, template: '' }) export class Header {} @Component({ selector: 'p-footer', + standalone: true, template: '' }) export class Footer {} @Directive({ selector: '[pTemplate]', + standalone: true, host: {} }) export class PrimeTemplate { @@ -30,8 +32,7 @@ export class PrimeTemplate { } @NgModule({ - imports: [CommonModule], - exports: [Header, Footer, PrimeTemplate], - declarations: [Header, Footer, PrimeTemplate] + imports: [Header, Footer, PrimeTemplate], + exports: [Header, Footer, PrimeTemplate] }) export class SharedModule {} diff --git a/src/app/components/autofocus/autofocus.ts b/src/app/components/autofocus/autofocus.ts index 11253f8051b..504103917b3 100644 --- a/src/app/components/autofocus/autofocus.ts +++ b/src/app/components/autofocus/autofocus.ts @@ -1,4 +1,3 @@ -import { CommonModule } from '@angular/common'; import { Directive, ElementRef, Input, NgModule, booleanAttribute } from '@angular/core'; import { DomHandler } from 'primeng/dom'; /** @@ -7,6 +6,7 @@ import { DomHandler } from 'primeng/dom'; */ @Directive({ selector: '[pAutoFocus]', + standalone: true, host: { class: 'p-element' } @@ -49,8 +49,7 @@ export class AutoFocus { } @NgModule({ - imports: [CommonModule], - exports: [AutoFocus], - declarations: [AutoFocus] + imports: [AutoFocus], + exports: [AutoFocus] }) export class AutoFocusModule {} diff --git a/src/app/components/button/button.ts b/src/app/components/button/button.ts index cd02156c196..94fafb2293f 100755 --- a/src/app/components/button/button.ts +++ b/src/app/components/button/button.ts @@ -1,4 +1,4 @@ -import { CommonModule, DOCUMENT } from '@angular/common'; +import { DOCUMENT, NgClass, NgIf, NgStyle, NgTemplateOutlet } from '@angular/common'; import { AfterContentInit, AfterViewInit, @@ -20,11 +20,11 @@ import { numberAttribute } from '@angular/core'; import { PrimeTemplate, SharedModule } from 'primeng/api'; +import { AutoFocus } from 'primeng/autofocus'; import { DomHandler } from 'primeng/dom'; import { SpinnerIcon } from 'primeng/icons/spinner'; -import { RippleModule } from 'primeng/ripple'; +import { Ripple } from 'primeng/ripple'; import { ObjectUtils } from 'primeng/utils'; -import { AutoFocusModule } from 'primeng/autofocus'; type ButtonIconPosition = 'left' | 'right' | 'top' | 'bottom'; @@ -36,12 +36,14 @@ const INTERNAL_BUTTON_CLASSES = { loading: 'p-button-loading', labelOnly: 'p-button-loading-label-only' } as const; + /** * Button directive is an extension to button component. * @group Components */ @Directive({ selector: '[pButton]', + standalone: true, host: { class: 'p-element' } @@ -329,6 +331,8 @@ export class ButtonDirective implements AfterViewInit, OnDestroy { */ @Component({ selector: 'p-button', + standalone: true, + imports: [NgIf, NgTemplateOutlet, NgStyle, NgClass, Ripple, AutoFocus, SpinnerIcon], template: `