@momo-kits/information 0.165.2-beta.2 → 0.167.1-beta.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/index.tsx +1 -41
- package/package.json +1 -1
- package/types.ts +0 -6
package/index.tsx
CHANGED
|
@@ -11,9 +11,6 @@ import {
|
|
|
11
11
|
Text,
|
|
12
12
|
} from '@momo-kits/foundation';
|
|
13
13
|
|
|
14
|
-
const isWordChar = (char?: string) =>
|
|
15
|
-
!!char && (char.toLowerCase() !== char.toUpperCase() || /[0-9_]/.test(char));
|
|
16
|
-
|
|
17
14
|
const Information: FC<InformationProps> = ({
|
|
18
15
|
title,
|
|
19
16
|
description = 'Description',
|
|
@@ -26,7 +23,6 @@ const Information: FC<InformationProps> = ({
|
|
|
26
23
|
showIconClose = true,
|
|
27
24
|
onPressClose,
|
|
28
25
|
accessibilityLabel,
|
|
29
|
-
highlightText,
|
|
30
26
|
}) => {
|
|
31
27
|
const app = useContext<any>(MiniAppContext);
|
|
32
28
|
const screen = useContext<any>(ScreenContext);
|
|
@@ -65,42 +61,6 @@ const Information: FC<InformationProps> = ({
|
|
|
65
61
|
|
|
66
62
|
const {backgroundColor, borderColor, color, iconSource} = getTypeStyle();
|
|
67
63
|
|
|
68
|
-
const renderDescription = () => {
|
|
69
|
-
const keywords = highlightText?.filter(
|
|
70
|
-
keyword => typeof keyword === 'string' && keyword,
|
|
71
|
-
);
|
|
72
|
-
if (!keywords?.length || typeof description !== 'string') {
|
|
73
|
-
return description;
|
|
74
|
-
}
|
|
75
|
-
const pattern = [...keywords]
|
|
76
|
-
.sort((a, b) => b.length - a.length)
|
|
77
|
-
.map(keyword => keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
78
|
-
.join('|');
|
|
79
|
-
const regex = new RegExp(pattern, 'g');
|
|
80
|
-
const parts: React.ReactNode[] = [];
|
|
81
|
-
let lastIndex = 0;
|
|
82
|
-
let match;
|
|
83
|
-
while ((match = regex.exec(description))) {
|
|
84
|
-
const start = match.index;
|
|
85
|
-
const end = start + match[0].length;
|
|
86
|
-
if (isWordChar(description[start - 1]) || isWordChar(description[end])) {
|
|
87
|
-
regex.lastIndex = start + 1;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (start > lastIndex) {
|
|
91
|
-
parts.push(description.slice(lastIndex, start));
|
|
92
|
-
}
|
|
93
|
-
parts.push(
|
|
94
|
-
<Text key={start} typography={'header_xs_semibold'}>
|
|
95
|
-
{match[0]}
|
|
96
|
-
</Text>,
|
|
97
|
-
);
|
|
98
|
-
lastIndex = end;
|
|
99
|
-
}
|
|
100
|
-
parts.push(description.slice(lastIndex));
|
|
101
|
-
return parts;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
64
|
return (
|
|
105
65
|
<View
|
|
106
66
|
style={[style, {backgroundColor, borderColor}, styles.container]}
|
|
@@ -133,7 +93,7 @@ const Information: FC<InformationProps> = ({
|
|
|
133
93
|
<Text
|
|
134
94
|
typography={'description_default_regular'}
|
|
135
95
|
accessibilityLabel={componentId + '|description-text'}>
|
|
136
|
-
{
|
|
96
|
+
{description}
|
|
137
97
|
</Text>
|
|
138
98
|
</View>
|
|
139
99
|
{showIconClose && (
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -18,12 +18,6 @@ export type InformationProps = {
|
|
|
18
18
|
*/
|
|
19
19
|
description: string;
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Optional. List of substrings within `description` to be rendered in semibold.
|
|
23
|
-
* Matching is case-sensitive; every occurrence of each string is highlighted.
|
|
24
|
-
*/
|
|
25
|
-
highlightText?: string[];
|
|
26
|
-
|
|
27
21
|
/**
|
|
28
22
|
* Optional. The text for the Call To Action (CTA) button. This is intended to prompt the user
|
|
29
23
|
* to take some specified action like "Retry", "Learn More", or "Dismiss".
|