@pagopa/io-app-design-system 6.0.6 → 6.1.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.
- package/lib/commonjs/components/badge/Badge.js +2 -2
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/badge/__test__/__snapshots__/badge.test.tsx.snap +2 -2
- package/lib/commonjs/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +3 -3
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -6
- package/lib/commonjs/components/index.js +30 -19
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/markdown/CodeBlock.js +36 -0
- package/lib/commonjs/components/markdown/CodeBlock.js.map +1 -0
- package/lib/commonjs/components/markdown/IOMarkdown.js +71 -0
- package/lib/commonjs/components/markdown/IOMarkdown.js.map +1 -0
- package/lib/commonjs/components/markdown/IOMarkdownLite.js +22 -0
- package/lib/commonjs/components/markdown/IOMarkdownLite.js.map +1 -0
- package/lib/commonjs/components/markdown/ImageRenderer.js +53 -0
- package/lib/commonjs/components/markdown/ImageRenderer.js.map +1 -0
- package/lib/commonjs/components/markdown/index.js +20 -0
- package/lib/commonjs/components/markdown/index.js.map +1 -0
- package/lib/commonjs/components/markdown/parser.js +253 -0
- package/lib/commonjs/components/markdown/parser.js.map +1 -0
- package/lib/commonjs/components/markdown/rules.js +324 -0
- package/lib/commonjs/components/markdown/rules.js.map +1 -0
- package/lib/commonjs/components/markdown/types.js +6 -0
- package/lib/commonjs/components/markdown/types.js.map +1 -0
- package/lib/commonjs/components/markdown/utils.js +113 -0
- package/lib/commonjs/components/markdown/utils.js.map +1 -0
- package/lib/commonjs/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +2 -2
- package/lib/commonjs/components/otpInput/OTPInput.js +41 -26
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/tag/Tag.js +2 -1
- package/lib/commonjs/components/tag/Tag.js.map +1 -1
- package/lib/commonjs/components/toast/ToastProvider.js +3 -3
- package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
- package/lib/commonjs/components/tooltip/Tooltip.js +3 -3
- package/lib/commonjs/components/tooltip/Tooltip.js.map +1 -1
- package/lib/commonjs/components/typography/BodySmall.js +6 -3
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/commonjs/components/typography/IOText.js +2 -3
- package/lib/commonjs/components/typography/IOText.js.map +1 -1
- package/lib/commonjs/utils/pipe.js +29 -0
- package/lib/commonjs/utils/pipe.js.map +1 -0
- package/lib/commonjs/utils/throttle.js +19 -0
- package/lib/commonjs/utils/throttle.js.map +1 -0
- package/lib/module/components/badge/Badge.js +2 -2
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/badge/__test__/__snapshots__/badge.test.tsx.snap +2 -2
- package/lib/module/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +3 -3
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -6
- package/lib/module/components/index.js +3 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/markdown/CodeBlock.js +31 -0
- package/lib/module/components/markdown/CodeBlock.js.map +1 -0
- package/lib/module/components/markdown/IOMarkdown.js +66 -0
- package/lib/module/components/markdown/IOMarkdown.js.map +1 -0
- package/lib/module/components/markdown/IOMarkdownLite.js +17 -0
- package/lib/module/components/markdown/IOMarkdownLite.js.map +1 -0
- package/lib/module/components/markdown/ImageRenderer.js +48 -0
- package/lib/module/components/markdown/ImageRenderer.js.map +1 -0
- package/lib/module/components/markdown/index.js +5 -0
- package/lib/module/components/markdown/index.js.map +1 -0
- package/lib/module/components/markdown/parser.js +246 -0
- package/lib/module/components/markdown/parser.js.map +1 -0
- package/lib/module/components/markdown/rules.js +319 -0
- package/lib/module/components/markdown/rules.js.map +1 -0
- package/lib/module/components/markdown/types.js +4 -0
- package/lib/module/components/markdown/types.js.map +1 -0
- package/lib/module/components/markdown/utils.js +103 -0
- package/lib/module/components/markdown/utils.js.map +1 -0
- package/lib/module/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +2 -2
- package/lib/module/components/otpInput/OTPInput.js +42 -27
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/tag/Tag.js +2 -1
- package/lib/module/components/tag/Tag.js.map +1 -1
- package/lib/module/components/toast/ToastProvider.js +1 -1
- package/lib/module/components/toast/ToastProvider.js.map +1 -1
- package/lib/module/components/tooltip/Tooltip.js +3 -3
- package/lib/module/components/tooltip/Tooltip.js.map +1 -1
- package/lib/module/components/typography/BodySmall.js +5 -2
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/typography/IOText.js +3 -4
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/utils/pipe.js +25 -0
- package/lib/module/utils/pipe.js.map +1 -0
- package/lib/module/utils/throttle.js +14 -0
- package/lib/module/utils/throttle.js.map +1 -0
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +3 -2
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/markdown/CodeBlock.d.ts +10 -0
- package/lib/typescript/components/markdown/CodeBlock.d.ts.map +1 -0
- package/lib/typescript/components/markdown/IOMarkdown.d.ts +34 -0
- package/lib/typescript/components/markdown/IOMarkdown.d.ts.map +1 -0
- package/lib/typescript/components/markdown/IOMarkdownLite.d.ts +22 -0
- package/lib/typescript/components/markdown/IOMarkdownLite.d.ts.map +1 -0
- package/lib/typescript/components/markdown/ImageRenderer.d.ts +12 -0
- package/lib/typescript/components/markdown/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/components/markdown/index.d.ts +6 -0
- package/lib/typescript/components/markdown/index.d.ts.map +1 -0
- package/lib/typescript/components/markdown/parser.d.ts +17 -0
- package/lib/typescript/components/markdown/parser.d.ts.map +1 -0
- package/lib/typescript/components/markdown/rules.d.ts +6 -0
- package/lib/typescript/components/markdown/rules.d.ts.map +1 -0
- package/lib/typescript/components/markdown/types.d.ts +41 -0
- package/lib/typescript/components/markdown/types.d.ts.map +1 -0
- package/lib/typescript/components/markdown/utils.d.ts +27 -0
- package/lib/typescript/components/markdown/utils.d.ts.map +1 -0
- package/lib/typescript/components/otpInput/OTPInput.d.ts +4 -0
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/tag/Tag.d.ts.map +1 -1
- package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts +2 -0
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/utils/pipe.d.ts +25 -0
- package/lib/typescript/utils/pipe.d.ts.map +1 -0
- package/lib/typescript/utils/throttle.d.ts +2 -0
- package/lib/typescript/utils/throttle.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/badge/Badge.tsx +2 -2
- package/src/components/badge/__test__/__snapshots__/badge.test.tsx.snap +2 -2
- package/src/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +3 -3
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +6 -6
- package/src/components/index.tsx +3 -2
- package/src/components/markdown/CodeBlock.tsx +32 -0
- package/src/components/markdown/IOMarkdown.tsx +110 -0
- package/src/components/markdown/IOMarkdownLite.tsx +27 -0
- package/src/components/markdown/ImageRenderer.tsx +52 -0
- package/src/components/markdown/index.ts +7 -0
- package/src/components/markdown/parser.ts +334 -0
- package/src/components/markdown/rules.tsx +366 -0
- package/src/components/markdown/types.ts +81 -0
- package/src/components/markdown/utils.ts +127 -0
- package/src/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +2 -2
- package/src/components/otpInput/OTPInput.tsx +57 -32
- package/src/components/tag/Tag.tsx +2 -1
- package/src/components/toast/ToastProvider.tsx +1 -1
- package/src/components/tooltip/Tooltip.tsx +4 -3
- package/src/components/typography/BodySmall.tsx +5 -2
- package/src/components/typography/IOText.tsx +5 -15
- package/src/utils/pipe.ts +55 -0
- package/src/utils/throttle.ts +15 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { TextStyle } from "react-native";
|
|
3
|
+
import type { IOColors } from "../../core";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* All supported markdown node types.
|
|
7
|
+
*/
|
|
8
|
+
export type MarkdownNodeType =
|
|
9
|
+
/* Headings */
|
|
10
|
+
| "heading1"
|
|
11
|
+
| "heading2"
|
|
12
|
+
| "heading3"
|
|
13
|
+
| "heading4"
|
|
14
|
+
| "heading5"
|
|
15
|
+
| "heading6"
|
|
16
|
+
/* Inline */
|
|
17
|
+
| "paragraph"
|
|
18
|
+
| "text"
|
|
19
|
+
| "strong"
|
|
20
|
+
| "em"
|
|
21
|
+
| "link"
|
|
22
|
+
| "softbreak"
|
|
23
|
+
| "hardbreak"
|
|
24
|
+
/* Lists */
|
|
25
|
+
| "bullet_list"
|
|
26
|
+
| "ordered_list"
|
|
27
|
+
| "list_item"
|
|
28
|
+
/* Block-level */
|
|
29
|
+
| "blockquote"
|
|
30
|
+
| "image"
|
|
31
|
+
| "code_inline"
|
|
32
|
+
| "fence"
|
|
33
|
+
| "hr"
|
|
34
|
+
| "html_block"
|
|
35
|
+
| "html_inline";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A node in the markdown AST.
|
|
39
|
+
*/
|
|
40
|
+
export type MarkdownNode = {
|
|
41
|
+
type: MarkdownNodeType;
|
|
42
|
+
key: string;
|
|
43
|
+
content?: string;
|
|
44
|
+
attributes?: Record<string, string>;
|
|
45
|
+
children: ReadonlyArray<MarkdownNode>;
|
|
46
|
+
/** List metadata: whether the list is ordered */
|
|
47
|
+
ordered?: boolean;
|
|
48
|
+
/** Number of ancestor lists wrapping this node */
|
|
49
|
+
listDepth?: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type RenderContext = {
|
|
53
|
+
onLinkPress?: (url: string) => void;
|
|
54
|
+
linkColor: IOColors;
|
|
55
|
+
/** Applied to paragraph */
|
|
56
|
+
textAlign: TextStyle["textAlign"];
|
|
57
|
+
/** Applied to paragraph segments */
|
|
58
|
+
fontSize: TextStyle["fontSize"];
|
|
59
|
+
lineHeight: TextStyle["lineHeight"];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type RenderChildrenFn = (
|
|
63
|
+
nodes: ReadonlyArray<MarkdownNode>
|
|
64
|
+
) => ReadonlyArray<React.ReactNode>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A render rule receives a node, a function to recursively render children,
|
|
68
|
+
* and the current render context.
|
|
69
|
+
*/
|
|
70
|
+
export type RenderRule = (
|
|
71
|
+
node: MarkdownNode,
|
|
72
|
+
renderChildren: RenderChildrenFn,
|
|
73
|
+
context: RenderContext
|
|
74
|
+
) => React.ReactNode;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Partial record of render rules. Only the provided keys override the defaults.
|
|
78
|
+
*/
|
|
79
|
+
export type IOMarkdownRenderRules = Partial<
|
|
80
|
+
Record<MarkdownNodeType, RenderRule>
|
|
81
|
+
>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { IOPictogramsBleed } from "../pictograms";
|
|
2
|
+
import type { MarkdownNode } from "./types";
|
|
3
|
+
|
|
4
|
+
const BULLET_FULL = "\u2022";
|
|
5
|
+
const BULLET_HOLLOW = "\u25E6";
|
|
6
|
+
const BULLET_SQUARE = "\u25B8";
|
|
7
|
+
|
|
8
|
+
const PICTOGRAM_REGEXP = /^\s*\[!(.*?)\]/;
|
|
9
|
+
|
|
10
|
+
const ROMAN_NUMERALS: ReadonlyArray<readonly [number, string]> = [
|
|
11
|
+
[1000, "m"],
|
|
12
|
+
[900, "cm"],
|
|
13
|
+
[500, "d"],
|
|
14
|
+
[400, "cd"],
|
|
15
|
+
[100, "c"],
|
|
16
|
+
[90, "xc"],
|
|
17
|
+
[50, "l"],
|
|
18
|
+
[40, "xl"],
|
|
19
|
+
[10, "x"],
|
|
20
|
+
[9, "ix"],
|
|
21
|
+
[5, "v"],
|
|
22
|
+
[4, "iv"],
|
|
23
|
+
[1, "i"]
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns the bullet glyph used for unordered lists at a given nesting depth.
|
|
28
|
+
*/
|
|
29
|
+
export const getUnorderedListBullet = (listDepth: number): string => {
|
|
30
|
+
switch (listDepth % 3) {
|
|
31
|
+
case 0:
|
|
32
|
+
return BULLET_FULL;
|
|
33
|
+
case 1:
|
|
34
|
+
return BULLET_HOLLOW;
|
|
35
|
+
default:
|
|
36
|
+
return BULLET_SQUARE;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Converts a positive integer to its lowercase Roman numeral representation.
|
|
42
|
+
*/
|
|
43
|
+
const toRomanNumeral = (value: number, index = 0): string => {
|
|
44
|
+
const numeral = ROMAN_NUMERALS[index];
|
|
45
|
+
|
|
46
|
+
if (value <= 0 || numeral === undefined) {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const [arabic, roman] = numeral;
|
|
51
|
+
|
|
52
|
+
if (value >= arabic) {
|
|
53
|
+
// Consume the current numeral and keep using it until the remainder is smaller.
|
|
54
|
+
return `${roman}${toRomanNumeral(value - arabic, index)}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Try the next Roman numeral when the current one no longer fits.
|
|
58
|
+
return toRomanNumeral(value, index + 1);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Converts a positive integer to a lowercase alphabetic sequence (`a`, `b`, `aa`).
|
|
63
|
+
*/
|
|
64
|
+
const toAlphabeticMarker = (value: number): string => {
|
|
65
|
+
if (value <= 0) {
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Convert to a zero-based base-26 index so 1 -> a, 26 -> z, 27 -> aa.
|
|
70
|
+
const normalizedValue = value - 1;
|
|
71
|
+
const prefix = toAlphabeticMarker(Math.floor(normalizedValue / 26));
|
|
72
|
+
const suffix = String.fromCodePoint(97 + (normalizedValue % 26));
|
|
73
|
+
|
|
74
|
+
return `${prefix}${suffix}`;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the ordered-list marker for a given item index and nesting depth.
|
|
79
|
+
*/
|
|
80
|
+
export const getOrderedListMarker = (
|
|
81
|
+
value: number,
|
|
82
|
+
listDepth: number
|
|
83
|
+
): string => {
|
|
84
|
+
switch (listDepth % 3) {
|
|
85
|
+
case 0:
|
|
86
|
+
return `${value}.`;
|
|
87
|
+
case 1:
|
|
88
|
+
return `${toRomanNumeral(value)}.`;
|
|
89
|
+
default:
|
|
90
|
+
return `${toAlphabeticMarker(value)}.`;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Extracts a banner pictogram name from a `[!pictogramName]` prefix.
|
|
96
|
+
*/
|
|
97
|
+
export const extractPictogramName = (text: string): IOPictogramsBleed => {
|
|
98
|
+
const match = PICTOGRAM_REGEXP.exec(text);
|
|
99
|
+
const value = match?.[1];
|
|
100
|
+
const isValid = value != null && value in IOPictogramsBleed;
|
|
101
|
+
return isValid ? (value as IOPictogramsBleed) : "notification";
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Removes the leading pictogram directive from blockquote content.
|
|
106
|
+
*/
|
|
107
|
+
export const stripPictogramPrefix = (text: string): string =>
|
|
108
|
+
text.replace(PICTOGRAM_REGEXP, "");
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Recursively collects plain text content from a Markdown AST node.
|
|
112
|
+
*/
|
|
113
|
+
export const collectRawText = (node: MarkdownNode): string => {
|
|
114
|
+
if (node.content) {
|
|
115
|
+
return node.content;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return node.children.map(collectRawText).join("");
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns true when a raw HTML fragment is a `<br>` tag.
|
|
123
|
+
*/
|
|
124
|
+
export const isBrTag = (content: string): boolean => {
|
|
125
|
+
const match = new RegExp(/<([^\s/>]+)\s*\/?>/).exec(content);
|
|
126
|
+
return match?.[1] === "br";
|
|
127
|
+
};
|
|
@@ -1095,6 +1095,7 @@ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) With Badge (badge
|
|
|
1095
1095
|
"borderCurve": "continuous",
|
|
1096
1096
|
"flexDirection": "row",
|
|
1097
1097
|
"justifyContent": "center",
|
|
1098
|
+
"overflow": "hidden",
|
|
1098
1099
|
},
|
|
1099
1100
|
{
|
|
1100
1101
|
"borderRadius": 24,
|
|
@@ -1125,7 +1126,6 @@ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) With Badge (badge
|
|
|
1125
1126
|
},
|
|
1126
1127
|
{
|
|
1127
1128
|
"alignSelf": "center",
|
|
1128
|
-
"flexShrink": 1,
|
|
1129
1129
|
"letterSpacing": 0.5,
|
|
1130
1130
|
"textTransform": "uppercase",
|
|
1131
1131
|
},
|
|
@@ -2571,6 +2571,7 @@ exports[`ModuleNavigationAlt - Snapshot With Badge (badge + chevron) 1`] = `
|
|
|
2571
2571
|
"borderCurve": "continuous",
|
|
2572
2572
|
"flexDirection": "row",
|
|
2573
2573
|
"justifyContent": "center",
|
|
2574
|
+
"overflow": "hidden",
|
|
2574
2575
|
},
|
|
2575
2576
|
{
|
|
2576
2577
|
"borderRadius": 24,
|
|
@@ -2601,7 +2602,6 @@ exports[`ModuleNavigationAlt - Snapshot With Badge (badge + chevron) 1`] = `
|
|
|
2601
2602
|
},
|
|
2602
2603
|
{
|
|
2603
2604
|
"alignSelf": "center",
|
|
2604
|
-
"flexShrink": 1,
|
|
2605
2605
|
"letterSpacing": 0.5,
|
|
2606
2606
|
"textTransform": "uppercase",
|
|
2607
2607
|
},
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
} from "react";
|
|
9
9
|
import {
|
|
10
10
|
AccessibilityInfo,
|
|
11
|
-
|
|
11
|
+
Platform,
|
|
12
12
|
Pressable,
|
|
13
|
+
StyleSheet,
|
|
13
14
|
TextInput,
|
|
14
|
-
|
|
15
|
+
TextInputKeyPressEvent,
|
|
15
16
|
View
|
|
16
17
|
} from "react-native";
|
|
17
18
|
import Animated from "react-native-reanimated";
|
|
@@ -35,6 +36,10 @@ type Props = {
|
|
|
35
36
|
accessibilityLabel?: string;
|
|
36
37
|
deleteButtonAccessibilityLabel?: string;
|
|
37
38
|
accessibilityHint?: string;
|
|
39
|
+
accessibilityValueText?: (params: {
|
|
40
|
+
valueLength: number;
|
|
41
|
+
length: number;
|
|
42
|
+
}) => string;
|
|
38
43
|
inputAccessoryViewID?: string;
|
|
39
44
|
autoFocus?: boolean;
|
|
40
45
|
};
|
|
@@ -60,6 +65,7 @@ export const OTPInput = forwardRef<View, Props>(
|
|
|
60
65
|
length,
|
|
61
66
|
accessibilityLabel,
|
|
62
67
|
accessibilityHint,
|
|
68
|
+
accessibilityValueText,
|
|
63
69
|
onValidate,
|
|
64
70
|
errorMessage = "",
|
|
65
71
|
secret = false,
|
|
@@ -120,10 +126,8 @@ export const OTPInput = forwardRef<View, Props>(
|
|
|
120
126
|
handleValidate(value);
|
|
121
127
|
};
|
|
122
128
|
|
|
123
|
-
const handleKeyPress = ({
|
|
124
|
-
nativeEvent
|
|
125
|
-
}: NativeSyntheticEvent<TextInputKeyPressEventData>) => {
|
|
126
|
-
switch (nativeEvent.key) {
|
|
129
|
+
const handleKeyPress = (e: TextInputKeyPressEvent) => {
|
|
130
|
+
switch (e.nativeEvent.key) {
|
|
127
131
|
case "Backspace":
|
|
128
132
|
if (deleteButtonAccessibilityLabel && value.length > 0) {
|
|
129
133
|
AccessibilityInfo.announceForAccessibility(
|
|
@@ -132,7 +136,7 @@ export const OTPInput = forwardRef<View, Props>(
|
|
|
132
136
|
}
|
|
133
137
|
break;
|
|
134
138
|
default:
|
|
135
|
-
AccessibilityInfo.announceForAccessibility(nativeEvent.key);
|
|
139
|
+
AccessibilityInfo.announceForAccessibility(e.nativeEvent.key);
|
|
136
140
|
break;
|
|
137
141
|
}
|
|
138
142
|
};
|
|
@@ -147,21 +151,20 @@ export const OTPInput = forwardRef<View, Props>(
|
|
|
147
151
|
setHasFocus(true);
|
|
148
152
|
}}
|
|
149
153
|
ref={ref}
|
|
150
|
-
|
|
151
|
-
flexDirection: "row",
|
|
152
|
-
justifyContent: "space-between",
|
|
153
|
-
columnGap: OTP_ITEMS_GAP
|
|
154
|
-
}}
|
|
155
|
-
accessible={true}
|
|
156
|
-
accessibilityLabel={accessibilityLabel}
|
|
157
|
-
accessibilityHint={accessibilityHint}
|
|
158
|
-
accessibilityValue={{ text: value }}
|
|
154
|
+
accessible={false}
|
|
159
155
|
>
|
|
160
156
|
<TextInput
|
|
161
157
|
value={value}
|
|
162
158
|
onChangeText={handleChange}
|
|
163
159
|
onKeyPress={handleKeyPress}
|
|
164
|
-
|
|
160
|
+
caretHidden={Platform.OS === "ios"}
|
|
161
|
+
style={[
|
|
162
|
+
StyleSheet.absoluteFillObject,
|
|
163
|
+
Platform.select({
|
|
164
|
+
ios: { opacity: 0.01 },
|
|
165
|
+
android: { opacity: 0 }
|
|
166
|
+
})
|
|
167
|
+
]}
|
|
165
168
|
maxLength={length}
|
|
166
169
|
ref={inputRef}
|
|
167
170
|
onBlur={() => setHasFocus(false)}
|
|
@@ -172,23 +175,45 @@ export const OTPInput = forwardRef<View, Props>(
|
|
|
172
175
|
autoComplete={autocomplete ? "sms-otp" : undefined}
|
|
173
176
|
inputAccessoryViewID={inputAccessoryViewID}
|
|
174
177
|
accessible={true}
|
|
178
|
+
accessibilityLabel={accessibilityLabel}
|
|
179
|
+
accessibilityHint={accessibilityHint}
|
|
180
|
+
// Ensure the screen reader pronounces the code digit by digit
|
|
181
|
+
accessibilityValue={{
|
|
182
|
+
text:
|
|
183
|
+
accessibilityValueText?.({
|
|
184
|
+
valueLength: value.length,
|
|
185
|
+
length
|
|
186
|
+
}) ?? value.split("").join(" ")
|
|
187
|
+
}}
|
|
175
188
|
autoFocus={autoFocus}
|
|
176
|
-
secureTextEntry={
|
|
189
|
+
secureTextEntry={secret}
|
|
177
190
|
/>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
<View
|
|
192
|
+
style={{
|
|
193
|
+
flexDirection: "row",
|
|
194
|
+
justifyContent: "space-between",
|
|
195
|
+
columnGap: OTP_ITEMS_GAP,
|
|
196
|
+
flexGrow: 1,
|
|
197
|
+
zIndex: 10
|
|
198
|
+
}}
|
|
199
|
+
accessibilityElementsHidden={true}
|
|
200
|
+
importantForAccessibility="no-hide-descendants"
|
|
201
|
+
>
|
|
202
|
+
{cells.map((_, i) => (
|
|
203
|
+
<BoxedInput
|
|
204
|
+
key={i}
|
|
205
|
+
status={
|
|
206
|
+
hasError
|
|
207
|
+
? "error"
|
|
208
|
+
: hasFocus && value.length === i
|
|
209
|
+
? "focus"
|
|
210
|
+
: "default"
|
|
211
|
+
}
|
|
212
|
+
secret={secret}
|
|
213
|
+
value={value[i]}
|
|
214
|
+
/>
|
|
215
|
+
))}
|
|
216
|
+
</View>
|
|
192
217
|
</Pressable>
|
|
193
218
|
<VSpacer size={4} />
|
|
194
219
|
{hasError && errorMessage && (
|
|
@@ -77,6 +77,7 @@ const styles = StyleSheet.create({
|
|
|
77
77
|
textAlignVertical: "center"
|
|
78
78
|
}
|
|
79
79
|
}),
|
|
80
|
+
overflow: "hidden",
|
|
80
81
|
borderWidth: 1,
|
|
81
82
|
borderCurve: "continuous"
|
|
82
83
|
},
|
|
@@ -88,7 +89,7 @@ const styles = StyleSheet.create({
|
|
|
88
89
|
columnGap: IOTagIconMargin
|
|
89
90
|
},
|
|
90
91
|
iconWrapper: {
|
|
91
|
-
flexShrink:
|
|
92
|
+
flexShrink: 0
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { throttle } from "lodash";
|
|
2
1
|
import { ReactNode, useCallback, useMemo, useRef, useState } from "react";
|
|
3
2
|
import { AccessibilityInfo, StyleSheet, View } from "react-native";
|
|
4
3
|
import Animated, {
|
|
@@ -10,6 +9,7 @@ import Animated, {
|
|
|
10
9
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
11
10
|
import { IOVisualCostants } from "../../core";
|
|
12
11
|
import { triggerHaptic } from "../../functions";
|
|
12
|
+
import { throttle } from "../../utils/throttle";
|
|
13
13
|
import { Dismissable } from "../templates";
|
|
14
14
|
import { ToastNotification } from "./ToastNotification";
|
|
15
15
|
import { ToastContext } from "./context";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { every, some } from "lodash";
|
|
2
1
|
import {
|
|
3
2
|
JSXElementConstructor,
|
|
4
3
|
PropsWithChildren,
|
|
@@ -194,8 +193,10 @@ export const Tooltip = ({
|
|
|
194
193
|
() => ARROWS_BY_PLACEMENT[currentPlacement],
|
|
195
194
|
[currentPlacement]
|
|
196
195
|
);
|
|
196
|
+
const childrenCoordsValues = Object.values(childrenCoords);
|
|
197
197
|
const isChildrenMeasurementFinished =
|
|
198
|
-
every(
|
|
198
|
+
childrenCoordsValues.every(isDefined) &&
|
|
199
|
+
childrenCoordsValues.some(isNotZero);
|
|
199
200
|
const isTooltipMeasurementCompleted = isDefined(tooltipLayout);
|
|
200
201
|
const tooltipVisibility = { opacity: isTooltipMeasurementCompleted ? 1 : 0 };
|
|
201
202
|
|
|
@@ -211,7 +212,7 @@ export const Tooltip = ({
|
|
|
211
212
|
width,
|
|
212
213
|
height
|
|
213
214
|
};
|
|
214
|
-
if (every(
|
|
215
|
+
if (Object.values(coords).every(isDefined)) {
|
|
215
216
|
setChildrenCoords(coords);
|
|
216
217
|
}
|
|
217
218
|
});
|
|
@@ -13,6 +13,9 @@ type BodySmallProps = TypographicStyleProps & {
|
|
|
13
13
|
weight?: Extract<IOFontWeight, "Regular" | "Semibold">;
|
|
14
14
|
} & TypographicStyleAsLinkProps;
|
|
15
15
|
|
|
16
|
+
export const bodySmallFontSize = 14;
|
|
17
|
+
export const bodySmallLineHeight = 21;
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* `BodySmall` typographic style
|
|
18
21
|
*/
|
|
@@ -40,8 +43,8 @@ export const BodySmall = forwardRef<View, BodySmallProps>(
|
|
|
40
43
|
...props,
|
|
41
44
|
dynamicTypeRamp: "footnote" /* iOS only */,
|
|
42
45
|
weight: customWeight ?? "Regular",
|
|
43
|
-
size:
|
|
44
|
-
lineHeight:
|
|
46
|
+
size: bodySmallFontSize,
|
|
47
|
+
lineHeight: bodySmallLineHeight,
|
|
45
48
|
color: customColor ?? defaultColor,
|
|
46
49
|
...(asLink
|
|
47
50
|
? {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
View
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import Animated from "react-native-reanimated";
|
|
11
|
-
import { useIONewTypeface
|
|
11
|
+
import { useIONewTypeface } from "../../context";
|
|
12
12
|
import { IOColors } from "../../core";
|
|
13
13
|
import { useBoldTextEnabled } from "../../utils/accessibility";
|
|
14
14
|
import {
|
|
@@ -74,11 +74,11 @@ export type TypographicStyleAsLinkProps =
|
|
|
74
74
|
* @param args the args of the function {@link makeFontStyleObject}
|
|
75
75
|
*/
|
|
76
76
|
const calculateTextStyle = (
|
|
77
|
-
color
|
|
77
|
+
color?: IOColors,
|
|
78
78
|
...args: Parameters<typeof makeFontStyleObject>
|
|
79
79
|
) => ({
|
|
80
80
|
...makeFontStyleObject(...args),
|
|
81
|
-
color: IOColors[color]
|
|
81
|
+
color: color ? IOColors[color] : undefined
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -106,7 +106,6 @@ export const IOText = forwardRef<View, IOTextProps>(
|
|
|
106
106
|
},
|
|
107
107
|
ref
|
|
108
108
|
) => {
|
|
109
|
-
const theme = useIOTheme();
|
|
110
109
|
const boldEnabled = useBoldTextEnabled();
|
|
111
110
|
const { newTypefaceEnabled } = useIONewTypeface();
|
|
112
111
|
|
|
@@ -116,7 +115,7 @@ export const IOText = forwardRef<View, IOTextProps>(
|
|
|
116
115
|
const computedStyleObj = useMemo(
|
|
117
116
|
() =>
|
|
118
117
|
calculateTextStyle(
|
|
119
|
-
color
|
|
118
|
+
color,
|
|
120
119
|
size,
|
|
121
120
|
computedFont,
|
|
122
121
|
lineHeight,
|
|
@@ -124,16 +123,7 @@ export const IOText = forwardRef<View, IOTextProps>(
|
|
|
124
123
|
fontStyle,
|
|
125
124
|
boldEnabled
|
|
126
125
|
),
|
|
127
|
-
[
|
|
128
|
-
color,
|
|
129
|
-
theme,
|
|
130
|
-
size,
|
|
131
|
-
computedFont,
|
|
132
|
-
lineHeight,
|
|
133
|
-
weight,
|
|
134
|
-
fontStyle,
|
|
135
|
-
boldEnabled
|
|
136
|
-
]
|
|
126
|
+
[color, size, computedFont, lineHeight, weight, fontStyle, boldEnabled]
|
|
137
127
|
);
|
|
138
128
|
|
|
139
129
|
/* In some cases, for example when we use color transitions with
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chains functions together, passing the result of each function as input to the next.
|
|
3
|
+
* The first argument is the initial value, followed by any number of transformation functions.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const addOne = (x: number) => x + 1;
|
|
8
|
+
* const double = (x: number) => x * 2;
|
|
9
|
+
* const stringify = (x: number) => `Result: ${x}`;
|
|
10
|
+
*
|
|
11
|
+
* const result = pipe(
|
|
12
|
+
* 10,
|
|
13
|
+
* addOne, // 11
|
|
14
|
+
* double, // 22
|
|
15
|
+
* stringify // "Result: 22"
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function pipe<T>(value: T): T;
|
|
20
|
+
export function pipe<T, R1>(value: T, fn1: (arg: T) => R1): R1;
|
|
21
|
+
export function pipe<T, R1, R2>(
|
|
22
|
+
value: T,
|
|
23
|
+
fn1: (arg: T) => R1,
|
|
24
|
+
fn2: (arg: R1) => R2
|
|
25
|
+
): R2;
|
|
26
|
+
export function pipe<T, R1, R2, R3>(
|
|
27
|
+
value: T,
|
|
28
|
+
fn1: (arg: T) => R1,
|
|
29
|
+
fn2: (arg: R1) => R2,
|
|
30
|
+
fn3: (arg: R2) => R3
|
|
31
|
+
): R3;
|
|
32
|
+
export function pipe<T, R1, R2, R3, R4>(
|
|
33
|
+
value: T,
|
|
34
|
+
fn1: (arg: T) => R1,
|
|
35
|
+
fn2: (arg: R1) => R2,
|
|
36
|
+
fn3: (arg: R2) => R3,
|
|
37
|
+
fn4: (arg: R3) => R4
|
|
38
|
+
): R4;
|
|
39
|
+
export function pipe<T, R1, R2, R3, R4, R5>(
|
|
40
|
+
value: T,
|
|
41
|
+
fn1: (arg: T) => R1,
|
|
42
|
+
fn2: (arg: R1) => R2,
|
|
43
|
+
fn3: (arg: R2) => R3,
|
|
44
|
+
fn4: (arg: R3) => R4,
|
|
45
|
+
fn5: (arg: R4) => R5
|
|
46
|
+
): R5;
|
|
47
|
+
export function pipe(
|
|
48
|
+
initialValue: any,
|
|
49
|
+
...transformers: Array<(arg: any) => any>
|
|
50
|
+
): any {
|
|
51
|
+
return transformers.reduce(
|
|
52
|
+
(currentValue, transformer) => transformer(currentValue),
|
|
53
|
+
initialValue
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const throttle = <T extends Array<unknown>>(
|
|
2
|
+
fn: (...args: T) => void,
|
|
3
|
+
ms: number
|
|
4
|
+
) => {
|
|
5
|
+
// eslint-disable-next-line functional/no-let
|
|
6
|
+
let lastCall = 0;
|
|
7
|
+
return (...args: T) => {
|
|
8
|
+
const now = Date.now();
|
|
9
|
+
|
|
10
|
+
if (now - lastCall >= ms) {
|
|
11
|
+
lastCall = now;
|
|
12
|
+
fn(...args);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
};
|