@cityway/bo-ui 1.1.0-beta029 → 1.1.0-beta030

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -52,7 +52,7 @@ Trois emplacements dans la barre d'actions, dans l'ordre du template, plus un so
52
52
  | Import | `cwPageHeaderImport` | en tête de barre, avant l'export | `<cw-import-button>` |
53
53
  | Export | `cwPageHeaderExport` | après l'import, avant le slot libre | `<cw-export-button>` |
54
54
  | Libre | *(aucun)* | après l'export, avant *Réinitialiser* | tout le reste |
55
- | Description | `cwPageHeaderDescription` | sous le titre, à la place de `description` (même classe `page-header-description`) | badges `cw-badge`, lien, donnée mise en forme. **L'emporte sur l'input `description`** s'il est rempli. Depuis la beta029. |
55
+ | Description | `cwPageHeaderDescription` | sous le titre, à la place de `description` (même classe `page-header-description`) | badges `cw-badge`, lien, donnée mise en forme. **L'emporte sur l'input `description`** s'il est rempli. Le remplissage est suivi en continu (beta030) : un slot rendu après coup (`@if (user())`) remplace `description`, un slot vidé la fait réapparaître. Depuis la beta029. |
56
56
 
57
57
  ```html
58
58
  <cw-page-header [title]="'DOMAIN.USERS.TITLE'" [actions]="[actionEnum.add]" (action)="onAction($event)">
@@ -213,15 +213,17 @@ Configuration de `importConfig` / `exportOptions` : voir `import-button.md` et
213
213
  ### Description riche (badges, donnée)
214
214
 
215
215
  ```html
216
- <cw-page-header [title]="'USERS.DETAIL.TITLE'">
217
- <span cwPageHeaderDescription class="d-flex-h gap-xs items-center">
218
- {{ user().email }}
219
- <cw-badge [type]="badgeType.lightSuccess" [label]="'USERS.STATUS.ACTIVE'" />
220
- </span>
216
+ <cw-page-header [title]="'USERS.DETAIL.TITLE'" [description]="'USERS.DETAIL.SUBTITLE'">
217
+ @if (user(); as u) {
218
+ <span cwPageHeaderDescription class="d-flex-h gap-xs items-center">
219
+ {{ u.email }}
220
+ <cw-badge [type]="badgeType.lightSuccess" [label]="'USERS.STATUS.ACTIVE'" />
221
+ </span>
222
+ }
221
223
  </cw-page-header>
