@masterteam/form-builder 0.0.37 → 0.0.39

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.
@@ -52,6 +52,10 @@
52
52
  "is-read-description": "عند التعطيل، سيتم إخفاء هذا الحقل عن المستخدمين",
53
53
  "is-write": "قابل للتعديل",
54
54
  "is-write-description": "عند التعطيل، سيكون هذا الحقل للقراءة فقط للمستخدمين",
55
+ "edit-label": "تسمية مخصصة",
56
+ "edit-label-description": "استبدل التسمية الافتراضية للحقل بنص خاص بك لكل لغة",
57
+ "label-en": "التسمية (بالإنجليزية)",
58
+ "label-ar": "التسمية (بالعربية)",
55
59
  "hidden": "مخفي",
56
60
  "read-only": "للقراءة فقط",
57
61
  "sections": "أقسام",
@@ -52,6 +52,10 @@
52
52
  "is-read-description": "When disabled, this field will be hidden from users",
53
53
  "is-write": "Editable",
54
54
  "is-write-description": "When disabled, this field will be read-only for users",
55
+ "edit-label": "Custom Label",
56
+ "edit-label-description": "Override the default field label with your own text per language",
57
+ "label-en": "Label (English)",
58
+ "label-ar": "Label (Arabic)",
55
59
  "hidden": "Hidden",
56
60
  "read-only": "Read Only",
57
61
  "sections": "Sections",
@@ -32,9 +32,9 @@ import { CONDITION_FUNCTION_CATEGORIES, CONDITION_OPERATORS, FormulaToolbar, For
32
32
  import { Tooltip } from '@masterteam/components/tooltip';
33
33
  import { ClientForm } from '@masterteam/forms/client-form';
34
34
  import { Table } from '@masterteam/components/table';
35
+ import { startWith, of, map, catchError } from 'rxjs';
35
36
  import { RadioCardsField } from '@masterteam/components/radio-cards-field';
36
37
  import { FormulaBuilder } from '@masterteam/formula-builder';
37
- import { of, map, catchError } from 'rxjs';
38
38
 
39
39
  // ============================================================================
40
40
  // Module Configuration Actions
@@ -80,6 +80,9 @@ class GetFormConfiguration {
80
80
  class ResetFormConfiguration {
81
81
  static type = '[FormBuilder] Reset Form Configuration';
82
82
  }
83
+ class ResetFormFromAppForm {
84
+ static type = '[FormBuilder] Reset Form From App Form';
85
+ }
83
86
  class UpdateFormSettings {
84
87
  payload;
85
88
  static type = '[FormBuilder] Update Form Settings';
@@ -216,6 +219,7 @@ var FormBuilderActionKey;
216
219
  // Form Configuration
217
220
  FormBuilderActionKey["GetFormConfiguration"] = "getFormConfiguration";
218
221
  FormBuilderActionKey["ResetFormConfiguration"] = "resetFormConfiguration";
222
+ FormBuilderActionKey["ResetFormFromAppForm"] = "resetFormFromAppForm";
219
223
  FormBuilderActionKey["UpdateFormSettings"] = "updateFormSettings";
220
224
  // Section CRUD
221
225
  FormBuilderActionKey["AddSection"] = "addSection";
@@ -374,6 +378,19 @@ let FormBuilderState = class FormBuilderState extends CrudStateBase {
374
378
  }),
375
379
  });
376
380
  }
