@pagopa/io-app-design-system 5.0.0-5 → 5.0.0-6
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/banner/Banner.js +3 -2
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +56 -0
- package/lib/commonjs/components/layout/HeaderFirstLevel.js +1 -1
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/commonjs/components/layout/HeaderSecondLevel.js +3 -2
- package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -198
- package/lib/commonjs/components/listitems/__test__/listitem.test.js +0 -9
- package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleIDP.js +26 -5
- package/lib/commonjs/components/modules/ModuleIDP.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +62 -63
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +2 -2
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +13 -3
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/module/components/banner/Banner.js +3 -2
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +56 -0
- package/lib/module/components/layout/HeaderFirstLevel.js +1 -1
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/module/components/layout/HeaderSecondLevel.js +3 -2
- package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -198
- package/lib/module/components/listitems/__test__/listitem.test.js +0 -9
- package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/module/components/modules/ModuleIDP.js +27 -6
- package/lib/module/components/modules/ModuleIDP.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +65 -67
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +2 -2
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/core/IOColors.js +13 -3
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts +2 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleIDP.d.ts +10 -3
- package/lib/typescript/components/modules/ModuleIDP.d.ts.map +1 -1
- package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +1 -1
- package/lib/typescript/components/typography/H1.d.ts +1 -1
- package/lib/typescript/components/typography/H2.d.ts +1 -1
- package/lib/typescript/components/typography/H3.d.ts +1 -1
- package/lib/typescript/components/typography/H4.d.ts +1 -1
- package/lib/typescript/components/typography/H5.d.ts +1 -1
- package/lib/typescript/components/typography/H6.d.ts +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
- package/lib/typescript/core/IOColors.d.ts +1 -3
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/banner/Banner.tsx +3 -2
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +56 -0
- package/src/components/layout/HeaderFirstLevel.tsx +7 -11
- package/src/components/layout/HeaderSecondLevel.tsx +8 -2
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -198
- package/src/components/listitems/__test__/listitem.test.tsx +0 -13
- package/src/components/modules/ModuleIDP.tsx +43 -8
- package/src/components/tabs/TabItem.tsx +116 -108
- package/src/components/textInput/TextInputValidation.tsx +2 -2
- package/src/core/IOColors.ts +17 -3
|
@@ -78,6 +78,9 @@ type CommonProps = WithTestID<{
|
|
|
78
78
|
variant?: "neutral" | "contrast";
|
|
79
79
|
backgroundColor?: string;
|
|
80
80
|
ignoreSafeAreaMargin?: boolean;
|
|
81
|
+
// Prevents screen readers from focusing on the title when other elements are focused
|
|
82
|
+
// (e.g. when an input text is throwing an error)
|
|
83
|
+
ignoreAccessibilityCheck?: boolean;
|
|
81
84
|
}>;
|
|
82
85
|
|
|
83
86
|
interface Base extends CommonProps {
|
|
@@ -151,7 +154,8 @@ export const HeaderSecondLevel = ({
|
|
|
151
154
|
testID,
|
|
152
155
|
firstAction,
|
|
153
156
|
secondAction,
|
|
154
|
-
thirdAction
|
|
157
|
+
thirdAction,
|
|
158
|
+
ignoreAccessibilityCheck = false
|
|
155
159
|
}: HeaderSecondLevel) => {
|
|
156
160
|
const scrollOffset = useScrollViewOffset(
|
|
157
161
|
(animatedRef as AnimatedRef<Animated.ScrollView>) ||
|
|
@@ -300,7 +304,9 @@ export const HeaderSecondLevel = ({
|
|
|
300
304
|
ref={titleRef}
|
|
301
305
|
accessibilityElementsHidden={!isTitleAccessible}
|
|
302
306
|
importantForAccessibility={
|
|
303
|
-
isTitleAccessible
|
|
307
|
+
isTitleAccessible && !ignoreAccessibilityCheck
|
|
308
|
+
? "yes"
|
|
309
|
+
: "no-hide-descendants"
|
|
304
310
|
}
|
|
305
311
|
accessible={isTitleAccessible}
|
|
306
312
|
accessibilityLabel={title}
|
|
@@ -105,105 +105,6 @@ exports[`Test List Item Components - Experimental Enabled ListItemAction Snapsh
|
|
|
105
105
|
</View>
|
|
106
106
|
`;
|
|
107
107
|
|
|
108
|
-
exports[`Test List Item Components - Experimental Enabled ListItemIDP Snapshot 1`] = `
|
|
109
|
-
<View
|
|
110
|
-
accessibilityRole="button"
|
|
111
|
-
accessibilityState={
|
|
112
|
-
{
|
|
113
|
-
"busy": undefined,
|
|
114
|
-
"checked": undefined,
|
|
115
|
-
"disabled": undefined,
|
|
116
|
-
"expanded": undefined,
|
|
117
|
-
"selected": undefined,
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
accessibilityValue={
|
|
121
|
-
{
|
|
122
|
-
"max": undefined,
|
|
123
|
-
"min": undefined,
|
|
124
|
-
"now": undefined,
|
|
125
|
-
"text": undefined,
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
accessible={true}
|
|
129
|
-
collapsable={false}
|
|
130
|
-
focusable={true}
|
|
131
|
-
onBlur={[Function]}
|
|
132
|
-
onClick={[Function]}
|
|
133
|
-
onFocus={[Function]}
|
|
134
|
-
onResponderGrant={[Function]}
|
|
135
|
-
onResponderMove={[Function]}
|
|
136
|
-
onResponderRelease={[Function]}
|
|
137
|
-
onResponderTerminate={[Function]}
|
|
138
|
-
onResponderTerminationRequest={[Function]}
|
|
139
|
-
onStartShouldSetResponder={[Function]}
|
|
140
|
-
onTouchEnd={[Function]}
|
|
141
|
-
>
|
|
142
|
-
<View
|
|
143
|
-
style={
|
|
144
|
-
[
|
|
145
|
-
{
|
|
146
|
-
"alignItems": "center",
|
|
147
|
-
"borderColor": "#E8EBF1",
|
|
148
|
-
"borderCurve": "continuous",
|
|
149
|
-
"borderRadius": 8,
|
|
150
|
-
"borderWidth": 1,
|
|
151
|
-
"flexDirection": "row",
|
|
152
|
-
"justifyContent": "space-between",
|
|
153
|
-
"paddingHorizontal": 16,
|
|
154
|
-
"paddingVertical": 16,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"borderColor": "#E8EBF1",
|
|
158
|
-
},
|
|
159
|
-
false,
|
|
160
|
-
{
|
|
161
|
-
"transform": [
|
|
162
|
-
{
|
|
163
|
-
"scale": undefined,
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
>
|
|
170
|
-
<Text
|
|
171
|
-
allowFontScaling={true}
|
|
172
|
-
maxFontSizeMultiplier={1.5}
|
|
173
|
-
style={
|
|
174
|
-
[
|
|
175
|
-
{
|
|
176
|
-
"alignSelf": "center",
|
|
177
|
-
"flexShrink": 1,
|
|
178
|
-
"letterSpacing": 0.5,
|
|
179
|
-
"textTransform": "uppercase",
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"color": "#555C70",
|
|
183
|
-
"fontFamily": "Titillio",
|
|
184
|
-
"fontSize": 12,
|
|
185
|
-
"fontStyle": "normal",
|
|
186
|
-
"fontWeight": "600",
|
|
187
|
-
"lineHeight": 16,
|
|
188
|
-
},
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
/>
|
|
192
|
-
<Image
|
|
193
|
-
accessibilityIgnoresInvertColors={true}
|
|
194
|
-
style={
|
|
195
|
-
{
|
|
196
|
-
"height": 30,
|
|
197
|
-
"marginStart": 8,
|
|
198
|
-
"resizeMode": "contain",
|
|
199
|
-
"width": 120,
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/>
|
|
203
|
-
</View>
|
|
204
|
-
</View>
|
|
205
|
-
`;
|
|
206
|
-
|
|
207
108
|
exports[`Test List Item Components - Experimental Enabled ListItemInfo Snapshot 1`] = `
|
|
208
109
|
<View
|
|
209
110
|
accessibilityLabel="accessibilityLabel"
|
|
@@ -1775,105 +1676,6 @@ exports[`Test List Item Components ListItemAction Snapshot 1`] = `
|
|
|
1775
1676
|
</View>
|
|
1776
1677
|
`;
|
|
1777
1678
|
|
|
1778
|
-
exports[`Test List Item Components ListItemIDP Snapshot 1`] = `
|
|
1779
|
-
<View
|
|
1780
|
-
accessibilityRole="button"
|
|
1781
|
-
accessibilityState={
|
|
1782
|
-
{
|
|
1783
|
-
"busy": undefined,
|
|
1784
|
-
"checked": undefined,
|
|
1785
|
-
"disabled": undefined,
|
|
1786
|
-
"expanded": undefined,
|
|
1787
|
-
"selected": undefined,
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
accessibilityValue={
|
|
1791
|
-
{
|
|
1792
|
-
"max": undefined,
|
|
1793
|
-
"min": undefined,
|
|
1794
|
-
"now": undefined,
|
|
1795
|
-
"text": undefined,
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
accessible={true}
|
|
1799
|
-
collapsable={false}
|
|
1800
|
-
focusable={true}
|
|
1801
|
-
onBlur={[Function]}
|
|
1802
|
-
onClick={[Function]}
|
|
1803
|
-
onFocus={[Function]}
|
|
1804
|
-
onResponderGrant={[Function]}
|
|
1805
|
-
onResponderMove={[Function]}
|
|
1806
|
-
onResponderRelease={[Function]}
|
|
1807
|
-
onResponderTerminate={[Function]}
|
|
1808
|
-
onResponderTerminationRequest={[Function]}
|
|
1809
|
-
onStartShouldSetResponder={[Function]}
|
|
1810
|
-
onTouchEnd={[Function]}
|
|
1811
|
-
>
|
|
1812
|
-
<View
|
|
1813
|
-
style={
|
|
1814
|
-
[
|
|
1815
|
-
{
|
|
1816
|
-
"alignItems": "center",
|
|
1817
|
-
"borderColor": "#E8EBF1",
|
|
1818
|
-
"borderCurve": "continuous",
|
|
1819
|
-
"borderRadius": 8,
|
|
1820
|
-
"borderWidth": 1,
|
|
1821
|
-
"flexDirection": "row",
|
|
1822
|
-
"justifyContent": "space-between",
|
|
1823
|
-
"paddingHorizontal": 16,
|
|
1824
|
-
"paddingVertical": 16,
|
|
1825
|
-
},
|
|
1826
|
-
{
|
|
1827
|
-
"borderColor": "#E8EBF1",
|
|
1828
|
-
},
|
|
1829
|
-
false,
|
|
1830
|
-
{
|
|
1831
|
-
"transform": [
|
|
1832
|
-
{
|
|
1833
|
-
"scale": undefined,
|
|
1834
|
-
},
|
|
1835
|
-
],
|
|
1836
|
-
},
|
|
1837
|
-
]
|
|
1838
|
-
}
|
|
1839
|
-
>
|
|
1840
|
-
<Text
|
|
1841
|
-
allowFontScaling={true}
|
|
1842
|
-
maxFontSizeMultiplier={1.5}
|
|
1843
|
-
style={
|
|
1844
|
-
[
|
|
1845
|
-
{
|
|
1846
|
-
"alignSelf": "center",
|
|
1847
|
-
"flexShrink": 1,
|
|
1848
|
-
"letterSpacing": 0.5,
|
|
1849
|
-
"textTransform": "uppercase",
|
|
1850
|
-
},
|
|
1851
|
-
{
|
|
1852
|
-
"color": "#555C70",
|
|
1853
|
-
"fontFamily": "Titillio",
|
|
1854
|
-
"fontSize": 12,
|
|
1855
|
-
"fontStyle": "normal",
|
|
1856
|
-
"fontWeight": "600",
|
|
1857
|
-
"lineHeight": 16,
|
|
1858
|
-
},
|
|
1859
|
-
]
|
|
1860
|
-
}
|
|
1861
|
-
/>
|
|
1862
|
-
<Image
|
|
1863
|
-
accessibilityIgnoresInvertColors={true}
|
|
1864
|
-
style={
|
|
1865
|
-
{
|
|
1866
|
-
"height": 30,
|
|
1867
|
-
"marginStart": 8,
|
|
1868
|
-
"resizeMode": "contain",
|
|
1869
|
-
"width": 120,
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
/>
|
|
1873
|
-
</View>
|
|
1874
|
-
</View>
|
|
1875
|
-
`;
|
|
1876
|
-
|
|
1877
1679
|
exports[`Test List Item Components ListItemInfo Snapshot 1`] = `
|
|
1878
1680
|
<View
|
|
1879
1681
|
accessibilityLabel="accessibilityLabel"
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import { Alert } from "react-native";
|
|
3
3
|
import * as TestRenderer from "react-test-renderer";
|
|
4
4
|
import { TestRendererWithExperimentalEnabledContextProvider } from "../../../utils/testing";
|
|
5
|
-
import ListItemIDP from "../../modules/ModuleIDP";
|
|
6
5
|
import ListItemAction from "../ListItemAction";
|
|
7
6
|
import ListItemInfo from "../ListItemInfo";
|
|
8
7
|
import ListItemInfoCopy from "../ListItemInfoCopy";
|
|
@@ -69,12 +68,6 @@ describe("Test List Item Components", () => {
|
|
|
69
68
|
).toJSON();
|
|
70
69
|
expect(listItemAction).toMatchSnapshot();
|
|
71
70
|
});
|
|
72
|
-
it("ListItemIDP Snapshot", () => {
|
|
73
|
-
const listItemIDP = TestRenderer.create(
|
|
74
|
-
<ListItemIDP></ListItemIDP>
|
|
75
|
-
).toJSON();
|
|
76
|
-
expect(listItemIDP).toMatchSnapshot();
|
|
77
|
-
});
|
|
78
71
|
it("ListItemTransaction Snapshot", () => {
|
|
79
72
|
const listItemIDP = TestRenderer.create(
|
|
80
73
|
<ListItemTransaction
|
|
@@ -171,12 +164,6 @@ describe("Test List Item Components - Experimental Enabled ", () => {
|
|
|
171
164
|
).toJSON();
|
|
172
165
|
expect(listItemAction).toMatchSnapshot();
|
|
173
166
|
});
|
|
174
|
-
it("ListItemIDP Snapshot", () => {
|
|
175
|
-
const listItemIDP = TestRendererWithExperimentalEnabledContextProvider(
|
|
176
|
-
<ListItemIDP></ListItemIDP>
|
|
177
|
-
).toJSON();
|
|
178
|
-
expect(listItemIDP).toMatchSnapshot();
|
|
179
|
-
});
|
|
180
167
|
it("ListItemTransaction Snapshot", () => {
|
|
181
168
|
const listItemIDP = TestRendererWithExperimentalEnabledContextProvider(
|
|
182
169
|
<ListItemTransaction
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Image, ImageSourcePropType, StyleSheet } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IOListItemLogoMargin,
|
|
5
|
+
useIONewTypeface,
|
|
6
|
+
useIOTheme,
|
|
7
|
+
useIOThemeContext
|
|
8
|
+
} from "../../core";
|
|
4
9
|
import { addCacheTimestampToUri } from "../../utils/image";
|
|
5
10
|
import { IOText } from "../typography";
|
|
6
11
|
import {
|
|
@@ -8,10 +13,18 @@ import {
|
|
|
8
13
|
PressableModuleBaseProps
|
|
9
14
|
} from "./PressableModuleBase";
|
|
10
15
|
|
|
16
|
+
type IDPLogoSource = {
|
|
17
|
+
local: ImageSourcePropType;
|
|
18
|
+
url: ImageSourcePropType;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type IDPLogoColorMode = {
|
|
22
|
+
light: IDPLogoSource;
|
|
23
|
+
dark?: IDPLogoSource;
|
|
24
|
+
};
|
|
11
25
|
interface ModuleIDP extends PressableModuleBaseProps {
|
|
12
26
|
name: string;
|
|
13
|
-
|
|
14
|
-
logo: ImageSourcePropType;
|
|
27
|
+
logo: IDPLogoColorMode;
|
|
15
28
|
accessibilityLabel?: string;
|
|
16
29
|
}
|
|
17
30
|
|
|
@@ -24,19 +37,41 @@ const styles = StyleSheet.create({
|
|
|
24
37
|
}
|
|
25
38
|
});
|
|
26
39
|
|
|
40
|
+
const useIDPLogo = (logo: IDPLogoColorMode): ImageSourcePropType => {
|
|
41
|
+
const { themeType } = useIOThemeContext();
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
light: { url: urlLogoLightMode, local: localLogoLightMode }
|
|
45
|
+
} = logo;
|
|
46
|
+
|
|
47
|
+
const logoIDPLightMode =
|
|
48
|
+
localLogoLightMode ?? addCacheTimestampToUri(urlLogoLightMode);
|
|
49
|
+
|
|
50
|
+
if (!logo.dark) {
|
|
51
|
+
return logoIDPLightMode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
dark: { url: urlLogoDarkMode, local: localLogoDarkMode }
|
|
56
|
+
} = logo;
|
|
57
|
+
|
|
58
|
+
const logoIDPDarkMode =
|
|
59
|
+
localLogoDarkMode ?? addCacheTimestampToUri(urlLogoDarkMode);
|
|
60
|
+
|
|
61
|
+
return themeType === "dark" ? logoIDPDarkMode : logoIDPLightMode;
|
|
62
|
+
};
|
|
63
|
+
|
|
27
64
|
export const ModuleIDP = ({
|
|
28
65
|
name,
|
|
29
|
-
localLogo,
|
|
30
66
|
logo,
|
|
31
67
|
withLooseSpacing = false,
|
|
32
68
|
onPress,
|
|
33
69
|
testID,
|
|
34
70
|
accessibilityLabel
|
|
35
71
|
}: ModuleIDP) => {
|
|
36
|
-
const theme = useIOTheme();
|
|
37
72
|
const { newTypefaceEnabled } = useIONewTypeface();
|
|
38
|
-
|
|
39
|
-
const
|
|
73
|
+
const theme = useIOTheme();
|
|
74
|
+
const IDPLogoSource = useIDPLogo(logo);
|
|
40
75
|
|
|
41
76
|
return (
|
|
42
77
|
<PressableModuleBase
|
|
@@ -62,7 +97,7 @@ export const ModuleIDP = ({
|
|
|
62
97
|
</IOText>
|
|
63
98
|
<Image
|
|
64
99
|
accessibilityIgnoresInvertColors
|
|
65
|
-
source={
|
|
100
|
+
source={IDPLogoSource}
|
|
66
101
|
style={styles.idpLogo}
|
|
67
102
|
/>
|
|
68
103
|
</PressableModuleBase>
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useMemo } from "react";
|
|
2
2
|
import { GestureResponderEvent, Pressable, StyleSheet } from "react-native";
|
|
3
|
+
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
3
4
|
import Animated, {
|
|
4
|
-
SharedValue,
|
|
5
5
|
interpolateColor,
|
|
6
6
|
useAnimatedStyle,
|
|
7
7
|
useDerivedValue,
|
|
8
8
|
useReducedMotion,
|
|
9
|
-
useSharedValue,
|
|
10
9
|
withSpring
|
|
11
10
|
} from "react-native-reanimated";
|
|
12
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
IOColors,
|
|
13
|
+
IOSpringValues,
|
|
14
|
+
hexToRgba,
|
|
15
|
+
useIONewTypeface,
|
|
16
|
+
useIOTheme
|
|
17
|
+
} from "../../core";
|
|
13
18
|
import { useScaleAnimation } from "../../hooks";
|
|
14
19
|
import { WithTestID } from "../../utils/types";
|
|
15
20
|
import { IOIcons, Icon } from "../icons";
|
|
16
|
-
import {
|
|
21
|
+
import { IOText } from "../typography";
|
|
17
22
|
|
|
18
23
|
type ColorMode = "light" | "dark";
|
|
19
24
|
|
|
25
|
+
type TabItemState = "default" | "selected" | "disabled";
|
|
26
|
+
|
|
20
27
|
export type TabItem = WithTestID<{
|
|
21
28
|
label: string;
|
|
22
29
|
color?: ColorMode;
|
|
@@ -37,12 +44,10 @@ type ColorStates = {
|
|
|
37
44
|
border: {
|
|
38
45
|
default: string;
|
|
39
46
|
selected: string;
|
|
40
|
-
disabled: string;
|
|
41
47
|
};
|
|
42
48
|
background: {
|
|
43
49
|
default: string;
|
|
44
50
|
selected: string;
|
|
45
|
-
pressed: string;
|
|
46
51
|
};
|
|
47
52
|
foreground: {
|
|
48
53
|
default: IOColors;
|
|
@@ -51,42 +56,7 @@ type ColorStates = {
|
|
|
51
56
|
};
|
|
52
57
|
};
|
|
53
58
|
|
|
54
|
-
const
|
|
55
|
-
light: {
|
|
56
|
-
border: {
|
|
57
|
-
default: IOColors["grey-300"],
|
|
58
|
-
selected: IOColors["blueIO-500"],
|
|
59
|
-
disabled: IOColors["grey-300"]
|
|
60
|
-
},
|
|
61
|
-
background: {
|
|
62
|
-
default: IOColors.white,
|
|
63
|
-
selected: IOColors["blueIO-50"],
|
|
64
|
-
pressed: IOColors.white
|
|
65
|
-
},
|
|
66
|
-
foreground: {
|
|
67
|
-
default: "black",
|
|
68
|
-
selected: "blueIO-500",
|
|
69
|
-
disabled: "grey-700"
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
dark: {
|
|
73
|
-
border: {
|
|
74
|
-
default: hexToRgba(IOColors.white, 0),
|
|
75
|
-
selected: IOColors.white,
|
|
76
|
-
disabled: hexToRgba(IOColors.white, 0.5)
|
|
77
|
-
},
|
|
78
|
-
background: {
|
|
79
|
-
default: hexToRgba(IOColors.white, 0),
|
|
80
|
-
selected: IOColors.white,
|
|
81
|
-
pressed: IOColors.white
|
|
82
|
-
},
|
|
83
|
-
foreground: {
|
|
84
|
-
default: "white",
|
|
85
|
-
selected: "black",
|
|
86
|
-
disabled: "white"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
59
|
+
const DISABLED_OPACITY = 0.5;
|
|
90
60
|
|
|
91
61
|
const TabItem = ({
|
|
92
62
|
label,
|
|
@@ -101,75 +71,109 @@ const TabItem = ({
|
|
|
101
71
|
icon,
|
|
102
72
|
iconSelected
|
|
103
73
|
}: TabItem) => {
|
|
104
|
-
const {
|
|
105
|
-
useScaleAnimation();
|
|
74
|
+
const { onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
75
|
+
useScaleAnimation("medium");
|
|
76
|
+
const theme = useIOTheme();
|
|
106
77
|
const reducedMotion = useReducedMotion();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
78
|
+
const { newTypefaceEnabled } = useIONewTypeface();
|
|
79
|
+
|
|
80
|
+
const mapColorStates: Record<
|
|
81
|
+
NonNullable<TabItem["color"]>,
|
|
82
|
+
ColorStates
|
|
83
|
+
> = useMemo(
|
|
84
|
+
() => ({
|
|
85
|
+
light: {
|
|
86
|
+
border: {
|
|
87
|
+
default: IOColors[theme["tab-item-border-default"]],
|
|
88
|
+
selected: hexToRgba(
|
|
89
|
+
IOColors[theme["tab-item-foreground-selected"]],
|
|
90
|
+
0.5
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
background: {
|
|
94
|
+
default: hexToRgba(
|
|
95
|
+
IOColors[theme["tab-item-background-selected"]],
|
|
96
|
+
0
|
|
97
|
+
),
|
|
98
|
+
selected: hexToRgba(
|
|
99
|
+
IOColors[theme["tab-item-background-selected"]],
|
|
100
|
+
0.25
|
|
101
|
+
),
|
|
102
|
+
pressed: IOColors[theme["appBackground-primary"]]
|
|
103
|
+
},
|
|
104
|
+
foreground: {
|
|
105
|
+
default: theme["tab-item-foreground-default"],
|
|
106
|
+
selected: theme["tab-item-foreground-selected"],
|
|
107
|
+
disabled: "grey-700"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
dark: {
|
|
111
|
+
border: {
|
|
112
|
+
default: hexToRgba(IOColors.white, 0),
|
|
113
|
+
selected: IOColors.white
|
|
114
|
+
},
|
|
115
|
+
background: {
|
|
116
|
+
default: hexToRgba(IOColors.white, 0.1),
|
|
117
|
+
selected: IOColors.white,
|
|
118
|
+
pressed: IOColors.white
|
|
119
|
+
},
|
|
120
|
+
foreground: {
|
|
121
|
+
default: "white",
|
|
122
|
+
selected: "black",
|
|
123
|
+
disabled: "white"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
[theme]
|
|
114
128
|
);
|
|
115
129
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
[color, selected, disabled]
|
|
122
|
-
);
|
|
130
|
+
const itemState: TabItemState = selected
|
|
131
|
+
? "selected"
|
|
132
|
+
: disabled
|
|
133
|
+
? "disabled"
|
|
134
|
+
: "default";
|
|
123
135
|
|
|
124
|
-
const
|
|
125
|
-
mapColorStates[color].background.pressed,
|
|
126
|
-
0.1
|
|
127
|
-
);
|
|
136
|
+
const foregroundColor = mapColorStates[color].foreground[itemState];
|
|
128
137
|
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
withSpring(isSelected.value, IOSpringValues.selection)
|
|
138
|
+
const selectedStateTransition = useDerivedValue(() =>
|
|
139
|
+
withSpring(selected ? 1 : 0, IOSpringValues.selection)
|
|
132
140
|
);
|
|
133
141
|
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
// eslint-disable-next-line functional/immutable-data
|
|
136
|
-
isSelected.value = selected ? 1 : 0;
|
|
137
|
-
}, [isSelected, selected]);
|
|
138
|
-
|
|
139
142
|
// Interpolate animation values from `pressed` values
|
|
140
|
-
const animatedStyle = useAnimatedStyle(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
backgroundColor: selected
|
|
165
|
-
? selectedBackgroundColor
|
|
166
|
-
: pressedBackgroundColor,
|
|
167
|
-
borderColor: selected ? selectedBorderColor : borderColor
|
|
168
|
-
};
|
|
169
|
-
}, [progress, progressSelected, selected]);
|
|
143
|
+
const animatedStyle = useAnimatedStyle(
|
|
144
|
+
() => ({
|
|
145
|
+
backgroundColor: interpolateColor(
|
|
146
|
+
selectedStateTransition.value,
|
|
147
|
+
[0, 1],
|
|
148
|
+
[
|
|
149
|
+
mapColorStates[color].background.default,
|
|
150
|
+
mapColorStates[color].background.selected
|
|
151
|
+
]
|
|
152
|
+
),
|
|
153
|
+
borderColor: interpolateColor(
|
|
154
|
+
selectedStateTransition.value,
|
|
155
|
+
[0, 1],
|
|
156
|
+
[
|
|
157
|
+
mapColorStates[color].border.default,
|
|
158
|
+
mapColorStates[color].border.selected
|
|
159
|
+
]
|
|
160
|
+
)
|
|
161
|
+
}),
|
|
162
|
+
[selectedStateTransition]
|
|
163
|
+
);
|
|
170
164
|
|
|
171
165
|
const activeIcon = selected ? iconSelected ?? icon : icon;
|
|
172
166
|
|
|
167
|
+
const handleOnPress = useCallback(
|
|
168
|
+
(event: GestureResponderEvent) => {
|
|
169
|
+
if (onPress) {
|
|
170
|
+
ReactNativeHapticFeedback.trigger("impactLight");
|
|
171
|
+
onPress(event);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
[onPress]
|
|
175
|
+
);
|
|
176
|
+
|
|
173
177
|
return (
|
|
174
178
|
<Pressable
|
|
175
179
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -177,7 +181,7 @@ const TabItem = ({
|
|
|
177
181
|
accessibilityRole={"button"}
|
|
178
182
|
accessibilityState={{ selected }}
|
|
179
183
|
testID={testID}
|
|
180
|
-
onPress={
|
|
184
|
+
onPress={handleOnPress}
|
|
181
185
|
onPressIn={onPressIn}
|
|
182
186
|
onPressOut={onPressOut}
|
|
183
187
|
accessible={true}
|
|
@@ -187,18 +191,23 @@ const TabItem = ({
|
|
|
187
191
|
style={[
|
|
188
192
|
styles.container,
|
|
189
193
|
{ columnGap: 4 },
|
|
190
|
-
!reducedMotion && scaleAnimatedStyle,
|
|
194
|
+
!disabled && !reducedMotion && scaleAnimatedStyle,
|
|
191
195
|
animatedStyle,
|
|
192
196
|
fullWidth && styles.fullWidth,
|
|
193
|
-
disabled &&
|
|
197
|
+
disabled && { opacity: DISABLED_OPACITY }
|
|
194
198
|
]}
|
|
195
199
|
>
|
|
196
200
|
{activeIcon && (
|
|
197
201
|
<Icon name={activeIcon} color={foregroundColor} size={16} />
|
|
198
202
|
)}
|
|
199
|
-
<
|
|
203
|
+
<IOText
|
|
204
|
+
size={14}
|
|
205
|
+
font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
|
|
206
|
+
weight="Semibold"
|
|
207
|
+
color={foregroundColor}
|
|
208
|
+
>
|
|
200
209
|
{label}
|
|
201
|
-
</
|
|
210
|
+
</IOText>
|
|
202
211
|
</Animated.View>
|
|
203
212
|
</Pressable>
|
|
204
213
|
);
|
|
@@ -218,8 +227,7 @@ const styles = StyleSheet.create({
|
|
|
218
227
|
},
|
|
219
228
|
fullWidth: {
|
|
220
229
|
alignSelf: "auto"
|
|
221
|
-
}
|
|
222
|
-
disabled: { opacity: 0.5 }
|
|
230
|
+
}
|
|
223
231
|
});
|
|
224
232
|
|
|
225
233
|
export { TabItem };
|
|
@@ -86,12 +86,12 @@ export const TextInputValidation = ({
|
|
|
86
86
|
}, [onFocus]);
|
|
87
87
|
|
|
88
88
|
const labelError = useMemo(
|
|
89
|
-
() => (
|
|
89
|
+
() => (isValid === false && errMessage ? errMessage : bottomMessage),
|
|
90
90
|
[isValid, errMessage, bottomMessage]
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
const labelErrorColor: IOColors | undefined = useMemo(
|
|
94
|
-
() => (
|
|
94
|
+
() => (isValid === false && errMessage ? theme.errorText : undefined),
|
|
95
95
|
[isValid, errMessage, theme.errorText]
|
|
96
96
|
);
|
|
97
97
|
|