@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.
- package/dist/lib/apply/form-placement-dialog.component.d.ts +266 -0
- package/dist/lib/apply/form-placement-dialog.component.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-dialog.component.js +1522 -0
- package/dist/lib/apply/form-placement-dialog.component.js.map +1 -0
- package/dist/lib/apply/form-placement-order.d.ts +37 -0
- package/dist/lib/apply/form-placement-order.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-order.js +111 -0
- package/dist/lib/apply/form-placement-order.js.map +1 -0
- package/dist/lib/apply/form-placement-preview.component.d.ts +112 -0
- package/dist/lib/apply/form-placement-preview.component.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-preview.component.js +346 -0
- package/dist/lib/apply/form-placement-preview.component.js.map +1 -0
- package/dist/lib/apply/form-placement-text.d.ts +61 -0
- package/dist/lib/apply/form-placement-text.d.ts.map +1 -0
- package/dist/lib/apply/form-placement-text.js +279 -0
- package/dist/lib/apply/form-placement-text.js.map +1 -0
- package/dist/lib/apply/form-placement.d.ts +320 -0
- package/dist/lib/apply/form-placement.d.ts.map +1 -0
- package/dist/lib/apply/form-placement.js +432 -0
- package/dist/lib/apply/form-placement.js.map +1 -0
- package/dist/lib/apply/form-slot-probe.service.d.ts +121 -0
- package/dist/lib/apply/form-slot-probe.service.d.ts.map +1 -0
- package/dist/lib/apply/form-slot-probe.service.js +264 -0
- package/dist/lib/apply/form-slot-probe.service.js.map +1 -0
- package/dist/lib/base-form-component-internals.d.ts +11 -0
- package/dist/lib/base-form-component-internals.d.ts.map +1 -0
- package/dist/lib/base-form-component-internals.js +33 -0
- package/dist/lib/base-form-component-internals.js.map +1 -0
- package/dist/lib/base-form-component.d.ts +166 -1
- package/dist/lib/base-form-component.d.ts.map +1 -1
- package/dist/lib/base-form-component.js +296 -20
- package/dist/lib/base-form-component.js.map +1 -1
- package/dist/lib/chrome/form-chrome.d.ts +78 -0
- package/dist/lib/chrome/form-chrome.d.ts.map +1 -1
- package/dist/lib/chrome/form-chrome.js +128 -2
- package/dist/lib/chrome/form-chrome.js.map +1 -1
- package/dist/lib/chrome/form-composition-registry.d.ts +34 -0
- package/dist/lib/chrome/form-composition-registry.d.ts.map +1 -0
- package/dist/lib/chrome/form-composition-registry.js +56 -0
- package/dist/lib/chrome/form-composition-registry.js.map +1 -0
- package/dist/lib/chrome/form-composition-snapshot.d.ts +151 -0
- package/dist/lib/chrome/form-composition-snapshot.d.ts.map +1 -0
- package/dist/lib/chrome/form-composition-snapshot.js +137 -0
- package/dist/lib/chrome/form-composition-snapshot.js.map +1 -0
- package/dist/lib/chrome/resolve-form-chrome.d.ts +15 -0
- package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
- package/dist/lib/chrome/resolve-form-chrome.js +31 -2
- package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
- package/dist/lib/container/record-form-container.component.d.ts +261 -5
- package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
- package/dist/lib/container/record-form-container.component.js +1180 -371
- package/dist/lib/container/record-form-container.component.js.map +1 -1
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts +150 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts.map +1 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.js +263 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.js.map +1 -0
- package/dist/lib/field/form-field.component.d.ts +22 -0
- package/dist/lib/field/form-field.component.d.ts.map +1 -1
- package/dist/lib/field/form-field.component.js +51 -6
- package/dist/lib/field/form-field.component.js.map +1 -1
- package/dist/lib/form-field-edit.coordinator.d.ts +25 -0
- package/dist/lib/form-field-edit.coordinator.d.ts.map +1 -0
- package/dist/lib/form-field-edit.coordinator.js +27 -0
- package/dist/lib/form-field-edit.coordinator.js.map +1 -0
- package/dist/lib/form-state.service.d.ts +5 -0
- package/dist/lib/form-state.service.d.ts.map +1 -1
- package/dist/lib/form-state.service.js +6 -1
- package/dist/lib/form-state.service.js.map +1 -1
- package/dist/lib/host/entity-form-host.component.d.ts +16 -1
- package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
- package/dist/lib/host/entity-form-host.component.js +27 -6
- package/dist/lib/host/entity-form-host.component.js.map +1 -1
- package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts +24 -0
- package/dist/lib/interactive-form/form-panel-host-props.builder.d.ts.map +1 -0
- package/dist/lib/interactive-form/form-panel-host-props.builder.js +99 -0
- package/dist/lib/interactive-form/form-panel-host-props.builder.js.map +1 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.d.ts +109 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.d.ts.map +1 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.js +424 -0
- package/dist/lib/interactive-form/interactive-form-panel.component.js.map +1 -0
- package/dist/lib/interactive-form/interactive-form.component.d.ts +2 -0
- package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
- package/dist/lib/interactive-form/interactive-form.component.js +4 -5
- package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
- package/dist/lib/panel/collapsible-panel.component.d.ts +69 -1
- package/dist/lib/panel/collapsible-panel.component.d.ts.map +1 -1
- package/dist/lib/panel/collapsible-panel.component.js +148 -12
- package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
- package/dist/lib/panel-manager/form-audience.d.ts +46 -0
- package/dist/lib/panel-manager/form-audience.d.ts.map +1 -0
- package/dist/lib/panel-manager/form-audience.js +34 -0
- package/dist/lib/panel-manager/form-audience.js.map +1 -0
- package/dist/lib/panel-manager/form-panel-admin.service.d.ts +150 -0
- package/dist/lib/panel-manager/form-panel-admin.service.d.ts.map +1 -0
- package/dist/lib/panel-manager/form-panel-admin.service.js +433 -0
- package/dist/lib/panel-manager/form-panel-admin.service.js.map +1 -0
- package/dist/lib/panel-manager/form-panel-inventory.d.ts +255 -0
- package/dist/lib/panel-manager/form-panel-inventory.d.ts.map +1 -0
- package/dist/lib/panel-manager/form-panel-inventory.js +293 -0
- package/dist/lib/panel-manager/form-panel-inventory.js.map +1 -0
- package/dist/lib/panel-manager/panel-manager.component.d.ts +232 -0
- package/dist/lib/panel-manager/panel-manager.component.d.ts.map +1 -0
- package/dist/lib/panel-manager/panel-manager.component.js +1112 -0
- package/dist/lib/panel-manager/panel-manager.component.js.map +1 -0
- package/dist/lib/panel-slot/base-contribution-panel.d.ts +40 -0
- package/dist/lib/panel-slot/base-contribution-panel.d.ts.map +1 -0
- package/dist/lib/panel-slot/base-contribution-panel.js +55 -0
- package/dist/lib/panel-slot/base-contribution-panel.js.map +1 -0
- package/dist/lib/panel-slot/base-form-panel.d.ts +116 -8
- package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
- package/dist/lib/panel-slot/base-form-panel.js +76 -5
- package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
- package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts +29 -0
- package/dist/lib/panel-slot/collect-form-contribution-registrations.d.ts.map +1 -0
- package/dist/lib/panel-slot/collect-form-contribution-registrations.js +214 -0
- package/dist/lib/panel-slot/collect-form-contribution-registrations.js.map +1 -0
- package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts +6 -3
- package/dist/lib/panel-slot/collect-form-panel-registrations.d.ts.map +1 -1
- package/dist/lib/panel-slot/collect-form-panel-registrations.js +8 -14
- package/dist/lib/panel-slot/collect-form-panel-registrations.js.map +1 -1
- package/dist/lib/panel-slot/form-contribution.d.ts +170 -7
- package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-contribution.js +242 -64
- package/dist/lib/panel-slot/form-contribution.js.map +1 -1
- package/dist/lib/panel-slot/form-contributions.component.d.ts +16 -5
- package/dist/lib/panel-slot/form-contributions.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-contributions.component.js +43 -7
- package/dist/lib/panel-slot/form-contributions.component.js.map +1 -1
- package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts +66 -0
- package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts.map +1 -0
- package/dist/lib/panel-slot/form-field-panel-slot.component.js +190 -0
- package/dist/lib/panel-slot/form-field-panel-slot.component.js.map +1 -0
- package/dist/lib/panel-slot/form-panel-slot.component.d.ts +52 -16
- package/dist/lib/panel-slot/form-panel-slot.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-panel-slot.component.js +190 -66
- package/dist/lib/panel-slot/form-panel-slot.component.js.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +11 -0
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.js +17 -0
- package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
- package/dist/lib/panel-slot/merge-panel-validation.d.ts +7 -0
- package/dist/lib/panel-slot/merge-panel-validation.d.ts.map +1 -0
- package/dist/lib/panel-slot/merge-panel-validation.js +16 -0
- package/dist/lib/panel-slot/merge-panel-validation.js.map +1 -0
- package/dist/lib/panel-slot/mount-form-contribution.d.ts +15 -0
- package/dist/lib/panel-slot/mount-form-contribution.d.ts.map +1 -0
- package/dist/lib/panel-slot/mount-form-contribution.js +37 -0
- package/dist/lib/panel-slot/mount-form-contribution.js.map +1 -0
- package/dist/lib/panel-slot/panel-hides.d.ts +35 -0
- package/dist/lib/panel-slot/panel-hides.d.ts.map +1 -0
- package/dist/lib/panel-slot/panel-hides.js +111 -0
- package/dist/lib/panel-slot/panel-hides.js.map +1 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.d.ts +16 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.d.ts.map +1 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.js +112 -0
- package/dist/lib/panel-slot/placement-preview-panel.component.js.map +1 -0
- package/dist/lib/panel-slot/placement-preview.d.ts +57 -0
- package/dist/lib/panel-slot/placement-preview.d.ts.map +1 -0
- package/dist/lib/panel-slot/placement-preview.js +86 -0
- package/dist/lib/panel-slot/placement-preview.js.map +1 -0
- package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
- package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js +10 -3
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
- package/dist/lib/panel-slot/slot-order.d.ts +19 -0
- package/dist/lib/panel-slot/slot-order.d.ts.map +1 -0
- package/dist/lib/panel-slot/slot-order.js +53 -0
- package/dist/lib/panel-slot/slot-order.js.map +1 -0
- package/dist/lib/resolver/form-resolver.service.d.ts +4 -2
- package/dist/lib/resolver/form-resolver.service.d.ts.map +1 -1
- package/dist/lib/resolver/form-resolver.service.js +18 -8
- package/dist/lib/resolver/form-resolver.service.js.map +1 -1
- package/dist/lib/resolver/form-variants.d.ts +28 -0
- package/dist/lib/resolver/form-variants.d.ts.map +1 -0
- package/dist/lib/resolver/form-variants.js +40 -0
- package/dist/lib/resolver/form-variants.js.map +1 -0
- package/dist/lib/section-counts/form-section-counts.d.ts +99 -0
- package/dist/lib/section-counts/form-section-counts.d.ts.map +1 -0
- package/dist/lib/section-counts/form-section-counts.js +223 -0
- package/dist/lib/section-counts/form-section-counts.js.map +1 -0
- package/dist/lib/toolbar/form-toolbar.component.d.ts +129 -2
- package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
- package/dist/lib/toolbar/form-toolbar.component.js +974 -307
- package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
- package/dist/lib/types/form-events.d.ts +6 -0
- package/dist/lib/types/form-events.d.ts.map +1 -1
- package/dist/lib/types/form-events.js +6 -0
- package/dist/lib/types/form-events.js.map +1 -1
- package/dist/lib/types/form-toolbar-item.d.ts +20 -1
- package/dist/lib/types/form-toolbar-item.d.ts.map +1 -1
- package/dist/lib/types/form-toolbar-item.js.map +1 -1
- package/dist/lib/types/form-types.d.ts +13 -0
- package/dist/lib/types/form-types.d.ts.map +1 -1
- package/dist/lib/types/form-types.js.map +1 -1
- package/dist/lib/types/toolbar-config.d.ts +16 -0
- package/dist/lib/types/toolbar-config.d.ts.map +1 -1
- package/dist/lib/types/toolbar-config.js +3 -0
- package/dist/lib/types/toolbar-config.js.map +1 -1
- package/dist/module.d.ts +29 -22
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +50 -8
- package/dist/module.js.map +1 -1
- package/dist/public-api.d.ts +22 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +24 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +20 -18
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The sentences that describe a placement: the line under "Where it goes", the
|
|
3
|
+
* summary beside Apply, and the labels and lists they are built from.
|
|
4
|
+
*
|
|
5
|
+
* Both sentences read what the answers point at through one lookup ({@link placementTarget}),
|
|
6
|
+
* so they always name the same sections, fields, grid, panel or tab.
|
|
7
|
+
*/
|
|
8
|
+
import { DETAILS_SECTION_KEY, DETAILS_SECTION_TITLE, MORE_SECTION_KEY, SlotChromeGroup } from '../chrome/form-chrome';
|
|
9
|
+
import { ChosenFieldNames, ChosenSectionKeys, FORM_PLACEMENT_SLOTS, HasDetailsTab, ReplacedPreviewKeys, SectionHoldingField, ShowsRail, SlotIsOnForm, } from './form-placement';
|
|
10
|
+
/**
|
|
11
|
+
* How one section reads in the list, told apart from the tab that contains it.
|
|
12
|
+
*
|
|
13
|
+
* CodeGen names a generated field section "Details" whenever the entity has fields it
|
|
14
|
+
* files nowhere else, and the rail then folds that section — with every other field
|
|
15
|
+
* section — into a tab it also calls "Details". Two different targets under one name,
|
|
16
|
+
* one of them a part of the other, so the section is qualified.
|
|
17
|
+
*/
|
|
18
|
+
export function SectionOptionLabel(section, context) {
|
|
19
|
+
const title = section.Title.trim() || section.Key;
|
|
20
|
+
if (HasDetailsTab(context) && title.toLowerCase() === DETAILS_SECTION_TITLE.toLowerCase()) {
|
|
21
|
+
return `${title} (the field group, not the tab)`;
|
|
22
|
+
}
|
|
23
|
+
return title;
|
|
24
|
+
}
|
|
25
|
+
/** Section titles joined for a sentence: "A and B", "A, B and C". */
|
|
26
|
+
export function DescribeSectionList(titles) {
|
|
27
|
+
if (titles.length <= 1)
|
|
28
|
+
return titles[0] ?? '';
|
|
29
|
+
return `${titles.slice(0, -1).join(', ')} and ${titles[titles.length - 1]}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A readable list of field labels: up to three by name ("the A, B and C fields"), and past
|
|
33
|
+
* three the first two and a count of the rest ("the A, B and 2 other fields").
|
|
34
|
+
*
|
|
35
|
+
* Counted past three because the sentence is one line beside the buttons, and a panel
|
|
36
|
+
* standing in for eight fields would push the rest of it off the end.
|
|
37
|
+
*/
|
|
38
|
+
export function DescribeFieldList(labels) {
|
|
39
|
+
if (labels.length === 0)
|
|
40
|
+
return 'nothing';
|
|
41
|
+
if (labels.length === 1)
|
|
42
|
+
return `the ${labels[0]} field`;
|
|
43
|
+
if (labels.length === 2)
|
|
44
|
+
return `the ${labels[0]} and ${labels[1]} fields`;
|
|
45
|
+
if (labels.length === 3)
|
|
46
|
+
return `the ${labels[0]}, ${labels[1]} and ${labels[2]} fields`;
|
|
47
|
+
return `the ${labels[0]}, ${labels[1]} and ${labels.length - 2} other fields`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Who sees a panel, as the end of "visible to …": the caller alone, a named role, or everyone.
|
|
51
|
+
* A panel added from a conversation is always the caller's own; one edited from the Manage
|
|
52
|
+
* drawer keeps the audience it has.
|
|
53
|
+
*/
|
|
54
|
+
export function DescribeVisibleTo(scope, roleName) {
|
|
55
|
+
if (scope === 'Global')
|
|
56
|
+
return 'everyone';
|
|
57
|
+
if (scope === 'Role')
|
|
58
|
+
return roleName ? `the ${roleName} role` : 'a role';
|
|
59
|
+
return 'you only';
|
|
60
|
+
}
|
|
61
|
+
/** The fields a field claim stands in for, as {@link DescribeFieldList} words them. */
|
|
62
|
+
export function DescribeChosenFields(state, context) {
|
|
63
|
+
return DescribeFieldList(chosenFieldLabels(state, context));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Where the panel goes and what it replaces, in one short line: "In place of the Details and
|
|
67
|
+
* Dates sections", "At the top of Details, in place of the Name field", "After the fields".
|
|
68
|
+
*/
|
|
69
|
+
export function DescribePlacementLine(state, context) {
|
|
70
|
+
const target = placementTarget(state, context);
|
|
71
|
+
const end = state.SectionPosition === 'end' ? 'bottom' : 'top';
|
|
72
|
+
switch (target.Mode) {
|
|
73
|
+
case 'section':
|
|
74
|
+
return target.Titles.length > 1
|
|
75
|
+
? `In place of the ${DescribeSectionList(target.Titles)} sections`
|
|
76
|
+
: `In place of the ${target.Titles[0] ?? 'chosen'} section`;
|
|
77
|
+
case 'field': {
|
|
78
|
+
const fields = target.FieldLabels.length > 0 ? DescribeFieldList(target.FieldLabels) : 'the fields you pick';
|
|
79
|
+
return `At the ${end} of ${target.Section?.Title ?? 'the section'}, in place of ${fields}`;
|
|
80
|
+
}
|
|
81
|
+
case 'related':
|
|
82
|
+
return `In place of the ${target.Title ?? 'related'} grid`;
|
|
83
|
+
case 'contribution':
|
|
84
|
+
return `In place of the ${target.Title ?? 'existing'} panel`;
|
|
85
|
+
case 'rail-tab':
|
|
86
|
+
return `In place of the whole ${target.Title ?? state.ReplaceRailKey} tab`;
|
|
87
|
+
default:
|
|
88
|
+
if (target.Section)
|
|
89
|
+
return `At the ${end} of the ${target.Section.Title} section`;
|
|
90
|
+
return FORM_PLACEMENT_SLOTS.find((s) => s.Slot === state.Slot)?.Name ?? state.Slot;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* One sentence saying what pressing Apply does, in the same terms the user just chose.
|
|
95
|
+
*
|
|
96
|
+
* It is the only place the separate answers are stated together, so a contradiction the
|
|
97
|
+
* form allows — a panel that is active but invisible behind a full form — reads plainly.
|
|
98
|
+
*
|
|
99
|
+
* @param visibleTo Who sees the panel, from {@link DescribeVisibleTo}.
|
|
100
|
+
* @param notes What the dialog's starting answers stood in for, and what its seed dropped.
|
|
101
|
+
*/
|
|
102
|
+
export function SummarizePlacement(state, context, visibleTo = DescribeVisibleTo('User'), notes = {}) {
|
|
103
|
+
const target = placementTarget(state, context);
|
|
104
|
+
const inSection = target.Mode === 'none' ? target.Section : null;
|
|
105
|
+
const what = state.Presentation === 'bare' ? 'a bare strip' : 'a panel';
|
|
106
|
+
const where = target.Mode === 'field' ? ''
|
|
107
|
+
: inSection ? ` ${state.SectionPosition === 'end' ? 'at the bottom' : 'at the top'} of the ${inSection.Title} section`
|
|
108
|
+
: ` at ${state.Slot}`;
|
|
109
|
+
const parts = [`Adds ${what}${where} on every ${context.EntityName} record`];
|
|
110
|
+
const replacement = describeReplacement(target, state, context);
|
|
111
|
+
if (replacement)
|
|
112
|
+
parts.push(replacement);
|
|
113
|
+
if (target.Mode === 'none' && !inSection && state.Presentation === 'panel' && ShowsRail(context)) {
|
|
114
|
+
parts.push(SlotChromeGroup(state.Slot) === 'details'
|
|
115
|
+
? 'inside the Details tab'
|
|
116
|
+
: 'as a tab of its own');
|
|
117
|
+
}
|
|
118
|
+
parts.push(`visible to ${visibleTo}`);
|
|
119
|
+
parts.push(state.ActivateNow ? 'starting now' : state.KeepOff ? 'kept off' : 'saved as a draft');
|
|
120
|
+
return `${parts.join(', ')}.${summaryCaveats(state, context, inSection, notes)}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The sections, fields, tab, grid or panel the answers point at. For a placement that replaces
|
|
124
|
+
* nothing, the section the panel draws inside, if any.
|
|
125
|
+
*/
|
|
126
|
+
function placementTarget(state, context) {
|
|
127
|
+
switch (state.ReplaceMode) {
|
|
128
|
+
case 'rail-tab':
|
|
129
|
+
return { Mode: 'rail-tab', Title: context.Rail.find((item) => item.Key === state.ReplaceRailKey)?.Title ?? null };
|
|
130
|
+
case 'section': {
|
|
131
|
+
const keys = ChosenSectionKeys(state, context);
|
|
132
|
+
return {
|
|
133
|
+
Mode: 'section',
|
|
134
|
+
Titles: keys.map((key) => context.Sections.find((s) => s.Key === key)?.Title ?? key),
|
|
135
|
+
First: context.Sections.find((s) => s.Key === keys[0]) ?? null,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
case 'field':
|
|
139
|
+
return { Mode: 'field', Section: fieldClaimSection(state, context), FieldLabels: chosenFieldLabels(state, context) };
|
|
140
|
+
case 'related':
|
|
141
|
+
return { Mode: 'related', Title: context.Related[state.ReplaceRelatedIndex]?.DisplayName ?? null };
|
|
142
|
+
case 'contribution':
|
|
143
|
+
return { Mode: 'contribution', Title: context.Existing[state.ReplaceContributionIndex]?.Title ?? null };
|
|
144
|
+
default:
|
|
145
|
+
return { Mode: 'none', Section: context.Sections.find((s) => s.Key === state.InSectionKey.trim()) ?? null };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** The section a field claim chooses its fields from, or null when the form does not draw it. */
|
|
149
|
+
function fieldClaimSection(state, context) {
|
|
150
|
+
return context.Sections.find((s) => s.Key === state.ReplaceFieldSectionKey) ?? null;
|
|
151
|
+
}
|
|
152
|
+
/** The labels of the fields a field claim stands in for, falling back to each field's name. */
|
|
153
|
+
function chosenFieldLabels(state, context) {
|
|
154
|
+
const section = fieldClaimSection(state, context);
|
|
155
|
+
return ChosenFieldNames(state, context)
|
|
156
|
+
.map((name) => (section?.Fields ?? []).find((f) => f.Name === name)?.Label || name);
|
|
157
|
+
}
|
|
158
|
+
/** The summary's clause about what the panel replaces, or null when it replaces nothing nameable. */
|
|
159
|
+
function describeReplacement(target, state, context) {
|
|
160
|
+
const end = state.SectionPosition === 'end' ? 'bottom' : 'top';
|
|
161
|
+
switch (target.Mode) {
|
|
162
|
+
case 'rail-tab':
|
|
163
|
+
return target.Title
|
|
164
|
+
? `taking the place of the whole ${target.Title} tab, leaving the other tabs alone`
|
|
165
|
+
: 'taking the place of a whole tab, leaving the other tabs alone';
|
|
166
|
+
case 'section':
|
|
167
|
+
if (target.Titles.length > 1) {
|
|
168
|
+
return `standing in for the ${DescribeSectionList(target.Titles)} sections, in the place of the first`;
|
|
169
|
+
}
|
|
170
|
+
if (target.First && HasDetailsTab(context)) {
|
|
171
|
+
return `standing in for the ${target.First.Title} section, one of ${context.Sections.length} inside the Details tab`;
|
|
172
|
+
}
|
|
173
|
+
return target.First ? `standing in for the ${target.First.Title} section` : null;
|
|
174
|
+
case 'field':
|
|
175
|
+
return target.FieldLabels.length > 0 && target.Section
|
|
176
|
+
? `standing in for ${DescribeFieldList(target.FieldLabels)} at the ${end} of the ${target.Section.Title} section`
|
|
177
|
+
: 'standing in for no field yet — pick at least one';
|
|
178
|
+
case 'related':
|
|
179
|
+
return target.Title ? `taking over the ${target.Title} grid` : null;
|
|
180
|
+
case 'contribution':
|
|
181
|
+
return target.Title ? `replacing the ${target.Title} panel` : null;
|
|
182
|
+
default:
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** One field's label on the form, or its entity field name when no section draws it. */
|
|
187
|
+
function fieldLabel(context, fieldName) {
|
|
188
|
+
return SectionHoldingField(context, fieldName)?.Fields?.find((f) => f.Name === fieldName)?.Label || fieldName;
|
|
189
|
+
}
|
|
190
|
+
/** Whether the answers hide the section drawing any of these fields, so the form shows no input for it. */
|
|
191
|
+
function hidesAnyFieldSection(state, context, fieldNames) {
|
|
192
|
+
const hidden = ReplacedPreviewKeys(state, context);
|
|
193
|
+
return fieldNames.some((name) => {
|
|
194
|
+
const section = SectionHoldingField(context, name);
|
|
195
|
+
return section != null && hidden.has(section.Key);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** A tab's name for a sentence: the rail title for Details and More, the key for any other tab. */
|
|
199
|
+
function tabTitle(railKey) {
|
|
200
|
+
if (railKey === DETAILS_SECTION_KEY)
|
|
201
|
+
return DETAILS_SECTION_TITLE;
|
|
202
|
+
if (railKey === MORE_SECTION_KEY)
|
|
203
|
+
return 'More';
|
|
204
|
+
return railKey;
|
|
205
|
+
}
|
|
206
|
+
/** What a dropped proposal claim would have done, as the end of "built to …". */
|
|
207
|
+
function describeDroppedClaim(claim, context) {
|
|
208
|
+
switch (claim.Kind) {
|
|
209
|
+
case 'field':
|
|
210
|
+
return `stand in for ${DescribeFieldList(claim.FieldNames.map((name) => fieldLabel(context, name)))}`;
|
|
211
|
+
case 'section':
|
|
212
|
+
return `stand in for the ${DescribeSectionList(claim.SectionKeys)} section${claim.SectionKeys.length > 1 ? 's' : ''}`;
|
|
213
|
+
case 'rail-tab':
|
|
214
|
+
return `stand in for the ${tabTitle(claim.RailKey)} tab`;
|
|
215
|
+
case 'in-section':
|
|
216
|
+
return `sit inside the ${claim.SectionKey} section`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Whether the answers make the dropped claim themselves, so the panel is saved with it: every
|
|
221
|
+
* field it named is chosen in field mode, every section it named is chosen in section mode,
|
|
222
|
+
* its tab is chosen in tab mode, or its section is the one the panel is placed in.
|
|
223
|
+
*/
|
|
224
|
+
function answersMakeClaim(claim, state, context) {
|
|
225
|
+
switch (claim.Kind) {
|
|
226
|
+
case 'field': {
|
|
227
|
+
if (state.ReplaceMode !== 'field')
|
|
228
|
+
return false;
|
|
229
|
+
const chosen = ChosenFieldNames(state, context);
|
|
230
|
+
return claim.FieldNames.every((name) => chosen.includes(name));
|
|
231
|
+
}
|
|
232
|
+
case 'section': {
|
|
233
|
+
if (state.ReplaceMode !== 'section')
|
|
234
|
+
return false;
|
|
235
|
+
const chosen = ChosenSectionKeys(state, context);
|
|
236
|
+
return claim.SectionKeys.every((key) => chosen.includes(key));
|
|
237
|
+
}
|
|
238
|
+
case 'rail-tab':
|
|
239
|
+
return state.ReplaceMode === 'rail-tab' && state.ReplaceRailKey.trim() === claim.RailKey;
|
|
240
|
+
case 'in-section':
|
|
241
|
+
return state.ReplaceMode === 'none' && state.InSectionKey.trim() === claim.SectionKey;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The sentences that follow the summary when an answer will not land the way it reads.
|
|
246
|
+
*
|
|
247
|
+
* A panel moved off a field claim keeps its `configuration.fields`, so it still draws those
|
|
248
|
+
* fields, while the host saves a panel's edits only to fields it claims. The form shows its
|
|
249
|
+
* own inputs for them unless the new answer hides the section that draws them.
|
|
250
|
+
*/
|
|
251
|
+
function summaryCaveats(state, context, inSection, notes) {
|
|
252
|
+
const fieldsStoodInFor = notes.FieldsStoodInFor ?? [];
|
|
253
|
+
let caveats = '';
|
|
254
|
+
if (state.ReplaceMode === 'field') {
|
|
255
|
+
caveats += ' The chosen position does not apply: a panel standing in for a field renders inside that field\'s section.';
|
|
256
|
+
}
|
|
257
|
+
if (state.ReplaceMode !== 'field' && fieldsStoodInFor.length > 0) {
|
|
258
|
+
const labels = fieldsStoodInFor.map((name) => fieldLabel(context, name)).join(', ');
|
|
259
|
+
caveats += ` This panel keeps drawing the fields it was set to stand in for (${labels}).`
|
|
260
|
+
+ (hidesAnyFieldSection(state, context, fieldsStoodInFor)
|
|
261
|
+
? ' It no longer stands in for them, so edits made to them in the panel are not saved.'
|
|
262
|
+
: ' The form also shows its own inputs for them, and edits made to them in the panel are not saved.');
|
|
263
|
+
}
|
|
264
|
+
if (notes.DroppedClaim && !answersMakeClaim(notes.DroppedClaim, state, context)) {
|
|
265
|
+
caveats += ` This panel was built to ${describeDroppedClaim(notes.DroppedClaim, context)} on this form,`
|
|
266
|
+
+ ' but the form could not confirm it, so the panel is saved without that claim.';
|
|
267
|
+
}
|
|
268
|
+
if (state.ReplaceMode !== 'field' && !inSection && context.SlotsVerified && !SlotIsOnForm(context, state.Slot)) {
|
|
269
|
+
caveats += ` This form does not emit ${state.Slot}, so the panel renders at the bottom instead.`;
|
|
270
|
+
}
|
|
271
|
+
if (state.ReplaceMode === 'section' && !context.TargetsVerified) {
|
|
272
|
+
caveats += ' The section list comes from entity metadata, not from the form itself, so a section may not match.';
|
|
273
|
+
}
|
|
274
|
+
if (context.FullCustomForm && state.ActivateNow) {
|
|
275
|
+
caveats += ' A full custom form is rendering this entity, so it will not appear until that form is turned off.';
|
|
276
|
+
}
|
|
277
|
+
return caveats;
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=form-placement-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-placement-text.js","sourceRoot":"","sources":["../../../src/lib/apply/form-placement-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtH,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,YAAY,GAKf,MAAM,kBAAkB,CAAC;AAa1B;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA6B,EAAE,OAA6B;IAC3F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC;IAClD,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,qBAAqB,CAAC,WAAW,EAAE,EAAE,CAAC;QACxF,OAAO,GAAG,KAAK,iCAAiC,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,mBAAmB,CAAC,MAAyB;IACzD,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QA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AAK,EAAE,OAAO,CAAC,EAAE,CAAC;QAC9E,OAAO,IAAI,4BAA4B,oBAAoB,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,gBAAgB;cAClG,+EAA+E,CAAC;IAC1F,CAAC;IACD,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,aAAa,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7G,OAAO,IAAI,4BAA4B,KAAK,CAAC,IAAI,+CAA+C,CAAC;IACrG,CAAC;IACD,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QAC9D,OAAO,IAAI,qGAAqG,CAAC;IACrH,CAAC;IACD,IAAI,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,IAAI,oGAAoG,CAAC;IACpH,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["/**\n * @fileoverview The sentences that describe a placement: the line under \"Where it goes\", the\n * summary beside Apply, and the labels and lists they are built from.\n *\n * Both sentences read what the answers point at through one lookup ({@link placementTarget}),\n * so they always name the same sections, fields, grid, panel or tab.\n */\n\nimport { DETAILS_SECTION_KEY, DETAILS_SECTION_TITLE, MORE_SECTION_KEY, SlotChromeGroup } from '../chrome/form-chrome';\nimport {\n ChosenFieldNames,\n ChosenSectionKeys,\n FORM_PLACEMENT_SLOTS,\n HasDetailsTab,\n ReplacedPreviewKeys,\n SectionHoldingField,\n ShowsRail,\n SlotIsOnForm,\n type FormPlacementContext,\n type FormPlacementDroppedClaim,\n type FormPlacementSection,\n type FormPlacementState,\n} from './form-placement';\n\n/** What the dialog knows about its starting answers that the summary reports. */\nexport interface PlacementSummaryNotes {\n /** The fields the dialog's starting answers stood in for, by entity field name. */\n FieldsStoodInFor?: readonly string[];\n /**\n * A proposal's claim the seed dropped because the form could not confirm it. The summary\n * leaves it out while the answers make that claim themselves.\n */\n DroppedClaim?: FormPlacementDroppedClaim | null;\n}\n\n/**\n * How one section reads in the list, told apart from the tab that contains it.\n *\n * CodeGen names a generated field section \"Details\" whenever the entity has fields it\n * files nowhere else, and the rail then folds that section — with every other field\n * section — into a tab it also calls \"Details\". Two different targets under one name,\n * one of them a part of the other, so the section is qualified.\n */\nexport function SectionOptionLabel(section: FormPlacementSection, context: FormPlacementContext): string {\n const title = section.Title.trim() || section.Key;\n if (HasDetailsTab(context) && title.toLowerCase() === DETAILS_SECTION_TITLE.toLowerCase()) {\n return `${title} (the field group, not the tab)`;\n }\n return title;\n}\n\n/** Section titles joined for a sentence: \"A and B\", \"A, B and C\". */\nexport function DescribeSectionList(titles: readonly string[]): string {\n if (titles.length <= 1) return titles[0] ?? '';\n return `${titles.slice(0, -1).join(', ')} and ${titles[titles.length - 1]}`;\n}\n\n/**\n * A readable list of field labels: up to three by name (\"the A, B and C fields\"), and past\n * three the first two and a count of the rest (\"the A, B and 2 other fields\").\n *\n * Counted past three because the sentence is one line beside the buttons, and a panel\n * standing in for eight fields would push the rest of it off the end.\n */\nexport function DescribeFieldList(labels: readonly string[]): string {\n if (labels.length === 0) return 'nothing';\n if (labels.length === 1) return `the ${labels[0]} field`;\n if (labels.length === 2) return `the ${labels[0]} and ${labels[1]} fields`;\n if (labels.length === 3) return `the ${labels[0]}, ${labels[1]} and ${labels[2]} fields`;\n return `the ${labels[0]}, ${labels[1]} and ${labels.length - 2} other fields`;\n}\n\n/**\n * Who sees a panel, as the end of \"visible to …\": the caller alone, a named role, or everyone.\n * A panel added from a conversation is always the caller's own; one edited from the Manage\n * drawer keeps the audience it has.\n */\nexport function DescribeVisibleTo(scope: string | null | undefined, roleName?: string | null): string {\n if (scope === 'Global') return 'everyone';\n if (scope === 'Role') return roleName ? `the ${roleName} role` : 'a role';\n return 'you only';\n}\n\n/** The fields a field claim stands in for, as {@link DescribeFieldList} words them. */\nexport function DescribeChosenFields(state: FormPlacementState, context: FormPlacementContext): string {\n return DescribeFieldList(chosenFieldLabels(state, context));\n}\n\n/**\n * Where the panel goes and what it replaces, in one short line: \"In place of the Details and\n * Dates sections\", \"At the top of Details, in place of the Name field\", \"After the fields\".\n */\nexport function DescribePlacementLine(state: FormPlacementState, context: FormPlacementContext): string {\n const target = placementTarget(state, context);\n const end = state.SectionPosition === 'end' ? 'bottom' : 'top';\n switch (target.Mode) {\n case 'section':\n return target.Titles.length > 1\n ? `In place of the ${DescribeSectionList(target.Titles)} sections`\n : `In place of the ${target.Titles[0] ?? 'chosen'} section`;\n case 'field': {\n const fields = target.FieldLabels.length > 0 ? DescribeFieldList(target.FieldLabels) : 'the fields you pick';\n return `At the ${end} of ${target.Section?.Title ?? 'the section'}, in place of ${fields}`;\n }\n case 'related':\n return `In place of the ${target.Title ?? 'related'} grid`;\n case 'contribution':\n return `In place of the ${target.Title ?? 'existing'} panel`;\n case 'rail-tab':\n return `In place of the whole ${target.Title ?? state.ReplaceRailKey} tab`;\n default:\n if (target.Section) return `At the ${end} of the ${target.Section.Title} section`;\n return FORM_PLACEMENT_SLOTS.find((s) => s.Slot === state.Slot)?.Name ?? state.Slot;\n }\n}\n\n/**\n * One sentence saying what pressing Apply does, in the same terms the user just chose.\n *\n * It is the only place the separate answers are stated together, so a contradiction the\n * form allows — a panel that is active but invisible behind a full form — reads plainly.\n *\n * @param visibleTo Who sees the panel, from {@link DescribeVisibleTo}.\n * @param notes What the dialog's starting answers stood in for, and what its seed dropped.\n */\nexport function SummarizePlacement(\n state: FormPlacementState,\n context: FormPlacementContext,\n visibleTo = DescribeVisibleTo('User'),\n notes: PlacementSummaryNotes = {},\n): string {\n const target = placementTarget(state, context);\n const inSection = target.Mode === 'none' ? target.Section : null;\n const what = state.Presentation === 'bare' ? 'a bare strip' : 'a panel';\n const where = target.Mode === 'field' ? ''\n : inSection ? ` ${state.SectionPosition === 'end' ? 'at the bottom' : 'at the top'} of the ${inSection.Title} section`\n : ` at ${state.Slot}`;\n const parts = [`Adds ${what}${where} on every ${context.EntityName} record`];\n\n const replacement = describeReplacement(target, state, context);\n if (replacement) parts.push(replacement);\n\n if (target.Mode === 'none' && !inSection && state.Presentation === 'panel' && ShowsRail(context)) {\n parts.push(SlotChromeGroup(state.Slot) === 'details'\n ? 'inside the Details tab'\n : 'as a tab of its own');\n }\n\n parts.push(`visible to ${visibleTo}`);\n parts.push(state.ActivateNow ? 'starting now' : state.KeepOff ? 'kept off' : 'saved as a draft');\n\n return `${parts.join(', ')}.${summaryCaveats(state, context, inSection, notes)}`;\n}\n\n/** What the answers point at on the form, looked up once for every sentence that names it. */\ntype PlacementTarget =\n | { Mode: 'none'; Section: FormPlacementSection | null }\n | { Mode: 'rail-tab'; Title: string | null }\n | { Mode: 'section'; Titles: string[]; First: FormPlacementSection | null }\n | { Mode: 'field'; Section: FormPlacementSection | null; FieldLabels: string[] }\n | { Mode: 'related'; Title: string | null }\n | { Mode: 'contribution'; Title: string | null };\n\n/**\n * The sections, fields, tab, grid or panel the answers point at. For a placement that replaces\n * nothing, the section the panel draws inside, if any.\n */\nfunction placementTarget(state: FormPlacementState, context: FormPlacementContext): PlacementTarget {\n switch (state.ReplaceMode) {\n case 'rail-tab':\n return { Mode: 'rail-tab', Title: context.Rail.find((item) => item.Key === state.ReplaceRailKey)?.Title ?? null };\n case 'section': {\n const keys = ChosenSectionKeys(state, context);\n return {\n Mode: 'section',\n Titles: keys.map((key) => context.Sections.find((s) => s.Key === key)?.Title ?? key),\n First: context.Sections.find((s) => s.Key === keys[0]) ?? null,\n };\n }\n case 'field':\n return { Mode: 'field', Section: fieldClaimSection(state, context), FieldLabels: chosenFieldLabels(state, context) };\n case 'related':\n return { Mode: 'related', Title: context.Related[state.ReplaceRelatedIndex]?.DisplayName ?? null };\n case 'contribution':\n return { Mode: 'contribution', Title: context.Existing[state.ReplaceContributionIndex]?.Title ?? null };\n default:\n return { Mode: 'none', Section: context.Sections.find((s) => s.Key === state.InSectionKey.trim()) ?? null };\n }\n}\n\n/** The section a field claim chooses its fields from, or null when the form does not draw it. */\nfunction fieldClaimSection(state: FormPlacementState, context: FormPlacementContext): FormPlacementSection | null {\n return context.Sections.find((s) => s.Key === state.ReplaceFieldSectionKey) ?? null;\n}\n\n/** The labels of the fields a field claim stands in for, falling back to each field's name. */\nfunction chosenFieldLabels(state: FormPlacementState, context: FormPlacementContext): string[] {\n const section = fieldClaimSection(state, context);\n return ChosenFieldNames(state, context)\n .map((name) => (section?.Fields ?? []).find((f) => f.Name === name)?.Label || name);\n}\n\n/** The summary's clause about what the panel replaces, or null when it replaces nothing nameable. */\nfunction describeReplacement(target: PlacementTarget, state: FormPlacementState, context: FormPlacementContext): string | null {\n const end = state.SectionPosition === 'end' ? 'bottom' : 'top';\n switch (target.Mode) {\n case 'rail-tab':\n return target.Title\n ? `taking the place of the whole ${target.Title} tab, leaving the other tabs alone`\n : 'taking the place of a whole tab, leaving the other tabs alone';\n case 'section':\n if (target.Titles.length > 1) {\n return `standing in for the ${DescribeSectionList(target.Titles)} sections, in the place of the first`;\n }\n if (target.First && HasDetailsTab(context)) {\n return `standing in for the ${target.First.Title} section, one of ${context.Sections.length} inside the Details tab`;\n }\n return target.First ? `standing in for the ${target.First.Title} section` : null;\n case 'field':\n return target.FieldLabels.length > 0 && target.Section\n ? `standing in for ${DescribeFieldList(target.FieldLabels)} at the ${end} of the ${target.Section.Title} section`\n : 'standing in for no field yet — pick at least one';\n case 'related':\n return target.Title ? `taking over the ${target.Title} grid` : null;\n case 'contribution':\n return target.Title ? `replacing the ${target.Title} panel` : null;\n default:\n return null;\n }\n}\n\n/** One field's label on the form, or its entity field name when no section draws it. */\nfunction fieldLabel(context: FormPlacementContext, fieldName: string): string {\n return SectionHoldingField(context, fieldName)?.Fields?.find((f) => f.Name === fieldName)?.Label || fieldName;\n}\n\n/** Whether the answers hide the section drawing any of these fields, so the form shows no input for it. */\nfunction hidesAnyFieldSection(state: FormPlacementState, context: FormPlacementContext, fieldNames: readonly string[]): boolean {\n const hidden = ReplacedPreviewKeys(state, context);\n return fieldNames.some((name) => {\n const section = SectionHoldingField(context, name);\n return section != null && hidden.has(section.Key);\n });\n}\n\n/** A tab's name for a sentence: the rail title for Details and More, the key for any other tab. */\nfunction tabTitle(railKey: string): string {\n if (railKey === DETAILS_SECTION_KEY) return DETAILS_SECTION_TITLE;\n if (railKey === MORE_SECTION_KEY) return 'More';\n return railKey;\n}\n\n/** What a dropped proposal claim would have done, as the end of \"built to …\". */\nfunction describeDroppedClaim(claim: FormPlacementDroppedClaim, context: FormPlacementContext): string {\n switch (claim.Kind) {\n case 'field':\n return `stand in for ${DescribeFieldList(claim.FieldNames.map((name) => fieldLabel(context, name)))}`;\n case 'section':\n return `stand in for the ${DescribeSectionList(claim.SectionKeys)} section${claim.SectionKeys.length > 1 ? 's' : ''}`;\n case 'rail-tab':\n return `stand in for the ${tabTitle(claim.RailKey)} tab`;\n case 'in-section':\n return `sit inside the ${claim.SectionKey} section`;\n }\n}\n\n/**\n * Whether the answers make the dropped claim themselves, so the panel is saved with it: every\n * field it named is chosen in field mode, every section it named is chosen in section mode,\n * its tab is chosen in tab mode, or its section is the one the panel is placed in.\n */\nfunction answersMakeClaim(claim: FormPlacementDroppedClaim, state: FormPlacementState, context: FormPlacementContext): boolean {\n switch (claim.Kind) {\n case 'field': {\n if (state.ReplaceMode !== 'field') return false;\n const chosen = ChosenFieldNames(state, context);\n return claim.FieldNames.every((name) => chosen.includes(name));\n }\n case 'section': {\n if (state.ReplaceMode !== 'section') return false;\n const chosen = ChosenSectionKeys(state, context);\n return claim.SectionKeys.every((key) => chosen.includes(key));\n }\n case 'rail-tab':\n return state.ReplaceMode === 'rail-tab' && state.ReplaceRailKey.trim() === claim.RailKey;\n case 'in-section':\n return state.ReplaceMode === 'none' && state.InSectionKey.trim() === claim.SectionKey;\n }\n}\n\n/**\n * The sentences that follow the summary when an answer will not land the way it reads.\n *\n * A panel moved off a field claim keeps its `configuration.fields`, so it still draws those\n * fields, while the host saves a panel's edits only to fields it claims. The form shows its\n * own inputs for them unless the new answer hides the section that draws them.\n */\nfunction summaryCaveats(\n state: FormPlacementState,\n context: FormPlacementContext,\n inSection: FormPlacementSection | null,\n notes: PlacementSummaryNotes,\n): string {\n const fieldsStoodInFor = notes.FieldsStoodInFor ?? [];\n let caveats = '';\n if (state.ReplaceMode === 'field') {\n caveats += ' The chosen position does not apply: a panel standing in for a field renders inside that field\\'s section.';\n }\n if (state.ReplaceMode !== 'field' && fieldsStoodInFor.length > 0) {\n const labels = fieldsStoodInFor.map((name) => fieldLabel(context, name)).join(', ');\n caveats += ` This panel keeps drawing the fields it was set to stand in for (${labels}).`\n + (hidesAnyFieldSection(state, context, fieldsStoodInFor)\n ? ' It no longer stands in for them, so edits made to them in the panel are not saved.'\n : ' The form also shows its own inputs for them, and edits made to them in the panel are not saved.');\n }\n if (notes.DroppedClaim && !answersMakeClaim(notes.DroppedClaim, state, context)) {\n caveats += ` This panel was built to ${describeDroppedClaim(notes.DroppedClaim, context)} on this form,`\n + ' but the form could not confirm it, so the panel is saved without that claim.';\n }\n if (state.ReplaceMode !== 'field' && !inSection && context.SlotsVerified && !SlotIsOnForm(context, state.Slot)) {\n caveats += ` This form does not emit ${state.Slot}, so the panel renders at the bottom instead.`;\n }\n if (state.ReplaceMode === 'section' && !context.TargetsVerified) {\n caveats += ' The section list comes from entity metadata, not from the form itself, so a section may not match.';\n }\n if (context.FullCustomForm && state.ActivateNow) {\n caveats += ' A full custom form is rendering this entity, so it will not appear until that form is turned off.';\n }\n return caveats;\n}\n"]}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The placement decision — what the user answers before a panel is written.
|
|
3
|
+
*
|
|
4
|
+
* A generated panel arrives carrying a `formContribution` block. Its **identity** —
|
|
5
|
+
* `presentation`, `title`, `icon` — describes what the component is. Its **placement** — slot
|
|
6
|
+
* and claims — is a proposal: the dialog starts from every claim the open form can honour and
|
|
7
|
+
* from a fixed default for the rest, and the user confirms or changes it.
|
|
8
|
+
*
|
|
9
|
+
* Everything here is pure. The component holds a {@link FormPlacementState} and renders it;
|
|
10
|
+
* these functions decide what that state means. The sentences that describe a state are in
|
|
11
|
+
* `form-placement-text.ts`, and the order of panels in one position is in
|
|
12
|
+
* `form-placement-order.ts`.
|
|
13
|
+
*/
|
|
14
|
+
import { type FormContributionPresentation, type FormContributionSlot, type FormContributionSpec } from '@memberjunction/interactive-component-types/forms';
|
|
15
|
+
/** One input inside a field section, which a panel may stand in for. */
|
|
16
|
+
export interface FormPlacementField {
|
|
17
|
+
/** The entity field name, which is what reaches the database. */
|
|
18
|
+
Name: string;
|
|
19
|
+
/** What the form labels it, for the reader. */
|
|
20
|
+
Label: string;
|
|
21
|
+
}
|
|
22
|
+
/** A field section on the form, which a panel may hide. */
|
|
23
|
+
export interface FormPlacementSection {
|
|
24
|
+
Key: string;
|
|
25
|
+
Title: string;
|
|
26
|
+
/**
|
|
27
|
+
* The inputs this section draws. Empty when the targets were derived rather than read
|
|
28
|
+
* from a form, in which case replacing one field is not offered: naming a field the
|
|
29
|
+
* form does not draw would hide nothing and report no error.
|
|
30
|
+
*/
|
|
31
|
+
Fields?: readonly FormPlacementField[];
|
|
32
|
+
}
|
|
33
|
+
/** A related-record grid on the form, which a panel may take over. */
|
|
34
|
+
export interface FormPlacementRelated {
|
|
35
|
+
Entity: string;
|
|
36
|
+
JoinField: string;
|
|
37
|
+
DisplayName: string;
|
|
38
|
+
}
|
|
39
|
+
/** A panel already registered on this entity. */
|
|
40
|
+
export interface FormPlacementExisting {
|
|
41
|
+
Key: string;
|
|
42
|
+
Slot: string;
|
|
43
|
+
Title: string;
|
|
44
|
+
/** Order among panels in the same position, higher first. Absent means 0. */
|
|
45
|
+
SortKey?: number;
|
|
46
|
+
/** The section it is placed in, replacing nothing. */
|
|
47
|
+
InSectionKey?: string | null;
|
|
48
|
+
/** Where inside its section it draws, for a placement in a section or a field claim. */
|
|
49
|
+
SectionPosition?: 'start' | 'end' | null;
|
|
50
|
+
/** Fields it stands in for; it draws inside the section holding them. */
|
|
51
|
+
FieldNames?: readonly string[];
|
|
52
|
+
/** Blocks it stands in for; it draws in the place of the first. */
|
|
53
|
+
SectionKeys?: readonly string[];
|
|
54
|
+
/** True when it stands in for a section, tab or grid, so it draws in that place, not at a position. */
|
|
55
|
+
ReplacesPlace?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** One item in the form's side rail, and the panels it holds. */
|
|
58
|
+
export interface FormPlacementRailItem {
|
|
59
|
+
Key: string;
|
|
60
|
+
Title: string;
|
|
61
|
+
Icon: string;
|
|
62
|
+
/** Section keys of the panels filed under this item. */
|
|
63
|
+
SectionKeys: readonly string[];
|
|
64
|
+
IsMore: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* What the form actually contains, so the dialog offers real targets.
|
|
68
|
+
*
|
|
69
|
+
* `FullCustomForm` is the case with no good answer yet: a full custom form renders its own
|
|
70
|
+
* body, so a panel applied to that entity is stored and never seen.
|
|
71
|
+
*/
|
|
72
|
+
export interface FormPlacementContext {
|
|
73
|
+
EntityName: string;
|
|
74
|
+
Sections: readonly FormPlacementSection[];
|
|
75
|
+
Related: readonly FormPlacementRelated[];
|
|
76
|
+
Existing: readonly FormPlacementExisting[];
|
|
77
|
+
/**
|
|
78
|
+
* Slots this form emits. A slot outside this list still accepts a panel, but the slot
|
|
79
|
+
* coordinator sends it down the fallback chain to the container's `after-everything`
|
|
80
|
+
* terminator — the bottom of the form. A generated form emits whichever slots CodeGen
|
|
81
|
+
* knew about when it last ran, so the set differs from form to form.
|
|
82
|
+
*/
|
|
83
|
+
SlotsPresent: readonly FormContributionSlot[];
|
|
84
|
+
/**
|
|
85
|
+
* Whether {@link SlotsPresent} was read from a form, rather than assumed from the shape
|
|
86
|
+
* CodeGen produces. Separate from {@link TargetsVerified} because the two are learned
|
|
87
|
+
* apart: a slot probe answers the slot question without answering the section question.
|
|
88
|
+
*/
|
|
89
|
+
SlotsVerified: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* How the form arranges itself. In `left-nav` the chrome folds every field section into
|
|
92
|
+
* one "Details" tab, so the section names the user can choose from are a level below
|
|
93
|
+
* anything the form shows them.
|
|
94
|
+
*/
|
|
95
|
+
Layout: 'accordion' | 'left-nav';
|
|
96
|
+
/**
|
|
97
|
+
* The rail the form shows, in order. Empty when it could not be resolved, which the
|
|
98
|
+
* preview treats as "no rail to draw" rather than as a form with no sections.
|
|
99
|
+
*/
|
|
100
|
+
Rail: readonly FormPlacementRailItem[];
|
|
101
|
+
FullCustomForm: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether these targets came from the form itself.
|
|
104
|
+
*
|
|
105
|
+
* True means the open form reported them, so a section key here is one the form
|
|
106
|
+
* really renders. False means they were derived from entity metadata on the server,
|
|
107
|
+
* which is a different thing: a generated form is frozen at the moment CodeGen last
|
|
108
|
+
* ran, so a field recategorised since then moves in the metadata and not on the form.
|
|
109
|
+
* A key that only exists in the metadata hides nothing and reports no error.
|
|
110
|
+
*/
|
|
111
|
+
TargetsVerified: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Whether the panel adds to the form or takes something's place. */
|
|
114
|
+
export type FormPlacementReplaceMode = 'none' | 'rail-tab' | 'section' | 'field' | 'related' | 'contribution';
|
|
115
|
+
/**
|
|
116
|
+
* Whether the form bundles its field sections into a Details tab.
|
|
117
|
+
*
|
|
118
|
+
* Only a rail layout does. An accordion shows every section in place, so there is no tab
|
|
119
|
+
* to stand in for and the section list means exactly what it says.
|
|
120
|
+
*/
|
|
121
|
+
export declare function HasDetailsTab(context: FormPlacementContext): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the form shows a side rail, so there are tabs a user can point at.
|
|
124
|
+
*
|
|
125
|
+
* The rail groups exist whatever the layout — an accordion form uses them to decide what
|
|
126
|
+
* is visible, it just draws no rail. So a non-empty `Rail` does not mean the user sees
|
|
127
|
+
* tabs, and offering to "replace a whole tab" on a form that shows none describes
|
|
128
|
+
* something that is not on their screen.
|
|
129
|
+
*/
|
|
130
|
+
export declare function ShowsRail(context: FormPlacementContext): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* The blocks in the preview that this choice will take off the form.
|
|
133
|
+
*
|
|
134
|
+
* The replace choices differ only in how much they cover — a whole tab is every field
|
|
135
|
+
* group in it, one field group is one of those — and saying that in a label has not been
|
|
136
|
+
* enough. Marking the blocks themselves shows the difference instead of describing it.
|
|
137
|
+
*/
|
|
138
|
+
export declare function ReplacedPreviewKeys(state: FormPlacementState, context: FormPlacementContext): ReadonlySet<string>;
|
|
139
|
+
/**
|
|
140
|
+
* Whether the form's targets are not known yet: no sections, and none read from the form.
|
|
141
|
+
* A claim cannot be checked against such a context, so it is kept as it stands.
|
|
142
|
+
*/
|
|
143
|
+
export declare function TargetsUnread(context: FormPlacementContext): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* The sections the `section` mode stands in for, in the form's order and kept to sections the
|
|
146
|
+
* form draws. The list when one is set, else the single key.
|
|
147
|
+
*/
|
|
148
|
+
export declare function ChosenSectionKeys(state: FormPlacementState, context: FormPlacementContext): string[];
|
|
149
|
+
/** The section drawing this field, or null when no section on the form does. */
|
|
150
|
+
export declare function SectionHoldingField(context: FormPlacementContext, fieldName: string): FormPlacementSection | null;
|
|
151
|
+
/** Sections that draw at least one field, so there is something to choose from. */
|
|
152
|
+
export declare function SectionsWithFields(context: FormPlacementContext): readonly FormPlacementSection[];
|
|
153
|
+
/** The fields of one section, by key. Empty for a section the form does not draw. */
|
|
154
|
+
export declare function FieldsInSection(context: FormPlacementContext, sectionKey: string): readonly FormPlacementField[];
|
|
155
|
+
/**
|
|
156
|
+
* The chosen field names, kept to the ones the chosen section really draws.
|
|
157
|
+
*
|
|
158
|
+
* The section and the names are held apart in the state, so switching section leaves a
|
|
159
|
+
* stale set behind. Filtering here rather than on every change keeps the state simple and
|
|
160
|
+
* means a section the form stopped drawing cannot smuggle a claim through.
|
|
161
|
+
*/
|
|
162
|
+
export declare function ChosenFieldNames(state: FormPlacementState, context: FormPlacementContext): string[];
|
|
163
|
+
/** The section a field claim starts on: the first one with fields to offer. */
|
|
164
|
+
export declare function DefaultFieldSectionKey(context: FormPlacementContext): string;
|
|
165
|
+
/** Tabs a panel may stand in for — every rail item, on a form that shows a rail. */
|
|
166
|
+
export declare function ReplaceableRailTabs(context: FormPlacementContext): readonly FormPlacementRailItem[];
|
|
167
|
+
/** The tab the dialog starts on: Details when the form has one, else the first. */
|
|
168
|
+
export declare function DefaultRailKeyFor(context: FormPlacementContext): string;
|
|
169
|
+
/**
|
|
170
|
+
* Which rail item the panel will appear under, given the answers so far.
|
|
171
|
+
*
|
|
172
|
+
* Replacing something puts the panel where that thing was, so the answer is the item
|
|
173
|
+
* holding it. Replacing nothing gives the panel a rail item of its own, and null says so:
|
|
174
|
+
* the preview then draws a new item rather than highlighting an existing one.
|
|
175
|
+
*/
|
|
176
|
+
export declare function TargetRailItem(state: FormPlacementState, context: FormPlacementContext): FormPlacementRailItem | null;
|
|
177
|
+
/** The editable answers. One field per control in the dialog. */
|
|
178
|
+
export interface FormPlacementState {
|
|
179
|
+
Slot: FormContributionSlot;
|
|
180
|
+
Presentation: FormContributionPresentation;
|
|
181
|
+
Title: string;
|
|
182
|
+
Icon: string;
|
|
183
|
+
ReplaceMode: FormPlacementReplaceMode;
|
|
184
|
+
/** Key of the rail tab to stand in for, when the mode is `rail-tab`. */
|
|
185
|
+
ReplaceRailKey: string;
|
|
186
|
+
ReplaceSectionKey: string;
|
|
187
|
+
/**
|
|
188
|
+
* Sections to stand in for, when the `section` mode names more than one. Empty means the
|
|
189
|
+
* one in {@link ReplaceSectionKey}.
|
|
190
|
+
*/
|
|
191
|
+
ReplaceSectionKeys: string[];
|
|
192
|
+
/** Section to draw inside, replacing nothing. Empty means the panel goes at {@link Slot}. */
|
|
193
|
+
InSectionKey: string;
|
|
194
|
+
/** Where inside its section the panel draws: for {@link InSectionKey} and for a field claim. */
|
|
195
|
+
SectionPosition: 'start' | 'end';
|
|
196
|
+
/** Section whose fields the `field` mode chooses from. */
|
|
197
|
+
ReplaceFieldSectionKey: string;
|
|
198
|
+
/** Entity field names to stand in for, all inside {@link ReplaceFieldSectionKey}. */
|
|
199
|
+
ReplaceFieldNames: string[];
|
|
200
|
+
ReplaceRelatedIndex: number;
|
|
201
|
+
ReplaceContributionIndex: number;
|
|
202
|
+
/**
|
|
203
|
+
* Order among the panels in the same position, higher first. Null leaves it unset: a new
|
|
204
|
+
* panel saves 0, and an edited one keeps the order it has.
|
|
205
|
+
*/
|
|
206
|
+
SortKey: number | null;
|
|
207
|
+
ActivateNow: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Keeps a panel that is off, off, rather than saving it as a draft. Only an edit of a panel
|
|
210
|
+
* that is off offers it, and it is false whenever {@link ActivateNow} is true.
|
|
211
|
+
*/
|
|
212
|
+
KeepOff: boolean;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A proposal's claim the dialog does not offer because the form could not confirm it: the
|
|
216
|
+
* fields, sections or tab the panel was built to stand in for, or the section it was built to
|
|
217
|
+
* sit inside.
|
|
218
|
+
*/
|
|
219
|
+
export type FormPlacementDroppedClaim = {
|
|
220
|
+
Kind: 'field';
|
|
221
|
+
FieldNames: readonly string[];
|
|
222
|
+
} | {
|
|
223
|
+
Kind: 'section';
|
|
224
|
+
SectionKeys: readonly string[];
|
|
225
|
+
} | {
|
|
226
|
+
Kind: 'rail-tab';
|
|
227
|
+
RailKey: string;
|
|
228
|
+
} | {
|
|
229
|
+
Kind: 'in-section';
|
|
230
|
+
SectionKey: string;
|
|
231
|
+
};
|
|
232
|
+
/** The answers, in the shape the write path consumes. */
|
|
233
|
+
export interface FormPlacementDecision {
|
|
234
|
+
/** Merged into `spec.formContribution` before the create action runs. */
|
|
235
|
+
Contribution: FormContributionSpec;
|
|
236
|
+
/** False leaves the row Pending — stored, rendering for nobody. */
|
|
237
|
+
ActivateNow: boolean;
|
|
238
|
+
/** True leaves a row that is off, off, rather than Pending. */
|
|
239
|
+
KeepOff?: boolean;
|
|
240
|
+
}
|
|
241
|
+
/** One position a panel can take, named twice: for the reader and for the record. */
|
|
242
|
+
export interface FormPlacementSlotChoice {
|
|
243
|
+
Slot: FormContributionSlot;
|
|
244
|
+
/** Where it is on the form, in plain words. What the dialog leads with. */
|
|
245
|
+
Name: string;
|
|
246
|
+
/** The slot's own name, which is what reaches the database. Shown beside it. */
|
|
247
|
+
Label: string;
|
|
248
|
+
}
|
|
249
|
+
/** The slots, top to bottom. */
|
|
250
|
+
export declare const FORM_PLACEMENT_SLOTS: readonly FormPlacementSlotChoice[];
|
|
251
|
+
/**
|
|
252
|
+
* Whether the form emits this slot.
|
|
253
|
+
*
|
|
254
|
+
* An empty {@link FormPlacementContext.SlotsPresent} means nobody has told us, not that the
|
|
255
|
+
* form has no slots, so the generated shape stands in. That shape excludes `top-area`, which
|
|
256
|
+
* no form emits — offering it would send the panel to the bottom of the form under a label
|
|
257
|
+
* that says the opposite.
|
|
258
|
+
*/
|
|
259
|
+
export declare function SlotIsOnForm(context: FormPlacementContext, slot: FormContributionSlot): boolean;
|
|
260
|
+
/** The preferred slot, unless this form does not emit it — then the first one it does. */
|
|
261
|
+
export declare function DefaultSlotFor(context: FormPlacementContext): FormContributionSlot;
|
|
262
|
+
/**
|
|
263
|
+
* The starting answers.
|
|
264
|
+
*
|
|
265
|
+
* The fixed default. A host that wants the dialog to start from a proposal's claims seeds it
|
|
266
|
+
* with {@link PlacementStateFromContribution}.
|
|
267
|
+
*
|
|
268
|
+
* The one thing that moves the default is the form: starting on a slot the form does not
|
|
269
|
+
* emit would put the panel at the bottom no matter what the dialog showed.
|
|
270
|
+
*/
|
|
271
|
+
export declare function InitialPlacementState(proposal: FormContributionSpec | null, context: FormPlacementContext): FormPlacementState;
|
|
272
|
+
/**
|
|
273
|
+
* The starting answers read from a contribution block: the user's own earlier choice when
|
|
274
|
+
* editing a saved row, or a generated panel's proposal when applying one. A claim the form
|
|
275
|
+
* cannot honour falls back to the default.
|
|
276
|
+
*
|
|
277
|
+
* While the form is unread ({@link TargetsUnread}), a section, tab, field or in-section claim
|
|
278
|
+
* cannot be checked, so it is passed through as stated. A grid or panel claim is still checked
|
|
279
|
+
* against the context's grids and panels. A field claim is matched against the sections' fields
|
|
280
|
+
* whether or not those were read from the form, so it can name fields the dialog does not offer.
|
|
281
|
+
*
|
|
282
|
+
* @param activeNow Whether the panel is on now, so the edit keeps it on.
|
|
283
|
+
* @param keepOff Whether the panel is off now, so the edit keeps it off rather than making it a draft.
|
|
284
|
+
*/
|
|
285
|
+
export declare function PlacementStateFromContribution(spec: FormContributionSpec, context: FormPlacementContext, activeNow: boolean, keepOff?: boolean): FormPlacementState;
|
|
286
|
+
/**
|
|
287
|
+
* The block an edited row is written back with.
|
|
288
|
+
*
|
|
289
|
+
* {@link ResolvePlacementDecision} writes a key only when the user chose to replace a panel, and
|
|
290
|
+
* the write path derives one otherwise. For a row already saved, that would change its identity
|
|
291
|
+
* on every edit. So a decision with no key and no grid claim keeps the row's own key, unless that
|
|
292
|
+
* key was the claim the user just dropped: the key of a panel the dialog listed, or a grid key.
|
|
293
|
+
*
|
|
294
|
+
* @param existing The other panels the dialog offered to replace.
|
|
295
|
+
*/
|
|
296
|
+
export declare function KeepEditedRowKey(contribution: FormContributionSpec, row: {
|
|
297
|
+
ContributionKey: string | null;
|
|
298
|
+
}, existing: readonly FormPlacementExisting[]): FormContributionSpec;
|
|
299
|
+
/**
|
|
300
|
+
* The state as a contribution block.
|
|
301
|
+
*
|
|
302
|
+
* `sortKey` is written only once the user has placed the panel among others in its position,
|
|
303
|
+
* and `contributionKey` is set only when the user chose to
|
|
304
|
+
* take over a named panel. A key is what makes one contribution replace another, so it is
|
|
305
|
+
* written when a replacement is meant and left for the write path to derive otherwise — the
|
|
306
|
+
* duplicate check compares those strings literally, and two algorithms would not agree.
|
|
307
|
+
* The proposal's `configuration` is carried through; a field claim also writes the chosen
|
|
308
|
+
* fields into `configuration.fields`.
|
|
309
|
+
*/
|
|
310
|
+
export declare function ResolvePlacementDecision(state: FormPlacementState, context: FormPlacementContext, proposal: FormContributionSpec | null): FormPlacementDecision;
|
|
311
|
+
/**
|
|
312
|
+
* The proposal merged onto the spec the write path sends.
|
|
313
|
+
*
|
|
314
|
+
* The spec is what the component runs from, so it is copied rather than edited: the caller
|
|
315
|
+
* may still be showing the original in a preview.
|
|
316
|
+
*/
|
|
317
|
+
export declare function ApplyDecisionToSpec<T extends {
|
|
318
|
+
formContribution?: FormContributionSpec;
|
|
319
|
+
}>(spec: T, decision: FormPlacementDecision): T;
|
|
320
|
+
//# sourceMappingURL=form-placement.d.ts.map
|