@memberjunction/ng-base-forms 6.2.0-edge.4 → 6.2.0-edge.6

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 (102) hide show
  1. package/README.md +195 -2
  2. package/dist/lib/base-form-component.d.ts +23 -1
  3. package/dist/lib/base-form-component.d.ts.map +1 -1
  4. package/dist/lib/base-form-component.js +54 -10
  5. package/dist/lib/base-form-component.js.map +1 -1
  6. package/dist/lib/chrome/form-chrome-coordinator.service.d.ts +9 -0
  7. package/dist/lib/chrome/form-chrome-coordinator.service.d.ts.map +1 -1
  8. package/dist/lib/chrome/form-chrome-coordinator.service.js +11 -0
  9. package/dist/lib/chrome/form-chrome-coordinator.service.js.map +1 -1
  10. package/dist/lib/chrome/form-composition-snapshot.d.ts +52 -0
  11. package/dist/lib/chrome/form-composition-snapshot.d.ts.map +1 -1
  12. package/dist/lib/chrome/form-composition-snapshot.js +4 -0
  13. package/dist/lib/chrome/form-composition-snapshot.js.map +1 -1
  14. package/dist/lib/container/record-form-container.component.d.ts +107 -1
  15. package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
  16. package/dist/lib/container/record-form-container.component.js +1500 -316
  17. package/dist/lib/container/record-form-container.component.js.map +1 -1
  18. package/dist/lib/field/form-field.component.d.ts +167 -14
  19. package/dist/lib/field/form-field.component.d.ts.map +1 -1
  20. package/dist/lib/field/form-field.component.js +1374 -470
  21. package/dist/lib/field/form-field.component.js.map +1 -1
  22. package/dist/lib/form-record-refresh.coordinator.d.ts +124 -0
  23. package/dist/lib/form-record-refresh.coordinator.d.ts.map +1 -1
  24. package/dist/lib/form-record-refresh.coordinator.js +93 -13
  25. package/dist/lib/form-record-refresh.coordinator.js.map +1 -1
  26. package/dist/lib/host/entity-form-host.component.d.ts +104 -2
  27. package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
  28. package/dist/lib/host/entity-form-host.component.js +272 -34
  29. package/dist/lib/host/entity-form-host.component.js.map +1 -1
  30. package/dist/lib/isa-related-panel/isa-related-card.component.js +7 -4
  31. package/dist/lib/isa-related-panel/isa-related-card.component.js.map +1 -1
  32. package/dist/lib/isa-related-panel/isa-related-panel.component.js +1 -2
  33. package/dist/lib/isa-related-panel/isa-related-panel.component.js.map +1 -1
  34. package/dist/lib/links/record-link-utils.d.ts +83 -0
  35. package/dist/lib/links/record-link-utils.d.ts.map +1 -0
  36. package/dist/lib/links/record-link-utils.js +232 -0
  37. package/dist/lib/links/record-link-utils.js.map +1 -0
  38. package/dist/lib/links/record-link.component.d.ts +50 -0
  39. package/dist/lib/links/record-link.component.d.ts.map +1 -0
  40. package/dist/lib/links/record-link.component.js +319 -0
  41. package/dist/lib/links/record-link.component.js.map +1 -0
  42. package/dist/lib/links/record-link.directive.d.ts +94 -0
  43. package/dist/lib/links/record-link.directive.d.ts.map +1 -0
  44. package/dist/lib/links/record-link.directive.js +277 -0
  45. package/dist/lib/links/record-link.directive.js.map +1 -0
  46. package/dist/lib/links/record-links-drawer.component.d.ts +21 -0
  47. package/dist/lib/links/record-links-drawer.component.d.ts.map +1 -0
  48. package/dist/lib/links/record-links-drawer.component.js +61 -0
  49. package/dist/lib/links/record-links-drawer.component.js.map +1 -0
  50. package/dist/lib/links/record-links.component.d.ts +249 -0
  51. package/dist/lib/links/record-links.component.d.ts.map +1 -0
  52. package/dist/lib/links/record-links.component.js +1523 -0
  53. package/dist/lib/links/record-links.component.js.map +1 -0
  54. package/dist/lib/panel/collapsible-panel.component.d.ts.map +1 -1
  55. package/dist/lib/panel/collapsible-panel.component.js +5 -0
  56. package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
  57. package/dist/lib/panel-slot/form-field-panel-slot.component.d.ts.map +1 -1
  58. package/dist/lib/panel-slot/form-field-panel-slot.component.js +3 -1
  59. package/dist/lib/panel-slot/form-field-panel-slot.component.js.map +1 -1
  60. package/dist/lib/panel-slot/form-panel-slot.component.d.ts.map +1 -1
  61. package/dist/lib/panel-slot/form-panel-slot.component.js +6 -0
  62. package/dist/lib/panel-slot/form-panel-slot.component.js.map +1 -1
  63. package/dist/lib/preview-popover/record-preview-popover.component.d.ts +187 -0
  64. package/dist/lib/preview-popover/record-preview-popover.component.d.ts.map +1 -0
  65. package/dist/lib/preview-popover/record-preview-popover.component.js +1060 -0
  66. package/dist/lib/preview-popover/record-preview-popover.component.js.map +1 -0
  67. package/dist/lib/preview-popover/record-preview-popover.service.d.ts +105 -0
  68. package/dist/lib/preview-popover/record-preview-popover.service.d.ts.map +1 -0
  69. package/dist/lib/preview-popover/record-preview-popover.service.js +278 -0
  70. package/dist/lib/preview-popover/record-preview-popover.service.js.map +1 -0
  71. package/dist/lib/resolver/form-resolver.service.d.ts +44 -1
  72. package/dist/lib/resolver/form-resolver.service.d.ts.map +1 -1
  73. package/dist/lib/resolver/form-resolver.service.js +51 -3
  74. package/dist/lib/resolver/form-resolver.service.js.map +1 -1
  75. package/dist/lib/toolbar/actions/record-links-toolbar-action.d.ts +21 -0
  76. package/dist/lib/toolbar/actions/record-links-toolbar-action.d.ts.map +1 -0
  77. package/dist/lib/toolbar/actions/record-links-toolbar-action.js +90 -0
  78. package/dist/lib/toolbar/actions/record-links-toolbar-action.js.map +1 -0
  79. package/dist/lib/toolbar/base-form-toolbar-action.d.ts +189 -0
  80. package/dist/lib/toolbar/base-form-toolbar-action.d.ts.map +1 -0
  81. package/dist/lib/toolbar/base-form-toolbar-action.js +274 -0
  82. package/dist/lib/toolbar/base-form-toolbar-action.js.map +1 -0
  83. package/dist/lib/toolbar/form-toolbar.component.d.ts +21 -1
  84. package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
  85. package/dist/lib/toolbar/form-toolbar.component.js +295 -195
  86. package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
  87. package/dist/lib/types/form-toolbar-item.d.ts +1 -1
  88. package/dist/lib/types/form-toolbar-item.d.ts.map +1 -1
  89. package/dist/lib/types/form-toolbar-item.js.map +1 -1
  90. package/dist/lib/types/toolbar-config.d.ts +4 -0
  91. package/dist/lib/types/toolbar-config.d.ts.map +1 -1
  92. package/dist/lib/types/toolbar-config.js +6 -0
  93. package/dist/lib/types/toolbar-config.js.map +1 -1
  94. package/dist/module.d.ts +19 -14
  95. package/dist/module.d.ts.map +1 -1
  96. package/dist/module.js +39 -6
  97. package/dist/module.js.map +1 -1
  98. package/dist/public-api.d.ts +9 -0
  99. package/dist/public-api.d.ts.map +1 -1
  100. package/dist/public-api.js +9 -0
  101. package/dist/public-api.js.map +1 -1
  102. package/package.json +20 -20
