react-smart-copy 1.21.0 → 1.23.0

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.
Files changed (44) hide show
  1. package/README.md +67 -0
  2. package/dist/chunks/digits-BUEvSVrs.cjs +51 -0
  3. package/dist/chunks/digits-BUEvSVrs.cjs.map +1 -0
  4. package/dist/chunks/digits-DkU-O9_A.js +46 -0
  5. package/dist/chunks/digits-DkU-O9_A.js.map +1 -0
  6. package/dist/chunks/field-BHo5y-t_.js +535 -0
  7. package/dist/chunks/field-BHo5y-t_.js.map +1 -0
  8. package/dist/chunks/field-BTsKTs2M.d.cts +87 -0
  9. package/dist/chunks/field-BTsKTs2M.d.ts +87 -0
  10. package/dist/chunks/field-Bytz2WfN.cjs +558 -0
  11. package/dist/chunks/field-Bytz2WfN.cjs.map +1 -0
  12. package/dist/chunks/{text-field-Ba8W3v4R.cjs → text-field-BEzUVOag.cjs} +26 -5
  13. package/dist/chunks/text-field-BEzUVOag.cjs.map +1 -0
  14. package/dist/chunks/{text-field-DUvrMMaK.js → text-field-D7PF2WlX.js} +21 -6
  15. package/dist/chunks/text-field-D7PF2WlX.js.map +1 -0
  16. package/dist/code.cjs +1 -1
  17. package/dist/code.js +1 -1
  18. package/dist/color.cjs +1 -1
  19. package/dist/color.js +1 -1
  20. package/dist/index.cjs +89 -0
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +42 -1
  23. package/dist/index.d.ts +42 -1
  24. package/dist/index.js +89 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/link.cjs +1 -1
  27. package/dist/link.js +1 -1
  28. package/dist/markdown.cjs +1 -1
  29. package/dist/markdown.js +1 -1
  30. package/dist/number.cjs +442 -0
  31. package/dist/number.cjs.map +1 -0
  32. package/dist/number.d.cts +172 -0
  33. package/dist/number.d.ts +172 -0
  34. package/dist/number.js +436 -0
  35. package/dist/number.js.map +1 -0
  36. package/dist/otp.cjs +7 -0
  37. package/dist/otp.d.cts +54 -0
  38. package/dist/otp.d.ts +54 -0
  39. package/dist/otp.js +2 -0
  40. package/dist/secrets.cjs +1 -1
  41. package/dist/secrets.js +1 -1
  42. package/package.json +71 -3
  43. package/dist/chunks/text-field-Ba8W3v4R.cjs.map +0 -1
  44. package/dist/chunks/text-field-DUvrMMaK.js.map +0 -1
