react-magma-dom 4.14.0 → 4.14.1-next.0

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.
package/dist/esm/index.js CHANGED
@@ -18738,16 +18738,20 @@ var PasswordInput = /*#__PURE__*/forwardRef(function (props, ref) {
18738
18738
  var theme = useContext(ThemeContext);
18739
18739
  var isInverse = useIsInverse(props.isInverse);
18740
18740
  var usesDefaultText = SHOW_PASSWORD_BUTTON_TEXT === i18n.password.shown.buttonText && HIDE_PASSWORD_BUTTON_TEXT === i18n.password.hidden.buttonText;
18741
- var buttonRef = useRef();
18741
+ var buttonRef = useRef(null);
18742
+ var _React$useState2 = useState(0),
18743
+ buttonWidth = _React$useState2[0],
18744
+ setButtonWidth = _React$useState2[1];
18745
+ useLayoutEffect(function () {
18746
+ if (buttonRef.current && !usesDefaultText) {
18747
+ setButtonWidth(buttonRef.current.offsetWidth);
18748
+ }
18749
+ }, [usesDefaultText, passwordShown, SHOW_PASSWORD_BUTTON_TEXT, HIDE_PASSWORD_BUTTON_TEXT]);
18742
18750
  var getButtonWidth = function getButtonWidth() {
18743
18751
  if (usesDefaultText) {
18744
- if (inputSize === InputSize.large) {
18745
- return '64px';
18746
- }
18747
- return '54px';
18748
- } else {
18749
- var _buttonRef$current;
18750
- return (buttonRef == null || (_buttonRef$current = buttonRef.current) == null ? void 0 : _buttonRef$current.offsetWidth) + "px";
18752
+ return inputSize === InputSize.large ? '64px' : '54px';
18753
+ } else if (buttonWidth !== 0) {
18754
+ return buttonWidth + "px";
18751
18755
  }
18752
18756
  };
18753
18757
  var getInputStyle = function getInputStyle() {
@@ -18762,9 +18766,9 @@ var PasswordInput = /*#__PURE__*/forwardRef(function (props, ref) {
18762
18766
  width: 'calc(100% - 64px)'
18763
18767
  };
18764
18768
  } else {
18765
- var _buttonRef$current2;
18769
+ // right margin (3px) so input doesn't overflow
18766
18770
  return {
18767
- width: "calc(100% - " + (buttonRef == null || (_buttonRef$current2 = buttonRef.current) == null ? void 0 : _buttonRef$current2.offsetWidth) + "px)"
18771
+ width: "calc(100% - " + (buttonWidth + 3) + "px)"
18768
18772
  };
18769
18773
  }
18770
18774
  };