381
+ resetFormFromAppForm(ctx) {
382
+ const state = ctx.getState();
383
+ const apiPath = `${this.getApiPath(state)}/reset-from-app-form`;
384
+ const req$ = this.http.post(apiPath, {});
385
+ return handleApiRequest({
386
+ ctx,
387
+ key: FormBuilderActionKey.ResetFormFromAppForm,
388
+ request$: req$,
389
+ onSuccess: (res) => ({
390
+ formConfiguration: this.normalizeFormConfiguration(res.data),
391
+ }),
392
+ });
393
+ }
377
394
  updateFormSettings(ctx, action) {
378
395
  const state = ctx.getState();
379
396
  const currentConfig = state.formConfiguration;
@@ -939,6 +956,9 @@ __decorate([
939
956
  __decorate([
940
957
  Action(ResetFormConfiguration)
941
958
  ], FormBuilderState.prototype, "resetFormConfiguration", null);
959
+ __decorate([
960
+ Action(ResetFormFromAppForm)
961
+ ], FormBuilderState.prototype, "resetFormFromAppForm", null);
942
962
  __decorate([
943
963
  Action(UpdateFormSettings)
944
964
  ], FormBuilderState.prototype, "updateFormSettings", null);
@@ -1022,7 +1042,7 @@ FormBuilderState = __decorate([
1022
1042
  ], FormBuilderState);
1023
1043
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormBuilderState, decorators: [{
1024
1044
  type: Injectable
1025
- }], propDecorators: { setModuleInfo: [], resetState: [], setProperties: [], setPreviewInfo: [], getFormConfiguration: [], resetFormConfiguration: [], updateFormSettings: [], addSection: [], updateSection: [], reorderSections: [], deleteSection: [], addField: [], updateField: [], deleteField: [], reorderFields: [], moveField: [], addValidation: [], updateValidation: [], deleteValidation: [], toggleValidationActive: [] } });
1045
+ }], propDecorators: { setModuleInfo: [], resetState: [], setProperties: [], setPreviewInfo: [], getFormConfiguration: [], resetFormConfiguration: [], resetFormFromAppForm: [], updateFormSettings: [], addSection: [], updateSection: [], reorderSections: [], deleteSection: [], addField: [], updateField: [], deleteField: [], reorderFields: [], moveField: [], addValidation: [], updateValidation: [], deleteValidation: [], toggleValidationActive: [] } });
1026
1046
 
