@masterteam/components 0.0.337 → 0.0.339

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,15 +1,15 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, Injectable, InjectionToken, ChangeDetectionStrategy, Component, inject, computed, input, ElementRef, DestroyRef, afterNextRender, Directive, effect, untracked, ViewEncapsulation, output, NgZone, model } from '@angular/core';
2
+ import { signal, Injectable, InjectionToken, ChangeDetectionStrategy, Component, input, computed, inject, ElementRef, DestroyRef, afterNextRender, Directive, effect, untracked, ViewEncapsulation, output, NgZone, model } from '@angular/core';
3
3
  import { Tooltip, TruncateTooltip } from '@masterteam/components/tooltip';
4
4
  import { Icon } from '@masterteam/icons';
5
5
  import { TranslocoPipe, TranslocoService } from '@jsverse/transloco';
6
+ import { toSignal } from '@angular/core/rxjs-interop';
6
7
  import { NgTemplateOutlet, NgComponentOutlet, DOCUMENT } from '@angular/common';
7
8
  import { MTDateFormatPipe, REQUEST_CONTEXT, coerceCheckboxValue, readableTextOn, getLightColor } from '@masterteam/components';
8
9
  import { HttpContext, HttpClient } from '@angular/common/http';
9
10
  import { Avatar } from '@masterteam/components/avatar';
10
11
  import { SecureImagePipe, UploadField } from '@masterteam/components/upload-field';
11
12
  import { Progress } from '@masterteam/components/progress';
12
- import { toSignal } from '@angular/core/rxjs-interop';
13
13
  import * as i1 from '@angular/forms';
14
14
  import { FormsModule } from '@angular/forms';
15
15
  import { Button } from '@masterteam/components/button';
@@ -345,45 +345,419 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
345
345
  */
346
346
  const ENTITY_LIST_TABLE_COMPONENT = new InjectionToken('ENTITY_LIST_TABLE_COMPONENT');
347
347
 
