How do I add conditional fields to a paragraph? I was able to add conditional fields in a paragraph, following Conditional Fields in Paragraphs Using the Javascript States API for Drupal 8, but it controls and hides only 1 field.
I need to control multiple fields from one select list. I added multiple fields to a variable and created a for loop. The select list has 3 options.

3row|3row
2row|2row
1row|1row

The following is the code for the custom module. When it runs, the last for loop is the only one that works. The first 2 select list options don't work. Do I need to add a field value check before each for loop? My module name is conditional_fields.
use Drupal\node\NodeInterface;
use Drupal\node\NodeForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\paragraphs\ParagraphInterface;
use Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget;
use Drupal\paragraphs\Entity\Paragraph;

/*
 * Implements hook_field_widget_form_alter().
 */
function conditional_fields_field_widget_paragraphs_form_alter(&amp;$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
  $field_definition = $context['items']-&gt;getFieldDefinition();
  $paragraph_entity_reference_field_name = $field_definition-&gt;getName();

  if ($paragraph_entity_reference_field_name == 'field_topic_paragraphs') {
    $widget_state = \Drupal\Core\Field\WidgetBase::getWidgetState($element['#field_parents'], $paragraph_entity_reference_field_name, $form_state);

    $paragraph_instance = $widget_state['paragraphs'][$element['#delta']]['entity'];
    $paragraph_type = $paragraph_instance-&gt;bundle();

    if ($paragraph_type == 'teaser_content') {
      $dependee_field_name = 'field_paragraph_number_of_rows';
      $selector = sprintf('select[name=&quot;%s[%d][subform][%s]&quot;]', $paragraph_entity_reference_field_name, $element['#delta'], $dependee_field_name);

      $fields_to_control1 = ['field_description_col_5','field_link_col_5','field_description_col_6','field_link_col_6','field_description_col_7','field_link_col_7','field_description_col_8','field_link_col_8','field_description_col_9','field_link_col_9','field_description_col_10','field_link_col_10','field_description_col_11','field_link_col_11','field_description_col_12','field_link_col_12','field_description_col_13','field_link_col_13','field_description_col_14','field_link_col_14','field_description_col_15','field_link_col_15','field_description_col_16','field_link_col_16'];

      $fields_to_control2 = ['field_description_col_9','field_link_col_9','field_description_col_10','field_link_col_10','field_description_col_11','field_link_col_11','field_description_col_12','field_link_col_12','field_description_col_13','field_link_col_13','field_description_col_14','field_link_col_14','field_description_col_15','field_link_col_15','field_description_col_16','field_link_col_16'];

      $fields_to_control3 = ['field_description_col_13','field_link_col_13','field_description_col_14','field_link_col_14','field_description_col_15','field_link_col_15','field_description_col_16','field_link_col_16'];

      foreach ($fields_to_control3 as $field) {
        $element['subform'][$field]['#states'] = [
          'invisible' =&gt; [
            $selector =&gt; ['value' =&gt; '3row'],
          ],
        ];
      }

      foreach ($fields_to_control2 as $field){
        $element['subform'][$field]['#states'] = [
          'invisible' =&gt; [
            $selector =&gt; ['value' =&gt; '2row'],
          ],
        ];
      }

      foreach ($fields_to_control1 as $field) {
        $element['subform'][$field]['#states'] = [
          'invisible' =&gt; [
            $selector =&gt; ['value' =&gt; '1row'],
          ],
        ];
      }

      unset($element['subform']['field_paragraph_number_of_rows']['widget']['#options']['_none']);
      $element['subform']['field_paragraph_number_of_rows']['widget']['#empty_option']  = t('- 4 Rows -');
    }
  }
}
I've used form states with these pre-requisites:

Form states with paragraphs
The content widget used is: Inline Entity Form - Complex
The widget should be changed, not the field

There is this content type with the paragraph reference with a two-fields paragraph: content reference and content number. The content reference field cardinality is 5, and the number of content is a select list (1, 2, 3, or 5). So, the logic is used to enable the content input according to the number of content selected.
This was the solution I've used, hopefully, it can help someone else:
/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function HOOK_inline_entity_form_entity_form_alter(&amp;$entity_form, &amp;$form_state) {
  if ($entity_form['#entity_type'] === 'paragraph' &amp;&amp; $entity_form['#bundle'] === 'PARAGRAPH_BUNDLE') {
    $parents = $entity_form['#parents'];
    // It needs to get the parent form (content type form field) in order to work fine.
    $identifier = $parents[0] . '[' . implode('][', array_slice($parents, 1)) . ']';
    // I need to use the target_id to aim the wdiget.
    // The first input should be shown if I select 1, 2, 3, or 5 content to be added.
    $entity_form[&quot;field_content_reference&quot;][&quot;widget&quot;][0][&quot;target_id&quot;]['#states'] = [
      'enabled' =&gt; [
        'select[name=&quot;' . $identifier . '[field_content_number]&quot;]' =&gt; [
          ['value' =&gt; 1],
          'or',
          ['value' =&gt; 2],
          'or',
          ['value' =&gt; 3],
          'or',
          ['value' =&gt; 5],
        ],
      ],
    ];
    // The second input should be shown if I select 2, 3, or 5 content to be added.
    $entity_form[&quot;field_content_reference&quot;][&quot;widget&quot;][1][&quot;target_id&quot;]['#states'] = [
      'enabled' =&gt; [
        'select[name=&quot;' . $identifier . '[field_content_number]&quot;]' =&gt; [
          ['value' =&gt; 2],
          'or',
          ['value' =&gt; 3],
          'or',
          ['value' =&gt; 5],
        ],
      ],
    ];
    // The third input should be shown if I select 3, or 5 content to be added.
    $entity_form[&quot;field_content_reference&quot;][&quot;widget&quot;][2][&quot;target_id&quot;]['#states'] = [
      'enabled' =&gt; [
        'select[name=&quot;' . $identifier . '[field_content_number]&quot;]' =&gt; [
          ['value' =&gt; 3],
          'or',
          ['value' =&gt; 5],
        ],
      ],
    ];
    // The rest of the input should be shown if I select 5 content to be added.
    $entity_form[&quot;field_content_reference&quot;][&quot;widget&quot;][3][&quot;target_id&quot;]['#states'] = [
      'enabled' =&gt; [
        'select[name=&quot;' . $identifier . '[field_content_number]&quot;]' =&gt; ['value' =&gt; 5],
      ],
    ];
    $entity_form[&quot;field_content_reference&quot;][&quot;widget&quot;][4][&quot;target_id&quot;]['#states'] = [
      'enabled' =&gt; [
        'select[name=&quot;' . $identifier . '[field_content_number]&quot;]' =&gt; ['value' =&gt; 5],
      ],
    ];
  }
}