commons-shared-web-ui 0.0.54 → 0.0.55

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 (225) hide show
  1. package/.claude/settings.local.json +10 -0
  2. package/documentation/alert.md +123 -0
  3. package/documentation/button-dropdown.md +126 -0
  4. package/documentation/button.md +184 -0
  5. package/documentation/cards-usage-guidelines.md +131 -0
  6. package/documentation/configurable-form.md +605 -0
  7. package/documentation/confirmation-modal.md +250 -0
  8. package/documentation/filter-sidebar.md +178 -0
  9. package/documentation/filter-table-selector.md +228 -0
  10. package/documentation/form-builder.md +599 -0
  11. package/documentation/form-components.md +384 -0
  12. package/documentation/form-field-configuration.md +250 -0
  13. package/documentation/nav.md +427 -0
  14. package/documentation/pagination.md +181 -0
  15. package/documentation/side-nav-documentation.md +169 -0
  16. package/documentation/smart-form.md +2765 -0
  17. package/documentation/smart-table.md +1221 -0
  18. package/documentation/snackbar.md +118 -0
  19. package/documentation/style-externalization.md +88 -0
  20. package/documentation/summary-card.md +279 -0
  21. package/documentation/table-column-configuration.md +221 -0
  22. package/documentation/time-picker.md +274 -0
  23. package/ng-package.json +30 -0
  24. package/package.json +53 -34
  25. package/src/lib/modules/alert/alert.models.ts +6 -0
  26. package/src/lib/modules/alert/alert.module.ts +16 -0
  27. package/src/lib/modules/alert/components/alert/alert.component.html +27 -0
  28. package/src/lib/modules/alert/components/alert/alert.component.scss +92 -0
  29. package/src/lib/modules/alert/components/alert/alert.component.ts +81 -0
  30. package/src/lib/modules/button/button.models.ts +13 -0
  31. package/src/lib/modules/button/button.module.ts +16 -0
  32. package/src/lib/modules/button/components/button/button.component.html +22 -0
  33. package/src/lib/modules/button/components/button/button.component.scss +88 -0
  34. package/src/lib/modules/button/components/button/button.component.ts +67 -0
  35. package/src/lib/modules/button-dropdown/button-dropdown.models.ts +26 -0
  36. package/src/lib/modules/button-dropdown/button-dropdown.module.ts +22 -0
  37. package/src/lib/modules/button-dropdown/button-dropdown.theme.scss +87 -0
  38. package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.html +41 -0
  39. package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.scss +135 -0
  40. package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.ts +160 -0
  41. package/src/lib/modules/configurable-form/component/configurable-form.component.html +294 -0
  42. package/src/lib/modules/configurable-form/component/configurable-form.component.scss +503 -0
  43. package/src/lib/modules/configurable-form/component/configurable-form.component.ts +628 -0
  44. package/src/lib/modules/configurable-form/configurable-form.examples.ts +154 -0
  45. package/src/lib/modules/configurable-form/configurable-form.model.ts +131 -0
  46. package/src/lib/modules/configurable-form/configurable-form.module.ts +19 -0
  47. package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.html +77 -0
  48. package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.scss +395 -0
  49. package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.ts +266 -0
  50. package/src/lib/modules/confirmation-modal/confirmation-modal.models.ts +71 -0
  51. package/src/lib/modules/confirmation-modal/confirmation-modal.module.ts +20 -0
  52. package/src/lib/modules/filter/components/filter/filter.component.html +131 -0
  53. package/src/lib/modules/filter/components/filter/filter.component.scss +245 -0
  54. package/src/lib/modules/filter/components/filter/filter.component.ts +216 -0
  55. package/src/lib/modules/filter/filter.models.ts +88 -0
  56. package/src/lib/modules/filter/filter.module.ts +24 -0
  57. package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.html +112 -0
  58. package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.scss +186 -0
  59. package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.ts +163 -0
  60. package/src/lib/modules/filter-sidebar/filter-sidebar.models.ts +95 -0
  61. package/src/lib/modules/filter-sidebar/filter-sidebar.module.ts +24 -0
  62. package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.html +73 -0
  63. package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.scss +321 -0
  64. package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.ts +361 -0
  65. package/src/lib/modules/filter-table-selector/filter-table-selector.models.ts +91 -0
  66. package/src/lib/modules/filter-table-selector/filter-table-selector.module.ts +22 -0
  67. package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.html +63 -0
  68. package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.scss +496 -0
  69. package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.ts +445 -0
  70. package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.html +75 -0
  71. package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.scss +210 -0
  72. package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.ts +55 -0
  73. package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.html +25 -0
  74. package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.scss +82 -0
  75. package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.ts +95 -0
  76. package/src/lib/modules/form-builder/components/field-selection/field-selection.component.html +20 -0
  77. package/src/lib/modules/form-builder/components/field-selection/field-selection.component.scss +37 -0
  78. package/src/lib/modules/form-builder/components/field-selection/field-selection.component.ts +94 -0
  79. package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.html +46 -0
  80. package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.scss +102 -0
  81. package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.ts +50 -0
  82. package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.html +35 -0
  83. package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.scss +67 -0
  84. package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.ts +34 -0
  85. package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.html +68 -0
  86. package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.scss +113 -0
  87. package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.ts +74 -0
  88. package/src/lib/modules/form-builder/configs/field-type-schema.map.ts +533 -0
  89. package/src/lib/modules/form-builder/form-builder.module.ts +36 -0
  90. package/src/lib/modules/form-builder/index.ts +9 -0
  91. package/src/lib/modules/form-builder/models/builder.models.ts +7 -0
  92. package/src/lib/modules/form-builder/models/field-configurator.models.ts +38 -0
  93. package/src/lib/modules/form-builder/models/field-selection.models.ts +51 -0
  94. package/src/lib/modules/form-builder/services/field-configurator.service.ts +258 -0
  95. package/src/lib/modules/form-builder/services/field-selection.service.ts +299 -0
  96. package/src/lib/modules/form-builder/services/form-schema-tree.service.ts +670 -0
  97. package/src/lib/modules/form-builder/tokens/builder.tokens.ts +10 -0
  98. package/src/lib/modules/form-builder/utils/constants.ts +43 -0
  99. package/src/lib/modules/form-components/components/checkbox/checkbox.component.html +29 -0
  100. package/src/lib/modules/form-components/components/checkbox/checkbox.component.scss +111 -0
  101. package/src/lib/modules/form-components/components/checkbox/checkbox.component.ts +207 -0
  102. package/src/lib/modules/form-components/components/checkbox/checkbox.models.ts +35 -0
  103. package/src/lib/modules/form-components/components/datepicker/datepicker.component.html +42 -0
  104. package/src/lib/modules/form-components/components/datepicker/datepicker.component.scss +115 -0
  105. package/src/lib/modules/form-components/components/datepicker/datepicker.component.ts +267 -0
  106. package/src/lib/modules/form-components/components/datepicker/datepicker.models.ts +45 -0
  107. package/src/lib/modules/form-components/components/dropdown/dropdown.component.html +74 -0
  108. package/src/lib/modules/form-components/components/dropdown/dropdown.component.scss +252 -0
  109. package/src/lib/modules/form-components/components/dropdown/dropdown.component.ts +377 -0
  110. package/src/lib/modules/form-components/components/dropdown/dropdown.models.ts +53 -0
  111. package/src/lib/modules/form-components/components/input/input.component.html +51 -0
  112. package/src/lib/modules/form-components/components/input/input.component.scss +128 -0
  113. package/src/lib/modules/form-components/components/input/input.component.ts +250 -0
  114. package/src/lib/modules/form-components/components/input/input.models.ts +55 -0
  115. package/src/lib/modules/form-components/components/radio/radio.component.html +22 -0
  116. package/src/lib/modules/form-components/components/radio/radio.component.scss +107 -0
  117. package/src/lib/modules/form-components/components/radio/radio.component.ts +181 -0
  118. package/src/lib/modules/form-components/components/radio/radio.models.ts +39 -0
  119. package/src/lib/modules/form-components/components/search/search.component.html +15 -0
  120. package/src/lib/modules/form-components/components/search/search.component.scss +87 -0
  121. package/src/lib/modules/form-components/components/search/search.component.ts +213 -0
  122. package/src/lib/modules/form-components/components/search/search.models.ts +40 -0
  123. package/src/lib/modules/form-components/components/toggle/toggle.component.html +15 -0
  124. package/src/lib/modules/form-components/components/toggle/toggle.component.scss +81 -0
  125. package/src/lib/modules/form-components/components/toggle/toggle.component.ts +166 -0
  126. package/src/lib/modules/form-components/components/toggle/toggle.models.ts +27 -0
  127. package/src/lib/modules/form-components/directives/click-outside.directive.ts +22 -0
  128. package/src/lib/modules/form-components/form-components.module.ts +42 -0
  129. package/src/lib/modules/form-field-configuration/components/_ffc-controls.scss +89 -0
  130. package/src/lib/modules/form-field-configuration/components/config-field-node/config-field-node.component.html +68 -0
  131. package/src/lib/modules/form-field-configuration/components/config-field-node/config-field-node.component.scss +73 -0
  132. package/src/lib/modules/form-field-configuration/components/config-field-node/config-field-node.component.ts +34 -0
  133. package/src/lib/modules/form-field-configuration/components/config-section-node/config-section-node.component.html +78 -0
  134. package/src/lib/modules/form-field-configuration/components/config-section-node/config-section-node.component.scss +83 -0
  135. package/src/lib/modules/form-field-configuration/components/config-section-node/config-section-node.component.ts +94 -0
  136. package/src/lib/modules/form-field-configuration/components/form-field-configuration/form-field-configuration.component.html +38 -0
  137. package/src/lib/modules/form-field-configuration/components/form-field-configuration/form-field-configuration.component.scss +42 -0
  138. package/src/lib/modules/form-field-configuration/components/form-field-configuration/form-field-configuration.component.ts +92 -0
  139. package/src/lib/modules/form-field-configuration/form-field-configuration.module.ts +23 -0
  140. package/src/lib/modules/form-field-configuration/index.ts +7 -0
  141. package/src/lib/modules/form-field-configuration/models/field-configuration.models.ts +62 -0
  142. package/src/lib/modules/form-field-configuration/services/config-schema-tree.service.ts +159 -0
  143. package/src/lib/modules/form-field-configuration/services/field-configuration.service.ts +228 -0
  144. package/src/lib/modules/material/material.module.ts +94 -0
  145. package/src/lib/modules/nav/components/nav/nav.component.html +34 -0
  146. package/src/lib/modules/nav/components/nav/nav.component.scss +171 -0
  147. package/src/lib/modules/nav/components/nav/nav.component.ts +82 -0
  148. package/src/lib/modules/nav/nav.models.ts +31 -0
  149. package/src/lib/modules/nav/nav.module.ts +17 -0
  150. package/src/lib/modules/pagination/components/pagination/pagination.component.html +52 -0
  151. package/src/lib/modules/pagination/components/pagination/pagination.component.scss +155 -0
  152. package/src/lib/modules/pagination/components/pagination/pagination.component.ts +109 -0
  153. package/src/lib/modules/pagination/pagination.module.ts +17 -0
  154. package/src/lib/modules/side-nav/components/side-nav/side-nav.component.html +56 -0
  155. package/src/lib/modules/side-nav/components/side-nav/side-nav.component.scss +342 -0
  156. package/src/lib/modules/side-nav/components/side-nav/side-nav.component.ts +135 -0
  157. package/src/lib/modules/side-nav/side-nav.models.ts +38 -0
  158. package/src/lib/modules/side-nav/side-nav.module.ts +16 -0
  159. package/src/lib/modules/smart-form/components/form-field/form-field.component.html +1330 -0
  160. package/src/lib/modules/smart-form/components/form-field/form-field.component.scss +2112 -0
  161. package/src/lib/modules/smart-form/components/form-field/form-field.component.ts +3006 -0
  162. package/src/lib/modules/smart-form/components/form-section/form-section.component.html +65 -0
  163. package/src/lib/modules/smart-form/components/form-section/form-section.component.scss +209 -0
  164. package/src/lib/modules/smart-form/components/form-section/form-section.component.ts +131 -0
  165. package/src/lib/modules/smart-form/components/smart-form/smart-form.component.html +253 -0
  166. package/src/lib/modules/smart-form/components/smart-form/smart-form.component.scss +689 -0
  167. package/src/lib/modules/smart-form/components/smart-form/smart-form.component.ts +1131 -0
  168. package/src/lib/modules/smart-form/index.ts +10 -0
  169. package/src/lib/modules/smart-form/models/form-schema.model.ts +793 -0
  170. package/src/lib/modules/smart-form/models/hierarchy-config.model.ts +21 -0
  171. package/src/lib/modules/smart-form/services/expression.service.ts +75 -0
  172. package/src/lib/modules/smart-form/services/smart-form-controller.service.ts +67 -0
  173. package/src/lib/modules/smart-form/smart-form.examples.ts +1324 -0
  174. package/src/lib/modules/smart-form/smart-form.module.ts +38 -0
  175. package/src/lib/modules/smart-form/utils/translation.utils.ts +82 -0
  176. package/src/lib/modules/smart-form/utils/trusted-url.pipe.ts +25 -0
  177. package/src/lib/modules/smart-form/utils/validation.utils.ts +98 -0
  178. package/src/lib/modules/smart-table/components/smart-table/smart-table.component.html +283 -0
  179. package/src/lib/modules/smart-table/components/smart-table/smart-table.component.scss +685 -0
  180. package/src/lib/modules/smart-table/components/smart-table/smart-table.component.ts +1128 -0
  181. package/src/lib/modules/smart-table/models/table-config.model.ts +213 -0
  182. package/src/lib/modules/smart-table/smart-table.module.ts +30 -0
  183. package/src/lib/modules/smart-table/utils/safe-html.pipe.ts +28 -0
  184. package/src/lib/modules/smart-table/utils/smart-table.utils.ts +18 -0
  185. package/src/lib/modules/snackbar/components/snackbar.component.html +41 -0
  186. package/src/lib/modules/snackbar/components/snackbar.component.scss +99 -0
  187. package/src/lib/modules/snackbar/components/snackbar.component.ts +18 -0
  188. package/src/lib/modules/snackbar/models/snackbar.models.ts +10 -0
  189. package/src/lib/modules/snackbar/services/snackbar.service.ts +40 -0
  190. package/src/lib/modules/snackbar/snackbar.module.ts +11 -0
  191. package/src/lib/modules/summary-card/components/summary-card/summary-card.component.html +47 -0
  192. package/src/lib/modules/summary-card/components/summary-card/summary-card.component.scss +199 -0
  193. package/src/lib/modules/summary-card/components/summary-card/summary-card.component.ts +126 -0
  194. package/src/lib/modules/summary-card/summary-card.module.ts +18 -0
  195. package/src/lib/modules/table-column-configuration/components/_tcc-controls.scss +53 -0
  196. package/src/lib/modules/table-column-configuration/components/config-column-node/config-column-node.component.html +47 -0
  197. package/src/lib/modules/table-column-configuration/components/config-column-node/config-column-node.component.scss +50 -0
  198. package/src/lib/modules/table-column-configuration/components/config-column-node/config-column-node.component.ts +33 -0
  199. package/src/lib/modules/table-column-configuration/components/table-column-configuration/table-column-configuration.component.html +30 -0
  200. package/src/lib/modules/table-column-configuration/components/table-column-configuration/table-column-configuration.component.scss +36 -0
  201. package/src/lib/modules/table-column-configuration/components/table-column-configuration/table-column-configuration.component.ts +78 -0
  202. package/src/lib/modules/table-column-configuration/index.ts +5 -0
  203. package/src/lib/modules/table-column-configuration/models/table-column-configuration.models.ts +20 -0
  204. package/src/lib/modules/table-column-configuration/services/table-column-configuration.service.ts +77 -0
  205. package/src/lib/modules/table-column-configuration/table-column-configuration.module.ts +21 -0
  206. package/src/lib/modules/time-picker/components/time-picker/time-picker.component.html +37 -0
  207. package/src/lib/modules/time-picker/components/time-picker/time-picker.component.scss +102 -0
  208. package/src/lib/modules/time-picker/components/time-picker/time-picker.component.ts +178 -0
  209. package/src/lib/modules/time-picker/components/time-wheel-panel/time-wheel-panel.component.html +78 -0
  210. package/src/lib/modules/time-picker/components/time-wheel-panel/time-wheel-panel.component.scss +226 -0
  211. package/src/lib/modules/time-picker/components/time-wheel-panel/time-wheel-panel.component.ts +595 -0
  212. package/src/lib/modules/time-picker/models/time-picker.models.ts +49 -0
  213. package/src/lib/modules/time-picker/time-picker.module.ts +23 -0
  214. package/src/lib/modules/time-picker/time-picker.theme.scss +87 -0
  215. package/src/lib/shared-ui.module.ts +55 -0
  216. package/src/lib/styles/global.scss +10 -0
  217. package/src/lib/utils/constants.ts +11 -0
  218. package/src/lib/utils/storage.utils.ts +37 -0
  219. package/src/lib/utils/string.utils.ts +23 -0
  220. package/src/lib/utils/translation.utils.ts +87 -0
  221. package/src/public-api.ts +127 -0
  222. package/tsconfig.lib.json +15 -0
  223. package/fesm2022/commons-shared-web-ui.mjs +0 -14823
  224. package/fesm2022/commons-shared-web-ui.mjs.map +0 -1
  225. package/index.d.ts +0 -4679