348
- /** Marks a property value the backend calculates. Rendered beside its label. */
348
+ const TOOLTIP_KEYS = {
349
+ idle: 'components.entitiesPreview.calculatedValue',
350
+ running: 'components.entitiesPreview.calculatingValue',
351
+ waiting: 'components.entitiesPreview.waitingToCalculate',
352
+ delayed: 'components.entitiesPreview.calculationDelayed',
353
+ };
354
+ const CHANGED_TOOLTIP_KEY = 'components.entitiesPreview.calculatedValueChanged';
355
+ /** The calculated-value mark. Drawn, so it sits centred at any size. */
356
+ class EntityCalculatedGlyph {
357
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedGlyph, deps: [], target: i0.ɵɵFactoryTarget.Component });
358
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.8", type: EntityCalculatedGlyph, isStandalone: true, selector: "mt-entity-calculated-glyph", host: { classAttribute: "block size-full" }, ngImport: i0, template: `
359
+ <svg
360
+ viewBox="0 0 16 16"
361
+ width="100%"
362
+ height="100%"
363
+ fill="none"
364
+ stroke="currentColor"
365
+ stroke-width="1.5"
366
+ stroke-linecap="round"
367
+ stroke-linejoin="round"
368
+ aria-hidden="true"
369
+ >
370
+ <path
371
+ d="M10.1 4.7c-.35-.42-.85-.62-1.38-.56-.87.1-1.4.76-1.57 1.66L6.1 11.3"
372
+ />
373
+ <path d="M5.5 7.5h3.9" />
374
+ </svg>
375
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
376
+ }
377
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedGlyph, decorators: [{
378
+ type: Component,
379
+ args: [{
380
+ selector: 'mt-entity-calculated-glyph',
381
+ changeDetection: ChangeDetectionStrategy.OnPush,
382
+ template: `
383
+ <svg
384
+ viewBox="0 0 16 16"
385
+ width="100%"
386
+ height="100%"
387
+ fill="none"
388
+ stroke="currentColor"
389
+ stroke-width="1.5"
390
+ stroke-linecap="round"
391
+ stroke-linejoin="round"
392
+ aria-hidden="true"
393
+ >
394
+ <path
395
+ d="M10.1 4.7c-.35-.42-.85-.62-1.38-.56-.87.1-1.4.76-1.57 1.66L6.1 11.3"
396
+ />
397
+ <path d="M5.5 7.5h3.9" />
398
+ </svg>
399
+ `,
400
+ host: {
401
+ class: 'block size-full',
402
+ },
403
+ }]
404
+ }] });
405
+ /**
406
+ * Marks a property value the backend calculates. Rendered beside its label; it
407
+ * pulses while a recalculation that covers the value is in progress, and stays
408
+ * lit without pulsing once that is taking longer than expected.
409
+ */
349
410
  class EntityCalculatedIndicator {
411
+ /** Set while the value is being recalculated. */
412
+ status = input(null, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
413
+ /** The value's last change, described in the tooltip when it is not busy. */
414
+ change = input(null, ...(ngDevMode ? [{ debugName: "change" }] : /* istanbul ignore next */ []));
415
+ pulsing = computed(() => !!this.status() && this.status() !== 'delayed', ...(ngDevMode ? [{ debugName: "pulsing" }] : /* istanbul ignore next */ []));
416
+ tooltipKey = computed(() => {
417
+ const status = this.status();
418
+ if (status) {
419
+ return TOOLTIP_KEYS[status];
420
+ }
421
+ return this.change() ? CHANGED_TOOLTIP_KEY : TOOLTIP_KEYS.idle;
422
+ }, ...(ngDevMode ? [{ debugName: "tooltipKey" }] : /* istanbul ignore next */ []));
423
+ tooltipParams = computed(() => {
424
+ const change = this.change();
425
+ return change
426
+ ? { previous: change.previous, current: change.current }
427
+ : undefined;
428
+ }, ...(ngDevMode ? [{ debugName: "tooltipParams" }] : /* istanbul ignore next */ []));
350
429
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedIndicator, deps: [], target: i0.ɵɵFactoryTarget.Component });
351
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.8", type: EntityCalculatedIndicator, isStandalone: true, selector: "mt-entity-calculated-indicator", host: { classAttribute: "inline-flex shrink-0" }, ngImport: i0, template: `
430
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCalculatedIndicator, isStandalone: true, selector: "mt-entity-calculated-indicator", inputs: { status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null }, change: { classPropertyName: "change", publicName: "change", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "inline-flex shrink-0" }, ngImport: i0, template: `
352
431
  <span
353
- class="inline-flex size-4.5 cursor-help items-center justify-center rounded-md bg-surface-100 font-serif text-xs leading-none font-bold text-surface-500 italic select-none dark:bg-surface-800 dark:text-surface-300"
354
- role="img"
355
- [attr.aria-label]="
356
- 'components.entitiesPreview.calculatedValue' | transloco
432
+ class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
433
+ [class]="
434
+ status()
435
+ ? 'bg-primary-700 text-white'
436
+ : 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
357
437
  "
358
- [mtTooltip]="'components.entitiesPreview.calculatedValue' | transloco"
438
+ role="img"
439
+ [attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
440
+ [mtTooltip]="tooltipKey() | transloco: tooltipParams()"
359
441
  tooltipPosition="top"
360
- >f</span
361
442
  >
362
- `, isInline: true, dependencies: [{ kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
443
+ @if (pulsing()) {
444
+ <span
445
+ class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
446
+ aria-hidden="true"
447
+ ></span>
448
+ }
449
+ <mt-entity-calculated-glyph class="relative" />
450
+ </span>
451
+ `, isInline: true, dependencies: [{ kind: "component", type: EntityCalculatedGlyph, selector: "mt-entity-calculated-glyph" }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
363
452
  }
364
453
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedIndicator, decorators: [{
365
454
  type: Component,
366
455
  args: [{
367
456
  selector: 'mt-entity-calculated-indicator',
368
457
  changeDetection: ChangeDetectionStrategy.OnPush,
458
+ imports: [EntityCalculatedGlyph, Tooltip, TranslocoPipe],
459
+ template: `
460
+ <span
461
+ class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
462
+ [class]="
463
+ status()
464
+ ? 'bg-primary-700 text-white'
465
+ : 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
466
+ "
467
+ role="img"
468
+ [attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
469
+ [mtTooltip]="tooltipKey() | transloco: tooltipParams()"
470
+ tooltipPosition="top"
471
+ >
472
+ @if (pulsing()) {
473
+ <span
474
+ class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
475
+ aria-hidden="true"
476
+ ></span>
477
+ }
478
+ <mt-entity-calculated-glyph class="relative" />
479
+ </span>
480
+ `,
481
+ host: {
482
+ class: 'inline-flex shrink-0',
483
+ },
484
+ }]
485
+ }], propDecorators: { status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }], change: [{ type: i0.Input, args: [{ isSignal: true, alias: "change", required: false }] }] } });
486
+
487
+ /**
488
+ * One shared active-language signal per `TranslocoService`.
489
+ *
490
+ * `mt-entity-preview` renders once per property per record — a client-list card
491
+ * grid mounts thousands of them — so a `toSignal(langChanges$)` inside each
492
+ * instance would open thousands of subscriptions to the same Subject just to
493
+ * read one global value. The language is global, so the signal is too: created
494
+ * once, cached against the service, and shared by every entity that needs it.
495
+ *
496
+ * `manualCleanup` is deliberate. The cached signal outlives any single
497
+ * component by design, and the service it hangs off is the root injector's —
498
+ * tying its subscription to whichever entity happened to ask first would tear
499
+ * it down the moment that entity scrolled out of view.
500
+ */
501
+ const langSignals = new WeakMap();
502
+ function sharedActiveLang(transloco) {
503
+ const cached = langSignals.get(transloco);
504
+ if (cached) {
505
+ return cached;
506
+ }
507
+ const lang = toSignal(transloco.langChanges$, {
508
+ initialValue: transloco.getActiveLang(),
509
+ manualCleanup: true,
510
+ });
511
+ langSignals.set(transloco, lang);
512
+ return lang;
513
+ }
514
+
515
+ /**
516
+ * The largest amount still rendered in full.
517
+ *
518
+ * The reviewer measured exactly where the line falls: `100,000 SAR` fits a card
519
+ * slot, `1,000,000 SAR` does not and loses its currency to the ellipsis. So the
520
+ * comparison below is inclusive — anything ABOVE this compacts, and everything
521
+ * a tenant sees today at or under it is untouched.
522
+ */
523
+ const CURRENCY_COMPACT_THRESHOLD = 100_000;
524
+ /**
525
+ * The numeric amount inside a formatted currency string.
526
+ *
527
+ * Strips the currency token, the grouping separators and the bidirectional
528
+ * marks `Intl` leaves around them, and normalises Arabic-Indic digits so an
529
+ * `ar-SA` payload parses like an `en` one. `null` when there is no number.
530
+ */
531
+ function parseCurrencyAmount(raw) {
532
+ if (typeof raw !== 'string') {
533
+ return null;
534
+ }
535
+ const numeric = normalizeNumerals(raw).replace(/[^0-9.+-]/g, '');
536
+ if (!numeric || !/\d/.test(numeric)) {
537
+ return null;
538
+ }
539
+ const parsed = Number.parseFloat(numeric);
540
+ return Number.isFinite(parsed) ? parsed : null;
541
+ }
542
+ /**
543
+ * Whatever is left of a formatted amount once the number is removed — `SAR`,
544
+ * `ر.س`, `$`. Read from the payload rather than configured, so a tenant's own
545
+ * currency survives untouched.
546
+ */
547
+ function currencyUnitOf(formatted) {
548
+ return normalizeNumerals(formatted)
549
+ .replace(/[0-9.,+-]/g, '')
550
+ .trim();
551
+ }
552
+ /**
553
+ * A large currency amount shortened so it fits a card slot, with the unit kept.
554
+ *
555
+ * A budget of a million or more used to render as `1,000,000 …`: the digits
556
+ * survived the ellipsis and the currency did not, so the largest and most
557
+ * consequential figures in the product were the only ones whose unit could not
558
+ * be read (finding H-06). Compact notation keeps the whole thing inside the
559
+ * slot — `SAR 1M` instead of `1,000,000 SAR` — and callers put the exact figure
560
+ * in a tooltip, which is where a precise number belongs on a summary card.
561
+ *
562
+ * Returns `formatted` unchanged whenever the value already fits, is not a
563
+ * number, or the runtime has no compact notation — so no tenant sees an
564
+ * existing number change shape for no reason.
565
+ */
566
+ function compactCurrencyDisplay(formatted, rawValue, locale, threshold = CURRENCY_COMPACT_THRESHOLD) {
567
+ const amount = parseCurrencyAmount(rawValue ?? formatted);
568
+ if (amount === null || Math.abs(amount) <= threshold) {
569
+ return formatted;
570
+ }
571
+ let compact;
572
+ try {
573
+ compact = new Intl.NumberFormat(locale, {
574
+ notation: 'compact',
575
+ maximumFractionDigits: 1,
576
+ }).format(amount);
577
+ }
578
+ catch {
579
+ return formatted;
580
+ }
581
+ const unit = currencyUnitOf(formatted);
582
+ if (!unit) {
583
+ return compact;
584
+ }
585
+ // Keep the payload's own unit placement — `SAR 1,000` and `1,000 SAR` are
586
+ // both in use, and flipping one to the other reads as a different currency.
587
+ return formatted.trimStart().startsWith(unit)
588
+ ? `${unit} ${compact}`
589
+ : `${compact} ${unit}`;
590
+ }
591
+
592
+ const NUMERIC_VIEW_TYPES = [
593
+ 'Number',
594
+ 'Currency',
595
+ 'Percentage',
596
+ ];
597
+ const EMPTY_VALUE_TEXT = '—';
598
+ const MAX_FRACTION_DIGITS = 2;
599
+ /** What a value reads as: the formatted string, or the object's own label. */
600
+ function valueText(value) {
601
+ if (value === null || value === undefined) {
602
+ return '';
603
+ }
604
+ if (typeof value === 'string') {
605
+ return value;
606
+ }
607
+ if (typeof value === 'number' || typeof value === 'boolean') {
608
+ return String(value);
609
+ }
610
+ if (Array.isArray(value)) {
611
+ return value.map(valueText).filter(Boolean).join(', ');
612
+ }
613
+ if (typeof value === 'object') {
614
+ const { display, displayName, name } = value;
615
+ return valueText(display ?? displayName ?? name);
616
+ }
617
+ return '';
618
+ }
619
+ function roundTo(value, digits) {
620
+ const factor = 10 ** digits;
621
+ return Math.round(value * factor) / factor;
622
+ }
623
+ /** Decimals the value is displayed with, so the difference reads the same way. */
624
+ function displayedFractionDigits(text) {
625
+ const decimals = /[.٫](\d+)/.exec(normalizeNumerals(text))?.[1]?.length ?? 0;
626
+ return Math.min(decimals, MAX_FRACTION_DIGITS);
627
+ }
628
+ /** An amount with its unit where the backend writes it, e.g. `SAR 5` or `5%`. */
629
+ function withUnit(amount, unit, unitLeads) {
630
+ if (!unit) {
631
+ return amount;
632
+ }
633
+ if (unit === '%') {
634
+ return `${amount}%`;
635
+ }
636
+ return unitLeads ? `${unit} ${amount}` : `${amount} ${unit}`;
637
+ }
638
+ /**
639
+ * How a calculated value moved between two reads of the same record, or `null`
640
+ * when it did not. Numeric view types get a signed difference; anything else
641
+ * only records what it read before and after. `locale` formats the exact
642
+ * values used when the displayed ones round to the same text.
643
+ */
644
+ function describeCalculationChange(previous, current, locale = 'en') {
645
+ if (previous.rawValue === current.rawValue) {
646
+ return null;
647
+ }
648
+ const previousText = valueText(previous.value);
649
+ const currentText = valueText(current.value);
650
+ const texts = {
651
+ previous: previousText || EMPTY_VALUE_TEXT,
652
+ current: currentText || EMPTY_VALUE_TEXT,
653
+ recent: true,
654
+ };
655
+ const before = parseCurrencyAmount(previous.rawValue);
656
+ const after = parseCurrencyAmount(current.rawValue);
657
+ if (NUMERIC_VIEW_TYPES.includes(current.viewType) &&
658
+ before !== null &&
659
+ after !== null) {
660
+ const delta = after - before;
661
+ if (roundTo(delta, MAX_FRACTION_DIGITS) === 0) {
662
+ return null;
663
+ }
664
+ const digits = displayedFractionDigits(currentText);
665
+ const unit = currencyUnitOf(currentText);
666
+ const unitLeads = !!unit && currentText.replace(/^[\s+-]+/, '').startsWith(unit);
667
+ // "Was 2.7%, now 2.7%" says nothing: show the exact values instead.
668
+ const exact = (amount) => withUnit(new Intl.NumberFormat(locale, {
669
+ maximumFractionDigits: MAX_FRACTION_DIGITS,
670
+ }).format(amount), unit, unitLeads);
671
+ return {
672
+ ...texts,
673
+ ...(previousText === currentText && {
674
+ previous: exact(before),
675
+ current: exact(after),
676
+ }),
677
+ delta,
678
+ unit,
679
+ unitLeads,
680
+ // A move too small for the displayed decimals still has to show a number.
681
+ fractionDigits: roundTo(delta, digits) === 0 ? MAX_FRACTION_DIGITS : digits,
682
+ };
683
+ }
684
+ if (previousText === currentText) {
685
+ return null;
686
+ }
687
+ // No number to show beside the value: only the icon's tooltip describes it.
688
+ return {
689
+ ...texts,
690
+ recent: false,
691
+ delta: null,
692
+ unit: '',
693
+ unitLeads: false,
694
+ fractionDigits: 0,
695
+ };
696
+ }
697
+ /** The signed difference as the chip shows it, e.g. `+500K SAR` or `+0.1%`. */
698
+ function formatCalculationDelta(change, locale) {
699
+ if (change.delta === null) {
700
+ return null;
701
+ }
702
+ const magnitude = Math.abs(change.delta);
703
+ const amount = new Intl.NumberFormat(locale, magnitude > CURRENCY_COMPACT_THRESHOLD
704
+ ? { notation: 'compact', maximumFractionDigits: 1 }
705
+ : { maximumFractionDigits: change.fractionDigits }).format(magnitude);
706
+ const sign = change.delta > 0 ? '+' : '-';
707
+ return sign + withUnit(amount, change.unit, change.unitLeads);
708
+ }
709
+
710
+ /**
711
+ * Says how a calculated number just moved: the signed difference, with the
712
+ * exact values in its tooltip.
713
+ */
714
+ class EntityCalculationChangeChip {
715
+ activeLang = sharedActiveLang(inject(TranslocoService));
716
+ change = input.required(...(ngDevMode ? [{ debugName: "change" }] : /* istanbul ignore next */ []));
717
+ delta = computed(() => formatCalculationDelta(this.change(), this.activeLang()), ...(ngDevMode ? [{ debugName: "delta" }] : /* istanbul ignore next */ []));
718
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculationChangeChip, deps: [], target: i0.ɵɵFactoryTarget.Component });
719
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: EntityCalculationChangeChip, isStandalone: true, selector: "mt-entity-calculation-change", inputs: { change: { classPropertyName: "change", publicName: "change", isSignal: true, isRequired: true, transformFunction: null } }, host: { classAttribute: "inline-flex shrink-0" }, ngImport: i0, template: `
720
+ @let description =
721
+ 'components.entitiesPreview.calculationChangeDetail'
722
+ | transloco: { previous: change().previous, current: change().current };
723
+ <span
724
+ class="inline-flex cursor-help items-center rounded-md bg-surface-100 px-1.5 text-xs leading-5 font-semibold whitespace-nowrap text-surface-700 tabular-nums dark:bg-surface-800 dark:text-surface-200"
725
+ role="img"
726
+ dir="ltr"
727
+ [attr.aria-label]="description"
728
+ [mtTooltip]="description"
729
+ tooltipPosition="top"
730
+ >
731
+ {{ delta() }}
732
+ </span>
733
+ `, isInline: true, dependencies: [{ kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
734
+ }
735
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculationChangeChip, decorators: [{
736
+ type: Component,
737
+ args: [{
738
+ selector: 'mt-entity-calculation-change',
739
+ changeDetection: ChangeDetectionStrategy.OnPush,
369
740
  imports: [Tooltip, TranslocoPipe],
370
741
  template: `
742
+ @let description =
743
+ 'components.entitiesPreview.calculationChangeDetail'
744
+ | transloco: { previous: change().previous, current: change().current };
371
745
  <span
372
- class="inline-flex size-4.5 cursor-help items-center justify-center rounded-md bg-surface-100 font-serif text-xs leading-none font-bold text-surface-500 italic select-none dark:bg-surface-800 dark:text-surface-300"
746
+ class="inline-flex cursor-help items-center rounded-md bg-surface-100 px-1.5 text-xs leading-5 font-semibold whitespace-nowrap text-surface-700 tabular-nums dark:bg-surface-800 dark:text-surface-200"
373
747
  role="img"
374
- [attr.aria-label]="
375
- 'components.entitiesPreview.calculatedValue' | transloco
376
- "
377
- [mtTooltip]="'components.entitiesPreview.calculatedValue' | transloco"
748
+ dir="ltr"
749
+ [attr.aria-label]="description"
750
+ [mtTooltip]="description"
378
751
  tooltipPosition="top"
379
- >f</span
380
752
  >
753
+ {{ delta() }}
754
+ </span>
381
755
  `,
382
756
  host: {
383
757
  class: 'inline-flex shrink-0',
384
758
  },
385
759
  }]
386
- }] });
760
+ }], propDecorators: { change: [{ type: i0.Input, args: [{ isSignal: true, alias: "change", required: true }] }] } });
387
761
 
388
762
  /**
389
763
  * The entity of the enclosing `mt-entity-preview`. `mt-entity-field` only
@@ -397,6 +771,12 @@ class EntityField {
397
771
  optional: true,
398
772
  });
399
773
  calculated = computed(() => this.previewData?.().calculated === true, ...(ngDevMode ? [{ debugName: "calculated" }] : /* istanbul ignore next */ []));
774
+ calculationStatus = computed(() => this.previewData?.().calculationStatus, ...(ngDevMode ? [{ debugName: "calculationStatus" }] : /* istanbul ignore next */ []));
775
+ calculationChange = computed(() => this.previewData?.().calculationChange, ...(ngDevMode ? [{ debugName: "calculationChange" }] : /* istanbul ignore next */ []));
776
+ recentChange = computed(() => {
777
+ const change = this.calculationChange();
778
+ return change?.recent ? change : null;
779
+ }, ...(ngDevMode ? [{ debugName: "recentChange" }] : /* istanbul ignore next */ []));
400
780
  label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
401
781
  labelIconName = input(null, ...(ngDevMode ? [{ debugName: "labelIconName" }] : /* istanbul ignore next */ []));
402
782
  configuration = input(...(ngDevMode ? [undefined, { debugName: "configuration" }] : /* istanbul ignore next */ []));
@@ -413,7 +793,13 @@ class EntityField {
413
793
  const alignClass = isEntityAlignEnd(this.configuration())
414
794
  ? 'self-end'
415
795
  : 'self-stretch';
416
- return `min-w-0 max-w-full ${alignClass}`;
796
+ // Only while a chip shows, so every other field keeps its exact layout.
797
+ // A chip that does not fit beside the value goes below it rather than
798
+ // truncating the value (a narrow card column).
799
+ const chipClass = this.recentChange()
800
+ ? 'flex flex-wrap items-center gap-x-1.5 gap-y-0.5 '
801
+ : '';
802
+ return `${chipClass}min-w-0 max-w-full ${alignClass}`;
417
803
  }, ...(ngDevMode ? [{ debugName: "contentContainerClass" }] : /* istanbul ignore next */ []));
418
804
  containerClass = computed(() => {
419
805
  const gapClass = this.gap() === 'relaxed'
@@ -432,6 +818,9 @@ class EntityField {
432
818
  <div [class]="containerClass()">
433
819
  <div [class]="contentContainerClass()">
434
820
  <ng-content />
821
+ @if (recentChange(); as change) {
822
+ <mt-entity-calculation-change [change]="change" />
823
+ }
435
824
  </div>
436
825
  @if (!hideLabel()) {
437
826
  <div [class]="labelContainerClass()">
@@ -446,23 +835,34 @@ class EntityField {
446
835
  {{ label() }}
447
836
  </span>
448
837
  @if (calculated()) {
449
- <mt-entity-calculated-indicator />
838
+ <mt-entity-calculated-indicator
839
+ [status]="calculationStatus()"
840
+ [change]="calculationChange()"
841
+ />
450
842
  }
451
843
  </div>
452
844
  }
453
845
  </div>
454
- `, isInline: true, dependencies: [{ kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: EntityCalculatedIndicator, selector: "mt-entity-calculated-indicator" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
846
+ `, isInline: true, dependencies: [{ kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: EntityCalculatedIndicator, selector: "mt-entity-calculated-indicator", inputs: ["status", "change"] }, { kind: "component", type: EntityCalculationChangeChip, selector: "mt-entity-calculation-change", inputs: ["change"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
455
847
  }
456
848
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityField, decorators: [{
457
849
  type: Component,
458
850
  args: [{
459
851
  selector: 'mt-entity-field',
460
852
  changeDetection: ChangeDetectionStrategy.OnPush,
461
- imports: [TruncateTooltip, Icon, EntityCalculatedIndicator],
853
+ imports: [
854
+ TruncateTooltip,
855
+ Icon,
856
+ EntityCalculatedIndicator,
857
+ EntityCalculationChangeChip,
858
+ ],
462
859
  template: `
463
860
  <div [class]="containerClass()">
464
861
  <div [class]="contentContainerClass()">
465
862
  <ng-content />
863
+ @if (recentChange(); as change) {
864
+ <mt-entity-calculation-change [change]="change" />
865
+ }
466
866
  </div>
467
867
  @if (!hideLabel()) {
468
868
  <div [class]="labelContainerClass()">
@@ -477,7 +877,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
477
877
  {{ label() }}
478
878
  </span>
479
879
  @if (calculated()) {
480
- <mt-entity-calculated-indicator />
880
+ <mt-entity-calculated-indicator
881
+ [status]="calculationStatus()"
882
+ [change]="calculationChange()"
883
+ />
481
884
  }
482
885
  </div>
483
886
  }
@@ -496,7 +899,13 @@ class EntityText {
496
899
  name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : /* istanbul ignore next */ []));
497
900
  value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
498
901
  displayName = computed(() => this.data()?.name ?? this.name() ?? '', ...(ngDevMode ? [{ debugName: "displayName" }] : /* istanbul ignore next */ []));
499
- hideLabel = computed(() => isEntityLabelHidden(this.data()?.configuration), ...(ngDevMode ? [{ debugName: "hideLabel" }] : /* istanbul ignore next */ []));
902
+ /**
903
+ * Renders without the field wrapper, which only carries the label, unless
904
+ * the wrapper has a chip to show beside the value: how a calculated value
905
+ * just changed. The wrapper hides the label itself.
906
+ */
907
+ bare = computed(() => isEntityLabelHidden(this.data()?.configuration) &&
908
+ !this.data()?.calculationChange?.recent, ...(ngDevMode ? [{ debugName: "bare" }] : /* istanbul ignore next */ []));
500
909
  alignEnd = computed(() => isEntityAlignEnd(this.data()?.configuration), ...(ngDevMode ? [{ debugName: "alignEnd" }] : /* istanbul ignore next */ []));
501
910
  displayValue = computed(() => {
502
911
  const d = this.data();
@@ -509,11 +918,11 @@ class EntityText {
509
918
  // per cell while preserving the existing sanitized markup/entity contract.
510
919
  hasMarkup = computed(() => /[<&]/.test(this.displayValue()), ...(ngDevMode ? [{ debugName: "hasMarkup" }] : /* istanbul ignore next */ []));
511
920
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityText, deps: [], target: i0.ɵɵFactoryTarget.Component });
512
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityText, isStandalone: true, selector: "mt-entity-text", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (hideLabel()) {\r\n <ng-container [ngTemplateOutlet]=\"content\" />\r\n} @else {\r\n <mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"content\" />\r\n </mt-entity-field>\r\n}\r\n<ng-template #content>\r\n <!--\r\n Two lines before the ellipsis, not one. Portfolio and project names were\r\n being cut mid-word on the Explore board (\"Smart City Infrastructure Po\u2026\"),\r\n which makes similarly-titled records indistinguishable without opening each\r\n one (finding H-06). `line-clamp-2` still ellipsises what genuinely does not\r\n fit, and `mtTruncateTooltip` reads `scrollHeight > clientHeight`, so the\r\n tooltip keeps working for the clamped case exactly as it did for the\r\n single-line one.\r\n -->\r\n <div\r\n class=\"min-w-0 max-w-full line-clamp-2 break-words text-sm font-semibold\"\r\n [class.text-end]=\"alignEnd()\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n @if (hasMarkup()) {\r\n <span [innerHTML]=\"displayValue()\"></span>\r\n } @else {\r\n {{ displayValue() }}\r\n }\r\n </div>\r\n</ng-template>\r\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
921
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityText, isStandalone: true, selector: "mt-entity-text", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (bare()) {\n <ng-container [ngTemplateOutlet]=\"content\" />\n} @else {\n <mt-entity-field\n [label]=\"displayName()\"\n [configuration]=\"data()?.configuration\"\n >\n <ng-container [ngTemplateOutlet]=\"content\" />\n </mt-entity-field>\n}\n<ng-template #content>\n <!--\n Two lines before the ellipsis, not one. Portfolio and project names were\n being cut mid-word on the Explore board (\"Smart City Infrastructure Po\u2026\"),\n which makes similarly-titled records indistinguishable without opening each\n one (finding H-06). `line-clamp-2` still ellipsises what genuinely does not\n fit, and `mtTruncateTooltip` reads `scrollHeight > clientHeight`, so the\n tooltip keeps working for the clamped case exactly as it did for the\n single-line one.\n -->\n <div\n class=\"min-w-0 max-w-full line-clamp-2 break-words text-sm font-semibold\"\n [class.text-end]=\"alignEnd()\"\n mtTruncateTooltip\n tooltipPosition=\"top\"\n >\n @if (hasMarkup()) {\n <span [innerHTML]=\"displayValue()\"></span>\n } @else {\n {{ displayValue() }}\n }\n </div>\n</ng-template>\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
513
922
  }
514
923
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityText, decorators: [{
515
924
  type: Component,
516
- args: [{ selector: 'mt-entity-text', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip, NgTemplateOutlet], template: "@if (hideLabel()) {\r\n <ng-container [ngTemplateOutlet]=\"content\" />\r\n} @else {\r\n <mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n >\r\n <ng-container [ngTemplateOutlet]=\"content\" />\r\n </mt-entity-field>\r\n}\r\n<ng-template #content>\r\n <!--\r\n Two lines before the ellipsis, not one. Portfolio and project names were\r\n being cut mid-word on the Explore board (\"Smart City Infrastructure Po\u2026\"),\r\n which makes similarly-titled records indistinguishable without opening each\r\n one (finding H-06). `line-clamp-2` still ellipsises what genuinely does not\r\n fit, and `mtTruncateTooltip` reads `scrollHeight > clientHeight`, so the\r\n tooltip keeps working for the clamped case exactly as it did for the\r\n single-line one.\r\n -->\r\n <div\r\n class=\"min-w-0 max-w-full line-clamp-2 break-words text-sm font-semibold\"\r\n [class.text-end]=\"alignEnd()\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n @if (hasMarkup()) {\r\n <span [innerHTML]=\"displayValue()\"></span>\r\n } @else {\r\n {{ displayValue() }}\r\n }\r\n </div>\r\n</ng-template>\r\n" }]
925
+ args: [{ selector: 'mt-entity-text', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip, NgTemplateOutlet], template: "@if (bare()) {\n <ng-container [ngTemplateOutlet]=\"content\" />\n} @else {\n <mt-entity-field\n [label]=\"displayName()\"\n [configuration]=\"data()?.configuration\"\n >\n <ng-container [ngTemplateOutlet]=\"content\" />\n </mt-entity-field>\n}\n<ng-template #content>\n <!--\n Two lines before the ellipsis, not one. Portfolio and project names were\n being cut mid-word on the Explore board (\"Smart City Infrastructure Po\u2026\"),\n which makes similarly-titled records indistinguishable without opening each\n one (finding H-06). `line-clamp-2` still ellipsises what genuinely does not\n fit, and `mtTruncateTooltip` reads `scrollHeight > clientHeight`, so the\n tooltip keeps working for the clamped case exactly as it did for the\n single-line one.\n -->\n <div\n class=\"min-w-0 max-w-full line-clamp-2 break-words text-sm font-semibold\"\n [class.text-end]=\"alignEnd()\"\n mtTruncateTooltip\n tooltipPosition=\"top\"\n >\n @if (hasMarkup()) {\n <span [innerHTML]=\"displayValue()\"></span>\n } @else {\n {{ displayValue() }}\n }\n </div>\n</ng-template>\n" }]
517
926
  }], 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 }] }] } });
