@pagopa/io-app-design-system 5.11.12 → 5.11.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/lib/commonjs/components/banner/BannerErrorState.js +3 -2
  2. package/lib/commonjs/components/banner/BannerErrorState.js.map +1 -1
  3. package/lib/commonjs/components/buttons/__test__/button.test.js +13 -9
  4. package/lib/commonjs/components/buttons/__test__/button.test.js.map +1 -1
  5. package/lib/commonjs/components/buttons/index.js +0 -33
  6. package/lib/commonjs/components/buttons/index.js.map +1 -1
  7. package/lib/commonjs/components/listitems/ListItemHeader.js +2 -1
  8. package/lib/commonjs/components/listitems/ListItemHeader.js.map +1 -1
  9. package/lib/commonjs/components/listitems/ListItemInfo.js +2 -1
  10. package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
  11. package/lib/commonjs/components/modules/ModuleCheckout.js +2 -1
  12. package/lib/commonjs/components/modules/ModuleCheckout.js.map +1 -1
  13. package/lib/commonjs/components/pictograms/Pictogram.js +2 -0
  14. package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
  15. package/lib/commonjs/components/pictograms/svg/PictogramPinSecurity.js +64 -0
  16. package/lib/commonjs/components/pictograms/svg/PictogramPinSecurity.js.map +1 -0
  17. package/lib/commonjs/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
  18. package/lib/module/components/banner/BannerErrorState.js +3 -2
  19. package/lib/module/components/banner/BannerErrorState.js.map +1 -1
  20. package/lib/module/components/buttons/__test__/button.test.js +13 -9
  21. package/lib/module/components/buttons/__test__/button.test.js.map +1 -1
  22. package/lib/module/components/buttons/index.js +0 -3
  23. package/lib/module/components/buttons/index.js.map +1 -1
  24. package/lib/module/components/listitems/ListItemHeader.js +3 -2
  25. package/lib/module/components/listitems/ListItemHeader.js.map +1 -1
  26. package/lib/module/components/listitems/ListItemInfo.js +3 -2
  27. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  28. package/lib/module/components/modules/ModuleCheckout.js +3 -2
  29. package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
  30. package/lib/module/components/pictograms/Pictogram.js +2 -0
  31. package/lib/module/components/pictograms/Pictogram.js.map +1 -1
  32. package/lib/module/components/pictograms/svg/PictogramPinSecurity.js +59 -0
  33. package/lib/module/components/pictograms/svg/PictogramPinSecurity.js.map +1 -0
  34. package/lib/module/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
  35. package/lib/typescript/components/banner/BannerErrorState.d.ts.map +1 -1
  36. package/lib/typescript/components/buttons/index.d.ts +0 -3
  37. package/lib/typescript/components/buttons/index.d.ts.map +1 -1
  38. package/lib/typescript/components/listitems/ListItemHeader.d.ts +2 -2
  39. package/lib/typescript/components/listitems/ListItemHeader.d.ts.map +1 -1
  40. package/lib/typescript/components/listitems/ListItemInfo.d.ts +2 -2
  41. package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
  42. package/lib/typescript/components/pictograms/Pictogram.d.ts +1 -0
  43. package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
  44. package/lib/typescript/components/pictograms/svg/PictogramPinSecurity.d.ts +5 -0
  45. package/lib/typescript/components/pictograms/svg/PictogramPinSecurity.d.ts.map +1 -0
  46. package/package.json +1 -1
  47. package/src/components/banner/BannerErrorState.tsx +7 -2
  48. package/src/components/buttons/__test__/button.test.tsx +15 -13
  49. package/src/components/buttons/index.tsx +0 -3
  50. package/src/components/listitems/ListItemHeader.tsx +3 -3
  51. package/src/components/listitems/ListItemInfo.tsx +4 -3
  52. package/src/components/modules/ModuleCheckout.tsx +2 -2
  53. package/src/components/pictograms/Pictogram.tsx +2 -0
  54. package/src/components/pictograms/svg/PictogramPinSecurity.tsx +44 -0
  55. package/src/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
  56. package/lib/commonjs/components/buttons/ButtonLink.js +0 -157
  57. package/lib/commonjs/components/buttons/ButtonLink.js.map +0 -1
  58. package/lib/commonjs/components/buttons/ButtonOutline.js +0 -173
  59. package/lib/commonjs/components/buttons/ButtonOutline.js.map +0 -1
  60. package/lib/commonjs/components/buttons/ButtonSolid.js +0 -194
  61. package/lib/commonjs/components/buttons/ButtonSolid.js.map +0 -1
  62. package/lib/module/components/buttons/ButtonLink.js +0 -152
  63. package/lib/module/components/buttons/ButtonLink.js.map +0 -1
  64. package/lib/module/components/buttons/ButtonOutline.js +0 -168
  65. package/lib/module/components/buttons/ButtonOutline.js.map +0 -1
  66. package/lib/module/components/buttons/ButtonSolid.js +0 -188
  67. package/lib/module/components/buttons/ButtonSolid.js.map +0 -1
  68. package/lib/typescript/components/buttons/ButtonLink.d.ts +0 -36
  69. package/lib/typescript/components/buttons/ButtonLink.d.ts.map +0 -1
  70. package/lib/typescript/components/buttons/ButtonOutline.d.ts +0 -26
  71. package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +0 -1
  72. package/lib/typescript/components/buttons/ButtonSolid.d.ts +0 -52
  73. package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +0 -1
  74. package/src/components/buttons/ButtonLink.tsx +0 -222
  75. package/src/components/buttons/ButtonOutline.tsx +0 -261
  76. package/src/components/buttons/ButtonSolid.tsx +0 -285
