@solcre-org/core-ui 2.12.38 → 2.12.39
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.
|
@@ -2154,6 +2154,8 @@ class SelectFieldComponent extends BaseFieldComponent {
|
|
|
2154
2154
|
selectionChange = output();
|
|
2155
2155
|
isInitialized = signal(false);
|
|
2156
2156
|
hasValue = signal(false);
|
|
2157
|
+
userHasInteracted = signal(false);
|
|
2158
|
+
lastDynamicValue = undefined;
|
|
2157
2159
|
computedValue = computed(() => {
|
|
2158
2160
|
const value = this.value();
|
|
2159
2161
|
if (this.field().multiple && !Array.isArray(value)) {
|
|
@@ -2207,17 +2209,13 @@ class SelectFieldComponent extends BaseFieldComponent {
|
|
|
2207
2209
|
const formValue = this.formValue();
|
|
2208
2210
|
if ('dynamicValue' in fieldCfg && typeof fieldCfg.dynamicValue === 'function' && formValue) {
|
|
2209
2211
|
const newValue = fieldCfg.dynamicValue(formValue);
|
|
2210
|
-
|
|
2211
|
-
if (newValue !== null && newValue !== undefined && newValue !== currentValue) {
|
|
2212
|
-
setTimeout(() => {
|
|
2213
|
-
this.formControl().setValue(newValue, { emitEvent: true });
|
|
2214
|
-
this.valueChange.emit(newValue);
|
|
2215
|
-
}, 0);
|
|
2216
|
-
}
|
|
2212
|
+
this.scheduleDynamicValue(newValue);
|
|
2217
2213
|
}
|
|
2218
2214
|
});
|
|
2219
2215
|
}
|
|
2220
2216
|
ngOnInit() {
|
|
2217
|
+
this.userHasInteracted.set(false);
|
|
2218
|
+
this.lastDynamicValue = undefined;
|
|
2221
2219
|
super.ngOnInit();
|
|
2222
2220
|
const currentInitialValue = this.formControl().value;
|
|
2223
2221
|
if (!this.field().multiple && typeof currentInitialValue === 'string' && currentInitialValue.trim() === '') {
|
|
@@ -2241,12 +2239,7 @@ class SelectFieldComponent extends BaseFieldComponent {
|
|
|
2241
2239
|
const formValue = this.formValue();
|
|
2242
2240
|
if ('dynamicValue' in fieldCfg && typeof fieldCfg.dynamicValue === 'function' && formValue) {
|
|
2243
2241
|
const newValue = fieldCfg.dynamicValue(formValue);
|
|
2244
|
-
|
|
2245
|
-
if (newValue !== null && newValue !== undefined && newValue !== currentValue) {
|
|
2246
|
-
this.formControl().setValue(newValue, { emitEvent: true });
|
|
2247
|
-
this.valueChange.emit(newValue);
|
|
2248
|
-
this.hasValue.set(true);
|
|
2249
|
-
}
|
|
2242
|
+
this.scheduleDynamicValue(newValue);
|
|
2250
2243
|
}
|
|
2251
2244
|
const finalValue = this.formControl().value;
|
|
2252
2245
|
if (finalValue !== null && finalValue !== undefined && finalValue !== '') {
|
|
@@ -2298,6 +2291,12 @@ class SelectFieldComponent extends BaseFieldComponent {
|
|
|
2298
2291
|
finalValue !== '' &&
|
|
2299
2292
|
(!Array.isArray(finalValue) || finalValue.length > 0);
|
|
2300
2293
|
this.hasValue.set(hasValidValue);
|
|
2294
|
+
if (this.formControl().dirty && !this.userHasInteracted()) {
|
|
2295
|
+
this.userHasInteracted.set(true);
|
|
2296
|
+
}
|
|
2297
|
+
if (!this.areValuesEqual(finalValue, this.lastDynamicValue)) {
|
|
2298
|
+
this.lastDynamicValue = undefined;
|
|
2299
|
+
}
|
|
2301
2300
|
const fieldConfig = this.field();
|
|
2302
2301
|
if (fieldConfig.onSelectionChange && this.formValue()) {
|
|
2303
2302
|
try {
|
|
@@ -2344,6 +2343,72 @@ class SelectFieldComponent extends BaseFieldComponent {
|
|
|
2344
2343
|
onBlurInput() {
|
|
2345
2344
|
this.onBlur();
|
|
2346
2345
|
}
|
|
2346
|
+
scheduleDynamicValue(newValue, delay = 0) {
|
|
2347
|
+
const control = this.formControl();
|
|
2348
|
+
if (!control)
|
|
2349
|
+
return;
|
|
2350
|
+
const currentValue = control.value;
|
|
2351
|
+
if (!this.shouldApplyDynamicValue(newValue, currentValue)) {
|
|
2352
|
+
if (!this.userHasInteracted() && this.areValuesEqual(newValue, currentValue)) {
|
|
2353
|
+
this.lastDynamicValue = this.cloneValue(newValue);
|
|
2354
|
+
}
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
setTimeout(() => {
|
|
2358
|
+
const ctrl = this.formControl();
|
|
2359
|
+
if (!ctrl)
|
|
2360
|
+
return;
|
|
2361
|
+
const latestValue = ctrl.value;
|
|
2362
|
+
if (!this.shouldApplyDynamicValue(newValue, latestValue)) {
|
|
2363
|
+
if (!this.userHasInteracted() && this.areValuesEqual(newValue, latestValue)) {
|
|
2364
|
+
this.lastDynamicValue = this.cloneValue(newValue);
|
|
2365
|
+
}
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
ctrl.setValue(newValue, { emitEvent: true });
|
|
2369
|
+
ctrl.markAsPristine();
|
|
2370
|
+
this.lastDynamicValue = this.cloneValue(newValue);
|
|
2371
|
+
this.hasValue.set(this.hasMeaningfulValue(newValue));
|
|
2372
|
+
}, delay);
|
|
2373
|
+
}
|
|
2374
|
+
shouldApplyDynamicValue(newValue, currentValue) {
|
|
2375
|
+
if (newValue === undefined || newValue === null)
|
|
2376
|
+
return false;
|
|
2377
|
+
if (this.userHasInteracted())
|
|
2378
|
+
return false;
|
|
2379
|
+
const hasCurrentValue = this.hasMeaningfulValue(currentValue);
|
|
2380
|
+
const currentMatchesLastDynamic = this.areValuesEqual(currentValue, this.lastDynamicValue);
|
|
2381
|
+
if (hasCurrentValue && !currentMatchesLastDynamic) {
|
|
2382
|
+
return false;
|
|
2383
|
+
}
|
|
2384
|
+
return !this.areValuesEqual(newValue, currentValue);
|
|
2385
|
+
}
|
|
2386
|
+
hasMeaningfulValue(value) {
|
|
2387
|
+
if (value === null || value === undefined) {
|
|
2388
|
+
return false;
|
|
2389
|
+
}
|
|
2390
|
+
if (Array.isArray(value)) {
|
|
2391
|
+
return value.length > 0;
|
|
2392
|
+
}
|
|
2393
|
+
if (typeof value === 'string') {
|
|
2394
|
+
return value.trim() !== '';
|
|
2395
|
+
}
|
|
2396
|
+
return true;
|
|
2397
|
+
}
|
|
2398
|
+
areValuesEqual(a, b) {
|
|
2399
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2400
|
+
if (a.length !== b.length)
|
|
2401
|
+
return false;
|
|
2402
|
+
return a.every((item, index) => item === b[index]);
|
|
2403
|
+
}
|
|
2404
|
+
return a === b;
|
|
2405
|
+
}
|
|
2406
|
+
cloneValue(value) {
|
|
2407
|
+
if (Array.isArray(value)) {
|
|
2408
|
+
return [...value];
|
|
2409
|
+
}
|
|
2410
|
+
return value;
|
|
2411
|
+
}
|
|
2347
2412
|
onSelectChange(value) {
|
|
2348
2413
|
const hasValidValue = value !== null &&
|
|
2349
2414
|
value !== undefined &&
|
|
@@ -5502,8 +5567,10 @@ class GenericModalComponent {
|
|
|
5502
5567
|
this.allFields().forEach(field => {
|
|
5503
5568
|
const fieldKey = field.key;
|
|
5504
5569
|
const payloadKey = (field.keyToPayload ?? field.key);
|
|
5505
|
-
|
|
5506
|
-
|
|
5570
|
+
const modeConfig = field.modes?.[this.mode()];
|
|
5571
|
+
const dynamicValueFn = (modeConfig?.dynamicValue ?? field.dynamicValue);
|
|
5572
|
+
if (typeof dynamicValueFn === 'function') {
|
|
5573
|
+
const dynamicVal = dynamicValueFn(newInstance);
|
|
5507
5574
|
if (dynamicVal !== undefined && dynamicVal !== null) {
|
|
5508
5575
|
newInstance[payloadKey] = dynamicVal;
|
|
5509
5576
|
const control = this.form().get(fieldKey);
|
|
@@ -13290,11 +13357,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
|
|
|
13290
13357
|
// Este archivo es generado automáticamente por scripts/update-version.js
|
|
13291
13358
|
// No edites manualmente este archivo
|
|
13292
13359
|
const VERSION = {
|
|
13293
|
-
full: '2.12.
|
|
13360
|
+
full: '2.12.39',
|
|
13294
13361
|
major: 2,
|
|
13295
13362
|
minor: 12,
|
|
13296
|
-
patch:
|
|
13297
|
-
timestamp: '2025-09-
|
|
13363
|
+
patch: 39,
|
|
13364
|
+
timestamp: '2025-09-17T15:15:12.462Z',
|
|
13298
13365
|
buildDate: '17/9/2025'
|
|
13299
13366
|
};
|
|
13300
13367
|
|