@pagopa/io-app-design-system 4.4.8 → 4.5.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/lib/commonjs/components/Advice/Advice.js +1 -1
- package/lib/commonjs/components/accordion/RawAccordion.js +1 -1
- package/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +0 -4
- package/lib/commonjs/components/buttons/ButtonLink.js +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +24 -24
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +3 -3
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +5 -5
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonContained.js +11 -11
- package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonSolid.js +3 -3
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/commonjs/components/icons/Icon.js +2 -2
- package/lib/commonjs/components/icons/Icon.js.map +1 -1
- package/lib/commonjs/components/icons/README.md +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js +47 -13
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/PressableListItemBase.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +2 -2
- package/lib/commonjs/components/modules/PressableModuleBase.js +10 -2
- package/lib/commonjs/components/modules/PressableModuleBase.js.map +1 -1
- package/lib/commonjs/components/numberpad/NumberButton.js +1 -1
- package/lib/commonjs/components/pictograms/Pictogram.js +1 -22
- package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
- package/lib/commonjs/components/spacer/Spacer.js +1 -1
- package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
- package/lib/commonjs/components/stepper/Stepper.js +1 -1
- package/lib/commonjs/components/switch/NativeSwitch.js +2 -2
- package/lib/commonjs/components/switch/NativeSwitch.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +3 -3
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +18 -15
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +8 -6
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +4 -4
- package/lib/commonjs/components/typography/__test__/typography.test.js +13 -13
- package/lib/commonjs/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +30 -99
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/core/IOStyles.js +2 -2
- package/lib/commonjs/core/IOThemeContextProvider.js +12 -7
- package/lib/commonjs/core/IOThemeContextProvider.js.map +1 -1
- package/lib/module/components/Advice/Advice.js +1 -1
- package/lib/module/components/accordion/RawAccordion.js +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +0 -4
- package/lib/module/components/buttons/ButtonLink.js +1 -1
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +24 -24
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +3 -3
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +5 -5
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js +11 -11
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js +3 -3
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/icons/Icon.js +2 -2
- package/lib/module/components/icons/Icon.js.map +1 -1
- package/lib/module/components/icons/README.md +1 -1
- package/lib/module/components/listitems/ListItemInfo.js +48 -15
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/PressableListItemBase.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +2 -2
- package/lib/module/components/modules/PressableModuleBase.js +10 -2
- package/lib/module/components/modules/PressableModuleBase.js.map +1 -1
- package/lib/module/components/numberpad/NumberButton.js +1 -1
- package/lib/module/components/pictograms/Pictogram.js +0 -20
- package/lib/module/components/pictograms/Pictogram.js.map +1 -1
- package/lib/module/components/spacer/Spacer.js +1 -1
- package/lib/module/components/spacer/Spacer.js.map +1 -1
- package/lib/module/components/stepper/Stepper.js +1 -1
- package/lib/module/components/switch/NativeSwitch.js +2 -2
- package/lib/module/components/switch/NativeSwitch.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +3 -3
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +19 -16
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +8 -6
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +4 -4
- package/lib/module/components/typography/__test__/typography.test.js +13 -13
- package/lib/module/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/module/core/IOColors.js +30 -99
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/core/IOStyles.js +2 -2
- package/lib/module/core/IOThemeContextProvider.js +14 -8
- package/lib/module/core/IOThemeContextProvider.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemInfo.d.ts +13 -11
- package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
- package/lib/typescript/components/listitems/PressableListItemBase.d.ts +2 -2
- package/lib/typescript/components/listitems/PressableListItemBase.d.ts.map +1 -1
- package/lib/typescript/components/modules/PressableModuleBase.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/Pictogram.d.ts +2 -11
- package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/types.d.ts +0 -1
- package/lib/typescript/components/pictograms/types.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputBase.d.ts +2 -2
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/styles.d.ts +2 -2
- 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 +5 -35
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/core/IOStyles.d.ts +2 -2
- package/lib/typescript/core/IOThemeContextProvider.d.ts +6 -6
- package/lib/typescript/core/IOThemeContextProvider.d.ts.map +1 -1
- package/lib/typescript/utils/fonts.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/Advice/Advice.tsx +1 -1
- package/src/components/accordion/RawAccordion.tsx +1 -1
- package/src/components/alert/Alert.tsx +3 -2
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +0 -4
- package/src/components/buttons/ButtonLink.tsx +1 -1
- package/src/components/buttons/ButtonOutline.tsx +24 -24
- package/src/components/buttons/ButtonSolid.tsx +3 -3
- package/src/components/buttons/IconButton.tsx +5 -5
- package/src/components/buttons/IconButtonContained.tsx +11 -11
- package/src/components/buttons/IconButtonSolid.tsx +3 -3
- package/src/components/icons/Icon.tsx +2 -2
- package/src/components/icons/README.md +1 -1
- package/src/components/listitems/ListItemInfo.tsx +107 -53
- package/src/components/listitems/ListItemNavAlert.tsx +3 -1
- package/src/components/listitems/ListItemTransaction.tsx +1 -1
- package/src/components/listitems/PressableListItemBase.tsx +3 -2
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +2 -2
- package/src/components/modules/PressableModuleBase.tsx +15 -4
- package/src/components/numberpad/NumberButton.tsx +1 -1
- package/src/components/pictograms/Pictogram.tsx +0 -22
- package/src/components/pictograms/types.ts +0 -1
- package/src/components/spacer/Spacer.tsx +1 -1
- package/src/components/stepper/Stepper.tsx +1 -1
- package/src/components/switch/NativeSwitch.tsx +2 -2
- package/src/components/tabs/TabItem.tsx +3 -3
- package/src/components/textInput/TextInputBase.tsx +28 -16
- package/src/components/textInput/TextInputValidation.tsx +18 -10
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +4 -4
- package/src/components/typography/__test__/typography.test.tsx +18 -16
- package/src/core/IOColors.ts +33 -95
- package/src/core/IOStyles.ts +2 -2
- package/src/core/IOThemeContextProvider.tsx +27 -15
- package/lib/commonjs/components/pictograms/svg/PictogramCompleted.js +0 -33
- package/lib/commonjs/components/pictograms/svg/PictogramCompleted.js.map +0 -1
- package/lib/commonjs/components/pictograms/svg/PictogramProcessing.js +0 -33
- package/lib/commonjs/components/pictograms/svg/PictogramProcessing.js.map +0 -1
- package/lib/commonjs/components/pictograms/svg/originals/PictogramCompleted.svg +0 -14
- package/lib/module/components/pictograms/svg/PictogramCompleted.js +0 -25
- package/lib/module/components/pictograms/svg/PictogramCompleted.js.map +0 -1
- package/lib/module/components/pictograms/svg/PictogramProcessing.js +0 -25
- package/lib/module/components/pictograms/svg/PictogramProcessing.js.map +0 -1
- package/lib/module/components/pictograms/svg/originals/PictogramCompleted.svg +0 -14
- package/lib/typescript/components/pictograms/svg/PictogramCompleted.d.ts +0 -5
- package/lib/typescript/components/pictograms/svg/PictogramCompleted.d.ts.map +0 -1
- package/lib/typescript/components/pictograms/svg/PictogramProcessing.d.ts +0 -5
- package/lib/typescript/components/pictograms/svg/PictogramProcessing.d.ts.map +0 -1
- package/src/components/pictograms/svg/PictogramCompleted.tsx +0 -22
- package/src/components/pictograms/svg/PictogramProcessing.tsx +0 -22
- package/src/components/pictograms/svg/originals/PictogramCompleted.svg +0 -14
|
@@ -2800,7 +2800,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 1`] = `
|
|
|
2800
2800
|
"width": 24,
|
|
2801
2801
|
},
|
|
2802
2802
|
{
|
|
2803
|
-
"borderColor": "#
|
|
2803
|
+
"borderColor": "#555C70",
|
|
2804
2804
|
},
|
|
2805
2805
|
]
|
|
2806
2806
|
}
|
|
@@ -3085,7 +3085,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 2`] = `
|
|
|
3085
3085
|
"width": 24,
|
|
3086
3086
|
},
|
|
3087
3087
|
{
|
|
3088
|
-
"borderColor": "#
|
|
3088
|
+
"borderColor": "#555C70",
|
|
3089
3089
|
},
|
|
3090
3090
|
]
|
|
3091
3091
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { PropsWithChildren } from "react";
|
|
3
|
-
import { Pressable } from "react-native";
|
|
2
|
+
import { PropsWithChildren, useCallback } from "react";
|
|
3
|
+
import { GestureResponderEvent, Pressable } from "react-native";
|
|
4
|
+
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
4
5
|
import Animated, { useReducedMotion } from "react-native-reanimated";
|
|
5
|
-
import { useScaleAnimation } from "../../hooks";
|
|
6
6
|
import {
|
|
7
7
|
IOColors,
|
|
8
8
|
IOModuleIDPSavedVSpacing,
|
|
9
9
|
IOModuleStyles,
|
|
10
10
|
useIOTheme
|
|
11
11
|
} from "../../core";
|
|
12
|
+
import { useScaleAnimation } from "../../hooks";
|
|
12
13
|
import { WithTestID } from "../../utils/types";
|
|
13
14
|
|
|
14
15
|
export type PressableModuleBaseProps = WithTestID<
|
|
@@ -39,9 +40,19 @@ export const PressableModuleBase = ({
|
|
|
39
40
|
If we remove it, they they won't be able to understand
|
|
40
41
|
if there's an ongoing interaction. */
|
|
41
42
|
|
|
43
|
+
const handleOnPress = useCallback(
|
|
44
|
+
(event: GestureResponderEvent) => {
|
|
45
|
+
if (onPress) {
|
|
46
|
+
ReactNativeHapticFeedback.trigger("impactLight");
|
|
47
|
+
onPress(event);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[onPress]
|
|
51
|
+
);
|
|
52
|
+
|
|
42
53
|
return (
|
|
43
54
|
<Pressable
|
|
44
|
-
onPress={
|
|
55
|
+
onPress={handleOnPress}
|
|
45
56
|
testID={testID}
|
|
46
57
|
accessible={true}
|
|
47
58
|
onPressIn={onPressIn}
|
|
@@ -56,7 +56,7 @@ const legacyColorMap: Record<NumberButtonVariantType, ColorMapVariant> = {
|
|
|
56
56
|
light: {
|
|
57
57
|
background: IOColors["grey-100"],
|
|
58
58
|
pressed: IOColors["grey-200"],
|
|
59
|
-
foreground: "blue"
|
|
59
|
+
foreground: "blue-500"
|
|
60
60
|
},
|
|
61
61
|
dark: {
|
|
62
62
|
background: hexToRgba(IOColors.black, 0.1),
|
|
@@ -12,7 +12,6 @@ import PictogramCameraDenied from "./svg/PictogramCameraDenied";
|
|
|
12
12
|
import PictogramCameraRequest from "./svg/PictogramCameraRequest";
|
|
13
13
|
import PictogramCharity from "./svg/PictogramCharity";
|
|
14
14
|
import PictogramCie from "./svg/PictogramCie";
|
|
15
|
-
import PictogramCompleted from "./svg/PictogramCompleted";
|
|
16
15
|
import PictogramComunicationProblem from "./svg/PictogramComunicationProblem";
|
|
17
16
|
import PictogramEmpty from "./svg/PictogramEmpty";
|
|
18
17
|
import PictogramEmptyArchive from "./svg/PictogramEmptyArchive";
|
|
@@ -36,7 +35,6 @@ import PictogramObjManual from "./svg/PictogramObjManual";
|
|
|
36
35
|
import PictogramObjTrash from "./svg/PictogramObjTrash";
|
|
37
36
|
import PictogramPasscode from "./svg/PictogramPasscode";
|
|
38
37
|
import PictogramPayments from "./svg/PictogramPayments";
|
|
39
|
-
import PictogramProcessing from "./svg/PictogramProcessing";
|
|
40
38
|
import PictogramSecurity from "./svg/PictogramSecurity";
|
|
41
39
|
import PictogramStopSecurity from "./svg/PictogramStopSecurity";
|
|
42
40
|
import PictogramSuccess from "./svg/PictogramSuccess";
|
|
@@ -117,10 +115,6 @@ import PictogramWalletDoc from "./svg/PictogramWalletDoc";
|
|
|
117
115
|
import { SVGPictogramProps } from "./types";
|
|
118
116
|
|
|
119
117
|
export const IOPictograms = {
|
|
120
|
-
// Start legacy pictograms //
|
|
121
|
-
processing: PictogramProcessing,
|
|
122
|
-
completed: PictogramCompleted,
|
|
123
|
-
// End legacy pictograms
|
|
124
118
|
empty: PictogramEmpty,
|
|
125
119
|
feature: PictogramFeature,
|
|
126
120
|
charity: PictogramCharity,
|
|
@@ -197,7 +191,6 @@ export type IOPictogramSizeScale = 48 | 64 | 72 | 80 | 120 | 180;
|
|
|
197
191
|
|
|
198
192
|
type IOPictogramsProps = {
|
|
199
193
|
name: IOPictograms;
|
|
200
|
-
color?: IOColors;
|
|
201
194
|
/* Not too happy about the API choice,
|
|
202
195
|
but at least we have the same <StatusBar …>
|
|
203
196
|
component props. */
|
|
@@ -215,7 +208,6 @@ type PictogramPalette = {
|
|
|
215
208
|
|
|
216
209
|
export const Pictogram = ({
|
|
217
210
|
name,
|
|
218
|
-
color = "aqua",
|
|
219
211
|
pictogramStyle = "default",
|
|
220
212
|
size = 120,
|
|
221
213
|
allowFontScaling = false,
|
|
@@ -256,7 +248,6 @@ export const Pictogram = ({
|
|
|
256
248
|
<PictogramElement
|
|
257
249
|
{...props}
|
|
258
250
|
size={pictogramSize}
|
|
259
|
-
color={IOColors[color]}
|
|
260
251
|
colorValues={colorValues}
|
|
261
252
|
/>
|
|
262
253
|
);
|
|
@@ -365,7 +356,6 @@ export const IOPictogramsBleed: {
|
|
|
365
356
|
|
|
366
357
|
export const PictogramBleed = ({
|
|
367
358
|
name,
|
|
368
|
-
color = "aqua",
|
|
369
359
|
size = 80,
|
|
370
360
|
pictogramStyle = "default",
|
|
371
361
|
allowFontScaling = false,
|
|
@@ -406,7 +396,6 @@ export const PictogramBleed = ({
|
|
|
406
396
|
<PictogramElement
|
|
407
397
|
{...props}
|
|
408
398
|
size={pictogramSize}
|
|
409
|
-
color={IOColors[color]}
|
|
410
399
|
colorValues={colorValues}
|
|
411
400
|
/>
|
|
412
401
|
);
|
|
@@ -428,14 +417,3 @@ export const IOPictogramsObject = {
|
|
|
428
417
|
} as const;
|
|
429
418
|
|
|
430
419
|
export type IOPictogramsObject = keyof typeof IOPictogramsObject;
|
|
431
|
-
|
|
432
|
-
/* Legacy pictograms */
|
|
433
|
-
|
|
434
|
-
const { processing, completed } = IOPictograms;
|
|
435
|
-
|
|
436
|
-
export const IOPictogramsLegacy = {
|
|
437
|
-
processing,
|
|
438
|
-
completed
|
|
439
|
-
} as const;
|
|
440
|
-
|
|
441
|
-
export type IOPictogramsLegacy = keyof typeof IOPictogramsLegacy;
|
|
@@ -18,7 +18,7 @@ type OwnProps = Pick<
|
|
|
18
18
|
|
|
19
19
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
20
20
|
const bgLegacyTrackColorAndroid =
|
|
21
|
-
Platform.OS === "android" ? IOColors["grey-300"] : IOColors
|
|
21
|
+
Platform.OS === "android" ? IOColors["grey-300"] : IOColors["grey-50"];
|
|
22
22
|
|
|
23
23
|
export const NativeSwitch = ({
|
|
24
24
|
onValueChange,
|
|
@@ -34,7 +34,7 @@ export const NativeSwitch = ({
|
|
|
34
34
|
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
|
|
35
35
|
const legacyTrackColor = {
|
|
36
36
|
false: bgLegacyTrackColorAndroid,
|
|
37
|
-
true: IOColors
|
|
37
|
+
true: IOColors["blue-500"]
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const trackColorComponent = isExperimental ? trackColor : legacyTrackColor;
|
|
@@ -100,17 +100,17 @@ const mapLegacyColorStates: Record<
|
|
|
100
100
|
light: {
|
|
101
101
|
border: {
|
|
102
102
|
default: IOColors["grey-300"],
|
|
103
|
-
selected: IOColors
|
|
103
|
+
selected: IOColors["blue-500"],
|
|
104
104
|
disabled: hexToRgba(IOColors.white)
|
|
105
105
|
},
|
|
106
106
|
background: {
|
|
107
107
|
default: IOColors.white,
|
|
108
|
-
selected: hexToRgba(IOColors
|
|
108
|
+
selected: hexToRgba(IOColors["blue-500"], 0.1),
|
|
109
109
|
pressed: IOColors.white
|
|
110
110
|
},
|
|
111
111
|
foreground: {
|
|
112
112
|
default: "black",
|
|
113
|
-
selected: "blue",
|
|
113
|
+
selected: "blue-500",
|
|
114
114
|
disabled: "grey-700"
|
|
115
115
|
}
|
|
116
116
|
},
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/* eslint-disable functional/immutable-data */
|
|
2
|
-
import React, {
|
|
2
|
+
import React, {
|
|
3
|
+
ReactNode,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
3
10
|
import {
|
|
4
11
|
ColorValue,
|
|
5
12
|
LayoutChangeEvent,
|
|
@@ -46,7 +53,7 @@ type InputTextProps = WithTestID<{
|
|
|
46
53
|
inputType?: InputType;
|
|
47
54
|
status?: InputStatus;
|
|
48
55
|
icon?: IOIcons;
|
|
49
|
-
rightElement?:
|
|
56
|
+
rightElement?: ReactNode;
|
|
50
57
|
counterLimit?: number;
|
|
51
58
|
bottomMessage?: string;
|
|
52
59
|
bottomMessageColor?: IOColors;
|
|
@@ -67,12 +74,8 @@ const inputLabelScaleFactor: number = 0.75; /* 16pt becomes 12pt */
|
|
|
67
74
|
const inputLabelFontSize: IOFontSize = 16;
|
|
68
75
|
const inputDisabledOpacity: number = 0.5;
|
|
69
76
|
const inputRightElementMargin: IOSpacingScale = 8;
|
|
70
|
-
const iconColor: IOColors = "grey-300";
|
|
71
77
|
const iconSize: IOIconSizeScale = 24;
|
|
72
78
|
const iconMargin: IOSpacingScale = 8;
|
|
73
|
-
const inputLabelColor: ColorValue = IOColors["grey-700"];
|
|
74
|
-
const inputTextColor: ColorValue = IOColors.black;
|
|
75
|
-
const inputDisabledTextColor: ColorValue = IOColors["grey-850"];
|
|
76
79
|
|
|
77
80
|
const styles = StyleSheet.create({
|
|
78
81
|
textInput: {
|
|
@@ -126,11 +129,9 @@ const styles = StyleSheet.create({
|
|
|
126
129
|
justifyContent: "center"
|
|
127
130
|
},
|
|
128
131
|
textInputLabel: {
|
|
129
|
-
color: inputLabelColor,
|
|
130
132
|
...makeFontStyleObject(inputLabelFontSize, "Titillio", undefined, "Regular")
|
|
131
133
|
},
|
|
132
134
|
textInputLabelLegacyFont: {
|
|
133
|
-
color: inputLabelColor,
|
|
134
135
|
...makeFontStyleObject(
|
|
135
136
|
inputLabelFontSize,
|
|
136
137
|
"TitilliumSansPro",
|
|
@@ -149,10 +150,15 @@ const HelperRow = ({
|
|
|
149
150
|
value,
|
|
150
151
|
counterLimit,
|
|
151
152
|
bottomMessage,
|
|
152
|
-
bottomMessageColor
|
|
153
|
+
bottomMessageColor
|
|
153
154
|
}: InputTextHelperRow) => {
|
|
155
|
+
const theme = useIOTheme();
|
|
154
156
|
const valueCount = useMemo(() => value.length, [value]);
|
|
155
157
|
|
|
158
|
+
const bottomMessageColorDefault: IOColors = theme["textBody-tertiary"];
|
|
159
|
+
const bottomMessageColorValue =
|
|
160
|
+
bottomMessageColor ?? bottomMessageColorDefault;
|
|
161
|
+
|
|
156
162
|
const helperRowStyle: ViewStyle = useMemo(() => {
|
|
157
163
|
if (counterLimit && bottomMessage) {
|
|
158
164
|
return {
|
|
@@ -189,14 +195,14 @@ const HelperRow = ({
|
|
|
189
195
|
}
|
|
190
196
|
>
|
|
191
197
|
{bottomMessage && (
|
|
192
|
-
<BodySmall weight="Regular" color={
|
|
198
|
+
<BodySmall weight="Regular" color={bottomMessageColorValue}>
|
|
193
199
|
{bottomMessage}
|
|
194
200
|
</BodySmall>
|
|
195
201
|
)}
|
|
196
202
|
{counterLimit && (
|
|
197
203
|
<BodySmall
|
|
198
204
|
weight="Regular"
|
|
199
|
-
color=
|
|
205
|
+
color={bottomMessageColorValue}
|
|
200
206
|
>{`${valueCount} / ${counterLimit}`}</BodySmall>
|
|
201
207
|
)}
|
|
202
208
|
</View>
|
|
@@ -226,7 +232,7 @@ export const TextInputBase = ({
|
|
|
226
232
|
}: InputTextProps) => {
|
|
227
233
|
const inputRef = useRef<TextInput>(null);
|
|
228
234
|
const isSecretInput = useMemo(() => isPassword, [isPassword]);
|
|
229
|
-
const [inputStatus, setInputStatus] =
|
|
235
|
+
const [inputStatus, setInputStatus] = useState<InputStatus>(
|
|
230
236
|
disabled ? "disabled" : "initial"
|
|
231
237
|
);
|
|
232
238
|
const focusedState = useSharedValue<number>(0);
|
|
@@ -234,9 +240,14 @@ export const TextInputBase = ({
|
|
|
234
240
|
const { dynamicFontScale, spacingScaleMultiplier } = useIOFontDynamicScale();
|
|
235
241
|
|
|
236
242
|
const theme = useIOTheme();
|
|
243
|
+
const iconColor: IOColors = theme["icon-decorative"];
|
|
244
|
+
const inputLabelColor: ColorValue = IOColors[theme["textInputLabel-default"]];
|
|
245
|
+
const inputTextColor: ColorValue = IOColors[theme["textInputValue-default"]];
|
|
246
|
+
const inputDisabledTextColor: ColorValue =
|
|
247
|
+
IOColors[theme["textInputValue-disabled"]];
|
|
237
248
|
|
|
238
249
|
/* Get the label width to enable the correct translation */
|
|
239
|
-
const [labelWidth, setLabelWidth] =
|
|
250
|
+
const [labelWidth, setLabelWidth] = useState<number>(0);
|
|
240
251
|
|
|
241
252
|
const getLabelWidth = ({ nativeEvent }: LayoutChangeEvent) => {
|
|
242
253
|
setLabelWidth(nativeEvent.layout.width);
|
|
@@ -255,10 +266,10 @@ export const TextInputBase = ({
|
|
|
255
266
|
|
|
256
267
|
const borderColorMap: Record<InputStatus, string> = useMemo(
|
|
257
268
|
() => ({
|
|
258
|
-
initial: IOColors["
|
|
259
|
-
disabled: IOColors["
|
|
269
|
+
initial: IOColors[theme["textInputBorder-default"]],
|
|
270
|
+
disabled: IOColors[theme["textInputBorder-default"]],
|
|
260
271
|
focused: IOColors[theme["interactiveElem-default"]],
|
|
261
|
-
error: IOColors[
|
|
272
|
+
error: IOColors[theme.errorText]
|
|
262
273
|
}),
|
|
263
274
|
[theme]
|
|
264
275
|
);
|
|
@@ -467,6 +478,7 @@ export const TextInputBase = ({
|
|
|
467
478
|
isExperimental
|
|
468
479
|
? styles.textInputLabel
|
|
469
480
|
: styles.textInputLabelLegacyFont,
|
|
481
|
+
{ color: inputLabelColor },
|
|
470
482
|
animatedLabelStyle
|
|
471
483
|
]}
|
|
472
484
|
>
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import { AccessibilityInfo, View } from "react-native";
|
|
4
4
|
import Animated from "react-native-reanimated";
|
|
5
|
+
import { useIOTheme } from "../../core";
|
|
5
6
|
import { IOColors } from "../../core/IOColors";
|
|
6
7
|
import {
|
|
7
8
|
enterTransitionInputIcon,
|
|
@@ -18,8 +19,8 @@ type TextInputValidationProps = Omit<
|
|
|
18
19
|
"rightElement" | "status" | "bottomMessageColor" | "isPassword"
|
|
19
20
|
> & {
|
|
20
21
|
/**
|
|
21
|
-
* This function can return either a `boolean` or a `ValidationWithOptions` object.
|
|
22
|
-
* If a `boolean` is returned and the field is not valid, the value of the errorMessage prop will be displayed/announced.
|
|
22
|
+
* This function can return either a `boolean` or a `ValidationWithOptions` object.
|
|
23
|
+
* If a `boolean` is returned and the field is not valid, the value of the errorMessage prop will be displayed/announced.
|
|
23
24
|
* If a `ValidationWithOptions` object is returned and the field is not valid, the value displayed/announced will be the one contained within this object.
|
|
24
25
|
*/
|
|
25
26
|
onValidate: (value: string) => boolean | ValidationWithOptions;
|
|
@@ -29,8 +30,14 @@ type TextInputValidationProps = Omit<
|
|
|
29
30
|
errorMessage: string;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
function isValidationWithOptions(
|
|
33
|
-
|
|
33
|
+
function isValidationWithOptions(
|
|
34
|
+
validation: boolean | ValidationWithOptions
|
|
35
|
+
): validation is ValidationWithOptions {
|
|
36
|
+
return (
|
|
37
|
+
typeof validation === "object" &&
|
|
38
|
+
"isValid" in validation &&
|
|
39
|
+
"errorMessage" in validation
|
|
40
|
+
);
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
const feedbackIconSize: IOIconSizeScale = 24;
|
|
@@ -44,6 +51,7 @@ export const TextInputValidation = ({
|
|
|
44
51
|
onFocus,
|
|
45
52
|
...props
|
|
46
53
|
}: TextInputValidationProps) => {
|
|
54
|
+
const theme = useIOTheme();
|
|
47
55
|
const [isValid, setIsValid] = useState<boolean | undefined>(undefined);
|
|
48
56
|
const [errMessage, setErrMessage] = useState(errorMessage);
|
|
49
57
|
|
|
@@ -78,13 +86,13 @@ export const TextInputValidation = ({
|
|
|
78
86
|
}, [onFocus]);
|
|
79
87
|
|
|
80
88
|
const labelError = useMemo(
|
|
81
|
-
() => (isValid
|
|
89
|
+
() => (!isValid && errMessage ? errMessage : bottomMessage),
|
|
82
90
|
[isValid, errMessage, bottomMessage]
|
|
83
91
|
);
|
|
84
92
|
|
|
85
93
|
const labelErrorColor: IOColors | undefined = useMemo(
|
|
86
|
-
() => (isValid
|
|
87
|
-
[isValid, errMessage]
|
|
94
|
+
() => (!isValid && errMessage ? theme.errorText : undefined),
|
|
95
|
+
[isValid, errMessage, theme.errorText]
|
|
88
96
|
);
|
|
89
97
|
|
|
90
98
|
const feedbackIconAttrMap: Record<
|
|
@@ -94,14 +102,14 @@ export const TextInputValidation = ({
|
|
|
94
102
|
() => ({
|
|
95
103
|
valid: {
|
|
96
104
|
name: "success",
|
|
97
|
-
color:
|
|
105
|
+
color: theme.successIcon
|
|
98
106
|
},
|
|
99
107
|
notValid: {
|
|
100
108
|
name: "errorFilled",
|
|
101
|
-
color:
|
|
109
|
+
color: theme.errorIcon
|
|
102
110
|
}
|
|
103
111
|
}),
|
|
104
|
-
[]
|
|
112
|
+
[theme]
|
|
105
113
|
);
|
|
106
114
|
|
|
107
115
|
const feedbackIcon = useMemo(() => {
|
|
@@ -103,7 +103,7 @@ exports[`Test Typography Components BodySmall Snapshot 3`] = `
|
|
|
103
103
|
[
|
|
104
104
|
{},
|
|
105
105
|
{
|
|
106
|
-
"color": "#
|
|
106
|
+
"color": "#555C70",
|
|
107
107
|
"fontFamily": "Titillium Sans Pro",
|
|
108
108
|
"fontSize": 14,
|
|
109
109
|
"fontStyle": "normal",
|
|
@@ -126,7 +126,7 @@ exports[`Test Typography Components BodySmall Snapshot 4`] = `
|
|
|
126
126
|
[
|
|
127
127
|
{},
|
|
128
128
|
{
|
|
129
|
-
"color": "#
|
|
129
|
+
"color": "#D13333",
|
|
130
130
|
"fontFamily": "Titillium Sans Pro",
|
|
131
131
|
"fontSize": 14,
|
|
132
132
|
"fontStyle": "normal",
|
|
@@ -286,7 +286,7 @@ exports[`Test Typography Components H3 Snapshot 2`] = `
|
|
|
286
286
|
[
|
|
287
287
|
{},
|
|
288
288
|
{
|
|
289
|
-
"color": "#
|
|
289
|
+
"color": "#D2D6E3",
|
|
290
290
|
"fontFamily": "Titillium Sans Pro",
|
|
291
291
|
"fontSize": 22,
|
|
292
292
|
"fontStyle": "normal",
|
|
@@ -476,7 +476,7 @@ exports[`Test Typography Components H5 Snapshot 2`] = `
|
|
|
476
476
|
"textTransform": "uppercase",
|
|
477
477
|
},
|
|
478
478
|
{
|
|
479
|
-
"color": "#
|
|
479
|
+
"color": "#555C70",
|
|
480
480
|
"fontFamily": "Titillium Sans Pro",
|
|
481
481
|
"fontSize": 14,
|
|
482
482
|
"fontStyle": "normal",
|
|
@@ -30,10 +30,10 @@ describe("Test Typography Components", () => {
|
|
|
30
30
|
// SemiBold weight, default weight
|
|
31
31
|
const h3Default = TestRenderer.create(<H3>Text</H3>).toJSON();
|
|
32
32
|
expect(h3Default).toMatchSnapshot();
|
|
33
|
-
const
|
|
34
|
-
<H3 color={"
|
|
33
|
+
const h3grey200 = TestRenderer.create(
|
|
34
|
+
<H3 color={"grey-200"}>Text</H3>
|
|
35
35
|
).toJSON();
|
|
36
|
-
expect(
|
|
36
|
+
expect(h3grey200).toMatchSnapshot();
|
|
37
37
|
const h3white = TestRenderer.create(<H3 color={"white"}>Text</H3>).toJSON();
|
|
38
38
|
expect(h3white).toMatchSnapshot();
|
|
39
39
|
const h3whiteBold = TestRenderer.create(
|
|
@@ -49,7 +49,9 @@ describe("Test Typography Components", () => {
|
|
|
49
49
|
// Bold weight, default weight
|
|
50
50
|
const h4Default = TestRenderer.create(<H4>Text</H4>).toJSON();
|
|
51
51
|
expect(h4Default).toMatchSnapshot();
|
|
52
|
-
const h4Dblue = TestRenderer.create(
|
|
52
|
+
const h4Dblue = TestRenderer.create(
|
|
53
|
+
<H4 color={"blue-500"}>Text</H4>
|
|
54
|
+
).toJSON();
|
|
53
55
|
expect(h4Dblue).toMatchSnapshot();
|
|
54
56
|
const h4white = TestRenderer.create(<H4 color={"white"}>Text</H4>).toJSON();
|
|
55
57
|
expect(h4white).toMatchSnapshot();
|
|
@@ -59,11 +61,11 @@ describe("Test Typography Components", () => {
|
|
|
59
61
|
const h5Default = TestRenderer.create(<H5>Text</H5>).toJSON();
|
|
60
62
|
expect(h5Default).toMatchSnapshot();
|
|
61
63
|
const h5Defaultbluegrey = TestRenderer.create(
|
|
62
|
-
<H5 color={"
|
|
64
|
+
<H5 color={"grey-700"}>Text</H5>
|
|
63
65
|
).toJSON();
|
|
64
66
|
expect(h5Defaultbluegrey).toMatchSnapshot();
|
|
65
67
|
const h5Defaultblue = TestRenderer.create(
|
|
66
|
-
<H5 color={"blue"}>Text</H5>
|
|
68
|
+
<H5 color={"blue-500"}>Text</H5>
|
|
67
69
|
).toJSON();
|
|
68
70
|
expect(h5Defaultblue).toMatchSnapshot();
|
|
69
71
|
const h5Defaultwhite = TestRenderer.create(
|
|
@@ -93,9 +95,9 @@ describe("Test Typography Components", () => {
|
|
|
93
95
|
type BodyColors = React.ComponentProps<typeof BodySmall>["color"];
|
|
94
96
|
|
|
95
97
|
const allowedColors: ReadonlyArray<BodyColors> = [
|
|
96
|
-
"blue",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
98
|
+
"blue-500",
|
|
99
|
+
"grey-700",
|
|
100
|
+
"error-600",
|
|
99
101
|
"white"
|
|
100
102
|
];
|
|
101
103
|
|
|
@@ -126,26 +128,26 @@ describe("Test Typography common", () => {
|
|
|
126
128
|
it("Test calculateWeightColor behaviour", () => {
|
|
127
129
|
const noValues = calculateWeightColor<IOFontWeight, IOColors>(
|
|
128
130
|
"Bold",
|
|
129
|
-
"
|
|
131
|
+
"error-600"
|
|
130
132
|
);
|
|
131
|
-
expect(noValues.color).toBe("
|
|
133
|
+
expect(noValues.color).toBe("error-600");
|
|
132
134
|
expect(noValues.weight).toBe("Bold");
|
|
133
135
|
|
|
134
136
|
const weightProvided = calculateWeightColor<IOFontWeight, IOColors>(
|
|
135
137
|
"Bold",
|
|
136
|
-
"
|
|
138
|
+
"error-600",
|
|
137
139
|
"Regular"
|
|
138
140
|
);
|
|
139
|
-
expect(weightProvided.color).toBe("
|
|
141
|
+
expect(weightProvided.color).toBe("error-600");
|
|
140
142
|
expect(weightProvided.weight).toBe("Regular");
|
|
141
143
|
|
|
142
144
|
const allValuesProvided = calculateWeightColor<IOFontWeight, IOColors>(
|
|
143
145
|
"Bold",
|
|
144
|
-
"
|
|
146
|
+
"error-600",
|
|
145
147
|
"Regular",
|
|
146
|
-
"
|
|
148
|
+
"grey-700"
|
|
147
149
|
);
|
|
148
|
-
expect(allValuesProvided.color).toBe("
|
|
150
|
+
expect(allValuesProvided.color).toBe("grey-700");
|
|
149
151
|
expect(allValuesProvided.weight).toBe("Regular");
|
|
150
152
|
});
|
|
151
153
|
});
|