@gnggln/ng-ui-system 1.0.0-alpha.21 → 1.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/crud-table/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.d.ts +1 -0
  2. package/crud-table/lib/components/form-builder/types/schema.types.d.ts +20 -0
  3. package/crud-table/lib/core/logging/logger.service.d.ts +1 -1
  4. package/esm2022/crud-table/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  5. package/esm2022/crud-table/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  6. package/esm2022/crud-table/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  7. package/esm2022/crud-table/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.mjs +13 -7
  8. package/esm2022/crud-table/lib/components/form-builder/types/schema.types.mjs +1 -1
  9. package/esm2022/crud-table/lib/core/logging/logger.service.mjs +1 -1
  10. package/esm2022/form-builder/lib/components/form-builder/form-wizard.component.mjs +105 -18
  11. package/esm2022/form-builder/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  12. package/esm2022/form-builder/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  13. package/esm2022/form-builder/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  14. package/esm2022/form-builder/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.mjs +13 -7
  15. package/esm2022/form-builder/lib/components/form-builder/types/index.mjs +1 -1
  16. package/esm2022/form-builder/lib/components/form-builder/types/schema.types.mjs +1 -1
  17. package/esm2022/form-builder/lib/core/logging/logger.service.mjs +1 -1
  18. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  19. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  20. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  21. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.mjs +13 -7
  22. package/esm2022/form-builder-editor/lib/components/form-builder/types/index.mjs +1 -1
  23. package/esm2022/form-builder-editor/lib/components/form-builder/types/schema.types.mjs +1 -1
  24. package/esm2022/form-builder-editor/lib/core/logging/logger.service.mjs +1 -1
  25. package/esm2022/lib/components/form-builder/form-wizard.component.mjs +105 -18
  26. package/esm2022/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  27. package/esm2022/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  28. package/esm2022/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  29. package/esm2022/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.mjs +13 -7
  30. package/esm2022/lib/components/form-builder/types/index.mjs +1 -1
  31. package/esm2022/lib/components/form-builder/types/schema.types.mjs +1 -1
  32. package/esm2022/lib/core/logging/logger.service.mjs +1 -1
  33. package/fesm2022/gnggln-ng-ui-system-crud-table.mjs +12 -6
  34. package/fesm2022/gnggln-ng-ui-system-crud-table.mjs.map +1 -1
  35. package/fesm2022/gnggln-ng-ui-system-form-builder-editor.mjs +12 -6
  36. package/fesm2022/gnggln-ng-ui-system-form-builder-editor.mjs.map +1 -1
  37. package/fesm2022/gnggln-ng-ui-system-form-builder.mjs +116 -23
  38. package/fesm2022/gnggln-ng-ui-system-form-builder.mjs.map +1 -1
  39. package/fesm2022/gnggln-ng-ui-system.mjs +116 -23
  40. package/fesm2022/gnggln-ng-ui-system.mjs.map +1 -1
  41. package/form-builder/lib/components/form-builder/form-wizard.component.d.ts +10 -1
  42. package/form-builder/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.d.ts +1 -0
  43. package/form-builder/lib/components/form-builder/types/index.d.ts +1 -1
  44. package/form-builder/lib/components/form-builder/types/schema.types.d.ts +20 -0
  45. package/form-builder/lib/core/logging/logger.service.d.ts +1 -1
  46. package/form-builder-editor/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.d.ts +1 -0
  47. package/form-builder-editor/lib/components/form-builder/types/index.d.ts +1 -1
  48. package/form-builder-editor/lib/components/form-builder/types/schema.types.d.ts +20 -0
  49. package/form-builder-editor/lib/core/logging/logger.service.d.ts +1 -1
  50. package/lib/components/form-builder/form-wizard.component.d.ts +10 -1
  51. package/lib/components/form-builder/sub-components/specifica-territoriale/specifica-territoriale.component.d.ts +1 -0
  52. package/lib/components/form-builder/types/index.d.ts +1 -1
  53. package/lib/components/form-builder/types/schema.types.d.ts +20 -0
  54. package/lib/core/logging/logger.service.d.ts +1 -1
  55. package/package.json +13 -13
@@ -46280,6 +46280,12 @@ class UiSpecificaTerritorialeComponent {
46280
46280
  }
46281
46281
  return value;
46282
46282
  }
