@masterteam/components 0.0.338 → 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.
- package/assets/common.css +1 -1
- package/assets/i18n/ar.json +4 -1
- package/assets/i18n/en.json +4 -1
- package/fesm2022/masterteam-components-business-fields.mjs +4 -4
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +517 -140
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components-field-validation.mjs.map +1 -1
- package/fesm2022/masterteam-components-treeselect-field.mjs +2 -2
- package/fesm2022/masterteam-components-treeselect-field.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-entities.d.ts +124 -5
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, Injectable, InjectionToken,
|
|
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';
|
|
@@ -349,72 +349,415 @@ const TOOLTIP_KEYS = {
|
|
|
349
349
|
idle: 'components.entitiesPreview.calculatedValue',
|
|
350
350
|
running: 'components.entitiesPreview.calculatingValue',
|
|
351
351
|
waiting: 'components.entitiesPreview.waitingToCalculate',
|
|
352
|
+
delayed: 'components.entitiesPreview.calculationDelayed',
|
|
352
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
|
+
}] });
|
|
353
405
|
/**
|
|
354
406
|
* Marks a property value the backend calculates. Rendered beside its label; it
|
|
355
|
-
* pulses while a recalculation that covers the value is in progress
|
|
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.
|
|
356
409
|
*/
|
|
357
410
|
class EntityCalculatedIndicator {
|
|
358
411
|
/** Set while the value is being recalculated. */
|
|
359
412
|
status = input(null, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
360
|
-
|
|
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 */ []));
|
|
361
429
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedIndicator, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
362
|
-
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 } }, 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: `
|
|
363
431
|
<span
|
|
364
|
-
class="relative inline-flex size-
|
|
432
|
+
class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
|
|
365
433
|
[class]="
|
|
366
434
|
status()
|
|
367
435
|
? 'bg-primary-700 text-white'
|
|
368
436
|
: 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
|
|
369
437
|
"
|
|
370
438
|
role="img"
|
|
371
|
-
[attr.aria-label]="tooltipKey() | transloco"
|
|
372
|
-
[mtTooltip]="tooltipKey() | transloco"
|
|
439
|
+
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
440
|
+
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
373
441
|
tooltipPosition="top"
|
|
374
442
|
>
|
|
375
|
-
@if (
|
|
443
|
+
@if (pulsing()) {
|
|
376
444
|
<span
|
|
377
445
|
class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
|
|
378
446
|
aria-hidden="true"
|
|
379
447
|
></span>
|
|
380
448
|
}
|
|
381
|
-
<
|
|
449
|
+
<mt-entity-calculated-glyph class="relative" />
|
|
382
450
|
</span>
|
|
383
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
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 });
|
|
384
452
|
}
|
|
385
453
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCalculatedIndicator, decorators: [{
|
|
386
454
|
type: Component,
|
|
387
455
|
args: [{
|
|
388
456
|
selector: 'mt-entity-calculated-indicator',
|
|
389
457
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
390
|
-
imports: [Tooltip, TranslocoPipe],
|
|
458
|
+
imports: [EntityCalculatedGlyph, Tooltip, TranslocoPipe],
|
|
391
459
|
template: `
|
|
392
460
|
<span
|
|
393
|
-
class="relative inline-flex size-
|
|
461
|
+
class="relative inline-flex size-4 cursor-help items-center justify-center rounded-full select-none"
|
|
394
462
|
[class]="
|
|
395
463
|
status()
|
|
396
464
|
? 'bg-primary-700 text-white'
|
|
397
465
|
: 'bg-surface-100 text-surface-500 dark:bg-surface-800 dark:text-surface-300'
|
|
398
466
|
"
|
|
399
467
|
role="img"
|
|
400
|
-
[attr.aria-label]="tooltipKey() | transloco"
|
|
401
|
-
[mtTooltip]="tooltipKey() | transloco"
|
|
468
|
+
[attr.aria-label]="tooltipKey() | transloco: tooltipParams()"
|
|
469
|
+
[mtTooltip]="tooltipKey() | transloco: tooltipParams()"
|
|
402
470
|
tooltipPosition="top"
|
|
403
471
|
>
|
|
404
|
-
@if (
|
|
472
|
+
@if (pulsing()) {
|
|
405
473
|
<span
|
|
406
474
|
class="absolute inset-0 animate-ping rounded-full bg-primary-700 opacity-60 motion-reduce:animate-none"
|
|
407
475
|
aria-hidden="true"
|
|
408
476
|
></span>
|
|
409
477
|
}
|
|
410
|
-
<
|
|
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,
|
|
740
|
+
imports: [Tooltip, TranslocoPipe],
|
|
741
|
+
template: `
|
|
742
|
+
@let description =
|
|
743
|
+
'components.entitiesPreview.calculationChangeDetail'
|
|
744
|
+
| transloco: { previous: change().previous, current: change().current };
|
|
745
|
+
<span
|
|
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"
|
|
747
|
+
role="img"
|
|
748
|
+
dir="ltr"
|
|
749
|
+
[attr.aria-label]="description"
|
|
750
|
+
[mtTooltip]="description"
|
|
751
|
+
tooltipPosition="top"
|
|
752
|
+
>
|
|
753
|
+
{{ delta() }}
|
|
411
754
|
</span>
|
|
412
755
|
`,
|
|
413
756
|
host: {
|
|
414
757
|
class: 'inline-flex shrink-0',
|
|
415
758
|
},
|
|
416
759
|
}]
|
|
417
|
-
}], propDecorators: {
|
|
760
|
+
}], propDecorators: { change: [{ type: i0.Input, args: [{ isSignal: true, alias: "change", required: true }] }] } });
|
|
418
761
|
|
|
419
762
|
/**
|
|
420
763
|
* The entity of the enclosing `mt-entity-preview`. `mt-entity-field` only
|
|
@@ -429,6 +772,11 @@ class EntityField {
|
|
|
429
772
|
});
|
|
430
773
|
calculated = computed(() => this.previewData?.().calculated === true, ...(ngDevMode ? [{ debugName: "calculated" }] : /* istanbul ignore next */ []));
|
|
431
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 */ []));
|
|
432
780
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
433
781
|
labelIconName = input(null, ...(ngDevMode ? [{ debugName: "labelIconName" }] : /* istanbul ignore next */ []));
|
|
434
782
|
configuration = input(...(ngDevMode ? [undefined, { debugName: "configuration" }] : /* istanbul ignore next */ []));
|
|
@@ -445,7 +793,13 @@ class EntityField {
|
|
|
445
793
|
const alignClass = isEntityAlignEnd(this.configuration())
|
|
446
794
|
? 'self-end'
|
|
447
795
|
: 'self-stretch';
|
|
448
|
-
|
|
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}`;
|
|
449
803
|
}, ...(ngDevMode ? [{ debugName: "contentContainerClass" }] : /* istanbul ignore next */ []));
|
|
450
804
|
containerClass = computed(() => {
|
|
451
805
|
const gapClass = this.gap() === 'relaxed'
|
|
@@ -464,6 +818,9 @@ class EntityField {
|
|
|
464
818
|
<div [class]="containerClass()">
|
|
465
819
|
<div [class]="contentContainerClass()">
|
|
466
820
|
<ng-content />
|
|
821
|
+
@if (recentChange(); as change) {
|
|
822
|
+
<mt-entity-calculation-change [change]="change" />
|
|
823
|
+
}
|
|
467
824
|
</div>
|
|
468
825
|
@if (!hideLabel()) {
|
|
469
826
|
<div [class]="labelContainerClass()">
|
|
@@ -478,23 +835,34 @@ class EntityField {
|
|
|
478
835
|
{{ label() }}
|
|
479
836
|
</span>
|
|
480
837
|
@if (calculated()) {
|
|
481
|
-
<mt-entity-calculated-indicator
|
|
838
|
+
<mt-entity-calculated-indicator
|
|
839
|
+
[status]="calculationStatus()"
|
|
840
|
+
[change]="calculationChange()"
|
|
841
|
+
/>
|
|
482
842
|
}
|
|
483
843
|
</div>
|
|
484
844
|
}
|
|
485
845
|
</div>
|
|
486
|
-
`, 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"] }], 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 });
|
|
487
847
|
}
|
|
488
848
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityField, decorators: [{
|
|
489
849
|
type: Component,
|
|
490
850
|
args: [{
|
|
491
851
|
selector: 'mt-entity-field',
|
|
492
852
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
493
|
-
imports: [
|
|
853
|
+
imports: [
|
|
854
|
+
TruncateTooltip,
|
|
855
|
+
Icon,
|
|
856
|
+
EntityCalculatedIndicator,
|
|
857
|
+
EntityCalculationChangeChip,
|
|
858
|
+
],
|
|
494
859
|
template: `
|
|
495
860
|
<div [class]="containerClass()">
|
|
496
861
|
<div [class]="contentContainerClass()">
|
|
497
862
|
<ng-content />
|
|
863
|
+
@if (recentChange(); as change) {
|
|
864
|
+
<mt-entity-calculation-change [change]="change" />
|
|
865
|
+
}
|
|
498
866
|
</div>
|
|
499
867
|
@if (!hideLabel()) {
|
|
500
868
|
<div [class]="labelContainerClass()">
|
|
@@ -509,7 +877,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
509
877
|
{{ label() }}
|
|
510
878
|
</span>
|
|
511
879
|
@if (calculated()) {
|
|
512
|
-
<mt-entity-calculated-indicator
|
|
880
|
+
<mt-entity-calculated-indicator
|
|
881
|
+
[status]="calculationStatus()"
|
|
882
|
+
[change]="calculationChange()"
|
|
883
|
+
/>
|
|
513
884
|
}
|
|
514
885
|
</div>
|
|
515
886
|
}
|
|
@@ -528,7 +899,13 @@ class EntityText {
|
|
|
528
899
|
name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : /* istanbul ignore next */ []));
|
|
529
900
|
value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
530
901
|
displayName = computed(() => this.data()?.name ?? this.name() ?? '', ...(ngDevMode ? [{ debugName: "displayName" }] : /* istanbul ignore next */ []));
|
|
531
|
-
|
|
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 */ []));
|
|
532
909
|
alignEnd = computed(() => isEntityAlignEnd(this.data()?.configuration), ...(ngDevMode ? [{ debugName: "alignEnd" }] : /* istanbul ignore next */ []));
|
|
533
910
|
displayValue = computed(() => {
|
|
534
911
|
const d = this.data();
|
|
@@ -541,11 +918,11 @@ class EntityText {
|
|
|
541
918
|
// per cell while preserving the existing sanitized markup/entity contract.
|
|
542
919
|
hasMarkup = computed(() => /[<&]/.test(this.displayValue()), ...(ngDevMode ? [{ debugName: "hasMarkup" }] : /* istanbul ignore next */ []));
|
|
543
920
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityText, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
544
|
-
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 (
|
|
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 });
|
|
545
922
|
}
|
|
546
923
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityText, decorators: [{
|
|
547
924
|
type: Component,
|
|
548
|
-
args: [{ selector: 'mt-entity-text', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip, NgTemplateOutlet], template: "@if (
|
|
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" }]
|
|
549
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 }] }] } });
|
|
550
927
|
|
|
551
928
|
/** Smallest size the text may shrink to before ellipsis takes over, in px. */
|
|
@@ -1048,90 +1425,13 @@ class EntityPercentage {
|
|
|
1048
1425
|
return Number.isNaN(numericValue) ? null : numericValue;
|
|
1049
1426
|
}
|
|
1050
1427
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityPercentage, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1051
|
-
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 />\r\n }\r\n </span>\r\n }\r\n <span class=\"
|
|
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 });
|
|
1052
1429
|
}
|
|
1053
1430
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityPercentage, decorators: [{
|
|
1054
1431
|
type: Component,
|
|
1055
|
-
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 [status]=\"data()?.calculationStatus\"\r\n />\r\n }\r\n </span>\r\n }\r\n <span class=\"
|
|
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" }]
|
|
1056
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 }] }] } });
|
|
1057
1434
|
|
|
1058
|
-
/**
|
|
1059
|
-
* The largest amount still rendered in full.
|
|
1060
|
-
*
|
|
1061
|
-
* The reviewer measured exactly where the line falls: `100,000 SAR` fits a card
|
|
1062
|
-
* slot, `1,000,000 SAR` does not and loses its currency to the ellipsis. So the
|
|
1063
|
-
* comparison below is inclusive — anything ABOVE this compacts, and everything
|
|
1064
|
-
* a tenant sees today at or under it is untouched.
|
|
1065
|
-
*/
|
|
1066
|
-
const CURRENCY_COMPACT_THRESHOLD = 100_000;
|
|
1067
|
-
/**
|
|
1068
|
-
* The numeric amount inside a formatted currency string.
|
|
1069
|
-
*
|
|
1070
|
-
* Strips the currency token, the grouping separators and the bidirectional
|
|
1071
|
-
* marks `Intl` leaves around them, and normalises Arabic-Indic digits so an
|
|
1072
|
-
* `ar-SA` payload parses like an `en` one. `null` when there is no number.
|
|
1073
|
-
*/
|
|
1074
|
-
function parseCurrencyAmount(raw) {
|
|
1075
|
-
if (typeof raw !== 'string') {
|
|
1076
|
-
return null;
|
|
1077
|
-
}
|
|
1078
|
-
const numeric = normalizeNumerals(raw).replace(/[^0-9.+-]/g, '');
|
|
1079
|
-
if (!numeric || !/\d/.test(numeric)) {
|
|
1080
|
-
return null;
|
|
1081
|
-
}
|
|
1082
|
-
const parsed = Number.parseFloat(numeric);
|
|
1083
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* Whatever is left of a formatted amount once the number is removed — `SAR`,
|
|
1087
|
-
* `ر.س`, `$`. Read from the payload rather than configured, so a tenant's own
|
|
1088
|
-
* currency survives untouched.
|
|
1089
|
-
*/
|
|
1090
|
-
function currencyUnitOf(formatted) {
|
|
1091
|
-
return normalizeNumerals(formatted)
|
|
1092
|
-
.replace(/[0-9.,+-]/g, '')
|
|
1093
|
-
.trim();
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
* A large currency amount shortened so it fits a card slot, with the unit kept.
|
|
1097
|
-
*
|
|
1098
|
-
* A budget of a million or more used to render as `1,000,000 …`: the digits
|
|
1099
|
-
* survived the ellipsis and the currency did not, so the largest and most
|
|
1100
|
-
* consequential figures in the product were the only ones whose unit could not
|
|
1101
|
-
* be read (finding H-06). Compact notation keeps the whole thing inside the
|
|
1102
|
-
* slot — `SAR 1M` instead of `1,000,000 SAR` — and callers put the exact figure
|
|
1103
|
-
* in a tooltip, which is where a precise number belongs on a summary card.
|
|
1104
|
-
*
|
|
1105
|
-
* Returns `formatted` unchanged whenever the value already fits, is not a
|
|
1106
|
-
* number, or the runtime has no compact notation — so no tenant sees an
|
|
1107
|
-
* existing number change shape for no reason.
|
|
1108
|
-
*/
|
|
1109
|
-
function compactCurrencyDisplay(formatted, rawValue, locale, threshold = CURRENCY_COMPACT_THRESHOLD) {
|
|
1110
|
-
const amount = parseCurrencyAmount(rawValue ?? formatted);
|
|
1111
|
-
if (amount === null || Math.abs(amount) <= threshold) {
|
|
1112
|
-
return formatted;
|
|
1113
|
-
}
|
|
1114
|
-
let compact;
|
|
1115
|
-
try {
|
|
1116
|
-
compact = new Intl.NumberFormat(locale, {
|
|
1117
|
-
notation: 'compact',
|
|
1118
|
-
maximumFractionDigits: 1,
|
|
1119
|
-
}).format(amount);
|
|
1120
|
-
}
|
|
1121
|
-
catch {
|
|
1122
|
-
return formatted;
|
|
1123
|
-
}
|
|
1124
|
-
const unit = currencyUnitOf(formatted);
|
|
1125
|
-
if (!unit) {
|
|
1126
|
-
return compact;
|
|
1127
|
-
}
|
|
1128
|
-
// Keep the payload's own unit placement — `SAR 1,000` and `1,000 SAR` are
|
|
1129
|
-
// both in use, and flipping one to the other reads as a different currency.
|
|
1130
|
-
return formatted.trimStart().startsWith(unit)
|
|
1131
|
-
? `${unit} ${compact}`
|
|
1132
|
-
: `${compact} ${unit}`;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
1435
|
class EntityCurrency {
|
|
1136
1436
|
transloco = inject(TranslocoService);
|
|
1137
1437
|
/** Active locale, so number formatting follows the UI language. */
|
|
@@ -1185,11 +1485,11 @@ class EntityCheckbox {
|
|
|
1185
1485
|
return coerceCheckboxValue(this.data()?.value ?? this.value());
|
|
1186
1486
|
}, ...(ngDevMode ? [{ debugName: "checkboxState" }] : /* istanbul ignore next */ []));
|
|
1187
1487
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1188
|
-
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
|
|
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 });
|
|
1189
1489
|
}
|
|
1190
1490
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCheckbox, decorators: [{
|
|
1191
1491
|
type: Component,
|
|
1192
|
-
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
|
|
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" }]
|
|
1193
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 }] }] } });
|
|
1194
1494
|
|
|
1195
1495
|
class EntityLongText {
|
|
@@ -1352,34 +1652,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1352
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" }]
|
|
1353
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 }] }] } });
|
|
1354
1654
|
|
|
1355
|
-
/**
|
|
1356
|
-
* One shared active-language signal per `TranslocoService`.
|
|
1357
|
-
*
|
|
1358
|
-
* `mt-entity-preview` renders once per property per record — a client-list card
|
|
1359
|
-
* grid mounts thousands of them — so a `toSignal(langChanges$)` inside each
|
|
1360
|
-
* instance would open thousands of subscriptions to the same Subject just to
|
|
1361
|
-
* read one global value. The language is global, so the signal is too: created
|
|
1362
|
-
* once, cached against the service, and shared by every entity that needs it.
|
|
1363
|
-
*
|
|
1364
|
-
* `manualCleanup` is deliberate. The cached signal outlives any single
|
|
1365
|
-
* component by design, and the service it hangs off is the root injector's —
|
|
1366
|
-
* tying its subscription to whichever entity happened to ask first would tear
|
|
1367
|
-
* it down the moment that entity scrolled out of view.
|
|
1368
|
-
*/
|
|
1369
|
-
const langSignals = new WeakMap();
|
|
1370
|
-
function sharedActiveLang(transloco) {
|
|
1371
|
-
const cached = langSignals.get(transloco);
|
|
1372
|
-
if (cached) {
|
|
1373
|
-
return cached;
|
|
1374
|
-
}
|
|
1375
|
-
const lang = toSignal(transloco.langChanges$, {
|
|
1376
|
-
initialValue: transloco.getActiveLang(),
|
|
1377
|
-
manualCleanup: true,
|
|
1378
|
-
});
|
|
1379
|
-
langSignals.set(transloco, lang);
|
|
1380
|
-
return lang;
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
1655
|
/**
|
|
1384
1656
|
* Shared reading of a `PerformanceScore` value. The gauge draws from it and the
|
|
1385
1657
|
* table resolver filters by it, so a card's pill and the filter it sets can
|
|
@@ -2051,11 +2323,11 @@ class EntityConnection {
|
|
|
2051
2323
|
}, ...(ngDevMode ? [{ debugName: "connection" }] : /* istanbul ignore next */ []));
|
|
2052
2324
|
displayValue = computed(() => displayOrPlaceholder(this.connection()?.display), ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
|
|
2053
2325
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityConnection, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2054
|
-
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 });
|
|
2055
2327
|
}
|
|
2056
2328
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityConnection, decorators: [{
|
|
2057
2329
|
type: Component,
|
|
2058
|
-
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" }]
|
|
2059
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 }] }] } });
|
|
2060
2332
|
function normalizeEntityConnection(value) {
|
|
2061
2333
|
if (value === null || value === undefined || value === '') {
|
|
@@ -2103,11 +2375,11 @@ class EntityScheduleItem {
|
|
|
2103
2375
|
}, ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
2104
2376
|
emptyLabel = ENTITY_EMPTY_VALUE_PLACEHOLDER;
|
|
2105
2377
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityScheduleItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2106
|
-
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 });
|
|
2107
2379
|
}
|
|
2108
2380
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityScheduleItem, decorators: [{
|
|
2109
2381
|
type: Component,
|
|
2110
|
-
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" }]
|
|
2111
2383
|
}], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
|
|
2112
2384
|
|
|
2113
2385
|
/**
|
|
@@ -3679,6 +3951,111 @@ function buildDisplayEntities(entities) {
|
|
|
3679
3951
|
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0)));
|
|
3680
3952
|
}
|
|
3681
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
|
+
|
|
3682
4059
|
/**
|
|
3683
4060
|
* A Text entity configured as the card header (`configuration.header`): a
|
|
3684
4061
|
* full-width band with a coloured top border and the value centred, no label.
|
|
@@ -4245,5 +4622,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
4245
4622
|
* Generated bundle index. Do not edit.
|
|
4246
4623
|
*/
|
|
4247
4624
|
|
|
4248
|
-
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 };
|
|
4249
4626
|
//# sourceMappingURL=masterteam-components-entities.mjs.map
|