@masterteam/components 0.0.281 → 0.0.283

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, computed, ChangeDetectionStrategy, Component, inject, ElementRef, DestroyRef, afterNextRender, Directive, signal, effect, untracked, output, NgZone, model } from '@angular/core';
2
+ import { input, computed, ChangeDetectionStrategy, Component, inject, ElementRef, DestroyRef, afterNextRender, Directive, signal, effect, untracked, ViewEncapsulation, output, NgZone, model } from '@angular/core';
3
3
  import { TruncateTooltip, Tooltip } from '@masterteam/components/tooltip';
4
4
  import { Icon } from '@masterteam/icons';
5
5
  import { MTDateFormatPipe, REQUEST_CONTEXT, readableTextOn } from '@masterteam/components';
@@ -19,6 +19,76 @@ import { TooltipModule } from 'primeng/tooltip';
19
19
  import { NgTemplateOutlet, DOCUMENT } from '@angular/common';
20
20
  import { CdkDrag, CdkDropList, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
21
21
 
22
+ /**
23
+ * A section is persisted/transported as an ordinary display item whose
24
+ * `propertyKey` carries this sentinel prefix instead of a real property key
25
+ * (mirrors the LeafDetails synthetic-key convention). Both the customization
26
+ * builder and the runtime renderer recognize it, so the constant lives here in
27
+ * the shared entities layer rather than in either consumer.
28
+ */
29
+ const SECTION_KEY_PREFIX = '__section__::';
30
+ /** True when a display item's key denotes a section marker. */
31
+ function isSectionKey(key) {
32
+ return typeof key === 'string' && key.startsWith(SECTION_KEY_PREFIX);
33
+ }
34
+ /** Mints a unique section marker key. */
35
+ function buildSectionKey() {
36
+ return `${SECTION_KEY_PREFIX}${crypto.randomUUID()}`;
37
+ }
38
+ /**
39
+ * Resolves a localized label (`{ en, ar }`) for the given language, falling
40
+ * back across locales. Returns '' when nothing is set.
41
+ */
42
+ function resolveLocalizedLabel(label, lang) {
43
+ if (!label)
44
+ return '';
45
+ const primary = lang === 'ar' ? label.ar : label.en;
46
+ return (primary || label.en || label.ar || '').trim();
47
+ }
48
+ /** True when the entity is a `Section` layout marker rather than a value. */
49
+ function isEntitySection(entity) {
50
+ return entity?.viewType === 'Section';
51
+ }
52
+ /**
53
+ * Splits a flat, order-sorted entity list into section groups. Membership is
54
+ * purely positional: each entity belongs to whichever `Section` marker precedes
55
+ * it. Pass the output of `buildDisplayEntities` (already sorted by `order`).
56
+ *
57
+ * Zero markers → a single `{ section: null }` group holding everything, so the
58
+ * bare-grid rendering is unchanged. Empty leading/trailing runs are dropped.
59
+ */
60
+ function groupEntitiesIntoSections(entities) {
61
+ const groups = [];
62
+ let current = { section: null, entities: [] };
63
+ const flush = () => {
64
+ if (current.section || current.entities.length > 0) {
65
+ groups.push(current);
66
+ }
67
+ };
68
+ for (const entity of entities) {
69
+ if (isEntitySection(entity)) {
70
+ flush();
71
+ current = { section: entity, entities: [] };
72
+ }
73
+ else {
74
+ current.entities.push(entity);
75
+ }
76
+ }
77
+ flush();
78
+ return groups;
79
+ }
80
+ /**
81
+ * Resolves a section marker's display label for the given language, falling
82
+ * back across locales and finally to the entity's `name`.
83
+ */
84
+ function getEntitySectionTitle(section, lang) {
85
+ if (!section)
86
+ return '';
87
+ const label = section.configuration
88
+ ?.label;
89
+ return resolveLocalizedLabel(label, lang) || (section.name ?? '');
90
+ }
91
+
22
92
  const ENTITY_EMPTY_VALUE_PLACEHOLDER = '_';
23
93
  function isValueMissing(value) {
24
94
  if (value === null || value === undefined) {
@@ -81,6 +151,19 @@ function isEntityAlignEnd(configuration) {
81
151
  const config = configuration;
82
152
  return config?.alignEnd ?? false;
83
153
  }
154
+ /**
155
+ * The admin-authored note attached to a property in the customization drawer
156
+ * (`configuration.info`), resolved for the active language.
157
+ *
158
+ * Returns `''` when there is no note, which is what the renderer keys off to
159
+ * decide whether the entity gets an info affordance at all. The drawer omits
160
+ * the key entirely rather than writing an empty object, so "absent" and "blank"
161
+ * collapse to the same answer here on purpose.
162
+ */
163
+ function resolveEntityInfo(configuration, lang) {
164
+ const config = configuration;
165
+ return resolveLocalizedLabel(config?.info, lang);
166
+ }
84
167
  /**
85
168
  * The product default: label above value.
86
169
  *
@@ -918,76 +1001,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
918
1001
  args: [{ selector: 'mt-entity-lookup', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (lookupValues().length) {\r\n <div class=\"flex flex-wrap gap-2\" data-testid=\"lookup-values\">\r\n @for (lookup of lookupValues(); track lookup.key) {\r\n <span\r\n class=\"inline-flex w-fit items-center rounded-md px-3 py-2 text-xs font-semibold\"\r\n data-testid=\"lookup-value\"\r\n [style]=\"lookupBadgeStyle(lookup)\"\r\n >\r\n {{ lookupLabel(lookup) }}\r\n </span>\r\n }\r\n </div>\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center px-3 py-2 rounded-md text-xs font-semibold w-fit text-gray-500 bg-gray-100\"\r\n >\r\n {{ emptyLabel }}\r\n </span>\r\n }\r\n</mt-entity-field>\r\n" }]
919
1002
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }] } });
920
1003
 
921
- /**
922
- * A section is persisted/transported as an ordinary display item whose
923
- * `propertyKey` carries this sentinel prefix instead of a real property key
924
- * (mirrors the LeafDetails synthetic-key convention). Both the customization
925
- * builder and the runtime renderer recognize it, so the constant lives here in
926
- * the shared entities layer rather than in either consumer.
927
- */
928
- const SECTION_KEY_PREFIX = '__section__::';
929
- /** True when a display item's key denotes a section marker. */
930
- function isSectionKey(key) {
931
- return typeof key === 'string' && key.startsWith(SECTION_KEY_PREFIX);
932
- }
933
- /** Mints a unique section marker key. */
934
- function buildSectionKey() {
935
- return `${SECTION_KEY_PREFIX}${crypto.randomUUID()}`;
936
- }
937
- /**
938
- * Resolves a localized label (`{ en, ar }`) for the given language, falling
939
- * back across locales. Returns '' when nothing is set.
940
- */
941
- function resolveLocalizedLabel(label, lang) {
942
- if (!label)
943
- return '';
944
- const primary = lang === 'ar' ? label.ar : label.en;
945
- return (primary || label.en || label.ar || '').trim();
946
- }
947
- /** True when the entity is a `Section` layout marker rather than a value. */
948
- function isEntitySection(entity) {
949
- return entity?.viewType === 'Section';
950
- }
951
- /**
952
- * Splits a flat, order-sorted entity list into section groups. Membership is
953
- * purely positional: each entity belongs to whichever `Section` marker precedes
954
- * it. Pass the output of `buildDisplayEntities` (already sorted by `order`).
955
- *
956
- * Zero markers → a single `{ section: null }` group holding everything, so the
957
- * bare-grid rendering is unchanged. Empty leading/trailing runs are dropped.
958
- */
959
- function groupEntitiesIntoSections(entities) {
960
- const groups = [];
961
- let current = { section: null, entities: [] };
962
- const flush = () => {
963
- if (current.section || current.entities.length > 0) {
964
- groups.push(current);
965
- }
966
- };
967
- for (const entity of entities) {
968
- if (isEntitySection(entity)) {
969
- flush();
970
- current = { section: entity, entities: [] };
971
- }
972
- else {
973
- current.entities.push(entity);
974
- }
975
- }
976
- flush();
977
- return groups;
978
- }
979
- /**
980
- * Resolves a section marker's display label for the given language, falling
981
- * back across locales and finally to the entity's `name`.
982
- */
983
- function getEntitySectionTitle(section, lang) {
984
- if (!section)
985
- return '';
986
- const label = section.configuration
987
- ?.label;
988
- return resolveLocalizedLabel(label, lang) || (section.name ?? '');
989
- }
990
-
991
1004
  /** `#RGB` / `#RRGGBB`. Anything else is used as-is for the text color only. */
992
1005
  const HEX_COLOR_PATTERN = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
993
1006
  /**
@@ -1515,10 +1528,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
1515
1528
  args: [{ selector: 'mt-entity-schedule-item', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, Chip], template: "<mt-entity-field\n [label]=\"displayName()\"\n [configuration]=\"data()?.configuration\"\n gap=\"normal\"\n>\n @if (items().length) {\n <div class=\"flex flex-wrap items-center gap-2\">\n @for (item of items(); track item.id) {\n <mt-chip [label]=\"item.name\" size=\"small\" />\n }\n </div>\n } @else {\n <span\n class=\"inline-flex items-center px-3 py-2 rounded-md text-xs font-semibold w-fit text-gray-500 bg-gray-100\"\n >\n {{ emptyLabel }}\n </span>\n }\n</mt-entity-field>\n" }]
1516
1529
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
1517
1530
 
1531
+ /**
1532
+ * One shared active-language signal per `TranslocoService`.
1533
+ *
1534
+ * `mt-entity-preview` renders once per property per record — a client-list card
1535
+ * grid mounts thousands of them — so a `toSignal(langChanges$)` inside each
1536
+ * instance would open thousands of subscriptions to the same Subject just to
1537
+ * read one global value. The language is global, so the signal is too: created
1538
+ * once, cached against the service, and shared by every entity that needs it.
1539
+ *
1540
+ * `manualCleanup` is deliberate. The cached signal outlives any single
1541
+ * component by design, and the service it hangs off is the root injector's —
1542
+ * tying its subscription to whichever entity happened to ask first would tear
1543
+ * it down the moment that entity scrolled out of view.
1544
+ */
1545
+ const langSignals = new WeakMap();
1546
+ function sharedActiveLang(transloco) {
1547
+ const cached = langSignals.get(transloco);
1548
+ if (cached) {
1549
+ return cached;
1550
+ }
1551
+ const lang = toSignal(transloco.langChanges$, {
1552
+ initialValue: transloco.getActiveLang(),
1553
+ manualCleanup: true,
1554
+ });
1555
+ langSignals.set(transloco, lang);
1556
+ return lang;
1557
+ }
1558
+
1518
1559
  /** Neutral grey for a status the catalog left without a colour. */
1519
1560
  const DEFAULT_STATUS_COLOR = '#9CA3AF';
1520
1561
  class EntityLeafDetails {
1562
+ transloco = inject(TranslocoService);
1521
1563
  data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1564
+ /**
1565
+ * Re-resolves the "Phases" qualifier when the user switches language. The
1566
+ * shared signal keeps this to one subscription for the whole grid — a cards
1567
+ * board mounts thousands of these.
1568
+ */
1569
+ activeLang = sharedActiveLang(this.transloco);
1522
1570
  leafValue = computed(() => {
1523
1571
  const v = this.data().value;
1524
1572
  if (v && typeof v === 'object' && !Array.isArray(v) && 'levelId' in v) {
@@ -1526,13 +1574,34 @@ class EntityLeafDetails {
1526
1574
  }
1527
1575
  return null;
1528
1576
  }, ...(ngDevMode ? [{ debugName: "leafValue" }] : /* istanbul ignore next */ []));
1529
- /** Label shown below the badges: "Level Name (total)" */
1577
+ /** True when this item paints the level's phase badges instead of statuses. */
1578
+ isPhaseItem = computed(() => this.leafValue()?.kind === 'phase', ...(ngDevMode ? [{ debugName: "isPhaseItem" }] : /* istanbul ignore next */ []));
1579
+ /**
1580
+ * The badges to paint. Phases and statuses carry the same `{ key, display,
1581
+ * color, count }` shape, so one template drives both — only which projection
1582
+ * of the level is read differs.
1583
+ */
1584
+ badges = computed(() => {
1585
+ const leaf = this.leafValue();
1586
+ if (!leaf)
1587
+ return [];
1588
+ return this.isPhaseItem() ? (leaf.phases ?? []) : leaf.statuses;
1589
+ }, ...(ngDevMode ? [{ debugName: "badges" }] : /* istanbul ignore next */ []));
1590
+ /**
1591
+ * Label shown below the badges: "Level Name (total)", with a "— Phases"
1592
+ * qualifier on the phase item so a level configured with both projections
1593
+ * does not render two identically-labelled tiles.
1594
+ */
1530
1595
  labelWithTotal = computed(() => {
1531
1596
  const leaf = this.leafValue();
1532
- const name = this.data().name ?? leaf?.levelName ?? '';
1597
+ const lang = this.activeLang();
1598
+ const base = this.data().name ?? leaf?.levelName ?? '';
1599
+ const name = this.isPhaseItem()
1600
+ ? `${base} — ${this.transloco.translate('components.entitiesPreview.leafPhases', {}, lang)}`
1601
+ : base;
1533
1602
  if (!leaf)
1534
1603
  return name;
1535
- const total = leaf.statuses.reduce((sum, s) => sum + s.count, 0);
1604
+ const total = this.badges().reduce((sum, badge) => sum + badge.count, 0);
1536
1605
  return `${name} (${total})`;
1537
1606
  }, ...(ngDevMode ? [{ debugName: "labelWithTotal" }] : /* istanbul ignore next */ []));
1538
1607
  labelIcon = computed(() => this.leafValue()?.levelIcon ?? null, ...(ngDevMode ? [{ debugName: "labelIcon" }] : /* istanbul ignore next */ []));
@@ -1548,11 +1617,11 @@ class EntityLeafDetails {
1548
1617
  return readableTextOn(this.statusColor(color));
1549
1618
  }
1550
1619
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityLeafDetails, deps: [], target: i0.ɵɵFactoryTarget.Component });
1551
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityLeafDetails, isStandalone: true, selector: "mt-entity-leaf-details", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\r\n [label]=\"labelWithTotal()\"\r\n [labelIconName]=\"labelIcon()\"\r\n [configuration]=\"data().configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (leafValue(); as leaf) {\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (status of leaf.statuses; track status.key) {\r\n <!--\r\n The badge is a count, and the colour is the only thing saying WHICH\r\n count \u2014 so the status name has to be reachable without hovering, and\r\n the number has to be legible on whatever hex the tenant's catalog\r\n carries. The tooltip names it for a pointer, the aria-label names it\r\n for a screen reader, and the foreground is chosen against the badge\r\n colour rather than hardcoded white (findings M-04, H-03).\r\n -->\r\n <div\r\n class=\"flex h-7 min-w-7 items-center justify-center rounded-lg px-1.5 text-xs font-bold tabular-nums\"\r\n role=\"img\"\r\n [style.background-color]=\"statusColor(status.color)\"\r\n [style.color]=\"statusTextColor(status.color)\"\r\n [attr.aria-label]=\"status.display + ': ' + status.count\"\r\n [pTooltip]=\"status.display\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ status.count }}\r\n </div>\r\n }\r\n @if (leaf.statuses.length === 0) {\r\n <span class=\"text-sm text-muted-color\">\u2014</span>\r\n }\r\n </div>\r\n }\r\n</mt-entity-field>\r\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i1$1.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "showOnEllipsis", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip", "pTooltipPT", "pTooltipUnstyled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1620
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityLeafDetails, isStandalone: true, selector: "mt-entity-leaf-details", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\r\n [label]=\"labelWithTotal()\"\r\n [labelIconName]=\"labelIcon()\"\r\n [configuration]=\"data().configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (leafValue()) {\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (badge of badges(); track badge.key) {\r\n <!--\r\n The badge is a count, and the colour is the only thing saying WHICH\r\n count \u2014 so the status/phase name has to be reachable without hovering,\r\n and the number has to be legible on whatever hex the tenant's catalog\r\n carries. The tooltip names it for a pointer, the aria-label names it\r\n for a screen reader, and the foreground is chosen against the badge\r\n colour rather than hardcoded white (findings M-04, H-03).\r\n -->\r\n <div\r\n class=\"flex h-7 min-w-7 items-center justify-center rounded-lg px-1.5 text-xs font-bold tabular-nums\"\r\n role=\"img\"\r\n [style.background-color]=\"statusColor(badge.color)\"\r\n [style.color]=\"statusTextColor(badge.color)\"\r\n [attr.aria-label]=\"badge.display + ': ' + badge.count\"\r\n [pTooltip]=\"badge.display\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ badge.count }}\r\n </div>\r\n }\r\n @if (badges().length === 0) {\r\n <span class=\"text-sm text-muted-color\">\u2014</span>\r\n }\r\n </div>\r\n }\r\n</mt-entity-field>\r\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i1$1.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "showOnEllipsis", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip", "pTooltipPT", "pTooltipUnstyled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1552
1621
  }
1553
1622
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityLeafDetails, decorators: [{
1554
1623
  type: Component,
1555
- args: [{ selector: 'mt-entity-leaf-details', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [EntityField, TooltipModule], template: "<mt-entity-field\r\n [label]=\"labelWithTotal()\"\r\n [labelIconName]=\"labelIcon()\"\r\n [configuration]=\"data().configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (leafValue(); as leaf) {\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (status of leaf.statuses; track status.key) {\r\n <!--\r\n The badge is a count, and the colour is the only thing saying WHICH\r\n count \u2014 so the status name has to be reachable without hovering, and\r\n the number has to be legible on whatever hex the tenant's catalog\r\n carries. The tooltip names it for a pointer, the aria-label names it\r\n for a screen reader, and the foreground is chosen against the badge\r\n colour rather than hardcoded white (findings M-04, H-03).\r\n -->\r\n <div\r\n class=\"flex h-7 min-w-7 items-center justify-center rounded-lg px-1.5 text-xs font-bold tabular-nums\"\r\n role=\"img\"\r\n [style.background-color]=\"statusColor(status.color)\"\r\n [style.color]=\"statusTextColor(status.color)\"\r\n [attr.aria-label]=\"status.display + ': ' + status.count\"\r\n [pTooltip]=\"status.display\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ status.count }}\r\n </div>\r\n }\r\n @if (leaf.statuses.length === 0) {\r\n <span class=\"text-sm text-muted-color\">\u2014</span>\r\n }\r\n </div>\r\n }\r\n</mt-entity-field>\r\n" }]
1624
+ args: [{ selector: 'mt-entity-leaf-details', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [EntityField, TooltipModule], template: "<mt-entity-field\r\n [label]=\"labelWithTotal()\"\r\n [labelIconName]=\"labelIcon()\"\r\n [configuration]=\"data().configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (leafValue()) {\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (badge of badges(); track badge.key) {\r\n <!--\r\n The badge is a count, and the colour is the only thing saying WHICH\r\n count \u2014 so the status/phase name has to be reachable without hovering,\r\n and the number has to be legible on whatever hex the tenant's catalog\r\n carries. The tooltip names it for a pointer, the aria-label names it\r\n for a screen reader, and the foreground is chosen against the badge\r\n colour rather than hardcoded white (findings M-04, H-03).\r\n -->\r\n <div\r\n class=\"flex h-7 min-w-7 items-center justify-center rounded-lg px-1.5 text-xs font-bold tabular-nums\"\r\n role=\"img\"\r\n [style.background-color]=\"statusColor(badge.color)\"\r\n [style.color]=\"statusTextColor(badge.color)\"\r\n [attr.aria-label]=\"badge.display + ': ' + badge.count\"\r\n [pTooltip]=\"badge.display\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ badge.count }}\r\n </div>\r\n }\r\n @if (badges().length === 0) {\r\n <span class=\"text-sm text-muted-color\">\u2014</span>\r\n }\r\n </div>\r\n }\r\n</mt-entity-field>\r\n" }]
1556
1625
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }] } });
1557
1626
 