@@ -0,0 +1,2765 @@
1
+ # Smart Form Module
2
+
3
+ A powerful, JSON-driven dynamic form builder for Angular applications. This module allows you to create complex forms with conditional visibility, auto-calculated fields, multi-section support, stepper navigation, repeatable groups, column-based layouts, automatic API submission, and full i18n support — using simple JSON configurations.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Quick Start](#quick-start)
9
+ - [Form Types](#form-types)
10
+ - [Field Types](#field-types)
11
+ - [Layout System](#layout-system)
12
+ - [Configuration Options](#configuration-options)
13
+ - [Advanced Features](#advanced-features)
14
+ - [i18n / Translation Support](#i18n--translation-support)
15
+ - [API Submission](#api-submission)
16
+ - [API Authentication (Token)](#api-authentication-token)
17
+ - [Theme Configuration](#theme-configuration)
18
+ - [Examples](#examples)
19
+ - [API Reference](#api-reference)
20
+ - [Best Practices](#best-practices)
21
+ - [Troubleshooting](#troubleshooting)
22
+
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ To install the latest version of the `commons-shared-web-ui` library, run the following command:
28
+
29
+ ```bash
30
+ npm install commons-shared-web-ui@latest
31
+ ```
32
+
33
+ 1. Import the module in your Angular application:
34
+
35
+ ```typescript
36
+ import { SmartFormModule } from "./modules/smart-form/smart-form.module";
37
+
38
+ @NgModule({
39
+ imports: [SmartFormModule],
40
+ })
41
+ export class AppModule {}
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Quick Start
47
+
48
+ ### Basic Usage
49
+
50
+ ```typescript
51
+ import { Component } from "@angular/core";
52
+
53
+ @Component({
54
+ selector: "app-example",
55
+ template: `
56
+ <lib-smart-form
57
+ [formJson]="formJson"
58
+ [initialValues]="initialValues"
59
+ [labels]="labels"
60
+ (submit)="onSubmit($event)"
61
+ >
62
+ </lib-smart-form>
63
+ `,
64
+ })
65
+ export class ExampleComponent {
66
+ formJson = JSON.stringify({
67
+ entityType: "USER",
68
+ label: "FORM.TITLE",
69
+ formType: "SECTION",
70
+ sectionConfig: {
71
+ children: [
72
+ {
73
+ name: "firstName",
74
+ label: "FIELD.FIRST_NAME",
75
+ type: "TEXT_INPUT",
76
+ subType: "SHORT",
77
+ required: true,
78
+ },
79
+ {
80
+ name: "email",
81
+ label: "FIELD.EMAIL",
82
+ type: "TEXT_INPUT",
83
+ subType: "EMAIL",
84
+ required: true,
85
+ },
86
+ ],
87
+ },
88
+ });
89
+
90
+ initialValues = { firstName: "John" };
91
+
92
+ labels = {
93
+ "FORM.TITLE": "User Registration",
94
+ "FIELD.FIRST_NAME": "First Name",
95
+ "FIELD.EMAIL": "Email Address",
96
+ };
97
+
98
+ onSubmit(data: any) {
99
+ console.log("Form submitted:", data);
100
+ }
101
+ }
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Form Types
107
+
108
+ ### 1. Section Form (SECTION)
109
+
110
+ A simple form with all fields displayed at once.
111
+
112
+ ```json
113
+ {
114
+ "entityType": "USER",
115
+ "label": "User Form",
116
+ "formType": "SECTION",
117
+ "sectionConfig": {
118
+ "children": [...]
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### 2. Stepper Form (STEPPER)
124
+
125
+ A multi-step form with navigation between steps. Each step is a `GROUP` field with a `sectionConfig`.
126
+
127
+ ```json
128
+ {
129
+ "entityType": "USER",
130
+ "label": "User Registration",
131
+ "formType": "STEPPER",
132
+ "stepperConfig": {
133
+ "children": [
134
+ {
135
+ "type": "GROUP",
136
+ "subType": "SECTION",
137
+ "sectionConfig": {
138
+ "label": "Step 1: Basic Info",
139
+ "children": [...]
140
+ }
141
+ },
142
+ {
143
+ "type": "GROUP",
144
+ "subType": "SECTION",
145
+ "sectionConfig": {
146
+ "label": "Step 2: Contact Info",
147
+ "children": [...]
148
+ }
149
+ }
150
+ ],
151
+ "showStep": true,
152
+ "isHorizontal": true
153
+ }
154
+ }
155
+ ```
156
+
157
+ ### 3. Section Stepper (SECTION + `sectionStepper`)
158
+
159
+ A `SECTION` form where top-level `GROUP` children are rendered as a horizontal step-progress bar at the top, showing one section at a time. Set `"sectionStepper": true` to enable it explicitly. The form auto-detects it when all top-level children are `GROUP` type — set `"sectionStepper": false` to suppress auto-detection.
160
+
161
+ > **Note:** A schema with exactly **one** surviving top-level `GROUP` (e.g. after a business user disables every other section via the Field Selection Configurator — see `form-builder.md`) is still treated as a section stepper. The step nav bar itself is hidden when there's only one step, so it renders as a plain single-section form instead of the blank result older versions produced in this case.
162
+
163
+ The component automatically renders **Previous** and **Next** buttons in the action bar. Any configured `actionBarConfig` buttons appear alongside these navigation buttons.
164
+
165
+ ```json
166
+ {
167
+ "entityType": "REGISTRATION",
168
+ "label": "Multi-Step Registration",
169
+ "formType": "SECTION",
170
+ "sectionStepper": true,
171
+ "sectionConfig": {
172
+ "children": [
173
+ {
174
+ "type": "GROUP",
175
+ "subType": "SECTION",
176
+ "sectionConfig": {
177
+ "label": "Personal Info",
178
+ "children": [...]
179
+ }
180
+ },
181
+ {
182
+ "type": "GROUP",
183
+ "subType": "SECTION",
184
+ "sectionConfig": {
185
+ "label": "Contact Details",
186
+ "children": [...]
187
+ }
188
+ },
189
+ {
190
+ "type": "GROUP",
191
+ "subType": "SECTION",
192
+ "sectionConfig": {
193
+ "label": "Review & Submit",
194
+ "children": [...]
195
+ }
196
+ }
197
+ ]
198
+ }
199
+ }
200
+ ```
201
+
202
+ | Setting | Behaviour |
203
+ |---------|-----------|
204
+ | `"sectionStepper": true` | Always enables section stepper |
205
+ | `"sectionStepper": false` | Disables section stepper; renders all sections at once in the regular layout |
206
+ | Omitted | Auto-detected when all top-level children are `GROUP` type (one or more) |
207
+
208
+ ### Host-Driven Navigation (Section Stepper `@ViewChild` API)
209
+
210
+ For layouts where the host app renders its **own** Previous/Next/Submit buttons (instead of relying on `actionBarConfig`), grab a reference to `SmartFormComponent` via `@ViewChild` and drive the stepper directly:
211
+
212
+ ```typescript
213
+ import { ViewChild } from '@angular/core';
214
+ import { SmartFormComponent } from 'commons-shared-web-ui';
215
+
216
+ export class MyWizardComponent {
217
+ @ViewChild(SmartFormComponent) smartFormComponent!: SmartFormComponent;
218
+
219
+ onStepChange(info: { currentStep: number; totalSteps: number; isFirst: boolean; isLast: boolean; stepLabel: string }) {
220
+ this.stepInfo = info; // drive your own footer UI from this
221
+ }
222
+
223
+ onNextClicked(): void {
224
+ // isCurrentStepValid() marks the current step's controls as touched and returns
225
+ // false if any required field on THIS step is invalid — navigateToNext() itself
226
+ // never blocks, it always advances (it only records a soft "warning" badge state).
227
+ if (this.smartFormComponent.isCurrentStepValid() === false) {
228
+ return; // field-level error states are now visible; stop here
229
+ }
230
+ this.smartFormComponent.navigateToNext();
231
+ }
232
+ }
233
+ ```
234
+
235
+ ```html
236
+ <lib-smart-form
237
+ [formJson]="formJson"
238
+ (stepChange)="onStepChange($event)">
239
+ </lib-smart-form>
240
+ ```
241
+
242
+ | Member | Type | Description |
243
+ | :--- | :--- | :--- |
244
+ | `navigateToNext()` | method | Advances to the next section step. Marks the step being left with a `valid`/`warning` badge but **always advances** regardless of validity. |
245
+ | `navigateToPrevious()` | method | Goes back to the previous section step. Does not run validation. |
246
+ | `goToSectionStep(index)` | method | Jumps directly to a step by index (e.g. clicking a step nav bubble). Validates the step being left, same as `navigateToNext()`. |
247
+ | `isCurrentStepValid()` | method → `boolean` | **The hard-block guard.** Marks every control in the current step as touched (so field-level errors render) and returns `false` if any required field is invalid. Call this before `navigateToNext()` if your screen must prevent skipping incomplete steps — `navigateToNext()` alone will never do this for you. Returns `true` immediately for non-stepper forms. |
248
+ | `isSectionStepFirst` | getter → `boolean` | `true` when on the first step. |
249
+ | `isSectionStepLast` | getter → `boolean` | `true` when on the last step. For a single-step form (see note above), this and `isSectionStepFirst` are both `true` simultaneously. |
250
+ | `(stepChange)` | `EventEmitter<{ currentStep, totalSteps, isFirst, isLast, stepLabel }>` | Emitted after every step change — use it to sync a custom footer/progress UI. |
251
+
252
+ > **Important:** validation is opt-in at the host level. If you never call `isCurrentStepValid()`, users can freely skip past incomplete required fields by clicking Next — only the step's nav badge shows a warning. This is intentional: some hosts want a soft warning only, others (e.g. multi-step onboarding wizards) want a hard block. Add the `isCurrentStepValid()` check in your own Next handler only if you want the latter.
253
+
254
+ ---
255
+
256
+ ## Field Types
257
+
258
+ ### 1. Text Input (TEXT_INPUT)
259
+
260
+ **SubTypes:** `SHORT`, `LONG`, `EMAIL`, `PHONE`, `PASSWORD`
261
+
262
+ ```json
263
+ {
264
+ "name": "firstName",
265
+ "label": "First Name",
266
+ "type": "TEXT_INPUT",
267
+ "subType": "SHORT",
268
+ "required": true,
269
+ "hint": "Enter your first name",
270
+ "placeholder": "e.g. John",
271
+ "textConfig": {
272
+ "length": { "min": 2, "max": 50 },
273
+ "pattern": "^[A-Za-z ]+$",
274
+ "patternMessage": "Only alphabets and spaces are allowed"
275
+ }
276
+ }
277
+ ```
278
+
279
+ **Password with match validation** (`subType: PASSWORD` + `matchField`):
280
+
281
+ ```json
282
+ {
283
+ "name": "password",
284
+ "label": "Password",
285
+ "type": "TEXT_INPUT",
286
+ "subType": "PASSWORD",
287
+ "required": true,
288
+ "textConfig": { "length": { "min": 8, "max": 64 } }
289
+ },
290
+ {
291
+ "name": "confirmPassword",
292
+ "label": "Confirm Password",
293
+ "type": "TEXT_INPUT",
294
+ "subType": "PASSWORD",
295
+ "required": true,
296
+ "textConfig": { "matchField": "password" }
297
+ }
298
+ ```
299
+
300
+ The `matchField` property tells the field to validate that its value equals the named sibling field. If the values differ, a `passwordMismatch` error is added and a user-friendly message is displayed.
301
+
302
+ ### 2. Number Input (NUMBER_INPUT)
303
+
304
+ **SubTypes:** `INTEGER`, `DECIMAL`
305
+
306
+ ```json
307
+ {
308
+ "name": "age",
309
+ "label": "Age",
310
+ "type": "NUMBER_INPUT",
311
+ "subType": "INTEGER",
312
+ "required": true,
313
+ "numberConfig": { "min": 18, "max": 100, "step": 1 }
314
+ }
315
+ ```
316
+
317
+ ### 3. Date Input (DATE)
318
+
319
+ **SubTypes:** `SINGLE`
320
+
321
+ ```json
322
+ {
323
+ "name": "birthDate",
324
+ "label": "Date of Birth",
325
+ "type": "DATE",
326
+ "subType": "SINGLE",
327
+ "required": true,
328
+ "dateConfig": {
329
+ "allowFuture": false,
330
+ "minDate": "1920-01-01",
331
+ "maxDate": "2010-12-31"
332
+ }
333
+ }
334
+ ```
335
+
336
+ **`dateConfig` properties**
337
+
338
+ | Property | Type | Description |
339
+ |---|---|---|
340
+ | `allowFuture` | `boolean` | When `false`, dates after today are blocked (default: `true`) |
341
+ | `minDate` | `string` | Static minimum date in `YYYY-MM-DD` format |
342
+ | `maxDate` | `string` | Static maximum date in `YYYY-MM-DD` format |
343
+ | `minDateField` | `string` | Name of a sibling field whose current value is used as the dynamic minimum date. When the source field changes, the min date updates reactively. If the current field's value is now before the new minimum, it is automatically cleared. |
344
+ | `inputReadonly` | `boolean` | When `true`, the text input is read-only — the user can only pick a date from the calendar, not type one. Default: `false` |
345
+
346
+ **Dynamic min date (linked to another field)**
347
+
348
+ Use `minDateField` to link the minimum of an end-date picker to a start-date field:
349
+
350
+ ```json
351
+ [
352
+ {
353
+ "name": "startDate",
354
+ "label": "Start Date",
355
+ "type": "DATE",
356
+ "subType": "SINGLE",
357
+ "required": true,
358
+ "dateConfig": { "inputReadonly": true }
359
+ },
360
+ {
361
+ "name": "endDate",
362
+ "label": "End Date",
363
+ "type": "DATE",
364
+ "subType": "SINGLE",
365
+ "required": true,
366
+ "dateConfig": {
367
+ "inputReadonly": true,
368
+ "minDateField": "startDate"
369
+ }
370
+ }
371
+ ]
372
+ ```
373
+
374
+ The End Date picker automatically sets its minimum to whatever value `startDate` holds. If the user later picks an earlier start date, `endDate` is cleared automatically.
375
+
376
+ ### 4. Time Input (TIME)
377
+
378
+ **SubTypes:** `SINGLE`
379
+
380
+ ```json
381
+ {
382
+ "name": "meetingTime",
383
+ "label": "Meeting Time",
384
+ "type": "TIME",
385
+ "subType": "SINGLE",
386
+ "required": true,
387
+ "placeholder": "Select Time"
388
+ }
389
+ ```
390
+
391
+ **`timeConfig` options** (all optional):
392
+
393
+ | Key | Type | Description |
394
+ | --- | --- | --- |
395
+ | `minTime` | string | Explicit minimum time in 24-hour `"HH:mm"` format (e.g. `"09:00"`). |
396
+ | `maxTime` | string | Explicit maximum time in 24-hour `"HH:mm"` format (e.g. `"18:00"`). |
397
+ | `inputReadonly` | boolean | When true, the input is readonly. |
398
+ | `minTimeField` | string | Name of a sibling TIME field whose value is used as the dynamic minimum. When it changes, this field's minimum updates and any now-invalid value (earlier than the new minimum) is cleared. Mirrors `dateConfig.minTimeField`. |
399
+ | `variant` | string | Rendering variant: `'default'` (native picker input, default) or `'wheel'` (custom drum-roll slide picker). |
400
+ | `mode` | string | Hour display mode for `'wheel'` variant: `'12'` (12-hour, AM/PM column, default) or `'24'` (24-hour, no AM/PM). |
401
+ | `minuteStep` | number | Minute column increment step for `'wheel'` variant. Omit (or `1`) for every minute `00–59`; a value greater than `0` adds the break (e.g. `5`, `10`, `15`, `30`). |
402
+ | `placeholder` | string | Overridden placeholder text for the `'wheel'` variant trigger field. |
403
+
404
+ **Start / End time pair** — the end time cannot be earlier than the start time (same pattern as `dateConfig.minDateField`):
405
+
406
+ ```json
407
+ {
408
+ "name": "startTime",
409
+ "label": "Start Time",
410
+ "type": "TIME",
411
+ "required": true,
412
+ "colSpan": 2
413
+ },
414
+ {
415
+ "name": "endTime",
416
+ "label": "End Time",
417
+ "type": "TIME",
418
+ "required": true,
419
+ "colSpan": 2,
420
+ "timeConfig": {
421
+ "minTimeField": "startTime"
422
+ }
423
+ }
424
+ ```
425
+
426
+ **Custom Wheel Time Picker Example** — using the custom drum-roll picker with 12-hour mode and 15-minute increments:
427
+
428
+ ```json
429
+ {
430
+ "name": "preferredSlot",
431
+ "label": "Preferred Meeting Slot",
432
+ "type": "TIME",
433
+ "subType": "SINGLE",
434
+ "required": true,
435
+ "timeConfig": {
436
+ "variant": "wheel",
437
+ "mode": "12",
438
+ "minuteStep": 15,
439
+ "minTime": "09:00",
440
+ "maxTime": "17:00",
441
+ "placeholder": "Choose a 15-minute slot"
442
+ }
443
+ }
444
+ ```
445
+
446
+ > **Note:** `minuteStep` omitted (or `0`/`1`) shows every minute `00–59`; any value greater than `0` adds the step break (e.g. `15` → `00, 15, 30, 45`). The wheel opens as a compact, centered modal.
447
+
448
+ **Styling & Variants (SCSS)**:
449
+ By default, the time picker uses the black/grey theme (Image 2 style). To use a blue accent variant instead, include the theme mixin with overrides inside your global stylesheet or MFE container styles:
450
+
451
+ ```scss
452
+ @use 'commons-shared-web-ui/lib/modules/time-picker/time-picker.theme' as tp;
453
+
454
+ // Default variant (Black/Grey Color Scheme)
455
+ :root {
456
+ @include tp.time-picker-theme();
457
+ }
458
+
459
+ // Blue Accent Variant
460
+ :root {
461
+ @include tp.time-picker-theme((
462
+ accent: #4D89EB,
463
+ accent-light: rgba(77, 137, 235, 0.08),
464
+ accent-border: rgba(77, 137, 235, 0.15),
465
+ btn-confirm-bg: #4D89EB,
466
+ btn-confirm-hover: #3b74d1,
467
+ btn-cancel-bg: transparent,
468
+ btn-cancel-border: #e5e7eb,
469
+ btn-cancel-hover: #e5e7eb
470
+ ));
471
+ }
472
+ ```
473
+
474
+ **Time Picker i18n labels** — the `'wheel'` variant reads these keys from the form-level `[labels]` map (all optional; each falls back to English):
475
+
476
+ | Label key | Applies to | Default |
477
+ | --- | --- | --- |
478
+ | `TIME_PICKER.SELECT_TIME` | Popup title | `Select Time` |
479
+ | `TIME_PICKER.HOUR` | Hour column header | `Hour` |
480
+ | `TIME_PICKER.MINUTE` | Minute column header | `Minute` |
481
+ | `TIME_PICKER.PERIOD` | AM/PM column header | `AM/PM` |
482
+ | `TIME_PICKER.AM` / `TIME_PICKER.PM` | Period values | `AM` / `PM` |
483
+ | `COMMON.ACTIONS.CONFIRM` | Confirm button | `Confirm` |
484
+ | `COMMON.ACTIONS.CANCEL` | Cancel button | `Cancel` |
485
+
486
+ #### Complete Example (TIME wheel field in a Smart Form)
487
+
488
+ A full form schema with a start/end wheel time-picker pair, plus the parent-component wiring and picker i18n labels.
489
+
490
+ ```typescript
491
+ import { Component } from '@angular/core';
492
+
493
+ @Component({
494
+ selector: 'app-booking-form',
495
+ template: `
496
+ <lib-smart-form
497
+ [formJson]="formJson"
498
+ [labels]="labels"
499
+ (submit)="onSubmit($event)">
500
+ </lib-smart-form>
501
+ `
502
+ })
503
+ export class BookingFormComponent {
504
+ formJson = JSON.stringify({
505
+ entityType: 'BOOKING',
506
+ label: 'FORM.BOOKING_TITLE',
507
+ formType: 'SECTION',
508
+ sectionConfig: {
509
+ children: [
510
+ {
511
+ type: 'ROW',
512
+ subType: 'HORIZONTAL',
513
+ children: [
514
+ {
515
+ name: 'startTime',
516
+ label: 'FIELD.START_TIME',
517
+ type: 'TIME',
518
+ subType: 'SINGLE',
519
+ required: true,
520
+ colSpan: 6,
521
+ timeConfig: {
522
+ variant: 'wheel',
523
+ mode: '12',
524
+ minuteStep: 15,
525
+ minTime: '09:00',
526
+ maxTime: '18:00'
527
+ }
528
+ },
529
+ {
530
+ name: 'endTime',
531
+ label: 'FIELD.END_TIME',
532
+ type: 'TIME',
533
+ subType: 'SINGLE',
534
+ required: true,
535
+ colSpan: 6,
536
+ timeConfig: {
537
+ variant: 'wheel',
538
+ mode: '12',
539
+ minuteStep: 15,
540
+ minTimeField: 'startTime' // end cannot precede start
541
+ }
542
+ }
543
+ ]
544
+ }
545
+ ]
546
+ },
547
+ submitConfig: {
548
+ apiUrl: 'https://api.example.com/bookings',
549
+ method: 'POST',
550
+ successMessage: 'Booking created!'
551
+ }
552
+ });
553
+
554
+ labels = {
555
+ 'FORM.BOOKING_TITLE': 'New Booking',
556
+ 'FIELD.START_TIME': 'Start Time',
557
+ 'FIELD.END_TIME': 'End Time',
558
+ // Time picker popup i18n
559
+ 'TIME_PICKER.SELECT_TIME': 'Pick a time',
560
+ 'TIME_PICKER.HOUR': 'Hour',
561
+ 'TIME_PICKER.MINUTE': 'Min',
562
+ 'TIME_PICKER.PERIOD': 'AM/PM',
563
+ 'COMMON.ACTIONS.CONFIRM': 'Confirm',
564
+ 'COMMON.ACTIONS.CANCEL': 'Cancel'
565
+ };
566
+
567
+ onSubmit(payload: any): void {
568
+ // { startTime: "09:15 AM", endTime: "10:00 AM" }
569
+ console.log('Booking:', payload);
570
+ }
571
+ }
572
+ ```
573
+
574
+ ### 5. Autocomplete (AUTOCOMPLETE)
575
+
576
+ A searchable input backed by Angular Material's `mat-autocomplete`. As the user types, the option list is filtered by label or code. The form control stores the **code** value, while the input shows the human-readable **label**.
577
+
578
+ Autocomplete fields now use a dedicated `autocompleteConfig` for specialized behavior, while still using `optionConfig` for core API/data settings.
579
+
580
+ #### Basic Usage (Local Filtering)
581
+
582
+ ```json
583
+ {
584
+ "name": "country",
585
+ "label": "Country",
586
+ "type": "AUTOCOMPLETE",
587
+ "subType": "SINGLE",
588
+ "optionConfig": {
589
+ "optionList": [
590
+ { "label": "India", "code": "IN" },
591
+ { "label": "USA", "code": "US" }
592
+ ]
593
+ }
594
+ }
595
+ ```
596
+
597
+ #### Advanced Usage (Server-side Search & Rich Display)
598
+
599
+ For large datasets, use `autocompleteConfig` to trigger server-side filtering and display rich metadata (emails, phones, avatars) in the dropdown options.
600
+
601
+ ```json
602
+ {
603
+ "name": "responsiblePerson",
604
+ "label": "Responsible Person",
605
+ "type": "AUTOCOMPLETE",
606
+ "optionConfig": {
607
+ "apiUrl": "gateway/search-service/api/v1/users",
608
+ "dataPath": "elements",
609
+ "labelPath": "displayName",
610
+ "valuePath": "userId"
611
+ },
612
+ "autocompleteConfig": {
613
+ "method": "POST",
614
+ "body": [],
615
+ "searchParam": "searchTerm",
616
+ "searchMinLength": 2,
617
+ "displayFields": [
618
+ { "path": "photoUrl", "type": "image" },
619
+ { "path": "login", "type": "email", "label": "Email: " },
620
+ { "path": "phone", "type": "phone" }
621
+ ]
622
+ }
623
+ }
624
+ ```
625
+
626
+ #### Autocomplete Configuration (`autocompleteConfig`)
627
+
628
+ | Property | Type | Description |
629
+ | :--- | :--- | :--- |
630
+ | `method` | `'GET' \| 'POST' \| 'PUT' \| 'PATCH'` | HTTP method for the search API (Default: `GET`). |
631
+ | `body` | `any` | Static request body for `POST`/`PUT`/`PATCH` requests. |
632
+ | `labelTemplate` | `string` | Template string for composite labels, e.g., `"{firstName} {lastName} ({empId})"`. |
633
+ | `displayFields` | `string \| DisplayField[]` | Extra fields to show below the label. See [Rich Display Fields](#rich-display-fields). |
634
+ | `searchParam` | `string` | Query parameter key sent to the API as the user types (e.g., `"q"` or `"searchTerm"`). |
635
+ | `searchMinLength`| `number` | Minimum characters to type before firing an API request (Default: `1`). |
636
+ | `searchDebounce` | `number` | Delay in ms before firing the search request (Default: `300ms`). |
637
+
638
+ #### Rich Display Fields
639
+
640
+ The `displayFields` property allows you to show extra information in the dropdown. Each field is rendered with an appropriate icon and style.
641
+
642
+ | Type | Rendering |
643
+ | :--- | :--- |
644
+ | `text` | Plain secondary text (Default). |
645
+ | `email` | Rendered with an envelope icon in a pill-style chip. |
646
+ | `phone` | Rendered with a phone icon in a pill-style chip. |
647
+ | `image` | Rendered as a small circular avatar/thumbnail. |
648
+
649
+ #### Autocomplete Behaviour
650
+
651
+ | Feature | Detail |
652
+ | :--- | :--- |
653
+ | **Debouncing** | Automatically waits for the user to stop typing before calling the API. |
654
+ | **Syncing** | If the form is patched with a `code`, the component automatically fetches or resolves the `label` for display. |
655
+ | **Edge Case Handling** | If a user types an invalid value and blurs, the input reverts to the last valid selection. |
656
+ | **Clear Button** | A built-in "X" button allows users to reset the field instantly. |
657
+
658
+ ### 4. Dropdown (DROPDOWN)
659
+
660
+ **SubTypes:** `SINGLE`, `MULTIPLE`
661
+
662
+ **Static options:**
663
+
664
+ ```json
665
+ {
666
+ "name": "country",
667
+ "label": "Country",
668
+ "type": "DROPDOWN",
669
+ "subType": "SINGLE",
670
+ "required": true,
671
+ "optionConfig": {
672
+ "optionList": [
673
+ { "label": "USA", "code": "US" },
674
+ { "label": "Canada", "code": "CA" }
675
+ ]
676
+ }
677
+ }
678
+ ```
679
+
680
+ **Load from API** (supports nested data paths):
681
+
682
+ ```json
683
+ {
684
+ "name": "department",
685
+ "label": "Department",
686
+ "type": "DROPDOWN",
687
+ "subType": "SINGLE",
688
+ "optionConfig": {
689
+ "apiUrl": "https://api.example.com/departments",
690
+ "dataPath": "data.items",
691
+ "labelPath": "profile.name",
692
+ "valuePath": "meta.id"
693
+ }
694
+ }
695
+ ```
696
+
697
+ **Dependent Dropdown (Cascading Select):**
698
+
699
+ ```json
700
+ {
701
+ "name": "state",
702
+ "label": "State",
703
+ "type": "DROPDOWN",
704
+ "subType": "SINGLE",
705
+ "optionConfig": {
706
+ "apiUrl": "https://api.example.com/states",
707
+ "valuePath": "code"
708
+ }
709
+ },
710
+ {
711
+ "name": "district",
712
+ "label": "District",
713
+ "type": "DROPDOWN",
714
+ "subType": "SINGLE",
715
+ "optionConfig": {
716
+ "apiUrl": "https://api.example.com/districts",
717
+ "dependencies": {
718
+ "stateCode": "state"
719
+ }
720
+ }
721
+ }
722
+ ```
723
+
724
+ `dependencies` maps API query-param keys to other field names. The parent field's current value is automatically appended to the API URL.
725
+
726
+ **Merge Multiple APIs:**
727
+
728
+ ```json
729
+ {
730
+ "name": "region",
731
+ "label": "Region",
732
+ "type": "DROPDOWN",
733
+ "subType": "SINGLE",
734
+ "optionConfig": {
735
+ "apiUrls": [
736
+ "https://api.example.com/states",
737
+ "https://api.example.com/union-territories"
738
+ ],
739
+ "valuePath": "code",
740
+ "labelPath": "name"
741
+ }
742
+ }
743
+ ```
744
+
745
+ **Sort Options:**
746
+
747
+ ```json
748
+ {
749
+ "name": "country",
750
+ "label": "Select Country",
751
+ "type": "DROPDOWN",
752
+ "subType": "SINGLE",
753
+ "optionConfig": {
754
+ "apiUrl": "https://api.example.com/countries",
755
+ "valuePath": "code",
756
+ "labelPath": "name.common",
757
+ "sortBy": "name.common",
758
+ "sortDirection": "ASC"
759
+ }
760
+ }
761
+ ```
762
+
763
+ **Searchable Dropdown (Local Filtering):**
764
+
765
+ Add a search input inside the dropdown panel to filter options client-side. Works with both `SINGLE` and `MULTIPLE` subtypes.
766
+
767
+ ```json
768
+ {
769
+ "name": "country",
770
+ "label": "Select Country",
771
+ "type": "DROPDOWN",
772
+ "subType": "SINGLE",
773
+ "optionConfig": {
774
+ "apiUrl": "https://api.example.com/countries",
775
+ "valuePath": "code",
776
+ "labelPath": "name",
777
+ "searchConfig": {
778
+ "enabled": true
779
+ }
780
+ }
781
+ }
782
+ ```
783
+
784
+ **Searchable Dropdown (Server-side Filtering via GET):**
785
+
786
+ For large datasets, configure the dropdown to query the API as the user types. The search term is appended as a query parameter to the existing API URL.
787
+
788
+ ```json
789
+ {
790
+ "name": "academicSubject",
791
+ "label": "Academic Subject",
792
+ "type": "DROPDOWN",
793
+ "subType": "MULTIPLE",
794
+ "optionConfig": {
795
+ "apiUrl": "https://api.example.com/subjects",
796
+ "dataPath": "elements",
797
+ "labelPath": "name",
798
+ "valuePath": "code",
799
+ "searchConfig": {
800
+ "enabled": true,
801
+ "mode": "server",
802
+ "searchKey": "searchTerm",
803
+ "minSearchLength": 3,
804
+ "debounceTime": 400
805
+ }
806
+ }
807
+ }
808
+ ```
809
+
810
+ **Selected Option Label Persistence (Server-side Search):**
811
+
812
+ When using `mode: "server"`, the dropdown only displays options fetched from the API (such as the first page of results or matching search results). If a form is loaded in `EDIT` mode, the selected value might not be in the initial page of options, causing the field to appear blank in the UI.
813
+
814
+ To prevent this, you can pass the selected options' metadata (label, code, details) to `<lib-smart-form>` using the `selectedOptionsData` input property. This caches the selected item details and ensures they are merged into the dropdown's option list even after searches or paginated listings are fetched.
815
+
816
+ #### Example MFE Integration
817
+
818
+ ##### 1. Form Schema Config (JSON)
819
+ ```json
820
+ {
821
+ "name": "academicSubject",
822
+ "label": "Academic Subject",
823
+ "type": "DROPDOWN",
824
+ "subType": "SINGLE",
825
+ "optionConfig": {
826
+ "apiUrl": "https://api.example.com/subjects",
827
+ "valuePath": "id",
828
+ "labelPath": "name",
829
+ "searchConfig": {
830
+ "enabled": true,
831
+ "mode": "server",
832
+ "searchKey": "q"
833
+ }
834
+ }
835
+ }
836
+ ```
837
+
838
+ ##### 2. MFE Parent Component Markup
839
+ ```html
840
+ <lib-smart-form
841
+ [formJson]="formSchema"
842
+ [initialValues]="formInitialValues"
843
+ [selectedOptionsData]="selectedOptionsData"
844
+ [mode]="'EDIT'"
845
+ (submit)="onSubmit($event)">
846
+ </lib-smart-form>
847
+ ```
848
+
849
+ ##### 3. MFE Parent Component Controller (TypeScript)
850
+ ```typescript
851
+ import { Component, OnInit } from '@angular/core';
852
+
853
+ @Component({
854
+ selector: 'app-subject-edit',
855
+ templateUrl: './subject-edit.component.html'
856
+ })
857
+ export class SubjectEditComponent implements OnInit {
858
+ formSchema = `...`; // Schema JSON from Step 1
859
+
860
+ // 1. Keep initialValues flat with primitive codes/IDs
861
+ formInitialValues = {
862
+ academicSubject: 8
863
+ };
864
+
865
+ // 2. Provide the full metadata for the selected options so the form can display the label
866
+ selectedOptionsData = {
867
+ // For single select: pass a single object
868
+ academicSubject: {
869
+ id: 8,
870
+ name: "Chemistry"
871
+ }
872
+ // For multi-select: pass an array of objects
873
+ // academicSubjects: [
874
+ // { id: 8, name: "Chemistry" },
875
+ // { id: 10, name: "Mathematics" }
876
+ // ]
877
+ };
878
+
879
+ onSubmit(payload: any) {
880
+ // Submits the standard flat form payload containing raw codes:
881
+ // payload: { academicSubject: 8 }
882
+ console.log('Form Submitted:', payload);
883
+ }
884
+ }
885
+ ```
886
+
887
+ **Select All (Multi-Select Only):**
888
+
889
+ For `MULTIPLE` dropdowns, add a "Select All" checkbox at the top of the option list. Can be combined with `searchConfig` — when a search filter is active, "Select All" toggles only the visible (filtered) options.
890
+
891
+ ```json
892
+ {
893
+ "name": "skills",
894
+ "label": "Skills",
895
+ "type": "DROPDOWN",
896
+ "subType": "MULTIPLE",
897
+ "optionConfig": {
898
+ "optionList": [
899
+ { "label": "JavaScript", "code": "JS" },
900
+ { "label": "Python", "code": "PY" },
901
+ { "label": "Java", "code": "JAVA" },
902
+ { "label": "Go", "code": "GO" }
903
+ ],
904
+ "showSelectAll": true,
905
+ "searchConfig": {
906
+ "enabled": true
907
+ }
908
+ }
909
+ }
910
+ ```
911
+
912
+ #### Dropdown Search Configuration (`searchConfig`)
913
+
914
+ | Property | Type | Default | Description |
915
+ | :--- | :--- | :--- | :--- |
916
+ | `enabled` | `boolean` | — | **Required.** Displays a search input inside the dropdown panel. |
917
+ | `mode` | `'local' \| 'server'` | `'local'` | `local`: filters client-side. `server`: queries the API on typing via GET. |
918
+ | `searchKey` | `string` | `'search'` | Query parameter key for the search term sent to the API. Only used in `server` mode. |
919
+ | `minSearchLength` | `number` | `3` | Minimum characters required before triggering a server-side search. Only used in `server` mode. |
920
+ | `debounceTime` | `number` | `300` | Debounce delay in milliseconds before firing the search. |
921
+
922
+ #### Select All Configuration
923
+
924
+ | Property | Type | Default | Description |
925
+ | :--- | :--- | :--- | :--- |
926
+ | `showSelectAll` | `boolean` | `false` | Renders a "Select All" checkbox at the top of a `MULTIPLE` select dropdown. |
927
+
928
+ #### i18n Labels for Search & Select All
929
+
930
+ The following label keys can be provided via the `labels` input to customise the UI text:
931
+
932
+ | Key | Default | Description |
933
+ | :--- | :--- | :--- |
934
+ | `SEARCH_PLACEHOLDER` | `Search...` | Placeholder text for the search input. |
935
+ | `SELECT_ALL` | `Select All` | Label for the Select All checkbox. |
936
+ | `NO_MATCHING_OPTIONS` | `No options match your search` | Shown when the search filter yields no results. |
937
+
938
+ ### 5. Radio Button (RADIO)
939
+
940
+ ```json
941
+ {
942
+ "name": "gender",
943
+ "label": "Gender",
944
+ "type": "RADIO",
945
+ "subType": "SINGLE",
946
+ "required": true,
947
+ "optionConfig": {
948
+ "optionList": [
949
+ { "label": "Male", "code": "M" },
950
+ { "label": "Female", "code": "F" }
951
+ ]
952
+ }
953
+ }
954
+ ```
955
+
956
+ ### 6. Checkbox (CHECKBOX)
957
+
958
+ **SubTypes:** `BOOL`, `LIST`
959
+
960
+ ```json
961
+ {
962
+ "name": "agreeToTerms",
963
+ "label": "I agree to terms",
964
+ "type": "CHECKBOX",
965
+ "subType": "BOOL",
966
+ "required": true
967
+ }
968
+ ```
969
+
970
+ ### 7. Chip Selection (CHIP)
971
+
972
+ ```json
973
+ {
974
+ "name": "skills",
975
+ "label": "Skills",
976
+ "type": "CHIP",
977
+ "subType": "MULTIPLE",
978
+ "optionConfig": {
979
+ "optionList": [
980
+ { "label": "JavaScript", "code": "JS" },
981
+ { "label": "Python", "code": "PY" }
982
+ ]
983
+ }
984
+ }
985
+ ```
986
+
987
+ ### 8. Switch (SWITCH)
988
+
989
+ ```json
990
+ {
991
+ "name": "notifications",
992
+ "label": "Enable Notifications",
993
+ "type": "SWITCH",
994
+ "subType": "BOOL",
995
+ "defaultValue": true
996
+ }
997
+ ```
998
+
999
+ ### 9. Rating (RATING)
1000
+
1001
+ ```json
1002
+ {
1003
+ "name": "rating",
1004
+ "label": "Rate your experience",
1005
+ "type": "RATING",
1006
+ "subType": "STAR",
1007
+ "ratingConfig": {
1008
+ "maxRating": 5,
1009
+ "allowHalf": true
1010
+ }
1011
+ }
1012
+ ```
1013
+
1014
+ ### 10. File Upload (FILE_UPLOAD)
1015
+
1016
+ Provides a drag-and-drop area with file-type and file-size validation. The field value is an array of `UploadedFile` objects. This field uses a unified `attachmentConfig` for all upload types (PDF, Images, Documents, etc.).
1017
+
1018
+ **SubTypes:** `SINGLE`
1019
+
1020
+ ```json
1021
+ {
1022
+ "name": "profilePicture",
1023
+ "label": "Profile Picture",
1024
+ "type": "FILE_UPLOAD",
1025
+ "subType": "SINGLE",
1026
+ "attachmentConfig": {
1027
+ "multiple": false,
1028
+ "maxSizeMB": 2,
1029
+ "accept": "image/*",
1030
+ "acceptLabel": "JPG, PNG, SVG (max 2 MB)"
1031
+ }
1032
+ }
1033
+ ```
1034
+
1035
+ | `attachmentConfig` key | Type | Description |
1036
+ | ---------------------- | ------- | ------------------------------------------------------------ |
1037
+ | `multiple` | boolean | Allow multiple file selection (default: `false`) |
1038
+ | `maxFiles` | number | Max number of files when `multiple: true` (default: `10`) |
1039
+ | `maxSizeMB` | number | Max file size per file in MB (default: `10`) |
1040
+ | `accept` | string | Accepted MIME types / extensions, e.g. `".pdf,.jpg,image/*"` |
1041
+ | `acceptLabel` | string | Human-readable hint shown in the drop zone |
1042
+
1043
+ ### 11. Generated Field (GENERATED)
1044
+
1045
+ Auto-calculated fields that update whenever dependent field values change.
1046
+
1047
+ ```json
1048
+ {
1049
+ "name": "fullName",
1050
+ "label": "Full Name",
1051
+ "type": "GENERATED",
1052
+ "subType": "FORMULA",
1053
+ "generatedConfig": {
1054
+ "formula": "function fullName(first, last) { return (first || '') + ' ' + (last || ''); }",
1055
+ "variables": ["firstName", "lastName"]
1056
+ }
1057
+ }
1058
+ ```
1059
+
1060
+ ### 12. Geography Dynamic (GEOGRAPHY_DYNAMIC)
1061
+
1062
+ Renders a cascading hierarchy of geography dropdowns (e.g. Country → State → District) by fetching a hierarchy template from an MDM API. When the hierarchy has a **branch point** (e.g. State → RURAL | URABN), an **Area Type** selector is automatically inserted so the user can choose which path to follow.
1063
+
1064
+ **Branch point behavior**
1065
+
1066
+ - The Area Type dropdown is generated automatically from the branch children (e.g. "Rural" / "Urban").
1067
+ - Selecting a branch value shows only the dropdowns belonging to that path (District, Taluka, Village …).
1068
+ - Structural branch-type nodes (RURAL, URABN) are **not** rendered as data dropdowns — only their descendants are. The first descendant depends on the last linear parent before the fork (e.g. State), not on the branch node itself.
1069
+ - If the form is pre-populated with an `areaType` value (edit mode), the downstream dropdowns are visible immediately.
1070
+
1071
+ ```json
1072
+ {
1073
+ "name": "address",
1074
+ "label": "Address",
1075
+ "type": "GEOGRAPHY_DYNAMIC",
1076
+ "geographyConfig": {
1077
+ "templateApi": {
1078
+ "apiUrl": "https://api.example.com/mdm/hierarchy-templates",
1079
+ "listPath": "templates",
1080
+ "select": "byCode",
1081
+ "selectCode": "ADDRESS_TEMPLATE"
1082
+ },
1083
+ "dataApi": {
1084
+ "apiUrl": "https://api.example.com/mdm/data/{classCode}",
1085
+ "dataPath": "elements",
1086
+ "labelPath": "name[0].text",
1087
+ "valuePath": "code"
1088
+ },
1089
+ "structure": {
1090
+ "rootCodePath": "rootClassCode",
1091
+ "hierarchyListPath": "mdmclasshierarchytemplatestructList",
1092
+ "parentField": "parentCode",
1093
+ "childField": "childCode"
1094
+ },
1095
+ "field": {
1096
+ "colSpan": 4,
1097
+ "payloadPathPrefix": "addressInfo",
1098
+ "branchSubType": "SINGLE",
1099
+ "dependency": {
1100
+ "paramName": "parentDataCode"
1101
+ },
1102
+ "nodes": {
1103
+ "REGION.COUNTRY": { "label": "Country", "required": true },
1104
+ "REGION.STATE": { "label": "State", "payloadField": "stateCode" }
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+ ```
1110
+
1111
+ **`field` configuration keys**
1112
+
1113
+ | Key | Type | Default | Description |
1114
+ |---|---|---|---|
1115
+ | `colSpan` | `number` | `12` | Column span applied to every generated dropdown |
1116
+ | `payloadPathPrefix` | `string` | `''` | Dot-notation prefix prepended to all generated `payloadPath` values |
1117
+ | `branchSubType` | `'SINGLE' \| 'MULTIPLE'` | `'SINGLE'` | Sub-type for the auto-generated Area Type selector |
1118
+ | `dependency.paramName` | `string` | `'parentDataCode'` | Query parameter name sent when loading child data |
1119
+ | `nodes` | `Record<string, object>` | `{}` | Per-node overrides keyed by class code — supports `label`, `name`, `payloadField`, `required`, `placeholder`, `hidden`, `noDependency` |
1120
+
1121
+ ### 13. Rich Text Editor (RICH_TEXT)
1122
+
1123
+ Provides a WYSIWYG rich text editor using Quill.
1124
+
1125
+ ```json
1126
+ {
1127
+ "name": "description",
1128
+ "label": "Detailed Description",
1129
+ "type": "RICH_TEXT",
1130
+ "required": true,
1131
+ "richTextConfig": {
1132
+ "placeholder": "Enter detailed information here...",
1133
+ "height": "250px",
1134
+ "headerConfig": ["bold", "italic", "underline", "font", "size", "color", "link", "image", "video"]
1135
+ }
1136
+ }
1137
+ ```
1138
+
1139
+ `headerConfig` controls which toolbar buttons are shown, in order. If omitted, it defaults to:
1140
+ `["bold", "italic", "underline", "font", "size", "color", "link", "image", "video"]`.
1141
+
1142
+ Supported tokens: `bold`, `italic`, `underline`, `strike`, `blockquote`, `code`, `font`, `size`, `color`, `background`, `align`, `header1`, `header2`, `orderedList`, `bulletList`, `subscript`, `superscript`, `indentMinus`, `indentPlus`, `link`, `image`, `video`, `clean`.
1143
+
1144
+ ### 14. Link List (LINK_LIST)
1145
+
1146
+ Allows users to manage a list of URLs dynamically. Provides a text input box with a trailing plus icon to add links, displaying them as a list above or below the input field.
1147
+
1148
+ **Configuration Properties (`linkListConfig`):**
1149
+
1150
+ | Property | Type | Description |
1151
+ |---|---|---|
1152
+ | `listPosition` | `'top' \| 'bottom'` | Renders the link list above or below the input field (default: `'bottom'`). |
1153
+ | `editable` | `boolean` | Allows inline editing of existing links in the list (default: `true`). |
1154
+ | `deleteable` | `boolean` | Shows a delete action button on list items (default: `true`). |
1155
+ | `valueFormat` | `'string' \| 'array' \| 'object'` | Format in which data is stored in the form control: `'string'` (separated by `separator`), `'array'` (array of strings), or `'object'` (array of objects) (default: `'string'`). |
1156
+ | `separator` | `string` | Character used to separate links when `valueFormat` is `'string'` (default: `','`). |
1157
+ | `urlKey` | `string` | The object key used to store/load the link URL when `valueFormat` is `'object'` (default: `'linkUrl'`). |
1158
+ | `idField` | `string` | The object key representing the link identifier when resolving API placeholders (default: `'id'`). |
1159
+ | `deleteApiUrl` | `string` | Optional API endpoint to execute an HTTP DELETE call upon removing a saved item (e.g. `/api/v1/links/:id`). |
1160
+ | `editApiUrl` | `string` | Optional API endpoint to execute an HTTP PUT call upon editing a saved item (e.g. `/api/v1/links/:id`). |
1161
+ | `pattern` | `string` | Regular expression pattern for validating each link (default URL validator regex: `^https?://([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,}(/\S*)?$`). |
1162
+ | `patternMessage` | `string` | Custom error message displayed if pattern validation fails. |
1163
+ | `colSpan` | `number` | Grid column span (1-12) for each list item in the 12-column grid. E.g., `6` for two columns side-by-side (default: `12`). |
1164
+
1165
+ **Example Config (Storing as an Array of Objects):**
1166
+
1167
+ ```json
1168
+ {
1169
+ "name": "externalLinks",
1170
+ "label": "External Links",
1171
+ "type": "LINK_LIST",
1172
+ "placeholder": "Enter link...",
1173
+ "colSpan": 12,
1174
+ "linkListConfig": {
1175
+ "listPosition": "bottom",
1176
+ "editable": true,
1177
+ "deleteable": true,
1178
+ "valueFormat": "object",
1179
+ "urlKey": "linkUrl"
1180
+ }
1181
+ }
1182
+ ```
1183
+
1184
+ **Example Config (Storing as a Comma-Separated String):**
1185
+
1186
+ ```json
1187
+ {
1188
+ "name": "externalLinks",
1189
+ "label": "External Links",
1190
+ "type": "LINK_LIST",
1191
+ "placeholder": "Enter link...",
1192
+ "colSpan": 12,
1193
+ "linkListConfig": {
1194
+ "listPosition": "top",
1195
+ "editable": true,
1196
+ "deleteable": true,
1197
+ "valueFormat": "string",
1198
+ "separator": ","
1199
+ }
1200
+ }
1201
+ ```
1202
+
1203
+ **Example Config (Two-Column Layout with Regex Validation):**
1204
+
1205
+ ```json
1206
+ {
1207
+ "name": "externalLinks",
1208
+ "label": "External Links",
1209
+ "type": "LINK_LIST",
1210
+ "placeholder": "Enter link...",
1211
+ "colSpan": 12,
1212
+ "linkListConfig": {
1213
+ "listPosition": "bottom",
1214
+ "editable": true,
1215
+ "deleteable": true,
1216
+ "valueFormat": "object",
1217
+ "urlKey": "linkUrl",
1218
+ "colSpan": 6,
1219
+ "pattern": "^https?://([a-zA-Z0-9\\-]+\\.)+com(/\\S*)?$",
1220
+ "patternMessage": "Only .com domain links are allowed"
1221
+ }
1222
+ }
1223
+ ```
1224
+
1225
+ ---
1226
+
1227
+ ## Layout System
1228
+
1229
+ ### ROW Layout
1230
+
1231
+ Use `type: "ROW"` to place multiple fields horizontally in a 12-column CSS grid. Each child can declare a `colSpan` (1–12). If omitted, the available columns are divided equally among all children.
1232
+
1233
+ ```json
1234
+ {
1235
+ "type": "ROW",
1236
+ "subType": "HORIZONTAL",
1237
+ "children": [
1238
+ {
1239
+ "name": "firstName",
1240
+ "label": "First Name",
1241
+ "type": "TEXT_INPUT",
1242
+ "subType": "SHORT",
1243
+ "colSpan": 6
1244
+ },
1245
+ {
1246
+ "name": "lastName",
1247
+ "label": "Last Name",
1248
+ "type": "TEXT_INPUT",
1249
+ "subType": "SHORT",
1250
+ "colSpan": 6
1251
+ }
1252
+ ]
1253
+ }
1254
+ ```
1255
+
1256
+ ### `colSpan` on Section-level Fields
1257
+
1258
+ A non-ROW field that is a direct child of a section can also carry a `colSpan` to participate in the section-level 12-column grid:
1259
+
1260
+ ```json
1261
+ {
1262
+ "name": "description",
1263
+ "label": "Description",
1264
+ "type": "TEXT_INPUT",
1265
+ "subType": "LONG",
1266
+ "colSpan": 8
1267
+ }
1268
+ ```
1269
+
1270
+ ### `colSpan` Reference
1271
+
1272
+ | `colSpan` value | Effective width |
1273
+ | --------------- | --------------- |
1274
+ | 3 | 25% |
1275
+ | 4 | 33% |
1276
+ | 6 | 50% |
1277
+ | 8 | 67% |
1278
+ | 9 | 75% |
1279
+ | 12 (default) | 100% |
1280
+
1281
+ ---
1282
+
1283
+ ## Configuration Options
1284
+
1285
+ ### Form Schema
1286
+
1287
+ ```typescript
1288
+ interface FormSchema {
1289
+ entityType: string;
1290
+ label: string; // Can be an i18n key
1291
+ formType: "SECTION" | "STEPPER";
1292
+ showTitle?: boolean;
1293
+ showDescription?: boolean;
1294
+ description?: string; // Can be an i18n key
1295
+ metadata?: { [key: string]: any };
1296
+ sectionConfig?: SectionConfig;
1297
+ stepperConfig?: StepperConfig;
1298
+ submitConfig?: SubmitConfig;
1299
+ editConfig?: EditConfig; // Config for form editing (GET to load, PATCH/PUT to submit)
1300
+ actionBarConfig?: ActionBarConfig; // Flexible action bar (Cancel / Draft / Submit)
1301
+ showActions?: boolean;
1302
+ token?: string; // Full auth token (e.g. "Bearer eyJ…") — applied to all API calls
1303
+ tokenHeader?: string; // HTTP header name (default: "Authorization")
1304
+ }
1305
+ ```
1306
+
1307
+ ### Action Bar Config
1308
+
1309
+ The `actionBarConfig` defines the buttons rendered at the bottom of the form. It uses a **unified, flexible list of buttons** where each button has its own visual style and behavior-driven action.
1310
+
1311
+ #### Unified Button Model
1312
+
1313
+ In the new model, a button is **only visual** (label, variant, alignment, order). All logic (what happens when clicked) is delegated to an `action` object of type `ActionConfig`.
1314
+
1315
+ | Action `kind` | Behaviour |
1316
+ |---------------|-----------|
1317
+ | `'submit'` | Validates the form and calls the central `submitConfig` or `editConfig` API. |
1318
+ | `'draft'` | Saves the form data without full validation. Merges `extraPayload` if provided. |
1319
+ | `'navigate'` | Simply navigates to the `redirectUrl`. No API call. |
1320
+ | `'api'` | Fires a standalone API call (`apiUrl`, `method`), then optionally navigates. |
1321
+ | `'emit'` | Emits the `actionClick` output event with the button `id` and form data. |
1322
+ | `'next'` | Advances to the next step (Stepper forms only). |
1323
+ | `'prev'` | Goes back to the previous step (Stepper forms only). |
1324
+
1325
+ #### Interfaces
1326
+
1327
+ ```typescript
1328
+ interface ActionBarConfig {
1329
+ /** Explicitly ordered list of action buttons. */
1330
+ buttons: ActionButtonConfig[];
1331
+ }
1332
+
1333
+ interface ActionButtonConfig {
1334
+ id: string; // Unique identifier for the button
1335
+ label?: string; // i18n key or plain text
1336
+ variant?: string; // lib-button variant (primary, outline, etc.)
1337
+ alignment?: 'left'|'right'; // Which side of the bar to place the button (default: 'right')
1338
+ order?: number; // Display order within the alignment group
1339
+ hidden?: boolean; // Hide the button
1340
+ disabled?: boolean; // Disable the button
1341
+ showOnLastStepOnly?: boolean; // Section Stepper only: show this button only on the last step
1342
+ action: ActionConfig; // The behavior triggered on click
1343
+ }
1344
+
1345
+ interface ActionConfig {
1346
+ kind: 'submit' | 'draft' | 'navigate' | 'api' | 'emit' | 'next' | 'prev';
1347
+ redirectUrl?: string; // Used by 'navigate', 'api', 'draft', and 'submit'
1348
+ apiUrl?: string; // Required for 'api' kind
1349
+ method?: string; // HTTP method for 'api' actions (default: 'POST')
1350
+ extraPayload?: object; // Static payload for 'api' or 'draft' saves
1351
+ successMessage?: string; // Custom success snackbar message
1352
+ errorMessage?: string; // Custom error snackbar message
1353
+ snackbarConfig?: object; // Snackbar display options
1354
+ }
1355
+ ```
1356
+
1357
+ #### Example — Standard Cancel, Draft, and Submit
1358
+
1359
+ This configuration places a "Cancel" button on the left that navigates away, and "Save as Draft" + "Submit" buttons on the right.
1360
+
1361
+ ```json
1362
+ {
1363
+ "actionBarConfig": {
1364
+ "buttons": [
1365
+ {
1366
+ "id": "cancel",
1367
+ "label": "Cancel",
1368
+ "variant": "outline",
1369
+ "alignment": "left",
1370
+ "action": { "kind": "navigate", "redirectUrl": "/dashboard" }
1371
+ },
1372
+ {
1373
+ "id": "draft",
1374
+ "label": "Save as Draft",
1375
+ "variant": "secondary",
1376
+ "alignment": "right",
1377
+ "action": { "kind": "draft", "extraPayload": { "status": "DRAFT" } }
1378
+ },
1379
+ {
1380
+ "id": "submit",
1381
+ "label": "Submit",
1382
+ "variant": "primary",
1383
+ "alignment": "right",
1384
+ "action": { "kind": "submit" }
1385
+ }
1386
+ ]
1387
+ }
1388
+ }
1389
+ ```
1390
+
1391
+ #### Example — Stepper with Back/Next and a Custom Finish Button
1392
+
1393
+ ```json
1394
+ {
1395
+ "actionBarConfig": {
1396
+ "buttons": [
1397
+ {
1398
+ "id": "back",
1399
+ "label": "Back",
1400
+ "alignment": "left",
1401
+ "action": { "kind": "prev" }
1402
+ },
1403
+ {
1404
+ "id": "save-and-exit",
1405
+ "label": "Save & Exit",
1406
+ "alignment": "right",
1407
+ "variant": "outline",
1408
+ "action": { "kind": "api", "apiUrl": "/api/v1/sessions/save-progress" }
1409
+ },
1410
+ {
1411
+ "id": "next",
1412
+ "label": "Next Step",
1413
+ "alignment": "right",
1414
+ "variant": "primary",
1415
+ "action": { "kind": "submit" }
1416
+ }
1417
+ ]
1418
+ }
1419
+ }
1420
+ ```
1421
+
1422
+ #### Notes
1423
+
1424
+ - **Alignment**: Buttons with `alignment: 'left'` are grouped on the left side. `alignment: 'right'` (the default) are on the right. Both groups use `flexbox` for layout, pushing them to opposite edges of the form.
1425
+ - **Ordering**: Within each side, buttons are sorted by the `order` property (numeric, ascending). If `order` is omitted, they appear in the order defined in the JSON array.
1426
+ - **Custom Actions**: Use `kind: 'emit'` to handle logic in your parent component. Whenever clicked, the `<lib-smart-form>` will emit an `(actionClick)` event containing the button's `id` and the current form data.
1427
+ - **Draft Behavior**: Just like the legacy mode, `'kind': 'draft'` skips required field validation and collects whatever data is currently in the form.
1428
+ - **`showOnLastStepOnly`**: When `true` and the form is in **Section Stepper** mode, the button is hidden on all intermediate steps and only appears on the last step. Has no effect in regular (non-stepper) layouts — the button always shows there. Ideal for Submit buttons that should not be reachable until the user has navigated through all steps.
1429
+
1430
+ ### Section Config
1431
+
1432
+ ```typescript
1433
+ interface SectionConfig {
1434
+ children: FieldConfig[];
1435
+ allowMulti?: boolean; // Enables repeater mode — see Repeatable Sections
1436
+ name?: string; // Required when allowMulti is true (used as FormArray key)
1437
+ label?: string; // Can be an i18n key
1438
+ isEnabled?: boolean; // Static flag to explicitly hide the entire section if false
1439
+ }
1440
+ ```
1441
+
1442
+ ### Submit & Edit Configs
1443
+
1444
+ ```typescript
1445
+ interface SubmitConfig {
1446
+ apiUrl: string;
1447
+ method?: "POST" | "PUT" | "PATCH";
1448
+ successMessage?: string; // Can be an i18n key
1449
+ errorMessage?: string; // Can be an i18n key
1450
+ redirectUrl?: string; // Redirect after success
1451
+ extraPayload?: { [key: string]: any }; // Static extra fields for payload
1452
+ snackbarConfig?: SnackbarConfigOverride; // Customizes the API feedback alerts
1453
+ }
1454
+
1455
+ interface EditConfig {
1456
+ loadApiUrl: string; // Custom GET API to load existing form data
1457
+ submitApiUrl: string; // PATCH/PUT/POST API for updating
1458
+ submitMethod?: "PATCH" | "PUT" | "POST";
1459
+ successMessage?: string;
1460
+ errorMessage?: string;
1461
+ redirectUrl?: string;
1462
+ extraPayload?: { [key: string]: any };
1463
+ snackbarConfig?: SnackbarConfigOverride;
1464
+ }
1465
+
1466
+ interface SnackbarConfigOverride {
1467
+ duration?: number; // Auto-dismiss time (default 5000)
1468
+ horizontalPosition?: "start" | "center" | "end" | "left" | "right";
1469
+ verticalPosition?: "top" | "bottom";
1470
+ showCloseButton?: boolean;
1471
+ }
1472
+ ```
1473
+
1474
+ ### Field Config (key properties)
1475
+
1476
+ ```typescript
1477
+ interface FieldConfig {
1478
+ name?: string;
1479
+ label?: string; // Can be an i18n key
1480
+ type: string;
1481
+ subType: string;
1482
+ required?: boolean;
1483
+ disabled?: boolean;
1484
+ defaultValue?: any;
1485
+ placeholder?: string; // Can be an i18n key
1486
+ hint?: string; // Can be an i18n key
1487
+ colSpan?: number; // Column span in 12-column grid (1–12)
1488
+ payloadPath?: string; // Dot-notation path for nested payload mapping (e.g., 'status.code')
1489
+ visibilityExpression?: string;
1490
+ isEnabled?: boolean; // Static flag to explicitly disable/hide the field if false
1491
+ readonly?: boolean; // Whether the field is read-only (shows lock icon)
1492
+ suffixActionIcons?: SuffixActionIcon[]; // Clickable action icons inside the input
1493
+ sectionConfig?: SectionConfig;
1494
+ textConfig?: TextConfig;
1495
+ numberConfig?: NumberConfig;
1496
+ dateConfig?: DateConfig;
1497
+ timeConfig?: TimeConfig;
1498
+ optionConfig?: OptionConfig;
1499
+ attachmentConfig?: AttachmentConfig;
1500
+ ratingConfig?: RatingConfig;
1501
+ generatedConfig?: GeneratedConfig;
1502
+ richTextConfig?: RichTextConfig;
1503
+ children?: FieldConfig[]; // For ROW and GROUP fields
1504
+ }
1505
+
1506
+ interface SuffixActionIcon {
1507
+ icon: string; // Material icon name (e.g. 'edit', 'refresh')
1508
+ actionId: string; // Unique ID emitted on click
1509
+ tooltip?: string; // Optional tooltip shown on hover
1510
+ color?: string; // Optional custom color override (e.g. '#16A34A')
1511
+ }
1512
+
1513
+ interface AttachmentConfig {
1514
+ multiple?: boolean;
1515
+ maxFiles?: number;
1516
+ maxSizeMB?: number;
1517
+ accept?: string;
1518
+ acceptLabel?: string;
1519
+ allowedExtensions?: string[]; // Legacy
1520
+ }
1521
+
1522
+ interface RichTextConfig {
1523
+ height?: string; // CSS height for the editor (e.g. "200px")
1524
+ placeholder?: string; // Custom placeholder text
1525
+ maxLength?: number;
1526
+ showCharCount?: boolean;
1527
+ headerConfig?: string[]; // Toolbar tokens to show, in order (default: bold/italic/underline/font/size/color/link/image/video)
1528
+ }
1529
+ ```
1530
+
1531
+ ---
1532
+
1533
+ ## Advanced Features
1534
+
1535
+ ### 1. Conditional Visibility
1536
+
1537
+ Show/hide fields based on other field values using a JavaScript-like expression:
1538
+
1539
+ ```json
1540
+ {
1541
+ "name": "otherReason",
1542
+ "label": "Please specify",
1543
+ "type": "TEXT_INPUT",
1544
+ "subType": "SHORT",
1545
+ "visibilityExpression": "reason === 'OTHER'",
1546
+ "required": true
1547
+ }
1548
+ ```
1549
+
1550
+ The expression is evaluated against the live form data. When a field is hidden its control is disabled so its value is excluded from submission.
1551
+
1552
+ ### 2. Auto-Calculated Fields
1553
+
1554
+ Fields that automatically update based on other fields:
1555
+
1556
+ ```json
1557
+ {
1558
+ "name": "total",
1559
+ "label": "Total Amount",
1560
+ "type": "GENERATED",
1561
+ "subType": "FORMULA",
1562
+ "generatedConfig": {
1563
+ "formula": "function total(price, quantity) { return (price || 0) * (quantity || 0); }",
1564
+ "variables": ["price", "quantity"]
1565
+ }
1566
+ }
1567
+ ```
1568
+
1569
+ ### 3. Repeatable Sections (`allowMulti` on GROUP)
1570
+
1571
+ Allow users to add multiple instances of a section (e.g., multiple work experiences):
1572
+
1573
+ ```json
1574
+ {
1575
+ "type": "GROUP",
1576
+ "subType": "SECTION",
1577
+ "sectionConfig": {
1578
+ "label": "Work Experience",
1579
+ "allowMulti": true,
1580
+ "name": "experienceList",
1581
+ "children": [
1582
+ {
1583
+ "name": "company",
1584
+ "label": "Company",
1585
+ "type": "TEXT_INPUT",
1586
+ "subType": "SHORT",
1587
+ "required": true
1588
+ },
1589
+ {
1590
+ "name": "position",
1591
+ "label": "Position",
1592
+ "type": "TEXT_INPUT",
1593
+ "subType": "SHORT",
1594
+ "required": true
1595
+ }
1596
+ ]
1597
+ }
1598
+ }
1599
+ ```
1600
+
1601
+ - `name` is **required** when `allowMulti: true` — it becomes the `FormArray` key on the root `FormGroup`.
1602
+ - Each instance is a completely isolated `FormGroup`; data does not leak between instances.
1603
+ - The submitted value for this key is an **array of objects**, e.g. `{ "experienceList": [{ "company": "...", "position": "..." }, ...] }`.
1604
+ - **Add is gated on completeness.** Clicking "Add" is refused if the *previous* instance still has an invalid required field — that instance is re-expanded and marked touched (its errors render) instead of a new blank row being added. This prevents users from stacking up several incomplete rows with no indication anything is wrong until final submit.
1605
+ - **Sibling dropdowns auto-exclude taken values.** A single-select `DROPDOWN` field inside a repeater automatically hides values already chosen by *other* instances of the same repeater — e.g. picking "English" in Language Details #1 removes it from Language Details #2's option list. This is automatic for any single-select `DROPDOWN` in a repeater; no schema config is needed. It does **not** apply to `MULTIPLE`-subtype dropdowns.
1606
+
1607
+ ### 4. Cross-Field Match Validation (e.g. confirm password)
1608
+
1609
+ Use `textConfig.matchField` on the confirmation field to enforce equality:
1610
+
1611
+ ```json
1612
+ {
1613
+ "name": "confirmPassword",
1614
+ "label": "Confirm Password",
1615
+ "type": "TEXT_INPUT",
1616
+ "subType": "PASSWORD",
1617
+ "required": true,
1618
+ "textConfig": { "matchField": "password" }
1619
+ }
1620
+ ```
1621
+
1622
+ - Validation fires bi-directionally: if the user edits the source field after confirming, the error clears automatically.
1623
+ - Error key: `passwordMismatch`, shown as "Passwords do not match".
1624
+
1625
+ ### 5. Row Layouts with Column Spans
1626
+
1627
+ Display multiple fields in a row with fine-grained width control:
1628
+
1629
+ ```json
1630
+ {
1631
+ "type": "ROW",
1632
+ "subType": "HORIZONTAL",
1633
+ "children": [
1634
+ {
1635
+ "name": "shortCode",
1636
+ "label": "Short Code",
1637
+ "type": "TEXT_INPUT",
1638
+ "subType": "SHORT",
1639
+ "colSpan": 3
1640
+ },
1641
+ {
1642
+ "name": "donorType",
1643
+ "label": "Donor Type",
1644
+ "type": "DROPDOWN",
1645
+ "subType": "SINGLE",
1646
+ "colSpan": 3
1647
+ },
1648
+ {
1649
+ "name": "regNumber",
1650
+ "label": "Reg. Number",
1651
+ "type": "TEXT_INPUT",
1652
+ "subType": "SHORT",
1653
+ "colSpan": 3
1654
+ },
1655
+ {
1656
+ "name": "country",
1657
+ "label": "Country",
1658
+ "type": "DROPDOWN",
1659
+ "subType": "SINGLE",
1660
+ "colSpan": 3
1661
+ }
1662
+ ]
1663
+ }
1664
+ ```
1665
+
1666
+ ### 6. Suffix Action Icons
1667
+
1668
+ Add clickable action icons inside `TEXT_INPUT` (short text, email, phone) and `NUMBER_INPUT` fields to trigger custom logic in the host application (e.g. password visibility toggling, code validation, API lookup).
1669
+
1670
+ ```json
1671
+ {
1672
+ "name": "promoCode",
1673
+ "label": "PROMO_CODE.LABEL",
1674
+ "type": "TEXT_INPUT",
1675
+ "subType": "SHORT",
1676
+ "suffixActionIcons": [
1677
+ {
1678
+ "icon": "refresh",
1679
+ "actionId": "regenerate_code",
1680
+ "tooltip": "Regenerate Promo Code",
1681
+ "color": "#1E3A8A"
1682
+ },
1683
+ {
1684
+ "icon": "check_circle",
1685
+ "actionId": "verify_code",
1686
+ "tooltip": "Verify Validity",
1687
+ "color": "#16A34A"
1688
+ }
1689
+ ]
1690
+ }
1691
+ ```
1692
+
1693
+ When clicked, the `(suffixActionClick)` output event is emitted. The host application catches this event to run specific actions (such as generating a new promo code or verifying its validity).
1694
+
1695
+ > [!NOTE]
1696
+ > Suffix action icons are ignored if the field is set to `readonly: true`. In that state, the default security lock icon (`lock`) takes visual precedence.
1697
+
1698
+ ---
1699
+
1700
+ ## i18n / Translation Support
1701
+
1702
+ The `SmartFormComponent` accepts a `[labels]` input that is a **flat key–value map** of i18n strings (or an object with a `labelsObject` property following the same pattern used by `ConfigurableFormComponent`).
1703
+
1704
+ When `labels` is provided, the component recursively walks the parsed schema **before rendering** and replaces every matching key with its translated value.
1705
+
1706
+ ### Action Labels
1707
+
1708
+ The form action buttons (Next, Submit, Previous, Add, Remove) and file upload error messages can be localized by providing keys in the `labels` property of the `FormSchema`.
1709
+
1710
+ ```json
1711
+ {
1712
+ "entityType": "USER",
1713
+ "label": "FORM.TITLE",
1714
+ "formType": "SECTION",
1715
+ "labels": {
1716
+ "nextLabel": "APP.BUTTON.NEXT",
1717
+ "submitLabel": "APP.BUTTON.SUBMIT",
1718
+ "previousLabel": "APP.BUTTON.PREVIOUS",
1719
+ "addLabel": "APP.BUTTON.ADD",
1720
+ "removeLabel": "APP.BUTTON.REMOVE",
1721
+ "fileTypeError": "\"{fileName}\" is not a supported file type.",
1722
+ "fileSizeError": "\"{fileName}\" exceeds the maximum allowed size of {maxSizeMB} MB.",
1723
+ "maxFilesError": "Maximum {maxFiles} files allowed.",
1724
+ "fileUploadFailed": "Failed to upload \"{fileName}\". Please try again.",
1725
+ "fileDeleteFailed": "Failed to delete \"{fileName}\". Please try again."
1726
+ }
1727
+ }
1728
+ ```
1729
+
1730
+ If a mapping is not provided, the buttons and messages fall back to default English strings.
1731
+
1732
+ **File upload label placeholders**
1733
+
1734
+ | Label key | Dynamic placeholders | Default English text |
1735
+ |---|---|---|
1736
+ | `fileTypeError` | `{fileName}` | `"{fileName}" is not a supported file type.` |
1737
+ | `fileSizeError` | `{fileName}`, `{maxSizeMB}` | `"{fileName}" exceeds the maximum allowed size of {maxSizeMB} MB.` |
1738
+ | `maxFilesError` | `{maxFiles}` | `Maximum {maxFiles} files allowed.` |
1739
+ | `fileUploadFailed` | `{fileName}` | `Failed to upload "{fileName}". Please try again.` |
1740
+ | `fileDeleteFailed` | `{fileName}` | `Failed to delete "{fileName}". Please try again.` |
1741
+
1742
+ ### Translatable Schema Properties
1743
+
1744
+ | Property path | Description |
1745
+ | --------------------------------------- | ---------------------------------------------- |
1746
+ | `schema.label` | Form title |
1747
+ | `schema.description` | Form description |
1748
+ | `schema.submitConfig.successMessage` | Success alert text |
1749
+ | `schema.submitConfig.errorMessage` | Error alert text |
1750
+ | `sectionConfig.label` | Section heading |
1751
+ | `field.label` | Field label |
1752
+ | `field.placeholder` | Field placeholder |
1753
+ | `field.hint` | Field hint text |
1754
+ | `field.textConfig.patternMessage` | Custom pattern error message |
1755
+ | `field.attachmentConfig.acceptLabel` | File drop-zone hint (for all attachment types) |
1756
+ | `field.optionConfig.optionList[].label` | Static option labels |
1757
+ | `schema.labels.nextLabel` | Key for "Next" button text (Stepper) |
1758
+ | `schema.labels.submitLabel` | Key for "Submit" button text |
1759
+ | `schema.labels.previousLabel` | Key for "Previous" button text (Stepper) |
1760
+ | `schema.labels.addLabel` | Key for "Add" button text (Repeater) |
1761
+ | `schema.labels.removeLabel` | Key for "Remove" button text (Repeater) |
1762
+ | `schema.labels.fileTypeError` | File upload: unsupported file type error |
1763
+ | `schema.labels.fileSizeError` | File upload: file too large error |
1764
+ | `schema.labels.maxFilesError` | File upload: too many files error |
1765
+ | `schema.labels.fileUploadFailed` | File upload: API upload failure message |
1766
+ | `schema.labels.fileDeleteFailed` | File upload: API delete failure message |
1767
+
1768
+ > **Note:** Translation logic is centralized in the `SmartFormTranslationUtils` class. If you add new translatable properties to the `FormSchema` or `FieldConfig` models, ensure they are also registered in the `SmartFormTranslationUtils.translateSchema` method to be correctly processed.
1769
+
1770
+ Translation is applied recursively — it covers fields inside `ROW` children, `GROUP` children, nested `sectionConfig` sections, and all stepper steps.
1771
+
1772
+ ### Usage
1773
+
1774
+ ```html
1775
+ <lib-smart-form
1776
+ [formJson]="formJson"
1777
+ [labels]="labels"
1778
+ (submit)="onSubmit($event)"
1779
+ >
1780
+ </lib-smart-form>
1781
+ ```
1782
+
1783
+ ```typescript
1784
+ // Flat map — keys exactly match the strings used in the JSON schema
1785
+ labels = {
1786
+ "SMART_FORM.TITLE": "User Registration",
1787
+ "SMART_FORM.FIELD.FIRST_NAME": "First Name",
1788
+ "SMART_FORM.PH.FIRST_NAME": "Enter your first name",
1789
+ };
1790
+ ```
1791
+
1792
+ When `labels` changes (e.g., user switches language), the form is automatically re-parsed and all labels are re-translated.
1793
+
1794
+ ### Compatibility with `labelsObject`
1795
+
1796
+ The component also accepts the pattern used by `ConfigurableFormComponent`:
1797
+
1798
+ ```typescript
1799
+ labels = {
1800
+ errorMaxItemsAllowed: "...",
1801
+ labelsObject: { "SMART_FORM.TITLE": "User Registration" /* ... */ },
1802
+ };
1803
+ ```
1804
+
1805
+ If `labels.labelsObject` is present, translations are read from there; otherwise the top-level object is used directly.
1806
+
1807
+ ---
1808
+
1809
+ ## API Submission
1810
+
1811
+ ### Automatic API Submission (CREATE / POST)
1812
+
1813
+ Configure the form to automatically submit to an API endpoint by providing a `submitConfig`. You can also provide static additional payload fields that the form will merge into the final API request.
1814
+
1815
+ ```json
1816
+ {
1817
+ "entityType": "USER",
1818
+ "submitConfig": {
1819
+ "apiUrl": "https://api.example.com/users",
1820
+ "method": "POST",
1821
+ "successMessage": "User created successfully!",
1822
+ "redirectUrl": "https://platformcommons.dev/home",
1823
+ "extraPayload": {
1824
+ "channelCode": "CHANNEL.COMMONS.GRE_DEFAULT_CHANNEL",
1825
+ "marketCode": "COMMONS.GRE",
1826
+ "status": {
1827
+ "code": "REQUEST_STATUS.SUBMITTED"
1828
+ }
1829
+ }
1830
+ }
1831
+ }
1832
+ ```
1833
+
1834
+ ### Form Editing (EDIT / PATCH)
1835
+
1836
+ To support editing an existing record, switch the SmartFormComponent mode to `EDIT` and provide an `editConfig` in the `FormSchema`. The component will fetch the existing data using `loadApiUrl` before the form renders, and submit changes to `submitApiUrl` using the defined `submitMethod` (default `PATCH`).
1837
+
1838
+ ```html
1839
+ <lib-smart-form [formJson]="formJson" mode="EDIT" (submit)="onSubmit($event)">
1840
+ </lib-smart-form>
1841
+ ```
1842
+
1843
+ ```json
1844
+ {
1845
+ "entityType": "USER",
1846
+ "editConfig": {
1847
+ "loadApiUrl": "https://api.example.com/users/123",
1848
+ "submitApiUrl": "https://api.example.com/users/123",
1849
+ "submitMethod": "PATCH",
1850
+ "successMessage": "User updated successfully!",
1851
+ "redirectUrl": "https://platformcommons.dev/home",
1852
+ "extraPayload": {
1853
+ "updatedBy": "admin"
1854
+ }
1855
+ }
1856
+ }
1857
+ ```
1858
+
1859
+ ### Nested Payload Mapping
1860
+
1861
+ By default, the form submits a flat object matching the field names. If your API requires nested structures (like `status.code` or `address.city`), specify the nested hierarchy using the `payloadPath` property on the `FieldConfig`.
1862
+
1863
+ ```json
1864
+ {
1865
+ "name": "statusCodeInput",
1866
+ "label": "Status",
1867
+ "type": "TEXT_INPUT",
1868
+ "subType": "SHORT",
1869
+ "payloadPath": "status.code"
1870
+ }
1871
+ ```
1872
+
1873
+ Upon submission, the value from `statusCodeInput` will be formatted as:
1874
+
1875
+ ```json
1876
+ {
1877
+ "status": {
1878
+ "code": "Submitted value"
1879
+ }
1880
+ }
1881
+ ```
1882
+
1883
+ **Array Support in Payload Mapping:**
1884
+ You can also specify array indices directly in the `payloadPath` if your API expects values inside nested arrays.
1885
+
1886
+ ```json
1887
+ {
1888
+ "name": "firstName",
1889
+ "label": "First Name",
1890
+ "type": "TEXT_INPUT",
1891
+ "subType": "SHORT",
1892
+ "payloadPath": "name[0].labels.text"
1893
+ }
1894
+ ```
1895
+
1896
+ Upon submission, the value from `firstName` will be formatted as:
1897
+
1898
+ ```json
1899
+ {
1900
+ "name": [
1901
+ {
1902
+ "labels": {
1903
+ "text": "Submitted value"
1904
+ }
1905
+ }
1906
+ ]
1907
+ }
1908
+ ```
1909
+
1910
+ ### Deep-Merging with `extraPayload`
1911
+
1912
+ The `SmartFormComponent` intelligently deep-merges anything you provide in `submitConfig.extraPayload` (or `editConfig.extraPayload`) with the payload constructed from the form fields.
1913
+
1914
+ This means you can provide static extra properties that share the same nested structure (even arrays), and they will perfectly overlay each other.
1915
+
1916
+ **Example: Merging Array Values**
1917
+ Using the `firstName` setup above, if you needed your API payload to look like this:
1918
+
1919
+ ```json
1920
+ {
1921
+ "name": [
1922
+ {
1923
+ "id": 0,
1924
+ "labels": {
1925
+ "text": "John"
1926
+ }
1927
+ }
1928
+ ]
1929
+ }
1930
+ ```
1931
+
1932
+ You simply put the static `"id": 0` inside your `extraPayload` mirroring the structure:
1933
+
1934
+ ```json
1935
+ {
1936
+ "entityType": "USER",
1937
+ "submitConfig": {
1938
+ "apiUrl": "https://api.example.com/users",
1939
+ "extraPayload": {
1940
+ "name": [
1941
+ {
1942
+ "id": 0
1943
+ }
1944
+ ]
1945
+ }
1946
+ },
1947
+ "sectionConfig": {
1948
+ "children": [
1949
+ {
1950
+ "name": "firstName",
1951
+ "payloadPath": "name[0].labels.text",
1952
+ "type": "TEXT_INPUT"
1953
+ }
1954
+ ]
1955
+ }
1956
+ }
1957
+ ```
1958
+
1959
+ The internal deep-merge algorithm combines the values at `name[0]` to produce the exact desired payload.
1960
+
1961
+ "label": "User Registration",
1962
+ "formType": "SECTION",
1963
+ "submitConfig": {
1964
+ "apiUrl": "https://api.example.com/users",
1965
+ "method": "POST",
1966
+ "successMessage": "User created successfully",
1967
+ "errorMessage": "Failed to create user"
1968
+ },
1969
+ "sectionConfig": { "children": [...] }
1970
+ }
1971
+
1972
+ ````
1973
+
1974
+ ### Manual Submission
1975
+
1976
+ If no `submitConfig` is provided, handle submission in the parent component via the `(submit)` output:
1977
+
1978
+ ```typescript
1979
+ onSubmit(data: any) {
1980
+ this.http.post("https://api.example.com/users", data).subscribe(
1981
+ response => console.log("Success", response),
1982
+ error => console.error("Error", error)
1983
+ );
1984
+ }
1985
+ ````
1986
+
1987
+ ### Submitted Data Shape
1988
+
1989
+ - **Flat fields** → top-level key/value pairs. If `payloadPath` is set, maps the value to the specified nested path.
1990
+ - **GROUP (Visual Section)** → If a group lacks an explicit `name` or `allowMulti`, it is purely visual. Its contents are **flattened** directly onto the target payload layer.
1991
+ - **GROUP (Structural Block)** → If a group defines `sectionConfig.name`, `field.name`, or `allowMulti: true`.
1992
+ - Its payload is built as a nested object (or an array of objects if `allowMulti`).
1993
+ - The object key is determined by priority: `sectionConfig.name` → `field.name` → a generated camelCase derived from `sectionConfig.label` → `__group__`.
1994
+ - If a `payloadPath` is provided on the structural block, the payload is mapped to that precise dot-notation path instead of the generated default key.
1995
+
1996
+ ```json
1997
+ {
1998
+ // Flattened visual group fields (no 'name' specified on the group layout)
1999
+ "someOtherField": "Flattened value",
2000
+
2001
+ // Structural single block nested under derived key
2002
+ "basicDetails": {
2003
+ "firstName": "John",
2004
+ "lastName": "Doe"
2005
+ },
2006
+
2007
+ // Structural Repeater block (allowMulti: true)
2008
+ "experienceList": [
2009
+ { "company": "Acme", "position": "Engineer" },
2010
+ { "company": "Globex", "position": "Lead" }
2011
+ ]
2012
+ }
2013
+ ```
2014
+
2015
+ ---
2016
+
2017
+ ## API Authentication (Token)
2018
+
2019
+ The Smart Form can attach an auth token to **every library-initiated HTTP call** — this includes:
2020
+
2021
+ - Dropdown / Radio / Chip option loading (`optionConfig.apiUrl`, `apiUrls`, `optionUrl`)
2022
+ - Dependent dropdown refreshes (cascading selects)
2023
+ - Automatic form submission (`submitConfig.apiUrl`)
2024
+
2025
+ ### How It Works
2026
+
2027
+ The `token` and `tokenHeader` are defined **directly in the configJSON** (`FormSchema`). When the form is parsed, these values are stored in the `SmartFormController` service and automatically applied to every internal HTTP call — no manual `@Input` wiring in the parent template is needed.
2028
+
2029
+ ```json
2030
+ {
2031
+ "entityType": "USER",
2032
+ "label": "User Form",
2033
+ "formType": "SECTION",
2034
+ "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
2035
+ "tokenHeader": "Authorization",
2036
+ "sectionConfig": { "children": [...] }
2037
+ }
2038
+ ```
2039
+
2040
+ > **Note:** `tokenHeader` is optional. When omitted it defaults to `"Authorization"`.
2041
+
2042
+ ### Template
2043
+
2044
+ No extra bindings are required on `<lib-smart-form>`. The token flows entirely through the JSON:
2045
+
2046
+ ```html
2047
+ <lib-smart-form
2048
+ [formJson]="formJson"
2049
+ [labels]="labels"
2050
+ (submit)="onSubmit($event)"
2051
+ >
2052
+ </lib-smart-form>
2053
+ ```
2054
+
2055
+ ### How the Token Flows Internally
2056
+
2057
+ ```
2058
+ FormSchema JSON
2059
+ │ token / tokenHeader parsed by SmartFormComponent
2060
+ ▼
2061
+ SmartFormController (token & tokenHeader stored here)
2062
+ │ read by every FormFieldComponent directly
2063
+ ▼
2064
+ HttpHeaders → every API call (dropdowns, submit)
2065
+ ```
2066
+
2067
+ The token propagates automatically through the entire component tree without any `@Input` prop-drilling.
2068
+
2069
+ ### Per-Submit Override
2070
+
2071
+ If your submit endpoint requires a **different** token than the option-loading endpoints, set it directly inside `submitConfig`:
2072
+
2073
+ ```json
2074
+ {
2075
+ "submitConfig": {
2076
+ "apiUrl": "https://api.example.com/users",
2077
+ "method": "POST",
2078
+ "token": "ApiKey my-write-only-key",
2079
+ "tokenHeader": "X-API-Key"
2080
+ }
2081
+ }
2082
+ ```
2083
+
2084
+ `submitConfig.token` always takes precedence over the schema-level `token` for the submit call only.
2085
+
2086
+ ### Priority Order
2087
+
2088
+ ```
2089
+ submitConfig.token → FormSchema.token → (no header sent)
2090
+ ```
2091
+
2092
+ ---
2093
+
2094
+ ## Theme Configuration
2095
+
2096
+ The Smart Form exposes a rich set of CSS custom properties (variables) that allow you to fully customise the appearance without touching any component SCSS.
2097
+
2098
+ Two built-in themes are provided via a Sass mixin in `smart-form.theme.scss`.
2099
+
2100
+ ### Available Themes
2101
+
2102
+ | Theme constant | Description |
2103
+ | ---------------------------- | ------------------------------------------------ |
2104
+ | `$default-smart-form-config` | **Theme 1** — Clean & Professional (light, blue) |
2105
+ | `$theme-2-smart-form-config` | **Theme 2** — Vibrant & Modern (dark slate) |
2106
+
2107
+ ### Applying a Theme
2108
+
2109
+ In your consuming application's component SCSS, `@use` the theme file and call the mixin inside a wrapper class:
2110
+
2111
+ ```scss
2112
+ @use "commons-shared-web-ui/src/lib/modules/smart-form/smart-form.theme" as sf;
2113
+
2114
+ // Default (light) theme
2115
+ .my-form-wrapper {
2116
+ @include sf.smart-form-theme();
2117
+ }
2118
+
2119
+ // Dark theme
2120
+ .my-form-wrapper.dark {
2121
+ @include sf.smart-form-theme(sf.$theme-2-smart-form-config);
2122
+ }
2123
+ ```
2124
+
2125
+ ```html
2126
+ <div class="my-form-wrapper" [class.dark]="isDarkTheme">
2127
+ <lib-smart-form [formJson]="formJson" (submit)="onSubmit($event)">
2128
+ </lib-smart-form>
2129
+ </div>
2130
+ ```
2131
+
2132
+ ### Custom Theme
2133
+
2134
+ Pass a partial override map to `smart-form-theme()` to produce a custom theme without affecting the defaults:
2135
+
2136
+ ```scss
2137
+ @use "commons-shared-web-ui/src/lib/modules/smart-form/smart-form.theme" as sf;
2138
+
2139
+ .my-brand-form {
2140
+ @include sf.smart-form-theme(
2141
+ (
2142
+ form-bg: #f4f7ff,
2143
+ input-focus-border: #7c3aed,
2144
+ input-focus-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2),
2145
+ btn-primary-bg: #7c3aed,
2146
+ btn-primary-hover-bg: #6d28d9,
2147
+ )
2148
+ );
2149
+ }
2150
+ ```
2151
+
2152
+ ### CSS Custom Properties Reference
2153
+
2154
+ All variables are prefixed `--cc-sf-`. They are generated by the mixin and cascade into every child component automatically.
2155
+
2156
+ #### Form Container
2157
+
2158
+ | Variable | Default (Theme 1) | Description |
2159
+ | ---------------------------- | ---------------------------- | ------------------------------- |
2160
+ | `--cc-sf-font-family` | `'Inter', sans-serif` | Font family for the entire form |
2161
+ | `--cc-sf-font-size-base` | `0.875rem` | Base font size |
2162
+ | `--cc-sf-form-bg` | `#ffffff` | Form wrapper background |
2163
+ | `--cc-sf-form-border-radius` | `12px` | Form wrapper border radius |
2164
+ | `--cc-sf-form-border` | `none` | Form wrapper border |
2165
+ | `--cc-sf-form-shadow` | `0 1px 3px rgba(0,0,0,0.06)` | Form wrapper box shadow |
2166
+ | `--cc-sf-form-padding` | `24px` | Form outer padding |
2167
+ | `--cc-sf-form-max-width` | `1200px` | Form max width |
2168
+ | `--cc-sf-form-title-color` | `#111827` | Form title color |
2169
+ | `--cc-sf-form-title-size` | `1.5rem` | Form title font size |
2170
+ | `--cc-sf-form-title-weight` | `700` | Form title font weight |
2171
+ | `--cc-sf-form-desc-color` | `#6B7280` | Form description color |
2172
+ | `--cc-sf-form-desc-size` | `0.875rem` | Form description font size |
2173
+
2174
+ #### Section / GROUP Card
2175
+
2176
+ | Variable | Default (Theme 1) | Description |
2177
+ | ------------------------------ | ------------------- | ----------------------------- |
2178
+ | `--cc-sf-section-bg` | `#ffffff` | Section card background |
2179
+ | `--cc-sf-section-border` | `1px solid #E5E7EB` | Section card border |
2180
+ | `--cc-sf-section-radius` | `10px` | Section card border radius |
2181
+ | `--cc-sf-section-shadow` | `0 1px 4px rgba(…)` | Section card box shadow |
2182
+ | `--cc-sf-section-padding` | `20px` | Section card inner padding |
2183
+ | `--cc-sf-section-gap` | `20px` | Gap between sections |
2184
+ | `--cc-sf-section-label-color` | `#1F2937` | Section heading color |
2185
+ | `--cc-sf-section-label-size` | `1rem` | Section heading font size |
2186
+ | `--cc-sf-section-label-weight` | `600` | Section heading font weight |
2187
+ | `--cc-sf-section-label-border` | `2px solid #E5E7EB` | Section heading bottom border |
2188
+
2189
+ #### Grid
2190
+
2191
+ | Variable | Default (Theme 1) | Description |
2192
+ | ------------------ | ----------------- | -------------------------------- |
2193
+ | `--cc-sf-grid-gap` | `16px` | Gap between columns in all grids |
2194
+
2195
+ #### Labels
2196
+
2197
+ | Variable | Default (Theme 1) | Description |
2198
+ | ------------------------------ | ----------------- | ----------------------- |
2199
+ | `--cc-sf-label-color` | `#111827` | Field label text color |
2200
+ | `--cc-sf-label-size` | `0.875rem` | Field label font size |
2201
+ | `--cc-sf-label-weight` | `500` | Field label font weight |
2202
+ | `--cc-sf-label-required-color` | `#DC2626` | Required asterisk color |
2203
+
2204
+ #### Inputs
2205
+
2206
+ | Variable | Default (Theme 1) | Description |
2207
+ | ------------------------------- | --------------------------------- | ------------------------- |
2208
+ | `--cc-sf-input-bg` | `#ffffff` | Input background |
2209
+ | `--cc-sf-input-color` | `#111827` | Input text color |
2210
+ | `--cc-sf-input-placeholder` | `#9CA3AF` | Placeholder text color |
2211
+ | `--cc-sf-input-border` | `1.5px solid #D1D5DB` | Input border |
2212
+ | `--cc-sf-input-radius` | `8px` | Input border radius |
2213
+ | `--cc-sf-input-padding` | `0.625rem 0.875rem` | Input padding |
2214
+ | `--cc-sf-input-shadow` | `none` | Input default box shadow |
2215
+ | `--cc-sf-input-hover-border` | `#9CA3AF` | Input border on hover |
2216
+ | `--cc-sf-input-focus-border` | `#3B82F6` | Input border when focused |
2217
+ | `--cc-sf-input-focus-shadow` | `0 0 0 3px rgba(59,130,246,0.12)` | Focus ring glow |
2218
+ | `--cc-sf-input-disabled-bg` | `#F3F4F6` | Disabled input background |
2219
+ | `--cc-sf-input-disabled-color` | `#6B7280` | Disabled input text color |
2220
+ | `--cc-sf-input-disabled-border` | `#E5E7EB` | Disabled input border |
2221
+ | `--cc-sf-input-transition` | `all 0.2s ease` | Input transition speed |
2222
+
2223
+ #### Validation
2224
+
2225
+ | Variable | Default (Theme 1) | Description |
2226
+ | ---------------------------- | ------------------------------- | ------------------------------ |
2227
+ | `--cc-sf-error-border` | `#DC2626` | Error state input border color |
2228
+ | `--cc-sf-error-bg` | `#FEF2F2` | Error state input background |
2229
+ | `--cc-sf-error-focus-shadow` | `0 0 0 3px rgba(220,38,38,0.1)` | Error state focus ring |
2230
+ | `--cc-sf-error-text-color` | `#DC2626` | Error message text color |
2231
+ | `--cc-sf-error-text-size` | `0.75rem` | Error message font size |
2232
+ | `--cc-sf-hint-color` | `#6B7280` | Hint text color |
2233
+ | `--cc-sf-hint-size` | `0.75rem` | Hint text font size |
2234
+
2235
+ #### Chips
2236
+
2237
+ | Variable | Default (Theme 1) | Description |
2238
+ | ------------------------------ | ------------------- | ------------------------ |
2239
+ | `--cc-sf-chip-bg` | `#ffffff` | Chip default background |
2240
+ | `--cc-sf-chip-color` | `#374151` | Chip default text color |
2241
+ | `--cc-sf-chip-border` | `1px solid #D1D5DB` | Chip border |
2242
+ | `--cc-sf-chip-radius` | `20px` | Chip border radius |
2243
+ | `--cc-sf-chip-padding` | `6px 14px` | Chip padding |
2244
+ | `--cc-sf-chip-hover-bg` | `#F3F4F6` | Chip hover background |
2245
+ | `--cc-sf-chip-selected-bg` | `#3B82F6` | Selected chip background |
2246
+ | `--cc-sf-chip-selected-color` | `#ffffff` | Selected chip text |
2247
+ | `--cc-sf-chip-selected-border` | `#3B82F6` | Selected chip border |
2248
+
2249
+ #### Switch
2250
+
2251
+ | Variable | Default (Theme 1) | Description |
2252
+ | -------------------------- | ----------------- | ------------------- |
2253
+ | `--cc-sf-switch-track-on` | `#3B82F6` | Toggle track (on) |
2254
+ | `--cc-sf-switch-track-off` | `#D1D5DB` | Toggle track (off) |
2255
+ | `--cc-sf-switch-thumb` | `#ffffff` | Toggle thumb colour |
2256
+
2257
+ #### Rating Stars
2258
+
2259
+ | Variable | Default (Theme 1) | Description |
2260
+ | --------------------- | ----------------- | ------------------ |
2261
+ | `--cc-sf-star-filled` | `#F59E0B` | Filled star colour |
2262
+ | `--cc-sf-star-empty` | `#D1D5DB` | Empty star colour |
2263
+ | `--cc-sf-star-size` | `28px` | Star font size |
2264
+
2265
+ #### File Upload Drop Zone
2266
+
2267
+ | Variable | Default (Theme 1) | Description |
2268
+ | ------------------------------- | ---------------------- | ---------------------------- |
2269
+ | `--cc-sf-dropzone-bg` | `#FFFAF1` | Drop zone background |
2270
+ | `--cc-sf-dropzone-border` | `1.5px dashed #CBD5E1` | Drop zone border |
2271
+ | `--cc-sf-dropzone-radius` | `12px` | Drop zone border radius |
2272
+ | `--cc-sf-dropzone-hover-bg` | `#EFF6FF` | Hover background |
2273
+ | `--cc-sf-dropzone-hover-border` | `#93C5FD` | Hover border |
2274
+ | `--cc-sf-dropzone-over-border` | `#3B82F6` | Active drag-over border |
2275
+ | `--cc-sf-dropzone-icon-color` | `#94A3B8` | Cloud icon colour |
2276
+ | `--cc-sf-dropzone-link-color` | `#3B82F6` | "click to upload" link color |
2277
+ | `--cc-sf-dropzone-hint-color` | `#64748B` | Hint text colour in zone |
2278
+ | `--cc-sf-dropzone-over-shadow` | `0 0 0 4px rgba(…)` | Drag-over glow |
2279
+
2280
+ #### Stepper
2281
+
2282
+ | Variable | Default (Theme 1) | Description |
2283
+ | ---------------------------------- | ----------------- | -------------------------------- |
2284
+ | `--cc-sf-step-number-size` | `40px` | Step bubble size |
2285
+ | `--cc-sf-step-number-bg` | `#E5E7EB` | Idle step bubble background |
2286
+ | `--cc-sf-step-number-color` | `#6B7280` | Idle step number colour |
2287
+ | `--cc-sf-step-number-font-size` | `0.875rem` | Step number font size |
2288
+ | `--cc-sf-step-number-weight` | `600` | Step number font weight |
2289
+ | `--cc-sf-step-label-color` | `#6B7280` | Idle step label colour |
2290
+ | `--cc-sf-step-label-size` | `0.875rem` | Step label font size |
2291
+ | `--cc-sf-step-label-weight` | `500` | Step label font weight |
2292
+ | `--cc-sf-step-active-bg` | `#3B82F6` | Active step bubble background |
2293
+ | `--cc-sf-step-active-color` | `#ffffff` | Active step number colour |
2294
+ | `--cc-sf-step-active-label` | `#1D4ED8` | Active step label colour |
2295
+ | `--cc-sf-step-active-label-weight` | `700` | Active step label font weight |
2296
+ | `--cc-sf-step-done-bg` | `#22C55E` | Completed step bubble background |
2297
+ | `--cc-sf-step-done-color` | `#ffffff` | Completed step number colour |
2298
+ | `--cc-sf-step-connector-color` | `#E5E7EB` | Connector line (idle) |
2299
+ | `--cc-sf-step-connector-done` | `#22C55E` | Connector line (completed) |
2300
+
2301
+ #### Action Buttons
2302
+
2303
+ | Variable | Default (Theme 1) | Description |
2304
+ | -------------------------------- | -------------------- | ---------------------------------- |
2305
+ | `--cc-sf-btn-primary-bg` | `#3B82F6` | Primary (submit) button background |
2306
+ | `--cc-sf-btn-primary-color` | `#ffffff` | Primary button text colour |
2307
+ | `--cc-sf-btn-primary-radius` | `8px` | Primary button border radius |
2308
+ | `--cc-sf-btn-primary-padding` | `0.625rem 1.5rem` | Primary button padding |
2309
+ | `--cc-sf-btn-primary-hover-bg` | `#2563EB` | Primary button hover background |
2310
+ | `--cc-sf-btn-secondary-bg` | `#F3F4F6` | Secondary (previous) button bg |
2311
+ | `--cc-sf-btn-secondary-color` | `#374151` | Secondary button text colour |
2312
+ | `--cc-sf-btn-secondary-radius` | `8px` | Secondary button border radius |
2313
+ | `--cc-sf-btn-secondary-padding` | `0.625rem 1.5rem` | Secondary button padding |
2314
+ | `--cc-sf-btn-secondary-hover-bg` | `#E5E7EB` | Secondary button hover background |
2315
+ | `--cc-sf-btn-disabled-opacity` | `0.55` | Disabled button opacity |
2316
+ | `--cc-sf-btn-font-size` | `0.875rem` | Button font size |
2317
+ | `--cc-sf-btn-font-weight` | `600` | Button font weight |
2318
+ | `--cc-sf-btn-transition` | `all 0.2s ease` | Button transition |
2319
+ | `--cc-sf-actions-gap` | `12px` | Gap between action buttons |
2320
+ | `--cc-sf-actions-padding` | `20px 0 0` | Action bar padding |
2321
+ | `--cc-sf-actions-border` | `1px solid #E5E7EB` | Action bar top border |
2322
+ | `--cc-sf-btn-add-bg` | `transparent` | Add-instance button background |
2323
+ | `--cc-sf-btn-add-color` | `#3B82F6` | Add-instance button text colour |
2324
+ | `--cc-sf-btn-add-border` | `1px dashed #CBD5E1` | Add-instance button border |
2325
+ | `--cc-sf-btn-add-radius` | `6px` | Add-instance button radius |
2326
+ | `--cc-sf-btn-add-hover-bg` | `#EFF6FF` | Add-instance button hover bg |
2327
+ | `--cc-sf-btn-add-hover-border` | `#BFDBFE` | Add-instance button hover border |
2328
+ | `--cc-sf-btn-remove-bg` | `#FFF5F5` | Remove-instance button background |
2329
+ | `--cc-sf-btn-remove-color` | `#E53E3E` | Remove-instance button text colour |
2330
+ | `--cc-sf-btn-remove-border` | `1px solid #FED7D7` | Remove-instance button border |
2331
+ | `--cc-sf-btn-remove-radius` | `4px` | Remove-instance button radius |
2332
+ | `--cc-sf-btn-remove-hover-bg` | `#FED7D7` | Remove-instance button hover bg |
2333
+
2334
+ ---
2335
+
2336
+ ## Examples
2337
+
2338
+ ### Contact Form
2339
+
2340
+ ```json
2341
+ {
2342
+ "entityType": "CONTACT",
2343
+ "label": "Contact Us",
2344
+ "formType": "SECTION",
2345
+ "submitConfig": {
2346
+ "apiUrl": "https://api.example.com/contact",
2347
+ "method": "POST",
2348
+ "successMessage": "Message sent successfully",
2349
+ "errorMessage": "Failed to send message",
2350
+ "snackbarConfig": {
2351
+ "duration": 6000,
2352
+ "verticalPosition": "top",
2353
+ "horizontalPosition": "center",
2354
+ "showCloseButton": true
2355
+ }
2356
+ },
2357
+ "sectionConfig": {
2358
+ "children": [
2359
+ {
2360
+ "name": "name",
2361
+ "label": "Full Name",
2362
+ "type": "TEXT_INPUT",
2363
+ "subType": "SHORT",
2364
+ "required": true
2365
+ },
2366
+ {
2367
+ "name": "email",
2368
+ "label": "Email Address",
2369
+ "type": "TEXT_INPUT",
2370
+ "subType": "EMAIL",
2371
+ "required": true
2372
+ },
2373
+ {
2374
+ "name": "message",
2375
+ "label": "Message",
2376
+ "type": "TEXT_INPUT",
2377
+ "subType": "LONG",
2378
+ "required": true,
2379
+ "textConfig": { "length": { "min": 10, "max": 500 } }
2380
+ }
2381
+ ]
2382
+ }
2383
+ }
2384
+ ```
2385
+
2386
+ ### User Registration with Password Validation
2387
+
2388
+ ```json
2389
+ {
2390
+ "entityType": "USER_REGISTRATION",
2391
+ "label": "User Registration",
2392
+ "formType": "SECTION",
2393
+ "sectionConfig": {
2394
+ "children": [
2395
+ {
2396
+ "type": "GROUP",
2397
+ "subType": "SECTION",
2398
+ "sectionConfig": {
2399
+ "label": "Credentials",
2400
+ "name": "credentials",
2401
+ "children": [
2402
+ {
2403
+ "type": "ROW",
2404
+ "subType": "HORIZONTAL",
2405
+ "children": [
2406
+ {
2407
+ "name": "loginId",
2408
+ "label": "Login ID",
2409
+ "type": "TEXT_INPUT",
2410
+ "subType": "SHORT",
2411
+ "required": true,
2412
+ "colSpan": 4
2413
+ },
2414
+ {
2415
+ "name": "password",
2416
+ "label": "Password",
2417
+ "type": "TEXT_INPUT",
2418
+ "subType": "PASSWORD",
2419
+ "required": true,
2420
+ "colSpan": 4
2421
+ },
2422
+ {
2423
+ "name": "confirmPassword",
2424
+ "label": "Confirm Password",
2425
+ "type": "TEXT_INPUT",
2426
+ "subType": "PASSWORD",
2427
+ "required": true,
2428
+ "colSpan": 4,
2429
+ "textConfig": { "matchField": "password" }
2430
+ }
2431
+ ]
2432
+ }
2433
+ ]
2434
+ }
2435
+ }
2436
+ ]
2437
+ }
2438
+ }
2439
+ ```
2440
+
2441
+ ### Section Stepper with `showOnLastStepOnly`
2442
+
2443
+ A three-step registration form using Section Stepper. The **Submit** button carries `"showOnLastStepOnly": true` so it is only visible on the last step. **Previous** and **Next** are rendered automatically by the form — no extra config needed.
2444
+
2445
+ ```json
2446
+ {
2447
+ "entityType": "REGISTRATION",
2448
+ "label": "Event Registration",
2449
+ "formType": "SECTION",
2450
+ "sectionStepper": true,
2451
+ "submitConfig": {
2452
+ "apiUrl": "https://api.example.com/registrations",
2453
+ "method": "POST",
2454
+ "successMessage": "Registration submitted successfully!",
2455
+ "redirectUrl": "/dashboard"
2456
+ },
2457
+ "actionBarConfig": {
2458
+ "buttons": [
2459
+ {
2460
+ "id": "cancel",
2461
+ "label": "Cancel",
2462
+ "variant": "outline",
2463
+ "alignment": "left",
2464
+ "order": 0,
2465
+ "action": { "kind": "navigate", "redirectUrl": "/dashboard" }
2466
+ },
2467
+ {
2468
+ "id": "save-draft",
2469
+ "label": "Save as Draft",
2470
+ "variant": "secondary",
2471
+ "alignment": "right",
2472
+ "order": 0,
2473
+ "action": { "kind": "draft", "extraPayload": { "status": "DRAFT" } }
2474
+ },
2475
+ {
2476
+ "id": "submit",
2477
+ "label": "Submit",
2478
+ "variant": "primary",
2479
+ "alignment": "right",
2480
+ "order": 1,
2481
+ "showOnLastStepOnly": true,
2482
+ "action": { "kind": "submit" }
2483
+ }
2484
+ ]
2485
+ },
2486
+ "sectionConfig": {
2487
+ "children": [
2488
+ {
2489
+ "type": "GROUP",
2490
+ "subType": "SECTION",
2491
+ "sectionConfig": {
2492
+ "label": "Personal Info",
2493
+ "children": [
2494
+ {
2495
+ "type": "ROW",
2496
+ "subType": "HORIZONTAL",
2497
+ "children": [
2498
+ {
2499
+ "name": "firstName",
2500
+ "label": "First Name",
2501
+ "type": "TEXT_INPUT",
2502
+ "subType": "SHORT",
2503
+ "required": true,
2504
+ "colSpan": 6
2505
+ },
2506
+ {
2507
+ "name": "lastName",
2508
+ "label": "Last Name",
2509
+ "type": "TEXT_INPUT",
2510
+ "subType": "SHORT",
2511
+ "required": true,
2512
+ "colSpan": 6
2513
+ }
2514
+ ]
2515
+ },
2516
+ {
2517
+ "name": "email",
2518
+ "label": "Email Address",
2519
+ "type": "TEXT_INPUT",
2520
+ "subType": "EMAIL",
2521
+ "required": true
2522
+ }
2523
+ ]
2524
+ }
2525
+ },
2526
+ {
2527
+ "type": "GROUP",
2528
+ "subType": "SECTION",
2529
+ "sectionConfig": {
2530
+ "label": "Event Preferences",
2531
+ "children": [
2532
+ {
2533
+ "name": "session",
2534
+ "label": "Preferred Session",
2535
+ "type": "DROPDOWN",
2536
+ "subType": "SINGLE",
2537
+ "required": true,
2538
+ "optionConfig": {
2539
+ "optionList": [
2540
+ { "label": "Morning", "code": "MORNING" },
2541
+ { "label": "Afternoon", "code": "AFTERNOON" },
2542
+ { "label": "Evening", "code": "EVENING" }
2543
+ ]
2544
+ }
2545
+ },
2546
+ {
2547
+ "name": "dietaryRequirements",
2548
+ "label": "Dietary Requirements",
2549
+ "type": "CHIP",
2550
+ "subType": "MULTIPLE",
2551
+ "optionConfig": {
2552
+ "optionList": [
2553
+ { "label": "Vegetarian", "code": "VEG" },
2554
+ { "label": "Vegan", "code": "VEGAN" },
2555
+ { "label": "Gluten-Free", "code": "GF" },
2556
+ { "label": "None", "code": "NONE" }
2557
+ ]
2558
+ }
2559
+ }
2560
+ ]
2561
+ }
2562
+ },
2563
+ {
2564
+ "type": "GROUP",
2565
+ "subType": "SECTION",
2566
+ "sectionConfig": {
2567
+ "label": "Review & Submit",
2568
+ "children": [
2569
+ {
2570
+ "name": "agreeToTerms",
2571
+ "label": "I agree to the terms and conditions",
2572
+ "type": "CHECKBOX",
2573
+ "subType": "BOOL",
2574
+ "required": true
2575
+ },
2576
+ {
2577
+ "name": "notes",
2578
+ "label": "Additional Notes",
2579
+ "type": "TEXT_INPUT",
2580
+ "subType": "LONG"
2581
+ }
2582
+ ]
2583
+ }
2584
+ }
2585
+ ]
2586
+ }
2587
+ }
2588
+ ```
2589
+
2590
+ **What the action bar looks like on each step:**
2591
+
2592
+ | Step | Left side | Right side |
2593
+ |------|-----------|------------|
2594
+ | Step 1 (first) | Cancel | Save as Draft · **Next** |
2595
+ | Step 2 | Cancel · **Previous** | Save as Draft · **Next** |
2596
+ | Step 3 (last) | Cancel · **Previous** | Save as Draft · **Submit** |
2597
+
2598
+ - **Previous** / **Next** are rendered automatically; no button config needed.
2599
+ - **Submit** (`showOnLastStepOnly: true`) is hidden on steps 1 and 2, then replaces **Next** on step 3.
2600
+ - **Cancel** and **Save as Draft** have no `showOnLastStepOnly` flag, so they appear on every step.
2601
+
2602
+ ### Repeatable Work Experience
2603
+
2604
+ ```json
2605
+ {
2606
+ "type": "GROUP",
2607
+ "subType": "SECTION",
2608
+ "sectionConfig": {
2609
+ "label": "Work Experience",
2610
+ "allowMulti": true,
2611
+ "name": "experienceList",
2612
+ "children": [
2613
+ {
2614
+ "name": "company",
2615
+ "label": "Company",
2616
+ "type": "TEXT_INPUT",
2617
+ "subType": "SHORT",
2618
+ "required": true
2619
+ },
2620
+ {
2621
+ "name": "position",
2622
+ "label": "Position",
2623
+ "type": "TEXT_INPUT",
2624
+ "subType": "SHORT",
2625
+ "required": true
2626
+ },
2627
+ {
2628
+ "type": "ROW",
2629
+ "subType": "HORIZONTAL",
2630
+ "children": [
2631
+ {
2632
+ "name": "startDate",
2633
+ "label": "Start Date",
2634
+ "type": "DATE",
2635
+ "subType": "SINGLE",
2636
+ "required": true,
2637
+ "colSpan": 6
2638
+ },
2639
+ {
2640
+ "name": "endDate",
2641
+ "label": "End Date",
2642
+ "type": "DATE",
2643
+ "subType": "SINGLE",
2644
+ "colSpan": 6
2645
+ }
2646
+ ]
2647
+ }
2648
+ ]
2649
+ }
2650
+ }
2651
+ ```
2652
+
2653
+ ---
2654
+
2655
+ ## API Reference
2656
+
2657
+ ### Component Inputs
2658
+
2659
+ | Input | Type | Required | Description |
2660
+ | --------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
2661
+ | `formJson` | string | Yes | JSON string of the form schema configuration |
2662
+ | `mode` | string | No | Determines whether the form creates or edits an entity: `"CREATE" \| "EDIT"` (default: `"CREATE"`) |
2663
+ | `initialValues` | object | No | Pre-populate form values (key = field `name`) |
2664
+ | `enableDraftAutoSave` | boolean | No | Enable auto-save drafts (default: `false`) |
2665
+ | `labels` | object | No | Flat i18n key–value map. Keys must match the string values used in the JSON schema. See [i18n section](#i18n--translation-support). |
2666
+ | `readOnly` | boolean | No | When `true`, all form controls are disabled and the action bar is hidden. Use this for **read-only preview** in a Form Builder wizard (default: `false`). |
2667
+
2668
+
2669
+ ### Component Outputs
2670
+
2671
+ | `submit` | `EventEmitter<object>` | Emitted when the form is submitted. Contains collected form data or the API response |
2672
+ | `draftSave` | `EventEmitter<string>` | Emitted when a draft is saved (requires `enableDraftAutoSave: true`) |
2673
+ | `fileAdded` | `EventEmitter<any>` | Emitted when a file upload starts internally (MEDIA_UPLOAD or FILE_UPLOAD). |
2674
+ | `fileRemoved` | `EventEmitter<any>` | Emitted when a file upload completes, fails, or is manually removed. |
2675
+ | `suffixActionClick` | `EventEmitter<{ fieldName: string; actionId: string }>` | Emitted when a clickable action icon (configured via `suffixActionIcons`) is clicked inside a text or number field. |
2676
+
2677
+ ### Usage in Component
2678
+
2679
+ ```typescript
2680
+ @Component({
2681
+ template: `
2682
+ <lib-smart-form
2683
+ [formJson]="formJson"
2684
+ [initialValues]="initialData"
2685
+ [labels]="labels"
2686
+ (submit)="handleSubmit($event)"
2687
+ >
2688
+ </lib-smart-form>
2689
+ `,
2690
+ })
2691
+ export class MyComponent {
2692
+ formJson: string; // JSON.stringify(yourSchemaObject)
2693
+ initialData = { firstName: "John" };
2694
+ labels = { "FIELD.FIRST_NAME": "First Name" };
2695
+
2696
+ handleSubmit(data: any) {
2697
+ console.log("Form Data:", data);
2698
+ }
2699
+ }
2700
+ ```
2701
+
2702
+ ---
2703
+
2704
+ ## Best Practices
2705
+
2706
+ 1. Use **meaningful camelCase field names** (`firstName`, `emailId`).
2707
+ 2. Store all label strings in your **i18n JSON files** and pass them via `[labels]`. Every label property in the JSON schema should be an i18n key that exists in your translation files. These are processed by `SmartFormTranslationUtils` before rendering.
2708
+ 3. Always set `name` on `GROUP` + `allowMulti` sections — it becomes the `FormArray` key.
2709
+ 4. Use `colSpan` to build responsive multi-column layouts inside `ROW`.
2710
+ 5. Use `visibilityExpression` to keep forms concise — hidden fields are excluded from submission.
2711
+ 6. Provide `hints` and `placeholders` for complex fields; these are also translatable.
2712
+ 7. Use `matchField` for confirm-password style validation instead of custom validators.
2713
+ 8. Test `GENERATED` formulas with `null`/`undefined` inputs — they will be called before the user types.
2714
+ 9. For long forms, prefer `STEPPER` over a single `SECTION` with many fields.
2715
+ 10. Verify `submitConfig.apiUrl` CORS settings before relying on automatic API submission.
2716
+ 11. Always set **`token`** in the configJSON (`FormSchema.token`) when dropdowns load from secured API endpoints — without it the requests will be unauthenticated. The token flows automatically to every field; no `@Input` binding is needed on `<lib-smart-form>`.
2717
+ 12. Apply themes using the `smart-form-theme()` mixin inside a scoped wrapper class, not at `:root` level, to avoid conflicts with other form instances on the same page.
2718
+
2719
+ ---
2720
+
2721
+ ## Troubleshooting
2722
+
2723
+ ### Form not rendering
2724
+
2725
+ - Ensure `formJson` is a valid JSON **string** (use `JSON.stringify`).
2726
+ - Check the browser console for parse errors.
2727
+
2728
+ ### Labels not translating
2729
+
2730
+ - Confirm the key in `labels` exactly matches the string value in the schema JSON.
2731
+ - If `labels` arrives after `formJson`, the component automatically re-parses — but make sure `ngOnChanges` is reaching the component (i.e., `labels` is a fresh object reference, not mutated in place).
2732
+
2733
+ ### Repeater instances sharing values
2734
+
2735
+ - Ensure `sectionConfig.name` is set on the `GROUP` field — without it the `FormArray` key defaults to `__repeater__` and may conflict.
2736
+ - Each repeater instance starts blank by design (`inRepeater: true` disables cross-instance controller reads).
2737
+
2738
+ ### Generated fields not updating
2739
+
2740
+ - Verify `variables` lists every field name the formula reads.
2741
+ - Check formula syntax — it must be a valid **named** JavaScript function.
2742
+
2743
+ ### API submission not working
2744
+
2745
+ - Verify `submitConfig.apiUrl` is correct and the server allows the HTTP method.
2746
+ - Check CORS settings on the API endpoint.
2747
+
2748
+ ### Dropdown options not loading
2749
+
2750
+ - Verify `apiUrl` / `optionUrl` is reachable.
2751
+ - Check `dataPath` if the response wraps the array in an object.
2752
+ - Verify `labelPath` and `valuePath` exist on each item.
2753
+ - For dependent dropdowns, ensure the parent field name in `dependencies` maps matches the field's `name` exactly.
2754
+
2755
+ ### Dropdown options return 401 / 403
2756
+
2757
+ - Set `token` and optionally `tokenHeader` inside the **configJSON** (`FormSchema`) so the library attaches auth headers to every dropdown API call automatically.
2758
+ - If only the **submit** endpoint is secured, set `token` inside `submitConfig` in the JSON schema — it takes precedence over `FormSchema.token` for the submit call only.
2759
+ - Confirm the token value includes the scheme prefix if required by your API (e.g. `"Bearer "` not just the raw JWT).
2760
+
2761
+ ---
2762
+
2763
+ ## License
2764
+
2765
+ This module is part of the shared-ui library.