518
927
 
519
928
  /** Smallest size the text may shrink to before ellipsis takes over, in px. */
@@ -1016,90 +1425,13 @@ class EntityPercentage {
1016
1425
  return Number.isNaN(numericValue) ? null : numericValue;
1017
1426
  }
1018
1427
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityPercentage, deps: [], target: i0.ɵɵFactoryTarget.Component });
1019
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityPercentage, isStandalone: true, selector: "mt-entity-percentage", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, rawValue: { classPropertyName: "rawValue", publicName: "rawValue", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"flex flex-col gap-1\">\r\n <div class=\"flex items-center justify-between\">\r\n @if (!hideName()) {\r\n <span class=\"inline-flex min-w-0 items-center gap-1\">\r\n <span class=\"text-xs font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator />\r\n }\r\n </span>\r\n }\r\n <span class=\"text-xs font-bold\" [class.ms-auto]=\"hideName()\">{{\r\n displayValue()\r\n }}</span>\r\n </div>\r\n @if (hasNumericValue()) {\r\n <mt-progress\r\n [value]=\"numericValue()\"\r\n [showLabel]=\"false\"\r\n [height]=\"9\"\r\n [maxValue]=\"maxValue()\"\r\n [color]=\"progressColor()\"\r\n >\r\n </mt-progress>\r\n } @else {\r\n <div class=\"h-[9px] rounded-full bg-gray-200\"></div>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "component", type: Progress, selector: "mt-progress", inputs: ["value", "mode", "showLabel", "unit", "color", "minValue", "maxValue", "height", "circleSize", "strokeWidth", "customClass"] }, { kind: "component", type: EntityCalculatedIndicator, selector: "mt-entity-calculated-indicator" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1428
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityPercentage, isStandalone: true, selector: "mt-entity-percentage", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, rawValue: { classPropertyName: "rawValue", publicName: "rawValue", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"flex flex-col gap-1\">\r\n <div class=\"flex items-center justify-between\">\r\n @if (!hideName()) {\r\n <span class=\"inline-flex min-w-0 items-center gap-1\">\r\n <span class=\"text-xs font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator\r\n [status]=\"data()?.calculationStatus\"\r\n [change]=\"data()?.calculationChange\"\r\n />\r\n }\r\n </span>\r\n }\r\n <span class=\"inline-flex items-center gap-1.5\" [class.ms-auto]=\"hideName()\">\r\n @if (data()?.calculationChange; as change) {\r\n @if (change.recent) {\r\n <mt-entity-calculation-change [change]=\"change\" />\r\n }\r\n }\r\n <span class=\"text-xs font-bold\">{{ displayValue() }}</span>\r\n </span>\r\n </div>\r\n @if (hasNumericValue()) {\r\n <mt-progress\r\n [value]=\"numericValue()\"\r\n [showLabel]=\"false\"\r\n [height]=\"9\"\r\n [maxValue]=\"maxValue()\"\r\n [color]=\"progressColor()\"\r\n >\r\n </mt-progress>\r\n } @else {\r\n <div class=\"h-[9px] rounded-full bg-gray-200\"></div>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "component", type: Progress, selector: "mt-progress", inputs: ["value", "mode", "showLabel", "unit", "color", "minValue", "maxValue", "height", "circleSize", "strokeWidth", "customClass"] }, { kind: "component", type: EntityCalculatedIndicator, selector: "mt-entity-calculated-indicator", inputs: ["status", "change"] }, { kind: "component", type: EntityCalculationChangeChip, selector: "mt-entity-calculation-change", inputs: ["change"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1020
1429
  }
1021
1430
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityPercentage, decorators: [{
1022
1431
  type: Component,
1023
- args: [{ selector: 'mt-entity-percentage', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [Progress, EntityCalculatedIndicator], template: "<div class=\"flex flex-col gap-1\">\r\n <div class=\"flex items-center justify-between\">\r\n @if (!hideName()) {\r\n <span class=\"inline-flex min-w-0 items-center gap-1\">\r\n <span class=\"text-xs font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator />\r\n }\r\n </span>\r\n }\r\n <span class=\"text-xs font-bold\" [class.ms-auto]=\"hideName()\">{{\r\n displayValue()\r\n }}</span>\r\n </div>\r\n @if (hasNumericValue()) {\r\n <mt-progress\r\n [value]=\"numericValue()\"\r\n [showLabel]=\"false\"\r\n [height]=\"9\"\r\n [maxValue]=\"maxValue()\"\r\n [color]=\"progressColor()\"\r\n >\r\n </mt-progress>\r\n } @else {\r\n <div class=\"h-[9px] rounded-full bg-gray-200\"></div>\r\n }\r\n</div>\r\n" }]
1432
+ args: [{ selector: 'mt-entity-percentage', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [Progress, EntityCalculatedIndicator, EntityCalculationChangeChip], template: "<div class=\"flex flex-col gap-1\">\r\n <div class=\"flex items-center justify-between\">\r\n @if (!hideName()) {\r\n <span class=\"inline-flex min-w-0 items-center gap-1\">\r\n <span class=\"text-xs font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator\r\n [status]=\"data()?.calculationStatus\"\r\n [change]=\"data()?.calculationChange\"\r\n />\r\n }\r\n </span>\r\n }\r\n <span class=\"inline-flex items-center gap-1.5\" [class.ms-auto]=\"hideName()\">\r\n @if (data()?.calculationChange; as change) {\r\n @if (change.recent) {\r\n <mt-entity-calculation-change [change]=\"change\" />\r\n }\r\n }\r\n <span class=\"text-xs font-bold\">{{ displayValue() }}</span>\r\n </span>\r\n </div>\r\n @if (hasNumericValue()) {\r\n <mt-progress\r\n [value]=\"numericValue()\"\r\n [showLabel]=\"false\"\r\n [height]=\"9\"\r\n [maxValue]=\"maxValue()\"\r\n [color]=\"progressColor()\"\r\n >\r\n </mt-progress>\r\n } @else {\r\n <div class=\"h-[9px] rounded-full bg-gray-200\"></div>\r\n }\r\n</div>\r\n" }]
1024
1433
  }], 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 }] }], rawValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "rawValue", required: false }] }] } });
