@masterteam/form-builder 0.0.2 → 0.0.3

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 (33) hide show
  1. package/assets/form-builder.css +2 -4
  2. package/fesm2022/masterteam-form-builder.mjs +1908 -0
  3. package/fesm2022/masterteam-form-builder.mjs.map +1 -0
  4. package/package.json +16 -16
  5. package/types/masterteam-form-builder.d.ts +297 -0
  6. package/.angular/cache/21.0.2/ng-packagr/db70d8f07b5a2d2d1c3124ca92e8d56d14fb894dce4d4867ba7c0db29ba913a3 +0 -1
  7. package/.angular/cache/21.0.2/ng-packagr/tsbuildinfo/masterteam-form-builder.tsbuildinfo +0 -1
  8. package/BACKEND_API_SPEC.md +0 -338
  9. package/angular.json +0 -26
  10. package/ng-package.json +0 -13
  11. package/src/lib/fb-field-conditions/condition-constants.ts +0 -262
  12. package/src/lib/fb-field-conditions/fb-field-conditions.html +0 -35
  13. package/src/lib/fb-field-conditions/fb-field-conditions.ts +0 -123
  14. package/src/lib/fb-field-form/fb-field-form.html +0 -59
  15. package/src/lib/fb-field-form/fb-field-form.ts +0 -250
  16. package/src/lib/fb-preview-form/fb-preview-form.html +0 -31
  17. package/src/lib/fb-preview-form/fb-preview-form.ts +0 -147
  18. package/src/lib/fb-section/fb-section.html +0 -130
  19. package/src/lib/fb-section/fb-section.ts +0 -211
  20. package/src/lib/fb-section-form/fb-section-form.html +0 -38
  21. package/src/lib/fb-section-form/fb-section-form.ts +0 -128
  22. package/src/lib/form-builder.html +0 -166
  23. package/src/lib/form-builder.model.ts +0 -27
  24. package/src/lib/form-builder.scss +0 -20
  25. package/src/lib/form-builder.ts +0 -208
  26. package/src/public-api.ts +0 -6
  27. package/src/store/form-builder/api.model.ts +0 -13
  28. package/src/store/form-builder/form-builder.actions.ts +0 -113
  29. package/src/store/form-builder/form-builder.facade.ts +0 -207
  30. package/src/store/form-builder/form-builder.model.ts +0 -147
  31. package/src/store/form-builder/form-builder.state.ts +0 -668
  32. package/src/store/form-builder/index.ts +0 -5
  33. package/tsconfig.json +0 -31