1027
1047
  class FormBuilderFacade {
1028
1048
  store = inject(Store);
@@ -1045,6 +1065,9 @@ class FormBuilderFacade {
1045
1065
  // ============================================================================
1046
1066
  isLoadingFormConfiguration = computed(() => this.stateSignal().loadingActive.includes(FormBuilderActionKey.GetFormConfiguration), ...(ngDevMode ? [{ debugName: "isLoadingFormConfiguration" }] : /* istanbul ignore next */ []));
1047
1067
  isResettingFormConfiguration = computed(() => this.stateSignal().loadingActive.includes(FormBuilderActionKey.ResetFormConfiguration), ...(ngDevMode ? [{ debugName: "isResettingFormConfiguration" }] : /* istanbul ignore next */ []));
1068
+ isResettingFormFromAppForm = computed(() => this.stateSignal().loadingActive.includes(FormBuilderActionKey.ResetFormFromAppForm), ...(ngDevMode ? [{ debugName: "isResettingFormFromAppForm" }] : /* istanbul ignore next */ []));
1069
+ resetFormFromAppFormError = computed(() => this.stateSignal().errors[FormBuilderActionKey.ResetFormFromAppForm] ??
1070
+ null, ...(ngDevMode ? [{ debugName: "resetFormFromAppFormError" }] : /* istanbul ignore next */ []));
1048
1071
  isUpdatingFormSettings = computed(() => this.stateSignal().loadingActive.includes(FormBuilderActionKey.UpdateFormSettings), ...(ngDevMode ? [{ debugName: "isUpdatingFormSettings" }] : /* istanbul ignore next */ []));
1049
1072
  isAddingSection = computed(() => this.stateSignal().loadingActive.includes(FormBuilderActionKey.AddSection), ...(ngDevMode ? [{ debugName: "isAddingSection" }] : /* istanbul ignore next */ []));
1050
1073
  isUpdatingSection = computed(() => this.stateSignal().loadingActive.includes(FormBuilderActionKey.UpdateSection), ...(ngDevMode ? [{ debugName: "isUpdatingSection" }] : /* istanbul ignore next */ []));
@@ -1110,6 +1133,9 @@ class FormBuilderFacade {
1110
1133
  resetFormConfiguration() {
1111
1134
  return this.store.dispatch(new ResetFormConfiguration());
1112
1135
  }
1136
+ resetFormFromAppForm() {
1137
+ return this.store.dispatch(new ResetFormFromAppForm());
1138
+ }
1113
1139
  updateFormSettings(payload) {
1114
1140
  return this.store.dispatch(new UpdateFormSettings(payload));
1115
1141
  }
@@ -1301,6 +1327,12 @@ class FBFieldForm {
1301
1327
  showHideControl = new FormControl(false);
1302
1328
  isReadControl = new FormControl(true);
1303
1329
  isWriteControl = new FormControl(true);
1330
+ // Custom label override
1331
+ editLabelControl = new FormControl(false);
1332
+ labelEnControl = new FormControl('', { nonNullable: true });
1333
+ labelArControl = new FormControl('', { nonNullable: true });
1334
+ /** Whether the field already had a custom label when the dialog opened. */
1335
+ hadInitialLabel = signal(false, ...(ngDevMode ? [{ debugName: "hadInitialLabel" }] : /* istanbul ignore next */ []));
1304
1336
  formConfig = {
1305
1337
  sections: [
1306
1338
  {
@@ -1398,6 +1430,14 @@ class FBFieldForm {
1398
1430
  // isRead/isWrite controls
1399
1431
  this.isReadControl.patchValue(data.isRead !== false);
1400
1432
  this.isWriteControl.patchValue(data.isWrite !== false);
1433
+ // Custom label override
1434
+ const label = data.label;
1435
+ const hasLabel = !!label &&
1436
+ ((label.en ?? '').trim() !== '' || (label.ar ?? '').trim() !== '');
1437
+ this.hadInitialLabel.set(hasLabel);
1438
+ this.editLabelControl.patchValue(hasLabel);
1439
+ this.labelEnControl.patchValue(label?.en ?? '');
1440
+ this.labelArControl.patchValue(label?.ar ?? '');
1401
1441
  }
1402
1442
  });
1403
1443
  // Cascade: isWrite=true forces isRead=true
@@ -1440,6 +1480,19 @@ class FBFieldForm {
1440
1480
  payload['conditionalDisplayFormula'] = this.showHideControl.value
1441
1481
  ? this.conditionalDisplayFormula()
1442
1482
  : null;
1483
+ // Custom label override:
1484
+ // - toggle on → send the entered ar/en values
1485
+ // - toggle off but a label existed → reset to the inherited label
1486
+ // - toggle off and no label existed → omit (backend keeps as-is)
1487
+ if (this.editLabelControl.value) {
1488
+ payload['label'] = {
1489
+ ar: this.labelArControl.value.trim(),
1490
+ en: this.labelEnControl.value.trim(),
1491
+ };
1492
+ }
1493
+ else if (this.hadInitialLabel()) {
1494
+ payload['useInheritedLabel'] = true;
1495
+ }
1443
1496
  }
1444
1497
  this.submitting.set(true);
1445
1498
  this.facade.updateField(sectionId, field.id, payload).subscribe({
@@ -1487,7 +1540,7 @@ class FBFieldForm {
1487
1540
  });
1488
1541
  }
1489
1542
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FBFieldForm, deps: [], target: i0.ɵɵFactoryTarget.Component });
1490
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FBFieldForm, isStandalone: true, selector: "mt-fb-field-form", inputs: { sectionId: { classPropertyName: "sectionId", publicName: "sectionId", isSignal: true, isRequired: false, transformFunction: null }, initialData: { classPropertyName: "initialData", publicName: "initialData", isSignal: true, isRequired: false, transformFunction: null }, allSections: { classPropertyName: "allSections", publicName: "allSections", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'formBuilder'\">\n <div\n [class]=\"[\n modalService.contentClass,\n 'min-w-0',\n 'p-4',\n 'overflow-y-hidden!',\n 'max-[640px]:p-3',\n ]\"\n >\n <div class=\"mt-2 flex h-full min-h-0 flex-col gap-4 overflow-y-auto pb-10\">\n <mt-dynamic-form\n [formConfig]=\"activeFormConfig()\"\n [formControl]=\"formControl\"\n >\n </mt-dynamic-form>\n\n <!-- isRead Toggle -->\n <mt-toggle-field\n toggleShape=\"card\"\n [label]=\"t('is-read')\"\n [descriptionCard]=\"t('is-read-description')\"\n icon=\"general.eye\"\n [formControl]=\"isReadControl\"\n ></mt-toggle-field>\n\n <!-- isWrite Toggle -->\n <mt-toggle-field\n toggleShape=\"card\"\n [label]=\"t('is-write')\"\n [descriptionCard]=\"t('is-write-description')\"\n icon=\"general.edit-02\"\n [formControl]=\"isWriteControl\"\n ></mt-toggle-field>\n\n @if (!isManageProperties()) {\n <!-- Show/Hide Toggle with Set Conditions -->\n <mt-toggle-field\n toggleShape=\"card\"\n [label]=\"t('show-hide')\"\n [descriptionCard]=\"t('show-hide-description')\"\n icon=\"general.eye\"\n [formControl]=\"showHideControl\"\n class=\"mt-3\"\n >\n <ng-template #toggleCardBottom>\n @if (showHideControl.value) {\n <div class=\"mt-3\">\n <mt-button\n [label]=\"t('set-conditions')\"\n size=\"small\"\n styleClass=\"w-full sm:w-auto\"\n (onClick)=\"onSetConditions()\"\n ></mt-button>\n </div>\n }\n </ng-template>\n </mt-toggle-field>\n }\n </div>\n </div>\n\n <div\n [class]=\"[\n modalService.footerClass,\n '!h-auto',\n 'min-h-0',\n 'flex-col',\n 'gap-2',\n 'sm:flex-row',\n 'sm:items-center',\n 'sm:justify-end',\n ]\"\n >\n @if (initialData() && !isManageProperties()) {\n <mt-button\n [tooltip]=\"t('delete')\"\n severity=\"danger\"\n [variant]=\"'outlined'\"\n icon=\"general.trash-01\"\n [loading]=\"deleting()\"\n [disabled]=\"submitting()\"\n (onClick)=\"onDelete($event)\"\n class=\"self-start sm:me-auto\"\n ></mt-button>\n }\n <mt-button\n [label]=\"t('cancel')\"\n variant=\"outlined\"\n [disabled]=\"submitting() || deleting()\"\n styleClass=\"w-full sm:w-auto\"\n (onClick)=\"onCancel()\"\n >\n </mt-button>\n <mt-button\n [disabled]=\"!formControl.valid || deleting()\"\n [label]=\"t('save')\"\n severity=\"primary\"\n [loading]=\"submitting()\"\n styleClass=\"w-full sm:w-auto\"\n (onClick)=\"onSave()\"\n >\n </mt-button>\n </div>\n</ng-container>\n", dependencies: [{ kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DynamicForm, selector: "mt-dynamic-form", inputs: ["formConfig", "forcedHiddenFieldKeys", "preserveForcedHiddenValues", "visibleSectionKeys"], outputs: ["runtimeMessagesChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: ToggleField, selector: "mt-toggle-field", inputs: ["label", "inputId", "labelPosition", "placeholder", "readonly", "pInputs", "required", "toggleShape", "size", "icon", "descriptionCard"], outputs: ["onChange"] }] });
1543
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FBFieldForm, isStandalone: true, selector: "mt-fb-field-form", inputs: { sectionId: { classPropertyName: "sectionId", publicName: "sectionId", isSignal: true, isRequired: false, transformFunction: null }, initialData: { classPropertyName: "initialData", publicName: "initialData", isSignal: true, isRequired: false, transformFunction: null }, allSections: { classPropertyName: "allSections", publicName: "allSections", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'formBuilder'\">\r\n <div\r\n [class]=\"[\r\n modalService.contentClass,\r\n 'min-w-0',\r\n 'p-4',\r\n 'overflow-y-hidden!',\r\n 'max-[640px]:p-3',\r\n ]\"\r\n >\r\n <div class=\"mt-2 flex h-full min-h-0 flex-col gap-4 overflow-y-auto pb-10\">\r\n <mt-dynamic-form\r\n [formConfig]=\"activeFormConfig()\"\r\n [formControl]=\"formControl\"\r\n >\r\n </mt-dynamic-form>\r\n\r\n <!-- isRead Toggle -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('is-read')\"\r\n [descriptionCard]=\"t('is-read-description')\"\r\n icon=\"general.eye\"\r\n [formControl]=\"isReadControl\"\r\n ></mt-toggle-field>\r\n\r\n <!-- isWrite Toggle -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('is-write')\"\r\n [descriptionCard]=\"t('is-write-description')\"\r\n icon=\"general.edit-02\"\r\n [formControl]=\"isWriteControl\"\r\n ></mt-toggle-field>\r\n\r\n @if (!isManageProperties()) {\r\n <!-- Edit Label Toggle with localized label inputs -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('edit-label')\"\r\n [descriptionCard]=\"t('edit-label-description')\"\r\n icon=\"general.translate-01\"\r\n [formControl]=\"editLabelControl\"\r\n >\r\n <ng-template #toggleCardBottom>\r\n @if (editLabelControl.value) {\r\n <div class=\"mt-3 grid gap-3\">\r\n <mt-text-field\r\n [label]=\"t('label-en')\"\r\n [formControl]=\"labelEnControl\"\r\n ></mt-text-field>\r\n <mt-text-field\r\n [label]=\"t('label-ar')\"\r\n [formControl]=\"labelArControl\"\r\n ></mt-text-field>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-toggle-field>\r\n\r\n <!-- Show/Hide Toggle with Set Conditions -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('show-hide')\"\r\n [descriptionCard]=\"t('show-hide-description')\"\r\n icon=\"general.eye\"\r\n [formControl]=\"showHideControl\"\r\n class=\"mt-3\"\r\n >\r\n <ng-template #toggleCardBottom>\r\n @if (showHideControl.value) {\r\n <div class=\"mt-3\">\r\n <mt-button\r\n [label]=\"t('set-conditions')\"\r\n size=\"small\"\r\n styleClass=\"w-full sm:w-auto\"\r\n (onClick)=\"onSetConditions()\"\r\n ></mt-button>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-toggle-field>\r\n }\r\n </div>\r\n </div>\r\n\r\n <div\r\n [class]=\"[\r\n modalService.footerClass,\r\n '!h-auto',\r\n 'min-h-0',\r\n 'flex-col',\r\n 'gap-2',\r\n 'sm:flex-row',\r\n 'sm:items-center',\r\n 'sm:justify-end',\r\n ]\"\r\n >\r\n @if (initialData() && !isManageProperties()) {\r\n <mt-button\r\n [tooltip]=\"t('delete')\"\r\n severity=\"danger\"\r\n [variant]=\"'outlined'\"\r\n icon=\"general.trash-01\"\r\n [loading]=\"deleting()\"\r\n [disabled]=\"submitting()\"\r\n (onClick)=\"onDelete($event)\"\r\n class=\"self-start sm:me-auto\"\r\n ></mt-button>\r\n }\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n variant=\"outlined\"\r\n [disabled]=\"submitting() || deleting()\"\r\n styleClass=\"w-full sm:w-auto\"\r\n (onClick)=\"onCancel()\"\r\n >\r\n </mt-button>\r\n <mt-button\r\n [disabled]=\"!formControl.valid || deleting()\"\r\n [label]=\"t('save')\"\r\n severity=\"primary\"\r\n [loading]=\"submitting()\"\r\n styleClass=\"w-full sm:w-auto\"\r\n (onClick)=\"onSave()\"\r\n >\r\n </mt-button>\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DynamicForm, selector: "mt-dynamic-form", inputs: ["formConfig", "forcedHiddenFieldKeys", "preserveForcedHiddenValues", "visibleSectionKeys"], outputs: ["runtimeMessagesChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: ToggleField, selector: "mt-toggle-field", inputs: ["label", "inputId", "labelPosition", "placeholder", "readonly", "pInputs", "required", "toggleShape", "size", "icon", "descriptionCard"], outputs: ["onChange"] }, { kind: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "maxLength", "icon", "iconPosition"] }] });
1491
1544
  }
1492
1545
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FBFieldForm, decorators: [{
1493
1546
  type: Component,
@@ -1497,7 +1550,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
1497
1550
  DynamicForm,
1498
1551
  Button,
1499
1552
  ToggleField,
1500
- ], template: "<ng-container *transloco=\"let t; prefix: 'formBuilder'\">\n <div\n [class]=\"[\n modalService.contentClass,\n 'min-w-0',\n 'p-4',\n 'overflow-y-hidden!',\n 'max-[640px]:p-3',\n ]\"\n >\n <div class=\"mt-2 flex h-full min-h-0 flex-col gap-4 overflow-y-auto pb-10\">\n <mt-dynamic-form\n [formConfig]=\"activeFormConfig()\"\n [formControl]=\"formControl\"\n >\n </mt-dynamic-form>\n\n <!-- isRead Toggle -->\n <mt-toggle-field\n toggleShape=\"card\"\n [label]=\"t('is-read')\"\n [descriptionCard]=\"t('is-read-description')\"\n icon=\"general.eye\"\n [formControl]=\"isReadControl\"\n ></mt-toggle-field>\n\n <!-- isWrite Toggle -->\n <mt-toggle-field\n toggleShape=\"card\"\n [label]=\"t('is-write')\"\n [descriptionCard]=\"t('is-write-description')\"\n icon=\"general.edit-02\"\n [formControl]=\"isWriteControl\"\n ></mt-toggle-field>\n\n @if (!isManageProperties()) {\n <!-- Show/Hide Toggle with Set Conditions -->\n <mt-toggle-field\n toggleShape=\"card\"\n [label]=\"t('show-hide')\"\n [descriptionCard]=\"t('show-hide-description')\"\n icon=\"general.eye\"\n [formControl]=\"showHideControl\"\n class=\"mt-3\"\n >\n <ng-template #toggleCardBottom>\n @if (showHideControl.value) {\n <div class=\"mt-3\">\n <mt-button\n [label]=\"t('set-conditions')\"\n size=\"small\"\n styleClass=\"w-full sm:w-auto\"\n (onClick)=\"onSetConditions()\"\n ></mt-button>\n </div>\n }\n </ng-template>\n </mt-toggle-field>\n }\n </div>\n </div>\n\n <div\n [class]=\"[\n modalService.footerClass,\n '!h-auto',\n 'min-h-0',\n 'flex-col',\n 'gap-2',\n 'sm:flex-row',\n 'sm:items-center',\n 'sm:justify-end',\n ]\"\n >\n @if (initialData() && !isManageProperties()) {\n <mt-button\n [tooltip]=\"t('delete')\"\n severity=\"danger\"\n [variant]=\"'outlined'\"\n icon=\"general.trash-01\"\n [loading]=\"deleting()\"\n [disabled]=\"submitting()\"\n (onClick)=\"onDelete($event)\"\n class=\"self-start sm:me-auto\"\n ></mt-button>\n }\n <mt-button\n [label]=\"t('cancel')\"\n variant=\"outlined\"\n [disabled]=\"submitting() || deleting()\"\n styleClass=\"w-full sm:w-auto\"\n (onClick)=\"onCancel()\"\n >\n </mt-button>\n <mt-button\n [disabled]=\"!formControl.valid || deleting()\"\n [label]=\"t('save')\"\n severity=\"primary\"\n [loading]=\"submitting()\"\n styleClass=\"w-full sm:w-auto\"\n (onClick)=\"onSave()\"\n >\n </mt-button>\n </div>\n</ng-container>\n" }]
1553
+ TextField,
1554
+ ], template: "<ng-container *transloco=\"let t; prefix: 'formBuilder'\">\r\n <div\r\n [class]=\"[\r\n modalService.contentClass,\r\n 'min-w-0',\r\n 'p-4',\r\n 'overflow-y-hidden!',\r\n 'max-[640px]:p-3',\r\n ]\"\r\n >\r\n <div class=\"mt-2 flex h-full min-h-0 flex-col gap-4 overflow-y-auto pb-10\">\r\n <mt-dynamic-form\r\n [formConfig]=\"activeFormConfig()\"\r\n [formControl]=\"formControl\"\r\n >\r\n </mt-dynamic-form>\r\n\r\n <!-- isRead Toggle -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('is-read')\"\r\n [descriptionCard]=\"t('is-read-description')\"\r\n icon=\"general.eye\"\r\n [formControl]=\"isReadControl\"\r\n ></mt-toggle-field>\r\n\r\n <!-- isWrite Toggle -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('is-write')\"\r\n [descriptionCard]=\"t('is-write-description')\"\r\n icon=\"general.edit-02\"\r\n [formControl]=\"isWriteControl\"\r\n ></mt-toggle-field>\r\n\r\n @if (!isManageProperties()) {\r\n <!-- Edit Label Toggle with localized label inputs -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('edit-label')\"\r\n [descriptionCard]=\"t('edit-label-description')\"\r\n icon=\"general.translate-01\"\r\n [formControl]=\"editLabelControl\"\r\n >\r\n <ng-template #toggleCardBottom>\r\n @if (editLabelControl.value) {\r\n <div class=\"mt-3 grid gap-3\">\r\n <mt-text-field\r\n [label]=\"t('label-en')\"\r\n [formControl]=\"labelEnControl\"\r\n ></mt-text-field>\r\n <mt-text-field\r\n [label]=\"t('label-ar')\"\r\n [formControl]=\"labelArControl\"\r\n ></mt-text-field>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-toggle-field>\r\n\r\n <!-- Show/Hide Toggle with Set Conditions -->\r\n <mt-toggle-field\r\n toggleShape=\"card\"\r\n [label]=\"t('show-hide')\"\r\n [descriptionCard]=\"t('show-hide-description')\"\r\n icon=\"general.eye\"\r\n [formControl]=\"showHideControl\"\r\n class=\"mt-3\"\r\n >\r\n <ng-template #toggleCardBottom>\r\n @if (showHideControl.value) {\r\n <div class=\"mt-3\">\r\n <mt-button\r\n [label]=\"t('set-conditions')\"\r\n size=\"small\"\r\n styleClass=\"w-full sm:w-auto\"\r\n (onClick)=\"onSetConditions()\"\r\n ></mt-button>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-toggle-field>\r\n }\r\n </div>\r\n </div>\r\n\r\n <div\r\n [class]=\"[\r\n modalService.footerClass,\r\n '!h-auto',\r\n 'min-h-0',\r\n 'flex-col',\r\n 'gap-2',\r\n 'sm:flex-row',\r\n 'sm:items-center',\r\n 'sm:justify-end',\r\n ]\"\r\n >\r\n @if (initialData() && !isManageProperties()) {\r\n <mt-button\r\n [tooltip]=\"t('delete')\"\r\n severity=\"danger\"\r\n [variant]=\"'outlined'\"\r\n icon=\"general.trash-01\"\r\n [loading]=\"deleting()\"\r\n [disabled]=\"submitting()\"\r\n (onClick)=\"onDelete($event)\"\r\n class=\"self-start sm:me-auto\"\r\n ></mt-button>\r\n }\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n variant=\"outlined\"\r\n [disabled]=\"submitting() || deleting()\"\r\n styleClass=\"w-full sm:w-auto\"\r\n (onClick)=\"onCancel()\"\r\n >\r\n </mt-button>\r\n <mt-button\r\n [disabled]=\"!formControl.valid || deleting()\"\r\n [label]=\"t('save')\"\r\n severity=\"primary\"\r\n [loading]=\"submitting()\"\r\n styleClass=\"w-full sm:w-auto\"\r\n (onClick)=\"onSave()\"\r\n >\r\n </mt-button>\r\n </div>\r\n</ng-container>\r\n" }]
1501
1555
  }], ctorParameters: () => [], propDecorators: { sectionId: [{ type: i0.Input, args: [{ isSignal: true, alias: "sectionId", required: false }] }], initialData: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialData", required: false }] }], allSections: [{ type: i0.Input, args: [{ isSignal: true, alias: "allSections", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }] } });
1502
1556
 
1503
1557
  const hasNonWhitespaceValue = (value) => {
@@ -1938,7 +1992,7 @@ class FBPreviewForm {
1938
1992
  this.ref.close();
1939
1993
  }
1940
1994
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FBPreviewForm, deps: [], target: i0.ɵɵFactoryTarget.Component });
1941
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FBPreviewForm, isStandalone: true, selector: "mt-fb-preview-form", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'formBuilder'\">\n <div\n [class]=\"[\n modalService.contentClass,\n 'min-w-0',\n 'p-4',\n 'overflow-y-hidden!',\n 'max-[640px]:p-3',\n ]\"\n >\n <div class=\"h-full min-h-0 overflow-y-auto px-3 pb-10\">\n @if (moduleKey() && operationKey()) {\n <mt-client-form\n [moduleKey]=\"moduleKey()\"\n [operationKey]=\"operationKey()\"\n [moduleId]=\"previewModuleId()\"\n [levelId]=\"previewLevelId()\"\n [levelDataId]=\"previewInfo()?.levelDataId\"\n [moduleDataId]=\"previewInfo()?.moduleDataId\"\n [requestSchemaId]=\"previewInfo()?.requestSchemaId\"\n [autoLoad]=\"true\"\n [renderMode]=\"renderMode()\"\n />\n } @else {\n <div\n class=\"flex justify-center items-center h-64 text-muted-color text-lg\"\n >\n {{ t(\"no-fields-visible\") }}\n </div>\n }\n </div>\n </div>\n</ng-container>\n", dependencies: [{ kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: ClientForm, selector: "mt-client-form", inputs: ["moduleKey", "operationKey", "moduleId", "levelId", "levelDataId", "moduleDataId", "requestSchemaId", "draftProcessId", "preview", "returnUrl", "defaultValues", "submitRequestMapper", "readonly", "autoLoad", "formMode", "renderMode", "showInternalStepActions", "confirmWarningsOnSubmit", "confirmWarningsOnStepChange", "lookups", "ignoredFieldKeys", "allowedFieldKeys"], outputs: ["loaded", "submitted", "errored", "modeDetected", "formSourceDetected", "footerStateChanged"] }] });
1995
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FBPreviewForm, isStandalone: true, selector: "mt-fb-preview-form", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'formBuilder'\">\n <div\n [class]=\"[\n modalService.contentClass,\n 'min-w-0',\n 'p-4',\n 'overflow-y-hidden!',\n 'max-[640px]:p-3',\n ]\"\n >\n <div class=\"h-full min-h-0 overflow-y-auto px-3 pb-10\">\n @if (moduleKey() && operationKey()) {\n <mt-client-form\n [moduleKey]=\"moduleKey()\"\n [operationKey]=\"operationKey()\"\n [moduleId]=\"previewModuleId()\"\n [levelId]=\"previewLevelId()\"\n [levelDataId]=\"previewInfo()?.levelDataId\"\n [moduleDataId]=\"previewInfo()?.moduleDataId\"\n [requestSchemaId]=\"previewInfo()?.requestSchemaId\"\n [autoLoad]=\"true\"\n [renderMode]=\"renderMode()\"\n />\n } @else {\n <div\n class=\"flex justify-center items-center h-64 text-muted-color text-lg\"\n >\n {{ t(\"no-fields-visible\") }}\n </div>\n }\n </div>\n </div>\n</ng-container>\n", dependencies: [{ kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: ClientForm, selector: "mt-client-form", inputs: ["moduleKey", "operationKey", "moduleId", "levelId", "levelDataId", "moduleDataId", "requestSchemaId", "draftProcessId", "preview", "returnUrl", "defaultValues", "submitRequestMapper", "readonly", "autoLoad", "formMode", "renderMode", "showInternalStepActions", "confirmWarningsOnSubmit", "confirmWarningsOnStepChange", "lookups", "statuses", "ignoredFieldKeys", "allowedFieldKeys"], outputs: ["loaded", "submitted", "errored", "modeDetected", "formSourceDetected", "footerStateChanged"] }] });
1942
1996
  }