1025
1434
 
1026
- /**
1027
- * The largest amount still rendered in full.
1028
- *
1029
- * The reviewer measured exactly where the line falls: `100,000 SAR` fits a card
1030
- * slot, `1,000,000 SAR` does not and loses its currency to the ellipsis. So the
1031
- * comparison below is inclusive — anything ABOVE this compacts, and everything
1032
- * a tenant sees today at or under it is untouched.
1033
- */
1034
- const CURRENCY_COMPACT_THRESHOLD = 100_000;
1035
- /**
1036
- * The numeric amount inside a formatted currency string.
1037
- *
1038
- * Strips the currency token, the grouping separators and the bidirectional
1039
- * marks `Intl` leaves around them, and normalises Arabic-Indic digits so an
1040
- * `ar-SA` payload parses like an `en` one. `null` when there is no number.
1041
- */
1042
- function parseCurrencyAmount(raw) {
1043
- if (typeof raw !== 'string') {
1044
- return null;
1045
- }
1046
- const numeric = normalizeNumerals(raw).replace(/[^0-9.+-]/g, '');
1047
- if (!numeric || !/\d/.test(numeric)) {
1048
- return null;
1049
- }
1050
- const parsed = Number.parseFloat(numeric);
1051
- return Number.isFinite(parsed) ? parsed : null;
1052
- }
1053
- /**
1054
- * Whatever is left of a formatted amount once the number is removed — `SAR`,
1055
- * `ر.س`, `$`. Read from the payload rather than configured, so a tenant's own
1056
- * currency survives untouched.
1057
- */
1058
- function currencyUnitOf(formatted) {
1059
- return normalizeNumerals(formatted)
1060
- .replace(/[0-9.,+-]/g, '')
1061
- .trim();
1062
- }
1063
- /**
1064
- * A large currency amount shortened so it fits a card slot, with the unit kept.
1065
- *
1066
- * A budget of a million or more used to render as `1,000,000 …`: the digits
1067
- * survived the ellipsis and the currency did not, so the largest and most
1068
- * consequential figures in the product were the only ones whose unit could not
1069
- * be read (finding H-06). Compact notation keeps the whole thing inside the
1070
- * slot — `SAR 1M` instead of `1,000,000 SAR` — and callers put the exact figure
1071
- * in a tooltip, which is where a precise number belongs on a summary card.
1072
- *
1073
- * Returns `formatted` unchanged whenever the value already fits, is not a
1074
- * number, or the runtime has no compact notation — so no tenant sees an
1075
- * existing number change shape for no reason.
1076
- */
1077
- function compactCurrencyDisplay(formatted, rawValue, locale, threshold = CURRENCY_COMPACT_THRESHOLD) {
1078
- const amount = parseCurrencyAmount(rawValue ?? formatted);
1079
- if (amount === null || Math.abs(amount) <= threshold) {
1080
- return formatted;
1081
- }
1082
- let compact;
1083
- try {
1084
- compact = new Intl.NumberFormat(locale, {
1085
- notation: 'compact',
1086
- maximumFractionDigits: 1,
1087
- }).format(amount);
1088
- }
1089
- catch {
1090
- return formatted;
1091
- }
1092
- const unit = currencyUnitOf(formatted);
1093
- if (!unit) {
1094
- return compact;
1095
- }
1096
- // Keep the payload's own unit placement — `SAR 1,000` and `1,000 SAR` are
1097
- // both in use, and flipping one to the other reads as a different currency.
1098
- return formatted.trimStart().startsWith(unit)
1099
- ? `${unit} ${compact}`
1100
- : `${compact} ${unit}`;
1101
- }
1102
-
1103
1435
  class EntityCurrency {
1104
1436
  transloco = inject(TranslocoService);
1105
1437
  /** Active locale, so number formatting follows the UI language. */
@@ -1153,11 +1485,11 @@ class EntityCheckbox {
1153
1485
  return coerceCheckboxValue(this.data()?.value ?? this.value());
1154
1486
  }, ...(ngDevMode ? [{ debugName: "checkboxState" }] : /* istanbul ignore next */ []));
