commons-shared-web-ui 0.0.51 → 0.0.53

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