platformcommons-web-lib 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commons-shared-web-ui-1.0.0.tgz +0 -0
- package/documentation/alert.md +123 -0
- package/documentation/button-dropdown.md +126 -0
- package/documentation/button.md +184 -0
- package/documentation/cards-usage-guidelines.md +131 -0
- package/documentation/configurable-form.md +605 -0
- package/documentation/confirmation-modal.md +250 -0
- package/documentation/filter-sidebar.md +178 -0
- package/documentation/filter-table-selector.md +228 -0
- package/documentation/form-builder.md +597 -0
- package/documentation/form-components.md +384 -0
- package/documentation/nav.md +427 -0
- package/documentation/pagination.md +181 -0
- package/documentation/side-nav-documentation.md +169 -0
- package/documentation/smart-form.md +2177 -0
- package/documentation/smart-table.md +1198 -0
- package/documentation/snackbar.md +118 -0
- package/documentation/style-externalization.md +88 -0
- package/documentation/summary-card.md +279 -0
- package/ng-package.json +28 -0
- package/package.json +54 -0
- package/src/lib/modules/alert/alert.models.ts +6 -0
- package/src/lib/modules/alert/alert.module.ts +16 -0
- package/src/lib/modules/alert/alert.theme.scss +85 -0
- package/src/lib/modules/alert/components/alert/alert.component.html +27 -0
- package/src/lib/modules/alert/components/alert/alert.component.scss +92 -0
- package/src/lib/modules/alert/components/alert/alert.component.ts +81 -0
- package/src/lib/modules/button/button.models.ts +13 -0
- package/src/lib/modules/button/button.module.ts +16 -0
- package/src/lib/modules/button/button.theme.scss +121 -0
- package/src/lib/modules/button/components/button/button.component.html +22 -0
- package/src/lib/modules/button/components/button/button.component.scss +88 -0
- package/src/lib/modules/button/components/button/button.component.ts +67 -0
- package/src/lib/modules/button-dropdown/button-dropdown.models.ts +26 -0
- package/src/lib/modules/button-dropdown/button-dropdown.module.ts +22 -0
- package/src/lib/modules/button-dropdown/button-dropdown.theme.scss +87 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.html +41 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.scss +135 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.ts +160 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.html +294 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.scss +503 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.ts +628 -0
- package/src/lib/modules/configurable-form/configurable-form.examples.ts +154 -0
- package/src/lib/modules/configurable-form/configurable-form.model.ts +131 -0
- package/src/lib/modules/configurable-form/configurable-form.module.ts +19 -0
- package/src/lib/modules/configurable-form/configurable-form.theme.scss +78 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.html +77 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.scss +395 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.ts +266 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.models.ts +71 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.module.ts +20 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.theme.scss +87 -0
- package/src/lib/modules/filter/components/filter/filter.component.html +131 -0
- package/src/lib/modules/filter/components/filter/filter.component.scss +245 -0
- package/src/lib/modules/filter/components/filter/filter.component.ts +216 -0
- package/src/lib/modules/filter/filter.models.ts +88 -0
- package/src/lib/modules/filter/filter.module.ts +24 -0
- package/src/lib/modules/filter/filter.theme.scss +92 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.html +112 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.scss +186 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.ts +163 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.models.ts +95 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.module.ts +24 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.theme.scss +38 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.html +73 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.scss +321 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.ts +361 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.models.ts +91 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.module.ts +22 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.theme.scss +36 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.html +63 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.scss +496 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.ts +445 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.html +75 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.scss +210 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.ts +55 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.html +25 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.scss +82 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.ts +95 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.html +20 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.scss +37 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.ts +94 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.html +46 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.scss +102 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.ts +50 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.html +35 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.scss +67 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.ts +34 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.html +68 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.scss +113 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.ts +74 -0
- package/src/lib/modules/form-builder/configs/field-type-schema.map.ts +533 -0
- package/src/lib/modules/form-builder/form-builder.module.ts +36 -0
- package/src/lib/modules/form-builder/form-builder.theme.scss +212 -0
- package/src/lib/modules/form-builder/index.ts +9 -0
- package/src/lib/modules/form-builder/models/builder.models.ts +7 -0
- package/src/lib/modules/form-builder/models/field-configurator.models.ts +38 -0
- package/src/lib/modules/form-builder/models/field-selection.models.ts +51 -0
- package/src/lib/modules/form-builder/services/field-configurator.service.ts +258 -0
- package/src/lib/modules/form-builder/services/field-selection.service.ts +300 -0
- package/src/lib/modules/form-builder/services/form-schema-tree.service.ts +652 -0
- package/src/lib/modules/form-builder/tokens/builder.tokens.ts +10 -0
- package/src/lib/modules/form-builder/utils/constants.ts +43 -0
- package/src/lib/modules/form-components/components/checkbox/_theme.scss +63 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.html +29 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.scss +111 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.ts +207 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.models.ts +35 -0
- package/src/lib/modules/form-components/components/datepicker/_theme.scss +82 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.html +42 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.scss +115 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.ts +267 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.models.ts +45 -0
- package/src/lib/modules/form-components/components/dropdown/_theme.scss +91 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.html +74 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.scss +252 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.ts +377 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.models.ts +53 -0
- package/src/lib/modules/form-components/components/input/_theme.scss +77 -0
- package/src/lib/modules/form-components/components/input/input.component.html +51 -0
- package/src/lib/modules/form-components/components/input/input.component.scss +128 -0
- package/src/lib/modules/form-components/components/input/input.component.ts +250 -0
- package/src/lib/modules/form-components/components/input/input.models.ts +55 -0
- package/src/lib/modules/form-components/components/radio/_theme.scss +61 -0
- package/src/lib/modules/form-components/components/radio/radio.component.html +22 -0
- package/src/lib/modules/form-components/components/radio/radio.component.scss +107 -0
- package/src/lib/modules/form-components/components/radio/radio.component.ts +181 -0
- package/src/lib/modules/form-components/components/radio/radio.models.ts +39 -0
- package/src/lib/modules/form-components/components/search/_theme.scss +73 -0
- package/src/lib/modules/form-components/components/search/search.component.html +15 -0
- package/src/lib/modules/form-components/components/search/search.component.scss +87 -0
- package/src/lib/modules/form-components/components/search/search.component.ts +213 -0
- package/src/lib/modules/form-components/components/search/search.models.ts +40 -0
- package/src/lib/modules/form-components/components/toggle/_theme.scss +45 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.html +15 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.scss +81 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.ts +166 -0
- package/src/lib/modules/form-components/components/toggle/toggle.models.ts +27 -0
- package/src/lib/modules/form-components/directives/click-outside.directive.ts +22 -0
- package/src/lib/modules/form-components/form-components.module.ts +41 -0
- package/src/lib/modules/form-components/form-components.theme.scss +25 -0
- package/src/lib/modules/material/material.module.ts +94 -0
- package/src/lib/modules/nav/components/nav/nav.component.html +34 -0
- package/src/lib/modules/nav/components/nav/nav.component.scss +171 -0
- package/src/lib/modules/nav/components/nav/nav.component.ts +82 -0
- package/src/lib/modules/nav/nav.models.ts +31 -0
- package/src/lib/modules/nav/nav.module.ts +17 -0
- package/src/lib/modules/nav/nav.theme.scss +86 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.html +52 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.scss +155 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.ts +109 -0
- package/src/lib/modules/pagination/pagination.module.ts +17 -0
- package/src/lib/modules/pagination/pagination.theme.scss +66 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.html +56 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.scss +342 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.ts +135 -0
- package/src/lib/modules/side-nav/side-nav.models.ts +38 -0
- package/src/lib/modules/side-nav/side-nav.module.ts +16 -0
- package/src/lib/modules/side-nav/side-nav.theme.scss +111 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.html +1109 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.scss +1860 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.ts +2232 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.html +64 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.scss +209 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.ts +119 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.html +253 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.scss +689 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.ts +1087 -0
- package/src/lib/modules/smart-form/index.ts +10 -0
- package/src/lib/modules/smart-form/models/form-schema.model.ts +700 -0
- package/src/lib/modules/smart-form/models/hierarchy-config.model.ts +21 -0
- package/src/lib/modules/smart-form/services/expression.service.ts +75 -0
- package/src/lib/modules/smart-form/services/smart-form-controller.service.ts +65 -0
- package/src/lib/modules/smart-form/smart-form.examples.ts +1324 -0
- package/src/lib/modules/smart-form/smart-form.module.ts +36 -0
- package/src/lib/modules/smart-form/smart-form.theme.scss +890 -0
- package/src/lib/modules/smart-form/utils/translation.utils.ts +82 -0
- package/src/lib/modules/smart-form/utils/trusted-url.pipe.ts +25 -0
- package/src/lib/modules/smart-form/utils/validation.utils.ts +98 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.html +283 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.scss +685 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.ts +1118 -0
- package/src/lib/modules/smart-table/models/table-config.model.ts +202 -0
- package/src/lib/modules/smart-table/smart-table.module.ts +30 -0
- package/src/lib/modules/smart-table/smart-table.theme.scss +335 -0
- package/src/lib/modules/smart-table/utils/safe-html.pipe.ts +22 -0
- package/src/lib/modules/smart-table/utils/smart-table.utils.ts +18 -0
- package/src/lib/modules/snackbar/components/snackbar.component.html +41 -0
- package/src/lib/modules/snackbar/components/snackbar.component.scss +99 -0
- package/src/lib/modules/snackbar/components/snackbar.component.ts +18 -0
- package/src/lib/modules/snackbar/models/snackbar.models.ts +10 -0
- package/src/lib/modules/snackbar/services/snackbar.service.ts +40 -0
- package/src/lib/modules/snackbar/snackbar.module.ts +11 -0
- package/src/lib/modules/snackbar/snackbar.theme.scss +93 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.html +47 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.scss +199 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.ts +126 -0
- package/src/lib/modules/summary-card/summary-card.module.ts +18 -0
- package/src/lib/modules/summary-card/summary-card.theme.scss +176 -0
- package/src/lib/shared-ui.module.ts +44 -0
- package/src/lib/styles/global.scss +152 -0
- package/src/lib/styles/utilities.scss +250 -0
- package/src/lib/utils/constants.ts +11 -0
- package/src/lib/utils/storage.utils.ts +37 -0
- package/src/lib/utils/string.utils.ts +23 -0
- package/src/lib/utils/translation.utils.ts +87 -0
- package/src/public-api.ts +104 -0
- package/tsconfig.lib.json +15 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { FormConfig } from './configurable-form.model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Example: Basic Form Configuration
|
|
5
|
+
* This is a generic example for testing and demonstration purposes.
|
|
6
|
+
*/
|
|
7
|
+
export const EXAMPLE_FORM_CONFIG: FormConfig = {
|
|
8
|
+
sections: [
|
|
9
|
+
{
|
|
10
|
+
sectionTitle: 'User Information',
|
|
11
|
+
fields: [
|
|
12
|
+
{
|
|
13
|
+
name: 'fullName',
|
|
14
|
+
label: 'Full Name',
|
|
15
|
+
type: 'text',
|
|
16
|
+
placeholder: 'Enter full name',
|
|
17
|
+
required: true,
|
|
18
|
+
class: 'col-12'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'email',
|
|
22
|
+
label: 'Email Address',
|
|
23
|
+
type: 'email',
|
|
24
|
+
placeholder: 'Enter email address',
|
|
25
|
+
required: true,
|
|
26
|
+
class: 'col-6'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'phone',
|
|
30
|
+
label: 'Phone Number',
|
|
31
|
+
type: 'tel',
|
|
32
|
+
placeholder: '+91 9999999999',
|
|
33
|
+
class: 'col-6'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'role',
|
|
37
|
+
label: 'Role',
|
|
38
|
+
type: 'dropdown',
|
|
39
|
+
placeholder: 'Select Role',
|
|
40
|
+
options: [
|
|
41
|
+
{ label: 'Admin', value: 'admin' },
|
|
42
|
+
{ label: 'User', value: 'user' },
|
|
43
|
+
{ label: 'Guest', value: 'guest' }
|
|
44
|
+
],
|
|
45
|
+
class: 'col-12'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
sectionTitle: 'Preferences',
|
|
51
|
+
fields: [
|
|
52
|
+
{
|
|
53
|
+
name: 'notifications',
|
|
54
|
+
label: 'Receive Notifications',
|
|
55
|
+
type: 'radio',
|
|
56
|
+
options: [
|
|
57
|
+
{ label: 'Yes', value: 'yes' },
|
|
58
|
+
{ label: 'No', value: 'no' }
|
|
59
|
+
],
|
|
60
|
+
value: 'yes',
|
|
61
|
+
class: 'col-12'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
sectionTitle: 'Documents',
|
|
67
|
+
fields: [
|
|
68
|
+
{
|
|
69
|
+
name: 'profilePicture',
|
|
70
|
+
label: 'Profile Picture',
|
|
71
|
+
type: 'file',
|
|
72
|
+
accept: '.jpg,.png',
|
|
73
|
+
multiple: false,
|
|
74
|
+
helpText: 'Upload a single profile picture (Max 5MB)',
|
|
75
|
+
class: 'col-12'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'certificates',
|
|
79
|
+
label: 'Certificates',
|
|
80
|
+
type: 'file',
|
|
81
|
+
accept: '.pdf,.doc,.docx',
|
|
82
|
+
multiple: true,
|
|
83
|
+
helpText: 'Upload multiple certificates (Max 5MB each)',
|
|
84
|
+
class: 'col-12'
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
entityType: 'User'
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Example: Target Group Configuration
|
|
94
|
+
* Demonstrates composite fields for Age Group and Gender Split
|
|
95
|
+
*/
|
|
96
|
+
export const TARGET_GROUP_CONFIG: FormConfig = {
|
|
97
|
+
sections: [
|
|
98
|
+
{
|
|
99
|
+
sectionTitle: 'Target Group Settings',
|
|
100
|
+
fields: [
|
|
101
|
+
{
|
|
102
|
+
name: 'targetAgeGroup',
|
|
103
|
+
label: 'Target Age Group',
|
|
104
|
+
type: 'composite',
|
|
105
|
+
separator: '-',
|
|
106
|
+
subFields: [
|
|
107
|
+
{
|
|
108
|
+
label: "Min Age",
|
|
109
|
+
name: 'minAge',
|
|
110
|
+
type: 'number',
|
|
111
|
+
placeholder: 'Min Age',
|
|
112
|
+
validationRules: { min: 0 }
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: "Max Age",
|
|
116
|
+
name: 'maxAge',
|
|
117
|
+
type: 'number',
|
|
118
|
+
placeholder: 'Max Age',
|
|
119
|
+
validationRules: { min: 0 }
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
compositeValidationRule: 'minMax',
|
|
123
|
+
class: 'col-12'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'genderSplit',
|
|
127
|
+
label: 'Target Gender Split',
|
|
128
|
+
type: 'composite',
|
|
129
|
+
subFields: [
|
|
130
|
+
{
|
|
131
|
+
label: "Male",
|
|
132
|
+
name: 'malePercentage',
|
|
133
|
+
type: 'number',
|
|
134
|
+
placeholder: 'Male',
|
|
135
|
+
suffixText: '%',
|
|
136
|
+
validationRules: { min: 0, max: 100 }
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: "Female",
|
|
140
|
+
name: 'femalePercentage',
|
|
141
|
+
type: 'number',
|
|
142
|
+
placeholder: 'Female',
|
|
143
|
+
suffixText: '%',
|
|
144
|
+
validationRules: { min: 0, max: 100 }
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
compositeValidationRule: 'percentageTotal',
|
|
148
|
+
class: 'col-12'
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
|
|
154
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export type FieldType = 'text' | 'number' | 'email' | 'tel' | 'password' | 'select' | 'radio' | 'textarea' | 'date' | 'composite' | 'file' | 'dropdown' | 'url';
|
|
2
|
+
export type KeyType = 'KEY_TYPE.UI_INPUT' | 'KEY_TYPE.NESTED_REF_JSON' | 'KEY_TYPE.REF_JSON';
|
|
3
|
+
export type UIType = 'UI_TYPE.TEXT' | 'UI_TYPE.DROP_DOWN' | 'UI_TYPE.RADIO' | 'UI_TYPE.DATE' | 'UI_TYPE.FILE' | 'UI_TYPE.TEXTAREA';
|
|
4
|
+
export type UISubType = 'UI_SUBTYPE.SHORT_TEXT' | 'UI_SUBTYPE.LONG_TEXT' | 'UI_SUBTYPE.NUMBER' | 'UI_SUBTYPE.EMAIL' | 'UI_SUBTYPE.PHONE' | 'UI_SUBTYPE.URL';
|
|
5
|
+
export type OptionDTO = 'OPTION_DTO.REF_DATA' | 'OPTION_DTO.STATIC';
|
|
6
|
+
|
|
7
|
+
export interface FormOption {
|
|
8
|
+
label: string;
|
|
9
|
+
value: any;
|
|
10
|
+
code?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface OptionConfig {
|
|
15
|
+
optionDTO: OptionDTO;
|
|
16
|
+
class?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
labelKey?: string;
|
|
19
|
+
requestKey?: string;
|
|
20
|
+
valueKey?: string;
|
|
21
|
+
staticOptions?: FormOption[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface UIConfig {
|
|
25
|
+
type: UIType;
|
|
26
|
+
subType?: UISubType;
|
|
27
|
+
dependent?: string[]; // Array of field names that depend on this field
|
|
28
|
+
optionConfigs?: OptionConfig;
|
|
29
|
+
minCharacters?: number;
|
|
30
|
+
maxCharacters?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ValidationRules {
|
|
34
|
+
isMandatory?: boolean;
|
|
35
|
+
isRequired?: boolean; // Alias for isMandatory
|
|
36
|
+
minLength?: number;
|
|
37
|
+
maxLength?: number;
|
|
38
|
+
pattern?: string;
|
|
39
|
+
min?: number;
|
|
40
|
+
max?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface UploadedFile {
|
|
44
|
+
name: string;
|
|
45
|
+
size: number;
|
|
46
|
+
type: string;
|
|
47
|
+
url?: string;
|
|
48
|
+
file?: File;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FormField {
|
|
52
|
+
// Core properties
|
|
53
|
+
type?: FieldType;
|
|
54
|
+
name: string;
|
|
55
|
+
label?: string; // i18n key
|
|
56
|
+
jsonKey?: string; // Alternative to 'name' for JSON config
|
|
57
|
+
sequence?: number; // For ordering fields
|
|
58
|
+
|
|
59
|
+
// JSON Config properties
|
|
60
|
+
keyType?: KeyType;
|
|
61
|
+
uiConfig?: UIConfig;
|
|
62
|
+
validationRules?: ValidationRules;
|
|
63
|
+
|
|
64
|
+
// Legacy properties (for backward compatibility)
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
hint?: string;
|
|
67
|
+
helpText?: string;
|
|
68
|
+
options?: FormOption[];
|
|
69
|
+
required?: boolean;
|
|
70
|
+
mandatory?: boolean;
|
|
71
|
+
disabled?: boolean;
|
|
72
|
+
visible?: boolean; // Controls field visibility
|
|
73
|
+
class?: string; // Grid class e.g. 'col-3', 'col-6 col-md-4'
|
|
74
|
+
value?: any;
|
|
75
|
+
icon?: string; // Internal icon
|
|
76
|
+
suffixIcon?: string;
|
|
77
|
+
prefixIcon?: string;
|
|
78
|
+
suffixText?: string;
|
|
79
|
+
readonly?: boolean;
|
|
80
|
+
subFields?: FormField[]; // For composite fields
|
|
81
|
+
separator?: string; // For composite fields like 'Age Range'
|
|
82
|
+
dependsOn?: string; // Name of the field this field depends on
|
|
83
|
+
dependent?: string[]; // Fields that depend on this field
|
|
84
|
+
accept?: string; // For file fields
|
|
85
|
+
multiple?: boolean; // For file fields
|
|
86
|
+
uploadedFiles?: UploadedFile[]; // Track uploaded files
|
|
87
|
+
|
|
88
|
+
// Dynamic options
|
|
89
|
+
optionConfigs?: OptionConfig;
|
|
90
|
+
loadedOptions?: FormOption[]; // Dynamically loaded options
|
|
91
|
+
|
|
92
|
+
// Composite Validators
|
|
93
|
+
compositeValidationRule?: 'minTotal' | 'percentageTotal' | 'minMax';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface FormSection {
|
|
97
|
+
sectionTitle?: string;
|
|
98
|
+
fields: FormField[];
|
|
99
|
+
isRepeater?: boolean; // If true, this section is a FormArray
|
|
100
|
+
addLabel?: string; // Label for 'Add' button if repeater
|
|
101
|
+
removeLabel?: string; // Label for 'Remove' button if repeater
|
|
102
|
+
repeaterItemLabel?: string; // Label template for repeater items (e.g., "Contact")
|
|
103
|
+
formArrayName?: string; // Name for the FormArray control
|
|
104
|
+
noCardLayout?: boolean; // If true, removes the section-card container styling
|
|
105
|
+
collapsible?: boolean; // If true, section can be collapsed
|
|
106
|
+
collapsed?: boolean; // Initial collapsed state
|
|
107
|
+
minItems?: number; // Minimum number of items in repeater (default: 1)
|
|
108
|
+
maxItems?: number; // Maximum number of items in repeater
|
|
109
|
+
class?: string; // CSS class for section container
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface FormConfig {
|
|
113
|
+
sections: FormSection[];
|
|
114
|
+
entityType?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// JSON Config format (from API)
|
|
118
|
+
export interface JsonFieldConfig {
|
|
119
|
+
jsonKey: string;
|
|
120
|
+
sequence: number;
|
|
121
|
+
label: string;
|
|
122
|
+
keyType: KeyType;
|
|
123
|
+
validationRules?: ValidationRules;
|
|
124
|
+
uiConfig: UIConfig;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface JsonFormConfig {
|
|
128
|
+
entityType: string;
|
|
129
|
+
label: string;
|
|
130
|
+
jsonConfig: JsonFieldConfig[];
|
|
131
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { ConfigurableFormComponent } from './component/configurable-form.component';
|
|
5
|
+
import { MaterialModule } from '../material/material.module';
|
|
6
|
+
|
|
7
|
+
@NgModule({
|
|
8
|
+
declarations: [],
|
|
9
|
+
imports: [
|
|
10
|
+
CommonModule,
|
|
11
|
+
ReactiveFormsModule,
|
|
12
|
+
MaterialModule,
|
|
13
|
+
ConfigurableFormComponent
|
|
14
|
+
],
|
|
15
|
+
exports: [
|
|
16
|
+
ConfigurableFormComponent
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
export class ConfigurableFormModule { }
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
|
|
3
|
+
// Default configuration for the configurable form theme
|
|
4
|
+
$default-configurable-form-config: (
|
|
5
|
+
// Colors
|
|
6
|
+
primary-color: #3B82F6,
|
|
7
|
+
surface-background: #ffffff,
|
|
8
|
+
border-color: #D1D5DB,
|
|
9
|
+
text-primary: #111827,
|
|
10
|
+
text-secondary: #6B7280,
|
|
11
|
+
error-color: #DC2626,
|
|
12
|
+
disabled-background: #F3F4F6,
|
|
13
|
+
hover-background: #F9FAFB,
|
|
14
|
+
|
|
15
|
+
// Inputs specific
|
|
16
|
+
input-border-color: #D1D5DB,
|
|
17
|
+
input-focus-border-color: #3B82F6,
|
|
18
|
+
input-hover-border-color: #9CA3AF,
|
|
19
|
+
input-bg: #ffffff,
|
|
20
|
+
|
|
21
|
+
// Dimensions
|
|
22
|
+
section-radius: 12px,
|
|
23
|
+
section-padding: 2rem,
|
|
24
|
+
section-spacing: 1.5rem,
|
|
25
|
+
input-radius: 8px,
|
|
26
|
+
input-padding-y: 0.625rem,
|
|
27
|
+
input-padding-x: 0.875rem,
|
|
28
|
+
|
|
29
|
+
// Typography
|
|
30
|
+
font-family: (-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif),
|
|
31
|
+
section-title-size: 1.25rem,
|
|
32
|
+
section-title-weight: 600,
|
|
33
|
+
label-size: 0.875rem,
|
|
34
|
+
label-weight: 600,
|
|
35
|
+
input-font-size: 0.875rem,
|
|
36
|
+
hint-size: 0.75rem,
|
|
37
|
+
|
|
38
|
+
// Shadows
|
|
39
|
+
section-shadow: (0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Mixin to generate CSS variables for the configurable form component
|
|
43
|
+
@mixin configurable-form-theme($user-config: ()) {
|
|
44
|
+
// Merge user config with defaults
|
|
45
|
+
$config: map.merge($default-configurable-form-config, $user-config);
|
|
46
|
+
|
|
47
|
+
// Generate CSS Variables
|
|
48
|
+
--cf-primary-color: #{map.get($config, primary-color)};
|
|
49
|
+
--cf-surface-background: #{map.get($config, surface-background)};
|
|
50
|
+
--cf-border-color: #{map.get($config, border-color)};
|
|
51
|
+
--cf-text-primary: #{map.get($config, text-primary)};
|
|
52
|
+
--cf-text-secondary: #{map.get($config, text-secondary)};
|
|
53
|
+
--cf-error-color: #{map.get($config, error-color)};
|
|
54
|
+
--cf-disabled-background: #{map.get($config, disabled-background)};
|
|
55
|
+
--cf-hover-background: #{map.get($config, hover-background)};
|
|
56
|
+
|
|
57
|
+
--cf-input-border-color: #{map.get($config, input-border-color)};
|
|
58
|
+
--cf-input-focus-border-color: #{map.get($config, input-focus-border-color)};
|
|
59
|
+
--cf-input-hover-border-color: #{map.get($config, input-hover-border-color)};
|
|
60
|
+
--cf-input-bg: #{map.get($config, input-bg)};
|
|
61
|
+
|
|
62
|
+
--cf-section-radius: #{map.get($config, section-radius)};
|
|
63
|
+
--cf-section-padding: #{map.get($config, section-padding)};
|
|
64
|
+
--cf-section-spacing: #{map.get($config, section-spacing)};
|
|
65
|
+
--cf-input-radius: #{map.get($config, input-radius)};
|
|
66
|
+
--cf-input-padding-y: #{map.get($config, input-padding-y)};
|
|
67
|
+
--cf-input-padding-x: #{map.get($config, input-padding-x)};
|
|
68
|
+
|
|
69
|
+
--cf-font-family: #{map.get($config, font-family)};
|
|
70
|
+
--cf-section-title-size: #{map.get($config, section-title-size)};
|
|
71
|
+
--cf-section-title-weight: #{map.get($config, section-title-weight)};
|
|
72
|
+
--cf-label-size: #{map.get($config, label-size)};
|
|
73
|
+
--cf-label-weight: #{map.get($config, label-weight)};
|
|
74
|
+
--cf-input-font-size: #{map.get($config, input-font-size)};
|
|
75
|
+
--cf-hint-size: #{map.get($config, hint-size)};
|
|
76
|
+
|
|
77
|
+
--cf-section-shadow: #{map.get($config, section-shadow)};
|
|
78
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<div *ngIf="isOpen" class="cc-modal-backdrop"
|
|
2
|
+
[ngClass]="{'cc-modal-backdrop--side-panel': mergedConfig.type === 'side-panel'}"
|
|
3
|
+
(click)="onBackdropClick($event)" role="dialog" [attr.aria-modal]="true"
|
|
4
|
+
[attr.aria-labelledby]="'modal-title-' + mergedConfig.title" [attr.aria-label]="mergedConfig.ariaLabel"
|
|
5
|
+
[attr.aria-describedby]="mergedConfig.ariaDescribedBy">
|
|
6
|
+
|
|
7
|
+
<div class="cc-modal-container {{ mergedConfig.customClass }}"
|
|
8
|
+
[ngClass]="{'side-panel': mergedConfig.type === 'side-panel'}"
|
|
9
|
+
[ngStyle]="getModalStyles()" (click)="$event.stopPropagation()">
|
|
10
|
+
|
|
11
|
+
<!-- Header -->
|
|
12
|
+
<div [ngClass]="getHeaderClass()" [style.background-color]="mergedConfig.headerBackgroundColor"
|
|
13
|
+
[style.border-bottom]="mergedConfig.headerBorderBottom">
|
|
14
|
+
<div class="modal-header__content">
|
|
15
|
+
<!-- Icon (Optional) -->
|
|
16
|
+
<span *ngIf="mergedConfig.icon" class="modal-header__icon">
|
|
17
|
+
<ng-container [ngSwitch]="resolveIconType(mergedConfig.icon)">
|
|
18
|
+
<mat-icon *ngSwitchCase="'material'" [style.color]="getIconColor(mergedConfig.icon)">
|
|
19
|
+
{{ getIconValue(mergedConfig.icon) }}
|
|
20
|
+
</mat-icon>
|
|
21
|
+
<img *ngSwitchCase="'custom'" [src]="getIconValue(mergedConfig.icon)"
|
|
22
|
+
[attr.alt]="mergedConfig.labels?.iconAltText || mergedConfig.title + ' icon'"
|
|
23
|
+
class="modal-header__custom-icon">
|
|
24
|
+
<img *ngSwitchCase="'img'" [src]="getIconValue(mergedConfig.icon)"
|
|
25
|
+
[attr.alt]="mergedConfig.labels?.iconAltText || mergedConfig.title + ' icon'"
|
|
26
|
+
class="modal-header__custom-icon">
|
|
27
|
+
</ng-container>
|
|
28
|
+
</span>
|
|
29
|
+
|
|
30
|
+
<!-- Title -->
|
|
31
|
+
<h2 class="modal-header__title" [id]="'modal-title-' + mergedConfig.title"
|
|
32
|
+
[style.color]="mergedConfig.headerTextColor">
|
|
33
|
+
{{ mergedConfig.title }}
|
|
34
|
+
</h2>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<!-- Code Snippet Button -->
|
|
38
|
+
<button *ngIf="mergedConfig.showCodeSnippetButton" type="button" class="modal-header__code-btn"
|
|
39
|
+
(click)="onShowCodeSnippet()" [attr.aria-label]="mergedConfig.labels?.codeSnippetAriaLabel"
|
|
40
|
+
[attr.title]="mergedConfig.labels?.codeSnippetTitle">
|
|
41
|
+
<mat-icon>code</mat-icon>
|
|
42
|
+
</button>
|
|
43
|
+
|
|
44
|
+
<!-- Close Button -->
|
|
45
|
+
<button *ngIf="mergedConfig.showCloseButton" type="button" class="modal-header__close" (click)="onClose()"
|
|
46
|
+
[attr.aria-label]="mergedConfig.labels?.closeAriaLabel">
|
|
47
|
+
<mat-icon>close</mat-icon>
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<!-- Body (Content Projection) -->
|
|
52
|
+
<div class="cc-modal-body" [ngClass]="{'cc-modal-body--form-mode': mergedConfig.formMode}" [style.padding]="mergedConfig.padding" [style.color]="mergedConfig.bodyTextColor">
|
|
53
|
+
<ng-content></ng-content>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Footer -->
|
|
57
|
+
<div class="cc-modal-footer" [style.background-color]="mergedConfig.footerBackgroundColor"
|
|
58
|
+
[style.border-top]="mergedConfig.footerBorderTop">
|
|
59
|
+
|
|
60
|
+
<ng-container *ngIf="!mergedConfig.customFooter">
|
|
61
|
+
<button *ngIf="mergedConfig.cancelButton?.show" type="button" class="cc-btn cc-btn-secondary"
|
|
62
|
+
(click)="onCancel()">
|
|
63
|
+
{{ mergedConfig.cancelButton?.label }}
|
|
64
|
+
</button>
|
|
65
|
+
|
|
66
|
+
<button type="button" [ngClass]="getConfirmButtonClass()"
|
|
67
|
+
[disabled]="confirmDisabled || mergedConfig.confirmButton.disabled || confirmLoading || mergedConfig.confirmButton.loading"
|
|
68
|
+
(click)="onConfirm()">
|
|
69
|
+
<span *ngIf="confirmLoading || mergedConfig.confirmButton.loading" class="cc-btn-spinner"></span>
|
|
70
|
+
{{ mergedConfig.confirmButton.label }}
|
|
71
|
+
</button>
|
|
72
|
+
</ng-container>
|
|
73
|
+
|
|
74
|
+
<ng-content select="[cc-modal-footer]"></ng-content>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|