@pagopa/io-app-design-system 5.11.13-0 → 5.11.14

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 (94) 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/otpInput/BoxedInput.js +6 -2
  14. package/lib/commonjs/components/otpInput/BoxedInput.js.map +1 -1
  15. package/lib/commonjs/components/otpInput/OTPInput.js +3 -1
  16. package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
  17. package/lib/commonjs/components/pictograms/Pictogram.js +2 -0
  18. package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
  19. package/lib/commonjs/components/pictograms/svg/PictogramPinSecurity.js +64 -0
  20. package/lib/commonjs/components/pictograms/svg/PictogramPinSecurity.js.map +1 -0
  21. package/lib/commonjs/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
  22. package/lib/commonjs/components/toast/ToastProvider.js +1 -5
  23. package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
  24. package/lib/module/components/banner/BannerErrorState.js +3 -2
  25. package/lib/module/components/banner/BannerErrorState.js.map +1 -1
  26. package/lib/module/components/buttons/__test__/button.test.js +13 -9
  27. package/lib/module/components/buttons/__test__/button.test.js.map +1 -1
  28. package/lib/module/components/buttons/index.js +0 -3
  29. package/lib/module/components/buttons/index.js.map +1 -1
  30. package/lib/module/components/listitems/ListItemHeader.js +3 -2
  31. package/lib/module/components/listitems/ListItemHeader.js.map +1 -1
  32. package/lib/module/components/listitems/ListItemInfo.js +3 -2
  33. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  34. package/lib/module/components/modules/ModuleCheckout.js +3 -2
  35. package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
  36. package/lib/module/components/otpInput/BoxedInput.js +6 -2
  37. package/lib/module/components/otpInput/BoxedInput.js.map +1 -1
  38. package/lib/module/components/otpInput/OTPInput.js +3 -1
  39. package/lib/module/components/otpInput/OTPInput.js.map +1 -1
  40. package/lib/module/components/pictograms/Pictogram.js +2 -0
  41. package/lib/module/components/pictograms/Pictogram.js.map +1 -1
  42. package/lib/module/components/pictograms/svg/PictogramPinSecurity.js +59 -0
  43. package/lib/module/components/pictograms/svg/PictogramPinSecurity.js.map +1 -0
  44. package/lib/module/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
  45. package/lib/module/components/toast/ToastProvider.js +2 -6
  46. package/lib/module/components/toast/ToastProvider.js.map +1 -1
  47. package/lib/typescript/components/banner/BannerErrorState.d.ts.map +1 -1
  48. package/lib/typescript/components/buttons/index.d.ts +0 -3
  49. package/lib/typescript/components/buttons/index.d.ts.map +1 -1
  50. package/lib/typescript/components/listitems/ListItemHeader.d.ts +2 -2
  51. package/lib/typescript/components/listitems/ListItemHeader.d.ts.map +1 -1
  52. package/lib/typescript/components/listitems/ListItemInfo.d.ts +2 -2
  53. package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
  54. package/lib/typescript/components/otpInput/BoxedInput.d.ts.map +1 -1
  55. package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
  56. package/lib/typescript/components/pictograms/Pictogram.d.ts +1 -0
  57. package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
  58. package/lib/typescript/components/pictograms/svg/PictogramPinSecurity.d.ts +5 -0
  59. package/lib/typescript/components/pictograms/svg/PictogramPinSecurity.d.ts.map +1 -0
  60. package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/src/components/banner/BannerErrorState.tsx +7 -2
  63. package/src/components/buttons/__test__/button.test.tsx +15 -13
  64. package/src/components/buttons/index.tsx +0 -3
  65. package/src/components/listitems/ListItemHeader.tsx +3 -3
  66. package/src/components/listitems/ListItemInfo.tsx +4 -3
  67. package/src/components/modules/ModuleCheckout.tsx +2 -2
  68. package/src/components/otpInput/BoxedInput.tsx +7 -2
  69. package/src/components/otpInput/OTPInput.tsx +7 -1
  70. package/src/components/pictograms/Pictogram.tsx +2 -0
  71. package/src/components/pictograms/svg/PictogramPinSecurity.tsx +44 -0
  72. package/src/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
  73. package/src/components/toast/ToastProvider.tsx +1 -13
  74. package/lib/commonjs/components/buttons/ButtonLink.js +0 -157
  75. package/lib/commonjs/components/buttons/ButtonLink.js.map +0 -1
  76. package/lib/commonjs/components/buttons/ButtonOutline.js +0 -173
  77. package/lib/commonjs/components/buttons/ButtonOutline.js.map +0 -1
  78. package/lib/commonjs/components/buttons/ButtonSolid.js +0 -194
  79. package/lib/commonjs/components/buttons/ButtonSolid.js.map +0 -1
  80. package/lib/module/components/buttons/ButtonLink.js +0 -152
  81. package/lib/module/components/buttons/ButtonLink.js.map +0 -1
  82. package/lib/module/components/buttons/ButtonOutline.js +0 -168
  83. package/lib/module/components/buttons/ButtonOutline.js.map +0 -1
  84. package/lib/module/components/buttons/ButtonSolid.js +0 -188
  85. package/lib/module/components/buttons/ButtonSolid.js.map +0 -1
  86. package/lib/typescript/components/buttons/ButtonLink.d.ts +0 -36
  87. package/lib/typescript/components/buttons/ButtonLink.d.ts.map +0 -1
  88. package/lib/typescript/components/buttons/ButtonOutline.d.ts +0 -26
  89. package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +0 -1
  90. package/lib/typescript/components/buttons/ButtonSolid.d.ts +0 -52
  91. package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +0 -1
  92. package/src/components/buttons/ButtonLink.tsx +0 -222
  93. package/src/components/buttons/ButtonOutline.tsx +0 -261
  94. package/src/components/buttons/ButtonSolid.tsx +0 -285
@@ -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;