@dsivd/prestations-ng 19.0.2-beta.1 → 19.0.2-beta.2

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.
@@ -5840,6 +5840,7 @@ class FoehnCheckableGroupComponent extends FoehnInputComponent {
5840
5840
  this.multiple = signal(false, ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
5841
5841
  this.ngZone = inject(NgZone);
5842
5842
  this._onInitSubject = new Subject();
5843
+ this.disabledByElements = false;
5843
5844
  effect(() => {
5844
5845
  if (!this.elementsUrl()?.length) {
5845
5846
  this.onElementsRetrieved();
@@ -5914,13 +5915,16 @@ class FoehnCheckableGroupComponent extends FoehnInputComponent {
5914
5915
  if (this.disabled()) {
5915
5916
  return true;
5916
5917
  }
5918
+ return this.getElementDisabled(element);
5919
+ }
5920
+ getElementDisabled(element) {
5917
5921
  const elementDisabled = this.elementDisabled();
5918
5922
  const disabledValue = typeof elementDisabled === 'string'
5919
5923
  ? ObjectHelper.getNestedProperty(element, elementDisabled)
5920
5924
  : elementDisabled(element);
5921
5925
  if (typeof disabledValue === 'string') {
5922
5926
  const normalizedValue = disabledValue.trim().toLowerCase();
5923
- return normalizedValue.length > 0 && normalizedValue === 'true';
5927
+ return !!normalizedValue.length && normalizedValue === 'true';
5924
5928
  }
5925
5929
  return !!disabledValue;
5926
5930
  }
@@ -5993,10 +5997,22 @@ class FoehnCheckableGroupComponent extends FoehnInputComponent {
5993
5997
  this.updateNgModel(this.model_);
5994
5998
  });
5995
5999
  }
5996
- // Check if we need to disable component because all it's elements are disabled
6000
+ // Sync component disabled state only when it was auto-derived from elements.
5997
6001
  const elements = this.elements();
5998
- if (elements?.length && !this.disabled()) {
5999
- this.disabled.set(elements.every((elem) => !!this.getDisabled(elem)));
6002
+ if (elements?.length) {
6003
+ const allElementsDisabled = elements.every((elem) => this.getElementDisabled(elem));
6004
+ if (allElementsDisabled && !this.disabled()) {
6005
+ this.disabledByElements = true;
6006
+ this.disabled.set(true);
6007
+ }
6008
+ else if (!allElementsDisabled && this.disabledByElements) {
6009
+ this.disabledByElements = false;
6010
+ this.disabled.set(false);
6011
+ }
6012
+ }
6013
+ else if (this.disabledByElements) {
6014
+ this.disabledByElements = false;
6015
+ this.disabled.set(false);
6000
6016
  }
6001
6017
  this.groupedElements = this.getGroupedElements();
6002
6018
  this.onInitSubject.next();
@@ -9009,6 +9025,9 @@ class FoehnRadioComponent extends FoehnCheckableGroupComponent {
9009
9025
  this.inputValue = this.getValueOrObject(value);
9010
9026
  super.onModelChange(value);
9011
9027
  }
9028
+ ngAfterViewChecked() {
9029
+ this.syncDisabledState();
9030
+ }
9012
9031
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9013
9032
  getValueOrObject(element) {
9014
9033
  if (typeof element === 'undefined') {
@@ -9030,6 +9049,30 @@ class FoehnRadioComponent extends FoehnCheckableGroupComponent {
9030
9049
  }
9031
9050
  return this.getValue(element);
9032
9051
  }
9052
+ syncDisabledState() {
9053
+ if (!this.groupedElements?.length) {
9054
+ return;
9055
+ }
9056
+ for (const [groupIndex, elementsGroup,] of this.groupedElements.entries()) {
9057
+ for (const [elementIndex, element,] of elementsGroup.elements.entries()) {
9058
+ const inputId = `${this.buildChildId()}${groupIndex}_${elementIndex}`;
9059
+ const input = document.getElementById(inputId);
9060
+ if (!input) {
9061
+ continue;
9062
+ }
9063
+ const shouldBeDisabled = this.getDisabled(element);
9064
+ if (input.disabled !== shouldBeDisabled) {
9065
+ input.disabled = shouldBeDisabled;
9066
+ }
9067
+ if (shouldBeDisabled) {
9068
+ input.setAttribute('disabled', 'disabled');
9069
+ }
9070
+ else {
9071
+ input.removeAttribute('disabled');
9072
+ }
9073
+ }
9074
+ }
9075
+ }
9033
9076
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FoehnRadioComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
9034
9077
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: FoehnRadioComponent, isStandalone: true, selector: "foehn-radio", providers: [
9035
9078
  {