@masterteam/components 0.0.302 → 0.0.303

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.
@@ -27,6 +27,13 @@ function isEntityListLocalDocument(value) {
27
27
  !Array.isArray(value) &&
28
28
  value.storageMode === 'Local');
29
29
  }
30
+ /** Whether a stored or rendered `EntityList` value is a Selected document. */
31
+ function isEntityListSelectionDocument(value) {
32
+ return (!!value &&
33
+ typeof value === 'object' &&
34
+ !Array.isArray(value) &&
35
+ value.recordMode === 'Selected');
36
+ }
30
37
 
31
38
  /**
32
39
  * A section is persisted/transported as an ordinary display item whose
@@ -1852,6 +1859,9 @@ function buildEntityListRows(data, allowed = [], lang = 'en') {
1852
1859
  if (isEntityListLocalDocument(value)) {
1853
1860
  return buildLocalRows(value, data, allowed, lang);
1854
1861
  }
1862
+ if (isEntityListSelectionDocument(value)) {
1863
+ return buildSelectionRows(value, data, allowed);
1864
+ }
1855
1865
  const fields = visibleFields(data, allowed);
1856
1866
  const rows = value?.rows;
1857
1867
  if (!Array.isArray(rows))
@@ -1881,8 +1891,9 @@ function buildEntityListRows(data, allowed = [], lang = 'en') {
1881
1891
  * The projected document `process-form-load` returns carries its own
1882
1892
  * `schema`, and it wins: pending and approved evidence is pinned to the schema
1883
1893
  * 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.
1894
+ * may no longer be. The fetch endpoints project against the active schema;
1895
+ * an older backend returned the stored document there (`schema: null`), for
1896
+ * which the configuration's `localSchema` is the fallback.
1886
1897
  * Cells are keyed by the field's local id and carry the backend-rendered
1887
1898
  * `value` beside `rawValue` where one was rendered; otherwise the raw value
1888
1899
  * shows.
@@ -1921,6 +1932,91 @@ function buildLocalRows(document, data, allowed, lang) {
1921
1932
  };
1922
1933
  });
1923
1934
  }
1935
+ /**
1936
+ * Rows of a Selected list (`recordMode: "Selected"`): one per selected record
1937
+ * the value carries values for, in selection order.
1938
+ *
1939
+ * Here there is no metadata request, so nothing names the fields or their
1940
+ * view types: labels come from the keys and each value renders as its display
1941
+ * text. A record whose values the backend withheld (`unavailableIds`) has
1942
+ * nothing to show and is left out.
1943
+ *
1944
+ * `allowed` narrows by field key; otherwise the configured `readFields`
1945
+ * order, then the order the values arrived in.
1946
+ */
1947
+ function buildSelectionRows(document, data, allowed) {
1948
+ const records = new Map((document.records ?? []).map((record) => [record.entityId, record]));
1949
+ const ids = document.entityIds?.length
1950
+ ? document.entityIds
1951
+ : [...records.keys()];
1952
+ const configured = readConfiguredReadFields(data);
1953
+ return ids.flatMap((id) => {
1954
+ const record = records.get(id);
1955
+ if (!record)
1956
+ return [];
1957
+ const values = new Map((record.values ?? []).map((item) => [item.propertyKey, item]));
1958
+ const keys = allowed.length
1959
+ ? allowed
1960
+ : configured.length
1961
+ ? configured
1962
+ : [...values.keys()];
1963
+ const rendered = keys
1964
+ .map((key) => values.get(key))
1965
+ .filter((item) => !!item)
1966
+ .map((item, index) => ({
1967
+ key: item.propertyKey,
1968
+ name: humanizeEntityListKey(item.propertyKey),
1969
+ viewType: 'Text',
1970
+ value: selectionDisplayText(item.value, item.rawValue),
1971
+ rawValue: item.rawValue ?? undefined,
1972
+ configuration: NESTED_FIELD_CONFIG,
1973
+ order: index,
1974
+ }));
1975
+ const [first, ...rest] = rendered;
1976
+ return [
1977
+ {
1978
+ id: String(record.entityId),
1979
+ title: first ? { ...first, configuration: TITLE_FIELD_CONFIG } : null,
1980
+ fields: rest,
1981
+ },
1982
+ ];
1983
+ });
1984
+ }
1985
+ /** The configured displayed fields of a Selected list, if any. */
1986
+ function readConfiguredReadFields(data) {
1987
+ for (const source of [data.propertyConfiguration, data.configuration]) {
1988
+ if (!source || Array.isArray(source))
1989
+ continue;
1990
+ const fields = source['readFields'];
1991
+ if (Array.isArray(fields) && fields.length) {
1992
+ return fields.filter((key) => typeof key === 'string' && !!key);
1993
+ }
1994
+ }
1995
+ return [];
1996
+ }
1997
+ /**
1998
+ * A rendered source value as text: a scalar as is, a user or a lookup by its
1999
+ * display name, a list joined. Falls back to the stored scalar.
2000
+ */
2001
+ function selectionDisplayText(value, rawValue) {
2002
+ if (value == null || value === '')
2003
+ return rawValue ?? '';
2004
+ if (Array.isArray(value)) {
2005
+ return value
2006
+ .map((entry) => selectionDisplayText(entry, null))
2007
+ .filter((text) => !!text)
2008
+ .join(', ');
2009
+ }
2010
+ if (typeof value !== 'object')
2011
+ return String(value);
2012
+ const record = value;
2013
+ for (const key of ['display', 'displayName', 'name']) {
2014
+ const text = record[key];
2015
+ if (typeof text === 'string' && text.trim())
2016
+ return text.trim();
2017
+ }
2018
+ return rawValue ?? '';
2019
+ }
1924
2020
  /** The active Local schema from the property configuration, if any. */
