@masterteam/form-builder 0.0.6 → 0.0.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterteam/form-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"directory": "../../../dist/masterteam/form-builder",
|
|
6
6
|
"linkDirectory": true,
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"rxjs": "^7.8.2",
|
|
20
20
|
"tailwindcss": "^4.1.17",
|
|
21
21
|
"tailwindcss-primeui": "^0.6.1",
|
|
22
|
-
"@masterteam/properties": "^0.0.
|
|
23
|
-
"@masterteam/forms": "^0.0.
|
|
24
|
-
"@masterteam/
|
|
25
|
-
"@masterteam/
|
|
22
|
+
"@masterteam/properties": "^0.0.30",
|
|
23
|
+
"@masterteam/forms": "^0.0.35",
|
|
24
|
+
"@masterteam/components": "^0.0.86",
|
|
25
|
+
"@masterteam/icons": "^0.0.13"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"exports": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as _masterteam_form_builder from '@masterteam/form-builder';
|
|
2
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { OnInit } from '@angular/core';
|
|
3
|
+
import * as _masterteam_form_builder from '@masterteam/form-builder';
|
|
3
4
|
import { LoadingStateShape, CrudStateBase, Response as Response$1 } from '@masterteam/components';
|
|
4
5
|
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
|
5
6
|
import * as rxjs from 'rxjs';
|
|
@@ -15,13 +16,18 @@ declare enum FormBuilderActionKey {
|
|
|
15
16
|
UpdateField = "updateField",
|
|
16
17
|
DeleteField = "deleteField",
|
|
17
18
|
MoveField = "moveField",
|
|
18
|
-
ReorderFields = "reorderFields"
|
|
19
|
+
ReorderFields = "reorderFields",
|
|
20
|
+
AddValidation = "addValidation",
|
|
21
|
+
UpdateValidation = "updateValidation",
|
|
22
|
+
DeleteValidation = "deleteValidation",
|
|
23
|
+
ToggleValidationActive = "toggleValidationActive"
|
|
19
24
|
}
|
|
20
25
|
type FieldWidth = '25' | '50' | '100';
|
|
21
26
|
interface FormField {
|
|
22
27
|
id: string;
|
|
23
28
|
sectionId: string;
|
|
24
|
-
|
|
29
|
+
propertyKey: string;
|
|
30
|
+
property?: PropertyItem;
|
|
25
31
|
width: FieldWidth;
|
|
26
32
|
order: number;
|
|
27
33
|
hiddenInCreation?: boolean;
|
|
@@ -44,6 +50,19 @@ interface FormSection {
|
|
|
44
50
|
interface FormConfiguration {
|
|
45
51
|
isActive: boolean;
|
|
46
52
|
sections: FormSection[];
|
|
53
|
+
validations?: ValidationRule[];
|
|
54
|
+
}
|
|
55
|
+
type ValidationSeverity = 'error' | 'warning';
|
|
56
|
+
interface ValidationRule {
|
|
57
|
+
id: string | number;
|
|
58
|
+
formulaTokens: string;
|
|
59
|
+
formulaText: string;
|
|
60
|
+
message: {
|
|
61
|
+
en: string;
|
|
62
|
+
ar: string;
|
|
63
|
+
};
|
|
64
|
+
severity: ValidationSeverity;
|
|
65
|
+
enabled: boolean;
|
|
47
66
|
}
|
|
48
67
|
interface AddSectionPayload {
|
|
49
68
|
name: {
|
|
@@ -60,7 +79,7 @@ interface UpdateSectionPayload {
|
|
|
60
79
|
order?: number;
|
|
61
80
|
}
|
|
62
81
|
interface AddFieldPayload {
|
|
63
|
-
|
|
82
|
+
propertyKey: string;
|
|
64
83
|
width: FieldWidth;
|
|
65
84
|
order?: number;
|
|
66
85
|
hiddenInCreation?: boolean;
|
|
@@ -86,8 +105,30 @@ interface ReorderFieldPayload {
|
|
|
86
105
|
id: string;
|
|
87
106
|
order: number;
|
|
88
107
|
}
|
|
108
|
+
interface AddValidationPayload {
|
|
109
|
+
formulaTokens: string;
|
|
110
|
+
formulaText: string;
|
|
111
|
+
message: {
|
|
112
|
+
en: string;
|
|
113
|
+
ar: string;
|
|
114
|
+
};
|
|
115
|
+
severity: ValidationSeverity;
|
|
116
|
+
}
|
|
117
|
+
interface UpdateValidationPayload {
|
|
118
|
+
formulaTokens: string;
|
|
119
|
+
formulaText: string;
|
|
120
|
+
message: {
|
|
121
|
+
en: string;
|
|
122
|
+
ar: string;
|
|
123
|
+
};
|
|
124
|
+
severity: ValidationSeverity;
|
|
125
|
+
}
|
|
126
|
+
interface ToggleValidationPayload {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
}
|
|
89
129
|
interface PropertyItem {
|
|
90
|
-
|
|
130
|
+
key: string;
|
|
131
|
+
propertyId?: number;
|
|
91
132
|
name: string | Record<string, string>;
|
|
92
133
|
viewType?: string;
|
|
93
134
|
[key: string]: any;
|
|
@@ -116,8 +157,12 @@ declare class FormBuilderFacade {
|
|
|
116
157
|
readonly formConfiguration: _angular_core.Signal<_masterteam_form_builder.FormConfiguration | null>;
|
|
117
158
|
readonly sections: _angular_core.Signal<_masterteam_form_builder.FormSection[]>;
|
|
118
159
|
readonly properties: _angular_core.Signal<PropertyItem[]>;
|
|
160
|
+
readonly validations: _angular_core.Signal<_masterteam_form_builder.ValidationRule[]>;
|
|
119
161
|
readonly moduleType: _angular_core.Signal<string | null>;
|
|
120
162
|
readonly moduleId: _angular_core.Signal<string | number | null>;
|
|
163
|
+
readonly parentModuleType: _angular_core.Signal<string | null>;
|
|
164
|
+
readonly parentModuleId: _angular_core.Signal<string | number | null>;
|
|
165
|
+
readonly parentPath: _angular_core.Signal<string>;
|
|
121
166
|
readonly isLoadingFormConfiguration: _angular_core.Signal<boolean>;
|
|
122
167
|
readonly isResettingFormConfiguration: _angular_core.Signal<boolean>;
|
|
123
168
|
readonly isAddingSection: _angular_core.Signal<boolean>;
|
|
@@ -127,9 +172,14 @@ declare class FormBuilderFacade {
|
|
|
127
172
|
readonly isUpdatingField: _angular_core.Signal<boolean>;
|
|
128
173
|
readonly isDeletingField: _angular_core.Signal<boolean>;
|
|
129
174
|
readonly isMovingField: _angular_core.Signal<boolean>;
|
|
175
|
+
readonly isAddingValidation: _angular_core.Signal<boolean>;
|
|
176
|
+
readonly isUpdatingValidation: _angular_core.Signal<boolean>;
|
|
177
|
+
readonly isDeletingValidation: _angular_core.Signal<boolean>;
|
|
178
|
+
readonly isTogglingValidation: _angular_core.Signal<boolean>;
|
|
130
179
|
readonly formConfigurationError: _angular_core.Signal<string | null>;
|
|
131
180
|
readonly sectionError: _angular_core.Signal<string | null>;
|
|
132
181
|
readonly fieldError: _angular_core.Signal<string | null>;
|
|
182
|
+
readonly validationError: _angular_core.Signal<string | null>;
|
|
133
183
|
setModuleInfo(moduleType: string, moduleId: string | number, parentModuleType?: string, parentModuleId?: string | number, parentPath?: string): rxjs.Observable<void>;
|
|
134
184
|
resetState(): rxjs.Observable<void>;
|
|
135
185
|
setProperties(properties: PropertyItem[]): rxjs.Observable<void>;
|
|
@@ -143,38 +193,115 @@ declare class FormBuilderFacade {
|
|
|
143
193
|
deleteField(sectionId: string, fieldId: string): rxjs.Observable<void>;
|
|
144
194
|
reorderFields(sectionId: string, payload: ReorderFieldPayload[]): rxjs.Observable<void>;
|
|
145
195
|
moveField(sectionId: string, fieldId: string, payload: MoveFieldPayload): rxjs.Observable<void>;
|
|
196
|
+
addValidation(payload: AddValidationPayload): rxjs.Observable<void>;
|
|
197
|
+
updateValidation(validationId: string | number, payload: UpdateValidationPayload): rxjs.Observable<void>;
|
|
198
|
+
deleteValidation(validationId: string | number): rxjs.Observable<void>;
|
|
199
|
+
toggleValidationActive(validationId: string | number, payload: ToggleValidationPayload): rxjs.Observable<void>;
|
|
146
200
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormBuilderFacade, never>;
|
|
147
201
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormBuilderFacade>;
|
|
148
202
|
}
|
|
149
203
|
|
|
150
|
-
|
|
204
|
+
type ScopeKey = 'Current' | 'Host' | 'Parent' | 'Ancestors' | 'Children' | 'Descendants' | 'Related' | 'Siblings';
|
|
205
|
+
type PathToken = Exclude<ScopeKey, 'Current'>;
|
|
206
|
+
interface ContextOption {
|
|
207
|
+
contextKey: string;
|
|
208
|
+
label: string;
|
|
209
|
+
}
|
|
210
|
+
interface PathSegment {
|
|
211
|
+
token: PathToken;
|
|
212
|
+
value: string;
|
|
213
|
+
label: string;
|
|
214
|
+
}
|
|
215
|
+
declare class FormBuilder implements OnInit {
|
|
151
216
|
private readonly modalService;
|
|
152
217
|
private readonly confirmationService;
|
|
153
218
|
private readonly translocoService;
|
|
154
219
|
protected readonly facade: FormBuilderFacade;
|
|
220
|
+
private readonly contextService;
|
|
221
|
+
private readonly popovers;
|
|
155
222
|
private dialogRef;
|
|
156
|
-
readonly activeTab: _angular_core.WritableSignal<string>;
|
|
157
|
-
readonly searchQuery: _angular_core.WritableSignal<string>;
|
|
158
223
|
readonly sections: _angular_core.Signal<_masterteam_form_builder.FormSection[]>;
|
|
159
224
|
readonly properties: _angular_core.Signal<PropertyItem[]>;
|
|
160
225
|
readonly isLoading: _angular_core.Signal<boolean>;
|
|
161
226
|
readonly error: _angular_core.Signal<string | null>;
|
|
227
|
+
readonly moduleType: _angular_core.Signal<string | null>;
|
|
228
|
+
readonly moduleId: _angular_core.Signal<string | number | null>;
|
|
229
|
+
readonly parentPath: _angular_core.Signal<string>;
|
|
230
|
+
readonly activeScope: _angular_core.WritableSignal<ScopeKey>;
|
|
231
|
+
readonly searchQuery: _angular_core.WritableSignal<string>;
|
|
232
|
+
readonly isContextLoading: _angular_core.WritableSignal<boolean>;
|
|
233
|
+
private readonly initialContext;
|
|
234
|
+
private readonly currentProperties;
|
|
235
|
+
readonly scopeLoading: _angular_core.WritableSignal<boolean>;
|
|
236
|
+
readonly scopeProperties: _angular_core.WritableSignal<PropertyItem[]>;
|
|
237
|
+
readonly scopePath: _angular_core.WritableSignal<PathSegment[]>;
|
|
238
|
+
readonly scopeSelectedKey: _angular_core.WritableSignal<string>;
|
|
239
|
+
private scopeNavigation;
|
|
240
|
+
private initialRequestId;
|
|
241
|
+
private scopeRequestId;
|
|
242
|
+
private lastContextKey;
|
|
243
|
+
private readonly contextKey;
|
|
244
|
+
private readonly usedPropertyKeys;
|
|
162
245
|
private readonly propertiesMap;
|
|
163
|
-
|
|
164
|
-
readonly
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
readonly filteredPropertiesByTab: _angular_core.Signal<{
|
|
170
|
-
id: string;
|
|
171
|
-
title: string;
|
|
172
|
-
properties: PropertyItem[];
|
|
246
|
+
/** Navigation options from initial context */
|
|
247
|
+
readonly baseScopeContexts: _angular_core.Signal<Record<ScopeKey, ContextOption[]>>;
|
|
248
|
+
/** Available scope tabs */
|
|
249
|
+
readonly scopeOptions: _angular_core.Signal<{
|
|
250
|
+
key: ScopeKey;
|
|
251
|
+
label: string;
|
|
173
252
|
}[]>;
|
|
253
|
+
/** Enriched sections for display */
|
|
254
|
+
readonly enrichedSections: _angular_core.Signal<EnrichedFormSection[]>;
|
|
174
255
|
constructor();
|
|
256
|
+
ngOnInit(): void;
|
|
257
|
+
private loadInitialContext;
|
|
258
|
+
onScopeChange(scope: ScopeKey): void;
|
|
259
|
+
private loadScopeContext;
|
|
260
|
+
private resetScopeState;
|
|
261
|
+
getScopeBaseContexts(scope: ScopeKey): ContextOption[];
|
|
262
|
+
/** Template calls this with scope.key */
|
|
263
|
+
getScopePath(_scope?: ScopeKey): PathSegment[];
|
|
264
|
+
getTokenLabel(token: PathToken): string;
|
|
265
|
+
getScopeSegmentLabel(_scope: ScopeKey, index: number): string;
|
|
266
|
+
getScopeSegmentOptions(_scope: ScopeKey, index: number): ContextOption[];
|
|
267
|
+
setScopeSegmentValue(_scope: ScopeKey, index: number, contextKey: string, label?: string): void;
|
|
268
|
+
private findOptionLabel;
|
|
269
|
+
/** Template handler: hide popover first, then set value (like formula-builder) */
|
|
270
|
+
onSetScopeSegmentValue(scope: ScopeKey, index: number, contextKey: string, popover: {
|
|
271
|
+
hide: () => void;
|
|
272
|
+
}): void;
|
|
273
|
+
addScopeSegment(_scope: ScopeKey, token: PathToken): void;
|
|
274
|
+
/** Template handler: hide popover first, then add segment (like formula-builder) */
|
|
275
|
+
onAddScopeSegment(scope: ScopeKey, token: PathToken, popover: {
|
|
276
|
+
hide: () => void;
|
|
277
|
+
}): void;
|
|
278
|
+
getScopeNextTokens(_scope?: ScopeKey): PathToken[];
|
|
279
|
+
canAddNextScopeSegment(_scope?: ScopeKey): boolean;
|
|
280
|
+
canRemoveScopePath(_scope?: ScopeKey): boolean;
|
|
281
|
+
removeScopePath(_scope?: ScopeKey): void;
|
|
282
|
+
/** Template-compatible version (returns properties array for the scope) */
|
|
283
|
+
getScopeProperties(_scope?: ScopeKey): PropertyItem[];
|
|
284
|
+
getScopePropertyOptions(_scope?: ScopeKey): Array<{
|
|
285
|
+
key: string;
|
|
286
|
+
name: string;
|
|
287
|
+
}>;
|
|
288
|
+
getScopeSelectedPropertyKey(_scope?: ScopeKey): string;
|
|
289
|
+
setScopeSelectedProperty(_scope: ScopeKey, key: string): void;
|
|
290
|
+
getScopeSelectedProperty(_scope?: ScopeKey): PropertyItem | null;
|
|
291
|
+
getFilteredProperties(_scope?: ScopeKey): PropertyItem[];
|
|
292
|
+
isScopePropertiesLoading(_scope?: ScopeKey): boolean;
|
|
293
|
+
getPropertyLabel(property: PropertyItem): string;
|
|
294
|
+
private hideAllPopovers;
|
|
295
|
+
private getNavigationOptionsByToken;
|
|
296
|
+
private resolvePropertyName;
|
|
297
|
+
private createContextOption;
|
|
298
|
+
private formatContextLabel;
|
|
299
|
+
private formatContextKey;
|
|
300
|
+
private mergeContextOptions;
|
|
175
301
|
drop(event: CdkDragDrop<EnrichedFormField[] | PropertyItem[]>): void;
|
|
176
302
|
addSection(): void;
|
|
177
303
|
openPreview(): void;
|
|
304
|
+
openValidationRules(): void;
|
|
178
305
|
resetFormConfiguration(): void;
|
|
179
306
|
noReturnPredicate: () => boolean;
|
|
180
307
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormBuilder, never>;
|
|
@@ -266,6 +393,28 @@ declare class MoveField {
|
|
|
266
393
|
static readonly type = "[FormBuilder] Move Field";
|
|
267
394
|
constructor(sectionId: string, fieldId: string, payload: MoveFieldPayload);
|
|
268
395
|
}
|
|
396
|
+
declare class AddValidation {
|
|
397
|
+
payload: AddValidationPayload;
|
|
398
|
+
static readonly type = "[FormBuilder] Add Validation";
|
|
399
|
+
constructor(payload: AddValidationPayload);
|
|
400
|
+
}
|
|
401
|
+
declare class UpdateValidation {
|
|
402
|
+
validationId: string | number;
|
|
403
|
+
payload: UpdateValidationPayload;
|
|
404
|
+
static readonly type = "[FormBuilder] Update Validation";
|
|
405
|
+
constructor(validationId: string | number, payload: UpdateValidationPayload);
|
|
406
|
+
}
|
|
407
|
+
declare class DeleteValidation {
|
|
408
|
+
validationId: string | number;
|
|
409
|
+
static readonly type = "[FormBuilder] Delete Validation";
|
|
410
|
+
constructor(validationId: string | number);
|
|
411
|
+
}
|
|
412
|
+
declare class ToggleValidationActive {
|
|
413
|
+
validationId: string | number;
|
|
414
|
+
payload: ToggleValidationPayload;
|
|
415
|
+
static readonly type = "[FormBuilder] Toggle Validation Active";
|
|
416
|
+
constructor(validationId: string | number, payload: ToggleValidationPayload);
|
|
417
|
+
}
|
|
269
418
|
|
|
270
419
|
declare class FormBuilderState extends CrudStateBase<FormSection, FormBuilderStateModel, FormBuilderActionKey> {
|
|
271
420
|
private http;
|
|
@@ -276,7 +425,11 @@ declare class FormBuilderState extends CrudStateBase<FormSection, FormBuilderSta
|
|
|
276
425
|
static getSections(state: FormBuilderStateModel): FormSection[];
|
|
277
426
|
static getModuleType(state: FormBuilderStateModel): string | null;
|
|
278
427
|
static getModuleId(state: FormBuilderStateModel): string | number | null;
|
|
428
|
+
static getParentModuleType(state: FormBuilderStateModel): string | null;
|
|
429
|
+
static getParentModuleId(state: FormBuilderStateModel): string | number | null;
|
|
430
|
+
static getParentPath(state: FormBuilderStateModel): string;
|
|
279
431
|
static getProperties(state: FormBuilderStateModel): _masterteam_form_builder.PropertyItem[];
|
|
432
|
+
static getValidations(state: FormBuilderStateModel): ValidationRule[];
|
|
280
433
|
setModuleInfo(ctx: StateContext<FormBuilderStateModel>, action: SetModuleInfo): void;
|
|
281
434
|
resetState(ctx: StateContext<FormBuilderStateModel>): void;
|
|
282
435
|
setProperties(ctx: StateContext<FormBuilderStateModel>, action: SetProperties): void;
|
|
@@ -297,9 +450,15 @@ declare class FormBuilderState extends CrudStateBase<FormSection, FormBuilderSta
|
|
|
297
450
|
fields: FormField[];
|
|
298
451
|
}>>;
|
|
299
452
|
moveField(ctx: StateContext<FormBuilderStateModel>, action: MoveField): rxjs.Observable<Response$1<FormField>>;
|
|
453
|
+
addValidation(ctx: StateContext<FormBuilderStateModel>, action: AddValidation): rxjs.Observable<Response$1<ValidationRule>>;
|
|
454
|
+
updateValidation(ctx: StateContext<FormBuilderStateModel>, action: UpdateValidation): rxjs.Observable<Response$1<ValidationRule>>;
|
|
455
|
+
deleteValidation(ctx: StateContext<FormBuilderStateModel>, action: DeleteValidation): rxjs.Observable<Response$1<{
|
|
456
|
+
id: string | number;
|
|
457
|
+
}>>;
|
|
458
|
+
toggleValidationActive(ctx: StateContext<FormBuilderStateModel>, action: ToggleValidationActive): rxjs.Observable<Response$1<ValidationRule>>;
|
|
300
459
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormBuilderState, never>;
|
|
301
460
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormBuilderState>;
|
|
302
461
|
}
|
|
303
462
|
|
|
304
|
-
export { AddField, AddSection, DeleteField, DeleteSection, FormBuilder, FormBuilderActionKey, FormBuilderFacade, FormBuilderState, GetFormConfiguration, MoveField, ReorderFields, ResetFormBuilderState, ResetFormConfiguration, SetModuleInfo, SetProperties, UpdateField, UpdateSection };
|
|
305
|
-
export type { AddFieldPayload, AddSectionPayload, EnrichedFormField, EnrichedFormSection, FieldWidth, FormBuilderStateModel, FormConfiguration, FormField, FormSection, MoveFieldPayload, PropertyItem, ReorderFieldPayload, Response, UpdateFieldPayload, UpdateSectionPayload };
|
|
463
|
+
export { AddField, AddSection, AddValidation, DeleteField, DeleteSection, DeleteValidation, FormBuilder, FormBuilderActionKey, FormBuilderFacade, FormBuilderState, GetFormConfiguration, MoveField, ReorderFields, ResetFormBuilderState, ResetFormConfiguration, SetModuleInfo, SetProperties, ToggleValidationActive, UpdateField, UpdateSection, UpdateValidation };
|
|
464
|
+
export type { AddFieldPayload, AddSectionPayload, AddValidationPayload, EnrichedFormField, EnrichedFormSection, FieldWidth, FormBuilderStateModel, FormConfiguration, FormField, FormSection, MoveFieldPayload, PropertyItem, ReorderFieldPayload, Response, ToggleValidationPayload, UpdateFieldPayload, UpdateSectionPayload, UpdateValidationPayload, ValidationRule, ValidationSeverity };
|