@@ -1,5 +1,19 @@
1
1
  import { BaseEntity } from '@memberjunction/core';
2
2
  import * as i0 from "@angular/core";
3
+ /**
4
+ * Represents a field-level edit conflict where a remote session modified a field
5
+ * that the user has also modified locally while in Edit Mode.
6
+ */
7
+ export interface FormFieldConflict {
8
+ /** Field name on the entity */
9
+ fieldName: string;
10
+ /** Server value before the remote update */
11
+ previousServerValue: unknown;
12
+ /** New value that just arrived from the server */
13
+ incomingServerValue: unknown;
14
+ /** Unsaved value the user currently has in the form */
15
+ localEditedValue: unknown;
16
+ }
3
17
  /**
4
18
  * Per-form broadcast that the current record was reloaded from the database.
5
19
  *
@@ -13,14 +27,124 @@ import * as i0 from "@angular/core";
13
27
  * waiting on `DeferLoadUntilVisible`). Parent refresh is not a license to
14
28
  * fan out RunView across every collapsed section.
15
29
  */
30
+ export interface FormRemoteUpdateEvent {
31
+ record: BaseEntity;
32
+ changedFieldNames: ReadonlySet<string>;
33
+ /** Map of lowercased field name -> previous server value for clean fields that were auto-merged while editing */
34
+ autoMergedPreviousValues?: ReadonlyMap<string, unknown>;
35
+ /** Map of lowercased field name -> conflict info for dirty fields whose server value changed */
36
+ conflicts?: ReadonlyMap<string, FormFieldConflict>;
37
+ }
38
+ /**
39
+ * Per-field comparison between a historical version snapshot and the current live record.
40
+ */
41
+ export interface FormVersionPreviewFieldDiff {
42
+ FieldName: string;
43
+ DisplayName?: string;
44
+ HistoricalValue: unknown;
45
+ CurrentLiveValue: unknown;
46
+ IsChanged?: boolean;
47
+ }
48
+ /**
49
+ * Active In-Form Time-Travel version preview state broadcast to all `<mj-form-field>` instances.
50
+ */
51
+ export interface FormVersionPreviewState {
52
+ ChangeID: string;
53
+ ChangedAt: Date | string;
54
+ ChangedByUser?: string;
55
+ UserName?: string;
56
+ VersionLabel?: string;
57
+ VersionSummary?: string;
58
+ ChangeType?: string;
59
+ Type?: string;
60
+ Source?: string;
61
+ Summary?: string;
62
+ Comments?: string;
63
+ /** Raw parsed `FullRecordJSON` map keyed by field name */
64
+ SnapshotValues?: Readonly<Record<string, unknown>>;
65
+ Snapshot?: Readonly<Record<string, unknown>>;
66
+ /** Map of lowercased field name -> diff against the live record */
67
+ FieldDiffs?: ReadonlyMap<string, FormVersionPreviewFieldDiff>;
68
+ ChangedFields?: ReadonlyMap<string, FormVersionPreviewFieldDiff>;
69
+ /** Count of fields that differ between the historical snapshot and current live record */
70
+ DiffCount?: number;
71
+ CurrentIndex?: number;
72
+ TotalRestoreableCount?: number;
73
+ }
74
+ /**
75
+ * Request emitted when the user clicks "Restore this field" on an individual `<mj-form-field>`
76
+ * while in Time-Travel version preview mode.
77
+ */
78
+ export interface FormSingleFieldRestoreRequest {
79
+ FieldName: string;
80
+ HistoricalValue: unknown;
81
+ SourceChangeID?: string;
82
+ ChangeID?: string;
83
+ ChangedAt?: Date | string;
84
+ ChangedByUser?: string;
85
+ }
16
86
  export declare class FormRecordRefreshCoordinator {
17
87
  private readonly refreshed$;
88
+ private readonly remoteUpdated$;
89
+ private readonly activeConflicts;
90
+ private readonly conflictsChanged$;
91
+ private activeVersionPreview;
92
+ private readonly versionPreviewChanged$;
93
+ private readonly singleFieldRestoreRequested$;
18
94
  /** Emits the live parent record after a successful `RefreshRecord()`. */
19
95
  readonly Refreshed$: import("rxjs").Observable<BaseEntity<unknown>>;
96
+ /**
97
+ * Emits when the parent record was auto-refreshed due to a remote/cross-tab
98
+ * update, carrying the set of field names (lowercased and original) whose
99
+ * values changed so `<mj-form-field>` instances can briefly highlight them
100
+ * and refresh any cached FK labels.
101
+ */
102
+ readonly RemoteUpdated$: import("rxjs").Observable<FormRemoteUpdateEvent>;
103
+ /**
104
+ * Emits whenever the map of unresolved field conflicts changes.
105
+ */
106
+ readonly ConflictsChanged$: import("rxjs").Observable<ReadonlyMap<string, FormFieldConflict>>;
107
+ /**
108
+ * Emits whenever the active In-Form Time-Travel version preview state changes.
109
+ */
110
+ readonly VersionPreviewChanged$: import("rxjs").Observable<FormVersionPreviewState | null>;
111
+ /**
112
+ * Emits when a single `<mj-form-field>` requests restoring only its historical value.
113
+ */
114
+ readonly SingleFieldRestoreRequested$: import("rxjs").Observable<FormSingleFieldRestoreRequest>;
115
+ /**
116
+ * Current map of unresolved field conflicts (keyed by lowercased field name).
117
+ */
118
+ get ActiveConflicts(): ReadonlyMap<string, FormFieldConflict>;
119
+ /**
120
+ * Currently active In-Form Time-Travel version preview state, or `null` when viewing live data.
121
+ */
122
+ get ActiveVersionPreview(): FormVersionPreviewState | null;
123
+ /**
124
+ * Enter, update, or exit In-Form Time-Travel version preview mode.
125
+ */
126
+ SetVersionPreview(preview: FormVersionPreviewState | null): void;
127
+ /**
128
+ * Request restoring a single field's historical value from the active Time-Travel preview.
129
+ */
130
+ RequestRestoreSingleField(request: FormSingleFieldRestoreRequest): void;
20
131
  /**
21
132
  * Push a successful parent-record refresh to in-form listeners.
22
133
  */
23
134
  Notify(record: BaseEntity): void;
135
+ /**
136
+ * Push a remote/cross-tab update notification with the set of changed field names,
137
+ * optional auto-merged clean field baselines, and optional dirty-field conflicts.
138
+ */
139
+ NotifyRemoteUpdate(record: BaseEntity, changedFieldNames: ReadonlySet<string>, autoMergedPreviousValues?: ReadonlyMap<string, unknown>, conflicts?: ReadonlyMap<string, FormFieldConflict>): void;
140
+ /**
141
+ * Mark a single field's conflict as resolved and notify subscribers.
142
+ */
143
+ ResolveConflict(fieldName: string): void;
144
+ /**
145
+ * Clear all active conflicts (e.g. when saving, cancelling edit mode, or switching records).
146
+ */
147
+ ClearAllConflicts(): void;
24
148
  static ɵfac: i0.ɵɵFactoryDeclaration<FormRecordRefreshCoordinator, never>;
25
149
  static ɵprov: i0.ɵɵInjectableDeclaration<FormRecordRefreshCoordinator>;
26
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form-record-refresh.coordinator.d.ts","sourceRoot":"","sources":["../../src/lib/form-record-refresh.coordinator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;;AAElD;;;;;;;;;;;;GAYG;AACH,qBACa,4BAA4B;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IAExD,yEAAyE;IACzE,SAAgB,UAAU,iDAAkC;IAE5D;;OAEG;IACI,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;yCAT9B,4BAA4B;6CAA5B,4BAA4B;CAYxC"}
1
+ {"version":3,"file":"form-record-refresh.coordinator.d.ts","sourceRoot":"","sources":["../../src/lib/form-record-refresh.coordinator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;;AAElD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,mBAAmB,EAAE,OAAO,CAAC;IAC7B,kDAAkD;IAClD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,uDAAuD;IACvD,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,iHAAiH;IACjH,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,gGAAgG;IAChG,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,C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S,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACnD,IAAI;IAgBP;;OAEG;IACI,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAU/C;;OAEG;IACI,iBAAiB,IAAI,IAAI;yCAhHvB,4BAA4B;6CAA5B,4BAA4B;CAwHxC"}
@@ -1,29 +1,109 @@
1
1
  import { Injectable } from '@angular/core';
2
2
  import { Subject } from 'rxjs';
3
3
  import * as i0 from "@angular/core";
4
- /**
5
- * Per-form broadcast that the current record was reloaded from the database.
6
- *
7
- * Provided on `<mj-record-form-container>` (same pattern as
8
- * {@link FormChromeCoordinator} / {@link FormSlotCoordinator}) so projected
9
- * related-entity grids, slot-mounted panels, the IS-A side panel, and the
10
- * toolbar can all see it. `providers` (not `viewProviders`) is what makes
11
- * that visible to `ng-content`.
12
- *
13
- * Listeners MUST no-op when they have never loaded (e.g. a related grid still
14
- * waiting on `DeferLoadUntilVisible`). Parent refresh is not a license to
15
- * fan out RunView across every collapsed section.
16
- */
17
4
  export class FormRecordRefreshCoordinator {
18
5
  refreshed$ = new Subject();
6
+ remoteUpdated$ = new Subject();
7
+ activeConflicts = new Map();
8
+ conflictsChanged$ = new Subject();
9
+ activeVersionPreview = null;
10
+ versionPreviewChanged$ = new Subject();
11
+ singleFieldRestoreRequested$ = new Subject();
19
12
  /** Emits the live parent record after a successful `RefreshRecord()`. */
20
13
  Refreshed$ = this.refreshed$.asObservable();
14
+ /**
15
+ * Emits when the parent record was auto-refreshed due to a remote/cross-tab
16
+ * update, carrying the set of field names (lowercased and original) whose
17
+ * values changed so `<mj-form-field>` instances can briefly highlight them
18
+ * and refresh any cached FK labels.
19
+ */
20
+ RemoteUpdated$ = this.remoteUpdated$.asObservable();
21
+ /**
22
+ * Emits whenever the map of unresolved field conflicts changes.
23
+ */
24
+ ConflictsChanged$ = this.conflictsChanged$.asObservable();
25
+ /**
26
+ * Emits whenever the active In-Form Time-Travel version preview state changes.
27
+ */
28
+ VersionPreviewChanged$ = this.versionPreviewChanged$.asObservable();
29
+ /**
30
+ * Emits when a single `<mj-form-field>` requests restoring only its historical value.
31
+ */
32
+ SingleFieldRestoreRequested$ = this.singleFieldRestoreRequested$.asObservable();
33
+ /**
34
+ * Current map of unresolved field conflicts (keyed by lowercased field name).
35
+ */
36
+ get ActiveConflicts() {
37
+ return this.activeConflicts;
38
+ }
39
+ /**
40
+ * Currently active In-Form Time-Travel version preview state, or `null` when viewing live data.
41
+ */
42
+ get ActiveVersionPreview() {
43
+ return this.activeVersionPreview;
44
+ }
45
+ /**
46
+ * Enter, update, or exit In-Form Time-Travel version preview mode.
47
+ */
48
+ SetVersionPreview(preview) {
49
+ this.activeVersionPreview = preview;
50
+ this.versionPreviewChanged$.next(preview);
51
+ }
52
+ /**
53
+ * Request restoring a single field's historical value from the active Time-Travel preview.
54
+ */
55
+ RequestRestoreSingleField(request) {
56
+ this.singleFieldRestoreRequested$.next(request);
57
+ }
21
58
  /**
22
59
  * Push a successful parent-record refresh to in-form listeners.
23
60
  */
24
61
  Notify(record) {
25
62
  this.refreshed$.next(record);
26
63
  }
64
+ /**
65
+ * Push a remote/cross-tab update notification with the set of changed field names,
66
+ * optional auto-merged clean field baselines, and optional dirty-field conflicts.
67
+ */
68
+ NotifyRemoteUpdate(record, changedFieldNames, autoMergedPreviousValues, conflicts) {
69
+ if (conflicts && conflicts.size > 0) {
70
+ for (const [key, conflict] of conflicts.entries()) {
71
+ this.activeConflicts.set(key.toLowerCase(), conflict);
72
+ }
73
+ this.conflictsChanged$.next(new Map(this.activeConflicts));
74
+ }
75
+ this.remoteUpdated$.next({
76
+ record,
77
+ changedFieldNames,
78
+ autoMergedPreviousValues,
79
+ conflicts
80
+ });
81
+ this.refreshed$.next(record);
82
+ }
83
+ /**
84
+ * Mark a single field's conflict as resolved and notify subscribers.
85
+ */
86
+ ResolveConflict(fieldName) {
87
+ if (!fieldName) {
88
+ return;
89
+ }
90
+ const key = fieldName.toLowerCase();
91
+ if (this.activeConflicts.delete(key)) {
92
+ this.conflictsChanged$.next(new Map(this.activeConflicts));
93
+ }
94
+ }
95
+ /**
96
+ * Clear all active conflicts (e.g. when saving, cancelling edit mode, or switching records).
97
+ */
98
+ ClearAllConflicts() {
99
+ if (this.activeConflicts.size > 0) {
100
+ this.activeConflicts.clear();
101
+ this.conflictsChanged$.next(new Map(this.activeConflicts));
102
+ }
103
+ else {
104
+ this.conflictsChanged$.next(new Map());
105
+ }
106
+ }
27
107
  static ɵfac = function FormRecordRefreshCoordinator_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FormRecordRefreshCoordinator)(); };
28
108
  static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FormRecordRefreshCoordinator, factory: FormRecordRefreshCoordinator.ɵfac });
