@r5n/otp-react-native 0.0.0-stage → 8.0.1
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/CHANGELOG.md +139 -0
- package/LICENSE +21 -0
- package/README.md +227 -2
- package/lib/commonjs/Cell.js +140 -0
- package/lib/commonjs/Cell.js.map +1 -0
- package/lib/commonjs/OtpInput.js +129 -0
- package/lib/commonjs/OtpInput.js.map +1 -0
- package/lib/commonjs/accessibility.js +90 -0
- package/lib/commonjs/accessibility.js.map +1 -0
- package/lib/commonjs/clipboard.js +197 -0
- package/lib/commonjs/clipboard.js.map +1 -0
- package/lib/commonjs/dev.js +63 -0
- package/lib/commonjs/dev.js.map +1 -0
- package/lib/commonjs/hiddenInput.js +95 -0
- package/lib/commonjs/hiddenInput.js.map +1 -0
- package/lib/commonjs/index.js +53 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/legacy.js +218 -0
- package/lib/commonjs/legacy.js.map +1 -0
- package/lib/commonjs/managedProps.js +73 -0
- package/lib/commonjs/managedProps.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +45 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useOtpController.js +70 -0
- package/lib/commonjs/useOtpController.js.map +1 -0
- package/lib/commonjs/useOtpInput.js +251 -0
- package/lib/commonjs/useOtpInput.js.map +1 -0
- package/lib/module/Cell.js +103 -0
- package/lib/module/Cell.js.map +1 -0
- package/lib/module/OtpInput.js +94 -0
- package/lib/module/OtpInput.js.map +1 -0
- package/lib/module/accessibility.js +49 -0
- package/lib/module/accessibility.js.map +1 -0
- package/lib/module/clipboard.js +156 -0
- package/lib/module/clipboard.js.map +1 -0
- package/lib/module/dev.js +22 -0
- package/lib/module/dev.js.map +1 -0
- package/lib/module/hiddenInput.js +54 -0
- package/lib/module/hiddenInput.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/legacy.js +188 -0
- package/lib/module/legacy.js.map +1 -0
- package/lib/module/managedProps.js +32 -0
- package/lib/module/managedProps.js.map +1 -0
- package/lib/module/types.js +3 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useOtpController.js +29 -0
- package/lib/module/useOtpController.js.map +1 -0
- package/lib/module/useOtpInput.js +216 -0
- package/lib/module/useOtpInput.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/Cell.d.ts +39 -0
- package/lib/typescript/commonjs/src/Cell.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/OtpInput.d.ts +12 -0
- package/lib/typescript/commonjs/src/OtpInput.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/accessibility.d.ts +39 -0
- package/lib/typescript/commonjs/src/accessibility.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/clipboard.d.ts +9 -0
- package/lib/typescript/commonjs/src/clipboard.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/dev.d.ts +13 -0
- package/lib/typescript/commonjs/src/dev.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hiddenInput.d.ts +31 -0
- package/lib/typescript/commonjs/src/hiddenInput.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +11 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/legacy.d.ts +78 -0
- package/lib/typescript/commonjs/src/legacy.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/managedProps.d.ts +5 -0
- package/lib/typescript/commonjs/src/managedProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +262 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOtpController.d.ts +28 -0
- package/lib/typescript/commonjs/src/useOtpController.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useOtpInput.d.ts +22 -0
- package/lib/typescript/commonjs/src/useOtpInput.d.ts.map +1 -0
- package/lib/typescript/module/src/Cell.d.ts +39 -0
- package/lib/typescript/module/src/Cell.d.ts.map +1 -0
- package/lib/typescript/module/src/OtpInput.d.ts +12 -0
- package/lib/typescript/module/src/OtpInput.d.ts.map +1 -0
- package/lib/typescript/module/src/accessibility.d.ts +39 -0
- package/lib/typescript/module/src/accessibility.d.ts.map +1 -0
- package/lib/typescript/module/src/clipboard.d.ts +9 -0
- package/lib/typescript/module/src/clipboard.d.ts.map +1 -0
- package/lib/typescript/module/src/dev.d.ts +13 -0
- package/lib/typescript/module/src/dev.d.ts.map +1 -0
- package/lib/typescript/module/src/hiddenInput.d.ts +31 -0
- package/lib/typescript/module/src/hiddenInput.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +11 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/legacy.d.ts +78 -0
- package/lib/typescript/module/src/legacy.d.ts.map +1 -0
- package/lib/typescript/module/src/managedProps.d.ts +5 -0
- package/lib/typescript/module/src/managedProps.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +262 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/lib/typescript/module/src/useOtpController.d.ts +28 -0
- package/lib/typescript/module/src/useOtpController.d.ts.map +1 -0
- package/lib/typescript/module/src/useOtpInput.d.ts +22 -0
- package/lib/typescript/module/src/useOtpInput.d.ts.map +1 -0
- package/package.json +93 -4
- package/src/Cell.tsx +146 -0
- package/src/OtpInput.tsx +120 -0
- package/src/accessibility.ts +86 -0
- package/src/clipboard.ts +232 -0
- package/src/dev.ts +33 -0
- package/src/hiddenInput.ts +80 -0
- package/src/index.ts +38 -0
- package/src/legacy.tsx +320 -0
- package/src/managedProps.ts +29 -0
- package/src/types.ts +299 -0
- package/src/useOtpController.ts +58 -0
- package/src/useOtpInput.ts +313 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ResolvedOtpOptions } from '@r5n/otp-core';
|
|
2
|
+
import { type TextInputProps, type TextStyle } from 'react-native';
|
|
3
|
+
import type { OtpInputAutoComplete } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Functional style of the hidden `TextInput` (orchestrator decision P1, `rn-platform.md` Q2).
|
|
6
|
+
* - Literal absolute positioning with zero insets: `StyleSheet.absoluteFillObject` no longer
|
|
7
|
+
* exists in React Native 0.88.
|
|
8
|
+
* - `opacity: 0.02`: iOS ignores touches on views below 0.01 (no tap focus, no long-press Paste),
|
|
9
|
+
* and Android treats alpha 0 as invisible (no autofill session, no TalkBack).
|
|
10
|
+
* - Transparent colours hide the text at that opacity; `fontSize: 1` makes taps land after the
|
|
11
|
+
* text, so the native caret stays at the end.
|
|
12
|
+
* - No `lineHeight`, `letterSpacing` or `fontFamily`: fewer attribute writes on the focused iOS
|
|
13
|
+
* field, which can drop fast keystrokes (`rn-platform.md` Q5, RN #58904).
|
|
14
|
+
*/
|
|
15
|
+
export declare const HIDDEN_INPUT_STYLE: TextStyle;
|
|
16
|
+
interface HiddenInputOptions {
|
|
17
|
+
options: ResolvedOtpOptions;
|
|
18
|
+
autoComplete: OtpInputAutoComplete;
|
|
19
|
+
keyboardType: TextInputProps['keyboardType'];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Platform props of the hidden input (P2, `rn-platform.md` Q1). Deliberately absent:
|
|
23
|
+
* `maxLength` (native truncation cuts pastes and autofill before JavaScript sees them, G1),
|
|
24
|
+
* `inputMode` (it would override `keyboardType`), `caretHidden` and `contextMenuHidden` (they
|
|
25
|
+
* remove the long-press Paste/AutoFill menu), `secureTextEntry` (masking is visual; on iOS it can
|
|
26
|
+
* bring up the Strong Password UI) and a controlled `selection` (it races fast typing, P3).
|
|
27
|
+
* Predictive text and the keyboard's learning are off through `autoCorrect`/`spellCheck`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const hiddenInputProps: ({ options, autoComplete, keyboardType, }: HiddenInputOptions) => TextInputProps;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=hiddenInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hiddenInput.d.ts","sourceRoot":"","sources":["../../../../src/hiddenInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAY,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAW/B,CAAC;AAEH,UAAU,kBAAkB;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,YAAY,EAAE,oBAAoB,CAAC;IACnC,YAAY,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CAC9C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,6CAI1B,kBAAkB,KAAG,cAiCvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@r5n/otp-react-native`: one-time code input for React Native, built on `@r5n/otp-core`.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export type { OtpCasing, OtpCharset, OtpController, OtpSelection, OtpSlot, OtpSnapshot, } from '@r5n/otp-core';
|
|
7
|
+
export { OtpInputs as default, type OtpInputsProps, type OtpInputsRef, type OtpLegacyClipboard, } from './legacy.js';
|
|
8
|
+
export { OtpInput } from './OtpInput.js';
|
|
9
|
+
export type { OtpCellProps, OtpClipboardProvider, OtpDecorationProps, OtpHiddenInputProps, OtpInputAccessibilityTexts, OtpInputAutoComplete, OtpInputCellState, OtpInputDirection, OtpInputProps, OtpInputRef, OtpTextInputProps, OtpTextInputRef, UseOtpInputOptions, UseOtpInputResult, } from './types.js';
|
|
10
|
+
export { useOtpInput } from './useOtpInput.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,SAAS,EACT,UAAU,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,IAAI,OAAO,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type KeyboardTypeOptions, type StyleProp, type TextInputProps, type TextStyle, type ViewStyle } from 'react-native';
|
|
2
|
+
import type { OtpClipboardProvider } from './types.js';
|
|
3
|
+
/** Clipboard module for the v7 wrapper, for example `@react-native-clipboard/clipboard`. */
|
|
4
|
+
export type OtpLegacyClipboard = Pick<OtpClipboardProvider, 'getString' | 'hasString'>;
|
|
5
|
+
/**
|
|
6
|
+
* Props of the deprecated v7-compatible default export.
|
|
7
|
+
* @deprecated Use `OtpInputProps` with the named `OtpInput` export.
|
|
8
|
+
*/
|
|
9
|
+
export interface OtpInputsProps extends Omit<TextInputProps, 'style' | 'keyboardType' | 'defaultValue'> {
|
|
10
|
+
/** Maps to `length`. Default `4`. */
|
|
11
|
+
numberOfInputs?: number | undefined;
|
|
12
|
+
/** Maps to `onChange`. */
|
|
13
|
+
handleChange?: ((otpCode: string) => void) | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Fills the code, as in v7: shown at mount (and reported through `handleChange`), and every
|
|
16
|
+
* later non-empty change is applied as if entered (`handleChange`, then `onComplete` behaviour).
|
|
17
|
+
*/
|
|
18
|
+
defaultValue?: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Reads the clipboard through `clipboard`, which is required since v8 (no native dependency).
|
|
21
|
+
* Default: on when `clipboard` is given.
|
|
22
|
+
*/
|
|
23
|
+
autofillFromClipboard?: boolean | undefined;
|
|
24
|
+
/** Also read the clipboard at this interval while focused and incomplete. */
|
|
25
|
+
autofillListenerIntervalMS?: number | undefined;
|
|
26
|
+
/** New in v8: the clipboard module to read from (only read, never written). */
|
|
27
|
+
clipboard?: OtpLegacyClipboard | undefined;
|
|
28
|
+
/** Default `'phone-pad'`, as in v7. */
|
|
29
|
+
keyboardType?: KeyboardTypeOptions | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Hides the code. The cells always show `•` (`mask`).
|
|
32
|
+
*
|
|
33
|
+
* - Android: the hidden input is also a real secure field (`secureTextEntry`), as in v7.4.0, so
|
|
34
|
+
* TalkBack and other accessibility services do not get the code. Android treats only text and
|
|
35
|
+
* number fields as passwords, so `keyboardType` `'phone-pad'` (the default) becomes
|
|
36
|
+
* `'number-pad'`.
|
|
37
|
+
* - iOS: mask only. A secure iOS field clears itself when typing resumes after a refocus (with
|
|
38
|
+
* one input that would erase the whole code), and it can offer the Strong Password UI.
|
|
39
|
+
*
|
|
40
|
+
* The named `OtpInput` export does not do this; it takes `secureTextEntry` as an opt-in through
|
|
41
|
+
* `textInputProps`.
|
|
42
|
+
*/
|
|
43
|
+
secureTextEntry?: boolean | undefined;
|
|
44
|
+
/** Row of cells. */
|
|
45
|
+
style?: StyleProp<ViewStyle>;
|
|
46
|
+
/** Maps to `focusedCellStyle`. */
|
|
47
|
+
focusStyles?: StyleProp<ViewStyle>;
|
|
48
|
+
/** Maps to `cellStyle`. */
|
|
49
|
+
inputContainerStyles?: StyleProp<ViewStyle>;
|
|
50
|
+
/** Maps to `cellTextStyle`. */
|
|
51
|
+
inputStyles?: StyleProp<TextStyle>;
|
|
52
|
+
/**
|
|
53
|
+
* Reverses the cells, as in v7: the first character is in the right-most cell when `isRTL`
|
|
54
|
+
* differs from `I18nManager.isRTL` (v7 reversed the cells inside a row that React Native mirrors
|
|
55
|
+
* in right-to-left apps). So in a right-to-left app `isRTL` puts the first character on the left.
|
|
56
|
+
* Maps to `direction: 'rtl'` or `'ltr'`.
|
|
57
|
+
*/
|
|
58
|
+
isRTL?: boolean | undefined;
|
|
59
|
+
/** Test ID of the hidden input (default `'otpInput'`); cells get `${testIDPrefix}-cell-<index>`. */
|
|
60
|
+
testIDPrefix?: string | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Ref of the deprecated default export.
|
|
64
|
+
* @deprecated Use `OtpInputRef`.
|
|
65
|
+
*/
|
|
66
|
+
export interface OtpInputsRef {
|
|
67
|
+
/** Empties the value and calls `handleChange('')`, also when already empty. Never touches the clipboard. */
|
|
68
|
+
reset(): void;
|
|
69
|
+
focus(): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* v7-compatible wrapper around {@link OtpInput}, kept for one major version: accepts any
|
|
73
|
+
* character (`charset: 'any'`) and dismisses the keyboard on completion, as v7 did.
|
|
74
|
+
*
|
|
75
|
+
* @deprecated Use the named export: `import { OtpInput } from '@r5n/otp-react-native'`.
|
|
76
|
+
*/
|
|
77
|
+
export declare const OtpInputs: import("react").ForwardRefExoticComponent<OtpInputsProps & import("react").RefAttributes<OtpInputsRef>>;
|
|
78
|
+
//# sourceMappingURL=legacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../../src/legacy.tsx"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,mBAAmB,EAExB,KAAK,SAAS,EAEd,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,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AC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,4GAA4G;IAC5G,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACf;AAqDD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,yGAqKpB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Runtime list of `OtpTextInputManagedProp` (kept equal by the public API type test). */
|
|
2
|
+
export declare const TEXT_INPUT_MANAGED_PROPS: readonly ["value", "defaultValue", "maxLength", "selection", "editable", "readOnly", "caretHidden", "contextMenuHidden", "pointerEvents", "selectTextOnFocus", "clearTextOnFocus", "inputMode"];
|
|
3
|
+
/** Runtime list of `OtpCellManagedProp` (kept equal by the public API type test). */
|
|
4
|
+
export declare const CELL_MANAGED_PROPS: readonly ["children", "style", "testID", "pointerEvents", "aria-hidden", "accessible", "accessibilityElementsHidden", "importantForAccessibility"];
|
|
5
|
+
//# sourceMappingURL=managedProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedProps.d.ts","sourceRoot":"","sources":["../../../../src/managedProps.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,eAAO,MAAM,wBAAwB,iMAakB,CAAC;AAExD,qFAAqF;AACrF,eAAO,MAAM,kBAAkB,oJASmB,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type { OtpController, OtpOptions, OtpSnapshot } from '@r5n/otp-core';
|
|
2
|
+
import type { ComponentRef, ReactNode, RefObject } from 'react';
|
|
3
|
+
import type { ColorValue, StyleProp, TextInput, TextInputProps, TextStyle, ViewProps, ViewStyle } from 'react-native';
|
|
4
|
+
/**
|
|
5
|
+
* Layout direction of the row of cells. The value is always stored in logical order; only the
|
|
6
|
+
* row is mirrored.
|
|
7
|
+
* - `'ltr'` (default): codes read left to right, also in right-to-left apps.
|
|
8
|
+
* - `'rtl'`: the first character is in the right-most cell.
|
|
9
|
+
* - `'auto'`: follows `I18nManager.isRTL`.
|
|
10
|
+
*/
|
|
11
|
+
export type OtpInputDirection = 'ltr' | 'rtl' | 'auto';
|
|
12
|
+
/**
|
|
13
|
+
* OS one-time-code autofill. `'auto'` (or its alias `'one-time-code'`, the value
|
|
14
|
+
* `@r5n/otp-react` uses) offers SMS codes (iOS `oneTimeCode`, Android `sms-otp`); `'off'` opts the
|
|
15
|
+
* field out of autofill.
|
|
16
|
+
*/
|
|
17
|
+
export type OtpInputAutoComplete = 'auto' | 'one-time-code' | 'off';
|
|
18
|
+
/**
|
|
19
|
+
* Clipboard access injected by the app, so the package needs no native clipboard module. Works
|
|
20
|
+
* with `@react-native-clipboard/clipboard` (pass the default export) and `expo-clipboard`
|
|
21
|
+
* (`{ getString: Clipboard.getStringAsync, hasString: Clipboard.hasStringAsync }`).
|
|
22
|
+
*/
|
|
23
|
+
export interface OtpClipboardProvider {
|
|
24
|
+
/** Reads the clipboard text. Never written to: the component only reads. */
|
|
25
|
+
getString(): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional cheap check run before `getString`. Returning `false` skips the read, which avoids
|
|
28
|
+
* the iOS 16+ paste prompt when the clipboard has no text. iOS can report no text while it is
|
|
29
|
+
* still presenting the keyboard, so after an empty result on focus or on return to the
|
|
30
|
+
* foreground the clipboard is checked once more about 800 ms later.
|
|
31
|
+
*/
|
|
32
|
+
hasString?: (() => Promise<boolean>) | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Also read every `intervalMs` milliseconds while the input is focused and incomplete. Without
|
|
35
|
+
* it the clipboard is read only on focus and when the app returns to the foreground (plus the
|
|
36
|
+
* one later check described under `hasString`).
|
|
37
|
+
*/
|
|
38
|
+
intervalMs?: number | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Texts read by screen readers. Defaults are English; override them to localise. Announcements
|
|
42
|
+
* are queued behind speech in progress on iOS.
|
|
43
|
+
*/
|
|
44
|
+
export interface OtpInputAccessibilityTexts {
|
|
45
|
+
/** Announced when the code becomes complete; `false` disables it. Default `'Code complete'`. */
|
|
46
|
+
complete?: string | false | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Announced when `error` turns on, and part of the field's accessibility value while it stays
|
|
49
|
+
* on; `false` disables it. Default `'Incorrect code'`. Only a change from `false` to `true` is
|
|
50
|
+
* announced: turn `error` off when the user edits the code, so a second wrong code is announced
|
|
51
|
+
* too.
|
|
52
|
+
*/
|
|
53
|
+
error?: string | false | undefined;
|
|
54
|
+
/** Progress part of the field's accessibility value. Default `` `${filled} of ${length} entered` ``. */
|
|
55
|
+
progress?: ((filled: number, length: number) => string) | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** Instance of the hidden native `TextInput`. */
|
|
58
|
+
export type OtpTextInputRef = ComponentRef<typeof TextInput>;
|
|
59
|
+
/**
|
|
60
|
+
* Props of the hidden `TextInput` that the component manages, or that would break paste, autofill
|
|
61
|
+
* or screen readers on it (P1). Passed anyway (from JavaScript or through a cast), they are
|
|
62
|
+
* dropped with a development warning (C:S3-6).
|
|
63
|
+
*/
|
|
64
|
+
export type OtpTextInputManagedProp = 'value' | 'defaultValue' | 'maxLength' | 'selection' | 'editable' | 'readOnly' | 'caretHidden' | 'contextMenuHidden' | 'pointerEvents' | 'selectTextOnFocus' | 'clearTextOnFocus' | 'inputMode';
|
|
65
|
+
/**
|
|
66
|
+
* Extra props for the hidden `TextInput` (escape hatch). The props in `OtpTextInputManagedProp`
|
|
67
|
+
* cannot be passed. Overriding the functional props it sets (style,
|
|
68
|
+
* autofill, keyboard) is possible but voids the platform guarantees described in the docs.
|
|
69
|
+
* `secureTextEntry` is allowed as an opt-in that hides the characters from screen readers too, at
|
|
70
|
+
* the cost described in the accessibility docs (iOS clears a secure field when typing resumes after
|
|
71
|
+
* refocusing, and may offer password AutoFill).
|
|
72
|
+
*/
|
|
73
|
+
export type OtpTextInputProps = Omit<TextInputProps, OtpTextInputManagedProp>;
|
|
74
|
+
/** Props spread onto the hidden `TextInput` by {@link UseOtpInputResult.inputProps}. */
|
|
75
|
+
export type OtpHiddenInputProps = TextInputProps & {
|
|
76
|
+
ref: RefObject<OtpTextInputRef | null>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Props of a cell's `View` that keep it out of touches and screen readers (P4). Passed in
|
|
80
|
+
* `cellProps` anyway, they are dropped with a development warning (C:S3-6).
|
|
81
|
+
*/
|
|
82
|
+
export type OtpCellManagedProp = 'children' | 'style' | 'testID' | 'pointerEvents' | 'aria-hidden' | 'accessible' | 'accessibilityElementsHidden' | 'importantForAccessibility';
|
|
83
|
+
/** Extra props applied to the `View` of every cell. */
|
|
84
|
+
export type OtpCellProps = Omit<ViewProps, OtpCellManagedProp>;
|
|
85
|
+
/** Props that hide a decorative view from touches and screen readers; see `decorationProps`. */
|
|
86
|
+
export interface OtpDecorationProps {
|
|
87
|
+
readonly pointerEvents: 'none';
|
|
88
|
+
readonly accessibilityElementsHidden: true;
|
|
89
|
+
readonly importantForAccessibility: 'no-hide-descendants';
|
|
90
|
+
}
|
|
91
|
+
/** Render state of one cell: primitives only, so memoised cells re-render only when it changes. */
|
|
92
|
+
export interface OtpInputCellState {
|
|
93
|
+
/** Position of the cell, from 0, in logical order. */
|
|
94
|
+
readonly index: number;
|
|
95
|
+
/** The entered character, `''` when empty. Not masked: render `displayChar` to honour `mask`. */
|
|
96
|
+
readonly char: string;
|
|
97
|
+
/** What the default cell shows: the character, the mask glyph, the placeholder, or `''`. */
|
|
98
|
+
readonly displayChar: string;
|
|
99
|
+
readonly isFilled: boolean;
|
|
100
|
+
/** The caret is on this cell while the input is focused. */
|
|
101
|
+
readonly isActive: boolean;
|
|
102
|
+
/** `displayChar` is the placeholder. */
|
|
103
|
+
readonly isPlaceholder: boolean;
|
|
104
|
+
readonly isMasked: boolean;
|
|
105
|
+
readonly isError: boolean;
|
|
106
|
+
readonly isDisabled: boolean;
|
|
107
|
+
/** Index of the group (see `groups`) the cell belongs to. */
|
|
108
|
+
readonly groupIndex: number;
|
|
109
|
+
readonly isFirstInGroup: boolean;
|
|
110
|
+
readonly isLastInGroup: boolean;
|
|
111
|
+
}
|
|
112
|
+
/** Imperative API of {@link OtpInput} (via `ref`) and of {@link useOtpInput}. */
|
|
113
|
+
export interface OtpInputRef {
|
|
114
|
+
/** Focuses the hidden input (no-op while `disabled`). */
|
|
115
|
+
focus(): void;
|
|
116
|
+
blur(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Empties the value. Fires `onChange('')` only when the value was not already empty. Never
|
|
119
|
+
* touches the clipboard.
|
|
120
|
+
*/
|
|
121
|
+
clear(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Sets the value as if the user entered it: fires `onChange` when the value changes and, for a
|
|
124
|
+
* complete code, `onComplete` (in controlled mode, once the parent confirms it; see
|
|
125
|
+
* `onComplete`). `''` clears. Text longer than `length` (an SMS body) is searched for a code;
|
|
126
|
+
* otherwise only a bare code is set (`'12'`, `'123 456'`), and other text (`'Error: 15'`) is
|
|
127
|
+
* ignored: the value stays and no callback fires.
|
|
128
|
+
*/
|
|
129
|
+
setValue(value: string): void;
|
|
130
|
+
getValue(): string;
|
|
131
|
+
isFocused(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The hidden native `TextInput` instance, for measuring or for native methods the component does
|
|
134
|
+
* not wrap. `null` before mount and after unmount. It reads the current instance on every access,
|
|
135
|
+
* so it stays valid after React re-runs the effects of a mounted input (StrictMode,
|
|
136
|
+
* `<Activity>`). The same name as `OtpInputRef.input` in `@r5n/otp-react` (W:#22). The component
|
|
137
|
+
* owns the value, selection and managed props: change those through this API, not on the
|
|
138
|
+
* instance.
|
|
139
|
+
*/
|
|
140
|
+
readonly input: OtpTextInputRef | null;
|
|
141
|
+
}
|
|
142
|
+
/** Behaviour options shared by {@link OtpInput} and {@link useOtpInput}. */
|
|
143
|
+
export interface UseOtpInputOptions extends OtpOptions {
|
|
144
|
+
/**
|
|
145
|
+
* Controlled value. Updates from the parent never fire `onChange`; a change the parent does not
|
|
146
|
+
* accept is reverted on the next render. A parent update fires `onComplete` only to confirm a
|
|
147
|
+
* complete value the user just entered (see `onComplete`).
|
|
148
|
+
*/
|
|
149
|
+
value?: string | undefined;
|
|
150
|
+
/** Initial value when uncontrolled. Read once; never fires callbacks. */
|
|
151
|
+
defaultValue?: string | undefined;
|
|
152
|
+
/** Called once per visible change of the value, from the input event (never during render). */
|
|
153
|
+
onChange?: ((value: string) => void) | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Called when a user action, paste, autofill, clipboard autofill or `ref.setValue()` produces a
|
|
156
|
+
* different complete value. Uncontrolled: right after `onChange`. Controlled (`value` set): after
|
|
157
|
+
* the parent confirms that value, that is, once the next render passes it back as `value`; if
|
|
158
|
+
* the parent passes a different value instead, `onComplete` does not fire.
|
|
159
|
+
*/
|
|
160
|
+
onComplete?: ((value: string) => void) | undefined;
|
|
161
|
+
/** Focuses the input one frame after mount (deferred, so it survives navigation transitions). */
|
|
162
|
+
autoFocus?: boolean | undefined;
|
|
163
|
+
/** Makes the input non-editable and reports the disabled state to screen readers. */
|
|
164
|
+
disabled?: boolean | undefined;
|
|
165
|
+
/** Shows the error styles and announces `accessibilityTexts.error` when it turns on. */
|
|
166
|
+
error?: boolean | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Hides the characters in the cells: `true` shows `•`, a string shows that glyph (`''` means not
|
|
169
|
+
* masked). The value is not changed. Screen readers: on iOS the field's value then reports only
|
|
170
|
+
* progress, but typing echo and the field's text can still speak the characters on both
|
|
171
|
+
* platforms; pass `textInputProps={{ secureTextEntry: true }}` to hide them from assistive
|
|
172
|
+
* technology too (see `OtpTextInputProps`).
|
|
173
|
+
*/
|
|
174
|
+
mask?: boolean | string | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Shown in empty cells. A string of exactly `length` characters gives each cell its own
|
|
177
|
+
* character; any other string is shown whole in every empty cell.
|
|
178
|
+
*/
|
|
179
|
+
placeholder?: string | undefined;
|
|
180
|
+
/** Default `'auto'`. */
|
|
181
|
+
autoComplete?: OtpInputAutoComplete | undefined;
|
|
182
|
+
/** Default: `'number-pad'` for the numeric charset, `'default'` otherwise. */
|
|
183
|
+
keyboardType?: TextInputProps['keyboardType'];
|
|
184
|
+
/** Default `'ltr'`. */
|
|
185
|
+
direction?: OtpInputDirection | undefined;
|
|
186
|
+
/** Blurs the input (closing the keyboard) right after `onComplete`. Default `false`. */
|
|
187
|
+
blurOnComplete?: boolean | undefined;
|
|
188
|
+
/** Opt-in clipboard autofill. Default `false`: the clipboard is never read. */
|
|
189
|
+
clipboardAutofill?: false | OtpClipboardProvider | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* Default `'One-time code, <length> digits'`: `digit(s)` for the numeric charset, `letter(s)` for
|
|
192
|
+
* alphabetic, `character(s)` otherwise (for example `'One-time code, 6 digits'`).
|
|
193
|
+
*/
|
|
194
|
+
accessibilityLabel?: string | undefined;
|
|
195
|
+
accessibilityHint?: string | undefined;
|
|
196
|
+
accessibilityTexts?: OtpInputAccessibilityTexts | undefined;
|
|
197
|
+
onFocus?: TextInputProps['onFocus'];
|
|
198
|
+
onBlur?: TextInputProps['onBlur'];
|
|
199
|
+
/** See {@link OtpTextInputProps}. */
|
|
200
|
+
textInputProps?: OtpTextInputProps | undefined;
|
|
201
|
+
/** Test ID of the hidden input; cells get `` `${testID}-cell-${index}` ``. */
|
|
202
|
+
testID?: string | undefined;
|
|
203
|
+
}
|
|
204
|
+
/** Everything needed to render a custom code input around the hidden `TextInput`. */
|
|
205
|
+
export interface UseOtpInputResult extends OtpInputRef {
|
|
206
|
+
/** Current state of the core controller (value, selection, slots, completion, focus). */
|
|
207
|
+
snapshot: OtpSnapshot;
|
|
208
|
+
/** Render state of every cell, with `mask`, `placeholder`, `error` and `disabled` applied. */
|
|
209
|
+
cells: readonly OtpInputCellState[];
|
|
210
|
+
/**
|
|
211
|
+
* Spread onto every cell and separator view: hides them from touches and screen readers, so the
|
|
212
|
+
* hidden input stays the only accessibility element (P4, W:#15).
|
|
213
|
+
*/
|
|
214
|
+
decorationProps: OtpDecorationProps;
|
|
215
|
+
/**
|
|
216
|
+
* Spread onto a `TextInput` rendered **last** inside the row, so it covers the cells and owns
|
|
217
|
+
* every tap, long-press paste, autofill and screen-reader focus.
|
|
218
|
+
*/
|
|
219
|
+
inputProps: OtpHiddenInputProps;
|
|
220
|
+
/** Style for the row that contains the cells and the input (`flexDirection` and `direction`). */
|
|
221
|
+
rowStyle: ViewStyle;
|
|
222
|
+
/** For a `Pressable` around custom cells when the input does not cover them. */
|
|
223
|
+
pressableProps: {
|
|
224
|
+
onPress: () => void;
|
|
225
|
+
disabled: boolean;
|
|
226
|
+
accessible: false;
|
|
227
|
+
};
|
|
228
|
+
/** The underlying `@r5n/otp-core` controller (advanced use). */
|
|
229
|
+
controller: OtpController;
|
|
230
|
+
}
|
|
231
|
+
/** Props of {@link OtpInput}. */
|
|
232
|
+
export interface OtpInputProps extends UseOtpInputOptions {
|
|
233
|
+
/** Row that contains the cells. */
|
|
234
|
+
style?: StyleProp<ViewStyle>;
|
|
235
|
+
cellStyle?: StyleProp<ViewStyle>;
|
|
236
|
+
/** Applied to the active cell while focused. Precedence: cell < filled < focused < error. */
|
|
237
|
+
focusedCellStyle?: StyleProp<ViewStyle>;
|
|
238
|
+
filledCellStyle?: StyleProp<ViewStyle>;
|
|
239
|
+
errorCellStyle?: StyleProp<ViewStyle>;
|
|
240
|
+
/**
|
|
241
|
+
* Style of the cell text. The default colour follows the system colour scheme (`useColorScheme`:
|
|
242
|
+
* near-black in light mode, white in dark mode); set `color` here when the app's theme does not
|
|
243
|
+
* follow the system scheme.
|
|
244
|
+
*/
|
|
245
|
+
cellTextStyle?: StyleProp<TextStyle>;
|
|
246
|
+
/** Colour of placeholder characters (applied after `cellTextStyle`). Default `'#8E8E93'`. */
|
|
247
|
+
placeholderTextColor?: ColorValue | undefined;
|
|
248
|
+
/** Style of the spacer between groups (see `groups`). */
|
|
249
|
+
separatorStyle?: StyleProp<ViewStyle>;
|
|
250
|
+
/** Replaces the content of every cell; the cell styles are then not applied. */
|
|
251
|
+
renderCell?: ((state: OtpInputCellState) => ReactNode) | undefined;
|
|
252
|
+
/** Content of the spacer between groups; `groupIndex` is the group before it. */
|
|
253
|
+
renderSeparator?: ((groupIndex: number) => ReactNode) | undefined;
|
|
254
|
+
cellProps?: OtpCellProps | undefined;
|
|
255
|
+
/**
|
|
256
|
+
* Largest font scale of the cell text (Dynamic Type, font size settings). Default `2` (200%,
|
|
257
|
+
* WCAG 1.4.4). The text shrinks to fit its cell (`adjustsFontSizeToFit`, down to half size on
|
|
258
|
+
* iOS), so long codes at the largest sizes get smaller digits instead of clipped ones.
|
|
259
|
+
*/
|
|
260
|
+
maxFontSizeMultiplier?: number | undefined;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,eAAe,GAAG,KAAK,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;;;OAKG;IACH,SAAS,CAA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,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,gFAAgF;IAChF,UAAU,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IACnE,iFAAiF;IACjF,eAAe,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IAClE,SAAS,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OtpController, OtpControllerOptions, OtpSnapshot } from '@r5n/otp-core';
|
|
2
|
+
/** Whether an effect cleanup destroyed `controller` (it is about to be replaced). */
|
|
3
|
+
export declare const isDestroyed: (controller: OtpController) => boolean;
|
|
4
|
+
/** Creates a controller; `seed` is the last snapshot of a destroyed one being replaced. */
|
|
5
|
+
export type CreateController = (seed?: OtpSnapshot) => OtpController;
|
|
6
|
+
interface ControllerBinding {
|
|
7
|
+
controller: OtpController;
|
|
8
|
+
snapshot: OtpSnapshot;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Owns the core controller of one mounted input (`rn-platform.md` Q5).
|
|
12
|
+
*
|
|
13
|
+
* - Created in the state initialiser: pure, no subscriptions, so double rendering is harmless.
|
|
14
|
+
* - Destroyed on unmount. When React runs the effects of a component that is still mounted again
|
|
15
|
+
* (StrictMode in development, an `<Activity>` becoming visible), the destroyed controller is
|
|
16
|
+
* replaced by a new one seeded with its last value, so the input never stays dead. Focus is not
|
|
17
|
+
* carried over: the caller reads it from the native input (C:S3-1).
|
|
18
|
+
* - Props are reconciled after every render with `update()` from a layout effect, never during
|
|
19
|
+
* render (core B6). Running it after every render reverts an optimistic edit that a controlled
|
|
20
|
+
* parent did not accept, and confirms a complete one it did: `update()` calls no `onChange`, and
|
|
21
|
+
* calls `onComplete` only for that confirmation (C:S3-4).
|
|
22
|
+
* - Read through `useSyncExternalStore`; the snapshot is stable until something changes.
|
|
23
|
+
*
|
|
24
|
+
* `create` must be stable (it should read the latest props from a ref).
|
|
25
|
+
*/
|
|
26
|
+
export declare const useOtpController: (create: CreateController, reconcile: Partial<OtpControllerOptions>) => ControllerBinding;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=useOtpController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOtpController.d.ts","sourceRoot":"","sources":["../../../../src/useOtpController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAMtF,qFAAqF;AACrF,eAAO,MAAM,WAAW,eAAgB,aAAa,KAAG,OAAoC,CAAC;AAE7F,2FAA2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,CAAC;AAErE,UAAU,iBAAiB;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,WACnB,gBAAgB,aACb,OAAO,CAAC,oBAAoB,CAAC,KACvC,iBAqBF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { UseOtpInputOptions, UseOtpInputResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Headless code input: the state, cell render data and hidden `TextInput` props behind
|
|
4
|
+
* `OtpInput`, for building a custom layout.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const otp = useOtpInput({ length: 6, onComplete: verify });
|
|
9
|
+
* return (
|
|
10
|
+
* <View style={otp.rowStyle}>
|
|
11
|
+
* {otp.cells.map((cell) => (
|
|
12
|
+
* <View key={cell.index} {...otp.decorationProps}>
|
|
13
|
+
* <Text>{cell.displayChar}</Text>
|
|
14
|
+
* </View>
|
|
15
|
+
* ))}
|
|
16
|
+
* <TextInput {...otp.inputProps} />
|
|
17
|
+
* </View>
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function useOtpInput(options: UseOtpInputOptions): UseOtpInputResult;
|
|
22
|
+
//# sourceMappingURL=useOtpInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOtpInput.d.ts","sourceRoot":"","sources":["../../../../src/useOtpInput.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAsCjB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAyO1E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { type ColorValue, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { OtpCellProps, OtpDecorationProps, OtpInputCellState } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Cells and separators are decoration: the hidden input on top owns every touch and is the only
|
|
6
|
+
* accessibility element (P4), so this layer ignores touches (a custom cell with `elevation` must
|
|
7
|
+
* not steal taps on Android) and is hidden from VoiceOver and TalkBack.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DECORATION_PROPS: OtpDecorationProps;
|
|
10
|
+
/**
|
|
11
|
+
* Whether cells get the built-in look. Internal: the v7 wrapper turns it off under v7 style props,
|
|
12
|
+
* which styled unstyled cells (C:S3-7).
|
|
13
|
+
*/
|
|
14
|
+
export declare const CellAppearance: import("react").Context<"default" | "none">;
|
|
15
|
+
export interface CellProps extends OtpInputCellState {
|
|
16
|
+
testID: string | undefined;
|
|
17
|
+
cellStyle: StyleProp<ViewStyle>;
|
|
18
|
+
filledCellStyle: StyleProp<ViewStyle>;
|
|
19
|
+
focusedCellStyle: StyleProp<ViewStyle>;
|
|
20
|
+
errorCellStyle: StyleProp<ViewStyle>;
|
|
21
|
+
cellTextStyle: StyleProp<TextStyle>;
|
|
22
|
+
placeholderTextColor: ColorValue;
|
|
23
|
+
maxFontSizeMultiplier: number;
|
|
24
|
+
/** The colour scheme is dark: the built-in text colour is white. */
|
|
25
|
+
dark: boolean;
|
|
26
|
+
renderCell: ((state: OtpInputCellState) => ReactNode) | undefined;
|
|
27
|
+
cellProps: OtpCellProps | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** One visual cell. Memoised on primitives, so typing re-renders only the cells that changed. */
|
|
30
|
+
export declare const Cell: import("react").MemoExoticComponent<({ testID, cellStyle, filledCellStyle, focusedCellStyle, errorCellStyle, cellTextStyle, placeholderTextColor, maxFontSizeMultiplier, dark, renderCell, cellProps, ...state }: CellProps) => ReactElement>;
|
|
31
|
+
interface SeparatorProps {
|
|
32
|
+
groupIndex: number;
|
|
33
|
+
style: StyleProp<ViewStyle>;
|
|
34
|
+
renderSeparator: ((groupIndex: number) => ReactNode) | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** Spacer between two groups; `groupIndex` is the group before it. */
|
|
37
|
+
export declare const Separator: import("react").MemoExoticComponent<({ groupIndex, style, renderSeparator, }: SeparatorProps) => ReactElement>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=Cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cell.d.ts","sourceRoot":"","sources":["../../../../src/Cell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAC3F,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAGd,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEnF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAI7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,6CAA+C,CAAC;AA6B3E,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IAClD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,eAAe,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,gBAAgB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,cAAc,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,oBAAoB,EAAE,UAAU,CAAC;IACjC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IAClE,SAAS,EAAE,YAAY,GAAG,SAAS,CAAC;CACrC;AAED,iGAAiG;AACjG,eAAO,MAAM,IAAI,oNAad,SAAS,KAAG,YAAY,CAyCzB,CAAC;AAEH,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,eAAe,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;CAClE;AAED,sEAAsE;AACtE,eAAO,MAAM,SAAS,gFAInB,cAAc,KAAG,YAAY,CAM9B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OtpInputProps, OtpInputRef } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* One-time code input: one hidden native `TextInput` over a row of visual cells, so the OS owns
|
|
4
|
+
* typing, paste, SMS autofill and screen-reader focus, and the whole row is one touch target.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <OtpInput length={6} onComplete={(code) => verify(code)} autoFocus />
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const OtpInput: import("react").ForwardRefExoticComponent<OtpInputProps & import("react").RefAttributes<OtpInputRef>>;
|
|
12
|
+
//# sourceMappingURL=OtpInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtpInput.d.ts","sourceRoot":"","sources":["../../../../src/OtpInput.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAS1D;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,uGAyFnB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ResolvedOtpOptions } from '@r5n/otp-core';
|
|
2
|
+
import type { OtpInputAccessibilityTexts } from './types.js';
|
|
3
|
+
/** Resolves an announcement text: `undefined` falls back to the default, `false`/`''` disable it. */
|
|
4
|
+
export declare const announcementText: (text: string | false | undefined, fallback: 'complete' | 'error') => string;
|
|
5
|
+
/**
|
|
6
|
+
* Default accessible name of the hidden input, for example "One-time code, 6 digits" (scenario 31;
|
|
7
|
+
* the same wording as `@r5n/otp-react`, W:#20). Never the test ID (v7 used it, so screen readers
|
|
8
|
+
* said "otpInput-0", G10).
|
|
9
|
+
*/
|
|
10
|
+
export declare const defaultLabel: ({ length, charset }: ResolvedOtpOptions) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Accessibility value of the hidden input. React Native has no "invalid" state (`rn-platform.md`
|
|
13
|
+
* Q7), so the error is part of the text. Characters are separated by spaces so they are read one
|
|
14
|
+
* by one; a masked value only reports progress, never the characters.
|
|
15
|
+
*/
|
|
16
|
+
export declare const valueText: (value: string, length: number, masked: boolean, error: string, texts: OtpInputAccessibilityTexts | undefined) => string;
|
|
17
|
+
/**
|
|
18
|
+
* The hidden input's `accessibilityValue`.
|
|
19
|
+
*
|
|
20
|
+
* - iOS: VoiceOver reads it in place of the field's text, so a masked code reports only progress.
|
|
21
|
+
* - Android: React Native appends the value text to the field's `contentDescription`, which
|
|
22
|
+
* TalkBack reads together with the field's own text. Progress there would be read twice and
|
|
23
|
+
* rewritten on every keystroke (W:#8), so only the error is reported. The value is always an
|
|
24
|
+
* object: when it went from `{ text: error }` back to `undefined` as the error cleared, React
|
|
25
|
+
* Native left the content description empty and TalkBack lost the field's name (a plain
|
|
26
|
+
* `TextInput` does the same, on React Native 0.86 and 0.88). `{ text: '' }` keeps the name.
|
|
27
|
+
*/
|
|
28
|
+
export declare const accessibilityValue: (value: string, length: number, masked: boolean, error: string, texts: OtpInputAccessibilityTexts | undefined) => {
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Announces `text` to VoiceOver/TalkBack; a no-op for an empty text. Queued on iOS, so it follows
|
|
33
|
+
* the echo of the last typed character instead of cutting it off or being dropped (W:#17). `queue`
|
|
34
|
+
* is iOS-only: on Android React Native ignores the options and announces the text.
|
|
35
|
+
*/
|
|
36
|
+
export declare const announce: (text: string) => void;
|
|
37
|
+
/** Announces `text` when `active` turns on after mount (not on mount, not while it stays on). */
|
|
38
|
+
export declare const useAnnounceOnRise: (active: boolean, text: string) => void;
|
|
39
|
+
//# sourceMappingURL=accessibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility.d.ts","sourceRoot":"","sources":["../../../../src/accessibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAK1D,qGAAqG;AACrG,eAAO,MAAM,gBAAgB,SACrB,MAAM,GAAG,KAAK,GAAG,SAAS,YACtB,UAAU,GAAG,OAAO,KAC7B,MAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,wBAAyB,kBAAkB,KAAG,MAGtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,UACb,MAAM,UACL,MAAM,UACN,OAAO,SACR,MAAM,SACN,0BAA0B,GAAG,SAAS,KAC5C,MAMF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,UACtB,MAAM,UACL,MAAM,UACN,OAAO,SACR,MAAM,SACN,0BAA0B,GAAG,SAAS,KAC5C;IAAE,IAAI,EAAE,MAAM,CAAA;CAGhB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAAU,MAAM,KAAG,IAGvC,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,WAAY,OAAO,QAAQ,MAAM,KAAG,IAMjE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type OtpController } from '@r5n/otp-core';
|
|
2
|
+
import type { OtpClipboardProvider } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Opt-in clipboard autofill (`clipboardAutofill`). The provider object may be a new literal on
|
|
5
|
+
* every render. Enabling autofill takes a new baseline; changing `intervalMs` or replacing the
|
|
6
|
+
* controller (revival) restarts the triggers but keeps what was read so far.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useClipboardAutofill: (controller: OtpController, clipboardAutofill: false | OtpClipboardProvider | undefined) => void;
|
|
9
|
+
//# sourceMappingURL=clipboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../../src/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAyMpD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,eACnB,aAAa,qBACN,KAAK,GAAG,oBAAoB,GAAG,SAAS,KAC1D,IAmBF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints a development-only warning once per `key` for the lifetime of the app. Call it behind an
|
|
3
|
+
* `if (__DEV__)` guard, so production builds drop the message text.
|
|
4
|
+
*/
|
|
5
|
+
export declare const warnOnce: (key: string, message: string) => void;
|
|
6
|
+
/** The keys of `props` from `forbidden` that are set (not `undefined`). */
|
|
7
|
+
export declare const forbiddenKeys: (props: object | undefined, forbidden: readonly string[]) => readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* A copy of `props` without `keys`, or `props` itself when there is nothing to remove (so a stable
|
|
10
|
+
* object keeps its identity for memoised children).
|
|
11
|
+
*/
|
|
12
|
+
export declare const withoutKeys: <T extends object>(props: T | undefined, keys: readonly string[]) => T | undefined;
|
|
13
|
+
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../../src/dev.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,WAAW,MAAM,KAAG,IAIvD,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,aAAa,UACjB,MAAM,GAAG,SAAS,aACd,SAAS,MAAM,EAAE,KAC3B,SAAS,MAAM,EAGoE,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,SACnC,CAAC,GAAG,SAAS,QACd,SAAS,MAAM,EAAE,KACtB,CAAC,GAAG,SAIN,CAAC"}
|