1558
1627
  /**
@@ -1872,6 +1941,12 @@ function expandConnectionEntity(entity) {
1872
1941
  }
1873
1942
 
1874
1943
  const LEAF_DETAILS_KEY_SEPARATOR = '::leaflevel::';
1944
+ /**
1945
+ * The phase projection of the same child level. One level can contribute both
1946
+ * a status item and a phase item to the same area, so they need distinct keys
1947
+ * — the key is what each item's persisted order/size is looked up by.
1948
+ */
1949
+ const LEAF_PHASES_KEY_SEPARATOR = '::leafphase::';
1875
1950
  function isLeafDetailsStatusSummary(value) {
1876
1951
  return (!!value &&
1877
1952
  typeof value === 'object' &&
@@ -1902,6 +1977,28 @@ function isLeafDetailsRuntimeStatusCount(value) {
1902
1977
  isLeafDetailsRuntimeStatusDetails(value.details) &&
1903
1978
  'count' in value);
1904
1979
  }
1980
+ function isLeafDetailsRuntimePhaseCount(value) {
1981
+ return (!!value &&
1982
+ typeof value === 'object' &&
1983
+ 'details' in value &&
1984
+ isLeafDetailsRuntimeStatusDetails(value.details) &&
1985
+ 'count' in value);
1986
+ }
1987
+ /**
1988
+ * Phases are optional on both the catalog configuration and the runtime value —
1989
+ * the backend omits the field entirely for child levels with no phase gates —
1990
+ * so anything that is not a well-formed array reads as "no phases".
1991
+ */
1992
+ function readRuntimePhases(value) {
1993
+ return Array.isArray(value) && value.every(isLeafDetailsRuntimePhaseCount)
1994
+ ? value
1995
+ : [];
1996
+ }
1997
+ function readCatalogPhases(value) {
1998
+ return Array.isArray(value) && value.every(isLeafDetailsCatalogStatusValue)
1999
+ ? value
2000
+ : [];
2001
+ }
1905
2002
  function isLeafDetailsRuntimeChildSchema(value) {
1906
2003
  return (!!value &&
1907
2004
  typeof value === 'object' &&
@@ -1938,6 +2035,23 @@ function isLeafDetailsRuntimeValue(value) {
1938
2035
  function isLeafDetailsSyntheticKey(key) {
1939
2036
  return key?.includes(LEAF_DETAILS_KEY_SEPARATOR) ?? false;
1940
2037
  }
2038
+ /** True for the key of an expanded *phase* item of a LeafDetails property. */
2039
+ function isLeafPhasesSyntheticKey(key) {
2040
+ return key?.includes(LEAF_PHASES_KEY_SEPARATOR) ?? false;
2041
+ }
2042
+ /** True for either projection's expanded key. */
2043
+ function isLeafSyntheticKey(key) {
2044
+ return isLeafDetailsSyntheticKey(key) || isLeafPhasesSyntheticKey(key);
2045
+ }
2046
+ /** Splits either projection's expanded key back into property key + level id. */
2047
+ function splitLeafKey(key) {
2048
+ if (isLeafPhasesSyntheticKey(key)) {
2049
+ const [propertyKey, levelId] = key.split(LEAF_PHASES_KEY_SEPARATOR);
2050
+ return { propertyKey, levelId, kind: 'phase' };
2051
+ }
2052
+ const [propertyKey, levelId] = key.split(LEAF_DETAILS_KEY_SEPARATOR);
2053
+ return { propertyKey, levelId, kind: 'status' };
2054
+ }
1941
2055
  function toLeafDetailsStatusSummary(status) {
1942
2056
  return {
1943
2057
  key: status.details.key,
@@ -1946,6 +2060,15 @@ function toLeafDetailsStatusSummary(status) {
1946
2060
  count: status.count,
1947
2061
  };
1948
2062
  }
2063
+ function toLeafDetailsPhaseSummary(phase) {
2064
+ return {
2065
+ id: phase.details.id ?? null,
2066
+ key: phase.details.key,
2067
+ display: phase.details.display,
2068
+ color: phase.details.color || null,
2069
+ count: phase.count,
2070
+ };
2071
+ }
1949
2072
  function normalizeLeafDetailsCollection(value) {
1950
2073
  if (isLeafDetailsCollectionValue(value)) {
1951
2074
  return value;
@@ -1959,6 +2082,7 @@ function normalizeLeafDetailsCollection(value) {
1959
2082
  levelName: schema.levelName,
1960
2083
  levelIcon: schema.levelIcon,
1961
2084
  statuses: schema.statuses.map(toLeafDetailsStatusSummary),
2085
+ phases: readRuntimePhases(schema.phases).map(toLeafDetailsPhaseSummary),
1962
2086
  }));
1963
2087
  }
1964
2088
  if (typeof value === 'string' && value.trim().length > 0) {
@@ -1983,6 +2107,13 @@ function normalizeLeafDetailsCatalogConfiguration(value) {
1983
2107
  color: status.color ?? null,
1984
2108
  count: 0,
1985
2109
  })),
2110
+ phases: readCatalogPhases(level.phases).map((phase) => ({
2111
+ id: phase.id ?? null,
2112
+ key: phase.key,
2113
+ display: phase.display,
2114
+ color: phase.color || null,
2115
+ count: 0,
2116
+ })),
1986
2117
  }));
