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

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 (45) hide show
  1. package/crud-table/lib/components/form-builder/types/schema.types.d.ts +20 -0
  2. package/crud-table/lib/core/logging/logger.service.d.ts +1 -1
  3. package/esm2022/crud-table/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  4. package/esm2022/crud-table/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  5. package/esm2022/crud-table/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  6. package/esm2022/crud-table/lib/components/form-builder/types/schema.types.mjs +1 -1
  7. package/esm2022/crud-table/lib/core/logging/logger.service.mjs +1 -1
  8. package/esm2022/form-builder/lib/components/form-builder/form-wizard.component.mjs +105 -18
  9. package/esm2022/form-builder/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  10. package/esm2022/form-builder/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  11. package/esm2022/form-builder/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  12. package/esm2022/form-builder/lib/components/form-builder/types/index.mjs +1 -1
  13. package/esm2022/form-builder/lib/components/form-builder/types/schema.types.mjs +1 -1
  14. package/esm2022/form-builder/lib/core/logging/logger.service.mjs +1 -1
  15. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  16. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  17. package/esm2022/form-builder-editor/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  18. package/esm2022/form-builder-editor/lib/components/form-builder/types/index.mjs +1 -1
  19. package/esm2022/form-builder-editor/lib/components/form-builder/types/schema.types.mjs +1 -1
  20. package/esm2022/form-builder-editor/lib/core/logging/logger.service.mjs +1 -1
  21. package/esm2022/lib/components/form-builder/form-wizard.component.mjs +105 -18
  22. package/esm2022/lib/components/form-builder/sub-components/form-fields/form-number-field.component.mjs +1 -1
  23. package/esm2022/lib/components/form-builder/sub-components/form-fields/form-radio-field.component.mjs +1 -1
  24. package/esm2022/lib/components/form-builder/sub-components/form-fields/form-select-field.component.mjs +1 -1
  25. package/esm2022/lib/components/form-builder/types/index.mjs +1 -1
  26. package/esm2022/lib/components/form-builder/types/schema.types.mjs +1 -1
  27. package/esm2022/lib/core/logging/logger.service.mjs +1 -1
  28. package/fesm2022/gnggln-ng-ui-system-crud-table.mjs.map +1 -1
  29. package/fesm2022/gnggln-ng-ui-system-form-builder-editor.mjs.map +1 -1
  30. package/fesm2022/gnggln-ng-ui-system-form-builder.mjs +104 -17
  31. package/fesm2022/gnggln-ng-ui-system-form-builder.mjs.map +1 -1
  32. package/fesm2022/gnggln-ng-ui-system.mjs +104 -17
  33. package/fesm2022/gnggln-ng-ui-system.mjs.map +1 -1
  34. package/form-builder/lib/components/form-builder/form-wizard.component.d.ts +10 -1
  35. package/form-builder/lib/components/form-builder/types/index.d.ts +1 -1
  36. package/form-builder/lib/components/form-builder/types/schema.types.d.ts +20 -0
  37. package/form-builder/lib/core/logging/logger.service.d.ts +1 -1
  38. package/form-builder-editor/lib/components/form-builder/types/index.d.ts +1 -1
  39. package/form-builder-editor/lib/components/form-builder/types/schema.types.d.ts +20 -0
  40. package/form-builder-editor/lib/core/logging/logger.service.d.ts +1 -1
  41. package/lib/components/form-builder/form-wizard.component.d.ts +10 -1
  42. package/lib/components/form-builder/types/index.d.ts +1 -1
  43. package/lib/components/form-builder/types/schema.types.d.ts +20 -0
  44. package/lib/core/logging/logger.service.d.ts +1 -1
  45. package/package.json +30 -30
@@ -51068,6 +51068,69 @@ class UiFormWizardComponent {
51068
51068
  await this.wizardConfig.onStepSave(data, this.state.currentStep);
51069
51069
  }
51070
51070
  }
