@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
@@ -45251,6 +45251,12 @@ class UiSpecificaTerritorialeComponent {
45251
45251
  }
45252
45252
  return value;
45253
45253
  }
45254
+ emitFormValueIfReady() {
45255
+ if (!this.isInitializing && this.tipologicheLoaded) {
45256
+ this.onChange(this.form.getRawValue());
45257
+ this.notifyValidationChange();
45258
+ }
45259
+ }
45254
45260
  // ─── Subscriptions ──────────────────────────────────────────────
45255
45261
  setupFormSubscriptions() {
45256
45262
  // Subscription per i cambiamenti territoriali (nazione/provincia/comune)
@@ -45269,14 +45275,13 @@ class UiSpecificaTerritorialeComponent {
45269
45275
  this.handleTerritorialChanges(nazioneId, provinciaId, comuneId);
45270
45276
  }
45271
45277
  });
45272
- // Subscription per tutti i cambiamenti del form
45278
+ // Subscription per tutti i cambiamenti del form.
45279
+ // getRawValue(): i campi disabilitati (es. CAP auto-selezionato, nazione con italyByDefault)
45280
+ // non compaiono in form.value ma devono essere propagati al form parent.
45273
45281
  this.form.valueChanges
45274
45282
  .pipe(takeUntil$1(this.destroy$), distinctUntilChanged((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)))
45275
- .subscribe((formValue) => {
45276
- if (!this.isInitializing && this.tipologicheLoaded) {
45277
- this.onChange(formValue);
45278
- this.notifyValidationChange();
45279
- }
45283
+ .subscribe(() => {
45284
+ this.emitFormValueIfReady();
45280
45285
  });
45281
45286
  this.cdr.detectChanges();
45282
45287
  }
@@ -45305,6 +45310,7 @@ class UiSpecificaTerritorialeComponent {
45305
45310
  this.filteredCaps = [];
45306
45311
  }
45307
45312
  this.applyFieldsDisabledState();
45313
+ this.emitFormValueIfReady();
45308
45314
  }
