@masterteam/components 0.0.273 → 0.0.274

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, computed, ChangeDetectionStrategy, Component, signal, effect, untracked, inject, output, ElementRef, NgZone, Directive, model } from '@angular/core';
2
+ import { input, computed, ChangeDetectionStrategy, Component, inject, ElementRef, DestroyRef, afterNextRender, Directive, signal, effect, untracked, output, NgZone, model } from '@angular/core';
3
3
  import { TruncateTooltip, Tooltip } from '@masterteam/components/tooltip';
4
4
  import { Icon } from '@masterteam/icons';
5
5
  import { MTDateFormatPipe, REQUEST_CONTEXT, readableTextOn } from '@masterteam/components';
@@ -214,6 +214,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
214
214
  args: [{ selector: 'mt-entity-text', 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 <!--\r\n Two lines before the ellipsis, not one. Portfolio and project names were\r\n being cut mid-word on the Explore board (\"Smart City Infrastructure Po\u2026\"),\r\n which makes similarly-titled records indistinguishable without opening each\r\n one (finding H-06). `line-clamp-2` still ellipsises what genuinely does not\r\n fit, and `mtTruncateTooltip` reads `scrollHeight > clientHeight`, so the\r\n tooltip keeps working for the clamped case exactly as it did for the\r\n single-line one.\r\n -->\r\n <div\r\n class=\"min-w-0 max-w-full line-clamp-2 break-words text-sm font-semibold\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n [innerHTML]=\"displayValue()\"\r\n ></div>\r\n</mt-entity-field>\r\n" }]
215
215
  }], 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 }] }] } });
216
216
 