1155
1487
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
1156
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCheckbox, isStandalone: true, selector: "mt-entity-checkbox", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, rawValue: { classPropertyName: "rawValue", publicName: "rawValue", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"flex items-center gap-2\">\r\n @if (checkboxState() === true) {\r\n <svg class=\"w-5 h-5 text-green-500\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else if (checkboxState() === false) {\r\n <svg class=\"w-5 h-5 text-gray-300\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm-1-5.414l-2.293-2.293a1 1 0 011.414-1.414L10 11.172l3.879-3.879a1 1 0 111.414 1.414L10 13.414l-.707-.707-.293-.293z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else {\r\n <span\r\n class=\"inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-100 px-1 text-[10px] font-semibold text-gray-500\"\r\n >\r\n {{ emptyLabel }}\r\n </span>\r\n }\r\n @if (!hideName()) {\r\n <span class=\"text-sm font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator />\r\n }\r\n }\r\n</div>\r\n", dependencies: [{ kind: "component", type: EntityCalculatedIndicator, selector: "mt-entity-calculated-indicator" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1488
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityCheckbox, isStandalone: true, selector: "mt-entity-checkbox", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, rawValue: { classPropertyName: "rawValue", publicName: "rawValue", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"flex items-center gap-2\">\r\n @if (checkboxState() === true) {\r\n <svg class=\"w-5 h-5 text-green-500\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else if (checkboxState() === false) {\r\n <svg class=\"w-5 h-5 text-gray-300\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm-1-5.414l-2.293-2.293a1 1 0 011.414-1.414L10 11.172l3.879-3.879a1 1 0 111.414 1.414L10 13.414l-.707-.707-.293-.293z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else {\r\n <span\r\n class=\"inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-100 px-1 text-[10px] font-semibold text-gray-500\"\r\n >\r\n {{ emptyLabel }}\r\n </span>\r\n }\r\n @if (!hideName()) {\r\n <span class=\"text-sm font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator\r\n [status]=\"data()?.calculationStatus\"\r\n [change]=\"data()?.calculationChange\"\r\n />\r\n @if (data()?.calculationChange; as change) {\r\n @if (change.recent) {\r\n <mt-entity-calculation-change [change]=\"change\" />\r\n }\r\n }\r\n }\r\n }\r\n</div>\r\n", dependencies: [{ kind: "component", type: EntityCalculatedIndicator, selector: "mt-entity-calculated-indicator", inputs: ["status", "change"] }, { kind: "component", type: EntityCalculationChangeChip, selector: "mt-entity-calculation-change", inputs: ["change"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1157
1489
  }
1158
1490
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCheckbox, decorators: [{
1159
1491
  type: Component,
1160
- args: [{ selector: 'mt-entity-checkbox', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityCalculatedIndicator], template: "<div class=\"flex items-center gap-2\">\r\n @if (checkboxState() === true) {\r\n <svg class=\"w-5 h-5 text-green-500\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else if (checkboxState() === false) {\r\n <svg class=\"w-5 h-5 text-gray-300\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm-1-5.414l-2.293-2.293a1 1 0 011.414-1.414L10 11.172l3.879-3.879a1 1 0 111.414 1.414L10 13.414l-.707-.707-.293-.293z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else {\r\n <span\r\n class=\"inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-100 px-1 text-[10px] font-semibold text-gray-500\"\r\n >\r\n {{ emptyLabel }}\r\n </span>\r\n }\r\n @if (!hideName()) {\r\n <span class=\"text-sm font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator />\r\n }\r\n }\r\n</div>\r\n" }]
1492
+ args: [{ selector: 'mt-entity-checkbox', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityCalculatedIndicator, EntityCalculationChangeChip], template: "<div class=\"flex items-center gap-2\">\r\n @if (checkboxState() === true) {\r\n <svg class=\"w-5 h-5 text-green-500\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else if (checkboxState() === false) {\r\n <svg class=\"w-5 h-5 text-gray-300\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\r\n <path\r\n fill-rule=\"evenodd\"\r\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm-1-5.414l-2.293-2.293a1 1 0 011.414-1.414L10 11.172l3.879-3.879a1 1 0 111.414 1.414L10 13.414l-.707-.707-.293-.293z\"\r\n clip-rule=\"evenodd\"\r\n />\r\n </svg>\r\n } @else {\r\n <span\r\n class=\"inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-100 px-1 text-[10px] font-semibold text-gray-500\"\r\n >\r\n {{ emptyLabel }}\r\n </span>\r\n }\r\n @if (!hideName()) {\r\n <span class=\"text-sm font-semibold\">{{ displayName() }}</span>\r\n @if (data()?.calculated) {\r\n <mt-entity-calculated-indicator\r\n [status]=\"data()?.calculationStatus\"\r\n [change]=\"data()?.calculationChange\"\r\n />\r\n @if (data()?.calculationChange; as change) {\r\n @if (change.recent) {\r\n <mt-entity-calculation-change [change]=\"change\" />\r\n }\r\n }\r\n }\r\n }\r\n</div>\r\n" }]
1161
1493
  }], 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 }] }], rawValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "rawValue", required: false }] }] } });