@@ -1,261 +0,0 @@
1
- import React, { ComponentProps, forwardRef } from "react";
2
- import {
3
- GestureResponderEvent,
4
- Pressable,
5
- StyleSheet,
6
- View
7
- } from "react-native";
8
- import Animated, {
9
- interpolateColor,
10
- useAnimatedProps,
11
- useAnimatedStyle,
12
- useReducedMotion
13
- } from "react-native-reanimated";
14
- import { useIONewTypeface, useIOTheme } from "../../context";
15
- import { IOButtonStyles, IOColors, hexToRgba } from "../../core/";
16
- import { useScaleAnimation } from "../../hooks";
17
- import { WithTestID } from "../../utils/types";
18
- import {
19
- AnimatedIcon,
20
- AnimatedIconWithColorTransition,
21
- IOIconSizeScale,
22
- IOIcons
23
- } from "../icons";
24
- import { IOText, buttonTextFontSize } from "../typography";
25
-
26
- type ColorButtonOutline = "primary" | "contrast";
27
- export type ButtonOutline = WithTestID<
28
- {
29
- color?: ColorButtonOutline;
30
- label: string;
31
- fullWidth?: boolean;
32
- // Icons
33
- icon?: IOIcons;
34
- iconPosition?: "start" | "end";
35
- // Events
36
- onPress: (event: GestureResponderEvent) => void;
37
- } & Pick<
38
- ComponentProps<typeof Pressable>,
39
- "disabled" | "accessibilityLabel" | "accessibilityHint"
40
- >
41
- >;
42
-
43
- type ColorStates = {
44
- background: {
45
- default: string;
46
- pressed: string;
47
- disabled: string;
48
- };
49
- foreground: {
50
- default: string;
51
- pressed: string;
52
- disabled: string;
53
- };
54
- };
55
-
56
- // Icon size
57
- const iconSize: IOIconSizeScale = 20;
58
-
59
- const DISABLED_OPACITY = 0.5;
60
- const ICON_MARGIN = 8;
61
-
62
- const IOButtonStylesLocal = StyleSheet.create({
63
- buttonWithBorder: {
64
- borderWidth: 2
65
- }
66
- });
67
-
68
- /**
69
- * @deprecated Use `Button` with variant `outline` instead
70
- */
71
- export const ButtonOutline = forwardRef<View, ButtonOutline>(
72
- (
73
- {
74
- color = "primary",
75
- label,
76
- fullWidth = false,
77
- disabled = false,
78
- icon,
79
- iconPosition = "start",
80
- onPress,
81
- accessibilityLabel,
82
- accessibilityHint,
83
- testID
84
- },
85
- ref
86
- ) => {
87
- const theme = useIOTheme();
88
- const { newTypefaceEnabled } = useIONewTypeface();
89
- const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
90
- useScaleAnimation();
91
- const reducedMotion = useReducedMotion();
92
-
93
- const AnimatedIOText = Animated.createAnimatedComponent(IOText);
94
-
95
- const mapColorStates: Record<
96
- NonNullable<ButtonOutline["color"]>,
97
- ColorStates
98
- > = {
99
- // Primary button
100
- primary: {
101
- background: {
102
- default: hexToRgba(IOColors[theme["interactiveElem-pressed"]], 0),
103
- pressed: hexToRgba(IOColors[theme["interactiveElem-pressed"]], 0.1),
104
- disabled: "transparent"
105
- },
106
- foreground: {
107
- default: IOColors[theme["interactiveElem-default"]],
108
- pressed: IOColors[theme["interactiveElem-pressed"]],
109
- disabled: IOColors[theme["interactiveOutline-disabled"]]
110
- }
111
- },
112
- // Contrast button
113
- contrast: {
114
- background: {
115
- default: hexToRgba(IOColors["blueIO-600"], 0),
116
- pressed: hexToRgba(IOColors["blueIO-600"], 0.5),
117
- disabled: "transparent"
118
- },
119
- foreground: {
120
- default: IOColors.white,
121
- pressed: IOColors.white,
122
- disabled: IOColors["blueIO-200"]
123
- }
124
- }
125
- };
126
-
127
- // Interpolate animation values from `isPressed` values
128
- const pressedAnimationStyle = useAnimatedStyle(() => {
129
- // Link color states to the pressed states
130
- const backgroundColor = interpolateColor(
131
- progress.value,
132
- [0, 1],
133
- [
134
- mapColorStates[color].background.default,
135
- mapColorStates[color].background.pressed
136
- ]
137
- );
138
-
139
- const borderColor = interpolateColor(
140
- progress.value,
141
- [0, 1],
142
- [
143
- mapColorStates[color].foreground.default,
144
- mapColorStates[color].foreground.pressed
145
- ]
146
- );
147
-
148
- return {
149
- borderColor,
150
- backgroundColor
151
- };
152
- });
153
-
154
- const pressedColorLabelAnimationStyle = useAnimatedStyle(() => ({
155
- color: interpolateColor(
156
- progress.value,
157
- [0, 1],
158
- [
159
- mapColorStates[color].foreground.default,
160
- mapColorStates[color].foreground.pressed
161
- ]
162
- )
163
- }));
164
-
165
- // Animate the <Icon> color prop
166
- const pressedColorIconAnimationStyle = useAnimatedProps(() => ({
167
- color: interpolateColor(
168
- progress.value,
169
- [0, 1],
170
- [
171
- mapColorStates[color].foreground.default,
172
- mapColorStates[color].foreground.pressed
173
- ]
174
- )
175
- }));
176
-
177
- return (
178
- <Pressable
179
- ref={ref}
180
- accessible={true}
181
- accessibilityLabel={accessibilityLabel || label}
182
- accessibilityHint={accessibilityHint}
183
- accessibilityRole={"button"}
184
- accessibilityState={{ disabled: disabled || false }}
185
- onPress={onPress}
186
- onPressIn={onPressIn}
187
- onPressOut={onPressOut}
188
- disabled={disabled}
189
- style={
190
- fullWidth
191
- ? { flexShrink: 0, alignSelf: "stretch" }
192
- : { flexShrink: 1, alignSelf: "auto" }
193
- }
194
- testID={testID}
195
- >
196
- <Animated.View
197
- style={[
198
- IOButtonStyles.button,
199
- IOButtonStyles.buttonSizeDefault,
200
- IOButtonStylesLocal.buttonWithBorder,
201
- fullWidth && { paddingHorizontal: 16 },
202
- { columnGap: ICON_MARGIN },
203
- iconPosition === "end" && { flexDirection: "row-reverse" },
204
- disabled
205
- ? {
206
- backgroundColor: mapColorStates[color]?.background?.disabled,
207
- borderColor: mapColorStates[color]?.foreground?.disabled,
208
- opacity: DISABLED_OPACITY
209
- }
210
- : {
211
- backgroundColor: mapColorStates[color]?.background?.default,
212
- borderColor: mapColorStates[color]?.foreground.default
213
- },
214
- /* Prevent Reanimated from overriding background colors
215
- if button is disabled */
216
- !reducedMotion && !disabled && scaleAnimatedStyle,
217
- !disabled && pressedAnimationStyle
218
- ]}
219
- >
220
- {icon &&
221
- (!disabled ? (
222
- <AnimatedIconWithColorTransition
223
- allowFontScaling
224
- name={icon}
225
- animatedProps={pressedColorIconAnimationStyle}
226
- color={mapColorStates[color]?.foreground?.default}
227
- size={iconSize}
228
- />
229
- ) : (
230
- <AnimatedIcon
231
- allowFontScaling
232
- name={icon}
233
- color={mapColorStates[color]?.foreground?.disabled}
234
- size={iconSize}
235
- />
236
- ))}
237
- <AnimatedIOText
238
- font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
239
- weight={"Semibold"}
240
- size={buttonTextFontSize}
241
- accessible={false}
242
- accessibilityElementsHidden
243
- importantForAccessibility="no-hide-descendants"
244
- numberOfLines={1}
245
- ellipsizeMode="tail"
246
- style={[
247
- { alignSelf: "center" },
248
- disabled
249
- ? { color: mapColorStates[color]?.foreground?.disabled }
250
- : { ...pressedColorLabelAnimationStyle }
251
- ]}
252
- >
253
- {label}
254
- </AnimatedIOText>
255
- </Animated.View>
256
- </Pressable>
257
- );
258
- }
259
- );
260
-
261
- export default ButtonOutline;
@@ -1,285 +0,0 @@
1
- import React, {
2
- ComponentProps,
3
- forwardRef,
4
- useCallback,
5
- useEffect,
6
- useRef
7
- } from "react";
8
- import {
9
- ColorValue,
10
- GestureResponderEvent,
11
- Pressable,
12
- View
13
- } from "react-native";
14
- import ReactNativeHapticFeedback from "react-native-haptic-feedback";
15
- import Animated, {
16
- interpolateColor,
17
- useAnimatedStyle,
18
- useReducedMotion
19
- } from "react-native-reanimated";
20
- import { useIOTheme } from "../../context";
21
- import {
22
- IOButtonStyles,
23
- IOColors,
24
- enterTransitionInnerContent,
25
- enterTransitionInnerContentSmall,
26
- exitTransitionInnerContent
27
- } from "../../core";
28
- import { useScaleAnimation } from "../../hooks";
29
- import { WithTestID } from "../../utils/types";
30
- import { IOIconSizeScale, IOIcons, Icon } from "../icons";
31
- import { LoadingSpinner } from "../loadingSpinner";
32
- import { ButtonText } from "../typography/ButtonText";
33
-
34
- export type ButtonSolidColor = "primary" | "danger" | "contrast";
35
-
36
- type ColorStates = {
37
- background: {
38
- default: string;
39
- pressed: string;
40
- disabled: string;
41
- };
42
- foreground: {
43
- default: IOColors;
44
- disabled: IOColors;
45
- };
46
- };
47
-
48
- const ICON_MARGIN = 8;
49
- const DISABLED_OPACITY = 0.5;
50
-
51
- // Icon size
52
- const iconSize: IOIconSizeScale = 20;
53
-
54
- export type ButtonSolidProps = WithTestID<
55
- {
56
- /**
57
- * @default primary
58
- */
59
- color?: ButtonSolidColor;
60
- label: string;
61
- /**
62
- * @default false
63
- */
64
- fullWidth?: boolean;
65
- /**
66
- * @default false
67
- */
68
- loading?: boolean;
69
- icon?: IOIcons;
70
- /**
71
- * @default start
72
- */
73
- iconPosition?: "start" | "end";
74
- onPress: (event: GestureResponderEvent) => void;
75
- } & Pick<
76
- ComponentProps<typeof Pressable>,
77
- "disabled" | "accessibilityLabel" | "accessibilityHint"
78
- >
79
- >;
80
-
81
- /**
82
- * @deprecated Use `Button` with variant `solid` instead
83
- */
84
- export const ButtonSolid = forwardRef<View, ButtonSolidProps>(
85
- (
86
- {
87
- color = "primary",
88
- label,
89
- fullWidth = false,
90
- disabled = false,
91
- loading = false,
92
- icon,
93
- iconPosition = "start",
94
- onPress,
95
- accessibilityLabel,
96
- accessibilityHint,
97
- testID
98
- },
99
- ref
100
- ) => {
101
- const theme = useIOTheme();
102
- const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
103
- useScaleAnimation();
104
- const reducedMotion = useReducedMotion();
105
-
106
- const mapColorStates: Record<
107
- NonNullable<ButtonSolidProps["color"]>,
108
- ColorStates
109
- > = {
110
- // Primary button
111
- primary: {
112
- background: {
113
- default: IOColors[theme["interactiveElem-default"]],
114
- pressed: IOColors[theme["interactiveElem-pressed"]],
115
- disabled: IOColors[theme["interactiveElem-disabled"]]
116
- },
117
- foreground: {
118
- default: theme["buttonText-default"],
119
- disabled: theme["buttonText-disabled"]
120
- }
121
- },
122
- // Danger button
123
- danger: {
124
- background: {
125
- default: IOColors["error-600"],
126
- pressed: IOColors["error-500"],
127
- disabled: IOColors[theme["interactiveElem-disabled"]]
128
- },
129
- foreground: {
130
- default: theme["buttonText-danger"],
131
- disabled: theme["buttonText-disabled"]
132
- }
133
- },
134
- // Contrast button
135
- contrast: {
136
- background: {
137
- default: IOColors.white,
138
- pressed: IOColors["blueIO-50"],
139
- disabled: IOColors["blueIO-50"]
140
- },
141
- foreground: {
142
- default: "blueIO-500",
143
- disabled: "blueIO-500"
144
- }
145
- }
146
- };
147
-
148
- /* Prevent the component from triggering the `isEntering' transition
149
- on the on the first render. Solution from this discussion:
150
- https://github.com/software-mansion/react-native-reanimated/discussions/2513
151
- */
152
- const isMounted = useRef(false);
153
-
154
- useEffect(() => {
155
- // eslint-disable-next-line functional/immutable-data
156
- isMounted.current = true;
157
- }, []);
158
-
159
- // Interpolate animation values from `isPressed` values
160
- const pressedAnimationStyle = useAnimatedStyle(() => {
161
- // Link color states to the pressed states
162
- const backgroundColor = interpolateColor(
163
- progress.value,
164
- [0, 1],
165
- [
166
- mapColorStates[color].background.default,
167
- mapColorStates[color].background.pressed
168
- ]
169
- );
170
-
171
- return { backgroundColor };
172
- });
173
-
174
- const handleOnPress = useCallback(
175
- (event: GestureResponderEvent) => {
176
- /* Don't call `onPress` if the button is
177
- in loading state */
178
- if (loading) {
179
- return;
180
- }
181
- ReactNativeHapticFeedback.trigger("impactLight");
182
- onPress(event);
183
- },
184
- [loading, onPress]
185
- );
186
-
187
- // Background
188
- const backgroundColor: ColorValue = disabled
189
- ? mapColorStates[color]?.background?.disabled
190
- : mapColorStates[color]?.background?.default;
191
-
192
- // Label & Icons colors
193
- const foregroundColor: IOColors = disabled
194
- ? mapColorStates[color]?.foreground?.disabled
195
- : mapColorStates[color]?.foreground?.default;
196
-
197
- return (
198
- <Pressable
199
- testID={testID}
200
- ref={ref}
201
- accessible={true}
202
- // Using || operator because empty string is not an accepted value
203
- accessibilityLabel={accessibilityLabel || label}
204
- accessibilityHint={accessibilityHint}
205
- accessibilityState={{
206
- busy: loading,
207
- disabled: disabled || false
208
- }}
209
- accessibilityRole={"button"}
210
- onPress={handleOnPress}
211
- onPressIn={onPressIn}
212
- onPressOut={onPressOut}
213
- disabled={disabled}
214
- style={
215
- fullWidth
216
- ? { flexShrink: 0, alignSelf: "stretch" }
217
- : { flexShrink: 1, alignSelf: "auto" }
218
- }
219
- >
220
- <Animated.View
221
- style={[
222
- IOButtonStyles.button,
223
- IOButtonStyles.buttonSizeDefault,
224
- { backgroundColor, overflow: "hidden" },
225
- fullWidth && { paddingHorizontal: 16 },
226
- disabled ? { opacity: DISABLED_OPACITY } : {},
227
- /* Prevent Reanimated from overriding background colors
228
- if button is disabled */
229
- !disabled && !reducedMotion && scaleAnimatedStyle,
230
- !disabled && pressedAnimationStyle
231
- ]}
232
- >
233
- {loading && (
234
- <Animated.View
235
- style={IOButtonStyles.buttonInner}
236
- entering={
237
- isMounted.current ? enterTransitionInnerContentSmall : undefined
238
- }
239
- exiting={exitTransitionInnerContent}
240
- >
241
- <LoadingSpinner color={IOColors[foregroundColor]} />
242
- </Animated.View>
243
- )}
244
-
245
- {!loading && (
246
- <Animated.View
247
- style={[
248
- IOButtonStyles.buttonInner,
249
- { columnGap: ICON_MARGIN },
250
- /* If 'iconPosition' is set to 'end', we use
251
- reverse flex property to invert the position */
252
- iconPosition === "end" && { flexDirection: "row-reverse" }
253
- ]}
254
- entering={
255
- isMounted.current ? enterTransitionInnerContent : undefined
256
- }
257
- >
258
- {icon && (
259
- <Icon
260
- allowFontScaling
261
- name={icon}
262
- size={iconSize}
263
- color={foregroundColor}
264
- />
265
- )}
266
- <ButtonText
267
- color={foregroundColor}
268
- style={IOButtonStyles.label}
269
- numberOfLines={1}
270
- ellipsizeMode="tail"
271
- accessible={false}
272
- accessibilityElementsHidden
273
- importantForAccessibility="no-hide-descendants"
274
- >
275
- {label}
276
- </ButtonText>
277
- </Animated.View>
278
- )}
279
- </Animated.View>
280
- </Pressable>
281
- );
282
- }
283
- );
284
-
285
- export default ButtonSolid;