@masterteam/components 0.0.301 → 0.0.302
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 +392 -391
- package/assets/i18n/en.json +392 -391
- package/fesm2022/masterteam-components-business-fields.mjs +562 -4
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +158 -5
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +180 -3
- package/types/masterteam-components-entities.d.ts +126 -3
|
@@ -20,6 +20,14 @@ import * as i1$1 from 'primeng/tooltip';
|
|
|
20
20
|
import { TooltipModule } from 'primeng/tooltip';
|
|
21
21
|
import { CdkDrag, CdkDropList, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
|
|
22
22
|
|
|
23
|
+
/** Whether a stored or rendered `EntityList` value is a Local document. */
|
|
24
|
+
function isEntityListLocalDocument(value) {
|
|
25
|
+
return (!!value &&
|
|
26
|
+
typeof value === 'object' &&
|
|
27
|
+
!Array.isArray(value) &&
|
|
28
|
+
value.storageMode === 'Local');
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* A section is persisted/transported as an ordinary display item whose
|
|
25
33
|
* `propertyKey` carries this sentinel prefix instead of a real property key
|
|
@@ -1579,6 +1587,87 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1579
1587
|
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" }]
|
|
1580
1588
|
}], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
|
|
1581
1589
|
|
|
1590
|
+
/**
|
|
1591
|
+
* Pure helpers shared by everything that reads a Local `EntityList`
|
|
1592
|
+
* (`storageMode: "Local"`) — the runtime field that edits it and the preview
|
|
1593
|
+
* that only renders it. See `.github/instructions/properties/EntityList.md`.
|
|
1594
|
+
*/
|
|
1595
|
+
/**
|
|
1596
|
+
* The schema's fields a row is rendered with, in order.
|
|
1597
|
+
*
|
|
1598
|
+
* A removed field stays in the stored schema as `hidden` so its values survive
|
|
1599
|
+
* and come back if it is re-added. The projected schema of a loaded value has
|
|
1600
|
+
* already dropped them, but the configuration's copy — what a create form falls
|
|
1601
|
+
* back to — has not.
|
|
1602
|
+
*/
|
|
1603
|
+
function visibleLocalSchemaFields(schema) {
|
|
1604
|
+
const fields = Array.isArray(schema?.fields) ? schema.fields : [];
|
|
1605
|
+
return fields
|
|
1606
|
+
.filter((field) => !!field && !field.hidden && !!field.id)
|
|
1607
|
+
.slice()
|
|
1608
|
+
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1609
|
+
}
|
|
1610
|
+
function pickTranslatable(value, lang) {
|
|
1611
|
+
if (!value)
|
|
1612
|
+
return '';
|
|
1613
|
+
const own = lang === 'ar' ? value.ar : value.en;
|
|
1614
|
+
const other = lang === 'ar' ? value.en : value.ar;
|
|
1615
|
+
return (own ?? '').trim() || (other ?? '').trim();
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* The label a field renders under: its local override, then the source label
|
|
1619
|
+
* captured when it was published, then its key. The publisher writes an
|
|
1620
|
+
* override into the captured definition as well, so either path shows it.
|
|
1621
|
+
*/
|
|
1622
|
+
function resolveLocalFieldLabel(field, lang = 'en') {
|
|
1623
|
+
const definition = field.definition;
|
|
1624
|
+
return (pickTranslatable(field.label, lang) ||
|
|
1625
|
+
pickTranslatable({ en: definition?.nameEn, ar: definition?.nameAr }, lang) ||
|
|
1626
|
+
(definition?.name ?? '').trim() ||
|
|
1627
|
+
field.sourceKey);
|
|
1628
|
+
}
|
|
1629
|
+
/** The source view type the field captured; `Text` when none was. */
|
|
1630
|
+
function resolveLocalFieldViewType(field) {
|
|
1631
|
+
return field.definition?.viewType || 'Text';
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* The captured source configuration (lookup id, percentage colour rules …).
|
|
1635
|
+
* `PropertyDefinitionReadDto.configuration` is typed `object?`, so the backend
|
|
1636
|
+
* writes whatever the source held — an object, or its JSON text.
|
|
1637
|
+
*/
|
|
1638
|
+
function resolveLocalFieldConfiguration(field) {
|
|
1639
|
+
const configuration = field.definition?.configuration;
|
|
1640
|
+
if (!configuration)
|
|
1641
|
+
return null;
|
|
1642
|
+
if (typeof configuration !== 'string')
|
|
1643
|
+
return configuration;
|
|
1644
|
+
try {
|
|
1645
|
+
const parsed = JSON.parse(configuration);
|
|
1646
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
1647
|
+
? parsed
|
|
1648
|
+
: null;
|
|
1649
|
+
}
|
|
1650
|
+
catch {
|
|
1651
|
+
return null;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
/** A row's cells keyed by field id. */
|
|
1655
|
+
function localCellsByFieldId(row) {
|
|
1656
|
+
const map = new Map();
|
|
1657
|
+
for (const cell of Array.isArray(row?.cells) ? row.cells : []) {
|
|
1658
|
+
if (cell?.fieldId)
|
|
1659
|
+
map.set(cell.fieldId, cell);
|
|
1660
|
+
}
|
|
1661
|
+
return map;
|
|
1662
|
+
}
|
|
1663
|
+
/** Rows in their stored order. */
|
|
1664
|
+
function sortLocalRows(rows) {
|
|
1665
|
+
return (Array.isArray(rows) ? rows : [])
|
|
1666
|
+
.filter((row) => !!row?.rowId)
|
|
1667
|
+
.slice()
|
|
1668
|
+
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1582
1671
|
/**
|
|
1583
1672
|
* Nested fields render as small labelled pairs. The row is the unit of
|
|
1584
1673
|
* meaning, so labels sit above their values and stay muted.
|
|
@@ -1758,9 +1847,13 @@ function toNestedEntity(field, values) {
|
|
|
1758
1847
|
* `allowed` narrows to those keys, in that order; empty renders every field
|
|
1759
1848
|
* that survives the companion and identifier rules.
|
|
1760
1849
|
*/
|
|
1761
|
-
function buildEntityListRows(data, allowed = []) {
|
|
1850
|
+
function buildEntityListRows(data, allowed = [], lang = 'en') {
|
|
1851
|
+
const value = coerceValue(data);
|
|
1852
|
+
if (isEntityListLocalDocument(value)) {
|
|
1853
|
+
return buildLocalRows(value, data, allowed, lang);
|
|
1854
|
+
}
|
|
1762
1855
|
const fields = visibleFields(data, allowed);
|
|
1763
|
-
const rows =
|
|
1856
|
+
const rows = value?.rows;
|
|
1764
1857
|
if (!Array.isArray(rows))
|
|
1765
1858
|
return [];
|
|
1766
1859
|
return rows
|
|
@@ -1782,6 +1875,64 @@ function buildEntityListRows(data, allowed = []) {
|
|
|
1782
1875
|
};
|
|
1783
1876
|
});
|
|
1784
1877
|
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Rows of a Local list (`storageMode: "Local"`).
|
|
1880
|
+
*
|
|
1881
|
+
* The projected document `process-form-load` returns carries its own
|
|
1882
|
+
* `schema`, and it wins: pending and approved evidence is pinned to the schema
|
|
1883
|
+
* it was submitted against, which the property configuration's *active* one
|
|
1884
|
+
* may no longer be. The fetch endpoints return the stored document instead —
|
|
1885
|
+
* `schema: null` — so the configuration's `localSchema` is the fallback.
|
|
1886
|
+
* Cells are keyed by the field's local id and carry the backend-rendered
|
|
1887
|
+
* `value` beside `rawValue` where one was rendered; otherwise the raw value
|
|
1888
|
+
* shows.
|
|
1889
|
+
*
|
|
1890
|
+
* `allowed` narrows by source key, the one identity the host can know.
|
|
1891
|
+
*/
|
|
1892
|
+
function buildLocalRows(document, data, allowed, lang) {
|
|
1893
|
+
const declared = visibleLocalSchemaFields(document.schema ?? readConfiguredLocalSchema(data));
|
|
1894
|
+
const bySourceKey = new Map(declared.map((field) => [field.sourceKey, field]));
|
|
1895
|
+
const fields = allowed.length === 0
|
|
1896
|
+
? declared
|
|
1897
|
+
: allowed
|
|
1898
|
+
.map((key) => bySourceKey.get(key))
|
|
1899
|
+
.filter((field) => !!field);
|
|
1900
|
+
return sortLocalRows(document.localRows).map((row) => {
|
|
1901
|
+
const cells = localCellsByFieldId(row);
|
|
1902
|
+
const rendered = fields.map((field) => {
|
|
1903
|
+
const cell = cells.get(field.id);
|
|
1904
|
+
const rawValue = cell?.rawValue ?? undefined;
|
|
1905
|
+
return {
|
|
1906
|
+
key: field.sourceKey,
|
|
1907
|
+
name: resolveLocalFieldLabel(field, lang),
|
|
1908
|
+
viewType: normalizeViewType(resolveLocalFieldViewType(field)),
|
|
1909
|
+
value: (cell?.value ?? rawValue ?? ''),
|
|
1910
|
+
rawValue,
|
|
1911
|
+
propertyConfiguration: resolveLocalFieldConfiguration(field) ?? undefined,
|
|
1912
|
+
configuration: NESTED_FIELD_CONFIG,
|
|
1913
|
+
order: field.order,
|
|
1914
|
+
};
|
|
1915
|
+
});
|
|
1916
|
+
const [first, ...rest] = rendered;
|
|
1917
|
+
return {
|
|
1918
|
+
id: row.rowId,
|
|
1919
|
+
title: first ? { ...first, configuration: TITLE_FIELD_CONFIG } : null,
|
|
1920
|
+
fields: rest,
|
|
1921
|
+
};
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
/** The active Local schema from the property configuration, if any. */
|
|
1925
|
+
function readConfiguredLocalSchema(data) {
|
|
1926
|
+
for (const source of [data.propertyConfiguration, data.configuration]) {
|
|
1927
|
+
if (!source || Array.isArray(source))
|
|
1928
|
+
continue;
|
|
1929
|
+
const schema = source['localSchema'];
|
|
1930
|
+
if (schema && typeof schema === 'object') {
|
|
1931
|
+
return schema;
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
return null;
|
|
1935
|
+
}
|
|
1785
1936
|
/**
|
|
1786
1937
|
* The row's title as plain text. A title that folded into a `Status` carries
|
|
1787
1938
|
* an object, not a string — reading only the string case would silently drop
|
|
@@ -2008,7 +2159,9 @@ class EntityListDrawer {
|
|
|
2008
2159
|
data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
2009
2160
|
/** Ordered allowlist of nested field keys; empty renders all of them. */
|
|
2010
2161
|
fields = input([], ...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
|
|
2011
|
-
|
|
2162
|
+
/** A Local list's labels are `{ en, ar }` pairs; see `sharedActiveLang`. */
|
|
2163
|
+
activeLang = sharedActiveLang(inject(TranslocoService));
|
|
2164
|
+
rows = computed(() => buildEntityListRows(this.data(), this.fields(), this.activeLang()), ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
2012
2165
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListDrawer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2013
2166
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListDrawer, isStandalone: true, selector: "mt-entity-list-drawer", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "block h-full" }, ngImport: i0, template: "<!--\n Owns its scroll rather than taking the shared `mt-modal-content` shell: that\n class reserves 60px for a footer, and this drawer is read-only and has none,\n so it would leave a dead strip at the bottom. `h-full` chains off the host's,\n which chains off `.p-drawer-content` \u2014 the one definite height here.\n-->\n<div class=\"flex h-full flex-col gap-2 overflow-auto p-5\">\n @for (row of rows(); track row.id) {\n <div class=\"rounded-md border border-surface-200 bg-surface-50 px-3 py-2.5\">\n @if (row.title; as title) {\n <div class=\"min-w-0 text-sm font-medium text-color\">\n <mt-entity-value-preview [data]=\"title\" attachmentShape=\"compact\" />\n </div>\n }\n\n @if (row.fields.length) {\n <!--\n The drawer has room the cell did not, so fields get a real grid with\n their labels instead of being crushed onto one wrapping line.\n `auto-fill` adapts to the drawer's actual width without a container\n query, and the `min()` floor keeps a narrow drawer from being forced\n wider than the viewport.\n -->\n <div\n class=\"mt-2 grid gap-x-4 gap-y-3 [grid-template-columns:repeat(auto-fill,minmax(min(9rem,100%),1fr))]\"\n >\n @for (field of row.fields; track field.key) {\n <div class=\"min-w-0 overflow-hidden\">\n <mt-entity-value-preview\n [data]=\"field\"\n attachmentShape=\"compact\"\n />\n </div>\n }\n </div>\n }\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: EntityValuePreview, selector: "mt-entity-value-preview", inputs: ["data", "attachmentShape"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2014
2167
|
}
|
|
@@ -2081,7 +2234,7 @@ class EntityListPreview {
|
|
|
2081
2234
|
*/
|
|
2082
2235
|
activeLang = sharedActiveLang(this.transloco);
|
|
2083
2236
|
label = computed(() => this.data().name ?? '', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2084
|
-
rows = computed(() => buildEntityListRows(this.data(), this.fields()), ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
2237
|
+
rows = computed(() => buildEntityListRows(this.data(), this.fields(), this.activeLang()), ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
2085
2238
|
count = computed(() => this.rows().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
2086
2239
|
hasRows = computed(() => this.count() > 0, ...(ngDevMode ? [{ debugName: "hasRows" }] : /* istanbul ignore next */ []));
|
|
2087
2240
|
/**
|
|
@@ -3252,5 +3405,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
3252
3405
|
* Generated bundle index. Do not edit.
|
|
3253
3406
|
*/
|
|
3254
3407
|
|
|
3255
|
-
export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, ENTITY_LIST_TABLE_COMPONENT, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityRuntimeContextStore, 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 };
|
|
3408
|
+
export { CONNECTION_KEY_SEPARATOR, CURRENCY_COMPACT_THRESHOLD, ComparisonEntityList, ComparisonValue, DEFAULT_PHASE_GATE_COLOR, ENTITY_EMPTY_VALUE_PLACEHOLDER, ENTITY_LIST_TABLE_COMPONENT, EntitiesManage, EntitiesPreview, EntitiesResizeBase, EntityAttachment, EntityCheckbox, EntityConnection, EntityCurrency, EntityDate, EntityField, EntityIcon, EntityLeafDetails, EntityListDrawer, EntityListPreview, EntityLocation, EntityLongText, EntityLookup, EntityLookupModuleCheckList, EntityPercentage, EntityPhaseGate, EntityPreview, EntityPreviewBody, EntityRuntimeContextStore, 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, isEntityListLocalDocument, isEntitySection, isLeafDetailsCatalogConfiguration, isLeafDetailsCollectionValue, isLeafDetailsRuntimeValue, isLeafDetailsSyntheticKey, isLeafDetailsValue, isLeafPhasesSyntheticKey, isLeafSyntheticKey, isSectionKey, isValueMissing, localCellsByFieldId, matchesPercentageColorRule, normalizeConnectionSourceLevels, normalizeNumerals, parseCurrencyAmount, readEntityValueColor, resolveConnectionLevelName, resolveEntityInfo, resolveEntityLabelPosition, resolveLocalFieldConfiguration, resolveLocalFieldLabel, resolveLocalFieldViewType, resolveLocalizedLabel, resolvePercentageColor, serializeEntityRawValue, sharedActiveLang, sortLocalRows, splitConnectionKey, splitLeafKey, summarizeEntityListRows, visibleLocalSchemaFields };
|
|
3256
3409
|
//# sourceMappingURL=masterteam-components-entities.mjs.map
|