217
+ /** Smallest size the text may shrink to before ellipsis takes over, in px. */
218
+ const MIN_FONT_PX = 11;
219
+ /** Each pass down the ramp. Small enough to look deliberate, not stepped. */
220
+ const STEP_PX = 0.5;
221
+ /**
222
+ * Shrinks an atomic value a little rather than letting it truncate.
223
+ *
224
+ * A date and an amount are single indivisible facts: `2026/08/16` cut to
225
+ * `2026/08…` has lost the day, and `100,000 SAR` cut to `100,000 …` has lost
226
+ * the currency — which is the one part a reader cannot infer. Prose survives an
227
+ * ellipsis; these do not, so they get one lever before it.
228
+ *
229
+ * Why measure instead of thresholding. The first pass at this capped currency
230
+ * by magnitude — compact anything above 100,000 — with the threshold read off
231
+ * one measured card slot. But slot width is a property of the card layout, not
232
+ * of the number: the three-across boxes on an Explore card are far narrower
233
+ * than the slot that was measured, so `100,000 SAR` and `50,000 SAR` sat under
234
+ * the threshold and truncated anyway. No constant can know the width it has.
235
+ * This asks the element.
236
+ *
237
+ * The element keeps its `truncate`, so anything still too long at the floor
238
+ * ellipsizes exactly as before — with the tooltip callers already attach
239
+ * carrying the full value. Shrinking is a nudge, never the whole answer.
240
+ */
241
+ class FitText {
242
+ /** Set false to leave a particular instance alone. */
243
+ mtFitText = input(true, { ...(ngDevMode ? { debugName: "mtFitText" } : /* istanbul ignore next */ {}), transform: (value) => value !== false && value !== 'false' });
244
+ host = inject(ElementRef);
245
+ destroyRef = inject(DestroyRef);
246
+ basePx = 0;
247
+ frame = 0;
248
+ resizeObserver;
249
+ mutationObserver;
250
+ constructor() {
251
+ afterNextRender(() => {
252
+ const el = this.host.nativeElement;
253
+ this.basePx = parseFloat(getComputedStyle(el).fontSize) || 0;
254
+ if (!this.basePx) {
255
+ return;
256
+ }
257
+ if (typeof ResizeObserver !== 'undefined') {
258
+ this.resizeObserver = new ResizeObserver(() => this.schedule());
259
+ this.resizeObserver.observe(el);
260
+ }
261
+ // The value itself changes without the box changing size — a re-fetch,
262
+ // a locale switch, an edit committed in place.
263
+ this.mutationObserver = new MutationObserver(() => this.schedule());
264
+ this.mutationObserver.observe(el, {
265
+ characterData: true,
266
+ childList: true,
267
+ subtree: true,
268
+ });
269
+ this.schedule();
270
+ });
271
+ this.destroyRef.onDestroy(() => {
272
+ this.resizeObserver?.disconnect();
273
+ this.mutationObserver?.disconnect();
274
+ if (this.frame) {
275
+ cancelAnimationFrame(this.frame);
276
+ }
277
+ });
278
+ }
279
+ schedule() {
280
+ if (this.frame) {
281
+ cancelAnimationFrame(this.frame);
282
+ }
283
+ this.frame = requestAnimationFrame(() => {
284
+ this.frame = 0;
285
+ this.fit();
286
+ });
287
+ }
288
+ fit() {
289
+ const el = this.host.nativeElement;
290
+ if (!this.mtFitText() || !this.basePx) {
291
+ el.style.removeProperty('font-size');
292
+ return;
293
+ }
294
+ // Always measure from the base size: the box may have grown back, and a
295
+ // value that once needed shrinking should return to full size when it fits.
296
+ el.style.fontSize = `${this.basePx}px`;
297
+ if (el.clientWidth === 0) {
298
+ return;
299
+ }
300
+ let size = this.basePx;
301
+ while (el.scrollWidth > el.clientWidth && size > MIN_FONT_PX) {
302
+ size = Math.max(MIN_FONT_PX, size - STEP_PX);
303
+ el.style.fontSize = `${size}px`;
304
+ }
305
+ if (size === this.basePx) {
306
+ el.style.removeProperty('font-size');
307
+ }
308
+ }
309
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FitText, deps: [], target: i0.ɵɵFactoryTarget.Directive });
310
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.8", type: FitText, isStandalone: true, selector: "[mtFitText]", inputs: { mtFitText: { classPropertyName: "mtFitText", publicName: "mtFitText", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
311
+ }
312
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FitText, decorators: [{
313
+ type: Directive,
314
+ args: [{
315
+ selector: '[mtFitText]',
316
+ standalone: true,
317
+ }]
318
+ }], ctorParameters: () => [], propDecorators: { mtFitText: [{ type: i0.Input, args: [{ isSignal: true, alias: "mtFitText", required: false }] }] } });
319
+
217
320
  class EntityDate {
218
321
  /** Full entity data object */
219
322
  data = input(...(ngDevMode ? [undefined, { debugName: "data" }] : /* istanbul ignore next */ []));
@@ -239,11 +342,11 @@ class EntityDate {
239
342
  }, ...(ngDevMode ? [{ debugName: "resolvedViewType" }] : /* istanbul ignore next */ []));
240
343
  displayValue = computed(() => this.data()?.rawValue ?? this.data()?.value ?? this.value(), ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
241
344
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityDate, deps: [], target: i0.ɵɵFactoryTarget.Component });
242
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityDate, isStandalone: true, selector: "mt-entity-date", 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 }, viewType: { classPropertyName: "viewType", publicName: "viewType", 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 <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n @if (displayValue()) {\r\n {{ displayValue() | mtDateFormat: resolvedViewType() }}\r\n } @else {\r\n -\r\n }\r\n </span>\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]" }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
345
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityDate, isStandalone: true, selector: "mt-entity-date", 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 }, viewType: { classPropertyName: "viewType", publicName: "viewType", 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 <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n mtFitText\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n @if (displayValue()) {\r\n {{ displayValue() | mtDateFormat: resolvedViewType() }}\r\n } @else {\r\n -\r\n }\r\n </span>\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]" }, { kind: "directive", type: FitText, selector: "[mtFitText]", inputs: ["mtFitText"] }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
243
346
  }
244
347
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityDate, decorators: [{
245
348
  type: Component,
246
- args: [{ selector: 'mt-entity-date', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip, MTDateFormatPipe], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n>\r\n <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n @if (displayValue()) {\r\n {{ displayValue() | mtDateFormat: resolvedViewType() }}\r\n } @else {\r\n -\r\n }\r\n </span>\r\n</mt-entity-field>\r\n" }]
349
+ args: [{ selector: 'mt-entity-date', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, TruncateTooltip, MTDateFormatPipe, FitText], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n>\r\n <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n mtFitText\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >\r\n @if (displayValue()) {\r\n {{ displayValue() | mtDateFormat: resolvedViewType() }}\r\n } @else {\r\n -\r\n }\r\n </span>\r\n</mt-entity-field>\r\n" }]
247
350
  }], 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 }] }], viewType: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewType", required: false }] }] } });
