@siliconst/metaui 1.0.2 → 1.2.0

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 (183) hide show
  1. package/README.md +134 -123
  2. package/package.json +3 -2
  3. package/src/nz/co/siliconst/ui5/metaui/.library +7 -7
  4. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js +299 -163
  5. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js.map +1 -1
  6. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts +54 -6
  7. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts.map +1 -1
  8. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js +1 -1
  9. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js.map +1 -1
  10. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.ts +292 -162
  11. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js +51 -43
  12. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js.map +1 -1
  13. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts +5 -0
  14. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts.map +1 -1
  15. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js +1 -1
  16. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js.map +1 -1
  17. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.ts +49 -40
  18. package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js +81 -58
  19. package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js.map +1 -1
  20. package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts +5 -12
  21. package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts.map +1 -1
  22. package/src/nz/co/siliconst/ui5/metaui/core/Engine.js +1 -1
  23. package/src/nz/co/siliconst/ui5/metaui/core/Engine.js.map +1 -1
  24. package/src/nz/co/siliconst/ui5/metaui/core/Engine.ts +82 -56
  25. package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js +65 -50
  26. package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js.map +1 -1
  27. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts +9 -0
  28. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts.map +1 -1
  29. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js +1 -1
  30. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js.map +1 -1
  31. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.ts +60 -45
  32. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js +72 -59
  33. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js.map +1 -1
  34. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts +6 -4
  35. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts.map +1 -1
  36. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js +1 -1
  37. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js.map +1 -1
  38. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.ts +71 -56
  39. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +145 -36
  40. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js.map +1 -1
  41. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts +13 -8
  42. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts.map +1 -1
  43. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js +1 -1
  44. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js.map +1 -1
  45. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts +157 -31
  46. package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js +55 -55
  47. package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js.map +1 -1
  48. package/src/nz/co/siliconst/ui5/metaui/core/StateManager.d.ts.map +1 -1
  49. package/src/nz/co/siliconst/ui5/metaui/core/StateManager.js.map +1 -1
  50. package/src/nz/co/siliconst/ui5/metaui/core/StateManager.ts +56 -56
  51. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js +1 -1
  52. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js.map +1 -1
  53. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.d.ts.map +1 -1
  54. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.ts +29 -29
  55. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js +1 -1
  56. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js.map +1 -1
  57. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts +6 -12
  58. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts.map +1 -1
  59. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.ts +21 -26
  60. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js +1 -1
  61. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js.map +1 -1
  62. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts +3 -20
  63. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts.map +1 -1
  64. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.ts +14 -33
  65. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js +1 -1
  66. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js.map +1 -1
  67. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts +33 -43
  68. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts.map +1 -1
  69. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.ts +70 -70
  70. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js +23 -38
  71. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js.map +1 -1
  72. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts +4 -17
  73. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts.map +1 -1
  74. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js +1 -1
  75. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js.map +1 -1
  76. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.ts +22 -34
  77. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +98 -56
  78. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js.map +1 -1
  79. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts +7 -7
  80. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts.map +1 -1
  81. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js +1 -1
  82. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js.map +1 -1
  83. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts +97 -60
  84. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js +102 -90
  85. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js.map +1 -1
  86. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts +4 -8
  87. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts.map +1 -1
  88. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js +1 -1
  89. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js.map +1 -1
  90. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.ts +119 -102
  91. package/src/nz/co/siliconst/ui5/metaui/library-dbg.js +43 -32
  92. package/src/nz/co/siliconst/ui5/metaui/library-dbg.js.map +1 -1
  93. package/src/nz/co/siliconst/ui5/metaui/library-preload.js +22 -17
  94. package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -1
  95. package/src/nz/co/siliconst/ui5/metaui/library.d.ts.map +1 -1
  96. package/src/nz/co/siliconst/ui5/metaui/library.js +1 -1
  97. package/src/nz/co/siliconst/ui5/metaui/library.js.map +1 -1
  98. package/src/nz/co/siliconst/ui5/metaui/library.ts +55 -43
  99. package/src/nz/co/siliconst/ui5/metaui/manifest.json +1 -0
  100. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js +68 -0
  101. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js.map +1 -0
  102. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts +15 -0
  103. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts.map +1 -0
  104. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js +2 -0
  105. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js.map +1 -0
  106. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.ts +71 -0
  107. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js +54 -59
  108. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js.map +1 -1
  109. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts +8 -27
  110. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts.map +1 -1
  111. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js +1 -1
  112. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js.map +1 -1
  113. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.ts +56 -58
  114. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js +41 -42
  115. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js.map +1 -1
  116. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts +2 -2
  117. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts.map +1 -1
  118. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js +1 -1
  119. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js.map +1 -1
  120. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.ts +41 -42
  121. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js +68 -60
  122. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js.map +1 -1
  123. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts +2 -2
  124. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts.map +1 -1
  125. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js +1 -1
  126. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js.map +1 -1
  127. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.ts +69 -63
  128. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js +68 -0
  129. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js.map +1 -0
  130. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts +18 -0
  131. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts.map +1 -0
  132. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js +2 -0
  133. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js.map +1 -0
  134. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.ts +68 -0
  135. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js +66 -66
  136. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js.map +1 -1
  137. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts +2 -2
  138. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts.map +1 -1
  139. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js +1 -1
  140. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js.map +1 -1
  141. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.ts +65 -65
  142. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js +55 -53
  143. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js.map +1 -1
  144. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts +3 -3
  145. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts.map +1 -1
  146. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js +1 -1
  147. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js.map +1 -1
  148. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.ts +56 -55
  149. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js +56 -53
  150. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js.map +1 -1
  151. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts +2 -2
  152. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts.map +1 -1
  153. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js +1 -1
  154. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js.map +1 -1
  155. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.ts +58 -55
  156. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js +43 -0
  157. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js.map +1 -0
  158. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts +18 -0
  159. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts.map +1 -0
  160. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js +2 -0
  161. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js.map +1 -0
  162. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.ts +42 -0
  163. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js +58 -0
  164. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js.map +1 -0
  165. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts +18 -0
  166. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts.map +1 -0
  167. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js +2 -0
  168. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js.map +1 -0
  169. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.ts +58 -0
  170. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js +74 -0
  171. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js.map +1 -0
  172. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts +18 -0
  173. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts.map +1 -0
  174. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js +2 -0
  175. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js.map +1 -0
  176. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.ts +71 -0
  177. package/ui5.yaml +3 -3
  178. package/test-resources/App.js +0 -11
  179. package/test-resources/Main.controller.js +0 -73
  180. package/test-resources/Main.view.xml +0 -42
  181. package/test-resources/index.html +0 -21
  182. package/test-resources/mockData.json +0 -27
  183. package/test-resources/mockSchema.json +0 -98