29
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form-record-refresh.coordinator.js","sourceRoot":"","sources":["../../src/lib/form-record-refresh.coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;;AAG/B;;;;;;;;;;;;GAYG;AAEH,MAAM,OAAO,4BAA4B;IACpB,UAAU,GAAG,IAAI,OAAO,EAAc,CAAC;IAExD,yEAAyE;IACzD,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAC,MAAkB;QAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;sHAXQ,4BAA4B;gEAA5B,4BAA4B,WAA5B,4BAA4B;;iFAA5B,4BAA4B;cADxC,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { BaseEntity } from '@memberjunction/core';\n\n/**\n * Per-form broadcast that the current record was reloaded from the database.\n *\n * Provided on `<mj-record-form-container>` (same pattern as\n * {@link FormChromeCoordinator} / {@link FormSlotCoordinator}) so projected\n * related-entity grids, slot-mounted panels, the IS-A side panel, and the\n * toolbar can all see it. `providers` (not `viewProviders`) is what makes\n * that visible to `ng-content`.\n *\n * Listeners MUST no-op when they have never loaded (e.g. a related grid still\n * waiting on `DeferLoadUntilVisible`). Parent refresh is not a license to\n * fan out RunView across every collapsed section.\n */\n@Injectable()\nexport class FormRecordRefreshCoordinator {\n private readonly refreshed$ = new Subject<BaseEntity>();\n\n /** Emits the live parent record after a successful `RefreshRecord()`. */\n public readonly Refreshed$ = this.refreshed$.asObservable();\n\n /**\n * Push a successful parent-record refresh to in-form listeners.\n */\n public Notify(record: BaseEntity): void {\n this.refreshed$.next(record);\n }\n}\n"]}
1
+ {"version":3,"file":"form-record-refresh.coordinator.js","sourceRoot":"","sources":["../../src/lib/form-record-refresh.coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;;AA4F/B,MAAM,OAAO,4BAA4B;IACpB,UAAU,GAAG,IAAI,OAAO,EAAc,CAAC;IACvC,cAAc,GAAG,IAAI,OAAO,EAAyB,CAAC;IACtD,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAC;IACvD,iBAAiB,GAAG,IAAI,OAAO,EAA0C,CAAC;IACnF,oBAAoB,GAAmC,IAAI,CAAC;IACnD,sBAAsB,GAAG,IAAI,OAAO,EAAkC,CAAC;IACvE,4BAA4B,GAAG,IAAI,OAAO,EAAiC,CAAC;IAE7F,yEAAyE;IACzD,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;IAE5D;;;;;OAKG;IACa,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IAEpE;;OAEG;IACa,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC;IAE1E;;OAEG;IACa,sBAAsB,GAAG,IAAI,CAAC,sBAAs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,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,SAAiB;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO;QACX,CAAC;QACD,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;QAC/D,CAAC;IACL,CAAC;IAED;;OAEG;IACI,iBAAiB;QACpB,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;sHAvHQ,4BAA4B;gEAA5B,4BAA4B,WAA5B,4BAA4B;;iFAA5B,4BAA4B;cADxC,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { BaseEntity } from '@memberjunction/core';\n\n/**\n * Represents a field-level edit conflict where a remote session modified a field\n * that the user has also modified locally while in Edit Mode.\n */\nexport interface FormFieldConflict {\n /** Field name on the entity */\n fieldName: string;\n /** Server value before the remote update */\n previousServerValue: unknown;\n /** New value that just arrived from the server */\n incomingServerValue: unknown;\n /** Unsaved value the user currently has in the form */\n localEditedValue: unknown;\n}\n\n/**\n * Per-form broadcast that the current record was reloaded from the database.\n *\n * Provided on `<mj-record-form-container>` (same pattern as\n * {@link FormChromeCoordinator} / {@link FormSlotCoordinator}) so projected\n * related-entity grids, slot-mounted panels, the IS-A side panel, and the\n * toolbar can all see it. `providers` (not `viewProviders`) is what makes\n * that visible to `ng-content`.\n *\n * Listeners MUST no-op when they have never loaded (e.g. a related grid still\n * waiting on `DeferLoadUntilVisible`). Parent refresh is not a license to\n * fan out RunView across every collapsed section.\n */\nexport interface FormRemoteUpdateEvent {\n record: BaseEntity;\n changedFieldNames: ReadonlySet<string>;\n /** Map of lowercased field name -> previous server value for clean fields that were auto-merged while editing */\n autoMergedPreviousValues?: ReadonlyMap<string, unknown>;\n /** Map of lowercased field name -> conflict info for dirty fields whose server value changed */\n conflicts?: ReadonlyMap<string, FormFieldConflict>;\n}\n\n/**\n * Per-field comparison between a historical version snapshot and the current live record.\n */\nexport interface FormVersionPreviewFieldDiff {\n FieldName: string;\n DisplayName?: string;\n HistoricalValue: unknown;\n CurrentLiveValue: unknown;\n IsChanged?: boolean;\n}\n\n/**\n * Active In-Form Time-Travel version preview state broadcast to all `<mj-form-field>` instances.\n */\nexport interface FormVersionPreviewState {\n ChangeID: string;\n ChangedAt: Date | string;\n ChangedByUser?: string;\n UserName?: string;\n VersionLabel?: string;\n VersionSummary?: string;\n ChangeType?: string;\n Type?: string;\n Source?: string;\n Summary?: string;\n Comments?: string;\n /** Raw parsed `FullRecordJSON` map keyed by field name */\n SnapshotValues?: Readonly<Record<string, unknown>>;\n Snapshot?: Readonly<Record<string, unknown>>;\n /** Map of lowercased field name -> diff against the live record */\n FieldDiffs?: ReadonlyMap<string, FormVersionPreviewFieldDiff>;\n ChangedFields?: ReadonlyMap<string, FormVersionPreviewFieldDiff>;\n /** Count of fields that differ between the historical snapshot and current live record */\n DiffCount?: number;\n CurrentIndex?: number;\n TotalRestoreableCount?: number;\n}\n\n/**\n * Request emitted when the user clicks \"Restore this field\" on an individual `<mj-form-field>`\n * while in Time-Travel version preview mode.\n */\nexport interface FormSingleFieldRestoreRequest {\n FieldName: string;\n HistoricalValue: unknown;\n SourceChangeID?: string;\n ChangeID?: string;\n ChangedAt?: Date | string;\n ChangedByUser?: string;\n}\n\n@Injectable()\nexport class FormRecordRefreshCoordinator {\n private readonly refreshed$ = new Subject<BaseEntity>();\n private readonly remoteUpdated$ = new Subject<FormRemoteUpdateEvent>();\n private readonly activeConflicts = new Map<string, FormFieldConflict>();\n private readonly conflictsChanged$ = new Subject<ReadonlyMap<string, FormFieldConflict>>();\n private activeVersionPreview: FormVersionPreviewState | null = null;\n private readonly versionPreviewChanged$ = new Subject<FormVersionPreviewState | null>();\n private readonly singleFieldRestoreRequested$ = new Subject<FormSingleFieldRestoreRequest>();\n\n /** Emits the live parent record after a successful `RefreshRecord()`. */\n public readonly Refreshed$ = this.refreshed$.asObservable();\n\n /**\n * Emits when the parent record was auto-refreshed due to a remote/cross-tab\n * update, carrying the set of field names (lowercased and original) whose\n * values changed so `<mj-form-field>` instances can briefly highlight them\n * and refresh any cached FK labels.\n */\n public readonly RemoteUpdated$ = this.remoteUpdated$.asObservable();\n\n /**\n * Emits whenever the map of unresolved field conflicts changes.\n */\n public readonly ConflictsChanged$ = this.conflictsChanged$.asObservable();\n\n /**\n * Emits whenever the active In-Form Time-Travel version preview state changes.\n */\n public readonly VersionPreviewChanged$ = this.versionPreviewChanged$.asObservable();\n\n /**\n * Emits when a single `<mj-form-field>` requests restoring only its historical value.\n */\n public readonly SingleFieldRestoreRequested$ = this.singleFieldRestoreRequested$.asObservable();\n\n /**\n * Current map of unresolved field conflicts (keyed by lowercased field name).\n */\n public get ActiveConflicts(): ReadonlyMap<string, FormFieldConflict> {\n return this.activeConflicts;\n }\n\n /**\n * Currently active In-Form Time-Travel version preview state, or `null` when viewing live data.\n */\n public get ActiveVersionPreview(): FormVersionPreviewState | null {\n return this.activeVersionPreview;\n }\n\n /**\n * Enter, update, or exit In-Form Time-Travel version preview mode.\n */\n public SetVersionPreview(preview: FormVersionPreviewState | null): void {\n this.activeVersionPreview = preview;\n this.versionPreviewChanged$.next(preview);\n }\n\n /**\n * Request restoring a single field's historical value from the active Time-Travel preview.\n */\n public RequestRestoreSingleField(request: FormSingleFieldRestoreRequest): void {\n this.singleFieldRestoreRequested$.next(request);\n }\n\n /**\n * Push a successful parent-record refresh to in-form listeners.\n */\n public Notify(record: BaseEntity): void {\n this.refreshed$.next(record);\n }\n\n /**\n * Push a remote/cross-tab update notification with the set of changed field names,\n * optional auto-merged clean field baselines, and optional dirty-field conflicts.\n */\n public NotifyRemoteUpdate(\n record: BaseEntity,\n changedFieldNames: ReadonlySet<string>,\n autoMergedPreviousValues?: ReadonlyMap<string, unknown>,\n conflicts?: ReadonlyMap<string, FormFieldConflict>\n ): void {\n if (conflicts && conflicts.size > 0) {\n for (const [key, conflict] of conflicts.entries()) {\n this.activeConflicts.set(key.toLowerCase(), conflict);\n }\n this.conflictsChanged$.next(new Map(this.activeConflicts));\n }\n this.remoteUpdated$.next({\n record,\n changedFieldNames,\n autoMergedPreviousValues,\n conflicts\n });\n this.refreshed$.next(record);\n }\n\n /**\n * Mark a single field's conflict as resolved and notify subscribers.\n */\n public ResolveConflict(fieldName: string): void {\n if (!fieldName) {\n return;\n }\n const key = fieldName.toLowerCase();\n if (this.activeConflicts.delete(key)) {\n this.conflictsChanged$.next(new Map(this.activeConflicts));\n }\n }\n\n /**\n * Clear all active conflicts (e.g. when saving, cancelling edit mode, or switching records).\n */\n public ClearAllConflicts(): void {\n if (this.activeConflicts.size > 0) {\n this.activeConflicts.clear();\n this.conflictsChanged$.next(new Map(this.activeConflicts));\n } else {\n this.conflictsChanged$.next(new Map());\n }\n }\n}\n"]}
@@ -2,6 +2,7 @@ import { EventEmitter, AfterViewInit, OnDestroy } from '@angular/core';
2
2
  import { CompositeKey, BaseEntity } from '@memberjunction/core';
