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

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 (188) hide show
  1. package/dist/lib/apply/form-placement-dialog.component.d.ts +266 -0
  2. package/dist/lib/apply/form-placement-dialog.component.d.ts.map +1 -0
  3. package/dist/lib/apply/form-placement-dialog.component.js +1522 -0
  4. package/dist/lib/apply/form-placement-dialog.component.js.map +1 -0
  5. package/dist/lib/apply/form-placement-order.d.ts +37 -0
  6. package/dist/lib/apply/form-placement-order.d.ts.map +1 -0
  7. package/dist/lib/apply/form-placement-order.js +111 -0
  8. package/dist/lib/apply/form-placement-order.js.map +1 -0
  9. package/dist/lib/apply/form-placement-preview.component.d.ts +112 -0
  10. package/dist/lib/apply/form-placement-preview.component.d.ts.map +1 -0
  11. package/dist/lib/apply/form-placement-preview.component.js +346 -0
  12. package/dist/lib/apply/form-placement-preview.component.js.map +1 -0
  13. package/dist/lib/apply/form-placement-text.d.ts +61 -0
  14. package/dist/lib/apply/form-placement-text.d.ts.map +1 -0
  15. package/dist/lib/apply/form-placement-text.js +279 -0
  16. package/dist/lib/apply/form-placement-text.js.map +1 -0
  17. package/dist/lib/apply/form-placement.d.ts +320 -0
  18. package/dist/lib/apply/form-placement.d.ts.map +1 -0
  19. package/dist/lib/apply/form-placement.js +432 -0
  20. package/dist/lib/apply/form-placement.js.map +1 -0
  21. package/dist/lib/apply/form-slot-probe.service.d.ts +121 -0
  22. package/dist/lib/apply/form-slot-probe.service.d.ts.map +1 -0
  23. package/dist/lib/apply/form-slot-probe.service.js +264 -0
  24. package/dist/lib/apply/form-slot-probe.service.js.map +1 -0
  25. package/dist/lib/base-form-component-internals.d.ts +11 -0
  26. package/dist/lib/base-form-component-internals.d.ts.map +1 -0
  27. package/dist/lib/base-form-component-internals.js +33 -0
  28. package/dist/lib/base-form-component-internals.js.map +1 -0
  29. package/dist/lib/base-form-component.d.ts +132 -1
  30. package/dist/lib/base-form-component.d.ts.map +1 -1
  31. package/dist/lib/base-form-component.js +228 -19
  32. package/dist/lib/base-form-component.js.map +1 -1
  33. package/dist/lib/chrome/form-chrome.d.ts +78 -0
  34. package/dist/lib/chrome/form-chrome.d.ts.map +1 -1
  35. package/dist/lib/chrome/form-chrome.js +128 -2
  36. package/dist/lib/chrome/form-chrome.js.map +1 -1
  37. package/dist/lib/chrome/form-composition-registry.d.ts +34 -0
  38. package/dist/lib/chrome/form-composition-registry.d.ts.map +1 -0
  39. package/dist/lib/chrome/form-composition-registry.js +56 -0
  40. package/dist/lib/chrome/form-composition-registry.js.map +1 -0
  41. package/dist/lib/chrome/form-composition-snapshot.d.ts +151 -0
  42. package/dist/lib/chrome/form-composition-snapshot.d.ts.map +1 -0
  43. package/dist/lib/chrome/form-composition-snapshot.js +137 -0
  44. package/dist/lib/chrome/form-composition-snapshot.js.map +1 -0
  45. package/dist/lib/chrome/resolve-form-chrome.d.ts +15 -0
  46. package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
  47. package/dist/lib/chrome/resolve-form-chrome.js +31 -2
  48. package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
  49. package/dist/lib/container/record-form-container.component.d.ts +240 -5
  50. package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
  51. package/dist/lib/container/record-form-container.component.js +976 -249
  52. package/dist/lib/container/record-form-container.component.js.map +1 -1
  53. package/dist/lib/field/form-field.component.d.ts +17 -0
  54. package/dist/lib/field/form-field.component.d.ts.map +1 -1
  55. package/dist/lib/field/form-field.component.js +41 -5
  56. package/dist/lib/field/form-field.component.js.map +1 -1
  57. package/dist/lib/form-state.service.d.ts +5 -0
  58. package/dist/lib/form-state.service.d.ts.map +1 -1
  59. package/dist/lib/form-state.service.js +6 -1
  60. package/dist/lib/form-state.service.js.map +1 -1
  61. package/dist/lib/host/entity-form-host.component.d.ts +16 -1
  62. package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
  63. package/dist/lib/host/entity-form-host.component.js +27 -6
  64. package/dist/lib/host/entity-form-host.component.js.map +1 -1
  65. package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts +24 -0
  66. package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts.map +1 -0
  67. package/dist/lib/interactive-form/form-panel-host-props.builder.js +99 -0
  68. package/dist/lib/interactive-form/form-panel-host-props.builder.js.map +1 -0
  69. package/dist/lib/interactive-form/interactive-form-panel.component.d.ts +109 -0
  70. package/dist/lib/interactive-form/interactive-form-panel.component.d.ts.map +1 -0
  71. package/dist/lib/interactive-form/interactive-form-panel.component.js +424 -0
  72. package/dist/lib/interactive-form/interactive-form-panel.component.js.map +1 -0
  73. package/dist/lib/interactive-form/interactive-form.component.d.ts +2 -0
  74. package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
  75. package/dist/lib/interactive-form/interactive-form.component.js +4 -5
  76. package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
  77. package/dist/lib/panel/collapsible-panel.component.d.ts +69 -1
  78. package/dist/lib/panel/collapsible-panel.component.d.ts.map +1 -1
  79. package/dist/lib/panel/collapsible-panel.component.js +148 -12
  80. package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
  81. package/dist/lib/panel-manager/form-audience.d.ts +46 -0
  82. package/dist/lib/panel-manager/form-audience.d.ts.map +1 -0
  83. package/dist/lib/panel-manager/form-audience.js +34 -0
  84. package/dist/lib/panel-manager/form-audience.js.map +1 -0
  85. package/dist/lib/panel-manager/form-panel-admin.service.d.ts +150 -0
  86. package/dist/lib/panel-manager/form-panel-admin.service.d.ts.map +1 -0
  87. package/dist/lib/panel-manager/form-panel-admin.service.js +433 -0
  88. package/dist/lib/panel-manager/form-panel-admin.service.js.map +1 -0
  89. package/dist/lib/panel-manager/form-panel-inventory.d.ts +255 -0
  90. package/dist/lib/panel-manager/form-panel-inventory.d.ts.map +1 -0
  91. package/dist/lib/panel-manager/form-panel-inventory.js +293 -0
  92. package/dist/lib/panel-manager/form-panel-inventory.js.map +1 -0
  93. package/dist/lib/panel-manager/panel-manager.component.d.ts +232 -0
  94. package/dist/lib/panel-manager/panel-manager.component.d.ts.map +1 -0
  95. package/dist/lib/panel-manager/panel-manager.component.js +1112 -0
  96. package/dist/lib/panel-manager/panel-manager.component.js.map +1 -0
  97. package/dist/lib/panel-slot/base-contribution-panel.d.ts +40 -0
  98. package/dist/lib/panel-slot/base-contribution-panel.d.ts.map +1 -0
  99. package/dist/lib/panel-slot/base-contribution-panel.js +55 -0
  100. package/dist/lib/panel-slot/base-contribution-panel.js.map +1 -0
  101. package/dist/lib/panel-slot/base-form-panel.d.ts +116 -8
  102. package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
  103. package/dist/lib/panel-slot/base-form-panel.js +76 -5
  104. package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
  105. package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts +29 -0
  106. package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts.map +1 -0
  107. package/dist/lib/panel-slot/collect-form-contribution-registrations.js +214 -0
  108. package/dist/lib/panel-slot/collect-form-contribution-registrations.js.map +1 -0
  109. package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts +6 -3
  110. package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts.map +1 -1
  111. package/dist/lib/panel-slot/collect-form-panel-registrations.js +8 -14
  112. package/dist/lib/panel-slot/collect-form-panel-registrations.js.map +1 -1
  113. package/dist/lib/panel-slot/form-contribution.d.ts +170 -7
  114. package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
  115. package/dist/lib/panel-slot/form-contribution.js +242 -64
  116. package/dist/lib/panel-slot/form-contribution.js.map +1 -1
  117. package/dist/lib/panel-slot/form-contributions.component.d.ts +16 -5
  118. package/dist/lib/panel-slot/form-contributions.component.d.ts.map +1 -1
  119. package/dist/lib/panel-slot/form-contributions.component.js +43 -7
  120. package/dist/lib/panel-slot/form-contributions.component.js.map +1 -1
  121. package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts +66 -0
  122. package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts.map +1 -0
  123. package/dist/lib/panel-slot/form-field-panel-slot.component.js +190 -0
  124. package/dist/lib/panel-slot/form-field-panel-slot.component.js.map +1 -0
  125. package/dist/lib/panel-slot/form-panel-slot.component.d.ts +52 -16
  126. package/dist/lib/panel-slot/form-panel-slot.component.d.ts.map +1 -1
  127. package/dist/lib/panel-slot/form-panel-slot.component.js +190 -66
  128. package/dist/lib/panel-slot/form-panel-slot.component.js.map +1 -1
  129. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +11 -0
  130. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
  131. package/dist/lib/panel-slot/form-slot-coordinator.service.js +17 -0
  132. package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
  133. package/dist/lib/panel-slot/merge-panel-validation.d.ts +7 -0
  134. package/dist/lib/panel-slot/merge-panel-validation.d.ts.map +1 -0
  135. package/dist/lib/panel-slot/merge-panel-validation.js +16 -0
  136. package/dist/lib/panel-slot/merge-panel-validation.js.map +1 -0
  137. package/dist/lib/panel-slot/mount-form-contribution.d.ts +15 -0
  138. package/dist/lib/panel-slot/mount-form-contribution.d.ts.map +1 -0
  139. package/dist/lib/panel-slot/mount-form-contribution.js +37 -0
  140. package/dist/lib/panel-slot/mount-form-contribution.js.map +1 -0
  141. package/dist/lib/panel-slot/panel-hides.d.ts +35 -0
  142. package/dist/lib/panel-slot/panel-hides.d.ts.map +1 -0
  143. package/dist/lib/panel-slot/panel-hides.js +111 -0
  144. package/dist/lib/panel-slot/panel-hides.js.map +1 -0
  145. package/dist/lib/panel-slot/placement-preview-panel.component.d.ts +16 -0
  146. package/dist/lib/panel-slot/placement-preview-panel.component.d.ts.map +1 -0
  147. package/dist/lib/panel-slot/placement-preview-panel.component.js +112 -0
  148. package/dist/lib/panel-slot/placement-preview-panel.component.js.map +1 -0
  149. package/dist/lib/panel-slot/placement-preview.d.ts +57 -0
  150. package/dist/lib/panel-slot/placement-preview.d.ts.map +1 -0
  151. package/dist/lib/panel-slot/placement-preview.js +86 -0
  152. package/dist/lib/panel-slot/placement-preview.js.map +1 -0
  153. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
  154. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
  155. package/dist/lib/panel-slot/related-entity-grid-panel.component.js +10 -3
  156. package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
  157. package/dist/lib/panel-slot/slot-order.d.ts +19 -0
  158. package/dist/lib/panel-slot/slot-order.d.ts.map +1 -0
  159. package/dist/lib/panel-slot/slot-order.js +53 -0
  160. package/dist/lib/panel-slot/slot-order.js.map +1 -0
  161. package/dist/lib/resolver/form-resolver.service.d.ts +4 -2
  162. package/dist/lib/resolver/form-resolver.service.d.ts.map +1 -1
  163. package/dist/lib/resolver/form-resolver.service.js +18 -8
  164. package/dist/lib/resolver/form-resolver.service.js.map +1 -1
  165. package/dist/lib/resolver/form-variants.d.ts +28 -0
  166. package/dist/lib/resolver/form-variants.d.ts.map +1 -0
  167. package/dist/lib/resolver/form-variants.js +40 -0
  168. package/dist/lib/resolver/form-variants.js.map +1 -0
  169. package/dist/lib/section-counts/form-section-counts.d.ts +99 -0
  170. package/dist/lib/section-counts/form-section-counts.d.ts.map +1 -0
  171. package/dist/lib/section-counts/form-section-counts.js +223 -0
  172. package/dist/lib/section-counts/form-section-counts.js.map +1 -0
  173. package/dist/lib/toolbar/form-toolbar.component.d.ts +7 -0
  174. package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
  175. package/dist/lib/toolbar/form-toolbar.component.js +194 -128
  176. package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
  177. package/dist/lib/types/form-types.d.ts +8 -0
  178. package/dist/lib/types/form-types.d.ts.map +1 -1
  179. package/dist/lib/types/form-types.js.map +1 -1
  180. package/dist/module.d.ts +29 -23
  181. package/dist/module.d.ts.map +1 -1
  182. package/dist/module.js +43 -5
  183. package/dist/module.js.map +1 -1
  184. package/dist/public-api.d.ts +20 -0
  185. package/dist/public-api.d.ts.map +1 -1
  186. package/dist/public-api.js +21 -0
  187. package/dist/public-api.js.map +1 -1
  188. package/package.json +20 -20