1925
2021
  function readConfiguredLocalSchema(data) {
1926
2022
  for (const source of [data.propertyConfiguration, data.configuration]) {
@@ -2363,11 +2459,11 @@ class EntityListPreview {
2363
2459
  });
2364
2460
  }
2365
2461
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListPreview, deps: [], target: i0.ɵɵFactoryTarget.Component });
2366
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListPreview, isStandalone: true, selector: "mt-entity-list-preview", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\n [label]=\"label()\"\n [configuration]=\"data().configuration\"\n gap=\"normal\"\n>\n @if (tableHost(); as host) {\n <!--\n The related records, rendered in full by the read-only\n `mt-entity-list-field`. It owns the metadata request, the access notices\n and the column projection \u2014 see `ENTITY_LIST_TABLE_COMPONENT` for why it\n arrives through an outlet rather than an import.\n -->\n <ng-container\n *ngComponentOutlet=\"host.component; inputs: host.inputs\"\n ></ng-container>\n } @else if (hasRows()) {\n <!--\n The count carries the information; the button carries the affordance.\n `mt-button` owns the tooltip and the accessible name, so the trigger is\n one element rather than a button wrapped in a tooltip host.\n -->\n <mt-button\n icon=\"general.eye\"\n [label]=\"count().toString()\"\n [tooltip]=\"tooltip()\"\n [ariaLabel]=\"ariaLabel()\"\n variant=\"text\"\n size=\"small\"\n styleClass=\"!px-2 !py-1 !gap-1\"\n (onClick)=\"openDrawer()\"\n />\n } @else {\n <span\n class=\"inline-flex w-fit items-center rounded-md bg-surface-100 px-3 py-2 text-xs font-semibold text-muted-color\"\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: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2462
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListPreview, isStandalone: true, selector: "mt-entity-list-preview", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<mt-entity-field\r\n [label]=\"label()\"\r\n [configuration]=\"data().configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (tableHost(); as host) {\r\n <!--\r\n The related records, rendered in full by the read-only\r\n `mt-entity-list-field`. It owns the metadata request, the access notices\r\n and the column projection \u2014 see `ENTITY_LIST_TABLE_COMPONENT` for why it\r\n arrives through an outlet rather than an import.\r\n -->\r\n <ng-container\r\n *ngComponentOutlet=\"host.component; inputs: host.inputs\"\r\n ></ng-container>\r\n } @else if (hasRows()) {\r\n <!--\r\n The count carries the information; the button carries the affordance.\r\n `mt-button` owns the tooltip and the accessible name, so the trigger is\r\n one element rather than a button wrapped in a tooltip host.\r\n -->\r\n <mt-button\r\n icon=\"general.eye\"\r\n [label]=\"count().toString()\"\r\n [tooltip]=\"tooltip()\"\r\n [ariaLabel]=\"ariaLabel()\"\r\n variant=\"text\"\r\n size=\"small\"\r\n styleClass=\"!px-2 !py-1 !gap-1\"\r\n (onClick)=\"openDrawer()\"\r\n />\r\n } @else {\r\n <span\r\n class=\"inline-flex w-fit items-center rounded-md bg-surface-100 px-3 py-2 text-xs font-semibold text-muted-color\"\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: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2367
2463
  }