3
3
  import { BaseAngularComponent } from '@memberjunction/ng-base-types';
4
4
  import { BaseFormComponent } from '../base-form-component';
5
+ import { EntityFormMode } from '../resolver/form-resolver.service';
5
6
  import { EntityFormConfig } from '../types/entity-form-config';
6
7
  import { FormNavigationEvent } from '../types/navigation-events';
7
8
  import { FormNotificationEvent, RecordSavedEvent, RecordDeletedEvent, RecordSaveFailedEvent, ValidationFailedEvent } from '../types/form-types';
@@ -33,12 +34,23 @@ import * as i0 from "@angular/core";
33
34
  * ```html
34
35
  * <mj-entity-form-host [Record]="myEntity" [Config]="DIALOG_FORM_CONFIG"></mj-entity-form-host>
35
36
  * ```
37
+ *
38
+ * **Standard-form switch.** When a custom form (a higher-priority class form or
39
+ * an interactive override) hides the CodeGen-generated form, the host renders a
40
+ * one-line strip above it offering "Open standard form" — every field, same
41
+ * permissions — and back. It lives here rather than in `<mj-form-toolbar>`
42
+ * because a fully custom form may not render the toolbar at all, which would
43
+ * leave the generated form unreachable. Surfaces drive/persist the choice via
44
+ * {@link FormMode} / {@link FormModeChange}; hosts that must not offer it set
45
+ * {@link ShowFormModeSwitch} to false.
36
46
  */
