@masterteam/forms 0.0.71 → 0.0.73

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.
@@ -0,0 +1,80 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, input, viewChild, computed, signal, ChangeDetectionStrategy, Component } from '@angular/core';
4
+ import { TranslocoDirective } from '@jsverse/transloco';
5
+ import { Button } from '@masterteam/components/button';
6
+ import { ModalRef } from '@masterteam/components/dialog';
7
+ import { ClientForm } from '@masterteam/forms/client-form';
8
+ import { ENTITY_LIST_ADD_DIALOG_COMPONENT } from '@masterteam/components/business-fields';
9
+
10
+ /**
11
+ * Add-row dialog used by `mt-entity-list-field` in Write mode. Renders the
12
+ * full module form via `mt-client-form` (`/api/process-form-load`) but
13
+ * restricts the editable fields to the property keys listed in `writeFields`.
14
+ *
15
+ * Closes with the form's raw value on Save, or `null` on Cancel.
16
+ */
17
+ class EntityListAddFormDialog {
18
+ ref = inject(ModalRef);
19
+ // Inputs (passed via ModalService.openModal inputValues)
20
+ moduleId = input(null, ...(ngDevMode ? [{ debugName: "moduleId" }] : /* istanbul ignore next */ []));
21
+ levelId = input(null, ...(ngDevMode ? [{ debugName: "levelId" }] : /* istanbul ignore next */ []));
22
+ levelDataId = input(null, ...(ngDevMode ? [{ debugName: "levelDataId" }] : /* istanbul ignore next */ []));
23
+ writeFields = input([], ...(ngDevMode ? [{ debugName: "writeFields" }] : /* istanbul ignore next */ []));
24
+ /** Pre-populated values (keyed by property key) when opening for Edit. */
25
+ initialValues = input({}, ...(ngDevMode ? [{ debugName: "initialValues" }] : /* istanbul ignore next */ []));
26
+ clientForm = viewChild('clientForm', ...(ngDevMode ? [{ debugName: "clientForm" }] : /* istanbul ignore next */ []));
27
+ hasContext = computed(() => this.moduleId() != null &&
28
+ this.levelId() != null &&
29
+ this.levelDataId() != null, ...(ngDevMode ? [{ debugName: "hasContext" }] : /* istanbul ignore next */ []));
30
+ saving = signal(false, ...(ngDevMode ? [{ debugName: "saving" }] : /* istanbul ignore next */ []));
31
+ onCancel() {
32
+ this.ref.close(null);
33
+ }
34
+ /**
35
+ * Called when the ClientForm finishes loading its config. Patches the
36
+ * internal formControl with any pre-populated values (Edit mode).
37
+ */
38
+ onFormLoaded() {
39
+ const vals = this.initialValues();
40
+ if (!vals || Object.keys(vals).length === 0)
41
+ return;
42
+ this.clientForm()?.formControl.patchValue(vals);
43
+ }
44
+ onSave() {
45
+ const cf = this.clientForm();
46
+ if (!cf)
47
+ return;
48
+ if (cf.formControl.invalid) {
49
+ cf.formControl.markAllAsTouched();
50
+ return;
51
+ }
52
+ const values = cf.formControl.getRawValue() ?? {};
53
+ this.ref.close(values);
54
+ }
55
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListAddFormDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
56
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: EntityListAddFormDialog, isStandalone: true, selector: "mt-entity-list-add-form-dialog", inputs: { moduleId: { classPropertyName: "moduleId", publicName: "moduleId", isSignal: true, isRequired: false, transformFunction: null }, levelId: { classPropertyName: "levelId", publicName: "levelId", isSignal: true, isRequired: false, transformFunction: null }, levelDataId: { classPropertyName: "levelDataId", publicName: "levelDataId", isSignal: true, isRequired: false, transformFunction: null }, writeFields: { classPropertyName: "writeFields", publicName: "writeFields", isSignal: true, isRequired: false, transformFunction: null }, initialValues: { classPropertyName: "initialValues", publicName: "initialValues", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "clientForm", first: true, predicate: ["clientForm"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t\">\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n @if (!hasContext()) {\r\n <p class=\"text-sm text-muted-color\">\r\n {{ t(\"entityListField.missingContext\") }}\r\n </p>\r\n } @else {\r\n <mt-client-form\r\n #clientForm\r\n moduleKey=\"ModuleData\"\r\n operationKey=\"Create\"\r\n [moduleId]=\"moduleId()!\"\r\n [levelId]=\"levelId()!\"\r\n [levelDataId]=\"levelDataId()!\"\r\n [allowedFieldKeys]=\"writeFields()\"\r\n (loaded)=\"onFormLoaded()\"\r\n />\r\n }\r\n\r\n <div class=\"flex justify-end gap-2 pt-4 border-t border-surface-200\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button\r\n [label]=\"t('add')\"\r\n severity=\"primary\"\r\n [disabled]=\"!hasContext() || saving()\"\r\n (onClick)=\"onSave()\"\r\n />\r\n </div>\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { 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"] }, { 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
57
+ }
58
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: EntityListAddFormDialog, decorators: [{
59
+ type: Component,
60
+ args: [{ selector: 'mt-entity-list-add-form-dialog', standalone: true, imports: [CommonModule, TranslocoDirective, ClientForm, Button], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t\">\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n @if (!hasContext()) {\r\n <p class=\"text-sm text-muted-color\">\r\n {{ t(\"entityListField.missingContext\") }}\r\n </p>\r\n } @else {\r\n <mt-client-form\r\n #clientForm\r\n moduleKey=\"ModuleData\"\r\n operationKey=\"Create\"\r\n [moduleId]=\"moduleId()!\"\r\n [levelId]=\"levelId()!\"\r\n [levelDataId]=\"levelDataId()!\"\r\n [allowedFieldKeys]=\"writeFields()\"\r\n (loaded)=\"onFormLoaded()\"\r\n />\r\n }\r\n\r\n <div class=\"flex justify-end gap-2 pt-4 border-t border-surface-200\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button\r\n [label]=\"t('add')\"\r\n severity=\"primary\"\r\n [disabled]=\"!hasContext() || saving()\"\r\n (onClick)=\"onSave()\"\r\n />\r\n </div>\r\n </div>\r\n</ng-container>\r\n" }]
61
+ }], propDecorators: { moduleId: [{ type: i0.Input, args: [{ isSignal: true, alias: "moduleId", required: false }] }], levelId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelId", required: false }] }], levelDataId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelDataId", required: false }] }], writeFields: [{ type: i0.Input, args: [{ isSignal: true, alias: "writeFields", required: false }] }], initialValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialValues", required: false }] }], clientForm: [{ type: i0.ViewChild, args: ['clientForm', { isSignal: true }] }] } });
62
+
63
+ /**
64
+ * Registers the rich EntityList add-row dialog (powered by `mt-client-form`)
65
+ * for use by `mt-entity-list-field` Write mode. Without this provider the
66
+ * field falls back to a minimal text-only popup.
67
+ */
68
+ function provideEntityListAddForm() {
69
+ return {
70
+ provide: ENTITY_LIST_ADD_DIALOG_COMPONENT,
71
+ useValue: EntityListAddFormDialog,
72
+ };
73
+ }
74
+
75
+ /**
76
+ * Generated bundle index. Do not edit.
77
+ */
78
+
79
+ export { EntityListAddFormDialog, provideEntityListAddForm };
80
+ //# sourceMappingURL=masterteam-forms-entity-list-add-form.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"masterteam-forms-entity-list-add-form.mjs","sources":["../../../../packages/masterteam/forms/entity-list-add-form/entity-list-add-form-dialog.ts","../../../../packages/masterteam/forms/entity-list-add-form/entity-list-add-form-dialog.html","../../../../packages/masterteam/forms/entity-list-add-form/provide-entity-list-add-form.ts","../../../../packages/masterteam/forms/entity-list-add-form/masterteam-forms-entity-list-add-form.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport {\r\n ChangeDetectionStrategy,\r\n Component,\r\n computed,\r\n inject,\r\n input,\r\n signal,\r\n viewChild,\r\n} from '@angular/core';\r\nimport { TranslocoDirective } from '@jsverse/transloco';\r\nimport { Button } from '@masterteam/components/button';\r\nimport { ModalRef } from '@masterteam/components/dialog';\r\nimport { ClientForm } from '@masterteam/forms/client-form';\r\n\r\n/**\r\n * Add-row dialog used by `mt-entity-list-field` in Write mode. Renders the\r\n * full module form via `mt-client-form` (`/api/process-form-load`) but\r\n * restricts the editable fields to the property keys listed in `writeFields`.\r\n *\r\n * Closes with the form's raw value on Save, or `null` on Cancel.\r\n */\r\n@Component({\r\n selector: 'mt-entity-list-add-form-dialog',\r\n standalone: true,\r\n imports: [CommonModule, TranslocoDirective, ClientForm, Button],\r\n templateUrl: './entity-list-add-form-dialog.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class EntityListAddFormDialog {\r\n private readonly ref = inject(ModalRef);\r\n\r\n // Inputs (passed via ModalService.openModal inputValues)\r\n readonly moduleId = input<number | string | null>(null);\r\n readonly levelId = input<number | string | null>(null);\r\n readonly levelDataId = input<number | string | null>(null);\r\n readonly writeFields = input<string[]>([]);\r\n /** Pre-populated values (keyed by property key) when opening for Edit. */\r\n readonly initialValues = input<Record<string, unknown>>({});\r\n\r\n protected readonly clientForm = viewChild<ClientForm>('clientForm');\r\n\r\n protected readonly hasContext = computed(\r\n () =>\r\n this.moduleId() != null &&\r\n this.levelId() != null &&\r\n this.levelDataId() != null,\r\n );\r\n\r\n protected readonly saving = signal(false);\r\n\r\n protected onCancel(): void {\r\n this.ref.close(null);\r\n }\r\n\r\n /**\r\n * Called when the ClientForm finishes loading its config. Patches the\r\n * internal formControl with any pre-populated values (Edit mode).\r\n */\r\n protected onFormLoaded(): void {\r\n const vals = this.initialValues();\r\n if (!vals || Object.keys(vals).length === 0) return;\r\n this.clientForm()?.formControl.patchValue(vals);\r\n }\r\n\r\n protected onSave(): void {\r\n const cf = this.clientForm();\r\n if (!cf) return;\r\n\r\n if (cf.formControl.invalid) {\r\n cf.formControl.markAllAsTouched();\r\n return;\r\n }\r\n\r\n const values = cf.formControl.getRawValue() ?? {};\r\n this.ref.close(values);\r\n }\r\n}\r\n","<ng-container *transloco=\"let t\">\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n @if (!hasContext()) {\r\n <p class=\"text-sm text-muted-color\">\r\n {{ t(\"entityListField.missingContext\") }}\r\n </p>\r\n } @else {\r\n <mt-client-form\r\n #clientForm\r\n moduleKey=\"ModuleData\"\r\n operationKey=\"Create\"\r\n [moduleId]=\"moduleId()!\"\r\n [levelId]=\"levelId()!\"\r\n [levelDataId]=\"levelDataId()!\"\r\n [allowedFieldKeys]=\"writeFields()\"\r\n (loaded)=\"onFormLoaded()\"\r\n />\r\n }\r\n\r\n <div class=\"flex justify-end gap-2 pt-4 border-t border-surface-200\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button\r\n [label]=\"t('add')\"\r\n severity=\"primary\"\r\n [disabled]=\"!hasContext() || saving()\"\r\n (onClick)=\"onSave()\"\r\n />\r\n </div>\r\n </div>\r\n</ng-container>\r\n","import { Provider } from '@angular/core';\r\nimport { ENTITY_LIST_ADD_DIALOG_COMPONENT } from '@masterteam/components/business-fields';\r\n\r\nimport { EntityListAddFormDialog } from './entity-list-add-form-dialog';\r\n\r\n/**\r\n * Registers the rich EntityList add-row dialog (powered by `mt-client-form`)\r\n * for use by `mt-entity-list-field` Write mode. Without this provider the\r\n * field falls back to a minimal text-only popup.\r\n */\r\nexport function provideEntityListAddForm(): Provider {\r\n return {\r\n provide: ENTITY_LIST_ADD_DIALOG_COMPONENT,\r\n useValue: EntityListAddFormDialog,\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAeA;;;;;;AAMG;MAQU,uBAAuB,CAAA;AACjB,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;;AAG9B,IAAA,QAAQ,GAAG,KAAK,CAAyB,IAAI,+EAAC;AAC9C,IAAA,OAAO,GAAG,KAAK,CAAyB,IAAI,8EAAC;AAC7C,IAAA,WAAW,GAAG,KAAK,CAAyB,IAAI,kFAAC;AACjD,IAAA,WAAW,GAAG,KAAK,CAAW,EAAE,kFAAC;;AAEjC,IAAA,aAAa,GAAG,KAAK,CAA0B,EAAE,oFAAC;AAExC,IAAA,UAAU,GAAG,SAAS,CAAa,YAAY,iFAAC;IAEhD,UAAU,GAAG,QAAQ,CACtC,MACE,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI;AACvB,QAAA,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI;AACtB,QAAA,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,iFAC7B;AAEkB,IAAA,MAAM,GAAG,MAAM,CAAC,KAAK,6EAAC;IAE/B,QAAQ,GAAA;AAChB,QAAA,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;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oBAAA,EAAA,oBAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,MAAM,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,SAAA,EAAA,OAAA,EAAA,MAAA,EAAA,YAAA,EAAA,UAAA,EAAA,OAAA,EAAA,SAAA,EAAA,eAAA,EAAA,MAAA,EAAA,SAAA,EAAA,WAAA,EAAA,OAAA,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,OAAA,EAAA,UAAA,EAAA,MAAA,EAAA,UAAA,EAAA,SAAA,EAAA,SAAA,CAAA,EAAA,OAAA,EAAA,CAAA,SAAA,EAAA,SAAA,EAAA,QAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAInD,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAPnC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gCAAgC,EAAA,UAAA,EAC9B,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,CAAC,EAAA,eAAA,EAE9C,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,ijCAAA,EAAA;4jBAaO,YAAY,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEnCpE;;;;AAIG;SACa,wBAAwB,GAAA;IACtC,OAAO;AACL,QAAA,OAAO,EAAE,gCAAgC;AACzC,QAAA,QAAQ,EAAE,uBAAuB;KAClC;AACH;;ACfA;;AAEG;;;;"}
@@ -50,7 +50,7 @@ class RuntimeActionConfirmDialog {
50
50
  this.ref.close(this.formControl.getRawValue() ?? {});
51
51
  }
