@memberjunction/ng-base-forms 6.2.0-edge.1 → 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 (207) 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 +166 -1
  30. package/dist/lib/base-form-component.d.ts.map +1 -1
  31. package/dist/lib/base-form-component.js +296 -20
  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 +261 -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 +1180 -371
  52. package/dist/lib/container/record-form-container.component.js.map +1 -1
  53. package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts +150 -0
  54. package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts.map +1 -0
  55. package/dist/lib/duplicate-entry-check/duplicate-entry-check.js +263 -0
  56. package/dist/lib/duplicate-entry-check/duplicate-entry-check.js.map +1 -0
  57. package/dist/lib/field/form-field.component.d.ts +22 -0
  58. package/dist/lib/field/form-field.component.d.ts.map +1 -1
  59. package/dist/lib/field/form-field.component.js +51 -6
  60. package/dist/lib/field/form-field.component.js.map +1 -1
  61. package/dist/lib/form-field-edit.coordinator.d.ts +25 -0
  62. package/dist/lib/form-field-edit.coordinator.d.ts.map +1 -0
  63. package/dist/lib/form-field-edit.coordinator.js +27 -0
  64. package/dist/lib/form-field-edit.coordinator.js.map +1 -0
  65. package/dist/lib/form-state.service.d.ts +5 -0
  66. package/dist/lib/form-state.service.d.ts.map +1 -1
  67. package/dist/lib/form-state.service.js +6 -1
  68. package/dist/lib/form-state.service.js.map +1 -1
  69. package/dist/lib/host/entity-form-host.component.d.ts +16 -1
  70. package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
  71. package/dist/lib/host/entity-form-host.component.js +27 -6
  72. package/dist/lib/host/entity-form-host.component.js.map +1 -1
  73. package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts +24 -0
  74. package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts.map +1 -0
  75. package/dist/lib/interactive-form/form-panel-host-props.builder.js +99 -0
  76. package/dist/lib/interactive-form/form-panel-host-props.builder.js.map +1 -0
  77. package/dist/lib/interactive-form/interactive-form-panel.component.d.ts +109 -0
  78. package/dist/lib/interactive-form/interactive-form-panel.component.d.ts.map +1 -0
  79. package/dist/lib/interactive-form/interactive-form-panel.component.js +424 -0
  80. package/dist/lib/interactive-form/interactive-form-panel.component.js.map +1 -0
  81. package/dist/lib/interactive-form/interactive-form.component.d.ts +2 -0
  82. package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
  83. package/dist/lib/interactive-form/interactive-form.component.js +4 -5
  84. package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
  85. package/dist/lib/panel/collapsible-panel.component.d.ts +69 -1
  86. package/dist/lib/panel/collapsible-panel.component.d.ts.map +1 -1
  87. package/dist/lib/panel/collapsible-panel.component.js +148 -12
  88. package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
  89. package/dist/lib/panel-manager/form-audience.d.ts +46 -0
  90. package/dist/lib/panel-manager/form-audience.d.ts.map +1 -0
  91. package/dist/lib/panel-manager/form-audience.js +34 -0
  92. package/dist/lib/panel-manager/form-audience.js.map +1 -0
  93. package/dist/lib/panel-manager/form-panel-admin.service.d.ts +150 -0
  94. package/dist/lib/panel-manager/form-panel-admin.service.d.ts.map +1 -0
  95. package/dist/lib/panel-manager/form-panel-admin.service.js +433 -0
  96. package/dist/lib/panel-manager/form-panel-admin.service.js.map +1 -0
  97. package/dist/lib/panel-manager/form-panel-inventory.d.ts +255 -0
  98. package/dist/lib/panel-manager/form-panel-inventory.d.ts.map +1 -0
  99. package/dist/lib/panel-manager/form-panel-inventory.js +293 -0
  100. package/dist/lib/panel-manager/form-panel-inventory.js.map +1 -0
  101. package/dist/lib/panel-manager/panel-manager.component.d.ts +232 -0
  102. package/dist/lib/panel-manager/panel-manager.component.d.ts.map +1 -0
  103. package/dist/lib/panel-manager/panel-manager.component.js +1112 -0
  104. package/dist/lib/panel-manager/panel-manager.component.js.map +1 -0
  105. package/dist/lib/panel-slot/base-contribution-panel.d.ts +40 -0
  106. package/dist/lib/panel-slot/base-contribution-panel.d.ts.map +1 -0
  107. package/dist/lib/panel-slot/base-contribution-panel.js +55 -0
  108. package/dist/lib/panel-slot/base-contribution-panel.js.map +1 -0
  109. package/dist/lib/panel-slot/base-form-panel.d.ts +116 -8
  110. package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
  111. package/dist/lib/panel-slot/base-form-panel.js +76 -5
  112. package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
  113. package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts +29 -0
  114. package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts.map +1 -0
  115. package/dist/lib/panel-slot/collect-form-contribution-registrations.js +214 -0
  116. package/dist/lib/panel-slot/collect-form-contribution-registrations.js.map +1 -0
  117. package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts +6 -3
  118. package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts.map +1 -1
  119. package/dist/lib/panel-slot/collect-form-panel-registrations.js +8 -14
  120. package/dist/lib/panel-slot/collect-form-panel-registrations.js.map +1 -1
  121. package/dist/lib/panel-slot/form-contribution.d.ts +170 -7
  122. package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
  123. package/dist/lib/panel-slot/form-contribution.js +242 -64
  124. package/dist/lib/panel-slot/form-contribution.js.map +1 -1
  125. package/dist/lib/panel-slot/form-contributions.component.d.ts +16 -5
  126. package/dist/lib/panel-slot/form-contributions.component.d.ts.map +1 -1
  127. package/dist/lib/panel-slot/form-contributions.component.js +43 -7
  128. package/dist/lib/panel-slot/form-contributions.component.js.map +1 -1
  129. package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts +66 -0
  130. package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts.map +1 -0
  131. package/dist/lib/panel-slot/form-field-panel-slot.component.js +190 -0
  132. package/dist/lib/panel-slot/form-field-panel-slot.component.js.map +1 -0
  133. package/dist/lib/panel-slot/form-panel-slot.component.d.ts +52 -16
  134. package/dist/lib/panel-slot/form-panel-slot.component.d.ts.map +1 -1
  135. package/dist/lib/panel-slot/form-panel-slot.component.js +190 -66
  136. package/dist/lib/panel-slot/form-panel-slot.component.js.map +1 -1
  137. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +11 -0
  138. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
  139. package/dist/lib/panel-slot/form-slot-coordinator.service.js +17 -0
  140. package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
  141. package/dist/lib/panel-slot/merge-panel-validation.d.ts +7 -0
  142. package/dist/lib/panel-slot/merge-panel-validation.d.ts.map +1 -0
  143. package/dist/lib/panel-slot/merge-panel-validation.js +16 -0
  144. package/dist/lib/panel-slot/merge-panel-validation.js.map +1 -0
  145. package/dist/lib/panel-slot/mount-form-contribution.d.ts +15 -0
  146. package/dist/lib/panel-slot/mount-form-contribution.d.ts.map +1 -0
  147. package/dist/lib/panel-slot/mount-form-contribution.js +37 -0
  148. package/dist/lib/panel-slot/mount-form-contribution.js.map +1 -0
  149. package/dist/lib/panel-slot/panel-hides.d.ts +35 -0
  150. package/dist/lib/panel-slot/panel-hides.d.ts.map +1 -0
  151. package/dist/lib/panel-slot/panel-hides.js +111 -0
  152. package/dist/lib/panel-slot/panel-hides.js.map +1 -0
  153. package/dist/lib/panel-slot/placement-preview-panel.component.d.ts +16 -0
  154. package/dist/lib/panel-slot/placement-preview-panel.component.d.ts.map +1 -0
  155. package/dist/lib/panel-slot/placement-preview-panel.component.js +112 -0
  156. package/dist/lib/panel-slot/placement-preview-panel.component.js.map +1 -0
  157. package/dist/lib/panel-slot/placement-preview.d.ts +57 -0
  158. package/dist/lib/panel-slot/placement-preview.d.ts.map +1 -0
  159. package/dist/lib/panel-slot/placement-preview.js +86 -0
  160. package/dist/lib/panel-slot/placement-preview.js.map +1 -0
  161. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
  162. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
  163. package/dist/lib/panel-slot/related-entity-grid-panel.component.js +10 -3
  164. package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
  165. package/dist/lib/panel-slot/slot-order.d.ts +19 -0
  166. package/dist/lib/panel-slot/slot-order.d.ts.map +1 -0
  167. package/dist/lib/panel-slot/slot-order.js +53 -0
  168. package/dist/lib/panel-slot/slot-order.js.map +1 -0
  169. package/dist/lib/resolver/form-resolver.service.d.ts +4 -2
  170. package/dist/lib/resolver/form-resolver.service.d.ts.map +1 -1
  171. package/dist/lib/resolver/form-resolver.service.js +18 -8
  172. package/dist/lib/resolver/form-resolver.service.js.map +1 -1
  173. package/dist/lib/resolver/form-variants.d.ts +28 -0
  174. package/dist/lib/resolver/form-variants.d.ts.map +1 -0
  175. package/dist/lib/resolver/form-variants.js +40 -0
  176. package/dist/lib/resolver/form-variants.js.map +1 -0
  177. package/dist/lib/section-counts/form-section-counts.d.ts +99 -0
  178. package/dist/lib/section-counts/form-section-counts.d.ts.map +1 -0
  179. package/dist/lib/section-counts/form-section-counts.js +223 -0
  180. package/dist/lib/section-counts/form-section-counts.js.map +1 -0
  181. package/dist/lib/toolbar/form-toolbar.component.d.ts +129 -2
  182. package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
  183. package/dist/lib/toolbar/form-toolbar.component.js +974 -307
  184. package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
  185. package/dist/lib/types/form-events.d.ts +6 -0
  186. package/dist/lib/types/form-events.d.ts.map +1 -1
  187. package/dist/lib/types/form-events.js +6 -0
  188. package/dist/lib/types/form-events.js.map +1 -1
  189. package/dist/lib/types/form-toolbar-item.d.ts +20 -1
  190. package/dist/lib/types/form-toolbar-item.d.ts.map +1 -1
  191. package/dist/lib/types/form-toolbar-item.js.map +1 -1
  192. package/dist/lib/types/form-types.d.ts +13 -0
  193. package/dist/lib/types/form-types.d.ts.map +1 -1
  194. package/dist/lib/types/form-types.js.map +1 -1
  195. package/dist/lib/types/toolbar-config.d.ts +16 -0
  196. package/dist/lib/types/toolbar-config.d.ts.map +1 -1
  197. package/dist/lib/types/toolbar-config.js +3 -0
  198. package/dist/lib/types/toolbar-config.js.map +1 -1
  199. package/dist/module.d.ts +29 -22
  200. package/dist/module.d.ts.map +1 -1
  201. package/dist/module.js +50 -8
  202. package/dist/module.js.map +1 -1
  203. package/dist/public-api.d.ts +22 -0
  204. package/dist/public-api.d.ts.map +1 -1
  205. package/dist/public-api.js +24 -0
  206. package/dist/public-api.js.map +1 -1
  207. package/package.json +20 -18