37
47
  export declare class MjEntityFormHostComponent extends BaseAngularComponent implements AfterViewInit, OnDestroy {
38
48
  private cdr;
39
49
  private formResolver;
40
50
  /** Anchor for the dynamically-created form component. Always present in the DOM. */
41
51
  private anchor;
52
+ /** The strip's switch button — present only while the strip renders. */
53
+ private modeSwitchButton?;
42
54
  private _entityName;
43
55
  /** Entity name to load a record for. Ignored when {@link Record} is supplied. */
44
56
  set EntityName(value: string | null);
@@ -72,6 +84,17 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
72
84
  get EditMode(): boolean | null;
73
85
  /** Per-instance form presentation config (toolbar, sections, width, links). */
74
86
  Config: EntityFormConfig | null;
87
+ private _formMode;
88
+ /**
89
+ * Which form to mount: `'default'` = the resolver's normal pick; `'standard'`
90
+ * = the CodeGen-generated form, even when a custom form outranks it. Falls
91
+ * back to the default (and logs) when the entity has no standard form.
92
+ * A change after the view initializes reloads the form.
93
+ */
94
+ set FormMode(value: EntityFormMode);
95
+ get FormMode(): EntityFormMode;
96
+ /** Offer the standard-form strip when a custom form hides the generated one. Set false to suppress it. */
97
+ ShowFormModeSwitch: boolean;
75
98
  /** Form navigation request (record link, new record, hierarchy, email, external, dismiss). */
76
99
  Navigate: EventEmitter<FormNavigationEvent>;
77
100
  /** User-facing notification request (success/error/warning/info). */
@@ -101,6 +124,8 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
101
124
  }>;
