sapenlinea-components 0.11.90 → 0.11.92
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.
|
@@ -3632,28 +3632,27 @@ class FeatureCard {
|
|
|
3632
3632
|
const yyyy = d.getFullYear();
|
|
3633
3633
|
return `${dd}/${mm}/${yyyy}`;
|
|
3634
3634
|
}
|
|
3635
|
+
case 'number':
|
|
3636
|
+
return isNaN(numValue) ? raw : `${Math.trunc(numValue)}`;
|
|
3635
3637
|
default:
|
|
3636
3638
|
return raw;
|
|
3637
3639
|
}
|
|
3638
3640
|
}, ...(ngDevMode ? [{ debugName: "formattedDescription" }] : []));
|
|
3639
3641
|
constructor() {
|
|
3640
|
-
// Sincroniza
|
|
3642
|
+
// Sincroniza description solo cuando el feature cambia desde el padre,
|
|
3643
|
+
// pero nunca pisa un valor que el formulario (writeValue) ya haya establecido.
|
|
3641
3644
|
effect(() => {
|
|
3642
3645
|
const feat = this.feature();
|
|
3643
|
-
|
|
3646
|
+
const incoming = feat?.description ?? '';
|
|
3647
|
+
if (incoming !== this.descriptionValue()) {
|
|
3648
|
+
this.descriptionValue.set(incoming);
|
|
3649
|
+
}
|
|
3644
3650
|
});
|
|
3645
3651
|
}
|
|
3646
3652
|
// --- ControlValueAccessor Implementation ---
|
|
3647
3653
|
writeValue(value) {
|
|
3648
3654
|
const nextDescription = value == null ? '' : String(value);
|
|
3649
|
-
// Solo actualizamos el valor visual (descriptionValue)
|
|
3650
3655
|
this.descriptionValue.set(nextDescription);
|
|
3651
|
-
// Mantenemos sincronizado el objeto base
|
|
3652
|
-
const current = this.feature();
|
|
3653
|
-
if (current) {
|
|
3654
|
-
// Modificamos el objeto feature subyacente para no perder la configuración
|
|
3655
|
-
this.feature.set({ ...current, description: nextDescription });
|
|
3656
|
-
}
|
|
3657
3656
|
}
|
|
3658
3657
|
registerOnChange(fn) {
|
|
3659
3658
|
this.onChange = fn;
|
|
@@ -3672,7 +3671,21 @@ class FeatureCard {
|
|
|
3672
3671
|
let nextDescription = target.value;
|
|
3673
3672
|
const currentFeature = this.feature();
|
|
3674
3673
|
// Validar y filtrar entrada para tipos numéricos
|
|
3675
|
-
if (currentFeature?.type
|
|
3674
|
+
if (currentFeature?.type === 'number') {
|
|
3675
|
+
// Solo dígitos enteros
|
|
3676
|
+
nextDescription = nextDescription.replace(/[^0-9]/g, '');
|
|
3677
|
+
// Aplicar límite máximo en tiempo real
|
|
3678
|
+
if (currentFeature.max !== undefined && nextDescription !== '') {
|
|
3679
|
+
const numericValue = parseInt(nextDescription, 10);
|
|
3680
|
+
if (!isNaN(numericValue) && numericValue > currentFeature.max) {
|
|
3681
|
+
nextDescription = currentFeature.max.toString();
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
if (target.value !== nextDescription) {
|
|
3685
|
+
target.value = nextDescription;
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
else if (currentFeature?.type && ['money', 'percentage', 'measurement'].includes(currentFeature.type)) {
|
|
3676
3689
|
// Permitir solo números y punto decimal
|
|
3677
3690
|
nextDescription = nextDescription.replace(/[^0-9.]/g, '');
|
|
3678
3691
|
// Evitar múltiples puntos decimales
|
|
@@ -3687,7 +3700,6 @@ class FeatureCard {
|
|
|
3687
3700
|
nextDescription = currentFeature.max.toString();
|
|
3688
3701
|
}
|
|
3689
3702
|
}
|
|
3690
|
-
// Sincronizar el valor visual del input si cambió por el filtrado o límite
|
|
3691
3703
|
if (target.value !== nextDescription) {
|
|
3692
3704
|
target.value = nextDescription;
|
|
3693
3705
|
}
|
|
@@ -3716,7 +3728,7 @@ class FeatureCard {
|
|
|
3716
3728
|
this.isEditingDescription.set(false);
|
|
3717
3729
|
// Aplicar límite mínimo al perder el foco (para evitar interrumpir mientras se escribe)
|
|
3718
3730
|
const currentFeature = this.feature();
|
|
3719
|
-
if (currentFeature?.type && ['money', 'percentage', 'measurement'].includes(currentFeature.type) && currentFeature.min !== undefined) {
|
|
3731
|
+
if (currentFeature?.type && ['money', 'percentage', 'measurement', 'number'].includes(currentFeature.type) && currentFeature.min !== undefined) {
|
|
3720
3732
|
const currentRaw = this.descriptionValue();
|
|
3721
3733
|
const numericValue = parseFloat(currentRaw);
|
|
3722
3734
|
if (!isNaN(numericValue) && numericValue < currentFeature.min) {
|