45309
45315
  async updateFilteredComuni(provinciaId) {
45310
45316
  if (!provinciaId) {
@@ -49246,6 +49252,69 @@ class UiFormWizardComponent {
49246
49252
  await this.wizardConfig.onStepSave(data, this.state.currentStep);
49247
49253
  }
49248
49254
  }
49255
+ /**
49256
+ * Scansiona gli step in ordine, marca come completati quelli validi rispetto alle
49257
+ * stesse regole di Next/Completa e posiziona il wizard sul primo step non valido
49258
+ * (o sull'ultimo se tutti validi). Utile dopo il preload di `initialData` in edit.
49259
+ */
49260
+ async resumeCompletedStepsFromValidation(options) {
49261
+ const emitStepComplete = options?.emitStepComplete ?? false;
49262
+ const emitStepSave = options?.emitStepSave ?? false;
49263
+ if (!this.schema || this.state.totalSteps <= 0) {
49264
+ return { lastCompletedStep: -1, currentStep: 0 };
49265
+ }
49266
+ this.logger?.logWizardAction('resume', {
49267
+ wizardId: this.wizardConfig?.wizardId,
49268
+ schemaId: this.schema.id,
49269
+ totalSteps: this.state.totalSteps,
49270
+ });
49271
+ const completed = new Set();
49272
+ let lastCompletedStep = -1;
49273
+ let targetStep = 0;
49274
+ for (let i = 0; i < this.state.totalSteps; i++) {
49275
+ const ready = await this.prepareStepForValidation(i);
49276
+ if (!ready) {
49277
+ targetStep = i;
49278
+ break;
49279
+ }
49280
+ const valid = await this.validateCurrentStep({
49281
+ emitStepComplete,
49282
+ emitStepValidationFailed: false,
49283
+ });
49284
+ if (!valid) {
49285
+ targetStep = i;
49286
+ break;
49287
+ }
49288
+ completed.add(i);
49289
+ lastCompletedStep = i;
49290
+ targetStep = i;
49291
+ this.accumulatedData = {
49292
+ ...this.accumulatedData,
49293
+ ...(this.formBuilder?.getFormValue() || {}),
49294
+ };
49295
+ if (emitStepSave) {
49296
+ await this.autoSaveIfNeeded();
49297
+ }
49298
+ }
49299
+ this.state.completedSteps = completed;
49300
+ for (let v = 0; v <= targetStep; v++) {
49301
+ this.state.visitedSteps.add(v);
49302
+ }
49303
+ if (this.state.currentStep !== targetStep) {
49304
+ this.navigateToStep(targetStep);
49305
+ }
49306
+ else {
49307
+ this.syncWizardState();
49308
+ this.cdr.markForCheck();
49309
+ }
49310
+ this.logger?.logWizardAction('resumeComplete', {
49311
+ wizardId: this.wizardConfig?.wizardId,
49312
+ lastCompletedStep,
49313
+ currentStep: targetStep,
49314
+ completedSteps: Array.from(completed),
49315
+ });
49316
+ return { lastCompletedStep, currentStep: targetStep };
49317
+ }
49249
49318
  // ─── Callback form builder ─────────────────────────────────────
49250
49319
  onValueChange(data) {
49251
49320
  this.accumulatedData = { ...this.accumulatedData, ...data };
@@ -49286,7 +49355,9 @@ class UiFormWizardComponent {
49286
49355
  this.syncWizardState();
49287
49356
  this.cdr.markForCheck();
49288
49357
  }
49289
- async validateCurrentStep() {
49358
+ async validateCurrentStep(options) {
49359
+ const emitStepComplete = options?.emitStepComplete ?? true;
49360
+ const emitStepValidationFailed = options?.emitStepValidationFailed ?? true;
49290
49361
  this.formBuilder?.validateAllFields();
49291
49362
  const group = this.wizardStepGroups[this.state.currentStep];
49292
49363
  const primary = group?.[0];
@@ -49300,10 +49371,12 @@ class UiFormWizardComponent {
49300
49371
  if (customFnName && this.customValidationMethods[customFnName]) {
49301
49372
  const customValid = await this.customValidationMethods[customFnName](this.accumulatedData, this.state.currentStep, isFormValid);
49302
49373
  if (!customValid) {
49303
- this.stepValidationFailed.emit({
49304
- step: this.state.currentStep,
49305
- errors: ['Validazione custom fallita'],
49306
- });
49374
+ if (emitStepValidationFailed) {
49375
+ this.stepValidationFailed.emit({
49376
+ step: this.state.currentStep,
49377
+ errors: ['Validazione custom fallita'],
49378
+ });
49379
+ }
49307
49380
  return false;
49308
49381
  }
49309
49382
  }
@@ -49318,23 +49391,43 @@ class UiFormWizardComponent {
49318
49391
  step: this.state.currentStep,
49319
49392
  errors,
49320
49393
  });
49321
- this.stepValidationFailed.emit({
49394
+ if (emitStepValidationFailed) {
49395
+ this.stepValidationFailed.emit({
49396
+ step: this.state.currentStep,
49397
+ errors,
49398
+ });
49399
+ }
49400
+ return false;
49401
+ }
49402
+ if (emitStepComplete) {
49403
+ this.logger?.logWizardAction('stepComplete', {
49404
+ wizardId: this.wizardConfig.wizardId,
49322
49405
  step: this.state.currentStep,
49323
- errors,
49406
+ schemaId: this.schema?.id,
49407
+ });
49408
+ this.stepComplete.emit({
49409
+ step: this.state.currentStep,
49410
+ data: this.formBuilder?.getFormValue() || {},
49324
49411
  });
49325
- return false;
49326
49412
  }
49327
- this.logger?.logWizardAction('stepComplete', {
49328
- wizardId: this.wizardConfig.wizardId,
49329
- step: this.state.currentStep,
49330
- schemaId: this.schema?.id,
49331
- });
49332
- this.stepComplete.emit({
49333
- step: this.state.currentStep,
49334
- data: this.formBuilder?.getFormValue() || {},
49335
- });
49336
49413
  return true;
49337
49414
  }
49415
+ /** Naviga allo step e attende il mount del form builder per la validazione resume. */
49416
+ async prepareStepForValidation(stepIndex) {
49417
+ this.navigateToStep(stepIndex);
49418
+ return this.waitForFormBuilderReady();
49419
+ }
49420
+ async waitForFormBuilderReady(maxAttempts = 30) {
49421
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
49422
+ this.cdr.detectChanges();
49423
+ if (this.formBuilder) {
49424
+ await Promise.resolve();
49425
+ return true;
49426
+ }
49427
+ await new Promise((resolve) => setTimeout(resolve, 0));
49428
+ }
49429
+ return false;
49430
+ }
49338
49431
  /**
49339
49432
  * Raggruppa le sezioni con `wizardStep` per `stepNumber` (ordine stabile per numero, poi ordine di apparizione nello schema).
49340
49433
  */