1162
1494
 
1163
1495
  class EntityLongText {
@@ -1320,34 +1652,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
1320
1652
  args: [{ selector: 'mt-entity-phase-gate', 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 (hasValue()) {\r\n <span\r\n class=\"inline-flex items-center px-3 py-2 rounded-md text-xs font-semibold w-fit\"\r\n [style]=\"badgeStyle()\"\r\n >\r\n {{ phaseGateLabel() }}\r\n </span>\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" }]
1321
1653
  }], 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 }] }] } });
1322
1654
 
1323
- /**
1324
- * One shared active-language signal per `TranslocoService`.
1325
- *
1326
- * `mt-entity-preview` renders once per property per record — a client-list card
1327
- * grid mounts thousands of them — so a `toSignal(langChanges$)` inside each
1328
- * instance would open thousands of subscriptions to the same Subject just to
1329
- * read one global value. The language is global, so the signal is too: created
1330
- * once, cached against the service, and shared by every entity that needs it.
1331
- *
1332
- * `manualCleanup` is deliberate. The cached signal outlives any single
1333
- * component by design, and the service it hangs off is the root injector's —
1334
- * tying its subscription to whichever entity happened to ask first would tear
1335
- * it down the moment that entity scrolled out of view.
1336
- */
1337
- const langSignals = new WeakMap();
1338
- function sharedActiveLang(transloco) {
1339
- const cached = langSignals.get(transloco);
1340
- if (cached) {
1341
- return cached;
1342
- }
1343
- const lang = toSignal(transloco.langChanges$, {
1344
- initialValue: transloco.getActiveLang(),
1345
- manualCleanup: true,
1346
- });
1347
- langSignals.set(transloco, lang);
1348
- return lang;
1349
- }
1350
-
1351
1655
  /**
1352
1656
  * Shared reading of a `PerformanceScore` value. The gauge draws from it and the
1353
1657
  * table resolver filters by it, so a card's pill and the filter it sets can
@@ -2019,11 +2323,11 @@ class EntityConnection {
2019
2323
  }, ...(ngDevMode ? [{ debugName: "connection" }] : /* istanbul ignore next */ []));
