@solcre-org/core-ui 2.12.32 → 2.12.33

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.
@@ -167,9 +167,8 @@ class BaseFieldComponent {
167
167
  return this.errors().length > 0;
168
168
  });
169
169
  hasRequiredValidators = computed(() => {
170
- const modeConfig = this.field().modes?.[this.mode()];
171
- const validators = modeConfig?.validators ?? this.field().validators ?? [];
172
- return validators.some(validator => validator === Validators.required);
170
+ const validators = this.getCurrentValidators();
171
+ return validators.some((validator) => validator === Validators.required);
173
172
  });
174
173
  ngOnInit() {
175
174
  this.initializeFormControl();
@@ -183,12 +182,39 @@ class BaseFieldComponent {
183
182
  this.lastEmittedValue = newValue;
184
183
  }
185
184
  });
185
+ effect(() => {
186
+ const formValue = this.formValue();
187
+ const control = this.formControl();
188
+ if (control) {
189
+ const currentValidators = this.getCurrentValidators();
190
+ control.setValidators(currentValidators);
191
+ control.updateValueAndValidity({ emitEvent: false });
192
+ }
193
+ });
194
+ effect(() => {
195
+ const formValue = this.formValue();
196
+ const control = this.formControl();
197
+ const currentValue = this.value();
198
+ if (formValue && control && (currentValue === undefined || currentValue === null || currentValue === '')) {
199
+ const dynamicValue = this.getDynamicValue();
200
+ if (dynamicValue !== undefined && dynamicValue !== null) {
201
+ const controlValue = control.value;
202
+ if (this.normalizeValue(dynamicValue) !== this.normalizeValue(controlValue)) {
203
+ control.setValue(dynamicValue, { emitEvent: false });
204
+ this.lastEmittedValue = dynamicValue;
205
+ }
206
+ }
207
+ }
208
+ });
186
209
  }
187
210
  initializeFormControl() {
188
- const modeConfig = this.field().modes?.[this.mode()];
189
- const validators = modeConfig?.validators ?? this.field().validators ?? [];
190
- const initialValue = this.value() ?? '';
191
- this.formControl.set(new FormControl(initialValue, validators));
211
+ const initialValidators = this.getCurrentValidators();
212
+ let initialValue = this.value();
213
+ if (initialValue === undefined || initialValue === null) {
214
+ const dynamicValue = this.getDynamicValue();
215
+ initialValue = dynamicValue !== undefined ? dynamicValue : '';
216
+ }
217
+ this.formControl.set(new FormControl(initialValue, initialValidators));
192
218
  this.lastEmittedValue = initialValue;
193
219
  this.formControl().valueChanges.subscribe(newValue => {
194
220
  if (this.normalizeValue(newValue) !== this.normalizeValue(this.lastEmittedValue)) {
@@ -197,6 +223,38 @@ class BaseFieldComponent {
197
223
  }
198
224
  });
199
225
  }
226
+ getCurrentValidators() {
227
+ const modeConfig = this.field().modes?.[this.mode()];
228
+ const modeValidators = modeConfig?.validators;
229
+ const fieldValidators = this.field().validators;
230
+ const validatorConfig = modeValidators ?? fieldValidators ?? [];
231
+ if (typeof validatorConfig === 'function') {
232
+ try {
233
+ return validatorConfig(this.formValue());
234
+ }
235
+ catch (error) {
236
+ console.warn('Error evaluating dynamic validators:', error);
237
+ return [];
238
+ }
239
+ }
240
+ return validatorConfig;
241
+ }
242
+ getDynamicValue() {
243
+ const modeConfig = this.field().modes?.[this.mode()];
244
+ const modeDynamicValue = modeConfig?.dynamicValue;
245
+ const fieldDynamicValue = this.field().dynamicValue;
246
+ const dynamicValueConfig = modeDynamicValue ?? fieldDynamicValue;
247
+ if (typeof dynamicValueConfig === 'function') {
248
+ try {
249
+ return dynamicValueConfig(this.formValue());
250
+ }
251
+ catch (error) {
252
+ console.warn('Error evaluating dynamicValue:', error);
253
+ return undefined;
254
+ }
255
+ }
256
+ return undefined;
257
+ }
200
258
  normalizeValue(value) {
201
259
  if (value === null || value === undefined)
202
260
  return '';
@@ -687,10 +745,25 @@ class DatetimeFieldComponent {
687
745
  }));
688
746
  });
689
747
  hasRequiredValidators = computed(() => {
690
- const modeConfig = this.field().modes?.[this.mode()];
691
- const validators = modeConfig?.validators ?? this.field().validators ?? [];
692
- return validators.some(validator => validator === Validators.required);
748
+ const validators = this.getCurrentValidators();
749
+ return validators.some((validator) => validator === Validators.required);
693
750
  });
