@fluxhub/fluxhub-lib 19.0.88 → 19.0.89

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.
@@ -14899,6 +14899,11 @@ class FHColorPickerComponent {
14899
14899
  return this._color ? this._color.toHexString() : null;
14900
14900
  }
14901
14901
  ngOnInit() {
14902
+ // Inizializza con un colore di default se _color è null
14903
+ if (!this._color) {
14904
+ this.colorControl.setValueFrom('#2196F3');
14905
+ this._color = this.colorControl.value;
14906
+ }
14902
14907
  }
14903
14908
  showColorPicker(event) {
14904
14909
  if (this.isVisible === true) {
@@ -14910,14 +14915,38 @@ class FHColorPickerComponent {
14910
14915
  event.preventDefault();
14911
14916
  event.stopPropagation();
14912
14917
  this.isVisible = false;
14913
- this.onChange(this.colorControl.value);
14914
14918
  this._color = this.colorControl.value;
14915
- this.change.emit(this.colorControl.value.toHexString());
14919
+ const hexValue = this._color ? this._color.toHexString() : '#2196F3';
14920
+ this.onChange(hexValue);
14921
+ this.change.emit(hexValue);
14916
14922
  }
14917
14923
  constructor() { }
14918
14924
  ngAfterViewInit() { }
14919
14925
  writeValue(value) {
14920
- this._color = value;
14926
+ // Gestisce sia stringhe hex che oggetti Color
14927
+ if (value) {
14928
+ if (typeof value === 'string') {
14929
+ // Se è una stringa, convertila in un oggetto Color
14930
+ try {
14931
+ this.colorControl.setValueFrom(value);
14932
+ this._color = this.colorControl.value;
14933
+ }
14934
+ catch (e) {
14935
+ // Se la conversione fallisce, usa un colore di default
14936
+ this.colorControl.setValueFrom('#2196F3');
14937
+ this._color = this.colorControl.value;
14938
+ }
14939
+ }
14940
+ else {
14941
+ // Se è già un oggetto Color
14942
+ this._color = value;
14943
+ }
14944
+ }
14945
+ else {
14946
+ // Se il valore è null/undefined, usa un colore di default
14947
+ this.colorControl.setValueFrom('#2196F3');
14948
+ this._color = this.colorControl.value;
14949
+ }
14921
14950
  }
14922
14951
  onChange = (_) => { };
14923
14952
  onTouched = () => { };