2368
2464
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListPreview, decorators: [{
2369
2465
  type: Component,
2370
- args: [{ selector: 'mt-entity-list-preview', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [EntityField, Button, NgComponentOutlet], template: "<mt-entity-field\n [label]=\"label()\"\n [configuration]=\"data().configuration\"\n gap=\"normal\"\n>\n @if (tableHost(); as host) {\n <!--\n The related records, rendered in full by the read-only\n `mt-entity-list-field`. It owns the metadata request, the access notices\n and the column projection \u2014 see `ENTITY_LIST_TABLE_COMPONENT` for why it\n arrives through an outlet rather than an import.\n -->\n <ng-container\n *ngComponentOutlet=\"host.component; inputs: host.inputs\"\n ></ng-container>\n } @else if (hasRows()) {\n <!--\n The count carries the information; the button carries the affordance.\n `mt-button` owns the tooltip and the accessible name, so the trigger is\n one element rather than a button wrapped in a tooltip host.\n -->\n <mt-button\n icon=\"general.eye\"\n [label]=\"count().toString()\"\n [tooltip]=\"tooltip()\"\n [ariaLabel]=\"ariaLabel()\"\n variant=\"text\"\n size=\"small\"\n styleClass=\"!px-2 !py-1 !gap-1\"\n (onClick)=\"openDrawer()\"\n />\n } @else {\n <span\n class=\"inline-flex w-fit items-center rounded-md bg-surface-100 px-3 py-2 text-xs font-semibold text-muted-color\"\n >\n {{ emptyLabel }}\n </span>\n }\n</mt-entity-field>\n" }]
2466
+ args: [{ selector: 'mt-entity-list-preview', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [EntityField, Button, NgComponentOutlet], template: "<mt-entity-field\r\n [label]=\"label()\"\r\n [configuration]=\"data().configuration\"\r\n gap=\"normal\"\r\n>\r\n @if (tableHost(); as host) {\r\n <!--\r\n The related records, rendered in full by the read-only\r\n `mt-entity-list-field`. It owns the metadata request, the access notices\r\n and the column projection \u2014 see `ENTITY_LIST_TABLE_COMPONENT` for why it\r\n arrives through an outlet rather than an import.\r\n -->\r\n <ng-container\r\n *ngComponentOutlet=\"host.component; inputs: host.inputs\"\r\n ></ng-container>\r\n } @else if (hasRows()) {\r\n <!--\r\n The count carries the information; the button carries the affordance.\r\n `mt-button` owns the tooltip and the accessible name, so the trigger is\r\n one element rather than a button wrapped in a tooltip host.\r\n -->\r\n <mt-button\r\n icon=\"general.eye\"\r\n [label]=\"count().toString()\"\r\n [tooltip]=\"tooltip()\"\r\n [ariaLabel]=\"ariaLabel()\"\r\n variant=\"text\"\r\n size=\"small\"\r\n styleClass=\"!px-2 !py-1 !gap-1\"\r\n (onClick)=\"openDrawer()\"\r\n />\r\n } @else {\r\n <span\r\n class=\"inline-flex w-fit items-center rounded-md bg-surface-100 px-3 py-2 text-xs font-semibold text-muted-color\"\r\n >\r\n {{ emptyLabel }}\r\n </span>\r\n }\r\n</mt-entity-field>\r\n" }]
2371
2467
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], fields: [{ type: i0.Input, args: [{ isSignal: true, alias: "fields", required: false }] }] } });
2372
2468
 
2373
2469
  /**
@@ -3405,5 +3501,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
3405
3501
  * Generated bundle index. Do not edit.
3406
3502
  */
3407
3503
 
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 };
3504
+ 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, isEntityListSelectionDocument, 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 };
3409
3505
  //# sourceMappingURL=masterteam-components-entities.mjs.map