@@ -0,0 +1,255 @@
1
+ /**
2
+ * @fileoverview What is registered on one entity's form, as something a person can read.
3
+ *
4
+ * The rows behind a form are spread across three places that look nothing alike: a
5
+ * `MJ: Entity Form Contributions` row, a compiled `BaseFormPanel` registration, and a
6
+ * relationship that the container fills in with a stock grid. A user who wants to take a
7
+ * panel off their form should not have to know which of those they are looking at.
8
+ *
9
+ * Everything here is pure. The service loads and writes; this decides what the list says.
10
+ */
11
+ /** Where an item came from, which decides what can be done to it. */
12
+ export type FormPanelOrigin = 'contribution' | 'compiled' | 'stock-grid';
13
+ /**
14
+ * Who an item belongs to, from where the user sits. It decides what they may do: anything to
15
+ * their own, hide what is shared with them, nothing to what a relationship draws.
16
+ */
17
+ export type FormPanelAudience = 'yours' | 'shared' | 'builtin' | 'relationship';
18
+ /**
19
+ * What the item is doing right now. `outranked` is on and still draws nothing: another panel
20
+ * holds its key, or the form does not draw it for this user.
21
+ */
22
+ export type FormPanelState = 'active' | 'draft' | 'off' | 'held' | 'outranked';
23
+ /**
24
+ * Which items draw for the user, as the form resolves them: the winner of each key, with the
25
+ * user's hidden panels left out.
26
+ */
27
+ export interface FormPanelRendering {
28
+ /** Contribution rows that draw, by row ID in lower case. */
29
+ RowIDs: ReadonlySet<string>;
30
+ /** Hide keys of the compiled panels that draw. */
31
+ CompiledKeys: ReadonlySet<string>;
32
+ }
33
+ /** One line in the manager. */
34
+ export interface FormPanelInventoryItem {
35
+ /** Row ID for a contribution; the registration or section key otherwise. */
36
+ ID: string;
37
+ Title: string;
38
+ /** What kind of thing this is, and where it came from. */
39
+ Subtitle: string;
40
+ Origin: FormPanelOrigin;
41
+ /** The slot it mounts at, as stored. Empty for a stock grid. */
42
+ Slot: string;
43
+ /** What it stands in for, in words. Empty when it adds rather than replaces. */
44
+ Replaces: string;
45
+ Presentation: string;
46
+ /** Who it belongs to, from the user's side. */
47
+ Audience: FormPanelAudience;
48
+ /** Who sees it, in words: "Only you", "Sales role", "Everyone", "Built in". */
49
+ AudienceLabel: string;
50
+ State: FormPanelState;
51
+ /** The state in a word, for the label beside the audience. */
52
+ StateLabel: string;
53
+ /** The key a hide is recorded against. Null when the item cannot be hidden. */
54
+ HideKey: string | null;
55
+ /** Whether this user has hidden it. */
56
+ IsHidden: boolean;
57
+ /** An icon for the row, by what the item is. */
58
+ Icon: string;
59
+ /** Only a contribution row can be switched, edited or deleted. */
60
+ CanTurnOn: boolean;
61
+ CanTurnOff: boolean;
62
+ CanRemove: boolean;
63
+ CanEdit: boolean;
64
+ /** Hide it for this user — anything they did not add themselves. */
65
+ CanHide: boolean;
66
+ CanShow: boolean;
67
+ /** Publish their own item to a role or to everyone. Holders of the grant only. */
68
+ CanPublish: boolean;
69
+ /** Re-aim or unpublish an item shared with them. Holders of the grant only. */
70
+ CanChangeAudience: boolean;
71
+ }
72
+ /** A heading in the list, and the rows under it. */
73
+ export interface FormPanelInventoryGroup {
74
+ Key: 'yours' | 'shared' | 'hidden' | 'fixed';
75
+ Title: string;
76
+ /** One line saying what this heading means, for the states that need it. */
77
+ Note: string;
78
+ Items: FormPanelInventoryItem[];
79
+ }
80
+ /** A `MJ: Entity Form Contributions` row, as much of it as the list needs. */
81
+ export interface FormPanelContributionRow {
82
+ ID: string;
83
+ Name: string;
84
+ Title: string | null;
85
+ Icon: string | null;
86
+ Slot: string;
87
+ Presentation: string;
88
+ Status: string;
89
+ Scope: string;
90
+ /** Owner of a personal row; null for one shared with a role or everyone. */
91
+ UserID: string | null;
92
+ RoleID: string | null;
93
+ /** The role's name, for the audience label. */
94
+ Role: string | null;
95
+ ReplacesSectionKey: string | null;
96
+ ReplacesFieldNames: readonly string[];
97
+ /** Sections the panel stands in for, when it names more than one. */
98
+ ReplacesSectionKeys: readonly string[];
99
+ /** A section the panel draws inside, replacing nothing. */
100
+ InSectionKey: string | null;
101
+ /** Where inside its section it draws. Null means the start. */
102
+ SectionPosition: 'start' | 'end' | null;
103
+ RelatedEntity: string | null;
104
+ /** The join field of the grid it replaces, which tells apart two grids of one entity. */
105
+ RelatedJoinField: string | null;
106
+ ChromeGroup: string | null;
107
+ ContributionKey: string | null;
108
+ /** The component the panel renders. */
109
+ ComponentID: string;
110
+ /** Order among panels in the same slot, higher first. */
111
+ SortKey: number;
112
+ /** The row's `Configuration` column, as stored (JSON text), when it was read. */
113
+ Configuration?: string | null;
114
+ }
115
+ /** A full custom form registered on the entity, for the drawer's Form group. */
116
+ export interface FormOverrideRow {
117
+ ID: string;
118
+ Name: string;
119
+ Status: string;
120
+ Scope: string;
121
+ UserID: string | null;
122
+ RoleID: string | null;
123
+ Role: string | null;
124
+ }
125
+ /** A compiled `BaseFormPanel`, which the list shows but cannot change. */
126
+ export interface FormPanelCompiledRow {
127
+ Key: string;
128
+ Title: string;
129
+ Slot: string;
130
+ /** The key a hide is recorded against. Null when the panel has no stable identity. */
131
+ HideKey: string | null;
132
+ }
133
+ /** A relationship the container fills a grid in for. */
134
+ export interface FormPanelStockGridRow {
135
+ SectionKey: string;
136
+ DisplayName: string;
137
+ }
138
+ export interface FormPanelInventoryInput {
139
+ Contributions: readonly FormPanelContributionRow[];
140
+ Compiled: readonly FormPanelCompiledRow[];
141
+ StockGrids: readonly FormPanelStockGridRow[];
142
+ /**
143
+ * Whether a full custom form is drawing this entity. It owns the whole body, so
144
+ * everything else is stored and rendered for nobody — which the list has to say, or a
145
+ * user turning a panel on and seeing nothing has no way to find out why.
146
+ */
147
+ FullCustomForm: boolean;
148
+ /** Titles by rail key and section key, so "what it replaces" reads as a name. */
149
+ TitleByKey?: ReadonlyMap<string, string>;
150
+ /** The user looking at the list. Decides what is "yours". */
151
+ CallerID: string;
152
+ /** The user's roles. A role item is listed only when it is shared with one of them. */
153
+ CallerRoleIDs: readonly string[];
154
+ /** Whether the user holds the grant to publish to a role or to everyone. */
155
+ CanPublish: boolean;
156
+ /** Keys this user has hidden on this entity. */
157
+ HiddenKeys: readonly string[];
158
+ /** Which items draw for this user. Without it, every item that is on is taken to draw. */
159
+ Rendering?: FormPanelRendering;
160
+ }
161
+ /**
162
+ * A row's `Configuration` text as an object, or undefined when it is empty, not JSON, or not
163
+ * a JSON object.
164
+ */
165
+ export declare function ParseContributionConfiguration(text: string | null | undefined): Record<string, unknown> | undefined;
166
+ /**
167
+ * What a contribution stands in for, named the way the user chose it.
168
+ *
169
+ * A key is not a name. `__mj_form_details` is the Details tab and `contactMethods` is
170
+ * whatever that section is titled, and a list that printed the keys would be a list of
171
+ * things the user never typed.
172
+ */
173
+ export declare function DescribeReplacement(row: Pick<FormPanelContributionRow, 'ReplacesSectionKey' | 'ReplacesFieldNames' | 'RelatedEntity'> & Partial<Pick<FormPanelContributionRow, 'ReplacesSectionKeys'>>, titleByKey?: ReadonlyMap<string, string>): string;
174
+ /**
175
+ * Who sees an item, in words.
176
+ *
177
+ * Names the role rather than saying "a role": someone reading their form wants to know which
178
+ * group of people a panel was put in front of, and the role's name is the answer.
179
+ */
180
+ export declare function DescribeAudience(scope: string, roleName?: string | null): string;
181
+ /** A state in a word, for the label beside the audience. */
182
+ export declare function DescribeState(state: FormPanelState): string;
183
+ /**
184
+ * Whether the list shows this contribution to this user.
185
+ *
186
+ * The user's role can read every row, so the list has to decide what belongs in front of them:
187
+ * their own, what is shared with one of their roles, and what is shared with everyone. Another
188
+ * person's personal panel, or one aimed at a role they are not in, is not theirs to see here.
189
+ */
190
+ export declare function IsListedFor(row: Pick<FormPanelContributionRow, 'Scope' | 'UserID' | 'RoleID'>, callerID: string, callerRoleIDs: readonly string[]): boolean;
191
+ /**
192
+ * What state a contribution is in.
193
+ *
194
+ * `held` and `outranked` are the cases worth separating: the row is Active and correct, and
195
+ * still renders nothing — because a full custom form owns the body, or because another panel
196
+ * wins its key. Reporting either as Active would be true of the row and false of the form.
197
+ *
198
+ * @param draws Whether the form draws the row, from {@link FormPanelRendering}.
199
+ */
200
+ export declare function ContributionState(status: string, fullCustomForm: boolean, draws?: boolean): FormPanelState;
201
+ /**
202
+ * Everything on this form that concerns this user, contributions first.
203
+ *
204
+ * Their own contributions lead because they can do anything to them. What is shared with them
205
+ * follows — published panels and panels shipped in code — which they can hide. Grids drawn from
206
+ * a relationship come last; they are listed so the form's contents are accounted for, and offer
207
+ * no button that would not work.
208
+ */
209
+ export declare function BuildPanelInventory(input: FormPanelInventoryInput): FormPanelInventoryItem[];
210
+ /** The count line under the list: how much is registered, and how much of it renders for this user. */
211
+ export declare function SummarizeInventory(items: readonly FormPanelInventoryItem[]): string;
212
+ /**
213
+ * The list broken into headed groups, by who each item belongs to.
214
+ *
215
+ * Grouped by audience rather than by state because audience now decides what a user may do: they
216
+ * can remove their own, but only hide something shared with them. State becomes a label on each
217
+ * row. Hidden items get their own group so a hide can always be undone. Empty groups are dropped.
218
+ */
219
+ export declare function GroupPanelInventory(items: readonly FormPanelInventoryItem[]): FormPanelInventoryGroup[];
220
+ /** One full custom form in the drawer's Form group, or the generated form. */
221
+ export interface FormPanelFormItem {
222
+ /** The override's ID; null for the generated form. */
223
+ ID: string | null;
224
+ Title: string;
225
+ AudienceLabel: string;
226
+ /** The form this user sees now. */
227
+ IsCurrent: boolean;
228
+ /** Whether it belongs to this user alone. */
229
+ IsYours: boolean;
230
+ /** Publish this user's own form. Holders of the grant only. */
231
+ CanPublish: boolean;
232
+ /** Re-aim or unpublish a form shared with this user. Holders of the grant only. */
233
+ CanChangeAudience: boolean;
234
+ }
235
+ export interface FormPanelFormInput {
236
+ /** The forms the toolbar picker offers, in its order. */
237
+ Variants: ReadonlyArray<{
238
+ ID: string;
239
+ Label: string;
240
+ }>;
241
+ /** Every form registered on the entity, for each one's audience. */
242
+ Overrides: readonly FormOverrideRow[];
243
+ /** The form this user sees now; null when it is the generated form. */
244
+ CurrentFormID: string | null;
245
+ CanPublish: boolean;
246
+ }
247
+ /**
248
+ * The full custom forms available to this user, and the generated form.
249
+ *
250
+ * Built from the toolbar picker's own list so the two cannot disagree about which forms exist.
251
+ * The generated form is listed too: stepping back to it is a choice like any other, and the only
252
+ * way to see a panel on an entity whose custom form draws its whole body.
253
+ */
254
+ export declare function BuildFormItems(input: FormPanelFormInput): FormPanelFormItem[];
255
+ //# sourceMappingURL=form-panel-inventory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-panel-inventory.d.ts","sourceRoot":"","sources":["../../../src/lib/panel-manager/form-panel-inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,qEAAqE;AACrE,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC;AAEzE;;;G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/B,KAAK,EAAE,SAAS,sBAAsB,EAAE,GACzC,uBAAuB,EAAE,CAsB3B;AAED,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAC9B,sDAAsD;IACtD,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,UAAU,EAAE,OAAO,CAAC;IACpB,mFAAmF;IACnF,iBAAiB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IAC/B,yDAAyD;IACzD,QAAQ,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,oEAAoE;IACpE,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,uEAAuE;IACvE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,kBAAkB,GAAG,iBAAiB,EAAE,CA0B7E"}
@@ -0,0 +1,293 @@
1
+ /**
2
+ * @fileoverview What is registered on one entity's form, as something a person can read.
3
+ *
4
+ * The rows behind a form are spread across three places that look nothing alike: a
5
+ * `MJ: Entity Form Contributions` row, a compiled `BaseFormPanel` registration, and a
6
+ * relationship that the container fills in with a stock grid. A user who wants to take a
7
+ * panel off their form should not have to know which of those they are looking at.
8
+ *
9
+ * Everything here is pure. The service loads and writes; this decides what the list says.
10
+ */
11
+ import { SafeJSONParse } from '@memberjunction/global';
12
+ import { DETAILS_SECTION_KEY, MORE_SECTION_KEY } from '../chrome/form-chrome';
13
+ /**
14
+ * A row's `Configuration` text as an object, or undefined when it is empty, not JSON, or not
15
+ * a JSON object.
16
+ */
17
+ export function ParseContributionConfiguration(text) {
18
+ const parsed = SafeJSONParse(text ?? '', false);
19
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : undefined;
20
+ }
21
+ /**
22
+ * What a contribution stands in for, named the way the user chose it.
23
+ *
24
+ * A key is not a name. `__mj_form_details` is the Details tab and `contactMethods` is
25
+ * whatever that section is titled, and a list that printed the keys would be a list of
26
+ * things the user never typed.
27
+ */
28
+ export function DescribeReplacement(row, titleByKey) {
29
+ const related = (row.RelatedEntity ?? '').trim();
30
+ if (related)
31
+ return `the ${related} grid`;
32
+ const sections = row.ReplacesSectionKeys ?? [];
33
+ if (sections.length > 1) {
34
+ const titles = sections.map((key) => titleByKey?.get(key) ?? key);
35
+ return `the ${titles.slice(0, -1).join(', ')} and ${titles[titles.length - 1]} sections`;
36
+ }
37
+ const fields = row.ReplacesFieldNames ?? [];
38
+ if (fields.length === 1)
39
+ return `the ${titleByKey?.get(fields[0]) ?? fields[0]} field`;
40
+ if (fields.length > 1)
41
+ return `${fields.length} fields`;
42
+ const key = (row.ReplacesSectionKey ?? '').trim();
43
+ if (!key)
44
+ return '';
45
+ if (key === DETAILS_SECTION_KEY)
46
+ return 'the whole Details tab';
47
+ if (key === MORE_SECTION_KEY)
48
+ return 'the whole More tab';
49
+ const title = titleByKey?.get(key);
50
+ return title ? `the ${title} section` : `the "${key}" section`;
51
+ }
52
+ /**
53
+ * Who sees an item, in words.
54
+ *
55
+ * Names the role rather than saying "a role": someone reading their form wants to know which
56
+ * group of people a panel was put in front of, and the role's name is the answer.
57
+ */
58
+ export function DescribeAudience(scope, roleName) {
59
+ if (scope === 'Role')
60
+ return roleName ? `${roleName} role` : 'A role';
61
+ if (scope === 'Global')
62
+ return 'Everyone';
63
+ return 'Only you';
64
+ }
65
+ /** A state in a word, for the label beside the audience. */
66
+ export function DescribeState(state) {
67
+ if (state === 'active')
68
+ return 'on';
69
+ if (state === 'held')
70
+ return 'held back';
71
+ if (state === 'outranked')
72
+ return 'not shown';
73
+ if (state === 'draft')
74
+ return 'draft';
75
+ return 'off';
76
+ }
77
+ /**
78
+ * Whether the list shows this contribution to this user.
79
+ *
80
+ * The user's role can read every row, so the list has to decide what belongs in front of them:
81
+ * their own, what is shared with one of their roles, and what is shared with everyone. Another
82
+ * person's personal panel, or one aimed at a role they are not in, is not theirs to see here.
83
+ */
84
+ export function IsListedFor(row, callerID, callerRoleIDs) {
85
+ const same = (a, b) => (a ?? '').trim().toLowerCase() === b.trim().toLowerCase();
86
+ if (row.Scope === 'User')
87
+ return same(row.UserID, callerID);
88
+ if (row.Scope === 'Role')
89
+ return callerRoleIDs.some((roleID) => same(row.RoleID, roleID));
90
+ return row.Scope === 'Global';
91
+ }
92
+ /**
93
+ * What state a contribution is in.
94
+ *
95
+ * `held` and `outranked` are the cases worth separating: the row is Active and correct, and
96
+ * still renders nothing — because a full custom form owns the body, or because another panel
97
+ * wins its key. Reporting either as Active would be true of the row and false of the form.
98
+ *
99
+ * @param draws Whether the form draws the row, from {@link FormPanelRendering}.
100
+ */
101
+ export function ContributionState(status, fullCustomForm, draws = true) {
102
+ if (status === 'Pending')
103
+ return 'draft';
104
+ if (status !== 'Active')
105
+ return 'off';
106
+ if (fullCustomForm)
107
+ return 'held';
108
+ return draws ? 'active' : 'outranked';
109
+ }
110
+ /**
111
+ * Everything on this form that concerns this user, contributions first.
112
+ *
113
+ * Their own contributions lead because they can do anything to them. What is shared with them
114
+ * follows — published panels and panels shipped in code — which they can hide. Grids drawn from
115
+ * a relationship come last; they are listed so the form's contents are accounted for, and offer
116
+ * no button that would not work.
117
+ */
118
+ export function BuildPanelInventory(input) {
119
+ const hidden = new Set(input.HiddenKeys);
120
+ const out = [];
121
+ for (const row of input.Contributions) {
122
+ if (!IsListedFor(row, input.CallerID, input.CallerRoleIDs))
123
+ continue;
124
+ out.push(contributionItem(row, input, hidden));
125
+ }
126
+ for (const row of input.Compiled)
127
+ out.push(compiledItem(row, input, hidden));
128
+ for (const row of input.StockGrids)
129
+ out.push(stockGridItem(row, input));
130
+ return out;
131
+ }
132
+ function contributionItem(row, input, hidden) {
133
+ const yours = row.Scope === 'User';
134
+ const hideKey = yours ? null : (row.ContributionKey ?? '').trim() || null;
135
+ const isHidden = !!hideKey && hidden.has(hideKey);
136
+ // A hidden panel is listed under Hidden, so its state says what it does for everyone else.
137
+ const draws = isHidden || !input.Rendering || input.Rendering.RowIDs.has(row.ID.toLowerCase());
138
+ const state = ContributionState(row.Status, input.FullCustomForm, draws);
139
+ return {
140
+ ID: row.ID,
141
+ Title: (row.Title ?? '').trim() || row.Name,
142
+ Subtitle: `${row.Presentation === 'bare' ? 'bare strip' : 'panel'} · ${yours ? 'added by you' : 'shared with you'}`,
143
+ Origin: 'contribution',
144
+ Slot: row.Slot,
145
+ Replaces: DescribeReplacement(row, input.TitleByKey),
146
+ Presentation: row.Presentation === 'bare' ? 'Bare' : 'Panel',
147
+ Audience: yours ? 'yours' : 'shared',
148
+ AudienceLabel: DescribeAudience(row.Scope, row.Role),
149
+ State: state,
150
+ StateLabel: DescribeState(state),
151
+ HideKey: hideKey,
152
+ IsHidden: isHidden,
153
+ Icon: row.Presentation === 'bare' ? 'fa-solid fa-minus' : 'fa-solid fa-puzzle-piece',
154
+ // Turning on and off changes the row for everyone it reaches, so on a shared item it is
155
+ // a holder's act; hiding is the per-user switch instead.
156
+ CanTurnOn: (yours || input.CanPublish) && (state === 'draft' || state === 'off'),
157
+ CanTurnOff: (yours || input.CanPublish) && (state === 'active' || state === 'held' || state === 'outranked'),
158
+ CanRemove: yours || input.CanPublish,
159
+ CanEdit: yours || input.CanPublish,
160
+ CanHide: !!hideKey && !isHidden,
161
+ CanShow: isHidden,
162
+ CanPublish: yours && input.CanPublish,
163
+ CanChangeAudience: !yours && input.CanPublish,
164
+ };
165
+ }
166
+ function compiledItem(row, input, hidden) {
167
+ const isHidden = !!row.HideKey && hidden.has(row.HideKey);
168
+ // A panel with no hide key has no key to lose, so it always draws.
169
+ const draws = isHidden || !input.Rendering || !row.HideKey || input.Rendering.CompiledKeys.has(row.HideKey);
170
+ const state = input.FullCustomForm ? 'held' : draws ? 'active' : 'outranked';
171
+ return {
172
+ ID: row.Key,
173
+ Title: row.Title || row.Key,
174
+ Subtitle: 'panel · built into this app',
175
+ Origin: 'compiled',
176
+ Slot: row.Slot,
177
+ Replaces: '',
178
+ Presentation: 'Panel',
179
+ Audience: 'builtin',
180
+ AudienceLabel: 'Built in',
181
+ State: state,
182
+ StateLabel: DescribeState(state),
183
+ HideKey: row.HideKey,
184
+ IsHidden: isHidden,
185
+ Icon: 'fa-solid fa-code',
186
+ CanTurnOn: false,
187
+ CanTurnOff: false,
188
+ CanRemove: false,
189
+ CanEdit: false,
190
+ CanHide: !!row.HideKey && !isHidden,
191
+ CanShow: isHidden,
192
+ CanPublish: false,
193
+ CanChangeAudience: false,
194
+ };
195
+ }
196
+ function stockGridItem(row, input) {
197
+ const state = input.FullCustomForm ? 'held' : 'active';
198
+ return {
199
+ ID: row.SectionKey,
200
+ Title: row.DisplayName,
201
+ Subtitle: 'automatic grid · from the relationship',
202
+ Origin: 'stock-grid',
203
+ Slot: '',
204
+ Replaces: '',
205
+ Presentation: 'Panel',
206
+ Audience: 'relationship',
207
+ AudienceLabel: 'From a relationship',
208
+ State: state,
209
+ StateLabel: DescribeState(state),
210
+ HideKey: null,
211
+ IsHidden: false,
212
+ Icon: 'fa-solid fa-table',
213
+ CanTurnOn: false,
214
+ CanTurnOff: false,
215
+ CanRemove: false,
216
+ CanEdit: false,
217
+ CanHide: false,
218
+ CanShow: false,
219
+ CanPublish: false,
220
+ CanChangeAudience: false,
221
+ };
222
+ }
223
+ /** The count line under the list: how much is registered, and how much of it renders for this user. */
224
+ export function SummarizeInventory(items) {
225
+ const total = items.length;
226
+ const showing = items.filter((item) => item.State === 'active' && !item.IsHidden).length;
227
+ const noun = total === 1 ? 'thing' : 'things';
228
+ return `${total} ${noun} registered on this form · ${showing} rendering`;
229
+ }
230
+ /**
231
+ * The list broken into headed groups, by who each item belongs to.
232
+ *
233
+ * Grouped by audience rather than by state because audience now decides what a user may do: they
234
+ * can remove their own, but only hide something shared with them. State becomes a label on each
235
+ * row. Hidden items get their own group so a hide can always be undone. Empty groups are dropped.
236
+ */
237
+ export function GroupPanelInventory(items) {
238
+ const groups = [
239
+ {
240
+ Key: 'yours', Title: 'Yours', Note: '',
241
+ Items: items.filter((i) => i.Audience === 'yours'),
242
+ },
243
+ {
244
+ Key: 'shared', Title: 'Shared with you',
245
+ Note: 'Put on this form for your role, for everyone, or by the app. Hide any of them for yourself.',
246
+ Items: items.filter((i) => (i.Audience === 'shared' || i.Audience === 'builtin') && !i.IsHidden),
247
+ },
248
+ {
249
+ Key: 'hidden', Title: 'Hidden by you', Note: 'Still there for everyone else. Show one to put it back.',
250
+ Items: items.filter((i) => i.IsHidden),
251
+ },
252
+ {
253
+ Key: 'fixed', Title: 'Part of the form itself',
254
+ Note: 'Drawn from a relationship. Not yours to change here.',
255
+ Items: items.filter((i) => i.Audience === 'relationship'),
256
+ },
257
+ ];
258
+ return groups.filter((group) => group.Items.length > 0);
259
+ }
260
+ /**
261
+ * The full custom forms available to this user, and the generated form.
262
+ *
263
+ * Built from the toolbar picker's own list so the two cannot disagree about which forms exist.
264
+ * The generated form is listed too: stepping back to it is a choice like any other, and the only
265
+ * way to see a panel on an entity whose custom form draws its whole body.
266
+ */
267
+ export function BuildFormItems(input) {
268
+ const same = (a, b) => (a ?? '').trim().toLowerCase() === (b ?? '').trim().toLowerCase();
269
+ const items = input.Variants.map((variant) => {
270
+ const row = input.Overrides.find((o) => same(o.ID, variant.ID));
271
+ const yours = (row?.Scope ?? 'User') === 'User';
272
+ return {
273
+ ID: variant.ID,
274
+ Title: variant.Label,
275
+ AudienceLabel: DescribeAudience(row?.Scope ?? 'User', row?.Role),
276
+ IsCurrent: same(variant.ID, input.CurrentFormID),
277
+ IsYours: yours,
278
+ CanPublish: yours && input.CanPublish,
279
+ CanChangeAudience: !yours && input.CanPublish,
280
+ };
281
+ });
282
+ items.push({
283
+ ID: null,
284
+ Title: 'Generated form',
285
+ AudienceLabel: 'Built in',
286
+ IsCurrent: !input.CurrentFormID,
287
+ IsYours: false,
288
+ CanPublish: false,
289
+ CanChangeAudience: false,
290
+ });
291
+ return items;
292
+ }
293
+ //# sourceMappingURL=form-panel-inventory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-panel-inventory.js","sourceRoot":"","sources":["../../../src/lib/panel-manager/form-panel-inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAmK9E;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAA+B;IAC1E,MAAM,MAAM,GAAG,aAAa,CAAU,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAiC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1H,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAC/B,GACoE,EACpE,UAAwC;IAExC,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,OAAO;QAAE,OAAO,OAAO,OAAO,OAAO,CAAC;IAE1C,MAAM,QAAQ,GAAG,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC;IAC/C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAA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,UAAU;SAChD,CAAC;IACN,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,CAAC;QACP,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,gBAAgB;QACvB,aAAa,EAAE,UAAU;QACzB,SAAS,EAAE,CAAC,KAAK,CAAC,aAAa;QAC/B,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,KAAK;QACjB,iBAAiB,EAAE,KAAK;KAC3B,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/**\n * @fileoverview What is registered on one entity's form, as something a person can read.\n *\n * The rows behind a form are spread across three places that look nothing alike: a\n * `MJ: Entity Form Contributions` row, a compiled `BaseFormPanel` registration, and a\n * relationship that the container fills in with a stock grid. A user who wants to take a\n * panel off their form should not have to know which of those they are looking at.\n *\n * Everything here is pure. The service loads and writes; this decides what the list says.\n */\n\nimport { SafeJSONParse } from '@memberjunction/global';\nimport { DETAILS_SECTION_KEY, MORE_SECTION_KEY } from '../chrome/form-chrome';\n\n/** Where an item came from, which decides what can be done to it. */\nexport type FormPanelOrigin = 'contribution' | 'compiled' | 'stock-grid';\n\n/**\n * Who an item belongs to, from where the user sits. It decides what they may do: anything to\n * their own, hide what is shared with them, nothing to what a relationship draws.\n */\nexport type FormPanelAudience = 'yours' | 'shared' | 'builtin' | 'relationship';\n\n/**\n * What the item is doing right now. `outranked` is on and still draws nothing: another panel\n * holds its key, or the form does not draw it for this user.\n */\nexport type FormPanelState = 'active' | 'draft' | 'off' | 'held' | 'outranked';\n\n/**\n * Which items draw for the user, as the form resolves them: the winner of each key, with the\n * user's hidden panels left out.\n */\nexport interface FormPanelRendering {\n /** Contribution rows that draw, by row ID in lower case. */\n RowIDs: ReadonlySet<string>;\n /** Hide keys of the compiled panels that draw. */\n CompiledKeys: ReadonlySet<string>;\n}\n\n/** One line in the manager. */\nexport interface FormPanelInventoryItem {\n /** Row ID for a contribution; the registration or section key otherwise. */\n ID: string;\n Title: string;\n /** What kind of thing this is, and where it came from. */\n Subtitle: string;\n Origin: FormPanelOrigin;\n /** The slot it mounts at, as stored. Empty for a stock grid. */\n Slot: string;\n /** What it stands in for, in words. Empty when it adds rather than replaces. */\n Replaces: string;\n Presentation: string;\n /** Who it belongs to, from the user's side. */\n Audience: FormPanelAudience;\n /** Who sees it, in words: \"Only you\", \"Sales role\", \"Everyone\", \"Built in\". */\n AudienceLabel: string;\n State: FormPanelState;\n /** The state in a word, for the label beside the audience. */\n StateLabel: string;\n /** The key a hide is recorded against. Null when the item cannot be hidden. */\n HideKey: string | null;\n /** Whether this user has hidden it. */\n IsHidden: boolean;\n /** An icon for the row, by what the item is. */\n Icon: string;\n /** Only a contribution row can be switched, edited or deleted. */\n CanTurnOn: boolean;\n CanTurnOff: boolean;\n CanRemove: boolean;\n CanEdit: boolean;\n /** Hide it for this user — anything they did not add themselves. */\n CanHide: boolean;\n CanShow: boolean;\n /** Publish their own item to a role or to everyone. Holders of the grant only. */\n CanPublish: boolean;\n /** Re-aim or unpublish an item shared with them. Holders of the grant only. */\n CanChangeAudience: boolean;\n}\n\n/** A heading in the list, and the rows under it. */\nexport interface FormPanelInventoryGroup {\n Key: 'yours' | 'shared' | 'hidden' | 'fixed';\n Title: string;\n /** One line saying what this heading means, for the states that need it. */\n Note: string;\n Items: FormPanelInventoryItem[];\n}\n\n/** A `MJ: Entity Form Contributions` row, as much of it as the list needs. */\nexport interface FormPanelContributionRow {\n ID: string;\n Name: string;\n Title: string | null;\n Icon: string | null;\n Slot: string;\n Presentation: string;\n Status: string;\n Scope: string;\n /** Owner of a personal row; null for one shared with a role or everyone. */\n UserID: string | null;\n RoleID: string | null;\n /** The role's name, for the audience label. */\n Role: string | null;\n ReplacesSectionKey: string | null;\n ReplacesFieldNames: readonly string[];\n /** Sections the panel stands in for, when it names more than one. */\n ReplacesSectionKeys: readonly string[];\n /** A section the panel draws inside, replacing nothing. */\n InSectionKey: string | null;\n /** Where inside its section it draws. Null means the start. */\n SectionPosition: 'start' | 'end' | null;\n RelatedEntity: string | null;\n /** The join field of the grid it replaces, which tells apart two grids of one entity. */\n RelatedJoinField: string | null;\n ChromeGroup: string | null;\n ContributionKey: string | null;\n /** The component the panel renders. */\n ComponentID: string;\n /** Order among panels in the same slot, higher first. */\n SortKey: number;\n /** The row's `Configuration` column, as stored (JSON text), when it was read. */\n Configuration?: string | null;\n}\n\n/** A full custom form registered on the entity, for the drawer's Form group. */\nexport interface FormOverrideRow {\n ID: string;\n Name: string;\n Status: string;\n Scope: string;\n UserID: string | null;\n RoleID: string | null;\n Role: string | null;\n}\n\n/** A compiled `BaseFormPanel`, which the list shows but cannot change. */\nexport interface FormPanelCompiledRow {\n Key: string;\n Title: string;\n Slot: string;\n /** The key a hide is recorded against. Null when the panel has no stable identity. */\n HideKey: string | null;\n}\n\n/** A relationship the container fills a grid in for. */\nexport interface FormPanelStockGridRow {\n SectionKey: string;\n DisplayName: string;\n}\n\nexport interface FormPanelInventoryInput {\n Contributions: readonly FormPanelContributionRow[];\n Compiled: readonly FormPanelCompiledRow[];\n StockGrids: readonly FormPanelStockGridRow[];\n /**\n * Whether a full custom form is drawing this entity. It owns the whole body, so\n * everything else is stored and rendered for nobody — which the list has to say, or a\n * user turning a panel on and seeing nothing has no way to find out why.\n */\n FullCustomForm: boolean;\n /** Titles by rail key and section key, so \"what it replaces\" reads as a name. */\n TitleByKey?: ReadonlyMap<string, string>;\n /** The user looking at the list. Decides what is \"yours\". */\n CallerID: string;\n /** The user's roles. A role item is listed only when it is shared with one of them. */\n CallerRoleIDs: readonly string[];\n /** Whether the user holds the grant to publish to a role or to everyone. */\n CanPublish: boolean;\n /** Keys this user has hidden on this entity. */\n HiddenKeys: readonly string[];\n /** Which items draw for this user. Without it, every item that is on is taken to draw. */\n Rendering?: FormPanelRendering;\n}\n\n/**\n * A row's `Configuration` text as an object, or undefined when it is empty, not JSON, or not\n * a JSON object.\n */\nexport function ParseContributionConfiguration(text: string | null | undefined): Record<string, unknown> | undefined {\n const parsed = SafeJSONParse<unknown>(text ?? '', false);\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed as Record<string, unknown> : undefined;\n}\n\n/**\n * What a contribution stands in for, named the way the user chose it.\n *\n * A key is not a name. `__mj_form_details` is the Details tab and `contactMethods` is\n * whatever that section is titled, and a list that printed the keys would be a list of\n * things the user never typed.\n */\nexport function DescribeReplacement(\n row: Pick<FormPanelContributionRow, 'ReplacesSectionKey' | 'ReplacesFieldNames' | 'RelatedEntity'>\n & Partial<Pick<FormPanelContributionRow, 'ReplacesSectionKeys'>>,\n titleByKey?: ReadonlyMap<string, string>,\n): string {\n const related = (row.RelatedEntity ?? '').trim();\n if (related) return `the ${related} grid`;\n\n const sections = row.ReplacesSectionKeys ?? [];\n if (sections.length > 1) {\n const titles = sections.map((key) => titleByKey?.get(key) ?? key);\n return `the ${titles.slice(0, -1).join(', ')} and ${titles[titles.length - 1]} sections`;\n }\n\n const fields = row.ReplacesFieldNames ?? [];\n if (fields.length === 1) return `the ${titleByKey?.get(fields[0]) ?? fields[0]} field`;\n if (fields.length > 1) return `${fields.length} fields`;\n\n const key = (row.ReplacesSectionKey ?? '').trim();\n if (!key) return '';\n if (key === DETAILS_SECTION_KEY) return 'the whole Details tab';\n if (key === MORE_SECTION_KEY) return 'the whole More tab';\n const title = titleByKey?.get(key);\n return title ? `the ${title} section` : `the \"${key}\" section`;\n}\n\n/**\n * Who sees an item, in words.\n *\n * Names the role rather than saying \"a role\": someone reading their form wants to know which\n * group of people a panel was put in front of, and the role's name is the answer.\n */\nexport function DescribeAudience(scope: string, roleName?: string | null): string {\n if (scope === 'Role') return roleName ? `${roleName} role` : 'A role';\n if (scope === 'Global') return 'Everyone';\n return 'Only you';\n}\n\n/** A state in a word, for the label beside the audience. */\nexport function DescribeState(state: FormPanelState): string {\n if (state === 'active') return 'on';\n if (state === 'held') return 'held back';\n if (state === 'outranked') return 'not shown';\n if (state === 'draft') return 'draft';\n return 'off';\n}\n\n/**\n * Whether the list shows this contribution to this user.\n *\n * The user's role can read every row, so the list has to decide what belongs in front of them:\n * their own, what is shared with one of their roles, and what is shared with everyone. Another\n * person's personal panel, or one aimed at a role they are not in, is not theirs to see here.\n */\nexport function IsListedFor(\n row: Pick<FormPanelContributionRow, 'Scope' | 'UserID' | 'RoleID'>,\n callerID: string,\n callerRoleIDs: readonly string[],\n): boolean {\n const same = (a: string | null | undefined, b: string): boolean =>\n (a ?? '').trim().toLowerCase() === b.trim().toLowerCase();\n if (row.Scope === 'User') return same(row.UserID, callerID);\n if (row.Scope === 'Role') return callerRoleIDs.some((roleID) => same(row.RoleID, roleID));\n return row.Scope === 'Global';\n}\n\n/**\n * What state a contribution is in.\n *\n * `held` and `outranked` are the cases worth separating: the row is Active and correct, and\n * still renders nothing — because a full custom form owns the body, or because another panel\n * wins its key. Reporting either as Active would be true of the row and false of the form.\n *\n * @param draws Whether the form draws the row, from {@link FormPanelRendering}.\n */\nexport function ContributionState(status: string, fullCustomForm: boolean, draws = true): FormPanelState {\n if (status === 'Pending') return 'draft';\n if (status !== 'Active') return 'off';\n if (fullCustomForm) return 'held';\n return draws ? 'active' : 'outranked';\n}\n\n/**\n * Everything on this form that concerns this user, contributions first.\n *\n * Their own contributions lead because they can do anything to them. What is shared with them\n * follows — published panels and panels shipped in code — which they can hide. Grids drawn from\n * a relationship come last; they are listed so the form's contents are accounted for, and offer\n * no button that would not work.\n */\nexport function BuildPanelInventory(input: FormPanelInventoryInput): FormPanelInventoryItem[] {\n const hidden = new Set(input.HiddenKeys);\n const out: FormPanelInventoryItem[] = [];\n for (const row of input.Contributions) {\n if (!IsListedFor(row, input.CallerID, input.CallerRoleIDs)) continue;\n out.push(contributionItem(row, input, hidden));\n }\n for (const row of input.Compiled) out.push(compiledItem(row, input, hidden));\n for (const row of input.StockGrids) out.push(stockGridItem(row, input));\n return out;\n}\n\nfunction contributionItem(\n row: FormPanelContributionRow,\n input: FormPanelInventoryInput,\n hidden: ReadonlySet<string>,\n): FormPanelInventoryItem {\n const yours = row.Scope === 'User';\n const hideKey = yours ? null : (row.ContributionKey ?? '').trim() || null;\n const isHidden = !!hideKey && hidden.has(hideKey);\n // A hidden panel is listed under Hidden, so its state says what it does for everyone else.\n const draws = isHidden || !input.Rendering || input.Rendering.RowIDs.has(row.ID.toLowerCase());\n const state = ContributionState(row.Status, input.FullCustomForm, draws);\n return {\n ID: row.ID,\n Title: (row.Title ?? '').trim() || row.Name,\n Subtitle: `${row.Presentation === 'bare' ? 'bare strip' : 'panel'} · ${yours ? 'added by you' : 'shared with you'}`,\n Origin: 'contribution',\n Slot: row.Slot,\n Replaces: DescribeReplacement(row, input.TitleByKey),\n Presentation: row.Presentation === 'bare' ? 'Bare' : 'Panel',\n Audience: yours ? 'yours' : 'shared',\n AudienceLabel: DescribeAudience(row.Scope, row.Role),\n State: state,\n StateLabel: DescribeState(state),\n HideKey: hideKey,\n IsHidden: isHidden,\n Icon: row.Presentation === 'bare' ? 'fa-solid fa-minus' : 'fa-solid fa-puzzle-piece',\n // Turning on and off changes the row for everyone it reaches, so on a shared item it is\n // a holder's act; hiding is the per-user switch instead.\n CanTurnOn: (yours || input.CanPublish) && (state === 'draft' || state === 'off'),\n CanTurnOff: (yours || input.CanPublish) && (state === 'active' || state === 'held' || state === 'outranked'),\n CanRemove: yours || input.CanPublish,\n CanEdit: yours || input.CanPublish,\n CanHide: !!hideKey && !isHidden,\n CanShow: isHidden,\n CanPublish: yours && input.CanPublish,\n CanChangeAudience: !yours && input.CanPublish,\n };\n}\n\nfunction compiledItem(\n row: FormPanelCompiledRow,\n input: FormPanelInventoryInput,\n hidden: ReadonlySet<string>,\n): FormPanelInventoryItem {\n const isHidden = !!row.HideKey && hidden.has(row.HideKey);\n // A panel with no hide key has no key to lose, so it always draws.\n const draws = isHidden || !input.Rendering || !row.HideKey || input.Rendering.CompiledKeys.has(row.HideKey);\n const state: FormPanelState = input.FullCustomForm ? 'held' : draws ? 'active' : 'outranked';\n return {\n ID: row.Key,\n Title: row.Title || row.Key,\n Subtitle: 'panel · built into this app',\n Origin: 'compiled',\n Slot: row.Slot,\n Replaces: '',\n Presentation: 'Panel',\n Audience: 'builtin',\n AudienceLabel: 'Built in',\n State: state,\n StateLabel: DescribeState(state),\n HideKey: row.HideKey,\n IsHidden: isHidden,\n Icon: 'fa-solid fa-code',\n CanTurnOn: false,\n CanTurnOff: false,\n CanRemove: false,\n CanEdit: false,\n CanHide: !!row.HideKey && !isHidden,\n CanShow: isHidden,\n CanPublish: false,\n CanChangeAudience: false,\n };\n}\n\nfunction stockGridItem(row: FormPanelStockGridRow, input: FormPanelInventoryInput): FormPanelInventoryItem {\n const state: FormPanelState = input.FullCustomForm ? 'held' : 'active';\n return {\n ID: row.SectionKey,\n Title: row.DisplayName,\n Subtitle: 'automatic grid · from the relationship',\n Origin: 'stock-grid',\n Slot: '',\n Replaces: '',\n Presentation: 'Panel',\n Audience: 'relationship',\n AudienceLabel: 'From a relationship',\n State: state,\n StateLabel: DescribeState(state),\n HideKey: null,\n IsHidden: false,\n Icon: 'fa-solid fa-table',\n CanTurnOn: false,\n CanTurnOff: false,\n CanRemove: false,\n CanEdit: false,\n CanHide: false,\n CanShow: false,\n CanPublish: false,\n CanChangeAudience: false,\n };\n}\n\n/** The count line under the list: how much is registered, and how much of it renders for this user. */\nexport function SummarizeInventory(items: readonly FormPanelInventoryItem[]): string {\n const total = items.length;\n const showing = items.filter((item) => item.State === 'active' && !item.IsHidden).length;\n const noun = total === 1 ? 'thing' : 'things';\n return `${total} ${noun} registered on this form · ${showing} rendering`;\n}\n\n\n/**\n * The list broken into headed groups, by who each item belongs to.\n *\n * Grouped by audience rather than by state because audience now decides what a user may do: they\n * can remove their own, but only hide something shared with them. State becomes a label on each\n * row. Hidden items get their own group so a hide can always be undone. Empty groups are dropped.\n */\nexport function GroupPanelInventory(\n items: readonly FormPanelInventoryItem[],\n): FormPanelInventoryGroup[] {\n const groups: FormPanelInventoryGroup[] = [\n {\n Key: 'yours', Title: 'Yours', Note: '',\n Items: items.filter((i) => i.Audience === 'yours'),\n },\n {\n Key: 'shared', Title: 'Shared with you',\n Note: 'Put on this form for your role, for everyone, or by the app. Hide any of them for yourself.',\n Items: items.filter((i) => (i.Audience === 'shared' || i.Audience === 'builtin') && !i.IsHidden),\n },\n {\n Key: 'hidden', Title: 'Hidden by you', Note: 'Still there for everyone else. Show one to put it back.',\n Items: items.filter((i) => i.IsHidden),\n },\n {\n Key: 'fixed', Title: 'Part of the form itself',\n Note: 'Drawn from a relationship. Not yours to change here.',\n Items: items.filter((i) => i.Audience === 'relationship'),\n },\n ];\n return groups.filter((group) => group.Items.length > 0);\n}\n\n/** One full custom form in the drawer's Form group, or the generated form. */\nexport interface FormPanelFormItem {\n /** The override's ID; null for the generated form. */\n ID: string | null;\n Title: string;\n AudienceLabel: string;\n /** The form this user sees now. */\n IsCurrent: boolean;\n /** Whether it belongs to this user alone. */\n IsYours: boolean;\n /** Publish this user's own form. Holders of the grant only. */\n CanPublish: boolean;\n /** Re-aim or unpublish a form shared with this user. Holders of the grant only. */\n CanChangeAudience: boolean;\n}\n\nexport interface FormPanelFormInput {\n /** The forms the toolbar picker offers, in its order. */\n Variants: ReadonlyArray<{ ID: string; Label: string }>;\n /** Every form registered on the entity, for each one's audience. */\n Overrides: readonly FormOverrideRow[];\n /** The form this user sees now; null when it is the generated form. */\n CurrentFormID: string | null;\n CanPublish: boolean;\n}\n\n/**\n * The full custom forms available to this user, and the generated form.\n *\n * Built from the toolbar picker's own list so the two cannot disagree about which forms exist.\n * The generated form is listed too: stepping back to it is a choice like any other, and the only\n * way to see a panel on an entity whose custom form draws its whole body.\n */\nexport function BuildFormItems(input: FormPanelFormInput): FormPanelFormItem[] {\n const same = (a: string | null, b: string | null): boolean =>\n (a ?? '').trim().toLowerCase() === (b ?? '').trim().toLowerCase();\n const items: FormPanelFormItem[] = input.Variants.map((variant) => {\n const row = input.Overrides.find((o) => same(o.ID, variant.ID));\n const yours = (row?.Scope ?? 'User') === 'User';\n return {\n ID: variant.ID,\n Title: variant.Label,\n AudienceLabel: DescribeAudience(row?.Scope ?? 'User', row?.Role),\n IsCurrent: same(variant.ID, input.CurrentFormID),\n IsYours: yours,\n CanPublish: yours && input.CanPublish,\n CanChangeAudience: !yours && input.CanPublish,\n };\n });\n items.push({\n ID: null,\n Title: 'Generated form',\n AudienceLabel: 'Built in',\n IsCurrent: !input.CurrentFormID,\n IsYours: false,\n CanPublish: false,\n CanChangeAudience: false,\n });\n return items;\n}\n"]}