102
125
  /** The live form instance, emitted right after it's created (for power-user wiring). */
103
126
  FormCreated: EventEmitter<BaseFormComponent>;
127
+ /** The user switched between the custom and the standard form (so the surface can persist it, e.g. in the URL). */
128
+ FormModeChange: EventEmitter<EntityFormMode>;
104
129
  /**
105
130
  * Re-emitted form `EditModeChanged` (true = edit started, false = ended),
106
131
  * plus one `true` right after mount when the form was created already in
@@ -108,6 +133,8 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
108
133
  * in that path, so without this the shell would never hear about it.
109
134
  */
110
135
  EditModeChanged: EventEmitter<boolean>;
136
+ /** Emitted when the user clicks the "Ask AI" button on the form toolbar. */
137
+ AskAIRequested: EventEmitter<void>;
111
138
  Loading: boolean;
112
139
  /** @deprecated Use {@link Loading}. */
113
140
  get loading(): boolean;
@@ -119,6 +146,12 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
119
146
  /** @deprecated Use {@link ErrorTitle}. */
120
147
  set errorTitle(value: string | null);
121
148
  errorDetail: string | null;
149
+ /**
150
+ * True when a custom form is hiding the standard (CodeGen) form — so the
151
+ * switch strip has somewhere to go. Stays true while the standard form is
152
+ * the one mounted, so the strip can offer the way back.
153
+ */
154
+ HasStandardFormAlternative: boolean;
122
155
  private _formComponentRef;