1943
1997
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FBPreviewForm, decorators: [{
1944
1998
  type: Component,
@@ -1973,6 +2027,7 @@ class FBValidationRuleForm {
1973
2027
  nonNullable: true,
1974
2028
  });
1975
2029
  formulaControl = new FormControl(null);
2030
+ formulaValue = toSignal(this.formulaControl.valueChanges.pipe(startWith(this.formulaControl.value)), { initialValue: this.formulaControl.value });
1976
2031
  formulaValidation = signal(EMPTY_FORMULA_VALIDATION, ...(ngDevMode ? [{ debugName: "formulaValidation" }] : /* istanbul ignore next */ []));
1977
2032
  builderSchemaId = computed(() => {
1978
2033
  const parentModuleId = this.toNumericId(this.parentModuleId());
@@ -2022,13 +2077,14 @@ class FBValidationRuleForm {
2022
2077
  };
2023
2078
  }, ...(ngDevMode ? [{ debugName: "formulaPropertiesByPath" }] : /* istanbul ignore next */ []));
2024
2079
  hasFormula = computed(() => {
2025
- const value = this.formulaControl.value;
2080
+ const value = this.formulaValue();
2026
2081
  const expression = value?.expression?.trim() ?? '';
2027
2082
  return expression.length > 0 || (value?.builder?.length ?? 0) > 0;
2028
2083
  }, ...(ngDevMode ? [{ debugName: "hasFormula" }] : /* istanbul ignore next */ []));
2029
2084
  canSave = computed(() => {
2030
2085
  return (this.hasFormula() &&
2031
- this.formulaValidation().isValid && !this.submitting());
2086
+ this.formulaValidation().isValid &&
2087
+ !this.submitting());
2032
2088
  }, ...(ngDevMode ? [{ debugName: "canSave" }] : /* istanbul ignore next */ []));