46283
+ emitFormValueIfReady() {
46284
+ if (!this.isInitializing && this.tipologicheLoaded) {
46285
+ this.onChange(this.form.getRawValue());
46286
+ this.notifyValidationChange();
46287
+ }
46288
+ }
46283
46289
  // ─── Subscriptions ──────────────────────────────────────────────
46284
46290
  setupFormSubscriptions() {
46285
46291
  // Subscription per i cambiamenti territoriali (nazione/provincia/comune)
@@ -46298,14 +46304,13 @@ class UiSpecificaTerritorialeComponent {
46298
46304
  this.handleTerritorialChanges(nazioneId, provinciaId, comuneId);
46299
46305
  }
46300
46306
  });
46301
- // Subscription per tutti i cambiamenti del form
46307
+ // Subscription per tutti i cambiamenti del form.
46308
+ // getRawValue(): i campi disabilitati (es. CAP auto-selezionato, nazione con italyByDefault)
46309
+ // non compaiono in form.value ma devono essere propagati al form parent.
46302
46310
  this.form.valueChanges
46303
46311
  .pipe(takeUntil$1(this.destroy$), distinctUntilChanged((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)))
46304
- .subscribe((formValue) => {
46305
- if (!this.isInitializing && this.tipologicheLoaded) {
46306
- this.onChange(formValue);
46307
- this.notifyValidationChange();
46308
- }
46312
+ .subscribe(() => {
46313
+ this.emitFormValueIfReady();
46309
46314
  });
46310
46315
  this.cdr.detectChanges();
46311
46316
  }
@@ -46334,6 +46339,7 @@ class UiSpecificaTerritorialeComponent {
46334
46339
  this.filteredCaps = [];
46335
46340
  }
46336
46341
  this.applyFieldsDisabledState();
46342
+ this.emitFormValueIfReady();
46337
46343
  }