52
52
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: RuntimeActionConfirmDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
53
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: RuntimeActionConfirmDialog, isStandalone: true, selector: "mt-runtime-action-confirm-dialog", inputs: { action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'runtimeAction'\">\n <div [class]=\"modal.contentClass + ' p-4'\">\n @if (hasFormFields()) {\n <mt-dynamic-form\n [formConfig]=\"formConfig()\"\n [formControl]=\"formControl\"\n />\n } @else {\n <p class=\"text-sm text-surface-500\">\n {{ t(\"modal.confirmAction\", { action: actionLabel() }) }}\n </p>\n }\n </div>\n\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('modal.cancel')\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"onCancel()\"\n />\n <mt-button [label]=\"actionLabel()\" (onClick)=\"onConfirm()\" />\n </div>\n</ng-container>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { 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: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { 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"] }] });
53
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: RuntimeActionConfirmDialog, isStandalone: true, selector: "mt-runtime-action-confirm-dialog", inputs: { action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'runtimeAction'\">\r\n <div [class]=\"modal.contentClass + ' p-4'\">\r\n @if (hasFormFields()) {\r\n <mt-dynamic-form\r\n [formConfig]=\"formConfig()\"\r\n [formControl]=\"formControl\"\r\n />\r\n } @else {\r\n <p class=\"text-sm text-surface-500\">\r\n {{ t(\"modal.confirmAction\", { action: actionLabel() }) }}\r\n </p>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('modal.cancel')\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button [label]=\"actionLabel()\" (onClick)=\"onConfirm()\" />\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { 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: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { 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"] }] });
54
54
  }