2033
2089
  severityOptions = computed(() => {
2034
2090
  const _lang = this.activeLang();
@@ -2077,7 +2133,7 @@ class FBValidationRuleForm {
2077
2133
  this.formulaValidation.set(result);
2078
2134
  }
2079
2135
  onSave() {
2080
- const formulaValue = this.formulaControl.value;
2136
+ const formulaValue = this.formulaValue();
2081
2137
  const formulaPayload = this.buildFormulaPayload(formulaValue);
2082
2138
  if (!formulaPayload || !this.formulaValidation().isValid) {
2083
2139
  return;
@@ -3060,5 +3116,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
3060
3116
  * Generated bundle index. Do not edit.
3061
3117
  */
3062
3118
 
3063
- export { AddField, AddSection, AddValidation, DeleteField, DeleteSection, DeleteValidation, FormBuilder, FormBuilderActionKey, FormBuilderFacade, FormBuilderState, GetFormConfiguration, MoveField, ReorderFields, ReorderSections, ResetFormBuilderState, ResetFormConfiguration, SetModuleInfo, SetPreviewInfo, SetProperties, ToggleValidationActive, UpdateField, UpdateFormSettings, UpdateSection, UpdateValidation };
3119
+ export { AddField, AddSection, AddValidation, DeleteField, DeleteSection, DeleteValidation, FormBuilder, FormBuilderActionKey, FormBuilderFacade, FormBuilderState, GetFormConfiguration, MoveField, ReorderFields, ReorderSections, ResetFormBuilderState, ResetFormConfiguration, ResetFormFromAppForm, SetModuleInfo, SetPreviewInfo, SetProperties, ToggleValidationActive, UpdateField, UpdateFormSettings, UpdateSection, UpdateValidation };
3064
3120
  //# sourceMappingURL=masterteam-form-builder.mjs.map