@@ -1,6 +1,8 @@
1
1
  export const MORE_SECTION_KEY = '__mj_form_more';
2
2
  /** Field panels (default / inherited) collapse into this one left-nav item. */
3
3
  export const DETAILS_SECTION_KEY = '__mj_form_details';
4
+ /** The title of the left-nav item {@link DETAILS_SECTION_KEY} names. */
5
+ export const DETAILS_SECTION_TITLE = 'Details';
4
6
  export const SYSTEM_METADATA_SECTION_KEY = 'systemMetadata';
5
7
  /**
6
8
  * Expand-all / collapse-all only apply to stacked accordion panels.
@@ -18,6 +20,123 @@ export function IsAlwaysMoreSection(sectionKey, sectionName) {
18
20
  const name = (sectionName ?? '').trim().toLowerCase();
19
21
  return name === 'system metadata';
20
22
  }
23
+ /**
24
+ * The section keys filed under one rail item, worked out from the panels alone.
25
+ *
26
+ * The rail's own membership is not usable here: it is computed from the set of panels a
27
+ * contribution has hidden, so asking it which panels a contribution should hide would be
28
+ * circular. This applies the same classification the rail applies — audit leftovers to
29
+ * More, related grids and contributions to an item of their own merged by title,
30
+ * everything else to Details — over the unfiltered panels.
31
+ *
32
+ * `groupKey` is any rail item's key, so nothing here privileges Details.
33
+ */
34
+ export function RailGroupSectionKeys(panels, contributionSectionKeys, groupKey) {
35
+ const key = (groupKey ?? '').trim();
36
+ if (!key)
37
+ return [];
38
+ const contributions = new Set(contributionSectionKeys);
39
+ const groupOf = (panel) => {
40
+ if (IsAlwaysMoreSection(panel.SectionKey, panel.SectionName))
41
+ return MORE_SECTION_KEY;
42
+ if (panel.Variant === 'related-entity' || contributions.has(panel.SectionKey))
43
+ return panel.SectionKey;
44
+ return DETAILS_SECTION_KEY;
45
+ };
46
+ // Related items sharing a title are one rail item, so naming either one names both.
47
+ const named = panels.find((panel) => groupOf(panel) === key);
48
+ const namedTitle = named && key !== DETAILS_SECTION_KEY && key !== MORE_SECTION_KEY
49
+ ? HumanizeEntityTitle(named.SectionName || named.SectionKey)
50
+ : null;
51
+ return panels
52
+ .filter((panel) => {
53
+ const group = groupOf(panel);
54
+ if (group === key)
55
+ return true;
56
+ if (!namedTitle || group === DETAILS_SECTION_KEY || group === MORE_SECTION_KEY)
57
+ return false;
58
+ return HumanizeEntityTitle(panel.SectionName || panel.SectionKey) === namedTitle;
59
+ })
60
+ .map((panel) => panel.SectionKey);
61
+ }
62
+ /**
63
+ * The panels a contribution can replace one of: what the Details rail item is made of,
64
+ * in document order.
65
+ *
66
+ * Not "every panel that is not a related grid". That set also holds the contributions
67
+ * already installed — replaced by naming the panel, not a section — and the leftover
68
+ * audit sections, which the rail files under More. Offering either as a field group
69
+ * inside Details tells the user the tab contains things it does not. With no Details
70
+ * item the form has no such tab, and every non-grid panel stands on its own.
71
+ */
72
+ export function FieldGroupsInDetails(panels, groups) {
73
+ const details = groups.find((group) => group.Key === DETAILS_SECTION_KEY);
74
+ const keep = details
75
+ ? (panel) => details.SectionKeys.includes(panel.SectionKey)
76
+ : (panel) => panel.Variant !== 'related-entity';
77
+ return panels.filter(keep).map((panel) => ({ Key: panel.SectionKey, Title: panel.SectionName }));
78
+ }
79
+ /**
80
+ * The section drawing any of these fields, which is where a field claim renders.
81
+ *
82
+ * Any, not all: a claim naming a field the form has stopped drawing still renders where
83
+ * its remaining fields are. The first match wins, and the claim is meant to name fields of
84
+ * one section, so there is normally only one.
85
+ */
86
+ export function SectionDrawingAnyField(panels, fieldNames) {
87
+ const wanted = new Set(fieldNames.map((name) => name.trim()).filter((name) => name.length > 0));
88
+ if (wanted.size === 0)
89
+ return undefined;
90
+ return panels.find((panel) => (panel.Fields ?? []).some((field) => wanted.has(field.Name)))?.SectionKey;
91
+ }
92
+ /**
93
+ * The rail item a contribution belongs to by virtue of the slot it mounts at.
94
+ *
95
+ * A slot says where a panel sits in the form body, and the rail groups that body — so the
96
+ * slot decides the group unless something more specific does. `before-fields` and
97
+ * `after-fields` are positions among the field sections, and the field sections are the
98
+ * Details tab, so a panel at either belongs in Details. The rest are positions relative
99
+ * to things that are tabs in their own right, so a panel there is its own tab too.
100
+ *
101
+ * Without this the slot has no visible effect on a rail form at all: every contribution
102
+ * that claims nothing becomes its own tab, and a user who asked for "before the fields"
103
+ * gets a tab at the bottom of the rail instead.
104
+ */
105
+ export function SlotChromeGroup(slot) {
106
+ const key = (slot ?? '').trim();
107
+ return key === 'before-fields' || key === 'after-fields' ? 'details' : null;
108
+ }
109
+ /**
110
+ * The rail item a contribution joins when it replaces `sectionKey`.
111
+ *
112
+ * Replacing something means standing where it stood. A panel put in place of a field
113
+ * section belongs in the Details tab that section was part of; one put in place of the
114
+ * whole Details group belongs in that group; one put in place of a leftover audit section
115
+ * belongs in More. Null means the contribution keeps a rail item of its own: it replaces
116
+ * nothing, the section is not on the form, or it takes over a related grid — that last one
117
+ * already inherits the grid's rail item through the relationship claim.
118
+ *
119
+ * Without this a replacing panel is lifted to a first-class rail item beside the tab it
120
+ * emptied, so the form loses a section and gains a tab.
121
+ */
122
+ export function ReplacedSectionChromeGroup(sectionKey, section) {
123
+ const key = (sectionKey ?? '').trim();
124
+ if (!key)
125
+ return null;
126
+ // Details and More are assembled at render time, so neither has a panel of its own to
127
+ // look up, and a panel standing in for one has nowhere else to be. Every other rail
128
+ // item is named after the panels it holds, so replacing all of them empties the item
129
+ // and the contribution becomes the item — null, a rail item of its own.
130
+ if (key === DETAILS_SECTION_KEY)
131
+ return 'details';
132
+ if (key === MORE_SECTION_KEY)
133
+ return 'more';
134
+ if (!section || section.Variant === 'related-entity')
135
+ return null;
136
+ return IsAlwaysMoreSection(key, section.SectionName) ? 'more' : 'details';
137
+ }
138
+ const SCHEMA_PREFIX = /^[A-Za-z][A-Za-z0-9_]*$/;
139
+ const LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
21
140
  /**
22
141
  * Drop a schema entity-name prefix (`MJ_BizApps_Common: Contact Methods` →
23
142
  * `Contact Methods`). DisplayName is the long-term source of truth; this keeps
@@ -25,8 +144,15 @@ export function IsAlwaysMoreSection(sectionKey, sectionName) {
25
144
  */
