@verma-consulting/design-library 0.1.62 → 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.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -12
package/dist/index.d.mts
CHANGED
|
@@ -231,7 +231,11 @@ type OTPFieldProps = {
|
|
|
231
231
|
initialValue?: string;
|
|
232
232
|
onChange: (value: string, index?: number) => void;
|
|
233
233
|
onComplete?: (value: string, index?: number) => void;
|
|
234
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Use `type="password"` on each cell when `type` is not `"numeric"`.
|
|
236
|
+
* Ignored when `type="numeric"`: masking forces a full keyboard on mobile and
|
|
237
|
+
* breaks OTP / confirmation-code entry; prefer `type="numeric"` without `secret`.
|
|
238
|
+
*/
|
|
235
239
|
secret?: boolean;
|
|
236
240
|
autoSelect?: boolean;
|
|
237
241
|
disabled?: boolean;
|
|
@@ -239,9 +243,18 @@ type OTPFieldProps = {
|
|
|
239
243
|
inputFocusStyle?: CSSProperties;
|
|
240
244
|
/** Applied to the outer `Box` (MUI `sx`). */
|
|
241
245
|
sx?: SxProps<Theme>;
|
|
246
|
+
/**
|
|
247
|
+
* `"numeric"` — OTP / PIN mode: `type="tel"`, default `inputMode="numeric"`,
|
|
248
|
+
* digits-only when `regexCriteria` is omitted. `secret` is not applied.
|
|
249
|
+
* Other values — plain text cells; `secret` uses `type="password"`.
|
|
250
|
+
*/
|
|
242
251
|
type?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Hint for the on-screen keyboard. Defaults to `"numeric"` when `type="numeric"`,
|
|
254
|
+
* otherwise `"text"`. Avoid `"number"` for OTP (decimal pad on some devices).
|
|
255
|
+
*/
|
|
243
256
|
inputMode?: React__default.HTMLAttributes<HTMLInputElement>["inputMode"];
|
|
244
|
-
/**
|
|
257
|
+
/** Per-character filter; defaults to `/^[0-9]$/` when `type="numeric"` and omitted. */
|
|
245
258
|
regexCriteria?: RegExp;
|
|
246
259
|
};
|
|
247
260
|
declare const OTPField: React__default.FC<OTPFieldProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -231,7 +231,11 @@ type OTPFieldProps = {
|
|
|
231
231
|
initialValue?: string;
|
|
232
232
|
onChange: (value: string, index?: number) => void;
|
|
233
233
|
onComplete?: (value: string, index?: number) => void;
|
|
234
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Use `type="password"` on each cell when `type` is not `"numeric"`.
|
|
236
|
+
* Ignored when `type="numeric"`: masking forces a full keyboard on mobile and
|
|
237
|
+
* breaks OTP / confirmation-code entry; prefer `type="numeric"` without `secret`.
|
|
238
|
+
*/
|
|
235
239
|
secret?: boolean;
|
|
236
240
|
autoSelect?: boolean;
|
|
237
241
|
disabled?: boolean;
|
|
@@ -239,9 +243,18 @@ type OTPFieldProps = {
|
|
|
239
243
|
inputFocusStyle?: CSSProperties;
|
|
240
244
|
/** Applied to the outer `Box` (MUI `sx`). */
|
|
241
245
|
sx?: SxProps<Theme>;
|
|
246
|
+
/**
|
|
247
|
+
* `"numeric"` — OTP / PIN mode: `type="tel"`, default `inputMode="numeric"`,
|
|
248
|
+
* digits-only when `regexCriteria` is omitted. `secret` is not applied.
|
|
249
|
+
* Other values — plain text cells; `secret` uses `type="password"`.
|
|
250
|
+
*/
|
|
242
251
|
type?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Hint for the on-screen keyboard. Defaults to `"numeric"` when `type="numeric"`,
|
|
254
|
+
* otherwise `"text"`. Avoid `"number"` for OTP (decimal pad on some devices).
|
|
255
|
+
*/
|
|
243
256
|
inputMode?: React__default.HTMLAttributes<HTMLInputElement>["inputMode"];
|
|
244
|
-
/**
|
|
257
|
+
/** Per-character filter; defaults to `/^[0-9]$/` when `type="numeric"` and omitted. */
|
|
245
258
|
regexCriteria?: RegExp;
|
|
246
259
|
};
|
|
247
260
|
declare const OTPField: React__default.FC<OTPFieldProps>;
|
package/dist/index.js
CHANGED
|
@@ -2452,9 +2452,12 @@ var OTPField = ({
|
|
|
2452
2452
|
inputFocusStyle,
|
|
2453
2453
|
sx,
|
|
2454
2454
|
type = "text",
|
|
2455
|
-
inputMode
|
|
2455
|
+
inputMode,
|
|
2456
2456
|
regexCriteria
|
|
2457
2457
|
}) => {
|
|
2458
|
+
const isNumeric = type === "numeric";
|
|
2459
|
+
const resolvedInputMode = inputMode != null ? inputMode : isNumeric ? "numeric" : "text";
|
|
2460
|
+
const resolvedRegexCriteria = regexCriteria != null ? regexCriteria : isNumeric ? /^[0-9]$/ : void 0;
|
|
2458
2461
|
const [cells, setCells] = (0, import_react11.useState)(() => toCells(initialValue, length));
|
|
2459
2462
|
const cellsRef = (0, import_react11.useRef)(cells);
|
|
2460
2463
|
cellsRef.current = cells;
|
|
@@ -2484,16 +2487,17 @@ var OTPField = ({
|
|
|
2484
2487
|
const charAllowed = (0, import_react11.useCallback)(
|
|
2485
2488
|
(ch) => {
|
|
2486
2489
|
if (!ch) return true;
|
|
2487
|
-
if (
|
|
2488
|
-
if (
|
|
2490
|
+
if (isNumeric && /\D/.test(ch)) return false;
|
|
2491
|
+
if (resolvedRegexCriteria && !resolvedRegexCriteria.test(ch))
|
|
2492
|
+
return false;
|
|
2489
2493
|
return true;
|
|
2490
2494
|
},
|
|
2491
|
-
[
|
|
2495
|
+
[isNumeric, resolvedRegexCriteria]
|
|
2492
2496
|
);
|
|
2493
2497
|
const applyMany = (0, import_react11.useCallback)(
|
|
2494
2498
|
(startIdx, raw) => {
|
|
2495
2499
|
var _a2;
|
|
2496
|
-
const incoming = (
|
|
2500
|
+
const incoming = (isNumeric ? raw.replace(/\D/g, "") : raw).split("");
|
|
2497
2501
|
const next = [...cellsRef.current];
|
|
2498
2502
|
let i = startIdx;
|
|
2499
2503
|
for (const ch of incoming) {
|
|
@@ -2506,7 +2510,7 @@ var OTPField = ({
|
|
|
2506
2510
|
emit(next, focusAt);
|
|
2507
2511
|
(_a2 = refs.current[focusAt]) == null ? void 0 : _a2.focus();
|
|
2508
2512
|
},
|
|
2509
|
-
[charAllowed, emit,
|
|
2513
|
+
[charAllowed, emit, isNumeric, length]
|
|
2510
2514
|
);
|
|
2511
2515
|
const onFieldChange = (idx, e) => {
|
|
2512
2516
|
var _a2;
|
|
@@ -2550,7 +2554,7 @@ var OTPField = ({
|
|
|
2550
2554
|
if (!text) return;
|
|
2551
2555
|
applyMany(0, text);
|
|
2552
2556
|
};
|
|
2553
|
-
const inputType = secret ? "password" :
|
|
2557
|
+
const inputType = secret && !isNumeric ? "password" : isNumeric ? "tel" : "text";
|
|
2554
2558
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2555
2559
|
import_material17.Box,
|
|
2556
2560
|
{
|
|
@@ -2590,7 +2594,7 @@ var OTPField = ({
|
|
|
2590
2594
|
},
|
|
2591
2595
|
inputProps: {
|
|
2592
2596
|
maxLength: 1,
|
|
2593
|
-
inputMode:
|
|
2597
|
+
inputMode: resolvedInputMode,
|
|
2594
2598
|
"aria-label": `Code character ${idx + 1} of ${length}`,
|
|
2595
2599
|
autoComplete: "one-time-code"
|
|
2596
2600
|
}
|