@swype-org/react-sdk 0.1.164 → 0.1.165

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/index.cjs CHANGED
@@ -2429,7 +2429,14 @@ function OtpInput({ value, onChange, length = 6, disabled }) {
2429
2429
  inputsRef.current[clamped]?.focus();
2430
2430
  }, [length]);
2431
2431
  const handleChange = react.useCallback((index, char) => {
2432
- const digit = char.replace(/\D/g, "").slice(0, 1);
2432
+ const cleaned = char.replace(/\D/g, "");
2433
+ if (cleaned.length > 1) {
2434
+ const filled = cleaned.slice(0, length);
2435
+ onChange(filled);
2436
+ focusInput(Math.min(filled.length, length - 1));
2437
+ return;
2438
+ }
2439
+ const digit = cleaned.slice(0, 1);
2433
2440
  const next = digits.slice();
2434
2441
  next[index] = digit;
2435
2442
  const joined = next.join("").replace(/\s/g, "");
@@ -2467,7 +2474,7 @@ function OtpInput({ value, onChange, length = 6, disabled }) {
2467
2474
  disabled,
2468
2475
  onChange: (e) => handleChange(i, e.target.value),
2469
2476
  onKeyDown: (e) => handleKeyDown(i, e),
2470
- onPaste: i === 0 ? handlePaste : void 0,
2477
+ onPaste: handlePaste,
2471
2478
  onFocus: (e) => e.target.select(),
2472
2479
  style: inputStyle(tokens, !!digit.trim())
2473
2480
  },