@memberjunction/ng-react 6.1.4 → 6.2.0-edge.1
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/__tests__/react-bridge.service.test.js +11 -3
- package/dist/__tests__/react-bridge.service.test.js.map +1 -1
- package/dist/lib/components/mj-react-component.component.d.ts +128 -14
- package/dist/lib/components/mj-react-component.component.js +313 -207
- package/dist/lib/components/mj-react-component.component.js.map +1 -1
- package/dist/lib/config/react-debug.config.d.ts +4 -0
- package/dist/lib/config/react-debug.config.js +10 -2
- package/dist/lib/config/react-debug.config.js.map +1 -1
- package/dist/lib/hooks/antd-dropdown-position-hook.d.ts +2 -0
- package/dist/lib/hooks/antd-dropdown-position-hook.js +5 -1
- package/dist/lib/hooks/antd-dropdown-position-hook.js.map +1 -1
- package/dist/lib/services/angular-adapter.service.d.ts +32 -0
- package/dist/lib/services/angular-adapter.service.js +78 -18
- package/dist/lib/services/angular-adapter.service.js.map +1 -1
- package/dist/lib/services/react-bridge.service.d.ts +26 -2
- package/dist/lib/services/react-bridge.service.js +66 -18
- package/dist/lib/services/react-bridge.service.js.map +1 -1
- package/dist/lib/services/script-loader.service.d.ts +17 -0
- package/dist/lib/services/script-loader.service.js +26 -6
- package/dist/lib/services/script-loader.service.js.map +1 -1
- package/package.json +10 -10
- package/dist/__tests__/runtime-utilities-ml.test.d.ts +0 -1
- package/dist/__tests__/runtime-utilities-ml.test.js +0 -170
- package/dist/__tests__/runtime-utilities-ml.test.js.map +0 -1
- package/dist/lib/utilities/runtime-utilities.d.ts +0 -80
- package/dist/lib/utilities/runtime-utilities.js +0 -396
- package/dist/lib/utilities/runtime-utilities.js.map +0 -1
|
@@ -9,9 +9,8 @@ import { BaseAngularComponent } from '@memberjunction/ng-base-types';
|
|
|
9
9
|
import { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
10
10
|
import { ReactBridgeService } from '../services/react-bridge.service';
|
|
11
11
|
import { AngularAdapterService } from '../services/angular-adapter.service';
|
|
12
|
-
import { createErrorBoundary, ComponentHierarchyRegistrar, resourceManager, reactRootManager, BuildStylesFromTheme, ApplyStyleOverrides, wrapWithLibraryThemeProviders, ComponentRegistryService, resolveUserStateScope, userStateStorageKey, parseStoredUserSettings, mergeUserSettings, applyUserSettingsUpdate } from '@memberjunction/react-runtime';
|
|
13
|
-
import {
|
|
14
|
-
import { LogError, CompositeKey, RunView, DataSnapshot, DataTable, MJColumnDescriptor } from '@memberjunction/core';
|
|
12
|
+
import { createErrorBoundary, ComponentHierarchyRegistrar, resourceManager, reactRootManager, BuildStylesFromTheme, ApplyStyleOverrides, wrapWithLibraryThemeProviders, ComponentRegistryService, resolveUserStateScope, userStateStorageKey, parseStoredUserSettings, mergeUserSettings, applyUserSettingsUpdate, generateComponentHierarchyHash, createRuntimeUtilities, resolveEntityRecordKey } from '@memberjunction/react-runtime';
|
|
13
|
+
import { LogError, DataSnapshot, DataTable, MJColumnDescriptor } from '@memberjunction/core';
|
|
15
14
|
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
16
15
|
import { ComponentMetadataEngine, UserInfoEngine } from '@memberjunction/core-entities';
|
|
17
16
|
import * as i0 from "@angular/core";
|
|
@@ -38,11 +37,11 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
38
37
|
* When this changes after initialization, the component will be reinitialized
|
|
39
38
|
* to load and render the new specification.
|
|
40
39
|
*/
|
|
41
|
-
set
|
|
40
|
+
set Component(value) {
|
|
42
41
|
const previousComponent = this._component;
|
|
43
42
|
this._component = value;
|
|
44
43
|
// If already initialized and component spec changed, reinitialize
|
|
45
|
-
if (this.
|
|
44
|
+
if (this.IsInitialized && value && previousComponent !== value) {
|
|
46
45
|
// Check if it's actually a different component (not just same reference)
|
|
47
46
|
const isDifferent = !previousComponent ||
|
|
48
47
|
previousComponent.name !== value.name ||
|
|
@@ -55,16 +54,40 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
55
54
|
// Same code, new styleOverrides (a regenerated spec whose only change is the
|
|
56
55
|
// requested styling): re-render in place — no teardown needed. The resolved
|
|
57
56
|
// spec must be kept in step because the styleOverrides getter prefers it.
|
|
58
|
-
if (this.
|
|
59
|
-
this.
|
|
57
|
+
if (this.ResolvedComponentSpec) {
|
|
58
|
+
this.ResolvedComponentSpec.styleOverrides = value.styleOverrides;
|
|
60
59
|
}
|
|
61
60
|
this.renderComponent();
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
get
|
|
64
|
+
get Component() {
|
|
66
65
|
return this._component;
|
|
67
66
|
}
|
|
67
|
+
/** @deprecated Use {@link Component}. */
|
|
68
|
+
get component() {
|
|
69
|
+
return this.Component;
|
|
70
|
+
}
|
|
71
|
+
/** @deprecated Use {@link Component}. */
|
|
72
|
+
set component(value) {
|
|
73
|
+
this.Component = value;
|
|
74
|
+
}
|
|
75
|
+
/** @deprecated Use {@link EnableLogging}. */
|
|
76
|
+
set enableLogging(value) {
|
|
77
|
+
this.EnableLogging = value;
|
|
78
|
+
}
|
|
79
|
+
/** @deprecated Use {@link EnableLogging}. */
|
|
80
|
+
get enableLogging() {
|
|
81
|
+
return this.EnableLogging;
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use {@link UseComponentManager}. */
|
|
84
|
+
set useComponentManager(value) {
|
|
85
|
+
this.UseComponentManager = value;
|
|
86
|
+
}
|
|
87
|
+
/** @deprecated Use {@link UseComponentManager}. */
|
|
88
|
+
get useComponentManager() {
|
|
89
|
+
return this.UseComponentManager;
|
|
90
|
+
} // NEW: Use unified ComponentManager by default
|
|
68
91
|
set utilities(value) {
|
|
69
92
|
this._utilities = value;
|
|
70
93
|
}
|
|
@@ -72,17 +95,17 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
72
95
|
// Lazy initialization - only create default utilities when needed
|
|
73
96
|
if (!this._utilities) {
|
|
74
97
|
const runtimeUtils = createRuntimeUtilities();
|
|
75
|
-
this._utilities = runtimeUtils.buildUtilities(this.
|
|
76
|
-
if (this.
|
|
98
|
+
this._utilities = runtimeUtils.buildUtilities(this.EnableLogging, this.ProviderToUse);
|
|
99
|
+
if (this.EnableLogging) {
|
|
77
100
|
console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');
|
|
78
101
|
}
|
|
79
102
|
}
|
|
80
103
|
return this._utilities;
|
|
81
104
|
}
|
|
82
|
-
set
|
|
105
|
+
set Styles(value) {
|
|
83
106
|
this._styles = value;
|
|
84
107
|
}
|
|
85
|
-
get
|
|
108
|
+
get Styles() {
|
|
86
109
|
// An explicitly-provided styles input always wins — but user-requested overrides
|
|
87
110
|
// still layer on top, since they represent an explicit request rather than a theme.
|
|
88
111
|
if (this._styles) {
|
|
@@ -96,7 +119,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
96
119
|
if (!this._themeStyles || this._themeStylesKey !== key) {
|
|
97
120
|
this._themeStyles = BuildStylesFromTheme();
|
|
98
121
|
this._themeStylesKey = key;
|
|
99
|
-
if (this.
|
|
122
|
+
if (this.EnableLogging) {
|
|
100
123
|
console.log(`MJReactComponent: Bridged styles from live theme (key="${key}")`);
|
|
101
124
|
}
|
|
102
125
|
}
|
|
@@ -104,13 +127,21 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
104
127
|
// (the memo caches the theme, not the request).
|
|
105
128
|
return this.applyStyleOverridesMemoized(this._themeStyles);
|
|
106
129
|
}
|
|
130
|
+
/** @deprecated Use {@link Styles}. */
|
|
131
|
+
get styles() {
|
|
132
|
+
return this.Styles;
|
|
133
|
+
}
|
|
134
|
+
/** @deprecated Use {@link Styles}. */
|
|
135
|
+
set styles(value) {
|
|
136
|
+
this.Styles = value;
|
|
137
|
+
}
|
|
107
138
|
/**
|
|
108
139
|
* Explicitly user-requested styling from the spec being rendered, resolved above
|
|
109
140
|
* the theme. Reads the resolved spec when available (registry components resolve
|
|
110
141
|
* asynchronously) and falls back to the spec passed in.
|
|
111
142
|
*/
|
|
112
143
|
get styleOverrides() {
|
|
113
|
-
return this.
|
|
144
|
+
return this.ResolvedComponentSpec?.styleOverrides ?? this._component?.styleOverrides;
|
|
114
145
|
}
|
|
115
146
|
applyStyleOverridesMemoized(base) {
|
|
116
147
|
const overrides = this.styleOverrides;
|
|
@@ -151,7 +182,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
151
182
|
if (key !== this._themeStylesKey) {
|
|
152
183
|
this._themeStyles = undefined;
|
|
153
184
|
this._themeStylesKey = undefined;
|
|
154
|
-
if (this.
|
|
185
|
+
if (this.IsInitialized) {
|
|
155
186
|
this.renderComponent();
|
|
156
187
|
}
|
|
157
188
|
}
|
|
@@ -161,25 +192,73 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
161
192
|
attributeFilter: ['data-theme', 'data-theme-overlay'],
|
|
162
193
|
});
|
|
163
194
|
}
|
|
164
|
-
set
|
|
195
|
+
set SavedUserSettings(value) {
|
|
165
196
|
this._savedUserSettings = value || {};
|
|
166
197
|
// Re-render if component is initialized
|
|
167
|
-
if (this.
|
|
198
|
+
if (this.IsInitialized) {
|
|
168
199
|
this.renderComponent();
|
|
169
200
|
}
|
|
170
201
|
}
|
|
171
|
-
get
|
|
202
|
+
get SavedUserSettings() {
|
|
172
203
|
return this._savedUserSettings;
|
|
173
204
|
}
|
|
174
|
-
|
|
205
|
+
/** @deprecated Use {@link SavedUserSettings}. */
|
|
206
|
+
get savedUserSettings() {
|
|
207
|
+
return this.SavedUserSettings;
|
|
208
|
+
}
|
|
209
|
+
/** @deprecated Use {@link SavedUserSettings}. */
|
|
210
|
+
set savedUserSettings(value) {
|
|
211
|
+
this.SavedUserSettings = value;
|
|
212
|
+
}
|
|
213
|
+
set ComponentProps(value) {
|
|
175
214
|
this._componentProps = value ?? {};
|
|
176
|
-
if (this.
|
|
215
|
+
if (this.IsInitialized) {
|
|
177
216
|
this.renderComponent();
|
|
178
217
|
}
|
|
179
218
|
}
|
|
180
|
-
get
|
|
219
|
+
get ComponentProps() {
|
|
181
220
|
return this._componentProps;
|
|
182
221
|
}
|
|
222
|
+
/** @deprecated Use {@link ComponentProps}. */
|
|
223
|
+
get componentProps() {
|
|
224
|
+
return this.ComponentProps;
|
|
225
|
+
}
|
|
226
|
+
/** @deprecated Use {@link ComponentProps}. */
|
|
227
|
+
set componentProps(value) {
|
|
228
|
+
this.ComponentProps = value;
|
|
229
|
+
}
|
|
230
|
+
/** @deprecated Use {@link Container}. */
|
|
231
|
+
get container() {
|
|
232
|
+
return this.Container;
|
|
233
|
+
}
|
|
234
|
+
/** @deprecated Use {@link Container}. */
|
|
235
|
+
set container(value) {
|
|
236
|
+
this.Container = value;
|
|
237
|
+
}
|
|
238
|
+
/** @deprecated Use {@link IsInitialized}. */
|
|
239
|
+
get isInitialized() {
|
|
240
|
+
return this.IsInitialized;
|
|
241
|
+
}
|
|
242
|
+
/** @deprecated Use {@link IsInitialized}. */
|
|
243
|
+
set isInitialized(value) {
|
|
244
|
+
this.IsInitialized = value;
|
|
245
|
+
}
|
|
246
|
+
/** @deprecated Use {@link HasError}. */
|
|
247
|
+
get hasError() {
|
|
248
|
+
return this.HasError;
|
|
249
|
+
}
|
|
250
|
+
/** @deprecated Use {@link HasError}. */
|
|
251
|
+
set hasError(value) {
|
|
252
|
+
this.HasError = value;
|
|
253
|
+
}
|
|
254
|
+
/** @deprecated Use {@link ResolvedComponentSpec}. */
|
|
255
|
+
get resolvedComponentSpec() {
|
|
256
|
+
return this.ResolvedComponentSpec;
|
|
257
|
+
}
|
|
258
|
+
/** @deprecated Use {@link ResolvedComponentSpec}. */
|
|
259
|
+
set resolvedComponentSpec(value) {
|
|
260
|
+
this.ResolvedComponentSpec = value;
|
|
261
|
+
}
|
|
183
262
|
constructor(reactBridge, adapter, cdr, notificationService) {
|
|
184
263
|
super();
|
|
185
264
|
this.reactBridge = reactBridge;
|
|
@@ -191,8 +270,8 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
191
270
|
* Note: This does NOT control which React build (dev/prod) is loaded.
|
|
192
271
|
* To control React builds, use ReactDebugConfig.setDebugMode() at app startup.
|
|
193
272
|
*/
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
273
|
+
this.EnableLogging = false;
|
|
274
|
+
this.UseComponentManager = true;
|
|
196
275
|
this._savedUserSettings = {};
|
|
197
276
|
/**
|
|
198
277
|
* When `true` (default), the host transparently persists `savedUserSettings`
|
|
@@ -213,13 +292,61 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
213
292
|
* platform contract stable.
|
|
214
293
|
*/
|
|
215
294
|
this._componentProps = {};
|
|
216
|
-
this.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
295
|
+
this.StateChange = new EventEmitter();
|
|
296
|
+
/**
|
|
297
|
+
* @deprecated Use {@link StateChange}.
|
|
298
|
+
*
|
|
299
|
+
* The same emitter under the old binding name, so a template still binding
|
|
300
|
+
* (stateChange) keeps working. Must stay AFTER StateChange: class fields
|
|
301
|
+
* initialise in order, and the other way round this captures undefined.
|
|
302
|
+
*/
|
|
303
|
+
this.stateChange = this.StateChange;
|
|
304
|
+
this.ComponentEvent = new EventEmitter();
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated Use {@link ComponentEvent}.
|
|
307
|
+
*
|
|
308
|
+
* The same emitter under the old binding name, so a template still binding
|
|
309
|
+
* (componentEvent) keeps working. Must stay AFTER ComponentEvent: class fields
|
|
310
|
+
* initialise in order, and the other way round this captures undefined.
|
|
311
|
+
*/
|
|
312
|
+
this.componentEvent = this.ComponentEvent;
|
|
313
|
+
this.RefreshData = new EventEmitter();
|
|
314
|
+
/**
|
|
315
|
+
* @deprecated Use {@link RefreshData}.
|
|
316
|
+
*
|
|
317
|
+
* The same emitter under the old binding name, so a template still binding
|
|
318
|
+
* (refreshData) keeps working. Must stay AFTER RefreshData: class fields
|
|
319
|
+
* initialise in order, and the other way round this captures undefined.
|
|
320
|
+
*/
|
|
321
|
+
this.refreshData = this.RefreshData;
|
|
322
|
+
this.OpenEntityRecord = new EventEmitter();
|
|
323
|
+
/**
|
|
324
|
+
* @deprecated Use {@link OpenEntityRecord}.
|
|
325
|
+
*
|
|
326
|
+
* The same emitter under the old binding name, so a template still binding
|
|
327
|
+
* (openEntityRecord) keeps working. Must stay AFTER OpenEntityRecord: class fields
|
|
328
|
+
* initialise in order, and the other way round this captures undefined.
|
|
329
|
+
*/
|
|
330
|
+
this.openEntityRecord = this.OpenEntityRecord;
|
|
331
|
+
this.UserSettingsChanged = new EventEmitter();
|
|
332
|
+
/**
|
|
333
|
+
* @deprecated Use {@link UserSettingsChanged}.
|
|
334
|
+
*
|
|
335
|
+
* The same emitter under the old binding name, so a template still binding
|
|
336
|
+
* (userSettingsChanged) keeps working. Must stay AFTER UserSettingsChanged: class fields
|
|
337
|
+
* initialise in order, and the other way round this captures undefined.
|
|
338
|
+
*/
|
|
339
|
+
this.userSettingsChanged = this.UserSettingsChanged;
|
|
221
340
|
/** Emitted once after the component successfully loads and resolvedComponentSpec is populated. */
|
|
222
|
-
this.
|
|
341
|
+
this.Initialized = new EventEmitter();
|
|
342
|
+
/**
|
|
343
|
+
* @deprecated Use {@link Initialized}.
|
|
344
|
+
*
|
|
345
|
+
* The same emitter under the old binding name, so a template still binding
|
|
346
|
+
* (initialized) keeps working. Must stay AFTER Initialized: class fields
|
|
347
|
+
* initialise in order, and the other way round this captures undefined.
|
|
348
|
+
*/
|
|
349
|
+
this.initialized = this.Initialized;
|
|
223
350
|
// ─── Automatic data capture ───
|
|
224
351
|
// Stores RunView/RunQuery results for components that don't implement getCurrentDataState().
|
|
225
352
|
// Cleared on component reinitialize. Used as fallback in GetCurrentDataState().
|
|
@@ -229,19 +356,19 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
229
356
|
this.loadedDependencies = {};
|
|
230
357
|
this.destroyed$ = new Subject();
|
|
231
358
|
this.currentCallbacks = null;
|
|
232
|
-
this.
|
|
359
|
+
this.IsInitialized = false;
|
|
233
360
|
this.isRendering = false;
|
|
234
361
|
this.pendingRender = false;
|
|
235
362
|
this.isDestroying = false;
|
|
236
363
|
this.componentVersion = ''; // Store the version for resolver
|
|
237
|
-
this.
|
|
364
|
+
this.HasError = false;
|
|
238
365
|
/**
|
|
239
366
|
* Public property containing the fully resolved component specification.
|
|
240
367
|
* This includes all external code fetched from registries, allowing consumers
|
|
241
368
|
* to inspect the complete resolved specification including dependencies.
|
|
242
369
|
* Only populated after successful component initialization.
|
|
243
370
|
*/
|
|
244
|
-
this.
|
|
371
|
+
this.ResolvedComponentSpec = null;
|
|
245
372
|
// Generate unique component ID for resource tracking
|
|
246
373
|
this.componentId = `mj-react-component-${Date.now()}-${Math.random()}`;
|
|
247
374
|
}
|
|
@@ -261,7 +388,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
261
388
|
}
|
|
262
389
|
console.log(`🎬 [ngAfterViewInit] Starting component initialization:`, {
|
|
263
390
|
componentId: this.componentId,
|
|
264
|
-
componentName: this.
|
|
391
|
+
componentName: this.Component?.name,
|
|
265
392
|
timestamp: new Date().toISOString(),
|
|
266
393
|
registrySize: registrySize
|
|
267
394
|
});
|
|
@@ -293,11 +420,11 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
293
420
|
}
|
|
294
421
|
// Clear cached state from previous component
|
|
295
422
|
this.compiledComponent = null;
|
|
296
|
-
this.
|
|
423
|
+
this.ResolvedComponentSpec = null;
|
|
297
424
|
this.loadedDependencies = {};
|
|
298
425
|
this.componentVersion = '';
|
|
299
|
-
this.
|
|
300
|
-
this.
|
|
426
|
+
this.HasError = false;
|
|
427
|
+
this.IsInitialized = false;
|
|
301
428
|
this.capturedData = [];
|
|
302
429
|
// Unmount existing React root if present
|
|
303
430
|
if (this.reactRootId) {
|
|
@@ -321,7 +448,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
321
448
|
// Wait for React to be fully ready (handles first-load delay)
|
|
322
449
|
await this.reactBridge.waitForReactReady();
|
|
323
450
|
// NEW: Use ComponentManager if enabled (default: true)
|
|
324
|
-
if (this.
|
|
451
|
+
if (this.UseComponentManager) {
|
|
325
452
|
console.log(`🎯 [initializeComponent] Using NEW ComponentManager approach`);
|
|
326
453
|
await this.loadComponentWithManager();
|
|
327
454
|
// Component is already compiled and stored in this.compiledComponent
|
|
@@ -336,39 +463,39 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
336
463
|
// Get the already-registered component from the registry
|
|
337
464
|
const registry = this.adapter.getRegistry();
|
|
338
465
|
console.log(`🔍 [initializeComponent] Looking for component in registry:`, {
|
|
339
|
-
name: this.
|
|
340
|
-
namespace: this.
|
|
466
|
+
name: this.Component.name,
|
|
467
|
+
namespace: this.Component.namespace || 'Global',
|
|
341
468
|
version: this.componentVersion
|
|
342
469
|
});
|
|
343
470
|
// Let's also check what's actually in the registry
|
|
344
471
|
// Note: ComponentRegistry doesn't have a list() method, so we'll skip this for now
|
|
345
|
-
const componentWrapper = registry.get(this.
|
|
472
|
+
const componentWrapper = registry.get(this.Component.name, this.Component.namespace || 'Global', this.componentVersion);
|
|
346
473
|
console.log(`🔍 [initializeComponent] Registry.get result:`, {
|
|
347
474
|
found: !!componentWrapper,
|
|
348
475
|
type: componentWrapper ? typeof componentWrapper : 'undefined',
|
|
349
476
|
hasComponent: componentWrapper ? !!componentWrapper.component : false
|
|
350
477
|
});
|
|
351
478
|
if (!componentWrapper) {
|
|
352
|
-
const source = this.
|
|
479
|
+
const source = this.Component.registry ? `external registry ${this.Component.registry}` : 'local registry';
|
|
353
480
|
console.error(`❌ [initializeComponent] Component not found! Details:`, {
|
|
354
|
-
searchedName: this.
|
|
355
|
-
searchedNamespace: this.
|
|
481
|
+
searchedName: this.Component.name,
|
|
482
|
+
searchedNamespace: this.Component.namespace || 'Global',
|
|
356
483
|
searchedVersion: this.componentVersion,
|
|
357
484
|
source: source
|
|
358
485
|
});
|
|
359
|
-
throw new Error(`Component ${this.
|
|
486
|
+
throw new Error(`Component ${this.Component.name} was not found in registry after registration from ${source}`);
|
|
360
487
|
}
|
|
361
488
|
// The registry now stores ComponentObjects directly
|
|
362
489
|
// Validate it has the expected structure
|
|
363
490
|
if (!componentWrapper || typeof componentWrapper !== 'object') {
|
|
364
|
-
throw new Error(`Invalid component wrapper returned for ${this.
|
|
491
|
+
throw new Error(`Invalid component wrapper returned for ${this.Component.name}: ${typeof componentWrapper}`);
|
|
365
492
|
}
|
|
366
493
|
if (!componentWrapper.component) {
|
|
367
|
-
throw new Error(`Component wrapper missing 'component' property for ${this.
|
|
494
|
+
throw new Error(`Component wrapper missing 'component' property for ${this.Component.name}`);
|
|
368
495
|
}
|
|
369
496
|
// Now that we use a regular HOC wrapper, components should always be functions
|
|
370
497
|
if (typeof componentWrapper.component !== 'function') {
|
|
371
|
-
throw new Error(`Component is not a function for ${this.
|
|
498
|
+
throw new Error(`Component is not a function for ${this.Component.name}: ${typeof componentWrapper.component}`);
|
|
372
499
|
}
|
|
373
500
|
this.compiledComponent = componentWrapper;
|
|
374
501
|
} // End of else block for legacy approach
|
|
@@ -377,23 +504,23 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
377
504
|
if (!reactContext) {
|
|
378
505
|
throw new Error('React context not available');
|
|
379
506
|
}
|
|
380
|
-
this.reactRootId = reactRootManager.createRoot(this.
|
|
507
|
+
this.reactRootId = reactRootManager.createRoot(this.Container.nativeElement, (container) => reactContext.ReactDOM.createRoot(container), this.componentId);
|
|
381
508
|
// Seed savedUserSettings from durable per-user storage before the first
|
|
382
509
|
// render so the component mounts with the user's persisted preferences.
|
|
383
510
|
await this.seedUserSettingsFromStore();
|
|
384
511
|
// Initial render
|
|
385
512
|
this.renderComponent();
|
|
386
|
-
this.
|
|
513
|
+
this.IsInitialized = true;
|
|
387
514
|
// Trigger change detection since we're using OnPush
|
|
388
515
|
this.cdr.detectChanges();
|
|
389
516
|
// Notify parent that the component has successfully initialized and
|
|
390
517
|
// resolvedComponentSpec is now populated with the full spec from the registry
|
|
391
|
-
this.
|
|
518
|
+
this.Initialized.emit();
|
|
392
519
|
}
|
|
393
520
|
catch (error) {
|
|
394
|
-
this.
|
|
521
|
+
this.HasError = true;
|
|
395
522
|
LogError(`Failed to initialize React component: ${error}`);
|
|
396
|
-
this.
|
|
523
|
+
this.ComponentEvent.emit({
|
|
397
524
|
type: 'error',
|
|
398
525
|
payload: {
|
|
399
526
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -405,34 +532,15 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
405
532
|
}
|
|
406
533
|
}
|
|
407
534
|
/**
|
|
408
|
-
* Generate a hash from component code for versioning
|
|
409
|
-
*
|
|
535
|
+
* Generate a hash from component code for versioning.
|
|
536
|
+
*
|
|
537
|
+
* Delegates to the runtime so every host derives the same version for the same spec. When this
|
|
538
|
+
* lived here, the React Native app had to reimplement it to load the same component, and two
|
|
539
|
+
* implementations of a registry key is how one surface silently compiles a second copy of a
|
|
540
|
+
* component the other already has.
|
|
410
541
|
*/
|
|
411
542
|
generateComponentHash(spec) {
|
|
412
|
-
|
|
413
|
-
const codeStrings = [];
|
|
414
|
-
const collectCode = (s) => {
|
|
415
|
-
if (s.code) {
|
|
416
|
-
codeStrings.push(s.code);
|
|
417
|
-
}
|
|
418
|
-
if (s.dependencies) {
|
|
419
|
-
for (const dep of s.dependencies) {
|
|
420
|
-
collectCode(dep);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
collectCode(spec);
|
|
425
|
-
// Generate hash from concatenated code
|
|
426
|
-
const fullCode = codeStrings.join('|');
|
|
427
|
-
let hash = 0;
|
|
428
|
-
for (let i = 0; i < fullCode.length; i++) {
|
|
429
|
-
const char = fullCode.charCodeAt(i);
|
|
430
|
-
hash = ((hash << 5) - hash) + char;
|
|
431
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
432
|
-
}
|
|
433
|
-
// Convert to hex string and take first 8 characters for readability
|
|
434
|
-
const hexHash = Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);
|
|
435
|
-
return `v${hexHash}`;
|
|
543
|
+
return generateComponentHierarchyHash(spec);
|
|
436
544
|
}
|
|
437
545
|
/**
|
|
438
546
|
* Resolve components using the runtime's resolver
|
|
@@ -440,13 +548,13 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
440
548
|
async resolveComponentsWithVersion(spec, version, namespace = 'Global') {
|
|
441
549
|
const resolver = this.adapter.getResolver();
|
|
442
550
|
// Debug: Log what dependencies we're trying to resolve
|
|
443
|
-
if (this.
|
|
551
|
+
if (this.EnableLogging) {
|
|
444
552
|
console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);
|
|
445
553
|
}
|
|
446
554
|
// Use the runtime's resolver which now handles registry-based components
|
|
447
555
|
const resolved = await resolver.resolveComponents(spec, namespace, this.ProviderToUse.CurrentUser // Pass current user context for database operations
|
|
448
556
|
);
|
|
449
|
-
if (this.
|
|
557
|
+
if (this.EnableLogging) {
|
|
450
558
|
console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));
|
|
451
559
|
}
|
|
452
560
|
return resolved;
|
|
@@ -457,12 +565,12 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
457
565
|
async loadComponentWithManager() {
|
|
458
566
|
try {
|
|
459
567
|
const manager = this.adapter.getComponentManager();
|
|
460
|
-
console.log(`🚀 [ComponentManager] Loading component hierarchy: ${this.
|
|
568
|
+
console.log(`🚀 [ComponentManager] Loading component hierarchy: ${this.Component.name}`);
|
|
461
569
|
// Load the entire hierarchy with one simple call
|
|
462
|
-
const result = await manager.loadHierarchy(this.
|
|
570
|
+
const result = await manager.loadHierarchy(this.Component, {
|
|
463
571
|
contextUser: this.ProviderToUse.CurrentUser,
|
|
464
572
|
defaultNamespace: 'Global',
|
|
465
|
-
defaultVersion: this.
|
|
573
|
+
defaultVersion: this.Component.version || this.generateComponentHash(this.Component),
|
|
466
574
|
returnType: 'both'
|
|
467
575
|
});
|
|
468
576
|
if (!result.success) {
|
|
@@ -471,9 +579,9 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
471
579
|
throw new Error(`Component loading failed: ${errorMessages}`);
|
|
472
580
|
}
|
|
473
581
|
// Store the results (handle undefined values)
|
|
474
|
-
this.
|
|
582
|
+
this.ResolvedComponentSpec = this.enrichSpecWithRegistryInfo(result.resolvedSpec || null);
|
|
475
583
|
this.compiledComponent = result.rootComponent || null;
|
|
476
|
-
this.componentVersion = result.resolvedSpec?.version || this.
|
|
584
|
+
this.componentVersion = result.resolvedSpec?.version || this.Component.version || 'latest';
|
|
477
585
|
// IMPORTANT: Store the loaded dependencies for use in renderComponent
|
|
478
586
|
this.loadedDependencies = result.components || {};
|
|
479
587
|
console.log(`✅ [ComponentManager] Successfully loaded hierarchy:`, {
|
|
@@ -496,20 +604,20 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
496
604
|
*/
|
|
497
605
|
async registerComponentHierarchy() {
|
|
498
606
|
// Use semantic version from spec or generate hash-based version for uniqueness
|
|
499
|
-
const version = this.
|
|
607
|
+
const version = this.Component.version || this.generateComponentHash(this.Component);
|
|
500
608
|
this.componentVersion = version; // Store for use in resolver
|
|
501
|
-
console.log(`🔍 [registerComponentHierarchy] Starting registration for ${this.
|
|
502
|
-
location: this.
|
|
503
|
-
registry: this.
|
|
504
|
-
namespace: this.
|
|
505
|
-
hasCode: !!this.
|
|
506
|
-
codeLength: this.
|
|
609
|
+
console.log(`🔍 [registerComponentHierarchy] Starting registration for ${this.Component.name}@${version}`, {
|
|
610
|
+
location: this.Component.location,
|
|
611
|
+
registry: this.Component.registry,
|
|
612
|
+
namespace: this.Component.namespace,
|
|
613
|
+
hasCode: !!this.Component.code,
|
|
614
|
+
codeLength: this.Component.code?.length || 0
|
|
507
615
|
});
|
|
508
616
|
// Check if already registered to avoid duplication
|
|
509
617
|
const registry = this.adapter.getRegistry();
|
|
510
|
-
const checkNamespace = this.
|
|
618
|
+
const checkNamespace = this.Component.namespace || 'Global';
|
|
511
619
|
console.log(`🔍 [registerComponentHierarchy] Checking registry for existing component:`, {
|
|
512
|
-
name: this.
|
|
620
|
+
name: this.Component.name,
|
|
513
621
|
namespace: checkNamespace,
|
|
514
622
|
version: version,
|
|
515
623
|
registrySize: registry.size(),
|
|
@@ -520,9 +628,9 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
520
628
|
totalSize: registry.size(),
|
|
521
629
|
registryInstance: registry.registryId || 'unknown'
|
|
522
630
|
});
|
|
523
|
-
const existingComponent = registry.get(this.
|
|
631
|
+
const existingComponent = registry.get(this.Component.name, checkNamespace, version);
|
|
524
632
|
if (existingComponent) {
|
|
525
|
-
console.log(`⚠️ [registerComponentHierarchy] Component ${this.
|
|
633
|
+
console.log(`⚠️ [registerComponentHierarchy] Component ${this.Component.name}@${version} already registered!`, {
|
|
526
634
|
existingType: typeof existingComponent,
|
|
527
635
|
hasComponent: !!existingComponent.component,
|
|
528
636
|
registrationTime: existingComponent.registeredAt || 'unknown',
|
|
@@ -530,13 +638,13 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
530
638
|
});
|
|
531
639
|
// For registry components, we need to check the resolved spec's libraries, not the input spec
|
|
532
640
|
// The input spec from Angular doesn't have library information for registry components
|
|
533
|
-
if (this.
|
|
641
|
+
if (this.Component.location === 'registry' && this.Component.registry) {
|
|
534
642
|
console.log(`📋 [registerComponentHierarchy] Component is from registry, need to fetch full spec to check libraries`);
|
|
535
643
|
// Continue to fetch the full spec below - don't return early
|
|
536
644
|
}
|
|
537
645
|
else {
|
|
538
646
|
// For local components, check using the input spec
|
|
539
|
-
const requiredLibraries = this.
|
|
647
|
+
const requiredLibraries = this.Component.libraries || [];
|
|
540
648
|
const runtimeLibraries = this.adapter.getRuntimeContext().libraries || {};
|
|
541
649
|
const missingLibraries = requiredLibraries.filter(lib => !runtimeLibraries[lib.globalVariable]);
|
|
542
650
|
if (missingLibraries.length > 0) {
|
|
@@ -548,7 +656,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
548
656
|
// Don't return early - continue to load libraries
|
|
549
657
|
}
|
|
550
658
|
else {
|
|
551
|
-
console.log(`✅ [registerComponentHierarchy] Component ${this.
|
|
659
|
+
console.log(`✅ [registerComponentHierarchy] Component ${this.Component.name}@${version} already registered with all libraries, skipping`);
|
|
552
660
|
return;
|
|
553
661
|
}
|
|
554
662
|
}
|
|
@@ -560,20 +668,20 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
560
668
|
await ComponentMetadataEngine.Instance.Config(false, this.ProviderToUse.CurrentUser);
|
|
561
669
|
// Use the runtime's hierarchy registrar
|
|
562
670
|
const registrar = new ComponentHierarchyRegistrar(this.adapter.getCompiler(), this.adapter.getRegistry(), this.adapter.getRuntimeContext());
|
|
563
|
-
console.log(`📦 [registerComponentHierarchy] Calling registrar.registerHierarchy for ${this.
|
|
564
|
-
hasStyles: !!this.
|
|
565
|
-
namespace: this.
|
|
671
|
+
console.log(`📦 [registerComponentHierarchy] Calling registrar.registerHierarchy for ${this.Component.name}`, {
|
|
672
|
+
hasStyles: !!this.Styles,
|
|
673
|
+
namespace: this.Component.namespace || 'Global',
|
|
566
674
|
version: version,
|
|
567
675
|
libraryCount: ComponentMetadataEngine.Instance.ComponentLibraries?.length || 0,
|
|
568
|
-
hasCode: !!this.
|
|
569
|
-
codeLength: this.
|
|
676
|
+
hasCode: !!this.Component.code,
|
|
677
|
+
codeLength: this.Component.code?.length || 0
|
|
570
678
|
});
|
|
571
679
|
// Register with proper configuration
|
|
572
680
|
// Pass the partial spec - the React runtime will handle fetching from registries
|
|
573
|
-
const result = await registrar.registerHierarchy(this.
|
|
681
|
+
const result = await registrar.registerHierarchy(this.Component, // Pass the original spec, not fetched
|
|
574
682
|
{
|
|
575
|
-
styles: this.
|
|
576
|
-
namespace: this.
|
|
683
|
+
styles: this.Styles,
|
|
684
|
+
namespace: this.Component.namespace || 'Global',
|
|
577
685
|
version: version,
|
|
578
686
|
allowOverride: false, // Each version is unique
|
|
579
687
|
allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries,
|
|
@@ -587,7 +695,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
587
695
|
}
|
|
588
696
|
// Store the resolved spec from the registration result
|
|
589
697
|
if (result.resolvedSpec) {
|
|
590
|
-
this.
|
|
698
|
+
this.ResolvedComponentSpec = this.enrichSpecWithRegistryInfo(result.resolvedSpec || null);
|
|
591
699
|
console.log(`📋 [registerComponentHierarchy] Received resolved spec from runtime:`, {
|
|
592
700
|
name: result.resolvedSpec.name,
|
|
593
701
|
hasCode: !!result.resolvedSpec.code,
|
|
@@ -597,11 +705,11 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
597
705
|
}
|
|
598
706
|
console.log(`✅ [registerComponentHierarchy] Successfully registered ${result.registeredComponents.length} components:`, result.registeredComponents);
|
|
599
707
|
// Verify the component is actually in the registry
|
|
600
|
-
const verifyComponent = registry.get(this.
|
|
708
|
+
const verifyComponent = registry.get(this.Component.name, this.Component.namespace || 'Global', version);
|
|
601
709
|
console.log(`🔍 [registerComponentHierarchy] Verification - component in registry after registration:`, {
|
|
602
710
|
found: !!verifyComponent,
|
|
603
|
-
name: this.
|
|
604
|
-
namespace: this.
|
|
711
|
+
name: this.Component.name,
|
|
712
|
+
namespace: this.Component.namespace || 'Global',
|
|
605
713
|
version: version,
|
|
606
714
|
componentType: verifyComponent ? typeof verifyComponent : 'not found'
|
|
607
715
|
});
|
|
@@ -612,7 +720,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
612
720
|
* Applied to all resolved specs so any consumer of this wrapper benefits.
|
|
613
721
|
*/
|
|
614
722
|
enrichSpecWithRegistryInfo(spec) {
|
|
615
|
-
if (!spec || !this.
|
|
723
|
+
if (!spec || !this.Component)
|
|
616
724
|
return spec;
|
|
617
725
|
// Create a deep copy to avoid mutating the original
|
|
618
726
|
const enrichedSpec = JSON.parse(JSON.stringify(spec));
|
|
@@ -664,7 +772,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
664
772
|
});
|
|
665
773
|
}
|
|
666
774
|
};
|
|
667
|
-
processSpec(enrichedSpec, this.
|
|
775
|
+
processSpec(enrichedSpec, this.Component);
|
|
668
776
|
return enrichedSpec;
|
|
669
777
|
}
|
|
670
778
|
/**
|
|
@@ -692,8 +800,8 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
692
800
|
// Resolve components with the correct version using runtime's resolver
|
|
693
801
|
// SKIP this if using ComponentManager - components are already loaded!
|
|
694
802
|
let components = {};
|
|
695
|
-
if (!this.
|
|
696
|
-
components = await this.resolveComponentsWithVersion(this.
|
|
803
|
+
if (!this.UseComponentManager) {
|
|
804
|
+
components = await this.resolveComponentsWithVersion(this.Component, this.componentVersion);
|
|
697
805
|
}
|
|
698
806
|
else {
|
|
699
807
|
// Use the dependencies that were already loaded and unwrapped by ComponentManager
|
|
@@ -718,19 +826,19 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
718
826
|
utilities: wrappedUtilities,
|
|
719
827
|
callbacks: this.currentCallbacks,
|
|
720
828
|
components,
|
|
721
|
-
styles: this.
|
|
829
|
+
styles: this.Styles,
|
|
722
830
|
libraries, // Pass the loaded libraries to components
|
|
723
831
|
savedUserSettings: this._savedUserSettings,
|
|
724
832
|
onSaveUserSettings: this.handleSaveUserSettings.bind(this)
|
|
725
833
|
};
|
|
726
834
|
// Validate component before creating element
|
|
727
835
|
if (!this.compiledComponent.component) {
|
|
728
|
-
LogError(`Component is undefined for ${this.
|
|
836
|
+
LogError(`Component is undefined for ${this.Component.name} during render`);
|
|
729
837
|
return;
|
|
730
838
|
}
|
|
731
839
|
// Components should be functions after HOC wrapping
|
|
732
840
|
if (typeof this.compiledComponent.component !== 'function') {
|
|
733
|
-
LogError(`Component is not a function for ${this.
|
|
841
|
+
LogError(`Component is not a function for ${this.Component.name}: ${typeof this.compiledComponent.component}`);
|
|
734
842
|
return;
|
|
735
843
|
}
|
|
736
844
|
// Create error boundary
|
|
@@ -744,13 +852,13 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
744
852
|
// components don't read styles.* on their own and would otherwise render in their
|
|
745
853
|
// built-in light theme even in dark mode. One wrap themes every antd component in
|
|
746
854
|
// the subtree; no-op when antd isn't loaded.
|
|
747
|
-
const themedComponent = wrapWithLibraryThemeProviders(React, React.createElement(this.compiledComponent.component, props), libraries, this.
|
|
855
|
+
const themedComponent = wrapWithLibraryThemeProviders(React, React.createElement(this.compiledComponent.component, props), libraries, this.Styles);
|
|
748
856
|
const element = React.createElement(ErrorBoundary, null, themedComponent);
|
|
749
857
|
// Render with timeout protection using resource manager
|
|
750
858
|
const timeoutId = resourceManager.setTimeout(this.componentId, () => {
|
|
751
859
|
// Check if still rendering and not destroyed
|
|
752
860
|
if (this.isRendering && !this.isDestroying) {
|
|
753
|
-
this.
|
|
861
|
+
this.ComponentEvent.emit({
|
|
754
862
|
type: 'error',
|
|
755
863
|
payload: {
|
|
756
864
|
error: 'Component render timeout - possible infinite loop detected',
|
|
@@ -791,74 +899,16 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
791
899
|
this.notificationService.CreateSimpleNotification(message, style, hideAfter);
|
|
792
900
|
},
|
|
793
901
|
OpenEntityRecord: async (entityName, key) => {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
else if (typeof key === 'object' && !!key.GetValueByFieldName) {
|
|
799
|
-
keyToUse = key;
|
|
800
|
-
}
|
|
801
|
-
else if (typeof key === 'object') {
|
|
802
|
-
//} && !!key.FieldName && !!key.Value) {
|
|
803
|
-
// possible that have an object that is a simple key/value pair with
|
|
804
|
-
// FieldName and value properties
|
|
805
|
-
const keyAny = key;
|
|
806
|
-
if (keyAny.FieldName && keyAny.Value) {
|
|
807
|
-
keyToUse = CompositeKey.FromKeyValuePairs([keyAny]);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
902
|
+
// Shape coercion and the non-primary-key lookup both live in the runtime now, so the
|
|
903
|
+
// React Native host resolves a component's key exactly the way this one does. What stays
|
|
904
|
+
// here is the only part that is Angular's: what "open" means.
|
|
905
|
+
const keyToUse = await resolveEntityRecordKey(entityName, key, this.ProviderToUse);
|
|
810
906
|
if (keyToUse) {
|
|
811
|
-
|
|
812
|
-
// use, but are not the pkey, so if that is the case, we'll run a quick view to try
|
|
813
|
-
// and get the pkey so that we can emit the openEntityRecord call with the pkey
|
|
814
|
-
const md = this.ProviderToUse;
|
|
815
|
-
const e = md.EntityByName(entityName);
|
|
816
|
-
if (!e) {
|
|
817
|
-
console.warn(`Entity not found: ${entityName}`);
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
let shouldRunView = false;
|
|
821
|
-
// now check each key in the keyToUse to see if it is a pkey
|
|
822
|
-
for (const singleKey of keyToUse.KeyValuePairs) {
|
|
823
|
-
const field = e.Fields.find(f => f.Name.trim().toLowerCase() === singleKey.FieldName.trim().toLowerCase());
|
|
824
|
-
if (!field) {
|
|
825
|
-
// if we get here this is a problem, the component has given us a non-matching field, this shouldn't ever happen
|
|
826
|
-
// but if it doesn't log warning to console and exit
|
|
827
|
-
console.warn(`Non-matching field found for key: ${JSON.stringify(keyToUse)}`);
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
else if (!field.IsPrimaryKey) {
|
|
831
|
-
// if we get here that means we have a non-pkey so we'll want to do a lookup via a RunView
|
|
832
|
-
// to get the actual pkey value
|
|
833
|
-
shouldRunView = true;
|
|
834
|
-
break;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
// if we get here and shouldRunView is true, we need to run a view using the info provided
|
|
838
|
-
// by our contained component to get the pkey
|
|
839
|
-
if (shouldRunView) {
|
|
840
|
-
const rv = RunView.FromMetadataProvider(this.ProviderToUse);
|
|
841
|
-
const result = await rv.RunView({
|
|
842
|
-
EntityName: entityName,
|
|
843
|
-
ExtraFilter: keyToUse.ToWhereClause()
|
|
844
|
-
});
|
|
845
|
-
if (result && result.Success && result.Results.length > 0) {
|
|
846
|
-
// we have a match, use the first row and update our keyToUse
|
|
847
|
-
const kvPairs = [];
|
|
848
|
-
e.PrimaryKeys.forEach(pk => {
|
|
849
|
-
kvPairs.push({
|
|
850
|
-
FieldName: pk.Name,
|
|
851
|
-
Value: result.Results[0][pk.Name]
|
|
852
|
-
});
|
|
853
|
-
});
|
|
854
|
-
keyToUse = CompositeKey.FromKeyValuePairs(kvPairs);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
this.openEntityRecord.emit({ entityName, key: keyToUse });
|
|
907
|
+
this.OpenEntityRecord.emit({ entityName, key: keyToUse });
|
|
858
908
|
}
|
|
859
909
|
},
|
|
860
910
|
NotifyEvent: async (eventName, args) => {
|
|
861
|
-
this.
|
|
911
|
+
this.ComponentEvent.emit({ type: eventName, payload: args });
|
|
862
912
|
}
|
|
863
913
|
};
|
|
864
914
|
}
|
|
@@ -867,7 +917,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
867
917
|
*/
|
|
868
918
|
handleReactError(error, errorInfo) {
|
|
869
919
|
LogError(`React component error: ${error?.toString() || 'Unknown error'}`, errorInfo);
|
|
870
|
-
this.
|
|
920
|
+
this.ComponentEvent.emit({
|
|
871
921
|
type: 'error',
|
|
872
922
|
payload: {
|
|
873
923
|
error: error?.toString() || 'Unknown error',
|
|
@@ -901,9 +951,9 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
901
951
|
// Durably persist the latest settings for this user, scoped to this component.
|
|
902
952
|
this.persistUserSettings(this._savedUserSettings);
|
|
903
953
|
// Bubble the event up to parent containers (back-compat; no consumer required).
|
|
904
|
-
this.
|
|
954
|
+
this.UserSettingsChanged.emit({
|
|
905
955
|
settings: this._savedUserSettings,
|
|
906
|
-
componentName: this.
|
|
956
|
+
componentName: this.Component?.name,
|
|
907
957
|
timestamp: new Date()
|
|
908
958
|
});
|
|
909
959
|
}
|
|
@@ -940,7 +990,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
940
990
|
this._savedUserSettings = mergeUserSettings(this._savedUserSettings, stored);
|
|
941
991
|
}
|
|
942
992
|
catch (error) {
|
|
943
|
-
if (this.
|
|
993
|
+
if (this.EnableLogging) {
|
|
944
994
|
console.warn('MJReactComponent: failed to seed user settings from store', error);
|
|
945
995
|
}
|
|
946
996
|
}
|
|
@@ -968,7 +1018,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
968
1018
|
UserInfoEngine.Instance.SetSettingDebounced(key, serialized, user);
|
|
969
1019
|
}
|
|
970
1020
|
catch (error) {
|
|
971
|
-
if (this.
|
|
1021
|
+
if (this.EnableLogging) {
|
|
972
1022
|
console.warn('MJReactComponent: failed to persist user settings', error);
|
|
973
1023
|
}
|
|
974
1024
|
}
|
|
@@ -1042,7 +1092,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1042
1092
|
* Builds a DataSnapshot from captured RunView/RunQuery results.
|
|
1043
1093
|
* Returns null if no data was captured.
|
|
1044
1094
|
*/
|
|
1045
|
-
|
|
1095
|
+
buildCapturedDataSnapshot() {
|
|
1046
1096
|
if (this.capturedData.length === 0)
|
|
1047
1097
|
return null;
|
|
1048
1098
|
const tables = this.capturedData.map((captured, idx) => {
|
|
@@ -1074,7 +1124,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1074
1124
|
};
|
|
1075
1125
|
return table;
|
|
1076
1126
|
});
|
|
1077
|
-
return DataSnapshot.FromTables(tables, this.
|
|
1127
|
+
return DataSnapshot.FromTables(tables, this.Component?.title ?? this.Component?.name);
|
|
1078
1128
|
}
|
|
1079
1129
|
/**
|
|
1080
1130
|
* Clean up resources
|
|
@@ -1097,7 +1147,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1097
1147
|
}
|
|
1098
1148
|
// Clear references
|
|
1099
1149
|
this.compiledComponent = null;
|
|
1100
|
-
this.
|
|
1150
|
+
this.IsInitialized = false;
|
|
1101
1151
|
this.capturedData = [];
|
|
1102
1152
|
// Trigger registry cleanup (guard: adapter may not be initialized if
|
|
1103
1153
|
// React bootstrap failed or was destroyed during retry)
|
|
@@ -1127,7 +1177,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1127
1177
|
*/
|
|
1128
1178
|
updateState(path, value) {
|
|
1129
1179
|
// Just emit the event, don't manage state here
|
|
1130
|
-
this.
|
|
1180
|
+
this.StateChange.emit({ path, value });
|
|
1131
1181
|
}
|
|
1132
1182
|
// =================================================================
|
|
1133
1183
|
// Standard Component Methods - Strongly Typed
|
|
@@ -1141,7 +1191,7 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1141
1191
|
const explicit = this.compiledComponent?.getCurrentDataState?.();
|
|
1142
1192
|
if (explicit && typeof explicit === 'object')
|
|
1143
1193
|
return explicit;
|
|
1144
|
-
return this.
|
|
1194
|
+
return this.buildCapturedDataSnapshot() ?? undefined;
|
|
1145
1195
|
}
|
|
1146
1196
|
/**
|
|
1147
1197
|
* Validates the current state of the component
|
|
@@ -1154,51 +1204,75 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1154
1204
|
* Checks if the component has unsaved changes
|
|
1155
1205
|
* @returns true if dirty, false otherwise
|
|
1156
1206
|
*/
|
|
1157
|
-
|
|
1207
|
+
IsDirty() {
|
|
1158
1208
|
return this.compiledComponent?.isDirty?.() || false;
|
|
1159
1209
|
}
|
|
1210
|
+
/** @deprecated Use {@link IsDirty}. */
|
|
1211
|
+
isDirty() {
|
|
1212
|
+
return this.IsDirty();
|
|
1213
|
+
}
|
|
1160
1214
|
/**
|
|
1161
1215
|
* Resets the component to its initial state
|
|
1162
1216
|
*/
|
|
1163
|
-
|
|
1217
|
+
Reset() {
|
|
1164
1218
|
this.compiledComponent?.reset?.();
|
|
1165
1219
|
}
|
|
1220
|
+
/** @deprecated Use {@link Reset}. */
|
|
1221
|
+
reset() {
|
|
1222
|
+
return this.Reset();
|
|
1223
|
+
}
|
|
1166
1224
|
/**
|
|
1167
1225
|
* Scrolls to a specific element or position within the component
|
|
1168
1226
|
* @param target - Element selector, element reference, or scroll options
|
|
1169
1227
|
*/
|
|
1170
|
-
|
|
1228
|
+
ScrollTo(target) {
|
|
1171
1229
|
this.compiledComponent?.scrollTo?.(target);
|
|
1172
1230
|
}
|
|
1231
|
+
/** @deprecated Use {@link ScrollTo}. */
|
|
1232
|
+
scrollTo(target) {
|
|
1233
|
+
return this.ScrollTo(target);
|
|
1234
|
+
}
|
|
1173
1235
|
/**
|
|
1174
1236
|
* Sets focus to a specific element within the component
|
|
1175
1237
|
* @param target - Element selector or element reference
|
|
1176
1238
|
*/
|
|
1177
|
-
|
|
1239
|
+
Focus(target) {
|
|
1178
1240
|
this.compiledComponent?.focus?.(target);
|
|
1179
1241
|
}
|
|
1242
|
+
/** @deprecated Use {@link Focus}. */
|
|
1243
|
+
focus(target) {
|
|
1244
|
+
return this.Focus(target);
|
|
1245
|
+
}
|
|
1180
1246
|
/**
|
|
1181
1247
|
* Invokes a custom method on the component
|
|
1182
1248
|
* @param methodName - Name of the method to invoke
|
|
1183
1249
|
* @param args - Arguments to pass to the method
|
|
1184
1250
|
* @returns The result of the method call, or undefined if method doesn't exist
|
|
1185
1251
|
*/
|
|
1186
|
-
|
|
1252
|
+
InvokeMethod(methodName, ...args) {
|
|
1187
1253
|
return this.compiledComponent?.invokeMethod?.(methodName, ...args);
|
|
1188
1254
|
}
|
|
1255
|
+
/** @deprecated Use {@link InvokeMethod}. */
|
|
1256
|
+
invokeMethod(methodName, ...args) {
|
|
1257
|
+
return this.InvokeMethod(methodName, ...args);
|
|
1258
|
+
}
|
|
1189
1259
|
/**
|
|
1190
1260
|
* Checks if a method is available on the component
|
|
1191
1261
|
* @param methodName - Name of the method to check
|
|
1192
1262
|
* @returns true if the method exists
|
|
1193
1263
|
*/
|
|
1194
|
-
|
|
1264
|
+
HasMethod(methodName) {
|
|
1195
1265
|
return this.compiledComponent?.hasMethod?.(methodName) || false;
|
|
1196
1266
|
}
|
|
1267
|
+
/** @deprecated Use {@link HasMethod}. */
|
|
1268
|
+
hasMethod(methodName) {
|
|
1269
|
+
return this.HasMethod(methodName);
|
|
1270
|
+
}
|
|
1197
1271
|
/**
|
|
1198
1272
|
* Print the component content
|
|
1199
1273
|
* Uses component's print method if available, otherwise uses window.print()
|
|
1200
1274
|
*/
|
|
1201
|
-
|
|
1275
|
+
Print() {
|
|
1202
1276
|
if (this.compiledComponent?.print) {
|
|
1203
1277
|
this.compiledComponent.print();
|
|
1204
1278
|
}
|
|
@@ -1206,12 +1280,16 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1206
1280
|
window.print();
|
|
1207
1281
|
}
|
|
1208
1282
|
}
|
|
1283
|
+
/** @deprecated Use {@link Print}. */
|
|
1284
|
+
print() {
|
|
1285
|
+
return this.Print();
|
|
1286
|
+
}
|
|
1209
1287
|
/**
|
|
1210
1288
|
* Force clear component registries
|
|
1211
1289
|
* Used by Component Studio for fresh loads
|
|
1212
1290
|
* This is a static method that can be called without a component instance
|
|
1213
1291
|
*/
|
|
1214
|
-
static
|
|
1292
|
+
static ForceClearRegistries() {
|
|
1215
1293
|
// Clear React runtime's component registry service
|
|
1216
1294
|
ComponentRegistryService.reset();
|
|
1217
1295
|
// Clear any cached hierarchy registrar
|
|
@@ -1220,6 +1298,10 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1220
1298
|
}
|
|
1221
1299
|
console.log('🧹 All component registries cleared for fresh load');
|
|
1222
1300
|
}
|
|
1301
|
+
/** @deprecated Use {@link ForceClearRegistries}. */
|
|
1302
|
+
static forceClearRegistries() {
|
|
1303
|
+
return this.ForceClearRegistries();
|
|
1304
|
+
}
|
|
1223
1305
|
/**
|
|
1224
1306
|
* Gets the current data state from the hosted React component.
|
|
1225
1307
|
* Falls back to a DataSnapshot built from intercepted RunView/RunQuery results
|
|
@@ -1241,8 +1323,8 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1241
1323
|
i0.ɵɵviewQuery(_c0, 7, ElementRef);
|
|
1242
1324
|
} if (rf & 2) {
|
|
1243
1325
|
let _t;
|
|
1244
|
-
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.
|
|
1245
|
-
} }, inputs: { component: "component", enableLogging: "enableLogging", useComponentManager: "useComponentManager", utilities: "utilities", styles: "styles", savedUserSettings: "savedUserSettings", UserStateScope: "UserStateScope", PersistUserSettings: "PersistUserSettings", componentProps: "componentProps" }, outputs: { stateChange: "stateChange", componentEvent: "componentEvent", refreshData: "refreshData", openEntityRecord: "openEntityRecord", userSettingsChanged: "userSettingsChanged", initialized: "initialized" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 4, vars: 3, consts: [["container", ""], [1, "react-component-wrapper"], [1, "react-component-container"], [1, "loading-overlay"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "loading-text"]], template: function MJReactComponent_Template(rf, ctx) { if (rf & 1) {
|
|
1326
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.Container = _t.first);
|
|
1327
|
+
} }, inputs: { Component: "Component", component: "component", EnableLogging: "EnableLogging", enableLogging: "enableLogging", UseComponentManager: "UseComponentManager", useComponentManager: "useComponentManager", utilities: "utilities", Styles: "Styles", styles: "styles", SavedUserSettings: "SavedUserSettings", savedUserSettings: "savedUserSettings", UserStateScope: "UserStateScope", PersistUserSettings: "PersistUserSettings", ComponentProps: "ComponentProps", componentProps: "componentProps" }, outputs: { StateChange: "StateChange", stateChange: "stateChange", ComponentEvent: "ComponentEvent", componentEvent: "componentEvent", RefreshData: "RefreshData", refreshData: "refreshData", OpenEntityRecord: "OpenEntityRecord", openEntityRecord: "openEntityRecord", UserSettingsChanged: "UserSettingsChanged", userSettingsChanged: "userSettingsChanged", Initialized: "Initialized", initialized: "initialized" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 4, vars: 3, consts: [["container", ""], [1, "react-component-wrapper"], [1, "react-component-container"], [1, "loading-overlay"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "loading-text"]], template: function MJReactComponent_Template(rf, ctx) { if (rf & 1) {
|
|
1246
1328
|
i0.ɵɵelementStart(0, "div", 1);
|
|
1247
1329
|
i0.ɵɵelement(1, "div", 2, 0);
|
|
1248
1330
|
i0.ɵɵconditionalCreate(3, MJReactComponent_Conditional_3_Template, 5, 0, "div", 3);
|
|
@@ -1269,39 +1351,63 @@ export class MJReactComponent extends BaseAngularComponent {
|
|
|
1269
1351
|
}
|
|
1270
1352
|
</div>
|
|
1271
1353
|
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n .react-component-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n }\n .react-component-container {\n width: 100%;\n height: 100%;\n transition: opacity 0.3s ease;\n }\n .react-component-container.loading {\n opacity: 0;\n }\n .loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background-color: rgba(255, 255, 255, 0.9);\n z-index: 1;\n }\n .loading-spinner {\n font-size: 48px;\n color: #5B4FE9;\n margin-bottom: 16px;\n }\n .loading-text {\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", Roboto, sans-serif;\n font-size: 14px;\n color: #64748B;\n margin-top: 8px;\n }\n "] }]
|
|
1272
|
-
}], () => [{ type: i1.ReactBridgeService }, { type: i2.AngularAdapterService }, { type: i0.ChangeDetectorRef }, { type: i3.MJNotificationService }], {
|
|
1354
|
+
}], () => [{ type: i1.ReactBridgeService }, { type: i2.AngularAdapterService }, { type: i0.ChangeDetectorRef }, { type: i3.MJNotificationService }], { Component: [{
|
|
1355
|
+
type: Input
|
|
1356
|
+
}], component: [{
|
|
1357
|
+
type: Input
|
|
1358
|
+
}], EnableLogging: [{
|
|
1273
1359
|
type: Input
|
|
1274
1360
|
}], enableLogging: [{
|
|
1275
1361
|
type: Input
|
|
1362
|
+
}], UseComponentManager: [{
|
|
1363
|
+
type: Input
|
|
1276
1364
|
}], useComponentManager: [{
|
|
1277
1365
|
type: Input
|
|
1278
1366
|
}], utilities: [{
|
|
1279
1367
|
type: Input
|
|
1368
|
+
}], Styles: [{
|
|
1369
|
+
type: Input
|
|
1280
1370
|
}], styles: [{
|
|
1281
1371
|
type: Input
|
|
1372
|
+
}], SavedUserSettings: [{
|
|
1373
|
+
type: Input
|
|
1282
1374
|
}], savedUserSettings: [{
|
|
1283
1375
|
type: Input
|
|
1284
1376
|
}], UserStateScope: [{
|
|
1285
1377
|
type: Input
|
|
1286
1378
|
}], PersistUserSettings: [{
|
|
1287
1379
|
type: Input
|
|
1380
|
+
}], ComponentProps: [{
|
|
1381
|
+
type: Input
|
|
1288
1382
|
}], componentProps: [{
|
|
1289
1383
|
type: Input
|
|
1384
|
+
}], StateChange: [{
|
|
1385
|
+
type: Output
|
|
1290
1386
|
}], stateChange: [{
|
|
1291
1387
|
type: Output
|
|
1388
|
+
}], ComponentEvent: [{
|
|
1389
|
+
type: Output
|
|
1292
1390
|
}], componentEvent: [{
|
|
1293
1391
|
type: Output
|
|
1392
|
+
}], RefreshData: [{
|
|
1393
|
+
type: Output
|
|
1294
1394
|
}], refreshData: [{
|
|
1295
1395
|
type: Output
|
|
1396
|
+
}], OpenEntityRecord: [{
|
|
1397
|
+
type: Output
|
|
1296
1398
|
}], openEntityRecord: [{
|
|
1297
1399
|
type: Output
|
|
1400
|
+
}], UserSettingsChanged: [{
|
|
1401
|
+
type: Output
|
|
1298
1402
|
}], userSettingsChanged: [{
|
|
1299
1403
|
type: Output
|
|
1404
|
+
}], Initialized: [{
|
|
1405
|
+
type: Output
|
|
1300
1406
|
}], initialized: [{
|
|
1301
1407
|
type: Output
|
|
1302
|
-
}],
|
|
1408
|
+
}], Container: [{
|
|
1303
1409
|
type: ViewChild,
|
|
1304
1410
|
args: ['container', { read: ElementRef, static: true }]
|
|
1305
1411
|
}] }); })();
|
|
1306
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber:
|
|
1412
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 161 }); })();
|
|
1307
1413
|
//# sourceMappingURL=mj-react-component.component.js.map
|