222
224
  ```
223
225
 
224
- `{{ user().email }}` est interpolé : `&` et `<` s'affichent tels quels, sans échappement manuel.
226
+ `{{ u.email }}` est interpolé : `&` et `<` s'affichent tels quels, sans échappement manuel. Tant que `user()` est vide (chargement HTTP), `description` sert de repli ; dès que le slot est rendu, il la remplace (depuis la beta030 ; avant, un slot rendu après le premier affichage était ignoré). Inutile de rendre le `<span>` en permanence avec un `@else` recopiant le texte de repli.
225
227
 
226
228
  ### Action personnalisée projetée
227
229
 
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, ChangeDetectionStrategy, Component, output, effect, signal, computed, untracked, isDevMode, InjectionToken, makeEnvironmentProviders, inject, DestroyRef, contentChild, viewChild, afterNextRender, isSignal, Injector, ElementRef, viewChildren, afterRenderEffect, ChangeDetectorRef, contentChildren } from '@angular/core';
2
+ import { input, ChangeDetectionStrategy, Component, output, effect, signal, computed, untracked, isDevMode, InjectionToken, makeEnvironmentProviders, inject, DestroyRef, contentChild, viewChild, afterNextRender, isSignal, Injector, ElementRef, viewChildren, afterRenderEffect, contentChildren } from '@angular/core';
3
3
  import { BoButtonTypeEnum, BadgeTypeEnum, BadgeComponent, ButtonComponent, CardComponent, SpriteIconEnum, IconSizeEnum, ButtonPositionEnum, ButtonIconSizeEnum, AlertTypeEnum, CardTypeEnum, IconComponent, AlertComponent, FormFieldTypeEnum, FormFieldComponent, ModalsService, IconTypeEnum, IconUiTypeEnum, EmptyStateIllustrationEnum, ModalsType, LoaderComponent, ImageComponent, EmptyStateComponent, DividerComponent, ToastService, DropdownItemDirective, LoaderSizeEnum, AccordionComponent, FileDropComponent, FileToDownloadComponent } from '@cityway/basic-ui';
4
4
  import * as i1 from '@ngx-translate/core';
5
5
  import { TranslateModule, TranslateService } from '@ngx-translate/core';
@@ -2627,7 +2627,6 @@ var PageHeaderActionEnum;
2627
2627
  class PageHeaderComponent {
2628
2628
  constructor() {
2629
2629
  this.location = inject(Location);
2630
- this.cdRef = inject(ChangeDetectorRef);
2631
2630
  /** Portee courante fournie par l'app (`provideCwPageScope`) ; `null` sans provider. */
2632
2631
  this.pageScope = inject(CW_PAGE_SCOPE);
2633
2632
  this.title = input.required(...(ngDevMode ? [{ debugName: "title" }] : []));
@@ -2651,20 +2650,26 @@ class PageHeaderComponent {
2651
2650
  this.badgeType = BadgeTypeEnum;
2652
2651
  this.descriptionSlot = viewChild('descriptionSlot', ...(ngDevMode ? [{ debugName: "descriptionSlot" }] : []));
2653
2652
  /**
2654
- * Slot `[cwPageHeaderDescription]` rempli. Vaut `false` jusqu'au premier rendu, puis est lu
2655
- * depuis le DOM (meme principe que l'en-tete de `cw-card`).
2653
+ * Slot `[cwPageHeaderDescription]` rempli, lu dans le DOM et suivi par un `MutationObserver` :
2654
+ * un slot rendu apres coup (`@if` sur une donnee chargee en HTTP) s'affiche, un slot vide fait
2655
+ * reapparaitre `description` (meme principe que l'en-tete de `cw-card`).
2656
2656
  */
2657
2657
  this.hasDescriptionSlot = signal(false, ...(ngDevMode ? [{ debugName: "hasDescriptionSlot" }] : []));
2658
2658
  this.showReset = computed(() => this.actions().includes(PageHeaderActionEnum.reset), ...(ngDevMode ? [{ debugName: "showReset" }] : []));
2659
2659
  this.showAdd = computed(() => this.actions().includes(PageHeaderActionEnum.add), ...(ngDevMode ? [{ debugName: "showAdd" }] : []));
2660
2660
  this.showSave = computed(() => this.actions().includes(PageHeaderActionEnum.save), ...(ngDevMode ? [{ debugName: "showSave" }] : []));
2661
- }
2662
- ngAfterViewInit() {
2663
- const projected = (this.descriptionSlot()?.nativeElement.children.length ?? 0) > 0;
2664
- if (projected) {
2665
- this.hasDescriptionSlot.set(true);
2666
- this.cdRef.detectChanges();
2667
- }
2661
+ effect(onCleanup => {
2662
+ const slot = this.descriptionSlot()?.nativeElement;
2663
+ if (!slot)
2664
+ return;
2665
+ const update = () => this.hasDescriptionSlot.set(slot.children.length > 0);
2666
+ untracked(update);
2667
+ if (typeof MutationObserver === 'undefined')
2668
+ return;
2669
+ const observer = new MutationObserver(update);
2670
+ observer.observe(slot, { childList: true });
2671
+ onCleanup(() => observer.disconnect());
2672
+ });
2668
2673
  }
2669
2674
  goBack() {
2670
2675
  this.location.back();
@@ -2689,7 +2694,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.20", ngImpo
2689
2694
  IconComponent,
2690
2695
  TranslateModule
2691
2696
  ], template: "<div class=\"page-header d-flex-v gap-2xs\">\r\n @if (showBack()) {\r\n <cw-button [type]=\"buttonType.ghost\" [label]=\"'_COMMON._FORM.BACK'\" [withIcon]=\"spriteIcon.left1\"\r\n (btnAction)=\"goBack()\" />\r\n }\r\n <div class=\"d-flex-h gap-md items-start justify-between flex-wrap\">\r\n <div class=\"d-flex-v\">\r\n <!-- Badge de portee HORS du <h1> : le nom accessible du titre reste le titre. -->\r\n <div class=\"page-header-heading d-flex-h gap-sm flex-wrap items-center\">\r\n <h1 class=\"page-header-title\">{{ title() | translate}}</h1>\r\n @if (showScope() && pageScope(); as scope) {\r\n @if (scope.kind === 'instance') {\r\n <!-- Badge maison : structure `.badge` de basic-ui, couleurs et logo propres (cf. _page-header.scss). -->\r\n <span class=\"badge page-header-scope-instance\">\r\n @if (scope.imageUrl; as img) {\r\n <img class=\"page-header-scope-logo\" [src]=\"img\" alt=\"\" />\r\n } @else {\r\n <cw-icon [icon]=\"spriteIcon.poiCompany\" aria-hidden=\"true\" />\r\n }\r\n <span class=\"visually-hidden\">{{ '_COMMON._PAGE_SCOPE.INSTANCE_PREFIX' | translate }}</span>\r\n <span>{{ scope.label }}</span>\r\n </span>\r\n } @else {\r\n <cw-badge [type]=\"badgeType.lightInfo\" [label]=\"'_COMMON._PAGE_SCOPE.ALL_INSTANCES'\"\r\n [withIcon]=\"spriteIcon.mapWorld\" />\r\n }\r\n }\r\n </div>\r\n <!-- Description riche (badges, lien...) : `<span cwPageHeaderDescription>\u2026</span>`. Si le slot\r\n est rempli, il l'emporte sur l'input `description`. -->\r\n <div #descriptionSlot class=\"fs-md page-header-description\" [class.d-none]=\"!hasDescriptionSlot()\">\r\n <ng-content select=\"[cwPageHeaderDescription]\"></ng-content>\r\n </div>\r\n <!-- Texte interpole, jamais du HTML : une donnee (email, nom saisi) s'affiche telle quelle. -->\r\n @if (!hasDescriptionSlot() && description(); as desc) {\r\n <p class=\"fs-md page-header-description\">{{ desc | translate }}</p>\r\n }\r\n </div>\r\n\r\n <div class=\"d-flex-v gap-2xs\">\r\n <div class=\"page-header-actions d-flex-h gap-md flex-wrap items-center justify-end\">\r\n <!-- Slot de l'import : `<cw-import-button cwPageHeaderImport \u2026>`. Projete plutot que\r\n rendu, pour que `cw-page-header` ne reference pas `cw-import-wizard`. -->\r\n <ng-content select=\"[cwPageHeaderImport]\"></ng-content>\r\n\r\n <!-- Slot de l'export : `<cw-export-button cwPageHeaderExport \u2026>`. -->\r\n <ng-content select=\"[cwPageHeaderExport]\"></ng-content>\r\n\r\n <!-- Slot libre, inchange : tout ce qui n'est marque ni import ni export atterrit ici.\r\n C'est l'echappatoire d'un hote qui veut piloter son propre bouton. -->\r\n <ng-content></ng-content>\r\n\r\n @if (showReset()) {\r\n <cw-button [type]=\"buttonType.secondary\" [label]=\"'_COMMON._ACTION.RESET'\"\r\n [isDisabled]=\"disabled(actionEnum.reset)\" [isLoading]=\"loading(actionEnum.reset)\"\r\n (btnAction)=\"emit(actionEnum.reset)\">\r\n </cw-button>\r\n }\r\n\r\n @if (showAdd()) {\r\n <cw-button [type]=\"buttonType.primary\" [label]=\"'_COMMON._ACTION.ADD'\" [withIcon]=\"spriteIcon.add\"\r\n [isDisabled]=\"disabled(actionEnum.add)\" [isLoading]=\"loading(actionEnum.add)\"\r\n (btnAction)=\"emit(actionEnum.add)\">\r\n </cw-button>\r\n }\r\n\r\n @if (showSave()) {\r\n <cw-button [type]=\"buttonType.primary\" [label]=\"'_COMMON._ACTION.SAVE'\" [isDisabled]=\"disabled(actionEnum.save)\"\r\n [isLoading]=\"loading(actionEnum.save)\" (btnAction)=\"emit(actionEnum.save)\">\r\n </cw-button>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n" }]
2692
- }], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: true }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], showBack: [{ type: i0.Input, args: [{ isSignal: true, alias: "showBack", required: false }] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], isLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "isLoading", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDisabled", required: false }] }], showScope: [{ type: i0.Input, args: [{ isSignal: true, alias: "showScope", required: false }] }], action: [{ type: i0.Output, args: ["action"] }], descriptionSlot: [{ type: i0.ViewChild, args: ['descriptionSlot', { isSignal: true }] }] } });
2697
+ }], ctorParameters: () => [], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: true }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], showBack: [{ type: i0.Input, args: [{ isSignal: true, alias: "showBack", required: false }] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], isLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "isLoading", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDisabled", required: false }] }], showScope: [{ type: i0.Input, args: [{ isSignal: true, alias: "showScope", required: false }] }], action: [{ type: i0.Output, args: ["action"] }], descriptionSlot: [{ type: i0.ViewChild, args: ['descriptionSlot', { isSignal: true }] }] } });
2693
2698
 
2694
2699
  class WizardStepComponent {
2695
2700
  constructor() {