248
351
 
249
352
  class EntityStatus {
@@ -657,11 +760,11 @@ class EntityCurrency {
657
760
  */
658
761
  displayValue = computed(() => compactCurrencyDisplay(this.fullValue(), this.data()?.rawValue, this.locale()), ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
659
762
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCurrency, deps: [], target: i0.ɵɵFactoryTarget.Component });
660
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: EntityCurrency, isStandalone: true, selector: "mt-entity-currency", 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 <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n [mtTooltip]=\"fullValue()\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ displayValue() }}\r\n </span>\r\n</mt-entity-field>\r\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
763
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: EntityCurrency, isStandalone: true, selector: "mt-entity-currency", 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 <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n mtFitText\r\n [mtTooltip]=\"fullValue()\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ displayValue() }}\r\n </span>\r\n</mt-entity-field>\r\n", dependencies: [{ kind: "component", type: EntityField, selector: "mt-entity-field", inputs: ["label", "labelIconName", "configuration", "gap"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "directive", type: FitText, selector: "[mtFitText]", inputs: ["mtFitText"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
661
764
  }
662
765
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityCurrency, decorators: [{
663
766
  type: Component,
664
- args: [{ selector: 'mt-entity-currency', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, Tooltip], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n>\r\n <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n [mtTooltip]=\"fullValue()\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ displayValue() }}\r\n </span>\r\n</mt-entity-field>\r\n" }]
767
+ args: [{ selector: 'mt-entity-currency', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [EntityField, Tooltip, FitText], template: "<mt-entity-field\r\n [label]=\"displayName()\"\r\n [configuration]=\"data()?.configuration\"\r\n>\r\n <span\r\n class=\"block min-w-0 truncate text-sm font-semibold tabular-nums whitespace-nowrap\"\r\n mtFitText\r\n [mtTooltip]=\"fullValue()\"\r\n tooltipPosition=\"top\"\r\n >\r\n {{ displayValue() }}\r\n </span>\r\n</mt-entity-field>\r\n" }]
665
768
  }], 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 }] }] } });
666
769
 
667
770
  class EntityCheckbox {
@@ -2367,5 +2470,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
2367
2470
  * Generated bundle index. Do not edit.
2368
2471
  */
2369
2472
 
2370
- 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, EntityLeafDetails, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityScheduleItem, EntityStatus, EntityText, EntityUser, LEAF_DETAILS_KEY_SEPARATOR, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildSectionKey, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, getEntitySectionTitle, groupEntitiesIntoSections, isConnectionSyntheticKey, isEntityAlignEnd, isEntityLabelHidden, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isSectionKey, isValueMissing, matchesPercentageColorRule, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, resolveConnectionLevelName, resolveEntityLabelPosition, resolveLocalizedLabel, resolvePercentageColor, serializeEntityRawValue, splitConnectionKey };
2473
+ 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, EntityLeafDetails, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityScheduleItem, EntityStatus, EntityText, EntityUser, FitText, LEAF_DETAILS_KEY_SEPARATOR, SECTION_KEY_PREFIX, buildConnectionKey, buildDisplayEntities, buildSectionKey, compactCurrencyDisplay, currencyUnitOf, displayOrPlaceholder, expandConnectionEntity, expandLeafDetailsEntity, getEntitySectionTitle, groupEntitiesIntoSections, isConnectionSyntheticKey, isEntityAlignEnd, isEntityLabelHidden, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isSectionKey, isValueMissing, matchesPercentageColorRule, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, resolveConnectionLevelName, resolveEntityLabelPosition, resolveLocalizedLabel, resolvePercentageColor, serializeEntityRawValue, splitConnectionKey };
2371
2474
  //# sourceMappingURL=masterteam-components-entities.mjs.map