@@ -1,162 +1,292 @@
1
- /**
2
- * @file GeneratorHost.ts
3
- * @description The core UI5 custom control that exposes the MetaUI engine to host applications.
4
- */
5
-
6
- import Control from "sap/ui/core/Control";
7
- import RenderManager from "sap/ui/core/RenderManager";
8
- import Dialog from "sap/m/Dialog";
9
- import Button from "sap/m/Button";
10
- import { SchemaNormalizer } from "../core/SchemaNormalizer";
11
- import { Engine } from "../core/Engine";
12
- import { StateManager } from "../core/StateManager";
13
- import { BaseLayout } from "../layouts/BaseLayout";
14
-
15
- /**
16
- * Enterprise wrapper element for embedding or popping the dynamic form.
17
- *
18
- * @namespace nz.co.siliconst.ui5.metaui.controls
19
- */
20
- export default class GeneratorHost extends Control {
21
-
22
- private stateManager: StateManager | null = null;
23
- private generatedContent: Control | null = null;
24
-
25
- static readonly metadata = {
26
- properties: {
27
- /** The raw JSON metadata schema provided by the ABAP backend. */
28
- schemaDefinition: { type: "object", defaultValue: null },
29
- /** The initial data payload to populate the fields. */
30
- initialData: { type: "object", defaultValue: {} }
31
- },
32
- aggregations: {
33
- /** The internal hidden container holding the generated layouts. */
34
- _content: { type: "sap.ui.core.Control", multiple: false, visibility: "hidden" }
35
- },
36
- events: {
37
- /** Triggered when the user submits the form via the Dialog modality. */
38
- submit: {
39
- parameters: {
40
- /** The clean extracted JSON payload representing the current state. */
41
- payload: { type: "object" }
42
- }
43
- },
44
- /** Triggered if the dialog is cancelled. */
45
- cancel: {}
46
- }
47
- };
48
-
49
- /**
50
- * Standard UI5 control renderer. Renders the generated internal content.
51
- */
52
- static renderer = {
53
- apiVersion: 2,
54
- render(rm: RenderManager, control: GeneratorHost) {
55
- rm.openStart("div", control);
56
- rm.style("width", "100%");
57
- rm.style("height", "100%");
58
- rm.openEnd();
59
-
60
- const content = control.getAggregation("_content") as Control;
61
- if (content) {
62
- rm.renderControl(content);
63
- }
64
-
65
- rm.close("div");
66
- }
67
- };
68
-
69
- /**
70
- * Initializes the UI5 control.
71
- */
72
- public init(): void {
73
- super.init();
74
- }
75
-
76
- /**
77
- * Lifecycle hook to automatically generate the layout if bound declaratively in XML.
78
- */
79
- public onBeforeRendering(): void {
80
- if (!this.generatedContent && this.getProperty("schemaDefinition")) {
81
- this.generate();
82
- }
83
- }
84
-
85
- /**
86
- * Extracts the payload and fires the submit event manually. Useful for inline XML embedding.
87
- */
88
- public triggerSubmit(): void {
89
- if (this.stateManager) {
90
- const payload = this.stateManager.extractPayload();
91
- this.fireEvent("submit", { payload });
92
- }
93
- }
94
-
95
- /**
96
- * Triggers the engine to parse the schema and build the layout.
97
- * Must be called manually or hooked into onBeforeRendering if properties are bound.
98
- */
99
- public generate(): void {
100
- const rawSchema = this.getProperty("schemaDefinition");
101
- const initialData = this.getProperty("initialData");
102
-
103
- if (!rawSchema) {
104
- throw new Error("[MetaUI] Cannot generate layout without a schemaDefinition.");
105
- }
106
-
107
- // 1. Normalize schema
108
- const normalizedSchema = SchemaNormalizer.normalize(rawSchema);
109
-
110
- // 2. Bootstrap isolated State Manager
111
- this.stateManager = new StateManager(initialData);
112
- this.setModel(this.stateManager.getModel(), "meta");
113
-
114
- // 3. Delegate to Layout Engine
115
- const engine = new Engine();
116
- const layoutFactory = new BaseLayout();
117
-
118
- this.generatedContent = engine.build(normalizedSchema, layoutFactory);
119
-
120
- // 4. Mount into hidden aggregation
121
- this.setAggregation("_content", this.generatedContent);
122
- }
123
-
124
- /**
125
- * Dialog Modality: Opens the generated layout inside a sap.m.Dialog.
126
- * Automatically wires up 'Save' and 'Cancel' buttons.
127
- */
128
- public openInDialog(title: string = "Dynamic Form", submitButtonText: string = "Save"): void {
129
- if (!this.generatedContent) {
130
- this.generate();
131
- }
132
-
133
- const dialog = new Dialog({
134
- title: title,
135
- contentWidth: "800px",
136
- content: [this], // Mount self inside the dialog
137
- beginButton: new Button({
138
- text: submitButtonText,
139
- type: "Emphasized",
140
- press: () => {
141
- if (this.stateManager) {
142
- const payload = this.stateManager.extractPayload();
143
- this.fireEvent("submit", { payload });
144
- }
145
- dialog.close();
146
- }
147
- }),
148
- endButton: new Button({
149
- text: "Cancel",
150
- press: () => {
151
- this.fireEvent("cancel");
152
- dialog.close();
153
- }
154
- }),
155
- afterClose: () => {
156
- dialog.destroy();
157
- }
158
- });
159
-
160
- dialog.open();
161
- }
162
- }
1
+ /**
2
+ * @file GeneratorHost.ts
3
+ * @description The core UI5 custom control that exposes the MetaUI engine to host applications.
4
+ */
5
+
6
+ import Control from "sap/ui/core/Control";
7
+ import RenderManager from "sap/ui/core/RenderManager";
8
+ import Dialog from "sap/m/Dialog";
9
+ import Button from "sap/m/Button";
10
+ import MessagePage from "sap/m/MessagePage";
11
+ import Log from "sap/base/Log";
12
+ import { SchemaNormalizer } from "../core/SchemaNormalizer";
13
+ import { Engine } from "../core/Engine";
14
+ import { StateManager } from "../core/StateManager";
15
+ import { BaseLayout } from "../layouts/BaseLayout";
16
+
17
+ /**
18
+ * Wrapper element for embedding or popping the dynamic form.
19
+ *
20
+ * @namespace nz.co.siliconst.ui5.metaui.controls
21
+ */
22
+ export default class GeneratorHost extends Control {
23
+
24
+ private stateManager: StateManager | null = null;
25
+ private generatedContent: Control | null = null;
26
+ private engine: Engine | null = null;
27
+
28
+ static readonly metadata = {
29
+ properties: {
30
+ /** The raw JSON metadata schema provided by the ABAP backend. */
31
+ schemaDefinition: { type: "any", defaultValue: null },
32
+ /** The initial data payload to populate the fields as an object. */
33
+ initialData: { type: "any", defaultValue: null },
34
+ /** The initial data payload provided as a raw JSON string. */
35
+ initialDataJson: { type: "string", defaultValue: null },
36
+ /** The final payload data object, updated on submit. */
37
+ outputData: { type: "object", defaultValue: null },
38
+ /** The final payload JSON string, updated on submit. */
39
+ outputDataJson: { type: "string", defaultValue: null },
40
+ /** If true, validation errors will be pushed to the global sap.ui.core.message.MessageManager. */
41
+ useMessageManager: { type: "boolean", defaultValue: false }
42
+ },
43
+ aggregations: {
44
+ /** The internal hidden container holding the generated layouts. */
45
+ _content: { type: "sap.ui.core.Control", multiple: false, visibility: "hidden" }
46
+ },
47
+ events: {
48
+ /** Triggered before final submission, allowing host apps to run custom validation logic and halt submission if needed. */
49
+ beforeSubmit: {
50
+ parameters: {
51
+ /** The clean extracted JSON payload representing the current state. */
52
+ payload: { type: "object" },
53
+ /** Function to add a custom validation error message for a specific field path. */
54
+ addError: { type: "function" },
55
+ /** Function to prevent the default submission and dialog closure. */
56
+ preventDefault: { type: "function" }
57
+ }
58
+ },
59
+ /** Triggered when the user submits the form via the Dialog modality. */
60
+ submit: {
61
+ parameters: {
62
+ /** The clean extracted JSON payload representing the current state. */
63
+ payload: { type: "object" },
64
+ /** The stringified final JSON payload. */
65
+ payloadJson: { type: "string" }
66
+ }
67
+ },
68
+ /** Triggered if the dialog is cancelled. */
69
+ cancel: {}
70
+ }
71
+ };
72
+
73
+ /**
74
+ * Standard UI5 control renderer. Renders the generated internal content.
75
+ */
76
+ static renderer = {
77
+ apiVersion: 2,
78
+ render(rm: RenderManager, control: GeneratorHost) {
79
+ rm.openStart("div", control);
80
+ rm.style("width", "100%");
81
+ rm.style("height", "100%");
82
+ rm.openEnd();
83
+
84
+ const content = control.getAggregation("_content") as Control;
85
+ if (content) {
86
+ rm.renderControl(content);
87
+ }
88
+
89
+ rm.close("div");
90
+ }
91
+ };
92
+
93
+ /**
94
+ * Initializes the UI5 control.
95
+ */
96
+ public init(): void {
97
+ super.init();
98
+ }
99
+
100
+ /**
101
+ * Standard UI5 lifecycle hook for destruction.
102
+ * Guaranteed to tear down isolated models and unbind global event listeners.
103
+ */
104
+ public exit(): void {
105
+ if (this.engine) {
106
+ this.engine.destroy();
107
+ this.engine = null;
108
+ }
109
+
110
+ if (this.stateManager) {
111
+ this.stateManager.getModel().destroy();
112
+ this.stateManager = null;
113
+ }
114
+
115
+ if (this.generatedContent) {
116
+ this.generatedContent.destroy();
117
+ this.generatedContent = null;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Lifecycle hook to automatically generate the layout if bound declaratively in XML.
123
+ */
124
+ public onBeforeRendering(): void {
125
+ if (!this.generatedContent && this.getProperty("schemaDefinition")) {
126
+ this.generate();
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Extracts the payload, pushes it to properties, and fires the submit event manually.
132
+ * Returns true if submission was successful, false if validation failed or was prevented.
133
+ */
134
+ public triggerSubmit(): boolean {
135
+ if (this.stateManager && this.engine) {
136
+ let isPrevented = false;
137
+ const useMessageManager = this.getProperty("useMessageManager") as boolean;
138
+ let messageManager: any = null;
139
+
140
+ if (useMessageManager) {
141
+ messageManager = sap.ui.getCore().getMessageManager();
142
+ messageManager.removeAllMessages();
143
+ }
144
+
145
+ // Helper to add messages securely via async require so it isn't a hard dependency
146
+ const pushMessage = (path: string, text: string) => {
147
+ if (useMessageManager && messageManager) {
148
+ sap.ui.require(["sap/ui/core/message/Message"], (Message: any) => {
149
+ messageManager.addMessages(new Message({
150
+ message: text,
151
+ type: "Error" as any,
152
+ target: `${this.stateManager?.getModel().getId()}>/${path}`,
153
+ processor: this.stateManager?.getModel()
154
+ }));
155
+ });
156
+ }
157
+ };
158
+
159
+ // 1. Run global schema validation
160
+ if (!this.engine.validateAll()) {
161
+ pushMessage("", "One or more fields failed schema validation. Please review the highlighted fields.");
162
+ return false; // Schema validation failed, inputs already turned red
163
+ }
164
+
165
+ const payload = this.stateManager.extractPayload();
166
+ const payloadJson = JSON.stringify(payload);
167
+
168
+ // 2. Fire beforeSubmit exit
169
+ this.fireEvent("beforeSubmit", {
170
+ payload,
171
+ preventDefault: () => {
172
+ isPrevented = true;
173
+ },
174
+ addError: (propertyPath: string, errorMessage: string) => {
175
+ isPrevented = true;
176
+ if (useMessageManager && messageManager) {
177
+ pushMessage(propertyPath, errorMessage);
178
+ } else {
179
+ Log.warning(`[MetaUI] Validation Error for ${propertyPath}: ${errorMessage}`, "GeneratorHost");
180
+ }
181
+ }
182
+ });
183
+
184
+ if (isPrevented) {
185
+ return false; // Exit validation failed or prevented submission
186
+ }
187
+
188
+ // Push final values to properties (updating XML bindings)
189
+ this.setProperty("outputData", payload, true);
190
+ this.setProperty("outputDataJson", payloadJson, true);
191
+
192
+ this.fireEvent("submit", { payload, payloadJson });
193
+ return true;
194
+ }
195
+ return false;
196
+ }
197
+
198
+ /**
199
+ * Triggers the engine to parse the schema and build the layout.
200
+ * Safely wrapped in a try/catch to prevent Launchpad crashes.
201
+ */
202
+ public generate(): void {
203
+ try {
204
+ const rawSchema = this.getProperty("schemaDefinition");
205
+
206
+ let initialData = this.getProperty("initialData");
207
+ const initialDataJson = this.getProperty("initialDataJson");
208
+
209
+ if (initialDataJson) {
210
+ try {
211
+ initialData = JSON.parse(initialDataJson);
212
+ } catch (e) {
213
+ Log.error("[MetaUI] Failed to parse initialDataJson string.", (e as Error).message, "GeneratorHost");
214
+ }
215
+ } else if (typeof initialData === "string") {
216
+ try {
217
+ initialData = JSON.parse(initialData);
218
+ } catch (e) {
219
+ Log.error("[MetaUI] Failed to parse initialData string.", (e as Error).message, "GeneratorHost");
220
+ }
221
+ }
222
+
223
+ // 1. Normalize schema (allows fallback to data inference)
224
+ const normalizedSchema = SchemaNormalizer.normalize(rawSchema, initialData);
225
+
226
+ // 2. Bootstrap isolated State Manager
227
+ this.stateManager = new StateManager(initialData || {});
228
+
229
+ // Dynamically generate a 100% unique model name for isolation
230
+ const modelName = "metaUI_" + this.getId();
231
+ this.setModel(this.stateManager.getModel(), modelName);
232
+
233
+ // 3. Delegate to Layout Engine
234
+ this.engine = new Engine();
235
+ const layoutFactory = new BaseLayout();
236
+
237
+ this.generatedContent = this.engine.build(normalizedSchema, layoutFactory, modelName);
238
+
239
+ // 4. Mount into hidden aggregation
240
+ this.setAggregation("_content", this.generatedContent);
241
+
242
+ } catch (error) {
243
+ Log.error("[MetaUI] Engine failed to generate layout. Preventing Launchpad crash.", (error as Error).message, "GeneratorHost");
244
+
245
+ const errorPage = new MessagePage({
246
+ text: "UI Generation Failed",
247
+ description: "The dynamic schema could not be rendered. Please check the Fiori console for diagnostic logs.",
248
+ icon: "sap-icon://error"
249
+ });
250
+
251
+ this.setAggregation("_content", errorPage);
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Dialog Modality: Opens the generated layout inside a sap.m.Dialog.
257
+ * Automatically wires up 'Save' and 'Cancel' buttons.
258
+ */
259
+ public openInDialog(title: string = "Dynamic Form", submitButtonText: string = "Save"): void {
260
+ if (!this.generatedContent) {
261
+ this.generate();
262
+ }
263
+
264
+ const dialog = new Dialog({
265
+ title: title,
266
+ contentWidth: "800px",
267
+ content: [this], // Mount self inside the dialog
268
+ beginButton: new Button({
269
+ text: submitButtonText,
270
+ type: "Emphasized",
271
+ press: () => {
272
+ const success = this.triggerSubmit();
273
+ if (success) {
274
+ dialog.close();
275
+ }
276
+ }
277
+ }),
278
+ endButton: new Button({
279
+ text: "Cancel",
280
+ press: () => {
281
+ this.fireEvent("cancel");
282
+ dialog.close();
283
+ }
284
+ }),
285
+ afterClose: () => {
286
+ dialog.destroy();
287
+ }
288
+ });
289
+
290
+ dialog.open();
291
+ }
292
+ }
@@ -1,44 +1,52 @@
1
- sap.ui.define(["./EventBus"], function (___EventBus) {
2
- "use strict";
3
-
4
- /**
5
- * @file ConditionEngine.ts
6
- * @description Evaluates dynamic rules to alter the schema in real-time.
7
- */
8
- const EventBus = ___EventBus["EventBus"];
9
- /**
10
- * Engine that listens to the EventBus and evaluates cross-field dependencies.
11
- */
12
- class ConditionEngine {
13
- /**
14
- * Initializes the ConditionEngine with the active schema.
15
- * @param schema The current UI layout schema.
16
- */
17
- constructor(schema) {
18
- this.schema = schema;
19
- this.initializeListeners();
20
- }
21
-
22
- /**
23
- * Subscribes to the EventBus for real-time field change interception.
24
- */
25
- initializeListeners() {
26
- EventBus.getInstance().subscribe(this.handleEvent.bind(this));
27
- }
28
-
29
- /**
30
- * Internal handler to evaluate business rules when a field is updated.
31
- * @param event The structured change event.
32
- */
33
- handleEvent(event) {
34
- // Architecture hook: Logic to evaluate conditions against the schema
35
- // and update plugin properties will be injected here in later phases.
36
- }
37
- }
38
- var __exports = {
39
- __esModule: true
40
- };
41
- __exports.ConditionEngine = ConditionEngine;
42
- return __exports;
43
- });
1
+ sap.ui.define(["./EventBus"], function (___EventBus) {
2
+ "use strict";
3
+
4
+ /**
5
+ * @file ConditionEngine.ts
6
+ * @description Evaluates dynamic rules to alter the schema in real-time.
7
+ */
8
+ const EventBus = ___EventBus["EventBus"];
9
+ /**
10
+ * Engine that listens to the EventBus and evaluates cross-field dependencies.
11
+ */
12
+ class ConditionEngine {
13
+ /**
14
+ * Initializes the ConditionEngine with the active schema.
15
+ * @param schema The current UI layout schema.
16
+ */
17
+ constructor(schema) {
18
+ this.schema = schema;
19
+ this.boundHandler = this.handleEvent.bind(this);
20
+ this.initializeListeners();
21
+ }
22
+
23
+ /**
24
+ * Subscribes to the EventBus for real-time field change interception.
25
+ */
26
+ initializeListeners() {
27
+ EventBus.getInstance().subscribe(this.boundHandler);
28
+ }
29
+
30
+ /**
31
+ * Internal handler to evaluate business rules when a field is updated.
32
+ * @param event The structured change event.
33
+ */
34
+ handleEvent(event) {
35
+ // Architecture hook: Logic to evaluate conditions against the schema
36
+ // and update plugin properties will be injected here in later phases.
37
+ }
38
+
39
+ /**
40
+ * Cleans up EventBus listeners to prevent memory leaks on destruction.
41
+ */
42
+ destroy() {
43
+ EventBus.getInstance().unsubscribe(this.boundHandler);
44
+ }
45
+ }
46
+ var __exports = {
47
+ __esModule: true
48
+ };
49
+ __exports.ConditionEngine = ConditionEngine;
50
+ return __exports;
51
+ });
44
52
  //# sourceMappingURL=ConditionEngine-dbg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionEngine-dbg.js","names":["EventBus","___EventBus","ConditionEngine","constructor","schema","initializeListeners","getInstance","subscribe","handleEvent","bind","event","__exports","__esModule"],"sources":["ConditionEngine.ts"],"sourcesContent":["/**\r\n * @file ConditionEngine.ts\r\n * @description Evaluates dynamic rules to alter the schema in real-time.\r\n */\r\n\r\nimport { EventBus } from \"./EventBus\";\r\nimport { ISchema } from \"../interfaces/ISchema\";\r\nimport { IFieldChangeEvent } from \"../interfaces/IEventBus\";\r\n\r\n/**\r\n * Engine that listens to the EventBus and evaluates cross-field dependencies.\r\n */\r\nexport class ConditionEngine {\r\n private schema: ISchema;\r\n\r\n /**\r\n * Initializes the ConditionEngine with the active schema.\r\n * @param schema The current UI layout schema.\r\n */\r\n constructor(schema: ISchema) {\r\n this.schema = schema;\r\n this.initializeListeners();\r\n }\r\n\r\n /**\r\n * Subscribes to the EventBus for real-time field change interception.\r\n */\r\n private initializeListeners(): void {\r\n EventBus.getInstance().subscribe(this.handleEvent.bind(this));\r\n }\r\n\r\n /**\r\n * Internal handler to evaluate business rules when a field is updated.\r\n * @param event The structured change event.\r\n */\r\n private handleEvent(event: IFieldChangeEvent): void {\r\n // Architecture hook: Logic to evaluate conditions against the schema \r\n // and update plugin properties will be injected here in later phases.\r\n }\r\n}\r\n"],"mappings":";;;EAAA;AACA;AACA;AACA;EAHA,MAKSA,QAAQ,GAAAC,WAAA;EAIjB;AACA;AACA;EACO,MAAMC,eAAe,CAAC;IAGzB;AACJ;AACA;AACA;IACIC,WAAWA,CAACC,MAAe,EAAE;MACzB,IAAI,CAACA,MAAM,GAAGA,MAAM;MACpB,IAAI,CAACC,mBAAmB,CAAC,CAAC;IAC9B;;IAEA;AACJ;AACA;IACYA,mBAAmBA,CAAA,EAAS;MAChCL,QAAQ,CAACM,WAAW,CAAC,CAAC,CAACC,SAAS,CAAC,IAAI,CAACC,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE;;IAEA;AACJ;AACA;AACA;IACYD,WAAWA,CAACE,KAAwB,EAAQ;MAChD;MACA;IAAA;EAER;EAAC,IAAAC,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAT,eAAA,GAAAA,eAAA;EAAA,OAAAS,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"ConditionEngine-dbg.js","names":["EventBus","___EventBus","ConditionEngine","constructor","schema","boundHandler","handleEvent","bind","initializeListeners","getInstance","subscribe","event","destroy","unsubscribe","__exports","__esModule"],"sources":["ConditionEngine.ts"],"sourcesContent":["/**\n * @file ConditionEngine.ts\n * @description Evaluates dynamic rules to alter the schema in real-time.\n */\n\nimport { EventBus } from \"./EventBus\";\nimport { ISchema } from \"../interfaces/ISchema\";\nimport { IFieldChangeEvent } from \"../interfaces/IEventBus\";\n\n/**\n * Engine that listens to the EventBus and evaluates cross-field dependencies.\n */\nexport class ConditionEngine {\n private schema: ISchema;\n private boundHandler: (event: IFieldChangeEvent) => void;\n\n /**\n * Initializes the ConditionEngine with the active schema.\n * @param schema The current UI layout schema.\n */\n constructor(schema: ISchema) {\n this.schema = schema;\n this.boundHandler = this.handleEvent.bind(this);\n this.initializeListeners();\n }\n\n /**\n * Subscribes to the EventBus for real-time field change interception.\n */\n private initializeListeners(): void {\n EventBus.getInstance().subscribe(this.boundHandler);\n }\n\n /**\n * Internal handler to evaluate business rules when a field is updated.\n * @param event The structured change event.\n */\n private handleEvent(event: IFieldChangeEvent): void {\n // Architecture hook: Logic to evaluate conditions against the schema \n // and update plugin properties will be injected here in later phases.\n }\n\n /**\n * Cleans up EventBus listeners to prevent memory leaks on destruction.\n */\n public destroy(): void {\n EventBus.getInstance().unsubscribe(this.boundHandler);\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;EAHA,MAKSA,QAAQ,GAAAC,WAAA;EAIjB;AACA;AACA;EACO,MAAMC,eAAe,CAAC;IAIzB;AACJ;AACA;AACA;IACIC,WAAWA,CAACC,MAAe,EAAE;MACzB,IAAI,CAACA,MAAM,GAAGA,MAAM;MACpB,IAAI,CAACC,YAAY,GAAG,IAAI,CAACC,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC;MAC/C,IAAI,CAACC,mBAAmB,CAAC,CAAC;IAC9B;;IAEA;AACJ;AACA;IACYA,mBAAmBA,CAAA,EAAS;MAChCR,QAAQ,CAACS,WAAW,CAAC,CAAC,CAACC,SAAS,CAAC,IAAI,CAACL,YAAY,CAAC;IACvD;;IAEA;AACJ;AACA;AACA;IACYC,WAAWA,CAACK,KAAwB,EAAQ;MAChD;MACA;IAAA;;IAGJ;AACJ;AACA;IACWC,OAAOA,CAAA,EAAS;MACnBZ,QAAQ,CAACS,WAAW,CAAC,CAAC,CAACI,WAAW,CAAC,IAAI,CAACR,YAAY,CAAC;IACzD;EACJ;EAAC,IAAAS,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAZ,eAAA,GAAAA,eAAA;EAAA,OAAAY,SAAA;AAAA","ignoreList":[]}
@@ -5,6 +5,7 @@ declare module "nz/co/siliconst/ui5/metaui/core/ConditionEngine" {
5
5
  */
6
6
  export class ConditionEngine {
7
7
  private schema;
8
+ private boundHandler;
8
9
  /**
9
10
  * Initializes the ConditionEngine with the active schema.
10
11
  * @param schema The current UI layout schema.
@@ -19,6 +20,10 @@ declare module "nz/co/siliconst/ui5/metaui/core/ConditionEngine" {
19
20
  * @param event The structured change event.
20
21
  */
21
22
  private handleEvent;
23
+ /**
24
+ * Cleans up EventBus listeners to prevent memory leaks on destruction.
25
+ */
26
+ destroy(): void;
22
27
  }
23
28
  }
24
29
  //# sourceMappingURL=ConditionEngine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionEngine.d.ts","sourceRoot":"..\\..\\..\\..\\..\\..\\..\\..","sources":["src\\nz\\co\\siliconst\\ui5\\metaui\\core\\ConditionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,iDAAiD,CAAC;IAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;IAGxE;;OAEG;IACH,MAAa,eAAe;QACxB,OAAO,CAAC,MAAM,CAAU;QAExB;;;WAGG;oBACS,MAAM,EAAE,OAAO;QAK3B;;WAEG;QACH,OAAO,CAAC,mBAAmB;QAI3B;;;WAGG;QACH,OAAO,CAAC,WAAW;KAItB;CAEA"}
1
+ {"version":3,"file":"ConditionEngine.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,iDAAiD,CAAC;IAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;IAGxE;;OAEG;IACH,MAAa,eAAe;QACxB,OAAO,CAAC,MAAM,CAAU;QACxB,OAAO,CAAC,YAAY,CAAqC;QAEzD;;;WAGG;oBACS,MAAM,EAAE,OAAO;QAM3B;;WAEG;QACH,OAAO,CAAC,mBAAmB;QAI3B;;;WAGG;QACH,OAAO,CAAC,WAAW;QAKnB;;WAEG;QACI,OAAO,IAAI,IAAI;KAGzB;CAEA"}
@@ -1,2 +1,2 @@
1
- sap.ui.define(["./EventBus"],function(e){"use strict";const i=e["EventBus"];class n{constructor(e){this.schema=e;this.initializeListeners()}initializeListeners(){i.getInstance().subscribe(this.handleEvent.bind(this))}handleEvent(e){}}var t={__esModule:true};t.ConditionEngine=n;return t});
1
+ sap.ui.define(["./EventBus"],function(n){"use strict";const e=n["EventBus"];class s{constructor(n){this.schema=n;this.boundHandler=this.handleEvent.bind(this);this.initializeListeners()}initializeListeners(){e.getInstance().subscribe(this.boundHandler)}handleEvent(n){}destroy(){e.getInstance().unsubscribe(this.boundHandler)}}var t={__esModule:true};t.ConditionEngine=s;return t});
2
2
  //# sourceMappingURL=ConditionEngine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionEngine.js","names":["EventBus","___EventBus","ConditionEngine","constructor","schema","this","initializeListeners","getInstance","subscribe","handleEvent","bind","event","__exports","__esModule"],"sources":["ConditionEngine.ts"],"sourcesContent":["/**\r\n * @file ConditionEngine.ts\r\n * @description Evaluates dynamic rules to alter the schema in real-time.\r\n */\r\n\r\nimport { EventBus } from \"./EventBus\";\r\nimport { ISchema } from \"../interfaces/ISchema\";\r\nimport { IFieldChangeEvent } from \"../interfaces/IEventBus\";\r\n\r\n/**\r\n * Engine that listens to the EventBus and evaluates cross-field dependencies.\r\n */\r\nexport class ConditionEngine {\r\n private schema: ISchema;\r\n\r\n /**\r\n * Initializes the ConditionEngine with the active schema.\r\n * @param schema The current UI layout schema.\r\n */\r\n constructor(schema: ISchema) {\r\n this.schema = schema;\r\n this.initializeListeners();\r\n }\r\n\r\n /**\r\n * Subscribes to the EventBus for real-time field change interception.\r\n */\r\n private initializeListeners(): void {\r\n EventBus.getInstance().subscribe(this.handleEvent.bind(this));\r\n }\r\n\r\n /**\r\n * Internal handler to evaluate business rules when a field is updated.\r\n * @param event The structured change event.\r\n */\r\n private handleEvent(event: IFieldChangeEvent): void {\r\n // Architecture hook: Logic to evaluate conditions against the schema \r\n // and update plugin properties will be injected here in later phases.\r\n }\r\n}\r\n"],"mappings":"sDAAA,MAKSA,EAAQC,EAAA,YAOV,MAAMC,EAOTC,YAAYC,GACRC,KAAKD,OAASA,EACdC,KAAKC,qBACT,CAKQA,sBACJN,EAASO,cAAcC,UAAUH,KAAKI,YAAYC,KAAKL,MAC3D,CAMQI,YAAYE,GAEhB,EAEP,IAAAC,EAAA,CAAAC,WAAA,MAAAD,EAAAV,kBAAA,OAAAU,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"ConditionEngine.js","names":["EventBus","___EventBus","ConditionEngine","constructor","schema","this","boundHandler","handleEvent","bind","initializeListeners","getInstance","subscribe","event","destroy","unsubscribe","__exports","__esModule"],"sources":["ConditionEngine.ts"],"sourcesContent":["/**\n * @file ConditionEngine.ts\n * @description Evaluates dynamic rules to alter the schema in real-time.\n */\n\nimport { EventBus } from \"./EventBus\";\nimport { ISchema } from \"../interfaces/ISchema\";\nimport { IFieldChangeEvent } from \"../interfaces/IEventBus\";\n\n/**\n * Engine that listens to the EventBus and evaluates cross-field dependencies.\n */\nexport class ConditionEngine {\n private schema: ISchema;\n private boundHandler: (event: IFieldChangeEvent) => void;\n\n /**\n * Initializes the ConditionEngine with the active schema.\n * @param schema The current UI layout schema.\n */\n constructor(schema: ISchema) {\n this.schema = schema;\n this.boundHandler = this.handleEvent.bind(this);\n this.initializeListeners();\n }\n\n /**\n * Subscribes to the EventBus for real-time field change interception.\n */\n private initializeListeners(): void {\n EventBus.getInstance().subscribe(this.boundHandler);\n }\n\n /**\n * Internal handler to evaluate business rules when a field is updated.\n * @param event The structured change event.\n */\n private handleEvent(event: IFieldChangeEvent): void {\n // Architecture hook: Logic to evaluate conditions against the schema \n // and update plugin properties will be injected here in later phases.\n }\n\n /**\n * Cleans up EventBus listeners to prevent memory leaks on destruction.\n */\n public destroy(): void {\n EventBus.getInstance().unsubscribe(this.boundHandler);\n }\n}\n"],"mappings":"sDAAA,MAKSA,EAAQC,EAAA,YAOV,MAAMC,EAQTC,YAAYC,GACRC,KAAKD,OAASA,EACdC,KAAKC,aAAeD,KAAKE,YAAYC,KAAKH,MAC1CA,KAAKI,qBACT,CAKQA,sBACJT,EAASU,cAAcC,UAAUN,KAAKC,aAC1C,CAMQC,YAAYK,GAEhB,CAMGC,UACHb,EAASU,cAAcI,YAAYT,KAAKC,aAC5C,EACH,IAAAS,EAAA,CAAAC,WAAA,MAAAD,EAAAb,kBAAA,OAAAa,CAAA","ignoreList":[]}