1987
2118
  }
1988
2119
  if (typeof value === 'string' && value.trim().length > 0) {
@@ -1999,8 +2130,7 @@ function expandLeafDetailsEntity(entity) {
1999
2130
  if (entity.viewType !== 'LeafDetails') {
2000
2131
  return [entity];
2001
2132
  }
2002
- if (isLeafDetailsSyntheticKey(entity.key) &&
2003
- isLeafDetailsValue(entity.value)) {
2133
+ if (isLeafSyntheticKey(entity.key) && isLeafDetailsValue(entity.value)) {
2004
2134
  return [entity];
2005
2135
  }
2006
2136
  const configuration = entity.configuration;
@@ -2014,7 +2144,7 @@ function expandLeafDetailsEntity(entity) {
2014
2144
  if (resolvedLevels.length === 0) {
2015
2145
  return [entity];
2016
2146
  }
2017
- const expanded = resolvedLevels.flatMap((level) => {
2147
+ const statusItems = resolvedLevels.flatMap((level) => {
2018
2148
  const levelConfig = configuration?.leafLevels?.[String(level.levelId)];
2019
2149
  if (configuration?.leafLevels && !levelConfig) {
2020
2150
  return [];
@@ -2031,6 +2161,7 @@ function expandLeafDetailsEntity(entity) {
2031
2161
  name: level.levelName,
2032
2162
  value: {
2033
2163
  ...level,
2164
+ kind: 'status',
2034
2165
  statuses: selectedStatuses
2035
2166
  ? level.statuses.filter((status) => selectedStatuses.has(status.key))
2036
2167
  : level.statuses,
@@ -2043,6 +2174,44 @@ function expandLeafDetailsEntity(entity) {
2043
2174
  },
2044
2175
  ];
2045
2176
  });
2177
+ /**
2178
+ * Phases are opt-in: only levels with an explicit `leafPhases` entry produce
2179
+ * a phase item. An absent map means "no phase badges", never "all of them" —
2180
+ * the opposite of `leafLevels`, whose absence predates the per-level config
2181
+ * and has to keep meaning "show every level".
2182
+ */
2183
+ const phaseItems = resolvedLevels.flatMap((level) => {
2184
+ const phaseConfig = configuration?.leafPhases?.[String(level.levelId)];
2185
+ if (!phaseConfig) {
2186
+ return [];
2187
+ }
2188
+ const phases = level.phases ?? [];
2189
+ const selectedPhases = phaseConfig.selectedPhases?.length
2190
+ ? new Set(phaseConfig.selectedPhases)
2191
+ : null;
2192
+ return [
2193
+ {
2194
+ ...entity,
2195
+ key: entity.key
2196
+ ? `${entity.key}${LEAF_PHASES_KEY_SEPARATOR}${level.levelId}`
2197
+ : entity.key,
2198
+ name: level.levelName,
2199
+ value: {
2200
+ ...level,
2201
+ kind: 'phase',
2202
+ phases: selectedPhases
2203
+ ? phases.filter((phase) => selectedPhases.has(phase.key))
2204
+ : phases,
2205
+ },
2206
+ order: phaseConfig.order ?? entity.order,
2207
+ configuration: {
2208
+ ...configuration,
2209
+ size: phaseConfig.size ?? configuration?.size,
2210
+ },
2211
+ },
2212
+ ];
2213
+ });
2214
+ const expanded = [...statusItems, ...phaseItems];
2046
2215
  return expanded.length > 0 ? expanded : [entity];
2047
2216
  }
2048
2217
  /**
@@ -2155,8 +2324,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
2155
2324
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }] } });
2156
2325
 
2157
2326
  class EntityPreview {
2327
+ transloco = inject(TranslocoService);
2158
2328
  data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
2159
2329
  attachmentShape = input('default', ...(ngDevMode ? [{ debugName: "attachmentShape" }] : /* istanbul ignore next */ []));
2330
+ activeLang = sharedActiveLang(this.transloco);
2331
+ /**
2332
+ * The admin-authored note for the active language, or `''` when the property
2333
+ * has none. Resolved here rather than in each `entity-*` component because
2334
+ * this is the one wrapper every view type and every call site passes through
2335
+ * — the card grid, the customization builder preview, and the standalone
2336
+ * `mt-entity-preview` usages in the app.
2337
+ */
2338
+ infoText = computed(() => resolveEntityInfo(this.data().configuration, this.activeLang()), ...(ngDevMode ? [{ debugName: "infoText" }] : /* istanbul ignore next */ []));
2160
2339
  comparisonKind = computed(() => {
2161
2340
  const c = this.data().comparison;
2162
2341
  if (!c)
@@ -2168,13 +2347,23 @@ class EntityPreview {
2168
2347
  return null;
2169
2348
  }, ...(ngDevMode ? [{ debugName: "comparisonKind" }] : /* istanbul ignore next */ []));
2170
2349
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityPreview, deps: [], target: i0.ɵɵFactoryTarget.Component });
2171
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityPreview, isStandalone: true, selector: "mt-entity-preview", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, attachmentShape: { classPropertyName: "attachmentShape", publicName: "attachmentShape", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "w-full" }, ngImport: i0, template: "@switch (comparisonKind()) {\r\n @case (\"Value\") {\r\n <mt-comparison-value [data]=\"data()\" />\r\n }\r\n @case (\"EntityList\") {\r\n <mt-comparison-entity-list [data]=\"data()\" />\r\n }\r\n @default {\r\n <mt-entity-preview-body\r\n [data]=\"data()\"\r\n [attachmentShape]=\"attachmentShape()\"\r\n />\r\n }\r\n}\r\n", dependencies: [{ kind: "component", type: EntityPreviewBody, selector: "mt-entity-preview-body", inputs: ["data", "attachmentShape"] }, { kind: "component", type: ComparisonValue, selector: "mt-comparison-value", inputs: ["data"] }, { kind: "component", type: ComparisonEntityList, selector: "mt-comparison-entity-list", inputs: ["data"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2350
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityPreview, isStandalone: true, selector: "mt-entity-preview", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, attachmentShape: { classPropertyName: "attachmentShape", publicName: "attachmentShape", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.relative": "infoText()", "class.pe-4": "infoText()" }, classAttribute: "w-full" }, ngImport: i0, template: "@if (infoText(); as info) {\n <!--\n The note affordance. Absolutely positioned so it stays out of the value's\n own layout \u2014 each viewType renders its own markup and there is no shared\n slot to put this in \u2014 while the host reserves the corner with `pe-4`, so a\n long value truncates before it can run underneath the icon.\n -->\n <!--\n Sized with `text-sm`, not a `size` input: `mt-icon` has none, and its host\n is `width: 1em` \u2014 so font-size is what actually scales the glyph.\n -->\n <mt-icon\n icon=\"general.info-circle\"\n class=\"absolute top-0 end-0 z-10 cursor-help text-sm text-surface-400 transition-colors hover:text-primary-600\"\n [mtTooltip]=\"info\"\n tooltipPosition=\"top\"\n tooltipStyleClass=\"mt-entity-info-tooltip\"\n [attr.aria-label]=\"info\"\n />\n}\n\n@switch (comparisonKind()) {\n @case (\"Value\") {\n <mt-comparison-value [data]=\"data()\" />\n }\n @case (\"EntityList\") {\n <mt-comparison-entity-list [data]=\"data()\" />\n }\n @default {\n <mt-entity-preview-body\n [data]=\"data()\"\n [attachmentShape]=\"attachmentShape()\"\n />\n }\n}\n", styles: [".mt-entity-info-tooltip{max-width:22rem}.mt-entity-info-tooltip .p-tooltip-text{white-space:pre-wrap;text-align:start;overflow-wrap:anywhere}\n"], dependencies: [{ kind: "component", type: EntityPreviewBody, selector: "mt-entity-preview-body", inputs: ["data", "attachmentShape"] }, { kind: "component", type: ComparisonValue, selector: "mt-comparison-value", inputs: ["data"] }, { kind: "component", type: ComparisonEntityList, selector: "mt-comparison-entity-list", inputs: ["data"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2172
2351
  }
2173
2352
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityPreview, decorators: [{
2174
2353
  type: Component,
2175
- args: [{ selector: 'mt-entity-preview', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [EntityPreviewBody, ComparisonValue, ComparisonEntityList], host: {
2354
+ args: [{ selector: 'mt-entity-preview', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
2355
+ EntityPreviewBody,
2356
+ ComparisonValue,
2357
+ ComparisonEntityList,
2358
+ Tooltip,
2359
+ Icon,
2360
+ ], encapsulation: ViewEncapsulation.None, host: {
2176
2361
  class: 'w-full',
2177
- }, template: "@switch (comparisonKind()) {\r\n @case (\"Value\") {\r\n <mt-comparison-value [data]=\"data()\" />\r\n }\r\n @case (\"EntityList\") {\r\n <mt-comparison-entity-list [data]=\"data()\" />\r\n }\r\n @default {\r\n <mt-entity-preview-body\r\n [data]=\"data()\"\r\n [attachmentShape]=\"attachmentShape()\"\r\n />\r\n }\r\n}\r\n" }]
2362
+ // Both only apply when there is a note, so an entity without one keeps
2363
+ // exactly the box it had before this feature existed.
2364
+ '[class.relative]': 'infoText()',
2365
+ '[class.pe-4]': 'infoText()',
2366
+ }, template: "@if (infoText(); as info) {\n <!--\n The note affordance. Absolutely positioned so it stays out of the value's\n own layout \u2014 each viewType renders its own markup and there is no shared\n slot to put this in \u2014 while the host reserves the corner with `pe-4`, so a\n long value truncates before it can run underneath the icon.\n -->\n <!--\n Sized with `text-sm`, not a `size` input: `mt-icon` has none, and its host\n is `width: 1em` \u2014 so font-size is what actually scales the glyph.\n -->\n <mt-icon\n icon=\"general.info-circle\"\n class=\"absolute top-0 end-0 z-10 cursor-help text-sm text-surface-400 transition-colors hover:text-primary-600\"\n [mtTooltip]=\"info\"\n tooltipPosition=\"top\"\n tooltipStyleClass=\"mt-entity-info-tooltip\"\n [attr.aria-label]=\"info\"\n />\n}\n\n@switch (comparisonKind()) {\n @case (\"Value\") {\n <mt-comparison-value [data]=\"data()\" />\n }\n @case (\"EntityList\") {\n <mt-comparison-entity-list [data]=\"data()\" />\n }\n @default {\n <mt-entity-preview-body\n [data]=\"data()\"\n [attachmentShape]=\"attachmentShape()\"\n />\n }\n}\n", styles: [".mt-entity-info-tooltip{max-width:22rem}.mt-entity-info-tooltip .p-tooltip-text{white-space:pre-wrap;text-align:start;overflow-wrap:anywhere}\n"] }]
2178
2367
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], attachmentShape: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachmentShape", required: false }] }] } });
2179
2368
 
2180
2369
  const EMPTY_KEY_SET = new Set();
@@ -2477,8 +2666,7 @@ class EntitiesManage extends EntitiesResizeBase {
2477
2666
  : this.displayEntities();
2478
2667
  // Expanded items (LeafDetails levels / Connection source levels) are rebuilt
2479
2668
  // on every render, so identity no longer matches — fall back to the key.
2480
- const isExpandedItem = isLeafDetailsSyntheticKey(entity.key) ||
2481
- isConnectionSyntheticKey(entity.key);
2669
+ const isExpandedItem = isLeafSyntheticKey(entity.key) || isConnectionSyntheticKey(entity.key);
2482
2670
  const updated = sourceEntities.map((e) => e === entity || (isExpandedItem && e.key === entity.key)
2483
2671
  ? {
2484
2672
  ...e,
@@ -2510,5 +2698,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
2510
2698
  * Generated bundle index. Do not edit.
2511
2699
  */
2512
2700
 
2513
- export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityIcon, EntityLeafDetails, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildSectionKey, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, getEntitySectionTitle, groupEntitiesIntoSections, isConnectionSyntheticKey, isEntityAlignEnd, isEntityLabelHidden, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isSectionKey, isValueMissing, matchesPercentageColorRule, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, resolveConnectionLevelName, resolveEntityLabelPosition, resolveLocalizedLabel, resolvePercentageColor, serializeEntityRawValue, splitConnectionKey };
2701
+ export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityIcon, EntityLeafDetails, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildSectionKey, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, getEntitySectionTitle, groupEntitiesIntoSections, isConnectionSyntheticKey, isEntityAlignEnd, isEntityLabelHidden, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isSectionKey, isValueMissing, matchesPercentageColorRule, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, resolveConnectionLevelName, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalizedLabel, resolvePercentageColor, serializeEntityRawValue, sharedActiveLang, splitConnectionKey, splitLeafKey };
2514
2702
  //# sourceMappingURL=masterteam-components-entities.mjs.map