const textInput = () => {
  function passwordToggle(id) {
    var x = document.getElementById(id);
    if (x.type === 'password') {
      x.type = 'text';
    } else {
      x.type = 'password';
    }
  }

  const passwordInputs = document.querySelectorAll('.ds-text-input [type=password]');
  passwordInputs.forEach((input) => {
    const toggle = document.getElementById(`${input.id}-password-toggle`);
    if (toggle) {
      toggle.addEventListener('click', () => {
        passwordToggle(input.id);
      });
    }
  });
};

export default textInput;