2020
2324
  displayValue = computed(() => displayOrPlaceholder(this.connection()?.display), ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
2021
2325
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityConnection, deps: [], target: i0.ɵɵFactoryTarget.Component });
2022
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: EntityConnection, isStandalone: true, selector: "mt-entity-connection", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\n [label]=\"displayName()\"\n [configuration]=\"data()?.configuration\"\n>\n <div\n class=\"min-w-0 max-w-full truncate text-sm font-semibold\"\n mtTruncateTooltip\n tooltipPosition=\"top\"\n >\n {{ displayValue() }}\n </div>\n</mt-entity-field>\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2326
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: EntityConnection, isStandalone: true, selector: "mt-entity-connection", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n>\r\n <div\r\n class=\"min-w-0 max-w-full truncate text-sm font-semibold\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n {{ displayValue() }}\r\n </div>\r\n</mt-entity-field>\r\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2023
2327
  }
2024
2328
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityConnection, decorators: [{
2025
2329
  type: Component,
2026
- args: [{ selector: 'mt-entity-connection', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip], template: "<mt-entity-field\n [label]=\"displayName()\"\n [configuration]=\"data()?.configuration\"\n>\n <div\n class=\"min-w-0 max-w-full truncate text-sm font-semibold\"\n mtTruncateTooltip\n tooltipPosition=\"top\"\n >\n {{ displayValue() }}\n </div>\n</mt-entity-field>\n" }]
2330
+ args: [{ selector: 'mt-entity-connection', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n>\r\n <div\r\n class=\"min-w-0 max-w-full truncate text-sm font-semibold\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n {{ displayValue() }}\r\n </div>\r\n</mt-entity-field>\r\n" }]
2027
2331
  }], 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 }] }] } });
