@razorpay/blade 6.0.4 → 6.0.5

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.
@@ -17217,7 +17217,9 @@ var OTPInput = function OTPInput(_ref) {
17217
17217
  successText = _ref.successText,
17218
17218
  validationState = _ref.validationState,
17219
17219
  inputValue = _ref.value,
17220
- isMasked = _ref.isMasked;
17220
+ isMasked = _ref.isMasked,
17221
+ _ref$autoCompleteSugg = _ref.autoCompleteSuggestionType,
17222
+ autoCompleteSuggestionType = _ref$autoCompleteSugg === void 0 ? 'oneTimeCode' : _ref$autoCompleteSugg;
17221
17223
  var inputRefs = [];
17222
17224
 
17223
17225
  var _useState = useState(otpToArray(inputValue)),
@@ -17225,6 +17227,11 @@ var OTPInput = function OTPInput(_ref) {
17225
17227
  otpValue = _useState2[0],
17226
17228
  setOtpValue = _useState2[1];
17227
17229
 
17230
+ var _useState3 = useState([]),
17231
+ _useState4 = _slicedToArray(_useState3, 2),
17232
+ inputType = _useState4[0],
17233
+ setInputType = _useState4[1];
17234
+
17228
17235
  var isLabelLeftPositioned = labelPosition === 'left';
17229
17236
 
17230
17237
  var _useFormId = useFormId('otp'),
@@ -17252,6 +17259,28 @@ var OTPInput = function OTPInput(_ref) {
17252
17259
  });
17253
17260
  }
17254
17261
  }, [otpValue, otpLength, name, inputValue, onOTPFilled]);
17262
+ useEffect(function () {
17263
+ /* We want to disable the password managers for OTPInput when isMasked is set.
17264
+ The issue with only setting autocomplete='off' is that its not an enforcement but a suggestion to the browser to follow.
17265
+ This workaround unsets type on first render and sets it to `password` only once a value is entered by the user.
17266
+ */
17267
+ otpValue.forEach(function (otp, index) {
17268
+ // Set inputType as 'password' only when a value is entered when isMasked is set
17269
+ if (!isEmpty_1(otp) && !inputType[index] && isMasked) {
17270
+ var newInputType = Array.from(inputType);
17271
+ newInputType[index] = 'password';
17272
+ setInputType(newInputType);
17273
+ } // Cleanup the inputType array whenever the value is empty but inputType[index] is set
17274
+
17275
+
17276
+ if (isEmpty_1(otp) && inputType[index]) {
17277
+ var _newInputType = Array.from(inputType);
17278
+
17279
+ _newInputType[index] = undefined;
17280
+ setInputType(_newInputType);
17281
+ }
17282
+ });
17283
+ }, [otpValue, inputType, isMasked]);
17255
17284
  /**
17256
17285
  * Changes the value of the otp at a given index and updates the otpValue stored in state
17257
17286
  *
@@ -17395,7 +17424,15 @@ var OTPInput = function OTPInput(_ref) {
17395
17424
  var _otpValue$index, _Array$from$index;
17396
17425
 
17397
17426
  var currentValue = inputValue ? otpToArray(inputValue)[index] || '' : otpValue[index] || '';
17398
- var ref = /*#__PURE__*/React__default.createRef();
17427
+ var ref = /*#__PURE__*/React__default.createRef(); // if an inputValue is passed (controlled) and isMasked is set, inputType will always be password
17428
+
17429
+ var currentInputType = void 0;
17430
+
17431
+ if (isMasked) {
17432
+ // if inputValue is passed (controlled component) then the inputType will always be password
17433
+ currentInputType = inputValue ? 'password' : inputType[index];
17434
+ }
17435
+
17399
17436
  inputRefs.push(ref);
17400
17437
  inputs.push( /*#__PURE__*/jsx(Box, {
17401
17438
  flex: 1,
@@ -17431,7 +17468,7 @@ var OTPInput = function OTPInput(_ref) {
17431
17468
  isDisabled: isDisabled,
17432
17469
  placeholder: (_Array$from$index = Array.from(placeholder !== null && placeholder !== void 0 ? placeholder : '')[index]) !== null && _Array$from$index !== void 0 ? _Array$from$index : '',
17433
17470
  isRequired: true,
17434
- autoCompleteSuggestionType: "oneTimeCode",
17471
+ autoCompleteSuggestionType: autoCompleteSuggestionType,
17435
17472
  keyboardType: keyboardType,
17436
17473
  keyboardReturnKeyType: keyboardReturnKeyType,
17437
17474
  validationState: validationState,
@@ -17439,7 +17476,7 @@ var OTPInput = function OTPInput(_ref) {
17439
17476
  errorText: errorText,
17440
17477
  helpText: helpText,
17441
17478
  hideFormHint: true,
17442
- type: isMasked ? 'password' : undefined
17479
+ type: currentInputType
17443
17480
  })
17444
17481
  }, "".concat(inputId, "-").concat(index)));
17445
17482
  };