55
55
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: RuntimeActionConfirmDialog, decorators: [{
56
56
  type: Component,
@@ -60,7 +60,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
60
60
  TranslocoDirective,
61
61
  DynamicForm,
62
62
  Button,
63
- ], template: "<ng-container *transloco=\"let t; prefix: 'runtimeAction'\">\n <div [class]=\"modal.contentClass + ' p-4'\">\n @if (hasFormFields()) {\n <mt-dynamic-form\n [formConfig]=\"formConfig()\"\n [formControl]=\"formControl\"\n />\n } @else {\n <p class=\"text-sm text-surface-500\">\n {{ t(\"modal.confirmAction\", { action: actionLabel() }) }}\n </p>\n }\n </div>\n\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('modal.cancel')\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"onCancel()\"\n />\n <mt-button [label]=\"actionLabel()\" (onClick)=\"onConfirm()\" />\n </div>\n</ng-container>\n" }]
63
+ ], template: "<ng-container *transloco=\"let t; prefix: 'runtimeAction'\">\r\n <div [class]=\"modal.contentClass + ' p-4'\">\r\n @if (hasFormFields()) {\r\n <mt-dynamic-form\r\n [formConfig]=\"formConfig()\"\r\n [formControl]=\"formControl\"\r\n />\r\n } @else {\r\n <p class=\"text-sm text-surface-500\">\r\n {{ t(\"modal.confirmAction\", { action: actionLabel() }) }}\r\n </p>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('modal.cancel')\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button [label]=\"actionLabel()\" (onClick)=\"onConfirm()\" />\r\n </div>\r\n</ng-container>\r\n" }]
64
64
  }], ctorParameters: () => [], propDecorators: { action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: true }] }] } });
