useRemovePasswordTimeout.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = useRemovePasswordTimeout;
  6. var _react = require("react");
  7. function useRemovePasswordTimeout(inputRef, triggerOnMount) {
  8. const removePasswordTimeoutRef = (0, _react.useRef)([]);
  9. const removePasswordTimeout = () => {
  10. removePasswordTimeoutRef.current.push(setTimeout(() => {
  11. var _a, _b, _c, _d;
  12. if (((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.input.getAttribute('type')) === 'password' && ((_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.input.hasAttribute('value'))) {
  13. (_d = inputRef.current) === null || _d === void 0 ? void 0 : _d.input.removeAttribute('value');
  14. }
  15. }));
  16. };
  17. (0, _react.useEffect)(() => {
  18. if (triggerOnMount) {
  19. removePasswordTimeout();
  20. }
  21. return () => removePasswordTimeoutRef.current.forEach(timer => {
  22. if (timer) {
  23. clearTimeout(timer);
  24. }
  25. });
  26. }, []);
  27. return removePasswordTimeout;
  28. }