@memberjunction/ng-base-forms 6.2.0-edge.0 → 6.2.0-edge.2

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.
Files changed (105) hide show
  1. package/dist/lib/base-form-component.d.ts +34 -0
  2. package/dist/lib/base-form-component.d.ts.map +1 -1
  3. package/dist/lib/base-form-component.js +68 -1
  4. package/dist/lib/base-form-component.js.map +1 -1
  5. package/dist/lib/base-form-section-info.js +5 -5
  6. package/dist/lib/base-form-section-info.js.map +1 -1
  7. package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
  8. package/dist/lib/chrome/resolve-form-chrome.js +22 -12
  9. package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
  10. package/dist/lib/container/record-form-container.component.d.ts +41 -12
  11. package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
  12. package/dist/lib/container/record-form-container.component.js +476 -378
  13. package/dist/lib/container/record-form-container.component.js.map +1 -1
  14. package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts +150 -0
  15. package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts.map +1 -0
  16. package/dist/lib/duplicate-entry-check/duplicate-entry-check.js +263 -0
  17. package/dist/lib/duplicate-entry-check/duplicate-entry-check.js.map +1 -0
  18. package/dist/lib/explorer-entity-data-grid.component.d.ts +18 -1
  19. package/dist/lib/explorer-entity-data-grid.component.d.ts.map +1 -1
  20. package/dist/lib/explorer-entity-data-grid.component.js +38 -10
  21. package/dist/lib/explorer-entity-data-grid.component.js.map +1 -1
  22. package/dist/lib/field/form-field.component.d.ts +42 -5
  23. package/dist/lib/field/form-field.component.d.ts.map +1 -1
  24. package/dist/lib/field/form-field.component.js +118 -23
  25. package/dist/lib/field/form-field.component.js.map +1 -1
  26. package/dist/lib/form-field-edit.coordinator.d.ts +25 -0
  27. package/dist/lib/form-field-edit.coordinator.d.ts.map +1 -0
  28. package/dist/lib/form-field-edit.coordinator.js +27 -0
  29. package/dist/lib/form-field-edit.coordinator.js.map +1 -0
  30. package/dist/lib/form-state.service.d.ts +58 -0
  31. package/dist/lib/form-state.service.d.ts.map +1 -1
  32. package/dist/lib/form-state.service.js +156 -40
  33. package/dist/lib/form-state.service.js.map +1 -1
  34. package/dist/lib/host/entity-form-host.component.d.ts +10 -2
  35. package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
  36. package/dist/lib/host/entity-form-host.component.js +24 -8
  37. package/dist/lib/host/entity-form-host.component.js.map +1 -1
  38. package/dist/lib/interactive-form/interactive-form.component.d.ts +16 -4
  39. package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
  40. package/dist/lib/interactive-form/interactive-form.component.js +38 -12
  41. package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
  42. package/dist/lib/isa-related-panel/isa-related-card.component.d.ts +3 -3
  43. package/dist/lib/isa-related-panel/isa-related-card.component.js +6 -6
  44. package/dist/lib/isa-related-panel/isa-related-card.component.js.map +1 -1
  45. package/dist/lib/isa-related-panel/isa-related-panel.component.d.ts +3 -3
  46. package/dist/lib/isa-related-panel/isa-related-panel.component.js +8 -8
  47. package/dist/lib/isa-related-panel/isa-related-panel.component.js.map +1 -1
  48. package/dist/lib/overlays/form-slide-in.component.d.ts +2 -0
  49. package/dist/lib/overlays/form-slide-in.component.d.ts.map +1 -1
  50. package/dist/lib/overlays/form-slide-in.component.js +5 -1
  51. package/dist/lib/overlays/form-slide-in.component.js.map +1 -1
  52. package/dist/lib/panel/collapsible-panel.component.d.ts +9 -9
  53. package/dist/lib/panel/collapsible-panel.component.js +23 -23
  54. package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
  55. package/dist/lib/panel-slot/base-form-panel.d.ts +2 -0
  56. package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
  57. package/dist/lib/panel-slot/base-form-panel.js +5 -1
  58. package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
  59. package/dist/lib/panel-slot/form-contribution.d.ts +12 -0
  60. package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
  61. package/dist/lib/panel-slot/form-contribution.js +43 -10
  62. package/dist/lib/panel-slot/form-contribution.js.map +1 -1
  63. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +10 -0
  64. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
  65. package/dist/lib/panel-slot/form-slot-coordinator.service.js +25 -5
  66. package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
  67. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
  68. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
  69. package/dist/lib/panel-slot/related-entity-grid-panel.component.js +5 -1
  70. package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
  71. package/dist/lib/section-loader-component.d.ts +5 -1
  72. package/dist/lib/section-loader-component.d.ts.map +1 -1
  73. package/dist/lib/section-loader-component.js +13 -5
  74. package/dist/lib/section-loader-component.js.map +1 -1
  75. package/dist/lib/section-manager/section-manager.component.d.ts +2 -2
  76. package/dist/lib/section-manager/section-manager.component.js +6 -6
  77. package/dist/lib/section-manager/section-manager.component.js.map +1 -1
  78. package/dist/lib/toolbar/form-toolbar.component.d.ts +127 -7
  79. package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
  80. package/dist/lib/toolbar/form-toolbar.component.js +935 -334
  81. package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
  82. package/dist/lib/types/form-events.d.ts +6 -0
  83. package/dist/lib/types/form-events.d.ts.map +1 -1
  84. package/dist/lib/types/form-events.js +6 -0
  85. package/dist/lib/types/form-events.js.map +1 -1
  86. package/dist/lib/types/form-toolbar-item.d.ts +20 -1
  87. package/dist/lib/types/form-toolbar-item.d.ts.map +1 -1
  88. package/dist/lib/types/form-toolbar-item.js.map +1 -1
  89. package/dist/lib/types/form-types.d.ts +7 -0
  90. package/dist/lib/types/form-types.d.ts.map +1 -1
  91. package/dist/lib/types/form-types.js +5 -1
  92. package/dist/lib/types/form-types.js.map +1 -1
  93. package/dist/lib/types/toolbar-config.d.ts +16 -0
  94. package/dist/lib/types/toolbar-config.d.ts.map +1 -1
  95. package/dist/lib/types/toolbar-config.js +3 -0
  96. package/dist/lib/types/toolbar-config.js.map +1 -1
  97. package/dist/module.d.ts +2 -1
  98. package/dist/module.d.ts.map +1 -1
  99. package/dist/module.js +7 -3
  100. package/dist/module.js.map +1 -1
  101. package/dist/public-api.d.ts +2 -0
  102. package/dist/public-api.d.ts.map +1 -1
  103. package/dist/public-api.js +3 -0
  104. package/dist/public-api.js.map +1 -1
  105. package/package.json +20 -18