@@ -1,338 +0,0 @@
1
- # Form Builder - Backend API Specification
2
-
3
- ## Data Models
4
-
5
- ### FormConfiguration
6
-
7
- ```typescript
8
- interface FormConfiguration {
9
- isActive: boolean;
10
- sections: FormSection[];
11
- }
12
- ```
13
-
14
- ### FormSection
15
-
16
- ```typescript
17
- interface FormSection {
18
- id: string;
19
- name: {
20
- en: string;
21
- ar: string;
22
- };
23
- order: number;
24
- fields: FormField[];
25
- }
26
- ```
27
-
28
- ### FormField
29
-
30
- ```typescript
31
- interface FormField {
32
- id: string;
33
- sectionId: string; // Parent section reference
34
- propertyId: number; // Reference to PropertyItem.id
35
- width: "25" | "50" | "100";
36
- order: number;
37
- hiddenInCreation?: boolean;
38
- }
39
- ```
40
-
41
- > **Note:** `PropertyItem` is already defined in `@masterteam/properties` module.
42
-
43
- ### Response Structure
44
-
45
- ```typescript
46
- interface Response<T> {
47
- endpoint: string;
48
- status: number;
49
- code: number;
50
- locale: string;
51
- message?: string | null;
52
- errors?: any | null;
53
- data: T;
54
- cacheSession?: string;
55
- }
56
- ```
57
-
58
- ---
59
-
60
- ## API Endpoints
61
-
62
- ### Base URL
63
- ```
64
- /api/v1/form-configurations
65
- ```
66
-
67
- ### URL Pattern
68
- ```
69
- /api/v1/form-configurations/{moduleType}/{moduleId}
70
- /api/v1/form-configurations/{levelType}/{levelId}/{moduleType}/{moduleId}
71
- ```
72
-
73
- **Examples:**
74
- - `/api/v1/form-configurations/level/1` - Level form configuration
75
- - `/api/v1/form-configurations/module/123` - Direct module
76
- - `/api/v1/form-configurations/level/1/module/123` - Module nested under level
77
-
78
- ---
79
-
80
- ## Form Configuration
81
-
82
- | Method | Endpoint | Description |
83
- |--------|----------|-------------|
84
- | GET | `/{moduleType}/{moduleId}` | Get form configuration |
85
- | GET | `/{levelType}/{levelId}/{moduleType}/{moduleId}` | Get nested form configuration |
86
-
87
- ---
88
-
89
- ## Section Operations
90
-
91
- | Method | Endpoint | Description |
92
- |--------|----------|-------------|
93
- | POST | `.../sections` | Add section |
94
- | PUT | `.../sections/{sectionId}` | Update section |
95
- | DELETE | `.../sections/{sectionId}` | Delete section |
96
-
97
- ---
98
-
99
- ## Field Operations
100
-
101
- | Method | Endpoint | Description |
102
- |--------|----------|-------------|
103
- | POST | `.../sections/{sectionId}/fields` | Add field to section |
104
- | PUT | `.../sections/{sectionId}/fields/{fieldId}` | Update field |
105
- | PUT | `.../sections/{sectionId}/fields/{fieldId}/move` | Move field to another section |
106
- | DELETE | `.../sections/{sectionId}/fields/{fieldId}` | Delete field |
107
-
108
- ---
109
-
110
- ## Sample Requests & Responses
111
-
112
- ### Get Form Configuration
113
-
114
- **GET /api/v1/form-configurations/level/1/module/123**
115
-
116
- ```json
117
- {
118
- "endpoint": "/api/v1/form-configurations/level/1/module/123",
119
- "status": 200,
120
- "code": 0,
121
- "locale": "en",
122
- "message": null,
123
- "data": {
124
- "isActive": false,
125
- "sections": [
126
- {
127
- "id": "section-1",
128
- "name": { "en": "Basic Info", "ar": "معلومات أساسية" },
129
- "order": 0,
130
- "fields": [
131
- { "id": "field-1", "sectionId": "section-1", "propertyId": 101, "width": "100", "order": 0, "hiddenInCreation": false },
132
- { "id": "field-2", "sectionId": "section-1", "propertyId": 102, "width": "50", "order": 1, "hiddenInCreation": true }
133
- ]
134
- },
135
- {
136
- "id": "section-2",
137
- "name": { "en": "Details", "ar": "تفاصيل" },
138
- "order": 1,
139
- "fields": []
140
- }
141
- ]
142
- }
143
- }
144
- ```
145
-
146
- ---
147
-
148
- ### Section CRUD
149
-
150
- **POST .../sections** - Add Section
151
-
152
- Request:
153
- ```json
154
- {
155
- "name": { "en": "New Section", "ar": "قسم جديد" },
156
- "order": 2
157
- }
158
- ```
159
-
160
- Response:
161
- ```json
162
- {
163
- "status": 201,
164
- "code": 0,
165
- "locale": "en",
166
- "data": {
167
- "id": "section-3",
168
- "name": { "en": "New Section", "ar": "قسم جديد" },
169
- "order": 2,
170
- "fields": []
171
- }
172
- }
173
- ```
174
-
175
- **PUT .../sections/section-3** - Update Section
176
-
177
- Request:
178
- ```json
179
- {
180
- "name": { "en": "Updated Section", "ar": "قسم محدث" },
181
- "order": 0
182
- }
183
- ```
184
-
185
- Response:
186
- ```json
187
- {
188
- "status": 200,
189
- "code": 0,
190
- "locale": "en",
191
- "data": {
192
- "id": "section-3",
193
- "name": { "en": "Updated Section", "ar": "قسم محدث" },
194
- "order": 0,
195
- "fields": []
196
- }
197
- }
198
- ```
199
-
200
- **DELETE .../sections/section-3** - Delete Section
201
-
202
- Response:
203
- ```json
204
- {
205
- "status": 200,
206
- "code": 0,
207
- "locale": "en",
208
- "data": {
209
- "id": "section-3"
210
- }
211
- }
212
- ```
213
-
214
- ---
215
-
216
- ### Field CRUD
217
-
218
- **POST .../sections/section-1/fields** - Add Field
219
-
220
- Request:
221
- ```json
222
- {
223
- "propertyId": 103,
224
- "width": "50",
225
- "order": 2,
226
- "hiddenInCreation": false
227
- }
228
- ```
229
-
230
- Response:
231
- ```json
232
- {
233
- "status": 201,
234
- "code": 0,
235
- "locale": "en",
236
- "data": {
237
- "id": "field-3",
238
- "sectionId": "section-1",
239
- "propertyId": 103,
240
- "width": "50",
241
- "order": 2,
242
- "hiddenInCreation": false
243
- }
244
- }
245
- ```
246
-
247
- **PUT .../sections/section-1/fields/field-3** - Update Field
248
-
249
- Request:
250
- ```json
251
- {
252
- "width": "100",
253
- "order": 0,
254
- "hiddenInCreation": true
255
- }
256
- ```
257
-
258
- Response:
259
- ```json
260
- {
261
- "status": 200,
262
- "code": 0,
263
- "locale": "en",
264
- "data": {
265
- "id": "field-3",
266
- "sectionId": "section-1",
267
- "propertyId": 103,
268
- "width": "100",
269
- "order": 0,
270
- "hiddenInCreation": true
271
- }
272
- }
273
- ```
274
-
275
- **DELETE .../sections/section-1/fields/field-3** - Delete Field
276
-
277
- Response:
278
- ```json
279
- {
280
- "status": 200,
281
- "code": 0,
282
- "locale": "en",
283
- "data": {
284
- "id": "field-3",
285
- "sectionId": "section-1"
286
- }
287
- }
288
- ```
289
-
290
- ---
291
-
292
- ### Move Field Between Sections
293
-
294
- **PUT .../sections/section-1/fields/field-2/move** - Move Field
295
-
296
- Request:
297
- ```json
298
- {
299
- "targetSectionId": "section-2",
300
- "order": 0
301
- }
302
- ```
303
-
304
- Response:
305
- ```json
306
- {
307
- "status": 200,
308
- "code": 0,
309
- "locale": "en",
310
- "data": {
311
- "id": "field-2",
312
- "sectionId": "section-2",
313
- "propertyId": 102,
314
- "width": "50",
315
- "order": 0,
316
- "hiddenInCreation": true
317
- }
318
- }
319
- ```
320
-
321
- ---
322
-
323
- ## Error Codes
324
-
325
- | HTTP Status | Code | Description |
326
- |-------------|------|-------------|
327
- | 400 | VALIDATION_ERROR | Request validation failed |
328
- | 404 | NOT_FOUND | Resource not found |
329
- | 409 | VERSION_CONFLICT | Optimistic locking conflict |
330
-
331
- ---
332
-
333
- ## Notes
334
-
335
- 1. `propertyId` must reference a valid `PropertyItem.id`
336
- 2. `order` is auto-calculated from array index if not provided
337
- 3. All mutation responses return the affected record for auto-reflect in UI
338
- 4. Deleting a section will also delete all fields within it
package/angular.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/@angular/cli/lib/config/schema.json",
3
- "version": 1,
4
- "cli": {
5
- "packageManager": "pnpm",
6
- "analytics": false
7
- },
8
- "newProjectRoot": "projects",
9
- "projects": {
10
- "@masterteam/icons": {
11
- "projectType": "library",
12
- "root": "./",
13
- "sourceRoot": "src",
14
- "prefix": "mt",
15
- "architect": {
16
- "build": {
17
- "builder": "@angular-devkit/build-angular:ng-packagr",
18
- "options": {
19
- "project": "ng-package.json",
20
- "tsConfig": "./tsconfig.json"
21
- }
22
- }
23
- }
24
- }
25
- }
26
- }
package/ng-package.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../../dist/masterteam/form-builder",
4
- "assets": ["assets/"],
5
- "lib": {
6
- "entryFile": "src/public-api.ts"
7
- },
8
- "allowedNonPeerDependencies": [
9
- "@masterteam/components",
10
- "@masterteam/icons",
11
- "@masterteam/forms"
12
- ]
13
- }
@@ -1,262 +0,0 @@
1
- /**
2
- * Condition Formula Constants
3
- * Static functions and operators for condition formulas (Show/Hide/Enable/Disable)
4
- */
5
-
6
- import type {
7
- FunctionCategoryGroup,
8
- OperatorDefinition,
9
- } from '@masterteam/components/formula';
10
-
11
- /**
12
- * Functions for field conditions
13
- */
14
- export const CONDITION_FUNCTION_CATEGORIES: FunctionCategoryGroup[] = [
15
- {
16
- name: 'Logic',
17
- displayName: 'Field Visibility',
18
- functions: [
19
- {
20
- name: 'SHOW_IF',
21
- category: 'Logic',
22
- description: 'Show this field when condition is true',
23
- signature: 'SHOW_IF(condition)',
24
- parameters: [
25
- {
26
- name: 'condition',
27
- type: 'boolean',
28
- description: 'When true, field is visible',
29
- required: true,
30
- },
31
- ],
32
- returnType: 'boolean',
33
- examples: [
34
- 'SHOW_IF(@Status == "Active")',
35
- 'SHOW_IF(@Type == "Custom")',
36
- ],
37
- },
38
- {
39
- name: 'HIDE_IF',
40
- category: 'Logic',
41
- description: 'Hide this field when condition is true',
42
- signature: 'HIDE_IF(condition)',
43
- parameters: [
44
- {
45
- name: 'condition',
46
- type: 'boolean',
47
- description: 'When true, field is hidden',
48
- required: true,
49
- },
50
- ],
51
- returnType: 'boolean',
52
- examples: ['HIDE_IF(@Status == "Closed")', 'HIDE_IF(ISNULL(@Parent))'],
53
- },
54
- {
55
- name: 'DISABLE_IF',
56
- category: 'Logic',
57
- description: 'Disable this field when condition is true',
58
- signature: 'DISABLE_IF(condition)',
59
- parameters: [
60
- {
61
- name: 'condition',
62
- type: 'boolean',
63
- description: 'When true, field is disabled',
64
- required: true,
65
- },
66
- ],
67
- returnType: 'boolean',
68
- examples: [
69
- 'DISABLE_IF(@IsLocked == true)',
70
- 'DISABLE_IF(@Status == "Approved")',
71
- ],
72
- },
73
- {
74
- name: 'ENABLE_IF',
75
- category: 'Logic',
76
- description: 'Enable this field when condition is true',
77
- signature: 'ENABLE_IF(condition)',
78
- parameters: [
79
- {
80
- name: 'condition',
81
- type: 'boolean',
82
- description: 'When true, field is enabled',
83
- required: true,
84
- },
85
- ],
86
- returnType: 'boolean',
87
- examples: [
88
- 'ENABLE_IF(@Status == "Draft")',
89
- 'ENABLE_IF(@CanEdit == true)',
90
- ],
91
- },
92
- ],
93
- },
94
- {
95
- name: 'Aggregation',
96
- displayName: 'Logic Helpers',
97
- functions: [
98
- {
99
- name: 'AND',
100
- category: 'Aggregation',
101
- description: 'Returns true if all conditions are true',
102
- signature: 'AND(condition1, condition2)',
103
- parameters: [
104
- {
105
- name: 'condition1',
106
- type: 'boolean',
107
- description: 'First condition',
108
- required: true,
109
- },
110
- {
111
- name: 'condition2',
112
- type: 'boolean',
113
- description: 'Second condition',
114
- required: true,
115
- },
116
- ],
117
- returnType: 'boolean',
118
- examples: ['AND(@Status == "Active", @Priority > 0)'],
119
- },
120
- {
121
- name: 'OR',
122
- category: 'Aggregation',
123
- description: 'Returns true if any condition is true',
124
- signature: 'OR(condition1, condition2)',
125
- parameters: [
126
- {
127
- name: 'condition1',
128
- type: 'boolean',
129
- description: 'First condition',
130
- required: true,
131
- },
132
- {
133
- name: 'condition2',
134
- type: 'boolean',
135
- description: 'Second condition',
136
- required: true,
137
- },
138
- ],
139
- returnType: 'boolean',
140
- examples: ['OR(@Status == "Active", @Status == "Pending")'],
141
- },
142
- {
143
- name: 'NOT',
144
- category: 'Aggregation',
145
- description: 'Returns the opposite of the condition',
146
- signature: 'NOT(condition)',
147
- parameters: [
148
- {
149
- name: 'condition',
150
- type: 'boolean',
151
- description: 'The condition to negate',
152
- required: true,
153
- },
154
- ],
155
- returnType: 'boolean',
156
- examples: ['NOT(@IsCompleted)'],
157
- },
158
- {
159
- name: 'ISNULL',
160
- category: 'Aggregation',
161
- description: 'Returns true if value is null or empty',
162
- signature: 'ISNULL(value)',
163
- parameters: [
164
- {
165
- name: 'value',
166
- type: 'any',
167
- description: 'The value to check',
168
- required: true,
169
- },
170
- ],
171
- returnType: 'boolean',
172
- examples: ['ISNULL(@Description)'],
173
- },
174
- {
175
- name: 'CONTAINS',
176
- category: 'Aggregation',
177
- description: 'Returns true if text contains the search string',
178
- signature: 'CONTAINS(text, search)',
179
- parameters: [
180
- {
181
- name: 'text',
182
- type: 'string',
183
- description: 'The text to search in',
184
- required: true,
185
- },
186
- {
187
- name: 'search',
188
- type: 'string',
189
- description: 'The string to search for',
190
- required: true,
191
- },
192
- ],
193
- returnType: 'boolean',
194
- examples: ['CONTAINS(@Name, "Project")'],
195
- },
196
- ],
197
- },
198
- ];
199
-
200
- /**
201
- * Operators for conditions
202
- */
203
- export const CONDITION_OPERATORS: OperatorDefinition[] = [
204
- // Comparison
205
- {
206
- symbol: '==',
207
- name: 'Equal',
208
- type: 'comparison',
209
- description: 'Equal to',
210
- precedence: 3,
211
- },
212
- {
213
- symbol: '!=',
214
- name: 'Not Equal',
215
- type: 'comparison',
216
- description: 'Not equal to',
217
- precedence: 3,
218
- },
219
- {
220
- symbol: '>',
221
- name: 'Greater Than',
222
- type: 'comparison',
223
- description: 'Greater than',
224
- precedence: 4,
225
- },
226
- {
227
- symbol: '<',
228
- name: 'Less Than',
229
- type: 'comparison',
230
- description: 'Less than',
231
- precedence: 4,
232
- },
233
- {
234
- symbol: '>=',
235
- name: 'Greater or Equal',
236
- type: 'comparison',
237
- description: 'Greater than or equal',
238
- precedence: 4,
239
- },
240
- {
241
- symbol: '<=',
242
- name: 'Less or Equal',
243
- type: 'comparison',
244
- description: 'Less than or equal',
245
- precedence: 4,
246
- },
247
- // Logical
248
- {
249
- symbol: '&&',
250
- name: 'And',
251
- type: 'logical',
252
- description: 'Logical AND',
253
- precedence: 2,
254
- },
255
- {
256
- symbol: '||',
257
- name: 'Or',
258
- type: 'logical',
259
- description: 'Logical OR',
260
- precedence: 1,
261
- },
262
- ];
@@ -1,35 +0,0 @@
1
- <ng-container *transloco="let t; prefix: 'formBuilder'">
2
- <div [class]="[modalService.contentClass, 'p-4', 'overflow-y-hidden!']">
3
- <div class="mt-4 h-full overflow-y-auto pb-10 flex flex-col gap-3">
4
- <!-- Formula Toolbar -->
5
- <mt-formula-toolbar
6
- [knownProperties]="propertyKeys()"
7
- [functionCategories]="functionCategories"
8
- [operators]="operators"
9
- [labels]="toolbarLabels"
10
- (onBlockInsert)="onBlockInsert($event)"
11
- />
12
- <!-- Formula Editor -->
13
- <mt-formula-editor
14
- #editor
15
- [placeholder]="t('build-condition-formula')"
16
- [formControl]="formulaControl"
17
- />
18
- </div>
19
- </div>
20
-
21
- <div [class]="modalService.footerClass">
22
- <mt-button
23
- [label]="t('cancel')"
24
- severity="secondary"
25
- [disabled]="submitting()"
26
- (onClick)="onCancel()"
27
- />
28
- <mt-button
29
- [label]="t('save')"
30
- severity="primary"
31
- [loading]="submitting()"
32
- (onClick)="onSave()"
33
- />
34
- </div>
35
- </ng-container>