@verma-consulting/design-library 0.1.63 → 0.1.64

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.mjs CHANGED
@@ -2453,9 +2453,12 @@ var OTPField = ({
2453
2453
  inputFocusStyle,
2454
2454
  sx,
2455
2455
  type = "text",
2456
- inputMode = "text",
2456
+ inputMode,
2457
2457
  regexCriteria
2458
2458
  }) => {
2459
+ const isNumeric = type === "numeric";
2460
+ const resolvedInputMode = inputMode != null ? inputMode : isNumeric ? "numeric" : "text";
2461
+ const resolvedRegexCriteria = regexCriteria != null ? regexCriteria : isNumeric ? /^[0-9]$/ : void 0;
2459
2462
  const [cells, setCells] = useState7(() => toCells(initialValue, length));
2460
2463
  const cellsRef = useRef5(cells);
2461
2464
  cellsRef.current = cells;
@@ -2485,16 +2488,17 @@ var OTPField = ({
2485
2488
  const charAllowed = useCallback2(
2486
2489
  (ch) => {
2487
2490
  if (!ch) return true;
2488
- if (type === "numeric" && /\D/.test(ch)) return false;
2489
- if (regexCriteria && !regexCriteria.test(ch)) return false;
2491
+ if (isNumeric && /\D/.test(ch)) return false;
2492
+ if (resolvedRegexCriteria && !resolvedRegexCriteria.test(ch))
2493
+ return false;
2490
2494
  return true;
2491
2495
  },
2492
- [regexCriteria, type]
2496
+ [isNumeric, resolvedRegexCriteria]
2493
2497
  );
2494
2498
  const applyMany = useCallback2(
2495
2499
  (startIdx, raw) => {
2496
2500
  var _a2;
2497
- const incoming = (type === "numeric" ? raw.replace(/\D/g, "") : raw).split("");
2501
+ const incoming = (isNumeric ? raw.replace(/\D/g, "") : raw).split("");
2498
2502
  const next = [...cellsRef.current];
2499
2503
  let i = startIdx;
2500
2504
  for (const ch of incoming) {
@@ -2507,7 +2511,7 @@ var OTPField = ({
2507
2511
  emit(next, focusAt);
2508
2512
  (_a2 = refs.current[focusAt]) == null ? void 0 : _a2.focus();
2509
2513
  },
2510
- [charAllowed, emit, length, type]
2514
+ [charAllowed, emit, isNumeric, length]
2511
2515
  );
2512
2516
  const onFieldChange = (idx, e) => {
2513
2517
  var _a2;
@@ -2551,7 +2555,7 @@ var OTPField = ({
2551
2555
  if (!text) return;
2552
2556
  applyMany(0, text);
2553
2557
  };
2554
- const inputType = secret ? "password" : type === "numeric" ? "tel" : "text";
2558
+ const inputType = secret && !isNumeric ? "password" : isNumeric ? "tel" : "text";
2555
2559
  return /* @__PURE__ */ jsx19(
2556
2560
  Box11,
2557
2561
  {
@@ -2591,7 +2595,7 @@ var OTPField = ({
2591
2595
  },
2592
2596
  inputProps: {
2593
2597
  maxLength: 1,
2594
- inputMode: inputMode != null ? inputMode : void 0,
2598
+ inputMode: resolvedInputMode,
2595
2599
  "aria-label": `Code character ${idx + 1} of ${length}`,
2596
2600
  autoComplete: "one-time-code"
2597
2601
  }