46338
46344
  async updateFilteredComuni(provinciaId) {
46339
46345
  if (!provinciaId) {
@@ -51068,6 +51074,69 @@ class UiFormWizardComponent {
51068
51074
  await this.wizardConfig.onStepSave(data, this.state.currentStep);
51069
51075
  }
51070
51076
  }
51077
+ /**
51078
+ * Scansiona gli step in ordine, marca come completati quelli validi rispetto alle
51079
+ * stesse regole di Next/Completa e posiziona il wizard sul primo step non valido
51080
+ * (o sull'ultimo se tutti validi). Utile dopo il preload di `initialData` in edit.
51081
+ */
51082
+ async resumeCompletedStepsFromValidation(options) {
51083
+ const emitStepComplete = options?.emitStepComplete ?? false;
51084
+ const emitStepSave = options?.emitStepSave ?? false;
51085
+ if (!this.schema || this.state.totalSteps <= 0) {
51086
+ return { lastCompletedStep: -1, currentStep: 0 };
51087
+ }
51088
+ this.logger?.logWizardAction('resume', {
51089
+ wizardId: this.wizardConfig?.wizardId,
51090
+ schemaId: this.schema.id,
51091
+ totalSteps: this.state.totalSteps,
51092
+ });
51093
+ const completed = new Set();
51094
+ let lastCompletedStep = -1;
51095
+ let targetStep = 0;
51096
+ for (let i = 0; i < this.state.totalSteps; i++) {
51097
+ const ready = await this.prepareStepForValidation(i);
51098
+ if (!ready) {
51099
+ targetStep = i;
51100
+ break;
51101
+ }
51102
+ const valid = await this.validateCurrentStep({
51103
+ emitStepComplete,
51104
+ emitStepValidationFailed: false,
51105
+ });
51106
+ if (!valid) {
51107
+ targetStep = i;
51108
+ break;
51109
+ }
51110
+ completed.add(i);
51111
+ lastCompletedStep = i;
51112
+ targetStep = i;
51113
+ this.accumulatedData = {
51114
+ ...this.accumulatedData,
51115
+ ...(this.formBuilder?.getFormValue() || {}),
51116
+ };
51117
+ if (emitStepSave) {
51118
+ await this.autoSaveIfNeeded();
51119
+ }
51120
+ }
51121
+ this.state.completedSteps = completed;
51122
+ for (let v = 0; v <= targetStep; v++) {
51123
+ this.state.visitedSteps.add(v);
51124
+ }
51125
+ if (this.state.currentStep !== targetStep) {
51126
+ this.navigateToStep(targetStep);
51127
+ }
51128
+ else {
51129
+ this.syncWizardState();
51130
+ this.cdr.markForCheck();
51131
+ }
51132
+ this.logger?.logWizardAction('resumeComplete', {
51133
+ wizardId: this.wizardConfig?.wizardId,
51134
+ lastCompletedStep,
51135
+ currentStep: targetStep,
51136
+ completedSteps: Array.from(completed),
51137
+ });
51138
+ return { lastCompletedStep, currentStep: targetStep };
51139
+ }
51071
51140
  // ─── Callback form builder ─────────────────────────────────────
51072
51141
  onValueChange(data) {
51073
51142
  this.accumulatedData = { ...this.accumulatedData, ...data };
@@ -51108,7 +51177,9 @@ class UiFormWizardComponent {
51108
51177
  this.syncWizardState();
51109
51178
  this.cdr.markForCheck();
51110
51179
  }
51111
- async validateCurrentStep() {
51180
+ async validateCurrentStep(options) {
51181
+ const emitStepComplete = options?.emitStepComplete ?? true;
51182
+ const emitStepValidationFailed = options?.emitStepValidationFailed ?? true;
51112
51183
  this.formBuilder?.validateAllFields();
51113
51184
  const group = this.wizardStepGroups[this.state.currentStep];
51114
51185
  const primary = group?.[0];
@@ -51122,10 +51193,12 @@ class UiFormWizardComponent {
51122
51193
  if (customFnName && this.customValidationMethods[customFnName]) {
51123
51194
  const customValid = await this.customValidationMethods[customFnName](this.accumulatedData, this.state.currentStep, isFormValid);
51124
51195
  if (!customValid) {
51125
- this.stepValidationFailed.emit({
51126
- step: this.state.currentStep,
51127
- errors: ['Validazione custom fallita'],
51128
- });
51196
+ if (emitStepValidationFailed) {
51197
+ this.stepValidationFailed.emit({
51198
+ step: this.state.currentStep,
51199
+ errors: ['Validazione custom fallita'],
51200
+ });
51201
+ }
51129
51202
  return false;
51130
51203
  }
51131
51204
  }
@@ -51140,23 +51213,43 @@ class UiFormWizardComponent {
51140
51213
  step: this.state.currentStep,
51141
51214
  errors,
51142
51215
  });
51143
- this.stepValidationFailed.emit({
51216
+ if (emitStepValidationFailed) {
51217
+ this.stepValidationFailed.emit({
51218
+ step: this.state.currentStep,
51219
+ errors,
51220
+ });
51221
+ }
51222
+ return false;
51223
+ }
51224
+ if (emitStepComplete) {
51225
+ this.logger?.logWizardAction('stepComplete', {
51226
+ wizardId: this.wizardConfig.wizardId,
51144
51227
  step: this.state.currentStep,
51145
- errors,
51228
+ schemaId: this.schema?.id,
51229
+ });
51230
+ this.stepComplete.emit({
51231
+ step: this.state.currentStep,
51232
+ data: this.formBuilder?.getFormValue() || {},
51146
51233
  });
51147
- return false;
51148
51234
  }
51149
- this.logger?.logWizardAction('stepComplete', {
51150
- wizardId: this.wizardConfig.wizardId,
51151
- step: this.state.currentStep,
51152
- schemaId: this.schema?.id,
51153
- });
51154
- this.stepComplete.emit({
51155
- step: this.state.currentStep,
51156
- data: this.formBuilder?.getFormValue() || {},
51157
- });
51158
51235
  return true;
51159
51236
  }
51237
+ /** Naviga allo step e attende il mount del form builder per la validazione resume. */
51238
+ async prepareStepForValidation(stepIndex) {
51239
+ this.navigateToStep(stepIndex);
51240
+ return this.waitForFormBuilderReady();
51241
+ }
51242
+ async waitForFormBuilderReady(maxAttempts = 30) {
51243
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
51244
+ this.cdr.detectChanges();
51245
+ if (this.formBuilder) {
51246
+ await Promise.resolve();
51247
+ return true;
51248
+ }
51249
+ await new Promise((resolve) => setTimeout(resolve, 0));
51250
+ }
51251
+ return false;
51252
+ }
51160
51253
  /**
51161
51254
  * Raggruppa le sezioni con `wizardStep` per `stepNumber` (ordine stabile per numero, poi ordine di apparizione nello schema).
51162
51255
  */