123
156
  private _sectionRef;
124
157
  private _isSection;
@@ -126,6 +159,26 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
126
159
  private _saveHandlerSub;
127
160
  private _formEventSubs;
128
161
  private _viewInitialized;
162
+ /**
163
+ * An unsaved new record carried across a form switch. A brand-new record is
164
+ * always `Dirty` (never saved), so the dirty guard can't protect it; instead
165
+ * the switch re-binds the same live instance rather than creating a fresh one,
166
+ * so whatever the user typed survives. Consumed by the next {@link obtainRecord}.
167
+ */
168
+ private _carryNewRecord;
169
+ /**
170
+ * Set when the strip's own button started a switch. The reload unmounts the
171
+ * strip (and the focused button with it), so focus is handed to the new
172
+ * button once the mount completes instead of falling to `<body>`.
173
+ */
174
+ private _refocusModeSwitch;
175
+ /**
176
+ * Bumped by every {@link teardown} (so by every reload and by destroy). A
177
+ * load captures it on entry and gives up after any `await` once it has
178
+ * moved: a superseded load must not mount, emit, register a save handler,
179
+ * or report a failure over the load that replaced it.
180
+ */
181
+ private _loadGeneration;
129
182
  /** The live form component instance, or null before mount / after teardown. */
130
183
  get Form(): BaseFormComponent | null;
131
184
  /** Whether the bound record has unsaved changes. */
@@ -143,8 +196,54 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
143
196
  Cancel(): void;
144
197
  /** Refresh the bound record from the database. Full-form mode uses the form's refresh pipeline. */
145
198
  Refresh(): Promise<boolean>;
199
+ /**
200
+ * Switch between the custom (`'default'`) and the standard form. Refuses —
201
+ * returning false and emitting a `warning` Notification — when remounting
202
+ * would silently discard unsaved work (see {@link hasUnsavedWorkToLose}).
203
+ * A brand-new record is carried across instead (see {@link _carryNewRecord}).
204
+ * With a form mounted but no standard alternative (the generated form is
205
+ * the only one), both modes mount the same form: the mode is recorded and
206
+ * emitted, with no reload and so nothing for the unsaved-work guard to
207
+ * protect. The error state is excluded: `fail()` also clears
208
+ * `HasStandardFormAlternative` and `Loading`, and there the switch must
209
+ * still reload — it is the retry of the failed load.
210
+ */
211
+ SwitchFormMode(mode: EntityFormMode): boolean;
212
+ /** Template handler for the strip's button: switch, and keep keyboard focus on the button. */
213
+ OnModeSwitchClick(): void;
214
+ /**
215
+ * Whether tearing the mounted form down would lose unsaved work. A saved
216
+ * record's field edits count; a brand-new record's don't, because its live
217
+ * instance is carried across the switch. Work the form holds outside the
218
+ * record (pending related records, designer/canvas state) always counts —
219
+ * it lives in the form component, which the switch destroys.
220
+ */
221
+ private hasUnsavedWorkToLose;
146
222
  private reload;
147
223
  private loadAndMount;
