Skip to content

Commit 7baf14c

Browse files
committed
feat(page): suporta tags HTML básicas no subtitle
Permite a formatação de texto no conteúdo do subtitle utilizando as tags HTML básicas: <b>, <strong>, <i>, <em> e <u>. Fixes DTHFUI-13081
1 parent 20669cb commit 7baf14c

20 files changed

Lines changed: 376 additions & 258 deletions
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
export * from './po-helper.module';
22
export * from './po-helper.component';
33
export * from './interfaces/po-helper.interface';
4-
export * from './po-helper-content-utils';
5-
export * from './po-helper-content.pipe';

projects/ui/src/lib/components/po-helper/po-helper-content-utils.ts

Lines changed: 0 additions & 126 deletions
This file was deleted.

projects/ui/src/lib/components/po-helper/po-helper-content.pipe.spec.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

projects/ui/src/lib/components/po-helper/po-helper-content.pipe.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

projects/ui/src/lib/components/po-helper/po-helper.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
<span class="po-helper-content-text">
2929
@for (fragment of contentFragments(); track $index) {
3030
<span
31-
[class.po-helper-text-bold]="fragment.bold"
32-
[class.po-helper-text-italic]="fragment.italic"
33-
[class.po-helper-text-underline]="fragment.underline"
31+
[class.po-text-bold]="fragment.bold"
32+
[class.po-text-italic]="fragment.italic"
33+
[class.po-text-underline]="fragment.underline"
3434
>{{ fragment.text }}</span
3535
>
3636
}

projects/ui/src/lib/components/po-helper/po-helper.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { PoHelperBaseComponent } from './po-helper-base.component';
1313
import { PoHelperOptions } from './interfaces/po-helper.interface';
1414
import { PoPopoverComponent } from '../po-popover/po-popover.component';
1515
import { PoButtonComponent } from '../po-button';
16-
import { parseHelperContent, PoHelperTextFragment } from './po-helper-content-utils';
16+
import { parseSafeText, PoTextFragment, PoFormattingTag } from '../../utils/safe-text-parser';
17+
18+
/** Tags de formatação aceitas pelo po-helper. */
19+
const PO_HELPER_ALLOWED_TAGS: Array<PoFormattingTag> = ['b', 'i', 'u', 'strong', 'em'];
1720
/**
1821
* @docsExtends PoHelperBaseComponent
1922
*
@@ -70,12 +73,12 @@ export class PoHelperComponent extends PoHelperBaseComponent implements AfterVie
7073
}
7174
};
7275

73-
protected readonly contentFragments = computed<Array<PoHelperTextFragment>>(() => {
76+
protected readonly contentFragments = computed<Array<PoTextFragment>>(() => {
7477
const helperValue = this.helper();
7578
if (!helperValue) {
7679
return [];
7780
}
78-
return parseHelperContent((helperValue as PoHelperOptions).content);
81+
return parseSafeText((helperValue as PoHelperOptions).content, PO_HELPER_ALLOWED_TAGS);
7982
});
8083

8184
constructor(private readonly cdr: ChangeDetectorRef) {

projects/ui/src/lib/components/po-helper/po-helper.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common';
22
import { NgModule } from '@angular/core';
33

44
import { PoHelperComponent } from './po-helper.component';
5-
import { PoHelperContentPipe } from './po-helper-content.pipe';
65

76
import { PoIconModule } from '../po-icon/index';
87
import { PoLinkModule } from '../po-link/index';
@@ -15,7 +14,7 @@ import { PoDividerModule } from '../po-divider/index';
1514
*/
1615
@NgModule({
1716
imports: [CommonModule, PoIconModule, PoPopoverModule, PoLinkModule, PoDividerModule],
18-
declarations: [PoHelperComponent, PoHelperContentPipe],
17+
declarations: [PoHelperComponent],
1918
exports: [PoHelperComponent]
2019
})
2120
export class PoHelperModule {}

projects/ui/src/lib/components/po-page/po-page-default/po-page-default-base.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,15 @@ export abstract class PoPageDefaultBaseComponent {
283283
*
284284
* Define um texto de apoio ou informações adicionais logo abaixo do título principal.
285285
*
286-
* > Requer que`p-title` esteja definido.
286+
* Suporta formatação básica com as tags `<b>` (negrito), `<strong>` (negrito), `<i>` (itálico), `<em>` (itálico) e
287+
* `<u>` (sublinhado).
288+
*
289+
* Exemplo:
290+
* ```typescript
291+
* subtitle = 'Texto <b>importante</b> com <em>destaque</em> e <u>sublinhado</u>';
292+
* ```
293+
*
294+
* > Requer que `p-title` esteja definido.
287295
*/
288296
@Input('p-subtitle') set subtitle(value: string) {
289297
this._subtitle = value;

projects/ui/src/lib/components/po-page/po-page-detail/po-page-detail-base.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,17 @@ export class PoPageDetailBaseComponent {
192192
*
193193
* @description
194194
*
195-
* Subtitulo do Header da página
195+
* Subtitulo do Header da página.
196+
*
197+
* Suporta formatação básica com as tags `<b>` (negrito), `<strong>` (negrito), `<i>` (itálico), `<em>` (itálico) e
198+
* `<u>` (sublinhado).
199+
*
200+
* Exemplo:
201+
* ```typescript
202+
* subtitle = 'Status: <b>Active</b> | Role: <i>Administrator</i>';
203+
* ```
204+
*
205+
* > Requer que `p-title` esteja definido.
196206
*/
197207
@Input('p-subtitle') subtitle: string;
198208

projects/ui/src/lib/components/po-page/po-page-detail/samples/sample-po-page-detail-user/sample-po-page-detail-user.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<po-page-detail p-title="User Detail" [p-breadcrumb]="breadcrumb" (p-edit)="edit()">
1+
<po-page-detail
2+
p-title="User Detail"
3+
p-subtitle="Status: <b>Active</b> | Role: <i>Administrator</i>"
4+
[p-breadcrumb]="breadcrumb"
5+
(p-edit)="edit()"
6+
>
27
<div class="po-row">
38
<po-info class="po-md-4" p-label="User ID" [p-value]="userId"> </po-info>
49

0 commit comments

Comments
 (0)