@@ -1 +1 @@
1
- {"version":3,"file":"base-form-panel.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/base-form-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAc,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;;AAkHxF;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,OAAgB,aAAa;IAC/B;;;;OAIG;IAEM,WAAW,GAAG,UAAU,CAAC;IAElC,6EAA6E;IACpE,MAAM,CAAW;IAC1B,kGAAkG;IACzF,aAAa,CAAqB;IAC3C,qGAAqG;IAC5F,WAAW,CAAe;IAEnC;;;;;OAKG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,aAAa,EAAE,QAAQ,IAAI,KAAK,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,QAAQ;QACX,6EAA6E;QAC7E,6DAA6D;QAC7D,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAC,OAAgB;QACrC,0BAA0B;IAC9B,CAAC;IAED;;OAEG;IACI,mBAAmB,CAAC,IAA2B;QAClD,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,GAAW;QACpC,IAAI,CAAC,aAAa,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,GAAuB,EAAE,SAAyC;QAC1F,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,GAAuB;QAC1C,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,GAAuB;QAC1C,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,GAAuB,EAAE,MAAe;QAC9D,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,iBAAiB,CAAC,GAAuB;QAC5C,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,mBAAmB,CAAC,GAAuB,EAAE,KAAa;QAC7D,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;uGA1GiB,aAAa;6DAAb,aAAa;YAAb,0CAAa;;;iFAAb,aAAa;cADlC,SAAS;;kBAOL,WAAW;mBAAC,eAAe;;kBAI3B,KAAK;;kBAEL,KAAK;;kBAEL,KAAK","sourcesContent":["import { Directive, HostBinding, Input } from '@angular/core';\nimport { BaseEntity, ValidationResult, type FormInclusion } from '@memberjunction/core';\nimport { BaseFormComponent } from '../base-form-component';\nimport { FormContext } from '../types/form-types';\nimport { FormToolbarItemConfig, FormToolbarItemKey } from '../types/form-toolbar-item';\n\n/**\n * Well-known slot positions where panels can be injected into a generated\n * entity form. Used as the `slot` field in a panel's registration metadata.\n *\n * Slot positions inside the form, top to bottom:\n *\n * ┌─ <mj-record-form-container>\n * │ [top-area slot] ← CodeGen-emitted; rare (entities with top-area section)\n * │ [before-fields slot] ← CodeGen-emitted; banners / warnings above field panels\n * │ <connection details>\n * │ <other generated field panels>\n * │ [after-fields slot] ← CodeGen-emitted; typed config knobs, secondary settings — most common slot\n * │ <content items grid>\n * │ <other related-entity grids>\n * │ [after-related slot] ← CodeGen-emitted; bottom-of-form addenda\n * │ [after-everything slot] ← Container-emitted; ALWAYS present (fallback target)\n * └─ </mj-record-form-container>\n *\n * Pick the slot that matches the panel's role. `after-fields` is the default\n * for most \"additional settings\" panels — it sits in the field column, before\n * the related-entity grids.\n *\n * **Fallback behavior** — see `FormSlotCoordinator`. If the registered slot is\n * missing in the current form (CodeGen hasn't been rerun against the new\n * template emitter), the panel walks forward in the chain until it finds an\n * existing slot. `after-everything` is always emitted by the container, so\n * fallback never dead-ends. Pre-CodeGen-regen forms show every panel at the\n * bottom of the form; post-regen forms show them in the preferred position.\n */\nexport type FormPanelSlot =\n | 'top-area'\n | 'before-fields'\n | 'after-fields'\n | 'after-related'\n | 'after-everything';\n\n/**\n * Shape of the `metadata` object every BaseFormPanel registration MUST attach\n * via `@RegisterClass(BaseFormPanel, { metadata: {...} })`. The\n * `<mj-form-panel-slot>` host filters registrations by matching against this\n * shape — registrations without it are silently ignored.\n *\n * - `entity` — the exact entity name (case-sensitive equality enforced by the\n * slot host), OR the wildcard `'*'` to register an\n * **entity-agnostic** panel that mounts on EVERY entity's form.\n * Wildcard panels are expected to self-hide (render nothing) when\n * they don't apply to the current record, so the cross-cutting\n * registration stays unobtrusive on forms it has no business on.\n * - `slot` — which slot the panel renders into.\n * - `sortKey`— higher = earlier within the slot. Defaults to 0 if omitted.\n * Use ranges (e.g., 100/50/10) so future panels can wedge in\n * without recomputing every neighbor's sort.\n */\nexport interface FormPanelRegistrationMetadata extends Record<string, unknown> {\n entity: string;\n slot: FormPanelSlot;\n sortKey?: number;\n /**\n * Identity for last-wins collapse. Two registrations with the same key\n * compete; highest ClassFactory `Priority` wins. Omit to derive:\n * `related:${relatedEntity}:${relatedJoinField}` when claiming a\n * relationship, otherwise the registration is unique and never collapses.\n */\n contributionKey?: string;\n /**\n * When set, this panel **replaces** the default related-entity grid for\n * that relationship on `entity`'s form. The baked CodeGen panel (if any)\n * is hidden; the stock fill-in grid is not mounted.\n */\n relatedEntity?: string;\n /**\n * Disambiguates two FKs to the same related entity (BillTo vs ShipTo).\n * Compared after stripping wrapping `[]`.\n */\n relatedJoinField?: string;\n /**\n * CodeGen `SectionKey` of a baked field (or other) panel this contribution\n * replaces — e.g. `'details'`, `'personalIdentity'`. Hidden at runtime via\n * `HiddenSectionKeys`. Use with `slot: 'before-fields'` for a form hero that\n * is not a collapsible panel. Must name a concrete `entity` (not `'*'`).\n */\n replacesSectionKey?: string;\n /**\n * Pin this contribution to a chrome bucket instead of its own rail item.\n * `'details'` — leftover own-fields group. `'more'` — overflow folder.\n */\n chromeGroup?: 'details' | 'more';\n /**\n * L1 inclusion for this contribution (same verbs as relationships).\n * `'Primary'` — own first-class rail item, in the lead band before Details.\n * `'More'` — overflow folder. `'None'` — hidden.\n * L3 `MJ: Form Chrome Rules` still wins. `chromeGroup` still merges.\n */\n inclusion?: FormInclusion;\n\n /**\n * Open a NEW (unsaved) record on this contribution instead of the first first-class group.\n *\n * A saved record opens where the user last was, or on the lead group. That is right for reading a\n * record and wrong for creating one: the lead group is usually a summary, and a summary of a record\n * with no data is a page of blanks the user has to look past to find where typing starts.\n *\n * Only consulted when the record is unsaved, so it cannot change how an existing record opens.\n * If several contributions on one entity set it, the highest ClassFactory `Priority` wins, matching\n * how every other conflict between registrations is settled.\n */\n leadsWhenUnsaved?: boolean;\n}\n\n/**\n * Abstract base for every dynamically-injectable form panel.\n *\n * Subclasses are standalone Angular components decorated with\n * `@RegisterClass(BaseFormPanel, { metadata: { entity, slot, sortKey? } })`.\n * At runtime, `<mj-form-panel-slot>` discovers matching registrations via\n * `ClassFactory.GetAllRegistrationsByMetadata`, instantiates each via\n * `ViewContainerRef.createComponent`, and wires `Record` + `FormComponent` +\n * `FormContext` into the inputs.\n *\n * Lifecycle hooks: standard Angular `ngOnInit` / `ngOnDestroy` work as usual.\n * `Record` is guaranteed to be set before the first change-detection pass.\n *\n * Optional `validate()` returns a synchronous validation result; the parent\n * `BaseFormComponent.Save()` path will surface it via the existing validation\n * pipeline when called. Panels that don't validate anything beyond what the\n * record itself does can leave this method off.\n */\n@Directive()\nexport abstract class BaseFormPanel<TRecord extends BaseEntity = BaseEntity> {\n /**\n * Slot-mounted hosts must not sit in the left-nav flex column — leftover\n * height targets `mj-collapsible-panel` as a direct child of\n * `.mj-forms-all-panels`. `display: contents` makes the inner panel that child.\n */\n @HostBinding('style.display')\n readonly HostDisplay = 'contents';\n\n /** The entity record being edited. Set by the slot host before view init. */\n @Input() Record!: TRecord;\n /** The host form component (use for EditMode, dirty notifications, etc). Set by the slot host. */\n @Input() FormComponent!: BaseFormComponent;\n /** Optional form context — same shape the collapsible-panel chrome expects. Set by the slot host. */\n @Input() FormContext?: FormContext;\n\n /**\n * Convenience getter for read-only / edit-mode rendering. Falls back to\n * `false` when the panel is shown outside a `BaseFormComponent` host (e.g.,\n * a dashboard quick-edit dialog reusing the same panel — see the\n * \"composable panel\" docs).\n */\n public get EditMode(): boolean {\n return this.FormComponent?.EditMode ?? false;\n }\n\n /**\n * Override to add per-panel validation that should block the parent form's\n * Save(). Return `{ Success: true, Errors: [] }` when valid, or include\n * `ValidationErrorInfo` entries to surface field-level errors. The default\n * implementation reports valid (panels that don't need extra validation\n * can leave this method off).\n */\n public validate(): ValidationResult {\n // Inline construction — ValidationResult is a class in @memberjunction/core,\n // not a plain interface, so callers can construct via `new`.\n const result = new ValidationResult();\n result.Success = true;\n return result;\n }\n\n /**\n * Called after the parent form reloads the current record from the database.\n * Default is a no-op. Override to refresh panel-owned data that is not a\n * related-entity grid (those already subscribe to\n * {@link FormRecordRefreshCoordinator} themselves).\n */\n public OnRecordRefreshed(_record: TRecord): void {\n // Subclasses can override\n }\n\n /**\n * Registers a dynamic toolbar action item / button into the host form toolbar.\n */\n public RegisterToolbarItem(item: FormToolbarItemConfig): void {\n this.FormComponent?.RegisterToolbarItem(item);\n }\n\n /**\n * Unregisters a previously registered dynamic toolbar item by key.\n */\n public UnregisterToolbarItem(key: string): void {\n this.FormComponent?.UnregisterToolbarItem(key);\n }\n\n /**\n * Configures overrides for any toolbar item (standard built-in items like 'edit',\n * 'delete', 'favorite', 'history', etc., or custom items).\n */\n public ConfigureToolbarItem(key: FormToolbarItemKey, overrides: Partial<FormToolbarItemConfig>): void {\n this.FormComponent?.ConfigureToolbarItem(key, overrides);\n }\n\n /**\n * Dynamically hides a toolbar item by key.\n */\n public HideToolbarItem(key: FormToolbarItemKey): void {\n this.FormComponent?.HideToolbarItem(key);\n }\n\n /**\n * Dynamically shows a toolbar item by key.\n */\n public ShowToolbarItem(key: FormToolbarItemKey): void {\n this.FormComponent?.ShowToolbarItem(key);\n }\n\n /**\n * Dynamically disables a toolbar item by key, with an optional reason string for the tooltip.\n */\n public DisableToolbarItem(key: FormToolbarItemKey, reason?: string): void {\n this.FormComponent?.DisableToolbarItem(key, reason);\n }\n\n /**\n * Dynamically enables a toolbar item by key.\n */\n public EnableToolbarItem(key: FormToolbarItemKey): void {\n this.FormComponent?.EnableToolbarItem(key);\n }\n\n /**\n * Sets the numeric display order for a toolbar item.\n */\n public SetToolbarItemOrder(key: FormToolbarItemKey, order: number): void {\n this.FormComponent?.SetToolbarItemOrder(key, order);\n }\n}\n"]}
1
+ {"version":3,"file":"base-form-panel.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/base-form-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,M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AAC,GAAuB;QAC1C,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,GAAuB,EAAE,MAAe;QAC9D,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,iBAAiB,CAAC,GAAuB;QAC5C,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,mBAAmB,CAAC,GAAuB,EAAE,KAAa;QAC7D,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;uGA/GiB,aAAa;6DAAb,aAAa;YAAb,0CAAa;;;iFAAb,aAAa;cADlC,SAAS;;kBAOL,WAAW;mBAAC,eAAe;;kBAI3B,KAAK;;kBAEL,KAAK;;kBAEL,KAAK","sourcesContent":["import { Directive, HostBinding, Input } from '@angular/core';\nimport { BaseEntity, ValidationResult, type FormInclusion } from '@memberjunction/core';\nimport { BaseFormComponent } from '../base-form-component';\nimport { FormContext } from '../types/form-types';\nimport { FormToolbarItemConfig, FormToolbarItemKey } from '../types/form-toolbar-item';\n\n/**\n * Well-known slot positions where panels can be injected into a generated\n * entity form. Used as the `slot` field in a panel's registration metadata.\n *\n * Slot positions inside the form, top to bottom:\n *\n * ┌─ <mj-record-form-container>\n * │ [top-area slot] ← CodeGen-emitted; rare (entities with top-area section)\n * │ [before-fields slot] ← CodeGen-emitted; banners / warnings above field panels\n * │ <connection details>\n * │ <other generated field panels>\n * │ [after-fields slot] ← CodeGen-emitted; typed config knobs, secondary settings — most common slot\n * │ <content items grid>\n * │ <other related-entity grids>\n * │ [after-related slot] ← CodeGen-emitted; bottom-of-form addenda\n * │ [after-everything slot] ← Container-emitted; ALWAYS present (fallback target)\n * └─ </mj-record-form-container>\n *\n * Pick the slot that matches the panel's role. `after-fields` is the default\n * for most \"additional settings\" panels — it sits in the field column, before\n * the related-entity grids.\n *\n * **Fallback behavior** — see `FormSlotCoordinator`. If the registered slot is\n * missing in the current form (CodeGen hasn't been rerun against the new\n * template emitter), the panel walks forward in the chain until it finds an\n * existing slot. `after-everything` is always emitted by the container, so\n * fallback never dead-ends. Pre-CodeGen-regen forms show every panel at the\n * bottom of the form; post-regen forms show them in the preferred position.\n */\nexport type FormPanelSlot =\n | 'top-area'\n | 'before-fields'\n | 'after-fields'\n | 'after-related'\n | 'after-everything';\n\n/**\n * Shape of the `metadata` object every BaseFormPanel registration MUST attach\n * via `@RegisterClass(BaseFormPanel, { metadata: {...} })`. The\n * `<mj-form-panel-slot>` host filters registrations by matching against this\n * shape — registrations without it are silently ignored.\n *\n * - `entity` — the exact entity name (case-sensitive equality enforced by the\n * slot host), OR the wildcard `'*'` to register an\n * **entity-agnostic** panel that mounts on EVERY entity's form.\n * Wildcard panels are expected to self-hide (render nothing) when\n * they don't apply to the current record, so the cross-cutting\n * registration stays unobtrusive on forms it has no business on.\n * - `slot` — which slot the panel renders into.\n * - `sortKey`— higher = earlier within the slot. Defaults to 0 if omitted.\n * Use ranges (e.g., 100/50/10) so future panels can wedge in\n * without recomputing every neighbor's sort.\n */\nexport interface FormPanelRegistrationMetadata extends Record<string, unknown> {\n entity: string;\n slot: FormPanelSlot;\n sortKey?: number;\n /**\n * Identity for last-wins collapse. Two registrations with the same key\n * compete; highest ClassFactory `Priority` wins. Omit to derive:\n * `related:${relatedEntity}:${relatedJoinField}` when claiming a\n * relationship, otherwise the registration is unique and never collapses.\n */\n contributionKey?: string;\n /**\n * When set, this panel **replaces** the default related-entity grid for\n * that relationship on `entity`'s form. The baked CodeGen panel (if any)\n * is hidden; the stock fill-in grid is not mounted.\n */\n relatedEntity?: string;\n /**\n * Disambiguates two FKs to the same related entity (BillTo vs ShipTo).\n * Compared after stripping wrapping `[]`.\n */\n relatedJoinField?: string;\n /**\n * CodeGen `SectionKey` of a baked field (or other) panel this contribution\n * replaces — e.g. `'details'`, `'personalIdentity'`. Hidden at runtime via\n * `HiddenSectionKeys`. Use with `slot: 'before-fields'` for a form hero that\n * is not a collapsible panel. Must name a concrete `entity` (not `'*'`).\n */\n replacesSectionKey?: string;\n /**\n * Pin this contribution to a chrome bucket instead of its own rail item.\n * `'details'` — leftover own-fields group. `'more'` — overflow folder.\n */\n chromeGroup?: 'details' | 'more';\n /**\n * L1 inclusion for this contribution (same verbs as relationships).\n * `'Primary'` — own first-class rail item, in the lead band before Details.\n * `'More'` — overflow folder. `'None'` — hidden.\n * L3 `MJ: Form Chrome Rules` still wins. `chromeGroup` still merges.\n */\n inclusion?: FormInclusion;\n\n /**\n * Open a NEW (unsaved) record on this contribution instead of the first first-class group.\n *\n * A saved record opens where the user last was, or on the lead group. That is right for reading a\n * record and wrong for creating one: the lead group is usually a summary, and a summary of a record\n * with no data is a page of blanks the user has to look past to find where typing starts.\n *\n * Only consulted when the record is unsaved, so it cannot change how an existing record opens.\n * If several contributions on one entity set it, the highest ClassFactory `Priority` wins, matching\n * how every other conflict between registrations is settled.\n */\n leadsWhenUnsaved?: boolean;\n}\n\n/**\n * Abstract base for every dynamically-injectable form panel.\n *\n * Subclasses are standalone Angular components decorated with\n * `@RegisterClass(BaseFormPanel, { metadata: { entity, slot, sortKey? } })`.\n * At runtime, `<mj-form-panel-slot>` discovers matching registrations via\n * `ClassFactory.GetAllRegistrationsByMetadata`, instantiates each via\n * `ViewContainerRef.createComponent`, and wires `Record` + `FormComponent` +\n * `FormContext` into the inputs.\n *\n * Lifecycle hooks: standard Angular `ngOnInit` / `ngOnDestroy` work as usual.\n * `Record` is guaranteed to be set before the first change-detection pass.\n *\n * Optional `validate()` returns a synchronous validation result; the parent\n * `BaseFormComponent.Save()` path will surface it via the existing validation\n * pipeline when called. Panels that don't validate anything beyond what the\n * record itself does can leave this method off.\n */\n@Directive()\nexport abstract class BaseFormPanel<TRecord extends BaseEntity = BaseEntity> {\n /**\n * Slot-mounted hosts must not sit in the left-nav flex column — leftover\n * height targets `mj-collapsible-panel` as a direct child of\n * `.mj-forms-all-panels`. `display: contents` makes the inner panel that child.\n */\n @HostBinding('style.display')\n readonly HostDisplay = 'contents';\n\n /** The entity record being edited. Set by the slot host before view init. */\n @Input() Record!: TRecord;\n /** The host form component (use for EditMode, dirty notifications, etc). Set by the slot host. */\n @Input() FormComponent!: BaseFormComponent;\n /** Optional form context — same shape the collapsible-panel chrome expects. Set by the slot host. */\n @Input() FormContext?: FormContext;\n\n /**\n * Convenience getter for read-only / edit-mode rendering. Falls back to\n * `false` when the panel is shown outside a `BaseFormComponent` host (e.g.,\n * a dashboard quick-edit dialog reusing the same panel — see the\n * \"composable panel\" docs).\n */\n public get EditMode(): boolean {\n return this.FormComponent?.EditMode ?? false;\n }\n\n /**\n * Override to add per-panel validation that should block the parent form's\n * Save(). Return `{ Success: true, Errors: [] }` when valid, or include\n * `ValidationErrorInfo` entries to surface field-level errors. The default\n * implementation reports valid (panels that don't need extra validation\n * can leave this method off).\n */\n public Validate(): ValidationResult {\n // Inline construction — ValidationResult is a class in @memberjunction/core,\n // not a plain interface, so callers can construct via `new`.\n const result = new ValidationResult();\n result.Success = true;\n return result;\n }\n\n /** @deprecated Use {@link Validate}. */\n public validate(): ValidationResult {\n return this.Validate();\n }\n\n /**\n * Called after the parent form reloads the current record from the database.\n * Default is a no-op. Override to refresh panel-owned data that is not a\n * related-entity grid (those already subscribe to\n * {@link FormRecordRefreshCoordinator} themselves).\n */\n public OnRecordRefreshed(_record: TRecord): void {\n // Subclasses can override\n }\n\n /**\n * Registers a dynamic toolbar action item / button into the host form toolbar.\n */\n public RegisterToolbarItem(item: FormToolbarItemConfig): void {\n this.FormComponent?.RegisterToolbarItem(item);\n }\n\n /**\n * Unregisters a previously registered dynamic toolbar item by key.\n */\n public UnregisterToolbarItem(key: string): void {\n this.FormComponent?.UnregisterToolbarItem(key);\n }\n\n /**\n * Configures overrides for any toolbar item (standard built-in items like 'edit',\n * 'delete', 'favorite', 'history', etc., or custom items).\n */\n public ConfigureToolbarItem(key: FormToolbarItemKey, overrides: Partial<FormToolbarItemConfig>): void {\n this.FormComponent?.ConfigureToolbarItem(key, overrides);\n }\n\n /**\n * Dynamically hides a toolbar item by key.\n */\n public HideToolbarItem(key: FormToolbarItemKey): void {\n this.FormComponent?.HideToolbarItem(key);\n }\n\n /**\n * Dynamically shows a toolbar item by key.\n */\n public ShowToolbarItem(key: FormToolbarItemKey): void {\n this.FormComponent?.ShowToolbarItem(key);\n }\n\n /**\n * Dynamically disables a toolbar item by key, with an optional reason string for the tooltip.\n */\n public DisableToolbarItem(key: FormToolbarItemKey, reason?: string): void {\n this.FormComponent?.DisableToolbarItem(key, reason);\n }\n\n /**\n * Dynamically enables a toolbar item by key.\n */\n public EnableToolbarItem(key: FormToolbarItemKey): void {\n this.FormComponent?.EnableToolbarItem(key);\n }\n\n /**\n * Sets the numeric display order for a toolbar item.\n */\n public SetToolbarItemOrder(key: FormToolbarItemKey, order: number): void {\n this.FormComponent?.SetToolbarItemOrder(key, order);\n }\n}\n"]}
@@ -58,6 +58,18 @@ export declare function ResolveContributionKey(meta: FormPanelRegistrationMetada
58
58
  * appended so BillTo / ShipTo do not collide.
59
59
  */
60
60
  export declare function RelatedEntitySectionKey(relationship: FormContributionRelationship, displayInFormPeers: readonly FormContributionRelationship[]): string;
61
+ /**
62
+ * Builds a function that returns {@link RelatedEntitySectionKey}`(relationship, displayInFormPeers)`
63
+ * for any relationship, against the ONE peer set passed here. Build it once per peer set, then
64
+ * call it once per relationship. The relationship does not have to be in the peer set; it is keyed
65
+ * by how many peers share its related entity.
66
+ *
67
+ * Building counts each related entity once, so keying all n peers is O(n). Calling
68
+ * RelatedEntitySectionKey per peer is O(n²), which on an entity with ~150 DisplayInForm
69
+ * relationships (MJ: Users), resolved on every change-detection pass, pegged a CPU core.
70
+ * The returned function reflects the peers as they were when it was built.
71
+ */
72
+ export declare function CreateRelatedEntitySectionKeyResolver(displayInFormPeers: readonly FormContributionRelationship[]): (relationship: FormContributionRelationship) => string;
61
73
  export declare function RelationshipDisplayName(relationship: FormContributionRelationship): string;
62
74
  /**
63
75
  * Last-wins collapse by contributionKey (or derived related key).
@@ -1 +1 @@
1
- {"version":3,"file":"form-contribution.d.ts","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-contribution.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,6BAA6B,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEjF,0FAA0F;AAC1F,MAAM,WAAW,4BAA4B;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,4BAA4B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,6BAA6B,CAAC;CAC3C;AAED,MAAM,WAAW,6BAA6B;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACzD,iFAAiF;IACjF,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,aAAa,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACvD,sFAAsF;IACtF,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,mBAAmB,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,YAAY,CAAC;AAE/D,MAAM,WAAW,sBAAsB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,aAAa,C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GAAG,MAAM,CAI1F;AAyCD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,6BAA6B,CAAA;CAAE,EAClH,aAAa,EAAE,SAAS,CAAC,EAAE,GAC5B,CAAC,EAAE,CAWL;AAyDD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,GAAG,8BAA8B,CA2D7G;AAED,mFAAmF;AACnF,wBAAgB,6BAA6B,CACzC,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,SAAS,4BAA4B,EAAE,EACxD,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,aAAa,EAAE,SAAS,4BAA4B,EAAE,GACvD,MAAM,EAAE,CAwBV;AAED,6DAA6D;AAC7D,wBAAgB,yBAAyB,CACrC,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,SAAS,4BAA4B,EAAE,EACxD,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,aAAa,EAAE,SAAS,4BAA4B,EAAE,GACvD,MAAM,EAAE,CAEV"}
@@ -9,7 +9,7 @@
9
9
  * (`angular-codegen.ts` `camelCase` + related-entity sectionKey). If they drift,
10
10
  * hide-baked and skip-baked miss and the user sees a double grid.
11
11
  */
12
- import { UUIDsEqual } from '@memberjunction/global';
12
+ import { NormalizeUUID, UUIDsEqual } from '@memberjunction/global';
13
13
  /** Strip wrapping [] from a join field, matching CodeGen's tab-name helper. */
14
14
  export function StripJoinFieldBrackets(joinField) {
15
15
  return (joinField ?? '').trim().replace(/^\[/, '').replace(/\]$/, '');
@@ -47,12 +47,43 @@ export function ResolveContributionKey(meta) {
47
47
  * appended so BillTo / ShipTo do not collide.
48
48
  */
49
49
  export function RelatedEntitySectionKey(relationship, displayInFormPeers) {
50
- const sameEntity = displayInFormPeers.filter((peer) => UUIDsEqual(peer.RelatedEntityID, relationship.RelatedEntityID));
51
- if (sameEntity.length > 1) {
50
+ // Normalize the target once and stop at the second match. UUIDsEqual's `===` fast path
51
+ // misses on every peer that points elsewhere, so a filter over UUIDsEqual lowercases both
52
+ // sides of every comparison. To key many relationships against the same peers, use
53
+ // CreateRelatedEntitySectionKeyResolver instead.
54
+ const target = NormalizeUUID(relationship.RelatedEntityID);
55
+ let sameEntityCount = 0;
56
+ for (const peer of displayInFormPeers) {
57
+ if (NormalizeUUID(peer.RelatedEntityID) === target && ++sameEntityCount > 1)
58
+ break;
59
+ }
60
+ return relatedSectionKey(relationship, sameEntityCount > 1);
61
+ }
62
+ function relatedSectionKey(relationship, sharesRelatedEntity) {
63
+ if (sharesRelatedEntity) {
52
64
  return FormSectionCamelCase(`${relationship.RelatedEntity} ${StripJoinFieldBrackets(relationship.RelatedEntityJoinField)}`);
53
65
  }
54
66
  return FormSectionCamelCase(relationship.RelatedEntity);
55
67
  }
68
+ /**
69
+ * Builds a function that returns {@link RelatedEntitySectionKey}`(relationship, displayInFormPeers)`
70
+ * for any relationship, against the ONE peer set passed here. Build it once per peer set, then
71
+ * call it once per relationship. The relationship does not have to be in the peer set; it is keyed
72
+ * by how many peers share its related entity.
73
+ *
74
+ * Building counts each related entity once, so keying all n peers is O(n). Calling
75
+ * RelatedEntitySectionKey per peer is O(n²), which on an entity with ~150 DisplayInForm
76
+ * relationships (MJ: Users), resolved on every change-detection pass, pegged a CPU core.
77
+ * The returned function reflects the peers as they were when it was built.
78
+ */
79
+ export function CreateRelatedEntitySectionKeyResolver(displayInFormPeers) {
80
+ const countByEntityID = new Map();
81
+ for (const peer of displayInFormPeers) {
82
+ const id = NormalizeUUID(peer.RelatedEntityID);
83
+ countByEntityID.set(id, (countByEntityID.get(id) ?? 0) + 1);
84
+ }
85
+ return (relationship) => relatedSectionKey(relationship, (countByEntityID.get(NormalizeUUID(relationship.RelatedEntityID)) ?? 0) > 1);
86
+ }
56
87
  export function RelationshipDisplayName(relationship) {
57
88
  const named = relationship.DisplayName?.trim();
58
89
  const raw = named && named.length > 0 ? named : relationship.RelatedEntity;
@@ -113,7 +144,7 @@ function collapseRegistrations(registrations) {
113
144
  }
114
145
  return winners;
115
146
  }
116
- function stockWinner(relationship, peers) {
147
+ function stockWinner(relationship, sectionKey) {
117
148
  const join = StripJoinFieldBrackets(relationship.RelatedEntityJoinField);
118
149
  return {
119
150
  ContributionKey: RelatedContributionKey(relationship.RelatedEntity, join),
@@ -123,7 +154,7 @@ function stockWinner(relationship, peers) {
123
154
  Kind: 'stock-grid',
124
155
  RelatedEntity: relationship.RelatedEntity,
125
156
  RelatedJoinField: join,
126
- BakedSectionKey: RelatedEntitySectionKey(relationship, peers),
157
+ BakedSectionKey: sectionKey,
127
158
  DisplayName: RelationshipDisplayName(relationship),
128
159
  };
129
160
  }
@@ -159,6 +190,7 @@ export function ResolveFormContributions(input) {
159
190
  const peers = visibleRelationships(input.RelatedEntities, input.IsaChildEntityIDs);
160
191
  const collapsed = collapseRegistrations(applicableRegistrations(input.EntityName, input.Registrations));
161
192
  const baked = new Set(input.BakedSectionKeys);
193
+ const sectionKeyOf = CreateRelatedEntitySectionKeyResolver(peers);
162
194
  const claimedKeys = new Set();
163
195
  const registered = [];
164
196
  for (const [key, reg] of collapsed) {
@@ -173,7 +205,7 @@ export function ResolveFormContributions(input) {
173
205
  return StripJoinFieldBrackets(rel.RelatedEntityJoinField) === wantJoin;
174
206
  })
175
207
  : undefined;
176
- const sectionKey = peer ? RelatedEntitySectionKey(peer, peers) : '';
208
+ const sectionKey = peer ? sectionKeyOf(peer) : '';
177
209
  if (related) {
178
210
  claimedKeys.add(key);
179
211
  // A claim that omits the join field covers every FK to that entity.
@@ -190,7 +222,7 @@ export function ResolveFormContributions(input) {
190
222
  if (input.ShowRelatedEntities) {
191
223
  for (const rel of peers) {
192
224
  const key = RelatedContributionKey(rel.RelatedEntity, rel.RelatedEntityJoinField);
193
- const sectionKey = RelatedEntitySectionKey(rel, peers);
225
+ const sectionKey = sectionKeyOf(rel);
194
226
  if (claimedKeys.has(key)) {
195
227
  if (baked.has(sectionKey))
196
228
  hiddenBaked.push(sectionKey);
@@ -198,13 +230,13 @@ export function ResolveFormContributions(input) {
198
230
  }
199
231
  if (baked.has(sectionKey))
200
232
  continue;
201
- stock.push(stockWinner(rel, peers));
233
+ stock.push(stockWinner(rel, sectionKey));
202
234
  }
203
235
  }
204
236
  else {
205
237
  for (const rel of peers) {
206
238
  const key = RelatedContributionKey(rel.RelatedEntity, rel.RelatedEntityJoinField);
207
- const sectionKey = RelatedEntitySectionKey(rel, peers);
239
+ const sectionKey = sectionKeyOf(rel);
208
240
  if (claimedKeys.has(key) && baked.has(sectionKey))
209
241
  hiddenBaked.push(sectionKey);
210
242
  }
@@ -226,6 +258,7 @@ export function ContributionHiddenSectionKeys(entityName, relatedEntities, isaCh
226
258
  ShowRelatedEntities: true,
227
259
  });
228
260
  const peers = visibleRelationships(relatedEntities, isaChildEntityIDs);
261
+ const sectionKeyOf = CreateRelatedEntitySectionKeyResolver(peers);
229
262
  const keys = [];
230
263
  for (const winner of resolved.Winners) {
231
264
  if (winner.Kind !== 'registered')
@@ -242,7 +275,7 @@ export function ContributionHiddenSectionKeys(entityName, relatedEntities, isaCh
242
275
  return StripJoinFieldBrackets(rel.RelatedEntityJoinField) === winner.RelatedJoinField;
243
276
  });
244
277
  if (peer)
245
- keys.push(RelatedEntitySectionKey(peer, peers));
278
+ keys.push(sectionKeyOf(peer));
246
279
  }
247
280
  return keys;
248
281
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form-contribution.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-contribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAqDpD,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CAAC,SAAoC;IACvE,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CA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,MAAM,CAAC,aAAa;YAAE,SAAS;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5B,IAAI,GAAG,CAAC,aAAa,KAAK,MAAM,CAAC,aAAa;gBAAE,OAAO,KAAK,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,gBAAgB;gBAAE,OAAO,IAAI,CAAC;YAC1C,OAAO,sBAAsB,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,MAAM,CAAC,gBAAgB,CAAC;QAC1F,CAAC,CAAC,CAAC;QACH,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,yBAAyB,CACrC,UAAkB,EAClB,eAAwD,EACxD,iBAAoC,EACpC,aAAsD;IAEtD,OAAO,6BAA6B,CAAC,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;AACxG,CAAC","sourcesContent":["/**\n * Form contributions — pure resolve of what should appear on an entity form.\n *\n * A contribution is either a registered BaseFormPanel or the stock related-entity\n * grid. Related claims replace the stock/baked grid. No Angular, no ClassFactory\n * — the host queries registrations and feeds this.\n *\n * Section keys for related panels MUST match CodeGen's camelCase\n * (`angular-codegen.ts` `camelCase` + related-entity sectionKey). If they drift,\n * hide-baked and skip-baked miss and the user sees a double grid.\n */\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { FormPanelRegistrationMetadata, FormPanelSlot } from './base-form-panel';\n\n/** Minimum relationship shape the composer reads. Satisfied by EntityRelationshipInfo. */\nexport interface FormContributionRelationship {\n RelatedEntity: string;\n RelatedEntityID: string;\n RelatedEntityJoinField: string;\n DisplayInForm: boolean;\n DisplayName?: string | null;\n Sequence?: number | null;\n}\n\nexport interface FormContributionRegistration {\n Priority: number;\n Metadata: FormPanelRegistrationMetadata;\n}\n\nexport interface ResolveFormContributionsInput {\n EntityName: string;\n RelatedEntities: readonly FormContributionRelationship[];\n /** IS-A child entity IDs — CodeGen skips these (shown in the ISA side panel). */\n IsaChildEntityIDs: readonly string[];\n Registrations: readonly FormContributionRegistration[];\n /** SectionKeys already projected as Variant=\"related-entity\" in the form template. */\n BakedSectionKeys: readonly string[];\n ShowRelatedEntities: boolean;\n}\n\nexport type FormContributionKind = 'registered' | 'stock-grid';\n\nexport interface FormContributionWinner {\n ContributionKey: string;\n Slot: FormPanelSlot;\n SortKey: number;\n Priority: number;\n Kind: FormContributionKind;\n RelatedEntity?: string;\n RelatedJoinField?: string;\n /** Field/other section this registered winner asked to hide. */\n ReplacesSectionKey?: string;\n BakedSectionKey: string;\n DisplayName: string;\n}\n\nexport interface ResolveFormContributionsResult {\n Winners: FormContributionWinner[];\n /** CodeGen section keys to hide because a registered panel claimed them. */\n HiddenBakedSectionKeys: string[];\n /** Stock grids the host should mount (unclaimed and not already baked). */\n StockGrids: FormContributionWinner[];\n}\n\n/** Strip wrapping [] from a join field, matching CodeGen's tab-name helper. */\nexport function StripJoinFieldBrackets(joinField: string | null | undefined): string {\n return (joinField ?? '').trim().replace(/^\\[/, '').replace(/\\]$/, '');\n}\n\n/**\n * camelCase + identifier sanitize. Byte-compatible with\n * `CodeGenLib` `angular-codegen.ts` `camelCase` — do not \"improve\".\n */\nexport function FormSectionCamelCase(str: string): string {\n const sanitized = str.replace(/[^a-zA-Z0-9\\s]/g, ' ');\n let result = sanitized\n .replace(/\\s(.)/g, (_match, char: string) => char.toUpperCase())\n .replace(/\\s/g, '')\n .replace(/^(.)/, (_match, char: string) => char.toLowerCase());\n if (/^\\d/.test(result)) {\n result = '_' + result;\n }\n return result.length === 0 ? 'section' : result;\n}\n\nexport function RelatedContributionKey(relatedEntity: string, joinField?: string | null): string {\n return `related:${relatedEntity.trim()}:${StripJoinFieldBrackets(joinField)}`;\n}\n\nexport function ResolveContributionKey(meta: FormPanelRegistrationMetadata): string {\n if (meta.contributionKey && meta.contributionKey.trim().length > 0) {\n return meta.contributionKey.trim();\n }\n if (meta.relatedEntity && meta.relatedEntity.trim().length > 0) {\n return RelatedContributionKey(meta.relatedEntity, meta.relatedJoinField);\n }\n return '';\n}\n\n/**\n * SectionKey CodeGen emits for a related-entity panel. When more than one\n * DisplayInForm relationship points at the same entity, the join field is\n * appended so BillTo / ShipTo do not collide.\n */\nexport function RelatedEntitySectionKey(\n relationship: FormContributionRelationship,\n displayInFormPeers: readonly FormContributionRelationship[],\n): string {\n const sameEntity = displayInFormPeers.filter((peer) =>\n UUIDsEqual(peer.RelatedEntityID, relationship.RelatedEntityID),\n );\n if (sameEntity.length > 1) {\n return FormSectionCamelCase(\n `${relationship.RelatedEntity} ${StripJoinFieldBrackets(relationship.RelatedEntityJoinField)}`,\n );\n }\n return FormSectionCamelCase(relationship.RelatedEntity);\n}\n\nexport function RelationshipDisplayName(relationship: FormContributionRelationship): string {\n const named = relationship.DisplayName?.trim();\n const raw = named && named.length > 0 ? named : relationship.RelatedEntity;\n return raw.replace(/^[A-Za-z][A-Za-z0-9_]*:\\s+/, '').trim() || raw;\n}\n\nfunction isIsaChild(relationship: FormContributionRelationship, isaChildIds: readonly string[]): boolean {\n return isaChildIds.some((id) => UUIDsEqual(id, relationship.RelatedEntityID));\n}\n\nfunction visibleRelationships(\n related: readonly FormContributionRelationship[],\n isaChildIds: readonly string[],\n): FormContributionRelationship[] {\n const visible = related.filter((rel) => rel.DisplayInForm && !isIsaChild(rel, isaChildIds));\n return [...visible].sort((a, b) => {\n const aSeq = a.Sequence ?? 999999;\n const bSeq = b.Sequence ?? 999999;\n if (aSeq !== bSeq) return aSeq - bSeq;\n return a.RelatedEntity.localeCompare(b.RelatedEntity);\n });\n}\n\nfunction entityMatches(registeredEntity: string, formEntity: string): boolean {\n return registeredEntity === '*' || registeredEntity === formEntity;\n}\n\nfunction applicableRegistrations(\n entityName: string,\n registrations: readonly FormContributionRegistration[],\n): FormContributionRegistration[] {\n return registrations.filter((reg) => {\n const entity = reg.Metadata.entity;\n if (!entity || !entityMatches(entity, entityName)) return false;\n // A related claim on entity:'*' would hide that grid on every form.\n // Claims must name the form entity.\n // Related / field-section claims on entity:'*' would hide panels on every\n // form. Those claims must name the form entity.\n if ((reg.Metadata.relatedEntity || reg.Metadata.replacesSectionKey) && entity === '*') {\n return false;\n }\n return true;\n });\n}\n\n/**\n * Last-wins collapse by contributionKey (or derived related key).\n * Highest Priority keeps the slot. Registrations without a key never collapse.\n */\nexport function CollapseFormPanelRegistrations<T extends { Priority: number; Metadata: FormPanelRegistrationMetadata }>(\n registrations: readonly T[],\n): T[] {\n const winners = new Map<string, T>();\n let uniqueIndex = 0;\n for (const reg of registrations) {\n const key = ResolveContributionKey(reg.Metadata) || `__unique:${uniqueIndex++}`;\n const incumbent = winners.get(key);\n if (!incumbent || reg.Priority > incumbent.Priority) {\n winners.set(key, reg);\n }\n }\n return [...winners.values()];\n}\n\nfunction collapseRegistrations(\n registrations: readonly FormContributionRegistration[],\n): Map<string, FormContributionRegistration> {\n const winners = new Map<string, FormContributionRegistration>();\n for (const reg of CollapseFormPanelRegistrations(registrations)) {\n const key = ResolveContributionKey(reg.Metadata) || `${reg.Metadata.entity}:${reg.Metadata.slot}:${reg.Priority}`;\n winners.set(key, reg);\n }\n return winners;\n}\n\nfunction stockWinner(\n relationship: FormContributionRelationship,\n peers: readonly FormContributionRelationship[],\n): FormContributionWinner {\n const join = StripJoinFieldBrackets(relationship.RelatedEntityJoinField);\n return {\n ContributionKey: RelatedContributionKey(relationship.RelatedEntity, join),\n Slot: 'after-related',\n SortKey: -(relationship.Sequence ?? 0),\n Priority: 0,\n Kind: 'stock-grid',\n RelatedEntity: relationship.RelatedEntity,\n RelatedJoinField: join,\n BakedSectionKey: RelatedEntitySectionKey(relationship, peers),\n DisplayName: RelationshipDisplayName(relationship),\n };\n}\n\nfunction registeredWinner(\n key: string,\n reg: FormContributionRegistration,\n sectionKey: string,\n displayName: string,\n): FormContributionWinner {\n const meta = reg.Metadata;\n return {\n ContributionKey: key,\n Slot: meta.slot,\n SortKey: meta.sortKey ?? 0,\n Priority: reg.Priority,\n Kind: 'registered',\n RelatedEntity: meta.relatedEntity,\n RelatedJoinField: meta.relatedJoinField ? StripJoinFieldBrackets(meta.relatedJoinField) : undefined,\n ReplacesSectionKey: meta.replacesSectionKey?.trim() || undefined,\n BakedSectionKey: sectionKey,\n DisplayName: displayName,\n };\n}\n\nfunction sortWinners(winners: FormContributionWinner[]): FormContributionWinner[] {\n return [...winners].sort((a, b) => {\n if (a.SortKey !== b.SortKey) return b.SortKey - a.SortKey;\n if (a.Priority !== b.Priority) return b.Priority - a.Priority;\n return a.ContributionKey.localeCompare(b.ContributionKey);\n });\n}\n\n/**\n * Resolve what belongs on the form. Stock grids are only those the template\n * did not already bake and that no panel claimed.\n */\nexport function ResolveFormContributions(input: ResolveFormContributionsInput): ResolveFormContributionsResult {\n const peers = visibleRelationships(input.RelatedEntities, input.IsaChildEntityIDs);\n const collapsed = collapseRegistrations(applicableRegistrations(input.EntityName, input.Registrations));\n const baked = new Set(input.BakedSectionKeys);\n\n const claimedKeys = new Set<string>();\n const registered: FormContributionWinner[] = [];\n for (const [key, reg] of collapsed) {\n const related = reg.Metadata.relatedEntity?.trim();\n const peer = related\n ? peers.find((rel) => {\n if (rel.RelatedEntity !== related) return false;\n const wantJoin = StripJoinFieldBrackets(reg.Metadata.relatedJoinField);\n if (!wantJoin) return true;\n return StripJoinFieldBrackets(rel.RelatedEntityJoinField) === wantJoin;\n })\n : undefined;\n const sectionKey = peer ? RelatedEntitySectionKey(peer, peers) : '';\n if (related) {\n claimedKeys.add(key);\n // A claim that omits the join field covers every FK to that entity.\n if (!StripJoinFieldBrackets(reg.Metadata.relatedJoinField)) {\n for (const match of peers.filter((rel) => rel.RelatedEntity === related)) {\n claimedKeys.add(RelatedContributionKey(match.RelatedEntity, match.RelatedEntityJoinField));\n }\n }\n }\n registered.push(\n registeredWinner(key, reg, sectionKey, peer ? RelationshipDisplayName(peer) : related ?? key),\n );\n }\n\n const hiddenBaked: string[] = [];\n const stock: FormContributionWinner[] = [];\n if (input.ShowRelatedEntities) {\n for (const rel of peers) {\n const key = RelatedContributionKey(rel.RelatedEntity, rel.RelatedEntityJoinField);\n const sectionKey = RelatedEntitySectionKey(rel, peers);\n if (claimedKeys.has(key)) {\n if (baked.has(sectionKey)) hiddenBaked.push(sectionKey);\n continue;\n }\n if (baked.has(sectionKey)) continue;\n stock.push(stockWinner(rel, peers));\n }\n } else {\n for (const rel of peers) {\n const key = RelatedContributionKey(rel.RelatedEntity, rel.RelatedEntityJoinField);\n const sectionKey = RelatedEntitySectionKey(rel, peers);\n if (claimedKeys.has(key) && baked.has(sectionKey)) hiddenBaked.push(sectionKey);\n }\n }\n\n return {\n Winners: sortWinners([...registered, ...stock]),\n HiddenBakedSectionKeys: hiddenBaked,\n StockGrids: sortWinners(stock),\n };\n}\n\n/** Section keys a form should hide because a winning contribution claimed them. */\nexport function ContributionHiddenSectionKeys(\n entityName: string,\n relatedEntities: readonly FormContributionRelationship[],\n isaChildEntityIDs: readonly string[],\n registrations: readonly FormContributionRegistration[],\n): string[] {\n const resolved = ResolveFormContributions({\n EntityName: entityName,\n RelatedEntities: relatedEntities,\n IsaChildEntityIDs: isaChildEntityIDs,\n Registrations: registrations,\n BakedSectionKeys: [],\n ShowRelatedEntities: true,\n });\n const peers = visibleRelationships(relatedEntities, isaChildEntityIDs);\n const keys: string[] = [];\n for (const winner of resolved.Winners) {\n if (winner.Kind !== 'registered') continue;\n if (winner.ReplacesSectionKey) keys.push(winner.ReplacesSectionKey);\n if (!winner.RelatedEntity) continue;\n const peer = peers.find((rel) => {\n if (rel.RelatedEntity !== winner.RelatedEntity) return false;\n if (!winner.RelatedJoinField) return true;\n return StripJoinFieldBrackets(rel.RelatedEntityJoinField) === winner.RelatedJoinField;\n });\n if (peer) keys.push(RelatedEntitySectionKey(peer, peers));\n }\n return keys;\n}\n\n/** @deprecated Use {@link ContributionHiddenSectionKeys}. */\nexport function ClaimedRelatedSectionKeys(\n entityName: string,\n relatedEntities: readonly FormContributionRelationship[],\n isaChildEntityIDs: readonly string[],\n registrations: readonly FormContributionRegistration[],\n): string[] {\n return ContributionHiddenSectionKeys(entityName, relatedEntities, isaChildEntityIDs, registrations);\n}\n"]}
1
+ {"version":3,"file":"form-contribution.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-contribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAqDnE,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CAAC,SAAoC;IACvE,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC5C,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACtD,IAAI,MAAM,GAAG,SAAS;SACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;SAC/D,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACnE,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,M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MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY;YAAE,SAAS;QAC3C,IAAI,MAAM,CAAC,kBAAkB;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,CAAC,aAAa;YAAE,SAAS;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5B,IAAI,GAAG,CAAC,aAAa,KAAK,MAAM,CAAC,aAAa;gBAAE,OAAO,KAAK,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,gBAAgB;gBAAE,OAAO,IAAI,CAAC;YAC1C,OAAO,sBAAsB,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,MAAM,CAAC,gBAAgB,CAAC;QAC1F,CAAC,CAAC,CAAC;QACH,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,yBAAyB,CACrC,UAAkB,EAClB,eAAwD,EACxD,iBAAoC,EACpC,aAAsD;IAEtD,OAAO,6BAA6B,CAAC,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;AACxG,CAAC","sourcesContent":["/**\n * Form contributions — pure resolve of what should appear on an entity form.\n *\n * A contribution is either a registered BaseFormPanel or the stock related-entity\n * grid. Related claims replace the stock/baked grid. No Angular, no ClassFactory\n * — the host queries registrations and feeds this.\n *\n * Section keys for related panels MUST match CodeGen's camelCase\n * (`angular-codegen.ts` `camelCase` + related-entity sectionKey). If they drift,\n * hide-baked and skip-baked miss and the user sees a double grid.\n */\nimport { NormalizeUUID, UUIDsEqual } from '@memberjunction/global';\nimport { FormPanelRegistrationMetadata, FormPanelSlot } from './base-form-panel';\n\n/** Minimum relationship shape the composer reads. Satisfied by EntityRelationshipInfo. */\nexport interface FormContributionRelationship {\n RelatedEntity: string;\n RelatedEntityID: string;\n RelatedEntityJoinField: string;\n DisplayInForm: boolean;\n DisplayName?: string | null;\n Sequence?: number | null;\n}\n\nexport interface FormContributionRegistration {\n Priority: number;\n Metadata: FormPanelRegistrationMetadata;\n}\n\nexport interface ResolveFormContributionsInput {\n EntityName: string;\n RelatedEntities: readonly FormContributionRelationship[];\n /** IS-A child entity IDs — CodeGen skips these (shown in the ISA side panel). */\n IsaChildEntityIDs: readonly string[];\n Registrations: readonly FormContributionRegistration[];\n /** SectionKeys already projected as Variant=\"related-entity\" in the form template. */\n BakedSectionKeys: readonly string[];\n ShowRelatedEntities: boolean;\n}\n\nexport type FormContributionKind = 'registered' | 'stock-grid';\n\nexport interface FormContributionWinner {\n ContributionKey: string;\n Slot: FormPanelSlot;\n SortKey: number;\n Priority: number;\n Kind: FormContributionKind;\n RelatedEntity?: string;\n RelatedJoinField?: string;\n /** Field/other section this registered winner asked to hide. */\n ReplacesSectionKey?: string;\n BakedSectionKey: string;\n DisplayName: string;\n}\n\nexport interface ResolveFormContributionsResult {\n Winners: FormContributionWinner[];\n /** CodeGen section keys to hide because a registered panel claimed them. */\n HiddenBakedSectionKeys: string[];\n /** Stock grids the host should mount (unclaimed and not already baked). */\n StockGrids: FormContributionWinner[];\n}\n\n/** Strip wrapping [] from a join field, matching CodeGen's tab-name helper. */\nexport function StripJoinFieldBrackets(joinField: string | null | undefined): string {\n return (joinField ?? '').trim().replace(/^\\[/, '').replace(/\\]$/, '');\n}\n\n/**\n * camelCase + identifier sanitize. Byte-compatible with\n * `CodeGenLib` `angular-codegen.ts` `camelCase` — do not \"improve\".\n */\nexport function FormSectionCamelCase(str: string): string {\n const sanitized = str.replace(/[^a-zA-Z0-9\\s]/g, ' ');\n let result = sanitized\n .replace(/\\s(.)/g, (_match, char: string) => char.toUpperCase())\n .replace(/\\s/g, '')\n .replace(/^(.)/, (_match, char: string) => char.toLowerCase());\n if (/^\\d/.test(result)) {\n result = '_' + result;\n }\n return result.length === 0 ? 'section' : result;\n}\n\nexport function RelatedContributionKey(relatedEntity: string, joinField?: string | null): string {\n return `related:${relatedEntity.trim()}:${StripJoinFieldBrackets(joinField)}`;\n}\n\nexport function ResolveContributionKey(meta: FormPanelRegistrationMetadata): string {\n if (meta.contributionKey && meta.contributionKey.trim().length > 0) {\n return meta.contributionKey.trim();\n }\n if (meta.relatedEntity && meta.relatedEntity.trim().length > 0) {\n return RelatedContributionKey(meta.relatedEntity, meta.relatedJoinField);\n }\n return '';\n}\n\n/**\n * SectionKey CodeGen emits for a related-entity panel. When more than one\n * DisplayInForm relationship points at the same entity, the join field is\n * appended so BillTo / ShipTo do not collide.\n */\nexport function RelatedEntitySectionKey(\n relationship: FormContributionRelationship,\n displayInFormPeers: readonly FormContributionRelationship[],\n): string {\n // Normalize the target once and stop at the second match. UUIDsEqual's `===` fast path\n // misses on every peer that points elsewhere, so a filter over UUIDsEqual lowercases both\n // sides of every comparison. To key many relationships against the same peers, use\n // CreateRelatedEntitySectionKeyResolver instead.\n const target = NormalizeUUID(relationship.RelatedEntityID);\n let sameEntityCount = 0;\n for (const peer of displayInFormPeers) {\n if (NormalizeUUID(peer.RelatedEntityID) === target && ++sameEntityCount > 1) break;\n }\n return relatedSectionKey(relationship, sameEntityCount > 1);\n}\n\nfunction relatedSectionKey(relationship: FormContributionRelationship, sharesRelatedEntity: boolean): string {\n if (sharesRelatedEntity) {\n return FormSectionCamelCase(\n `${relationship.RelatedEntity} ${StripJoinFieldBrackets(relationship.RelatedEntityJoinField)}`,\n );\n }\n return FormSectionCamelCase(relationship.RelatedEntity);\n}\n\n/**\n * Builds a function that returns {@link RelatedEntitySectionKey}`(relationship, displayInFormPeers)`\n * for any relationship, against the ONE peer set passed here. Build it once per peer set, then\n * call it once per relationship. The relationship does not have to be in the peer set; it is keyed\n * by how many peers share its related entity.\n *\n * Building counts each related entity once, so keying all n peers is O(n). Calling\n * RelatedEntitySectionKey per peer is O(n²), which on an entity with ~150 DisplayInForm\n * relationships (MJ: Users), resolved on every change-detection pass, pegged a CPU core.\n * The returned function reflects the peers as they were when it was built.\n */\nexport function CreateRelatedEntitySectionKeyResolver(\n displayInFormPeers: readonly FormContributionRelationship[],\n): (relationship: FormContributionRelationship) => string {\n const countByEntityID = new Map<string, number>();\n for (const peer of displayInFormPeers) {\n const id = NormalizeUUID(peer.RelatedEntityID);\n countByEntityID.set(id, (countByEntityID.get(id) ?? 0) + 1);\n }\n return (relationship) =>\n relatedSectionKey(relationship, (countByEntityID.get(NormalizeUUID(relationship.RelatedEntityID)) ?? 0) > 1);\n}\n\nexport function RelationshipDisplayName(relationship: FormContributionRelationship): string {\n const named = relationship.DisplayName?.trim();\n const raw = named && named.length > 0 ? named : relationship.RelatedEntity;\n return raw.replace(/^[A-Za-z][A-Za-z0-9_]*:\\s+/, '').trim() || raw;\n}\n\nfunction isIsaChild(relationship: FormContributionRelationship, isaChildIds: readonly string[]): boolean {\n return isaChildIds.some((id) => UUIDsEqual(id, relationship.RelatedEntityID));\n}\n\nfunction visibleRelationships(\n related: readonly FormContributionRelationship[],\n isaChildIds: readonly string[],\n): FormContributionRelationship[] {\n const visible = related.filter((rel) => rel.DisplayInForm && !isIsaChild(rel, isaChildIds));\n return [...visible].sort((a, b) => {\n const aSeq = a.Sequence ?? 999999;\n const bSeq = b.Sequence ?? 999999;\n if (aSeq !== bSeq) return aSeq - bSeq;\n return a.RelatedEntity.localeCompare(b.RelatedEntity);\n });\n}\n\nfunction entityMatches(registeredEntity: string, formEntity: string): boolean {\n return registeredEntity === '*' || registeredEntity === formEntity;\n}\n\nfunction applicableRegistrations(\n entityName: string,\n registrations: readonly FormContributionRegistration[],\n): FormContributionRegistration[] {\n return registrations.filter((reg) => {\n const entity = reg.Metadata.entity;\n if (!entity || !entityMatches(entity, entityName)) return false;\n // A related claim on entity:'*' would hide that grid on every form.\n // Claims must name the form entity.\n // Related / field-section claims on entity:'*' would hide panels on every\n // form. Those claims must name the form entity.\n if ((reg.Metadata.relatedEntity || reg.Metadata.replacesSectionKey) && entity === '*') {\n return false;\n }\n return true;\n });\n}\n\n/**\n * Last-wins collapse by contributionKey (or derived related key).\n * Highest Priority keeps the slot. Registrations without a key never collapse.\n */\nexport function CollapseFormPanelRegistrations<T extends { Priority: number; Metadata: FormPanelRegistrationMetadata }>(\n registrations: readonly T[],\n): T[] {\n const winners = new Map<string, T>();\n let uniqueIndex = 0;\n for (const reg of registrations) {\n const key = ResolveContributionKey(reg.Metadata) || `__unique:${uniqueIndex++}`;\n const incumbent = winners.get(key);\n if (!incumbent || reg.Priority > incumbent.Priority) {\n winners.set(key, reg);\n }\n }\n return [...winners.values()];\n}\n\nfunction collapseRegistrations(\n registrations: readonly FormContributionRegistration[],\n): Map<string, FormContributionRegistration> {\n const winners = new Map<string, FormContributionRegistration>();\n for (const reg of CollapseFormPanelRegistrations(registrations)) {\n const key = ResolveContributionKey(reg.Metadata) || `${reg.Metadata.entity}:${reg.Metadata.slot}:${reg.Priority}`;\n winners.set(key, reg);\n }\n return winners;\n}\n\nfunction stockWinner(relationship: FormContributionRelationship, sectionKey: string): FormContributionWinner {\n const join = StripJoinFieldBrackets(relationship.RelatedEntityJoinField);\n return {\n ContributionKey: RelatedContributionKey(relationship.RelatedEntity, join),\n Slot: 'after-related',\n SortKey: -(relationship.Sequence ?? 0),\n Priority: 0,\n Kind: 'stock-grid',\n RelatedEntity: relationship.RelatedEntity,\n RelatedJoinField: join,\n BakedSectionKey: sectionKey,\n DisplayName: RelationshipDisplayName(relationship),\n };\n}\n\nfunction registeredWinner(\n key: string,\n reg: FormContributionRegistration,\n sectionKey: string,\n displayName: string,\n): FormContributionWinner {\n const meta = reg.Metadata;\n return {\n ContributionKey: key,\n Slot: meta.slot,\n SortKey: meta.sortKey ?? 0,\n Priority: reg.Priority,\n Kind: 'registered',\n RelatedEntity: meta.relatedEntity,\n RelatedJoinField: meta.relatedJoinField ? StripJoinFieldBrackets(meta.relatedJoinField) : undefined,\n ReplacesSectionKey: meta.replacesSectionKey?.trim() || undefined,\n BakedSectionKey: sectionKey,\n DisplayName: displayName,\n };\n}\n\nfunction sortWinners(winners: FormContributionWinner[]): FormContributionWinner[] {\n return [...winners].sort((a, b) => {\n if (a.SortKey !== b.SortKey) return b.SortKey - a.SortKey;\n if (a.Priority !== b.Priority) return b.Priority - a.Priority;\n return a.ContributionKey.localeCompare(b.ContributionKey);\n });\n}\n\n/**\n * Resolve what belongs on the form. Stock grids are only those the template\n * did not already bake and that no panel claimed.\n */\nexport function ResolveFormContributions(input: ResolveFormContributionsInput): ResolveFormContributionsResult {\n const peers = visibleRelationships(input.RelatedEntities, input.IsaChildEntityIDs);\n const collapsed = collapseRegistrations(applicableRegistrations(input.EntityName, input.Registrations));\n const baked = new Set(input.BakedSectionKeys);\n const sectionKeyOf = CreateRelatedEntitySectionKeyResolver(peers);\n\n const claimedKeys = new Set<string>();\n const registered: FormContributionWinner[] = [];\n for (const [key, reg] of collapsed) {\n const related = reg.Metadata.relatedEntity?.trim();\n const peer = related\n ? peers.find((rel) => {\n if (rel.RelatedEntity !== related) return false;\n const wantJoin = StripJoinFieldBrackets(reg.Metadata.relatedJoinField);\n if (!wantJoin) return true;\n return StripJoinFieldBrackets(rel.RelatedEntityJoinField) === wantJoin;\n })\n : undefined;\n const sectionKey = peer ? sectionKeyOf(peer) : '';\n if (related) {\n claimedKeys.add(key);\n // A claim that omits the join field covers every FK to that entity.\n if (!StripJoinFieldBrackets(reg.Metadata.relatedJoinField)) {\n for (const match of peers.filter((rel) => rel.RelatedEntity === related)) {\n claimedKeys.add(RelatedContributionKey(match.RelatedEntity, match.RelatedEntityJoinField));\n }\n }\n }\n registered.push(\n registeredWinner(key, reg, sectionKey, peer ? RelationshipDisplayName(peer) : related ?? key),\n );\n }\n\n const hiddenBaked: string[] = [];\n const stock: FormContributionWinner[] = [];\n if (input.ShowRelatedEntities) {\n for (const rel of peers) {\n const key = RelatedContributionKey(rel.RelatedEntity, rel.RelatedEntityJoinField);\n const sectionKey = sectionKeyOf(rel);\n if (claimedKeys.has(key)) {\n if (baked.has(sectionKey)) hiddenBaked.push(sectionKey);\n continue;\n }\n if (baked.has(sectionKey)) continue;\n stock.push(stockWinner(rel, sectionKey));\n }\n } else {\n for (const rel of peers) {\n const key = RelatedContributionKey(rel.RelatedEntity, rel.RelatedEntityJoinField);\n const sectionKey = sectionKeyOf(rel);\n if (claimedKeys.has(key) && baked.has(sectionKey)) hiddenBaked.push(sectionKey);\n }\n }\n\n return {\n Winners: sortWinners([...registered, ...stock]),\n HiddenBakedSectionKeys: hiddenBaked,\n StockGrids: sortWinners(stock),\n };\n}\n\n/** Section keys a form should hide because a winning contribution claimed them. */\nexport function ContributionHiddenSectionKeys(\n entityName: string,\n relatedEntities: readonly FormContributionRelationship[],\n isaChildEntityIDs: readonly string[],\n registrations: readonly FormContributionRegistration[],\n): string[] {\n const resolved = ResolveFormContributions({\n EntityName: entityName,\n RelatedEntities: relatedEntities,\n IsaChildEntityIDs: isaChildEntityIDs,\n Registrations: registrations,\n BakedSectionKeys: [],\n ShowRelatedEntities: true,\n });\n const peers = visibleRelationships(relatedEntities, isaChildEntityIDs);\n const sectionKeyOf = CreateRelatedEntitySectionKeyResolver(peers);\n const keys: string[] = [];\n for (const winner of resolved.Winners) {\n if (winner.Kind !== 'registered') continue;\n if (winner.ReplacesSectionKey) keys.push(winner.ReplacesSectionKey);\n if (!winner.RelatedEntity) continue;\n const peer = peers.find((rel) => {\n if (rel.RelatedEntity !== winner.RelatedEntity) return false;\n if (!winner.RelatedJoinField) return true;\n return StripJoinFieldBrackets(rel.RelatedEntityJoinField) === winner.RelatedJoinField;\n });\n if (peer) keys.push(sectionKeyOf(peer));\n }\n return keys;\n}\n\n/** @deprecated Use {@link ContributionHiddenSectionKeys}. */\nexport function ClaimedRelatedSectionKeys(\n entityName: string,\n relatedEntities: readonly FormContributionRelationship[],\n isaChildEntityIDs: readonly string[],\n registrations: readonly FormContributionRegistration[],\n): string[] {\n return ContributionHiddenSectionKeys(entityName, relatedEntities, isaChildEntityIDs, registrations);\n}\n"]}
@@ -29,9 +29,15 @@ export declare class FormSlotCoordinator {
29
29
  * caused by a future refactor surfaces loudly instead of freezing. */
30
30
  private emitDepth;
31
31
  /** Slot host calls this on init. Idempotent — safe if invoked twice. */
32
+ RegisterSlot(slot: FormPanelSlot): void;
33
+ /** @deprecated Use {@link RegisterSlot}. */
32
34
  registerSlot(slot: FormPanelSlot): void;
33
35
  /** Slot host calls this on destroy. */
36
+ DeregisterSlot(slot: FormPanelSlot): void;
37
+ /** @deprecated Use {@link DeregisterSlot}. */
34
38
  deregisterSlot(slot: FormPanelSlot): void;
39
+ HasSlot(slot: FormPanelSlot): boolean;
40
+ /** @deprecated Use {@link HasSlot}. */
35
41
  hasSlot(slot: FormPanelSlot): boolean;
36
42
  /**
37
43
  * Resolve a preferred slot to the slot that should ACTUALLY render the
@@ -42,8 +48,12 @@ export declare class FormSlotCoordinator {
42
48
  * present — the container guarantees `after-everything` exists, so this
43
49
  * should never happen in practice.
44
50
  */
51
+ ResolveSlot(preferred: FormPanelSlot): FormPanelSlot | null;
52
+ /** @deprecated Use {@link ResolveSlot}. */
45
53
  resolveSlot(preferred: FormPanelSlot): FormPanelSlot | null;
46
54
  /** RxJS stream that fires whenever a slot registers or deregisters. */
55
+ get Changes(): import("rxjs").Observable<void>;
56
+ /** @deprecated Use {@link Changes}. */
47
57
  get changes(): import("rxjs").Observable<void>;
48
58
  /**
49
59
  * Emit with re-entrancy detection. If we're already in the middle of an
@@ -1 +1 @@
1
- {"version":3,"file":"form-slot-coordinator.service.d.ts","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-slot-coordinator.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,EAM1C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,qBACa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAChD;2EACuE;IACvE,OAAO,CAAC,SAAS,CAAK;IAEtB,wEAAwE;IACjE,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAO9C,uCAAuC;IAChC,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAOzC,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAI5C;;;;;;;;OAQG;IACI,WAAW,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI;IAYlE,uEAAuE;IACvE,IAAW,OAAO,oCAEjB;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAQ;yCA1DP,mBAAmB;6CAAnB,mBAAmB;CAsE/B"}
1
+ {"version":3,"file":"form-slot-coordinator.service.d.ts","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-slot-coordinator.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,EAM1C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,qBACa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAChD;2EACuE;IACvE,OAAO,CAAC,SAAS,CAAK;IAEtB,wEAAwE;IACjE,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAO9C,4CAA4C;IACrC,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAI9C,uCAAuC;IAChC,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAOhD,8CAA8C;IACvC,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAIzC,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAI5C,uCAAuC;IAChC,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAI5C;;;;;;;;OAQG;IACI,WAAW,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI;IAYlE,2CAA2C;IACpC,WAAW,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI;IAIlE,uEAAuE;IACvE,IAAW,OAAO,oCAEjB;IAED,uCAAuC;IACvC,IAAW,OAAO,oCAEjB;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAQ;yCAnFP,mBAAmB;6CAAnB,mBAAmB;CA+F/B"}
@@ -36,22 +36,34 @@ export class FormSlotCoordinator {
36
36
  * caused by a future refactor surfaces loudly instead of freezing. */
37
37
  emitDepth = 0;
38
38
  /** Slot host calls this on init. Idempotent — safe if invoked twice. */
39
- registerSlot(slot) {
39
+ RegisterSlot(slot) {
40
40
  if (!this.presentSlots.has(slot)) {
41
41
  this.presentSlots.add(slot);
42
42
  this.safeEmit('registerSlot');
43
43
  }
44
44
  }
45
+ /** @deprecated Use {@link RegisterSlot}. */
46
+ registerSlot(slot) {
47
+ return this.RegisterSlot(slot);
48
+ }
45
49
  /** Slot host calls this on destroy. */
46
- deregisterSlot(slot) {
50
+ DeregisterSlot(slot) {
47
51
  if (this.presentSlots.has(slot)) {
48
52
  this.presentSlots.delete(slot);
49
53
  this.safeEmit('deregisterSlot');
50
54
  }
51
55
  }
52
- hasSlot(slot) {
56
+ /** @deprecated Use {@link DeregisterSlot}. */
57
+ deregisterSlot(slot) {
58
+ return this.DeregisterSlot(slot);
59
+ }
60
+ HasSlot(slot) {
53
61
  return this.presentSlots.has(slot);
54
62
  }
63
+ /** @deprecated Use {@link HasSlot}. */
64
+ hasSlot(slot) {
65
+ return this.HasSlot(slot);
66
+ }
55
67
  /**
56
68
  * Resolve a preferred slot to the slot that should ACTUALLY render the
57
69
  * panel. Returns the preferred slot if it's present; otherwise walks
@@ -61,7 +73,7 @@ export class FormSlotCoordinator {
61
73
  * present — the container guarantees `after-everything` exists, so this
62
74
  * should never happen in practice.
63
75
  */
64
- resolveSlot(preferred) {
76
+ ResolveSlot(preferred) {
65
77
  const startIdx = FORM_SLOT_CHAIN.indexOf(preferred);
66
78
  if (startIdx === -1)
67
79
  return null;
@@ -73,10 +85,18 @@ export class FormSlotCoordinator {
73
85
  }
74
86
  return null;
75
87
  }
88
+ /** @deprecated Use {@link ResolveSlot}. */
89
+ resolveSlot(preferred) {
90
+ return this.ResolveSlot(preferred);
91
+ }
76
92
  /** RxJS stream that fires whenever a slot registers or deregisters. */
77
- get changes() {
93
+ get Changes() {
78
94
  return this.changes$.asObservable();
79
95
  }
96
+ /** @deprecated Use {@link Changes}. */
97
+ get changes() {
98
+ return this.Changes;
99
+ }
80
100
  /**
81
101
  * Emit with re-entrancy detection. If we're already in the middle of an
82
102
  * emit (i.e., a subscriber triggered another emit), log loudly so the loop
@@ -1 +1 @@
1
- {"version":3,"file":"form-slot-coordinator.service.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-slot-coordinator.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;;AAG/B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC5C,UAAU;IACV,eAAe;IACf,cAAc;IACd,eAAe;IACf,kBAAkB;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,mBAAmB;IACX,YAAY,GAAG,IAAI,GAAG,EAAiB,CAAC;IACxC,QAAQ,GAAG,IAAI,OAAO,EAAQ,CAAC;IAChD;2EACuE;IAC/D,SAAS,GAAG,CAAC,CAAC;IAEtB,wEAAwE;IACjE,YAAY,CAAC,IAAmB;QACnC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC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,kCAAkC,CAAC,CAAC;YAClI,OAAO;QACX,CAAC;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACL,CAAC;6GArEQ,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB;;iFAAnB,mBAAmB;cAD/B,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { FormPanelSlot } from './base-form-panel';\n\n/**\n * Document-order chain used by the slot host to figure out where to render a\n * panel whose preferred slot is missing in the current form. Walks forward:\n * a panel registered for `after-fields` looks for the next existing slot down\n * the chain (`after-related`, then `after-everything`) until it finds one.\n *\n * The chain is intentionally short — these are the only positions any panel\n * should ever need. New positions can be added by inserting into this array\n * at the right document-order position.\n */\nexport const FORM_SLOT_CHAIN: FormPanelSlot[] = [\n 'top-area',\n 'before-fields',\n 'after-fields',\n 'after-related',\n 'after-everything',\n];\n\n/**\n * Per-form coordinator that tracks which slot positions are physically present\n * in the current form's DOM. Provided at the `<mj-record-form-container>` level\n * (one instance per form) so descendant slot hosts can register themselves and\n * compute the fallback chain.\n *\n * The container template guarantees an `after-everything` slot host at the very\n * bottom of the form body — so panels whose preferred slot is missing always\n * have a final landing spot. Pre-CodeGen-regen forms still display every\n * panel; post-regen forms display them at the better position.\n */\n@Injectable()\nexport class FormSlotCoordinator {\n private readonly presentSlots = new Set<FormPanelSlot>();\n private readonly changes$ = new Subject<void>();\n /** Tracks synchronous re-entry depth into safeEmit so an emit storm\n * caused by a future refactor surfaces loudly instead of freezing. */\n private emitDepth = 0;\n\n /** Slot host calls this on init. Idempotent — safe if invoked twice. */\n public registerSlot(slot: FormPanelSlot): void {\n if (!this.presentSlots.has(slot)) {\n this.presentSlots.add(slot);\n this.safeEmit('registerSlot');\n }\n }\n\n /** Slot host calls this on destroy. */\n public deregisterSlot(slot: FormPanelSlot): void {\n if (this.presentSlots.has(slot)) {\n this.presentSlots.delete(slot);\n this.safeEmit('deregisterSlot');\n }\n }\n\n public hasSlot(slot: FormPanelSlot): boolean {\n return this.presentSlots.has(slot);\n }\n\n /**\n * Resolve a preferred slot to the slot that should ACTUALLY render the\n * panel. Returns the preferred slot if it's present; otherwise walks\n * forward in the chain to find the next existing slot.\n *\n * Returns null only in the (impossible) case where no slot at all is\n * present — the container guarantees `after-everything` exists, so this\n * should never happen in practice.\n */\n public resolveSlot(preferred: FormPanelSlot): FormPanelSlot | null {\n const startIdx = FORM_SLOT_CHAIN.indexOf(preferred);\n if (startIdx === -1) return null;\n for (let i = startIdx; i < FORM_SLOT_CHAIN.length; i++) {\n const candidate = FORM_SLOT_CHAIN[i];\n if (this.presentSlots.has(candidate)) {\n return candidate;\n }\n }\n return null;\n }\n\n /** RxJS stream that fires whenever a slot registers or deregisters. */\n public get changes() {\n return this.changes$.asObservable();\n }\n\n /**\n * Emit with re-entrancy detection. If we're already in the middle of an\n * emit (i.e., a subscriber triggered another emit), log loudly so the loop\n * is visible in the console instead of silently freezing the browser.\n */\n private safeEmit(cause: string): void {\n if (this.emitDepth > 10) {\n console.error(`[FormSlotCoordinator] LOOP DETECTED — emit depth ${this.emitDepth} from ${cause}. Bailing out to prevent freeze.`);\n return;\n }\n this.emitDepth++;\n try {\n this.changes$.next();\n } finally {\n this.emitDepth--;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"form-slot-coordinator.service.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/form-slot-coordinator.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;;AAG/B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC5C,UAAU;IACV,eAAe;IACf,cAAc;IACd,eAAe;IACf,kBAAkB;CACr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I,QAAQ,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrD,MAAM,SAAS,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnC,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,2CAA2C;IACpC,WAAW,CAAC,SAAwB;QACvC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,uEAAuE;IACvE,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAED,uCAAuC;IACvC,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAC,KAAa;QAC1B,IAAI,IAAI,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,oDAAoD,IAAI,CAAC,SAAS,SAAS,KAAK,kCAAkC,CAAC,CAAC;YAClI,OAAO;QACX,CAAC;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACL,CAAC;6GA9FQ,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB;;iFAAnB,mBAAmB;cAD/B,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { FormPanelSlot } from './base-form-panel';\n\n/**\n * Document-order chain used by the slot host to figure out where to render a\n * panel whose preferred slot is missing in the current form. Walks forward:\n * a panel registered for `after-fields` looks for the next existing slot down\n * the chain (`after-related`, then `after-everything`) until it finds one.\n *\n * The chain is intentionally short — these are the only positions any panel\n * should ever need. New positions can be added by inserting into this array\n * at the right document-order position.\n */\nexport const FORM_SLOT_CHAIN: FormPanelSlot[] = [\n 'top-area',\n 'before-fields',\n 'after-fields',\n 'after-related',\n 'after-everything',\n];\n\n/**\n * Per-form coordinator that tracks which slot positions are physically present\n * in the current form's DOM. Provided at the `<mj-record-form-container>` level\n * (one instance per form) so descendant slot hosts can register themselves and\n * compute the fallback chain.\n *\n * The container template guarantees an `after-everything` slot host at the very\n * bottom of the form body — so panels whose preferred slot is missing always\n * have a final landing spot. Pre-CodeGen-regen forms still display every\n * panel; post-regen forms display them at the better position.\n */\n@Injectable()\nexport class FormSlotCoordinator {\n private readonly presentSlots = new Set<FormPanelSlot>();\n private readonly changes$ = new Subject<void>();\n /** Tracks synchronous re-entry depth into safeEmit so an emit storm\n * caused by a future refactor surfaces loudly instead of freezing. */\n private emitDepth = 0;\n\n /** Slot host calls this on init. Idempotent — safe if invoked twice. */\n public RegisterSlot(slot: FormPanelSlot): void {\n if (!this.presentSlots.has(slot)) {\n this.presentSlots.add(slot);\n this.safeEmit('registerSlot');\n }\n }\n\n /** @deprecated Use {@link RegisterSlot}. */\n public registerSlot(slot: FormPanelSlot): void {\n return this.RegisterSlot(slot);\n }\n\n /** Slot host calls this on destroy. */\n public DeregisterSlot(slot: FormPanelSlot): void {\n if (this.presentSlots.has(slot)) {\n this.presentSlots.delete(slot);\n this.safeEmit('deregisterSlot');\n }\n }\n\n /** @deprecated Use {@link DeregisterSlot}. */\n public deregisterSlot(slot: FormPanelSlot): void {\n return this.DeregisterSlot(slot);\n }\n\n public HasSlot(slot: FormPanelSlot): boolean {\n return this.presentSlots.has(slot);\n }\n\n /** @deprecated Use {@link HasSlot}. */\n public hasSlot(slot: FormPanelSlot): boolean {\n return this.HasSlot(slot);\n }\n\n /**\n * Resolve a preferred slot to the slot that should ACTUALLY render the\n * panel. Returns the preferred slot if it's present; otherwise walks\n * forward in the chain to find the next existing slot.\n *\n * Returns null only in the (impossible) case where no slot at all is\n * present — the container guarantees `after-everything` exists, so this\n * should never happen in practice.\n */\n public ResolveSlot(preferred: FormPanelSlot): FormPanelSlot | null {\n const startIdx = FORM_SLOT_CHAIN.indexOf(preferred);\n if (startIdx === -1) return null;\n for (let i = startIdx; i < FORM_SLOT_CHAIN.length; i++) {\n const candidate = FORM_SLOT_CHAIN[i];\n if (this.presentSlots.has(candidate)) {\n return candidate;\n }\n }\n return null;\n }\n\n /** @deprecated Use {@link ResolveSlot}. */\n public resolveSlot(preferred: FormPanelSlot): FormPanelSlot | null {\n return this.ResolveSlot(preferred);\n }\n\n /** RxJS stream that fires whenever a slot registers or deregisters. */\n public get Changes() {\n return this.changes$.asObservable();\n }\n\n /** @deprecated Use {@link Changes}. */\n public get changes() {\n return this.Changes;\n }\n\n /**\n * Emit with re-entrancy detection. If we're already in the middle of an\n * emit (i.e., a subscriber triggered another emit), log loudly so the loop\n * is visible in the console instead of silently freezing the browser.\n */\n private safeEmit(cause: string): void {\n if (this.emitDepth > 10) {\n console.error(`[FormSlotCoordinator] LOOP DETECTED — emit depth ${this.emitDepth} from ${cause}. Bailing out to prevent freeze.`);\n return;\n }\n this.emitDepth++;\n try {\n this.changes$.next();\n } finally {\n this.emitDepth--;\n }\n }\n}\n"]}
@@ -14,6 +14,8 @@ export declare class RelatedEntityGridPanelComponent {
14
14
  Record: BaseEntity;
15
15
  FormComponent: BaseFormComponent;
16
16
  FormContext?: FormContext;
17
+ OnDataLoad(event: AfterDataLoadEventArgs): void;
18
+ /** @deprecated Use {@link OnDataLoad}. */
17
19
  onDataLoad(event: AfterDataLoadEventArgs): void;
18
20
  get GridIcon(): string;
19
21
  static ɵfac: i0.ɵɵFactoryDeclaration<RelatedEntityGridPanelComponent, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"related-entity-grid-panel.component.d.ts","sourceRoot":"","sources":["../../../src/lib/panel-slot/related-entity-grid-panel.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;;AAElE;;;;GAIG;AACH,qBA0Ba,+BAA+B;IAC/B,YAAY,EAAG,sBAAsB,CAAC;IACtC,MAAM,EAAG,UAAU,CAAC;IACpB,aAAa,EAAG,iBAAiB,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAE5B,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAItD,IAAW,QAAQ,IAAI,MAAM,CAK5B;yCAfQ,+BAA+B;2CAA/B,+BAA+B;CAgB3C"}
1
+ {"version":3,"file":"related-entity-grid-panel.component.d.ts","sourceRoot":"","sources":["../../../src/lib/panel-slot/related-entity-grid-panel.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;;AAElE;;;;GAIG;AACH,qBA0Ba,+BAA+B;IAC/B,YAAY,EAAG,sBAAsB,CAAC;IACtC,MAAM,EAAG,UAAU,CAAC;IACpB,aAAa,EAAG,iBAAiB,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAE5B,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAItD,0CAA0C;IACnC,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAItD,IAAW,QAAQ,IAAI,MAAM,CAK5B;yCApBQ,+BAA+B;2CAA/B,+BAA+B;CAqB3C"}
@@ -21,9 +21,13 @@ export class RelatedEntityGridPanelComponent {
21
21
  Record;
22
22
  FormComponent;
23
23
  FormContext;
24
- onDataLoad(event) {
24
+ OnDataLoad(event) {
25
25
  this.FormComponent.SetSectionRowCount(this.Contribution.BakedSectionKey, event.totalRowCount);
26
26
  }
27
+ /** @deprecated Use {@link OnDataLoad}. */
28
+ onDataLoad(event) {
29
+ return this.OnDataLoad(event);
30
+ }
27
31
  get GridIcon() {
28
32
  const name = this.Contribution.RelatedEntity;
29
33
  if (!name)
@@ -1 +1 @@
1
- {"version":3,"file":"related-entity-grid-panel.component.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/related-entity-grid-panel.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;;;;;;IAyBjC,uDAMyC;IAArC,AADA,qOAAY,2CAAoC,KAAC,kOAChC,yBAAkB,KAAC;IACxC,iBAA+B;;;IAH3B,AADA,AADA,AADA,8JAA4H,kIACf,0FAClC,qBACvD;;AAtBxC;;;;GAIG;AA2BH,MAAM,OAAO,+BAA+B;IAC/B,YAAY,CAA0B;IACtC,MAAM,CAAc;IACpB,aAAa,CAAqB;IAClC,WAAW,CAAe;IAE5B,UAAU,CAAC,KAA6B;QAC3C,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAClG,CAAC;IAED,IAAW,QAAQ;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;QAC7C,IAAI,CAAC,IAAI;YAAE,OAAO,aAAa,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/E,OAAO,IAAI,IAAI,aAAa,CAAC;IACjC,CAAC;yHAfQ,+BAA+B;6DAA/B,+BAA+B;YAtBpC,+CAO8B;YAC1B,0HAAsB;YAU1B,iBAAuB;;YAXnB,AADA,AADA,AAFA,AADA,AADA,6DAA2C,6CACH,sBACvB,2BAEK,gCACK,0BACF;YACzB,cASC;YATD,6CASC;;;iFAKA,+BAA+B;cA1B3C,SAAS;6BACM,KAAK,YACP,8BAA8B,YAC9B;;;;;;;;;;;;;;;;;;;;KAoBT;;kBAIA,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kFAJG,+BAA+B","sourcesContent":["import { Component, Input } from '@angular/core';\nimport { BaseEntity } from '@memberjunction/core';\nimport type { AfterDataLoadEventArgs } from '@memberjunction/ng-entity-viewer';\nimport { BaseFormComponent } from '../base-form-component';\nimport { FormContext } from '../types/form-types';\nimport type { FormContributionWinner } from './form-contribution';\n\n/**\n * Stock related-entity grid the composer mounts when a DisplayInForm\n * relationship is neither baked into the form template nor claimed by a\n * registered panel. Mirrors the CodeGen EntityDataGrid template.\n */\n@Component({\n standalone: false,\n selector: 'mj-related-entity-grid-panel',\n template: `\n <mj-collapsible-panel\n [SectionKey]=\"Contribution.BakedSectionKey\"\n [SectionName]=\"Contribution.DisplayName\"\n [Icon]=\"GridIcon\"\n Variant=\"related-entity\"\n [Form]=\"FormComponent\"\n [FormContext]=\"FormContext\"\n [DefaultExpanded]=\"false\">\n @if (Record.IsSaved) {\n <mj-explorer-entity-data-grid\n [Params]=\"FormComponent.BuildRelationshipViewParamsByEntityName(Contribution.RelatedEntity!, Contribution.RelatedJoinField)\"\n [NewRecordValues]=\"FormComponent.NewRecordValues(Contribution.RelatedEntity!, Contribution.RelatedJoinField)\"\n [AllowLoad]=\"FormComponent.IsSectionExpanded(Contribution.BakedSectionKey)\"\n [ShowToolbar]=\"true\"\n (Navigate)=\"FormComponent.OnFormNavigate($event)\"\n (AfterDataLoad)=\"onDataLoad($event)\">\n </mj-explorer-entity-data-grid>\n }\n </mj-collapsible-panel>\n `,\n styles: [`:host { display: contents; }`],\n})\nexport class RelatedEntityGridPanelComponent {\n @Input() Contribution!: FormContributionWinner;\n @Input() Record!: BaseEntity;\n @Input() FormComponent!: BaseFormComponent;\n @Input() FormContext?: FormContext;\n\n public onDataLoad(event: AfterDataLoadEventArgs): void {\n this.FormComponent.SetSectionRowCount(this.Contribution.BakedSectionKey, event.totalRowCount);\n }\n\n public get GridIcon(): string {\n const name = this.Contribution.RelatedEntity;\n if (!name) return 'fa fa-table';\n const icon = this.FormComponent.ProviderToUse.EntityByName(name)?.Icon?.trim();\n return icon || 'fa fa-table';\n }\n}\n"]}
1
+ {"version":3,"file":"related-entity-grid-panel.component.js","sourceRoot":"","sources":["../../../src/lib/panel-slot/related-entity-grid-panel.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;;;;;;IAyBjC,uDAMyC;IAArC,AADA,qOAAY,2CAAoC,KAAC,kOAChC,yBAAkB,KAAC;IACxC,iBAA+B;;;IAH3B,AADA,AADA,AADA,8JAA4H,kIACf,0FAClC,qBACvD;;AAtBxC;;;;GAIG;AA2BH,MAAM,OAAO,+BAA+B;IAC/B,YAAY,CAA0B;IACtC,MAAM,CAAc;IACpB,aAAa,CAAqB;IAClC,WAAW,CAAe;IAE5B,UAAU,CAAC,KAA6B;QAC3C,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAClG,CAAC;IAED,0CAA0C;IACnC,UAAU,CAAC,KAA6B;QAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,IAAW,QAAQ;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;QAC7C,IAAI,CAAC,IAAI;YAAE,OAAO,aAAa,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/E,OAAO,IAAI,IAAI,aAAa,CAAC;IACjC,CAAC;yHApBQ,+BAA+B;6DAA/B,+BAA+B;YAtBpC,+CAO8B;YAC1B,0HAAsB;YAU1B,iBAAuB;;YAXnB,AADA,AADA,AAFA,AADA,AADA,6DAA2C,6CACH,sBACvB,2BAEK,gCACK,0BACF;YACzB,cASC;YATD,6CASC;;;iFAKA,+BAA+B;cA1B3C,SAAS;6BACM,KAAK,YACP,8BAA8B,YAC9B;;;;;;;;;;;;;;;;;;;;KAoBT;;kBAIA,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kFAJG,+BAA+B","sourcesContent":["import { Component, Input } from '@angular/core';\nimport { BaseEntity } from '@memberjunction/core';\nimport type { AfterDataLoadEventArgs } from '@memberjunction/ng-entity-viewer';\nimport { BaseFormComponent } from '../base-form-component';\nimport { FormContext } from '../types/form-types';\nimport type { FormContributionWinner } from './form-contribution';\n\n/**\n * Stock related-entity grid the composer mounts when a DisplayInForm\n * relationship is neither baked into the form template nor claimed by a\n * registered panel. Mirrors the CodeGen EntityDataGrid template.\n */\n@Component({\n standalone: false,\n selector: 'mj-related-entity-grid-panel',\n template: `\n <mj-collapsible-panel\n [SectionKey]=\"Contribution.BakedSectionKey\"\n [SectionName]=\"Contribution.DisplayName\"\n [Icon]=\"GridIcon\"\n Variant=\"related-entity\"\n [Form]=\"FormComponent\"\n [FormContext]=\"FormContext\"\n [DefaultExpanded]=\"false\">\n @if (Record.IsSaved) {\n <mj-explorer-entity-data-grid\n [Params]=\"FormComponent.BuildRelationshipViewParamsByEntityName(Contribution.RelatedEntity!, Contribution.RelatedJoinField)\"\n [NewRecordValues]=\"FormComponent.NewRecordValues(Contribution.RelatedEntity!, Contribution.RelatedJoinField)\"\n [AllowLoad]=\"FormComponent.IsSectionExpanded(Contribution.BakedSectionKey)\"\n [ShowToolbar]=\"true\"\n (Navigate)=\"FormComponent.OnFormNavigate($event)\"\n (AfterDataLoad)=\"onDataLoad($event)\">\n </mj-explorer-entity-data-grid>\n }\n </mj-collapsible-panel>\n `,\n styles: [`:host { display: contents; }`],\n})\nexport class RelatedEntityGridPanelComponent {\n @Input() Contribution!: FormContributionWinner;\n @Input() Record!: BaseEntity;\n @Input() FormComponent!: BaseFormComponent;\n @Input() FormContext?: FormContext;\n\n public OnDataLoad(event: AfterDataLoadEventArgs): void {\n this.FormComponent.SetSectionRowCount(this.Contribution.BakedSectionKey, event.totalRowCount);\n }\n\n /** @deprecated Use {@link OnDataLoad}. */\n public onDataLoad(event: AfterDataLoadEventArgs): void {\n return this.OnDataLoad(event);\n }\n\n public get GridIcon(): string {\n const name = this.Contribution.RelatedEntity;\n if (!name) return 'fa fa-table';\n const icon = this.FormComponent.ProviderToUse.EntityByName(name)?.Icon?.trim();\n return icon || 'fa fa-table';\n }\n}\n"]}
@@ -8,7 +8,11 @@ export declare class SectionLoaderComponent implements AfterViewInit, OnDestroy,
8
8
  record: BaseEntity;
9
9
  EditMode: boolean;
10
10
  LoadComplete: EventEmitter<void>;
11
- container: ViewContainerRef;
11
+ Container: ViewContainerRef;
12
+ /** @deprecated Use {@link Container}. */
13
+ get container(): ViewContainerRef;
14
+ /** @deprecated Use {@link Container}. */
15
+ set container(value: ViewContainerRef);
12
16
  private _sectionObj;
13
17
  constructor(cdr: ChangeDetectorRef);
14
18
  ngOnChanges(changes: SimpleChanges): void;
@@ -1 +1 @@
1
- {"version":3,"file":"section-loader-component.d.ts","sourceRoot":"","sources":["../../src/lib/section-loader-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAa,gBAAgB,EAAE,aAAa,EAAE,SAAS,E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CAAyC;IACzC,IAAI,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAEpC;IAED,OAAO,CAAC,WAAW,CAAyC;gBACxC,GAAG,EAAE,iBAAiB;IAE1C,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAOzC,eAAe,IAAI,IAAI;IAOvB,OAAO,CAAC,aAAa;IAiBrB,WAAW;yCApDF,sBAAsB;2CAAtB,sBAAsB;CAwDlC"}
@@ -11,7 +11,15 @@ export class SectionLoaderComponent {
11
11
  record;
12
12
  EditMode = false;
13
13
  LoadComplete = new EventEmitter();
14
- container;
14
+ Container;
15
+ /** @deprecated Use {@link Container}. */
16
+ get container() {
17
+ return this.Container;
18
+ }
19
+ /** @deprecated Use {@link Container}. */
20
+ set container(value) {
21
+ this.Container = value;
22
+ }
15
23
  _sectionObj = null;
16
24
  constructor(cdr) {
17
25
  this.cdr = cdr;
@@ -32,7 +40,7 @@ export class SectionLoaderComponent {
32
40
  //console.log("loading component?", `${this.Entity}.${this.Section}`);
33
41
  const sectionInfo = MJGlobal.Instance.ClassFactory.GetRegistration(BaseFormSectionComponent, `${this.Entity}.${this.Section}`);
34
42
  if (sectionInfo) {
35
- const componentRef = this.container.createComponent(sectionInfo.SubClass);
43
+ const componentRef = this.Container.createComponent(sectionInfo.SubClass);
36
44
  // pass in record and edit mode
37
45
  this._sectionObj = componentRef.instance;
38
46
  this._sectionObj.record = this.record;
@@ -46,14 +54,14 @@ export class SectionLoaderComponent {
46
54
  }
47
55
  ngOnDestroy() {
48
56
  // Don't forget to cleanup dynamically created components
49
- this.container.clear();
57
+ this.Container.clear();
50
58
  }
51
59
  static ɵfac = function SectionLoaderComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SectionLoaderComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
52
60
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SectionLoaderComponent, selectors: [["mj-form-section"]], viewQuery: function SectionLoaderComponent_Query(rf, ctx) { if (rf & 1) {
53
61
  i0.ɵɵviewQuery(_c0, 5, ViewContainerRef);
54
62
  } if (rf & 2) {
55
63
  let _t;
56
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
64
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.Container = _t.first);
57
65
  } }, inputs: { Entity: "Entity", Section: "Section", record: "record", EditMode: "EditMode" }, outputs: { LoadComplete: "LoadComplete" }, standalone: false, features: [i0.ɵɵNgOnChangesFeature], decls: 3, vars: 0, consts: [["container", ""], [1, "form-section"]], template: function SectionLoaderComponent_Template(rf, ctx) { if (rf & 1) {
58
66
  i0.ɵɵelementStart(0, "div", 1);
59
67
  i0.ɵɵtemplate(1, SectionLoaderComponent_ng_template_1_Template, 0, 0, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
@@ -77,7 +85,7 @@ export class SectionLoaderComponent {
77
85
  type: Input
78
86
  }], LoadComplete: [{
79
87
  type: Output
80
- }], container: [{
88
+ }], Container: [{
81
89
  type: ViewChild,
82
90
  args: ['container', { read: ViewContainerRef }]
83
91
  }] }); })();