@masterteam/components 0.0.291 → 0.0.292
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/fesm2022/masterteam-components-business-fields.mjs +66 -14
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +79 -118
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +9 -1
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +17 -1
- package/types/masterteam-components-entities.d.ts +47 -47
|
@@ -122,6 +122,25 @@ function serializeEntityRawValue(raw) {
|
|
|
122
122
|
}
|
|
123
123
|
return String(raw);
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Reads the colour the backend resolved for a value cell.
|
|
127
|
+
*
|
|
128
|
+
* The cell carries it as a sibling of `raw`/`value` — `{ raw: "22", value:
|
|
129
|
+
* "22%", color: "#FF0000" }` — because for a Percentage the value is a
|
|
130
|
+
* formatted string with nowhere to hang a colour on. Status and Lookup cells
|
|
131
|
+
* repeat it inside `value`, where those renderers already read it.
|
|
132
|
+
*
|
|
133
|
+
* Typed as `unknown` on purpose: every fetch-cell interface in the consuming
|
|
134
|
+
* packages carries an index signature, so a mistyped or absent `color` is a
|
|
135
|
+
* runtime possibility rather than a compile error.
|
|
136
|
+
*/
|
|
137
|
+
function readEntityValueColor(color) {
|
|
138
|
+
if (typeof color !== 'string') {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
const trimmed = color.trim();
|
|
142
|
+
return trimmed || undefined;
|
|
143
|
+
}
|
|
125
144
|
function displayOrPlaceholder(value) {
|
|
126
145
|
if (isValueMissing(value)) {
|
|
127
146
|
return ENTITY_EMPTY_VALUE_PLACEHOLDER;
|
|
@@ -237,26 +256,26 @@ class EntityField {
|
|
|
237
256
|
return `flex min-w-0 ${directionClass} ${gapClass} ${alignClass}`.trimEnd();
|
|
238
257
|
}, ...(ngDevMode ? [{ debugName: "containerClass" }] : /* istanbul ignore next */ []));
|
|
239
258
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
240
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityField, isStandalone: true, selector: "mt-entity-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelIconName: { classPropertyName: "labelIconName", publicName: "labelIconName", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "block min-w-0 w-full" }, ngImport: i0, template: `
|
|
241
|
-
<div [class]="containerClass()">
|
|
242
|
-
<div [class]="contentContainerClass()">
|
|
243
|
-
<ng-content />
|
|
244
|
-
</div>
|
|
245
|
-
@if (!hideLabel()) {
|
|
246
|
-
<div [class]="labelContainerClass()">
|
|
247
|
-
@if (labelIconName(); as iconName) {
|
|
248
|
-
<mt-icon [icon]="iconName" size="xs" class="shrink-0" />
|
|
249
|
-
}
|
|
250
|
-
<span
|
|
251
|
-
class="block min-w-0 truncate"
|
|
252
|
-
mtTruncateTooltip
|
|
253
|
-
tooltipPosition="top"
|
|
254
|
-
>
|
|
255
|
-
{{ label() }}
|
|
256
|
-
</span>
|
|
257
|
-
</div>
|
|
258
|
-
}
|
|
259
|
-
</div>
|
|
259
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityField, isStandalone: true, selector: "mt-entity-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelIconName: { classPropertyName: "labelIconName", publicName: "labelIconName", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "block min-w-0 w-full" }, ngImport: i0, template: `
|
|
260
|
+
<div [class]="containerClass()">
|
|
261
|
+
<div [class]="contentContainerClass()">
|
|
262
|
+
<ng-content />
|
|
263
|
+
</div>
|
|
264
|
+
@if (!hideLabel()) {
|
|
265
|
+
<div [class]="labelContainerClass()">
|
|
266
|
+
@if (labelIconName(); as iconName) {
|
|
267
|
+
<mt-icon [icon]="iconName" size="xs" class="shrink-0" />
|
|
268
|
+
}
|
|
269
|
+
<span
|
|
270
|
+
class="block min-w-0 truncate"
|
|
271
|
+
mtTruncateTooltip
|
|
272
|
+
tooltipPosition="top"
|
|
273
|
+
>
|
|
274
|
+
{{ label() }}
|
|
275
|
+
</span>
|
|
276
|
+
</div>
|
|
277
|
+
}
|
|
278
|
+
</div>
|
|
260
279
|
`, isInline: true, dependencies: [{ kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
261
280
|
}
|
|
262
281
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityField, decorators: [{
|
|
@@ -265,26 +284,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
265
284
|
selector: 'mt-entity-field',
|
|
266
285
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
267
286
|
imports: [TruncateTooltip, Icon],
|
|
268
|
-
template: `
|
|
269
|
-
<div [class]="containerClass()">
|
|
270
|
-
<div [class]="contentContainerClass()">
|
|
271
|
-
<ng-content />
|
|
272
|
-
</div>
|
|
273
|
-
@if (!hideLabel()) {
|
|
274
|
-
<div [class]="labelContainerClass()">
|
|
275
|
-
@if (labelIconName(); as iconName) {
|
|
276
|
-
<mt-icon [icon]="iconName" size="xs" class="shrink-0" />
|
|
277
|
-
}
|
|
278
|
-
<span
|
|
279
|
-
class="block min-w-0 truncate"
|
|
280
|
-
mtTruncateTooltip
|
|
281
|
-
tooltipPosition="top"
|
|
282
|
-
>
|
|
283
|
-
{{ label() }}
|
|
284
|
-
</span>
|
|
285
|
-
</div>
|
|
286
|
-
}
|
|
287
|
-
</div>
|
|
287
|
+
template: `
|
|
288
|
+
<div [class]="containerClass()">
|
|
289
|
+
<div [class]="contentContainerClass()">
|
|
290
|
+
<ng-content />
|
|
291
|
+
</div>
|
|
292
|
+
@if (!hideLabel()) {
|
|
293
|
+
<div [class]="labelContainerClass()">
|
|
294
|
+
@if (labelIconName(); as iconName) {
|
|
295
|
+
<mt-icon [icon]="iconName" size="xs" class="shrink-0" />
|
|
296
|
+
}
|
|
297
|
+
<span
|
|
298
|
+
class="block min-w-0 truncate"
|
|
299
|
+
mtTruncateTooltip
|
|
300
|
+
tooltipPosition="top"
|
|
301
|
+
>
|
|
302
|
+
{{ label() }}
|
|
303
|
+
</span>
|
|
304
|
+
</div>
|
|
305
|
+
}
|
|
306
|
+
</div>
|
|
288
307
|
`,
|
|
289
308
|
host: {
|
|
290
309
|
class: 'block min-w-0 w-full',
|
|
@@ -649,70 +668,17 @@ function matchesPercentageColorRule(value, rule) {
|
|
|
649
668
|
return max === null || value <= max;
|
|
650
669
|
}
|
|
651
670
|
/**
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
* not dynamic — a half-authored configuration must keep behaving like the
|
|
655
|
-
* value-based one rather than losing its colour entirely.
|
|
656
|
-
*/
|
|
657
|
-
function isDynamicPercentageColorSource(source) {
|
|
658
|
-
return resolvePercentageColorPropertyRef(source) !== null;
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* The colour-bearing property the configuration points at, or `null` when it
|
|
662
|
-
* is value-based.
|
|
663
|
-
*
|
|
664
|
-
* The mode is also inferred from a present reference, not only from
|
|
665
|
-
* `colorSource`: the reference is the part that carries meaning, and a stored
|
|
666
|
-
* configuration that kept it while losing the discriminator must still resolve
|
|
667
|
-
* dynamically instead of silently repainting itself from the rules.
|
|
668
|
-
*/
|
|
669
|
-
function resolvePercentageColorPropertyRef(source) {
|
|
670
|
-
if (source?.colorSource === 'rules') {
|
|
671
|
-
return null;
|
|
672
|
-
}
|
|
673
|
-
const ref = source?.colorProperty;
|
|
674
|
-
if (!ref || !isPropertyId(ref.propertyId)) {
|
|
675
|
-
return null;
|
|
676
|
-
}
|
|
677
|
-
return { ...ref, propertyId: ref.propertyId };
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Whether a value identifies a real property.
|
|
681
|
-
*
|
|
682
|
-
* `0` is rejected as deliberately as `null`. Property ids are database
|
|
683
|
-
* identities and start at 1, so a zero can only mean "none" — and a backend
|
|
684
|
-
* DTO that models the reference as a non-nullable struct emits exactly that
|
|
685
|
-
* for an absent one. Accepting it would read every such payload as dynamic and
|
|
686
|
-
* abandon the colour rules of every Percentage property on the record.
|
|
687
|
-
*
|
|
688
|
-
* Nothing is coerced here either. `''`, `' '` and `[]` all become `0` through
|
|
689
|
-
* `Number()`, so a string or array that happens to stringify to nothing would
|
|
690
|
-
* otherwise sail through as a valid id.
|
|
691
|
-
*/
|
|
692
|
-
function isPropertyId(value) {
|
|
693
|
-
return typeof value === 'number' && Number.isInteger(value) && value > 0;
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* The colour for a percentage value.
|
|
697
|
-
*
|
|
698
|
-
* In `rules` mode: the rules in their configured order, first match wins,
|
|
699
|
-
* `defaultColor` when nothing matches. In `property` mode the value decides
|
|
700
|
-
* nothing, and there is nothing here to decide it with — the colour belongs to
|
|
701
|
-
* another property on the same record, which only the backend can read — so the
|
|
702
|
-
* answer is `defaultColor`. The rules are never consulted in that mode: they
|
|
703
|
-
* would paint a value-based colour that the author deliberately replaced.
|
|
671
|
+
* The colour for a percentage value: rules in their configured order, first
|
|
672
|
+
* match wins, `defaultColor` when nothing matches.
|
|
704
673
|
*
|
|
705
674
|
* The backend owns this evaluation and ships the winner as `color` on
|
|
706
675
|
* render/value/fetch responses, so callers must prefer that resolved colour.
|
|
707
|
-
* This exists for the surfaces that hold a raw
|
|
708
|
-
*
|
|
709
|
-
*
|
|
676
|
+
* This exists for the surfaces that hold a raw rule set and no resolved colour
|
|
677
|
+
* — the property-form preview, and catalog reads that never went through a
|
|
678
|
+
* value response.
|
|
710
679
|
*/
|
|
711
680
|
function resolvePercentageColor(value, source) {
|
|
712
681
|
const fallback = source?.defaultColor?.trim() || null;
|
|
713
|
-
if (isDynamicPercentageColorSource(source)) {
|
|
714
|
-
return fallback;
|
|
715
|
-
}
|
|
716
682
|
const numericValue = toFiniteNumber(value);
|
|
717
683
|
const rules = source?.colorRules;
|
|
718
684
|
if (numericValue === null || !Array.isArray(rules)) {
|
|
@@ -762,36 +728,31 @@ class EntityPercentage {
|
|
|
762
728
|
// ── Configuration-driven visibility ──
|
|
763
729
|
hideName = computed(() => isEntityLabelHidden(this.data()?.configuration), ...(ngDevMode ? [{ debugName: "hideName" }] : /* istanbul ignore next */ []));
|
|
764
730
|
/**
|
|
765
|
-
* The bar colour. The backend evaluates the property's
|
|
731
|
+
* The bar colour. The backend evaluates the property's colour rules and
|
|
766
732
|
* returns the winner as `color` on render/value/fetch responses, so a
|
|
767
|
-
* resolved colour always wins — the
|
|
768
|
-
*
|
|
733
|
+
* resolved colour always wins — the rules are only evaluated here for
|
|
734
|
+
* configurations that arrive without one (a catalog read, or the
|
|
735
|
+
* property-form preview).
|
|
769
736
|
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
* `
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
* is evaluated. Deciding it per-configuration would let a `colorRules` copy
|
|
777
|
-
* left on the instance config paint a band colour for a property whose own
|
|
778
|
-
* configuration replaced those rules — the one outcome this mode exists to
|
|
779
|
-
* prevent.
|
|
737
|
+
* The value's own `color` is checked first and is not the same thing as
|
|
738
|
+
* `configuration.color`: it is resolved per record, so it is the only one
|
|
739
|
+
* that can carry a band colour for *this* value, or the colour a
|
|
740
|
+
* `colorSource: 'property'` configuration took from a sibling property on
|
|
741
|
+
* this record. A configuration-level colour applies to every value alike and
|
|
742
|
+
* cannot answer either question.
|
|
780
743
|
*/
|
|
781
744
|
progressColor = computed(() => {
|
|
782
745
|
const d = this.data();
|
|
783
746
|
const direct = d?.configuration;
|
|
784
747
|
const fromProperty = d?.propertyConfiguration;
|
|
748
|
+
const perValue = readEntityValueColor(d?.color);
|
|
749
|
+
if (perValue) {
|
|
750
|
+
return perValue;
|
|
751
|
+
}
|
|
785
752
|
const resolved = direct?.color?.trim() || fromProperty?.color?.trim();
|
|
786
753
|
if (resolved) {
|
|
787
754
|
return resolved;
|
|
788
755
|
}
|
|
789
|
-
if (isDynamicPercentageColorSource(direct) ||
|
|
790
|
-
isDynamicPercentageColorSource(fromProperty)) {
|
|
791
|
-
return (direct?.defaultColor?.trim() ||
|
|
792
|
-
fromProperty?.defaultColor?.trim() ||
|
|
793
|
-
'primary');
|
|
794
|
-
}
|
|
795
756
|
const raw = this.rawNumericValue();
|
|
796
757
|
return (resolvePercentageColor(raw, direct) ??
|
|
797
758
|
resolvePercentageColor(raw, fromProperty) ??
|
|
@@ -3169,5 +3130,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
3169
3130
|
* Generated bundle index. Do not edit.
|
|
3170
3131
|
*/
|
|
3171
3132
|
|
|
3172
|
-
export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildSectionKey, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, getEntitySectionTitle, groupEntitiesIntoSections, humanizeEntityListKey, isConnectionSyntheticKey,
|
|
3133
|
+
export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, LEAF_PHASES_KEY_SEPARATOR, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildEntityListRows, buildSectionKey, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, extractDisplayText, getEntitySectionTitle, groupEntitiesIntoSections, humanizeEntityListKey, isConnectionSyntheticKey, isEntityAlignEnd, isEntityLabelHidden, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isSectionKey, isValueMissing, matchesPercentageColorRule, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, readEntityValueColor, resolveConnectionLevelName, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalizedLabel, resolvePercentageColor, serializeEntityRawValue, sharedActiveLang, splitConnectionKey, splitLeafKey, summarizeEntityListRows };
|
|
3173
3134
|
//# sourceMappingURL=masterteam-components-entities.mjs.map
|