751
+ getCurrentValidators() {
752
+ const modeConfig = this.field().modes?.[this.mode()];
753
+ const modeValidators = modeConfig?.validators;
754
+ const fieldValidators = this.field().validators;
755
+ const validatorConfig = modeValidators ?? fieldValidators ?? [];
756
+ if (typeof validatorConfig === 'function') {
757
+ try {
758
+ return validatorConfig(this.formValue());
759
+ }
760
+ catch (error) {
761
+ console.warn('Error evaluating dynamic validators:', error);
762
+ return [];
763
+ }
764
+ }
765
+ return validatorConfig;
766
+ }
694
767
  formattedDate = computed(() => {
695
768
  const date = this.selectedDate();
696
769
  if (!date || isNaN(date.getTime()))
@@ -1468,15 +1541,14 @@ class FileFieldComponent extends BaseFieldComponent {
1468
1541
  setTimeout(() => this.regeneratePreviewsIfNeeded(), 200);
1469
1542
  }
1470
1543
  initializeFormControl() {
1471
- const modeConfig = this.field().modes?.[this.mode()];
1472
- const validators = modeConfig?.validators ?? this.field().validators ?? [];
1544
+ const currentValidators = this.getCurrentValidators();
1473
1545
  const initialValue = this.value() ?? null;
1474
1546
  const cfg = this.fieldConfig();
1475
1547
  const extraValidators = [];
1476
1548
  if (cfg.multiple && (cfg.minFiles || cfg.maxFiles)) {
1477
1549
  extraValidators.push(this.filesCountValidator(cfg.minFiles, cfg.maxFiles));
1478
1550
  }
1479
- this.formControl.set(new FormControl(initialValue, [...validators, ...extraValidators]));
1551
+ this.formControl.set(new FormControl(initialValue, [...currentValidators, ...extraValidators]));
1480
1552
  }
1481
1553
  filesCountValidator(min, max) {
1482
1554
  return (control) => {
@@ -3216,9 +3288,25 @@ class TimeFieldComponent {
3216
3288
  return this.errors().length > 0;
3217
3289
  });
3218
3290
  hasRequiredValidators = computed(() => {
3219
- const validators = this.field().validators || [];
3220
- return validators.some(validator => validator === Validators.required);
3291
+ const validators = this.getCurrentValidators();
3292
+ return validators.some((validator) => validator === Validators.required);
3221
3293
  });
3294
+ getCurrentValidators() {
3295
+ const modeConfig = this.field().modes?.[this.mode()];
3296
+ const modeValidators = modeConfig?.validators;
3297
+ const fieldValidators = this.field().validators;
3298
+ const validatorConfig = modeValidators ?? fieldValidators ?? [];
3299
+ if (typeof validatorConfig === 'function') {
3300
+ try {
3301
+ return validatorConfig(this.formValue());
3302
+ }
3303
+ catch (error) {
3304
+ console.warn('Error evaluating dynamic validators:', error);
3305
+ return [];
3306
+ }
3307
+ }
3308
+ return validatorConfig;
3309
+ }
3222
3310
  evaluateReadonly() {
3223
3311
  const readonly = this.field().readonly;
3224
3312
  if (typeof readonly === 'function') {
@@ -3549,10 +3637,25 @@ class MultiEntryFieldComponent {
3549
3637
  canRemove = computed(() => this.entries().length > this.minEntries());
3550
3638
  isDisabled = computed(() => this.mode() === ModalMode.VIEW);
3551
3639
  hasRequiredValidators = computed(() => {
3552
- const modeConfig = this.field().modes?.[this.mode()];
3553
- const validators = modeConfig?.validators ?? this.field().validators ?? [];
3554
- return validators.some(validator => validator === Validators.required);
3640
+ const validators = this.getCurrentValidators();
3641
+ return validators.some((validator) => validator === Validators.required);
3555
3642
  });
3643
+ getCurrentValidators() {
3644
+ const modeConfig = this.field().modes?.[this.mode()];
3645
+ const modeValidators = modeConfig?.validators;
3646
+ const fieldValidators = this.field().validators;
3647
+ const validatorConfig = modeValidators ?? fieldValidators ?? [];
3648
+ if (typeof validatorConfig === 'function') {
3649
+ try {
3650
+ return validatorConfig(this.formValue());
3651
+ }
3652
+ catch (error) {
3653
+ console.warn('Error evaluating dynamic validators:', error);
3654
+ return [];
3655
+ }
3656
+ }
3657
+ return validatorConfig;
3658
+ }
3556
3659
  constructor() {
3557
3660
  effect(() => {
3558
3661
  const inputValue = this.value();
@@ -8722,7 +8825,8 @@ class InlineEditService {
8722
8825
  return;
8723
8826
  const errors = [];
8724
8827
  const cellKey = this.getCellKey(row, column);
8725
- editableColumn.validators.forEach(validator => {
8828
+ const resolvedValidators = this.resolveValidators(editableColumn.validators, row);
8829
+ resolvedValidators.forEach((validator) => {
8726
8830
  const result = validator({ value });
8727
8831
  if (result && typeof result === 'object') {
8728
8832
  Object.keys(result).forEach(errorKey => {
@@ -8749,6 +8853,18 @@ class InlineEditService {
8749
8853
  }
8750
8854
  this.editingErrors.set(currentErrors);
8751
8855
  }
8856
+ resolveValidators(validatorConfig, row) {
8857
+ if (typeof validatorConfig === 'function') {
8858
+ try {
8859
+ return validatorConfig(row);
8860
+ }
8861
+ catch (error) {
8862
+ console.warn('Error evaluating dynamic validators in inline edit:', error);
8863
+ return [];
8864
+ }
8865
+ }
8866
+ return validatorConfig;
8867
+ }
8752
8868
  getCellErrors(row, column) {
8753
8869
  const cellKey = this.getCellKey(row, column);
8754
8870
  return this.editingErrors().get(cellKey) || [];
@@ -12243,12 +12359,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
12243
12359
  // Este archivo es generado automáticamente por scripts/update-version.js
12244
12360
  // No edites manualmente este archivo
12245
12361
  const VERSION = {
12246
- full: '2.12.32',
12362
+ full: '2.12.33',
12247
12363
  major: 2,
12248
12364
  minor: 12,
12249
- patch: 32,
12250
- timestamp: '2025-09-15T19:43:40.649Z',
12251
- buildDate: '15/9/2025'
12365
+ patch: 33,
12366
+ timestamp: '2025-09-16T10:31:16.858Z',
12367
+ buildDate: '16/9/2025'
12252
12368
  };
12253
12369
 
12254
12370
  class MainNavComponent {