26
145
  export function HumanizeEntityTitle(name) {
27
146
  const trimmed = (name ?? '').trim();
28
- const match = trimmed.match(/^[A-Za-z][A-Za-z0-9_]*:\s+(.+)$/);
29
- return match?.[1]?.trim() || trimmed;
147
+ const colon = trimmed.indexOf(':');
148
+ if (colon < 1 || !SCHEMA_PREFIX.test(trimmed.slice(0, colon)))
149
+ return trimmed;
150
+ const rest = trimmed.slice(colon + 1);
151
+ const title = rest.trimStart();
152
+ // The prefix needs whitespace after its colon, and the title is one line.
153
+ if (title.length === rest.length || LINE_TERMINATOR.test(title))
154
+ return trimmed;
155
+ return title || trimmed;
30
156
  }
31
157
  /**
32
158
  * True when `sectionKey` sits in the left-nav Details group — the one rail
@@ -1 +1 @@
1
- {"version":3,"file":"form-chrome.js","sourceRoot":"","sources":["../../../src/lib/chrome/form-chrome.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiC;IACnE,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,WAAW,CAAC;AACnD,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,mBAAmB,CAAC,UAAkB,EAAE,WAAoB;IACxE,MAAM,GAAG,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACpD,IAAI,GAAG,KAAK,2BAA2B,CAAC,WAAW,EAAE;QAAE,OAAO,IAAI,CAAC;IACnE,MAAM,IAAI,GAAG,CAAC,WA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CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACzE,CAAC;AASD,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACpD,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,EAAE;IACV,YAAY,EAAE,IAAI,GAAG,EAAE;IACvB,eAAe,EAAE,EAAE;CACtB,CAAC","sourcesContent":["/**\n * Form chrome — how the container arranges sections (accordion vs left-nav,\n * first-class vs More). Complements form contributions (what is on the form).\n *\n * @see plans/form-chrome-policy.md\n */\nimport type { FormRole } from '@memberjunction/core';\n\nexport const MORE_SECTION_KEY = '__mj_form_more';\n\n/** Field panels (default / inherited) collapse into this one left-nav item. */\nexport const DETAILS_SECTION_KEY = '__mj_form_details';\n\nexport const SYSTEM_METADATA_SECTION_KEY = 'systemMetadata';\n\n/**\n * Expand-all / collapse-all only apply to stacked accordion panels.\n * Left-nav and right-nav show one section at a time, so those buttons\n * would be noise.\n */\nexport function IsAccordionFormChrome(layout: string | null | undefined): boolean {\n return (layout ?? 'accordion') === 'accordion';\n}\n\n/** Audit / timestamp leftover sections always fold into More. */\nexport function IsAlwaysMoreSection(sectionKey: string, sectionName?: string): boolean {\n const key = (sectionKey ?? '').trim().toLowerCase();\n if (key === SYSTEM_METADATA_SECTION_KEY.toLowerCase()) return true;\n const name = (sectionName ?? '').trim().toLowerCase();\n return name === 'system metadata';\n}\n\n/**\n * Drop a schema entity-name prefix (`MJ_BizApps_Common: Contact Methods` →\n * `Contact Methods`). DisplayName is the long-term source of truth; this keeps\n * already-baked SectionName strings readable until CodeGen reruns.\n */\nexport function HumanizeEntityTitle(name: string): string {\n const trimmed = (name ?? '').trim();\n const match = trimmed.match(/^[A-Za-z][A-Za-z0-9_]*:\\s+(.+)$/);\n return match?.[1]?.trim() || trimmed;\n}\n\nexport interface FormChromeGroup {\n Key: string;\n Title: string;\n Icon: string;\n SectionKeys: string[];\n /** True when this group is the More bucket (Detail related grids). */\n IsMore: boolean;\n /**\n * Primary contribution that owns its own rail item and sorts in the\n * lead band (before Details). Overview is the usual case.\n */\n IsLead?: boolean;\n}\n\nexport interface FormChromeSpec {\n Layout: 'accordion' | 'left-nav';\n Groups: FormChromeGroup[];\n /** SectionKey → role for related-entity panels. Field panels are omitted. */\n RelatedRoles: ReadonlyMap<string, FormRole>;\n MoreSectionKeys: string[];\n /**\n * L3 admin Title overlays, keyed by section key or contribution key.\n * First-class group titles are already rewritten; More items and\n * accordion headers read this map so the same override reaches both.\n */\n TitleBySectionKey?: ReadonlyMap<string, string>;\n}\n\n/**\n * True when `sectionKey` sits in the left-nav Details group — the one rail\n * item that shows SEVERAL panels at once (every field panel, plus any\n * contribution registered with `ChromeGroup: 'details'`). The container\n * renders those panels as ONE card (`.mj-chrome-details`, with\n * `-first` / `-last` on the visual edges): no per-section headers, one\n * surface — otherwise the field rows float on the page background.\n */\nexport function IsDetailsSectionKey(spec: Pick<FormChromeSpec, 'Groups'>, sectionKey: string): boolean {\n const details = spec.Groups.find((g) => g.Key === DETAILS_SECTION_KEY);\n return !!details && details.SectionKeys.includes(sectionKey);\n}\n\n/**\n * The visual first and last of the Details panels currently shown. Panels are\n * flex items sequenced by CSS `order` (the form's section display order), so\n * DOM order is not enough — a user who reordered sections would get the card's\n * rounded corners on the wrong panels. Ties keep DOM order (stable sort).\n */\nexport function DetailsCardEdges(\n keysInDomOrder: readonly string[],\n orderOf: (sectionKey: string) => number,\n): { First: string | null; Last: string | null } {\n if (keysInDomOrder.length === 0) return { First: null, Last: null };\n const sorted = keysInDomOrder\n .map((key, index) => ({ key, index, order: orderOf(key) }))\n .sort((a, b) => (a.order - b.order) || (a.index - b.index));\n return { First: sorted[0].key, Last: sorted[sorted.length - 1].key };\n}\n\nexport interface FormChromePanelSnapshot {\n SectionKey: string;\n SectionName: string;\n Variant: string;\n Icon?: string;\n}\n\nexport const DEFAULT_FORM_CHROME_SPEC: FormChromeSpec = {\n Layout: 'accordion',\n Groups: [],\n RelatedRoles: new Map(),\n MoreSectionKeys: [],\n};\n"]}
1
+ {"version":3,"file":"form-chrome.js","sourceRoot":"","sources":["../../../src/lib/chrome/form-chrome.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEvD,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAE/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,gBAAgB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiC;IACnE,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,WAAW,CAAC;AACnD,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,mBAAmB,CAAC,UAAkB,EAAE,WAAoB;IACxE,MAAM,GAAG,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACpD,IAAI,GAAG,KAAK,2BAA2B,CAAC,WAAW,EAAE;QAAE,OAAO,IAAI,CAAC;IACnE,MAAM,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtD,OAAO,IAAI,KAAK,iBAAiB,CAAC;AACtC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAChC,MAA0C,EAC1C,uBAA0C,EAC1C,QAAgB;IAEhB,MAAM,GAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,aAAa,GAAG,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CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACzE,CAAC;AAeD,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACpD,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,EAAE;IACV,YAAY,EAAE,IAAI,GAAG,EAAE;IACvB,eAAe,EAAE,EAAE;CACtB,CAAC","sourcesContent":["/**\n * Form chrome — how the container arranges sections (accordion vs left-nav,\n * first-class vs More). Complements form contributions (what is on the form).\n *\n * @see plans/form-chrome-policy.md\n */\nimport type { FormRole } from '@memberjunction/core';\n\nexport const MORE_SECTION_KEY = '__mj_form_more';\n\n/** Field panels (default / inherited) collapse into this one left-nav item. */\nexport const DETAILS_SECTION_KEY = '__mj_form_details';\n\n/** The title of the left-nav item {@link DETAILS_SECTION_KEY} names. */\nexport const DETAILS_SECTION_TITLE = 'Details';\n\nexport const SYSTEM_METADATA_SECTION_KEY = 'systemMetadata';\n\n/**\n * Expand-all / collapse-all only apply to stacked accordion panels.\n * Left-nav and right-nav show one section at a time, so those buttons\n * would be noise.\n */\nexport function IsAccordionFormChrome(layout: string | null | undefined): boolean {\n return (layout ?? 'accordion') === 'accordion';\n}\n\n/** Audit / timestamp leftover sections always fold into More. */\nexport function IsAlwaysMoreSection(sectionKey: string, sectionName?: string): boolean {\n const key = (sectionKey ?? '').trim().toLowerCase();\n if (key === SYSTEM_METADATA_SECTION_KEY.toLowerCase()) return true;\n const name = (sectionName ?? '').trim().toLowerCase();\n return name === 'system metadata';\n}\n\n/**\n * The section keys filed under one rail item, worked out from the panels alone.\n *\n * The rail's own membership is not usable here: it is computed from the set of panels a\n * contribution has hidden, so asking it which panels a contribution should hide would be\n * circular. This applies the same classification the rail applies — audit leftovers to\n * More, related grids and contributions to an item of their own merged by title,\n * everything else to Details — over the unfiltered panels.\n *\n * `groupKey` is any rail item's key, so nothing here privileges Details.\n */\nexport function RailGroupSectionKeys(\n panels: readonly FormChromePanelSnapshot[],\n contributionSectionKeys: readonly string[],\n groupKey: string,\n): string[] {\n const key = (groupKey ?? '').trim();\n if (!key) return [];\n const contributions = new Set(contributionSectionKeys);\n\n const groupOf = (panel: FormChromePanelSnapshot): string => {\n if (IsAlwaysMoreSection(panel.SectionKey, panel.SectionName)) return MORE_SECTION_KEY;\n if (panel.Variant === 'related-entity' || contributions.has(panel.SectionKey)) return panel.SectionKey;\n return DETAILS_SECTION_KEY;\n };\n\n // Related items sharing a title are one rail item, so naming either one names both.\n const named = panels.find((panel) => groupOf(panel) === key);\n const namedTitle = named && key !== DETAILS_SECTION_KEY && key !== MORE_SECTION_KEY\n ? HumanizeEntityTitle(named.SectionName || named.SectionKey)\n : null;\n\n return panels\n .filter((panel) => {\n const group = groupOf(panel);\n if (group === key) return true;\n if (!namedTitle || group === DETAILS_SECTION_KEY || group === MORE_SECTION_KEY) return false;\n return HumanizeEntityTitle(panel.SectionName || panel.SectionKey) === namedTitle;\n })\n .map((panel) => panel.SectionKey);\n}\n\n/**\n * The panels a contribution can replace one of: what the Details rail item is made of,\n * in document order.\n *\n * Not \"every panel that is not a related grid\". That set also holds the contributions\n * already installed — replaced by naming the panel, not a section — and the leftover\n * audit sections, which the rail files under More. Offering either as a field group\n * inside Details tells the user the tab contains things it does not. With no Details\n * item the form has no such tab, and every non-grid panel stands on its own.\n */\nexport function FieldGroupsInDetails(\n panels: readonly FormChromePanelSnapshot[],\n groups: readonly FormChromeGroup[],\n): Array<{ Key: string; Title: string }> {\n const details = groups.find((group) => group.Key === DETAILS_SECTION_KEY);\n const keep = details\n ? (panel: FormChromePanelSnapshot) => details.SectionKeys.includes(panel.SectionKey)\n : (panel: FormChromePanelSnapshot) => panel.Variant !== 'related-entity';\n return panels.filter(keep).map((panel) => ({ Key: panel.SectionKey, Title: panel.SectionName }));\n}\n\n/**\n * The section drawing any of these fields, which is where a field claim renders.\n *\n * Any, not all: a claim naming a field the form has stopped drawing still renders where\n * its remaining fields are. The first match wins, and the claim is meant to name fields of\n * one section, so there is normally only one.\n */\nexport function SectionDrawingAnyField(\n panels: readonly FormChromePanelSnapshot[],\n fieldNames: readonly string[],\n): string | undefined {\n const wanted = new Set(fieldNames.map((name) => name.trim()).filter((name) => name.length > 0));\n if (wanted.size === 0) return undefined;\n return panels.find((panel) => (panel.Fields ?? []).some((field) => wanted.has(field.Name)))?.SectionKey;\n}\n\n/**\n * The rail item a contribution belongs to by virtue of the slot it mounts at.\n *\n * A slot says where a panel sits in the form body, and the rail groups that body — so the\n * slot decides the group unless something more specific does. `before-fields` and\n * `after-fields` are positions among the field sections, and the field sections are the\n * Details tab, so a panel at either belongs in Details. The rest are positions relative\n * to things that are tabs in their own right, so a panel there is its own tab too.\n *\n * Without this the slot has no visible effect on a rail form at all: every contribution\n * that claims nothing becomes its own tab, and a user who asked for \"before the fields\"\n * gets a tab at the bottom of the rail instead.\n */\nexport function SlotChromeGroup(slot: string | null | undefined): 'details' | null {\n const key = (slot ?? '').trim();\n return key === 'before-fields' || key === 'after-fields' ? 'details' : null;\n}\n\n/** Enough of a rendered section to decide which rail item it belongs to. */\nexport interface ChromeSectionShape {\n Variant?: string;\n SectionName?: string;\n}\n\n/**\n * The rail item a contribution joins when it replaces `sectionKey`.\n *\n * Replacing something means standing where it stood. A panel put in place of a field\n * section belongs in the Details tab that section was part of; one put in place of the\n * whole Details group belongs in that group; one put in place of a leftover audit section\n * belongs in More. Null means the contribution keeps a rail item of its own: it replaces\n * nothing, the section is not on the form, or it takes over a related grid — that last one\n * already inherits the grid's rail item through the relationship claim.\n *\n * Without this a replacing panel is lifted to a first-class rail item beside the tab it\n * emptied, so the form loses a section and gains a tab.\n */\nexport function ReplacedSectionChromeGroup(\n sectionKey: string | null | undefined,\n section: ChromeSectionShape | null | undefined,\n): 'details' | 'more' | null {\n const key = (sectionKey ?? '').trim();\n if (!key) return null;\n // Details and More are assembled at render time, so neither has a panel of its own to\n // look up, and a panel standing in for one has nowhere else to be. Every other rail\n // item is named after the panels it holds, so replacing all of them empties the item\n // and the contribution becomes the item — null, a rail item of its own.\n if (key === DETAILS_SECTION_KEY) return 'details';\n if (key === MORE_SECTION_KEY) return 'more';\n if (!section || section.Variant === 'related-entity') return null;\n return IsAlwaysMoreSection(key, section.SectionName) ? 'more' : 'details';\n}\n\nconst SCHEMA_PREFIX = /^[A-Za-z][A-Za-z0-9_]*$/;\nconst LINE_TERMINATOR = /[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Drop a schema entity-name prefix (`MJ_BizApps_Common: Contact Methods` →\n * `Contact Methods`). DisplayName is the long-term source of truth; this keeps\n * already-baked SectionName strings readable until CodeGen reruns.\n */\nexport function HumanizeEntityTitle(name: string): string {\n const trimmed = (name ?? '').trim();\n const colon = trimmed.indexOf(':');\n if (colon < 1 || !SCHEMA_PREFIX.test(trimmed.slice(0, colon))) return trimmed;\n const rest = trimmed.slice(colon + 1);\n const title = rest.trimStart();\n // The prefix needs whitespace after its colon, and the title is one line.\n if (title.length === rest.length || LINE_TERMINATOR.test(title)) return trimmed;\n return title || trimmed;\n}\n\nexport interface FormChromeGroup {\n Key: string;\n Title: string;\n Icon: string;\n SectionKeys: string[];\n /** True when this group is the More bucket (Detail related grids). */\n IsMore: boolean;\n /**\n * Primary contribution that owns its own rail item and sorts in the\n * lead band (before Details). Overview is the usual case.\n */\n IsLead?: boolean;\n}\n\nexport interface FormChromeSpec {\n Layout: 'accordion' | 'left-nav';\n Groups: FormChromeGroup[];\n /** SectionKey → role for related-entity panels. Field panels are omitted. */\n RelatedRoles: ReadonlyMap<string, FormRole>;\n MoreSectionKeys: string[];\n /**\n * L3 admin Title overlays, keyed by section key or contribution key.\n * First-class group titles are already rewritten; More items and\n * accordion headers read this map so the same override reaches both.\n */\n TitleBySectionKey?: ReadonlyMap<string, string>;\n}\n\n/**\n * True when `sectionKey` sits in the left-nav Details group — the one rail\n * item that shows SEVERAL panels at once (every field panel, plus any\n * contribution registered with `ChromeGroup: 'details'`). The container\n * renders those panels as ONE card (`.mj-chrome-details`, with\n * `-first` / `-last` on the visual edges): no per-section headers, one\n * surface — otherwise the field rows float on the page background.\n */\nexport function IsDetailsSectionKey(spec: Pick<FormChromeSpec, 'Groups'>, sectionKey: string): boolean {\n const details = spec.Groups.find((g) => g.Key === DETAILS_SECTION_KEY);\n return !!details && details.SectionKeys.includes(sectionKey);\n}\n\n/**\n * The visual first and last of the Details panels currently shown. Panels are\n * flex items sequenced by CSS `order` (the form's section display order), so\n * DOM order is not enough — a user who reordered sections would get the card's\n * rounded corners on the wrong panels. Ties keep DOM order (stable sort).\n */\nexport function DetailsCardEdges(\n keysInDomOrder: readonly string[],\n orderOf: (sectionKey: string) => number,\n): { First: string | null; Last: string | null } {\n if (keysInDomOrder.length === 0) return { First: null, Last: null };\n const sorted = keysInDomOrder\n .map((key, index) => ({ key, index, order: orderOf(key) }))\n .sort((a, b) => (a.order - b.order) || (a.index - b.index));\n return { First: sorted[0].key, Last: sorted[sorted.length - 1].key };\n}\n\nexport interface FormChromePanelSnapshot {\n SectionKey: string;\n SectionName: string;\n Variant: string;\n Icon?: string;\n /**\n * The inputs this panel draws, when it draws any. Present so the composition snapshot\n * can name a field a contribution could stand in for; the chrome rules themselves do\n * not read it.\n */\n Fields?: ReadonlyArray<{ Name: string; Label: string }>;\n}\n\nexport const DEFAULT_FORM_CHROME_SPEC: FormChromeSpec = {\n Layout: 'accordion',\n Groups: [],\n RelatedRoles: new Map(),\n MoreSectionKeys: [],\n};\n"]}
@@ -0,0 +1,34 @@
1
+ import type { FormCompositionSnapshot } from './form-composition-snapshot';
2
+ import * as i0 from "@angular/core";
3
+ /** What names one open form: its entity and its record. The compact agent context is one. */
4
+ export interface FormRecordRef {
5
+ Entity: string;
6
+ /** The record as `CompositeKey.ToURLSegment()`; null or blank for a record not saved yet. */
7
+ RecordPrimaryKey: string | null;
8
+ }
9
+ /**
10
+ * The full composition of each form open in this browser, by entity and record.
11
+ *
12
+ * Each record form container publishes its latest snapshot here and removes it when the form goes
13
+ * away. In-browser consumers that need the whole snapshot, such as the apply flow, look it up by
14
+ * the entity and record the compact agent context names. Agent prompts get only that compact
15
+ * context, so the snapshot's fields and rail never reach them.
16
+ */
17
+ export declare class FormCompositionRegistry {
18
+ private readonly entries;
19
+ private sequence;
20
+ /** Records the latest snapshot a form published. One entry per owner, so a newer one replaces it. */
21
+ Publish(owner: object, snapshot: FormCompositionSnapshot): void;
22
+ /** Forgets the snapshot an owner published. */
23
+ Remove(owner: object): void;
24
+ /**
25
+ * The latest snapshot published for this entity and record, or null. The entity name is
26
+ * matched trimmed and case-insensitively; the record key exactly, with null and blank alike.
27
+ */
28
+ Get(entityName: string | null | undefined, recordPrimaryKey: string | null | undefined): FormCompositionSnapshot | null;
29
+ /** The snapshot a reference names, or null when there is no reference or no such form is open. */
30
+ Find(ref: FormRecordRef | null | undefined): FormCompositionSnapshot | null;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormCompositionRegistry, never>;
32
+ static ɵprov: i0.ɵɵInjectableDeclaration<FormCompositionRegistry>;
33
+ }
34
+ //# sourceMappingURL=form-composition-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-composition-registry.d.ts","sourceRoot":"","sources":["../../../src/lib/chrome/form-composition-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;;AAE3E,6FAA6F;AAC7F,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,qBACa,uBAAuB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8E;IACtG,OAAO,CAAC,QAAQ,CAAK;IAErB,qGAAqG;IAC9F,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,uBAAuB,GAAG,IAAI;IAItE,+CAA+C;IACxC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIlC;;;OAGG;IACI,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,uBAAuB,GAAG,IAAI;IAa9H,kGAAkG;IAC3F,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,uBAAuB,GAAG,IAAI;yCAhCzE,uBAAuB;6CAAvB,uBAAuB;CAmCnC"}
@@ -0,0 +1,56 @@
1
+ import { Injectable } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * The full composition of each form open in this browser, by entity and record.
5
+ *
6
+ * Each record form container publishes its latest snapshot here and removes it when the form goes
7
+ * away. In-browser consumers that need the whole snapshot, such as the apply flow, look it up by
8
+ * the entity and record the compact agent context names. Agent prompts get only that compact
9
+ * context, so the snapshot's fields and rail never reach them.
10
+ */
11
+ export class FormCompositionRegistry {
12
+ entries = new Map();
13
+ sequence = 0;
14
+ /** Records the latest snapshot a form published. One entry per owner, so a newer one replaces it. */
15
+ Publish(owner, snapshot) {
16
+ this.entries.set(owner, { Snapshot: snapshot, Sequence: ++this.sequence });
17
+ }
18
+ /** Forgets the snapshot an owner published. */
19
+ Remove(owner) {
20
+ this.entries.delete(owner);
21
+ }
22
+ /**
23
+ * The latest snapshot published for this entity and record, or null. The entity name is
24
+ * matched trimmed and case-insensitively; the record key exactly, with null and blank alike.
25
+ */
26
+ Get(entityName, recordPrimaryKey) {
27
+ const entity = normalizeEntity(entityName);
28
+ if (!entity)
29
+ return null;
30
+ const record = (recordPrimaryKey ?? '').trim();
31
+ let latest = null;
32
+ for (const entry of this.entries.values()) {
33
+ if (normalizeEntity(entry.Snapshot.Entity) !== entity)
34
+ continue;
35
+ if ((entry.Snapshot.RecordPrimaryKey ?? '').trim() !== record)
36
+ continue;
37
+ if (!latest || entry.Sequence > latest.Sequence)
38
+ latest = entry;
39
+ }
40
+ return latest?.Snapshot ?? null;
41
+ }
42
+ /** The snapshot a reference names, or null when there is no reference or no such form is open. */
43
+ Find(ref) {
44
+ return ref ? this.Get(ref.Entity, ref.RecordPrimaryKey) : null;
45
+ }
46
+ static ɵfac = function FormCompositionRegistry_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FormCompositionRegistry)(); };
47
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FormCompositionRegistry, factory: FormCompositionRegistry.ɵfac, providedIn: 'root' });
48
+ }
49
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormCompositionRegistry, [{
50
+ type: Injectable,
51
+ args: [{ providedIn: 'root' }]
52
+ }], null, null); })();
53
+ function normalizeEntity(name) {
54
+ return (name ?? '').trim().toLowerCase();
55
+ }
56
+ //# sourceMappingURL=form-composition-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-composition-registry.js","sourceRoot":"","sources":["../../../src/lib/chrome/form-composition-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAU3C;;;;;;;GAOG;AAEH,MAAM,OAAO,uBAAuB;IACf,OAAO,GAAG,IAAI,GAAG,EAAmE,CAAC;IAC9F,QAAQ,GAAG,CAAC,CAAC;IAErB,qGAAqG;IAC9F,OAAO,CAAC,KAAa,EAAE,QAAiC;QAC3D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,+CAA+C;IACxC,MAAM,CAAC,KAAa;QACvB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,UAAqC,EAAE,gBAA2C;QACzF,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,MAAM,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/C,IAAI,MAAM,GAAmE,IAAI,CAAC;QAClF,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,IAAI,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,MAAM;gBAAE,SAAS;YAChE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM;gBAAE,SAAS;YACxE,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;gBAAE,MAAM,GAAG,KAAK,CAAC;QACpE,CAAC;QACD,OAAO,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC;IACpC,CAAC;IAED,kGAAkG;IAC3F,IAAI,CAAC,GAAqC;QAC7C,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,CAAC;iHAlCQ,uBAAuB;gEAAvB,uBAAuB,WAAvB,uBAAuB,mBADV,MAAM;;iFACnB,uBAAuB;cADnC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;AAsClC,SAAS,eAAe,CAAC,IAA+B;IACpD,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC7C,CAAC","sourcesContent":["import { Injectable } from '@angular/core';\nimport type { FormCompositionSnapshot } from './form-composition-snapshot';\n\n/** What names one open form: its entity and its record. The compact agent context is one. */\nexport interface FormRecordRef {\n Entity: string;\n /** The record as `CompositeKey.ToURLSegment()`; null or blank for a record not saved yet. */\n RecordPrimaryKey: string | null;\n}\n\n/**\n * The full composition of each form open in this browser, by entity and record.\n *\n * Each record form container publishes its latest snapshot here and removes it when the form goes\n * away. In-browser consumers that need the whole snapshot, such as the apply flow, look it up by\n * the entity and record the compact agent context names. Agent prompts get only that compact\n * context, so the snapshot's fields and rail never reach them.\n */\n@Injectable({ providedIn: 'root' })\nexport class FormCompositionRegistry {\n private readonly entries = new Map<object, { Snapshot: FormCompositionSnapshot; Sequence: number }>();\n private sequence = 0;\n\n /** Records the latest snapshot a form published. One entry per owner, so a newer one replaces it. */\n public Publish(owner: object, snapshot: FormCompositionSnapshot): void {\n this.entries.set(owner, { Snapshot: snapshot, Sequence: ++this.sequence });\n }\n\n /** Forgets the snapshot an owner published. */\n public Remove(owner: object): void {\n this.entries.delete(owner);\n }\n\n /**\n * The latest snapshot published for this entity and record, or null. The entity name is\n * matched trimmed and case-insensitively; the record key exactly, with null and blank alike.\n */\n public Get(entityName: string | null | undefined, recordPrimaryKey: string | null | undefined): FormCompositionSnapshot | null {\n const entity = normalizeEntity(entityName);\n if (!entity) return null;\n const record = (recordPrimaryKey ?? '').trim();\n let latest: { Snapshot: FormCompositionSnapshot; Sequence: number } | null = null;\n for (const entry of this.entries.values()) {\n if (normalizeEntity(entry.Snapshot.Entity) !== entity) continue;\n if ((entry.Snapshot.RecordPrimaryKey ?? '').trim() !== record) continue;\n if (!latest || entry.Sequence > latest.Sequence) latest = entry;\n }\n return latest?.Snapshot ?? null;\n }\n\n /** The snapshot a reference names, or null when there is no reference or no such form is open. */\n public Find(ref: FormRecordRef | null | undefined): FormCompositionSnapshot | null {\n return ref ? this.Get(ref.Entity, ref.RecordPrimaryKey) : null;\n }\n}\n\nfunction normalizeEntity(name: string | null | undefined): string {\n return (name ?? '').trim().toLowerCase();\n}\n"]}
@@ -0,0 +1,151 @@
1
+ import type { FormInclusion, FormRole } from '@memberjunction/core';
2
+ import type { FormPanelSlot } from '../panel-slot/base-form-panel';
3
+ import { type FormContributionRegistration, type FormContributionRelationship } from '../panel-slot/form-contribution';
4
+ import type { FormChromeGroup, FormChromePanelSnapshot } from './form-chrome';
5
+ /**
6
+ * What is on this form right now — the input the apply flow needs to add or replace one piece.
7
+ * Built by the container after every chrome resolve and, when it changed, published through
8
+ * `BaseFormComponent.CompositionChanged` and the `FormCompositionRegistry`. It stays in the
9
+ * browser: an agent is handed the compact {@link FormAgentContext} built from it.
10
+ */
11
+ export interface FormCompositionSection {
12
+ Key: string;
13
+ Title: string;
14
+ Variant: string;
15
+ /** Rail group key, or null when the section is not in any first-class group. */
16
+ Group: string | null;
17
+ Hidden: boolean;
18
+ /**
19
+ * The inputs this section draws, so a panel can be offered one field to stand in for.
20
+ * Empty for a section with no fields of its own, such as a related grid.
21
+ */
22
+ Fields: Array<{
23
+ Name: string;
24
+ Label: string;
25
+ }>;
26
+ }
27
+ export interface FormCompositionRelated {
28
+ Entity: string;
29
+ JoinField: string;
30
+ SectionKey: string;
31
+ Inclusion: FormInclusion | 'Auto';
32
+ /** baked = in the template; stock = container fill-in; claimed = a contribution replaced it. */
33
+ Source: 'baked' | 'stock' | 'claimed';
34
+ }
35
+ export interface FormCompositionContribution {
36
+ Key: string;
37
+ Slot: FormPanelSlot;
38
+ Source: 'class' | 'metadata';
39
+ Title: string;
40
+ Presentation: 'panel' | 'bare';
41
+ /** Suppressed by an L3 rule or inclusion None, or hidden by this user. */
42
+ Hidden: boolean;
43
+ /** Last-wins rank; the apply flow uses incumbent + 1 to replace a compiled piece. */
44
+ Precedence: number;
45
+ /** Order among panels in the same slot, higher first. */
46
+ SortKey: number;
47
+ /** The section it is placed in, replacing nothing. */
48
+ InSectionKey?: string;
49
+ /** Where inside its section it draws. */
50
+ SectionPosition?: 'start' | 'end';
51
+ /** Fields it stands in for. */
52
+ FieldNames?: string[];
53
+ /** Blocks it stands in for. */
54
+ SectionKeys?: string[];
55
+ /** True when it stands in for a section, tab or grid. */
56
+ ReplacesPlace?: boolean;
57
+ }
58
+ /** Which form the user sees: the standard form, or one full custom form. */
59
+ export interface FormCompositionChoice {
60
+ /** True when a full custom form owns the whole body, so no section, grid or panel draws. */
61
+ FullCustomForm: boolean;
62
+ /** The `MJ: Entity Form Overrides` row the user sees, or null for the standard form. */
63
+ OverrideID: string | null;
64
+ /** The form's name in the form picker. */
65
+ Label: string;
66
+ }
67
+ export interface FormCompositionSnapshot {
68
+ Entity: string;
69
+ /**
70
+ * The record this composition was built for, as `CompositeKey.ToURLSegment()`, which
71
+ * `CompositeKey.FromURLSegment` reads back. Null for a record not saved yet.
72
+ * `AdditionalContext` is app-global and replaced wholesale by whichever surface
73
+ * published last, so a consumer needs to be able to tell which record a snapshot
74
+ * describes rather than assuming it matches the conversation.
75
+ */
76
+ RecordPrimaryKey: string | null;
77
+ FormChoice: FormCompositionChoice;
78
+ Layout: 'accordion' | 'left-nav';
79
+ Sections: FormCompositionSection[];
80
+ Related: FormCompositionRelated[];
81
+ Contributions: FormCompositionContribution[];
82
+ /** The side rail this form shows, in order, with the panels filed under each item. */
83
+ Rail: FormCompositionRailItem[];
84
+ SlotsPresent: FormPanelSlot[];
85
+ ChromeRuleCount: number;
86
+ }
87
+ /** One rail item, as a consumer outside the form needs it. */
88
+ export interface FormCompositionRailItem {
89
+ Key: string;
90
+ Title: string;
91
+ Icon: string;
92
+ SectionKeys: string[];
93
+ IsMore: boolean;
94
+ }
95
+ export interface BuildFormCompositionSnapshotInput {
96
+ EntityName: string;
97
+ RecordPrimaryKey: string | null;
98
+ FormChoice: FormCompositionChoice;
99
+ Layout: 'accordion' | 'left-nav';
100
+ Groups: readonly FormChromeGroup[];
101
+ /** Every section on the form, the hidden ones included. */
102
+ Panels: readonly FormChromePanelSnapshot[];
103
+ /** The sections in {@link Panels} the form does not show. */
104
+ HiddenSectionKeys: ReadonlySet<string>;
105
+ RelatedEntities: readonly FormContributionRelationship[];
106
+ IsaChildEntityIDs: readonly string[];
107
+ BakedSectionKeys: readonly string[];
108
+ /** Every registration on the form, including the panels this user hid. */
109
+ Registrations: readonly FormContributionRegistration[];
110
+ /** The keys of the panels this user hid. Their registrations are listed, marked hidden. */
111
+ HiddenPanelKeys?: readonly string[];
112
+ /** SectionKey → resolved role for related grids (Primary | Detail). Detail reads as More. */
113
+ RelatedRoles: ReadonlyMap<string, FormRole>;
114
+ HiddenContributionKeys: ReadonlySet<string>;
115
+ SlotsPresent: readonly FormPanelSlot[];
116
+ ChromeRuleCount: number;
117
+ }
118
+ export declare function BuildFormCompositionSnapshot(input: BuildFormCompositionSnapshotInput): FormCompositionSnapshot;
119
+ /** One section of {@link FormAgentContext}. */
120
+ export interface FormAgentContextSection {
121
+ Key: string;
122
+ Title: string;
123
+ Variant: string;
124
+ Hidden: boolean;
125
+ /** The contribution that draws this section or stands in for it, or null when none does. */
126
+ ContributionKey: string | null;
127
+ }
128
+ /**
129
+ * The form the user is looking at, as an agent sees it in `AppContext.AdditionalContext.Form`.
130
+ *
131
+ * Every value of `AdditionalContext` goes into every agent prompt, so this carries only what
132
+ * identifies the form and its sections. The rest (fields, rail, contribution details) stays in
133
+ * the full {@link FormCompositionSnapshot}, which the apply flow reads from the
134
+ * `FormCompositionRegistry`, and the `Get Form Composition For Entity` and
135
+ * `Get Form Contributions For Entity` actions report it to an agent that needs it. Keep field
136
+ * names stable.
137
+ */
138
+ export interface FormAgentContext {
139
+ Entity: string;
140
+ /** The record, as `CompositeKey.ToURLSegment()`; null for a record not saved yet. */
141
+ RecordPrimaryKey: string | null;
142
+ FormChoice: FormCompositionChoice;
143
+ Sections: FormAgentContextSection[];
144
+ }
145
+ /**
146
+ * The compact {@link FormAgentContext} of a snapshot. Only contributions the form draws hold a
147
+ * section: one that is hidden (by the user, or by inclusion `None`) holds none, so the section is
148
+ * reported as the form draws it.
149
+ */
150
+ export declare function BuildFormAgentContext(snapshot: FormCompositionSnapshot): FormAgentContext;
151
+ //# sourceMappingURL=form-composition-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-composition-snapshot.d.ts","sourceRoot":"","sources":["../../../src/lib/chrome/form-composition-snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EASH,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACpC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,aAAa,GAAG,MAAM,CAAC;IAClC,gGAAgG;IAChG,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,2BAA2B;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,0EAA0E;IAC1E,MAAM,EAAE,OAAO,CAAC;IAChB,qFAAqF;IACrF,UAAU,EAAE,MAAM,CAA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AuB,EAAE,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,gBAAgB,CA0BzF"}
@@ -0,0 +1,137 @@
1
+ import { CreateRelatedEntitySectionKeyResolver, RelatedContributionKey, ResolveContributionKey, ReplacedSectionKeys, ResolveFormContributionWinners, ResolveFormContributions, StripJoinFieldBrackets, VisibleFormRelationships, } from '../panel-slot/form-contribution';
2
+ import { IsPanelHiddenByUser } from '../panel-slot/panel-hides';
3
+ function groupOf(groups, sectionKey) {
4
+ return groups.find((g) => !g.IsMore && g.SectionKeys.includes(sectionKey))?.Key ?? null;
5
+ }
6
+ /** A hero (`bare`) or a card (`panel`). `presentation` is the only statement of it, on both sources. */
7
+ function presentationOf(reg) {
8
+ return reg.Presentation ?? reg.Metadata.presentation ?? 'panel';
9
+ }
10
+ /**
11
+ * The contributions on the form, as the server's composition answer lists them: one winner per
12
+ * key among the panels the form draws, then, marked hidden by the caller, the winners among the
13
+ * panels this user hid whose keys no drawn panel holds. A hidden panel is out of the collapse, so
14
+ * a panel it would have outranked holds its key.
15
+ */
16
+ function listedWinners(entityName, drawn, userHidden) {
17
+ const shown = ResolveFormContributionWinners(entityName, drawn).Winners;
18
+ if (userHidden.length === 0)
19
+ return shown;
20
+ const shownKeys = new Set(shown.map((reg) => ResolveContributionKey(reg.Metadata)).filter((key) => !!key));
21
+ const hiddenOnly = ResolveFormContributionWinners(entityName, userHidden).Winners
22
+ .filter((reg) => !shownKeys.has(ResolveContributionKey(reg.Metadata)));
23
+ return [...shown, ...hiddenOnly];
24
+ }
25
+ export function BuildFormCompositionSnapshot(input) {
26
+ const userHidden = new Set(input.HiddenPanelKeys ?? []);
27
+ const isUserHidden = (reg) => IsPanelHiddenByUser(reg, userHidden);
28
+ const drawn = userHidden.size > 0 ? input.Registrations.filter((reg) => !isUserHidden(reg)) : input.Registrations;
29
+ const hiddenByUser = userHidden.size > 0 ? input.Registrations.filter(isUserHidden) : [];
30
+ const resolved = ResolveFormContributions({
31
+ EntityName: input.EntityName,
32
+ RelatedEntities: input.RelatedEntities,
33
+ IsaChildEntityIDs: input.IsaChildEntityIDs,
34
+ Registrations: drawn,
35
+ BakedSectionKeys: input.BakedSectionKeys,
36
+ ShowRelatedEntities: true,
37
+ });
38
+ const stockKeys = new Set(resolved.StockGrids.map((g) => g.ContributionKey));
39
+ const claimedKeys = new Set(resolved.Winners.filter((w) => w.Kind === 'registered' && w.RelatedEntity)
40
+ .map((w) => RelatedContributionKey(w.RelatedEntity, w.RelatedJoinField)));
41
+ const visibleRelated = VisibleFormRelationships(input.RelatedEntities, input.IsaChildEntityIDs);
42
+ const sectionKeyOf = CreateRelatedEntitySectionKeyResolver(visibleRelated);
43
+ const related = visibleRelated.map((rel) => {
44
+ const join = StripJoinFieldBrackets(rel.RelatedEntityJoinField);
45
+ const key = RelatedContributionKey(rel.RelatedEntity, join);
46
+ const sectionKey = sectionKeyOf(rel);
47
+ const role = input.RelatedRoles.get(sectionKey);
48
+ return {
49
+ Entity: rel.RelatedEntity,
50
+ JoinField: join,
51
+ SectionKey: sectionKey,
52
+ Inclusion: role === 'Primary' ? 'Primary' : role === 'Detail' ? 'More' : 'Auto',
53
+ Source: claimedKeys.has(key) ? 'claimed' : stockKeys.has(key) ? 'stock' : 'baked',
54
+ };
55
+ });
56
+ let unique = 0;
57
+ const winners = listedWinners(input.EntityName, drawn, hiddenByUser);
58
+ const contributions = winners.map((reg) => {
59
+ const key = ResolveContributionKey(reg.Metadata) || `__unique:${unique++}`;
60
+ return {
61
+ Key: key,
62
+ Slot: reg.Metadata.slot,
63
+ Source: reg.Source ?? 'class',
64
+ Title: reg.Title ?? reg.Metadata.contributionKey ?? key,
65
+ Presentation: presentationOf(reg),
66
+ Hidden: input.HiddenContributionKeys.has(key) || isUserHidden(reg),
67
+ Precedence: reg.Priority,
68
+ SortKey: reg.Metadata.sortKey ?? 0,
69
+ ...(reg.Metadata.inSectionKey ? { InSectionKey: reg.Metadata.inSectionKey } : {}),
70
+ ...(reg.Metadata.sectionPosition ? { SectionPosition: reg.Metadata.sectionPosition } : {}),
71
+ ...(reg.Metadata.replacesFieldNames?.length ? { FieldNames: [...reg.Metadata.replacesFieldNames] } : {}),
72
+ ...(ReplacedSectionKeys(reg.Metadata).length > 0 ? { SectionKeys: [...ReplacedSectionKeys(reg.Metadata)] } : {}),
73
+ ...(ReplacedSectionKeys(reg.Metadata).length > 0 || reg.Metadata.relatedEntity ? { ReplacesPlace: true } : {}),
74
+ };
75
+ });
76
+ return {
77
+ Entity: input.EntityName,
78
+ RecordPrimaryKey: input.RecordPrimaryKey,
79
+ FormChoice: { ...input.FormChoice },
80
+ Layout: input.Layout,
81
+ Sections: input.Panels.map((p) => ({
82
+ Key: p.SectionKey,
83
+ Title: p.SectionName,
84
+ Variant: p.Variant,
85
+ Group: groupOf(input.Groups, p.SectionKey),
86
+ Hidden: input.HiddenSectionKeys.has(p.SectionKey),
87
+ Fields: (p.Fields ?? []).map((f) => ({ Name: f.Name, Label: f.Label })),
88
+ })),
89
+ Related: related,
90
+ Contributions: contributions,
91
+ Rail: input.Groups.map((group) => ({
92
+ Key: group.Key,
93
+ Title: group.Title,
94
+ Icon: group.Icon,
95
+ SectionKeys: [...group.SectionKeys],
96
+ IsMore: group.IsMore === true,
97
+ })),
98
+ SlotsPresent: [...input.SlotsPresent],
99
+ ChromeRuleCount: input.ChromeRuleCount,
100
+ };
101
+ }
102
+ /**
103
+ * The compact {@link FormAgentContext} of a snapshot. Only contributions the form draws hold a
104
+ * section: one that is hidden (by the user, or by inclusion `None`) holds none, so the section is
105
+ * reported as the form draws it.
106
+ */
107
+ export function BuildFormAgentContext(snapshot) {
108
+ const drawn = snapshot.Contributions.filter((c) => !c.Hidden);
109
+ const contributionKeys = new Set(drawn.map((c) => c.Key));
110
+ const holderBySection = new Map();
111
+ // Weakest claim first, so a stronger one overwrites it: a grid claim, then a block a
112
+ // contribution stands in for, then the contribution's own section.
113
+ for (const rel of snapshot.Related) {
114
+ const key = RelatedContributionKey(rel.Entity, rel.JoinField);
115
+ if (rel.Source === 'claimed' && contributionKeys.has(key))
116
+ holderBySection.set(rel.SectionKey, key);
117
+ }
118
+ for (const c of drawn) {
119
+ for (const sectionKey of c.SectionKeys ?? [])
120
+ holderBySection.set(sectionKey, c.Key);
121
+ }
122
+ for (const key of contributionKeys)
123
+ holderBySection.set(key, key);
124
+ return {
125
+ Entity: snapshot.Entity,
126
+ RecordPrimaryKey: snapshot.RecordPrimaryKey,
127
+ FormChoice: { ...snapshot.FormChoice },
128
+ Sections: snapshot.Sections.map((section) => ({
129
+ Key: section.Key,
130
+ Title: section.Title,
131
+ Variant: section.Variant,
132
+ Hidden: section.Hidden,
133
+ ContributionKey: holderBySection.get(section.Key) ?? null,
134
+ })),
135
+ };
136
+ }
137
+ //# sourceMappingURL=form-composition-snapshot.js.map