From 02176f16b3c34d28ebb2e505541c68e3dba12720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin?= <69278826+cetincakiroglu@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:12:51 +0300 Subject: [PATCH] Revert "Fixed #14286 - Add missing icon template" This reverts commit 09e5249562c31803a19ae171685e8cbcd441fb2b. --- .../togglebutton/togglebutton.interface.ts | 19 ------------ .../components/togglebutton/togglebutton.ts | 29 ++----------------- 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/src/app/components/togglebutton/togglebutton.interface.ts b/src/app/components/togglebutton/togglebutton.interface.ts index c1ab3b02ff3..67d6d3b4551 100644 --- a/src/app/components/togglebutton/togglebutton.interface.ts +++ b/src/app/components/togglebutton/togglebutton.interface.ts @@ -1,6 +1,4 @@ -import { TemplateRef } from '@angular/core'; import { ToggleButton } from './togglebutton'; - /** * Custom change event. * @see {@link ToggleButton.onChange} @@ -16,20 +14,3 @@ export interface ToggleButtonChangeEvent { */ checked: boolean | undefined; } - -/** - * Defines valid templates in ToggleButton. - * @group Templates - */ -export interface ToggleButtonTemplates { - /** - * Custom icon template. - * @param {boolean} context - checked state as boolean. - */ - icon(context: { - /** - * Checked. - */ - $implicit: boolean; - }): TemplateRef<{ $implicit: boolean }>; -} diff --git a/src/app/components/togglebutton/togglebutton.ts b/src/app/components/togglebutton/togglebutton.ts index e54b0562d41..9c05cccf370 100755 --- a/src/app/components/togglebutton/togglebutton.ts +++ b/src/app/components/togglebutton/togglebutton.ts @@ -1,10 +1,8 @@ import { CommonModule } from '@angular/common'; -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, EventEmitter, forwardRef, Input, NgModule, Output, QueryList, TemplateRef } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, forwardRef, Input, NgModule, Output } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { RippleModule } from 'primeng/ripple'; import { ToggleButtonChangeEvent } from './togglebutton.interface'; -import { Nullable } from 'primeng/ts-helpers'; -import { PrimeTemplate, SharedModule } from 'primeng/api'; type ToggleButtonIconPosition = 'left' | 'right'; @@ -35,16 +33,12 @@ export const TOGGLEBUTTON_VALUE_ACCESSOR: any = { [attr.data-pc-name]="'togglebutton'" [attr.data-pc-section]="'root'" > - @if(!iconTemplate) { - } @else { - - } {{ checked ? (hasOnLabel ? onLabel : '') : hasOffLabel ? offLabel : '' }} `, @@ -123,10 +117,6 @@ export class ToggleButton implements ControlValueAccessor { */ @Output() onChange: EventEmitter = new EventEmitter(); - @ContentChildren(PrimeTemplate) templates!: QueryList; - - iconTemplate: Nullable>; - checked: boolean = false; onModelChange: Function = () => {}; @@ -135,19 +125,6 @@ export class ToggleButton implements ControlValueAccessor { constructor(public cd: ChangeDetectorRef) {} - ngAfterContentInit() { - this.templates.forEach((item) => { - switch (item.getType()) { - case 'icon': - this.iconTemplate = item.template; - break; - default: - this.iconTemplate = item.template; - break; - } - }); - } - toggle(event: Event) { if (!this.disabled) { this.checked = !this.checked; @@ -207,8 +184,8 @@ export class ToggleButton implements ControlValueAccessor { } @NgModule({ - imports: [CommonModule, RippleModule, SharedModule], - exports: [ToggleButton, SharedModule], + imports: [CommonModule, RippleModule], + exports: [ToggleButton], declarations: [ToggleButton] }) export class ToggleButtonModule {}