51071
+ /**
51072
+ * Scansiona gli step in ordine, marca come completati quelli validi rispetto alle
51073
+ * stesse regole di Next/Completa e posiziona il wizard sul primo step non valido
51074
+ * (o sull'ultimo se tutti validi). Utile dopo il preload di `initialData` in edit.
51075
+ */
51076
+ async resumeCompletedStepsFromValidation(options) {
51077
+ const emitStepComplete = options?.emitStepComplete ?? false;
51078
+ const emitStepSave = options?.emitStepSave ?? false;
51079
+ if (!this.schema || this.state.totalSteps <= 0) {
51080
+ return { lastCompletedStep: -1, currentStep: 0 };
51081
+ }
51082
+ this.logger?.logWizardAction('resume', {
51083
+ wizardId: this.wizardConfig?.wizardId,
51084
+ schemaId: this.schema.id,
51085
+ totalSteps: this.state.totalSteps,
51086
+ });
51087
+ const completed = new Set();
51088
+ let lastCompletedStep = -1;
51089
+ let targetStep = 0;
51090
+ for (let i = 0; i < this.state.totalSteps; i++) {
51091
+ const ready = await this.prepareStepForValidation(i);
51092
+ if (!ready) {
51093
+ targetStep = i;
51094
+ break;
51095
+ }
51096
+ const valid = await this.validateCurrentStep({
51097
+ emitStepComplete,
51098
+ emitStepValidationFailed: false,
51099
+ });
51100
+ if (!valid) {
51101
+ targetStep = i;
51102
+ break;
51103
+ }
51104
+ completed.add(i);
51105
+ lastCompletedStep = i;
51106
+ targetStep = i;
51107
+ this.accumulatedData = {
51108
+ ...this.accumulatedData,
51109
+ ...(this.formBuilder?.getFormValue() || {}),
51110
+ };
51111
+ if (emitStepSave) {
51112
+ await this.autoSaveIfNeeded();
51113
+ }
51114
+ }
51115
+ this.state.completedSteps = completed;
51116
+ for (let v = 0; v <= targetStep; v++) {
51117
+ this.state.visitedSteps.add(v);
51118
+ }
51119
+ if (this.state.currentStep !== targetStep) {
51120
+ this.navigateToStep(targetStep);
51121
+ }
51122
+ else {
51123
+ this.syncWizardState();
51124
+ this.cdr.markForCheck();
51125
+ }
51126
+ this.logger?.logWizardAction('resumeComplete', {
51127
+ wizardId: this.wizardConfig?.wizardId,
51128
+ lastCompletedStep,
51129
+ currentStep: targetStep,
51130
+ completedSteps: Array.from(completed),
51131
+ });
51132
+ return { lastCompletedStep, currentStep: targetStep };
51133
+ }
51071
51134
  // ─── Callback form builder ─────────────────────────────────────
51072
51135
  onValueChange(data) {
51073
51136
  this.accumulatedData = { ...this.accumulatedData, ...data };
@@ -51108,7 +51171,9 @@ class UiFormWizardComponent {
51108
51171
  this.syncWizardState();
51109
51172
  this.cdr.markForCheck();
51110
51173
  }
51111
- async validateCurrentStep() {
51174
+ async validateCurrentStep(options) {
51175
+ const emitStepComplete = options?.emitStepComplete ?? true;
51176
+ const emitStepValidationFailed = options?.emitStepValidationFailed ?? true;
51112
51177
  this.formBuilder?.validateAllFields();
51113
51178
  const group = this.wizardStepGroups[this.state.currentStep];
51114
51179
  const primary = group?.[0];
@@ -51122,10 +51187,12 @@ class UiFormWizardComponent {
51122
51187
  if (customFnName && this.customValidationMethods[customFnName]) {
51123
51188
  const customValid = await this.customValidationMethods[customFnName](this.accumulatedData, this.state.currentStep, isFormValid);
51124
51189
  if (!customValid) {
51125
- this.stepValidationFailed.emit({
51126
- step: this.state.currentStep,
51127
- errors: ['Validazione custom fallita'],
51128
- });
51190
+ if (emitStepValidationFailed) {
51191
+ this.stepValidationFailed.emit({
51192
+ step: this.state.currentStep,
51193
+ errors: ['Validazione custom fallita'],
51194
+ });
51195
+ }
51129
51196
  return false;
51130
51197
  }
51131
51198
  }
@@ -51140,23 +51207,43 @@ class UiFormWizardComponent {
51140
51207
  step: this.state.currentStep,
51141
51208
  errors,
51142
51209
  });
51143
- this.stepValidationFailed.emit({
51210
+ if (emitStepValidationFailed) {
51211
+ this.stepValidationFailed.emit({
51212
+ step: this.state.currentStep,
51213
+ errors,
51214
+ });
51215
+ }
51216
+ return false;
51217
+ }
51218
+ if (emitStepComplete) {
51219
+ this.logger?.logWizardAction('stepComplete', {
51220
+ wizardId: this.wizardConfig.wizardId,
51221
+ step: this.state.currentStep,
51222
+ schemaId: this.schema?.id,
51223
+ });
51224
+ this.stepComplete.emit({
51144
51225
  step: this.state.currentStep,
51145
- errors,
51226
+ data: this.formBuilder?.getFormValue() || {},
51146
51227
  });
51147
- return false;
51148
51228
  }
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
51229
  return true;
51159
51230
  }
51231
+ /** Naviga allo step e attende il mount del form builder per la validazione resume. */
51232
+ async prepareStepForValidation(stepIndex) {
51233
+ this.navigateToStep(stepIndex);
51234
+ return this.waitForFormBuilderReady();
51235
+ }
51236
+ async waitForFormBuilderReady(maxAttempts = 30) {
51237
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
51238
+ this.cdr.detectChanges();
51239
+ if (this.formBuilder) {
51240
+ await Promise.resolve();
51241
+ return true;
51242
+ }
51243
+ await new Promise((resolve) => setTimeout(resolve, 0));
51244
+ }
51245
+ return false;
51246
+ }
51160
51247
  /**
51161
51248
  * Raggruppa le sezioni con `wizardStep` per `stepNumber` (ordine stabile per numero, poi ordine di apparizione nello schema).
51162
51249
  */