@@ -0,0 +1,87 @@
1
+
2
+ //#region src/otp/normalize.d.ts
3
+ /** What a one-time code is made of. */
4
+ type OtpAlphabet = 'numeric' | 'alphanumeric';
5
+ /**
6
+ * `text` with its digits in ASCII and, for alphanumeric codes, its letters in upper case:
7
+ * full-width digits and letters, and Arabic-Indic, Devanagari and other scripts' digits,
8
+ * become ASCII. Other characters are kept: callers decide what to drop.
9
+ */
10
+ declare function normalizeOtpText(text: string, alphabet: OtpAlphabet): string;
11
+ //#endregion
12
+ //#region src/otp/web-otp.d.ts
13
+ /**
14
+ * Where filling a code from an SMS (the WebOTP API) stands.
15
+ *
16
+ * - `idle`: not asked for.
17
+ * - `waiting`: the browser is waiting for an SMS that ends with `@your.host #code`.
18
+ * - `received`: it came, and filled the field.
19
+ * - `unsupported`: this browser has no WebOTP API (only Chrome on Android has).
20
+ * - `failed`: the browser refused or gave up (no permission, a timeout, an insecure page).
21
+ * - `aborted`: the field was detached before an SMS came.
22
+ */
23
+ type WebOtpStatus = 'idle' | 'waiting' | 'received' | 'unsupported' | 'failed' | 'aborted';
24
+ //#endregion
25
+ //#region src/otp/field.d.ts
26
+ interface OtpFieldOptions {
27
+ /** How many characters the code has: one box each. Default 6. */
28
+ readonly length?: number;
29
+ /** Default `'numeric'`. */
30
+ readonly alphabet?: OtpAlphabet;
31
+ /**
32
+ * Each box's accessible name. Default `Digit 1 of 6` (`Character 1 of 6` for alphanumeric
33
+ * codes). Name the group around the boxes too (`role="group"` with a label).
34
+ */
35
+ readonly label?: (index: number, length: number) => string;
36
+ /**
37
+ * Fill the code from an SMS with the WebOTP API, where the browser has it (Chrome on
38
+ * Android): the message must end with `@your.host #code`. Asked for when the boxes are
39
+ * attached; cancelled when they are detached, or when the code is typed. Default `false`.
40
+ */
41
+ readonly webOtp?: boolean;
42
+ /** Called when the value changes. */
43
+ readonly onChange?: (snapshot: OtpSnapshot) => void;
44
+ /** Called when every box is filled, with the code. Again after an edit fills them anew. */
45
+ readonly onComplete?: (code: string) => void;
46
+ }
47
+ interface OtpSnapshot {
48
+ /** Each box's character: `''` for an empty box. */
49
+ readonly chars: readonly string[];
50
+ /** The characters typed so far, in order, without gaps. */
51
+ readonly value: string;
52
+ /** Every box holds a character: `value` is the code. */
53
+ readonly complete: boolean;
54
+ /** Where filling the code from an SMS stands. `idle` unless `webOtp` is on. */
55
+ readonly webOtp: WebOtpStatus;
56
+ }
57
+ /** The field's functions are bound: pass them around freely (`onClick={field.clear}`). */
58
+ interface OtpField {
59
+ /**
60
+ * Wires up the boxes (one `<input>` each, in order): their typing, pasting, autofill,
61
+ * keys, focus and attributes. Returns a function that undoes it. Boxes are wired to one
62
+ * field at a time: attaching again first detaches the previous boxes.
63
+ */
64
+ readonly attach: (inputs: readonly HTMLInputElement[]) => () => void;
65
+ /** The current state. A new object after each change, the same one otherwise. */
66
+ readonly getSnapshot: () => OtpSnapshot;
67
+ /** Calls `listener` after each change. Returns a function that stops it. */
68
+ readonly subscribe: (listener: () => void) => () => void;
69
+ /** Fills the boxes with `code` from the first (characters a code can't have are dropped). */
70
+ readonly setValue: (code: string) => void;
71
+ /** Empties every box and focuses the first. */
72
+ readonly clear: () => void;
73
+ /** Focuses the first empty box (or the last, when all are filled). */
74
+ readonly focus: () => void;
75
+ }
76
+ /**
77
+ * A one-time code field over a row of single-character boxes, without a framework:
78
+ * typing moves to the next box, Backspace to the one before; pasting a code, or an SMS
79
+ * holding one, fills every box from any of them; an SMS autofill into the first box
80
+ * (iOS, Android) fills them all. `useOtpField` is this, for React.
81
+ *
82
+ * @throws {CopyFailure} `invalid-payload` for a `length` that is not 1 to 32.
83
+ */
84
+ declare function createOtpField(options?: OtpFieldOptions): OtpField;
85
+ //#endregion
86
+ export { WebOtpStatus as a, createOtpField as i, OtpFieldOptions as n, OtpAlphabet as o, OtpSnapshot as r, normalizeOtpText as s, OtpField as t };
87
+ //# sourceMappingURL=field-BTsKTs2M.d.cts.map
@@ -0,0 +1,87 @@
1
+
2
+ //#region src/otp/normalize.d.ts
3
+ /** What a one-time code is made of. */
4
+ type OtpAlphabet = 'numeric' | 'alphanumeric';
5
+ /**
6
+ * `text` with its digits in ASCII and, for alphanumeric codes, its letters in upper case:
7
+ * full-width digits and letters, and Arabic-Indic, Devanagari and other scripts' digits,
8
+ * become ASCII. Other characters are kept: callers decide what to drop.
9
+ */
10
+ declare function normalizeOtpText(text: string, alphabet: OtpAlphabet): string;
11
+ //#endregion
12
+ //#region src/otp/web-otp.d.ts
13
+ /**
14
+ * Where filling a code from an SMS (the WebOTP API) stands.
15
+ *
16
+ * - `idle`: not asked for.
17
+ * - `waiting`: the browser is waiting for an SMS that ends with `@your.host #code`.
18
+ * - `received`: it came, and filled the field.
19
+ * - `unsupported`: this browser has no WebOTP API (only Chrome on Android has).
20
+ * - `failed`: the browser refused or gave up (no permission, a timeout, an insecure page).
21
+ * - `aborted`: the field was detached before an SMS came.
22
+ */
23
+ type WebOtpStatus = 'idle' | 'waiting' | 'received' | 'unsupported' | 'failed' | 'aborted';
24
+ //#endregion
25
+ //#region src/otp/field.d.ts
26
+ interface OtpFieldOptions {
27
+ /** How many characters the code has: one box each. Default 6. */
28
+ readonly length?: number;
29
+ /** Default `'numeric'`. */
30
+ readonly alphabet?: OtpAlphabet;
31
+ /**
32
+ * Each box's accessible name. Default `Digit 1 of 6` (`Character 1 of 6` for alphanumeric
33
+ * codes). Name the group around the boxes too (`role="group"` with a label).
34
+ */
35
+ readonly label?: (index: number, length: number) => string;
36
+ /**
37
+ * Fill the code from an SMS with the WebOTP API, where the browser has it (Chrome on
38
+ * Android): the message must end with `@your.host #code`. Asked for when the boxes are
39
+ * attached; cancelled when they are detached, or when the code is typed. Default `false`.
40
+ */
41
+ readonly webOtp?: boolean;
42
+ /** Called when the value changes. */
43
+ readonly onChange?: (snapshot: OtpSnapshot) => void;
44
+ /** Called when every box is filled, with the code. Again after an edit fills them anew. */
45
+ readonly onComplete?: (code: string) => void;
46
+ }
47
+ interface OtpSnapshot {
48
+ /** Each box's character: `''` for an empty box. */
49
+ readonly chars: readonly string[];
50
+ /** The characters typed so far, in order, without gaps. */
51
+ readonly value: string;
52
+ /** Every box holds a character: `value` is the code. */
53
+ readonly complete: boolean;
54
+ /** Where filling the code from an SMS stands. `idle` unless `webOtp` is on. */
55
+ readonly webOtp: WebOtpStatus;
56
+ }
57
+ /** The field's functions are bound: pass them around freely (`onClick={field.clear}`). */
58
+ interface OtpField {
59
+ /**
60
+ * Wires up the boxes (one `<input>` each, in order): their typing, pasting, autofill,
61
+ * keys, focus and attributes. Returns a function that undoes it. Boxes are wired to one
62
+ * field at a time: attaching again first detaches the previous boxes.
63
+ */
64
+ readonly attach: (inputs: readonly HTMLInputElement[]) => () => void;
65
+ /** The current state. A new object after each change, the same one otherwise. */
66
+ readonly getSnapshot: () => OtpSnapshot;
67
+ /** Calls `listener` after each change. Returns a function that stops it. */
68
+ readonly subscribe: (listener: () => void) => () => void;
69
+ /** Fills the boxes with `code` from the first (characters a code can't have are dropped). */
70
+ readonly setValue: (code: string) => void;
71
+ /** Empties every box and focuses the first. */
72
+ readonly clear: () => void;
73
+ /** Focuses the first empty box (or the last, when all are filled). */
74
+ readonly focus: () => void;
75
+ }
76
+ /**
77
+ * A one-time code field over a row of single-character boxes, without a framework:
78
+ * typing moves to the next box, Backspace to the one before; pasting a code, or an SMS
79
+ * holding one, fills every box from any of them; an SMS autofill into the first box
80
+ * (iOS, Android) fills them all. `useOtpField` is this, for React.
81
+ *
82
+ * @throws {CopyFailure} `invalid-payload` for a `length` that is not 1 to 32.
83
+ */
84
+ declare function createOtpField(options?: OtpFieldOptions): OtpField;
85
+ //#endregion
86
+ export { WebOtpStatus as a, createOtpField as i, OtpFieldOptions as n, OtpAlphabet as o, OtpSnapshot as r, normalizeOtpText as s, OtpField as t };
87
+ //# sourceMappingURL=field-BTsKTs2M.d.ts.map