65
65
  function buildActionFields(action, t) {
66
66
  const requestedKeys = new Set(action.payloadKeys ?? []);
@@ -1 +1 @@
1
- {"version":3,"file":"masterteam-forms-runtime-action-dialog.mjs","sources":["../../../../packages/masterteam/forms/runtime-action-dialog/runtime-action-confirm-dialog.ts","../../../../packages/masterteam/forms/runtime-action-dialog/runtime-action-confirm-dialog.html","../../../../packages/masterteam/forms/runtime-action-dialog/provide-runtime-action-confirm-dialog.ts","../../../../packages/masterteam/forms/runtime-action-dialog/masterteam-forms-runtime-action-dialog.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\nimport { TranslocoDirective, TranslocoService } from '@jsverse/transloco';\nimport {\n DynamicFieldConfig,\n DynamicFormConfig,\n ValidatorConfig,\n} from '@masterteam/components';\nimport { Button } from '@masterteam/components/button';\nimport { ModalRef } from '@masterteam/components/dialog';\nimport { ModalService } from '@masterteam/components/modal';\nimport {\n RuntimeAction,\n resolveActionLabel,\n} from '@masterteam/components/runtime-action';\nimport { DynamicForm } from '@masterteam/forms/dynamic-form';\n\n@Component({\n selector: 'mt-runtime-action-confirm-dialog',\n standalone: true,\n imports: [\n CommonModule,\n ReactiveFormsModule,\n TranslocoDirective,\n DynamicForm,\n Button,\n ],\n templateUrl: './runtime-action-confirm-dialog.html',\n})\nexport class RuntimeActionConfirmDialog {\n private readonly ref = inject(ModalRef);\n readonly modal = inject(ModalService);\n private readonly transloco = inject(TranslocoService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly activeLang = signal(this.transloco.getActiveLang());\n\n readonly action = input.required<RuntimeAction>();\n\n protected readonly formControl = new FormControl<Record<string, unknown>>({});\n protected readonly actionLabel = computed(() =>\n resolveActionLabel(this.action()),\n );\n protected readonly formConfig = computed<DynamicFormConfig>(() => {\n this.activeLang();\n return {\n sections: [\n {\n key: 'action-confirmation',\n type: 'none',\n fields: buildActionFields(this.action(), (key) =>\n this.transloco.translate<string>(key),\n ),\n },\n ],\n };\n });\n protected readonly hasFormFields = computed(\n () => this.formConfig().sections[0]?.fields.length > 0,\n );\n\n constructor() {\n this.transloco.langChanges$\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((lang) => this.activeLang.set(lang));\n }\n\n protected onCancel(): void {\n this.ref.close(null);\n }\n\n protected onConfirm(): void {\n if (this.formControl.invalid) {\n this.formControl.markAllAsTouched();\n return;\n }\n\n this.ref.close(this.formControl.getRawValue() ?? {});\n }\n}\n\nfunction buildActionFields(\n action: RuntimeAction,\n t: (key: string) => string,\n): DynamicFieldConfig[] {\n const requestedKeys = new Set(action.payloadKeys ?? []);\n const requiredKeys = new Set(action.requiredPayloadKeys ?? []);\n const fields: DynamicFieldConfig[] = [];\n const progressField = resolveProgressField(action);\n\n if (progressField) {\n fields.push({\n key: 'progress',\n type: 'slider',\n label: t('runtimeAction.field.progress'),\n min: 0,\n max: 100,\n step: 1,\n unit: '%',\n validators: buildRequiredValidators(requiredKeys.has('fields')),\n defaultValue: progressField.value,\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('delegatedUser')) {\n fields.push({\n key: 'delegatedUser',\n type: 'user-search',\n label: t('runtimeAction.field.delegatedUser'),\n placeholder: t('runtimeAction.field.delegatedUserPlaceholder'),\n apiUrl: 'Identity/users',\n optionLabel: 'displayName',\n optionValue: 'id',\n validators: buildRequiredValidators(requiredKeys.has('delegatedUser')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('reason')) {\n fields.push({\n key: 'reason',\n type: 'textarea',\n label: t('runtimeAction.field.reason'),\n placeholder: t('runtimeAction.field.reasonPlaceholder'),\n rows: 4,\n validators: buildRequiredValidators(requiredKeys.has('reason')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('note')) {\n fields.push({\n key: 'note',\n type: 'textarea',\n label: t('runtimeAction.field.note'),\n placeholder: t('runtimeAction.field.notePlaceholder'),\n rows: 4,\n validators: buildRequiredValidators(requiredKeys.has('note')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('attachments')) {\n fields.push({\n key: 'attachments',\n type: 'upload-file',\n label: t('runtimeAction.field.attachments'),\n endPoint: 'uploader',\n multiple: true,\n title: t('runtimeAction.field.uploadTitle'),\n description: t('runtimeAction.field.uploadDescription'),\n validators: buildRequiredValidators(requiredKeys.has('attachments')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n return fields;\n}\n\nfunction buildRequiredValidators(required: boolean): ValidatorConfig[] {\n return required ? [ValidatorConfig.required()] : [];\n}\n\nfunction resolveProgressField(\n action: RuntimeAction,\n): { value?: number } | null {\n const fields = (action.payloadTemplate as { fields?: unknown } | null)\n ?.fields;\n if (!Array.isArray(fields)) {\n return null;\n }\n\n const progressField = fields.find(\n (field) =>\n !!field &&\n typeof field === 'object' &&\n (field as { propertyKey?: string }).propertyKey === 'Progress',\n ) as { value?: unknown } | undefined;\n\n if (!progressField) {\n return null;\n }\n\n return {\n value: normalizeProgressValue(progressField.value),\n };\n}\n\nfunction normalizeProgressValue(value: unknown): number | undefined {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string') {\n return undefined;\n }\n\n const normalized = Number(value.replace('%', '').trim());\n return Number.isFinite(normalized) ? normalized : undefined;\n}\n","<ng-container *transloco=\"let t; prefix: 'runtimeAction'\">\n <div [class]=\"modal.contentClass + ' p-4'\">\n @if (hasFormFields()) {\n <mt-dynamic-form\n [formConfig]=\"formConfig()\"\n [formControl]=\"formControl\"\n />\n } @else {\n <p class=\"text-sm text-surface-500\">\n {{ t(\"modal.confirmAction\", { action: actionLabel() }) }}\n </p>\n }\n </div>\n\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('modal.cancel')\"\n severity=\"secondary\"\n variant=\"outlined\"\n (onClick)=\"onCancel()\"\n />\n <mt-button [label]=\"actionLabel()\" (onClick)=\"onConfirm()\" />\n </div>\n</ng-container>\n","import { Provider } from '@angular/core';\nimport { RUNTIME_ACTION_CONFIRM_DIALOG } from '@masterteam/components/runtime-action';\n\nimport { RuntimeActionConfirmDialog } from './runtime-action-confirm-dialog';\n\nexport function provideRuntimeActionConfirmDialog(): Provider {\n return {\n provide: RUNTIME_ACTION_CONFIRM_DIALOG,\n useValue: RuntimeActionConfirmDialog,\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MAsCa,0BAA0B,CAAA;AACpB,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC9B,IAAA,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;AACpB,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACpC,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAC/B,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,YAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAE3D,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,4EAAiB;AAE9B,IAAA,WAAW,GAAG,IAAI,WAAW,CAA0B,EAAE,CAAC;AAC1D,IAAA,WAAW,GAAG,QAAQ,CAAC,MACxC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,kFAClC;AACkB,IAAA,UAAU,GAAG,QAAQ,CAAoB,MAAK;QAC/D,IAAI,CAAC,UAAU,EAAE;QACjB,OAAO;AACL,YAAA,QAAQ,EAAE;AACR,gBAAA;AACE,oBAAA,GAAG,EAAE,qBAAqB;AAC1B,oBAAA,IAAI,EAAE,MAAM;oBACZ,MAAM,EAAE,iBAAiB,CA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AAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACvD,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACxD,IAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,SAAS;AAC7D;;SE3MgB,iCAAiC,GAAA;IAC/C,OAAO;AACL,QAAA,OAAO,EAAE,6BAA6B;AACtC,QAAA,QAAQ,EAAE,0BAA0B;KACrC;AACH;;ACVA;;AAEG;;;;"}
1
+ {"version":3,"file":"masterteam-forms-runtime-action-dialog.mjs","sources":["../../../../packages/masterteam/forms/runtime-action-dialog/runtime-action-confirm-dialog.ts","../../../../packages/masterteam/forms/runtime-action-dialog/runtime-action-confirm-dialog.html","../../../../packages/masterteam/forms/runtime-action-dialog/provide-runtime-action-confirm-dialog.ts","../../../../packages/masterteam/forms/runtime-action-dialog/masterteam-forms-runtime-action-dialog.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\nimport { TranslocoDirective, TranslocoService } from '@jsverse/transloco';\nimport {\n DynamicFieldConfig,\n DynamicFormConfig,\n ValidatorConfig,\n} from '@masterteam/components';\nimport { Button } from '@masterteam/components/button';\nimport { ModalRef } from '@masterteam/components/dialog';\nimport { ModalService } from '@masterteam/components/modal';\nimport {\n RuntimeAction,\n resolveActionLabel,\n} from '@masterteam/components/runtime-action';\nimport { DynamicForm } from '@masterteam/forms/dynamic-form';\n\n@Component({\n selector: 'mt-runtime-action-confirm-dialog',\n standalone: true,\n imports: [\n CommonModule,\n ReactiveFormsModule,\n TranslocoDirective,\n DynamicForm,\n Button,\n ],\n templateUrl: './runtime-action-confirm-dialog.html',\n})\nexport class RuntimeActionConfirmDialog {\n private readonly ref = inject(ModalRef);\n readonly modal = inject(ModalService);\n private readonly transloco = inject(TranslocoService);\n private readonly destroyRef = inject(DestroyRef);\n private readonly activeLang = signal(this.transloco.getActiveLang());\n\n readonly action = input.required<RuntimeAction>();\n\n protected readonly formControl = new FormControl<Record<string, unknown>>({});\n protected readonly actionLabel = computed(() =>\n resolveActionLabel(this.action()),\n );\n protected readonly formConfig = computed<DynamicFormConfig>(() => {\n this.activeLang();\n return {\n sections: [\n {\n key: 'action-confirmation',\n type: 'none',\n fields: buildActionFields(this.action(), (key) =>\n this.transloco.translate<string>(key),\n ),\n },\n ],\n };\n });\n protected readonly hasFormFields = computed(\n () => this.formConfig().sections[0]?.fields.length > 0,\n );\n\n constructor() {\n this.transloco.langChanges$\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((lang) => this.activeLang.set(lang));\n }\n\n protected onCancel(): void {\n this.ref.close(null);\n }\n\n protected onConfirm(): void {\n if (this.formControl.invalid) {\n this.formControl.markAllAsTouched();\n return;\n }\n\n this.ref.close(this.formControl.getRawValue() ?? {});\n }\n}\n\nfunction buildActionFields(\n action: RuntimeAction,\n t: (key: string) => string,\n): DynamicFieldConfig[] {\n const requestedKeys = new Set(action.payloadKeys ?? []);\n const requiredKeys = new Set(action.requiredPayloadKeys ?? []);\n const fields: DynamicFieldConfig[] = [];\n const progressField = resolveProgressField(action);\n\n if (progressField) {\n fields.push({\n key: 'progress',\n type: 'slider',\n label: t('runtimeAction.field.progress'),\n min: 0,\n max: 100,\n step: 1,\n unit: '%',\n validators: buildRequiredValidators(requiredKeys.has('fields')),\n defaultValue: progressField.value,\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('delegatedUser')) {\n fields.push({\n key: 'delegatedUser',\n type: 'user-search',\n label: t('runtimeAction.field.delegatedUser'),\n placeholder: t('runtimeAction.field.delegatedUserPlaceholder'),\n apiUrl: 'Identity/users',\n optionLabel: 'displayName',\n optionValue: 'id',\n validators: buildRequiredValidators(requiredKeys.has('delegatedUser')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('reason')) {\n fields.push({\n key: 'reason',\n type: 'textarea',\n label: t('runtimeAction.field.reason'),\n placeholder: t('runtimeAction.field.reasonPlaceholder'),\n rows: 4,\n validators: buildRequiredValidators(requiredKeys.has('reason')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('note')) {\n fields.push({\n key: 'note',\n type: 'textarea',\n label: t('runtimeAction.field.note'),\n placeholder: t('runtimeAction.field.notePlaceholder'),\n rows: 4,\n validators: buildRequiredValidators(requiredKeys.has('note')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n if (requestedKeys.has('attachments')) {\n fields.push({\n key: 'attachments',\n type: 'upload-file',\n label: t('runtimeAction.field.attachments'),\n endPoint: 'uploader',\n multiple: true,\n title: t('runtimeAction.field.uploadTitle'),\n description: t('runtimeAction.field.uploadDescription'),\n validators: buildRequiredValidators(requiredKeys.has('attachments')),\n colSpan: 12,\n } as DynamicFieldConfig);\n }\n\n return fields;\n}\n\nfunction buildRequiredValidators(required: boolean): ValidatorConfig[] {\n return required ? [ValidatorConfig.required()] : [];\n}\n\nfunction resolveProgressField(\n action: RuntimeAction,\n): { value?: number } | null {\n const fields = (action.payloadTemplate as { fields?: unknown } | null)\n ?.fields;\n if (!Array.isArray(fields)) {\n return null;\n }\n\n const progressField = fields.find(\n (field) =>\n !!field &&\n typeof field === 'object' &&\n (field as { propertyKey?: string }).propertyKey === 'Progress',\n ) as { value?: unknown } | undefined;\n\n if (!progressField) {\n return null;\n }\n\n return {\n value: normalizeProgressValue(progressField.value),\n };\n}\n\nfunction normalizeProgressValue(value: unknown): number | undefined {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string') {\n return undefined;\n }\n\n const normalized = Number(value.replace('%', '').trim());\n return Number.isFinite(normalized) ? normalized : undefined;\n}\n","<ng-container *transloco=\"let t; prefix: 'runtimeAction'\">\r\n <div [class]=\"modal.contentClass + ' p-4'\">\r\n @if (hasFormFields()) {\r\n <mt-dynamic-form\r\n [formConfig]=\"formConfig()\"\r\n [formControl]=\"formControl\"\r\n />\r\n } @else {\r\n <p class=\"text-sm text-surface-500\">\r\n {{ t(\"modal.confirmAction\", { action: actionLabel() }) }}\r\n </p>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('modal.cancel')\"\r\n variant=\"outlined\"\r\n (onClick)=\"onCancel()\"\r\n />\r\n <mt-button [label]=\"actionLabel()\" (onClick)=\"onConfirm()\" />\r\n </div>\r\n</ng-container>\r\n","import { Provider } from '@angular/core';\nimport { RUNTIME_ACTION_CONFIRM_DIALOG } from '@masterteam/components/runtime-action';\n\nimport { RuntimeActionConfirmDialog } from './runtime-action-confirm-dialog';\n\nexport function provideRuntimeActionConfirmDialog(): Provider {\n return {\n provide: RUNTIME_ACTION_CONFIRM_DIALOG,\n useValue: RuntimeActionConfirmDialog,\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MAsCa,0BAA0B,CAAA;AACpB,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC9B,IAAA,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;AACpB,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACpC,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAC/B,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,YAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;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,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAC/B,CAAC,KAAK,KACJ,CAAC,CAAC,KAAK;QACP,OAAO,KAAK,KAAK,QAAQ;AACxB,QAAA,KAAkC,CAAC,WAAW,KAAK,UAAU,CAC9B;IAEpC,IAAI,CAAC,aAAa,EAAE;AAClB,QAAA,OAAO,IAAI;IACb;IAEA,OAAO;AACL,QAAA,KAAK,EAAE,sBAAsB,CAAC,aAAa,CAAC,KAAK,CAAC;KACnD;AACH;AAEA,SAAS,sBAAsB,CAAC,KAAc,EAAA;AAC5C,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACvD,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACxD,IAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,SAAS;AAC7D;;SE3MgB,iCAAiC,GAAA;IAC/C,OAAO;AACL,QAAA,OAAO,EAAE,6BAA6B;AACtC,QAAA,QAAQ,EAAE,0BAA0B;KACrC;AACH;;ACVA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masterteam/forms",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "publishConfig": {
5
5
  "directory": "../../../dist/masterteam/forms",
6
6
  "linkDirectory": true,
@@ -17,7 +17,7 @@
17
17
  "primeng": "21.1.5",
18
18
  "@primeuix/themes": "^2.0.3",
19
19
  "rxjs": "^7.8.2",
20
- "@masterteam/components": "^0.0.157"
20
+ "@masterteam/components": "^0.0.164"
21
21
  },
22
22
  "sideEffects": false,
23
23
  "exports": {
@@ -43,6 +43,10 @@
43
43
  "types": "./types/masterteam-forms-dynamic-form.d.ts",
44
44
  "default": "./fesm2022/masterteam-forms-dynamic-form.mjs"
45
45
  },
46
+ "./entity-list-add-form": {
47
+ "types": "./types/masterteam-forms-entity-list-add-form.d.ts",
48
+ "default": "./fesm2022/masterteam-forms-entity-list-add-form.mjs"
49
+ },
46
50
  "./pipes": {
47
51
  "types": "./types/masterteam-forms-pipes.d.ts",
48
52
  "default": "./fesm2022/masterteam-forms-pipes.mjs"
@@ -393,6 +393,13 @@ declare class ClientForm implements OnDestroy {
393
393
  readonly lang: _angular_core.WritableSignal<"en" | "ar">;
394
394
  readonly lookups: _angular_core.InputSignal<ClientLookup[]>;
395
395
  readonly ignoredFieldKeys: _angular_core.InputSignal<string[]>;
396
+ /**
397
+ * When non-empty, only fields whose property key is in this list are rendered
398
+ * in the editable form. The preview section is hidden as well so the form
399
+ * shows nothing but the allowed fields. Used by callers like the EntityList
400
+ * Write-mode add dialog to restrict the form to `writeFields`.
401
+ */
402
+ readonly allowedFieldKeys: _angular_core.InputSignal<string[]>;
396
403
  readonly rtl: _angular_core.Signal<boolean>;
397
404
  readonly stepNavigationValidating: _angular_core.Signal<boolean>;
398
405
  readonly loaded: _angular_core.OutputEmitterRef<ProcessFormLoadResponse>;
@@ -491,7 +498,7 @@ declare class ClientForm implements OnDestroy {
491
498
  private resolveTranslatableValue;
492
499
  private resolveStepTimelineState;
493
500
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ClientForm, never>;
494
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<ClientForm, "mt-client-form", never, { "moduleKey": { "alias": "moduleKey"; "required": true; "isSignal": true; }; "operationKey": { "alias": "operationKey"; "required": true; "isSignal": true; }; "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "levelId": { "alias": "levelId"; "required": false; "isSignal": true; }; "levelDataId": { "alias": "levelDataId"; "required": false; "isSignal": true; }; "moduleDataId": { "alias": "moduleDataId"; "required": false; "isSignal": true; }; "requestSchemaId": { "alias": "requestSchemaId"; "required": false; "isSignal": true; }; "draftProcessId": { "alias": "draftProcessId"; "required": false; "isSignal": true; }; "preview": { "alias": "preview"; "required": false; "isSignal": true; }; "returnUrl": { "alias": "returnUrl"; "required": false; "isSignal": true; }; "defaultValues": { "alias": "defaultValues"; "required": false; "isSignal": true; }; "submitRequestMapper": { "alias": "submitRequestMapper"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "autoLoad": { "alias": "autoLoad"; "required": false; "isSignal": true; }; "formMode": { "alias": "formMode"; "required": false; "isSignal": true; }; "renderMode": { "alias": "renderMode"; "required": false; "isSignal": true; }; "showInternalStepActions": { "alias": "showInternalStepActions"; "required": false; "isSignal": true; }; "confirmWarningsOnSubmit": { "alias": "confirmWarningsOnSubmit"; "required": false; "isSignal": true; }; "confirmWarningsOnStepChange": { "alias": "confirmWarningsOnStepChange"; "required": false; "isSignal": true; }; "lookups": { "alias": "lookups"; "required": false; "isSignal": true; }; "ignoredFieldKeys": { "alias": "ignoredFieldKeys"; "required": false; "isSignal": true; }; }, { "loaded": "loaded"; "submitted": "submitted"; "errored": "errored"; "modeDetected": "modeDetected"; "formSourceDetected": "formSourceDetected"; "footerStateChanged": "footerStateChanged"; }, never, never, true, never>;
501
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ClientForm, "mt-client-form", never, { "moduleKey": { "alias": "moduleKey"; "required": true; "isSignal": true; }; "operationKey": { "alias": "operationKey"; "required": true; "isSignal": true; }; "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "levelId": { "alias": "levelId"; "required": false; "isSignal": true; }; "levelDataId": { "alias": "levelDataId"; "required": false; "isSignal": true; }; "moduleDataId": { "alias": "moduleDataId"; "required": false; "isSignal": true; }; "requestSchemaId": { "alias": "requestSchemaId"; "required": false; "isSignal": true; }; "draftProcessId": { "alias": "draftProcessId"; "required": false; "isSignal": true; }; "preview": { "alias": "preview"; "required": false; "isSignal": true; }; "returnUrl": { "alias": "returnUrl"; "required": false; "isSignal": true; }; "defaultValues": { "alias": "defaultValues"; "required": false; "isSignal": true; }; "submitRequestMapper": { "alias": "submitRequestMapper"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "autoLoad": { "alias": "autoLoad"; "required": false; "isSignal": true; }; "formMode": { "alias": "formMode"; "required": false; "isSignal": true; }; "renderMode": { "alias": "renderMode"; "required": false; "isSignal": true; }; "showInternalStepActions": { "alias": "showInternalStepActions"; "required": false; "isSignal": true; }; "confirmWarningsOnSubmit": { "alias": "confirmWarningsOnSubmit"; "required": false; "isSignal": true; }; "confirmWarningsOnStepChange": { "alias": "confirmWarningsOnStepChange"; "required": false; "isSignal": true; }; "lookups": { "alias": "lookups"; "required": false; "isSignal": true; }; "ignoredFieldKeys": { "alias": "ignoredFieldKeys"; "required": false; "isSignal": true; }; "allowedFieldKeys": { "alias": "allowedFieldKeys"; "required": false; "isSignal": true; }; }, { "loaded": "loaded"; "submitted": "submitted"; "errored": "errored"; "modeDetected": "modeDetected"; "formSourceDetected": "formSourceDetected"; "footerStateChanged": "footerStateChanged"; }, never, never, true, never>;
495
502
  }
496
503
 
497
504
  interface TeamMemberApiDto {
@@ -37,6 +37,7 @@ declare class DynamicForm implements OnDestroy, ControlValueAccessor, Validator
37
37
  registerOnTouched(fn: () => void): void;
38
38
  private buildForm;
39
39
  private shouldCreateControl;
40
+ private refreshControlValidity;
40
41
  writeValue(value: any): void;
41
42
  validate(_control: AbstractControl): ValidationErrors | null;
42
43
  /**
@@ -0,0 +1,41 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { Provider } from '@angular/core';
3
+ import { ClientForm } from '@masterteam/forms/client-form';
4
+
5
+ /**
6
+ * Add-row dialog used by `mt-entity-list-field` in Write mode. Renders the
7
+ * full module form via `mt-client-form` (`/api/process-form-load`) but
8
+ * restricts the editable fields to the property keys listed in `writeFields`.
9
+ *
10
+ * Closes with the form's raw value on Save, or `null` on Cancel.
11
+ */
12
+ declare class EntityListAddFormDialog {
13
+ private readonly ref;
14
+ readonly moduleId: _angular_core.InputSignal<string | number | null>;
15
+ readonly levelId: _angular_core.InputSignal<string | number | null>;
16
+ readonly levelDataId: _angular_core.InputSignal<string | number | null>;
17
+ readonly writeFields: _angular_core.InputSignal<string[]>;
18
+ /** Pre-populated values (keyed by property key) when opening for Edit. */
19
+ readonly initialValues: _angular_core.InputSignal<Record<string, unknown>>;
20
+ protected readonly clientForm: _angular_core.Signal<ClientForm | undefined>;
21
+ protected readonly hasContext: _angular_core.Signal<boolean>;
22
+ protected readonly saving: _angular_core.WritableSignal<boolean>;
23
+ protected onCancel(): void;
24
+ /**
25
+ * Called when the ClientForm finishes loading its config. Patches the
26
+ * internal formControl with any pre-populated values (Edit mode).
27
+ */
28
+ protected onFormLoaded(): void;
29
+ protected onSave(): void;
30
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<EntityListAddFormDialog, never>;
31
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EntityListAddFormDialog, "mt-entity-list-add-form-dialog", never, { "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "levelId": { "alias": "levelId"; "required": false; "isSignal": true; }; "levelDataId": { "alias": "levelDataId"; "required": false; "isSignal": true; }; "writeFields": { "alias": "writeFields"; "required": false; "isSignal": true; }; "initialValues": { "alias": "initialValues"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
32
+ }
33
+
34
+ /**
35
+ * Registers the rich EntityList add-row dialog (powered by `mt-client-form`)
36
+ * for use by `mt-entity-list-field` Write mode. Without this provider the
37
+ * field falls back to a minimal text-only popup.
38
+ */
39
+ declare function provideEntityListAddForm(): Provider;
40
+
41
+ export { EntityListAddFormDialog, provideEntityListAddForm };