2028
2332
  function normalizeEntityConnection(value) {
2029
2333
  if (value === null || value === undefined || value === '') {
@@ -2071,11 +2375,11 @@ class EntityScheduleItem {
2071
2375
  }, ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
2072
2376
  emptyLabel = ENTITY_EMPTY_VALUE_PLACEHOLDER;
2073
2377
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityScheduleItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
2074
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityScheduleItem, isStandalone: true, selector: "mt-entity-schedule-item", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, 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", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "component", type: Chip, selector: "mt-chip", inputs: ["label", "icon", "image", "removable", "removeIcon", "styleClass", "size"], outputs: ["onRemove", "onImageError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2378
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityScheduleItem, isStandalone: true, selector: "mt-entity-schedule-item", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (items().length) {\r\n <div class=\"flex flex-wrap items-center gap-2\">\r\n @for (item of items(); track item.id) {\r\n <mt-chip [label]=\"item.name\" size=\"small\" />\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", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "component", type: Chip, selector: "mt-chip", inputs: ["label", "icon", "image", "removable", "removeIcon", "styleClass", "size"], outputs: ["onRemove", "onImageError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2075
2379
  }
2076
2380
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityScheduleItem, decorators: [{
2077
2381
  type: Component,
2078
- 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" }]
2382
+ args: [{ selector: 'mt-entity-schedule-item', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, Chip], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (items().length) {\r\n <div class=\"flex flex-wrap items-center gap-2\">\r\n @for (item of items(); track item.id) {\r\n <mt-chip [label]=\"item.name\" size=\"small\" />\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" }]
2079
2383
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
2080
2384
 
2081
2385
  /**
@@ -3647,6 +3951,111 @@ function buildDisplayEntities(entities) {
3647
3951
  .sort((a, b) => (a.order ?? 0) - (b.order ?? 0)));
3648
3952
  }
3649
3953
 
3954
+ /** How long the chip beside a value that just changed stays visible. */
3955
+ const CALCULATION_CHANGE_CHIP_MS = 30_000;
3956
+ /**
3957
+ * Whether a surface marks this property as calculated. `isCalculated` alone is
3958
+ * too broad: the backend also sets it, with no calculation method, on system
3959
+ * columns such as `created_at`, `id` and `team_members`. A status has no method
3960
+ * but is recalculated, and an auto code is generated once.
3961
+ */
3962
+ function isCalculatedProperty(meta) {
3963
+ if (!meta) {
3964
+ return false;
3965
+ }
3966
+ if (meta.viewType === 'Status') {
3967
+ return true;
3968
+ }
3969
+ return (meta.isCalculated === true &&
3970
+ !!meta.calculationMethod &&
3971
+ meta.calculationMethod !== 'CodeBuilder');
3972
+ }
3973
+ const EMPTY_CHANGES = new Map();
3974
+ const historyKey = (scope, recordId, propertyKey) => `${scope}|${recordId}|${propertyKey}`;
3975
+ /**
3976
+ * Remembers the calculated values each surface last showed, for the whole
3977
+ * session, so a value that moved while the surface was closed still says so
3978
+ * when it opens again: the card of a project edited from its workspace, or a
3979
+ * preview opened a second time.
3980
+ *
3981
+ * A scope names a kind of surface, such as `preview:level:12` or
3982
+ * `list:level:12`. Each compares only with itself: two endpoints may not agree
3983
+ * at the same moment, and comparing across them would invent changes.
3984
+ */
3985
+ class CalculatedValueHistory {
3986
+ seen = new Map();
3987
+ timers = new Map();
3988
+ changes = signal(EMPTY_CHANGES, ...(ngDevMode ? [{ debugName: "changes" }] : /* istanbul ignore next */ []));
3989
+ /**
3990
+ * Records the calculated values a surface just read. Those that moved since
3991
+ * the scope last read them get a change, shown as recent for
3992
+ * {@link CALCULATION_CHANGE_CHIP_MS}.
3993
+ */
3994
+ observe(scope, recordId, entities, locale) {
3995
+ let next = null;
3996
+ for (const entity of entities) {
3997
+ if (!entity.calculated || !entity.key) {
3998
+ continue;
3999
+ }
4000
+ const key = historyKey(scope, recordId, entity.key);
4001
+ const previous = this.seen.get(key);
4002
+ this.seen.set(key, entity);
4003
+ const change = previous && describeCalculationChange(previous, entity, locale);
4004
+ if (!change) {
4005
+ continue;
4006
+ }
4007
+ next ??= new Map(this.changes());
4008
+ next.set(key, change);
4009
+ this.expireLater(key);
4010
+ }
4011
+ if (next) {
4012
+ this.changes.set(next);
4013
+ }
4014
+ }
4015
+ /** The last change of one value, if the scope saw it move. Reactive. */
4016
+ changeOf(scope, recordId, propertyKey) {
4017
+ return this.changes().get(historyKey(scope, recordId, propertyKey)) ?? null;
4018
+ }
4019
+ /**
4020
+ * The entities with the last change of each calculated value attached.
4021
+ * Returns the same array when nothing changed, so inputs stay stable.
4022
+ * Reactive.
4023
+ */
4024
+ apply(scope, recordId, entities) {
4025
+ if (this.changes().size === 0) {
4026
+ return entities;
4027
+ }
4028
+ let result = null;
4029
+ for (let index = 0; index < entities.length; index++) {
4030
+ const entity = entities[index];
4031
+ const change = entity.calculated && entity.key
4032
+ ? this.changeOf(scope, recordId, entity.key)
4033
+ : null;
4034
+ if (change && entity.calculationChange !== change) {
4035
+ result ??= [...entities];
4036
+ result[index] = { ...entity, calculationChange: change };
4037
+ }
4038
+ }
4039
+ return result ?? entities;
4040
+ }
4041
+ expireLater(key) {
4042
+ clearTimeout(this.timers.get(key));
4043
+ this.timers.set(key, setTimeout(() => {
4044
+ this.timers.delete(key);
4045
+ const change = this.changes().get(key);
4046
+ if (change?.recent) {
4047
+ this.changes.set(new Map(this.changes()).set(key, { ...change, recent: false }));
4048
+ }
4049
+ }, CALCULATION_CHANGE_CHIP_MS));
4050
+ }
4051
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculatedValueHistory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4052
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculatedValueHistory, providedIn: 'root' });
4053
+ }
4054
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: CalculatedValueHistory, decorators: [{
4055
+ type: Injectable,
4056
+ args: [{ providedIn: 'root' }]
4057
+ }] });
4058
+
3650
4059
  /**
3651
4060
  * A Text entity configured as the card header (`configuration.header`): a
3652
4061
  * full-width band with a coloured top border and the value centred, no label.
@@ -4213,5 +4622,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
4213
4622
  * Generated bundle index. Do not edit.
4214
4623
  */
4215
4624
 
4216
- export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PERFORMANCE_SCORE_CHART_SIZE, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, ENTITY_HEADER_VIEW_TYPES, ENTITY_LIST_TABLE_COMPONENT, ENTITY_ROW_SPANS, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityColor, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityHeader, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPerformanceScore, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityRuntimeContextStore, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, PERFORMANCE_SCORE_CHART_SIZES, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildSectionKey, canEntityBeHeader, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, getEntitySectionTitle, getPerformanceScoreBands, groupEntitiesIntoSections, humanizeEntityListKey, isConnectionSyntheticKey, isEntityAlignEnd, isEntityHeader, isEntityLabelHidden, isEntityListLocalDocument, isEntityListSelectionDocument, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, mergeStakeholderNameColumns, mergeStakeholderNameEntities, mergeStakeholderNameRows, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, parsePerformanceScore, pinEntityHeaderFirst, readEntityHeaderDefaults, readEntityValueColor, resolveConnectionLevelName, resolveEntityGridRow, resolveEntityHeader, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, resolvePerformanceScoreStatus, serializeEntityRawValue, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, summarizeEntityListRows, visibleLocalSchemaFields };
4625
+ export { CALCULATION_CHANGE_CHIP_MS, CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, CalculatedValueHistory, ComparisonEntityList, ComparisonValue, DEFAULT_PERFORMANCE_SCORE_CHART_SIZE, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, ENTITY_HEADER_VIEW_TYPES, ENTITY_LIST_TABLE_COMPONENT, ENTITY_ROW_SPANS, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCalculatedGlyph, EntityCalculatedIndicator, EntityCalculationChangeChip, EntityCheckbox, EntityColor, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityHeader, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPerformanceScore, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityRuntimeContextStore, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, PERFORMANCE_SCORE_CHART_SIZES, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildSectionKey, canEntityBeHeader, compactCurrencyDisplay, currencyUnitOf, describeCalculationChange, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, formatCalculationDelta, getEntitySectionTitle, getPerformanceScoreBands, groupEntitiesIntoSections, humanizeEntityListKey, isCalculatedProperty, isConnectionSyntheticKey, isEntityAlignEnd, isEntityHeader, isEntityLabelHidden, isEntityListLocalDocument, isEntityListSelectionDocument, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, mergeStakeholderNameColumns, mergeStakeholderNameEntities, mergeStakeholderNameRows, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, parsePerformanceScore, pinEntityHeaderFirst, readEntityHeaderDefaults, readEntityValueColor, resolveConnectionLevelName, resolveEntityGridRow, resolveEntityHeader, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, resolvePerformanceScoreStatus, serializeEntityRawValue, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, summarizeEntityListRows, visibleLocalSchemaFields };
4217
4626
  //# sourceMappingURL=masterteam-components-entities.mjs.map