224
+ /** Whether a newer load (or destroy) has replaced the load that captured `generation`. */
225
+ private isSuperseded;
226
+ /** End the current load: clear the loading state, render, and restore the switch's focus. */
227
+ private settleLoad;
228
+ /** After a strip-initiated switch, hand focus to the re-rendered switch button (if the strip is back). */
229
+ private restoreModeSwitchFocus;
230
+ /**
231
+ * The standard form class to mount instead of the resolver's pick, or null
232
+ * to mount the pick. Only non-null in `'standard'` mode when a custom form is
233
+ * actually hiding the standard one; when the pick already IS the standard
234
+ * form there is nothing to swap. A `'standard'` request for an entity with
235
+ * no standard form falls back to the pick and logs, so a stale deep link
236
+ * can't break the record.
237
+ */
238
+ private standardFormToMount;
239
+ /** Entities this host has already logged a missing standard form for (lowercased names). */
240
+ private readonly _missingStandardLogged;
241
+ /**
242
+ * Log the "standard requested, none registered" fallback once per entity per
243
+ * host. A stale `?form=standard` would otherwise log on every reload (each
244
+ * variant pick, switch or input change).
245
+ */
246
+ private logMissingStandardFormOnce;
148
247
  /**
149
248
  * The config to bind for a given record. For brand-new (unsaved) records we hide the
150
249
  * `systemMetadata` section by default — its fields (audit timestamps, IDs, etc.) are
@@ -159,7 +258,10 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
159
258
  * field editors; the host saves the record directly (see {@link Save}).
160
259
  */
161
260
  private mountSection;
162
- /** Resolve the BaseEntity to bind: the supplied instance, or a freshly loaded/new one. */
261
+ /**
262
+ * Resolve the BaseEntity to bind: the supplied instance, or a freshly loaded/new one.
263
+ * Returns null on failure; reports it through {@link fail} only while `generation` is still current.
264
+ */
163
265
  private obtainRecord;
164
266
  /** Push variant list + active selection and wire the variant-switch handler. */
165
267
  private applyVariants;
@@ -181,6 +283,6 @@ export declare class MjEntityFormHostComponent extends BaseAngularComponent impl
181
283
  private cleanupFormSubs;
182
284
  private teardown;
183
285
  static ɵfac: i0.ɵɵFactoryDeclaration<MjEntityFormHostComponent, never>;
184
- static ɵcmp: i0.ɵɵComponentDeclaration<MjEntityFormHostComponent, "mj-entity-form-host", never, { "EntityName": { "alias": "EntityName"; "required": false; }; "PrimaryKey": { "alias": "PrimaryKey"; "required": false; }; "Record": { "alias": "Record"; "required": false; }; "NewRecordValues": { "alias": "NewRecordValues"; "required": false; }; "SectionName": { "alias": "SectionName"; "required": false; }; "EditMode": { "alias": "EditMode"; "required": false; }; "Config": { "alias": "Config"; "required": false; }; }, { "Navigate": "Navigate"; "Notification": "Notification"; "Saved": "Saved"; "RecordSaved": "RecordSaved"; "RecordRefreshed": "RecordRefreshed"; "RecordDeleted": "RecordDeleted"; "RecordSaveFailed": "RecordSaveFailed"; "ValidationFailed": "ValidationFailed"; "RecordReady": "RecordReady"; "Dismissed": "Dismissed"; "LoadComplete": "LoadComplete"; "LoadError": "LoadError"; "FormCreated": "FormCreated"; "EditModeChanged": "EditModeChanged"; }, never, never, false, never>;
286
+ static ɵcmp: i0.ɵɵComponentDeclaration<MjEntityFormHostComponent, "mj-entity-form-host", never, { "EntityName": { "alias": "EntityName"; "required": false; }; "PrimaryKey": { "alias": "PrimaryKey"; "required": false; }; "Record": { "alias": "Record"; "required": false; }; "NewRecordValues": { "alias": "NewRecordValues"; "required": false; }; "SectionName": { "alias": "SectionName"; "required": false; }; "EditMode": { "alias": "EditMode"; "required": false; }; "Config": { "alias": "Config"; "required": false; }; "FormMode": { "alias": "FormMode"; "required": false; }; "ShowFormModeSwitch": { "alias": "ShowFormModeSwitch"; "required": false; }; }, { "Navigate": "Navigate"; "Notification": "Notification"; "Saved": "Saved"; "RecordSaved": "RecordSaved"; "RecordRefreshed": "RecordRefreshed"; "RecordDeleted": "RecordDeleted"; "RecordSaveFailed": "RecordSaveFailed"; "ValidationFailed": "ValidationFailed"; "RecordReady": "RecordReady"; "Dismissed": "Dismissed"; "LoadComplete": "LoadComplete"; "LoadError": "LoadError"; "FormCreated": "FormCreated"; "FormModeChange": "FormModeChange"; "EditModeChanged": "EditModeChanged"; "AskAIRequested": "AskAIRequested"; }, never, never, false, never>;
185
287
  }
186
288
  //# sourceMappingURL=entity-form-host.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity-form-host.component.d.ts","sourceRoot":"","sources":["../../../src/lib/host/entity-form-host.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACqB,YAAY,EACG,aAAa,EAAE,SAAS,EAClE,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EAAE,UAAU,EACzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,qBAAqB,EAAE,gBAAgB,EAAE,kBAAkB,EAC3D,qBAAqB,EAAE,qBAAqB,EAC7C,MAAM,qBAAqB,CAAC;;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAMa,yBAA0B,SAAQ,oBAAqB,YAAW,aAAa,EAAE,SAAS;IACrG,OAAO,CAAC,GAAG,CAA6B;IACxC,OAAO,CAAC,YAAY,CAA+B;IAEnD,oFAAoF;IACrB,OAAO,CAAC,MAAM,CAAoB;IAIjG,OAAO,CAAC,WAAW,CAAuB;IAC1C,iFAAiF;IACjF,IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAIlC;IACD,IAAI,UAAU,IAAI,MAAM,GAAG,IAAI,CAA6B;IAE5D,OAAO,CAAC,WAAW,CAAoC;IACvD,iEAAiE;IACjE,IACI,UAAU,CAAC,KAAK,EAAE,YAAY,EAQjC;IACD,IAAI,UAAU,IAAI,YAAY,CAA6B;IAE3D,OAAO,CAAC,OAAO,CAA2B;IAC1C;;;;OAIG;IACH,IACI,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,EAIlC;IACD,IAAI,MAAM,IA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